@solidjs/web 2.0.0-rc.11 → 2.0.0-rc.14

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 (60) hide show
  1. package/dist/server.dev.js +705 -151
  2. package/dist/server.js +604 -123
  3. package/dist/server.observe.js +617 -124
  4. package/dist/web.dev.js +102 -41
  5. package/dist/web.js +75 -37
  6. package/dist/web.observe.js +75 -39
  7. package/frames/dist/assets.js +92 -0
  8. package/frames/dist/bind.dev.js +326 -0
  9. package/frames/dist/bind.js +295 -0
  10. package/frames/dist/client.dev.js +693 -919
  11. package/frames/dist/client.js +636 -917
  12. package/frames/dist/client.observe.js +637 -917
  13. package/frames/dist/regions.js +130 -0
  14. package/frames/dist/server.dev.js +607 -212
  15. package/frames/dist/server.js +554 -212
  16. package/frames/dist/server.observe.js +554 -212
  17. package/frames/dist/trace.js +42 -0
  18. package/frames/dist/wire.js +133 -0
  19. package/package.json +30 -3
  20. package/performance-tracks/dist/performance-tracks.dev.js +2 -1
  21. package/performance-tracks/dist/performance-tracks.observe.js +2 -1
  22. package/performance-tracks/types/index.d.ts +8 -6
  23. package/serialization/dist/decode.js +37 -8
  24. package/serialization/dist/serialization.js +39 -10
  25. package/serialization/types/serializer-decode.d.ts +24 -2
  26. package/server-functions/dist/client.dev.js +178 -72
  27. package/server-functions/dist/client.js +99 -61
  28. package/server-functions/dist/client.observe.js +178 -72
  29. package/server-functions/dist/server.dev.js +117 -56
  30. package/server-functions/dist/server.js +117 -56
  31. package/server-functions/dist/server.observe.js +117 -56
  32. package/skills/server-components/SKILL.md +228 -0
  33. package/types/client.d.ts +37 -2
  34. package/types/constants.d.ts +2 -1
  35. package/types/diagnostics.d.ts +8 -0
  36. package/types/frames/assets-tier.d.ts +78 -0
  37. package/types/frames/bind-tier.d.ts +60 -0
  38. package/types/frames/client.d.ts +37 -3
  39. package/types/frames/frame-client.d.ts +249 -96
  40. package/types/frames/frame-container-plugin.d.ts +2 -10
  41. package/types/frames/frame-sink.d.ts +33 -0
  42. package/types/frames/frame-transport.d.ts +66 -18
  43. package/types/frames/regions-tier.d.ts +45 -0
  44. package/types/frames/serializer-decode.d.ts +24 -2
  45. package/types/frames/server.d.ts +53 -1
  46. package/types/frames/trace-tier.d.ts +2 -0
  47. package/types/frames/tree-rewrite.d.ts +39 -0
  48. package/types/frames/wire-tier.d.ts +116 -0
  49. package/types/index.d.ts +38 -0
  50. package/types/index.server.d.ts +10 -1
  51. package/types/jsx.d.ts +11 -1
  52. package/types/observe.d.ts +182 -12
  53. package/types/request-error-hook.d.ts +5 -0
  54. package/types/serializer-decode.d.ts +24 -2
  55. package/types/server-functions/client.d.ts +26 -0
  56. package/types/server-functions/registry.d.ts +4 -1
  57. package/types/server-functions/shared.d.ts +12 -8
  58. package/types/server-mock.d.ts +13 -1
  59. package/types/server-observe.d.ts +8 -0
  60. package/types/server.d.ts +125 -12
package/dist/web.dev.js CHANGED
@@ -1,6 +1,6 @@
1
- import { createRenderEffect, getOwner, createMemo, OBSERVE, DEV, sharedConfig, enableHydration, $PROXY, untrack, runWithOwner, resetErrorHalt, enforceLoadingBoundary, createRoot, ROOT_ERROR_HOOK, flatten, flush, createComponent, omit, createOwner, createSignal, $DEVCOMP, onCleanup, createEffect } from 'solid-js';
1
+ import { createRenderEffect, getOwner, createMemo, OBSERVE, DEV, enableHydration, $PROXY, untrack, runWithOwner, resetErrorHalt, enforceLoadingBoundary, createRoot, ROOT_ERROR_HOOK, flatten, flush, createComponent, omit, createOwner, createSignal, createEffect, onCleanup } from 'solid-js';
2
2
  export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
3
- import { sourceKeys, SOURCE_PROXY, hasStaticKeys, resolvedTable, viewOf, OmitView, sourceHas, SOURCE_OMIT, sourceGet, SOURCE_MEMO, SOURCE_PLAIN } from 'solid-js/internal';
3
+ import { sharedConfig, sourceKeys, SOURCE_PROXY, resolvedTable, viewOf, OmitView, hasStaticKeys, SOURCE_MEMO, sourceHas, SOURCE_OMIT, sourceGet, SOURCE_PLAIN, $DEVCOMP } from 'solid-js/internal';
4
4
 
5
5
  const DOMWithState = {
6
6
  INPUT: {
@@ -231,6 +231,24 @@ function unscopedHoleAllocatedIds(before, after, site, subject) {
231
231
  }
232
232
  }, subject);
233
233
  }
