You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@royale.apache.org by Carlos Rovira <ca...@apache.org> on 2019/06/03 17:25:12 UTC

Last blog example: Using external javascript libraries in Apache Royale

Hi Andrew!

just finished the last blog example, could you please take a look and fix
whatever aggression against the English language that may have been
committed? :)

https://royale.codeoscopic.com/using-external-javascript-libraries-in-apache-royale/

To the rest of folks: please let me know if you thing something is wrong or
must be modified in some way.

thanks in advance


-- 
Carlos Rovira
http://about.me/carlosrovira

Re: Last blog example: Using external javascript libraries in Apache Royale

Posted by Carlos Rovira <ca...@apache.org>.
Hi Jude!

El lun., 3 jun. 2019 a las 22:32, QA (<fl...@gmail.com>) escribió:

> Great job! :) I have a few comments:
>

thanks!


>
> In the introduction I would add at the end, "It also allows an IDE to
> provide code completion, type checking, etc." You mention the advantages
> later in the post.
>
>
added! :)


> />Note: Currently the inject_html injection only works if your @externs
> class is located in a Royale library. It will not work if is located in
> the application project./
>
> Does that mean my externs class in my project directory, src, will work
> but it cannot add html to the template? Do I need to move my AS class
> somewhere else, or manually add the script tags to my template or is
> this a temporary issue that will be fixed in the future?
>

I think this is a temporary issue that will be fixed sometime. I asked for
help
so I can know where I could look to fix it, since it's not clear to me.
Maybe others like Alex or Josh could give a hand here or take directly a
look.


>
> In the example, the *hljs* class is not declared locally in the project
> because it is declared already in Royale. Does that mean it is available
> via code hinting automatically?
>

Is available in Jewel, so if you have Jewel added (that use to be since is
an official Royale lib)
you'll have it.


>
> When I create my extern classes for my own project where do I put them?
>

in a library project, like a did in jewel library project


>
> What is the code component? Does that a code tag?
>

I don't understand that question... the code of hljs.as is posted in the
example text.
and for code tag, it can't be used that way since it doesn't implement the
IMXMLDocument interface
you need to make a component that support that feature.


>
> Is it possible in the example code you use to remove the large comment
> at the top? :)
>

I prefer not to do it since is official Royale project, and it's been
shared there as is, so
I think I should not do it, sorry :(

Thanks! :)


>
> Jude
>
> On 6/3/19 1:25 PM, Carlos Rovira wrote:
> > Hi Andrew!
> >
> > just finished the last blog example, could you please take a look and fix
> > whatever aggression against the English language that may have been
> > committed? :)
> >
> >
> https://royale.codeoscopic.com/using-external-javascript-libraries-in-apache-royale/
> >
> > To the rest of folks: please let me know if you thing something is wrong
> or
> > must be modified in some way.
> >
> > thanks in advance
> >
> >
>


-- 
Carlos Rovira
http://about.me/carlosrovira

Re: Last blog example: Using external javascript libraries in Apache Royale

Posted by QA <fl...@gmail.com>.
Great job! :) I have a few comments:

In the introduction I would add at the end, "It also allows an IDE to 
provide code completion, type checking, etc." You mention the advantages 
later in the post.

/>Note: Currently the inject_html injection only works if your @externs 
class is located in a Royale library. It will not work if is located in 
the application project./

Does that mean my externs class in my project directory, src, will work 
but it cannot add html to the template? Do I need to move my AS class 
somewhere else, or manually add the script tags to my template or is 
this a temporary issue that will be fixed in the future?

In the example, the *hljs* class is not declared locally in the project 
because it is declared already in Royale. Does that mean it is available 
via code hinting automatically?

When I create my extern classes for my own project where do I put them?

What is the code component? Does that a code tag?

Is it possible in the example code you use to remove the large comment 
at the top? :)

Jude

On 6/3/19 1:25 PM, Carlos Rovira wrote:
> Hi Andrew!
>
> just finished the last blog example, could you please take a look and fix
> whatever aggression against the English language that may have been
> committed? :)
>
> https://royale.codeoscopic.com/using-external-javascript-libraries-in-apache-royale/
>
> To the rest of folks: please let me know if you thing something is wrong or
> must be modified in some way.
>
> thanks in advance
>
>

