@sproutboat/runtime 0.15.0 → 0.16.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 +8 -0
- package/README.md +6 -0
- package/WEB_STREAMS.md +33 -0
- package/WEB_STREAMS_LICENSE +22 -0
- package/package.json +1 -1
- package/src/gen-streams.ts +35 -0
- package/src/native-fetch-prelude.js +2324 -0
- package/src/streams-entry.js +5 -0
- package/test/native-base64.ts +89 -0
- package/test/native-model-resolver.ts +100 -0
- package/test/native-streams.ts +107 -0
- package/test/native-timers.ts +89 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @sproutboat/runtime
|
|
2
2
|
|
|
3
|
+
## 0.16.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 14546a0: Add Web Streams globals from web-streams-polyfill 4.3.0, including readable, writable and transform streams, with native regression coverage. Streams run in memory; HTTP request and response bodies remain buffered by the native transport. Together with the compiler fixes, Better Auth 1.7.1 passes email/password and signed-cookie session flows with an explicit memory database adapter. Database-free encrypted sessions still require unsupported AES crypto.
|
|
8
|
+
|
|
9
|
+
Expose the existing native timeout and interval functions on globalThis, supporting host-task yields in noble hashes 2.4 without changing timer semantics.
|
|
10
|
+
|
|
3
11
|
## 0.15.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -32,6 +32,12 @@ crypto random values, binding shims, trigger dispatch) and is identical
|
|
|
32
32
|
for both transports, which is what lets one conformance suite hold them
|
|
33
33
|
honest.
|
|
34
34
|
|
|
35
|
+
## Web Streams
|
|
36
|
+
|
|
37
|
+
The prelude includes readable, writable and transform stream globals. These
|
|
38
|
+
operate in memory; HTTP bodies remain buffered. See [native Web Streams](WEB_STREAMS.md)
|
|
39
|
+
for tested APIs, transport limits and Better Auth compatibility.
|
|
40
|
+
|
|
35
41
|
## R2 multipart uploads
|
|
36
42
|
|
|
37
43
|
R2 bindings implement the Cloudflare multipart method shape for objects that
|
package/WEB_STREAMS.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Native Web Streams
|
|
2
|
+
|
|
3
|
+
The runtime installs missing Web Streams globals using the MIT-licensed
|
|
4
|
+
web-streams-polyfill 4.3.0. The generated implementation is embedded in the
|
|
5
|
+
native prelude, so deployed binaries need no JavaScript files or package loader.
|
|
6
|
+
Run `bun run gen:streams` from the repository root to regenerate it.
|
|
7
|
+
|
|
8
|
+
Native regression tests cover default readers, locking, pending reads,
|
|
9
|
+
cancellation, source errors, array conversion, writable sinks, pipeTo,
|
|
10
|
+
pipeThrough, transforms, tee, pull sources, byte streams and BYOB reads.
|
|
11
|
+
This is API support for streams in memory, not progressive HTTP transport.
|
|
12
|
+
Request and Response bodies and outbound fetch remain buffered. Passing a
|
|
13
|
+
ReadableStream as an HTTP body is not supported. TextEncoderStream,
|
|
14
|
+
TextDecoderStream, CompressionStream and DecompressionStream are not included.
|
|
15
|
+
BYOB buffer detachment requires transfer support from the underlying engine;
|
|
16
|
+
the polyfill cannot supply that engine primitive. Full Web Platform Tests
|
|
17
|
+
conformance has not been established for Porffor.
|
|
18
|
+
|
|
19
|
+
Porffor Alpha 16 requires controller classes at module scope, rather than inside
|
|
20
|
+
an IIFE. The generator also adapts dynamic array iterator lookup to the working
|
|
21
|
+
native array values iterator. User handler modules retain their separate scope.
|
|
22
|
+
|
|
23
|
+
Better Auth 1.7.1 now passes native email/password signup, signed-cookie session
|
|
24
|
+
lookup, wrong-password rejection, signin, signout and session revocation with an
|
|
25
|
+
explicit memory database adapter. The compiler also needs the local-function
|
|
26
|
+
return-type and Uint8Array base64 patches shipped with this upgrade. The default
|
|
27
|
+
Better Auth password hashing is retained; credential operations take about
|
|
28
|
+
6 to 8 seconds on the development machine with optimized native compilation.
|
|
29
|
+
This is a verified integration configuration, not a production database benchmark.
|
|
30
|
+
|
|
31
|
+
Database-free Better Auth selects encrypted JWE sessions and still fails because
|
|
32
|
+
native crypto does not implement AES. Production database adapters, OAuth,
|
|
33
|
+
plugins and asymmetric JWT algorithms have not been validated by this probe.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mattias Buelens
|
|
4
|
+
Copyright (c) 2016 Diwank Singh Tomer
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/package.json
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
|
|
3
|
+
const marker = "// WEB STREAMS: generated by gen-streams.ts, do not edit.";
|
|
4
|
+
const endMarker = "// END WEB STREAMS";
|
|
5
|
+
const result = await Bun.build({
|
|
6
|
+
entrypoints: [`${import.meta.dir}/streams-entry.js`],
|
|
7
|
+
target: "browser",
|
|
8
|
+
format: "iife",
|
|
9
|
+
minify: false,
|
|
10
|
+
});
|
|
11
|
+
if (!result.success) throw new Error(result.logs.join("\n"));
|
|
12
|
+
let code = await result.outputs[0].text();
|
|
13
|
+
// Porffor cannot resolve controller class prototypes captured by an IIFE.
|
|
14
|
+
// Keep these classes at module scope. User modules have their own scope.
|
|
15
|
+
if (!code.startsWith("(() => {") || !code.trimEnd().endsWith("})();")) {
|
|
16
|
+
throw new Error("Unexpected streams bundle format");
|
|
17
|
+
}
|
|
18
|
+
code = code.slice("(() => {".length).trimEnd().slice(0, -"})();".length);
|
|
19
|
+
code = code.replace(/^\s*\/\/ .*streams-entry.js$/m, "// streams-entry.js");
|
|
20
|
+
code = code.replace(/^\s*\/\/ .*web-streams-polyfill\/dist\/ponyfill.mjs$/m,
|
|
21
|
+
"// web-streams-polyfill 4.3.0, MIT, copyright Mattias Buelens (see WEB_STREAMS_LICENSE)");
|
|
22
|
+
// Alpha 16's direct array iterator works, but dynamic symbol lookup misses it.
|
|
23
|
+
const lookup = "const r = e[t];\n if (r != null)";
|
|
24
|
+
if (!code.includes(lookup)) throw new Error("Streams iterator adapter target changed");
|
|
25
|
+
code = code.replace(lookup,
|
|
26
|
+
"let r = e[t];\n if (r == null && t === Symbol.iterator && Array.isArray(e)) r = () => e.values();\n if (r != null)");
|
|
27
|
+
const path = `${import.meta.dir}/native-fetch-prelude.js`;
|
|
28
|
+
let prelude = await readFile(path, "utf8");
|
|
29
|
+
const start = prelude.indexOf(marker);
|
|
30
|
+
if (start !== -1) {
|
|
31
|
+
const end = prelude.indexOf(endMarker, start);
|
|
32
|
+
if (end === -1) throw new Error("Missing streams block end marker");
|
|
33
|
+
prelude = prelude.slice(0, start) + prelude.slice(end + endMarker.length).replace(/^\n+/, "");
|
|
34
|
+
}
|
|
35
|
+
await writeFile(path, `${marker}\n/* oxlint-disable -- generated third-party implementation */\n${code}\n/* oxlint-enable */\n${endMarker}\n\n${prelude}`);
|