234
+ const lowercaseEventAttributesReported = /*#__PURE__*/new Set();
235
+ function lowercaseEventAttribute(name, node) {
236
+ if (lowercaseEventAttributesReported.has(name)) return;
237
+ lowercaseEventAttributesReported.add(name);
238
+ const event = name.slice(name.charAt(2) === ":" ? 3 : 2);
239
+ const handler = "on" + event.charAt(0).toUpperCase() + event.slice(1);
240
+ devCheck({
241
+ code: "LOWERCASE_EVENT_ATTRIBUTE",
242
+ kind: "render",
243
+ severity: "warn",
244
+ message: `[LOWERCASE_EVENT_ATTRIBUTE] \`${name}\` received a function, but \`${name}\` is an attribute ` + `in Solid 2.0, not an event handler: the function was set as the attribute's text. ` + `Use \`${handler}\` for event handlers.`,
245
+ data: {
246
+ name,
247
+ handler,
248
+ tag: node.localName
249
+ }
250
+ });
251
+ }
234
252
 
235
253
  const HEAD_ELIGIBLE_TAGS = new Set(["title", "meta", "link", "style", "script", "base"]);
236
254
  const HEAD_ATTR_NAME = /^[a-zA-Z_][a-zA-Z0-9_:.-]*$/;
@@ -398,7 +416,7 @@ function assertServableCookie(name, options) {
398
416
  }
399
417
  }
400
418
  const FLASH_COOKIE = "flash";
401
- const FLASH_MATCHER = new RegExp(`(?:^|;\\s*)${FLASH_COOKIE}=([^;]+)`);
419
+ const FLASH_MATCHER = /(?:^|;\s*)flash=([^;]+)/;
402
420
  function hasFlashCookie(cookieHeader) {
403
421
  return !!cookieHeader && FLASH_MATCHER.test(cookieHeader);
404
422
  }
@@ -447,6 +465,34 @@ function HydrationScript(_props) {
447
465
  return null;
448
466
  }
449
467
  const getRequestEvent = voidFn;
468
+ const getHydrationWriter = voidFn;
469
+ function takeHydrationValue(key) {
470
+ const registry = globalThis._$HY && globalThis._$HY.r;
471
+ if (!registry || !(key in registry)) return;
472
+ const v = registry[key];
473
+ delete registry[key];
474
+ if (v !== null && typeof v === "object" && typeof v.then === "function") {
475
+ if (v.s === 1) return {
476
+ status: "resolved",
477
+ value: v.v
478
+ };
479
+ if (v.s === 2) {
480
+ v.then(undefined, voidFn);
481
+ return {
482
+ status: "rejected",
483
+ error: v.v
484
+ };
485
+ }
486
+ return {
487
+ status: "pending",
488
+ promise: v
489
+ };
490
+ }
491
+ return {
492
+ status: "resolved",
493
+ value: v
494
+ };
495
+ }
450
496
  const getTraceContext = voidFn;
451
497
  function render(code, element, init, options = {}) {
452
498
  if (!element) {
@@ -563,8 +609,9 @@ function dispatchAsInteraction(e, fn) {
563
609
  return OBSERVE.attribution.withInteraction({
564
610
  type: e.type,
565
611
  target: describeEventTarget(e.target),
566
- at: interactionStart(e)
567
- }, fn);
612
+ at: interactionStart(e),
613
+ event: e
614
+ }, fn) ;
568
615
  }
