@remix_labs/machine-starter 2.3356.0 → 2.3362.0-dev

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/common.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { GROOVEBOX_BUILD } from "./groovebox_build.js";
2
2
  import { nanoid } from "nanoid";
3
- import { MixcoreTauri, filterFFINames } from "./mixcore.lib.mjs";
3
+ import { createStarterMixcore } from "./mixcore-groovebox-starter.lib.mjs";
4
4
 
5
5
  const DEBUG_STATE = 4;
6
6
 
@@ -126,11 +126,10 @@ async function StartWASM2(hub, config) {
126
126
  let starterFFIs = config.localFFIs || {};
127
127
  // from now on, the "local" FFIs are called "starter" FFIs, because this
128
128
  // distinguishes these from other locally defined FFIs
129
- let mixcoreFFIs = await getMixcoreFFIs(config.mixcore);
130
- if (mixcoreFFIs) {
131
- console.log("[machine-starter] mixcore FFIs", Object.keys(mixcoreFFIs));
129
+ let mixcore = await createStarterMixcore(config.mixcore);
130
+ if (mixcore) {
132
131
  // merge the ffis and store them back into the config so sub vms also get them
133
- config.localFFIs = Object.assign(starterFFIs, mixcoreFFIs);
132
+ config.localFFIs = Object.assign(starterFFIs, await mixcoreStarterFFIs(mixcore));
134
133
  // delete the mixcore config to avoid being handled further by the worker
135
134
  delete config.mixcore;
136
135
  }
@@ -192,6 +191,11 @@ async function StartWASM2(hub, config) {
192
191
  return worker;
193
192
  }
194
193
 
194
+ async function mixcoreStarterFFIs(mixcore) {
195
+ let names = await mixcore.ffiNames();
196
+ return Object.fromEntries(names.map(name => [name, {isRaw: true, run}]));
197
+ }
198
+
195
199
  async function ffi_vm_start(conn, args) {
196
200
  let vm_id = "embedded." + nanoid();
197
201
  console.log("[machine-starter] starting VM: ", vm_id);
@@ -485,34 +489,6 @@ class FFIComm {
485
489
  }
486
490
  }
487
491
 
488
- async function getMixcoreFFIs(config) {
489
- let mixcore;
490
- switch (config?.kind) {
491
- case 'mixcore':
492
- mixcore = config.mixcore;
493
- break;
494
- case 'tauri':
495
- mixcore = await MixcoreTauri.create(config.workspace, config.app);
496
- break;
497
- default:
498
- console.warn("[machine-starter] not going to configure mixcore - kind: ", config?.kind);
499
- return;
500
- }
501
-
502
- let names = await mixcore.ffiNames();
503
- names = filterFFINames(names, config.enableFFIs, config.disableFFIs);
504
-
505
- let starterFFIs = {};
506
- for (let name of names) {
507
- starterFFIs[name] = {
508
- isRaw: true,
509
- run: (conn, argsBuf) => mixcore.ffiDispatch(conn.call_id, name, argsBuf),
510
- };
511
- }
512
-
513
- return starterFFIs;
514
- }
515
-
516
492
  // use terminateVM to shut a worker down!
517
493
  export { StartWASM, StartWASM2, terminateAll, terminateVM,
518
494
  Token, Case, Opaque
@@ -1,2 +1,2 @@
1
- var GROOVEBOX_BUILD = "3356";
1
+ var GROOVEBOX_BUILD = "3362";
2
2
  export { GROOVEBOX_BUILD }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remix_labs/machine-starter",
3
- "version": "2.3356.0",
3
+ "version": "2.3362.0-dev",
4
4
  "description": "start the groove",
5
5
  "main": "node.js",
6
6
  "browser": "index.js",
@@ -11,7 +11,7 @@
11
11
  "author": "Remixlabs staff",
12
12
  "license": "ISC",
13
13
  "dependencies": {
14
- "@remix_labs/hub-client": "2.3356.0",
14
+ "@remix_labs/hub-client": "2.3362.0-dev",
15
15
  "nanoid": "^5.0.2",
16
16
  "web-worker": "^1.2.0"
17
17
  },
package/start.js CHANGED
@@ -32,12 +32,17 @@ let noOutputViaMQTT = Process.env["MIX_MQTT_NO_OUTPUT"] !== undefined;
32
32
  console.log("Machine params: variant=" + variant + " baseURL=" + baseURL, " mqttURL=" + mqttURL, " mqttUser=" + mqttUser, " mqttToken=" + mqttToken, " id=" + id, " noOutputViaMQTT=" + noOutputViaMQTT);
33
33
  let w = new Hub.Worker();
34
34
  globalThis.GROOVEBOX_ALLOW_INSECURE_HTTP = true;
35
+
36
+ // Node does not support blob URLs (for dynamic import?), resulting in error:
37
+ // [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data, and
38
+ // node are supported by the default ESM loader. Received protocol 'blob:'
39
+ let mixcoreJsUrl = "data:text/javascript;base64," + mixcoreJsBase64;
35
40
  let mixcoreWasmUrl = "data:application/wasm;base64," + mixcoreWasmBase64;
36
- let mixcoreJsUrl = "data:text/javascript;charset=utf-8;base64," + mixcoreJsBase64;
41
+
37
42
  let mixcore = {
38
- kind: "wasm-opfs",
39
- mixcoreWasmUrl,
43
+ kind: "wasm",
40
44
  mixcoreJsUrl,
45
+ mixcoreWasmUrl,
41
46
  dbDir: "/databases",
42
47
  dbUser: "test@user",
43
48
  dbName: "compiler-testing",