mutts 1.0.13 → 1.0.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 (54) hide show
  1. package/BROWSER_ASYNC_POLYFILL.md +79 -0
  2. package/README.md +2 -2
  3. package/dist/browser.cjs +145 -26
  4. package/dist/browser.cjs.map +1 -1
  5. package/dist/browser.d.ts +42 -9
  6. package/dist/browser.dev.cjs +12 -2
  7. package/dist/browser.dev.cjs.map +1 -1
  8. package/dist/browser.dev.d.ts +2 -2
  9. package/dist/browser.dev.esm.js +2 -2
  10. package/dist/browser.esm.js +137 -28
  11. package/dist/browser.esm.js.map +1 -1
  12. package/dist/chunks/{index-CAdnMJev.cjs → index-BnTNC9eC.cjs} +158 -90
  13. package/dist/chunks/index-BnTNC9eC.cjs.map +1 -0
  14. package/dist/chunks/{index-XsYTUhHx.esm.js → index-CAWVZL7P.esm.js} +156 -88
  15. package/dist/chunks/index-CAWVZL7P.esm.js.map +1 -0
  16. package/dist/chunks/node-Df_5r_WA.cjs +187 -0
  17. package/dist/chunks/node-Df_5r_WA.cjs.map +1 -0
  18. package/dist/chunks/node-DuIduHw3.esm.js +185 -0
  19. package/dist/chunks/node-DuIduHw3.esm.js.map +1 -0
  20. package/dist/chunks/{proxy-BtmPFjSr.esm.js → proxy-C2lnvvbx.esm.js} +652 -222
  21. package/dist/chunks/proxy-C2lnvvbx.esm.js.map +1 -0
  22. package/dist/chunks/{proxy-DBHj3kGK.cjs → proxy-HA_QQnd5.cjs} +662 -223
  23. package/dist/chunks/proxy-HA_QQnd5.cjs.map +1 -0
  24. package/dist/debug.cjs +37 -10
  25. package/dist/debug.cjs.map +1 -1
  26. package/dist/debug.esm.js +37 -10
  27. package/dist/debug.esm.js.map +1 -1
  28. package/dist/mutts.umd.js +4086 -3469
  29. package/dist/mutts.umd.js.map +1 -1
  30. package/dist/mutts.umd.min.js +1 -1
  31. package/dist/mutts.umd.min.js.map +1 -1
  32. package/dist/node.cjs +13 -3
  33. package/dist/node.cjs.map +1 -1
  34. package/dist/node.d.ts +2 -2
  35. package/dist/node.dev.cjs +13 -3
  36. package/dist/node.dev.cjs.map +1 -1
  37. package/dist/node.dev.d.ts +2 -2
  38. package/dist/node.dev.esm.js +3 -3
  39. package/dist/node.esm.js +3 -3
  40. package/dist/types.d.ts +30 -15
  41. package/docs/ai/api-reference.md +3 -1
  42. package/docs/ai/manual.md +17 -5
  43. package/docs/reactive/advanced.md +169 -10
  44. package/docs/reactive/debugging.md +15 -13
  45. package/docs/reactive.md +2 -1
  46. package/package.json +12 -7
  47. package/dist/chunks/index-CAdnMJev.cjs.map +0 -1
  48. package/dist/chunks/index-XsYTUhHx.esm.js.map +0 -1
  49. package/dist/chunks/node-DrrphEPf.cjs +0 -98
  50. package/dist/chunks/node-DrrphEPf.cjs.map +0 -1
  51. package/dist/chunks/node-NEZvVo4M.esm.js +0 -96
  52. package/dist/chunks/node-NEZvVo4M.esm.js.map +0 -1
  53. package/dist/chunks/proxy-BtmPFjSr.esm.js.map +0 -1
  54. package/dist/chunks/proxy-DBHj3kGK.cjs.map +0 -1
@@ -25,7 +25,7 @@ These hooks are called during the execution of effects and computed values.
25
25
 
26
26
  - **`beginChain(targets: Function[]) / endChain()`**: Called when a batch of effects starts and ends its execution.
27
27
  - **`maxEffectChain`**: (Default: `100`) Limits the depth of synchronous effect triggering to prevent stack overflows.
