mutts 1.0.7 → 1.0.9
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/README.md +72 -17
- package/dist/browser.cjs +3111 -0
- package/dist/browser.cjs.map +1 -0
- package/dist/browser.d.ts +1391 -1
- package/dist/browser.esm.js +264 -35
- package/dist/browser.esm.js.map +1 -1
- package/dist/chunks/async-browser-lvzLOCgk.cjs +297 -0
- package/dist/chunks/async-browser-lvzLOCgk.cjs.map +1 -0
- package/dist/chunks/async-core-CRLKP3l-.cjs +29 -0
- package/dist/chunks/async-core-CRLKP3l-.cjs.map +1 -0
- package/dist/chunks/async-node-C3DeIb0y.cjs +96 -0
- package/dist/chunks/async-node-C3DeIb0y.cjs.map +1 -0
- package/dist/chunks/index-2vea86wD.esm.js +3011 -0
- package/dist/chunks/index-2vea86wD.esm.js.map +1 -0
- package/dist/chunks/index-CtA2AWl3.esm.js +4376 -0
- package/dist/chunks/index-CtA2AWl3.esm.js.map +1 -0
- package/dist/chunks/index-VTO-b2vR.cjs +4461 -0
- package/dist/chunks/index-VTO-b2vR.cjs.map +1 -0
- package/dist/debug/debug.d.ts +122 -0
- package/dist/debug/debug.d.ts.map +1 -0
- package/dist/debug/index.d.ts +4 -0
- package/dist/debug/index.d.ts.map +1 -0
- package/dist/debug/lineage-panel.d.ts +5 -0
- package/dist/debug/lineage-panel.d.ts.map +1 -0
- package/dist/debug/lineage.d.ts +79 -0
- package/dist/debug/lineage.d.ts.map +1 -0
- package/dist/debug.cjs +35 -0
- package/dist/debug.cjs.map +1 -0
- package/dist/debug.d.ts +209 -0
- package/dist/debug.esm.js +2 -0
- package/dist/debug.esm.js.map +1 -0
- package/dist/devtools/devtool/devtools.d.ts +1 -0
- package/dist/devtools/devtool/devtools.d.ts.map +1 -0
- package/dist/devtools/devtool/panel.d.ts +2 -0
- package/dist/devtools/devtool/panel.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/mutts.umd.js +1 -1
- package/dist/mutts.umd.js.map +1 -1
- package/dist/mutts.umd.min.js +1 -1
- package/dist/mutts.umd.min.js.map +1 -1
- package/dist/node.cjs +107 -0
- package/dist/node.cjs.map +1 -0
- package/dist/node.d.ts +2 -2
- package/dist/node.esm.js +86 -33
- package/dist/node.esm.js.map +1 -1
- package/dist/src/async/browser.d.ts +2 -0
- package/dist/src/async/browser.d.ts.map +1 -0
- package/dist/src/async/index.d.ts +19 -0
- package/dist/src/async/index.d.ts.map +1 -0
- package/dist/src/async/node.d.ts +2 -0
- package/dist/src/async/node.d.ts.map +1 -0
- package/dist/src/decorator.d.ts +106 -0
- package/dist/src/decorator.d.ts.map +1 -0
- package/dist/src/destroyable.d.ts +87 -0
- package/dist/src/destroyable.d.ts.map +1 -0
- package/dist/src/entry-browser.d.ts +3 -0
- package/dist/src/entry-browser.d.ts.map +1 -0
- package/dist/src/entry-node.d.ts +3 -0
- package/dist/src/entry-node.d.ts.map +1 -0
- package/dist/src/eventful.d.ts +20 -0
- package/dist/src/eventful.d.ts.map +1 -0
- package/dist/src/flavored.d.ts +33 -0
- package/dist/src/flavored.d.ts.map +1 -0
- package/dist/src/index.d.ts +14 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/indexable.d.ts +243 -0
- package/dist/src/indexable.d.ts.map +1 -0
- package/dist/src/introspection.d.ts +27 -0
- package/dist/src/introspection.d.ts.map +1 -0
- package/dist/src/iterableWeak.d.ts +53 -0
- package/dist/src/iterableWeak.d.ts.map +1 -0
- package/dist/src/mixins.d.ts +25 -0
- package/dist/src/mixins.d.ts.map +1 -0
- package/dist/src/promiseChain.d.ts +20 -0
- package/dist/src/promiseChain.d.ts.map +1 -0
- package/dist/src/reactive/array.d.ts +48 -0
- package/dist/src/reactive/array.d.ts.map +1 -0
- package/dist/src/reactive/buffer.d.ts +120 -0
- package/dist/src/reactive/buffer.d.ts.map +1 -0
- package/dist/src/reactive/change.d.ts +29 -0
- package/dist/src/reactive/change.d.ts.map +1 -0
- package/dist/src/reactive/deep-touch.d.ts +28 -0
- package/dist/src/reactive/deep-touch.d.ts.map +1 -0
- package/dist/src/reactive/deep-watch-state.d.ts +25 -0
- package/dist/src/reactive/deep-watch-state.d.ts.map +1 -0
- package/dist/src/reactive/deep-watch.d.ts +20 -0
- package/dist/src/reactive/deep-watch.d.ts.map +1 -0
- package/dist/src/reactive/describe.d.ts +12 -0
- package/dist/src/reactive/describe.d.ts.map +1 -0
- package/dist/src/reactive/effect-context.d.ts +34 -0
- package/dist/src/reactive/effect-context.d.ts.map +1 -0
- package/dist/src/reactive/effects.d.ts +164 -0
- package/dist/src/reactive/effects.d.ts.map +1 -0
- package/dist/src/reactive/index.d.ts +19 -0
- package/dist/src/reactive/index.d.ts.map +1 -0
- package/dist/src/reactive/map.d.ts +28 -0
- package/dist/src/reactive/map.d.ts.map +1 -0
- package/dist/src/reactive/memoize.d.ts +28 -0
- package/dist/src/reactive/memoize.d.ts.map +1 -0
- package/dist/src/reactive/non-reactive-state.d.ts +9 -0
- package/dist/src/reactive/non-reactive-state.d.ts.map +1 -0
- package/dist/src/reactive/non-reactive.d.ts +11 -0
- package/dist/src/reactive/non-reactive.d.ts.map +1 -0
- package/dist/src/reactive/project.d.ts +40 -0
- package/dist/src/reactive/project.d.ts.map +1 -0
- package/dist/src/reactive/proxy-state.d.ts +8 -0
- package/dist/src/reactive/proxy-state.d.ts.map +1 -0
- package/dist/src/reactive/proxy.d.ts +23 -0
- package/dist/src/reactive/proxy.d.ts.map +1 -0
- package/dist/src/reactive/record.d.ts +115 -0
- package/dist/src/reactive/record.d.ts.map +1 -0
- package/dist/src/reactive/register.d.ts +125 -0
- package/dist/src/reactive/register.d.ts.map +1 -0
- package/dist/src/reactive/registry.d.ts +21 -0
- package/dist/src/reactive/registry.d.ts.map +1 -0
- package/dist/src/reactive/set.d.ts +26 -0
- package/dist/src/reactive/set.d.ts.map +1 -0
- package/dist/src/reactive/tracking.d.ts +7 -0
- package/dist/src/reactive/tracking.d.ts.map +1 -0
- package/dist/src/reactive/types.d.ts +424 -0
- package/dist/src/reactive/types.d.ts.map +1 -0
- package/dist/src/reactive/watch.d.ts +48 -0
- package/dist/src/reactive/watch.d.ts.map +1 -0
- package/dist/src/std-decorators.d.ts +45 -0
- package/dist/src/std-decorators.d.ts.map +1 -0
- package/dist/src/utils.d.ts +49 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/src/zone.d.ts +40 -0
- package/dist/src/zone.d.ts.map +1 -0
- package/dist/types-DaHFfhlN.d.ts +414 -0
- package/docs/ai/api-reference.md +1 -1
- package/docs/ai/manual.md +443 -17
- package/docs/events.md +57 -2
- package/docs/flavored.md +210 -0
- package/docs/reactive/advanced.md +2 -3
- package/docs/reactive/attend.md +143 -0
- package/docs/reactive/collections.md +55 -0
- package/docs/reactive/core.md +120 -4
- package/docs/reactive/debugging.md +8 -10
- package/docs/reactive/describe.md +85 -0
- package/docs/reactive/error-handling.md +121 -0
- package/docs/reactive/project.md +1 -1
- package/docs/reactive/scan.md +215 -0
- package/docs/reactive.md +2 -0
- package/docs/std-decorators.md +171 -52
- package/docs/zone.md +9 -6
- package/package.json +44 -27
- package/src/async/browser.ts +277 -41
- package/src/async/index.ts +23 -4
- package/src/async/node.ts +78 -32
- package/src/entry-browser.ts +5 -0
- package/src/entry-node.ts +5 -0
- package/src/eventful.ts +82 -49
- package/src/flavored.ts +106 -0
- package/src/index.d.ts +12 -9
- package/src/index.ts +2 -1
- package/src/introspection.ts +1 -1
- package/src/reactive/array.ts +160 -80
- package/src/reactive/buffer.ts +187 -27
- package/src/reactive/change.ts +16 -23
- package/src/reactive/deep-touch.ts +19 -14
- package/src/reactive/deep-watch-state.ts +3 -3
- package/src/reactive/deep-watch.ts +7 -4
- package/src/reactive/describe.ts +39 -0
- package/src/reactive/effect-context.ts +71 -6
- package/src/reactive/effects.ts +445 -393
- package/src/reactive/index.ts +12 -14
- package/src/reactive/map.ts +8 -24
- package/src/reactive/memoize.ts +26 -3
- package/src/reactive/project.md +107 -0
- package/src/reactive/project.ts +48 -71
- package/src/reactive/proxy.ts +21 -3
- package/src/reactive/record.ts +30 -45
- package/src/reactive/register.ts +138 -19
- package/src/reactive/registry.ts +22 -9
- package/src/reactive/set.ts +7 -20
- package/src/reactive/tracking.ts +9 -12
- package/src/reactive/types.ts +104 -24
- package/src/reactive/{interface.ts → watch.ts} +29 -59
- package/src/std-decorators.ts +56 -17
- package/src/utils.ts +3 -4
- package/src/zone.ts +43 -28
- package/dist/browser.js +0 -161
- package/dist/browser.js.map +0 -1
- package/dist/chunks/index-BFYK02LG.js +0 -6378
- package/dist/chunks/index-BFYK02LG.js.map +0 -1
- package/dist/chunks/index-CNR6QRUl.esm.js +0 -6291
- package/dist/chunks/index-CNR6QRUl.esm.js.map +0 -1
- package/dist/node.js +0 -136
- package/dist/node.js.map +0 -1
- package/src/reactive/debug.ts +0 -517
package/README.md
CHANGED
|
@@ -44,6 +44,66 @@ import { Destroyable, allocated } from 'mutts/destroyable'
|
|
|
44
44
|
|
|
45
45
|
**Note:** When importing from source files, you'll need to configure your build system (TypeScript, Vite, Webpack, etc.) to handle TypeScript compilation and module resolution. The source files are published alongside the built modules, so you can import directly from the `src` directory.
|
|
46
46
|
|
|
47
|
+
### Environment Setup (Node vs Browser)
|
|
48
|
+
|
|
49
|
+
`mutts` has two distinct entry points to handle environment-specific behaviors (like `async_hooks` in Node vs `wrap` in Browser).
|
|
50
|
+
|
|
51
|
+
* **Automatic Resolution**: Bundlers (Vite, Rollup, Webpack) and Node.js will automatically pick the correct entry point (`mutts/node` or `mutts/browser`) based on the `exports` field in `package.json`.
|
|
52
|
+
* **Manual Selection**: You can force a specific environment if needed:
|
|
53
|
+
```typescript
|
|
54
|
+
import 'mutts/node' // Side-effect import to polyfill async hooks in tests
|
|
55
|
+
import { ... } from 'mutts/node' // Explicit Node entry
|
|
56
|
+
import { ... } from 'mutts/browser' // Explicit Browser entry
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## [Reactive](./docs/reactive.md)
|
|
60
|
+
|
|
61
|
+
A comprehensive reactivity system. See the **[Introduction](./docs/reactive/core.md)** or browse the **[Table of Contents](./docs/reactive.md)**.
|
|
62
|
+
|
|
63
|
+
**Key Features:**
|
|
64
|
+
- **Core Reactivity**: Proxy-based property access tracking with `reactive()`, `effect()`, `memoize()`, `project()`, and `scan()`
|
|
65
|
+
- **Deep Watching**: Automatic tracking of nested object changes with `deepWatch()`
|
|
66
|
+
- **Reactive Collections**: Specialized reactive versions of Array, Map, Set, WeakMap, and WeakSet
|
|
67
|
+
- **Class Reactivity**: `@reactive` decorator and `ReactiveBase` for class-based reactivity
|
|
68
|
+
- **Reactive Mixin**: Always-reactive classes with mixin support (`Reactive`)
|
|
69
|
+
- **Back-Reference System**: Efficient change propagation through object hierarchies
|
|
70
|
+
- **Type Safety**: Full TypeScript support with proper type inference
|
|
71
|
+
- **Performance Optimized**: Lazy back-reference creation and efficient dependency tracking
|
|
72
|
+
- **Debugging & Development**: Built-in tools like cycle detection and memoization discrepancy check
|
|
73
|
+
|
|
74
|
+
**Use Cases:**
|
|
75
|
+
- State management systems
|
|
76
|
+
- UI framework reactivity
|
|
77
|
+
- Data synchronization
|
|
78
|
+
- Real-time applications
|
|
79
|
+
- Form validation and processing
|
|
80
|
+
|
|
81
|
+
## [Zones & Async Context](./docs/zone.md)
|
|
82
|
+
|
|
83
|
+
A powerful context propagation system that maintains state across asynchronous boundaries (Promises, timeouts, listeners).
|
|
84
|
+
|
|
85
|
+
**Key Features:**
|
|
86
|
+
- **Universal Context**: Works reliably in both Node.js (via `async_hooks`) and Browser/Edge environments.
|
|
87
|
+
- **Zone**: A simple value container that propagates with execution flow.
|
|
88
|
+
- **ZoneHistory**: A zone that tracks the history of values it has held in the current execution path.
|
|
89
|
+
- **ZoneAggregator**: Combines multiple zones into a single propagatable context.
|
|
90
|
+
- **Async Hooks**: Low-level hooks to capture, restore, and undo context changes across async boundaries.
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
import { Zone, asyncZone } from 'mutts'
|
|
94
|
+
|
|
95
|
+
const userZone = new Zone<User>()
|
|
96
|
+
// Register for async propagation
|
|
97
|
+
asyncZone.add(userZone)
|
|
98
|
+
|
|
99
|
+
userZone.with(currentUser, async () => {
|
|
100
|
+
// Context is available here
|
|
101
|
+
await someAsyncWork()
|
|
102
|
+
// Context is STILL available here, magically!
|
|
103
|
+
console.log(userZone.active) // currentUser
|
|
104
|
+
})
|
|
105
|
+
```
|
|
106
|
+
|
|
47
107
|
## [Indexable](./docs/indexable.md)
|
|
48
108
|
|
|
49
109
|
A way to write classes that allow numeric indexes managed by a custom function - either given in the class by the symbols [getAt] and [setAt] either by a specification if the Indexable class.
|
|
@@ -85,7 +145,7 @@ A powerful mixin system that allows you to create reusable functionality that ca
|
|
|
85
145
|
|
|
86
146
|
A collection of standard decorators that shouldn't be implemented a 101-th time.
|
|
87
147
|
|
|
88
|
-
In extenso: cached,
|
|
148
|
+
In extenso: cached, descriptor(enumerable, configurable, writable) with flavors (.enumerable, .hidden, .configurable, .frozen, .writable, .readonly), deprecated, debounce, throttle
|
|
89
149
|
|
|
90
150
|
## [Decorator System](./docs/decorator.md)
|
|
91
151
|
|
|
@@ -158,24 +218,19 @@ A comprehensive resource management system that provides automatic cleanup for o
|
|
|
158
218
|
- Plugin systems with proper cleanup
|
|
159
219
|
- Temporary resource management
|
|
160
220
|
|
|
161
|
-
## [
|
|
221
|
+
## [Flavored](./docs/flavored.md)
|
|
162
222
|
|
|
163
|
-
A
|
|
223
|
+
A utility for creating extensible functions with chainable property modifiers. Enables fluent APIs where properties return specialized variants of the base function.
|
|
164
224
|
|
|
165
225
|
**Key Features:**
|
|
166
|
-
- **
|
|
167
|
-
- **
|
|
168
|
-
- **
|
|
169
|
-
- **
|
|
170
|
-
- **
|
|
171
|
-
- **Back-Reference System**: Efficient change propagation through object hierarchies
|
|
172
|
-
- **Type Safety**: Full TypeScript support with proper type inference
|
|
173
|
-
- **Performance Optimized**: Lazy back-reference creation and efficient dependency tracking
|
|
174
|
-
- **Debugging & Development**: Built-in tools like cycle detection and memoization discrepancy check
|
|
226
|
+
- **Property-based Modifiers**: Add chainable properties to functions via getters or methods
|
|
227
|
+
- **Options Merging**: `flavorOptions` helper for automatic options object merging
|
|
228
|
+
- **Argument Transformation**: `createFlavor` helper for custom argument transformation
|
|
229
|
+
- **Hand-made Functions**: Return custom functions for complete control (the generic case)
|
|
230
|
+
- **Full TypeScript Support**: Proper type inference for chained modifiers
|
|
175
231
|
|
|
176
232
|
**Use Cases:**
|
|
177
|
-
-
|
|
178
|
-
-
|
|
179
|
-
-
|
|
180
|
-
-
|
|
181
|
-
- Form validation and processing
|
|
233
|
+
- Creating functions with preset configurations (e.g., `effect.opaque`, `effect.named()`)
|
|
234
|
+
- Fluent APIs for function variants
|
|
235
|
+
- Partial application with named parameters
|
|
236
|
+
- Building chainable configuration DSLs
|