@remix_labs/machine-starter 2.2237.0-dev → 2.2241.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 +80 -46
- package/groovebox_build.js +1 -1
- package/machine-wasm.worker.js +1 -1
- package/package.json +2 -2
- package/start.js +50 -33
package/common.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { GROOVEBOX_BUILD } from "./groovebox_build.js";
|
|
2
|
+
import { filterFFINames } from "./mixcore-common.js";
|
|
2
3
|
import { nanoid } from "nanoid";
|
|
3
4
|
|
|
4
5
|
let workers = {};
|
|
@@ -56,52 +57,73 @@ function StartWASM(hub, baseURL, org, workspace, vmID, user, token, noOutputViaM
|
|
|
56
57
|
})
|
|
57
58
|
}
|
|
58
59
|
|
|
59
|
-
function
|
|
60
|
+
function mixcoreLocalFFIs(mixcore, names) {
|
|
61
|
+
return Object.fromEntries(
|
|
62
|
+
names.map(name => [name, {
|
|
63
|
+
isRaw: true,
|
|
64
|
+
run: (conn, argsBuf) => mixcore.ffiDispatch(conn.call_id, name, argsBuf),
|
|
65
|
+
}]));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// See `mix-rs/mixcore/README.md` for a description of the values of
|
|
69
|
+
// config.mixcore.
|
|
70
|
+
async function StartWASM2(hub, config) {
|
|
60
71
|
console.log("GROOVEBOX_BUILD (machine-starter)", GROOVEBOX_BUILD);
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
let vm_kind = { isRaw:false, canFail:false, useJsonDecoder:false};
|
|
78
|
-
localFFIkind["$vm_start"] = vm_kind;
|
|
79
|
-
localFFIfuns["$vm_start"] = ffi_vm_start;
|
|
80
|
-
localFFIkind["$vm_stop"] = vm_kind;
|
|
81
|
-
localFFIfuns["$vm_stop"] = ffi_vm_stop;
|
|
72
|
+
let channel = await hub.newChannel();
|
|
73
|
+
// injected by either index.js or node.js
|
|
74
|
+
let worker = globalThis.GetMachineWASMWorker();
|
|
75
|
+
workers[config.vmID] = worker;
|
|
76
|
+
let mixcore = null;
|
|
77
|
+
let localFFIs = config.localFFIs || {};
|
|
78
|
+
if (config.mixcore && config.mixcore.kind == 'mixcore') {
|
|
79
|
+
let enableFFIs, disableFFIs;
|
|
80
|
+
({mixcore, enableFFIs, disableFFIs} = config.mixcore);
|
|
81
|
+
let ffiNames = filterFFINames(await mixcore.ffiNames(), enableFFIs, disableFFIs);
|
|
82
|
+
console.log("Mixcore (starter)", mixcore, ffiNames, mixcore.registerDebugObject);
|
|
83
|
+
localFFIs = {...localFFIs, ...mixcoreLocalFFIs(mixcore, ffiNames)};
|
|
84
|
+
config.mixcore = {};
|
|
85
|
+
if (mixcore.registerDebugObject) {
|
|
86
|
+
config.mixcore.publishDebugObjects = true;
|
|
87
|
+
subscribeDebugObjects(mixcore, hub, config);
|
|
82
88
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
89
|
+
}
|
|
90
|
+
let localFFIkind = {};
|
|
91
|
+
let localFFIfuns = {};
|
|
92
|
+
for (const [k, v] of Object.entries(localFFIs)) {
|
|
93
|
+
localFFIfuns[k] = {...v};
|
|
94
|
+
if (v.isRaw && (v.canFail || v.useJsonDecoder)) {
|
|
95
|
+
console.error("A raw, local FFI must neither be failing nor use the JSON decoder: " + k);
|
|
96
|
+
} else {
|
|
97
|
+
localFFIkind[k] = {...v};
|
|
98
|
+
delete localFFIkind[k].run;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
let vm_kind = { isRaw:false, canFail:false, useJsonDecoder:false};
|
|
102
|
+
localFFIkind["$vm_start"] = vm_kind;
|
|
103
|
+
localFFIfuns["$vm_start"] = ffi_vm_start;
|
|
104
|
+
localFFIkind["$vm_stop"] = vm_kind;
|
|
105
|
+
localFFIfuns["$vm_stop"] = ffi_vm_stop;
|
|
106
|
+
let config_msg =
|
|
107
|
+
{ "_rmx_type": "msg_vm_configure",
|
|
108
|
+
"baseURL": config.baseURL,
|
|
109
|
+
"org": config.org,
|
|
110
|
+
"workspace": config.workspace,
|
|
111
|
+
"vmID": config.vmID,
|
|
112
|
+
"user": config.user,
|
|
113
|
+
"token": config.token,
|
|
114
|
+
"hub": channel.port,
|
|
115
|
+
"outputViaMQTT": !(config.noOutputViaMQTT),
|
|
116
|
+
"machType": config.machType,
|
|
117
|
+
"debugMask": initialMask,
|
|
118
|
+
"localFFIs": localFFIkind,
|
|
119
|
+
"allowInsecureHttp": globalThis.GROOVEBOX_ALLOW_INSECURE_HTTP,
|
|
120
|
+
"interceptFFI": config.interceptFFI,
|
|
121
|
+
"interceptDynloadFFI": config.interceptDynloadFFI,
|
|
122
|
+
"mixcore": config.mixcore,
|
|
123
|
+
};
|
|
124
|
+
worker.postMessage(config_msg, [ channel.port ]);
|
|
125
|
+
setupLocalFFIs(hub, config, localFFIfuns); // don't await!
|
|
126
|
+
return worker;
|
|
105
127
|
}
|
|
106
128
|
|
|
107
129
|
async function ffi_vm_start(conn, args) {
|
|
@@ -260,8 +282,7 @@ async function setupLocalFFIs(hub, config, localFFIs) {
|
|
|
260
282
|
let args = decode(msg.payload.args);
|
|
261
283
|
let fun = localFFIs[name];
|
|
262
284
|
try {
|
|
263
|
-
if (!fun)
|
|
264
|
-
throw new Error("no such local FFI: " + name);
|
|
285
|
+
if (!fun) throw new Error("no such local FFI: " + name);
|
|
265
286
|
let connector =
|
|
266
287
|
{ call_id: call_id,
|
|
267
288
|
hub: hub,
|
|
@@ -284,6 +305,19 @@ async function setupLocalFFIs(hub, config, localFFIs) {
|
|
|
284
305
|
}
|
|
285
306
|
}
|
|
286
307
|
|
|
308
|
+
async function subscribeDebugObjects(mixcore, hub, config) {
|
|
309
|
+
let channel = await hub.newChannel();
|
|
310
|
+
let vmID = config.vmID;
|
|
311
|
+
await channel.setLocalSubTopic(`/debug-objects/${vmID}`);
|
|
312
|
+
let sub = await channel.subscribe(`/debug-objects/${vmID}`);
|
|
313
|
+
while (true) {
|
|
314
|
+
let msg = await sub.next();
|
|
315
|
+
let id = msg.payload.id;
|
|
316
|
+
let code = msg.payload.code;
|
|
317
|
+
mixcore.registerDebugObject(id, code);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
287
321
|
class FFIComm {
|
|
288
322
|
constructor(vmID, hub, channel) {
|
|
289
323
|
this.vmID = vmID;
|
package/groovebox_build.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var GROOVEBOX_BUILD = "
|
|
1
|
+
var GROOVEBOX_BUILD = "2419";
|
|
2
2
|
export { GROOVEBOX_BUILD }
|