Re: Last blog example: Using external javascript libraries in Apache Royale

Posted by Kenny Lerma <ke...@kennylerma.com>.
Thank you Josh, that's just the information I was looking for.  I'm getting
away with currently because I'm using "WHITESPACE_ONLY" currently, so no
re-naming.

I'm using WHITESPACE_ONLY since I'm loading multiple different apps at
runtime that share the same base code in a separate JS file.  Basically,
just like loading swf files at runtime only with JS files instead.

Kenny

On Mon, Jun 3, 2019 at 3:00 PM Josh Tynjala <jo...@apache.org> wrote:

> COMPILE::JS should not be necessary, but if you're targeting JS, you
> should add the doc comment with the @externs tag. By default, Royale uses
> the Google Closure compiler, which aggressively renames properties and
> methods to make the generated code smaller. The @externs tag tells it not
> to rename any of the APIs on that particular class. If you have an external
> JS library included with <script>, you want to avoid this renaming or your
> calls to the external library will fail.
>
> Now, I saw that you said that you don't have the @externs tag, and things
> are working fine. It's worth mentioning that Closure compiler sometimes
> skips this renaming (I'm not sure why, but maybe it depends on your app's
> complexity). In the future, your code may cross some threshold where
> Clsoure compiler decides that it has changed its mind and wants to do the
> renaming after all, and suddenly your code that was working correctly will
> break. I had that happen a month or two ago. Code that was working for over
> a year suddenly had a couple of APIs renamed in the generated JS and it
> took me half an hour to realize it was because I had forgotten @externs on
> code that I hadn't touched in a very long time.
>
> (There's also a way to pass a certain compiler option through Royale to
> Closure compiler to disable the "ADVANCED_OPTIMIZATIONS" that handles the
> renaming. If you happen to be using the "SIMPLE_OPTIMIZATIONS" instead, you
> can probably get away with skipping @externs. I don't think many people are
> using this option, but it's worth mentioning as another possible reason why
> you might not have had an issue when @externs is missing.)
>
> - Josh
>
> On 2019/06/03 17:36:56, Kenny Lerma <ke...@kennylerma.com> wrote:
> > Looking at the demo, I noticed you added @externs and COMPILE::JS?  Is
> this
> > necessary?
> > I'm just curious since the ActionsScript I've done for creating external
> JS
> > code completion and SWC files too, I'm not adding these.
> >
> > Kenny
> >
> > On Mon, Jun 3, 2019 at 12:25 PM Carlos Rovira <ca...@apache.org>
> > wrote:
> >
> > > Hi Andrew!
> > >
> > > just finished the last blog example, could you please take a look and
> fix
> > > whatever aggression against the English language that may have been
> > > committed? :)
> > >
> > >
> > >
> https://royale.codeoscopic.com/using-external-javascript-libraries-in-apache-royale/
> > >
> > > To the rest of folks: please let me know if you thing something is
> wrong or
> > > must be modified in some way.
> > >
> > > thanks in advance
> > >
> > >
> > > --
> > > Carlos Rovira
> > > http://about.me/carlosrovira
> > >
> >
>

Re: Last blog example: Using external javascript libraries in Apache Royale

Posted by Josh Tynjala <jo...@apache.org>.
COMPILE::JS should not be necessary, but if you're targeting JS, you should add the doc comment with the @externs tag. By default, Royale uses the Google Closure compiler, which aggressively renames properties and methods to make the generated code smaller. The @externs tag tells it not to rename any of the APIs on that particular class. If you have an external JS library included with <script>, you want to avoid this renaming or your calls to the external library will fail.

Now, I saw that you said that you don't have the @externs tag, and things are working fine. It's worth mentioning that Closure compiler sometimes skips this renaming (I'm not sure why, but maybe it depends on your app's complexity). In the future, your code may cross some threshold where Clsoure compiler decides that it has changed its mind and wants to do the renaming after all, and suddenly your code that was working correctly will break. I had that happen a month or two ago. Code that was working for over a year suddenly had a couple of APIs renamed in the generated JS and it took me half an hour to realize it was because I had forgotten @externs on code that I hadn't touched in a very long time.

