I just added a CompressionUtils class which uses ByteArray on the Flash side 
and pako on the javascript side.

It uses inject_html to link to the js because I don’t know of a better way to 
currently do this.

I don’t like this approach for a number of reasons:
1. It hardwires the link into the generated HTML. In this case it’s using the 
“best” cdn, but it does not allow the content to be hosted on the app server.
2. There’s no (easy) way to link to relative paths when an app is being loaded 
locally. Requiring it be downloaded from the internet is inefficient, and does 
not allow the app to be run when there’s no internet connection.
3. This will not work for Node.js. Node.js needs require(‘pako’) instead of 
linking to the script.

Here’s what I’m thinking: I’d like to have a “Require” tag which would cause 
FlaconJX to do the right thing depending on the compilation. If it’s compiling 
for Node.js, it would require() the dependency. If it’s compiling for the 
browser, it would link to a relative path if that path exists (there would be 
some standardized way of linking) or to a url if not (assuming a url is 
provided).

I don’t really care what the require tag looks like, but I personally like 
metadata over the comment approach. It could also be a function call which the 
compiler recognizes as a “special” one which gets optimized out.

So something like this:

[Require(name=“pako", 
url="https://cdnjs.cloudflare.com/ajax/libs/pako/1.0.3/pako.min.js”)]

or:
/**
* @require pako, https://cdnjs.cloudflare.com/ajax/libs/pako/1.0.3/pako.min.js 
<https://cdnjs.cloudflare.com/ajax/libs/pako/1.0.3/pako.min.js>
*/
or:
require(‘pako’,'https://cdnjs.cloudflare.com/ajax/libs/pako/1.0.3/pako.min.js' 
<https://cdnjs.cloudflare.com/ajax/libs/pako/1.0.3/pako.min.js'>);
where the signature for require would be:
require(name:String,url:String=“”)

Thoughts?
Harbs

Reply via email to