solid-js 2.0.0-beta.10 → 2.0.0-beta.12

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/CHEATSHEET.md CHANGED
@@ -255,12 +255,12 @@ Optimistic writes revert when the transition completes.
255
255
  ```tsx
256
256
  // List, keyed by identity (default)
257
257
  <For each={items()}>
258
- {(item, i) => <Row item={item()} index={i()} />}
258
+ {(item, i) => <Row item={item} index={i()} />}
259
259
  </For>
260
260
 
261
261
  // List, non-keyed (replaces <Index>)
262
262
  <For each={items()} keyed={false}>
263
- {(item, i) => <Row item={item()} index={i()} />}
263
+ {(item, i) => <Row item={item()} index={i} />}
264
264
  </For>
265
265
 
266
266
  // List with custom key
@@ -316,7 +316,8 @@ import { Dynamic } from "@solidjs/web";
316
316
  <Dynamic component={isEditing() ? Editor : Viewer} value={value()} />
317
317
  ```
318
318
 
319
- `<For>` non-keyed: `item` and `i` are **accessors** call them: `item()`, `i()`.
319
+ `<For>` non-keyed: `item` is an **accessor** and `i` is a plain number.
320
+ `<For>` default/keyed-by-identity: `item` is a **plain value** and `i` is an accessor.
320
321
  `<Repeat>`: `i` is a **plain number**.
321
322
 
322
323
  ---
@@ -618,8 +619,8 @@ If your training data is 1.x, these are the corrections. **Read this before gene
618
619
  - **No top-level reactive reads in component body** — reading signals/props directly at the top of a component warns. Read inside JSX, a memo, or `untrack`.
619
620
  - **Props are values, not accessors** — at the call site call accessors (`<X v={count()} />`, not `<X v={count} />`). The single most common AI-generated bug.
620
621
  - **Don't destructure props** — `function Comp({ name })` warns; use `props.name` to keep reactivity. (Same root cause as above; see the Props section.)
621
- - **`<For>` non-keyed children are accessors** — `(item, i) => ...` where `item` and `i` are functions. Call them: `item()`, `i()`.
622
- - **`<Show>` / `<Match>` function children receive narrowed accessors** — also call them.
622
+ - **`<For>` callback shape follows keying** — default/keyed-by-identity receives a raw item and index accessor; `keyed={false}` receives an item accessor and stable numeric index; custom keys receive accessors.
623
+ - **`<Show>` / `<Match>` function children narrow values** — non-keyed children receive accessors; keyed children receive raw values.
623
624
  - **Stores: setters take a draft callback** — mutate the draft in place by default. Returning a new value is shallow (array index-replace, object top-level diff); reach for it for filter/remove. Keyed reconcile is a _projection-fn_ feature, not a setter feature.
624
625
  - **`undefined` is a real value in `merge`** — it overrides rather than "skip this key".
625
626
  - **Async lives in computations** — return a Promise/AsyncIterable from `createMemo`/`createStore(fn)`/`createProjection`. Reads suspend; wrap in `<Loading>`.
package/dist/dev.cjs CHANGED
@@ -24,7 +24,8 @@ function children(fn) {
24
24
  });
25
25
  const memo = signals.createMemo(() => signals.flatten(c()), {
26
26
  name: "children",
27
- lazy: true
27
+ lazy: true,
28
+ sync: true
28
29
  } );
29
30
  memo.toArray = () => {
30
31
  const v = memo();
@@ -761,7 +762,9 @@ function lazy(fn, moduleUrl) {
761
762
  [$DEVCOMP]: true
762
763
  });
763
764
  return Comp(props);
764
- }) : "");
765
+ }) : "", {
766
+ sync: true
767
+ });
765
768
  };
766
769
  wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
767
770
  wrap.moduleUrl = moduleUrl;
@@ -798,21 +801,23 @@ function Show(props) {
798
801
  } );
799
802
  const condition = keyed ? conditionValue : signals.createMemo(conditionValue, {
800
803
  equals: (a, b) => !a === !b,
801
- name: "condition"
804
+ name: "condition",
805
+ sync: true
802
806
  } );
