@tanstack/redact 0.0.21 → 0.1.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/dist/core/attributes.js +2 -1
- package/dist/core/attributes.js.map +2 -2
- package/dist/core/browser.d.ts +9 -0
- package/dist/core/browser.js +35 -0
- package/dist/core/browser.js.map +7 -0
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +3 -3
- package/dist/core/internal.d.ts +31 -8
- package/dist/core/internal.js +3 -1
- package/dist/core/internal.js.map +2 -2
- package/dist/core/resource-hints.d.ts +7 -0
- package/dist/core/resource-hints.js +19 -0
- package/dist/core/resource-hints.js.map +7 -0
- package/dist/core/types.js +1 -1
- package/dist/dom/_all.d.ts +11 -16
- package/dist/dom/_all.js +9 -20
- package/dist/dom/_all.js.map +2 -2
- package/dist/dom/client.d.ts +4 -4
- package/dist/dom/client.js +4 -4
- package/dist/dom/commit.d.ts +23 -0
- package/dist/dom/commit.js +191 -0
- package/dist/dom/commit.js.map +7 -0
- package/dist/dom/dispatcher.d.ts +4 -22
- package/dist/dom/dispatcher.js +184 -126
- package/dist/dom/dispatcher.js.map +3 -3
- package/dist/dom/dom.d.ts +2 -0
- package/dist/dom/dom.js +72 -52
- package/dist/dom/dom.js.map +2 -2
- package/dist/dom/error-info.d.ts +2 -0
- package/dist/dom/error-info.js +16 -0
- package/dist/dom/error-info.js.map +7 -0
- package/dist/dom/event-replay.js +1 -1
- package/dist/dom/features/activity/full.d.ts +1 -0
- package/dist/dom/features/activity/full.js +162 -0
- package/dist/dom/features/activity/full.js.map +7 -0
- package/dist/dom/features/activity/index.d.ts +1 -0
- package/dist/dom/features/activity/index.js +3 -0
- package/dist/dom/features/activity/index.js.map +7 -0
- package/dist/dom/features/activity/stub.d.ts +1 -0
- package/dist/dom/features/activity/stub.js +12 -0
- package/dist/dom/features/activity/stub.js.map +7 -0
- package/dist/dom/features/class/full.js +87 -27
- package/dist/dom/features/class/full.js.map +2 -2
- package/dist/dom/features/class/index.d.ts +1 -1
- package/dist/dom/features/class/index.js +2 -2
- package/dist/dom/features/class/stub.js +3 -3
- package/dist/dom/features/context/full.d.ts +4 -1
- package/dist/dom/features/context/full.js +72 -15
- package/dist/dom/features/context/full.js.map +2 -2
- package/dist/dom/features/context/index.d.ts +1 -1
- package/dist/dom/features/context/index.js +2 -2
- package/dist/dom/features/context/stub.d.ts +4 -1
- package/dist/dom/features/context/stub.js +17 -8
- package/dist/dom/features/context/stub.js.map +2 -2
- package/dist/dom/features/forward-ref/full.js +12 -21
- package/dist/dom/features/forward-ref/full.js.map +2 -2
- package/dist/dom/features/forward-ref/index.d.ts +1 -1
- package/dist/dom/features/forward-ref/index.js +2 -2
- package/dist/dom/features/forward-ref/stub.js +4 -4
- package/dist/dom/features/fragment-refs/index.d.ts +1 -0
- package/dist/dom/features/fragment-refs/index.js +8 -0
- package/dist/dom/features/fragment-refs/index.js.map +7 -0
- package/dist/dom/features/fragment-refs/stub.d.ts +3 -0
- package/dist/dom/features/fragment-refs/stub.js +14 -0
- package/dist/dom/features/fragment-refs/stub.js.map +7 -0
- package/dist/dom/features/hydration/full.d.ts +11 -6
- package/dist/dom/features/hydration/full.js +76 -77
- package/dist/dom/features/hydration/full.js.map +2 -2
- package/dist/dom/features/hydration/index.d.ts +1 -1
- package/dist/dom/features/hydration/index.js +2 -2
- package/dist/dom/features/hydration/stub.d.ts +7 -2
- package/dist/dom/features/hydration/stub.js +1 -1
- package/dist/dom/features/hydration/stub.js.map +1 -1
- package/dist/dom/features/index.d.ts +8 -7
- package/dist/dom/features/index.js +9 -8
- package/dist/dom/features/index.js.map +2 -2
- package/dist/dom/features/lazy/full.js +4 -4
- package/dist/dom/features/lazy/index.d.ts +1 -1
- package/dist/dom/features/lazy/index.js +2 -2
- package/dist/dom/features/lazy/stub.js +4 -4
- package/dist/dom/features/memo/full.js +8 -6
- package/dist/dom/features/memo/full.js.map +2 -2
- package/dist/dom/features/memo/index.d.ts +1 -1
- package/dist/dom/features/memo/index.js +2 -2
- package/dist/dom/features/memo/stub.js +4 -4
- package/dist/dom/features/portal/full.js +4 -4
- package/dist/dom/features/portal/index.d.ts +1 -1
- package/dist/dom/features/portal/index.js +2 -2
- package/dist/dom/features/portal/stub.js +4 -4
- package/dist/dom/features/suspense/full.js +197 -52
- package/dist/dom/features/suspense/full.js.map +2 -2
- package/dist/dom/features/suspense/index.d.ts +1 -1
- package/dist/dom/features/suspense/index.js +2 -2
- package/dist/dom/features/suspense/stub.js +4 -4
- package/dist/dom/features/view-transition/full.d.ts +6 -0
- package/dist/dom/features/view-transition/full.js +280 -0
- package/dist/dom/features/view-transition/full.js.map +7 -0
- package/dist/dom/features/view-transition/index.d.ts +1 -0
- package/dist/dom/features/view-transition/index.js +3 -0
- package/dist/dom/features/view-transition/index.js.map +7 -0
- package/dist/dom/features/view-transition/resources.d.ts +11 -0
- package/dist/dom/features/view-transition/resources.js +108 -0
- package/dist/dom/features/view-transition/resources.js.map +7 -0
- package/dist/dom/features/view-transition/stub.d.ts +6 -0
- package/dist/dom/features/view-transition/stub.js +22 -0
- package/dist/dom/features/view-transition/stub.js.map +7 -0
- package/dist/dom/features/view-transition/visual.d.ts +14 -0
- package/dist/dom/features/view-transition/visual.js +356 -0
- package/dist/dom/features/view-transition/visual.js.map +7 -0
- package/dist/dom/fragment-instance.d.ts +40 -0
- package/dist/dom/fragment-instance.js +324 -0
- package/dist/dom/fragment-instance.js.map +7 -0
- package/dist/dom/index.d.ts +11 -11
- package/dist/dom/index.js +11 -18
- package/dist/dom/index.js.map +3 -3
- package/dist/dom/portal.d.ts +2 -2
- package/dist/dom/portal.js +2 -2
- package/dist/dom/portal.js.map +1 -1
- package/dist/dom/reconcile.d.ts +32 -3
- package/dist/dom/reconcile.js +689 -221
- package/dist/dom/reconcile.js.map +2 -2
- package/dist/dom/resource-hints.d.ts +6 -0
- package/dist/dom/resource-hints.js +115 -0
- package/dist/dom/resource-hints.js.map +7 -0
- package/dist/dom/resource-store.d.ts +13 -0
- package/dist/dom/resource-store.js +43 -0
- package/dist/dom/resource-store.js.map +7 -0
- package/dist/dom/resources.d.ts +1 -0
- package/dist/dom/resources.js +44 -0
- package/dist/dom/resources.js.map +7 -0
- package/dist/dom/retained-effects.d.ts +6 -0
- package/dist/dom/retained-effects.js +49 -0
- package/dist/dom/retained-effects.js.map +7 -0
- package/dist/dom/root-internal.d.ts +4 -4
- package/dist/dom/root-internal.js +2 -2
- package/dist/dom/root-internal.js.map +2 -2
- package/dist/dom/root.d.ts +5 -5
- package/dist/dom/root.js +11 -11
- package/dist/dom/root.js.map +2 -2
- package/dist/dom/test-utils.js +1 -1
- package/dist/react/activity.d.ts +7 -0
- package/dist/react/activity.js +8 -0
- package/dist/react/activity.js.map +7 -0
- package/dist/react/children.d.ts +1 -1
- package/dist/react/children.js +3 -3
- package/dist/react/children.js.map +1 -1
- package/dist/react/class.d.ts +1 -1
- package/dist/react/class.js +3 -3
- package/dist/react/class.js.map +1 -1
- package/dist/react/compiler-runtime.js +2 -2
- package/dist/react/context.d.ts +7 -2
- package/dist/react/context.js +3 -11
- package/dist/react/context.js.map +3 -3
- package/dist/react/element.d.ts +6 -3
- package/dist/react/element.js +7 -11
- package/dist/react/element.js.map +2 -2
- package/dist/react/hooks.d.ts +26 -7
- package/dist/react/hooks.js +13 -3
- package/dist/react/hooks.js.map +2 -2
- package/dist/react/index.d.ts +39 -24
- package/dist/react/index.js +39 -19
- package/dist/react/index.js.map +3 -3
- package/dist/react/jsx-runtime.d.ts +2 -2
- package/dist/react/jsx-runtime.js +3 -3
- package/dist/react/memo.d.ts +1 -1
- package/dist/react/memo.js +1 -1
- package/dist/react/portal.js +1 -1
- package/dist/react/shared-internals.d.ts +15 -5
- package/dist/react/shared-internals.js +2 -3
- package/dist/react/shared-internals.js.map +2 -2
- package/dist/react/suspense.js +1 -1
- package/dist/react/view-transition.d.ts +32 -0
- package/dist/react/view-transition.js +13 -0
- package/dist/react/view-transition.js.map +7 -0
- package/dist/scheduler/index.js +1 -1
- package/dist/server/bootstrap-script.d.ts +1 -23
- package/dist/server/bootstrap-script.js +7 -6
- package/dist/server/bootstrap-script.js.map +2 -2
- package/dist/server/dispatcher.d.ts +28 -6
- package/dist/server/dispatcher.js +33 -15
- package/dist/server/dispatcher.js.map +2 -2
- package/dist/server/escape.js +16 -15
- package/dist/server/escape.js.map +2 -2
- package/dist/server/index.d.ts +6 -6
- package/dist/server/index.js +7 -7
- package/dist/server/renderToString.d.ts +1 -1
- package/dist/server/renderToString.js +12 -8
- package/dist/server/renderToString.js.map +2 -2
- package/dist/server/resource-hints.d.ts +22 -0
- package/dist/server/resource-hints.js +148 -0
- package/dist/server/resource-hints.js.map +7 -0
- package/dist/server/stream.d.ts +15 -2
- package/dist/server/stream.js +155 -63
- package/dist/server/stream.js.map +2 -2
- package/dist/server/walk.d.ts +15 -2
- package/dist/server/walk.js +150 -110
- package/dist/server/walk.js.map +2 -2
- package/dist/vite/index.d.ts +6 -0
- package/dist/vite/index.js +22 -6
- package/dist/vite/index.js.map +2 -2
- package/package.json +1 -1
- package/src/core/attributes.ts +1 -0
- package/src/core/browser.ts +33 -0
- package/src/core/internal.ts +24 -6
- package/src/core/resource-hints.ts +36 -0
- package/src/dom/_all.ts +1 -7
- package/src/dom/commit.ts +186 -0
- package/src/dom/dispatcher.ts +190 -134
- package/src/dom/dom.ts +70 -54
- package/src/dom/error-info.ts +15 -0
- package/src/dom/features/activity/full.ts +166 -0
- package/src/dom/features/activity/index.ts +1 -0
- package/src/dom/features/activity/stub.ts +14 -0
- package/src/dom/features/class/full.ts +72 -28
- package/src/dom/features/context/full.ts +70 -13
- package/src/dom/features/context/stub.ts +10 -5
- package/src/dom/features/forward-ref/full.ts +9 -19
- package/src/dom/features/fragment-refs/index.ts +1 -0
- package/src/dom/features/fragment-refs/stub.ts +3 -0
- package/src/dom/features/hydration/full.ts +84 -85
- package/src/dom/features/hydration/stub.ts +1 -1
- package/src/dom/features/index.ts +1 -0
- package/src/dom/features/memo/full.ts +4 -3
- package/src/dom/features/suspense/full.ts +192 -55
- package/src/dom/features/view-transition/full.ts +288 -0
- package/src/dom/features/view-transition/index.ts +1 -0
- package/src/dom/features/view-transition/resources.ts +107 -0
- package/src/dom/features/view-transition/stub.ts +7 -0
- package/src/dom/features/view-transition/visual.ts +406 -0
- package/src/dom/fragment-instance.ts +337 -0
- package/src/dom/index.ts +6 -7
- package/src/dom/portal.ts +1 -1
- package/src/dom/reconcile.ts +695 -242
- package/src/dom/resource-hints.ts +115 -0
- package/src/dom/resource-store.ts +52 -0
- package/src/dom/resources.ts +39 -0
- package/src/dom/retained-effects.ts +38 -0
- package/src/dom/root-internal.ts +4 -4
- package/src/dom/root.ts +12 -14
- package/src/react/activity.ts +10 -0
- package/src/react/context.ts +4 -11
- package/src/react/element.ts +11 -12
- package/src/react/hooks.ts +12 -3
- package/src/react/index.ts +18 -0
- package/src/react/shared-internals.ts +3 -3
- package/src/react/view-transition.ts +41 -0
- package/src/server/bootstrap-script.ts +36 -5
- package/src/server/dispatcher.ts +35 -13
- package/src/server/escape.ts +15 -12
- package/src/server/renderToString.ts +7 -5
- package/src/server/resource-hints.ts +165 -0
- package/src/server/stream.ts +154 -62
- package/src/server/walk.ts +79 -26
- package/src/vite/index.ts +30 -13
|
@@ -1,25 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Inline client runtime injected into the streamed HTML. Two jobs:
|
|
3
|
-
*
|
|
4
|
-
* 1. Reveal suspense boundaries as their resolved chunks arrive ($RC).
|
|
5
|
-
* 2. Capture interaction events from the moment the shell is visible so the
|
|
6
|
-
* main bundle can replay them against un-hydrated subtrees ($RE_q buffer).
|
|
7
|
-
*
|
|
8
|
-
* Wire format:
|
|
9
|
-
* Fallback: <!--$?ID--><div id="B:ID">fallback</div><!--/$-->
|
|
10
|
-
* Resolved: emits <div hidden id="S:ID">real</div><script>$RC(ID)</script>
|
|
11
|
-
* which splices real into place and rewrites the comment to <!--$ID-->.
|
|
12
|
-
* The fallback div is visible (it's the user-visible loading
|
|
13
|
-
* state); only the resolved-content staging div is `hidden`
|
|
14
|
-
* before $RC moves its children inline.
|
|
15
|
-
*
|
|
16
|
-
* Client hydration calls $RH(ID, cb) to register a callback invoked once the
|
|
17
|
-
* boundary has been revealed (or immediately, if it was already revealed).
|
|
18
|
-
*
|
|
19
|
-
* Early-event buffering: before the main bundle is parsed, we attach capture
|
|
20
|
-
* listeners for a small set of interactive events and push them into a buffer.
|
|
21
|
-
* The bundle drains and replays them via the replay code in @tanstack/redact/dom.
|
|
22
|
-
*/
|
|
23
1
|
export declare const BOUNDARY_REVEAL_RUNTIME: string;
|
|
24
2
|
export declare function injectBootstrapScript(nonce?: string): string;
|
|
25
|
-
export declare function revealScript(id: number, nonce?: string): string;
|
|
3
|
+
export declare function revealScript(id: number, nonce?: string, styles?: string[][]): string;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
1
|
+
// src/server/bootstrap-script.ts
|
|
2
|
+
import { escapeAttr } from "./escape.js";
|
|
3
|
+
var BOUNDARY_REVEAL_RUNTIME = `(function(){var c={},r=new Map;function place(n,v){var a=document.head.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),t=a.length?a[a.length-1]:null,p=t;for(var k=0;k<a.length;k++){if(a[k].getAttribute("data-precedence")===v)p=a[k];else if(p!==t)break}document.head.insertBefore(n,p?p.nextSibling:document.head.firstChild);}function load(n,e){return new Promise(function(y,x){n.onload=function(){e.p=null;y()};n.onerror=function(){e.p=null;x()}})}window.$RH=function(i,f){if(!document.getElementById("B:"+i))f();else c[i]=f;};window.$RC=function(i){var s=document.getElementById("S:"+i),b=document.getElementById("B:"+i);if(!s||!b)return;var a=document.querySelectorAll('body link[rel="stylesheet"][data-precedence],body style[data-precedence]');for(var j=0;j<a.length;j++){var n=a[j];if(n.getAttribute("media")==="not all")n.removeAttribute("media");place(n,n.getAttribute("data-precedence"));}var p=b.parentNode,m=b.previousSibling;while(s.firstChild)p.insertBefore(s.firstChild,b);s.parentNode.removeChild(s);p.removeChild(b);if(m&&m.nodeType===8)m.data="$"+i;if(c[i]){var f=c[i];delete c[i];f()}};window.$RL=function(i,d){var w=[];for(var j=0;j<d.length;j++){var a=d[j],e=r.get(a[0]);if(!e){var n=null,l=document.querySelectorAll('link[rel="stylesheet"]');for(var k=0;k<l.length;k++)if(l[k].getAttribute("href")===a[0]){n=l[k];break}e={n:n,p:null};r.set(a[0],e);if(!n){n=e.n=document.createElement("link");n.rel="stylesheet";n.href=a[0];n.setAttribute("data-precedence",a[1]);for(var k=2;k<a.length;k+=2)n.setAttribute(a[k],a[k+1]);e.p=load(n,e);place(n,a[1]);}}var m=e.n.getAttribute("media");if(e.p&&(!m||matchMedia(m).matches))w.push(e.p);}Promise.all(w).then(function(){$RC(i)},function(){$RB(i,1)});};window.$RB=function(i,e){var b=document.getElementById("B:"+i);if(!b)return;var m=b.previousSibling;if(m&&m.nodeType===8)m.data=(e?"$E":"$!")+i;b.removeAttribute("id");if(c[i]){var f=c[i];delete c[i];f()}};var q=[];window.$RE_q=q;var evs=["click","submit","input","change","keydown"];function h(e){q.push([e.type,e.target,e.timeStamp])}for(var j=0;j<evs.length;j++)document.addEventListener(evs[j],h,true);window.$RE_stop=function(){for(var j=0;j<evs.length;j++)document.removeEventListener(evs[j],h,true)};})();`;
|
|
3
4
|
function injectBootstrapScript(nonce) {
|
|
4
|
-
const n = nonce ? ` nonce="${nonce}"` : "";
|
|
5
|
+
const n = nonce ? ` nonce="${escapeAttr(nonce)}"` : "";
|
|
5
6
|
return `<script${n}>${BOUNDARY_REVEAL_RUNTIME}<\/script>`;
|
|
6
7
|
}
|
|
7
|
-
function revealScript(id, nonce) {
|
|
8
|
-
const n = nonce ? ` nonce="${nonce}"` : "";
|
|
9
|
-
return `<script${n}>$RC(${id})<\/script>`;
|
|
8
|
+
function revealScript(id, nonce, styles) {
|
|
9
|
+
const n = nonce ? ` nonce="${escapeAttr(nonce)}"` : "";
|
|
10
|
+
return `<script${n}>${styles?.length ? `$RL(${id},${JSON.stringify(styles).replace(/</g, "\\u003c")})` : `$RC(${id})`}<\/script>`;
|
|
10
11
|
}
|
|
11
12
|
export {
|
|
12
13
|
BOUNDARY_REVEAL_RUNTIME,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/server/bootstrap-script.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Inline client runtime injected into the streamed HTML. Two jobs:\n *\n * 1. Reveal suspense boundaries as their resolved chunks arrive ($RC).\n * 2. Capture interaction events from the moment the shell is visible so the\n * main bundle can replay them against un-hydrated subtrees ($RE_q buffer).\n *\n * Wire format:\n * Fallback: <!--$?ID--><div id=\"B:ID\">fallback</div><!--/$-->\n * Resolved: emits <div hidden id=\"S:ID\">real</div><script>$RC(ID)</script>\n * which splices real into place and rewrites the comment to <!--$ID-->.\n * The fallback div is visible (it's the user-visible loading\n * state); only the resolved-content staging div is `hidden`\n * before $RC moves its children inline.\n *\n * Client hydration calls $RH(ID, cb) to register a callback invoked once the\n * boundary has been revealed (or immediately, if it was already revealed).\n *\n * Early-event buffering: before the main bundle is parsed, we attach capture\n * listeners for a small set of interactive events and push them into a buffer.\n * The bundle drains and replays them via the replay code in @tanstack/redact/dom.\n */\nexport const BOUNDARY_REVEAL_RUNTIME =\n `(function(){` +\n `var c={};` +\n `window.$RH=function(i,f){` +\n `if(!document.getElementById(\"B:\"+i))f();` +\n `else c[i]=f;` +\n `};` +\n `window.$RC=function(i){` +\n `var s=document.getElementById(\"S:\"+i),b=document.getElementById(\"B:\"+i);` +\n `if(!s||!b)return;` +\n `var p=b.parentNode,m=b.previousSibling;` +\n `while(s.firstChild)p.insertBefore(s.firstChild,b);` +\n `s.parentNode.removeChild(s);` +\n `p.removeChild(b);` +\n `if(m&&m.nodeType===8)m.data=\"$\"+i;` +\n `if(c[i]){var f=c[i];delete c[i];f()}` +\n `};` +\n `var q=[];window.$RE_q=q;` +\n `var evs=[\"click\",\"submit\",\"input\",\"change\",\"keydown\"];` +\n `function h(e){q.push([e.type,e.target,e.timeStamp])}` +\n `for(var j=0;j<evs.length;j++)document.addEventListener(evs[j],h,true);` +\n `window.$RE_stop=function(){for(var j=0;j<evs.length;j++)document.removeEventListener(evs[j],h,true)};` +\n `})();`\n\nexport function injectBootstrapScript(nonce?: string): string {\n const n = nonce ? ` nonce=\"${nonce}\"` : ''\n return `<script${n}>${BOUNDARY_REVEAL_RUNTIME}</script>`\n}\n\nexport function revealScript(id: number, nonce?: string): string {\n const n = nonce ? ` nonce=\"${nonce}\"` : ''\n return `<script${n}>$RC(${id})</script>`\n}\n"],
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["/**\n * Inline client runtime injected into the streamed HTML. Two jobs:\n *\n * 1. Reveal suspense boundaries as their resolved chunks arrive ($RC).\n * 2. Capture interaction events from the moment the shell is visible so the\n * main bundle can replay them against un-hydrated subtrees ($RE_q buffer).\n *\n * Wire format:\n * Fallback: <!--$?ID--><div id=\"B:ID\">fallback</div><!--/$-->\n * Resolved: emits <div hidden id=\"S:ID\">real</div><script>$RC(ID)</script>\n * which splices real into place and rewrites the comment to <!--$ID-->.\n * The fallback div is visible (it's the user-visible loading\n * state); only the resolved-content staging div is `hidden`\n * before $RC moves its children inline.\n *\n * Client hydration calls $RH(ID, cb) to register a callback invoked once the\n * boundary has been revealed (or immediately, if it was already revealed).\n *\n * Early-event buffering: before the main bundle is parsed, we attach capture\n * listeners for a small set of interactive events and push them into a buffer.\n * The bundle drains and replays them via the replay code in @tanstack/redact/dom.\n */\nimport { escapeAttr } from './escape'\n\nexport const BOUNDARY_REVEAL_RUNTIME =\n `(function(){` +\n `var c={},r=new Map;` +\n `function place(n,v){` +\n `var a=document.head.querySelectorAll('link[rel=\"stylesheet\"][data-precedence],style[data-precedence]'),t=a.length?a[a.length-1]:null,p=t;` +\n `for(var k=0;k<a.length;k++){if(a[k].getAttribute(\"data-precedence\")===v)p=a[k];else if(p!==t)break}` +\n `document.head.insertBefore(n,p?p.nextSibling:document.head.firstChild);` +\n `}` +\n `function load(n,e){return new Promise(function(y,x){n.onload=function(){e.p=null;y()};n.onerror=function(){e.p=null;x()}})}` +\n `window.$RH=function(i,f){` +\n `if(!document.getElementById(\"B:\"+i))f();` +\n `else c[i]=f;` +\n `};` +\n `window.$RC=function(i){` +\n `var s=document.getElementById(\"S:\"+i),b=document.getElementById(\"B:\"+i);` +\n `if(!s||!b)return;` +\n `var a=document.querySelectorAll('body link[rel=\"stylesheet\"][data-precedence],body style[data-precedence]');` +\n `for(var j=0;j<a.length;j++){` +\n `var n=a[j];if(n.getAttribute(\"media\")===\"not all\")n.removeAttribute(\"media\");place(n,n.getAttribute(\"data-precedence\"));` +\n `}` +\n `var p=b.parentNode,m=b.previousSibling;` +\n `while(s.firstChild)p.insertBefore(s.firstChild,b);` +\n `s.parentNode.removeChild(s);` +\n `p.removeChild(b);` +\n `if(m&&m.nodeType===8)m.data=\"$\"+i;` +\n `if(c[i]){var f=c[i];delete c[i];f()}` +\n `};` +\n `window.$RL=function(i,d){` +\n `var w=[];for(var j=0;j<d.length;j++){` +\n `var a=d[j],e=r.get(a[0]);if(!e){` +\n `var n=null,l=document.querySelectorAll('link[rel=\"stylesheet\"]');for(var k=0;k<l.length;k++)if(l[k].getAttribute(\"href\")===a[0]){n=l[k];break}` +\n `e={n:n,p:null};r.set(a[0],e);if(!n){` +\n `n=e.n=document.createElement(\"link\");n.rel=\"stylesheet\";n.href=a[0];n.setAttribute(\"data-precedence\",a[1]);` +\n `for(var k=2;k<a.length;k+=2)n.setAttribute(a[k],a[k+1]);` +\n `e.p=load(n,e);place(n,a[1]);` +\n `}` +\n `}` +\n `var m=e.n.getAttribute(\"media\");if(e.p&&(!m||matchMedia(m).matches))w.push(e.p);` +\n `}` +\n `Promise.all(w).then(function(){$RC(i)},function(){$RB(i,1)});` +\n `};` +\n `window.$RB=function(i,e){` +\n `var b=document.getElementById(\"B:\"+i);if(!b)return;` +\n `var m=b.previousSibling;if(m&&m.nodeType===8)m.data=(e?\"$E\":\"$!\")+i;` +\n `b.removeAttribute(\"id\");if(c[i]){var f=c[i];delete c[i];f()}` +\n `};` +\n `var q=[];window.$RE_q=q;` +\n `var evs=[\"click\",\"submit\",\"input\",\"change\",\"keydown\"];` +\n `function h(e){q.push([e.type,e.target,e.timeStamp])}` +\n `for(var j=0;j<evs.length;j++)document.addEventListener(evs[j],h,true);` +\n `window.$RE_stop=function(){for(var j=0;j<evs.length;j++)document.removeEventListener(evs[j],h,true)};` +\n `})();`\n\nexport function injectBootstrapScript(nonce?: string): string {\n const n = nonce ? ` nonce=\"${escapeAttr(nonce)}\"` : ''\n return `<script${n}>${BOUNDARY_REVEAL_RUNTIME}</script>`\n}\n\nexport function revealScript(id: number, nonce?: string, styles?: string[][]): string {\n const n = nonce ? ` nonce=\"${escapeAttr(nonce)}\"` : ''\n return `<script${n}>${styles?.length ? `$RL(${id},${JSON.stringify(styles).replace(/</g, '\\\\u003c')})` : `$RC(${id})`}</script>`\n}\n"],
|
|
5
|
+
"mappings": ";AAsBA,SAAS,kBAAkB;AAEpB,IAAM,0BACX;AAoDK,SAAS,sBAAsB,OAAwB;AAC5D,QAAM,IAAI,QAAQ,WAAW,WAAW,KAAK,CAAC,MAAM;AACpD,SAAO,UAAU,CAAC,IAAI,uBAAuB;AAC/C;AAEO,SAAS,aAAa,IAAY,OAAgB,QAA6B;AACpF,QAAM,IAAI,QAAQ,WAAW,WAAW,KAAK,CAAC,MAAM;AACpD,SAAO,UAAU,CAAC,IAAI,QAAQ,SAAS,OAAO,EAAE,IAAI,KAAK,UAAU,MAAM,EAAE,QAAQ,MAAM,SAAS,CAAC,MAAM,OAAO,EAAE,GAAG;AACvH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
1
|
+
import { createResourceHints, type ResourceScope } from "./resource-hints.js";
|
|
2
|
+
export interface SSRFrame {
|
|
3
|
+
idCounter: number;
|
|
4
|
+
identifierPrefix: string;
|
|
5
|
+
contextStack: Array<{
|
|
6
|
+
context: any;
|
|
7
|
+
prev: any;
|
|
8
|
+
}>;
|
|
9
|
+
resources?: ReturnType<typeof createResourceHints>;
|
|
10
|
+
shellFlushed?: boolean;
|
|
11
|
+
styleNonce?: string | undefined;
|
|
12
|
+
}
|
|
13
|
+
export declare function beginSSR(identifierPrefix?: string, nextFrame?: SSRFrame): {
|
|
14
|
+
frame: SSRFrame;
|
|
15
|
+
dispatcher: import("../react/shared-internals.js").Dispatcher;
|
|
16
|
+
};
|
|
17
|
+
export declare function currentSSRFrame(): SSRFrame;
|
|
18
|
+
export declare function recordHostResource(type: string, props: any, scope?: ResourceScope): boolean;
|
|
19
|
+
export declare function endSSR(previous?: ReturnType<typeof beginSSR>): void;
|
|
3
20
|
export declare function pushContext(context: any, value: any): void;
|
|
4
21
|
export declare function popContext(context: any): void;
|
|
5
22
|
export type ContextSnapshot = Array<{
|
|
@@ -14,7 +31,11 @@ export declare function snapshotContexts(): ContextSnapshot;
|
|
|
14
31
|
*/
|
|
15
32
|
export declare function applyContextSnapshot(snapshot: ContextSnapshot): () => void;
|
|
16
33
|
export declare const ssrDispatcher: {
|
|
17
|
-
|
|
34
|
+
useCacheRefresh(): () => never;
|
|
35
|
+
useState<S>(initial: S | (() => S)): [
|
|
36
|
+
S,
|
|
37
|
+
any
|
|
38
|
+
];
|
|
18
39
|
useReducer<S, A>(_reducer: (s: S, a: A) => S, initialArg: any, init?: (a: any) => S): any[];
|
|
19
40
|
useEffect(): void;
|
|
20
41
|
useLayoutEffect(): void;
|
|
@@ -28,10 +49,11 @@ export declare const ssrDispatcher: {
|
|
|
28
49
|
useImperativeHandle(): void;
|
|
29
50
|
useDebugValue(): void;
|
|
30
51
|
useId(): string;
|
|
31
|
-
useTransition(): [
|
|
52
|
+
useTransition(): [
|
|
53
|
+
boolean,
|
|
54
|
+
(fn: () => void) => void
|
|
55
|
+
];
|
|
32
56
|
useDeferredValue<T>(v: T): T;
|
|
33
57
|
useSyncExternalStore<T>(_subscribe: (cb: () => void) => () => void, getSnapshot: () => T, getServerSnapshot?: () => T): T;
|
|
34
58
|
use<T>(resource: any): T;
|
|
35
59
|
};
|
|
36
|
-
export declare function installSSRDispatcher(): void;
|
|
37
|
-
export declare function uninstallSSRDispatcher(): void;
|
|
@@ -1,17 +1,35 @@
|
|
|
1
|
-
//
|
|
2
|
-
import { ReactSharedInternals, REACT_CONTEXT_TYPE } from "../react";
|
|
1
|
+
// src/server/dispatcher.ts
|
|
2
|
+
import { ReactSharedInternals, REACT_CONTEXT_TYPE } from "../react/index.js";
|
|
3
|
+
import { isBrowserToken, browserError } from "../core/browser.js";
|
|
4
|
+
import { resourceHintDispatcher } from "../core/resource-hints.js";
|
|
5
|
+
import { createResourceHints } from "./resource-hints.js";
|
|
3
6
|
var frame = null;
|
|
4
|
-
|
|
5
|
-
frame
|
|
7
|
+
resourceHintDispatcher.emit = (kind, href, options) => {
|
|
8
|
+
if (!frame) return false;
|
|
9
|
+
(frame.resources ||= createResourceHints(!!frame.shellFlushed, frame.styleNonce)).add(kind, href, options);
|
|
10
|
+
return true;
|
|
11
|
+
};
|
|
12
|
+
function beginSSR(identifierPrefix = ":R", nextFrame) {
|
|
13
|
+
const previous = { frame, dispatcher: ReactSharedInternals.H };
|
|
14
|
+
frame = nextFrame ?? { idCounter: 0, identifierPrefix, contextStack: [] };
|
|
15
|
+
ReactSharedInternals.H = ssrDispatcher;
|
|
16
|
+
return previous;
|
|
17
|
+
}
|
|
18
|
+
function currentSSRFrame() {
|
|
19
|
+
return frame;
|
|
20
|
+
}
|
|
21
|
+
function recordHostResource(type, props, scope) {
|
|
22
|
+
return !!frame && (frame.resources ||= createResourceHints(!!frame.shellFlushed, frame.styleNonce)).addHost(type, props, scope);
|
|
6
23
|
}
|
|
7
|
-
function endSSR() {
|
|
24
|
+
function endSSR(previous) {
|
|
8
25
|
if (frame) {
|
|
9
26
|
for (let i = frame.contextStack.length - 1; i >= 0; i--) {
|
|
10
27
|
const { context, prev } = frame.contextStack[i];
|
|
11
28
|
context._currentValue = prev;
|
|
12
29
|
}
|
|
13
30
|
}
|
|
14
|
-
|
|
31
|
+
ReactSharedInternals.H = previous?.dispatcher ?? null;
|
|
32
|
+
frame = previous?.frame ?? null;
|
|
15
33
|
}
|
|
16
34
|
function pushContext(context, value) {
|
|
17
35
|
if (!frame) throw new Error("pushContext called outside SSR");
|
|
@@ -38,6 +56,11 @@ function applyContextSnapshot(snapshot) {
|
|
|
38
56
|
};
|
|
39
57
|
}
|
|
40
58
|
var ssrDispatcher = {
|
|
59
|
+
useCacheRefresh() {
|
|
60
|
+
return () => {
|
|
61
|
+
throw new Error("Refreshing the cache is not supported during server rendering.");
|
|
62
|
+
};
|
|
63
|
+
},
|
|
41
64
|
useState(initial) {
|
|
42
65
|
const v = typeof initial === "function" ? initial() : initial;
|
|
43
66
|
return [v, (() => {
|
|
@@ -85,6 +108,7 @@ var ssrDispatcher = {
|
|
|
85
108
|
},
|
|
86
109
|
use(resource) {
|
|
87
110
|
if (resource == null) throw new Error("use() received null or undefined");
|
|
111
|
+
if (isBrowserToken(resource)) throw browserError(resource);
|
|
88
112
|
if (resource.$$typeof === REACT_CONTEXT_TYPE) {
|
|
89
113
|
return resource._currentValue;
|
|
90
114
|
}
|
|
@@ -120,21 +144,15 @@ var ssrDispatcher = {
|
|
|
120
144
|
throw new Error("use() expected a Promise or Context");
|
|
121
145
|
}
|
|
122
146
|
};
|
|
123
|
-
function installSSRDispatcher() {
|
|
124
|
-
ReactSharedInternals.H = ssrDispatcher;
|
|
125
|
-
}
|
|
126
|
-
function uninstallSSRDispatcher() {
|
|
127
|
-
ReactSharedInternals.H = null;
|
|
128
|
-
}
|
|
129
147
|
export {
|
|
130
148
|
applyContextSnapshot,
|
|
131
149
|
beginSSR,
|
|
150
|
+
currentSSRFrame,
|
|
132
151
|
endSSR,
|
|
133
|
-
installSSRDispatcher,
|
|
134
152
|
popContext,
|
|
135
153
|
pushContext,
|
|
154
|
+
recordHostResource,
|
|
136
155
|
snapshotContexts,
|
|
137
|
-
ssrDispatcher
|
|
138
|
-
uninstallSSRDispatcher
|
|
156
|
+
ssrDispatcher
|
|
139
157
|
};
|
|
140
158
|
//# sourceMappingURL=dispatcher.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/server/dispatcher.ts"],
|
|
4
|
-
"sourcesContent": ["import { ReactSharedInternals, REACT_CONTEXT_TYPE } from '../react'\n\
|
|
5
|
-
"mappings": ";AAAA,SAAS,sBAAsB,0BAA0B;
|
|
4
|
+
"sourcesContent": ["import { ReactSharedInternals, REACT_CONTEXT_TYPE } from '../react'\nimport { isBrowserToken, browserError } from '../core/browser'\nimport { resourceHintDispatcher } from '../core/resource-hints'\nimport { createResourceHints, type ResourceScope } from './resource-hints'\n\nexport interface SSRFrame {\n idCounter: number\n identifierPrefix: string\n contextStack: Array<{ context: any; prev: any }>\n resources?: ReturnType<typeof createResourceHints>\n shellFlushed?: boolean\n styleNonce?: string | undefined\n}\n\nlet frame: SSRFrame | null = null\n\nresourceHintDispatcher.emit = (kind, href, options) => {\n if (!frame) return false\n ;(frame.resources ||= createResourceHints(!!frame.shellFlushed, frame.styleNonce)).add(kind, href, options)\n return true\n}\n\nexport function beginSSR(identifierPrefix = ':R', nextFrame?: SSRFrame) {\n const previous = { frame, dispatcher: ReactSharedInternals.H }\n frame = nextFrame ?? { idCounter: 0, identifierPrefix, contextStack: [] }\n ReactSharedInternals.H = ssrDispatcher as any\n return previous\n}\n\nexport function currentSSRFrame(): SSRFrame {\n return frame!\n}\n\nexport function recordHostResource(type: string, props: any, scope?: ResourceScope): boolean {\n return !!frame && (frame.resources ||= createResourceHints(!!frame.shellFlushed, frame.styleNonce)).addHost(type, props, scope)\n}\n\nexport function endSSR(previous?: ReturnType<typeof beginSSR>): void {\n // Restore any remaining pushed contexts (defensive)\n if (frame) {\n for (let i = frame.contextStack.length - 1; i >= 0; i--) {\n const { context, prev } = frame.contextStack[i]!\n context._currentValue = prev\n }\n }\n // Only synchronous renders restore their caller. A stream can finish\n // after its caller has returned, so it must not reinstall that dispatcher.\n ReactSharedInternals.H = previous?.dispatcher ?? null\n frame = previous?.frame ?? null\n}\n\nexport function pushContext(context: any, value: any): void {\n if (!frame) throw new Error('pushContext called outside SSR')\n frame.contextStack.push({ context, prev: context._currentValue })\n context._currentValue = value\n}\n\nexport function popContext(context: any): void {\n if (!frame) return\n const top = frame.contextStack.pop()\n if (top && top.context === context) context._currentValue = top.prev\n}\n\nexport type ContextSnapshot = Array<{ context: any; value: any }>\n\nexport function snapshotContexts(): ContextSnapshot {\n if (!frame) return []\n const out: ContextSnapshot = []\n for (const entry of frame.contextStack) {\n out.push({ context: entry.context, value: entry.context._currentValue })\n }\n return out\n}\n\n/**\n * Push snapshot values and return a function that pops them.\n * Called when we re-render a suspended boundary so it sees the same provider\n * values that were active at suspension time.\n */\nexport function applyContextSnapshot(snapshot: ContextSnapshot): () => void {\n for (const { context, value } of snapshot) pushContext(context, value)\n return () => {\n for (let i = snapshot.length - 1; i >= 0; i--) popContext(snapshot[i]!.context)\n }\n}\n\nexport const ssrDispatcher = {\n useCacheRefresh() {\n return () => { throw new Error('Refreshing the cache is not supported during server rendering.') }\n },\n useState<S>(initial: S | (() => S)) {\n const v = typeof initial === 'function' ? (initial as () => S)() : initial\n return [v, (() => {}) as any] as [S, any]\n },\n useReducer<S, A>(_reducer: (s: S, a: A) => S, initialArg: any, init?: (a: any) => S) {\n const v = init ? init(initialArg) : initialArg\n return [v, (() => {}) as any]\n },\n useEffect() {\n // noop on server\n },\n useLayoutEffect() {\n // noop on server\n },\n useInsertionEffect() {\n // noop on server\n },\n useRef<T>(initial: T) {\n return { current: initial }\n },\n useMemo<T>(factory: () => T) {\n return factory()\n },\n useCallback<T extends Function>(fn: T) {\n return fn\n },\n useContext<T>(ctx: any): T {\n return ctx._currentValue\n },\n useImperativeHandle() {\n // noop on server\n },\n useDebugValue() {\n // noop\n },\n useId(): string {\n if (!frame) return ':r0:'\n return `${frame.identifierPrefix}${(frame.idCounter++).toString(36)}`\n },\n useTransition(): [boolean, (fn: () => void) => void] {\n return [false, (fn) => fn()]\n },\n useDeferredValue<T>(v: T): T {\n return v\n },\n useSyncExternalStore<T>(\n _subscribe: (cb: () => void) => () => void,\n getSnapshot: () => T,\n getServerSnapshot?: () => T,\n ): T {\n return getServerSnapshot ? getServerSnapshot() : getSnapshot()\n },\n use<T>(resource: any): T {\n if (resource == null) throw new Error('use() received null or undefined')\n if (isBrowserToken(resource)) throw browserError(resource)\n if (resource.$$typeof === REACT_CONTEXT_TYPE) {\n return resource._currentValue\n }\n if (typeof resource.then === 'function') {\n const thenable = resource\n switch (thenable.status) {\n case 'fulfilled':\n return thenable.value\n case 'rejected':\n throw thenable.reason\n default: {\n if (thenable.status === undefined) {\n thenable.status = 'pending'\n thenable.then(\n (v: any) => {\n if (thenable.status === 'pending') {\n thenable.status = 'fulfilled'\n thenable.value = v\n }\n },\n (e: any) => {\n if (thenable.status === 'pending') {\n thenable.status = 'rejected'\n thenable.reason = e\n }\n },\n )\n }\n throw thenable\n }\n }\n }\n throw new Error('use() expected a Promise or Context')\n },\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,sBAAsB,0BAA0B;AACzD,SAAS,gBAAgB,oBAAoB;AAC7C,SAAS,8BAA8B;AACvC,SAAS,2BAA+C;AAWxD,IAAI,QAAyB;AAE7B,uBAAuB,OAAO,CAAC,MAAM,MAAM,YAAY;AACrD,MAAI,CAAC,MAAO,QAAO;AAClB,GAAC,MAAM,cAAc,oBAAoB,CAAC,CAAC,MAAM,cAAc,MAAM,UAAU,GAAG,IAAI,MAAM,MAAM,OAAO;AAC1G,SAAO;AACT;AAEO,SAAS,SAAS,mBAAmB,MAAM,WAAsB;AACtE,QAAM,WAAW,EAAE,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;AAAA,EACA,IAAO,UAAkB;AACvB,QAAI,YAAY,KAAM,OAAM,IAAI,MAAM,kCAAkC;AACxE,QAAI,eAAe,QAAQ,EAAG,OAAM,aAAa,QAAQ;AACzD,QAAI,SAAS,aAAa,oBAAoB;AAC5C,aAAO,SAAS;AAAA,IAClB;AACA,QAAI,OAAO,SAAS,SAAS,YAAY;AACvC,YAAM,WAAW;AACjB,cAAQ,SAAS,QAAQ;AAAA,QACvB,KAAK;AACH,iBAAO,SAAS;AAAA,QAClB,KAAK;AACH,gBAAM,SAAS;AAAA,QACjB,SAAS;AACP,cAAI,SAAS,WAAW,QAAW;AACjC,qBAAS,SAAS;AAClB,qBAAS;AAAA,cACP,CAAC,MAAW;AACV,oBAAI,SAAS,WAAW,WAAW;AACjC,2BAAS,SAAS;AAClB,2BAAS,QAAQ;AAAA,gBACnB;AAAA,cACF;AAAA,cACA,CAAC,MAAW;AACV,oBAAI,SAAS,WAAW,WAAW;AACjC,2BAAS,SAAS;AAClB,2BAAS,SAAS;AAAA,gBACpB;AAAA,cACF;AAAA,YACF;AAAA,UACF;AACA,gBAAM;AAAA,QACR;AAAA,MACF;AAAA,IACF;AACA,UAAM,IAAI,MAAM,qCAAqC;AAAA,EACvD;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/server/escape.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
//
|
|
2
|
-
import { attributeName, STRING_BOOLEAN_ATTRS } from "../core/attributes";
|
|
3
|
-
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
1
|
+
// src/server/escape.ts
|
|
2
|
+
import { attributeName, STRING_BOOLEAN_ATTRS } from "../core/attributes.js";
|
|
3
|
+
function escape(value, pattern) {
|
|
4
|
+
let out = "";
|
|
5
|
+
let start = 0;
|
|
6
|
+
while (pattern.test(value)) {
|
|
7
|
+
const end = pattern.lastIndex;
|
|
8
|
+
const char = value[end - 1];
|
|
9
|
+
out += value.slice(start, end - 1) + (char === "&" ? "&" : char === "<" ? "<" : char === ">" ? ">" : """);
|
|
10
|
+
start = end;
|
|
11
|
+
}
|
|
12
|
+
return out + value.slice(start);
|
|
13
|
+
}
|
|
14
14
|
function escapeAttr(value) {
|
|
15
|
-
return value
|
|
15
|
+
return /[&"<>]/.test(value) ? escape(value, /[&"<>]/g) : value;
|
|
16
16
|
}
|
|
17
17
|
function escapeText(value) {
|
|
18
|
-
return value
|
|
18
|
+
return /[&<>]/.test(value) ? escape(value, /[&<>]/g) : value;
|
|
19
19
|
}
|
|
20
20
|
function escapeScript(value) {
|
|
21
21
|
return value.replace(/<\/(script|style)/gi, "<\\/$1").replace(/<!--/g, "<\\!--");
|
|
@@ -44,6 +44,7 @@ var BOOLEAN_ATTRS = /* @__PURE__ */ new Set([
|
|
|
44
44
|
"autoplay",
|
|
45
45
|
"checked",
|
|
46
46
|
"controls",
|
|
47
|
+
"credentialless",
|
|
47
48
|
"default",
|
|
48
49
|
"defer",
|
|
49
50
|
"disabled",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/server/escape.ts"],
|
|
4
|
-
"sourcesContent": ["import { attributeName, STRING_BOOLEAN_ATTRS } from '../core/attributes'\n\
|
|
5
|
-
"mappings": ";AAAA,SAAS,eAAe,4BAA4B;AAEpD,
|
|
4
|
+
"sourcesContent": ["import { attributeName, STRING_BOOLEAN_ATTRS } from '../core/attributes'\n\nfunction escape(value: string, pattern: RegExp): string {\n let out = ''\n let start = 0\n while (pattern.test(value)) {\n const end = pattern.lastIndex\n const char = value[end - 1]\n out += value.slice(start, end - 1) + (\n char === '&' ? '&' : char === '<' ? '<' : char === '>' ? '>' : '"'\n )\n start = end\n }\n return out + value.slice(start)\n}\n\nexport function escapeAttr(value: string): string {\n return /[&\"<>]/.test(value) ? escape(value, /[&\"<>]/g) : value\n}\n\nexport function escapeText(value: string): string {\n return /[&<>]/.test(value) ? escape(value, /[&<>]/g) : value\n}\n\n// Raw-text element body escaping: prevent any closing tag for the raw-text\n// elements (<script>, <style>) from terminating the element early, plus\n// `<!--` (which would start an HTML comment that survives even inside\n// raw-text bodies and can be exploited to alter following script content).\n// React's serializer follows the same approach.\nexport function escapeScript(value: string): string {\n return value\n .replace(/<\\/(script|style)/gi, '<\\\\/$1')\n .replace(/<!--/g, '<\\\\!--')\n}\n\nexport const VOID_ELEMENTS = new Set([\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr',\n])\n\nexport const RAW_TEXT_ELEMENTS = new Set(['script', 'style'])\n\nconst BOOLEAN_ATTRS = new Set([\n 'allowfullscreen',\n 'async',\n 'autofocus',\n 'autoplay',\n 'checked',\n 'controls',\n 'credentialless',\n 'default',\n 'defer',\n 'disabled',\n 'formnovalidate',\n 'hidden',\n 'inert',\n 'ismap',\n 'itemscope',\n 'loop',\n 'multiple',\n 'muted',\n 'nomodule',\n 'novalidate',\n 'open',\n 'playsinline',\n 'readonly',\n 'required',\n 'reversed',\n 'selected',\n])\n\nexport function attrToHtml(name: string, value: unknown, isSvg = false): string {\n if (\n name === 'children' ||\n name === 'key' ||\n name === 'ref' ||\n name === 'dangerouslySetInnerHTML' ||\n name === 'defaultValue' ||\n name === 'defaultChecked' ||\n name === 'suppressHydrationWarning' ||\n name === 'suppressContentEditableWarning'\n ) {\n return ''\n }\n if (name[0] === 'o' && name[1] === 'n' && typeof value === 'function') return ''\n if (value == null) return ''\n\n const htmlName = attributeName(name, isSvg)\n\n // These attributes need explicit \"false\", not boolean-attribute absence.\n if (\n STRING_BOOLEAN_ATTRS.has(htmlName) ||\n name.startsWith('aria-') ||\n name.startsWith('data-')\n ) {\n return ` ${htmlName}=\"${escapeAttr(String(value))}\"`\n }\n\n if (value === false) return ''\n\n if (value === true || BOOLEAN_ATTRS.has(htmlName)) {\n return value ? ` ${htmlName}=\"\"` : ''\n }\n\n if (name === 'style' && typeof value === 'object' && value !== null) {\n return ` style=\"${escapeAttr(styleToString(value as Record<string, unknown>))}\"`\n }\n\n return ` ${htmlName}=\"${escapeAttr(String(value))}\"`\n}\n\nconst UNITLESS_STYLE = new Set([\n 'animationIterationCount',\n 'borderImageOutset',\n 'borderImageSlice',\n 'borderImageWidth',\n 'boxFlex',\n 'boxFlexGroup',\n 'boxOrdinalGroup',\n 'columnCount',\n 'columns',\n 'flex',\n 'flexGrow',\n 'flexPositive',\n 'flexShrink',\n 'flexNegative',\n 'flexOrder',\n 'gridArea',\n 'gridRow',\n 'gridRowEnd',\n 'gridRowSpan',\n 'gridRowStart',\n 'gridColumn',\n 'gridColumnEnd',\n 'gridColumnSpan',\n 'gridColumnStart',\n 'fontWeight',\n 'lineClamp',\n 'lineHeight',\n 'opacity',\n 'order',\n 'orphans',\n 'tabSize',\n 'widows',\n 'zIndex',\n 'zoom',\n 'fillOpacity',\n 'floodOpacity',\n 'stopOpacity',\n 'strokeDasharray',\n 'strokeDashoffset',\n 'strokeMiterlimit',\n 'strokeOpacity',\n 'strokeWidth',\n])\n\nfunction styleToString(style: Record<string, unknown>): string {\n let out = ''\n for (const key in style) {\n const v = style[key]\n if (v == null || v === false) continue\n const kebab = key.startsWith('--')\n ? key\n : key.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase())\n const value =\n typeof v === 'number' && !UNITLESS_STYLE.has(key) && v !== 0 ? v + 'px' : v\n out += `${kebab}:${value};`\n }\n return out\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,eAAe,4BAA4B;AAEpD,SAAS,OAAO,OAAe,SAAyB;AACtD,MAAI,MAAM;AACV,MAAI,QAAQ;AACZ,SAAO,QAAQ,KAAK,KAAK,GAAG;AAC1B,UAAM,MAAM,QAAQ;AACpB,UAAM,OAAO,MAAM,MAAM,CAAC;AAC1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M,MAAO;AAC9B,UAAM,QAAQ,IAAI,WAAW,IAAI,IAC7B,MACA,IAAI,QAAQ,UAAU,CAAC,MAAM,MAAM,EAAE,YAAY,CAAC;AACtD,UAAM,QACJ,OAAO,MAAM,YAAY,CAAC,eAAe,IAAI,GAAG,KAAK,MAAM,IAAI,IAAI,OAAO;AAC5E,WAAO,GAAG,KAAK,IAAI,KAAK;AAAA,EAC1B;AACA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { renderToString, renderToStaticMarkup } from
|
|
2
|
-
export { renderToReadableStream, renderToPipeableStream } from
|
|
3
|
-
export type { StreamOptions, PipeableOptions, PipeableHandle, ReadableStreamResult, } from
|
|
4
|
-
export { BOUNDARY_REVEAL_RUNTIME } from
|
|
1
|
+
export { renderToString, renderToStaticMarkup } from "./renderToString.js";
|
|
2
|
+
export { renderToReadableStream, renderToPipeableStream } from "./stream.js";
|
|
3
|
+
export type { StreamOptions, PipeableOptions, PipeableHandle, ReadableStreamResult, } from "./stream.js";
|
|
4
|
+
export { BOUNDARY_REVEAL_RUNTIME } from "./bootstrap-script.js";
|
|
5
5
|
export declare const version = "19.2.3";
|
|
6
|
-
import { renderToString, renderToStaticMarkup } from
|
|
7
|
-
import { renderToReadableStream, renderToPipeableStream } from
|
|
6
|
+
import { renderToString, renderToStaticMarkup } from "./renderToString.js";
|
|
7
|
+
import { renderToReadableStream, renderToPipeableStream } from "./stream.js";
|
|
8
8
|
declare const _default: {
|
|
9
9
|
renderToString: typeof renderToString;
|
|
10
10
|
renderToStaticMarkup: typeof renderToStaticMarkup;
|
package/dist/server/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
//
|
|
2
|
-
import { renderToString, renderToStaticMarkup } from "./renderToString";
|
|
3
|
-
import { renderToReadableStream, renderToPipeableStream } from "./stream";
|
|
4
|
-
import { BOUNDARY_REVEAL_RUNTIME } from "./bootstrap-script";
|
|
5
|
-
import { renderToString as renderToString2, renderToStaticMarkup as renderToStaticMarkup2 } from "./renderToString";
|
|
6
|
-
import { renderToReadableStream as renderToReadableStream2, renderToPipeableStream as renderToPipeableStream2 } from "./stream";
|
|
7
|
-
import { BOUNDARY_REVEAL_RUNTIME as BOUNDARY_REVEAL_RUNTIME2 } from "./bootstrap-script";
|
|
1
|
+
// src/server/index.ts
|
|
2
|
+
import { renderToString, renderToStaticMarkup } from "./renderToString.js";
|
|
3
|
+
import { renderToReadableStream, renderToPipeableStream } from "./stream.js";
|
|
4
|
+
import { BOUNDARY_REVEAL_RUNTIME } from "./bootstrap-script.js";
|
|
5
|
+
import { renderToString as renderToString2, renderToStaticMarkup as renderToStaticMarkup2 } from "./renderToString.js";
|
|
6
|
+
import { renderToReadableStream as renderToReadableStream2, renderToPipeableStream as renderToPipeableStream2 } from "./stream.js";
|
|
7
|
+
import { BOUNDARY_REVEAL_RUNTIME as BOUNDARY_REVEAL_RUNTIME2 } from "./bootstrap-script.js";
|
|
8
8
|
var version = "19.2.3";
|
|
9
9
|
var server_default = {
|
|
10
10
|
renderToString: renderToString2,
|
|
@@ -1,21 +1,25 @@
|
|
|
1
|
-
//
|
|
2
|
-
import { beginSSR,
|
|
3
|
-
import { walk } from "./walk";
|
|
1
|
+
// src/server/renderToString.ts
|
|
2
|
+
import { beginSSR, currentSSRFrame, endSSR } from "./dispatcher.js";
|
|
3
|
+
import { walk } from "./walk.js";
|
|
4
4
|
function renderToString(children, options = {}) {
|
|
5
|
-
|
|
6
|
-
beginSSR(options.identifierPrefix);
|
|
5
|
+
const previous = beginSSR(options.identifierPrefix);
|
|
7
6
|
let output = "";
|
|
8
7
|
let id = 0;
|
|
8
|
+
let head = 0;
|
|
9
9
|
try {
|
|
10
10
|
walk(children, {
|
|
11
11
|
emit: (s) => {
|
|
12
12
|
output += s;
|
|
13
13
|
},
|
|
14
|
-
nextBoundaryId: () => id
|
|
14
|
+
nextBoundaryId: () => id++,
|
|
15
|
+
onHead: () => {
|
|
16
|
+
head = output.length;
|
|
17
|
+
}
|
|
15
18
|
});
|
|
19
|
+
const hints = currentSSRFrame().resources?.drain();
|
|
20
|
+
if (hints) output = output.slice(0, head) + hints + output.slice(head);
|
|
16
21
|
} finally {
|
|
17
|
-
endSSR();
|
|
18
|
-
uninstallSSRDispatcher();
|
|
22
|
+
endSSR(previous);
|
|
19
23
|
}
|
|
20
24
|
return output;
|
|
21
25
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/server/renderToString.ts"],
|
|
4
|
-
"sourcesContent": ["import type { ReactNode } from '../core'\nimport { beginSSR,
|
|
5
|
-
"mappings": ";AACA,SAAS,UAAU,
|
|
4
|
+
"sourcesContent": ["import type { ReactNode } from '../core'\nimport { beginSSR, currentSSRFrame, endSSR } from './dispatcher'\nimport { walk } from './walk'\n\nexport function renderToString(\n children: ReactNode,\n options: { identifierPrefix?: string } = {},\n): string {\n const previous = beginSSR(options.identifierPrefix)\n let output = ''\n let id = 0\n let head = 0\n try {\n walk(children, {\n emit: (s) => {\n output += s\n },\n nextBoundaryId: () => id++,\n onHead: () => { head = output.length },\n })\n const hints = currentSSRFrame().resources?.drain()\n if (hints) output = output.slice(0, head) + hints + output.slice(head)\n } finally {\n endSSR(previous)\n }\n return output\n}\n\nexport function renderToStaticMarkup(\n children: ReactNode,\n options: { identifierPrefix?: string } = {},\n): string {\n // For our purposes identical to renderToString (no hydration markers in static output)\n return renderToString(children, options).replace(/<!--[^>]*-->/g, '')\n}\n"],
|
|
5
|
+
"mappings": ";AACA,SAAS,UAAU,iBAAiB,cAAc;AAClD,SAAS,YAAY;AAEd,SAAS,eACd,UACA,UAAyC,CAAC,GAClC;AACR,QAAM,WAAW,SAAS,QAAQ,gBAAgB;AAClD,MAAI,SAAS;AACb,MAAI,KAAK;AACT,MAAI,OAAO;AACX,MAAI;AACF,SAAK,UAAU;AAAA,MACb,MAAM,CAAC,MAAM;AACX,kBAAU;AAAA,MACZ;AAAA,MACA,gBAAgB,MAAM;AAAA,MACtB,QAAQ,MAAM;AAAE,eAAO,OAAO;AAAA,MAAO;AAAA,IACvC,CAAC;AACD,UAAM,QAAQ,gBAAgB,EAAE,WAAW,MAAM;AACjD,QAAI,MAAO,UAAS,OAAO,MAAM,GAAG,IAAI,IAAI,QAAQ,OAAO,MAAM,IAAI;AAAA,EACvE,UAAE;AACA,WAAO,QAAQ;AAAA,EACjB;AACA,SAAO;AACT;AAEO,SAAS,qBACd,UACA,UAAyC,CAAC,GAClC;AAER,SAAO,eAAe,UAAU,OAAO,EAAE,QAAQ,iBAAiB,EAAE;AACtE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type ResourceHintKind, type ResourceHintOptions } from "../core/resource-hints.js";
|
|
2
|
+
interface Resource {
|
|
3
|
+
kind: ResourceHintKind | 'style';
|
|
4
|
+
href: string;
|
|
5
|
+
options: Record<string, any>;
|
|
6
|
+
sent?: boolean;
|
|
7
|
+
cancelled?: boolean;
|
|
8
|
+
preloaded?: boolean;
|
|
9
|
+
css?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ResourceScope {
|
|
12
|
+
stylesheets?: Map<string, string[]>;
|
|
13
|
+
inline?: Set<string>;
|
|
14
|
+
}
|
|
15
|
+
export declare function createResourceHints(shellFlushed?: boolean, styleNonce?: string): {
|
|
16
|
+
add(kind: ResourceHintKind | "style", href: string, options: ResourceHintOptions): Resource;
|
|
17
|
+
addHost(type: string, props: any, scope?: ResourceScope): boolean;
|
|
18
|
+
mergeScope(scope: ResourceScope, parent?: ResourceScope): void;
|
|
19
|
+
takeStylesheets(): string[][];
|
|
20
|
+
drain(): string;
|
|
21
|
+
};
|
|
22
|
+
export {};
|