@telperion/ng-pack 1.7.0 → 1.8.0
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,4 +1,4 @@
|
|
|
1
|
-
import { InjectionToken, inject } from '@angular/core';
|
|
1
|
+
import { computed, InjectionToken, inject } from '@angular/core';
|
|
2
2
|
import { ReactiveWebLocalStorage, ReactiveWebSessionStorage, ReactiveCookieStorage } from '@telperion/reactive-storage';
|
|
3
3
|
import { toSignal } from '@angular/core/rxjs-interop';
|
|
4
4
|
|
|
@@ -48,17 +48,18 @@ import { toSignal } from '@angular/core/rxjs-interop';
|
|
|
48
48
|
* @internal This is primarily for internal use. Use the specialized signal creators instead.
|
|
49
49
|
*/
|
|
50
50
|
function storageSignal(storage, store, key) {
|
|
51
|
-
const
|
|
51
|
+
const resolvedKey = typeof key === 'string' ? () => key : key;
|
|
52
|
+
const source = computed(() => toSignal(storage.get(store, resolvedKey()))(), ...(ngDevMode ? [{ debugName: "source" }] : []));
|
|
52
53
|
function setter(value) {
|
|
53
|
-
storage.set(store,
|
|
54
|
+
storage.set(store, resolvedKey(), value);
|
|
54
55
|
}
|
|
55
56
|
function updater(updaterFn) {
|
|
56
57
|
const currentValue = source();
|
|
57
58
|
const newValue = updaterFn(currentValue);
|
|
58
|
-
storage.set(store,
|
|
59
|
+
storage.set(store, resolvedKey(), newValue);
|
|
59
60
|
}
|
|
60
61
|
function deleter() {
|
|
61
|
-
storage.delete(store,
|
|
62
|
+
storage.delete(store, resolvedKey());
|
|
62
63
|
}
|
|
63
64
|
return new Proxy(source, {
|
|
64
65
|
apply() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telperion-ng-pack-storage-signals.mjs","sources":["../../storage-signals/src/storage.ts","../../storage-signals/src/local-storage.ts","../../storage-signals/src/session-storage.ts","../../storage-signals/src/cookie-storage.ts","../../storage-signals/src/telperion-ng-pack-storage-signals.ts"],"sourcesContent":["import { toSignal } from \"@angular/core/rxjs-interop\";\r\nimport { ReactiveStorage } from '@telperion/reactive-storage';\r\nimport { StorageSignal } from \"./storage-signal\";\r\n\r\n/**\r\n * Creates a StorageSignal from a ReactiveStorage instance.\r\n *\r\n * @template T - The type of value stored\r\n * @param storage - The ReactiveStorage instance (localStorage, sessionStorage, or cookie storage)\r\n * @param store - The storage namespace/store name\r\n * @param key - The key within the store\r\n * @returns A StorageSignal that provides reactive access to the stored value\r\n *\r\n * @remarks\r\n * This is a low-level factory function that bridges Angular signals with ReactiveStorage.\r\n * Most applications should use the higher-level functions:\r\n * - {@link localStorageSignal} for localStorage\r\n * - {@link sessionStorageSignal} for sessionStorage\r\n * - {@link cookieStorageSignal} for cookies\r\n *\r\n * The function:\r\n * 1. Converts the ReactiveStorage Observable into an Angular signal using `toSignal`\r\n * 2. Creates a Proxy that intercepts calls to add `set`, `update`, and `delete` methods\r\n * 3. Ensures all storage operations propagate to both the underlying storage and the signal\r\n *\r\n * **Proxy Pattern:**\r\n * The returned signal is a Proxy that:\r\n * - Delegates reading to the underlying signal\r\n * - Provides `set()` to write values\r\n * - Provides `update()` for functional updates\r\n * - Provides `delete()` to remove the value\r\n *\r\n * @example\r\n * ```typescript\r\n * // Typically used internally by specialized signal creators\r\n * import { ReactiveWebLocalStorage } from '@telperion/reactive-storage';\r\n *\r\n * const storage = new ReactiveWebLocalStorage('my-app');\r\n * const userSignal = storageSignal<User>(storage, 'users', 'current');\r\n *\r\n * userSignal.set({ id: 1, name: 'Alice' });\r\n * console.log(userSignal()); // { id: 1, name: 'Alice' }\r\n *\r\n * userSignal.update(user => ({ ...user, name: 'Bob' }));\r\n * userSignal.delete();\r\n * ```\r\n *\r\n * @internal This is primarily for internal use. Use the specialized signal creators instead.\r\n */\r\nexport function storageSignal<T>(storage: ReactiveStorage, store: string, key: string): StorageSignal<T> {\r\n const source = toSignal(storage.get<T>(store, key));\r\n\r\n function setter(value: T | null | undefined) {\r\n storage.set(store, key, value);\r\n }\r\n\r\n function updater(updaterFn: (value: T | null | undefined) => T | null | undefined) {\r\n const currentValue = source();\r\n const newValue = updaterFn(currentValue);\r\n\r\n storage.set(store, key, newValue);\r\n }\r\n\r\n function deleter() {\r\n storage.delete(store, key);\r\n }\r\n\r\n return new Proxy(source as StorageSignal<T>, {\r\n apply() {\r\n return source();\r\n },\r\n get(target, prop, receiver) {\r\n switch (prop) {\r\n case 'set':\r\n return setter;\r\n case 'update':\r\n return updater;\r\n case 'delete':\r\n return deleter;\r\n default:\r\n return Reflect.get(target, prop, receiver);\r\n }\r\n }\r\n })\r\n}\r\n","import { inject, InjectionToken, Provider } from \"@angular/core\";\r\nimport { ReactiveWebLocalStorage } from '@telperion/reactive-storage';\r\n\r\nimport { storageSignal } from \"./storage\";\r\nimport { StorageSignal } from \"./storage-signal\";\r\n\r\n/**\r\n * Injection token for the ReactiveWebLocalStorage singleton.\r\n * @internal\r\n */\r\nconst LOCAL_STORAGE = new InjectionToken<ReactiveWebLocalStorage>('Telperion Local Storage');\r\n\r\n/**\r\n * Provides a ReactiveWebLocalStorage instance for dependency injection.\r\n *\r\n * @param appName - Optional application name for namespacing localStorage keys\r\n * @returns An Angular provider configuration\r\n *\r\n * @remarks\r\n * This provider creates a singleton ReactiveWebLocalStorage instance that can be injected\r\n * throughout your application. All `localStorageSignal` calls will use this shared instance,\r\n * ensuring consistent storage access and change detection.\r\n *\r\n * **Namespacing:**\r\n * The `appName` parameter prefixes all localStorage keys to prevent conflicts:\r\n * - With appName: `my-app:store:key`\r\n * - Without appName: `store:key`\r\n *\r\n * **Singleton Pattern:**\r\n * Only one instance is created per application, ensuring:\r\n * - Consistent storage access across components\r\n * - Efficient memory usage\r\n * - Reliable cross-component synchronization\r\n *\r\n * @example\r\n * ```typescript\r\n * // app.config.ts\r\n * import { ApplicationConfig } from '@angular/core';\r\n * import { provideLocalStorage } from '@telperion/ng-pack/storage-signals';\r\n *\r\n * export const appConfig: ApplicationConfig = {\r\n * providers: [\r\n * provideLocalStorage('my-app'),\r\n * // ... other providers\r\n * ]\r\n * };\r\n * ```\r\n *\r\n * @example\r\n * ```typescript\r\n * // Without namespace (keys are not prefixed)\r\n * export const appConfig: ApplicationConfig = {\r\n * providers: [\r\n * provideLocalStorage(),\r\n * ]\r\n * };\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport function provideLocalStorage(appName?: string): Provider {\r\n return {\r\n provide: LOCAL_STORAGE,\r\n useValue: new ReactiveWebLocalStorage(appName)\r\n };\r\n}\r\n\r\n/**\r\n * Creates a reactive signal connected to browser's localStorage.\r\n *\r\n * @template T - The type of value stored\r\n * @param store - The storage namespace/store name\r\n * @param key - The key within the store\r\n * @returns A StorageSignal that reactively tracks the localStorage value\r\n *\r\n * @remarks\r\n * This function creates an Angular signal that automatically syncs with localStorage.\r\n * Any changes to the value (via `set`, `update`, or `delete`) are immediately persisted\r\n * to localStorage and propagate to all components using the same signal.\r\n *\r\n * **Requirements:**\r\n * Must call {@link provideLocalStorage} in application config before using this function.\r\n *\r\n * **Storage Key:**\r\n * The actual localStorage key is formed as:\r\n * - With app name: `appName:store:key`\r\n * - Without app name: `store:key`\r\n *\r\n * **Type Safety:**\r\n * Values are automatically serialized/deserialized as JSON:\r\n * - Objects and arrays are preserved\r\n * - Primitives (string, number, boolean) work correctly\r\n * - Functions and undefined values are not supported\r\n *\r\n * **Cross-Component Sync:**\r\n * All components using the same `store` and `key` share the same signal state.\r\n * Changes in one component immediately reflect in others.\r\n *\r\n * @example\r\n * ```typescript\r\n * import { Component } from '@angular/core';\r\n * import { localStorageSignal } from '@telperion/ng-pack/storage-signals';\r\n *\r\n * @Component({\r\n * selector: 'app-settings',\r\n * template: `\r\n * <div>\r\n * <p>Theme: {{ theme() }}</p>\r\n * <button (click)=\"theme.set('dark')\">Dark</button>\r\n * <button (click)=\"theme.set('light')\">Light</button>\r\n * <button (click)=\"theme.delete()\">Reset</button>\r\n * </div>\r\n * `\r\n * })\r\n * export class SettingsComponent {\r\n * theme = localStorageSignal<string>('settings', 'theme');\r\n * }\r\n * ```\r\n *\r\n * @example\r\n * ```typescript\r\n * // Complex types\r\n * interface UserPreferences {\r\n * theme: 'light' | 'dark';\r\n * fontSize: number;\r\n * notifications: boolean;\r\n * }\r\n *\r\n * const prefs = localStorageSignal<UserPreferences>('user', 'preferences');\r\n *\r\n * // Set entire object\r\n * prefs.set({ theme: 'dark', fontSize: 14, notifications: true });\r\n *\r\n * // Update specific property\r\n * prefs.update(current => ({\r\n * ...current,\r\n * theme: current?.theme === 'dark' ? 'light' : 'dark'\r\n * }));\r\n * ```\r\n *\r\n * @throws Error if {@link provideLocalStorage} was not called in application config\r\n *\r\n * @public\r\n */\r\nexport function localStorageSignal<T>(store: string, key: string): StorageSignal<T> {\r\n const storage = inject(LOCAL_STORAGE);\r\n\r\n return storageSignal(storage, store, key);\r\n}\r\n","import { inject, InjectionToken, Provider } from \"@angular/core\";\r\nimport { ReactiveWebSessionStorage } from '@telperion/reactive-storage';\r\n\r\nimport { storageSignal } from \"./storage\";\r\nimport { StorageSignal } from \"./storage-signal\";\r\n\r\n/**\r\n * Injection token for the ReactiveWebSessionStorage singleton.\r\n * @internal\r\n */\r\nconst SESSION_STORAGE = new InjectionToken<ReactiveWebSessionStorage>('Telperion Session Storage');\r\n\r\n/**\r\n * Provides a ReactiveWebSessionStorage instance for dependency injection.\r\n *\r\n * @param appName - Optional application name for namespacing sessionStorage keys\r\n * @returns An Angular provider configuration\r\n *\r\n * @remarks\r\n * This provider creates a singleton ReactiveWebSessionStorage instance that can be injected\r\n * throughout your application. All `sessionStorageSignal` calls will use this shared instance,\r\n * ensuring consistent storage access and change detection.\r\n *\r\n * **SessionStorage vs LocalStorage:**\r\n * - **sessionStorage**: Data persists only for the browser tab/window session (cleared on close)\r\n * - **localStorage**: Data persists indefinitely until explicitly cleared\r\n *\r\n * **Use Cases for sessionStorage:**\r\n * - Multi-step form wizards\r\n * - Temporary authentication tokens\r\n * - Per-session user preferences\r\n * - Shopping cart for current session\r\n * - Tab-specific state isolation\r\n *\r\n * **Namespacing:**\r\n * The `appName` parameter prefixes all sessionStorage keys to prevent conflicts:\r\n * - With appName: `my-app:store:key`\r\n * - Without appName: `store:key`\r\n *\r\n * **Singleton Pattern:**\r\n * Only one instance is created per application, ensuring:\r\n * - Consistent storage access across components\r\n * - Efficient memory usage\r\n * - Reliable cross-component synchronization\r\n *\r\n * @example\r\n * ```typescript\r\n * // app.config.ts\r\n * import { ApplicationConfig } from '@angular/core';\r\n * import { provideSessionStorage } from '@telperion/ng-pack/storage-signals';\r\n *\r\n * export const appConfig: ApplicationConfig = {\r\n * providers: [\r\n * provideSessionStorage('my-app'),\r\n * // ... other providers\r\n * ]\r\n * };\r\n * ```\r\n *\r\n * @example\r\n * ```typescript\r\n * // Without namespace\r\n * export const appConfig: ApplicationConfig = {\r\n * providers: [\r\n * provideSessionStorage(),\r\n * ]\r\n * };\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport function provideSessionStorage(appName?: string): Provider {\r\n return {\r\n provide: SESSION_STORAGE,\r\n useValue: new ReactiveWebSessionStorage(appName)\r\n };\r\n}\r\n\r\n/**\r\n * Creates a reactive signal connected to browser's sessionStorage.\r\n *\r\n * @template T - The type of value stored\r\n * @param store - The storage namespace/store name\r\n * @param key - The key within the store\r\n * @returns A StorageSignal that reactively tracks the sessionStorage value\r\n *\r\n * @remarks\r\n * This function creates an Angular signal that automatically syncs with sessionStorage.\r\n * Any changes to the value (via `set`, `update`, or `delete`) are immediately persisted\r\n * to sessionStorage and propagate to all components using the same signal.\r\n *\r\n * **Session Lifecycle:**\r\n * - Data is cleared when the browser tab/window is closed\r\n * - Each tab has its own independent sessionStorage\r\n * - Opening a page in a new tab creates fresh sessionStorage (even for same URL)\r\n * - Refreshing the page preserves sessionStorage data\r\n *\r\n * **Requirements:**\r\n * Must call {@link provideSessionStorage} in application config before using this function.\r\n *\r\n * **Storage Key:**\r\n * The actual sessionStorage key is formed as:\r\n * - With app name: `appName:store:key`\r\n * - Without app name: `store:key`\r\n *\r\n * **Type Safety:**\r\n * Values are automatically serialized/deserialized as JSON:\r\n * - Objects and arrays are preserved\r\n * - Primitives (string, number, boolean) work correctly\r\n * - Functions and undefined values are not supported\r\n *\r\n * **Cross-Component Sync:**\r\n * All components in the same tab using the same `store` and `key` share the same signal state.\r\n * Changes in one component immediately reflect in others within the same tab.\r\n * Different tabs do NOT share sessionStorage.\r\n *\r\n * @example\r\n * ```typescript\r\n * import { Component } from '@angular/core';\r\n * import { sessionStorageSignal } from '@telperion/ng-pack/storage-signals';\r\n *\r\n * @Component({\r\n * selector: 'app-wizard',\r\n * template: `\r\n * <div>\r\n * <p>Current Step: {{ currentStep() }}</p>\r\n * <button (click)=\"nextStep()\">Next</button>\r\n * <button (click)=\"currentStep.delete()\">Reset</button>\r\n * </div>\r\n * `\r\n * })\r\n * export class WizardComponent {\r\n * currentStep = sessionStorageSignal<number>('wizard', 'step');\r\n *\r\n * nextStep() {\r\n * this.currentStep.update(step => (step ?? 0) + 1);\r\n * }\r\n * }\r\n * ```\r\n *\r\n * @example\r\n * ```typescript\r\n * // Form data that shouldn't persist across sessions\r\n * interface FormData {\r\n * email: string;\r\n * message: string;\r\n * }\r\n *\r\n * const formData = sessionStorageSignal<FormData>('contact', 'draft');\r\n *\r\n * // Auto-save form data (cleared when tab closes)\r\n * formData.set({ email: 'user@example.com', message: 'Hello!' });\r\n *\r\n * // Update specific field\r\n * formData.update(current => ({\r\n * ...current,\r\n * message: 'Updated message'\r\n * }));\r\n * ```\r\n *\r\n * @throws Error if {@link provideSessionStorage} was not called in application config\r\n *\r\n * @public\r\n */\r\nexport function sessionStorageSignal<T>(store: string, key: string): StorageSignal<T> {\r\n const storage = inject(SESSION_STORAGE);\r\n\r\n return storageSignal(storage, store, key);\r\n}\r\n","import { inject, Provider } from '@angular/core';\r\nimport { ReactiveCookieStorage, ReactiveCookieStorageOptions } from '@telperion/reactive-storage';\r\nimport { storageSignal } from './storage';\r\n\r\n/**\r\n * Internal provider that manages ReactiveCookieStorage instances with different configurations.\r\n *\r\n * @remarks\r\n * This class implements a registry pattern to ensure that cookie storages with identical\r\n * configurations share the same underlying ReactiveCookieStorage instance. This is critical for:\r\n * - Preventing duplicate cookie writes\r\n * - Ensuring consistent change detection across components\r\n * - Optimizing memory usage\r\n *\r\n * **Linker Pattern:**\r\n * All instances created by this provider share a common linker (Symbol) to enable\r\n * cross-instance synchronization even when using different option combinations.\r\n *\r\n * **Instance Deduplication:**\r\n * Two `cookieStorageSignal` calls with the same options will reuse the same storage instance,\r\n * preventing redundant cookie operations.\r\n *\r\n * @internal This class is not exported publicly\r\n */\r\nclass CookieStorageProvider {\r\n /**\r\n * Valid cookie option keys that can be used to configure cookie storage.\r\n * Filters out any invalid properties from being passed to cookie operations.\r\n */\r\n static #VALID_OPTIONS = ['path', 'domain', 'secure', 'sameSite', 'expires', 'maxAge'] as (keyof ReactiveCookieStorageOptions)[];\r\n\r\n /**\r\n * Shared linker symbol used to synchronize all cookie storage instances\r\n * created by this provider, enabling cross-instance change notifications.\r\n */\r\n #linker = Symbol('ReactiveCookieStorage Linker');\r\n\r\n /**\r\n * Registry of ReactiveCookieStorage instances keyed by their configuration options.\r\n * Ensures instances with identical options are reused.\r\n */\r\n #stores = new Map<ReactiveCookieStorageOptions, ReactiveCookieStorage>();\r\n\r\n /**\r\n * Creates a new CookieStorageProvider with base configuration.\r\n *\r\n * @param appName - Optional application name for namespacing cookie keys\r\n * @param baseOptions - Default cookie options applied to all storage instances\r\n */\r\n constructor(\r\n private appName?: string,\r\n private baseOptions: ReactiveCookieStorageOptions = {}\r\n ) {\r\n const parsedOptions = this.#parseOptions(baseOptions);\r\n\r\n this.#stores.set(parsedOptions, new ReactiveCookieStorage(appName, parsedOptions, this.#linker));\r\n }\r\n\r\n /**\r\n * Gets or creates a ReactiveCookieStorage instance with the specified options.\r\n *\r\n * @param options - Cookie options to override base options\r\n * @returns A ReactiveCookieStorage instance (reused if options match existing instance)\r\n *\r\n * @remarks\r\n * This method implements option merging and instance deduplication:\r\n * 1. Merges provided options with base options (provided options take precedence)\r\n * 2. Checks if an instance with these exact options already exists\r\n * 3. Returns existing instance if found, otherwise creates and caches a new one\r\n *\r\n * All instances share the same linker for cross-instance synchronization.\r\n */\r\n getStore(options: ReactiveCookieStorageOptions = {}): ReactiveCookieStorage {\r\n const parsedOptions = this.#parseOptions({...this.baseOptions, ...options});\r\n let existingKey = this.#getStoredOptions(parsedOptions);\r\n\r\n if (!existingKey) {\r\n this.#stores.set(parsedOptions, new ReactiveCookieStorage(this.appName, parsedOptions, this.#linker));\r\n existingKey = parsedOptions;\r\n }\r\n\r\n return this.#stores.get(existingKey)!;\r\n }\r\n\r\n /**\r\n * Filters cookie options to include only valid properties.\r\n *\r\n * @param options - Raw options object that may contain invalid properties\r\n * @returns Filtered options containing only valid cookie configuration properties\r\n */\r\n #parseOptions(options: ReactiveCookieStorageOptions) {\r\n return Object.fromEntries(\r\n Object.entries(options).filter(([key]) => CookieStorageProvider.#VALID_OPTIONS.includes(key as keyof ReactiveCookieStorageOptions))\r\n ) as ReactiveCookieStorageOptions;\r\n }\r\n\r\n /**\r\n * Searches the registry for an existing options object that matches the provided options.\r\n *\r\n * @param options - Cookie options to search for\r\n * @returns The stored options object if found, undefined otherwise\r\n *\r\n * @remarks\r\n * Two options objects are considered equal if all valid cookie properties have identical values.\r\n */\r\n #getStoredOptions(options: ReactiveCookieStorageOptions): ReactiveCookieStorageOptions | undefined {\r\n const stored = this.#stores.keys();\r\n\r\n return stored.find(storedOpts => {\r\n return CookieStorageProvider.#VALID_OPTIONS.every(key => storedOpts[key] === options[key]);\r\n });\r\n }\r\n}\r\n\r\n/**\r\n * Provides a CookieStorageProvider instance for dependency injection.\r\n *\r\n * @param appName - Optional application name for namespacing cookie keys\r\n * @param options - Default cookie options applied to all cookie storage signals\r\n * @returns An Angular provider configuration\r\n *\r\n * @remarks\r\n * This provider creates a singleton CookieStorageProvider that manages all cookie storage\r\n * instances in your application. All `cookieStorageSignal` calls will use this shared provider.\r\n *\r\n * **Cookie Namespacing:**\r\n * The `appName` parameter prefixes all cookie names to prevent conflicts:\r\n * - With appName: `my-app:store:key`\r\n * - Without appName: `store:key`\r\n *\r\n * **Base Options:**\r\n * The `options` parameter provides default cookie configuration for all signals.\r\n * Individual signals can override these options when created.\r\n *\r\n * **Common Options:**\r\n * - `path` - Cookie path (default: current path)\r\n * - `domain` - Cookie domain (default: current domain)\r\n * - `secure` - Require HTTPS (recommended for production)\r\n * - `sameSite` - CSRF protection ('strict' | 'lax' | 'none')\r\n * - `maxAge` - Expiry time in seconds\r\n * - `expires` - Expiry as Date object\r\n *\r\n * **Instance Management:**\r\n * The provider automatically deduplicates storage instances:\r\n * - Signals with identical options share the same storage instance\r\n * - All instances are linked for cross-instance synchronization\r\n * - Memory-efficient for applications with many cookie signals\r\n *\r\n * @example\r\n * ```typescript\r\n * // app.config.ts\r\n * import { ApplicationConfig } from '@angular/core';\r\n * import { provideCookieStorage } from '@telperion/ng-pack/storage-signals';\r\n *\r\n * export const appConfig: ApplicationConfig = {\r\n * providers: [\r\n * provideCookieStorage('my-app', {\r\n * path: '/',\r\n * secure: true,\r\n * sameSite: 'strict',\r\n * maxAge: 86400 // 24 hours\r\n * }),\r\n * ]\r\n * };\r\n * ```\r\n *\r\n * @example\r\n * ```typescript\r\n * // Minimal configuration\r\n * export const appConfig: ApplicationConfig = {\r\n * providers: [\r\n * provideCookieStorage('my-app'),\r\n * ]\r\n * };\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport function provideCookieStorage(\r\n appName?: string,\r\n options?: ReactiveCookieStorageOptions\r\n): Provider {\r\n return {\r\n provide: CookieStorageProvider,\r\n useValue: new CookieStorageProvider(appName, options)\r\n };\r\n}\r\n\r\n/**\r\n * Creates a reactive signal connected to browser cookies.\r\n *\r\n * @template T - The type of value stored\r\n * @param store - The cookie namespace/store name\r\n * @param key - The cookie key within the store\r\n * @param options - Optional cookie-specific options that override provider defaults\r\n * @returns A StorageSignal that reactively tracks the cookie value\r\n *\r\n * @remarks\r\n * This function creates an Angular signal that automatically syncs with browser cookies.\r\n * Any changes to the value (via `set`, `update`, or `delete`) are immediately written\r\n * to cookies and propagate to all components using the same signal.\r\n *\r\n * **Requirements:**\r\n * Must call {@link provideCookieStorage} in application config before using this function.\r\n *\r\n * **Cookie Name:**\r\n * The actual cookie name is formed as:\r\n * - With app name: `appName:store:key`\r\n * - Without app name: `store:key`\r\n *\r\n * **Size Limitations:**\r\n * Cookies have a ~4KB size limit. The underlying ReactiveCookieStorage enforces a 4000 byte\r\n * limit and throws an error if exceeded. Use localStorage for larger data.\r\n *\r\n * **Options Merging:**\r\n * Cookie options are merged in this order (later overrides earlier):\r\n * 1. Provider base options (from `provideCookieStorage`)\r\n * 2. Signal-specific options (from this function's `options` parameter)\r\n *\r\n * **Instance Deduplication:**\r\n * Signals with identical merged options share the same underlying storage instance:\r\n * ```typescript\r\n * // These share the same storage instance\r\n * const token1 = cookieStorageSignal('auth', 'token', { secure: true });\r\n * const token2 = cookieStorageSignal('auth', 'token', { secure: true });\r\n *\r\n * // These use different instances (different options)\r\n * const temp = cookieStorageSignal('auth', 'token', { maxAge: 300 });\r\n * ```\r\n *\r\n * **Type Safety:**\r\n * Values are automatically serialized/deserialized as JSON:\r\n * - Objects and arrays are preserved\r\n * - Primitives (string, number, boolean) work correctly\r\n * - Functions and undefined values are not supported\r\n *\r\n * **Security Best Practices:**\r\n * - Use `secure: true` in production (HTTPS only)\r\n * - Use `sameSite: 'strict'` for CSRF protection\r\n * - Set appropriate `maxAge` or `expires` for sensitive data\r\n * - Never store sensitive data in cookies without encryption\r\n *\r\n * @example\r\n * ```typescript\r\n * import { Component } from '@angular/core';\r\n * import { cookieStorageSignal } from '@telperion/ng-pack/storage-signals';\r\n *\r\n * @Component({\r\n * selector: 'app-auth',\r\n * template: `\r\n * <div>\r\n * <p>Token: {{ authToken() }}</p>\r\n * <button (click)=\"login()\">Login</button>\r\n * <button (click)=\"logout()\">Logout</button>\r\n * </div>\r\n * `\r\n * })\r\n * export class AuthComponent {\r\n * // Secure cookie with 1 hour expiry\r\n * authToken = cookieStorageSignal<string>('auth', 'token', {\r\n * secure: true,\r\n * sameSite: 'strict',\r\n * maxAge: 3600\r\n * });\r\n *\r\n * login() {\r\n * this.authToken.set('abc123');\r\n * }\r\n *\r\n * logout() {\r\n * this.authToken.delete();\r\n * }\r\n * }\r\n * ```\r\n *\r\n * @example\r\n * ```typescript\r\n * // User preferences with different cookie lifetimes\r\n * const theme = cookieStorageSignal<string>('prefs', 'theme', {\r\n * maxAge: 31536000 // 1 year\r\n * });\r\n *\r\n * const tempSetting = cookieStorageSignal<boolean>('prefs', 'banner-dismissed', {\r\n * maxAge: 86400 // 1 day\r\n * });\r\n *\r\n * theme.set('dark');\r\n * tempSetting.set(true);\r\n * ```\r\n *\r\n * @throws Error if {@link provideCookieStorage} was not called in application config\r\n * @throws Error if the serialized value exceeds 4000 bytes\r\n *\r\n * @public\r\n */\r\nexport function cookieStorageSignal<T>(store: string, key: string, options?: ReactiveCookieStorageOptions) {\r\n const provider = inject(CookieStorageProvider);\r\n const storage = provider.getStore(options);\r\n\r\n return storageSignal<T>(storage, store, key);\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CG;SACa,aAAa,CAAI,OAAwB,EAAE,KAAa,EAAE,GAAW,EAAA;AACnF,IAAA,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAI,KAAK,EAAE,GAAG,CAAC,CAAC;IAEnD,SAAS,MAAM,CAAC,KAA2B,EAAA;QACzC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC;IAChC;IAEA,SAAS,OAAO,CAAC,SAAgE,EAAA;AAC/E,QAAA,MAAM,YAAY,GAAG,MAAM,EAAE;AAC7B,QAAA,MAAM,QAAQ,GAAG,S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ChB,OAAsC,EAAA;IAEtC,OAAO;AACL,QAAA,OAAO,EAAE,qBAAqB;AAC9B,QAAA,QAAQ,EAAE,IAAI,qBAAqB,CAAC,OAAO,EAAE,OAAO;KACrD;AACH;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0GG;SACa,mBAAmB,CAAI,KAAa,EAAE,GAAW,EAAE,OAAsC,EAAA;AACvG,IAAA,MAAM,QAAQ,GAAG,MAAM,CAAC,qBAAqB,CAAC;IAC9C,MAAM,OAAO,GAAG,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC;IAE1C,OAAO,aAAa,CAAI,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC;AAC9C;;AC5SA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"telperion-ng-pack-storage-signals.mjs","sources":["../../storage-signals/src/storage.ts","../../storage-signals/src/local-storage.ts","../../storage-signals/src/session-storage.ts","../../storage-signals/src/cookie-storage.ts","../../storage-signals/src/telperion-ng-pack-storage-signals.ts"],"sourcesContent":["import { toSignal } from \"@angular/core/rxjs-interop\";\r\nimport { ReactiveStorage } from '@telperion/reactive-storage';\r\nimport { StorageSignal } from \"./storage-signal\";\r\nimport { computed, Signal } from \"@angular/core\";\r\n\r\n/**\r\n * Creates a StorageSignal from a ReactiveStorage instance.\r\n *\r\n * @template T - The type of value stored\r\n * @param storage - The ReactiveStorage instance (localStorage, sessionStorage, or cookie storage)\r\n * @param store - The storage namespace/store name\r\n * @param key - The key within the store\r\n * @returns A StorageSignal that provides reactive access to the stored value\r\n *\r\n * @remarks\r\n * This is a low-level factory function that bridges Angular signals with ReactiveStorage.\r\n * Most applications should use the higher-level functions:\r\n * - {@link localStorageSignal} for localStorage\r\n * - {@link sessionStorageSignal} for sessionStorage\r\n * - {@link cookieStorageSignal} for cookies\r\n *\r\n * The function:\r\n * 1. Converts the ReactiveStorage Observable into an Angular signal using `toSignal`\r\n * 2. Creates a Proxy that intercepts calls to add `set`, `update`, and `delete` methods\r\n * 3. Ensures all storage operations propagate to both the underlying storage and the signal\r\n *\r\n * **Proxy Pattern:**\r\n * The returned signal is a Proxy that:\r\n * - Delegates reading to the underlying signal\r\n * - Provides `set()` to write values\r\n * - Provides `update()` for functional updates\r\n * - Provides `delete()` to remove the value\r\n *\r\n * @example\r\n * ```typescript\r\n * // Typically used internally by specialized signal creators\r\n * import { ReactiveWebLocalStorage } from '@telperion/reactive-storage';\r\n *\r\n * const storage = new ReactiveWebLocalStorage('my-app');\r\n * const userSignal = storageSignal<User>(storage, 'users', 'current');\r\n *\r\n * userSignal.set({ id: 1, name: 'Alice' });\r\n * console.log(userSignal()); // { id: 1, name: 'Alice' }\r\n *\r\n * userSignal.update(user => ({ ...user, name: 'Bob' }));\r\n * userSignal.delete();\r\n * ```\r\n *\r\n * @internal This is primarily for internal use. Use the specialized signal creators instead.\r\n */\r\nexport function storageSignal<T>(storage: ReactiveStorage, store: string, key: string | Signal<string>): StorageSignal<T> {\r\n const resolvedKey = typeof key === 'string' ? () => key : key;\r\n const source = computed(() => toSignal(storage.get<T>(store, resolvedKey()))());\r\n\r\n function setter(value: T | null | undefined) {\r\n storage.set(store, resolvedKey(), value);\r\n }\r\n\r\n function updater(updaterFn: (value: T | null | undefined) => T | null | undefined) {\r\n const currentValue = source();\r\n const newValue = updaterFn(currentValue);\r\n\r\n storage.set(store, resolvedKey(), newValue);\r\n }\r\n\r\n function deleter() {\r\n storage.delete(store, resolvedKey());\r\n }\r\n\r\n return new Proxy(source as StorageSignal<T>, {\r\n apply() {\r\n return source();\r\n },\r\n get(target, prop, receiver) {\r\n switch (prop) {\r\n case 'set':\r\n return setter;\r\n case 'update':\r\n return updater;\r\n case 'delete':\r\n return deleter;\r\n default:\r\n return Reflect.get(target, prop, receiver);\r\n }\r\n }\r\n })\r\n}\r\n","import { inject, InjectionToken, Provider } from \"@angular/core\";\r\nimport { ReactiveWebLocalStorage } from '@telperion/reactive-storage';\r\n\r\nimport { storageSignal } from \"./storage\";\r\nimport { StorageSignal } from \"./storage-signal\";\r\n\r\n/**\r\n * Injection token for the ReactiveWebLocalStorage singleton.\r\n * @internal\r\n */\r\nconst LOCAL_STORAGE = new InjectionToken<ReactiveWebLocalStorage>('Telperion Local Storage');\r\n\r\n/**\r\n * Provides a ReactiveWebLocalStorage instance for dependency injection.\r\n *\r\n * @param appName - Optional application name for namespacing localStorage keys\r\n * @returns An Angular provider configuration\r\n *\r\n * @remarks\r\n * This provider creates a singleton ReactiveWebLocalStorage instance that can be injected\r\n * throughout your application. All `localStorageSignal` calls will use this shared instance,\r\n * ensuring consistent storage access and change detection.\r\n *\r\n * **Namespacing:**\r\n * The `appName` parameter prefixes all localStorage keys to prevent conflicts:\r\n * - With appName: `my-app:store:key`\r\n * - Without appName: `store:key`\r\n *\r\n * **Singleton Pattern:**\r\n * Only one instance is created per application, ensuring:\r\n * - Consistent storage access across components\r\n * - Efficient memory usage\r\n * - Reliable cross-component synchronization\r\n *\r\n * @example\r\n * ```typescript\r\n * // app.config.ts\r\n * import { ApplicationConfig } from '@angular/core';\r\n * import { provideLocalStorage } from '@telperion/ng-pack/storage-signals';\r\n *\r\n * export const appConfig: ApplicationConfig = {\r\n * providers: [\r\n * provideLocalStorage('my-app'),\r\n * // ... other providers\r\n * ]\r\n * };\r\n * ```\r\n *\r\n * @example\r\n * ```typescript\r\n * // Without namespace (keys are not prefixed)\r\n * export const appConfig: ApplicationConfig = {\r\n * providers: [\r\n * provideLocalStorage(),\r\n * ]\r\n * };\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport function provideLocalStorage(appName?: string): Provider {\r\n return {\r\n provide: LOCAL_STORAGE,\r\n useValue: new ReactiveWebLocalStorage(appName)\r\n };\r\n}\r\n\r\n/**\r\n * Creates a reactive signal connected to browser's localStorage.\r\n *\r\n * @template T - The type of value stored\r\n * @param store - The storage namespace/store name\r\n * @param key - The key within the store\r\n * @returns A StorageSignal that reactively tracks the localStorage value\r\n *\r\n * @remarks\r\n * This function creates an Angular signal that automatically syncs with localStorage.\r\n * Any changes to the value (via `set`, `update`, or `delete`) are immediately persisted\r\n * to localStorage and propagate to all components using the same signal.\r\n *\r\n * **Requirements:**\r\n * Must call {@link provideLocalStorage} in application config before using this function.\r\n *\r\n * **Storage Key:**\r\n * The actual localStorage key is formed as:\r\n * - With app name: `appName:store:key`\r\n * - Without app name: `store:key`\r\n *\r\n * **Type Safety:**\r\n * Values are automatically serialized/deserialized as JSON:\r\n * - Objects and arrays are preserved\r\n * - Primitives (string, number, boolean) work correctly\r\n * - Functions and undefined values are not supported\r\n *\r\n * **Cross-Component Sync:**\r\n * All components using the same `store` and `key` share the same signal state.\r\n * Changes in one component immediately reflect in others.\r\n *\r\n * @example\r\n * ```typescript\r\n * import { Component } from '@angular/core';\r\n * import { localStorageSignal } from '@telperion/ng-pack/storage-signals';\r\n *\r\n * @Component({\r\n * selector: 'app-settings',\r\n * template: `\r\n * <div>\r\n * <p>Theme: {{ theme() }}</p>\r\n * <button (click)=\"theme.set('dark')\">Dark</button>\r\n * <button (click)=\"theme.set('light')\">Light</button>\r\n * <button (click)=\"theme.delete()\">Reset</button>\r\n * </div>\r\n * `\r\n * })\r\n * export class SettingsComponent {\r\n * theme = localStorageSignal<string>('settings', 'theme');\r\n * }\r\n * ```\r\n *\r\n * @example\r\n * ```typescript\r\n * // Complex types\r\n * interface UserPreferences {\r\n * theme: 'light' | 'dark';\r\n * fontSize: number;\r\n * notifications: boolean;\r\n * }\r\n *\r\n * const prefs = localStorageSignal<UserPreferences>('user', 'preferences');\r\n *\r\n * // Set entire object\r\n * prefs.set({ theme: 'dark', fontSize: 14, notifications: true });\r\n *\r\n * // Update specific property\r\n * prefs.update(current => ({\r\n * ...current,\r\n * theme: current?.theme === 'dark' ? 'light' : 'dark'\r\n * }));\r\n * ```\r\n *\r\n * @throws Error if {@link provideLocalStorage} was not called in application config\r\n *\r\n * @public\r\n */\r\nexport function localStorageSignal<T>(store: string, key: string): StorageSignal<T> {\r\n const storage = inject(LOCAL_STORAGE);\r\n\r\n return storageSignal(storage, store, key);\r\n}\r\n","import { inject, InjectionToken, Provider } from \"@angular/core\";\r\nimport { ReactiveWebSessionStorage } from '@telperion/reactive-storage';\r\n\r\nimport { storageSignal } from \"./storage\";\r\nimport { StorageSignal } from \"./storage-signal\";\r\n\r\n/**\r\n * Injection token for the ReactiveWebSessionStorage singleton.\r\n * @internal\r\n */\r\nconst SESSION_STORAGE = new InjectionToken<ReactiveWebSessionStorage>('Telperion Session Storage');\r\n\r\n/**\r\n * Provides a ReactiveWebSessionStorage instance for dependency injection.\r\n *\r\n * @param appName - Optional application name for namespacing sessionStorage keys\r\n * @returns An Angular provider configuration\r\n *\r\n * @remarks\r\n * This provider creates a singleton ReactiveWebSessionStorage instance that can be injected\r\n * throughout your application. All `sessionStorageSignal` calls will use this shared instance,\r\n * ensuring consistent storage access and change detection.\r\n *\r\n * **SessionStorage vs LocalStorage:**\r\n * - **sessionStorage**: Data persists only for the browser tab/window session (cleared on close)\r\n * - **localStorage**: Data persists indefinitely until explicitly cleared\r\n *\r\n * **Use Cases for sessionStorage:**\r\n * - Multi-step form wizards\r\n * - Temporary authentication tokens\r\n * - Per-session user preferences\r\n * - Shopping cart for current session\r\n * - Tab-specific state isolation\r\n *\r\n * **Namespacing:**\r\n * The `appName` parameter prefixes all sessionStorage keys to prevent conflicts:\r\n * - With appName: `my-app:store:key`\r\n * - Without appName: `store:key`\r\n *\r\n * **Singleton Pattern:**\r\n * Only one instance is created per application, ensuring:\r\n * - Consistent storage access across components\r\n * - Efficient memory usage\r\n * - Reliable cross-component synchronization\r\n *\r\n * @example\r\n * ```typescript\r\n * // app.config.ts\r\n * import { ApplicationConfig } from '@angular/core';\r\n * import { provideSessionStorage } from '@telperion/ng-pack/storage-signals';\r\n *\r\n * export const appConfig: ApplicationConfig = {\r\n * providers: [\r\n * provideSessionStorage('my-app'),\r\n * // ... other providers\r\n * ]\r\n * };\r\n * ```\r\n *\r\n * @example\r\n * ```typescript\r\n * // Without namespace\r\n * export const appConfig: ApplicationConfig = {\r\n * providers: [\r\n * provideSessionStorage(),\r\n * ]\r\n * };\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport function provideSessionStorage(appName?: string): Provider {\r\n return {\r\n provide: SESSION_STORAGE,\r\n useValue: new ReactiveWebSessionStorage(appName)\r\n };\r\n}\r\n\r\n/**\r\n * Creates a reactive signal connected to browser's sessionStorage.\r\n *\r\n * @template T - The type of value stored\r\n * @param store - The storage namespace/store name\r\n * @param key - The key within the store\r\n * @returns A StorageSignal that reactively tracks the sessionStorage value\r\n *\r\n * @remarks\r\n * This function creates an Angular signal that automatically syncs with sessionStorage.\r\n * Any changes to the value (via `set`, `update`, or `delete`) are immediately persisted\r\n * to sessionStorage and propagate to all components using the same signal.\r\n *\r\n * **Session Lifecycle:**\r\n * - Data is cleared when the browser tab/window is closed\r\n * - Each tab has its own independent sessionStorage\r\n * - Opening a page in a new tab creates fresh sessionStorage (even for same URL)\r\n * - Refreshing the page preserves sessionStorage data\r\n *\r\n * **Requirements:**\r\n * Must call {@link provideSessionStorage} in application config before using this function.\r\n *\r\n * **Storage Key:**\r\n * The actual sessionStorage key is formed as:\r\n * - With app name: `appName:store:key`\r\n * - Without app name: `store:key`\r\n *\r\n * **Type Safety:**\r\n * Values are automatically serialized/deserialized as JSON:\r\n * - Objects and arrays are preserved\r\n * - Primitives (string, number, boolean) work correctly\r\n * - Functions and undefined values are not supported\r\n *\r\n * **Cross-Component Sync:**\r\n * All components in the same tab using the same `store` and `key` share the same signal state.\r\n * Changes in one component immediately reflect in others within the same tab.\r\n * Different tabs do NOT share sessionStorage.\r\n *\r\n * @example\r\n * ```typescript\r\n * import { Component } from '@angular/core';\r\n * import { sessionStorageSignal } from '@telperion/ng-pack/storage-signals';\r\n *\r\n * @Component({\r\n * selector: 'app-wizard',\r\n * template: `\r\n * <div>\r\n * <p>Current Step: {{ currentStep() }}</p>\r\n * <button (click)=\"nextStep()\">Next</button>\r\n * <button (click)=\"currentStep.delete()\">Reset</button>\r\n * </div>\r\n * `\r\n * })\r\n * export class WizardComponent {\r\n * currentStep = sessionStorageSignal<number>('wizard', 'step');\r\n *\r\n * nextStep() {\r\n * this.currentStep.update(step => (step ?? 0) + 1);\r\n * }\r\n * }\r\n * ```\r\n *\r\n * @example\r\n * ```typescript\r\n * // Form data that shouldn't persist across sessions\r\n * interface FormData {\r\n * email: string;\r\n * message: string;\r\n * }\r\n *\r\n * const formData = sessionStorageSignal<FormData>('contact', 'draft');\r\n *\r\n * // Auto-save form data (cleared when tab closes)\r\n * formData.set({ email: 'user@example.com', message: 'Hello!' });\r\n *\r\n * // Update specific field\r\n * formData.update(current => ({\r\n * ...current,\r\n * message: 'Updated message'\r\n * }));\r\n * ```\r\n *\r\n * @throws Error if {@link provideSessionStorage} was not called in application config\r\n *\r\n * @public\r\n */\r\nexport function sessionStorageSignal<T>(store: string, key: string): StorageSignal<T> {\r\n const storage = inject(SESSION_STORAGE);\r\n\r\n return storageSignal(storage, store, key);\r\n}\r\n","import { inject, Provider } from '@angular/core';\r\nimport { ReactiveCookieStorage, ReactiveCookieStorageOptions } from '@telperion/reactive-storage';\r\nimport { storageSignal } from './storage';\r\n\r\n/**\r\n * Internal provider that manages ReactiveCookieStorage instances with different configurations.\r\n *\r\n * @remarks\r\n * This class implements a registry pattern to ensure that cookie storages with identical\r\n * configurations share the same underlying ReactiveCookieStorage instance. This is critical for:\r\n * - Preventing duplicate cookie writes\r\n * - Ensuring consistent change detection across components\r\n * - Optimizing memory usage\r\n *\r\n * **Linker Pattern:**\r\n * All instances created by this provider share a common linker (Symbol) to enable\r\n * cross-instance synchronization even when using different option combinations.\r\n *\r\n * **Instance Deduplication:**\r\n * Two `cookieStorageSignal` calls with the same options will reuse the same storage instance,\r\n * preventing redundant cookie operations.\r\n *\r\n * @internal This class is not exported publicly\r\n */\r\nclass CookieStorageProvider {\r\n /**\r\n * Valid cookie option keys that can be used to configure cookie storage.\r\n * Filters out any invalid properties from being passed to cookie operations.\r\n */\r\n static #VALID_OPTIONS = ['path', 'domain', 'secure', 'sameSite', 'expires', 'maxAge'] as (keyof ReactiveCookieStorageOptions)[];\r\n\r\n /**\r\n * Shared linker symbol used to synchronize all cookie storage instances\r\n * created by this provider, enabling cross-instance change notifications.\r\n */\r\n #linker = Symbol('ReactiveCookieStorage Linker');\r\n\r\n /**\r\n * Registry of ReactiveCookieStorage instances keyed by their configuration options.\r\n * Ensures instances with identical options are reused.\r\n */\r\n #stores = new Map<ReactiveCookieStorageOptions, ReactiveCookieStorage>();\r\n\r\n /**\r\n * Creates a new CookieStorageProvider with base configuration.\r\n *\r\n * @param appName - Optional application name for namespacing cookie keys\r\n * @param baseOptions - Default cookie options applied to all storage instances\r\n */\r\n constructor(\r\n private appName?: string,\r\n private baseOptions: ReactiveCookieStorageOptions = {}\r\n ) {\r\n const parsedOptions = this.#parseOptions(baseOptions);\r\n\r\n this.#stores.set(parsedOptions, new ReactiveCookieStorage(appName, parsedOptions, this.#linker));\r\n }\r\n\r\n /**\r\n * Gets or creates a ReactiveCookieStorage instance with the specified options.\r\n *\r\n * @param options - Cookie options to override base options\r\n * @returns A ReactiveCookieStorage instance (reused if options match existing instance)\r\n *\r\n * @remarks\r\n * This method implements option merging and instance deduplication:\r\n * 1. Merges provided options with base options (provided options take precedence)\r\n * 2. Checks if an instance with these exact options already exists\r\n * 3. Returns existing instance if found, otherwise creates and caches a new one\r\n *\r\n * All instances share the same linker for cross-instance synchronization.\r\n */\r\n getStore(options: ReactiveCookieStorageOptions = {}): ReactiveCookieStorage {\r\n const parsedOptions = this.#parseOptions({...this.baseOptions, ...options});\r\n let existingKey = this.#getStoredOptions(parsedOptions);\r\n\r\n if (!existingKey) {\r\n this.#stores.set(parsedOptions, new ReactiveCookieStorage(this.appName, parsedOptions, this.#linker));\r\n existingKey = parsedOptions;\r\n }\r\n\r\n return this.#stores.get(existingKey)!;\r\n }\r\n\r\n /**\r\n * Filters cookie options to include only valid properties.\r\n *\r\n * @param options - Raw options object that may contain invalid properties\r\n * @returns Filtered options containing only valid cookie configuration properties\r\n */\r\n #parseOptions(options: ReactiveCookieStorageOptions) {\r\n return Object.fromEntries(\r\n Object.entries(options).filter(([key]) => CookieStorageProvider.#VALID_OPTIONS.includes(key as keyof ReactiveCookieStorageOptions))\r\n ) as ReactiveCookieStorageOptions;\r\n }\r\n\r\n /**\r\n * Searches the registry for an existing options object that matches the provided options.\r\n *\r\n * @param options - Cookie options to search for\r\n * @returns The stored options object if found, undefined otherwise\r\n *\r\n * @remarks\r\n * Two options objects are considered equal if all valid cookie properties have identical values.\r\n */\r\n #getStoredOptions(options: ReactiveCookieStorageOptions): ReactiveCookieStorageOptions | undefined {\r\n const stored = this.#stores.keys();\r\n\r\n return stored.find(storedOpts => {\r\n return CookieStorageProvider.#VALID_OPTIONS.every(key => storedOpts[key] === options[key]);\r\n });\r\n }\r\n}\r\n\r\n/**\r\n * Provides a CookieStorageProvider instance for dependency injection.\r\n *\r\n * @param appName - Optional application name for namespacing cookie keys\r\n * @param options - Default cookie options applied to all cookie storage signals\r\n * @returns An Angular provider configuration\r\n *\r\n * @remarks\r\n * This provider creates a singleton CookieStorageProvider that manages all cookie storage\r\n * instances in your application. All `cookieStorageSignal` calls will use this shared provider.\r\n *\r\n * **Cookie Namespacing:**\r\n * The `appName` parameter prefixes all cookie names to prevent conflicts:\r\n * - With appName: `my-app:store:key`\r\n * - Without appName: `store:key`\r\n *\r\n * **Base Options:**\r\n * The `options` parameter provides default cookie configuration for all signals.\r\n * Individual signals can override these options when created.\r\n *\r\n * **Common Options:**\r\n * - `path` - Cookie path (default: current path)\r\n * - `domain` - Cookie domain (default: current domain)\r\n * - `secure` - Require HTTPS (recommended for production)\r\n * - `sameSite` - CSRF protection ('strict' | 'lax' | 'none')\r\n * - `maxAge` - Expiry time in seconds\r\n * - `expires` - Expiry as Date object\r\n *\r\n * **Instance Management:**\r\n * The provider automatically deduplicates storage instances:\r\n * - Signals with identical options share the same storage instance\r\n * - All instances are linked for cross-instance synchronization\r\n * - Memory-efficient for applications with many cookie signals\r\n *\r\n * @example\r\n * ```typescript\r\n * // app.config.ts\r\n * import { ApplicationConfig } from '@angular/core';\r\n * import { provideCookieStorage } from '@telperion/ng-pack/storage-signals';\r\n *\r\n * export const appConfig: ApplicationConfig = {\r\n * providers: [\r\n * provideCookieStorage('my-app', {\r\n * path: '/',\r\n * secure: true,\r\n * sameSite: 'strict',\r\n * maxAge: 86400 // 24 hours\r\n * }),\r\n * ]\r\n * };\r\n * ```\r\n *\r\n * @example\r\n * ```typescript\r\n * // Minimal configuration\r\n * export const appConfig: ApplicationConfig = {\r\n * providers: [\r\n * provideCookieStorage('my-app'),\r\n * ]\r\n * };\r\n * ```\r\n *\r\n * @public\r\n */\r\nexport function provideCookieStorage(\r\n appName?: string,\r\n options?: ReactiveCookieStorageOptions\r\n): Provider {\r\n return {\r\n provide: CookieStorageProvider,\r\n useValue: new CookieStorageProvider(appName, options)\r\n };\r\n}\r\n\r\n/**\r\n * Creates a reactive signal connected to browser cookies.\r\n *\r\n * @template T - The type of value stored\r\n * @param store - The cookie namespace/store name\r\n * @param key - The cookie key within the store\r\n * @param options - Optional cookie-specific options that override provider defaults\r\n * @returns A StorageSignal that reactively tracks the cookie value\r\n *\r\n * @remarks\r\n * This function creates an Angular signal that automatically syncs with browser cookies.\r\n * Any changes to the value (via `set`, `update`, or `delete`) are immediately written\r\n * to cookies and propagate to all components using the same signal.\r\n *\r\n * **Requirements:**\r\n * Must call {@link provideCookieStorage} in application config before using this function.\r\n *\r\n * **Cookie Name:**\r\n * The actual cookie name is formed as:\r\n * - With app name: `appName:store:key`\r\n * - Without app name: `store:key`\r\n *\r\n * **Size Limitations:**\r\n * Cookies have a ~4KB size limit. The underlying ReactiveCookieStorage enforces a 4000 byte\r\n * limit and throws an error if exceeded. Use localStorage for larger data.\r\n *\r\n * **Options Merging:**\r\n * Cookie options are merged in this order (later overrides earlier):\r\n * 1. Provider base options (from `provideCookieStorage`)\r\n * 2. Signal-specific options (from this function's `options` parameter)\r\n *\r\n * **Instance Deduplication:**\r\n * Signals with identical merged options share the same underlying storage instance:\r\n * ```typescript\r\n * // These share the same storage instance\r\n * const token1 = cookieStorageSignal('auth', 'token', { secure: true });\r\n * const token2 = cookieStorageSignal('auth', 'token', { secure: true });\r\n *\r\n * // These use different instances (different options)\r\n * const temp = cookieStorageSignal('auth', 'token', { maxAge: 300 });\r\n * ```\r\n *\r\n * **Type Safety:**\r\n * Values are automatically serialized/deserialized as JSON:\r\n * - Objects and arrays are preserved\r\n * - Primitives (string, number, boolean) work correctly\r\n * - Functions and undefined values are not supported\r\n *\r\n * **Security Best Practices:**\r\n * - Use `secure: true` in production (HTTPS only)\r\n * - Use `sameSite: 'strict'` for CSRF protection\r\n * - Set appropriate `maxAge` or `expires` for sensitive data\r\n * - Never store sensitive data in cookies without encryption\r\n *\r\n * @example\r\n * ```typescript\r\n * import { Component } from '@angular/core';\r\n * import { cookieStorageSignal } from '@telperion/ng-pack/storage-signals';\r\n *\r\n * @Component({\r\n * selector: 'app-auth',\r\n * template: `\r\n * <div>\r\n * <p>Token: {{ authToken() }}</p>\r\n * <button (click)=\"login()\">Login</button>\r\n * <button (click)=\"logout()\">Logout</button>\r\n * </div>\r\n * `\r\n * })\r\n * export class AuthComponent {\r\n * // Secure cookie with 1 hour expiry\r\n * authToken = cookieStorageSignal<string>('auth', 'token', {\r\n * secure: true,\r\n * sameSite: 'strict',\r\n * maxAge: 3600\r\n * });\r\n *\r\n * login() {\r\n * this.authToken.set('abc123');\r\n * }\r\n *\r\n * logout() {\r\n * this.authToken.delete();\r\n * }\r\n * }\r\n * ```\r\n *\r\n * @example\r\n * ```typescript\r\n * // User preferences with different cookie lifetimes\r\n * const theme = cookieStorageSignal<string>('prefs', 'theme', {\r\n * maxAge: 31536000 // 1 year\r\n * });\r\n *\r\n * const tempSetting = cookieStorageSignal<boolean>('prefs', 'banner-dismissed', {\r\n * maxAge: 86400 // 1 day\r\n * });\r\n *\r\n * theme.set('dark');\r\n * tempSetting.set(true);\r\n * ```\r\n *\r\n * @throws Error if {@link provideCookieStorage} was not called in application config\r\n * @throws Error if the serialized value exceeds 4000 bytes\r\n *\r\n * @public\r\n */\r\nexport function cookieStorageSignal<T>(store: string, key: string, options?: ReactiveCookieStorageOptions) {\r\n const provider = inject(CookieStorageProvider);\r\n const storage = provider.getStore(options);\r\n\r\n return storageSignal<T>(storage, store, key);\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CG;SACa,aAAa,CAAI,OAAwB,EAAE,KAAa,EAAE,GAA4B,EAAA;AACpG,IAAA,MAAM,WAAW,GAAG,OAAO,GAAG,KAAK,QAAQ,GAAG,MAAM,GAAG,GAAG,GAAG;IAC7D,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAI,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC,EAAE,EAAA,IAAA,SAAA,GAAA,CAAA,EAAA,SAAA,EAAA,QAAA,EAAA,CAAA,GAAA,EAAA,CAAA,CAAC;IAE/E,SAAS,MAAM,CAAC,KAA2B,EAAA;QACzC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE,KAAK,CAAC;IAC1C;IAEA,SAAS,OAAO,CAAC,SAAgE,EAAA;AAC/E,QAAA,MAAM,YAAY,GAAG,MAAM,EAAE;AAC7B,QAAA,MAAM,QAAQ,GAAG,SAAS,CAAC,YAAY,CAAC;QAExC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,WAAW,EAAE,EAAE,QAAQ,CAAC;IAC7C;AAEA,IAAA,SAAS,OAAO,GAAA;QACd,OAAO,CAAC,MAAM,CAAC,KAAK,EA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0GG;SACa,mBAAmB,CAAI,KAAa,EAAE,GAAW,EAAE,OAAsC,EAAA;AACvG,IAAA,MAAM,QAAQ,GAAG,MAAM,CAAC,qBAAqB,CAAC;IAC9C,MAAM,OAAO,GAAG,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC;IAE1C,OAAO,aAAa,CAAI,OAAO,EAAE,KAAK,EAAE,GAAG,CAAC;AAC9C;;AC5SA;;AAEG;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telperion-ng-pack-utils.mjs","sources":["../../utils/src/provide-service-directive.ts","../../utils/src/event-modifiers.plugin.ts","../../utils/src/construct-fetcher.ts","../../utils/src/to-signal.ts","../../utils/src/telperion-ng-pack-utils.ts"],"sourcesContent":["import { forwardRef, InjectionToken, Provider, Type } from \"@angular/core\";\r\n\r\n/**\r\n * Utility function to create a provider for a directive/component that can be injected as a service.\r\n * This is useful for cases where you want to inject a directive/component instance into another directive/component.\r\n *\r\n * Example usage:\r\n *\r\n * files:\r\n * - parent.directive.ts\r\n * - child.directive.ts\r\n * - parent.service.ts\r\n *\r\n * parent.service.ts:\r\n * ```\r\n * import { InjectionToken } from \"@angular/core\";\r\n * import type { ParentDirective } from \"./parent.directive\";\r\n *\r\n * export const ParentService = new InjectionToken<ParentDirective>(\"ParentService\");\r\n * ```\r\n *\r\n * parent.directive.ts:\r\n * ```\r\n * @Directive({\r\n * selector: 'parent',\r\n * providers: [provideServiceDirective(ParentService, ParentDirective)],\r\n * })\r\n * export class ParentDirective {...}\r\n * ```\r\n * child.directive.ts:\r\n * ```\r\n * @Directive({\r\n * selector: 'child',\r\n * })\r\n * export class ChildDirective {\r\n * #parent = inject(ParentService);\r\n * }\r\n * ```\r\n *\r\n * @param token - The injection token to provide.\r\n * @param directive - The directive/component class that will be provided.\r\n * @returns A provider object that can be used in the providers array of an Angular module or component.\r\n */\r\nexport function provideServiceDirective<T>(\r\n token: InjectionToken<T>,\r\n directive: Type<NoInfer<T>>\r\n): Provider {\r\n return {\r\n provide: token,\r\n useExisting: forwardRef(() => directive)\r\n }\r\n}\r\n","/**\r\n * Angular Event Manager Plugin that enables event modifier syntax in templates.\r\n *\r\n * @example\r\n * ```html\r\n * <form (submit.pd)=\"onSubmit()\">...</form>\r\n * <div (click.sp)=\"handleClick()\">...</div>\r\n * <button (click.pd.sp)=\"handleButtonClick()\">Click me</button>\r\n * ```\r\n */\r\n\r\nimport { DOCUMENT } from '@angular/common';\r\nimport { Inject, Injectable, Provider } from '@angular/core';\r\nimport { EVENT_MANAGER_PLUGINS, EventManagerPlugin } from '@angular/platform-browser';\r\n\r\n/**\r\n * Event Manager Plugin that adds support for event modifiers.\r\n * @internal\r\n */\r\n@Injectable()\r\nexport class EventModifiersPlugin extends EventManagerPlugin {\r\n /**\r\n * Supported modifiers: `pd` (preventDefault), `sp` (stopPropagation)\r\n */\r\n private static modifierMap: { [key: string]: (e: Event) => void } = {\r\n 'pd': (e: Event) => e.preventDefault(),\r\n 'sp': (e: Event) => e.stopPropagation(),\r\n };\r\n\r\n constructor(@Inject(DOCUMENT) doc: Document) {\r\n super(doc);\r\n }\r\n\r\n supports(eventName: string): boolean {\r\n return eventName.includes('.') &&\r\n eventName.split('.').some(part => part in EventModifiersPlugin.modifierMap);\r\n }\r\n\r\n addEventListener(element: HTMLElement, eventName: string, handler: (event: Event) => void): () => void {\r\n const parts = eventName.split('.');\r\n const domEventName = parts[0];\r\n const modifiers = parts.slice(1).filter(m => m in EventModifiersPlugin.modifierMap);\r\n\r\n const wrappedHandler = (event: Event) => {\r\n modifiers.forEach(mod => EventModifiersPlugin.modifierMap[mod](event));\r\n\r\n return handler(event);\r\n };\r\n\r\n element.addEventListener(domEventName, wrappedHandler);\r\n\r\n return () => element.removeEventListener(domEventName, wrappedHandler);\r\n }\r\n}\r\n\r\n/**\r\n * Provides the Event Modifiers Plugin.\r\n *\r\n * @example\r\n * ```typescript\r\n * bootstrapApplication(AppComponent, {\r\n * providers: [provideEventModifiersPlugin()]\r\n * });\r\n * ```\r\n */\r\nexport function provideEventModifiersPlugin(): Provider {\r\n return {\r\n provide: EVENT_MANAGER_PLUGINS,\r\n useClass: EventModifiersPlugin,\r\n multi: true\r\n };\r\n}\r\n","import { HttpClient } from \"@angular/common/http\";\nimport { inject, Injector } from \"@angular/core\";\nimport { AnyFunction } from '@telperion/extra-ts-types';\nimport { tryCatch } from \"@telperion/js-utils/promise/try-catch\";\nimport { firstValueFrom, Observable } from 'rxjs';\n\nexport type Fetcher = {\n [P in keyof HttpClient]: HttpClient[P] extends (...args: infer A) => Observable<unknown> ? <T>(...args: A) => Promise<[unknown, T]> : never;\n}\n\n/**\n * Constructs a Fetcher that proxies HttpClient methods and returns a tuple of [error, response].\n * If the HttpClient method throws an error, it will be caught and returned as the first element of the tuple.\n * If the HttpClient method succeeds, the response will be returned as the second element of the tuple.\n * Example usage:\n * ```\n * @Component({\n * selector: 'app-example',\n * template: `<button (click)=\"fetchData()\">Fetch Data</button>`,\n * })\n * export class ExampleComponent {\n * private fetcher = constructFetcher();\n *\n * async fetchData() {\n * const [error, response] = await this.fetcher.get('/api/data');\n *\n* if (error) {\n* console.error('Error fetching data:', error);\n* } else {\n* console.log('Fetched data:', response);\n* }\n * }\n * }\n * ```\n */\nexport function constructFetcher(injector?: Injector) {\n const client = injector ? injector.get(HttpClient) : inject(HttpClient);\n\n return new Proxy({} as Fetcher, {\n get(target, prop) {\n if (prop in client) {\n return (...args: any[]) => {\n const method = (client as any)[prop] as AnyFunction;\n\n return tryCatch(firstValueFrom(method.apply(client, args)));\n }\n }\n\n throw new Error(`HttpClient does not have method ${String(prop)}`);\n }\n });\n}\n","import { Signal } from \"@angular/core\";\r\nimport { toSignal as ngToSignal } from \"@angular/core/rxjs-interop\";\r\nimport { from, Observable } from \"rxjs\";\r\nimport { promisify } from '@telperion/js-utils/promise/promisify';\r\n\r\n/**\r\n * Converts a value, Promise, or Observable into an Angular Signal.\r\n * Accepts any of the three source types and normalises them through\r\n * `@angular/core/rxjs-interop`'s `toSignal` under the hood.\r\n *\r\n * @param source - A plain value, Promise, or Observable to convert\r\n * @param options - Optional configuration forwarded to Angular's `toSignal`\r\n * @returns A read-only Signal that emits the resolved value (or `undefined` until it resolves)\r\n *\r\n * @example\r\n * ```typescript\r\n * // From a plain value\r\n * const sig = toSignal(42);\r\n *\r\n * // From a Promise\r\n * const sig = toSignal(fetch('/api/data').then(r => r.json()));\r\n *\r\n * // From an Observable\r\n * const sig = toSignal(myService.data$);\r\n * ```\r\n */\r\nexport function toSignal<T>(\r\n source: T | Promise<T> | Observable<T>,\r\n options: Partial<Parameters<typeof ngToSignal<T, T>>[1]> = {}\r\n): Signal<T | undefined> {\r\n if (!(source instanceof Observable)) {\r\n source = promisify(source);\r\n }\r\n\r\n return ngToSignal(from(source), options as Parameters<typeof ngToSignal<T, T>>[1]);\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["ngToSignal"],"mappings":";;;;;;;;;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCG;AACG,SAAU,uBAAuB,CACrC,KAAwB,EACxB,SAA2B,EAAA;IAE3B,OAAO;AACL,QAAA,OAAO,EAAE,KAAK;AACd,QAAA,WAAW,EAAE,UAAU,CAAC,MAAM,SAAS;KACxC;AACH;;ACnDA;;;;;;;;;AASG;AAMH;;;AAGG;AAEG,MAAO,oBAAqB,SAAQ,kBAAkB,CAAA;AAC1D;;AAEG;IACK,OAAO,WAAW,GAA0C;QAClE,IAAI,EAAE,CAAC,CAAQ,KAAK,CAAC,CAAC,cAAc,EAAE;QACtC,IAAI,EAAE,CAAC,CAAQ,KAAK,CAAC,CAAC,eAAe,EAAE;KACxC;AAED,IAAA,WAAA,CAA8B,GAAa,EAAA;QACzC,KAAK,CAAC,GAAG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ers.plugin.ts","../../utils/src/construct-fetcher.ts","../../utils/src/to-signal.ts","../../utils/src/telperion-ng-pack-utils.ts"],"sourcesContent":["import { forwardRef, InjectionToken, Provider, Type } from \"@angular/core\";\r\n\r\n/**\r\n * Utility function to create a provider for a directive/component that can be injected as a service.\r\n * This is useful for cases where you want to inject a directive/component instance into another directive/component.\r\n *\r\n * Example usage:\r\n *\r\n * files:\r\n * - parent.directive.ts\r\n * - child.directive.ts\r\n * - parent.service.ts\r\n *\r\n * parent.service.ts:\r\n * ```\r\n * import { InjectionToken } from \"@angular/core\";\r\n * import type { ParentDirective } from \"./parent.directive\";\r\n *\r\n * export const ParentService = new InjectionToken<ParentDirective>(\"ParentService\");\r\n * ```\r\n *\r\n * parent.directive.ts:\r\n * ```\r\n * @Directive({\r\n * selector: 'parent',\r\n * providers: [provideServiceDirective(ParentService, ParentDirective)],\r\n * })\r\n * export class ParentDirective {...}\r\n * ```\r\n * child.directive.ts:\r\n * ```\r\n * @Directive({\r\n * selector: 'child',\r\n * })\r\n * export class ChildDirective {\r\n * #parent = inject(ParentService);\r\n * }\r\n * ```\r\n *\r\n * @param token - The injection token to provide.\r\n * @param directive - The directive/component class that will be provided.\r\n * @returns A provider object that can be used in the providers array of an Angular module or component.\r\n */\r\nexport function provideServiceDirective<T>(\r\n token: InjectionToken<T>,\r\n directive: Type<NoInfer<T>>\r\n): Provider {\r\n return {\r\n provide: token,\r\n useExisting: forwardRef(() => directive)\r\n }\r\n}\r\n","/**\r\n * Angular Event Manager Plugin that enables event modifier syntax in templates.\r\n *\r\n * @example\r\n * ```html\r\n * <form (submit.pd)=\"onSubmit()\">...</form>\r\n * <div (click.sp)=\"handleClick()\">...</div>\r\n * <button (click.pd.sp)=\"handleButtonClick()\">Click me</button>\r\n * ```\r\n */\r\n\r\nimport { DOCUMENT } from '@angular/common';\r\nimport { Inject, Injectable, Provider } from '@angular/core';\r\nimport { EVENT_MANAGER_PLUGINS, EventManagerPlugin } from '@angular/platform-browser';\r\n\r\n/**\r\n * Event Manager Plugin that adds support for event modifiers.\r\n * @internal\r\n */\r\n@Injectable()\r\nexport class EventModifiersPlugin extends EventManagerPlugin {\r\n /**\r\n * Supported modifiers: `pd` (preventDefault), `sp` (stopPropagation)\r\n */\r\n private static modifierMap: { [key: string]: (e: Event) => void } = {\r\n 'pd': (e: Event) => e.preventDefault(),\r\n 'sp': (e: Event) => e.stopPropagation(),\r\n };\r\n\r\n constructor(@Inject(DOCUMENT) doc: Document) {\r\n super(doc);\r\n }\r\n\r\n supports(eventName: string): boolean {\r\n return eventName.includes('.') &&\r\n eventName.split('.').some(part => part in EventModifiersPlugin.modifierMap);\r\n }\r\n\r\n addEventListener(element: HTMLElement, eventName: string, handler: (event: Event) => void): () => void {\r\n const parts = eventName.split('.');\r\n const domEventName = parts[0];\r\n const modifiers = parts.slice(1).filter(m => m in EventModifiersPlugin.modifierMap);\r\n\r\n const wrappedHandler = (event: Event) => {\r\n modifiers.forEach(mod => EventModifiersPlugin.modifierMap[mod](event));\r\n\r\n return handler(event);\r\n };\r\n\r\n element.addEventListener(domEventName, wrappedHandler);\r\n\r\n return () => element.removeEventListener(domEventName, wrappedHandler);\r\n }\r\n}\r\n\r\n/**\r\n * Provides the Event Modifiers Plugin.\r\n *\r\n * @example\r\n * ```typescript\r\n * bootstrapApplication(AppComponent, {\r\n * providers: [provideEventModifiersPlugin()]\r\n * });\r\n * ```\r\n */\r\nexport function provideEventModifiersPlugin(): Provider {\r\n return {\r\n provide: EVENT_MANAGER_PLUGINS,\r\n useClass: EventModifiersPlugin,\r\n multi: true\r\n };\r\n}\r\n","import { HttpClient } from \"@angular/common/http\";\nimport { inject, Injector } from \"@angular/core\";\nimport { AnyFunction } from '@telperion/extra-ts-types';\nimport { tryCatch } from \"@telperion/js-utils/promise/try-catch\";\nimport { firstValueFrom, Observable } from 'rxjs';\n\nexport type Fetcher = {\n [P in keyof HttpClient]: HttpClient[P] extends (...args: infer A) => Observable<unknown> ? <T>(...args: A) => Promise<[unknown, T]> : never;\n}\n\n/**\n * Constructs a Fetcher that proxies HttpClient methods and returns a tuple of [error, response].\n * If the HttpClient method throws an error, it will be caught and returned as the first element of the tuple.\n * If the HttpClient method succeeds, the response will be returned as the second element of the tuple.\n * Example usage:\n * ```\n * @Component({\n * selector: 'app-example',\n * template: `<button (click)=\"fetchData()\">Fetch Data</button>`,\n * })\n * export class ExampleComponent {\n * private fetcher = constructFetcher();\n *\n * async fetchData() {\n * const [error, response] = await this.fetcher.get('/api/data');\n *\n* if (error) {\n* console.error('Error fetching data:', error);\n* } else {\n* console.log('Fetched data:', response);\n* }\n * }\n * }\n * ```\n */\nexport function constructFetcher(injector?: Injector) {\n const client = injector ? injector.get(HttpClient) : inject(HttpClient);\n\n return new Proxy({} as Fetcher, {\n get(target, prop) {\n if (prop in client) {\n return (...args: any[]) => {\n const method = (client as any)[prop] as AnyFunction;\n\n return tryCatch(firstValueFrom(method.apply(client, args)));\n }\n }\n\n throw new Error(`HttpClient does not have method ${String(prop)}`);\n }\n });\n}\n","import { Signal } from \"@angular/core\";\r\nimport { toSignal as ngToSignal } from \"@angular/core/rxjs-interop\";\r\nimport { from, Observable } from \"rxjs\";\r\nimport { promisify } from '@telperion/js-utils/promise/promisify';\r\n\r\ntype ToSignalOptions<T> = Partial<Parameters<typeof ngToSignal<T, T>>[1]>;\r\n\r\n/**\r\n * Converts a value, Promise, or Observable into an Angular Signal.\r\n * Accepts any of the three source types and normalises them through\r\n * `@angular/core/rxjs-interop`'s `toSignal` under the hood.\r\n *\r\n * @param source - A plain value, Promise, or Observable to convert\r\n * @param options - Optional configuration forwarded to Angular's `toSignal`\r\n * @returns A read-only Signal that emits the resolved value (or `undefined` until it resolves)\r\n *\r\n * @example\r\n * ```typescript\r\n * // From a plain value\r\n * const sig = toSignal(42);\r\n *\r\n * // From a Promise\r\n * const sig = toSignal(fetch('/api/data').then(r => r.json()));\r\n *\r\n * // From an Observable\r\n * const sig = toSignal(myService.data$);\r\n * ```\r\n */\r\nexport function toSignal<T, O extends ToSignalOptions<T>>(\r\n source: T | Promise<T> | Observable<T>,\r\n options: O = {} as O\r\n): O extends { initialValue: T } ? Signal<T> : Signal<T | undefined> {\r\n if (!(source instanceof Observable)) {\r\n source = promisify(source);\r\n }\r\n\r\n return ngToSignal(from(source), options as ToSignalOptions<any>) as any;\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["ngToSignal"],"mappings":";;;;;;;;;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCG;AACG,SAAU,uBAAuB,CACrC,KAAwB,EACxB,SAA2B,EAAA;IAE3B,OAAO;AACL,QAAA,OAAO,EAAE,KAAK;AACd,QAAA,WAAW,EAAE,UAAU,CAAC,MAAM,SAAS;KACxC;AACH;;ACnDA;;;;;;;;;AASG;AAMH;;;AAGG;AAEG,MAAO,oBAAqB,SAAQ,kBAAkB,CAAA;AAC1D;;AAEG;IACK,OAAO,WAAW,GAA0C;QAClE,IAAI,EAAE,CAAC,CAAQ,KAAK,CAAC,CAAC,cAAc,EAAE;QACtC,IAAI,EAAE,CAAC,CAAQ,KAAK,CAAC,CAAC,eAAe,EAAE;KACxC;AAED,IAAA,WAAA,CAA8B,GAAa,EAAA;QACzC,KAAK,CAAC,GAAG,CAAC;IACZ;AAEA,IAAA,QAAQ,CAAC,SAAiB,EAAA;AACxB,QAAA,OAAO,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC;AAC5B,YAAA,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,IAAI,oBAAoB,CAAC,WAAW,CAAC;IAC/E;AAEA,IAAA,gBAAgB,CAAC,OAAoB,EAAE,SAAiB,EAAE,OAA+B,EAAA;QACvF,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC;AAClC,QAAA,MAAM,YAAY,GAAG,KAAK,CAAC,CAAC,CAAC;QAC7B,MAAM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,CAAC,MAAM,EAAE,IAAI,EAAA;AACd,YAAA,IAAI,IAAI,IAAI,MAAM,EAAE;AAClB,gBAAA,OAAO,CAAC,GAAG,IAAW,KAAI;AACxB,oBAAA,MAAM,MAAM,GAAI,MAAc,CAAC,IAAI,CAAgB;AAEnD,oBAAA,OAAO,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;AAC7D,gBAAA,CAAC;YACH;YAEA,MAAM,IAAI,KAAK,CAAC,CAAA,gCAAA,EAAmC,MAAM,CAAC,IAAI,CAAC,CAAA,CAAE,CAAC;QACpE;AACD,KAAA,CAAC;AACJ;;AC5CA;;;;;;;;;;;;;;;;;;;;AAoBG;SACa,QAAQ,CACtB,MAAsC,EACtC,UAAa,EAAO,EAAA;AAEpB,IAAA,IAAI,EAAE,MAAM,YAAY,UAAU,CAAC,EAAE;AACnC,QAAA,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC;IAC5B;IAEA,OAAOA,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,OAA+B,CAAQ;AACzE;;ACrCA;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telperion/ng-pack",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "Collection of Angular utilities and libraries organized as secondary entry points. Includes signal-based storage (localStorage/sessionStorage/cookieStorage), SSE client with HttpClient-inspired interceptors, event modifier plugins, and more. Built with TypeScript, RxJS, and Angular Signals for modern Angular applications.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"angular",
|
|
@@ -88,6 +88,7 @@ type Fetcher = {
|
|
|
88
88
|
*/
|
|
89
89
|
declare function constructFetcher(injector?: Injector): Fetcher;
|
|
90
90
|
|
|
91
|
+
type ToSignalOptions<T> = Partial<Parameters<typeof toSignal$1<T, T>>[1]>;
|
|
91
92
|
/**
|
|
92
93
|
* Converts a value, Promise, or Observable into an Angular Signal.
|
|
93
94
|
* Accepts any of the three source types and normalises them through
|
|
@@ -109,6 +110,8 @@ declare function constructFetcher(injector?: Injector): Fetcher;
|
|
|
109
110
|
* const sig = toSignal(myService.data$);
|
|
110
111
|
* ```
|
|
111
112
|
*/
|
|
112
|
-
declare function toSignal<T
|
|
113
|
+
declare function toSignal<T, O extends ToSignalOptions<T>>(source: T | Promise<T> | Observable<T>, options?: O): O extends {
|
|
114
|
+
initialValue: T;
|
|
115
|
+
} ? Signal<T> : Signal<T | undefined>;
|
|
113
116
|
|
|
114
117
|
export { constructFetcher, provideEventModifiersPlugin, provideServiceDirective, toSignal };
|