@remix_labs/machine-starter 2.3402.0 → 2.3404.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 CHANGED
@@ -7,6 +7,7 @@ const DEBUG_STATE = 4;
7
7
  let last_hub = null;
8
8
 
9
9
  let workers = {};
10
+ let worker_topics = {};
10
11
  let children = {};
11
12
  let ffiLoops = {};
12
13
  let blobs = {};
@@ -44,11 +45,10 @@ function terminateVM(vmID) {
44
45
  let blobList = blobs[vmID] || [];
45
46
  let ffiLoop = ffiLoops[vmID];
46
47
  let blobsLoop = blobsLoops[vmID];
47
- delete workers[vmID];
48
48
  delete children[vmID];
49
49
  delete ffiLoops[vmID];
50
50
  delete blobsLoops[vmID];
51
- worker.terminate();
51
+ killVM(vmID);
52
52
  ffiLoop.terminate();
53
53
  if (blobsLoop) {
54
54
  blobsLoop.terminate();
@@ -65,6 +65,22 @@ function terminateVM(vmID) {
65
65
  }
66
66
  }
67
67
 
68
+ function killVM(vmID) {
69
+ let worker = workers[vmID];
70
+ let topic = worker_topics[vmID];
71
+ delete workers[vmID];
72
+ delete worker_topics[vmID];
73
+ if (topic && last_hub) {
74
+ let payload = { _rmx_type:"msg_vm_register", id: vmID, alive: false };
75
+ last_hub.newChannel().then(channel => {
76
+ let msg = channel.newJSONMessage("msg_vm_register", "vm", payload);
77
+ channel.publish(topic + "/announce", msg, true)
78
+ }).then(_ => worker.terminate())
79
+ } else {
80
+ worker.terminate()
81
+ }
82
+ }
83
+
68
84
  if (globalThis.Process) {
69
85
  Process.on("exit", () => {
70
86
  terminateAll()
@@ -123,6 +139,7 @@ async function StartWASM2(hub, config) {
123
139
  if (workers[config.vmID] || ffiLoops[config.vmID])
124
140
  throw new Error("Cannot start VM, the ID is used: " + config.vmID);
125
141
  workers[config.vmID] = worker;
142
+ worker_topics[config.vmID] = "/org/" + config.org + "/ws/" + config.workspace + "/vm/" + config.vmID;
126
143
  let starterFFIs = config.localFFIs || {};
127
144
  // from now on, the "local" FFIs are called "starter" FFIs, because this
128
145
  // distinguishes these from other locally defined FFIs
@@ -1,2 +1,2 @@
1
- var GROOVEBOX_BUILD = "3402";
1
+ var GROOVEBOX_BUILD = "3404";
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.3402.0",
3
+ "version": "2.3404.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.3402.0",
14
+ "@remix_labs/hub-client": "2.3404.0",
15
15
  "nanoid": "^5.0.2",
16
16
  "web-worker": "^1.2.0"
17
17
  },