(There's also a way to pass a certain compiler option through Royale to Closure compiler to disable the "ADVANCED_OPTIMIZATIONS" that handles the renaming. If you happen to be using the "SIMPLE_OPTIMIZATIONS" instead, you can probably get away with skipping @externs. I don't think many people are using this option, but it's worth mentioning as another possible reason why you might not have had an issue when @externs is missing.)

- Josh

On 2019/06/03 17:36:56, Kenny Lerma <ke...@kennylerma.com> wrote: 
> Looking at the demo, I noticed you added @externs and COMPILE::JS?  Is this
> necessary?
> I'm just curious since the ActionsScript I've done for creating external JS
> code completion and SWC files too, I'm not adding these.
> 
> Kenny
> 
> On Mon, Jun 3, 2019 at 12:25 PM Carlos Rovira <ca...@apache.org>
> wrote:
> 
> > Hi Andrew!
> >
> > just finished the last blog example, could you please take a look and fix
> > whatever aggression against the English language that may have been
> > committed? :)
> >
> >
> > https://royale.codeoscopic.com/using-external-javascript-libraries-in-apache-royale/
> >
> > To the rest of folks: please let me know if you thing something is wrong or
> > must be modified in some way.
> >
> > thanks in advance
> >
> >
> > --
> > Carlos Rovira
> > http://about.me/carlosrovira
> >
> 

Re: Last blog example: Using external javascript libraries in Apache Royale

Posted by Carlos Rovira <ca...@apache.org>.
Great Andrew!

Many thanks, I'll be pushing to public in the next hours or so. :)

El lun., 3 jun. 2019 a las 20:40, Andrew Wetmore (<co...@gmail.com>)
escribió:

> @Carlos Rovira <ca...@apache.org>  I have updated the blog entry
> with a few teeny tiny corrections. It seems very clear, and is a useful
> guide!
>
> On Mon, Jun 3, 2019 at 3:19 PM Kenny Lerma <ke...@kennylerma.com> wrote:
>
>> Thank Piotr.  I am only working with JS so that makes sense.  I just
>> wanted
>> to make sure I didn't need to add these for some other reason.
>>
>> Thanks,
>> Kenny
>>
>> On Mon, Jun 3, 2019 at 1:07 PM Piotr Zarzycki <pi...@gmail.com>
>> wrote:
>>
>> > Hi Kenny,
>> >
>> > I think it may not be necessary in your app when you build to JS only.
>> >
>> > If there is any different type of compilation - now to swf - you need to
>> > surround your JS related code with COMPILE::JS
>> >
>> > Thanks,
>> > Piotr
>> >
>> >
>> > On Mon, Jun 3, 2019, 7:37 PM Kenny Lerma <ke...@kennylerma.com> wrote:
>> >
>> > > Looking at the demo, I noticed you added @externs and COMPILE::JS?  Is
>> > this
>> > > necessary?
>> > > I'm just curious since the ActionsScript I've done for creating
>> external
>> > JS
>> > > code completion and SWC files too, I'm not adding these.
>> > >
>> > > Kenny
>> > >
>> > > On Mon, Jun 3, 2019 at 12:25 PM Carlos Rovira <
>> carlosrovira@apache.org>
>> > > wrote:
>> > >
>> > > > Hi Andrew!
>> > > >
>> > > > just finished the last blog example, could you please take a look
>> and
>> > fix
>> > > > whatever aggression against the English language that may have been
>> > > > committed? :)
>> > > >
>> > > >
>> > > >
>> > >
>> >
>> https://royale.codeoscopic.com/using-external-javascript-libraries-in-apache-royale/
>> > > >
>> > > > To the rest of folks: please let me know if you thing something is
>> > wrong
>> > > or
>> > > > must be modified in some way.
>> > > >
>> > > > thanks in advance
>> > > >
>> > > >
>> > > > --
>> > > > Carlos Rovira
>> > > > http://about.me/carlosrovira
>> > > >
>> > >
>> >
>>
>
>
> --
> Andrew Wetmore
>
> http://cottage14.blogspot.com/
>
>
>
>
>

