@solidjs/web 2.0.0-beta.21 → 2.0.0-beta.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev.cjs +51 -1
- package/dist/dev.js +47 -2
- package/dist/server.cjs +98 -34
- package/dist/server.js +94 -35
- package/dist/web.cjs +51 -1
- package/dist/web.js +47 -2
- package/frames/dist/client.cjs +1442 -0
- package/frames/dist/client.js +1430 -0
- package/frames/dist/server.cjs +1705 -0
- package/frames/dist/server.js +1694 -0
- package/frames/package.json +30 -0
- package/package.json +78 -5
- package/serialization/dist/serialization.cjs +83 -0
- package/serialization/dist/serialization.js +82 -1
- package/serialization/types/index.d.ts +12 -0
- package/serialization/types-cjs/index.d.cts +12 -0
- package/server-functions/dist/client.cjs +114 -59
- package/server-functions/dist/client.js +113 -61
- package/server-functions/dist/server.cjs +54 -10
- package/server-functions/dist/server.js +52 -11
- package/types/client.d.ts +26 -0
- package/types/core.d.ts +2 -1
- package/types/frames/client.d.ts +53 -0
- package/types/frames/frame-client.d.ts +205 -0
- package/types/frames/frame-sink.d.ts +145 -0
- package/types/frames/frame-transport.d.ts +105 -0
- package/types/frames/serializer.d.ts +151 -0
- package/types/frames/server.d.ts +21 -0
- package/types/jsx.d.ts +17 -2
- package/types/response.d.ts +27 -1
- package/types/serializer.d.ts +12 -0
- package/types/server-functions/client.d.ts +40 -5
- package/types/server-functions/server.d.ts +9 -5
- package/types/server-functions/shared.d.ts +29 -0
- package/types/server.d.ts +10 -0
- package/types-cjs/client.d.cts +26 -0
- package/types-cjs/core.d.cts +2 -1
- package/types-cjs/frames/client.d.cts +53 -0
- package/types-cjs/frames/frame-client.d.cts +205 -0
- package/types-cjs/frames/frame-sink.d.cts +145 -0
- package/types-cjs/frames/frame-transport.d.cts +105 -0
- package/types-cjs/frames/serializer.d.cts +151 -0
- package/types-cjs/frames/server.d.cts +21 -0
- package/types-cjs/jsx.d.cts +17 -2
- package/types-cjs/response.d.cts +27 -1
- package/types-cjs/serializer.d.cts +12 -0
- package/types-cjs/server-functions/client.d.cts +40 -5
- package/types-cjs/server-functions/server.d.cts +9 -5
- package/types-cjs/server-functions/shared.d.cts +29 -0
- package/types-cjs/server.d.cts +10 -0
package/dist/dev.cjs
CHANGED
|
@@ -33,6 +33,7 @@ const DOMWithState = {
|
|
|
33
33
|
const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
|
|
34
34
|
const $$SLOT = /*#__PURE__*/Symbol("slot");
|
|
35
35
|
const $$HOST = /*#__PURE__*/Symbol("host");
|
|
36
|
+
const $$FRAME = /*#__PURE__*/Symbol.for("dom-expressions.frame");
|
|
36
37
|
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"]);
|
|
37
38
|
const SVGElements = /*#__PURE__*/new Set([
|
|
38
39
|
"altGlyph", "altGlyphDef", "altGlyphItem", "animate", "animateColor", "animateMotion", "animateTransform", "circle", "clipPath", "color-profile", "cursor", "defs", "desc", "ellipse", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence", "filter", "font", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignObject", "g", "glyph", "glyphRef", "hkern", "image", "line", "linearGradient", "marker", "mask", "metadata", "missing-glyph", "mpath", "path", "pattern", "polygon", "polyline", "radialGradient", "rect",
|
|
@@ -282,9 +283,40 @@ function setProperty(node, name, value) {
|
|
|
282
283
|
if (isHydrating(node)) return;
|
|
283
284
|
node[name] = value;
|
|
284
285
|
}
|
|
286
|
+
let claimHandlers = null;
|
|
287
|
+
const CLAIM_SEAM = Symbol.for("dom-expressions.element-claims");
|
|
288
|
+
function registerElementClaim(handler) {
|
|
289
|
+
(claimHandlers || (claimHandlers = globalThis[CLAIM_SEAM] = [])).push(handler);
|
|
290
|
+
return () => {
|
|
291
|
+
const index = claimHandlers.indexOf(handler);
|
|
292
|
+
index > -1 && claimHandlers.splice(index, 1);
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
const CLAIMED_ELEMENTS = "a[href], form[action]";
|
|
296
|
+
function claimElementTree(root) {
|
|
297
|
+
const handlers = globalThis[CLAIM_SEAM];
|
|
298
|
+
if (handlers === undefined || handlers.length === 0) return root;
|
|
299
|
+
const isElement = root.nodeType === 1;
|
|
300
|
+
if (!isElement && root.nodeType !== 11) return root;
|
|
301
|
+
if (isElement && root.matches(CLAIMED_ELEMENTS)) {
|
|
302
|
+
for (let i = 0; i < handlers.length; i++) handlers[i](root);
|
|
303
|
+
}
|
|
304
|
+
const found = root.querySelectorAll(CLAIMED_ELEMENTS);
|
|
305
|
+
for (let i = 0; i < found.length; i++) {
|
|
306
|
+
for (let j = 0; j < handlers.length; j++) handlers[j](found[i]);
|
|
307
|
+
}
|
|
308
|
+
return root;
|
|
309
|
+
}
|
|
310
|
+
function claimElement(node) {
|
|
311
|
+
if (claimHandlers !== null) {
|
|
312
|
+
for (let i = 0; i < claimHandlers.length; i++) claimHandlers[i](node);
|
|
313
|
+
}
|
|
314
|
+
return node;
|
|
315
|
+
}
|
|
285
316
|
function setAttribute(node, name, value) {
|
|
286
317
|
if (isHydrating(node)) return;
|
|
287
318
|
if (value == null || value === false) node.removeAttribute(name);else node.setAttribute(name, value === true ? "" : value);
|
|
319
|
+
if (claimHandlers !== null && (name === "href" || name === "action")) claimElement(node);
|
|
288
320
|
}
|
|
289
321
|
function setAttributeNS(node, namespace, name, value) {
|
|
290
322
|
if (isHydrating(node)) return;
|
|
@@ -993,6 +1025,11 @@ function insertExpression(parent, value, current, marker) {
|
|
|
993
1025
|
parent.appendChild(value);
|
|
994
1026
|
}
|
|
995
1027
|
if (marker) value[$$SLOT] = marker;
|
|
1028
|
+
} else if (value[$$FRAME]) {
|
|
1029
|
+
if (current) {
|
|
1030
|
+
cleanChildren(parent, Array.isArray(current) ? current : [current], multi ? marker : null);
|
|
1031
|
+
}
|
|
1032
|
+
value[$$FRAME](parent, multi ? marker : null);
|
|
996
1033
|
} else if (Array.isArray(value)) {
|
|
997
1034
|
const currentArray = current && Array.isArray(current);
|
|
998
1035
|
if (value.length === 0) {
|
|
@@ -1013,6 +1050,7 @@ function normalize(value, current, multi, doNotUnwrap) {
|
|
|
1013
1050
|
doNotUnwrap
|
|
1014
1051
|
});
|
|
1015
1052
|
if (doNotUnwrap && typeof value === "function") return value;
|
|
1053
|
+
if (value != null && value[$$FRAME]) return value;
|
|
1016
1054
|
if (multi && !Array.isArray(value)) value = [value != null ? value : ""];
|
|
1017
1055
|
if (Array.isArray(value)) {
|
|
1018
1056
|
for (let i = 0, len = value.length; i < len; i++) {
|
|
@@ -1130,6 +1168,10 @@ ResponseEnvelope.prototype[ENVELOPE] = true;
|
|
|
1130
1168
|
function isResponseEnvelope(value) {
|
|
1131
1169
|
return !!(value && typeof value === "object" && value[ENVELOPE]);
|
|
1132
1170
|
}
|
|
1171
|
+
const HREF = Symbol.for("solid.Href");
|
|
1172
|
+
function isHref(value) {
|
|
1173
|
+
return !!(value && (typeof value === "object" || typeof value === "function") && value[HREF]);
|
|
1174
|
+
}
|
|
1133
1175
|
function initWithRevalidate(init) {
|
|
1134
1176
|
const {
|
|
1135
1177
|
revalidate,
|
|
@@ -1143,6 +1185,9 @@ function initWithRevalidate(init) {
|
|
|
1143
1185
|
};
|
|
1144
1186
|
}
|
|
1145
1187
|
function redirect(url, init = 302) {
|
|
1188
|
+
if (typeof url !== "string" && !isHref(url)) {
|
|
1189
|
+
throw new TypeError("redirect() expects a string URL or an Href-branded value (Symbol.for('solid.Href')).");
|
|
1190
|
+
}
|
|
1146
1191
|
const {
|
|
1147
1192
|
responseInit,
|
|
1148
1193
|
headers
|
|
@@ -1152,7 +1197,7 @@ function redirect(url, init = 302) {
|
|
|
1152
1197
|
if (responseInit.status === undefined) {
|
|
1153
1198
|
responseInit.status = 302;
|
|
1154
1199
|
}
|
|
1155
|
-
headers.set("Location", url);
|
|
1200
|
+
headers.set("Location", String(url));
|
|
1156
1201
|
return new Response(null, {
|
|
1157
1202
|
...responseInit,
|
|
1158
1203
|
headers
|
|
@@ -1341,6 +1386,7 @@ exports.DOMElements = DOMElements;
|
|
|
1341
1386
|
exports.DOMWithState = DOMWithState;
|
|
1342
1387
|
exports.DelegatedEvents = DelegatedEvents;
|
|
1343
1388
|
exports.Dynamic = Dynamic;
|
|
1389
|
+
exports.HREF = HREF;
|
|
1344
1390
|
exports.HydrationScript = voidFn;
|
|
1345
1391
|
exports.MathMLElements = MathMLElements;
|
|
1346
1392
|
exports.Namespaces = Namespaces;
|
|
@@ -1354,6 +1400,8 @@ exports.acquireAsset = acquireAsset;
|
|
|
1354
1400
|
exports.addEvent = addEvent;
|
|
1355
1401
|
exports.applyRef = applyRef;
|
|
1356
1402
|
exports.assign = assign;
|
|
1403
|
+
exports.claimElement = claimElement;
|
|
1404
|
+
exports.claimElementTree = claimElementTree;
|
|
1357
1405
|
exports.className = className;
|
|
1358
1406
|
exports.delegateEvents = delegateEvents;
|
|
1359
1407
|
exports.dynamic = dynamic;
|
|
@@ -1374,6 +1422,7 @@ exports.hydrate = hydrate;
|
|
|
1374
1422
|
exports.insert = insert;
|
|
1375
1423
|
exports.installHydrationRuntime = installHydrationRuntime;
|
|
1376
1424
|
exports.isDev = isDev;
|
|
1425
|
+
exports.isHref = isHref;
|
|
1377
1426
|
exports.isResponseEnvelope = isResponseEnvelope;
|
|
1378
1427
|
exports.isServer = isServer;
|
|
1379
1428
|
exports.memo = memo;
|
|
@@ -1382,6 +1431,7 @@ exports.redirect = redirect;
|
|
|
1382
1431
|
exports.ref = ref;
|
|
1383
1432
|
exports.registerDelegatedContainer = registerDelegatedContainer;
|
|
1384
1433
|
exports.registerDelegatedRoot = registerDelegatedRoot;
|
|
1434
|
+
exports.registerElementClaim = registerElementClaim;
|
|
1385
1435
|
exports.reload = reload;
|
|
1386
1436
|
exports.render = render;
|
|
1387
1437
|
exports.renderToStream = renderToStream;
|
package/dist/dev.js
CHANGED
|
@@ -32,6 +32,7 @@ const DOMWithState = {
|
|
|
32
32
|
const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
|
|
33
33
|
const $$SLOT = /*#__PURE__*/Symbol("slot");
|
|
34
34
|
const $$HOST = /*#__PURE__*/Symbol("host");
|
|
35
|
+
const $$FRAME = /*#__PURE__*/Symbol.for("dom-expressions.frame");
|
|
35
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"]);
|
|
36
37
|
const SVGElements = /*#__PURE__*/new Set([
|
|
37
38
|
"altGlyph", "altGlyphDef", "altGlyphItem", "animate", "animateColor", "animateMotion", "animateTransform", "circle", "clipPath", "color-profile", "cursor", "defs", "desc", "ellipse", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence", "filter", "font", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignObject", "g", "glyph", "glyphRef", "hkern", "image", "line", "linearGradient", "marker", "mask", "metadata", "missing-glyph", "mpath", "path", "pattern", "polygon", "polyline", "radialGradient", "rect",
|
|
@@ -281,9 +282,40 @@ function setProperty(node, name, value) {
|
|
|
281
282
|
if (isHydrating(node)) return;
|
|
282
283
|
node[name] = value;
|
|
283
284
|
}
|
|
285
|
+
let claimHandlers = null;
|
|
286
|
+
const CLAIM_SEAM = Symbol.for("dom-expressions.element-claims");
|
|
287
|
+
function registerElementClaim(handler) {
|
|
288
|
+
(claimHandlers || (claimHandlers = globalThis[CLAIM_SEAM] = [])).push(handler);
|
|
289
|
+
return () => {
|
|
290
|
+
const index = claimHandlers.indexOf(handler);
|
|
291
|
+
index > -1 && claimHandlers.splice(index, 1);
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
const CLAIMED_ELEMENTS = "a[href], form[action]";
|
|
295
|
+
function claimElementTree(root) {
|
|
296
|
+
const handlers = globalThis[CLAIM_SEAM];
|
|
297
|
+
if (handlers === undefined || handlers.length === 0) return root;
|
|
298
|
+
const isElement = root.nodeType === 1;
|
|
299
|
+
if (!isElement && root.nodeType !== 11) return root;
|
|
300
|
+
if (isElement && root.matches(CLAIMED_ELEMENTS)) {
|
|
301
|
+
for (let i = 0; i < handlers.length; i++) handlers[i](root);
|
|
302
|
+
}
|
|
303
|
+
const found = root.querySelectorAll(CLAIMED_ELEMENTS);
|
|
304
|
+
for (let i = 0; i < found.length; i++) {
|
|
305
|
+
for (let j = 0; j < handlers.length; j++) handlers[j](found[i]);
|
|
306
|
+
}
|
|
307
|
+
return root;
|
|
308
|
+
}
|
|
309
|
+
function claimElement(node) {
|
|
310
|
+
if (claimHandlers !== null) {
|
|
311
|
+
for (let i = 0; i < claimHandlers.length; i++) claimHandlers[i](node);
|
|
312
|
+
}
|
|
313
|
+
return node;
|
|
314
|
+
}
|
|
284
315
|
function setAttribute(node, name, value) {
|
|
285
316
|
if (isHydrating(node)) return;
|
|
286
317
|
if (value == null || value === false) node.removeAttribute(name);else node.setAttribute(name, value === true ? "" : value);
|
|
318
|
+
if (claimHandlers !== null && (name === "href" || name === "action")) claimElement(node);
|
|
287
319
|
}
|
|
288
320
|
function setAttributeNS(node, namespace, name, value) {
|
|
289
321
|
if (isHydrating(node)) return;
|
|
@@ -992,6 +1024,11 @@ function insertExpression(parent, value, current, marker) {
|
|
|
992
1024
|
parent.appendChild(value);
|
|
993
1025
|
}
|
|
994
1026
|
if (marker) value[$$SLOT] = marker;
|
|
1027
|
+
} else if (value[$$FRAME]) {
|
|
1028
|
+
if (current) {
|
|
1029
|
+
cleanChildren(parent, Array.isArray(current) ? current : [current], multi ? marker : null);
|
|
1030
|
+
}
|
|
1031
|
+
value[$$FRAME](parent, multi ? marker : null);
|
|
995
1032
|
} else if (Array.isArray(value)) {
|
|
996
1033
|
const currentArray = current && Array.isArray(current);
|
|
997
1034
|
if (value.length === 0) {
|
|
@@ -1012,6 +1049,7 @@ function normalize(value, current, multi, doNotUnwrap) {
|
|
|
1012
1049
|
doNotUnwrap
|
|
1013
1050
|
});
|
|
1014
1051
|
if (doNotUnwrap && typeof value === "function") return value;
|
|
1052
|
+
if (value != null && value[$$FRAME]) return value;
|
|
1015
1053
|
if (multi && !Array.isArray(value)) value = [value != null ? value : ""];
|
|
1016
1054
|
if (Array.isArray(value)) {
|
|
1017
1055
|
for (let i = 0, len = value.length; i < len; i++) {
|
|
@@ -1129,6 +1167,10 @@ ResponseEnvelope.prototype[ENVELOPE] = true;
|
|
|
1129
1167
|
function isResponseEnvelope(value) {
|
|
1130
1168
|
return !!(value && typeof value === "object" && value[ENVELOPE]);
|
|
1131
1169
|
}
|
|
1170
|
+
const HREF = Symbol.for("solid.Href");
|
|
1171
|
+
function isHref(value) {
|
|
1172
|
+
return !!(value && (typeof value === "object" || typeof value === "function") && value[HREF]);
|
|
1173
|
+
}
|
|
1132
1174
|
function initWithRevalidate(init) {
|
|
1133
1175
|
const {
|
|
1134
1176
|
revalidate,
|
|
@@ -1142,6 +1184,9 @@ function initWithRevalidate(init) {
|
|
|
1142
1184
|
};
|
|
1143
1185
|
}
|
|
1144
1186
|
function redirect(url, init = 302) {
|
|
1187
|
+
if (typeof url !== "string" && !isHref(url)) {
|
|
1188
|
+
throw new TypeError("redirect() expects a string URL or an Href-branded value (Symbol.for('solid.Href')).");
|
|
1189
|
+
}
|
|
1145
1190
|
const {
|
|
1146
1191
|
responseInit,
|
|
1147
1192
|
headers
|
|
@@ -1151,7 +1196,7 @@ function redirect(url, init = 302) {
|
|
|
1151
1196
|
if (responseInit.status === undefined) {
|
|
1152
1197
|
responseInit.status = 302;
|
|
1153
1198
|
}
|
|
1154
|
-
headers.set("Location", url);
|
|
1199
|
+
headers.set("Location", String(url));
|
|
1155
1200
|
return new Response(null, {
|
|
1156
1201
|
...responseInit,
|
|
1157
1202
|
headers
|
|
@@ -1282,4 +1327,4 @@ function createElement(tagName, is = undefined) {
|
|
|
1282
1327
|
});
|
|
1283
1328
|
}
|
|
1284
1329
|
|
|
1285
|
-
export { voidFn as Assets, ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, voidFn as HydrationScript, MathMLElements, Namespaces, Portal, RawTextElements, RequestContext, ResponseEnvelope, SVGElements, VoidElements, acquireAsset, addEvent, applyRef, assign, className, delegateEvents, dynamic, dynamicProperty, effect, escape, voidFn as generateHydrationScript, voidFn as getAssets, getDelegatedRoot, getFirstChild, getHydrationKey, getNextElement, getNextMarker, getNextMatch, getNextSibling, voidFn as getRequestEvent, hydrate, insert, installHydrationRuntime, isDev, isResponseEnvelope, isServer, memo, mergeProps, redirect, ref, registerDelegatedContainer, registerDelegatedRoot, reload, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, respond, runHydrationEvents, scope, setAttribute, setAttributeNS, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrStyle, style, template, unregisterDelegatedContainer, unregisterDelegatedRoot, voidFn as useAssets };
|
|
1330
|
+
export { voidFn as Assets, ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF, voidFn as HydrationScript, MathMLElements, Namespaces, Portal, RawTextElements, RequestContext, ResponseEnvelope, SVGElements, VoidElements, acquireAsset, addEvent, applyRef, assign, claimElement, claimElementTree, className, delegateEvents, dynamic, dynamicProperty, effect, escape, voidFn as generateHydrationScript, voidFn as getAssets, getDelegatedRoot, getFirstChild, getHydrationKey, getNextElement, getNextMarker, getNextMatch, getNextSibling, voidFn as getRequestEvent, hydrate, insert, installHydrationRuntime, isDev, isHref, isResponseEnvelope, isServer, memo, mergeProps, redirect, ref, registerDelegatedContainer, registerDelegatedRoot, registerElementClaim, reload, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, respond, runHydrationEvents, scope, setAttribute, setAttributeNS, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrStyle, style, template, unregisterDelegatedContainer, unregisterDelegatedRoot, voidFn as useAssets };
|
package/dist/server.cjs
CHANGED
|
@@ -328,10 +328,53 @@ function renderToStream(code, options = {}) {
|
|
|
328
328
|
completed = true;
|
|
329
329
|
if (firstFlushed) dispose();
|
|
330
330
|
};
|
|
331
|
-
const
|
|
331
|
+
const sink = {
|
|
332
|
+
data(payload) {
|
|
333
|
+
pushTask(payload);
|
|
334
|
+
},
|
|
335
|
+
fragment(key, value, meta) {
|
|
336
|
+
const deferActivation = !!meta.revealGroup;
|
|
337
|
+
const styles = meta.styles;
|
|
338
|
+
for (let i = 0; i < styles.inline.length; i++) {
|
|
339
|
+
buffer.write(renderInlineStyle(styles.inline[i], nonce));
|
|
340
|
+
}
|
|
341
|
+
if (styles.links.length) {
|
|
342
|
+
emitTask(`$dfs("${key}",${styles.links.length},${deferActivation ? 1 : 0})`);
|
|
343
|
+
writeTasks();
|
|
344
|
+
for (const url of styles.links) {
|
|
345
|
+
buffer.write(`<link rel="stylesheet" href="${url}" onload="$dfc('${key}')" onerror="$dfc('${key}')">`);
|
|
346
|
+
}
|
|
347
|
+
buffer.write(`<template id="${key}">${value}</template>`);
|
|
348
|
+
} else {
|
|
349
|
+
buffer.write(`<template id="${key}">${value}</template>`);
|
|
350
|
+
if (!deferActivation) {
|
|
351
|
+
emitTask(`$df("${key}")`);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
},
|
|
355
|
+
reveal(keys, meta) {
|
|
356
|
+
emitTask(`${meta.fallback ? "$dflj" : "$dfj"}(${JSON.stringify(keys)})`);
|
|
357
|
+
},
|
|
358
|
+
asset(type, value) {
|
|
359
|
+
if (type === "module") {
|
|
360
|
+
buffer.write(`<link rel="modulepreload" href="${value}">`);
|
|
361
|
+
} else if (type === "inline-style") {
|
|
362
|
+
buffer.write(renderInlineStyle(value, nonce));
|
|
363
|
+
}
|
|
364
|
+
},
|
|
365
|
+
shell(shellHtml, meta) {
|
|
366
|
+
shellHtml = injectBeforeHead(shellHtml, meta.assets);
|
|
367
|
+
shellHtml = injectPreloadLinks(meta.preloads, shellHtml);
|
|
368
|
+
shellHtml = injectInlineStyles(meta.inlineStyles, shellHtml, nonce);
|
|
369
|
+
if (meta.tasks.length) shellHtml = injectScripts(shellHtml, meta.tasks, nonce);
|
|
370
|
+
buffer.write(shellHtml);
|
|
371
|
+
},
|
|
372
|
+
...options.sink
|
|
373
|
+
};
|
|
374
|
+
const serializer = (options.serializer || createHydrationSerializer)({
|
|
332
375
|
scopeId: options.renderId,
|
|
333
376
|
plugins: options.plugins,
|
|
334
|
-
onData:
|
|
377
|
+
onData: payload => sink.data(payload),
|
|
335
378
|
onDone,
|
|
336
379
|
onError: options.onError
|
|
337
380
|
});
|
|
@@ -405,7 +448,7 @@ function renderToStream(code, options = {}) {
|
|
|
405
448
|
const entry = tracking.registerInlineStyle(value);
|
|
406
449
|
if (firstFlushed && !tracking.currentBoundaryId && !entry.emitted) {
|
|
407
450
|
entry.emitted = true;
|
|
408
|
-
|
|
451
|
+
sink.asset("inline-style", entry);
|
|
409
452
|
}
|
|
410
453
|
return;
|
|
411
454
|
}
|
|
@@ -419,9 +462,7 @@ function renderToStream(code, options = {}) {
|
|
|
419
462
|
}
|
|
420
463
|
if (!tracking.emittedAssets.has(value)) {
|
|
421
464
|
tracking.emittedAssets.add(value);
|
|
422
|
-
if (firstFlushed
|
|
423
|
-
buffer.write(`<link rel="modulepreload" href="${value}">`);
|
|
424
|
-
}
|
|
465
|
+
if (firstFlushed) sink.asset(type, value);
|
|
425
466
|
}
|
|
426
467
|
},
|
|
427
468
|
block(p) {
|
|
@@ -503,23 +544,11 @@ function renderToStream(code, options = {}) {
|
|
|
503
544
|
} else {
|
|
504
545
|
serializeFragmentAssets(key, tracking.boundaryModules, context);
|
|
505
546
|
const styles = collectStreamStyles(key, tracking, headStyles);
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
emitTask(`$dfs("${key}",${styles.links.length},${deferActivation ? 1 : 0})`);
|
|
512
|
-
writeTasks();
|
|
513
|
-
for (const url of styles.links) {
|
|
514
|
-
buffer.write(`<link rel="stylesheet" href="${url}" onload="$dfc('${key}')" onerror="$dfc('${key}')">`);
|
|
515
|
-
}
|
|
516
|
-
buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`);
|
|
517
|
-
} else {
|
|
518
|
-
buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`);
|
|
519
|
-
if (!deferActivation) {
|
|
520
|
-
emitTask(`$df("${key}")`);
|
|
521
|
-
}
|
|
522
|
-
}
|
|
547
|
+
sink.fragment(key, value !== undefined ? value : " ", {
|
|
548
|
+
styles,
|
|
549
|
+
revealGroup,
|
|
550
|
+
error
|
|
551
|
+
});
|
|
523
552
|
item.resolve(error);
|
|
524
553
|
}
|
|
525
554
|
}
|
|
@@ -530,12 +559,16 @@ function renderToStream(code, options = {}) {
|
|
|
530
559
|
revealFragments(groupOrKeys) {
|
|
531
560
|
const keys = resolveRevealKeys(groupOrKeys, true, true);
|
|
532
561
|
if (!keys) return;
|
|
533
|
-
|
|
562
|
+
sink.reveal(keys, {
|
|
563
|
+
fallback: false
|
|
564
|
+
});
|
|
534
565
|
},
|
|
535
566
|
revealFallbacks(groupOrKeys) {
|
|
536
567
|
const keys = resolveRevealKeys(groupOrKeys, false, false);
|
|
537
568
|
if (!keys) return;
|
|
538
|
-
|
|
569
|
+
sink.reveal(keys, {
|
|
570
|
+
fallback: true
|
|
571
|
+
});
|
|
539
572
|
}
|
|
540
573
|
};
|
|
541
574
|
applyAssetTracking(context, tracking, manifest);
|
|
@@ -595,16 +628,18 @@ function renderToStream(code, options = {}) {
|
|
|
595
628
|
if (shellCompleted) return;
|
|
596
629
|
if (!resolveRootHoles()) return;
|
|
597
630
|
solidJs.sharedConfig.context = context;
|
|
598
|
-
|
|
631
|
+
const assetsHtml = resolveAssetsHtml(context.assets);
|
|
599
632
|
headStyles = new Set();
|
|
600
633
|
for (const url of tracking.emittedAssets) {
|
|
601
634
|
if (url.endsWith(".css")) headStyles.add(url);
|
|
602
635
|
}
|
|
603
|
-
html = injectPreloadLinks(tracking.emittedAssets, html);
|
|
604
|
-
html = injectInlineStyles(tracking.inlineStyles, html, nonce);
|
|
605
636
|
serializeRootAssets();
|
|
606
|
-
|
|
607
|
-
|
|
637
|
+
sink.shell(html, {
|
|
638
|
+
assets: assetsHtml,
|
|
639
|
+
preloads: tracking.emittedAssets,
|
|
640
|
+
inlineStyles: tracking.inlineStyles,
|
|
641
|
+
tasks
|
|
642
|
+
});
|
|
608
643
|
tasks = "";
|
|
609
644
|
onCompleteShell && onCompleteShell({
|
|
610
645
|
write(v) {
|
|
@@ -1054,13 +1089,20 @@ function allSettled(promises) {
|
|
|
1054
1089
|
return;
|
|
1055
1090
|
});
|
|
1056
1091
|
}
|
|
1057
|
-
function
|
|
1058
|
-
if (!assets || !assets.length) return
|
|
1092
|
+
function resolveAssetsHtml(assets) {
|
|
1093
|
+
if (!assets || !assets.length) return "";
|
|
1059
1094
|
let out = "";
|
|
1060
1095
|
for (let i = 0, len = assets.length; i < len; i++) out += assets[i]();
|
|
1096
|
+
return out;
|
|
1097
|
+
}
|
|
1098
|
+
function injectBeforeHead(html, content) {
|
|
1099
|
+
if (!content) return html;
|
|
1061
1100
|
const index = html.indexOf("</head>");
|
|
1062
1101
|
if (index === -1) return html;
|
|
1063
|
-
return html.slice(0, index) +
|
|
1102
|
+
return html.slice(0, index) + content + html.slice(index);
|
|
1103
|
+
}
|
|
1104
|
+
function injectAssets(assets, html) {
|
|
1105
|
+
return injectBeforeHead(html, resolveAssetsHtml(assets));
|
|
1064
1106
|
}
|
|
1065
1107
|
function injectPreloadLinks(emittedAssets, html, nonce) {
|
|
1066
1108
|
if (!emittedAssets.size) return html;
|
|
@@ -1272,6 +1314,16 @@ function getRequestEvent() {
|
|
|
1272
1314
|
function renderToStringAsync(code, options = {}) {
|
|
1273
1315
|
return new Promise(resolve => renderToStream(code, options).then(resolve));
|
|
1274
1316
|
}
|
|
1317
|
+
function registerElementClaim() {
|
|
1318
|
+
return noopCleanup;
|
|
1319
|
+
}
|
|
1320
|
+
function noopCleanup() {}
|
|
1321
|
+
function claimElement(node) {
|
|
1322
|
+
return node;
|
|
1323
|
+
}
|
|
1324
|
+
function claimElementTree(root) {
|
|
1325
|
+
return root;
|
|
1326
|
+
}
|
|
1275
1327
|
function notSup() {
|
|
1276
1328
|
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>.");
|
|
1277
1329
|
}
|
|
@@ -1287,6 +1339,10 @@ ResponseEnvelope.prototype[ENVELOPE] = true;
|
|
|
1287
1339
|
function isResponseEnvelope(value) {
|
|
1288
1340
|
return !!(value && typeof value === "object" && value[ENVELOPE]);
|
|
1289
1341
|
}
|
|
1342
|
+
const HREF = Symbol.for("solid.Href");
|
|
1343
|
+
function isHref(value) {
|
|
1344
|
+
return !!(value && (typeof value === "object" || typeof value === "function") && value[HREF]);
|
|
1345
|
+
}
|
|
1290
1346
|
function initWithRevalidate(init) {
|
|
1291
1347
|
const {
|
|
1292
1348
|
revalidate,
|
|
@@ -1300,6 +1356,9 @@ function initWithRevalidate(init) {
|
|
|
1300
1356
|
};
|
|
1301
1357
|
}
|
|
1302
1358
|
function redirect(url, init = 302) {
|
|
1359
|
+
if (typeof url !== "string" && !isHref(url)) {
|
|
1360
|
+
throw new TypeError("redirect() expects a string URL or an Href-branded value (Symbol.for('solid.Href')).");
|
|
1361
|
+
}
|
|
1303
1362
|
const {
|
|
1304
1363
|
responseInit,
|
|
1305
1364
|
headers
|
|
@@ -1309,7 +1368,7 @@ function redirect(url, init = 302) {
|
|
|
1309
1368
|
if (responseInit.status === undefined) {
|
|
1310
1369
|
responseInit.status = 302;
|
|
1311
1370
|
}
|
|
1312
|
-
headers.set("Location", url);
|
|
1371
|
+
headers.set("Location", String(url));
|
|
1313
1372
|
return new Response(null, {
|
|
1314
1373
|
...responseInit,
|
|
1315
1374
|
headers
|
|
@@ -1454,6 +1513,7 @@ exports.DOMElements = DOMElements;
|
|
|
1454
1513
|
exports.DOMWithState = DOMWithState;
|
|
1455
1514
|
exports.DelegatedEvents = DelegatedEvents;
|
|
1456
1515
|
exports.Dynamic = Dynamic;
|
|
1516
|
+
exports.HREF = HREF;
|
|
1457
1517
|
exports.HydrationScript = HydrationScript;
|
|
1458
1518
|
exports.MathMLElements = MathMLElements;
|
|
1459
1519
|
exports.Namespaces = Namespaces;
|
|
@@ -1467,6 +1527,8 @@ exports.acquireAsset = notSup;
|
|
|
1467
1527
|
exports.addEvent = notSup;
|
|
1468
1528
|
exports.applyRef = applyRef;
|
|
1469
1529
|
exports.assign = notSup;
|
|
1530
|
+
exports.claimElement = claimElement;
|
|
1531
|
+
exports.claimElementTree = claimElementTree;
|
|
1470
1532
|
exports.className = notSup;
|
|
1471
1533
|
exports.delegateEvents = notSup;
|
|
1472
1534
|
exports.dynamic = dynamic;
|
|
@@ -1484,6 +1546,7 @@ exports.getRequestEvent = getRequestEvent;
|
|
|
1484
1546
|
exports.hydrate = notSup;
|
|
1485
1547
|
exports.insert = notSup;
|
|
1486
1548
|
exports.isDev = isDev;
|
|
1549
|
+
exports.isHref = isHref;
|
|
1487
1550
|
exports.isResponseEnvelope = isResponseEnvelope;
|
|
1488
1551
|
exports.isServer = isServer;
|
|
1489
1552
|
exports.memo = memo;
|
|
@@ -1491,6 +1554,7 @@ exports.redirect = redirect;
|
|
|
1491
1554
|
exports.ref = notSup;
|
|
1492
1555
|
exports.registerDelegatedContainer = notSup;
|
|
1493
1556
|
exports.registerDelegatedRoot = notSup;
|
|
1557
|
+
exports.registerElementClaim = registerElementClaim;
|
|
1494
1558
|
exports.reload = reload;
|
|
1495
1559
|
exports.render = notSup;
|
|
1496
1560
|
exports.renderToStream = renderToStream;
|