Fix broken external link
|3 years ago|
|.vscode||3 years ago|
|app||3 years ago|
|.gitignore||3 years ago|
|CMakeLists.txt||3 years ago|
|LICENSE||3 years ago|
|Makefile||3 years ago|
|README.md||3 years ago|
|dialog.c||3 years ago|
|dialog.h||3 years ago|
|dialog.tpl||3 years ago|
|duk_config.h||3 years ago|
|duk_source_meta.json||3 years ago|
|dukbridge.c||3 years ago|
|dukbridge.h||3 years ago|
|duktape.c||3 years ago|
|duktape.h||3 years ago|
|main.c||3 years ago|
|makeResource.js||3 years ago|
|package.json||3 years ago|
|types.h||3 years ago|
|utils.h||3 years ago|
|yarn.lock||3 years ago|
Macintosh fake-react native
This is a porting of my afternoon experiment to the Macintosh platform
It's based on the work I've done for Windows 3.11 for this twitter thread
You need a build of https://github.com/autc04/Retro68, that includes the Apple Universal Interfaces,
to get those download the image from one of the links, open it in Basilisk and then copy those file back to windows: I used HVFExplorer and I copied them w/out the resource partition, seems to work.
About basilisk, I'm using the windows build, in order to enable the sharing between windows and basilisk I had to add
ignoresegv true to the preference file as it keeps crashing otherwise in Windows 10.
To simplify this step you can find a pce/macplus image linked in this article I personally did not try it but should work fine, but probably you'll need to pull the latest changes from git (recursively).
I used WSL2, you can get this to work fine with WSL1 probably as long as you use a windows shared folder mounted on your linux for using the
launchAPPL utility, otherwise you'll have to use HVFExplorer to copy the executable to the mac image.
If you use the launchAPPL I suggest to make an alias like
alias launchAPPL='/path/to/Retro68/build/build-host/LaunchAPPL/Client/LaunchAPPL -e shared --shared-directory /mnt/c/share'
If you use other emulators such as minivmac2 you can probably use the network share, it doesn't work on Basilisk though.
Ensure the node dependencies are installed by running yarn. I wrote a script to create and embed the sources as mac resources inside the executable resource partition, node wasn't strictly necessary for this, but I still needed babel to convert the JSX to ES3 that can be run in duktape, so that's why it's a nodejs file.
In the Makefile you'll need to edit the path to your Retro68 build, just change the value of
CMAKE_TOOLCHAIN_FILE to the appropriate path.
How does this work?
main.c is just a simple barebone program that initialize everything needed by the mac to start up an application, then it loads duktape a real stack based JS engine that can run the code that babel outputs; the dukbridge file creates 2 duktape native functions that will we use to bridge the JS world to the native world.
First though we load the app/fakeReact.js that creates some globals that we need,
React with its 2 functions
mount, plus a
MessageBox and a
Dialog native components (you might notice that will call some weird
React.duktape. methods, explained later), and two implementation specific things, an empty object property named
duktape, under the
React global to avoid too much pollution, and a
native property that simply maps all the native components, this is used by
React.mount to know if it needs to call the native function or continue rendering; a little note here is that I didn't implement a fully descendant reconciler, it only supports 2 levels, the one needed for the demo, sorry!
Anyway, at this point the
populateCtx in dukbridge.c runs and connects the JS world to the native world by adding the
showMessageBox native functions to
At this point the main setup is done, so the app/index.js is loaded first and the
main function is mounted.