mutts 1.0.1 → 1.0.3

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 (111) hide show
  1. package/README.md +36 -6
  2. package/dist/chunks/_tslib-BgjropY9.js +81 -0
  3. package/dist/chunks/_tslib-BgjropY9.js.map +1 -0
  4. package/dist/chunks/_tslib-Mzh1rNsX.esm.js +75 -0
  5. package/dist/chunks/_tslib-Mzh1rNsX.esm.js.map +1 -0
  6. package/dist/chunks/{decorator-8qjFb7dw.js → decorator-DLvrD0UF.js} +103 -14
  7. package/dist/chunks/decorator-DLvrD0UF.js.map +1 -0
  8. package/dist/chunks/{decorator-AbRkXM5O.esm.js → decorator-DqiszP7i.esm.js} +100 -15
  9. package/dist/chunks/decorator-DqiszP7i.esm.js.map +1 -0
  10. package/dist/chunks/index-DzUDtFc7.esm.js +4841 -0
  11. package/dist/chunks/index-DzUDtFc7.esm.js.map +1 -0
  12. package/dist/chunks/index-HNVqPzjz.js +4891 -0
  13. package/dist/chunks/index-HNVqPzjz.js.map +1 -0
  14. package/dist/decorator.d.ts +57 -0
  15. package/dist/decorator.esm.js +1 -1
  16. package/dist/decorator.js +1 -1
  17. package/dist/destroyable.d.ts +43 -1
  18. package/dist/destroyable.esm.js +19 -1
  19. package/dist/destroyable.esm.js.map +1 -1
  20. package/dist/destroyable.js +19 -1
  21. package/dist/destroyable.js.map +1 -1
  22. package/dist/devtools/devtools.html +9 -0
  23. package/dist/devtools/devtools.js +5 -0
  24. package/dist/devtools/devtools.js.map +1 -0
  25. package/dist/devtools/manifest.json +8 -0
  26. package/dist/devtools/panel.css +72 -0
  27. package/dist/devtools/panel.html +31 -0
  28. package/dist/devtools/panel.js +13048 -0
  29. package/dist/devtools/panel.js.map +1 -0
  30. package/dist/eventful.d.ts +10 -1
  31. package/dist/eventful.esm.js +5 -27
  32. package/dist/eventful.esm.js.map +1 -1
  33. package/dist/eventful.js +15 -37
  34. package/dist/eventful.js.map +1 -1
  35. package/dist/index.d.ts +18 -14
  36. package/dist/index.esm.js +4 -3
  37. package/dist/index.esm.js.map +1 -1
  38. package/dist/index.js +44 -5
  39. package/dist/index.js.map +1 -1
  40. package/dist/indexable.d.ts +213 -1
  41. package/dist/indexable.esm.js +203 -3
  42. package/dist/indexable.esm.js.map +1 -1
  43. package/dist/indexable.js +204 -2
  44. package/dist/indexable.js.map +1 -1
  45. package/dist/mutts.umd.js +1 -1
  46. package/dist/mutts.umd.js.map +1 -1
  47. package/dist/mutts.umd.min.js +1 -1
  48. package/dist/mutts.umd.min.js.map +1 -1
  49. package/dist/promiseChain.d.ts +10 -0
  50. package/dist/promiseChain.esm.js +6 -0
  51. package/dist/promiseChain.esm.js.map +1 -1
  52. package/dist/promiseChain.js +6 -0
  53. package/dist/promiseChain.js.map +1 -1
  54. package/dist/reactive.d.ts +774 -33
  55. package/dist/reactive.esm.js +4 -1458
  56. package/dist/reactive.esm.js.map +1 -1
  57. package/dist/reactive.js +53 -1474
  58. package/dist/reactive.js.map +1 -1
  59. package/dist/std-decorators.d.ts +35 -0
  60. package/dist/std-decorators.esm.js +36 -1
  61. package/dist/std-decorators.esm.js.map +1 -1
  62. package/dist/std-decorators.js +36 -1
  63. package/dist/std-decorators.js.map +1 -1
  64. package/docs/ai/api-reference.md +133 -0
  65. package/docs/ai/manual.md +105 -0
  66. package/docs/iterableWeak.md +646 -0
  67. package/docs/mixin.md +229 -0
  68. package/docs/reactive/advanced.md +1280 -0
  69. package/docs/reactive/collections.md +767 -0
  70. package/docs/reactive/core.md +973 -0
  71. package/docs/reactive.md +21 -2688
  72. package/package.json +18 -5
  73. package/src/decorator.ts +266 -0
  74. package/src/destroyable.ts +199 -0
  75. package/src/eventful.ts +77 -0
  76. package/src/index.d.ts +9 -0
  77. package/src/index.ts +9 -0
  78. package/src/indexable.ts +484 -0
  79. package/src/introspection.ts +59 -0
  80. package/src/iterableWeak.ts +233 -0
  81. package/src/mixins.ts +123 -0
  82. package/src/promiseChain.ts +110 -0
  83. package/src/reactive/array.ts +414 -0
  84. package/src/reactive/change.ts +134 -0
  85. package/src/reactive/debug.ts +517 -0
  86. package/src/reactive/deep-touch.ts +268 -0
  87. package/src/reactive/deep-watch-state.ts +82 -0
  88. package/src/reactive/deep-watch.ts +168 -0
  89. package/src/reactive/effect-context.ts +94 -0
  90. package/src/reactive/effects.ts +1333 -0
  91. package/src/reactive/index.ts +75 -0
  92. package/src/reactive/interface.ts +223 -0
  93. package/src/reactive/map.ts +171 -0
  94. package/src/reactive/mapped.ts +130 -0
  95. package/src/reactive/memoize.ts +107 -0
  96. package/src/reactive/non-reactive-state.ts +49 -0
  97. package/src/reactive/non-reactive.ts +43 -0
  98. package/src/reactive/project.project.md +93 -0
  99. package/src/reactive/project.ts +335 -0
  100. package/src/reactive/proxy-state.ts +27 -0
  101. package/src/reactive/proxy.ts +285 -0
  102. package/src/reactive/record.ts +196 -0
  103. package/src/reactive/register.ts +421 -0
  104. package/src/reactive/set.ts +144 -0
  105. package/src/reactive/tracking.ts +101 -0
  106. package/src/reactive/types.ts +358 -0
  107. package/src/reactive/zone.ts +208 -0
  108. package/src/std-decorators.ts +217 -0
  109. package/src/utils.ts +117 -0
  110. package/dist/chunks/decorator-8qjFb7dw.js.map +0 -1
  111. package/dist/chunks/decorator-AbRkXM5O.esm.js.map +0 -1
