mutts 1.0.10 → 1.0.11
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 +3 -3
- package/dist/browser.cjs +395 -987
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.ts +2 -2
- package/dist/browser.dev.cjs +13 -9
- package/dist/browser.dev.cjs.map +1 -1
- package/dist/browser.dev.d.ts +2 -2
- package/dist/browser.dev.esm.js +2 -2
- package/dist/browser.esm.js +15 -13
- package/dist/browser.esm.js.map +1 -1
- package/dist/chunks/{async-browser-BU_IfxYD.cjs → async-browser-Dgr5CreQ.cjs} +13 -11
- package/dist/chunks/async-browser-Dgr5CreQ.cjs.map +1 -0
- package/dist/chunks/{index-CaaQQlPJ.esm.js → index-Sf74wXTV.esm.js} +384 -981
- package/dist/chunks/index-Sf74wXTV.esm.js.map +1 -0
- package/dist/chunks/{node-nKJBk8iJ.esm.js → node-Bo7WU5S2.esm.js} +2 -2
- package/dist/chunks/{node-nKJBk8iJ.esm.js.map → node-Bo7WU5S2.esm.js.map} +1 -1
- package/dist/chunks/{proxy-Dtg-bJ3T.cjs → proxy-Cc79Lrzj.cjs} +414 -339
- package/dist/chunks/proxy-Cc79Lrzj.cjs.map +1 -0
- package/dist/chunks/{proxy-r7lARftl.esm.js → proxy-D2C49sXH.esm.js} +401 -330
- package/dist/chunks/proxy-D2C49sXH.esm.js.map +1 -0
- package/dist/debug.cjs +17 -3
- package/dist/debug.cjs.map +1 -1
- package/dist/debug.d.ts +2 -2
- package/dist/debug.esm.js +17 -3
- package/dist/debug.esm.js.map +1 -1
- package/dist/index.d.ts +84 -209
- package/dist/mutts.umd.js +842 -1362
- 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 +13 -9
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.ts +2 -2
- package/dist/node.dev.cjs +13 -9
- package/dist/node.dev.cjs.map +1 -1
- package/dist/node.dev.d.ts +2 -2
- package/dist/node.dev.esm.js +3 -3
- package/dist/node.esm.js +3 -3
- package/dist/{types-W5vD6m2n.d.ts → types-Bx2PhORg.d.ts} +38 -47
- package/docs/ai/api-reference.md +0 -14
- package/docs/ai/manual.md +2 -22
- package/docs/reactive/advanced.md +13 -14
- package/docs/reactive/attend.md +1 -2
- package/docs/reactive/collections.md +2 -149
- package/docs/reactive/core.md +218 -96
- package/docs/reactive/debugging.md +2 -2
- package/docs/reactive/resource.md +1 -1
- package/docs/reactive.md +1 -3
- package/docs/zone.md +1 -1
- package/package.json +18 -9
- package/dist/chunks/async-browser-BU_IfxYD.cjs.map +0 -1
- package/dist/chunks/index-CaaQQlPJ.esm.js.map +0 -1
- package/dist/chunks/proxy-Dtg-bJ3T.cjs.map +0 -1
- package/dist/chunks/proxy-r7lARftl.esm.js.map +0 -1
- package/docs/reactive/scan.md +0 -324
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as
|
|
2
|
-
export { A as AZone,
|
|
1
|
+
import { c as EffectAccess, d as EffectCloser, S as ScopedCallback, e as State, a as Evolution, b as EffectCleanup, Z as ZoneAggregator, C as CleanupReason, H as HistoryValue, E as EffectTrigger, f as CatchFunction, g as EffectOptions } from './types-Bx2PhORg.js';
|
|
2
|
+
export { A as AZone, G as GetterWrapper, P as PropTrigger, R as ReactiveError, h as ReactiveErrorCode, i as Zone, j as ZoneHistory, k as asyncZone, l as debugPreset, m as devPreset, n as formatCleanupReason, o as isReactive, p as objectToProxy, q as prodPreset, r as proxyToObject, s as reactiveOptions, u as unwrap } from './types-Bx2PhORg.js';
|
|
3
3
|
|
|
4
4
|
type Restorer = () => () => void;
|
|
5
5
|
type Hook = () => Restorer;
|
|
@@ -634,49 +634,11 @@ declare function chainPromise<T>(given: Promise<T> | T): PromiseChain<T>;
|
|
|
634
634
|
* attend(() => Object.keys(record), (key) => { ... })
|
|
635
635
|
* ```
|
|
636
636
|
*/
|
|
637
|
-
declare function attend<T>(source: readonly T[], callback: (index: number) => EffectCloser |
|
|
638
|
-
declare function attend<K, V>(source: Map<K, V>, callback: (key: K) => EffectCloser |
|
|
639
|
-
declare function attend<T>(source: Set<T>, callback: (value: T) => EffectCloser |
|
|
640
|
-
declare function attend<S extends
|
|
641
|
-
declare function attend<Key>(enumerate: () => Iterable<Key>, callback: (key: Key) => EffectCloser |
|
|
642
|
-
/**
|
|
643
|
-
* Result of a reactive scan, which is a reactive array of accumulated values
|
|
644
|
-
* with an attached cleanup function.
|
|
645
|
-
*/
|
|
646
|
-
type ScanResult<Output> = readonly Output[] & {
|
|
647
|
-
[cleanup]: ScopedCallback;
|
|
648
|
-
};
|
|
649
|
-
/**
|
|
650
|
-
* Perform a reactive scan over an array of items.
|
|
651
|
-
*
|
|
652
|
-
* This implementation is highly optimized for performance and fine-grained reactivity:
|
|
653
|
-
* - **Incremental Updates**: Changes to an item only trigger re-computation from that
|
|
654
|
-
* point onwards in the result chain.
|
|
655
|
-
* - **Move Optimization**: If items are moved within the array, their accumulated
|
|
656
|
-
* values are reused as long as their predecessor remains the same.
|
|
657
|
-
* - **Duplicate Support**: Correctly handles multiple occurrences of the same object
|
|
658
|
-
* instance using an internal occurrence tracking mechanism.
|
|
659
|
-
* - **Memory Efficient**: Uses `WeakMap` for caching intermediates, which are
|
|
660
|
-
* automatically cleared when source items are garbage collected.
|
|
661
|
-
*
|
|
662
|
-
* @example
|
|
663
|
-
* ```typescript
|
|
664
|
-
* const source = reactive([{ val: 1 }, { val: 2 }, { val: 3 }])
|
|
665
|
-
* const sum = scan(source, (acc, item) => acc + item.val, 0)
|
|
666
|
-
*
|
|
667
|
-
* expect([...sum]).toEqual([1, 3, 6])
|
|
668
|
-
*
|
|
669
|
-
* // Modifying an item only re-computes subsequent sums
|
|
670
|
-
* source[1].val = 10
|
|
671
|
-
* expect([...sum]).toEqual([1, 11, 14])
|
|
672
|
-
* ```
|
|
673
|
-
*
|
|
674
|
-
* @param source The source array of objects (will be made reactive)
|
|
675
|
-
* @param callback The accumulator function called with (accumulator, currentItem)
|
|
676
|
-
* @param initialValue The starting value for the accumulation
|
|
677
|
-
* @returns A reactive array of accumulated values, with a [cleanup] property to stop the tracking
|
|
678
|
-
*/
|
|
679
|
-
declare function scan<Input extends object, Output>(source: readonly Input[], callback: (acc: Output, val: Input) => Output, initialValue: Output): ScanResult<Output>;
|
|
637
|
+
declare function attend<T>(source: readonly T[], callback: (index: number, access: EffectAccess) => EffectCloser | void): ScopedCallback;
|
|
638
|
+
declare function attend<K, V>(source: Map<K, V>, callback: (key: K, access: EffectAccess) => EffectCloser | void): ScopedCallback;
|
|
639
|
+
declare function attend<T>(source: Set<T>, callback: (value: T, access: EffectAccess) => EffectCloser | void): ScopedCallback;
|
|
640
|
+
declare function attend<S extends object>(source: S, callback: (key: keyof S & string, access: EffectAccess) => EffectCloser | void): ScopedCallback;
|
|
641
|
+
declare function attend<Key>(enumerate: () => Iterable<Key>, callback: (key: Key, access: EffectAccess) => EffectCloser | void): ScopedCallback;
|
|
680
642
|
/**
|
|
681
643
|
* Lifts a callback that returns an array into a reactive array that automatically
|
|
682
644
|
* synchronizes with the source array returned by the callback.
|
|
@@ -698,9 +660,7 @@ declare function scan<Input extends object, Output>(source: readonly Input[], ca
|
|
|
698
660
|
* @param cb Callback function that returns an array
|
|
699
661
|
* @returns A reactive array synchronized with the callback's result, with a [cleanup] property to stop tracking
|
|
700
662
|
*/
|
|
701
|
-
declare function lift<Output extends any[]>(cb: (access: EffectAccess) => Output): Output
|
|
702
|
-
[cleanup]: ScopedCallback;
|
|
703
|
-
};
|
|
663
|
+
declare function lift<Output extends any[]>(cb: (access: EffectAccess) => Output): Output;
|
|
704
664
|
/**
|
|
705
665
|
* Lifts a callback that returns an object into a reactive object that automatically
|
|
706
666
|
* synchronizes with the source object returned by the callback.
|
|
@@ -729,9 +689,7 @@ declare function lift<Output extends any[]>(cb: (access: EffectAccess) => Output
|
|
|
729
689
|
* @param cb Callback function that returns an object
|
|
730
690
|
* @returns A reactive object synchronized with the callback's result, with a [cleanup] property to stop tracking
|
|
731
691
|
*/
|
|
732
|
-
declare function lift<Output extends object>(cb: (access: EffectAccess) => Output): Output
|
|
733
|
-
[cleanup]: ScopedCallback;
|
|
734
|
-
};
|
|
692
|
+
declare function lift<Output extends object>(cb: (access: EffectAccess) => Output): Output;
|
|
735
693
|
/**
|
|
736
694
|
* Options for `morph` and its variants.
|
|
737
695
|
*
|
|
@@ -751,16 +709,10 @@ type MorphOptions<I> = {
|
|
|
751
709
|
* @see morphRecord
|
|
752
710
|
*/
|
|
753
711
|
type Morph = {
|
|
754
|
-
<I, O>(source: readonly I[] | (() => readonly I[]), fn: (arg: I) => O, options?: MorphOptions<I>): readonly O[]
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
<K, V, O>(source: Map<K, V>, fn: (arg: V) => O, options?: MorphOptions<V>): Map<K, O> & {
|
|
758
|
-
[cleanup]: ScopedCallback;
|
|
759
|
-
};
|
|
760
|
-
<S extends Record<PropertyKey, any>, O>(source: S, fn: (arg: S[keyof S]) => O, options?: MorphOptions<S[keyof S]>): {
|
|
712
|
+
<I, O>(source: readonly I[] | (() => readonly I[]), fn: (arg: I, access?: EffectAccess) => O, options?: MorphOptions<I>): readonly O[];
|
|
713
|
+
<K, V, O>(source: Map<K, V>, fn: (arg: V, key: K, access?: EffectAccess) => O, options?: MorphOptions<V>): Map<K, O>;
|
|
714
|
+
<S extends Record<PropertyKey, any>, O>(source: S, fn: (arg: S[keyof S], key: keyof S, access?: EffectAccess) => O, options?: MorphOptions<S[keyof S]>): {
|
|
761
715
|
[K in keyof S]: O;
|
|
762
|
-
} & {
|
|
763
|
-
[cleanup]: ScopedCallback;
|
|
764
716
|
};
|
|
765
717
|
pure: Morph;
|
|
766
718
|
};
|
|
@@ -829,19 +781,38 @@ declare function deepWatch<T extends object>(target: T, callback: (value: T) =>
|
|
|
829
781
|
declare const effectAggregator: ZoneAggregator;
|
|
830
782
|
declare function getActiveEffect(): ScopedCallback;
|
|
831
783
|
/**
|
|
832
|
-
*
|
|
833
|
-
*
|
|
784
|
+
* Attach cleanup dependencies to an object. When `unlink(obj)` is called,
|
|
785
|
+
* each dependency is disposed: functions are invoked with the cleanup reason,
|
|
786
|
+
* objects are recursively `unlink`ed. This forms a cleanup tree.
|
|
787
|
+
*
|
|
788
|
+
* @param obj - The owner object
|
|
789
|
+
* @param cleanupFns - Cleanup callbacks and/or child objects to unlink recursively
|
|
790
|
+
* @returns The owner object (for chaining)
|
|
791
|
+
*
|
|
792
|
+
* @example
|
|
793
|
+
* ```ts
|
|
794
|
+
* // Functions are called with CleanupReason
|
|
795
|
+
* link(parent, () => console.log('disposed'))
|
|
834
796
|
*
|
|
835
|
-
*
|
|
836
|
-
*
|
|
797
|
+
* // Objects are recursively unlinked
|
|
798
|
+
* link(parent, childA, childB)
|
|
837
799
|
*
|
|
838
|
-
*
|
|
839
|
-
*
|
|
840
|
-
*
|
|
800
|
+
* // Mixed
|
|
801
|
+
* link(parent, childObj, () => timer.clear())
|
|
802
|
+
*
|
|
803
|
+
* unlink(parent) // disposes childA, childB, calls the function
|
|
804
|
+
* ```
|
|
841
805
|
*/
|
|
842
|
-
declare function
|
|
843
|
-
|
|
844
|
-
|
|
806
|
+
declare function link<T extends object>(obj: T, ...cleanupFns: (ScopedCallback | object | undefined)[]): T;
|
|
807
|
+
/**
|
|
808
|
+
* Dispose an object's cleanup dependencies. Functions are called with the
|
|
809
|
+
* reason; linked objects are recursively unlinked. The cleanup set is removed
|
|
810
|
+
* so calling `unlink` twice is safe (second call is a no-op).
|
|
811
|
+
*
|
|
812
|
+
* @param obj - The object to dispose
|
|
813
|
+
* @param reason - Optional cleanup reason propagated to callbacks
|
|
814
|
+
*/
|
|
815
|
+
declare function unlink(obj: object, reason?: CleanupReason): void;
|
|
845
816
|
|
|
846
817
|
interface ActivationRecord {
|
|
847
818
|
effect: EffectTrigger;
|
|
@@ -898,6 +869,17 @@ declare function reset(): void;
|
|
|
898
869
|
* Decorator that makes methods atomic - batches all effects triggered within the method
|
|
899
870
|
*/
|
|
900
871
|
declare const atomic: LegacyPropertyDecorator<any> & ModernMethodDecorator<any> & (<Args extends any[], Return>(original: (...args: Args) => Return) => (...args: Args) => Return);
|
|
872
|
+
/**
|
|
873
|
+
* Wraps `fn` so it runs within `effect`'s zone context when invoked later.
|
|
874
|
+
*
|
|
875
|
+
* Useful for deferred callbacks (event listeners, `DOMContentLoaded`, etc.)
|
|
876
|
+
* that need sub-effects parented to the original effect.
|
|
877
|
+
*
|
|
878
|
+
* @param prev - The effect whose context should be restored, or `undefined` for root context
|
|
879
|
+
* @param fn - The function to wrap
|
|
880
|
+
* @returns A function with the same signature that restores the effect context before calling `fn`
|
|
881
|
+
*/
|
|
882
|
+
declare function captured<Args extends any[], Return>(prev: HistoryValue<EffectTrigger> | undefined, fn: (...args: Args) => Return): (...args: Args) => Return;
|
|
901
883
|
/**
|
|
902
884
|
* Runs `fn` atomically and **always immediately**, batching all reactive effects
|
|
903
885
|
* triggered inside it so they fire only once after `fn` completes.
|
|
@@ -921,16 +903,23 @@ declare function atom<T>(fn: () => T): any;
|
|
|
921
903
|
* @param fn - The effect function to run - provides the cleaner
|
|
922
904
|
* @returns The cleanup function
|
|
923
905
|
*/
|
|
906
|
+
/**
|
|
907
|
+
* Reactive effect function with chainable flavor modifiers.
|
|
908
|
+
*/
|
|
909
|
+
interface Effect {
|
|
910
|
+
(fn: (access: EffectAccess) => EffectCloser | undefined | void | Promise<any>, effectOptions?: EffectOptions): EffectCleanup;
|
|
911
|
+
/** Opaque flavor: bypasses deep-touch optimizations */
|
|
912
|
+
readonly opaque: Effect;
|
|
913
|
+
/** Named flavor: assigns a debug name */
|
|
914
|
+
named(name: string): Effect;
|
|
915
|
+
}
|
|
924
916
|
/**
|
|
925
917
|
* Creates a reactive effect that automatically re-runs when dependencies change
|
|
926
918
|
* @param fn - The effect function that provides dependencies and may return a cleanup function or Promise
|
|
927
919
|
* @param options - Options for effect execution
|
|
928
920
|
* @returns A cleanup function to stop the effect
|
|
929
921
|
*/
|
|
930
|
-
declare const effect:
|
|
931
|
-
readonly opaque: any;
|
|
932
|
-
named(name: string): any;
|
|
933
|
-
};
|
|
922
|
+
declare const effect: Effect;
|
|
934
923
|
/**
|
|
935
924
|
* Executes a function without tracking dependencies but maintains parent cleanup relationship
|
|
936
925
|
* Effects created inside will still be cleaned up when the parent effect is destroyed
|
|
@@ -1014,7 +1003,12 @@ declare const memoize: ReturnType<typeof makeMemoizeDecorator> & {
|
|
|
1014
1003
|
readonly lenient: ReturnType<typeof makeMemoizeDecorator>;
|
|
1015
1004
|
};
|
|
1016
1005
|
|
|
1017
|
-
|
|
1006
|
+
/**
|
|
1007
|
+
* Add unreactive properties to a prototype.
|
|
1008
|
+
* If no set is provided, marks the entire object/prototype as non-reactive (sets [unreactiveProperties] = true).
|
|
1009
|
+
* If a set is provided, merges with existing unreactive properties (never overrides true).
|
|
1010
|
+
*/
|
|
1011
|
+
declare function addUnreactiveProps<T extends object>(proto: T, set?: Iterable<PropertyKey>): T;
|
|
1018
1012
|
declare function isNonReactive(obj: any): boolean;
|
|
1019
1013
|
|
|
1020
1014
|
type SubProxy = {
|
|
@@ -1081,13 +1075,7 @@ target: Target) => EffectCloser | undefined;
|
|
|
1081
1075
|
* The result type of the organized function, combining the target object with cleanup capability.
|
|
1082
1076
|
* @template Target - The type of the target object
|
|
1083
1077
|
*/
|
|
1084
|
-
type OrganizedResult<Target extends object> = Target
|
|
1085
|
-
/**
|
|
1086
|
-
* Cleanup function to dispose of all reactive bindings created by organized().
|
|
1087
|
-
* This is automatically called when the effect that created the organized binding is disposed.
|
|
1088
|
-
*/
|
|
1089
|
-
[cleanup]: ScopedCallback;
|
|
1090
|
-
};
|
|
1078
|
+
type OrganizedResult<Target extends object> = Target;
|
|
1091
1079
|
/**
|
|
1092
1080
|
* Organizes a source object's properties into a target object using a callback function.
|
|
1093
1081
|
* This creates a reactive mapping between source properties and a target object,
|
|
@@ -1153,129 +1141,6 @@ declare function organize<T>(target: object, property: PropertyKey, access: {
|
|
|
1153
1141
|
set?(value: T): boolean;
|
|
1154
1142
|
}): () => boolean;
|
|
1155
1143
|
|
|
1156
|
-
type KeyFunction<T, K extends PropertyKey> = (item: T) => K;
|
|
1157
|
-
/**
|
|
1158
|
-
* Events emitted by the Register for CRUD operations
|
|
1159
|
-
*/
|
|
1160
|
-
interface RegisterEvents<T, K extends PropertyKey> {
|
|
1161
|
-
/**
|
|
1162
|
-
* Emitted when a new item is added to the register
|
|
1163
|
-
*/
|
|
1164
|
-
add: (item: T, key: K, index: number) => void;
|
|
1165
|
-
/**
|
|
1166
|
-
* Emitted when an item is removed from the register
|
|
1167
|
-
*/
|
|
1168
|
-
delete: (item: T, key: K, index: number) => void;
|
|
1169
|
-
/**
|
|
1170
|
-
* Emitted when an item's value is updated (same key, new value)
|
|
1171
|
-
*/
|
|
1172
|
-
update: (oldItem: T, newItem: T, key: K, index: number) => void;
|
|
1173
|
-
/**
|
|
1174
|
-
* Emitted when an item's key changes (rekey operation)
|
|
1175
|
-
*/
|
|
1176
|
-
rekey: (item: T, oldKey: K, newKey: K, index: number) => void;
|
|
1177
|
-
/**
|
|
1178
|
-
* Index signature for EventsBase compatibility
|
|
1179
|
-
*/
|
|
1180
|
-
[key: string]: (...args: any[]) => void;
|
|
1181
|
-
}
|
|
1182
|
-
interface RegisterInstance<T> extends ArrayReadForward<T> {
|
|
1183
|
-
[index: number]: T;
|
|
1184
|
-
}
|
|
1185
|
-
declare const RegisterClass_base: new () => ArrayReadForward<any> & {
|
|
1186
|
-
[x: number]: any;
|
|
1187
|
-
toArray(): any[];
|
|
1188
|
-
};
|
|
1189
|
-
declare class RegisterClass<T, K extends PropertyKey = PropertyKey> extends RegisterClass_base implements RegisterInstance<T> {
|
|
1190
|
-
#private;
|
|
1191
|
-
protected get [forwardArray](): readonly T[];
|
|
1192
|
-
/**
|
|
1193
|
-
* Register event listeners for CRUD operations
|
|
1194
|
-
*/
|
|
1195
|
-
on(events: Partial<RegisterEvents<T, K>>): void;
|
|
1196
|
-
on<EventType extends keyof RegisterEvents<T, K>>(event: EventType, cb: RegisterEvents<T, K>[EventType]): () => void;
|
|
1197
|
-
/**
|
|
1198
|
-
* Remove event listeners
|
|
1199
|
-
*/
|
|
1200
|
-
off(events: Partial<RegisterEvents<T, K>>): void;
|
|
1201
|
-
off<EventType extends keyof RegisterEvents<T, K>>(event: EventType, cb?: RegisterEvents<T, K>[EventType]): void;
|
|
1202
|
-
/**
|
|
1203
|
-
* Register a global hook that receives all events
|
|
1204
|
-
*/
|
|
1205
|
-
hook(cb: <EventType extends keyof RegisterEvents<T, K>>(event: EventType, ...args: Parameters<RegisterEvents<T, K>[EventType]>) => void): () => void;
|
|
1206
|
-
constructor(keyFn: KeyFunction<T, K>, initial?: Iterable<T>);
|
|
1207
|
-
private ensureKey;
|
|
1208
|
-
private assertValidKey;
|
|
1209
|
-
private setKeyValue;
|
|
1210
|
-
private cleanupValue;
|
|
1211
|
-
private disposeKeyEffects;
|
|
1212
|
-
private incrementUsage;
|
|
1213
|
-
private decrementUsage;
|
|
1214
|
-
private normalizeIndex;
|
|
1215
|
-
private assignAt;
|
|
1216
|
-
private insertKeyValue;
|
|
1217
|
-
private rebuildFrom;
|
|
1218
|
-
get length(): number;
|
|
1219
|
-
[getAt](index: number): T | undefined;
|
|
1220
|
-
[setAt](index: number, value: T): void;
|
|
1221
|
-
push(...items: T[]): number;
|
|
1222
|
-
pop(): T | undefined;
|
|
1223
|
-
shift(): T | undefined;
|
|
1224
|
-
unshift(...items: T[]): number;
|
|
1225
|
-
splice(start: number, deleteCount?: number, ...items: T[]): T[];
|
|
1226
|
-
clear(): void;
|
|
1227
|
-
get(key: K): T | undefined;
|
|
1228
|
-
set(key: K, value: T): void;
|
|
1229
|
-
remove(key: K): void;
|
|
1230
|
-
removeAt(index: number): T | undefined;
|
|
1231
|
-
/**
|
|
1232
|
-
* Keep only the items for which the predicate returns true.
|
|
1233
|
-
* Items for which the predicate returns false are removed.
|
|
1234
|
-
*
|
|
1235
|
-
* The predicate is evaluated once per distinct key; duplicate keys
|
|
1236
|
-
* will follow the same keep/remove decision.
|
|
1237
|
-
*/
|
|
1238
|
-
keep(predicate: (value: T) => boolean): void;
|
|
1239
|
-
hasKey(key: K): boolean;
|
|
1240
|
-
indexOfKey(key: K): number;
|
|
1241
|
-
mapKeys(): IterableIterator<K>;
|
|
1242
|
-
update(...values: T[]): void;
|
|
1243
|
-
upsert(insert: (value: T) => void, ...values: T[]): void;
|
|
1244
|
-
entries(): IterableIterator<[number, T]>;
|
|
1245
|
-
[Symbol.iterator](): IterableIterator<T>;
|
|
1246
|
-
toString(): string;
|
|
1247
|
-
at(index: number): T | undefined;
|
|
1248
|
-
reverse(): this;
|
|
1249
|
-
sort(compareFn?: ((a: T, b: T) => number) | undefined): this;
|
|
1250
|
-
fill(value: T, start?: number, end?: number): this;
|
|
1251
|
-
copyWithin(target: number, start: number, end?: number): this;
|
|
1252
|
-
}
|
|
1253
|
-
type Register<T, K extends PropertyKey = PropertyKey> = RegisterClass<T, K> & T[];
|
|
1254
|
-
declare const Register: new <T, K extends PropertyKey = PropertyKey>(keyFn: KeyFunction<T, K>, initial?: Iterable<T>) => Register<T, K>;
|
|
1255
|
-
/**
|
|
1256
|
-
* Creates a reactive Register - an ordered, array-like collection with stable key-based identity.
|
|
1257
|
-
*
|
|
1258
|
-
* Register combines array semantics (indexable access, ordering, iteration) with Map-like
|
|
1259
|
-
* key-based lookups. Items with the same key share the same value instance, making it ideal
|
|
1260
|
-
* for UI lists keyed by IDs or when you need to preserve identity across reorders.
|
|
1261
|
-
*
|
|
1262
|
-
* @param keyFn - Function that extracts the key from each item
|
|
1263
|
-
* @param initial - Optional initial items to populate the register
|
|
1264
|
-
* @returns A reactive Register instance
|
|
1265
|
-
*
|
|
1266
|
-
* @example
|
|
1267
|
-
* ```typescript
|
|
1268
|
-
* const users = register(
|
|
1269
|
-
* (user: User) => user.id,
|
|
1270
|
-
* [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }]
|
|
1271
|
-
* )
|
|
1272
|
-
*
|
|
1273
|
-
* users.push({ id: 3, name: 'Charlie' })
|
|
1274
|
-
* const bob = users.get(2) // Get by key
|
|
1275
|
-
* ```
|
|
1276
|
-
*/
|
|
1277
|
-
declare function register<T, K extends PropertyKey = PropertyKey>(keyFn: KeyFunction<T, K>, initial?: Iterable<T>): Register<T, K>;
|
|
1278
|
-
|
|
1279
1144
|
/**
|
|
1280
1145
|
* Options for the watch function
|
|
1281
1146
|
*/
|
|
@@ -1328,7 +1193,8 @@ interface Resource<T> {
|
|
|
1328
1193
|
loading: boolean;
|
|
1329
1194
|
error: any;
|
|
1330
1195
|
latest: T | undefined;
|
|
1331
|
-
reload
|
|
1196
|
+
reload(): void;
|
|
1197
|
+
promise: Promise<void>;
|
|
1332
1198
|
}
|
|
1333
1199
|
/**
|
|
1334
1200
|
* Creates a reactive resource that automatically tracks async state.
|
|
@@ -1336,10 +1202,16 @@ interface Resource<T> {
|
|
|
1336
1202
|
* @param options - Resource options (initialValue)
|
|
1337
1203
|
* @returns Reactive Resource object with value, loading, error, latest properties
|
|
1338
1204
|
*/
|
|
1339
|
-
declare function resource<T>(fetcher: (
|
|
1205
|
+
declare function resource<T>(fetcher: (access: EffectAccess) => Promise<T> | T, options?: {
|
|
1340
1206
|
initialValue?: T;
|
|
1341
1207
|
}): Resource<T>;
|
|
1342
1208
|
|
|
1209
|
+
/**
|
|
1210
|
+
* Executes a function and throws if any reactive dependencies are tracked during execution.
|
|
1211
|
+
* Used to assert that code runs in an untracked context.
|
|
1212
|
+
*/
|
|
1213
|
+
declare function assertUntracked<T>(fn: () => T): T;
|
|
1214
|
+
|
|
1343
1215
|
/**
|
|
1344
1216
|
* Object containing internal reactive system state for debugging and profiling
|
|
1345
1217
|
*/
|
|
@@ -1442,6 +1314,9 @@ declare function tag<T extends object>(name: string, obj: T): T;
|
|
|
1442
1314
|
* @returns The function with the new name
|
|
1443
1315
|
*/
|
|
1444
1316
|
declare function named<T extends Function>(name: string, fn: T): T;
|
|
1317
|
+
declare const isDev: boolean;
|
|
1318
|
+
declare const isProd: boolean;
|
|
1319
|
+
declare const isTest: boolean;
|
|
1445
1320
|
|
|
1446
|
-
export { ArrayReadForward, DecoratorError, Destroyable, DestructionError, EffectAccess, EffectCleanup, EffectCloser, EffectOptions, EffectTrigger, Eventful, Evolution, Indexable, IterableWeakMap, IterableWeakSet, ReactiveBase,
|
|
1447
|
-
export type { ArrayDiffResult, ContextManager, Decorator, DecoratorDescription, DecoratorFactory, EventsBase, GenericClassDecorator, Hook, LegacyClassDecorator, LegacyPropertyDecorator, Memoizable, MemoizableArgument, MixinClass, MixinFunction, ModernAccessorDecorator, ModernClassDecorator, ModernGetterDecorator, ModernMethodDecorator, ModernSetterDecorator, PromiseChain, Resource, Restorer
|
|
1321
|
+
export { ArrayReadForward, CleanupReason, DecoratorError, Destroyable, DestructionError, EffectAccess, EffectCleanup, EffectCloser, EffectOptions, EffectTrigger, Eventful, Evolution, HistoryValue, Indexable, IterableWeakMap, IterableWeakSet, ReactiveBase, ScopedCallback, ZoneAggregator, addBatchCleanup, addUnreactiveProps, allocated, allocatedValues, arrayDiff, arrayEquals, assertUntracked, asyncHook, asyncHooks, atom, atomic, attend, biDi, cache, cached, callOnGC, captured, caught, chainPromise, createFlavor, debounce, decorator, deepCompare, deepWatch, defer, deprecated, descriptor, destructor, effect, effectAggregator, flavorOptions, flavored, forwardArray, getActivationLog, getActiveEffect, getAt, getState, hooks$1 as hooks, isCached, isConstructor, isDev, isNonReactive, isObject, isProd, isTest, legacyDecorator, lift, link, memoize, mixin, modernDecorator, morph, named, onEffectThrow, organize, organized, profileInfo, morph as project, reactive, reset, resource, root, setAt, tag, throttle, touched, touched1, unlink, unreactive, untracked, watch, when, zip };
|
|
1322
|
+
export type { ArrayDiffResult, ContextManager, Decorator, DecoratorDescription, DecoratorFactory, EventsBase, GenericClassDecorator, Hook, LegacyClassDecorator, LegacyPropertyDecorator, Memoizable, MemoizableArgument, MixinClass, MixinFunction, ModernAccessorDecorator, ModernClassDecorator, ModernGetterDecorator, ModernMethodDecorator, ModernSetterDecorator, PromiseChain, Resource, Restorer };
|