@sproutboat/toolchain 0.4.10 → 0.4.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/CHANGELOG.md +17 -1
- package/PORFFOR_ALPHA9.md +70 -0
- package/package.json +1 -1
- package/src/acquire.test.ts +44 -1
- package/src/acquire.ts +17 -3
- package/src/patch.ts +71 -16
- package/src/pin.ts +4 -4
- package/vendor/porffor-de4eb58.tar.gz +0 -0
- package/vendor/porffor-8f01541.tar.gz +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @sproutboat/toolchain
|
|
2
2
|
|
|
3
|
+
## 0.4.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ed9640a: Point Porffor patch diagnostics, runtime comments, and historical notes to the
|
|
8
|
+
shared upstream notes in the Sproutboat platform repository.
|
|
9
|
+
- b6cc9e6: Pin Porffor alpha 9, including alpha 8's compiler and GC fixes and alpha 9's ESM module support. Adapt the native-fetch link and compile-flag patches to Porffor's split C-unit build. Preserve the published 0.4.11 `TypedArray.from` workaround, which alpha 9 still needs. Re-vendor the verified alpha 9 source archive. The uWebSockets commit is unchanged.
|
|
10
|
+
|
|
11
|
+
## 0.4.11
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 6d72af7: Fix `TypedArray.from` with array-like inputs in native binaries and
|
|
16
|
+
regenerate Porffor's builtin table after the source patch, including when
|
|
17
|
+
the compiler is unpacked through a symlinked temporary path.
|
|
18
|
+
|
|
3
19
|
## 0.4.10
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -81,7 +97,7 @@
|
|
|
81
97
|
prototype and stop once the "next" pointer stops advancing, reading a
|
|
82
98
|
fixed-point chain as "no `.then` found" instead of spinning. Not specific to
|
|
83
99
|
`Date.prototype.toISOString()` — an earlier note wrongly correlated the bug
|
|
84
|
-
with that one call; see `sproutboat
|
|
100
|
+
with that one call; see `https://github.com/baronunread/sproutboat/tree/main/patches/upstream`.
|
|
85
101
|
|
|
86
102
|
## 0.4.0
|
|
87
103
|
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Porffor alpha 9 upgrade audit
|
|
2
|
+
|
|
3
|
+
Pin: `de4eb588264885b3a1596f75010e371a2052033f`, tagged `alpha-9` on
|
|
4
|
+
2026-09-24. The vendored codeload archive has SHA-256
|
|
5
|
+
`1a62187a93356b36cb6ac703ce9770c8917e4fa65545fd7c33ee8a180ae5a4c9`.
|
|
6
|
+
|
|
7
|
+
## Alpha 8 changes
|
|
8
|
+
|
|
9
|
+
The [alpha 8 release](https://github.com/CanadaHonk/porffor/releases/tag/alpha-8)
|
|
10
|
+
contains 27 commits. Every commit falls into one of these groups:
|
|
11
|
+
|
|
12
|
+
| Area | Commits | Effect on Sproutboat |
|
|
13
|
+
| --- | --- | --- |
|
|
14
|
+
| Language and compiler correctness | `6063154a`, `8436b386`, `d3376a2d`, `8833624c`, `b92571c4`, `dfab4235`, `65a6bb3f`, `cb26d320`, `6a47f02c`, `acf6dda0`, `c54557ba`, `50855902`, `5e5db5a4`, `6ec00849`, `61d42690` | Better default parameters, spread calls, object values, closure parameters, uninitialized and `let` bindings, optional computed keys, `finally` and exception exits; the remaining edits remove redundant IR and code generation. These improve handler correctness without replacing a local patch. |
|
|
15
|
+
| GC and memory | `83cd4902`, `b5eb0b98`, `9e283dd2`, `f687ac7c`, `08bf855d`, `135d2761`, `ae4002b1`, `a110867b` | Smaller memory commitment and less GC work. `a110867b` supplies a C macro used by the renderer. No Sproutboat GC patch exists to remove. |
|
|
16
|
+
| String built-ins | `f483ba7e` | Better `substring` and `substr`; no corresponding local shim. |
|
|
17
|
+
| Compiler progress | `b77750b0` | Shows compile progress on a TTY; no runtime contract change. |
|
|
18
|
+
| Self-hosted tools and benchmarks | `370f1f75`, `7b12abd2` | Adds `stat.isFile` and a TypeScript compiler benchmark; neither is used by Sproutboat. |
|
|
19
|
+
|
|
20
|
+
## Alpha 9 and cleanup decision
|
|
21
|
+
|
|
22
|
+
The [alpha 9 release](https://github.com/CanadaHonk/porffor/releases/tag/alpha-9)
|
|
23
|
+
contains `de4eb588`, adding ESM imports and exports. A direct native-fetch
|
|
24
|
+
fixture importing a sibling module compiled and returned its imported value.
|
|
25
|
+
Porffor now compiles modules as separate cached C units. The local `SB_EXTRA_LINK`
|
|
26
|
+
and `SB_EXTRA_CFLAGS` patches had to move to the new link list and shared
|
|
27
|
+
compile arguments. `UWS_COMMIT` remains `360c276d609d59af56ae6932adb95154ace9f15f`.
|
|
28
|
+
|
|
29
|
+
No local patch is superseded by the alpha 8 or 9 changes. The patches provide
|
|
30
|
+
Sproutboat-specific native-fetch behavior: `$PORT`, log routing, bytestring
|
|
31
|
+
encoding, raw asset bodies, status and header handling, request size, R2
|
|
32
|
+
transfers, and external link and include flags. The CLI still bundles before
|
|
33
|
+
Porffor to validate the full dependency graph, apply its Node shims, and pass
|
|
34
|
+
one controlled handler export to the runtime wrapper. Native ESM makes a future
|
|
35
|
+
module-based wrapper possible, but removing Bun.build or export normalization
|
|
36
|
+
now would also change capability validation and binding behavior. Porffor's
|
|
37
|
+
old external esbuild requirement is gone in alpha 9, so the CLI can drop its
|
|
38
|
+
esbuild dependency and bundled platform executable.
|
|
39
|
+
|
|
40
|
+
A module-wrapper prototype compiled a separate handler module. Its normal
|
|
41
|
+
`env.GREETING` reference returned HTTP 500; using `globalThis.env.GREETING`
|
|
42
|
+
returned HTTP 200. The current export normalization keeps the existing
|
|
43
|
+
unqualified `env` contract. The direct ESM import is now part of the CI native
|
|
44
|
+
crypto vector, so a future pin cannot silently lose module support.
|
|
45
|
+
|
|
46
|
+
Alpha 9 caches compiled C units by the absolute entry path. In one local
|
|
47
|
+
`hello` handler-edit comparison, a stable path compiled in 549 ms versus
|
|
48
|
+
1,505 ms with changing paths. The CLI's `dev` loop now uses a stable entry
|
|
49
|
+
path per process while keeping candidate artifacts isolated. These are local
|
|
50
|
+
single-run timings, not a published performance claim.
|
|
51
|
+
|
|
52
|
+
The published `@sproutboat/toolchain@0.4.11` includes a `TypedArray.from`
|
|
53
|
+
array-like input patch absent from this checkout's 0.4.10 base. Clean alpha 9
|
|
54
|
+
still returns an empty array for `Uint8Array.from({ length: 4 }, mapFn)`. The
|
|
55
|
+
0.4.11 patch was carried forward, its precompiled builtin table is regenerated,
|
|
56
|
+
and a native crypto vector now exercises that array-like input.
|
|
57
|
+
|
|
58
|
+
Regression evidence for this pin: toolchain tests (11), CLI tests (92), both
|
|
59
|
+
kitchen-sink harnesses (27 broker checks, 29 standalone checks), and all 12 CLI
|
|
60
|
+
examples passed. The direct ESM fixture returned HTTP 200 with the imported
|
|
61
|
+
value. The package typecheck and lint passed.
|
|
62
|
+
|
|
63
|
+
## Release order
|
|
64
|
+
|
|
65
|
+
The registry's latest toolchain is 0.4.11 and still pins alpha 7. This checkout
|
|
66
|
+
has been reconciled with that release's `TypedArray.from` patch; its pending
|
|
67
|
+
changeset targets 0.4.12. Publish the alpha 9 toolchain first. Then update
|
|
68
|
+
`sproutboat-cli`, the main `sproutboat` app, and `sproutboat-site/web` to require
|
|
69
|
+
0.4.12 and refresh their lockfiles. The CLI can then ship without an esbuild
|
|
70
|
+
executable. Until 0.4.12 is published, existing npm consumers still run alpha 7.
|
package/package.json
CHANGED
package/src/acquire.test.ts
CHANGED
|
@@ -28,7 +28,21 @@ async function fixture(): Promise<{ archive: string; sha256: string }> {
|
|
|
28
28
|
" }\n" +
|
|
29
29
|
" return -1;\n" +
|
|
30
30
|
"}\n",
|
|
31
|
-
"compiler/index.js": "
|
|
31
|
+
"compiler/index.js": " ...darwinReleaseCompileArgs,\n uSocketsArchive,\n '-lm'\n",
|
|
32
|
+
"compiler/precompile.js":
|
|
33
|
+
"const fs = require('node:fs');\n" +
|
|
34
|
+
"const path = require('node:path');\n" +
|
|
35
|
+
"fs.writeFileSync(path.join(__dirname, 'builtins_precompiled.js'), fs.readFileSync(path.join(__dirname, 'builtins/typedarray.js')));\n",
|
|
36
|
+
"compiler/builtins_precompiled.js": "fixture:precompiled\n",
|
|
37
|
+
"compiler/builtins/typedarray.js":
|
|
38
|
+
"export const __${name}_from = (arg: any, mapFn: any): ${name} => {\n" +
|
|
39
|
+
" const arr: any[] = Porffor.array.new(4);\n" +
|
|
40
|
+
" let len: i32 = 0;\n" +
|
|
41
|
+
" if (Porffor.type(arg) == Porffor.TYPES.array) {\n" +
|
|
42
|
+
" let i: i32 = 0;\n" +
|
|
43
|
+
" for (const x of arg) arr[i++] = x;\n" +
|
|
44
|
+
" len = i;\n" +
|
|
45
|
+
" }\n\n arr.length = len;\n\n return new ${name}(arr);\n};\n",
|
|
32
46
|
"compiler/uwebsockets.js":
|
|
33
47
|
"static const size_t REQUEST_BODY_MAX_BYTES = 1024u * 1024u;\n" +
|
|
34
48
|
"int porf_native_fetch_read_value(struct jsval value, const char** out_buf, size_t* out_len, char** out_owned);\n" +
|
|
@@ -202,6 +216,35 @@ test("a corrupted warm cache is replaced from the verified archive", async () =>
|
|
|
202
216
|
expect(await readFile(join(root, "compiler/render.js"), "utf8")).toContain('getenv("PORT")');
|
|
203
217
|
});
|
|
204
218
|
|
|
219
|
+
test("a cache built by an older toolchain version is rebuilt, not silently reused", async () => {
|
|
220
|
+
const { archive, sha256 } = await fixture();
|
|
221
|
+
const cacheRoot = await mkdtemp(join(tmpdir(), "sb-porffor-stale-toolchain-"));
|
|
222
|
+
temporary.push(cacheRoot);
|
|
223
|
+
let requests = 0;
|
|
224
|
+
const options = {
|
|
225
|
+
cacheRoot,
|
|
226
|
+
url: "fixture",
|
|
227
|
+
expectedSha256: sha256,
|
|
228
|
+
fetcher: async () => {
|
|
229
|
+
requests += 1;
|
|
230
|
+
return new Response(Bun.file(archive));
|
|
231
|
+
},
|
|
232
|
+
};
|
|
233
|
+
const root = await ensurePorffor(options);
|
|
234
|
+
const manifestPath = join(root, ".sproutboat-complete");
|
|
235
|
+
const manifest = JSON.parse(await readFile(manifestPath, "utf8"));
|
|
236
|
+
expect(manifest.toolchainVersion).toBeTruthy();
|
|
237
|
+
// Simulate a cache left behind by an older @sproutboat/toolchain publish
|
|
238
|
+
// (baronunread/sproutboat#205): a patch.ts fix landing in a new version used
|
|
239
|
+
// to sit unused because the cache key only tracked the upstream commit.
|
|
240
|
+
await rm(manifestPath);
|
|
241
|
+
await writeFile(manifestPath, JSON.stringify({ ...manifest, toolchainVersion: "0.0.0-stale" }));
|
|
242
|
+
await ensurePorffor(options);
|
|
243
|
+
expect(requests).toBe(2);
|
|
244
|
+
const rebuilt = JSON.parse(await readFile(manifestPath, "utf8"));
|
|
245
|
+
expect(rebuilt.toolchainVersion).toBe(manifest.toolchainVersion);
|
|
246
|
+
});
|
|
247
|
+
|
|
205
248
|
test("an interrupted stale lock is recovered", async () => {
|
|
206
249
|
const { archive, sha256 } = await fixture();
|
|
207
250
|
const cacheRoot = await mkdtemp(join(tmpdir(), "sb-porffor-interrupted-"));
|
package/src/acquire.ts
CHANGED
|
@@ -5,9 +5,15 @@ import { homedir } from "node:os";
|
|
|
5
5
|
import { resolve } from "node:path";
|
|
6
6
|
// @ts-expect-error Bun's file loader supplies a path; see the pinned-commit
|
|
7
7
|
// check below for why this is safe to trust unconditionally.
|
|
8
|
-
import vendoredPorfforArchive from "../vendor/porffor-
|
|
8
|
+
import vendoredPorfforArchive from "../vendor/porffor-de4eb58.tar.gz" with { type: "file" };
|
|
9
9
|
import { ensurePorfforPatched } from "./patch";
|
|
10
10
|
import { PORFFOR_ARCHIVE_SHA256, PORFFOR_ARCHIVE_URL, PORFFOR_COMMIT_FULL } from "./pin";
|
|
11
|
+
// Folded into the cache manifest below so a toolchain release that changes
|
|
12
|
+
// patch.ts's output invalidates every machine's cache automatically
|
|
13
|
+
// (baronunread/sproutboat#205 — a patch fix published as a new version used
|
|
14
|
+
// to sit unused behind a still-"complete" cache keyed only on the upstream
|
|
15
|
+
// Porffor commit).
|
|
16
|
+
import { version as TOOLCHAIN_VERSION } from "../package.json" with { type: "json" };
|
|
11
17
|
|
|
12
18
|
export class PorfforToolchainError extends Error {
|
|
13
19
|
constructor(
|
|
@@ -31,6 +37,9 @@ const required = [
|
|
|
31
37
|
"compiler/render.js",
|
|
32
38
|
"compiler/index.js",
|
|
33
39
|
"compiler/uwebsockets.js",
|
|
40
|
+
"compiler/precompile.js",
|
|
41
|
+
"compiler/builtins/typedarray.js",
|
|
42
|
+
"compiler/builtins_precompiled.js",
|
|
34
43
|
];
|
|
35
44
|
async function digest(path: string): Promise<string> {
|
|
36
45
|
return createHash("sha256")
|
|
@@ -45,9 +54,14 @@ async function complete(dir: string, expectedArchive = PORFFOR_ARCHIVE_SHA256):
|
|
|
45
54
|
const manifest = JSON.parse(await readFile(resolve(dir, ".sproutboat-complete"), "utf8")) as {
|
|
46
55
|
commit?: string;
|
|
47
56
|
archiveSha256?: string;
|
|
57
|
+
toolchainVersion?: string;
|
|
48
58
|
files?: Record<string, string>;
|
|
49
59
|
};
|
|
50
|
-
if (
|
|
60
|
+
if (
|
|
61
|
+
manifest.commit !== PORFFOR_COMMIT_FULL ||
|
|
62
|
+
manifest.archiveSha256 !== expectedArchive ||
|
|
63
|
+
manifest.toolchainVersion !== TOOLCHAIN_VERSION
|
|
64
|
+
)
|
|
51
65
|
return false;
|
|
52
66
|
for (const file of required)
|
|
53
67
|
if (!manifest.files?.[file] || (await digest(resolve(dir, file))) !== manifest.files[file])
|
|
@@ -185,7 +199,7 @@ export async function ensurePorffor(options: AcquireOptions = {}): Promise<strin
|
|
|
185
199
|
);
|
|
186
200
|
await writeFile(
|
|
187
201
|
resolve(stage, ".sproutboat-complete"),
|
|
188
|
-
JSON.stringify({ commit: PORFFOR_COMMIT_FULL, archiveSha256: actual, files }),
|
|
202
|
+
JSON.stringify({ commit: PORFFOR_COMMIT_FULL, archiveSha256: actual, toolchainVersion: TOOLCHAIN_VERSION, files }),
|
|
189
203
|
{ mode: 0o444 },
|
|
190
204
|
);
|
|
191
205
|
await rename(stage, dir);
|
package/src/patch.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Idempotent, marker-guarded in-place edits to Porffor's generated C
|
|
3
|
-
* (`compiler/render.js`, `compiler/index.js`, `compiler/uwebsockets.js
|
|
3
|
+
* (`compiler/render.js`, `compiler/index.js`, `compiler/uwebsockets.js`,
|
|
4
|
+
* `compiler/builtins/typedarray.js`). Run
|
|
4
5
|
* from the build path, not a `postinstall` hook: package managers block
|
|
5
6
|
* dependency lifecycle scripts by default, so a published `postinstall` would
|
|
6
7
|
* silently not run.
|
|
7
8
|
*
|
|
8
9
|
* Each edit is independent and re-applied on every build; a file patched by an
|
|
9
10
|
* older version of this module still receives the newer edits. All of them are
|
|
10
|
-
* tracked in
|
|
11
|
+
* tracked in the platform's upstream notes:
|
|
12
|
+
* https://github.com/baronunread/sproutboat/tree/main/patches/upstream
|
|
13
|
+
* They go away as Porffor closes the gaps.
|
|
11
14
|
*/
|
|
12
|
-
import { readFile, writeFile } from "node:fs/promises";
|
|
15
|
+
import { readFile, realpath, writeFile } from "node:fs/promises";
|
|
13
16
|
import { resolve } from "node:path";
|
|
14
17
|
|
|
15
18
|
// --- compiler/render.js: the native-fetch server, rendered as C text ---
|
|
@@ -151,22 +154,45 @@ const RENDER_REPLACEMENTS = [
|
|
|
151
154
|
* a musl (deploy) build overrides it outright. This splices one spread of
|
|
152
155
|
* `SB_EXTRA_LINK` before `-lm`, inert unless the variable is set.
|
|
153
156
|
*/
|
|
154
|
-
const LINK_ANCHOR = "
|
|
157
|
+
const LINK_ANCHOR = " uSocketsArchive,\n '-lm'\n";
|
|
155
158
|
const LINK_INJECT =
|
|
156
|
-
"
|
|
159
|
+
" ...(process.env.SB_EXTRA_LINK ? process.env.SB_EXTRA_LINK.split(' ').filter(Boolean) : []),\n";
|
|
157
160
|
const LINK_MARKER = "SB_EXTRA_LINK";
|
|
158
161
|
|
|
159
162
|
/**
|
|
160
163
|
* #15 — and the same for the compile step, so the prelude's inline C can
|
|
161
|
-
* `#include <bearssl.h>`. The link patch alone is not enough: Porffor
|
|
162
|
-
*
|
|
163
|
-
* no way to add an include path.
|
|
164
|
+
* `#include <bearssl.h>`. The link patch alone is not enough: Porffor's
|
|
165
|
+
* module builds compile several C units with a fixed argument list, so there
|
|
166
|
+
* is otherwise no way to add an include path. Add the flag before the cache
|
|
167
|
+
* stamp is computed so a change invalidates compiled units.
|
|
164
168
|
*/
|
|
165
|
-
const CFLAGS_ANCHOR = "
|
|
169
|
+
const CFLAGS_ANCHOR = " ...darwinReleaseCompileArgs,\n";
|
|
166
170
|
const CFLAGS_INJECT =
|
|
167
|
-
"
|
|
171
|
+
" ...(process.env.SB_EXTRA_CFLAGS ? process.env.SB_EXTRA_CFLAGS.split(' ').filter(Boolean) : []),\n";
|
|
168
172
|
const CFLAGS_MARKER = "SB_EXTRA_CFLAGS";
|
|
169
173
|
|
|
174
|
+
// Porffor's TypedArray.from only handles iterables. An array-like input such
|
|
175
|
+
// as { length: 16 } silently becomes an empty typed array, including HMAC
|
|
176
|
+
// keys made with Uint8Array.from({ length: 16 }, mapFn). The compiler uses a
|
|
177
|
+
// precompiled builtin table, so the edited source must be precompiled again.
|
|
178
|
+
const TYPED_ARRAY_FROM_ANCHOR =
|
|
179
|
+
" len = i;\n }\n\n arr.length = len;\n\n return new ${name}(arr);\n};";
|
|
180
|
+
const TYPED_ARRAY_FROM_INJECT =
|
|
181
|
+
" len = i;\n" +
|
|
182
|
+
" } else {\n" +
|
|
183
|
+
" // sproutboat: TypedArray.from accepts array-like objects.\n" +
|
|
184
|
+
" let count = ecma262.ToIntegerOrInfinity(Porffor.object.get(arg, 'length'));\n" +
|
|
185
|
+
" if (count < 0) count = 0;\n" +
|
|
186
|
+
" if (count > 2147483643) throw new RangeError('Invalid TypedArray length (over maximum supported length)');\n" +
|
|
187
|
+
" if (Porffor.type(mapFn) != Porffor.TYPES.undefined && Porffor.type(mapFn) != Porffor.TYPES.function)\n" +
|
|
188
|
+
" throw new TypeError('Called TypedArray.from with a non-function mapFn');\n" +
|
|
189
|
+
" for (let i: i32 = 0; i < count; i++) {\n" +
|
|
190
|
+
" arr[i] = Porffor.type(mapFn) == Porffor.TYPES.undefined ? arg[i] : mapFn(arg[i], i);\n" +
|
|
191
|
+
" }\n" +
|
|
192
|
+
" len = count;\n" +
|
|
193
|
+
" }\n\n arr.length = len;\n\n return new ${name}(arr);\n};";
|
|
194
|
+
const TYPED_ARRAY_FROM_MARKER = "sproutboat: TypedArray.from accepts array-like objects";
|
|
195
|
+
|
|
170
196
|
/**
|
|
171
197
|
* #56 — make the inbound request-body limit configurable.
|
|
172
198
|
*
|
|
@@ -794,7 +820,7 @@ export async function patchUwebsockets(root: string): Promise<void> {
|
|
|
794
820
|
if (!src.includes(anchor)) {
|
|
795
821
|
throw new Error(
|
|
796
822
|
`could not patch Porffor's ${what}: anchor not found in ${file}. ` +
|
|
797
|
-
"Porffor's uWebSockets shim changed
|
|
823
|
+
"Porffor's uWebSockets shim changed. See https://github.com/baronunread/sproutboat/tree/main/patches/upstream.",
|
|
798
824
|
);
|
|
799
825
|
}
|
|
800
826
|
src = src.replace(anchor, inject);
|
|
@@ -816,11 +842,11 @@ async function patchCompilerArgs(root: string): Promise<void> {
|
|
|
816
842
|
if (at === -1) {
|
|
817
843
|
throw new Error(
|
|
818
844
|
`could not patch Porffor for ${what}: anchor not found in ${file}. ` +
|
|
819
|
-
"Porffor's native-fetch build changed
|
|
845
|
+
"Porffor's native-fetch build changed. See https://github.com/baronunread/sproutboat/tree/main/patches/upstream.",
|
|
820
846
|
);
|
|
821
847
|
}
|
|
822
|
-
//
|
|
823
|
-
//
|
|
848
|
+
// Add flags to compileOnlyArgs so every generated C unit sees them and
|
|
849
|
+
// Porffor's module-build cache includes them in its compiler command.
|
|
824
850
|
src =
|
|
825
851
|
marker === CFLAGS_MARKER
|
|
826
852
|
? src.slice(0, at + anchor.length) + inject + src.slice(at + anchor.length)
|
|
@@ -830,6 +856,34 @@ async function patchCompilerArgs(root: string): Promise<void> {
|
|
|
830
856
|
if (changed) await writeFile(file, src);
|
|
831
857
|
}
|
|
832
858
|
|
|
859
|
+
export async function patchTypedArrayFrom(root: string): Promise<void> {
|
|
860
|
+
const file = resolve(root, "compiler/builtins/typedarray.js");
|
|
861
|
+
const src = await readFile(file, "utf8");
|
|
862
|
+
if (!src.includes(TYPED_ARRAY_FROM_MARKER) && !src.includes(TYPED_ARRAY_FROM_ANCHOR)) {
|
|
863
|
+
throw new Error(`could not patch Porffor's TypedArray.from: anchor not found in ${file}`);
|
|
864
|
+
}
|
|
865
|
+
if (!src.includes(TYPED_ARRAY_FROM_MARKER))
|
|
866
|
+
await writeFile(file, src.replace(TYPED_ARRAY_FROM_ANCHOR, TYPED_ARRAY_FROM_INJECT));
|
|
867
|
+
const table = resolve(root, "compiler/builtins_precompiled.js");
|
|
868
|
+
const before = await readFile(table);
|
|
869
|
+
// Porffor only writes the table when import.meta.url matches argv[1].
|
|
870
|
+
// macOS's /var -> /private/var symlink makes a noncanonical argv[1] skip it.
|
|
871
|
+
const precompile = await realpath(resolve(root, "compiler/precompile.js"));
|
|
872
|
+
const child = Bun.spawn(["node", precompile], {
|
|
873
|
+
cwd: root,
|
|
874
|
+
stdout: "pipe",
|
|
875
|
+
stderr: "pipe",
|
|
876
|
+
});
|
|
877
|
+
const [code, stdout, stderr] = await Promise.all([
|
|
878
|
+
child.exited,
|
|
879
|
+
new Response(child.stdout).text(),
|
|
880
|
+
new Response(child.stderr).text(),
|
|
881
|
+
]);
|
|
882
|
+
if (code !== 0) throw new Error(`could not precompile Porffor's TypedArray.from: ${stderr || stdout}`);
|
|
883
|
+
if (!src.includes(TYPED_ARRAY_FROM_MARKER) && before.equals(await readFile(table)))
|
|
884
|
+
throw new Error(`Porffor precompile did not update ${table}`);
|
|
885
|
+
}
|
|
886
|
+
|
|
833
887
|
/** The native-fetch server source: $PORT support + the #165 console sink. Exported for tests. */
|
|
834
888
|
export async function patchRenderJs(root: string): Promise<void> {
|
|
835
889
|
const file = resolve(root, "compiler/render.js");
|
|
@@ -841,7 +895,7 @@ export async function patchRenderJs(root: string): Promise<void> {
|
|
|
841
895
|
if (at === -1) {
|
|
842
896
|
throw new Error(
|
|
843
897
|
`could not patch Porffor for ${what}: anchor not found in ${file}. ` +
|
|
844
|
-
"Porffor's native-fetch renderer changed
|
|
898
|
+
"Porffor's native-fetch renderer changed. See https://github.com/baronunread/sproutboat/tree/main/patches/upstream.",
|
|
845
899
|
);
|
|
846
900
|
}
|
|
847
901
|
src = src.slice(0, at + anchor.length) + inject + src.slice(at + anchor.length);
|
|
@@ -855,7 +909,7 @@ export async function patchRenderJs(root: string): Promise<void> {
|
|
|
855
909
|
if (!src.includes(anchor)) {
|
|
856
910
|
throw new Error(
|
|
857
911
|
`could not patch Porffor for ${what}: anchor not found in ${file}. ` +
|
|
858
|
-
"Porffor's native-fetch renderer changed
|
|
912
|
+
"Porffor's native-fetch renderer changed. See https://github.com/baronunread/sproutboat/tree/main/patches/upstream.",
|
|
859
913
|
);
|
|
860
914
|
}
|
|
861
915
|
src = src.replace(anchor, inject);
|
|
@@ -876,5 +930,6 @@ export async function ensurePorfforPatched(root: string): Promise<void> {
|
|
|
876
930
|
await patchCompilerArgs(root);
|
|
877
931
|
await patchUwebsockets(root);
|
|
878
932
|
await patchRenderJs(root);
|
|
933
|
+
await patchTypedArrayFrom(root);
|
|
879
934
|
done.add(root);
|
|
880
935
|
}
|
package/src/pin.ts
CHANGED
|
@@ -11,14 +11,14 @@
|
|
|
11
11
|
* uWebSockets archive in `sproutboat-cli/vendor/` — then run both repos'
|
|
12
12
|
* test + conformance suites. See sproutboat-cli/MIGRATION.md.
|
|
13
13
|
*/
|
|
14
|
-
export const PORFFOR_CHANNEL = "alpha-
|
|
15
|
-
export const PORFFOR_COMMIT_FULL = "
|
|
14
|
+
export const PORFFOR_CHANNEL = "alpha-9";
|
|
15
|
+
export const PORFFOR_COMMIT_FULL = "de4eb588264885b3a1596f75010e371a2052033f";
|
|
16
16
|
export const PORFFOR_COMMIT = PORFFOR_COMMIT_FULL.slice(0, 7);
|
|
17
17
|
export const PORFFOR_ARCHIVE_SHA256 =
|
|
18
|
-
"
|
|
18
|
+
"1a62187a93356b36cb6ac703ce9770c8917e4fa65545fd7c33ee8a180ae5a4c9";
|
|
19
19
|
export const PORFFOR_ARCHIVE_URL = `https://codeload.github.com/CanadaHonk/porffor/tar.gz/${PORFFOR_COMMIT_FULL}`;
|
|
20
20
|
|
|
21
|
-
/** A compact identity string for a manifest / report (`alpha-
|
|
21
|
+
/** A compact identity string for a manifest / report (`alpha-9 (de4eb58)`). */
|
|
22
22
|
export function porfforVersion(): string {
|
|
23
23
|
return process.env.PORFFOR_VERSION || `${PORFFOR_CHANNEL} (${PORFFOR_COMMIT})`;
|
|
24
24
|
}
|
|
Binary file
|
|
Binary file
|