Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changes to make it work on haxe 4 #141

Open
mastef opened this issue Dec 3, 2017 · 2 comments
Open

changes to make it work on haxe 4 #141

mastef opened this issue Dec 3, 2017 · 2 comments

Comments

@mastef
Copy link

mastef commented Dec 3, 2017

When building on haxe 4 you'll get :
src/Api.hx:7: characters 8-25 : Type not found : haxe.web.Dispatch
src/Editor.hx:8: characters 8-17 : Type not found : js.JQuery

This is due to these haxe 4 changes :
all : moved haxe.web.Dispatch into hx3compat library (https://github.com/HaxeFoundation/hx3compat).
js : js.JQuery and js.SWFObject were moved into hx3compat library (https://github.com/HaxeFoundation/hx3compat)

1. Add hx3compat library

In the build.hxml add -lib hx3compat before and after --next

2. Adjust imports due to depreciation

There's a few changes in the source to adapt to the new syntax like changing all instances of :

-import js.JQuery;
+import js.jquery.JQuery;

3. Typing of events :

Change all instances of

-(e : JqEvent)
+(e : js.jquery.Event)

4. The library array had some typing issues :

       if( program.libs != null ){
         for( lib in libs.find("input.lib") ){
-          if( program.libs.has( lib.val() ) ){
-            lib.attr("checked","checked");
+          if( program.libs.has( new JQuery(lib).val() ) ){
+            new JQuery(lib).attr("checked","checked");
           }else{
-            lib.removeAttr("checked");
+            new JQuery(lib).removeAttr("checked");
           }
         }
       }
-                       libs.push(i.val());
+                       libs.push(new JQuery(i).val());

5. Button methods

And I wasn't sure where the .button* methods were defined, as they were missing now. These changes made buttons work for me :

-compileBtn.buttonLoading();
+untyped compileBtn.button('loading');
-      new JQuery(".link-btn, .fullscreen-btn")
-        .buttonReset()
+      untyped new JQuery(".link-btn, .fullscreen-btn")
+        .button('reset')
-               compileBtn.buttonReset();
+               untyped compileBtn.button('reset');

Note : These are not optimal changes, just the ones that made try.haxe work with haxe 4 for me.

@clemos
Copy link
Owner

clemos commented Dec 5, 2017

Thanks ! It would be nice to make a PR with these changes, I would happily merge it :)
Also, please use conditional compilation like :

#if (haxe_ver >= 4)
import js.jquery.JQuery;
#else
import js.JQuery;
#end

As for buttons (5), the bootstrap methods are defined here: https://github.com/clemos/haxe-bootstrap
Weird that they are not available any more.
This is probably related to (4): maybe some JQuery signatures have changed, and compileBtn (or lib) is not typed as JQuery but as Element or something.

@mastef
Copy link
Author

mastef commented Dec 17, 2017

I think that would be okay, but first try.haxe.org should support haxe version switching, right?

Because there are definitely big changes between the current haxe 3 and the upcoming haxe 4 - not sure try.haxe should be fully on haxe 4 yet. Would be nice to be able to switch between rc versions and run code there.

When I made as3hx.spacemages.com based on this repo, I did a Docker approach. Could have multiple haxe versions compiled in the Dockerfile, and then support different haxe versions by switching the command line haxe path.

And yeah, I was confused with the bootstrap buttons - wasn't able to find the methods quickly so hacked it with untyped - that's on me. I'm sure there's a proper way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants