@solidjs/signals 2.0.0-beta.9 → 2.0.0-rc.0

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 (91) hide show
  1. package/README.md +13 -9
  2. package/dist/dev.js +5971 -1426
  3. package/dist/node.cjs +7681 -3293
  4. package/dist/prod/affects.js +126 -0
  5. package/dist/prod/boundaries.js +572 -0
  6. package/dist/prod/core/action.js +139 -0
  7. package/dist/prod/core/async.js +553 -0
  8. package/dist/prod/core/constants.js +92 -0
  9. package/dist/prod/core/context.js +67 -0
  10. package/dist/prod/core/core.js +817 -0
  11. package/dist/prod/core/dev.js +3 -0
  12. package/dist/prod/core/effect.js +145 -0
  13. package/dist/prod/core/error.js +68 -0
  14. package/dist/prod/core/external.js +98 -0
  15. package/dist/prod/core/graph.js +104 -0
  16. package/dist/prod/core/heap.js +140 -0
  17. package/dist/prod/core/invariants.js +42 -0
  18. package/dist/prod/core/lanes.js +140 -0
  19. package/dist/prod/core/optimistic.js +245 -0
  20. package/dist/prod/core/owner.js +302 -0
  21. package/dist/prod/core/scheduler.js +749 -0
  22. package/dist/prod/core/verdict.js +369 -0
  23. package/dist/prod/index.js +45 -0
  24. package/dist/prod/map.js +317 -0
  25. package/dist/prod/signals.js +375 -0
  26. package/dist/prod/store/optimistic.js +217 -0
  27. package/dist/prod/store/projection.js +231 -0
  28. package/dist/prod/store/reconcile.js +707 -0
  29. package/dist/prod/store/store.js +1081 -0
  30. package/dist/prod/store/storePath.js +103 -0
  31. package/dist/prod/store/utils.js +328 -0
  32. package/dist/types/affects.d.ts +47 -0
  33. package/dist/types/boundaries.d.ts +60 -13
  34. package/dist/types/core/action.d.ts +35 -6
  35. package/dist/types/core/async.d.ts +16 -1
  36. package/dist/types/core/constants.d.ts +35 -6
  37. package/dist/types/core/context.d.ts +10 -2
  38. package/dist/types/core/core.d.ts +58 -63
  39. package/dist/types/core/dev.d.ts +17 -2
  40. package/dist/types/core/effect.d.ts +1 -2
  41. package/dist/types/core/error.d.ts +33 -0
  42. package/dist/types/core/external.d.ts +0 -11
  43. package/dist/types/core/graph.d.ts +2 -1
  44. package/dist/types/core/heap.d.ts +8 -0
  45. package/dist/types/core/index.d.ts +3 -2
  46. package/dist/types/core/invariants.d.ts +59 -0
  47. package/dist/types/core/lanes.d.ts +2 -0
  48. package/dist/types/core/optimistic.d.ts +6 -0
  49. package/dist/types/core/owner.d.ts +50 -3
  50. package/dist/types/core/scheduler.d.ts +82 -10
  51. package/dist/types/core/types.d.ts +66 -1
  52. package/dist/types/core/verdict.d.ts +2 -0
  53. package/dist/types/index.d.ts +3 -2
  54. package/dist/types/map.d.ts +21 -5
  55. package/dist/types/signals.d.ts +164 -12
  56. package/dist/types/store/index.d.ts +1 -1
  57. package/dist/types/store/optimistic.d.ts +3 -3
  58. package/dist/types/store/projection.d.ts +10 -6
  59. package/dist/types/store/reconcile.d.ts +31 -8
  60. package/dist/types/store/store.d.ts +101 -6
  61. package/dist/types-cjs/affects.d.cts +47 -0
  62. package/dist/types-cjs/boundaries.d.cts +60 -13
  63. package/dist/types-cjs/core/action.d.cts +35 -6
  64. package/dist/types-cjs/core/async.d.cts +16 -1
  65. package/dist/types-cjs/core/constants.d.cts +35 -6
  66. package/dist/types-cjs/core/context.d.cts +10 -2
  67. package/dist/types-cjs/core/core.d.cts +58 -63
  68. package/dist/types-cjs/core/dev.d.cts +17 -2
  69. package/dist/types-cjs/core/effect.d.cts +1 -2
  70. package/dist/types-cjs/core/error.d.cts +33 -0
  71. package/dist/types-cjs/core/external.d.cts +0 -11
  72. package/dist/types-cjs/core/graph.d.cts +2 -1
  73. package/dist/types-cjs/core/heap.d.cts +8 -0
  74. package/dist/types-cjs/core/index.d.cts +3 -2
  75. package/dist/types-cjs/core/invariants.d.cts +59 -0
  76. package/dist/types-cjs/core/lanes.d.cts +2 -0
  77. package/dist/types-cjs/core/optimistic.d.cts +6 -0
  78. package/dist/types-cjs/core/owner.d.cts +50 -3
  79. package/dist/types-cjs/core/scheduler.d.cts +82 -10
  80. package/dist/types-cjs/core/types.d.cts +66 -1
  81. package/dist/types-cjs/core/verdict.d.cts +2 -0
  82. package/dist/types-cjs/index.d.cts +3 -2
  83. package/dist/types-cjs/map.d.cts +21 -5
  84. package/dist/types-cjs/signals.d.cts +164 -12
  85. package/dist/types-cjs/store/index.d.cts +1 -1
  86. package/dist/types-cjs/store/optimistic.d.cts +3 -3
  87. package/dist/types-cjs/store/projection.d.cts +10 -6
  88. package/dist/types-cjs/store/reconcile.d.cts +31 -8
  89. package/dist/types-cjs/store/store.d.cts +101 -6
  90. package/package.json +11 -9
  91. package/dist/prod.js +0 -3627
