@solidjs/web 2.0.0-beta.13 → 2.0.0-beta.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev.cjs +246 -89
- package/dist/dev.js +242 -89
- package/dist/server.cjs +41 -1
- package/dist/server.js +32 -1
- package/dist/web.cjs +246 -89
- package/dist/web.js +242 -89
- package/package.json +3 -3
- package/types/client.d.ts +25 -12
- package/types/jsx-properties.d.ts +1 -0
- package/types/jsx.d.ts +55 -9
- package/types/server.d.ts +26 -7
- package/types-cjs/client.d.cts +25 -12
- package/types-cjs/jsx-properties.d.cts +1 -0
- package/types-cjs/jsx.d.cts +55 -9
- package/types-cjs/server.d.cts +26 -7
package/dist/dev.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createRenderEffect, createMemo, sharedConfig, untrack, runWithOwner, flatten, createRoot, merge, createComponent, omit, $DEVCOMP, enableHydration, enforceLoadingBoundary, flush } from 'solid-js';
|
|
1
|
+
import { createRenderEffect, createMemo, sharedConfig, untrack, runWithOwner, flatten, createRoot, merge, createComponent, omit, getOwner, createEffect, $DEVCOMP, enableHydration, enforceLoadingBoundary, flush } from 'solid-js';
|
|
2
2
|
export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, untrack } from 'solid-js';
|
|
3
3
|
|
|
4
4
|
const DOMWithState = {
|
|
@@ -30,6 +30,8 @@ const DOMWithState = {
|
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
32
|
const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
|
|
33
|
+
const $$SLOT = /*#__PURE__*/Symbol("slot");
|
|
34
|
+
const $$HOST = /*#__PURE__*/Symbol("host");
|
|
33
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"]);
|
|
34
36
|
const SVGElements = /*#__PURE__*/new Set([
|
|
35
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",
|
|
@@ -63,14 +65,18 @@ const effect = (fn, effectFn, options) => createRenderEffect(fn, effectFn, optio
|
|
|
63
65
|
} : transparentOptions);
|
|
64
66
|
const memo = fn => createMemo(() => fn(), syncOptions);
|
|
65
67
|
|
|
66
|
-
function reconcileArrays(parentNode, a, b) {
|
|
68
|
+
function reconcileArrays(parentNode, a, b, marker) {
|
|
67
69
|
let bLength = b.length,
|
|
68
70
|
aEnd = a.length,
|
|
69
71
|
bEnd = bLength,
|
|
70
72
|
aStart = 0,
|
|
71
73
|
bStart = 0,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
+
tail = a[aEnd - 1],
|
|
75
|
+
tailTag = tail[$$SLOT],
|
|
76
|
+
after = tail.parentNode === parentNode && (!tailTag || tailTag === marker) ? tail.nextSibling : marker || null,
|
|
77
|
+
map = null,
|
|
78
|
+
anchor,
|
|
79
|
+
anchorTag;
|
|
74
80
|
while (aStart < aEnd || bStart < bEnd) {
|
|
75
81
|
if (a[aStart] === b[bStart]) {
|
|
76
82
|
aStart++;
|
|
@@ -82,20 +88,43 @@ function reconcileArrays(parentNode, a, b) {
|
|
|
82
88
|
bEnd--;
|
|
83
89
|
}
|
|
84
90
|
if (aEnd === aStart) {
|
|
85
|
-
|
|
86
|
-
|
|
91
|
+
let node;
|
|
92
|
+
if (bEnd < bLength) {
|
|
93
|
+
if (bStart) {
|
|
94
|
+
const prev = b[bStart - 1];
|
|
95
|
+
const prevTag = prev[$$SLOT];
|
|
96
|
+
node = prev.parentNode === parentNode && (!prevTag || prevTag === marker) ? prev.nextSibling : after;
|
|
97
|
+
} else node = b[bEnd - bStart];
|
|
98
|
+
} else node = after;
|
|
99
|
+
while (bStart < bEnd) {
|
|
100
|
+
const n = b[bStart++];
|
|
101
|
+
parentNode.insertBefore(n, node);
|
|
102
|
+
if (marker) n[$$SLOT] = marker;
|
|
103
|
+
}
|
|
87
104
|
} else if (bEnd === bStart) {
|
|
88
105
|
while (aStart < aEnd) {
|
|
89
|
-
|
|
90
|
-
|
|
106
|
+
const n = a[aStart++];
|
|
107
|
+
if (!map || !map.has(n)) {
|
|
108
|
+
const tag = n[$$SLOT];
|
|
109
|
+
if (n.parentNode === parentNode && (!tag || tag === marker)) n.remove();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
} else if ((anchor = a[aStart]) === b[bEnd - 1] && b[bStart] === a[aEnd - 1] && anchor.parentNode === parentNode && (!(anchorTag = anchor[$$SLOT]) || anchorTag === marker)) {
|
|
113
|
+
if (marker) {
|
|
114
|
+
do {
|
|
115
|
+
const n = a[--aEnd];
|
|
116
|
+
parentNode.insertBefore(n, anchor);
|
|
117
|
+
n[$$SLOT] = marker;
|
|
118
|
+
bStart++;
|
|
119
|
+
if (aStart >= aEnd - 1 || bStart >= bEnd) break;
|
|
120
|
+
} while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
|
|
121
|
+
} else {
|
|
122
|
+
do {
|
|
123
|
+
parentNode.insertBefore(a[--aEnd], anchor);
|
|
124
|
+
bStart++;
|
|
125
|
+
if (aStart >= aEnd - 1 || bStart >= bEnd) break;
|
|
126
|
+
} while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
|
|
91
127
|
}
|
|
92
|
-
} else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
|
|
93
|
-
const anchor = a[aStart];
|
|
94
|
-
do {
|
|
95
|
-
parentNode.insertBefore(a[--aEnd], anchor);
|
|
96
|
-
bStart++;
|
|
97
|
-
if (aStart >= aEnd - 1 || bStart >= bEnd) break;
|
|
98
|
-
} while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
|
|
99
128
|
} else {
|
|
100
129
|
if (!map) {
|
|
101
130
|
map = new Map();
|
|
@@ -113,36 +142,66 @@ function reconcileArrays(parentNode, a, b) {
|
|
|
113
142
|
sequence++;
|
|
114
143
|
}
|
|
115
144
|
if (sequence > index - bStart) {
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
145
|
+
const head = a[aStart];
|
|
146
|
+
const headTag = head[$$SLOT];
|
|
147
|
+
const node = head.parentNode === parentNode && (!headTag || headTag === marker) ? head : after;
|
|
148
|
+
while (bStart < index) {
|
|
149
|
+
const n = b[bStart++];
|
|
150
|
+
parentNode.insertBefore(n, node);
|
|
151
|
+
if (marker) n[$$SLOT] = marker;
|
|
152
|
+
}
|
|
153
|
+
} else {
|
|
154
|
+
const oldNode = a[aStart++];
|
|
155
|
+
const newNode = b[bStart++];
|
|
156
|
+
const oldTag = oldNode[$$SLOT];
|
|
157
|
+
if (oldNode.parentNode === parentNode && (!oldTag || oldTag === marker)) {
|
|
158
|
+
parentNode.replaceChild(newNode, oldNode);
|
|
159
|
+
} else {
|
|
160
|
+
parentNode.insertBefore(newNode, after);
|
|
161
|
+
}
|
|
162
|
+
if (marker) newNode[$$SLOT] = marker;
|
|
163
|
+
}
|
|
119
164
|
} else aStart++;
|
|
120
|
-
} else
|
|
165
|
+
} else {
|
|
166
|
+
const n = a[aStart++];
|
|
167
|
+
const nTag = n[$$SLOT];
|
|
168
|
+
if (n.parentNode === parentNode && (!nTag || nTag === marker)) n.remove();
|
|
169
|
+
}
|
|
121
170
|
}
|
|
122
171
|
}
|
|
123
172
|
}
|
|
124
173
|
|
|
125
|
-
const $$
|
|
174
|
+
const $$EVENT_OWNER = "_$DX_EVENT_OWNER";
|
|
126
175
|
const INNER_OWNED = {};
|
|
176
|
+
const delegatedEvents = new Set();
|
|
177
|
+
const delegatedContainers = new Map();
|
|
127
178
|
function render$1(code, element, init, options = {}) {
|
|
128
179
|
if (!element) {
|
|
129
180
|
throw new Error("The `element` passed to `render(..., element)` doesn't exist. Make sure `element` exists in the document.");
|
|
130
181
|
}
|
|
131
182
|
let disposer;
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
183
|
+
registerDelegatedRoot(element);
|
|
184
|
+
try {
|
|
185
|
+
createRoot(dispose => {
|
|
186
|
+
disposer = dispose;
|
|
187
|
+
if (element === document) {
|
|
188
|
+
const tree = code();
|
|
189
|
+
effect(() => flatten(tree), () => {});
|
|
190
|
+
} else {
|
|
191
|
+
const tree = code();
|
|
192
|
+
insert(element, () => tree, element.firstChild ? null : undefined, init, options.insertOptions);
|
|
193
|
+
}
|
|
194
|
+
}, {
|
|
195
|
+
id: options.renderId
|
|
196
|
+
});
|
|
197
|
+
} catch (err) {
|
|
198
|
+
if (disposer) disposer();
|
|
199
|
+
unregisterDelegatedRoot(element);
|
|
200
|
+
throw err;
|
|
201
|
+
}
|
|
144
202
|
return () => {
|
|
145
203
|
disposer();
|
|
204
|
+
unregisterDelegatedRoot(element);
|
|
146
205
|
element.textContent = "";
|
|
147
206
|
};
|
|
148
207
|
}
|
|
@@ -158,20 +217,66 @@ function template(html, flag) {
|
|
|
158
217
|
fn._html = flag === 2 ? html.replace(/^<[^>]+>/, "") : html;
|
|
159
218
|
return fn;
|
|
160
219
|
}
|
|
161
|
-
function delegateEvents(eventNames
|
|
162
|
-
const e = document[$$EVENTS] || (document[$$EVENTS] = new Set());
|
|
220
|
+
function delegateEvents(eventNames) {
|
|
163
221
|
for (let i = 0, l = eventNames.length; i < l; i++) {
|
|
164
222
|
const name = eventNames[i];
|
|
165
|
-
if (!
|
|
166
|
-
|
|
167
|
-
|
|
223
|
+
if (!delegatedEvents.has(name)) {
|
|
224
|
+
delegatedEvents.add(name);
|
|
225
|
+
delegatedContainers.forEach((state, container) => attachDelegatedEvent(name, container, state));
|
|
168
226
|
}
|
|
169
227
|
}
|
|
170
228
|
}
|
|
171
|
-
function
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
229
|
+
function registerDelegatedRoot(root) {
|
|
230
|
+
const state = registerDelegatedContainer(root, root);
|
|
231
|
+
if (state) state.roots = (state.roots || 0) + 1;
|
|
232
|
+
}
|
|
233
|
+
function unregisterDelegatedRoot(root) {
|
|
234
|
+
const state = delegatedContainers.get(root);
|
|
235
|
+
if (state) state.roots > 1 ? state.roots-- : delete state.roots;
|
|
236
|
+
unregisterDelegatedContainer(root, root);
|
|
237
|
+
}
|
|
238
|
+
function registerDelegatedContainer(container, owner = container) {
|
|
239
|
+
if (!container || !owner) return;
|
|
240
|
+
let state = delegatedContainers.get(container);
|
|
241
|
+
if (!state) delegatedContainers.set(container, state = {
|
|
242
|
+
owners: new Map(),
|
|
243
|
+
handlers: new Map()
|
|
244
|
+
});
|
|
245
|
+
state.owners.set(owner, (state.owners.get(owner) || 0) + 1);
|
|
246
|
+
delegatedEvents.forEach(name => attachDelegatedEvent(name, container, state));
|
|
247
|
+
return state;
|
|
248
|
+
}
|
|
249
|
+
function unregisterDelegatedContainer(container, owner = container) {
|
|
250
|
+
const state = delegatedContainers.get(container);
|
|
251
|
+
if (!state) return;
|
|
252
|
+
const count = state.owners.get(owner);
|
|
253
|
+
if (count > 1) state.owners.set(owner, count - 1);else state.owners.delete(owner);
|
|
254
|
+
if (state.owners.size) return;
|
|
255
|
+
state.handlers.forEach((handler, name) => container.removeEventListener(name, handler));
|
|
256
|
+
delegatedContainers.delete(container);
|
|
257
|
+
}
|
|
258
|
+
function attachDelegatedEvent(name, container, state) {
|
|
259
|
+
if (state.handlers.has(name)) return;
|
|
260
|
+
const handler = e => eventHandler(e, container, state);
|
|
261
|
+
state.handlers.set(name, handler);
|
|
262
|
+
container.addEventListener(name, handler);
|
|
263
|
+
}
|
|
264
|
+
function getDelegatedRoot(node) {
|
|
265
|
+
while (node) {
|
|
266
|
+
if (delegatedContainers.get(node)?.roots) return node;
|
|
267
|
+
node = node._$host || node.parentNode || node.host;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
function findOwner(target, state) {
|
|
271
|
+
let node = target;
|
|
272
|
+
let distance = 0;
|
|
273
|
+
while (node) {
|
|
274
|
+
if (state.owners.has(node)) return {
|
|
275
|
+
owner: node,
|
|
276
|
+
distance
|
|
277
|
+
};
|
|
278
|
+
distance++;
|
|
279
|
+
node = node._$host || node.parentNode || node.host;
|
|
175
280
|
}
|
|
176
281
|
}
|
|
177
282
|
function setProperty(node, name, value) {
|
|
@@ -216,7 +321,7 @@ function className(node, value, prev) {
|
|
|
216
321
|
node.classList.add(key);
|
|
217
322
|
}
|
|
218
323
|
}
|
|
219
|
-
function
|
|
324
|
+
function addEvent(node, name, handler, delegate) {
|
|
220
325
|
if (delegate) {
|
|
221
326
|
if (Array.isArray(handler)) {
|
|
222
327
|
node[`$$${name}`] = handler[0];
|
|
@@ -283,6 +388,7 @@ function ref(fn, element) {
|
|
|
283
388
|
}
|
|
284
389
|
function insert(parent, accessor, marker, initial, options) {
|
|
285
390
|
const multi = marker !== undefined;
|
|
391
|
+
const host = options && options.host;
|
|
286
392
|
if (multi && !initial) initial = [];
|
|
287
393
|
if (isHydrating(parent)) {
|
|
288
394
|
if (!multi && initial === undefined && parent) initial = [...parent.childNodes];
|
|
@@ -296,7 +402,11 @@ function insert(parent, accessor, marker, initial, options) {
|
|
|
296
402
|
}
|
|
297
403
|
if (typeof accessor !== "function") {
|
|
298
404
|
accessor = normalize(accessor, initial, multi, true);
|
|
299
|
-
if (typeof accessor !== "function")
|
|
405
|
+
if (typeof accessor !== "function") {
|
|
406
|
+
insertExpression(parent, accessor, initial, marker);
|
|
407
|
+
host && tagHost(accessor, host);
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
300
410
|
}
|
|
301
411
|
if (multi && initial.length === 0) {
|
|
302
412
|
const placeholder = document.createTextNode("");
|
|
@@ -310,6 +420,7 @@ function insert(parent, accessor, marker, initial, options) {
|
|
|
310
420
|
effect(() => normalize(value, current, multi), inner => {
|
|
311
421
|
insertExpression(parent, inner, current, marker);
|
|
312
422
|
current = inner;
|
|
423
|
+
host && tagHost(current, host);
|
|
313
424
|
}, prev !== undefined && !(options && options.schedule) ? {
|
|
314
425
|
...options,
|
|
315
426
|
schedule: true
|
|
@@ -319,6 +430,7 @@ function insert(parent, accessor, marker, initial, options) {
|
|
|
319
430
|
if (value === INNER_OWNED) return;
|
|
320
431
|
insertExpression(parent, value, current, marker);
|
|
321
432
|
current = value;
|
|
433
|
+
host && tagHost(current, host);
|
|
322
434
|
}, options);
|
|
323
435
|
}
|
|
324
436
|
function assign(node, props, skipChildren, prevProps = {}, skipRef = false) {
|
|
@@ -518,7 +630,17 @@ function runHydrationEvents() {
|
|
|
518
630
|
const [el, e] = events[0];
|
|
519
631
|
if (!completed.has(el)) return;
|
|
520
632
|
events.shift();
|
|
521
|
-
|
|
633
|
+
let match;
|
|
634
|
+
for (const [container, state] of delegatedContainers) {
|
|
635
|
+
if (!state.handlers.has(e.type)) continue;
|
|
636
|
+
const entry = findOwner(e.target, state);
|
|
637
|
+
if (entry && (!match || entry.distance < match.distance)) match = {
|
|
638
|
+
container,
|
|
639
|
+
state,
|
|
640
|
+
distance: entry.distance
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
if (match) eventHandler(e, match.container, match.state);
|
|
522
644
|
}
|
|
523
645
|
if (sharedConfig.done) {
|
|
524
646
|
sharedConfig.events = _$HY.events = null;
|
|
@@ -573,7 +695,7 @@ function assignProp(node, prop, value, prev, skipRef, nodeName) {
|
|
|
573
695
|
node.removeEventListener(name, h);
|
|
574
696
|
}
|
|
575
697
|
if (delegate || value) {
|
|
576
|
-
|
|
698
|
+
addEvent(node, name, value, delegate);
|
|
577
699
|
delegate && delegateEvents([name]);
|
|
578
700
|
}
|
|
579
701
|
} else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop]) {
|
|
@@ -585,14 +707,18 @@ function assignProp(node, prop, value, prev, skipRef, nodeName) {
|
|
|
585
707
|
}
|
|
586
708
|
return value;
|
|
587
709
|
}
|
|
588
|
-
function eventHandler(e) {
|
|
710
|
+
function eventHandler(e, container, state) {
|
|
589
711
|
if (sharedConfig.registry && sharedConfig.events) {
|
|
590
712
|
if (sharedConfig.events.find(([el, ev]) => ev === e)) return;
|
|
591
713
|
}
|
|
714
|
+
if (e[$$EVENT_OWNER]) return;
|
|
715
|
+
const owner = state && (state.owners.size === 1 && state.owners.has(container) ? container : findOwner(e.target, state)?.owner);
|
|
716
|
+
if (state && !owner) return;
|
|
717
|
+
e[$$EVENT_OWNER] = owner || true;
|
|
592
718
|
let node = e.target;
|
|
593
719
|
const key = `$$${e.type}`;
|
|
594
720
|
const oriTarget = e.target;
|
|
595
|
-
const
|
|
721
|
+
const boundary = owner || container || e.currentTarget;
|
|
596
722
|
const retarget = value => Object.defineProperty(e, "target", {
|
|
597
723
|
configurable: true,
|
|
598
724
|
value
|
|
@@ -608,29 +734,34 @@ function eventHandler(e) {
|
|
|
608
734
|
return true;
|
|
609
735
|
};
|
|
610
736
|
const walkUpTree = () => {
|
|
611
|
-
while (handleNode()
|
|
737
|
+
while (handleNode()) {
|
|
738
|
+
if (node === boundary || node.parentNode === boundary) break;
|
|
739
|
+
node = node._$host || node.parentNode || node.host;
|
|
740
|
+
}
|
|
612
741
|
};
|
|
613
742
|
Object.defineProperty(e, "currentTarget", {
|
|
614
743
|
configurable: true,
|
|
615
744
|
get() {
|
|
616
|
-
return node || document;
|
|
745
|
+
return node || boundary || document;
|
|
617
746
|
}
|
|
618
747
|
});
|
|
619
748
|
if (e.composedPath) {
|
|
620
749
|
const path = e.composedPath();
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
750
|
+
if (path.length) {
|
|
751
|
+
retarget(path[0]);
|
|
752
|
+
for (let i = 0; i < path.length; i++) {
|
|
753
|
+
node = path[i];
|
|
754
|
+
if (!handleNode()) break;
|
|
755
|
+
if (node._$host) {
|
|
756
|
+
node = node._$host;
|
|
757
|
+
walkUpTree();
|
|
758
|
+
break;
|
|
759
|
+
}
|
|
760
|
+
if (node === boundary || node.parentNode === boundary) {
|
|
761
|
+
break;
|
|
762
|
+
}
|
|
632
763
|
}
|
|
633
|
-
}
|
|
764
|
+
} else walkUpTree();
|
|
634
765
|
}
|
|
635
766
|
else walkUpTree();
|
|
636
767
|
retarget(oriTarget);
|
|
@@ -650,9 +781,14 @@ function insertExpression(parent, value, current, marker) {
|
|
|
650
781
|
} else if (value.nodeType) {
|
|
651
782
|
if (Array.isArray(current)) {
|
|
652
783
|
cleanChildren(parent, current, multi ? marker : null, value);
|
|
653
|
-
} else if (current
|
|
784
|
+
} else if (current && current.nodeType) {
|
|
785
|
+
current.parentNode === parent ? parent.replaceChild(value, current) : parent.appendChild(value);
|
|
786
|
+
} else if (current && parent.firstChild) {
|
|
787
|
+
parent.replaceChild(value, parent.firstChild);
|
|
788
|
+
} else {
|
|
654
789
|
parent.appendChild(value);
|
|
655
|
-
}
|
|
790
|
+
}
|
|
791
|
+
if (marker) value[$$SLOT] = marker;
|
|
656
792
|
} else if (Array.isArray(value)) {
|
|
657
793
|
const currentArray = current && Array.isArray(current);
|
|
658
794
|
if (value.length === 0) {
|
|
@@ -660,7 +796,7 @@ function insertExpression(parent, value, current, marker) {
|
|
|
660
796
|
} else if (currentArray) {
|
|
661
797
|
if (current.length === 0) {
|
|
662
798
|
appendNodes(parent, value, marker);
|
|
663
|
-
} else reconcileArrays(parent, current, value);
|
|
799
|
+
} else reconcileArrays(parent, current, value, marker);
|
|
664
800
|
} else {
|
|
665
801
|
current && cleanChildren(parent);
|
|
666
802
|
appendNodes(parent, value);
|
|
@@ -684,8 +820,23 @@ function normalize(value, current, multi, doNotUnwrap) {
|
|
|
684
820
|
}
|
|
685
821
|
return value;
|
|
686
822
|
}
|
|
823
|
+
function tagHost(value, host) {
|
|
824
|
+
if (Array.isArray(value)) {
|
|
825
|
+
for (let i = 0, len = value.length; i < len; i++) tagHost(value[i], host);
|
|
826
|
+
} else if (value && value.nodeType && value[$$HOST] !== host) {
|
|
827
|
+
value[$$HOST] = host;
|
|
828
|
+
Object.defineProperty(value, "_$host", {
|
|
829
|
+
get: host,
|
|
830
|
+
configurable: true
|
|
831
|
+
});
|
|
832
|
+
}
|
|
833
|
+
}
|
|
687
834
|
function appendNodes(parent, array, marker = null) {
|
|
688
|
-
for (let i = 0, len = array.length; i < len; i++)
|
|
835
|
+
for (let i = 0, len = array.length; i < len; i++) {
|
|
836
|
+
const n = array[i];
|
|
837
|
+
parent.insertBefore(n, marker);
|
|
838
|
+
if (marker) n[$$SLOT] = marker;
|
|
839
|
+
}
|
|
689
840
|
}
|
|
690
841
|
function cleanChildren(parent, current, marker, replacement) {
|
|
691
842
|
if (marker === undefined) return parent.textContent = "";
|
|
@@ -694,11 +845,13 @@ function cleanChildren(parent, current, marker, replacement) {
|
|
|
694
845
|
for (let i = current.length - 1; i >= 0; i--) {
|
|
695
846
|
const el = current[i];
|
|
696
847
|
if (replacement !== el) {
|
|
697
|
-
const
|
|
698
|
-
|
|
848
|
+
const tag = el[$$SLOT];
|
|
849
|
+
const owns = el.parentNode === parent && (!tag || tag === marker);
|
|
850
|
+
if (replacement && !inserted && !i) owns ? parent.replaceChild(replacement, el) : parent.insertBefore(replacement, marker);else if (owns) el.remove();
|
|
699
851
|
} else inserted = true;
|
|
700
852
|
}
|
|
701
853
|
} else if (replacement) parent.insertBefore(replacement, marker);
|
|
854
|
+
if (replacement && marker) replacement[$$SLOT] = marker;
|
|
702
855
|
}
|
|
703
856
|
function gatherHydratable(element, root) {
|
|
704
857
|
const templates = element.querySelectorAll(`*[_hk]`);
|
|
@@ -762,12 +915,20 @@ function Portal(props) {
|
|
|
762
915
|
const treeMarker = document.createTextNode(""),
|
|
763
916
|
startMarker = document.createTextNode(""),
|
|
764
917
|
endMarker = document.createTextNode(""),
|
|
765
|
-
mount = () =>
|
|
766
|
-
|
|
767
|
-
createRenderEffect(
|
|
918
|
+
mount = () => props.mount || document.body,
|
|
919
|
+
content = createMemo(() => [startMarker, props.children]);
|
|
920
|
+
createRenderEffect(
|
|
921
|
+
() => [mount(), content(), getOwner()], ([, c, owner]) => {
|
|
922
|
+
const m = untrack(mount);
|
|
768
923
|
m.appendChild(endMarker);
|
|
769
|
-
|
|
924
|
+
const dispose = runWithOwner(owner, () => createRoot(d => {
|
|
925
|
+
insert(m, c, endMarker, undefined, {
|
|
926
|
+
host: () => treeMarker.parentNode
|
|
927
|
+
});
|
|
928
|
+
return d;
|
|
929
|
+
}));
|
|
770
930
|
return () => {
|
|
931
|
+
dispose();
|
|
771
932
|
let c = startMarker;
|
|
772
933
|
while (c && c !== endMarker) {
|
|
773
934
|
const n = c.nextSibling;
|
|
@@ -775,6 +936,15 @@ function Portal(props) {
|
|
|
775
936
|
c = n;
|
|
776
937
|
}
|
|
777
938
|
};
|
|
939
|
+
}, {
|
|
940
|
+
schedule: true
|
|
941
|
+
});
|
|
942
|
+
createEffect(mount, () => {
|
|
943
|
+
const m = untrack(mount);
|
|
944
|
+
const ownerRoot = getDelegatedRoot(treeMarker);
|
|
945
|
+
if (!ownerRoot || ownerRoot.contains(m)) return;
|
|
946
|
+
registerDelegatedContainer(m, ownerRoot);
|
|
947
|
+
return () => unregisterDelegatedContainer(m, ownerRoot);
|
|
778
948
|
});
|
|
779
949
|
return treeMarker;
|
|
780
950
|
}
|
|
@@ -808,22 +978,5 @@ function createElement(tagName, is = undefined) {
|
|
|
808
978
|
is
|
|
809
979
|
});
|
|
810
980
|
}
|
|
811
|
-
function createElementProxy(el, marker) {
|
|
812
|
-
return new Proxy(el, {
|
|
813
|
-
get(target, prop) {
|
|
814
|
-
if (prop === "appendChild" || prop === "insertBefore") {
|
|
815
|
-
return (...args) => {
|
|
816
|
-
Object.defineProperty(args[0], "_$host", {
|
|
817
|
-
get: () => marker.parentNode,
|
|
818
|
-
configurable: true
|
|
819
|
-
});
|
|
820
|
-
target[prop](...args);
|
|
821
|
-
};
|
|
822
|
-
}
|
|
823
|
-
const value = Reflect.get(target, prop);
|
|
824
|
-
return typeof value === "function" ? value.bind(target) : value;
|
|
825
|
-
}
|
|
826
|
-
});
|
|
827
|
-
}
|
|
828
981
|
|
|
829
|
-
export { voidFn as Assets, ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, voidFn as HydrationScript, MathMLElements, Namespaces, Portal, RawTextElements, RequestContext, SVGElements, VoidElements,
|
|
982
|
+
export { voidFn as Assets, ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, voidFn as HydrationScript, MathMLElements, Namespaces, Portal, RawTextElements, RequestContext, SVGElements, VoidElements, 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, isDev, isServer, memo, mergeProps, ref, registerDelegatedContainer, registerDelegatedRoot, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrStyle, style, template, unregisterDelegatedContainer, unregisterDelegatedRoot, voidFn as useAssets };
|
package/dist/server.cjs
CHANGED
|
@@ -4,6 +4,34 @@ var solidJs = require('solid-js');
|
|
|
4
4
|
var seroval = require('seroval');
|
|
5
5
|
var web = require('seroval-plugins/web');
|
|
6
6
|
|
|
7
|
+
const DOMWithState = {
|
|
8
|
+
INPUT: {
|
|
9
|
+
value: 1,
|
|
10
|
+
defaultValue: 2,
|
|
11
|
+
checked: 1,
|
|
12
|
+
defaultChecked: 2
|
|
13
|
+
},
|
|
14
|
+
SELECT: {
|
|
15
|
+
value: 1
|
|
16
|
+
},
|
|
17
|
+
OPTION: {
|
|
18
|
+
value: 1,
|
|
19
|
+
selected: 1,
|
|
20
|
+
defaultSelected: 2
|
|
21
|
+
},
|
|
22
|
+
TEXTAREA: {
|
|
23
|
+
value: 1,
|
|
24
|
+
defaultValue: 2
|
|
25
|
+
},
|
|
26
|
+
VIDEO: {
|
|
27
|
+
muted: 1,
|
|
28
|
+
defaultMuted: 2
|
|
29
|
+
},
|
|
30
|
+
AUDIO: {
|
|
31
|
+
muted: 1,
|
|
32
|
+
defaultMuted: 2
|
|
33
|
+
}
|
|
34
|
+
};
|
|
7
35
|
const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
|
|
8
36
|
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
37
|
const SVGElements = /*#__PURE__*/new Set([
|
|
@@ -952,6 +980,9 @@ function getAssets() {
|
|
|
952
980
|
for (let i = 0, len = assets.length; i < len; i++) out += assets[i]();
|
|
953
981
|
return out;
|
|
954
982
|
}
|
|
983
|
+
function Assets(props) {
|
|
984
|
+
useAssets(() => props.children);
|
|
985
|
+
}
|
|
955
986
|
function generateHydrationScript({
|
|
956
987
|
eventNames = ["click", "input"],
|
|
957
988
|
nonce
|
|
@@ -1228,8 +1259,10 @@ Object.defineProperty(exports, "untrack", {
|
|
|
1228
1259
|
enumerable: true,
|
|
1229
1260
|
get: function () { return solidJs.untrack; }
|
|
1230
1261
|
});
|
|
1262
|
+
exports.Assets = Assets;
|
|
1231
1263
|
exports.ChildProperties = ChildProperties;
|
|
1232
1264
|
exports.DOMElements = DOMElements;
|
|
1265
|
+
exports.DOMWithState = DOMWithState;
|
|
1233
1266
|
exports.DelegatedEvents = DelegatedEvents;
|
|
1234
1267
|
exports.Dynamic = Dynamic;
|
|
1235
1268
|
exports.HydrationScript = HydrationScript;
|
|
@@ -1240,7 +1273,7 @@ exports.RawTextElements = RawTextElements;
|
|
|
1240
1273
|
exports.RequestContext = RequestContext;
|
|
1241
1274
|
exports.SVGElements = SVGElements;
|
|
1242
1275
|
exports.VoidElements = VoidElements;
|
|
1243
|
-
exports.
|
|
1276
|
+
exports.addEvent = notSup;
|
|
1244
1277
|
exports.applyRef = applyRef;
|
|
1245
1278
|
exports.assign = notSup;
|
|
1246
1279
|
exports.className = notSup;
|
|
@@ -1251,6 +1284,7 @@ exports.effect = effect;
|
|
|
1251
1284
|
exports.escape = escape;
|
|
1252
1285
|
exports.generateHydrationScript = generateHydrationScript;
|
|
1253
1286
|
exports.getAssets = getAssets;
|
|
1287
|
+
exports.getDelegatedRoot = notSup;
|
|
1254
1288
|
exports.getHydrationKey = getHydrationKey;
|
|
1255
1289
|
exports.getNextElement = notSup;
|
|
1256
1290
|
exports.getNextMarker = notSup;
|
|
@@ -1262,6 +1296,9 @@ exports.isDev = isDev;
|
|
|
1262
1296
|
exports.isServer = isServer;
|
|
1263
1297
|
exports.memo = memo;
|
|
1264
1298
|
exports.mergeProps = mergeProps;
|
|
1299
|
+
exports.ref = notSup;
|
|
1300
|
+
exports.registerDelegatedContainer = notSup;
|
|
1301
|
+
exports.registerDelegatedRoot = notSup;
|
|
1265
1302
|
exports.render = notSup;
|
|
1266
1303
|
exports.renderToStream = renderToStream;
|
|
1267
1304
|
exports.renderToString = renderToString;
|
|
@@ -1270,6 +1307,7 @@ exports.runHydrationEvents = notSup;
|
|
|
1270
1307
|
exports.setAttribute = notSup;
|
|
1271
1308
|
exports.setAttributeNS = notSup;
|
|
1272
1309
|
exports.setProperty = notSup;
|
|
1310
|
+
exports.setStyleProperty = notSup;
|
|
1273
1311
|
exports.spread = notSup;
|
|
1274
1312
|
exports.ssr = ssr;
|
|
1275
1313
|
exports.ssrAttribute = ssrAttribute;
|
|
@@ -1281,4 +1319,6 @@ exports.ssrStyle = ssrStyle;
|
|
|
1281
1319
|
exports.ssrStyleProperty = ssrStyleProperty;
|
|
1282
1320
|
exports.style = notSup;
|
|
1283
1321
|
exports.template = notSup;
|
|
1322
|
+
exports.unregisterDelegatedContainer = notSup;
|
|
1323
|
+
exports.unregisterDelegatedRoot = notSup;
|
|
1284
1324
|
exports.useAssets = useAssets;
|
package/dist/server.js
CHANGED
|
@@ -3,6 +3,34 @@ export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, S
|
|
|
3
3
|
import { Serializer, Feature, getCrossReferenceHeader } from 'seroval';
|
|
4
4
|
import { AbortSignalPlugin, CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin } from 'seroval-plugins/web';
|
|
5
5
|
|
|
6
|
+
const DOMWithState = {
|
|
7
|
+
INPUT: {
|
|
8
|
+
value: 1,
|
|
9
|
+
defaultValue: 2,
|
|
10
|
+
checked: 1,
|
|
11
|
+
defaultChecked: 2
|
|
12
|
+
},
|
|
13
|
+
SELECT: {
|
|
14
|
+
value: 1
|
|
15
|
+
},
|
|
16
|
+
OPTION: {
|
|
17
|
+
value: 1,
|
|
18
|
+
selected: 1,
|
|
19
|
+
defaultSelected: 2
|
|
20
|
+
},
|
|
21
|
+
TEXTAREA: {
|
|
22
|
+
value: 1,
|
|
23
|
+
defaultValue: 2
|
|
24
|
+
},
|
|
25
|
+
VIDEO: {
|
|
26
|
+
muted: 1,
|
|
27
|
+
defaultMuted: 2
|
|
28
|
+
},
|
|
29
|
+
AUDIO: {
|
|
30
|
+
muted: 1,
|
|
31
|
+
defaultMuted: 2
|
|
32
|
+
}
|
|
33
|
+
};
|
|
6
34
|
const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
|
|
7
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"]);
|
|
8
36
|
const SVGElements = /*#__PURE__*/new Set([
|
|
@@ -951,6 +979,9 @@ function getAssets() {
|
|
|
951
979
|
for (let i = 0, len = assets.length; i < len; i++) out += assets[i]();
|
|
952
980
|
return out;
|
|
953
981
|
}
|
|
982
|
+
function Assets(props) {
|
|
983
|
+
useAssets(() => props.children);
|
|
984
|
+
}
|
|
954
985
|
function generateHydrationScript({
|
|
955
986
|
eventNames = ["click", "input"],
|
|
956
987
|
nonce
|
|
@@ -1175,4 +1206,4 @@ function Portal(props) {
|
|
|
1175
1206
|
throw new Error("Portal is not supported on the server");
|
|
1176
1207
|
}
|
|
1177
1208
|
|
|
1178
|
-
export { ChildProperties, DOMElements, DelegatedEvents, Dynamic, HydrationScript, MathMLElements, Namespaces, Portal, RawTextElements, RequestContext, SVGElements, VoidElements, notSup as
|
|
1209
|
+
export { Assets, ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HydrationScript, MathMLElements, Namespaces, Portal, RawTextElements, RequestContext, SVGElements, VoidElements, notSup as addEvent, applyRef, notSup as assign, notSup as className, notSup as delegateEvents, dynamic, notSup as dynamicProperty, effect, escape, generateHydrationScript, getAssets, notSup as getDelegatedRoot, getHydrationKey, notSup as getNextElement, notSup as getNextMarker, notSup as getNextMatch, getRequestEvent, notSup as hydrate, notSup as insert, isDev, isServer, memo, mergeProps, notSup as ref, notSup as registerDelegatedContainer, notSup as registerDelegatedRoot, notSup as render, renderToStream, renderToString, renderToStringAsync, notSup as runHydrationEvents, notSup as setAttribute, notSup as setAttributeNS, notSup as setProperty, notSup as setStyleProperty, notSup as spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrGroup, ssrHydrationKey, ssrStyle, ssrStyleProperty, notSup as style, notSup as template, notSup as unregisterDelegatedContainer, notSup as unregisterDelegatedRoot, useAssets };
|