@solidjs/web 2.0.0-beta.3 → 2.0.0-beta.30
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 +27 -4
- package/dist/dev.cjs +1211 -205
- package/dist/dev.js +1175 -199
- package/dist/server.cjs +1342 -234
- package/dist/server.js +1304 -231
- package/dist/web.cjs +1195 -196
- package/dist/web.js +1159 -190
- package/frames/dist/client.cjs +1746 -0
- package/frames/dist/client.dev.cjs +1759 -0
- package/frames/dist/client.dev.js +1747 -0
- package/frames/dist/client.js +1734 -0
- package/frames/dist/server.cjs +2426 -0
- package/frames/dist/server.js +2414 -0
- package/frames/package.json +30 -0
- package/package.json +287 -38
- package/serialization/dist/serialization.cjs +169 -0
- package/serialization/dist/serialization.js +159 -0
- package/serialization/package.json +20 -0
- package/serialization/types/index.d.ts +157 -0
- package/serialization/types-cjs/index.d.cts +157 -0
- package/serialization/types-cjs/package.json +3 -0
- package/server-functions/dist/client.cjs +613 -0
- package/server-functions/dist/client.js +585 -0
- package/server-functions/dist/server.cjs +904 -0
- package/server-functions/dist/server.js +875 -0
- package/server-functions/package.json +30 -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 +125 -21
- package/types/core.d.ts +4 -3
- package/types/frames/client.d.ts +20 -0
- package/types/frames/frame-client.d.ts +270 -0
- package/types/frames/frame-sink.d.ts +168 -0
- package/types/frames/frame-transport.d.ts +196 -0
- package/types/frames/serializer.d.ts +157 -0
- package/types/frames/server.d.ts +30 -0
- package/types/index.d.ts +211 -26
- package/types/jsx-properties.d.ts +93 -0
- package/types/jsx.d.ts +4150 -1
- package/types/response.d.ts +129 -0
- package/types/serializer.d.ts +157 -0
- package/types/server-functions/client.d.ts +200 -0
- package/types/server-functions/flash.d.ts +38 -0
- package/types/server-functions/server.d.ts +490 -0
- package/types/server-functions/shared.d.ts +445 -0
- package/types/server-mock.d.ts +93 -0
- package/types/server.d.ts +221 -28
- package/types-cjs/client.d.cts +192 -0
- package/types-cjs/core.d.cts +4 -0
- package/types-cjs/frames/client.d.cts +20 -0
- package/types-cjs/frames/frame-client.d.cts +270 -0
- package/types-cjs/frames/frame-sink.d.cts +168 -0
- package/types-cjs/frames/frame-transport.d.cts +196 -0
- package/types-cjs/frames/serializer.d.cts +157 -0
- package/types-cjs/frames/server.d.cts +30 -0
- package/types-cjs/index.d.cts +231 -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 +129 -0
- package/types-cjs/serializer.d.cts +157 -0
- package/types-cjs/server-functions/client.d.cts +200 -0
- package/types-cjs/server-functions/flash.d.cts +38 -0
- package/types-cjs/server-functions/server.d.cts +490 -0
- package/types-cjs/server-functions/shared.d.cts +445 -0
- package/types-cjs/server-mock.d.cts +165 -0
- package/types-cjs/server.d.cts +349 -0
- package/storage/types/src/client.d.ts +0 -1
- package/storage/types/src/index.d.ts +0 -46
- package/storage/types/src/server-mock.d.ts +0 -72
- package/storage/types/storage/src/index.d.ts +0 -2
package/dist/server.cjs
CHANGED
|
@@ -3,10 +3,35 @@
|
|
|
3
3
|
var solidJs = require('solid-js');
|
|
4
4
|
var seroval = require('seroval');
|
|
5
5
|
var web = require('seroval-plugins/web');
|
|
6
|
-
var signals = require('@solidjs/signals');
|
|
7
6
|
|
|
8
|
-
const
|
|
9
|
-
|
|
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
|
+
};
|
|
10
35
|
const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
|
|
11
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"]);
|
|
12
37
|
const SVGElements = /*#__PURE__*/new Set([
|
|
@@ -14,52 +39,161 @@ const SVGElements = /*#__PURE__*/new Set([
|
|
|
14
39
|
"set", "stop",
|
|
15
40
|
"svg", "switch", "symbol", "text", "textPath",
|
|
16
41
|
"tref", "tspan", "use", "view", "vkern"]);
|
|
17
|
-
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",
|
|
18
46
|
xlink: "http://www.w3.org/1999/xlink",
|
|
19
47
|
xml: "http://www.w3.org/XML/1998/namespace"
|
|
20
48
|
};
|
|
21
|
-
const
|
|
22
|
-
"
|
|
23
|
-
"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(","));
|
|
24
52
|
|
|
25
|
-
const
|
|
26
|
-
transparent: true
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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);
|
|
31
66
|
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
67
|
+
const DEFAULT_DISABLED_FEATURES = seroval.Feature.AggregateError | seroval.Feature.BigIntTypedArray;
|
|
68
|
+
const serializeOnlyDisabledFeatures = () => process.env.NODE_ENV === "development" ? 0 : seroval.Feature.ErrorPrototypeStack;
|
|
69
|
+
const HYDRATION_GLOBAL = "_$HY.r";
|
|
70
|
+
const DEFAULT_WEB_PLUGINS = Object.freeze([web.AbortSignalPlugin,
|
|
71
|
+
web.CustomEventPlugin, web.DOMExceptionPlugin, web.EventPlugin,
|
|
72
|
+
web.FormDataPlugin, web.HeadersPlugin, web.ReadableStreamPlugin, web.RequestPlugin, web.ResponsePlugin, web.URLSearchParamsPlugin, web.URLPlugin]);
|
|
73
|
+
function resolveSerializerPlugins(customPlugins) {
|
|
74
|
+
return customPlugins ? [...customPlugins, ...DEFAULT_WEB_PLUGINS] : [...DEFAULT_WEB_PLUGINS];
|
|
75
|
+
}
|
|
76
|
+
function createSerializer(options) {
|
|
77
|
+
return new seroval.Serializer({
|
|
78
|
+
...options,
|
|
79
|
+
plugins: resolveSerializerPlugins(options.plugins),
|
|
80
|
+
disabledFeatures: (options.disabledFeatures === undefined ? DEFAULT_DISABLED_FEATURES : options.disabledFeatures) | serializeOnlyDisabledFeatures()
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
function createHydrationSerializer({
|
|
36
84
|
onData,
|
|
37
85
|
onDone,
|
|
38
86
|
scopeId,
|
|
39
87
|
onError,
|
|
40
|
-
plugins
|
|
88
|
+
plugins
|
|
41
89
|
}) {
|
|
42
|
-
|
|
43
|
-
web.CustomEventPlugin, web.DOMExceptionPlugin, web.EventPlugin,
|
|
44
|
-
web.FormDataPlugin, web.HeadersPlugin, web.ReadableStreamPlugin, web.RequestPlugin, web.ResponsePlugin, web.URLSearchParamsPlugin, web.URLPlugin];
|
|
45
|
-
const allPlugins = customPlugins ? [...customPlugins, ...defaultPlugins] : defaultPlugins;
|
|
46
|
-
return new seroval.Serializer({
|
|
90
|
+
return createSerializer({
|
|
47
91
|
scopeId,
|
|
48
|
-
plugins
|
|
49
|
-
globalIdentifier:
|
|
50
|
-
disabledFeatures: ES2017FLAG,
|
|
92
|
+
plugins,
|
|
93
|
+
globalIdentifier: HYDRATION_GLOBAL,
|
|
51
94
|
onData,
|
|
52
95
|
onDone,
|
|
53
96
|
onError
|
|
54
97
|
});
|
|
55
98
|
}
|
|
56
99
|
function getLocalHeaderScript(id) {
|
|
57
|
-
return seroval.getCrossReferenceHeader(id) +
|
|
100
|
+
return seroval.getCrossReferenceHeader(id) + ";";
|
|
101
|
+
}
|
|
102
|
+
seroval.Feature.RegExp;
|
|
103
|
+
|
|
104
|
+
const HEAD_ELIGIBLE_TAGS = new Set(["title", "meta", "link", "style", "script", "base"]);
|
|
105
|
+
const HEAD_ATTR_NAME = /^[a-zA-Z_][a-zA-Z0-9_:.-]*$/;
|
|
106
|
+
const RESOURCE_LINK_RELS = new Set(["preload", "modulepreload", "prefetch", "preconnect", "dns-prefetch", "icon", "stylesheet"]);
|
|
107
|
+
const RESOURCE_QUALIFIERS = ["as", "crossorigin", "type", "media", "imagesrcset", "imagesizes"];
|
|
108
|
+
const STYLESHEET_FETCH_META = new Set(["crossorigin", "integrity", "referrerpolicy", "fetchpriority"]);
|
|
109
|
+
function evalHeadValue(v) {
|
|
110
|
+
return typeof v === "function" ? v() : v;
|
|
111
|
+
}
|
|
112
|
+
function evalHeadProps(props, presets) {
|
|
113
|
+
const out = {};
|
|
114
|
+
for (const name in props) out[name] = presets && name in presets ? presets[name] : evalHeadValue(props[name]);
|
|
115
|
+
return out;
|
|
116
|
+
}
|
|
117
|
+
function classifyHeadTag(desc) {
|
|
118
|
+
const tag = desc.tag;
|
|
119
|
+
if (tag === "link") {
|
|
120
|
+
const rel = evalHeadValue(desc.props && desc.props.rel);
|
|
121
|
+
return {
|
|
122
|
+
resource: RESOURCE_LINK_RELS.has(rel),
|
|
123
|
+
rel
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
if (tag === "style") return {
|
|
127
|
+
resource: !!(desc.props && "href" in desc.props)
|
|
128
|
+
};
|
|
129
|
+
if (tag === "script") return {
|
|
130
|
+
resource: !!(desc.props && "src" in desc.props)
|
|
131
|
+
};
|
|
132
|
+
return {
|
|
133
|
+
resource: false
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
function resourceIdentity(tag, props) {
|
|
137
|
+
let id = "res:" + tag + ":" + (props.rel || "") + ":" + (props.href || props.src || "");
|
|
138
|
+
for (let i = 0; i < RESOURCE_QUALIFIERS.length; i++) {
|
|
139
|
+
const q = RESOURCE_QUALIFIERS[i];
|
|
140
|
+
if (props[q] != null) id += ":" + q + "=" + props[q];
|
|
141
|
+
}
|
|
142
|
+
return id;
|
|
143
|
+
}
|
|
144
|
+
function replaceableIdentity(tag, props, key, unique) {
|
|
145
|
+
if (tag === "title") return "title";
|
|
146
|
+
if (tag === "base") return "base";
|
|
147
|
+
if (tag === "meta" && props.charset != null) return "charset";
|
|
148
|
+
if (key != null) return tag + ":key:" + key;
|
|
149
|
+
if (tag === "meta") {
|
|
150
|
+
if (props.name != null) return "meta:name:" + props.name;
|
|
151
|
+
if (props.property != null) return "meta:property:" + props.property;
|
|
152
|
+
if (props["http-equiv"] != null) return "meta:http-equiv:" + props["http-equiv"];
|
|
153
|
+
return unique;
|
|
154
|
+
}
|
|
155
|
+
if (tag === "link") return "link:" + (props.rel || "") + ":" + (props.href || "");
|
|
156
|
+
return unique;
|
|
157
|
+
}
|
|
158
|
+
function resolveHead(groups) {
|
|
159
|
+
const winners = new Map();
|
|
160
|
+
const sorted = groups.slice().sort((a, b) => a.seq - b.seq);
|
|
161
|
+
for (let i = 0; i < sorted.length; i++) {
|
|
162
|
+
const group = sorted[i];
|
|
163
|
+
const byIdentity = new Map();
|
|
164
|
+
for (let j = 0; j < group.tags.length; j++) {
|
|
165
|
+
const t = group.tags[j];
|
|
166
|
+
let list = byIdentity.get(t.identity);
|
|
167
|
+
if (!list) byIdentity.set(t.identity, list = []);
|
|
168
|
+
list.push(t);
|
|
169
|
+
}
|
|
170
|
+
for (const [identity, tags] of byIdentity) {
|
|
171
|
+
if (identity === "title") {
|
|
172
|
+
if (tags.length > 1) console.warn("Multiple <title> tags in one head group; the last one wins.");
|
|
173
|
+
winners.set(identity, {
|
|
174
|
+
seq: group.seq,
|
|
175
|
+
tags: [tags[tags.length - 1]]
|
|
176
|
+
});
|
|
177
|
+
} else {
|
|
178
|
+
winners.set(identity, {
|
|
179
|
+
seq: group.seq,
|
|
180
|
+
tags
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return winners;
|
|
58
186
|
}
|
|
59
187
|
|
|
188
|
+
function joinAssetPath(base, file) {
|
|
189
|
+
if (/^(?:[a-z][a-z0-9+.-]*:)?\/\//i.test(file)) return file;
|
|
190
|
+
if (typeof base !== "string" || !base) base = "/";
|
|
191
|
+
if (base[base.length - 1] !== "/") base += "/";
|
|
192
|
+
return base + (file[0] === "/" ? file.slice(1) : file);
|
|
193
|
+
}
|
|
60
194
|
function resolveAssets(moduleUrl, manifest) {
|
|
61
195
|
if (!manifest) return null;
|
|
62
|
-
const base = manifest._base
|
|
196
|
+
const base = manifest._base;
|
|
63
197
|
const entry = manifest[moduleUrl];
|
|
64
198
|
if (!entry) return null;
|
|
65
199
|
const css = [];
|
|
@@ -70,8 +204,8 @@ function resolveAssets(moduleUrl, manifest) {
|
|
|
70
204
|
visited.add(key);
|
|
71
205
|
const e = manifest[key];
|
|
72
206
|
if (!e) return;
|
|
73
|
-
js.push(base
|
|
74
|
-
if (e.css) for (let i = 0; i < e.css.length; i++) css.push(base
|
|
207
|
+
js.push(joinAssetPath(base, e.file));
|
|
208
|
+
if (e.css) for (let i = 0; i < e.css.length; i++) css.push(joinAssetPath(base, e.css[i]));
|
|
75
209
|
if (e.imports) for (let i = 0; i < e.imports.length; i++) walk(e.imports[i]);
|
|
76
210
|
};
|
|
77
211
|
walk(moduleUrl);
|
|
@@ -81,7 +215,7 @@ function resolveAssets(moduleUrl, manifest) {
|
|
|
81
215
|
};
|
|
82
216
|
}
|
|
83
217
|
function registerEntryAssets(manifest) {
|
|
84
|
-
if (!manifest) return;
|
|
218
|
+
if (!manifest || typeof manifest === "function" || typeof manifest.resolve === "function") return;
|
|
85
219
|
const ctx = solidJs.sharedConfig.context;
|
|
86
220
|
if (!ctx?.registerAsset) return;
|
|
87
221
|
for (const key in manifest) {
|
|
@@ -98,25 +232,48 @@ function createAssetTracking() {
|
|
|
98
232
|
const boundaryModules = new Map();
|
|
99
233
|
const boundaryStyles = new Map();
|
|
100
234
|
const emittedAssets = new Set();
|
|
235
|
+
const inlineStyles = new Map();
|
|
101
236
|
let currentBoundaryId = null;
|
|
102
237
|
return {
|
|
103
238
|
boundaryModules,
|
|
104
239
|
boundaryStyles,
|
|
105
240
|
emittedAssets,
|
|
241
|
+
inlineStyles,
|
|
242
|
+
registerInlineStyle(desc) {
|
|
243
|
+
let entry = inlineStyles.get(desc.id);
|
|
244
|
+
if (!entry) {
|
|
245
|
+
entry = {
|
|
246
|
+
id: desc.id,
|
|
247
|
+
content: desc.content || "",
|
|
248
|
+
attrs: desc.attrs,
|
|
249
|
+
emitted: false
|
|
250
|
+
};
|
|
251
|
+
inlineStyles.set(desc.id, entry);
|
|
252
|
+
}
|
|
253
|
+
if (currentBoundaryId) {
|
|
254
|
+
let styles = boundaryStyles.get(currentBoundaryId);
|
|
255
|
+
if (!styles) {
|
|
256
|
+
styles = new Set();
|
|
257
|
+
boundaryStyles.set(currentBoundaryId, styles);
|
|
258
|
+
}
|
|
259
|
+
styles.add(entry);
|
|
260
|
+
}
|
|
261
|
+
return entry;
|
|
262
|
+
},
|
|
106
263
|
get currentBoundaryId() {
|
|
107
264
|
return currentBoundaryId;
|
|
108
265
|
},
|
|
109
266
|
set currentBoundaryId(v) {
|
|
110
267
|
currentBoundaryId = v;
|
|
111
268
|
},
|
|
112
|
-
registerModule(
|
|
113
|
-
|
|
114
|
-
let map = boundaryModules.get(
|
|
269
|
+
registerModule(key, entryUrl) {
|
|
270
|
+
const id = currentBoundaryId || "";
|
|
271
|
+
let map = boundaryModules.get(id);
|
|
115
272
|
if (!map) {
|
|
116
273
|
map = {};
|
|
117
|
-
boundaryModules.set(
|
|
274
|
+
boundaryModules.set(id, map);
|
|
118
275
|
}
|
|
119
|
-
map[
|
|
276
|
+
map[key] = entryUrl;
|
|
120
277
|
},
|
|
121
278
|
getBoundaryModules(id) {
|
|
122
279
|
return boundaryModules.get(id) || null;
|
|
@@ -126,7 +283,24 @@ function createAssetTracking() {
|
|
|
126
283
|
}
|
|
127
284
|
};
|
|
128
285
|
}
|
|
129
|
-
function
|
|
286
|
+
function warnUnresolvedModuleAssets(moduleUrl, warned) {
|
|
287
|
+
if (warned.has(moduleUrl)) return;
|
|
288
|
+
warned.add(moduleUrl);
|
|
289
|
+
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.");
|
|
290
|
+
}
|
|
291
|
+
function guardResolvedAssets(moduleUrl, result, warned) {
|
|
292
|
+
if (result && typeof result.then === "function") {
|
|
293
|
+
return result.then(assets => {
|
|
294
|
+
if (!assets || !assets.js || !assets.js.length) warnUnresolvedModuleAssets(moduleUrl, warned);
|
|
295
|
+
return assets;
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
if (!result || !result.js || !result.js.length) warnUnresolvedModuleAssets(moduleUrl, warned);
|
|
299
|
+
return result;
|
|
300
|
+
}
|
|
301
|
+
function applyAssetTracking(context, tracking, manifest, noScripts) {
|
|
302
|
+
const warned = new Set();
|
|
303
|
+
const guard = noScripts ? resolve => resolve : resolve => moduleUrl => guardResolvedAssets(moduleUrl, resolve(moduleUrl), warned);
|
|
130
304
|
Object.defineProperty(context, "_currentBoundaryId", {
|
|
131
305
|
get() {
|
|
132
306
|
return tracking.currentBoundaryId;
|
|
@@ -139,19 +313,290 @@ function applyAssetTracking(context, tracking, manifest) {
|
|
|
139
313
|
});
|
|
140
314
|
context.registerModule = tracking.registerModule;
|
|
141
315
|
context.getBoundaryModules = tracking.getBoundaryModules;
|
|
142
|
-
if (manifest
|
|
316
|
+
if (typeof manifest === "function") {
|
|
317
|
+
context.resolveAssets = guard(manifest);
|
|
318
|
+
} else if (manifest && typeof manifest.resolve === "function") {
|
|
319
|
+
context.resolveAssets = guard(key => manifest.resolve(key));
|
|
320
|
+
if (typeof manifest.resolveSync === "function") {
|
|
321
|
+
context.resolveAssetsSync = key => manifest.resolveSync(key);
|
|
322
|
+
}
|
|
323
|
+
} else if (manifest) {
|
|
324
|
+
const resolve = moduleUrl => resolveAssets(moduleUrl, manifest);
|
|
325
|
+
context.resolveAssets = guard(resolve);
|
|
326
|
+
context.resolveAssetsSync = resolve;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
function isCssUrl(url) {
|
|
330
|
+
const q = url.search(/[?#]/);
|
|
331
|
+
return (q === -1 ? url : url.slice(0, q)).endsWith(".css");
|
|
332
|
+
}
|
|
333
|
+
function createHeadRegistry() {
|
|
334
|
+
return {
|
|
335
|
+
pending: [],
|
|
336
|
+
committed: [],
|
|
337
|
+
seq: 0,
|
|
338
|
+
uniq: 0,
|
|
339
|
+
resources: new Set(),
|
|
340
|
+
eagerHtml: "",
|
|
341
|
+
flushed: null,
|
|
342
|
+
shellFlushed: false
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
function registerHeadTags(registry, context, tracking, emitResource, nonce, tags) {
|
|
346
|
+
const boundary = context._currentBoundaryId || "";
|
|
347
|
+
let replaceable = null;
|
|
348
|
+
for (let i = 0; i < tags.length; i++) {
|
|
349
|
+
const desc = tags[i];
|
|
350
|
+
if (!desc || !HEAD_ELIGIBLE_TAGS.has(desc.tag)) {
|
|
351
|
+
console.warn(`useHead: ignoring non-head tag`, desc);
|
|
352
|
+
continue;
|
|
353
|
+
}
|
|
354
|
+
const cls = classifyHeadTag(desc);
|
|
355
|
+
if (cls.resource) {
|
|
356
|
+
emitHeadResource(registry, context, tracking, emitResource, nonce, desc, cls.rel);
|
|
357
|
+
} else {
|
|
358
|
+
(replaceable || (replaceable = [])).push(cls.rel !== undefined ? {
|
|
359
|
+
tag: desc.tag,
|
|
360
|
+
props: desc.props,
|
|
361
|
+
key: desc.key,
|
|
362
|
+
rel: cls.rel
|
|
363
|
+
} : desc);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
if (replaceable) registry.pending.push({
|
|
367
|
+
boundary,
|
|
368
|
+
tags: replaceable
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
function emitHeadResource(registry, context, tracking, emitResource, nonce, desc, rel) {
|
|
372
|
+
let props;
|
|
373
|
+
try {
|
|
374
|
+
props = evalHeadProps(desc.props || {}, rel !== undefined ? {
|
|
375
|
+
rel
|
|
376
|
+
} : undefined);
|
|
377
|
+
} catch (err) {
|
|
378
|
+
console.warn(`useHead: error evaluating resource tag props`, err);
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
const identity = resourceIdentity(desc.tag, props);
|
|
382
|
+
if (registry.resources.has(identity)) return;
|
|
383
|
+
registry.resources.add(identity);
|
|
384
|
+
if (desc.tag === "link" && (rel === "stylesheet" || rel === "modulepreload")) {
|
|
385
|
+
let plain = true;
|
|
386
|
+
let gateable = rel === "stylesheet";
|
|
387
|
+
for (const name in props) {
|
|
388
|
+
if (name === "rel" || name === "href") continue;
|
|
389
|
+
plain = false;
|
|
390
|
+
if (!STYLESHEET_FETCH_META.has(name)) gateable = false;
|
|
391
|
+
}
|
|
392
|
+
if (plain && props.href != null) {
|
|
393
|
+
const isCss = isCssUrl(props.href);
|
|
394
|
+
if (rel === "stylesheet" ? isCss : !isCss) {
|
|
395
|
+
context.registerAsset(rel === "stylesheet" ? "style" : "module", props.href);
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
if (gateable && props.href != null) {
|
|
400
|
+
const attrHtml = renderHeadAttrHtml(props);
|
|
401
|
+
const entry = {
|
|
402
|
+
href: props.href,
|
|
403
|
+
attrHtml,
|
|
404
|
+
attrs: headAttrRecord(props)
|
|
405
|
+
};
|
|
406
|
+
if (tracking.currentBoundaryId) {
|
|
407
|
+
let styles = tracking.boundaryStyles.get(tracking.currentBoundaryId);
|
|
408
|
+
if (!styles) tracking.boundaryStyles.set(tracking.currentBoundaryId, styles = new Set());
|
|
409
|
+
styles.add(entry);
|
|
410
|
+
}
|
|
411
|
+
const markup = `<link${attrHtml}>`;
|
|
412
|
+
if (emitResource) emitResource(markup, entry);else {
|
|
413
|
+
registry.eagerHtml += markup;
|
|
414
|
+
entry.emitted = true;
|
|
415
|
+
}
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
const url = props.href || props.src;
|
|
420
|
+
if (url != null && tracking.emittedAssets.has(url)) return;
|
|
421
|
+
const markup = renderHeadTagMarkup(desc.tag, props, null, nonce);
|
|
422
|
+
if (emitResource) emitResource(markup);else registry.eagerHtml += markup;
|
|
423
|
+
}
|
|
424
|
+
function commitHeadBoundary(registry, boundary, isPendingFragment) {
|
|
425
|
+
const keep = [];
|
|
426
|
+
const groups = [];
|
|
427
|
+
for (let i = 0; i < registry.pending.length; i++) {
|
|
428
|
+
const reg = registry.pending[i];
|
|
429
|
+
const mine = boundary === "" ? !(isPendingFragment && reg.boundary !== "" && isPendingFragment(reg.boundary)) : reg.boundary === boundary;
|
|
430
|
+
if (!mine) {
|
|
431
|
+
keep.push(reg);
|
|
432
|
+
continue;
|
|
433
|
+
}
|
|
434
|
+
const tags = [];
|
|
435
|
+
for (let j = 0; j < reg.tags.length; j++) {
|
|
436
|
+
const desc = reg.tags[j];
|
|
437
|
+
let props, key;
|
|
438
|
+
try {
|
|
439
|
+
props = evalHeadProps(desc.props || {}, desc.rel !== undefined ? {
|
|
440
|
+
rel: desc.rel
|
|
441
|
+
} : undefined);
|
|
442
|
+
key = evalHeadValue(desc.key);
|
|
443
|
+
} catch (err) {
|
|
444
|
+
console.warn(`useHead: error evaluating tag props`, err);
|
|
445
|
+
continue;
|
|
446
|
+
}
|
|
447
|
+
const identity = replaceableIdentity(desc.tag, props, key, "u:" + registry.uniq++);
|
|
448
|
+
if ((identity === "base" || identity === "charset") && registry.shellFlushed) {
|
|
449
|
+
console.warn(`useHead: <${desc.tag}> (${identity}) registered after shell flush is ignored`);
|
|
450
|
+
continue;
|
|
451
|
+
}
|
|
452
|
+
tags.push({
|
|
453
|
+
tag: desc.tag,
|
|
454
|
+
props,
|
|
455
|
+
identity
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
if (tags.length) groups.push({
|
|
459
|
+
seq: registry.seq++,
|
|
460
|
+
tags
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
registry.pending = keep;
|
|
464
|
+
for (let i = 0; i < groups.length; i++) registry.committed.push(groups[i]);
|
|
465
|
+
return groups;
|
|
466
|
+
}
|
|
467
|
+
function adoptHeadBoundary(registry, childKey, parentKey) {
|
|
468
|
+
for (let i = 0; i < registry.pending.length; i++) {
|
|
469
|
+
if (registry.pending[i].boundary === childKey) registry.pending[i].boundary = parentKey;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
function dropHeadBoundary(registry, boundary) {
|
|
473
|
+
registry.pending = registry.pending.filter(reg => reg.boundary !== boundary);
|
|
474
|
+
}
|
|
475
|
+
function headGroupSignature(winner) {
|
|
476
|
+
let sig = "" + winner.seq;
|
|
477
|
+
for (let i = 0; i < winner.tags.length; i++) {
|
|
478
|
+
const t = winner.tags[i];
|
|
479
|
+
sig += "|" + t.tag + JSON.stringify(t.props);
|
|
480
|
+
}
|
|
481
|
+
return sig;
|
|
482
|
+
}
|
|
483
|
+
function renderShellHead(registry, nonce, isPendingFragment) {
|
|
484
|
+
commitHeadBoundary(registry, "", isPendingFragment);
|
|
485
|
+
registry.shellFlushed = true;
|
|
486
|
+
const winners = resolveHead(registry.committed);
|
|
487
|
+
registry.flushed = new Map();
|
|
488
|
+
let prelude = "";
|
|
489
|
+
let links = "";
|
|
490
|
+
let metas = "";
|
|
491
|
+
let others = "";
|
|
492
|
+
let scripts = "";
|
|
493
|
+
for (const [identity, winner] of winners) {
|
|
494
|
+
registry.flushed.set(identity, headGroupSignature(winner));
|
|
495
|
+
for (let i = 0; i < winner.tags.length; i++) {
|
|
496
|
+
const t = winner.tags[i];
|
|
497
|
+
const markup = renderHeadTagMarkup(t.tag, t.props, identity, nonce);
|
|
498
|
+
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;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
return {
|
|
502
|
+
prelude,
|
|
503
|
+
html: registry.eagerHtml + links + metas + others + scripts
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
function flushHeadFragment(registry, boundary) {
|
|
507
|
+
const groups = commitHeadBoundary(registry, boundary);
|
|
508
|
+
if (!groups.length) return null;
|
|
509
|
+
const winners = resolveHead(registry.committed);
|
|
510
|
+
const affected = new Set();
|
|
511
|
+
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);
|
|
512
|
+
const ops = [];
|
|
513
|
+
for (const identity of affected) {
|
|
514
|
+
const winner = winners.get(identity);
|
|
515
|
+
const sig = headGroupSignature(winner);
|
|
516
|
+
if (registry.flushed.get(identity) === sig) continue;
|
|
517
|
+
const existed = registry.flushed.has(identity);
|
|
518
|
+
registry.flushed.set(identity, sig);
|
|
519
|
+
if (identity === "title") {
|
|
520
|
+
const children = winner.tags[0].props.children;
|
|
521
|
+
ops.push(["t", children == null ? "" : String(children)]);
|
|
522
|
+
continue;
|
|
523
|
+
}
|
|
524
|
+
if (existed) ops.push(["r", identity]);
|
|
525
|
+
for (let i = 0; i < winner.tags.length; i++) {
|
|
526
|
+
const t = winner.tags[i];
|
|
527
|
+
const attrs = {};
|
|
528
|
+
for (const name in t.props) {
|
|
529
|
+
if (name === "children" || name === "ref" || name.slice(0, 2) === "on") continue;
|
|
530
|
+
if (!HEAD_ATTR_NAME.test(name)) {
|
|
531
|
+
console.warn(`useHead: ignoring invalid attribute name "${name}"`);
|
|
532
|
+
continue;
|
|
533
|
+
}
|
|
534
|
+
const v = t.props[name];
|
|
535
|
+
if (v == null || v === false) continue;
|
|
536
|
+
attrs[name] = v === true ? "" : String(v);
|
|
537
|
+
}
|
|
538
|
+
const children = t.props.children;
|
|
539
|
+
ops.push(["a", identity, t.tag, attrs, children == null ? null : String(children)]);
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
return ops.length ? ops : null;
|
|
543
|
+
}
|
|
544
|
+
function renderHeadAttrHtml(props) {
|
|
545
|
+
let attrs = "";
|
|
546
|
+
for (const name in props) {
|
|
547
|
+
if (name === "children" || name === "ref" || name.slice(0, 2) === "on") continue;
|
|
548
|
+
if (!HEAD_ATTR_NAME.test(name)) {
|
|
549
|
+
console.warn(`useHead: ignoring invalid attribute name "${name}"`);
|
|
550
|
+
continue;
|
|
551
|
+
}
|
|
552
|
+
const v = props[name];
|
|
553
|
+
if (v == null || v === false) continue;
|
|
554
|
+
attrs += v === true ? ` ${name}` : ` ${name}="${escape(String(v), true)}"`;
|
|
555
|
+
}
|
|
556
|
+
return attrs;
|
|
557
|
+
}
|
|
558
|
+
function headAttrRecord(props, skipRelHref) {
|
|
559
|
+
let attrs = null;
|
|
560
|
+
for (const name in props) {
|
|
561
|
+
if (name === "children" || name === "ref" || name.slice(0, 2) === "on") continue;
|
|
562
|
+
if ((name === "rel" || name === "href")) continue;
|
|
563
|
+
if (!HEAD_ATTR_NAME.test(name)) continue;
|
|
564
|
+
const v = props[name];
|
|
565
|
+
if (v == null || v === false) continue;
|
|
566
|
+
(attrs || (attrs = {}))[name] = v === true ? "" : String(v);
|
|
567
|
+
}
|
|
568
|
+
return attrs;
|
|
569
|
+
}
|
|
570
|
+
function renderHeadTagMarkup(tag, props, identity, nonce) {
|
|
571
|
+
let attrs = renderHeadAttrHtml(props);
|
|
572
|
+
if (identity != null) attrs += ` data-dh="${escape(identity, true)}"`;
|
|
573
|
+
if (nonce && (tag === "script" || tag === "style")) attrs += ` nonce="${nonce}"`;
|
|
574
|
+
if (tag === "meta" || tag === "link" || tag === "base") return `<${tag}${attrs}>`;
|
|
575
|
+
let body = props.children == null ? "" : String(props.children);
|
|
576
|
+
if (tag === "script") body = body.replace(/<\/(script)/gi, "<\\/$1");else if (tag === "style") body = escapeStyleContent(body);else body = escape(body);
|
|
577
|
+
return `<${tag}${attrs}>${body}</${tag}>`;
|
|
578
|
+
}
|
|
579
|
+
function useHead(tags) {
|
|
580
|
+
const ctx = solidJs.sharedConfig.context;
|
|
581
|
+
if (!ctx || !ctx.registerHeadTags) {
|
|
582
|
+
console.warn("useHead() called outside of a server render; registration ignored.");
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
585
|
+
ctx.registerHeadTags(Array.isArray(tags) ? tags : [tags]);
|
|
143
586
|
}
|
|
144
587
|
const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
|
|
145
|
-
const REPLACE_SCRIPT = `function $df(e,n,o,t){if(n=document.getElementById(e)
|
|
588
|
+
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.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])}`;
|
|
589
|
+
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)}`;
|
|
146
590
|
function renderToString(code, options = {}) {
|
|
147
591
|
const {
|
|
148
592
|
renderId = "",
|
|
149
593
|
nonce,
|
|
150
594
|
noScripts,
|
|
151
|
-
manifest
|
|
595
|
+
manifest,
|
|
596
|
+
onHead
|
|
152
597
|
} = options;
|
|
153
598
|
let scripts = "";
|
|
154
|
-
const serializer =
|
|
599
|
+
const serializer = createHydrationSerializer({
|
|
155
600
|
scopeId: renderId,
|
|
156
601
|
plugins: options.plugins,
|
|
157
602
|
onData(script) {
|
|
@@ -164,12 +609,16 @@ function renderToString(code, options = {}) {
|
|
|
164
609
|
onError: options.onError
|
|
165
610
|
});
|
|
166
611
|
const tracking = createAssetTracking();
|
|
612
|
+
const headRegistry = createHeadRegistry();
|
|
167
613
|
solidJs.sharedConfig.context = {
|
|
168
614
|
assets: [],
|
|
169
615
|
nonce,
|
|
170
616
|
escape: escape,
|
|
171
617
|
resolve: resolveSSRNode,
|
|
172
618
|
ssr: ssr,
|
|
619
|
+
registerHeadTags(tags) {
|
|
620
|
+
registerHeadTags(headRegistry, solidJs.sharedConfig.context, tracking, null, nonce, tags);
|
|
621
|
+
},
|
|
173
622
|
serialize(id, p) {
|
|
174
623
|
if (solidJs.sharedConfig.context.noHydrate) return;
|
|
175
624
|
if (p != null && typeof p === "object" && (typeof p.then === "function" || typeof p[Symbol.asyncIterator] === "function")) {
|
|
@@ -177,19 +626,23 @@ function renderToString(code, options = {}) {
|
|
|
177
626
|
}
|
|
178
627
|
serializer.write(id, p);
|
|
179
628
|
},
|
|
180
|
-
registerAsset(type,
|
|
629
|
+
registerAsset(type, value) {
|
|
630
|
+
if (type === "inline-style") {
|
|
631
|
+
tracking.registerInlineStyle(value);
|
|
632
|
+
return;
|
|
633
|
+
}
|
|
181
634
|
if (tracking.currentBoundaryId && type === "style") {
|
|
182
635
|
let styles = tracking.boundaryStyles.get(tracking.currentBoundaryId);
|
|
183
636
|
if (!styles) {
|
|
184
637
|
styles = new Set();
|
|
185
638
|
tracking.boundaryStyles.set(tracking.currentBoundaryId, styles);
|
|
186
639
|
}
|
|
187
|
-
styles.add(
|
|
640
|
+
styles.add(value);
|
|
188
641
|
}
|
|
189
|
-
tracking.emittedAssets.add(
|
|
642
|
+
tracking.emittedAssets.add(value);
|
|
190
643
|
}
|
|
191
644
|
};
|
|
192
|
-
applyAssetTracking(solidJs.sharedConfig.context, tracking, manifest);
|
|
645
|
+
applyAssetTracking(solidJs.sharedConfig.context, tracking, manifest, noScripts);
|
|
193
646
|
registerEntryAssets(manifest);
|
|
194
647
|
let html = solidJs.createRoot(d => {
|
|
195
648
|
setTimeout(d);
|
|
@@ -197,12 +650,12 @@ function renderToString(code, options = {}) {
|
|
|
197
650
|
}, {
|
|
198
651
|
id: renderId
|
|
199
652
|
});
|
|
653
|
+
serializeFragmentAssets("", tracking.boundaryModules, solidJs.sharedConfig.context);
|
|
200
654
|
solidJs.sharedConfig.context.noHydrate = true;
|
|
201
655
|
serializer.close();
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
return html;
|
|
656
|
+
const assetsHtml = resolveAssetsHtml(solidJs.sharedConfig.context.assets);
|
|
657
|
+
const head = renderShellHead(headRegistry, nonce, null);
|
|
658
|
+
return assembleDocument(html, assetsHtml, tracking.emittedAssets, tracking.inlineStyles, scripts.length ? scripts : "", nonce, head, onHead);
|
|
206
659
|
}
|
|
207
660
|
function renderToStream(code, options = {}) {
|
|
208
661
|
let {
|
|
@@ -211,18 +664,22 @@ function renderToStream(code, options = {}) {
|
|
|
211
664
|
onCompleteAll,
|
|
212
665
|
renderId = "",
|
|
213
666
|
noScripts,
|
|
214
|
-
manifest
|
|
667
|
+
manifest,
|
|
668
|
+
onHead
|
|
215
669
|
} = options;
|
|
216
670
|
let dispose;
|
|
217
671
|
const blockingPromises = new Set();
|
|
672
|
+
let headerEmitted = false;
|
|
218
673
|
const pushTask = task => {
|
|
219
674
|
if (noScripts) return;
|
|
220
|
-
if (!
|
|
221
|
-
|
|
675
|
+
if (!headerEmitted) {
|
|
676
|
+
headerEmitted = true;
|
|
677
|
+
tasks += getLocalHeaderScript(renderId);
|
|
222
678
|
}
|
|
223
679
|
tasks += task + ";";
|
|
224
680
|
if (!timer && firstFlushed) {
|
|
225
|
-
timer =
|
|
681
|
+
timer = true;
|
|
682
|
+
queue(() => queue(writeTasks));
|
|
226
683
|
}
|
|
227
684
|
};
|
|
228
685
|
const onDone = () => {
|
|
@@ -237,15 +694,63 @@ function renderToStream(code, options = {}) {
|
|
|
237
694
|
completed = true;
|
|
238
695
|
if (firstFlushed) dispose();
|
|
239
696
|
};
|
|
240
|
-
const
|
|
697
|
+
const sink = {
|
|
698
|
+
data(payload) {
|
|
699
|
+
pushTask(payload);
|
|
700
|
+
},
|
|
701
|
+
fragment(key, value, meta) {
|
|
702
|
+
const deferActivation = !!meta.revealGroup;
|
|
703
|
+
const styles = meta.styles;
|
|
704
|
+
for (let i = 0; i < styles.inline.length; i++) {
|
|
705
|
+
buffer.write(renderInlineStyle(styles.inline[i], nonce));
|
|
706
|
+
}
|
|
707
|
+
if (styles.links.length) {
|
|
708
|
+
emitTask(`$dfs("${key}",${styles.links.length},${deferActivation ? 1 : 0})`);
|
|
709
|
+
writeTasks();
|
|
710
|
+
for (const entry of styles.links) {
|
|
711
|
+
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}')">`);
|
|
712
|
+
}
|
|
713
|
+
buffer.write(`<template id="${key}">${value}</template>`);
|
|
714
|
+
} else {
|
|
715
|
+
buffer.write(`<template id="${key}">${value}</template>`);
|
|
716
|
+
if (!deferActivation) {
|
|
717
|
+
emitTask(`$df("${key}")`);
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
},
|
|
721
|
+
reveal(keys, meta) {
|
|
722
|
+
emitTask(`${meta.fallback ? "$dflj" : "$dfj"}(${JSON.stringify(keys)})`);
|
|
723
|
+
},
|
|
724
|
+
asset(type, value) {
|
|
725
|
+
if (type === "module") {
|
|
726
|
+
buffer.write(`<link rel="modulepreload" href="${value}">`);
|
|
727
|
+
} else if (type === "inline-style") {
|
|
728
|
+
buffer.write(renderInlineStyle(value, nonce));
|
|
729
|
+
} else if (type === "head-tag") {
|
|
730
|
+
buffer.write(value);
|
|
731
|
+
}
|
|
732
|
+
},
|
|
733
|
+
shell(shellHtml, meta) {
|
|
734
|
+
buffer.write(assembleDocument(shellHtml, meta.assets, meta.preloads, meta.inlineStyles, meta.tasks.length ? meta.tasks : "", nonce, meta.head, onHead));
|
|
735
|
+
},
|
|
736
|
+
...options.sink
|
|
737
|
+
};
|
|
738
|
+
const serializer = (options.serializer || createHydrationSerializer)({
|
|
241
739
|
scopeId: options.renderId,
|
|
242
740
|
plugins: options.plugins,
|
|
243
|
-
onData:
|
|
741
|
+
onData: payload => sink.data(payload),
|
|
244
742
|
onDone,
|
|
245
743
|
onError: options.onError
|
|
246
744
|
});
|
|
745
|
+
let rootAssetsSerialized = false;
|
|
746
|
+
const serializeRootAssets = () => {
|
|
747
|
+
if (rootAssetsSerialized) return;
|
|
748
|
+
rootAssetsSerialized = true;
|
|
749
|
+
serializeFragmentAssets("", tracking.boundaryModules, context);
|
|
750
|
+
};
|
|
247
751
|
const flushEnd = () => {
|
|
248
752
|
if (!registry.size) {
|
|
753
|
+
serializeRootAssets();
|
|
249
754
|
queue(() => queue(() => serializer.flush()));
|
|
250
755
|
}
|
|
251
756
|
};
|
|
@@ -255,7 +760,6 @@ function renderToStream(code, options = {}) {
|
|
|
255
760
|
buffer.write(`<script${nonce ? ` nonce="${nonce}"` : ""}>${tasks}</script>`);
|
|
256
761
|
tasks = "";
|
|
257
762
|
}
|
|
258
|
-
timer && clearTimeout(timer);
|
|
259
763
|
timer = null;
|
|
260
764
|
};
|
|
261
765
|
let context;
|
|
@@ -267,7 +771,29 @@ function renderToStream(code, options = {}) {
|
|
|
267
771
|
let shellCompleted = false;
|
|
268
772
|
let scriptFlushed = false;
|
|
269
773
|
let headStyles;
|
|
774
|
+
const revealGroups = new Map();
|
|
270
775
|
let timer = null;
|
|
776
|
+
const emitTask = task => {
|
|
777
|
+
pushTask(`${task}${!scriptFlushed ? ";" + REPLACE_SCRIPT : ""}`);
|
|
778
|
+
scriptFlushed = true;
|
|
779
|
+
};
|
|
780
|
+
function resolveRevealKeys(groupOrKeys, release, consume) {
|
|
781
|
+
if (Array.isArray(groupOrKeys)) return groupOrKeys.slice();
|
|
782
|
+
let group = revealGroups.get(groupOrKeys);
|
|
783
|
+
if (!group) {
|
|
784
|
+
if (!release) return;
|
|
785
|
+
group = {
|
|
786
|
+
order: [],
|
|
787
|
+
keys: new Set(),
|
|
788
|
+
released: true
|
|
789
|
+
};
|
|
790
|
+
revealGroups.set(groupOrKeys, group);
|
|
791
|
+
} else if (release) group.released = true;
|
|
792
|
+
if (!group.order.length) return;
|
|
793
|
+
const keys = group.order.slice();
|
|
794
|
+
if (consume) revealGroups.delete(groupOrKeys);
|
|
795
|
+
return keys;
|
|
796
|
+
}
|
|
271
797
|
let rootHoles = null;
|
|
272
798
|
let nextHoleId = 0;
|
|
273
799
|
let buffer = {
|
|
@@ -276,24 +802,48 @@ function renderToStream(code, options = {}) {
|
|
|
276
802
|
}
|
|
277
803
|
};
|
|
278
804
|
const tracking = createAssetTracking();
|
|
805
|
+
const headRegistry = createHeadRegistry();
|
|
806
|
+
let headScriptFlushed = false;
|
|
807
|
+
const emitHeadOps = (key, ops) => {
|
|
808
|
+
const payload = JSON.stringify(ops).replace(/</g, "\\u003C");
|
|
809
|
+
emitTask(`${!headScriptFlushed ? HEAD_SCRIPT : ""}(_$HY.hp=_$HY.hp||{})[${JSON.stringify(key)}]=${payload}`);
|
|
810
|
+
headScriptFlushed = true;
|
|
811
|
+
};
|
|
279
812
|
solidJs.sharedConfig.context = context = {
|
|
280
813
|
async: true,
|
|
281
814
|
assets: [],
|
|
282
815
|
nonce,
|
|
283
|
-
|
|
816
|
+
registerHeadTags(tags) {
|
|
817
|
+
registerHeadTags(headRegistry, context, tracking,
|
|
818
|
+
(markup, gateEntry) => {
|
|
819
|
+
if (!firstFlushed) {
|
|
820
|
+
headRegistry.eagerHtml += markup;
|
|
821
|
+
if (gateEntry) gateEntry.emitted = true;
|
|
822
|
+
} else if (!gateEntry || !tracking.currentBoundaryId) {
|
|
823
|
+
sink.asset("head-tag", markup);
|
|
824
|
+
}
|
|
825
|
+
}, nonce, tags);
|
|
826
|
+
},
|
|
827
|
+
registerAsset(type, value) {
|
|
828
|
+
if (type === "inline-style") {
|
|
829
|
+
const entry = tracking.registerInlineStyle(value);
|
|
830
|
+
if (firstFlushed && !tracking.currentBoundaryId && !entry.emitted) {
|
|
831
|
+
entry.emitted = true;
|
|
832
|
+
sink.asset("inline-style", entry);
|
|
833
|
+
}
|
|
834
|
+
return;
|
|
835
|
+
}
|
|
284
836
|
if (tracking.currentBoundaryId && type === "style") {
|
|
285
837
|
let styles = tracking.boundaryStyles.get(tracking.currentBoundaryId);
|
|
286
838
|
if (!styles) {
|
|
287
839
|
styles = new Set();
|
|
288
840
|
tracking.boundaryStyles.set(tracking.currentBoundaryId, styles);
|
|
289
841
|
}
|
|
290
|
-
styles.add(
|
|
842
|
+
styles.add(value);
|
|
291
843
|
}
|
|
292
|
-
if (!tracking.emittedAssets.has(
|
|
293
|
-
tracking.emittedAssets.add(
|
|
294
|
-
if (firstFlushed
|
|
295
|
-
buffer.write(`<link rel="modulepreload" href="${url}">`);
|
|
296
|
-
}
|
|
844
|
+
if (!tracking.emittedAssets.has(value)) {
|
|
845
|
+
tracking.emittedAssets.add(value);
|
|
846
|
+
if (firstFlushed) sink.asset(type, value);
|
|
297
847
|
}
|
|
298
848
|
},
|
|
299
849
|
block(p) {
|
|
@@ -317,7 +867,26 @@ function renderToStream(code, options = {}) {
|
|
|
317
867
|
escape: escape,
|
|
318
868
|
resolve: resolveSSRNode,
|
|
319
869
|
ssr: ssr,
|
|
320
|
-
registerFragment(key) {
|
|
870
|
+
registerFragment(key, options) {
|
|
871
|
+
const revealGroup = options && options.revealGroup;
|
|
872
|
+
if (revealGroup) {
|
|
873
|
+
let group = revealGroups.get(revealGroup);
|
|
874
|
+
if (!group) {
|
|
875
|
+
group = {
|
|
876
|
+
order: [],
|
|
877
|
+
keys: new Set(),
|
|
878
|
+
released: false
|
|
879
|
+
};
|
|
880
|
+
revealGroups.set(revealGroup, group);
|
|
881
|
+
}
|
|
882
|
+
if (!group.keys.has(key)) {
|
|
883
|
+
group.keys.add(key);
|
|
884
|
+
group.order.push(key);
|
|
885
|
+
}
|
|
886
|
+
if (group.released) {
|
|
887
|
+
throw new Error("registerFragment() for reveal group '" + revealGroup + "' was called after revealFragments(). Ensure template payload is emitted before grouped reveal.");
|
|
888
|
+
}
|
|
889
|
+
}
|
|
321
890
|
if (!registry.has(key)) {
|
|
322
891
|
let resolve, reject;
|
|
323
892
|
const p = new Promise((r, rej) => (resolve = r, reject = rej));
|
|
@@ -327,7 +896,7 @@ function renderToStream(code, options = {}) {
|
|
|
327
896
|
queue(flushEnd);
|
|
328
897
|
}))
|
|
329
898
|
});
|
|
330
|
-
serializer.write(key, p);
|
|
899
|
+
serializer.write(key + "_fr", p);
|
|
331
900
|
}
|
|
332
901
|
return (value, error) => {
|
|
333
902
|
if (registry.has(key)) {
|
|
@@ -345,10 +914,12 @@ function renderToStream(code, options = {}) {
|
|
|
345
914
|
parent.children[key] = value !== undefined ? value : "";
|
|
346
915
|
serializeFragmentAssets(key, tracking.boundaryModules, context);
|
|
347
916
|
propagateBoundaryStyles(key, parentKey, tracking);
|
|
917
|
+
adoptHeadBoundary(headRegistry, key, parentKey);
|
|
348
918
|
item.resolve();
|
|
349
919
|
return;
|
|
350
920
|
}
|
|
351
921
|
if (!completed) {
|
|
922
|
+
if (error) dropHeadBoundary(headRegistry, key);
|
|
352
923
|
if (!firstFlushed) {
|
|
353
924
|
queue(() => html = replacePlaceholder(html, key, value !== undefined ? value : ""));
|
|
354
925
|
serializeFragmentAssets(key, tracking.boundaryModules, context);
|
|
@@ -356,28 +927,36 @@ function renderToStream(code, options = {}) {
|
|
|
356
927
|
} else {
|
|
357
928
|
serializeFragmentAssets(key, tracking.boundaryModules, context);
|
|
358
929
|
const styles = collectStreamStyles(key, tracking, headStyles);
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`);
|
|
367
|
-
} else {
|
|
368
|
-
buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`);
|
|
369
|
-
pushTask(`$df("${key}")${!scriptFlushed ? ";" + REPLACE_SCRIPT : ""}`);
|
|
370
|
-
scriptFlushed = true;
|
|
371
|
-
}
|
|
930
|
+
const headOps = error ? null : flushHeadFragment(headRegistry, key);
|
|
931
|
+
if (headOps) emitHeadOps(key, headOps);
|
|
932
|
+
sink.fragment(key, value !== undefined ? value : " ", {
|
|
933
|
+
styles,
|
|
934
|
+
revealGroup,
|
|
935
|
+
error
|
|
936
|
+
});
|
|
372
937
|
item.resolve(error);
|
|
373
938
|
}
|
|
374
939
|
}
|
|
375
940
|
}
|
|
376
941
|
return firstFlushed;
|
|
377
942
|
};
|
|
943
|
+
},
|
|
944
|
+
revealFragments(groupOrKeys) {
|
|
945
|
+
const keys = resolveRevealKeys(groupOrKeys, true, true);
|
|
946
|
+
if (!keys) return;
|
|
947
|
+
sink.reveal(keys, {
|
|
948
|
+
fallback: false
|
|
949
|
+
});
|
|
950
|
+
},
|
|
951
|
+
revealFallbacks(groupOrKeys) {
|
|
952
|
+
const keys = resolveRevealKeys(groupOrKeys, false, false);
|
|
953
|
+
if (!keys) return;
|
|
954
|
+
sink.reveal(keys, {
|
|
955
|
+
fallback: true
|
|
956
|
+
});
|
|
378
957
|
}
|
|
379
958
|
};
|
|
380
|
-
applyAssetTracking(context, tracking, manifest);
|
|
959
|
+
applyAssetTracking(context, tracking, manifest, noScripts);
|
|
381
960
|
registerEntryAssets(manifest);
|
|
382
961
|
let html = solidJs.createRoot(d => {
|
|
383
962
|
dispose = d;
|
|
@@ -398,28 +977,56 @@ function renderToStream(code, options = {}) {
|
|
|
398
977
|
}, {
|
|
399
978
|
id: renderId
|
|
400
979
|
});
|
|
401
|
-
function
|
|
402
|
-
if (
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
980
|
+
function resolveRootHoles() {
|
|
981
|
+
if (!rootHoles) return true;
|
|
982
|
+
const pending = [];
|
|
983
|
+
for (const {
|
|
984
|
+
id,
|
|
985
|
+
fn
|
|
986
|
+
} of rootHoles) {
|
|
987
|
+
const marker = `<!--rh${id}-->`;
|
|
988
|
+
const res = resolveSSRNode(fn);
|
|
989
|
+
if (!res.h.length) {
|
|
990
|
+
html = html.replace(marker, res.t[0]);
|
|
991
|
+
} else {
|
|
992
|
+
let out = res.t[0];
|
|
993
|
+
for (let j = 0; j < res.h.length; j++) {
|
|
994
|
+
const newId = nextHoleId++;
|
|
995
|
+
pending.push({
|
|
996
|
+
id: newId,
|
|
997
|
+
fn: res.h[j]
|
|
998
|
+
});
|
|
999
|
+
out += `<!--rh${newId}-->` + res.t[j + 1];
|
|
1000
|
+
}
|
|
1001
|
+
html = html.replace(marker, out);
|
|
1002
|
+
for (const p of res.p) blockingPromises.add(p);
|
|
411
1003
|
}
|
|
412
|
-
rootHoles = null;
|
|
413
1004
|
}
|
|
1005
|
+
if (pending.length) {
|
|
1006
|
+
rootHoles = pending;
|
|
1007
|
+
return false;
|
|
1008
|
+
}
|
|
1009
|
+
rootHoles = null;
|
|
1010
|
+
return true;
|
|
1011
|
+
}
|
|
1012
|
+
function doShell() {
|
|
1013
|
+
if (shellCompleted) return;
|
|
1014
|
+
if (!resolveRootHoles()) return;
|
|
414
1015
|
solidJs.sharedConfig.context = context;
|
|
415
|
-
|
|
1016
|
+
const assetsHtml = resolveAssetsHtml(context.assets);
|
|
416
1017
|
headStyles = new Set();
|
|
417
1018
|
for (const url of tracking.emittedAssets) {
|
|
418
|
-
if (url
|
|
1019
|
+
if (isCssUrl(url)) headStyles.add(url);
|
|
419
1020
|
}
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
1021
|
+
serializeRootAssets();
|
|
1022
|
+
const head = renderShellHead(headRegistry, nonce, k => registry.has(k));
|
|
1023
|
+
sink.shell(html, {
|
|
1024
|
+
assets: assetsHtml,
|
|
1025
|
+
preloads: tracking.emittedAssets,
|
|
1026
|
+
inlineStyles: tracking.inlineStyles,
|
|
1027
|
+
tasks,
|
|
1028
|
+
head
|
|
1029
|
+
});
|
|
423
1030
|
tasks = "";
|
|
424
1031
|
onCompleteShell && onCompleteShell({
|
|
425
1032
|
write(v) {
|
|
@@ -428,53 +1035,57 @@ function renderToStream(code, options = {}) {
|
|
|
428
1035
|
});
|
|
429
1036
|
shellCompleted = true;
|
|
430
1037
|
}
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
1038
|
+
const MIN_DRAIN_TURNS = 8;
|
|
1039
|
+
let lastBlockingSize = -1;
|
|
1040
|
+
let lastRegistrySize = -1;
|
|
1041
|
+
let drainTurn = 0;
|
|
1042
|
+
const scheduleFlush = fn => {
|
|
1043
|
+
const attempt = () => {
|
|
1044
|
+
if (registry.size !== lastRegistrySize || drainTurn++ < MIN_DRAIN_TURNS) {
|
|
1045
|
+
if (registry.size !== lastRegistrySize) drainTurn = 0;
|
|
1046
|
+
lastRegistrySize = registry.size;
|
|
1047
|
+
queue(attempt);
|
|
1048
|
+
return;
|
|
436
1049
|
}
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
1050
|
+
fn();
|
|
1051
|
+
};
|
|
1052
|
+
const progressed = blockingPromises.size !== lastBlockingSize;
|
|
1053
|
+
lastBlockingSize = blockingPromises.size;
|
|
1054
|
+
lastRegistrySize = -1;
|
|
1055
|
+
drainTurn = 0;
|
|
1056
|
+
progressed ? queue(attempt) : setTimeout(attempt);
|
|
1057
|
+
};
|
|
1058
|
+
let cachedReadable;
|
|
1059
|
+
let consumer;
|
|
1060
|
+
const claimConsumer = name => {
|
|
1061
|
+
if (consumer && consumer !== name) {
|
|
1062
|
+
throw new Error(`renderToStream result was already consumed via \`${consumer}\`; cannot also consume it via \`${name}\`. Use exactly one of \`pipe\`, \`pipeTo\`, or \`readable\`.`);
|
|
1063
|
+
}
|
|
1064
|
+
consumer = name;
|
|
1065
|
+
};
|
|
1066
|
+
const pipeToImpl = w => {
|
|
1067
|
+
let resolve;
|
|
1068
|
+
const p = new Promise(r => resolve = r);
|
|
1069
|
+
function flush() {
|
|
447
1070
|
allSettled(blockingPromises).then(() => {
|
|
448
|
-
|
|
449
|
-
doShell();
|
|
450
|
-
buffer = writable = w;
|
|
451
|
-
buffer.write(tmp);
|
|
452
|
-
firstFlushed = true;
|
|
453
|
-
if (completed) {
|
|
454
|
-
dispose();
|
|
455
|
-
writable.end();
|
|
456
|
-
} else flushEnd();
|
|
457
|
-
});
|
|
458
|
-
});
|
|
459
|
-
},
|
|
460
|
-
pipeTo(w) {
|
|
461
|
-
return allSettled(blockingPromises).then(() => {
|
|
462
|
-
let resolve;
|
|
463
|
-
const p = new Promise(r => resolve = r);
|
|
464
|
-
setTimeout(() => {
|
|
1071
|
+
scheduleFlush(() => {
|
|
465
1072
|
doShell();
|
|
1073
|
+
if (!shellCompleted) return flush();
|
|
466
1074
|
const encoder = new TextEncoder();
|
|
467
1075
|
const writer = w.getWriter();
|
|
1076
|
+
let pendingWrites = Promise.resolve();
|
|
468
1077
|
writable = {
|
|
469
1078
|
end() {
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
1079
|
+
pendingWrites.then(() => {
|
|
1080
|
+
writer.releaseLock();
|
|
1081
|
+
w.close().catch(() => {});
|
|
1082
|
+
resolve();
|
|
1083
|
+
});
|
|
473
1084
|
}
|
|
474
1085
|
};
|
|
475
1086
|
buffer = {
|
|
476
1087
|
write(payload) {
|
|
477
|
-
writer.write(encoder.encode(payload)).catch(() => {});
|
|
1088
|
+
pendingWrites = pendingWrites.then(() => writer.write(encoder.encode(payload))).catch(() => {});
|
|
478
1089
|
}
|
|
479
1090
|
};
|
|
480
1091
|
buffer.write(tmp);
|
|
@@ -484,9 +1095,66 @@ function renderToStream(code, options = {}) {
|
|
|
484
1095
|
writable.end();
|
|
485
1096
|
} else flushEnd();
|
|
486
1097
|
});
|
|
487
|
-
return p;
|
|
488
1098
|
});
|
|
489
1099
|
}
|
|
1100
|
+
flush();
|
|
1101
|
+
return p;
|
|
1102
|
+
};
|
|
1103
|
+
return {
|
|
1104
|
+
then(fn) {
|
|
1105
|
+
function complete() {
|
|
1106
|
+
dispose();
|
|
1107
|
+
fn(tmp);
|
|
1108
|
+
}
|
|
1109
|
+
if (onCompleteAll) {
|
|
1110
|
+
let ogComplete = onCompleteAll;
|
|
1111
|
+
onCompleteAll = options => {
|
|
1112
|
+
ogComplete(options);
|
|
1113
|
+
complete();
|
|
1114
|
+
};
|
|
1115
|
+
} else onCompleteAll = complete;
|
|
1116
|
+
function flush() {
|
|
1117
|
+
allSettled(blockingPromises).then(() => {
|
|
1118
|
+
scheduleFlush(() => {
|
|
1119
|
+
if (!resolveRootHoles()) return flush();
|
|
1120
|
+
queue(flushEnd);
|
|
1121
|
+
});
|
|
1122
|
+
});
|
|
1123
|
+
}
|
|
1124
|
+
flush();
|
|
1125
|
+
},
|
|
1126
|
+
pipe(w) {
|
|
1127
|
+
claimConsumer("pipe");
|
|
1128
|
+
function flush() {
|
|
1129
|
+
allSettled(blockingPromises).then(() => {
|
|
1130
|
+
scheduleFlush(() => {
|
|
1131
|
+
doShell();
|
|
1132
|
+
if (!shellCompleted) return flush();
|
|
1133
|
+
buffer = writable = w;
|
|
1134
|
+
buffer.write(tmp);
|
|
1135
|
+
firstFlushed = true;
|
|
1136
|
+
if (completed) {
|
|
1137
|
+
dispose();
|
|
1138
|
+
writable.end();
|
|
1139
|
+
} else flushEnd();
|
|
1140
|
+
});
|
|
1141
|
+
});
|
|
1142
|
+
}
|
|
1143
|
+
flush();
|
|
1144
|
+
},
|
|
1145
|
+
pipeTo(w) {
|
|
1146
|
+
claimConsumer("pipeTo");
|
|
1147
|
+
return pipeToImpl(w);
|
|
1148
|
+
},
|
|
1149
|
+
get readable() {
|
|
1150
|
+
claimConsumer("readable");
|
|
1151
|
+
if (!cachedReadable) {
|
|
1152
|
+
const t = new TransformStream();
|
|
1153
|
+
pipeToImpl(t.writable);
|
|
1154
|
+
cachedReadable = t.readable;
|
|
1155
|
+
}
|
|
1156
|
+
return cachedReadable;
|
|
1157
|
+
}
|
|
490
1158
|
};
|
|
491
1159
|
}
|
|
492
1160
|
function HydrationScript(props) {
|
|
@@ -498,11 +1166,176 @@ function HydrationScript(props) {
|
|
|
498
1166
|
...props
|
|
499
1167
|
}));
|
|
500
1168
|
}
|
|
501
|
-
function
|
|
502
|
-
|
|
1169
|
+
function ssrGroup(fn, n) {
|
|
1170
|
+
fn.$g = n;
|
|
1171
|
+
return fn;
|
|
1172
|
+
}
|
|
1173
|
+
function buildAsyncWrap(err, node) {
|
|
1174
|
+
const p = solidJs.ssrHandleError(err);
|
|
1175
|
+
if (!p) return null;
|
|
1176
|
+
const owner = solidJs.getOwner();
|
|
503
1177
|
return {
|
|
1178
|
+
fn: owner ? () => solidJs.runWithOwner(owner, node) : node,
|
|
1179
|
+
p
|
|
1180
|
+
};
|
|
1181
|
+
}
|
|
1182
|
+
function ssrFirstGroupHit(hole) {
|
|
1183
|
+
try {
|
|
1184
|
+
return hole();
|
|
1185
|
+
} catch (err) {
|
|
1186
|
+
return buildAsyncWrap(err, hole);
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
function tryResolveFunctionHole(hole) {
|
|
1190
|
+
let value;
|
|
1191
|
+
try {
|
|
1192
|
+
value = hole();
|
|
1193
|
+
} catch (err) {
|
|
1194
|
+
return buildAsyncWrap(err, hole) || "";
|
|
1195
|
+
}
|
|
1196
|
+
const t = typeof value;
|
|
1197
|
+
if (t === "string") return value;
|
|
1198
|
+
if (t === "number") return "" + value;
|
|
1199
|
+
if (value == null || t === "boolean") return "";
|
|
1200
|
+
return tryResolveString(value);
|
|
1201
|
+
}
|
|
1202
|
+
function mergeTemplateInto(result, node) {
|
|
1203
|
+
result.t[result.t.length - 1] += node.t[0];
|
|
1204
|
+
if (node.t.length > 1) {
|
|
1205
|
+
result.t.push(...node.t.slice(1));
|
|
1206
|
+
result.h.push(...node.h);
|
|
1207
|
+
result.p.push(...node.p);
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
function appendResolvedNode(result, node) {
|
|
1211
|
+
if (node.fn !== undefined) {
|
|
1212
|
+
result.h.push(node.fn);
|
|
1213
|
+
result.p.push(node.p);
|
|
1214
|
+
result.t.push("");
|
|
1215
|
+
} else if (node.merge !== undefined) mergeTemplateInto(result, node.merge);else resolveSSRNode(node.bail, result);
|
|
1216
|
+
}
|
|
1217
|
+
let _lastGroupFn = null;
|
|
1218
|
+
let _lastGroupArr = null;
|
|
1219
|
+
let _lastGroupErr = null;
|
|
1220
|
+
function ssrGroupSlot(fn, idx) {
|
|
1221
|
+
return () => {
|
|
1222
|
+
if (idx > 0 && _lastGroupFn === fn) {
|
|
1223
|
+
if (_lastGroupArr !== null) return _lastGroupArr[idx];
|
|
1224
|
+
throw _lastGroupErr;
|
|
1225
|
+
}
|
|
1226
|
+
_lastGroupFn = fn;
|
|
1227
|
+
_lastGroupArr = null;
|
|
1228
|
+
_lastGroupErr = null;
|
|
1229
|
+
try {
|
|
1230
|
+
_lastGroupArr = fn();
|
|
1231
|
+
return _lastGroupArr[idx];
|
|
1232
|
+
} catch (err) {
|
|
1233
|
+
_lastGroupErr = err;
|
|
1234
|
+
throw err;
|
|
1235
|
+
}
|
|
1236
|
+
};
|
|
1237
|
+
}
|
|
1238
|
+
function ssr(t) {
|
|
1239
|
+
const len = arguments.length;
|
|
1240
|
+
if (len === 1) return {
|
|
504
1241
|
t
|
|
505
1242
|
};
|
|
1243
|
+
let s = t[0];
|
|
1244
|
+
let result = null;
|
|
1245
|
+
let lastGroup = null;
|
|
1246
|
+
let lastGroupVal = null;
|
|
1247
|
+
let lastGroupIdx = 0;
|
|
1248
|
+
for (let i = 1; i < len; i++) {
|
|
1249
|
+
const hole = arguments[i];
|
|
1250
|
+
const ht = typeof hole;
|
|
1251
|
+
if (ht === "string") {
|
|
1252
|
+
if (result === null) s += hole;else result.t[result.t.length - 1] += hole;
|
|
1253
|
+
} else if (ht === "number") {
|
|
1254
|
+
if (result === null) s += hole;else result.t[result.t.length - 1] += hole;
|
|
1255
|
+
} else if (hole == null || ht === "boolean") ; else if (ht === "function" && hole.$g) {
|
|
1256
|
+
let value;
|
|
1257
|
+
let hasValue = false;
|
|
1258
|
+
if (lastGroup !== hole) {
|
|
1259
|
+
const r = ssrFirstGroupHit(hole);
|
|
1260
|
+
if (r !== null) {
|
|
1261
|
+
lastGroup = hole;
|
|
1262
|
+
lastGroupVal = r;
|
|
1263
|
+
lastGroupIdx = 0;
|
|
1264
|
+
if (!Array.isArray(r) && result === null) {
|
|
1265
|
+
result = {
|
|
1266
|
+
t: [s],
|
|
1267
|
+
h: [],
|
|
1268
|
+
p: []
|
|
1269
|
+
};
|
|
1270
|
+
s = "";
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
if (lastGroup === hole) {
|
|
1275
|
+
if (Array.isArray(lastGroupVal)) {
|
|
1276
|
+
value = lastGroupVal[lastGroupIdx++];
|
|
1277
|
+
hasValue = true;
|
|
1278
|
+
} else {
|
|
1279
|
+
result.h.push(ssrGroupSlot(lastGroupVal.fn, lastGroupIdx++));
|
|
1280
|
+
result.p.push(lastGroupVal.p);
|
|
1281
|
+
result.t.push("");
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
if (hasValue) {
|
|
1285
|
+
const vt = typeof value;
|
|
1286
|
+
if (vt === "string" || vt === "number") {
|
|
1287
|
+
if (result === null) s += value;else result.t[result.t.length - 1] += value;
|
|
1288
|
+
} else if (value == null || vt === "boolean") ; else if (result !== null) {
|
|
1289
|
+
resolveSSRNode(value, result);
|
|
1290
|
+
} else {
|
|
1291
|
+
const rs = tryResolveString(value);
|
|
1292
|
+
if (typeof rs === "string") {
|
|
1293
|
+
s += rs;
|
|
1294
|
+
} else {
|
|
1295
|
+
result = {
|
|
1296
|
+
t: [s],
|
|
1297
|
+
h: [],
|
|
1298
|
+
p: []
|
|
1299
|
+
};
|
|
1300
|
+
s = "";
|
|
1301
|
+
if (rs.merge !== undefined) mergeTemplateInto(result, rs.merge);else resolveSSRNode(rs.bail, result);
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
}
|
|
1305
|
+
} else if (result !== null) {
|
|
1306
|
+
resolveSSRNode(hole, result);
|
|
1307
|
+
} else if (ht === "function") {
|
|
1308
|
+
const r = tryResolveFunctionHole(hole);
|
|
1309
|
+
if (typeof r === "string") s += r;else {
|
|
1310
|
+
result = {
|
|
1311
|
+
t: [s],
|
|
1312
|
+
h: [],
|
|
1313
|
+
p: []
|
|
1314
|
+
};
|
|
1315
|
+
s = "";
|
|
1316
|
+
appendResolvedNode(result, r);
|
|
1317
|
+
}
|
|
1318
|
+
} else {
|
|
1319
|
+
const r = tryResolveString(hole);
|
|
1320
|
+
if (typeof r === "string") {
|
|
1321
|
+
s += r;
|
|
1322
|
+
} else {
|
|
1323
|
+
result = {
|
|
1324
|
+
t: [s],
|
|
1325
|
+
h: [],
|
|
1326
|
+
p: []
|
|
1327
|
+
};
|
|
1328
|
+
s = "";
|
|
1329
|
+
appendResolvedNode(result, r);
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
const next = t[i];
|
|
1333
|
+
if (result === null) s += next;else result.t[result.t.length - 1] += next;
|
|
1334
|
+
}
|
|
1335
|
+
if (result === null) return {
|
|
1336
|
+
t: s
|
|
1337
|
+
};
|
|
1338
|
+
return result;
|
|
506
1339
|
}
|
|
507
1340
|
function ssrClassName(value) {
|
|
508
1341
|
if (!value) return "";
|
|
@@ -515,7 +1348,7 @@ function ssrClassName(value) {
|
|
|
515
1348
|
classValue = !!value[key];
|
|
516
1349
|
if (!key || key === "undefined" || !classValue) continue;
|
|
517
1350
|
i && (result += " ");
|
|
518
|
-
result += escape(key);
|
|
1351
|
+
result += escape(key, true);
|
|
519
1352
|
}
|
|
520
1353
|
return result;
|
|
521
1354
|
}
|
|
@@ -525,8 +1358,8 @@ function ssrStyle(value) {
|
|
|
525
1358
|
let result = "";
|
|
526
1359
|
const k = Object.keys(value);
|
|
527
1360
|
for (let i = 0; i < k.length; i++) {
|
|
528
|
-
const s = k[i];
|
|
529
|
-
const v = value[
|
|
1361
|
+
const s = escape(k[i], true);
|
|
1362
|
+
const v = value[k[i]];
|
|
530
1363
|
if (v != undefined) {
|
|
531
1364
|
if (i) result += ";";
|
|
532
1365
|
const r = escape(v, true);
|
|
@@ -541,10 +1374,11 @@ function ssrStyleProperty(name, value) {
|
|
|
541
1374
|
return value != null ? name + value : "";
|
|
542
1375
|
}
|
|
543
1376
|
function ssrElement(tag, props, children, needsId) {
|
|
1377
|
+
const hk = needsId ? ssrHydrationKey() : "";
|
|
544
1378
|
if (props == null) props = {};else if (typeof props === "function") props = props();
|
|
545
1379
|
const skipChildren = VOID_ELEMENTS.test(tag);
|
|
546
1380
|
const keys = Object.keys(props);
|
|
547
|
-
let result = `<${tag}${
|
|
1381
|
+
let result = `<${tag}${hk} `;
|
|
548
1382
|
for (let i = 0; i < keys.length; i++) {
|
|
549
1383
|
const prop = keys[i];
|
|
550
1384
|
if (ChildProperties.has(prop)) {
|
|
@@ -583,18 +1417,31 @@ function escape(s, attr) {
|
|
|
583
1417
|
const t = typeof s;
|
|
584
1418
|
if (t !== "string") {
|
|
585
1419
|
if (!attr && Array.isArray(s)) {
|
|
1420
|
+
const joined = tryJoinPlainSSRArray(s);
|
|
1421
|
+
if (joined !== undefined) return joined;
|
|
586
1422
|
s = s.slice();
|
|
587
1423
|
for (let i = 0; i < s.length; i++) s[i] = escape(s[i]);
|
|
588
1424
|
return s;
|
|
589
1425
|
}
|
|
590
|
-
if (attr
|
|
1426
|
+
if (attr) {
|
|
1427
|
+
if (s == null || t === "boolean" || t === "number") return s;
|
|
1428
|
+
return escape(String(s), attr);
|
|
1429
|
+
}
|
|
591
1430
|
return s;
|
|
592
1431
|
}
|
|
1432
|
+
const i = s.search(attr ? ESCAPE_ATTR : ESCAPE_CONTENT);
|
|
1433
|
+
if (i < 0) return s;
|
|
1434
|
+
return escapeSlow(s, attr, i);
|
|
1435
|
+
}
|
|
1436
|
+
const ESCAPE_CONTENT = /[&<]/;
|
|
1437
|
+
const ESCAPE_ATTR = /[&"]/;
|
|
1438
|
+
function escapeSlow(s, attr, start) {
|
|
593
1439
|
const delim = attr ? '"' : "<";
|
|
1440
|
+
const delimCode = attr ? 34 : 60;
|
|
594
1441
|
const escDelim = attr ? """ : "<";
|
|
595
|
-
|
|
596
|
-
let
|
|
597
|
-
|
|
1442
|
+
const c0 = s.charCodeAt(start);
|
|
1443
|
+
let iDelim = c0 === delimCode ? start : s.indexOf(delim, start);
|
|
1444
|
+
let iAmp = c0 === 38 ? start : s.indexOf("&", start);
|
|
598
1445
|
let left = 0,
|
|
599
1446
|
out = "";
|
|
600
1447
|
while (iDelim >= 0 && iAmp >= 0) {
|
|
@@ -625,28 +1472,17 @@ function escape(s, attr) {
|
|
|
625
1472
|
}
|
|
626
1473
|
return left < s.length ? out + s.substring(left) : out;
|
|
627
1474
|
}
|
|
628
|
-
function
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
if (
|
|
634
|
-
|
|
635
|
-
for (const key in descriptors) {
|
|
636
|
-
if (key in target) continue;
|
|
637
|
-
Object.defineProperty(target, key, {
|
|
638
|
-
enumerable: true,
|
|
639
|
-
get() {
|
|
640
|
-
for (let i = sources.length - 1; i >= 0; i--) {
|
|
641
|
-
const v = (sources[i] || {})[key];
|
|
642
|
-
if (v !== undefined) return v;
|
|
643
|
-
}
|
|
644
|
-
}
|
|
645
|
-
});
|
|
646
|
-
}
|
|
1475
|
+
function tryJoinPlainSSRArray(nodes) {
|
|
1476
|
+
if (nodes.length === 0) return undefined;
|
|
1477
|
+
let out = "";
|
|
1478
|
+
for (let i = 0, len = nodes.length; i < len; i++) {
|
|
1479
|
+
const node = nodes[i];
|
|
1480
|
+
if (node == null || typeof node !== "object" || node.h || typeof node.t !== "string") {
|
|
1481
|
+
return undefined;
|
|
647
1482
|
}
|
|
1483
|
+
out += node.t;
|
|
648
1484
|
}
|
|
649
|
-
return
|
|
1485
|
+
return out;
|
|
650
1486
|
}
|
|
651
1487
|
function getHydrationKey() {
|
|
652
1488
|
const hydrate = solidJs.sharedConfig.context;
|
|
@@ -664,11 +1500,14 @@ function getAssets() {
|
|
|
664
1500
|
for (let i = 0, len = assets.length; i < len; i++) out += assets[i]();
|
|
665
1501
|
return out;
|
|
666
1502
|
}
|
|
1503
|
+
function Assets(props) {
|
|
1504
|
+
useAssets(() => props.children);
|
|
1505
|
+
}
|
|
667
1506
|
function generateHydrationScript({
|
|
668
1507
|
eventNames = ["click", "input"],
|
|
669
1508
|
nonce
|
|
670
1509
|
} = {}) {
|
|
671
|
-
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('",
|
|
1510
|
+
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-->`;
|
|
672
1511
|
}
|
|
673
1512
|
function queue(fn) {
|
|
674
1513
|
return Promise.resolve().then(fn);
|
|
@@ -680,27 +1519,58 @@ function allSettled(promises) {
|
|
|
680
1519
|
return;
|
|
681
1520
|
});
|
|
682
1521
|
}
|
|
683
|
-
function
|
|
684
|
-
if (!assets || !assets.length) return
|
|
1522
|
+
function resolveAssetsHtml(assets) {
|
|
1523
|
+
if (!assets || !assets.length) return "";
|
|
685
1524
|
let out = "";
|
|
686
1525
|
for (let i = 0, len = assets.length; i < len; i++) out += assets[i]();
|
|
687
|
-
|
|
688
|
-
if (index === -1) return html;
|
|
689
|
-
return html.slice(0, index) + out + html.slice(index);
|
|
1526
|
+
return out;
|
|
690
1527
|
}
|
|
691
|
-
function
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
1528
|
+
function assembleDocument(html, assetsHtml, emittedAssets, inlineStyles, scripts, nonce, headTags, onHead) {
|
|
1529
|
+
const scriptTag = scripts ? `<script${nonce ? ` nonce="${nonce}"` : ""}>${scripts}</script>` : "";
|
|
1530
|
+
const headTagsHtml = headTags ? headTags.html : "";
|
|
1531
|
+
const headPrelude = headTags ? headTags.prelude : "";
|
|
1532
|
+
if (!onHead && !assetsHtml && !headTagsHtml && !headPrelude && !(emittedAssets && emittedAssets.size) && !(inlineStyles && inlineStyles.size)) {
|
|
1533
|
+
if (!scriptTag) return html;
|
|
1534
|
+
const xs = html.indexOf("<!--xs-->");
|
|
1535
|
+
return xs === -1 ? html + scriptTag : html.slice(0, xs) + scriptTag + html.slice(xs);
|
|
1536
|
+
}
|
|
1537
|
+
if (headPrelude) {
|
|
1538
|
+
const open = html.match(/<head(?:\s[^>]*)?>/);
|
|
1539
|
+
if (open) {
|
|
1540
|
+
const at = open.index + open[0].length;
|
|
1541
|
+
html = html.slice(0, at) + headPrelude + html.slice(at);
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
const headIdx = html.indexOf("</head>");
|
|
1545
|
+
if (headIdx === -1) {
|
|
1546
|
+
if (onHead) {
|
|
1547
|
+
onHead(headPrelude + headTagsHtml + (assetsHtml || "") + renderHeadAssets(emittedAssets, inlineStyles, nonce));
|
|
699
1548
|
}
|
|
1549
|
+
if (!scriptTag) return html;
|
|
1550
|
+
const xs = html.indexOf("<!--xs-->");
|
|
1551
|
+
return xs === -1 ? html + scriptTag : html.slice(0, xs) + scriptTag + html.slice(xs);
|
|
700
1552
|
}
|
|
701
|
-
const
|
|
702
|
-
if (
|
|
703
|
-
|
|
1553
|
+
const head = headTagsHtml + (assetsHtml || "") + renderHeadAssets(emittedAssets, inlineStyles, nonce);
|
|
1554
|
+
if (!scriptTag) return html.slice(0, headIdx) + head + html.slice(headIdx);
|
|
1555
|
+
const xsIdx = html.indexOf("<!--xs-->");
|
|
1556
|
+
if (xsIdx === -1) return html.slice(0, headIdx) + head + html.slice(headIdx) + scriptTag;
|
|
1557
|
+
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);
|
|
1558
|
+
}
|
|
1559
|
+
function renderHeadAssets(emittedAssets, inlineStyles, nonce) {
|
|
1560
|
+
let head = "";
|
|
1561
|
+
if (emittedAssets && emittedAssets.size) {
|
|
1562
|
+
for (const url of emittedAssets) {
|
|
1563
|
+
head += isCssUrl(url) ? `<link rel="stylesheet" href="${url}">` : `<link rel="modulepreload" href="${url}">`;
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
if (inlineStyles && inlineStyles.size) {
|
|
1567
|
+
for (const entry of inlineStyles.values()) {
|
|
1568
|
+
if (entry.emitted) continue;
|
|
1569
|
+
entry.emitted = true;
|
|
1570
|
+
head += renderInlineStyle(entry, nonce);
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
return head;
|
|
704
1574
|
}
|
|
705
1575
|
function serializeFragmentAssets(key, boundaryModules, context) {
|
|
706
1576
|
const map = boundaryModules.get(key);
|
|
@@ -721,22 +1591,41 @@ function propagateBoundaryStyles(childKey, parentKey, tracking) {
|
|
|
721
1591
|
}
|
|
722
1592
|
function collectStreamStyles(key, tracking, headStyles) {
|
|
723
1593
|
const styles = tracking.getBoundaryStyles(key);
|
|
724
|
-
|
|
725
|
-
const
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
1594
|
+
const links = [];
|
|
1595
|
+
const inline = [];
|
|
1596
|
+
if (!styles) return {
|
|
1597
|
+
links,
|
|
1598
|
+
inline
|
|
1599
|
+
};
|
|
1600
|
+
for (const entry of styles) {
|
|
1601
|
+
if (typeof entry === "string") {
|
|
1602
|
+
if (!headStyles || !headStyles.has(entry)) links.push(entry);
|
|
1603
|
+
} else if (entry.emitted) {
|
|
1604
|
+
continue;
|
|
1605
|
+
} else if (entry.attrHtml !== undefined) {
|
|
1606
|
+
entry.emitted = true;
|
|
1607
|
+
links.push(entry);
|
|
1608
|
+
} else {
|
|
1609
|
+
entry.emitted = true;
|
|
1610
|
+
inline.push(entry);
|
|
729
1611
|
}
|
|
730
1612
|
}
|
|
731
|
-
return
|
|
1613
|
+
return {
|
|
1614
|
+
links,
|
|
1615
|
+
inline
|
|
1616
|
+
};
|
|
732
1617
|
}
|
|
733
|
-
function
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
1618
|
+
function escapeStyleContent(content) {
|
|
1619
|
+
return content.replace(/<\/(style)/gi, "<\\/$1");
|
|
1620
|
+
}
|
|
1621
|
+
function renderInlineStyle(entry, nonce) {
|
|
1622
|
+
let attrs = "";
|
|
1623
|
+
if (entry.attrs) {
|
|
1624
|
+
for (const name in entry.attrs) {
|
|
1625
|
+
attrs += ` ${name}="${escape(String(entry.attrs[name]), true)}"`;
|
|
1626
|
+
}
|
|
738
1627
|
}
|
|
739
|
-
return
|
|
1628
|
+
return `<style${nonce ? ` nonce="${nonce}"` : ""} data-asset="${escape(entry.id, true)}"${attrs}>${escapeStyleContent(entry.content)}</style>`;
|
|
740
1629
|
}
|
|
741
1630
|
function waitForFragments(registry, key) {
|
|
742
1631
|
for (const k of [...registry.keys()].reverse()) {
|
|
@@ -766,19 +1655,49 @@ function flattenClassList(list, result) {
|
|
|
766
1655
|
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;
|
|
767
1656
|
}
|
|
768
1657
|
}
|
|
769
|
-
function
|
|
770
|
-
t
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
1658
|
+
function tryResolveString(node) {
|
|
1659
|
+
const t = typeof node;
|
|
1660
|
+
if (t === "string") return node;
|
|
1661
|
+
if (t === "number") return "" + node;
|
|
1662
|
+
if (node == null || t === "boolean") return "";
|
|
1663
|
+
if (t === "object") {
|
|
1664
|
+
if (Array.isArray(node)) {
|
|
1665
|
+
const joined = tryJoinPlainSSRArray(node);
|
|
1666
|
+
if (joined !== undefined) return joined;
|
|
1667
|
+
let s = "";
|
|
1668
|
+
let prevNonObj = false;
|
|
1669
|
+
for (let i = 0, len = node.length; i < len; i++) {
|
|
1670
|
+
const item = node[i];
|
|
1671
|
+
const itemNonObj = item !== null && typeof item !== "object";
|
|
1672
|
+
if (prevNonObj && itemNonObj) s += "<!--!$-->";
|
|
1673
|
+
prevNonObj = itemNonObj;
|
|
1674
|
+
const r = tryResolveString(item);
|
|
1675
|
+
if (typeof r !== "string") return {
|
|
1676
|
+
bail: node
|
|
1677
|
+
};
|
|
1678
|
+
s += r;
|
|
1679
|
+
}
|
|
1680
|
+
return s;
|
|
1681
|
+
}
|
|
1682
|
+
if (node.h && node.h.length > 0) return {
|
|
1683
|
+
merge: node
|
|
1684
|
+
};
|
|
1685
|
+
if (node.t === undefined) {
|
|
1686
|
+
console.warn(`Unrecognized value. Skipped inserting`, node);
|
|
1687
|
+
return "";
|
|
1688
|
+
}
|
|
1689
|
+
return Array.isArray(node.t) ? node.t[0] : node.t;
|
|
779
1690
|
}
|
|
780
|
-
|
|
781
|
-
|
|
1691
|
+
if (t === "function") {
|
|
1692
|
+
let v;
|
|
1693
|
+
try {
|
|
1694
|
+
v = node();
|
|
1695
|
+
} catch (err) {
|
|
1696
|
+
return buildAsyncWrap(err, node) || "";
|
|
1697
|
+
}
|
|
1698
|
+
return tryResolveString(v);
|
|
1699
|
+
}
|
|
1700
|
+
return "";
|
|
782
1701
|
}
|
|
783
1702
|
function resolveSSRNode(node, result = {
|
|
784
1703
|
t: [""],
|
|
@@ -789,10 +1708,13 @@ function resolveSSRNode(node, result = {
|
|
|
789
1708
|
if (t === "string" || t === "number") {
|
|
790
1709
|
result.t[result.t.length - 1] += node;
|
|
791
1710
|
} else if (node == null || t === "boolean") ; else if (Array.isArray(node)) {
|
|
792
|
-
let
|
|
1711
|
+
let prevNonObj = false;
|
|
793
1712
|
for (let i = 0, len = node.length; i < len; i++) {
|
|
794
|
-
|
|
795
|
-
|
|
1713
|
+
const item = node[i];
|
|
1714
|
+
const itemNonObj = item !== null && typeof item !== "object";
|
|
1715
|
+
if (!top && prevNonObj && itemNonObj) result.t[result.t.length - 1] += `<!--!$-->`;
|
|
1716
|
+
prevNonObj = itemNonObj;
|
|
1717
|
+
resolveSSRNode(item, result);
|
|
796
1718
|
}
|
|
797
1719
|
} else if (t === "object") {
|
|
798
1720
|
if (node.h) {
|
|
@@ -802,15 +1724,17 @@ function resolveSSRNode(node, result = {
|
|
|
802
1724
|
result.h.push(...node.h);
|
|
803
1725
|
result.p.push(...node.p);
|
|
804
1726
|
}
|
|
805
|
-
} else
|
|
1727
|
+
} else if (node.t !== undefined) {
|
|
1728
|
+
result.t[result.t.length - 1] += node.t;
|
|
1729
|
+
} else console.warn(`Unrecognized value. Skipped inserting`, node);
|
|
806
1730
|
} else if (t === "function") {
|
|
807
1731
|
try {
|
|
808
1732
|
resolveSSRNode(node(), result);
|
|
809
1733
|
} catch (err) {
|
|
810
|
-
const
|
|
811
|
-
if (
|
|
812
|
-
result.h.push(
|
|
813
|
-
result.p.push(p);
|
|
1734
|
+
const wrap = buildAsyncWrap(err, node);
|
|
1735
|
+
if (wrap) {
|
|
1736
|
+
result.h.push(wrap.fn);
|
|
1737
|
+
result.p.push(wrap.p);
|
|
814
1738
|
result.t.push("");
|
|
815
1739
|
}
|
|
816
1740
|
}
|
|
@@ -822,39 +1746,188 @@ function resolveSSRSync(node) {
|
|
|
822
1746
|
if (!res.h.length) return res.t[0];
|
|
823
1747
|
throw new Error("This value cannot be rendered synchronously. Are you missing a boundary?");
|
|
824
1748
|
}
|
|
825
|
-
const RequestContext = Symbol();
|
|
1749
|
+
const RequestContext = Symbol.for("solid.RequestContext");
|
|
826
1750
|
function getRequestEvent() {
|
|
827
1751
|
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;
|
|
828
1752
|
}
|
|
829
1753
|
function renderToStringAsync(code, options = {}) {
|
|
830
1754
|
return new Promise(resolve => renderToStream(code, options).then(resolve));
|
|
831
1755
|
}
|
|
1756
|
+
function registerElementClaim() {
|
|
1757
|
+
return noopCleanup;
|
|
1758
|
+
}
|
|
1759
|
+
function noopCleanup() {}
|
|
1760
|
+
function claimElement(node) {
|
|
1761
|
+
return node;
|
|
1762
|
+
}
|
|
1763
|
+
function claimElementTree(root) {
|
|
1764
|
+
return root;
|
|
1765
|
+
}
|
|
832
1766
|
function notSup() {
|
|
833
1767
|
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>.");
|
|
834
1768
|
}
|
|
835
1769
|
|
|
1770
|
+
const ENVELOPE = Symbol.for("solid.ResponseEnvelope");
|
|
1771
|
+
class ResponseEnvelope {
|
|
1772
|
+
constructor(response, value) {
|
|
1773
|
+
this.response = response;
|
|
1774
|
+
this.value = value;
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
ResponseEnvelope.prototype[ENVELOPE] = true;
|
|
1778
|
+
function isResponseEnvelope(value) {
|
|
1779
|
+
return !!(value && typeof value === "object" && value[ENVELOPE]);
|
|
1780
|
+
}
|
|
1781
|
+
const HREF = Symbol.for("solid.Href");
|
|
1782
|
+
function isHref(value) {
|
|
1783
|
+
return !!(value && (typeof value === "object" || typeof value === "function") && value[HREF]);
|
|
1784
|
+
}
|
|
1785
|
+
const REVALIDATE_HEADER = "X-Revalidate";
|
|
1786
|
+
function initWithRevalidate(init) {
|
|
1787
|
+
const {
|
|
1788
|
+
revalidate,
|
|
1789
|
+
...responseInit
|
|
1790
|
+
} = init;
|
|
1791
|
+
const headers = new Headers(responseInit.headers);
|
|
1792
|
+
revalidate !== undefined && headers.set(REVALIDATE_HEADER, revalidate.toString());
|
|
1793
|
+
return {
|
|
1794
|
+
responseInit,
|
|
1795
|
+
headers
|
|
1796
|
+
};
|
|
1797
|
+
}
|
|
1798
|
+
function redirect(url, init = 302) {
|
|
1799
|
+
if (typeof url !== "string" && !isHref(url)) {
|
|
1800
|
+
throw new TypeError("redirect() expects a string URL or an Href-branded value (Symbol.for('solid.Href')).");
|
|
1801
|
+
}
|
|
1802
|
+
const {
|
|
1803
|
+
responseInit,
|
|
1804
|
+
headers
|
|
1805
|
+
} = initWithRevalidate(typeof init === "number" ? {
|
|
1806
|
+
status: init
|
|
1807
|
+
} : init);
|
|
1808
|
+
if (responseInit.status === undefined) {
|
|
1809
|
+
responseInit.status = 302;
|
|
1810
|
+
}
|
|
1811
|
+
headers.set("Location", String(url));
|
|
1812
|
+
return new Response(null, {
|
|
1813
|
+
...responseInit,
|
|
1814
|
+
headers
|
|
1815
|
+
});
|
|
1816
|
+
}
|
|
1817
|
+
function reload(init = {}) {
|
|
1818
|
+
const {
|
|
1819
|
+
responseInit,
|
|
1820
|
+
headers
|
|
1821
|
+
} = initWithRevalidate(init);
|
|
1822
|
+
return new Response(null, {
|
|
1823
|
+
...responseInit,
|
|
1824
|
+
headers
|
|
1825
|
+
});
|
|
1826
|
+
}
|
|
1827
|
+
function respond(value, init = {}) {
|
|
1828
|
+
const {
|
|
1829
|
+
responseInit,
|
|
1830
|
+
headers
|
|
1831
|
+
} = initWithRevalidate(init);
|
|
1832
|
+
headers.set("Content-Type", "application/json");
|
|
1833
|
+
return new ResponseEnvelope(new Response(JSON.stringify(value), {
|
|
1834
|
+
...responseInit,
|
|
1835
|
+
headers
|
|
1836
|
+
}), value);
|
|
1837
|
+
}
|
|
1838
|
+
|
|
836
1839
|
const isServer = true;
|
|
837
1840
|
const isDev = false;
|
|
838
|
-
function
|
|
839
|
-
const
|
|
840
|
-
|
|
841
|
-
const memoOwner = solidJs.createOwner();
|
|
842
|
-
return solidJs.runWithOwner(memoOwner, () => {
|
|
843
|
-
const comp = component(),
|
|
844
|
-
t = typeof comp;
|
|
845
|
-
if (comp) {
|
|
846
|
-
if (t === "function") return comp(props);else if (t === "string") {
|
|
847
|
-
return ssrElement(comp, props, undefined, true);
|
|
848
|
-
}
|
|
849
|
-
}
|
|
1841
|
+
function dynamic(source) {
|
|
1842
|
+
const cached = solidJs.createMemo(source, {
|
|
1843
|
+
serialize: false
|
|
850
1844
|
});
|
|
1845
|
+
return props => {
|
|
1846
|
+
return solidJs.createMemo(() => {
|
|
1847
|
+
const c = cached();
|
|
1848
|
+
if (c) {
|
|
1849
|
+
if (typeof c === "function") return c(props);
|
|
1850
|
+
if (typeof c === "string") {
|
|
1851
|
+
return ssrElement(c, props, undefined, true);
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
}, {
|
|
1855
|
+
sync: true
|
|
1856
|
+
});
|
|
1857
|
+
};
|
|
851
1858
|
}
|
|
852
1859
|
function Dynamic(props) {
|
|
853
|
-
const
|
|
854
|
-
return
|
|
1860
|
+
const Comp = dynamic(() => props.component);
|
|
1861
|
+
return solidJs.createComponent(Comp, solidJs.omit(props, "component"));
|
|
855
1862
|
}
|
|
856
1863
|
function Portal(props) {
|
|
857
|
-
|
|
1864
|
+
const o = solidJs.getOwner();
|
|
1865
|
+
if (o?.id != null) solidJs.getNextChildId(o);
|
|
1866
|
+
return undefined;
|
|
1867
|
+
}
|
|
1868
|
+
function registerClientOnlyPreload(moduleUrl) {
|
|
1869
|
+
const ctx = solidJs.sharedConfig.context;
|
|
1870
|
+
if (!ctx?.registerAsset || !ctx.resolveAssets) return;
|
|
1871
|
+
const registerAsset = ctx.registerAsset;
|
|
1872
|
+
const resolve = ctx.resolveAssets;
|
|
1873
|
+
const apply = assets => {
|
|
1874
|
+
if (!assets) return;
|
|
1875
|
+
for (let i = 0; i < assets.css.length; i++) {
|
|
1876
|
+
const css = assets.css[i];
|
|
1877
|
+
if (typeof css === "string") registerAsset("style", css);else registerAsset("inline-style", css);
|
|
1878
|
+
}
|
|
1879
|
+
for (let i = 0; i < assets.js.length; i++) registerAsset("module", assets.js[i]);
|
|
1880
|
+
};
|
|
1881
|
+
const assets = resolve(moduleUrl);
|
|
1882
|
+
if (assets && typeof assets.then === "function") {
|
|
1883
|
+
const boundary = ctx._currentBoundaryId;
|
|
1884
|
+
assets.then(resolved => {
|
|
1885
|
+
const current = ctx._currentBoundaryId;
|
|
1886
|
+
ctx._currentBoundaryId = boundary;
|
|
1887
|
+
try {
|
|
1888
|
+
apply(resolved);
|
|
1889
|
+
} finally {
|
|
1890
|
+
ctx._currentBoundaryId = current;
|
|
1891
|
+
}
|
|
1892
|
+
},
|
|
1893
|
+
() => {});
|
|
1894
|
+
} else {
|
|
1895
|
+
apply(assets);
|
|
1896
|
+
}
|
|
1897
|
+
}
|
|
1898
|
+
function clientOnly(_fn, _options = {}, moduleUrl) {
|
|
1899
|
+
return props => {
|
|
1900
|
+
if (moduleUrl) registerClientOnlyPreload(moduleUrl);
|
|
1901
|
+
return solidJs.createMemo(() => props.fallback);
|
|
1902
|
+
};
|
|
1903
|
+
}
|
|
1904
|
+
function httpStatus(code, text) {
|
|
1905
|
+
const event = getRequestEvent();
|
|
1906
|
+
const response = event && event.response;
|
|
1907
|
+
if (response && !response.committed) {
|
|
1908
|
+
const prevStatus = response.status;
|
|
1909
|
+
const prevStatusText = response.statusText;
|
|
1910
|
+
response.status = code;
|
|
1911
|
+
response.statusText = text;
|
|
1912
|
+
solidJs.onCleanup(() => {
|
|
1913
|
+
if (response.committed) return;
|
|
1914
|
+
response.status = prevStatus;
|
|
1915
|
+
response.statusText = prevStatusText;
|
|
1916
|
+
});
|
|
1917
|
+
}
|
|
1918
|
+
}
|
|
1919
|
+
function httpHeader(name, value, options) {
|
|
1920
|
+
const event = getRequestEvent();
|
|
1921
|
+
const response = event && event.response;
|
|
1922
|
+
if (response && !response.committed) {
|
|
1923
|
+
const headers = response.headers;
|
|
1924
|
+
const prev = headers.get(name);
|
|
1925
|
+
if (options && options.append) headers.append(name, value);else headers.set(name, value);
|
|
1926
|
+
solidJs.onCleanup(() => {
|
|
1927
|
+
if (response.committed) return;
|
|
1928
|
+
if (prev === null) headers.delete(name);else headers.set(name, prev);
|
|
1929
|
+
});
|
|
1930
|
+
}
|
|
858
1931
|
}
|
|
859
1932
|
|
|
860
1933
|
Object.defineProperty(exports, "Errored", {
|
|
@@ -885,6 +1958,10 @@ Object.defineProperty(exports, "Repeat", {
|
|
|
885
1958
|
enumerable: true,
|
|
886
1959
|
get: function () { return solidJs.Repeat; }
|
|
887
1960
|
});
|
|
1961
|
+
Object.defineProperty(exports, "Reveal", {
|
|
1962
|
+
enumerable: true,
|
|
1963
|
+
get: function () { return solidJs.Reveal; }
|
|
1964
|
+
});
|
|
888
1965
|
Object.defineProperty(exports, "Show", {
|
|
889
1966
|
enumerable: true,
|
|
890
1967
|
get: function () { return solidJs.Show; }
|
|
@@ -901,62 +1978,93 @@ Object.defineProperty(exports, "getOwner", {
|
|
|
901
1978
|
enumerable: true,
|
|
902
1979
|
get: function () { return solidJs.getOwner; }
|
|
903
1980
|
});
|
|
904
|
-
Object.defineProperty(exports, "
|
|
1981
|
+
Object.defineProperty(exports, "mergeProps", {
|
|
1982
|
+
enumerable: true,
|
|
1983
|
+
get: function () { return solidJs.merge; }
|
|
1984
|
+
});
|
|
1985
|
+
Object.defineProperty(exports, "scope", {
|
|
905
1986
|
enumerable: true,
|
|
906
|
-
get: function () { return solidJs.
|
|
1987
|
+
get: function () { return solidJs.ssrScope; }
|
|
907
1988
|
});
|
|
908
1989
|
Object.defineProperty(exports, "untrack", {
|
|
909
1990
|
enumerable: true,
|
|
910
1991
|
get: function () { return solidJs.untrack; }
|
|
911
1992
|
});
|
|
1993
|
+
exports.Assets = Assets;
|
|
912
1994
|
exports.ChildProperties = ChildProperties;
|
|
913
1995
|
exports.DOMElements = DOMElements;
|
|
1996
|
+
exports.DOMWithState = DOMWithState;
|
|
914
1997
|
exports.DelegatedEvents = DelegatedEvents;
|
|
915
1998
|
exports.Dynamic = Dynamic;
|
|
1999
|
+
exports.HREF = HREF;
|
|
916
2000
|
exports.HydrationScript = HydrationScript;
|
|
2001
|
+
exports.MathMLElements = MathMLElements;
|
|
2002
|
+
exports.Namespaces = Namespaces;
|
|
917
2003
|
exports.Portal = Portal;
|
|
918
|
-
exports.
|
|
2004
|
+
exports.REVALIDATE_HEADER = REVALIDATE_HEADER;
|
|
2005
|
+
exports.RawTextElements = RawTextElements;
|
|
919
2006
|
exports.RequestContext = RequestContext;
|
|
2007
|
+
exports.ResponseEnvelope = ResponseEnvelope;
|
|
920
2008
|
exports.SVGElements = SVGElements;
|
|
921
|
-
exports.
|
|
922
|
-
exports.
|
|
2009
|
+
exports.VoidElements = VoidElements;
|
|
2010
|
+
exports.acquireAsset = notSup;
|
|
2011
|
+
exports.addEvent = notSup;
|
|
923
2012
|
exports.applyRef = applyRef;
|
|
924
2013
|
exports.assign = notSup;
|
|
2014
|
+
exports.claimElement = claimElement;
|
|
2015
|
+
exports.claimElementTree = claimElementTree;
|
|
925
2016
|
exports.className = notSup;
|
|
926
|
-
exports.
|
|
2017
|
+
exports.clientOnly = clientOnly;
|
|
927
2018
|
exports.delegateEvents = notSup;
|
|
2019
|
+
exports.dynamic = dynamic;
|
|
928
2020
|
exports.dynamicProperty = notSup;
|
|
929
2021
|
exports.effect = effect;
|
|
930
2022
|
exports.escape = escape;
|
|
931
2023
|
exports.generateHydrationScript = generateHydrationScript;
|
|
932
2024
|
exports.getAssets = getAssets;
|
|
2025
|
+
exports.getDelegatedRoot = notSup;
|
|
933
2026
|
exports.getHydrationKey = getHydrationKey;
|
|
934
2027
|
exports.getNextElement = notSup;
|
|
935
2028
|
exports.getNextMarker = notSup;
|
|
936
2029
|
exports.getNextMatch = notSup;
|
|
937
2030
|
exports.getRequestEvent = getRequestEvent;
|
|
2031
|
+
exports.httpHeader = httpHeader;
|
|
2032
|
+
exports.httpStatus = httpStatus;
|
|
938
2033
|
exports.hydrate = notSup;
|
|
939
2034
|
exports.insert = notSup;
|
|
940
2035
|
exports.isDev = isDev;
|
|
2036
|
+
exports.isHref = isHref;
|
|
2037
|
+
exports.isResponseEnvelope = isResponseEnvelope;
|
|
941
2038
|
exports.isServer = isServer;
|
|
942
2039
|
exports.memo = memo;
|
|
943
|
-
exports.
|
|
2040
|
+
exports.redirect = redirect;
|
|
2041
|
+
exports.ref = notSup;
|
|
2042
|
+
exports.registerDelegatedContainer = notSup;
|
|
2043
|
+
exports.registerDelegatedRoot = notSup;
|
|
2044
|
+
exports.registerElementClaim = registerElementClaim;
|
|
2045
|
+
exports.reload = reload;
|
|
944
2046
|
exports.render = notSup;
|
|
945
2047
|
exports.renderToStream = renderToStream;
|
|
946
2048
|
exports.renderToString = renderToString;
|
|
947
2049
|
exports.renderToStringAsync = renderToStringAsync;
|
|
2050
|
+
exports.respond = respond;
|
|
948
2051
|
exports.runHydrationEvents = notSup;
|
|
949
2052
|
exports.setAttribute = notSup;
|
|
950
2053
|
exports.setAttributeNS = notSup;
|
|
951
2054
|
exports.setProperty = notSup;
|
|
2055
|
+
exports.setStyleProperty = notSup;
|
|
952
2056
|
exports.spread = notSup;
|
|
953
2057
|
exports.ssr = ssr;
|
|
954
2058
|
exports.ssrAttribute = ssrAttribute;
|
|
955
2059
|
exports.ssrClassName = ssrClassName;
|
|
956
2060
|
exports.ssrElement = ssrElement;
|
|
2061
|
+
exports.ssrGroup = ssrGroup;
|
|
957
2062
|
exports.ssrHydrationKey = ssrHydrationKey;
|
|
958
2063
|
exports.ssrStyle = ssrStyle;
|
|
959
2064
|
exports.ssrStyleProperty = ssrStyleProperty;
|
|
960
2065
|
exports.style = notSup;
|
|
961
2066
|
exports.template = notSup;
|
|
2067
|
+
exports.unregisterDelegatedContainer = notSup;
|
|
2068
|
+
exports.unregisterDelegatedRoot = notSup;
|
|
962
2069
|
exports.useAssets = useAssets;
|
|
2070
|
+
exports.useHead = useHead;
|