569
616
  function getDelegatedRoot(node) {
570
617
  while (node) {
@@ -621,7 +668,10 @@ function claimElement(node) {
621
668
  return node;
622
669
  }
623
670
  function setAttribute(node, name, value) {
624
- tagElement(node);
671
+ {
672
+ tagElement(node);
673
+ if (typeof value === "function" && name.startsWith("on")) lowercaseEventAttribute(name, node);
674
+ }
625
675
  if (isHydrating(node)) return;
626
676
  const selectMultiple = name === "multiple" && node.localName === "select";
627
677
  if (value == null || value === false) node.removeAttribute(name);else {
@@ -783,8 +833,9 @@ function spread(node, props, skipChildren, skip, name) {
783
833
  if (r !== prevProps.ref && (typeof r === "function" || Array.isArray(r))) ref(() => r, node);
784
834
  assign(node, newProps, true, prevProps, true);
785
835
  };
786
- unscopedByDesign = node;
787
836
  if (Array.isArray(props)) {
837
+ effect(() => collectSources({}, props, undefined, skip), apply);
838
+ unscopedByDesign = node;
788
839
  if (!skipChildren && !(skip !== undefined && skip("children"))) insert(node, () => {
789
840
  for (let i = props.length - 1; i >= 0; i--) {
790
841
  const s = resolveSource(props[i]);
@@ -792,9 +843,20 @@ function spread(node, props, skipChildren, skip, name) {
792
843
  }
793
844
  });
794
845
  unscopedByDesign = null;
795
- effect(() => collectSources({}, props, undefined, skip), apply);
796
846
  return prevProps;
797
847
  }
848
+ effect(() => {
849
+ const source = resolveSource(props);
850
+ const newProps = {};
851
+ const table = resolvedTable(source);
852
+ if (table !== undefined) return collectTable(newProps, table, skip);
853
+ if (source != null) {
854
+ const view = viewOf(source);
855
+ if (view instanceof OmitView) collectProps(newProps, view, SOURCE_OMIT, skip);else if (view !== undefined) collectSources(newProps, view.sources, view.kinds, skip);else collectProps(newProps, source, $PROXY in source ? SOURCE_PROXY : SOURCE_PLAIN, skip);
856
+ }
857
+ return newProps;
858
+ }, apply);
859
+ unscopedByDesign = node;
798
860
  if (!skipChildren && !(skip !== undefined && skip("children"))) {
799
861
  if (typeof props !== "function" && props != null && hasStaticKeys(props)) {
800
862
  const desc = Object.getOwnPropertyDescriptor(props, "children");
@@ -807,17 +869,6 @@ function spread(node, props, skipChildren, skip, name) {
807
869
  });
808
870
  }
809
871
  unscopedByDesign = null;
810
- effect(() => {
811
- const source = resolveSource(props);
812
- const newProps = {};
813
- const table = resolvedTable(source);
814
- if (table !== undefined) return collectTable(newProps, table, skip);
815
- if (source != null) {
816
- const view = viewOf(source);
817
- if (view instanceof OmitView) collectProps(newProps, view, SOURCE_OMIT, skip);else if (view !== undefined) collectSources(newProps, view.sources, view.kinds, skip);else collectProps(newProps, source, $PROXY in source ? SOURCE_PROXY : SOURCE_PLAIN, skip);
818
- }
819
- return newProps;
820
- }, apply);
821
872
  return prevProps;
822
873
  }
823
874
  function collectTable(out, table, skip) {
@@ -1026,13 +1077,17 @@ function insert(parent, accessor, marker, initial, options) {
1026
1077
  const value = normalize(accessor(), current, multi, true);
1027
1078
  checkUnscopedHole(devNext, accessor, parent);
1028
1079
  if (typeof value !== "function") return value;
1080
+ const innerOptions = prev !== undefined && !(options && options.schedule) ? {
1081
+ ...options,
1082
+ schedule: true
1083
+ } : options;
1029
1084
  effect(() => (hydrationRt !== null && (current = hydrationRt.reclaimRegion(current, parent, marker)), normalize(value, current, multi)), inner => {
1030
1085
  current = insertExpression(parent, inner, current, marker);
1031
1086
  host && tagHost(current, host);
1032
- }, prev !== undefined && !(options && options.schedule) ? {
1033
- ...options,
1034
- schedule: true
1035
- } : options);
1087
+ }, {
1088
+ ...innerOptions,
1089
+ _wide: true
1090
+ } );
1036
1091
  checkUnscopedHole(devNext, accessor, parent);
1037
1092
  return INNER_OWNED;
1038
1093
  }, value => {
@@ -1344,7 +1399,7 @@ function flushHeadRegistry() {
1344
1399
  function createHeadElement(tag, props) {
1345
1400
  const el = document.createElement(tag);
1346
1401
  for (const name in props) {
1347
- if (name === "children" || name === "ref" || name.slice(0, 2) === "on") continue;
1402
+ if (name === "children" || name === "ref" || /^on[A-Z]/.test(name)) continue;
1348
1403
  if (!HEAD_ATTR_NAME.test(name)) {
1349
1404
  console.warn(`useHead: ignoring invalid attribute name "${name}"`);
1350
1405
  continue;
@@ -1368,7 +1423,7 @@ function renderHeadElement(t, identity, existing) {
1368
1423
  function headElementMatches(el, t) {
1369
1424
  if (el.tagName.toLowerCase() !== t.tag) return false;
1370
1425
  for (const name in t.props) {
1371
- if (name === "children" || name === "ref" || name.slice(0, 2) === "on") continue;
1426
+ if (name === "children" || name === "ref" || /^on[A-Z]/.test(name)) continue;
1372
1427
  if (!HEAD_ATTR_NAME.test(name)) continue;
1373
1428
  const v = t.props[name];
1374
1429
  if (v == null || v === false) {
@@ -1771,8 +1826,9 @@ function assignProp(node, prop, value, prev, skipRef, nodeName) {
1771
1826
  if (!skipRef && value) ref(() => value, node);
1772
1827
  return value;
1773
1828
  }
1829
+ let c;
1774
1830
  const hasNamespace = prop.indexOf(":") > -1;
1775
- if (!hasNamespace && prop.slice(0, 2) === "on") {
1831
+ if (!hasNamespace && prop.startsWith("on") && (c = prop.charCodeAt(2)) > 64 && c < 91) {
1776
1832
  const name = prop.slice(2).toLowerCase();
1777
1833
  const delegate = DelegatedEvents.has(name);
1778
1834
  if (!delegate && prev) {
@@ -1815,11 +1871,7 @@ function eventHandler(e, container, state) {
1815
1871
  value
1816
1872
  });
1817
1873
  const handleNode = () => {
1818
- let handler = node[key];
1819
- if (handler === undefined && node.hasAttribute && node.hasAttribute("_bnd")) {
1820
- const seam = globalThis[Symbol.for("solid.bnd")];
1821
- if (seam) handler = seam.resolve(node, e.type);
1822
- }
1874
+ const handler = node[key];
1823
1875
  if (handler && !node.disabled) {
1824
1876
  const data = node[`${key}Data`];
1825
1877
  data !== undefined ? handler.call(node, data, e) : typeof handler === "function" ? handler.call(node, e) : handler.handleEvent(e);
@@ -1880,6 +1932,7 @@ function insertExpression(parent, value, current, marker) {
1880
1932
  return value;
1881
1933
  }
1882
1934
  if (value === current) return value;
1935
+ if (hydrationRt !== null && sharedConfig.hydrating && current == null && value && [].concat(value).every(n => n?.parentNode === parent) && value.length !== 0) return value;
1883
1936
  const t = typeof value,
1884
1937
  multi = marker !== undefined;
1885
1938
  if (t === "string" || t === "number") {
@@ -2017,16 +2070,14 @@ function cleanChildren(parent, current, marker, replacement) {
2017
2070
  if (replacement && marker) replacement[$$SLOT] = marker;
2018
2071
  }
2019
2072
  function gatherHydratable(element, root) {
2020
- const templates = element.querySelectorAll(`*[_hk]`);
2073
+ const templates = element.querySelectorAll(root ? `[_hk^="${root.replace(/["\\]/g, "\\$&")}"]` : `*[_hk]`);
2021
2074
  const frames = root ? null : element.querySelectorAll("[data-fid]");
2022
2075
  const frameCount = frames ? frames.length : 0;
2023
2076
  const registry = sharedConfig.registry;
2024
2077
  for (let i = 0; i < templates.length; i++) {
2025
2078
  const node = templates[i];
2026
2079
  const key = node.getAttribute("_hk");
2027
- if (root) {
2028
- if (!key.startsWith(root)) continue;
2029
- } else if (frameCount !== 0) {
2080
+ if (frameCount !== 0) {
2030
2081
  let inFrame = false;
2031
2082
  for (let j = 0; j < frameCount; j++) {
2032
2083
  if (frames[j].contains(node)) {
@@ -2045,6 +2096,7 @@ function getHydrationKey() {
2045
2096
  const RequestContext = Symbol();
2046
2097
 
2047
2098
  function configureServerErrors(_config) {}
2099
+ function reportRequestFailure(_error, _event) {}
2048
2100
  function throwInBrowser(func) {
2049
2101
  const err = new Error(`${func.name} is not supported in the browser, returning undefined`);
2050
2102
  console.error(err);
@@ -2079,6 +2131,7 @@ function ssrElementAttribute(key, value) {}
2079
2131
  function ssrClassName(value) {}
2080
2132
  function ssrStyle(value) {}
2081
2133
  function ssrStyleProperty(name, value) {}
2134
+ function ssrStyleProperties(...entries) {}
2082
2135
  function ssrAttribute(key, value) {}
2083
2136
  function ssrGroup(fn, n) {}
2084
2137
  function ssrHydrationKey() {}
@@ -2270,7 +2323,13 @@ function bindingOf(value) {
2270
2323
  return value !== null && (typeof value === "function" || typeof value === "object") && value[COMPONENT_BINDING] || undefined;
2271
2324
  }
2272
2325
  function dynamic(source, options) {
2273
- if (options?.static) return staticDynamic(untrack(source));
2326
+ return dynamicCore(source, options, staticElement);
2327
+ }
2328
+ function dynamicComponent(source, options) {
2329
+ return dynamicCore(source, options);
2330
+ }
2331
+ function dynamicCore(source, options, tagArm) {
2332
+ if (options?.static) return staticDynamic(untrack(source), tagArm);
2274
2333
  const sites = new Set();
2275
2334
  let deliveredAddress;
2276
2335
  const resolveBinding = (next, prev) => {
@@ -2338,7 +2397,9 @@ function dynamic(source, options) {
2338
2397
  });
2339
2398
  const binding = bindingOf(component);
2340
2399
  if (binding) {
2341
- const [address, setAddress] = createSignal(deliveredAddress ??= binding.address);
2400
+ const [address, setAddress] = createSignal(deliveredAddress ??= binding.address, {
2401
+ ownedWrite: true
2402
+ });
2342
2403
  sites.add(setAddress);
2343
2404
  onCleanup(() => sites.delete(setAddress));
2344
2405
  return untrack(() => binding.component(props, address));
@@ -2346,12 +2407,12 @@ function dynamic(source, options) {
2346
2407
  return untrack(() => component(props));
2347
2408
  }
2348
2409
  case "string":
2349
- return staticElement(component, props);
2410
+ return tagArm ? tagArm(component, props) : undefined;
2350
2411
  }
2351
2412
  });
2352
2413
  };
2353
2414
  }
2354
- function staticDynamic(component) {
2415
+ function staticDynamic(component, tagArm) {
2355
2416
  if (component && typeof component.then === "function") throw new Error("dynamic(): a static source must resolve synchronously, not to a promise");
2356
2417
  if (typeof component === "function") {
2357
2418
  Object.assign(component, {
@@ -2364,7 +2425,7 @@ function staticDynamic(component) {
2364
2425
  }
2365
2426
  return props => untrack(() => component(props));
2366
2427
  }
2367
- if (typeof component === "string") return props => staticElement(component, props);
2428
+ if (typeof component === "string" && tagArm) return props => tagArm(component, props);
2368
2429
  return () => undefined;
2369
2430
  }
2370
2431
  function staticElement(tag, props) {
@@ -2413,4 +2474,4 @@ _moduleUrl) {
2413
2474
  function httpStatus(_code, _text) {}
2414
2475
  function httpHeader(_name, _value, _options) {}
2415
2476
 
2416
- export { ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF, HydrationScript, MathMLElements, NULL_BODY_STATUSES, Namespaces, Portal, RESPONSE_HEADER_VALUE_LIMIT, REVALIDATE_ALL, REVALIDATE_HEADER, RawTextElements, RequestContext, ResponseEnvelope, SAFE_ERROR, SVGElements, VoidElements, acquireAsset, addEvent, applyRef, assign, claimElement, claimElementTree, className, clearFlashCookie, clientOnly, commitEventResponse, composeMiddleware, configureServerErrors, createRequestEvent, createResponseStub, createSSRResponse, delegateEvents, dynamic, dynamicProperty, effect, escape, generateHydrationScript, getDelegatedRoot, getExpectedRedirectStatus, getFirstChild, getHydrationKey, getNextElement, getNextMarker, getNextMatch, getNextSibling, getRequestEvent, getServerFunctionMetadata, getServerFunctionRPC, getTraceContext, hasFlashCookie, httpHeader, httpStatus, hydrate, insert, installHydrationRuntime, isDev, isHref, isResponseEnvelope, isSafeError, isServer, isServerFunction, markSafeError, memo, parseCookieHeader, readShallow, redirect, ref, registerDelegatedContainer, registerDelegatedRoot, registerElementClaim, reload, render, renderToStream, renderToString, resolveSSRNode, respond, runHydrationEvents, scope, serializeCookie, setAttribute, setAttributeNS, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrElementAttribute, ssrGroup, ssrHydrationKey, ssrStyle, ssrStyleProperty, style, template, unregisterDelegatedContainer, unregisterDelegatedRoot, useHead, waitAsset, warmAsset };
2477
+ export { ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF, HydrationScript, MathMLElements, NULL_BODY_STATUSES, Namespaces, Portal, RESPONSE_HEADER_VALUE_LIMIT, REVALIDATE_ALL, REVALIDATE_HEADER, RawTextElements, RequestContext, ResponseEnvelope, SAFE_ERROR, SVGElements, VoidElements, acquireAsset, addEvent, applyRef, assign, claimElement, claimElementTree, className, clearFlashCookie, clientOnly, commitEventResponse, composeMiddleware, configureServerErrors, createRequestEvent, createResponseStub, createSSRResponse, delegateEvents, dispatchAsInteraction, dynamic, dynamicComponent, dynamicProperty, effect, escape, generateHydrationScript, getDelegatedRoot, getExpectedRedirectStatus, getFirstChild, getHydrationKey, getHydrationWriter, getNextElement, getNextMarker, getNextMatch, getNextSibling, getRequestEvent, getServerFunctionMetadata, getServerFunctionRPC, getTraceContext, hasFlashCookie, httpHeader, httpStatus, hydrate, insert, installHydrationRuntime, isDev, isHref, isResponseEnvelope, isSafeError, isServer, isServerFunction, markSafeError, memo, parseCookieHeader, readShallow, redirect, ref, registerDelegatedContainer, registerDelegatedRoot, registerElementClaim, reload, render, renderToStream, renderToString, reportRequestFailure, resolveSSRNode, respond, runHydrationEvents, scope, serializeCookie, setAttribute, setAttributeNS, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrElementAttribute, ssrGroup, ssrHydrationKey, ssrStyle, ssrStyleProperties, ssrStyleProperty, style, takeHydrationValue, template, unregisterDelegatedContainer, unregisterDelegatedRoot, useHead, waitAsset, warmAsset };
package/dist/web.js CHANGED
@@ -1,6 +1,6 @@
1
- import { createRenderEffect, createMemo, sharedConfig, enableHydration, $PROXY, untrack, runWithOwner, createRoot, getOwner, ROOT_ERROR_HOOK, flatten, flush, createComponent, omit, createOwner, createSignal, onCleanup, createEffect } from 'solid-js';
1
+ import { createRenderEffect, createMemo, enableHydration, $PROXY, untrack, runWithOwner, createRoot, getOwner, ROOT_ERROR_HOOK, flatten, flush, createComponent, omit, createOwner, createSignal, createEffect, onCleanup } from 'solid-js';
2
2
  export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
3
- import { sourceKeys, SOURCE_PROXY, hasStaticKeys, resolvedTable, viewOf, OmitView, sourceHas, SOURCE_OMIT, sourceGet, SOURCE_MEMO, SOURCE_PLAIN } from 'solid-js/internal';
3
+ import { sharedConfig, sourceKeys, SOURCE_PROXY, resolvedTable, viewOf, OmitView, hasStaticKeys, SOURCE_MEMO, sourceHas, SOURCE_OMIT, sourceGet, SOURCE_PLAIN } from 'solid-js/internal';
4
4
 
5
5
  const DOMWithState = {
6
6
  INPUT: {
@@ -317,7 +317,7 @@ function serializeCookie(name, value, options = {}) {
317
317
  return cookie;
318
318
  }
319
319
  const FLASH_COOKIE = "flash";
320
- const FLASH_MATCHER = new RegExp(`(?:^|;\\s*)${FLASH_COOKIE}=([^;]+)`);
320
+ const FLASH_MATCHER = /(?:^|;\s*)flash=([^;]+)/;
321
321
  function hasFlashCookie(cookieHeader) {
322
322
  return !!cookieHeader && FLASH_MATCHER.test(cookieHeader);
323
323
  }
@@ -366,6 +366,34 @@ function HydrationScript(_props) {
366
366
  return null;
367
367
  }
368
368
  const getRequestEvent = voidFn;
369
+ const getHydrationWriter = voidFn;
370
+ function takeHydrationValue(key) {
371
+ const registry = globalThis._$HY && globalThis._$HY.r;
372
+ if (!registry || !(key in registry)) return;
373
+ const v = registry[key];
374
+ delete registry[key];
375
+ if (v !== null && typeof v === "object" && typeof v.then === "function") {
376
+ if (v.s === 1) return {
377
+ status: "resolved",
378
+ value: v.v
379
+ };
380
+ if (v.s === 2) {
381
+ v.then(undefined, voidFn);
382
+ return {
383
+ status: "rejected",
384
+ error: v.v
385
+ };
386
+ }
387
+ return {
388
+ status: "pending",
389
+ promise: v
390
+ };
391
+ }
392
+ return {
393
+ status: "resolved",
394
+ value: v
395
+ };
396
+ }
369
397
  const getTraceContext = voidFn;
370
398
  function render(code, element, init, options = {}) {
371
399
  let disposer;
@@ -454,6 +482,9 @@ function attachDelegatedEvent(name, container, state) {
454
482
  state.handlers.set(name, handler);
455
483
  container.addEventListener(name, handler);
456
484
  }
485
+ function dispatchAsInteraction(e, fn) {
486
+ return fn();
487
+ }
457
488
  function getDelegatedRoot(node) {
458
489
  while (node) {
459
490
  if (delegatedContainers.get(node)?.roots) return node;
@@ -652,26 +683,15 @@ function spread(node, props, skipChildren, skip, name) {
652
683
  assign(node, newProps, true, prevProps, true);
653
684
  };
654
685
  if (Array.isArray(props)) {
686
+ effect(() => collectSources({}, props, undefined, skip), apply);
655
687
  if (!skipChildren && !(skip !== undefined && skip("children"))) insert(node, () => {
656
688
  for (let i = props.length - 1; i >= 0; i--) {
657
689
  const s = resolveSource(props[i]);
658
690
  if (s != null && entryHas(s, "children")) return entryGet(s, "children");
659
691
  }
660
692
  });
661
- effect(() => collectSources({}, props, undefined, skip), apply);
662
693
  return prevProps;
663
694
  }
664
- if (!skipChildren && !(skip !== undefined && skip("children"))) {
665
- if (typeof props !== "function" && props != null && hasStaticKeys(props)) {
666
- const desc = Object.getOwnPropertyDescriptor(props, "children");
667
- if (desc !== undefined) {
668
- if (desc.get === undefined) insert(node, desc.value);else insert(node, () => props.children);
669
- }
670
- } else insert(node, () => {
671
- const source = resolveSource(props);
672
- return source != null && entryHas(source, "children") ? entryGet(source, "children") : undefined;
673
- });
674
- }
675
695
  effect(() => {
676
696
  const source = resolveSource(props);
677
697
  const newProps = {};
@@ -683,6 +703,17 @@ function spread(node, props, skipChildren, skip, name) {
683
703
  }
684
704
  return newProps;
685
705
  }, apply);
706
+ if (!skipChildren && !(skip !== undefined && skip("children"))) {
707
+ if (typeof props !== "function" && props != null && hasStaticKeys(props)) {
708
+ const desc = Object.getOwnPropertyDescriptor(props, "children");
709
+ if (desc !== undefined) {
710
+ if (desc.get === undefined) insert(node, desc.value);else insert(node, () => props.children);
711
+ }
712
+ } else insert(node, () => {
713
+ const source = resolveSource(props);
714
+ return source != null && entryHas(source, "children") ? entryGet(source, "children") : undefined;
715
+ });
716
+ }
686
717
  return prevProps;
687
718
  }
688
719
  function collectTable(out, table, skip) {
@@ -863,13 +894,14 @@ function insert(parent, accessor, marker, initial, options) {
863
894
  if (hydrationRt !== null) current = hydrationRt.reclaimRegion(current, parent, marker);
864
895
  const value = normalize(accessor(), current, multi, true);
865
896
  if (typeof value !== "function") return value;
897
+ const innerOptions = prev !== undefined && !(options && options.schedule) ? {
898
+ ...options,
899
+ schedule: true
900
+ } : options;
866
901
  effect(() => (hydrationRt !== null && (current = hydrationRt.reclaimRegion(current, parent, marker)), normalize(value, current, multi)), inner => {
867
902
  current = insertExpression(parent, inner, current, marker);
868
903
  host && tagHost(current, host);
869
- }, prev !== undefined && !(options && options.schedule) ? {
870
- ...options,
871
- schedule: true
872
- } : options);
904
+ }, innerOptions);
873
905
  return INNER_OWNED;
874
906
  }, value => {
875
907
  if (value === INNER_OWNED) return;
@@ -1178,7 +1210,7 @@ function flushHeadRegistry() {
1178
1210
  function createHeadElement(tag, props) {
1179
1211
  const el = document.createElement(tag);
1180
1212
  for (const name in props) {
1181
- if (name === "children" || name === "ref" || name.slice(0, 2) === "on") continue;
1213
+ if (name === "children" || name === "ref" || /^on[A-Z]/.test(name)) continue;
1182
1214
  if (!HEAD_ATTR_NAME.test(name)) {
1183
1215
  continue;
1184
1216
  }
@@ -1201,7 +1233,7 @@ function renderHeadElement(t, identity, existing) {
1201
1233
  function headElementMatches(el, t) {
1202
1234
  if (el.tagName.toLowerCase() !== t.tag) return false;
1203
1235
  for (const name in t.props) {
1204
- if (name === "children" || name === "ref" || name.slice(0, 2) === "on") continue;
1236
+ if (name === "children" || name === "ref" || /^on[A-Z]/.test(name)) continue;
1205
1237
  if (!HEAD_ATTR_NAME.test(name)) continue;
1206
1238
  const v = t.props[name];
1207
1239
  if (v == null || v === false) {
@@ -1546,8 +1578,9 @@ function assignProp(node, prop, value, prev, skipRef, nodeName) {
1546
1578
  if (!skipRef && value) ref(() => value, node);
1547
1579
  return value;
1548
1580
  }
1581
+ let c;
1549
1582
  const hasNamespace = prop.indexOf(":") > -1;
1550
- if (!hasNamespace && prop.slice(0, 2) === "on") {
1583
+ if (!hasNamespace && prop.startsWith("on") && (c = prop.charCodeAt(2)) > 64 && c < 91) {
1551
1584
  const name = prop.slice(2).toLowerCase();
1552
1585
  const delegate = DelegatedEvents.has(name);
1553
1586
  if (!delegate && prev) {
@@ -1590,11 +1623,7 @@ function eventHandler(e, container, state) {
1590
1623
  value
1591
1624
  });
1592
1625
  const handleNode = () => {
1593
- let handler = node[key];
1594
- if (handler === undefined && node.hasAttribute && node.hasAttribute("_bnd")) {
1595
- const seam = globalThis[Symbol.for("solid.bnd")];
1596
- if (seam) handler = seam.resolve(node, e.type);
1597
- }
1626
+ const handler = node[key];
1598
1627
  if (handler && !node.disabled) {
1599
1628
  const data = node[`${key}Data`];
1600
1629
  data !== undefined ? handler.call(node, data, e) : typeof handler === "function" ? handler.call(node, e) : handler.handleEvent(e);
@@ -1654,6 +1683,7 @@ function insertExpression(parent, value, current, marker) {
1654
1683
  return value;
1655
1684
  }
1656
1685
  if (value === current) return value;
1686
+ if (hydrationRt !== null && sharedConfig.hydrating && current == null && value && [].concat(value).every(n => n?.parentNode === parent) && value.length !== 0) return value;
1657
1687
  const t = typeof value,
1658
1688
  multi = marker !== undefined;
1659
1689
  if (t === "string" || t === "number") {
@@ -1782,16 +1812,14 @@ function cleanChildren(parent, current, marker, replacement) {
1782
1812
  if (replacement && marker) replacement[$$SLOT] = marker;
1783
1813
  }
1784
1814
  function gatherHydratable(element, root) {
1785
- const templates = element.querySelectorAll(`*[_hk]`);
1815
+ const templates = element.querySelectorAll(root ? `[_hk^="${root.replace(/["\\]/g, "\\$&")}"]` : `*[_hk]`);
1786
1816
  const frames = root ? null : element.querySelectorAll("[data-fid]");
1787
1817
  const frameCount = frames ? frames.length : 0;
1788
1818
  const registry = sharedConfig.registry;
1789
1819
  for (let i = 0; i < templates.length; i++) {
1790
1820
  const node = templates[i];
1791
1821
  const key = node.getAttribute("_hk");
1792
- if (root) {
1793
- if (!key.startsWith(root)) continue;
1794
- } else if (frameCount !== 0) {
1822
+ if (frameCount !== 0) {
1795
1823
  let inFrame = false;
1796
1824
  for (let j = 0; j < frameCount; j++) {
1797
1825
  if (frames[j].contains(node)) {
@@ -1810,6 +1838,7 @@ function getHydrationKey() {
1810
1838
  const RequestContext = Symbol();
1811
1839
 
1812
1840
  function configureServerErrors(_config) {}
1841
+ function reportRequestFailure(_error, _event) {}
1813
1842
  function throwInBrowser(func) {
1814
1843
  const err = new Error(`${func.name} is not supported in the browser, returning undefined`);
1815
1844
  console.error(err);
@@ -1844,6 +1873,7 @@ function ssrElementAttribute(key, value) {}
1844
1873
  function ssrClassName(value) {}
1845
1874
  function ssrStyle(value) {}
1846
1875
  function ssrStyleProperty(name, value) {}
1876
+ function ssrStyleProperties(...entries) {}
1847
1877
  function ssrAttribute(key, value) {}
1848
1878
  function ssrGroup(fn, n) {}
1849
1879
  function ssrHydrationKey() {}
@@ -2035,7 +2065,13 @@ function bindingOf(value) {
2035
2065
  return value !== null && (typeof value === "function" || typeof value === "object") && value[COMPONENT_BINDING] || undefined;
2036
2066
  }
2037
2067
  function dynamic(source, options) {
2038
- if (options?.static) return staticDynamic(untrack(source));
2068
+ return dynamicCore(source, options, staticElement);
2069
+ }
2070
+ function dynamicComponent(source, options) {
2071
+ return dynamicCore(source, options);
2072
+ }
2073
+ function dynamicCore(source, options, tagArm) {
2074
+ if (options?.static) return staticDynamic(untrack(source), tagArm);
2039
2075
  const sites = new Set();
2040
2076
  let deliveredAddress;
2041
2077
  const resolveBinding = (next, prev) => {
@@ -2100,7 +2136,9 @@ function dynamic(source, options) {
2100
2136
  {
2101
2137
  const binding = bindingOf(component);
2102
2138
  if (binding) {
2103
- const [address, setAddress] = createSignal(deliveredAddress ??= binding.address);
2139
+ const [address, setAddress] = createSignal(deliveredAddress ??= binding.address, {
2140
+ ownedWrite: true
2141
+ });
2104
2142
  sites.add(setAddress);
2105
2143
  onCleanup(() => sites.delete(setAddress));
2106
2144
  return untrack(() => binding.component(props, address));
@@ -2108,12 +2146,12 @@ function dynamic(source, options) {
2108
2146
  return untrack(() => component(props));
2109
2147
  }
2110
2148
  case "string":
2111
- return staticElement(component, props);
2149
+ return tagArm ? tagArm(component, props) : undefined;
2112
2150
  }
2113
2151
  });
2114
2152
  };
2115
2153
  }
2116
- function staticDynamic(component) {
2154
+ function staticDynamic(component, tagArm) {
2117
2155
  if (typeof component === "function") {
2118
2156
  const binding = bindingOf(component);
2119
2157
  if (binding) {
@@ -2122,7 +2160,7 @@ function staticDynamic(component) {
2122
2160
  }
2123
2161
  return props => untrack(() => component(props));
2124
2162
  }
2125
- if (typeof component === "string") return props => staticElement(component, props);
2163
+ if (typeof component === "string" && tagArm) return props => tagArm(component, props);
2126
2164
  return () => undefined;
2127
2165
  }
2128
2166
  function staticElement(tag, props) {
@@ -2171,4 +2209,4 @@ _moduleUrl) {
2171
2209
  function httpStatus(_code, _text) {}
2172
2210
  function httpHeader(_name, _value, _options) {}
2173
2211
 
2174
- export { ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF, HydrationScript, MathMLElements, NULL_BODY_STATUSES, Namespaces, Portal, RESPONSE_HEADER_VALUE_LIMIT, REVALIDATE_ALL, REVALIDATE_HEADER, RawTextElements, RequestContext, ResponseEnvelope, SAFE_ERROR, SVGElements, VoidElements, acquireAsset, addEvent, applyRef, assign, claimElement, claimElementTree, className, clearFlashCookie, clientOnly, commitEventResponse, composeMiddleware, configureServerErrors, createRequestEvent, createResponseStub, createSSRResponse, delegateEvents, dynamic, dynamicProperty, effect, escape, generateHydrationScript, getDelegatedRoot, getExpectedRedirectStatus, getFirstChild, getHydrationKey, getNextElement, getNextMarker, getNextMatch, getNextSibling, getRequestEvent, getServerFunctionMetadata, getServerFunctionRPC, getTraceContext, hasFlashCookie, httpHeader, httpStatus, hydrate, insert, installHydrationRuntime, isDev, isHref, isResponseEnvelope, isSafeError, isServer, isServerFunction, markSafeError, memo, parseCookieHeader, readShallow, redirect, ref, registerDelegatedContainer, registerDelegatedRoot, registerElementClaim, reload, render, renderToStream, renderToString, resolveSSRNode, respond, runHydrationEvents, scope, serializeCookie, setAttribute, setAttributeNS, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrElementAttribute, ssrGroup, ssrHydrationKey, ssrStyle, ssrStyleProperty, style, template, unregisterDelegatedContainer, unregisterDelegatedRoot, useHead, waitAsset, warmAsset };
2212
+ export { ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF, HydrationScript, MathMLElements, NULL_BODY_STATUSES, Namespaces, Portal, RESPONSE_HEADER_VALUE_LIMIT, REVALIDATE_ALL, REVALIDATE_HEADER, RawTextElements, RequestContext, ResponseEnvelope, SAFE_ERROR, SVGElements, VoidElements, acquireAsset, addEvent, applyRef, assign, claimElement, claimElementTree, className, clearFlashCookie, clientOnly, commitEventResponse, composeMiddleware, configureServerErrors, createRequestEvent, createResponseStub, createSSRResponse, delegateEvents, dispatchAsInteraction, dynamic, dynamicComponent, dynamicProperty, effect, escape, generateHydrationScript, getDelegatedRoot, getExpectedRedirectStatus, getFirstChild, getHydrationKey, getHydrationWriter, getNextElement, getNextMarker, getNextMatch, getNextSibling, getRequestEvent, getServerFunctionMetadata, getServerFunctionRPC, getTraceContext, hasFlashCookie, httpHeader, httpStatus, hydrate, insert, installHydrationRuntime, isDev, isHref, isResponseEnvelope, isSafeError, isServer, isServerFunction, markSafeError, memo, parseCookieHeader, readShallow, redirect, ref, registerDelegatedContainer, registerDelegatedRoot, registerElementClaim, reload, render, renderToStream, renderToString, reportRequestFailure, resolveSSRNode, respond, runHydrationEvents, scope, serializeCookie, setAttribute, setAttributeNS, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrElementAttribute, ssrGroup, ssrHydrationKey, ssrStyle, ssrStyleProperties, ssrStyleProperty, style, takeHydrationValue, template, unregisterDelegatedContainer, unregisterDelegatedRoot, useHead, waitAsset, warmAsset };