@solidjs/web 2.0.0-rc.4 → 2.0.0-rc.6
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 +163 -36
- package/dist/dev.js +161 -37
- package/dist/server.cjs +178 -37
- package/dist/server.js +177 -38
- package/dist/web.cjs +143 -36
- package/dist/web.js +141 -37
- package/frames/dist/client.cjs +41 -8
- package/frames/dist/client.dev.cjs +41 -8
- package/frames/dist/client.dev.js +41 -8
- package/frames/dist/client.js +41 -8
- package/frames/dist/server.cjs +497 -44
- package/frames/dist/server.js +497 -44
- package/package.json +2 -2
- package/serialization/dist/decode.cjs +4 -2
- package/serialization/dist/decode.js +4 -2
- package/serialization/dist/serialization.cjs +12 -8
- package/serialization/dist/serialization.js +12 -8
- package/serialization/types/index.d.ts +7 -0
- package/serialization/types/serializer-decode.d.ts +14 -1
- package/serialization/types/serializer.d.ts +7 -0
- package/serialization/types-cjs/index.d.cts +7 -0
- package/serialization/types-cjs/serializer-decode.d.cts +14 -1
- package/serialization/types-cjs/serializer.d.cts +7 -0
- package/server-functions/dist/client.cjs +164 -35
- package/server-functions/dist/client.js +161 -36
- package/server-functions/dist/server.cjs +899 -136
- package/server-functions/dist/server.dev.cjs +919 -136
- package/server-functions/dist/server.dev.js +915 -137
- package/server-functions/dist/server.js +895 -137
- package/types/client.d.ts +2 -1
- package/types/constants.d.ts +3 -1
- package/types/cookies.d.ts +6 -14
- package/types/frames/frame-client.d.ts +4 -0
- package/types/frames/serializer-decode.d.ts +14 -1
- package/types/frames/serializer.d.ts +7 -0
- package/types/jsx.d.ts +11 -16
- package/types/response.d.ts +11 -0
- package/types/serializer-decode.d.ts +14 -1
- package/types/serializer.d.ts +7 -0
- package/types/server-functions/client.d.ts +22 -2
- package/types/server-functions/flash.d.ts +9 -0
- package/types/server-functions/server.d.ts +131 -11
- package/types/server-functions/shared.d.ts +77 -14
- package/types/server-mock.d.ts +17 -2
- package/types/server.d.ts +16 -2
- package/types-cjs/client.d.cts +2 -1
- package/types-cjs/constants.d.cts +3 -1
- package/types-cjs/cookies.d.cts +6 -14
- package/types-cjs/frames/frame-client.d.cts +4 -0
- package/types-cjs/frames/serializer-decode.d.cts +14 -1
- package/types-cjs/frames/serializer.d.cts +7 -0
- package/types-cjs/jsx.d.cts +11 -16
- package/types-cjs/response.d.cts +11 -0
- package/types-cjs/serializer-decode.d.cts +14 -1
- package/types-cjs/serializer.d.cts +7 -0
- package/types-cjs/server-functions/client.d.cts +22 -2
- package/types-cjs/server-functions/flash.d.cts +9 -0
- package/types-cjs/server-functions/server.d.cts +131 -11
- package/types-cjs/server-functions/shared.d.cts +77 -14
- package/types-cjs/server-mock.d.cts +17 -2
- package/types-cjs/server.d.cts +16 -2
package/dist/dev.js
CHANGED
|
@@ -48,6 +48,7 @@ const Namespaces = {
|
|
|
48
48
|
const VoidElements = /*#__PURE__*/new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]);
|
|
49
49
|
const RawTextElements = /*#__PURE__*/new Set(["style", "script", "noscript", "template", "textarea", "title"]);
|
|
50
50
|
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(","));
|
|
51
|
+
const COMPOSED_BODY_FRAMING = /*#__PURE__*/new Set(["content-length", "content-encoding", "transfer-encoding"]);
|
|
51
52
|
|
|
52
53
|
const transparentOptions = {
|
|
53
54
|
transparent: true,
|
|
@@ -214,7 +215,8 @@ function resourceIdentity(tag, props) {
|
|
|
214
215
|
let id = "res:" + tag + ":" + (props.rel || "") + ":" + (props.href || props.src || "");
|
|
215
216
|
for (let i = 0; i < RESOURCE_QUALIFIERS.length; i++) {
|
|
216
217
|
const q = RESOURCE_QUALIFIERS[i];
|
|
217
|
-
|
|
218
|
+
const value = props[q];
|
|
219
|
+
if (value != null) id += ":" + q + "=" + (value === true ? "" : value);
|
|
218
220
|
}
|
|
219
221
|
return id;
|
|
220
222
|
}
|
|
@@ -287,6 +289,7 @@ function decodeSafe(text) {
|
|
|
287
289
|
}
|
|
288
290
|
}
|
|
289
291
|
function serializeCookie(name, value, options = {}) {
|
|
292
|
+
assertServableCookie(name, options);
|
|
290
293
|
let cookie = `${encodeURIComponent(name)}=${encodeURIComponent(value)}`;
|
|
291
294
|
cookie += `; Path=${options.path === undefined ? "/" : options.path}`;
|
|
292
295
|
if (options.domain) cookie += `; Domain=${options.domain}`;
|
|
@@ -294,12 +297,32 @@ function serializeCookie(name, value, options = {}) {
|
|
|
294
297
|
if (options.expires) cookie += `; Expires=${options.expires.toUTCString()}`;
|
|
295
298
|
if (options.httpOnly) cookie += "; HttpOnly";
|
|
296
299
|
if (options.secure) cookie += "; Secure";
|
|
300
|
+
if (options.partitioned) cookie += "; Partitioned";
|
|
297
301
|
if (options.sameSite) {
|
|
298
302
|
const sameSite = options.sameSite.toLowerCase();
|
|
299
303
|
cookie += `; SameSite=${sameSite === "none" ? "None" : sameSite === "strict" ? "Strict" : "Lax"}`;
|
|
300
304
|
}
|
|
301
305
|
return cookie;
|
|
302
306
|
}
|
|
307
|
+
function assertServableCookie(name, options) {
|
|
308
|
+
const reject = reason => {
|
|
309
|
+
throw new Error(`serializeCookie: every browser silently rejects this cookie — ${reason}. ` + `It would never come back on a request, with no error anywhere.`);
|
|
310
|
+
};
|
|
311
|
+
const lower = name.toLowerCase();
|
|
312
|
+
if (lower.startsWith("__host-")) {
|
|
313
|
+
if (!options.secure) reject(`the __Host- prefix on \`${name}\` requires \`secure: true\``);
|
|
314
|
+
if (options.path !== undefined && options.path !== "/") reject(`the __Host- prefix on \`${name}\` requires \`Path=/\` (got \`${options.path}\`) — ` + `host-locking is the prefix's whole contract, so it cannot be path-scoped`);
|
|
315
|
+
if (options.domain) reject(`the __Host- prefix on \`${name}\` forbids \`Domain\` (got \`${options.domain}\`)`);
|
|
316
|
+
} else if (lower.startsWith("__secure-") && !options.secure) {
|
|
317
|
+
reject(`the __Secure- prefix on \`${name}\` requires \`secure: true\``);
|
|
318
|
+
}
|
|
319
|
+
if (options.sameSite && options.sameSite.toLowerCase() === "none" && !options.secure) {
|
|
320
|
+
reject("`SameSite=None` requires `secure: true`");
|
|
321
|
+
}
|
|
322
|
+
if (options.partitioned && !options.secure) {
|
|
323
|
+
reject("`Partitioned` requires `secure: true`");
|
|
324
|
+
}
|
|
325
|
+
}
|
|
303
326
|
const FLASH_COOKIE = "flash";
|
|
304
327
|
const FLASH_MATCHER = new RegExp(`(?:^|;\\s*)${FLASH_COOKIE}=([^;]+)`);
|
|
305
328
|
function hasFlashCookie(cookieHeader) {
|
|
@@ -338,6 +361,8 @@ function installListDriver(driver) {
|
|
|
338
361
|
listDriver = driver;
|
|
339
362
|
}
|
|
340
363
|
const $$EVENT_OWNER = "_$SOLID_EVENT_OWNER";
|
|
364
|
+
const $$EVENT_TUPLE = Symbol();
|
|
365
|
+
const hasOwn = Object.prototype.hasOwnProperty;
|
|
341
366
|
const INNER_OWNED = {};
|
|
342
367
|
const delegatedEvents = new Set();
|
|
343
368
|
const delegatedContainers = new Map();
|
|
@@ -463,7 +488,8 @@ function findOwner(target, state) {
|
|
|
463
488
|
}
|
|
464
489
|
function setProperty(node, name, value) {
|
|
465
490
|
if (isHydrating(node)) return;
|
|
466
|
-
|
|
491
|
+
const nodeName = node.nodeName;
|
|
492
|
+
if (name === "value" && nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else if ((name === "value" || name === "defaultValue") && (nodeName === "INPUT" || nodeName === "TEXTAREA")) node[name] = value ?? "";else node[name] = value;
|
|
467
493
|
}
|
|
468
494
|
let claimHandlers = null;
|
|
469
495
|
const CLAIM_SEAM = Symbol.for("solid.element-claims");
|
|
@@ -497,7 +523,17 @@ function claimElement(node) {
|
|
|
497
523
|
}
|
|
498
524
|
function setAttribute(node, name, value) {
|
|
499
525
|
if (isHydrating(node)) return;
|
|
500
|
-
|
|
526
|
+
const selectMultiple = name === "multiple" && node.localName === "select";
|
|
527
|
+
if (value == null || value === false) node.removeAttribute(name);else {
|
|
528
|
+
node.setAttribute(name, value === true ? "" : value);
|
|
529
|
+
if (selectMultiple && !node._$multiple) {
|
|
530
|
+
const options = node.options;
|
|
531
|
+
for (let i = 0; i < options.length; i++) {
|
|
532
|
+
if (options[i].defaultSelected) options[i].selected = true;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
if (selectMultiple) node._$multiple = true;
|
|
501
537
|
if (claimHandlers !== null && (name === "href" || name === "action")) claimElement(node);
|
|
502
538
|
}
|
|
503
539
|
function setAttributeNS(node, namespace, name, value) {
|
|
@@ -505,22 +541,32 @@ function setAttributeNS(node, namespace, name, value) {
|
|
|
505
541
|
if (value == null || value === false) node.removeAttributeNS(namespace, name.indexOf(":") > -1 ? name.split(":").pop() : name);else node.setAttributeNS(namespace, name, value === true ? "" : value);
|
|
506
542
|
}
|
|
507
543
|
function className(node, value, prev) {
|
|
508
|
-
if (
|
|
544
|
+
if (typeof value === "number") value = "" + value;
|
|
545
|
+
if (typeof prev === "number") prev = "" + prev;
|
|
546
|
+
if (isHydrating(node)) {
|
|
547
|
+
node._$classes = value && typeof value === "object" ? classListToObject(value) : undefined;
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
509
550
|
if (value == null || value === false) {
|
|
510
|
-
prev
|
|
551
|
+
if (prev || node._$classes) {
|
|
552
|
+
node.removeAttribute("class");
|
|
553
|
+
node._$classes = undefined;
|
|
554
|
+
}
|
|
511
555
|
return;
|
|
512
556
|
}
|
|
513
557
|
if (typeof value === "string") {
|
|
558
|
+
node._$classes = undefined;
|
|
514
559
|
value !== prev && node.setAttribute("class", value);
|
|
515
560
|
return;
|
|
516
561
|
}
|
|
562
|
+
let applied;
|
|
517
563
|
if (typeof prev === "string") {
|
|
518
|
-
|
|
564
|
+
applied = {};
|
|
519
565
|
node.removeAttribute("class");
|
|
520
|
-
} else
|
|
566
|
+
} else applied = node._$classes || classListToObject(prev || {});
|
|
521
567
|
value = classListToObject(value);
|
|
522
|
-
const classKeys = Object.keys(value
|
|
523
|
-
const prevKeys = Object.keys(
|
|
568
|
+
const classKeys = Object.keys(value);
|
|
569
|
+
const prevKeys = Object.keys(applied);
|
|
524
570
|
let i, len;
|
|
525
571
|
for (i = 0, len = prevKeys.length; i < len; i++) {
|
|
526
572
|
const key = prevKeys[i];
|
|
@@ -530,22 +576,34 @@ function className(node, value, prev) {
|
|
|
530
576
|
for (i = 0, len = classKeys.length; i < len; i++) {
|
|
531
577
|
const key = classKeys[i],
|
|
532
578
|
classValue = !!value[key];
|
|
533
|
-
if (!key || key === "undefined" ||
|
|
579
|
+
if (!key || key === "undefined" || applied[key] === classValue || !classValue) continue;
|
|
534
580
|
node.classList.add(key);
|
|
535
581
|
}
|
|
582
|
+
node._$classes = value;
|
|
536
583
|
}
|
|
537
584
|
function addEvent(node, name, handler, delegate) {
|
|
538
585
|
if (delegate) {
|
|
586
|
+
const key = `$$${name}`;
|
|
587
|
+
let data;
|
|
539
588
|
if (Array.isArray(handler)) {
|
|
540
|
-
|
|
541
|
-
node[
|
|
542
|
-
} else node[
|
|
543
|
-
|
|
589
|
+
data = handler[1];
|
|
590
|
+
node[key] = handler[0];
|
|
591
|
+
} else node[key] = handler;
|
|
592
|
+
node[`${key}Data`] = data;
|
|
593
|
+
return;
|
|
594
|
+
}
|
|
595
|
+
if (Array.isArray(handler)) {
|
|
544
596
|
const handlerFn = handler[0];
|
|
545
|
-
|
|
546
|
-
|
|
597
|
+
const listener = e => handlerFn.call(node, handler[1], e);
|
|
598
|
+
listener[$$EVENT_TUPLE] = handler;
|
|
599
|
+
node.addEventListener(name, listener);
|
|
600
|
+
return listener;
|
|
601
|
+
}
|
|
602
|
+
node.addEventListener(name, handler, typeof handler !== "function" && handler);
|
|
603
|
+
return handler;
|
|
547
604
|
}
|
|
548
605
|
function style(node, value, prev) {
|
|
606
|
+
if (isHydrating(node)) return;
|
|
549
607
|
if (!value) {
|
|
550
608
|
if (prev || node._$styles) {
|
|
551
609
|
setAttribute(node, "style");
|
|
@@ -570,12 +628,13 @@ function style(node, value, prev) {
|
|
|
570
628
|
}
|
|
571
629
|
let v, s;
|
|
572
630
|
for (s in applied) {
|
|
573
|
-
if (value[s] == null) {
|
|
631
|
+
if (!hasOwn.call(value, s) || value[s] == null) {
|
|
574
632
|
nodeStyle.removeProperty(s);
|
|
575
633
|
delete applied[s];
|
|
576
634
|
}
|
|
577
635
|
}
|
|
578
636
|
for (s in value) {
|
|
637
|
+
if (!hasOwn.call(value, s)) continue;
|
|
579
638
|
v = value[s];
|
|
580
639
|
if (v != null && v !== applied[s]) {
|
|
581
640
|
nodeStyle.setProperty(s, v);
|
|
@@ -584,20 +643,28 @@ function style(node, value, prev) {
|
|
|
584
643
|
}
|
|
585
644
|
}
|
|
586
645
|
function setStyleProperty(node, name, value) {
|
|
646
|
+
if (isHydrating(node)) return;
|
|
587
647
|
value != null ? node.style.setProperty(name, value) : node.style.removeProperty(name);
|
|
588
648
|
}
|
|
589
649
|
function spread(node, props = {}, skipChildren) {
|
|
590
650
|
const prevProps = {};
|
|
591
|
-
|
|
651
|
+
const get = typeof props === "function" ? props : () => props;
|
|
652
|
+
if (!skipChildren) insert(node, () => {
|
|
653
|
+
const source = get();
|
|
654
|
+
return hasOwn.call(source, "children") ? source.children : undefined;
|
|
655
|
+
});
|
|
592
656
|
effect(() => {
|
|
593
|
-
const
|
|
657
|
+
const source = get();
|
|
658
|
+
const r = hasOwn.call(source, "ref") && source.ref;
|
|
594
659
|
(typeof r === "function" || Array.isArray(r)) && ref(() => r, node);
|
|
595
660
|
}, () => {});
|
|
596
661
|
effect(() => {
|
|
662
|
+
const source = get();
|
|
597
663
|
const newProps = {};
|
|
598
|
-
for (const prop in
|
|
664
|
+
for (const prop in source) {
|
|
665
|
+
if (!hasOwn.call(source, prop)) continue;
|
|
599
666
|
if (prop === "children" || prop === "ref") continue;
|
|
600
|
-
newProps[prop] =
|
|
667
|
+
newProps[prop] = source[prop];
|
|
601
668
|
}
|
|
602
669
|
return newProps;
|
|
603
670
|
}, props => assign(node, props, true, prevProps, true));
|
|
@@ -627,6 +694,19 @@ function scope(fn) {
|
|
|
627
694
|
const SCOPE_OPTIONS = {
|
|
628
695
|
scope: true
|
|
629
696
|
};
|
|
697
|
+
let insertionParent = null;
|
|
698
|
+
function getInsertionParent() {
|
|
699
|
+
return insertionParent;
|
|
700
|
+
}
|
|
701
|
+
function withInsertionParent(parent, fn) {
|
|
702
|
+
const prev = insertionParent;
|
|
703
|
+
insertionParent = parent;
|
|
704
|
+
try {
|
|
705
|
+
return fn();
|
|
706
|
+
} finally {
|
|
707
|
+
insertionParent = prev;
|
|
708
|
+
}
|
|
709
|
+
}
|
|
630
710
|
let hydrationRt = null;
|
|
631
711
|
function installHydrationRuntime() {
|
|
632
712
|
hydrationRt = {
|
|
@@ -694,7 +774,7 @@ function insert(parent, accessor, marker, initial, options) {
|
|
|
694
774
|
if (listDriver(parent, accessor, marker, () => runWithOwner(owner, () => insert(parent, () => listAccessor(), marker, marker !== undefined ? [] : undefined, options)))) return;
|
|
695
775
|
}
|
|
696
776
|
if (typeof accessor !== "function") {
|
|
697
|
-
accessor = normalize(accessor, initial, multi, true);
|
|
777
|
+
accessor = withInsertionParent(parent, () => normalize(accessor, initial, multi, true));
|
|
698
778
|
if (typeof accessor !== "function") {
|
|
699
779
|
insertExpression(parent, accessor, initial, marker);
|
|
700
780
|
host && tagHost(accessor, host);
|
|
@@ -709,9 +789,9 @@ function insert(parent, accessor, marker, initial, options) {
|
|
|
709
789
|
let current = initial;
|
|
710
790
|
effect(prev => {
|
|
711
791
|
if (hydrationRt !== null) current = hydrationRt.reclaimRegion(current, parent, marker);
|
|
712
|
-
const value = normalize(accessor(), current, multi, true);
|
|
792
|
+
const value = withInsertionParent(parent, () => normalize(accessor(), current, multi, true));
|
|
713
793
|
if (typeof value !== "function") return value;
|
|
714
|
-
effect(() => (hydrationRt !== null && (current = hydrationRt.reclaimRegion(current, parent, marker)), normalize(value, current, multi)), inner => {
|
|
794
|
+
effect(() => (hydrationRt !== null && (current = hydrationRt.reclaimRegion(current, parent, marker)), withInsertionParent(parent, () => normalize(value, current, multi))), inner => {
|
|
715
795
|
current = insertExpression(parent, inner, current, marker);
|
|
716
796
|
host && tagHost(current, host);
|
|
717
797
|
}, prev !== undefined && !(options && options.schedule) ? {
|
|
@@ -1429,7 +1509,8 @@ function classListToObject(classList) {
|
|
|
1429
1509
|
function flattenClassList(list, result) {
|
|
1430
1510
|
for (let i = 0, len = list.length; i < len; i++) {
|
|
1431
1511
|
const item = list[i];
|
|
1432
|
-
if (Array.isArray(item)) flattenClassList(item, result);else if (typeof item === "object" && item != null) Object.assign(result, item);
|
|
1512
|
+
if (Array.isArray(item)) flattenClassList(item, result);else if (typeof item === "object" && item != null) Object.assign(result, item);
|
|
1513
|
+
else if (typeof item !== "boolean" && (item || item === 0)) result[item] = true;
|
|
1433
1514
|
}
|
|
1434
1515
|
}
|
|
1435
1516
|
function assignProp(node, prop, value, prev, skipRef, nodeName) {
|
|
@@ -1445,12 +1526,13 @@ function assignProp(node, prop, value, prev, skipRef, nodeName) {
|
|
|
1445
1526
|
const name = prop.slice(2).toLowerCase();
|
|
1446
1527
|
const delegate = DelegatedEvents.has(name);
|
|
1447
1528
|
if (!delegate && prev) {
|
|
1448
|
-
|
|
1449
|
-
node.removeEventListener(name,
|
|
1529
|
+
if (Array.isArray(value) && typeof prev === "function" && prev[$$EVENT_TUPLE] === value) return prev;
|
|
1530
|
+
node.removeEventListener(name, prev, typeof prev !== "function" && prev);
|
|
1450
1531
|
}
|
|
1451
1532
|
if (delegate || value) {
|
|
1452
|
-
addEvent(node, name, value, delegate);
|
|
1533
|
+
const attached = addEvent(node, name, value, delegate);
|
|
1453
1534
|
delegate && delegateEvents([name]);
|
|
1535
|
+
if (!delegate) return attached;
|
|
1454
1536
|
}
|
|
1455
1537
|
} else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop]) {
|
|
1456
1538
|
if (hasNamespace) prop = prop.slice(5);else if (isHydrating(node)) return value;
|
|
@@ -1490,7 +1572,7 @@ function eventHandler(e, container, state) {
|
|
|
1490
1572
|
}
|
|
1491
1573
|
if (handler && !node.disabled) {
|
|
1492
1574
|
const data = node[`${key}Data`];
|
|
1493
|
-
data !== undefined ? handler.call(node, data, e) : handler.call(node, e);
|
|
1575
|
+
data !== undefined ? handler.call(node, data, e) : typeof handler === "function" ? handler.call(node, e) : handler.handleEvent(e);
|
|
1494
1576
|
if (e.cancelBubble) return;
|
|
1495
1577
|
}
|
|
1496
1578
|
node.host && typeof node.host !== "string" && !node.host._$host && node.contains(e.target) && retarget(node.host);
|
|
@@ -1610,7 +1692,7 @@ function normalize(value, current, multi, doNotUnwrap) {
|
|
|
1610
1692
|
const item = value[i],
|
|
1611
1693
|
prev = current && current[i],
|
|
1612
1694
|
t = typeof item;
|
|
1613
|
-
if ((t === "string" || t === "number") && prev && prev.nodeType === 3) value[i] = prev;
|
|
1695
|
+
if ((t === "string" || t === "number") && prev && prev.nodeType === 3 && isHydrating(prev)) value[i] = prev;
|
|
1614
1696
|
}
|
|
1615
1697
|
}
|
|
1616
1698
|
return value;
|
|
@@ -2091,6 +2173,7 @@ function isSafeError(value) {
|
|
|
2091
2173
|
return !!(value && (typeof value === "object" || typeof value === "function") && value[SAFE_ERROR]);
|
|
2092
2174
|
}
|
|
2093
2175
|
const REVALIDATE_HEADER = "X-Revalidate";
|
|
2176
|
+
const RESPONSE_HEADER_VALUE_LIMIT = 4096;
|
|
2094
2177
|
function initWithRevalidate(init = {}) {
|
|
2095
2178
|
const resolved = typeof init === "number" ? {
|
|
2096
2179
|
status: init
|
|
@@ -2111,7 +2194,13 @@ function initWithRevalidate(init = {}) {
|
|
|
2111
2194
|
} else {
|
|
2112
2195
|
headers = new Headers(responseInit.headers);
|
|
2113
2196
|
}
|
|
2114
|
-
revalidate !== undefined
|
|
2197
|
+
if (revalidate !== undefined) {
|
|
2198
|
+
const keys = revalidate.toString();
|
|
2199
|
+
if (keys.length > RESPONSE_HEADER_VALUE_LIMIT) {
|
|
2200
|
+
throw new TypeError(`revalidate names ${keys.length} characters of cache keys; past ` + `${RESPONSE_HEADER_VALUE_LIMIT} the ${REVALIDATE_HEADER} header would overflow ` + `receivers (an 8 KiB proxy buffer holds the whole header block) and the response ` + `dies at the socket after the mutation committed. Split the invalidation across ` + `calls or use coarser keys — a dropped key would be a silently stale cache, so ` + `the runtime refuses rather than trims.`);
|
|
2201
|
+
}
|
|
2202
|
+
headers.set(REVALIDATE_HEADER, keys);
|
|
2203
|
+
}
|
|
2115
2204
|
return {
|
|
2116
2205
|
responseInit,
|
|
2117
2206
|
headers
|
|
@@ -2129,7 +2218,12 @@ function redirect(url, init = 302) {
|
|
|
2129
2218
|
responseInit.status = 302;
|
|
2130
2219
|
}
|
|
2131
2220
|
const target = typeof url === "string" ? url : url[HREF];
|
|
2132
|
-
|
|
2221
|
+
const location = typeof target === "string" ? target : String(url);
|
|
2222
|
+
const encoded = location.replace(/[^\x00-\x7f]/gu, encodeURIComponent);
|
|
2223
|
+
if (encoded.length > RESPONSE_HEADER_VALUE_LIMIT) {
|
|
2224
|
+
throw new TypeError(`redirect() target is ${encoded.length} characters; past ` + `${RESPONSE_HEADER_VALUE_LIMIT} the Location header (and the scripted transport's ` + `redirect header) would overflow receivers and the response dies at the socket. ` + `A target this size is usually unbounded input echoed into the url — carry the ` + `state server-side instead. Refused rather than trimmed: a cut target is a ` + `different address.`);
|
|
2225
|
+
}
|
|
2226
|
+
headers.set("Location", encoded);
|
|
2133
2227
|
return new Response(null, {
|
|
2134
2228
|
...responseInit,
|
|
2135
2229
|
headers
|
|
@@ -2145,11 +2239,19 @@ function reload(init = {}) {
|
|
|
2145
2239
|
headers
|
|
2146
2240
|
});
|
|
2147
2241
|
}
|
|
2242
|
+
const NULL_BODY_STATUSES = new Set([204, 205, 304]);
|
|
2148
2243
|
function respond(value, init = {}) {
|
|
2149
2244
|
const {
|
|
2150
2245
|
responseInit,
|
|
2151
2246
|
headers
|
|
2152
2247
|
} = initWithRevalidate(init);
|
|
2248
|
+
for (const header of COMPOSED_BODY_FRAMING) headers.delete(header);
|
|
2249
|
+
if (NULL_BODY_STATUSES.has(responseInit.status)) {
|
|
2250
|
+
return new ResponseEnvelope(new Response(null, {
|
|
2251
|
+
...responseInit,
|
|
2252
|
+
headers
|
|
2253
|
+
}), value);
|
|
2254
|
+
}
|
|
2153
2255
|
headers.set("Content-Type", "application/json");
|
|
2154
2256
|
return new ResponseEnvelope(new Response(JSON.stringify(value), {
|
|
2155
2257
|
...responseInit,
|
|
@@ -2259,9 +2361,24 @@ function dynamic(source) {
|
|
|
2259
2361
|
return untrack(() => component(props));
|
|
2260
2362
|
}
|
|
2261
2363
|
case "string":
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2364
|
+
{
|
|
2365
|
+
if (sharedConfig.hydrating) {
|
|
2366
|
+
const el = getNextElement();
|
|
2367
|
+
spread(el, props);
|
|
2368
|
+
return el;
|
|
2369
|
+
}
|
|
2370
|
+
const owner = getOwner();
|
|
2371
|
+
let el;
|
|
2372
|
+
return () => {
|
|
2373
|
+
if (!el) {
|
|
2374
|
+
runWithOwner(owner, () => {
|
|
2375
|
+
el = createElement(component, untrack(() => props.is));
|
|
2376
|
+
spread(el, props);
|
|
2377
|
+
});
|
|
2378
|
+
}
|
|
2379
|
+
return el;
|
|
2380
|
+
};
|
|
2381
|
+
}
|
|
2265
2382
|
}
|
|
2266
2383
|
});
|
|
2267
2384
|
};
|
|
@@ -2270,8 +2387,15 @@ function Dynamic(props) {
|
|
|
2270
2387
|
const Comp = dynamic(() => props.component);
|
|
2271
2388
|
return createComponent(Comp, omit(props, "component"));
|
|
2272
2389
|
}
|
|
2390
|
+
const AmbiguousSVGElements = /*#__PURE__*/new Set(["a", "script", "style", "title"]);
|
|
2273
2391
|
function createElement(tagName, is = undefined) {
|
|
2274
|
-
|
|
2392
|
+
if (SVGElements.has(tagName)) return document.createElementNS(Namespaces.svg, tagName);
|
|
2393
|
+
if (MathMLElements.has(tagName)) return document.createElementNS(Namespaces.mathml, tagName);
|
|
2394
|
+
if (AmbiguousSVGElements.has(tagName)) {
|
|
2395
|
+
const parent = getInsertionParent();
|
|
2396
|
+
if (parent && parent.namespaceURI === Namespaces.svg && parent.localName !== "foreignObject") return document.createElementNS(Namespaces.svg, tagName);
|
|
2397
|
+
}
|
|
2398
|
+
return document.createElement(tagName, {
|
|
2275
2399
|
is
|
|
2276
2400
|
});
|
|
2277
2401
|
}
|
|
@@ -2303,4 +2427,4 @@ _moduleUrl) {
|
|
|
2303
2427
|
function httpStatus(_code, _text) {}
|
|
2304
2428
|
function httpHeader(_name, _value, _options) {}
|
|
2305
2429
|
|
|
2306
|
-
export { ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF, HydrationScript, MathMLElements, Namespaces, Portal, REVALIDATE_HEADER, RawTextElements, RequestContext, ResponseEnvelope, SAFE_ERROR, SVGElements, VoidElements, acquireAsset, addEvent, applyRef, assign, claimElement, claimElementTree, className, clearFlashCookie, clientOnly, commitEventResponse, composeMiddleware, createRequestEvent, createResponseStub, createSSRResponse, delegateEvents, driveList, dynamic, dynamicProperty, effect, escape, generateHydrationScript, getDelegatedRoot, getExpectedRedirectStatus, getFirstChild, getHydrationKey, getNextElement, getNextMarker, getNextMatch, getNextSibling, getRequestEvent, getServerFunctionMetadata, getServerFunctionRPC, hasFlashCookie, httpHeader, httpStatus, hydrate, insert, installHydrationRuntime, installListDriver, isDev, isHref, isResponseEnvelope, isSafeError, isServer, isServerFunction, listDriver, markSafeError, memo, parseCookieHeader, patchDriver, redirect, ref, registerDelegatedContainer, registerDelegatedRoot, registerElementClaim, reload, render, renderToStream, renderToString, resolveSSRNode, respond, rowProof, runHydrationEvents, scope, serializeCookie, setAttribute, setAttributeNS, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrGroup, ssrHydrationKey, ssrStyle, ssrStyleProperty, style, template, unregisterDelegatedContainer, unregisterDelegatedRoot, useHead, waitAsset, warmAsset };
|
|
2430
|
+
export { ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF, HydrationScript, MathMLElements, NULL_BODY_STATUSES, Namespaces, Portal, RESPONSE_HEADER_VALUE_LIMIT, REVALIDATE_HEADER, RawTextElements, RequestContext, ResponseEnvelope, SAFE_ERROR, SVGElements, VoidElements, acquireAsset, addEvent, applyRef, assign, claimElement, claimElementTree, className, clearFlashCookie, clientOnly, commitEventResponse, composeMiddleware, createRequestEvent, createResponseStub, createSSRResponse, delegateEvents, driveList, dynamic, dynamicProperty, effect, escape, generateHydrationScript, getDelegatedRoot, getExpectedRedirectStatus, getFirstChild, getHydrationKey, getInsertionParent, getNextElement, getNextMarker, getNextMatch, getNextSibling, getRequestEvent, getServerFunctionMetadata, getServerFunctionRPC, hasFlashCookie, httpHeader, httpStatus, hydrate, insert, installHydrationRuntime, installListDriver, isDev, isHref, isResponseEnvelope, isSafeError, isServer, isServerFunction, listDriver, markSafeError, memo, parseCookieHeader, patchDriver, redirect, ref, registerDelegatedContainer, registerDelegatedRoot, registerElementClaim, reload, render, renderToStream, renderToString, resolveSSRNode, respond, rowProof, runHydrationEvents, scope, serializeCookie, setAttribute, setAttributeNS, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrGroup, ssrHydrationKey, ssrStyle, ssrStyleProperty, style, template, unregisterDelegatedContainer, unregisterDelegatedRoot, useHead, waitAsset, warmAsset };
|