@remix_labs/machine-starter 2.12015.0 → 2.12017.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 +7 -7
- package/groovebox_build.js +1 -1
- package/index.js +0 -11
- package/node.js +0 -20
- package/package.json +2 -2
- package/start.js +23 -1
package/common.js
CHANGED
|
@@ -117,7 +117,7 @@ globalThis.MixSetMask = (m => {
|
|
|
117
117
|
}
|
|
118
118
|
});
|
|
119
119
|
|
|
120
|
-
function StartWASM(hub, baseURL, org, workspace, vmID, user, token, noOutputViaMQTT) {
|
|
120
|
+
function StartWASM(hub, baseURL, org, workspace, vmID, user, token, noOutputViaMQTT, getWorker) {
|
|
121
121
|
return StartWASM2(hub, {
|
|
122
122
|
baseURL: baseURL,
|
|
123
123
|
org: org,
|
|
@@ -125,17 +125,17 @@ function StartWASM(hub, baseURL, org, workspace, vmID, user, token, noOutputViaM
|
|
|
125
125
|
token: token,
|
|
126
126
|
noOutputViaMQTT: noOutputViaMQTT,
|
|
127
127
|
machType: "WASM"
|
|
128
|
-
})
|
|
128
|
+
}, getWorker)
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
async function StartWASM2(hub, config) {
|
|
131
|
+
async function StartWASM2(hub, config, getWorker) {
|
|
132
132
|
if (!last_hub) {
|
|
133
133
|
console.log("[machine-starter] Call MixExplain() for explaining debug levels, and MixSetMask(m) for changing these")
|
|
134
134
|
};
|
|
135
135
|
last_hub = hub;
|
|
136
136
|
let channel = await hub.newChannel();
|
|
137
137
|
// injected by either index.js or node.js
|
|
138
|
-
let worker =
|
|
138
|
+
let worker = getWorker();
|
|
139
139
|
if (workers[config.vmID] || ffiLoops[config.vmID])
|
|
140
140
|
throw new Error("Cannot start VM, the ID is used: " + config.vmID);
|
|
141
141
|
workers[config.vmID] = worker;
|
|
@@ -163,7 +163,7 @@ async function StartWASM2(hub, config) {
|
|
|
163
163
|
};
|
|
164
164
|
let vm_kind = { isRaw:false, canFail:false, useJsonDecoder:false};
|
|
165
165
|
starterFFIkind["$vm_start"] = vm_kind;
|
|
166
|
-
starterFFIfuns["$vm_start"] = ffi_vm_start;
|
|
166
|
+
starterFFIfuns["$vm_start"] = (conn, args) => ffi_vm_start(conn, args, getWorker);
|
|
167
167
|
starterFFIkind["$vm_stop"] = vm_kind;
|
|
168
168
|
starterFFIfuns["$vm_stop"] = ffi_vm_stop;
|
|
169
169
|
let mixrtCode = config.mixrtCode;
|
|
@@ -218,7 +218,7 @@ async function mixcoreStarterFFIs(mixcore) {
|
|
|
218
218
|
return ffis;
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
-
async function ffi_vm_start(conn, args) {
|
|
221
|
+
async function ffi_vm_start(conn, args, getWorker) {
|
|
222
222
|
let vm_id = "embedded." + nanoid();
|
|
223
223
|
console.log("[machine-starter] starting VM: ", vm_id);
|
|
224
224
|
let config = {};
|
|
@@ -234,7 +234,7 @@ async function ffi_vm_start(conn, args) {
|
|
|
234
234
|
config["interceptFFI"] = arg_config.interceptFFI;
|
|
235
235
|
if (arg_config.interceptDynloadFFI !== undefined)
|
|
236
236
|
config["interceptDynloadFFI"] = arg_config.interceptDynloadFFI;
|
|
237
|
-
let worker = await StartWASM2(conn.hub, config);
|
|
237
|
+
let worker = await StartWASM2(conn.hub, config, getWorker);
|
|
238
238
|
return vm_id;
|
|
239
239
|
}
|
|
240
240
|
|
package/groovebox_build.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var GROOVEBOX_BUILD = "
|
|
1
|
+
var GROOVEBOX_BUILD = "12017";
|
|
2
2
|
export { GROOVEBOX_BUILD }
|
package/index.js
CHANGED
|
@@ -1,12 +1 @@
|
|
|
1
|
-
import MachineWASMWorker from './machine-wasm.worker.mjs'
|
|
2
|
-
|
|
3
|
-
const blob = new Blob([MachineWASMWorker], {type: 'application/javascript'});
|
|
4
|
-
const url = URL.createObjectURL(blob);
|
|
5
|
-
|
|
6
|
-
function GetMachineWASMWorker() {
|
|
7
|
-
return new Worker(url);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
globalThis.GetMachineWASMWorker = GetMachineWASMWorker;
|
|
11
|
-
|
|
12
1
|
export * from './common.js';
|
package/node.js
CHANGED
|
@@ -5,26 +5,6 @@ globalThis.console = new Console.Console({stdout: process.stderr, stderr: proces
|
|
|
5
5
|
// redirect stdout to stderr to avoid that log messages appear in the wrong
|
|
6
6
|
// order
|
|
7
7
|
|
|
8
|
-
// NB: The only way I've made this work in node+webpack is if:
|
|
9
|
-
//
|
|
10
|
-
// * we use Worker from worker_threads directly
|
|
11
|
-
// * we build each worker's module with webpack as an ESM .mjs bundle
|
|
12
|
-
// * we put all the bundles in one directory
|
|
13
|
-
// * we load the worker with a URL('./foo.mjs')
|
|
14
|
-
//
|
|
15
|
-
// Other ways to package/load might work, but definitely seems like
|
|
16
|
-
// using worker_threads.Worker directly is needed (rather than through,
|
|
17
|
-
// say, the web-worker packages that wraps either worker_threads.Worker
|
|
18
|
-
// or the browser Worker to give the same interface). Webpack says ESM
|
|
19
|
-
// is necessary but I'm not sure if this is true for either the main
|
|
20
|
-
// script or the workers.
|
|
21
|
-
import { Worker } from "worker_threads";
|
|
22
|
-
|
|
23
|
-
function GetMachineWASMWorker() {
|
|
24
|
-
return new Worker(new URL("./machine-wasm.node.mjs", import.meta.url));
|
|
25
|
-
}
|
|
26
|
-
globalThis.GetMachineWASMWorker = GetMachineWASMWorker;
|
|
27
|
-
|
|
28
8
|
// Can't just `export *` because we need hub-client below in common.js
|
|
29
9
|
import * as Hub from "@remix_labs/hub-client";
|
|
30
10
|
export { Hub };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remix_labs/machine-starter",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.12017.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.12017.0-dev",
|
|
15
15
|
"nanoid": "^5.0.2",
|
|
16
16
|
"web-worker": "^1.2.0"
|
|
17
17
|
},
|
package/start.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import Process from "process";
|
|
2
|
+
import { Worker } from "worker_threads";
|
|
2
3
|
import { StartWASM2, Hub } from "./node.js";
|
|
3
4
|
import { mixcoreWasmBase64, mixcoreJsBase64 } from './mixcore-wasm-inmem.js';
|
|
5
|
+
import MachineWASMWorkerString from './machine-wasm.worker.mjs'
|
|
4
6
|
|
|
5
7
|
if (Process.stdout._handle)
|
|
6
8
|
Process.stdout._handle.setBlocking(true);
|
|
@@ -48,6 +50,26 @@ let mixcore = {
|
|
|
48
50
|
dbName: "compiler-testing",
|
|
49
51
|
createDbs: ["compiler-testing"],
|
|
50
52
|
};
|
|
53
|
+
|
|
54
|
+
// comment from start.js (before https://github.com/remixlabs/mix-rs/pull/1129):
|
|
55
|
+
//
|
|
56
|
+
// NB: The only way I've made this work in node+webpack is if:
|
|
57
|
+
//
|
|
58
|
+
// * we use Worker from worker_threads directly
|
|
59
|
+
// * we build each worker's module with webpack as an ESM .mjs bundle
|
|
60
|
+
// * we put all the bundles in one directory
|
|
61
|
+
// * we load the worker with a URL('./foo.mjs')
|
|
62
|
+
//
|
|
63
|
+
// Other ways to package/load might work, but definitely seems like
|
|
64
|
+
// using worker_threads.Worker directly is needed (rather than through,
|
|
65
|
+
// say, the web-worker packages that wraps either worker_threads.Worker
|
|
66
|
+
// or the browser Worker to give the same interface). Webpack says ESM
|
|
67
|
+
// is necessary but I'm not sure if this is true for either the main
|
|
68
|
+
// script or the workers.
|
|
69
|
+
function getMachineWorker() {
|
|
70
|
+
return new Worker(new URL("./machine-wasm.node.mjs", import.meta.url));
|
|
71
|
+
}
|
|
72
|
+
|
|
51
73
|
w.configure({wsURL: mqttURL, user:mqttUser, token:mqttToken}).then(resp => {
|
|
52
74
|
if (variant == "BYTE") variant = "QCODE";
|
|
53
75
|
switch(variant) {
|
|
@@ -67,7 +89,7 @@ w.configure({wsURL: mqttURL, user:mqttUser, token:mqttToken}).then(resp => {
|
|
|
67
89
|
machType: variant,
|
|
68
90
|
localFFIs: {},
|
|
69
91
|
mixcore,
|
|
70
|
-
});
|
|
92
|
+
}, getMachineWorker);
|
|
71
93
|
});
|
|
72
94
|
if (globalThis.EnableAndStartMixCompiler) {
|
|
73
95
|
EnableAndStartMixCompiler(w).then(startVM);
|