@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/server.js
CHANGED
|
@@ -327,10 +327,53 @@ function renderToStream(code, options = {}) {
|
|
|
327
327
|
completed = true;
|
|
328
328
|
if (firstFlushed) dispose();
|
|
329
329
|
};
|
|
330
|
-
const
|
|
330
|
+
const sink = {
|
|
331
|
+
data(payload) {
|
|
332
|
+
pushTask(payload);
|
|
333
|
+
},
|
|
334
|
+
fragment(key, value, meta) {
|
|
335
|
+
const deferActivation = !!meta.revealGroup;
|
|
336
|
+
const styles = meta.styles;
|
|
337
|
+
for (let i = 0; i < styles.inline.length; i++) {
|
|
338
|
+
buffer.write(renderInlineStyle(styles.inline[i], nonce));
|
|
339
|
+
}
|
|
340
|
+
if (styles.links.length) {
|
|
341
|
+
emitTask(`$dfs("${key}",${styles.links.length},${deferActivation ? 1 : 0})`);
|
|
342
|
+
writeTasks();
|
|
343
|
+
for (const url of styles.links) {
|
|
344
|
+
buffer.write(`<link rel="stylesheet" href="${url}" onload="$dfc('${key}')" onerror="$dfc('${key}')">`);
|
|
345
|
+
}
|
|
346
|
+
buffer.write(`<template id="${key}">${value}</template>`);
|
|
347
|
+
} else {
|
|
348
|
+
buffer.write(`<template id="${key}">${value}</template>`);
|
|
349
|
+
if (!deferActivation) {
|
|
350
|
+
emitTask(`$df("${key}")`);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
},
|
|
354
|
+
reveal(keys, meta) {
|
|
355
|
+
emitTask(`${meta.fallback ? "$dflj" : "$dfj"}(${JSON.stringify(keys)})`);
|
|
356
|
+
},
|
|
357
|
+
asset(type, value) {
|
|
358
|
+
if (type === "module") {
|
|
359
|
+
buffer.write(`<link rel="modulepreload" href="${value}">`);
|
|
360
|
+
} else if (type === "inline-style") {
|
|
361
|
+
buffer.write(renderInlineStyle(value, nonce));
|
|
362
|
+
}
|
|
363
|
+
},
|
|
364
|
+
shell(shellHtml, meta) {
|
|
365
|
+
shellHtml = injectBeforeHead(shellHtml, meta.assets);
|
|
366
|
+
shellHtml = injectPreloadLinks(meta.preloads, shellHtml);
|
|
367
|
+
shellHtml = injectInlineStyles(meta.inlineStyles, shellHtml, nonce);
|
|
368
|
+
if (meta.tasks.length) shellHtml = injectScripts(shellHtml, meta.tasks, nonce);
|
|
369
|
+
buffer.write(shellHtml);
|
|
370
|
+
},
|
|
371
|
+
...options.sink
|
|
372
|
+
};
|
|
373
|
+
const serializer = (options.serializer || createHydrationSerializer)({
|
|
331
374
|
scopeId: options.renderId,
|
|
332
375
|
plugins: options.plugins,
|
|
333
|
-
onData:
|
|
376
|
+
onData: payload => sink.data(payload),
|
|
334
377
|
onDone,
|
|
335
378
|
onError: options.onError
|
|
336
379
|
});
|
|
@@ -404,7 +447,7 @@ function renderToStream(code, options = {}) {
|
|
|
404
447
|
const entry = tracking.registerInlineStyle(value);
|
|
405
448
|
if (firstFlushed && !tracking.currentBoundaryId && !entry.emitted) {
|
|
406
449
|
entry.emitted = true;
|
|
407
|
-
|
|
450
|
+
sink.asset("inline-style", entry);
|
|
408
451
|
}
|
|
409
452
|
return;
|
|
410
453
|
}
|
|
@@ -418,9 +461,7 @@ function renderToStream(code, options = {}) {
|
|
|
418
461
|
}
|
|
419
462
|
if (!tracking.emittedAssets.has(value)) {
|
|
420
463
|
tracking.emittedAssets.add(value);
|
|
421
|
-
if (firstFlushed
|
|
422
|
-
buffer.write(`<link rel="modulepreload" href="${value}">`);
|
|
423
|
-
}
|
|
464
|
+
if (firstFlushed) sink.asset(type, value);
|
|
424
465
|
}
|
|
425
466
|
},
|
|
426
467
|
block(p) {
|
|
@@ -502,23 +543,11 @@ function renderToStream(code, options = {}) {
|
|
|
502
543
|
} else {
|
|
503
544
|
serializeFragmentAssets(key, tracking.boundaryModules, context);
|
|
504
545
|
const styles = collectStreamStyles(key, tracking, headStyles);
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
emitTask(`$dfs("${key}",${styles.links.length},${deferActivation ? 1 : 0})`);
|
|
511
|
-
writeTasks();
|
|
512
|
-
for (const url of styles.links) {
|
|
513
|
-
buffer.write(`<link rel="stylesheet" href="${url}" onload="$dfc('${key}')" onerror="$dfc('${key}')">`);
|
|
514
|
-
}
|
|
515
|
-
buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`);
|
|
516
|
-
} else {
|
|
517
|
-
buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`);
|
|
518
|
-
if (!deferActivation) {
|
|
519
|
-
emitTask(`$df("${key}")`);
|
|
520
|
-
}
|
|
521
|
-
}
|
|
546
|
+
sink.fragment(key, value !== undefined ? value : " ", {
|
|
547
|
+
styles,
|
|
548
|
+
revealGroup,
|
|
549
|
+
error
|
|
550
|
+
});
|
|
522
551
|
item.resolve(error);
|
|
523
552
|
}
|
|
524
553
|
}
|
|
@@ -529,12 +558,16 @@ function renderToStream(code, options = {}) {
|
|
|
529
558
|
revealFragments(groupOrKeys) {
|
|
530
559
|
const keys = resolveRevealKeys(groupOrKeys, true, true);
|
|
531
560
|
if (!keys) return;
|
|
532
|
-
|
|
561
|
+
sink.reveal(keys, {
|
|
562
|
+
fallback: false
|
|
563
|
+
});
|
|
533
564
|
},
|
|
534
565
|
revealFallbacks(groupOrKeys) {
|
|
535
566
|
const keys = resolveRevealKeys(groupOrKeys, false, false);
|
|
536
567
|
if (!keys) return;
|
|
537
|
-
|
|
568
|
+
sink.reveal(keys, {
|
|
569
|
+
fallback: true
|
|
570
|
+
});
|
|
538
571
|
}
|
|
539
572
|
};
|
|
540
573
|
applyAssetTracking(context, tracking, manifest);
|
|
@@ -594,16 +627,18 @@ function renderToStream(code, options = {}) {
|
|
|
594
627
|
if (shellCompleted) return;
|
|
595
628
|
if (!resolveRootHoles()) return;
|
|
596
629
|
sharedConfig.context = context;
|
|
597
|
-
|
|
630
|
+
const assetsHtml = resolveAssetsHtml(context.assets);
|
|
598
631
|
headStyles = new Set();
|
|
599
632
|
for (const url of tracking.emittedAssets) {
|
|
600
633
|
if (url.endsWith(".css")) headStyles.add(url);
|
|
601
634
|
}
|
|
602
|
-
html = injectPreloadLinks(tracking.emittedAssets, html);
|
|
603
|
-
html = injectInlineStyles(tracking.inlineStyles, html, nonce);
|
|
604
635
|
serializeRootAssets();
|
|
605
|
-
|
|
606
|
-
|
|
636
|
+
sink.shell(html, {
|
|
637
|
+
assets: assetsHtml,
|
|
638
|
+
preloads: tracking.emittedAssets,
|
|
639
|
+
inlineStyles: tracking.inlineStyles,
|
|
640
|
+
tasks
|
|
641
|
+
});
|
|
607
642
|
tasks = "";
|
|
608
643
|
onCompleteShell && onCompleteShell({
|
|
609
644
|
write(v) {
|
|
@@ -1053,13 +1088,20 @@ function allSettled(promises) {
|
|
|
1053
1088
|
return;
|
|
1054
1089
|
});
|
|
1055
1090
|
}
|
|
1056
|
-
function
|
|
1057
|
-
if (!assets || !assets.length) return
|
|
1091
|
+
function resolveAssetsHtml(assets) {
|
|
1092
|
+
if (!assets || !assets.length) return "";
|
|
1058
1093
|
let out = "";
|
|
1059
1094
|
for (let i = 0, len = assets.length; i < len; i++) out += assets[i]();
|
|
1095
|
+
return out;
|
|
1096
|
+
}
|
|
1097
|
+
function injectBeforeHead(html, content) {
|
|
1098
|
+
if (!content) return html;
|
|
1060
1099
|
const index = html.indexOf("</head>");
|
|
1061
1100
|
if (index === -1) return html;
|
|
1062
|
-
return html.slice(0, index) +
|
|
1101
|
+
return html.slice(0, index) + content + html.slice(index);
|
|
1102
|
+
}
|
|
1103
|
+
function injectAssets(assets, html) {
|
|
1104
|
+
return injectBeforeHead(html, resolveAssetsHtml(assets));
|
|
1063
1105
|
}
|
|
1064
1106
|
function injectPreloadLinks(emittedAssets, html, nonce) {
|
|
1065
1107
|
if (!emittedAssets.size) return html;
|
|
@@ -1271,6 +1313,16 @@ function getRequestEvent() {
|
|
|
1271
1313
|
function renderToStringAsync(code, options = {}) {
|
|
1272
1314
|
return new Promise(resolve => renderToStream(code, options).then(resolve));
|
|
1273
1315
|
}
|
|
1316
|
+
function registerElementClaim() {
|
|
1317
|
+
return noopCleanup;
|
|
1318
|
+
}
|
|
1319
|
+
function noopCleanup() {}
|
|
1320
|
+
function claimElement(node) {
|
|
1321
|
+
return node;
|
|
1322
|
+
}
|
|
1323
|
+
function claimElementTree(root) {
|
|
1324
|
+
return root;
|
|
1325
|
+
}
|
|
1274
1326
|
function notSup() {
|
|
1275
1327
|
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>.");
|
|
1276
1328
|
}
|
|
@@ -1286,6 +1338,10 @@ ResponseEnvelope.prototype[ENVELOPE] = true;
|
|
|
1286
1338
|
function isResponseEnvelope(value) {
|
|
1287
1339
|
return !!(value && typeof value === "object" && value[ENVELOPE]);
|
|
1288
1340
|
}
|
|
1341
|
+
const HREF = Symbol.for("solid.Href");
|
|
1342
|
+
function isHref(value) {
|
|
1343
|
+
return !!(value && (typeof value === "object" || typeof value === "function") && value[HREF]);
|
|
1344
|
+
}
|
|
1289
1345
|
function initWithRevalidate(init) {
|
|
1290
1346
|
const {
|
|
1291
1347
|
revalidate,
|
|
@@ -1299,6 +1355,9 @@ function initWithRevalidate(init) {
|
|
|
1299
1355
|
};
|
|
1300
1356
|
}
|
|
1301
1357
|
function redirect(url, init = 302) {
|
|
1358
|
+
if (typeof url !== "string" && !isHref(url)) {
|
|
1359
|
+
throw new TypeError("redirect() expects a string URL or an Href-branded value (Symbol.for('solid.Href')).");
|
|
1360
|
+
}
|
|
1302
1361
|
const {
|
|
1303
1362
|
responseInit,
|
|
1304
1363
|
headers
|
|
@@ -1308,7 +1367,7 @@ function redirect(url, init = 302) {
|
|
|
1308
1367
|
if (responseInit.status === undefined) {
|
|
1309
1368
|
responseInit.status = 302;
|
|
1310
1369
|
}
|
|
1311
|
-
headers.set("Location", url);
|
|
1370
|
+
headers.set("Location", String(url));
|
|
1312
1371
|
return new Response(null, {
|
|
1313
1372
|
...responseInit,
|
|
1314
1373
|
headers
|
|
@@ -1387,4 +1446,4 @@ function Portal(props) {
|
|
|
1387
1446
|
return undefined;
|
|
1388
1447
|
}
|
|
1389
1448
|
|
|
1390
|
-
export { Assets, ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HydrationScript, MathMLElements, Namespaces, Portal, RawTextElements, RequestContext, ResponseEnvelope, SVGElements, VoidElements, notSup as acquireAsset, notSup as addEvent, applyRef, notSup as assign, notSup as className, notSup as delegateEvents, dynamic, notSup as dynamicProperty, effect, escape, generateHydrationScript, getAssets, notSup as getDelegatedRoot, getHydrationKey, notSup as getNextElement, notSup as getNextMarker, notSup as getNextMatch, getRequestEvent, notSup as hydrate, notSup as insert, isDev, isResponseEnvelope, isServer, memo, redirect, notSup as ref, notSup as registerDelegatedContainer, notSup as registerDelegatedRoot, reload, notSup as render, renderToStream, renderToString, renderToStringAsync, respond, notSup as runHydrationEvents, notSup as setAttribute, notSup as setAttributeNS, notSup as setProperty, notSup as setStyleProperty, notSup as spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrGroup, ssrHydrationKey, ssrStyle, ssrStyleProperty, notSup as style, notSup as template, notSup as unregisterDelegatedContainer, notSup as unregisterDelegatedRoot, useAssets };
|
|
1449
|
+
export { Assets, ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF, HydrationScript, MathMLElements, Namespaces, Portal, RawTextElements, RequestContext, ResponseEnvelope, SVGElements, VoidElements, notSup as acquireAsset, notSup as addEvent, applyRef, notSup as assign, claimElement, claimElementTree, notSup as className, notSup as delegateEvents, dynamic, notSup as dynamicProperty, effect, escape, generateHydrationScript, getAssets, notSup as getDelegatedRoot, getHydrationKey, notSup as getNextElement, notSup as getNextMarker, notSup as getNextMatch, getRequestEvent, notSup as hydrate, notSup as insert, isDev, isHref, isResponseEnvelope, isServer, memo, redirect, notSup as ref, notSup as registerDelegatedContainer, notSup as registerDelegatedRoot, registerElementClaim, reload, notSup as render, renderToStream, renderToString, renderToStringAsync, respond, notSup as runHydrationEvents, notSup as setAttribute, notSup as setAttributeNS, notSup as setProperty, notSup as setStyleProperty, notSup as spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrGroup, ssrHydrationKey, ssrStyle, ssrStyleProperty, notSup as style, notSup as template, notSup as unregisterDelegatedContainer, notSup as unregisterDelegatedRoot, useAssets };
|
package/dist/web.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",
|
|
@@ -277,9 +278,40 @@ function setProperty(node, name, value) {
|
|
|
277
278
|
if (isHydrating(node)) return;
|
|
278
279
|
node[name] = value;
|
|
279
280
|
}
|
|
281
|
+
let claimHandlers = null;
|
|
282
|
+
const CLAIM_SEAM = Symbol.for("dom-expressions.element-claims");
|
|
283
|
+
function registerElementClaim(handler) {
|
|
284
|
+
(claimHandlers || (claimHandlers = globalThis[CLAIM_SEAM] = [])).push(handler);
|
|
285
|
+
return () => {
|
|
286
|
+
const index = claimHandlers.indexOf(handler);
|
|
287
|
+
index > -1 && claimHandlers.splice(index, 1);
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
const CLAIMED_ELEMENTS = "a[href], form[action]";
|
|
291
|
+
function claimElementTree(root) {
|
|
292
|
+
const handlers = globalThis[CLAIM_SEAM];
|
|
293
|
+
if (handlers === undefined || handlers.length === 0) return root;
|
|
294
|
+
const isElement = root.nodeType === 1;
|
|
295
|
+
if (!isElement && root.nodeType !== 11) return root;
|
|
296
|
+
if (isElement && root.matches(CLAIMED_ELEMENTS)) {
|
|
297
|
+
for (let i = 0; i < handlers.length; i++) handlers[i](root);
|
|
298
|
+
}
|
|
299
|
+
const found = root.querySelectorAll(CLAIMED_ELEMENTS);
|
|
300
|
+
for (let i = 0; i < found.length; i++) {
|
|
301
|
+
for (let j = 0; j < handlers.length; j++) handlers[j](found[i]);
|
|
302
|
+
}
|
|
303
|
+
return root;
|
|
304
|
+
}
|
|
305
|
+
function claimElement(node) {
|
|
306
|
+
if (claimHandlers !== null) {
|
|
307
|
+
for (let i = 0; i < claimHandlers.length; i++) claimHandlers[i](node);
|
|
308
|
+
}
|
|
309
|
+
return node;
|
|
310
|
+
}
|
|
280
311
|
function setAttribute(node, name, value) {
|
|
281
312
|
if (isHydrating(node)) return;
|
|
282
313
|
if (value == null || value === false) node.removeAttribute(name);else node.setAttribute(name, value === true ? "" : value);
|
|
314
|
+
if (claimHandlers !== null && (name === "href" || name === "action")) claimElement(node);
|
|
283
315
|
}
|
|
284
316
|
function setAttributeNS(node, namespace, name, value) {
|
|
285
317
|
if (isHydrating(node)) return;
|
|
@@ -936,6 +968,11 @@ function insertExpression(parent, value, current, marker) {
|
|
|
936
968
|
parent.appendChild(value);
|
|
937
969
|
}
|
|
938
970
|
if (marker) value[$$SLOT] = marker;
|
|
971
|
+
} else if (value[$$FRAME]) {
|
|
972
|
+
if (current) {
|
|
973
|
+
cleanChildren(parent, Array.isArray(current) ? current : [current], multi ? marker : null);
|
|
974
|
+
}
|
|
975
|
+
value[$$FRAME](parent, multi ? marker : null);
|
|
939
976
|
} else if (Array.isArray(value)) {
|
|
940
977
|
const currentArray = current && Array.isArray(current);
|
|
941
978
|
if (value.length === 0) {
|
|
@@ -956,6 +993,7 @@ function normalize(value, current, multi, doNotUnwrap) {
|
|
|
956
993
|
doNotUnwrap
|
|
957
994
|
});
|
|
958
995
|
if (doNotUnwrap && typeof value === "function") return value;
|
|
996
|
+
if (value != null && value[$$FRAME]) return value;
|
|
959
997
|
if (multi && !Array.isArray(value)) value = [value != null ? value : ""];
|
|
960
998
|
if (Array.isArray(value)) {
|
|
961
999
|
for (let i = 0, len = value.length; i < len; i++) {
|
|
@@ -1073,6 +1111,10 @@ ResponseEnvelope.prototype[ENVELOPE] = true;
|
|
|
1073
1111
|
function isResponseEnvelope(value) {
|
|
1074
1112
|
return !!(value && typeof value === "object" && value[ENVELOPE]);
|
|
1075
1113
|
}
|
|
1114
|
+
const HREF = Symbol.for("solid.Href");
|
|
1115
|
+
function isHref(value) {
|
|
1116
|
+
return !!(value && (typeof value === "object" || typeof value === "function") && value[HREF]);
|
|
1117
|
+
}
|
|
1076
1118
|
function initWithRevalidate(init) {
|
|
1077
1119
|
const {
|
|
1078
1120
|
revalidate,
|
|
@@ -1086,6 +1128,9 @@ function initWithRevalidate(init) {
|
|
|
1086
1128
|
};
|
|
1087
1129
|
}
|
|
1088
1130
|
function redirect(url, init = 302) {
|
|
1131
|
+
if (typeof url !== "string" && !isHref(url)) {
|
|
1132
|
+
throw new TypeError("redirect() expects a string URL or an Href-branded value (Symbol.for('solid.Href')).");
|
|
1133
|
+
}
|
|
1089
1134
|
const {
|
|
1090
1135
|
responseInit,
|
|
1091
1136
|
headers
|
|
@@ -1095,7 +1140,7 @@ function redirect(url, init = 302) {
|
|
|
1095
1140
|
if (responseInit.status === undefined) {
|
|
1096
1141
|
responseInit.status = 302;
|
|
1097
1142
|
}
|
|
1098
|
-
headers.set("Location", url);
|
|
1143
|
+
headers.set("Location", String(url));
|
|
1099
1144
|
return new Response(null, {
|
|
1100
1145
|
...responseInit,
|
|
1101
1146
|
headers
|
|
@@ -1279,6 +1324,7 @@ exports.DOMElements = DOMElements;
|
|
|
1279
1324
|
exports.DOMWithState = DOMWithState;
|
|
1280
1325
|
exports.DelegatedEvents = DelegatedEvents;
|
|
1281
1326
|
exports.Dynamic = Dynamic;
|
|
1327
|
+
exports.HREF = HREF;
|
|
1282
1328
|
exports.HydrationScript = voidFn;
|
|
1283
1329
|
exports.MathMLElements = MathMLElements;
|
|
1284
1330
|
exports.Namespaces = Namespaces;
|
|
@@ -1292,6 +1338,8 @@ exports.acquireAsset = acquireAsset;
|
|
|
1292
1338
|
exports.addEvent = addEvent;
|
|
1293
1339
|
exports.applyRef = applyRef;
|
|
1294
1340
|
exports.assign = assign;
|
|
1341
|
+
exports.claimElement = claimElement;
|
|
1342
|
+
exports.claimElementTree = claimElementTree;
|
|
1295
1343
|
exports.className = className;
|
|
1296
1344
|
exports.delegateEvents = delegateEvents;
|
|
1297
1345
|
exports.dynamic = dynamic;
|
|
@@ -1312,6 +1360,7 @@ exports.hydrate = hydrate;
|
|
|
1312
1360
|
exports.insert = insert;
|
|
1313
1361
|
exports.installHydrationRuntime = installHydrationRuntime;
|
|
1314
1362
|
exports.isDev = isDev;
|
|
1363
|
+
exports.isHref = isHref;
|
|
1315
1364
|
exports.isResponseEnvelope = isResponseEnvelope;
|
|
1316
1365
|
exports.isServer = isServer;
|
|
1317
1366
|
exports.memo = memo;
|
|
@@ -1320,6 +1369,7 @@ exports.redirect = redirect;
|
|
|
1320
1369
|
exports.ref = ref;
|
|
1321
1370
|
exports.registerDelegatedContainer = registerDelegatedContainer;
|
|
1322
1371
|
exports.registerDelegatedRoot = registerDelegatedRoot;
|
|
1372
|
+
exports.registerElementClaim = registerElementClaim;
|
|
1323
1373
|
exports.reload = reload;
|
|
1324
1374
|
exports.render = render;
|
|
1325
1375
|
exports.renderToStream = renderToStream;
|
package/dist/web.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",
|
|
@@ -276,9 +277,40 @@ function setProperty(node, name, value) {
|
|
|
276
277
|
if (isHydrating(node)) return;
|
|
277
278
|
node[name] = value;
|
|
278
279
|
}
|
|
280
|
+
let claimHandlers = null;
|
|
281
|
+
const CLAIM_SEAM = Symbol.for("dom-expressions.element-claims");
|
|
282
|
+
function registerElementClaim(handler) {
|
|
283
|
+
(claimHandlers || (claimHandlers = globalThis[CLAIM_SEAM] = [])).push(handler);
|
|
284
|
+
return () => {
|
|
285
|
+
const index = claimHandlers.indexOf(handler);
|
|
286
|
+
index > -1 && claimHandlers.splice(index, 1);
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
const CLAIMED_ELEMENTS = "a[href], form[action]";
|
|
290
|
+
function claimElementTree(root) {
|
|
291
|
+
const handlers = globalThis[CLAIM_SEAM];
|
|
292
|
+
if (handlers === undefined || handlers.length === 0) return root;
|
|
293
|
+
const isElement = root.nodeType === 1;
|
|
294
|
+
if (!isElement && root.nodeType !== 11) return root;
|
|
295
|
+
if (isElement && root.matches(CLAIMED_ELEMENTS)) {
|
|
296
|
+
for (let i = 0; i < handlers.length; i++) handlers[i](root);
|
|
297
|
+
}
|
|
298
|
+
const found = root.querySelectorAll(CLAIMED_ELEMENTS);
|
|
299
|
+
for (let i = 0; i < found.length; i++) {
|
|
300
|
+
for (let j = 0; j < handlers.length; j++) handlers[j](found[i]);
|
|
301
|
+
}
|
|
302
|
+
return root;
|
|
303
|
+
}
|
|
304
|
+
function claimElement(node) {
|
|
305
|
+
if (claimHandlers !== null) {
|
|
306
|
+
for (let i = 0; i < claimHandlers.length; i++) claimHandlers[i](node);
|
|
307
|
+
}
|
|
308
|
+
return node;
|
|
309
|
+
}
|
|
279
310
|
function setAttribute(node, name, value) {
|
|
280
311
|
if (isHydrating(node)) return;
|
|
281
312
|
if (value == null || value === false) node.removeAttribute(name);else node.setAttribute(name, value === true ? "" : value);
|
|
313
|
+
if (claimHandlers !== null && (name === "href" || name === "action")) claimElement(node);
|
|
282
314
|
}
|
|
283
315
|
function setAttributeNS(node, namespace, name, value) {
|
|
284
316
|
if (isHydrating(node)) return;
|
|
@@ -935,6 +967,11 @@ function insertExpression(parent, value, current, marker) {
|
|
|
935
967
|
parent.appendChild(value);
|
|
936
968
|
}
|
|
937
969
|
if (marker) value[$$SLOT] = marker;
|
|
970
|
+
} else if (value[$$FRAME]) {
|
|
971
|
+
if (current) {
|
|
972
|
+
cleanChildren(parent, Array.isArray(current) ? current : [current], multi ? marker : null);
|
|
973
|
+
}
|
|
974
|
+
value[$$FRAME](parent, multi ? marker : null);
|
|
938
975
|
} else if (Array.isArray(value)) {
|
|
939
976
|
const currentArray = current && Array.isArray(current);
|
|
940
977
|
if (value.length === 0) {
|
|
@@ -955,6 +992,7 @@ function normalize(value, current, multi, doNotUnwrap) {
|
|
|
955
992
|
doNotUnwrap
|
|
956
993
|
});
|
|
957
994
|
if (doNotUnwrap && typeof value === "function") return value;
|
|
995
|
+
if (value != null && value[$$FRAME]) return value;
|
|
958
996
|
if (multi && !Array.isArray(value)) value = [value != null ? value : ""];
|
|
959
997
|
if (Array.isArray(value)) {
|
|
960
998
|
for (let i = 0, len = value.length; i < len; i++) {
|
|
@@ -1072,6 +1110,10 @@ ResponseEnvelope.prototype[ENVELOPE] = true;
|
|
|
1072
1110
|
function isResponseEnvelope(value) {
|
|
1073
1111
|
return !!(value && typeof value === "object" && value[ENVELOPE]);
|
|
1074
1112
|
}
|
|
1113
|
+
const HREF = Symbol.for("solid.Href");
|
|
1114
|
+
function isHref(value) {
|
|
1115
|
+
return !!(value && (typeof value === "object" || typeof value === "function") && value[HREF]);
|
|
1116
|
+
}
|
|
1075
1117
|
function initWithRevalidate(init) {
|
|
1076
1118
|
const {
|
|
1077
1119
|
revalidate,
|
|
@@ -1085,6 +1127,9 @@ function initWithRevalidate(init) {
|
|
|
1085
1127
|
};
|
|
1086
1128
|
}
|
|
1087
1129
|
function redirect(url, init = 302) {
|
|
1130
|
+
if (typeof url !== "string" && !isHref(url)) {
|
|
1131
|
+
throw new TypeError("redirect() expects a string URL or an Href-branded value (Symbol.for('solid.Href')).");
|
|
1132
|
+
}
|
|
1088
1133
|
const {
|
|
1089
1134
|
responseInit,
|
|
1090
1135
|
headers
|
|
@@ -1094,7 +1139,7 @@ function redirect(url, init = 302) {
|
|
|
1094
1139
|
if (responseInit.status === undefined) {
|
|
1095
1140
|
responseInit.status = 302;
|
|
1096
1141
|
}
|
|
1097
|
-
headers.set("Location", url);
|
|
1142
|
+
headers.set("Location", String(url));
|
|
1098
1143
|
return new Response(null, {
|
|
1099
1144
|
...responseInit,
|
|
1100
1145
|
headers
|
|
@@ -1220,4 +1265,4 @@ function createElement(tagName, is = undefined) {
|
|
|
1220
1265
|
});
|
|
1221
1266
|
}
|
|
1222
1267
|
|
|
1223
|
-
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 };
|
|
1268
|
+
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 };
|