@solidjs/web 2.0.0-beta.2 → 2.0.0-beta.21
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 +27 -4
- package/dist/dev.cjs +790 -223
- package/dist/dev.js +764 -217
- package/dist/server.cjs +742 -186
- package/dist/server.js +714 -183
- package/dist/web.cjs +779 -196
- package/dist/web.js +753 -190
- package/package.json +193 -38
- package/serialization/dist/serialization.cjs +83 -0
- package/serialization/dist/serialization.js +75 -0
- package/serialization/package.json +20 -0
- package/serialization/types/index.d.ts +139 -0
- package/serialization/types-cjs/index.d.cts +139 -0
- package/serialization/types-cjs/package.json +3 -0
- package/server-functions/dist/client.cjs +448 -0
- package/server-functions/dist/client.js +435 -0
- package/server-functions/dist/server.cjs +632 -0
- package/server-functions/dist/server.js +615 -0
- package/server-functions/package.json +30 -0
- package/storage/package.json +8 -3
- package/storage/types/index.d.ts +26 -0
- package/storage/types-cjs/index.d.cts +28 -0
- package/storage/types-cjs/package.json +3 -0
- package/types/client.d.ts +64 -21
- package/types/core.d.ts +3 -3
- package/types/index.d.ts +156 -24
- package/types/jsx-properties.d.ts +93 -0
- package/types/jsx.d.ts +4135 -1
- package/types/response.d.ts +93 -0
- package/types/serializer.d.ts +139 -0
- package/types/server-functions/client.d.ts +137 -0
- package/types/server-functions/server.d.ts +307 -0
- package/types/server-functions/shared.d.ts +342 -0
- package/types/server-mock.d.ts +89 -0
- package/types/server.d.ts +123 -28
- package/types-cjs/client.d.cts +131 -0
- package/types-cjs/core.d.cts +3 -0
- package/types-cjs/index.d.cts +178 -0
- package/types-cjs/jsx-properties.d.cts +93 -0
- package/types-cjs/jsx.d.cts +4135 -0
- package/types-cjs/package.json +3 -0
- package/types-cjs/response.d.cts +93 -0
- package/types-cjs/serializer.d.cts +139 -0
- package/types-cjs/server-functions/client.d.cts +137 -0
- package/types-cjs/server-functions/server.d.cts +307 -0
- package/types-cjs/server-functions/shared.d.cts +342 -0
- package/types-cjs/server-mock.d.cts +161 -0
- package/types-cjs/server.d.cts +251 -0
- package/storage/types/src/client.d.ts +0 -1
- package/storage/types/src/index.d.ts +0 -46
- package/storage/types/src/server-mock.d.ts +0 -72
- package/storage/types/storage/src/index.d.ts +0 -2
package/dist/web.js
CHANGED
|
@@ -1,39 +1,80 @@
|
|
|
1
|
-
import { createRenderEffect, createMemo
|
|
2
|
-
export { Errored, For, Hydration, Loading, Match, NoHydration, Show, Switch, createComponent, getOwner,
|
|
3
|
-
import { createMemo } from '@solidjs/signals';
|
|
1
|
+
import { createRenderEffect, createMemo, sharedConfig, untrack, runWithOwner, flatten, createRoot, merge, createComponent, omit, createOwner, enableHydration, flush, getOwner, createEffect } from 'solid-js';
|
|
2
|
+
export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, untrack } from 'solid-js';
|
|
4
3
|
|
|
5
|
-
const
|
|
6
|
-
|
|
4
|
+
const DOMWithState = {
|
|
5
|
+
INPUT: {
|
|
6
|
+
value: 1,
|
|
7
|
+
defaultValue: 2,
|
|
8
|
+
checked: 1,
|
|
9
|
+
defaultChecked: 2
|
|
10
|
+
},
|
|
11
|
+
SELECT: {
|
|
12
|
+
value: 1
|
|
13
|
+
},
|
|
14
|
+
OPTION: {
|
|
15
|
+
value: 1,
|
|
16
|
+
selected: 1,
|
|
17
|
+
defaultSelected: 2
|
|
18
|
+
},
|
|
19
|
+
TEXTAREA: {
|
|
20
|
+
value: 1,
|
|
21
|
+
defaultValue: 2
|
|
22
|
+
},
|
|
23
|
+
VIDEO: {
|
|
24
|
+
muted: 1,
|
|
25
|
+
defaultMuted: 2
|
|
26
|
+
},
|
|
27
|
+
AUDIO: {
|
|
28
|
+
muted: 1,
|
|
29
|
+
defaultMuted: 2
|
|
30
|
+
}
|
|
31
|
+
};
|
|
7
32
|
const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
|
|
33
|
+
const $$SLOT = /*#__PURE__*/Symbol("slot");
|
|
34
|
+
const $$HOST = /*#__PURE__*/Symbol("host");
|
|
8
35
|
const DelegatedEvents = /*#__PURE__*/new Set(["beforeinput", "click", "dblclick", "contextmenu", "focusin", "focusout", "input", "keydown", "keyup", "mousedown", "mousemove", "mouseout", "mouseover", "mouseup", "pointerdown", "pointermove", "pointerout", "pointerover", "pointerup", "touchend", "touchmove", "touchstart"]);
|
|
9
36
|
const SVGElements = /*#__PURE__*/new Set([
|
|
10
37
|
"altGlyph", "altGlyphDef", "altGlyphItem", "animate", "animateColor", "animateMotion", "animateTransform", "circle", "clipPath", "color-profile", "cursor", "defs", "desc", "ellipse", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence", "filter", "font", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignObject", "g", "glyph", "glyphRef", "hkern", "image", "line", "linearGradient", "marker", "mask", "metadata", "missing-glyph", "mpath", "path", "pattern", "polygon", "polyline", "radialGradient", "rect",
|
|
11
38
|
"set", "stop",
|
|
12
39
|
"svg", "switch", "symbol", "text", "textPath",
|
|
13
40
|
"tref", "tspan", "use", "view", "vkern"]);
|
|
14
|
-
const
|
|
41
|
+
const MathMLElements = /*#__PURE__*/new Set(["annotation", "annotation-xml", "maction", "math", "menclose", "merror", "mfenced", "mfrac", "mi", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mprescripts", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msubsup", "msup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "semantics"]);
|
|
42
|
+
const Namespaces = {
|
|
43
|
+
svg: "http://www.w3.org/2000/svg",
|
|
44
|
+
mathml: "http://www.w3.org/1998/Math/MathML",
|
|
15
45
|
xlink: "http://www.w3.org/1999/xlink",
|
|
16
46
|
xml: "http://www.w3.org/XML/1998/namespace"
|
|
17
47
|
};
|
|
18
|
-
const
|
|
19
|
-
"
|
|
20
|
-
"isindex
|
|
48
|
+
const VoidElements = /*#__PURE__*/new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]);
|
|
49
|
+
const RawTextElements = /*#__PURE__*/new Set(["style", "script", "noscript", "template", "textarea", "title"]);
|
|
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(","));
|
|
21
51
|
|
|
22
|
-
const
|
|
23
|
-
transparent: true
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
52
|
+
const transparentOptions = {
|
|
53
|
+
transparent: true,
|
|
54
|
+
sync: true
|
|
55
|
+
};
|
|
56
|
+
const syncOptions = {
|
|
57
|
+
sync: true
|
|
58
|
+
};
|
|
59
|
+
const effect = (fn, effectFn, options) => createRenderEffect(fn, effectFn, options ? {
|
|
60
|
+
sync: true,
|
|
61
|
+
...options,
|
|
62
|
+
transparent: !options.scope
|
|
63
|
+
} : transparentOptions);
|
|
64
|
+
const memo = fn => createMemo(() => fn(), syncOptions);
|
|
28
65
|
|
|
29
|
-
function reconcileArrays(parentNode, a, b) {
|
|
66
|
+
function reconcileArrays(parentNode, a, b, marker) {
|
|
30
67
|
let bLength = b.length,
|
|
31
68
|
aEnd = a.length,
|
|
32
69
|
bEnd = bLength,
|
|
33
70
|
aStart = 0,
|
|
34
71
|
bStart = 0,
|
|
35
|
-
|
|
36
|
-
|
|
72
|
+
tail = a[aEnd - 1],
|
|
73
|
+
tailTag = tail[$$SLOT],
|
|
74
|
+
after = tail.parentNode === parentNode && (!tailTag || tailTag === marker) ? tail.nextSibling : marker || null,
|
|
75
|
+
map = null,
|
|
76
|
+
anchor,
|
|
77
|
+
anchorTag;
|
|
37
78
|
while (aStart < aEnd || bStart < bEnd) {
|
|
38
79
|
if (a[aStart] === b[bStart]) {
|
|
39
80
|
aStart++;
|
|
@@ -45,18 +86,43 @@ function reconcileArrays(parentNode, a, b) {
|
|
|
45
86
|
bEnd--;
|
|
46
87
|
}
|
|
47
88
|
if (aEnd === aStart) {
|
|
48
|
-
|
|
49
|
-
|
|
89
|
+
let node;
|
|
90
|
+
if (bEnd < bLength) {
|
|
91
|
+
if (bStart) {
|
|
92
|
+
const prev = b[bStart - 1];
|
|
93
|
+
const prevTag = prev[$$SLOT];
|
|
94
|
+
node = prev.parentNode === parentNode && (!prevTag || prevTag === marker) ? prev.nextSibling : after;
|
|
95
|
+
} else node = b[bEnd - bStart];
|
|
96
|
+
} else node = after;
|
|
97
|
+
while (bStart < bEnd) {
|
|
98
|
+
const n = b[bStart++];
|
|
99
|
+
parentNode.insertBefore(n, node);
|
|
100
|
+
if (marker) n[$$SLOT] = marker;
|
|
101
|
+
}
|
|
50
102
|
} else if (bEnd === bStart) {
|
|
51
103
|
while (aStart < aEnd) {
|
|
52
|
-
|
|
53
|
-
|
|
104
|
+
const n = a[aStart++];
|
|
105
|
+
if (!map || !map.has(n)) {
|
|
106
|
+
const tag = n[$$SLOT];
|
|
107
|
+
if (n.parentNode === parentNode && (!tag || tag === marker)) n.remove();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
} else if ((anchor = a[aStart]) === b[bEnd - 1] && b[bStart] === a[aEnd - 1] && anchor.parentNode === parentNode && (!(anchorTag = anchor[$$SLOT]) || anchorTag === marker)) {
|
|
111
|
+
if (marker) {
|
|
112
|
+
do {
|
|
113
|
+
const n = a[--aEnd];
|
|
114
|
+
parentNode.insertBefore(n, anchor);
|
|
115
|
+
n[$$SLOT] = marker;
|
|
116
|
+
bStart++;
|
|
117
|
+
if (aStart >= aEnd - 1 || bStart >= bEnd) break;
|
|
118
|
+
} while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
|
|
119
|
+
} else {
|
|
120
|
+
do {
|
|
121
|
+
parentNode.insertBefore(a[--aEnd], anchor);
|
|
122
|
+
bStart++;
|
|
123
|
+
if (aStart >= aEnd - 1 || bStart >= bEnd) break;
|
|
124
|
+
} while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
|
|
54
125
|
}
|
|
55
|
-
} else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
|
|
56
|
-
const node = a[--aEnd].nextSibling;
|
|
57
|
-
parentNode.insertBefore(b[bStart++], a[aStart++].nextSibling);
|
|
58
|
-
parentNode.insertBefore(b[--bEnd], node);
|
|
59
|
-
a[aEnd] = b[bEnd];
|
|
60
126
|
} else {
|
|
61
127
|
if (!map) {
|
|
62
128
|
map = new Map();
|
|
@@ -74,53 +140,136 @@ function reconcileArrays(parentNode, a, b) {
|
|
|
74
140
|
sequence++;
|
|
75
141
|
}
|
|
76
142
|
if (sequence > index - bStart) {
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
143
|
+
const head = a[aStart];
|
|
144
|
+
const headTag = head[$$SLOT];
|
|
145
|
+
const node = head.parentNode === parentNode && (!headTag || headTag === marker) ? head : after;
|
|
146
|
+
while (bStart < index) {
|
|
147
|
+
const n = b[bStart++];
|
|
148
|
+
parentNode.insertBefore(n, node);
|
|
149
|
+
if (marker) n[$$SLOT] = marker;
|
|
150
|
+
}
|
|
151
|
+
} else {
|
|
152
|
+
const oldNode = a[aStart++];
|
|
153
|
+
const newNode = b[bStart++];
|
|
154
|
+
const oldTag = oldNode[$$SLOT];
|
|
155
|
+
if (oldNode.parentNode === parentNode && (!oldTag || oldTag === marker)) {
|
|
156
|
+
parentNode.replaceChild(newNode, oldNode);
|
|
157
|
+
} else {
|
|
158
|
+
parentNode.insertBefore(newNode, after);
|
|
159
|
+
}
|
|
160
|
+
if (marker) newNode[$$SLOT] = marker;
|
|
161
|
+
}
|
|
80
162
|
} else aStart++;
|
|
81
|
-
} else
|
|
163
|
+
} else {
|
|
164
|
+
const n = a[aStart++];
|
|
165
|
+
const nTag = n[$$SLOT];
|
|
166
|
+
if (n.parentNode === parentNode && (!nTag || nTag === marker)) n.remove();
|
|
167
|
+
}
|
|
82
168
|
}
|
|
83
169
|
}
|
|
84
170
|
}
|
|
85
171
|
|
|
86
|
-
const $$
|
|
172
|
+
const $$EVENT_OWNER = "_$DX_EVENT_OWNER";
|
|
173
|
+
const INNER_OWNED = {};
|
|
174
|
+
const delegatedEvents = new Set();
|
|
175
|
+
const delegatedContainers = new Map();
|
|
87
176
|
function render$1(code, element, init, options = {}) {
|
|
88
177
|
let disposer;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
178
|
+
registerDelegatedRoot(element);
|
|
179
|
+
try {
|
|
180
|
+
createRoot(dispose => {
|
|
181
|
+
disposer = dispose;
|
|
182
|
+
if (element === document) {
|
|
183
|
+
const tree = code();
|
|
184
|
+
effect(() => flatten(tree), () => {});
|
|
185
|
+
} else {
|
|
186
|
+
const tree = code();
|
|
187
|
+
insert(element, () => tree, element.firstChild ? null : undefined, init, options.insertOptions);
|
|
188
|
+
}
|
|
189
|
+
}, {
|
|
190
|
+
id: options.renderId
|
|
191
|
+
});
|
|
192
|
+
} catch (err) {
|
|
193
|
+
if (disposer) disposer();
|
|
194
|
+
unregisterDelegatedRoot(element);
|
|
195
|
+
throw err;
|
|
196
|
+
}
|
|
95
197
|
return () => {
|
|
96
198
|
disposer();
|
|
199
|
+
unregisterDelegatedRoot(element);
|
|
97
200
|
element.textContent = "";
|
|
98
201
|
};
|
|
99
202
|
}
|
|
100
|
-
function
|
|
203
|
+
function create(html, bypassGuard, flag) {
|
|
204
|
+
const t = document.createElement("template");
|
|
205
|
+
t.innerHTML = html;
|
|
206
|
+
return flag === 2 ? t.content.firstChild.firstChild : t.content.firstChild;
|
|
207
|
+
}
|
|
208
|
+
function template(html, flag) {
|
|
101
209
|
let node;
|
|
102
|
-
const
|
|
103
|
-
const t = isMathML ? document.createElementNS("http://www.w3.org/1998/Math/MathML", "template") : document.createElement("template");
|
|
104
|
-
t.innerHTML = html;
|
|
105
|
-
return isSVG ? t.content.firstChild.firstChild : isMathML ? t.firstChild : t.content.firstChild;
|
|
106
|
-
};
|
|
107
|
-
const fn = isImportNode ? bypassGuard => untrack(() => document.importNode(node || (node = create()), true)) : bypassGuard => (node || (node = create())).cloneNode(true);
|
|
210
|
+
const fn = flag === 1 ? bypassGuard => document.importNode(node || (node = create(html, bypassGuard, flag)), true) : bypassGuard => (node || (node = create(html, bypassGuard, flag))).cloneNode(true);
|
|
108
211
|
return fn;
|
|
109
212
|
}
|
|
110
|
-
function delegateEvents(eventNames
|
|
111
|
-
const e = document[$$EVENTS] || (document[$$EVENTS] = new Set());
|
|
213
|
+
function delegateEvents(eventNames) {
|
|
112
214
|
for (let i = 0, l = eventNames.length; i < l; i++) {
|
|
113
215
|
const name = eventNames[i];
|
|
114
|
-
if (!
|
|
115
|
-
|
|
116
|
-
|
|
216
|
+
if (!delegatedEvents.has(name)) {
|
|
217
|
+
delegatedEvents.add(name);
|
|
218
|
+
delegatedContainers.forEach((state, container) => attachDelegatedEvent(name, container, state));
|
|
117
219
|
}
|
|
118
220
|
}
|
|
119
221
|
}
|
|
120
|
-
function
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
222
|
+
function registerDelegatedRoot(root) {
|
|
223
|
+
const state = registerDelegatedContainer(root, root);
|
|
224
|
+
if (state) state.roots = (state.roots || 0) + 1;
|
|
225
|
+
}
|
|
226
|
+
function unregisterDelegatedRoot(root) {
|
|
227
|
+
const state = delegatedContainers.get(root);
|
|
228
|
+
if (state) state.roots > 1 ? state.roots-- : delete state.roots;
|
|
229
|
+
unregisterDelegatedContainer(root, root);
|
|
230
|
+
}
|
|
231
|
+
function registerDelegatedContainer(container, owner = container) {
|
|
232
|
+
if (!container || !owner) return;
|
|
233
|
+
let state = delegatedContainers.get(container);
|
|
234
|
+
if (!state) delegatedContainers.set(container, state = {
|
|
235
|
+
owners: new Map(),
|
|
236
|
+
handlers: new Map()
|
|
237
|
+
});
|
|
238
|
+
state.owners.set(owner, (state.owners.get(owner) || 0) + 1);
|
|
239
|
+
delegatedEvents.forEach(name => attachDelegatedEvent(name, container, state));
|
|
240
|
+
return state;
|
|
241
|
+
}
|
|
242
|
+
function unregisterDelegatedContainer(container, owner = container) {
|
|
243
|
+
const state = delegatedContainers.get(container);
|
|
244
|
+
if (!state) return;
|
|
245
|
+
const count = state.owners.get(owner);
|
|
246
|
+
if (count > 1) state.owners.set(owner, count - 1);else state.owners.delete(owner);
|
|
247
|
+
if (state.owners.size) return;
|
|
248
|
+
state.handlers.forEach((handler, name) => container.removeEventListener(name, handler));
|
|
249
|
+
delegatedContainers.delete(container);
|
|
250
|
+
}
|
|
251
|
+
function attachDelegatedEvent(name, container, state) {
|
|
252
|
+
if (state.handlers.has(name)) return;
|
|
253
|
+
const handler = e => eventHandler(e, container, state);
|
|
254
|
+
state.handlers.set(name, handler);
|
|
255
|
+
container.addEventListener(name, handler);
|
|
256
|
+
}
|
|
257
|
+
function getDelegatedRoot(node) {
|
|
258
|
+
while (node) {
|
|
259
|
+
if (delegatedContainers.get(node)?.roots) return node;
|
|
260
|
+
node = node._$host || node.parentNode || node.host;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
function findOwner(target, state) {
|
|
264
|
+
let node = target;
|
|
265
|
+
let distance = 0;
|
|
266
|
+
while (node) {
|
|
267
|
+
if (state.owners.has(node)) return {
|
|
268
|
+
owner: node,
|
|
269
|
+
distance
|
|
270
|
+
};
|
|
271
|
+
distance++;
|
|
272
|
+
node = node._$host || node.parentNode || node.host;
|
|
124
273
|
}
|
|
125
274
|
}
|
|
126
275
|
function setProperty(node, name, value) {
|
|
@@ -133,16 +282,16 @@ function setAttribute(node, name, value) {
|
|
|
133
282
|
}
|
|
134
283
|
function setAttributeNS(node, namespace, name, value) {
|
|
135
284
|
if (isHydrating(node)) return;
|
|
136
|
-
if (value == null) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value);
|
|
285
|
+
if (value == null || value === false) node.removeAttributeNS(namespace, name.indexOf(":") > -1 ? name.split(":").pop() : name);else node.setAttributeNS(namespace, name, value === true ? "" : value);
|
|
137
286
|
}
|
|
138
|
-
function className(node, value,
|
|
287
|
+
function className(node, value, prev) {
|
|
139
288
|
if (isHydrating(node)) return;
|
|
140
289
|
if (value == null || value === false) {
|
|
141
290
|
prev && node.removeAttribute("class");
|
|
142
291
|
return;
|
|
143
292
|
}
|
|
144
293
|
if (typeof value === "string") {
|
|
145
|
-
value !== prev &&
|
|
294
|
+
value !== prev && node.setAttribute("class", value);
|
|
146
295
|
return;
|
|
147
296
|
}
|
|
148
297
|
if (typeof prev === "string") {
|
|
@@ -156,16 +305,16 @@ function className(node, value, isSVG, prev) {
|
|
|
156
305
|
for (i = 0, len = prevKeys.length; i < len; i++) {
|
|
157
306
|
const key = prevKeys[i];
|
|
158
307
|
if (!key || key === "undefined" || value[key]) continue;
|
|
159
|
-
|
|
308
|
+
node.classList.remove(key);
|
|
160
309
|
}
|
|
161
310
|
for (i = 0, len = classKeys.length; i < len; i++) {
|
|
162
311
|
const key = classKeys[i],
|
|
163
312
|
classValue = !!value[key];
|
|
164
313
|
if (!key || key === "undefined" || prev[key] === classValue || !classValue) continue;
|
|
165
|
-
|
|
314
|
+
node.classList.add(key);
|
|
166
315
|
}
|
|
167
316
|
}
|
|
168
|
-
function
|
|
317
|
+
function addEvent(node, name, handler, delegate) {
|
|
169
318
|
if (delegate) {
|
|
170
319
|
if (Array.isArray(handler)) {
|
|
171
320
|
node[`$$${name}`] = handler[0];
|
|
@@ -178,33 +327,48 @@ function addEventListener(node, name, handler, delegate) {
|
|
|
178
327
|
}
|
|
179
328
|
function style(node, value, prev) {
|
|
180
329
|
if (!value) {
|
|
181
|
-
if (prev
|
|
330
|
+
if (prev || node._$styles) {
|
|
331
|
+
setAttribute(node, "style");
|
|
332
|
+
node._$styles = undefined;
|
|
333
|
+
}
|
|
182
334
|
return;
|
|
183
335
|
}
|
|
184
336
|
const nodeStyle = node.style;
|
|
185
|
-
if (typeof value === "string")
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
337
|
+
if (typeof value === "string") {
|
|
338
|
+
node._$styles = undefined;
|
|
339
|
+
return nodeStyle.cssText = value;
|
|
340
|
+
}
|
|
341
|
+
if (typeof prev === "string") {
|
|
342
|
+
nodeStyle.cssText = "";
|
|
343
|
+
prev = undefined;
|
|
344
|
+
}
|
|
345
|
+
let applied = node._$styles;
|
|
346
|
+
if (!applied) {
|
|
347
|
+
applied = node._$styles = prev ? {
|
|
348
|
+
...prev
|
|
349
|
+
} : {};
|
|
350
|
+
}
|
|
189
351
|
let v, s;
|
|
352
|
+
for (s in applied) {
|
|
353
|
+
if (value[s] == null) {
|
|
354
|
+
nodeStyle.removeProperty(s);
|
|
355
|
+
delete applied[s];
|
|
356
|
+
}
|
|
357
|
+
}
|
|
190
358
|
for (s in value) {
|
|
191
359
|
v = value[s];
|
|
192
|
-
if (v !==
|
|
193
|
-
|
|
360
|
+
if (v != null && v !== applied[s]) {
|
|
361
|
+
nodeStyle.setProperty(s, v);
|
|
362
|
+
applied[s] = v;
|
|
363
|
+
}
|
|
194
364
|
}
|
|
195
|
-
for (s in prev) value[s] == null && nodeStyle.removeProperty(s);
|
|
196
365
|
}
|
|
197
366
|
function setStyleProperty(node, name, value) {
|
|
198
367
|
value != null ? node.style.setProperty(name, value) : node.style.removeProperty(name);
|
|
199
368
|
}
|
|
200
|
-
function spread(node, props = {},
|
|
369
|
+
function spread(node, props = {}, skipChildren) {
|
|
201
370
|
const prevProps = {};
|
|
202
|
-
if (!skipChildren)
|
|
203
|
-
effect(() => normalize(props.children, prevProps.children), value => {
|
|
204
|
-
insertExpression(node, value, prevProps.children);
|
|
205
|
-
prevProps.children = value;
|
|
206
|
-
});
|
|
207
|
-
}
|
|
371
|
+
if (!skipChildren) insert(node, () => props.children);
|
|
208
372
|
effect(() => {
|
|
209
373
|
const r = props.ref;
|
|
210
374
|
(typeof r === "function" || Array.isArray(r)) && ref(() => r, node);
|
|
@@ -216,7 +380,7 @@ function spread(node, props = {}, isSVG, skipChildren) {
|
|
|
216
380
|
newProps[prop] = props[prop];
|
|
217
381
|
}
|
|
218
382
|
return newProps;
|
|
219
|
-
}, props => assign(node, props,
|
|
383
|
+
}, props => assign(node, props, true, prevProps, true));
|
|
220
384
|
return prevProps;
|
|
221
385
|
}
|
|
222
386
|
function dynamicProperty(props, key) {
|
|
@@ -236,49 +400,235 @@ function ref(fn, element) {
|
|
|
236
400
|
const resolved = untrack(fn);
|
|
237
401
|
runWithOwner(null, () => applyRef(resolved, element));
|
|
238
402
|
}
|
|
239
|
-
function
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
403
|
+
function scope(fn) {
|
|
404
|
+
fn.$s = true;
|
|
405
|
+
return fn;
|
|
406
|
+
}
|
|
407
|
+
const SCOPE_OPTIONS = {
|
|
408
|
+
scope: true
|
|
409
|
+
};
|
|
410
|
+
let hydrationRt = null;
|
|
411
|
+
function installHydrationRuntime() {
|
|
412
|
+
hydrationRt = {
|
|
413
|
+
claimInitial(parent, multi, initial) {
|
|
414
|
+
if (isHydrating(parent)) {
|
|
415
|
+
if (!multi && initial === undefined && parent) initial = [...parent.childNodes];
|
|
416
|
+
if (Array.isArray(initial)) stripTextSeparators(initial);
|
|
248
417
|
}
|
|
249
|
-
initial
|
|
418
|
+
return initial;
|
|
419
|
+
},
|
|
420
|
+
reclaimRegion(current, parent, marker) {
|
|
421
|
+
if (!sharedConfig.hydrating || !current || !parent.isConnected) return current;
|
|
422
|
+
const first = Array.isArray(current) ? current[0] : current;
|
|
423
|
+
if (!first || !first.nodeType || first.isConnected) return current;
|
|
424
|
+
let nodes;
|
|
425
|
+
if (marker) {
|
|
426
|
+
nodes = [];
|
|
427
|
+
let node = marker.previousSibling,
|
|
428
|
+
depth = 0;
|
|
429
|
+
while (node) {
|
|
430
|
+
if (node.nodeType === 8) {
|
|
431
|
+
const v = node.nodeValue;
|
|
432
|
+
if (v === "/") depth++;else if (v === "$") {
|
|
433
|
+
if (depth === 0) break;
|
|
434
|
+
depth--;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
nodes.unshift(node);
|
|
438
|
+
node = node.previousSibling;
|
|
439
|
+
}
|
|
440
|
+
} else nodes = [...parent.childNodes];
|
|
441
|
+
return stripTextSeparators(nodes);
|
|
442
|
+
},
|
|
443
|
+
dedupEvent(e) {
|
|
444
|
+
return !!(sharedConfig.registry && sharedConfig.events && sharedConfig.events.find(([el, ev]) => ev === e));
|
|
250
445
|
}
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
function stripTextSeparators(nodes) {
|
|
449
|
+
let j = 0;
|
|
450
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
451
|
+
if (nodes[i].nodeType === 8 && nodes[i].nodeValue === "!$") nodes[i].remove();else nodes[j++] = nodes[i];
|
|
251
452
|
}
|
|
453
|
+
nodes.length = j;
|
|
454
|
+
return nodes;
|
|
455
|
+
}
|
|
456
|
+
function insert(parent, accessor, marker, initial, options) {
|
|
457
|
+
const multi = marker !== undefined;
|
|
458
|
+
const host = options && options.host;
|
|
459
|
+
if (multi && !initial) initial = [];
|
|
460
|
+
if (hydrationRt !== null) initial = hydrationRt.claimInitial(parent, multi, initial);
|
|
252
461
|
if (typeof accessor !== "function") {
|
|
253
462
|
accessor = normalize(accessor, initial, multi, true);
|
|
254
|
-
if (typeof accessor !== "function")
|
|
463
|
+
if (typeof accessor !== "function") {
|
|
464
|
+
insertExpression(parent, accessor, initial, marker);
|
|
465
|
+
host && tagHost(accessor, host);
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
255
468
|
}
|
|
256
|
-
|
|
257
|
-
if (multi && initial.length === 0 && !isHydrating(parent)) {
|
|
469
|
+
if (multi && initial.length === 0) {
|
|
258
470
|
const placeholder = document.createTextNode("");
|
|
259
471
|
parent.insertBefore(placeholder, marker);
|
|
260
472
|
initial = [placeholder];
|
|
261
473
|
}
|
|
262
|
-
|
|
474
|
+
let current = initial;
|
|
475
|
+
effect(prev => {
|
|
476
|
+
if (hydrationRt !== null) current = hydrationRt.reclaimRegion(current, parent, marker);
|
|
477
|
+
const value = normalize(accessor(), current, multi, true);
|
|
478
|
+
if (typeof value !== "function") return value;
|
|
479
|
+
effect(() => (hydrationRt !== null && (current = hydrationRt.reclaimRegion(current, parent, marker)), normalize(value, current, multi)), inner => {
|
|
480
|
+
insertExpression(parent, inner, current, marker);
|
|
481
|
+
current = inner;
|
|
482
|
+
host && tagHost(current, host);
|
|
483
|
+
}, prev !== undefined && !(options && options.schedule) ? {
|
|
484
|
+
...options,
|
|
485
|
+
schedule: true
|
|
486
|
+
} : options);
|
|
487
|
+
return INNER_OWNED;
|
|
488
|
+
}, value => {
|
|
489
|
+
if (value === INNER_OWNED) return;
|
|
490
|
+
insertExpression(parent, value, current, marker);
|
|
491
|
+
current = value;
|
|
492
|
+
host && tagHost(current, host);
|
|
493
|
+
},
|
|
494
|
+
accessor.$s ? options ? {
|
|
495
|
+
...options,
|
|
496
|
+
scope: true
|
|
497
|
+
} : SCOPE_OPTIONS : options);
|
|
263
498
|
}
|
|
264
|
-
function assign(node, props,
|
|
499
|
+
function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
|
|
500
|
+
const nodeName = node.nodeName;
|
|
265
501
|
props || (props = {});
|
|
266
502
|
for (const prop in prevProps) {
|
|
267
503
|
if (!(prop in props)) {
|
|
268
504
|
if (prop === "children") continue;
|
|
269
|
-
prevProps[prop] = assignProp(node, prop, null, prevProps[prop],
|
|
505
|
+
prevProps[prop] = assignProp(node, prop, null, prevProps[prop], skipRef, nodeName);
|
|
270
506
|
}
|
|
271
507
|
}
|
|
272
508
|
for (const prop in props) {
|
|
273
509
|
if (prop === "children") {
|
|
274
|
-
if (!skipChildren) insertExpression(node, props.children);
|
|
510
|
+
if (!skipChildren) insertExpression(node, normalize(props.children, undefined, false));
|
|
275
511
|
continue;
|
|
276
512
|
}
|
|
277
|
-
|
|
278
|
-
prevProps[prop] = assignProp(node, prop, value, prevProps[prop], isSVG, skipRef);
|
|
513
|
+
prevProps[prop] = assignProp(node, prop, props[prop], prevProps[prop], skipRef, nodeName);
|
|
279
514
|
}
|
|
280
515
|
}
|
|
516
|
+
const ASSET_REMOVAL_GRACE = 100;
|
|
517
|
+
const assetRegistry = new Map();
|
|
518
|
+
function assetEntryKey(descriptor) {
|
|
519
|
+
if (descriptor.policy === "exclusive") return "x|" + descriptor.key;
|
|
520
|
+
return descriptor.type === "inline-style" ? "i|" + descriptor.id : descriptor.type + "|" + descriptor.href;
|
|
521
|
+
}
|
|
522
|
+
function findAssetElement(selector, attr, value) {
|
|
523
|
+
const nodes = document.querySelectorAll(selector);
|
|
524
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
525
|
+
if (nodes[i].getAttribute(attr) === value) return nodes[i];
|
|
526
|
+
}
|
|
527
|
+
return null;
|
|
528
|
+
}
|
|
529
|
+
function mountAssetElement(descriptor) {
|
|
530
|
+
let el;
|
|
531
|
+
if (descriptor.type === "inline-style") {
|
|
532
|
+
el = findAssetElement("style[data-asset]", "data-asset", descriptor.id);
|
|
533
|
+
if (!el) {
|
|
534
|
+
el = document.createElement("style");
|
|
535
|
+
el.setAttribute("data-asset", descriptor.id);
|
|
536
|
+
el.textContent = descriptor.content || "";
|
|
537
|
+
}
|
|
538
|
+
} else {
|
|
539
|
+
const rel = descriptor.type === "module" ? "modulepreload" : "stylesheet";
|
|
540
|
+
el = findAssetElement(`link[rel="${rel}"]`, "href", descriptor.href);
|
|
541
|
+
if (!el) {
|
|
542
|
+
el = document.createElement("link");
|
|
543
|
+
el.rel = rel;
|
|
544
|
+
el.href = descriptor.href;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
if (descriptor.attrs) {
|
|
548
|
+
for (const name in descriptor.attrs) el.setAttribute(name, descriptor.attrs[name]);
|
|
549
|
+
}
|
|
550
|
+
if (!el.isConnected) document.head.appendChild(el);
|
|
551
|
+
return el;
|
|
552
|
+
}
|
|
553
|
+
function acquireAsset(descriptor) {
|
|
554
|
+
const key = assetEntryKey(descriptor);
|
|
555
|
+
let entry = assetRegistry.get(key);
|
|
556
|
+
if (descriptor.policy === "exclusive") {
|
|
557
|
+
if (!entry) {
|
|
558
|
+
entry = {
|
|
559
|
+
original: descriptor.get(),
|
|
560
|
+
set: descriptor.set,
|
|
561
|
+
writers: []
|
|
562
|
+
};
|
|
563
|
+
assetRegistry.set(key, entry);
|
|
564
|
+
}
|
|
565
|
+
const writer = {
|
|
566
|
+
value: descriptor.value
|
|
567
|
+
};
|
|
568
|
+
entry.writers.push(writer);
|
|
569
|
+
entry.set(writer.value);
|
|
570
|
+
let released = false;
|
|
571
|
+
return () => {
|
|
572
|
+
if (released) return;
|
|
573
|
+
released = true;
|
|
574
|
+
const index = entry.writers.indexOf(writer);
|
|
575
|
+
const wasTop = index === entry.writers.length - 1;
|
|
576
|
+
entry.writers.splice(index, 1);
|
|
577
|
+
if (!wasTop) return;
|
|
578
|
+
if (entry.writers.length) {
|
|
579
|
+
entry.set(entry.writers[entry.writers.length - 1].value);
|
|
580
|
+
} else {
|
|
581
|
+
entry.set(entry.original);
|
|
582
|
+
assetRegistry.delete(key);
|
|
583
|
+
}
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
if (!entry) {
|
|
587
|
+
entry = {
|
|
588
|
+
count: 0,
|
|
589
|
+
element: null,
|
|
590
|
+
timer: null
|
|
591
|
+
};
|
|
592
|
+
assetRegistry.set(key, entry);
|
|
593
|
+
}
|
|
594
|
+
if (entry.timer) {
|
|
595
|
+
clearTimeout(entry.timer);
|
|
596
|
+
entry.timer = null;
|
|
597
|
+
}
|
|
598
|
+
entry.count++;
|
|
599
|
+
if (!entry.element || !entry.element.isConnected) entry.element = mountAssetElement(descriptor);
|
|
600
|
+
let released = false;
|
|
601
|
+
return () => {
|
|
602
|
+
if (released) return;
|
|
603
|
+
released = true;
|
|
604
|
+
if (--entry.count > 0) return;
|
|
605
|
+
entry.timer = setTimeout(() => {
|
|
606
|
+
assetRegistry.delete(key);
|
|
607
|
+
entry.element && entry.element.remove();
|
|
608
|
+
}, ASSET_REMOVAL_GRACE);
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
function loadModuleAssets(mapping) {
|
|
612
|
+
const hy = globalThis._$HY;
|
|
613
|
+
if (!hy) return;
|
|
614
|
+
const pending = [];
|
|
615
|
+
for (const key in mapping) {
|
|
616
|
+
if (hy.modules[key]) continue;
|
|
617
|
+
const entryUrl = mapping[key];
|
|
618
|
+
if (!hy.loading[key]) {
|
|
619
|
+
hy.loading[key] = import(entryUrl).then(mod => {
|
|
620
|
+
hy.modules[key] = mod;
|
|
621
|
+
}, err => {
|
|
622
|
+
delete hy.loading[key];
|
|
623
|
+
throw err;
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
pending.push(hy.loading[key]);
|
|
627
|
+
}
|
|
628
|
+
return pending.length ? Promise.all(pending).then(() => {}) : undefined;
|
|
629
|
+
}
|
|
281
630
|
function hydrate$1(code, element, options = {}) {
|
|
631
|
+
installHydrationRuntime();
|
|
282
632
|
if (globalThis._$HY.done) return render$1(code, element, [...element.childNodes], options);
|
|
283
633
|
options.renderId ||= "";
|
|
284
634
|
if (!globalThis._$HY.modules) globalThis._$HY.modules = {};
|
|
@@ -288,6 +638,7 @@ function hydrate$1(code, element, options = {}) {
|
|
|
288
638
|
sharedConfig.load = id => globalThis._$HY.r[id];
|
|
289
639
|
sharedConfig.has = id => id in globalThis._$HY.r;
|
|
290
640
|
sharedConfig.gather = root => gatherHydratable(element, root);
|
|
641
|
+
sharedConfig.loadModuleAssets = loadModuleAssets;
|
|
291
642
|
sharedConfig.cleanupFragment = id => {
|
|
292
643
|
const tpl = document.getElementById("pl-" + id);
|
|
293
644
|
if (tpl) {
|
|
@@ -305,7 +656,35 @@ function hydrate$1(code, element, options = {}) {
|
|
|
305
656
|
}
|
|
306
657
|
};
|
|
307
658
|
sharedConfig.registry = new Map();
|
|
659
|
+
if (!sharedConfig.boundaryScopes) sharedConfig.boundaryScopes = new Map();
|
|
660
|
+
sharedConfig.captureBoundaryScope = id => {
|
|
661
|
+
if (sharedConfig.registry) sharedConfig.boundaryScopes.set(id, {
|
|
662
|
+
registry: sharedConfig.registry,
|
|
663
|
+
gather: sharedConfig.gather
|
|
664
|
+
});
|
|
665
|
+
};
|
|
308
666
|
sharedConfig.hydrating = true;
|
|
667
|
+
const rootMapping = globalThis._$HY.r && globalThis._$HY.r["_assets"];
|
|
668
|
+
if (rootMapping && typeof rootMapping === "object") {
|
|
669
|
+
const p = loadModuleAssets(rootMapping);
|
|
670
|
+
if (p) {
|
|
671
|
+
gatherHydratable(element, options.renderId);
|
|
672
|
+
let disposer;
|
|
673
|
+
p.then(() => {
|
|
674
|
+
try {
|
|
675
|
+
disposer = render$1(code, element, [...element.childNodes], options);
|
|
676
|
+
} finally {
|
|
677
|
+
sharedConfig.hydrating = false;
|
|
678
|
+
}
|
|
679
|
+
}, err => {
|
|
680
|
+
console.error("Hydration module preload failed, falling back to client render:", err);
|
|
681
|
+
sharedConfig.hydrating = false;
|
|
682
|
+
sharedConfig.registry = undefined;
|
|
683
|
+
disposer = render$1(code, element, [...element.childNodes], options);
|
|
684
|
+
});
|
|
685
|
+
return () => disposer && disposer();
|
|
686
|
+
}
|
|
687
|
+
}
|
|
309
688
|
try {
|
|
310
689
|
gatherHydratable(element, options.renderId);
|
|
311
690
|
return render$1(code, element, [...element.childNodes], options);
|
|
@@ -371,7 +750,32 @@ function runHydrationEvents() {
|
|
|
371
750
|
const [el, e] = events[0];
|
|
372
751
|
if (!completed.has(el)) return;
|
|
373
752
|
events.shift();
|
|
374
|
-
|
|
753
|
+
let matchContainer, matchState, matchDistance, matches;
|
|
754
|
+
for (const [container, state] of delegatedContainers) {
|
|
755
|
+
if (!state.handlers.has(e.type)) continue;
|
|
756
|
+
const entry = findOwner(e.target, state);
|
|
757
|
+
if (!entry) continue;
|
|
758
|
+
if (matchContainer) {
|
|
759
|
+
if (!matches) matches = [{
|
|
760
|
+
container: matchContainer,
|
|
761
|
+
state: matchState,
|
|
762
|
+
distance: matchDistance
|
|
763
|
+
}];
|
|
764
|
+
matches.push({
|
|
765
|
+
container,
|
|
766
|
+
state,
|
|
767
|
+
distance: entry.distance
|
|
768
|
+
});
|
|
769
|
+
} else {
|
|
770
|
+
matchContainer = container;
|
|
771
|
+
matchState = state;
|
|
772
|
+
matchDistance = entry.distance;
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
if (matches) {
|
|
776
|
+
matches.sort((a, b) => a.distance - b.distance);
|
|
777
|
+
for (let i = 0; i < matches.length; i++) eventHandler(e, matches[i].container, matches[i].state);
|
|
778
|
+
} else if (matchContainer) eventHandler(e, matchContainer, matchState);
|
|
375
779
|
}
|
|
376
780
|
if (sharedConfig.done) {
|
|
377
781
|
sharedConfig.events = _$HY.events = null;
|
|
@@ -384,14 +788,21 @@ function runHydrationEvents() {
|
|
|
384
788
|
function isHydrating(node) {
|
|
385
789
|
return sharedConfig.hydrating && (!node || node.isConnected);
|
|
386
790
|
}
|
|
387
|
-
function toggleClassKey(node, key, value) {
|
|
388
|
-
const classNames = key.trim().split(/\s+/);
|
|
389
|
-
for (let i = 0, nameLen = classNames.length; i < nameLen; i++) node.classList.toggle(classNames[i], value);
|
|
390
|
-
}
|
|
391
791
|
function classListToObject(classList) {
|
|
392
792
|
if (Array.isArray(classList)) {
|
|
393
793
|
const result = {};
|
|
394
794
|
flattenClassList(classList, result);
|
|
795
|
+
classList = result;
|
|
796
|
+
}
|
|
797
|
+
if (classList && typeof classList === "object") {
|
|
798
|
+
const result = {},
|
|
799
|
+
keys = Object.keys(classList);
|
|
800
|
+
for (let i = 0, len = keys.length; i < len; i++) {
|
|
801
|
+
const key = keys[i];
|
|
802
|
+
if (!classList[key]) continue;
|
|
803
|
+
const classNames = key.trim().split(/\s+/);
|
|
804
|
+
for (let j = 0, nameLen = classNames.length; j < nameLen; j++) classNames[j] && (result[classNames[j]] = true);
|
|
805
|
+
}
|
|
395
806
|
return result;
|
|
396
807
|
}
|
|
397
808
|
return classList;
|
|
@@ -402,18 +813,16 @@ function flattenClassList(list, result) {
|
|
|
402
813
|
if (Array.isArray(item)) flattenClassList(item, result);else if (typeof item === "object" && item != null) Object.assign(result, item);else if (item || item === 0) result[item] = true;
|
|
403
814
|
}
|
|
404
815
|
}
|
|
405
|
-
function assignProp(node, prop, value, prev,
|
|
406
|
-
let forceProp;
|
|
816
|
+
function assignProp(node, prop, value, prev, skipRef, nodeName) {
|
|
407
817
|
if (prop === "style") return style(node, value, prev), value;
|
|
408
|
-
if (prop === "class") return className(node, value,
|
|
409
|
-
if (value === prev) return prev;
|
|
818
|
+
if (prop === "class") return className(node, value, prev), value;
|
|
819
|
+
if (value === prev && DOMWithState[nodeName]?.[prop] !== 1) return prev;
|
|
410
820
|
if (prop === "ref") {
|
|
411
821
|
if (!skipRef && value) ref(() => value, node);
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
} else if (prop.slice(0, 2) === "on") {
|
|
822
|
+
return value;
|
|
823
|
+
}
|
|
824
|
+
const hasNamespace = prop.indexOf(":") > -1;
|
|
825
|
+
if (!hasNamespace && prop.slice(0, 2) === "on") {
|
|
417
826
|
const name = prop.slice(2).toLowerCase();
|
|
418
827
|
const delegate = DelegatedEvents.has(name);
|
|
419
828
|
if (!delegate && prev) {
|
|
@@ -421,26 +830,33 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
|
|
|
421
830
|
node.removeEventListener(name, h);
|
|
422
831
|
}
|
|
423
832
|
if (delegate || value) {
|
|
424
|
-
|
|
833
|
+
addEvent(node, name, value, delegate);
|
|
425
834
|
delegate && delegateEvents([name]);
|
|
426
835
|
}
|
|
427
|
-
} else if (
|
|
428
|
-
if (
|
|
429
|
-
if (prop === "value" &&
|
|
836
|
+
} else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop]) {
|
|
837
|
+
if (hasNamespace) prop = prop.slice(5);else if (isHydrating(node)) return value;
|
|
838
|
+
if (prop === "value" && nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else node[prop] = value;
|
|
430
839
|
} else {
|
|
431
|
-
const ns =
|
|
840
|
+
const ns = hasNamespace && Namespaces[prop.split(":")[0]];
|
|
432
841
|
if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, prop, value);
|
|
433
842
|
}
|
|
434
843
|
return value;
|
|
435
844
|
}
|
|
436
|
-
function eventHandler(e) {
|
|
437
|
-
if (
|
|
438
|
-
|
|
845
|
+
function eventHandler(e, container, state) {
|
|
846
|
+
if (hydrationRt !== null && hydrationRt.dedupEvent(e)) return;
|
|
847
|
+
const prev = e[$$EVENT_OWNER];
|
|
848
|
+
let resumeNode;
|
|
849
|
+
if (prev) {
|
|
850
|
+
if (prev === true || prev === container || !container.contains(prev)) return;
|
|
851
|
+
resumeNode = prev;
|
|
439
852
|
}
|
|
440
|
-
|
|
853
|
+
const owner = state && (state.owners.size === 1 && state.owners.has(container) ? container : findOwner(e.target, state)?.owner);
|
|
854
|
+
if (state && !owner) return;
|
|
855
|
+
e[$$EVENT_OWNER] = owner || true;
|
|
856
|
+
let node = resumeNode || e.target;
|
|
441
857
|
const key = `$$${e.type}`;
|
|
442
858
|
const oriTarget = e.target;
|
|
443
|
-
const
|
|
859
|
+
const boundary = owner || container || e.currentTarget;
|
|
444
860
|
const retarget = value => Object.defineProperty(e, "target", {
|
|
445
861
|
configurable: true,
|
|
446
862
|
value
|
|
@@ -456,35 +872,43 @@ function eventHandler(e) {
|
|
|
456
872
|
return true;
|
|
457
873
|
};
|
|
458
874
|
const walkUpTree = () => {
|
|
459
|
-
while (handleNode()
|
|
875
|
+
while (handleNode()) {
|
|
876
|
+
if (node === boundary || node.parentNode === boundary) break;
|
|
877
|
+
node = node._$host || node.parentNode || node.host;
|
|
878
|
+
}
|
|
460
879
|
};
|
|
461
880
|
Object.defineProperty(e, "currentTarget", {
|
|
462
881
|
configurable: true,
|
|
463
882
|
get() {
|
|
464
|
-
return node || document;
|
|
883
|
+
return node || boundary || document;
|
|
465
884
|
}
|
|
466
885
|
});
|
|
467
|
-
if (
|
|
886
|
+
if (resumeNode) {
|
|
887
|
+
if (resumeNode === e.target) node = resumeNode._$host || resumeNode.parentNode || resumeNode.host;
|
|
888
|
+
if (node && node !== boundary) walkUpTree();
|
|
889
|
+
} else if (e.composedPath) {
|
|
468
890
|
const path = e.composedPath();
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
891
|
+
if (path.length) {
|
|
892
|
+
retarget(path[0]);
|
|
893
|
+
for (let i = 0; i < path.length; i++) {
|
|
894
|
+
node = path[i];
|
|
895
|
+
if (!handleNode()) break;
|
|
896
|
+
if (node._$host) {
|
|
897
|
+
node = node._$host;
|
|
898
|
+
walkUpTree();
|
|
899
|
+
break;
|
|
900
|
+
}
|
|
901
|
+
if (node === boundary || node.parentNode === boundary) {
|
|
902
|
+
break;
|
|
903
|
+
}
|
|
480
904
|
}
|
|
481
|
-
}
|
|
905
|
+
} else walkUpTree();
|
|
482
906
|
}
|
|
483
907
|
else walkUpTree();
|
|
484
908
|
retarget(oriTarget);
|
|
485
909
|
}
|
|
486
910
|
function insertExpression(parent, value, current, marker) {
|
|
487
|
-
if (isHydrating(parent)) return;
|
|
911
|
+
if (hydrationRt !== null && isHydrating(parent)) return;
|
|
488
912
|
if (value === current) return;
|
|
489
913
|
const t = typeof value,
|
|
490
914
|
multi = marker !== undefined;
|
|
@@ -492,15 +916,25 @@ function insertExpression(parent, value, current, marker) {
|
|
|
492
916
|
const tc = typeof current;
|
|
493
917
|
if (tc === "string" || tc === "number") {
|
|
494
918
|
parent.firstChild.data = value;
|
|
495
|
-
} else
|
|
919
|
+
} else {
|
|
920
|
+
if (ownsAllChildren(parent, current)) parent.textContent = value;else {
|
|
921
|
+
removeOwnedChildren(parent, current);
|
|
922
|
+
parent.insertBefore(document.createTextNode(value), parent.firstChild);
|
|
923
|
+
}
|
|
924
|
+
}
|
|
496
925
|
} else if (value === undefined) {
|
|
497
926
|
cleanChildren(parent, current, marker);
|
|
498
927
|
} else if (value.nodeType) {
|
|
499
928
|
if (Array.isArray(current)) {
|
|
500
929
|
cleanChildren(parent, current, multi ? marker : null, value);
|
|
501
|
-
} else if (current
|
|
930
|
+
} else if (current && current.nodeType) {
|
|
931
|
+
current.parentNode === parent ? parent.replaceChild(value, current) : parent.appendChild(value);
|
|
932
|
+
} else if (current && parent.firstChild) {
|
|
933
|
+
parent.replaceChild(value, parent.firstChild);
|
|
934
|
+
} else {
|
|
502
935
|
parent.appendChild(value);
|
|
503
|
-
}
|
|
936
|
+
}
|
|
937
|
+
if (marker) value[$$SLOT] = marker;
|
|
504
938
|
} else if (Array.isArray(value)) {
|
|
505
939
|
const currentArray = current && Array.isArray(current);
|
|
506
940
|
if (value.length === 0) {
|
|
@@ -508,9 +942,9 @@ function insertExpression(parent, value, current, marker) {
|
|
|
508
942
|
} else if (currentArray) {
|
|
509
943
|
if (current.length === 0) {
|
|
510
944
|
appendNodes(parent, value, marker);
|
|
511
|
-
} else reconcileArrays(parent, current, value);
|
|
945
|
+
} else reconcileArrays(parent, current, value, marker);
|
|
512
946
|
} else {
|
|
513
|
-
current && cleanChildren(parent);
|
|
947
|
+
current && cleanChildren(parent, current);
|
|
514
948
|
appendNodes(parent, value);
|
|
515
949
|
}
|
|
516
950
|
} else ;
|
|
@@ -532,21 +966,64 @@ function normalize(value, current, multi, doNotUnwrap) {
|
|
|
532
966
|
}
|
|
533
967
|
return value;
|
|
534
968
|
}
|
|
969
|
+
function tagHost(value, host) {
|
|
970
|
+
if (Array.isArray(value)) {
|
|
971
|
+
for (let i = 0, len = value.length; i < len; i++) tagHost(value[i], host);
|
|
972
|
+
} else if (value && value.nodeType && value[$$HOST] !== host) {
|
|
973
|
+
value[$$HOST] = host;
|
|
974
|
+
Object.defineProperty(value, "_$host", {
|
|
975
|
+
get: host,
|
|
976
|
+
configurable: true
|
|
977
|
+
});
|
|
978
|
+
}
|
|
979
|
+
}
|
|
535
980
|
function appendNodes(parent, array, marker = null) {
|
|
536
|
-
for (let i = 0, len = array.length; i < len; i++)
|
|
981
|
+
for (let i = 0, len = array.length; i < len; i++) {
|
|
982
|
+
const n = array[i];
|
|
983
|
+
parent.insertBefore(n, marker);
|
|
984
|
+
if (marker) n[$$SLOT] = marker;
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
function ownsAllChildren(parent, current) {
|
|
988
|
+
if (current == null) return true;
|
|
989
|
+
if (Array.isArray(current)) {
|
|
990
|
+
return current.length ? parent.firstChild === current[0] && parent.lastChild === current[current.length - 1] : parent.firstChild === null;
|
|
991
|
+
}
|
|
992
|
+
if (current === "") return parent.firstChild === null;
|
|
993
|
+
if (current.nodeType) return parent.firstChild === current && parent.lastChild === current;
|
|
994
|
+
const first = parent.firstChild;
|
|
995
|
+
return first !== null && first.nodeType === 3 && parent.lastChild === first;
|
|
996
|
+
}
|
|
997
|
+
function removeOwnedChildren(parent, current) {
|
|
998
|
+
if (Array.isArray(current)) {
|
|
999
|
+
for (let i = 0; i < current.length; i++) {
|
|
1000
|
+
const el = current[i];
|
|
1001
|
+
if (el.parentNode === parent) el.remove();
|
|
1002
|
+
}
|
|
1003
|
+
} else if (current.nodeType) {
|
|
1004
|
+
if (current.parentNode === parent) current.remove();
|
|
1005
|
+
} else {
|
|
1006
|
+
const first = parent.firstChild;
|
|
1007
|
+
if (first && first.nodeType === 3) first.remove();
|
|
1008
|
+
}
|
|
537
1009
|
}
|
|
538
1010
|
function cleanChildren(parent, current, marker, replacement) {
|
|
539
|
-
if (marker === undefined)
|
|
1011
|
+
if (marker === undefined) {
|
|
1012
|
+
if (ownsAllChildren(parent, current)) return parent.textContent = "";
|
|
1013
|
+
return removeOwnedChildren(parent, current);
|
|
1014
|
+
}
|
|
540
1015
|
if (current.length) {
|
|
541
1016
|
let inserted = false;
|
|
542
1017
|
for (let i = current.length - 1; i >= 0; i--) {
|
|
543
1018
|
const el = current[i];
|
|
544
1019
|
if (replacement !== el) {
|
|
545
|
-
const
|
|
546
|
-
|
|
1020
|
+
const tag = el[$$SLOT];
|
|
1021
|
+
const owns = el.parentNode === parent && (!tag || tag === marker);
|
|
1022
|
+
if (replacement && !inserted && !i) owns ? parent.replaceChild(replacement, el) : parent.insertBefore(replacement, marker);else if (owns) el.remove();
|
|
547
1023
|
} else inserted = true;
|
|
548
1024
|
}
|
|
549
1025
|
} else if (replacement) parent.insertBefore(replacement, marker);
|
|
1026
|
+
if (replacement && marker) replacement[$$SLOT] = marker;
|
|
550
1027
|
}
|
|
551
1028
|
function gatherHydratable(element, root) {
|
|
552
1029
|
const templates = element.querySelectorAll(`*[_hk]`);
|
|
@@ -584,77 +1061,163 @@ function ssrHydrationKey() {}
|
|
|
584
1061
|
function resolveSSRNode(node) {}
|
|
585
1062
|
function escape(html) {}
|
|
586
1063
|
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
1064
|
+
const ENVELOPE = Symbol.for("solid.ResponseEnvelope");
|
|
1065
|
+
class ResponseEnvelope {
|
|
1066
|
+
constructor(response, value) {
|
|
1067
|
+
this.response = response;
|
|
1068
|
+
this.value = value;
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
ResponseEnvelope.prototype[ENVELOPE] = true;
|
|
1072
|
+
function isResponseEnvelope(value) {
|
|
1073
|
+
return !!(value && typeof value === "object" && value[ENVELOPE]);
|
|
1074
|
+
}
|
|
1075
|
+
function initWithRevalidate(init) {
|
|
1076
|
+
const {
|
|
1077
|
+
revalidate,
|
|
1078
|
+
...responseInit
|
|
1079
|
+
} = init;
|
|
1080
|
+
const headers = new Headers(responseInit.headers);
|
|
1081
|
+
revalidate !== undefined && headers.set("X-Revalidate", revalidate.toString());
|
|
1082
|
+
return {
|
|
1083
|
+
responseInit,
|
|
1084
|
+
headers
|
|
1085
|
+
};
|
|
1086
|
+
}
|
|
1087
|
+
function redirect(url, init = 302) {
|
|
1088
|
+
const {
|
|
1089
|
+
responseInit,
|
|
1090
|
+
headers
|
|
1091
|
+
} = initWithRevalidate(typeof init === "number" ? {
|
|
1092
|
+
status: init
|
|
1093
|
+
} : init);
|
|
1094
|
+
if (responseInit.status === undefined) {
|
|
1095
|
+
responseInit.status = 302;
|
|
1096
|
+
}
|
|
1097
|
+
headers.set("Location", url);
|
|
1098
|
+
return new Response(null, {
|
|
1099
|
+
...responseInit,
|
|
1100
|
+
headers
|
|
1101
|
+
});
|
|
590
1102
|
}
|
|
1103
|
+
function reload(init = {}) {
|
|
1104
|
+
const {
|
|
1105
|
+
responseInit,
|
|
1106
|
+
headers
|
|
1107
|
+
} = initWithRevalidate(init);
|
|
1108
|
+
return new Response(null, {
|
|
1109
|
+
...responseInit,
|
|
1110
|
+
headers
|
|
1111
|
+
});
|
|
1112
|
+
}
|
|
1113
|
+
function respond(value, init = {}) {
|
|
1114
|
+
const {
|
|
1115
|
+
responseInit,
|
|
1116
|
+
headers
|
|
1117
|
+
} = initWithRevalidate(init);
|
|
1118
|
+
headers.set("Content-Type", "application/json");
|
|
1119
|
+
return new ResponseEnvelope(new Response(JSON.stringify(value), {
|
|
1120
|
+
...responseInit,
|
|
1121
|
+
headers
|
|
1122
|
+
}), value);
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
const mergeProps = merge;
|
|
591
1126
|
const isServer = false;
|
|
592
1127
|
const isDev = false;
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
1128
|
+
function render(code, element, init, options = {}) {
|
|
1129
|
+
try {
|
|
1130
|
+
const dispose = render$1(code, element, init, {
|
|
1131
|
+
...options,
|
|
1132
|
+
insertOptions: {
|
|
1133
|
+
schedule: true
|
|
1134
|
+
}
|
|
1135
|
+
});
|
|
1136
|
+
flush();
|
|
1137
|
+
return dispose;
|
|
1138
|
+
} finally {
|
|
1139
|
+
}
|
|
598
1140
|
}
|
|
599
1141
|
const hydrate = (...args) => {
|
|
600
1142
|
enableHydration();
|
|
601
1143
|
return hydrate$1(...args);
|
|
602
1144
|
};
|
|
603
1145
|
function Portal(props) {
|
|
1146
|
+
return runWithOwner(createOwner(), () => portalImpl(props));
|
|
1147
|
+
}
|
|
1148
|
+
function portalImpl(props) {
|
|
604
1149
|
const treeMarker = document.createTextNode(""),
|
|
605
1150
|
startMarker = document.createTextNode(""),
|
|
606
1151
|
endMarker = document.createTextNode(""),
|
|
607
|
-
mount = () =>
|
|
608
|
-
|
|
609
|
-
|
|
1152
|
+
mount = () => props.mount || document.body,
|
|
1153
|
+
content = createMemo(() => [startMarker, props.children], {
|
|
1154
|
+
ssrSource: "client"
|
|
1155
|
+
});
|
|
1156
|
+
createRenderEffect(
|
|
1157
|
+
() => [mount(), content(), getOwner()], ([, c, owner]) => {
|
|
1158
|
+
const m = untrack(mount);
|
|
610
1159
|
m.appendChild(endMarker);
|
|
611
|
-
|
|
1160
|
+
const dispose = runWithOwner(owner, () => createRoot(d => {
|
|
1161
|
+
insert(m, c, endMarker, undefined, {
|
|
1162
|
+
host: () => treeMarker.parentNode
|
|
1163
|
+
});
|
|
1164
|
+
return d;
|
|
1165
|
+
}));
|
|
612
1166
|
return () => {
|
|
1167
|
+
dispose();
|
|
613
1168
|
let c = startMarker;
|
|
614
|
-
while (c
|
|
1169
|
+
while (c) {
|
|
615
1170
|
const n = c.nextSibling;
|
|
616
1171
|
m.removeChild(c);
|
|
1172
|
+
if (c === endMarker) break;
|
|
617
1173
|
c = n;
|
|
618
1174
|
}
|
|
619
1175
|
};
|
|
1176
|
+
},
|
|
1177
|
+
{
|
|
1178
|
+
schedule: true,
|
|
1179
|
+
ssrSource: "client"
|
|
620
1180
|
});
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
get: () => marker.parentNode,
|
|
630
|
-
configurable: true
|
|
631
|
-
});
|
|
632
|
-
target[prop](...args);
|
|
633
|
-
};
|
|
634
|
-
}
|
|
635
|
-
const value = Reflect.get(target, prop);
|
|
636
|
-
return typeof value === "function" ? value.bind(target) : value;
|
|
637
|
-
}
|
|
1181
|
+
createEffect(mount, () => {
|
|
1182
|
+
const m = untrack(mount);
|
|
1183
|
+
const ownerRoot = getDelegatedRoot(treeMarker);
|
|
1184
|
+
if (!ownerRoot || ownerRoot.contains(m)) return;
|
|
1185
|
+
registerDelegatedContainer(m, ownerRoot);
|
|
1186
|
+
return () => unregisterDelegatedContainer(m, ownerRoot);
|
|
1187
|
+
}, {
|
|
1188
|
+
ssrSource: "client"
|
|
638
1189
|
});
|
|
1190
|
+
if (sharedConfig.hydrating) return createMemo(() => treeMarker, {
|
|
1191
|
+
ssrSource: "client"
|
|
1192
|
+
});
|
|
1193
|
+
return treeMarker;
|
|
639
1194
|
}
|
|
640
|
-
function
|
|
641
|
-
const cached = createMemo
|
|
642
|
-
|
|
643
|
-
const component = cached();
|
|
644
|
-
switch (typeof component) {
|
|
645
|
-
case "function":
|
|
646
|
-
return untrack(() => component(props));
|
|
647
|
-
case "string":
|
|
648
|
-
const isSvg = SVGElements.has(component);
|
|
649
|
-
const el = sharedConfig.hydrating ? getNextElement() : createElement(component, isSvg, untrack(() => props.is));
|
|
650
|
-
spread(el, props, isSvg);
|
|
651
|
-
return el;
|
|
652
|
-
}
|
|
1195
|
+
function dynamic(source) {
|
|
1196
|
+
const cached = createMemo(source, {
|
|
1197
|
+
lazy: true
|
|
653
1198
|
});
|
|
1199
|
+
return props => {
|
|
1200
|
+
return createMemo(() => {
|
|
1201
|
+
const component = cached();
|
|
1202
|
+
switch (typeof component) {
|
|
1203
|
+
case "function":
|
|
1204
|
+
return untrack(() => component(props));
|
|
1205
|
+
case "string":
|
|
1206
|
+
const el = sharedConfig.hydrating ? getNextElement() : createElement(component, untrack(() => props.is));
|
|
1207
|
+
spread(el, props);
|
|
1208
|
+
return el;
|
|
1209
|
+
}
|
|
1210
|
+
});
|
|
1211
|
+
};
|
|
654
1212
|
}
|
|
655
1213
|
function Dynamic(props) {
|
|
656
|
-
const
|
|
657
|
-
return
|
|
1214
|
+
const Comp = dynamic(() => props.component);
|
|
1215
|
+
return createComponent(Comp, omit(props, "component"));
|
|
1216
|
+
}
|
|
1217
|
+
function createElement(tagName, is = undefined) {
|
|
1218
|
+
return SVGElements.has(tagName) ? document.createElementNS(Namespaces.svg, tagName) : MathMLElements.has(tagName) ? document.createElementNS(Namespaces.mathml, tagName) : document.createElement(tagName, {
|
|
1219
|
+
is
|
|
1220
|
+
});
|
|
658
1221
|
}
|
|
659
1222
|
|
|
660
|
-
export { voidFn as Assets, ChildProperties, DOMElements, DelegatedEvents, Dynamic, voidFn as HydrationScript, Portal,
|
|
1223
|
+
export { voidFn as Assets, ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, voidFn as HydrationScript, MathMLElements, Namespaces, Portal, RawTextElements, RequestContext, ResponseEnvelope, SVGElements, VoidElements, acquireAsset, addEvent, applyRef, assign, className, delegateEvents, dynamic, dynamicProperty, effect, escape, voidFn as generateHydrationScript, voidFn as getAssets, getDelegatedRoot, getFirstChild, getHydrationKey, getNextElement, getNextMarker, getNextMatch, getNextSibling, voidFn as getRequestEvent, hydrate, insert, installHydrationRuntime, isDev, isResponseEnvelope, isServer, memo, mergeProps, redirect, ref, registerDelegatedContainer, registerDelegatedRoot, reload, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, respond, runHydrationEvents, scope, setAttribute, setAttributeNS, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrStyle, style, template, unregisterDelegatedContainer, unregisterDelegatedRoot, voidFn as useAssets };
|