@solidjs/web 2.0.0-experimental.8 → 2.0.0-rc.0
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 +1585 -225
- package/dist/dev.js +1510 -201
- package/dist/server.cjs +2642 -264
- package/dist/server.js +2542 -217
- package/dist/web.cjs +1523 -218
- package/dist/web.js +1448 -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 +3667 -0
- package/frames/dist/server.js +3654 -0
- package/frames/package.json +30 -0
- package/package.json +349 -37
- package/serialization/decode/package.json +20 -0
- package/serialization/dist/decode.cjs +110 -0
- package/serialization/dist/decode.js +104 -0
- package/serialization/dist/serialization.cjs +232 -0
- package/serialization/dist/serialization.js +215 -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 +646 -0
- package/server-functions/dist/client.js +617 -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 +1077 -0
- package/server-functions/dist/server.dev.cjs +1077 -0
- package/server-functions/dist/server.dev.js +1045 -0
- package/server-functions/dist/server.js +1045 -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 +209 -24
- package/types/jsx-properties.d.ts +93 -0
- package/types/jsx.d.ts +4150 -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 +201 -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 +588 -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 +230 -0
- package/types-cjs/jsx-properties.d.cts +93 -0
- package/types-cjs/jsx.d.cts +4150 -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 +201 -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 +588 -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(","));
|
|
52
|
+
|
|
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);
|
|
66
|
+
|
|
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
|
+
};
|
|
23
122
|
|
|
24
|
-
const
|
|
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;
|
|
25
131
|
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
function createSerializer({
|
|
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) + ";";
|
|
49
160
|
}
|
|
50
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;
|
|
405
|
+
}
|
|
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(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,120 +1285,923 @@ 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, 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(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) {
|
|
248
1406
|
!completed && buffer.write(v);
|
|
249
1407
|
}
|
|
250
|
-
});
|
|
251
|
-
shellCompleted = true;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
if (
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
1408
|
+
});
|
|
1409
|
+
shellCompleted = true;
|
|
1410
|
+
}
|
|
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() {
|
|
1443
|
+
allSettled(blockingPromises).then(() => {
|
|
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
|
+
};
|
|
1479
|
+
buffer.write(tmp);
|
|
1480
|
+
firstFlushed = true;
|
|
1481
|
+
if (completed) {
|
|
1482
|
+
dispose();
|
|
1483
|
+
writable.end();
|
|
1484
|
+
} else flushEnd();
|
|
1485
|
+
});
|
|
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: []
|
|
264
1847
|
};
|
|
265
|
-
|
|
266
|
-
|
|
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
|
+
};
|
|
267
1902
|
},
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
setTimeout(() => {
|
|
271
|
-
doShell();
|
|
272
|
-
buffer = writable = w;
|
|
273
|
-
buffer.write(tmp);
|
|
274
|
-
firstFlushed = true;
|
|
275
|
-
if (completed) {
|
|
276
|
-
dispose();
|
|
277
|
-
writable.end();
|
|
278
|
-
} else flushEnd();
|
|
279
|
-
});
|
|
280
|
-
});
|
|
1903
|
+
mint() {
|
|
1904
|
+
return nextId++;
|
|
281
1905
|
},
|
|
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
|
-
|
|
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)) {
|
|
@@ -405,18 +2283,31 @@ function escape(s, attr) {
|
|
|
405
2283
|
const t = typeof s;
|
|
406
2284
|
if (t !== "string") {
|
|
407
2285
|
if (!attr && Array.isArray(s)) {
|
|
2286
|
+
const joined = tryJoinPlainSSRArray(s);
|
|
2287
|
+
if (joined !== undefined) return joined;
|
|
408
2288
|
s = s.slice();
|
|
409
2289
|
for (let i = 0; i < s.length; i++) s[i] = escape(s[i]);
|
|
410
2290
|
return s;
|
|
411
2291
|
}
|
|
412
|
-
if (attr
|
|
2292
|
+
if (attr) {
|
|
2293
|
+
if (s == null || t === "boolean" || t === "number") return s;
|
|
2294
|
+
return escape(String(s), attr);
|
|
2295
|
+
}
|
|
413
2296
|
return s;
|
|
414
2297
|
}
|
|
2298
|
+
const i = s.search(attr ? ESCAPE_ATTR : ESCAPE_CONTENT);
|
|
2299
|
+
if (i < 0) return s;
|
|
2300
|
+
return escapeSlow(s, attr, i);
|
|
2301
|
+
}
|
|
2302
|
+
const ESCAPE_CONTENT = /[&<]/;
|
|
2303
|
+
const ESCAPE_ATTR = /[&"]/;
|
|
2304
|
+
function escapeSlow(s, attr, start) {
|
|
415
2305
|
const delim = attr ? '"' : "<";
|
|
2306
|
+
const delimCode = attr ? 34 : 60;
|
|
416
2307
|
const escDelim = attr ? """ : "<";
|
|
417
|
-
|
|
418
|
-
let
|
|
419
|
-
|
|
2308
|
+
const c0 = s.charCodeAt(start);
|
|
2309
|
+
let iDelim = c0 === delimCode ? start : s.indexOf(delim, start);
|
|
2310
|
+
let iAmp = c0 === 38 ? start : s.indexOf("&", start);
|
|
420
2311
|
let left = 0,
|
|
421
2312
|
out = "";
|
|
422
2313
|
while (iDelim >= 0 && iAmp >= 0) {
|
|
@@ -447,94 +2338,142 @@ function escape(s, attr) {
|
|
|
447
2338
|
}
|
|
448
2339
|
return left < s.length ? out + s.substring(left) : out;
|
|
449
2340
|
}
|
|
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
|
-
}
|
|
2341
|
+
function tryJoinPlainSSRArray(nodes) {
|
|
2342
|
+
if (nodes.length === 0) return undefined;
|
|
2343
|
+
let out = "";
|
|
2344
|
+
for (let i = 0, len = nodes.length; i < len; i++) {
|
|
2345
|
+
const node = nodes[i];
|
|
2346
|
+
if (node == null || typeof node !== "object" || node.h || typeof node.t !== "string") {
|
|
2347
|
+
return undefined;
|
|
469
2348
|
}
|
|
2349
|
+
out += node.t;
|
|
470
2350
|
}
|
|
471
|
-
return
|
|
2351
|
+
return out;
|
|
472
2352
|
}
|
|
473
2353
|
function getHydrationKey() {
|
|
474
2354
|
const hydrate = solidJs.sharedConfig.context;
|
|
475
|
-
return hydrate &&
|
|
476
|
-
}
|
|
477
|
-
function useAssets(fn) {
|
|
478
|
-
solidJs.sharedConfig.context.assets.push(() => resolveSSRSync(escape(fn())));
|
|
2355
|
+
return hydrate && solidJs.sharedConfig.getNextContextId();
|
|
479
2356
|
}
|
|
480
|
-
function
|
|
481
|
-
|
|
482
|
-
let out = "";
|
|
483
|
-
for (let i = 0, len = assets.length; i < len; i++) out += assets[i]();
|
|
484
|
-
return out;
|
|
2357
|
+
function applyRef(r, element) {
|
|
2358
|
+
Array.isArray(r) ? r.flat(Infinity).forEach(f => f && f(element)) : r(element);
|
|
485
2359
|
}
|
|
486
2360
|
function generateHydrationScript({
|
|
487
2361
|
eventNames = ["click", "input"],
|
|
488
2362
|
nonce
|
|
489
2363
|
} = {}) {
|
|
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;
|
|
2364
|
+
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
2365
|
}
|
|
513
2366
|
function queue(fn) {
|
|
514
2367
|
return Promise.resolve().then(fn);
|
|
515
2368
|
}
|
|
516
2369
|
function allSettled(promises) {
|
|
517
|
-
let
|
|
2370
|
+
let size = promises.size;
|
|
518
2371
|
return Promise.allSettled(promises).then(() => {
|
|
519
|
-
if (promises.
|
|
2372
|
+
if (promises.size !== size) return allSettled(promises);
|
|
520
2373
|
return;
|
|
521
2374
|
});
|
|
522
2375
|
}
|
|
523
|
-
function
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
2376
|
+
function assembleDocument(html, emittedAssets, inlineStyles, scripts, nonce, headTags, onHead) {
|
|
2377
|
+
const scriptTag = scripts ? `<script${nonce ? ` nonce="${nonce}"` : ""}>${scripts}</script>` : "";
|
|
2378
|
+
const headTagsHtml = headTags ? headTags.html : "";
|
|
2379
|
+
const headPrelude = headTags ? headTags.prelude : "";
|
|
2380
|
+
if (!onHead && !headTagsHtml && !headPrelude && !(emittedAssets && emittedAssets.size) && !(inlineStyles && inlineStyles.size)) {
|
|
2381
|
+
if (!scriptTag) return html;
|
|
2382
|
+
const xs = html.indexOf("<!--xs-->");
|
|
2383
|
+
return xs === -1 ? html + scriptTag : html.slice(0, xs) + scriptTag + html.slice(xs);
|
|
2384
|
+
}
|
|
2385
|
+
if (headPrelude) {
|
|
2386
|
+
const open = html.match(/<head(?:\s[^>]*)?>/);
|
|
2387
|
+
if (open) {
|
|
2388
|
+
const at = open.index + open[0].length;
|
|
2389
|
+
html = html.slice(0, at) + headPrelude + html.slice(at);
|
|
2390
|
+
}
|
|
2391
|
+
}
|
|
2392
|
+
const headIdx = html.indexOf("</head>");
|
|
2393
|
+
if (headIdx === -1) {
|
|
2394
|
+
if (onHead) {
|
|
2395
|
+
onHead(headPrelude + headTagsHtml + renderHeadAssets(emittedAssets, inlineStyles, nonce));
|
|
2396
|
+
}
|
|
2397
|
+
if (!scriptTag) return html;
|
|
2398
|
+
const xs = html.indexOf("<!--xs-->");
|
|
2399
|
+
return xs === -1 ? html + scriptTag : html.slice(0, xs) + scriptTag + html.slice(xs);
|
|
2400
|
+
}
|
|
2401
|
+
const head = headTagsHtml + renderHeadAssets(emittedAssets, inlineStyles, nonce);
|
|
2402
|
+
if (!scriptTag) return html.slice(0, headIdx) + head + html.slice(headIdx);
|
|
2403
|
+
const xsIdx = html.indexOf("<!--xs-->");
|
|
2404
|
+
if (xsIdx === -1) return html.slice(0, headIdx) + head + html.slice(headIdx) + scriptTag;
|
|
2405
|
+
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);
|
|
2406
|
+
}
|
|
2407
|
+
function renderHeadAssets(emittedAssets, inlineStyles, nonce) {
|
|
2408
|
+
let head = "";
|
|
2409
|
+
if (emittedAssets && emittedAssets.size) {
|
|
2410
|
+
for (const url of emittedAssets) {
|
|
2411
|
+
head += isCssUrl(url) ? `<link rel="stylesheet" href="${url}">` : `<link rel="modulepreload" href="${url}">`;
|
|
2412
|
+
}
|
|
2413
|
+
}
|
|
2414
|
+
if (inlineStyles && inlineStyles.size) {
|
|
2415
|
+
for (const entry of inlineStyles.values()) {
|
|
2416
|
+
if (entry.emitted) continue;
|
|
2417
|
+
entry.emitted = true;
|
|
2418
|
+
head += renderInlineStyle(entry, nonce);
|
|
2419
|
+
}
|
|
2420
|
+
}
|
|
2421
|
+
return head;
|
|
530
2422
|
}
|
|
531
|
-
function
|
|
532
|
-
const
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
2423
|
+
function serializeFragmentAssets(key, boundaryModules, context, name = key) {
|
|
2424
|
+
const map = boundaryModules.get(key);
|
|
2425
|
+
if (!map || !Object.keys(map).length) return;
|
|
2426
|
+
context.serialize(name + "_assets", map);
|
|
2427
|
+
}
|
|
2428
|
+
function propagateBoundaryStyles(childKey, parentKey, tracking) {
|
|
2429
|
+
const childStyles = tracking.getBoundaryStyles(childKey);
|
|
2430
|
+
if (!childStyles) return;
|
|
2431
|
+
let parentStyles = tracking.boundaryStyles.get(parentKey);
|
|
2432
|
+
if (!parentStyles) {
|
|
2433
|
+
parentStyles = new Set();
|
|
2434
|
+
tracking.boundaryStyles.set(parentKey, parentStyles);
|
|
2435
|
+
}
|
|
2436
|
+
for (const url of childStyles) {
|
|
2437
|
+
parentStyles.add(url);
|
|
2438
|
+
}
|
|
2439
|
+
}
|
|
2440
|
+
function collectStreamStyles(key, tracking, headStyles) {
|
|
2441
|
+
const styles = tracking.getBoundaryStyles(key);
|
|
2442
|
+
const links = [];
|
|
2443
|
+
const inline = [];
|
|
2444
|
+
if (!styles) return {
|
|
2445
|
+
links,
|
|
2446
|
+
inline
|
|
2447
|
+
};
|
|
2448
|
+
for (const entry of styles) {
|
|
2449
|
+
if (typeof entry === "string") {
|
|
2450
|
+
if (!headStyles || !headStyles.has(entry)) links.push(entry);
|
|
2451
|
+
} else if (entry.emitted) {
|
|
2452
|
+
continue;
|
|
2453
|
+
} else if (entry.attrHtml !== undefined) {
|
|
2454
|
+
entry.emitted = true;
|
|
2455
|
+
links.push(entry);
|
|
2456
|
+
} else {
|
|
2457
|
+
entry.emitted = true;
|
|
2458
|
+
inline.push(entry);
|
|
2459
|
+
}
|
|
536
2460
|
}
|
|
537
|
-
return
|
|
2461
|
+
return {
|
|
2462
|
+
links,
|
|
2463
|
+
inline
|
|
2464
|
+
};
|
|
2465
|
+
}
|
|
2466
|
+
function escapeStyleContent(content) {
|
|
2467
|
+
return content.replace(/<\/(style)/gi, "<\\/$1");
|
|
2468
|
+
}
|
|
2469
|
+
function renderInlineStyle(entry, nonce) {
|
|
2470
|
+
let attrs = "";
|
|
2471
|
+
if (entry.attrs) {
|
|
2472
|
+
for (const name in entry.attrs) {
|
|
2473
|
+
attrs += ` ${name}="${escape(String(entry.attrs[name]), true)}"`;
|
|
2474
|
+
}
|
|
2475
|
+
}
|
|
2476
|
+
return `<style${nonce ? ` nonce="${nonce}"` : ""} data-asset="${escape(entry.id, true)}"${attrs}>${escapeStyleContent(entry.content)}</style>`;
|
|
538
2477
|
}
|
|
539
2478
|
function waitForFragments(registry, key) {
|
|
540
2479
|
for (const k of [...registry.keys()].reverse()) {
|
|
@@ -564,19 +2503,48 @@ function flattenClassList(list, result) {
|
|
|
564
2503
|
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
2504
|
}
|
|
566
2505
|
}
|
|
567
|
-
function
|
|
568
|
-
t
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
2506
|
+
function tryResolveString(node) {
|
|
2507
|
+
const t = typeof node;
|
|
2508
|
+
if (t === "string") return node;
|
|
2509
|
+
if (t === "number") return "" + node;
|
|
2510
|
+
if (node == null || t === "boolean") return "";
|
|
2511
|
+
if (t === "object") {
|
|
2512
|
+
if (Array.isArray(node)) {
|
|
2513
|
+
const joined = tryJoinPlainSSRArray(node);
|
|
2514
|
+
if (joined !== undefined) return joined;
|
|
2515
|
+
let s = "";
|
|
2516
|
+
let prevNonObj = false;
|
|
2517
|
+
for (let i = 0, len = node.length; i < len; i++) {
|
|
2518
|
+
const item = node[i];
|
|
2519
|
+
const itemNonObj = item !== null && typeof item !== "object";
|
|
2520
|
+
if (prevNonObj && itemNonObj) s += "<!--!$-->";
|
|
2521
|
+
prevNonObj = itemNonObj;
|
|
2522
|
+
const r = tryResolveString(item);
|
|
2523
|
+
if (typeof r !== "string") return {
|
|
2524
|
+
bail: node
|
|
2525
|
+
};
|
|
2526
|
+
s += r;
|
|
2527
|
+
}
|
|
2528
|
+
return s;
|
|
2529
|
+
}
|
|
2530
|
+
if (node.h && node.h.length > 0) return {
|
|
2531
|
+
merge: node
|
|
2532
|
+
};
|
|
2533
|
+
if (node.t === undefined) {
|
|
2534
|
+
return "";
|
|
2535
|
+
}
|
|
2536
|
+
return Array.isArray(node.t) ? node.t[0] : node.t;
|
|
577
2537
|
}
|
|
578
|
-
|
|
579
|
-
|
|
2538
|
+
if (t === "function") {
|
|
2539
|
+
let v;
|
|
2540
|
+
try {
|
|
2541
|
+
v = node();
|
|
2542
|
+
} catch (err) {
|
|
2543
|
+
return buildAsyncWrap(err, node) || "";
|
|
2544
|
+
}
|
|
2545
|
+
return tryResolveString(v);
|
|
2546
|
+
}
|
|
2547
|
+
return "";
|
|
580
2548
|
}
|
|
581
2549
|
function resolveSSRNode(node, result = {
|
|
582
2550
|
t: [""],
|
|
@@ -587,10 +2555,19 @@ function resolveSSRNode(node, result = {
|
|
|
587
2555
|
if (t === "string" || t === "number") {
|
|
588
2556
|
result.t[result.t.length - 1] += node;
|
|
589
2557
|
} else if (node == null || t === "boolean") ; else if (Array.isArray(node)) {
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
2558
|
+
const slotLive = node.$slot && solidJs.sharedConfig.context && solidJs.sharedConfig.context.liveHoles;
|
|
2559
|
+
if (slotLive) slotLive.suppressed++;
|
|
2560
|
+
try {
|
|
2561
|
+
let prevNonObj = false;
|
|
2562
|
+
for (let i = 0, len = node.length; i < len; i++) {
|
|
2563
|
+
const item = node[i];
|
|
2564
|
+
const itemNonObj = item !== null && typeof item !== "object";
|
|
2565
|
+
if (!top && prevNonObj && itemNonObj) result.t[result.t.length - 1] += `<!--!$-->`;
|
|
2566
|
+
prevNonObj = itemNonObj;
|
|
2567
|
+
resolveSSRNode(item, result);
|
|
2568
|
+
}
|
|
2569
|
+
} finally {
|
|
2570
|
+
if (slotLive) slotLive.suppressed--;
|
|
594
2571
|
}
|
|
595
2572
|
} else if (t === "object") {
|
|
596
2573
|
if (node.h) {
|
|
@@ -600,16 +2577,24 @@ function resolveSSRNode(node, result = {
|
|
|
600
2577
|
result.h.push(...node.h);
|
|
601
2578
|
result.p.push(...node.p);
|
|
602
2579
|
}
|
|
603
|
-
} else
|
|
2580
|
+
} else if (node.t !== undefined) {
|
|
2581
|
+
result.t[result.t.length - 1] += node.t;
|
|
2582
|
+
} else ;
|
|
604
2583
|
} else if (t === "function") {
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
2584
|
+
const live = solidJs.sharedConfig.context && solidJs.sharedConfig.context.liveHoles;
|
|
2585
|
+
let liveNode = null;
|
|
2586
|
+
if (live && (liveNode = live.content(node)) !== null) {
|
|
2587
|
+
if (typeof liveNode === "string") result.t[result.t.length - 1] += liveNode;else resolveSSRNode(liveNode, result);
|
|
2588
|
+
} else {
|
|
2589
|
+
try {
|
|
2590
|
+
resolveSSRNode(node(), result);
|
|
2591
|
+
} catch (err) {
|
|
2592
|
+
const wrap = buildAsyncWrap(err, node);
|
|
2593
|
+
if (wrap) {
|
|
2594
|
+
result.h.push(wrap.fn);
|
|
2595
|
+
result.p.push(wrap.p);
|
|
2596
|
+
result.t.push("");
|
|
2597
|
+
}
|
|
613
2598
|
}
|
|
614
2599
|
}
|
|
615
2600
|
}
|
|
@@ -618,61 +2603,413 @@ function resolveSSRNode(node, result = {
|
|
|
618
2603
|
function resolveSSRSync(node) {
|
|
619
2604
|
const res = resolveSSRNode(node);
|
|
620
2605
|
if (!res.h.length) return res.t[0];
|
|
621
|
-
throw new Error("This value cannot be rendered synchronously. Are you missing a
|
|
2606
|
+
throw new Error("This value cannot be rendered synchronously. Are you missing a boundary?");
|
|
622
2607
|
}
|
|
623
|
-
const RequestContext = Symbol();
|
|
2608
|
+
const RequestContext = Symbol.for("solid.RequestContext");
|
|
624
2609
|
function getRequestEvent() {
|
|
625
|
-
return globalThis[RequestContext] ? globalThis[RequestContext].getStore() || solidJs.sharedConfig.context && solidJs.sharedConfig.context.event || console.
|
|
2610
|
+
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;
|
|
2611
|
+
}
|
|
2612
|
+
function createResponseStub() {
|
|
2613
|
+
return {
|
|
2614
|
+
status: undefined,
|
|
2615
|
+
statusText: undefined,
|
|
2616
|
+
headers: new Headers(),
|
|
2617
|
+
committed: false
|
|
2618
|
+
};
|
|
2619
|
+
}
|
|
2620
|
+
function createRequestEvent(request, init) {
|
|
2621
|
+
return {
|
|
2622
|
+
request,
|
|
2623
|
+
locals: {},
|
|
2624
|
+
response: createResponseStub(),
|
|
2625
|
+
...init
|
|
2626
|
+
};
|
|
2627
|
+
}
|
|
2628
|
+
function reportLostHeaderWrite(method, name) {
|
|
2629
|
+
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).";
|
|
2630
|
+
console.error(message);
|
|
2631
|
+
}
|
|
2632
|
+
function commitResponseStub(stub, {
|
|
2633
|
+
allowLateLocation = false
|
|
2634
|
+
} = {}) {
|
|
2635
|
+
if (!stub || stub.committed) return stub;
|
|
2636
|
+
stub.committed = true;
|
|
2637
|
+
const headers = stub.headers;
|
|
2638
|
+
if (!headers || typeof headers.set !== "function") return stub;
|
|
2639
|
+
for (const method of ["set", "append", "delete"]) {
|
|
2640
|
+
const original = headers[method].bind(headers);
|
|
2641
|
+
headers[method] = function (name, ...rest) {
|
|
2642
|
+
if (allowLateLocation && method === "set" && String(name).toLowerCase() === "location") {
|
|
2643
|
+
return original(name, ...rest);
|
|
2644
|
+
}
|
|
2645
|
+
reportLostHeaderWrite(method, name);
|
|
2646
|
+
};
|
|
2647
|
+
}
|
|
2648
|
+
return stub;
|
|
2649
|
+
}
|
|
2650
|
+
const validRedirectStatuses = /*#__PURE__*/new Set([301, 302, 303, 307, 308]);
|
|
2651
|
+
function getExpectedRedirectStatus(response) {
|
|
2652
|
+
if (response.status && validRedirectStatuses.has(response.status)) return response.status;
|
|
2653
|
+
return 302;
|
|
2654
|
+
}
|
|
2655
|
+
function mergeStubHeaders(target, stub) {
|
|
2656
|
+
if (!stub) return target;
|
|
2657
|
+
stub.headers.forEach((value, key) => {
|
|
2658
|
+
if (key !== "set-cookie") target.set(key, value);
|
|
2659
|
+
});
|
|
2660
|
+
const setCookies = stub.headers.getSetCookie ? stub.headers.getSetCookie() : [];
|
|
2661
|
+
for (const cookie of setCookies) target.append("set-cookie", cookie);
|
|
2662
|
+
return target;
|
|
2663
|
+
}
|
|
2664
|
+
function copyInitHeaders(init) {
|
|
2665
|
+
if (!init || !init.getSetCookie) return new Headers(init);
|
|
2666
|
+
const headers = new Headers();
|
|
2667
|
+
init.forEach((value, key) => {
|
|
2668
|
+
if (key !== "set-cookie") headers.append(key, value);
|
|
2669
|
+
});
|
|
2670
|
+
for (const cookie of init.getSetCookie()) headers.append("Set-Cookie", cookie);
|
|
2671
|
+
return headers;
|
|
2672
|
+
}
|
|
2673
|
+
const STUB_GAP_FILL_EXCLUDED = /*#__PURE__*/new Set([ERROR_HEADER, BODY_FORMAT_HEADER, SINGLE_FLIGHT_HEADER, REVALIDATE_HEADER, "Location"].map(header => header.toLowerCase()));
|
|
2674
|
+
function fillsStubGap(key, headers, response) {
|
|
2675
|
+
if (key === "set-cookie" || STUB_GAP_FILL_EXCLUDED.has(key)) return false;
|
|
2676
|
+
if (response.body === null && (key === "content-type" || key === "content-length")) return false;
|
|
2677
|
+
return !headers.has(key);
|
|
2678
|
+
}
|
|
2679
|
+
function commitEventResponse(response, event = getRequestEvent()) {
|
|
2680
|
+
const stub = event && event.response;
|
|
2681
|
+
if (!stub || !stub.headers || stub.committed) return response;
|
|
2682
|
+
const cookies = stub.headers.getSetCookie ? stub.headers.getSetCookie() : [];
|
|
2683
|
+
commitResponseStub(stub);
|
|
2684
|
+
let hasGaps = false;
|
|
2685
|
+
stub.headers.forEach((value, key) => {
|
|
2686
|
+
if (fillsStubGap(key, response.headers, response)) hasGaps = true;
|
|
2687
|
+
});
|
|
2688
|
+
if (!cookies.length && !hasGaps) return response;
|
|
2689
|
+
try {
|
|
2690
|
+
for (const cookie of cookies) response.headers.append("Set-Cookie", cookie);
|
|
2691
|
+
stub.headers.forEach((value, key) => {
|
|
2692
|
+
if (fillsStubGap(key, response.headers, response)) response.headers.set(key, value);
|
|
2693
|
+
});
|
|
2694
|
+
return response;
|
|
2695
|
+
} catch {
|
|
2696
|
+
const headers = copyInitHeaders(response.headers);
|
|
2697
|
+
for (const cookie of cookies) headers.append("Set-Cookie", cookie);
|
|
2698
|
+
stub.headers.forEach((value, key) => {
|
|
2699
|
+
if (fillsStubGap(key, headers, response)) headers.set(key, value);
|
|
2700
|
+
});
|
|
2701
|
+
return new Response(response.body, {
|
|
2702
|
+
status: response.status,
|
|
2703
|
+
statusText: response.statusText,
|
|
2704
|
+
headers
|
|
2705
|
+
});
|
|
2706
|
+
}
|
|
2707
|
+
}
|
|
2708
|
+
function deriveHead(stub, responseInit = {}) {
|
|
2709
|
+
const headers = mergeStubHeaders(copyInitHeaders(responseInit.headers), stub);
|
|
2710
|
+
const status = stub && stub.status || responseInit.status || 200;
|
|
2711
|
+
const statusText = stub && stub.statusText || responseInit.statusText || undefined;
|
|
2712
|
+
return {
|
|
2713
|
+
status,
|
|
2714
|
+
statusText,
|
|
2715
|
+
headers
|
|
2716
|
+
};
|
|
2717
|
+
}
|
|
2718
|
+
function escapeAttribute(value) {
|
|
2719
|
+
return value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<");
|
|
2720
|
+
}
|
|
2721
|
+
function createSSRResponse(result, event, options = {}) {
|
|
2722
|
+
const stub = event && event.response;
|
|
2723
|
+
const {
|
|
2724
|
+
responseInit,
|
|
2725
|
+
nonce,
|
|
2726
|
+
transformChunk
|
|
2727
|
+
} = options;
|
|
2728
|
+
if (typeof result === "string") {
|
|
2729
|
+
if (stub) commitResponseStub(stub);
|
|
2730
|
+
const head = deriveHead(stub, responseInit);
|
|
2731
|
+
if (stub && stub.headers.get("Location")) {
|
|
2732
|
+
return new Response(null, {
|
|
2733
|
+
status: getExpectedRedirectStatus(stub),
|
|
2734
|
+
headers: head.headers
|
|
2735
|
+
});
|
|
2736
|
+
}
|
|
2737
|
+
if (!head.headers.has("content-type")) {
|
|
2738
|
+
head.headers.set("content-type", "text/html; charset=utf-8");
|
|
2739
|
+
}
|
|
2740
|
+
return new Response(transformChunk ? transformChunk(result) : result, {
|
|
2741
|
+
status: head.status,
|
|
2742
|
+
statusText: head.statusText,
|
|
2743
|
+
headers: head.headers
|
|
2744
|
+
});
|
|
2745
|
+
}
|
|
2746
|
+
const encoder = new TextEncoder();
|
|
2747
|
+
return new Promise(resolve => {
|
|
2748
|
+
let controller;
|
|
2749
|
+
let closed = false;
|
|
2750
|
+
let flushed = false;
|
|
2751
|
+
const enqueue = value => {
|
|
2752
|
+
if (closed || !controller) return;
|
|
2753
|
+
try {
|
|
2754
|
+
controller.enqueue(encoder.encode(value));
|
|
2755
|
+
} catch {
|
|
2756
|
+
closed = true;
|
|
2757
|
+
}
|
|
2758
|
+
};
|
|
2759
|
+
result.pipe({
|
|
2760
|
+
write(chunk) {
|
|
2761
|
+
if (!flushed) {
|
|
2762
|
+
flushed = true;
|
|
2763
|
+
if (stub) commitResponseStub(stub, {
|
|
2764
|
+
allowLateLocation: true
|
|
2765
|
+
});
|
|
2766
|
+
const head = deriveHead(stub, responseInit);
|
|
2767
|
+
if (stub && stub.headers.get("Location")) {
|
|
2768
|
+
closed = true;
|
|
2769
|
+
resolve(new Response(null, {
|
|
2770
|
+
status: getExpectedRedirectStatus(stub),
|
|
2771
|
+
headers: head.headers
|
|
2772
|
+
}));
|
|
2773
|
+
return;
|
|
2774
|
+
}
|
|
2775
|
+
if (!head.headers.has("content-type")) {
|
|
2776
|
+
head.headers.set("content-type", "text/html; charset=utf-8");
|
|
2777
|
+
}
|
|
2778
|
+
resolve(new Response(new ReadableStream({
|
|
2779
|
+
start(c) {
|
|
2780
|
+
controller = c;
|
|
2781
|
+
},
|
|
2782
|
+
cancel() {
|
|
2783
|
+
closed = true;
|
|
2784
|
+
}
|
|
2785
|
+
}), {
|
|
2786
|
+
status: head.status,
|
|
2787
|
+
statusText: head.statusText,
|
|
2788
|
+
headers: head.headers
|
|
2789
|
+
}));
|
|
2790
|
+
}
|
|
2791
|
+
enqueue(transformChunk ? transformChunk(chunk) : chunk);
|
|
2792
|
+
},
|
|
2793
|
+
end() {
|
|
2794
|
+
if (closed || !controller) return;
|
|
2795
|
+
const location = stub && stub.headers.get("Location");
|
|
2796
|
+
if (location) {
|
|
2797
|
+
const attr = nonce ? ` nonce="${escapeAttribute(nonce)}"` : "";
|
|
2798
|
+
enqueue(`<script${attr}>window.location=${JSON.stringify(location).replace(/</g, "\\u003c")}</script>`);
|
|
2799
|
+
}
|
|
2800
|
+
closed = true;
|
|
2801
|
+
try {
|
|
2802
|
+
controller.close();
|
|
2803
|
+
} catch {}
|
|
2804
|
+
}
|
|
2805
|
+
});
|
|
2806
|
+
});
|
|
2807
|
+
}
|
|
2808
|
+
function composeMiddleware(middlewares) {
|
|
2809
|
+
return function run(request, next) {
|
|
2810
|
+
let index = -1;
|
|
2811
|
+
function dispatch(i, req) {
|
|
2812
|
+
if (i <= index) return Promise.reject(new Error("next() called multiple times"));
|
|
2813
|
+
index = i;
|
|
2814
|
+
if (i === middlewares.length) return Promise.resolve(next(req));
|
|
2815
|
+
return Promise.resolve(middlewares[i](req, override => dispatch(i + 1, override || req)));
|
|
2816
|
+
}
|
|
2817
|
+
return dispatch(0, request);
|
|
2818
|
+
};
|
|
2819
|
+
}
|
|
2820
|
+
function registerElementClaim() {
|
|
2821
|
+
return noopCleanup;
|
|
626
2822
|
}
|
|
627
|
-
function
|
|
628
|
-
|
|
2823
|
+
function noopCleanup() {}
|
|
2824
|
+
function claimElement(node) {
|
|
2825
|
+
return node;
|
|
2826
|
+
}
|
|
2827
|
+
function claimElementTree(root) {
|
|
2828
|
+
return root;
|
|
629
2829
|
}
|
|
630
2830
|
function notSup() {
|
|
631
2831
|
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
2832
|
}
|
|
633
2833
|
|
|
2834
|
+
setContainerTraceResolver(solidJs.getProjectionTrace);
|
|
634
2835
|
const isServer = true;
|
|
635
2836
|
const isDev = false;
|
|
636
|
-
function
|
|
637
|
-
const
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
2837
|
+
function dynamic(source) {
|
|
2838
|
+
const cached = solidJs.createMemo(source, {
|
|
2839
|
+
serialize: false
|
|
2840
|
+
});
|
|
2841
|
+
return props => {
|
|
2842
|
+
return solidJs.createMemo(() => {
|
|
2843
|
+
const c = cached();
|
|
2844
|
+
if (c) {
|
|
2845
|
+
if (typeof c === "function") return c(props);
|
|
2846
|
+
if (typeof c === "string") {
|
|
2847
|
+
return ssrElement(c, props, undefined, true);
|
|
2848
|
+
}
|
|
2849
|
+
}
|
|
2850
|
+
}, {
|
|
2851
|
+
sync: true
|
|
2852
|
+
});
|
|
2853
|
+
};
|
|
644
2854
|
}
|
|
645
2855
|
function Dynamic(props) {
|
|
646
|
-
const
|
|
647
|
-
return
|
|
2856
|
+
const Comp = dynamic(() => props.component);
|
|
2857
|
+
return solidJs.createComponent(Comp, solidJs.omit(props, "component"));
|
|
648
2858
|
}
|
|
649
2859
|
function Portal(props) {
|
|
650
|
-
|
|
2860
|
+
const o = solidJs.getOwner();
|
|
2861
|
+
if (o?.id != null) solidJs.getNextChildId(o);
|
|
2862
|
+
return undefined;
|
|
2863
|
+
}
|
|
2864
|
+
function registerClientOnlyPreload(moduleUrl) {
|
|
2865
|
+
const ctx = solidJs.sharedConfig.context;
|
|
2866
|
+
if (!ctx?.registerAsset || !ctx.resolveAssets) return;
|
|
2867
|
+
const registerAsset = ctx.registerAsset;
|
|
2868
|
+
const resolve = ctx.resolveAssets;
|
|
2869
|
+
const apply = assets => {
|
|
2870
|
+
if (!assets) return;
|
|
2871
|
+
for (let i = 0; i < assets.css.length; i++) {
|
|
2872
|
+
const css = assets.css[i];
|
|
2873
|
+
if (typeof css === "string") registerAsset("style", css);else registerAsset("inline-style", css);
|
|
2874
|
+
}
|
|
2875
|
+
for (let i = 0; i < assets.js.length; i++) registerAsset("module", assets.js[i]);
|
|
2876
|
+
};
|
|
2877
|
+
const assets = resolve(moduleUrl);
|
|
2878
|
+
if (assets && typeof assets.then === "function") {
|
|
2879
|
+
const boundary = ctx._currentBoundaryId;
|
|
2880
|
+
assets.then(resolved => {
|
|
2881
|
+
const current = ctx._currentBoundaryId;
|
|
2882
|
+
ctx._currentBoundaryId = boundary;
|
|
2883
|
+
try {
|
|
2884
|
+
apply(resolved);
|
|
2885
|
+
} finally {
|
|
2886
|
+
ctx._currentBoundaryId = current;
|
|
2887
|
+
}
|
|
2888
|
+
},
|
|
2889
|
+
() => {});
|
|
2890
|
+
} else {
|
|
2891
|
+
apply(assets);
|
|
2892
|
+
}
|
|
2893
|
+
}
|
|
2894
|
+
function clientOnly(_fn, _options = {}, moduleUrl) {
|
|
2895
|
+
return props => {
|
|
2896
|
+
if (moduleUrl) registerClientOnlyPreload(moduleUrl);
|
|
2897
|
+
return solidJs.createMemo(() => props.fallback);
|
|
2898
|
+
};
|
|
2899
|
+
}
|
|
2900
|
+
const statusLedgers = /* @__PURE__ */new WeakMap();
|
|
2901
|
+
const headerLedgers = /* @__PURE__ */new WeakMap();
|
|
2902
|
+
function httpStatus(code, text) {
|
|
2903
|
+
const event = getRequestEvent();
|
|
2904
|
+
const response = event && event.response;
|
|
2905
|
+
if (response && !response.committed) {
|
|
2906
|
+
let ledger = statusLedgers.get(response);
|
|
2907
|
+
if (!ledger) {
|
|
2908
|
+
ledger = {
|
|
2909
|
+
base: {
|
|
2910
|
+
status: response.status,
|
|
2911
|
+
statusText: response.statusText
|
|
2912
|
+
},
|
|
2913
|
+
live: []
|
|
2914
|
+
};
|
|
2915
|
+
statusLedgers.set(response, ledger);
|
|
2916
|
+
}
|
|
2917
|
+
const declaration = {
|
|
2918
|
+
status: code,
|
|
2919
|
+
statusText: text
|
|
2920
|
+
};
|
|
2921
|
+
ledger.live.push(declaration);
|
|
2922
|
+
response.status = code;
|
|
2923
|
+
response.statusText = text;
|
|
2924
|
+
solidJs.onCleanup(() => {
|
|
2925
|
+
if (response.committed) return;
|
|
2926
|
+
const index = ledger.live.indexOf(declaration);
|
|
2927
|
+
if (index < 0) return;
|
|
2928
|
+
ledger.live.splice(index, 1);
|
|
2929
|
+
const effective = ledger.live.length ? ledger.live[ledger.live.length - 1] : ledger.base;
|
|
2930
|
+
response.status = effective.status;
|
|
2931
|
+
response.statusText = effective.statusText;
|
|
2932
|
+
if (!ledger.live.length) statusLedgers.delete(response);
|
|
2933
|
+
});
|
|
2934
|
+
}
|
|
2935
|
+
}
|
|
2936
|
+
function httpHeader(name, value, options) {
|
|
2937
|
+
const event = getRequestEvent();
|
|
2938
|
+
const response = event && event.response;
|
|
2939
|
+
if (response && !response.committed) {
|
|
2940
|
+
const headers = response.headers;
|
|
2941
|
+
const key = name.toLowerCase();
|
|
2942
|
+
const setCookie = key === "set-cookie";
|
|
2943
|
+
let ledgers = headerLedgers.get(response);
|
|
2944
|
+
if (!ledgers) headerLedgers.set(response, ledgers = new Map());
|
|
2945
|
+
let ledger = ledgers.get(key);
|
|
2946
|
+
if (!ledger) {
|
|
2947
|
+
ledger = {
|
|
2948
|
+
base: setCookie ? headers.getSetCookie() : headers.get(name),
|
|
2949
|
+
live: []
|
|
2950
|
+
};
|
|
2951
|
+
ledgers.set(key, ledger);
|
|
2952
|
+
}
|
|
2953
|
+
const declaration = {
|
|
2954
|
+
value,
|
|
2955
|
+
append: !!(options && options.append)
|
|
2956
|
+
};
|
|
2957
|
+
ledger.live.push(declaration);
|
|
2958
|
+
if (declaration.append) headers.append(name, value);else headers.set(name, value);
|
|
2959
|
+
solidJs.onCleanup(() => {
|
|
2960
|
+
if (response.committed) return;
|
|
2961
|
+
const index = ledger.live.indexOf(declaration);
|
|
2962
|
+
if (index < 0) return;
|
|
2963
|
+
ledger.live.splice(index, 1);
|
|
2964
|
+
headers.delete(name);
|
|
2965
|
+
if (setCookie) {
|
|
2966
|
+
for (const cookie of ledger.base) headers.append(name, cookie);
|
|
2967
|
+
} else if (ledger.base !== null) {
|
|
2968
|
+
headers.set(name, ledger.base);
|
|
2969
|
+
}
|
|
2970
|
+
for (const d of ledger.live) {
|
|
2971
|
+
if (d.append) headers.append(name, d.value);else headers.set(name, d.value);
|
|
2972
|
+
}
|
|
2973
|
+
if (!ledger.live.length) ledgers.delete(key);
|
|
2974
|
+
});
|
|
2975
|
+
}
|
|
651
2976
|
}
|
|
652
2977
|
|
|
653
|
-
Object.defineProperty(exports, "
|
|
2978
|
+
Object.defineProperty(exports, "Errored", {
|
|
654
2979
|
enumerable: true,
|
|
655
|
-
get: function () { return solidJs.
|
|
2980
|
+
get: function () { return solidJs.Errored; }
|
|
656
2981
|
});
|
|
657
2982
|
Object.defineProperty(exports, "For", {
|
|
658
2983
|
enumerable: true,
|
|
659
2984
|
get: function () { return solidJs.For; }
|
|
660
2985
|
});
|
|
2986
|
+
Object.defineProperty(exports, "Hydration", {
|
|
2987
|
+
enumerable: true,
|
|
2988
|
+
get: function () { return solidJs.Hydration; }
|
|
2989
|
+
});
|
|
2990
|
+
Object.defineProperty(exports, "Loading", {
|
|
2991
|
+
enumerable: true,
|
|
2992
|
+
get: function () { return solidJs.Loading; }
|
|
2993
|
+
});
|
|
661
2994
|
Object.defineProperty(exports, "Match", {
|
|
662
2995
|
enumerable: true,
|
|
663
2996
|
get: function () { return solidJs.Match; }
|
|
664
2997
|
});
|
|
2998
|
+
Object.defineProperty(exports, "NoHydration", {
|
|
2999
|
+
enumerable: true,
|
|
3000
|
+
get: function () { return solidJs.NoHydration; }
|
|
3001
|
+
});
|
|
665
3002
|
Object.defineProperty(exports, "Repeat", {
|
|
666
3003
|
enumerable: true,
|
|
667
3004
|
get: function () { return solidJs.Repeat; }
|
|
668
3005
|
});
|
|
669
|
-
Object.defineProperty(exports, "
|
|
3006
|
+
Object.defineProperty(exports, "Reveal", {
|
|
670
3007
|
enumerable: true,
|
|
671
|
-
get: function () { return solidJs.
|
|
3008
|
+
get: function () { return solidJs.Reveal; }
|
|
672
3009
|
});
|
|
673
|
-
Object.defineProperty(exports, "
|
|
3010
|
+
Object.defineProperty(exports, "Show", {
|
|
674
3011
|
enumerable: true,
|
|
675
|
-
get: function () { return solidJs.
|
|
3012
|
+
get: function () { return solidJs.Show; }
|
|
676
3013
|
});
|
|
677
3014
|
Object.defineProperty(exports, "Switch", {
|
|
678
3015
|
enumerable: true,
|
|
@@ -682,17 +3019,17 @@ Object.defineProperty(exports, "createComponent", {
|
|
|
682
3019
|
enumerable: true,
|
|
683
3020
|
get: function () { return solidJs.createComponent; }
|
|
684
3021
|
});
|
|
685
|
-
Object.defineProperty(exports, "effect", {
|
|
686
|
-
enumerable: true,
|
|
687
|
-
get: function () { return solidJs.createRenderEffect; }
|
|
688
|
-
});
|
|
689
3022
|
Object.defineProperty(exports, "getOwner", {
|
|
690
3023
|
enumerable: true,
|
|
691
3024
|
get: function () { return solidJs.getOwner; }
|
|
692
3025
|
});
|
|
693
|
-
Object.defineProperty(exports, "
|
|
3026
|
+
Object.defineProperty(exports, "mergeProps", {
|
|
3027
|
+
enumerable: true,
|
|
3028
|
+
get: function () { return solidJs.merge; }
|
|
3029
|
+
});
|
|
3030
|
+
Object.defineProperty(exports, "scope", {
|
|
694
3031
|
enumerable: true,
|
|
695
|
-
get: function () { return solidJs.
|
|
3032
|
+
get: function () { return solidJs.ssrScope; }
|
|
696
3033
|
});
|
|
697
3034
|
Object.defineProperty(exports, "untrack", {
|
|
698
3035
|
enumerable: true,
|
|
@@ -700,52 +3037,93 @@ Object.defineProperty(exports, "untrack", {
|
|
|
700
3037
|
});
|
|
701
3038
|
exports.ChildProperties = ChildProperties;
|
|
702
3039
|
exports.DOMElements = DOMElements;
|
|
3040
|
+
exports.DOMWithState = DOMWithState;
|
|
703
3041
|
exports.DelegatedEvents = DelegatedEvents;
|
|
704
3042
|
exports.Dynamic = Dynamic;
|
|
705
|
-
exports.
|
|
3043
|
+
exports.HREF = HREF;
|
|
706
3044
|
exports.HydrationScript = HydrationScript;
|
|
707
|
-
exports.
|
|
3045
|
+
exports.MathMLElements = MathMLElements;
|
|
3046
|
+
exports.Namespaces = Namespaces;
|
|
708
3047
|
exports.Portal = Portal;
|
|
709
|
-
exports.
|
|
3048
|
+
exports.REVALIDATE_HEADER = REVALIDATE_HEADER;
|
|
3049
|
+
exports.RawTextElements = RawTextElements;
|
|
710
3050
|
exports.RequestContext = RequestContext;
|
|
3051
|
+
exports.ResponseEnvelope = ResponseEnvelope;
|
|
3052
|
+
exports.SAFE_ERROR = SAFE_ERROR;
|
|
711
3053
|
exports.SVGElements = SVGElements;
|
|
712
|
-
exports.
|
|
713
|
-
exports.
|
|
3054
|
+
exports.VoidElements = VoidElements;
|
|
3055
|
+
exports.acquireAsset = notSup;
|
|
3056
|
+
exports.addEvent = notSup;
|
|
3057
|
+
exports.applyRef = applyRef;
|
|
714
3058
|
exports.assign = notSup;
|
|
3059
|
+
exports.claimElement = claimElement;
|
|
3060
|
+
exports.claimElementTree = claimElementTree;
|
|
715
3061
|
exports.className = notSup;
|
|
716
|
-
exports.
|
|
3062
|
+
exports.clearFlashCookie = clearFlashCookie;
|
|
3063
|
+
exports.clientOnly = clientOnly;
|
|
3064
|
+
exports.commitEventResponse = commitEventResponse;
|
|
3065
|
+
exports.commitResponseStub = commitResponseStub;
|
|
3066
|
+
exports.composeMiddleware = composeMiddleware;
|
|
3067
|
+
exports.createLiveHoles = createLiveHoles;
|
|
3068
|
+
exports.createRequestEvent = createRequestEvent;
|
|
3069
|
+
exports.createResponseStub = createResponseStub;
|
|
3070
|
+
exports.createSSRResponse = createSSRResponse;
|
|
717
3071
|
exports.delegateEvents = notSup;
|
|
3072
|
+
exports.dynamic = dynamic;
|
|
718
3073
|
exports.dynamicProperty = notSup;
|
|
3074
|
+
exports.effect = effect;
|
|
719
3075
|
exports.escape = escape;
|
|
720
3076
|
exports.generateHydrationScript = generateHydrationScript;
|
|
721
|
-
exports.
|
|
3077
|
+
exports.getDelegatedRoot = notSup;
|
|
3078
|
+
exports.getExpectedRedirectStatus = getExpectedRedirectStatus;
|
|
722
3079
|
exports.getHydrationKey = getHydrationKey;
|
|
723
3080
|
exports.getNextElement = notSup;
|
|
724
3081
|
exports.getNextMarker = notSup;
|
|
725
3082
|
exports.getNextMatch = notSup;
|
|
726
3083
|
exports.getRequestEvent = getRequestEvent;
|
|
3084
|
+
exports.getServerFunctionMetadata = getServerFunctionMetadata;
|
|
3085
|
+
exports.getServerFunctionRPC = getServerFunctionRPC;
|
|
3086
|
+
exports.hasFlashCookie = hasFlashCookie;
|
|
3087
|
+
exports.httpHeader = httpHeader;
|
|
3088
|
+
exports.httpStatus = httpStatus;
|
|
727
3089
|
exports.hydrate = notSup;
|
|
728
3090
|
exports.insert = notSup;
|
|
729
3091
|
exports.isDev = isDev;
|
|
3092
|
+
exports.isHref = isHref;
|
|
3093
|
+
exports.isResponseEnvelope = isResponseEnvelope;
|
|
3094
|
+
exports.isSafeError = isSafeError;
|
|
730
3095
|
exports.isServer = isServer;
|
|
3096
|
+
exports.isServerFunction = isServerFunction;
|
|
3097
|
+
exports.markSafeError = markSafeError;
|
|
731
3098
|
exports.memo = memo;
|
|
732
|
-
exports.
|
|
3099
|
+
exports.parseCookieHeader = parseCookieHeader;
|
|
3100
|
+
exports.redirect = redirect;
|
|
3101
|
+
exports.ref = notSup;
|
|
3102
|
+
exports.registerDelegatedContainer = notSup;
|
|
3103
|
+
exports.registerDelegatedRoot = notSup;
|
|
3104
|
+
exports.registerElementClaim = registerElementClaim;
|
|
3105
|
+
exports.reload = reload;
|
|
733
3106
|
exports.render = notSup;
|
|
734
3107
|
exports.renderToStream = renderToStream;
|
|
735
3108
|
exports.renderToString = renderToString;
|
|
736
|
-
exports.
|
|
3109
|
+
exports.respond = respond;
|
|
737
3110
|
exports.runHydrationEvents = notSup;
|
|
3111
|
+
exports.serializeCookie = serializeCookie;
|
|
738
3112
|
exports.setAttribute = notSup;
|
|
739
3113
|
exports.setAttributeNS = notSup;
|
|
740
3114
|
exports.setProperty = notSup;
|
|
3115
|
+
exports.setStyleProperty = notSup;
|
|
741
3116
|
exports.spread = notSup;
|
|
742
3117
|
exports.ssr = ssr;
|
|
743
3118
|
exports.ssrAttribute = ssrAttribute;
|
|
744
3119
|
exports.ssrClassName = ssrClassName;
|
|
745
3120
|
exports.ssrElement = ssrElement;
|
|
3121
|
+
exports.ssrGroup = ssrGroup;
|
|
746
3122
|
exports.ssrHydrationKey = ssrHydrationKey;
|
|
747
3123
|
exports.ssrStyle = ssrStyle;
|
|
748
3124
|
exports.ssrStyleProperty = ssrStyleProperty;
|
|
749
3125
|
exports.style = notSup;
|
|
750
3126
|
exports.template = notSup;
|
|
751
|
-
exports.
|
|
3127
|
+
exports.unregisterDelegatedContainer = notSup;
|
|
3128
|
+
exports.unregisterDelegatedRoot = notSup;
|
|
3129
|
+
exports.useHead = useHead;
|