mutts 1.0.6 → 1.0.7

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 (110) hide show
  1. package/README.md +1 -1
  2. package/dist/browser.d.ts +2 -0
  3. package/dist/browser.esm.js +70 -0
  4. package/dist/browser.esm.js.map +1 -0
  5. package/dist/browser.js +161 -0
  6. package/dist/browser.js.map +1 -0
  7. package/dist/chunks/{index-CDCOjzTy.js → index-BFYK02LG.js} +5760 -4338
  8. package/dist/chunks/index-BFYK02LG.js.map +1 -0
  9. package/dist/chunks/{index-DiP0RXoZ.esm.js → index-CNR6QRUl.esm.js} +5440 -4054
  10. package/dist/chunks/index-CNR6QRUl.esm.js.map +1 -0
  11. package/dist/devtools/panel.js.map +1 -1
  12. package/dist/mutts.umd.js +1 -1
  13. package/dist/mutts.umd.js.map +1 -1
  14. package/dist/mutts.umd.min.js +1 -1
  15. package/dist/mutts.umd.min.js.map +1 -1
  16. package/dist/node.d.ts +2 -0
  17. package/dist/node.esm.js +45 -0
  18. package/dist/node.esm.js.map +1 -0
  19. package/dist/node.js +136 -0
  20. package/dist/node.js.map +1 -0
  21. package/docs/ai/api-reference.md +0 -2
  22. package/docs/reactive/advanced.md +2 -5
  23. package/docs/reactive/collections.md +0 -125
  24. package/docs/reactive/core.md +27 -24
  25. package/docs/reactive/debugging.md +12 -2
  26. package/docs/reactive/project.md +1 -1
  27. package/docs/reactive/scan.md +78 -0
  28. package/docs/reactive.md +2 -1
  29. package/docs/std-decorators.md +1 -0
  30. package/docs/zone.md +88 -0
  31. package/package.json +42 -10
  32. package/src/async/browser.ts +87 -0
  33. package/src/async/index.ts +8 -0
  34. package/src/async/node.ts +46 -0
  35. package/src/decorator.ts +5 -1
  36. package/src/destroyable.ts +1 -1
  37. package/src/index.ts +22 -14
  38. package/src/indexable.ts +42 -0
  39. package/src/mixins.ts +2 -2
  40. package/src/reactive/array.ts +149 -141
  41. package/src/reactive/buffer.ts +168 -0
  42. package/src/reactive/change.ts +2 -2
  43. package/src/reactive/effect-context.ts +15 -91
  44. package/src/reactive/effects.ts +119 -179
  45. package/src/reactive/index.ts +10 -13
  46. package/src/reactive/interface.ts +19 -33
  47. package/src/reactive/map.ts +48 -61
  48. package/src/reactive/memoize.ts +19 -9
  49. package/src/reactive/project.ts +43 -22
  50. package/src/reactive/proxy.ts +16 -41
  51. package/src/reactive/record.ts +3 -3
  52. package/src/reactive/register.ts +5 -7
  53. package/src/reactive/registry.ts +9 -17
  54. package/src/reactive/set.ts +42 -56
  55. package/src/reactive/tracking.ts +1 -29
  56. package/src/reactive/types.ts +46 -23
  57. package/src/utils.ts +80 -37
  58. package/src/zone.ts +127 -0
  59. package/dist/chunks/_tslib-BgjropY9.js +0 -81
  60. package/dist/chunks/_tslib-BgjropY9.js.map +0 -1
  61. package/dist/chunks/_tslib-MCKDzsSq.esm.js +0 -75
  62. package/dist/chunks/_tslib-MCKDzsSq.esm.js.map +0 -1
  63. package/dist/chunks/decorator-BGILvPtN.esm.js +0 -627
  64. package/dist/chunks/decorator-BGILvPtN.esm.js.map +0 -1
  65. package/dist/chunks/decorator-BQ2eBTCj.js +0 -651
  66. package/dist/chunks/decorator-BQ2eBTCj.js.map +0 -1
  67. package/dist/chunks/index-CDCOjzTy.js.map +0 -1
  68. package/dist/chunks/index-DiP0RXoZ.esm.js.map +0 -1
  69. package/dist/decorator.d.ts +0 -107
  70. package/dist/decorator.esm.js +0 -2
  71. package/dist/decorator.esm.js.map +0 -1
  72. package/dist/decorator.js +0 -11
  73. package/dist/decorator.js.map +0 -1
  74. package/dist/destroyable.d.ts +0 -90
  75. package/dist/destroyable.esm.js +0 -109
  76. package/dist/destroyable.esm.js.map +0 -1
  77. package/dist/destroyable.js +0 -116
  78. package/dist/destroyable.js.map +0 -1
  79. package/dist/eventful.d.ts +0 -20
  80. package/dist/eventful.esm.js +0 -66
  81. package/dist/eventful.esm.js.map +0 -1
  82. package/dist/eventful.js +0 -68
  83. package/dist/eventful.js.map +0 -1
  84. package/dist/index.d.ts +0 -19
  85. package/dist/index.esm.js +0 -53
  86. package/dist/index.esm.js.map +0 -1
  87. package/dist/index.js +0 -139
  88. package/dist/index.js.map +0 -1
  89. package/dist/indexable.d.ts +0 -243
  90. package/dist/indexable.esm.js +0 -285
  91. package/dist/indexable.esm.js.map +0 -1
  92. package/dist/indexable.js +0 -291
  93. package/dist/indexable.js.map +0 -1
  94. package/dist/promiseChain.d.ts +0 -21
  95. package/dist/promiseChain.esm.js +0 -78
  96. package/dist/promiseChain.esm.js.map +0 -1
  97. package/dist/promiseChain.js +0 -80
  98. package/dist/promiseChain.js.map +0 -1
  99. package/dist/reactive.d.ts +0 -910
  100. package/dist/reactive.esm.js +0 -5
  101. package/dist/reactive.esm.js.map +0 -1
  102. package/dist/reactive.js +0 -59
  103. package/dist/reactive.js.map +0 -1
  104. package/dist/std-decorators.d.ts +0 -52
  105. package/dist/std-decorators.esm.js +0 -196
  106. package/dist/std-decorators.esm.js.map +0 -1
  107. package/dist/std-decorators.js +0 -204
  108. package/dist/std-decorators.js.map +0 -1
  109. package/src/reactive/mapped.ts +0 -129
  110. package/src/reactive/zone.ts +0 -208
