@solidjs/web 2.0.0-experimental.9 → 2.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -4
- package/dist/dev.cjs +1588 -224
- package/dist/dev.js +1513 -200
- package/dist/server.cjs +2722 -254
- package/dist/server.js +2659 -245
- package/dist/web.cjs +1524 -218
- package/dist/web.js +1449 -194
- package/frames/dist/client.cjs +1916 -0
- package/frames/dist/client.dev.cjs +1933 -0
- package/frames/dist/client.dev.js +1921 -0
- package/frames/dist/client.js +1904 -0
- package/frames/dist/server.cjs +3756 -0
- package/frames/dist/server.js +3743 -0
- package/frames/package.json +30 -0
- package/package.json +350 -37
- package/serialization/decode/package.json +20 -0
- package/serialization/dist/decode.cjs +122 -0
- package/serialization/dist/decode.js +116 -0
- package/serialization/dist/serialization.cjs +244 -0
- package/serialization/dist/serialization.js +227 -0
- package/serialization/package.json +20 -0
- package/serialization/types/index.d.ts +182 -0
- package/serialization/types/serializer-decode.d.ts +182 -0
- package/serialization/types-cjs/index.d.cts +182 -0
- package/serialization/types-cjs/package.json +3 -0
- package/serialization/types-cjs/serializer-decode.d.cts +182 -0
- package/server-functions/dist/client.cjs +793 -0
- package/server-functions/dist/client.js +763 -0
- package/server-functions/dist/rich-args.cjs +11 -0
- package/server-functions/dist/rich-args.js +9 -0
- package/server-functions/dist/server.cjs +1171 -0
- package/server-functions/dist/server.dev.cjs +1171 -0
- package/server-functions/dist/server.dev.js +1137 -0
- package/server-functions/dist/server.js +1137 -0
- package/server-functions/package.json +40 -0
- package/server-functions/rich-args/package.json +20 -0
- package/storage/package.json +8 -3
- package/storage/types/index.d.ts +26 -0
- package/storage/types-cjs/index.d.cts +28 -0
- package/storage/types-cjs/package.json +3 -0
- package/types/client.d.ts +290 -27
- package/types/cookies.d.ts +93 -0
- package/types/core.d.ts +6 -2
- package/types/frames/client.d.ts +36 -0
- package/types/frames/frame-client.d.ts +338 -0
- package/types/frames/frame-sink.d.ts +194 -0
- package/types/frames/frame-transport.d.ts +222 -0
- package/types/frames/serializer.d.ts +182 -0
- package/types/frames/server.d.ts +52 -0
- package/types/index.d.ts +223 -24
- package/types/jsx-properties.d.ts +93 -0
- package/types/jsx.d.ts +4159 -1
- package/types/response.d.ts +174 -0
- package/types/serializer-decode.d.ts +182 -0
- package/types/serializer.d.ts +182 -0
- package/types/server-functions/client.d.ts +231 -0
- package/types/server-functions/flash.d.ts +38 -0
- package/types/server-functions/rich-args.d.ts +10 -0
- package/types/server-functions/server.d.ts +616 -0
- package/types/server-functions/shared.d.ts +523 -0
- package/types/server-mock.d.ts +249 -12
- package/types/server.d.ts +424 -51
- package/types-cjs/client.d.cts +337 -0
- package/types-cjs/cookies.d.cts +93 -0
- package/types-cjs/core.d.cts +6 -0
- package/types-cjs/frames/client.d.cts +36 -0
- package/types-cjs/frames/frame-client.d.cts +338 -0
- package/types-cjs/frames/frame-sink.d.cts +194 -0
- package/types-cjs/frames/frame-transport.d.cts +222 -0
- package/types-cjs/frames/serializer.d.cts +182 -0
- package/types-cjs/frames/server.d.cts +52 -0
- package/types-cjs/index.d.cts +244 -0
- package/types-cjs/jsx-properties.d.cts +93 -0
- package/types-cjs/jsx.d.cts +4159 -0
- package/types-cjs/package.json +3 -0
- package/types-cjs/response.d.cts +174 -0
- package/types-cjs/serializer-decode.d.cts +182 -0
- package/types-cjs/serializer.d.cts +182 -0
- package/types-cjs/server-functions/client.d.cts +231 -0
- package/types-cjs/server-functions/flash.d.cts +38 -0
- package/types-cjs/server-functions/rich-args.d.cts +10 -0
- package/types-cjs/server-functions/server.d.cts +616 -0
- package/types-cjs/server-functions/shared.d.cts +523 -0
- package/types-cjs/server-mock.d.cts +277 -0
- package/types-cjs/server.d.cts +523 -0
package/dist/server.cjs
CHANGED
|
@@ -4,8 +4,34 @@ var solidJs = require('solid-js');
|
|
|
4
4
|
var seroval = require('seroval');
|
|
5
5
|
var web = require('seroval-plugins/web');
|
|
6
6
|
|
|
7
|
-
const
|
|
8
|
-
|
|
7
|
+
const DOMWithState = {
|
|
8
|
+
INPUT: {
|
|
9
|
+
value: 1,
|
|
10
|
+
defaultValue: 2,
|
|
11
|
+
checked: 1,
|
|
12
|
+
defaultChecked: 2
|
|
13
|
+
},
|
|
14
|
+
SELECT: {
|
|
15
|
+
value: 1
|
|
16
|
+
},
|
|
17
|
+
OPTION: {
|
|
18
|
+
value: 1,
|
|
19
|
+
selected: 1,
|
|
20
|
+
defaultSelected: 2
|
|
21
|
+
},
|
|
22
|
+
TEXTAREA: {
|
|
23
|
+
value: 1,
|
|
24
|
+
defaultValue: 2
|
|
25
|
+
},
|
|
26
|
+
VIDEO: {
|
|
27
|
+
muted: 1,
|
|
28
|
+
defaultMuted: 2
|
|
29
|
+
},
|
|
30
|
+
AUDIO: {
|
|
31
|
+
muted: 1,
|
|
32
|
+
defaultMuted: 2
|
|
33
|
+
}
|
|
34
|
+
};
|
|
9
35
|
const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
|
|
10
36
|
const DelegatedEvents = /*#__PURE__*/new Set(["beforeinput", "click", "dblclick", "contextmenu", "focusin", "focusout", "input", "keydown", "keyup", "mousedown", "mousemove", "mouseout", "mouseover", "mouseup", "pointerdown", "pointermove", "pointerout", "pointerover", "pointerup", "touchend", "touchmove", "touchstart"]);
|
|
11
37
|
const SVGElements = /*#__PURE__*/new Set([
|
|
@@ -13,52 +39,882 @@ const SVGElements = /*#__PURE__*/new Set([
|
|
|
13
39
|
"set", "stop",
|
|
14
40
|
"svg", "switch", "symbol", "text", "textPath",
|
|
15
41
|
"tref", "tspan", "use", "view", "vkern"]);
|
|
16
|
-
const
|
|
42
|
+
const MathMLElements = /*#__PURE__*/new Set(["annotation", "annotation-xml", "maction", "math", "menclose", "merror", "mfenced", "mfrac", "mi", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mprescripts", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msubsup", "msup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "semantics"]);
|
|
43
|
+
const Namespaces = {
|
|
44
|
+
svg: "http://www.w3.org/2000/svg",
|
|
45
|
+
mathml: "http://www.w3.org/1998/Math/MathML",
|
|
17
46
|
xlink: "http://www.w3.org/1999/xlink",
|
|
18
47
|
xml: "http://www.w3.org/XML/1998/namespace"
|
|
19
48
|
};
|
|
20
|
-
const
|
|
21
|
-
"
|
|
22
|
-
"isindex
|
|
49
|
+
const VoidElements = /*#__PURE__*/new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]);
|
|
50
|
+
const RawTextElements = /*#__PURE__*/new Set(["style", "script", "noscript", "template", "textarea", "title"]);
|
|
51
|
+
const DOMElements = /*#__PURE__*/new Set(/*#__PURE__*/"a,abbr,acronym,address,applet,area,article,aside,audio,b,base,basefont,bdi,bdo,bgsound,big,blink,blockquote,body,br,button,canvas,caption,center,cite,code,col,colgroup,content,data,datalist,dd,del,details,dfn,dialog,dir,div,dl,dt,em,embed,fieldset,figcaption,figure,font,footer,form,frame,frameset,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,i,iframe,image,img,input,ins,isindex,kbd,keygen,label,legend,li,link,listing,main,map,mark,marquee,math,menu,menuitem,meta,meter,multicol,nav,nextid,nobr,noembed,noframes,noindex,noscript,object,ol,optgroup,option,output,p,param,picture,plaintext,portal,pre,progress,q,rb,rp,rt,rtc,ruby,s,samp,script,search,section,select,shadow,slot,small,source,spacer,span,strike,strong,style,sub,summary,sup,svg,table,tbody,td,template,textarea,tfoot,th,thead,time,title,tr,track,tt,u,ul,var,video,wbr,webview,xmp".split(","));
|
|
23
52
|
|
|
24
|
-
const
|
|
53
|
+
const transparentOptions = {
|
|
54
|
+
transparent: true,
|
|
55
|
+
sync: true
|
|
56
|
+
};
|
|
57
|
+
const syncOptions = {
|
|
58
|
+
sync: true
|
|
59
|
+
};
|
|
60
|
+
const effect = (fn, effectFn, options) => solidJs.createRenderEffect(fn, effectFn, options ? {
|
|
61
|
+
sync: true,
|
|
62
|
+
...options,
|
|
63
|
+
transparent: !options.scope
|
|
64
|
+
} : transparentOptions);
|
|
65
|
+
const memo = fn => solidJs.createMemo(() => fn(), syncOptions);
|
|
25
66
|
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
67
|
+
const STATE = Symbol.for("dom-expressions.container-trace-state");
|
|
68
|
+
const state = globalThis[STATE] || (globalThis[STATE] = {
|
|
69
|
+
materialized: new WeakMap(),
|
|
70
|
+
materializedValues: new WeakSet()
|
|
71
|
+
});
|
|
72
|
+
function setContainerTraceResolver(fn) {
|
|
73
|
+
state.resolveTrace = fn;
|
|
74
|
+
}
|
|
75
|
+
const TRACE = Symbol.for("dom-expressions.container-trace");
|
|
76
|
+
function materialize(marker) {
|
|
77
|
+
let value = state.materialized.get(marker.$tr);
|
|
78
|
+
if (value === undefined) {
|
|
79
|
+
value = state.materializeTrace(marker);
|
|
80
|
+
state.materialized.set(marker.$tr, value);
|
|
81
|
+
if (value !== null && typeof value === "object") state.materializedValues.add(value);
|
|
82
|
+
}
|
|
83
|
+
return value;
|
|
84
|
+
}
|
|
85
|
+
function parseTrace(value, ctx) {
|
|
86
|
+
const trace = value[TRACE];
|
|
87
|
+
return {
|
|
88
|
+
a: trace.array ? 1 : 0,
|
|
89
|
+
i: ctx.parse(trace.subscribe())
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
const ContainerTracePlugin = {
|
|
93
|
+
tag: "dom-expressions/container-trace",
|
|
94
|
+
test(value) {
|
|
95
|
+
return value != null && typeof value === "object" && TRACE in value;
|
|
96
|
+
},
|
|
97
|
+
parse: {
|
|
98
|
+
sync() {
|
|
99
|
+
throw new Error("A reactive container can only be serialized by a streaming serializer.");
|
|
100
|
+
},
|
|
101
|
+
async async(value, ctx) {
|
|
102
|
+
const trace = value[TRACE];
|
|
103
|
+
return {
|
|
104
|
+
a: trace.array ? 1 : 0,
|
|
105
|
+
i: await ctx.parse(trace.subscribe())
|
|
106
|
+
};
|
|
107
|
+
},
|
|
108
|
+
stream: parseTrace
|
|
109
|
+
},
|
|
110
|
+
serialize(node, ctx) {
|
|
111
|
+
return "{$tr:" + ctx.serialize(node.i) + ",$ta:" + node.a + "}";
|
|
112
|
+
},
|
|
113
|
+
deserialize(node, ctx) {
|
|
114
|
+
const iterable = ctx.deserialize(node.i);
|
|
115
|
+
const marker = {
|
|
116
|
+
$tr: iterable,
|
|
117
|
+
$ta: node.a
|
|
118
|
+
};
|
|
119
|
+
return state.materializeTrace ? materialize(marker) : marker;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const DEFAULT_WEB_PLUGINS = Object.freeze([web.AbortSignalPlugin,
|
|
124
|
+
web.CustomEventPlugin, web.DOMExceptionPlugin, web.EventPlugin,
|
|
125
|
+
web.FormDataPlugin, web.HeadersPlugin, web.ReadableStreamPlugin, web.RequestPlugin, web.ResponsePlugin, web.URLSearchParamsPlugin, web.URLPlugin,
|
|
126
|
+
ContainerTracePlugin]);
|
|
127
|
+
function resolveSerializerPlugins(customPlugins) {
|
|
128
|
+
return customPlugins ? [...customPlugins, ...DEFAULT_WEB_PLUGINS] : [...DEFAULT_WEB_PLUGINS];
|
|
129
|
+
}
|
|
130
|
+
seroval.Feature.RegExp;
|
|
131
|
+
|
|
132
|
+
const DEFAULT_DISABLED_FEATURES = seroval.Feature.AggregateError | seroval.Feature.BigIntTypedArray;
|
|
133
|
+
const serializeOnlyDisabledFeatures = () => process.env.NODE_ENV === "development" ? 0 : seroval.Feature.ErrorPrototypeStack;
|
|
134
|
+
const HYDRATION_GLOBAL = "_$HY.r";
|
|
135
|
+
function createSerializer(options) {
|
|
136
|
+
return new seroval.Serializer({
|
|
137
|
+
...options,
|
|
138
|
+
plugins: resolveSerializerPlugins(options.plugins),
|
|
139
|
+
disabledFeatures: (options.disabledFeatures === undefined ? DEFAULT_DISABLED_FEATURES : options.disabledFeatures) | serializeOnlyDisabledFeatures()
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
function createHydrationSerializer({
|
|
30
143
|
onData,
|
|
31
144
|
onDone,
|
|
32
145
|
scopeId,
|
|
33
|
-
onError
|
|
146
|
+
onError,
|
|
147
|
+
plugins
|
|
34
148
|
}) {
|
|
35
|
-
return
|
|
149
|
+
return createSerializer({
|
|
36
150
|
scopeId,
|
|
37
|
-
plugins
|
|
38
|
-
|
|
39
|
-
web.FormDataPlugin, web.HeadersPlugin, web.ReadableStreamPlugin, web.RequestPlugin, web.ResponsePlugin, web.URLSearchParamsPlugin, web.URLPlugin],
|
|
40
|
-
globalIdentifier: GLOBAL_IDENTIFIER,
|
|
41
|
-
disabledFeatures: ES2017FLAG,
|
|
151
|
+
plugins,
|
|
152
|
+
globalIdentifier: HYDRATION_GLOBAL,
|
|
42
153
|
onData,
|
|
43
154
|
onDone,
|
|
44
155
|
onError
|
|
45
156
|
});
|
|
46
157
|
}
|
|
47
158
|
function getLocalHeaderScript(id) {
|
|
48
|
-
return seroval.getCrossReferenceHeader(id) +
|
|
159
|
+
return seroval.getCrossReferenceHeader(id) + ";";
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const ENVELOPE = Symbol.for("solid.ResponseEnvelope");
|
|
163
|
+
// PURE-annotated factory (same convention as solid's MockPromise): the brand
|
|
164
|
+
const ResponseEnvelope = /* @__PURE__ */(() => {
|
|
165
|
+
class ResponseEnvelope {
|
|
166
|
+
constructor(response, value) {
|
|
167
|
+
this.response = response;
|
|
168
|
+
this.value = value;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
ResponseEnvelope.prototype[ENVELOPE] = true;
|
|
172
|
+
return ResponseEnvelope;
|
|
173
|
+
})();
|
|
174
|
+
function isResponseEnvelope(value) {
|
|
175
|
+
return !!(value && typeof value === "object" && value[ENVELOPE]);
|
|
176
|
+
}
|
|
177
|
+
const HREF = Symbol.for("solid.Href");
|
|
178
|
+
function isHref(value) {
|
|
179
|
+
return !!(value && (typeof value === "object" || typeof value === "function") && value[HREF]);
|
|
180
|
+
}
|
|
181
|
+
const SAFE_ERROR = Symbol.for("solid.SafeError");
|
|
182
|
+
function markSafeError(error) {
|
|
183
|
+
if (error && (typeof error === "object" || typeof error === "function")) {
|
|
184
|
+
Object.defineProperty(error, SAFE_ERROR, {
|
|
185
|
+
value: true,
|
|
186
|
+
enumerable: false,
|
|
187
|
+
configurable: true
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
return error;
|
|
191
|
+
}
|
|
192
|
+
function isSafeError(value) {
|
|
193
|
+
return !!(value && (typeof value === "object" || typeof value === "function") && value[SAFE_ERROR]);
|
|
194
|
+
}
|
|
195
|
+
const REVALIDATE_HEADER = "X-Revalidate";
|
|
196
|
+
function initWithRevalidate(init) {
|
|
197
|
+
const {
|
|
198
|
+
revalidate,
|
|
199
|
+
...responseInit
|
|
200
|
+
} = init;
|
|
201
|
+
let headers;
|
|
202
|
+
if (responseInit.headers && responseInit.headers.getSetCookie) {
|
|
203
|
+
headers = new Headers();
|
|
204
|
+
responseInit.headers.forEach((value, key) => {
|
|
205
|
+
if (key !== "set-cookie") headers.append(key, value);
|
|
206
|
+
});
|
|
207
|
+
for (const cookie of responseInit.headers.getSetCookie()) {
|
|
208
|
+
headers.append("Set-Cookie", cookie);
|
|
209
|
+
}
|
|
210
|
+
} else {
|
|
211
|
+
headers = new Headers(responseInit.headers);
|
|
212
|
+
}
|
|
213
|
+
revalidate !== undefined && headers.set(REVALIDATE_HEADER, revalidate.toString());
|
|
214
|
+
return {
|
|
215
|
+
responseInit,
|
|
216
|
+
headers
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
function redirect(url, init = 302) {
|
|
220
|
+
if (typeof url !== "string" && !isHref(url)) {
|
|
221
|
+
throw new TypeError("redirect() expects a string URL or an Href-branded value (Symbol.for('solid.Href')).");
|
|
222
|
+
}
|
|
223
|
+
const {
|
|
224
|
+
responseInit,
|
|
225
|
+
headers
|
|
226
|
+
} = initWithRevalidate(typeof init === "number" ? {
|
|
227
|
+
status: init
|
|
228
|
+
} : init);
|
|
229
|
+
if (responseInit.status === undefined) {
|
|
230
|
+
responseInit.status = 302;
|
|
231
|
+
}
|
|
232
|
+
headers.set("Location", String(url));
|
|
233
|
+
return new Response(null, {
|
|
234
|
+
...responseInit,
|
|
235
|
+
headers
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
function reload(init = {}) {
|
|
239
|
+
const {
|
|
240
|
+
responseInit,
|
|
241
|
+
headers
|
|
242
|
+
} = initWithRevalidate(init);
|
|
243
|
+
return new Response(null, {
|
|
244
|
+
...responseInit,
|
|
245
|
+
headers
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
function respond(value, init = {}) {
|
|
249
|
+
const {
|
|
250
|
+
responseInit,
|
|
251
|
+
headers
|
|
252
|
+
} = initWithRevalidate(init);
|
|
253
|
+
headers.set("Content-Type", "application/json");
|
|
254
|
+
return new ResponseEnvelope(new Response(JSON.stringify(value), {
|
|
255
|
+
...responseInit,
|
|
256
|
+
headers
|
|
257
|
+
}), value);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
const SERVER_FUNCTION_METADATA = Symbol.for("solid.ServerFunctionMetadata");
|
|
261
|
+
function getServerFunctionMetadata(fn) {
|
|
262
|
+
if (typeof fn !== "function") return undefined;
|
|
263
|
+
return fn[SERVER_FUNCTION_METADATA] || undefined;
|
|
264
|
+
}
|
|
265
|
+
function isServerFunction(fn) {
|
|
266
|
+
return typeof fn === "function" && !!fn[SERVER_FUNCTION_METADATA];
|
|
267
|
+
}
|
|
268
|
+
const SERVER_FUNCTION_RPC = Symbol.for("solid.ServerFunctionRPC");
|
|
269
|
+
function getServerFunctionRPC() {
|
|
270
|
+
return globalThis[SERVER_FUNCTION_RPC];
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function parseCookieHeader(header) {
|
|
274
|
+
const cookies = {};
|
|
275
|
+
if (!header) return cookies;
|
|
276
|
+
for (const part of header.split(";")) {
|
|
277
|
+
const eq = part.indexOf("=");
|
|
278
|
+
if (eq < 0) continue;
|
|
279
|
+
const name = decodeSafe(part.slice(0, eq).trim());
|
|
280
|
+
let value = part.slice(eq + 1).trim();
|
|
281
|
+
if (value.length > 1 && value[0] === '"' && value[value.length - 1] === '"') {
|
|
282
|
+
value = value.slice(1, -1);
|
|
283
|
+
}
|
|
284
|
+
cookies[name] = decodeSafe(value);
|
|
285
|
+
}
|
|
286
|
+
return cookies;
|
|
287
|
+
}
|
|
288
|
+
function decodeSafe(text) {
|
|
289
|
+
try {
|
|
290
|
+
return decodeURIComponent(text);
|
|
291
|
+
} catch {
|
|
292
|
+
return text;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
function serializeCookie(name, value, options = {}) {
|
|
296
|
+
let cookie = `${encodeURIComponent(name)}=${encodeURIComponent(value)}`;
|
|
297
|
+
cookie += `; Path=${options.path === undefined ? "/" : options.path}`;
|
|
298
|
+
if (options.domain) cookie += `; Domain=${options.domain}`;
|
|
299
|
+
if (options.maxAge !== undefined) cookie += `; Max-Age=${Math.trunc(options.maxAge)}`;
|
|
300
|
+
if (options.expires) cookie += `; Expires=${options.expires.toUTCString()}`;
|
|
301
|
+
if (options.httpOnly) cookie += "; HttpOnly";
|
|
302
|
+
if (options.secure) cookie += "; Secure";
|
|
303
|
+
if (options.sameSite) {
|
|
304
|
+
const sameSite = options.sameSite.toLowerCase();
|
|
305
|
+
cookie += `; SameSite=${sameSite === "none" ? "None" : sameSite === "strict" ? "Strict" : "Lax"}`;
|
|
306
|
+
}
|
|
307
|
+
return cookie;
|
|
308
|
+
}
|
|
309
|
+
const FLASH_COOKIE = "flash";
|
|
310
|
+
const FLASH_MATCHER = new RegExp(`(?:^|;\\s*)${FLASH_COOKIE}=([^;]+)`);
|
|
311
|
+
function hasFlashCookie(cookieHeader) {
|
|
312
|
+
return !!cookieHeader && FLASH_MATCHER.test(cookieHeader);
|
|
313
|
+
}
|
|
314
|
+
function clearFlashCookie() {
|
|
315
|
+
return `${FLASH_COOKIE}=; Max-Age=0; Path=/`;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
const ERROR_HEADER = "X-Server-Function-Error";
|
|
319
|
+
const BODY_FORMAT_HEADER = "X-Server-Function-Format";
|
|
320
|
+
const SINGLE_FLIGHT_HEADER = "X-Single-Flight";
|
|
321
|
+
|
|
322
|
+
const HEAD_ELIGIBLE_TAGS = new Set(["title", "meta", "link", "style", "script", "base"]);
|
|
323
|
+
const HEAD_ATTR_NAME = /^[a-zA-Z_][a-zA-Z0-9_:.-]*$/;
|
|
324
|
+
const RESOURCE_LINK_RELS = new Set(["preload", "modulepreload", "prefetch", "preconnect", "dns-prefetch", "stylesheet"]);
|
|
325
|
+
const RESOURCE_QUALIFIERS = ["as", "crossorigin", "type", "media", "imagesrcset", "imagesizes"];
|
|
326
|
+
const STYLESHEET_FETCH_META = new Set(["crossorigin", "integrity", "referrerpolicy", "fetchpriority"]);
|
|
327
|
+
function evalHeadValue(v) {
|
|
328
|
+
return typeof v === "function" ? v() : v;
|
|
329
|
+
}
|
|
330
|
+
function evalHeadProps(props, presets) {
|
|
331
|
+
const out = {};
|
|
332
|
+
for (const name in props) out[name] = presets && name in presets ? presets[name] : evalHeadValue(props[name]);
|
|
333
|
+
return out;
|
|
334
|
+
}
|
|
335
|
+
function classifyHeadTag(desc) {
|
|
336
|
+
const tag = desc.tag;
|
|
337
|
+
if (tag === "link") {
|
|
338
|
+
const rel = evalHeadValue(desc.props && desc.props.rel);
|
|
339
|
+
return {
|
|
340
|
+
resource: RESOURCE_LINK_RELS.has(rel),
|
|
341
|
+
rel
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
if (tag === "style") return {
|
|
345
|
+
resource: !!(desc.props && "href" in desc.props)
|
|
346
|
+
};
|
|
347
|
+
if (tag === "script") return {
|
|
348
|
+
resource: !!(desc.props && "src" in desc.props)
|
|
349
|
+
};
|
|
350
|
+
return {
|
|
351
|
+
resource: false
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
function resourceIdentity(tag, props) {
|
|
355
|
+
let id = "res:" + tag + ":" + (props.rel || "") + ":" + (props.href || props.src || "");
|
|
356
|
+
for (let i = 0; i < RESOURCE_QUALIFIERS.length; i++) {
|
|
357
|
+
const q = RESOURCE_QUALIFIERS[i];
|
|
358
|
+
if (props[q] != null) id += ":" + q + "=" + props[q];
|
|
359
|
+
}
|
|
360
|
+
return id;
|
|
361
|
+
}
|
|
362
|
+
function replaceableIdentity(tag, props, key, unique) {
|
|
363
|
+
if (tag === "title") return "title";
|
|
364
|
+
if (tag === "base") return "base";
|
|
365
|
+
if (tag === "meta" && props.charset != null) return "charset";
|
|
366
|
+
if (key != null) return tag + ":key:" + key;
|
|
367
|
+
if (tag === "meta") {
|
|
368
|
+
for (const ns of ["name", "property", "http-equiv"]) if (props[ns] != null) return "meta:" + ns + ":" + props[ns] + (props.media != null ? ":media=" + props.media : "");
|
|
369
|
+
return unique;
|
|
370
|
+
}
|
|
371
|
+
if (tag === "link") {
|
|
372
|
+
const rel = props.rel || "";
|
|
373
|
+
if (rel === "icon" || rel === "apple-touch-icon") return "link:" + rel + (props.sizes != null ? ":sizes=" + props.sizes : "") + (props.type != null ? ":type=" + props.type : "");
|
|
374
|
+
return "link:" + rel + ":" + (props.href || "");
|
|
375
|
+
}
|
|
376
|
+
return unique;
|
|
377
|
+
}
|
|
378
|
+
function resolveHead(groups) {
|
|
379
|
+
const winners = new Map();
|
|
380
|
+
const sorted = groups.slice().sort((a, b) => a.seq - b.seq);
|
|
381
|
+
for (let i = 0; i < sorted.length; i++) {
|
|
382
|
+
const group = sorted[i];
|
|
383
|
+
const byIdentity = new Map();
|
|
384
|
+
for (let j = 0; j < group.tags.length; j++) {
|
|
385
|
+
const t = group.tags[j];
|
|
386
|
+
let list = byIdentity.get(t.identity);
|
|
387
|
+
if (!list) byIdentity.set(t.identity, list = []);
|
|
388
|
+
list.push(t);
|
|
389
|
+
}
|
|
390
|
+
for (const [identity, tags] of byIdentity) {
|
|
391
|
+
if (identity === "title") {
|
|
392
|
+
winners.set(identity, {
|
|
393
|
+
seq: group.seq,
|
|
394
|
+
tags: [tags[tags.length - 1]]
|
|
395
|
+
});
|
|
396
|
+
} else {
|
|
397
|
+
winners.set(identity, {
|
|
398
|
+
seq: group.seq,
|
|
399
|
+
tags
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
return winners;
|
|
49
405
|
}
|
|
50
406
|
|
|
407
|
+
function joinAssetPath(base, file) {
|
|
408
|
+
if (/^(?:[a-z][a-z0-9+.-]*:)?\/\//i.test(file)) return file;
|
|
409
|
+
if (typeof base !== "string" || !base) base = "/";
|
|
410
|
+
if (base[base.length - 1] !== "/") base += "/";
|
|
411
|
+
return base + (file[0] === "/" ? file.slice(1) : file);
|
|
412
|
+
}
|
|
413
|
+
function resolveAssets(moduleUrl, manifest) {
|
|
414
|
+
if (!manifest) return null;
|
|
415
|
+
const base = manifest._base;
|
|
416
|
+
const entry = manifest[moduleUrl];
|
|
417
|
+
if (!entry) return null;
|
|
418
|
+
const css = [];
|
|
419
|
+
const js = [];
|
|
420
|
+
const visited = new Set();
|
|
421
|
+
const walk = key => {
|
|
422
|
+
if (visited.has(key)) return;
|
|
423
|
+
visited.add(key);
|
|
424
|
+
const e = manifest[key];
|
|
425
|
+
if (!e) return;
|
|
426
|
+
js.push(joinAssetPath(base, e.file));
|
|
427
|
+
if (e.css) for (let i = 0; i < e.css.length; i++) css.push(joinAssetPath(base, e.css[i]));
|
|
428
|
+
if (e.imports) for (let i = 0; i < e.imports.length; i++) walk(e.imports[i]);
|
|
429
|
+
};
|
|
430
|
+
walk(moduleUrl);
|
|
431
|
+
return {
|
|
432
|
+
js,
|
|
433
|
+
css
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
function registerEntryAssets(manifest) {
|
|
437
|
+
if (!manifest || typeof manifest === "function" || typeof manifest.resolve === "function") return;
|
|
438
|
+
const ctx = solidJs.sharedConfig.context;
|
|
439
|
+
if (!ctx?.registerAsset) return;
|
|
440
|
+
for (const key in manifest) {
|
|
441
|
+
if (manifest[key].isEntry) {
|
|
442
|
+
const assets = resolveAssets(key, manifest);
|
|
443
|
+
if (assets) {
|
|
444
|
+
for (let i = 0; i < assets.css.length; i++) ctx.registerAsset("style", assets.css[i]);
|
|
445
|
+
}
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
function createAssetTracking() {
|
|
451
|
+
const boundaryModules = new Map();
|
|
452
|
+
const boundaryStyles = new Map();
|
|
453
|
+
const emittedAssets = new Set();
|
|
454
|
+
const inlineStyles = new Map();
|
|
455
|
+
let currentBoundaryId = null;
|
|
456
|
+
return {
|
|
457
|
+
boundaryModules,
|
|
458
|
+
boundaryStyles,
|
|
459
|
+
emittedAssets,
|
|
460
|
+
inlineStyles,
|
|
461
|
+
registerInlineStyle(desc) {
|
|
462
|
+
let entry = inlineStyles.get(desc.id);
|
|
463
|
+
if (!entry) {
|
|
464
|
+
entry = {
|
|
465
|
+
id: desc.id,
|
|
466
|
+
content: desc.content || "",
|
|
467
|
+
attrs: desc.attrs,
|
|
468
|
+
emitted: false
|
|
469
|
+
};
|
|
470
|
+
inlineStyles.set(desc.id, entry);
|
|
471
|
+
}
|
|
472
|
+
if (currentBoundaryId) {
|
|
473
|
+
let styles = boundaryStyles.get(currentBoundaryId);
|
|
474
|
+
if (!styles) {
|
|
475
|
+
styles = new Set();
|
|
476
|
+
boundaryStyles.set(currentBoundaryId, styles);
|
|
477
|
+
}
|
|
478
|
+
styles.add(entry);
|
|
479
|
+
}
|
|
480
|
+
return entry;
|
|
481
|
+
},
|
|
482
|
+
get currentBoundaryId() {
|
|
483
|
+
return currentBoundaryId;
|
|
484
|
+
},
|
|
485
|
+
set currentBoundaryId(v) {
|
|
486
|
+
currentBoundaryId = v;
|
|
487
|
+
},
|
|
488
|
+
registerModule(key, entryUrl) {
|
|
489
|
+
const id = currentBoundaryId || "";
|
|
490
|
+
let map = boundaryModules.get(id);
|
|
491
|
+
if (!map) {
|
|
492
|
+
map = {};
|
|
493
|
+
boundaryModules.set(id, map);
|
|
494
|
+
}
|
|
495
|
+
map[key] = entryUrl;
|
|
496
|
+
},
|
|
497
|
+
getBoundaryModules(id) {
|
|
498
|
+
return boundaryModules.get(id) || null;
|
|
499
|
+
},
|
|
500
|
+
getBoundaryStyles(id) {
|
|
501
|
+
return boundaryStyles.get(id) || null;
|
|
502
|
+
}
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
function warnUnresolvedModuleAssets(moduleUrl, warned) {
|
|
506
|
+
if (warned.has(moduleUrl)) return;
|
|
507
|
+
warned.add(moduleUrl);
|
|
508
|
+
console.error(`Asset manifest returned no client assets for module "${moduleUrl}". ` + "If this module is a server-rendered lazy() component, its entry will be missing from " + "the serialized hydration asset map, the client will be unable to preload it, and " + "hydration will fail with 'lazy() module \"…\" was not preloaded before hydration'. " + "This means the integration's asset resolver (dev manifest bridge or build client " + "manifest) failed to answer for this module — check the integration's server logs, " + "restart the dev server, or verify the module is included in the client build.");
|
|
509
|
+
}
|
|
510
|
+
function guardResolvedAssets(moduleUrl, result, warned) {
|
|
511
|
+
if (result && typeof result.then === "function") {
|
|
512
|
+
return result.then(assets => {
|
|
513
|
+
if (!assets || !assets.js || !assets.js.length) warnUnresolvedModuleAssets(moduleUrl, warned);
|
|
514
|
+
return assets;
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
if (!result || !result.js || !result.js.length) warnUnresolvedModuleAssets(moduleUrl, warned);
|
|
518
|
+
return result;
|
|
519
|
+
}
|
|
520
|
+
function applyAssetTracking(context, tracking, manifest, noScripts) {
|
|
521
|
+
const warned = new Set();
|
|
522
|
+
const guard = noScripts ? resolve => resolve : resolve => moduleUrl => guardResolvedAssets(moduleUrl, resolve(moduleUrl), warned);
|
|
523
|
+
Object.defineProperty(context, "_currentBoundaryId", {
|
|
524
|
+
get() {
|
|
525
|
+
return tracking.currentBoundaryId;
|
|
526
|
+
},
|
|
527
|
+
set(v) {
|
|
528
|
+
tracking.currentBoundaryId = v;
|
|
529
|
+
},
|
|
530
|
+
configurable: true,
|
|
531
|
+
enumerable: true
|
|
532
|
+
});
|
|
533
|
+
context.registerModule = tracking.registerModule;
|
|
534
|
+
context.getBoundaryModules = tracking.getBoundaryModules;
|
|
535
|
+
if (typeof manifest === "function") {
|
|
536
|
+
context.resolveAssets = guard(manifest);
|
|
537
|
+
} else if (manifest && typeof manifest.resolve === "function") {
|
|
538
|
+
context.resolveAssets = guard(key => manifest.resolve(key));
|
|
539
|
+
if (typeof manifest.resolveSync === "function") {
|
|
540
|
+
context.resolveAssetsSync = key => manifest.resolveSync(key);
|
|
541
|
+
}
|
|
542
|
+
} else if (manifest) {
|
|
543
|
+
const resolve = moduleUrl => resolveAssets(moduleUrl, manifest);
|
|
544
|
+
context.resolveAssets = guard(resolve);
|
|
545
|
+
context.resolveAssetsSync = resolve;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
function isCssUrl(url) {
|
|
549
|
+
const q = url.search(/[?#]/);
|
|
550
|
+
return (q === -1 ? url : url.slice(0, q)).endsWith(".css");
|
|
551
|
+
}
|
|
552
|
+
function createHeadRegistry() {
|
|
553
|
+
return {
|
|
554
|
+
pending: [],
|
|
555
|
+
committed: [],
|
|
556
|
+
seq: 0,
|
|
557
|
+
uniq: 0,
|
|
558
|
+
resources: new Set(),
|
|
559
|
+
eagerHtml: "",
|
|
560
|
+
flushed: null,
|
|
561
|
+
shellFlushed: false,
|
|
562
|
+
parkedResources: []
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
function registerHeadTags(registry, context, tracking, emitResource, nonce, tags) {
|
|
566
|
+
const boundary = context._currentBoundaryId || "";
|
|
567
|
+
if (typeof tags === "function") {
|
|
568
|
+
registry.pending.push({
|
|
569
|
+
boundary,
|
|
570
|
+
list: tags,
|
|
571
|
+
resource: (desc, rel) => emitHeadResource(registry, context, tracking, emitResource, nonce, desc, rel)
|
|
572
|
+
});
|
|
573
|
+
return;
|
|
574
|
+
}
|
|
575
|
+
if (!Array.isArray(tags)) tags = [tags];
|
|
576
|
+
const probe = solidJs.sharedConfig.context && solidJs.sharedConfig.context._loadingPhase;
|
|
577
|
+
let replaceable = null;
|
|
578
|
+
for (let i = 0; i < tags.length; i++) {
|
|
579
|
+
const desc = tags[i];
|
|
580
|
+
if (!desc || !HEAD_ELIGIBLE_TAGS.has(desc.tag)) {
|
|
581
|
+
continue;
|
|
582
|
+
}
|
|
583
|
+
const cls = classifyHeadTag(desc);
|
|
584
|
+
if (probe && !cls.resource) {
|
|
585
|
+
try {
|
|
586
|
+
evalHeadProps(desc.props || {}, cls.rel !== undefined ? {
|
|
587
|
+
rel: cls.rel
|
|
588
|
+
} : undefined);
|
|
589
|
+
evalHeadValue(desc.key);
|
|
590
|
+
} catch (err) {
|
|
591
|
+
if (solidJs.ssrHandleError(err)) throw err;
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
if (cls.resource) {
|
|
595
|
+
emitHeadResource(registry, context, tracking, emitResource, nonce, desc, cls.rel);
|
|
596
|
+
} else {
|
|
597
|
+
(replaceable || (replaceable = [])).push(cls.rel !== undefined ? {
|
|
598
|
+
tag: desc.tag,
|
|
599
|
+
props: desc.props,
|
|
600
|
+
key: desc.key,
|
|
601
|
+
rel: cls.rel
|
|
602
|
+
} : desc);
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
if (replaceable) registry.pending.push({
|
|
606
|
+
boundary,
|
|
607
|
+
tags: replaceable
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
function headShellReady(registry, block) {
|
|
611
|
+
let ready = true;
|
|
612
|
+
const pends = err => {
|
|
613
|
+
const source = solidJs.ssrHandleError(err, true);
|
|
614
|
+
if (!source) return false;
|
|
615
|
+
block(source);
|
|
616
|
+
ready = false;
|
|
617
|
+
return true;
|
|
618
|
+
};
|
|
619
|
+
const parked = registry.parkedResources;
|
|
620
|
+
for (let i = parked.length - 1; i >= 0; i--) {
|
|
621
|
+
const {
|
|
622
|
+
desc,
|
|
623
|
+
rel,
|
|
624
|
+
emit
|
|
625
|
+
} = parked[i];
|
|
626
|
+
try {
|
|
627
|
+
evalHeadProps(desc.props || {}, rel !== undefined ? {
|
|
628
|
+
rel
|
|
629
|
+
} : undefined);
|
|
630
|
+
} catch (err) {
|
|
631
|
+
if (pends(err)) continue;
|
|
632
|
+
parked.splice(i, 1);
|
|
633
|
+
continue;
|
|
634
|
+
}
|
|
635
|
+
parked.splice(i, 1);
|
|
636
|
+
emit();
|
|
637
|
+
}
|
|
638
|
+
for (let i = 0; i < registry.pending.length; i++) {
|
|
639
|
+
const reg = registry.pending[i];
|
|
640
|
+
if (reg.boundary !== "" || reg.list) continue;
|
|
641
|
+
for (let j = 0; j < reg.tags.length; j++) {
|
|
642
|
+
const desc = reg.tags[j];
|
|
643
|
+
try {
|
|
644
|
+
evalHeadProps(desc.props || {}, desc.rel !== undefined ? {
|
|
645
|
+
rel: desc.rel
|
|
646
|
+
} : undefined);
|
|
647
|
+
evalHeadValue(desc.key);
|
|
648
|
+
} catch (err) {
|
|
649
|
+
pends(err);
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
return ready;
|
|
654
|
+
}
|
|
655
|
+
function emitHeadResource(registry, context, tracking, emitResource, nonce, desc, rel) {
|
|
656
|
+
let props;
|
|
657
|
+
try {
|
|
658
|
+
props = evalHeadProps(desc.props || {}, rel !== undefined ? {
|
|
659
|
+
rel
|
|
660
|
+
} : undefined);
|
|
661
|
+
} catch (err) {
|
|
662
|
+
const loadingPhase = solidJs.sharedConfig.context && solidJs.sharedConfig.context._loadingPhase;
|
|
663
|
+
if (loadingPhase && solidJs.ssrHandleError(err)) throw err;
|
|
664
|
+
if (!loadingPhase && !context._currentBoundaryId && !registry.shellFlushed && typeof context.block === "function" && solidJs.ssrHandleError(err, true)) {
|
|
665
|
+
registry.parkedResources.push({
|
|
666
|
+
desc,
|
|
667
|
+
rel,
|
|
668
|
+
emit: () => emitHeadResource(registry, context, tracking, emitResource, nonce, desc, rel)
|
|
669
|
+
});
|
|
670
|
+
return;
|
|
671
|
+
}
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
674
|
+
const identity = resourceIdentity(desc.tag, props);
|
|
675
|
+
if (registry.resources.has(identity)) return;
|
|
676
|
+
registry.resources.add(identity);
|
|
677
|
+
if (desc.tag === "link" && (rel === "stylesheet" || rel === "modulepreload")) {
|
|
678
|
+
let plain = true;
|
|
679
|
+
let gateable = rel === "stylesheet";
|
|
680
|
+
for (const name in props) {
|
|
681
|
+
if (name === "rel" || name === "href") continue;
|
|
682
|
+
plain = false;
|
|
683
|
+
if (!STYLESHEET_FETCH_META.has(name)) gateable = false;
|
|
684
|
+
}
|
|
685
|
+
if (plain && props.href != null) {
|
|
686
|
+
const isCss = isCssUrl(props.href);
|
|
687
|
+
if (rel === "stylesheet" ? isCss : !isCss) {
|
|
688
|
+
context.registerAsset(rel === "stylesheet" ? "style" : "module", props.href);
|
|
689
|
+
return;
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
if (gateable && props.href != null) {
|
|
693
|
+
const attrHtml = renderHeadAttrHtml(props);
|
|
694
|
+
const entry = {
|
|
695
|
+
href: props.href,
|
|
696
|
+
attrHtml,
|
|
697
|
+
attrs: headAttrRecord(props)
|
|
698
|
+
};
|
|
699
|
+
if (tracking.currentBoundaryId) {
|
|
700
|
+
let styles = tracking.boundaryStyles.get(tracking.currentBoundaryId);
|
|
701
|
+
if (!styles) tracking.boundaryStyles.set(tracking.currentBoundaryId, styles = new Set());
|
|
702
|
+
styles.add(entry);
|
|
703
|
+
}
|
|
704
|
+
const markup = `<link${attrHtml}>`;
|
|
705
|
+
if (emitResource) emitResource(markup, entry);else {
|
|
706
|
+
registry.eagerHtml += markup;
|
|
707
|
+
entry.emitted = true;
|
|
708
|
+
}
|
|
709
|
+
return;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
const url = props.href || props.src;
|
|
713
|
+
if (url != null && tracking.emittedAssets.has(url)) return;
|
|
714
|
+
const markup = renderHeadTagMarkup(desc.tag, props, null, nonce);
|
|
715
|
+
if (emitResource) emitResource(markup);else registry.eagerHtml += markup;
|
|
716
|
+
}
|
|
717
|
+
function commitHeadBoundary(registry, boundary, isPendingFragment) {
|
|
718
|
+
const keep = [];
|
|
719
|
+
const groups = [];
|
|
720
|
+
for (let i = 0; i < registry.pending.length; i++) {
|
|
721
|
+
const reg = registry.pending[i];
|
|
722
|
+
const mine = boundary === "" ? !(isPendingFragment && reg.boundary !== "" && isPendingFragment(reg.boundary)) : reg.boundary === boundary;
|
|
723
|
+
if (!mine) {
|
|
724
|
+
keep.push(reg);
|
|
725
|
+
continue;
|
|
726
|
+
}
|
|
727
|
+
let descs = reg.tags;
|
|
728
|
+
if (reg.list) {
|
|
729
|
+
let resolved;
|
|
730
|
+
try {
|
|
731
|
+
resolved = reg.list();
|
|
732
|
+
} catch (err) {
|
|
733
|
+
continue;
|
|
734
|
+
}
|
|
735
|
+
if (!Array.isArray(resolved)) resolved = [resolved];
|
|
736
|
+
descs = [];
|
|
737
|
+
for (let j = 0; j < resolved.length; j++) {
|
|
738
|
+
const desc = resolved[j];
|
|
739
|
+
if (!desc || !HEAD_ELIGIBLE_TAGS.has(desc.tag)) {
|
|
740
|
+
continue;
|
|
741
|
+
}
|
|
742
|
+
const cls = classifyHeadTag(desc);
|
|
743
|
+
if (cls.resource) {
|
|
744
|
+
reg.resource(desc, cls.rel);
|
|
745
|
+
} else {
|
|
746
|
+
descs.push(cls.rel !== undefined ? {
|
|
747
|
+
tag: desc.tag,
|
|
748
|
+
props: desc.props,
|
|
749
|
+
key: desc.key,
|
|
750
|
+
rel: cls.rel
|
|
751
|
+
} : desc);
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
const tags = [];
|
|
756
|
+
for (let j = 0; j < descs.length; j++) {
|
|
757
|
+
const desc = descs[j];
|
|
758
|
+
let props, key;
|
|
759
|
+
try {
|
|
760
|
+
props = evalHeadProps(desc.props || {}, desc.rel !== undefined ? {
|
|
761
|
+
rel: desc.rel
|
|
762
|
+
} : undefined);
|
|
763
|
+
key = evalHeadValue(desc.key);
|
|
764
|
+
} catch (err) {
|
|
765
|
+
continue;
|
|
766
|
+
}
|
|
767
|
+
const identity = replaceableIdentity(desc.tag, props, key, "u:" + registry.uniq++);
|
|
768
|
+
if ((identity === "base" || identity === "charset") && registry.shellFlushed) {
|
|
769
|
+
continue;
|
|
770
|
+
}
|
|
771
|
+
tags.push({
|
|
772
|
+
tag: desc.tag,
|
|
773
|
+
props,
|
|
774
|
+
identity
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
if (tags.length) groups.push({
|
|
778
|
+
seq: registry.seq++,
|
|
779
|
+
tags
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
registry.pending = keep;
|
|
783
|
+
for (let i = 0; i < groups.length; i++) registry.committed.push(groups[i]);
|
|
784
|
+
return groups;
|
|
785
|
+
}
|
|
786
|
+
function adoptHeadBoundary(registry, childKey, parentKey) {
|
|
787
|
+
for (let i = 0; i < registry.pending.length; i++) {
|
|
788
|
+
if (registry.pending[i].boundary === childKey) registry.pending[i].boundary = parentKey;
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
function dropHeadBoundary(registry, boundary) {
|
|
792
|
+
registry.pending = registry.pending.filter(reg => reg.boundary !== boundary);
|
|
793
|
+
}
|
|
794
|
+
function headGroupSignature(winner) {
|
|
795
|
+
let sig = "" + winner.seq;
|
|
796
|
+
for (let i = 0; i < winner.tags.length; i++) {
|
|
797
|
+
const t = winner.tags[i];
|
|
798
|
+
sig += "|" + t.tag + JSON.stringify(t.props);
|
|
799
|
+
}
|
|
800
|
+
return sig;
|
|
801
|
+
}
|
|
802
|
+
function renderShellHead(registry, nonce, isPendingFragment) {
|
|
803
|
+
commitHeadBoundary(registry, "", isPendingFragment);
|
|
804
|
+
registry.shellFlushed = true;
|
|
805
|
+
const winners = resolveHead(registry.committed);
|
|
806
|
+
registry.flushed = new Map();
|
|
807
|
+
let prelude = "";
|
|
808
|
+
let links = "";
|
|
809
|
+
let metas = "";
|
|
810
|
+
let others = "";
|
|
811
|
+
let scripts = "";
|
|
812
|
+
for (const [identity, winner] of winners) {
|
|
813
|
+
registry.flushed.set(identity, headGroupSignature(winner));
|
|
814
|
+
for (let i = 0; i < winner.tags.length; i++) {
|
|
815
|
+
const t = winner.tags[i];
|
|
816
|
+
const markup = renderHeadTagMarkup(t.tag, t.props, identity, nonce);
|
|
817
|
+
if (identity === "charset" || identity === "base") prelude += markup;else if (t.tag === "link" || t.tag === "style") links += markup;else if (t.tag === "meta") metas += markup;else if (t.tag === "script") scripts += markup;else others += markup;
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
return {
|
|
821
|
+
prelude,
|
|
822
|
+
html: registry.eagerHtml + links + metas + others + scripts
|
|
823
|
+
};
|
|
824
|
+
}
|
|
825
|
+
function flushHeadFragment(registry, boundary) {
|
|
826
|
+
const groups = commitHeadBoundary(registry, boundary);
|
|
827
|
+
if (!groups.length) return null;
|
|
828
|
+
const winners = resolveHead(registry.committed);
|
|
829
|
+
const affected = new Set();
|
|
830
|
+
for (let i = 0; i < groups.length; i++) for (let j = 0; j < groups[i].tags.length; j++) affected.add(groups[i].tags[j].identity);
|
|
831
|
+
const ops = [];
|
|
832
|
+
for (const identity of affected) {
|
|
833
|
+
const winner = winners.get(identity);
|
|
834
|
+
const sig = headGroupSignature(winner);
|
|
835
|
+
if (registry.flushed.get(identity) === sig) continue;
|
|
836
|
+
const existed = registry.flushed.has(identity);
|
|
837
|
+
registry.flushed.set(identity, sig);
|
|
838
|
+
if (identity === "title") {
|
|
839
|
+
const children = winner.tags[0].props.children;
|
|
840
|
+
ops.push(["t", children == null ? "" : String(children)]);
|
|
841
|
+
continue;
|
|
842
|
+
}
|
|
843
|
+
if (existed) ops.push(["r", identity]);
|
|
844
|
+
for (let i = 0; i < winner.tags.length; i++) {
|
|
845
|
+
const t = winner.tags[i];
|
|
846
|
+
const attrs = {};
|
|
847
|
+
for (const name in t.props) {
|
|
848
|
+
if (name === "children" || name === "ref" || name.slice(0, 2) === "on") continue;
|
|
849
|
+
if (!HEAD_ATTR_NAME.test(name)) {
|
|
850
|
+
continue;
|
|
851
|
+
}
|
|
852
|
+
const v = t.props[name];
|
|
853
|
+
if (v == null || v === false) continue;
|
|
854
|
+
attrs[name] = v === true ? "" : String(v);
|
|
855
|
+
}
|
|
856
|
+
const children = t.props.children;
|
|
857
|
+
ops.push(["a", identity, t.tag, attrs, children == null ? null : String(children)]);
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
return ops.length ? ops : null;
|
|
861
|
+
}
|
|
862
|
+
function renderHeadAttrHtml(props) {
|
|
863
|
+
let attrs = "";
|
|
864
|
+
for (const name in props) {
|
|
865
|
+
if (name === "children" || name === "ref" || name.slice(0, 2) === "on") continue;
|
|
866
|
+
if (!HEAD_ATTR_NAME.test(name)) {
|
|
867
|
+
continue;
|
|
868
|
+
}
|
|
869
|
+
const v = props[name];
|
|
870
|
+
if (v == null || v === false) continue;
|
|
871
|
+
attrs += v === true ? ` ${name}` : ` ${name}="${escape(String(v), true)}"`;
|
|
872
|
+
}
|
|
873
|
+
return attrs;
|
|
874
|
+
}
|
|
875
|
+
function headAttrRecord(props, skipRelHref) {
|
|
876
|
+
let attrs = null;
|
|
877
|
+
for (const name in props) {
|
|
878
|
+
if (name === "children" || name === "ref" || name.slice(0, 2) === "on") continue;
|
|
879
|
+
if ((name === "rel" || name === "href")) continue;
|
|
880
|
+
if (!HEAD_ATTR_NAME.test(name)) continue;
|
|
881
|
+
const v = props[name];
|
|
882
|
+
if (v == null || v === false) continue;
|
|
883
|
+
(attrs || (attrs = {}))[name] = v === true ? "" : String(v);
|
|
884
|
+
}
|
|
885
|
+
return attrs;
|
|
886
|
+
}
|
|
887
|
+
function renderHeadTagMarkup(tag, props, identity, nonce) {
|
|
888
|
+
let attrs = renderHeadAttrHtml(props);
|
|
889
|
+
if (identity != null) attrs += ` data-dh="${escape(identity, true)}"`;
|
|
890
|
+
if (nonce && (tag === "script" || tag === "style")) attrs += ` nonce="${nonce}"`;
|
|
891
|
+
if (tag === "meta" || tag === "link" || tag === "base") return `<${tag}${attrs}>`;
|
|
892
|
+
let body = props.children == null ? "" : String(props.children);
|
|
893
|
+
if (tag === "script") body = body.replace(/<\/(script)/gi, "<\\/$1");else if (tag === "style") body = escapeStyleContent(body);else body = escape(body);
|
|
894
|
+
return `<${tag}${attrs}>${body}</${tag}>`;
|
|
895
|
+
}
|
|
896
|
+
function useHead(tags) {
|
|
897
|
+
const ctx = solidJs.sharedConfig.context;
|
|
898
|
+
if (!ctx || !ctx.registerHeadTags) {
|
|
899
|
+
return;
|
|
900
|
+
}
|
|
901
|
+
ctx.registerHeadTags(tags);
|
|
902
|
+
}
|
|
51
903
|
const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
|
|
52
|
-
const REPLACE_SCRIPT = `function $df(e,n,o,t){if(n=document.getElementById(e)
|
|
904
|
+
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)}`;
|
|
53
906
|
function renderToString(code, options = {}) {
|
|
54
907
|
const {
|
|
55
908
|
renderId = "",
|
|
56
909
|
nonce,
|
|
57
|
-
noScripts
|
|
910
|
+
noScripts,
|
|
911
|
+
manifest,
|
|
912
|
+
onHead
|
|
58
913
|
} = options;
|
|
59
914
|
let scripts = "";
|
|
60
|
-
const serializer =
|
|
915
|
+
const serializer = createHydrationSerializer({
|
|
61
916
|
scopeId: renderId,
|
|
917
|
+
plugins: options.plugins,
|
|
62
918
|
onData(script) {
|
|
63
919
|
if (noScripts) return;
|
|
64
920
|
if (!scripts) {
|
|
@@ -68,27 +924,52 @@ function renderToString(code, options = {}) {
|
|
|
68
924
|
},
|
|
69
925
|
onError: options.onError
|
|
70
926
|
});
|
|
927
|
+
const tracking = createAssetTracking();
|
|
928
|
+
const headRegistry = createHeadRegistry();
|
|
71
929
|
solidJs.sharedConfig.context = {
|
|
72
|
-
assets: [],
|
|
73
930
|
nonce,
|
|
74
931
|
escape: escape,
|
|
75
932
|
resolve: resolveSSRNode,
|
|
76
933
|
ssr: ssr,
|
|
934
|
+
registerHeadTags(tags) {
|
|
935
|
+
registerHeadTags(headRegistry, solidJs.sharedConfig.context, tracking, null, nonce, tags);
|
|
936
|
+
},
|
|
77
937
|
serialize(id, p) {
|
|
78
|
-
|
|
938
|
+
if (solidJs.sharedConfig.context.noHydrate) return;
|
|
939
|
+
if (p != null && typeof p === "object" && (typeof p.then === "function" || typeof p[Symbol.asyncIterator] === "function")) {
|
|
940
|
+
throw new Error("Cannot serialize async value in renderToString (id: " + id + "). " + "Use renderToStream for async data.");
|
|
941
|
+
}
|
|
942
|
+
serializer.write(id, p);
|
|
943
|
+
},
|
|
944
|
+
registerAsset(type, value) {
|
|
945
|
+
if (type === "inline-style") {
|
|
946
|
+
tracking.registerInlineStyle(value);
|
|
947
|
+
return;
|
|
948
|
+
}
|
|
949
|
+
if (tracking.currentBoundaryId && type === "style") {
|
|
950
|
+
let styles = tracking.boundaryStyles.get(tracking.currentBoundaryId);
|
|
951
|
+
if (!styles) {
|
|
952
|
+
styles = new Set();
|
|
953
|
+
tracking.boundaryStyles.set(tracking.currentBoundaryId, styles);
|
|
954
|
+
}
|
|
955
|
+
styles.add(value);
|
|
956
|
+
}
|
|
957
|
+
tracking.emittedAssets.add(value);
|
|
79
958
|
}
|
|
80
959
|
};
|
|
960
|
+
applyAssetTracking(solidJs.sharedConfig.context, tracking, manifest, noScripts);
|
|
961
|
+
registerEntryAssets(manifest);
|
|
81
962
|
let html = solidJs.createRoot(d => {
|
|
82
963
|
setTimeout(d);
|
|
83
964
|
return resolveSSRSync(escape(code()));
|
|
84
965
|
}, {
|
|
85
966
|
id: renderId
|
|
86
967
|
});
|
|
968
|
+
serializeFragmentAssets("", tracking.boundaryModules, solidJs.sharedConfig.context, renderId);
|
|
87
969
|
solidJs.sharedConfig.context.noHydrate = true;
|
|
88
970
|
serializer.close();
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
return html;
|
|
971
|
+
const head = renderShellHead(headRegistry, nonce, null);
|
|
972
|
+
return assembleDocument(resolveSSRSelectValues(html), tracking.emittedAssets, tracking.inlineStyles, scripts.length ? scripts : "", nonce, head, onHead);
|
|
92
973
|
}
|
|
93
974
|
function renderToStream(code, options = {}) {
|
|
94
975
|
let {
|
|
@@ -96,18 +977,64 @@ function renderToStream(code, options = {}) {
|
|
|
96
977
|
onCompleteShell,
|
|
97
978
|
onCompleteAll,
|
|
98
979
|
renderId = "",
|
|
99
|
-
noScripts
|
|
980
|
+
noScripts,
|
|
981
|
+
manifest,
|
|
982
|
+
onHead
|
|
100
983
|
} = options;
|
|
101
984
|
let dispose;
|
|
102
|
-
|
|
985
|
+
let dead = false;
|
|
986
|
+
const abandon = () => {
|
|
987
|
+
if (dead) return;
|
|
988
|
+
dead = true;
|
|
989
|
+
completed = true;
|
|
990
|
+
buffer = {
|
|
991
|
+
write() {}
|
|
992
|
+
};
|
|
993
|
+
writable = {
|
|
994
|
+
end() {}
|
|
995
|
+
};
|
|
996
|
+
if (dispose) {
|
|
997
|
+
const d = dispose;
|
|
998
|
+
dispose = () => {};
|
|
999
|
+
d();
|
|
1000
|
+
}
|
|
1001
|
+
};
|
|
1002
|
+
const failRender = err => {
|
|
1003
|
+
try {
|
|
1004
|
+
options.onError ? options.onError(err) : console.error(err);
|
|
1005
|
+
} catch (_) {}
|
|
1006
|
+
abandon();
|
|
1007
|
+
};
|
|
1008
|
+
const guardSink = w => ({
|
|
1009
|
+
write(payload) {
|
|
1010
|
+
if (dead) return;
|
|
1011
|
+
try {
|
|
1012
|
+
w.write(payload);
|
|
1013
|
+
} catch (_) {
|
|
1014
|
+
abandon();
|
|
1015
|
+
}
|
|
1016
|
+
},
|
|
1017
|
+
end() {
|
|
1018
|
+
if (dead) return;
|
|
1019
|
+
try {
|
|
1020
|
+
w.end();
|
|
1021
|
+
} catch (_) {
|
|
1022
|
+
abandon();
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
});
|
|
1026
|
+
const blockingPromises = new Set();
|
|
1027
|
+
let headerEmitted = false;
|
|
103
1028
|
const pushTask = task => {
|
|
104
1029
|
if (noScripts) return;
|
|
105
|
-
if (!
|
|
106
|
-
|
|
1030
|
+
if (!headerEmitted) {
|
|
1031
|
+
headerEmitted = true;
|
|
1032
|
+
tasks += getLocalHeaderScript(renderId);
|
|
107
1033
|
}
|
|
108
1034
|
tasks += task + ";";
|
|
109
1035
|
if (!timer && firstFlushed) {
|
|
110
|
-
timer =
|
|
1036
|
+
timer = true;
|
|
1037
|
+
queue(() => queue(writeTasks));
|
|
111
1038
|
}
|
|
112
1039
|
};
|
|
113
1040
|
const onDone = () => {
|
|
@@ -122,15 +1049,72 @@ function renderToStream(code, options = {}) {
|
|
|
122
1049
|
completed = true;
|
|
123
1050
|
if (firstFlushed) dispose();
|
|
124
1051
|
};
|
|
125
|
-
const
|
|
1052
|
+
const sink = {
|
|
1053
|
+
data(payload) {
|
|
1054
|
+
pushTask(payload);
|
|
1055
|
+
},
|
|
1056
|
+
fragment(key, value, meta) {
|
|
1057
|
+
const deferActivation = !!meta.revealGroup;
|
|
1058
|
+
const styles = meta.styles;
|
|
1059
|
+
for (let i = 0; i < styles.inline.length; i++) {
|
|
1060
|
+
buffer.write(renderInlineStyle(styles.inline[i], nonce));
|
|
1061
|
+
}
|
|
1062
|
+
if (styles.links.length) {
|
|
1063
|
+
emitTask(`$dfs("${key}",${styles.links.length},${deferActivation ? 1 : 0})`);
|
|
1064
|
+
writeTasks();
|
|
1065
|
+
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}')">`);
|
|
1067
|
+
}
|
|
1068
|
+
buffer.write(`<template id="${key}">${value}</template>`);
|
|
1069
|
+
} else {
|
|
1070
|
+
buffer.write(`<template id="${key}">${value}</template>`);
|
|
1071
|
+
if (!deferActivation) {
|
|
1072
|
+
emitTask(`$df("${key}")`);
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
},
|
|
1076
|
+
reveal(keys, meta) {
|
|
1077
|
+
emitTask(`${meta.fallback ? "$dflj" : "$dfj"}(${JSON.stringify(keys)})`);
|
|
1078
|
+
},
|
|
1079
|
+
asset(type, value) {
|
|
1080
|
+
if (type === "module") {
|
|
1081
|
+
buffer.write(`<link rel="modulepreload" href="${value}">`);
|
|
1082
|
+
} else if (type === "inline-style") {
|
|
1083
|
+
buffer.write(renderInlineStyle(value, nonce));
|
|
1084
|
+
} else if (type === "head-tag") {
|
|
1085
|
+
buffer.write(value);
|
|
1086
|
+
}
|
|
1087
|
+
},
|
|
1088
|
+
shell(shellHtml, meta) {
|
|
1089
|
+
buffer.write(assembleDocument(shellHtml, meta.preloads, meta.inlineStyles, meta.tasks.length ? meta.tasks : "", nonce, meta.head, onHead));
|
|
1090
|
+
},
|
|
1091
|
+
...options.sink
|
|
1092
|
+
};
|
|
1093
|
+
const serializer = (options.serializer || createHydrationSerializer)({
|
|
126
1094
|
scopeId: options.renderId,
|
|
127
|
-
|
|
1095
|
+
plugins: options.plugins,
|
|
1096
|
+
onData: payload => sink.data(payload),
|
|
128
1097
|
onDone,
|
|
129
1098
|
onError: options.onError
|
|
130
1099
|
});
|
|
1100
|
+
let rootAssetsSerialized = false;
|
|
1101
|
+
const serializeRootAssets = () => {
|
|
1102
|
+
if (rootAssetsSerialized) return;
|
|
1103
|
+
rootAssetsSerialized = true;
|
|
1104
|
+
serializeFragmentAssets("", tracking.boundaryModules, context, renderId);
|
|
1105
|
+
};
|
|
1106
|
+
let holds = 0;
|
|
131
1107
|
const flushEnd = () => {
|
|
132
|
-
if (!registry.size) {
|
|
133
|
-
|
|
1108
|
+
if (!registry.size && !holds) {
|
|
1109
|
+
serializeRootAssets();
|
|
1110
|
+
queue(() => queue(() => {
|
|
1111
|
+
if (context.live.end) {
|
|
1112
|
+
const end = context.live.end;
|
|
1113
|
+
context.live.end = null;
|
|
1114
|
+
end();
|
|
1115
|
+
}
|
|
1116
|
+
serializer.flush();
|
|
1117
|
+
}));
|
|
134
1118
|
}
|
|
135
1119
|
};
|
|
136
1120
|
const registry = new Map();
|
|
@@ -139,7 +1123,6 @@ function renderToStream(code, options = {}) {
|
|
|
139
1123
|
buffer.write(`<script${nonce ? ` nonce="${nonce}"` : ""}>${tasks}</script>`);
|
|
140
1124
|
tasks = "";
|
|
141
1125
|
}
|
|
142
|
-
timer && clearTimeout(timer);
|
|
143
1126
|
timer = null;
|
|
144
1127
|
};
|
|
145
1128
|
let context;
|
|
@@ -150,18 +1133,94 @@ function renderToStream(code, options = {}) {
|
|
|
150
1133
|
let completed = false;
|
|
151
1134
|
let shellCompleted = false;
|
|
152
1135
|
let scriptFlushed = false;
|
|
1136
|
+
let headStyles;
|
|
1137
|
+
const revealGroups = new Map();
|
|
153
1138
|
let timer = null;
|
|
1139
|
+
const emitTask = task => {
|
|
1140
|
+
pushTask(`${task}${!scriptFlushed ? ";" + REPLACE_SCRIPT : ""}`);
|
|
1141
|
+
scriptFlushed = true;
|
|
1142
|
+
};
|
|
1143
|
+
function resolveRevealKeys(groupOrKeys, release, consume) {
|
|
1144
|
+
if (Array.isArray(groupOrKeys)) return groupOrKeys.slice();
|
|
1145
|
+
let group = revealGroups.get(groupOrKeys);
|
|
1146
|
+
if (!group) {
|
|
1147
|
+
if (!release) return;
|
|
1148
|
+
group = {
|
|
1149
|
+
order: [],
|
|
1150
|
+
keys: new Set(),
|
|
1151
|
+
released: true
|
|
1152
|
+
};
|
|
1153
|
+
revealGroups.set(groupOrKeys, group);
|
|
1154
|
+
} else if (release) group.released = true;
|
|
1155
|
+
if (!group.order.length) return;
|
|
1156
|
+
const keys = group.order.slice();
|
|
1157
|
+
if (consume) revealGroups.delete(groupOrKeys);
|
|
1158
|
+
return keys;
|
|
1159
|
+
}
|
|
1160
|
+
let rootHoles = null;
|
|
1161
|
+
let nextHoleId = 0;
|
|
154
1162
|
let buffer = {
|
|
155
1163
|
write(payload) {
|
|
156
1164
|
tmp += payload;
|
|
157
1165
|
}
|
|
158
1166
|
};
|
|
1167
|
+
const tracking = createAssetTracking();
|
|
1168
|
+
const headRegistry = createHeadRegistry();
|
|
1169
|
+
let headScriptFlushed = false;
|
|
1170
|
+
const emitHeadOps = (key, ops) => {
|
|
1171
|
+
const payload = JSON.stringify(ops).replace(/</g, "\\u003C");
|
|
1172
|
+
emitTask(`${!headScriptFlushed ? HEAD_SCRIPT : ""}(_$HY.hp=_$HY.hp||{})[${JSON.stringify(key)}]=${payload}`);
|
|
1173
|
+
headScriptFlushed = true;
|
|
1174
|
+
};
|
|
159
1175
|
solidJs.sharedConfig.context = context = {
|
|
160
1176
|
async: true,
|
|
161
|
-
assets: [],
|
|
162
1177
|
nonce,
|
|
1178
|
+
live: {},
|
|
1179
|
+
registerHeadTags(tags) {
|
|
1180
|
+
registerHeadTags(headRegistry, context, tracking,
|
|
1181
|
+
(markup, gateEntry) => {
|
|
1182
|
+
if (!firstFlushed) {
|
|
1183
|
+
headRegistry.eagerHtml += markup;
|
|
1184
|
+
if (gateEntry) gateEntry.emitted = true;
|
|
1185
|
+
} else if (!gateEntry || !tracking.currentBoundaryId) {
|
|
1186
|
+
sink.asset("head-tag", markup);
|
|
1187
|
+
}
|
|
1188
|
+
}, nonce, tags);
|
|
1189
|
+
},
|
|
1190
|
+
registerAsset(type, value) {
|
|
1191
|
+
if (type === "inline-style") {
|
|
1192
|
+
const entry = tracking.registerInlineStyle(value);
|
|
1193
|
+
if (firstFlushed && !tracking.currentBoundaryId && !entry.emitted) {
|
|
1194
|
+
entry.emitted = true;
|
|
1195
|
+
sink.asset("inline-style", entry);
|
|
1196
|
+
}
|
|
1197
|
+
return;
|
|
1198
|
+
}
|
|
1199
|
+
if (tracking.currentBoundaryId && type === "style") {
|
|
1200
|
+
let styles = tracking.boundaryStyles.get(tracking.currentBoundaryId);
|
|
1201
|
+
if (!styles) {
|
|
1202
|
+
styles = new Set();
|
|
1203
|
+
tracking.boundaryStyles.set(tracking.currentBoundaryId, styles);
|
|
1204
|
+
}
|
|
1205
|
+
styles.add(value);
|
|
1206
|
+
}
|
|
1207
|
+
if (!tracking.emittedAssets.has(value)) {
|
|
1208
|
+
tracking.emittedAssets.add(value);
|
|
1209
|
+
if (firstFlushed) sink.asset(type, value);
|
|
1210
|
+
}
|
|
1211
|
+
},
|
|
163
1212
|
block(p) {
|
|
164
|
-
if (!firstFlushed) blockingPromises.
|
|
1213
|
+
if (!firstFlushed) blockingPromises.add(p);
|
|
1214
|
+
},
|
|
1215
|
+
hold() {
|
|
1216
|
+
holds++;
|
|
1217
|
+
let released = false;
|
|
1218
|
+
return () => {
|
|
1219
|
+
if (released) return;
|
|
1220
|
+
released = true;
|
|
1221
|
+
holds--;
|
|
1222
|
+
if (!holds) queue(flushEnd);
|
|
1223
|
+
};
|
|
165
1224
|
},
|
|
166
1225
|
replace(id, payloadFn) {
|
|
167
1226
|
if (firstFlushed) return;
|
|
@@ -171,21 +1230,36 @@ function renderToStream(code, options = {}) {
|
|
|
171
1230
|
const last = html.indexOf(`<!--!$/${id}-->`, first + placeholder.length);
|
|
172
1231
|
html = html.slice(0, first) + resolveSSRSync(escape(payloadFn())) + html.slice(last + placeholder.length + 1);
|
|
173
1232
|
},
|
|
174
|
-
serialize(id, p,
|
|
175
|
-
|
|
176
|
-
if (!firstFlushed &&
|
|
177
|
-
blockingPromises.
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
}).catch(e => {
|
|
181
|
-
serializer.write(id, e);
|
|
182
|
-
});
|
|
183
|
-
} else if (!serverOnly) serializer.write(id, p);
|
|
1233
|
+
serialize(id, p, deferStream) {
|
|
1234
|
+
if (solidJs.sharedConfig.context.noHydrate) return;
|
|
1235
|
+
if (!firstFlushed && deferStream && typeof p === "object" && "then" in p) {
|
|
1236
|
+
blockingPromises.add(p);
|
|
1237
|
+
p.then(d => serializer.write(id, d)).catch(e => serializer.write(id, e));
|
|
1238
|
+
} else serializer.write(id, p);
|
|
184
1239
|
},
|
|
185
1240
|
escape: escape,
|
|
186
1241
|
resolve: resolveSSRNode,
|
|
187
1242
|
ssr: ssr,
|
|
188
|
-
registerFragment(key) {
|
|
1243
|
+
registerFragment(key, options) {
|
|
1244
|
+
const revealGroup = options && options.revealGroup;
|
|
1245
|
+
if (revealGroup) {
|
|
1246
|
+
let group = revealGroups.get(revealGroup);
|
|
1247
|
+
if (!group) {
|
|
1248
|
+
group = {
|
|
1249
|
+
order: [],
|
|
1250
|
+
keys: new Set(),
|
|
1251
|
+
released: false
|
|
1252
|
+
};
|
|
1253
|
+
revealGroups.set(revealGroup, group);
|
|
1254
|
+
}
|
|
1255
|
+
if (!group.keys.has(key)) {
|
|
1256
|
+
group.keys.add(key);
|
|
1257
|
+
group.order.push(key);
|
|
1258
|
+
}
|
|
1259
|
+
if (group.released) {
|
|
1260
|
+
throw new Error("registerFragment() for reveal group '" + revealGroup + "' was called after revealFragments(). Ensure template payload is emitted before grouped reveal.");
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
189
1263
|
if (!registry.has(key)) {
|
|
190
1264
|
let resolve, reject;
|
|
191
1265
|
const p = new Promise((r, rej) => (resolve = r, reject = rej));
|
|
@@ -195,7 +1269,7 @@ function renderToStream(code, options = {}) {
|
|
|
195
1269
|
queue(flushEnd);
|
|
196
1270
|
}))
|
|
197
1271
|
});
|
|
198
|
-
serializer.write(key, p);
|
|
1272
|
+
serializer.write(key + "_fr", p);
|
|
199
1273
|
}
|
|
200
1274
|
return (value, error) => {
|
|
201
1275
|
if (registry.has(key)) {
|
|
@@ -211,37 +1285,121 @@ function renderToStream(code, options = {}) {
|
|
|
211
1285
|
const parent = registry.get(parentKey);
|
|
212
1286
|
parent.children ||= {};
|
|
213
1287
|
parent.children[key] = value !== undefined ? value : "";
|
|
1288
|
+
serializeFragmentAssets(key, tracking.boundaryModules, context);
|
|
1289
|
+
propagateBoundaryStyles(key, parentKey, tracking);
|
|
1290
|
+
adoptHeadBoundary(headRegistry, key, parentKey);
|
|
214
1291
|
item.resolve();
|
|
215
1292
|
return;
|
|
216
1293
|
}
|
|
217
1294
|
if (!completed) {
|
|
1295
|
+
if (error) dropHeadBoundary(headRegistry, key);
|
|
218
1296
|
if (!firstFlushed) {
|
|
219
1297
|
queue(() => html = replacePlaceholder(html, key, value !== undefined ? value : ""));
|
|
1298
|
+
serializeFragmentAssets(key, tracking.boundaryModules, context);
|
|
220
1299
|
item.resolve(error);
|
|
221
1300
|
} else {
|
|
222
|
-
|
|
223
|
-
|
|
1301
|
+
serializeFragmentAssets(key, tracking.boundaryModules, context);
|
|
1302
|
+
const styles = collectStreamStyles(key, tracking, headStyles);
|
|
1303
|
+
const headOps = error ? null : flushHeadFragment(headRegistry, key);
|
|
1304
|
+
if (headOps) emitHeadOps(key, headOps);
|
|
1305
|
+
sink.fragment(key, resolveSSRSelectValues(value !== undefined ? value : " "), {
|
|
1306
|
+
styles,
|
|
1307
|
+
revealGroup,
|
|
1308
|
+
error
|
|
1309
|
+
});
|
|
224
1310
|
item.resolve(error);
|
|
225
|
-
scriptFlushed = true;
|
|
226
1311
|
}
|
|
227
1312
|
}
|
|
228
1313
|
}
|
|
229
1314
|
return firstFlushed;
|
|
230
1315
|
};
|
|
1316
|
+
},
|
|
1317
|
+
revealFragments(groupOrKeys) {
|
|
1318
|
+
const keys = resolveRevealKeys(groupOrKeys, true, true);
|
|
1319
|
+
if (!keys) return;
|
|
1320
|
+
sink.reveal(keys, {
|
|
1321
|
+
fallback: false
|
|
1322
|
+
});
|
|
1323
|
+
},
|
|
1324
|
+
revealFallbacks(groupOrKeys) {
|
|
1325
|
+
const keys = resolveRevealKeys(groupOrKeys, false, false);
|
|
1326
|
+
if (!keys) return;
|
|
1327
|
+
sink.reveal(keys, {
|
|
1328
|
+
fallback: true
|
|
1329
|
+
});
|
|
231
1330
|
}
|
|
232
1331
|
};
|
|
1332
|
+
applyAssetTracking(context, tracking, manifest, noScripts);
|
|
1333
|
+
context.failRender = failRender;
|
|
1334
|
+
registerEntryAssets(manifest);
|
|
233
1335
|
let html = solidJs.createRoot(d => {
|
|
234
1336
|
dispose = d;
|
|
235
|
-
|
|
1337
|
+
const res = resolveSSRNode(escape(code()));
|
|
1338
|
+
if (!res.h.length) return res.t[0];
|
|
1339
|
+
rootHoles = [];
|
|
1340
|
+
let out = res.t[0];
|
|
1341
|
+
for (let i = 0; i < res.h.length; i++) {
|
|
1342
|
+
const id = nextHoleId++;
|
|
1343
|
+
rootHoles.push({
|
|
1344
|
+
id,
|
|
1345
|
+
fn: res.h[i]
|
|
1346
|
+
});
|
|
1347
|
+
out += `<!--rh${id}-->` + res.t[i + 1];
|
|
1348
|
+
}
|
|
1349
|
+
for (const p of res.p) blockingPromises.add(p);
|
|
1350
|
+
return out;
|
|
236
1351
|
}, {
|
|
237
1352
|
id: renderId
|
|
238
1353
|
});
|
|
1354
|
+
function resolveRootHoles() {
|
|
1355
|
+
if (!rootHoles) return true;
|
|
1356
|
+
const pending = [];
|
|
1357
|
+
for (const {
|
|
1358
|
+
id,
|
|
1359
|
+
fn
|
|
1360
|
+
} of rootHoles) {
|
|
1361
|
+
const marker = `<!--rh${id}-->`;
|
|
1362
|
+
const res = resolveSSRNode(fn);
|
|
1363
|
+
if (!res.h.length) {
|
|
1364
|
+
html = html.replace(marker, res.t[0]);
|
|
1365
|
+
} else {
|
|
1366
|
+
let out = res.t[0];
|
|
1367
|
+
for (let j = 0; j < res.h.length; j++) {
|
|
1368
|
+
const newId = nextHoleId++;
|
|
1369
|
+
pending.push({
|
|
1370
|
+
id: newId,
|
|
1371
|
+
fn: res.h[j]
|
|
1372
|
+
});
|
|
1373
|
+
out += `<!--rh${newId}-->` + res.t[j + 1];
|
|
1374
|
+
}
|
|
1375
|
+
html = html.replace(marker, out);
|
|
1376
|
+
for (const p of res.p) blockingPromises.add(p);
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
if (pending.length) {
|
|
1380
|
+
rootHoles = pending;
|
|
1381
|
+
return false;
|
|
1382
|
+
}
|
|
1383
|
+
rootHoles = null;
|
|
1384
|
+
return true;
|
|
1385
|
+
}
|
|
239
1386
|
function doShell() {
|
|
240
1387
|
if (shellCompleted) return;
|
|
241
1388
|
solidJs.sharedConfig.context = context;
|
|
242
|
-
|
|
243
|
-
if (
|
|
244
|
-
|
|
1389
|
+
if (!resolveRootHoles()) return;
|
|
1390
|
+
if (!headShellReady(headRegistry, p => blockingPromises.add(p))) return;
|
|
1391
|
+
headStyles = new Set();
|
|
1392
|
+
for (const url of tracking.emittedAssets) {
|
|
1393
|
+
if (isCssUrl(url)) headStyles.add(url);
|
|
1394
|
+
}
|
|
1395
|
+
serializeRootAssets();
|
|
1396
|
+
const head = renderShellHead(headRegistry, nonce, k => registry.has(k));
|
|
1397
|
+
sink.shell(resolveSSRSelectValues(html), {
|
|
1398
|
+
preloads: tracking.emittedAssets,
|
|
1399
|
+
inlineStyles: tracking.inlineStyles,
|
|
1400
|
+
tasks,
|
|
1401
|
+
head
|
|
1402
|
+
});
|
|
245
1403
|
tasks = "";
|
|
246
1404
|
onCompleteShell && onCompleteShell({
|
|
247
1405
|
write(v) {
|
|
@@ -250,26 +1408,74 @@ function renderToStream(code, options = {}) {
|
|
|
250
1408
|
});
|
|
251
1409
|
shellCompleted = true;
|
|
252
1410
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
if (
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
1411
|
+
const MIN_DRAIN_TURNS = 8;
|
|
1412
|
+
let lastBlockingSize = -1;
|
|
1413
|
+
let lastRegistrySize = -1;
|
|
1414
|
+
let drainTurn = 0;
|
|
1415
|
+
const scheduleFlush = fn => {
|
|
1416
|
+
const attempt = () => {
|
|
1417
|
+
if (registry.size !== lastRegistrySize || drainTurn++ < MIN_DRAIN_TURNS) {
|
|
1418
|
+
if (registry.size !== lastRegistrySize) drainTurn = 0;
|
|
1419
|
+
lastRegistrySize = registry.size;
|
|
1420
|
+
queue(attempt);
|
|
1421
|
+
return;
|
|
1422
|
+
}
|
|
1423
|
+
fn();
|
|
1424
|
+
};
|
|
1425
|
+
const progressed = blockingPromises.size !== lastBlockingSize;
|
|
1426
|
+
lastBlockingSize = blockingPromises.size;
|
|
1427
|
+
lastRegistrySize = -1;
|
|
1428
|
+
drainTurn = 0;
|
|
1429
|
+
progressed ? queue(attempt) : setTimeout(attempt);
|
|
1430
|
+
};
|
|
1431
|
+
let cachedReadable;
|
|
1432
|
+
let consumer;
|
|
1433
|
+
const claimConsumer = name => {
|
|
1434
|
+
if (consumer && consumer !== name) {
|
|
1435
|
+
throw new Error(`renderToStream result was already consumed via \`${consumer}\`; cannot also consume it via \`${name}\`. Use exactly one of \`pipe\`, \`pipeTo\`, or \`readable\`.`);
|
|
1436
|
+
}
|
|
1437
|
+
consumer = name;
|
|
1438
|
+
};
|
|
1439
|
+
const pipeToImpl = w => {
|
|
1440
|
+
let resolve;
|
|
1441
|
+
const p = new Promise(r => resolve = r);
|
|
1442
|
+
function flush() {
|
|
269
1443
|
allSettled(blockingPromises).then(() => {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
1444
|
+
scheduleFlush(() => {
|
|
1445
|
+
if (dead) return resolve();
|
|
1446
|
+
try {
|
|
1447
|
+
doShell();
|
|
1448
|
+
} catch (err) {
|
|
1449
|
+
failRender(err);
|
|
1450
|
+
return resolve();
|
|
1451
|
+
}
|
|
1452
|
+
if (!shellCompleted) return flush();
|
|
1453
|
+
const encoder = new TextEncoder();
|
|
1454
|
+
const writer = w.getWriter();
|
|
1455
|
+
let pendingWrites = Promise.resolve();
|
|
1456
|
+
let ended = false;
|
|
1457
|
+
const failed = () => {
|
|
1458
|
+
if (!ended) {
|
|
1459
|
+
abandon();
|
|
1460
|
+
resolve();
|
|
1461
|
+
}
|
|
1462
|
+
};
|
|
1463
|
+
writer.closed && writer.closed.catch(failed);
|
|
1464
|
+
writable = {
|
|
1465
|
+
end() {
|
|
1466
|
+
pendingWrites.then(() => {
|
|
1467
|
+
ended = true;
|
|
1468
|
+
writer.releaseLock();
|
|
1469
|
+
w.close().catch(() => {});
|
|
1470
|
+
resolve();
|
|
1471
|
+
});
|
|
1472
|
+
}
|
|
1473
|
+
};
|
|
1474
|
+
buffer = {
|
|
1475
|
+
write(payload) {
|
|
1476
|
+
pendingWrites = pendingWrites.then(() => writer.write(encoder.encode(payload))).catch(failed);
|
|
1477
|
+
}
|
|
1478
|
+
};
|
|
273
1479
|
buffer.write(tmp);
|
|
274
1480
|
firstFlushed = true;
|
|
275
1481
|
if (completed) {
|
|
@@ -278,53 +1484,724 @@ function renderToStream(code, options = {}) {
|
|
|
278
1484
|
} else flushEnd();
|
|
279
1485
|
});
|
|
280
1486
|
});
|
|
1487
|
+
}
|
|
1488
|
+
flush();
|
|
1489
|
+
return p;
|
|
1490
|
+
};
|
|
1491
|
+
return {
|
|
1492
|
+
then(onFulfilled, onRejected) {
|
|
1493
|
+
const p = new Promise(resolve => {
|
|
1494
|
+
function complete() {
|
|
1495
|
+
dispose();
|
|
1496
|
+
resolve(tmp);
|
|
1497
|
+
}
|
|
1498
|
+
if (onCompleteAll) {
|
|
1499
|
+
let ogComplete = onCompleteAll;
|
|
1500
|
+
onCompleteAll = options => {
|
|
1501
|
+
ogComplete(options);
|
|
1502
|
+
complete();
|
|
1503
|
+
};
|
|
1504
|
+
} else onCompleteAll = complete;
|
|
1505
|
+
function flush() {
|
|
1506
|
+
allSettled(blockingPromises).then(() => {
|
|
1507
|
+
scheduleFlush(() => {
|
|
1508
|
+
try {
|
|
1509
|
+
if (!resolveRootHoles() || !headShellReady(headRegistry, p => blockingPromises.add(p))) return flush();
|
|
1510
|
+
} catch (err) {
|
|
1511
|
+
failRender(err);
|
|
1512
|
+
return resolve(tmp);
|
|
1513
|
+
}
|
|
1514
|
+
queue(flushEnd);
|
|
1515
|
+
});
|
|
1516
|
+
});
|
|
1517
|
+
}
|
|
1518
|
+
flush();
|
|
1519
|
+
});
|
|
1520
|
+
return p.then(onFulfilled, onRejected);
|
|
1521
|
+
},
|
|
1522
|
+
pipe(w) {
|
|
1523
|
+
claimConsumer("pipe");
|
|
1524
|
+
function flush() {
|
|
1525
|
+
allSettled(blockingPromises).then(() => {
|
|
1526
|
+
scheduleFlush(() => {
|
|
1527
|
+
if (dead) return;
|
|
1528
|
+
try {
|
|
1529
|
+
doShell();
|
|
1530
|
+
} catch (err) {
|
|
1531
|
+
failRender(err);
|
|
1532
|
+
try {
|
|
1533
|
+
w.end();
|
|
1534
|
+
} catch (_) {}
|
|
1535
|
+
return;
|
|
1536
|
+
}
|
|
1537
|
+
if (!shellCompleted) return flush();
|
|
1538
|
+
buffer = writable = guardSink(w);
|
|
1539
|
+
buffer.write(tmp);
|
|
1540
|
+
firstFlushed = true;
|
|
1541
|
+
if (completed) {
|
|
1542
|
+
dispose();
|
|
1543
|
+
writable.end();
|
|
1544
|
+
} else flushEnd();
|
|
1545
|
+
});
|
|
1546
|
+
});
|
|
1547
|
+
}
|
|
1548
|
+
flush();
|
|
1549
|
+
},
|
|
1550
|
+
pipeTo(w) {
|
|
1551
|
+
claimConsumer("pipeTo");
|
|
1552
|
+
return pipeToImpl(w);
|
|
1553
|
+
},
|
|
1554
|
+
get readable() {
|
|
1555
|
+
claimConsumer("readable");
|
|
1556
|
+
if (!cachedReadable) {
|
|
1557
|
+
const t = new TransformStream();
|
|
1558
|
+
pipeToImpl(t.writable);
|
|
1559
|
+
cachedReadable = t.readable;
|
|
1560
|
+
}
|
|
1561
|
+
return cachedReadable;
|
|
1562
|
+
}
|
|
1563
|
+
};
|
|
1564
|
+
}
|
|
1565
|
+
function HydrationScript(props) {
|
|
1566
|
+
const {
|
|
1567
|
+
nonce
|
|
1568
|
+
} = solidJs.sharedConfig.context;
|
|
1569
|
+
return ssr(generateHydrationScript({
|
|
1570
|
+
nonce,
|
|
1571
|
+
...props
|
|
1572
|
+
}));
|
|
1573
|
+
}
|
|
1574
|
+
function ssrGroup(fn, n) {
|
|
1575
|
+
fn.$g = n;
|
|
1576
|
+
return fn;
|
|
1577
|
+
}
|
|
1578
|
+
function buildAsyncWrap(err, node) {
|
|
1579
|
+
const p = solidJs.ssrHandleError(err);
|
|
1580
|
+
if (!p) return null;
|
|
1581
|
+
if (node.$rw) return {
|
|
1582
|
+
fn: node,
|
|
1583
|
+
p
|
|
1584
|
+
};
|
|
1585
|
+
const owner = solidJs.getOwner();
|
|
1586
|
+
const live = solidJs.sharedConfig.context && solidJs.sharedConfig.context.liveHoles;
|
|
1587
|
+
const suppress = node.$lhSuppress || live && (live.suppressed || live.sweeping);
|
|
1588
|
+
if (!owner) {
|
|
1589
|
+
if (suppress) node.$lhSuppress = true;
|
|
1590
|
+
return {
|
|
1591
|
+
fn: node,
|
|
1592
|
+
p
|
|
1593
|
+
};
|
|
1594
|
+
}
|
|
1595
|
+
const fn = () => solidJs.runWithOwner(owner, node);
|
|
1596
|
+
fn.$rw = true;
|
|
1597
|
+
if (suppress) fn.$lhSuppress = true;
|
|
1598
|
+
if (node.$lhSkip) fn.$lhSkip = true;
|
|
1599
|
+
if (node.$lhBinding) fn.$lhBinding = node.$lhBinding;
|
|
1600
|
+
return {
|
|
1601
|
+
fn,
|
|
1602
|
+
p
|
|
1603
|
+
};
|
|
1604
|
+
}
|
|
1605
|
+
function ssrFirstGroupHit(hole) {
|
|
1606
|
+
try {
|
|
1607
|
+
return hole();
|
|
1608
|
+
} catch (err) {
|
|
1609
|
+
return buildAsyncWrap(err, hole);
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
function tryResolveFunctionHole(hole) {
|
|
1613
|
+
let value;
|
|
1614
|
+
try {
|
|
1615
|
+
value = hole();
|
|
1616
|
+
} catch (err) {
|
|
1617
|
+
return buildAsyncWrap(err, hole) || "";
|
|
1618
|
+
}
|
|
1619
|
+
const t = typeof value;
|
|
1620
|
+
if (t === "string") return value;
|
|
1621
|
+
if (t === "number") return "" + value;
|
|
1622
|
+
if (value == null || t === "boolean") return "";
|
|
1623
|
+
return tryResolveString(value);
|
|
1624
|
+
}
|
|
1625
|
+
function mergeTemplateInto(result, node) {
|
|
1626
|
+
result.t[result.t.length - 1] += node.t[0];
|
|
1627
|
+
if (node.t.length > 1) {
|
|
1628
|
+
result.t.push(...node.t.slice(1));
|
|
1629
|
+
result.h.push(...node.h);
|
|
1630
|
+
result.p.push(...node.p);
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
function appendResolvedNode(result, node) {
|
|
1634
|
+
if (node.fn !== undefined) {
|
|
1635
|
+
result.h.push(node.fn);
|
|
1636
|
+
result.p.push(node.p);
|
|
1637
|
+
result.t.push("");
|
|
1638
|
+
} else if (node.merge !== undefined) mergeTemplateInto(result, node.merge);else resolveSSRNode(node.bail, result);
|
|
1639
|
+
}
|
|
1640
|
+
let _lastGroupFn = null;
|
|
1641
|
+
let _lastGroupArr = null;
|
|
1642
|
+
let _lastGroupErr = null;
|
|
1643
|
+
function ssrGroupSlot(fn, idx) {
|
|
1644
|
+
return () => {
|
|
1645
|
+
if (idx > 0 && _lastGroupFn === fn) {
|
|
1646
|
+
if (_lastGroupArr !== null) return _lastGroupArr[idx];
|
|
1647
|
+
throw _lastGroupErr;
|
|
1648
|
+
}
|
|
1649
|
+
_lastGroupFn = fn;
|
|
1650
|
+
_lastGroupArr = null;
|
|
1651
|
+
_lastGroupErr = null;
|
|
1652
|
+
try {
|
|
1653
|
+
_lastGroupArr = fn();
|
|
1654
|
+
return _lastGroupArr[idx];
|
|
1655
|
+
} catch (err) {
|
|
1656
|
+
_lastGroupErr = err;
|
|
1657
|
+
throw err;
|
|
1658
|
+
}
|
|
1659
|
+
};
|
|
1660
|
+
}
|
|
1661
|
+
const holePositionCache = new WeakMap();
|
|
1662
|
+
function holeContentPositions(t) {
|
|
1663
|
+
let cached = holePositionCache.get(t);
|
|
1664
|
+
if (cached) return cached;
|
|
1665
|
+
const pos = [];
|
|
1666
|
+
const openOff = [];
|
|
1667
|
+
const closeOff = [];
|
|
1668
|
+
let inTag = false;
|
|
1669
|
+
let quote = "";
|
|
1670
|
+
let curOpen = null;
|
|
1671
|
+
let scanningName = false;
|
|
1672
|
+
for (let i = 0; i < t.length; i++) {
|
|
1673
|
+
const seg = t[i];
|
|
1674
|
+
let close = -1;
|
|
1675
|
+
const openAtStart = inTag;
|
|
1676
|
+
let reopened = false;
|
|
1677
|
+
for (let j = 0; j < seg.length; j++) {
|
|
1678
|
+
const ch = seg[j];
|
|
1679
|
+
if (quote) {
|
|
1680
|
+
if (ch === quote) quote = "";
|
|
1681
|
+
} else if (inTag) {
|
|
1682
|
+
if (scanningName && (ch === " " || ch === "\t" || ch === "\n" || ch === ">" || ch === "/")) {
|
|
1683
|
+
scanningName = false;
|
|
1684
|
+
curOpen = {
|
|
1685
|
+
seg: i,
|
|
1686
|
+
off: j
|
|
1687
|
+
};
|
|
1688
|
+
}
|
|
1689
|
+
if (ch === '"' || ch === "'") quote = ch;else if (ch === ">") {
|
|
1690
|
+
inTag = false;
|
|
1691
|
+
if (openAtStart && !reopened && close === -1) close = j;
|
|
1692
|
+
curOpen = null;
|
|
1693
|
+
}
|
|
1694
|
+
} else if (ch === "<") {
|
|
1695
|
+
inTag = true;
|
|
1696
|
+
scanningName = true;
|
|
1697
|
+
reopened = true;
|
|
1698
|
+
curOpen = null;
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
if (inTag && scanningName) {
|
|
1702
|
+
scanningName = false;
|
|
1703
|
+
curOpen = {
|
|
1704
|
+
seg: i,
|
|
1705
|
+
off: seg.length
|
|
1706
|
+
};
|
|
1707
|
+
}
|
|
1708
|
+
closeOff.push(close);
|
|
1709
|
+
openOff.push(inTag && curOpen && curOpen.seg === i ? curOpen.off : -1);
|
|
1710
|
+
if (i < t.length - 1) pos.push(!inTag);
|
|
1711
|
+
}
|
|
1712
|
+
cached = {
|
|
1713
|
+
pos,
|
|
1714
|
+
openOff,
|
|
1715
|
+
closeOff
|
|
1716
|
+
};
|
|
1717
|
+
holePositionCache.set(t, cached);
|
|
1718
|
+
return cached;
|
|
1719
|
+
}
|
|
1720
|
+
function createLiveHoles(sink, scoped) {
|
|
1721
|
+
let nextId = 0;
|
|
1722
|
+
const stamp = typeof solidJs.creationStamp === "function" ? solidJs.creationStamp : () => 0;
|
|
1723
|
+
const inScope = scoped && typeof solidJs.inServerComponentScope === "function" ? solidJs.inServerComponentScope : null;
|
|
1724
|
+
const stripMarkers = html => html.replace(/<!--lh:\/?\d+-->/g, "");
|
|
1725
|
+
function resolveHoleValue(hole) {
|
|
1726
|
+
const result = {
|
|
1727
|
+
t: [""],
|
|
1728
|
+
h: [],
|
|
1729
|
+
p: []
|
|
1730
|
+
};
|
|
1731
|
+
try {
|
|
1732
|
+
resolveSSRNode(hole(), result);
|
|
1733
|
+
} catch (err) {
|
|
1734
|
+
const wrap = buildAsyncWrap(err, hole);
|
|
1735
|
+
if (!wrap) throw err;
|
|
1736
|
+
result.h.push(wrap.fn);
|
|
1737
|
+
result.p.push(wrap.p);
|
|
1738
|
+
result.t.push("");
|
|
1739
|
+
}
|
|
1740
|
+
return result;
|
|
1741
|
+
}
|
|
1742
|
+
function closeChildren(b) {
|
|
1743
|
+
for (const c of b.children) {
|
|
1744
|
+
c.closed = true;
|
|
1745
|
+
if (c.key) sink.closeBinding(c.key);
|
|
1746
|
+
closeChildren(c);
|
|
1747
|
+
}
|
|
1748
|
+
b.children.length = 0;
|
|
1749
|
+
}
|
|
1750
|
+
const engine = {
|
|
1751
|
+
suppressed: 0,
|
|
1752
|
+
sweeping: false,
|
|
1753
|
+
parent: null,
|
|
1754
|
+
recordStamp: 0,
|
|
1755
|
+
gateHit: false,
|
|
1756
|
+
content(hole) {
|
|
1757
|
+
if (hole.$lhSuppress) {
|
|
1758
|
+
const r = {
|
|
1759
|
+
t: [""],
|
|
1760
|
+
h: [],
|
|
1761
|
+
p: []
|
|
1762
|
+
};
|
|
1763
|
+
engine.suppressed++;
|
|
1764
|
+
try {
|
|
1765
|
+
try {
|
|
1766
|
+
resolveSSRNode(hole(), r);
|
|
1767
|
+
} catch (err) {
|
|
1768
|
+
const wrap = buildAsyncWrap(err, hole);
|
|
1769
|
+
if (wrap) {
|
|
1770
|
+
r.h.push(wrap.fn);
|
|
1771
|
+
r.p.push(wrap.p);
|
|
1772
|
+
r.t.push("");
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1775
|
+
} finally {
|
|
1776
|
+
engine.suppressed--;
|
|
1777
|
+
}
|
|
1778
|
+
const b = hole.$lhBinding;
|
|
1779
|
+
if (b && !b.closed && !r.h.length && !engine.sweeping) {
|
|
1780
|
+
b.last = stripMarkers(r.t[0]);
|
|
1781
|
+
}
|
|
1782
|
+
return r.h.length ? r : r.t[0];
|
|
1783
|
+
}
|
|
1784
|
+
if (engine.suppressed || engine.sweeping) return null;
|
|
1785
|
+
if (hole.$lhSkip) return null;
|
|
1786
|
+
if (inScope && !inScope()) return null;
|
|
1787
|
+
const recordsBefore = engine.recordStamp;
|
|
1788
|
+
const ownersBefore = stamp();
|
|
1789
|
+
const owner = solidJs.getOwner();
|
|
1790
|
+
const b = {
|
|
1791
|
+
key: null,
|
|
1792
|
+
children: [],
|
|
1793
|
+
last: null,
|
|
1794
|
+
closed: false,
|
|
1795
|
+
sweep() {
|
|
1796
|
+
if (b.closed) return;
|
|
1797
|
+
const prevSweeping = engine.sweeping;
|
|
1798
|
+
engine.sweeping = true;
|
|
1799
|
+
engine.gateHit = false;
|
|
1800
|
+
const sweepOwnersBefore = stamp();
|
|
1801
|
+
let res;
|
|
1802
|
+
try {
|
|
1803
|
+
res = owner ? solidJs.runWithOwner(owner, () => resolveHoleValue(hole)) : resolveHoleValue(hole);
|
|
1804
|
+
} catch (err) {
|
|
1805
|
+
b.closed = true;
|
|
1806
|
+
sink.closeBinding(b.key);
|
|
1807
|
+
sink.error(b.key, String(err && err.message || err));
|
|
1808
|
+
return;
|
|
1809
|
+
} finally {
|
|
1810
|
+
engine.sweeping = prevSweeping;
|
|
1811
|
+
}
|
|
1812
|
+
if (engine.gateHit || stamp() !== sweepOwnersBefore) {
|
|
1813
|
+
b.closed = true;
|
|
1814
|
+
sink.closeBinding(b.key);
|
|
1815
|
+
return;
|
|
1816
|
+
}
|
|
1817
|
+
if (res.h.length) return;
|
|
1818
|
+
const html = res.t[0];
|
|
1819
|
+
if (b.last === null || html === b.last) return;
|
|
1820
|
+
b.last = html;
|
|
1821
|
+
closeChildren(b);
|
|
1822
|
+
sink.hole(b.key, html);
|
|
1823
|
+
}
|
|
1824
|
+
};
|
|
1825
|
+
if (engine.parent) engine.parent.children.push(b);
|
|
1826
|
+
const prevParent = engine.parent;
|
|
1827
|
+
engine.parent = b;
|
|
1828
|
+
let value;
|
|
1829
|
+
let escalated = null;
|
|
1830
|
+
try {
|
|
1831
|
+
value = hole();
|
|
1832
|
+
} catch (err) {
|
|
1833
|
+
const wrap = buildAsyncWrap(err, hole);
|
|
1834
|
+
if (!wrap) {
|
|
1835
|
+
engine.parent = prevParent;
|
|
1836
|
+
closeChildren(b);
|
|
1837
|
+
return "";
|
|
1838
|
+
}
|
|
1839
|
+
escalated = wrap;
|
|
1840
|
+
}
|
|
1841
|
+
if (!escalated && (typeof value === "function" && value.$lhSkip || value !== null && typeof value === "object" && value.$slot)) {
|
|
1842
|
+
engine.parent = prevParent;
|
|
1843
|
+
const r = {
|
|
1844
|
+
t: [""],
|
|
1845
|
+
h: [],
|
|
1846
|
+
p: []
|
|
1847
|
+
};
|
|
1848
|
+
engine.suppressed++;
|
|
1849
|
+
try {
|
|
1850
|
+
resolveSSRNode(value, r);
|
|
1851
|
+
} finally {
|
|
1852
|
+
engine.suppressed--;
|
|
1853
|
+
}
|
|
1854
|
+
return r.h.length ? r : r.t[0];
|
|
1855
|
+
}
|
|
1856
|
+
let res;
|
|
1857
|
+
if (escalated) {
|
|
1858
|
+
closeChildren(b);
|
|
1859
|
+
escalated.fn.$lhSuppress = true;
|
|
1860
|
+
escalated.fn.$lhBinding = b;
|
|
1861
|
+
res = {
|
|
1862
|
+
t: ["", ""],
|
|
1863
|
+
h: [escalated.fn],
|
|
1864
|
+
p: [escalated.p]
|
|
1865
|
+
};
|
|
1866
|
+
} else {
|
|
1867
|
+
res = {
|
|
1868
|
+
t: [""],
|
|
1869
|
+
h: [],
|
|
1870
|
+
p: []
|
|
1871
|
+
};
|
|
1872
|
+
try {
|
|
1873
|
+
resolveSSRNode(value, res);
|
|
1874
|
+
} catch (_) {
|
|
1875
|
+
engine.parent = prevParent;
|
|
1876
|
+
closeChildren(b);
|
|
1877
|
+
return "";
|
|
1878
|
+
}
|
|
1879
|
+
}
|
|
1880
|
+
engine.parent = prevParent;
|
|
1881
|
+
if (engine.recordStamp !== recordsBefore || stamp() !== ownersBefore) {
|
|
1882
|
+
return res.h.length ? res : res.t[0];
|
|
1883
|
+
}
|
|
1884
|
+
const id = nextId++;
|
|
1885
|
+
const key = b.key = "lh:" + id;
|
|
1886
|
+
const open = `<!--lh:${id}-->`;
|
|
1887
|
+
const close = `<!--lh:/${id}-->`;
|
|
1888
|
+
if (!res.h.length) {
|
|
1889
|
+
b.last = stripMarkers(res.t[0]);
|
|
1890
|
+
sink.openBinding(key, b);
|
|
1891
|
+
return open + res.t[0] + close;
|
|
1892
|
+
}
|
|
1893
|
+
const t = res.t.slice();
|
|
1894
|
+
t[0] = open + t[0];
|
|
1895
|
+
t[t.length - 1] += close;
|
|
1896
|
+
sink.openBinding(key, b);
|
|
1897
|
+
return {
|
|
1898
|
+
t,
|
|
1899
|
+
h: res.h,
|
|
1900
|
+
p: res.p
|
|
1901
|
+
};
|
|
281
1902
|
},
|
|
282
|
-
|
|
283
|
-
return
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
1903
|
+
mint() {
|
|
1904
|
+
return nextId++;
|
|
1905
|
+
},
|
|
1906
|
+
active() {
|
|
1907
|
+
return !inScope || inScope();
|
|
1908
|
+
},
|
|
1909
|
+
attr(cap) {
|
|
1910
|
+
const owner = solidJs.getOwner();
|
|
1911
|
+
const b = {
|
|
1912
|
+
key: "lha:" + cap.id,
|
|
1913
|
+
children: [],
|
|
1914
|
+
last: cap.base,
|
|
1915
|
+
closed: false,
|
|
1916
|
+
sweep() {
|
|
1917
|
+
if (b.closed) return;
|
|
1918
|
+
const prevSweeping = engine.sweeping;
|
|
1919
|
+
engine.sweeping = true;
|
|
1920
|
+
engine.gateHit = false;
|
|
1921
|
+
const sweepOwnersBefore = stamp();
|
|
1922
|
+
let html = "";
|
|
1923
|
+
try {
|
|
1924
|
+
let group = null;
|
|
1925
|
+
let groupVal = null;
|
|
1926
|
+
const run = () => {
|
|
1927
|
+
for (const part of cap.parts) {
|
|
1928
|
+
if (typeof part === "string") {
|
|
1929
|
+
html += part;
|
|
1930
|
+
continue;
|
|
1931
|
+
}
|
|
1932
|
+
let v;
|
|
1933
|
+
if (part.g) {
|
|
1934
|
+
if (group !== part.g) {
|
|
1935
|
+
group = part.g;
|
|
1936
|
+
groupVal = part.g();
|
|
1937
|
+
}
|
|
1938
|
+
v = groupVal[part.i];
|
|
1939
|
+
} else {
|
|
1940
|
+
v = part.f();
|
|
1941
|
+
}
|
|
1942
|
+
const vt = typeof v;
|
|
1943
|
+
if (vt === "string" || vt === "number") html += v;
|
|
1944
|
+
}
|
|
1945
|
+
};
|
|
1946
|
+
owner ? solidJs.runWithOwner(owner, run) : run();
|
|
1947
|
+
} catch (err) {
|
|
1948
|
+
if (solidJs.ssrHandleError(err, true)) return;
|
|
1949
|
+
b.closed = true;
|
|
1950
|
+
sink.closeBinding(b.key);
|
|
1951
|
+
sink.error("lha:" + cap.id, String(err && err.message || err));
|
|
1952
|
+
return;
|
|
1953
|
+
} finally {
|
|
1954
|
+
engine.sweeping = prevSweeping;
|
|
1955
|
+
}
|
|
1956
|
+
if (engine.gateHit || stamp() !== sweepOwnersBefore) {
|
|
1957
|
+
b.closed = true;
|
|
1958
|
+
sink.closeBinding(b.key);
|
|
1959
|
+
return;
|
|
1960
|
+
}
|
|
1961
|
+
if (html === b.last) return;
|
|
1962
|
+
const before = attrNames(b.last);
|
|
1963
|
+
const after = attrNames(html);
|
|
1964
|
+
const removed = before.filter(n => !after.includes(n));
|
|
1965
|
+
b.last = html;
|
|
1966
|
+
sink.attr(String(cap.id), html, removed);
|
|
1967
|
+
}
|
|
1968
|
+
};
|
|
1969
|
+
sink.openBinding(b.key, b);
|
|
311
1970
|
}
|
|
312
1971
|
};
|
|
1972
|
+
return engine;
|
|
313
1973
|
}
|
|
314
|
-
function
|
|
315
|
-
const
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
...props
|
|
321
|
-
}));
|
|
1974
|
+
function attrNames(text) {
|
|
1975
|
+
const names = [];
|
|
1976
|
+
const re = /(?:^|\s)([^\s=/>"']+)(?:="[^"]*")?/g;
|
|
1977
|
+
let m;
|
|
1978
|
+
while (m = re.exec(text)) names.push(m[1]);
|
|
1979
|
+
return names;
|
|
322
1980
|
}
|
|
323
|
-
function ssr(t
|
|
324
|
-
|
|
325
|
-
return {
|
|
1981
|
+
function ssr(t) {
|
|
1982
|
+
const len = arguments.length;
|
|
1983
|
+
if (len === 1) return {
|
|
326
1984
|
t
|
|
327
1985
|
};
|
|
1986
|
+
let s = t[0];
|
|
1987
|
+
let result = null;
|
|
1988
|
+
let lastGroup = null;
|
|
1989
|
+
let lastGroupVal = null;
|
|
1990
|
+
let lastGroupIdx = 0;
|
|
1991
|
+
const live = solidJs.sharedConfig.context && solidJs.sharedConfig.context.liveHoles;
|
|
1992
|
+
const hp = live ? holeContentPositions(t) : null;
|
|
1993
|
+
let lastOpen = null;
|
|
1994
|
+
let cap = null;
|
|
1995
|
+
if (live && hp.openOff[0] >= 0) lastOpen = {
|
|
1996
|
+
r: null,
|
|
1997
|
+
seg: -1,
|
|
1998
|
+
off: hp.openOff[0]
|
|
1999
|
+
};
|
|
2000
|
+
const captureStart = () => {
|
|
2001
|
+
if (cap) return true;
|
|
2002
|
+
if (!lastOpen || live.suppressed || live.sweeping || !live.active()) return false;
|
|
2003
|
+
if (lastOpen.r !== result || result !== null && lastOpen.seg !== result.t.length - 1) {
|
|
2004
|
+
return false;
|
|
2005
|
+
}
|
|
2006
|
+
const id = live.mint();
|
|
2007
|
+
const inject = ` data-lha="${id}"`;
|
|
2008
|
+
let prefix;
|
|
2009
|
+
if (result === null) {
|
|
2010
|
+
s = s.slice(0, lastOpen.off) + inject + s.slice(lastOpen.off);
|
|
2011
|
+
prefix = s.slice(lastOpen.off + inject.length);
|
|
2012
|
+
} else {
|
|
2013
|
+
const seg = result.t[lastOpen.seg];
|
|
2014
|
+
result.t[lastOpen.seg] = seg.slice(0, lastOpen.off) + inject + seg.slice(lastOpen.off);
|
|
2015
|
+
prefix = result.t[lastOpen.seg].slice(lastOpen.off + inject.length);
|
|
2016
|
+
}
|
|
2017
|
+
cap = {
|
|
2018
|
+
id,
|
|
2019
|
+
parts: [prefix],
|
|
2020
|
+
base: prefix
|
|
2021
|
+
};
|
|
2022
|
+
return true;
|
|
2023
|
+
};
|
|
2024
|
+
for (let i = 1; i < len; i++) {
|
|
2025
|
+
const hole = arguments[i];
|
|
2026
|
+
const ht = typeof hole;
|
|
2027
|
+
if (ht === "string") {
|
|
2028
|
+
if (result === null) s += hole;else result.t[result.t.length - 1] += hole;
|
|
2029
|
+
if (cap) {
|
|
2030
|
+
cap.parts.push(hole);
|
|
2031
|
+
cap.base += hole;
|
|
2032
|
+
}
|
|
2033
|
+
} else if (ht === "number") {
|
|
2034
|
+
if (result === null) s += hole;else result.t[result.t.length - 1] += hole;
|
|
2035
|
+
if (cap) {
|
|
2036
|
+
cap.parts.push("" + hole);
|
|
2037
|
+
cap.base += hole;
|
|
2038
|
+
}
|
|
2039
|
+
} else if (hole == null || ht === "boolean") ; else if (ht === "function" && hole.$g) {
|
|
2040
|
+
let value;
|
|
2041
|
+
let hasValue = false;
|
|
2042
|
+
if (lastGroup !== hole) {
|
|
2043
|
+
const r = ssrFirstGroupHit(hole);
|
|
2044
|
+
if (r !== null) {
|
|
2045
|
+
lastGroup = hole;
|
|
2046
|
+
lastGroupVal = r;
|
|
2047
|
+
lastGroupIdx = 0;
|
|
2048
|
+
if (!Array.isArray(r) && result === null) {
|
|
2049
|
+
result = {
|
|
2050
|
+
t: [s],
|
|
2051
|
+
h: [],
|
|
2052
|
+
p: []
|
|
2053
|
+
};
|
|
2054
|
+
s = "";
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
}
|
|
2058
|
+
if (lastGroup === hole) {
|
|
2059
|
+
if (Array.isArray(lastGroupVal)) {
|
|
2060
|
+
value = lastGroupVal[lastGroupIdx++];
|
|
2061
|
+
hasValue = true;
|
|
2062
|
+
if (live && !hp.pos[i - 1] && captureStart()) {
|
|
2063
|
+
cap.parts.push({
|
|
2064
|
+
g: hole,
|
|
2065
|
+
i: lastGroupIdx - 1
|
|
2066
|
+
});
|
|
2067
|
+
}
|
|
2068
|
+
} else {
|
|
2069
|
+
cap = null;
|
|
2070
|
+
result.h.push(ssrGroupSlot(lastGroupVal.fn, lastGroupIdx++));
|
|
2071
|
+
result.p.push(lastGroupVal.p);
|
|
2072
|
+
result.t.push("");
|
|
2073
|
+
}
|
|
2074
|
+
}
|
|
2075
|
+
if (hasValue) {
|
|
2076
|
+
const vt = typeof value;
|
|
2077
|
+
if (vt === "string" || vt === "number") {
|
|
2078
|
+
if (result === null) s += value;else result.t[result.t.length - 1] += value;
|
|
2079
|
+
if (cap && !hp.pos[i - 1]) cap.base += value;
|
|
2080
|
+
} else if (value == null || vt === "boolean") ; else if (result !== null) {
|
|
2081
|
+
resolveSSRNode(value, result);
|
|
2082
|
+
} else {
|
|
2083
|
+
const rs = tryResolveString(value);
|
|
2084
|
+
if (typeof rs === "string") {
|
|
2085
|
+
s += rs;
|
|
2086
|
+
} else {
|
|
2087
|
+
result = {
|
|
2088
|
+
t: [s],
|
|
2089
|
+
h: [],
|
|
2090
|
+
p: []
|
|
2091
|
+
};
|
|
2092
|
+
s = "";
|
|
2093
|
+
if (rs.merge !== undefined) mergeTemplateInto(result, rs.merge);else resolveSSRNode(rs.bail, result);
|
|
2094
|
+
}
|
|
2095
|
+
}
|
|
2096
|
+
}
|
|
2097
|
+
} else if (ht === "function") {
|
|
2098
|
+
let liveNode = null;
|
|
2099
|
+
if (live && hp.pos[i - 1] && (liveNode = live.content(hole)) !== null) {
|
|
2100
|
+
if (typeof liveNode === "string") {
|
|
2101
|
+
if (result === null) s += liveNode;else result.t[result.t.length - 1] += liveNode;
|
|
2102
|
+
} else {
|
|
2103
|
+
if (result === null) {
|
|
2104
|
+
result = {
|
|
2105
|
+
t: [s],
|
|
2106
|
+
h: [],
|
|
2107
|
+
p: []
|
|
2108
|
+
};
|
|
2109
|
+
s = "";
|
|
2110
|
+
}
|
|
2111
|
+
resolveSSRNode(liveNode, result);
|
|
2112
|
+
}
|
|
2113
|
+
} else if (result !== null) {
|
|
2114
|
+
const inTag = live && !hp.pos[i - 1];
|
|
2115
|
+
const capturing = inTag && captureStart();
|
|
2116
|
+
const li = capturing ? result.t.length - 1 : 0;
|
|
2117
|
+
const before = capturing ? result.t[li].length : 0;
|
|
2118
|
+
if (live) live.suppressed++;
|
|
2119
|
+
try {
|
|
2120
|
+
resolveSSRNode(hole, result);
|
|
2121
|
+
} finally {
|
|
2122
|
+
if (live) live.suppressed--;
|
|
2123
|
+
}
|
|
2124
|
+
if (capturing) {
|
|
2125
|
+
if (result.t.length - 1 === li) {
|
|
2126
|
+
cap.base += result.t[li].slice(before);
|
|
2127
|
+
cap.parts.push({
|
|
2128
|
+
f: hole
|
|
2129
|
+
});
|
|
2130
|
+
} else {
|
|
2131
|
+
cap = null;
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
2134
|
+
} else {
|
|
2135
|
+
const capturing = live && !hp.pos[i - 1] && captureStart();
|
|
2136
|
+
const r = tryResolveFunctionHole(hole);
|
|
2137
|
+
if (typeof r === "string") {
|
|
2138
|
+
s += r;
|
|
2139
|
+
if (capturing) {
|
|
2140
|
+
cap.base += r;
|
|
2141
|
+
cap.parts.push({
|
|
2142
|
+
f: hole
|
|
2143
|
+
});
|
|
2144
|
+
}
|
|
2145
|
+
} else {
|
|
2146
|
+
if (capturing) cap = null;
|
|
2147
|
+
result = {
|
|
2148
|
+
t: [s],
|
|
2149
|
+
h: [],
|
|
2150
|
+
p: []
|
|
2151
|
+
};
|
|
2152
|
+
s = "";
|
|
2153
|
+
appendResolvedNode(result, r);
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2156
|
+
} else if (result !== null) {
|
|
2157
|
+
resolveSSRNode(hole, result);
|
|
2158
|
+
} else {
|
|
2159
|
+
const r = tryResolveString(hole);
|
|
2160
|
+
if (typeof r === "string") {
|
|
2161
|
+
s += r;
|
|
2162
|
+
} else {
|
|
2163
|
+
result = {
|
|
2164
|
+
t: [s],
|
|
2165
|
+
h: [],
|
|
2166
|
+
p: []
|
|
2167
|
+
};
|
|
2168
|
+
s = "";
|
|
2169
|
+
appendResolvedNode(result, r);
|
|
2170
|
+
}
|
|
2171
|
+
}
|
|
2172
|
+
const next = t[i];
|
|
2173
|
+
if (live) {
|
|
2174
|
+
if (cap) {
|
|
2175
|
+
const co = hp.closeOff[i];
|
|
2176
|
+
if (co >= 0) {
|
|
2177
|
+
const tail = next.slice(0, co);
|
|
2178
|
+
cap.parts.push(tail);
|
|
2179
|
+
cap.base += tail;
|
|
2180
|
+
live.attr(cap);
|
|
2181
|
+
cap = null;
|
|
2182
|
+
} else {
|
|
2183
|
+
cap.parts.push(next);
|
|
2184
|
+
cap.base += next;
|
|
2185
|
+
}
|
|
2186
|
+
}
|
|
2187
|
+
if (hp.openOff[i] >= 0) {
|
|
2188
|
+
lastOpen = result === null ? {
|
|
2189
|
+
r: null,
|
|
2190
|
+
seg: -1,
|
|
2191
|
+
off: s.length + hp.openOff[i]
|
|
2192
|
+
} : {
|
|
2193
|
+
r: result,
|
|
2194
|
+
seg: result.t.length - 1,
|
|
2195
|
+
off: result.t[result.t.length - 1].length + hp.openOff[i]
|
|
2196
|
+
};
|
|
2197
|
+
}
|
|
2198
|
+
}
|
|
2199
|
+
if (result === null) s += next;else result.t[result.t.length - 1] += next;
|
|
2200
|
+
}
|
|
2201
|
+
if (result === null) return {
|
|
2202
|
+
t: s
|
|
2203
|
+
};
|
|
2204
|
+
return result;
|
|
328
2205
|
}
|
|
329
2206
|
function ssrClassName(value) {
|
|
330
2207
|
if (!value) return "";
|
|
@@ -337,7 +2214,7 @@ function ssrClassName(value) {
|
|
|
337
2214
|
classValue = !!value[key];
|
|
338
2215
|
if (!key || key === "undefined" || !classValue) continue;
|
|
339
2216
|
i && (result += " ");
|
|
340
|
-
result += escape(key);
|
|
2217
|
+
result += escape(key, true);
|
|
341
2218
|
}
|
|
342
2219
|
return result;
|
|
343
2220
|
}
|
|
@@ -347,8 +2224,8 @@ function ssrStyle(value) {
|
|
|
347
2224
|
let result = "";
|
|
348
2225
|
const k = Object.keys(value);
|
|
349
2226
|
for (let i = 0; i < k.length; i++) {
|
|
350
|
-
const s = k[i];
|
|
351
|
-
const v = value[
|
|
2227
|
+
const s = escape(k[i], true);
|
|
2228
|
+
const v = value[k[i]];
|
|
352
2229
|
if (v != undefined) {
|
|
353
2230
|
if (i) result += ";";
|
|
354
2231
|
const r = escape(v, true);
|
|
@@ -363,10 +2240,11 @@ function ssrStyleProperty(name, value) {
|
|
|
363
2240
|
return value != null ? name + value : "";
|
|
364
2241
|
}
|
|
365
2242
|
function ssrElement(tag, props, children, needsId) {
|
|
2243
|
+
const hk = needsId ? ssrHydrationKey() : "";
|
|
366
2244
|
if (props == null) props = {};else if (typeof props === "function") props = props();
|
|
367
2245
|
const skipChildren = VOID_ELEMENTS.test(tag);
|
|
368
2246
|
const keys = Object.keys(props);
|
|
369
|
-
let result = `<${tag}${
|
|
2247
|
+
let result = `<${tag}${hk} `;
|
|
370
2248
|
for (let i = 0; i < keys.length; i++) {
|
|
371
2249
|
const prop = keys[i];
|
|
372
2250
|
if (ChildProperties.has(prop)) {
|
|
@@ -401,22 +2279,122 @@ function ssrHydrationKey() {
|
|
|
401
2279
|
const hk = getHydrationKey();
|
|
402
2280
|
return hk ? ` _hk=${hk}` : "";
|
|
403
2281
|
}
|
|
2282
|
+
function decodeSSREntities(s) {
|
|
2283
|
+
return s.indexOf("&") < 0 ? s : s.replace(/"/g, '"').replace(/</g, "<").replace(/&/g, "&");
|
|
2284
|
+
}
|
|
2285
|
+
const SELECT_VALUE_ATTR = /\svalue="([^"]*)"/;
|
|
2286
|
+
function tagEnd(html, i) {
|
|
2287
|
+
for (let j = i + 1; j < html.length; j++) {
|
|
2288
|
+
const c = html.charCodeAt(j);
|
|
2289
|
+
if (c === 34) {
|
|
2290
|
+
j = html.indexOf('"', j + 1);
|
|
2291
|
+
if (j < 0) return -1;
|
|
2292
|
+
} else if (c === 62) return j;
|
|
2293
|
+
}
|
|
2294
|
+
return -1;
|
|
2295
|
+
}
|
|
2296
|
+
function optionText(html, from) {
|
|
2297
|
+
let t = "";
|
|
2298
|
+
let i = from;
|
|
2299
|
+
for (;;) {
|
|
2300
|
+
const lt = html.indexOf("<", i);
|
|
2301
|
+
if (lt < 0) return t + html.slice(i);
|
|
2302
|
+
t += html.slice(i, lt);
|
|
2303
|
+
if (!html.startsWith("<!--", lt)) return t;
|
|
2304
|
+
const ce = html.indexOf("-->", lt);
|
|
2305
|
+
if (ce < 0) return t;
|
|
2306
|
+
i = ce + 3;
|
|
2307
|
+
}
|
|
2308
|
+
}
|
|
2309
|
+
function tagIs(html, i, name) {
|
|
2310
|
+
if (!html.startsWith(name, i + 1)) return false;
|
|
2311
|
+
const c = html.charCodeAt(i + 1 + name.length);
|
|
2312
|
+
return c === 32 || c === 62 || c === 9 || c === 10 || c === 13;
|
|
2313
|
+
}
|
|
2314
|
+
function resolveSSRSelectValues(html) {
|
|
2315
|
+
if (html.indexOf("<select") < 0) return html;
|
|
2316
|
+
let out = "";
|
|
2317
|
+
let idx = 0;
|
|
2318
|
+
let sel = null;
|
|
2319
|
+
let i = html.indexOf("<");
|
|
2320
|
+
while (i >= 0) {
|
|
2321
|
+
let e;
|
|
2322
|
+
if (html.charCodeAt(i + 1) === 33) {
|
|
2323
|
+
e = html.charCodeAt(i + 2) === 45 ? html.indexOf("-->", i) : html.indexOf(">", i);
|
|
2324
|
+
if (e < 0) break;
|
|
2325
|
+
if (html.charCodeAt(i + 2) === 45) e += 2;
|
|
2326
|
+
} else {
|
|
2327
|
+
e = tagEnd(html, i);
|
|
2328
|
+
if (e < 0) break;
|
|
2329
|
+
if (sel) {
|
|
2330
|
+
if (html.startsWith("</select>", i)) {
|
|
2331
|
+
out += html.slice(idx, sel.strip) + html.slice(sel.stripEnd, sel.body);
|
|
2332
|
+
let seg = sel.body;
|
|
2333
|
+
if (!sel.defaulted) {
|
|
2334
|
+
for (let k = 0; k < sel.marks.length; k++) {
|
|
2335
|
+
out += html.slice(seg, sel.marks[k]) + " selected";
|
|
2336
|
+
seg = sel.marks[k];
|
|
2337
|
+
}
|
|
2338
|
+
}
|
|
2339
|
+
out += html.slice(seg, i);
|
|
2340
|
+
idx = i;
|
|
2341
|
+
sel = null;
|
|
2342
|
+
} else if (tagIs(html, i, "option")) {
|
|
2343
|
+
const attrs = html.slice(i + 7, e);
|
|
2344
|
+
if (/\sselected(?=[\s=]|$)/.test(attrs)) sel.defaulted = true;else {
|
|
2345
|
+
const vm = SELECT_VALUE_ATTR.exec(attrs);
|
|
2346
|
+
const value = vm ? decodeSSREntities(vm[1]) : decodeSSREntities(optionText(html, e + 1)).replace(/\s+/g, " ").trim();
|
|
2347
|
+
if (sel.values.includes(value)) sel.marks.push(e);
|
|
2348
|
+
}
|
|
2349
|
+
}
|
|
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
|
+
}
|
|
2364
|
+
}
|
|
2365
|
+
i = html.indexOf("<", e + 1);
|
|
2366
|
+
}
|
|
2367
|
+
return out + html.slice(idx);
|
|
2368
|
+
}
|
|
404
2369
|
function escape(s, attr) {
|
|
405
2370
|
const t = typeof s;
|
|
406
2371
|
if (t !== "string") {
|
|
407
2372
|
if (!attr && Array.isArray(s)) {
|
|
2373
|
+
const joined = tryJoinPlainSSRArray(s);
|
|
2374
|
+
if (joined !== undefined) return joined;
|
|
408
2375
|
s = s.slice();
|
|
409
2376
|
for (let i = 0; i < s.length; i++) s[i] = escape(s[i]);
|
|
410
2377
|
return s;
|
|
411
2378
|
}
|
|
412
|
-
if (attr
|
|
2379
|
+
if (attr) {
|
|
2380
|
+
if (s == null || t === "boolean" || t === "number") return s;
|
|
2381
|
+
return escape(String(s), attr);
|
|
2382
|
+
}
|
|
413
2383
|
return s;
|
|
414
2384
|
}
|
|
2385
|
+
const i = s.search(attr ? ESCAPE_ATTR : ESCAPE_CONTENT);
|
|
2386
|
+
if (i < 0) return s;
|
|
2387
|
+
return escapeSlow(s, attr, i);
|
|
2388
|
+
}
|
|
2389
|
+
const ESCAPE_CONTENT = /[&<]/;
|
|
2390
|
+
const ESCAPE_ATTR = /[&"]/;
|
|
2391
|
+
function escapeSlow(s, attr, start) {
|
|
415
2392
|
const delim = attr ? '"' : "<";
|
|
2393
|
+
const delimCode = attr ? 34 : 60;
|
|
416
2394
|
const escDelim = attr ? """ : "<";
|
|
417
|
-
|
|
418
|
-
let
|
|
419
|
-
|
|
2395
|
+
const c0 = s.charCodeAt(start);
|
|
2396
|
+
let iDelim = c0 === delimCode ? start : s.indexOf(delim, start);
|
|
2397
|
+
let iAmp = c0 === 38 ? start : s.indexOf("&", start);
|
|
420
2398
|
let left = 0,
|
|
421
2399
|
out = "";
|
|
422
2400
|
while (iDelim >= 0 && iAmp >= 0) {
|
|
@@ -447,94 +2425,144 @@ function escape(s, attr) {
|
|
|
447
2425
|
}
|
|
448
2426
|
return left < s.length ? out + s.substring(left) : out;
|
|
449
2427
|
}
|
|
450
|
-
function
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
if (
|
|
456
|
-
|
|
457
|
-
for (const key in descriptors) {
|
|
458
|
-
if (key in target) continue;
|
|
459
|
-
Object.defineProperty(target, key, {
|
|
460
|
-
enumerable: true,
|
|
461
|
-
get() {
|
|
462
|
-
for (let i = sources.length - 1; i >= 0; i--) {
|
|
463
|
-
const v = (sources[i] || {})[key];
|
|
464
|
-
if (v !== undefined) return v;
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
});
|
|
468
|
-
}
|
|
2428
|
+
function tryJoinPlainSSRArray(nodes) {
|
|
2429
|
+
if (nodes.length === 0) return undefined;
|
|
2430
|
+
let out = "";
|
|
2431
|
+
for (let i = 0, len = nodes.length; i < len; i++) {
|
|
2432
|
+
const node = nodes[i];
|
|
2433
|
+
if (node == null || typeof node !== "object" || node.h || typeof node.t !== "string") {
|
|
2434
|
+
return undefined;
|
|
469
2435
|
}
|
|
2436
|
+
out += node.t;
|
|
470
2437
|
}
|
|
471
|
-
return
|
|
2438
|
+
return out;
|
|
472
2439
|
}
|
|
473
2440
|
function getHydrationKey() {
|
|
474
2441
|
const hydrate = solidJs.sharedConfig.context;
|
|
475
|
-
return hydrate &&
|
|
2442
|
+
return hydrate && solidJs.sharedConfig.getNextContextId();
|
|
476
2443
|
}
|
|
477
|
-
function
|
|
478
|
-
|
|
479
|
-
}
|
|
480
|
-
function getAssets() {
|
|
481
|
-
const assets = solidJs.sharedConfig.context.assets;
|
|
482
|
-
let out = "";
|
|
483
|
-
for (let i = 0, len = assets.length; i < len; i++) out += assets[i]();
|
|
484
|
-
return out;
|
|
2444
|
+
function applyRef(r, element) {
|
|
2445
|
+
Array.isArray(r) ? r.flat(Infinity).forEach(f => f && f(element)) : r(element);
|
|
485
2446
|
}
|
|
486
2447
|
function generateHydrationScript({
|
|
487
2448
|
eventNames = ["click", "input"],
|
|
488
2449
|
nonce
|
|
489
2450
|
} = {}) {
|
|
490
|
-
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('",
|
|
491
|
-
}
|
|
492
|
-
function Hydration(props) {
|
|
493
|
-
if (!solidJs.sharedConfig.context.noHydrate) return props.children;
|
|
494
|
-
const context = solidJs.sharedConfig.context;
|
|
495
|
-
solidJs.sharedConfig.context = {
|
|
496
|
-
...context,
|
|
497
|
-
noHydrate: false
|
|
498
|
-
};
|
|
499
|
-
const res = props.children;
|
|
500
|
-
solidJs.sharedConfig.context = context;
|
|
501
|
-
return res;
|
|
502
|
-
}
|
|
503
|
-
function NoHydration(props) {
|
|
504
|
-
let context = solidJs.sharedConfig.context;
|
|
505
|
-
if (context) solidJs.sharedConfig.context = {
|
|
506
|
-
...context,
|
|
507
|
-
noHydrate: true
|
|
508
|
-
};
|
|
509
|
-
const res = props.children;
|
|
510
|
-
if (context) solidJs.sharedConfig.context = context;
|
|
511
|
-
return res;
|
|
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-->`;
|
|
512
2452
|
}
|
|
513
2453
|
function queue(fn) {
|
|
514
2454
|
return Promise.resolve().then(fn);
|
|
515
2455
|
}
|
|
516
2456
|
function allSettled(promises) {
|
|
517
|
-
let
|
|
2457
|
+
let size = promises.size;
|
|
518
2458
|
return Promise.allSettled(promises).then(() => {
|
|
519
|
-
if (promises.
|
|
2459
|
+
if (promises.size !== size) return allSettled(promises);
|
|
520
2460
|
return;
|
|
521
2461
|
});
|
|
522
2462
|
}
|
|
523
|
-
function
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
2463
|
+
function assembleDocument(html, emittedAssets, inlineStyles, scripts, nonce, headTags, onHead) {
|
|
2464
|
+
const scriptTag = scripts ? `<script${nonce ? ` nonce="${nonce}"` : ""}>${scripts}</script>` : "";
|
|
2465
|
+
const headTagsHtml = headTags ? headTags.html : "";
|
|
2466
|
+
const headPrelude = headTags ? headTags.prelude : "";
|
|
2467
|
+
if (!onHead && !headTagsHtml && !headPrelude && !(emittedAssets && emittedAssets.size) && !(inlineStyles && inlineStyles.size)) {
|
|
2468
|
+
if (!scriptTag) return html;
|
|
2469
|
+
const xs = html.indexOf("<!--xs-->");
|
|
2470
|
+
return xs === -1 ? html + scriptTag : html.slice(0, xs) + scriptTag + html.slice(xs);
|
|
2471
|
+
}
|
|
2472
|
+
if (headPrelude) {
|
|
2473
|
+
const open = html.match(/<head(?:\s[^>]*)?>/);
|
|
2474
|
+
if (open) {
|
|
2475
|
+
const at = open.index + open[0].length;
|
|
2476
|
+
html = html.slice(0, at) + headPrelude + html.slice(at);
|
|
2477
|
+
}
|
|
2478
|
+
}
|
|
2479
|
+
const headIdx = html.indexOf("</head>");
|
|
2480
|
+
if (headIdx === -1) {
|
|
2481
|
+
if (onHead) {
|
|
2482
|
+
onHead(headPrelude + headTagsHtml + renderHeadAssets(emittedAssets, inlineStyles, nonce));
|
|
2483
|
+
}
|
|
2484
|
+
if (!scriptTag) return html;
|
|
2485
|
+
const xs = html.indexOf("<!--xs-->");
|
|
2486
|
+
return xs === -1 ? html + scriptTag : html.slice(0, xs) + scriptTag + html.slice(xs);
|
|
2487
|
+
}
|
|
2488
|
+
const head = headTagsHtml + renderHeadAssets(emittedAssets, inlineStyles, nonce);
|
|
2489
|
+
if (!scriptTag) return html.slice(0, headIdx) + head + html.slice(headIdx);
|
|
2490
|
+
const xsIdx = html.indexOf("<!--xs-->");
|
|
2491
|
+
if (xsIdx === -1) return html.slice(0, headIdx) + head + html.slice(headIdx) + scriptTag;
|
|
2492
|
+
return xsIdx < headIdx ? html.slice(0, xsIdx) + scriptTag + html.slice(xsIdx, headIdx) + head + html.slice(headIdx) : html.slice(0, headIdx) + head + html.slice(headIdx, xsIdx) + scriptTag + html.slice(xsIdx);
|
|
2493
|
+
}
|
|
2494
|
+
function renderHeadAssets(emittedAssets, inlineStyles, nonce) {
|
|
2495
|
+
let head = "";
|
|
2496
|
+
if (emittedAssets && emittedAssets.size) {
|
|
2497
|
+
for (const url of emittedAssets) {
|
|
2498
|
+
head += isCssUrl(url) ? `<link rel="stylesheet" href="${url}">` : `<link rel="modulepreload" href="${url}">`;
|
|
2499
|
+
}
|
|
2500
|
+
}
|
|
2501
|
+
if (inlineStyles && inlineStyles.size) {
|
|
2502
|
+
for (const entry of inlineStyles.values()) {
|
|
2503
|
+
if (entry.emitted) continue;
|
|
2504
|
+
entry.emitted = true;
|
|
2505
|
+
head += renderInlineStyle(entry, nonce);
|
|
2506
|
+
}
|
|
2507
|
+
}
|
|
2508
|
+
return head;
|
|
2509
|
+
}
|
|
2510
|
+
function serializeFragmentAssets(key, boundaryModules, context, name = key) {
|
|
2511
|
+
const map = boundaryModules.get(key);
|
|
2512
|
+
if (!map || !Object.keys(map).length) return;
|
|
2513
|
+
context.serialize(name + "_assets", {
|
|
2514
|
+
...map
|
|
2515
|
+
});
|
|
2516
|
+
}
|
|
2517
|
+
function propagateBoundaryStyles(childKey, parentKey, tracking) {
|
|
2518
|
+
const childStyles = tracking.getBoundaryStyles(childKey);
|
|
2519
|
+
if (!childStyles) return;
|
|
2520
|
+
let parentStyles = tracking.boundaryStyles.get(parentKey);
|
|
2521
|
+
if (!parentStyles) {
|
|
2522
|
+
parentStyles = new Set();
|
|
2523
|
+
tracking.boundaryStyles.set(parentKey, parentStyles);
|
|
2524
|
+
}
|
|
2525
|
+
for (const url of childStyles) {
|
|
2526
|
+
parentStyles.add(url);
|
|
2527
|
+
}
|
|
2528
|
+
}
|
|
2529
|
+
function collectStreamStyles(key, tracking, headStyles) {
|
|
2530
|
+
const styles = tracking.getBoundaryStyles(key);
|
|
2531
|
+
const links = [];
|
|
2532
|
+
const inline = [];
|
|
2533
|
+
if (!styles) return {
|
|
2534
|
+
links,
|
|
2535
|
+
inline
|
|
2536
|
+
};
|
|
2537
|
+
for (const entry of styles) {
|
|
2538
|
+
if (typeof entry === "string") {
|
|
2539
|
+
if (!headStyles || !headStyles.has(entry)) links.push(entry);
|
|
2540
|
+
} else if (entry.emitted) {
|
|
2541
|
+
continue;
|
|
2542
|
+
} else if (entry.attrHtml !== undefined) {
|
|
2543
|
+
entry.emitted = true;
|
|
2544
|
+
links.push(entry);
|
|
2545
|
+
} else {
|
|
2546
|
+
entry.emitted = true;
|
|
2547
|
+
inline.push(entry);
|
|
2548
|
+
}
|
|
2549
|
+
}
|
|
2550
|
+
return {
|
|
2551
|
+
links,
|
|
2552
|
+
inline
|
|
2553
|
+
};
|
|
530
2554
|
}
|
|
531
|
-
function
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
2555
|
+
function escapeStyleContent(content) {
|
|
2556
|
+
return content.replace(/<\/(style)/gi, "<\\/$1");
|
|
2557
|
+
}
|
|
2558
|
+
function renderInlineStyle(entry, nonce) {
|
|
2559
|
+
let attrs = "";
|
|
2560
|
+
if (entry.attrs) {
|
|
2561
|
+
for (const name in entry.attrs) {
|
|
2562
|
+
attrs += ` ${name}="${escape(String(entry.attrs[name]), true)}"`;
|
|
2563
|
+
}
|
|
536
2564
|
}
|
|
537
|
-
return
|
|
2565
|
+
return `<style${nonce ? ` nonce="${nonce}"` : ""} data-asset="${escape(entry.id, true)}"${attrs}>${escapeStyleContent(entry.content)}</style>`;
|
|
538
2566
|
}
|
|
539
2567
|
function waitForFragments(registry, key) {
|
|
540
2568
|
for (const k of [...registry.keys()].reverse()) {
|
|
@@ -564,19 +2592,48 @@ function flattenClassList(list, result) {
|
|
|
564
2592
|
if (Array.isArray(item)) flattenClassList(item, result);else if (typeof item === "object" && item != null) Object.assign(result, item);else if (item || item === 0) result[item] = true;
|
|
565
2593
|
}
|
|
566
2594
|
}
|
|
567
|
-
function
|
|
568
|
-
t
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
2595
|
+
function tryResolveString(node) {
|
|
2596
|
+
const t = typeof node;
|
|
2597
|
+
if (t === "string") return node;
|
|
2598
|
+
if (t === "number") return "" + node;
|
|
2599
|
+
if (node == null || t === "boolean") return "";
|
|
2600
|
+
if (t === "object") {
|
|
2601
|
+
if (Array.isArray(node)) {
|
|
2602
|
+
const joined = tryJoinPlainSSRArray(node);
|
|
2603
|
+
if (joined !== undefined) return joined;
|
|
2604
|
+
let s = "";
|
|
2605
|
+
let prevNonObj = false;
|
|
2606
|
+
for (let i = 0, len = node.length; i < len; i++) {
|
|
2607
|
+
const item = node[i];
|
|
2608
|
+
const itemNonObj = item !== null && typeof item !== "object";
|
|
2609
|
+
if (prevNonObj && itemNonObj) s += "<!--!$-->";
|
|
2610
|
+
prevNonObj = itemNonObj;
|
|
2611
|
+
const r = tryResolveString(item);
|
|
2612
|
+
if (typeof r !== "string") return {
|
|
2613
|
+
bail: node
|
|
2614
|
+
};
|
|
2615
|
+
s += r;
|
|
2616
|
+
}
|
|
2617
|
+
return s;
|
|
2618
|
+
}
|
|
2619
|
+
if (node.h && node.h.length > 0) return {
|
|
2620
|
+
merge: node
|
|
2621
|
+
};
|
|
2622
|
+
if (node.t === undefined) {
|
|
2623
|
+
return "";
|
|
2624
|
+
}
|
|
2625
|
+
return Array.isArray(node.t) ? node.t[0] : node.t;
|
|
577
2626
|
}
|
|
578
|
-
|
|
579
|
-
|
|
2627
|
+
if (t === "function") {
|
|
2628
|
+
let v;
|
|
2629
|
+
try {
|
|
2630
|
+
v = node();
|
|
2631
|
+
} catch (err) {
|
|
2632
|
+
return buildAsyncWrap(err, node) || "";
|
|
2633
|
+
}
|
|
2634
|
+
return tryResolveString(v);
|
|
2635
|
+
}
|
|
2636
|
+
return "";
|
|
580
2637
|
}
|
|
581
2638
|
function resolveSSRNode(node, result = {
|
|
582
2639
|
t: [""],
|
|
@@ -587,10 +2644,19 @@ function resolveSSRNode(node, result = {
|
|
|
587
2644
|
if (t === "string" || t === "number") {
|
|
588
2645
|
result.t[result.t.length - 1] += node;
|
|
589
2646
|
} else if (node == null || t === "boolean") ; else if (Array.isArray(node)) {
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
2647
|
+
const slotLive = node.$slot && solidJs.sharedConfig.context && solidJs.sharedConfig.context.liveHoles;
|
|
2648
|
+
if (slotLive) slotLive.suppressed++;
|
|
2649
|
+
try {
|
|
2650
|
+
let prevNonObj = false;
|
|
2651
|
+
for (let i = 0, len = node.length; i < len; i++) {
|
|
2652
|
+
const item = node[i];
|
|
2653
|
+
const itemNonObj = item !== null && typeof item !== "object";
|
|
2654
|
+
if (!top && prevNonObj && itemNonObj) result.t[result.t.length - 1] += `<!--!$-->`;
|
|
2655
|
+
prevNonObj = itemNonObj;
|
|
2656
|
+
resolveSSRNode(item, result);
|
|
2657
|
+
}
|
|
2658
|
+
} finally {
|
|
2659
|
+
if (slotLive) slotLive.suppressed--;
|
|
594
2660
|
}
|
|
595
2661
|
} else if (t === "object") {
|
|
596
2662
|
if (node.h) {
|
|
@@ -600,16 +2666,24 @@ function resolveSSRNode(node, result = {
|
|
|
600
2666
|
result.h.push(...node.h);
|
|
601
2667
|
result.p.push(...node.p);
|
|
602
2668
|
}
|
|
603
|
-
} else
|
|
2669
|
+
} else if (node.t !== undefined) {
|
|
2670
|
+
result.t[result.t.length - 1] += node.t;
|
|
2671
|
+
} else ;
|
|
604
2672
|
} else if (t === "function") {
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
2673
|
+
const live = solidJs.sharedConfig.context && solidJs.sharedConfig.context.liveHoles;
|
|
2674
|
+
let liveNode = null;
|
|
2675
|
+
if (live && (liveNode = live.content(node)) !== null) {
|
|
2676
|
+
if (typeof liveNode === "string") result.t[result.t.length - 1] += liveNode;else resolveSSRNode(liveNode, result);
|
|
2677
|
+
} else {
|
|
2678
|
+
try {
|
|
2679
|
+
resolveSSRNode(node(), result);
|
|
2680
|
+
} catch (err) {
|
|
2681
|
+
const wrap = buildAsyncWrap(err, node);
|
|
2682
|
+
if (wrap) {
|
|
2683
|
+
result.h.push(wrap.fn);
|
|
2684
|
+
result.p.push(wrap.p);
|
|
2685
|
+
result.t.push("");
|
|
2686
|
+
}
|
|
613
2687
|
}
|
|
614
2688
|
}
|
|
615
2689
|
}
|
|
@@ -618,61 +2692,413 @@ function resolveSSRNode(node, result = {
|
|
|
618
2692
|
function resolveSSRSync(node) {
|
|
619
2693
|
const res = resolveSSRNode(node);
|
|
620
2694
|
if (!res.h.length) return res.t[0];
|
|
621
|
-
throw new Error("This value cannot be rendered synchronously. Are you missing a
|
|
2695
|
+
throw new Error("This value cannot be rendered synchronously. Are you missing a boundary?");
|
|
622
2696
|
}
|
|
623
|
-
const RequestContext = Symbol();
|
|
2697
|
+
const RequestContext = Symbol.for("solid.RequestContext");
|
|
624
2698
|
function getRequestEvent() {
|
|
625
|
-
return globalThis[RequestContext] ? globalThis[RequestContext].getStore() || solidJs.sharedConfig.context && solidJs.sharedConfig.context.event || console.
|
|
2699
|
+
return globalThis[RequestContext] ? globalThis[RequestContext].getStore() || solidJs.sharedConfig.context && solidJs.sharedConfig.context.event || console.warn("RequestEvent is missing. This is most likely due to accessing `getRequestEvent` non-managed async scope in a partially polyfilled environment. Try moving it above all `await` calls.") : undefined;
|
|
2700
|
+
}
|
|
2701
|
+
function createResponseStub() {
|
|
2702
|
+
return {
|
|
2703
|
+
status: undefined,
|
|
2704
|
+
statusText: undefined,
|
|
2705
|
+
headers: new Headers(),
|
|
2706
|
+
committed: false
|
|
2707
|
+
};
|
|
2708
|
+
}
|
|
2709
|
+
function createRequestEvent(request, init) {
|
|
2710
|
+
return {
|
|
2711
|
+
request,
|
|
2712
|
+
locals: {},
|
|
2713
|
+
response: createResponseStub(),
|
|
2714
|
+
...init
|
|
2715
|
+
};
|
|
2716
|
+
}
|
|
2717
|
+
function reportLostHeaderWrite(method, name) {
|
|
2718
|
+
const message = `Response header write dropped: headers.${method}(${JSON.stringify(String(name))}) ` + "ran after the response head was sent. Write headers before the shell flushes " + "(or before the handler returns).";
|
|
2719
|
+
console.error(message);
|
|
2720
|
+
}
|
|
2721
|
+
function commitResponseStub(stub, {
|
|
2722
|
+
allowLateLocation = false
|
|
2723
|
+
} = {}) {
|
|
2724
|
+
if (!stub || stub.committed) return stub;
|
|
2725
|
+
stub.committed = true;
|
|
2726
|
+
const headers = stub.headers;
|
|
2727
|
+
if (!headers || typeof headers.set !== "function") return stub;
|
|
2728
|
+
for (const method of ["set", "append", "delete"]) {
|
|
2729
|
+
const original = headers[method].bind(headers);
|
|
2730
|
+
headers[method] = function (name, ...rest) {
|
|
2731
|
+
if (allowLateLocation && method === "set" && String(name).toLowerCase() === "location") {
|
|
2732
|
+
return original(name, ...rest);
|
|
2733
|
+
}
|
|
2734
|
+
reportLostHeaderWrite(method, name);
|
|
2735
|
+
};
|
|
2736
|
+
}
|
|
2737
|
+
return stub;
|
|
2738
|
+
}
|
|
2739
|
+
const validRedirectStatuses = /*#__PURE__*/new Set([301, 302, 303, 307, 308]);
|
|
2740
|
+
function getExpectedRedirectStatus(response) {
|
|
2741
|
+
if (response.status && validRedirectStatuses.has(response.status)) return response.status;
|
|
2742
|
+
return 302;
|
|
2743
|
+
}
|
|
2744
|
+
function mergeStubHeaders(target, stub) {
|
|
2745
|
+
if (!stub) return target;
|
|
2746
|
+
stub.headers.forEach((value, key) => {
|
|
2747
|
+
if (key !== "set-cookie") target.set(key, value);
|
|
2748
|
+
});
|
|
2749
|
+
const setCookies = stub.headers.getSetCookie ? stub.headers.getSetCookie() : [];
|
|
2750
|
+
for (const cookie of setCookies) target.append("set-cookie", cookie);
|
|
2751
|
+
return target;
|
|
2752
|
+
}
|
|
2753
|
+
function copyInitHeaders(init) {
|
|
2754
|
+
if (!init || !init.getSetCookie) return new Headers(init);
|
|
2755
|
+
const headers = new Headers();
|
|
2756
|
+
init.forEach((value, key) => {
|
|
2757
|
+
if (key !== "set-cookie") headers.append(key, value);
|
|
2758
|
+
});
|
|
2759
|
+
for (const cookie of init.getSetCookie()) headers.append("Set-Cookie", cookie);
|
|
2760
|
+
return headers;
|
|
2761
|
+
}
|
|
2762
|
+
const STUB_GAP_FILL_EXCLUDED = /*#__PURE__*/new Set([ERROR_HEADER, BODY_FORMAT_HEADER, SINGLE_FLIGHT_HEADER, REVALIDATE_HEADER, "Location"].map(header => header.toLowerCase()));
|
|
2763
|
+
function fillsStubGap(key, headers, response) {
|
|
2764
|
+
if (key === "set-cookie" || STUB_GAP_FILL_EXCLUDED.has(key)) return false;
|
|
2765
|
+
if (response.body === null && (key === "content-type" || key === "content-length")) return false;
|
|
2766
|
+
return !headers.has(key);
|
|
2767
|
+
}
|
|
2768
|
+
function commitEventResponse(response, event = getRequestEvent()) {
|
|
2769
|
+
const stub = event && event.response;
|
|
2770
|
+
if (!stub || !stub.headers || stub.committed) return response;
|
|
2771
|
+
const cookies = stub.headers.getSetCookie ? stub.headers.getSetCookie() : [];
|
|
2772
|
+
commitResponseStub(stub);
|
|
2773
|
+
let hasGaps = false;
|
|
2774
|
+
stub.headers.forEach((value, key) => {
|
|
2775
|
+
if (fillsStubGap(key, response.headers, response)) hasGaps = true;
|
|
2776
|
+
});
|
|
2777
|
+
if (!cookies.length && !hasGaps) return response;
|
|
2778
|
+
try {
|
|
2779
|
+
for (const cookie of cookies) response.headers.append("Set-Cookie", cookie);
|
|
2780
|
+
stub.headers.forEach((value, key) => {
|
|
2781
|
+
if (fillsStubGap(key, response.headers, response)) response.headers.set(key, value);
|
|
2782
|
+
});
|
|
2783
|
+
return response;
|
|
2784
|
+
} catch {
|
|
2785
|
+
const headers = copyInitHeaders(response.headers);
|
|
2786
|
+
for (const cookie of cookies) headers.append("Set-Cookie", cookie);
|
|
2787
|
+
stub.headers.forEach((value, key) => {
|
|
2788
|
+
if (fillsStubGap(key, headers, response)) headers.set(key, value);
|
|
2789
|
+
});
|
|
2790
|
+
return new Response(response.body, {
|
|
2791
|
+
status: response.status,
|
|
2792
|
+
statusText: response.statusText,
|
|
2793
|
+
headers
|
|
2794
|
+
});
|
|
2795
|
+
}
|
|
2796
|
+
}
|
|
2797
|
+
function deriveHead(stub, responseInit = {}) {
|
|
2798
|
+
const headers = mergeStubHeaders(copyInitHeaders(responseInit.headers), stub);
|
|
2799
|
+
const status = stub && stub.status || responseInit.status || 200;
|
|
2800
|
+
const statusText = stub && stub.statusText || responseInit.statusText || undefined;
|
|
2801
|
+
return {
|
|
2802
|
+
status,
|
|
2803
|
+
statusText,
|
|
2804
|
+
headers
|
|
2805
|
+
};
|
|
2806
|
+
}
|
|
2807
|
+
function escapeAttribute(value) {
|
|
2808
|
+
return value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<");
|
|
2809
|
+
}
|
|
2810
|
+
function createSSRResponse(result, event, options = {}) {
|
|
2811
|
+
const stub = event && event.response;
|
|
2812
|
+
const {
|
|
2813
|
+
responseInit,
|
|
2814
|
+
nonce,
|
|
2815
|
+
transformChunk
|
|
2816
|
+
} = options;
|
|
2817
|
+
if (typeof result === "string") {
|
|
2818
|
+
if (stub) commitResponseStub(stub);
|
|
2819
|
+
const head = deriveHead(stub, responseInit);
|
|
2820
|
+
if (stub && stub.headers.get("Location")) {
|
|
2821
|
+
return new Response(null, {
|
|
2822
|
+
status: getExpectedRedirectStatus(stub),
|
|
2823
|
+
headers: head.headers
|
|
2824
|
+
});
|
|
2825
|
+
}
|
|
2826
|
+
if (!head.headers.has("content-type")) {
|
|
2827
|
+
head.headers.set("content-type", "text/html; charset=utf-8");
|
|
2828
|
+
}
|
|
2829
|
+
return new Response(transformChunk ? transformChunk(result) : result, {
|
|
2830
|
+
status: head.status,
|
|
2831
|
+
statusText: head.statusText,
|
|
2832
|
+
headers: head.headers
|
|
2833
|
+
});
|
|
2834
|
+
}
|
|
2835
|
+
const encoder = new TextEncoder();
|
|
2836
|
+
return new Promise(resolve => {
|
|
2837
|
+
let controller;
|
|
2838
|
+
let closed = false;
|
|
2839
|
+
let flushed = false;
|
|
2840
|
+
const enqueue = value => {
|
|
2841
|
+
if (closed || !controller) return;
|
|
2842
|
+
try {
|
|
2843
|
+
controller.enqueue(encoder.encode(value));
|
|
2844
|
+
} catch {
|
|
2845
|
+
closed = true;
|
|
2846
|
+
}
|
|
2847
|
+
};
|
|
2848
|
+
result.pipe({
|
|
2849
|
+
write(chunk) {
|
|
2850
|
+
if (!flushed) {
|
|
2851
|
+
flushed = true;
|
|
2852
|
+
if (stub) commitResponseStub(stub, {
|
|
2853
|
+
allowLateLocation: true
|
|
2854
|
+
});
|
|
2855
|
+
const head = deriveHead(stub, responseInit);
|
|
2856
|
+
if (stub && stub.headers.get("Location")) {
|
|
2857
|
+
closed = true;
|
|
2858
|
+
resolve(new Response(null, {
|
|
2859
|
+
status: getExpectedRedirectStatus(stub),
|
|
2860
|
+
headers: head.headers
|
|
2861
|
+
}));
|
|
2862
|
+
return;
|
|
2863
|
+
}
|
|
2864
|
+
if (!head.headers.has("content-type")) {
|
|
2865
|
+
head.headers.set("content-type", "text/html; charset=utf-8");
|
|
2866
|
+
}
|
|
2867
|
+
resolve(new Response(new ReadableStream({
|
|
2868
|
+
start(c) {
|
|
2869
|
+
controller = c;
|
|
2870
|
+
},
|
|
2871
|
+
cancel() {
|
|
2872
|
+
closed = true;
|
|
2873
|
+
}
|
|
2874
|
+
}), {
|
|
2875
|
+
status: head.status,
|
|
2876
|
+
statusText: head.statusText,
|
|
2877
|
+
headers: head.headers
|
|
2878
|
+
}));
|
|
2879
|
+
}
|
|
2880
|
+
enqueue(transformChunk ? transformChunk(chunk) : chunk);
|
|
2881
|
+
},
|
|
2882
|
+
end() {
|
|
2883
|
+
if (closed || !controller) return;
|
|
2884
|
+
const location = stub && stub.headers.get("Location");
|
|
2885
|
+
if (location) {
|
|
2886
|
+
const attr = nonce ? ` nonce="${escapeAttribute(nonce)}"` : "";
|
|
2887
|
+
enqueue(`<script${attr}>window.location=${JSON.stringify(location).replace(/</g, "\\u003c")}</script>`);
|
|
2888
|
+
}
|
|
2889
|
+
closed = true;
|
|
2890
|
+
try {
|
|
2891
|
+
controller.close();
|
|
2892
|
+
} catch {}
|
|
2893
|
+
}
|
|
2894
|
+
});
|
|
2895
|
+
});
|
|
2896
|
+
}
|
|
2897
|
+
function composeMiddleware(middlewares) {
|
|
2898
|
+
return function run(request, next) {
|
|
2899
|
+
let index = -1;
|
|
2900
|
+
function dispatch(i, req) {
|
|
2901
|
+
if (i <= index) return Promise.reject(new Error("next() called multiple times"));
|
|
2902
|
+
index = i;
|
|
2903
|
+
if (i === middlewares.length) return Promise.resolve(next(req));
|
|
2904
|
+
return Promise.resolve(middlewares[i](req, override => dispatch(i + 1, override || req)));
|
|
2905
|
+
}
|
|
2906
|
+
return dispatch(0, request);
|
|
2907
|
+
};
|
|
2908
|
+
}
|
|
2909
|
+
function registerElementClaim() {
|
|
2910
|
+
return noopCleanup;
|
|
626
2911
|
}
|
|
627
|
-
function
|
|
628
|
-
|
|
2912
|
+
function noopCleanup() {}
|
|
2913
|
+
function claimElement(node) {
|
|
2914
|
+
return node;
|
|
2915
|
+
}
|
|
2916
|
+
function claimElementTree(root) {
|
|
2917
|
+
return root;
|
|
629
2918
|
}
|
|
630
2919
|
function notSup() {
|
|
631
2920
|
throw new Error("Client-only API called on the server side. Run client-only code in onMount, or conditionally run client-only component with <Show>.");
|
|
632
2921
|
}
|
|
633
2922
|
|
|
2923
|
+
setContainerTraceResolver(solidJs.getProjectionTrace);
|
|
634
2924
|
const isServer = true;
|
|
635
2925
|
const isDev = false;
|
|
636
|
-
function
|
|
637
|
-
const
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
2926
|
+
function dynamic(source) {
|
|
2927
|
+
const cached = solidJs.createMemo(source, {
|
|
2928
|
+
serialize: false
|
|
2929
|
+
});
|
|
2930
|
+
return props => {
|
|
2931
|
+
return solidJs.createMemo(() => {
|
|
2932
|
+
const c = cached();
|
|
2933
|
+
if (c) {
|
|
2934
|
+
if (typeof c === "function") return c(props);
|
|
2935
|
+
if (typeof c === "string") {
|
|
2936
|
+
return ssrElement(c, props, undefined, true);
|
|
2937
|
+
}
|
|
2938
|
+
}
|
|
2939
|
+
}, {
|
|
2940
|
+
sync: true
|
|
2941
|
+
});
|
|
2942
|
+
};
|
|
644
2943
|
}
|
|
645
2944
|
function Dynamic(props) {
|
|
646
|
-
const
|
|
647
|
-
return
|
|
2945
|
+
const Comp = dynamic(() => props.component);
|
|
2946
|
+
return solidJs.createComponent(Comp, solidJs.omit(props, "component"));
|
|
648
2947
|
}
|
|
649
2948
|
function Portal(props) {
|
|
650
|
-
|
|
2949
|
+
const o = solidJs.getOwner();
|
|
2950
|
+
if (o?.id != null) solidJs.getNextChildId(o);
|
|
2951
|
+
return undefined;
|
|
2952
|
+
}
|
|
2953
|
+
function registerClientOnlyPreload(moduleUrl) {
|
|
2954
|
+
const ctx = solidJs.sharedConfig.context;
|
|
2955
|
+
if (!ctx?.registerAsset || !ctx.resolveAssets) return;
|
|
2956
|
+
const registerAsset = ctx.registerAsset;
|
|
2957
|
+
const resolve = ctx.resolveAssets;
|
|
2958
|
+
const apply = assets => {
|
|
2959
|
+
if (!assets) return;
|
|
2960
|
+
for (let i = 0; i < assets.css.length; i++) {
|
|
2961
|
+
const css = assets.css[i];
|
|
2962
|
+
if (typeof css === "string") registerAsset("style", css);else registerAsset("inline-style", css);
|
|
2963
|
+
}
|
|
2964
|
+
for (let i = 0; i < assets.js.length; i++) registerAsset("module", assets.js[i]);
|
|
2965
|
+
};
|
|
2966
|
+
const assets = resolve(moduleUrl);
|
|
2967
|
+
if (assets && typeof assets.then === "function") {
|
|
2968
|
+
const boundary = ctx._currentBoundaryId;
|
|
2969
|
+
assets.then(resolved => {
|
|
2970
|
+
const current = ctx._currentBoundaryId;
|
|
2971
|
+
ctx._currentBoundaryId = boundary;
|
|
2972
|
+
try {
|
|
2973
|
+
apply(resolved);
|
|
2974
|
+
} finally {
|
|
2975
|
+
ctx._currentBoundaryId = current;
|
|
2976
|
+
}
|
|
2977
|
+
},
|
|
2978
|
+
() => {});
|
|
2979
|
+
} else {
|
|
2980
|
+
apply(assets);
|
|
2981
|
+
}
|
|
2982
|
+
}
|
|
2983
|
+
function clientOnly(_fn, _options = {}, moduleUrl) {
|
|
2984
|
+
return props => {
|
|
2985
|
+
if (moduleUrl) registerClientOnlyPreload(moduleUrl);
|
|
2986
|
+
return solidJs.createMemo(() => props.fallback);
|
|
2987
|
+
};
|
|
2988
|
+
}
|
|
2989
|
+
const statusLedgers = /* @__PURE__ */new WeakMap();
|
|
2990
|
+
const headerLedgers = /* @__PURE__ */new WeakMap();
|
|
2991
|
+
function httpStatus(code, text) {
|
|
2992
|
+
const event = getRequestEvent();
|
|
2993
|
+
const response = event && event.response;
|
|
2994
|
+
if (response && !response.committed) {
|
|
2995
|
+
let ledger = statusLedgers.get(response);
|
|
2996
|
+
if (!ledger) {
|
|
2997
|
+
ledger = {
|
|
2998
|
+
base: {
|
|
2999
|
+
status: response.status,
|
|
3000
|
+
statusText: response.statusText
|
|
3001
|
+
},
|
|
3002
|
+
live: []
|
|
3003
|
+
};
|
|
3004
|
+
statusLedgers.set(response, ledger);
|
|
3005
|
+
}
|
|
3006
|
+
const declaration = {
|
|
3007
|
+
status: code,
|
|
3008
|
+
statusText: text
|
|
3009
|
+
};
|
|
3010
|
+
ledger.live.push(declaration);
|
|
3011
|
+
response.status = code;
|
|
3012
|
+
response.statusText = text;
|
|
3013
|
+
solidJs.onCleanup(() => {
|
|
3014
|
+
if (response.committed) return;
|
|
3015
|
+
const index = ledger.live.indexOf(declaration);
|
|
3016
|
+
if (index < 0) return;
|
|
3017
|
+
ledger.live.splice(index, 1);
|
|
3018
|
+
const effective = ledger.live.length ? ledger.live[ledger.live.length - 1] : ledger.base;
|
|
3019
|
+
response.status = effective.status;
|
|
3020
|
+
response.statusText = effective.statusText;
|
|
3021
|
+
if (!ledger.live.length) statusLedgers.delete(response);
|
|
3022
|
+
});
|
|
3023
|
+
}
|
|
3024
|
+
}
|
|
3025
|
+
function httpHeader(name, value, options) {
|
|
3026
|
+
const event = getRequestEvent();
|
|
3027
|
+
const response = event && event.response;
|
|
3028
|
+
if (response && !response.committed) {
|
|
3029
|
+
const headers = response.headers;
|
|
3030
|
+
const key = name.toLowerCase();
|
|
3031
|
+
const setCookie = key === "set-cookie";
|
|
3032
|
+
let ledgers = headerLedgers.get(response);
|
|
3033
|
+
if (!ledgers) headerLedgers.set(response, ledgers = new Map());
|
|
3034
|
+
let ledger = ledgers.get(key);
|
|
3035
|
+
if (!ledger) {
|
|
3036
|
+
ledger = {
|
|
3037
|
+
base: setCookie ? headers.getSetCookie() : headers.get(name),
|
|
3038
|
+
live: []
|
|
3039
|
+
};
|
|
3040
|
+
ledgers.set(key, ledger);
|
|
3041
|
+
}
|
|
3042
|
+
const declaration = {
|
|
3043
|
+
value,
|
|
3044
|
+
append: !!(options && options.append)
|
|
3045
|
+
};
|
|
3046
|
+
ledger.live.push(declaration);
|
|
3047
|
+
if (declaration.append) headers.append(name, value);else headers.set(name, value);
|
|
3048
|
+
solidJs.onCleanup(() => {
|
|
3049
|
+
if (response.committed) return;
|
|
3050
|
+
const index = ledger.live.indexOf(declaration);
|
|
3051
|
+
if (index < 0) return;
|
|
3052
|
+
ledger.live.splice(index, 1);
|
|
3053
|
+
headers.delete(name);
|
|
3054
|
+
if (setCookie) {
|
|
3055
|
+
for (const cookie of ledger.base) headers.append(name, cookie);
|
|
3056
|
+
} else if (ledger.base !== null) {
|
|
3057
|
+
headers.set(name, ledger.base);
|
|
3058
|
+
}
|
|
3059
|
+
for (const d of ledger.live) {
|
|
3060
|
+
if (d.append) headers.append(name, d.value);else headers.set(name, d.value);
|
|
3061
|
+
}
|
|
3062
|
+
if (!ledger.live.length) ledgers.delete(key);
|
|
3063
|
+
});
|
|
3064
|
+
}
|
|
651
3065
|
}
|
|
652
3066
|
|
|
653
|
-
Object.defineProperty(exports, "
|
|
3067
|
+
Object.defineProperty(exports, "Errored", {
|
|
654
3068
|
enumerable: true,
|
|
655
|
-
get: function () { return solidJs.
|
|
3069
|
+
get: function () { return solidJs.Errored; }
|
|
656
3070
|
});
|
|
657
3071
|
Object.defineProperty(exports, "For", {
|
|
658
3072
|
enumerable: true,
|
|
659
3073
|
get: function () { return solidJs.For; }
|
|
660
3074
|
});
|
|
3075
|
+
Object.defineProperty(exports, "Hydration", {
|
|
3076
|
+
enumerable: true,
|
|
3077
|
+
get: function () { return solidJs.Hydration; }
|
|
3078
|
+
});
|
|
3079
|
+
Object.defineProperty(exports, "Loading", {
|
|
3080
|
+
enumerable: true,
|
|
3081
|
+
get: function () { return solidJs.Loading; }
|
|
3082
|
+
});
|
|
661
3083
|
Object.defineProperty(exports, "Match", {
|
|
662
3084
|
enumerable: true,
|
|
663
3085
|
get: function () { return solidJs.Match; }
|
|
664
3086
|
});
|
|
3087
|
+
Object.defineProperty(exports, "NoHydration", {
|
|
3088
|
+
enumerable: true,
|
|
3089
|
+
get: function () { return solidJs.NoHydration; }
|
|
3090
|
+
});
|
|
665
3091
|
Object.defineProperty(exports, "Repeat", {
|
|
666
3092
|
enumerable: true,
|
|
667
3093
|
get: function () { return solidJs.Repeat; }
|
|
668
3094
|
});
|
|
669
|
-
Object.defineProperty(exports, "
|
|
3095
|
+
Object.defineProperty(exports, "Reveal", {
|
|
670
3096
|
enumerable: true,
|
|
671
|
-
get: function () { return solidJs.
|
|
3097
|
+
get: function () { return solidJs.Reveal; }
|
|
672
3098
|
});
|
|
673
|
-
Object.defineProperty(exports, "
|
|
3099
|
+
Object.defineProperty(exports, "Show", {
|
|
674
3100
|
enumerable: true,
|
|
675
|
-
get: function () { return solidJs.
|
|
3101
|
+
get: function () { return solidJs.Show; }
|
|
676
3102
|
});
|
|
677
3103
|
Object.defineProperty(exports, "Switch", {
|
|
678
3104
|
enumerable: true,
|
|
@@ -682,17 +3108,17 @@ Object.defineProperty(exports, "createComponent", {
|
|
|
682
3108
|
enumerable: true,
|
|
683
3109
|
get: function () { return solidJs.createComponent; }
|
|
684
3110
|
});
|
|
685
|
-
Object.defineProperty(exports, "effect", {
|
|
686
|
-
enumerable: true,
|
|
687
|
-
get: function () { return solidJs.createRenderEffect; }
|
|
688
|
-
});
|
|
689
3111
|
Object.defineProperty(exports, "getOwner", {
|
|
690
3112
|
enumerable: true,
|
|
691
3113
|
get: function () { return solidJs.getOwner; }
|
|
692
3114
|
});
|
|
693
|
-
Object.defineProperty(exports, "
|
|
3115
|
+
Object.defineProperty(exports, "mergeProps", {
|
|
3116
|
+
enumerable: true,
|
|
3117
|
+
get: function () { return solidJs.merge; }
|
|
3118
|
+
});
|
|
3119
|
+
Object.defineProperty(exports, "scope", {
|
|
694
3120
|
enumerable: true,
|
|
695
|
-
get: function () { return solidJs.
|
|
3121
|
+
get: function () { return solidJs.ssrScope; }
|
|
696
3122
|
});
|
|
697
3123
|
Object.defineProperty(exports, "untrack", {
|
|
698
3124
|
enumerable: true,
|
|
@@ -700,52 +3126,94 @@ Object.defineProperty(exports, "untrack", {
|
|
|
700
3126
|
});
|
|
701
3127
|
exports.ChildProperties = ChildProperties;
|
|
702
3128
|
exports.DOMElements = DOMElements;
|
|
3129
|
+
exports.DOMWithState = DOMWithState;
|
|
703
3130
|
exports.DelegatedEvents = DelegatedEvents;
|
|
704
3131
|
exports.Dynamic = Dynamic;
|
|
705
|
-
exports.
|
|
3132
|
+
exports.HREF = HREF;
|
|
706
3133
|
exports.HydrationScript = HydrationScript;
|
|
707
|
-
exports.
|
|
3134
|
+
exports.MathMLElements = MathMLElements;
|
|
3135
|
+
exports.Namespaces = Namespaces;
|
|
708
3136
|
exports.Portal = Portal;
|
|
709
|
-
exports.
|
|
3137
|
+
exports.REVALIDATE_HEADER = REVALIDATE_HEADER;
|
|
3138
|
+
exports.RawTextElements = RawTextElements;
|
|
710
3139
|
exports.RequestContext = RequestContext;
|
|
3140
|
+
exports.ResponseEnvelope = ResponseEnvelope;
|
|
3141
|
+
exports.SAFE_ERROR = SAFE_ERROR;
|
|
711
3142
|
exports.SVGElements = SVGElements;
|
|
712
|
-
exports.
|
|
713
|
-
exports.
|
|
3143
|
+
exports.VoidElements = VoidElements;
|
|
3144
|
+
exports.acquireAsset = notSup;
|
|
3145
|
+
exports.addEvent = notSup;
|
|
3146
|
+
exports.applyRef = applyRef;
|
|
714
3147
|
exports.assign = notSup;
|
|
3148
|
+
exports.claimElement = claimElement;
|
|
3149
|
+
exports.claimElementTree = claimElementTree;
|
|
715
3150
|
exports.className = notSup;
|
|
716
|
-
exports.
|
|
3151
|
+
exports.clearFlashCookie = clearFlashCookie;
|
|
3152
|
+
exports.clientOnly = clientOnly;
|
|
3153
|
+
exports.commitEventResponse = commitEventResponse;
|
|
3154
|
+
exports.commitResponseStub = commitResponseStub;
|
|
3155
|
+
exports.composeMiddleware = composeMiddleware;
|
|
3156
|
+
exports.createLiveHoles = createLiveHoles;
|
|
3157
|
+
exports.createRequestEvent = createRequestEvent;
|
|
3158
|
+
exports.createResponseStub = createResponseStub;
|
|
3159
|
+
exports.createSSRResponse = createSSRResponse;
|
|
717
3160
|
exports.delegateEvents = notSup;
|
|
3161
|
+
exports.dynamic = dynamic;
|
|
718
3162
|
exports.dynamicProperty = notSup;
|
|
3163
|
+
exports.effect = effect;
|
|
719
3164
|
exports.escape = escape;
|
|
720
3165
|
exports.generateHydrationScript = generateHydrationScript;
|
|
721
|
-
exports.
|
|
3166
|
+
exports.getDelegatedRoot = notSup;
|
|
3167
|
+
exports.getExpectedRedirectStatus = getExpectedRedirectStatus;
|
|
722
3168
|
exports.getHydrationKey = getHydrationKey;
|
|
723
3169
|
exports.getNextElement = notSup;
|
|
724
3170
|
exports.getNextMarker = notSup;
|
|
725
3171
|
exports.getNextMatch = notSup;
|
|
726
3172
|
exports.getRequestEvent = getRequestEvent;
|
|
3173
|
+
exports.getServerFunctionMetadata = getServerFunctionMetadata;
|
|
3174
|
+
exports.getServerFunctionRPC = getServerFunctionRPC;
|
|
3175
|
+
exports.hasFlashCookie = hasFlashCookie;
|
|
3176
|
+
exports.httpHeader = httpHeader;
|
|
3177
|
+
exports.httpStatus = httpStatus;
|
|
727
3178
|
exports.hydrate = notSup;
|
|
728
3179
|
exports.insert = notSup;
|
|
729
3180
|
exports.isDev = isDev;
|
|
3181
|
+
exports.isHref = isHref;
|
|
3182
|
+
exports.isResponseEnvelope = isResponseEnvelope;
|
|
3183
|
+
exports.isSafeError = isSafeError;
|
|
730
3184
|
exports.isServer = isServer;
|
|
3185
|
+
exports.isServerFunction = isServerFunction;
|
|
3186
|
+
exports.markSafeError = markSafeError;
|
|
731
3187
|
exports.memo = memo;
|
|
732
|
-
exports.
|
|
3188
|
+
exports.parseCookieHeader = parseCookieHeader;
|
|
3189
|
+
exports.redirect = redirect;
|
|
3190
|
+
exports.ref = notSup;
|
|
3191
|
+
exports.registerDelegatedContainer = notSup;
|
|
3192
|
+
exports.registerDelegatedRoot = notSup;
|
|
3193
|
+
exports.registerElementClaim = registerElementClaim;
|
|
3194
|
+
exports.reload = reload;
|
|
733
3195
|
exports.render = notSup;
|
|
734
3196
|
exports.renderToStream = renderToStream;
|
|
735
3197
|
exports.renderToString = renderToString;
|
|
736
|
-
exports.
|
|
3198
|
+
exports.resolveSSRSelectValues = resolveSSRSelectValues;
|
|
3199
|
+
exports.respond = respond;
|
|
737
3200
|
exports.runHydrationEvents = notSup;
|
|
3201
|
+
exports.serializeCookie = serializeCookie;
|
|
738
3202
|
exports.setAttribute = notSup;
|
|
739
3203
|
exports.setAttributeNS = notSup;
|
|
740
3204
|
exports.setProperty = notSup;
|
|
3205
|
+
exports.setStyleProperty = notSup;
|
|
741
3206
|
exports.spread = notSup;
|
|
742
3207
|
exports.ssr = ssr;
|
|
743
3208
|
exports.ssrAttribute = ssrAttribute;
|
|
744
3209
|
exports.ssrClassName = ssrClassName;
|
|
745
3210
|
exports.ssrElement = ssrElement;
|
|
3211
|
+
exports.ssrGroup = ssrGroup;
|
|
746
3212
|
exports.ssrHydrationKey = ssrHydrationKey;
|
|
747
3213
|
exports.ssrStyle = ssrStyle;
|
|
748
3214
|
exports.ssrStyleProperty = ssrStyleProperty;
|
|
749
3215
|
exports.style = notSup;
|
|
750
3216
|
exports.template = notSup;
|
|
751
|
-
exports.
|
|
3217
|
+
exports.unregisterDelegatedContainer = notSup;
|
|
3218
|
+
exports.unregisterDelegatedRoot = notSup;
|
|
3219
|
+
exports.useHead = useHead;
|