@volter/tabnode 0.5.10 → 0.5.12
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/assets/{runtime-worker-CQv8H3sj.js → runtime-worker-C5pP4aT7.js} +11 -4
- package/dist/index.d.ts +4 -1
- package/dist/index.mjs +21 -2
- package/dist/native-stream-owner.d.ts +11 -0
- package/package.json +1 -1
- package/src/http-client-transport.ts +3 -2
- package/src/index.ts +5 -2
- package/src/native-stream-owner.ts +22 -0
|
@@ -17621,10 +17621,17 @@ var implementation$1 = function bind2(that) {
|
|
|
17621
17621
|
var implementation = implementation$1;
|
|
17622
17622
|
var functionBind = Function.prototype.bind || implementation;
|
|
17623
17623
|
var functionCall = Function.prototype.call;
|
|
17624
|
-
var functionApply
|
|
17624
|
+
var functionApply;
|
|
17625
|
+
var hasRequiredFunctionApply;
|
|
17626
|
+
function requireFunctionApply() {
|
|
17627
|
+
if (hasRequiredFunctionApply) return functionApply;
|
|
17628
|
+
hasRequiredFunctionApply = 1;
|
|
17629
|
+
functionApply = Function.prototype.apply;
|
|
17630
|
+
return functionApply;
|
|
17631
|
+
}
|
|
17625
17632
|
var reflectApply = typeof Reflect !== "undefined" && Reflect && Reflect.apply;
|
|
17626
17633
|
var bind$2 = functionBind;
|
|
17627
|
-
var $apply$1 =
|
|
17634
|
+
var $apply$1 = requireFunctionApply();
|
|
17628
17635
|
var $call$2 = functionCall;
|
|
17629
17636
|
var $reflectApply = reflectApply;
|
|
17630
17637
|
var actualApply = $reflectApply || bind$2.call($call$2, $apply$1);
|
|
@@ -17744,7 +17751,7 @@ var hasSymbols = requireHasSymbols()();
|
|
|
17744
17751
|
var getProto = requireGetProto();
|
|
17745
17752
|
var $ObjectGPO = requireObject_getPrototypeOf();
|
|
17746
17753
|
var $ReflectGPO = requireReflect_getPrototypeOf();
|
|
17747
|
-
var $apply =
|
|
17754
|
+
var $apply = requireFunctionApply();
|
|
17748
17755
|
var $call = functionCall;
|
|
17749
17756
|
var needsEval = {};
|
|
17750
17757
|
var TypedArray = typeof Uint8Array === "undefined" || !getProto ? undefined$1 : getProto(Uint8Array);
|
|
@@ -18385,7 +18392,7 @@ function requireApplyBind() {
|
|
|
18385
18392
|
if (hasRequiredApplyBind) return applyBind;
|
|
18386
18393
|
hasRequiredApplyBind = 1;
|
|
18387
18394
|
var bind3 = functionBind;
|
|
18388
|
-
var $apply2 =
|
|
18395
|
+
var $apply2 = requireFunctionApply();
|
|
18389
18396
|
var actualApply$1 = actualApply;
|
|
18390
18397
|
applyBind = function applyBind2() {
|
|
18391
18398
|
return actualApply$1(bind3, $apply2, arguments);
|
package/dist/index.d.ts
CHANGED
|
@@ -44,6 +44,7 @@ import { Runtime, RuntimeOptions } from './runtime';
|
|
|
44
44
|
import { PackageManager } from './npm';
|
|
45
45
|
import { ServerBridge } from './server-bridge';
|
|
46
46
|
import { type Socket as NetSocket } from './node-lib/net-module';
|
|
47
|
+
import { type NativeStreamHandleView } from './native-stream-owner';
|
|
47
48
|
import { runPid, processByPid } from './process-tokens';
|
|
48
49
|
export { runPid, processByPid };
|
|
49
50
|
export { createProcessRegistryScope, installProcessRegistry, ownerProcessRegistryScope, ownerProcessTable } from './process-tokens';
|
|
@@ -52,7 +53,7 @@ export type { NodeProcessLaunch, NodeProcessHost } from './node-process-host';
|
|
|
52
53
|
export type { ProcessIdentity, ProcessRegistry, ProcessRegistryScope, InitialProcessRegistration } from './process-registry';
|
|
53
54
|
export { NativeStreamScope } from './native-stream-owner';
|
|
54
55
|
export { installNativeStreamTransport, nativeStreamDescriptor } from './native-stream-binding';
|
|
55
|
-
export type { NativeStreamDescriptor, NativeStreamLimits, NativeStreamEvent, NativeStreamOperation, NativeStreamReply, NativeStreamTransport } from './native-stream-owner';
|
|
56
|
+
export type { NativeStreamDescriptor, NativeStreamLimits, NativeStreamEvent, NativeStreamOperation, NativeStreamReply, NativeStreamTransport, NativeStreamHandleView } from './native-stream-owner';
|
|
56
57
|
export interface RunResult {
|
|
57
58
|
stdout: string;
|
|
58
59
|
stderr: string;
|
|
@@ -116,6 +117,8 @@ export declare function createContainer(options?: ContainerOptions): {
|
|
|
116
117
|
processPorts: (token: string) => number[];
|
|
117
118
|
/** The pid of the process listening on a port of this engine, where a guest process is: `/proc`'s socket owner. */
|
|
118
119
|
portPid: (port: number) => number | undefined;
|
|
120
|
+
/** The stream handles the processes of other workers hold through this engine: `/proc/<pid>/fd`. */
|
|
121
|
+
streamHandles: () => NativeStreamHandleView[];
|
|
119
122
|
/** Deliver a signal to the named run as another process's `kill(pid)` does; false when the run is gone. */
|
|
120
123
|
signalProcess: (token: string, signal: string) => boolean;
|
|
121
124
|
stopProcess: (token: string) => boolean;
|
package/dist/index.mjs
CHANGED
|
@@ -35728,7 +35728,7 @@ class WorkerRuntime {
|
|
|
35728
35728
|
this.worker = new Worker(
|
|
35729
35729
|
new URL(
|
|
35730
35730
|
/* @vite-ignore */
|
|
35731
|
-
"/assets/runtime-worker-
|
|
35731
|
+
"/assets/runtime-worker-C5pP4aT7.js",
|
|
35732
35732
|
import.meta.url
|
|
35733
35733
|
),
|
|
35734
35734
|
{ type: "module" }
|
|
@@ -35962,7 +35962,7 @@ function installHttpClientTransport(factory, transportOptions = {}) {
|
|
|
35962
35962
|
}
|
|
35963
35963
|
try {
|
|
35964
35964
|
if (options.socketPath || options.localAddress || options.localPort || options.lookup || options.family) throw unsupported("custom socket routing");
|
|
35965
|
-
if (tlsOptions.some((key) => options[key] !== void 0) || options.rejectUnauthorized === false || options.servername !== void 0 && options.servername !== host2) throw unsupported("custom TLS options");
|
|
35965
|
+
if (protocol === "https:" && (tlsOptions.some((key) => options[key] !== void 0) || options.rejectUnauthorized === false || options.servername !== void 0 && options.servername !== host2)) throw unsupported("custom TLS options");
|
|
35966
35966
|
const authority = new URL(`${protocol}//${host2.includes(":") && !host2.startsWith("[") ? `[${host2}]` : host2}:${options.port ?? (protocol === "https:" ? 443 : 80)}`);
|
|
35967
35967
|
return connection(authority, factory(), require2);
|
|
35968
35968
|
} catch (cause) {
|
|
@@ -38098,6 +38098,7 @@ function resetServerBridge() {
|
|
|
38098
38098
|
globalBridge = null;
|
|
38099
38099
|
}
|
|
38100
38100
|
const scopes = /* @__PURE__ */ new WeakMap();
|
|
38101
|
+
const liveScopes = /* @__PURE__ */ new Set();
|
|
38101
38102
|
class NativeStreamScope {
|
|
38102
38103
|
/**
|
|
38103
38104
|
* `ownerPid` names the process whose worker this scope serves: a listener
|
|
@@ -38116,6 +38117,19 @@ class NativeStreamScope {
|
|
|
38116
38117
|
this.ownerPid = ownerPid;
|
|
38117
38118
|
if ([limits.maxHandles, limits.maxReadChunkBytes, limits.maxQueuedBytes, limits.maxQueuedHandles, limits.maxPendingWriteBytes].some((value) => !Number.isSafeInteger(value) || value < 1) || limits.maxReadChunkBytes > 2147483647 || limits.maxReadChunkBytes > limits.maxQueuedBytes || limits.maxReadChunkBytes > limits.maxPendingWriteBytes) throw new Error("Invalid native stream resource limits.");
|
|
38118
38119
|
this.limits = Object.freeze({ ...limits });
|
|
38120
|
+
liveScopes.add(this);
|
|
38121
|
+
}
|
|
38122
|
+
/** This scope's open handles, with the process it serves. */
|
|
38123
|
+
handles() {
|
|
38124
|
+
var _a2;
|
|
38125
|
+
if (this.disposed) return [];
|
|
38126
|
+
const pid = (_a2 = this.ownerPid) == null ? void 0 : _a2.call(this);
|
|
38127
|
+
return [...this.entries.values()].map(({ handle, descriptor }) => ({
|
|
38128
|
+
...pid !== void 0 ? { pid } : {},
|
|
38129
|
+
id: descriptor.id,
|
|
38130
|
+
kind: descriptor.kind,
|
|
38131
|
+
listening: !!handle.listening
|
|
38132
|
+
}));
|
|
38119
38133
|
}
|
|
38120
38134
|
entry(id) {
|
|
38121
38135
|
return this.disposed ? void 0 : this.entries.get(id);
|
|
@@ -38387,6 +38401,7 @@ class NativeStreamScope {
|
|
|
38387
38401
|
dispose() {
|
|
38388
38402
|
if (this.disposed) return;
|
|
38389
38403
|
this.disposed = true;
|
|
38404
|
+
liveScopes.delete(this);
|
|
38390
38405
|
const failures = [];
|
|
38391
38406
|
for (const id of [...this.entries.keys()]) {
|
|
38392
38407
|
try {
|
|
@@ -38402,6 +38417,9 @@ function nativeStreamOwnerPid(handle) {
|
|
|
38402
38417
|
var _a2, _b2;
|
|
38403
38418
|
return (_b2 = (_a2 = scopes.get(handle)) == null ? void 0 : _a2.ownerPid) == null ? void 0 : _b2.call(_a2);
|
|
38404
38419
|
}
|
|
38420
|
+
function nativeStreamHandles() {
|
|
38421
|
+
return [...liveScopes].flatMap((scope) => scope.handles());
|
|
38422
|
+
}
|
|
38405
38423
|
let __nextRunName = 1;
|
|
38406
38424
|
function createContainer(options) {
|
|
38407
38425
|
const vfs2 = options && options.vfs || new VirtualFS();
|
|
@@ -38464,6 +38482,7 @@ function createContainer(options) {
|
|
|
38464
38482
|
if (!listener) return void 0;
|
|
38465
38483
|
return ((_a2 = runPid(ownerOf(listener))) == null ? void 0 : _a2.pid) ?? nativeStreamOwnerPid(listener);
|
|
38466
38484
|
},
|
|
38485
|
+
streamHandles: () => nativeStreamHandles(),
|
|
38467
38486
|
/**
|
|
38468
38487
|
* Deliver a signal to the named run as another process's `kill(pid)` does:
|
|
38469
38488
|
* the guest's listeners for it run, else its default action ends the run.
|
|
@@ -88,6 +88,13 @@ export interface NativeStreamTransport {
|
|
|
88
88
|
write(id: number, bytes: Uint8Array, handle?: number): Promise<number>;
|
|
89
89
|
onEvent(listener: (event: NativeStreamEvent) => void): () => void;
|
|
90
90
|
}
|
|
91
|
+
/** One open stream handle, as a process's descriptor table shows it. */
|
|
92
|
+
export interface NativeStreamHandleView {
|
|
93
|
+
pid?: number;
|
|
94
|
+
id: number;
|
|
95
|
+
kind: 'tcp' | 'pipe';
|
|
96
|
+
listening: boolean;
|
|
97
|
+
}
|
|
91
98
|
/**
|
|
92
99
|
* One capability namespace per worker. Only the trusted host can inherit a
|
|
93
100
|
* descriptor from another scope; wire operations can name this scope's IDs only.
|
|
@@ -108,6 +115,8 @@ export declare class NativeStreamScope {
|
|
|
108
115
|
* it opens is that process's socket, as the container's /proc shows it.
|
|
109
116
|
*/
|
|
110
117
|
constructor(limits: NativeStreamLimits, emit: (event: NativeStreamEvent) => void, ownerPid?: (() => number | undefined) | undefined);
|
|
118
|
+
/** This scope's open handles, with the process it serves. */
|
|
119
|
+
handles(): NativeStreamHandleView[];
|
|
111
120
|
private entry;
|
|
112
121
|
private publish;
|
|
113
122
|
private claim;
|
|
@@ -126,3 +135,5 @@ export declare class NativeStreamScope {
|
|
|
126
135
|
}
|
|
127
136
|
/** The process a handle opened for another worker's process belongs to, where a scope holds it. */
|
|
128
137
|
export declare function nativeStreamOwnerPid(handle: object): number | undefined;
|
|
138
|
+
/** Every open native stream handle in this worker, by the process each scope serves. */
|
|
139
|
+
export declare function nativeStreamHandles(): NativeStreamHandleView[];
|
package/package.json
CHANGED
|
@@ -61,8 +61,9 @@ export function installHttpClientTransport(factory: HttpClientTransportFactory,
|
|
|
61
61
|
}
|
|
62
62
|
try {
|
|
63
63
|
if (options.socketPath || options.localAddress || options.localPort || options.lookup || options.family) throw unsupported('custom socket routing');
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
// Node's Agent names a servername for plain HTTP too ('' for an IP); TLS options are an https question.
|
|
65
|
+
if (protocol === 'https:' && (tlsOptions.some(key => options[key] !== undefined) || options.rejectUnauthorized === false
|
|
66
|
+
|| (options.servername !== undefined && options.servername !== host))) throw unsupported('custom TLS options');
|
|
66
67
|
const authority = new URL(`${protocol}//${host.includes(':') && !host.startsWith('[') ? `[${host}]` : host}:${options.port ?? (protocol === 'https:' ? 443 : 80)}`);
|
|
67
68
|
return connection(authority, factory(), require);
|
|
68
69
|
} catch (cause) {
|
package/src/index.ts
CHANGED
|
@@ -56,7 +56,7 @@ import { runCommand, registerRunStreams, releaseRunStreams, sendStdin } from './
|
|
|
56
56
|
import { Server as NetServer, __releaseOwnedHandles, type Socket as NetSocket } from './node-lib/net-module';
|
|
57
57
|
import { __adoptHandle, ownerOf, type OwnedHandle } from './node-lib/binding/handles';
|
|
58
58
|
import { listenerOnPort } from './node-lib/binding/tcp_wrap';
|
|
59
|
-
import { nativeStreamOwnerPid } from './native-stream-owner';
|
|
59
|
+
import { nativeStreamHandles, nativeStreamOwnerPid, type NativeStreamHandleView } from './native-stream-owner';
|
|
60
60
|
|
|
61
61
|
import { __currentProcessToken, __runFor, __signalOwnedProcess, __takeTermination, __stopOwnedProcess, runPid, processByPid } from './process-tokens';
|
|
62
62
|
export { runPid, processByPid };
|
|
@@ -66,7 +66,7 @@ export type { NodeProcessLaunch, NodeProcessHost } from './node-process-host';
|
|
|
66
66
|
export type { ProcessIdentity, ProcessRegistry, ProcessRegistryScope, InitialProcessRegistration } from './process-registry';
|
|
67
67
|
export { NativeStreamScope } from './native-stream-owner';
|
|
68
68
|
export { installNativeStreamTransport, nativeStreamDescriptor } from './native-stream-binding';
|
|
69
|
-
export type { NativeStreamDescriptor, NativeStreamLimits, NativeStreamEvent, NativeStreamOperation, NativeStreamReply, NativeStreamTransport } from './native-stream-owner';
|
|
69
|
+
export type { NativeStreamDescriptor, NativeStreamLimits, NativeStreamEvent, NativeStreamOperation, NativeStreamReply, NativeStreamTransport, NativeStreamHandleView } from './native-stream-owner';
|
|
70
70
|
|
|
71
71
|
export interface RunResult {
|
|
72
72
|
stdout: string;
|
|
@@ -129,6 +129,8 @@ export function createContainer(options?: ContainerOptions): {
|
|
|
129
129
|
processPorts: (token: string) => number[];
|
|
130
130
|
/** The pid of the process listening on a port of this engine, where a guest process is: `/proc`'s socket owner. */
|
|
131
131
|
portPid: (port: number) => number | undefined;
|
|
132
|
+
/** The stream handles the processes of other workers hold through this engine: `/proc/<pid>/fd`. */
|
|
133
|
+
streamHandles: () => NativeStreamHandleView[];
|
|
132
134
|
/** Deliver a signal to the named run as another process's `kill(pid)` does; false when the run is gone. */
|
|
133
135
|
signalProcess: (token: string, signal: string) => boolean;
|
|
134
136
|
stopProcess: (token: string) => boolean;
|
|
@@ -224,6 +226,7 @@ export function createContainer(options?: ContainerOptions): {
|
|
|
224
226
|
// a guest's own listener, or one this engine holds for another worker's process
|
|
225
227
|
return runPid(ownerOf(listener as unknown as OwnedHandle))?.pid ?? nativeStreamOwnerPid(listener);
|
|
226
228
|
},
|
|
229
|
+
streamHandles: (): NativeStreamHandleView[] => nativeStreamHandles(),
|
|
227
230
|
/**
|
|
228
231
|
* Deliver a signal to the named run as another process's `kill(pid)` does:
|
|
229
232
|
* the guest's listeners for it run, else its default action ends the run.
|
|
@@ -41,6 +41,12 @@ export interface NativeStreamTransport {
|
|
|
41
41
|
type NativeHandle = TCP | Pipe;
|
|
42
42
|
interface Entry { handle: NativeHandle; descriptor: NativeStreamDescriptor; buffer?: Uint8Array }
|
|
43
43
|
const scopes = new WeakMap<LibuvStreamWrap, NativeStreamScope>();
|
|
44
|
+
// Every scope not yet disposed: what the container's /proc lists as each
|
|
45
|
+
// process's descriptors.
|
|
46
|
+
const liveScopes = new Set<NativeStreamScope>();
|
|
47
|
+
|
|
48
|
+
/** One open stream handle, as a process's descriptor table shows it. */
|
|
49
|
+
export interface NativeStreamHandleView { pid?: number; id: number; kind: 'tcp' | 'pipe'; listening: boolean }
|
|
44
50
|
|
|
45
51
|
/**
|
|
46
52
|
* One capability namespace per worker. Only the trusted host can inherit a
|
|
@@ -66,6 +72,16 @@ export class NativeStreamScope {
|
|
|
66
72
|
|| limits.maxReadChunkBytes > limits.maxQueuedBytes
|
|
67
73
|
|| limits.maxReadChunkBytes > limits.maxPendingWriteBytes) throw new Error('Invalid native stream resource limits.');
|
|
68
74
|
this.limits = Object.freeze({ ...limits });
|
|
75
|
+
liveScopes.add(this);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** This scope's open handles, with the process it serves. */
|
|
79
|
+
handles(): NativeStreamHandleView[] {
|
|
80
|
+
if (this.disposed) return [];
|
|
81
|
+
const pid = this.ownerPid?.();
|
|
82
|
+
return [...this.entries.values()].map(({ handle, descriptor }) => ({
|
|
83
|
+
...(pid !== undefined ? { pid } : {}), id: descriptor.id, kind: descriptor.kind, listening: !!handle.listening,
|
|
84
|
+
}));
|
|
69
85
|
}
|
|
70
86
|
|
|
71
87
|
private entry(id: number): Entry | undefined {
|
|
@@ -318,6 +334,7 @@ export class NativeStreamScope {
|
|
|
318
334
|
dispose(): void {
|
|
319
335
|
if (this.disposed) return;
|
|
320
336
|
this.disposed = true;
|
|
337
|
+
liveScopes.delete(this);
|
|
321
338
|
const failures: unknown[] = [];
|
|
322
339
|
for (const id of [...this.entries.keys()]) {
|
|
323
340
|
try { this.close(id); } catch (cause) { failures.push(cause); }
|
|
@@ -330,3 +347,8 @@ export class NativeStreamScope {
|
|
|
330
347
|
export function nativeStreamOwnerPid(handle: object): number | undefined {
|
|
331
348
|
return scopes.get(handle as NativeHandle)?.ownerPid?.();
|
|
332
349
|
}
|
|
350
|
+
|
|
351
|
+
/** Every open native stream handle in this worker, by the process each scope serves. */
|
|
352
|
+
export function nativeStreamHandles(): NativeStreamHandleView[] {
|
|
353
|
+
return [...liveScopes].flatMap(scope => scope.handles());
|
|
354
|
+
}
|