@signaltree/core 5.1.0 → 5.1.1
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/package.json +1 -1
- package/dist/constants.js +0 -6
- package/dist/deep-clone.js +0 -80
- package/dist/deep-equal.js +0 -41
- package/dist/enhancers/batching/lib/batching.js +0 -161
- package/dist/enhancers/computed/lib/computed.js +0 -21
- package/dist/enhancers/devtools/lib/devtools.js +0 -321
- package/dist/enhancers/entities/lib/entities.js +0 -93
- package/dist/enhancers/index.js +0 -72
- package/dist/enhancers/memoization/lib/memoization.js +0 -410
- package/dist/enhancers/presets/lib/presets.js +0 -87
- package/dist/enhancers/serialization/constants.js +0 -15
- package/dist/enhancers/serialization/lib/serialization.js +0 -662
- package/dist/enhancers/time-travel/lib/time-travel.js +0 -193
- package/dist/index.js +0 -19
- package/dist/is-built-in-object.js +0 -23
- package/dist/lib/async-helpers.js +0 -77
- package/dist/lib/constants.js +0 -56
- package/dist/lib/entity-signal.js +0 -280
- package/dist/lib/memory/memory-manager.js +0 -164
- package/dist/lib/path-notifier.js +0 -106
- package/dist/lib/performance/diff-engine.js +0 -156
- package/dist/lib/performance/path-index.js +0 -156
- package/dist/lib/performance/update-engine.js +0 -188
- package/dist/lib/security/security-validator.js +0 -121
- package/dist/lib/signal-tree.js +0 -625
- package/dist/lib/types.js +0 -9
- package/dist/lib/utils.js +0 -254
- package/dist/lru-cache.js +0 -64
- package/dist/parse-path.js +0 -13
- package/src/enhancers/batching/index.d.ts +0 -1
- package/src/enhancers/batching/lib/batching.d.ts +0 -16
- package/src/enhancers/batching/test-setup.d.ts +0 -3
- package/src/enhancers/computed/index.d.ts +0 -1
- package/src/enhancers/computed/lib/computed.d.ts +0 -12
- package/src/enhancers/devtools/index.d.ts +0 -1
- package/src/enhancers/devtools/lib/devtools.d.ts +0 -77
- package/src/enhancers/devtools/test-setup.d.ts +0 -3
- package/src/enhancers/entities/index.d.ts +0 -1
- package/src/enhancers/entities/lib/entities.d.ts +0 -20
- package/src/enhancers/entities/test-setup.d.ts +0 -3
- package/src/enhancers/index.d.ts +0 -3
- package/src/enhancers/memoization/index.d.ts +0 -1
- package/src/enhancers/memoization/lib/memoization.d.ts +0 -65
- package/src/enhancers/memoization/test-setup.d.ts +0 -3
- package/src/enhancers/presets/index.d.ts +0 -1
- package/src/enhancers/presets/lib/presets.d.ts +0 -11
- package/src/enhancers/presets/test-setup.d.ts +0 -3
- package/src/enhancers/serialization/constants.d.ts +0 -14
- package/src/enhancers/serialization/index.d.ts +0 -2
- package/src/enhancers/serialization/lib/serialization.d.ts +0 -59
- package/src/enhancers/serialization/test-setup.d.ts +0 -3
- package/src/enhancers/time-travel/index.d.ts +0 -1
- package/src/enhancers/time-travel/lib/time-travel.d.ts +0 -36
- package/src/enhancers/time-travel/lib/utils.d.ts +0 -1
- package/src/enhancers/time-travel/test-setup.d.ts +0 -3
- package/src/enhancers/types.d.ts +0 -74
- package/src/index.d.ts +0 -18
- package/src/lib/async-helpers.d.ts +0 -8
- package/src/lib/constants.d.ts +0 -41
- package/src/lib/entity-signal.d.ts +0 -1
- package/src/lib/memory/memory-manager.d.ts +0 -30
- package/src/lib/path-notifier.d.ts +0 -4
- package/src/lib/performance/diff-engine.d.ts +0 -33
- package/src/lib/performance/path-index.d.ts +0 -25
- package/src/lib/performance/update-engine.d.ts +0 -32
- package/src/lib/security/security-validator.d.ts +0 -33
- package/src/lib/signal-tree.d.ts +0 -8
- package/src/lib/types.d.ts +0 -278
- package/src/lib/utils.d.ts +0 -28
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './lib/time-travel';
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { SignalTree } from '../../../lib/types';
|
|
2
|
-
export interface TimeTravelEntry<T> {
|
|
3
|
-
state: T;
|
|
4
|
-
timestamp: number;
|
|
5
|
-
action: string;
|
|
6
|
-
payload?: unknown;
|
|
7
|
-
}
|
|
8
|
-
export interface TimeTravelInterface<T> {
|
|
9
|
-
undo(): boolean;
|
|
10
|
-
redo(): boolean;
|
|
11
|
-
getHistory(): TimeTravelEntry<T>[];
|
|
12
|
-
resetHistory(): void;
|
|
13
|
-
jumpTo(index: number): boolean;
|
|
14
|
-
getCurrentIndex(): number;
|
|
15
|
-
canUndo(): boolean;
|
|
16
|
-
canRedo(): boolean;
|
|
17
|
-
}
|
|
18
|
-
export interface TimeTravelConfig {
|
|
19
|
-
maxHistorySize?: number;
|
|
20
|
-
includePayload?: boolean;
|
|
21
|
-
actionNames?: {
|
|
22
|
-
update?: string;
|
|
23
|
-
set?: string;
|
|
24
|
-
batch?: string;
|
|
25
|
-
[key: string]: string | undefined;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
export declare function withTimeTravel<T>(config?: TimeTravelConfig): (tree: SignalTree<T>) => SignalTree<T> & {
|
|
29
|
-
__timeTravel: TimeTravelInterface<T>;
|
|
30
|
-
};
|
|
31
|
-
export declare function enableTimeTravel<T>(maxHistorySize?: number): (tree: SignalTree<T>) => SignalTree<T> & {
|
|
32
|
-
__timeTravel: TimeTravelInterface<T>;
|
|
33
|
-
};
|
|
34
|
-
export declare function getTimeTravel<T>(tree: SignalTree<T> & {
|
|
35
|
-
__timeTravel?: TimeTravelInterface<T>;
|
|
36
|
-
}): TimeTravelInterface<T> | undefined;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { deepClone, deepEqual } from '@signaltree/shared';
|
package/src/enhancers/types.d.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
export interface BatchingConfig {
|
|
2
|
-
maxBatchSize?: number;
|
|
3
|
-
debounceMs?: number;
|
|
4
|
-
flushOnMicrotask?: boolean;
|
|
5
|
-
}
|
|
6
|
-
export interface BatchUpdate<T = unknown> {
|
|
7
|
-
path: string[];
|
|
8
|
-
value: T;
|
|
9
|
-
timestamp: number;
|
|
10
|
-
}
|
|
11
|
-
export interface ComputedSignal<T> {
|
|
12
|
-
(): T;
|
|
13
|
-
readonly value: T;
|
|
14
|
-
}
|
|
15
|
-
export interface ComputedConfig {
|
|
16
|
-
lazy?: boolean;
|
|
17
|
-
memoize?: boolean;
|
|
18
|
-
}
|
|
19
|
-
export interface MemoizationConfig {
|
|
20
|
-
maxSize?: number;
|
|
21
|
-
ttl?: number;
|
|
22
|
-
strategy?: 'lru' | 'fifo' | 'lfu';
|
|
23
|
-
}
|
|
24
|
-
export interface MemoizedFunction<T extends (...args: never[]) => unknown> {
|
|
25
|
-
(...args: Parameters<T>): ReturnType<T>;
|
|
26
|
-
clear(): void;
|
|
27
|
-
stats(): {
|
|
28
|
-
hits: number;
|
|
29
|
-
misses: number;
|
|
30
|
-
size: number;
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
export interface TimeTravelConfig {
|
|
34
|
-
maxHistorySize?: number;
|
|
35
|
-
enableCompression?: boolean;
|
|
36
|
-
}
|
|
37
|
-
export interface TimeTravelState {
|
|
38
|
-
canUndo: boolean;
|
|
39
|
-
canRedo: boolean;
|
|
40
|
-
historySize: number;
|
|
41
|
-
currentIndex: number;
|
|
42
|
-
}
|
|
43
|
-
export interface DevToolsConfig {
|
|
44
|
-
name?: string;
|
|
45
|
-
enabled?: boolean;
|
|
46
|
-
logLevel?: 'debug' | 'info' | 'warn' | 'error';
|
|
47
|
-
}
|
|
48
|
-
export interface DevToolsAction {
|
|
49
|
-
type: string;
|
|
50
|
-
payload?: unknown;
|
|
51
|
-
timestamp: number;
|
|
52
|
-
source: string;
|
|
53
|
-
}
|
|
54
|
-
export interface PresetConfig {
|
|
55
|
-
name: string;
|
|
56
|
-
enhancers: unknown[];
|
|
57
|
-
config?: Record<string, unknown>;
|
|
58
|
-
}
|
|
59
|
-
export interface EntityConfig {
|
|
60
|
-
idField?: string;
|
|
61
|
-
indexes?: string[];
|
|
62
|
-
relations?: Record<string, string>;
|
|
63
|
-
}
|
|
64
|
-
export interface SerializationConfig {
|
|
65
|
-
includeComputed?: boolean;
|
|
66
|
-
includeMeta?: boolean;
|
|
67
|
-
customSerializers?: Record<string, (value: unknown) => unknown>;
|
|
68
|
-
}
|
|
69
|
-
export interface SerializedState {
|
|
70
|
-
version: string;
|
|
71
|
-
timestamp: number;
|
|
72
|
-
data: unknown;
|
|
73
|
-
meta?: Record<string, unknown>;
|
|
74
|
-
}
|
package/src/index.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export { signalTree } from './lib/signal-tree';
|
|
2
|
-
export type { SignalTree, TreeNode, CallableWritableSignal, AccessibleNode, NodeAccessor, RemoveSignalMethods, Primitive, BuiltInObject, NotFn, DeepPath, DeepAccess, TreeConfig, TreePreset, Enhancer, EnhancerMeta, EnhancerWithMeta, ChainResult, WithMethod, EntitySignal, EntityMapMarker, EntityConfig, MutationOptions, AddOptions, AddManyOptions, PerformanceMetrics, EntityHelpers, TimeTravelEntry, } from './lib/types';
|
|
3
|
-
export { entityMap } from './lib/types';
|
|
4
|
-
export { equal, deepEqual, isNodeAccessor, isAnySignal, toWritableSignal, parsePath, composeEnhancers, isBuiltInObject, createLazySignalTree, } from './lib/utils';
|
|
5
|
-
export { getPathNotifier } from './lib/path-notifier';
|
|
6
|
-
export { SecurityValidator, SecurityPresets, type SecurityEvent, type SecurityEventType, type SecurityValidatorConfig, } from './lib/security/security-validator';
|
|
7
|
-
export { createEnhancer, resolveEnhancerOrder } from './enhancers/index';
|
|
8
|
-
export { ENHANCER_META } from './lib/types';
|
|
9
|
-
export { withBatching, withHighPerformanceBatching, flushBatchedUpdates, hasPendingUpdates, getBatchQueueSize, } from './enhancers/batching/lib/batching';
|
|
10
|
-
export { withMemoization, withSelectorMemoization, withComputedMemoization, withDeepStateMemoization, withHighFrequencyMemoization, withHighPerformanceMemoization, withLightweightMemoization, withShallowMemoization, memoize, memoizeShallow, memoizeReference, cleanupMemoizationCache, clearAllCaches, getGlobalCacheStats, } from './enhancers/memoization/lib/memoization';
|
|
11
|
-
export { withTimeTravel, enableTimeTravel, getTimeTravel, type TimeTravelInterface, } from './enhancers/time-travel/lib/time-travel';
|
|
12
|
-
export { withEntities, enableEntities, withHighPerformanceEntities, } from './enhancers/entities/lib/entities';
|
|
13
|
-
export { withSerialization, enableSerialization, withPersistence, createStorageAdapter, createIndexedDBAdapter, applySerialization, applyPersistence, } from './enhancers/serialization/lib/serialization';
|
|
14
|
-
export { withDevTools, enableDevTools, withFullDevTools, withProductionDevTools, } from './enhancers/devtools/lib/devtools';
|
|
15
|
-
export { createAsyncOperation, trackAsync } from './lib/async-helpers';
|
|
16
|
-
export { TREE_PRESETS, createPresetConfig, validatePreset, getAvailablePresets, combinePresets, createDevTree, } from './enhancers/presets/lib/presets';
|
|
17
|
-
export { computedEnhancer, createComputed, type ComputedConfig, type ComputedSignal, type ComputedSignalTree, } from './enhancers/computed/lib/computed';
|
|
18
|
-
export { SIGNAL_TREE_CONSTANTS, SIGNAL_TREE_MESSAGES } from './lib/constants';
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { SignalTree } from './types';
|
|
2
|
-
export declare function createAsyncOperation<T, TResult>(name: string, operation: () => Promise<TResult>): (tree: SignalTree<T>) => Promise<TResult>;
|
|
3
|
-
export declare function trackAsync<T>(operation: () => Promise<T>): {
|
|
4
|
-
pending: import("@angular/core").Signal<boolean>;
|
|
5
|
-
error: import("@angular/core").Signal<Error | null>;
|
|
6
|
-
result: import("@angular/core").Signal<T | null>;
|
|
7
|
-
execute: () => Promise<T>;
|
|
8
|
-
};
|
package/src/lib/constants.d.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
export declare const SIGNAL_TREE_CONSTANTS: {
|
|
2
|
-
readonly MAX_PATH_CACHE_SIZE: 1000;
|
|
3
|
-
readonly LAZY_THRESHOLD: 50;
|
|
4
|
-
readonly ESTIMATE_MAX_DEPTH: 3;
|
|
5
|
-
readonly ESTIMATE_SAMPLE_SIZE_ARRAY: 3;
|
|
6
|
-
readonly ESTIMATE_SAMPLE_SIZE_OBJECT: 5;
|
|
7
|
-
readonly DEFAULT_CACHE_SIZE: 100;
|
|
8
|
-
readonly DEFAULT_BATCH_SIZE: 10;
|
|
9
|
-
};
|
|
10
|
-
export declare const SIGNAL_TREE_MESSAGES: Readonly<{
|
|
11
|
-
readonly NULL_OR_UNDEFINED: "null/undefined";
|
|
12
|
-
readonly CIRCULAR_REF: "circular ref";
|
|
13
|
-
readonly UPDATER_INVALID: "updater invalid";
|
|
14
|
-
readonly LAZY_FALLBACK: "lazy fallback";
|
|
15
|
-
readonly SIGNAL_CREATION_FAILED: "signal creation failed";
|
|
16
|
-
readonly UPDATE_PATH_NOT_FOUND: "update path not found";
|
|
17
|
-
readonly UPDATE_FAILED: "update failed";
|
|
18
|
-
readonly ROLLBACK_FAILED: "rollback failed";
|
|
19
|
-
readonly CLEANUP_ERROR: "cleanup error";
|
|
20
|
-
readonly PRESET_UNKNOWN: "unknown preset";
|
|
21
|
-
readonly STRATEGY_SELECTION: "strategy select";
|
|
22
|
-
readonly TREE_DESTROYED: "destroyed";
|
|
23
|
-
readonly UPDATE_TRANSACTION: "update tx";
|
|
24
|
-
readonly BATCH_NOT_ENABLED: "batching disabled";
|
|
25
|
-
readonly MEMOIZE_NOT_ENABLED: "memoize disabled";
|
|
26
|
-
readonly MIDDLEWARE_NOT_AVAILABLE: "middleware missing";
|
|
27
|
-
readonly ENTITY_HELPERS_NOT_AVAILABLE: "entity helpers missing";
|
|
28
|
-
readonly TIME_TRAVEL_NOT_AVAILABLE: "time travel missing";
|
|
29
|
-
readonly OPTIMIZE_NOT_AVAILABLE: "optimize missing";
|
|
30
|
-
readonly UPDATE_OPTIMIZED_NOT_AVAILABLE: "update optimized missing";
|
|
31
|
-
readonly CACHE_NOT_AVAILABLE: "cache missing";
|
|
32
|
-
readonly PERFORMANCE_NOT_ENABLED: "performance disabled";
|
|
33
|
-
readonly ENHANCER_ORDER_FAILED: "enhancer order failed";
|
|
34
|
-
readonly ENHANCER_CYCLE_DETECTED: "enhancer cycle";
|
|
35
|
-
readonly ENHANCER_REQUIREMENT_MISSING: "enhancer req missing";
|
|
36
|
-
readonly ENHANCER_PROVIDES_MISSING: "enhancer provides missing";
|
|
37
|
-
readonly ENHANCER_FAILED: "enhancer failed";
|
|
38
|
-
readonly ENHANCER_NOT_FUNCTION: "enhancer not function";
|
|
39
|
-
readonly EFFECT_NO_CONTEXT: "no angular context";
|
|
40
|
-
readonly SUBSCRIBE_NO_CONTEXT: "no angular context";
|
|
41
|
-
}>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { WritableSignal } from '@angular/core';
|
|
2
|
-
export interface MemoryStats {
|
|
3
|
-
cachedSignals: number;
|
|
4
|
-
cleanedUpSignals: number;
|
|
5
|
-
peakCachedSignals: number;
|
|
6
|
-
manualDisposes: number;
|
|
7
|
-
estimatedMemoryBytes: number;
|
|
8
|
-
}
|
|
9
|
-
export interface MemoryManagerConfig {
|
|
10
|
-
enableAutoCleanup?: boolean;
|
|
11
|
-
debugMode?: boolean;
|
|
12
|
-
onCleanup?: (path: string, stats: MemoryStats) => void;
|
|
13
|
-
}
|
|
14
|
-
export declare class SignalMemoryManager {
|
|
15
|
-
private cache;
|
|
16
|
-
private registry;
|
|
17
|
-
private config;
|
|
18
|
-
private stats;
|
|
19
|
-
constructor(config?: MemoryManagerConfig);
|
|
20
|
-
cacheSignal<T>(path: string, signal: WritableSignal<T>): void;
|
|
21
|
-
getSignal(path: string): WritableSignal<unknown> | undefined;
|
|
22
|
-
hasSignal(path: string): boolean;
|
|
23
|
-
removeSignal(path: string): boolean;
|
|
24
|
-
private handleCleanup;
|
|
25
|
-
getStats(): MemoryStats;
|
|
26
|
-
dispose(): void;
|
|
27
|
-
getCachedPaths(): string[];
|
|
28
|
-
clearStale(): number;
|
|
29
|
-
resetStats(): void;
|
|
30
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { Path } from './path-index';
|
|
2
|
-
export declare enum ChangeType {
|
|
3
|
-
ADD = "add",
|
|
4
|
-
UPDATE = "update",
|
|
5
|
-
DELETE = "delete",
|
|
6
|
-
REPLACE = "replace"
|
|
7
|
-
}
|
|
8
|
-
export interface Change {
|
|
9
|
-
type: ChangeType;
|
|
10
|
-
path: Path;
|
|
11
|
-
value?: unknown;
|
|
12
|
-
oldValue?: unknown;
|
|
13
|
-
}
|
|
14
|
-
export interface Diff {
|
|
15
|
-
changes: Change[];
|
|
16
|
-
hasChanges: boolean;
|
|
17
|
-
}
|
|
18
|
-
export interface DiffOptions {
|
|
19
|
-
maxDepth?: number;
|
|
20
|
-
detectDeletions?: boolean;
|
|
21
|
-
ignoreArrayOrder?: boolean;
|
|
22
|
-
equalityFn?: (a: unknown, b: unknown) => boolean;
|
|
23
|
-
keyValidator?: (key: string) => boolean;
|
|
24
|
-
}
|
|
25
|
-
export declare class DiffEngine {
|
|
26
|
-
private defaultOptions;
|
|
27
|
-
diff(current: unknown, updates: unknown, options?: DiffOptions): Diff;
|
|
28
|
-
private traverse;
|
|
29
|
-
private diffArrays;
|
|
30
|
-
private diffArraysOrdered;
|
|
31
|
-
private diffArraysUnordered;
|
|
32
|
-
private stringify;
|
|
33
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { WritableSignal } from '@angular/core';
|
|
2
|
-
export type PathSegment = string | number;
|
|
3
|
-
export type Path = PathSegment[];
|
|
4
|
-
export declare class PathIndex<T extends object = WritableSignal<any>> {
|
|
5
|
-
private root;
|
|
6
|
-
private pathCache;
|
|
7
|
-
private stats;
|
|
8
|
-
set(path: Path, signal: T): void;
|
|
9
|
-
get(path: Path): T | null;
|
|
10
|
-
has(path: Path): boolean;
|
|
11
|
-
getByPrefix(prefix: Path): Map<string, T>;
|
|
12
|
-
delete(path: Path): boolean;
|
|
13
|
-
clear(): void;
|
|
14
|
-
getStats(): {
|
|
15
|
-
hits: number;
|
|
16
|
-
misses: number;
|
|
17
|
-
sets: number;
|
|
18
|
-
cleanups: number;
|
|
19
|
-
hitRate: number;
|
|
20
|
-
cacheSize: number;
|
|
21
|
-
};
|
|
22
|
-
buildFromTree(tree: unknown, path?: Path): void;
|
|
23
|
-
private pathToString;
|
|
24
|
-
private collectDescendants;
|
|
25
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { PathIndex } from './path-index';
|
|
2
|
-
import type { DiffOptions } from './diff-engine';
|
|
3
|
-
export interface UpdateOptions extends DiffOptions {
|
|
4
|
-
batch?: boolean;
|
|
5
|
-
batchSize?: number;
|
|
6
|
-
}
|
|
7
|
-
export interface UpdateResult {
|
|
8
|
-
changed: boolean;
|
|
9
|
-
duration: number;
|
|
10
|
-
changedPaths: string[];
|
|
11
|
-
stats?: {
|
|
12
|
-
totalPaths: number;
|
|
13
|
-
optimizedPaths: number;
|
|
14
|
-
batchedUpdates: number;
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
export declare class OptimizedUpdateEngine {
|
|
18
|
-
private pathIndex;
|
|
19
|
-
private diffEngine;
|
|
20
|
-
constructor(tree: unknown);
|
|
21
|
-
update(tree: unknown, updates: unknown, options?: UpdateOptions): UpdateResult;
|
|
22
|
-
rebuildIndex(tree: unknown): void;
|
|
23
|
-
getIndexStats(): ReturnType<PathIndex['getStats']>;
|
|
24
|
-
private createPatches;
|
|
25
|
-
private createPatch;
|
|
26
|
-
private calculatePriority;
|
|
27
|
-
private sortPatches;
|
|
28
|
-
private applyPatches;
|
|
29
|
-
private batchApplyPatches;
|
|
30
|
-
private applyPatch;
|
|
31
|
-
private isEqual;
|
|
32
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
export type SecurityEventType = 'dangerous-key-blocked' | 'xss-attempt-blocked' | 'function-value-blocked' | 'validation-error';
|
|
2
|
-
export interface SecurityEvent {
|
|
3
|
-
type: SecurityEventType;
|
|
4
|
-
key?: string;
|
|
5
|
-
value?: unknown;
|
|
6
|
-
reason: string;
|
|
7
|
-
timestamp: number;
|
|
8
|
-
}
|
|
9
|
-
export interface SecurityValidatorConfig {
|
|
10
|
-
preventPrototypePollution?: boolean;
|
|
11
|
-
preventXSS?: boolean;
|
|
12
|
-
preventFunctions?: boolean;
|
|
13
|
-
customDangerousKeys?: string[];
|
|
14
|
-
onSecurityEvent?: (event: SecurityEvent) => void;
|
|
15
|
-
sanitizationMode?: 'strict' | 'permissive';
|
|
16
|
-
}
|
|
17
|
-
export declare class SecurityValidator {
|
|
18
|
-
private readonly config;
|
|
19
|
-
private readonly dangerousKeys;
|
|
20
|
-
constructor(config?: SecurityValidatorConfig);
|
|
21
|
-
validateKey(key: string): void;
|
|
22
|
-
validateValue<T>(value: T): T;
|
|
23
|
-
private sanitize;
|
|
24
|
-
validateKeyValue<T>(key: string, value: T): T;
|
|
25
|
-
isDangerousKey(key: string): boolean;
|
|
26
|
-
getConfig(): Readonly<Required<SecurityValidatorConfig>>;
|
|
27
|
-
}
|
|
28
|
-
export declare const SecurityPresets: {
|
|
29
|
-
strict: () => SecurityValidator;
|
|
30
|
-
standard: () => SecurityValidator;
|
|
31
|
-
permissive: () => SecurityValidator;
|
|
32
|
-
disabled: () => SecurityValidator;
|
|
33
|
-
};
|
package/src/lib/signal-tree.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { SignalTree, TreeConfig, TreePreset, EnhancerWithMeta, NodeAccessor } from './types';
|
|
2
|
-
export declare function isNodeAccessor(value: unknown): value is NodeAccessor<unknown>;
|
|
3
|
-
export declare function signalTree<T>(obj: T): SignalTree<T>;
|
|
4
|
-
export declare function signalTree<T>(obj: T, preset: TreePreset): SignalTree<T>;
|
|
5
|
-
export declare function signalTree<T>(obj: T, config: TreeConfig): SignalTree<T>;
|
|
6
|
-
export declare function signalTree<T extends Record<string, unknown>>(obj: Required<T>, configOrPreset?: TreeConfig | TreePreset): SignalTree<Required<T>>;
|
|
7
|
-
export declare function signalTree<T>(obj: T, configOrPreset?: TreeConfig | TreePreset): SignalTree<T>;
|
|
8
|
-
export declare function applyEnhancer<T, O>(tree: SignalTree<T>, enhancer: EnhancerWithMeta<SignalTree<T>, O>): O;
|
package/src/lib/types.d.ts
DELETED
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
import { Signal, WritableSignal } from '@angular/core';
|
|
2
|
-
import type { SecurityValidatorConfig } from './security/security-validator';
|
|
3
|
-
export type NotFn<T> = T extends (...args: unknown[]) => unknown ? never : T;
|
|
4
|
-
declare module '@angular/core' {
|
|
5
|
-
interface WritableSignal<T> {
|
|
6
|
-
(value: NotFn<T>): void;
|
|
7
|
-
(updater: (current: T) => T): void;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
export type Primitive = string | number | boolean | null | undefined | bigint | symbol;
|
|
11
|
-
export type BuiltInObject = Date | RegExp | ((...args: unknown[]) => unknown) | Map<unknown, unknown> | Set<unknown> | WeakMap<object, unknown> | WeakSet<object> | ArrayBuffer | DataView | Error | Promise<unknown> | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array | URL | URLSearchParams | FormData | Blob | File | Headers | Request | Response | AbortController | AbortSignal;
|
|
12
|
-
export type Unwrap<T> = [T] extends [WritableSignal<infer U>] ? U : [T] extends [Signal<infer U>] ? U : [T] extends [BuiltInObject] ? T : [T] extends [readonly unknown[]] ? T : [T] extends [EntityMapMarker<infer E, infer K>] ? EntitySignal<E, K> : [T] extends [object] ? {
|
|
13
|
-
[K in keyof T]: Unwrap<T[K]>;
|
|
14
|
-
} : T;
|
|
15
|
-
export interface NodeAccessor<T> {
|
|
16
|
-
(): T;
|
|
17
|
-
(value: T): void;
|
|
18
|
-
(updater: (current: T) => T): void;
|
|
19
|
-
}
|
|
20
|
-
export type AccessibleNode<T> = NodeAccessor<T> & TreeNode<T>;
|
|
21
|
-
export type CallableWritableSignal<T> = WritableSignal<T> & {
|
|
22
|
-
(value: NotFn<T>): void;
|
|
23
|
-
(updater: (current: T) => T): void;
|
|
24
|
-
};
|
|
25
|
-
export type TreeNode<T> = {
|
|
26
|
-
[K in keyof T]: [T[K]] extends [EntityMapMarker<infer E, infer Key>] ? EntitySignal<E, Key> : [T[K]] extends [readonly unknown[]] ? CallableWritableSignal<T[K]> : [T[K]] extends [object] ? [T[K]] extends [Signal<unknown>] ? T[K] : [T[K]] extends [BuiltInObject] ? CallableWritableSignal<T[K]> : [T[K]] extends [(...args: unknown[]) => unknown] ? CallableWritableSignal<T[K]> : AccessibleNode<T[K]> : CallableWritableSignal<T[K]>;
|
|
27
|
-
};
|
|
28
|
-
export type RemoveSignalMethods<T> = T extends infer U ? U : never;
|
|
29
|
-
export type DeepPath<T, Prefix extends string = '', Depth extends readonly number[] = []> = Depth['length'] extends 5 ? never : {
|
|
30
|
-
[K in keyof T]: K extends string ? T[K] extends readonly unknown[] ? `${Prefix}${K}` : T[K] extends object ? T[K] extends Signal<unknown> ? never : T[K] extends BuiltInObject ? never : T[K] extends (...args: unknown[]) => unknown ? never : `${Prefix}${K}` | DeepPath<T[K], `${Prefix}${K}.`, [...Depth, 1]> : never : never;
|
|
31
|
-
}[keyof T];
|
|
32
|
-
export type DeepAccess<T, Path extends string> = Path extends `${infer First}.${infer Rest}` ? First extends keyof T ? DeepAccess<T[First] & object, Rest> : never : Path extends keyof T ? T[Path] : never;
|
|
33
|
-
export interface EnhancerMeta {
|
|
34
|
-
name?: string;
|
|
35
|
-
requires?: string[];
|
|
36
|
-
provides?: string[];
|
|
37
|
-
}
|
|
38
|
-
export type Enhancer<Input = unknown, Output = unknown> = (input: Input) => Output;
|
|
39
|
-
export type EnhancerWithMeta<Input = unknown, Output = unknown> = Enhancer<Input, Output> & {
|
|
40
|
-
metadata?: EnhancerMeta;
|
|
41
|
-
};
|
|
42
|
-
export declare const ENHANCER_META: unique symbol;
|
|
43
|
-
export type ChainResult<Start, E extends Array<EnhancerWithMeta<unknown, unknown>>> = E extends [infer H, ...infer R] ? H extends EnhancerWithMeta<SignalTree<unknown>, infer O> ? R extends Array<EnhancerWithMeta<unknown, unknown>> ? ChainResult<O, R> : O : H extends EnhancerWithMeta<infer I, infer O> ? Start extends I ? R extends Array<EnhancerWithMeta<unknown, unknown>> ? ChainResult<O, R> : O : unknown : unknown : Start;
|
|
44
|
-
export interface WithMethod<T> {
|
|
45
|
-
(): SignalTree<T>;
|
|
46
|
-
<O>(enhancer: (input: SignalTree<T>) => O): O;
|
|
47
|
-
<O1, O2>(e1: (input: SignalTree<T>) => O1, e2: (input: O1) => O2): O2;
|
|
48
|
-
<O1, O2, O3>(e1: (input: SignalTree<T>) => O1, e2: (input: O1) => O2, e3: (input: O2) => O3): O3;
|
|
49
|
-
<O>(enhancer: EnhancerWithMeta<SignalTree<T>, O>): O;
|
|
50
|
-
<O1, O2>(e1: EnhancerWithMeta<SignalTree<T>, O1>, e2: EnhancerWithMeta<O1, O2>): O2;
|
|
51
|
-
<O1, O2, O3>(e1: EnhancerWithMeta<SignalTree<T>, O1>, e2: EnhancerWithMeta<O1, O2>, e3: EnhancerWithMeta<O2, O3>): O3;
|
|
52
|
-
}
|
|
53
|
-
export type SignalTree<T> = NodeAccessor<T> & {
|
|
54
|
-
state: TreeNode<T>;
|
|
55
|
-
$: TreeNode<T>;
|
|
56
|
-
with: WithMethod<T>;
|
|
57
|
-
destroy(): void;
|
|
58
|
-
dispose?(): void;
|
|
59
|
-
effect(fn: (tree: T) => void): void;
|
|
60
|
-
subscribe(fn: (tree: T) => void): () => void;
|
|
61
|
-
batch(updater: (tree: T) => void): void;
|
|
62
|
-
batchUpdate(updater: (current: T) => Partial<T>): void;
|
|
63
|
-
memoize<R>(fn: (tree: T) => R, cacheKey?: string): Signal<R>;
|
|
64
|
-
memoizedUpdate(updater: (current: T) => Partial<T>, cacheKey?: string): void;
|
|
65
|
-
clearMemoCache(key?: string): void;
|
|
66
|
-
getCacheStats(): {
|
|
67
|
-
size: number;
|
|
68
|
-
hitRate: number;
|
|
69
|
-
totalHits: number;
|
|
70
|
-
totalMisses: number;
|
|
71
|
-
keys: string[];
|
|
72
|
-
};
|
|
73
|
-
optimize(): void;
|
|
74
|
-
clearCache(): void;
|
|
75
|
-
invalidatePattern(pattern: string): number;
|
|
76
|
-
updateOptimized?(updates: Partial<T>, options?: {
|
|
77
|
-
batch?: boolean;
|
|
78
|
-
batchSize?: number;
|
|
79
|
-
maxDepth?: number;
|
|
80
|
-
ignoreArrayOrder?: boolean;
|
|
81
|
-
equalityFn?: (a: unknown, b: unknown) => boolean;
|
|
82
|
-
}): {
|
|
83
|
-
changed: boolean;
|
|
84
|
-
duration: number;
|
|
85
|
-
changedPaths: string[];
|
|
86
|
-
stats?: {
|
|
87
|
-
totalPaths: number;
|
|
88
|
-
optimizedPaths: number;
|
|
89
|
-
batchedUpdates: number;
|
|
90
|
-
};
|
|
91
|
-
};
|
|
92
|
-
getMetrics(): PerformanceMetrics;
|
|
93
|
-
entities<E extends {
|
|
94
|
-
id: string | number;
|
|
95
|
-
}>(entityKey?: keyof T): EntityHelpers<E>;
|
|
96
|
-
undo(): void;
|
|
97
|
-
redo(): void;
|
|
98
|
-
getHistory(): TimeTravelEntry<T>[];
|
|
99
|
-
resetHistory(): void;
|
|
100
|
-
jumpTo?: (index: number) => void;
|
|
101
|
-
canUndo?: () => boolean;
|
|
102
|
-
canRedo?: () => boolean;
|
|
103
|
-
getCurrentIndex?: () => number;
|
|
104
|
-
};
|
|
105
|
-
export type TreePreset = 'basic' | 'performance' | 'development' | 'production';
|
|
106
|
-
export interface TreeConfig {
|
|
107
|
-
batchUpdates?: boolean;
|
|
108
|
-
useMemoization?: boolean;
|
|
109
|
-
enableTimeTravel?: boolean;
|
|
110
|
-
useLazySignals?: boolean;
|
|
111
|
-
useShallowComparison?: boolean;
|
|
112
|
-
maxCacheSize?: number;
|
|
113
|
-
trackPerformance?: boolean;
|
|
114
|
-
treeName?: string;
|
|
115
|
-
enableDevTools?: boolean;
|
|
116
|
-
debugMode?: boolean;
|
|
117
|
-
useStructuralSharing?: boolean;
|
|
118
|
-
security?: SecurityValidatorConfig;
|
|
119
|
-
}
|
|
120
|
-
export interface PerformanceMetrics {
|
|
121
|
-
updates: number;
|
|
122
|
-
computations: number;
|
|
123
|
-
cacheHits: number;
|
|
124
|
-
cacheMisses: number;
|
|
125
|
-
averageUpdateTime: number;
|
|
126
|
-
}
|
|
127
|
-
export interface EntityConfig<E, K extends string | number = string> {
|
|
128
|
-
selectId?: (entity: E) => K;
|
|
129
|
-
hooks?: {
|
|
130
|
-
beforeAdd?: (entity: E) => E | false;
|
|
131
|
-
beforeUpdate?: (id: K, changes: Partial<E>) => Partial<E> | false;
|
|
132
|
-
beforeRemove?: (id: K, entity: E) => boolean;
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
declare const ENTITY_MAP_BRAND: unique symbol;
|
|
136
|
-
export interface EntityMapMarker<E, K extends string | number> {
|
|
137
|
-
readonly [ENTITY_MAP_BRAND]: {
|
|
138
|
-
__entity: E;
|
|
139
|
-
__key: K;
|
|
140
|
-
};
|
|
141
|
-
readonly __isEntityMap: true;
|
|
142
|
-
readonly __entityMapConfig?: EntityConfig<E, K>;
|
|
143
|
-
}
|
|
144
|
-
export declare function entityMap<E, K extends string | number = E extends {
|
|
145
|
-
id: infer I extends string | number;
|
|
146
|
-
} ? I : string>(config?: EntityConfig<E, K>): EntityMapMarker<E, K>;
|
|
147
|
-
export interface MutationOptions {
|
|
148
|
-
onError?: (error: Error) => void;
|
|
149
|
-
}
|
|
150
|
-
export interface AddOptions<E, K> extends MutationOptions {
|
|
151
|
-
selectId?: (entity: E) => K;
|
|
152
|
-
}
|
|
153
|
-
export interface AddManyOptions<E, K> extends AddOptions<E, K> {
|
|
154
|
-
mode?: 'strict' | 'skip' | 'overwrite';
|
|
155
|
-
}
|
|
156
|
-
export interface TapHandlers<E, K extends string | number> {
|
|
157
|
-
onAdd?: (entity: E, id: K) => void;
|
|
158
|
-
onUpdate?: (id: K, changes: Partial<E>, entity: E) => void;
|
|
159
|
-
onRemove?: (id: K, entity: E) => void;
|
|
160
|
-
onChange?: () => void;
|
|
161
|
-
}
|
|
162
|
-
export interface InterceptContext<T> {
|
|
163
|
-
block(reason?: string): void;
|
|
164
|
-
transform(value: T): void;
|
|
165
|
-
readonly blocked: boolean;
|
|
166
|
-
readonly blockReason: string | undefined;
|
|
167
|
-
}
|
|
168
|
-
export interface InterceptHandlers<E, K extends string | number> {
|
|
169
|
-
onAdd?: (entity: E, ctx: InterceptContext<E>) => void | Promise<void>;
|
|
170
|
-
onUpdate?: (id: K, changes: Partial<E>, ctx: InterceptContext<Partial<E>>) => void | Promise<void>;
|
|
171
|
-
onRemove?: (id: K, entity: E, ctx: InterceptContext<void>) => void | Promise<void>;
|
|
172
|
-
}
|
|
173
|
-
export type EntityNode<E> = {
|
|
174
|
-
(): E;
|
|
175
|
-
(value: E): void;
|
|
176
|
-
(updater: (current: E) => E): void;
|
|
177
|
-
} & {
|
|
178
|
-
[P in keyof E]: E[P] extends object ? E[P] extends readonly unknown[] ? CallableWritableSignal<E[P]> : EntityNode<E[P]> : CallableWritableSignal<E[P]>;
|
|
179
|
-
};
|
|
180
|
-
export interface EntitySignal<E, K extends string | number = string> {
|
|
181
|
-
byId(id: K): EntityNode<E> | undefined;
|
|
182
|
-
byIdOrFail(id: K): EntityNode<E>;
|
|
183
|
-
all(): Signal<E[]>;
|
|
184
|
-
count(): Signal<number>;
|
|
185
|
-
ids(): Signal<K[]>;
|
|
186
|
-
has(id: K): Signal<boolean>;
|
|
187
|
-
isEmpty(): Signal<boolean>;
|
|
188
|
-
map(): Signal<ReadonlyMap<K, E>>;
|
|
189
|
-
where(predicate: (entity: E) => boolean): Signal<E[]>;
|
|
190
|
-
find(predicate: (entity: E) => boolean): Signal<E | undefined>;
|
|
191
|
-
addOne(entity: E, opts?: AddOptions<E, K>): K;
|
|
192
|
-
addMany(entities: E[], opts?: AddManyOptions<E, K>): K[];
|
|
193
|
-
updateOne(id: K, changes: Partial<E>, opts?: MutationOptions): void;
|
|
194
|
-
updateMany(ids: K[], changes: Partial<E>, opts?: MutationOptions): void;
|
|
195
|
-
updateWhere(predicate: (entity: E) => boolean, changes: Partial<E>): number;
|
|
196
|
-
upsertOne(entity: E, opts?: AddOptions<E, K>): K;
|
|
197
|
-
upsertMany(entities: E[], opts?: AddOptions<E, K>): K[];
|
|
198
|
-
removeOne(id: K, opts?: MutationOptions): void;
|
|
199
|
-
removeMany(ids: K[], opts?: MutationOptions): void;
|
|
200
|
-
removeWhere(predicate: (entity: E) => boolean): number;
|
|
201
|
-
clear(): void;
|
|
202
|
-
removeAll(): void;
|
|
203
|
-
setAll(entities: E[], opts?: AddOptions<E, K>): void;
|
|
204
|
-
tap(handlers: TapHandlers<E, K>): () => void;
|
|
205
|
-
intercept(handlers: InterceptHandlers<E, K>): () => void;
|
|
206
|
-
}
|
|
207
|
-
export interface EntityHelpers<E extends {
|
|
208
|
-
id: string | number;
|
|
209
|
-
}> {
|
|
210
|
-
add(entity: E): void;
|
|
211
|
-
update(id: E['id'], updates: Partial<E>): void;
|
|
212
|
-
remove(id: E['id']): void;
|
|
213
|
-
upsert(entity: E): void;
|
|
214
|
-
selectById(id: E['id']): Signal<E | undefined>;
|
|
215
|
-
selectBy(predicate: (entity: E) => boolean): Signal<E[]>;
|
|
216
|
-
selectIds(): Signal<Array<string | number>>;
|
|
217
|
-
selectAll(): Signal<E[]>;
|
|
218
|
-
selectTotal(): Signal<number>;
|
|
219
|
-
clear(): void;
|
|
220
|
-
}
|
|
221
|
-
export interface LoggingConfig {
|
|
222
|
-
name?: string;
|
|
223
|
-
filter?: (path: string) => boolean;
|
|
224
|
-
collapsed?: boolean;
|
|
225
|
-
onLog?: (entry: LogEntry) => void;
|
|
226
|
-
}
|
|
227
|
-
export interface LogEntry {
|
|
228
|
-
path: string;
|
|
229
|
-
prev: unknown;
|
|
230
|
-
value: unknown;
|
|
231
|
-
timestamp: number;
|
|
232
|
-
}
|
|
233
|
-
export interface ValidationConfig<T> {
|
|
234
|
-
validators: Array<{
|
|
235
|
-
match: (path: string) => boolean;
|
|
236
|
-
validate: (value: T, path: string) => void | never;
|
|
237
|
-
}>;
|
|
238
|
-
onError?: (error: Error, path: string) => void;
|
|
239
|
-
}
|
|
240
|
-
export interface PersistenceConfig {
|
|
241
|
-
key: string;
|
|
242
|
-
storage?: Storage;
|
|
243
|
-
debounceMs?: number;
|
|
244
|
-
filter?: (path: string) => boolean;
|
|
245
|
-
serialize?: (state: unknown) => string;
|
|
246
|
-
deserialize?: (json: string) => unknown;
|
|
247
|
-
}
|
|
248
|
-
export interface DevToolsConfig {
|
|
249
|
-
name?: string;
|
|
250
|
-
maxAge?: number;
|
|
251
|
-
features?: {
|
|
252
|
-
jump?: boolean;
|
|
253
|
-
skip?: boolean;
|
|
254
|
-
reorder?: boolean;
|
|
255
|
-
};
|
|
256
|
-
}
|
|
257
|
-
export type EntityType<T> = T extends EntitySignal<infer E, infer K extends string | number> ? E : never;
|
|
258
|
-
export type EntityKeyType<T> = T extends EntitySignal<unknown, infer K extends string | number> ? K : never;
|
|
259
|
-
export type IsEntityMap<T> = T extends EntityMapMarker<unknown, infer K extends string | number> ? true : false;
|
|
260
|
-
export type EntityAwareTreeNode<T> = {
|
|
261
|
-
[K in keyof T]: T[K] extends EntityMapMarker<infer E, infer Key> ? EntitySignal<E, Key> : T[K] extends object ? EntityAwareTreeNode<T[K]> : CallableWritableSignal<T[K]>;
|
|
262
|
-
};
|
|
263
|
-
export type PathHandler = (value: unknown, prev: unknown, path: string) => void;
|
|
264
|
-
export type PathInterceptor = (ctx: {
|
|
265
|
-
path: string;
|
|
266
|
-
value: unknown;
|
|
267
|
-
prev: unknown;
|
|
268
|
-
blocked: boolean;
|
|
269
|
-
blockReason?: string;
|
|
270
|
-
}, next: () => void) => void | Promise<void>;
|
|
271
|
-
export interface TimeTravelEntry<T> {
|
|
272
|
-
action: string;
|
|
273
|
-
timestamp: number;
|
|
274
|
-
state: T;
|
|
275
|
-
payload?: unknown;
|
|
276
|
-
}
|
|
277
|
-
export declare function isSignalTree<T>(value: unknown): value is SignalTree<T>;
|
|
278
|
-
export {};
|