{"version":3,"file":"ngxtension-inject-local-storage.mjs","sources":["../../../../libs/ngxtension/inject-local-storage/src/inject-local-storage.ts","../../../../libs/ngxtension/inject-local-storage/src/ngxtension-inject-local-storage.ts"],"sourcesContent":["import { DOCUMENT } from '@angular/common';\nimport {\n\tcomputed,\n\tDestroyRef,\n\tinject,\n\tInjectionToken,\n\ttype Injector,\n\tlinkedSignal,\n\tsignal,\n\tuntracked,\n\ttype WritableSignal,\n} from '@angular/core';\nimport { assertInjector } from 'ngxtension/assert-injector';\n\nexport const NGXTENSION_LOCAL_STORAGE = new InjectionToken(\n\t'NGXTENSION_LOCAL_STORAGE',\n\t{\n\t\tprovidedIn: 'platform',\n\t\tfactory: () => localStorage, // this would be the default\n\t},\n);\n\nexport function provideLocalStorageImpl(impl: typeof globalThis.localStorage) {\n\treturn {\n\t\tprovide: NGXTENSION_LOCAL_STORAGE,\n\t\tuseValue: impl,\n\t};\n}\n\n/**\n * Options to override the default behavior of the local storage signal.\n */\nexport type LocalStorageOptionsBase<T> = {\n\t/**\n\t * Determines if local storage syncs with the signal.\n\t * When true, updates in one tab reflect in others, ideal for shared-state apps.\n\t * @default true\n\t */\n\tstorageSync?: boolean;\n\t/**\n\t * Override the default JSON.stringify function for custom serialization.\n\t * @param value\n\t */\n\tstringify?: (value: T) => string;\n\t/**\n\t * Override the default JSON.parse function for custom deserialization.\n\t * @param value\n\t */\n\tparse?: (value: string) => T;\n\n\t/**\n\t * Injector for the Injection Context\n\t */\n\tinjector?: Injector;\n};\n\nexport type LocalStorageOptionsNoDefault<T> = LocalStorageOptionsBase<T>;\n\nexport type LocalStorageOptionsWithDefaultValue<T> =\n\tLocalStorageOptionsNoDefault<T> & {\n\t\t/**\n\t\t * Default value for the signal.\n\t\t * Can be a value or a function that returns the value.\n\t\t */\n\t\tdefaultValue: T | (() => T);\n\t};\n\ntype ClearOnKeyChange = {\n\t/**\n\t * Specifies whether the value stored under the previous key\n\t * should be removed from `localStorage` when the key changes.\n\t * @default true\n\t */\n\tclearOnKeyChange?: boolean;\n};\n\nexport type LocalStorageOptionsComputedNoDefault<T> =\n\tLocalStorageOptionsBase<T> & ClearOnKeyChange;\n\nexport type LocalStorageOptionsComputedWithDefaultValue<T> =\n\tLocalStorageOptionsWithDefaultValue<T> & ClearOnKeyChange;\n\nexport type LocalStorageOptions<T> =\n\t| LocalStorageOptionsNoDefault<T>\n\t| LocalStorageOptionsWithDefaultValue<T>\n\t| LocalStorageOptionsComputedNoDefault<T>\n\t| LocalStorageOptionsComputedWithDefaultValue<T>;\n\nenum Kind {\n\tINITIAL,\n\tCOMPUTED,\n}\n\ninterface InitialState {\n\tkind: Kind.INITIAL;\n\tkey: null;\n\tvalue: null;\n}\n\ninterface ComputedState<T> {\n\tkind: Kind.COMPUTED;\n\tkey: string;\n\tvalue: T;\n}\n\ntype State<T> = InitialState | ComputedState<T>;\n\ntype LocalStorageSignal<T> = WritableSignal<T>;\n\nfunction isLocalStorageWithDefaultValue<T>(\n\toptions: LocalStorageOptions<T>,\n): options is LocalStorageOptionsWithDefaultValue<T> {\n\treturn 'defaultValue' in options;\n}\n\nfunction isFunction(value: unknown): value is (...args: unknown[]) => unknown {\n\treturn typeof value === 'function';\n}\n\nfunction getDefaultValue<R>(defaultValue: R | (() => R)): R {\n\treturn isFunction(defaultValue) ? defaultValue() : defaultValue;\n}\n\nfunction goodTry<T>(tryFn: () => T, defaultValue: () => T): T {\n\ttry {\n\t\treturn tryFn();\n\t} catch {\n\t\treturn defaultValue();\n\t}\n}\n\nfunction parseJSON(value: string): unknown {\n\treturn value === 'undefined' ? undefined : JSON.parse(value);\n}\n\nexport const injectLocalStorage: {\n\t<T>(\n\t\tkey: string,\n\t\toptions: LocalStorageOptionsWithDefaultValue<T>,\n\t): LocalStorageSignal<T>;\n\t<T>(\n\t\tkey: string,\n\t\toptions?: LocalStorageOptionsNoDefault<T>,\n\t): LocalStorageSignal<T | undefined>;\n\t<T>(\n\t\tkeyComputation: () => string,\n\t\toptions: LocalStorageOptionsComputedWithDefaultValue<T>,\n\t): LocalStorageSignal<T>;\n\t<T>(\n\t\tkeyComputation: () => string,\n\t\toptions?: LocalStorageOptionsComputedNoDefault<T>,\n\t): LocalStorageSignal<T | undefined>;\n} = <T>(\n\tkeyOrComputation: string | (() => string),\n\toptions: LocalStorageOptions<T> = {},\n): LocalStorageSignal<T | undefined> => {\n\treturn internalInjectLocalStorage<T, T | undefined>(\n\t\tkeyOrComputation,\n\t\toptions,\n\t\tisLocalStorageWithDefaultValue(options) ? options.defaultValue : undefined,\n\t);\n};\n\nconst internalInjectLocalStorage = <T, R = T>(\n\tkeyOrComputation: string | (() => string),\n\toptions: LocalStorageOptions<T>,\n\tdefaultValue: R | (() => R),\n): LocalStorageSignal<R> => {\n\tconst stringify = isFunction(options.stringify)\n\t\t? options.stringify\n\t\t: JSON.stringify;\n\tconst parse = isFunction(options.parse) ? options.parse : parseJSON;\n\tconst storageSync = options.storageSync ?? true;\n\tconst clearOnKeyChange =\n\t\t'clearOnKeyChange' in options ? (options.clearOnKeyChange ?? true) : true;\n\n\treturn assertInjector(injectLocalStorage, options.injector, () => {\n\t\tconst localStorage = inject(NGXTENSION_LOCAL_STORAGE);\n\t\tconst destroyRef = inject(DestroyRef);\n\t\tconst window = inject(DOCUMENT).defaultView;\n\n\t\tif (!window) {\n\t\t\tthrow new Error('Cannot access to window element');\n\t\t}\n\n\t\tconst computedKey = computed(() =>\n\t\t\ttypeof keyOrComputation === 'string'\n\t\t\t\t? keyOrComputation\n\t\t\t\t: keyOrComputation(),\n\t\t);\n\n\t\tconst state = signal<State<R>>(\n\t\t\t{\n\t\t\t\tkind: Kind.INITIAL,\n\t\t\t\tkey: null,\n\t\t\t\tvalue: null,\n\t\t\t},\n\t\t\t{\n\t\t\t\tequal: (a, b) => a.kind === b.kind && a.value === b.value,\n\t\t\t},\n\t\t);\n\n\t\tconst getInitialValue = (key: string) => {\n\t\t\tconst initialStoredValue = goodTry(\n\t\t\t\t() => localStorage.getItem(key),\n\t\t\t\t() => null,\n\t\t\t);\n\n\t\t\treturn initialStoredValue\n\t\t\t\t? goodTry(\n\t\t\t\t\t\t() => parse(initialStoredValue) as R,\n\t\t\t\t\t\t() => getDefaultValue(defaultValue),\n\t\t\t\t\t)\n\t\t\t\t: getDefaultValue(defaultValue);\n\t\t};\n\n\t\tconst internalSignal = linkedSignal<R>(() => {\n\t\t\tconst key = computedKey();\n\n\t\t\tuntracked(() => {\n\t\t\t\tconst { kind, key: prevKey } = state();\n\t\t\t\tif (kind === Kind.INITIAL || prevKey !== key) {\n\t\t\t\t\tif (clearOnKeyChange && kind === Kind.COMPUTED) {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tlocalStorage.removeItem(prevKey);\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t/* ignore */\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tstate.set({\n\t\t\t\t\t\tkind: Kind.COMPUTED,\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\tvalue: getInitialValue(key),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tconst { kind, value } = state();\n\n\t\t\tif (kind === Kind.COMPUTED) {\n\t\t\t\treturn value;\n\t\t\t}\n\n\t\t\tthrow new Error('Cannot access to the value');\n\t\t});\n\n\t\tconst syncValueWithLocalStorage = (value: R): void => {\n\t\t\tconst key = untracked(computedKey);\n\t\t\tconst newValue = goodTry(\n\t\t\t\t() => (value === undefined ? null : untracked(() => stringify(value))),\n\t\t\t\t() => null,\n\t\t\t);\n\n\t\t\ttry {\n\t\t\t\tif (newValue === localStorage.getItem(key)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (newValue === null) {\n\t\t\t\t\tlocalStorage.removeItem(key);\n\t\t\t\t} else {\n\t\t\t\t\tlocalStorage.setItem(key, newValue);\n\t\t\t\t}\n\n\t\t\t\tif (!storageSync) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// We notify other consumers in this tab about changing the value in the store for synchronization\n\t\t\t\twindow.dispatchEvent(\n\t\t\t\t\tnew StorageEvent(`storage`, {\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\tnewValue,\n\t\t\t\t\t\tstorageArea: localStorage,\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t} catch {\n\t\t\t\t// ignore errors\n\t\t\t}\n\t\t};\n\n\t\tif (storageSync) {\n\t\t\tconst onStorage = (event: StorageEvent) => {\n\t\t\t\tconst key = untracked(computedKey);\n\n\t\t\t\tif (event.storageArea === localStorage && event.key === key) {\n\t\t\t\t\tconst newValue = goodTry(\n\t\t\t\t\t\t() =>\n\t\t\t\t\t\t\tevent.newValue !== null\n\t\t\t\t\t\t\t\t? (parse(event.newValue) as R)\n\t\t\t\t\t\t\t\t: getDefaultValue(defaultValue),\n\t\t\t\t\t\t() => getDefaultValue(defaultValue),\n\t\t\t\t\t);\n\n\t\t\t\t\tstate.set({\n\t\t\t\t\t\tkind: Kind.COMPUTED,\n\t\t\t\t\t\tkey,\n\t\t\t\t\t\tvalue: newValue,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t};\n\n\t\t\twindow.addEventListener('storage', onStorage);\n\t\t\tdestroyRef.onDestroy(() => {\n\t\t\t\twindow.removeEventListener('storage', onStorage);\n\t\t\t});\n\t\t}\n\n\t\tinternalSignal.set = (newValue: R) => {\n\t\t\tconst { kind, key } = untracked(state);\n\t\t\tlet newKey: string;\n\n\t\t\tswitch (kind) {\n\t\t\t\tcase Kind.INITIAL: {\n\t\t\t\t\tnewKey = untracked(computedKey);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase Kind.COMPUTED: {\n\t\t\t\t\tnewKey = key;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// set the value in the signal using the original set function\n\t\t\tstate.set({\n\t\t\t\tkind: Kind.COMPUTED,\n\t\t\t\tkey: newKey,\n\t\t\t\tvalue: newValue,\n\t\t\t});\n\n\t\t\t// then we refresh the value in localStorage and notify other consumers in this tab about the change\n\t\t\tsyncValueWithLocalStorage(newValue);\n\t\t};\n\n\t\tinternalSignal.update = (updateFn: (value: R) => R) => {\n\t\t\t// set the value in the signal using the original set function\n\t\t\tstate.update(({ kind, key, value }) => {\n\t\t\t\tlet newValue: R;\n\t\t\t\tlet newKey: string;\n\n\t\t\t\tswitch (kind) {\n\t\t\t\t\tcase Kind.INITIAL: {\n\t\t\t\t\t\tnewKey = untracked(computedKey);\n\t\t\t\t\t\tnewValue = updateFn(getInitialValue(newKey));\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase Kind.COMPUTED: {\n\t\t\t\t\t\tnewKey = key;\n\t\t\t\t\t\tnewValue = updateFn(value);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// then we refresh the value in localStorage and notify other consumers in this tab about the change\n\t\t\t\tsyncValueWithLocalStorage(newValue);\n\n\t\t\t\treturn {\n\t\t\t\t\tkind: Kind.COMPUTED,\n\t\t\t\t\tkey: newKey,\n\t\t\t\t\tvalue: newValue,\n\t\t\t\t};\n\t\t\t});\n\t\t};\n\n\t\treturn internalSignal;\n\t});\n};\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;MAca,wBAAwB,GAAG,IAAI,cAAc,CACzD,0BAA0B,EAC1B;AACC,IAAA,UAAU,EAAE,UAAU;AACtB,IAAA,OAAO,EAAE,MAAM,YAAY;AAC3B,CAAA,EACA;AAEI,SAAU,uBAAuB,CAAC,IAAoC,EAAA;IAC3E,OAAO;AACN,QAAA,OAAO,EAAE,wBAAwB;AACjC,QAAA,QAAQ,EAAE,IAAI;KACd,CAAC;AACH,CAAC;AA6DD,IAAK,IAGJ,CAAA;AAHD,CAAA,UAAK,IAAI,EAAA;AACR,IAAA,IAAA,CAAA,IAAA,CAAA,SAAA,CAAA,GAAA,CAAA,CAAA,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