@nimbus-sh/core 0.6.0 → 0.7.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/README.md +47 -26
- package/dist/_shared/byte-stream.d.ts +5 -4
- package/dist/_shared/byte-stream.d.ts.map +1 -1
- package/dist/_shared/real-node-imports.d.ts +7 -0
- package/dist/_shared/real-node-imports.d.ts.map +1 -1
- package/dist/_shared/real-node-imports.js +8 -0
- package/dist/_shared/tarball.d.ts +23 -5
- package/dist/_shared/tarball.d.ts.map +1 -1
- package/dist/_shared/tarball.js +38 -5
- package/dist/_shared/vfs-write-ledger.d.ts.map +1 -1
- package/dist/_shared/vfs-write-ledger.js +22 -16
- package/dist/runtime/comment-strip.d.ts +0 -35
- package/dist/runtime/comment-strip.d.ts.map +1 -1
- package/dist/runtime/comment-strip.js +48 -20
- package/dist/runtime/esbuild-service.d.ts +38 -42
- package/dist/runtime/esbuild-service.d.ts.map +1 -1
- package/dist/runtime/esbuild-service.js +494 -197
- package/dist/runtime/javascript-ast.d.ts.map +1 -1
- package/dist/runtime/javascript-ast.js +45 -7
- package/dist/runtime/opentui-wasm-backend.d.ts.map +1 -1
- package/dist/runtime/opentui-wasm-backend.js +18 -16
- package/dist/runtime/port-registry.d.ts +4 -2
- package/dist/runtime/port-registry.d.ts.map +1 -1
- package/dist/runtime/port-registry.js +60 -8
- package/dist/shell/stdin-adapter.d.ts +11 -0
- package/dist/shell/stdin-adapter.d.ts.map +1 -0
- package/dist/shell/stdin-adapter.js +59 -0
- package/dist/shell/unix-commands.d.ts +2 -1
- package/dist/shell/unix-commands.d.ts.map +1 -1
- package/dist/shell/unix-commands.js +1078 -50
- package/dist/substrate/lifo/commands/io/dd.js +1 -1
- package/dist/substrate/lifo/commands/net/curl.d.ts.map +1 -1
- package/dist/substrate/lifo/commands/net/curl.js +270 -54
- package/dist/substrate/lifo/commands/system/npm.d.ts +18 -1
- package/dist/substrate/lifo/commands/system/npm.d.ts.map +1 -1
- package/dist/substrate/lifo/commands/system/npm.js +26 -43
- package/dist/substrate/lifo/commands/text/head.d.ts.map +1 -1
- package/dist/substrate/lifo/commands/text/head.js +2 -1
- package/dist/substrate/lifo/commands/text/sed.d.ts.map +1 -1
- package/dist/substrate/lifo/commands/text/sed.js +499 -117
- package/dist/substrate/lifo/commands/types.d.ts +8 -4
- package/dist/substrate/lifo/commands/types.d.ts.map +1 -1
- package/dist/substrate/lifo/node-compat/zlib.d.ts +37 -18
- package/dist/substrate/lifo/node-compat/zlib.d.ts.map +1 -1
- package/dist/substrate/lifo/node-compat/zlib.js +122 -23
- package/dist/substrate/lifo/shell/interpreter.d.ts +9 -1
- package/dist/substrate/lifo/shell/interpreter.d.ts.map +1 -1
- package/dist/substrate/lifo/shell/interpreter.js +79 -29
- package/dist/substrate/lifo/shell/pipe.d.ts +16 -0
- package/dist/substrate/lifo/shell/pipe.d.ts.map +1 -1
- package/dist/substrate/lifo/shell/pipe.js +62 -18
- package/dist/substrate/lifo/shell/terminal-stdin.d.ts +20 -3
- package/dist/substrate/lifo/shell/terminal-stdin.d.ts.map +1 -1
- package/dist/substrate/lifo/shell/terminal-stdin.js +60 -24
- package/dist/vfs/sqlite-vfs.d.ts +19 -0
- package/dist/vfs/sqlite-vfs.d.ts.map +1 -1
- package/dist/vfs/sqlite-vfs.js +106 -23
- package/dist/workspace/nimbus-workspace.d.ts +15 -0
- package/dist/workspace/nimbus-workspace.d.ts.map +1 -1
- package/dist/workspace/nimbus-workspace.js +20 -3
- package/dist/workspace/supervisor-op.d.ts +23 -0
- package/dist/workspace/supervisor-op.d.ts.map +1 -0
- package/dist/workspace/supervisor-op.js +92 -0
- package/package.json +2 -2
- package/src/_shared/byte-stream.ts +5 -4
- package/src/_shared/real-node-imports.ts +8 -0
- package/src/_shared/tarball.ts +56 -5
- package/src/_shared/vfs-write-ledger.ts +22 -16
- package/src/runtime/comment-strip.ts +42 -23
- package/src/runtime/esbuild-service.ts +566 -217
- package/src/runtime/javascript-ast.ts +40 -9
- package/src/runtime/opentui-wasm-backend.ts +19 -17
- package/src/runtime/port-registry.ts +66 -8
- package/src/shell/stdin-adapter.ts +58 -0
- package/src/shell/unix-commands.ts +1054 -50
- package/src/substrate/lifo/commands/io/dd.ts +2 -2
- package/src/substrate/lifo/commands/net/curl.ts +310 -58
- package/src/substrate/lifo/commands/system/npm.ts +58 -38
- package/src/substrate/lifo/commands/text/head.ts +2 -1
- package/src/substrate/lifo/commands/text/sed.ts +519 -109
- package/src/substrate/lifo/commands/types.ts +8 -5
- package/src/substrate/lifo/node-compat/zlib.ts +155 -26
- package/src/substrate/lifo/shell/interpreter.ts +74 -27
- package/src/substrate/lifo/shell/pipe.ts +65 -24
- package/src/substrate/lifo/shell/terminal-stdin.ts +66 -30
- package/src/vfs/sqlite-vfs.ts +104 -23
- package/src/workspace/nimbus-workspace.ts +26 -2
- package/src/workspace/supervisor-op.ts +117 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"javascript-ast.d.ts","sourceRoot":"","sources":["../../src/runtime/javascript-ast.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"javascript-ast.d.ts","sourceRoot":"","sources":["../../src/runtime/javascript-ast.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,OAAO,EAAkB,MAAM,OAAO,CAAC;AAEjF,MAAM,MAAM,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAExD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAM7D;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CA4C/D;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,EAAE,CAI9D;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAIpF;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAItE;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAG1E;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAGhE;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAEhF;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAElF;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAE1D"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { parse } from 'acorn';
|
|
1
|
+
import { parse, tokenizer, tokTypes } from 'acorn';
|
|
2
2
|
export function parseJavaScriptModule(source) {
|
|
3
3
|
return parse(source, {
|
|
4
4
|
ecmaVersion: 'latest',
|
|
@@ -7,17 +7,55 @@ export function parseJavaScriptModule(source) {
|
|
|
7
7
|
});
|
|
8
8
|
}
|
|
9
9
|
export function hasTopLevelModuleSyntax(source) {
|
|
10
|
-
let ast;
|
|
11
10
|
try {
|
|
12
|
-
|
|
11
|
+
const tokens = tokenizer(source, {
|
|
12
|
+
ecmaVersion: 'latest',
|
|
13
|
+
sourceType: 'module',
|
|
14
|
+
allowHashBang: true,
|
|
15
|
+
});
|
|
16
|
+
let braceDepth = 0;
|
|
17
|
+
let parenDepth = 0;
|
|
18
|
+
let bracketDepth = 0;
|
|
19
|
+
let previous;
|
|
20
|
+
const updateDepth = (type) => {
|
|
21
|
+
if (type === tokTypes.braceL || type === tokTypes.dollarBraceL)
|
|
22
|
+
braceDepth++;
|
|
23
|
+
else if (type === tokTypes.braceR)
|
|
24
|
+
braceDepth = Math.max(0, braceDepth - 1);
|
|
25
|
+
else if (type === tokTypes.parenL)
|
|
26
|
+
parenDepth++;
|
|
27
|
+
else if (type === tokTypes.parenR)
|
|
28
|
+
parenDepth = Math.max(0, parenDepth - 1);
|
|
29
|
+
else if (type === tokTypes.bracketL)
|
|
30
|
+
bracketDepth++;
|
|
31
|
+
else if (type === tokTypes.bracketR)
|
|
32
|
+
bracketDepth = Math.max(0, bracketDepth - 1);
|
|
33
|
+
};
|
|
34
|
+
while (true) {
|
|
35
|
+
const token = tokens.getToken();
|
|
36
|
+
const type = token.type;
|
|
37
|
+
if (type === tokTypes.eof)
|
|
38
|
+
return false;
|
|
39
|
+
const topLevel = braceDepth === 0 && parenDepth === 0 && bracketDepth === 0;
|
|
40
|
+
if (topLevel && previous !== tokTypes.dot) {
|
|
41
|
+
if (type === tokTypes._export)
|
|
42
|
+
return true;
|
|
43
|
+
if (type === tokTypes._import) {
|
|
44
|
+
const next = tokens.getToken();
|
|
45
|
+
if (next.type !== tokTypes.parenL && next.type !== tokTypes.dot)
|
|
46
|
+
return true;
|
|
47
|
+
updateDepth(next.type);
|
|
48
|
+
previous = next.type;
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
updateDepth(type);
|
|
53
|
+
previous = type;
|
|
54
|
+
}
|
|
13
55
|
}
|
|
14
56
|
catch {
|
|
15
57
|
return false;
|
|
16
58
|
}
|
|
17
|
-
return nodeList(ast, 'body').some((node) => node.type === 'ImportDeclaration' ||
|
|
18
|
-
node.type === 'ExportNamedDeclaration' ||
|
|
19
|
-
node.type === 'ExportDefaultDeclaration' ||
|
|
20
|
-
node.type === 'ExportAllDeclaration');
|
|
21
59
|
}
|
|
22
60
|
export function nodeList(node, key) {
|
|
23
61
|
const value = node[key];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opentui-wasm-backend.d.ts","sourceRoot":"","sources":["../../src/runtime/opentui-wasm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AK,MAAM,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC,CAAA;KAAE,EAC9E,OAAO,EAAE,cAAc,EACvB,MAAM,EAAE,MAAM,GACb,CAAC;IAKJ,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,iBAAiB;CAiMrE;AAID,wBAAgB,QAAQ,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,CAExD;AAED,iFAAiF;AACjF,wBAAgB,SAAS,CAAC,KAAK,EAAE,WAAW,GAAG,eAAe,GAAG;IAC/D,KAAK,EAAE,UAAU,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB,CAOA"}
|
|
@@ -78,13 +78,12 @@ export class OpenTUIWasmBackend {
|
|
|
78
78
|
* semantics), so each `dlopen`'d symbol call frees what was allocated before
|
|
79
79
|
* it. Without this a per-frame `rgbaPtr(color)` would leak linear memory.
|
|
80
80
|
*
|
|
81
|
-
* `view` is
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
* `
|
|
86
|
-
*
|
|
87
|
-
* so the claimed-scratch release copies these back before freeing.
|
|
81
|
+
* `view` is a writable byte view over the caller's original storage.
|
|
82
|
+
* Native `ptr(value)` exposes live memory for both ArrayBuffer and typed-array
|
|
83
|
+
* inputs, so every transient allocation copies back after the symbol call.
|
|
84
|
+
* OpenTUI's struct getters use bare ArrayBuffers (`LogicalCursorStruct`,
|
|
85
|
+
* `VisualCursorStruct`, stats, terminal capabilities), while span-feed drains
|
|
86
|
+
* use typed arrays. Both forms must observe Zig's writes.
|
|
88
87
|
*/
|
|
89
88
|
#pendingPtrScratch = [];
|
|
90
89
|
/**
|
|
@@ -176,12 +175,10 @@ export class OpenTUIWasmBackend {
|
|
|
176
175
|
// allocation as transient scratch that the next symbol call frees (see
|
|
177
176
|
// `#bindSymbol`). This keeps a per-frame `rgbaPtr(color)` loop leak-free.
|
|
178
177
|
//
|
|
179
|
-
//
|
|
180
|
-
// a live pointer into the
|
|
181
|
-
//
|
|
182
|
-
//
|
|
183
|
-
// and every FFIRenderLib `ptr(outBuffer)`/`ptr(cursorBuffer)`/`ptr(statsBuffer)`
|
|
184
|
-
// getter depend on this). Read-only ArrayBuffers carry a null view (copy-in only).
|
|
178
|
+
// Every ArrayBuffer and ArrayBufferView is potentially an OUT-buffer:
|
|
179
|
+
// native `ptr(value)` is a live pointer into the same storage. Copy the
|
|
180
|
+
// arena bytes back after the call so bare struct buffers and typed-array
|
|
181
|
+
// windows have identical semantics.
|
|
185
182
|
ptr(value) {
|
|
186
183
|
const { bytes, byteOffset, byteLength } = viewBytes(value);
|
|
187
184
|
const size = byteLength === 0 ? ARENA_ALIGN : byteLength;
|
|
@@ -192,7 +189,7 @@ export class OpenTUIWasmBackend {
|
|
|
192
189
|
this.#pendingPtrScratch.push({
|
|
193
190
|
offset,
|
|
194
191
|
size,
|
|
195
|
-
view: ArrayBuffer.isView(value) ? value :
|
|
192
|
+
view: ArrayBuffer.isView(value) ? value : new Uint8Array(value),
|
|
196
193
|
});
|
|
197
194
|
return offset;
|
|
198
195
|
}
|
|
@@ -336,8 +333,13 @@ export class OpenTUIWasmBackend {
|
|
|
336
333
|
scratchBytes += s.size;
|
|
337
334
|
diag.rec(name, this.#exports.memory.buffer.byteLength - memBefore, marshaled, scratchBytes);
|
|
338
335
|
}
|
|
339
|
-
if (returns === 'u64'
|
|
340
|
-
|
|
336
|
+
if (returns === 'u64') {
|
|
337
|
+
const value = typeof result === 'bigint' ? result : BigInt(result);
|
|
338
|
+
return BigInt.asUintN(64, value);
|
|
339
|
+
}
|
|
340
|
+
if (returns === 'i64') {
|
|
341
|
+
const value = typeof result === 'bigint' ? result : BigInt(result);
|
|
342
|
+
return BigInt.asIntN(64, value);
|
|
341
343
|
}
|
|
342
344
|
return result;
|
|
343
345
|
};
|
|
@@ -23,8 +23,9 @@
|
|
|
23
23
|
* `request.method` and application headers mirror the outer request,
|
|
24
24
|
* Nimbus credentials/internal headers are removed, and
|
|
25
25
|
* `request.body` is a ReadableStream (or null for GET/HEAD) that
|
|
26
|
-
* the facet can consume once. The returned Response is
|
|
27
|
-
*
|
|
26
|
+
* the facet can consume once. The returned Response is streamed
|
|
27
|
+
* straight back, with one normalization: the hop speaks identity,
|
|
28
|
+
* so a compressed body is decoded here. See `decodeContentCoding`.
|
|
28
29
|
*/
|
|
29
30
|
import type { RouteableFacetTarget } from './os-contracts.js';
|
|
30
31
|
export interface PortEntry {
|
|
@@ -44,6 +45,7 @@ export interface PortEntry {
|
|
|
44
45
|
*/
|
|
45
46
|
capability: string;
|
|
46
47
|
}
|
|
48
|
+
export declare function createPortCapability(): string;
|
|
47
49
|
export declare class PortRegistry {
|
|
48
50
|
private ports;
|
|
49
51
|
private facetStubsByPid;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"port-registry.d.ts","sourceRoot":"","sources":["../../src/runtime/port-registry.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"port-registry.d.ts","sourceRoot":"","sources":["../../src/runtime/port-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAGH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ;;;;OAIG;IACH,SAAS,EAAE,oBAAoB,GAAG,IAAI,CAAC;IACvC,YAAY,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAuDD,wBAAgB,oBAAoB,IAAI,MAAM,CAG7C;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,KAAK,CAAgC;IAC7C,OAAO,CAAC,eAAe,CAA2C;IAClE,OAAO,CAAC,gBAAgB,CAAsC;IAE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lC,IAAI,KAAK;;;;;;MAKR;IAED,OAAO,CAAC,oBAAoB;IAsB5B,OAAO,CAAC,iBAAiB;CAM1B"}
|
|
@@ -23,11 +23,59 @@
|
|
|
23
23
|
* `request.method` and application headers mirror the outer request,
|
|
24
24
|
* Nimbus credentials/internal headers are removed, and
|
|
25
25
|
* `request.body` is a ReadableStream (or null for GET/HEAD) that
|
|
26
|
-
* the facet can consume once. The returned Response is
|
|
27
|
-
*
|
|
26
|
+
* the facet can consume once. The returned Response is streamed
|
|
27
|
+
* straight back, with one normalization: the hop speaks identity,
|
|
28
|
+
* so a compressed body is decoded here. See `decodeContentCoding`.
|
|
28
29
|
*/
|
|
29
30
|
import { sanitizeUntrustedHeaders } from '../_shared/untrusted-request.js';
|
|
30
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Content codings this hop can undo. `DecompressionStream` decodes exactly
|
|
33
|
+
* these; brotli and zstd have no decoder in the runtime, so a body in one of
|
|
34
|
+
* those cannot be repaired here.
|
|
35
|
+
*/
|
|
36
|
+
const DECODABLE_CONTENT_CODINGS = new Map([
|
|
37
|
+
['gzip', 'gzip'],
|
|
38
|
+
['x-gzip', 'gzip'],
|
|
39
|
+
['deflate', 'deflate'],
|
|
40
|
+
]);
|
|
41
|
+
/**
|
|
42
|
+
* Hand back a port target's response with its bytes and its headers in
|
|
43
|
+
* agreement.
|
|
44
|
+
*
|
|
45
|
+
* A `Response` a facet builds always holds an identity body. The runtime
|
|
46
|
+
* treats the bytes a `Response` is constructed from as unencoded and runs its
|
|
47
|
+
* own content negotiation on the way out: it drops a `Content-Encoding` the
|
|
48
|
+
* client did not ask for, and compresses again when the client did. Either
|
|
49
|
+
* way a guest server's `Content-Encoding` is a label with nothing behind it,
|
|
50
|
+
* and the browser renders compressed bytes as text.
|
|
51
|
+
*
|
|
52
|
+
* The forwarded request asks the target for `identity`, so this decode covers
|
|
53
|
+
* the server that compresses whatever the client said. A coding with no
|
|
54
|
+
* decoder answers 502: an honest failure beats a page of mojibake.
|
|
55
|
+
*/
|
|
56
|
+
function decodeContentCoding(response, port) {
|
|
57
|
+
const coding = response.headers.get('Content-Encoding')?.trim().toLowerCase();
|
|
58
|
+
if (!coding || coding === 'identity' || response.body === null)
|
|
59
|
+
return response;
|
|
60
|
+
const format = DECODABLE_CONTENT_CODINGS.get(coding);
|
|
61
|
+
if (!format) {
|
|
62
|
+
void response.body.cancel().catch(() => { });
|
|
63
|
+
return new Response(JSON.stringify({
|
|
64
|
+
error: `port proxy: target answered Content-Encoding "${coding}", which this hop cannot decode`,
|
|
65
|
+
port,
|
|
66
|
+
}), { status: 502, headers: { 'Content-Type': 'application/json' } });
|
|
67
|
+
}
|
|
68
|
+
const headers = new Headers(response.headers);
|
|
69
|
+
headers.delete('Content-Encoding');
|
|
70
|
+
// The decoded body has a different length; the Response re-derives it.
|
|
71
|
+
headers.delete('Content-Length');
|
|
72
|
+
return new Response(response.body.pipeThrough(new DecompressionStream(format)), {
|
|
73
|
+
status: response.status,
|
|
74
|
+
statusText: response.statusText,
|
|
75
|
+
headers,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
export function createPortCapability() {
|
|
31
79
|
const bytes = crypto.getRandomValues(new Uint8Array(12));
|
|
32
80
|
return Array.from(bytes, (byte) => byte.toString(16).padStart(2, '0')).join('');
|
|
33
81
|
}
|
|
@@ -217,6 +265,10 @@ export class PortRegistry {
|
|
|
217
265
|
if (authorization)
|
|
218
266
|
headers.set('authorization', authorization);
|
|
219
267
|
headers.set('X-Nimbus-Port', String(port));
|
|
268
|
+
// A Response cannot carry an encoded body across this hop, so the
|
|
269
|
+
// target is asked for the one coding that survives it. See
|
|
270
|
+
// `decodeContentCoding` for the server that compresses anyway.
|
|
271
|
+
headers.set('Accept-Encoding', 'identity');
|
|
220
272
|
// `duplex: 'half'` is required by workerd when body is a
|
|
221
273
|
// ReadableStream — otherwise `new Request(…)` throws. It's not
|
|
222
274
|
// part of the published @cloudflare/workers-types RequestInit,
|
|
@@ -255,12 +307,12 @@ export class PortRegistry {
|
|
|
255
307
|
headers: { 'Content-Type': 'application/json' },
|
|
256
308
|
});
|
|
257
309
|
}
|
|
258
|
-
//
|
|
259
|
-
//
|
|
260
|
-
// inject Access-Control-Allow-Origin — a port proxy
|
|
261
|
-
// whatever CORS policy the user's HTTP server chose (audit C3
|
|
310
|
+
// Stream the facet's Response back. Status, status-text, and every
|
|
311
|
+
// header pass through; only a content coding the hop cannot carry is
|
|
312
|
+
// undone. We do NOT inject Access-Control-Allow-Origin — a port proxy
|
|
313
|
+
// forwards whatever CORS policy the user's HTTP server chose (audit C3
|
|
262
314
|
// discourages gratuitous wildcards on non-static routes).
|
|
263
|
-
return response;
|
|
315
|
+
return decodeContentCoding(response, port);
|
|
264
316
|
}
|
|
265
317
|
catch (error) {
|
|
266
318
|
// Server-side triage — users see only the 502 body, operators
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CommandInputStream } from '../substrate/lifo/commands/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* One consuming source behind the full reader contract, byte-accurate:
|
|
4
|
+
* the text is encoded once and every offset is a byte offset, so
|
|
5
|
+
* readBytes(1) over `é` yields exactly one UTF-8 byte per call and mixed
|
|
6
|
+
* text/byte consumption never diverges. Worker pure-builtin adapters hold
|
|
7
|
+
* stdin as a plain string; without this they can only offer readAll, and
|
|
8
|
+
* streaming commands see an empty pipe.
|
|
9
|
+
*/
|
|
10
|
+
export declare function staticStdinReader(text: string): CommandInputStream;
|
|
11
|
+
//# sourceMappingURL=stdin-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stdin-adapter.d.ts","sourceRoot":"","sources":["../../src/shell/stdin-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAE9E;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,kBAAkB,CA+ClE"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One consuming source behind the full reader contract, byte-accurate:
|
|
3
|
+
* the text is encoded once and every offset is a byte offset, so
|
|
4
|
+
* readBytes(1) over `é` yields exactly one UTF-8 byte per call and mixed
|
|
5
|
+
* text/byte consumption never diverges. Worker pure-builtin adapters hold
|
|
6
|
+
* stdin as a plain string; without this they can only offer readAll, and
|
|
7
|
+
* streaming commands see an empty pipe.
|
|
8
|
+
*/
|
|
9
|
+
export function staticStdinReader(text) {
|
|
10
|
+
const bytes = new TextEncoder().encode(text);
|
|
11
|
+
const decoder = new TextDecoder('utf-8');
|
|
12
|
+
let offset = 0;
|
|
13
|
+
const pull = (max) => {
|
|
14
|
+
if (offset >= bytes.length)
|
|
15
|
+
return null;
|
|
16
|
+
const end = Math.min(offset + max, bytes.length);
|
|
17
|
+
const chunk = bytes.subarray(offset, end);
|
|
18
|
+
offset = end;
|
|
19
|
+
return chunk;
|
|
20
|
+
};
|
|
21
|
+
return {
|
|
22
|
+
readBytes: async (maxLength) => {
|
|
23
|
+
if (maxLength <= 0)
|
|
24
|
+
return new Uint8Array(0);
|
|
25
|
+
return pull(maxLength);
|
|
26
|
+
},
|
|
27
|
+
read: async () => {
|
|
28
|
+
while (offset < bytes.length) {
|
|
29
|
+
const end = Math.min(offset + 65536, bytes.length);
|
|
30
|
+
const text2 = decoder.decode(bytes.subarray(offset, end), { stream: true });
|
|
31
|
+
offset = end;
|
|
32
|
+
if (text2.length > 0)
|
|
33
|
+
return text2;
|
|
34
|
+
}
|
|
35
|
+
const tail = decoder.decode();
|
|
36
|
+
return tail.length > 0 ? tail : null;
|
|
37
|
+
},
|
|
38
|
+
readAll: async () => {
|
|
39
|
+
if (offset >= bytes.length)
|
|
40
|
+
return '';
|
|
41
|
+
const out = decoder.decode(bytes.subarray(offset));
|
|
42
|
+
offset = bytes.length;
|
|
43
|
+
return out;
|
|
44
|
+
},
|
|
45
|
+
readLine: async () => {
|
|
46
|
+
if (offset >= bytes.length)
|
|
47
|
+
return null;
|
|
48
|
+
const newline = bytes.indexOf(0x0a, offset);
|
|
49
|
+
if (newline === -1) {
|
|
50
|
+
const line = decoder.decode(bytes.subarray(offset));
|
|
51
|
+
offset = bytes.length;
|
|
52
|
+
return line;
|
|
53
|
+
}
|
|
54
|
+
const line = decoder.decode(bytes.subarray(offset, newline));
|
|
55
|
+
offset = newline + 1;
|
|
56
|
+
return line;
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
* uptime, tree, find, grep -r, head, tail, wc, diff, sort, uniq,
|
|
9
9
|
* sed (s///), awk (field extract), xargs, tee, chown, ln -s,
|
|
10
10
|
* du, man/help, basename, dirname, printf, true, false, seq, sleep,
|
|
11
|
-
* touch, stat, file, xxd, base64, sha256sum, id, hostname,
|
|
11
|
+
* touch, stat, file, xxd, od, hexdump, base64, sha256sum, id, hostname,
|
|
12
|
+
* realpath
|
|
12
13
|
*/
|
|
13
14
|
import type { SqliteVFS } from '../vfs/sqlite-vfs.js';
|
|
14
15
|
import type { Command } from '../substrate/lifo/commands/types.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unix-commands.d.ts","sourceRoot":"","sources":["../../src/shell/unix-commands.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"unix-commands.d.ts","sourceRoot":"","sources":["../../src/shell/unix-commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAmB,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAavE,OAAO,KAAK,EAAE,OAAO,EAAsB,MAAM,qCAAqC,CAAC;AAoFvF;;;;;;GAMG;AACH,KAAK,mBAAmB,GAAG;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IAC/C,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CAChC,CAAC;AAskKF,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,mBAAmB,EAC7B,SAAS,EAAE,SAAS,GACnB,IAAI,CAyKN"}
|