-- 
Carlos Rovira
http://about.me/carlosrovira

Re: Last blog example: Using external javascript libraries in Apache Royale

Posted by Andrew Wetmore <co...@gmail.com>.
@Carlos Rovira <ca...@apache.org>  I have updated the blog entry
with a few teeny tiny corrections. It seems very clear, and is a useful
guide!

On Mon, Jun 3, 2019 at 3:19 PM Kenny Lerma <ke...@kennylerma.com> wrote:

> Thank Piotr.  I am only working with JS so that makes sense.  I just wanted
> to make sure I didn't need to add these for some other reason.
>
> Thanks,
> Kenny
>
> On Mon, Jun 3, 2019 at 1:07 PM Piotr Zarzycki <pi...@gmail.com>
> wrote:
>
> > Hi Kenny,
> >
> > I think it may not be necessary in your app when you build to JS only.
> >
> > If there is any different type of compilation - now to swf - you need to
> > surround your JS related code with COMPILE::JS
> >
> > Thanks,
> > Piotr
> >
> >
> > On Mon, Jun 3, 2019, 7:37 PM Kenny Lerma <ke...@kennylerma.com> wrote:
> >
> > > Looking at the demo, I noticed you added @externs and COMPILE::JS?  Is
> > this
> > > necessary?
> > > I'm just curious since the ActionsScript I've done for creating
> external
> > JS
> > > code completion and SWC files too, I'm not adding these.
> > >
> > > Kenny
> > >
> > > On Mon, Jun 3, 2019 at 12:25 PM Carlos Rovira <carlosrovira@apache.org
> >
> > > wrote:
> > >
> > > > Hi Andrew!
> > > >
> > > > just finished the last blog example, could you please take a look and
> > fix
> > > > whatever aggression against the English language that may have been
> > > > committed? :)
> > > >
> > > >
> > > >
> > >
> >
> https://royale.codeoscopic.com/using-external-javascript-libraries-in-apache-royale/
> > > >
> > > > To the rest of folks: please let me know if you thing something is
> > wrong
> > > or
> > > > must be modified in some way.
> > > >
> > > > thanks in advance
> > > >
> > > >
> > > > --
> > > > Carlos Rovira
> > > > http://about.me/carlosrovira
> > > >
> > >
> >
>


-- 
Andrew Wetmore

http://cottage14.blogspot.com/

Re: Last blog example: Using external javascript libraries in Apache Royale

Posted by Kenny Lerma <ke...@kennylerma.com>.
Thank Piotr.  I am only working with JS so that makes sense.  I just wanted
to make sure I didn't need to add these for some other reason.

Thanks,
Kenny

On Mon, Jun 3, 2019 at 1:07 PM Piotr Zarzycki <pi...@gmail.com>
wrote:

> Hi Kenny,
>
> I think it may not be necessary in your app when you build to JS only.
>
> If there is any different type of compilation - now to swf - you need to
> surround your JS related code with COMPILE::JS
>
> Thanks,
> Piotr
>
>
> On Mon, Jun 3, 2019, 7:37 PM Kenny Lerma <ke...@kennylerma.com> wrote:
>
> > Looking at the demo, I noticed you added @externs and COMPILE::JS?  Is
> this
> > necessary?
> > I'm just curious since the ActionsScript I've done for creating external
> JS
> > code completion and SWC files too, I'm not adding these.
> >
> > Kenny
> >
> > On Mon, Jun 3, 2019 at 12:25 PM Carlos Rovira <ca...@apache.org>
> > wrote:
> >
> > > Hi Andrew!
> > >
> > > just finished the last blog example, could you please take a look and
> fix
> > > whatever aggression against the English language that may have been
> > > committed? :)
> > >
> > >
> > >
> >
> https://royale.codeoscopic.com/using-external-javascript-libraries-in-apache-royale/
> > >
> > > To the rest of folks: please let me know if you thing something is
> wrong
> > or
> > > must be modified in some way.
> > >
> > > thanks in advance
> > >
> > >
> > > --
> > > Carlos Rovira
> > > http://about.me/carlosrovira
> > >
> >
>

