@signaltree/core 6.2.1 → 6.2.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.
- package/dist/constants.js +6 -0
- package/dist/deep-equal.js +41 -0
- package/dist/enhancers/batching/batching.js +230 -0
- package/dist/enhancers/devtools/devtools.js +318 -0
- package/dist/enhancers/effects/effects.js +66 -0
- package/dist/enhancers/entities/entities.js +51 -0
- package/dist/enhancers/index.js +72 -0
- package/dist/enhancers/memoization/memoization.js +420 -0
- package/dist/enhancers/presets/lib/presets.js +27 -0
- package/dist/enhancers/serialization/constants.js +15 -0
- package/dist/enhancers/serialization/serialization.js +656 -0
- package/dist/enhancers/time-travel/time-travel.js +247 -0
- package/dist/enhancers/time-travel/utils.js +11 -0
- package/dist/enhancers/utils/copy-tree-properties.js +20 -0
- package/dist/index.js +20 -0
- package/dist/is-built-in-object.js +23 -0
- package/dist/lib/async-helpers.js +77 -0
- package/dist/lib/constants.js +56 -0
- package/dist/lib/edit-session.js +84 -0
- package/dist/lib/entity-signal.js +558 -0
- package/dist/lib/memory/memory-manager.js +164 -0
- package/dist/lib/path-notifier.js +106 -0
- package/dist/lib/presets.js +21 -0
- package/dist/lib/security/security-validator.js +121 -0
- package/dist/lib/signal-tree.js +278 -0
- package/dist/lib/types.js +9 -0
- package/dist/lib/utils.js +264 -0
- package/dist/lru-cache.js +64 -0
- package/dist/parse-path.js +13 -0
- package/package.json +2 -2
- package/src/enhancers/batching/batching.d.ts +10 -0
- package/src/enhancers/batching/batching.types.d.ts +1 -0
- package/src/enhancers/batching/index.d.ts +1 -0
- package/src/enhancers/batching/test-setup.d.ts +3 -0
- package/src/enhancers/devtools/devtools.d.ts +68 -0
- package/src/enhancers/devtools/devtools.types.d.ts +1 -0
- package/src/enhancers/devtools/index.d.ts +1 -0
- package/src/enhancers/devtools/test-setup.d.ts +3 -0
- package/src/enhancers/effects/effects.d.ts +9 -0
- package/src/enhancers/effects/effects.types.d.ts +1 -0
- package/src/enhancers/effects/index.d.ts +1 -0
- package/src/enhancers/entities/entities.d.ts +11 -0
- package/src/enhancers/entities/entities.types.d.ts +1 -0
- package/src/enhancers/entities/index.d.ts +1 -0
- package/src/enhancers/entities/test-setup.d.ts +3 -0
- package/src/enhancers/index.d.ts +3 -0
- package/src/enhancers/memoization/index.d.ts +1 -0
- package/src/enhancers/memoization/memoization.d.ts +54 -0
- package/src/enhancers/memoization/memoization.types.d.ts +1 -0
- package/src/enhancers/memoization/test-setup.d.ts +3 -0
- package/src/enhancers/presets/index.d.ts +1 -0
- package/src/enhancers/presets/lib/presets.d.ts +8 -0
- package/src/enhancers/serialization/constants.d.ts +14 -0
- package/src/enhancers/serialization/index.d.ts +2 -0
- package/src/enhancers/serialization/serialization.d.ts +68 -0
- package/src/enhancers/serialization/test-setup.d.ts +3 -0
- package/src/enhancers/test-helpers/types-equals.d.ts +2 -0
- package/src/enhancers/time-travel/index.d.ts +1 -0
- package/src/enhancers/time-travel/test-setup.d.ts +3 -0
- package/src/enhancers/time-travel/time-travel.d.ts +10 -0
- package/src/enhancers/time-travel/time-travel.types.d.ts +1 -0
- package/src/enhancers/time-travel/utils.d.ts +2 -0
- package/src/enhancers/types.d.ts +1 -0
- package/src/enhancers/typing/helpers-types.d.ts +2 -0
- package/src/enhancers/utils/copy-tree-properties.d.ts +1 -0
- package/src/index.d.ts +19 -0
- package/src/lib/async-helpers.d.ts +8 -0
- package/src/lib/constants.d.ts +41 -0
- package/src/lib/dev-proxy.d.ts +3 -0
- package/src/lib/edit-session.d.ts +21 -0
- package/src/lib/entity-signal.d.ts +1 -0
- package/src/lib/memory/memory-manager.d.ts +30 -0
- package/src/lib/path-notifier.d.ts +4 -0
- package/src/lib/performance/diff-engine.d.ts +33 -0
- package/src/lib/performance/path-index.d.ts +25 -0
- package/src/lib/performance/update-engine.d.ts +32 -0
- package/src/lib/presets.d.ts +34 -0
- package/src/lib/security/security-validator.d.ts +33 -0
- package/src/lib/signal-tree.d.ts +3 -0
- package/src/lib/types.d.ts +301 -0
- package/src/lib/utils.d.ts +32 -0
- package/LICENSE +0 -54
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import { Signal, WritableSignal } from '@angular/core';
|
|
2
|
+
import { SecurityValidatorConfig } from './security/security-validator';
|
|
3
|
+
export interface TimeTravelConfig {
|
|
4
|
+
enabled?: boolean;
|
|
5
|
+
maxHistorySize?: number;
|
|
6
|
+
includePayload?: boolean;
|
|
7
|
+
actionNames?: {
|
|
8
|
+
update?: string;
|
|
9
|
+
set?: string;
|
|
10
|
+
batch?: string;
|
|
11
|
+
[key: string]: string | undefined;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export interface MemoizationConfig {
|
|
15
|
+
enabled?: boolean;
|
|
16
|
+
maxCacheSize?: number;
|
|
17
|
+
ttl?: number;
|
|
18
|
+
enableLRU?: boolean;
|
|
19
|
+
equality?: 'deep' | 'shallow' | 'reference';
|
|
20
|
+
}
|
|
21
|
+
export type Primitive = string | number | boolean | null | undefined | bigint | symbol;
|
|
22
|
+
export type NotFn<T> = T extends (...args: unknown[]) => unknown ? never : T;
|
|
23
|
+
declare module '@angular/core' {
|
|
24
|
+
interface WritableSignal<T> {
|
|
25
|
+
(value: NotFn<T>): void;
|
|
26
|
+
(updater: (current: T) => T): void;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export interface NodeAccessor<T> {
|
|
30
|
+
(): T;
|
|
31
|
+
(value: T): void;
|
|
32
|
+
(updater: (current: T) => T): void;
|
|
33
|
+
}
|
|
34
|
+
export type TreeNode<T> = {
|
|
35
|
+
[K in keyof T]: T[K] extends EntityMapMarker<infer E, infer Key> ? EntitySignal<E, Key> : T[K] extends Primitive ? CallableWritableSignal<T[K]> : T[K] extends readonly unknown[] ? CallableWritableSignal<T[K]> : T[K] extends Date | RegExp | Map<any, any> | Set<any> | Error | ((...args: unknown[]) => unknown) ? CallableWritableSignal<T[K]> : T[K] extends object ? NodeAccessor<T[K]> & TreeNode<T[K]> : CallableWritableSignal<T[K]>;
|
|
36
|
+
};
|
|
37
|
+
export interface ISignalTree<T> extends NodeAccessor<T> {
|
|
38
|
+
readonly state: TreeNode<T>;
|
|
39
|
+
readonly $: TreeNode<T>;
|
|
40
|
+
with<TAdded>(enhancer: (tree: ISignalTree<T>) => ISignalTree<T> & TAdded): this & TAdded;
|
|
41
|
+
bind(thisArg?: unknown): NodeAccessor<T>;
|
|
42
|
+
destroy(): void;
|
|
43
|
+
}
|
|
44
|
+
export interface EffectsMethods<T> {
|
|
45
|
+
effect(fn: (state: T) => void | (() => void)): () => void;
|
|
46
|
+
subscribe(fn: (state: T) => void): () => void;
|
|
47
|
+
}
|
|
48
|
+
export interface BatchingConfig {
|
|
49
|
+
enabled?: boolean;
|
|
50
|
+
notificationDelayMs?: number;
|
|
51
|
+
}
|
|
52
|
+
export interface BatchingMethods<T = unknown> {
|
|
53
|
+
batch(fn: () => void): void;
|
|
54
|
+
coalesce(fn: () => void): void;
|
|
55
|
+
hasPendingNotifications(): boolean;
|
|
56
|
+
flushNotifications(): void;
|
|
57
|
+
}
|
|
58
|
+
export interface MemoizationMethods<T> {
|
|
59
|
+
memoize<R>(fn: (state: T) => R, cacheKey?: string): Signal<R>;
|
|
60
|
+
memoizedUpdate?: (updater: (current: T) => Partial<T>, cacheKey?: string) => void;
|
|
61
|
+
clearMemoCache(key?: string): void;
|
|
62
|
+
clearCache?: (key?: string) => void;
|
|
63
|
+
getCacheStats(): CacheStats;
|
|
64
|
+
}
|
|
65
|
+
export type CacheStats = {
|
|
66
|
+
size: number;
|
|
67
|
+
hitRate: number;
|
|
68
|
+
totalHits: number;
|
|
69
|
+
totalMisses: number;
|
|
70
|
+
keys: string[];
|
|
71
|
+
};
|
|
72
|
+
export interface TimeTravelMethods<T = unknown> {
|
|
73
|
+
undo(): void;
|
|
74
|
+
redo(): void;
|
|
75
|
+
canUndo(): boolean;
|
|
76
|
+
canRedo(): boolean;
|
|
77
|
+
getHistory(): TimeTravelEntry<T>[];
|
|
78
|
+
resetHistory(): void;
|
|
79
|
+
jumpTo(index: number): void;
|
|
80
|
+
getCurrentIndex(): number;
|
|
81
|
+
readonly __timeTravel?: {
|
|
82
|
+
undo(): void;
|
|
83
|
+
redo(): void;
|
|
84
|
+
canUndo(): boolean;
|
|
85
|
+
canRedo(): boolean;
|
|
86
|
+
getHistory(): TimeTravelEntry<T>[];
|
|
87
|
+
resetHistory(): void;
|
|
88
|
+
jumpTo(index: number): void;
|
|
89
|
+
getCurrentIndex(): number;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
export interface DevToolsMethods {
|
|
93
|
+
connectDevTools(): void;
|
|
94
|
+
disconnectDevTools(): void;
|
|
95
|
+
}
|
|
96
|
+
export interface EntitiesEnabled {
|
|
97
|
+
}
|
|
98
|
+
export interface OptimizedUpdateMethods<T> {
|
|
99
|
+
updateOptimized(updates: Partial<T>, options?: {
|
|
100
|
+
batch?: boolean;
|
|
101
|
+
batchSize?: number;
|
|
102
|
+
maxDepth?: number;
|
|
103
|
+
ignoreArrayOrder?: boolean;
|
|
104
|
+
equalityFn?: (a: unknown, b: unknown) => boolean;
|
|
105
|
+
}): {
|
|
106
|
+
changed: boolean;
|
|
107
|
+
duration: number;
|
|
108
|
+
changedPaths: string[];
|
|
109
|
+
stats?: {
|
|
110
|
+
totalPaths: number;
|
|
111
|
+
optimizedPaths: number;
|
|
112
|
+
batchedUpdates: number;
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
export interface TimeTravelEntry<T> {
|
|
117
|
+
action: string;
|
|
118
|
+
timestamp: number;
|
|
119
|
+
state: T;
|
|
120
|
+
payload?: unknown;
|
|
121
|
+
}
|
|
122
|
+
export type TreePreset = 'basic' | 'performance' | 'development' | 'production';
|
|
123
|
+
export interface TreeConfig {
|
|
124
|
+
batchUpdates?: boolean;
|
|
125
|
+
useMemoization?: boolean;
|
|
126
|
+
enableTimeTravel?: boolean;
|
|
127
|
+
useLazySignals?: boolean;
|
|
128
|
+
useShallowComparison?: boolean;
|
|
129
|
+
maxCacheSize?: number;
|
|
130
|
+
trackPerformance?: boolean;
|
|
131
|
+
treeName?: string;
|
|
132
|
+
enableDevTools?: boolean;
|
|
133
|
+
debugMode?: boolean;
|
|
134
|
+
useStructuralSharing?: boolean;
|
|
135
|
+
security?: SecurityValidatorConfig;
|
|
136
|
+
}
|
|
137
|
+
export interface EntityConfig<E, K extends string | number = string> {
|
|
138
|
+
selectId?: (entity: E) => K;
|
|
139
|
+
hooks?: {
|
|
140
|
+
beforeAdd?: (entity: E) => E | false;
|
|
141
|
+
beforeUpdate?: (id: K, changes: Partial<E>) => Partial<E> | false;
|
|
142
|
+
beforeRemove?: (id: K, entity: E) => boolean;
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
declare const ENTITY_MAP_BRAND: unique symbol;
|
|
146
|
+
export interface EntityMapMarker<E, K extends string | number> {
|
|
147
|
+
readonly [ENTITY_MAP_BRAND]: {
|
|
148
|
+
__entity: E;
|
|
149
|
+
__key: K;
|
|
150
|
+
};
|
|
151
|
+
readonly __isEntityMap: true;
|
|
152
|
+
readonly __entityMapConfig?: EntityConfig<E, K>;
|
|
153
|
+
}
|
|
154
|
+
export declare function entityMap<E, K extends string | number = E extends {
|
|
155
|
+
id: infer I extends string | number;
|
|
156
|
+
} ? I : string>(config?: EntityConfig<E, K>): EntityMapMarker<E, K>;
|
|
157
|
+
export interface MutationOptions {
|
|
158
|
+
onError?: (error: Error) => void;
|
|
159
|
+
}
|
|
160
|
+
export interface AddOptions<E, K> extends MutationOptions {
|
|
161
|
+
selectId?: (entity: E) => K;
|
|
162
|
+
}
|
|
163
|
+
export interface AddManyOptions<E, K> extends AddOptions<E, K> {
|
|
164
|
+
mode?: 'strict' | 'skip' | 'overwrite';
|
|
165
|
+
}
|
|
166
|
+
export interface TapHandlers<E, K extends string | number> {
|
|
167
|
+
onAdd?: (entity: E, id: K) => void;
|
|
168
|
+
onUpdate?: (id: K, changes: Partial<E>, entity: E) => void;
|
|
169
|
+
onRemove?: (id: K, entity: E) => void;
|
|
170
|
+
onChange?: () => void;
|
|
171
|
+
}
|
|
172
|
+
export interface InterceptContext<T> {
|
|
173
|
+
block(reason?: string): void;
|
|
174
|
+
transform(value: T): void;
|
|
175
|
+
readonly blocked: boolean;
|
|
176
|
+
readonly blockReason: string | undefined;
|
|
177
|
+
}
|
|
178
|
+
export interface InterceptHandlers<E, K extends string | number> {
|
|
179
|
+
onAdd?: (entity: E, ctx: InterceptContext<E>) => void | Promise<void>;
|
|
180
|
+
onUpdate?: (id: K, changes: Partial<E>, ctx: InterceptContext<Partial<E>>) => void | Promise<void>;
|
|
181
|
+
onRemove?: (id: K, entity: E, ctx: InterceptContext<void>) => void | Promise<void>;
|
|
182
|
+
}
|
|
183
|
+
export type EntityNode<E> = {
|
|
184
|
+
(): E;
|
|
185
|
+
(value: E): void;
|
|
186
|
+
(updater: (current: E) => E): void;
|
|
187
|
+
} & {
|
|
188
|
+
[P in keyof E]: E[P] extends object ? E[P] extends readonly unknown[] ? CallableWritableSignal<E[P]> : EntityNode<E[P]> : CallableWritableSignal<E[P]>;
|
|
189
|
+
};
|
|
190
|
+
export interface EntitySignal<E, K extends string | number = string> {
|
|
191
|
+
byId(id: K): EntityNode<E> | undefined;
|
|
192
|
+
byIdOrFail(id: K): EntityNode<E>;
|
|
193
|
+
readonly all: Signal<E[]>;
|
|
194
|
+
readonly count: Signal<number>;
|
|
195
|
+
readonly ids: Signal<K[]>;
|
|
196
|
+
has(id: K): Signal<boolean>;
|
|
197
|
+
readonly isEmpty: Signal<boolean>;
|
|
198
|
+
readonly map: Signal<ReadonlyMap<K, E>>;
|
|
199
|
+
where(predicate: (entity: E) => boolean): Signal<E[]>;
|
|
200
|
+
find(predicate: (entity: E) => boolean): Signal<E | undefined>;
|
|
201
|
+
addOne(entity: E, opts?: AddOptions<E, K>): K;
|
|
202
|
+
addMany(entities: E[], opts?: AddManyOptions<E, K>): K[];
|
|
203
|
+
updateOne(id: K, changes: Partial<E>, opts?: MutationOptions): void;
|
|
204
|
+
updateMany(ids: K[], changes: Partial<E>, opts?: MutationOptions): void;
|
|
205
|
+
updateWhere(predicate: (entity: E) => boolean, changes: Partial<E>): number;
|
|
206
|
+
upsertOne(entity: E, opts?: AddOptions<E, K>): K;
|
|
207
|
+
upsertMany(entities: E[], opts?: AddOptions<E, K>): K[];
|
|
208
|
+
removeOne(id: K, opts?: MutationOptions): void;
|
|
209
|
+
removeMany(ids: K[], opts?: MutationOptions): void;
|
|
210
|
+
removeWhere(predicate: (entity: E) => boolean): number;
|
|
211
|
+
clear(): void;
|
|
212
|
+
removeAll(): void;
|
|
213
|
+
setAll(entities: E[], opts?: AddOptions<E, K>): void;
|
|
214
|
+
tap(handlers: TapHandlers<E, K>): () => void;
|
|
215
|
+
intercept(handlers: InterceptHandlers<E, K>): () => void;
|
|
216
|
+
}
|
|
217
|
+
export interface LoggingConfig {
|
|
218
|
+
name?: string;
|
|
219
|
+
filter?: (path: string) => boolean;
|
|
220
|
+
collapsed?: boolean;
|
|
221
|
+
onLog?: (entry: LogEntry) => void;
|
|
222
|
+
}
|
|
223
|
+
export interface LogEntry {
|
|
224
|
+
path: string;
|
|
225
|
+
prev: unknown;
|
|
226
|
+
value: unknown;
|
|
227
|
+
timestamp: number;
|
|
228
|
+
}
|
|
229
|
+
export interface ValidationConfig<T> {
|
|
230
|
+
validators: Array<{
|
|
231
|
+
match: (path: string) => boolean;
|
|
232
|
+
validate: (value: T, path: string) => void | never;
|
|
233
|
+
}>;
|
|
234
|
+
onError?: (error: Error, path: string) => void;
|
|
235
|
+
}
|
|
236
|
+
export interface PersistenceConfig {
|
|
237
|
+
key: string;
|
|
238
|
+
storage?: Storage;
|
|
239
|
+
debounceMs?: number;
|
|
240
|
+
filter?: (path: string) => boolean;
|
|
241
|
+
serialize?: (state: unknown) => string;
|
|
242
|
+
deserialize?: (json: string) => unknown;
|
|
243
|
+
}
|
|
244
|
+
export interface DevToolsConfig {
|
|
245
|
+
enableBrowserDevTools?: boolean;
|
|
246
|
+
enableLogging?: boolean;
|
|
247
|
+
performanceThreshold?: number;
|
|
248
|
+
name?: string;
|
|
249
|
+
treeName?: string;
|
|
250
|
+
enabled?: boolean;
|
|
251
|
+
logActions?: boolean;
|
|
252
|
+
maxAge?: number;
|
|
253
|
+
features?: {
|
|
254
|
+
jump?: boolean;
|
|
255
|
+
skip?: boolean;
|
|
256
|
+
reorder?: boolean;
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
export type EntityType<T> = T extends EntitySignal<infer E, infer K extends string | number> ? E : never;
|
|
260
|
+
export type EntityKeyType<T> = T extends EntitySignal<unknown, infer K extends string | number> ? K : never;
|
|
261
|
+
export type IsEntityMap<T> = T extends EntityMapMarker<unknown, infer K extends string | number> ? true : false;
|
|
262
|
+
export type DeepEntityAwareTreeNode<T> = {
|
|
263
|
+
[K in keyof T]: T[K] extends EntityMapMarker<infer E, infer Key> ? EntitySignal<E, Key> : T[K] extends object ? DeepEntityAwareTreeNode<T[K]> : CallableWritableSignal<T[K]>;
|
|
264
|
+
};
|
|
265
|
+
export type EntityAwareTreeNode<T> = {
|
|
266
|
+
[K in keyof T]: T[K] extends EntityMapMarker<infer E, infer Key> ? EntitySignal<E, Key> : CallableWritableSignal<T[K]>;
|
|
267
|
+
};
|
|
268
|
+
export type TypedSignalTree<T> = ISignalTree<T> & {
|
|
269
|
+
$: DeepEntityAwareTreeNode<T>;
|
|
270
|
+
};
|
|
271
|
+
export type PathHandler = (value: unknown, prev: unknown, path: string) => void;
|
|
272
|
+
export type PathInterceptor = (ctx: {
|
|
273
|
+
path: string;
|
|
274
|
+
value: unknown;
|
|
275
|
+
prev: unknown;
|
|
276
|
+
blocked: boolean;
|
|
277
|
+
blockReason?: string;
|
|
278
|
+
}, next: () => void) => void | Promise<void>;
|
|
279
|
+
export type CallableWritableSignal<T> = WritableSignal<T> & {
|
|
280
|
+
(value: NotFn<T>): void;
|
|
281
|
+
(updater: (current: T) => T): void;
|
|
282
|
+
};
|
|
283
|
+
export type AccessibleNode<T> = NodeAccessor<T> & TreeNode<T>;
|
|
284
|
+
export declare const ENHANCER_META: unique symbol;
|
|
285
|
+
export type Enhancer<TAdded> = (tree: ISignalTree<any>) => ISignalTree<any> & TAdded;
|
|
286
|
+
export type EnhancerWithMeta<TAdded> = Enhancer<TAdded> & {
|
|
287
|
+
metadata?: EnhancerMeta;
|
|
288
|
+
};
|
|
289
|
+
export interface EnhancerMeta {
|
|
290
|
+
name?: string;
|
|
291
|
+
requires?: string[];
|
|
292
|
+
provides?: string[];
|
|
293
|
+
description?: string;
|
|
294
|
+
}
|
|
295
|
+
export type FullSignalTree<T> = ISignalTree<T> & EffectsMethods<T> & BatchingMethods<T> & MemoizationMethods<T> & TimeTravelMethods<T> & DevToolsMethods & EntitiesEnabled & OptimizedUpdateMethods<T>;
|
|
296
|
+
export type ProdSignalTree<T> = ISignalTree<T> & EffectsMethods<T> & BatchingMethods<T> & MemoizationMethods<T> & EntitiesEnabled & OptimizedUpdateMethods<T>;
|
|
297
|
+
export type MinimalSignalTree<T> = ISignalTree<T> & EffectsMethods<T>;
|
|
298
|
+
export type SignalTree<T> = ISignalTree<T> & TreeNode<T>;
|
|
299
|
+
export type SignalTreeBase<T> = ISignalTree<T> & TreeNode<T>;
|
|
300
|
+
export declare function isSignalTree<T>(value: unknown): value is ISignalTree<T>;
|
|
301
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Signal, WritableSignal } from '@angular/core';
|
|
2
|
+
import { deepEqual, isBuiltInObject, parsePath } from '@signaltree/shared';
|
|
3
|
+
export { deepEqual };
|
|
4
|
+
export { deepEqual as equal };
|
|
5
|
+
export { isBuiltInObject };
|
|
6
|
+
export { parsePath };
|
|
7
|
+
export declare function isEntityMapMarker(value: unknown): boolean;
|
|
8
|
+
export interface MemoryManager {
|
|
9
|
+
getSignal(path: string): WritableSignal<unknown> | undefined;
|
|
10
|
+
cacheSignal(path: string, signal: WritableSignal<unknown>): void;
|
|
11
|
+
dispose(): void;
|
|
12
|
+
}
|
|
13
|
+
export interface NodeAccessor<T> {
|
|
14
|
+
(): T;
|
|
15
|
+
(value: T): void;
|
|
16
|
+
(updater: (current: T) => T): void;
|
|
17
|
+
}
|
|
18
|
+
export type TreeNode<T> = {
|
|
19
|
+
[K in keyof T]: T[K] extends readonly unknown[] ? WritableSignal<T[K]> : T[K] extends object ? T[K] extends Signal<unknown> ? T[K] : T[K] extends (...args: unknown[]) => unknown ? WritableSignal<T[K]> : NodeAccessor<T[K]> : WritableSignal<T[K]>;
|
|
20
|
+
};
|
|
21
|
+
export declare function isNodeAccessor(value: unknown): value is NodeAccessor<unknown>;
|
|
22
|
+
export declare function isAnySignal(value: unknown): boolean;
|
|
23
|
+
export declare function toWritableSignal<T>(node: NodeAccessor<T>, injector?: unknown): WritableSignal<T>;
|
|
24
|
+
export declare function composeEnhancers<T>(...enhancers: Array<(tree: T) => T>): (tree: T) => T;
|
|
25
|
+
export declare function createLazySignalTree<T extends object>(obj: T, equalityFn: (a: unknown, b: unknown) => boolean, basePath?: string, memoryManager?: MemoryManager): TreeNode<T>;
|
|
26
|
+
export declare function unwrap<T>(node: TreeNode<T>): T;
|
|
27
|
+
export declare function unwrap<T>(node: NodeAccessor<T> & TreeNode<T>): T;
|
|
28
|
+
export declare function unwrap<T>(node: NodeAccessor<T>): T;
|
|
29
|
+
export declare function unwrap<T>(node: unknown): T;
|
|
30
|
+
export declare function snapshotState<T>(state: TreeNode<T>): T;
|
|
31
|
+
export declare function applyState<T>(stateNode: TreeNode<T>, snapshot: T): void;
|
|
32
|
+
export declare function deepCloneJSON<T>(value: T): T;
|
package/LICENSE
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
BUSINESS SOURCE LICENSE 1.1
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Jonathan D Borgia
|
|
4
|
-
|
|
5
|
-
This Business Source License 1.1 ("License") governs the use of the software and associated documentation files (the "Software"). You are granted a limited license to use the Software under the terms of this License.
|
|
6
|
-
|
|
7
|
-
1. Definitions
|
|
8
|
-
|
|
9
|
-
"Change Date" means the date on which the Change License set out in section 6 will apply to the Software. The Change Date for this release is 2028-09-05.
|
|
10
|
-
|
|
11
|
-
"Change License" means the open source license that will apply to the Software on and after the Change Date. The Change License for this release is the MIT License.
|
|
12
|
-
|
|
13
|
-
"Licensor" means the copyright owner granting rights under this License (Jonathan D Borgia).
|
|
14
|
-
|
|
15
|
-
"You" ("Licensee") means an individual or legal entity exercising rights under this License who has not violated the terms of this License or had their rights terminated.
|
|
16
|
-
|
|
17
|
-
2. License Grant
|
|
18
|
-
|
|
19
|
-
Subject to the terms and conditions of this License, Licensor hereby grants You a non-exclusive, non-transferable, worldwide license to use, reproduce, display, perform, and distribute the Software, and to make modifications and derivative works for internal use, until the Change Date.
|
|
20
|
-
|
|
21
|
-
3. Commercial Use
|
|
22
|
-
|
|
23
|
-
You may use the Software in commercial applications, including for providing services, selling products that include the Software, or otherwise exploiting the Software commercially, subject to the other terms of this License.
|
|
24
|
-
|
|
25
|
-
4. Limitations and Conditions
|
|
26
|
-
|
|
27
|
-
a. You may not remove or alter this License, the copyright notice, or notices of the Change Date.
|
|
28
|
-
|
|
29
|
-
b. You may not publicly offer a modified version of the Software that would directly compete with Licensor's public offering of the Software if doing so would circumvent the intent of this License.
|
|
30
|
-
|
|
31
|
-
c. Except as expressly provided in this License, no rights are granted to You under any patent or trademark of Licensor.
|
|
32
|
-
|
|
33
|
-
5. Disclaimer and Limitation of Liability
|
|
34
|
-
|
|
35
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED. TO THE FULLEST EXTENT PERMITTED BY LAW, LICENSOR WILL NOT BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY ARISING FROM OR RELATING TO THE SOFTWARE.
|
|
36
|
-
|
|
37
|
-
6. Change License
|
|
38
|
-
|
|
39
|
-
On and after the Change Date specified above, the Software will be licensed under the Change License (MIT License) on the same terms and conditions as set forth by that Change License.
|
|
40
|
-
|
|
41
|
-
7. Governing Law
|
|
42
|
-
|
|
43
|
-
This License will be governed by and construed in accordance with the laws of the State of New York, USA, without regard to conflict of law principles.
|
|
44
|
-
|
|
45
|
-
8. Accepting this License
|
|
46
|
-
|
|
47
|
-
You accept this License by copying, modifying, or distributing the Software or any portion thereof.
|
|
48
|
-
|
|
49
|
-
---
|
|
50
|
-
|
|
51
|
-
LICENSE NOTE
|
|
52
|
-
|
|
53
|
-
- Original license file replaced on 2025-09-05 to Business Source License 1.1. Change Date: 2028-09-05. Change License: MIT.
|
|
54
|
-
or standard modifications for your own applications.
|