@modern-js/runtime 3.9.2 → 3.9.3
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/cjs/core/server/requestHandler.js +2 -0
- package/dist/cjs/core/server/stream/createReadableStream.js +51 -8
- package/dist/cjs/core/server/stream/createReadableStream.worker.js +37 -15
- package/dist/cjs/core/server/stream/deferredScript.js +12 -6
- package/dist/cjs/core/server/stream/deferredScriptOutputCoordinator.js +370 -0
- package/dist/cjs/router/runtime/DeferredDataScripts.node.js +3 -1
- package/dist/esm/core/server/requestHandler.mjs +2 -0
- package/dist/esm/core/server/stream/createReadableStream.mjs +51 -8
- package/dist/esm/core/server/stream/createReadableStream.worker.mjs +37 -15
- package/dist/esm/core/server/stream/deferredScript.mjs +12 -6
- package/dist/esm/core/server/stream/deferredScriptOutputCoordinator.mjs +332 -0
- package/dist/esm/router/runtime/DeferredDataScripts.node.mjs +3 -1
- package/dist/esm-node/core/server/requestHandler.mjs +2 -0
- package/dist/esm-node/core/server/stream/createReadableStream.mjs +51 -8
- package/dist/esm-node/core/server/stream/createReadableStream.worker.mjs +37 -15
- package/dist/esm-node/core/server/stream/deferredScript.mjs +12 -6
- package/dist/esm-node/core/server/stream/deferredScriptOutputCoordinator.mjs +333 -0
- package/dist/esm-node/router/runtime/DeferredDataScripts.node.mjs +3 -1
- package/dist/types/core/server/stream/deferredScript.d.ts +1 -1
- package/dist/types/core/server/stream/deferredScriptOutputCoordinator.d.ts +72 -0
- package/package.json +12 -12
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serializes the router's deferred-data resolver scripts with React's Fizz
|
|
3
|
+
* output without rewriting either producer's bytes.
|
|
4
|
+
*
|
|
5
|
+
* Why this exists:
|
|
6
|
+
* - A resolver script settles the client-side Promise created for a
|
|
7
|
+
* `defer()` key. It must be sent when that individual server Promise
|
|
8
|
+
* settles; waiting for the whole React stream would unnecessarily delay
|
|
9
|
+
* hydration and interactivity behind unrelated Suspense boundaries.
|
|
10
|
+
* - React and the resolver callbacks are independent stream producers. A
|
|
11
|
+
* direct `write()` can therefore land in a partial HTML tag, a hidden Fizz
|
|
12
|
+
* segment container, or between that container and its continuation
|
|
13
|
+
* instruction.
|
|
14
|
+
* - React's public streaming callbacks expose shell/all-ready lifecycle
|
|
15
|
+
* events, not a safe byte-level insertion point. React chunk sizes and
|
|
16
|
+
* `progressiveChunkSize` are buffering heuristics, not HTML or Fizz
|
|
17
|
+
* boundaries.
|
|
18
|
+
*
|
|
19
|
+
* The coordinator deliberately recognizes the Fizz continuation containers
|
|
20
|
+
* and instructions used by the supported React stream format. This is a
|
|
21
|
+
* compatibility boundary: when the supported React/Fizz output protocol is
|
|
22
|
+
* changed, update this recognizer and its Node, Edge, HTML, SVG, MathML, and
|
|
23
|
+
* table continuation tests together. It is not intended to be a general HTML
|
|
24
|
+
* rewriter.
|
|
25
|
+
*
|
|
26
|
+
* Shell completion only makes a resolver eligible to send. The resolver is
|
|
27
|
+
* emitted after a root-level HTML boundary and, for a continuation segment,
|
|
28
|
+
* after React's matching continuation instruction.
|
|
29
|
+
*/
|
|
30
|
+
export declare class DeferredScriptOutputCoordinator {
|
|
31
|
+
private readonly emit;
|
|
32
|
+
private readonly pendingResolvers;
|
|
33
|
+
private readonly openElements;
|
|
34
|
+
private shellFinished;
|
|
35
|
+
private closed;
|
|
36
|
+
private state;
|
|
37
|
+
private currentTagName;
|
|
38
|
+
private currentAttributes;
|
|
39
|
+
private currentAttributeName;
|
|
40
|
+
private currentAttributeValue;
|
|
41
|
+
private currentAttributeHasValue;
|
|
42
|
+
private declarationPrefix;
|
|
43
|
+
private commentTail;
|
|
44
|
+
private rawTextElement;
|
|
45
|
+
private rawTextSearch;
|
|
46
|
+
private continuationProtocolScript;
|
|
47
|
+
private continuationProtocolTail;
|
|
48
|
+
private hasContinuationProtocolCall;
|
|
49
|
+
private awaitingContinuationProtocol;
|
|
50
|
+
constructor(emit: (chunk: string) => void);
|
|
51
|
+
enqueueResolver(script: string): void;
|
|
52
|
+
/**
|
|
53
|
+
* Keep this separate from the ShellChunkStatus assignment. The caller sets
|
|
54
|
+
* FINISH at the existing marker position, then calls this after the marker
|
|
55
|
+
* chunk's afterMark bytes have been observed.
|
|
56
|
+
*/
|
|
57
|
+
markShellFinished(): void;
|
|
58
|
+
writeReact(chunk: string): void;
|
|
59
|
+
finish(): void;
|
|
60
|
+
abort(): void;
|
|
61
|
+
private isSafeBoundary;
|
|
62
|
+
private flushResolvers;
|
|
63
|
+
private consume;
|
|
64
|
+
private startTag;
|
|
65
|
+
private startAttribute;
|
|
66
|
+
private completeAttribute;
|
|
67
|
+
private completeStartTag;
|
|
68
|
+
private completeEndTag;
|
|
69
|
+
private consumeRawText;
|
|
70
|
+
private completeRawTextEndTag;
|
|
71
|
+
private closeOpenElement;
|
|
72
|
+
}
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "3.9.
|
|
18
|
+
"version": "3.9.3",
|
|
19
19
|
"engines": {
|
|
20
20
|
"node": ">=20"
|
|
21
21
|
},
|
|
@@ -215,12 +215,12 @@
|
|
|
215
215
|
"isbot": "3.8.0",
|
|
216
216
|
"react-helmet": "^6.1.0",
|
|
217
217
|
"react-is": "^18.3.1",
|
|
218
|
-
"@modern-js/plugin": "3.9.
|
|
219
|
-
"@modern-js/plugin-data-loader": "3.9.
|
|
220
|
-
"@modern-js/render": "3.9.
|
|
221
|
-
"@modern-js/runtime-utils": "3.9.
|
|
222
|
-
"@modern-js/
|
|
223
|
-
"@modern-js/
|
|
218
|
+
"@modern-js/plugin": "3.9.3",
|
|
219
|
+
"@modern-js/plugin-data-loader": "3.9.3",
|
|
220
|
+
"@modern-js/render": "3.9.3",
|
|
221
|
+
"@modern-js/runtime-utils": "3.9.3",
|
|
222
|
+
"@modern-js/types": "3.9.3",
|
|
223
|
+
"@modern-js/utils": "3.9.3"
|
|
224
224
|
},
|
|
225
225
|
"peerDependencies": {
|
|
226
226
|
"react": ">=18.3.1",
|
|
@@ -228,10 +228,10 @@
|
|
|
228
228
|
},
|
|
229
229
|
"devDependencies": {
|
|
230
230
|
"@remix-run/web-fetch": "^4.1.3",
|
|
231
|
-
"@rsbuild/core": "2.2.
|
|
232
|
-
"@rslib/core": "1.0.
|
|
233
|
-
"@testing-library/dom": "^10.4.
|
|
234
|
-
"@testing-library/react": "^16.3.
|
|
231
|
+
"@rsbuild/core": "2.2.9",
|
|
232
|
+
"@rslib/core": "1.0.1",
|
|
233
|
+
"@testing-library/dom": "^10.4.2",
|
|
234
|
+
"@testing-library/react": "^16.3.3",
|
|
235
235
|
"@types/cookie": "0.6.0",
|
|
236
236
|
"@types/invariant": "^2.2.37",
|
|
237
237
|
"@types/loadable__server": "5.12.11",
|
|
@@ -240,7 +240,7 @@
|
|
|
240
240
|
"react-dom": "^19.2.8",
|
|
241
241
|
"ts-node": "^10.9.2",
|
|
242
242
|
"typescript": "^5",
|
|
243
|
-
"@modern-js/app-tools": "3.9.
|
|
243
|
+
"@modern-js/app-tools": "3.9.3",
|
|
244
244
|
"@modern-js/rslib": "2.68.10",
|
|
245
245
|
"@scripts/rstest-config": "2.66.0"
|
|
246
246
|
},
|