Re: Last blog example: Using external javascript libraries in Apache Royale

Posted by Carlos Rovira <ca...@apache.org>.
Hi Kenny,

I understand that you are not using "window" object, but you're talking
about "tags" in htjs.as. You refer to <inject_html>?

ITOH, for example If I remove the stub as3 classes for hljs and
dialogPolyfill in Jewel library and try to compile I get this:

/Users/carlosrovira/Dev/Royale/Source/royale-asjs/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/Alert.as(225):
col: 7 Access of possibly undefined property dialogPolyfill.


dialogPolyfill.registerDialog(dialog);

So in Alert.as this is failing:

if (!("showModal" in dialog))
                    {
                        dialogPolyfill.registerDialog(dialog); <----- line
225
                    }





El lun., 3 jun. 2019 a las 20:07, Piotr Zarzycki (<pi...@gmail.com>)
escribió:

> Hi Kenny,
>
> I think it may not be necessary in your app when you build to JS only.
>
> If there is any different type of compilation - now to swf - you need to
> surround your JS related code with COMPILE::JS
>
> Thanks,
> Piotr
>
>
> On Mon, Jun 3, 2019, 7:37 PM Kenny Lerma <ke...@kennylerma.com> wrote:
>
> > Looking at the demo, I noticed you added @externs and COMPILE::JS?  Is
> this
> > necessary?
> > I'm just curious since the ActionsScript I've done for creating external
> JS
> > code completion and SWC files too, I'm not adding these.
> >
> > Kenny
> >
> > On Mon, Jun 3, 2019 at 12:25 PM Carlos Rovira <ca...@apache.org>
> > wrote:
> >
> > > Hi Andrew!
> > >
> > > just finished the last blog example, could you please take a look and
> fix
> > > whatever aggression against the English language that may have been
> > > committed? :)
> > >
> > >
> > >
> >
> https://royale.codeoscopic.com/using-external-javascript-libraries-in-apache-royale/
> > >
> > > To the rest of folks: please let me know if you thing something is
> wrong
> > or
> > > must be modified in some way.
> > >
> > > thanks in advance
> > >
> > >
> > > --
> > > Carlos Rovira
> > > http://about.me/carlosrovira
> > >
> >
>


-- 
Carlos Rovira
http://about.me/carlosrovira

Re: Last blog example: Using external javascript libraries in Apache Royale

Posted by Piotr Zarzycki <pi...@gmail.com>.
Hi Kenny,

I think it may not be necessary in your app when you build to JS only.

If there is any different type of compilation - now to swf - you need to
surround your JS related code with COMPILE::JS

Thanks,
Piotr


On Mon, Jun 3, 2019, 7:37 PM Kenny Lerma <ke...@kennylerma.com> wrote:

> Looking at the demo, I noticed you added @externs and COMPILE::JS?  Is this
> necessary?
> I'm just curious since the ActionsScript I've done for creating external JS
> code completion and SWC files too, I'm not adding these.
>
> Kenny
>
> On Mon, Jun 3, 2019 at 12:25 PM Carlos Rovira <ca...@apache.org>
> wrote:
>
> > Hi Andrew!
> >
> > just finished the last blog example, could you please take a look and fix
> > whatever aggression against the English language that may have been
> > committed? :)
> >
> >
> >
> https://royale.codeoscopic.com/using-external-javascript-libraries-in-apache-royale/
> >
> > To the rest of folks: please let me know if you thing something is wrong
> or
> > must be modified in some way.
> >
> > thanks in advance
> >
> >
> > --
> > Carlos Rovira
> > http://about.me/carlosrovira
> >
>

Re: Last blog example: Using external javascript libraries in Apache Royale

Posted by Kenny Lerma <ke...@kennylerma.com>.
I was referencing the tags you are adding to the ActionScript class "hljs.as".
I personally never use the window[""] route.

I'm just wondering why you need those specific tags in you actionscript.  I
don't use those tags and it still works.

On Mon, Jun 3, 2019 at 12:49 PM Carlos Rovira <ca...@apache.org>
wrote:

