royale-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Harui <aha...@adobe.com.INVALID>
Subject Re: Struggling with resource files
Date Wed, 04 Oct 2017 03:35:49 GMT
Hi Nicolas,

Thanks for the ideas.

A Class in JS is not a binary value, so ClassReference just link in the JS
for the class and resolves to the class reference at runtime.  We are not
currently supporting embedded images, so images are just URLs to external
images right now.

We haven't worried about inflate/deflate and other compression of the
output.  I'm not quite sure how it works, but I thought the servers and
browsers agreed to compress the transfer over the wire and we didn't have
to do anything.

We'll write an AppLoadingProgressBar when someone write a big enough and
slow enough app to need one ;-)

There can be PAYG in the sense that if you don't need resource modules you
don't need a ResourceManager with such code.  And we could output resource
bundles that lazily instantiate themselves on-demand.

Regarding Herbs suggestion:  for Flash, when you had a sequential lookup
like in CSS and locale chains (look here, then over here if you didn't
find it, then over here if you still didn't find it, etc) it turned out to
be much faster to use prototype chain lookups than write and run a lookup
in AS.  So we will likely use functions and objects and protochains and
I'm unclear how storing in LocalStorage would help.

But we'll find out as soon as someone finds the time to code it up.

My 2 cents,
-Alex

On 10/3/17, 3:57 PM, "Idylog - Nicolas Granon" <ngranon@idylog.com> wrote:

>I'm not an expert, but I feel that a plain JS object is conceptually
>closer to the SWF way.
>That said, I have no idea on how a binary value (Class, Image) could be
>stored in such an object (but there are people around there who certainly
>know!). TypedArray maybe ?
>
>I agree that the core ResourceManager class (or IResourceManager
>interface) does not need to have all the dynamic stuff (load, unload
>etc.). That could be optional features.
>
>I wouldn't object if the locales (bundles) specified at compile time are
>"physically" represented in additional js files that must be loaded in
>addition to the main js app even if I understand the delay it implies at
>load time (for business apps, load time is not such an issue but there
>should be some equivalent of "app loader" that shows some progress
>indicator). That is not to say that I oppose "inlined resources" !  I
>just mean that if it makes implementation simpler, it is acceptable for
>our kind of app.
>(those files should be automatically loaded at bootstrap).
>
>As you know, resource modules (resource SWFs) are compressed. Obviously,
>resource strings are strong candidates to compression (GZIP or
>equivalent).
>Is there any provision in FlexJS SDK for inflate/deflate ? That would
>allow much smaller resource bundle files.
>
>To sum it up, (and maybe it will make folks here jump off their seats)
>things could go the following way :
>
>For each locale specified at compile time (-locale argument), the
>compiler could simply create a js file containing all the objects
>corresponding to all the resource bundles coming from (1) the framework,
>(2) the user defined bundles specified by ResourceBundle metatag or
>@resource keyword for the locales that were specified.
>
>At bootstrap, the app would load those files and make the different
>objects available through resource manager.
>(alternatively, one could imagine that additional locales are only loaded
>when necessary, and that only the first locale is loaded at bootstrap. In
>that case, the app loader should be able to "know" which implicit locales
>are available).
>
>I would not be shocked if the "compiled" resource files are in fact
>ordinary SWF files following the SWF resource module spec (maybe they
>should not have a SWF extension !). The compiler is probably already able
>to output that kind of files. The resource manager implementation should
>be able to access the resource rather easily (unzip the file content, get
>the appropriate tag, load the as3 object in a js object, add the js
>object to the dictionary of objects for the given locale).
>
>You will notice that this is not PAYG at all !
>
>I am not sure that PAYG really applies to ResourceManager, which is such
>a central piece. In my foolish suggestion, you will notice that all
>resource bundles are loaded as external files. It somehow implies that
>"on demand" loading shares the same logic, the only difference being
>that, for on-demand, resource loading is explicit.
>
>I understand that you try to have short load delays and do not want to
>embed unnecessary code, but users of Flex apps are used to long loads. We
>are not talking about a web site and a 5-8 seconds load time is usually
>quite acceptable (again : we need some visual preloader showing load
>progress).
>
>Nicolas Granon
>
>
>
>
>> -----Message d'origine-----
>> De : Harbs [mailto:harbs.lists@gmail.com]
>> Envoyé : mardi 3 octobre 2017 00:40
>> À : dev@royale.apache.org
>> Objet : Re: Struggling with resource files
>> 
>> > IMO, it is just a database.
>> 
>> That statement triggered a thought: Why not use sessionStorage or
>> localStorage as a “ResourceManager” in JS?[1]
>> 
>> Alternatively IndexedDB.[2] (although sessionStorage is probably
>> sufficient).
>> 
>> Using localStorage instead of sessionStorage might enable caching.
>> 
>> 
>>[1]https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdevel
>>oper.mozilla.org%2Fen-US%2Fdocs%2FWeb%2FAPI%2FStorage&data=02%7C01%7C%7C8
>>c02d7b750644119fab308d50ab22ce3%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C
>>0%7C636426682742780939&sdata=awPOzRs9dIIIFIOA%2FJAvaekHZvUdg5tXduFlLh%2FL
>>AvA%3D&reserved=0
>> 
>><https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdevelop
>>er.mozilla.org%2Fen-US%2Fdocs%2FWeb%2FAPI%2FStorage&data=02%7C01%7C%7C8c0
>>2d7b750644119fab308d50ab22ce3%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%
>>7C636426682742780939&sdata=awPOzRs9dIIIFIOA%2FJAvaekHZvUdg5tXduFlLh%2FLAv
>>A%3D&reserved=0>
>> 
>>[2]https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdevel
>>oper.mozilla.org%2Fen-US%2Fdocs%2FWeb%2FAPI%2FIndexedDB_API&data=02%7C01%
>>7C%7C8c02d7b750644119fab308d50ab22ce3%7Cfa7b1b5a7b34438794aed2c178decee1%
>>7C0%7C0%7C636426682742780939&sdata=lL7nf%2FZuDsmF1vUb%2FmtwXP9vny015dDMxi
>>CzxgjiuBM%3D&reserved=0
>> 
>><https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdevelop
>>er.mozilla.org%2Fen-US%2Fdocs%2FWeb%2FAPI%2FIndexedDB_API&data=02%7C01%7C
>>%7C8c02d7b750644119fab308d50ab22ce3%7Cfa7b1b5a7b34438794aed2c178decee1%7C
>>0%7C0%7C636426682742780939&sdata=lL7nf%2FZuDsmF1vUb%2FmtwXP9vny015dDMxiCz
>>xgjiuBM%3D&reserved=0>
>> > On Oct 2, 2017, at 9:07 PM, Alex Harui <aharui@adobe.com.INVALID>
>> wrote:
>> >
>> > The Flash runtime doesn't know anything about resources.  In regular
>> > Flex, and Resource Module is a SWF full of compiled Resource Bundles
>> > which are classes that wrap the resource data.  IMO, that's too heavy
>> > for strings and I believe there are many apps where the only things
>> > that change per locale are strings, especially if images are not
>> > embedded and loaded via URLs.
>> >
>> > So, for Royale, for only Strings, I would propose that we teach the
>> > compiler to take the same arguments, but maybe produce JSON or
>> > embedded .properties files.  Not sure which one or both until we see
>> how it works.
>> >
>> > ClassReference already works in CSS files, so I suspect we can make
>> it
>> > work for Resources, but once you introduce ClassReference, JSON and
>> or
>> > embedded strings aren't sufficient, so I think we'd have to produce a
>> > .js file instead.
>> >
>> > A ResourceManager that is fully equivalent of the regular Flex
>> > ResourceManager is not PAYG.  That's why I earlier suggested
>> different
>> > implementations that are PAYG.  The smallest would count on all
>> > resources being inlined.  A fancier one would support loadable
>> resources.
>> >
>> > Today, the CSS information in each SWC is collected at compile time.
>> > Type Selectors are examined to make sure the class they represent is
>> > being linked into the app, and all of that information is encoded.
>> > CSS implementations like SimpleCSSValuesImpl know how to find that
>> > encoded information and turn it into data structures.  I think that
>> is
>> > PAYG, although we could experiment with it doing lazy loading or
>> > just-in-time parsing of the encoded data.
>> >
>> > I think we'd do roughly the same thing for Resources.  Encode the
>> data
>> > as embedded Strings and/or JSON.  Not sure we'd need to wrap a bead
>> > around each bundle or locale.  IMO, it is just a database.  And then
>> > SimpleCSSAndLocalesValuesImpl would know how to look for that data.
>> >
>> > Of course, I could be wrong...
>> > -Alex
>> >
>> > On 10/2/17, 12:24 AM, "Harbs" <harbs.lists@gmail.com
>> <mailto:harbs.lists@gmail.com>> wrote:
>> >
>> >> Thanks for the links.
>> >>
>> >> Some thoughts/questions:
>> >>
>> >> The loading of the resource modules is something handled by the
>> Flash
>> >> runtime, or is that internal to Flex?
>> >>
>> >> Currently, do the compiler options do anything for the JS side of
>> things?
>> >>
>> >> If I understand correctly, the “inlining” option adds the resources
>> >> to the ResourceManager. I’m suggesting the ResourceManager is not
>> >> necessarily needed if locales are configured at compile time. A more
>> >> PAYG way would be to inline the resource directly into a variable of
>> >> a bead which knows what to do with the resource. I don’t see any
>> >> current annotation which could do that (either in MXML or AS).
>> >>
>> >> I don’t see how class references (and image references) could work
>> in
>> >> Royale (in JS). If we could get that working, it would be huge.
>> >>
>> >> Harbs
>> >>
>> >>> On Oct 2, 2017, at 9:57 AM, Alex Harui <aharui@adobe.com.INVALID>
>> wrote:
>> >>>
>> >>> See the Adobe docs: [1][2]
>> >>>
>> >>> I think the functionality you are looking forward is supported by
>> >>> the compiler.  The compiler already has a set of options that
>> >>> dictate what bundles are "inline" in the app and I think they can
>> be
>> >>> re-used to output different things.
>> >>>
>> >>> [ResourceBundle] metadata tells the compiler which bundles to link.
>> >>> The compiler's -locale option dictates which language bundles for
>> >>> the [ResourceBundles] it saw when linking the app need to be baked
>> >>> into the app.  Separately, the ResourceManager in regular Flex has
>> a
>> >>> way to load a SWF of other bundles.  The compiler has options to
>> >>> build a SWF with certain bundles.
>> >>>
>> >>> For JS, JSON might be a good format for a "ResourceModule".
>> >>>
>> >>> I've seen the packages be accepted by Flash Builder on both Mac and
>> >>> Windows.  There's a separate thread about when to merge packaging
>> >>> into develop, and how to do the "big rename".
>> >>>
>> >>> Later,
>> >>> -Alex
>> >>>
>> >>> [1]
>> >>>
>> >>>
>> https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fhelp
>> >>> .adob
>> >>>
>> <https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fhel
>> >>> p.adob> e.com
>> >>>
>> 
>><https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fe.com%2F
>>&data=02%7C01%7C%7C8c02d7b750644119fab308d50ab22ce3%7Cfa7b1b5a7b34438794a
>>ed2c178decee1%7C0%7C0%7C636426682742780939&sdata=sHm%2BiImcsWFoCwQjlhiATF
>>AMQkIaRGLCDLtUPhC00mE%3D&reserved=0>%2Fen_US%2Fflex%2Fusing%2FWS2db454920
>>e96a9e51e63e3d11
>> >>> c0bf69084&data=
>> >>>
>> 02%7C01%7C%7C0889dd3b253c45d9126d08d50966a728%7Cfa7b1b5a7b34438794ae
>> >>> d2c17
>> >>>
>> 8decee1%7C0%7C0%7C636425258895710848&sdata=ovLxTjMA4dcJUbWvTu6JSWF%2
>> >>> F9VH1
>> >>> uciPIthGxL%2FF5H8%3D&reserved=0
>> >>> -7f3a.html
>> >>> [2]
>> >>>
>> >>>
>> https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fhelp
>> >>> .adob
>> >>>
>> <https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fhel
>> >>> p.adob> e.com
>> >>>
>> 
>><https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fe.com%2F
>>&data=02%7C01%7C%7C8c02d7b750644119fab308d50ab22ce3%7Cfa7b1b5a7b34438794a
>>ed2c178decee1%7C0%7C0%7C636426682742780939&sdata=sHm%2BiImcsWFoCwQjlhiATF
>>AMQkIaRGLCDLtUPhC00mE%3D&reserved=0>%2Fen_US%2Fflex%2Fusing%2FWS2db454920
>>e96a9e51e63e3d11
>> >>> c0bf69084&data=
>> >>>
>> 02%7C01%7C%7C0889dd3b253c45d9126d08d50966a728%7Cfa7b1b5a7b34438794ae
>> >>> d2c17
>> >>>
>> 8decee1%7C0%7C0%7C636425258895710848&sdata=ovLxTjMA4dcJUbWvTu6JSWF%2
>> >>> F9VH1
>> >>> uciPIthGxL%2FF5H8%3D&reserved=0
>> >>> -7f3c.html
>> >>>
>> >>> On 10/1/17, 11:34 PM, "Harbs" <harbs.lists@gmail.com> wrote:
>> >>>
>> >>>> I should probably spend some time to learn how resource bundles
>> >>>> worked in Flex… ;-)
>> >>>>
>> >>>> Metadata seems like a good solution, but it seems to me like there
>> >>>> needs to be two sets of metadata tags. Some comments and questions
>> >>>> I have:
>> >>>>
>> >>>> 1. We’d need metadata tags which would just inline the resource
>> >>>> into the compiled code for cases where a full-blown
>> ResourceManager
>> >>>> is overkill.
>> >>>> 2. We’d need the [ResourceBundle] tag for compiling downloadable
>> >>>> resource bundles. What would that look like in Javascript? A JS
>> >>>> file which evaluates to the resources? A JSON file? Would default
>> >>>> resources get auto-included in the main JS?
>> >>>>
>> >>>> BTW, if there’s something I can do to help you with the packaging
>> >>>> branch, please let me know.
>> >>>>
>> >>>> Harbs
>> >>>>
>> >>>>> On Oct 2, 2017, at 2:28 AM, Alex Harui <aharui@adobe.com.INVALID>
>> >>>>> wrote:
>> >>>>>
>> >>>>>
>> >>>>>
>> >>>>> On 10/1/17, 7:31 AM, "Harbs" <harbs.lists@gmail.com> wrote:
>> >>>>>
>> >>>>>> I’d really like for the compiler to include resources
as
>> strings,
>> >>>>>> but I’m not sure what the best way to declare it is.
>> >>>>>>
>> >>>>>> How can we declare a reference to the resource and have
the
>> >>>>>> compiler include it?
>> >>>>>
>> >>>>> Well, that depends...
>> >>>>>
>> >>>>> The [ResourceBundle] metadata and the compiler's -locale option
>> >>>>> seemed to make people happy.  I don't remember any complaints
>> >>>>> about it, my only issue was that it didn't seem to be efficient
>> >>>>> for String-only resources.
>> >>>>> [ResourceBundle] allows the strings to be managed in separate
>> >>>>> .properties files that are packaged with a SWC.  That's probably
>> >>>>> important because you probably don't want to have to list out
>> >>>>> every component's resources as beads in your app.  It probably
>> >>>>> needs to be driven automatically by metadata.
>> >>>>>
>> >>>>> So, if we decide to stick with it, the challenge will be to
teach
>> >>>>> the compiler to do something different with the resource
>> properties.
>> >>>>>
>> >>>>> Thoughts?
>> >>>>> -Alex
>
>

Mime
View raw message