Skip to content

Conversation

@waterwheels
Copy link
Contributor

Restructured slightly so that openHarmony is used by calling const $ = require("openHarmony.js") instead of include. Each sub-script adds its functions to the exports object, which the main script require()s, and then adds the attributes of to $.

It seems like using include may still work, although I haven't tested this thouroughly yet.

In the current state, it can run the example script and make a car, although there are several errors with cloning nodes (TypeError: ambiguous call of overloaded function setValue(), in ...attribute.js ln695), and with linking nodes that don't seem to impact the car.

TO DO:

  • API functions aren't accessible globally, which they were before (usually). I tried using this.__proto__[classItem] = $[classItem] which I thought would add them to the prototype of the global scope, like the regular API functions, but they ended up as members of the top-level this, so I obviously don't understand what's going on.
  • I haven't thoroughly checked the built in documentation, and I haven't checked peripheral files outside ./openHarmony/*, ./openHarmony.js, and ./examples/openHarmonyExample.js
  • installers still create stubs that use inlcude. I have a funny setup locally, so I haven't gotten around to looking at these yet
  • Testing
    • Some kind of test structure or external package? I am happy to write tests, but probably need examples to follow. I tried writing a simple one as a learning exercise, but it wasn't very good.

Went looking for references to API function that assume the API is available on the global scope or that `$` is accessible, and conformed all found to use `this.$`, the link to `$` that's added to every function member of `$`
when running a script in the sandbox, __file__ is undefined, so trying to look at $ in the debugger errors out when it tries to generate the oH directory. If we use the __file__ it stored when it was required in, we can avoid this error. $.directory is supposed to refer to the oH dir, so I can't think of why this would be a problem
For some reason, `this.$` is undefined for this line, however `this.prototype.$` is. With the debug console I tried to set `this.$ = this.prototype.$`, and it didn't work, it stayed undefined. Then I tried using an intermediary constant, which did work.

Referencing `exports` bypasses the issue.

Is this a different case because we're not instantiating an oPreferences object, so the prototype isn't linked in the same way?
it does seem to add $ to the global __proto__, but I thought it was supposed to make eg `log` or `oNode` accessible globally, and it doesn't seem to
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

Successfully merging this pull request may close these issues.

1 participant