@solidjs/web 2.0.0-rc.5 → 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 +113 -31
- package/dist/dev.js +113 -32
- package/dist/server.cjs +17 -3
- package/dist/server.js +17 -3
- package/dist/web.cjs +113 -31
- package/dist/web.js +113 -32
- package/frames/dist/server.cjs +87 -22
- package/frames/dist/server.js +87 -22
- package/package.json +2 -2
- package/server-functions/dist/client.cjs +14 -2
- package/server-functions/dist/client.js +14 -2
- package/server-functions/dist/server.cjs +219 -69
- package/server-functions/dist/server.dev.cjs +219 -69
- package/server-functions/dist/server.dev.js +219 -69
- package/server-functions/dist/server.js +219 -69
- package/types/client.d.ts +2 -1
- package/types/constants.d.ts +3 -1
- package/types/server-functions/server.d.ts +73 -2
- package/types-cjs/client.d.cts +2 -1
- package/types-cjs/constants.d.cts +3 -1
- package/types-cjs/server-functions/server.d.cts +73 -2
package/dist/web.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,
|
|
@@ -339,6 +340,8 @@ function installListDriver(driver) {
|
|
|
339
340
|
listDriver = driver;
|
|
340
341
|
}
|
|
341
342
|
const $$EVENT_OWNER = "_$SOLID_EVENT_OWNER";
|
|
343
|
+
const $$EVENT_TUPLE = Symbol();
|
|
344
|
+
const hasOwn = Object.prototype.hasOwnProperty;
|
|
342
345
|
const INNER_OWNED = {};
|
|
343
346
|
const delegatedEvents = new Set();
|
|
344
347
|
const delegatedContainers = new Map();
|
|
@@ -456,7 +459,8 @@ function findOwner(target, state) {
|
|
|
456
459
|
}
|
|
457
460
|
function setProperty(node, name, value) {
|
|
458
461
|
if (isHydrating(node)) return;
|
|
459
|
-
|
|
462
|
+
const nodeName = node.nodeName;
|
|
463
|
+
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;
|
|
460
464
|
}
|
|
461
465
|
let claimHandlers = null;
|
|
462
466
|
const CLAIM_SEAM = Symbol.for("solid.element-claims");
|
|
@@ -490,7 +494,17 @@ function claimElement(node) {
|
|
|
490
494
|
}
|
|
491
495
|
function setAttribute(node, name, value) {
|
|
492
496
|
if (isHydrating(node)) return;
|
|
493
|
-
|
|
497
|
+
const selectMultiple = name === "multiple" && node.localName === "select";
|
|
498
|
+
if (value == null || value === false) node.removeAttribute(name);else {
|
|
499
|
+
node.setAttribute(name, value === true ? "" : value);
|
|
500
|
+
if (selectMultiple && !node._$multiple) {
|
|
501
|
+
const options = node.options;
|
|
502
|
+
for (let i = 0; i < options.length; i++) {
|
|
503
|
+
if (options[i].defaultSelected) options[i].selected = true;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
if (selectMultiple) node._$multiple = true;
|
|
494
508
|
if (claimHandlers !== null && (name === "href" || name === "action")) claimElement(node);
|
|
495
509
|
}
|
|
496
510
|
function setAttributeNS(node, namespace, name, value) {
|
|
@@ -498,22 +512,32 @@ function setAttributeNS(node, namespace, name, value) {
|
|
|
498
512
|
if (value == null || value === false) node.removeAttributeNS(namespace, name.indexOf(":") > -1 ? name.split(":").pop() : name);else node.setAttributeNS(namespace, name, value === true ? "" : value);
|
|
499
513
|
}
|
|
500
514
|
function className(node, value, prev) {
|
|
501
|
-
if (
|
|
515
|
+
if (typeof value === "number") value = "" + value;
|
|
516
|
+
if (typeof prev === "number") prev = "" + prev;
|
|
517
|
+
if (isHydrating(node)) {
|
|
518
|
+
node._$classes = value && typeof value === "object" ? classListToObject(value) : undefined;
|
|
519
|
+
return;
|
|
520
|
+
}
|
|
502
521
|
if (value == null || value === false) {
|
|
503
|
-
prev
|
|
522
|
+
if (prev || node._$classes) {
|
|
523
|
+
node.removeAttribute("class");
|
|
524
|
+
node._$classes = undefined;
|
|
525
|
+
}
|
|
504
526
|
return;
|
|
505
527
|
}
|
|
506
528
|
if (typeof value === "string") {
|
|
529
|
+
node._$classes = undefined;
|
|
507
530
|
value !== prev && node.setAttribute("class", value);
|
|
508
531
|
return;
|
|
509
532
|
}
|
|
533
|
+
let applied;
|
|
510
534
|
if (typeof prev === "string") {
|
|
511
|
-
|
|
535
|
+
applied = {};
|
|
512
536
|
node.removeAttribute("class");
|
|
513
|
-
} else
|
|
537
|
+
} else applied = node._$classes || classListToObject(prev || {});
|
|
514
538
|
value = classListToObject(value);
|
|
515
|
-
const classKeys = Object.keys(value
|
|
516
|
-
const prevKeys = Object.keys(
|
|
539
|
+
const classKeys = Object.keys(value);
|
|
540
|
+
const prevKeys = Object.keys(applied);
|
|
517
541
|
let i, len;
|
|
518
542
|
for (i = 0, len = prevKeys.length; i < len; i++) {
|
|
519
543
|
const key = prevKeys[i];
|
|
@@ -523,22 +547,34 @@ function className(node, value, prev) {
|
|
|
523
547
|
for (i = 0, len = classKeys.length; i < len; i++) {
|
|
524
548
|
const key = classKeys[i],
|
|
525
549
|
classValue = !!value[key];
|
|
526
|
-
if (!key || key === "undefined" ||
|
|
550
|
+
if (!key || key === "undefined" || applied[key] === classValue || !classValue) continue;
|
|
527
551
|
node.classList.add(key);
|
|
528
552
|
}
|
|
553
|
+
node._$classes = value;
|
|
529
554
|
}
|
|
530
555
|
function addEvent(node, name, handler, delegate) {
|
|
531
556
|
if (delegate) {
|
|
557
|
+
const key = `$$${name}`;
|
|
558
|
+
let data;
|
|
532
559
|
if (Array.isArray(handler)) {
|
|
533
|
-
|
|
534
|
-
node[
|
|
535
|
-
} else node[
|
|
536
|
-
|
|
560
|
+
data = handler[1];
|
|
561
|
+
node[key] = handler[0];
|
|
562
|
+
} else node[key] = handler;
|
|
563
|
+
node[`${key}Data`] = data;
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
566
|
+
if (Array.isArray(handler)) {
|
|
537
567
|
const handlerFn = handler[0];
|
|
538
|
-
|
|
539
|
-
|
|
568
|
+
const listener = e => handlerFn.call(node, handler[1], e);
|
|
569
|
+
listener[$$EVENT_TUPLE] = handler;
|
|
570
|
+
node.addEventListener(name, listener);
|
|
571
|
+
return listener;
|
|
572
|
+
}
|
|
573
|
+
node.addEventListener(name, handler, typeof handler !== "function" && handler);
|
|
574
|
+
return handler;
|
|
540
575
|
}
|
|
541
576
|
function style(node, value, prev) {
|
|
577
|
+
if (isHydrating(node)) return;
|
|
542
578
|
if (!value) {
|
|
543
579
|
if (prev || node._$styles) {
|
|
544
580
|
setAttribute(node, "style");
|
|
@@ -563,12 +599,13 @@ function style(node, value, prev) {
|
|
|
563
599
|
}
|
|
564
600
|
let v, s;
|
|
565
601
|
for (s in applied) {
|
|
566
|
-
if (value[s] == null) {
|
|
602
|
+
if (!hasOwn.call(value, s) || value[s] == null) {
|
|
567
603
|
nodeStyle.removeProperty(s);
|
|
568
604
|
delete applied[s];
|
|
569
605
|
}
|
|
570
606
|
}
|
|
571
607
|
for (s in value) {
|
|
608
|
+
if (!hasOwn.call(value, s)) continue;
|
|
572
609
|
v = value[s];
|
|
573
610
|
if (v != null && v !== applied[s]) {
|
|
574
611
|
nodeStyle.setProperty(s, v);
|
|
@@ -577,20 +614,26 @@ function style(node, value, prev) {
|
|
|
577
614
|
}
|
|
578
615
|
}
|
|
579
616
|
function setStyleProperty(node, name, value) {
|
|
617
|
+
if (isHydrating(node)) return;
|
|
580
618
|
value != null ? node.style.setProperty(name, value) : node.style.removeProperty(name);
|
|
581
619
|
}
|
|
582
620
|
function spread(node, props = {}, skipChildren) {
|
|
583
621
|
const prevProps = {};
|
|
584
622
|
const get = typeof props === "function" ? props : () => props;
|
|
585
|
-
if (!skipChildren) insert(node, () =>
|
|
623
|
+
if (!skipChildren) insert(node, () => {
|
|
624
|
+
const source = get();
|
|
625
|
+
return hasOwn.call(source, "children") ? source.children : undefined;
|
|
626
|
+
});
|
|
586
627
|
effect(() => {
|
|
587
|
-
const
|
|
628
|
+
const source = get();
|
|
629
|
+
const r = hasOwn.call(source, "ref") && source.ref;
|
|
588
630
|
(typeof r === "function" || Array.isArray(r)) && ref(() => r, node);
|
|
589
631
|
}, () => {});
|
|
590
632
|
effect(() => {
|
|
591
633
|
const source = get();
|
|
592
634
|
const newProps = {};
|
|
593
635
|
for (const prop in source) {
|
|
636
|
+
if (!hasOwn.call(source, prop)) continue;
|
|
594
637
|
if (prop === "children" || prop === "ref") continue;
|
|
595
638
|
newProps[prop] = source[prop];
|
|
596
639
|
}
|
|
@@ -622,6 +665,19 @@ function scope(fn) {
|
|
|
622
665
|
const SCOPE_OPTIONS = {
|
|
623
666
|
scope: true
|
|
624
667
|
};
|
|
668
|
+
let insertionParent = null;
|
|
669
|
+
function getInsertionParent() {
|
|
670
|
+
return insertionParent;
|
|
671
|
+
}
|
|
672
|
+
function withInsertionParent(parent, fn) {
|
|
673
|
+
const prev = insertionParent;
|
|
674
|
+
insertionParent = parent;
|
|
675
|
+
try {
|
|
676
|
+
return fn();
|
|
677
|
+
} finally {
|
|
678
|
+
insertionParent = prev;
|
|
679
|
+
}
|
|
680
|
+
}
|
|
625
681
|
let hydrationRt = null;
|
|
626
682
|
function installHydrationRuntime() {
|
|
627
683
|
hydrationRt = {
|
|
@@ -689,7 +745,7 @@ function insert(parent, accessor, marker, initial, options) {
|
|
|
689
745
|
if (listDriver(parent, accessor, marker, () => runWithOwner(owner, () => insert(parent, () => listAccessor(), marker, marker !== undefined ? [] : undefined, options)))) return;
|
|
690
746
|
}
|
|
691
747
|
if (typeof accessor !== "function") {
|
|
692
|
-
accessor = normalize(accessor, initial, multi, true);
|
|
748
|
+
accessor = withInsertionParent(parent, () => normalize(accessor, initial, multi, true));
|
|
693
749
|
if (typeof accessor !== "function") {
|
|
694
750
|
insertExpression(parent, accessor, initial, marker);
|
|
695
751
|
host && tagHost(accessor, host);
|
|
@@ -704,9 +760,9 @@ function insert(parent, accessor, marker, initial, options) {
|
|
|
704
760
|
let current = initial;
|
|
705
761
|
effect(prev => {
|
|
706
762
|
if (hydrationRt !== null) current = hydrationRt.reclaimRegion(current, parent, marker);
|
|
707
|
-
const value = normalize(accessor(), current, multi, true);
|
|
763
|
+
const value = withInsertionParent(parent, () => normalize(accessor(), current, multi, true));
|
|
708
764
|
if (typeof value !== "function") return value;
|
|
709
|
-
effect(() => (hydrationRt !== null && (current = hydrationRt.reclaimRegion(current, parent, marker)), normalize(value, current, multi)), inner => {
|
|
765
|
+
effect(() => (hydrationRt !== null && (current = hydrationRt.reclaimRegion(current, parent, marker)), withInsertionParent(parent, () => normalize(value, current, multi))), inner => {
|
|
710
766
|
current = insertExpression(parent, inner, current, marker);
|
|
711
767
|
host && tagHost(current, host);
|
|
712
768
|
}, prev !== undefined && !(options && options.schedule) ? {
|
|
@@ -1366,7 +1422,8 @@ function classListToObject(classList) {
|
|
|
1366
1422
|
function flattenClassList(list, result) {
|
|
1367
1423
|
for (let i = 0, len = list.length; i < len; i++) {
|
|
1368
1424
|
const item = list[i];
|
|
1369
|
-
if (Array.isArray(item)) flattenClassList(item, result);else if (typeof item === "object" && item != null) Object.assign(result, item);
|
|
1425
|
+
if (Array.isArray(item)) flattenClassList(item, result);else if (typeof item === "object" && item != null) Object.assign(result, item);
|
|
1426
|
+
else if (typeof item !== "boolean" && (item || item === 0)) result[item] = true;
|
|
1370
1427
|
}
|
|
1371
1428
|
}
|
|
1372
1429
|
function assignProp(node, prop, value, prev, skipRef, nodeName) {
|
|
@@ -1382,12 +1439,13 @@ function assignProp(node, prop, value, prev, skipRef, nodeName) {
|
|
|
1382
1439
|
const name = prop.slice(2).toLowerCase();
|
|
1383
1440
|
const delegate = DelegatedEvents.has(name);
|
|
1384
1441
|
if (!delegate && prev) {
|
|
1385
|
-
|
|
1386
|
-
node.removeEventListener(name,
|
|
1442
|
+
if (Array.isArray(value) && typeof prev === "function" && prev[$$EVENT_TUPLE] === value) return prev;
|
|
1443
|
+
node.removeEventListener(name, prev, typeof prev !== "function" && prev);
|
|
1387
1444
|
}
|
|
1388
1445
|
if (delegate || value) {
|
|
1389
|
-
addEvent(node, name, value, delegate);
|
|
1446
|
+
const attached = addEvent(node, name, value, delegate);
|
|
1390
1447
|
delegate && delegateEvents([name]);
|
|
1448
|
+
if (!delegate) return attached;
|
|
1391
1449
|
}
|
|
1392
1450
|
} else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop]) {
|
|
1393
1451
|
if (hasNamespace) prop = prop.slice(5);else if (isHydrating(node)) return value;
|
|
@@ -1427,7 +1485,7 @@ function eventHandler(e, container, state) {
|
|
|
1427
1485
|
}
|
|
1428
1486
|
if (handler && !node.disabled) {
|
|
1429
1487
|
const data = node[`${key}Data`];
|
|
1430
|
-
data !== undefined ? handler.call(node, data, e) : handler.call(node, e);
|
|
1488
|
+
data !== undefined ? handler.call(node, data, e) : typeof handler === "function" ? handler.call(node, e) : handler.handleEvent(e);
|
|
1431
1489
|
if (e.cancelBubble) return;
|
|
1432
1490
|
}
|
|
1433
1491
|
node.host && typeof node.host !== "string" && !node.host._$host && node.contains(e.target) && retarget(node.host);
|
|
@@ -1547,7 +1605,7 @@ function normalize(value, current, multi, doNotUnwrap) {
|
|
|
1547
1605
|
const item = value[i],
|
|
1548
1606
|
prev = current && current[i],
|
|
1549
1607
|
t = typeof item;
|
|
1550
|
-
if ((t === "string" || t === "number") && prev && prev.nodeType === 3) value[i] = prev;
|
|
1608
|
+
if ((t === "string" || t === "number") && prev && prev.nodeType === 3 && isHydrating(prev)) value[i] = prev;
|
|
1551
1609
|
}
|
|
1552
1610
|
}
|
|
1553
1611
|
return value;
|
|
@@ -2091,6 +2149,7 @@ function respond(value, init = {}) {
|
|
|
2091
2149
|
responseInit,
|
|
2092
2150
|
headers
|
|
2093
2151
|
} = initWithRevalidate(init);
|
|
2152
|
+
for (const header of COMPOSED_BODY_FRAMING) headers.delete(header);
|
|
2094
2153
|
if (NULL_BODY_STATUSES.has(responseInit.status)) {
|
|
2095
2154
|
return new ResponseEnvelope(new Response(null, {
|
|
2096
2155
|
...responseInit,
|
|
@@ -2203,9 +2262,24 @@ function dynamic(source) {
|
|
|
2203
2262
|
return untrack(() => component(props));
|
|
2204
2263
|
}
|
|
2205
2264
|
case "string":
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2265
|
+
{
|
|
2266
|
+
if (sharedConfig.hydrating) {
|
|
2267
|
+
const el = getNextElement();
|
|
2268
|
+
spread(el, props);
|
|
2269
|
+
return el;
|
|
2270
|
+
}
|
|
2271
|
+
const owner = getOwner();
|
|
2272
|
+
let el;
|
|
2273
|
+
return () => {
|
|
2274
|
+
if (!el) {
|
|
2275
|
+
runWithOwner(owner, () => {
|
|
2276
|
+
el = createElement(component, untrack(() => props.is));
|
|
2277
|
+
spread(el, props);
|
|
2278
|
+
});
|
|
2279
|
+
}
|
|
2280
|
+
return el;
|
|
2281
|
+
};
|
|
2282
|
+
}
|
|
2209
2283
|
}
|
|
2210
2284
|
});
|
|
2211
2285
|
};
|
|
@@ -2214,8 +2288,15 @@ function Dynamic(props) {
|
|
|
2214
2288
|
const Comp = dynamic(() => props.component);
|
|
2215
2289
|
return createComponent(Comp, omit(props, "component"));
|
|
2216
2290
|
}
|
|
2291
|
+
const AmbiguousSVGElements = /*#__PURE__*/new Set(["a", "script", "style", "title"]);
|
|
2217
2292
|
function createElement(tagName, is = undefined) {
|
|
2218
|
-
|
|
2293
|
+
if (SVGElements.has(tagName)) return document.createElementNS(Namespaces.svg, tagName);
|
|
2294
|
+
if (MathMLElements.has(tagName)) return document.createElementNS(Namespaces.mathml, tagName);
|
|
2295
|
+
if (AmbiguousSVGElements.has(tagName)) {
|
|
2296
|
+
const parent = getInsertionParent();
|
|
2297
|
+
if (parent && parent.namespaceURI === Namespaces.svg && parent.localName !== "foreignObject") return document.createElementNS(Namespaces.svg, tagName);
|
|
2298
|
+
}
|
|
2299
|
+
return document.createElement(tagName, {
|
|
2219
2300
|
is
|
|
2220
2301
|
});
|
|
2221
2302
|
}
|
|
@@ -2247,4 +2328,4 @@ _moduleUrl) {
|
|
|
2247
2328
|
function httpStatus(_code, _text) {}
|
|
2248
2329
|
function httpHeader(_name, _value, _options) {}
|
|
2249
2330
|
|
|
2250
|
-
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, 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 };
|
|
2331
|
+
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 };
|
package/frames/dist/server.cjs
CHANGED
|
@@ -101,6 +101,8 @@ const ContainerTracePlugin = {
|
|
|
101
101
|
}
|
|
102
102
|
};
|
|
103
103
|
|
|
104
|
+
const COMPOSED_BODY_FRAMING = /*#__PURE__*/new Set(["content-length", "content-encoding", "transfer-encoding"]);
|
|
105
|
+
|
|
104
106
|
setContainerTraceStreamMint(iterable => {
|
|
105
107
|
const stream = seroval.createStream();
|
|
106
108
|
(async () => {
|
|
@@ -2791,8 +2793,55 @@ function resolveSSRSync(node) {
|
|
|
2791
2793
|
if (!res.h.length) return res.t[0];
|
|
2792
2794
|
throw new Error("This value cannot be rendered synchronously. Are you missing a boundary?");
|
|
2793
2795
|
}
|
|
2794
|
-
/*#__PURE__*/new Set([ERROR_HEADER, BODY_FORMAT_HEADER, SINGLE_FLIGHT_HEADER, REVALIDATE_HEADER, REDIRECT_HEADER, "Location"
|
|
2796
|
+
/*#__PURE__*/new Set([ERROR_HEADER, BODY_FORMAT_HEADER, SINGLE_FLIGHT_HEADER, REVALIDATE_HEADER, REDIRECT_HEADER, "Location",
|
|
2797
|
+
...COMPOSED_BODY_FRAMING].map(header => header.toLowerCase()));
|
|
2795
2798
|
|
|
2799
|
+
function scopeDeferredResult(value, scope) {
|
|
2800
|
+
if (value === null || typeof value !== "object" && typeof value !== "function") return value;
|
|
2801
|
+
const promised = scope(() => nativePromise(value));
|
|
2802
|
+
if (promised) {
|
|
2803
|
+
return promised.then(result => scope(() => scopeDeferredResult(result, scope)));
|
|
2804
|
+
}
|
|
2805
|
+
if (typeof ReadableStream !== "undefined" && value instanceof ReadableStream) {
|
|
2806
|
+
let reader;
|
|
2807
|
+
return new ReadableStream({
|
|
2808
|
+
async pull(controller) {
|
|
2809
|
+
try {
|
|
2810
|
+
const step = await scope(() => {
|
|
2811
|
+
if (!reader) reader = value.getReader();
|
|
2812
|
+
return reader.read();
|
|
2813
|
+
});
|
|
2814
|
+
if (step.done) controller.close();else controller.enqueue(step.value);
|
|
2815
|
+
} catch (error) {
|
|
2816
|
+
controller.error(error);
|
|
2817
|
+
}
|
|
2818
|
+
},
|
|
2819
|
+
cancel(reason) {
|
|
2820
|
+
return scope(() => reader ? reader.cancel(reason) : value.cancel(reason));
|
|
2821
|
+
}
|
|
2822
|
+
}, {
|
|
2823
|
+
highWaterMark: 0
|
|
2824
|
+
});
|
|
2825
|
+
}
|
|
2826
|
+
const scopedIterator = symbol => ({
|
|
2827
|
+
[symbol]() {
|
|
2828
|
+
const iterator = scope(() => value[symbol]());
|
|
2829
|
+
return new Proxy(iterator, {
|
|
2830
|
+
get(target, property) {
|
|
2831
|
+
const member = Reflect.get(target, property, target);
|
|
2832
|
+
return typeof member === "function" && (property === "next" || property === "return" || property === "throw") ? (...args) => scope(() => member.apply(target, args)) : member;
|
|
2833
|
+
}
|
|
2834
|
+
});
|
|
2835
|
+
}
|
|
2836
|
+
});
|
|
2837
|
+
if (typeof value[Symbol.asyncIterator] === "function") {
|
|
2838
|
+
return scopedIterator(Symbol.asyncIterator);
|
|
2839
|
+
}
|
|
2840
|
+
if (typeof value[Symbol.iterator] === "function" && !Array.isArray(value) && !(value instanceof Map) && !(value instanceof Set) && !ArrayBuffer.isView(value)) {
|
|
2841
|
+
return scopedIterator(Symbol.iterator);
|
|
2842
|
+
}
|
|
2843
|
+
return value;
|
|
2844
|
+
}
|
|
2796
2845
|
const INVOCATIONS = new WeakMap();
|
|
2797
2846
|
function getEventServerFunctionInvocation(event) {
|
|
2798
2847
|
return event && INVOCATIONS.get(event);
|
|
@@ -2857,14 +2906,11 @@ function guardFailures(value, state) {
|
|
|
2857
2906
|
top.next.add(guarded);
|
|
2858
2907
|
if (guarded !== original) top.changed = true;
|
|
2859
2908
|
} else if (guarded !== original || top.accessorRead === i) {
|
|
2860
|
-
Object.defineProperty(top.next, items[i],
|
|
2861
|
-
|
|
2862
|
-
configurable: true,
|
|
2909
|
+
Object.defineProperty(top.next, items[i], {
|
|
2910
|
+
value: guarded,
|
|
2863
2911
|
writable: true,
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
...top.descriptors[items[i]],
|
|
2867
|
-
value: guarded
|
|
2912
|
+
configurable: true,
|
|
2913
|
+
enumerable: top.descriptors[items[i]].enumerable
|
|
2868
2914
|
});
|
|
2869
2915
|
top.changed = true;
|
|
2870
2916
|
}
|
|
@@ -2899,6 +2945,9 @@ class Frame {
|
|
|
2899
2945
|
this.pendingKey = undefined;
|
|
2900
2946
|
}
|
|
2901
2947
|
}
|
|
2948
|
+
function guardOperation(state, run) {
|
|
2949
|
+
return state.scope ? state.scope(run) : run();
|
|
2950
|
+
}
|
|
2902
2951
|
function enterGuard(value, state) {
|
|
2903
2952
|
if (value === null || typeof value !== "object") return value;
|
|
2904
2953
|
if (state.seen.has(value)) {
|
|
@@ -2913,7 +2962,7 @@ function enterGuard(value, state) {
|
|
|
2913
2962
|
if (finished) return;
|
|
2914
2963
|
finished = true;
|
|
2915
2964
|
try {
|
|
2916
|
-
const cancelled = reader ? reader.cancel() : value.cancel();
|
|
2965
|
+
const cancelled = guardOperation(state, () => reader ? reader.cancel() : value.cancel());
|
|
2917
2966
|
if (cancelled && typeof cancelled.then === "function") cancelled.then(undefined, () => {});
|
|
2918
2967
|
} catch {}
|
|
2919
2968
|
};
|
|
@@ -2925,19 +2974,19 @@ function enterGuard(value, state) {
|
|
|
2925
2974
|
controller.close();
|
|
2926
2975
|
return;
|
|
2927
2976
|
}
|
|
2928
|
-
if (!reader) reader = value.getReader();
|
|
2977
|
+
if (!reader) reader = guardOperation(state, () => value.getReader());
|
|
2929
2978
|
const {
|
|
2930
2979
|
done,
|
|
2931
2980
|
value: chunk
|
|
2932
|
-
} = await reader.read();
|
|
2933
|
-
done ? controller.close() : controller.enqueue(guardFailures(chunk, state));
|
|
2981
|
+
} = await guardOperation(state, () => reader.read());
|
|
2982
|
+
done ? controller.close() : controller.enqueue(guardOperation(state, () => guardFailures(chunk, state)));
|
|
2934
2983
|
} catch (error) {
|
|
2935
|
-
controller.error(sanitizeServerError(error));
|
|
2984
|
+
controller.error(guardOperation(state, () => sanitizeServerError(error)));
|
|
2936
2985
|
}
|
|
2937
2986
|
},
|
|
2938
2987
|
cancel(reason) {
|
|
2939
2988
|
finished = true;
|
|
2940
|
-
return reader ? reader.cancel(reason) : value.cancel(reason);
|
|
2989
|
+
return guardOperation(state, () => reader ? reader.cancel(reason) : value.cancel(reason));
|
|
2941
2990
|
}
|
|
2942
2991
|
});
|
|
2943
2992
|
if (gate) gate.onOpen(close);
|
|
@@ -2945,9 +2994,10 @@ function enterGuard(value, state) {
|
|
|
2945
2994
|
return guardedStream;
|
|
2946
2995
|
}
|
|
2947
2996
|
if (typeof value.then === "function") {
|
|
2948
|
-
const guardedPromise = Promise.resolve(value).then(resolved => guardFailures(resolved, state), error => {
|
|
2949
|
-
throw sanitizeServerError(error);
|
|
2997
|
+
const guardedPromise = Promise.resolve(value).then(resolved => guardOperation(state, () => guardFailures(resolved, state)), error => {
|
|
2998
|
+
throw guardOperation(state, () => sanitizeServerError(error));
|
|
2950
2999
|
});
|
|
3000
|
+
guardedPromise.catch(() => {});
|
|
2951
3001
|
state.seen.set(value, guardedPromise);
|
|
2952
3002
|
return guardedPromise;
|
|
2953
3003
|
}
|
|
@@ -2956,13 +3006,13 @@ function enterGuard(value, state) {
|
|
|
2956
3006
|
const gate = state.gate;
|
|
2957
3007
|
const guardedIterable = {
|
|
2958
3008
|
[Symbol.asyncIterator]() {
|
|
2959
|
-
const iterator = source[Symbol.asyncIterator]();
|
|
3009
|
+
const iterator = guardOperation(state, () => source[Symbol.asyncIterator]());
|
|
2960
3010
|
let finished = false;
|
|
2961
3011
|
const close = () => {
|
|
2962
3012
|
if (finished) return;
|
|
2963
3013
|
finished = true;
|
|
2964
3014
|
try {
|
|
2965
|
-
const returned = iterator.return && iterator.return();
|
|
3015
|
+
const returned = iterator.return && guardOperation(state, () => iterator.return());
|
|
2966
3016
|
if (returned && typeof returned.then === "function") returned.then(undefined, () => {});
|
|
2967
3017
|
} catch {}
|
|
2968
3018
|
};
|
|
@@ -2970,17 +3020,17 @@ function enterGuard(value, state) {
|
|
|
2970
3020
|
const step = () => finished ? Promise.resolve({
|
|
2971
3021
|
done: true,
|
|
2972
3022
|
value: undefined
|
|
2973
|
-
}) : iterator.next().then(step => {
|
|
3023
|
+
}) : guardOperation(state, () => iterator.next()).then(step => {
|
|
2974
3024
|
if (step.done) {
|
|
2975
3025
|
finished = true;
|
|
2976
3026
|
return step;
|
|
2977
3027
|
}
|
|
2978
3028
|
return {
|
|
2979
3029
|
done: false,
|
|
2980
|
-
value: guardFailures(step.value, state)
|
|
3030
|
+
value: guardOperation(state, () => guardFailures(step.value, state))
|
|
2981
3031
|
};
|
|
2982
3032
|
}, error => {
|
|
2983
|
-
throw sanitizeServerError(error);
|
|
3033
|
+
throw guardOperation(state, () => sanitizeServerError(error));
|
|
2984
3034
|
});
|
|
2985
3035
|
return {
|
|
2986
3036
|
next: () => finished || !gate || gate.wantsMore() ? step() : gate.awaitDemand().then(step),
|
|
@@ -2997,6 +3047,11 @@ function enterGuard(value, state) {
|
|
|
2997
3047
|
state.seen.set(value, guardedIterable);
|
|
2998
3048
|
return guardedIterable;
|
|
2999
3049
|
}
|
|
3050
|
+
if (state.scope && typeof value[Symbol.iterator] === "function" && !Array.isArray(value) && !(value instanceof Map) && !(value instanceof Set) && !ArrayBuffer.isView(value)) {
|
|
3051
|
+
const scopedIterable = scopeDeferredResult(value, state.scope);
|
|
3052
|
+
state.seen.set(value, scopedIterable);
|
|
3053
|
+
return scopedIterable;
|
|
3054
|
+
}
|
|
3000
3055
|
if (Array.isArray(value)) {
|
|
3001
3056
|
const next = value.slice();
|
|
3002
3057
|
state.seen.set(value, next);
|
|
@@ -3020,9 +3075,13 @@ function enterGuard(value, state) {
|
|
|
3020
3075
|
return value;
|
|
3021
3076
|
}
|
|
3022
3077
|
const descriptors = Object.getOwnPropertyDescriptors(value);
|
|
3078
|
+
for (const key of Object.keys(descriptors)) {
|
|
3079
|
+
descriptors[key].configurable = true;
|
|
3080
|
+
if ("value" in descriptors[key]) descriptors[key].writable = true;
|
|
3081
|
+
}
|
|
3023
3082
|
const next = Object.create(prototype, descriptors);
|
|
3024
3083
|
state.seen.set(value, next);
|
|
3025
|
-
return new Frame(OBJECT, value, next, Object.keys(
|
|
3084
|
+
return new Frame(OBJECT, value, next, Object.keys(value), descriptors);
|
|
3026
3085
|
}
|
|
3027
3086
|
function keepGuarded(value, next, changed, state) {
|
|
3028
3087
|
if (changed || state.cyclic.has(value)) return next;
|
|
@@ -3034,6 +3093,12 @@ function sanitizeServerError(value) {
|
|
|
3034
3093
|
if (isSafeError(value)) return value;
|
|
3035
3094
|
return new Error(GENERIC_SERVER_ERROR_MESSAGE);
|
|
3036
3095
|
}
|
|
3096
|
+
function nativePromise(value) {
|
|
3097
|
+
if (value instanceof Promise) return value;
|
|
3098
|
+
try {
|
|
3099
|
+
if (Object.prototype.toString.call(value) === "[object Promise]") return Promise.prototype.then.call(value, value => value);
|
|
3100
|
+
} catch {}
|
|
3101
|
+
}
|
|
3037
3102
|
|
|
3038
3103
|
const FRAME_STREAM_HEADER = "X-Frame-Stream";
|
|
3039
3104
|
function isFrameStreamResponse(response) {
|