@@ -1,4 +1,12 @@
1
- declare class Eventful<Events extends Record<string, (...args: any[]) => void>> {
1
+ /**
2
+ * Base type for event maps - all event handlers must be functions
3
+ */
4
+ type EventsBase = Record<string, (...args: any[]) => void>;
5
+ /**
6
+ * A type-safe event system that provides a clean API for event handling
7
+ * @template Events - The event map defining event names and their handler signatures
8
+ */
9
+ declare class Eventful<Events extends EventsBase> {
2
10
  #private;
3
11
  hook(cb: <EventType extends keyof Events>(event: EventType, ...args: Parameters<Events[EventType]>) => void): () => void;
4
12
  on(events: Partial<Events>): void;
@@ -9,3 +17,4 @@ declare class Eventful<Events extends Record<string, (...args: any[]) => void>>
9
17
  }
10
18
 
11
19
  export { Eventful };
20
+ export type { EventsBase };
@@ -1,32 +1,10 @@
1
- /******************************************************************************
2
- Copyright (c) Microsoft Corporation.
3
-
4
- Permission to use, copy, modify, and/or distribute this software for any
5
- purpose with or without fee is hereby granted.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
- PERFORMANCE OF THIS SOFTWARE.
14
- ***************************************************************************** */
15
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
16
-
17
-
18
- function __classPrivateFieldGet(receiver, state, kind, f) {
19
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
20
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
21
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
22
- }
23
-
24
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
25
- var e = new Error(message);
26
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
27
- };
1
+ import { _ as __classPrivateFieldGet } from './chunks/_tslib-Mzh1rNsX.esm.js';
28
2
 
