@remix_labs/machine-starter 2.2836.0-dev → 2.2840.0
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 +13 -12
- package/groovebox_build.js +1 -1
- package/package.json +2 -2
package/common.js
CHANGED
|
@@ -4,19 +4,19 @@ import { MixcoreTauri, filterFFINames } from "./mixcore.lib.mjs";
|
|
|
4
4
|
|
|
5
5
|
let workers = {};
|
|
6
6
|
let children = {};
|
|
7
|
-
let
|
|
7
|
+
let ffiLoops = {};
|
|
8
8
|
|
|
9
9
|
function terminateAll() {
|
|
10
10
|
console.log("[groovebox-starter] terminate all VMs");
|
|
11
11
|
for (let [vmID, worker] of Object.entries(workers)) {
|
|
12
12
|
worker.terminate();
|
|
13
13
|
};
|
|
14
|
-
for (let
|
|
15
|
-
|
|
14
|
+
for (let ffiLoop of Object.values(ffiLoops)) {
|
|
15
|
+
ffiLoop.terminate();
|
|
16
16
|
}
|
|
17
17
|
workers = {};
|
|
18
18
|
children = {};
|
|
19
|
-
|
|
19
|
+
ffiLoops = {};
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
function terminateVM(vmID) {
|
|
@@ -24,12 +24,12 @@ function terminateVM(vmID) {
|
|
|
24
24
|
let worker = workers[vmID];
|
|
25
25
|
if (worker) {
|
|
26
26
|
let vmChildren = children[vmID];
|
|
27
|
-
let
|
|
27
|
+
let ffiLoop = ffiLoops[vmID];
|
|
28
28
|
delete workers[vmID];
|
|
29
29
|
delete children[vmID];
|
|
30
|
-
delete
|
|
30
|
+
delete ffiLoops[vmID];
|
|
31
31
|
worker.terminate();
|
|
32
|
-
|
|
32
|
+
ffiLoop.terminate();
|
|
33
33
|
if (vmChildren) {
|
|
34
34
|
for (let subID of vmChildren) {
|
|
35
35
|
terminateVM(subID)
|
|
@@ -72,7 +72,8 @@ async function StartWASM2(hub, config) {
|
|
|
72
72
|
let channel = await hub.newChannel();
|
|
73
73
|
// injected by either index.js or node.js
|
|
74
74
|
let worker = globalThis.GetMachineWASMWorker();
|
|
75
|
-
if (workers[config.vmID]
|
|
75
|
+
if (workers[config.vmID] || ffiLoops[config.vmID])
|
|
76
|
+
throw new Error("Cannot start VM, the ID is used: " + config.vmID);
|
|
76
77
|
workers[config.vmID] = worker;
|
|
77
78
|
let localFFIs = config.localFFIs || {};
|
|
78
79
|
let mixcoreFFIs = await getMixcoreFFIs(config.mixcore);
|
|
@@ -97,6 +98,7 @@ async function StartWASM2(hub, config) {
|
|
|
97
98
|
localFFIfuns["$vm_start"] = ffi_vm_start;
|
|
98
99
|
localFFIkind["$vm_stop"] = vm_kind;
|
|
99
100
|
localFFIfuns["$vm_stop"] = ffi_vm_stop;
|
|
101
|
+
ffiLoops[config.vmID] = setupLocalFFIs(hub, config, localFFIfuns);
|
|
100
102
|
let config_msg =
|
|
101
103
|
{ "_rmx_type": "msg_vm_configure",
|
|
102
104
|
"baseURL": config.baseURL,
|
|
@@ -119,7 +121,6 @@ async function StartWASM2(hub, config) {
|
|
|
119
121
|
// (http, https, data)
|
|
120
122
|
};
|
|
121
123
|
worker.postMessage(config_msg, [ channel.port ]);
|
|
122
|
-
setupLocalFFIs(hub, config, localFFIfuns);
|
|
123
124
|
return worker;
|
|
124
125
|
}
|
|
125
126
|
|
|
@@ -265,13 +266,13 @@ function decode(val) {
|
|
|
265
266
|
}
|
|
266
267
|
}
|
|
267
268
|
|
|
268
|
-
//
|
|
269
|
+
// spawn the messaging loop and return an object with a function to terminate
|
|
270
|
+
// the loop `{terminate: () => void}`
|
|
269
271
|
function setupLocalFFIs(hub, config, localFFIs) {
|
|
270
272
|
let vmID = config.vmID;
|
|
271
273
|
let terminate = Promise.withResolvers();
|
|
272
|
-
if (ffiSubscriptions[vmID]) ffiSubscriptions[vmID].terminate();
|
|
273
|
-
ffiSubscriptions[vmID] = {terminate: terminate.resolve};
|
|
274
274
|
localFFIsMessageLoop(hub, config, localFFIs, terminate.promise); // don't wait
|
|
275
|
+
return {terminate: terminate.resolve};
|
|
275
276
|
}
|
|
276
277
|
|
|
277
278
|
async function localFFIsMessageLoop(hub, config, localFFIs, terminate) {
|
package/groovebox_build.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var GROOVEBOX_BUILD = "
|
|
1
|
+
var GROOVEBOX_BUILD = "3120";
|
|
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.2840.0",
|
|
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.2840.0",
|
|
15
15
|
"nanoid": "^5.0.2",
|
|
16
16
|
"web-worker": "^1.2.0"
|
|
17
17
|
},
|