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