@solidjs/web 2.0.0-rc.0 → 2.0.0-rc.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/server.dev.js +4472 -0
- package/dist/server.js +1363 -224
- package/dist/{server.cjs → server.observe.js} +1563 -424
- package/dist/{dev.cjs → web.dev.js} +708 -365
- package/dist/web.js +460 -144
- package/dist/{dev.js → web.observe.js} +511 -213
- package/frames/dist/client.dev.js +464 -72
- package/frames/dist/client.js +364 -71
- package/frames/dist/{client.dev.cjs → client.observe.js} +487 -134
- package/frames/dist/server.dev.js +1713 -0
- package/frames/dist/server.js +553 -2495
- package/frames/dist/server.observe.js +1713 -0
- package/frames/package.json +2 -25
- package/package.json +214 -254
- package/performance-tracks/dist/performance-tracks.dev.js +678 -0
- package/performance-tracks/dist/performance-tracks.js +6 -0
- package/performance-tracks/dist/performance-tracks.observe.js +666 -0
- package/performance-tracks/package.json +7 -0
- package/performance-tracks/types/index.d.ts +67 -0
- package/serialization/decode/package.json +2 -15
- package/serialization/dist/decode.js +101 -12
- package/serialization/dist/serialization.js +112 -20
- package/serialization/package.json +2 -15
- package/serialization/types/index.d.ts +76 -157
- package/serialization/types/serializer-decode.d.ts +149 -112
- package/serialization/types/serializer.d.ts +101 -0
- package/server-functions/dist/client.dev.js +1364 -0
- package/server-functions/dist/client.js +745 -85
- package/server-functions/dist/client.observe.js +1343 -0
- package/server-functions/dist/server.dev.js +2203 -175
- package/server-functions/dist/server.js +2111 -176
- package/server-functions/dist/server.observe.js +3043 -0
- package/server-functions/package.json +2 -35
- package/server-functions/rich-args/package.json +2 -15
- package/storage/package.json +2 -15
- package/types/client.d.ts +193 -288
- package/types/constants.d.ts +20 -0
- package/types/cookies.d.ts +32 -84
- package/types/diagnostics.d.ts +56 -0
- package/types/frames/client.d.ts +1 -1
- package/types/frames/frame-client.d.ts +323 -259
- package/types/frames/frame-container-plugin.d.ts +72 -0
- package/types/frames/frame-sink.d.ts +101 -158
- package/types/frames/frame-transport.d.ts +192 -190
- package/types/frames/serializer-decode.d.ts +219 -0
- package/types/frames/serializer.d.ts +76 -157
- package/types/frames/server.d.ts +1 -1
- package/types/head.d.ts +19 -0
- package/types/index.d.ts +62 -76
- package/types/index.server.d.ts +174 -0
- package/types/jsx.d.ts +33 -26
- package/types/observe.d.ts +358 -0
- package/types/reconcile.d.ts +1 -0
- package/types/render.d.ts +9 -0
- package/types/response.d.ts +75 -150
- package/types/serializer-decode.d.ts +149 -112
- package/types/serializer.d.ts +76 -157
- package/types/server-functions/client.d.ts +202 -174
- package/types/server-functions/flash.d.ts +28 -30
- package/types/server-functions/registry.d.ts +102 -0
- package/types/server-functions/rich-args.d.ts +1 -10
- package/types/server-functions/server.d.ts +518 -454
- package/types/server-functions/shared.d.ts +366 -425
- package/types/server-mock.d.ts +110 -13
- package/types/server-observe.d.ts +77 -0
- package/types/server.d.ts +425 -425
- package/types/trace.d.ts +127 -0
- package/LICENSE +0 -21
- package/dist/web.cjs +0 -2007
- package/frames/dist/client.cjs +0 -1916
- package/frames/dist/server.cjs +0 -3667
- package/serialization/dist/decode.cjs +0 -110
- package/serialization/dist/serialization.cjs +0 -232
- package/serialization/types-cjs/index.d.cts +0 -182
- package/serialization/types-cjs/package.json +0 -3
- package/serialization/types-cjs/serializer-decode.d.cts +0 -182
- package/server-functions/dist/client.cjs +0 -646
- package/server-functions/dist/rich-args.cjs +0 -11
- package/server-functions/dist/server.cjs +0 -1077
- package/server-functions/dist/server.dev.cjs +0 -1077
- package/storage/dist/storage.cjs +0 -12
- package/storage/types-cjs/index.d.cts +0 -28
- package/storage/types-cjs/package.json +0 -3
- package/types/core.d.ts +0 -6
- package/types-cjs/client.d.cts +0 -337
- package/types-cjs/cookies.d.cts +0 -93
- package/types-cjs/core.d.cts +0 -6
- package/types-cjs/frames/client.d.cts +0 -36
- package/types-cjs/frames/frame-client.d.cts +0 -338
- package/types-cjs/frames/frame-sink.d.cts +0 -194
- package/types-cjs/frames/frame-transport.d.cts +0 -222
- package/types-cjs/frames/serializer.d.cts +0 -182
- package/types-cjs/frames/server.d.cts +0 -52
- package/types-cjs/index.d.cts +0 -230
- package/types-cjs/jsx-properties.d.cts +0 -93
- package/types-cjs/jsx.d.cts +0 -4150
- package/types-cjs/package.json +0 -3
- package/types-cjs/response.d.cts +0 -174
- package/types-cjs/serializer-decode.d.cts +0 -182
- package/types-cjs/serializer.d.cts +0 -182
- package/types-cjs/server-functions/client.d.cts +0 -201
- package/types-cjs/server-functions/flash.d.cts +0 -38
- package/types-cjs/server-functions/rich-args.d.cts +0 -10
- package/types-cjs/server-functions/server.d.cts +0 -588
- package/types-cjs/server-functions/shared.d.cts +0 -523
- package/types-cjs/server-mock.d.cts +0 -277
- package/types-cjs/server.d.cts +0 -523
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { createRenderEffect, createMemo,
|
|
2
|
-
export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, untrack } from 'solid-js';
|
|
1
|
+
import { createRenderEffect, createMemo, sharedConfig, enableHydration, $PROXY, untrack, runWithOwner, createRoot, getOwner, ROOT_ERROR_HOOK, flatten, flush, OBSERVE, createComponent, omit, createOwner, createSignal, onCleanup, createEffect } from 'solid-js';
|
|
2
|
+
export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
|
|
3
|
+
import { sourceKeys, SOURCE_PROXY, hasStaticKeys, resolvedTable, viewOf, OmitView, sourceHas, SOURCE_OMIT, sourceGet, SOURCE_MEMO, SOURCE_PLAIN } from 'solid-js/internal';
|
|
3
4
|
|
|
4
5
|
const DOMWithState = {
|
|
5
6
|
INPUT: {
|
|
@@ -48,31 +49,34 @@ const Namespaces = {
|
|
|
48
49
|
const VoidElements = /*#__PURE__*/new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]);
|
|
49
50
|
const RawTextElements = /*#__PURE__*/new Set(["style", "script", "noscript", "template", "textarea", "title"]);
|
|
50
51
|
const DOMElements = /*#__PURE__*/new Set(/*#__PURE__*/"a,abbr,acronym,address,applet,area,article,aside,audio,b,base,basefont,bdi,bdo,bgsound,big,blink,blockquote,body,br,button,canvas,caption,center,cite,code,col,colgroup,content,data,datalist,dd,del,details,dfn,dialog,dir,div,dl,dt,em,embed,fieldset,figcaption,figure,font,footer,form,frame,frameset,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,i,iframe,image,img,input,ins,isindex,kbd,keygen,label,legend,li,link,listing,main,map,mark,marquee,math,menu,menuitem,meta,meter,multicol,nav,nextid,nobr,noembed,noframes,noindex,noscript,object,ol,optgroup,option,output,p,param,picture,plaintext,portal,pre,progress,q,rb,rp,rt,rtc,ruby,s,samp,script,search,section,select,shadow,slot,small,source,spacer,span,strike,strong,style,sub,summary,sup,svg,table,tbody,td,template,textarea,tfoot,th,thead,time,title,tr,track,tt,u,ul,var,video,wbr,webview,xmp".split(","));
|
|
52
|
+
const COMPOSED_BODY_FRAMING = /*#__PURE__*/new Set(["content-length", "content-encoding", "transfer-encoding"]);
|
|
51
53
|
|
|
52
54
|
const transparentOptions = {
|
|
53
55
|
transparent: true,
|
|
54
56
|
sync: true
|
|
55
57
|
};
|
|
58
|
+
let spreadName;
|
|
59
|
+
function setSpreadName(name) {
|
|
60
|
+
spreadName = name;
|
|
61
|
+
}
|
|
56
62
|
const syncOptions = {
|
|
57
63
|
sync: true
|
|
58
64
|
};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
gate();
|
|
75
|
-
};
|
|
65
|
+
function effect(fn, effectFn, options) {
|
|
66
|
+
if (spreadName !== undefined && (options === undefined || options.name === undefined)) options = {
|
|
67
|
+
...options,
|
|
68
|
+
name: spreadName + ".spread"
|
|
69
|
+
};
|
|
70
|
+
const nodeOptions = options ? {
|
|
71
|
+
sync: true,
|
|
72
|
+
...options,
|
|
73
|
+
transparent: !options.scope
|
|
74
|
+
} : transparentOptions;
|
|
75
|
+
createRenderEffect(fn, effectFn, nodeOptions);
|
|
76
|
+
}
|
|
77
|
+
function memo(fn) {
|
|
78
|
+
return createMemo(() => fn(), syncOptions);
|
|
79
|
+
}
|
|
76
80
|
|
|
77
81
|
function reconcileArrays(parentNode, a, b, marker) {
|
|
78
82
|
let bLength = b.length,
|
|
@@ -86,13 +90,18 @@ function reconcileArrays(parentNode, a, b, marker) {
|
|
|
86
90
|
map = null,
|
|
87
91
|
anchor,
|
|
88
92
|
anchorTag;
|
|
93
|
+
const isLive = n => {
|
|
94
|
+
if (!n) return false;
|
|
95
|
+
const tag = n[$$SLOT];
|
|
96
|
+
return n.parentNode === parentNode && (!tag || tag === marker);
|
|
97
|
+
};
|
|
89
98
|
while (aStart < aEnd || bStart < bEnd) {
|
|
90
|
-
if (a[aStart] === b[bStart]) {
|
|
99
|
+
if (a[aStart] === b[bStart] && isLive(a[aStart])) {
|
|
91
100
|
aStart++;
|
|
92
101
|
bStart++;
|
|
93
102
|
continue;
|
|
94
103
|
}
|
|
95
|
-
while (a[aEnd - 1] === b[bEnd - 1]) {
|
|
104
|
+
while (a[aEnd - 1] === b[bEnd - 1] && isLive(a[aEnd - 1])) {
|
|
96
105
|
aEnd--;
|
|
97
106
|
bEnd--;
|
|
98
107
|
}
|
|
@@ -212,11 +221,24 @@ function classifyHeadTag(desc) {
|
|
|
212
221
|
resource: false
|
|
213
222
|
};
|
|
214
223
|
}
|
|
224
|
+
function qualifierValue(name, value) {
|
|
225
|
+
if (value == null || value === false) return null;
|
|
226
|
+
if (name === "imagesrcset" || name === "imagesizes") return typeof value === "string" && value !== "" ? value : null;
|
|
227
|
+
const v = value === true ? "" : String(value);
|
|
228
|
+
if (name === "as") return asciiLowerCase(v);
|
|
229
|
+
if (name !== "crossorigin") return v;
|
|
230
|
+
return v.length === 15 && v.toLowerCase() === "use-credentials" ? v.toLowerCase() : "anonymous";
|
|
231
|
+
}
|
|
232
|
+
function asciiLowerCase(value) {
|
|
233
|
+
return value.replace(/[A-Z]/g, c => String.fromCharCode(c.charCodeAt(0) + 32));
|
|
234
|
+
}
|
|
215
235
|
function resourceIdentity(tag, props) {
|
|
216
|
-
|
|
236
|
+
const url = String(props.href || props.src || "");
|
|
237
|
+
let id = "res:" + tag + ":" + (props.rel || "") + ":" + url.length + ":" + url;
|
|
217
238
|
for (let i = 0; i < RESOURCE_QUALIFIERS.length; i++) {
|
|
218
239
|
const q = RESOURCE_QUALIFIERS[i];
|
|
219
|
-
|
|
240
|
+
const value = qualifierValue(q, props[q]);
|
|
241
|
+
if (value !== null) id += ":" + q + "=" + value.length + ":" + value;
|
|
220
242
|
}
|
|
221
243
|
return id;
|
|
222
244
|
}
|
|
@@ -250,7 +272,6 @@ function resolveHead(groups) {
|
|
|
250
272
|
}
|
|
251
273
|
for (const [identity, tags] of byIdentity) {
|
|
252
274
|
if (identity === "title") {
|
|
253
|
-
if (tags.length > 1) console.warn("Multiple <title> tags in one head group; the last one wins.");
|
|
254
275
|
winners.set(identity, {
|
|
255
276
|
seq: group.seq,
|
|
256
277
|
tags: [tags[tags.length - 1]]
|
|
@@ -296,6 +317,7 @@ function serializeCookie(name, value, options = {}) {
|
|
|
296
317
|
if (options.expires) cookie += `; Expires=${options.expires.toUTCString()}`;
|
|
297
318
|
if (options.httpOnly) cookie += "; HttpOnly";
|
|
298
319
|
if (options.secure) cookie += "; Secure";
|
|
320
|
+
if (options.partitioned) cookie += "; Partitioned";
|
|
299
321
|
if (options.sameSite) {
|
|
300
322
|
const sameSite = options.sameSite.toLowerCase();
|
|
301
323
|
cookie += `; SameSite=${sameSite === "none" ? "None" : sameSite === "strict" ? "Strict" : "Lax"}`;
|
|
@@ -324,33 +346,61 @@ function getServerFunctionRPC() {
|
|
|
324
346
|
return globalThis[SERVER_FUNCTION_RPC];
|
|
325
347
|
}
|
|
326
348
|
|
|
327
|
-
const
|
|
349
|
+
const assetGates = new WeakMap();
|
|
350
|
+
const waitAsset = promise => {
|
|
351
|
+
let gate = assetGates.get(promise);
|
|
352
|
+
if (!gate) {
|
|
353
|
+
runWithOwner(null, () => {
|
|
354
|
+
gate = createMemo(() => promise, {
|
|
355
|
+
transparent: true
|
|
356
|
+
});
|
|
357
|
+
});
|
|
358
|
+
assetGates.set(promise, gate);
|
|
359
|
+
}
|
|
360
|
+
gate();
|
|
361
|
+
};
|
|
362
|
+
const EVENT_KEY = "_$$";
|
|
363
|
+
const $$EVENT_OWNER = "_$SOLID_EVENT_OWNER";
|
|
364
|
+
const $$EVENT_TUPLE = Symbol();
|
|
365
|
+
const hasOwn = Object.prototype.hasOwnProperty;
|
|
328
366
|
const INNER_OWNED = {};
|
|
329
367
|
const delegatedEvents = new Set();
|
|
330
368
|
const delegatedContainers = new Map();
|
|
331
|
-
function
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
369
|
+
function voidFn() {}
|
|
370
|
+
function generateHydrationScript(_options) {
|
|
371
|
+
return "";
|
|
372
|
+
}
|
|
373
|
+
function HydrationScript(_props) {
|
|
374
|
+
return null;
|
|
375
|
+
}
|
|
376
|
+
const getRequestEvent = voidFn;
|
|
377
|
+
const getTraceContext = voidFn;
|
|
378
|
+
function render(code, element, init, options = {}) {
|
|
335
379
|
let disposer;
|
|
336
380
|
registerDelegatedRoot(element);
|
|
337
381
|
try {
|
|
338
382
|
createRoot(dispose => {
|
|
339
383
|
disposer = dispose;
|
|
384
|
+
if (options.onError) getOwner()[ROOT_ERROR_HOOK] = options.onError;
|
|
340
385
|
if (element === document) {
|
|
341
386
|
const tree = code();
|
|
342
387
|
effect(() => flatten(tree), () => {});
|
|
343
388
|
} else {
|
|
344
389
|
const tree = code();
|
|
345
|
-
insert(element, () => tree, element.firstChild ? null : undefined, init,
|
|
390
|
+
insert(element, () => tree, element.firstChild ? null : undefined, init, {
|
|
391
|
+
...options.insertOptions,
|
|
392
|
+
schedule: true
|
|
393
|
+
});
|
|
346
394
|
}
|
|
347
395
|
}, {
|
|
348
396
|
id: options.renderId
|
|
349
397
|
});
|
|
398
|
+
flush();
|
|
350
399
|
} catch (err) {
|
|
351
400
|
if (disposer) disposer();
|
|
352
401
|
unregisterDelegatedRoot(element);
|
|
353
402
|
throw err;
|
|
403
|
+
} finally {
|
|
354
404
|
}
|
|
355
405
|
return () => {
|
|
356
406
|
disposer();
|
|
@@ -359,7 +409,6 @@ function render$1(code, element, init, options = {}) {
|
|
|
359
409
|
};
|
|
360
410
|
}
|
|
361
411
|
function create(html, bypassGuard, flag) {
|
|
362
|
-
if (isHydrating() && !bypassGuard) throw new Error("Failed attempt to create new DOM elements during hydration. Check that the libraries you are using support hydration.");
|
|
363
412
|
const t = document.createElement("template");
|
|
364
413
|
t.innerHTML = html;
|
|
365
414
|
return flag === 2 ? t.content.firstChild.firstChild : t.content.firstChild;
|
|
@@ -367,7 +416,6 @@ function create(html, bypassGuard, flag) {
|
|
|
367
416
|
function template(html, flag) {
|
|
368
417
|
let node;
|
|
369
418
|
const fn = flag === 1 ? bypassGuard => document.importNode(node || (node = create(html, bypassGuard, flag)), true) : bypassGuard => (node || (node = create(html, bypassGuard, flag))).cloneNode(true);
|
|
370
|
-
fn._html = flag === 2 ? html.replace(/^<[^>]+>/, "") : html;
|
|
371
419
|
return fn;
|
|
372
420
|
}
|
|
373
421
|
function delegateEvents(eventNames) {
|
|
@@ -410,10 +458,32 @@ function unregisterDelegatedContainer(container, owner = container) {
|
|
|
410
458
|
}
|
|
411
459
|
function attachDelegatedEvent(name, container, state) {
|
|
412
460
|
if (state.handlers.has(name)) return;
|
|
413
|
-
const handler = e => eventHandler(e, container, state);
|
|
461
|
+
const handler = e => dispatchAsInteraction(e, () => eventHandler(e, container, state)) ;
|
|
414
462
|
state.handlers.set(name, handler);
|
|
415
463
|
container.addEventListener(name, handler);
|
|
416
464
|
}
|
|
465
|
+
function describeEventTarget(target) {
|
|
466
|
+
if (!target || typeof target.tagName !== "string") return undefined;
|
|
467
|
+
const tag = target.tagName.toLowerCase();
|
|
468
|
+
let out = tag;
|
|
469
|
+
if (target.id) out += `#${target.id}`;else if (typeof target.name === "string" && target.name) out += `[name=${target.name}]`;
|
|
470
|
+
if (tag !== "input" && tag !== "textarea" && tag !== "select") {
|
|
471
|
+
const text = (target.textContent || "").trim().replace(/\s+/g, " ");
|
|
472
|
+
if (text) out += ` "${text.length > 30 ? text.slice(0, 29) + "…" : text}"`;
|
|
473
|
+
}
|
|
474
|
+
return out;
|
|
475
|
+
}
|
|
476
|
+
function interactionStart(e) {
|
|
477
|
+
const at = e.timeStamp;
|
|
478
|
+
return typeof at === "number" && at >= 0 && at <= performance.now() ? at : undefined;
|
|
479
|
+
}
|
|
480
|
+
function dispatchAsInteraction(e, fn) {
|
|
481
|
+
return OBSERVE.attribution.withInteraction({
|
|
482
|
+
type: e.type,
|
|
483
|
+
target: describeEventTarget(e.target),
|
|
484
|
+
at: interactionStart(e)
|
|
485
|
+
}, fn);
|
|
486
|
+
}
|
|
417
487
|
function getDelegatedRoot(node) {
|
|
418
488
|
while (node) {
|
|
419
489
|
if (delegatedContainers.get(node)?.roots) return node;
|
|
@@ -434,10 +504,11 @@ function findOwner(target, state) {
|
|
|
434
504
|
}
|
|
435
505
|
function setProperty(node, name, value) {
|
|
436
506
|
if (isHydrating(node)) return;
|
|
437
|
-
|
|
507
|
+
const nodeName = node.nodeName;
|
|
508
|
+
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;
|
|
438
509
|
}
|
|
439
510
|
let claimHandlers = null;
|
|
440
|
-
const CLAIM_SEAM = Symbol.for("
|
|
511
|
+
const CLAIM_SEAM = Symbol.for("solid.element-claims");
|
|
441
512
|
function registerElementClaim(handler) {
|
|
442
513
|
(claimHandlers || (claimHandlers = globalThis[CLAIM_SEAM] = [])).push(handler);
|
|
443
514
|
return () => {
|
|
@@ -468,7 +539,17 @@ function claimElement(node) {
|
|
|
468
539
|
}
|
|
469
540
|
function setAttribute(node, name, value) {
|
|
470
541
|
if (isHydrating(node)) return;
|
|
471
|
-
|
|
542
|
+
const selectMultiple = name === "multiple" && node.localName === "select";
|
|
543
|
+
if (value == null || value === false) node.removeAttribute(name);else {
|
|
544
|
+
node.setAttribute(name, value === true ? "" : value);
|
|
545
|
+
if (selectMultiple && !node._$multiple) {
|
|
546
|
+
const options = node.options;
|
|
547
|
+
for (let i = 0; i < options.length; i++) {
|
|
548
|
+
if (options[i].defaultSelected) options[i].selected = true;
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
if (selectMultiple) node._$multiple = true;
|
|
472
553
|
if (claimHandlers !== null && (name === "href" || name === "action")) claimElement(node);
|
|
473
554
|
}
|
|
474
555
|
function setAttributeNS(node, namespace, name, value) {
|
|
@@ -476,22 +557,32 @@ function setAttributeNS(node, namespace, name, value) {
|
|
|
476
557
|
if (value == null || value === false) node.removeAttributeNS(namespace, name.indexOf(":") > -1 ? name.split(":").pop() : name);else node.setAttributeNS(namespace, name, value === true ? "" : value);
|
|
477
558
|
}
|
|
478
559
|
function className(node, value, prev) {
|
|
479
|
-
if (
|
|
560
|
+
if (typeof value === "number") value = "" + value;
|
|
561
|
+
if (typeof prev === "number") prev = "" + prev;
|
|
562
|
+
if (isHydrating(node)) {
|
|
563
|
+
node._$classes = value && typeof value === "object" ? classListToObject(value) : undefined;
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
480
566
|
if (value == null || value === false) {
|
|
481
|
-
prev
|
|
567
|
+
if (prev || node._$classes) {
|
|
568
|
+
node.removeAttribute("class");
|
|
569
|
+
node._$classes = undefined;
|
|
570
|
+
}
|
|
482
571
|
return;
|
|
483
572
|
}
|
|
484
573
|
if (typeof value === "string") {
|
|
574
|
+
node._$classes = undefined;
|
|
485
575
|
value !== prev && node.setAttribute("class", value);
|
|
486
576
|
return;
|
|
487
577
|
}
|
|
578
|
+
let applied;
|
|
488
579
|
if (typeof prev === "string") {
|
|
489
|
-
|
|
580
|
+
applied = {};
|
|
490
581
|
node.removeAttribute("class");
|
|
491
|
-
} else
|
|
582
|
+
} else applied = node._$classes || classListToObject(prev || {});
|
|
492
583
|
value = classListToObject(value);
|
|
493
|
-
const classKeys = Object.keys(value
|
|
494
|
-
const prevKeys = Object.keys(
|
|
584
|
+
const classKeys = Object.keys(value);
|
|
585
|
+
const prevKeys = Object.keys(applied);
|
|
495
586
|
let i, len;
|
|
496
587
|
for (i = 0, len = prevKeys.length; i < len; i++) {
|
|
497
588
|
const key = prevKeys[i];
|
|
@@ -501,22 +592,39 @@ function className(node, value, prev) {
|
|
|
501
592
|
for (i = 0, len = classKeys.length; i < len; i++) {
|
|
502
593
|
const key = classKeys[i],
|
|
503
594
|
classValue = !!value[key];
|
|
504
|
-
if (!key || key === "undefined" ||
|
|
595
|
+
if (!key || key === "undefined" || applied[key] === classValue || !classValue) continue;
|
|
505
596
|
node.classList.add(key);
|
|
506
597
|
}
|
|
598
|
+
node._$classes = value;
|
|
507
599
|
}
|
|
508
600
|
function addEvent(node, name, handler, delegate) {
|
|
509
601
|
if (delegate) {
|
|
602
|
+
const key = EVENT_KEY + name;
|
|
603
|
+
let data;
|
|
510
604
|
if (Array.isArray(handler)) {
|
|
511
|
-
|
|
512
|
-
node[
|
|
513
|
-
} else node[
|
|
514
|
-
|
|
605
|
+
data = handler[1];
|
|
606
|
+
node[key] = handler[0];
|
|
607
|
+
} else node[key] = handler;
|
|
608
|
+
node[`${key}Data`] = data;
|
|
609
|
+
return;
|
|
610
|
+
}
|
|
611
|
+
if (Array.isArray(handler)) {
|
|
515
612
|
const handlerFn = handler[0];
|
|
516
|
-
|
|
517
|
-
|
|
613
|
+
const listener = e => dispatchAsInteraction(e, () => handlerFn.call(node, handler[1], e)) ;
|
|
614
|
+
listener[$$EVENT_TUPLE] = handler;
|
|
615
|
+
node.addEventListener(name, listener);
|
|
616
|
+
return listener;
|
|
617
|
+
}
|
|
618
|
+
if (typeof handler === "function") {
|
|
619
|
+
const listener = e => dispatchAsInteraction(e, () => handler.call(node, e));
|
|
620
|
+
node.addEventListener(name, listener);
|
|
621
|
+
return listener;
|
|
622
|
+
}
|
|
623
|
+
node.addEventListener(name, handler, typeof handler !== "function" && handler);
|
|
624
|
+
return handler;
|
|
518
625
|
}
|
|
519
626
|
function style(node, value, prev) {
|
|
627
|
+
if (isHydrating(node)) return;
|
|
520
628
|
if (!value) {
|
|
521
629
|
if (prev || node._$styles) {
|
|
522
630
|
setAttribute(node, "style");
|
|
@@ -541,12 +649,13 @@ function style(node, value, prev) {
|
|
|
541
649
|
}
|
|
542
650
|
let v, s;
|
|
543
651
|
for (s in applied) {
|
|
544
|
-
if (value[s] == null) {
|
|
652
|
+
if (!hasOwn.call(value, s) || value[s] == null) {
|
|
545
653
|
nodeStyle.removeProperty(s);
|
|
546
654
|
delete applied[s];
|
|
547
655
|
}
|
|
548
656
|
}
|
|
549
657
|
for (s in value) {
|
|
658
|
+
if (!hasOwn.call(value, s)) continue;
|
|
550
659
|
v = value[s];
|
|
551
660
|
if (v != null && v !== applied[s]) {
|
|
552
661
|
nodeStyle.setProperty(s, v);
|
|
@@ -554,26 +663,131 @@ function style(node, value, prev) {
|
|
|
554
663
|
}
|
|
555
664
|
}
|
|
556
665
|
}
|
|
666
|
+
function readShallow(value) {
|
|
667
|
+
if (value === null || typeof value !== "object") return value;
|
|
668
|
+
if (Array.isArray(value)) return value.map(readShallow);
|
|
669
|
+
if (value[$PROXY] !== value) return value;
|
|
670
|
+
const keys = sourceKeys(value, SOURCE_PROXY);
|
|
671
|
+
const out = {};
|
|
672
|
+
for (let i = 0; i < keys.length; i++) {
|
|
673
|
+
const k = keys[i];
|
|
674
|
+
if (typeof k === "string") out[k] = value[k];
|
|
675
|
+
}
|
|
676
|
+
return out;
|
|
677
|
+
}
|
|
557
678
|
function setStyleProperty(node, name, value) {
|
|
679
|
+
if (isHydrating(node)) return;
|
|
558
680
|
value != null ? node.style.setProperty(name, value) : node.style.removeProperty(name);
|
|
559
681
|
}
|
|
560
|
-
function spread(node, props
|
|
682
|
+
function spread(node, props, skipChildren, skip, name) {
|
|
683
|
+
if (name !== undefined) {
|
|
684
|
+
const outer = spreadName;
|
|
685
|
+
setSpreadName(name);
|
|
686
|
+
try {
|
|
687
|
+
return spread(node, props, skipChildren, skip);
|
|
688
|
+
} finally {
|
|
689
|
+
setSpreadName(outer);
|
|
690
|
+
}
|
|
691
|
+
}
|
|
561
692
|
const prevProps = {};
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
(
|
|
566
|
-
}
|
|
693
|
+
const apply = newProps => {
|
|
694
|
+
const r = newProps.ref;
|
|
695
|
+
if (r !== prevProps.ref && (typeof r === "function" || Array.isArray(r))) ref(() => r, node);
|
|
696
|
+
assign(node, newProps, true, prevProps, true);
|
|
697
|
+
};
|
|
698
|
+
if (Array.isArray(props)) {
|
|
699
|
+
if (!skipChildren && !(skip !== undefined && skip("children"))) insert(node, () => {
|
|
700
|
+
for (let i = props.length - 1; i >= 0; i--) {
|
|
701
|
+
const s = resolveSource(props[i]);
|
|
702
|
+
if (s != null && entryHas(s, "children")) return entryGet(s, "children");
|
|
703
|
+
}
|
|
704
|
+
});
|
|
705
|
+
effect(() => collectSources({}, props, undefined, skip), apply);
|
|
706
|
+
return prevProps;
|
|
707
|
+
}
|
|
708
|
+
if (!skipChildren && !(skip !== undefined && skip("children"))) {
|
|
709
|
+
if (typeof props !== "function" && props != null && hasStaticKeys(props)) {
|
|
710
|
+
const desc = Object.getOwnPropertyDescriptor(props, "children");
|
|
711
|
+
if (desc !== undefined) {
|
|
712
|
+
if (desc.get === undefined) insert(node, desc.value);else insert(node, () => props.children);
|
|
713
|
+
}
|
|
714
|
+
} else insert(node, () => {
|
|
715
|
+
const source = resolveSource(props);
|
|
716
|
+
return source != null && entryHas(source, "children") ? entryGet(source, "children") : undefined;
|
|
717
|
+
});
|
|
718
|
+
}
|
|
567
719
|
effect(() => {
|
|
720
|
+
const source = resolveSource(props);
|
|
568
721
|
const newProps = {};
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
722
|
+
const table = resolvedTable(source);
|
|
723
|
+
if (table !== undefined) return collectTable(newProps, table, skip);
|
|
724
|
+
if (source != null) {
|
|
725
|
+
const view = viewOf(source);
|
|
726
|
+
if (view instanceof OmitView) collectProps(newProps, view, SOURCE_OMIT, skip);else if (view !== undefined) collectSources(newProps, view.sources, view.kinds, skip);else collectProps(newProps, source, $PROXY in source ? SOURCE_PROXY : SOURCE_PLAIN, skip);
|
|
572
727
|
}
|
|
573
728
|
return newProps;
|
|
574
|
-
},
|
|
729
|
+
}, apply);
|
|
575
730
|
return prevProps;
|
|
576
731
|
}
|
|
732
|
+
function collectTable(out, table, skip) {
|
|
733
|
+
for (const [prop, leaf] of table) {
|
|
734
|
+
if (typeof prop !== "string" || prop === "children") continue;
|
|
735
|
+
if (skip !== undefined && skip(prop)) continue;
|
|
736
|
+
const v = leaf[prop];
|
|
737
|
+
out[prop] = prop === "style" || prop === "class" ? readShallow(v) : v;
|
|
738
|
+
}
|
|
739
|
+
return out;
|
|
740
|
+
}
|
|
741
|
+
function resolveSource(s) {
|
|
742
|
+
return typeof s === "function" ? s() : s;
|
|
743
|
+
}
|
|
744
|
+
function entryHas(s, key) {
|
|
745
|
+
const view = viewOf(s);
|
|
746
|
+
return view instanceof OmitView ? sourceHas(view, SOURCE_OMIT, key) : key in s;
|
|
747
|
+
}
|
|
748
|
+
function entryGet(s, key) {
|
|
749
|
+
const view = viewOf(s);
|
|
750
|
+
return view instanceof OmitView ? sourceGet(view, SOURCE_OMIT, key) : s[key];
|
|
751
|
+
}
|
|
752
|
+
function collectSources(out, sources, kinds, skip) {
|
|
753
|
+
const resolved = [];
|
|
754
|
+
const resolvedKinds = [];
|
|
755
|
+
for (let i = 0; i < sources.length; i++) pushEntry(resolved, resolvedKinds, sources[i], kinds !== undefined ? kinds[i] : SOURCE_MEMO);
|
|
756
|
+
for (let i = 0; i < resolved.length; i++) collectProps(out, resolved[i], resolvedKinds[i], skip, resolved, resolvedKinds, i + 1);
|
|
757
|
+
return out;
|
|
758
|
+
}
|
|
759
|
+
function pushEntry(resolved, kinds, s, kind) {
|
|
760
|
+
if (kind !== SOURCE_MEMO) {
|
|
761
|
+
resolved.push(s);
|
|
762
|
+
kinds.push(kind);
|
|
763
|
+
return;
|
|
764
|
+
}
|
|
765
|
+
s = resolveSource(s);
|
|
766
|
+
if (s == null) return;
|
|
767
|
+
const view = viewOf(s);
|
|
768
|
+
if (view instanceof OmitView) {
|
|
769
|
+
resolved.push(view);
|
|
770
|
+
kinds.push(SOURCE_OMIT);
|
|
771
|
+
} else if (view !== undefined) {
|
|
772
|
+
const f = view.sources,
|
|
773
|
+
k = view.kinds;
|
|
774
|
+
for (let j = 0; j < f.length; j++) pushEntry(resolved, kinds, f[j], k[j]);
|
|
775
|
+
} else {
|
|
776
|
+
resolved.push(s);
|
|
777
|
+
kinds.push($PROXY in s ? SOURCE_PROXY : SOURCE_PLAIN);
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
function collectProps(out, s, kind, skip, later, laterKinds, from) {
|
|
781
|
+
const keys = sourceKeys(s, kind);
|
|
782
|
+
outer: for (let i = 0; i < keys.length; i++) {
|
|
783
|
+
const prop = keys[i];
|
|
784
|
+
if (typeof prop !== "string" || prop === "children") continue;
|
|
785
|
+
if (skip !== undefined && skip(prop)) continue;
|
|
786
|
+
if (later !== undefined) for (let j = from; j < later.length; j++) if (sourceHas(later[j], laterKinds[j], prop)) continue outer;
|
|
787
|
+
const v = sourceGet(s, kind, prop);
|
|
788
|
+
out[prop] = prop === "style" || prop === "class" ? readShallow(v) : v;
|
|
789
|
+
}
|
|
790
|
+
}
|
|
577
791
|
function dynamicProperty(props, key) {
|
|
578
792
|
const src = props[key];
|
|
579
793
|
Object.defineProperty(props, key, {
|
|
@@ -603,8 +817,7 @@ function installHydrationRuntime() {
|
|
|
603
817
|
hydrationRt = {
|
|
604
818
|
claimInitial(parent, multi, initial) {
|
|
605
819
|
if (isHydrating(parent)) {
|
|
606
|
-
if (!multi && initial === undefined && parent) initial =
|
|
607
|
-
if (Array.isArray(initial)) stripTextSeparators(initial);
|
|
820
|
+
if (!multi && initial === undefined && parent) initial = claimChildNodes(parent);else if (Array.isArray(initial)) stripTextSeparators(initial);
|
|
608
821
|
}
|
|
609
822
|
return initial;
|
|
610
823
|
},
|
|
@@ -628,7 +841,7 @@ function installHydrationRuntime() {
|
|
|
628
841
|
nodes.unshift(node);
|
|
629
842
|
node = node.previousSibling;
|
|
630
843
|
}
|
|
631
|
-
} else
|
|
844
|
+
} else return claimChildNodes(parent);
|
|
632
845
|
return stripTextSeparators(nodes);
|
|
633
846
|
},
|
|
634
847
|
dedupEvent(e) {
|
|
@@ -641,20 +854,41 @@ function stripTextSeparators(nodes) {
|
|
|
641
854
|
for (let i = 0; i < nodes.length; i++) {
|
|
642
855
|
const node = nodes[i],
|
|
643
856
|
t = node.nodeType;
|
|
644
|
-
if (t === 8) {
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
}
|
|
650
|
-
if (v.startsWith("pl-")) continue;
|
|
651
|
-
} else if (t === 1 && node.localName === "template" && node.id.startsWith("pl-")) continue;
|
|
857
|
+
if (t === 8 && node.nodeValue === "!$") {
|
|
858
|
+
node.remove();
|
|
859
|
+
continue;
|
|
860
|
+
}
|
|
861
|
+
if (isPlaceholderScaffolding(node, t)) continue;
|
|
652
862
|
nodes[j++] = node;
|
|
653
863
|
}
|
|
654
864
|
nodes.length = j;
|
|
655
865
|
return nodes;
|
|
656
866
|
}
|
|
867
|
+
function claimChildNodes(parent) {
|
|
868
|
+
const live = parent.childNodes;
|
|
869
|
+
const out = [];
|
|
870
|
+
for (let i = 0, n = live.length; i < n; i++) {
|
|
871
|
+
const node = live[i],
|
|
872
|
+
t = node.nodeType;
|
|
873
|
+
if (t === 8 && node.nodeValue === "!$") {
|
|
874
|
+
node.remove();
|
|
875
|
+
i--;
|
|
876
|
+
n--;
|
|
877
|
+
continue;
|
|
878
|
+
}
|
|
879
|
+
if (isPlaceholderScaffolding(node, t)) continue;
|
|
880
|
+
out.push(node);
|
|
881
|
+
}
|
|
882
|
+
return out;
|
|
883
|
+
}
|
|
884
|
+
function isPlaceholderScaffolding(node, t) {
|
|
885
|
+
return t === 8 ? node.nodeValue.startsWith("pl-") : t === 1 && node.localName === "template" && node.id.startsWith("pl-");
|
|
886
|
+
}
|
|
657
887
|
function insert(parent, accessor, marker, initial, options) {
|
|
888
|
+
if (spreadName !== undefined && (options === undefined || options.name === undefined)) options = {
|
|
889
|
+
...options,
|
|
890
|
+
name: spreadName + ".children"
|
|
891
|
+
};
|
|
658
892
|
const multi = marker !== undefined;
|
|
659
893
|
const host = options && options.host;
|
|
660
894
|
if (multi && !initial) initial = [];
|
|
@@ -718,10 +952,16 @@ function assetEntryKey(descriptor) {
|
|
|
718
952
|
if (descriptor.policy === "exclusive") return "x|" + descriptor.key;
|
|
719
953
|
return descriptor.type === "inline-style" ? "i|" + descriptor.id : descriptor.type + "|" + descriptor.href;
|
|
720
954
|
}
|
|
721
|
-
function findAssetElement(selector, attr, value) {
|
|
955
|
+
function findAssetElement(selector, attr, value, qualifiers) {
|
|
722
956
|
const nodes = document.querySelectorAll(selector);
|
|
723
|
-
for (let i = 0; i < nodes.length; i++) {
|
|
724
|
-
if (nodes[i].getAttribute(attr)
|
|
957
|
+
outer: for (let i = 0; i < nodes.length; i++) {
|
|
958
|
+
if (nodes[i].getAttribute(attr) !== value) continue;
|
|
959
|
+
if (!qualifiers) return nodes[i];
|
|
960
|
+
for (let q = 0; q < RESOURCE_QUALIFIERS.length; q++) {
|
|
961
|
+
const name = RESOURCE_QUALIFIERS[q];
|
|
962
|
+
if (qualifierValue(name, qualifiers[name]) !== qualifierValue(name, nodes[i].getAttribute(name))) continue outer;
|
|
963
|
+
}
|
|
964
|
+
return nodes[i];
|
|
725
965
|
}
|
|
726
966
|
return null;
|
|
727
967
|
}
|
|
@@ -894,7 +1134,7 @@ function initHeadRegistry() {
|
|
|
894
1134
|
headOwned = new Map();
|
|
895
1135
|
headApplied = new Map();
|
|
896
1136
|
const t = document.querySelector("title");
|
|
897
|
-
headFallbackTitle = t
|
|
1137
|
+
headFallbackTitle = t ? t.hasAttribute("data-dh") ? t.getAttribute("data-dhf") : t.textContent : null;
|
|
898
1138
|
if (globalThis._$HY) globalThis._$HY.h = applyServerHeadOps;
|
|
899
1139
|
}
|
|
900
1140
|
function applyServerHeadOps(ops) {
|
|
@@ -949,7 +1189,11 @@ function flushHeadRegistry() {
|
|
|
949
1189
|
headOwned.delete(identity);
|
|
950
1190
|
headApplied.delete(identity);
|
|
951
1191
|
if (identity === "title") {
|
|
952
|
-
if (headFallbackTitle != null)
|
|
1192
|
+
if (headFallbackTitle != null) {
|
|
1193
|
+
const el = setHeadTitle(headFallbackTitle);
|
|
1194
|
+
el.removeAttribute("data-dh");
|
|
1195
|
+
el.removeAttribute("data-dhf");
|
|
1196
|
+
}
|
|
953
1197
|
} else {
|
|
954
1198
|
for (let i = 0; i < els.length; i++) els[i].remove();
|
|
955
1199
|
}
|
|
@@ -960,7 +1204,6 @@ function flushHeadRegistry() {
|
|
|
960
1204
|
if (headApplied.get(identity) === sig) continue;
|
|
961
1205
|
headApplied.set(identity, sig);
|
|
962
1206
|
if (identity === "base" || identity === "charset") {
|
|
963
|
-
console.warn(`useHead: <${winner.tags[0].tag}> (${identity}) is shell-only and ignored on the client`);
|
|
964
1207
|
continue;
|
|
965
1208
|
}
|
|
966
1209
|
if (identity === "title") {
|
|
@@ -985,7 +1228,6 @@ function createHeadElement(tag, props) {
|
|
|
985
1228
|
for (const name in props) {
|
|
986
1229
|
if (name === "children" || name === "ref" || name.slice(0, 2) === "on") continue;
|
|
987
1230
|
if (!HEAD_ATTR_NAME.test(name)) {
|
|
988
|
-
console.warn(`useHead: ignoring invalid attribute name "${name}"`);
|
|
989
1231
|
continue;
|
|
990
1232
|
}
|
|
991
1233
|
const v = props[name];
|
|
@@ -1023,8 +1265,8 @@ function mountHeadResource(tag, props) {
|
|
|
1023
1265
|
headMountedResources.add(identity);
|
|
1024
1266
|
const url = props.href || props.src;
|
|
1025
1267
|
let el = null;
|
|
1026
|
-
if (url != null) {
|
|
1027
|
-
if (tag === "link") el = findAssetElement(`link[rel="${props.rel}"]`, "href", url);else if (tag === "script") el = findAssetElement("script[src]", "src", url);else el = findAssetElement("style[href]", "href", url);
|
|
1268
|
+
if (tag === "link" && url == null && typeof props.imagesrcset === "string") el = findAssetElement(`link[rel="${props.rel}"]`, "href", null, props);else if (url != null) {
|
|
1269
|
+
if (tag === "link") el = findAssetElement(`link[rel="${props.rel}"]`, "href", url, props);else if (tag === "script") el = findAssetElement("script[src]", "src", url);else el = findAssetElement("style[href]", "href", url);
|
|
1028
1270
|
}
|
|
1029
1271
|
if (!el) document.head.appendChild(createHeadElement(tag, props));
|
|
1030
1272
|
}
|
|
@@ -1046,7 +1288,7 @@ function gateHeadResource(props) {
|
|
|
1046
1288
|
if (attrs) descriptor.attrs = attrs;
|
|
1047
1289
|
effect(() => {
|
|
1048
1290
|
const entry = warmAsset(descriptor);
|
|
1049
|
-
if (gateable && entry.loadState === "pending" && typeof waitAsset === "function") waitAsset(entry.loadPromise);
|
|
1291
|
+
if (gateable && !sharedConfig.hydrating && entry.loadState === "pending" && typeof waitAsset === "function") waitAsset(entry.loadPromise);
|
|
1050
1292
|
}, () => acquireAsset(descriptor));
|
|
1051
1293
|
}
|
|
1052
1294
|
function useHead(tags) {
|
|
@@ -1064,7 +1306,6 @@ function useHead(tags) {
|
|
|
1064
1306
|
for (let i = 0; i < list.length; i++) {
|
|
1065
1307
|
const desc = list[i];
|
|
1066
1308
|
if (!desc || !HEAD_ELIGIBLE_TAGS.has(desc.tag)) {
|
|
1067
|
-
console.warn(`useHead: ignoring non-head tag`, desc);
|
|
1068
1309
|
continue;
|
|
1069
1310
|
}
|
|
1070
1311
|
const cls = classifyHeadTag(desc);
|
|
@@ -1116,7 +1357,7 @@ function loadModuleAssets(mapping) {
|
|
|
1116
1357
|
const pending = [];
|
|
1117
1358
|
for (const key in mapping) {
|
|
1118
1359
|
if (hy.modules[key]) continue;
|
|
1119
|
-
const entryUrl = mapping[key];
|
|
1360
|
+
const entryUrl = new URL(mapping[key], document.baseURI).href;
|
|
1120
1361
|
if (!hy.loading[key]) {
|
|
1121
1362
|
hy.loading[key] = import(entryUrl).then(mod => {
|
|
1122
1363
|
hy.modules[key] = mod;
|
|
@@ -1129,9 +1370,19 @@ function loadModuleAssets(mapping) {
|
|
|
1129
1370
|
}
|
|
1130
1371
|
return pending.length ? Promise.all(pending).then(() => {}) : undefined;
|
|
1131
1372
|
}
|
|
1132
|
-
function hydrate
|
|
1373
|
+
function hydrate(code, element, options = {}) {
|
|
1374
|
+
enableHydration();
|
|
1133
1375
|
installHydrationRuntime();
|
|
1134
|
-
if (globalThis._$HY.done) return render
|
|
1376
|
+
if (globalThis._$HY.done) return render(code, element, [...element.childNodes], options);
|
|
1377
|
+
const head = (element.nodeType === 9 ? element : element.ownerDocument).head;
|
|
1378
|
+
if (head && element.contains(head)) {
|
|
1379
|
+
let n = head.firstChild;
|
|
1380
|
+
while (n && n.nodeType === 1 && n.hasAttribute("data-dh") && !n.hasAttribute("data-dhf")) {
|
|
1381
|
+
const next = n.nextSibling;
|
|
1382
|
+
head.appendChild(n);
|
|
1383
|
+
n = next;
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1135
1386
|
options.renderId ||= "";
|
|
1136
1387
|
if (!globalThis._$HY.modules) globalThis._$HY.modules = {};
|
|
1137
1388
|
if (!globalThis._$HY.loading) globalThis._$HY.loading = {};
|
|
@@ -1166,16 +1417,6 @@ function hydrate$1(code, element, options = {}) {
|
|
|
1166
1417
|
});
|
|
1167
1418
|
};
|
|
1168
1419
|
sharedConfig.hydrating = true;
|
|
1169
|
-
{
|
|
1170
|
-
sharedConfig.verifyHydration = () => {
|
|
1171
|
-
if (sharedConfig.registry && sharedConfig.registry.size) {
|
|
1172
|
-
const orphaned = [...sharedConfig.registry.values()].filter(node => node.isConnected);
|
|
1173
|
-
sharedConfig.registry.clear();
|
|
1174
|
-
if (!orphaned.length) return;
|
|
1175
|
-
console.warn(`Hydration completed with ${orphaned.length} unclaimed server-rendered node(s):\n` + orphaned.map(node => ` ${node.outerHTML.slice(0, 100)}`).join("\n"));
|
|
1176
|
-
}
|
|
1177
|
-
};
|
|
1178
|
-
}
|
|
1179
1420
|
const hyr = globalThis._$HY.r;
|
|
1180
1421
|
const rootMapping = hyr && (hyr[options.renderId + "_assets"] || hyr["_assets"]);
|
|
1181
1422
|
if (rootMapping && typeof rootMapping === "object") {
|
|
@@ -1190,22 +1431,26 @@ function hydrate$1(code, element, options = {}) {
|
|
|
1190
1431
|
sharedConfig.gather = gather;
|
|
1191
1432
|
sharedConfig.hydrating = true;
|
|
1192
1433
|
try {
|
|
1193
|
-
disposer = render
|
|
1434
|
+
disposer = render(code, element, [...element.childNodes], options);
|
|
1194
1435
|
} finally {
|
|
1195
1436
|
sharedConfig.hydrating = false;
|
|
1196
1437
|
}
|
|
1197
1438
|
}, err => {
|
|
1198
|
-
console.error("Hydration module preload failed, falling back to client render:", err);
|
|
1199
1439
|
sharedConfig.hydrating = false;
|
|
1200
1440
|
sharedConfig.registry = undefined;
|
|
1201
|
-
|
|
1441
|
+
if (element.nodeType === 9) {
|
|
1442
|
+
(globalThis.reportError || console.error)(err);
|
|
1443
|
+
return;
|
|
1444
|
+
}
|
|
1445
|
+
console.error("Hydration module preload failed, falling back to client render:", err);
|
|
1446
|
+
disposer = render(code, element, [...element.childNodes], options);
|
|
1202
1447
|
});
|
|
1203
1448
|
return () => disposer && disposer();
|
|
1204
1449
|
}
|
|
1205
1450
|
}
|
|
1206
1451
|
try {
|
|
1207
1452
|
gatherHydratable(element, options.renderId);
|
|
1208
|
-
return render
|
|
1453
|
+
return render(code, element, [...element.childNodes], options);
|
|
1209
1454
|
} finally {
|
|
1210
1455
|
sharedConfig.hydrating = false;
|
|
1211
1456
|
}
|
|
@@ -1220,12 +1465,6 @@ function getNextElement(template) {
|
|
|
1220
1465
|
}
|
|
1221
1466
|
return template(true);
|
|
1222
1467
|
}
|
|
1223
|
-
if (template && template._html) {
|
|
1224
|
-
const expected = template._html.match(/^<(\w+)/)?.[1];
|
|
1225
|
-
if (expected && node.localName !== expected) {
|
|
1226
|
-
console.warn(`Hydration tag mismatch for key "${key}": expected <${expected}> but found`, node);
|
|
1227
|
-
}
|
|
1228
|
-
}
|
|
1229
1468
|
if (sharedConfig.completed) sharedConfig.completed.add(node);
|
|
1230
1469
|
sharedConfig.registry.delete(key);
|
|
1231
1470
|
return node;
|
|
@@ -1255,48 +1494,12 @@ function getNextMarker(start) {
|
|
|
1255
1494
|
}
|
|
1256
1495
|
function getFirstChild(node, expectedTag) {
|
|
1257
1496
|
const child = node.firstChild;
|
|
1258
|
-
if (isHydrating() && expectedTag && child?.localName !== expectedTag) {
|
|
1259
|
-
const isMissing = !child || child.nodeType !== 1;
|
|
1260
|
-
console.warn("Hydration structure mismatch: expected <" + expectedTag + "> as first child of", node, "\n " + describeSiblings(node, child, expectedTag, isMissing));
|
|
1261
|
-
}
|
|
1262
1497
|
return child;
|
|
1263
1498
|
}
|
|
1264
1499
|
function getNextSibling(node, expectedTag) {
|
|
1265
1500
|
const sibling = node.nextSibling;
|
|
1266
|
-
if (isHydrating() && expectedTag && sibling?.localName !== expectedTag) {
|
|
1267
|
-
const parent = node.parentNode;
|
|
1268
|
-
const isMissing = !sibling || sibling.nodeType !== 1;
|
|
1269
|
-
console.warn("Hydration structure mismatch: expected <" + expectedTag + "> after", node, "in", parent, "\n " + describeSiblings(parent, sibling, expectedTag, isMissing));
|
|
1270
|
-
}
|
|
1271
1501
|
return sibling;
|
|
1272
1502
|
}
|
|
1273
|
-
function describeSiblings(parent, mismatchChild, expectedTag, isMissing) {
|
|
1274
|
-
if (!parent) return `<${expectedTag} \u2190 parent unavailable>`;
|
|
1275
|
-
const children = [];
|
|
1276
|
-
let child = parent.firstChild;
|
|
1277
|
-
while (child) {
|
|
1278
|
-
if (child.nodeType === 1) children.push(child);
|
|
1279
|
-
child = child.nextSibling;
|
|
1280
|
-
}
|
|
1281
|
-
const pTag = parent.localName || "#fragment";
|
|
1282
|
-
if (isMissing) {
|
|
1283
|
-
const tags = children.map(c => `<${c.localName}>`).join("");
|
|
1284
|
-
return `<${pTag}>${tags}<${expectedTag} \u2190 missing></${pTag}>`;
|
|
1285
|
-
}
|
|
1286
|
-
const idx = children.indexOf(mismatchChild);
|
|
1287
|
-
let start = 0,
|
|
1288
|
-
end = children.length;
|
|
1289
|
-
let prefix = "",
|
|
1290
|
-
suffix = "";
|
|
1291
|
-
if (children.length > 6) {
|
|
1292
|
-
start = Math.max(0, idx - 2);
|
|
1293
|
-
end = Math.min(children.length, idx + 3);
|
|
1294
|
-
if (start > 0) prefix = "...";
|
|
1295
|
-
if (end < children.length) suffix = "...";
|
|
1296
|
-
}
|
|
1297
|
-
const tags = children.slice(start, end).map(c => c === mismatchChild ? `<${c.localName} \u2190 expected ${expectedTag}>` : `<${c.localName}>`).join("");
|
|
1298
|
-
return `<${pTag}>${prefix}${tags}${suffix}</${pTag}>`;
|
|
1299
|
-
}
|
|
1300
1503
|
function runHydrationEvents() {
|
|
1301
1504
|
if (sharedConfig.events && !sharedConfig.events.queued) {
|
|
1302
1505
|
queueMicrotask(() => {
|
|
@@ -1347,6 +1550,7 @@ function runHydrationEvents() {
|
|
|
1347
1550
|
}
|
|
1348
1551
|
function isHydrating(node) {
|
|
1349
1552
|
if (!sharedConfig.hydrating) return false;
|
|
1553
|
+
if (sharedConfig.isClaiming && !sharedConfig.isClaiming()) return false;
|
|
1350
1554
|
if (!node || node.isConnected) return true;
|
|
1351
1555
|
const roots = sharedConfig.claimRoots;
|
|
1352
1556
|
if (roots) {
|
|
@@ -1378,7 +1582,8 @@ function classListToObject(classList) {
|
|
|
1378
1582
|
function flattenClassList(list, result) {
|
|
1379
1583
|
for (let i = 0, len = list.length; i < len; i++) {
|
|
1380
1584
|
const item = list[i];
|
|
1381
|
-
if (Array.isArray(item)) flattenClassList(item, result);else if (typeof item === "object" && item != null) Object.assign(result, item);
|
|
1585
|
+
if (Array.isArray(item)) flattenClassList(item, result);else if (typeof item === "object" && item != null) Object.assign(result, item);
|
|
1586
|
+
else if (typeof item !== "boolean" && (item || item === 0)) result[item] = true;
|
|
1382
1587
|
}
|
|
1383
1588
|
}
|
|
1384
1589
|
function assignProp(node, prop, value, prev, skipRef, nodeName) {
|
|
@@ -1394,12 +1599,13 @@ function assignProp(node, prop, value, prev, skipRef, nodeName) {
|
|
|
1394
1599
|
const name = prop.slice(2).toLowerCase();
|
|
1395
1600
|
const delegate = DelegatedEvents.has(name);
|
|
1396
1601
|
if (!delegate && prev) {
|
|
1397
|
-
|
|
1398
|
-
node.removeEventListener(name,
|
|
1602
|
+
if (Array.isArray(value) && typeof prev === "function" && prev[$$EVENT_TUPLE] === value) return prev;
|
|
1603
|
+
node.removeEventListener(name, prev, typeof prev !== "function" && prev);
|
|
1399
1604
|
}
|
|
1400
1605
|
if (delegate || value) {
|
|
1401
|
-
addEvent(node, name, value, delegate);
|
|
1606
|
+
const attached = addEvent(node, name, value, delegate);
|
|
1402
1607
|
delegate && delegateEvents([name]);
|
|
1608
|
+
if (!delegate) return attached;
|
|
1403
1609
|
}
|
|
1404
1610
|
} else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop]) {
|
|
1405
1611
|
if (hasNamespace) prop = prop.slice(5);else if (isHydrating(node)) return value;
|
|
@@ -1421,9 +1627,10 @@ function eventHandler(e, container, state) {
|
|
|
1421
1627
|
}
|
|
1422
1628
|
const owner = state && (state.owners.size === 1 && state.owners.has(container) ? container : findOwner(e.target, state)?.owner);
|
|
1423
1629
|
if (state && !owner) return;
|
|
1630
|
+
if (owner && owner === resumeNode) return;
|
|
1424
1631
|
e[$$EVENT_OWNER] = owner || true;
|
|
1425
1632
|
let node = resumeNode || e.target;
|
|
1426
|
-
const key =
|
|
1633
|
+
const key = EVENT_KEY + e.type;
|
|
1427
1634
|
const oriTarget = e.target;
|
|
1428
1635
|
const boundary = owner || container || e.currentTarget;
|
|
1429
1636
|
const retarget = value => Object.defineProperty(e, "target", {
|
|
@@ -1431,17 +1638,21 @@ function eventHandler(e, container, state) {
|
|
|
1431
1638
|
value
|
|
1432
1639
|
});
|
|
1433
1640
|
const handleNode = () => {
|
|
1434
|
-
|
|
1641
|
+
let handler = node[key];
|
|
1642
|
+
if (handler === undefined && node.hasAttribute && node.hasAttribute("_bnd")) {
|
|
1643
|
+
const seam = globalThis[Symbol.for("solid.bnd")];
|
|
1644
|
+
if (seam) handler = seam.resolve(node, e.type);
|
|
1645
|
+
}
|
|
1435
1646
|
if (handler && !node.disabled) {
|
|
1436
1647
|
const data = node[`${key}Data`];
|
|
1437
|
-
data !== undefined ? handler.call(node, data, e) : handler.call(node, e);
|
|
1648
|
+
data !== undefined ? handler.call(node, data, e) : typeof handler === "function" ? handler.call(node, e) : handler.handleEvent(e);
|
|
1438
1649
|
if (e.cancelBubble) return;
|
|
1439
1650
|
}
|
|
1440
1651
|
node.host && typeof node.host !== "string" && !node.host._$host && node.contains(e.target) && retarget(node.host);
|
|
1441
1652
|
return true;
|
|
1442
1653
|
};
|
|
1443
1654
|
const walkUpTree = () => {
|
|
1444
|
-
while (handleNode()) {
|
|
1655
|
+
while (node && handleNode()) {
|
|
1445
1656
|
if (node === boundary || node.parentNode === boundary) break;
|
|
1446
1657
|
node = node._$host || node.parentNode || node.host;
|
|
1447
1658
|
}
|
|
@@ -1478,7 +1689,16 @@ function eventHandler(e, container, state) {
|
|
|
1478
1689
|
}
|
|
1479
1690
|
function insertExpression(parent, value, current, marker) {
|
|
1480
1691
|
if (hydrationRt !== null && isHydrating(parent)) {
|
|
1481
|
-
if (value && value !== current)
|
|
1692
|
+
if (value && value !== current) {
|
|
1693
|
+
const arr = Array.isArray(value);
|
|
1694
|
+
for (const n of arr ? value : [value]) {
|
|
1695
|
+
if (n && n.nodeType) {
|
|
1696
|
+
if (!isHydrating(n)) return current;
|
|
1697
|
+
} else if (arr && (typeof n === "string" || typeof n === "number")) {
|
|
1698
|
+
return current;
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
}
|
|
1482
1702
|
return value;
|
|
1483
1703
|
}
|
|
1484
1704
|
if (value === current) return value;
|
|
@@ -1499,16 +1719,27 @@ function insertExpression(parent, value, current, marker) {
|
|
|
1499
1719
|
} else if (value.nodeType) {
|
|
1500
1720
|
if (Array.isArray(current)) {
|
|
1501
1721
|
cleanChildren(parent, current, multi ? marker : null, value);
|
|
1502
|
-
} else if (current && current.nodeType) {
|
|
1722
|
+
} else if (current != null && current.nodeType) {
|
|
1503
1723
|
current.parentNode === parent ? parent.replaceChild(value, current) : parent.appendChild(value);
|
|
1504
|
-
} else if (current && parent.firstChild) {
|
|
1724
|
+
} else if (current != null && parent.firstChild) {
|
|
1505
1725
|
parent.replaceChild(value, parent.firstChild);
|
|
1506
1726
|
} else {
|
|
1507
1727
|
parent.appendChild(value);
|
|
1508
1728
|
}
|
|
1509
1729
|
if (marker) value[$$SLOT] = marker;
|
|
1510
1730
|
} else if (Array.isArray(value)) {
|
|
1511
|
-
const currentArray =
|
|
1731
|
+
const currentArray = Array.isArray(current);
|
|
1732
|
+
for (let i = 0, len = value.length; i < len; i++) {
|
|
1733
|
+
const item = value[i],
|
|
1734
|
+
t = typeof item;
|
|
1735
|
+
if (t === "string" || t === "number") {
|
|
1736
|
+
const prev = currentArray ? current[i] : undefined;
|
|
1737
|
+
if (prev && prev.nodeType === 3) {
|
|
1738
|
+
if (prev.data !== "" + item) prev.data = item;
|
|
1739
|
+
value[i] = prev;
|
|
1740
|
+
} else value[i] = document.createTextNode(item);
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1512
1743
|
if (value.length === 0) {
|
|
1513
1744
|
cleanChildren(parent, current, marker);
|
|
1514
1745
|
} else if (currentArray) {
|
|
@@ -1516,10 +1747,10 @@ function insertExpression(parent, value, current, marker) {
|
|
|
1516
1747
|
appendNodes(parent, value, marker);
|
|
1517
1748
|
} else reconcileArrays(parent, current, value, marker);
|
|
1518
1749
|
} else {
|
|
1519
|
-
current
|
|
1750
|
+
if (current != null) cleanChildren(parent, current);
|
|
1520
1751
|
appendNodes(parent, value);
|
|
1521
1752
|
}
|
|
1522
|
-
} else
|
|
1753
|
+
} else ;
|
|
1523
1754
|
return value;
|
|
1524
1755
|
}
|
|
1525
1756
|
function normalize(value, current, multi, doNotUnwrap) {
|
|
@@ -1529,12 +1760,12 @@ function normalize(value, current, multi, doNotUnwrap) {
|
|
|
1529
1760
|
});
|
|
1530
1761
|
if (doNotUnwrap && typeof value === "function") return value;
|
|
1531
1762
|
if (multi && !Array.isArray(value)) value = [value != null ? value : ""];
|
|
1532
|
-
if (Array.isArray(value)) {
|
|
1763
|
+
if (sharedConfig.hydrating && Array.isArray(value)) {
|
|
1533
1764
|
for (let i = 0, len = value.length; i < len; i++) {
|
|
1534
1765
|
const item = value[i],
|
|
1535
1766
|
prev = current && current[i],
|
|
1536
1767
|
t = typeof item;
|
|
1537
|
-
if (t === "string" || t === "number")
|
|
1768
|
+
if ((t === "string" || t === "number") && prev && prev.nodeType === 3 && isHydrating(prev)) value[i] = prev;
|
|
1538
1769
|
}
|
|
1539
1770
|
}
|
|
1540
1771
|
return value;
|
|
@@ -1600,24 +1831,33 @@ function cleanChildren(parent, current, marker, replacement) {
|
|
|
1600
1831
|
}
|
|
1601
1832
|
function gatherHydratable(element, root) {
|
|
1602
1833
|
const templates = element.querySelectorAll(`*[_hk]`);
|
|
1834
|
+
const frames = root ? null : element.querySelectorAll("[data-fid]");
|
|
1835
|
+
const frameCount = frames ? frames.length : 0;
|
|
1836
|
+
const registry = sharedConfig.registry;
|
|
1603
1837
|
for (let i = 0; i < templates.length; i++) {
|
|
1604
1838
|
const node = templates[i];
|
|
1605
1839
|
const key = node.getAttribute("_hk");
|
|
1606
1840
|
if (root) {
|
|
1607
1841
|
if (!key.startsWith(root)) continue;
|
|
1608
|
-
} else {
|
|
1609
|
-
|
|
1610
|
-
|
|
1842
|
+
} else if (frameCount !== 0) {
|
|
1843
|
+
let inFrame = false;
|
|
1844
|
+
for (let j = 0; j < frameCount; j++) {
|
|
1845
|
+
if (frames[j].contains(node)) {
|
|
1846
|
+
inFrame = true;
|
|
1847
|
+
break;
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
if (inFrame) continue;
|
|
1611
1851
|
}
|
|
1612
|
-
if (!
|
|
1852
|
+
if (!registry.has(key)) registry.set(key, node);
|
|
1613
1853
|
}
|
|
1614
1854
|
}
|
|
1615
1855
|
function getHydrationKey() {
|
|
1616
1856
|
return sharedConfig.getNextContextId();
|
|
1617
1857
|
}
|
|
1618
|
-
const voidFn = () => undefined;
|
|
1619
1858
|
const RequestContext = Symbol();
|
|
1620
1859
|
|
|
1860
|
+
function configureServerErrors(_config) {}
|
|
1621
1861
|
function throwInBrowser(func) {
|
|
1622
1862
|
const err = new Error(`${func.name} is not supported in the browser, returning undefined`);
|
|
1623
1863
|
console.error(err);
|
|
@@ -1647,14 +1887,15 @@ function composeMiddleware(middlewares) {
|
|
|
1647
1887
|
throwInBrowser(composeMiddleware);
|
|
1648
1888
|
}
|
|
1649
1889
|
function ssr(template, ...nodes) {}
|
|
1650
|
-
function ssrElement(name, props, children, needsId) {}
|
|
1890
|
+
function ssrElement(name, props, children, needsId, skip, attrs) {}
|
|
1891
|
+
function ssrElementAttribute(key, value) {}
|
|
1651
1892
|
function ssrClassName(value) {}
|
|
1652
1893
|
function ssrStyle(value) {}
|
|
1653
1894
|
function ssrStyleProperty(name, value) {}
|
|
1654
1895
|
function ssrAttribute(key, value) {}
|
|
1655
1896
|
function ssrGroup(fn, n) {}
|
|
1656
1897
|
function ssrHydrationKey() {}
|
|
1657
|
-
function resolveSSRNode(node, result, top) {}
|
|
1898
|
+
function resolveSSRNode(node, result, top, nested) {}
|
|
1658
1899
|
function escape(s, attr) {}
|
|
1659
1900
|
|
|
1660
1901
|
const ENVELOPE = Symbol.for("solid.ResponseEnvelope");
|
|
@@ -1691,11 +1932,16 @@ function isSafeError(value) {
|
|
|
1691
1932
|
return !!(value && (typeof value === "object" || typeof value === "function") && value[SAFE_ERROR]);
|
|
1692
1933
|
}
|
|
1693
1934
|
const REVALIDATE_HEADER = "X-Revalidate";
|
|
1694
|
-
|
|
1935
|
+
const REVALIDATE_ALL = "*";
|
|
1936
|
+
const RESPONSE_HEADER_VALUE_LIMIT = 4096;
|
|
1937
|
+
function initWithRevalidate(init = {}) {
|
|
1938
|
+
const resolved = typeof init === "number" ? {
|
|
1939
|
+
status: init
|
|
1940
|
+
} : init;
|
|
1695
1941
|
const {
|
|
1696
1942
|
revalidate,
|
|
1697
1943
|
...responseInit
|
|
1698
|
-
} =
|
|
1944
|
+
} = resolved;
|
|
1699
1945
|
let headers;
|
|
1700
1946
|
if (responseInit.headers && responseInit.headers.getSetCookie) {
|
|
1701
1947
|
headers = new Headers();
|
|
@@ -1708,7 +1954,17 @@ function initWithRevalidate(init) {
|
|
|
1708
1954
|
} else {
|
|
1709
1955
|
headers = new Headers(responseInit.headers);
|
|
1710
1956
|
}
|
|
1711
|
-
revalidate !== undefined
|
|
1957
|
+
if (revalidate !== undefined) {
|
|
1958
|
+
const list = Array.isArray(revalidate) ? revalidate : [revalidate];
|
|
1959
|
+
if (list.length > 1 && list.includes(REVALIDATE_ALL)) {
|
|
1960
|
+
throw new TypeError(`revalidate names "${REVALIDATE_ALL}" alongside other keys; "${REVALIDATE_ALL}" already ` + `means every entry and stands alone — pass revalidate: "${REVALIDATE_ALL}" or the named keys.`);
|
|
1961
|
+
}
|
|
1962
|
+
const keys = list.join(",");
|
|
1963
|
+
if (keys.length > RESPONSE_HEADER_VALUE_LIMIT) {
|
|
1964
|
+
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.`);
|
|
1965
|
+
}
|
|
1966
|
+
headers.set(REVALIDATE_HEADER, keys);
|
|
1967
|
+
}
|
|
1712
1968
|
return {
|
|
1713
1969
|
responseInit,
|
|
1714
1970
|
headers
|
|
@@ -1721,13 +1977,17 @@ function redirect(url, init = 302) {
|
|
|
1721
1977
|
const {
|
|
1722
1978
|
responseInit,
|
|
1723
1979
|
headers
|
|
1724
|
-
} = initWithRevalidate(
|
|
1725
|
-
status: init
|
|
1726
|
-
} : init);
|
|
1980
|
+
} = initWithRevalidate(init);
|
|
1727
1981
|
if (responseInit.status === undefined) {
|
|
1728
1982
|
responseInit.status = 302;
|
|
1729
1983
|
}
|
|
1730
|
-
|
|
1984
|
+
const target = typeof url === "string" ? url : url[HREF];
|
|
1985
|
+
const location = typeof target === "string" ? target : String(url);
|
|
1986
|
+
const encoded = location.replace(/[^\x00-\x7f]/gu, encodeURIComponent);
|
|
1987
|
+
if (encoded.length > RESPONSE_HEADER_VALUE_LIMIT) {
|
|
1988
|
+
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.`);
|
|
1989
|
+
}
|
|
1990
|
+
headers.set("Location", encoded);
|
|
1731
1991
|
return new Response(null, {
|
|
1732
1992
|
...responseInit,
|
|
1733
1993
|
headers
|
|
@@ -1743,11 +2003,19 @@ function reload(init = {}) {
|
|
|
1743
2003
|
headers
|
|
1744
2004
|
});
|
|
1745
2005
|
}
|
|
2006
|
+
const NULL_BODY_STATUSES = new Set([204, 205, 304]);
|
|
1746
2007
|
function respond(value, init = {}) {
|
|
1747
2008
|
const {
|
|
1748
2009
|
responseInit,
|
|
1749
2010
|
headers
|
|
1750
2011
|
} = initWithRevalidate(init);
|
|
2012
|
+
for (const header of COMPOSED_BODY_FRAMING) headers.delete(header);
|
|
2013
|
+
if (NULL_BODY_STATUSES.has(responseInit.status)) {
|
|
2014
|
+
return new ResponseEnvelope(new Response(null, {
|
|
2015
|
+
...responseInit,
|
|
2016
|
+
headers
|
|
2017
|
+
}), value);
|
|
2018
|
+
}
|
|
1751
2019
|
headers.set("Content-Type", "application/json");
|
|
1752
2020
|
return new ResponseEnvelope(new Response(JSON.stringify(value), {
|
|
1753
2021
|
...responseInit,
|
|
@@ -1755,28 +2023,8 @@ function respond(value, init = {}) {
|
|
|
1755
2023
|
}), value);
|
|
1756
2024
|
}
|
|
1757
2025
|
|
|
1758
|
-
const mergeProps = merge;
|
|
1759
2026
|
const isServer = false;
|
|
1760
|
-
const isDev =
|
|
1761
|
-
function render(code, element, init, options = {}) {
|
|
1762
|
-
enforceLoadingBoundary(true);
|
|
1763
|
-
try {
|
|
1764
|
-
const dispose = render$1(code, element, init, {
|
|
1765
|
-
...options,
|
|
1766
|
-
insertOptions: {
|
|
1767
|
-
schedule: true
|
|
1768
|
-
}
|
|
1769
|
-
});
|
|
1770
|
-
flush();
|
|
1771
|
-
return dispose;
|
|
1772
|
-
} finally {
|
|
1773
|
-
enforceLoadingBoundary(false);
|
|
1774
|
-
}
|
|
1775
|
-
}
|
|
1776
|
-
const hydrate = (...args) => {
|
|
1777
|
-
enableHydration();
|
|
1778
|
-
return hydrate$1(...args);
|
|
1779
|
-
};
|
|
2027
|
+
const isDev = false;
|
|
1780
2028
|
function Portal(props) {
|
|
1781
2029
|
return runWithOwner(createOwner(), () => portalImpl(props));
|
|
1782
2030
|
}
|
|
@@ -1829,12 +2077,13 @@ function portalImpl(props) {
|
|
|
1829
2077
|
});
|
|
1830
2078
|
return treeMarker;
|
|
1831
2079
|
}
|
|
1832
|
-
const COMPONENT_BINDING = Symbol.for("
|
|
2080
|
+
const COMPONENT_BINDING = Symbol.for("solid.component-binding");
|
|
2081
|
+
const FLIGHT = Symbol("solid.dynamic-flight");
|
|
1833
2082
|
function bindingOf(value) {
|
|
1834
2083
|
return value !== null && (typeof value === "function" || typeof value === "object") && value[COMPONENT_BINDING] || undefined;
|
|
1835
2084
|
}
|
|
1836
|
-
function dynamic(source) {
|
|
1837
|
-
|
|
2085
|
+
function dynamic(source, options) {
|
|
2086
|
+
if (options?.static) return staticDynamic(untrack(source));
|
|
1838
2087
|
const sites = new Set();
|
|
1839
2088
|
let deliveredAddress;
|
|
1840
2089
|
const resolveBinding = (next, prev) => {
|
|
@@ -1848,28 +2097,58 @@ function dynamic(source) {
|
|
|
1848
2097
|
}
|
|
1849
2098
|
return next;
|
|
1850
2099
|
};
|
|
2100
|
+
const sameInstance = (prev, next) => {
|
|
2101
|
+
if (prev === next) return true;
|
|
2102
|
+
const held = bindingOf(prev);
|
|
2103
|
+
const incoming = bindingOf(next);
|
|
2104
|
+
if (!held || !incoming || held.component !== incoming.component) return false;
|
|
2105
|
+
if (held.address === incoming.address) return true;
|
|
2106
|
+
if (deliveredAddress === undefined) return false;
|
|
2107
|
+
if (incoming.address !== deliveredAddress) {
|
|
2108
|
+
deliveredAddress = incoming.address;
|
|
2109
|
+
for (const deliver of sites) deliver(incoming.address);
|
|
2110
|
+
}
|
|
2111
|
+
return true;
|
|
2112
|
+
};
|
|
1851
2113
|
const cached = createMemo(prev => {
|
|
1852
2114
|
const next = source();
|
|
1853
2115
|
if (!next || typeof next.then !== "function") return resolveBinding(next, prev);
|
|
1854
|
-
const token = ++latest;
|
|
1855
2116
|
return {
|
|
1856
|
-
|
|
2117
|
+
[FLIGHT]: next
|
|
1857
2118
|
};
|
|
1858
2119
|
}, {
|
|
1859
|
-
lazy: true
|
|
2120
|
+
lazy: true,
|
|
2121
|
+
equals: sameInstance
|
|
1860
2122
|
});
|
|
1861
2123
|
return props => {
|
|
2124
|
+
if (sharedConfig.hydrating) {
|
|
2125
|
+
try {
|
|
2126
|
+
untrack(cached);
|
|
2127
|
+
} catch {}
|
|
2128
|
+
}
|
|
2129
|
+
let latest = 0;
|
|
2130
|
+
const value = createMemo(prev => {
|
|
2131
|
+
const c = cached();
|
|
2132
|
+
if (!c || !c[FLIGHT]) return resolveBinding(c, prev);
|
|
2133
|
+
const next = c[FLIGHT];
|
|
2134
|
+
const token = ++latest;
|
|
2135
|
+
return {
|
|
2136
|
+
then: (onFulfilled, onRejected) => next.then(resolved => {
|
|
2137
|
+
const landed = token === latest ? resolveBinding(resolved, prev) : resolved;
|
|
2138
|
+
return onFulfilled ? onFulfilled(landed) : landed;
|
|
2139
|
+
}, onRejected)
|
|
2140
|
+
};
|
|
2141
|
+
}, {
|
|
2142
|
+
equals: sameInstance
|
|
2143
|
+
});
|
|
1862
2144
|
return createMemo(() => {
|
|
1863
|
-
const component =
|
|
2145
|
+
const component = value();
|
|
1864
2146
|
switch (typeof component) {
|
|
1865
2147
|
case "function":
|
|
1866
2148
|
{
|
|
1867
|
-
Object.assign(component, {
|
|
1868
|
-
[$DEVCOMP]: true
|
|
1869
|
-
});
|
|
1870
2149
|
const binding = bindingOf(component);
|
|
1871
2150
|
if (binding) {
|
|
1872
|
-
const [address, setAddress] = createSignal(deliveredAddress
|
|
2151
|
+
const [address, setAddress] = createSignal(deliveredAddress ??= binding.address);
|
|
1873
2152
|
sites.add(setAddress);
|
|
1874
2153
|
onCleanup(() => sites.delete(setAddress));
|
|
1875
2154
|
return untrack(() => binding.component(props, address));
|
|
@@ -1877,37 +2156,56 @@ function dynamic(source) {
|
|
|
1877
2156
|
return untrack(() => component(props));
|
|
1878
2157
|
}
|
|
1879
2158
|
case "string":
|
|
1880
|
-
|
|
1881
|
-
spread(el, props);
|
|
1882
|
-
return el;
|
|
2159
|
+
return staticElement(component, props);
|
|
1883
2160
|
}
|
|
1884
2161
|
});
|
|
1885
2162
|
};
|
|
1886
2163
|
}
|
|
2164
|
+
function staticDynamic(component) {
|
|
2165
|
+
if (typeof component === "function") {
|
|
2166
|
+
const binding = bindingOf(component);
|
|
2167
|
+
if (binding) {
|
|
2168
|
+
const address = () => binding.address;
|
|
2169
|
+
return props => untrack(() => binding.component(props, address));
|
|
2170
|
+
}
|
|
2171
|
+
return props => untrack(() => component(props));
|
|
2172
|
+
}
|
|
2173
|
+
if (typeof component === "string") return props => staticElement(component, props);
|
|
2174
|
+
return () => undefined;
|
|
2175
|
+
}
|
|
2176
|
+
function staticElement(tag, props) {
|
|
2177
|
+
const hydrating = sharedConfig.hydrating;
|
|
2178
|
+
const el = hydrating ? getNextElement() : createElement(tag, untrack(() => props.is), untrack(() => props.xmlns));
|
|
2179
|
+
spread(el, props);
|
|
2180
|
+
if (hydrating) runHydrationEvents();
|
|
2181
|
+
return el;
|
|
2182
|
+
}
|
|
1887
2183
|
function Dynamic(props) {
|
|
1888
2184
|
const Comp = dynamic(() => props.component);
|
|
1889
2185
|
return createComponent(Comp, omit(props, "component"));
|
|
1890
2186
|
}
|
|
1891
|
-
function createElement(tagName, is = undefined) {
|
|
1892
|
-
return
|
|
2187
|
+
function createElement(tagName, is = undefined, xmlns = undefined) {
|
|
2188
|
+
return xmlns ? document.createElementNS(xmlns, tagName, {
|
|
2189
|
+
is
|
|
2190
|
+
}) : SVGElements.has(tagName) ? document.createElementNS(Namespaces.svg, tagName) : MathMLElements.has(tagName) ? document.createElementNS(Namespaces.mathml, tagName) : document.createElement(tagName, {
|
|
1893
2191
|
is
|
|
1894
2192
|
});
|
|
1895
2193
|
}
|
|
1896
|
-
function loadClientOnly(fn, setComp) {
|
|
1897
|
-
fn().then(m => setComp(() => m.default));
|
|
2194
|
+
function loadClientOnly(fn, setComp, exportName) {
|
|
2195
|
+
fn().then(m => setComp(() => exportName ? m[exportName] : m.default));
|
|
1898
2196
|
}
|
|
1899
2197
|
function clientOnly(fn, options = {},
|
|
1900
2198
|
_moduleUrl) {
|
|
1901
2199
|
const [comp, setComp] = createSignal();
|
|
1902
2200
|
let started = !options.lazy;
|
|
1903
|
-
started && loadClientOnly(fn, setComp);
|
|
2201
|
+
started && loadClientOnly(fn, setComp, options.export);
|
|
1904
2202
|
return props => {
|
|
1905
2203
|
let Comp;
|
|
1906
2204
|
let m;
|
|
1907
2205
|
const rest = omit(props, "fallback");
|
|
1908
2206
|
if (!started) {
|
|
1909
2207
|
started = true;
|
|
1910
|
-
loadClientOnly(fn, setComp);
|
|
2208
|
+
loadClientOnly(fn, setComp, options.export);
|
|
1911
2209
|
}
|
|
1912
2210
|
if ((Comp = untrack(comp)) && !sharedConfig.hydrating) return Comp(rest);
|
|
1913
2211
|
const [mounted, setMounted] = createSignal(!sharedConfig.hydrating);
|
|
@@ -1921,4 +2219,4 @@ _moduleUrl) {
|
|
|
1921
2219
|
function httpStatus(_code, _text) {}
|
|
1922
2220
|
function httpHeader(_name, _value, _options) {}
|
|
1923
2221
|
|
|
1924
|
-
export { ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF,
|
|
2222
|
+
export { ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF, HydrationScript, MathMLElements, NULL_BODY_STATUSES, Namespaces, Portal, RESPONSE_HEADER_VALUE_LIMIT, REVALIDATE_ALL, REVALIDATE_HEADER, RawTextElements, RequestContext, ResponseEnvelope, SAFE_ERROR, SVGElements, VoidElements, acquireAsset, addEvent, applyRef, assign, claimElement, claimElementTree, className, clearFlashCookie, clientOnly, commitEventResponse, composeMiddleware, configureServerErrors, createRequestEvent, createResponseStub, createSSRResponse, delegateEvents, dynamic, dynamicProperty, effect, escape, generateHydrationScript, getDelegatedRoot, getExpectedRedirectStatus, getFirstChild, getHydrationKey, getNextElement, getNextMarker, getNextMatch, getNextSibling, getRequestEvent, getServerFunctionMetadata, getServerFunctionRPC, getTraceContext, hasFlashCookie, httpHeader, httpStatus, hydrate, insert, installHydrationRuntime, isDev, isHref, isResponseEnvelope, isSafeError, isServer, isServerFunction, markSafeError, memo, parseCookieHeader, readShallow, redirect, ref, registerDelegatedContainer, registerDelegatedRoot, registerElementClaim, reload, render, renderToStream, renderToString, resolveSSRNode, respond, runHydrationEvents, scope, serializeCookie, setAttribute, setAttributeNS, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrElementAttribute, ssrGroup, ssrHydrationKey, ssrStyle, ssrStyleProperty, style, template, unregisterDelegatedContainer, unregisterDelegatedRoot, useHead, waitAsset, warmAsset };
|