@phreshos/node 0.1.5 → 0.1.6
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/dist/system.js +25 -22
- package/package.json +7 -3
package/dist/system.js
CHANGED
|
@@ -153,7 +153,7 @@ class ProgramRegistry extends Events {
|
|
|
153
153
|
const waited = value;
|
|
154
154
|
if (waited.event === "uninstall") {
|
|
155
155
|
const payload = waited.payload;
|
|
156
|
-
return { program: programHandle(this.system, required(payload.program)),
|
|
156
|
+
return { program: programHandle(this.system, required(payload.program)), everything: payload.everything === true };
|
|
157
157
|
}
|
|
158
158
|
return programHandle(this.system, required(waited.payload));
|
|
159
159
|
}
|
|
@@ -171,7 +171,7 @@ class ProgramHandle extends ProgramBase {
|
|
|
171
171
|
this.snapshot = snapshot;
|
|
172
172
|
bindEvents(this, new Events(["forget", "uninstall"], (event, signal, timeout) => transport(system).control({
|
|
173
173
|
capability: "program", operation: "wait", input: { program: snapshot.identity, event, timeout }
|
|
174
|
-
}, signal).then(value => value
|
|
174
|
+
}, signal).then(value => programEntityEvent(event, value))));
|
|
175
175
|
this.reference = snapshot.reference;
|
|
176
176
|
this.identity = snapshot.identity;
|
|
177
177
|
this.process = new ProgramProcesses(system, this);
|
|
@@ -255,7 +255,7 @@ class ProgramProcesses extends Events {
|
|
|
255
255
|
system;
|
|
256
256
|
program;
|
|
257
257
|
constructor(system, program) {
|
|
258
|
-
super(["
|
|
258
|
+
super(["create", "exit"], (event, signal, timeout) => transport(system).control({
|
|
259
259
|
capability: "process", operation: "wait", input: { program: program.identity, event, timeout }
|
|
260
260
|
}, signal).then(value => processEvent(system, value)));
|
|
261
261
|
this.system = system;
|
|
@@ -328,7 +328,7 @@ class ProgramProcesses extends Events {
|
|
|
328
328
|
class ProcessRegistry extends Events {
|
|
329
329
|
system;
|
|
330
330
|
constructor(system) {
|
|
331
|
-
super(["
|
|
331
|
+
super(["create", "exit"], (event, signal, timeout) => transport(system).control({
|
|
332
332
|
capability: "process", operation: "wait", input: { event, timeout }
|
|
333
333
|
}, signal).then(value => processEvent(system, value)));
|
|
334
334
|
this.system = system;
|
|
@@ -358,9 +358,9 @@ class ProcessHandle extends ProcessBase {
|
|
|
358
358
|
super();
|
|
359
359
|
this.system = system;
|
|
360
360
|
this.snapshot = snapshot;
|
|
361
|
-
bindEvents(this, new Events(["
|
|
361
|
+
bindEvents(this, new Events(["exit"], (event, signal, timeout) => transport(system).control({
|
|
362
362
|
capability: "process", operation: "wait", input: { process: snapshot.identity, event, timeout }
|
|
363
|
-
}, signal).then(
|
|
363
|
+
}, signal).then(exactProcessEvent)));
|
|
364
364
|
this.identity = snapshot.identity;
|
|
365
365
|
this.name = snapshot.name;
|
|
366
366
|
this.startedAt = new Date(snapshot.startedAt);
|
|
@@ -599,18 +599,15 @@ async function* command(system, request) {
|
|
|
599
599
|
async function waitEndpointLifecycle(system, owner, endpoint, event, signal, timeout = 10_000) {
|
|
600
600
|
if (event !== "start" && event !== "stop")
|
|
601
601
|
throw new Error(`An Endpoint lifecycle has no "${event}" event`);
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
if (changed === owner[endpoint])
|
|
612
|
-
return undefined;
|
|
613
|
-
}
|
|
602
|
+
await transport(system).control({
|
|
603
|
+
capability: "endpoint",
|
|
604
|
+
operation: "waitLifecycle",
|
|
605
|
+
input: { process: owner.identity, endpoint, event, timeout }
|
|
606
|
+
}, signal);
|
|
607
|
+
}
|
|
608
|
+
function programEntityEvent(event, value) {
|
|
609
|
+
const payload = value.payload;
|
|
610
|
+
return event === "uninstall" ? payload?.everything === true : undefined;
|
|
614
611
|
}
|
|
615
612
|
function processEvent(system, value) {
|
|
616
613
|
const waited = value;
|
|
@@ -622,14 +619,20 @@ function processEvent(system, value) {
|
|
|
622
619
|
code: payload.code,
|
|
623
620
|
signal: payload.signal
|
|
624
621
|
};
|
|
625
|
-
if ((waited.event === "endpointStart" || waited.event === "endpointStop") && payload?.processSnapshot) {
|
|
626
|
-
const process = processHandle(system, payload.processSnapshot);
|
|
627
|
-
return payload.endpoint === "client" ? process.client : process.server;
|
|
628
|
-
}
|
|
629
622
|
if (payload && typeof payload.identity === "string")
|
|
630
623
|
return processHandle(system, payload);
|
|
631
624
|
return payload;
|
|
632
625
|
}
|
|
626
|
+
function exactProcessEvent(value) {
|
|
627
|
+
const payload = value.payload;
|
|
628
|
+
if (!payload)
|
|
629
|
+
return payload;
|
|
630
|
+
return {
|
|
631
|
+
status: payload.status,
|
|
632
|
+
code: payload.code,
|
|
633
|
+
signal: payload.signal
|
|
634
|
+
};
|
|
635
|
+
}
|
|
633
636
|
function bindEvents(target, events) {
|
|
634
637
|
Object.assign(target, eventsOf(events));
|
|
635
638
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phreshos/node",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "Node.js access to PhreshOS and Program projects.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -11,7 +11,11 @@
|
|
|
11
11
|
"default": "./dist/main.js"
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
|
-
"files": [
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"LICENSE",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
15
19
|
"author": "Zohayr SLILEH",
|
|
16
20
|
"license": "MIT",
|
|
17
21
|
"repository": {
|
|
@@ -32,7 +36,7 @@
|
|
|
32
36
|
"prepack": "node --run build"
|
|
33
37
|
},
|
|
34
38
|
"dependencies": {
|
|
35
|
-
"@phreshos/core": "^0.1.
|
|
39
|
+
"@phreshos/core": "^0.1.27",
|
|
36
40
|
"adm-zip": "^0.6.0",
|
|
37
41
|
"jiti": "^2.7.0"
|
|
38
42
|
},
|