I’m confused. Why does marked() need to be a constructor?
From: Carlos Rovira <[email protected]> Sent: Wednesday, April 15, 2020 11:48:21 AM To: Apache Royale Development <[email protected]> Subject: Problems to create AS3 externs when JS library returns some kind of object Hi, I'm playing with a js markdown library [1] to see if is an option to make a Royale website that load markdown and render it (I'm experimenting to see if we can't remove wordpress from our website and make a web based on markdown similar to royale-docs) I'm having problems trying to create the extern as3 file. I'm trying something similar to what we did with hljs. Here's my try: package { /** * marked js library */ COMPILE::JS public class marked { /** * * <inject_html> * <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script<https://cdn.jsdelivr.net/npm/marked/marked.min.js%22%3e%3c/script>> * </inject_html> * * @royaleignorecoercion String */ public function marked(s:String):String {}; /** * configure marked with options */ public function setOptions(o:Object):void {}; } } The problem is public function marked(s:String):String {}; since the library gets a String and returns a String, but AS3 constructors must be void I remember Josh posted alternative ways to create this kind of AS3 stubs, but he posted in a paste apache that is now gone. Anyway would be good to know if this is a limitation of AS3 language and we can't create this kind of AS3 classes that model a JS library with constructors that return something like a string. Thanks [1] https://marked.js.org/#/README.md#usage -- Carlos Rovira http://about.me/carlosrovira From: Carlos Rovira<mailto:[email protected]> Sent: Wednesday, April 15, 2020 11:48 AM To: Apache Royale Development<mailto:[email protected]> Subject: Problems to create AS3 externs when JS library returns some kind of object Hi, I'm playing with a js markdown library [1] to see if is an option to make a Royale website that load markdown and render it (I'm experimenting to see if we can't remove wordpress from our website and make a web based on markdown similar to royale-docs) I'm having problems trying to create the extern as3 file. I'm trying something similar to what we did with hljs. Here's my try: package { /** * marked js library */ COMPILE::JS public class marked { /** * * <inject_html> * <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script<https://cdn.jsdelivr.net/npm/marked/marked.min.js%22%3e%3c/script>> * </inject_html> * * @royaleignorecoercion String */ public function marked(s:String):String {}; /** * configure marked with options */ public function setOptions(o:Object):void {}; } } The problem is public function marked(s:String):String {}; since the library gets a String and returns a String, but AS3 constructors must be void I remember Josh posted alternative ways to create this kind of AS3 stubs, but he posted in a paste apache that is now gone. Anyway would be good to know if this is a limitation of AS3 language and we can't create this kind of AS3 classes that model a JS library with constructors that return something like a string. Thanks [1] https://marked.js.org/#/README.md#usage -- Carlos Rovira http://about.me/carlosrovira