@@ -1 +0,0 @@
1
- {"version":3,"file":"eventful.js","sources":["../src/eventful.ts"],"sourcesContent":["/**\n * Base type for event maps - all event handlers must be functions\n */\nexport type EventsBase = Record<string, (...args: any[]) => void>\n/**\n * A type-safe event system that provides a clean API for event handling\n * @template Events - The event map defining event names and their handler signatures\n */\nexport class Eventful<Events extends EventsBase> {\n\treadonly #events = new Map<keyof Events, ((...args: any[]) => void)[]>()\n\treadonly #hooks = [] as ((...args: any[]) => void)[]\n\n\tpublic hook(\n\t\tcb: <EventType extends keyof Events>(\n\t\t\tevent: EventType,\n\t\t\t...args: Parameters<Events[EventType]>\n\t\t) => void\n\t): () => void {\n\t\tif (!this.#hooks.includes(cb)) this.#hooks.push(cb)\n\t\treturn () => {\n\t\t\tthis.#hooks.splice(this.#hooks.indexOf(cb), 1)\n\t\t}\n\t}\n\n\tpublic on(events: Partial<Events>): void\n\tpublic on<EventType extends keyof Events>(event: EventType, cb: Events[EventType]): () => void\n\tpublic on<EventType extends keyof Events>(\n\t\teventOrEvents: EventType | Partial<Events>,\n\t\tcb?: Events[EventType]\n\t): () => void {\n\t\tif (typeof eventOrEvents === 'object') {\n\t\t\tfor (const e of Object.keys(eventOrEvents) as (keyof Events)[]) {\n\t\t\t\tthis.on(e, eventOrEvents[e]!)\n\t\t\t}\n\t\t} else if (cb !== undefined) {\n\t\t\tlet callbacks = this.#events.get(eventOrEvents)\n\t\t\tif (!callbacks) {\n\t\t\t\tcallbacks = []\n\t\t\t\tthis.#events.set(eventOrEvents, callbacks)\n\t\t\t}\n\t\t\tcallbacks.push(cb)\n\t\t}\n\t\t// @ts-expect-error Generic case leads to generic case\n\t\treturn () => this.off(eventOrEvents, cb)\n\t}\n\tpublic off(events: Partial<Events>): void\n\tpublic off<EventType extends keyof Events>(event: EventType, cb?: Events[EventType]): void\n\tpublic off<EventType extends keyof Events>(\n\t\teventOrEvents: EventType | Partial<Events>,\n\t\tcb?: Events[EventType]\n\t): void {\n\t\tif (typeof eventOrEvents === 'object') {\n\t\t\tfor (const e of Object.keys(eventOrEvents) as (keyof Events)[]) {\n\t\t\t\tthis.off(e, eventOrEvents[e])\n\t\t\t}\n\t\t} else if (cb !== null && cb !== undefined) {\n\t\t\tconst callbacks = this.#events.get(eventOrEvents)\n\t\t\tif (callbacks) {\n\t\t\t\tthis.#events.set(\n\t\t\t\t\teventOrEvents,\n\t\t\t\t\tcallbacks.filter((c) => c !== cb)\n\t\t\t\t)\n\t\t\t}\n\t\t} else {\n\t\t\t// Remove all listeners for this event\n\t\t\tthis.#events.delete(eventOrEvents)\n\t\t}\n\t}\n\tpublic emit<EventType extends keyof Events>(\n\t\tevent: EventType,\n\t\t...args: Parameters<Events[EventType]>\n\t) {\n\t\tconst callbacks = this.#events.get(event)\n\t\tif (callbacks) for (const cb of callbacks) cb.apply(this, args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CAAO;YAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;IAC5D;AACA;;;;;"}
package/dist/index.d.ts DELETED
@@ -1,19 +0,0 @@
1
- export * from './decorator.js'
2
- export * from './destroyable.js'
3
- export * from './eventful.js'
4
- export * from './indexable.js'
5
- export * from './iterableWeak.js'
6
- export * from './mixins.js'
7
- export * from './reactive.js'
8
- export * from './std-decorators.js'
9
- export * from './utils.js'
10
-
11
- // Augment Array.isArray to properly handle readonly arrays in type narrowing
12
- interface ArrayConstructor {
13
- /**
14
- * Determines whether an object is an array.
15
- * @param arg Any value to test.
16
- * @returns True if the value is an array (mutable or readonly), false otherwise.
17
- */
18
- isArray(arg: any): arg is any[] | readonly any[]
19
- }
package/dist/index.esm.js DELETED
@@ -1,53 +0,0 @@
1
- export { D as DecoratorError, R as ReactiveError, a as ReflectGet, b as ReflectSet, c as arrayEquals, d as decorator, e as deepCompare, i as isConstructor, f as isOwnAccessor, l as legacyDecorator, m as modernDecorator, o as reactiveOptions, r as renamed, z as zip } from './chunks/decorator-BGILvPtN.esm.js';
2
- export { Destroyable, DestructionError, allocated, allocatedValues, callOnGC, destructor } from './destroyable.esm.js';
3
- export { Eventful } from './eventful.esm.js';
4
- export { ArrayReadForward, Indexable, forwardArray, getAt, setAt } from './indexable.esm.js';
5
- export { I as IterableWeakMap, a as IterableWeakSet, R as ReactiveBase, b as ReadOnlyError, c as Register, d as addBatchCleanup, e as atomic, f as batch, g as biDi, h as buildReactivityGraph, i as cleanedBy, j as cleanup, k as deepWatch, l as defer, m as derived, n as effect, o as enableDevTools, p as getActivationLog, q as getActiveEffect, r as getActiveProjection, s as getState, t as immutables, u as isDevtoolsEnabled, v as isNonReactive, w as isReactive, x as isZoneEnabled, y as mapped, z as memoize, A as mixin, B as organize, C as organized, D as profileInfo, E as project, F as reactive, G as reduced, H as register, J as registerEffectForDebug, K as registerNativeReactivity, L as registerObjectForDebug, M as root, N as setEffectName, O as setObjectName, P as setZoneEnabled, Q as touched, S as touched1, T as trackEffect, U as unreactive, V as untracked, W as unwrap, X as watch } from './chunks/index-DiP0RXoZ.esm.js';
6
- export { cache, cached, debounce, deprecated, describe, isCached, throttle } from './std-decorators.esm.js';
7
- import './chunks/_tslib-MCKDzsSq.esm.js';
8
-
9
- var version$1 = "1.0.6";
10
- var pkg = {
11
- version: version$1};
12
-
13
- const { version } = pkg;
14
- // Singleton verification
15
- const GLOBAL_MUTTS_KEY = '__MUTTS_INSTANCE__';
16
- const globalScope = (typeof globalThis !== 'undefined' ? globalThis :
17
- (typeof window !== 'undefined' ? window :
18
- (typeof global !== 'undefined' ? global : false)));
19
- if (globalScope) {
20
- // Detect the source of this instance safely across different environments
21
- let source = 'mutts/index';
22
- try {
23
- // @ts-ignore
24
- if (typeof __filename !== 'undefined')
25
- source = __filename;
26
- // @ts-ignore
27
- else {
28
- // Using eval to avoid SyntaxError in CJS environments where import.meta is not allowed
29
- const meta = eval('import.meta');
30
- if (meta && meta.url)
31
- source = meta.url;
32
- }
33
- }
34
- catch (e) {
35
- // Fallback for environments where neither is available or accessible
36
- }
37
- const currentSourceInfo = {
38
- version,
39
- source,
40
- timestamp: Date.now()
41
- };
42
- if (globalScope[GLOBAL_MUTTS_KEY]) {
43
- const existing = globalScope[GLOBAL_MUTTS_KEY];
44
- throw new Error(`[Mutts] Multiple instances detected!\n` +
45
- `Existing instance: ${JSON.stringify(existing, null, 2)}\n` +
46
- `New instance: ${JSON.stringify(currentSourceInfo, null, 2)}\n` +
47
- `This usually happens when 'mutts' is both installed as a dependency and bundled, ` +
48
- `or when different versions are loaded. ` +
49
- `Please check your build configuration (aliases, externals) to ensure a single source of truth.`);
50
- }
51
- globalScope[GLOBAL_MUTTS_KEY] = currentSourceInfo;
52
- }
53
- //# sourceMappingURL=index.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/index.ts"],"sourcesContent":["export * from './decorator'\nexport * from './destroyable'\nexport * from './eventful'\nexport * from './indexable'\nexport * from './iterableWeak'\nexport * from './mixins'\nexport * from './reactive'\nexport * from './std-decorators'\nexport * from './utils'\n\nimport pkg from '../package.json'\nconst { version } = pkg\n\n// Singleton verification\nconst GLOBAL_MUTTS_KEY = '__MUTTS_INSTANCE__'\nconst globalScope = \n\t(typeof globalThis !== 'undefined' ? globalThis : \n\t(typeof window !== 'undefined' ? window : \n\t(typeof global !== 'undefined' ? global : false))) as any\nif(globalScope) {\n\t// Detect the source of this instance safely across different environments\n\tlet source = 'mutts/index'\n\ttry {\n\t\t// @ts-ignore\n\t\tif (typeof __filename !== 'undefined') source = __filename\n\t\t// @ts-ignore\n\t\telse {\n\t\t\t// Using eval to avoid SyntaxError in CJS environments where import.meta is not allowed\n\t\t\tconst meta = eval('import.meta')\n\t\t\tif (meta && meta.url) source = meta.url\n\t\t}\n\t} catch (e) {\n\t\t// Fallback for environments where neither is available or accessible\n\t}\n\n\tconst currentSourceInfo = {\n\t\tversion,\n\t\tsource,\n\t\ttimestamp: Date.now()\n\t}\n\n\tif (globalScope[GLOBAL_MUTTS_KEY]) {\n\t\tconst existing = globalScope[GLOBAL_MUTTS_KEY]\n\t\tthrow new Error(\n\t\t\t`[Mutts] Multiple instances detected!\\n` + \n\t\t\t`Existing instance: ${JSON.stringify(existing, null, 2)}\\n` +\n\t\t\t`New instance: ${JSON.stringify(currentSourceInfo, null, 2)}\\n` +\n\t\t\t`This usually happens when 'mutts' is both installed as a dependency and bundled, ` +\n\t\t\t`or when different versions are loaded. ` +\n\t\t\t`Please check your build configuration (aliases, externals) to ensure a single source of truth.`\n\t\t)\n\t}\n\n\tglobalScope[GLOBAL_MUTTS_KEY] = currentSourceInfo\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAWA,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG;AAEvB;AACA,MAAM,gBAAgB,GAAG,oBAAoB;AAC7C,MAAM,WAAW,IACf,OAAO,UAAU,KAAK,WAAW,GAAG,UAAU;KAC9C,OAAO,MAAM,KAAK,WAAW,GAAG,MAAM;AACvC,SAAC,OAAO,MAAM,KAAK,WAAW,GAAG,MAAM,GAAG,KAAK,CAAC,CAAC,CAAQ;AAC1D,IAAG,WAAW,EAAE;;IAEf,IAAI,MAAM,GAAG,aAAa;AAC1B,IAAA,IAAI;;QAEH,IAAI,OAAO,UAAU,KAAK,WAAW;YAAE,MAAM,GAAG,UAAU;;aAErD;;AAEJ,YAAA,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC;AAChC,YAAA,IAAI,IAAI,IAAI,IAAI,CAAC,GAAG;AAAE,gBAAA,MAAM,GAAG,IAAI,CAAC,GAAG;QACxC;IACD;IAAE,OAAO,CAAC,EAAE;;IAEZ;AAEA,IAAA,MAAM,iBAAiB,GAAG;QACzB,OAAO;QACP,MAAM;AACN,QAAA,SAAS,EAAE,IAAI,CAAC,GAAG;KACnB;AAED,IAAA,IAAI,WAAW,CAAC,gBAAgB,CAAC,EAAE;AAClC,QAAA,MAAM,QAAQ,GAAG,WAAW,CAAC,gBAAgB,CAAC;QAC9C,MAAM,IAAI,KAAK,CACd,CAAA,sCAAA,CAAwC;YACxC,CAAA,mBAAA,EAAsB,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA,EAAA,CAAI;YAC3D,CAAA,cAAA,EAAiB,IAAI,CAAC,SAAS,CAAC,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA,EAAA,CAAI;YAC/D,CAAA,iFAAA,CAAmF;YACnF,CAAA,uCAAA,CAAyC;AACzC,YAAA,CAAA,8FAAA,CAAgG,CAChG;IACF;AAEA,IAAA,WAAW,CAAC,gBAAgB,CAAC,GAAG,iBAAiB;AAClD"}
package/dist/index.js DELETED
@@ -1,139 +0,0 @@
1
- 'use strict';
2
-
3
- var decorator = require('./chunks/decorator-BQ2eBTCj.js');
4
- var destroyable = require('./destroyable.js');
5
- var eventful = require('./eventful.js');
6
- var indexable = require('./indexable.js');
7
- var reactive = require('./chunks/index-CDCOjzTy.js');
8
- var stdDecorators = require('./std-decorators.js');
9
- require('./chunks/_tslib-BgjropY9.js');
10
-
11
- var version$1 = "1.0.6";
12
- var pkg = {
13
- version: version$1};
14
-
15
- const { version } = pkg;
16
- // Singleton verification
17
- const GLOBAL_MUTTS_KEY = '__MUTTS_INSTANCE__';
18
- const globalScope = (typeof globalThis !== 'undefined' ? globalThis :
19
- (typeof window !== 'undefined' ? window :
20
- (typeof global !== 'undefined' ? global : false)));
21
- if (globalScope) {
22
- // Detect the source of this instance safely across different environments
23
- let source = 'mutts/index';
24
- try {
25
- // @ts-ignore
26
- if (typeof __filename !== 'undefined')
27
- source = __filename;
28
- // @ts-ignore
29
- else {
30
- // Using eval to avoid SyntaxError in CJS environments where import.meta is not allowed
31
- const meta = eval('import.meta');
32
- if (meta && meta.url)
33
- source = meta.url;
34
- }
35
- }
36
- catch (e) {
37
- // Fallback for environments where neither is available or accessible
38
- }
39
- const currentSourceInfo = {
40
- version,
41
- source,
42
- timestamp: Date.now()
43
- };
44
- if (globalScope[GLOBAL_MUTTS_KEY]) {
45
- const existing = globalScope[GLOBAL_MUTTS_KEY];
46
- throw new Error(`[Mutts] Multiple instances detected!\n` +
47
- `Existing instance: ${JSON.stringify(existing, null, 2)}\n` +
48
- `New instance: ${JSON.stringify(currentSourceInfo, null, 2)}\n` +
49
- `This usually happens when 'mutts' is both installed as a dependency and bundled, ` +
50
- `or when different versions are loaded. ` +
51
- `Please check your build configuration (aliases, externals) to ensure a single source of truth.`);
52
- }
53
- globalScope[GLOBAL_MUTTS_KEY] = currentSourceInfo;
54
- }
55
-
56
- exports.DecoratorError = decorator.DecoratorError;
57
- exports.ReactiveError = decorator.ReactiveError;
58
- exports.ReflectGet = decorator.ReflectGet;
59
- exports.ReflectSet = decorator.ReflectSet;
60
- exports.arrayEquals = decorator.arrayEquals;
61
- exports.decorator = decorator.decorator;
62
- exports.deepCompare = decorator.deepCompare;
63
- exports.isConstructor = decorator.isConstructor;
64
- exports.isOwnAccessor = decorator.isOwnAccessor;
65
- exports.legacyDecorator = decorator.legacyDecorator;
66
- exports.modernDecorator = decorator.modernDecorator;
67
- exports.reactiveOptions = decorator.options;
68
- exports.renamed = decorator.renamed;
69
- exports.zip = decorator.zip;
70
- exports.Destroyable = destroyable.Destroyable;
71
- exports.DestructionError = destroyable.DestructionError;
72
- exports.allocated = destroyable.allocated;
73
- exports.allocatedValues = destroyable.allocatedValues;
74
- exports.callOnGC = destroyable.callOnGC;
75
- exports.destructor = destroyable.destructor;
76
- exports.Eventful = eventful.Eventful;
77
- exports.ArrayReadForward = indexable.ArrayReadForward;
78
- exports.Indexable = indexable.Indexable;
79
- exports.forwardArray = indexable.forwardArray;
80
- exports.getAt = indexable.getAt;
81
- exports.setAt = indexable.setAt;
82
- exports.IterableWeakMap = reactive.IterableWeakMap;
83
- exports.IterableWeakSet = reactive.IterableWeakSet;
84
- exports.ReactiveBase = reactive.ReactiveBase;
85
- exports.ReadOnlyError = reactive.ReadOnlyError;
86
- exports.Register = reactive.Register;
87
- exports.addBatchCleanup = reactive.addBatchCleanup;
88
- exports.atomic = reactive.atomic;
89
- exports.batch = reactive.batch;
90
- exports.biDi = reactive.biDi;
91
- exports.buildReactivityGraph = reactive.buildReactivityGraph;
92
- exports.cleanedBy = reactive.cleanedBy;
93
- exports.cleanup = reactive.cleanup;
94
- exports.deepWatch = reactive.deepWatch;
95
- exports.defer = reactive.defer;
96
- exports.derived = reactive.derived;
97
- exports.effect = reactive.effect;
98
- exports.enableDevTools = reactive.enableDevTools;
99
- exports.getActivationLog = reactive.getActivationLog;
100
- exports.getActiveEffect = reactive.getActiveEffect;
101
- exports.getActiveProjection = reactive.getActiveProjection;
102
- exports.getState = reactive.getState;
103
- exports.immutables = reactive.immutables;
104
- exports.isDevtoolsEnabled = reactive.isDevtoolsEnabled;
105
- exports.isNonReactive = reactive.isNonReactive;
106
- exports.isReactive = reactive.isReactive;
107
- exports.isZoneEnabled = reactive.isZoneEnabled;
108
- exports.mapped = reactive.mapped;
109
- exports.memoize = reactive.memoize;
110
- exports.mixin = reactive.mixin;
111
- exports.organize = reactive.organize;
112
- exports.organized = reactive.organized;
113
- exports.profileInfo = reactive.profileInfo;
114
- exports.project = reactive.project;
115
- exports.reactive = reactive.reactive;
116
- exports.reduced = reactive.reduced;
117
- exports.register = reactive.register;
118
- exports.registerEffectForDebug = reactive.registerEffectForDebug;
119
- exports.registerNativeReactivity = reactive.registerNativeReactivity;
120
- exports.registerObjectForDebug = reactive.registerObjectForDebug;
121
- exports.root = reactive.root;
122
- exports.setEffectName = reactive.setEffectName;
123
- exports.setObjectName = reactive.setObjectName;
124
- exports.setZoneEnabled = reactive.setZoneEnabled;
125
- exports.touched = reactive.touched;
126
- exports.touched1 = reactive.touched1;
127
- exports.trackEffect = reactive.trackEffect;
128
- exports.unreactive = reactive.unreactive;
129
- exports.untracked = reactive.untracked;
130
- exports.unwrap = reactive.unwrap;
131
- exports.watch = reactive.watch;
132
- exports.cache = stdDecorators.cache;
133
- exports.cached = stdDecorators.cached;
134
- exports.debounce = stdDecorators.debounce;
135
- exports.deprecated = stdDecorators.deprecated;
136
- exports.describe = stdDecorators.describe;
137
- exports.isCached = stdDecorators.isCached;
138
- exports.throttle = stdDecorators.throttle;
139
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["export * from './decorator'\nexport * from './destroyable'\nexport * from './eventful'\nexport * from './indexable'\nexport * from './iterableWeak'\nexport * from './mixins'\nexport * from './reactive'\nexport * from './std-decorators'\nexport * from './utils'\n\nimport pkg from '../package.json'\nconst { version } = pkg\n\n// Singleton verification\nconst GLOBAL_MUTTS_KEY = '__MUTTS_INSTANCE__'\nconst globalScope = \n\t(typeof globalThis !== 'undefined' ? globalThis : \n\t(typeof window !== 'undefined' ? window : \n\t(typeof global !== 'undefined' ? global : false))) as any\nif(globalScope) {\n\t// Detect the source of this instance safely across different environments\n\tlet source = 'mutts/index'\n\ttry {\n\t\t// @ts-ignore\n\t\tif (typeof __filename !== 'undefined') source = __filename\n\t\t// @ts-ignore\n\t\telse {\n\t\t\t// Using eval to avoid SyntaxError in CJS environments where import.meta is not allowed\n\t\t\tconst meta = eval('import.meta')\n\t\t\tif (meta && meta.url) source = meta.url\n\t\t}\n\t} catch (e) {\n\t\t// Fallback for environments where neither is available or accessible\n\t}\n\n\tconst currentSourceInfo = {\n\t\tversion,\n\t\tsource,\n\t\ttimestamp: Date.now()\n\t}\n\n\tif (globalScope[GLOBAL_MUTTS_KEY]) {\n\t\tconst existing = globalScope[GLOBAL_MUTTS_KEY]\n\t\tthrow new Error(\n\t\t\t`[Mutts] Multiple instances detected!\\n` + \n\t\t\t`Existing instance: ${JSON.stringify(existing, null, 2)}\\n` +\n\t\t\t`New instance: ${JSON.stringify(currentSourceInfo, null, 2)}\\n` +\n\t\t\t`This usually happens when 'mutts' is both installed as a dependency and bundled, ` +\n\t\t\t`or when different versions are loaded. ` +\n\t\t\t`Please check your build configuration (aliases, externals) to ensure a single source of truth.`\n\t\t)\n\t}\n\n\tglobalScope[GLOBAL_MUTTS_KEY] = currentSourceInfo\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAWA,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG;AAEvB;AACA,MAAM,gBAAgB,GAAG,oBAAoB;AAC7C,MAAM,WAAW,IACf,OAAO,UAAU,KAAK,WAAW,GAAG,UAAU;KAC9C,OAAO,MAAM,KAAK,WAAW,GAAG,MAAM;AACvC,SAAC,OAAO,MAAM,KAAK,WAAW,GAAG,MAAM,GAAG,KAAK,CAAC,CAAC,CAAQ;AAC1D,IAAG,WAAW,EAAE;;IAEf,IAAI,MAAM,GAAG,aAAa;AAC1B,IAAA,IAAI;;QAEH,IAAI,OAAO,UAAU,KAAK,WAAW;YAAE,MAAM,GAAG,UAAU;;aAErD;;AAEJ,YAAA,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC;AAChC,YAAA,IAAI,IAAI,IAAI,IAAI,CAAC,GAAG;AAAE,gBAAA,MAAM,GAAG,IAAI,CAAC,GAAG;QACxC;IACD;IAAE,OAAO,CAAC,EAAE;;IAEZ;AAEA,IAAA,MAAM,iBAAiB,GAAG;QACzB,OAAO;QACP,MAAM;AACN,QAAA,SAAS,EAAE,IAAI,CAAC,GAAG;KACnB;AAED,IAAA,IAAI,WAAW,CAAC,gBAAgB,CAAC,EAAE;AAClC,QAAA,MAAM,QAAQ,GAAG,WAAW,CAAC,gBAAgB,CAAC;QAC9C,MAAM,IAAI,KAAK,CACd,CAAA,sCAAA,CAAwC;YACxC,CAAA,mBAAA,EAAsB,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA,EAAA,CAAI;YAC3D,CAAA,cAAA,EAAiB,IAAI,CAAC,SAAS,CAAC,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA,EAAA,CAAI;YAC/D,CAAA,iFAAA,CAAmF;YACnF,CAAA,uCAAA,CAAyC;AACzC,YAAA,CAAA,8FAAA,CAAgG,CAChG;IACF;AAEA,IAAA,WAAW,CAAC,gBAAgB,CAAC,GAAG,iBAAiB;AAClD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,243 +0,0 @@
1
- /**
2
- * Symbol for defining custom getter logic for numeric index access
3
- */
4
- declare const getAt: unique symbol;
5
- /**
6
- * Symbol for defining custom setter logic for numeric index access
7
- */
8
- declare const setAt: unique symbol;
9
- interface IndexingAt<Items = any> {
10
- [getAt](index: number): Items;
11
- }
12
- interface Accessor<T, Items> {
13
- get(this: T, index: number): Items;
14
- set?(this: T, index: number, value: Items): void;
15
- getLength?(this: T): number;
16
- setLength?(this: T, value: number): void;
17
- }
18
- declare abstract class AbstractGetAt<Items = any> {
19
- abstract [getAt](index: number): Items;
20
- }
21
- /**
22
- * Creates an indexable class with a base class and accessor object
23
- * @param base - The base class to extend
24
- * @param accessor - Object containing get/set methods for numeric index access
25
- * @returns A class that supports numeric index access
26
- */
27
- declare function Indexable<Items, Base extends abstract new (...args: any[]) => any>(base: Base, accessor: Accessor<InstanceType<Base>, Items>): new (...args: ConstructorParameters<Base>) => InstanceType<Base> & {
28
- [x: number]: Items;
29
- };
30
- /**
31
- * Creates an indexable class with only an accessor object (no base class)
32
- * @param accessor - Object containing get/set methods for numeric index access
33
- * @returns A class that supports numeric index access
34
- */
35
- declare function Indexable<Items>(accessor: Accessor<any, Items>): new () => {
36
- [x: number]: Items;
37
- };
38
- /**
39
- * Creates an indexable class with a base class that has [getAt] method
40
- * @param base - The base class that implements [getAt] method
41
- * @returns A class that supports numeric index access using the base class's [getAt] method
42
- */
43
- declare function Indexable<Base extends new (...args: any[]) => IndexingAt>(base: Base): new (...args: ConstructorParameters<Base>) => InstanceType<Base> & {
44
- [x: number]: AtReturnType<InstanceType<Base>>;
45
- };
46
- /**
47
- * Creates an abstract indexable base class
48
- * @returns An abstract class that supports numeric index access
49
- */
50
- declare function Indexable<Items>(): abstract new (...args: any[]) => AbstractGetAt & {
51
- [x: number]: Items;
52
- };
53
- type AtReturnType<T> = T extends {
54
- [getAt](index: number): infer R;
55
- } ? R : never;
56
- /**
57
- * Symbol for accessing the forwarded array in ArrayReadForward
58
- */
59
- declare const forwardArray: unique symbol;
60
- /**
61
- * A read-only array forwarder that implements all reading/iterating methods of Array
62
- * but does not implement modification methods.
63
- *
64
- * The constructor takes a callback that returns an array, and all methods forward
65
- * their behavior to the result of that callback.
66
- */
67
- declare class ArrayReadForward<T> {
68
- protected get [forwardArray](): readonly T[];
69
- /**
70
- * Get the length of the array
71
- */
72
- get length(): number;
73
- /**
74
- * Get an element at a specific index
75
- */
76
- [index: number]: T | undefined;
77
- /**
78
- * Iterator protocol support
79
- */
80
- [Symbol.iterator](): Iterator<T>;
81
- /**
82
- * Creates a new array with the results of calling a provided function on every element
83
- */
84
- map<U>(callbackfn: (value: T, index: number, array: readonly T[]) => U, thisArg?: any): U[];
85
- /**
86
- * Creates a new array with all elements that pass the test implemented by the provided function
87
- */
88
- filter<S extends T>(predicate: (value: T, index: number, array: readonly T[]) => value is S, thisArg?: any): S[];
89
- filter(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): T[];
90
- /**
91
- * Executes a reducer function on each element of the array, resulting in a single output value
92
- */
93
- reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T): T;
94
- reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T, initialValue: T): T;
95
- reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: readonly T[]) => U, initialValue: U): U;
96
- /**
97
- * Executes a reducer function on each element of the array (right-to-left), resulting in a single output value
98
- */
99
- reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T): T;
100
- reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: readonly T[]) => T, initialValue: T): T;
101
- reduceRight<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: readonly T[]) => U, initialValue: U): U;
102
- /**
103
- * Executes a provided function once for each array element
104
- */
105
- forEach(callbackfn: (value: T, index: number, array: readonly T[]) => void, thisArg?: any): void;
106
- /**
107
- * Returns the value of the first element in the array that satisfies the provided testing function
108
- */
109
- find<S extends T>(predicate: (value: T, index: number, array: readonly T[]) => value is S, thisArg?: any): S | undefined;
110
- find(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): T | undefined;
111
- /**
112
- * Returns the index of the first element in the array that satisfies the provided testing function
113
- */
114
- findIndex(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): number;
115
- /**
116
- * Returns the value of the last element in the array that satisfies the provided testing function
117
- */
118
- findLast<S extends T>(predicate: (value: T, index: number, array: readonly T[]) => value is S, thisArg?: any): S | undefined;
119
- findLast(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): T | undefined;
120
- /**
121
- * Returns the index of the last element in the array that satisfies the provided testing function
122
- */
123
- findLastIndex(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): number;
124
- /**
125
- * Determines whether an array includes a certain value among its entries
126
- */
127
- includes(searchElement: T, fromIndex?: number): boolean;
128
- /**
129
- * Returns the first index at which a given element can be found in the array
130
- */
131
- indexOf(searchElement: T, fromIndex?: number): number;
132
- /**
133
- * Returns the last index at which a given element can be found in the array
134
- */
135
- lastIndexOf(searchElement: T, fromIndex?: number): number;
136
- /**
137
- * Returns a shallow copy of a portion of an array into a new array object
138
- */
139
- slice(start?: number, end?: number): T[];
140
- /**
141
- * Returns a new array comprised of this array joined with other array(s) and/or value(s)
142
- */
143
- concat(...items: ConcatArray<T>[]): T[];
144
- concat(...items: (T | ConcatArray<T>)[]): T[];
145
- /**
146
- * Tests whether all elements in the array pass the test implemented by the provided function
147
- */
148
- every(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): boolean;
149
- /**
150
- * Tests whether at least one element in the array passes the test implemented by the provided function
151
- */
152
- some(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: any): boolean;
153
- /**
154
- * Joins all elements of an array into a string
155
- */
156
- join(separator?: string): string;
157
- /**
158
- * Returns a new array iterator that contains the keys for each index in the array
159
- */
160
- keys(): IterableIterator<number>;
161
- /**
162
- * Returns a new array iterator that contains the values for each index in the array
163
- */
164
- values(): IterableIterator<T>;
165
- /**
166
- * Returns a new array iterator that contains the key/value pairs for each index in the array
167
- */
168
- entries(): IterableIterator<[number, T]>;
169
- /**
170
- * Returns a string representation of the array
171
- */
172
- toString(): string;
173
- /**
174
- * Returns a localized string representing the array
175
- */
176
- toLocaleString(locales?: string | string[], options?: Intl.NumberFormatOptions | Intl.DateTimeFormatOptions): string;
177
- /**
178
- * Returns the element at the specified index, or undefined if the index is out of bounds
179
- */
180
- at(index: number): T | undefined;
181
- /**
182
- * Returns a new array with all sub-array elements concatenated into it recursively up to the specified depth
183
- */
184
- flat(depth?: number): T[];
185
- /**
186
- * Returns a new array formed by applying a given callback function to each element of the array,
187
- * and then flattening the result by one level
188
- */
189
- flatMap<U, This = undefined>(callback: (this: This, value: T, index: number, array: readonly T[]) => U | ReadonlyArray<U>, thisArg?: This): U[];
190
- /**
191
- * Returns a new array with elements in reversed order (ES2023)
192
- */
193
- toReversed(): T[];
194
- /**
195
- * Returns a new array with elements sorted (ES2023)
196
- */
197
- toSorted(compareFn?: ((a: T, b: T) => number) | undefined): T[];
198
- /**
199
- * Returns a new array with some elements removed and/or replaced at a given index (ES2023)
200
- */
201
- toSpliced(start: number, deleteCount?: number, ...items: T[]): T[];
202
- /**
203
- * Returns a new array with the element at the given index replaced with the given value (ES2023)
204
- */
205
- with(index: number, value: T): T[];
206
- get [Symbol.unscopables](): {
207
- readonly [x: number]: boolean;
208
- readonly length?: boolean;
209
- toString?: boolean;
210
- toLocaleString?: boolean;
211
- concat?: boolean;
212
- join?: boolean;
213
- slice?: boolean;
214
- indexOf?: boolean;
215
- lastIndexOf?: boolean;
216
- every?: boolean;
217
- some?: boolean;
218
- forEach?: boolean;
219
- map?: boolean;
220
- filter?: boolean;
221
- reduce?: boolean;
222
- reduceRight?: boolean;
223
- find?: boolean;
224
- findIndex?: boolean;
225
- entries?: boolean;
226
- keys?: boolean;
227
- values?: boolean;
228
- includes?: boolean;
229
- flatMap?: boolean;
230
- flat?: boolean;
231
- at?: boolean;
232
- findLast?: boolean;
233
- findLastIndex?: boolean;
234
- toReversed?: boolean;
235
- toSorted?: boolean;
236
- toSpliced?: boolean;
237
- with?: boolean;
238
- [Symbol.iterator]?: boolean;
239
- readonly [Symbol.unscopables]?: boolean;
240
- };
241
- }
242
-
243
- export { ArrayReadForward, Indexable, forwardArray, getAt, setAt };