@sproutboat/runtime 0.16.0 → 0.17.1
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 +68 -0
- package/WEB_STREAMS.md +7 -3
- package/package.json +1 -1
- package/src/asset-rules.test.js +125 -0
- package/src/egress.test.ts +248 -5
- package/src/gen-streams.ts +4 -5
- package/src/native-fetch-prelude.js +776 -112
- package/src/streams-entry.js +17 -3
- package/src/transport-broker.js +12 -0
- package/src/transport-embedded.js +403 -71
- package/test/native-bodies.ts +136 -0
- package/test/native-errors.ts +101 -0
- package/test/native-events.ts +102 -0
- package/test/native-iterators.ts +6 -1
- package/test/native-json.ts +102 -0
- package/test/native-raw-body.ts +118 -0
- package/test/native-request.ts +101 -0
- package/test/native-response-defaults.ts +98 -0
- package/test/native-streaming.ts +117 -0
- package/test/native-url.ts +145 -0
- package/test/native-waituntil.ts +107 -0
- package/test/native-web-apis.ts +110 -0
package/src/streams-entry.js
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
// Generator input only. Native modules use the generated, import-free block.
|
|
2
|
+
// One static assignment per class, not a loop over the exports: Porffor resolves a bare
|
|
3
|
+
// identifier such as ReadableStream at compile time from the globalThis.X assignments it
|
|
4
|
+
// can see. Where the prelude is a separate unit (sproutd), a dynamic install compiled
|
|
5
|
+
// `new ReadableStream()` in the app to a ReferenceError. gen-streams.ts checks the list.
|
|
2
6
|
import * as streams from "web-streams-polyfill";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
7
|
+
if (globalThis.ByteLengthQueuingStrategy == null) globalThis.ByteLengthQueuingStrategy = streams.ByteLengthQueuingStrategy;
|
|
8
|
+
if (globalThis.CountQueuingStrategy == null) globalThis.CountQueuingStrategy = streams.CountQueuingStrategy;
|
|
9
|
+
if (globalThis.ReadableByteStreamController == null) globalThis.ReadableByteStreamController = streams.ReadableByteStreamController;
|
|
10
|
+
if (globalThis.ReadableStream == null) globalThis.ReadableStream = streams.ReadableStream;
|
|
11
|
+
if (globalThis.ReadableStreamBYOBReader == null) globalThis.ReadableStreamBYOBReader = streams.ReadableStreamBYOBReader;
|
|
12
|
+
if (globalThis.ReadableStreamBYOBRequest == null) globalThis.ReadableStreamBYOBRequest = streams.ReadableStreamBYOBRequest;
|
|
13
|
+
if (globalThis.ReadableStreamDefaultController == null) globalThis.ReadableStreamDefaultController = streams.ReadableStreamDefaultController;
|
|
14
|
+
if (globalThis.ReadableStreamDefaultReader == null) globalThis.ReadableStreamDefaultReader = streams.ReadableStreamDefaultReader;
|
|
15
|
+
if (globalThis.TransformStream == null) globalThis.TransformStream = streams.TransformStream;
|
|
16
|
+
if (globalThis.TransformStreamDefaultController == null) globalThis.TransformStreamDefaultController = streams.TransformStreamDefaultController;
|
|
17
|
+
if (globalThis.WritableStream == null) globalThis.WritableStream = streams.WritableStream;
|
|
18
|
+
if (globalThis.WritableStreamDefaultController == null) globalThis.WritableStreamDefaultController = streams.WritableStreamDefaultController;
|
|
19
|
+
if (globalThis.WritableStreamDefaultWriter == null) globalThis.WritableStreamDefaultWriter = streams.WritableStreamDefaultWriter;
|
package/src/transport-broker.js
CHANGED
|
@@ -407,6 +407,18 @@ globalThis.__sbFetchUpstream = function (op, msg) {
|
|
|
407
407
|
return reply;
|
|
408
408
|
};
|
|
409
409
|
|
|
410
|
+
// Async fetch (a host that drives requests off its event loop, like sproutd) exists
|
|
411
|
+
// only in the embedded transport. Here fetch() is always synchronous.
|
|
412
|
+
function __sbHttpAsyncEnabled() {
|
|
413
|
+
return false;
|
|
414
|
+
}
|
|
415
|
+
function __sbHttpAsyncResult() {
|
|
416
|
+
return "";
|
|
417
|
+
}
|
|
418
|
+
function __sbFetchReply() {
|
|
419
|
+
throw new Error("async fetch needs the embedded transport");
|
|
420
|
+
}
|
|
421
|
+
|
|
410
422
|
/** Static asset metadata stays JSON; the response body uses the v1 byte tail. */
|
|
411
423
|
globalThis.__sbAssetsGet = function (path) {
|
|
412
424
|
const token = __sbEnv("SB_BROKER_TOKEN");
|