28
- - **`maxTriggerPerBatch`**: (Default: `10`) Limits how many times a single effect can be triggered within the same batch. Useful for detecting aggressive re-computation or infinite cycles in `cycleHandling: 'production'` mode.
28
+ - **`maxTriggerPerBatch`**: (Default: `10`) Limits how many times a single effect can be triggered within the same batch. Useful for detecting aggressive re-computation or infinite cycles, especially in `scheduler: 'raw'` mode.
29
29
 
30
30
  ## Cycle Detection
31
31
 
@@ -33,25 +33,27 @@ These hooks are called during the execution of effects and computed values.
33
33
 
34
34
  ### Configuration
35
35
 
36
- You can control how cycles are handled via `reactiveOptions.cycleHandling`:
36
+ You can control how cycles are handled via `reactiveOptions.scheduler`:
37
37
 
38
- - **`'production'`**: High-performance FIFO mode. Disables the dependency graph and topological sorting. Uses heuristic detection via `maxEffectChain`.
39
- - **`'development'`** (Default): Maintains direct dependency graph for early cycle detection during edge creation. Throws immediately with basic path information.
40
- - **`'debug'`**: Full diagnostic mode with transitive closures and topological sorting. Provides detailed cycle path reporting.
38
+ - **`'ordered'`** (Default): Maintains the causal effect graph for dependency ordering, parent/child lifecycle ordering, and early cycle detection. Throws immediately with basic path information.
39
+ - **`'raw'`**: High-performance FIFO mode. Disables the dependency graph and topological sorting. Uses heuristic detection via `maxEffectChain`.
40
+ - **`'debug'`**: Ordered scheduling plus the heaviest diagnostics. Provides detailed cycle path reporting.
41
+
42
+ `reactiveOptions.cycleHandling` is still accepted as a deprecated alias: `'production'` maps to `'raw'`, and `'development'` maps to `'ordered'`.
41
43
 
42
44
  ### Topological vs. Flat Mode Detection
43
45
  - **Detection**: Cycles are detected when the execution depth exceeds `maxEffectChain` (default 100).
44
46
  - **Diagnostics**: The resulting `ReactiveError` includes a `trace` property (the recent execution sequence) and attempts to identify a repeating `cycle`.
45
- - **Recommendation**: Use this mode only for production to minimize performance overhead.
47
+ - **Recommendation**: Use `raw` only when FIFO scheduling is sufficient and you want minimum overhead.
46
48
 
47
49
  ### Cycle Handling Modes
48
50
 
49
- You can configure how the system handles cycles via `reactiveOptions.cycleHandling`:
51
+ You can configure how the system handles cycles via `reactiveOptions.scheduler`:
50
52
 
51
53
  | Mode | Detection Timing | Cycle Information | Performance |
52
54
  |------|-----------------|-------------------|-------------|
53
- | `'production'` | Late (Heuristic) | Trace of last N effects | Fastest |
54
- | `'development'` | Eager (On edge) | Exact path (DFS) | Moderate |
55
+ | `'ordered'` | Eager (On edge) | Exact path (DFS) | Moderate |
56
+ | `'raw'` | Late (Heuristic) | Trace of last N effects | Fastest |
55
57
  | `'debug'` | Structural | Transitive closures | Slowest |
56
58
 
57
59
  #### Finding Cycle Information
