On 6/23/15, 8:53 AM, "Frédéric THOMAS" <webdoubl...@hotmail.com> wrote:
>
>Playing with the externs, we've seen that in order to customize our
>index.html (adding a Script tag for JQuery for example) we had to create
>another index.html outside the build folder referencing our main .js
>because the original one was overridden each time we built, so, instead
>of doing that, I was looking for a way to write our Script tag from AS
>which is not possible at the moment and we haven't got a template index
>to use neither.
>
>ok, IIUC, the goal of having externs is to ease the implementation of
>as/js components giving the possibility to implement them in AS and use
>the generated JS as JS source of the new FlexJS component, so, we can, in
>the generated JS, add a comment to load a JS Script or CS.
>
>But still, if I look at the jQuerySample.mxml, I can see something that
>should be done at each build, not every user friendly:
><!--
>    To make this sample work, please add the following lines to the
>index.html
>    
>    <link rel="stylesheet"
>href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css"; />
>    <script src="http://code.jquery.com/jquery-1.9.1.js";></script>
>    <script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js";></script>
>    -->
>
>So, my goal was to simplify link and script tags either making them
>accessible from the AS via a MataTag for example or having an utility
>class to download dynamically those resources and add them to the head of
>the html application container.
>
>Am I clearer ? Did I miss something ? Is that a bad direction ?

Yeah, I think I get it.  Actually, that comment in JQuerySample.mxml is
obsolete.  The org.apache.flex.jquery.Application.js has <inject_html>
tags in a comment in that file, and GoogDepsWriter.java and
MXMLFlexJSPublisher.java find it and add it to the index.html.  That is
how FlexJS handles bootstrapping JS frameworks.

It just occurred to me that you can’t use this sort of mechanism because
none of the JS or AS actually gets baked into the final JS so there will
never be an <inject_html> tag found by the scan.

The reason it works for FlexJS is because some non-extern class like
Application has to be used in the app.  If you create your own Jquery
Application that folks must subclass in their apps then you can use the
same mechanism.  Otherwise, you probably need to invent a new mechanism.

One idea I considered was this:  Right now in any SDK there is a
flex-config.xml and an air-config.xml and often an airmobile-config.xml.
These configs specify a set of libraries and other settings.  We could
create a js-config.xml and jquery-config.xml and figure out a way to tell
the compiler in the -config.xml what to inject into the .html.  Then in FB
and elsewhere, you can switch by adding +configname=js or
+configname=jquery just like we do +configname=air

I’m sure there are other ways as well.

Thoughts?
-Alex


Reply via email to