@nimbus-sh/core 0.7.0 → 0.8.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/dist/_shared/tarball.d.ts +2 -1
- package/dist/_shared/tarball.d.ts.map +1 -1
- package/dist/_shared/tarball.js +5 -1
- package/dist/runtime/comment-strip.d.ts +38 -0
- package/dist/runtime/comment-strip.d.ts.map +1 -1
- package/dist/runtime/comment-strip.js +270 -76
- package/dist/runtime/cpython-runner.d.ts +1 -0
- package/dist/runtime/cpython-runner.d.ts.map +1 -1
- package/dist/runtime/cpython-runner.js +1 -1
- package/dist/runtime/esbuild-service.d.ts.map +1 -1
- package/dist/runtime/esbuild-service.js +10 -195
- package/dist/runtime/ruby-runner.d.ts +1 -0
- package/dist/runtime/ruby-runner.d.ts.map +1 -1
- package/dist/runtime/ruby-runner.js +1 -0
- package/dist/substrate/lifo/commands/system/npm.d.ts.map +1 -1
- package/dist/substrate/lifo/commands/system/npm.js +3 -4
- package/dist/workspace/nimbus-workspace.d.ts +7 -1
- package/dist/workspace/nimbus-workspace.d.ts.map +1 -1
- package/dist/workspace/nimbus-workspace.js +1 -2
- package/dist/workspace/supervisor-op.d.ts +88 -4
- package/dist/workspace/supervisor-op.d.ts.map +1 -1
- package/dist/workspace/supervisor-op.js +146 -14
- package/package.json +2 -2
- package/src/_shared/tarball.ts +5 -1
- package/src/runtime/comment-strip.ts +216 -69
- package/src/runtime/cpython-runner.ts +2 -1
- package/src/runtime/esbuild-service.ts +10 -159
- package/src/runtime/ruby-runner.ts +2 -0
- package/src/substrate/lifo/commands/system/npm.ts +3 -6
- package/src/workspace/nimbus-workspace.ts +6 -3
- package/src/workspace/supervisor-op.ts +212 -20
|
@@ -27,7 +27,8 @@ export interface TarballWriteResult {
|
|
|
27
27
|
* Stream a gzipped npm archive into a package directory. Entry names are
|
|
28
28
|
* already canonical and prefix-stripped by streamTarEntries. Hold only the
|
|
29
29
|
* current entry and the manifest; write the manifest last so a failed install
|
|
30
|
-
* is not mistaken for a complete package on retry.
|
|
30
|
+
* is not mistaken for a complete package on retry. A second manifest in one
|
|
31
|
+
* archive is a malformed package, not an overwrite. Filesystem failures reject.
|
|
31
32
|
*/
|
|
32
33
|
export declare function writeTarballStream(body: ReadableStream<Uint8Array>, targetDir: string, vfs: TarballWriteTarget): Promise<TarballWriteResult>;
|
|
33
34
|
/** Extract every regular file. Gzipped input is decompressed first. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tarball.d.ts","sourceRoot":"","sources":["../../src/_shared/tarball.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAOH,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAC9B,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IAC7D,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC;CAC7D;AAED,MAAM,WAAW,kBAAkB;IACjC,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAC;IACd,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;CACf;AAID
|
|
1
|
+
{"version":3,"file":"tarball.d.ts","sourceRoot":"","sources":["../../src/_shared/tarball.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAOH,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAC9B,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IAC7D,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC;CAC7D;AAED,MAAM,WAAW,kBAAkB;IACjC,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAC;IACd,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;CACf;AAID;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,EAChC,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,kBAAkB,GACtB,OAAO,CAAC,kBAAkB,CAAC,CA6B7B;AAED,uEAAuE;AACvE,wBAAsB,cAAc,CAClC,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAsBlC"}
|
package/dist/_shared/tarball.js
CHANGED
|
@@ -16,7 +16,8 @@ const PACKAGE_MANIFEST = 'package.json';
|
|
|
16
16
|
* Stream a gzipped npm archive into a package directory. Entry names are
|
|
17
17
|
* already canonical and prefix-stripped by streamTarEntries. Hold only the
|
|
18
18
|
* current entry and the manifest; write the manifest last so a failed install
|
|
19
|
-
* is not mistaken for a complete package on retry.
|
|
19
|
+
* is not mistaken for a complete package on retry. A second manifest in one
|
|
20
|
+
* archive is a malformed package, not an overwrite. Filesystem failures reject.
|
|
20
21
|
*/
|
|
21
22
|
export async function writeTarballStream(body, targetDir, vfs) {
|
|
22
23
|
const ensureDir = (path) => {
|
|
@@ -30,6 +31,9 @@ export async function writeTarballStream(body, targetDir, vfs) {
|
|
|
30
31
|
const entries = streamTarEntries(readableStreamToAsyncIterable(body.pipeThrough(new DecompressionStream('gzip'))));
|
|
31
32
|
for await (const entry of entries) {
|
|
32
33
|
if (entry.name === PACKAGE_MANIFEST) {
|
|
34
|
+
if (manifest !== null) {
|
|
35
|
+
throw new Error(`tarball for ${targetDir} carried two ${PACKAGE_MANIFEST} entries`);
|
|
36
|
+
}
|
|
33
37
|
manifest = entry.data;
|
|
34
38
|
continue;
|
|
35
39
|
}
|
|
@@ -1,2 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One JavaScript source scanner shared by the two comment-stripping
|
|
3
|
+
* call sites — prefetch's import detection and the esbuild transform
|
|
4
|
+
* pipeline's classifiers.
|
|
5
|
+
*
|
|
6
|
+
* `scanJsSource(src, literals)` walks `src` once and returns a
|
|
7
|
+
* byte-aligned copy in which `//` and `/* … *\/` comments are blanked
|
|
8
|
+
* (each comment becomes a space; newlines inside a block comment are
|
|
9
|
+
* preserved so line numbers still match the input). String, template
|
|
10
|
+
* and regex literals are what `literals` decides:
|
|
11
|
+
*
|
|
12
|
+
* - `'blank'`: literal content is replaced too — templates keep their
|
|
13
|
+
* `${…}` interpolation expression as code so a depth-tracked caller
|
|
14
|
+
* sees `await` etc. inside it. This is the transform pipeline's
|
|
15
|
+
* classification view: nothing quoted can read as an `import`.
|
|
16
|
+
* - `'keep'`: literals are copied verbatim. This is prefetch's
|
|
17
|
+
* import-detection view: IMPORT_RE/REQUIRE_RE must see the
|
|
18
|
+
* specifier string, and a `//` or `/*` inside a literal must NOT
|
|
19
|
+
* open a comment that swallows a following real import.
|
|
20
|
+
*
|
|
21
|
+
* The output is assembled from input slices and joined once. It used to
|
|
22
|
+
* be built one character at a time (`stripped += c`), which V8 keeps as
|
|
23
|
+
* a rope of one node per append — ~30 bytes of heap per character, all
|
|
24
|
+
* live until the string is first read. On typescript's 6.15 MB
|
|
25
|
+
* `lib/_tsc.js` that rope measured 174 MB against a 128 MB isolate —
|
|
26
|
+
* the session Durable Object was killed inside `tsc`'s spawn before the
|
|
27
|
+
* facet existed. Spans hold the input, the output and a short array.
|
|
28
|
+
*
|
|
29
|
+
* Serialized by name: `generateEsbuildTransformRuntimeSource` embeds
|
|
30
|
+
* this function's `.toString()` in the transform runtime, so every
|
|
31
|
+
* constant it reads is declared inside the body.
|
|
32
|
+
*/
|
|
33
|
+
export declare function scanJsSource(src: string, literals: 'keep' | 'blank'): string;
|
|
34
|
+
/**
|
|
35
|
+
* Strip comments for import/require detection. Literals are kept: the
|
|
36
|
+
* specifier the regexes extract lives inside a string, and a comment
|
|
37
|
+
* marker inside a string must not swallow the code that follows it.
|
|
38
|
+
*/
|
|
1
39
|
export declare function stripCommentsForImports(src: string): string;
|
|
2
40
|
//# sourceMappingURL=comment-strip.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"comment-strip.d.ts","sourceRoot":"","sources":["../../src/runtime/comment-strip.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"comment-strip.d.ts","sourceRoot":"","sources":["../../src/runtime/comment-strip.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,CAqM5E;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE3D"}
|
|
@@ -1,102 +1,296 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* One JavaScript source scanner shared by the two comment-stripping
|
|
3
|
+
* call sites — prefetch's import detection and the esbuild transform
|
|
4
|
+
* pipeline's classifiers.
|
|
3
5
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* comment
|
|
7
|
-
*
|
|
8
|
-
* `
|
|
9
|
-
* pipeline).
|
|
6
|
+
* `scanJsSource(src, literals)` walks `src` once and returns a
|
|
7
|
+
* byte-aligned copy in which `//` and `/* … *\/` comments are blanked
|
|
8
|
+
* (each comment becomes a space; newlines inside a block comment are
|
|
9
|
+
* preserved so line numbers still match the input). String, template
|
|
10
|
+
* and regex literals are what `literals` decides:
|
|
10
11
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
12
|
+
* - `'blank'`: literal content is replaced too — templates keep their
|
|
13
|
+
* `${…}` interpolation expression as code so a depth-tracked caller
|
|
14
|
+
* sees `await` etc. inside it. This is the transform pipeline's
|
|
15
|
+
* classification view: nothing quoted can read as an `import`.
|
|
16
|
+
* - `'keep'`: literals are copied verbatim. This is prefetch's
|
|
17
|
+
* import-detection view: IMPORT_RE/REQUIRE_RE must see the
|
|
18
|
+
* specifier string, and a `//` or `/*` inside a literal must NOT
|
|
19
|
+
* open a comment that swallows a following real import.
|
|
17
20
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* String-literal handling is intentionally OUT of scope. A literal
|
|
25
|
-
* `import x from 'y'` inside a JavaScript string would still produce
|
|
26
|
-
* a false-positive prefetch attempt. The resolver no-ops on misses,
|
|
27
|
-
* so it's a minor wasted-work cost — see IMPORT_RE header comment in
|
|
28
|
-
* `require-resolver.ts:84-86`.
|
|
29
|
-
*
|
|
30
|
-
* Memory: the output is assembled from slices of the input — one per
|
|
31
|
-
* comment-free span — and joined once. It used to be built one character
|
|
32
|
-
* at a time with `out += c`, which every JS engine represents as a rope
|
|
33
|
-
* of one node per append: ~30 bytes of heap per character of output, all
|
|
34
|
-
* of it live until the string is first read. The require walk runs this
|
|
35
|
-
* over every file in the closure, and on typescript's 6.15 MB `lib/_tsc.js`
|
|
36
|
-
* that rope measured 174 MB (V8) / 172 MB (JSC) against a 128 MB isolate —
|
|
21
|
+
* The output is assembled from input slices and joined once. It used to
|
|
22
|
+
* be built one character at a time (`stripped += c`), which V8 keeps as
|
|
23
|
+
* a rope of one node per append — ~30 bytes of heap per character, all
|
|
24
|
+
* live until the string is first read. On typescript's 6.15 MB
|
|
25
|
+
* `lib/_tsc.js` that rope measured 174 MB against a 128 MB isolate —
|
|
37
26
|
* the session Durable Object was killed inside `tsc`'s spawn before the
|
|
38
|
-
* facet existed.
|
|
39
|
-
* short array of slices, and nothing else.
|
|
27
|
+
* facet existed. Spans hold the input, the output and a short array.
|
|
40
28
|
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* same logical pass over comments; only the string/regex-literal
|
|
45
|
-
* handling differs.
|
|
29
|
+
* Serialized by name: `generateEsbuildTransformRuntimeSource` embeds
|
|
30
|
+
* this function's `.toString()` in the transform runtime, so every
|
|
31
|
+
* constant it reads is declared inside the body.
|
|
46
32
|
*/
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
33
|
+
export function scanJsSource(src, literals) {
|
|
34
|
+
const NEWLINE = 0x0a;
|
|
35
|
+
// Identifier-suffix detection: `/` after one of these is division;
|
|
36
|
+
// after anything else (operators, punctuators, keywords, start-of-file)
|
|
37
|
+
// it opens a regex literal. Word chars + `)` + `]` cover `foo()/x` and
|
|
38
|
+
// `a[i]/y`; the quote characters cover `'…' /re/` and `` `…` /re/ ``.
|
|
39
|
+
const DIVISION_AFTER = /[A-Za-z0-9_$\)\]'\"`]/;
|
|
52
40
|
const parts = [];
|
|
53
|
-
// Start of the
|
|
41
|
+
// Start of the span not yet copied to `parts`.
|
|
54
42
|
let spanStart = 0;
|
|
55
43
|
let i = 0;
|
|
56
|
-
|
|
57
|
-
|
|
44
|
+
const N = src.length;
|
|
45
|
+
let lastNonWs = '';
|
|
46
|
+
const record = (ch) => {
|
|
47
|
+
if (ch !== ' ' && ch !== '\t' && ch !== '\n' && ch !== '\r')
|
|
48
|
+
lastNonWs = ch;
|
|
49
|
+
};
|
|
50
|
+
// The division/regex discriminator needs the last non-ws char the loop
|
|
51
|
+
// has passed — stepped chars record themselves; spans already landed in
|
|
52
|
+
// `parts` only need their final char re-derived.
|
|
53
|
+
const step = () => { record(src[i]); i++; };
|
|
54
|
+
const copy = (end) => {
|
|
55
|
+
if (end > spanStart)
|
|
56
|
+
parts.push(src.slice(spanStart, end));
|
|
57
|
+
};
|
|
58
|
+
const emit = (ch) => { parts.push(ch); };
|
|
59
|
+
// A shebang is the file's first line and never a comment or a regex —
|
|
60
|
+
// `#!/` at offset 0 is copied whole before the loop sees the `/`.
|
|
61
|
+
if (src.charCodeAt(0) === 0x23 && src.charCodeAt(1) === 0x21) {
|
|
62
|
+
i = 2;
|
|
63
|
+
while (i < N && src.charCodeAt(i) !== NEWLINE)
|
|
58
64
|
i++;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
record('!');
|
|
66
|
+
}
|
|
67
|
+
while (i < N) {
|
|
68
|
+
if (src.charCodeAt(i) === 0x2f /* / */) {
|
|
69
|
+
const next = src.charCodeAt(i + 1);
|
|
70
|
+
if (next === 0x2f) {
|
|
71
|
+
// Line comment: to end-of-line, one space. The newline itself is
|
|
72
|
+
// not part of the comment and stays in the next span.
|
|
73
|
+
copy(i);
|
|
74
|
+
i += 2;
|
|
75
|
+
while (i < N && src.charCodeAt(i) !== NEWLINE)
|
|
76
|
+
i++;
|
|
77
|
+
emit(' ');
|
|
78
|
+
spanStart = i;
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
if (next === 0x2a) {
|
|
82
|
+
// Block comment: replaced by its own newlines plus one space; an
|
|
83
|
+
// unterminated one runs to the end of input and gets no space.
|
|
84
|
+
copy(i);
|
|
85
|
+
i += 2;
|
|
86
|
+
let newlines = 0;
|
|
87
|
+
let closed = false;
|
|
88
|
+
while (i < N) {
|
|
89
|
+
const bc = src.charCodeAt(i);
|
|
90
|
+
if (bc === NEWLINE)
|
|
91
|
+
newlines++;
|
|
92
|
+
else if (bc === 0x2a && src.charCodeAt(i + 1) === 0x2f) {
|
|
93
|
+
i += 2;
|
|
94
|
+
closed = true;
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
i++;
|
|
98
|
+
}
|
|
99
|
+
if (newlines > 0)
|
|
100
|
+
parts.push('\n'.repeat(newlines));
|
|
101
|
+
if (closed)
|
|
102
|
+
emit(' ');
|
|
103
|
+
spanStart = i;
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
// Regex literal when the previous non-ws char can't end a value.
|
|
107
|
+
if (!DIVISION_AFTER.test(lastNonWs)) {
|
|
108
|
+
// A regex needs its closing `/` on the same line; without one the
|
|
109
|
+
// slash is division (or a lone `/`), and treating the rest of the
|
|
110
|
+
// line as a literal would drop real code — imports included.
|
|
111
|
+
let j = i + 1;
|
|
112
|
+
let closes = false;
|
|
113
|
+
while (j < N) {
|
|
114
|
+
const rc = src.charCodeAt(j);
|
|
115
|
+
if (rc === 0x5c) {
|
|
116
|
+
j += 2;
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
if (rc === 0x5b) {
|
|
120
|
+
j++;
|
|
121
|
+
while (j < N && src.charCodeAt(j) !== 0x5d) {
|
|
122
|
+
if (src.charCodeAt(j) === 0x5c) {
|
|
123
|
+
j += 2;
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
j++;
|
|
127
|
+
}
|
|
128
|
+
if (j < N)
|
|
129
|
+
j++;
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
if (rc === 0x2f) {
|
|
133
|
+
closes = true;
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
if (rc === NEWLINE)
|
|
137
|
+
break;
|
|
138
|
+
j++;
|
|
139
|
+
}
|
|
140
|
+
if (!closes) {
|
|
141
|
+
step();
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
copy(i);
|
|
145
|
+
emit(' ');
|
|
68
146
|
i++;
|
|
69
|
-
|
|
147
|
+
while (i < N) {
|
|
148
|
+
const rc = src.charCodeAt(i);
|
|
149
|
+
if (rc === 0x5c) {
|
|
150
|
+
i += 2;
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
if (rc === 0x5b) {
|
|
154
|
+
// Character class: `/` inside it is content.
|
|
155
|
+
i++;
|
|
156
|
+
while (i < N && src.charCodeAt(i) !== 0x5d) {
|
|
157
|
+
if (src.charCodeAt(i) === 0x5c) {
|
|
158
|
+
i += 2;
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
i++;
|
|
162
|
+
}
|
|
163
|
+
if (i < N)
|
|
164
|
+
i++;
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
if (rc === 0x2f) {
|
|
168
|
+
i++;
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
i++;
|
|
172
|
+
}
|
|
173
|
+
// Flags: g, i, m, s, u, y, d.
|
|
174
|
+
while (i < N && /[gimsuyd]/.test(src[i]))
|
|
175
|
+
i++;
|
|
176
|
+
record('/');
|
|
177
|
+
spanStart = i;
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
// Division or a lone slash — plain source.
|
|
181
|
+
step();
|
|
70
182
|
continue;
|
|
71
183
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
184
|
+
const ch = src[i];
|
|
185
|
+
if (ch === '"' || ch === "'" || ch === '`') {
|
|
186
|
+
if (literals === 'keep') {
|
|
187
|
+
i++;
|
|
188
|
+
while (i < N) {
|
|
189
|
+
const cc = src[i];
|
|
190
|
+
if (cc === '\\') {
|
|
191
|
+
i += 2;
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
if (cc === ch) {
|
|
195
|
+
i++;
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
i++;
|
|
199
|
+
}
|
|
200
|
+
// The literal ends a value: a following `/` is division.
|
|
201
|
+
record(ch);
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
// blank: the delimiters and content become one space; a template's
|
|
205
|
+
// `${…}` interpolation keeps its expression as code.
|
|
206
|
+
copy(i);
|
|
207
|
+
emit(' ');
|
|
208
|
+
i++;
|
|
80
209
|
while (i < N) {
|
|
81
|
-
const
|
|
82
|
-
if (
|
|
83
|
-
newlines++;
|
|
84
|
-
else if (c === STAR && src.charCodeAt(i + 1) === SLASH) {
|
|
210
|
+
const cc = src[i];
|
|
211
|
+
if (cc === '\\') {
|
|
85
212
|
i += 2;
|
|
86
|
-
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
if (cc === ch) {
|
|
216
|
+
i++;
|
|
87
217
|
break;
|
|
88
218
|
}
|
|
219
|
+
if (ch === '`' && cc === '$' && src[i + 1] === '{') {
|
|
220
|
+
emit('${');
|
|
221
|
+
i += 2;
|
|
222
|
+
let depth = 1;
|
|
223
|
+
while (i < N && depth > 0) {
|
|
224
|
+
const ic = src[i];
|
|
225
|
+
// Nested string inside the interpolation: blank its content
|
|
226
|
+
// so a `}` inside it doesn't drop the depth early.
|
|
227
|
+
if (ic === '"' || ic === "'" || ic === '`') {
|
|
228
|
+
const iq = ic;
|
|
229
|
+
emit(' ');
|
|
230
|
+
i++;
|
|
231
|
+
while (i < N) {
|
|
232
|
+
const icc = src[i];
|
|
233
|
+
if (icc === '\\') {
|
|
234
|
+
i += 2;
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
if (icc === iq) {
|
|
238
|
+
i++;
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
// A nested template's own ${…} recurses once more —
|
|
242
|
+
// deeper nesting falls back to brace counting.
|
|
243
|
+
if (iq === '`' && icc === '$' && src[i + 1] === '{') {
|
|
244
|
+
emit('${');
|
|
245
|
+
i += 2;
|
|
246
|
+
let d2 = 1;
|
|
247
|
+
while (i < N && d2 > 0) {
|
|
248
|
+
const i2 = src[i];
|
|
249
|
+
if (i2 === '{')
|
|
250
|
+
d2++;
|
|
251
|
+
else if (i2 === '}')
|
|
252
|
+
d2--;
|
|
253
|
+
if (d2 > 0)
|
|
254
|
+
emit(i2);
|
|
255
|
+
i++;
|
|
256
|
+
}
|
|
257
|
+
emit('}');
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
260
|
+
if (icc === '\n')
|
|
261
|
+
emit('\n');
|
|
262
|
+
i++;
|
|
263
|
+
}
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
if (ic === '{')
|
|
267
|
+
depth++;
|
|
268
|
+
else if (ic === '}')
|
|
269
|
+
depth--;
|
|
270
|
+
if (depth > 0)
|
|
271
|
+
emit(ic);
|
|
272
|
+
i++;
|
|
273
|
+
}
|
|
274
|
+
emit('}');
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
if (cc === '\n')
|
|
278
|
+
emit('\n');
|
|
89
279
|
i++;
|
|
90
280
|
}
|
|
91
|
-
if (newlines > 0)
|
|
92
|
-
parts.push('\n'.repeat(newlines));
|
|
93
|
-
if (closed)
|
|
94
|
-
parts.push(' ');
|
|
95
281
|
spanStart = i;
|
|
96
282
|
continue;
|
|
97
283
|
}
|
|
98
|
-
|
|
284
|
+
step();
|
|
99
285
|
}
|
|
100
|
-
|
|
286
|
+
copy(N);
|
|
101
287
|
return parts.join('');
|
|
102
288
|
}
|
|
289
|
+
/**
|
|
290
|
+
* Strip comments for import/require detection. Literals are kept: the
|
|
291
|
+
* specifier the regexes extract lives inside a string, and a comment
|
|
292
|
+
* marker inside a string must not swallow the code that follows it.
|
|
293
|
+
*/
|
|
294
|
+
export function stripCommentsForImports(src) {
|
|
295
|
+
return scanJsSource(src, 'keep');
|
|
296
|
+
}
|
|
@@ -71,6 +71,7 @@ export interface CPythonFacetResult {
|
|
|
71
71
|
* that has none does not get a degraded version — it gets none, and says so.
|
|
72
72
|
*/
|
|
73
73
|
export type CPythonResidentStart = (spawn: {
|
|
74
|
+
argv: string[];
|
|
74
75
|
/** VFS path of the interpreter. By path, not by value: it is 10.6 MiB. */
|
|
75
76
|
wasmVfsPath: string;
|
|
76
77
|
startArgs: Record<string, unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cpython-runner.d.ts","sourceRoot":"","sources":["../../src/runtime/cpython-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;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H,OAAO,KAAK,EAAE,OAAO,EAAkB,MAAM,qCAAqC,CAAC;AAEnF,OAAO,KAAK,EAAmB,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAKvE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AASjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAsB7D;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAM7C;AAkFD,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAsCD;;;;;;;GAOG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,KAAK,EAAE;IACzC,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,0EAA0E;IAC1E,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;CACjB,KAAK,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAElC,wBAAgB,wBAAwB,CAAC,IAAI,EAAE;IAC7C,MAAM,EAAE,SAAS,CAAC;IAClB,GAAG,EAAE,SAAS,CAAC;IACf,iFAAiF;IACjF,aAAa,CAAC,EAAE,oBAAoB,CAAC;CACtC,GAAG,CAAC,QAAQ,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,KAC7F,OAAO,CAkQV"}
|
|
@@ -391,7 +391,7 @@ export function makeCPythonRunnerFactory(deps) {
|
|
|
391
391
|
return 1;
|
|
392
392
|
}
|
|
393
393
|
const command = [binName, ...argv].map((part) => (/^[A-Za-z0-9_./:=@+-]+$/.test(part) ? part : JSON.stringify(part))).join(' ');
|
|
394
|
-
const spawnResult = await deps.startResident({ wasmVfsPath: wasmVfs, startArgs: facetArgs, cwd, command });
|
|
394
|
+
const spawnResult = await deps.startResident({ wasmVfsPath: wasmVfs, startArgs: facetArgs, cwd, command, argv: [binName, ...argv] });
|
|
395
395
|
if (spawnResult.stdout)
|
|
396
396
|
ctx.stdout.write(spawnResult.stdout);
|
|
397
397
|
if (spawnResult.stderr)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"esbuild-service.d.ts","sourceRoot":"","sources":["../../src/runtime/esbuild-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"esbuild-service.d.ts","sourceRoot":"","sources":["../../src/runtime/esbuild-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAc5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,eAAO,MAAM,eAAe,OAAO,CAAC;AAIpC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CA4DrE;AA2rBD;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,GAClB,eAAe,GAAG,IAAI,CAoCxB;AAiCD,OAAO,KAAK,KAAK,OAAO,MAAM,6BAA6B,CAAC;AAY5D;;;;;;;;;;;;GAYG;AACH,wBAAsB,WAAW,IAAI,OAAO,CAAC,OAAO,OAAO,CAAC,CAiB3D;AAID,MAAM,WAAW,uBAAuB;IACtC,MAAM,CAAC,EAAE,IAAI,GAAG,KAAK,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,GAAG,MAAM,CAAC;IACtD,MAAM,CAAC,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