@remix_labs/machine-starter 2.3275.0-dev → 2.3278.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
@@ -123,31 +123,33 @@ async function StartWASM2(hub, config) {
123
123
  if (workers[config.vmID] || ffiLoops[config.vmID])
124
124
  throw new Error("Cannot start VM, the ID is used: " + config.vmID);
125
125
  workers[config.vmID] = worker;
126
- let localFFIs = config.localFFIs || {};
126
+ let starterFFIs = config.localFFIs || {};
127
+ // from now on, the "local" FFIs are called "starter" FFIs, because this
128
+ // distinguishes these from other locally defined FFIs
127
129
  let mixcoreFFIs = await getMixcoreFFIs(config.mixcore);
128
130
  if (mixcoreFFIs) {
129
131
  console.log("[machine-starter] mixcore FFIs", Object.keys(mixcoreFFIs));
130
132
  // merge the ffis and store them back into the config so sub vms also get them
131
- config.localFFIs = Object.assign(localFFIs, mixcoreFFIs);
133
+ config.localFFIs = Object.assign(starterFFIs, mixcoreFFIs);
132
134
  // delete the mixcore config to avoid being handled further by the worker
133
135
  delete config.mixcore;
134
136
  }
135
- let localFFIkind = {};
136
- let localFFIfuns = {};
137
- for (const [k, v] of Object.entries(localFFIs)) {
138
- localFFIfuns[k] = {...v};
137
+ let starterFFIkind = {};
138
+ let starterFFIfuns = {};
139
+ for (const [k, v] of Object.entries(starterFFIs)) {
140
+ starterFFIfuns[k] = {...v};
139
141
  if (v.isRaw && (v.canFail || v.useJsonDecoder)) {
140
- console.error("A raw, local FFI must neither be failing nor use the JSON decoder: " + k);
142
+ console.error("A raw, starter FFI must neither be failing nor use the JSON decoder: " + k);
141
143
  } else {
142
- localFFIkind[k] = {...v};
143
- delete localFFIkind[k].run;
144
+ starterFFIkind[k] = {...v};
145
+ delete starterFFIkind[k].run;
144
146
  }
145
147
  };
146
148
  let vm_kind = { isRaw:false, canFail:false, useJsonDecoder:false};
147
- localFFIkind["$vm_start"] = vm_kind;
148
- localFFIfuns["$vm_start"] = ffi_vm_start;
149
- localFFIkind["$vm_stop"] = vm_kind;
150
- localFFIfuns["$vm_stop"] = ffi_vm_stop;
149
+ starterFFIkind["$vm_start"] = vm_kind;
150
+ starterFFIfuns["$vm_start"] = ffi_vm_start;
151
+ starterFFIkind["$vm_stop"] = vm_kind;
152
+ starterFIfuns["$vm_stop"] = ffi_vm_stop;
151
153
  let mixrtCode = config.mixrtCode;
152
154
  if (typeof(mixrtCode) == "string" && mixrtCode.startsWith("remix://")) {
153
155
  // for the desktop only: precompile the mixrt module to get faster
@@ -163,7 +165,7 @@ async function StartWASM2(hub, config) {
163
165
  globalThis.mixrtCodeModule = mixrtCode;
164
166
  }
165
167
  };
166
- ffiLoops[config.vmID] = setupLocalFFIs(hub, config, localFFIfuns);
168
+ ffiLoops[config.vmID] = setupStarterFFIs(hub, config, starterFFIfuns);
167
169
  blobsLoops[config.vmID] = setupBlobs(hub, config);
168
170
  let config_msg =
169
171
  { "_rmx_type": "msg_vm_configure",
@@ -177,7 +179,7 @@ async function StartWASM2(hub, config) {
177
179
  "outputViaMQTT": !(config.noOutputViaMQTT),
178
180
  "machType": config.machType,
179
181
  "debugMask": initialMask,
180
- "localFFIs": localFFIkind,
182
+ "starterFFIs": starterFFIkind,
181
183
  "allowInsecureHttp": globalThis.GROOVEBOX_ALLOW_INSECURE_HTTP,
182
184
  "interceptFFI": config.interceptFFI,
183
185
  "interceptDynloadFFI": config.interceptDynloadFFI,
@@ -335,14 +337,14 @@ function decode(val) {
335
337
 
336
338
  // spawn the messaging loop and return an object with a function to terminate
337
339
  // the loop `{terminate: () => void}`
338
- function setupLocalFFIs(hub, config, localFFIs) {
340
+ function setupStarterFFIs(hub, config, starterFFIs) {
339
341
  let vmID = config.vmID;
340
342
  let terminate = Promise.withResolvers();
341
- localFFIsMessageLoop(hub, config, localFFIs, terminate.promise); // don't wait
343
+ starterFFIsMessageLoop(hub, config, starterFFIs, terminate.promise); // don't wait
342
344
  return {terminate: terminate.resolve};
343
345
  }
344
346
 
345
- async function localFFIsMessageLoop(hub, config, localFFIs, terminate) {
347
+ async function starterFFIsMessageLoop(hub, config, starterFFIs, terminate) {
346
348
  let vmID = config.vmID;
347
349
  let channel = await hub.newChannel();
348
350
  let comm = new FFIComm(vmID, hub, channel);
@@ -361,11 +363,11 @@ async function localFFIsMessageLoop(hub, config, localFFIs, terminate) {
361
363
  let name = msg.payload.name;
362
364
  let call_id = msg.payload.callID;
363
365
  let args = decode(msg.payload.args);
364
- let fun = localFFIs[name];
366
+ let fun = starterFFIs[name];
365
367
  if (initialMask & DEBUG_STATE)
366
- console.debug("[groovebox-starter] local FFI call", vmID, call_id, name);
368
+ console.debug("[groovebox-starter] starter FFI call", vmID, call_id, name);
367
369
  try {
368
- if (!fun) throw new Error("No such local FFI in groovebox starter: " + name);
370
+ if (!fun) throw new Error("No such starter FFI in groovebox starter: " + name);
369
371
  let connector =
370
372
  { call_id: call_id,
371
373
  hub: hub,
@@ -467,7 +469,7 @@ class FFIComm {
467
469
  name = result._rmx_type.substring(10);
468
470
  arg = result._rmx_value;
469
471
  } else {
470
- return this.error(call_id, "expected result from local FFI that can fail");
472
+ return this.error(call_id, "expected result from starter FFI that can fail");
471
473
  }
472
474
  switch (name) {
473
475
  case "ok":
@@ -475,7 +477,7 @@ class FFIComm {
475
477
  case "error":
476
478
  return this.error(call_id, arg);
477
479
  default:
478
- return this.error(call_id, "expected result from local FFI that can fail, found case value " + name);
480
+ return this.error(call_id, "expected result from starter FFI that can fail, found case value " + name);
479
481
  }
480
482
  } else {
481
483
  return this.return_(fun, call_id, result);
@@ -500,15 +502,15 @@ async function getMixcoreFFIs(config) {
500
502
  let names = await mixcore.ffiNames();
501
503
  names = filterFFINames(names, config.enableFFIs, config.disableFFIs);
502
504
 
503
- let localFFIs = {};
505
+ let starterFFIs = {};
504
506
  for (let name of names) {
505
- localFFIs[name] = {
507
+ starterFFIs[name] = {
506
508
  isRaw: true,
507
509
  run: (conn, argsBuf) => mixcore.ffiDispatch(conn.call_id, name, argsBuf),
508
510
  };
509
511
  }
510
512
 
511
- return localFFIs;
513
+ return starterFFIs;
512
514
  }
513
515
 
514
516
  // use terminateVM to shut a worker down!
@@ -1,2 +1,2 @@
1
- var GROOVEBOX_BUILD = "3275";
1
+ var GROOVEBOX_BUILD = "3278";
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.3275.0-dev",
3
+ "version": "2.3278.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.3275.0-dev",
14
+ "@remix_labs/hub-client": "2.3278.0-dev",
15
15
  "nanoid": "^5.0.2",
16
16
  "web-worker": "^1.2.0"
17
17
  },