29
3
  var _Eventful_events, _Eventful_hooks;
4
+ /**
5
+ * A type-safe event system that provides a clean API for event handling
6
+ * @template Events - The event map defining event names and their handler signatures
7
+ */
30
8
  class Eventful {
31
9
  constructor() {
32
10
  _Eventful_events.set(this, new Map());
@@ -1 +1 @@
1
- {"version":3,"file":"eventful.esm.js","sources":["../src/eventful.ts"],"sourcesContent":["export class Eventful<Events extends Record<string, (...args: any[]) => void>> {\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)\n\t\tfor (const cb of this.#hooks) cb.call(this, event, ...args)\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAAa,QAAQ,CAAA;AAArB,IAAA,WAAA,GAAA;QACU,gBAAA,CAAA,GAAA,CAAA,IAAA,EAAU,IAAI,GAAG,EAA8C,CAAA;AAC/D,QAAA,eAAA,CAAA,GAAA,CAAA,IAAA,EAAS,EAAkC,CAAA;IAkErD;AAhEQ,IAAA,IAAI,CACV,EAGS,EAAA;QAET,IAAI,CAAC,uBAAA,IAAI,EAAA,eAAA,EAAA,GAAA,CAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;AAAE,YAAA,sBAAA,CAAA,IAAI,EAAA,eAAA,EAAA,GAAA,CAAO,CAAC,IAAI,CAAC,EAAE,CAAC;AACnD,QAAA,OAAO,MAAK;AACX,YAAA,sBAAA,CAAA,IAAI,EAAA,eAAA,EAAA,GAAA,CAAO,CAAC,MAAM,CAAC,uBAAA,IAAI,EAAA,eAAA,EAAA,GAAA,CAAO,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AAC/C,QAAA,CAAC;IACF;IAIO,EAAE,CACR,aAA0C,EAC1C,EAAsB,EAAA;AAEtB,QAAA,IAAI,OAAO,aAAa,KAAK,QAAQ,EAAE;YACtC,KAAK,MAAM,CAAC,IAAI,MAAM,CA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IACD;AACO,IAAA,IAAI,CACV,KAAgB,EAChB,GAAG,IAAmC,EAAA;QAEtC,MAAM,SAAS,GAAG,sBAAA,CAAA,IAAI,EAAA,gBAAA,EAAA,GAAA,CAAQ,CAAC,GAAG,CAAC,KAAK,CAAC;AACzC,QAAA,IAAI,SAAS;YAAE,KAAK,MAAM,EAAE,IAAI,SAAS;AAAE,gBAAA,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC;AAC/D,QAAA,KAAK,MAAM,EAAE,IAAI,sBAAA,CAAA,IAAI,EAAA,eAAA,EAAA,GAAA,CAAO;YAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;IAC5D;AACA;;;;;"}
1
+ {"version":3,"file":"eventful.esm.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)\n\t\tfor (const cb of this.#hooks) cb.call(this, event, ...args)\n\t}\n}\n"],"names":[],"mappings":";;;AAIA;;;AAGG;MACU,QAAQ,CAAA;AAArB,IAAA,WAAA,GAAA;QACU,gBAAA,CAAA,GAAA,CAAA,IAAA,EAAU,IAAI,GAAG,EAA8C,CAAA;AAC/D,QAAA,eAAA,CAAA,GAAA,CAAA,IAAA,EAAS,EAAkC,CAAA;IAkErD;AAhEQ,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AC,IAAI,CAAC,aAAa,CAAqB,EAAE;gBAC/D,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;YAC9B;QACD;aAAO,IAAI,EAAE,KAAK,IAAI,IAAI,EAAE,KAAK,SAAS,EAAE;YAC3C,MAAM,SAAS,GAAG,sBAAA,CAAA,IAAI,EAAA,gBAAA,EAAA,GAAA,CAAQ,CAAC,GAAG,CAAC,aAAa,CAAC;YACjD,IAAI,SAAS,EAAE;gBACd,sBAAA,CAAA,IAAI,wBAAQ,CAAC,GAAG,CACf,aAAa,EACb,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CACjC;YACF;QACD;aAAO;;AAEN,YAAA,sBAAA,CAAA,IAAI,EAAA,gBAAA,EAAA,GAAA,CAAQ,CAAC,MAAM,CAAC,aAAa,CAAC;QACnC;IACD;AACO,IAAA,IAAI,CACV,KAAgB,EAChB,GAAG,IAAmC,EAAA;QAEtC,MAAM,SAAS,GAAG,sBAAA,CAAA,IAAI,EAAA,gBAAA,EAAA,GAAA,CAAQ,CAAC,GAAG,CAAC,KAAK,CAAC;AACzC,QAAA,IAAI,SAAS;YAAE,KAAK,MAAM,EAAE,IAAI,SAAS;AAAE,gBAAA,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC;AAC/D,QAAA,KAAK,MAAM,EAAE,IAAI,sBAAA,CAAA,IAAI,EAAA,eAAA,EAAA,GAAA,CAAO;YAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;IAC5D;AACA;;;;;"}
package/dist/eventful.js CHANGED
@@ -1,44 +1,22 @@
1
1
  'use strict';
2
2
 
3
- /******************************************************************************
4
- Copyright (c) Microsoft Corporation.
5
-
6
- Permission to use, copy, modify, and/or distribute this software for any
7
- purpose with or without fee is hereby granted.
8
-
9
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
- PERFORMANCE OF THIS SOFTWARE.
16
- ***************************************************************************** */
17
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
18
-
19
-
20
- function __classPrivateFieldGet(receiver, state, kind, f) {
21
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
22
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
23
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
24
- }
25
-
26
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
27
- var e = new Error(message);
28
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
29
- };
3
+ var _tslib = require('./chunks/_tslib-BgjropY9.js');
30
4
 
31
5
  var _Eventful_events, _Eventful_hooks;
6
+ /**
7
+ * A type-safe event system that provides a clean API for event handling
8
+ * @template Events - The event map defining event names and their handler signatures
9
+ */
32
10
  class Eventful {
33
11
  constructor() {
34
12
  _Eventful_events.set(this, new Map());
35
13
  _Eventful_hooks.set(this, []);
36
14
  }
37
15
  hook(cb) {
38
- if (!__classPrivateFieldGet(this, _Eventful_hooks, "f").includes(cb))
39
- __classPrivateFieldGet(this, _Eventful_hooks, "f").push(cb);
16
+ if (!_tslib.__classPrivateFieldGet(this, _Eventful_hooks, "f").includes(cb))
17
+ _tslib.__classPrivateFieldGet(this, _Eventful_hooks, "f").push(cb);
40
18
  return () => {
41
- __classPrivateFieldGet(this, _Eventful_hooks, "f").splice(__classPrivateFieldGet(this, _Eventful_hooks, "f").indexOf(cb), 1);
19
+ _tslib.__classPrivateFieldGet(this, _Eventful_hooks, "f").splice(_tslib.__classPrivateFieldGet(this, _Eventful_hooks, "f").indexOf(cb), 1);
42
20
  };
43
21
  }
44
22
  on(eventOrEvents, cb) {
@@ -48,10 +26,10 @@ class Eventful {
48
26
  }
49
27
  }
50
28
  else if (cb !== undefined) {
51
- let callbacks = __classPrivateFieldGet(this, _Eventful_events, "f").get(eventOrEvents);
29
+ let callbacks = _tslib.__classPrivateFieldGet(this, _Eventful_events, "f").get(eventOrEvents);
52
30
  if (!callbacks) {
53
31
  callbacks = [];
54
- __classPrivateFieldGet(this, _Eventful_events, "f").set(eventOrEvents, callbacks);
32
+ _tslib.__classPrivateFieldGet(this, _Eventful_events, "f").set(eventOrEvents, callbacks);
55
33
  }
56
34
  callbacks.push(cb);
57
35
  }
@@ -65,22 +43,22 @@ class Eventful {
65
43
  }
66
44
  }
67
45
  else if (cb !== null && cb !== undefined) {
68
- const callbacks = __classPrivateFieldGet(this, _Eventful_events, "f").get(eventOrEvents);
46
+ const callbacks = _tslib.__classPrivateFieldGet(this, _Eventful_events, "f").get(eventOrEvents);
69
47
  if (callbacks) {
70
- __classPrivateFieldGet(this, _Eventful_events, "f").set(eventOrEvents, callbacks.filter((c) => c !== cb));
48
+ _tslib.__classPrivateFieldGet(this, _Eventful_events, "f").set(eventOrEvents, callbacks.filter((c) => c !== cb));
71
49
  }
72
50
  }
73
51
  else {
74
52
  // Remove all listeners for this event
75
- __classPrivateFieldGet(this, _Eventful_events, "f").delete(eventOrEvents);
53
+ _tslib.__classPrivateFieldGet(this, _Eventful_events, "f").delete(eventOrEvents);
76
54
  }
77
55
  }
