@o3r/store-sync 13.0.0-next.3 → 13.0.0-next.31

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.
@@ -1 +1 @@
1
- {"version":3,"file":"o3r-store-sync.mjs","sources":["../../src/deep-fill/deep-fill.ts","../../src/sync-storage/storage-sync.ts","../../src/sync-storage/index.ts","../../src/core/storage-sync.helpers.ts","../../src/core/storage-sync.ts","../../src/o3r-store-sync.ts"],"sourcesContent":["import {\n utils,\n} from '@ama-sdk/core';\nimport {\n deepFill,\n type PrimitiveReviverMapper,\n} from '@o3r/core';\n\nconst mapper: PrimitiveReviverMapper[] = [\n {\n condition: (data) => data instanceof utils.DateTime,\n construct: (data) => new utils.DateTime(data)\n },\n {\n condition: (data) => data instanceof utils.Date,\n construct: (data) => new utils.Date(data)\n }\n];\n\n/**\n * Deep fill of base object using source\n * It will do a deep merge of the objects, overriding arrays\n * All properties not present in source, but present in base, will remain\n * @param base\n * @param source\n */\nexport function deepFillWithDate<T extends { [x: string]: any }>(base: T, source?: { [x: string]: any }): T {\n return deepFill(base, source, mapper);\n}\n","import {\n INIT,\n UPDATE,\n} from '@ngrx/store';\nimport {\n deepFill,\n} from '@o3r/core';\nimport type {\n Logger,\n} from '@o3r/core';\nimport type {\n StorageKeyConfiguration,\n StorageKeys,\n SyncStorageConfig,\n SyncStorageSyncOptions,\n} from './interfaces';\n\n/**\n * Reviver the date from a JSON field if the string is matching iso format. Return the same value otherwise\n * @param _key JSON item key name\n * @param value JSON item value\n */\nexport const dateReviver = (_key: string, value: any) => {\n if (typeof value === 'string' && /\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}.\\d{3}Z/.test(value)) {\n return new Date(value);\n }\n return value;\n};\n\n/**\n * Dummy reviver returning the value of the field as it is\n * @param _key JSON item key name\n * @param value JSON item value\n */\nconst dummyReviver = (_key: string, value: any) => value;\n\n/**\n * Determine if the code is run in a browser\n */\nconst checkIsBrowserEnv = () => {\n return typeof window !== 'undefined';\n};\n\n/**\n * Validate the keys structure of the registered stores\n * @param keys map of store to synchronize\n */\nconst validateStateKeys = (keys: StorageKeys) => {\n return (keys as any[]).map((key) => {\n let attr = key;\n\n if (typeof key === 'object') {\n attr = Object.keys(key)[0];\n }\n\n if (typeof attr !== 'string') {\n throw new TypeError(\n 'localStorageSync Unknown Parameter Type: ' + `Expected type of string, got ${typeof attr}`\n );\n }\n return key;\n });\n};\n\n/**\n * Rehydrate the state of the whole application store\n * @param keys Keys of the store to rehydrate\n * @param storage storage when getting the data from\n * @param storageKeySerializer storage key transform function\n * @param restoreDates determine if the date need to be restored\n * @param logger\n */\nexport const rehydrateApplicationState = (\n keys: StorageKeys,\n storage: Storage | undefined,\n storageKeySerializer: (key: string) => string,\n restoreDates: boolean,\n logger: Logger = console\n) => {\n return (keys as any[]).reduce((acc, curr) => {\n let key = curr;\n let reviver = restoreDates ? dateReviver : dummyReviver;\n let deserialize: ((arg0: string) => any) | undefined;\n let decrypt: ((arg0: string) => string) | undefined;\n let syncForFeature = false;\n\n if (typeof key === 'object') {\n key = Object.keys(key)[0];\n syncForFeature = !!(curr?.[key] as SyncStorageSyncOptions)?.syncForFeature;\n\n // use the custom reviver function\n if (typeof curr[key] === 'function') {\n reviver = curr[key];\n } else {\n // use custom reviver function if available\n if (curr[key].reviver) {\n reviver = curr[key].reviver;\n }\n // use custom serialize function if available\n if (curr[key].deserialize) {\n deserialize = curr[key].deserialize;\n }\n }\n\n // Ensure that encrypt and decrypt functions are both present\n if (curr[key].encrypt && curr[key].decrypt) {\n if (typeof curr[key].encrypt === 'function' && typeof curr[key].decrypt === 'function') {\n decrypt = curr[key].decrypt;\n } else {\n logger.error(`Either encrypt or decrypt is not a function on '${curr[key] as string}' key object.`);\n }\n } else if (curr[key].encrypt || curr[key].decrypt) {\n // Let know that one of the encryption functions is not provided\n logger.error(`Either encrypt or decrypt function is not present on '${curr[key] as string}' key object.`);\n }\n }\n if (storage !== undefined) {\n let stateSlice = storage.getItem(storageKeySerializer(key));\n if (stateSlice) {\n // Use provided decrypt function\n if (decrypt) {\n stateSlice = decrypt(stateSlice);\n }\n\n const isObjectRegex = new RegExp('{|\\\\[');\n let raw = stateSlice;\n\n if (stateSlice === 'null' || stateSlice === 'true' || stateSlice === 'false' || isObjectRegex.test(stateSlice.charAt(0))) {\n raw = JSON.parse(stateSlice, reviver);\n }\n\n const rehydratedState = deserialize ? deserialize(raw) : raw;\n\n return syncForFeature\n ? rehydratedState\n : Object.assign({}, acc, {\n [key]: rehydratedState\n });\n }\n }\n return acc;\n }, {});\n};\n\n// Recursively traverse all properties of the existing slice as defined by the `filter` argument,\n// and output the new object with extraneous properties removed.\nfunction createStateSlice(existingSlice: any, filter: (string | number | StorageKeyConfiguration | SyncStorageSyncOptions)[]) {\n return filter.reduce(\n (memo: { [x: string]: any;[x: number]: any }, attr: string | number | StorageKeyConfiguration | SyncStorageSyncOptions) => {\n if (typeof attr === 'string' || typeof attr === 'number') {\n const value = existingSlice?.[attr];\n if (value !== undefined) {\n memo[attr] = value;\n }\n } else {\n for (const key in attr) {\n if (Object.prototype.hasOwnProperty.call(attr, key)) {\n const element: any = attr[key as keyof typeof attr];\n memo[key] = createStateSlice(existingSlice[key], element);\n }\n }\n }\n return memo;\n },\n {}\n );\n}\n\n/**\n * Update the state of the store after reviving from storage\n * Note: this function is mainly use for internal process of store synchronization\n * @param state store state\n * @param keys key of the store\n * @param storage storage to use for the synchronization\n * @param storageKeySerializer callback to serialize the store key\n * @param removeOnUndefined Define if the store should be clean in the storage if undefined\n * @param syncCondition callback to define if the synchronization should be process\n * @param logger Logger to report messages\n */\nexport const syncStateUpdate = (\n state: any,\n keys: StorageKeys,\n storage: Storage | undefined,\n storageKeySerializer: (key: string | number) => string,\n removeOnUndefined = false,\n syncCondition?: (state: any) => any,\n logger: Logger = console\n) => {\n if (syncCondition) {\n try {\n if (syncCondition(state) !== true) {\n return;\n }\n } catch (e) {\n // Treat TypeError as do not sync\n if (e instanceof TypeError) {\n return;\n }\n throw e;\n }\n }\n\n keys.forEach((key: string | StorageKeyConfiguration | SyncStorageSyncOptions | ((key: string, value: any) => any)): void => {\n let stateSlice = state?.[key as string];\n let replacer;\n let space: string | number | undefined;\n let encrypt;\n let syncForFeature = false;\n\n if (typeof key === 'object') {\n const name = (Object.keys(key) as (keyof typeof key)[])[0];\n syncForFeature = !!(key?.[name] as SyncStorageSyncOptions)?.syncForFeature;\n stateSlice = syncForFeature ? state : state?.[name];\n\n if (typeof stateSlice !== 'undefined' && key[name]) {\n // use serialize function if specified.\n if ((key[name] as any).serialize) {\n stateSlice = (key[name] as SyncStorageSyncOptions).serialize!(stateSlice);\n } else {\n // if serialize function is not specified filter on fields if an array has been provided.\n let filter: StorageKeyConfiguration[] | undefined;\n if ((key[name] as any).reduce) {\n filter = key[name] as StorageKeyConfiguration[];\n } else if ((key[name] as any).filter) {\n filter = (key[name] as any).filter as StorageKeyConfiguration[];\n }\n if (filter) {\n stateSlice = createStateSlice(stateSlice, filter);\n }\n\n // Check if encrypt and decrypt are present, also checked at this#rehydrateApplicationState()\n if ((key[name] as any).encrypt && (key[name] as any).decrypt) {\n if (typeof (key[name] as any).encrypt === 'function') {\n encrypt = (key[name] as any).encrypt;\n }\n } else if ((key[name] as any).encrypt || (key[name] as any).decrypt) {\n // If one of those is not present, then let know that one is missing\n logger.error(\n `Either encrypt or decrypt function is not present on '${key[name] as string}' key object.`\n );\n }\n }\n\n /*\n Replacer and space arguments to pass to JSON.stringify.\n If these fields don't exist, undefined will be passed.\n */\n replacer = (key[name] as any).replacer;\n space = (key[name] as any).space;\n }\n\n key = name;\n } else if (typeof key === 'string') {\n stateSlice = syncForFeature ? state : state?.[key];\n }\n\n if (typeof stateSlice !== 'undefined' && storage !== undefined) {\n try {\n if (encrypt) {\n // ensure that a string message is passed\n stateSlice = encrypt(\n typeof stateSlice === 'string' ? stateSlice : JSON.stringify(stateSlice, replacer, space)\n );\n }\n storage.setItem(\n storageKeySerializer(key as string),\n typeof stateSlice === 'string' ? stateSlice : JSON.stringify(stateSlice, replacer, space)\n );\n } catch (e) {\n logger.warn('Unable to save state to localStorage:', e);\n }\n } else if (typeof stateSlice === 'undefined' && removeOnUndefined && storage !== undefined) {\n try {\n storage.removeItem(storageKeySerializer(key as string));\n } catch (e) {\n logger.warn(`Exception on removing/cleaning undefined '${key as string}' state`, e);\n }\n }\n });\n};\n\nconst defaultMergeReducer = (state: any, rehydratedState: any, action: any) => {\n if ((action.type === INIT || action.type === UPDATE) && rehydratedState) {\n const allKeys = Array.from(new Set([...Object.keys(state), ...Object.keys(rehydratedState)]));\n state = Object.fromEntries(allKeys.map((key) => {\n // No need to create new object reference if no merge is actually needed\n if (!rehydratedState[key]) {\n return [key, state[key]];\n } else if (state[key]) {\n return [key, deepFill(state[key], rehydratedState[key])];\n } else {\n return [key, rehydratedState[key]];\n }\n }));\n }\n\n return state;\n};\n\n/**\n * Local and Session storage synchronization helper\n * @param config\n */\nexport const syncStorage = (config: SyncStorageConfig) => (reducer: any) => {\n if (\n (config.storage === undefined && !config.checkStorageAvailability)\n || (config.checkStorageAvailability && checkIsBrowserEnv())\n ) {\n config.storage = localStorage || window.localStorage;\n }\n\n if (config.storageKeySerializer === undefined) {\n config.storageKeySerializer = (key) => key;\n }\n\n if (config.restoreDates === undefined) {\n config.restoreDates = true;\n }\n\n // Use default merge reducer.\n let mergeReducer = config.mergeReducer;\n\n if (mergeReducer === undefined || typeof mergeReducer !== 'function') {\n mergeReducer = defaultMergeReducer;\n }\n\n const logger = config.logger || console;\n\n const stateKeys = validateStateKeys(config.keys);\n const rehydratedState = config.rehydrate\n ? rehydrateApplicationState(stateKeys, config.storage, config.storageKeySerializer, config.restoreDates, logger)\n : undefined;\n\n return (state: any, action: any) => {\n let nextState: any;\n\n // If state arrives undefined, we need to let it through the supplied reducer\n // in order to get a complete state as defined by user\n nextState = action.type === INIT && !state ? reducer(state, action) : { ...state };\n\n // Merge the store state with the rehydrated state using\n // either a user-defined reducer or the default.\n nextState = mergeReducer(nextState, rehydratedState, action);\n\n nextState = reducer(nextState, action);\n\n if (action.type !== INIT) {\n syncStateUpdate(\n nextState,\n (typeof config.syncKeyCondition === 'function')\n ? stateKeys.filter((key) => {\n const keyName = typeof key === 'object' ? Object.keys(key)[0] : key;\n return config.syncKeyCondition!(keyName, nextState);\n })\n : stateKeys,\n config.storage,\n config.storageKeySerializer as (key: string | number) => string,\n config.removeOnUndefined,\n config.syncCondition,\n logger\n );\n }\n if (config.postProcess) {\n config.postProcess(nextState);\n }\n return nextState;\n };\n};\n","/*\n * This file is a fork of the package ngrx-store-localstorage (https://github.com/btroncone/ngrx-store-localstorage) - MIT\n * The following update as been added:\n * - properly export dateReviver function\n * - add missing comments\n * - explicit dependency to @ngrx/store for action names\n * - change interface names to prefix with \"sync\"\n * - add logger support\n * - fix lint according to eslint rules\n * - split code in several files\n * - migrate tests to Jest\n */\n\nexport * from './interfaces';\nexport * from './storage-sync';\n","import {\n createAction,\n props,\n} from '@ngrx/store';\nimport type {\n Serializer,\n} from '@o3r/core';\nimport type {\n SyncStorageConfig,\n} from '../sync-storage';\nimport type {\n StorageSyncOptions,\n} from './interfaces';\n\n/**\n * Defines if an object is a Serializer\n * @param obj Object to test\n * @returns True if the object is a Serializer\n */\nexport const isSerializer = (obj: any): obj is Serializer<any> => !!(obj.serialize || obj.deserialize || obj.reviver || obj.replacer || obj.initialState);\n\n/**\n * Label of the action to rehydrate the store\n */\nexport const REHYDRATE_ACTION_LABEL = '[storeSync] rehydrate';\n\n/**\n * Action to rehydrate the store\n */\nexport const rehydrateAction = createAction(REHYDRATE_ACTION_LABEL, props<{\n payload: Record<string, any>;\n}>());\n\n/**\n * Defines if the storage is a non-async storage\n * @param options The storage config\n * @returns in case the storage used is a non-async storage\n */\nexport const isLocalStorageConfig = (options: StorageSyncOptions): options is SyncStorageConfig => !options.storage || options.storage instanceof Storage;\n","import {\n INIT,\n UPDATE,\n} from '@ngrx/store';\nimport equal from 'fast-deep-equal';\nimport {\n deepFillWithDate,\n} from '../deep-fill/deep-fill';\nimport {\n syncStorage,\n} from '../sync-storage';\nimport type {\n StorageSyncOptions,\n} from './interfaces';\nimport {\n StorageSyncConstructorOptions,\n} from './interfaces';\nimport {\n isLocalStorageConfig,\n isSerializer,\n rehydrateAction,\n} from './storage-sync.helpers';\n\n/**\n * Storage synchronizer\n */\nexport class StorageSync {\n private readonly alreadyHydratedStoreSlices: Set<string> = new Set();\n private hasHydrated = false;\n private readonly storeImage: { [key: string]: any } = {};\n\n public options: StorageSyncOptions;\n\n constructor(options?: StorageSyncConstructorOptions, extraOptions?: { disableSmartSync: boolean }) {\n this.options = {\n keys: [],\n ...(extraOptions?.disableSmartSync\n ? {}\n : {\n syncKeyCondition: (key, state) => !equal(this.storeImage[key], state[key]),\n postProcess: (state) => {\n this.options.keys.forEach((key) => {\n const keyName: string = typeof key === 'object' ? Object.keys(key)[0] : key;\n this.storeImage[keyName] = state[keyName];\n });\n }\n }),\n ...options,\n storage: options?.storage as unknown as Storage,\n mergeReducer: typeof options?.mergeReducer === 'function' ? options.mergeReducer : this.mergeReducer\n };\n }\n\n /**\n * Handle state manipulation in case of store storage sync\n * Merge strategy is a full merge at init; When a new `store slice` is registered, its initial state is merged with its corresponding storage content\n * Pass it as mergeReducer callback when calling localStorageSync function from 'ngrx-store-localstorage', in the app\n * @param state actual state\n * @param rehydratedState state from storage\n * @param action Triggered action\n */\n public readonly mergeReducer = (state: any, rehydratedState: any, action: any) => {\n if (rehydratedState) {\n if (action.type === INIT) {\n state = deepFillWithDate(state, rehydratedState);\n }\n if (action.type === UPDATE && Array.isArray(action.features)) {\n const notHandledFeatures = action.features.filter((featName: string) => !this.alreadyHydratedStoreSlices.has(featName));\n\n notHandledFeatures.filter((featName: string) => !!rehydratedState[featName]).forEach((fName: string) => {\n state[fName] = state[fName] ? deepFillWithDate(state[fName], rehydratedState[fName]) : rehydratedState[fName];\n this.alreadyHydratedStoreSlices.add(fName);\n });\n }\n }\n return state;\n };\n\n /**\n * Returns a meta reducer that handles storage sync\n */\n public localStorageSync = () => {\n const base = (reducer: any) => syncStorage({\n ...this.options,\n rehydrate: false,\n storage: this.options.storage as unknown as Storage,\n syncCondition: () => this.hasHydrated\n })(reducer);\n\n return (reducer: any) => {\n if (isLocalStorageConfig(this.options)) {\n return syncStorage(this.options)(reducer);\n }\n\n return (state: any, action: any) => {\n let hydratedState = state;\n if (action.type === rehydrateAction.type) {\n const hasAlreadyHydrated = this.hasHydrated;\n this.hasHydrated = true;\n const initialStates = this.options.keys.reduce((acc: Record<string, any>, key) => {\n const storeName = Object.keys(key)[0];\n const storeSynchronizer = (key as any)[storeName];\n if (isSerializer(storeSynchronizer)) {\n acc[storeName] = storeSynchronizer.initialState;\n }\n return acc;\n }, {});\n let overrides = {};\n if (!hasAlreadyHydrated) {\n overrides = Object.entries(action.payload).reduce<Record<string, any>>((acc, [storeName, value]) => {\n if (!initialStates[storeName] || initialStates[storeName] === state[storeName]) {\n acc[storeName] = value;\n } else if (initialStates[storeName] !== state[storeName]) {\n (this.options.logger || console).error(`Unable to rehydrate store \"${storeName}\", it has been modified before being hydrated`);\n }\n return acc;\n }, {});\n }\n if (Object.keys(overrides).length > 0) {\n hydratedState = { ...state, ...overrides };\n }\n }\n return base(reducer)(hydratedState, action);\n };\n };\n };\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;AAQA,MAAM,MAAM,GAA6B;AACvC,IAAA;QACE,SAAS,EAAE,CAAC,IAAI,KAAK,IAAI,YAAY,KAAK,CAAC,QAAQ;AACnD,QAAA,SAAS,EAAE,CAAC,IAAI,KAAK,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI;AAC7C,KAAA;AACD,IAAA;QACE,SAAS,EAAE,CAAC,IAAI,KAAK,IAAI,YAAY,KAAK,CAAC,IAAI;AAC/C,QAAA,SAAS,EAAE,CAAC,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,CAAC,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ACR,IAAI,YAAY,EAAE;AAChB,kBAAE;AACF,kBAAE;oBACA,gBAAgB,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;AAC1E,oBAAA,WAAW,EAAE,CAAC,KAAK,KAAI;wBACrB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,KAAI;4BAChC,MAAM,OAAO,GAAW,OAAO,GAAG,KAAK,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG;4BAC3E,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC;AAC3C,yBAAC,CAAC;;iBAEL,CAAC;AACJ,YAAA,GAAG,OAAO;YACV,OAAO,EAAE,OAAO,EAAE,OAA6B;AAC/C,YAAA,YAAY,EAAE,OAAO,OAAO,EAAE,YAAY,KAAK,UAAU,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;SACzF;;AA4EJ;;AC9HD;;AAEG;;;;"}
1
+ {"version":3,"file":"o3r-store-sync.mjs","sources":["../../src/deep-fill/deep-fill.ts","../../src/sync-storage/storage-sync.ts","../../src/sync-storage/index.ts","../../src/core/storage-sync.helpers.ts","../../src/core/storage-sync.ts","../../src/o3r-store-sync.ts"],"sourcesContent":["import {\n utils,\n} from '@ama-sdk/core';\nimport {\n deepFill,\n type PrimitiveReviverMapper,\n} from '@o3r/core';\n\nconst mapper: PrimitiveReviverMapper[] = [\n {\n condition: (data) => data instanceof utils.DateTime,\n construct: (data) => new utils.DateTime(data)\n },\n {\n condition: (data) => data instanceof utils.Date,\n construct: (data) => new utils.Date(data)\n }\n];\n\n/**\n * Deep fill of base object using source\n * It will do a deep merge of the objects, overriding arrays\n * All properties not present in source, but present in base, will remain\n * @param base\n * @param source\n */\nexport function deepFillWithDate<T extends { [x: string]: any }>(base: T, source?: { [x: string]: any }): T {\n return deepFill(base, source, mapper);\n}\n","import {\n INIT,\n UPDATE,\n} from '@ngrx/store';\nimport {\n deepFill,\n} from '@o3r/core';\nimport type {\n Logger,\n} from '@o3r/core';\nimport type {\n StorageKeyConfiguration,\n StorageKeys,\n SyncStorageConfig,\n SyncStorageSyncOptions,\n} from './interfaces';\n\n/**\n * Reviver the date from a JSON field if the string is matching iso format. Return the same value otherwise\n * @param _key JSON item key name\n * @param value JSON item value\n */\nexport const dateReviver = (_key: string, value: any) => {\n if (typeof value === 'string' && /\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}.\\d{3}Z/.test(value)) {\n return new Date(value);\n }\n return value;\n};\n\n/**\n * Dummy reviver returning the value of the field as it is\n * @param _key JSON item key name\n * @param value JSON item value\n */\nconst dummyReviver = (_key: string, value: any) => value;\n\n/**\n * Determine if the code is run in a browser\n */\nconst checkIsBrowserEnv = () => {\n return typeof window !== 'undefined';\n};\n\n/**\n * Validate the keys structure of the registered stores\n * @param keys map of store to synchronize\n */\nconst validateStateKeys = (keys: StorageKeys) => {\n return (keys as any[]).map((key) => {\n let attr = key;\n\n if (typeof key === 'object') {\n attr = Object.keys(key)[0];\n }\n\n if (typeof attr !== 'string') {\n throw new TypeError(\n 'localStorageSync Unknown Parameter Type: ' + `Expected type of string, got ${typeof attr}`\n );\n }\n return key;\n });\n};\n\n/**\n * Rehydrate the state of the whole application store\n * @param keys Keys of the store to rehydrate\n * @param storage storage when getting the data from\n * @param storageKeySerializer storage key transform function\n * @param restoreDates determine if the date need to be restored\n * @param logger\n */\nexport const rehydrateApplicationState = (\n keys: StorageKeys,\n storage: Storage | undefined,\n storageKeySerializer: (key: string) => string,\n restoreDates: boolean,\n logger: Logger = console\n) => {\n return (keys as any[]).reduce((acc, curr) => {\n let key = curr;\n let reviver = restoreDates ? dateReviver : dummyReviver;\n let deserialize: ((arg0: string) => any) | undefined;\n let decrypt: ((arg0: string) => string) | undefined;\n let syncForFeature = false;\n\n if (typeof key === 'object') {\n key = Object.keys(key)[0];\n syncForFeature = !!(curr?.[key] as SyncStorageSyncOptions)?.syncForFeature;\n\n // use the custom reviver function\n if (typeof curr[key] === 'function') {\n reviver = curr[key];\n } else {\n // use custom reviver function if available\n if (curr[key].reviver) {\n reviver = curr[key].reviver;\n }\n // use custom serialize function if available\n if (curr[key].deserialize) {\n deserialize = curr[key].deserialize;\n }\n }\n\n // Ensure that encrypt and decrypt functions are both present\n if (curr[key].encrypt && curr[key].decrypt) {\n if (typeof curr[key].encrypt === 'function' && typeof curr[key].decrypt === 'function') {\n decrypt = curr[key].decrypt;\n } else {\n logger.error(`Either encrypt or decrypt is not a function on '${curr[key] as string}' key object.`);\n }\n } else if (curr[key].encrypt || curr[key].decrypt) {\n // Let know that one of the encryption functions is not provided\n logger.error(`Either encrypt or decrypt function is not present on '${curr[key] as string}' key object.`);\n }\n }\n if (storage !== undefined) {\n let stateSlice = storage.getItem(storageKeySerializer(key));\n if (stateSlice) {\n // Use provided decrypt function\n if (decrypt) {\n stateSlice = decrypt(stateSlice);\n }\n\n const isObjectRegex = new RegExp('{|\\\\[');\n let raw = stateSlice;\n\n if (stateSlice === 'null' || stateSlice === 'true' || stateSlice === 'false' || isObjectRegex.test(stateSlice.charAt(0))) {\n raw = JSON.parse(stateSlice, reviver);\n }\n\n const rehydratedState = deserialize ? deserialize(raw) : raw;\n\n return syncForFeature\n ? rehydratedState\n : Object.assign({}, acc, {\n [key]: rehydratedState\n });\n }\n }\n return acc;\n }, {});\n};\n\n// Recursively traverse all properties of the existing slice as defined by the `filter` argument,\n// and output the new object with extraneous properties removed.\nfunction createStateSlice(existingSlice: any, filter: (string | number | StorageKeyConfiguration | SyncStorageSyncOptions)[]) {\n return filter.reduce(\n (memo: { [x: string]: any; [x: number]: any }, attr: string | number | StorageKeyConfiguration | SyncStorageSyncOptions) => {\n if (typeof attr === 'string' || typeof attr === 'number') {\n const value = existingSlice?.[attr];\n if (value !== undefined) {\n memo[attr] = value;\n }\n } else {\n for (const key in attr) {\n if (Object.prototype.hasOwnProperty.call(attr, key)) {\n const element: any = attr[key as keyof typeof attr];\n memo[key] = createStateSlice(existingSlice[key], element);\n }\n }\n }\n return memo;\n },\n {}\n );\n}\n\n/**\n * Update the state of the store after reviving from storage\n * Note: this function is mainly use for internal process of store synchronization\n * @param state store state\n * @param keys key of the store\n * @param storage storage to use for the synchronization\n * @param storageKeySerializer callback to serialize the store key\n * @param removeOnUndefined Define if the store should be clean in the storage if undefined\n * @param syncCondition callback to define if the synchronization should be process\n * @param logger Logger to report messages\n */\nexport const syncStateUpdate = (\n state: any,\n keys: StorageKeys,\n storage: Storage | undefined,\n storageKeySerializer: (key: string | number) => string,\n removeOnUndefined = false,\n syncCondition?: (state: any) => any,\n logger: Logger = console\n) => {\n if (syncCondition) {\n try {\n if (syncCondition(state) !== true) {\n return;\n }\n } catch (e) {\n // Treat TypeError as do not sync\n if (e instanceof TypeError) {\n return;\n }\n throw e;\n }\n }\n\n keys.forEach((key: string | StorageKeyConfiguration | SyncStorageSyncOptions | ((key: string, value: any) => any)): void => {\n let stateSlice = state?.[key as string];\n let replacer;\n let space: string | number | undefined;\n let encrypt;\n let syncForFeature = false;\n\n if (typeof key === 'object') {\n const name = (Object.keys(key) as (keyof typeof key)[])[0];\n syncForFeature = !!(key?.[name] as SyncStorageSyncOptions)?.syncForFeature;\n stateSlice = syncForFeature ? state : state?.[name];\n\n if (typeof stateSlice !== 'undefined' && key[name]) {\n // use serialize function if specified.\n if ((key[name] as any).serialize) {\n stateSlice = (key[name] as SyncStorageSyncOptions).serialize!(stateSlice);\n } else {\n // if serialize function is not specified filter on fields if an array has been provided.\n let filter: StorageKeyConfiguration[] | undefined;\n if ((key[name] as any).reduce) {\n filter = key[name] as StorageKeyConfiguration[];\n } else if ((key[name] as any).filter) {\n filter = (key[name] as any).filter as StorageKeyConfiguration[];\n }\n if (filter) {\n stateSlice = createStateSlice(stateSlice, filter);\n }\n\n // Check if encrypt and decrypt are present, also checked at this#rehydrateApplicationState()\n if ((key[name] as any).encrypt && (key[name] as any).decrypt) {\n if (typeof (key[name] as any).encrypt === 'function') {\n encrypt = (key[name] as any).encrypt;\n }\n } else if ((key[name] as any).encrypt || (key[name] as any).decrypt) {\n // If one of those is not present, then let know that one is missing\n logger.error(\n `Either encrypt or decrypt function is not present on '${key[name] as string}' key object.`\n );\n }\n }\n\n /*\n Replacer and space arguments to pass to JSON.stringify.\n If these fields don't exist, undefined will be passed.\n */\n replacer = (key[name] as any).replacer;\n space = (key[name] as any).space;\n }\n\n key = name;\n } else if (typeof key === 'string') {\n stateSlice = syncForFeature ? state : state?.[key];\n }\n\n if (typeof stateSlice !== 'undefined' && storage !== undefined) {\n try {\n if (encrypt) {\n // ensure that a string message is passed\n stateSlice = encrypt(\n typeof stateSlice === 'string' ? stateSlice : JSON.stringify(stateSlice, replacer, space)\n );\n }\n storage.setItem(\n storageKeySerializer(key as string),\n typeof stateSlice === 'string' ? stateSlice : JSON.stringify(stateSlice, replacer, space)\n );\n } catch (e) {\n logger.warn('Unable to save state to localStorage:', e);\n }\n } else if (typeof stateSlice === 'undefined' && removeOnUndefined && storage !== undefined) {\n try {\n storage.removeItem(storageKeySerializer(key as string));\n } catch (e) {\n logger.warn(`Exception on removing/cleaning undefined '${key as string}' state`, e);\n }\n }\n });\n};\n\nconst defaultMergeReducer = (state: any, rehydratedState: any, action: any) => {\n if ((action.type === INIT || action.type === UPDATE) && rehydratedState) {\n const allKeys = Array.from(new Set([...Object.keys(state), ...Object.keys(rehydratedState)]));\n state = Object.fromEntries(allKeys.map((key) => {\n // No need to create new object reference if no merge is actually needed\n if (!rehydratedState[key]) {\n return [key, state[key]];\n } else if (state[key]) {\n return [key, deepFill(state[key], rehydratedState[key])];\n } else {\n return [key, rehydratedState[key]];\n }\n }));\n }\n\n return state;\n};\n\n/**\n * Local and Session storage synchronization helper\n * @param config\n */\nexport const syncStorage = (config: SyncStorageConfig) => (reducer: any) => {\n if (\n (config.storage === undefined && !config.checkStorageAvailability)\n || (config.checkStorageAvailability && checkIsBrowserEnv())\n ) {\n config.storage = localStorage || window.localStorage;\n }\n\n if (config.storageKeySerializer === undefined) {\n config.storageKeySerializer = (key) => key;\n }\n\n if (config.restoreDates === undefined) {\n config.restoreDates = true;\n }\n\n // Use default merge reducer.\n let mergeReducer = config.mergeReducer;\n\n if (mergeReducer === undefined || typeof mergeReducer !== 'function') {\n mergeReducer = defaultMergeReducer;\n }\n\n const logger = config.logger || console;\n\n const stateKeys = validateStateKeys(config.keys);\n const rehydratedState = config.rehydrate\n ? rehydrateApplicationState(stateKeys, config.storage, config.storageKeySerializer, config.restoreDates, logger)\n : undefined;\n\n return (state: any, action: any) => {\n let nextState: any;\n\n // If state arrives undefined, we need to let it through the supplied reducer\n // in order to get a complete state as defined by user\n nextState = action.type === INIT && !state ? reducer(state, action) : { ...state };\n\n // Merge the store state with the rehydrated state using\n // either a user-defined reducer or the default.\n nextState = mergeReducer(nextState, rehydratedState, action);\n\n nextState = reducer(nextState, action);\n\n if (action.type !== INIT) {\n syncStateUpdate(\n nextState,\n (typeof config.syncKeyCondition === 'function')\n ? stateKeys.filter((key) => {\n const keyName = typeof key === 'object' ? Object.keys(key)[0] : key;\n return config.syncKeyCondition!(keyName, nextState);\n })\n : stateKeys,\n config.storage,\n config.storageKeySerializer as (key: string | number) => string,\n config.removeOnUndefined,\n config.syncCondition,\n logger\n );\n }\n if (config.postProcess) {\n config.postProcess(nextState);\n }\n return nextState;\n };\n};\n","/*\n * This file is a fork of the package ngrx-store-localstorage (https://github.com/btroncone/ngrx-store-localstorage) - MIT\n * The following update as been added:\n * - properly export dateReviver function\n * - add missing comments\n * - explicit dependency to @ngrx/store for action names\n * - change interface names to prefix with \"sync\"\n * - add logger support\n * - fix lint according to eslint rules\n * - split code in several files\n * - migrate tests to Jest\n */\n\nexport * from './interfaces';\nexport * from './storage-sync';\n","import {\n createAction,\n props,\n} from '@ngrx/store';\nimport type {\n Serializer,\n} from '@o3r/core';\nimport type {\n SyncStorageConfig,\n} from '../sync-storage';\nimport type {\n StorageSyncOptions,\n} from './interfaces';\n\n/**\n * Defines if an object is a Serializer\n * @param obj Object to test\n * @returns True if the object is a Serializer\n */\nexport const isSerializer = (obj: any): obj is Serializer<any> => !!(obj.serialize || obj.deserialize || obj.reviver || obj.replacer || obj.initialState);\n\n/**\n * Label of the action to rehydrate the store\n */\nexport const REHYDRATE_ACTION_LABEL = '[storeSync] rehydrate';\n\n/**\n * Action to rehydrate the store\n */\nexport const rehydrateAction = createAction(REHYDRATE_ACTION_LABEL, props<{\n payload: Record<string, any>;\n}>());\n\n/**\n * Defines if the storage is a non-async storage\n * @param options The storage config\n * @returns in case the storage used is a non-async storage\n */\nexport const isLocalStorageConfig = (options: StorageSyncOptions): options is SyncStorageConfig => !options.storage || options.storage instanceof Storage;\n","import {\n INIT,\n UPDATE,\n} from '@ngrx/store';\nimport equal from 'fast-deep-equal';\nimport {\n deepFillWithDate,\n} from '../deep-fill/deep-fill';\nimport {\n syncStorage,\n} from '../sync-storage';\nimport type {\n StorageSyncOptions,\n} from './interfaces';\nimport {\n StorageSyncConstructorOptions,\n} from './interfaces';\nimport {\n isLocalStorageConfig,\n isSerializer,\n rehydrateAction,\n} from './storage-sync.helpers';\n\n/**\n * Storage synchronizer\n */\nexport class StorageSync {\n private readonly alreadyHydratedStoreSlices: Set<string> = new Set();\n private hasHydrated = false;\n private readonly storeImage: { [key: string]: any } = {};\n\n public options: StorageSyncOptions;\n\n constructor(options?: StorageSyncConstructorOptions, extraOptions?: { disableSmartSync: boolean }) {\n this.options = {\n keys: [],\n ...(extraOptions?.disableSmartSync\n ? {}\n : {\n syncKeyCondition: (key, state) => !equal(this.storeImage[key], state[key]),\n postProcess: (state) => {\n this.options.keys.forEach((key) => {\n const keyName: string = typeof key === 'object' ? Object.keys(key)[0] : key;\n this.storeImage[keyName] = state[keyName];\n });\n }\n }),\n ...options,\n storage: options?.storage as unknown as Storage,\n mergeReducer: typeof options?.mergeReducer === 'function' ? options.mergeReducer : this.mergeReducer\n };\n }\n\n /**\n * Handle state manipulation in case of store storage sync\n * Merge strategy is a full merge at init; When a new `store slice` is registered, its initial state is merged with its corresponding storage content\n * Pass it as mergeReducer callback when calling localStorageSync function from 'ngrx-store-localstorage', in the app\n * @param state actual state\n * @param rehydratedState state from storage\n * @param action Triggered action\n */\n public readonly mergeReducer = (state: any, rehydratedState: any, action: any) => {\n if (rehydratedState) {\n if (action.type === INIT) {\n state = deepFillWithDate(state, rehydratedState);\n }\n if (action.type === UPDATE && Array.isArray(action.features)) {\n const notHandledFeatures = action.features.filter((featName: string) => !this.alreadyHydratedStoreSlices.has(featName));\n\n notHandledFeatures.filter((featName: string) => !!rehydratedState[featName]).forEach((fName: string) => {\n state[fName] = state[fName] ? deepFillWithDate(state[fName], rehydratedState[fName]) : rehydratedState[fName];\n this.alreadyHydratedStoreSlices.add(fName);\n });\n }\n }\n return state;\n };\n\n /**\n * Returns a meta reducer that handles storage sync\n */\n public localStorageSync = () => {\n const base = (reducer: any) => syncStorage({\n ...this.options,\n rehydrate: false,\n storage: this.options.storage as unknown as Storage,\n syncCondition: () => this.hasHydrated\n })(reducer);\n\n return (reducer: any) => {\n if (isLocalStorageConfig(this.options)) {\n return syncStorage(this.options)(reducer);\n }\n\n return (state: any, action: any) => {\n let hydratedState = state;\n if (action.type === rehydrateAction.type) {\n const hasAlreadyHydrated = this.hasHydrated;\n this.hasHydrated = true;\n const initialStates = this.options.keys.reduce((acc: Record<string, any>, key) => {\n const storeName = Object.keys(key)[0];\n const storeSynchronizer = (key as any)[storeName];\n if (isSerializer(storeSynchronizer)) {\n acc[storeName] = storeSynchronizer.initialState;\n }\n return acc;\n }, {});\n let overrides = {};\n if (!hasAlreadyHydrated) {\n overrides = Object.entries(action.payload).reduce<Record<string, any>>((acc, [storeName, value]) => {\n if (!initialStates[storeName] || initialStates[storeName] === state[storeName]) {\n acc[storeName] = value;\n } else if (initialStates[storeName] !== state[storeName]) {\n (this.options.logger || console).error(`Unable to rehydrate store \"${storeName}\", it has been modified before being hydrated`);\n }\n return acc;\n }, {});\n }\n if (Object.keys(overrides).length > 0) {\n hydratedState = { ...state, ...overrides };\n }\n }\n return base(reducer)(hydratedState, action);\n };\n };\n };\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;AAQA,MAAM,MAAM,GAA6B;AACvC,IAAA;QACE,SAAS,EAAE,CAAC,IAAI,KAAK,IAAI,YAAY,KAAK,CAAC,QAAQ;AACnD,QAAA,SAAS,EAAE,CAAC,IAAI,KAAK,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI;AAC7C,KAAA;AACD,IAAA;QACE,SAAS,EAAE,CAAC,IAAI,KAAK,IAAI,YAAY,KAAK,CAAC,IAAI;AAC/C,QAAA,SAAS,EAAE,CAAC,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI;AACzC;CACF;AAED;;;;;;AAMG;AACG,SAAU,gBAAgB,CAAiC,IAAO,EAAE,MAA6B,EAAA;IACrG,OAAO,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC;AACvC;;ACXA;;;;AAIG;MACU,WAAW,GAAG,CAAC,IAAY,EAAE,KAAU,KAAI;AACtD,IAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,4CAA4C,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;AACzF,QAAA,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC;IACxB;AACA,IAAA,OAAO,KAAK;AACd;AAEA;;;;AAIG;AACH,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,KAAU,KAAK,KAAK;AAExD;;AAEG;AACH,MAAM,iBAAiB,GAAG,MAAK;AAC7B,IAAA,OAAO,OAAO,MAAM,KAAK,WAAW;AACtC,CAAC;AAED;;;AAGG;AACH,MAAM,iBAAiB,GAAG,CAAC,IAAiB,KAAI;AA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IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,KAAI;4BAChC,MAAM,OAAO,GAAW,OAAO,GAAG,KAAK,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG;4BAC3E,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC;AAC3C,wBAAA,CAAC,CAAC;oBACJ;iBACD,CAAC;AACJ,YAAA,GAAG,OAAO;YACV,OAAO,EAAE,OAAO,EAAE,OAA6B;AAC/C,YAAA,YAAY,EAAE,OAAO,OAAO,EAAE,YAAY,KAAK,UAAU,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;SACzF;IACH;AA2ED;;AC9HD;;AAEG;;;;"}
package/index.d.ts CHANGED
@@ -1,6 +1,188 @@
1
+ import { Logger, Serializer } from '@o3r/core';
2
+ import * as _ngrx_store from '@ngrx/store';
3
+
1
4
  /**
2
- * Generated bundle index. Do not edit.
5
+ * Options to provide to the synchronous store synchronization mechanism
3
6
  */
4
- /// <amd-module name="@o3r/store-sync" />
5
- export * from './public_api';
6
- //# sourceMappingURL=o3r-store-sync.d.ts.map
7
+ interface SyncStorageSyncOptions {
8
+ /** Callback to define the serialization strategy of the store */
9
+ serialize?: (state: any) => any;
10
+ /** Callback to define the deserialization strategy of the store */
11
+ deserialize?: (state: any) => any;
12
+ /** Callback to define the reviving strategy of the store */
13
+ reviver?: (key: string, value: any) => any;
14
+ /** replacer callback function provided to the parser */
15
+ replacer?: ((key: string, value: any) => any) | string[];
16
+ /** Filter to apply to the store fields */
17
+ filter?: string[];
18
+ /** Spacing for serializer */
19
+ space?: string | number;
20
+ /** Defines whether the store is loaded as forFeature */
21
+ syncForFeature?: boolean;
22
+ }
23
+ /**
24
+ * Interface of the configurations for a store
25
+ */
26
+ interface StorageKeyConfiguration {
27
+ [key: string]: string[] | number[] | StorageKeyConfiguration[] | SyncStorageSyncOptions | ((key: string, value: any) => any);
28
+ }
29
+ /**
30
+ * Definition of a store to to synchronize
31
+ */
32
+ type StorageKeys = (StorageKeyConfiguration | SyncStorageSyncOptions | string)[];
33
+ /**
34
+ * Configuration to define the way the stores should be synchronize to the storage
35
+ */
36
+ interface SyncStorageConfig {
37
+ /** Map of the store to synchronize */
38
+ keys: StorageKeys;
39
+ /** Should the stores be initially rehydrated */
40
+ rehydrate?: boolean;
41
+ /** Storage reference */
42
+ storage?: Storage;
43
+ /** Should be removed from storage if undefined */
44
+ removeOnUndefined?: boolean;
45
+ /** Should apply restore date to the restored stores */
46
+ restoreDates?: boolean;
47
+ /** Callback to define the serialization strategy for the store keys */
48
+ storageKeySerializer?: (key: string) => string;
49
+ /** Callback to define the condition to the synchronization */
50
+ syncCondition?: (state: any) => any;
51
+ /** Callback to define the condition to the key synchronization */
52
+ syncKeyCondition?: (key: string, state: any) => boolean;
53
+ /** check the availability of the storage */
54
+ checkStorageAvailability?: boolean;
55
+ /** Merge reducer to use to deserialize the store */
56
+ mergeReducer?: (state: any, rehydratedState: any, action: any) => any;
57
+ /** Logger to report messages */
58
+ logger?: Logger;
59
+ /** Post process after sync storage execution */
60
+ postProcess?: (state: any) => void;
61
+ }
62
+
63
+ /**
64
+ * Reviver the date from a JSON field if the string is matching iso format. Return the same value otherwise
65
+ * @param _key JSON item key name
66
+ * @param value JSON item value
67
+ */
68
+ declare const dateReviver: (_key: string, value: any) => any;
69
+ /**
70
+ * Rehydrate the state of the whole application store
71
+ * @param keys Keys of the store to rehydrate
72
+ * @param storage storage when getting the data from
73
+ * @param storageKeySerializer storage key transform function
74
+ * @param restoreDates determine if the date need to be restored
75
+ * @param logger
76
+ */
77
+ declare const rehydrateApplicationState: (keys: StorageKeys, storage: Storage | undefined, storageKeySerializer: (key: string) => string, restoreDates: boolean, logger?: Logger) => any;
78
+ /**
79
+ * Update the state of the store after reviving from storage
80
+ * Note: this function is mainly use for internal process of store synchronization
81
+ * @param state store state
82
+ * @param keys key of the store
83
+ * @param storage storage to use for the synchronization
84
+ * @param storageKeySerializer callback to serialize the store key
85
+ * @param removeOnUndefined Define if the store should be clean in the storage if undefined
86
+ * @param syncCondition callback to define if the synchronization should be process
87
+ * @param logger Logger to report messages
88
+ */
89
+ declare const syncStateUpdate: (state: any, keys: StorageKeys, storage: Storage | undefined, storageKeySerializer: (key: string | number) => string, removeOnUndefined?: boolean, syncCondition?: (state: any) => any, logger?: Logger) => void;
90
+ /**
91
+ * Local and Session storage synchronization helper
92
+ * @param config
93
+ */
94
+ declare const syncStorage: (config: SyncStorageConfig) => (reducer: any) => (state: any, action: any) => any;
95
+
96
+ /**
97
+ * Format of a key in `StoreSyncConfig`
98
+ */
99
+ interface StoreSyncSerializers {
100
+ [storeName: string]: Serializer<any>;
101
+ }
102
+ /**
103
+ * An interface defining the configuration attributes to bootstrap `storeSyncMetaReducer`
104
+ */
105
+ interface StoreSyncConfig {
106
+ /** State keys to sync with storage */
107
+ keys: StoreSyncSerializers[];
108
+ /** Pull initial state from storage on startup */
109
+ rehydrate?: boolean;
110
+ /** Specify an object that conforms to the Storage interface to use, this will default to localStorage */
111
+ storage?: Storage;
112
+ /** When set, sync to storage will only occur when this function returns a true boolean */
113
+ syncCondition?: (state: any) => any;
114
+ }
115
+ /**
116
+ * Typings for async storage
117
+ */
118
+ type AsyncStorage = Omit<Storage, 'getItem'> & {
119
+ getItem(key: string): Promise<string | null>;
120
+ };
121
+ /**
122
+ * Options for async storage sync
123
+ */
124
+ interface AsyncStorageSyncOptions extends Omit<SyncStorageConfig, 'storage'> {
125
+ storage?: AsyncStorage;
126
+ }
127
+ /** Options for storage sync method */
128
+ type StorageSyncOptions = SyncStorageConfig | AsyncStorageSyncOptions;
129
+ /**
130
+ * Options that can be set on the Storage sync constructor
131
+ * postProcess and syncKeyCondition will be handled by the StorageSync class if smart sync is activated
132
+ */
133
+ type StorageSyncConstructorOptions = Omit<StorageSyncOptions, 'postProcess' | 'syncKeyCondition'>;
134
+
135
+ /**
136
+ * Storage synchronizer
137
+ */
138
+ declare class StorageSync {
139
+ private readonly alreadyHydratedStoreSlices;
140
+ private hasHydrated;
141
+ private readonly storeImage;
142
+ options: StorageSyncOptions;
143
+ constructor(options?: StorageSyncConstructorOptions, extraOptions?: {
144
+ disableSmartSync: boolean;
145
+ });
146
+ /**
147
+ * Handle state manipulation in case of store storage sync
148
+ * Merge strategy is a full merge at init; When a new `store slice` is registered, its initial state is merged with its corresponding storage content
149
+ * Pass it as mergeReducer callback when calling localStorageSync function from 'ngrx-store-localstorage', in the app
150
+ * @param state actual state
151
+ * @param rehydratedState state from storage
152
+ * @param action Triggered action
153
+ */
154
+ readonly mergeReducer: (state: any, rehydratedState: any, action: any) => any;
155
+ /**
156
+ * Returns a meta reducer that handles storage sync
157
+ */
158
+ localStorageSync: () => (reducer: any) => (state: any, action: any) => any;
159
+ }
160
+
161
+ /**
162
+ * Defines if an object is a Serializer
163
+ * @param obj Object to test
164
+ * @returns True if the object is a Serializer
165
+ */
166
+ declare const isSerializer: (obj: any) => obj is Serializer<any>;
167
+ /**
168
+ * Label of the action to rehydrate the store
169
+ */
170
+ declare const REHYDRATE_ACTION_LABEL = "[storeSync] rehydrate";
171
+ /**
172
+ * Action to rehydrate the store
173
+ */
174
+ declare const rehydrateAction: _ngrx_store.ActionCreator<"[storeSync] rehydrate", (props: {
175
+ payload: Record<string, any>;
176
+ }) => {
177
+ payload: Record<string, any>;
178
+ } & _ngrx_store.Action<"[storeSync] rehydrate">>;
179
+ /**
180
+ * Defines if the storage is a non-async storage
181
+ * @param options The storage config
182
+ * @returns in case the storage used is a non-async storage
183
+ */
184
+ declare const isLocalStorageConfig: (options: StorageSyncOptions) => options is SyncStorageConfig;
185
+
186
+ export { REHYDRATE_ACTION_LABEL, StorageSync, dateReviver, isLocalStorageConfig, isSerializer, rehydrateAction, rehydrateApplicationState, syncStateUpdate, syncStorage };
187
+ export type { AsyncStorage, AsyncStorageSyncOptions, StorageKeyConfiguration, StorageKeys, StorageSyncConstructorOptions, StorageSyncOptions, StoreSyncConfig, StoreSyncSerializers, SyncStorageConfig, SyncStorageSyncOptions };
188
+ //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sources":["../src/sync-storage/interfaces.ts","../src/sync-storage/storage-sync.ts","../src/core/interfaces.ts","../src/core/storage-sync.ts","../src/core/storage-sync.helpers.ts"],"sourcesContent":[null,null,null,null,null],"names":[],"mappings":";;;AAIA;;AAEG;;;;;;;AAOD;;AAEA;;AAEA;;AAEA;;;AAGD;AAED;;AAEG;;;AAGF;AAED;;AAEG;AACG;AAEN;;AAEG;;;;;;;;;;;;;;;;;AAiBD;;;;AAIA;;;;;AAKD;;AC/CD;;;;AAIG;AACH;AA0CA;;;;;;;AAOG;AACH;AAgGA;;;;;;;;;;AAUG;AACH;AAwHA;;;AAGG;AACH;;ACxSA;;AAEG;;;AAGF;AAED;;AAEG;;;;;;;;;;AAUF;AAED;;AAEG;AACG;;;AAIN;;AAEG;AACG;;AAEL;AAED;;AAGA;;;AAGG;AACG;;AC1BN;;AAEG;AACH;AACE;;AAEA;;AAIY;;AAAqF;AAoBjG;;;;;;;AAOG;;AAkBH;;AAEG;;AA8CJ;;AChHD;;;;AAIG;AACH;AAEA;;AAEG;AACH;AAEA;;AAEG;AACH;AACW;;AAAA;;AAGX;;;;AAIG;AACH;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@o3r/store-sync",
3
- "version": "13.0.0-next.3",
3
+ "version": "13.0.0-next.31",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -13,19 +13,19 @@
13
13
  "otter-module"
14
14
  ],
15
15
  "peerDependencies": {
16
- "@ama-sdk/core": "^13.0.0-next.3",
17
- "@angular-devkit/core": "^19.0.0",
18
- "@angular-devkit/schematics": "^19.0.0",
19
- "@ngrx/entity": "^19.0.0",
20
- "@ngrx/store": "^19.0.0",
21
- "@o3r/core": "^13.0.0-next.3",
22
- "@o3r/logger": "^13.0.0-next.3",
23
- "@o3r/schematics": "^13.0.0-next.3",
24
- "@schematics/angular": "^19.0.0",
16
+ "@ama-sdk/core": "^13.0.0-next.31",
17
+ "@angular-devkit/core": "^20.0.0",
18
+ "@angular-devkit/schematics": "^20.0.0",
19
+ "@ngrx/entity": "^20.0.0",
20
+ "@ngrx/store": "^20.0.0",
21
+ "@o3r/core": "^13.0.0-next.31",
22
+ "@o3r/logger": "^13.0.0-next.31",
23
+ "@o3r/schematics": "^13.0.0-next.31",
24
+ "@schematics/angular": "^20.0.0",
25
25
  "fast-deep-equal": "^3.1.3",
26
26
  "rxjs": "^7.8.1",
27
27
  "ts-node": "~10.9.2",
28
- "type-fest": "^4.10.2"
28
+ "type-fest": "^4.30.1"
29
29
  },
30
30
  "peerDependenciesMeta": {
31
31
  "@angular-devkit/core": {
@@ -45,12 +45,12 @@
45
45
  }
46
46
  },
47
47
  "dependencies": {
48
- "@o3r/schematics": "^13.0.0-next.3",
48
+ "@o3r/schematics": "^13.0.0-next.31",
49
49
  "tslib": "^2.6.2"
50
50
  },
51
51
  "schematics": "./collection.json",
52
52
  "engines": {
53
- "node": "^20.11.1 || >=22.0.0"
53
+ "node": "^20.19.0 || ^22.17.0 || ^24.0.0"
54
54
  },
55
55
  "module": "fesm2022/o3r-store-sync.mjs",
56
56
  "typings": "index.d.ts",
@@ -9,12 +9,13 @@
9
9
  "description": "Project name",
10
10
  "$default": {
11
11
  "$source": "projectName"
12
- }
12
+ },
13
+ "alias": "project"
13
14
  },
