@solidjs/web 2.0.0-rc.1 → 2.0.0-rc.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/dev.cjs +116 -66
- package/dist/dev.js +109 -65
- package/dist/server.cjs +386 -109
- package/dist/server.js +378 -113
- package/dist/web.cjs +113 -64
- package/dist/web.js +106 -63
- package/frames/dist/client.cjs +100 -14
- package/frames/dist/client.dev.cjs +103 -14
- package/frames/dist/client.dev.js +104 -15
- package/frames/dist/client.js +101 -15
- package/frames/dist/server.cjs +285 -154
- package/frames/dist/server.js +287 -156
- package/package.json +20 -22
- package/serialization/dist/decode.cjs +22 -5
- package/serialization/dist/decode.js +23 -6
- package/serialization/dist/serialization.cjs +26 -13
- package/serialization/dist/serialization.js +26 -8
- package/serialization/types/index.d.ts +69 -157
- package/serialization/types/serializer-decode.d.ts +89 -112
- package/serialization/types/serializer.d.ts +94 -0
- package/serialization/types-cjs/index.d.cts +69 -157
- package/serialization/types-cjs/serializer-decode.d.cts +89 -112
- package/serialization/types-cjs/serializer.d.cts +94 -0
- package/server-functions/dist/client.cjs +48 -7
- package/server-functions/dist/client.js +48 -8
- package/server-functions/dist/server.cjs +76 -5
- package/server-functions/dist/server.dev.cjs +76 -5
- package/server-functions/dist/server.dev.js +76 -6
- package/server-functions/dist/server.js +76 -6
- package/types/client.d.ts +150 -290
- package/types/constants.d.ts +18 -0
- package/types/cookies.d.ts +31 -75
- package/types/frames/frame-client.d.ts +287 -259
- package/types/frames/frame-container-plugin.d.ts +71 -0
- package/types/frames/frame-sink.d.ts +58 -160
- package/types/frames/frame-transport.d.ts +161 -194
- package/types/frames/serializer-decode.d.ts +159 -0
- package/types/frames/serializer.d.ts +69 -157
- package/types/head.d.ts +16 -0
- package/types/index.d.ts +0 -65
- package/types/index.server.d.ts +125 -0
- package/types/jsx.d.ts +5 -13
- package/types/reconcile.d.ts +1 -0
- package/types/render.d.ts +4 -0
- package/types/response.d.ts +41 -153
- package/types/serializer-decode.d.ts +89 -112
- package/types/serializer.d.ts +69 -157
- package/types/server-functions/client.d.ts +101 -199
- package/types/server-functions/flash.d.ts +10 -30
- package/types/server-functions/registry.d.ts +63 -0
- package/types/server-functions/rich-args.d.ts +1 -10
- package/types/server-functions/server.d.ts +301 -518
- package/types/server-functions/shared.d.ts +112 -458
- package/types/server-mock.d.ts +13 -4
- package/types/server.d.ts +256 -427
- package/types-cjs/client.d.cts +150 -290
- package/types-cjs/constants.d.cts +18 -0
- package/types-cjs/cookies.d.cts +31 -75
- package/types-cjs/frames/frame-client.d.cts +287 -259
- package/types-cjs/frames/frame-container-plugin.d.cts +71 -0
- package/types-cjs/frames/frame-sink.d.cts +58 -160
- package/types-cjs/frames/frame-transport.d.cts +161 -194
- package/types-cjs/frames/serializer-decode.d.cts +159 -0
- package/types-cjs/frames/serializer.d.cts +69 -157
- package/types-cjs/head.d.cts +16 -0
- package/types-cjs/index.d.cts +0 -65
- package/types-cjs/index.server.d.cts +125 -0
- package/types-cjs/jsx.d.cts +5 -13
- package/types-cjs/reconcile.d.cts +1 -0
- package/types-cjs/render.d.cts +4 -0
- package/types-cjs/response.d.cts +41 -153
- package/types-cjs/serializer-decode.d.cts +89 -112
- package/types-cjs/serializer.d.cts +69 -157
- package/types-cjs/server-functions/client.d.cts +101 -199
- package/types-cjs/server-functions/flash.d.cts +10 -30
- package/types-cjs/server-functions/registry.d.cts +63 -0
- package/types-cjs/server-functions/rich-args.d.cts +1 -10
- package/types-cjs/server-functions/server.d.cts +301 -518
- package/types-cjs/server-functions/shared.d.cts +112 -458
- package/types-cjs/server-mock.d.cts +13 -4
- package/types-cjs/server.d.cts +256 -427
- package/LICENSE +0 -21
- package/types/core.d.ts +0 -6
- package/types-cjs/core.d.cts +0 -6
package/frames/dist/server.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Feature, toCrossJSONStream, Serializer, getCrossReferenceHeader } from 'seroval';
|
|
1
|
+
import { sharedConfig, createRoot, ssrHandleError, getOwner, runWithOwner, inServerComponentScope, creationStamp, NoHydration, runInServerComponentScope, createMemo, Hydration, createOwner, getProjectionTrace } from 'solid-js';
|
|
2
|
+
import { Feature, createStream, toCrossJSONStream, Serializer, getCrossReferenceHeader } from 'seroval';
|
|
3
3
|
import { AbortSignalPlugin, CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin } from 'seroval-plugins/web';
|
|
4
4
|
|
|
5
|
-
const STATE = Symbol.for("
|
|
5
|
+
const STATE = Symbol.for("solid.container-trace-state");
|
|
6
6
|
const state = globalThis[STATE] || (globalThis[STATE] = {
|
|
7
7
|
materialized: new WeakMap(),
|
|
8
8
|
materializedValues: new WeakSet()
|
|
@@ -10,11 +10,14 @@ const state = globalThis[STATE] || (globalThis[STATE] = {
|
|
|
10
10
|
function setContainerTraceResolver(fn) {
|
|
11
11
|
state.resolveTrace = fn;
|
|
12
12
|
}
|
|
13
|
+
function setContainerTraceStreamMint(fn) {
|
|
14
|
+
state.streamOf = fn;
|
|
15
|
+
}
|
|
13
16
|
function isContainerTraced(value) {
|
|
14
17
|
const resolve = state.resolveTrace;
|
|
15
18
|
return !!(resolve && value && typeof value === "object" && resolve(value));
|
|
16
19
|
}
|
|
17
|
-
const TRACE = Symbol.for("
|
|
20
|
+
const TRACE = Symbol.for("solid.container-trace");
|
|
18
21
|
function envelopeContainerTraces(value) {
|
|
19
22
|
if (!state.resolveTrace || value == null || typeof value !== "object") return value;
|
|
20
23
|
const trace = state.resolveTrace(value);
|
|
@@ -58,13 +61,14 @@ function materialize(marker) {
|
|
|
58
61
|
}
|
|
59
62
|
function parseTrace(value, ctx) {
|
|
60
63
|
const trace = value[TRACE];
|
|
64
|
+
const sub = trace.subscribe();
|
|
61
65
|
return {
|
|
62
66
|
a: trace.array ? 1 : 0,
|
|
63
|
-
i: ctx.parse(
|
|
67
|
+
i: ctx.parse(state.streamOf ? state.streamOf(sub) : sub)
|
|
64
68
|
};
|
|
65
69
|
}
|
|
66
70
|
const ContainerTracePlugin = {
|
|
67
|
-
tag: "
|
|
71
|
+
tag: "solid/container-trace",
|
|
68
72
|
test(value) {
|
|
69
73
|
return value != null && typeof value === "object" && TRACE in value;
|
|
70
74
|
},
|
|
@@ -74,9 +78,10 @@ const ContainerTracePlugin = {
|
|
|
74
78
|
},
|
|
75
79
|
async async(value, ctx) {
|
|
76
80
|
const trace = value[TRACE];
|
|
81
|
+
const sub = trace.subscribe();
|
|
77
82
|
return {
|
|
78
83
|
a: trace.array ? 1 : 0,
|
|
79
|
-
i: await ctx.parse(
|
|
84
|
+
i: await ctx.parse(state.streamOf ? state.streamOf(sub) : sub)
|
|
80
85
|
};
|
|
81
86
|
},
|
|
82
87
|
stream: parseTrace
|
|
@@ -94,13 +99,18 @@ const ContainerTracePlugin = {
|
|
|
94
99
|
}
|
|
95
100
|
};
|
|
96
101
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
+
setContainerTraceStreamMint(iterable => {
|
|
103
|
+
const stream = createStream();
|
|
104
|
+
(async () => {
|
|
105
|
+
try {
|
|
106
|
+
for await (const value of iterable) stream.next(value);
|
|
107
|
+
stream.return(undefined);
|
|
108
|
+
} catch (error) {
|
|
109
|
+
stream.throw(error);
|
|
110
|
+
}
|
|
111
|
+
})();
|
|
112
|
+
return stream;
|
|
102
113
|
});
|
|
103
|
-
|
|
104
114
|
const DEFAULT_WEB_PLUGINS = Object.freeze([AbortSignalPlugin,
|
|
105
115
|
CustomEventPlugin, DOMExceptionPlugin, EventPlugin,
|
|
106
116
|
FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin,
|
|
@@ -480,6 +490,7 @@ function registerEntryAssets(manifest) {
|
|
|
480
490
|
const assets = resolveAssets(key, manifest);
|
|
481
491
|
if (assets) {
|
|
482
492
|
for (let i = 0; i < assets.css.length; i++) ctx.registerAsset("style", assets.css[i]);
|
|
493
|
+
for (let i = 1; i < assets.js.length; i++) ctx.registerAsset("module", assets.js[i]);
|
|
483
494
|
}
|
|
484
495
|
return;
|
|
485
496
|
}
|
|
@@ -739,7 +750,7 @@ function emitHeadResource(registry, context, tracking, emitResource, nonce, desc
|
|
|
739
750
|
if (!styles) tracking.boundaryStyles.set(tracking.currentBoundaryId, styles = new Set());
|
|
740
751
|
styles.add(entry);
|
|
741
752
|
}
|
|
742
|
-
const markup = `<link${attrHtml}>`;
|
|
753
|
+
const markup = `<link${attrHtml}${nonceAttr(nonce, "style")}>`;
|
|
743
754
|
if (emitResource) emitResource(markup, entry);else {
|
|
744
755
|
registry.eagerHtml += markup;
|
|
745
756
|
entry.emitted = true;
|
|
@@ -837,7 +848,7 @@ function headGroupSignature(winner) {
|
|
|
837
848
|
}
|
|
838
849
|
return sig;
|
|
839
850
|
}
|
|
840
|
-
function renderShellHead(registry, nonce, isPendingFragment) {
|
|
851
|
+
function renderShellHead(registry, nonce, isPendingFragment, noScripts) {
|
|
841
852
|
commitHeadBoundary(registry, "", isPendingFragment);
|
|
842
853
|
registry.shellFlushed = true;
|
|
843
854
|
const winners = resolveHead(registry.committed);
|
|
@@ -847,8 +858,14 @@ function renderShellHead(registry, nonce, isPendingFragment) {
|
|
|
847
858
|
let metas = "";
|
|
848
859
|
let others = "";
|
|
849
860
|
let scripts = "";
|
|
861
|
+
let title = null;
|
|
850
862
|
for (const [identity, winner] of winners) {
|
|
851
863
|
registry.flushed.set(identity, headGroupSignature(winner));
|
|
864
|
+
if (identity === "title") {
|
|
865
|
+
const children = winner.tags[0].props.children;
|
|
866
|
+
title = children == null ? "" : String(children);
|
|
867
|
+
continue;
|
|
868
|
+
}
|
|
852
869
|
for (let i = 0; i < winner.tags.length; i++) {
|
|
853
870
|
const t = winner.tags[i];
|
|
854
871
|
const markup = renderHeadTagMarkup(t.tag, t.props, identity, nonce);
|
|
@@ -857,10 +874,12 @@ function renderShellHead(registry, nonce, isPendingFragment) {
|
|
|
857
874
|
}
|
|
858
875
|
return {
|
|
859
876
|
prelude,
|
|
860
|
-
html: registry.eagerHtml + links + metas + others + scripts
|
|
877
|
+
html: registry.eagerHtml + links + metas + others + scripts,
|
|
878
|
+
title,
|
|
879
|
+
noScripts
|
|
861
880
|
};
|
|
862
881
|
}
|
|
863
|
-
function flushHeadFragment(registry, boundary) {
|
|
882
|
+
function flushHeadFragment(registry, boundary, nonce) {
|
|
864
883
|
const groups = commitHeadBoundary(registry, boundary);
|
|
865
884
|
if (!groups.length) return null;
|
|
866
885
|
const winners = resolveHead(registry.committed);
|
|
@@ -891,12 +910,75 @@ function flushHeadFragment(registry, boundary) {
|
|
|
891
910
|
if (v == null || v === false) continue;
|
|
892
911
|
attrs[name] = v === true ? "" : String(v);
|
|
893
912
|
}
|
|
913
|
+
if (nonce && !hasNonceProp(t.props)) {
|
|
914
|
+
const destination = nonceDestination(t.tag, t.props);
|
|
915
|
+
const value = destination && nonce[destination];
|
|
916
|
+
if (value) attrs.nonce = String(value);
|
|
917
|
+
}
|
|
894
918
|
const children = t.props.children;
|
|
895
919
|
ops.push(["a", identity, t.tag, attrs, children == null ? null : String(children)]);
|
|
896
920
|
}
|
|
897
921
|
}
|
|
898
922
|
return ops.length ? ops : null;
|
|
899
923
|
}
|
|
924
|
+
function normalizeNonce(nonce) {
|
|
925
|
+
if (nonce == null) return undefined;
|
|
926
|
+
if (typeof nonce === "string") {
|
|
927
|
+
const attr = nonce ? ` nonce="${escape(nonce, true)}"` : "";
|
|
928
|
+
return {
|
|
929
|
+
script: nonce,
|
|
930
|
+
style: nonce,
|
|
931
|
+
scriptAttr: attr,
|
|
932
|
+
styleAttr: attr
|
|
933
|
+
};
|
|
934
|
+
}
|
|
935
|
+
const script = nonce.script;
|
|
936
|
+
const style = nonce.style;
|
|
937
|
+
if (!script && !style) return undefined;
|
|
938
|
+
return {
|
|
939
|
+
script,
|
|
940
|
+
style,
|
|
941
|
+
scriptAttr: typeof script === "string" && script ? ` nonce="${escape(script, true)}"` : "",
|
|
942
|
+
styleAttr: typeof style === "string" && style ? ` nonce="${escape(style, true)}"` : ""
|
|
943
|
+
};
|
|
944
|
+
}
|
|
945
|
+
function asciiLowerCase(value) {
|
|
946
|
+
return value.replace(/[A-Z]/g, c => String.fromCharCode(c.charCodeAt(0) + 32));
|
|
947
|
+
}
|
|
948
|
+
function hasNonceProp(props) {
|
|
949
|
+
for (const name in props) if (name.length === 5 && asciiLowerCase(name) === "nonce" && props[name] != null) return true;
|
|
950
|
+
return false;
|
|
951
|
+
}
|
|
952
|
+
function nonceDestination(tag, props) {
|
|
953
|
+
if (tag === "script") return "script";
|
|
954
|
+
if (tag === "style") return "style";
|
|
955
|
+
if (tag !== "link") return null;
|
|
956
|
+
const rel = props.rel;
|
|
957
|
+
if (typeof rel !== "string") return null;
|
|
958
|
+
const rels = asciiLowerCase(rel).split(/[\t\n\f\r ]+/);
|
|
959
|
+
if (rels.includes("stylesheet")) return "style";
|
|
960
|
+
const isModulePreload = rels.includes("modulepreload");
|
|
961
|
+
if (!isModulePreload && !rels.includes("preload")) return null;
|
|
962
|
+
const as = typeof props.as === "string" ? asciiLowerCase(props.as) : "";
|
|
963
|
+
if (as === "style") return "style";
|
|
964
|
+
if (as === "script") return "script";
|
|
965
|
+
if (!isModulePreload) return null;
|
|
966
|
+
switch (as) {
|
|
967
|
+
case "fetch":
|
|
968
|
+
case "font":
|
|
969
|
+
case "image":
|
|
970
|
+
case "json":
|
|
971
|
+
case "text":
|
|
972
|
+
case "track":
|
|
973
|
+
return null;
|
|
974
|
+
default:
|
|
975
|
+
return "script";
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
function nonceAttr(nonce, destination) {
|
|
979
|
+
if (!nonce || !destination) return "";
|
|
980
|
+
return destination === "script" ? nonce.scriptAttr : nonce.styleAttr;
|
|
981
|
+
}
|
|
900
982
|
function renderHeadAttrHtml(props) {
|
|
901
983
|
let attrs = "";
|
|
902
984
|
for (const name in props) {
|
|
@@ -925,17 +1007,16 @@ function headAttrRecord(props, skipRelHref) {
|
|
|
925
1007
|
function renderHeadTagMarkup(tag, props, identity, nonce) {
|
|
926
1008
|
let attrs = renderHeadAttrHtml(props);
|
|
927
1009
|
if (identity != null) attrs += ` data-dh="${escape(identity, true)}"`;
|
|
928
|
-
if (nonce && (
|
|
1010
|
+
if (nonce && !hasNonceProp(props)) attrs += nonceAttr(nonce, nonceDestination(tag, props));
|
|
929
1011
|
if (tag === "meta" || tag === "link" || tag === "base") return `<${tag}${attrs}>`;
|
|
930
1012
|
let body = props.children == null ? "" : String(props.children);
|
|
931
1013
|
if (tag === "script") body = body.replace(/<\/(script)/gi, "<\\/$1");else if (tag === "style") body = escapeStyleContent(body);else body = escape(body);
|
|
932
1014
|
return `<${tag}${attrs}>${body}</${tag}>`;
|
|
933
1015
|
}
|
|
934
1016
|
const REPLACE_SCRIPT = `function $df(e){return _$HY.f?_$HY.f(e):$dfr(e)}function $dfr(e,n,o,t){if(!(n=document.getElementById(e)))return 0;if(!(o=document.getElementById("pl-"+e)))return(_$HY.dq=_$HY.dq||{})[e]=1,0;for(;o&&(8!==o.nodeType||o.nodeValue!=="pl-"+e);)t=o.nextSibling,o.remove(),o=t;t=o.parentNode,o.replaceWith(n.content),n.remove(),(_$HY.v=_$HY.v||{})[e]=1,_$HY.fe(e,t),_$HY.hp&&_$HY.hp[e]&&($dh(_$HY.hp[e]),delete _$HY.hp[e]),$dfd();return 1}function $dfl(e,o,n){if(!(o=document.getElementById("pl-"+e)))return(_$HY.dlq=_$HY.dlq||{})[e]=1,0;if(o._$fl)return 1;for(n=o.nextSibling;n;){if(8===n.nodeType&&n.nodeValue==="pl-"+e){o.parentNode&&o.parentNode.insertBefore(o.content.cloneNode(!0),n),o._$fl=1,$dfd();return 1}n=n.nextSibling}return 0}function $dflj(e,i){for(i=0;i<e.length;i++)$dfl(e[i])}function $dfd(e,i){if(e=_$HY.dq){_$HY.dq=0;for(i in e)$df(i)}if(e=_$HY.dlq){_$HY.dlq=0;for(i in e)$dfl(i)}}function $dfs(e,c,d){(_$HY.sc=_$HY.sc||{})[e]=c,d&&((_$HY.sd=_$HY.sd||{})[e]=1)}function $dfg(e,g,i,k){if(!(g=_$HY.sg&&_$HY.sg[e]))return;for(i=0;i<g.length;i++)if(_$HY.sc&&_$HY.sc[g[i]]>0)return;for(i=0;i<g.length;i++)k=g[i],delete _$HY.sg[k],$df(k)}function $dfc(e){if(--_$HY.sc[e]<=0){delete _$HY.sc[e],_$HY.sg&&_$HY.sg[e]?$dfg(e):!(_$HY.sd&&_$HY.sd[e])&&$df(e);_$HY.sd&&delete _$HY.sd[e]}}function $dfj(e,i,n){for(i=0;i<e.length;i++)if(_$HY.sc&&_$HY.sc[e[i]]>0){for(n=0;n<e.length;n++)(_$HY.sg=_$HY.sg||{})[e[n]]=e;return}for(i=0;i<e.length;i++)$df(e[i])}`;
|
|
935
|
-
const HEAD_SCRIPT = `function $dha(o,i,e,n){for(i=0;i<o.length;i++)e=o[i],"t"==e[0]?((n=document.querySelector("title"))||(n=document.createElement("title"),document.head.appendChild(n)),n.textContent=e[1],n.setAttribute("data-dh","title")):"r"==e[0]?$dhr(e[1]):(n=document.createElement(e[2]),Object.keys(e[3]).forEach(function(a){n.setAttribute(a,e[3][a])}),null!=e[4]&&(n.textContent=e[4]),n.setAttribute("data-dh",e[1]),document.head.appendChild(n))}function $dhr(v,l,i){for(l=document.head.querySelectorAll("[data-dh]"),i=0;i<l.length;i++)l[i].getAttribute("data-dh")==v&&l[i].remove()}function $dh(o){_$HY.h?_$HY.h(o):$dha(o)}`;
|
|
1017
|
+
const HEAD_SCRIPT = `function $dha(o,i,e,n){for(i=0;i<o.length;i++)e=o[i],"t"==e[0]?((n=document.querySelector("title"))?n.hasAttribute("data-dh")||n.setAttribute("data-dhf",n.textContent):(n=document.createElement("title"),document.head.appendChild(n)),n.textContent=e[1],n.setAttribute("data-dh","title")):"r"==e[0]?$dhr(e[1]):(n=document.createElement(e[2]),Object.keys(e[3]).forEach(function(a){n.setAttribute(a,e[3][a])}),null!=e[4]&&(n.textContent=e[4]),n.setAttribute("data-dh",e[1]),document.head.appendChild(n))}function $dhr(v,l,i){for(l=document.head.querySelectorAll("[data-dh]"),i=0;i<l.length;i++)l[i].getAttribute("data-dh")==v&&l[i].remove()}function $dh(o){_$HY.h?_$HY.h(o):$dha(o)}`;
|
|
936
1018
|
function renderToStream(code, options = {}) {
|
|
937
1019
|
let {
|
|
938
|
-
nonce,
|
|
939
1020
|
onCompleteShell,
|
|
940
1021
|
onCompleteAll,
|
|
941
1022
|
renderId = "",
|
|
@@ -943,6 +1024,7 @@ function renderToStream(code, options = {}) {
|
|
|
943
1024
|
manifest,
|
|
944
1025
|
onHead
|
|
945
1026
|
} = options;
|
|
1027
|
+
const nonce = normalizeNonce(options.nonce);
|
|
946
1028
|
let dispose;
|
|
947
1029
|
let dead = false;
|
|
948
1030
|
const abandon = () => {
|
|
@@ -967,6 +1049,32 @@ function renderToStream(code, options = {}) {
|
|
|
967
1049
|
} catch (_) {}
|
|
968
1050
|
abandon();
|
|
969
1051
|
};
|
|
1052
|
+
const coalesceWrites = (writeRaw, endRaw) => {
|
|
1053
|
+
let buf = "";
|
|
1054
|
+
let scheduled = false;
|
|
1055
|
+
const flush = () => {
|
|
1056
|
+
scheduled = false;
|
|
1057
|
+
if (!buf) return;
|
|
1058
|
+
const out = buf;
|
|
1059
|
+
buf = "";
|
|
1060
|
+
writeRaw(out);
|
|
1061
|
+
};
|
|
1062
|
+
return {
|
|
1063
|
+
write(payload) {
|
|
1064
|
+
buf += payload;
|
|
1065
|
+
if (buf.length >= 16384) return flush();
|
|
1066
|
+
if (!scheduled) {
|
|
1067
|
+
scheduled = true;
|
|
1068
|
+
deferFlush(flush);
|
|
1069
|
+
}
|
|
1070
|
+
},
|
|
1071
|
+
flush,
|
|
1072
|
+
end() {
|
|
1073
|
+
flush();
|
|
1074
|
+
endRaw();
|
|
1075
|
+
}
|
|
1076
|
+
};
|
|
1077
|
+
};
|
|
970
1078
|
const guardSink = w => ({
|
|
971
1079
|
write(payload) {
|
|
972
1080
|
if (dead) return;
|
|
@@ -986,6 +1094,23 @@ function renderToStream(code, options = {}) {
|
|
|
986
1094
|
}
|
|
987
1095
|
});
|
|
988
1096
|
const blockingPromises = new Set();
|
|
1097
|
+
const canBatchStubs = !options.serializer && !options.sink;
|
|
1098
|
+
let stubBatch = null;
|
|
1099
|
+
const STUB_BATCH_KEY = "$B";
|
|
1100
|
+
const flushStubBatch = () => {
|
|
1101
|
+
if (!stubBatch) return;
|
|
1102
|
+
const batch = stubBatch;
|
|
1103
|
+
stubBatch = null;
|
|
1104
|
+
if (batch.size === 1) {
|
|
1105
|
+
const [id, p] = batch.entries().next().value;
|
|
1106
|
+
serializer.write(id, p);
|
|
1107
|
+
return;
|
|
1108
|
+
}
|
|
1109
|
+
const obj = {};
|
|
1110
|
+
for (const [id, p] of batch) obj[id] = p;
|
|
1111
|
+
serializer.write(STUB_BATCH_KEY, obj);
|
|
1112
|
+
pushTask(`(b=>{for(var k in b)_$HY.r[k]=b[k];delete _$HY.r["${STUB_BATCH_KEY}"]})(_$HY.r["${STUB_BATCH_KEY}"])`);
|
|
1113
|
+
};
|
|
989
1114
|
let headerEmitted = false;
|
|
990
1115
|
const pushTask = task => {
|
|
991
1116
|
if (noScripts) return;
|
|
@@ -1022,10 +1147,11 @@ function renderToStream(code, options = {}) {
|
|
|
1022
1147
|
buffer.write(renderInlineStyle(styles.inline[i], nonce));
|
|
1023
1148
|
}
|
|
1024
1149
|
if (styles.links.length) {
|
|
1150
|
+
const styleAttr = nonceAttr(nonce, "style");
|
|
1025
1151
|
emitTask(`$dfs("${key}",${styles.links.length},${deferActivation ? 1 : 0})`);
|
|
1026
1152
|
writeTasks();
|
|
1027
1153
|
for (const entry of styles.links) {
|
|
1028
|
-
buffer.write(typeof entry === "string" ? `<link rel="stylesheet" href="${entry}" onload="$dfc('${key}')" onerror="$dfc('${key}')">` : `<link${entry.attrHtml} onload="$dfc('${key}')" onerror="$dfc('${key}')">`);
|
|
1154
|
+
buffer.write(typeof entry === "string" ? `<link rel="stylesheet" href="${entry}"${styleAttr} onload="$dfc('${key}')" onerror="$dfc('${key}')">` : `<link${entry.attrHtml}${styleAttr} onload="$dfc('${key}')" onerror="$dfc('${key}')">`);
|
|
1029
1155
|
}
|
|
1030
1156
|
buffer.write(`<template id="${key}">${value}</template>`);
|
|
1031
1157
|
} else {
|
|
@@ -1040,7 +1166,7 @@ function renderToStream(code, options = {}) {
|
|
|
1040
1166
|
},
|
|
1041
1167
|
asset(type, value) {
|
|
1042
1168
|
if (type === "module") {
|
|
1043
|
-
buffer.write(`<link rel="modulepreload" href="${value}">`);
|
|
1169
|
+
buffer.write(`<link rel="modulepreload" href="${value}"${nonceAttr(nonce, "script")}>`);
|
|
1044
1170
|
} else if (type === "inline-style") {
|
|
1045
1171
|
buffer.write(renderInlineStyle(value, nonce));
|
|
1046
1172
|
} else if (type === "head-tag") {
|
|
@@ -1075,6 +1201,7 @@ function renderToStream(code, options = {}) {
|
|
|
1075
1201
|
context.live.end = null;
|
|
1076
1202
|
end();
|
|
1077
1203
|
}
|
|
1204
|
+
flushStubBatch();
|
|
1078
1205
|
serializer.flush();
|
|
1079
1206
|
}));
|
|
1080
1207
|
}
|
|
@@ -1082,7 +1209,7 @@ function renderToStream(code, options = {}) {
|
|
|
1082
1209
|
const registry = new Map();
|
|
1083
1210
|
const writeTasks = () => {
|
|
1084
1211
|
if (tasks.length && !completed && firstFlushed) {
|
|
1085
|
-
buffer.write(`<script${nonce
|
|
1212
|
+
buffer.write(`<script${nonceAttr(nonce, "script")}>${tasks}</script>`);
|
|
1086
1213
|
tasks = "";
|
|
1087
1214
|
}
|
|
1088
1215
|
timer = null;
|
|
@@ -1136,7 +1263,7 @@ function renderToStream(code, options = {}) {
|
|
|
1136
1263
|
};
|
|
1137
1264
|
sharedConfig.context = context = {
|
|
1138
1265
|
async: true,
|
|
1139
|
-
nonce,
|
|
1266
|
+
nonce: options.nonce,
|
|
1140
1267
|
live: {},
|
|
1141
1268
|
registerHeadTags(tags) {
|
|
1142
1269
|
registerHeadTags(headRegistry, context, tracking,
|
|
@@ -1194,10 +1321,18 @@ function renderToStream(code, options = {}) {
|
|
|
1194
1321
|
},
|
|
1195
1322
|
serialize(id, p, deferStream) {
|
|
1196
1323
|
if (sharedConfig.context.noHydrate) return;
|
|
1197
|
-
if (!firstFlushed &&
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1324
|
+
if (!firstFlushed && p && typeof p === "object" && "then" in p) {
|
|
1325
|
+
if (deferStream) {
|
|
1326
|
+
blockingPromises.add(p);
|
|
1327
|
+
p.then(d => serializer.write(id, d)).catch(e => serializer.write(id, e));
|
|
1328
|
+
return;
|
|
1329
|
+
}
|
|
1330
|
+
if (canBatchStubs && !shellCompleted) {
|
|
1331
|
+
(stubBatch ||= new Map()).set(id, p);
|
|
1332
|
+
return;
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
serializer.write(id, p);
|
|
1201
1336
|
},
|
|
1202
1337
|
escape: escape,
|
|
1203
1338
|
resolve: resolveSSRNode,
|
|
@@ -1231,7 +1366,7 @@ function renderToStream(code, options = {}) {
|
|
|
1231
1366
|
queue(flushEnd);
|
|
1232
1367
|
}))
|
|
1233
1368
|
});
|
|
1234
|
-
serializer.write(key + "_fr", p);
|
|
1369
|
+
if (canBatchStubs && !shellCompleted) (stubBatch ||= new Map()).set(key + "_fr", p);else serializer.write(key + "_fr", p);
|
|
1235
1370
|
}
|
|
1236
1371
|
return (value, error) => {
|
|
1237
1372
|
if (registry.has(key)) {
|
|
@@ -1262,7 +1397,7 @@ function renderToStream(code, options = {}) {
|
|
|
1262
1397
|
} else {
|
|
1263
1398
|
serializeFragmentAssets(key, tracking.boundaryModules, context);
|
|
1264
1399
|
const styles = collectStreamStyles(key, tracking, headStyles);
|
|
1265
|
-
const headOps = error ? null : flushHeadFragment(headRegistry, key);
|
|
1400
|
+
const headOps = error ? null : flushHeadFragment(headRegistry, key, nonce);
|
|
1266
1401
|
if (headOps) emitHeadOps(key, headOps);
|
|
1267
1402
|
sink.fragment(key, resolveSSRSelectValues(value !== undefined ? value : " "), {
|
|
1268
1403
|
styles,
|
|
@@ -1348,14 +1483,17 @@ function renderToStream(code, options = {}) {
|
|
|
1348
1483
|
function doShell() {
|
|
1349
1484
|
if (shellCompleted) return;
|
|
1350
1485
|
sharedConfig.context = context;
|
|
1486
|
+
const blockersBefore = blockingPromises.size;
|
|
1351
1487
|
if (!resolveRootHoles()) return;
|
|
1488
|
+
if (blockingPromises.size !== blockersBefore) return;
|
|
1352
1489
|
if (!headShellReady(headRegistry, p => blockingPromises.add(p))) return;
|
|
1353
1490
|
headStyles = new Set();
|
|
1354
1491
|
for (const url of tracking.emittedAssets) {
|
|
1355
1492
|
if (isCssUrl(url)) headStyles.add(url);
|
|
1356
1493
|
}
|
|
1357
1494
|
serializeRootAssets();
|
|
1358
|
-
|
|
1495
|
+
flushStubBatch();
|
|
1496
|
+
const head = renderShellHead(headRegistry, nonce, k => registry.has(k), noScripts);
|
|
1359
1497
|
sink.shell(resolveSSRSelectValues(html), {
|
|
1360
1498
|
preloads: tracking.emittedAssets,
|
|
1361
1499
|
inlineStyles: tracking.inlineStyles,
|
|
@@ -1376,6 +1514,7 @@ function renderToStream(code, options = {}) {
|
|
|
1376
1514
|
let drainTurn = 0;
|
|
1377
1515
|
const scheduleFlush = fn => {
|
|
1378
1516
|
const attempt = () => {
|
|
1517
|
+
flushStubBatch();
|
|
1379
1518
|
if (registry.size !== lastRegistrySize || drainTurn++ < MIN_DRAIN_TURNS) {
|
|
1380
1519
|
if (registry.size !== lastRegistrySize) drainTurn = 0;
|
|
1381
1520
|
lastRegistrySize = registry.size;
|
|
@@ -1423,22 +1562,18 @@ function renderToStream(code, options = {}) {
|
|
|
1423
1562
|
}
|
|
1424
1563
|
};
|
|
1425
1564
|
writer.closed && writer.closed.catch(failed);
|
|
1426
|
-
writable = {
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
}
|
|
1435
|
-
};
|
|
1436
|
-
buffer = {
|
|
1437
|
-
write(payload) {
|
|
1438
|
-
pendingWrites = pendingWrites.then(() => writer.write(encoder.encode(payload))).catch(failed);
|
|
1439
|
-
}
|
|
1440
|
-
};
|
|
1565
|
+
buffer = writable = coalesceWrites(payload => {
|
|
1566
|
+
pendingWrites = pendingWrites.then(() => writer.write(encoder.encode(payload))).catch(failed);
|
|
1567
|
+
}, () => {
|
|
1568
|
+
pendingWrites.then(() => {
|
|
1569
|
+
ended = true;
|
|
1570
|
+
writer.releaseLock();
|
|
1571
|
+
w.close().catch(() => {});
|
|
1572
|
+
resolve();
|
|
1573
|
+
});
|
|
1574
|
+
});
|
|
1441
1575
|
buffer.write(tmp);
|
|
1576
|
+
buffer.flush();
|
|
1442
1577
|
firstFlushed = true;
|
|
1443
1578
|
if (completed) {
|
|
1444
1579
|
dispose();
|
|
@@ -1468,7 +1603,8 @@ function renderToStream(code, options = {}) {
|
|
|
1468
1603
|
allSettled(blockingPromises).then(() => {
|
|
1469
1604
|
scheduleFlush(() => {
|
|
1470
1605
|
try {
|
|
1471
|
-
|
|
1606
|
+
const blockersBefore = blockingPromises.size;
|
|
1607
|
+
if (!resolveRootHoles() || blockingPromises.size !== blockersBefore || !headShellReady(headRegistry, p => blockingPromises.add(p))) return flush();
|
|
1472
1608
|
} catch (err) {
|
|
1473
1609
|
failRender(err);
|
|
1474
1610
|
return resolve(tmp);
|
|
@@ -1497,8 +1633,10 @@ function renderToStream(code, options = {}) {
|
|
|
1497
1633
|
return;
|
|
1498
1634
|
}
|
|
1499
1635
|
if (!shellCompleted) return flush();
|
|
1500
|
-
|
|
1636
|
+
const sink = guardSink(w);
|
|
1637
|
+
buffer = writable = coalesceWrites(sink.write, sink.end);
|
|
1501
1638
|
buffer.write(tmp);
|
|
1639
|
+
buffer.flush();
|
|
1502
1640
|
firstFlushed = true;
|
|
1503
1641
|
if (completed) {
|
|
1504
1642
|
dispose();
|
|
@@ -1671,6 +1809,15 @@ function createLiveHoles(sink, scoped) {
|
|
|
1671
1809
|
const stamp = typeof creationStamp === "function" ? creationStamp : () => 0;
|
|
1672
1810
|
const inScope = scoped && typeof inServerComponentScope === "function" ? inServerComponentScope : null;
|
|
1673
1811
|
const stripMarkers = html => html.replace(/<!--lh:\/?\d+-->/g, "");
|
|
1812
|
+
const swept = (owner, ctx, fn) => {
|
|
1813
|
+
const prev = sharedConfig.context;
|
|
1814
|
+
sharedConfig.context = ctx;
|
|
1815
|
+
try {
|
|
1816
|
+
return owner ? runWithOwner(owner, fn) : fn();
|
|
1817
|
+
} finally {
|
|
1818
|
+
sharedConfig.context = prev;
|
|
1819
|
+
}
|
|
1820
|
+
};
|
|
1674
1821
|
function resolveHoleValue(hole) {
|
|
1675
1822
|
const result = {
|
|
1676
1823
|
t: [""],
|
|
@@ -1736,6 +1883,7 @@ function createLiveHoles(sink, scoped) {
|
|
|
1736
1883
|
const recordsBefore = engine.recordStamp;
|
|
1737
1884
|
const ownersBefore = stamp();
|
|
1738
1885
|
const owner = getOwner();
|
|
1886
|
+
const holeCtx = sharedConfig.context;
|
|
1739
1887
|
const b = {
|
|
1740
1888
|
key: null,
|
|
1741
1889
|
children: [],
|
|
@@ -1749,7 +1897,7 @@ function createLiveHoles(sink, scoped) {
|
|
|
1749
1897
|
const sweepOwnersBefore = stamp();
|
|
1750
1898
|
let res;
|
|
1751
1899
|
try {
|
|
1752
|
-
res =
|
|
1900
|
+
res = swept(owner, holeCtx, () => resolveHoleValue(hole));
|
|
1753
1901
|
} catch (err) {
|
|
1754
1902
|
b.closed = true;
|
|
1755
1903
|
sink.closeBinding(b.key);
|
|
@@ -1857,6 +2005,7 @@ function createLiveHoles(sink, scoped) {
|
|
|
1857
2005
|
},
|
|
1858
2006
|
attr(cap) {
|
|
1859
2007
|
const owner = getOwner();
|
|
2008
|
+
const holeCtx = sharedConfig.context;
|
|
1860
2009
|
const b = {
|
|
1861
2010
|
key: "lha:" + cap.id,
|
|
1862
2011
|
children: [],
|
|
@@ -1892,7 +2041,7 @@ function createLiveHoles(sink, scoped) {
|
|
|
1892
2041
|
if (vt === "string" || vt === "number") html += v;
|
|
1893
2042
|
}
|
|
1894
2043
|
};
|
|
1895
|
-
|
|
2044
|
+
swept(owner, holeCtx, run);
|
|
1896
2045
|
} catch (err) {
|
|
1897
2046
|
if (ssrHandleError(err, true)) return;
|
|
1898
2047
|
b.closed = true;
|
|
@@ -2152,92 +2301,11 @@ function ssr(t) {
|
|
|
2152
2301
|
};
|
|
2153
2302
|
return result;
|
|
2154
2303
|
}
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
const SELECT_VALUE_ATTR = /\svalue="([^"]*)"/;
|
|
2159
|
-
function tagEnd(html, i) {
|
|
2160
|
-
for (let j = i + 1; j < html.length; j++) {
|
|
2161
|
-
const c = html.charCodeAt(j);
|
|
2162
|
-
if (c === 34) {
|
|
2163
|
-
j = html.indexOf('"', j + 1);
|
|
2164
|
-
if (j < 0) return -1;
|
|
2165
|
-
} else if (c === 62) return j;
|
|
2166
|
-
}
|
|
2167
|
-
return -1;
|
|
2168
|
-
}
|
|
2169
|
-
function optionText(html, from) {
|
|
2170
|
-
let t = "";
|
|
2171
|
-
let i = from;
|
|
2172
|
-
for (;;) {
|
|
2173
|
-
const lt = html.indexOf("<", i);
|
|
2174
|
-
if (lt < 0) return t + html.slice(i);
|
|
2175
|
-
t += html.slice(i, lt);
|
|
2176
|
-
if (!html.startsWith("<!--", lt)) return t;
|
|
2177
|
-
const ce = html.indexOf("-->", lt);
|
|
2178
|
-
if (ce < 0) return t;
|
|
2179
|
-
i = ce + 3;
|
|
2180
|
-
}
|
|
2181
|
-
}
|
|
2182
|
-
function tagIs(html, i, name) {
|
|
2183
|
-
if (!html.startsWith(name, i + 1)) return false;
|
|
2184
|
-
const c = html.charCodeAt(i + 1 + name.length);
|
|
2185
|
-
return c === 32 || c === 62 || c === 9 || c === 10 || c === 13;
|
|
2186
|
-
}
|
|
2304
|
+
const CLAIM_PROP = /*#__PURE__*/Symbol.for("solid.claim-prop");
|
|
2305
|
+
const CLAIMS_STREAM = 1;
|
|
2306
|
+
const CLAIMS_DOCUMENT = 2;
|
|
2187
2307
|
function resolveSSRSelectValues(html) {
|
|
2188
|
-
|
|
2189
|
-
let out = "";
|
|
2190
|
-
let idx = 0;
|
|
2191
|
-
let sel = null;
|
|
2192
|
-
let i = html.indexOf("<");
|
|
2193
|
-
while (i >= 0) {
|
|
2194
|
-
let e;
|
|
2195
|
-
if (html.charCodeAt(i + 1) === 33) {
|
|
2196
|
-
e = html.charCodeAt(i + 2) === 45 ? html.indexOf("-->", i) : html.indexOf(">", i);
|
|
2197
|
-
if (e < 0) break;
|
|
2198
|
-
if (html.charCodeAt(i + 2) === 45) e += 2;
|
|
2199
|
-
} else {
|
|
2200
|
-
e = tagEnd(html, i);
|
|
2201
|
-
if (e < 0) break;
|
|
2202
|
-
if (sel) {
|
|
2203
|
-
if (html.startsWith("</select>", i)) {
|
|
2204
|
-
out += html.slice(idx, sel.strip) + html.slice(sel.stripEnd, sel.body);
|
|
2205
|
-
let seg = sel.body;
|
|
2206
|
-
if (!sel.defaulted) {
|
|
2207
|
-
for (let k = 0; k < sel.marks.length; k++) {
|
|
2208
|
-
out += html.slice(seg, sel.marks[k]) + " selected";
|
|
2209
|
-
seg = sel.marks[k];
|
|
2210
|
-
}
|
|
2211
|
-
}
|
|
2212
|
-
out += html.slice(seg, i);
|
|
2213
|
-
idx = i;
|
|
2214
|
-
sel = null;
|
|
2215
|
-
} else if (tagIs(html, i, "option")) {
|
|
2216
|
-
const attrs = html.slice(i + 7, e);
|
|
2217
|
-
if (/\sselected(?=[\s=]|$)/.test(attrs)) sel.defaulted = true;else {
|
|
2218
|
-
const vm = SELECT_VALUE_ATTR.exec(attrs);
|
|
2219
|
-
const value = vm ? decodeSSREntities(vm[1]) : decodeSSREntities(optionText(html, e + 1)).replace(/\s+/g, " ").trim();
|
|
2220
|
-
if (sel.values.includes(value)) sel.marks.push(e);
|
|
2221
|
-
}
|
|
2222
|
-
}
|
|
2223
|
-
} else if (tagIs(html, i, "select")) {
|
|
2224
|
-
const m = SELECT_VALUE_ATTR.exec(html.slice(i, e + 1));
|
|
2225
|
-
if (m) {
|
|
2226
|
-
const bound = decodeSSREntities(m[1]);
|
|
2227
|
-
sel = {
|
|
2228
|
-
values: /\smultiple(?=[\s>=])/.test(html.slice(i, e + 1)) ? bound.split(",") : [bound],
|
|
2229
|
-
strip: i + m.index,
|
|
2230
|
-
stripEnd: i + m.index + m[0].length,
|
|
2231
|
-
body: e + 1,
|
|
2232
|
-
marks: [],
|
|
2233
|
-
defaulted: false
|
|
2234
|
-
};
|
|
2235
|
-
}
|
|
2236
|
-
}
|
|
2237
|
-
}
|
|
2238
|
-
i = html.indexOf("<", e + 1);
|
|
2239
|
-
}
|
|
2240
|
-
return out + html.slice(idx);
|
|
2308
|
+
return html;
|
|
2241
2309
|
}
|
|
2242
2310
|
function escape(s, attr) {
|
|
2243
2311
|
const t = typeof s;
|
|
@@ -2260,22 +2328,20 @@ function escape(s, attr) {
|
|
|
2260
2328
|
return escapeSlow(s, attr, i);
|
|
2261
2329
|
}
|
|
2262
2330
|
const ESCAPE_CONTENT = /[&<]/;
|
|
2263
|
-
const ESCAPE_ATTR = /[&"]/;
|
|
2331
|
+
const ESCAPE_ATTR = /[&"<]/;
|
|
2264
2332
|
function escapeSlow(s, attr, start) {
|
|
2265
|
-
|
|
2266
|
-
const delimCode = attr ? 34 : 60;
|
|
2267
|
-
const escDelim = attr ? """ : "<";
|
|
2333
|
+
if (attr) return escapeAttrSlow(s, start);
|
|
2268
2334
|
const c0 = s.charCodeAt(start);
|
|
2269
|
-
let iDelim = c0 ===
|
|
2335
|
+
let iDelim = c0 === 60 ? start : s.indexOf("<", start);
|
|
2270
2336
|
let iAmp = c0 === 38 ? start : s.indexOf("&", start);
|
|
2271
2337
|
let left = 0,
|
|
2272
2338
|
out = "";
|
|
2273
2339
|
while (iDelim >= 0 && iAmp >= 0) {
|
|
2274
2340
|
if (iDelim < iAmp) {
|
|
2275
2341
|
if (left < iDelim) out += s.substring(left, iDelim);
|
|
2276
|
-
out +=
|
|
2342
|
+
out += "<";
|
|
2277
2343
|
left = iDelim + 1;
|
|
2278
|
-
iDelim = s.indexOf(
|
|
2344
|
+
iDelim = s.indexOf("<", left);
|
|
2279
2345
|
} else {
|
|
2280
2346
|
if (left < iAmp) out += s.substring(left, iAmp);
|
|
2281
2347
|
out += "&";
|
|
@@ -2286,9 +2352,9 @@ function escapeSlow(s, attr, start) {
|
|
|
2286
2352
|
if (iDelim >= 0) {
|
|
2287
2353
|
do {
|
|
2288
2354
|
if (left < iDelim) out += s.substring(left, iDelim);
|
|
2289
|
-
out +=
|
|
2355
|
+
out += "<";
|
|
2290
2356
|
left = iDelim + 1;
|
|
2291
|
-
iDelim = s.indexOf(
|
|
2357
|
+
iDelim = s.indexOf("<", left);
|
|
2292
2358
|
} while (iDelim >= 0);
|
|
2293
2359
|
} else while (iAmp >= 0) {
|
|
2294
2360
|
if (left < iAmp) out += s.substring(left, iAmp);
|
|
@@ -2298,6 +2364,36 @@ function escapeSlow(s, attr, start) {
|
|
|
2298
2364
|
}
|
|
2299
2365
|
return left < s.length ? out + s.substring(left) : out;
|
|
2300
2366
|
}
|
|
2367
|
+
function escapeAttrSlow(s, start) {
|
|
2368
|
+
const c0 = s.charCodeAt(start);
|
|
2369
|
+
let iQuot = c0 === 34 ? start : s.indexOf('"', start);
|
|
2370
|
+
let iAmp = c0 === 38 ? start : s.indexOf("&", start);
|
|
2371
|
+
let iLt = c0 === 60 ? start : s.indexOf("<", start);
|
|
2372
|
+
let left = 0,
|
|
2373
|
+
out = "";
|
|
2374
|
+
for (;;) {
|
|
2375
|
+
let i = -1,
|
|
2376
|
+
ent;
|
|
2377
|
+
if (iQuot >= 0) {
|
|
2378
|
+
i = iQuot;
|
|
2379
|
+
ent = """;
|
|
2380
|
+
}
|
|
2381
|
+
if (iAmp >= 0 && (i < 0 || iAmp < i)) {
|
|
2382
|
+
i = iAmp;
|
|
2383
|
+
ent = "&";
|
|
2384
|
+
}
|
|
2385
|
+
if (iLt >= 0 && (i < 0 || iLt < i)) {
|
|
2386
|
+
i = iLt;
|
|
2387
|
+
ent = "<";
|
|
2388
|
+
}
|
|
2389
|
+
if (i < 0) break;
|
|
2390
|
+
if (left < i) out += s.substring(left, i);
|
|
2391
|
+
out += ent;
|
|
2392
|
+
left = i + 1;
|
|
2393
|
+
if (i === iQuot) iQuot = s.indexOf('"', left);else if (i === iAmp) iAmp = s.indexOf("&", left);else iLt = s.indexOf("<", left);
|
|
2394
|
+
}
|
|
2395
|
+
return left < s.length ? out + s.substring(left) : out;
|
|
2396
|
+
}
|
|
2301
2397
|
function tryJoinPlainSSRArray(nodes) {
|
|
2302
2398
|
if (nodes.length === 0) return undefined;
|
|
2303
2399
|
let out = "";
|
|
@@ -2313,6 +2409,7 @@ function tryJoinPlainSSRArray(nodes) {
|
|
|
2313
2409
|
function queue(fn) {
|
|
2314
2410
|
return Promise.resolve().then(fn);
|
|
2315
2411
|
}
|
|
2412
|
+
const deferFlush = typeof setImmediate === "function" ? setImmediate : fn => setTimeout(fn, 0);
|
|
2316
2413
|
function allSettled(promises) {
|
|
2317
2414
|
let size = promises.size;
|
|
2318
2415
|
return Promise.allSettled(promises).then(() => {
|
|
@@ -2321,10 +2418,11 @@ function allSettled(promises) {
|
|
|
2321
2418
|
});
|
|
2322
2419
|
}
|
|
2323
2420
|
function assembleDocument(html, emittedAssets, inlineStyles, scripts, nonce, headTags, onHead) {
|
|
2324
|
-
const scriptTag = scripts ? `<script${nonce
|
|
2325
|
-
const
|
|
2421
|
+
const scriptTag = scripts ? `<script${nonceAttr(nonce, "script")}>${scripts}</script>` : "";
|
|
2422
|
+
const title = headTags ? headTags.title : null;
|
|
2423
|
+
let headTagsHtml = headTags ? headTags.html : "";
|
|
2326
2424
|
const headPrelude = headTags ? headTags.prelude : "";
|
|
2327
|
-
if (!onHead && !headTagsHtml && !headPrelude && !(emittedAssets && emittedAssets.size) && !(inlineStyles && inlineStyles.size)) {
|
|
2425
|
+
if (!onHead && title == null && !headTagsHtml && !headPrelude && !(emittedAssets && emittedAssets.size) && !(inlineStyles && inlineStyles.size)) {
|
|
2328
2426
|
if (!scriptTag) return html;
|
|
2329
2427
|
const xs = html.indexOf("<!--xs-->");
|
|
2330
2428
|
return xs === -1 ? html + scriptTag : html.slice(0, xs) + scriptTag + html.slice(xs);
|
|
@@ -2336,15 +2434,33 @@ function assembleDocument(html, emittedAssets, inlineStyles, scripts, nonce, hea
|
|
|
2336
2434
|
html = html.slice(0, at) + headPrelude + html.slice(at);
|
|
2337
2435
|
}
|
|
2338
2436
|
}
|
|
2339
|
-
|
|
2437
|
+
let headIdx = html.indexOf("</head>");
|
|
2340
2438
|
if (headIdx === -1) {
|
|
2341
2439
|
if (onHead) {
|
|
2342
|
-
|
|
2440
|
+
let titleHtml = "";
|
|
2441
|
+
if (title != null) {
|
|
2442
|
+
titleHtml = headTags.noScripts ? `<title data-dh="title">${escape(title)}</title>` : `<script${nonceAttr(nonce, "script")}>(function(x,t){(t=document.querySelector("title"))?(t.hasAttribute("data-dh")||t.setAttribute("data-dhf",t.textContent),t.textContent=x):(document.title=x,t=document.querySelector("title"));t&&t.setAttribute("data-dh","title")})(${JSON.stringify(title).replace(/</g, "\\u003C")})</script>`;
|
|
2443
|
+
}
|
|
2444
|
+
onHead(headPrelude + headTagsHtml + titleHtml + renderHeadAssets(emittedAssets, inlineStyles, nonce));
|
|
2343
2445
|
}
|
|
2344
2446
|
if (!scriptTag) return html;
|
|
2345
2447
|
const xs = html.indexOf("<!--xs-->");
|
|
2346
2448
|
return xs === -1 ? html + scriptTag : html.slice(0, xs) + scriptTag + html.slice(xs);
|
|
2347
2449
|
}
|
|
2450
|
+
if (title != null) {
|
|
2451
|
+
const winner = escape(title);
|
|
2452
|
+
const open = html.match(/<head(?:\s[^>]*)?>/);
|
|
2453
|
+
const from = open ? open.index + open[0].length : 0;
|
|
2454
|
+
const m = /<title(\s[^>]*)?>([\s\S]*?)<\/title>/.exec(html.slice(from, headIdx));
|
|
2455
|
+
if (m) {
|
|
2456
|
+
const at = from + m.index;
|
|
2457
|
+
const stash = m[2].replace(/"/g, """);
|
|
2458
|
+
html = html.slice(0, at) + `<title${m[1] || ""} data-dh="title" data-dhf="${stash}">${winner}</title>` + html.slice(at + m[0].length);
|
|
2459
|
+
headIdx = html.indexOf("</head>");
|
|
2460
|
+
} else {
|
|
2461
|
+
headTagsHtml = `<title data-dh="title">${winner}</title>` + headTagsHtml;
|
|
2462
|
+
}
|
|
2463
|
+
}
|
|
2348
2464
|
const head = headTagsHtml + renderHeadAssets(emittedAssets, inlineStyles, nonce);
|
|
2349
2465
|
if (!scriptTag) return html.slice(0, headIdx) + head + html.slice(headIdx);
|
|
2350
2466
|
const xsIdx = html.indexOf("<!--xs-->");
|
|
@@ -2353,9 +2469,11 @@ function assembleDocument(html, emittedAssets, inlineStyles, scripts, nonce, hea
|
|
|
2353
2469
|
}
|
|
2354
2470
|
function renderHeadAssets(emittedAssets, inlineStyles, nonce) {
|
|
2355
2471
|
let head = "";
|
|
2472
|
+
const styleAttr = nonceAttr(nonce, "style");
|
|
2473
|
+
const scriptAttr = nonceAttr(nonce, "script");
|
|
2356
2474
|
if (emittedAssets && emittedAssets.size) {
|
|
2357
2475
|
for (const url of emittedAssets) {
|
|
2358
|
-
head += isCssUrl(url) ? `<link rel="stylesheet" href="${url}">` : `<link rel="modulepreload" href="${url}">`;
|
|
2476
|
+
head += isCssUrl(url) ? `<link rel="stylesheet" href="${url}"${styleAttr}>` : `<link rel="modulepreload" href="${url}"${scriptAttr}>`;
|
|
2359
2477
|
}
|
|
2360
2478
|
}
|
|
2361
2479
|
if (inlineStyles && inlineStyles.size) {
|
|
@@ -2417,12 +2535,15 @@ function escapeStyleContent(content) {
|
|
|
2417
2535
|
}
|
|
2418
2536
|
function renderInlineStyle(entry, nonce) {
|
|
2419
2537
|
let attrs = "";
|
|
2538
|
+
let hasNonce = false;
|
|
2420
2539
|
if (entry.attrs) {
|
|
2421
2540
|
for (const name in entry.attrs) {
|
|
2541
|
+
if (name.length === 5 && asciiLowerCase(name) === "nonce") hasNonce = true;
|
|
2422
2542
|
attrs += ` ${name}="${escape(String(entry.attrs[name]), true)}"`;
|
|
2423
2543
|
}
|
|
2424
2544
|
}
|
|
2425
|
-
|
|
2545
|
+
const nonceHtml = hasNonce ? "" : nonceAttr(nonce, "style");
|
|
2546
|
+
return `<style${nonceHtml} data-asset="${escape(entry.id, true)}"${attrs}>${escapeStyleContent(entry.content)}</style>`;
|
|
2426
2547
|
}
|
|
2427
2548
|
function waitForFragments(registry, key) {
|
|
2428
2549
|
for (const k of [...registry.keys()].reverse()) {
|
|
@@ -2551,9 +2672,9 @@ const FRAME_STREAM_HEADER = "X-Frame-Stream";
|
|
|
2551
2672
|
function isFrameStreamResponse(response) {
|
|
2552
2673
|
return response.headers.has(FRAME_STREAM_HEADER);
|
|
2553
2674
|
}
|
|
2554
|
-
const SERVER_COMPONENT = /*#__PURE__*/Symbol.for("
|
|
2555
|
-
const SERVER_COMPONENT_SOURCE = /*#__PURE__*/Symbol.for("
|
|
2556
|
-
const SERVER_COMPONENT_ADDRESS = /*#__PURE__*/Symbol.for("
|
|
2675
|
+
const SERVER_COMPONENT = /*#__PURE__*/Symbol.for("solid.server-component");
|
|
2676
|
+
const SERVER_COMPONENT_SOURCE = /*#__PURE__*/Symbol.for("solid.server-component-source");
|
|
2677
|
+
const SERVER_COMPONENT_ADDRESS = /*#__PURE__*/Symbol.for("solid.server-component-address");
|
|
2557
2678
|
let serverComponentRegistryExpr;
|
|
2558
2679
|
function setServerComponentBootstrap(resolve) {
|
|
2559
2680
|
serverComponentRegistryExpr = resolve;
|
|
@@ -2565,7 +2686,7 @@ function parseServerComponent(value, ctx) {
|
|
|
2565
2686
|
};
|
|
2566
2687
|
}
|
|
2567
2688
|
const ServerComponentPlugin = {
|
|
2568
|
-
tag: "
|
|
2689
|
+
tag: "solid/server-component",
|
|
2569
2690
|
test(value) {
|
|
2570
2691
|
return typeof value === "function" && SERVER_COMPONENT in value;
|
|
2571
2692
|
},
|
|
@@ -2598,6 +2719,12 @@ function flightCodec(codec) {
|
|
|
2598
2719
|
};
|
|
2599
2720
|
}
|
|
2600
2721
|
|
|
2722
|
+
const runWithHydrationScope = (id, fn) => runWithOwner(createOwner({
|
|
2723
|
+
id
|
|
2724
|
+
}), fn);
|
|
2725
|
+
const ssrAsyncValue = value => createMemo(() => value, {
|
|
2726
|
+
serialize: false
|
|
2727
|
+
});
|
|
2601
2728
|
const scopeStamp = typeof creationStamp === "function" ? creationStamp : () => 0;
|
|
2602
2729
|
function serverOwned(render) {
|
|
2603
2730
|
return NoHydration ? NoHydration({
|
|
@@ -2875,6 +3002,7 @@ function renderServerComponent(component, options = {}) {
|
|
|
2875
3002
|
ctx.commit = sink.commit;
|
|
2876
3003
|
ctx.commitEpoch = () => sink.epoch;
|
|
2877
3004
|
ctx.liveHoles = createLiveHoles(sink);
|
|
3005
|
+
ctx.claims = CLAIMS_STREAM;
|
|
2878
3006
|
}
|
|
2879
3007
|
return serverComponentScope(() => component(props));
|
|
2880
3008
|
};
|
|
@@ -3168,13 +3296,14 @@ function createDocumentSlotProps(clientProps, frameId) {
|
|
|
3168
3296
|
return out;
|
|
3169
3297
|
};
|
|
3170
3298
|
fn.$lhSkip = true;
|
|
3299
|
+
fn[CLAIM_PROP] = prop;
|
|
3171
3300
|
getters.set(prop, fn);
|
|
3172
3301
|
}
|
|
3173
3302
|
return fn;
|
|
3174
3303
|
}
|
|
3175
3304
|
});
|
|
3176
3305
|
}
|
|
3177
|
-
const FRAME_TAG = "
|
|
3306
|
+
const FRAME_TAG = "solid-frame";
|
|
3178
3307
|
const FRAME_ID_ATTR = "data-fid";
|
|
3179
3308
|
function frameElementOpen(id) {
|
|
3180
3309
|
const escaped = sharedConfig.context ? sharedConfig.context.escape(String(id), true) : String(id);
|
|
@@ -3299,6 +3428,7 @@ function frameTransformDirectResult(value, {
|
|
|
3299
3428
|
},
|
|
3300
3429
|
serverOwned(() => {
|
|
3301
3430
|
armDocumentLiveHoles(sharedConfig.context);
|
|
3431
|
+
sharedConfig.context.claims = CLAIMS_DOCUMENT;
|
|
3302
3432
|
const slotProps = createDocumentSlotProps(props, id);
|
|
3303
3433
|
return serverComponentScope(() => component(slotProps));
|
|
3304
3434
|
}), {
|
|
@@ -3542,6 +3672,7 @@ function createSlotProps(sink, frame) {
|
|
|
3542
3672
|
return slotRange(occurrence);
|
|
3543
3673
|
};
|
|
3544
3674
|
fn.$lhSkip = true;
|
|
3675
|
+
fn[CLAIM_PROP] = prop;
|
|
3545
3676
|
getters.set(prop, fn);
|
|
3546
3677
|
}
|
|
3547
3678
|
return fn;
|