mutts 1.0.6 → 1.0.8
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 +61 -23
- package/dist/async/browser.d.ts +2 -0
- package/dist/async/browser.d.ts.map +1 -0
- package/dist/async/index.d.ts +18 -0
- package/dist/async/index.d.ts.map +1 -0
- package/dist/async/node.d.ts +2 -0
- package/dist/async/node.d.ts.map +1 -0
- package/dist/{chunks/index-CDCOjzTy.js → browser.cjs} +5913 -4382
- package/dist/browser.cjs.map +1 -0
- package/dist/browser.d.ts +1655 -0
- package/dist/browser.esm.js +305 -0
- package/dist/browser.esm.js.map +1 -0
- package/dist/chunks/async-browser-CA0jPWIi.cjs +304 -0
- package/dist/chunks/async-browser-CA0jPWIi.cjs.map +1 -0
- package/dist/chunks/async-core-UqHzvJ-S.cjs +25 -0
- package/dist/chunks/async-core-UqHzvJ-S.cjs.map +1 -0
- package/dist/chunks/async-node-BYHuGTni.cjs +103 -0
- package/dist/chunks/async-node-BYHuGTni.cjs.map +1 -0
- package/dist/chunks/{index-DiP0RXoZ.esm.js → index-DhaOVusv.esm.js} +5851 -4345
- package/dist/chunks/index-DhaOVusv.esm.js.map +1 -0
- package/dist/decorator.d.ts +17 -18
- package/dist/decorator.d.ts.map +1 -0
- package/dist/destroyable.d.ts +12 -15
- package/dist/destroyable.d.ts.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/devtools/panel.js.map +1 -1
- package/dist/entry-browser.d.ts +3 -0
- package/dist/entry-browser.d.ts.map +1 -0
- package/dist/entry-node.d.ts +3 -0
- package/dist/entry-node.d.ts.map +1 -0
- package/dist/eventful.d.ts +3 -5
- package/dist/eventful.d.ts.map +1 -0
- package/dist/index.d.ts +13 -19
- package/dist/index.d.ts.map +1 -0
- package/dist/indexable.d.ts +10 -10
- package/dist/indexable.d.ts.map +1 -0
- package/dist/introspection.d.ts +27 -0
- package/dist/introspection.d.ts.map +1 -0
- package/dist/iterableWeak.d.ts +53 -0
- package/dist/iterableWeak.d.ts.map +1 -0
- package/dist/mixins.d.ts +25 -0
- package/dist/mixins.d.ts.map +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 +105 -0
- package/dist/node.cjs.map +1 -0
- package/dist/node.d.ts +1 -0
- package/dist/node.esm.js +104 -0
- package/dist/node.esm.js.map +1 -0
- package/dist/promiseChain.d.ts +4 -5
- package/dist/promiseChain.d.ts.map +1 -0
- package/dist/reactive/array.d.ts +49 -0
- package/dist/reactive/array.d.ts.map +1 -0
- package/dist/reactive/buffer.d.ts +44 -0
- package/dist/reactive/buffer.d.ts.map +1 -0
- package/dist/reactive/change.d.ts +29 -0
- package/dist/reactive/change.d.ts.map +1 -0
- package/dist/reactive/debug.d.ts +111 -0
- package/dist/reactive/debug.d.ts.map +1 -0
- package/dist/reactive/deep-touch.d.ts +28 -0
- package/dist/reactive/deep-touch.d.ts.map +1 -0
- package/dist/reactive/deep-watch-state.d.ts +25 -0
- package/dist/reactive/deep-watch-state.d.ts.map +1 -0
- package/dist/reactive/deep-watch.d.ts +19 -0
- package/dist/reactive/deep-watch.d.ts.map +1 -0
- package/dist/reactive/effect-context.d.ts +7 -0
- package/dist/reactive/effect-context.d.ts.map +1 -0
- package/dist/reactive/effects.d.ts +151 -0
- package/dist/reactive/effects.d.ts.map +1 -0
- package/dist/reactive/index.d.ts +20 -0
- package/dist/reactive/index.d.ts.map +1 -0
- package/dist/reactive/interface.d.ts +64 -0
- package/dist/reactive/interface.d.ts.map +1 -0
- package/dist/reactive/map.d.ts +30 -0
- package/dist/reactive/map.d.ts.map +1 -0
- package/dist/reactive/memoize.d.ts +5 -0
- package/dist/reactive/memoize.d.ts.map +1 -0
- package/dist/reactive/non-reactive-state.d.ts +9 -0
- package/dist/reactive/non-reactive-state.d.ts.map +1 -0
- package/dist/reactive/non-reactive.d.ts +11 -0
- package/dist/reactive/non-reactive.d.ts.map +1 -0
- package/dist/reactive/project.d.ts +41 -0
- package/dist/reactive/project.d.ts.map +1 -0
- package/dist/reactive/proxy-state.d.ts +8 -0
- package/dist/reactive/proxy-state.d.ts.map +1 -0
- package/dist/reactive/proxy.d.ts +23 -0
- package/dist/reactive/proxy.d.ts.map +1 -0
- package/dist/reactive/record.d.ts +116 -0
- package/dist/reactive/record.d.ts.map +1 -0
- package/dist/reactive/register.d.ts +64 -0
- package/dist/reactive/register.d.ts.map +1 -0
- package/dist/reactive/registry.d.ts +20 -0
- package/dist/reactive/registry.d.ts.map +1 -0
- package/dist/reactive/set.d.ts +28 -0
- package/dist/reactive/set.d.ts.map +1 -0
- package/dist/reactive/tracking.d.ts +7 -0
- package/dist/reactive/tracking.d.ts.map +1 -0
- package/dist/reactive/types.d.ts +376 -0
- package/dist/reactive/types.d.ts.map +1 -0
- package/dist/std-decorators.d.ts +9 -11
- package/dist/std-decorators.d.ts.map +1 -0
- package/dist/utils.d.ts +49 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/zone.d.ts +40 -0
- package/dist/zone.d.ts.map +1 -0
- package/docs/ai/api-reference.md +0 -2
- package/docs/reactive/advanced.md +2 -5
- package/docs/reactive/collections.md +0 -125
- package/docs/reactive/core.md +27 -24
- package/docs/reactive/debugging.md +12 -2
- package/docs/reactive/project.md +1 -1
- package/docs/reactive/scan.md +78 -0
- package/docs/reactive.md +2 -1
- package/docs/std-decorators.md +69 -0
- package/docs/zone.md +95 -0
- package/package.json +67 -23
- package/src/async/browser.ts +319 -0
- package/src/async/index.ts +23 -0
- package/src/async/node.ts +104 -0
- package/src/decorator.ts +5 -1
- package/src/destroyable.ts +1 -1
- package/src/entry-browser.ts +5 -0
- package/src/entry-node.ts +5 -0
- package/src/index.d.ts +12 -9
- package/src/index.ts +23 -14
- package/src/indexable.ts +42 -0
- package/src/mixins.ts +2 -2
- package/src/reactive/array.ts +274 -179
- package/src/reactive/buffer.ts +168 -0
- package/src/reactive/change.ts +2 -2
- package/src/reactive/effect-context.ts +15 -91
- package/src/reactive/effects.ts +119 -179
- package/src/reactive/index.ts +11 -13
- package/src/reactive/interface.ts +19 -33
- package/src/reactive/map.ts +49 -62
- package/src/reactive/memoize.ts +19 -9
- package/src/reactive/project.ts +43 -22
- package/src/reactive/proxy.ts +16 -41
- package/src/reactive/record.ts +3 -3
- package/src/reactive/register.ts +5 -7
- package/src/reactive/registry.ts +9 -17
- package/src/reactive/set.ts +43 -57
- package/src/reactive/tracking.ts +1 -29
- package/src/reactive/types.ts +46 -23
- package/src/utils.ts +80 -37
- package/src/zone.ts +138 -0
- package/dist/chunks/_tslib-BgjropY9.js +0 -81
- package/dist/chunks/_tslib-BgjropY9.js.map +0 -1
- package/dist/chunks/_tslib-MCKDzsSq.esm.js +0 -75
- package/dist/chunks/_tslib-MCKDzsSq.esm.js.map +0 -1
- package/dist/chunks/decorator-BGILvPtN.esm.js +0 -627
- package/dist/chunks/decorator-BGILvPtN.esm.js.map +0 -1
- package/dist/chunks/decorator-BQ2eBTCj.js +0 -651
- package/dist/chunks/decorator-BQ2eBTCj.js.map +0 -1
- package/dist/chunks/index-CDCOjzTy.js.map +0 -1
- package/dist/chunks/index-DiP0RXoZ.esm.js.map +0 -1
- package/dist/decorator.esm.js +0 -2
- package/dist/decorator.esm.js.map +0 -1
- package/dist/decorator.js +0 -11
- package/dist/decorator.js.map +0 -1
- package/dist/destroyable.esm.js +0 -109
- package/dist/destroyable.esm.js.map +0 -1
- package/dist/destroyable.js +0 -116
- package/dist/destroyable.js.map +0 -1
- package/dist/eventful.esm.js +0 -66
- package/dist/eventful.esm.js.map +0 -1
- package/dist/eventful.js +0 -68
- package/dist/eventful.js.map +0 -1
- package/dist/index.esm.js +0 -53
- package/dist/index.esm.js.map +0 -1
- package/dist/index.js +0 -139
- package/dist/index.js.map +0 -1
- package/dist/indexable.esm.js +0 -285
- package/dist/indexable.esm.js.map +0 -1
- package/dist/indexable.js +0 -291
- package/dist/indexable.js.map +0 -1
- package/dist/promiseChain.esm.js +0 -78
- package/dist/promiseChain.esm.js.map +0 -1
- package/dist/promiseChain.js +0 -80
- package/dist/promiseChain.js.map +0 -1
- package/dist/reactive.d.ts +0 -910
- package/dist/reactive.esm.js +0 -5
- package/dist/reactive.esm.js.map +0 -1
- package/dist/reactive.js +0 -59
- package/dist/reactive.js.map +0 -1
- package/dist/std-decorators.esm.js +0 -196
- package/dist/std-decorators.esm.js.map +0 -1
- package/dist/std-decorators.js +0 -204
- package/dist/std-decorators.js.map +0 -1
- package/src/reactive/mapped.ts +0 -129
- package/src/reactive/zone.ts +0 -208
package/src/index.ts
CHANGED
|
@@ -4,29 +4,38 @@ export * from './eventful'
|
|
|
4
4
|
export * from './indexable'
|
|
5
5
|
export * from './iterableWeak'
|
|
6
6
|
export * from './mixins'
|
|
7
|
+
export * from './promiseChain'
|
|
7
8
|
export * from './reactive'
|
|
8
9
|
export * from './std-decorators'
|
|
9
10
|
export * from './utils'
|
|
11
|
+
export * from './zone'
|
|
12
|
+
export * from './async'
|
|
10
13
|
|
|
11
14
|
import pkg from '../package.json'
|
|
15
|
+
|
|
12
16
|
const { version } = pkg
|
|
13
17
|
|
|
14
18
|
// Singleton verification
|
|
15
19
|
const GLOBAL_MUTTS_KEY = '__MUTTS_INSTANCE__'
|
|
16
|
-
const globalScope =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
const globalScope = (
|
|
21
|
+
typeof globalThis !== 'undefined'
|
|
22
|
+
? globalThis
|
|
23
|
+
: typeof window !== 'undefined'
|
|
24
|
+
? window
|
|
25
|
+
: typeof global !== 'undefined'
|
|
26
|
+
? global
|
|
27
|
+
: false
|
|
28
|
+
) as any
|
|
29
|
+
if (globalScope) {
|
|
21
30
|
// Detect the source of this instance safely across different environments
|
|
22
31
|
let source = 'mutts/index'
|
|
32
|
+
const viteEval = eval
|
|
23
33
|
try {
|
|
24
34
|
// @ts-ignore
|
|
25
35
|
if (typeof __filename !== 'undefined') source = __filename
|
|
26
|
-
// @ts-ignore
|
|
27
36
|
else {
|
|
28
37
|
// Using eval to avoid SyntaxError in CJS environments where import.meta is not allowed
|
|
29
|
-
const meta =
|
|
38
|
+
const meta = viteEval('import.meta')
|
|
30
39
|
if (meta && meta.url) source = meta.url
|
|
31
40
|
}
|
|
32
41
|
} catch (e) {
|
|
@@ -36,18 +45,18 @@ if(globalScope) {
|
|
|
36
45
|
const currentSourceInfo = {
|
|
37
46
|
version,
|
|
38
47
|
source,
|
|
39
|
-
timestamp: Date.now()
|
|
48
|
+
timestamp: Date.now(),
|
|
40
49
|
}
|
|
41
50
|
|
|
42
51
|
if (globalScope[GLOBAL_MUTTS_KEY]) {
|
|
43
52
|
const existing = globalScope[GLOBAL_MUTTS_KEY]
|
|
44
53
|
throw new Error(
|
|
45
|
-
`[Mutts] Multiple instances detected!\n` +
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
54
|
+
`[Mutts] Multiple instances detected!\n` +
|
|
55
|
+
`Existing instance: ${JSON.stringify(existing, null, 2)}\n` +
|
|
56
|
+
`New instance: ${JSON.stringify(currentSourceInfo, null, 2)}\n` +
|
|
57
|
+
`This usually happens when 'mutts' is both installed as a dependency and bundled, ` +
|
|
58
|
+
`or when different versions are loaded. ` +
|
|
59
|
+
`Please check your build configuration (aliases, externals) to ensure a single source of truth.`
|
|
51
60
|
)
|
|
52
61
|
}
|
|
53
62
|
|
package/src/indexable.ts
CHANGED
|
@@ -140,6 +140,48 @@ export function Indexable<Items, Base extends abstract new (...args: any[]) => a
|
|
|
140
140
|
})
|
|
141
141
|
return true
|
|
142
142
|
},
|
|
143
|
+
has(target, prop) {
|
|
144
|
+
if (prop in target) return true
|
|
145
|
+
if (typeof prop === 'string') {
|
|
146
|
+
if (prop === 'length' && accessor.getLength) return true
|
|
147
|
+
const numProp = Number(prop)
|
|
148
|
+
if (!Number.isNaN(numProp)) return true
|
|
149
|
+
}
|
|
150
|
+
return false
|
|
151
|
+
},
|
|
152
|
+
ownKeys(target) {
|
|
153
|
+
const keys = Reflect.ownKeys(target)
|
|
154
|
+
if (accessor.getLength) {
|
|
155
|
+
keys.push('length')
|
|
156
|
+
const len = accessor.getLength.call(this as any)
|
|
157
|
+
for (let i = 0; i < len; i++) keys.push(String(i))
|
|
158
|
+
}
|
|
159
|
+
return keys
|
|
160
|
+
},
|
|
161
|
+
getOwnPropertyDescriptor(target, prop) {
|
|
162
|
+
if (prop in target) return Object.getOwnPropertyDescriptor(target, prop)
|
|
163
|
+
if (typeof prop === 'string') {
|
|
164
|
+
if (prop === 'length' && accessor.getLength) {
|
|
165
|
+
return {
|
|
166
|
+
enumerable: false,
|
|
167
|
+
configurable: true,
|
|
168
|
+
get: () => accessor.getLength!.call(this as any),
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
const numProp = Number(prop)
|
|
172
|
+
if (!Number.isNaN(numProp)) {
|
|
173
|
+
return {
|
|
174
|
+
enumerable: true,
|
|
175
|
+
configurable: true,
|
|
176
|
+
get: () => accessor.get!.call(this as any, numProp),
|
|
177
|
+
set: accessor.set
|
|
178
|
+
? (v: any) => accessor.set!.call(this as any, numProp, v)
|
|
179
|
+
: undefined,
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return undefined
|
|
184
|
+
},
|
|
143
185
|
})
|
|
144
186
|
)
|
|
145
187
|
return Indexable
|
package/src/mixins.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FoolProof, isConstructor } from './utils'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* A mixin function that takes a base class and returns a new class with mixed-in functionality
|
|
@@ -85,7 +85,7 @@ export function mixin<MixinFn extends (base: any) => new (...args: any[]) => any
|
|
|
85
85
|
const originalPrototype = baseClass.prototype
|
|
86
86
|
const proxiedPrototype = new Proxy(originalPrototype, {
|
|
87
87
|
get(target, prop, receiver) {
|
|
88
|
-
const value =
|
|
88
|
+
const value = FoolProof.get(target, prop, receiver)
|
|
89
89
|
|
|
90
90
|
// Only wrap methods that are likely to access private fields
|
|
91
91
|
// Skip symbols and special properties that the reactive system needs
|