803
807
  return signals.createMemo(() => {
804
808
  const c = condition();
805
809
  if (c) {
806
810
  const child = props.children;
807
811
  const fn = typeof child === "function" && child.length > 0;
808
- return fn ? signals.untrack(() => child(() => {
812
+ return fn ? keyed ? signals.untrack(() => child(c), "<Show>") : signals.untrack(() => child(() => {
809
813
  if (!signals.untrack(condition)) throw narrowedError("Show");
810
814
  return conditionValue();
811
815
  }), "<Show>") : child;
812
816
  }
813
817
  return props.fallback;
814
818
  }, {
815
- name: "value"
819
+ name: "value",
820
+ sync: true
816
821
  } );
817
822
  }
818
823
  function Switch(props) {
@@ -829,24 +834,33 @@ function Switch(props) {
829
834
  } );
830
835
  const condition = mp.keyed ? conditionValue : signals.createMemo(conditionValue, {
831
836
  equals: (a, b) => !a === !b,
832
- name: "condition"
837
+ name: "condition",
838
+ sync: true
833
839
  } );
834
- func = () => prevFunc() || (condition() ? [index, conditionValue, mp] : undefined);
840
+ func = () => {
841
+ const prev = prevFunc();
842
+ if (prev) return prev;
843
+ const c = condition();
844
+ return c ? [index, c, conditionValue, mp] : undefined;
845
+ };
835
846
  }
836
847
  return func;
848
+ }, {
849
+ sync: true
837
850
  });
838
851
  return signals.createMemo(() => {
839
852
  const sel = switchFunc()();
840
853
  if (!sel) return props.fallback;
841
- const [index, conditionValue, mp] = sel;
854
+ const [index, value, conditionValue, mp] = sel;
842
855
  const child = mp.children;
843
856
  const fn = typeof child === "function" && child.length > 0;
844
- return fn ? signals.untrack(() => child(() => {
857
+ return fn ? mp.keyed ? signals.untrack(() => child(value), "<Match>") : signals.untrack(() => child(() => {
845
858
  if (signals.untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match");
846
859
  return conditionValue();
847
860
  }), "<Match>") : child;
848
861
  }, {
849
- name: "eval conditions"
862
+ name: "eval conditions",
863
+ sync: true
850
864
  } );
851
865
  }
852
866
  function Match(props) {
@@ -873,7 +887,6 @@ function Reveal(props) {
873
887
  }
874
888
 
875
889
  function ssrHandleError() {}
876
- function ssrRunInScope() {}
877
890
  const DEV = signals.DEV ;
878
891
  if (globalThis) {
879
892
  if (!globalThis.Solid$$) globalThis.Solid$$ = true;else console.warn("You appear to have multiple instances of Solid. This can lead to unexpected behavior.");
@@ -1058,5 +1071,4 @@ exports.enableHydration = enableHydration;
1058
1071
  exports.lazy = lazy;
1059
1072
  exports.sharedConfig = sharedConfig;
1060
1073
  exports.ssrHandleError = ssrHandleError;
1061
- exports.ssrRunInScope = ssrRunInScope;
1062
1074
  exports.useContext = useContext;
package/dist/dev.js CHANGED
@@ -23,7 +23,8 @@ function children(fn) {
23
23
  });
24
24
  const memo = createMemo$1(() => flatten(c()), {
25
25
  name: "children",
26
- lazy: true
26
+ lazy: true,
27
+ sync: true
27
28
  } );
28
29
  memo.toArray = () => {
29
30
  const v = memo();
@@ -760,7 +761,9 @@ function lazy(fn, moduleUrl) {
760
761
  [$DEVCOMP]: true
761
762
  });
762
763
  return Comp(props);
763
- }) : "");
764
+ }) : "", {
765
+ sync: true
766
+ });
764
767
  };
765
768
  wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
766
769
  wrap.moduleUrl = moduleUrl;
