@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/dist/server.cjs
CHANGED
|
@@ -57,14 +57,18 @@ const transparentOptions = {
|
|
|
57
57
|
const syncOptions = {
|
|
58
58
|
sync: true
|
|
59
59
|
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
function effect(fn, effectFn, options) {
|
|
61
|
+
solidJs.createRenderEffect(fn, effectFn, options ? {
|
|
62
|
+
sync: true,
|
|
63
|
+
...options,
|
|
64
|
+
transparent: !options.scope
|
|
65
|
+
} : transparentOptions);
|
|
66
|
+
}
|
|
67
|
+
function memo(fn) {
|
|
68
|
+
return solidJs.createMemo(() => fn(), syncOptions);
|
|
69
|
+
}
|
|
66
70
|
|
|
67
|
-
const STATE = Symbol.for("
|
|
71
|
+
const STATE = Symbol.for("solid.container-trace-state");
|
|
68
72
|
const state = globalThis[STATE] || (globalThis[STATE] = {
|
|
69
73
|
materialized: new WeakMap(),
|
|
70
74
|
materializedValues: new WeakSet()
|
|
@@ -72,7 +76,10 @@ const state = globalThis[STATE] || (globalThis[STATE] = {
|
|
|
72
76
|
function setContainerTraceResolver(fn) {
|
|
73
77
|
state.resolveTrace = fn;
|
|
74
78
|
}
|
|
75
|
-
|
|
79
|
+
function setContainerTraceStreamMint(fn) {
|
|
80
|
+
state.streamOf = fn;
|
|
81
|
+
}
|
|
82
|
+
const TRACE = Symbol.for("solid.container-trace");
|
|
76
83
|
function materialize(marker) {
|
|
77
84
|
let value = state.materialized.get(marker.$tr);
|
|
78
85
|
if (value === undefined) {
|
|
@@ -84,13 +91,14 @@ function materialize(marker) {
|
|
|
84
91
|
}
|
|
85
92
|
function parseTrace(value, ctx) {
|
|
86
93
|
const trace = value[TRACE];
|
|
94
|
+
const sub = trace.subscribe();
|
|
87
95
|
return {
|
|
88
96
|
a: trace.array ? 1 : 0,
|
|
89
|
-
i: ctx.parse(
|
|
97
|
+
i: ctx.parse(state.streamOf ? state.streamOf(sub) : sub)
|
|
90
98
|
};
|
|
91
99
|
}
|
|
92
100
|
const ContainerTracePlugin = {
|
|
93
|
-
tag: "
|
|
101
|
+
tag: "solid/container-trace",
|
|
94
102
|
test(value) {
|
|
95
103
|
return value != null && typeof value === "object" && TRACE in value;
|
|
96
104
|
},
|
|
@@ -100,9 +108,10 @@ const ContainerTracePlugin = {
|
|
|
100
108
|
},
|
|
101
109
|
async async(value, ctx) {
|
|
102
110
|
const trace = value[TRACE];
|
|
111
|
+
const sub = trace.subscribe();
|
|
103
112
|
return {
|
|
104
113
|
a: trace.array ? 1 : 0,
|
|
105
|
-
i: await ctx.parse(
|
|
114
|
+
i: await ctx.parse(state.streamOf ? state.streamOf(sub) : sub)
|
|
106
115
|
};
|
|
107
116
|
},
|
|
108
117
|
stream: parseTrace
|
|
@@ -120,6 +129,18 @@ const ContainerTracePlugin = {
|
|
|
120
129
|
}
|
|
121
130
|
};
|
|
122
131
|
|
|
132
|
+
setContainerTraceStreamMint(iterable => {
|
|
133
|
+
const stream = seroval.createStream();
|
|
134
|
+
(async () => {
|
|
135
|
+
try {
|
|
136
|
+
for await (const value of iterable) stream.next(value);
|
|
137
|
+
stream.return(undefined);
|
|
138
|
+
} catch (error) {
|
|
139
|
+
stream.throw(error);
|
|
140
|
+
}
|
|
141
|
+
})();
|
|
142
|
+
return stream;
|
|
143
|
+
});
|
|
123
144
|
const DEFAULT_WEB_PLUGINS = Object.freeze([web.AbortSignalPlugin,
|
|
124
145
|
web.CustomEventPlugin, web.DOMExceptionPlugin, web.EventPlugin,
|
|
125
146
|
web.FormDataPlugin, web.HeadersPlugin, web.ReadableStreamPlugin, web.RequestPlugin, web.ResponsePlugin, web.URLSearchParamsPlugin, web.URLPlugin,
|
|
@@ -193,11 +214,14 @@ function isSafeError(value) {
|
|
|
193
214
|
return !!(value && (typeof value === "object" || typeof value === "function") && value[SAFE_ERROR]);
|
|
194
215
|
}
|
|
195
216
|
const REVALIDATE_HEADER = "X-Revalidate";
|
|
196
|
-
function initWithRevalidate(init) {
|
|
217
|
+
function initWithRevalidate(init = {}) {
|
|
218
|
+
const resolved = typeof init === "number" ? {
|
|
219
|
+
status: init
|
|
220
|
+
} : init;
|
|
197
221
|
const {
|
|
198
222
|
revalidate,
|
|
199
223
|
...responseInit
|
|
200
|
-
} =
|
|
224
|
+
} = resolved;
|
|
201
225
|
let headers;
|
|
202
226
|
if (responseInit.headers && responseInit.headers.getSetCookie) {
|
|
203
227
|
headers = new Headers();
|
|
@@ -223,9 +247,7 @@ function redirect(url, init = 302) {
|
|
|
223
247
|
const {
|
|
224
248
|
responseInit,
|
|
225
249
|
headers
|
|
226
|
-
} = initWithRevalidate(
|
|
227
|
-
status: init
|
|
228
|
-
} : init);
|
|
250
|
+
} = initWithRevalidate(init);
|
|
229
251
|
if (responseInit.status === undefined) {
|
|
230
252
|
responseInit.status = 302;
|
|
231
253
|
}
|
|
@@ -442,6 +464,7 @@ function registerEntryAssets(manifest) {
|
|
|
442
464
|
const assets = resolveAssets(key, manifest);
|
|
443
465
|
if (assets) {
|
|
444
466
|
for (let i = 0; i < assets.css.length; i++) ctx.registerAsset("style", assets.css[i]);
|
|
467
|
+
for (let i = 1; i < assets.js.length; i++) ctx.registerAsset("module", assets.js[i]);
|
|
445
468
|
}
|
|
446
469
|
return;
|
|
447
470
|
}
|
|
@@ -701,7 +724,7 @@ function emitHeadResource(registry, context, tracking, emitResource, nonce, desc
|
|
|
701
724
|
if (!styles) tracking.boundaryStyles.set(tracking.currentBoundaryId, styles = new Set());
|
|
702
725
|
styles.add(entry);
|
|
703
726
|
}
|
|
704
|
-
const markup = `<link${attrHtml}>`;
|
|
727
|
+
const markup = `<link${attrHtml}${nonceAttr(nonce, "style")}>`;
|
|
705
728
|
if (emitResource) emitResource(markup, entry);else {
|
|
706
729
|
registry.eagerHtml += markup;
|
|
707
730
|
entry.emitted = true;
|
|
@@ -799,7 +822,7 @@ function headGroupSignature(winner) {
|
|
|
799
822
|
}
|
|
800
823
|
return sig;
|
|
801
824
|
}
|
|
802
|
-
function renderShellHead(registry, nonce, isPendingFragment) {
|
|
825
|
+
function renderShellHead(registry, nonce, isPendingFragment, noScripts) {
|
|
803
826
|
commitHeadBoundary(registry, "", isPendingFragment);
|
|
804
827
|
registry.shellFlushed = true;
|
|
805
828
|
const winners = resolveHead(registry.committed);
|
|
@@ -809,8 +832,14 @@ function renderShellHead(registry, nonce, isPendingFragment) {
|
|
|
809
832
|
let metas = "";
|
|
810
833
|
let others = "";
|
|
811
834
|
let scripts = "";
|
|
835
|
+
let title = null;
|
|
812
836
|
for (const [identity, winner] of winners) {
|
|
813
837
|
registry.flushed.set(identity, headGroupSignature(winner));
|
|
838
|
+
if (identity === "title") {
|
|
839
|
+
const children = winner.tags[0].props.children;
|
|
840
|
+
title = children == null ? "" : String(children);
|
|
841
|
+
continue;
|
|
842
|
+
}
|
|
814
843
|
for (let i = 0; i < winner.tags.length; i++) {
|
|
815
844
|
const t = winner.tags[i];
|
|
816
845
|
const markup = renderHeadTagMarkup(t.tag, t.props, identity, nonce);
|
|
@@ -819,10 +848,12 @@ function renderShellHead(registry, nonce, isPendingFragment) {
|
|
|
819
848
|
}
|
|
820
849
|
return {
|
|
821
850
|
prelude,
|
|
822
|
-
html: registry.eagerHtml + links + metas + others + scripts
|
|
851
|
+
html: registry.eagerHtml + links + metas + others + scripts,
|
|
852
|
+
title,
|
|
853
|
+
noScripts
|
|
823
854
|
};
|
|
824
855
|
}
|
|
825
|
-
function flushHeadFragment(registry, boundary) {
|
|
856
|
+
function flushHeadFragment(registry, boundary, nonce) {
|
|
826
857
|
const groups = commitHeadBoundary(registry, boundary);
|
|
827
858
|
if (!groups.length) return null;
|
|
828
859
|
const winners = resolveHead(registry.committed);
|
|
@@ -853,12 +884,87 @@ function flushHeadFragment(registry, boundary) {
|
|
|
853
884
|
if (v == null || v === false) continue;
|
|
854
885
|
attrs[name] = v === true ? "" : String(v);
|
|
855
886
|
}
|
|
887
|
+
if (nonce && !hasNonceProp(t.props)) {
|
|
888
|
+
const destination = nonceDestination(t.tag, t.props);
|
|
889
|
+
const value = destination && nonce[destination];
|
|
890
|
+
if (value) attrs.nonce = String(value);
|
|
891
|
+
}
|
|
856
892
|
const children = t.props.children;
|
|
857
893
|
ops.push(["a", identity, t.tag, attrs, children == null ? null : String(children)]);
|
|
858
894
|
}
|
|
859
895
|
}
|
|
860
896
|
return ops.length ? ops : null;
|
|
861
897
|
}
|
|
898
|
+
function normalizeNonce(nonce) {
|
|
899
|
+
if (nonce == null) return undefined;
|
|
900
|
+
if (typeof nonce === "string") {
|
|
901
|
+
const attr = nonce ? ` nonce="${escape(nonce, true)}"` : "";
|
|
902
|
+
return {
|
|
903
|
+
script: nonce,
|
|
904
|
+
style: nonce,
|
|
905
|
+
scriptAttr: attr,
|
|
906
|
+
styleAttr: attr
|
|
907
|
+
};
|
|
908
|
+
}
|
|
909
|
+
const script = nonce.script;
|
|
910
|
+
const style = nonce.style;
|
|
911
|
+
if (!script && !style) return undefined;
|
|
912
|
+
return {
|
|
913
|
+
script,
|
|
914
|
+
style,
|
|
915
|
+
scriptAttr: typeof script === "string" && script ? ` nonce="${escape(script, true)}"` : "",
|
|
916
|
+
styleAttr: typeof style === "string" && style ? ` nonce="${escape(style, true)}"` : ""
|
|
917
|
+
};
|
|
918
|
+
}
|
|
919
|
+
function destinationNonce(nonce, destination) {
|
|
920
|
+
if (nonce == null) return undefined;
|
|
921
|
+
if (typeof nonce === "string") return nonce || undefined;
|
|
922
|
+
const value = nonce[destination];
|
|
923
|
+
return typeof value === "string" && value ? value : undefined;
|
|
924
|
+
}
|
|
925
|
+
function scriptNonce(nonce) {
|
|
926
|
+
return destinationNonce(nonce, "script");
|
|
927
|
+
}
|
|
928
|
+
function styleNonce(nonce) {
|
|
929
|
+
return destinationNonce(nonce, "style");
|
|
930
|
+
}
|
|
931
|
+
function asciiLowerCase(value) {
|
|
932
|
+
return value.replace(/[A-Z]/g, c => String.fromCharCode(c.charCodeAt(0) + 32));
|
|
933
|
+
}
|
|
934
|
+
function hasNonceProp(props) {
|
|
935
|
+
for (const name in props) if (name.length === 5 && asciiLowerCase(name) === "nonce" && props[name] != null) return true;
|
|
936
|
+
return false;
|
|
937
|
+
}
|
|
938
|
+
function nonceDestination(tag, props) {
|
|
939
|
+
if (tag === "script") return "script";
|
|
940
|
+
if (tag === "style") return "style";
|
|
941
|
+
if (tag !== "link") return null;
|
|
942
|
+
const rel = props.rel;
|
|
943
|
+
if (typeof rel !== "string") return null;
|
|
944
|
+
const rels = asciiLowerCase(rel).split(/[\t\n\f\r ]+/);
|
|
945
|
+
if (rels.includes("stylesheet")) return "style";
|
|
946
|
+
const isModulePreload = rels.includes("modulepreload");
|
|
947
|
+
if (!isModulePreload && !rels.includes("preload")) return null;
|
|
948
|
+
const as = typeof props.as === "string" ? asciiLowerCase(props.as) : "";
|
|
949
|
+
if (as === "style") return "style";
|
|
950
|
+
if (as === "script") return "script";
|
|
951
|
+
if (!isModulePreload) return null;
|
|
952
|
+
switch (as) {
|
|
953
|
+
case "fetch":
|
|
954
|
+
case "font":
|
|
955
|
+
case "image":
|
|
956
|
+
case "json":
|
|
957
|
+
case "text":
|
|
958
|
+
case "track":
|
|
959
|
+
return null;
|
|
960
|
+
default:
|
|
961
|
+
return "script";
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
function nonceAttr(nonce, destination) {
|
|
965
|
+
if (!nonce || !destination) return "";
|
|
966
|
+
return destination === "script" ? nonce.scriptAttr : nonce.styleAttr;
|
|
967
|
+
}
|
|
862
968
|
function renderHeadAttrHtml(props) {
|
|
863
969
|
let attrs = "";
|
|
864
970
|
for (const name in props) {
|
|
@@ -887,7 +993,7 @@ function headAttrRecord(props, skipRelHref) {
|
|
|
887
993
|
function renderHeadTagMarkup(tag, props, identity, nonce) {
|
|
888
994
|
let attrs = renderHeadAttrHtml(props);
|
|
889
995
|
if (identity != null) attrs += ` data-dh="${escape(identity, true)}"`;
|
|
890
|
-
if (nonce && (
|
|
996
|
+
if (nonce && !hasNonceProp(props)) attrs += nonceAttr(nonce, nonceDestination(tag, props));
|
|
891
997
|
if (tag === "meta" || tag === "link" || tag === "base") return `<${tag}${attrs}>`;
|
|
892
998
|
let body = props.children == null ? "" : String(props.children);
|
|
893
999
|
if (tag === "script") body = body.replace(/<\/(script)/gi, "<\\/$1");else if (tag === "style") body = escapeStyleContent(body);else body = escape(body);
|
|
@@ -902,15 +1008,15 @@ function useHead(tags) {
|
|
|
902
1008
|
}
|
|
903
1009
|
const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
|
|
904
1010
|
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])}`;
|
|
905
|
-
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)}`;
|
|
1011
|
+
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)}`;
|
|
906
1012
|
function renderToString(code, options = {}) {
|
|
907
1013
|
const {
|
|
908
1014
|
renderId = "",
|
|
909
|
-
nonce,
|
|
910
1015
|
noScripts,
|
|
911
1016
|
manifest,
|
|
912
1017
|
onHead
|
|
913
1018
|
} = options;
|
|
1019
|
+
const nonce = normalizeNonce(options.nonce);
|
|
914
1020
|
let scripts = "";
|
|
915
1021
|
const serializer = createHydrationSerializer({
|
|
916
1022
|
scopeId: renderId,
|
|
@@ -927,7 +1033,7 @@ function renderToString(code, options = {}) {
|
|
|
927
1033
|
const tracking = createAssetTracking();
|
|
928
1034
|
const headRegistry = createHeadRegistry();
|
|
929
1035
|
solidJs.sharedConfig.context = {
|
|
930
|
-
nonce,
|
|
1036
|
+
nonce: options.nonce,
|
|
931
1037
|
escape: escape,
|
|
932
1038
|
resolve: resolveSSRNode,
|
|
933
1039
|
ssr: ssr,
|
|
@@ -968,12 +1074,11 @@ function renderToString(code, options = {}) {
|
|
|
968
1074
|
serializeFragmentAssets("", tracking.boundaryModules, solidJs.sharedConfig.context, renderId);
|
|
969
1075
|
solidJs.sharedConfig.context.noHydrate = true;
|
|
970
1076
|
serializer.close();
|
|
971
|
-
const head = renderShellHead(headRegistry, nonce, null);
|
|
1077
|
+
const head = renderShellHead(headRegistry, nonce, null, noScripts);
|
|
972
1078
|
return assembleDocument(resolveSSRSelectValues(html), tracking.emittedAssets, tracking.inlineStyles, scripts.length ? scripts : "", nonce, head, onHead);
|
|
973
1079
|
}
|
|
974
1080
|
function renderToStream(code, options = {}) {
|
|
975
1081
|
let {
|
|
976
|
-
nonce,
|
|
977
1082
|
onCompleteShell,
|
|
978
1083
|
onCompleteAll,
|
|
979
1084
|
renderId = "",
|
|
@@ -981,6 +1086,7 @@ function renderToStream(code, options = {}) {
|
|
|
981
1086
|
manifest,
|
|
982
1087
|
onHead
|
|
983
1088
|
} = options;
|
|
1089
|
+
const nonce = normalizeNonce(options.nonce);
|
|
984
1090
|
let dispose;
|
|
985
1091
|
let dead = false;
|
|
986
1092
|
const abandon = () => {
|
|
@@ -1005,6 +1111,32 @@ function renderToStream(code, options = {}) {
|
|
|
1005
1111
|
} catch (_) {}
|
|
1006
1112
|
abandon();
|
|
1007
1113
|
};
|
|
1114
|
+
const coalesceWrites = (writeRaw, endRaw) => {
|
|
1115
|
+
let buf = "";
|
|
1116
|
+
let scheduled = false;
|
|
1117
|
+
const flush = () => {
|
|
1118
|
+
scheduled = false;
|
|
1119
|
+
if (!buf) return;
|
|
1120
|
+
const out = buf;
|
|
1121
|
+
buf = "";
|
|
1122
|
+
writeRaw(out);
|
|
1123
|
+
};
|
|
1124
|
+
return {
|
|
1125
|
+
write(payload) {
|
|
1126
|
+
buf += payload;
|
|
1127
|
+
if (buf.length >= 16384) return flush();
|
|
1128
|
+
if (!scheduled) {
|
|
1129
|
+
scheduled = true;
|
|
1130
|
+
deferFlush(flush);
|
|
1131
|
+
}
|
|
1132
|
+
},
|
|
1133
|
+
flush,
|
|
1134
|
+
end() {
|
|
1135
|
+
flush();
|
|
1136
|
+
endRaw();
|
|
1137
|
+
}
|
|
1138
|
+
};
|
|
1139
|
+
};
|
|
1008
1140
|
const guardSink = w => ({
|
|
1009
1141
|
write(payload) {
|
|
1010
1142
|
if (dead) return;
|
|
@@ -1024,6 +1156,23 @@ function renderToStream(code, options = {}) {
|
|
|
1024
1156
|
}
|
|
1025
1157
|
});
|
|
1026
1158
|
const blockingPromises = new Set();
|
|
1159
|
+
const canBatchStubs = !options.serializer && !options.sink;
|
|
1160
|
+
let stubBatch = null;
|
|
1161
|
+
const STUB_BATCH_KEY = "$B";
|
|
1162
|
+
const flushStubBatch = () => {
|
|
1163
|
+
if (!stubBatch) return;
|
|
1164
|
+
const batch = stubBatch;
|
|
1165
|
+
stubBatch = null;
|
|
1166
|
+
if (batch.size === 1) {
|
|
1167
|
+
const [id, p] = batch.entries().next().value;
|
|
1168
|
+
serializer.write(id, p);
|
|
1169
|
+
return;
|
|
1170
|
+
}
|
|
1171
|
+
const obj = {};
|
|
1172
|
+
for (const [id, p] of batch) obj[id] = p;
|
|
1173
|
+
serializer.write(STUB_BATCH_KEY, obj);
|
|
1174
|
+
pushTask(`(b=>{for(var k in b)_$HY.r[k]=b[k];delete _$HY.r["${STUB_BATCH_KEY}"]})(_$HY.r["${STUB_BATCH_KEY}"])`);
|
|
1175
|
+
};
|
|
1027
1176
|
let headerEmitted = false;
|
|
1028
1177
|
const pushTask = task => {
|
|
1029
1178
|
if (noScripts) return;
|
|
@@ -1060,10 +1209,11 @@ function renderToStream(code, options = {}) {
|
|
|
1060
1209
|
buffer.write(renderInlineStyle(styles.inline[i], nonce));
|
|
1061
1210
|
}
|
|
1062
1211
|
if (styles.links.length) {
|
|
1212
|
+
const styleAttr = nonceAttr(nonce, "style");
|
|
1063
1213
|
emitTask(`$dfs("${key}",${styles.links.length},${deferActivation ? 1 : 0})`);
|
|
1064
1214
|
writeTasks();
|
|
1065
1215
|
for (const entry of styles.links) {
|
|
1066
|
-
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}')">`);
|
|
1216
|
+
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}')">`);
|
|
1067
1217
|
}
|
|
1068
1218
|
buffer.write(`<template id="${key}">${value}</template>`);
|
|
1069
1219
|
} else {
|
|
@@ -1078,7 +1228,7 @@ function renderToStream(code, options = {}) {
|
|
|
1078
1228
|
},
|
|
1079
1229
|
asset(type, value) {
|
|
1080
1230
|
if (type === "module") {
|
|
1081
|
-
buffer.write(`<link rel="modulepreload" href="${value}">`);
|
|
1231
|
+
buffer.write(`<link rel="modulepreload" href="${value}"${nonceAttr(nonce, "script")}>`);
|
|
1082
1232
|
} else if (type === "inline-style") {
|
|
1083
1233
|
buffer.write(renderInlineStyle(value, nonce));
|
|
1084
1234
|
} else if (type === "head-tag") {
|
|
@@ -1113,6 +1263,7 @@ function renderToStream(code, options = {}) {
|
|
|
1113
1263
|
context.live.end = null;
|
|
1114
1264
|
end();
|
|
1115
1265
|
}
|
|
1266
|
+
flushStubBatch();
|
|
1116
1267
|
serializer.flush();
|
|
1117
1268
|
}));
|
|
1118
1269
|
}
|
|
@@ -1120,7 +1271,7 @@ function renderToStream(code, options = {}) {
|
|
|
1120
1271
|
const registry = new Map();
|
|
1121
1272
|
const writeTasks = () => {
|
|
1122
1273
|
if (tasks.length && !completed && firstFlushed) {
|
|
1123
|
-
buffer.write(`<script${nonce
|
|
1274
|
+
buffer.write(`<script${nonceAttr(nonce, "script")}>${tasks}</script>`);
|
|
1124
1275
|
tasks = "";
|
|
1125
1276
|
}
|
|
1126
1277
|
timer = null;
|
|
@@ -1174,7 +1325,7 @@ function renderToStream(code, options = {}) {
|
|
|
1174
1325
|
};
|
|
1175
1326
|
solidJs.sharedConfig.context = context = {
|
|
1176
1327
|
async: true,
|
|
1177
|
-
nonce,
|
|
1328
|
+
nonce: options.nonce,
|
|
1178
1329
|
live: {},
|
|
1179
1330
|
registerHeadTags(tags) {
|
|
1180
1331
|
registerHeadTags(headRegistry, context, tracking,
|
|
@@ -1232,10 +1383,18 @@ function renderToStream(code, options = {}) {
|
|
|
1232
1383
|
},
|
|
1233
1384
|
serialize(id, p, deferStream) {
|
|
1234
1385
|
if (solidJs.sharedConfig.context.noHydrate) return;
|
|
1235
|
-
if (!firstFlushed &&
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1386
|
+
if (!firstFlushed && p && typeof p === "object" && "then" in p) {
|
|
1387
|
+
if (deferStream) {
|
|
1388
|
+
blockingPromises.add(p);
|
|
1389
|
+
p.then(d => serializer.write(id, d)).catch(e => serializer.write(id, e));
|
|
1390
|
+
return;
|
|
1391
|
+
}
|
|
1392
|
+
if (canBatchStubs && !shellCompleted) {
|
|
1393
|
+
(stubBatch ||= new Map()).set(id, p);
|
|
1394
|
+
return;
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
serializer.write(id, p);
|
|
1239
1398
|
},
|
|
1240
1399
|
escape: escape,
|
|
1241
1400
|
resolve: resolveSSRNode,
|
|
@@ -1269,7 +1428,7 @@ function renderToStream(code, options = {}) {
|
|
|
1269
1428
|
queue(flushEnd);
|
|
1270
1429
|
}))
|
|
1271
1430
|
});
|
|
1272
|
-
serializer.write(key + "_fr", p);
|
|
1431
|
+
if (canBatchStubs && !shellCompleted) (stubBatch ||= new Map()).set(key + "_fr", p);else serializer.write(key + "_fr", p);
|
|
1273
1432
|
}
|
|
1274
1433
|
return (value, error) => {
|
|
1275
1434
|
if (registry.has(key)) {
|
|
@@ -1300,7 +1459,7 @@ function renderToStream(code, options = {}) {
|
|
|
1300
1459
|
} else {
|
|
1301
1460
|
serializeFragmentAssets(key, tracking.boundaryModules, context);
|
|
1302
1461
|
const styles = collectStreamStyles(key, tracking, headStyles);
|
|
1303
|
-
const headOps = error ? null : flushHeadFragment(headRegistry, key);
|
|
1462
|
+
const headOps = error ? null : flushHeadFragment(headRegistry, key, nonce);
|
|
1304
1463
|
if (headOps) emitHeadOps(key, headOps);
|
|
1305
1464
|
sink.fragment(key, resolveSSRSelectValues(value !== undefined ? value : " "), {
|
|
1306
1465
|
styles,
|
|
@@ -1386,14 +1545,17 @@ function renderToStream(code, options = {}) {
|
|
|
1386
1545
|
function doShell() {
|
|
1387
1546
|
if (shellCompleted) return;
|
|
1388
1547
|
solidJs.sharedConfig.context = context;
|
|
1548
|
+
const blockersBefore = blockingPromises.size;
|
|
1389
1549
|
if (!resolveRootHoles()) return;
|
|
1550
|
+
if (blockingPromises.size !== blockersBefore) return;
|
|
1390
1551
|
if (!headShellReady(headRegistry, p => blockingPromises.add(p))) return;
|
|
1391
1552
|
headStyles = new Set();
|
|
1392
1553
|
for (const url of tracking.emittedAssets) {
|
|
1393
1554
|
if (isCssUrl(url)) headStyles.add(url);
|
|
1394
1555
|
}
|
|
1395
1556
|
serializeRootAssets();
|
|
1396
|
-
|
|
1557
|
+
flushStubBatch();
|
|
1558
|
+
const head = renderShellHead(headRegistry, nonce, k => registry.has(k), noScripts);
|
|
1397
1559
|
sink.shell(resolveSSRSelectValues(html), {
|
|
1398
1560
|
preloads: tracking.emittedAssets,
|
|
1399
1561
|
inlineStyles: tracking.inlineStyles,
|
|
@@ -1414,6 +1576,7 @@ function renderToStream(code, options = {}) {
|
|
|
1414
1576
|
let drainTurn = 0;
|
|
1415
1577
|
const scheduleFlush = fn => {
|
|
1416
1578
|
const attempt = () => {
|
|
1579
|
+
flushStubBatch();
|
|
1417
1580
|
if (registry.size !== lastRegistrySize || drainTurn++ < MIN_DRAIN_TURNS) {
|
|
1418
1581
|
if (registry.size !== lastRegistrySize) drainTurn = 0;
|
|
1419
1582
|
lastRegistrySize = registry.size;
|
|
@@ -1461,22 +1624,18 @@ function renderToStream(code, options = {}) {
|
|
|
1461
1624
|
}
|
|
1462
1625
|
};
|
|
1463
1626
|
writer.closed && writer.closed.catch(failed);
|
|
1464
|
-
writable = {
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
}
|
|
1473
|
-
};
|
|
1474
|
-
buffer = {
|
|
1475
|
-
write(payload) {
|
|
1476
|
-
pendingWrites = pendingWrites.then(() => writer.write(encoder.encode(payload))).catch(failed);
|
|
1477
|
-
}
|
|
1478
|
-
};
|
|
1627
|
+
buffer = writable = coalesceWrites(payload => {
|
|
1628
|
+
pendingWrites = pendingWrites.then(() => writer.write(encoder.encode(payload))).catch(failed);
|
|
1629
|
+
}, () => {
|
|
1630
|
+
pendingWrites.then(() => {
|
|
1631
|
+
ended = true;
|
|
1632
|
+
writer.releaseLock();
|
|
1633
|
+
w.close().catch(() => {});
|
|
1634
|
+
resolve();
|
|
1635
|
+
});
|
|
1636
|
+
});
|
|
1479
1637
|
buffer.write(tmp);
|
|
1638
|
+
buffer.flush();
|
|
1480
1639
|
firstFlushed = true;
|
|
1481
1640
|
if (completed) {
|
|
1482
1641
|
dispose();
|
|
@@ -1506,7 +1665,8 @@ function renderToStream(code, options = {}) {
|
|
|
1506
1665
|
allSettled(blockingPromises).then(() => {
|
|
1507
1666
|
scheduleFlush(() => {
|
|
1508
1667
|
try {
|
|
1509
|
-
|
|
1668
|
+
const blockersBefore = blockingPromises.size;
|
|
1669
|
+
if (!resolveRootHoles() || blockingPromises.size !== blockersBefore || !headShellReady(headRegistry, p => blockingPromises.add(p))) return flush();
|
|
1510
1670
|
} catch (err) {
|
|
1511
1671
|
failRender(err);
|
|
1512
1672
|
return resolve(tmp);
|
|
@@ -1535,8 +1695,10 @@ function renderToStream(code, options = {}) {
|
|
|
1535
1695
|
return;
|
|
1536
1696
|
}
|
|
1537
1697
|
if (!shellCompleted) return flush();
|
|
1538
|
-
|
|
1698
|
+
const sink = guardSink(w);
|
|
1699
|
+
buffer = writable = coalesceWrites(sink.write, sink.end);
|
|
1539
1700
|
buffer.write(tmp);
|
|
1701
|
+
buffer.flush();
|
|
1540
1702
|
firstFlushed = true;
|
|
1541
1703
|
if (completed) {
|
|
1542
1704
|
dispose();
|
|
@@ -1563,9 +1725,7 @@ function renderToStream(code, options = {}) {
|
|
|
1563
1725
|
};
|
|
1564
1726
|
}
|
|
1565
1727
|
function HydrationScript(props) {
|
|
1566
|
-
const
|
|
1567
|
-
nonce
|
|
1568
|
-
} = solidJs.sharedConfig.context;
|
|
1728
|
+
const nonce = scriptNonce(solidJs.sharedConfig.context && solidJs.sharedConfig.context.nonce);
|
|
1569
1729
|
return ssr(generateHydrationScript({
|
|
1570
1730
|
nonce,
|
|
1571
1731
|
...props
|
|
@@ -1722,6 +1882,15 @@ function createLiveHoles(sink, scoped) {
|
|
|
1722
1882
|
const stamp = typeof solidJs.creationStamp === "function" ? solidJs.creationStamp : () => 0;
|
|
1723
1883
|
const inScope = scoped && typeof solidJs.inServerComponentScope === "function" ? solidJs.inServerComponentScope : null;
|
|
1724
1884
|
const stripMarkers = html => html.replace(/<!--lh:\/?\d+-->/g, "");
|
|
1885
|
+
const swept = (owner, ctx, fn) => {
|
|
1886
|
+
const prev = solidJs.sharedConfig.context;
|
|
1887
|
+
solidJs.sharedConfig.context = ctx;
|
|
1888
|
+
try {
|
|
1889
|
+
return owner ? solidJs.runWithOwner(owner, fn) : fn();
|
|
1890
|
+
} finally {
|
|
1891
|
+
solidJs.sharedConfig.context = prev;
|
|
1892
|
+
}
|
|
1893
|
+
};
|
|
1725
1894
|
function resolveHoleValue(hole) {
|
|
1726
1895
|
const result = {
|
|
1727
1896
|
t: [""],
|
|
@@ -1787,6 +1956,7 @@ function createLiveHoles(sink, scoped) {
|
|
|
1787
1956
|
const recordsBefore = engine.recordStamp;
|
|
1788
1957
|
const ownersBefore = stamp();
|
|
1789
1958
|
const owner = solidJs.getOwner();
|
|
1959
|
+
const holeCtx = solidJs.sharedConfig.context;
|
|
1790
1960
|
const b = {
|
|
1791
1961
|
key: null,
|
|
1792
1962
|
children: [],
|
|
@@ -1800,7 +1970,7 @@ function createLiveHoles(sink, scoped) {
|
|
|
1800
1970
|
const sweepOwnersBefore = stamp();
|
|
1801
1971
|
let res;
|
|
1802
1972
|
try {
|
|
1803
|
-
res =
|
|
1973
|
+
res = swept(owner, holeCtx, () => resolveHoleValue(hole));
|
|
1804
1974
|
} catch (err) {
|
|
1805
1975
|
b.closed = true;
|
|
1806
1976
|
sink.closeBinding(b.key);
|
|
@@ -1908,6 +2078,7 @@ function createLiveHoles(sink, scoped) {
|
|
|
1908
2078
|
},
|
|
1909
2079
|
attr(cap) {
|
|
1910
2080
|
const owner = solidJs.getOwner();
|
|
2081
|
+
const holeCtx = solidJs.sharedConfig.context;
|
|
1911
2082
|
const b = {
|
|
1912
2083
|
key: "lha:" + cap.id,
|
|
1913
2084
|
children: [],
|
|
@@ -1943,7 +2114,7 @@ function createLiveHoles(sink, scoped) {
|
|
|
1943
2114
|
if (vt === "string" || vt === "number") html += v;
|
|
1944
2115
|
}
|
|
1945
2116
|
};
|
|
1946
|
-
|
|
2117
|
+
swept(owner, holeCtx, run);
|
|
1947
2118
|
} catch (err) {
|
|
1948
2119
|
if (solidJs.ssrHandleError(err, true)) return;
|
|
1949
2120
|
b.closed = true;
|
|
@@ -2279,6 +2450,32 @@ function ssrHydrationKey() {
|
|
|
2279
2450
|
const hk = getHydrationKey();
|
|
2280
2451
|
return hk ? ` _hk=${hk}` : "";
|
|
2281
2452
|
}
|
|
2453
|
+
const CLAIM_PROP = /*#__PURE__*/Symbol.for("solid.claim-prop");
|
|
2454
|
+
const CLAIMS_STREAM = 1;
|
|
2455
|
+
const CLAIMS_DOCUMENT = 2;
|
|
2456
|
+
const CLAIM_UNSAFE = /[^A-Za-z0-9_.!~*'()-]/g;
|
|
2457
|
+
function encodeClaimKey(key) {
|
|
2458
|
+
return String(key).replace(CLAIM_UNSAFE, c => encodeURIComponent(c));
|
|
2459
|
+
}
|
|
2460
|
+
function ssrClaim(map) {
|
|
2461
|
+
const mode = solidJs.sharedConfig.context && solidJs.sharedConfig.context.claims;
|
|
2462
|
+
if (!mode || mode === CLAIMS_DOCUMENT && !(typeof solidJs.inServerComponentScope === "function" && solidJs.inServerComponentScope())) {
|
|
2463
|
+
return "";
|
|
2464
|
+
}
|
|
2465
|
+
let out = "";
|
|
2466
|
+
for (const pos in map) {
|
|
2467
|
+
const value = map[pos];
|
|
2468
|
+
const list = Array.isArray(value) ? value : [value];
|
|
2469
|
+
for (const fn of list) {
|
|
2470
|
+
const prop = typeof fn === "function" && fn[CLAIM_PROP] || undefined;
|
|
2471
|
+
if (prop === undefined) {
|
|
2472
|
+
continue;
|
|
2473
|
+
}
|
|
2474
|
+
out += `${out ? "," : ""}${pos}=${encodeClaimKey(prop)}`;
|
|
2475
|
+
}
|
|
2476
|
+
}
|
|
2477
|
+
return out ? ` _bnd="${out}"` : "";
|
|
2478
|
+
}
|
|
2282
2479
|
function decodeSSREntities(s) {
|
|
2283
2480
|
return s.indexOf("&") < 0 ? s : s.replace(/"/g, '"').replace(/</g, "<").replace(/&/g, "&");
|
|
2284
2481
|
}
|
|
@@ -2311,22 +2508,49 @@ function tagIs(html, i, name) {
|
|
|
2311
2508
|
const c = html.charCodeAt(i + 1 + name.length);
|
|
2312
2509
|
return c === 32 || c === 62 || c === 9 || c === 10 || c === 13;
|
|
2313
2510
|
}
|
|
2511
|
+
let selectValuesActive = false;
|
|
2512
|
+
function ssrSelectValues() {
|
|
2513
|
+
selectValuesActive = true;
|
|
2514
|
+
}
|
|
2314
2515
|
function resolveSSRSelectValues(html) {
|
|
2315
|
-
if (
|
|
2516
|
+
if (!selectValuesActive) return html;
|
|
2517
|
+
let cand = html.indexOf("<select");
|
|
2518
|
+
if (cand < 0) return html;
|
|
2316
2519
|
let out = "";
|
|
2317
2520
|
let idx = 0;
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2521
|
+
while (cand >= 0) {
|
|
2522
|
+
if (!tagIs(html, cand, "select")) {
|
|
2523
|
+
cand = html.indexOf("<select", cand + 7);
|
|
2524
|
+
continue;
|
|
2525
|
+
}
|
|
2526
|
+
const e0 = tagEnd(html, cand);
|
|
2527
|
+
if (e0 < 0) break;
|
|
2528
|
+
const open = html.slice(cand, e0 + 1);
|
|
2529
|
+
const m = SELECT_VALUE_ATTR.exec(open);
|
|
2530
|
+
if (!m) {
|
|
2531
|
+
cand = html.indexOf("<select", e0 + 1);
|
|
2532
|
+
continue;
|
|
2533
|
+
}
|
|
2534
|
+
const bound = decodeSSREntities(m[1]);
|
|
2535
|
+
const sel = {
|
|
2536
|
+
values: /\smultiple(?=[\s>=])/.test(open) ? bound.split(",") : [bound],
|
|
2537
|
+
strip: cand + m.index,
|
|
2538
|
+
stripEnd: cand + m.index + m[0].length,
|
|
2539
|
+
body: e0 + 1,
|
|
2540
|
+
marks: [],
|
|
2541
|
+
defaulted: false
|
|
2542
|
+
};
|
|
2543
|
+
let committed = false;
|
|
2544
|
+
let i = html.indexOf("<", e0 + 1);
|
|
2545
|
+
while (i >= 0) {
|
|
2546
|
+
let e;
|
|
2547
|
+
if (html.charCodeAt(i + 1) === 33) {
|
|
2548
|
+
e = html.charCodeAt(i + 2) === 45 ? html.indexOf("-->", i) : html.indexOf(">", i);
|
|
2549
|
+
if (e < 0) break;
|
|
2550
|
+
if (html.charCodeAt(i + 2) === 45) e += 2;
|
|
2551
|
+
} else {
|
|
2552
|
+
e = tagEnd(html, i);
|
|
2553
|
+
if (e < 0) break;
|
|
2330
2554
|
if (html.startsWith("</select>", i)) {
|
|
2331
2555
|
out += html.slice(idx, sel.strip) + html.slice(sel.stripEnd, sel.body);
|
|
2332
2556
|
let seg = sel.body;
|
|
@@ -2338,7 +2562,8 @@ function resolveSSRSelectValues(html) {
|
|
|
2338
2562
|
}
|
|
2339
2563
|
out += html.slice(seg, i);
|
|
2340
2564
|
idx = i;
|
|
2341
|
-
|
|
2565
|
+
committed = true;
|
|
2566
|
+
break;
|
|
2342
2567
|
} else if (tagIs(html, i, "option")) {
|
|
2343
2568
|
const attrs = html.slice(i + 7, e);
|
|
2344
2569
|
if (/\sselected(?=[\s=]|$)/.test(attrs)) sel.defaulted = true;else {
|
|
@@ -2347,23 +2572,13 @@ function resolveSSRSelectValues(html) {
|
|
|
2347
2572
|
if (sel.values.includes(value)) sel.marks.push(e);
|
|
2348
2573
|
}
|
|
2349
2574
|
}
|
|
2350
|
-
} else if (tagIs(html, i, "select")) {
|
|
2351
|
-
const m = SELECT_VALUE_ATTR.exec(html.slice(i, e + 1));
|
|
2352
|
-
if (m) {
|
|
2353
|
-
const bound = decodeSSREntities(m[1]);
|
|
2354
|
-
sel = {
|
|
2355
|
-
values: /\smultiple(?=[\s>=])/.test(html.slice(i, e + 1)) ? bound.split(",") : [bound],
|
|
2356
|
-
strip: i + m.index,
|
|
2357
|
-
stripEnd: i + m.index + m[0].length,
|
|
2358
|
-
body: e + 1,
|
|
2359
|
-
marks: [],
|
|
2360
|
-
defaulted: false
|
|
2361
|
-
};
|
|
2362
|
-
}
|
|
2363
2575
|
}
|
|
2576
|
+
i = html.indexOf("<", e + 1);
|
|
2364
2577
|
}
|
|
2365
|
-
|
|
2578
|
+
if (!committed) break;
|
|
2579
|
+
cand = html.indexOf("<select", idx);
|
|
2366
2580
|
}
|
|
2581
|
+
if (idx === 0) return html;
|
|
2367
2582
|
return out + html.slice(idx);
|
|
2368
2583
|
}
|
|
2369
2584
|
function escape(s, attr) {
|
|
@@ -2387,22 +2602,20 @@ function escape(s, attr) {
|
|
|
2387
2602
|
return escapeSlow(s, attr, i);
|
|
2388
2603
|
}
|
|
2389
2604
|
const ESCAPE_CONTENT = /[&<]/;
|
|
2390
|
-
const ESCAPE_ATTR = /[&"]/;
|
|
2605
|
+
const ESCAPE_ATTR = /[&"<]/;
|
|
2391
2606
|
function escapeSlow(s, attr, start) {
|
|
2392
|
-
|
|
2393
|
-
const delimCode = attr ? 34 : 60;
|
|
2394
|
-
const escDelim = attr ? """ : "<";
|
|
2607
|
+
if (attr) return escapeAttrSlow(s, start);
|
|
2395
2608
|
const c0 = s.charCodeAt(start);
|
|
2396
|
-
let iDelim = c0 ===
|
|
2609
|
+
let iDelim = c0 === 60 ? start : s.indexOf("<", start);
|
|
2397
2610
|
let iAmp = c0 === 38 ? start : s.indexOf("&", start);
|
|
2398
2611
|
let left = 0,
|
|
2399
2612
|
out = "";
|
|
2400
2613
|
while (iDelim >= 0 && iAmp >= 0) {
|
|
2401
2614
|
if (iDelim < iAmp) {
|
|
2402
2615
|
if (left < iDelim) out += s.substring(left, iDelim);
|
|
2403
|
-
out +=
|
|
2616
|
+
out += "<";
|
|
2404
2617
|
left = iDelim + 1;
|
|
2405
|
-
iDelim = s.indexOf(
|
|
2618
|
+
iDelim = s.indexOf("<", left);
|
|
2406
2619
|
} else {
|
|
2407
2620
|
if (left < iAmp) out += s.substring(left, iAmp);
|
|
2408
2621
|
out += "&";
|
|
@@ -2413,9 +2626,9 @@ function escapeSlow(s, attr, start) {
|
|
|
2413
2626
|
if (iDelim >= 0) {
|
|
2414
2627
|
do {
|
|
2415
2628
|
if (left < iDelim) out += s.substring(left, iDelim);
|
|
2416
|
-
out +=
|
|
2629
|
+
out += "<";
|
|
2417
2630
|
left = iDelim + 1;
|
|
2418
|
-
iDelim = s.indexOf(
|
|
2631
|
+
iDelim = s.indexOf("<", left);
|
|
2419
2632
|
} while (iDelim >= 0);
|
|
2420
2633
|
} else while (iAmp >= 0) {
|
|
2421
2634
|
if (left < iAmp) out += s.substring(left, iAmp);
|
|
@@ -2425,6 +2638,36 @@ function escapeSlow(s, attr, start) {
|
|
|
2425
2638
|
}
|
|
2426
2639
|
return left < s.length ? out + s.substring(left) : out;
|
|
2427
2640
|
}
|
|
2641
|
+
function escapeAttrSlow(s, start) {
|
|
2642
|
+
const c0 = s.charCodeAt(start);
|
|
2643
|
+
let iQuot = c0 === 34 ? start : s.indexOf('"', start);
|
|
2644
|
+
let iAmp = c0 === 38 ? start : s.indexOf("&", start);
|
|
2645
|
+
let iLt = c0 === 60 ? start : s.indexOf("<", start);
|
|
2646
|
+
let left = 0,
|
|
2647
|
+
out = "";
|
|
2648
|
+
for (;;) {
|
|
2649
|
+
let i = -1,
|
|
2650
|
+
ent;
|
|
2651
|
+
if (iQuot >= 0) {
|
|
2652
|
+
i = iQuot;
|
|
2653
|
+
ent = """;
|
|
2654
|
+
}
|
|
2655
|
+
if (iAmp >= 0 && (i < 0 || iAmp < i)) {
|
|
2656
|
+
i = iAmp;
|
|
2657
|
+
ent = "&";
|
|
2658
|
+
}
|
|
2659
|
+
if (iLt >= 0 && (i < 0 || iLt < i)) {
|
|
2660
|
+
i = iLt;
|
|
2661
|
+
ent = "<";
|
|
2662
|
+
}
|
|
2663
|
+
if (i < 0) break;
|
|
2664
|
+
if (left < i) out += s.substring(left, i);
|
|
2665
|
+
out += ent;
|
|
2666
|
+
left = i + 1;
|
|
2667
|
+
if (i === iQuot) iQuot = s.indexOf('"', left);else if (i === iAmp) iAmp = s.indexOf("&", left);else iLt = s.indexOf("<", left);
|
|
2668
|
+
}
|
|
2669
|
+
return left < s.length ? out + s.substring(left) : out;
|
|
2670
|
+
}
|
|
2428
2671
|
function tryJoinPlainSSRArray(nodes) {
|
|
2429
2672
|
if (nodes.length === 0) return undefined;
|
|
2430
2673
|
let out = "";
|
|
@@ -2448,11 +2691,12 @@ function generateHydrationScript({
|
|
|
2448
2691
|
eventNames = ["click", "input"],
|
|
2449
2692
|
nonce
|
|
2450
2693
|
} = {}) {
|
|
2451
|
-
return `<script${nonce ? ` nonce="${nonce}"` : ""}>window._$HY||(e=>{let t=e=>e&&e.hasAttribute&&(e.hasAttribute("_hk")?e:t(e.host&&e.host.nodeType?e.host:e.parentNode));["${eventNames.join('","')}"].forEach((o=>document.addEventListener(o,(o=>{if(!e.events)return;let s=t(o.composedPath&&o.composedPath()[0]||o.target);s&&!e.completed.has(s)&&e.events.push([s,o])}))))})(_$HY={events:[],completed:new WeakSet,r:{},fe(){}});</script><!--xs-->`;
|
|
2694
|
+
return `<script${nonce ? ` nonce="${escape(String(nonce), true)}"` : ""}>window._$HY||(e=>{let t=e=>e&&e.hasAttribute&&(e.hasAttribute("_hk")?e:t(e.host&&e.host.nodeType?e.host:e.parentNode));["${eventNames.join('","')}"].forEach((o=>document.addEventListener(o,(o=>{if(!e.events)return;let s=t(o.composedPath&&o.composedPath()[0]||o.target);s&&!e.completed.has(s)&&e.events.push([s,o])}))))})(_$HY={events:[],completed:new WeakSet,r:{},fe(){}});</script><!--xs-->`;
|
|
2452
2695
|
}
|
|
2453
2696
|
function queue(fn) {
|
|
2454
2697
|
return Promise.resolve().then(fn);
|
|
2455
2698
|
}
|
|
2699
|
+
const deferFlush = typeof setImmediate === "function" ? setImmediate : fn => setTimeout(fn, 0);
|
|
2456
2700
|
function allSettled(promises) {
|
|
2457
2701
|
let size = promises.size;
|
|
2458
2702
|
return Promise.allSettled(promises).then(() => {
|
|
@@ -2461,10 +2705,11 @@ function allSettled(promises) {
|
|
|
2461
2705
|
});
|
|
2462
2706
|
}
|
|
2463
2707
|
function assembleDocument(html, emittedAssets, inlineStyles, scripts, nonce, headTags, onHead) {
|
|
2464
|
-
const scriptTag = scripts ? `<script${nonce
|
|
2465
|
-
const
|
|
2708
|
+
const scriptTag = scripts ? `<script${nonceAttr(nonce, "script")}>${scripts}</script>` : "";
|
|
2709
|
+
const title = headTags ? headTags.title : null;
|
|
2710
|
+
let headTagsHtml = headTags ? headTags.html : "";
|
|
2466
2711
|
const headPrelude = headTags ? headTags.prelude : "";
|
|
2467
|
-
if (!onHead && !headTagsHtml && !headPrelude && !(emittedAssets && emittedAssets.size) && !(inlineStyles && inlineStyles.size)) {
|
|
2712
|
+
if (!onHead && title == null && !headTagsHtml && !headPrelude && !(emittedAssets && emittedAssets.size) && !(inlineStyles && inlineStyles.size)) {
|
|
2468
2713
|
if (!scriptTag) return html;
|
|
2469
2714
|
const xs = html.indexOf("<!--xs-->");
|
|
2470
2715
|
return xs === -1 ? html + scriptTag : html.slice(0, xs) + scriptTag + html.slice(xs);
|
|
@@ -2476,15 +2721,33 @@ function assembleDocument(html, emittedAssets, inlineStyles, scripts, nonce, hea
|
|
|
2476
2721
|
html = html.slice(0, at) + headPrelude + html.slice(at);
|
|
2477
2722
|
}
|
|
2478
2723
|
}
|
|
2479
|
-
|
|
2724
|
+
let headIdx = html.indexOf("</head>");
|
|
2480
2725
|
if (headIdx === -1) {
|
|
2481
2726
|
if (onHead) {
|
|
2482
|
-
|
|
2727
|
+
let titleHtml = "";
|
|
2728
|
+
if (title != null) {
|
|
2729
|
+
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>`;
|
|
2730
|
+
}
|
|
2731
|
+
onHead(headPrelude + headTagsHtml + titleHtml + renderHeadAssets(emittedAssets, inlineStyles, nonce));
|
|
2483
2732
|
}
|
|
2484
2733
|
if (!scriptTag) return html;
|
|
2485
2734
|
const xs = html.indexOf("<!--xs-->");
|
|
2486
2735
|
return xs === -1 ? html + scriptTag : html.slice(0, xs) + scriptTag + html.slice(xs);
|
|
2487
2736
|
}
|
|
2737
|
+
if (title != null) {
|
|
2738
|
+
const winner = escape(title);
|
|
2739
|
+
const open = html.match(/<head(?:\s[^>]*)?>/);
|
|
2740
|
+
const from = open ? open.index + open[0].length : 0;
|
|
2741
|
+
const m = /<title(\s[^>]*)?>([\s\S]*?)<\/title>/.exec(html.slice(from, headIdx));
|
|
2742
|
+
if (m) {
|
|
2743
|
+
const at = from + m.index;
|
|
2744
|
+
const stash = m[2].replace(/"/g, """);
|
|
2745
|
+
html = html.slice(0, at) + `<title${m[1] || ""} data-dh="title" data-dhf="${stash}">${winner}</title>` + html.slice(at + m[0].length);
|
|
2746
|
+
headIdx = html.indexOf("</head>");
|
|
2747
|
+
} else {
|
|
2748
|
+
headTagsHtml = `<title data-dh="title">${winner}</title>` + headTagsHtml;
|
|
2749
|
+
}
|
|
2750
|
+
}
|
|
2488
2751
|
const head = headTagsHtml + renderHeadAssets(emittedAssets, inlineStyles, nonce);
|
|
2489
2752
|
if (!scriptTag) return html.slice(0, headIdx) + head + html.slice(headIdx);
|
|
2490
2753
|
const xsIdx = html.indexOf("<!--xs-->");
|
|
@@ -2493,9 +2756,11 @@ function assembleDocument(html, emittedAssets, inlineStyles, scripts, nonce, hea
|
|
|
2493
2756
|
}
|
|
2494
2757
|
function renderHeadAssets(emittedAssets, inlineStyles, nonce) {
|
|
2495
2758
|
let head = "";
|
|
2759
|
+
const styleAttr = nonceAttr(nonce, "style");
|
|
2760
|
+
const scriptAttr = nonceAttr(nonce, "script");
|
|
2496
2761
|
if (emittedAssets && emittedAssets.size) {
|
|
2497
2762
|
for (const url of emittedAssets) {
|
|
2498
|
-
head += isCssUrl(url) ? `<link rel="stylesheet" href="${url}">` : `<link rel="modulepreload" href="${url}">`;
|
|
2763
|
+
head += isCssUrl(url) ? `<link rel="stylesheet" href="${url}"${styleAttr}>` : `<link rel="modulepreload" href="${url}"${scriptAttr}>`;
|
|
2499
2764
|
}
|
|
2500
2765
|
}
|
|
2501
2766
|
if (inlineStyles && inlineStyles.size) {
|
|
@@ -2557,12 +2822,15 @@ function escapeStyleContent(content) {
|
|
|
2557
2822
|
}
|
|
2558
2823
|
function renderInlineStyle(entry, nonce) {
|
|
2559
2824
|
let attrs = "";
|
|
2825
|
+
let hasNonce = false;
|
|
2560
2826
|
if (entry.attrs) {
|
|
2561
2827
|
for (const name in entry.attrs) {
|
|
2828
|
+
if (name.length === 5 && asciiLowerCase(name) === "nonce") hasNonce = true;
|
|
2562
2829
|
attrs += ` ${name}="${escape(String(entry.attrs[name]), true)}"`;
|
|
2563
2830
|
}
|
|
2564
2831
|
}
|
|
2565
|
-
|
|
2832
|
+
const nonceHtml = hasNonce ? "" : nonceAttr(nonce, "style");
|
|
2833
|
+
return `<style${nonceHtml} data-asset="${escape(entry.id, true)}"${attrs}>${escapeStyleContent(entry.content)}</style>`;
|
|
2566
2834
|
}
|
|
2567
2835
|
function waitForFragments(registry, key) {
|
|
2568
2836
|
for (const k of [...registry.keys()].reverse()) {
|
|
@@ -2804,16 +3072,13 @@ function deriveHead(stub, responseInit = {}) {
|
|
|
2804
3072
|
headers
|
|
2805
3073
|
};
|
|
2806
3074
|
}
|
|
2807
|
-
function escapeAttribute(value) {
|
|
2808
|
-
return value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<");
|
|
2809
|
-
}
|
|
2810
3075
|
function createSSRResponse(result, event, options = {}) {
|
|
2811
3076
|
const stub = event && event.response;
|
|
2812
3077
|
const {
|
|
2813
3078
|
responseInit,
|
|
2814
|
-
nonce,
|
|
2815
3079
|
transformChunk
|
|
2816
3080
|
} = options;
|
|
3081
|
+
const nonce = normalizeNonce(options.nonce);
|
|
2817
3082
|
if (typeof result === "string") {
|
|
2818
3083
|
if (stub) commitResponseStub(stub);
|
|
2819
3084
|
const head = deriveHead(stub, responseInit);
|
|
@@ -2883,7 +3148,7 @@ function createSSRResponse(result, event, options = {}) {
|
|
|
2883
3148
|
if (closed || !controller) return;
|
|
2884
3149
|
const location = stub && stub.headers.get("Location");
|
|
2885
3150
|
if (location) {
|
|
2886
|
-
const attr =
|
|
3151
|
+
const attr = nonceAttr(nonce, "script");
|
|
2887
3152
|
enqueue(`<script${attr}>window.location=${JSON.stringify(location).replace(/</g, "\\u003c")}</script>`);
|
|
2888
3153
|
}
|
|
2889
3154
|
closed = true;
|
|
@@ -3120,10 +3385,17 @@ Object.defineProperty(exports, "scope", {
|
|
|
3120
3385
|
enumerable: true,
|
|
3121
3386
|
get: function () { return solidJs.ssrScope; }
|
|
3122
3387
|
});
|
|
3388
|
+
Object.defineProperty(exports, "sharedConfig", {
|
|
3389
|
+
enumerable: true,
|
|
3390
|
+
get: function () { return solidJs.sharedConfig; }
|
|
3391
|
+
});
|
|
3123
3392
|
Object.defineProperty(exports, "untrack", {
|
|
3124
3393
|
enumerable: true,
|
|
3125
3394
|
get: function () { return solidJs.untrack; }
|
|
3126
3395
|
});
|
|
3396
|
+
exports.CLAIMS_DOCUMENT = CLAIMS_DOCUMENT;
|
|
3397
|
+
exports.CLAIMS_STREAM = CLAIMS_STREAM;
|
|
3398
|
+
exports.CLAIM_PROP = CLAIM_PROP;
|
|
3127
3399
|
exports.ChildProperties = ChildProperties;
|
|
3128
3400
|
exports.DOMElements = DOMElements;
|
|
3129
3401
|
exports.DOMWithState = DOMWithState;
|
|
@@ -3195,9 +3467,11 @@ exports.reload = reload;
|
|
|
3195
3467
|
exports.render = notSup;
|
|
3196
3468
|
exports.renderToStream = renderToStream;
|
|
3197
3469
|
exports.renderToString = renderToString;
|
|
3470
|
+
exports.resolveSSRNode = resolveSSRNode;
|
|
3198
3471
|
exports.resolveSSRSelectValues = resolveSSRSelectValues;
|
|
3199
3472
|
exports.respond = respond;
|
|
3200
3473
|
exports.runHydrationEvents = notSup;
|
|
3474
|
+
exports.scriptNonce = scriptNonce;
|
|
3201
3475
|
exports.serializeCookie = serializeCookie;
|
|
3202
3476
|
exports.setAttribute = notSup;
|
|
3203
3477
|
exports.setAttributeNS = notSup;
|
|
@@ -3206,13 +3480,16 @@ exports.setStyleProperty = notSup;
|
|
|
3206
3480
|
exports.spread = notSup;
|
|
3207
3481
|
exports.ssr = ssr;
|
|
3208
3482
|
exports.ssrAttribute = ssrAttribute;
|
|
3483
|
+
exports.ssrClaim = ssrClaim;
|
|
3209
3484
|
exports.ssrClassName = ssrClassName;
|
|
3210
3485
|
exports.ssrElement = ssrElement;
|
|
3211
3486
|
exports.ssrGroup = ssrGroup;
|
|
3212
3487
|
exports.ssrHydrationKey = ssrHydrationKey;
|
|
3488
|
+
exports.ssrSelectValues = ssrSelectValues;
|
|
3213
3489
|
exports.ssrStyle = ssrStyle;
|
|
3214
3490
|
exports.ssrStyleProperty = ssrStyleProperty;
|
|
3215
3491
|
exports.style = notSup;
|
|
3492
|
+
exports.styleNonce = styleNonce;
|
|
3216
3493
|
exports.template = notSup;
|
|
3217
3494
|
exports.unregisterDelegatedContainer = notSup;
|
|
3218
3495
|
exports.unregisterDelegatedRoot = notSup;
|