@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.cjs
CHANGED
|
@@ -4,7 +4,7 @@ var solidJs = require('solid-js');
|
|
|
4
4
|
var seroval = require('seroval');
|
|
5
5
|
var web = require('seroval-plugins/web');
|
|
6
6
|
|
|
7
|
-
const STATE = Symbol.for("
|
|
7
|
+
const STATE = Symbol.for("solid.container-trace-state");
|
|
8
8
|
const state = globalThis[STATE] || (globalThis[STATE] = {
|
|
9
9
|
materialized: new WeakMap(),
|
|
10
10
|
materializedValues: new WeakSet()
|
|
@@ -12,11 +12,14 @@ const state = globalThis[STATE] || (globalThis[STATE] = {
|
|
|
12
12
|
function setContainerTraceResolver(fn) {
|
|
13
13
|
state.resolveTrace = fn;
|
|
14
14
|
}
|
|
15
|
+
function setContainerTraceStreamMint(fn) {
|
|
16
|
+
state.streamOf = fn;
|
|
17
|
+
}
|
|
15
18
|
function isContainerTraced(value) {
|
|
16
19
|
const resolve = state.resolveTrace;
|
|
17
20
|
return !!(resolve && value && typeof value === "object" && resolve(value));
|
|
18
21
|
}
|
|
19
|
-
const TRACE = Symbol.for("
|
|
22
|
+
const TRACE = Symbol.for("solid.container-trace");
|
|
20
23
|
function envelopeContainerTraces(value) {
|
|
21
24
|
if (!state.resolveTrace || value == null || typeof value !== "object") return value;
|
|
22
25
|
const trace = state.resolveTrace(value);
|
|
@@ -60,13 +63,14 @@ function materialize(marker) {
|
|
|
60
63
|
}
|
|
61
64
|
function parseTrace(value, ctx) {
|
|
62
65
|
const trace = value[TRACE];
|
|
66
|
+
const sub = trace.subscribe();
|
|
63
67
|
return {
|
|
64
68
|
a: trace.array ? 1 : 0,
|
|
65
|
-
i: ctx.parse(
|
|
69
|
+
i: ctx.parse(state.streamOf ? state.streamOf(sub) : sub)
|
|
66
70
|
};
|
|
67
71
|
}
|
|
68
72
|
const ContainerTracePlugin = {
|
|
69
|
-
tag: "
|
|
73
|
+
tag: "solid/container-trace",
|
|
70
74
|
test(value) {
|
|
71
75
|
return value != null && typeof value === "object" && TRACE in value;
|
|
72
76
|
},
|
|
@@ -76,9 +80,10 @@ const ContainerTracePlugin = {
|
|
|
76
80
|
},
|
|
77
81
|
async async(value, ctx) {
|
|
78
82
|
const trace = value[TRACE];
|
|
83
|
+
const sub = trace.subscribe();
|
|
79
84
|
return {
|
|
80
85
|
a: trace.array ? 1 : 0,
|
|
81
|
-
i: await ctx.parse(
|
|
86
|
+
i: await ctx.parse(state.streamOf ? state.streamOf(sub) : sub)
|
|
82
87
|
};
|
|
83
88
|
},
|
|
84
89
|
stream: parseTrace
|
|
@@ -96,13 +101,18 @@ const ContainerTracePlugin = {
|
|
|
96
101
|
}
|
|
97
102
|
};
|
|
98
103
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
+
setContainerTraceStreamMint(iterable => {
|
|
105
|
+
const stream = seroval.createStream();
|
|
106
|
+
(async () => {
|
|
107
|
+
try {
|
|
108
|
+
for await (const value of iterable) stream.next(value);
|
|
109
|
+
stream.return(undefined);
|
|
110
|
+
} catch (error) {
|
|
111
|
+
stream.throw(error);
|
|
112
|
+
}
|
|
113
|
+
})();
|
|
114
|
+
return stream;
|
|
104
115
|
});
|
|
105
|
-
|
|
106
116
|
const DEFAULT_WEB_PLUGINS = Object.freeze([web.AbortSignalPlugin,
|
|
107
117
|
web.CustomEventPlugin, web.DOMExceptionPlugin, web.EventPlugin,
|
|
108
118
|
web.FormDataPlugin, web.HeadersPlugin, web.ReadableStreamPlugin, web.RequestPlugin, web.ResponsePlugin, web.URLSearchParamsPlugin, web.URLPlugin,
|
|
@@ -482,6 +492,7 @@ function registerEntryAssets(manifest) {
|
|
|
482
492
|
const assets = resolveAssets(key, manifest);
|
|
483
493
|
if (assets) {
|
|
484
494
|
for (let i = 0; i < assets.css.length; i++) ctx.registerAsset("style", assets.css[i]);
|
|
495
|
+
for (let i = 1; i < assets.js.length; i++) ctx.registerAsset("module", assets.js[i]);
|
|
485
496
|
}
|
|
486
497
|
return;
|
|
487
498
|
}
|
|
@@ -741,7 +752,7 @@ function emitHeadResource(registry, context, tracking, emitResource, nonce, desc
|
|
|
741
752
|
if (!styles) tracking.boundaryStyles.set(tracking.currentBoundaryId, styles = new Set());
|
|
742
753
|
styles.add(entry);
|
|
743
754
|
}
|
|
744
|
-
const markup = `<link${attrHtml}>`;
|
|
755
|
+
const markup = `<link${attrHtml}${nonceAttr(nonce, "style")}>`;
|
|
745
756
|
if (emitResource) emitResource(markup, entry);else {
|
|
746
757
|
registry.eagerHtml += markup;
|
|
747
758
|
entry.emitted = true;
|
|
@@ -839,7 +850,7 @@ function headGroupSignature(winner) {
|
|
|
839
850
|
}
|
|
840
851
|
return sig;
|
|
841
852
|
}
|
|
842
|
-
function renderShellHead(registry, nonce, isPendingFragment) {
|
|
853
|
+
function renderShellHead(registry, nonce, isPendingFragment, noScripts) {
|
|
843
854
|
commitHeadBoundary(registry, "", isPendingFragment);
|
|
844
855
|
registry.shellFlushed = true;
|
|
845
856
|
const winners = resolveHead(registry.committed);
|
|
@@ -849,8 +860,14 @@ function renderShellHead(registry, nonce, isPendingFragment) {
|
|
|
849
860
|
let metas = "";
|
|
850
861
|
let others = "";
|
|
851
862
|
let scripts = "";
|
|
863
|
+
let title = null;
|
|
852
864
|
for (const [identity, winner] of winners) {
|
|
853
865
|
registry.flushed.set(identity, headGroupSignature(winner));
|
|
866
|
+
if (identity === "title") {
|
|
867
|
+
const children = winner.tags[0].props.children;
|
|
868
|
+
title = children == null ? "" : String(children);
|
|
869
|
+
continue;
|
|
870
|
+
}
|
|
854
871
|
for (let i = 0; i < winner.tags.length; i++) {
|
|
855
872
|
const t = winner.tags[i];
|
|
856
873
|
const markup = renderHeadTagMarkup(t.tag, t.props, identity, nonce);
|
|
@@ -859,10 +876,12 @@ function renderShellHead(registry, nonce, isPendingFragment) {
|
|
|
859
876
|
}
|
|
860
877
|
return {
|
|
861
878
|
prelude,
|
|
862
|
-
html: registry.eagerHtml + links + metas + others + scripts
|
|
879
|
+
html: registry.eagerHtml + links + metas + others + scripts,
|
|
880
|
+
title,
|
|
881
|
+
noScripts
|
|
863
882
|
};
|
|
864
883
|
}
|
|
865
|
-
function flushHeadFragment(registry, boundary) {
|
|
884
|
+
function flushHeadFragment(registry, boundary, nonce) {
|
|
866
885
|
const groups = commitHeadBoundary(registry, boundary);
|
|
867
886
|
if (!groups.length) return null;
|
|
868
887
|
const winners = resolveHead(registry.committed);
|
|
@@ -893,12 +912,75 @@ function flushHeadFragment(registry, boundary) {
|
|
|
893
912
|
if (v == null || v === false) continue;
|
|
894
913
|
attrs[name] = v === true ? "" : String(v);
|
|
895
914
|
}
|
|
915
|
+
if (nonce && !hasNonceProp(t.props)) {
|
|
916
|
+
const destination = nonceDestination(t.tag, t.props);
|
|
917
|
+
const value = destination && nonce[destination];
|
|
918
|
+
if (value) attrs.nonce = String(value);
|
|
919
|
+
}
|
|
896
920
|
const children = t.props.children;
|
|
897
921
|
ops.push(["a", identity, t.tag, attrs, children == null ? null : String(children)]);
|
|
898
922
|
}
|
|
899
923
|
}
|
|
900
924
|
return ops.length ? ops : null;
|
|
901
925
|
}
|
|
926
|
+
function normalizeNonce(nonce) {
|
|
927
|
+
if (nonce == null) return undefined;
|
|
928
|
+
if (typeof nonce === "string") {
|
|
929
|
+
const attr = nonce ? ` nonce="${escape(nonce, true)}"` : "";
|
|
930
|
+
return {
|
|
931
|
+
script: nonce,
|
|
932
|
+
style: nonce,
|
|
933
|
+
scriptAttr: attr,
|
|
934
|
+
styleAttr: attr
|
|
935
|
+
};
|
|
936
|
+
}
|
|
937
|
+
const script = nonce.script;
|
|
938
|
+
const style = nonce.style;
|
|
939
|
+
if (!script && !style) return undefined;
|
|
940
|
+
return {
|
|
941
|
+
script,
|
|
942
|
+
style,
|
|
943
|
+
scriptAttr: typeof script === "string" && script ? ` nonce="${escape(script, true)}"` : "",
|
|
944
|
+
styleAttr: typeof style === "string" && style ? ` nonce="${escape(style, true)}"` : ""
|
|
945
|
+
};
|
|
946
|
+
}
|
|
947
|
+
function asciiLowerCase(value) {
|
|
948
|
+
return value.replace(/[A-Z]/g, c => String.fromCharCode(c.charCodeAt(0) + 32));
|
|
949
|
+
}
|
|
950
|
+
function hasNonceProp(props) {
|
|
951
|
+
for (const name in props) if (name.length === 5 && asciiLowerCase(name) === "nonce" && props[name] != null) return true;
|
|
952
|
+
return false;
|
|
953
|
+
}
|
|
954
|
+
function nonceDestination(tag, props) {
|
|
955
|
+
if (tag === "script") return "script";
|
|
956
|
+
if (tag === "style") return "style";
|
|
957
|
+
if (tag !== "link") return null;
|
|
958
|
+
const rel = props.rel;
|
|
959
|
+
if (typeof rel !== "string") return null;
|
|
960
|
+
const rels = asciiLowerCase(rel).split(/[\t\n\f\r ]+/);
|
|
961
|
+
if (rels.includes("stylesheet")) return "style";
|
|
962
|
+
const isModulePreload = rels.includes("modulepreload");
|
|
963
|
+
if (!isModulePreload && !rels.includes("preload")) return null;
|
|
964
|
+
const as = typeof props.as === "string" ? asciiLowerCase(props.as) : "";
|
|
965
|
+
if (as === "style") return "style";
|
|
966
|
+
if (as === "script") return "script";
|
|
967
|
+
if (!isModulePreload) return null;
|
|
968
|
+
switch (as) {
|
|
969
|
+
case "fetch":
|
|
970
|
+
case "font":
|
|
971
|
+
case "image":
|
|
972
|
+
case "json":
|
|
973
|
+
case "text":
|
|
974
|
+
case "track":
|
|
975
|
+
return null;
|
|
976
|
+
default:
|
|
977
|
+
return "script";
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
function nonceAttr(nonce, destination) {
|
|
981
|
+
if (!nonce || !destination) return "";
|
|
982
|
+
return destination === "script" ? nonce.scriptAttr : nonce.styleAttr;
|
|
983
|
+
}
|
|
902
984
|
function renderHeadAttrHtml(props) {
|
|
903
985
|
let attrs = "";
|
|
904
986
|
for (const name in props) {
|
|
@@ -927,17 +1009,16 @@ function headAttrRecord(props, skipRelHref) {
|
|
|
927
1009
|
function renderHeadTagMarkup(tag, props, identity, nonce) {
|
|
928
1010
|
let attrs = renderHeadAttrHtml(props);
|
|
929
1011
|
if (identity != null) attrs += ` data-dh="${escape(identity, true)}"`;
|
|
930
|
-
if (nonce && (
|
|
1012
|
+
if (nonce && !hasNonceProp(props)) attrs += nonceAttr(nonce, nonceDestination(tag, props));
|
|
931
1013
|
if (tag === "meta" || tag === "link" || tag === "base") return `<${tag}${attrs}>`;
|
|
932
1014
|
let body = props.children == null ? "" : String(props.children);
|
|
933
1015
|
if (tag === "script") body = body.replace(/<\/(script)/gi, "<\\/$1");else if (tag === "style") body = escapeStyleContent(body);else body = escape(body);
|
|
934
1016
|
return `<${tag}${attrs}>${body}</${tag}>`;
|
|
935
1017
|
}
|
|
936
1018
|
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])}`;
|
|
937
|
-
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)}`;
|
|
1019
|
+
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)}`;
|
|
938
1020
|
function renderToStream(code, options = {}) {
|
|
939
1021
|
let {
|
|
940
|
-
nonce,
|
|
941
1022
|
onCompleteShell,
|
|
942
1023
|
onCompleteAll,
|
|
943
1024
|
renderId = "",
|
|
@@ -945,6 +1026,7 @@ function renderToStream(code, options = {}) {
|
|
|
945
1026
|
manifest,
|
|
946
1027
|
onHead
|
|
947
1028
|
} = options;
|
|
1029
|
+
const nonce = normalizeNonce(options.nonce);
|
|
948
1030
|
let dispose;
|
|
949
1031
|
let dead = false;
|
|
950
1032
|
const abandon = () => {
|
|
@@ -969,6 +1051,32 @@ function renderToStream(code, options = {}) {
|
|
|
969
1051
|
} catch (_) {}
|
|
970
1052
|
abandon();
|
|
971
1053
|
};
|
|
1054
|
+
const coalesceWrites = (writeRaw, endRaw) => {
|
|
1055
|
+
let buf = "";
|
|
1056
|
+
let scheduled = false;
|
|
1057
|
+
const flush = () => {
|
|
1058
|
+
scheduled = false;
|
|
1059
|
+
if (!buf) return;
|
|
1060
|
+
const out = buf;
|
|
1061
|
+
buf = "";
|
|
1062
|
+
writeRaw(out);
|
|
1063
|
+
};
|
|
1064
|
+
return {
|
|
1065
|
+
write(payload) {
|
|
1066
|
+
buf += payload;
|
|
1067
|
+
if (buf.length >= 16384) return flush();
|
|
1068
|
+
if (!scheduled) {
|
|
1069
|
+
scheduled = true;
|
|
1070
|
+
deferFlush(flush);
|
|
1071
|
+
}
|
|
1072
|
+
},
|
|
1073
|
+
flush,
|
|
1074
|
+
end() {
|
|
1075
|
+
flush();
|
|
1076
|
+
endRaw();
|
|
1077
|
+
}
|
|
1078
|
+
};
|
|
1079
|
+
};
|
|
972
1080
|
const guardSink = w => ({
|
|
973
1081
|
write(payload) {
|
|
974
1082
|
if (dead) return;
|
|
@@ -988,6 +1096,23 @@ function renderToStream(code, options = {}) {
|
|
|
988
1096
|
}
|
|
989
1097
|
});
|
|
990
1098
|
const blockingPromises = new Set();
|
|
1099
|
+
const canBatchStubs = !options.serializer && !options.sink;
|
|
1100
|
+
let stubBatch = null;
|
|
1101
|
+
const STUB_BATCH_KEY = "$B";
|
|
1102
|
+
const flushStubBatch = () => {
|
|
1103
|
+
if (!stubBatch) return;
|
|
1104
|
+
const batch = stubBatch;
|
|
1105
|
+
stubBatch = null;
|
|
1106
|
+
if (batch.size === 1) {
|
|
1107
|
+
const [id, p] = batch.entries().next().value;
|
|
1108
|
+
serializer.write(id, p);
|
|
1109
|
+
return;
|
|
1110
|
+
}
|
|
1111
|
+
const obj = {};
|
|
1112
|
+
for (const [id, p] of batch) obj[id] = p;
|
|
1113
|
+
serializer.write(STUB_BATCH_KEY, obj);
|
|
1114
|
+
pushTask(`(b=>{for(var k in b)_$HY.r[k]=b[k];delete _$HY.r["${STUB_BATCH_KEY}"]})(_$HY.r["${STUB_BATCH_KEY}"])`);
|
|
1115
|
+
};
|
|
991
1116
|
let headerEmitted = false;
|
|
992
1117
|
const pushTask = task => {
|
|
993
1118
|
if (noScripts) return;
|
|
@@ -1024,10 +1149,11 @@ function renderToStream(code, options = {}) {
|
|
|
1024
1149
|
buffer.write(renderInlineStyle(styles.inline[i], nonce));
|
|
1025
1150
|
}
|
|
1026
1151
|
if (styles.links.length) {
|
|
1152
|
+
const styleAttr = nonceAttr(nonce, "style");
|
|
1027
1153
|
emitTask(`$dfs("${key}",${styles.links.length},${deferActivation ? 1 : 0})`);
|
|
1028
1154
|
writeTasks();
|
|
1029
1155
|
for (const entry of styles.links) {
|
|
1030
|
-
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}')">`);
|
|
1156
|
+
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}')">`);
|
|
1031
1157
|
}
|
|
1032
1158
|
buffer.write(`<template id="${key}">${value}</template>`);
|
|
1033
1159
|
} else {
|
|
@@ -1042,7 +1168,7 @@ function renderToStream(code, options = {}) {
|
|
|
1042
1168
|
},
|
|
1043
1169
|
asset(type, value) {
|
|
1044
1170
|
if (type === "module") {
|
|
1045
|
-
buffer.write(`<link rel="modulepreload" href="${value}">`);
|
|
1171
|
+
buffer.write(`<link rel="modulepreload" href="${value}"${nonceAttr(nonce, "script")}>`);
|
|
1046
1172
|
} else if (type === "inline-style") {
|
|
1047
1173
|
buffer.write(renderInlineStyle(value, nonce));
|
|
1048
1174
|
} else if (type === "head-tag") {
|
|
@@ -1077,6 +1203,7 @@ function renderToStream(code, options = {}) {
|
|
|
1077
1203
|
context.live.end = null;
|
|
1078
1204
|
end();
|
|
1079
1205
|
}
|
|
1206
|
+
flushStubBatch();
|
|
1080
1207
|
serializer.flush();
|
|
1081
1208
|
}));
|
|
1082
1209
|
}
|
|
@@ -1084,7 +1211,7 @@ function renderToStream(code, options = {}) {
|
|
|
1084
1211
|
const registry = new Map();
|
|
1085
1212
|
const writeTasks = () => {
|
|
1086
1213
|
if (tasks.length && !completed && firstFlushed) {
|
|
1087
|
-
buffer.write(`<script${nonce
|
|
1214
|
+
buffer.write(`<script${nonceAttr(nonce, "script")}>${tasks}</script>`);
|
|
1088
1215
|
tasks = "";
|
|
1089
1216
|
}
|
|
1090
1217
|
timer = null;
|
|
@@ -1138,7 +1265,7 @@ function renderToStream(code, options = {}) {
|
|
|
1138
1265
|
};
|
|
1139
1266
|
solidJs.sharedConfig.context = context = {
|
|
1140
1267
|
async: true,
|
|
1141
|
-
nonce,
|
|
1268
|
+
nonce: options.nonce,
|
|
1142
1269
|
live: {},
|
|
1143
1270
|
registerHeadTags(tags) {
|
|
1144
1271
|
registerHeadTags(headRegistry, context, tracking,
|
|
@@ -1196,10 +1323,18 @@ function renderToStream(code, options = {}) {
|
|
|
1196
1323
|
},
|
|
1197
1324
|
serialize(id, p, deferStream) {
|
|
1198
1325
|
if (solidJs.sharedConfig.context.noHydrate) return;
|
|
1199
|
-
if (!firstFlushed &&
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1326
|
+
if (!firstFlushed && p && typeof p === "object" && "then" in p) {
|
|
1327
|
+
if (deferStream) {
|
|
1328
|
+
blockingPromises.add(p);
|
|
1329
|
+
p.then(d => serializer.write(id, d)).catch(e => serializer.write(id, e));
|
|
1330
|
+
return;
|
|
1331
|
+
}
|
|
1332
|
+
if (canBatchStubs && !shellCompleted) {
|
|
1333
|
+
(stubBatch ||= new Map()).set(id, p);
|
|
1334
|
+
return;
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
serializer.write(id, p);
|
|
1203
1338
|
},
|
|
1204
1339
|
escape: escape,
|
|
1205
1340
|
resolve: resolveSSRNode,
|
|
@@ -1233,7 +1368,7 @@ function renderToStream(code, options = {}) {
|
|
|
1233
1368
|
queue(flushEnd);
|
|
1234
1369
|
}))
|
|
1235
1370
|
});
|
|
1236
|
-
serializer.write(key + "_fr", p);
|
|
1371
|
+
if (canBatchStubs && !shellCompleted) (stubBatch ||= new Map()).set(key + "_fr", p);else serializer.write(key + "_fr", p);
|
|
1237
1372
|
}
|
|
1238
1373
|
return (value, error) => {
|
|
1239
1374
|
if (registry.has(key)) {
|
|
@@ -1264,7 +1399,7 @@ function renderToStream(code, options = {}) {
|
|
|
1264
1399
|
} else {
|
|
1265
1400
|
serializeFragmentAssets(key, tracking.boundaryModules, context);
|
|
1266
1401
|
const styles = collectStreamStyles(key, tracking, headStyles);
|
|
1267
|
-
const headOps = error ? null : flushHeadFragment(headRegistry, key);
|
|
1402
|
+
const headOps = error ? null : flushHeadFragment(headRegistry, key, nonce);
|
|
1268
1403
|
if (headOps) emitHeadOps(key, headOps);
|
|
1269
1404
|
sink.fragment(key, resolveSSRSelectValues(value !== undefined ? value : " "), {
|
|
1270
1405
|
styles,
|
|
@@ -1350,14 +1485,17 @@ function renderToStream(code, options = {}) {
|
|
|
1350
1485
|
function doShell() {
|
|
1351
1486
|
if (shellCompleted) return;
|
|
1352
1487
|
solidJs.sharedConfig.context = context;
|
|
1488
|
+
const blockersBefore = blockingPromises.size;
|
|
1353
1489
|
if (!resolveRootHoles()) return;
|
|
1490
|
+
if (blockingPromises.size !== blockersBefore) return;
|
|
1354
1491
|
if (!headShellReady(headRegistry, p => blockingPromises.add(p))) return;
|
|
1355
1492
|
headStyles = new Set();
|
|
1356
1493
|
for (const url of tracking.emittedAssets) {
|
|
1357
1494
|
if (isCssUrl(url)) headStyles.add(url);
|
|
1358
1495
|
}
|
|
1359
1496
|
serializeRootAssets();
|
|
1360
|
-
|
|
1497
|
+
flushStubBatch();
|
|
1498
|
+
const head = renderShellHead(headRegistry, nonce, k => registry.has(k), noScripts);
|
|
1361
1499
|
sink.shell(resolveSSRSelectValues(html), {
|
|
1362
1500
|
preloads: tracking.emittedAssets,
|
|
1363
1501
|
inlineStyles: tracking.inlineStyles,
|
|
@@ -1378,6 +1516,7 @@ function renderToStream(code, options = {}) {
|
|
|
1378
1516
|
let drainTurn = 0;
|
|
1379
1517
|
const scheduleFlush = fn => {
|
|
1380
1518
|
const attempt = () => {
|
|
1519
|
+
flushStubBatch();
|
|
1381
1520
|
if (registry.size !== lastRegistrySize || drainTurn++ < MIN_DRAIN_TURNS) {
|
|
1382
1521
|
if (registry.size !== lastRegistrySize) drainTurn = 0;
|
|
1383
1522
|
lastRegistrySize = registry.size;
|
|
@@ -1425,22 +1564,18 @@ function renderToStream(code, options = {}) {
|
|
|
1425
1564
|
}
|
|
1426
1565
|
};
|
|
1427
1566
|
writer.closed && writer.closed.catch(failed);
|
|
1428
|
-
writable = {
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
}
|
|
1437
|
-
};
|
|
1438
|
-
buffer = {
|
|
1439
|
-
write(payload) {
|
|
1440
|
-
pendingWrites = pendingWrites.then(() => writer.write(encoder.encode(payload))).catch(failed);
|
|
1441
|
-
}
|
|
1442
|
-
};
|
|
1567
|
+
buffer = writable = coalesceWrites(payload => {
|
|
1568
|
+
pendingWrites = pendingWrites.then(() => writer.write(encoder.encode(payload))).catch(failed);
|
|
1569
|
+
}, () => {
|
|
1570
|
+
pendingWrites.then(() => {
|
|
1571
|
+
ended = true;
|
|
1572
|
+
writer.releaseLock();
|
|
1573
|
+
w.close().catch(() => {});
|
|
1574
|
+
resolve();
|
|
1575
|
+
});
|
|
1576
|
+
});
|
|
1443
1577
|
buffer.write(tmp);
|
|
1578
|
+
buffer.flush();
|
|
1444
1579
|
firstFlushed = true;
|
|
1445
1580
|
if (completed) {
|
|
1446
1581
|
dispose();
|
|
@@ -1470,7 +1605,8 @@ function renderToStream(code, options = {}) {
|
|
|
1470
1605
|
allSettled(blockingPromises).then(() => {
|
|
1471
1606
|
scheduleFlush(() => {
|
|
1472
1607
|
try {
|
|
1473
|
-
|
|
1608
|
+
const blockersBefore = blockingPromises.size;
|
|
1609
|
+
if (!resolveRootHoles() || blockingPromises.size !== blockersBefore || !headShellReady(headRegistry, p => blockingPromises.add(p))) return flush();
|
|
1474
1610
|
} catch (err) {
|
|
1475
1611
|
failRender(err);
|
|
1476
1612
|
return resolve(tmp);
|
|
@@ -1499,8 +1635,10 @@ function renderToStream(code, options = {}) {
|
|
|
1499
1635
|
return;
|
|
1500
1636
|
}
|
|
1501
1637
|
if (!shellCompleted) return flush();
|
|
1502
|
-
|
|
1638
|
+
const sink = guardSink(w);
|
|
1639
|
+
buffer = writable = coalesceWrites(sink.write, sink.end);
|
|
1503
1640
|
buffer.write(tmp);
|
|
1641
|
+
buffer.flush();
|
|
1504
1642
|
firstFlushed = true;
|
|
1505
1643
|
if (completed) {
|
|
1506
1644
|
dispose();
|
|
@@ -1673,6 +1811,15 @@ function createLiveHoles(sink, scoped) {
|
|
|
1673
1811
|
const stamp = typeof solidJs.creationStamp === "function" ? solidJs.creationStamp : () => 0;
|
|
1674
1812
|
const inScope = scoped && typeof solidJs.inServerComponentScope === "function" ? solidJs.inServerComponentScope : null;
|
|
1675
1813
|
const stripMarkers = html => html.replace(/<!--lh:\/?\d+-->/g, "");
|
|
1814
|
+
const swept = (owner, ctx, fn) => {
|
|
1815
|
+
const prev = solidJs.sharedConfig.context;
|
|
1816
|
+
solidJs.sharedConfig.context = ctx;
|
|
1817
|
+
try {
|
|
1818
|
+
return owner ? solidJs.runWithOwner(owner, fn) : fn();
|
|
1819
|
+
} finally {
|
|
1820
|
+
solidJs.sharedConfig.context = prev;
|
|
1821
|
+
}
|
|
1822
|
+
};
|
|
1676
1823
|
function resolveHoleValue(hole) {
|
|
1677
1824
|
const result = {
|
|
1678
1825
|
t: [""],
|
|
@@ -1738,6 +1885,7 @@ function createLiveHoles(sink, scoped) {
|
|
|
1738
1885
|
const recordsBefore = engine.recordStamp;
|
|
1739
1886
|
const ownersBefore = stamp();
|
|
1740
1887
|
const owner = solidJs.getOwner();
|
|
1888
|
+
const holeCtx = solidJs.sharedConfig.context;
|
|
1741
1889
|
const b = {
|
|
1742
1890
|
key: null,
|
|
1743
1891
|
children: [],
|
|
@@ -1751,7 +1899,7 @@ function createLiveHoles(sink, scoped) {
|
|
|
1751
1899
|
const sweepOwnersBefore = stamp();
|
|
1752
1900
|
let res;
|
|
1753
1901
|
try {
|
|
1754
|
-
res =
|
|
1902
|
+
res = swept(owner, holeCtx, () => resolveHoleValue(hole));
|
|
1755
1903
|
} catch (err) {
|
|
1756
1904
|
b.closed = true;
|
|
1757
1905
|
sink.closeBinding(b.key);
|
|
@@ -1859,6 +2007,7 @@ function createLiveHoles(sink, scoped) {
|
|
|
1859
2007
|
},
|
|
1860
2008
|
attr(cap) {
|
|
1861
2009
|
const owner = solidJs.getOwner();
|
|
2010
|
+
const holeCtx = solidJs.sharedConfig.context;
|
|
1862
2011
|
const b = {
|
|
1863
2012
|
key: "lha:" + cap.id,
|
|
1864
2013
|
children: [],
|
|
@@ -1894,7 +2043,7 @@ function createLiveHoles(sink, scoped) {
|
|
|
1894
2043
|
if (vt === "string" || vt === "number") html += v;
|
|
1895
2044
|
}
|
|
1896
2045
|
};
|
|
1897
|
-
|
|
2046
|
+
swept(owner, holeCtx, run);
|
|
1898
2047
|
} catch (err) {
|
|
1899
2048
|
if (solidJs.ssrHandleError(err, true)) return;
|
|
1900
2049
|
b.closed = true;
|
|
@@ -2154,92 +2303,11 @@ function ssr(t) {
|
|
|
2154
2303
|
};
|
|
2155
2304
|
return result;
|
|
2156
2305
|
}
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
const SELECT_VALUE_ATTR = /\svalue="([^"]*)"/;
|
|
2161
|
-
function tagEnd(html, i) {
|
|
2162
|
-
for (let j = i + 1; j < html.length; j++) {
|
|
2163
|
-
const c = html.charCodeAt(j);
|
|
2164
|
-
if (c === 34) {
|
|
2165
|
-
j = html.indexOf('"', j + 1);
|
|
2166
|
-
if (j < 0) return -1;
|
|
2167
|
-
} else if (c === 62) return j;
|
|
2168
|
-
}
|
|
2169
|
-
return -1;
|
|
2170
|
-
}
|
|
2171
|
-
function optionText(html, from) {
|
|
2172
|
-
let t = "";
|
|
2173
|
-
let i = from;
|
|
2174
|
-
for (;;) {
|
|
2175
|
-
const lt = html.indexOf("<", i);
|
|
2176
|
-
if (lt < 0) return t + html.slice(i);
|
|
2177
|
-
t += html.slice(i, lt);
|
|
2178
|
-
if (!html.startsWith("<!--", lt)) return t;
|
|
2179
|
-
const ce = html.indexOf("-->", lt);
|
|
2180
|
-
if (ce < 0) return t;
|
|
2181
|
-
i = ce + 3;
|
|
2182
|
-
}
|
|
2183
|
-
}
|
|
2184
|
-
function tagIs(html, i, name) {
|
|
2185
|
-
if (!html.startsWith(name, i + 1)) return false;
|
|
2186
|
-
const c = html.charCodeAt(i + 1 + name.length);
|
|
2187
|
-
return c === 32 || c === 62 || c === 9 || c === 10 || c === 13;
|
|
2188
|
-
}
|
|
2306
|
+
const CLAIM_PROP = /*#__PURE__*/Symbol.for("solid.claim-prop");
|
|
2307
|
+
const CLAIMS_STREAM = 1;
|
|
2308
|
+
const CLAIMS_DOCUMENT = 2;
|
|
2189
2309
|
function resolveSSRSelectValues(html) {
|
|
2190
|
-
|
|
2191
|
-
let out = "";
|
|
2192
|
-
let idx = 0;
|
|
2193
|
-
let sel = null;
|
|
2194
|
-
let i = html.indexOf("<");
|
|
2195
|
-
while (i >= 0) {
|
|
2196
|
-
let e;
|
|
2197
|
-
if (html.charCodeAt(i + 1) === 33) {
|
|
2198
|
-
e = html.charCodeAt(i + 2) === 45 ? html.indexOf("-->", i) : html.indexOf(">", i);
|
|
2199
|
-
if (e < 0) break;
|
|
2200
|
-
if (html.charCodeAt(i + 2) === 45) e += 2;
|
|
2201
|
-
} else {
|
|
2202
|
-
e = tagEnd(html, i);
|
|
2203
|
-
if (e < 0) break;
|
|
2204
|
-
if (sel) {
|
|
2205
|
-
if (html.startsWith("</select>", i)) {
|
|
2206
|
-
out += html.slice(idx, sel.strip) + html.slice(sel.stripEnd, sel.body);
|
|
2207
|
-
let seg = sel.body;
|
|
2208
|
-
if (!sel.defaulted) {
|
|
2209
|
-
for (let k = 0; k < sel.marks.length; k++) {
|
|
2210
|
-
out += html.slice(seg, sel.marks[k]) + " selected";
|
|
2211
|
-
seg = sel.marks[k];
|
|
2212
|
-
}
|
|
2213
|
-
}
|
|
2214
|
-
out += html.slice(seg, i);
|
|
2215
|
-
idx = i;
|
|
2216
|
-
sel = null;
|
|
2217
|
-
} else if (tagIs(html, i, "option")) {
|
|
2218
|
-
const attrs = html.slice(i + 7, e);
|
|
2219
|
-
if (/\sselected(?=[\s=]|$)/.test(attrs)) sel.defaulted = true;else {
|
|
2220
|
-
const vm = SELECT_VALUE_ATTR.exec(attrs);
|
|
2221
|
-
const value = vm ? decodeSSREntities(vm[1]) : decodeSSREntities(optionText(html, e + 1)).replace(/\s+/g, " ").trim();
|
|
2222
|
-
if (sel.values.includes(value)) sel.marks.push(e);
|
|
2223
|
-
}
|
|
2224
|
-
}
|
|
2225
|
-
} else if (tagIs(html, i, "select")) {
|
|
2226
|
-
const m = SELECT_VALUE_ATTR.exec(html.slice(i, e + 1));
|
|
2227
|
-
if (m) {
|
|
2228
|
-
const bound = decodeSSREntities(m[1]);
|
|
2229
|
-
sel = {
|
|
2230
|
-
values: /\smultiple(?=[\s>=])/.test(html.slice(i, e + 1)) ? bound.split(",") : [bound],
|
|
2231
|
-
strip: i + m.index,
|
|
2232
|
-
stripEnd: i + m.index + m[0].length,
|
|
2233
|
-
body: e + 1,
|
|
2234
|
-
marks: [],
|
|
2235
|
-
defaulted: false
|
|
2236
|
-
};
|
|
2237
|
-
}
|
|
2238
|
-
}
|
|
2239
|
-
}
|
|
2240
|
-
i = html.indexOf("<", e + 1);
|
|
2241
|
-
}
|
|
2242
|
-
return out + html.slice(idx);
|
|
2310
|
+
return html;
|
|
2243
2311
|
}
|
|
2244
2312
|
function escape(s, attr) {
|
|
2245
2313
|
const t = typeof s;
|
|
@@ -2262,22 +2330,20 @@ function escape(s, attr) {
|
|
|
2262
2330
|
return escapeSlow(s, attr, i);
|
|
2263
2331
|
}
|
|
2264
2332
|
const ESCAPE_CONTENT = /[&<]/;
|
|
2265
|
-
const ESCAPE_ATTR = /[&"]/;
|
|
2333
|
+
const ESCAPE_ATTR = /[&"<]/;
|
|
2266
2334
|
function escapeSlow(s, attr, start) {
|
|
2267
|
-
|
|
2268
|
-
const delimCode = attr ? 34 : 60;
|
|
2269
|
-
const escDelim = attr ? """ : "<";
|
|
2335
|
+
if (attr) return escapeAttrSlow(s, start);
|
|
2270
2336
|
const c0 = s.charCodeAt(start);
|
|
2271
|
-
let iDelim = c0 ===
|
|
2337
|
+
let iDelim = c0 === 60 ? start : s.indexOf("<", start);
|
|
2272
2338
|
let iAmp = c0 === 38 ? start : s.indexOf("&", start);
|
|
2273
2339
|
let left = 0,
|
|
2274
2340
|
out = "";
|
|
2275
2341
|
while (iDelim >= 0 && iAmp >= 0) {
|
|
2276
2342
|
if (iDelim < iAmp) {
|
|
2277
2343
|
if (left < iDelim) out += s.substring(left, iDelim);
|
|
2278
|
-
out +=
|
|
2344
|
+
out += "<";
|
|
2279
2345
|
left = iDelim + 1;
|
|
2280
|
-
iDelim = s.indexOf(
|
|
2346
|
+
iDelim = s.indexOf("<", left);
|
|
2281
2347
|
} else {
|
|
2282
2348
|
if (left < iAmp) out += s.substring(left, iAmp);
|
|
2283
2349
|
out += "&";
|
|
@@ -2288,9 +2354,9 @@ function escapeSlow(s, attr, start) {
|
|
|
2288
2354
|
if (iDelim >= 0) {
|
|
2289
2355
|
do {
|
|
2290
2356
|
if (left < iDelim) out += s.substring(left, iDelim);
|
|
2291
|
-
out +=
|
|
2357
|
+
out += "<";
|
|
2292
2358
|
left = iDelim + 1;
|
|
2293
|
-
iDelim = s.indexOf(
|
|
2359
|
+
iDelim = s.indexOf("<", left);
|
|
2294
2360
|
} while (iDelim >= 0);
|
|
2295
2361
|
} else while (iAmp >= 0) {
|
|
2296
2362
|
if (left < iAmp) out += s.substring(left, iAmp);
|
|
@@ -2300,6 +2366,36 @@ function escapeSlow(s, attr, start) {
|
|
|
2300
2366
|
}
|
|
2301
2367
|
return left < s.length ? out + s.substring(left) : out;
|
|
2302
2368
|
}
|
|
2369
|
+
function escapeAttrSlow(s, start) {
|
|
2370
|
+
const c0 = s.charCodeAt(start);
|
|
2371
|
+
let iQuot = c0 === 34 ? start : s.indexOf('"', start);
|
|
2372
|
+
let iAmp = c0 === 38 ? start : s.indexOf("&", start);
|
|
2373
|
+
let iLt = c0 === 60 ? start : s.indexOf("<", start);
|
|
2374
|
+
let left = 0,
|
|
2375
|
+
out = "";
|
|
2376
|
+
for (;;) {
|
|
2377
|
+
let i = -1,
|
|
2378
|
+
ent;
|
|
2379
|
+
if (iQuot >= 0) {
|
|
2380
|
+
i = iQuot;
|
|
2381
|
+
ent = """;
|
|
2382
|
+
}
|
|
2383
|
+
if (iAmp >= 0 && (i < 0 || iAmp < i)) {
|
|
2384
|
+
i = iAmp;
|
|
2385
|
+
ent = "&";
|
|
2386
|
+
}
|
|
2387
|
+
if (iLt >= 0 && (i < 0 || iLt < i)) {
|
|
2388
|
+
i = iLt;
|
|
2389
|
+
ent = "<";
|
|
2390
|
+
}
|
|
2391
|
+
if (i < 0) break;
|
|
2392
|
+
if (left < i) out += s.substring(left, i);
|
|
2393
|
+
out += ent;
|
|
2394
|
+
left = i + 1;
|
|
2395
|
+
if (i === iQuot) iQuot = s.indexOf('"', left);else if (i === iAmp) iAmp = s.indexOf("&", left);else iLt = s.indexOf("<", left);
|
|
2396
|
+
}
|
|
2397
|
+
return left < s.length ? out + s.substring(left) : out;
|
|
2398
|
+
}
|
|
2303
2399
|
function tryJoinPlainSSRArray(nodes) {
|
|
2304
2400
|
if (nodes.length === 0) return undefined;
|
|
2305
2401
|
let out = "";
|
|
@@ -2315,6 +2411,7 @@ function tryJoinPlainSSRArray(nodes) {
|
|
|
2315
2411
|
function queue(fn) {
|
|
2316
2412
|
return Promise.resolve().then(fn);
|
|
2317
2413
|
}
|
|
2414
|
+
const deferFlush = typeof setImmediate === "function" ? setImmediate : fn => setTimeout(fn, 0);
|
|
2318
2415
|
function allSettled(promises) {
|
|
2319
2416
|
let size = promises.size;
|
|
2320
2417
|
return Promise.allSettled(promises).then(() => {
|
|
@@ -2323,10 +2420,11 @@ function allSettled(promises) {
|
|
|
2323
2420
|
});
|
|
2324
2421
|
}
|
|
2325
2422
|
function assembleDocument(html, emittedAssets, inlineStyles, scripts, nonce, headTags, onHead) {
|
|
2326
|
-
const scriptTag = scripts ? `<script${nonce
|
|
2327
|
-
const
|
|
2423
|
+
const scriptTag = scripts ? `<script${nonceAttr(nonce, "script")}>${scripts}</script>` : "";
|
|
2424
|
+
const title = headTags ? headTags.title : null;
|
|
2425
|
+
let headTagsHtml = headTags ? headTags.html : "";
|
|
2328
2426
|
const headPrelude = headTags ? headTags.prelude : "";
|
|
2329
|
-
if (!onHead && !headTagsHtml && !headPrelude && !(emittedAssets && emittedAssets.size) && !(inlineStyles && inlineStyles.size)) {
|
|
2427
|
+
if (!onHead && title == null && !headTagsHtml && !headPrelude && !(emittedAssets && emittedAssets.size) && !(inlineStyles && inlineStyles.size)) {
|
|
2330
2428
|
if (!scriptTag) return html;
|
|
2331
2429
|
const xs = html.indexOf("<!--xs-->");
|
|
2332
2430
|
return xs === -1 ? html + scriptTag : html.slice(0, xs) + scriptTag + html.slice(xs);
|
|
@@ -2338,15 +2436,33 @@ function assembleDocument(html, emittedAssets, inlineStyles, scripts, nonce, hea
|
|
|
2338
2436
|
html = html.slice(0, at) + headPrelude + html.slice(at);
|
|
2339
2437
|
}
|
|
2340
2438
|
}
|
|
2341
|
-
|
|
2439
|
+
let headIdx = html.indexOf("</head>");
|
|
2342
2440
|
if (headIdx === -1) {
|
|
2343
2441
|
if (onHead) {
|
|
2344
|
-
|
|
2442
|
+
let titleHtml = "";
|
|
2443
|
+
if (title != null) {
|
|
2444
|
+
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>`;
|
|
2445
|
+
}
|
|
2446
|
+
onHead(headPrelude + headTagsHtml + titleHtml + renderHeadAssets(emittedAssets, inlineStyles, nonce));
|
|
2345
2447
|
}
|
|
2346
2448
|
if (!scriptTag) return html;
|
|
2347
2449
|
const xs = html.indexOf("<!--xs-->");
|
|
2348
2450
|
return xs === -1 ? html + scriptTag : html.slice(0, xs) + scriptTag + html.slice(xs);
|
|
2349
2451
|
}
|
|
2452
|
+
if (title != null) {
|
|
2453
|
+
const winner = escape(title);
|
|
2454
|
+
const open = html.match(/<head(?:\s[^>]*)?>/);
|
|
2455
|
+
const from = open ? open.index + open[0].length : 0;
|
|
2456
|
+
const m = /<title(\s[^>]*)?>([\s\S]*?)<\/title>/.exec(html.slice(from, headIdx));
|
|
2457
|
+
if (m) {
|
|
2458
|
+
const at = from + m.index;
|
|
2459
|
+
const stash = m[2].replace(/"/g, """);
|
|
2460
|
+
html = html.slice(0, at) + `<title${m[1] || ""} data-dh="title" data-dhf="${stash}">${winner}</title>` + html.slice(at + m[0].length);
|
|
2461
|
+
headIdx = html.indexOf("</head>");
|
|
2462
|
+
} else {
|
|
2463
|
+
headTagsHtml = `<title data-dh="title">${winner}</title>` + headTagsHtml;
|
|
2464
|
+
}
|
|
2465
|
+
}
|
|
2350
2466
|
const head = headTagsHtml + renderHeadAssets(emittedAssets, inlineStyles, nonce);
|
|
2351
2467
|
if (!scriptTag) return html.slice(0, headIdx) + head + html.slice(headIdx);
|
|
2352
2468
|
const xsIdx = html.indexOf("<!--xs-->");
|
|
@@ -2355,9 +2471,11 @@ function assembleDocument(html, emittedAssets, inlineStyles, scripts, nonce, hea
|
|
|
2355
2471
|
}
|
|
2356
2472
|
function renderHeadAssets(emittedAssets, inlineStyles, nonce) {
|
|
2357
2473
|
let head = "";
|
|
2474
|
+
const styleAttr = nonceAttr(nonce, "style");
|
|
2475
|
+
const scriptAttr = nonceAttr(nonce, "script");
|
|
2358
2476
|
if (emittedAssets && emittedAssets.size) {
|
|
2359
2477
|
for (const url of emittedAssets) {
|
|
2360
|
-
head += isCssUrl(url) ? `<link rel="stylesheet" href="${url}">` : `<link rel="modulepreload" href="${url}">`;
|
|
2478
|
+
head += isCssUrl(url) ? `<link rel="stylesheet" href="${url}"${styleAttr}>` : `<link rel="modulepreload" href="${url}"${scriptAttr}>`;
|
|
2361
2479
|
}
|
|
2362
2480
|
}
|
|
2363
2481
|
if (inlineStyles && inlineStyles.size) {
|
|
@@ -2419,12 +2537,15 @@ function escapeStyleContent(content) {
|
|
|
2419
2537
|
}
|
|
2420
2538
|
function renderInlineStyle(entry, nonce) {
|
|
2421
2539
|
let attrs = "";
|
|
2540
|
+
let hasNonce = false;
|
|
2422
2541
|
if (entry.attrs) {
|
|
2423
2542
|
for (const name in entry.attrs) {
|
|
2543
|
+
if (name.length === 5 && asciiLowerCase(name) === "nonce") hasNonce = true;
|
|
2424
2544
|
attrs += ` ${name}="${escape(String(entry.attrs[name]), true)}"`;
|
|
2425
2545
|
}
|
|
2426
2546
|
}
|
|
2427
|
-
|
|
2547
|
+
const nonceHtml = hasNonce ? "" : nonceAttr(nonce, "style");
|
|
2548
|
+
return `<style${nonceHtml} data-asset="${escape(entry.id, true)}"${attrs}>${escapeStyleContent(entry.content)}</style>`;
|
|
2428
2549
|
}
|
|
2429
2550
|
function waitForFragments(registry, key) {
|
|
2430
2551
|
for (const k of [...registry.keys()].reverse()) {
|
|
@@ -2553,9 +2674,9 @@ const FRAME_STREAM_HEADER = "X-Frame-Stream";
|
|
|
2553
2674
|
function isFrameStreamResponse(response) {
|
|
2554
2675
|
return response.headers.has(FRAME_STREAM_HEADER);
|
|
2555
2676
|
}
|
|
2556
|
-
const SERVER_COMPONENT = /*#__PURE__*/Symbol.for("
|
|
2557
|
-
const SERVER_COMPONENT_SOURCE = /*#__PURE__*/Symbol.for("
|
|
2558
|
-
const SERVER_COMPONENT_ADDRESS = /*#__PURE__*/Symbol.for("
|
|
2677
|
+
const SERVER_COMPONENT = /*#__PURE__*/Symbol.for("solid.server-component");
|
|
2678
|
+
const SERVER_COMPONENT_SOURCE = /*#__PURE__*/Symbol.for("solid.server-component-source");
|
|
2679
|
+
const SERVER_COMPONENT_ADDRESS = /*#__PURE__*/Symbol.for("solid.server-component-address");
|
|
2559
2680
|
let serverComponentRegistryExpr;
|
|
2560
2681
|
function setServerComponentBootstrap(resolve) {
|
|
2561
2682
|
serverComponentRegistryExpr = resolve;
|
|
@@ -2567,7 +2688,7 @@ function parseServerComponent(value, ctx) {
|
|
|
2567
2688
|
};
|
|
2568
2689
|
}
|
|
2569
2690
|
const ServerComponentPlugin = {
|
|
2570
|
-
tag: "
|
|
2691
|
+
tag: "solid/server-component",
|
|
2571
2692
|
test(value) {
|
|
2572
2693
|
return typeof value === "function" && SERVER_COMPONENT in value;
|
|
2573
2694
|
},
|
|
@@ -2600,6 +2721,12 @@ function flightCodec(codec) {
|
|
|
2600
2721
|
};
|
|
2601
2722
|
}
|
|
2602
2723
|
|
|
2724
|
+
const runWithHydrationScope = (id, fn) => solidJs.runWithOwner(solidJs.createOwner({
|
|
2725
|
+
id
|
|
2726
|
+
}), fn);
|
|
2727
|
+
const ssrAsyncValue = value => solidJs.createMemo(() => value, {
|
|
2728
|
+
serialize: false
|
|
2729
|
+
});
|
|
2603
2730
|
const scopeStamp = typeof solidJs.creationStamp === "function" ? solidJs.creationStamp : () => 0;
|
|
2604
2731
|
function serverOwned(render) {
|
|
2605
2732
|
return solidJs.NoHydration ? solidJs.NoHydration({
|
|
@@ -2877,6 +3004,7 @@ function renderServerComponent(component, options = {}) {
|
|
|
2877
3004
|
ctx.commit = sink.commit;
|
|
2878
3005
|
ctx.commitEpoch = () => sink.epoch;
|
|
2879
3006
|
ctx.liveHoles = createLiveHoles(sink);
|
|
3007
|
+
ctx.claims = CLAIMS_STREAM;
|
|
2880
3008
|
}
|
|
2881
3009
|
return serverComponentScope(() => component(props));
|
|
2882
3010
|
};
|
|
@@ -3170,13 +3298,14 @@ function createDocumentSlotProps(clientProps, frameId) {
|
|
|
3170
3298
|
return out;
|
|
3171
3299
|
};
|
|
3172
3300
|
fn.$lhSkip = true;
|
|
3301
|
+
fn[CLAIM_PROP] = prop;
|
|
3173
3302
|
getters.set(prop, fn);
|
|
3174
3303
|
}
|
|
3175
3304
|
return fn;
|
|
3176
3305
|
}
|
|
3177
3306
|
});
|
|
3178
3307
|
}
|
|
3179
|
-
const FRAME_TAG = "
|
|
3308
|
+
const FRAME_TAG = "solid-frame";
|
|
3180
3309
|
const FRAME_ID_ATTR = "data-fid";
|
|
3181
3310
|
function frameElementOpen(id) {
|
|
3182
3311
|
const escaped = solidJs.sharedConfig.context ? solidJs.sharedConfig.context.escape(String(id), true) : String(id);
|
|
@@ -3301,6 +3430,7 @@ function frameTransformDirectResult(value, {
|
|
|
3301
3430
|
},
|
|
3302
3431
|
serverOwned(() => {
|
|
3303
3432
|
armDocumentLiveHoles(solidJs.sharedConfig.context);
|
|
3433
|
+
solidJs.sharedConfig.context.claims = CLAIMS_DOCUMENT;
|
|
3304
3434
|
const slotProps = createDocumentSlotProps(props, id);
|
|
3305
3435
|
return serverComponentScope(() => component(slotProps));
|
|
3306
3436
|
}), {
|
|
@@ -3544,6 +3674,7 @@ function createSlotProps(sink, frame) {
|
|
|
3544
3674
|
return slotRange(occurrence);
|
|
3545
3675
|
};
|
|
3546
3676
|
fn.$lhSkip = true;
|
|
3677
|
+
fn[CLAIM_PROP] = prop;
|
|
3547
3678
|
getters.set(prop, fn);
|
|
3548
3679
|
}
|
|
3549
3680
|
return fn;
|