@@ -71,7 +73,7 @@ try {
71
73
 
72
74
  - **`error.cycle`**: An array of effect names forming the cycle.
73
75
  - **`error.causalChain`**: The sequence of triggers that led to the current effect.
74
- - **`error.lineage`**: The creation stack of the effect (available in `development` or `debug` modes).
76
+ - **`error.lineage`**: The creation stack of the effect (available in `ordered` or `debug` modes).
75
77
 
76
78
  ### Memoization Discrepancy Detection
77
79
 
@@ -190,13 +192,13 @@ Since these are runtime options, you can toggle them based on your environment:
190
192
 
191
193
  ```typescript
192
194
  if (process.env.NODE_ENV === 'development') {
193
- reactiveOptions.cycleHandling = 'debug';
195
+ reactiveOptions.scheduler = 'debug';
194
196
  reactiveOptions.onMemoizationDiscrepancy = myHandler;
195
197
  enableIntrospection();
196
198
  } else {
197
- // Ensure they are off in production for performance
199
+ // Keep heavy diagnostics off in production for performance
198
200
  reactiveOptions.onMemoizationDiscrepancy = undefined;
199
- reactiveOptions.cycleHandling = 'production';
201
+ reactiveOptions.scheduler = 'ordered'; // or 'raw' when FIFO scheduling is enough
200
202
  }
201
203
  ```
202
204
 
package/docs/reactive.md CHANGED
@@ -19,6 +19,7 @@ The Mutts Reactive System documentation has been split into focused sections for
19
19
  ## [Advanced Topics](./reactive/advanced.md)
20
20
  * **[Choosing the Right Primitive](./reactive/advanced.md#choosing-the-right-reactive-primitive)**: Comparison table of effect-value functions (memoize, lift, project, etc.)
21
21
  * **[Atomic Operations](./reactive/advanced.md#atomic-operations)**: Batching and Bidirectional binding
22
+ * **[Effect Ordering](./reactive/advanced.md#effect-ordering-with-phase-tokens)**: Use reactive phase tokens to make dependency ordering explicit
22
23
  * **[Evolution Tracking](./reactive/advanced.md#evolution-tracking)**: History introspection
23
24
  * **[Prototype Chains](./reactive/advanced.md#prototype-chains-and-pure-objects)**: Advanced inheritance patterns
24
25
  * **[Memoization](./reactive/advanced.md#memoization)**: Caching strategies
@@ -30,4 +31,4 @@ The Mutts Reactive System documentation has been split into focused sections for
30
31
  * **[Memoization Discrepancy](./reactive/debugging.md#memoization-discrepancy-detection)**: Identifying missing dependencies
31
32
  * **[Introspection API](./reactive/debugging.md#introspection-api)**: Programmatic analysis and dependency graphs
32
33
 
33
- * **[Performance](./reactive/debugging.md#performance-cost)**: Understanding the cost of debugging tools
34
+ * **[Performance](./reactive/debugging.md#performance-cost)**: Understanding the cost of debugging tools
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mutts",
3
3
  "description": "Modern UTility TS: A collection of TypeScript utilities",
4
- "version": "1.0.13",
4
+ "version": "1.0.14",
5
5
  "main": "dist/browser.cjs",
6
6
  "module": "dist/browser.esm.js",
7
7
  "exports": {
@@ -90,7 +90,8 @@
90
90
  "files": [
91
91
  "dist",
92
92
  "README.md",
93
- "docs"
93
+ "docs",
94
+ "BROWSER_ASYNC_POLYFILL.md"
94
95
  ],
95
96
  "scripts": {
96
97
  "build:js": "rollup -c",
@@ -142,6 +143,8 @@
142
143
  "./src/entry-browser.dev.ts",
143
144
  "./src/entry-node.ts",
144
145
  "./src/entry-node.dev.ts",
146
+ "./debug/index.ts",
147
+ "./debug/debug.ts",
145
148
  "./dist/browser.esm.js",
146
149
  "./dist/browser.dev.esm.js",
147
150
  "./dist/browser.cjs",
@@ -149,7 +152,9 @@
149
152
  "./dist/node.esm.js",
150
153
  "./dist/node.dev.esm.js",
151
154
  "./dist/node.cjs",
152
- "./dist/node.dev.cjs"
155
+ "./dist/node.dev.cjs",
156
+ "./dist/debug.esm.js",
157
+ "./dist/debug.cjs"
153
158
  ],
154
159
  "engines": {
155
160
  "node": ">=16.0.0"
@@ -162,8 +167,8 @@
162
167
  "@rollup/plugin-terser": "^1.0.0",
163
168
  "@rollup/plugin-typescript": "^12.1.4",
164
169
  "@types/node": "^22.10.10",
165
- "@vitest/browser": "^4.0.18",
166
- "@vitest/browser-playwright": "^4.0.18",
170
+ "@vitest/browser": "^4.1.4",
171
+ "@vitest/browser-playwright": "^4.1.4",
167
172
  "playwright": "^1.58.1",
168
173
  "rollup": "^4.52.2",
169
174
  "rollup-plugin-copy": "^3.5.0",
@@ -174,7 +179,7 @@
174
179
  "tsx": "^4.20.4",
175
180
  "typescript": "^5.8.3",
176
181
  "vis-network": "^9.1.9",
177
- "vitest": "^4.0.18"
182
+ "vitest": "^4.1.4"
178
183
  },
179
184
  "packageManager": "pnpm@10.7.1+sha512.2d92c86b7928dc8284f53494fb4201f983da65f0fb4f0d40baafa5cf628fa31dae3e5968f12466f17df7e97310e30f343a648baea1b9b350685dafafffdf5808"
180
- }
185
+ }