Proof of concept to run React Native - like applications on the classic Macintosh
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Go to file
Cristian Carlesso d3211fb1a2
Fix broken external link
3 years ago
.vscode LOL 3 years ago
app LOL 3 years ago
.gitignore LOL 3 years ago
CMakeLists.txt LOL 3 years ago
LICENSE Initial commit 3 years ago
Makefile LOL 3 years ago Update 3 years ago
dialog.c LOL 3 years ago
dialog.h LOL 3 years ago
dialog.tpl LOL 3 years ago
duk_config.h LOL 3 years ago
duk_source_meta.json LOL 3 years ago
dukbridge.c LOL 3 years ago
dukbridge.h LOL 3 years ago
duktape.c LOL 3 years ago
duktape.h LOL 3 years ago
main.c LOL 3 years ago
makeResource.js LOL 3 years ago
package.json LOL 3 years ago
types.h LOL 3 years ago
utils.h LOL 3 years ago
yarn.lock LOL 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, 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?

The 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 createElement and 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 showDialog and showMessageBox native functions to React.duktape.

At this point the main setup is done, so the app/index.js is loaded first and the main function is mounted.