> Hi Kenny,
>
> I added two options:
>
> 1 .- through @externs
> 2 .- through bracket access.
>
> Maybe you're using 2 instead of 1?
> I was using that until now though windows js object, but I think is not
> what we want to expose or advertise in Apache Royale right?
>
> Please let me know, if I'm missing something, or there's more options that
> I'm not aware of. If that's the case, I can update the post to reflect
> that.
> If so please let me know some example so I can try it.
>
> thanks!
>
>
>
> El lun., 3 jun. 2019 a las 19:37, Kenny Lerma (<ke...@kennylerma.com>)
> escribió:
>
> > Looking at the demo, I noticed you added @externs and COMPILE::JS?  Is
> this
> > necessary?
> > I'm just curious since the ActionsScript I've done for creating external
> JS
> > code completion and SWC files too, I'm not adding these.
> >
> > Kenny
> >
> > On Mon, Jun 3, 2019 at 12:25 PM Carlos Rovira <ca...@apache.org>
> > wrote:
> >
> > > Hi Andrew!
> > >
> > > just finished the last blog example, could you please take a look and
> fix
> > > whatever aggression against the English language that may have been
> > > committed? :)
> > >
> > >
> > >
> >
> https://royale.codeoscopic.com/using-external-javascript-libraries-in-apache-royale/
> > >
> > > To the rest of folks: please let me know if you thing something is
> wrong
> > or
> > > must be modified in some way.
> > >
> > > thanks in advance
> > >
> > >
> > > --
> > > Carlos Rovira
> > > http://about.me/carlosrovira
> > >
> >
>
>
> --
> Carlos Rovira
> http://about.me/carlosrovira
>

Re: Last blog example: Using external javascript libraries in Apache Royale

Posted by Carlos Rovira <ca...@apache.org>.
Hi Kenny,

I added two options:

1 .- through @externs
2 .- through bracket access.

Maybe you're using 2 instead of 1?
I was using that until now though windows js object, but I think is not
what we want to expose or advertise in Apache Royale right?

Please let me know, if I'm missing something, or there's more options that
I'm not aware of. If that's the case, I can update the post to reflect that.
If so please let me know some example so I can try it.

thanks!



El lun., 3 jun. 2019 a las 19:37, Kenny Lerma (<ke...@kennylerma.com>)
escribió:

> Looking at the demo, I noticed you added @externs and COMPILE::JS?  Is this
> necessary?
> I'm just curious since the ActionsScript I've done for creating external JS
> code completion and SWC files too, I'm not adding these.
>
> Kenny
>
> On Mon, Jun 3, 2019 at 12:25 PM Carlos Rovira <ca...@apache.org>
> wrote:
>
> > Hi Andrew!
> >
> > just finished the last blog example, could you please take a look and fix
> > whatever aggression against the English language that may have been
> > committed? :)
> >
> >
> >
> https://royale.codeoscopic.com/using-external-javascript-libraries-in-apache-royale/
> >
> > To the rest of folks: please let me know if you thing something is wrong
> or
> > must be modified in some way.
> >
> > thanks in advance
> >
> >
> > --
> > Carlos Rovira
> > http://about.me/carlosrovira
> >
>


-- 
Carlos Rovira
http://about.me/carlosrovira

Re: Last blog example: Using external javascript libraries in Apache Royale

Posted by Kenny Lerma <ke...@kennylerma.com>.
Looking at the demo, I noticed you added @externs and COMPILE::JS?  Is this
necessary?
I'm just curious since the ActionsScript I've done for creating external JS
code completion and SWC files too, I'm not adding these.

Kenny

On Mon, Jun 3, 2019 at 12:25 PM Carlos Rovira <ca...@apache.org>
wrote:

> Hi Andrew!
>
> just finished the last blog example, could you please take a look and fix
> whatever aggression against the English language that may have been
> committed? :)
>
>
> https://royale.codeoscopic.com/using-external-javascript-libraries-in-apache-royale/
>
> To the rest of folks: please let me know if you thing something is wrong or
> must be modified in some way.
>
> thanks in advance
>
>
> --
> Carlos Rovira
> http://about.me/carlosrovira
>