JoshMarler / react-juce

Write cross-platform native apps with React.js and JUCE
https://docs.react-juce.dev
MIT License
764 stars 79 forks source link

First pass v8 integration #208

Closed nick-thompson closed 3 years ago

nick-thompson commented 3 years ago

A'ight @JoshMarler this one's for you!

This work is not a branch I intend to merge, at least not in its current state. This is more of a proof-of-concept branch for kicking off the v8 integration behind the EcmascriptEngine interface (#178).

The work here addresses only this:

This is almost there. There is a little more work to satisfy some global shims. The first, which I'll add here shortly, is to shim out more of the BlueprintBackend interface, for which I have a clean approach in mind. The second, is adding polyfills for timers to satisfy the updated React-Reconciler dependency.

Then, of course, there's work to actually persist the v8 isolate and context on the EcmascriptEngine::Pimpl instance (right now I just make the and throw them away inside of evaluate), and start fleshing out the remainder of the interface. My hunch right now is that this will generally be an easier integration than Duktape, which is quite nice!

nick-thompson commented 3 years ago

@JoshMarler I just snuck a little commit onto master: c4274df910bd8195175b305b61dd3b699ee14643. This nudges the way that our react-juce package relies on the global __BlueprintNative__ object, and shims a little Proxy in there when we know that process.env.NODE_ENV !== 'production'. This means that if you do the following:

cd packages/react-juce
npm run watch
cd ../../examples/GainPlugin/jsui
npm install ../../packages/react-juce
npm start

You'll be running GainPlugin's jsui built against react-juce development, where process.env.NODE_ENV === 'development', so the proxy will be shimmed in there. This trick makes the bundle quite portable, so you could drop it in Chrome and run it there or drop it into v8 without injecting all the required native methods.

With that, all that's really left here to get the initial bundle really running is shimming the timers (can just shove some bs code in there for now to get it to run)

nick-thompson commented 3 years ago

@JoshMarler with all of the work going into Hermes and Quickjs lately, I'm going to close this PR out. We can revisit v8 at a later time

JoshMarler commented 3 years ago

Yeah sounds fair enough. Hopefully will have a clean approach to follow now if we come back to it.