78
56
  emit(event, ...args) {
79
- const callbacks = __classPrivateFieldGet(this, _Eventful_events, "f").get(event);
57
+ const callbacks = _tslib.__classPrivateFieldGet(this, _Eventful_events, "f").get(event);
80
58
  if (callbacks)
81
59
  for (const cb of callbacks)
82
60
  cb.apply(this, args);
83
- for (const cb of __classPrivateFieldGet(this, _Eventful_hooks, "f"))
61
+ for (const cb of _tslib.__classPrivateFieldGet(this, _Eventful_hooks, "f"))
84
62
  cb.call(this, event, ...args);
85
63
  }
86
64
  }
@@ -1 +1 @@
1
- {"version":3,"file":"eventful.js","sources":["../src/eventful.ts"],"sourcesContent":["export class Eventful<Events extends Record<string, (...args: any[]) => void>> {\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)\n\t\tfor (const cb of this.#hooks) cb.call(this, event, ...args)\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAAa,QAAQ,CAAA;AAArB,IAAA,WAAA,GAAA;QACU,gBAAA,CAAA,GAAA,CAAA,IAAA,EAAU,IAAI,GAAG,EAA8C,CAAA;AAC/D,QAAA,eAAA,CAAA,GAAA,CAAA,IAAA,EAAS,EAAkC,CAAA;IAkErD;AAhEQ,IAAA,IAAI,CACV,EAGS,EAAA;QAET,IAAI,CAAC,uBAAA,IAAI,EAAA,eAAA,EAAA,GAAA,CAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;AAAE,YAAA,sBAAA,CAAA,IAAI,EAAA,eAAA,EAAA,GAAA,CAAO,CAAC,IAAI,CAAC,EAAE,CAAC;AACnD,QAAA,OAAO,MAAK;AACX,YAAA,sBAAA,CAAA,IAAI,EAAA,eAAA,EAAA,GAAA,CAAO,CAAC,MAAM,CAAC,uBAAA,IAAI,EAAA,eAAA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wBAAQ,CAAC,GAAG,CACf,aAAa,EACb,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CACjC;YACF;QACD;aAAO;;AAEN,YAAA,sBAAA,CAAA,IAAI,EAAA,gBAAA,EAAA,GAAA,CAAQ,CAAC,MAAM,CAAC,aAAa,CAAC;QACnC;IACD;AACO,IAAA,IAAI,CACV,KAAgB,EAChB,GAAG,IAAmC,EAAA;QAEtC,MAAM,SAAS,GAAG,sBAAA,CAAA,IAAI,EAAA,gBAAA,EAAA,GAAA,CAAQ,CAAC,GAAG,CAAC,KAAK,CAAC;AACzC,QAAA,IAAI,SAAS;YAAE,KAAK,MAAM,EAAE,IAAI,SAAS;AAAE,gBAAA,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC;AAC/D,QAAA,KAAK,MAAM,EAAE,IAAI,sBAAA,CAAA,IAAI,EAAA,eAAA,EAAA,GAAA,CAAO;YAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;IAC5D;AACA;;;;;"}
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)\n\t\tfor (const cb of this.#hooks) cb.call(this, event, ...args)\n\t}\n}\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K,EAAE,GAAG,IAAI,CAAC;IAC5D;AACA;;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,15 +1,19 @@
1
- export { Decorator, DecoratorDescription, DecoratorError, DecoratorFactory, GenericClassDecorator, LegacyClassDecorator, LegacyPropertyDecorator, ModernAccessorDecorator, ModernClassDecorator, ModernGetterDecorator, ModernMethodDecorator, ModernSetterDecorator, decorator, legacyDecorator, modernDecorator } from './decorator.js';
2
- export { ContextManager, Destroyable, DestructionError, allocated, allocatedValues, callOnGC, destructor } from './destroyable.js';
3
- export { Eventful } from './eventful.js';
4
- export { Indexable, getAt, setAt } from './indexable.js';
5
- export { ReactiveBase, ReactiveError, ScopedCallback, atomic, computed, effect, getState, immutables, invalidateComputed, isNonReactive, isReactive, profileInfo, reactive, reactiveOptions, unreactive, untracked, unwrap, watch } from './reactive.js';
6
- export { cache, cached, debounce, deprecated, describe, isCached, throttle } from './std-decorators.js';
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'
7
10
 
8
- type ElementTypes<T extends readonly unknown[]> = {
9
- [K in keyof T]: T[K] extends readonly (infer U)[] ? U : T[K];
10
- };
11
- declare function zip<T extends (readonly unknown[])[]>(...args: T): ElementTypes<T>[];
12
- declare function isConstructor(fn: Function): boolean;
13
- declare function renamed<F extends Function>(fct: F, name: string): F;
14
-
15
- export { isConstructor, renamed, zip };
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 CHANGED
@@ -1,7 +1,8 @@
1
- export { D as DecoratorError, d as decorator, i as isConstructor, l as legacyDecorator, m as modernDecorator, r as renamed, z as zip } from './chunks/decorator-AbRkXM5O.esm.js';
1
+ export { D as DecoratorError, R as ReflectGet, b as ReflectSet, a as arrayEquals, d as decorator, i as isConstructor, c as isOwnAccessor, l as legacyDecorator, m as modernDecorator, r as renamed, z as zip } from './chunks/decorator-DqiszP7i.esm.js';
2
2
  export { Destroyable, DestructionError, allocated, allocatedValues, callOnGC, destructor } from './destroyable.esm.js';
3
3
  export { Eventful } from './eventful.esm.js';
4
- export { Indexable, getAt, setAt } from './indexable.esm.js';
5
- export { ReactiveBase, ReactiveError, atomic, computed, effect, getState, immutables, invalidateComputed, isNonReactive, isReactive, profileInfo, reactive, reactiveOptions, unreactive, untracked, unwrap, watch } from './reactive.esm.js';
4
+ export { ArrayReadForward, Indexable, forwardArray, getAt, setAt } from './indexable.esm.js';
5
+ export { I as IterableWeakMap, a as IterableWeakSet, L as ReactiveBase, U as ReactiveError, R as ReadOnlyError, Q as Register, j as addBatchCleanup, k as atomic, l as biDi, c as buildReactivityGraph, x as cleanedBy, y as cleanup, h as deepWatch, n as defer, z as derived, o as effect, e as enableDevTools, q as getActiveEffect, g as getState, F as immutables, i as isDevtoolsEnabled, G as isNonReactive, K as isReactive, V as isZoneEnabled, C as mapped, E as memoize, m as mixin, O as organize, P as organized, p as profileInfo, J as project, M as reactive, T as reactiveOptions, D as reduced, S as register, r as registerEffectForDebug, H as registerNativeReactivity, d as registerObjectForDebug, u as root, s as setEffectName, f as setObjectName, W as setZoneEnabled, t as touched, b as touched1, v as trackEffect, A as unreactive, w as untracked, N as unwrap, B as watch } from './chunks/index-DzUDtFc7.esm.js';
6
6
  export { cache, cached, debounce, deprecated, describe, isCached, throttle } from './std-decorators.esm.js';
7
+ import './chunks/_tslib-Mzh1rNsX.esm.js';
7
8
  //# sourceMappingURL=index.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
package/dist/index.js CHANGED
@@ -1,17 +1,22 @@
1
1
  'use strict';
2
2
 
3
- var decorator = require('./chunks/decorator-8qjFb7dw.js');
3
+ var decorator = require('./chunks/decorator-DLvrD0UF.js');
4
4
  var destroyable = require('./destroyable.js');
5
5
  var eventful = require('./eventful.js');
6
6
  var indexable = require('./indexable.js');
7
- var reactive = require('./reactive.js');
7
+ var reactive = require('./chunks/index-HNVqPzjz.js');
8
8
  var stdDecorators = require('./std-decorators.js');
9
+ require('./chunks/_tslib-BgjropY9.js');
9
10
 
10
11
 
11
12
 
12
13
  exports.DecoratorError = decorator.DecoratorError;
14
+ exports.ReflectGet = decorator.ReflectGet;
15
+ exports.ReflectSet = decorator.ReflectSet;
16
+ exports.arrayEquals = decorator.arrayEquals;
13
17
  exports.decorator = decorator.decorator;
14
18
  exports.isConstructor = decorator.isConstructor;
19
+ exports.isOwnAccessor = decorator.isOwnAccessor;
15
20
  exports.legacyDecorator = decorator.legacyDecorator;
16
21
  exports.modernDecorator = decorator.modernDecorator;
17
22
  exports.renamed = decorator.renamed;
@@ -23,22 +28,56 @@ exports.allocatedValues = destroyable.allocatedValues;
23
28
  exports.callOnGC = destroyable.callOnGC;
24
29
  exports.destructor = destroyable.destructor;
25
30
  exports.Eventful = eventful.Eventful;
31
+ exports.ArrayReadForward = indexable.ArrayReadForward;
26
32
  exports.Indexable = indexable.Indexable;
33
+ exports.forwardArray = indexable.forwardArray;
27
34
  exports.getAt = indexable.getAt;
28
35
  exports.setAt = indexable.setAt;
36
+ exports.IterableWeakMap = reactive.IterableWeakMap;
37
+ exports.IterableWeakSet = reactive.IterableWeakSet;
29
38
  exports.ReactiveBase = reactive.ReactiveBase;
30
39
  exports.ReactiveError = reactive.ReactiveError;
40
+ exports.ReadOnlyError = reactive.ReadOnlyError;
41
+ exports.Register = reactive.Register;
42
+ exports.addBatchCleanup = reactive.addBatchCleanup;
31
43
  exports.atomic = reactive.atomic;
32
- exports.computed = reactive.computed;
44
+ exports.biDi = reactive.biDi;
45
+ exports.buildReactivityGraph = reactive.buildReactivityGraph;
46
+ exports.cleanedBy = reactive.cleanedBy;
47
+ exports.cleanup = reactive.cleanup;
48
+ exports.deepWatch = reactive.deepWatch;
49
+ exports.defer = reactive.defer;
50
+ exports.derived = reactive.derived;
33
51
  exports.effect = reactive.effect;
52
+ exports.enableDevTools = reactive.enableDevTools;
53
+ exports.getActiveEffect = reactive.getActiveEffect;
34
54
  exports.getState = reactive.getState;
35
55
  exports.immutables = reactive.immutables;
36
- exports.invalidateComputed = reactive.invalidateComputed;
56
+ exports.isDevtoolsEnabled = reactive.isDevtoolsEnabled;
37
57
  exports.isNonReactive = reactive.isNonReactive;
38
58
  exports.isReactive = reactive.isReactive;
59
+ exports.isZoneEnabled = reactive.isZoneEnabled;
60
+ exports.mapped = reactive.mapped;
61
+ exports.memoize = reactive.memoize;
62
+ exports.mixin = reactive.mixin;
63
+ exports.organize = reactive.organize;
64
+ exports.organized = reactive.organized;
39
65
  exports.profileInfo = reactive.profileInfo;
66
+ exports.project = reactive.project;
40
67
  exports.reactive = reactive.reactive;
41
- exports.reactiveOptions = reactive.reactiveOptions;
68
+ exports.reactiveOptions = reactive.options;
69
+ exports.reduced = reactive.reduced;
70
+ exports.register = reactive.register;
71
+ exports.registerEffectForDebug = reactive.registerEffectForDebug;
72
+ exports.registerNativeReactivity = reactive.registerNativeReactivity;
73
+ exports.registerObjectForDebug = reactive.registerObjectForDebug;
74
+ exports.root = reactive.root;
75
+ exports.setEffectName = reactive.setEffectName;
76
+ exports.setObjectName = reactive.setObjectName;
77
+ exports.setZoneEnabled = reactive.setZoneEnabled;
78
+ exports.touched = reactive.touched;
79
+ exports.touched1 = reactive.touched1;
80
+ exports.trackEffect = reactive.trackEffect;
42
81
  exports.unreactive = reactive.unreactive;
43
82
  exports.untracked = reactive.untracked;
44
83
  exports.unwrap = reactive.unwrap;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,4 +1,10 @@
1
+ /**
2
+ * Symbol for defining custom getter logic for numeric index access
3
+ */
1
4
  declare const getAt: unique symbol;
5
+ /**
6
+ * Symbol for defining custom setter logic for numeric index access
7
+ */
2
8
  declare const setAt: unique symbol;
3
9
  interface IndexingAt<Items = any> {
4
10
  [getAt](index: number): Items;
@@ -12,20 +18,226 @@ interface Accessor<T, Items> {
12
18
  declare abstract class AbstractGetAt<Items = any> {
13
19
  abstract [getAt](index: number): Items;
14
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
+ */
15
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> & {
16
28
  [x: number]: Items;
17
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
+ */
18
35
  declare function Indexable<Items>(accessor: Accessor<any, Items>): new () => {
19
36
  [x: number]: Items;
20
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
+ */
21
43
  declare function Indexable<Base extends new (...args: any[]) => IndexingAt>(base: Base): new (...args: ConstructorParameters<Base>) => InstanceType<Base> & {
22
44
  [x: number]: AtReturnType<InstanceType<Base>>;
23
45
  };
46
+ /**
47
+ * Creates an abstract indexable base class
48
+ * @returns An abstract class that supports numeric index access
49
+ */
24
50
  declare function Indexable<Items>(): abstract new (...args: any[]) => AbstractGetAt & {
25
51
  [x: number]: Items;
26
52
  };
27
53
  type AtReturnType<T> = T extends {
28
54
  [getAt](index: number): infer R;
29
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
+ }
30
242
 
31
- export { Indexable, getAt, setAt };
243
+ export { ArrayReadForward, Indexable, forwardArray, getAt, setAt };