package/README.md CHANGED
@@ -107,12 +107,12 @@ const data = createMemo(async () => {
107
107
  return response.json();
108
108
  });
109
109
 
110
- // Check async state
111
- isPending(data); // true while loading
112
- latest(data); // last resolved value
110
+ // Check async state for this read
111
+ isPending(data); // true while an unrevealed value change is in flight for this read
112
+ latest(data); // last resolved value; follows the not-ready path if no value has resolved yet
113
113
  ```
114
114
 
115
- Use `action()` to coordinate async workflows with the reactive graph:
115
+ Use `action()` for mutations — imperative async workflows whose writes span an async gap. Each invocation runs as a single transaction: every write between yields batches into one atomic update, and nothing commits until the action completes or the next `yield` resolves.
116
116
 
117
117
  ```typescript
118
118
  const save = action(function* (item) {
@@ -120,6 +120,10 @@ const save = action(function* (item) {
120
120
  });
121
121
  ```
122
122
 
123
+ Navigation-shaped updates don't need an action. A plain setter call is enough — reads pull the async, downstream async computeds hold their previous values until new ones are ready, and `isPending`/`latest` expose the in-flight state. Reach for `action` when writes happen *after* async work (pairing with optimistic primitives for tentative state that reverts on failure), not when the async is merely downstream of a synchronous write.
124
+
125
+ Framework-level actions (router form actions, server actions) are specializations of this primitive: the same transactional semantics with form binding, serialization, and submission tracking layered on top.
126
+
123
127
  ## Optimistic Updates
124
128
 
125
129
  Optimistic signals show an immediate value while async work is pending, then automatically revert when it settles:
@@ -183,7 +187,7 @@ import { createErrorBoundary, createLoadingBoundary } from "@solidjs/signals";
183
187
 
184
188
  createErrorBoundary(
185
189
  () => riskyComputation(),
186
- (error, reset) => handleError(error)
190
+ (error, reset) => handleError(error())
187
191
  );
188
192
 
189
193
  createLoadingBoundary(
@@ -223,10 +227,10 @@ createRoot(dispose => {
223
227
  | ------------------------ | ------------------------------------------------------------------ |
224
228
  | `flush()` | Process all pending updates |
225
229
  | `untrack(fn)` | Run `fn` without tracking dependencies |
226
- | `isPending(accessor)` | Check if an async accessor is loading |
227
- | `latest(accessor)` | Get the last resolved value of an async accessor |
228
- | `refresh(accessor)` | Re-trigger an async computation |
229
- | `isRefreshing(accessor)` | Check if an async accessor is refreshing |
230
+ | `isPending(accessor)` | Check if an unrevealed value change is in flight for a read |
231
+ | `latest(accessor)` | Get the last resolved value, or follow not-ready if none exists |
232
+ | `refresh(accessor)` | Re-trigger an async computation (a quiet re-ask — not pending) |
233
+ | `affects(target, key?)` | Declare that in-flight work will change the targeted data (reads pending until settle) |
230
234
  | `resolve(fn)` | Returns a promise that resolves when a reactive expression settles |
231
235
  | `mapArray(list, mapFn)` | Reactive array mapping with keyed reconciliation |
232
236
  | `repeat(count, mapFn)` | Reactive repeat based on a reactive count |