@akala/pm 15.2.8 → 15.3.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/changelog.md +7 -2
- package/cli-commands.json +59 -59
- package/commands.json +61 -55
- package/dist/esm/akala.mjs +1 -1
- package/dist/esm/akala.mjs.map +1 -1
- package/dist/esm/cli-commands/link.js +1 -1
- package/dist/esm/cli-commands/link.js.map +1 -1
- package/dist/esm/cli-commands/run.js +2 -2
- package/dist/esm/cli-commands/run.js.map +1 -1
- package/dist/esm/cli-commands/start.js +1 -1
- package/dist/esm/cli-commands/start.js.map +1 -1
- package/dist/esm/cli-container.js +1 -1
- package/dist/esm/cli-container.js.map +1 -1
- package/dist/esm/commands/$init.js +2 -2
- package/dist/esm/commands/$init.js.map +1 -1
- package/dist/esm/container.js +1 -1
- package/dist/esm/container.js.map +1 -1
- package/dist/esm/ipc-adapter.d.ts +9 -6
- package/dist/esm/ipc-adapter.js +27 -17
- package/dist/esm/ipc-adapter.js.map +1 -1
- package/dist/esm/messageport-adapter.d.ts +10 -6
- package/dist/esm/messageport-adapter.js +48 -15
- package/dist/esm/messageport-adapter.js.map +1 -1
- package/dist/esm/runtimes/child_process.js +2 -1
- package/dist/esm/runtimes/child_process.js.map +1 -1
- package/dist/esm/standalone.js +1 -1
- package/dist/esm/standalone.js.map +1 -1
- package/dist/esm/virtual-scroll-prefixer.d.ts +12 -0
- package/dist/esm/virtual-scroll-prefixer.js +47 -0
- package/dist/esm/virtual-scroll-prefixer.js.map +1 -0
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +9 -9
- package/src/akala.mts +1 -1
- package/src/cli-commands/connect.json +3 -3
- package/src/cli-commands/discover.json +3 -3
- package/src/cli-commands/install.json +3 -3
- package/src/cli-commands/link.json +5 -5
- package/src/cli-commands/link.ts +1 -1
- package/src/cli-commands/log.json +3 -3
- package/src/cli-commands/map.json +5 -5
- package/src/cli-commands/run.json +2 -2
- package/src/cli-commands/run.ts +2 -2
- package/src/cli-commands/start.json +2 -2
- package/src/cli-commands/start.ts +1 -1
- package/src/cli-commands/uninstall.json +3 -3
- package/src/cli-commands/update.json +3 -3
- package/src/cli-commands/version.json +7 -7
- package/src/cli-container.ts +1 -1
- package/src/commands/$init.json +1 -1
- package/src/commands/$init.ts +2 -2
- package/src/commands/bridge.json +4 -4
- package/src/commands/proxy.json +4 -4
- package/src/commands/ready.json +2 -2
- package/src/commands/reload-metadata.json +3 -3
- package/src/commands/restart.json +10 -10
- package/src/commands/start.json +13 -13
- package/src/commands/status.json +6 -6
- package/src/commands/stop.json +5 -5
- package/src/container.ts +1 -1
- package/src/ipc-adapter.ts +45 -23
- package/src/messageport-adapter.ts +59 -19
- package/src/runtimes/child_process.ts +2 -1
- package/src/standalone.ts +1 -1
- package/src/test/pwet.json +2 -2
- package/src/virtual-scroll-prefixer.ts +67 -0
- package/test.json +5 -5
package/src/container.ts
CHANGED
@@ -52,7 +52,7 @@ namespace commands
|
|
52
52
|
'update'(...args: [Argument0<typeof import('./cli-commands/update.js').default>, Argument1<typeof import('./cli-commands/update.js').default>, Argument2<typeof import('./cli-commands/update.js').default>]): ReturnType<typeof import('./cli-commands/update.js').default>
|
53
53
|
'version'(...args: [Argument0<typeof import('./cli-commands/version.js').default>, Argument1<typeof import('./cli-commands/version.js').default>]): ReturnType<typeof import('./cli-commands/version.js').default>
|
54
54
|
}
|
55
|
-
export const meta={"name":"pm","commands":[{"name":"$init","config":{"fs":{"disabled":true,"path":"dist/esm/commands/$init.js","source":"src/commands/$init.ts","inject":["$container","
|
55
|
+
export const meta={"name":"pm","commands":[{"name":"$init","config":{"fs":{"disabled":true,"path":"dist/esm/commands/$init.js","source":"src/commands/$init.ts","inject":["$container","params.0"]},"":{"inject":["$container","params.0"]},"cli":{"inject":["$container","context"],"usage":"$init [...args]","options":{"configFile":{"needsValue":true,"aliases":["c"]},"keepAttached":{"aliases":["keep-attached"],"needsValue":false,"doc":"keeps the process attached to the current terminal"},"wait":{"aliases":["w"],"needsValue":false,"doc":"waits for the program to be started before returning, otherwise, returns after the start command is sent to the pm daemon"},"tcpPort":{"needsValue":true,"aliases":["tcp-port"]},"port":{"needsValue":true},"key":{"needsValue":true},"cert":{"needsValue":true}}}}},{"name":"bridge","config":{"fs":{"path":"dist/esm/commands/bridge.js","source":"src/commands/bridge.ts","inject":["params.0","params.1"]},"jsonrpc":{"inject":["params.0","socket"]},"":{"inject":["params.0","params.1"]}}},{"name":"name","config":{"fs":{"path":"dist/esm/commands/name.js","source":"src/commands/name.ts","inject":["params.0"]},"":{"inject":["params.0"]}}},{"name":"proxy","config":{"fs":{"path":"dist/esm/commands/proxy.js","source":"src/commands/proxy.ts","inject":["params.0","params.1"]},"jsonrpc":{"inject":["params.0","socket"]},"":{"inject":["params.0","params.1"]}}},{"name":"ready","config":{"fs":{"path":"dist/esm/commands/ready.js","source":"src/commands/ready.ts","inject":["$container","params.0"]},"jsonrpc":{"inject":["$container","dummy","connectionAsContainer"]},"pm":{"inject":["$container","params.0"]},"":{"inject":["$container","params.0"]}}},{"name":"reload-metadata","config":{"fs":{"inject":["params.0"],"path":"dist/esm/commands/reload-metadata.js","source":"src/commands/reload-metadata.ts"},"jsonrpc":{"inject":["connectionAsContainer"]},"":{"inject":["params.0"]}}},{"name":"restart","config":{"fs":{"path":"dist/esm/commands/restart.js","source":"src/commands/restart.ts","inject":["$container","params.0","params.1"]},"":{"inject":["$container","params.0","params.1"]},"cli":{"options":{"wait":{"aliases":["w"],"needsValue":false,"doc":"waits for the program to be started before returning, otherwise, returns after the start command is sent to the pm daemon"},"inspect":{"needsValue":false,"doc":"starts the process with --inspect-brk parameter to help debugging"},"new":{"needsValue":false},"name":{"doc":"name to assign to the process","needsValue":true},"program":{"doc":"program to start"}},"inject":["$container","params.0","context"],"usage":"restart <program>"},"schema":{"inject":["$container","params.0","params.1"],"$defs":{"params.0":{"type":"string"},"params.1":{"type":"object","properties":{"wait":{"type":"boolean"}}}}},"html-form":{"inject":["$container","params.0","params.1"]}}},{"name":"start","config":{"fs":{"path":"dist/esm/commands/start.js","source":"src/commands/start.ts","inject":["$container","params.0","params.1","params.2"]},"":{"inject":["$container","params.0","params.1","params.2"]},"cli":{"options":{"wait":{"aliases":["w"],"needsValue":false,"doc":"waits for the program to be started before returning, otherwise, returns after the start command is sent to the pm daemon"},"inspect":{"needsValue":false,"doc":"starts the process with --inspect-brk parameter to help debugging"},"new":{"needsValue":false},"name":{"doc":"name to assign to the process","needsValue":true},"program":{"doc":"program to start"},"autostart":{"doc":"start automatically when pm starts"}},"inject":["$container","options.program","options","context"],"usage":"start <program>"},"html-form":{"inject":["$container","params.0","params.1","params.2"]},"schema":{"inject":["$container","params.0","params.1","params.2"],"$defs":{"params.0":{"type":"string"},"params.1":{"type":"object","properties":{"wait":{"type":"boolean"},"inspect":{"type":"boolean"},"new":{"type":"boolean"},"name":{"type":"string"},"program":{"type":"string"}}},"params.2":{"type":"object","properties":{"args":{"type":"array","items":{"type":"string"}}}}}}}},{"name":"status","config":{"fs":{"path":"dist/esm/commands/status.js","source":"src/commands/status.ts","inject":["params.0"]},"":{"inject":["params.0"]},"cli":{"inject":["params.0"]},"html-form":{"inject":["params.0"]},"schema":{"inject":["params.0"],"$defs":{"params.0":{"type":"string","description":"The name of the container to get the status of"}}}}},{"name":"stop","config":{"fs":{"path":"dist/esm/commands/stop.js","source":"src/commands/stop.ts","inject":["params.0","$container"]},"":{"inject":["params.0","$container"]},"cli":{"inject":["options.process","$container"],"options":{"process":{"doc":"process to stop. Stops all the processes otherwise (including pm)."}},"usage":"stop [process]"},"html-form":{"inject":["params.0","$container"]},"schema":{"inject":["params.0","$container"],"$defs":{"params.0":{"type":"string"}}}}},{"name":"connect","config":{"fs":{"path":"dist/esm/cli-commands/connect.js","source":"src/cli-commands/connect.ts","inject":["params.0","params.1"]},"":{"inject":["params.0","params.1"]},"cli":{"usage":"connect <name>","inject":["options.name","context"],"options":{"tcpPort":{"needsValue":true,"aliases":["tcp-port"]},"port":{"needsValue":true},"key":{"needsValue":true},"cert":{"needsValue":true}}}}},{"name":"discover","config":{"fs":{"path":"dist/esm/cli-commands/discover.js","source":"src/cli-commands/discover.ts","inject":["params.0","params.1","$container"]},"":{"inject":["params.0","params.1","$container"]},"cli":{"usage":"discover <name> <folder>","options":{"folder":{"normalize":true}},"inject":["options.name","options.folder","$container"]}}},{"name":"install","config":{"fs":{"path":"dist/esm/cli-commands/install.js","source":"src/cli-commands/install.ts","inject":["params.0","$container"]},"":{"inject":["params.0","$container"]},"cli":{"inject":["params.0","$container"]}}},{"name":"link","config":{"fs":{"path":"dist/esm/cli-commands/link.js","source":"src/cli-commands/link.ts","inject":["params.0","params.1","$container"]},"":{"inject":["params.0","params.1","$container"]},"cli":{"inject":["params.0","params.1","$container"]}}},{"name":"log","config":{"fs":{"path":"dist/esm/cli-commands/log.js","source":"src/cli-commands/log.ts","inject":["params.0"]},"":{"inject":["params.0"]},"cli":{"inject":["params.0"]}}},{"name":"ls","config":{"fs":{"path":"dist/esm/cli-commands/ls.js","source":"src/cli-commands/ls.ts","inject":[]},"":{"inject":[]},"cli":{"inject":[]},"html-form":{"inject":[]}}},{"name":"map","config":{"fs":{"path":"dist/esm/cli-commands/map.js","source":"src/cli-commands/map.ts","inject":["params.0","params.1","params.2","params.3","params.4"]},"":{"inject":["params.0","params.1","params.2","params.3","params.4"]},"cli":{"inject":["options.name","options.path","options.runtime","cwd","options"],"options":{"commandable":{"aliases":["c"],"needsValue":false},"stateless":{"aliases":["s"],"needsValue":false},"runtime":{"aliases":["r"],"needsValue":true}},"usage":"map <name> <path>"}}},{"name":"run","config":{"fs":{"path":"dist/esm/cli-commands/run.js","source":"src/cli-commands/run.ts","inject":["params.0","params.1"]},"":{"inject":["params.0","params.1"]},"jsonrpc":false,"cli":{"options":{"output":{"aliases":["o"],"needsValue":true,"doc":"output as `table` if array otherwise falls back to standard node output"},"verbose":{"aliases":["v"]},"tls":{"doc":"enables tls connection to the `pmSock`"},"pmSock":{"aliases":["pm-sock"],"needsValue":true,"doc":"path to the unix socket or destination in the form host:port"},"help":{"doc":"displays this help message"},"keepAttached":{"aliases":["keep-attached"],"needsValue":false,"doc":"keeps the process attached to the current terminal"},"wait":{"aliases":["w"],"needsValue":false,"doc":"waits for the program to be started before returning, otherwise, returns after the start command is sent to the pm daemon"},"inspect":{"needsValue":false,"doc":"starts the process with --inspect-brk parameter to help debugging"},"new":{"needsValue":false},"name":{"doc":"name to assign to the process","needsValue":true},"program":{"doc":"program to start"}},"inject":["options.program","options.name","context","options.pmSock"],"usage":"run <name> [...args]"}}},{"name":"uninstall","config":{"fs":{"path":"dist/esm/cli-commands/uninstall.js","source":"src/cli-commands/uninstall.ts","inject":["params.0","$container"]},"":{"inject":["params.0","$container"]},"cli":{"inject":["params.0","$container"]}}},{"name":"update","config":{"fs":{"path":"dist/esm/cli-commands/update.js","source":"src/cli-commands/update.ts","inject":["params.0","params.1","params.2"]},"cli":{"inject":["params.0","params.1","$container"]},"":{"inject":["params.0","params.1","params.2"]}}},{"name":"version","config":{"fs":{"path":"dist/esm/cli-commands/version.js","source":"src/cli-commands/version.ts","inject":["params.0","params.1"]},"":{"inject":["params.0","params.1"]},"cli":{"inject":["options.packageName","options.folder"],"usage":"version <packageName> [folder]"},"schema":{"inject":["params.0","params.1"],"$defs":{"params.0":{"type":"string"},"params.1":{"type":"string"}}}}}],"extends":["./cli-commands.json"],"$schema":"https://raw.githubusercontent.com/npenin/akala/main/packages/commands/container-schema.json"} as Metadata.Container;
|
56
56
|
|
57
57
|
export function connect(processor?:ICommandProcessor) {
|
58
58
|
const container = new Container<void>("commands", void 0);
|
package/src/ipc-adapter.ts
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
import { ChildProcess } from "child_process";
|
2
2
|
import * as jsonrpc from '@akala/json-rpc-ws';
|
3
|
-
import {
|
3
|
+
import { AllEventKeys, AllEvents, EventArgs, EventKeys, EventListener, EventOptions, EventReturnType, StatefulSubscription, Subscription, TeardownManager } from "@akala/core";
|
4
4
|
|
5
|
-
export class IpcAdapter implements jsonrpc.SocketAdapter
|
5
|
+
export class IpcAdapter extends TeardownManager implements jsonrpc.SocketAdapter
|
6
6
|
{
|
7
7
|
get open(): boolean { return !!this.cp.pid; }
|
8
8
|
|
9
9
|
|
10
|
-
pipe(socket: jsonrpc.SocketAdapter
|
10
|
+
pipe(socket: jsonrpc.SocketAdapter)
|
11
11
|
{
|
12
12
|
this.on('message', (message) => socket.send(message));
|
13
13
|
this.on('close', () => socket.close());
|
@@ -25,7 +25,11 @@ export class IpcAdapter implements jsonrpc.SocketAdapter
|
|
25
25
|
else
|
26
26
|
console.warn(`process ${this.cp.pid} does not support send over IPC`);
|
27
27
|
}
|
28
|
-
|
28
|
+
|
29
|
+
public off<const TEvent extends AllEventKeys<jsonrpc.SocketAdapterAkalaEventMap>>(
|
30
|
+
event: TEvent,
|
31
|
+
handler: EventListener<AllEvents<jsonrpc.SocketAdapterAkalaEventMap>[TEvent]>
|
32
|
+
): boolean
|
29
33
|
{
|
30
34
|
switch (event)
|
31
35
|
{
|
@@ -39,41 +43,59 @@ export class IpcAdapter implements jsonrpc.SocketAdapter
|
|
39
43
|
this.cp.off('disconnect', handler);
|
40
44
|
break;
|
41
45
|
}
|
46
|
+
return true;
|
42
47
|
}
|
43
|
-
|
48
|
+
|
49
|
+
public on<const TEvent extends AllEventKeys<jsonrpc.SocketAdapterAkalaEventMap>>(
|
50
|
+
event: TEvent,
|
51
|
+
handler: EventListener<AllEvents<jsonrpc.SocketAdapterAkalaEventMap>[TEvent]>,
|
52
|
+
options?: EventOptions<AllEvents<jsonrpc.SocketAdapterAkalaEventMap>[TEvent]>
|
53
|
+
): Subscription
|
44
54
|
{
|
45
55
|
switch (event)
|
46
56
|
{
|
47
57
|
case 'message':
|
48
|
-
|
49
|
-
|
58
|
+
if (options?.once)
|
59
|
+
this.cp.on('message', handler);
|
60
|
+
else
|
61
|
+
this.cp.on('message', handler);
|
62
|
+
return new StatefulSubscription(() => this.cp.off('message', handler)).unsubscribe;
|
50
63
|
case 'open':
|
51
64
|
handler(null);
|
52
65
|
break;
|
53
66
|
case 'close':
|
54
|
-
|
55
|
-
|
67
|
+
if (options?.once)
|
68
|
+
this.cp.once('disconnect', handler);
|
69
|
+
else
|
70
|
+
this.cp.on('disconnect', handler);
|
71
|
+
return new StatefulSubscription(() => this.cp.off('disconnect', handler)).unsubscribe;
|
56
72
|
}
|
57
73
|
}
|
58
74
|
|
59
|
-
once<
|
75
|
+
public once<const TEvent extends AllEventKeys<jsonrpc.SocketAdapterAkalaEventMap>>(
|
76
|
+
event: TEvent,
|
77
|
+
handler: EventListener<AllEvents<jsonrpc.SocketAdapterAkalaEventMap>[TEvent]>,
|
78
|
+
): Subscription
|
60
79
|
{
|
61
|
-
|
62
|
-
{
|
63
|
-
case 'message':
|
64
|
-
this.cp.once('message', handler);
|
65
|
-
break;
|
66
|
-
case 'open':
|
67
|
-
handler(null);
|
68
|
-
break;
|
69
|
-
case 'close':
|
70
|
-
this.cp.once('disconnect', () => handler(null));
|
71
|
-
break;
|
72
|
-
}
|
80
|
+
return this.on(event, handler, { once: true } as EventOptions<AllEvents<jsonrpc.SocketAdapterAkalaEventMap>[TEvent]>)
|
73
81
|
}
|
74
82
|
|
75
83
|
constructor(private cp: ChildProcess | typeof process)
|
76
84
|
{
|
85
|
+
super();
|
86
|
+
}
|
87
|
+
hasListener<const TKey extends AllEventKeys<jsonrpc.SocketAdapterAkalaEventMap>>(name: TKey)
|
88
|
+
{
|
89
|
+
if (name === 'open')
|
90
|
+
return false;
|
91
|
+
return !!this.cp.listenerCount(name);
|
92
|
+
}
|
93
|
+
get definedEvents(): AllEventKeys<jsonrpc.SocketAdapterAkalaEventMap>[]
|
94
|
+
{
|
95
|
+
return (['close', 'error', 'message'] as const).filter(ev => this.hasListener(ev));
|
96
|
+
}
|
97
|
+
emit<const TEvent extends EventKeys<jsonrpc.SocketAdapterAkalaEventMap>>(event: TEvent, ...args: EventArgs<jsonrpc.SocketAdapterAkalaEventMap[TEvent]>): false | EventReturnType<jsonrpc.SocketAdapterAkalaEventMap[TEvent]>
|
98
|
+
{
|
99
|
+
throw new Error("Method not implemented.");
|
77
100
|
}
|
78
|
-
|
79
101
|
}
|
@@ -1,7 +1,8 @@
|
|
1
|
-
import {
|
1
|
+
import { AllEventKeys, AllEvents, EventArgs, EventKeys, EventListener, EventOptions, EventReturnType, StatefulSubscription, Subscription, TeardownManager } from "@akala/core";
|
2
|
+
import { SocketAdapter, SocketAdapterAkalaEventMap } from "@akala/json-rpc-ws";
|
2
3
|
import { MessagePort, Worker } from "worker_threads";
|
3
4
|
|
4
|
-
export class MessagePortAdapter implements SocketAdapter
|
5
|
+
export class MessagePortAdapter extends TeardownManager implements SocketAdapter
|
5
6
|
{
|
6
7
|
private isOpen: boolean = true;
|
7
8
|
|
@@ -17,48 +18,70 @@ export class MessagePortAdapter implements SocketAdapter
|
|
17
18
|
{
|
18
19
|
this.cp.postMessage(data);
|
19
20
|
}
|
20
|
-
|
21
|
+
|
22
|
+
public on<const TEvent extends AllEventKeys<SocketAdapterAkalaEventMap>>(
|
23
|
+
event: TEvent,
|
24
|
+
handler: EventListener<AllEvents<SocketAdapterAkalaEventMap>[TEvent]>,
|
25
|
+
options?: EventOptions<AllEvents<SocketAdapterAkalaEventMap>[TEvent]>
|
26
|
+
): Subscription
|
21
27
|
{
|
22
28
|
switch (event)
|
23
29
|
{
|
24
30
|
case 'message':
|
25
|
-
|
26
|
-
|
31
|
+
if (options?.once)
|
32
|
+
this.cp.on('message', handler);
|
33
|
+
else
|
34
|
+
this.cp.on('message', handler);
|
35
|
+
return new StatefulSubscription(() => this.cp.off('message', handler)).unsubscribe;
|
27
36
|
case 'open':
|
28
37
|
handler(null);
|
29
38
|
break;
|
30
39
|
case 'close':
|
31
|
-
|
32
|
-
|
40
|
+
if (options?.once)
|
41
|
+
this.cp.once('disconnect', handler);
|
42
|
+
else
|
43
|
+
this.cp.on('disconnect', handler);
|
44
|
+
return new StatefulSubscription(() => this.cp.off('disconnect', handler)).unsubscribe;
|
33
45
|
}
|
34
46
|
}
|
35
47
|
|
36
|
-
once<
|
48
|
+
public once<const TEvent extends AllEventKeys<SocketAdapterAkalaEventMap>>(
|
49
|
+
event: TEvent,
|
50
|
+
handler: EventListener<AllEvents<SocketAdapterAkalaEventMap>[TEvent]>,
|
51
|
+
): Subscription
|
52
|
+
{
|
53
|
+
return this.on(event, handler, { once: true } as EventOptions<AllEvents<SocketAdapterAkalaEventMap>[TEvent]>)
|
54
|
+
}
|
55
|
+
|
56
|
+
|
57
|
+
constructor(private cp: MessagePort | Worker)
|
58
|
+
{
|
59
|
+
super();
|
60
|
+
cp.on('close', () => this.isOpen = false);
|
61
|
+
}
|
62
|
+
|
63
|
+
public off<const TEvent extends AllEventKeys<SocketAdapterAkalaEventMap>>(
|
64
|
+
event: TEvent,
|
65
|
+
handler: EventListener<AllEvents<SocketAdapterAkalaEventMap>[TEvent]>
|
66
|
+
): boolean
|
37
67
|
{
|
38
68
|
switch (event)
|
39
69
|
{
|
40
70
|
case 'message':
|
41
|
-
this.cp.
|
71
|
+
this.cp.off('message', handler);
|
42
72
|
break;
|
43
73
|
case 'open':
|
44
74
|
handler(null);
|
45
75
|
break;
|
46
76
|
case 'close':
|
47
|
-
this.cp.
|
77
|
+
this.cp.off('disconnect', handler);
|
48
78
|
break;
|
49
79
|
}
|
80
|
+
return true;
|
50
81
|
}
|
51
82
|
|
52
|
-
constructor(private cp: MessagePort | Worker)
|
53
|
-
{
|
54
|
-
cp.on('close', () => this.isOpen = false);
|
55
|
-
}
|
56
|
-
off<K extends keyof SocketAdapterEventMap>(event: K, handler?: (this: unknown, ev: SocketAdapterEventMap[K]) => void): void
|
57
|
-
{
|
58
|
-
this.cp.off(event, handler);
|
59
|
-
}
|
60
83
|
|
61
|
-
pipe(socket: SocketAdapter
|
84
|
+
pipe(socket: SocketAdapter)
|
62
85
|
{
|
63
86
|
this.on('message', (message) => socket.send(message));
|
64
87
|
this.on('close', () => socket.close());
|
@@ -78,4 +101,21 @@ export class MessagePortAdapter implements SocketAdapter
|
|
78
101
|
// _read()
|
79
102
|
// {
|
80
103
|
// }
|
104
|
+
|
105
|
+
|
106
|
+
hasListener<const TKey extends AllEventKeys<SocketAdapterAkalaEventMap>>(name: TKey)
|
107
|
+
{
|
108
|
+
if (name === 'open')
|
109
|
+
return false;
|
110
|
+
return !!this.cp.listenerCount(name);
|
111
|
+
}
|
112
|
+
get definedEvents(): AllEventKeys<SocketAdapterAkalaEventMap>[]
|
113
|
+
{
|
114
|
+
return (['close', 'error', 'message'] as const).filter(ev => this.hasListener(ev));
|
115
|
+
}
|
116
|
+
|
117
|
+
emit<const TEvent extends EventKeys<SocketAdapterAkalaEventMap>>(event: TEvent, ...args: EventArgs<SocketAdapterAkalaEventMap[TEvent]>): false | EventReturnType<SocketAdapterAkalaEventMap[TEvent]>
|
118
|
+
{
|
119
|
+
throw new Error("Method not implemented.");
|
120
|
+
}
|
81
121
|
}
|
@@ -63,7 +63,8 @@ export default class Runtime extends EventEmitter<ChildProcessRuntimeEventMap> i
|
|
63
63
|
case 'SIGTERM':
|
64
64
|
return this.stop(5000, signal.reason);
|
65
65
|
default:
|
66
|
-
|
66
|
+
if (signal.reason?.name !== 'AbortError' || options.keepAttached)
|
67
|
+
return this.stop(5000);
|
67
68
|
}
|
68
69
|
})
|
69
70
|
}
|
package/src/standalone.ts
CHANGED
@@ -82,7 +82,7 @@ program.option<string, 'program'>('program', { needsValue: true, normalize: true
|
|
82
82
|
initMiddleware.action(async c =>
|
83
83
|
{
|
84
84
|
if (init)
|
85
|
-
await cliContainer.dispatch(init, { options: c.options,
|
85
|
+
await cliContainer.dispatch(init, { options: c.options, params: c.args, _trigger: 'cli', context: c });
|
86
86
|
});
|
87
87
|
}),
|
88
88
|
initMiddleware));
|
package/src/test/pwet.json
CHANGED
@@ -0,0 +1,67 @@
|
|
1
|
+
import { Transform } from 'stream';
|
2
|
+
import { NewLinePrefixer } from './new-line-prefixer.js';
|
3
|
+
|
4
|
+
export class VirtualScrollPrefixer extends Transform
|
5
|
+
{
|
6
|
+
private buffer: string[] = [];
|
7
|
+
private readonly maxLines: number;
|
8
|
+
private readonly prefixer: NewLinePrefixer;
|
9
|
+
|
10
|
+
constructor(prefix: string, options: { maxLines?: number, useColors?: boolean } = {})
|
11
|
+
{
|
12
|
+
super();
|
13
|
+
this.maxLines = options.maxLines || 5;
|
14
|
+
this.prefixer = new NewLinePrefixer(prefix, { useColors: options.useColors });
|
15
|
+
}
|
16
|
+
|
17
|
+
_transform(chunk: Buffer | string, encoding: string, callback: () => void)
|
18
|
+
{
|
19
|
+
// Convert chunk to string if it's a buffer
|
20
|
+
const str = Buffer.isBuffer(chunk) ? chunk.toString() : chunk;
|
21
|
+
|
22
|
+
// Split the input into lines
|
23
|
+
const lines = str.split('\n');
|
24
|
+
|
25
|
+
// Process each line
|
26
|
+
lines.forEach((line, i) =>
|
27
|
+
{
|
28
|
+
if (line || i < lines.length - 1)
|
29
|
+
{ // Skip empty lines at the end
|
30
|
+
// Add the new line to the buffer
|
31
|
+
this.buffer.push(line);
|
32
|
+
|
33
|
+
// If buffer exceeds max lines, remove the oldest line
|
34
|
+
if (this.buffer.length > this.maxLines)
|
35
|
+
{
|
36
|
+
this.buffer.shift();
|
37
|
+
}
|
38
|
+
|
39
|
+
// Clear the terminal and rewrite all lines
|
40
|
+
this.push('\x1b[' + this.maxLines + 'A\x1b[0G\x1b[0J'); // Move cursor up and clear screen below
|
41
|
+
|
42
|
+
// Write each line in the buffer
|
43
|
+
this.buffer.forEach(bufferedLine =>
|
44
|
+
{
|
45
|
+
const prefixed = new Promise<string>((resolve) =>
|
46
|
+
{
|
47
|
+
this.prefixer._transform(bufferedLine, 'utf8', () =>
|
48
|
+
{
|
49
|
+
this.prefixer.once('data', (data) =>
|
50
|
+
{
|
51
|
+
resolve(data);
|
52
|
+
});
|
53
|
+
});
|
54
|
+
});
|
55
|
+
prefixed.then(data => this.push(data + '\n'));
|
56
|
+
});
|
57
|
+
}
|
58
|
+
});
|
59
|
+
|
60
|
+
callback();
|
61
|
+
}
|
62
|
+
|
63
|
+
_flush(callback: () => void)
|
64
|
+
{
|
65
|
+
callback();
|
66
|
+
}
|
67
|
+
}
|
package/test.json
CHANGED
@@ -4,29 +4,29 @@
|
|
4
4
|
{
|
5
5
|
"name": "pwet",
|
6
6
|
"inject": [
|
7
|
-
"
|
7
|
+
"params.0"
|
8
8
|
],
|
9
9
|
"config": {
|
10
10
|
"": {
|
11
11
|
"inject": [
|
12
|
-
"
|
12
|
+
"params.0"
|
13
13
|
]
|
14
14
|
},
|
15
15
|
"fs": {
|
16
16
|
"path": "dist/test/pwet.js",
|
17
17
|
"source": "src/test/pwet.ts",
|
18
18
|
"inject": [
|
19
|
-
"
|
19
|
+
"params.0"
|
20
20
|
]
|
21
21
|
},
|
22
22
|
"cli": {
|
23
23
|
"standalone": true,
|
24
24
|
"inject": [
|
25
|
-
"
|
25
|
+
"params.0"
|
26
26
|
]
|
27
27
|
}
|
28
28
|
}
|
29
29
|
}
|
30
30
|
],
|
31
31
|
"$schema": "https://raw.githubusercontent.com/npenin/akala/main/packages/commands/container-schema.json"
|
32
|
-
}
|
32
|
+
}
|