14
15
  "skipLinter": {
15
16
  "type": "boolean",
16
17
  "description": "Skip the linter process which includes EsLint and EditorConfig rules applying",
17
- "default": true
18
+ "default": false
18
19
  },
19
20
  "exactO3rVersion": {
20
21
  "type": "boolean",
package/core/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export * from './interfaces';
2
- export * from './storage-sync';
3
- export * from './storage-sync.helpers';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC"}
@@ -1,41 +0,0 @@
1
- import type { Serializer } from '@o3r/core';
2
- import type { SyncStorageConfig } from '../sync-storage';
3
- /**
4
- * Format of a key in `StoreSyncConfig`
5
- */
6
- export interface StoreSyncSerializers {
7
- [storeName: string]: Serializer<any>;
8
- }
9
- /**
10
- * An interface defining the configuration attributes to bootstrap `storeSyncMetaReducer`
11
- */
12
- export interface StoreSyncConfig {
13
- /** State keys to sync with storage */
14
- keys: StoreSyncSerializers[];
15
- /** Pull initial state from storage on startup */
16
- rehydrate?: boolean;
17
- /** Specify an object that conforms to the Storage interface to use, this will default to localStorage */
18
- storage?: Storage;
19
- /** When set, sync to storage will only occur when this function returns a true boolean */
20
- syncCondition?: (state: any) => any;
21
- }
22
- /**
23
- * Typings for async storage
24
- */
25
- export type AsyncStorage = Omit<Storage, 'getItem'> & {
26
- getItem(key: string): Promise<string | null>;
27
- };
28
- /**
29
- * Options for async storage sync
30
- */
31
- export interface AsyncStorageSyncOptions extends Omit<SyncStorageConfig, 'storage'> {
32
- storage?: AsyncStorage;
33
- }
34
- /** Options for storage sync method */
35
- export type StorageSyncOptions = SyncStorageConfig | AsyncStorageSyncOptions;
36
- /**
37
- * Options that can be set on the Storage sync constructor
38
- * postProcess and syncKeyCondition will be handled by the StorageSync class if smart sync is activated
39
- */
40
- export type StorageSyncConstructorOptions = Omit<StorageSyncOptions, 'postProcess' | 'syncKeyCondition'>;
41
- //# sourceMappingURL=interfaces.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/core/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACX,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EACV,iBAAiB,EAClB,MAAM,iBAAiB,CAAC;AAEzB;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;CACtC;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,sCAAsC;IACtC,IAAI,EAAE,oBAAoB,EAAE,CAAC;IAC7B,iDAAiD;IACjD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,yGAAyG;IACzG,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,0FAA0F;IAC1F,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC;CACrC;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,GAAG;IACpD,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CAC9C,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,uBAAwB,SAAQ,IAAI,CAAC,iBAAiB,EAAE,SAAS,CAAC;IACjF,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB;AAED,sCAAsC;AACtC,MAAM,MAAM,kBAAkB,GAAG,iBAAiB,GAAG,uBAAuB,CAAC;AAE7E;;;GAGG;AACH,MAAM,MAAM,6BAA6B,GAAG,IAAI,CAAC,kBAAkB,EAAE,aAAa,GAAG,kBAAkB,CAAC,CAAC"}
@@ -1,28 +0,0 @@
1
- import type { StorageSyncOptions } from './interfaces';
2
- import { StorageSyncConstructorOptions } from './interfaces';
3
- /**
4
- * Storage synchronizer
5
- */
6
- export declare class StorageSync {
7
- private readonly alreadyHydratedStoreSlices;
8
- private hasHydrated;
9
- private readonly storeImage;
10
- options: StorageSyncOptions;
11
- constructor(options?: StorageSyncConstructorOptions, extraOptions?: {
12
- disableSmartSync: boolean;
13
- });
14
- /**
15
- * Handle state manipulation in case of store storage sync
16
- * Merge strategy is a full merge at init; When a new `store slice` is registered, its initial state is merged with its corresponding storage content
17
- * Pass it as mergeReducer callback when calling localStorageSync function from 'ngrx-store-localstorage', in the app
18
- * @param state actual state
19
- * @param rehydratedState state from storage
20
- * @param action Triggered action
21
- */
22
- readonly mergeReducer: (state: any, rehydratedState: any, action: any) => any;
23
- /**
24
- * Returns a meta reducer that handles storage sync
25
- */
26
- localStorageSync: () => (reducer: any) => (state: any, action: any) => any;
27
- }
28
- //# sourceMappingURL=storage-sync.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"storage-sync.d.ts","sourceRoot":"","sources":["../../src/core/storage-sync.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACV,kBAAkB,EACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,6BAA6B,EAC9B,MAAM,cAAc,CAAC;AAOtB;;GAEG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,0BAA0B,CAA0B;IACrE,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA8B;IAElD,OAAO,EAAE,kBAAkB,CAAC;gBAEvB,OAAO,CAAC,EAAE,6BAA6B,EAAE,YAAY,CAAC,EAAE;QAAE,gBAAgB,EAAE,OAAO,CAAA;KAAE;IAoBjG;;;;;;;OAOG;IACH,SAAgB,YAAY,GAAI,OAAO,GAAG,EAAE,iBAAiB,GAAG,EAAE,QAAQ,GAAG,SAe3E;IAEF;;OAEG;IACI,gBAAgB,SAQb,SAAS,GAAG,sCAoCpB;CACH"}
@@ -1,28 +0,0 @@
1
- import type { Serializer } from '@o3r/core';
2
- import type { SyncStorageConfig } from '../sync-storage';
3
- import type { StorageSyncOptions } from './interfaces';
4
- /**
5
- * Defines if an object is a Serializer
6
- * @param obj Object to test
7
- * @returns True if the object is a Serializer
8
- */
9
- export declare const isSerializer: (obj: any) => obj is Serializer<any>;
10
- /**
11
- * Label of the action to rehydrate the store
12
- */
13
- export declare const REHYDRATE_ACTION_LABEL = "[storeSync] rehydrate";
14
- /**
15
- * Action to rehydrate the store
16
- */
17
- export declare const rehydrateAction: import("@ngrx/store").ActionCreator<"[storeSync] rehydrate", (props: {
18
- payload: Record<string, any>;
19
- }) => {
20
- payload: Record<string, any>;
21
- } & import("@ngrx/store").Action<"[storeSync] rehydrate">>;
22
- /**
23
- * Defines if the storage is a non-async storage
24
- * @param options The storage config
25
- * @returns in case the storage used is a non-async storage
26
- */
27
- export declare const isLocalStorageConfig: (options: StorageSyncOptions) => options is SyncStorageConfig;
28
- //# sourceMappingURL=storage-sync.helpers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"storage-sync.helpers.d.ts","sourceRoot":"","sources":["../../src/core/storage-sync.helpers.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,UAAU,EACX,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EACV,iBAAiB,EAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EACV,kBAAkB,EACnB,MAAM,cAAc,CAAC;AAEtB;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,KAAK,GAAG,KAAG,GAAG,IAAI,UAAU,CAAC,GAAG,CAA4F,CAAC;AAE1J;;GAEG;AACH,eAAO,MAAM,sBAAsB,0BAA0B,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,eAAe;aACjB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;;aAAnB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;0DACzB,CAAC;AAEN;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAAI,SAAS,kBAAkB,KAAG,OAAO,IAAI,iBAA2E,CAAC"}
@@ -1,13 +0,0 @@
1
- /**
2
- * Deep fill of base object using source
3
- * It will do a deep merge of the objects, overriding arrays
4
- * All properties not present in source, but present in base, will remain
5
- * @param base
6
- * @param source
7
- */
8
- export declare function deepFillWithDate<T extends {
9
- [x: string]: any;
10
- }>(base: T, source?: {
11
- [x: string]: any;
12
- }): T;
13
- //# sourceMappingURL=deep-fill.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deep-fill.d.ts","sourceRoot":"","sources":["../../src/deep-fill/deep-fill.ts"],"names":[],"mappings":"AAmBA;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,GAAG,CAAC,CAE1G"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"o3r-store-sync.d.ts","sourceRoot":"","sources":["../src/o3r-store-sync.ts"],"names":[],"mappings":"AAAA;;GAEG;;AAEH,cAAc,cAAc,CAAC"}
package/public_api.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from './core/index';
2
- export * from './sync-storage/index';
3
- //# sourceMappingURL=public_api.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"public_api.d.ts","sourceRoot":"","sources":["../src/public_api.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC"}
@@ -1,3 +0,0 @@
1
- export * from './interfaces';
2
- export * from './storage-sync';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sync-storage/index.ts"],"names":[],"mappings":"AAaA,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC"}
@@ -1,60 +0,0 @@
1
- import type { Logger } from '@o3r/core';
2
- /**
3
- * Options to provide to the synchronous store synchronization mechanism
4
- */
5
- export interface SyncStorageSyncOptions {
6
- /** Callback to define the serialization strategy of the store */
7
- serialize?: (state: any) => any;
8
- /** Callback to define the deserialization strategy of the store */
9
- deserialize?: (state: any) => any;
10
- /** Callback to define the reviving strategy of the store */
11
- reviver?: (key: string, value: any) => any;
12
- /** replacer callback function provided to the parser */
13
- replacer?: ((key: string, value: any) => any) | string[];
14
- /** Filter to apply to the store fields */
15
- filter?: string[];
16
- /** Spacing for serializer */
17
- space?: string | number;
18
- /** Defines whether the store is loaded as forFeature */
19
- syncForFeature?: boolean;
20
- }
21
- /**
22
- * Interface of the configurations for a store
23
- */
24
- export interface StorageKeyConfiguration {
25
- [key: string]: string[] | number[] | StorageKeyConfiguration[] | SyncStorageSyncOptions | ((key: string, value: any) => any);
26
- }
27
- /**
28
- * Definition of a store to to synchronize
29
- */
30
- export type StorageKeys = (StorageKeyConfiguration | SyncStorageSyncOptions | string)[];
31
- /**
32
- * Configuration to define the way the stores should be synchronize to the storage
33
- */
34
- export interface SyncStorageConfig {
35
- /** Map of the store to synchronize */
36
- keys: StorageKeys;
37
- /** Should the stores be initially rehydrated */
38
- rehydrate?: boolean;
39
- /** Storage reference */
40
- storage?: Storage;
41
- /** Should be removed from storage if undefined */
42
- removeOnUndefined?: boolean;
43
- /** Should apply restore date to the restored stores */
44
- restoreDates?: boolean;
45
- /** Callback to define the serialization strategy for the store keys */
46
- storageKeySerializer?: (key: string) => string;
47
- /** Callback to define the condition to the synchronization */
48
- syncCondition?: (state: any) => any;
49
- /** Callback to define the condition to the key synchronization */
50
- syncKeyCondition?: (key: string, state: any) => boolean;
51
- /** check the availability of the storage */
52
- checkStorageAvailability?: boolean;
53
- /** Merge reducer to use to deserialize the store */
54
- mergeReducer?: (state: any, rehydratedState: any, action: any) => any;
55
- /** Logger to report messages */
56
- logger?: Logger;
57
- /** Post process after sync storage execution */
58
- postProcess?: (state: any) => void;
59
- }
60
- //# sourceMappingURL=interfaces.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/sync-storage/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACP,MAAM,WAAW,CAAC;AAEnB;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,iEAAiE;IACjE,SAAS,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E,MAAM,KAAK,MAAM,CAAC;IAC/C,8DAA8D;IAC9D,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC;IACpC,kEAAkE;IAClE,gBAAgB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC;IACxD,4CAA4C;IAC5C,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,oDAAoD;IACpD,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,KAAK,GAAG,CAAC;IACtE,gCAAgC;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;CACpC"}
@@ -1,35 +0,0 @@
1
- import type { Logger } from '@o3r/core';
2
- import type { StorageKeys, SyncStorageConfig } from './interfaces';
3
- /**
4
- * Reviver the date from a JSON field if the string is matching iso format. Return the same value otherwise
5
- * @param _key JSON item key name
6
- * @param value JSON item value
7
- */
8
- export declare const dateReviver: (_key: string, value: any) => any;
9
- /**
10
- * Rehydrate the state of the whole application store
11
- * @param keys Keys of the store to rehydrate
12
- * @param storage storage when getting the data from
13
- * @param storageKeySerializer storage key transform function
14
- * @param restoreDates determine if the date need to be restored
15
- * @param logger
16
- */
17
- export declare const rehydrateApplicationState: (keys: StorageKeys, storage: Storage | undefined, storageKeySerializer: (key: string) => string, restoreDates: boolean, logger?: Logger) => any;
18
- /**
19
- * Update the state of the store after reviving from storage
20
- * Note: this function is mainly use for internal process of store synchronization
21
- * @param state store state
22
- * @param keys key of the store
23
- * @param storage storage to use for the synchronization
24
- * @param storageKeySerializer callback to serialize the store key
25
- * @param removeOnUndefined Define if the store should be clean in the storage if undefined
26
- * @param syncCondition callback to define if the synchronization should be process
27
- * @param logger Logger to report messages
28
- */
29
- export declare const syncStateUpdate: (state: any, keys: StorageKeys, storage: Storage | undefined, storageKeySerializer: (key: string | number) => string, removeOnUndefined?: boolean, syncCondition?: (state: any) => any, logger?: Logger) => void;
30
- /**
31
- * Local and Session storage synchronization helper
32
- * @param config
33
- */
34
- export declare const syncStorage: (config: SyncStorageConfig) => (reducer: any) => (state: any, action: any) => any;
35
- //# sourceMappingURL=storage-sync.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"storage-sync.d.ts","sourceRoot":"","sources":["../../src/sync-storage/storage-sync.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,MAAM,EACP,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAEV,WAAW,EACX,iBAAiB,EAElB,MAAM,cAAc,CAAC;AAEtB;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,MAAM,MAAM,EAAE,OAAO,GAAG,QAKnD,CAAC;AAqCF;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB,GACpC,MAAM,WAAW,EACjB,SAAS,OAAO,GAAG,SAAS,EAC5B,sBAAsB,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,EAC7C,cAAc,OAAO,EACrB,SAAQ,MAAgB,QAiEzB,CAAC;AA0BF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,GAC1B,OAAO,GAAG,EACV,MAAM,WAAW,EACjB,SAAS,OAAO,GAAG,SAAS,EAC5B,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,KAAK,MAAM,EACtD,2BAAyB,EACzB,gBAAgB,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,EACnC,SAAQ,MAAgB,SA6FzB,CAAC;AAoBF;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAI,QAAQ,iBAAiB,MAAM,SAAS,GAAG,MA8B7D,OAAO,GAAG,EAAE,QAAQ,GAAG,QAkChC,CAAC"}