@solidjs/web 2.0.0-beta.2 → 2.0.0-beta.20
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 +783 -223
- package/dist/dev.js +757 -217
- package/dist/server.cjs +742 -186
- package/dist/server.js +714 -183
- package/dist/web.cjs +772 -196
- package/dist/web.js +746 -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 +370 -0
- package/server-functions/dist/client.js +363 -0
- package/server-functions/dist/server.cjs +542 -0
- package/server-functions/dist/server.js +531 -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 +63 -0
- package/types/server-functions/server.d.ts +188 -0
- package/types/server-functions/shared.d.ts +171 -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 +63 -0
- package/types-cjs/server-functions/server.d.cts +188 -0
- package/types-cjs/server-functions/shared.d.cts +171 -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
|
-
|
|
513
|
+
prevProps[prop] = assignProp(node, prop, props[prop], prevProps[prop], skipRef, nodeName);
|
|
514
|
+
}
|
|
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
|
+
}
|
|
279
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;
|
|
280
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) {
|
|
@@ -306,6 +657,27 @@ function hydrate$1(code, element, options = {}) {
|
|
|
306
657
|
};
|
|
307
658
|
sharedConfig.registry = new Map();
|
|
308
659
|
sharedConfig.hydrating = true;
|
|
660
|
+
const rootMapping = globalThis._$HY.r && globalThis._$HY.r["_assets"];
|
|
661
|
+
if (rootMapping && typeof rootMapping === "object") {
|
|
662
|
+
const p = loadModuleAssets(rootMapping);
|
|
663
|
+
if (p) {
|
|
664
|
+
gatherHydratable(element, options.renderId);
|
|
665
|
+
let disposer;
|
|
666
|
+
p.then(() => {
|
|
667
|
+
try {
|
|
668
|
+
disposer = render$1(code, element, [...element.childNodes], options);
|
|
669
|
+
} finally {
|
|
670
|
+
sharedConfig.hydrating = false;
|
|
671
|
+
}
|
|
672
|
+
}, err => {
|
|
673
|
+
console.error("Hydration module preload failed, falling back to client render:", err);
|
|
674
|
+
sharedConfig.hydrating = false;
|
|
675
|
+
sharedConfig.registry = undefined;
|
|
676
|
+
disposer = render$1(code, element, [...element.childNodes], options);
|
|
677
|
+
});
|
|
678
|
+
return () => disposer && disposer();
|
|
679
|
+
}
|
|
680
|
+
}
|
|
309
681
|
try {
|
|
310
682
|
gatherHydratable(element, options.renderId);
|
|
311
683
|
return render$1(code, element, [...element.childNodes], options);
|
|
@@ -371,7 +743,32 @@ function runHydrationEvents() {
|
|
|
371
743
|
const [el, e] = events[0];
|
|
372
744
|
if (!completed.has(el)) return;
|
|
373
745
|
events.shift();
|
|
374
|
-
|
|
746
|
+
let matchContainer, matchState, matchDistance, matches;
|
|
747
|
+
for (const [container, state] of delegatedContainers) {
|
|
748
|
+
if (!state.handlers.has(e.type)) continue;
|
|
749
|
+
const entry = findOwner(e.target, state);
|
|
750
|
+
if (!entry) continue;
|
|
751
|
+
if (matchContainer) {
|
|
752
|
+
if (!matches) matches = [{
|
|
753
|
+
container: matchContainer,
|
|
754
|
+
state: matchState,
|
|
755
|
+
distance: matchDistance
|
|
756
|
+
}];
|
|
757
|
+
matches.push({
|
|
758
|
+
container,
|
|
759
|
+
state,
|
|
760
|
+
distance: entry.distance
|
|
761
|
+
});
|
|
762
|
+
} else {
|
|
763
|
+
matchContainer = container;
|
|
764
|
+
matchState = state;
|
|
765
|
+
matchDistance = entry.distance;
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
if (matches) {
|
|
769
|
+
matches.sort((a, b) => a.distance - b.distance);
|
|
770
|
+
for (let i = 0; i < matches.length; i++) eventHandler(e, matches[i].container, matches[i].state);
|
|
771
|
+
} else if (matchContainer) eventHandler(e, matchContainer, matchState);
|
|
375
772
|
}
|
|
376
773
|
if (sharedConfig.done) {
|
|
377
774
|
sharedConfig.events = _$HY.events = null;
|
|
@@ -384,14 +781,21 @@ function runHydrationEvents() {
|
|
|
384
781
|
function isHydrating(node) {
|
|
385
782
|
return sharedConfig.hydrating && (!node || node.isConnected);
|
|
386
783
|
}
|
|
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
784
|
function classListToObject(classList) {
|
|
392
785
|
if (Array.isArray(classList)) {
|
|
393
786
|
const result = {};
|
|
394
787
|
flattenClassList(classList, result);
|
|
788
|
+
classList = result;
|
|
789
|
+
}
|
|
790
|
+
if (classList && typeof classList === "object") {
|
|
791
|
+
const result = {},
|
|
792
|
+
keys = Object.keys(classList);
|
|
793
|
+
for (let i = 0, len = keys.length; i < len; i++) {
|
|
794
|
+
const key = keys[i];
|
|
795
|
+
if (!classList[key]) continue;
|
|
796
|
+
const classNames = key.trim().split(/\s+/);
|
|
797
|
+
for (let j = 0, nameLen = classNames.length; j < nameLen; j++) classNames[j] && (result[classNames[j]] = true);
|
|
798
|
+
}
|
|
395
799
|
return result;
|
|
396
800
|
}
|
|
397
801
|
return classList;
|
|
@@ -402,18 +806,16 @@ function flattenClassList(list, result) {
|
|
|
402
806
|
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
807
|
}
|
|
404
808
|
}
|
|
405
|
-
function assignProp(node, prop, value, prev,
|
|
406
|
-
let forceProp;
|
|
809
|
+
function assignProp(node, prop, value, prev, skipRef, nodeName) {
|
|
407
810
|
if (prop === "style") return style(node, value, prev), value;
|
|
408
|
-
if (prop === "class") return className(node, value,
|
|
409
|
-
if (value === prev) return prev;
|
|
811
|
+
if (prop === "class") return className(node, value, prev), value;
|
|
812
|
+
if (value === prev && DOMWithState[nodeName]?.[prop] !== 1) return prev;
|
|
410
813
|
if (prop === "ref") {
|
|
411
814
|
if (!skipRef && value) ref(() => value, node);
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
} else if (prop.slice(0, 2) === "on") {
|
|
815
|
+
return value;
|
|
816
|
+
}
|
|
817
|
+
const hasNamespace = prop.indexOf(":") > -1;
|
|
818
|
+
if (!hasNamespace && prop.slice(0, 2) === "on") {
|
|
417
819
|
const name = prop.slice(2).toLowerCase();
|
|
418
820
|
const delegate = DelegatedEvents.has(name);
|
|
419
821
|
if (!delegate && prev) {
|
|
@@ -421,26 +823,33 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
|
|
|
421
823
|
node.removeEventListener(name, h);
|
|
422
824
|
}
|
|
423
825
|
if (delegate || value) {
|
|
424
|
-
|
|
826
|
+
addEvent(node, name, value, delegate);
|
|
425
827
|
delegate && delegateEvents([name]);
|
|
426
828
|
}
|
|
427
|
-
} else if (
|
|
428
|
-
if (
|
|
429
|
-
if (prop === "value" &&
|
|
829
|
+
} else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop]) {
|
|
830
|
+
if (hasNamespace) prop = prop.slice(5);else if (isHydrating(node)) return value;
|
|
831
|
+
if (prop === "value" && nodeName === "SELECT") queueMicrotask(() => node.value = value) || (node.value = value);else node[prop] = value;
|
|
430
832
|
} else {
|
|
431
|
-
const ns =
|
|
833
|
+
const ns = hasNamespace && Namespaces[prop.split(":")[0]];
|
|
432
834
|
if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, prop, value);
|
|
433
835
|
}
|
|
434
836
|
return value;
|
|
435
837
|
}
|
|
436
|
-
function eventHandler(e) {
|
|
437
|
-
if (
|
|
438
|
-
|
|
838
|
+
function eventHandler(e, container, state) {
|
|
839
|
+
if (hydrationRt !== null && hydrationRt.dedupEvent(e)) return;
|
|
840
|
+
const prev = e[$$EVENT_OWNER];
|
|
841
|
+
let resumeNode;
|
|
842
|
+
if (prev) {
|
|
843
|
+
if (prev === true || prev === container || !container.contains(prev)) return;
|
|
844
|
+
resumeNode = prev;
|
|
439
845
|
}
|
|
440
|
-
|
|
846
|
+
const owner = state && (state.owners.size === 1 && state.owners.has(container) ? container : findOwner(e.target, state)?.owner);
|
|
847
|
+
if (state && !owner) return;
|
|
848
|
+
e[$$EVENT_OWNER] = owner || true;
|
|
849
|
+
let node = resumeNode || e.target;
|
|
441
850
|
const key = `$$${e.type}`;
|
|
442
851
|
const oriTarget = e.target;
|
|
443
|
-
const
|
|
852
|
+
const boundary = owner || container || e.currentTarget;
|
|
444
853
|
const retarget = value => Object.defineProperty(e, "target", {
|
|
445
854
|
configurable: true,
|
|
446
855
|
value
|
|
@@ -456,35 +865,43 @@ function eventHandler(e) {
|
|
|
456
865
|
return true;
|
|
457
866
|
};
|
|
458
867
|
const walkUpTree = () => {
|
|
459
|
-
while (handleNode()
|
|
868
|
+
while (handleNode()) {
|
|
869
|
+
if (node === boundary || node.parentNode === boundary) break;
|
|
870
|
+
node = node._$host || node.parentNode || node.host;
|
|
871
|
+
}
|
|
460
872
|
};
|
|
461
873
|
Object.defineProperty(e, "currentTarget", {
|
|
462
874
|
configurable: true,
|
|
463
875
|
get() {
|
|
464
|
-
return node || document;
|
|
876
|
+
return node || boundary || document;
|
|
465
877
|
}
|
|
466
878
|
});
|
|
467
|
-
if (
|
|
879
|
+
if (resumeNode) {
|
|
880
|
+
if (resumeNode === e.target) node = resumeNode._$host || resumeNode.parentNode || resumeNode.host;
|
|
881
|
+
if (node && node !== boundary) walkUpTree();
|
|
882
|
+
} else if (e.composedPath) {
|
|
468
883
|
const path = e.composedPath();
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
884
|
+
if (path.length) {
|
|
885
|
+
retarget(path[0]);
|
|
886
|
+
for (let i = 0; i < path.length; i++) {
|
|
887
|
+
node = path[i];
|
|
888
|
+
if (!handleNode()) break;
|
|
889
|
+
if (node._$host) {
|
|
890
|
+
node = node._$host;
|
|
891
|
+
walkUpTree();
|
|
892
|
+
break;
|
|
893
|
+
}
|
|
894
|
+
if (node === boundary || node.parentNode === boundary) {
|
|
895
|
+
break;
|
|
896
|
+
}
|
|
480
897
|
}
|
|
481
|
-
}
|
|
898
|
+
} else walkUpTree();
|
|
482
899
|
}
|
|
483
900
|
else walkUpTree();
|
|
484
901
|
retarget(oriTarget);
|
|
485
902
|
}
|
|
486
903
|
function insertExpression(parent, value, current, marker) {
|
|
487
|
-
if (isHydrating(parent)) return;
|
|
904
|
+
if (hydrationRt !== null && isHydrating(parent)) return;
|
|
488
905
|
if (value === current) return;
|
|
489
906
|
const t = typeof value,
|
|
490
907
|
multi = marker !== undefined;
|
|
@@ -492,15 +909,25 @@ function insertExpression(parent, value, current, marker) {
|
|
|
492
909
|
const tc = typeof current;
|
|
493
910
|
if (tc === "string" || tc === "number") {
|
|
494
911
|
parent.firstChild.data = value;
|
|
495
|
-
} else
|
|
912
|
+
} else {
|
|
913
|
+
if (ownsAllChildren(parent, current)) parent.textContent = value;else {
|
|
914
|
+
removeOwnedChildren(parent, current);
|
|
915
|
+
parent.insertBefore(document.createTextNode(value), parent.firstChild);
|
|
916
|
+
}
|
|
917
|
+
}
|
|
496
918
|
} else if (value === undefined) {
|
|
497
919
|
cleanChildren(parent, current, marker);
|
|
498
920
|
} else if (value.nodeType) {
|
|
499
921
|
if (Array.isArray(current)) {
|
|
500
922
|
cleanChildren(parent, current, multi ? marker : null, value);
|
|
501
|
-
} else if (current
|
|
923
|
+
} else if (current && current.nodeType) {
|
|
924
|
+
current.parentNode === parent ? parent.replaceChild(value, current) : parent.appendChild(value);
|
|
925
|
+
} else if (current && parent.firstChild) {
|
|
926
|
+
parent.replaceChild(value, parent.firstChild);
|
|
927
|
+
} else {
|
|
502
928
|
parent.appendChild(value);
|
|
503
|
-
}
|
|
929
|
+
}
|
|
930
|
+
if (marker) value[$$SLOT] = marker;
|
|
504
931
|
} else if (Array.isArray(value)) {
|
|
505
932
|
const currentArray = current && Array.isArray(current);
|
|
506
933
|
if (value.length === 0) {
|
|
@@ -508,9 +935,9 @@ function insertExpression(parent, value, current, marker) {
|
|
|
508
935
|
} else if (currentArray) {
|
|
509
936
|
if (current.length === 0) {
|
|
510
937
|
appendNodes(parent, value, marker);
|
|
511
|
-
} else reconcileArrays(parent, current, value);
|
|
938
|
+
} else reconcileArrays(parent, current, value, marker);
|
|
512
939
|
} else {
|
|
513
|
-
current && cleanChildren(parent);
|
|
940
|
+
current && cleanChildren(parent, current);
|
|
514
941
|
appendNodes(parent, value);
|
|
515
942
|
}
|
|
516
943
|
} else ;
|
|
@@ -532,21 +959,64 @@ function normalize(value, current, multi, doNotUnwrap) {
|
|
|
532
959
|
}
|
|
533
960
|
return value;
|
|
534
961
|
}
|
|
962
|
+
function tagHost(value, host) {
|
|
963
|
+
if (Array.isArray(value)) {
|
|
964
|
+
for (let i = 0, len = value.length; i < len; i++) tagHost(value[i], host);
|
|
965
|
+
} else if (value && value.nodeType && value[$$HOST] !== host) {
|
|
966
|
+
value[$$HOST] = host;
|
|
967
|
+
Object.defineProperty(value, "_$host", {
|
|
968
|
+
get: host,
|
|
969
|
+
configurable: true
|
|
970
|
+
});
|
|
971
|
+
}
|
|
972
|
+
}
|
|
535
973
|
function appendNodes(parent, array, marker = null) {
|
|
536
|
-
for (let i = 0, len = array.length; i < len; i++)
|
|
974
|
+
for (let i = 0, len = array.length; i < len; i++) {
|
|
975
|
+
const n = array[i];
|
|
976
|
+
parent.insertBefore(n, marker);
|
|
977
|
+
if (marker) n[$$SLOT] = marker;
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
function ownsAllChildren(parent, current) {
|
|
981
|
+
if (current == null) return true;
|
|
982
|
+
if (Array.isArray(current)) {
|
|
983
|
+
return current.length ? parent.firstChild === current[0] && parent.lastChild === current[current.length - 1] : parent.firstChild === null;
|
|
984
|
+
}
|
|
985
|
+
if (current === "") return parent.firstChild === null;
|
|
986
|
+
if (current.nodeType) return parent.firstChild === current && parent.lastChild === current;
|
|
987
|
+
const first = parent.firstChild;
|
|
988
|
+
return first !== null && first.nodeType === 3 && parent.lastChild === first;
|
|
989
|
+
}
|
|
990
|
+
function removeOwnedChildren(parent, current) {
|
|
991
|
+
if (Array.isArray(current)) {
|
|
992
|
+
for (let i = 0; i < current.length; i++) {
|
|
993
|
+
const el = current[i];
|
|
994
|
+
if (el.parentNode === parent) el.remove();
|
|
995
|
+
}
|
|
996
|
+
} else if (current.nodeType) {
|
|
997
|
+
if (current.parentNode === parent) current.remove();
|
|
998
|
+
} else {
|
|
999
|
+
const first = parent.firstChild;
|
|
1000
|
+
if (first && first.nodeType === 3) first.remove();
|
|
1001
|
+
}
|
|
537
1002
|
}
|
|
538
1003
|
function cleanChildren(parent, current, marker, replacement) {
|
|
539
|
-
if (marker === undefined)
|
|
1004
|
+
if (marker === undefined) {
|
|
1005
|
+
if (ownsAllChildren(parent, current)) return parent.textContent = "";
|
|
1006
|
+
return removeOwnedChildren(parent, current);
|
|
1007
|
+
}
|
|
540
1008
|
if (current.length) {
|
|
541
1009
|
let inserted = false;
|
|
542
1010
|
for (let i = current.length - 1; i >= 0; i--) {
|
|
543
1011
|
const el = current[i];
|
|
544
1012
|
if (replacement !== el) {
|
|
545
|
-
const
|
|
546
|
-
|
|
1013
|
+
const tag = el[$$SLOT];
|
|
1014
|
+
const owns = el.parentNode === parent && (!tag || tag === marker);
|
|
1015
|
+
if (replacement && !inserted && !i) owns ? parent.replaceChild(replacement, el) : parent.insertBefore(replacement, marker);else if (owns) el.remove();
|
|
547
1016
|
} else inserted = true;
|
|
548
1017
|
}
|
|
549
1018
|
} else if (replacement) parent.insertBefore(replacement, marker);
|
|
1019
|
+
if (replacement && marker) replacement[$$SLOT] = marker;
|
|
550
1020
|
}
|
|
551
1021
|
function gatherHydratable(element, root) {
|
|
552
1022
|
const templates = element.querySelectorAll(`*[_hk]`);
|
|
@@ -584,77 +1054,163 @@ function ssrHydrationKey() {}
|
|
|
584
1054
|
function resolveSSRNode(node) {}
|
|
585
1055
|
function escape(html) {}
|
|
586
1056
|
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
1057
|
+
const ENVELOPE = Symbol.for("solid.ResponseEnvelope");
|
|
1058
|
+
class ResponseEnvelope {
|
|
1059
|
+
constructor(response, value) {
|
|
1060
|
+
this.response = response;
|
|
1061
|
+
this.value = value;
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
ResponseEnvelope.prototype[ENVELOPE] = true;
|
|
1065
|
+
function isResponseEnvelope(value) {
|
|
1066
|
+
return !!(value && typeof value === "object" && value[ENVELOPE]);
|
|
1067
|
+
}
|
|
1068
|
+
function initWithRevalidate(init) {
|
|
1069
|
+
const {
|
|
1070
|
+
revalidate,
|
|
1071
|
+
...responseInit
|
|
1072
|
+
} = init;
|
|
1073
|
+
const headers = new Headers(responseInit.headers);
|
|
1074
|
+
revalidate !== undefined && headers.set("X-Revalidate", revalidate.toString());
|
|
1075
|
+
return {
|
|
1076
|
+
responseInit,
|
|
1077
|
+
headers
|
|
1078
|
+
};
|
|
1079
|
+
}
|
|
1080
|
+
function redirect(url, init = 302) {
|
|
1081
|
+
const {
|
|
1082
|
+
responseInit,
|
|
1083
|
+
headers
|
|
1084
|
+
} = initWithRevalidate(typeof init === "number" ? {
|
|
1085
|
+
status: init
|
|
1086
|
+
} : init);
|
|
1087
|
+
if (responseInit.status === undefined) {
|
|
1088
|
+
responseInit.status = 302;
|
|
1089
|
+
}
|
|
1090
|
+
headers.set("Location", url);
|
|
1091
|
+
return new Response(null, {
|
|
1092
|
+
...responseInit,
|
|
1093
|
+
headers
|
|
1094
|
+
});
|
|
590
1095
|
}
|
|
1096
|
+
function reload(init = {}) {
|
|
1097
|
+
const {
|
|
1098
|
+
responseInit,
|
|
1099
|
+
headers
|
|
1100
|
+
} = initWithRevalidate(init);
|
|
1101
|
+
return new Response(null, {
|
|
1102
|
+
...responseInit,
|
|
1103
|
+
headers
|
|
1104
|
+
});
|
|
1105
|
+
}
|
|
1106
|
+
function respond(value, init = {}) {
|
|
1107
|
+
const {
|
|
1108
|
+
responseInit,
|
|
1109
|
+
headers
|
|
1110
|
+
} = initWithRevalidate(init);
|
|
1111
|
+
headers.set("Content-Type", "application/json");
|
|
1112
|
+
return new ResponseEnvelope(new Response(JSON.stringify(value), {
|
|
1113
|
+
...responseInit,
|
|
1114
|
+
headers
|
|
1115
|
+
}), value);
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
const mergeProps = merge;
|
|
591
1119
|
const isServer = false;
|
|
592
1120
|
const isDev = false;
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
1121
|
+
function render(code, element, init, options = {}) {
|
|
1122
|
+
try {
|
|
1123
|
+
const dispose = render$1(code, element, init, {
|
|
1124
|
+
...options,
|
|
1125
|
+
insertOptions: {
|
|
1126
|
+
schedule: true
|
|
1127
|
+
}
|
|
1128
|
+
});
|
|
1129
|
+
flush();
|
|
1130
|
+
return dispose;
|
|
1131
|
+
} finally {
|
|
1132
|
+
}
|
|
598
1133
|
}
|
|
599
1134
|
const hydrate = (...args) => {
|
|
600
1135
|
enableHydration();
|
|
601
1136
|
return hydrate$1(...args);
|
|
602
1137
|
};
|
|
603
1138
|
function Portal(props) {
|
|
1139
|
+
return runWithOwner(createOwner(), () => portalImpl(props));
|
|
1140
|
+
}
|
|
1141
|
+
function portalImpl(props) {
|
|
604
1142
|
const treeMarker = document.createTextNode(""),
|
|
605
1143
|
startMarker = document.createTextNode(""),
|
|
606
1144
|
endMarker = document.createTextNode(""),
|
|
607
|
-
mount = () =>
|
|
608
|
-
|
|
609
|
-
|
|
1145
|
+
mount = () => props.mount || document.body,
|
|
1146
|
+
content = createMemo(() => [startMarker, props.children], {
|
|
1147
|
+
ssrSource: "client"
|
|
1148
|
+
});
|
|
1149
|
+
createRenderEffect(
|
|
1150
|
+
() => [mount(), content(), getOwner()], ([, c, owner]) => {
|
|
1151
|
+
const m = untrack(mount);
|
|
610
1152
|
m.appendChild(endMarker);
|
|
611
|
-
|
|
1153
|
+
const dispose = runWithOwner(owner, () => createRoot(d => {
|
|
1154
|
+
insert(m, c, endMarker, undefined, {
|
|
1155
|
+
host: () => treeMarker.parentNode
|
|
1156
|
+
});
|
|
1157
|
+
return d;
|
|
1158
|
+
}));
|
|
612
1159
|
return () => {
|
|
1160
|
+
dispose();
|
|
613
1161
|
let c = startMarker;
|
|
614
|
-
while (c
|
|
1162
|
+
while (c) {
|
|
615
1163
|
const n = c.nextSibling;
|
|
616
1164
|
m.removeChild(c);
|
|
1165
|
+
if (c === endMarker) break;
|
|
617
1166
|
c = n;
|
|
618
1167
|
}
|
|
619
1168
|
};
|
|
1169
|
+
},
|
|
1170
|
+
{
|
|
1171
|
+
schedule: true,
|
|
1172
|
+
ssrSource: "client"
|
|
620
1173
|
});
|
|
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
|
-
}
|
|
1174
|
+
createEffect(mount, () => {
|
|
1175
|
+
const m = untrack(mount);
|
|
1176
|
+
const ownerRoot = getDelegatedRoot(treeMarker);
|
|
1177
|
+
if (!ownerRoot || ownerRoot.contains(m)) return;
|
|
1178
|
+
registerDelegatedContainer(m, ownerRoot);
|
|
1179
|
+
return () => unregisterDelegatedContainer(m, ownerRoot);
|
|
1180
|
+
}, {
|
|
1181
|
+
ssrSource: "client"
|
|
638
1182
|
});
|
|
1183
|
+
if (sharedConfig.hydrating) return createMemo(() => treeMarker, {
|
|
1184
|
+
ssrSource: "client"
|
|
1185
|
+
});
|
|
1186
|
+
return treeMarker;
|
|
639
1187
|
}
|
|
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
|
-
}
|
|
1188
|
+
function dynamic(source) {
|
|
1189
|
+
const cached = createMemo(source, {
|
|
1190
|
+
lazy: true
|
|
653
1191
|
});
|
|
1192
|
+
return props => {
|
|
1193
|
+
return createMemo(() => {
|
|
1194
|
+
const component = cached();
|
|
1195
|
+
switch (typeof component) {
|
|
1196
|
+
case "function":
|
|
1197
|
+
return untrack(() => component(props));
|
|
1198
|
+
case "string":
|
|
1199
|
+
const el = sharedConfig.hydrating ? getNextElement() : createElement(component, untrack(() => props.is));
|
|
1200
|
+
spread(el, props);
|
|
1201
|
+
return el;
|
|
1202
|
+
}
|
|
1203
|
+
});
|
|
1204
|
+
};
|
|
654
1205
|
}
|
|
655
1206
|
function Dynamic(props) {
|
|
656
|
-
const
|
|
657
|
-
return
|
|
1207
|
+
const Comp = dynamic(() => props.component);
|
|
1208
|
+
return createComponent(Comp, omit(props, "component"));
|
|
1209
|
+
}
|
|
1210
|
+
function createElement(tagName, is = undefined) {
|
|
1211
|
+
return SVGElements.has(tagName) ? document.createElementNS(Namespaces.svg, tagName) : MathMLElements.has(tagName) ? document.createElementNS(Namespaces.mathml, tagName) : document.createElement(tagName, {
|
|
1212
|
+
is
|
|
1213
|
+
});
|
|
658
1214
|
}
|
|
659
1215
|
|
|
660
|
-
export { voidFn as Assets, ChildProperties, DOMElements, DelegatedEvents, Dynamic, voidFn as HydrationScript, Portal,
|
|
1216
|
+
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 };
|