solid-js 1.8.19 → 1.8.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/dev.cjs +6 -6
  2. package/dist/dev.js +562 -321
  3. package/dist/server.js +168 -74
  4. package/dist/solid.cjs +6 -6
  5. package/dist/solid.js +489 -279
  6. package/h/dist/h.js +38 -9
  7. package/h/jsx-runtime/dist/jsx.js +1 -1
  8. package/h/jsx-runtime/types/index.d.ts +11 -8
  9. package/h/types/hyperscript.d.ts +11 -11
  10. package/html/dist/html.js +216 -94
  11. package/html/types/lit.d.ts +47 -33
  12. package/package.json +1 -1
  13. package/store/dist/dev.js +122 -43
  14. package/store/dist/server.js +19 -8
  15. package/store/dist/store.js +113 -40
  16. package/store/types/index.d.ts +21 -7
  17. package/store/types/modifiers.d.ts +6 -3
  18. package/store/types/mutable.d.ts +5 -2
  19. package/store/types/server.d.ts +12 -4
  20. package/store/types/store.d.ts +218 -61
  21. package/types/index.d.ts +75 -10
  22. package/types/jsx.d.ts +913 -862
  23. package/types/reactive/array.d.ts +12 -4
  24. package/types/reactive/observable.d.ts +25 -17
  25. package/types/reactive/scheduler.d.ts +9 -6
  26. package/types/reactive/signal.d.ts +233 -142
  27. package/types/render/Suspense.d.ts +5 -5
  28. package/types/render/component.d.ts +64 -33
  29. package/types/render/flow.d.ts +43 -31
  30. package/types/render/hydration.d.ts +15 -15
  31. package/types/server/index.d.ts +57 -2
  32. package/types/server/reactive.d.ts +73 -42
  33. package/types/server/rendering.d.ts +169 -98
  34. package/universal/dist/dev.js +28 -12
  35. package/universal/dist/universal.js +28 -12
  36. package/universal/types/index.d.ts +3 -1
  37. package/universal/types/universal.d.ts +0 -1
  38. package/web/dist/dev.cjs +34 -18
  39. package/web/dist/dev.js +655 -97
  40. package/web/dist/server.cjs +1 -1
  41. package/web/dist/server.js +210 -96
  42. package/web/dist/web.cjs +32 -16
  43. package/web/dist/web.js +646 -95
  44. package/web/storage/dist/storage.js +3 -3
  45. package/web/types/client.d.ts +2 -2
  46. package/web/types/core.d.ts +10 -1
  47. package/web/types/index.d.ts +27 -10
  48. package/web/types/server-mock.d.ts +47 -32
package/web/dist/dev.cjs CHANGED
@@ -125,7 +125,7 @@ function render(code, element, init, options = {}) {
125
125
  function template(html, isCE, isSVG) {
126
126
  let node;
127
127
  const create = () => {
128
- if (solidJs.sharedConfig.context) throw new Error("Failed attempt to create new DOM elements during hydration. Check that the libraries you are using support hydration.");
128
+ if (isHydrating()) throw new Error("Failed attempt to create new DOM elements during hydration. Check that the libraries you are using support hydration.");
129
129
  const t = document.createElement("template");
130
130
  t.innerHTML = html;
131
131
  return isSVG ? t.content.firstChild.firstChild : t.content.firstChild;
@@ -151,19 +151,19 @@ function clearDelegatedEvents(document = window.document) {
151
151
  }
152
152
  }
153
153
  function setProperty(node, name, value) {
154
- if (!!solidJs.sharedConfig.context && node.isConnected) return;
154
+ if (isHydrating(node)) return;
155
155
  node[name] = value;
156
156
  }
157
157
  function setAttribute(node, name, value) {
158
- if (!!solidJs.sharedConfig.context && node.isConnected) return;
158
+ if (isHydrating(node)) return;
159
159
  if (value == null) node.removeAttribute(name);else node.setAttribute(name, value);
160
160
  }
161
161
  function setAttributeNS(node, namespace, name, value) {
162
- if (!!solidJs.sharedConfig.context && node.isConnected) return;
162
+ if (isHydrating(node)) return;
163
163
  if (value == null) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value);
164
164
  }
165
165
  function className(node, value) {
166
- if (!!solidJs.sharedConfig.context && node.isConnected) return;
166
+ if (isHydrating(node)) return;
167
167
  if (value == null) node.removeAttribute("class");else node.className = value;
168
168
  }
169
169
  function addEventListener(node, name, handler, delegate) {
@@ -262,6 +262,7 @@ function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = fals
262
262
  }
263
263
  }
