@mhmo91/schmancy 0.2.127 → 0.2.128
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/card.cjs +1 -1
- package/dist/card.js +1 -1
- package/dist/content-drawer.cjs +1 -1
- package/dist/content-drawer.js +1 -1
- package/dist/{context-object-CVqtbNDv.js → context-object-CD26Iary.js} +20 -17
- package/dist/context-object-CD26Iary.js.map +1 -0
- package/dist/context-object-D81PeS3j.cjs +2 -0
- package/dist/context-object-D81PeS3j.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +99 -86
- package/dist/nav-drawer.cjs +1 -1
- package/dist/nav-drawer.js +1 -1
- package/dist/selector-hook-9dSW11-1.js +274 -0
- package/dist/selector-hook-9dSW11-1.js.map +1 -0
- package/dist/selector-hook-CH-z8W2d.cjs +2 -0
- package/dist/selector-hook-CH-z8W2d.cjs.map +1 -0
- package/dist/store.cjs +1 -1
- package/dist/store.js +30 -17
- package/dist/teleport.cjs +1 -1
- package/dist/{teleport.component-B8yyRFCq.js → teleport.component-CBNKUZwe.js} +2 -2
- package/dist/{teleport.component-B8yyRFCq.js.map → teleport.component-CBNKUZwe.js.map} +1 -1
- package/dist/{teleport.component-AE9wd-Xe.cjs → teleport.component-CplIV2h1.cjs} +2 -2
- package/dist/{teleport.component-AE9wd-Xe.cjs.map → teleport.component-CplIV2h1.cjs.map} +1 -1
- package/dist/teleport.js +1 -1
- package/package.json +1 -1
- package/types/src/store/context-create.d.ts +15 -2
- package/types/src/store/filter-directive.d.ts +38 -11
- package/types/src/store/selector-hook.d.ts +27 -0
- package/types/src/store/selectors.d.ts +30 -1
- package/types/src/store/storage-manager.d.ts +6 -14
- package/types/src/store/types.d.ts +100 -45
- package/dist/context-object-CVqtbNDv.js.map +0 -1
- package/dist/context-object-CgZ6F8E9.cjs +0 -2
- package/dist/context-object-CgZ6F8E9.cjs.map +0 -1
- package/dist/selector-hook-B5oIBdcJ.cjs +0 -2
- package/dist/selector-hook-B5oIBdcJ.cjs.map +0 -1
- package/dist/selector-hook-BdsJkaE2.js +0 -185
- package/dist/selector-hook-BdsJkaE2.js.map +0 -1
|
@@ -17,68 +17,123 @@ export interface StoreOptions<T> {
|
|
|
17
17
|
devTools?: boolean;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
21
|
-
*/
|
|
22
|
-
export interface Action<T = any> {
|
|
23
|
-
type: string;
|
|
24
|
-
payload?: T;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Type-safe action creator
|
|
28
|
-
*/
|
|
29
|
-
export type ActionCreator<P = void, R = void> = P extends void ? () => R : (payload: P) => R;
|
|
30
|
-
/**
|
|
31
|
-
* Map of action creators with preserved function signatures
|
|
32
|
-
*/
|
|
33
|
-
export type ActionCreatorMap<T> = {
|
|
34
|
-
[K in keyof T]: T[K] extends (...args: infer A) => infer R ? (...args: A) => R : never;
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* Reducer function type
|
|
38
|
-
*/
|
|
39
|
-
export type Reducer<T> = (state: T, action: Action) => T;
|
|
40
|
-
/**
|
|
41
|
-
* Middleware function type
|
|
42
|
-
*/
|
|
43
|
-
export type Middleware<T> = (prevState: T, nextState: T, context: {
|
|
44
|
-
type: string;
|
|
45
|
-
payload?: any;
|
|
46
|
-
}) => void;
|
|
47
|
-
/**
|
|
48
|
-
* Selector function type
|
|
49
|
-
*/
|
|
50
|
-
export type Selector<S, R> = (state: S) => R;
|
|
51
|
-
/**
|
|
52
|
-
* Enhanced store error with type information
|
|
20
|
+
* Enhanced store error with type information and better context handling
|
|
53
21
|
*/
|
|
54
22
|
export declare class StoreError<T = unknown> extends Error {
|
|
23
|
+
/** Original error that caused this store error */
|
|
55
24
|
readonly cause?: T;
|
|
25
|
+
/** Additional contextual information */
|
|
56
26
|
readonly context?: Record<string, unknown>;
|
|
27
|
+
/** Timestamp when the error occurred */
|
|
28
|
+
readonly timestamp: Date;
|
|
57
29
|
constructor(message: string, cause?: T, context?: Record<string, unknown>);
|
|
30
|
+
/**
|
|
31
|
+
* Returns a JSON-serializable representation of the error
|
|
32
|
+
*/
|
|
33
|
+
toJSON(): Record<string, unknown>;
|
|
58
34
|
}
|
|
59
35
|
/**
|
|
60
|
-
* Core store interface
|
|
36
|
+
* Core store interface with improved type definitions
|
|
61
37
|
*/
|
|
62
|
-
export interface IStore<T
|
|
63
|
-
value
|
|
64
|
-
|
|
38
|
+
export interface IStore<T extends Record<string, any>> {
|
|
39
|
+
/** Get the current store value */
|
|
40
|
+
readonly value: T;
|
|
41
|
+
/** Observable stream of store values */
|
|
42
|
+
readonly $: BehaviorSubject<T>;
|
|
43
|
+
/** The default/initial value of the store */
|
|
44
|
+
readonly defaultValue: T;
|
|
45
|
+
/** Whether the store is ready (loaded from storage) */
|
|
46
|
+
ready: boolean;
|
|
47
|
+
/** Observable stream of store errors */
|
|
48
|
+
readonly error$: Observable<StoreError | null>;
|
|
49
|
+
/**
|
|
50
|
+
* Update store value with partial data
|
|
51
|
+
* @param value Partial data to update
|
|
52
|
+
* @param merge Whether to merge with existing data (default: true)
|
|
53
|
+
*/
|
|
65
54
|
set(value: Partial<T>, merge?: boolean): void;
|
|
55
|
+
/**
|
|
56
|
+
* Reset store to default value
|
|
57
|
+
*/
|
|
66
58
|
clear(): void;
|
|
59
|
+
/**
|
|
60
|
+
* Replace entire store value
|
|
61
|
+
* @param newValue New value to set
|
|
62
|
+
*/
|
|
67
63
|
replace(newValue: T): void;
|
|
68
|
-
|
|
69
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Delete a specific key from the store
|
|
66
|
+
* @param key Key to delete
|
|
67
|
+
*/
|
|
68
|
+
delete<K extends keyof T>(key: K): void;
|
|
69
|
+
/**
|
|
70
|
+
* Clean up resources
|
|
71
|
+
*/
|
|
72
|
+
destroy(): void;
|
|
70
73
|
}
|
|
71
74
|
/**
|
|
72
|
-
* Interface for collection stores
|
|
73
|
-
* No longer extends IStore to avoid method signature conflicts
|
|
75
|
+
* Interface for collection stores with improved typing
|
|
74
76
|
*/
|
|
75
77
|
export interface ICollectionStore<T> {
|
|
76
|
-
value
|
|
77
|
-
|
|
78
|
+
/** Get the current collection value */
|
|
79
|
+
readonly value: Map<string, T>;
|
|
80
|
+
/** Observable stream of collection values */
|
|
81
|
+
readonly $: BehaviorSubject<Map<string, T>>;
|
|
82
|
+
/** The default/initial value of the collection */
|
|
83
|
+
readonly defaultValue: Map<string, T>;
|
|
84
|
+
/** Whether the store is ready (loaded from storage) */
|
|
85
|
+
ready: boolean;
|
|
86
|
+
/** Observable stream of store errors */
|
|
87
|
+
readonly error$: Observable<StoreError | null>;
|
|
88
|
+
/**
|
|
89
|
+
* Set a value in the collection
|
|
90
|
+
* @param key Item key
|
|
91
|
+
* @param value Item value
|
|
92
|
+
*/
|
|
78
93
|
set<V = T>(key: string, value: V): void;
|
|
94
|
+
/**
|
|
95
|
+
* Delete an item from the collection
|
|
96
|
+
* @param key Item key to delete
|
|
97
|
+
*/
|
|
79
98
|
delete(key: string): void;
|
|
99
|
+
/**
|
|
100
|
+
* Clear all items from the collection
|
|
101
|
+
*/
|
|
80
102
|
clear(): void;
|
|
103
|
+
/**
|
|
104
|
+
* Replace the entire collection
|
|
105
|
+
* @param newValue New collection value
|
|
106
|
+
*/
|
|
81
107
|
replace(newValue: Map<string, T>): void;
|
|
82
|
-
|
|
83
|
-
|
|
108
|
+
/**
|
|
109
|
+
* Clean up resources
|
|
110
|
+
*/
|
|
111
|
+
destroy(): void;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Interface for a storage manager
|
|
115
|
+
*/
|
|
116
|
+
export interface IStorageManager<T> {
|
|
117
|
+
/**
|
|
118
|
+
* Load data from storage
|
|
119
|
+
* @returns Promise resolving to stored data or null
|
|
120
|
+
*/
|
|
121
|
+
load(): Promise<T | null>;
|
|
122
|
+
/**
|
|
123
|
+
* Save data to storage
|
|
124
|
+
* @param state Data to save
|
|
125
|
+
*/
|
|
126
|
+
save(state: T): Promise<void>;
|
|
127
|
+
/**
|
|
128
|
+
* Clear data from storage
|
|
129
|
+
*/
|
|
130
|
+
clear(): Promise<void>;
|
|
84
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* Factory function type for creating stores
|
|
134
|
+
*/
|
|
135
|
+
export type StoreFactory = <T extends Record<string, any>>(initialData: T, storage: StorageType, key: string) => IStore<T>;
|
|
136
|
+
/**
|
|
137
|
+
* Factory function type for creating collection stores
|
|
138
|
+
*/
|
|
139
|
+
export type CollectionStoreFactory = <T>(initialData: Map<string, T>, storage: StorageType, key: string) => ICollectionStore<T>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context-object-CVqtbNDv.js","sources":["../src/store/types.ts","../src/store/storage-manager.ts","../src/store/context-collection.ts","../src/store/context-object.ts"],"sourcesContent":["// src/store/types.ts\nimport { BehaviorSubject, Observable } from 'rxjs'\n\n/**\n * Storage types supported by the store\n */\nexport type StorageType = 'memory' | 'local' | 'session' | 'indexeddb'\n\n/**\n * Base store options\n */\nexport interface StoreOptions<T> {\n\t/** Key used for persistent storage */\n\tkey: string\n\t/** Storage type */\n\tstorage: StorageType\n\t/** Initial state */\n\tinitialState: T\n\t/** Enable dev tools */\n\tdevTools?: boolean\n}\n\n/**\n * Action interface for all store actions\n */\nexport interface Action<T = any> {\n\ttype: string\n\tpayload?: T\n}\n\n/**\n * Type-safe action creator\n */\nexport type ActionCreator<P = void, R = void> = P extends void ? () => R : (payload: P) => R\n\n/**\n * Map of action creators with preserved function signatures\n */\nexport type ActionCreatorMap<T> = {\n\t[K in keyof T]: T[K] extends (...args: infer A) => infer R ? (...args: A) => R : never\n}\n\n/**\n * Reducer function type\n */\nexport type Reducer<T> = (state: T, action: Action) => T\n\n/**\n * Middleware function type\n */\nexport type Middleware<T> = (prevState: T, nextState: T, context: { type: string; payload?: any }) => void\n\n/**\n * Selector function type\n */\nexport type Selector<S, R> = (state: S) => R\n\n/**\n * Enhanced store error with type information\n */\nexport class StoreError<T = unknown> extends Error {\n\tconstructor(message: string, public readonly cause?: T, public readonly context?: Record<string, unknown>) {\n\t\tsuper(message)\n\t\tthis.name = 'StoreError'\n\t}\n}\n\n/**\n * Core store interface\n */\nexport interface IStore<T> {\n\t// Value getters with strong return types\n\tvalue: T\n\t$: BehaviorSubject<T>\n\n\t// Methods with improved parameter and return types\n\tset(value: Partial<T>, merge?: boolean): void\n\tclear(): void\n\treplace(newValue: T): void\n\n\t// Ready state with correct type\n\tready: boolean\n\n\t// Error handling\n\terror$: Observable<StoreError | null>\n}\n\n/**\n * Interface for collection stores\n * No longer extends IStore to avoid method signature conflicts\n */\nexport interface ICollectionStore<T> {\n\t// Value getters with strong return types\n\tvalue: Map<string, T>\n\t$: BehaviorSubject<Map<string, T>>\n\n\t// Methods specific to collections\n\tset<V = T>(key: string, value: V): void\n\tdelete(key: string): void\n\tclear(): void\n\treplace(newValue: Map<string, T>): void\n\n\t// Ready state with correct type\n\tready: boolean\n\n\t// Error handling\n\terror$: Observable<StoreError | null>\n}\n","import { StorageType, StoreError } from './types'\n\n/**\n * Storage manager interface with generic typing\n */\nexport interface StorageManager<T> {\n\tload(): Promise<T | null>\n\tsave(state: T): Promise<void>\n\tclear(): Promise<void>\n}\n\n/**\n * Memory storage manager implementation\n */\nexport class MemoryStorageManager<T> implements StorageManager<T> {\n\tprivate data: T | null = null\n\n\tasync load(): Promise<T | null> {\n\t\treturn this.data\n\t}\n\n\tasync save(state: T): Promise<void> {\n\t\tthis.data = state\n\t}\n\n\tasync clear(): Promise<void> {\n\t\tthis.data = null\n\t}\n}\n\n/**\n * Local storage manager implementation\n */\nexport class LocalStorageManager<T> implements StorageManager<T> {\n\tconstructor(private key: string) {}\n\n\tasync load(): Promise<T | null> {\n\t\ttry {\n\t\t\tconst data = localStorage.getItem(this.key)\n\t\t\treturn data ? JSON.parse(data) : null\n\t\t} catch (err) {\n\t\t\tconsole.error(`Failed to load from localStorage (${this.key}):`, err)\n\t\t\treturn null\n\t\t}\n\t}\n\n\tasync save(state: T): Promise<void> {\n\t\ttry {\n\t\t\tlocalStorage.setItem(this.key, JSON.stringify(state))\n\t\t} catch (err) {\n\t\t\tconsole.error(`Failed to save to localStorage (${this.key}):`, err)\n\t\t\tthrow new StoreError<unknown>(`Failed to save to localStorage (${this.key})`, err)\n\t\t}\n\t}\n\n\tasync clear(): Promise<void> {\n\t\tlocalStorage.removeItem(this.key)\n\t}\n}\n\n/**\n * Session storage manager implementation\n */\nexport class SessionStorageManager<T> implements StorageManager<T> {\n\tconstructor(private key: string) {}\n\n\tasync load(): Promise<T | null> {\n\t\ttry {\n\t\t\tconst data = sessionStorage.getItem(this.key)\n\t\t\treturn data ? JSON.parse(data) : null\n\t\t} catch (err) {\n\t\t\tconsole.error(`Failed to load from sessionStorage (${this.key}):`, err)\n\t\t\treturn null\n\t\t}\n\t}\n\n\tasync save(state: T): Promise<void> {\n\t\ttry {\n\t\t\tsessionStorage.setItem(this.key, JSON.stringify(state))\n\t\t} catch (err) {\n\t\t\tconsole.error(`Failed to save to sessionStorage (${this.key}):`, err)\n\t\t\tthrow new StoreError<unknown>(`Failed to save to sessionStorage (${this.key})`, err)\n\t\t}\n\t}\n\n\tasync clear(): Promise<void> {\n\t\tsessionStorage.removeItem(this.key)\n\t}\n}\n\n/**\n * IndexedDB storage manager implementation with better error typing\n */\nexport class IndexedDBStorageManager<T> implements StorageManager<T> {\n\tprivate static DB_NAME = 'StoreDB'\n\tprivate static STORE_NAME = 'states'\n\tprivate static DB_VERSION = 1\n\n\tconstructor(private key: string) {}\n\n\tprivate openDB(): Promise<IDBDatabase> {\n\t\treturn new Promise<IDBDatabase>((resolve, reject) => {\n\t\t\tconst request = indexedDB.open(IndexedDBStorageManager.DB_NAME, IndexedDBStorageManager.DB_VERSION)\n\n\t\t\trequest.onupgradeneeded = () => {\n\t\t\t\tconst db = request.result\n\t\t\t\tif (!db.objectStoreNames.contains(IndexedDBStorageManager.STORE_NAME)) {\n\t\t\t\t\tdb.createObjectStore(IndexedDBStorageManager.STORE_NAME)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\trequest.onsuccess = () => resolve(request.result)\n\t\t\trequest.onerror = () => reject(request.error)\n\t\t})\n\t}\n\n\tasync load(): Promise<T | null> {\n\t\ttry {\n\t\t\tconst db = await this.openDB()\n\t\t\treturn new Promise<T | null>((resolve, reject) => {\n\t\t\t\tconst transaction = db.transaction(IndexedDBStorageManager.STORE_NAME, 'readonly')\n\t\t\t\tconst store = transaction.objectStore(IndexedDBStorageManager.STORE_NAME)\n\t\t\t\tconst request = store.get(this.key)\n\n\t\t\t\trequest.onsuccess = () => {\n\t\t\t\t\tdb.close()\n\t\t\t\t\tresolve(request.result || null)\n\t\t\t\t}\n\n\t\t\t\trequest.onerror = () => {\n\t\t\t\t\tdb.close()\n\t\t\t\t\treject(request.error)\n\t\t\t\t}\n\t\t\t})\n\t\t} catch (err) {\n\t\t\tconsole.error(`Failed to load from IndexedDB (${this.key}):`, err)\n\t\t\treturn null\n\t\t}\n\t}\n\n\tasync save(state: T): Promise<void> {\n\t\ttry {\n\t\t\tconst db = await this.openDB()\n\t\t\treturn new Promise<void>((resolve, reject) => {\n\t\t\t\tconst transaction = db.transaction(IndexedDBStorageManager.STORE_NAME, 'readwrite')\n\t\t\t\tconst store = transaction.objectStore(IndexedDBStorageManager.STORE_NAME)\n\t\t\t\tconst request = store.put(state, this.key)\n\n\t\t\t\trequest.onsuccess = () => {\n\t\t\t\t\tdb.close()\n\t\t\t\t\tresolve()\n\t\t\t\t}\n\n\t\t\t\trequest.onerror = () => {\n\t\t\t\t\tdb.close()\n\t\t\t\t\treject(request.error)\n\t\t\t\t}\n\t\t\t})\n\t\t} catch (err) {\n\t\t\tconsole.error(`Failed to save to IndexedDB (${this.key}):`, err)\n\t\t\tthrow new StoreError<unknown>(`Failed to save to IndexedDB (${this.key})`, err)\n\t\t}\n\t}\n\n\tasync clear(): Promise<void> {\n\t\ttry {\n\t\t\tconst db = await this.openDB()\n\t\t\treturn new Promise<void>((resolve, reject) => {\n\t\t\t\tconst transaction = db.transaction(IndexedDBStorageManager.STORE_NAME, 'readwrite')\n\t\t\t\tconst store = transaction.objectStore(IndexedDBStorageManager.STORE_NAME)\n\t\t\t\tconst request = store.delete(this.key)\n\n\t\t\t\trequest.onsuccess = () => {\n\t\t\t\t\tdb.close()\n\t\t\t\t\tresolve()\n\t\t\t\t}\n\n\t\t\t\trequest.onerror = () => {\n\t\t\t\t\tdb.close()\n\t\t\t\t\treject(request.error)\n\t\t\t\t}\n\t\t\t})\n\t\t} catch (err) {\n\t\t\tconsole.error(`Failed to clear from IndexedDB (${this.key}):`, err)\n\t\t\tthrow new StoreError<unknown>(`Failed to clear from IndexedDB (${this.key})`, err)\n\t\t}\n\t}\n}\n\n/**\n * Factory function to create the appropriate storage manager\n */\nexport function createStorageManager<T>(type: StorageType, key: string): StorageManager<T> {\n\tswitch (type) {\n\t\tcase 'local':\n\t\t\treturn new LocalStorageManager<T>(key)\n\t\tcase 'session':\n\t\t\treturn new SessionStorageManager<T>(key)\n\t\tcase 'indexeddb':\n\t\t\treturn new IndexedDBStorageManager<T>(key)\n\t\tcase 'memory':\n\t\tdefault:\n\t\t\treturn new MemoryStorageManager<T>()\n\t}\n}\n","import { BehaviorSubject, Subject, throttleTime } from 'rxjs'\nimport { ICollectionStore, StorageType, StoreError } from './types'\nimport { createStorageManager, StorageManager } from './storage-manager'\n\n/**\n * Enhanced collection store with better TypeScript support\n */\nexport default class SchmancyCollectionStore<V = any> implements ICollectionStore<V> {\n\tpublic static type = 'collection'\n\n\t// Static map to hold instances\n\tprivate static instances: Map<string, SchmancyCollectionStore<any>> = new Map()\n\n\t// State management\n\tprivate _ready: boolean = false\n\tprivate _destroy$ = new Subject<void>()\n\n\t// Observable streams - modified to match interface requirements\n\tpublic $: BehaviorSubject<Map<string, V>>\n\tpublic error$ = new BehaviorSubject<StoreError | null>(null)\n\n\t// Default value for the store\n\tpublic readonly defaultValue: Map<string, V>\n\n\t// Storage manager\n\tprivate storage: StorageManager<Map<string, V>>\n\n\t/**\n\t * Get ready state\n\t */\n\tpublic get ready(): boolean {\n\t\treturn this._ready\n\t}\n\n\t/**\n\t * Set ready state\n\t */\n\tpublic set ready(value: boolean) {\n\t\tthis._ready = value\n\t\tthis.updateState(this.$.value)\n\t}\n\n\t/**\n\t * Private constructor to enforce singleton pattern\n\t */\n\tprivate constructor(private storageType: StorageType, private key: string, defaultValue: Map<string, V>) {\n\t\tthis.defaultValue = defaultValue\n\t\tthis.$ = new BehaviorSubject<Map<string, V>>(new Map<string, V>())\n\t\tthis.storage = createStorageManager<Map<string, V>>(storageType, key)\n\n\t\t// Initialize from storage\n\t\tthis.initializeFromStorage()\n\n\t\t// Set up persistence\n\t\tthis.setupPersistence()\n\n\t\t// Setup dev tools in development\n\t\tif (import.meta.env.MODE === 'development') {\n\t\t\tthis.setupDevTools()\n\t\t}\n\t}\n\n\t/**\n\t * Static method to get or create an instance with proper typing\n\t */\n\tpublic static getInstance<V = any>(\n\t\tstorage: StorageType,\n\t\tkey: string,\n\t\tdefaultValue: Map<string, V>,\n\t): SchmancyCollectionStore<V> {\n\t\tconst instanceKey = `${storage}:${key}`\n\t\tif (!this.instances.has(instanceKey)) {\n\t\t\tthis.instances.set(instanceKey, new SchmancyCollectionStore<V>(storage, key, defaultValue))\n\t\t}\n\t\treturn this.instances.get(instanceKey) as SchmancyCollectionStore<V>\n\t}\n\n\t/**\n\t * Get the current value\n\t */\n\tpublic get value(): Map<string, V> {\n\t\treturn this.$.getValue()\n\t}\n\n\t/**\n\t * Set a value in the collection with proper typing\n\t */\n\tpublic set<T = V>(key: string, value: T): void {\n\t\ttry {\n\t\t\tconst currentValue = new Map(this.value)\n\t\t\tcurrentValue.set(key, value as unknown as V)\n\t\t\tthis.updateState(currentValue)\n\t\t\tthis.error$.next(null) // Clear any previous errors\n\t\t} catch (err) {\n\t\t\tconst error = new StoreError<unknown>(`Error setting value for key ${key} in ${this.key}`, err)\n\t\t\tthis.error$.next(error)\n\t\t\tconsole.error(error)\n\t\t}\n\t}\n\n\t/**\n\t * Delete a value from the collection\n\t */\n\tpublic delete(key: string): void {\n\t\ttry {\n\t\t\tconst currentValue = new Map(this.value)\n\t\t\tcurrentValue.delete(key)\n\t\t\tthis.updateState(currentValue)\n\t\t\tthis.error$.next(null) // Clear any previous errors\n\t\t} catch (err) {\n\t\t\tconst error = new StoreError<unknown>(`Error deleting key ${key} from ${this.key}`, err)\n\t\t\tthis.error$.next(error)\n\t\t\tconsole.error(error)\n\t\t}\n\t}\n\n\t/**\n\t * Clear the collection\n\t */\n\tpublic clear(): void {\n\t\tthis.updateState(new Map<string, V>())\n\t}\n\n\tpublic replace(newValue: Map<string, V>): void {\n\t\tthis.updateState(newValue)\n\t}\n\n\t/**\n\t * Update the state with error handling\n\t */\n\tprivate updateState(newValue: Map<string, V>): void {\n\t\ttry {\n\t\t\tthis.$.next(newValue)\n\t\t} catch (err) {\n\t\t\tconst error = new StoreError<unknown>(`Error updating state in ${this.key}`, err)\n\t\t\tthis.error$.next(error)\n\t\t\tconsole.error(error)\n\t\t}\n\t}\n\n\t/**\n\t * Initialize from persistent storage\n\t */\n\tprivate async initializeFromStorage(): Promise<void> {\n\t\tif (this.storageType === 'local' || this.storageType === 'session') {\n\t\t\ttry {\n\t\t\t\tconst storedValue = await this.storage.load()\n\t\t\t\tif (storedValue) {\n\t\t\t\t\tthis.updateState(storedValue)\n\t\t\t\t}\n\t\t\t\tthis._ready = true\n\t\t\t} catch (err) {\n\t\t\t\tconst error = new StoreError<unknown>(`Error loading from ${this.storageType} storage for ${this.key}`, err)\n\t\t\t\tthis.error$.next(error)\n\t\t\t\tconsole.error(error)\n\t\t\t\tthis._ready = true // Mark as ready even if loading fails\n\t\t\t}\n\t\t} else if (this.storageType === 'indexeddb') {\n\t\t\tthis.loadFromIndexedDB()\n\t\t} else {\n\t\t\t// Memory storage doesn't need loading\n\t\t\tthis._ready = true\n\t\t}\n\t}\n\n\t/**\n\t * Load data from IndexedDB with better typing\n\t */\n\tprivate async loadFromIndexedDB(): Promise<void> {\n\t\ttry {\n\t\t\tconst result = await this.storage.load()\n\t\t\tthis.updateState(result || new Map<string, V>())\n\t\t\tthis._ready = true\n\t\t} catch (err) {\n\t\t\tconst error = new StoreError<unknown>(`Error loading from IndexedDB for ${this.key}`, err)\n\t\t\tthis.error$.next(error)\n\t\t\tconsole.error(error)\n\t\t\tthis._ready = true // Mark as ready even if loading fails\n\t\t}\n\t}\n\n\t/**\n\t * Set up persistence to storage\n\t */\n\tprivate setupPersistence(): void {\n\t\tif (this.storageType === 'memory') return\n\n\t\tthis.$.pipe(throttleTime(100, undefined, { leading: true, trailing: true })).subscribe(currentValue => {\n\t\t\tthis.storage.save(currentValue).catch(err => {\n\t\t\t\tconst error = new StoreError<unknown>(`Error saving to ${this.storageType} storage for ${this.key}`, err)\n\t\t\t\tthis.error$.next(error)\n\t\t\t\tconsole.error(error)\n\t\t\t})\n\t\t})\n\t}\n\n\t/**\n\t * Setup development tools for debugging\n\t */\n\tprivate setupDevTools(): void {\n\t\tif (typeof window !== 'undefined') {\n\t\t\t// Add to global store registry\n\t\t\t;(window as any).__STORES__ = (window as any).__STORES__ || {}\n\t\t\t;(window as any).__STORES__[this.key] = {\n\t\t\t\tgetState: () => this.value,\n\t\t\t\tset: this.set.bind(this),\n\t\t\t\tdelete: this.delete.bind(this),\n\t\t\t\tclear: this.clear.bind(this),\n\t\t\t\tsubscribe: (callback: (state: Map<string, V>) => void) => {\n\t\t\t\t\tconst subscription = this.$.subscribe(callback)\n\t\t\t\t\treturn () => subscription.unsubscribe()\n\t\t\t\t},\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Clean up resources\n\t */\n\tpublic destroy(): void {\n\t\tthis._destroy$.next()\n\t\tthis._destroy$.complete()\n\t\tthis.$.complete()\n\t\tthis.error$.complete()\n\t}\n}\n","import { BehaviorSubject, Subject } from 'rxjs'\nimport { createStorageManager, StorageManager } from './storage-manager'\nimport { IStore, StorageType, StoreError } from './types'\n\n/**\n * Enhanced store object with better TypeScript support\n */\nexport class SchmancyStoreObject<T extends Record<string, any>> implements IStore<T> {\n\tpublic static type = 'object'\n\n\t// Static map to hold instances with proper typing\n\tprivate static instances: Map<string, SchmancyStoreObject<any>> = new Map()\n\n\t// State tracking\n\tprivate _ready: boolean = false\n\tprivate _destroy$ = new Subject<void>()\n\n\t// Observable streams\n\tpublic $: BehaviorSubject<T>\n\tpublic error$ = new BehaviorSubject<StoreError | null>(null)\n\n\t// Default value for the store\n\tpublic readonly defaultValue: T\n\n\t// Storage manager\n\tprivate storage: StorageManager<T>\n\n\t/**\n\t * Get store ready state\n\t */\n\tpublic get ready(): boolean {\n\t\treturn this._ready\n\t}\n\n\t/**\n\t * Set store ready state\n\t */\n\tpublic set ready(value: boolean) {\n\t\tthis._ready = value\n\t\tthis.updateState(this.$.value)\n\t}\n\n\t/**\n\t * Private constructor to enforce singleton pattern\n\t */\n\tprivate constructor(private storageType: StorageType, private key: string, defaultValue: T) {\n\t\tthis.defaultValue = defaultValue\n\t\tthis.$ = new BehaviorSubject<T>(defaultValue)\n\t\tthis.storage = createStorageManager<T>(storageType, key)\n\n\t\t// Initialize from storage\n\t\tthis.initializeFromStorage()\n\n\t\t// Setup dev tools in development\n\t\tif (import.meta.env.MODE === 'development') {\n\t\t\tthis.setupDevTools()\n\t\t}\n\t}\n\n\t/**\n\t * Static method to get or create an instance with strong typing\n\t */\n\tpublic static getInstance<T extends Record<string, any>>(\n\t\tstorage: StorageType,\n\t\tkey: string,\n\t\tdefaultValue: T,\n\t): SchmancyStoreObject<T> {\n\t\tconst instanceKey = `${storage}:${key}`\n\t\tif (!this.instances.has(instanceKey)) {\n\t\t\tthis.instances.set(instanceKey, new SchmancyStoreObject<T>(storage, key, defaultValue))\n\t\t}\n\t\treturn this.instances.get(instanceKey) as SchmancyStoreObject<T>\n\t}\n\n\t/**\n\t * Get the current value from the store\n\t */\n\tpublic get value(): T {\n\t\treturn this.$.getValue()\n\t}\n\n\t/**\n\t * Set state with proper typing\n\t */\n\tpublic set(value: Partial<T>, merge: boolean = true): void {\n\t\ttry {\n\t\t\tthis.updateState(merge ? { ...this.value, ...value } : (value as T))\n\t\t\tthis.error$.next(null) // Clear any previous errors\n\t\t} catch (err) {\n\t\t\tconst error = new StoreError<unknown>(`Error updating store: ${this.key}`, err, { value, merge })\n\t\t\tthis.error$.next(error)\n\t\t\tconsole.error(error)\n\t\t}\n\t}\n\n\t/**\n\t * Reset the store to its default value\n\t */\n\tpublic clear(): void {\n\t\tthis.set(this.defaultValue, false)\n\t}\n\n\t/**\n\t * Replace the store with a new value\n\t */\n\tpublic replace(newValue: T): void {\n\t\tthis.updateState(newValue)\n\t}\n\n\t/**\n\t * Delete a specific key from the store with type checking\n\t */\n\tpublic delete<K extends keyof T>(key: K): void {\n\t\tconst value = { ...this.value }\n\t\tdelete value[key]\n\t\tthis.updateState(value)\n\t}\n\n\t/**\n\t * Update the state with proper error handling\n\t */\n\tprivate updateState(newValue: T): void {\n\t\ttry {\n\t\t\tthis.$.next(newValue)\n\n\t\t\t// Persist to storage\n\t\t\tif (this.storageType !== 'memory') {\n\t\t\t\tthis.storage.save(newValue).catch(err => {\n\t\t\t\t\tconsole.error(`Error saving to ${this.storageType} storage:`, err)\n\t\t\t\t})\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tconst error = new StoreError<unknown>(`Error updating state in ${this.key}`, err)\n\t\t\tthis.error$.next(error)\n\t\t\tconsole.error(error)\n\t\t}\n\t}\n\n\t/**\n\t * Initialize the store from persistent storage\n\t */\n\tprivate async initializeFromStorage(): Promise<void> {\n\t\ttry {\n\t\t\tconst storedValue = await this.storage.load()\n\t\t\tif (storedValue) {\n\t\t\t\tthis.updateState({ ...this.defaultValue, ...storedValue })\n\t\t\t}\n\t\t\tthis._ready = true\n\t\t} catch (err) {\n\t\t\tconst error = new StoreError<unknown>(`Error loading from ${this.storageType} storage for ${this.key}`, err)\n\t\t\tthis.error$.next(error)\n\t\t\tconsole.error(error)\n\t\t\tthis._ready = true // Mark as ready even if loading fails\n\t\t}\n\t}\n\n\t/**\n\t * Setup development tools for debugging\n\t */\n\tprivate setupDevTools(): void {\n\t\tif (typeof window !== 'undefined') {\n\t\t\t// Add to global store registry\n\t\t\t;(window as any).__STORES__ = (window as any).__STORES__ || {}\n\t\t\t;(window as any).__STORES__[this.key] = {\n\t\t\t\tgetState: () => this.value,\n\t\t\t\tset: this.set.bind(this),\n\t\t\t\tdelete: this.delete.bind(this),\n\t\t\t\tclear: this.clear.bind(this),\n\t\t\t\tsubscribe: (callback: (state: T) => void) => {\n\t\t\t\t\tconst subscription = this.$.subscribe(callback)\n\t\t\t\t\treturn () => subscription.unsubscribe()\n\t\t\t\t},\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Clean up resources\n\t */\n\tpublic destroy(): void {\n\t\tthis._destroy$.next()\n\t\tthis._destroy$.complete()\n\t\tthis.$.complete()\n\t\tthis.error$.complete()\n\t}\n}\n"],"names":["StoreError","Error","message","cause","context","super","this","name","MemoryStorageManager","constructor","data","state","LocalStorageManager","key","load","localStorage","getItem","JSON","parse","save","setItem","stringify","err","clear","removeItem","SessionStorageManager","sessionStorage","IndexedDBStorageManager","Promise","resolve","reject","request","indexedDB","open","DB_NAME","DB_VERSION","onupgradeneeded","db","result","objectStoreNames","contains","STORE_NAME","createObjectStore","onsuccess","onerror","error","openDB","transaction","objectStore","get","close","put","delete","_a","createStorageManager","type","SchmancyCollectionStore","storageType","defaultValue","_ready","_destroy$","Subject","error$","BehaviorSubject","$","Map","storage","initializeFromStorage","setupPersistence","ready","value","updateState","instanceKey","instances","has","set","getValue","currentValue","next","newValue","storedValue","loadFromIndexedDB","pipe","throttleTime","leading","trailing","subscribe","catch","window","__STORES__","getState","bind","callback","subscription","unsubscribe","destroy","complete","_c","SchmancyStoreObject","merge","setupDevTools","_l"],"mappings":";AA4DO,MAAMA,UAAgCC,MAC5C;AAAA,EA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AA,GAAiBsB,EAE7C1E,CAAAA,GAAAA,KAAKqD;aACGrC,GAAAA;AACF,YAAAuB,IAAQ,IAAI7C,EAAoB,sBAAsBM,KAAKmD,WAAAA,gBAA2BnD,KAAKO,GAAAA,IAAOS;AACnGhB,WAAAwD,OAAOgB,KAAKjC,CAAAA,GAEjBvC,KAAKqD,SAAS;AAAA,IAAA;AAAA,EACf;AAAA,EAMO,gBAAAyC;AACe,IAAXZ,OAAAA,SAAW,QAEJA,OAAAC,aAAcD,OAAeC,cAAc,CAAC,GAC5CD,OAAAC,WAAWnF,KAAKO,OAAO,EACvC6E,UAAU,MAAMpF,KAAKgE,OACrBK,KAAKrE,KAAKqE,IAAIgB,KAAKrF,IACnB8C,GAAAA,QAAQ9C,KAAK8C,OAAOuC,KAAKrF,IAAAA,GACzBiB,OAAOjB,KAAKiB,MAAMoE,KAAKrF,IAAAA,GACvBgF,WAAYM,OAAAA;AACX,YAAMC,IAAevF,KAAK0D,EAAEsB,UAAUM,CAC/B;AAAA,aAAA,MAAMC,EAAaC,YAAY;AAAA,IAAA,EAAA;AAAA,EAGzC;AAAA,EAMM;AACNxF,SAAKsD,UAAUkB,KACfxE,GAAAA,KAAKsD,UAAUoC,SAAAA,GACf1F,KAAK0D,EAAEgC,YACP1F,KAAKwD,OAAOkC,SAAS;AAAA,EAAA;AAAA;AA/KtB1F,EAAciD,OAAO,UAGNjD,EAAAmE,gCAAuDR;AAJhE,IAAMiC,IAANG;"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";const o=require("rxjs");class i extends Error{constructor(t,e,s){super(t),this.cause=e,this.context=s,this.name="StoreError"}}class g{constructor(){this.data=null}async load(){return this.data}async save(t){this.data=t}async clear(){this.data=null}}class w{constructor(t){this.key=t}async load(){try{const t=localStorage.getItem(this.key);return t?JSON.parse(t):null}catch{return null}}async save(t){try{localStorage.setItem(this.key,JSON.stringify(t))}catch(e){throw new i(`Failed to save to localStorage (${this.key})`,e)}}async clear(){localStorage.removeItem(this.key)}}class p{constructor(t){this.key=t}async load(){try{const t=sessionStorage.getItem(this.key);return t?JSON.parse(t):null}catch{return null}}async save(t){try{sessionStorage.setItem(this.key,JSON.stringify(t))}catch(e){throw new i(`Failed to save to sessionStorage (${this.key})`,e)}}async clear(){sessionStorage.removeItem(this.key)}}const a=class a{constructor(t){this.key=t}openDB(){return new Promise((t,e)=>{const s=indexedDB.open(a.DB_NAME,a.DB_VERSION);s.onupgradeneeded=()=>{const r=s.result;r.objectStoreNames.contains(a.STORE_NAME)||r.createObjectStore(a.STORE_NAME)},s.onsuccess=()=>t(s.result),s.onerror=()=>e(s.error)})}async load(){try{const t=await this.openDB();return new Promise((e,s)=>{const r=t.transaction(a.STORE_NAME,"readonly").objectStore(a.STORE_NAME).get(this.key);r.onsuccess=()=>{t.close(),e(r.result||null)},r.onerror=()=>{t.close(),s(r.error)}})}catch{return null}}async save(t){try{const e=await this.openDB();return new Promise((s,r)=>{const d=e.transaction(a.STORE_NAME,"readwrite").objectStore(a.STORE_NAME).put(t,this.key);d.onsuccess=()=>{e.close(),s()},d.onerror=()=>{e.close(),r(d.error)}})}catch(e){throw new i(`Failed to save to IndexedDB (${this.key})`,e)}}async clear(){try{const t=await this.openDB();return new Promise((e,s)=>{const r=t.transaction(a.STORE_NAME,"readwrite").objectStore(a.STORE_NAME).delete(this.key);r.onsuccess=()=>{t.close(),e()},r.onerror=()=>{t.close(),s(r.error)}})}catch(t){throw new i(`Failed to clear from IndexedDB (${this.key})`,t)}}};a.DB_NAME="StoreDB",a.STORE_NAME="states",a.DB_VERSION=1;let l=a;function S(n,t){switch(n){case"local":return new w(t);case"session":return new p(t);case"indexeddb":return new l(t);default:return new g}}const c=class c{constructor(t,e,s){this.storageType=t,this.key=e,this._ready=!1,this._destroy$=new o.Subject,this.error$=new o.BehaviorSubject(null),this.defaultValue=s,this.$=new o.BehaviorSubject(new Map),this.storage=S(t,e),this.initializeFromStorage(),this.setupPersistence()}get ready(){return this._ready}set ready(t){this._ready=t,this.updateState(this.$.value)}static getInstance(t,e,s){const r=`${t}:${e}`;return this.instances.has(r)||this.instances.set(r,new c(t,e,s)),this.instances.get(r)}get value(){return this.$.getValue()}set(t,e){try{const s=new Map(this.value);s.set(t,e),this.updateState(s),this.error$.next(null)}catch(s){const r=new i(`Error setting value for key ${t} in ${this.key}`,s);this.error$.next(r)}}delete(t){try{const e=new Map(this.value);e.delete(t),this.updateState(e),this.error$.next(null)}catch(e){const s=new i(`Error deleting key ${t} from ${this.key}`,e);this.error$.next(s)}}clear(){this.updateState(new Map)}replace(t){this.updateState(t)}updateState(t){try{this.$.next(t)}catch(e){const s=new i(`Error updating state in ${this.key}`,e);this.error$.next(s)}}async initializeFromStorage(){if(this.storageType==="local"||this.storageType==="session")try{const t=await this.storage.load();t&&this.updateState(t),this._ready=!0}catch(t){const e=new i(`Error loading from ${this.storageType} storage for ${this.key}`,t);this.error$.next(e),this._ready=!0}else this.storageType==="indexeddb"?this.loadFromIndexedDB():this._ready=!0}async loadFromIndexedDB(){try{const t=await this.storage.load();this.updateState(t||new Map),this._ready=!0}catch(t){const e=new i(`Error loading from IndexedDB for ${this.key}`,t);this.error$.next(e),this._ready=!0}}setupPersistence(){this.storageType!=="memory"&&this.$.pipe(o.throttleTime(100,void 0,{leading:!0,trailing:!0})).subscribe(t=>{this.storage.save(t).catch(e=>{const s=new i(`Error saving to ${this.storageType} storage for ${this.key}`,e);this.error$.next(s)})})}setupDevTools(){typeof window<"u"&&(window.__STORES__=window.__STORES__||{},window.__STORES__[this.key]={getState:()=>this.value,set:this.set.bind(this),delete:this.delete.bind(this),clear:this.clear.bind(this),subscribe:t=>{const e=this.$.subscribe(t);return()=>e.unsubscribe()}})}destroy(){this._destroy$.next(),this._destroy$.complete(),this.$.complete(),this.error$.complete()}};c.type="collection",c.instances=new Map;let u=c;const h=class h{constructor(t,e,s){this.storageType=t,this.key=e,this._ready=!1,this._destroy$=new o.Subject,this.error$=new o.BehaviorSubject(null),this.defaultValue=s,this.$=new o.BehaviorSubject(s),this.storage=S(t,e),this.initializeFromStorage()}get ready(){return this._ready}set ready(t){this._ready=t,this.updateState(this.$.value)}static getInstance(t,e,s){const r=`${t}:${e}`;return this.instances.has(r)||this.instances.set(r,new h(t,e,s)),this.instances.get(r)}get value(){return this.$.getValue()}set(t,e=!0){try{this.updateState(e?{...this.value,...t}:t),this.error$.next(null)}catch(s){const r=new i(`Error updating store: ${this.key}`,s,{value:t,merge:e});this.error$.next(r)}}clear(){this.set(this.defaultValue,!1)}replace(t){this.updateState(t)}delete(t){const e={...this.value};delete e[t],this.updateState(e)}updateState(t){try{this.$.next(t),this.storageType!=="memory"&&this.storage.save(t).catch(e=>{})}catch(e){const s=new i(`Error updating state in ${this.key}`,e);this.error$.next(s)}}async initializeFromStorage(){try{const t=await this.storage.load();t&&this.updateState({...this.defaultValue,...t}),this._ready=!0}catch(t){const e=new i(`Error loading from ${this.storageType} storage for ${this.key}`,t);this.error$.next(e),this._ready=!0}}setupDevTools(){typeof window<"u"&&(window.__STORES__=window.__STORES__||{},window.__STORES__[this.key]={getState:()=>this.value,set:this.set.bind(this),delete:this.delete.bind(this),clear:this.clear.bind(this),subscribe:t=>{const e=this.$.subscribe(t);return()=>e.unsubscribe()}})}destroy(){this._destroy$.next(),this._destroy$.complete(),this.$.complete(),this.error$.complete()}};h.type="object",h.instances=new Map;let y=h;exports.IndexedDBStorageManager=l,exports.LocalStorageManager=w,exports.MemoryStorageManager=g,exports.SchmancyCollectionStore=u,exports.SchmancyStoreObject=y,exports.SessionStorageManager=p,exports.StoreError=i,exports.createStorageManager=S;
|
|
2
|
-
//# sourceMappingURL=context-object-CgZ6F8E9.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context-object-CgZ6F8E9.cjs","sources":["../src/store/types.ts","../src/store/storage-manager.ts","../src/store/context-collection.ts","../src/store/context-object.ts"],"sourcesContent":["// src/store/types.ts\nimport { BehaviorSubject, Observable } from 'rxjs'\n\n/**\n * Storage types supported by the store\n */\nexport type StorageType = 'memory' | 'local' | 'session' | 'indexeddb'\n\n/**\n * Base store options\n */\nexport interface StoreOptions<T> {\n\t/** Key used for persistent storage */\n\tkey: string\n\t/** Storage type */\n\tstorage: StorageType\n\t/** Initial state */\n\tinitialState: T\n\t/** Enable dev tools */\n\tdevTools?: boolean\n}\n\n/**\n * Action interface for all store actions\n */\nexport interface Action<T = any> {\n\ttype: string\n\tpayload?: T\n}\n\n/**\n * Type-safe action creator\n */\nexport type ActionCreator<P = void, R = void> = P extends void ? () => R : (payload: P) => R\n\n/**\n * Map of action creators with preserved function signatures\n */\nexport type ActionCreatorMap<T> = {\n\t[K in keyof T]: T[K] extends (...args: infer A) => infer R ? (...args: A) => R : never\n}\n\n/**\n * Reducer function type\n */\nexport type Reducer<T> = (state: T, action: Action) => T\n\n/**\n * Middleware function type\n */\nexport type Middleware<T> = (prevState: T, nextState: T, context: { type: string; payload?: any }) => void\n\n/**\n * Selector function type\n */\nexport type Selector<S, R> = (state: S) => R\n\n/**\n * Enhanced store error with type information\n */\nexport class StoreError<T = unknown> extends Error {\n\tconstructor(message: string, public readonly cause?: T, public readonly context?: Record<string, unknown>) {\n\t\tsuper(message)\n\t\tthis.name = 'StoreError'\n\t}\n}\n\n/**\n * Core store interface\n */\nexport interface IStore<T> {\n\t// Value getters with strong return types\n\tvalue: T\n\t$: BehaviorSubject<T>\n\n\t// Methods with improved parameter and return types\n\tset(value: Partial<T>, merge?: boolean): void\n\tclear(): void\n\treplace(newValue: T): void\n\n\t// Ready state with correct type\n\tready: boolean\n\n\t// Error handling\n\terror$: Observable<StoreError | null>\n}\n\n/**\n * Interface for collection stores\n * No longer extends IStore to avoid method signature conflicts\n */\nexport interface ICollectionStore<T> {\n\t// Value getters with strong return types\n\tvalue: Map<string, T>\n\t$: BehaviorSubject<Map<string, T>>\n\n\t// Methods specific to collections\n\tset<V = T>(key: string, value: V): void\n\tdelete(key: string): void\n\tclear(): void\n\treplace(newValue: Map<string, T>): void\n\n\t// Ready state with correct type\n\tready: boolean\n\n\t// Error handling\n\terror$: Observable<StoreError | null>\n}\n","import { StorageType, StoreError } from './types'\n\n/**\n * Storage manager interface with generic typing\n */\nexport interface StorageManager<T> {\n\tload(): Promise<T | null>\n\tsave(state: T): Promise<void>\n\tclear(): Promise<void>\n}\n\n/**\n * Memory storage manager implementation\n */\nexport class MemoryStorageManager<T> implements StorageManager<T> {\n\tprivate data: T | null = null\n\n\tasync load(): Promise<T | null> {\n\t\treturn this.data\n\t}\n\n\tasync save(state: T): Promise<void> {\n\t\tthis.data = state\n\t}\n\n\tasync clear(): Promise<void> {\n\t\tthis.data = null\n\t}\n}\n\n/**\n * Local storage manager implementation\n */\nexport class LocalStorageManager<T> implements StorageManager<T> {\n\tconstructor(private key: string) {}\n\n\tasync load(): Promise<T | null> {\n\t\ttry {\n\t\t\tconst data = localStorage.getItem(this.key)\n\t\t\treturn data ? JSON.parse(data) : null\n\t\t} catch (err) {\n\t\t\tconsole.error(`Failed to load from localStorage (${this.key}):`, err)\n\t\t\treturn null\n\t\t}\n\t}\n\n\tasync save(state: T): Promise<void> {\n\t\ttry {\n\t\t\tlocalStorage.setItem(this.key, JSON.stringify(state))\n\t\t} catch (err) {\n\t\t\tconsole.error(`Failed to save to localStorage (${this.key}):`, err)\n\t\t\tthrow new StoreError<unknown>(`Failed to save to localStorage (${this.key})`, err)\n\t\t}\n\t}\n\n\tasync clear(): Promise<void> {\n\t\tlocalStorage.removeItem(this.key)\n\t}\n}\n\n/**\n * Session storage manager implementation\n */\nexport class SessionStorageManager<T> implements StorageManager<T> {\n\tconstructor(private key: string) {}\n\n\tasync load(): Promise<T | null> {\n\t\ttry {\n\t\t\tconst data = sessionStorage.getItem(this.key)\n\t\t\treturn data ? JSON.parse(data) : null\n\t\t} catch (err) {\n\t\t\tconsole.error(`Failed to load from sessionStorage (${this.key}):`, err)\n\t\t\treturn null\n\t\t}\n\t}\n\n\tasync save(state: T): Promise<void> {\n\t\ttry {\n\t\t\tsessionStorage.setItem(this.key, JSON.stringify(state))\n\t\t} catch (err) {\n\t\t\tconsole.error(`Failed to save to sessionStorage (${this.key}):`, err)\n\t\t\tthrow new StoreError<unknown>(`Failed to save to sessionStorage (${this.key})`, err)\n\t\t}\n\t}\n\n\tasync clear(): Promise<void> {\n\t\tsessionStorage.removeItem(this.key)\n\t}\n}\n\n/**\n * IndexedDB storage manager implementation with better error typing\n */\nexport class IndexedDBStorageManager<T> implements StorageManager<T> {\n\tprivate static DB_NAME = 'StoreDB'\n\tprivate static STORE_NAME = 'states'\n\tprivate static DB_VERSION = 1\n\n\tconstructor(private key: string) {}\n\n\tprivate openDB(): Promise<IDBDatabase> {\n\t\treturn new Promise<IDBDatabase>((resolve, reject) => {\n\t\t\tconst request = indexedDB.open(IndexedDBStorageManager.DB_NAME, IndexedDBStorageManager.DB_VERSION)\n\n\t\t\trequest.onupgradeneeded = () => {\n\t\t\t\tconst db = request.result\n\t\t\t\tif (!db.objectStoreNames.contains(IndexedDBStorageManager.STORE_NAME)) {\n\t\t\t\t\tdb.createObjectStore(IndexedDBStorageManager.STORE_NAME)\n\t\t\t\t}\n\t\t\t}\n\n\t\t\trequest.onsuccess = () => resolve(request.result)\n\t\t\trequest.onerror = () => reject(request.error)\n\t\t})\n\t}\n\n\tasync load(): Promise<T | null> {\n\t\ttry {\n\t\t\tconst db = await this.openDB()\n\t\t\treturn new Promise<T | null>((resolve, reject) => {\n\t\t\t\tconst transaction = db.transaction(IndexedDBStorageManager.STORE_NAME, 'readonly')\n\t\t\t\tconst store = transaction.objectStore(IndexedDBStorageManager.STORE_NAME)\n\t\t\t\tconst request = store.get(this.key)\n\n\t\t\t\trequest.onsuccess = () => {\n\t\t\t\t\tdb.close()\n\t\t\t\t\tresolve(request.result || null)\n\t\t\t\t}\n\n\t\t\t\trequest.onerror = () => {\n\t\t\t\t\tdb.close()\n\t\t\t\t\treject(request.error)\n\t\t\t\t}\n\t\t\t})\n\t\t} catch (err) {\n\t\t\tconsole.error(`Failed to load from IndexedDB (${this.key}):`, err)\n\t\t\treturn null\n\t\t}\n\t}\n\n\tasync save(state: T): Promise<void> {\n\t\ttry {\n\t\t\tconst db = await this.openDB()\n\t\t\treturn new Promise<void>((resolve, reject) => {\n\t\t\t\tconst transaction = db.transaction(IndexedDBStorageManager.STORE_NAME, 'readwrite')\n\t\t\t\tconst store = transaction.objectStore(IndexedDBStorageManager.STORE_NAME)\n\t\t\t\tconst request = store.put(state, this.key)\n\n\t\t\t\trequest.onsuccess = () => {\n\t\t\t\t\tdb.close()\n\t\t\t\t\tresolve()\n\t\t\t\t}\n\n\t\t\t\trequest.onerror = () => {\n\t\t\t\t\tdb.close()\n\t\t\t\t\treject(request.error)\n\t\t\t\t}\n\t\t\t})\n\t\t} catch (err) {\n\t\t\tconsole.error(`Failed to save to IndexedDB (${this.key}):`, err)\n\t\t\tthrow new StoreError<unknown>(`Failed to save to IndexedDB (${this.key})`, err)\n\t\t}\n\t}\n\n\tasync clear(): Promise<void> {\n\t\ttry {\n\t\t\tconst db = await this.openDB()\n\t\t\treturn new Promise<void>((resolve, reject) => {\n\t\t\t\tconst transaction = db.transaction(IndexedDBStorageManager.STORE_NAME, 'readwrite')\n\t\t\t\tconst store = transaction.objectStore(IndexedDBStorageManager.STORE_NAME)\n\t\t\t\tconst request = store.delete(this.key)\n\n\t\t\t\trequest.onsuccess = () => {\n\t\t\t\t\tdb.close()\n\t\t\t\t\tresolve()\n\t\t\t\t}\n\n\t\t\t\trequest.onerror = () => {\n\t\t\t\t\tdb.close()\n\t\t\t\t\treject(request.error)\n\t\t\t\t}\n\t\t\t})\n\t\t} catch (err) {\n\t\t\tconsole.error(`Failed to clear from IndexedDB (${this.key}):`, err)\n\t\t\tthrow new StoreError<unknown>(`Failed to clear from IndexedDB (${this.key})`, err)\n\t\t}\n\t}\n}\n\n/**\n * Factory function to create the appropriate storage manager\n */\nexport function createStorageManager<T>(type: StorageType, key: string): StorageManager<T> {\n\tswitch (type) {\n\t\tcase 'local':\n\t\t\treturn new LocalStorageManager<T>(key)\n\t\tcase 'session':\n\t\t\treturn new SessionStorageManager<T>(key)\n\t\tcase 'indexeddb':\n\t\t\treturn new IndexedDBStorageManager<T>(key)\n\t\tcase 'memory':\n\t\tdefault:\n\t\t\treturn new MemoryStorageManager<T>()\n\t}\n}\n","import { BehaviorSubject, Subject, throttleTime } from 'rxjs'\nimport { ICollectionStore, StorageType, StoreError } from './types'\nimport { createStorageManager, StorageManager } from './storage-manager'\n\n/**\n * Enhanced collection store with better TypeScript support\n */\nexport default class SchmancyCollectionStore<V = any> implements ICollectionStore<V> {\n\tpublic static type = 'collection'\n\n\t// Static map to hold instances\n\tprivate static instances: Map<string, SchmancyCollectionStore<any>> = new Map()\n\n\t// State management\n\tprivate _ready: boolean = false\n\tprivate _destroy$ = new Subject<void>()\n\n\t// Observable streams - modified to match interface requirements\n\tpublic $: BehaviorSubject<Map<string, V>>\n\tpublic error$ = new BehaviorSubject<StoreError | null>(null)\n\n\t// Default value for the store\n\tpublic readonly defaultValue: Map<string, V>\n\n\t// Storage manager\n\tprivate storage: StorageManager<Map<string, V>>\n\n\t/**\n\t * Get ready state\n\t */\n\tpublic get ready(): boolean {\n\t\treturn this._ready\n\t}\n\n\t/**\n\t * Set ready state\n\t */\n\tpublic set ready(value: boolean) {\n\t\tthis._ready = value\n\t\tthis.updateState(this.$.value)\n\t}\n\n\t/**\n\t * Private constructor to enforce singleton pattern\n\t */\n\tprivate constructor(private storageType: StorageType, private key: string, defaultValue: Map<string, V>) {\n\t\tthis.defaultValue = defaultValue\n\t\tthis.$ = new BehaviorSubject<Map<string, V>>(new Map<string, V>())\n\t\tthis.storage = createStorageManager<Map<string, V>>(storageType, key)\n\n\t\t// Initialize from storage\n\t\tthis.initializeFromStorage()\n\n\t\t// Set up persistence\n\t\tthis.setupPersistence()\n\n\t\t// Setup dev tools in development\n\t\tif (import.meta.env.MODE === 'development') {\n\t\t\tthis.setupDevTools()\n\t\t}\n\t}\n\n\t/**\n\t * Static method to get or create an instance with proper typing\n\t */\n\tpublic static getInstance<V = any>(\n\t\tstorage: StorageType,\n\t\tkey: string,\n\t\tdefaultValue: Map<string, V>,\n\t): SchmancyCollectionStore<V> {\n\t\tconst instanceKey = `${storage}:${key}`\n\t\tif (!this.instances.has(instanceKey)) {\n\t\t\tthis.instances.set(instanceKey, new SchmancyCollectionStore<V>(storage, key, defaultValue))\n\t\t}\n\t\treturn this.instances.get(instanceKey) as SchmancyCollectionStore<V>\n\t}\n\n\t/**\n\t * Get the current value\n\t */\n\tpublic get value(): Map<string, V> {\n\t\treturn this.$.getValue()\n\t}\n\n\t/**\n\t * Set a value in the collection with proper typing\n\t */\n\tpublic set<T = V>(key: string, value: T): void {\n\t\ttry {\n\t\t\tconst currentValue = new Map(this.value)\n\t\t\tcurrentValue.set(key, value as unknown as V)\n\t\t\tthis.updateState(currentValue)\n\t\t\tthis.error$.next(null) // Clear any previous errors\n\t\t} catch (err) {\n\t\t\tconst error = new StoreError<unknown>(`Error setting value for key ${key} in ${this.key}`, err)\n\t\t\tthis.error$.next(error)\n\t\t\tconsole.error(error)\n\t\t}\n\t}\n\n\t/**\n\t * Delete a value from the collection\n\t */\n\tpublic delete(key: string): void {\n\t\ttry {\n\t\t\tconst currentValue = new Map(this.value)\n\t\t\tcurrentValue.delete(key)\n\t\t\tthis.updateState(currentValue)\n\t\t\tthis.error$.next(null) // Clear any previous errors\n\t\t} catch (err) {\n\t\t\tconst error = new StoreError<unknown>(`Error deleting key ${key} from ${this.key}`, err)\n\t\t\tthis.error$.next(error)\n\t\t\tconsole.error(error)\n\t\t}\n\t}\n\n\t/**\n\t * Clear the collection\n\t */\n\tpublic clear(): void {\n\t\tthis.updateState(new Map<string, V>())\n\t}\n\n\tpublic replace(newValue: Map<string, V>): void {\n\t\tthis.updateState(newValue)\n\t}\n\n\t/**\n\t * Update the state with error handling\n\t */\n\tprivate updateState(newValue: Map<string, V>): void {\n\t\ttry {\n\t\t\tthis.$.next(newValue)\n\t\t} catch (err) {\n\t\t\tconst error = new StoreError<unknown>(`Error updating state in ${this.key}`, err)\n\t\t\tthis.error$.next(error)\n\t\t\tconsole.error(error)\n\t\t}\n\t}\n\n\t/**\n\t * Initialize from persistent storage\n\t */\n\tprivate async initializeFromStorage(): Promise<void> {\n\t\tif (this.storageType === 'local' || this.storageType === 'session') {\n\t\t\ttry {\n\t\t\t\tconst storedValue = await this.storage.load()\n\t\t\t\tif (storedValue) {\n\t\t\t\t\tthis.updateState(storedValue)\n\t\t\t\t}\n\t\t\t\tthis._ready = true\n\t\t\t} catch (err) {\n\t\t\t\tconst error = new StoreError<unknown>(`Error loading from ${this.storageType} storage for ${this.key}`, err)\n\t\t\t\tthis.error$.next(error)\n\t\t\t\tconsole.error(error)\n\t\t\t\tthis._ready = true // Mark as ready even if loading fails\n\t\t\t}\n\t\t} else if (this.storageType === 'indexeddb') {\n\t\t\tthis.loadFromIndexedDB()\n\t\t} else {\n\t\t\t// Memory storage doesn't need loading\n\t\t\tthis._ready = true\n\t\t}\n\t}\n\n\t/**\n\t * Load data from IndexedDB with better typing\n\t */\n\tprivate async loadFromIndexedDB(): Promise<void> {\n\t\ttry {\n\t\t\tconst result = await this.storage.load()\n\t\t\tthis.updateState(result || new Map<string, V>())\n\t\t\tthis._ready = true\n\t\t} catch (err) {\n\t\t\tconst error = new StoreError<unknown>(`Error loading from IndexedDB for ${this.key}`, err)\n\t\t\tthis.error$.next(error)\n\t\t\tconsole.error(error)\n\t\t\tthis._ready = true // Mark as ready even if loading fails\n\t\t}\n\t}\n\n\t/**\n\t * Set up persistence to storage\n\t */\n\tprivate setupPersistence(): void {\n\t\tif (this.storageType === 'memory') return\n\n\t\tthis.$.pipe(throttleTime(100, undefined, { leading: true, trailing: true })).subscribe(currentValue => {\n\t\t\tthis.storage.save(currentValue).catch(err => {\n\t\t\t\tconst error = new StoreError<unknown>(`Error saving to ${this.storageType} storage for ${this.key}`, err)\n\t\t\t\tthis.error$.next(error)\n\t\t\t\tconsole.error(error)\n\t\t\t})\n\t\t})\n\t}\n\n\t/**\n\t * Setup development tools for debugging\n\t */\n\tprivate setupDevTools(): void {\n\t\tif (typeof window !== 'undefined') {\n\t\t\t// Add to global store registry\n\t\t\t;(window as any).__STORES__ = (window as any).__STORES__ || {}\n\t\t\t;(window as any).__STORES__[this.key] = {\n\t\t\t\tgetState: () => this.value,\n\t\t\t\tset: this.set.bind(this),\n\t\t\t\tdelete: this.delete.bind(this),\n\t\t\t\tclear: this.clear.bind(this),\n\t\t\t\tsubscribe: (callback: (state: Map<string, V>) => void) => {\n\t\t\t\t\tconst subscription = this.$.subscribe(callback)\n\t\t\t\t\treturn () => subscription.unsubscribe()\n\t\t\t\t},\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Clean up resources\n\t */\n\tpublic destroy(): void {\n\t\tthis._destroy$.next()\n\t\tthis._destroy$.complete()\n\t\tthis.$.complete()\n\t\tthis.error$.complete()\n\t}\n}\n","import { BehaviorSubject, Subject } from 'rxjs'\nimport { createStorageManager, StorageManager } from './storage-manager'\nimport { IStore, StorageType, StoreError } from './types'\n\n/**\n * Enhanced store object with better TypeScript support\n */\nexport class SchmancyStoreObject<T extends Record<string, any>> implements IStore<T> {\n\tpublic static type = 'object'\n\n\t// Static map to hold instances with proper typing\n\tprivate static instances: Map<string, SchmancyStoreObject<any>> = new Map()\n\n\t// State tracking\n\tprivate _ready: boolean = false\n\tprivate _destroy$ = new Subject<void>()\n\n\t// Observable streams\n\tpublic $: BehaviorSubject<T>\n\tpublic error$ = new BehaviorSubject<StoreError | null>(null)\n\n\t// Default value for the store\n\tpublic readonly defaultValue: T\n\n\t// Storage manager\n\tprivate storage: StorageManager<T>\n\n\t/**\n\t * Get store ready state\n\t */\n\tpublic get ready(): boolean {\n\t\treturn this._ready\n\t}\n\n\t/**\n\t * Set store ready state\n\t */\n\tpublic set ready(value: boolean) {\n\t\tthis._ready = value\n\t\tthis.updateState(this.$.value)\n\t}\n\n\t/**\n\t * Private constructor to enforce singleton pattern\n\t */\n\tprivate constructor(private storageType: StorageType, private key: string, defaultValue: T) {\n\t\tthis.defaultValue = defaultValue\n\t\tthis.$ = new BehaviorSubject<T>(defaultValue)\n\t\tthis.storage = createStorageManager<T>(storageType, key)\n\n\t\t// Initialize from storage\n\t\tthis.initializeFromStorage()\n\n\t\t// Setup dev tools in development\n\t\tif (import.meta.env.MODE === 'development') {\n\t\t\tthis.setupDevTools()\n\t\t}\n\t}\n\n\t/**\n\t * Static method to get or create an instance with strong typing\n\t */\n\tpublic static getInstance<T extends Record<string, any>>(\n\t\tstorage: StorageType,\n\t\tkey: string,\n\t\tdefaultValue: T,\n\t): SchmancyStoreObject<T> {\n\t\tconst instanceKey = `${storage}:${key}`\n\t\tif (!this.instances.has(instanceKey)) {\n\t\t\tthis.instances.set(instanceKey, new SchmancyStoreObject<T>(storage, key, defaultValue))\n\t\t}\n\t\treturn this.instances.get(instanceKey) as SchmancyStoreObject<T>\n\t}\n\n\t/**\n\t * Get the current value from the store\n\t */\n\tpublic get value(): T {\n\t\treturn this.$.getValue()\n\t}\n\n\t/**\n\t * Set state with proper typing\n\t */\n\tpublic set(value: Partial<T>, merge: boolean = true): void {\n\t\ttry {\n\t\t\tthis.updateState(merge ? { ...this.value, ...value } : (value as T))\n\t\t\tthis.error$.next(null) // Clear any previous errors\n\t\t} catch (err) {\n\t\t\tconst error = new StoreError<unknown>(`Error updating store: ${this.key}`, err, { value, merge })\n\t\t\tthis.error$.next(error)\n\t\t\tconsole.error(error)\n\t\t}\n\t}\n\n\t/**\n\t * Reset the store to its default value\n\t */\n\tpublic clear(): void {\n\t\tthis.set(this.defaultValue, false)\n\t}\n\n\t/**\n\t * Replace the store with a new value\n\t */\n\tpublic replace(newValue: T): void {\n\t\tthis.updateState(newValue)\n\t}\n\n\t/**\n\t * Delete a specific key from the store with type checking\n\t */\n\tpublic delete<K extends keyof T>(key: K): void {\n\t\tconst value = { ...this.value }\n\t\tdelete value[key]\n\t\tthis.updateState(value)\n\t}\n\n\t/**\n\t * Update the state with proper error handling\n\t */\n\tprivate updateState(newValue: T): void {\n\t\ttry {\n\t\t\tthis.$.next(newValue)\n\n\t\t\t// Persist to storage\n\t\t\tif (this.storageType !== 'memory') {\n\t\t\t\tthis.storage.save(newValue).catch(err => {\n\t\t\t\t\tconsole.error(`Error saving to ${this.storageType} storage:`, err)\n\t\t\t\t})\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tconst error = new StoreError<unknown>(`Error updating state in ${this.key}`, err)\n\t\t\tthis.error$.next(error)\n\t\t\tconsole.error(error)\n\t\t}\n\t}\n\n\t/**\n\t * Initialize the store from persistent storage\n\t */\n\tprivate async initializeFromStorage(): Promise<void> {\n\t\ttry {\n\t\t\tconst storedValue = await this.storage.load()\n\t\t\tif (storedValue) {\n\t\t\t\tthis.updateState({ ...this.defaultValue, ...storedValue })\n\t\t\t}\n\t\t\tthis._ready = true\n\t\t} catch (err) {\n\t\t\tconst error = new StoreError<unknown>(`Error loading from ${this.storageType} storage for ${this.key}`, err)\n\t\t\tthis.error$.next(error)\n\t\t\tconsole.error(error)\n\t\t\tthis._ready = true // Mark as ready even if loading fails\n\t\t}\n\t}\n\n\t/**\n\t * Setup development tools for debugging\n\t */\n\tprivate setupDevTools(): void {\n\t\tif (typeof window !== 'undefined') {\n\t\t\t// Add to global store registry\n\t\t\t;(window as any).__STORES__ = (window as any).__STORES__ || {}\n\t\t\t;(window as any).__STORES__[this.key] = {\n\t\t\t\tgetState: () => this.value,\n\t\t\t\tset: this.set.bind(this),\n\t\t\t\tdelete: this.delete.bind(this),\n\t\t\t\tclear: this.clear.bind(this),\n\t\t\t\tsubscribe: (callback: (state: T) => void) => {\n\t\t\t\t\tconst subscription = this.$.subscribe(callback)\n\t\t\t\t\treturn () => subscription.unsubscribe()\n\t\t\t\t},\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Clean up resources\n\t */\n\tpublic destroy(): void {\n\t\tthis._destroy$.next()\n\t\tthis._destroy$.complete()\n\t\tthis.$.complete()\n\t\tthis.error$.complete()\n\t}\n}\n"],"names":["StoreError","Error","message","cause","context","super","this","name","MemoryStorageManager","data","state","LocalStorageManager","key","load","localStorage","getItem","JSON","parse","err","setItem","stringify","removeItem","SessionStorageManager","sessionStorage","clear","IndexedDBStorageManager","openDB","Promise","resolve","reject","request","indexedDB","open","DB_NAME","DB_VERSION","onupgradeneeded","db","result","objectStoreNames","contains","STORE_NAME","createObjectStore","onsuccess","onerror","error","transaction","objectStore","get","close","put","delete","_h","createStorageManager","type","SchmancyCollectionStore","storageType","defaultValue","_ready","_destroy$","Subject","error$","BehaviorSubject","$","Map","storage","initializeFromStorage","setupPersistence","ready","value","updateState","instanceKey","instances","has","set","getValue","currentValue","next","newValue","storedValue","loadFromIndexedDB","pipe","throttleTime","leading","trailing","subscribe","save","catch","window","__STORES__","getState","bind","callback","subscription","unsubscribe","complete","_o","SchmancyStoreObject","merge","setupDevTools","_a"],"mappings":"qCA4DO,MAAMA,UAAgCC,KAAAA,CAC5C,YAAYC,EAAiCC,EAA2BC,EACvEC,CAAAA,MAAMH,GADsCI,KAAAH,MAAAA,EAA2BG,KAAAF,QAAAA,EAEvEE,KAAKC,KAAO,YAAA,CCjDP,CAAA,MAAMC,CAAN,CAAA,cACNF,KAAQG,KAAiB,IAAA,CAEzB,YACC,CAAA,OAAOH,KAAKG,IAAA,CAGb,MAAA,KAAWC,EAAAA,CACVJ,KAAKG,KAAOC,CAAA,CAGb,MAAA,OACCJ,CAAAA,KAAKG,KAAO,IAAA,EAOP,MAAME,CAAAA,CACZ,YAAoBC,EAAAN,CAAAA,KAAAM,IAAAA,CAAA,CAEpB,MAAMC,MAAAA,CACD,GACH,CAAA,MAAMJ,EAAOK,aAAaC,QAAQT,KAAKM,GAAAA,EACvC,OAAOH,EAAOO,KAAKC,MAAMR,CAAAA,EAAQ,UACzBS,CAED,OAAA,IAAA,CACR,CAGD,MAAA,KAAWR,EAAAA,CACN,GACHI,CAAAA,aAAaK,QAAQb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AA,OAAW,MAEJA,OAAAC,WAAcD,OAAeC,YAAc,CAAC,EAC5CD,OAAAC,WAAWlF,KAAKM,GAAAA,EAAO,CACvC6E,SAAU,IAAMnF,KAAK8D,MACrBK,IAAKnE,KAAKmE,IAAIiB,KAAKpF,IACnB4C,EAAAA,OAAQ5C,KAAK4C,OAAOwC,KAAKpF,IACzBkB,EAAAA,MAAOlB,KAAKkB,MAAMkE,KAAKpF,IAAAA,EACvB8E,UAAYO,GAAAA,CACX,MAAMC,EAAetF,KAAKwD,EAAEsB,UAAUO,GAC/B,MAAA,IAAMC,EAAaC,YAAAA,CAAY,GAGzC,CAMM,SACNvF,CAAAA,KAAKoD,UAAUkB,KAAAA,EACftE,KAAKoD,UAAUoC,WACfxF,KAAKwD,EAAEgC,SACPxF,EAAAA,KAAKsD,OAAOkC,SAAS,CAAA,CAAA,EA/KtBxF,EAAc+C,KAAO,SAGN/C,EAAAiE,cAAuDR,IAJhE,IAAMiC,EAANG"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";const C=require("./context-object-CgZ6F8E9.cjs"),j=require("lit/decorators.js"),A=require("rxjs"),h=require("rxjs/operators"),L=(i,t)=>t.split(".").reduce((e,n)=>e==null?void 0:e[n],i),O=i=>{const t=[];for(let e=0;e<i.length-1;e++)t.push(i.substring(e,e+2));return t},x=(i,t)=>{const e=i.toLowerCase().trim(),n=t.toLowerCase().trim(),o=e.includes(n)?1:0,p=((a,l)=>{let s=0,r=0;for(;s<a.length&&r<l.length;)a[s]===l[r]&&s++,r++;return s===a.length})(n,e)?.8:0,g=((a,l)=>{const s=b=>b.split("").reduce((m,y)=>(m[y]=(m[y]||0)+1,m),{}),r=s(a),u=s(l);return Object.keys(r).every(b=>(u[b]||0)>=r[b])})(n,e)?.7:0,d=((a,l)=>{if(a.length<2||l.length<2)return 0;const s=O(a),r=O(l);let u=0;const b=new Array(r.length).fill(!1);for(const m of s)for(let y=0;y<r.length;y++)if(!b[y]&&r[y]===m){u++,b[y]=!0;break}return 2*u/(s.length+r.length)})(e,n),c=Math.max(e.length,n.length),f=c?1-((a,l)=>{const s=[];for(let r=0;r<=l.length;r++)s[r]=[r];for(let r=0;r<=a.length;r++)s[0][r]=r;for(let r=1;r<=l.length;r++)for(let u=1;u<=a.length;u++)l.charAt(r-1)===a.charAt(u-1)?s[r][u]=s[r-1][u-1]:s[r][u]=Math.min(s[r-1][u]+1,s[r][u-1]+1,s[r-1][u-1]+1);return s[l.length][a.length]})(e,n)/c:1;return Math.max(o,p,g,d,f)},M=(i,t,e)=>{switch(i){case"==":return t===e;case"!=":return t!==e;case">":return t>e;case"<":return t<e;case">=":return t>=e;case"<=":return t<=e;case"includes":return typeof t=="string"?t.toLowerCase().includes(String(e).toLowerCase()):!!Array.isArray(t)&&t.includes(e);case"notIncludes":return typeof t=="string"?!t.toLowerCase().includes(String(e).toLowerCase()):!!Array.isArray(t)&&!t.includes(e);case"startsWith":return typeof t=="string"&&t.startsWith(String(e));case"endsWith":return typeof t=="string"&&t.endsWith(String(e));case"in":return!!Array.isArray(e)&&e.includes(t);case"notIn":return!!Array.isArray(e)&&!e.includes(t);default:return!1}},w=(i,t=[])=>{const e=Array.from(i.values()).map(n=>{let o=0,p=0,g=!0;for(const d of t){let c,f,a,l=!1;if(Array.isArray(d)?([c,f,a,l=!1]=d,l=!!l):(c=d.key,f=d.operator,a=d.value,l=d.strict||!1),!l&&(a===""||a==null||Array.isArray(a)&&a.length===0))continue;const s=L(n,c);if(l){if(s!==a){g=!1;break}o+=1,p++}else if(f==="any"){if(typeof s!="string"||typeof a!="string"){g=!1;break}const r=x(s,a);if(r<.3){g=!1;break}o+=r,p++}else{if(!M(f,s,a)){g=!1;break}o+=1,p++}}return g?{item:n,score:p>0?o/p:1}:null}).filter(n=>n!==null);return e.sort((n,o)=>o.score-n.score),e.map(n=>n.item)},v=w;function k(i,t){return i.$.pipe(h.map(t),h.distinctUntilChanged((e,n)=>JSON.stringify(e)===JSON.stringify(n)),h.shareReplay(1))}function S(i,t){return i.$.pipe(h.map(t),h.distinctUntilChanged((e,n)=>e instanceof Map&&n instanceof Map?JSON.stringify(Array.from(e.entries()))===JSON.stringify(Array.from(n.entries())):JSON.stringify(e)===JSON.stringify(n)),h.shareReplay(1))}exports.createCollectionSelector=S,exports.createCompoundSelector=function(i,t){return A.combineLatest(i).pipe(h.map(e=>t(...e)),h.distinctUntilChanged((e,n)=>JSON.stringify(e)===JSON.stringify(n)),h.shareReplay(1))},exports.createContext=function(i,t,e){if(function(o){if(o==null||typeof o!="object")return!1;const p=Object.getPrototypeOf(o);return p!==Object.prototype&&p!==null&&typeof o[Symbol.iterator]=="function"}(i)){const o=C.SchmancyCollectionStore.getInstance(t,e,i);return o.value.size||o.$.next(i),o}if(typeof i=="object"&&i!==null){if(t==="indexeddb")throw new Error("IndexedDB storage is not supported for plain objects.");const o=C.SchmancyStoreObject.getInstance(t,e,i);return typeof(n=o.value)=="object"&&n!==null&&Object.keys(n).length===0&&o.$.next(i),o}throw new Error("Initial data must be an object or a Map.");var n},exports.createCountSelector=function(i,t){return S(i,e=>{if(!t)return e.size;let n=0;return e.forEach((o,p)=>{t(o,p)&&n++}),n})},exports.createFilterSelector=function(i,t){return S(i,e=>{const n=[];return e.forEach((o,p)=>{t(o,p)&&n.push(o)}),n})},exports.createItemSelector=function(i,t){return S(i,e=>e.get(t))},exports.createSelector=k,exports.filterMap=v,exports.filterMapItems=w,exports.select=function(i,t=n=>n,e={}){return function(n,o,p){j.property({attribute:!1,type:Object})(n,o);const g=n.connectedCallback,d=n.disconnectedCallback;n.connectedCallback=function(){var l;const c=this;c.t||(c.t={}),c.t[o]||(c.t[o]={subscription:null,initialLoad:!1});const f=c.t[o];!((l=c.disconnecting)!=null&&l.closed)&&c.disconnecting||(c.disconnecting=new A.Subject);const a=function(s){return"set"in s&&typeof s.set=="function"&&s.value instanceof Map}(i)?S(i,t):k(i,t);e.required||f.initialLoad||(g==null||g.call(c),f.initialLoad=!0),f.subscription||(f.subscription=a.pipe(h.takeUntil(c.disconnecting)).subscribe({next:s=>{var u;const r=structuredClone(s);c[o]=r,(u=c.requestUpdate)==null||u.call(c),e.required&&!f.initialLoad&&r&&(g==null||g.call(c),f.initialLoad=!0)},error:s=>{}}))},n.disconnectedCallback=function(){var f;d==null||d.call(this);const c=(f=this.t)==null?void 0:f[o];c!=null&&c.subscription&&(c.subscription.unsubscribe(),c.subscription=null),this.disconnecting&&(this.disconnecting.next(),this.disconnecting.complete())}}};
|
|
2
|
-
//# sourceMappingURL=selector-hook-B5oIBdcJ.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"selector-hook-B5oIBdcJ.cjs","sources":["../src/store/filter-directive.ts","../src/store/selectors.ts","../src/store/context-create.ts","../src/store/selector-hook.ts"],"sourcesContent":["/** Supported comparison operators. */\ntype ComparisonOperator =\n\t| '=='\n\t| '!='\n\t| '>'\n\t| '<'\n\t| '>='\n\t| '<='\n\t| 'includes'\n\t| 'notIncludes'\n\t| 'startsWith'\n\t| 'endsWith'\n\t| 'in'\n\t| 'notIn'\n\t| 'any' // fuzzy search operator\n\n/**\n * Query condition which can be either a tuple:\n * [field, operator, expected]\n * or an object:\n * { key, operator, value }\n */\nexport type QueryCondition =\n\t| [field: string, op: ComparisonOperator, expected: unknown, strict?: boolean]\n\t| { key: string; operator: ComparisonOperator; value: unknown; strict?: boolean }\n\n/**\n * Get a nested value from an object using a dot-separated path.\n * Checks explicitly for null/undefined so falsy values like 0 or false are preserved.\n */\nconst getFieldValue = (item: Record<string, any>, path: string): any =>\n\tpath.split('.').reduce((obj, key) => (obj == null ? undefined : obj[key]), item)\n\n/**\n * Compute the Levenshtein distance between two strings.\n */\nconst levenshtein = (a: string, b: string): number => {\n\tconst matrix: number[][] = []\n\n\t// initialize the first column\n\tfor (let i = 0; i <= b.length; i++) {\n\t\tmatrix[i] = [i]\n\t}\n\t// initialize the first row\n\tfor (let j = 0; j <= a.length; j++) {\n\t\tmatrix[0][j] = j\n\t}\n\n\tfor (let i = 1; i <= b.length; i++) {\n\t\tfor (let j = 1; j <= a.length; j++) {\n\t\t\tif (b.charAt(i - 1) === a.charAt(j - 1)) {\n\t\t\t\tmatrix[i][j] = matrix[i - 1][j - 1]\n\t\t\t} else {\n\t\t\t\tmatrix[i][j] = Math.min(\n\t\t\t\t\tmatrix[i - 1][j] + 1, // deletion\n\t\t\t\t\tmatrix[i][j - 1] + 1, // insertion\n\t\t\t\t\tmatrix[i - 1][j - 1] + 1, // substitution\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t}\n\treturn matrix[b.length][a.length]\n}\n\n/**\n * Check if string `sub` is a subsequence of string `str`.\n * All characters in `sub` must appear in order in `str` (they need not be contiguous).\n */\nconst isSubsequence = (sub: string, str: string): boolean => {\n\tlet i = 0,\n\t\tj = 0\n\twhile (i < sub.length && j < str.length) {\n\t\tif (sub[i] === str[j]) i++\n\t\tj++\n\t}\n\treturn i === sub.length\n}\n\n/**\n * Check if every character (with frequency) in the query exists in the target.\n * For example, \"aovc\" matches \"avocados\".\n */\nconst anagramMatch = (query: string, target: string): boolean => {\n\tconst countChars = (s: string): Record<string, number> =>\n\t\ts.split('').reduce((acc, char) => {\n\t\t\tacc[char] = (acc[char] || 0) + 1\n\t\t\treturn acc\n\t\t}, {} as Record<string, number>)\n\n\tconst queryCount = countChars(query)\n\tconst targetCount = countChars(target)\n\treturn Object.keys(queryCount).every(char => (targetCount[char] || 0) >= queryCount[char])\n}\n\n/**\n * Generate bigrams for a string.\n */\nconst getBigrams = (s: string): string[] => {\n\tconst bigrams = []\n\tfor (let i = 0; i < s.length - 1; i++) {\n\t\tbigrams.push(s.substring(i, i + 2))\n\t}\n\treturn bigrams\n}\n\n/**\n * Compute Dice's coefficient for two strings based on bigrams.\n * Returns a value between 0 (no similarity) and 1 (perfect match).\n */\nconst diceCoefficient = (s1: string, s2: string): number => {\n\tif (s1.length < 2 || s2.length < 2) return 0\n\tconst bigrams1 = getBigrams(s1)\n\tconst bigrams2 = getBigrams(s2)\n\tlet intersection = 0\n\tconst used = new Array(bigrams2.length).fill(false)\n\tfor (const bigram of bigrams1) {\n\t\tfor (let i = 0; i < bigrams2.length; i++) {\n\t\t\tif (!used[i] && bigrams2[i] === bigram) {\n\t\t\t\tintersection++\n\t\t\t\tused[i] = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\treturn (2 * intersection) / (bigrams1.length + bigrams2.length)\n}\n\n/**\n * Compute a fuzzy similarity score between two strings.\n * The score is computed by taking the maximum of several methods:\n * - Direct substring match (score 1)\n * - Subsequence check (score 0.8)\n * - Anagram subset match (score 0.7)\n * - Dice coefficient\n * - Normalized Levenshtein similarity\n */\nconst computeFuzzyScore = (actual: string, expected: string): number => {\n\tconst a = actual.toLowerCase().trim()\n\tconst b = expected.toLowerCase().trim()\n\n\tconst substringScore = a.includes(b) ? 1 : 0\n\tconst subsequenceScore = isSubsequence(b, a) ? 0.8 : 0\n\tconst anagramScore = anagramMatch(b, a) ? 0.7 : 0\n\tconst diceScore = diceCoefficient(a, b)\n\tconst maxLen = Math.max(a.length, b.length)\n\tconst levenshteinScore = maxLen ? 1 - levenshtein(a, b) / maxLen : 1\n\n\treturn Math.max(substringScore, subsequenceScore, anagramScore, diceScore, levenshteinScore)\n}\n\n/**\n * Compare two values based on a simple operator.\n * For non-fuzzy operators, this returns a boolean.\n */\nconst compareValues = (op: ComparisonOperator, actual: any, expected: any): boolean => {\n\tswitch (op) {\n\t\tcase '==':\n\t\t\treturn actual === expected\n\t\tcase '!=':\n\t\t\treturn actual !== expected\n\t\tcase '>':\n\t\t\treturn actual > expected\n\t\tcase '<':\n\t\t\treturn actual < expected\n\t\tcase '>=':\n\t\t\treturn actual >= expected\n\t\tcase '<=':\n\t\t\treturn actual <= expected\n\t\tcase 'includes': {\n\t\t\tif (typeof actual === 'string') return actual.toLowerCase().includes(String(expected).toLowerCase())\n\t\t\telse if (Array.isArray(actual)) return actual.includes(expected)\n\t\t\treturn false\n\t\t}\n\t\tcase 'notIncludes': {\n\t\t\tif (typeof actual === 'string') return !actual.toLowerCase().includes(String(expected).toLowerCase())\n\t\t\telse if (Array.isArray(actual)) return !actual.includes(expected)\n\t\t\treturn false\n\t\t}\n\t\tcase 'startsWith': {\n\t\t\tif (typeof actual === 'string') return actual.startsWith(String(expected))\n\t\t\treturn false\n\t\t}\n\t\tcase 'endsWith': {\n\t\t\tif (typeof actual === 'string') return actual.endsWith(String(expected))\n\t\t\treturn false\n\t\t}\n\t\tcase 'in': {\n\t\t\tif (Array.isArray(expected)) return expected.includes(actual)\n\t\t\treturn false\n\t\t}\n\t\tcase 'notIn': {\n\t\t\tif (Array.isArray(expected)) return !expected.includes(actual)\n\t\t\treturn false\n\t\t}\n\t\tdefault: {\n\t\t\tconsole.warn(`Operator \"${op}\" is not supported in strict comparison.`)\n\t\t\treturn false\n\t\t}\n\t}\n}\n\n/**\n * Filter a Map of items given an array of query conditions.\n * For each query condition:\n * - If the expected value is empty/null/undefined, it is treated as a match.\n * - For non-fuzzy operators, the condition must strictly match.\n * - For the \"any\" operator, a fuzzy similarity score is computed.\n * Items with a fuzzy score below a given threshold (e.g., 0.3) are excluded.\n *\n * The overall item score is the average of the scores from all conditions.\n * The results are sorted in descending order of relevance.\n *\n * @param items - A Map containing items to filter.\n * @param queries - An array of query conditions to apply.\n * @returns An array of items that match all query conditions, sorted by relevance.\n */\nexport const filterMapItems = <T extends Record<string, any>>(\n\titems: Map<string, T>,\n\tqueries: QueryCondition[] = [],\n): T[] => {\n\t// Fuzzy threshold (adjust as needed)\n\tconst fuzzyThreshold = 0.3\n\n\t// Score and filter each item.\n\tconst scoredItems = Array.from(items.values())\n\t\t.map(item => {\n\t\t\tlet totalScore = 0\n\t\t\tlet count = 0\n\t\t\t// If any query fails, mark the item as invalid.\n\t\t\tlet valid = true\n\n\t\t\tfor (const query of queries) {\n\t\t\t\tlet field: string,\n\t\t\t\t\top: ComparisonOperator,\n\t\t\t\t\texpected: unknown,\n\t\t\t\t\tstrict = false\n\t\t\t\tif (Array.isArray(query)) {\n\t\t\t\t\t// Extract optional strict flag from tuple if provided.\n\t\t\t\t\t;[field, op, expected, strict = false] = query\n\t\t\t\t\tstrict = !!strict // default to false if undefined\n\t\t\t\t} else {\n\t\t\t\t\tfield = query.key\n\t\t\t\t\top = query.operator\n\t\t\t\t\texpected = query.value\n\t\t\t\t\tstrict = query.strict || false\n\t\t\t\t}\n\n\t\t\t\t// If the expected value is empty/null/undefined, or an empty array, skip filtering.\n\t\t\t\t// If the expected value is empty/null/undefined, or an empty array, and strict is false, skip filtering\n\t\t\t\tif (!strict && (expected === '' || expected == null || (Array.isArray(expected) && expected.length === 0))) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tconst actual = getFieldValue(item, field)\n\n\t\t\t\t// If strict mode is enabled, enforce exact equality.\n\t\t\t\tif (strict) {\n\t\t\t\t\tif (actual !== expected) {\n\t\t\t\t\t\tvalid = false\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\ttotalScore += 1 // exact match yields a perfect score\n\t\t\t\t\tcount++\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tif (op === 'any') {\n\t\t\t\t\t// Fuzzy search requires both values to be strings.\n\t\t\t\t\tif (typeof actual !== 'string' || typeof expected !== 'string') {\n\t\t\t\t\t\tvalid = false\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tconst score = computeFuzzyScore(actual, expected)\n\t\t\t\t\tif (score < fuzzyThreshold) {\n\t\t\t\t\t\tvalid = false\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\ttotalScore += score\n\t\t\t\t\tcount++\n\t\t\t\t} else {\n\t\t\t\t\t// For non-fuzzy operators, if the condition fails, exclude the item.\n\t\t\t\t\tif (!compareValues(op, actual, expected)) {\n\t\t\t\t\t\tvalid = false\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\ttotalScore += 1 // strict match yields a perfect score.\n\t\t\t\t\tcount++\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!valid) return null\n\n\t\t\t// Use the average score if at least one condition contributed.\n\t\t\tconst overallScore = count > 0 ? totalScore / count : 1\n\t\t\treturn { item, score: overallScore }\n\t\t})\n\t\t.filter(x => x !== null) as { item: T; score: number }[]\n\n\t// Sort by descending overall score.\n\tscoredItems.sort((a, b) => b.score - a.score)\n\treturn scoredItems.map(x => x.item)\n}\n\n// /**\n// * A typed directive function interface.\n// * Ensures that using the directive returns a filtered (and ranked) array of items.\n// */\n// export type FilterMapDirectiveFn = <T extends Record<string, any>>(\n// \titems: Map<string, T>,\n// \tqueries?: QueryCondition[],\n// ) => T[]\n\n// /**\n// * Lit directive to filter a Map based on an array of query conditions.\n// *\n// * Usage in your Lit template:\n// *\n// * ```ts\n// * html`\n// * <div .items=${filterMap(this.items, [\n// * { key: 'category', operator: '==', value: itemsFilterContext.value.category },\n// * ['name', 'any', 'avo'], // will match \"avocados\" even if typed as \"avo\" or \"aovc\"\n// * ])}></div>\n// * `\n// * ```\n// */\n// class FilterMapDirective extends Directive {\n// \tconstructor(partInfo: PartInfo) {\n// \t\tsuper(partInfo)\n// \t}\n\n// \trender<T extends Record<string, any>>(items: Map<string, T>, queries: QueryCondition[] = []): T[] {\n// \t\treturn filterMapItems(items, queries) as T[]\n// \t}\n// }\n\n// Cast the directive to our typed directive function interface.\nexport const filterMap = filterMapItems\n","// src/store/selectors.ts\nimport { Observable, combineLatest } from 'rxjs'\nimport { map, distinctUntilChanged, shareReplay } from 'rxjs/operators'\nimport { IStore, ICollectionStore } from './types'\n\n/**\n * Creates a selector that derives a value from store state\n *\n * @param store The store to observe\n * @param selectorFn Function that transforms the state\n * @returns An observable of the selected state that only emits when the derived value changes\n */\nexport function createSelector<T, R>(store: IStore<T>, selectorFn: (state: T) => R): Observable<R> {\n\treturn store.$.pipe(\n\t\tmap(selectorFn),\n\t\tdistinctUntilChanged(\n\t\t\t(a, b) =>\n\t\t\t\t// Compare the two objects deep to see if they are equal\n\t\t\t\tJSON.stringify(a) === JSON.stringify(b),\n\t\t),\n\t\tshareReplay(1),\n\t)\n}\n\n/**\n * Creates a selector for collection stores that derives a value from the collection\n *\n * @param store The collection store to observe\n * @param selectorFn Function that transforms the collection\n * @returns An observable of the selected state that only emits when the derived value changes\n */\nexport function createCollectionSelector<T, R>(\n\tstore: ICollectionStore<T>,\n\tselectorFn: (state: Map<string, T>) => R,\n): Observable<R> {\n\treturn store.$.pipe(\n\t\tmap(selectorFn),\n\t\tdistinctUntilChanged((a, b) => {\n\t\t\tif (a instanceof Map && b instanceof Map) {\n\t\t\t\treturn JSON.stringify(Array.from(a.entries())) === JSON.stringify(Array.from(b.entries()))\n\t\t\t}\n\t\t\treturn JSON.stringify(a) === JSON.stringify(b)\n\t\t}),\n\t\tshareReplay(1),\n\t)\n}\n\n/**\n * Creates a selector that filters items from a collection\n *\n * @param store The collection store\n * @param filterFn Function that returns true for items to include\n * @returns An observable of filtered items as an array\n */\nexport function createFilterSelector<T>(\n\tstore: ICollectionStore<T>,\n\tfilterFn: (item: T, key: string) => boolean,\n): Observable<T[]> {\n\treturn createCollectionSelector(store, collection => {\n\t\tconst result: T[] = []\n\t\tcollection.forEach((item, key) => {\n\t\t\tif (filterFn(item, key)) {\n\t\t\t\tresult.push(item)\n\t\t\t}\n\t\t})\n\t\treturn result\n\t})\n}\n\n/**\n * Creates a selector that retrieves a single item from a collection\n *\n * @param store The collection store\n * @param itemKey The key of the item to select\n * @returns An observable of the selected item that emits when the item changes\n */\nexport function createItemSelector<T>(store: ICollectionStore<T>, itemKey: string): Observable<T | undefined> {\n\treturn createCollectionSelector(store, collection => collection.get(itemKey))\n}\n\n/**\n * Creates a selector that counts items in a collection, optionally filtered\n *\n * @param store The collection store\n * @param filterFn Optional function to filter which items to count\n * @returns An observable of the count\n */\nexport function createCountSelector<T>(\n\tstore: ICollectionStore<T>,\n\tfilterFn?: (item: T, key: string) => boolean,\n): Observable<number> {\n\treturn createCollectionSelector(store, collection => {\n\t\tif (!filterFn) return collection.size\n\n\t\tlet count = 0\n\t\tcollection.forEach((item, key) => {\n\t\t\tif (filterFn(item, key)) count++\n\t\t})\n\t\treturn count\n\t})\n}\n\n/**\n * Creates a compound selector that depends on multiple other selectors\n *\n * @param selectors Array of source selectors\n * @param combinerFn Function that combines all selector results\n * @returns An observable of the combined result\n */\nexport function createCompoundSelector<R, T extends any[]>(\n\tselectors: Observable<any>[],\n\tcombinerFn: (...values: T) => R,\n): Observable<R> {\n\treturn combineLatest(selectors).pipe(\n\t\tmap(values => combinerFn(...(values as T))),\n\t\tdistinctUntilChanged((a, b) => JSON.stringify(a) === JSON.stringify(b)),\n\t\tshareReplay(1),\n\t)\n}\n","import { ICollectionStore, IStore, StorageType } from './types'\nimport { SchmancyStoreObject } from './context-object'\nimport SchmancyCollectionStore from './context-collection'\n\n/**\n * Checks if an object is empty\n */\nfunction isEmptyObject(obj: object): boolean {\n\tif (typeof obj !== 'object' || obj === null) {\n\t\treturn false\n\t}\n\treturn Object.keys(obj).length === 0\n}\n\n/**\n * Returns true if obj is an iterable collection\n */\nfunction isCollection(obj: any): obj is Iterable<any> {\n\t// Must be non-null and of type 'object'\n\tif (obj == null || typeof obj !== 'object') {\n\t\treturn false\n\t}\n\n\t// Exclude plain objects.\n\tconst proto = Object.getPrototypeOf(obj)\n\tif (proto === Object.prototype || proto === null) {\n\t\treturn false\n\t}\n\n\t// Check for Symbol.iterator method\n\treturn typeof obj[Symbol.iterator] === 'function'\n}\n\n/**\n * Creates a context for managing state with better type safety\n */\nexport function createContext<T extends Record<string, any>>(\n\tinitialData: T,\n\tstorage: StorageType,\n\tkey: string,\n): IStore<T> & SchmancyStoreObject<T>\n\nexport function createContext<V>(\n\tinitialData: Map<string, V>,\n\tstorage: StorageType,\n\tkey: string,\n): ICollectionStore<V> & SchmancyCollectionStore<V>\n\nexport function createContext<T extends Record<string, any> | Map<string, any>>(\n\tinitialData: T | Map<string, any>,\n\tstorage: StorageType,\n\tkey: string,\n): (IStore<T> & SchmancyStoreObject<T>) | (ICollectionStore<any> & SchmancyCollectionStore<any>) {\n\tif (isCollection(initialData)) {\n\t\t// Create a collection store\n\t\tconst store = SchmancyCollectionStore.getInstance(storage, key, initialData as Map<string, any>)\n\n\t\t// Initialize with provided data if store is empty\n\t\tif (!store.value.size) {\n\t\t\tstore.$.next(initialData as Map<string, any>)\n\t\t}\n\t\treturn store as ICollectionStore<any> & SchmancyCollectionStore<any>\n\t} else if (typeof initialData === 'object' && initialData !== null) {\n\t\t// Validate storage type for object stores\n\t\tif (storage === 'indexeddb') {\n\t\t\tthrow new Error('IndexedDB storage is not supported for plain objects.')\n\t\t}\n\n\t\t// Create an object store\n\t\tconst store = SchmancyStoreObject.getInstance<T>(storage, key, initialData as T)\n\n\t\t// Initialize with provided data if store is empty\n\t\tif (isEmptyObject(store.value)) {\n\t\t\tstore.$.next(initialData as T)\n\t\t}\n\t\treturn store as IStore<T> & SchmancyStoreObject<T>\n\t} else {\n\t\tthrow new Error('Initial data must be an object or a Map.')\n\t}\n}\n","// src/store/selector-hook.ts\nimport { property as litProperty } from 'lit/decorators.js'\nimport { Subject, Subscription } from 'rxjs'\nimport { takeUntil } from 'rxjs/operators'\nimport { createCollectionSelector, createSelector } from './selectors'\nimport { ICollectionStore, IStore } from './types'\n\ninterface ComponentWithDisconnection {\n\tdisconnecting?: Subject<void>\n\trequestUpdate?: () => void\n\tisConnected: boolean\n\t__selectorProps?: Record<string, SelectorPropState<unknown>>\n\t[key: string]: any\n}\n\ninterface SelectorPropState<_T> {\n\tsubscription: Subscription | null\n\tinitialLoad: boolean\n}\n\ntype PropertyDescriptor<T> = {\n\tget?: () => T\n\tset?: (value: T) => void\n\tvalue?: T\n\tconfigurable?: boolean\n\tenumerable?: boolean\n\twritable?: boolean\n}\n\ninterface SelectOptions {\n\trequired?: boolean\n\tupdateOnly?: boolean\n}\n\nfunction isCollectionStore(store: any): store is ICollectionStore<unknown> {\n\treturn 'set' in store && typeof store.set === 'function' && store.value instanceof Map\n}\n\nexport function select<T, R>(\n\tstore: IStore<T> | ICollectionStore<T>,\n\tselectorFn: (state: any) => R = (state: R) => state,\n\toptions: SelectOptions = {},\n) {\n\treturn function (proto: Record<string, any>, propName: string, _descriptor?: PropertyDescriptor<R>) {\n\t\tlitProperty({ attribute: false, type: Object })(proto, propName)\n\n\t\tconst originalConnectedCallback = proto.connectedCallback\n\t\tconst originalDisconnectedCallback = proto.disconnectedCallback\n\n\t\tproto.connectedCallback = function (this: ComponentWithDisconnection) {\n\t\t\tconst instance = this\n\n\t\t\tif (!instance.__selectorProps) {\n\t\t\t\tinstance.__selectorProps = {}\n\t\t\t}\n\n\t\t\tif (!instance.__selectorProps[propName]) {\n\t\t\t\tinstance.__selectorProps[propName] = {\n\t\t\t\t\tsubscription: null,\n\t\t\t\t\tinitialLoad: false,\n\t\t\t\t} as SelectorPropState<R>\n\t\t\t}\n\n\t\t\tconst props = instance.__selectorProps[propName] as SelectorPropState<R>\n\n\t\t\t// Reset disconnecting Subject if it's closed or doesn't exist\n\t\t\tif (instance.disconnecting?.closed || !instance.disconnecting) {\n\t\t\t\tinstance.disconnecting = new Subject<void>()\n\t\t\t}\n\n\t\t\tconst selector = isCollectionStore(store)\n\t\t\t\t? createCollectionSelector(store, selectorFn)\n\t\t\t\t: createSelector(store as IStore<T>, selectorFn)\n\n\t\t\t// Call original connectedCallback immediately if not required\n\t\t\tif (!options.required && !props.initialLoad) {\n\t\t\t\toriginalConnectedCallback?.call(instance)\n\t\t\t\tprops.initialLoad = true\n\t\t\t}\n\n\t\t\tif (!props.subscription) {\n\t\t\t\tprops.subscription = selector.pipe(takeUntil(instance.disconnecting)).subscribe({\n\t\t\t\t\tnext: (value: R) => {\n\t\t\t\t\t\tconst newValue = structuredClone(value)\n\t\t\t\t\t\tinstance[propName] = newValue\n\t\t\t\t\t\tinstance.requestUpdate?.()\n\t\t\t\t\t\tif (options.required && !props.initialLoad && newValue) {\n\t\t\t\t\t\t\toriginalConnectedCallback?.call(instance)\n\t\t\t\t\t\t\tprops.initialLoad = true\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\terror: (err: Error) => {\n\t\t\t\t\t\tconsole.error(`Error in selector subscription for ${propName}:`, err)\n\t\t\t\t\t},\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\tproto.disconnectedCallback = function (this: ComponentWithDisconnection) {\n\t\t\toriginalDisconnectedCallback?.call(this)\n\n\t\t\tconst props = this.__selectorProps?.[propName] as SelectorPropState<R> | undefined\n\t\t\tif (props?.subscription) {\n\t\t\t\tprops.subscription.unsubscribe()\n\t\t\t\tprops.subscription = null\n\t\t\t}\n\n\t\t\tif (this.disconnecting) {\n\t\t\t\tthis.disconnecting.next()\n\t\t\t\tthis.disconnecting.complete()\n\t\t\t\t// Allow reinitialization by not deleting the disconnecting subject\n\t\t\t}\n\t\t}\n\t}\n}\n"],"names":["getFieldValue","item","path","split","reduce","obj","key","getBigrams","s","bigrams","i","length","push","substring","computeFuzzyScore","actual","expected","a","toLowerCase","trim","b","substringScore","includes","subsequenceScore","sub","str","j","anagramScore","query","target","countChars","acc","char","queryCount","targetCount","Object","keys","every","diceScore","s1","s2","bigrams1","bigrams2","intersection","used","Array","fill","bigram","maxLen","Math","max","levenshteinScore","matrix","charAt","min","compareValues","op","String","isArray","startsWith","endsWith","filterMapItems","items","queries","scoredItems","from","values","map","totalScore","count","valid","field","strict","operator","value","score","filter","x","sort","filterMap","createSelector","store","selectorFn","$","pipe","distinctUntilChanged","JSON","stringify","shareReplay","createCollectionSelector","Map","entries","selectors","combinerFn","combineLatest","initialData","storage","proto","getPrototypeOf","prototype","Symbol","iterator","SchmancyCollectionStore","getInstance","size","next","Error","SchmancyStoreObject","filterFn","collection","forEach","result","itemKey","get","state","options","propName","_descriptor","litProperty","attribute","type","originalConnectedCallback","connectedCallback","originalDisconnectedCallback","disconnectedCallback","instance","this","__selectorProps","subscription","initialLoad","props","disconnecting","closed","Subject","selector","set","required","call","takeUntil","subscribe","newValue","structuredClone","requestUpdate","error","err","unsubscribe","complete"],"mappings":"yIA8BA,EAAMA,EAAgB,CAACC,EAA2BC,IACjDA,EAAKC,MAAM,GAAKC,EAAAA,OAAO,CAACC,EAAKC,IAASD,GAAO,KAAO,OAAYA,EAAIC,CAAOL,EAAAA,CAAAA,EAkEtEM,EAAcC,GAAAA,CACnB,MAAMC,EAAU,CAChB,EAAA,QAASC,EAAI,EAAGA,EAAIF,EAAEG,OAAS,EAAGD,IACjCD,EAAQG,KAAKJ,EAAEK,UAAUH,EAAGA,EAAI,CAE1B,CAAA,EAAA,OAAAD,CAAA,EAkCFK,EAAoB,CAACC,EAAgBC,IAAAA,CAC1C,MAAMC,EAAIF,EAAOG,YAAcC,EAAAA,KAAAA,EACzBC,EAAIJ,EAASE,YAAcC,EAAAA,KAAAA,EAE3BE,EAAiBJ,EAAEK,SAASF,CAAAA,EAAK,EAAI,EACrCG,GAzEe,CAACC,EAAaC,IAAAA,CAC/B,IAAAf,EAAI,EACPgB,EAAI,EACL,KAAOhB,EAAIc,EAAIb,QAAUe,EAAID,EAAId,QAC5Ba,EAAId,CAAAA,IAAOe,EAAIC,CAAAA,GAAIhB,IACvBgB,IAED,OAAOhB,IAAMc,EAAIb,MAAA,GAkEsBS,EAAGH,CAAK,EAAA,GAAM,EAC/CU,GA5DeC,CAAAA,EAAeC,IAC9B,CAAA,MAAAC,EAActB,GACnBA,EAAEL,MAAM,EAAA,EAAIC,OAAO,CAAC2B,EAAKC,KACxBD,EAAIC,CAAAA,GAASD,EAAIC,CAAAA,GAAS,GAAK,EACxBD,GACL,IAEEE,EAAaH,EAAWF,CACxBM,EAAAA,EAAcJ,EAAWD,CAAAA,EAC/B,OAAOM,OAAOC,KAAKH,CAAAA,EAAYI,MAAML,IAASE,EAAYF,CAAAA,GAAS,IAAMC,EAAWD,CAAK,CAAA,CAAA,GAmDvDZ,EAAGH,CAAK,EAAA,GAAM,EAC1CqB,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7CnB,GAAAA,MAAAA,EAA2BgB,KAAKZ,GAChCK,EAAMD,eAAc,EAGtBc,MAAQC,GAAAA,CAC6D,CAIxE,CAAA,EAAA,EAEA/C,EAAM2B,qBAAuB,UAC5BD,OAAAA,GAAAA,MAAAA,EAA8Bc,KAAKX,MAE7B,MAAAI,GAAQJ,EAAAA,KAAKC,IAALD,YAAAA,EAAuBV,GACjCc,GAAAA,MAAAA,EAAOF,eACVE,EAAMF,aAAaiB,YACnBf,EAAAA,EAAMF,aAAe,MAGlBF,KAAKK,gBACRL,KAAKK,cAAc1B,KACnBqB,EAAAA,KAAKK,cAAce,SAAAA,EAGrB,CACD,CACD"}
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import { d as w, S as j } from "./context-object-CVqtbNDv.js";
|
|
2
|
-
import { property as C } from "lit/decorators.js";
|
|
3
|
-
import { combineLatest as L, Subject as x } from "rxjs";
|
|
4
|
-
import { map as A, distinctUntilChanged as S, shareReplay as O, takeUntil as v } from "rxjs/operators";
|
|
5
|
-
function z(i, e, t) {
|
|
6
|
-
if (function(s) {
|
|
7
|
-
if (s == null || typeof s != "object") return !1;
|
|
8
|
-
const p = Object.getPrototypeOf(s);
|
|
9
|
-
return p !== Object.prototype && p !== null && typeof s[Symbol.iterator] == "function";
|
|
10
|
-
}(i)) {
|
|
11
|
-
const s = w.getInstance(e, t, i);
|
|
12
|
-
return s.value.size || s.$.next(i), s;
|
|
13
|
-
}
|
|
14
|
-
if (typeof i == "object" && i !== null) {
|
|
15
|
-
if (e === "indexeddb") throw new Error("IndexedDB storage is not supported for plain objects.");
|
|
16
|
-
const s = j.getInstance(e, t, i);
|
|
17
|
-
return typeof (n = s.value) == "object" && n !== null && Object.keys(n).length === 0 && s.$.next(i), s;
|
|
18
|
-
}
|
|
19
|
-
throw new Error("Initial data must be an object or a Map.");
|
|
20
|
-
var n;
|
|
21
|
-
}
|
|
22
|
-
const J = (i, e) => e.split(".").reduce((t, n) => t == null ? void 0 : t[n], i), k = (i) => {
|
|
23
|
-
const e = [];
|
|
24
|
-
for (let t = 0; t < i.length - 1; t++) e.push(i.substring(t, t + 2));
|
|
25
|
-
return e;
|
|
26
|
-
}, N = (i, e) => {
|
|
27
|
-
const t = i.toLowerCase().trim(), n = e.toLowerCase().trim(), s = t.includes(n) ? 1 : 0, p = ((a, u) => {
|
|
28
|
-
let o = 0, r = 0;
|
|
29
|
-
for (; o < a.length && r < u.length; ) a[o] === u[r] && o++, r++;
|
|
30
|
-
return o === a.length;
|
|
31
|
-
})(n, t) ? 0.8 : 0, g = ((a, u) => {
|
|
32
|
-
const o = (h) => h.split("").reduce((b, y) => (b[y] = (b[y] || 0) + 1, b), {}), r = o(a), l = o(u);
|
|
33
|
-
return Object.keys(r).every((h) => (l[h] || 0) >= r[h]);
|
|
34
|
-
})(n, t) ? 0.7 : 0, d = ((a, u) => {
|
|
35
|
-
if (a.length < 2 || u.length < 2) return 0;
|
|
36
|
-
const o = k(a), r = k(u);
|
|
37
|
-
let l = 0;
|
|
38
|
-
const h = new Array(r.length).fill(!1);
|
|
39
|
-
for (const b of o) for (let y = 0; y < r.length; y++) if (!h[y] && r[y] === b) {
|
|
40
|
-
l++, h[y] = !0;
|
|
41
|
-
break;
|
|
42
|
-
}
|
|
43
|
-
return 2 * l / (o.length + r.length);
|
|
44
|
-
})(t, n), c = Math.max(t.length, n.length), f = c ? 1 - ((a, u) => {
|
|
45
|
-
const o = [];
|
|
46
|
-
for (let r = 0; r <= u.length; r++) o[r] = [r];
|
|
47
|
-
for (let r = 0; r <= a.length; r++) o[0][r] = r;
|
|
48
|
-
for (let r = 1; r <= u.length; r++) for (let l = 1; l <= a.length; l++) u.charAt(r - 1) === a.charAt(l - 1) ? o[r][l] = o[r - 1][l - 1] : o[r][l] = Math.min(o[r - 1][l] + 1, o[r][l - 1] + 1, o[r - 1][l - 1] + 1);
|
|
49
|
-
return o[u.length][a.length];
|
|
50
|
-
})(t, n) / c : 1;
|
|
51
|
-
return Math.max(s, p, g, d, f);
|
|
52
|
-
}, M = (i, e, t) => {
|
|
53
|
-
switch (i) {
|
|
54
|
-
case "==":
|
|
55
|
-
return e === t;
|
|
56
|
-
case "!=":
|
|
57
|
-
return e !== t;
|
|
58
|
-
case ">":
|
|
59
|
-
return e > t;
|
|
60
|
-
case "<":
|
|
61
|
-
return e < t;
|
|
62
|
-
case ">=":
|
|
63
|
-
return e >= t;
|
|
64
|
-
case "<=":
|
|
65
|
-
return e <= t;
|
|
66
|
-
case "includes":
|
|
67
|
-
return typeof e == "string" ? e.toLowerCase().includes(String(t).toLowerCase()) : !!Array.isArray(e) && e.includes(t);
|
|
68
|
-
case "notIncludes":
|
|
69
|
-
return typeof e == "string" ? !e.toLowerCase().includes(String(t).toLowerCase()) : !!Array.isArray(e) && !e.includes(t);
|
|
70
|
-
case "startsWith":
|
|
71
|
-
return typeof e == "string" && e.startsWith(String(t));
|
|
72
|
-
case "endsWith":
|
|
73
|
-
return typeof e == "string" && e.endsWith(String(t));
|
|
74
|
-
case "in":
|
|
75
|
-
return !!Array.isArray(t) && t.includes(e);
|
|
76
|
-
case "notIn":
|
|
77
|
-
return !!Array.isArray(t) && !t.includes(e);
|
|
78
|
-
default:
|
|
79
|
-
return !1;
|
|
80
|
-
}
|
|
81
|
-
}, I = (i, e = []) => {
|
|
82
|
-
const t = Array.from(i.values()).map((n) => {
|
|
83
|
-
let s = 0, p = 0, g = !0;
|
|
84
|
-
for (const d of e) {
|
|
85
|
-
let c, f, a, u = !1;
|
|
86
|
-
if (Array.isArray(d) ? ([c, f, a, u = !1] = d, u = !!u) : (c = d.key, f = d.operator, a = d.value, u = d.strict || !1), !u && (a === "" || a == null || Array.isArray(a) && a.length === 0)) continue;
|
|
87
|
-
const o = J(n, c);
|
|
88
|
-
if (u) {
|
|
89
|
-
if (o !== a) {
|
|
90
|
-
g = !1;
|
|
91
|
-
break;
|
|
92
|
-
}
|
|
93
|
-
s += 1, p++;
|
|
94
|
-
} else if (f === "any") {
|
|
95
|
-
if (typeof o != "string" || typeof a != "string") {
|
|
96
|
-
g = !1;
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
const r = N(o, a);
|
|
100
|
-
if (r < 0.3) {
|
|
101
|
-
g = !1;
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
s += r, p++;
|
|
105
|
-
} else {
|
|
106
|
-
if (!M(f, o, a)) {
|
|
107
|
-
g = !1;
|
|
108
|
-
break;
|
|
109
|
-
}
|
|
110
|
-
s += 1, p++;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
return g ? { item: n, score: p > 0 ? s / p : 1 } : null;
|
|
114
|
-
}).filter((n) => n !== null);
|
|
115
|
-
return t.sort((n, s) => s.score - n.score), t.map((n) => n.item);
|
|
116
|
-
}, B = I;
|
|
117
|
-
function E(i, e) {
|
|
118
|
-
return i.$.pipe(A(e), S((t, n) => JSON.stringify(t) === JSON.stringify(n)), O(1));
|
|
119
|
-
}
|
|
120
|
-
function m(i, e) {
|
|
121
|
-
return i.$.pipe(A(e), S((t, n) => t instanceof Map && n instanceof Map ? JSON.stringify(Array.from(t.entries())) === JSON.stringify(Array.from(n.entries())) : JSON.stringify(t) === JSON.stringify(n)), O(1));
|
|
122
|
-
}
|
|
123
|
-
function D(i, e) {
|
|
124
|
-
return m(i, (t) => {
|
|
125
|
-
const n = [];
|
|
126
|
-
return t.forEach((s, p) => {
|
|
127
|
-
e(s, p) && n.push(s);
|
|
128
|
-
}), n;
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
function P(i, e) {
|
|
132
|
-
return m(i, (t) => t.get(e));
|
|
133
|
-
}
|
|
134
|
-
function R(i, e) {
|
|
135
|
-
return m(i, (t) => {
|
|
136
|
-
if (!e) return t.size;
|
|
137
|
-
let n = 0;
|
|
138
|
-
return t.forEach((s, p) => {
|
|
139
|
-
e(s, p) && n++;
|
|
140
|
-
}), n;
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
function F(i, e) {
|
|
144
|
-
return L(i).pipe(A((t) => e(...t)), S((t, n) => JSON.stringify(t) === JSON.stringify(n)), O(1));
|
|
145
|
-
}
|
|
146
|
-
function G(i, e = (n) => n, t = {}) {
|
|
147
|
-
return function(n, s, p) {
|
|
148
|
-
C({ attribute: !1, type: Object })(n, s);
|
|
149
|
-
const g = n.connectedCallback, d = n.disconnectedCallback;
|
|
150
|
-
n.connectedCallback = function() {
|
|
151
|
-
var u;
|
|
152
|
-
const c = this;
|
|
153
|
-
c.t || (c.t = {}), c.t[s] || (c.t[s] = { subscription: null, initialLoad: !1 });
|
|
154
|
-
const f = c.t[s];
|
|
155
|
-
!((u = c.disconnecting) != null && u.closed) && c.disconnecting || (c.disconnecting = new x());
|
|
156
|
-
const a = function(o) {
|
|
157
|
-
return "set" in o && typeof o.set == "function" && o.value instanceof Map;
|
|
158
|
-
}(i) ? m(i, e) : E(i, e);
|
|
159
|
-
t.required || f.initialLoad || (g == null || g.call(c), f.initialLoad = !0), f.subscription || (f.subscription = a.pipe(v(c.disconnecting)).subscribe({ next: (o) => {
|
|
160
|
-
var l;
|
|
161
|
-
const r = structuredClone(o);
|
|
162
|
-
c[s] = r, (l = c.requestUpdate) == null || l.call(c), t.required && !f.initialLoad && r && (g == null || g.call(c), f.initialLoad = !0);
|
|
163
|
-
}, error: (o) => {
|
|
164
|
-
} }));
|
|
165
|
-
}, n.disconnectedCallback = function() {
|
|
166
|
-
var f;
|
|
167
|
-
d == null || d.call(this);
|
|
168
|
-
const c = (f = this.t) == null ? void 0 : f[s];
|
|
169
|
-
c != null && c.subscription && (c.subscription.unsubscribe(), c.subscription = null), this.disconnecting && (this.disconnecting.next(), this.disconnecting.complete());
|
|
170
|
-
};
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
export {
|
|
174
|
-
B as a,
|
|
175
|
-
E as b,
|
|
176
|
-
z as c,
|
|
177
|
-
m as d,
|
|
178
|
-
D as e,
|
|
179
|
-
I as f,
|
|
180
|
-
P as g,
|
|
181
|
-
R as h,
|
|
182
|
-
F as i,
|
|
183
|
-
G as s
|
|
184
|
-
};
|
|
185
|
-
//# sourceMappingURL=selector-hook-BdsJkaE2.js.map
|