@solidjs/web 2.0.0-experimental.14 → 2.0.0-experimental.16

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 CHANGED
@@ -19,6 +19,9 @@ const DOMElements = /*#__PURE__*/new Set(["html", "base", "head", "link", "meta"
19
19
  "webview",
20
20
  "isindex", "listing", "multicol", "nextid", "noindex", "search"]);
21
21
 
22
+ const effect = (fn, effectFn, initial) => solidJs.createRenderEffect(fn, effectFn, initial, {
23
+ transparent: true
24
+ });
22
25
  const memo = fn => solidJs.createMemo(() => fn());
23
26
 
24
27
  function reconcileArrays(parentNode, a, b) {
@@ -97,13 +100,15 @@ function render(code, element, init, options = {}) {
97
100
  }
98
101
  function template(html, isImportNode, isSVG, isMathML) {
99
102
  let node;
100
- const create = () => {
101
- if (isHydrating()) throw new Error("Failed attempt to create new DOM elements during hydration. Check that the libraries you are using support hydration.");
103
+ const create = bypassGuard => {
104
+ if (isHydrating() && !bypassGuard) throw new Error("Failed attempt to create new DOM elements during hydration. Check that the libraries you are using support hydration.");
102
105
  const t = isMathML ? document.createElementNS("http://www.w3.org/1998/Math/MathML", "template") : document.createElement("template");
103
106
  t.innerHTML = html;
104
107
  return isSVG ? t.content.firstChild.firstChild : isMathML ? t.firstChild : t.content.firstChild;
105
108
  };
106
- return isImportNode ? () => solidJs.untrack(() => document.importNode(node || (node = create()), true)) : () => (node || (node = create())).cloneNode(true);
109
+ const fn = isImportNode ? bypassGuard => solidJs.untrack(() => document.importNode(node || (node = create(bypassGuard)), true)) : bypassGuard => (node || (node = create(bypassGuard))).cloneNode(true);
110
+ fn._html = html;
111
+ return fn;
107
112
  }
108
113
  function delegateEvents(eventNames, document = window.document) {
109
114
  const e = document[$$EVENTS] || (document[$$EVENTS] = new Set());
@@ -176,7 +181,7 @@ function addEventListener(node, name, handler, delegate) {
176
181
  }
177
182
  function style(node, value, prev) {
178
183
  if (!value) {
179
- prev ? setAttribute(node, "style") : value;
184
+ if (prev) setAttribute(node, "style");
180
185
  return;
181
186
  }
182
187
  const nodeStyle = node.style;
@@ -198,13 +203,16 @@ function setStyleProperty(node, name, value) {
198
203
  function spread(node, props = {}, isSVG, skipChildren) {
199
204
  const prevProps = {};
200
205
  if (!skipChildren) {
201
- solidJs.createRenderEffect(() => normalize(props.children, prevProps.children), value => {
206
+ effect(() => normalize(props.children, prevProps.children), value => {
202
207
  insertExpression(node, value, prevProps.children);
203
208
  prevProps.children = value;
204
209
  });
205
210
  }
206
- solidJs.createRenderEffect(() => typeof props.ref === "function" && use(props.ref, node), () => {});
207
- solidJs.createRenderEffect(() => {
211
+ effect(() => {
212
+ const r = props.ref;
213
+ (typeof r === "function" || Array.isArray(r)) && ref(() => r, node);
214
+ }, () => {});
215
+ effect(() => {
208
216
  const newProps = {};
209
217
  for (const prop in props) {
210
218
  if (prop === "children" || prop === "ref") continue;
@@ -224,17 +232,28 @@ function dynamicProperty(props, key) {
224
232
  });
225
233
  return props;
226
234
  }
227
- function use(fn, element, arg) {
228
- solidJs.untrack(() => fn(element, arg));
235
+ function applyRef(r, element) {
236
+ Array.isArray(r) ? r.flat(Infinity).forEach(f => f && f(element)) : r(element);
237
+ }
238
+ function ref(fn, element) {
239
+ const resolved = solidJs.untrack(fn);
240
+ solidJs.runWithOwner(null, () => applyRef(resolved, element));
229
241
  }
230
242
  function insert(parent, accessor, marker, initial) {
231
243
  const multi = marker !== undefined;
232
244
  if (multi && !initial) initial = [];
245
+ if (isHydrating(parent) && Array.isArray(initial)) {
246
+ let j = 0;
247
+ for (let i = 0; i < initial.length; i++) {
248
+ if (initial[i].nodeType === 8 && initial[i].nodeValue === "!$") initial[i].remove();else initial[j++] = initial[i];
249
+ }
250
+ initial.length = j;
251
+ }
233
252
  if (typeof accessor !== "function") {
234
253
  accessor = normalize(accessor, initial, multi, true);
235
254
  if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
236
255
  }
237
- solidJs.createRenderEffect(prev => normalize(accessor, prev, multi), (value, current) => insertExpression(parent, value, current, marker), initial);
256
+ effect(prev => normalize(accessor, prev, multi), (value, current) => insertExpression(parent, value, current, marker), initial);
238
257
  }
239
258
  function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = false) {
240
259
  props || (props = {});
@@ -256,13 +275,39 @@ function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = fals
256
275
  function hydrate$1(code, element, options = {}) {
257
276
  if (globalThis._$HY.done) return render(code, element, [...element.childNodes], options);
258
277
  options.renderId ||= "";
278
+ if (!globalThis._$HY.modules) globalThis._$HY.modules = {};
279
+ if (!globalThis._$HY.loading) globalThis._$HY.loading = {};
259
280
  solidJs.sharedConfig.completed = globalThis._$HY.completed;
260
281
  solidJs.sharedConfig.events = globalThis._$HY.events;
261
282
  solidJs.sharedConfig.load = id => globalThis._$HY.r[id];
262
283
  solidJs.sharedConfig.has = id => id in globalThis._$HY.r;
263
284
  solidJs.sharedConfig.gather = root => gatherHydratable(element, root);
285
+ solidJs.sharedConfig.cleanupFragment = id => {
286
+ const tpl = document.getElementById("pl-" + id);
287
+ if (tpl) {
288
+ let node = tpl.nextSibling;
289
+ while (node) {
290
+ const next = node.nextSibling;
291
+ if (node.nodeType === 8 && node.nodeValue === "pl-" + id) {
292
+ node.remove();
293
+ break;
294
+ }
295
+ node.remove();
296
+ node = next;
297
+ }
298
+ tpl.remove();
299
+ }
300
+ };
264
301
  solidJs.sharedConfig.registry = new Map();
265
302
  solidJs.sharedConfig.hydrating = true;
303
+ {
304
+ solidJs.sharedConfig.verifyHydration = () => {
305
+ if (solidJs.sharedConfig.registry && solidJs.sharedConfig.registry.size) {
306
+ const orphaned = [...solidJs.sharedConfig.registry.values()];
307
+ console.warn(`Hydration completed with ${orphaned.length} unclaimed server-rendered node(s):\n` + orphaned.map(node => ` ${node.outerHTML.slice(0, 100)}`).join("\n"));
308
+ }
309
+ };
310
+ }
266
311
  try {
267
312
  gatherHydratable(element, options.renderId);
268
313
  return render(code, element, [...element.childNodes], options);
@@ -275,11 +320,16 @@ function getNextElement(template) {
275
320
  key,
276
321
  hydrating = isHydrating();
277
322
  if (!hydrating || !(node = solidJs.sharedConfig.registry.get(key = getHydrationKey()))) {
278
- if (hydrating) {
279
- solidJs.sharedConfig.done = true;
280
- throw new Error(`Hydration Mismatch. Unable to find DOM nodes for hydration key: ${key}\n${template ? template().outerHTML : ""}`);
323
+ if (!template) {
324
+ throw new Error(`Hydration Mismatch. Unable to find DOM nodes for hydration key: ${key}`);
325
+ }
326
+ return template(true);
327
+ }
328
+ if (template && template._html) {
329
+ const expected = template._html.match(/^<(\w+)/)?.[1];
330
+ if (expected && node.localName !== expected) {
331
+ console.warn(`Hydration tag mismatch for key "${key}": expected <${expected}> but found`, node);
281
332
  }
282
- return template();
283
333
  }
284
334
  if (solidJs.sharedConfig.completed) solidJs.sharedConfig.completed.add(node);
285
335
  solidJs.sharedConfig.registry.delete(key);
@@ -308,6 +358,49 @@ function getNextMarker(start) {
308
358
  }
309
359
  return [end, current];
310
360
  }
361
+ function getFirstChild(node, expectedTag) {
362
+ const child = node.firstChild;
363
+ if (isHydrating() && expectedTag && child?.localName !== expectedTag) {
364
+ const isMissing = !child || child.nodeType !== 1;
365
+ console.warn("Hydration structure mismatch: expected <" + expectedTag + "> as first child of", node, "\n " + describeSiblings(node, child, expectedTag, isMissing));
366
+ }
367
+ return child;
368
+ }
369
+ function getNextSibling(node, expectedTag) {
370
+ const sibling = node.nextSibling;
371
+ if (isHydrating() && expectedTag && sibling?.localName !== expectedTag) {
372
+ const parent = node.parentElement;
373
+ const isMissing = !sibling || sibling.nodeType !== 1;
374
+ console.warn("Hydration structure mismatch: expected <" + expectedTag + "> after", node, "in", parent, "\n " + describeSiblings(parent, sibling, expectedTag, isMissing));
375
+ }
376
+ return sibling;
377
+ }
378
+ function describeSiblings(parent, mismatchChild, expectedTag, isMissing) {
379
+ const children = [];
380
+ let child = parent.firstChild;
381
+ while (child) {
382
+ if (child.nodeType === 1) children.push(child);
383
+ child = child.nextSibling;
384
+ }
385
+ const pTag = parent.localName;
386
+ if (isMissing) {
387
+ const tags = children.map(c => `<${c.localName}>`).join("");
388
+ return `<${pTag}>${tags}<${expectedTag} \u2190 missing></${pTag}>`;
389
+ }
390
+ const idx = children.indexOf(mismatchChild);
391
+ let start = 0,
392
+ end = children.length;
393
+ let prefix = "",
394
+ suffix = "";
395
+ if (children.length > 6) {
396
+ start = Math.max(0, idx - 2);
397
+ end = Math.min(children.length, idx + 3);
398
+ if (start > 0) prefix = "...";
399
+ if (end < children.length) suffix = "...";
400
+ }
401
+ const tags = children.slice(start, end).map(c => c === mismatchChild ? `<${c.localName} \u2190 expected ${expectedTag}>` : `<${c.localName}>`).join("");
402
+ return `<${pTag}>${prefix}${tags}${suffix}</${pTag}>`;
403
+ }
311
404
  function runHydrationEvents() {
312
405
  if (solidJs.sharedConfig.events && !solidJs.sharedConfig.events.queued) {
313
406
  queueMicrotask(() => {
@@ -332,7 +425,7 @@ function runHydrationEvents() {
332
425
  }
333
426
  }
334
427
  function isHydrating(node) {
335
- return solidJs.sharedConfig.hydrating && !solidJs.sharedConfig.done && (!node || node.isConnected);
428
+ return solidJs.sharedConfig.hydrating && (!node || node.isConnected);
336
429
  }
337
430
  function toggleClassKey(node, key, value) {
338
431
  const classNames = key.trim().split(/\s+/);
@@ -358,7 +451,7 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
358
451
  if (prop === "class") return className(node, value, isSVG, prev), value;
359
452
  if (value === prev) return prev;
360
453
  if (prop === "ref") {
361
- if (!skipRef) value(node);
454
+ if (!skipRef && value) ref(() => value, node);
362
455
  } else if (prop.slice(0, 3) === "on:") {
363
456
  const e = prop.slice(3);
364
457
  prev && node.removeEventListener(e, prev, typeof prev !== "function" && prev);
@@ -414,7 +507,6 @@ function eventHandler(e) {
414
507
  return node || document;
415
508
  }
416
509
  });
417
- if (solidJs.sharedConfig.registry && !solidJs.sharedConfig.done) solidJs.sharedConfig.done = _$HY.done = true;
418
510
  if (e.composedPath) {
419
511
  const path = e.composedPath();
420
512
  retarget(path[0]);
@@ -641,10 +733,6 @@ Object.defineProperty(exports, "createComponent", {
641
733
  enumerable: true,
642
734
  get: function () { return solidJs.createComponent; }
643
735
  });
644
- Object.defineProperty(exports, "effect", {
645
- enumerable: true,
646
- get: function () { return solidJs.createRenderEffect; }
647
- });
648
736
  Object.defineProperty(exports, "getOwner", {
649
737
  enumerable: true,
650
738
  get: function () { return solidJs.getOwner; }
@@ -671,25 +759,30 @@ exports.RequestContext = RequestContext;
671
759
  exports.SVGElements = SVGElements;
672
760
  exports.SVGNamespace = SVGNamespace;
673
761
  exports.addEventListener = addEventListener;
762
+ exports.applyRef = applyRef;
674
763
  exports.assign = assign;
675
764
  exports.className = className;
676
765
  exports.clearDelegatedEvents = clearDelegatedEvents;
677
766
  exports.createDynamic = createDynamic;
678
767
  exports.delegateEvents = delegateEvents;
679
768
  exports.dynamicProperty = dynamicProperty;
769
+ exports.effect = effect;
680
770
  exports.escape = escape;
681
771
  exports.generateHydrationScript = voidFn;
682
772
  exports.getAssets = voidFn;
773
+ exports.getFirstChild = getFirstChild;
683
774
  exports.getHydrationKey = getHydrationKey;
684
775
  exports.getNextElement = getNextElement;
685
776
  exports.getNextMarker = getNextMarker;
686
777
  exports.getNextMatch = getNextMatch;
778
+ exports.getNextSibling = getNextSibling;
687
779
  exports.getRequestEvent = voidFn;
688
780
  exports.hydrate = hydrate;
689
781
  exports.insert = insert;
690
782
  exports.isDev = isDev;
691
783
  exports.isServer = isServer;
692
784
  exports.memo = memo;
785
+ exports.ref = ref;
693
786
  exports.render = render;
694
787
  exports.renderToStream = renderToStream;
695
788
  exports.renderToString = renderToString;
@@ -709,5 +802,4 @@ exports.ssrHydrationKey = ssrHydrationKey;
709
802
  exports.ssrStyle = ssrStyle;
710
803
  exports.style = style;
711
804
  exports.template = template;
712
- exports.use = use;
713
805
  exports.useAssets = voidFn;
package/dist/dev.js CHANGED
@@ -1,5 +1,5 @@
1
- import { createMemo, createRoot, flatten, untrack, createRenderEffect, sharedConfig, enableHydration, $DEVCOMP, omit } from 'solid-js';
2
- export { Errored, For, Loading, Match, Show, Switch, createComponent, createRenderEffect as effect, getOwner, merge as mergeProps, untrack } from 'solid-js';
1
+ import { createRenderEffect, createMemo, sharedConfig, untrack, runWithOwner, createRoot, flatten, omit, $DEVCOMP, enableHydration } from 'solid-js';
2
+ export { Errored, For, Loading, Match, Show, Switch, createComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
3
3
 
4
4
  const Properties = /*#__PURE__*/new Set([
5
5
  "value", "checked", "selected", "muted"]);
@@ -18,6 +18,9 @@ const DOMElements = /*#__PURE__*/new Set(["html", "base", "head", "link", "meta"
18
18
  "webview",
19
19
  "isindex", "listing", "multicol", "nextid", "noindex", "search"]);
20
20
 
21
+ const effect = (fn, effectFn, initial) => createRenderEffect(fn, effectFn, initial, {
22
+ transparent: true
23
+ });
21
24
  const memo = fn => createMemo(() => fn());
22
25
 
23
26
  function reconcileArrays(parentNode, a, b) {
@@ -96,13 +99,15 @@ function render(code, element, init, options = {}) {
96
99
  }
97
100
  function template(html, isImportNode, isSVG, isMathML) {
98
101
  let node;
99
- const create = () => {
100
- if (isHydrating()) throw new Error("Failed attempt to create new DOM elements during hydration. Check that the libraries you are using support hydration.");
102
+ const create = bypassGuard => {
103
+ if (isHydrating() && !bypassGuard) throw new Error("Failed attempt to create new DOM elements during hydration. Check that the libraries you are using support hydration.");
101
104
  const t = isMathML ? document.createElementNS("http://www.w3.org/1998/Math/MathML", "template") : document.createElement("template");
102
105
  t.innerHTML = html;
103
106
  return isSVG ? t.content.firstChild.firstChild : isMathML ? t.firstChild : t.content.firstChild;
104
107
  };
105
- return isImportNode ? () => untrack(() => document.importNode(node || (node = create()), true)) : () => (node || (node = create())).cloneNode(true);
108
+ const fn = isImportNode ? bypassGuard => untrack(() => document.importNode(node || (node = create(bypassGuard)), true)) : bypassGuard => (node || (node = create(bypassGuard))).cloneNode(true);
109
+ fn._html = html;
110
+ return fn;
106
111
  }
107
112
  function delegateEvents(eventNames, document = window.document) {
108
113
  const e = document[$$EVENTS] || (document[$$EVENTS] = new Set());
@@ -175,7 +180,7 @@ function addEventListener(node, name, handler, delegate) {
175
180
  }
176
181
  function style(node, value, prev) {
177
182
  if (!value) {
178
- prev ? setAttribute(node, "style") : value;
183
+ if (prev) setAttribute(node, "style");
179
184
  return;
180
185
  }
181
186
  const nodeStyle = node.style;
@@ -197,13 +202,16 @@ function setStyleProperty(node, name, value) {
197
202
  function spread(node, props = {}, isSVG, skipChildren) {
198
203
  const prevProps = {};
199
204
  if (!skipChildren) {
200
- createRenderEffect(() => normalize(props.children, prevProps.children), value => {
205
+ effect(() => normalize(props.children, prevProps.children), value => {
201
206
  insertExpression(node, value, prevProps.children);
202
207
  prevProps.children = value;
203
208
  });
204
209
  }
205
- createRenderEffect(() => typeof props.ref === "function" && use(props.ref, node), () => {});
206
- createRenderEffect(() => {
210
+ effect(() => {
211
+ const r = props.ref;
212
+ (typeof r === "function" || Array.isArray(r)) && ref(() => r, node);
213
+ }, () => {});
214
+ effect(() => {
207
215
  const newProps = {};
208
216
  for (const prop in props) {
209
217
  if (prop === "children" || prop === "ref") continue;
@@ -223,17 +231,28 @@ function dynamicProperty(props, key) {
223
231
  });
224
232
  return props;
225
233
  }
226
- function use(fn, element, arg) {
227
- untrack(() => fn(element, arg));
234
+ function applyRef(r, element) {
235
+ Array.isArray(r) ? r.flat(Infinity).forEach(f => f && f(element)) : r(element);
236
+ }
237
+ function ref(fn, element) {
238
+ const resolved = untrack(fn);
239
+ runWithOwner(null, () => applyRef(resolved, element));
228
240
  }
229
241
  function insert(parent, accessor, marker, initial) {
230
242
  const multi = marker !== undefined;
231
243
  if (multi && !initial) initial = [];
244
+ if (isHydrating(parent) && Array.isArray(initial)) {
245
+ let j = 0;
246
+ for (let i = 0; i < initial.length; i++) {
247
+ if (initial[i].nodeType === 8 && initial[i].nodeValue === "!$") initial[i].remove();else initial[j++] = initial[i];
248
+ }
249
+ initial.length = j;
250
+ }
232
251
  if (typeof accessor !== "function") {
233
252
  accessor = normalize(accessor, initial, multi, true);
234
253
  if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
235
254
  }
236
- createRenderEffect(prev => normalize(accessor, prev, multi), (value, current) => insertExpression(parent, value, current, marker), initial);
255
+ effect(prev => normalize(accessor, prev, multi), (value, current) => insertExpression(parent, value, current, marker), initial);
237
256
  }
238
257
  function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = false) {
239
258
  props || (props = {});
@@ -255,13 +274,39 @@ function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = fals
255
274
  function hydrate$1(code, element, options = {}) {
256
275
  if (globalThis._$HY.done) return render(code, element, [...element.childNodes], options);
257
276
  options.renderId ||= "";
277
+ if (!globalThis._$HY.modules) globalThis._$HY.modules = {};
278
+ if (!globalThis._$HY.loading) globalThis._$HY.loading = {};
258
279
  sharedConfig.completed = globalThis._$HY.completed;
259
280
  sharedConfig.events = globalThis._$HY.events;
260
281
  sharedConfig.load = id => globalThis._$HY.r[id];
261
282
  sharedConfig.has = id => id in globalThis._$HY.r;
262
283
  sharedConfig.gather = root => gatherHydratable(element, root);
284
+ sharedConfig.cleanupFragment = id => {
285
+ const tpl = document.getElementById("pl-" + id);
286
+ if (tpl) {
287
+ let node = tpl.nextSibling;
288
+ while (node) {
289
+ const next = node.nextSibling;
290
+ if (node.nodeType === 8 && node.nodeValue === "pl-" + id) {
291
+ node.remove();
292
+ break;
293
+ }
294
+ node.remove();
295
+ node = next;
296
+ }
297
+ tpl.remove();
298
+ }
299
+ };
263
300
  sharedConfig.registry = new Map();
264
301
  sharedConfig.hydrating = true;
302
+ {
303
+ sharedConfig.verifyHydration = () => {
304
+ if (sharedConfig.registry && sharedConfig.registry.size) {
305
+ const orphaned = [...sharedConfig.registry.values()];
306
+ console.warn(`Hydration completed with ${orphaned.length} unclaimed server-rendered node(s):\n` + orphaned.map(node => ` ${node.outerHTML.slice(0, 100)}`).join("\n"));
307
+ }
308
+ };
309
+ }
265
310
  try {
266
311
  gatherHydratable(element, options.renderId);
267
312
  return render(code, element, [...element.childNodes], options);
@@ -274,11 +319,16 @@ function getNextElement(template) {
274
319
  key,
275
320
  hydrating = isHydrating();
276
321
  if (!hydrating || !(node = sharedConfig.registry.get(key = getHydrationKey()))) {
277
- if (hydrating) {
278
- sharedConfig.done = true;
279
- throw new Error(`Hydration Mismatch. Unable to find DOM nodes for hydration key: ${key}\n${template ? template().outerHTML : ""}`);
322
+ if (!template) {
323
+ throw new Error(`Hydration Mismatch. Unable to find DOM nodes for hydration key: ${key}`);
324
+ }
325
+ return template(true);
326
+ }
327
+ if (template && template._html) {
328
+ const expected = template._html.match(/^<(\w+)/)?.[1];
329
+ if (expected && node.localName !== expected) {
330
+ console.warn(`Hydration tag mismatch for key "${key}": expected <${expected}> but found`, node);
280
331
  }
281
- return template();
282
332
  }
283
333
  if (sharedConfig.completed) sharedConfig.completed.add(node);
284
334
  sharedConfig.registry.delete(key);
@@ -307,6 +357,49 @@ function getNextMarker(start) {
307
357
  }
308
358
  return [end, current];
309
359
  }
360
+ function getFirstChild(node, expectedTag) {
361
+ const child = node.firstChild;
362
+ if (isHydrating() && expectedTag && child?.localName !== expectedTag) {
363
+ const isMissing = !child || child.nodeType !== 1;
364
+ console.warn("Hydration structure mismatch: expected <" + expectedTag + "> as first child of", node, "\n " + describeSiblings(node, child, expectedTag, isMissing));
365
+ }
366
+ return child;
367
+ }
368
+ function getNextSibling(node, expectedTag) {
369
+ const sibling = node.nextSibling;
370
+ if (isHydrating() && expectedTag && sibling?.localName !== expectedTag) {
371
+ const parent = node.parentElement;
372
+ const isMissing = !sibling || sibling.nodeType !== 1;
373
+ console.warn("Hydration structure mismatch: expected <" + expectedTag + "> after", node, "in", parent, "\n " + describeSiblings(parent, sibling, expectedTag, isMissing));
374
+ }
375
+ return sibling;
376
+ }
377
+ function describeSiblings(parent, mismatchChild, expectedTag, isMissing) {
378
+ const children = [];
379
+ let child = parent.firstChild;
380
+ while (child) {
381
+ if (child.nodeType === 1) children.push(child);
382
+ child = child.nextSibling;
383
+ }
384
+ const pTag = parent.localName;
385
+ if (isMissing) {
386
+ const tags = children.map(c => `<${c.localName}>`).join("");
387
+ return `<${pTag}>${tags}<${expectedTag} \u2190 missing></${pTag}>`;
388
+ }
389
+ const idx = children.indexOf(mismatchChild);
390
+ let start = 0,
391
+ end = children.length;
392
+ let prefix = "",
393
+ suffix = "";
394
+ if (children.length > 6) {
395
+ start = Math.max(0, idx - 2);
396
+ end = Math.min(children.length, idx + 3);
397
+ if (start > 0) prefix = "...";
398
+ if (end < children.length) suffix = "...";
399
+ }
400
+ const tags = children.slice(start, end).map(c => c === mismatchChild ? `<${c.localName} \u2190 expected ${expectedTag}>` : `<${c.localName}>`).join("");
401
+ return `<${pTag}>${prefix}${tags}${suffix}</${pTag}>`;
402
+ }
310
403
  function runHydrationEvents() {
311
404
  if (sharedConfig.events && !sharedConfig.events.queued) {
312
405
  queueMicrotask(() => {
@@ -331,7 +424,7 @@ function runHydrationEvents() {
331
424
  }
332
425
  }
333
426
  function isHydrating(node) {
334
- return sharedConfig.hydrating && !sharedConfig.done && (!node || node.isConnected);
427
+ return sharedConfig.hydrating && (!node || node.isConnected);
335
428
  }
336
429
  function toggleClassKey(node, key, value) {
337
430
  const classNames = key.trim().split(/\s+/);
@@ -357,7 +450,7 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
357
450
  if (prop === "class") return className(node, value, isSVG, prev), value;
358
451
  if (value === prev) return prev;
359
452
  if (prop === "ref") {
360
- if (!skipRef) value(node);
453
+ if (!skipRef && value) ref(() => value, node);
361
454
  } else if (prop.slice(0, 3) === "on:") {
362
455
  const e = prop.slice(3);
363
456
  prev && node.removeEventListener(e, prev, typeof prev !== "function" && prev);
@@ -413,7 +506,6 @@ function eventHandler(e) {
413
506
  return node || document;
414
507
  }
415
508
  });
416
- if (sharedConfig.registry && !sharedConfig.done) sharedConfig.done = _$HY.done = true;
417
509
  if (e.composedPath) {
418
510
  const path = e.composedPath();
419
511
  retarget(path[0]);
@@ -612,4 +704,4 @@ function Dynamic(props) {
612
704
  return createDynamic(() => props.component, others);
613
705
  }
614
706
 
615
- export { voidFn as Assets, ChildProperties, DOMElements, DelegatedEvents, Dynamic, Hydration, voidFn as HydrationScript, NoHydration, Portal, Properties, RequestContext, SVGElements, SVGNamespace, addEventListener, assign, className, clearDelegatedEvents, createDynamic, delegateEvents, dynamicProperty, escape, voidFn as generateHydrationScript, voidFn as getAssets, getHydrationKey, getNextElement, getNextMarker, getNextMatch, voidFn as getRequestEvent, hydrate, insert, isDev, isServer, memo, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrStyle, style, template, use, voidFn as useAssets };
707
+ export { voidFn as Assets, ChildProperties, DOMElements, DelegatedEvents, Dynamic, Hydration, voidFn as HydrationScript, NoHydration, Portal, Properties, RequestContext, SVGElements, SVGNamespace, addEventListener, applyRef, assign, className, clearDelegatedEvents, createDynamic, delegateEvents, dynamicProperty, effect, escape, voidFn as generateHydrationScript, voidFn as getAssets, getFirstChild, getHydrationKey, getNextElement, getNextMarker, getNextMatch, getNextSibling, voidFn as getRequestEvent, hydrate, insert, isDev, isServer, memo, ref, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrStyle, style, template, voidFn as useAssets };