@@ -797,21 +800,23 @@ function Show(props) {
797
800
  } );
798
801
  const condition = keyed ? conditionValue : createMemo$1(conditionValue, {
799
802
  equals: (a, b) => !a === !b,
800
- name: "condition"
803
+ name: "condition",
804
+ sync: true
801
805
  } );
802
806
  return createMemo$1(() => {
803
807
  const c = condition();
804
808
  if (c) {
805
809
  const child = props.children;
806
810
  const fn = typeof child === "function" && child.length > 0;
807
- return fn ? untrack(() => child(() => {
811
+ return fn ? keyed ? untrack(() => child(c), "<Show>") : untrack(() => child(() => {
808
812
  if (!untrack(condition)) throw narrowedError("Show");
809
813
  return conditionValue();
810
814
  }), "<Show>") : child;
811
815
  }
812
816
  return props.fallback;
813
817
  }, {
814
- name: "value"
818
+ name: "value",
819
+ sync: true
815
820
  } );
816
821
  }
817
822
  function Switch(props) {
@@ -828,24 +833,33 @@ function Switch(props) {
828
833
  } );
829
834
  const condition = mp.keyed ? conditionValue : createMemo$1(conditionValue, {
830
835
  equals: (a, b) => !a === !b,
831
- name: "condition"
836
+ name: "condition",
837
+ sync: true
832
838
  } );
833
- func = () => prevFunc() || (condition() ? [index, conditionValue, mp] : undefined);
839
+ func = () => {
840
+ const prev = prevFunc();
841
+ if (prev) return prev;
842
+ const c = condition();
843
+ return c ? [index, c, conditionValue, mp] : undefined;
844
+ };
834
845
  }
835
846
  return func;
847
+ }, {
848
+ sync: true
836
849
  });
837
850
  return createMemo$1(() => {
838
851
  const sel = switchFunc()();
839
852
  if (!sel) return props.fallback;
840
- const [index, conditionValue, mp] = sel;
853
+ const [index, value, conditionValue, mp] = sel;
841
854
  const child = mp.children;
842
855
  const fn = typeof child === "function" && child.length > 0;
843
- return fn ? untrack(() => child(() => {
856
+ return fn ? mp.keyed ? untrack(() => child(value), "<Match>") : untrack(() => child(() => {
844
857
  if (untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match");
845
858
  return conditionValue();
846
859
  }), "<Match>") : child;
847
860
  }, {
848
- name: "eval conditions"
861
+ name: "eval conditions",
862
+ sync: true
849
863
  } );
850
864
  }
851
865
  function Match(props) {
@@ -872,10 +886,9 @@ function Reveal(props) {
872
886
  }
873
887
 
874
888
  function ssrHandleError() {}
875
- function ssrRunInScope() {}
876
889
  const DEV = DEV$1 ;
877
890
  if (globalThis) {
878
891
  if (!globalThis.Solid$$) globalThis.Solid$$ = true;else console.warn("You appear to have multiple instances of Solid. This can lead to unexpected behavior.");
879
892
  }
880
893
 
881
- export { $DEVCOMP, DEV, Errored, For, Hydration, Loading, Match, NoHydrateContext, NoHydration, Repeat, Reveal, Show, Switch, children, createComponent, createContext, createEffect, createErrorBoundary, createLoadingBoundary, createMemo, createOptimistic, createOptimisticStore, createProjection, createRenderEffect, createSignal, createStore, createUniqueId, enableHydration, lazy, sharedConfig, ssrHandleError, ssrRunInScope, useContext };
894
+ export { $DEVCOMP, DEV, Errored, For, Hydration, Loading, Match, NoHydrateContext, NoHydration, Repeat, Reveal, Show, Switch, children, createComponent, createContext, createEffect, createErrorBoundary, createLoadingBoundary, createMemo, createOptimistic, createOptimisticStore, createProjection, createRenderEffect, createSignal, createStore, createUniqueId, enableHydration, lazy, sharedConfig, ssrHandleError, useContext };