264
264
  function hydrate$1(code, element, options = {}) {
265
+ if (globalThis._$HY.done) return render(code, element, [...element.childNodes], options);
265
266
  solidJs.sharedConfig.completed = globalThis._$HY.completed;
266
267
  solidJs.sharedConfig.events = globalThis._$HY.events;
267
268
  solidJs.sharedConfig.load = id => globalThis._$HY.r[id];
@@ -272,15 +273,19 @@ function hydrate$1(code, element, options = {}) {
272
273
  id: options.renderId || "",
273
274
  count: 0
274
275
  };
275
- gatherHydratable(element, options.renderId);
276
- const dispose = render(code, element, [...element.childNodes], options);
277
- solidJs.sharedConfig.context = null;
278
- return dispose;
276
+ try {
277
+ gatherHydratable(element, options.renderId);
278
+ return render(code, element, [...element.childNodes], options);
279
+ } finally {
280
+ solidJs.sharedConfig.context = null;
281
+ }
279
282
  }
280
283
  function getNextElement(template) {
281
- let node, key;
282
- if (!solidJs.sharedConfig.context || !(node = solidJs.sharedConfig.registry.get(key = getHydrationKey()))) {
283
- if (solidJs.sharedConfig.context) throw new Error(`Hydration Mismatch. Unable to find DOM nodes for hydration key: ${key}`);
284
+ let node,
285
+ key,
286
+ hydrating = isHydrating();
287
+ if (!hydrating || !(node = solidJs.sharedConfig.registry.get(key = getHydrationKey()))) {
288
+ if (hydrating) throw new Error(`Hydration Mismatch. Unable to find DOM nodes for hydration key: ${key}`);
284
289
  return template();
285
290
  }
286
291
  if (solidJs.sharedConfig.completed) solidJs.sharedConfig.completed.add(node);
@@ -295,7 +300,7 @@ function getNextMarker(start) {
295
300
  let end = start,
296
301
  count = 0,
297
302
  current = [];
298
- if (solidJs.sharedConfig.context) {
303
+ if (isHydrating(start)) {
299
304
  while (end) {
300
305
  if (end.nodeType === 8) {
301
306
  const v = end.nodeValue;
@@ -321,13 +326,20 @@ function runHydrationEvents() {
321
326
  while (events.length) {
322
327
  const [el, e] = events[0];
323
328
  if (!completed.has(el)) return;
324
- eventHandler(e);
325
329
  events.shift();
330
+ eventHandler(e);
331
+ }
332
+ if (solidJs.sharedConfig.done) {
333
+ solidJs.sharedConfig.events = _$HY.events = null;
334
+ solidJs.sharedConfig.completed = _$HY.completed = null;
326
335
  }
327
336
  });
328
337
  solidJs.sharedConfig.events.queued = true;
329
338
  }
330
339
  }
340
+ function isHydrating(node) {
341
+ return !!solidJs.sharedConfig.context && !solidJs.sharedConfig.done && (!node || node.isConnected);
342
+ }
331
343
  function toPropertyName(name) {
332
344
  return name.toLowerCase().replace(/-([a-z])/g, (_, w) => w.toUpperCase());
333
345
  }
@@ -367,7 +379,7 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
367
379
  if (forceProp) {
368
380
  prop = prop.slice(5);
369
381
  isProp = true;
370
- } else if (!!solidJs.sharedConfig.context && node.isConnected) return value;
382
+ } else if (isHydrating(node)) return value;
371
383
  if (prop === "class" || prop === "className") className(node, value);else if (isCE && !isProp && !isChildProp) node[toPropertyName(prop)] = value;else node[propAlias || prop] = value;
372
384
  } else {
373
385
  const ns = isSVG && prop.indexOf(":") > -1 && SVGNamespace[prop.split(":")[0]];
@@ -376,6 +388,9 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
376
388
  return value;
377
389
  }
378
390
  function eventHandler(e) {
391
+ if (solidJs.sharedConfig.registry && solidJs.sharedConfig.events) {
392
+ if (solidJs.sharedConfig.events.find(([el, ev]) => ev === e)) return;
393
+ }
379
394
  const key = `$$${e.type}`;
380
395
  let node = e.composedPath && e.composedPath()[0] || e.target;
381
396
  if (e.target !== node) {
@@ -402,7 +417,7 @@ function eventHandler(e) {
402
417
  }
403
418
  }
404
419
  function insertExpression(parent, value, current, marker, unwrapArray) {
405
- const hydrating = !!solidJs.sharedConfig.context && parent.isConnected;
420
+ const hydrating = isHydrating(parent);
406
421
  if (hydrating) {
407
422
  !current && (current = [...parent.childNodes]);
408
423
  let cleaned = [];
@@ -453,9 +468,10 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
453
468
  }
454
469
  if (hydrating) {
455
470
  if (!array.length) return current;
456
- if (marker === undefined) return [...parent.childNodes];
471
+ if (marker === undefined) return current = [...parent.childNodes];
457
472
  let node = array[0];
458
- let nodes = [node];
473
+ if (node.parentNode !== parent) return current;
474
+ const nodes = [node];
459
475
  while ((node = node.nextSibling) !== marker) nodes.push(node);
460
476
  return current = nodes;
461
477
  }