@alwatr/signal 9.26.0 → 9.29.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.
- package/README.md +197 -603
- package/dist/core/channel-signal.d.ts +12 -53
- package/dist/core/channel-signal.d.ts.map +1 -1
- package/dist/core/computed-signal.d.ts +19 -33
- package/dist/core/computed-signal.d.ts.map +1 -1
- package/dist/core/derived-signal.d.ts +71 -0
- package/dist/core/derived-signal.d.ts.map +1 -0
- package/dist/core/effect-signal.d.ts +15 -1
- package/dist/core/effect-signal.d.ts.map +1 -1
- package/dist/core/event-signal.d.ts +11 -4
- package/dist/core/event-signal.d.ts.map +1 -1
- package/dist/core/persistent-state-signal.d.ts +21 -2
- package/dist/core/persistent-state-signal.d.ts.map +1 -1
- package/dist/core/session-state-signal.d.ts +19 -2
- package/dist/core/session-state-signal.d.ts.map +1 -1
- package/dist/core/signal-base.d.ts +58 -38
- package/dist/core/signal-base.d.ts.map +1 -1
- package/dist/core/state-signal.d.ts +33 -14
- package/dist/core/state-signal.d.ts.map +1 -1
- package/dist/creators/channel.d.ts +1 -1
- package/dist/creators/channel.d.ts.map +1 -1
- package/dist/creators/derived.d.ts +31 -0
- package/dist/creators/derived.d.ts.map +1 -0
- package/dist/main.d.ts +2 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +3 -3
- package/dist/main.js.map +16 -15
- package/dist/operators/debounce.d.ts +2 -3
- package/dist/operators/debounce.d.ts.map +1 -1
- package/dist/operators/filter.d.ts +14 -13
- package/dist/operators/filter.d.ts.map +1 -1
- package/dist/type.d.ts +68 -3
- package/dist/type.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/core/channel-signal.ts +25 -68
- package/src/core/computed-signal.ts +50 -74
- package/src/core/derived-signal.ts +166 -0
- package/src/core/effect-signal.ts +23 -11
- package/src/core/event-signal.ts +14 -9
- package/src/core/persistent-state-signal.ts +21 -4
- package/src/core/session-state-signal.ts +19 -4
- package/src/core/signal-base.ts +98 -61
- package/src/core/state-signal.ts +48 -29
- package/src/creators/channel.ts +1 -2
- package/src/creators/derived.ts +34 -0
- package/src/main.ts +2 -1
- package/src/operators/debounce.ts +13 -23
- package/src/operators/filter.ts +20 -26
- package/src/type.ts +71 -3
- package/dist/operators/map.d.ts +0 -36
- package/dist/operators/map.d.ts.map +0 -1
- package/src/operators/map.ts +0 -48
package/dist/main.js.map
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/core/signal-base.ts", "../src/core/event-signal.ts", "../src/core/state-signal.ts", "../src/core/computed-signal.ts", "../src/core/effect-signal.ts", "../src/core/persistent-state-signal.ts", "../src/core/session-state-signal.ts", "../src/core/channel-signal.ts", "../src/creators/event.ts", "../src/creators/state.ts", "../src/creators/computed.ts", "../src/creators/
|
|
3
|
+
"sources": ["../src/core/signal-base.ts", "../src/core/event-signal.ts", "../src/core/state-signal.ts", "../src/core/computed-signal.ts", "../src/core/derived-signal.ts", "../src/core/effect-signal.ts", "../src/core/persistent-state-signal.ts", "../src/core/session-state-signal.ts", "../src/core/channel-signal.ts", "../src/creators/event.ts", "../src/creators/state.ts", "../src/creators/computed.ts", "../src/creators/derived.ts", "../src/creators/effect.ts", "../src/creators/persistent-state.ts", "../src/creators/session-state.ts", "../src/creators/channel.ts", "../src/operators/debounce.ts", "../src/operators/filter.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import type {Observer_, SubscribeOptions, SubscribeResult, ListenerCallback, SignalConfig} from '../type.js';\nimport type {AlwatrLogger} from '@alwatr/logger';\n\n/**\n * An abstract base class for signal implementations.\n * It provides
|
|
6
|
-
"import {
|
|
7
|
-
"import {
|
|
8
|
-
"import {
|
|
9
|
-
"import {
|
|
10
|
-
"import {
|
|
11
|
-
"import {createDebouncer} from '@alwatr/debounce';\nimport {
|
|
12
|
-
"import type {Awaitable} from '@alwatr/type-helper';\nimport {delay} from '@alwatr/delay';\nimport {createLogger, type AlwatrLogger} from '@alwatr/logger';\n\nimport {SignalBase} from './signal-base.js';\n\nimport type {SignalConfig, SubscribeOptions, SubscribeResult, ListenerCallback} from '../type.js';\n\n// ─── Types ────────────────────────────────────────────────────────────────────\n\n/**\n * Determines whether the payload argument for a given channel message is\n * required or optional, based solely on the declared type in `TMap`.\n *\n * - `void | undefined` → payload is optional (second arg may be omitted).\n * - anything else → payload is **required** (omitting it is a compile error).\n *\n * This is used to build the rest-parameter tuple for `dispatch()` so that\n * TypeScript enforces the correct call signature at every dispatch site.\n *\n * @template TMap A record mapping message names to their payload types.\n * @template K The specific message name key.\n *\n * @example\n * ```ts\n * // ActionRecord: { 'logout': void; 'add-to-cart': {productId: number} }\n * type A = DispatchArgs<ActionRecord, 'logout'>; // [name: 'logout', payload?: void]\n * type B = DispatchArgs<ActionRecord, 'add-to-cart'>; // [name: 'add-to-cart', payload: {productId: number}]\n * ```\n */\nexport type DispatchArgs<TMap extends object, K extends keyof TMap> =\n TMap[K] extends void | undefined ? [name: K, payload?: TMap[K]] : [name: K, payload: TMap[K]];\n\n/**\n * A single message dispatched through a `ChannelSignal`.\n *\n * `name` identifies the message type (e.g. `'open-drawer'`, `'add-to-cart'`).\n * `payload` carries the associated data, whose type is determined by the generic `TMap` based on the `name`.\n *\n * @template TMap A record mapping message names to their payload types.\n * @template K The specific message name key (inferred, not set manually).\n */\nexport type ChannelMessage<TMap extends object, K extends keyof TMap = keyof TMap> = {name: K; payload: TMap[K]};\n\n/**\n * A typed handler for a specific named message on a `ChannelSignal`.\n * Receives only the `payload` — the name is already known at subscription time.\n *\n * The payload type mirrors `DispatchArgs`: it is `TMap[K] | undefined` only\n * when the declared type is `void | undefined`; otherwise it is exactly `TMap[K]`\n * (non-optional) so handlers do not need unnecessary null-guards.\n *\n * @template TMap A record mapping message names to their payload types.\n * @template K The specific message name key.\n */\nexport type ChannelHandler<TMap extends object, K extends keyof TMap = keyof TMap> = (\n payload: TMap[K],\n) => Awaitable<void>;\n\n/**\n * Internal handler type used inside `namedHandlers__`.\n *\n * At the storage boundary we erase the conditional payload type to `unknown`\n * so TypeScript does not need to evaluate the conditional against every\n * possible `K`. Type safety is already enforced at the public `on()` and\n * `dispatch()` call sites — the internal executor only needs to call the\n * function with the value it received.\n *\n * @internal\n */\ntype InternalHandler = (payload: unknown) => Awaitable<void>;\n\n/**\n * Configuration for creating a `ChannelSignal`.\n */\nexport interface ChannelSignalConfig extends SignalConfig {}\n\n// ─── Class ────────────────────────────────────────────────────────────────────\n\n/**\n * A stateless multi-channel signal that acts as a typed O(1) message bus.\n *\n * `ChannelSignal` is ideal when you need a single signal to carry multiple\n * distinct message types — each identified by a `name` — rather than creating\n * a separate `EventSignal` for every event.\n *\n * ### Routing architecture\n *\n * Internally, `on()` subscriptions are stored in a per-name `Map` of handler\n * sets. When a message is dispatched, only the handlers registered for that\n * specific name are invoked — O(1) lookup regardless of how many distinct\n * names are subscribed. The inherited `SignalBase` observer list is used\n * exclusively by `subscribe()`, which receives the raw message stream for\n * logging or middleware purposes.\n *\n * ### Type safety\n *\n * The generic parameter `TMap` is a record that maps every valid message name\n * to its payload type. TypeScript enforces the correct payload type at both\n * `dispatch` and `on` call sites.\n *\n * @template TMap A record mapping message names to their payload types.\n *\n * @example\n * ```ts\n * interface AppMessages {\n * 'open-drawer': {panel: string};\n * 'close-drawer': void;\n * 'show-toast': {message: string; type: 'info' | 'error'};\n * }\n *\n * const appChannel = new ChannelSignal<AppMessages>({name: 'app-channel'});\n *\n * // Subscribe to a specific message — handler receives payload directly\n * appChannel.on('open-drawer', (payload) => {\n * openDrawer(payload!.panel);\n * });\n *\n * // Dispatch a typed message\n * appChannel.dispatch('open-drawer', {panel: 'settings'});\n * appChannel.dispatch('close-drawer'); // no payload needed\n * ```\n */\nexport class ChannelSignal<TMap extends object> extends SignalBase<ChannelMessage<TMap>> {\n /**\n * The logger instance for this signal.\n * @protected\n */\n protected logger_: AlwatrLogger;\n\n /**\n * Per-name handler registry for O(1) routing.\n *\n * Each key is a message name; the value is a Set of `{handler, once}` entries\n * registered via `on()`. Kept separate from `SignalBase`'s observer list so\n * that `subscribe()` (raw stream) and `on()` (named routing) never interfere.\n *\n * Stored as `InternalHandler` (erased to `unknown` payload) to avoid\n * unevaluable conditional types at the storage boundary. Type safety is\n * enforced at the public `on()` and `dispatch()` call sites.\n *\n * @private\n */\n private readonly namedHandlers__ = new Map<keyof TMap, Set<{handler: InternalHandler; once: boolean}>>();\n\n constructor(config: ChannelSignalConfig) {\n super(config);\n this.logger_ = createLogger(`channel-signal:${this.name}`);\n this.logger_.logMethod?.('constructor');\n }\n\n /**\n * Dispatches a named message to:\n * 1. All handlers registered via `on(name, …)` for this specific name — O(1).\n * 2. All raw-stream subscribers registered via `subscribe()` — O(N subscribers).\n *\n * The notification is scheduled as a microtask to ensure non-blocking,\n * consistent delivery — matching the behavior of `EventSignal`.\n *\n * ### Payload enforcement\n *\n * The payload argument is **required** unless the declared type in `TMap` is\n * `void` or `undefined`. Omitting a required payload — or passing `undefined`\n * for a non-optional type — is a **compile error**. This prevents accidental\n * `undefined` from propagating into handlers that expect a real value.\n *\n * ```ts\n * // TMap: { 'add-to-cart': {productId: number}; 'logout': void }\n * channel.dispatch('add-to-cart', {productId: 42}); // ✅ required payload\n * channel.dispatch('add-to-cart'); // ❌ compile error\n * channel.dispatch('logout'); // ✅ void — no payload\n * channel.dispatch('logout', undefined); // ✅ also fine\n * ```\n *\n * @param args Tuple of `[name, payload]` — payload optionality is enforced\n * by `DispatchArgs<TMap, K>` based on the declared type.\n */\n public dispatch<K extends keyof TMap>(...args: DispatchArgs<TMap, K>): void {\n const [name, payload] = args;\n this.logger_.logMethodArgs?.('dispatch', {name, payload});\n this.checkDestroyed_();\n delay.nextMicrotask().then(() => this.route__(name, payload));\n }\n\n /**\n * Subscribes to a specific named message on this channel.\n *\n * Uses an internal per-name handler map for O(1) routing — dispatching a\n * message with name `'A'` will never invoke handlers registered for `'B'`.\n *\n * The handler receives the `payload` directly (not the full `{name, payload}`\n * envelope) — since the name is already known at subscription time, passing\n * it again would be redundant.\n *\n * @param name The message name to listen for.\n * @param handler Callback invoked with the payload each time the named message\n * is dispatched.\n * @param options Standard subscribe options. Only `once` is supported here;\n * `priority` applies to `subscribe()` (raw stream) only.\n * @returns A `SubscribeResult` with an `unsubscribe()` method for cleanup.\n *\n * @example\n * ```ts\n * const sub = channel.on('open-drawer', (payload) => {\n * openDrawer(payload!.panel);\n * });\n *\n * // Stop listening when the component is destroyed\n * sub.unsubscribe();\n * ```\n */\n public on<K extends keyof TMap>(\n name: K,\n handler: ChannelHandler<TMap, K>,\n options?: Pick<SubscribeOptions, 'once'>,\n ): SubscribeResult {\n this.logger_.logMethodArgs?.('on', {name});\n this.checkDestroyed_();\n\n // Retrieve or create the handler set for this message name.\n let handlerSet = this.namedHandlers__.get(name);\n if (!handlerSet) {\n handlerSet = new Set();\n this.namedHandlers__.set(name, handlerSet);\n }\n\n const entry = {handler: handler as InternalHandler, once: options?.once ?? false};\n handlerSet.add(entry);\n\n return {\n unsubscribe: (): void => {\n handlerSet!.delete(entry);\n // Clean up the empty set to avoid memory leaks on long-lived channels.\n if (handlerSet!.size === 0) {\n this.namedHandlers__.delete(name);\n }\n },\n };\n }\n\n /**\n * Subscribes to **all** messages dispatched on this channel, regardless of name.\n *\n * Use this when you need to observe the raw message stream — for example,\n * for logging, debugging, or middleware-style processing.\n *\n * Prefer `on(name, handler)` for normal use cases to keep subscriptions\n * focused and type-safe.\n *\n * @param callback The function called with every `ChannelMessage`.\n * @param options Standard subscribe options.\n * @returns A `SubscribeResult` with an `unsubscribe()` method.\n *\n * @example\n * ```ts\n * // Log every message for debugging\n * channel.subscribe((msg) => console.log('[channel]', msg.name, msg.payload));\n * ```\n */\n public override subscribe(\n callback: ListenerCallback<ChannelMessage<TMap>>,\n options?: SubscribeOptions,\n ): SubscribeResult {\n this.logger_.logMethodArgs?.('subscribe', options);\n return super.subscribe(callback, options);\n }\n\n /**\n * Core routing method — called inside the microtask scheduled by `dispatch`.\n *\n * 1. Looks up the per-name handler set in O(1).\n * 2. Invokes each handler, removing `once` entries after their first call.\n * 3. Notifies raw-stream subscribers via `SignalBase.notify_()`.\n *\n * @private\n */\n private route__<K extends keyof TMap>(name: K, payload: TMap[K] | undefined): void {\n if (this.isDestroyed) return;\n // ── Named handlers (O(1) lookup) ──────────────────────────────────────────\n const handlerSet = this.namedHandlers__.get(name);\n if (handlerSet?.size) {\n for (const entry of handlerSet) {\n if (entry.once) {\n handlerSet.delete(entry);\n if (handlerSet.size === 0) this.namedHandlers__.delete(name);\n }\n try {\n const result = entry.handler(payload);\n if (result instanceof Promise) {\n result.catch((err) => this.logger_.error('route__', 'async_named_handler_failed', err));\n }\n } catch (err) {\n this.logger_.error('route__', 'sync_named_handler_failed', err);\n }\n }\n }\n\n // ── Raw-stream subscribers (SignalBase observers) ─────────────────────────\n this.notify_({name, payload} as ChannelMessage<TMap>);\n }\n\n /**\n * Destroys the signal, clearing all named handlers and raw-stream subscribers.\n */\n public override destroy(): void {\n this.namedHandlers__.clear();\n super.destroy();\n }\n}\n",
|
|
5
|
+
"import type {Observer_, SubscribeOptions, SubscribeResult, ListenerCallback, SignalConfig} from '../type.js';\nimport type {AlwatrLogger} from '@alwatr/logger';\n\n/**\n * An abstract base class for all signal implementations in the `@alwatr/signal` package.\n *\n * It provides core subscription management capabilities, including priority observer queues,\n * microtask/macrotask-friendly updates, type-safe unsubscribes, async promise resolution via `untilNext`,\n * and safe destruction lifecycles to prevent memory leaks.\n *\n * @template T The type of data that the signal holds, dispatches, or streams.\n */\nexport abstract class SignalBase<T> {\n /**\n * The unique identifier for this signal instance.\n * Highly useful for debugging, filtering logs, and tracing data flows.\n */\n public readonly name: string;\n\n /**\n * The logger instance for this signal.\n * Custom scoped logger based on the signal name and type.\n *\n * @protected\n */\n protected abstract logger_: AlwatrLogger;\n\n /**\n * High-priority observers that are executed first during notifications.\n * Allocated lazily upon the first priority subscription to guard heap memory.\n *\n * @protected\n */\n protected priorityObservers_?: Set<Observer_<T>>;\n\n /**\n * Standard-priority observers executed after priority observers.\n * Allocated lazily upon the first standard subscription to guard heap memory.\n *\n * @protected\n */\n protected observers_?: Set<Observer_<T>>;\n\n /**\n * Internal flag representing whether the signal has been destroyed.\n *\n * @private\n */\n private isDestroyed__ = false;\n\n /**\n * Indicates whether the signal has been destroyed.\n * A destroyed signal cannot be subscribed to or dispatched to.\n *\n * @returns `true` if the signal is destroyed, `false` otherwise.\n */\n public get isDestroyed(): boolean {\n return this.isDestroyed__;\n }\n\n /**\n * Creates a new instance of the signal base.\n *\n * @param config_ Configuration options including the unique signal name and cleanup hooks.\n */\n constructor(protected config_: SignalConfig) {\n this.name = config_.name;\n }\n\n /**\n * Removes a specific observer from both the standard and priority observer queues.\n *\n * @param observer The observer wrapper object containing the callback and options to remove.\n * @protected\n */\n protected removeObserver_(observer: Observer_<T>): void {\n this.logger_.logMethod?.('removeObserver_');\n\n if (this.isDestroyed__) {\n this.logger_.incident?.('removeObserver_', 'remove_observer_on_destroyed_signal');\n return;\n }\n\n if (observer.options?.priority) {\n this.priorityObservers_?.delete(observer);\n if (this.priorityObservers_?.size === 0) {\n this.priorityObservers_ = undefined;\n }\n } else {\n this.observers_?.delete(observer);\n if (this.observers_?.size === 0) {\n this.observers_ = undefined;\n }\n }\n }\n\n /**\n * Subscribes a listener function to this signal.\n *\n * The listener will be called whenever the signal notifies its observers.\n *\n * @param callback The function to invoke when the signal dispatches a new value.\n * @param options Custom options to control priority, immediate callback, or single execution.\n * @returns An object with an `unsubscribe` method to remove the subscription.\n */\n public subscribe(callback: ListenerCallback<T>, options?: SubscribeOptions): SubscribeResult {\n this.logger_.logMethodArgs?.('subscribe.base', options);\n this.checkDestroyed_();\n\n const observer: Observer_<T> = {callback, options};\n\n if (options?.priority) {\n this.priorityObservers_ ??= new Set();\n this.priorityObservers_.add(observer);\n } else {\n this.observers_ ??= new Set();\n this.observers_.add(observer);\n }\n\n // Return an unsubscribe handler as a closure to prevent memory leaks.\n return {\n unsubscribe: (): void => this.removeObserver_(observer),\n };\n }\n\n /**\n * Notifies all registered priority and standard observers with the given value.\n * Iterates synchronously over current queues.\n *\n * @param value The value to pass to each observer's callback.\n * @protected\n */\n protected notify_(value: T): void {\n this.logger_.logMethodArgs?.('notify_', value);\n\n if (this.isDestroyed__) {\n this.logger_.incident?.('notify_', 'notify_on_destroyed_signal');\n return;\n }\n\n // Execute priority observers first\n if (this.priorityObservers_?.size) {\n for (const observer of this.priorityObservers_) {\n this.executeObserver__(observer, value);\n }\n }\n\n // Execute standard observers second\n if (this.observers_?.size) {\n for (const observer of this.observers_) {\n this.executeObserver__(observer, value);\n }\n }\n }\n\n /**\n * Executes a single observer's callback, handles auto-unsubscribing for `once` listeners,\n * and wraps execution in a try-catch block to prevent observer exceptions from crashing the signal.\n *\n * @param observer The observer descriptor to execute.\n * @param value The value to supply to the observer's callback.\n * @private\n */\n private executeObserver__(observer: Observer_<T>, value: T): void {\n if (observer.options?.once) {\n this.removeObserver_(observer);\n }\n try {\n observer.callback(value);\n } catch (err) {\n this.logger_.error('notify_', 'sync_callback_failed', err);\n }\n }\n\n /**\n * Holds the promise rejection functions of any pending `untilNext` invocations\n * to reject them if the signal is destroyed.\n *\n * @private\n */\n private pendingRejects__?: Set<(reason?: any) => void>;\n\n /**\n * Returns a Promise that resolves with the next value/payload dispatched by the signal.\n * Use this for async orchestration (e.g. `await signal.untilNext()`).\n *\n * @returns A Promise that resolves with the next value dispatched by the signal.\n */\n public untilNext(): Promise<T> {\n this.logger_.logMethod?.('untilNext');\n this.checkDestroyed_();\n return new Promise((resolve, reject) => {\n this.pendingRejects__ ??= new Set();\n this.pendingRejects__.add(reject);\n this.subscribe(\n (value) => {\n this.pendingRejects__?.delete(reject);\n resolve(value);\n },\n {\n once: true,\n priority: true, // Internal promise resolution is prioritized over normal observers.\n receivePrevious: false, // Wait only for the next value change.\n },\n );\n });\n }\n\n /**\n * Permanently destroys the signal instance.\n * Clears all observers, rejects pending `untilNext` promises with a 'signal_destroyed' error,\n * invokes the optional `onDestroy` config hook, and breaks internal references to facilitate GC.\n */\n public destroy(): void {\n this.logger_.logMethod?.('destroy');\n if (this.isDestroyed__) {\n this.logger_.incident?.('destroy_', 'double_destroy_attempt');\n return;\n }\n this.isDestroyed__ = true;\n\n // Reject all pending promises to prevent hang-ups.\n if (this.pendingRejects__?.size) {\n const error = new Error('signal_destroyed');\n for (const reject of this.pendingRejects__) {\n reject(error);\n }\n this.pendingRejects__.clear();\n }\n this.priorityObservers_?.clear();\n this.observers_?.clear();\n this.config_.onDestroy?.();\n this.config_ = null as unknown as SignalConfig;\n }\n\n /**\n * Checks if the signal has been destroyed. If so, throws an error and logs an accident.\n *\n * @protected\n * @throws {Error} If the signal has been destroyed.\n */\n protected checkDestroyed_(): void {\n if (this.isDestroyed__) {\n this.logger_.accident('checkDestroyed_', 'attempt_to_use_destroyed_signal');\n throw new Error(`Cannot interact with a destroyed signal (id: ${this.name})`);\n }\n }\n}\n",
|
|
6
|
+
"import {queueMicrotask} from '@alwatr/delay';\nimport {createLogger, type AlwatrLogger} from '@alwatr/logger';\nimport {SignalBase} from './signal-base.js';\nimport type {IBaseSignal, SignalConfig} from '../type.js';\n\n/**\n * A stateless signal for dispatching transient events.\n *\n * `EventSignal` is ideal for broadcasting events that do not have a persistent state.\n * Unlike `StateSignal`, it does not hold a value. Listeners are only notified of new\n * events as they are dispatched. This makes it suitable for modeling user interactions,\n * system notifications, or any one-off message.\n *\n * @template T The type of the payload for the events. Defaults to `void` for events without a payload.\n *\n * @example\n * // Create a signal for user click events.\n * const onUserClick = new EventSignal<{ x: number, y: number }>({ name: 'on-user-click' });\n *\n * // Subscribe to the event.\n * onUserClick.subscribe(clickPosition => {\n * console.log(`User clicked at: ${clickPosition.x}, ${clickPosition.y}`);\n * });\n *\n * // Dispatch an event.\n * onUserClick.dispatch({ x: 100, y: 250 }); // Notifies the listener.\n *\n * // --- Example with no payload ---\n * const onAppReady = new EventSignal({ name: 'on-app-ready' });\n * onAppReady.subscribe(() => console.log('Application is ready!'));\n * onAppReady.dispatch(); // Notifies the listener.\n */\nexport class EventSignal<T = void> extends SignalBase<T> implements IBaseSignal<T> {\n /**\n * The logger instance for this signal.\n *\n * @protected\n */\n protected logger_: AlwatrLogger;\n\n /**\n * Creates a new EventSignal instance.\n *\n * @param config Configuration options including the unique event name and custom cleanup hooks.\n */\n constructor(config: SignalConfig) {\n super(config);\n this.logger_ = createLogger(`event_signal:${this.name}`);\n this.logger_.logMethod?.('constructor');\n }\n\n /**\n * Dispatches an event with the specified payload to all active listeners.\n *\n * To prevent blocking of the main thread and ensure consistent execution order,\n * the notification execution is scheduled as a microtask using `queueMicrotask`.\n *\n * @param payload The data payload to send with the event.\n */\n public dispatch(payload: T): void {\n this.logger_.logMethodArgs?.('dispatch', {payload});\n this.checkDestroyed_();\n // Dispatch as a microtask to ensure consistent, non-blocking behavior.\n queueMicrotask(() => this.notify_(payload));\n }\n}\n",
|
|
7
|
+
"import {queueMicrotask} from '@alwatr/delay';\nimport {createLogger, type AlwatrLogger} from '@alwatr/logger';\nimport {SignalBase} from './signal-base.js';\nimport type {StateSignalConfig, ListenerCallback, SubscribeOptions, SubscribeResult, IReadonlySignal} from '../type.js';\n\n/**\n * A stateful signal that holds a value and notifies listeners when the value changes.\n *\n * `StateSignal` is the core of the signal library, representing a piece of mutable state.\n * It always has a value, and new subscribers immediately receive the current value by default.\n *\n * @template T The type of the state it holds.\n * @implements {IReadonlySignal<T>}\n *\n * @example\n * // Create a new state signal with an initial value.\n * const counter = new StateSignal<number>({\n * name: 'counter-signal',\n * initialValue: 0,\n * });\n *\n * // Get the current value.\n * console.log(counter.get()); // Outputs: 0\n *\n * // Subscribe to changes.\n * const subscription = counter.subscribe(newValue => {\n * console.log(`Counter changed to: ${newValue}`);\n * });\n *\n * // Set a new value, which triggers the notification.\n * counter.set(1); // Outputs: \"Counter changed to: 1\"\n *\n * // Update value based on the previous value.\n * counter.update(current => current + 1); // Outputs: \"Counter changed to: 2\"\n *\n * // Unsubscribe when no longer needed.\n * subscription.unsubscribe();\n */\nexport class StateSignal<T> extends SignalBase<T> implements IReadonlySignal<T> {\n /**\n * The current value of the signal.\n *\n * @private\n */\n private value__: T;\n\n /**\n * The logger instance for this signal.\n *\n * @protected\n */\n protected logger_: AlwatrLogger;\n\n /**\n * Indicates if a notification is already scheduled.\n * Helps batch multiple synchronous `set` operations into a single microtask notification.\n *\n * @private\n */\n private notifyPending__ = false;\n\n /**\n * The version of the last notification. Incrementing on every state update.\n * Used to guard immediate subscriber execution when updates happen within the same tick.\n *\n * @private\n */\n private notifyVersion__ = 0;\n\n /**\n * Creates a new StateSignal instance.\n *\n * @param config Configuration options including name, initialValue, and custom cleanup hooks.\n */\n constructor(config: StateSignalConfig<T>) {\n super({\n name: config.name,\n onDestroy: config.onDestroy,\n });\n this.logger_ = createLogger(`state_signal:${this.name}`);\n this.value__ = config.initialValue;\n this.logger_.logMethodArgs?.('constructor', {initialValue: this.value__});\n }\n\n /**\n * Retrieves the current value of the signal.\n *\n * @returns The current value.\n * @throws {Error} If the signal has been destroyed.\n *\n * @example\n * console.log(mySignal.get());\n */\n public get(): T {\n this.checkDestroyed_();\n return this.value__;\n }\n\n /**\n * Updates the signal's value and schedules notifications for all active listeners.\n *\n * Primitives are comparison-checked via `Object.is`. If unchanged, the update is ignored.\n * The notification is scheduled as a microtask, allowing multiple synchronous updates\n * to be batched and executed once.\n *\n * @param newValue The new value to set.\n *\n * @example\n * // For primitive types\n * mySignal.set(42);\n *\n * // For object types, it's best practice to set an immutable new object.\n * mySignal.set({ ...mySignal.get(), property: 'new-value' });\n */\n public set(newValue: T): void {\n this.logger_.logMethodArgs?.('set', {newValue});\n\n // For primitives (including null), do not notify if the value is the same.\n if (Object.is(this.value__, newValue) && (typeof newValue !== 'object' || newValue === null)) {\n return;\n }\n\n this.value__ = newValue;\n\n this.notifyChange();\n }\n\n /**\n * Forcefully schedules a notification of the current value to all subscribers.\n *\n * Useful when mutating properties within object states directly without assigning a new reference.\n * Notification is queued as a microtask for batching.\n */\n public notifyChange(): void {\n this.logger_.logMethod?.('notifyChange');\n this.checkDestroyed_();\n\n this.notifyVersion__++;\n if (this.notifyPending__) return;\n this.notifyPending__ = true;\n\n // Dispatch as a microtask to ensure consistent, non-blocking behavior.\n queueMicrotask(() => {\n this.notifyPending__ = false;\n this.notify_(this.value__);\n });\n }\n\n /**\n * Updates the signal's value based on its previous value.\n *\n * A functional update pattern that retrieves the current value, computes the next, and sets it.\n *\n * @param updater A callback function that receives the current value and returns the new value.\n *\n * @example\n * // For a counter\n * counterSignal.update(current => current + 1);\n *\n * // For an object state\n * userSignal.update(currentUser => ({ ...currentUser, loggedIn: true }));\n */\n public update(updater: (previousValue: T) => T): void {\n this.checkDestroyed_();\n const newValue = updater(this.value__);\n this.logger_.logMethodFull?.('update', this.value__, newValue);\n this.set(newValue);\n }\n\n /**\n * Subscribes a listener function to this state signal.\n *\n * By default, the listener is immediately called with the signal's current value (`receivePrevious: true`).\n * This immediate call is queued as a microtask to match the asynchronous flow of signals.\n *\n * @param callback The function to invoke when the state changes.\n * @param options Custom options, such as `receivePrevious: false` to only listen to future updates.\n * @returns An object with an `unsubscribe` method to remove the listener.\n */\n public override subscribe(callback: ListenerCallback<T>, options: SubscribeOptions = {}): SubscribeResult {\n this.logger_.logMethodArgs?.('subscribe', options);\n this.checkDestroyed_();\n\n const result = super.subscribe(callback, options);\n\n if (options.receivePrevious === false) return result; // If the subscriber opts out of receiving the current value, skip the immediate callback.\n if (this.notifyPending__) return result; // If a notification is already pending, the callback will be called with the latest value when the notification is processed.\n\n const subscribeVersion = this.notifyVersion__;\n\n queueMicrotask((): void => {\n this.logger_.logStep?.('subscribe', 'immediate_callback');\n if (this.notifyVersion__ !== subscribeVersion) return; // A notification occurred after subscribing, so skip the immediate callback.\n if (options.once) {\n result.unsubscribe();\n }\n try {\n callback(this.value__);\n } catch (err) {\n this.logger_.error('subscribe', 'immediate_callback_failed', err);\n }\n });\n\n return result;\n }\n\n /**\n * Destroys the signal, clearing its value and all listeners.\n * Breaks references for garbage collection.\n */\n public override destroy(): void {\n this.value__ = null as T; // Clear the value to allow for garbage collection.\n super.destroy();\n }\n\n /**\n * Returns this signal cast to the `IReadonlySignal<T>` interface.\n * Limits access so external callers can only subscribe/read but not set/update state.\n *\n * @returns A readonly representation of this signal.\n */\n public asReadonly(): IReadonlySignal<T> {\n return this;\n }\n}\n",
|
|
8
|
+
"import {queueMicrotask} from '@alwatr/delay';\nimport {createLogger, type AlwatrLogger} from '@alwatr/logger';\nimport {StateSignal} from './state-signal.js';\nimport type {\n ComputedSignalConfig,\n IReadonlySignal,\n SubscribeOptions,\n SubscribeResult,\n ListenerCallback,\n} from '../type.js';\n\n/**\n * A read-only signal that derives its value from a set of dependency signals.\n *\n * `ComputedSignal` is a powerful tool for creating values that reactively update when their underlying\n * data sources change. Its value is memoized, meaning the `get` function is only re-evaluated when\n * one of its dependencies has actually changed.\n *\n * A key feature is its lifecycle management: a `ComputedSignal` **must** be destroyed when no longer\n * needed to prevent memory leaks from its subscriptions to dependency signals.\n *\n * @template T The type of the computed value.\n */\nexport class ComputedSignal<T> implements IReadonlySignal<T> {\n /**\n * The unique identifier for this signal instance.\n */\n public readonly name: string;\n\n /**\n * The logger instance for this signal.\n *\n * @protected\n */\n protected readonly logger_: AlwatrLogger;\n\n /**\n * The internal `StateSignal` that holds the computed value.\n * This is how the computed signal provides `.get()` and `.subscribe()` methods.\n * Enforces COMPOSITION over inheritance.\n *\n * @protected\n */\n protected readonly internalSignal_: StateSignal<T>;\n\n /**\n * A list of subscriptions to dependency signals.\n * Used to unsubscribe from dependencies when this signal is destroyed.\n *\n * @private\n */\n private readonly dependencySubscriptions__: SubscribeResult[] = [];\n\n /**\n * A flag to prevent concurrent recalculations.\n * Avoids queuing multiple updates in the event loop.\n *\n * @private\n */\n private isRecalculating__ = false;\n\n /**\n * Creates a new ComputedSignal instance.\n * Subscribes to all dependency signals to trigger recalculations.\n *\n * @param config_ Configuration options including dependencies, evaluation getter, and cleanup hook.\n */\n constructor(protected config_: ComputedSignalConfig<T>) {\n this.name = config_.name;\n this.logger_ = createLogger(`computed_signal:${this.name}`);\n this.recalculate_ = this.recalculate_.bind(this);\n\n this.logger_.logMethod?.('constructor');\n\n this.internalSignal_ = new StateSignal<T>({\n name: `compute_internal:${this.name}`,\n initialValue: this.config_.get(),\n });\n\n // Subscribe to all dependencies to trigger recalculation on change.\n for (let i = 0; i < this.config_.deps.length; i++) {\n const signal = this.config_.deps[i];\n this.logger_.logStep?.('constructor', 'subscribing_to_dependency', {signal: signal.name});\n this.dependencySubscriptions__.push(signal.subscribe(this.recalculate_, {receivePrevious: false}));\n }\n }\n\n /**\n * The current value of the computed signal.\n * Accessing this property returns the memoized value and does not trigger a recalculation.\n *\n * @returns The current computed value.\n * @throws {Error} If accessed after the signal has been destroyed.\n */\n public get(): T {\n return this.internalSignal_.get();\n }\n\n /**\n * Indicates whether the computed signal has been destroyed.\n * A destroyed signal cannot be used and will throw an error if interacted with.\n *\n * @returns `true` if the signal is destroyed, `false` otherwise.\n */\n public get isDestroyed(): boolean {\n return this.internalSignal_.isDestroyed;\n }\n\n /**\n * Subscribes a listener to this signal.\n * The listener will be called whenever the computed value changes.\n *\n * @param callback The function to be called with the new value.\n * @param options Subscription options.\n * @returns A `SubscribeResult` object with an `unsubscribe` method.\n */\n public subscribe(callback: ListenerCallback<T>, options?: SubscribeOptions): SubscribeResult {\n return this.internalSignal_.subscribe(callback, options);\n }\n\n /**\n * Returns a Promise that resolves with the next computed value.\n *\n * @returns A Promise that resolves with the next value.\n */\n public untilNext(): Promise<T> {\n return this.internalSignal_.untilNext();\n }\n\n /**\n * Permanently disposes of the computed signal.\n *\n * This is a critical cleanup step. It unsubscribes from all dependency signals,\n * stopping future recalculations and allowing the signal to be garbage collected.\n * Failure to call `destroy()` will result in memory leaks.\n *\n * After `destroy()` is called, any attempt to access `.get()` or `.subscribe()` will throw an error.\n */\n public destroy(): void {\n this.logger_.logMethod?.('destroy');\n if (this.isDestroyed) {\n this.logger_.incident?.('destroy', 'already_destroyed');\n return;\n }\n\n for (let i = 0; i < this.dependencySubscriptions__.length; i++) {\n this.dependencySubscriptions__[i].unsubscribe();\n }\n this.dependencySubscriptions__.length = 0;\n\n this.internalSignal_.destroy();\n this.config_.onDestroy?.();\n this.config_ = null as unknown as ComputedSignalConfig<T>;\n }\n\n /**\n * Recalculates the derived value.\n * Centralized microtask batcher coordination avoids internal loop crashes.\n *\n * @protected\n */\n protected recalculate_(): void {\n this.logger_.logMethod?.('recalculate_');\n\n if (this.isRecalculating__) {\n // If a recalculation is already scheduled, do nothing.\n this.logger_.logStep?.('recalculate_', 'skipping_recalculation_already_scheduled');\n return;\n }\n\n this.isRecalculating__ = true;\n\n queueMicrotask(() => {\n if (this.isDestroyed) {\n this.logger_.incident?.('recalculate_', 'destroyed_during_delay');\n this.isRecalculating__ = false;\n return;\n }\n\n this.logger_.logStep?.('recalculate_', 'recalculating_value');\n try {\n // Set the new value on the internal signal, which will notify our subscribers.\n this.internalSignal_.set(this.config_.get());\n } catch (err) {\n this.logger_.error('recalculate_', 'projection_evaluation_failed', err);\n }\n\n // Allow the next recalculation to be scheduled.\n this.isRecalculating__ = false;\n });\n }\n}\n",
|
|
9
|
+
"import {createLogger, type AlwatrLogger} from '@alwatr/logger';\nimport {StateSignal} from './state-signal.js';\nimport type {\n IReadonlySignal,\n DerivedSignalConfig,\n ListenerCallback,\n SubscribeOptions,\n SubscribeResult,\n} from '../type.js';\n\n/**\n * Ultra-performance read-only signal mapping exactly 1-to-1 over a single upstream source.\n *\n * COMPOSITION DESIGN PATTERN (HAS-A):\n * Instead of extending the heavyweight Base class and duplicating tracking structures, it wraps\n * an internal StateSignal instance. It features a \"Cold Awakening Lifecycle\": it consumes exactly\n * ZERO stream overhead from the source until it receives its own first consumer subscription.\n * If all consumers disconnect, it goes back to sleep (hibernation phase) to save performance.\n *\n * @template S The type of the source signal state.\n * @template T The type of the derived/projected signal state.\n */\nexport class DerivedSignal<S, T> implements IReadonlySignal<T> {\n /** The unique identifier for this signal instance, useful for debugging and tracing. */\n public readonly name: string;\n\n /** Scoped logger for tracking derived operations. */\n protected readonly logger_: AlwatrLogger;\n\n /** Wrapped internal state carrier - Enforcing COMPOSITION over inheritance, allocated lazily */\n protected internalSignal_?: StateSignal<T> | null;\n\n /** Subscription handle to the upstream source signal, active only when awake. */\n private sourceSubscription__?: SubscribeResult;\n\n /** Number of active standard/priority listeners currently subscribed to this signal. */\n private activeConsumerCount__ = 0;\n\n /**\n * Creates a new DerivedSignal instance.\n *\n * @param config_ Configuration options including name, source, and projector.\n */\n constructor(protected config_: DerivedSignalConfig<S, T>) {\n this.name = this.config_.name;\n this.logger_ = createLogger(`derived_signal:${this.name}`);\n }\n\n untilNext(): Promise<T> {\n this.logger_.logMethod?.('untilNext');\n this.checkDestroyed__();\n return new Promise<T>((resolve) => {\n this.subscribe(\n (value) => {\n resolve(value);\n },\n {receivePrevious: false, once: true},\n );\n });\n }\n\n /**\n * Retrieves the current value of the derived signal.\n *\n * If there are no active subscribers (cold state), it re-computes dynamically\n * on demand to ensure strict data freshness.\n *\n * @returns The current projected value.\n */\n public get(): T {\n this.logger_.logMethod?.('get');\n this.checkDestroyed__();\n if (this.activeConsumerCount__ === 0) {\n return this.config_.projector(this.config_.source.get());\n }\n return this.internalSignal_!.get();\n }\n\n /**\n * Indicates whether the signal has been destroyed.\n */\n public get isDestroyed(): boolean {\n return this.config_ === null;\n }\n\n /**\n * Subscribes a listener to updates of this derived signal.\n *\n * In case of first subscription, it triggers the \"Cold Awakening Lifecycle\"\n * to subscribe to the source signal.\n *\n * @param callback Subscription callback function.\n * @param options Subscription configurations.\n * @returns Unsubscribe handle object.\n */\n public subscribe(callback: ListenerCallback<T>, options?: SubscribeOptions): SubscribeResult {\n this.logger_.logMethod?.('subscribe');\n this.checkDestroyed__();\n this.activeConsumerCount__++;\n\n // Wake-up phase: if this is the first active consumer, dynamically clamp to the upstream core source\n if (this.activeConsumerCount__ === 1) {\n this.logger_.logMethod?.('wakeUp_');\n this.internalSignal_ = new StateSignal<T>({\n name: `derived-internal:${this.name}`,\n initialValue: this.config_.projector(this.config_.source.get()),\n });\n this.sourceSubscription__ = this.config_.source.subscribe(\n (newValue) => {\n this.internalSignal_!.set(this.config_.projector(newValue));\n },\n {receivePrevious: false},\n );\n }\n\n const sub = this.internalSignal_!.subscribe(callback, options);\n\n return {\n unsubscribe: () => {\n this.logger_.logMethod?.('unsubscribe');\n\n sub.unsubscribe();\n this.activeConsumerCount__--;\n\n // Hibernation phase: unlink tracking dependencies when view elements clear out to preserve processing cycles\n if (this.activeConsumerCount__ === 0 && this.sourceSubscription__) {\n this.logger_.logMethod?.('sleepCleanup_');\n this.sourceSubscription__.unsubscribe();\n this.sourceSubscription__ = undefined;\n this.internalSignal_?.destroy();\n this.internalSignal_ = undefined;\n }\n },\n };\n }\n\n /**\n * Destroys the derived signal and unsubscribes from the source signal if currently awake.\n */\n public destroy(): void {\n this.logger_.logMethod?.('destroy');\n if (this.isDestroyed) return;\n\n if (this.sourceSubscription__) {\n this.sourceSubscription__.unsubscribe();\n this.sourceSubscription__ = undefined;\n }\n\n this.internalSignal_?.destroy();\n this.config_.onDestroy?.();\n this.config_ = null as unknown as DerivedSignalConfig<S, T>;\n }\n\n /**\n * Checks if the signal has been destroyed.\n *\n * @private\n * @throws {Error} If destroyed.\n */\n private checkDestroyed__(): void {\n this.logger_.logMethod?.('checkDestroyed__');\n if (this.isDestroyed) {\n throw new Error(`Cannot interact with a destroyed signal (id: ${this.name})`);\n }\n }\n}\n",
|
|
10
|
+
"import {delay} from '@alwatr/delay';\nimport {createLogger, type AlwatrLogger} from '@alwatr/logger';\nimport type {EffectSignalConfig, IEffectSignal, SubscribeResult} from '../type.js';\n\n/**\n * Manages a side-effect that runs in response to changes in dependency signals.\n *\n * `EffectSignal` is designed for running logic that interacts with the \"outside world\"—such as\n * logging, network requests, or DOM manipulation—whenever its dependencies are updated.\n * It encapsulates the subscription and cleanup logic, providing a robust and memory-safe\n * way to handle reactive side-effects.\n *\n * A key feature is its lifecycle management: an `EffectSignal` **must** be destroyed when no longer\n * needed to prevent memory leaks and stop the effect from running unnecessarily.\n *\n * @implements {IEffectSignal}\n *\n * @example\n * // --- Create dependency signals ---\n * const counter = new StateSignal({ initialValue: 0, name: 'counter' });\n * const user = new StateSignal({ initialValue: 'guest', name: 'user' });\n *\n * // --- Create an effect ---\n * const analyticsEffect = new EffectSignal({\n * name: 'analytics-effect',\n * deps: [counter, user],\n * run: () => {\n * console.log(`Analytics: User '${user.get()}' clicked ${counter.get()} times.`);\n * },\n * runImmediately: true, // Optional: run once on creation\n * });\n * // Immediately logs: \"Analytics: User 'guest' clicked 0 times.\"\n *\n * // --- Trigger the effect by updating a dependency ---\n * counter.set(1);\n * // After a macrotask, logs: \"Analytics: User 'guest' clicked 1 times.\"\n *\n * // --- IMPORTANT: Clean up when the effect is no longer needed ---\n * analyticsEffect.destroy();\n *\n * // Further updates will not trigger the effect.\n * counter.set(2); // Nothing is logged.\n */\nexport class EffectSignal implements IEffectSignal {\n /**\n * The unique identifier for this signal instance.\n */\n public readonly name: string;\n\n /**\n * The logger instance for this signal.\n *\n * @protected\n */\n protected readonly logger_: AlwatrLogger;\n\n /**\n * A list of subscriptions to dependency signals.\n * Used to unsubscribe from dependencies when this signal is destroyed.\n *\n * @private\n */\n private readonly dependencySubscriptions__: SubscribeResult[] = [];\n\n /**\n * A flag to prevent concurrent executions of the effect.\n * Avoids scheduling multiple runs within the same event loop.\n *\n * @private\n */\n private isRunning__ = false;\n\n /**\n * A flag indicating whether the effect has been destroyed.\n *\n * @private\n */\n private isDestroyed__ = false;\n\n /**\n * Indicates whether the effect signal has been destroyed.\n * A destroyed signal will no longer execute its effect and cannot be reused.\n *\n * @returns `true` if the signal is destroyed, `false` otherwise.\n */\n public get isDestroyed(): boolean {\n return this.isDestroyed__;\n }\n\n /**\n * Creates a new EffectSignal instance.\n * Subscribes to all dependency signals to listen for updates.\n *\n * @param config_ Configuration options including dependencies, side-effect runner callback, and immediate execution flag.\n */\n constructor(protected config_: EffectSignalConfig) {\n this.name = config_.name ?? `[${config_.deps.map((dep) => dep.name).join(', ')}]`;\n this.logger_ = createLogger(`effect-signal:${this.name}`);\n this.scheduleExecution_ = this.scheduleExecution_.bind(this);\n\n this.logger_.logMethod?.('constructor');\n\n // Subscribe to all dependencies. We don't need the previous value,\n // as the `runImmediately` option controls the initial execution.\n for (const signal of config_.deps) {\n this.logger_.logStep?.('constructor', 'subscribing_to_dependency', {signal: signal.name});\n this.dependencySubscriptions__.push(signal.subscribe(this.scheduleExecution_, {receivePrevious: false}));\n }\n\n // Run the effect immediately if requested.\n if (config_.runImmediately === true) {\n this.logger_.logStep?.('constructor', 'scheduling_initial_execution');\n // We don't need to await this, let it run in the background.\n void this.scheduleExecution_();\n }\n }\n\n /**\n * Schedules the execution of the effect's `run` function.\n *\n * This method batches updates using a macrotask (`delay.nextMicrotask`) to ensure the\n * `run` function executes only once per event loop tick, even if multiple\n * dependencies change simultaneously.\n *\n * @protected\n * @returns A promise that resolves when the execution schedules or runs.\n */\n protected async scheduleExecution_(): Promise<void> {\n this.logger_.logMethod?.('scheduleExecution_');\n\n if (this.isDestroyed__) {\n this.logger_.incident?.('scheduleExecution_', 'schedule_execution_on_destroyed_signal');\n return;\n }\n if (this.isRunning__) {\n // If an execution is already scheduled, do nothing.\n this.logger_.logStep?.('scheduleExecution_', 'skipped_because_already_running');\n return;\n }\n\n this.isRunning__ = true;\n\n try {\n // Wait for the next macrotask to batch simultaneous updates.\n await delay.nextMicrotask();\n if (this.isDestroyed__) {\n this.logger_.incident?.('scheduleExecution_', 'destroyed_during_delay');\n this.isRunning__ = false;\n return;\n }\n\n this.logger_.logStep?.('scheduleExecution_', 'executing_effect');\n this.config_.run();\n } catch (err) {\n this.logger_.error('scheduleExecution_', 'effect_failed', err);\n }\n\n // Reset the flag after the current execution is complete.\n this.isRunning__ = false;\n }\n\n /**\n * Permanently disposes of the effect signal.\n *\n * This is a critical cleanup step. It unsubscribes from all dependency signals,\n * stopping any future executions of the effect and allowing it to be garbage collected.\n * Failure to call `destroy()` will result in memory leaks and potentially unwanted side effects.\n */\n public destroy(): void {\n this.logger_.logMethod?.('destroy');\n\n if (this.isDestroyed__) {\n this.logger_.incident?.('destroy', 'already_destroyed');\n return;\n }\n\n this.isDestroyed__ = true;\n\n // Unsubscribe from all upstream dependencies.\n for (const subscription of this.dependencySubscriptions__) {\n subscription.unsubscribe();\n }\n this.dependencySubscriptions__.length = 0; // Clear the array of subscriptions.\n\n this.config_.onDestroy?.(); // Call the optional onDestroy callback.\n this.config_ = null as unknown as EffectSignalConfig; // Release config closure.\n }\n}\n",
|
|
11
|
+
"import {createDebouncer} from '@alwatr/debounce';\nimport {createLocalStorageProvider} from '@alwatr/local-storage';\nimport {StateSignal} from './state-signal.js';\nimport type {PersistentStateSignalConfig} from '../type.js';\nimport type {LocalStorageProvider} from '@alwatr/local-storage';\n\n/**\n * A stateful signal that persists its value in the browser's localStorage.\n *\n * It extends the functionality of a standard `StateSignal` by automatically reading\n * its initial value from localStorage and writing back any subsequent changes.\n * The data persists across browser sessions and full page reloads until explicitly removed.\n *\n * @template T The type of the state it holds. If custom `parse` and `stringify` functions are\n * provided in the config, T can be any type. If they are not provided, T must be JSON-serializable\n * (using the default `JSON.parse` and `JSON.stringify`).\n *\n * @example\n * ```typescript\n * import {PersistentStateSignal} from '@alwatr/signal';\n *\n * // Example 1: Basic usage with JSON-serializable state\n * interface UserPreferences {\n * theme: 'light' | 'dark';\n * language: string;\n * }\n *\n * const preferencesSignal = new PersistentStateSignal<UserPreferences>({\n * name: 'user-preferences',\n * initialValue: { theme: 'light', language: 'en' },\n * });\n *\n * // Example 2: Custom state type with parse and stringify\n * const lastVisitSignal = new PersistentStateSignal<Date>({\n * name: 'last-visit',\n * initialValue: new Date(),\n * parse: (str: string) => new Date(str),\n * stringify: (date: Date) => date.toISOString(),\n * });\n *\n * // The state is restored from localStorage on every page load.\n * console.log(preferencesSignal.get());\n *\n * // Updates are automatically saved to localStorage (debounced).\n * preferencesSignal.set({ theme: 'dark', language: 'fa' });\n * ```\n */\nexport class PersistentStateSignal<T> extends StateSignal<T> {\n /**\n * The underlying storage provider instance.\n * Handles read, write, and schema version management under the hood.\n *\n * @private\n */\n private readonly storageProvider__: LocalStorageProvider<T>;\n\n /**\n * Debouncer to limit how often we write to localStorage.\n * Reduces performance overhead from excessive disk writes.\n *\n * @private\n */\n private readonly storageDebouncer__;\n\n /**\n * The subscription to the signal's own changes to sync with storage.\n * We subscribe to our own signal. When the value is set from anywhere,\n * this listener will trigger and write it to localStorage.\n *\n * @private\n */\n private readonly storageSyncSubscription__;\n\n /**\n * Listener for the browser's pagehide events to flush pending saves.\n * Ensures that pending changes are saved before the page unloading.\n *\n * @private\n */\n private readonly windowPageHideListener_ = (): void => {\n this.storageDebouncer__.flush();\n };\n\n /**\n * Listener for the browser's pageshow events to sync from storage when restored from BFCache.\n * Refreshes the in-memory value if retrieved from the Back/Forward Cache.\n *\n * @private\n */\n private readonly windowPageShowListener_ = (event: PageTransitionEvent): void => {\n if (event.persisted) {\n this.logger_.logMethod?.('windowPageShowListener_//restored_from_bfcache');\n const value = this.storageProvider__.read();\n if (value !== null) {\n this.set(value);\n }\n }\n };\n\n /**\n * Creates a new PersistentStateSignal instance.\n * Restores initial value from storage if it exists, otherwise uses default initialValue.\n * Sets up window page visibility and BFCache listeners to guarantee write flushes.\n *\n * @param config Configuration options including storage keys, debounce delays, schema, parse, and stringify overrides.\n */\n constructor(config: PersistentStateSignalConfig<T>) {\n const {\n name,\n storageKey = name,\n saveDebounceDelay = 1000,\n initialValue,\n onDestroy,\n schemaVersion,\n parse,\n stringify,\n } = config;\n\n const storageProvider = createLocalStorageProvider<T>({\n name: storageKey,\n schemaVersion,\n parse,\n stringify,\n });\n\n super({\n name,\n initialValue: storageProvider.read() ?? initialValue,\n onDestroy,\n });\n\n this.logger_.logMethodArgs?.('constructor', config);\n\n this.storageProvider__ = storageProvider;\n\n this.storageDebouncer__ = createDebouncer({\n delay: saveDebounceDelay,\n leading: false,\n trailing: true,\n thisContext: this,\n func: this.syncStorage__,\n });\n\n this.storageSyncSubscription__ = this.subscribe(this.storageDebouncer__.trigger, {receivePrevious: false});\n\n if (typeof globalThis.addEventListener === 'function') {\n globalThis.addEventListener('pagehide', this.windowPageHideListener_, {passive: true});\n globalThis.addEventListener('pageshow', this.windowPageShowListener_, {passive: true});\n }\n }\n\n /**\n * Syncs the new value to storage.\n * Invoked automatically by the debouncer.\n *\n * @param newValue The new value to write to storage.\n * @private\n */\n private syncStorage__(newValue: T): void {\n this.logger_.logMethodArgs?.('syncStorage__', newValue);\n this.storageProvider__.write(newValue);\n }\n\n /**\n * Removes the value from localStorage.\n * This provides a clean way to clear persisted data.\n */\n public remove(): void {\n this.checkDestroyed_();\n this.logger_.logMethod?.('remove');\n // Remove from storage.\n this.storageProvider__.remove();\n }\n\n /**\n * Overrides the destroy method to also clean up the storage sync subscription and event listeners.\n */\n public override destroy(): void {\n this.logger_.logMethod?.('destroy');\n if (typeof globalThis.removeEventListener === 'function') {\n globalThis.removeEventListener('pagehide', this.windowPageHideListener_);\n globalThis.removeEventListener('pageshow', this.windowPageShowListener_);\n }\n // Flush any pending storage writes before destroying.\n this.storageDebouncer__.flush();\n // Unsubscribe from the sync listener to prevent memory leaks.\n this.storageSyncSubscription__.unsubscribe();\n super.destroy();\n }\n}\n",
|
|
12
|
+
"import {createDebouncer} from '@alwatr/debounce';\nimport {createSessionStorageProvider} from '@alwatr/session-storage';\nimport {StateSignal} from './state-signal.js';\nimport type {SessionStateSignalConfig} from '../type.js';\nimport type {SessionStorageProvider} from '@alwatr/session-storage';\n\n/**\n * A stateful signal that persists its value in the browser's `sessionStorage`.\n *\n * It extends `StateSignal` by automatically reading its initial value from `sessionStorage`\n * and writing back any subsequent changes. Unlike `PersistentStateSignal`, the data is cleared\n * automatically when the browser tab or window is closed — it does not survive full page reloads\n * in a new session.\n *\n * This is ideal for transient UI state that should survive soft navigations and refreshes\n * within the same browser tab (e.g., wizard steps, unsaved form drafts, scroll position).\n *\n * @template T The type of the state it holds. If custom `parse` and `stringify` functions are\n * provided in the config, T can be any type. If they are not provided, T must be JSON-serializable\n * (using the default `JSON.parse` and `JSON.stringify`).\n *\n * @example\n * ```typescript\n * import {SessionStateSignal} from '@alwatr/signal';\n *\n * // Example 1: Basic usage with JSON-serializable state (default parse/stringify)\n * interface WizardState {\n * step: number;\n * answers: Record<string, string>;\n * }\n *\n * const wizardSignal = new SessionStateSignal<WizardState>({\n * name: 'checkout-wizard',\n * initialValue: { step: 1, answers: {} },\n * });\n *\n * // On first load: reads from sessionStorage (or uses initialValue if not found).\n * console.log(wizardSignal.get()); // { step: 1, answers: {} }\n *\n * // Update state — written to sessionStorage automatically (debounced).\n * wizardSignal.set({ step: 2, answers: { q1: 'yes' } });\n *\n * // Example 2: Custom state type with parse and stringify\n * const dateSignal = new SessionStateSignal<Date>({\n * name: 'timestamp-signal',\n * initialValue: new Date(),\n * parse: (str: string) => new Date(str),\n * stringify: (date: Date) => date.toISOString(),\n * });\n *\n * // After a soft page reload, the state is restored from sessionStorage.\n *\n * // Clear the persisted session data without destroying the signal.\n * wizardSignal.remove();\n *\n * // Clean up when the component/page is unmounted.\n * wizardSignal.destroy();\n * ```\n */\nexport class SessionStateSignal<T> extends StateSignal<T> {\n /**\n * The underlying session storage provider instance.\n *\n * @private\n */\n private readonly storageProvider__: SessionStorageProvider<T>;\n\n /**\n * Debouncer to limit how often we write to sessionStorage.\n * Helps reduce synchronous overhead from session storage updates.\n *\n * @private\n */\n private readonly storageDebouncer__;\n\n /**\n * Subscription to the signal's own changes for sessionStorage sync.\n * Writes the value to sessionStorage after a debounce delay.\n *\n * @private\n */\n private readonly storageSyncSubscription__;\n\n /**\n * Listener for the browser's pagehide events to flush pending saves.\n * Ensures pending state changes are flushed to sessionStorage before leaving the page.\n *\n * @private\n */\n private readonly windowPageHideListener__ = (): void => {\n this.storageDebouncer__.flush();\n };\n\n /**\n * Listener for the browser's pageshow events to sync from storage when restored from BFCache.\n * Ensures in-memory sync when restored from the back-forward cache.\n *\n * @private\n */\n private readonly windowPageShowListener__ = (event: PageTransitionEvent): void => {\n if (event.persisted) {\n this.logger_.logMethod?.('windowPageShowListener__//restored_from_bfcache');\n const value = this.storageProvider__.read();\n if (value !== null) {\n this.set(value);\n }\n }\n };\n\n /**\n * Creates a new SessionStateSignal instance.\n * Loads initial value from sessionStorage if found, otherwise uses config's initialValue.\n * Sets up page hide/show lifecycle handlers.\n *\n * @param config Configuration options including storageKeys, custom parse/stringify, and debounce delay.\n */\n constructor(config: SessionStateSignalConfig<T>) {\n const {name, storageKey = name, saveDebounceDelay = 1000, initialValue, onDestroy, parse, stringify} = config;\n\n const storageProvider = createSessionStorageProvider<T>({\n name: storageKey,\n parse,\n stringify,\n });\n\n super({\n name,\n initialValue: storageProvider.read() ?? initialValue,\n onDestroy,\n });\n\n this.logger_.logMethodArgs?.('constructor', config);\n\n this.storageProvider__ = storageProvider;\n\n this.storageDebouncer__ = createDebouncer({\n delay: saveDebounceDelay,\n leading: false,\n trailing: true,\n thisContext: this,\n func: this.syncStorage__,\n });\n\n this.storageSyncSubscription__ = this.subscribe(this.storageDebouncer__.trigger, {receivePrevious: false});\n\n if (typeof globalThis.addEventListener === 'function') {\n globalThis.addEventListener('pagehide', this.windowPageHideListener__, {passive: true});\n globalThis.addEventListener('pageshow', this.windowPageShowListener__, {passive: true});\n }\n }\n\n /**\n * Syncs the new value to sessionStorage.\n * Called automatically by the debouncer after each state change.\n *\n * @param newValue The new value to sync.\n * @private\n */\n private syncStorage__(newValue: T): void {\n this.logger_.logMethodArgs?.('syncStorage__', newValue);\n this.storageProvider__.write(newValue);\n }\n\n /**\n * Removes the stored value from sessionStorage without destroying the signal.\n *\n * After calling this, the signal continues to hold its current in-memory value;\n * only the sessionStorage entry is cleared.\n *\n * @example\n * ```typescript\n * // User logs out — clear transient session data.\n * wizardSignal.remove();\n * ```\n */\n public remove(): void {\n this.checkDestroyed_();\n this.logger_.logMethod?.('remove');\n this.storageProvider__.remove();\n }\n\n /**\n * Destroys the signal, flushing pending writes and cleaning up all resources and events.\n *\n * Always call this when the signal is no longer needed (e.g., on component unmount)\n * to prevent memory leaks.\n *\n * @example\n * ```typescript\n * // In a component teardown:\n * wizardSignal.destroy();\n * ```\n */\n public override destroy(): void {\n this.logger_.logMethod?.('destroy');\n if (typeof globalThis.removeEventListener === 'function') {\n globalThis.removeEventListener('pagehide', this.windowPageHideListener__);\n globalThis.removeEventListener('pageshow', this.windowPageShowListener__);\n }\n // Flush any pending debounced writes before destroying.\n this.storageDebouncer__.flush();\n // Unsubscribe the storage sync listener to prevent memory leaks.\n this.storageSyncSubscription__.unsubscribe();\n super.destroy();\n }\n}\n",
|
|
13
|
+
"import {queueMicrotask} from '@alwatr/delay';\nimport {createLogger, type AlwatrLogger} from '@alwatr/logger';\nimport {SignalBase} from './signal-base.js';\nimport type {\n SubscribeOptions,\n SubscribeResult,\n ListenerCallback,\n ChannelHandler,\n ChannelMessage,\n ChannelSignalConfig,\n DispatchArgs,\n} from '../type.js';\n\n/**\n * Internal handler type used inside `namedHandlers__`.\n *\n * At the storage boundary we erase the conditional payload type to `unknown`\n * so TypeScript does not need to evaluate the conditional against every\n * possible `K`. Type safety is already enforced at the public `on()` and\n * `dispatch()` call sites — the internal executor only needs to call the\n * function with the value it received.\n *\n * @internal\n */\ntype InternalHandler = (payload: unknown) => void;\n\n// ─── Class ────────────────────────────────────────────────────────────────────\n\n/**\n * A stateless multi-channel signal that acts as a typed O(1) message bus.\n *\n * `ChannelSignal` is ideal when you need a single signal to carry multiple\n * distinct message types — each identified by a `name` — rather than creating\n * a separate `EventSignal` for every event.\n *\n * ### Routing architecture\n *\n * Internally, `on()` subscriptions are stored in a per-name `Map` of handler\n * sets. When a message is dispatched, only the handlers registered for that\n * specific name are invoked — O(1) lookup regardless of how many distinct\n * names are subscribed. The inherited `SignalBase` observer list is used\n * exclusively by `subscribe()`, which receives the raw message stream for\n * logging or middleware purposes.\n *\n * ### Type safety\n *\n * The generic parameter `TMap` is a record that maps every valid message name\n * to its payload type. TypeScript enforces the correct payload type at both\n * `dispatch` and `on` call sites.\n *\n * @template TMap A record mapping message names to their payload types.\n *\n * @example\n * ```ts\n * interface AppMessages {\n * 'open-drawer': {panel: string};\n * 'close-drawer': void;\n * 'show-toast': {message: string; type: 'info' | 'error'};\n * }\n *\n * const appChannel = new ChannelSignal<AppMessages>({name: 'app-channel'});\n *\n * // Subscribe to a specific message — handler receives payload directly\n * appChannel.on('open-drawer', (payload) => {\n * openDrawer(payload!.panel);\n * });\n *\n * // Dispatch a typed message\n * appChannel.dispatch('open-drawer', {panel: 'settings'});\n * appChannel.dispatch('close-drawer'); // no payload needed\n * ```\n */\nexport class ChannelSignal<TMap extends object> extends SignalBase<ChannelMessage<TMap>> {\n /**\n * The logger instance for this signal.\n *\n * @protected\n */\n protected logger_: AlwatrLogger;\n\n /**\n * Per-name handler registry for O(1) routing.\n *\n * Each key is a message name; the value is a Set of `{handler, once}` entries\n * registered via `on()`. Kept separate from `SignalBase`'s observer list so\n * that `subscribe()` (raw stream) and `on()` (named routing) never interfere.\n *\n * Stored as `InternalHandler` (erased to `unknown` payload) to avoid\n * unevaluable conditional types at the storage boundary. Type safety is\n * enforced at the public `on()` and `dispatch()` call sites.\n *\n * @private\n */\n private readonly namedHandlers__ = new Map<keyof TMap, Set<{handler: InternalHandler; once: boolean}>>();\n\n /**\n * Creates a new ChannelSignal instance.\n *\n * @param config Configuration options including the unique channel name and cleanup hook.\n */\n constructor(config: ChannelSignalConfig) {\n super(config);\n this.logger_ = createLogger(`channel_signal:${this.name}`);\n this.logger_.logMethod?.('constructor');\n }\n\n /**\n * Dispatches a named message to:\n * 1. All handlers registered via `on(name, …)` for this specific name — O(1).\n * 2. All raw-stream subscribers registered via `subscribe()` — O(N subscribers).\n *\n * The notification is scheduled as a microtask to ensure non-blocking,\n * consistent delivery — matching the behavior of `EventSignal`.\n *\n * ### Payload enforcement\n *\n * The payload argument is **required** unless the declared type in `TMap` is\n * `void` or `undefined`. Omitting a required payload — or passing `undefined`\n * for a non-optional type — is a **compile error**. This prevents accidental\n * `undefined` from propagating into handlers that expect a real value.\n *\n * ```ts\n * // TMap: { 'add-to-cart': {productId: number}; 'logout': void }\n * channel.dispatch('add-to-cart', {productId: 42}); // ✅ required payload\n * channel.dispatch('add-to-cart'); // ❌ compile error\n * channel.dispatch('logout'); // ✅ void — no payload\n * channel.dispatch('logout', undefined); // ✅ also fine\n * ```\n *\n * @template K The specific message name key.\n * @param args Tuple of `[name, payload]` — payload optionality is enforced\n * by `DispatchArgs<TMap, K>` based on the declared type.\n */\n public dispatch<K extends keyof TMap>(...args: DispatchArgs<TMap, K>): void {\n const [name, payload] = args;\n this.logger_.logMethodArgs?.('dispatch', {name, payload});\n this.checkDestroyed_();\n queueMicrotask(() => this.route__(name, payload));\n }\n\n /**\n * Subscribes to a specific named message on this channel.\n *\n * Uses an internal per-name handler map for O(1) routing — dispatching a\n * message with name `'A'` will never invoke handlers registered for `'B'`.\n *\n * The handler receives the `payload` directly (not the full `{name, payload}`\n * envelope) — since the name is already known at subscription time, passing\n * it again would be redundant.\n *\n * @template K The specific message name key.\n * @param name The message name to listen for.\n * @param handler Callback invoked with the payload each time the named message\n * is dispatched.\n * @param options Standard subscribe options. Only `once` is supported here;\n * `priority` applies to `subscribe()` (raw stream) only.\n * @returns A `SubscribeResult` with an `unsubscribe()` method for cleanup.\n *\n * @example\n * ```ts\n * const sub = channel.on('open-drawer', (payload) => {\n * openDrawer(payload!.panel);\n * });\n *\n * // Stop listening when the component is destroyed\n * sub.unsubscribe();\n * ```\n */\n public on<K extends keyof TMap>(\n name: K,\n handler: ChannelHandler<TMap, K>,\n options?: Pick<SubscribeOptions, 'once'>,\n ): SubscribeResult {\n this.logger_.logMethodArgs?.('on', {name});\n this.checkDestroyed_();\n\n // Retrieve or create the handler set for this message name.\n let handlerSet = this.namedHandlers__.get(name);\n if (!handlerSet) {\n handlerSet = new Set();\n this.namedHandlers__.set(name, handlerSet);\n }\n\n const entry = {handler: handler as InternalHandler, once: options?.once ?? false};\n handlerSet.add(entry);\n\n return {\n unsubscribe: (): void => {\n handlerSet!.delete(entry);\n // Clean up the empty set to avoid memory leaks on long-lived channels.\n if (handlerSet!.size === 0) {\n this.namedHandlers__.delete(name);\n }\n },\n };\n }\n\n /**\n * Subscribes to **all** messages dispatched on this channel, regardless of name.\n *\n * Use this when you need to observe the raw message stream — for example,\n * for logging, debugging, or middleware-style processing.\n *\n * Prefer `on(name, handler)` for normal use cases to keep subscriptions\n * focused and type-safe.\n *\n * @param callback The function called with every `ChannelMessage`.\n * @param options Standard subscribe options.\n * @returns A `SubscribeResult` with an `unsubscribe()` method.\n *\n * @example\n * ```ts\n * // Log every message for debugging\n * channel.subscribe((msg) => console.log('[channel]', msg.name, msg.payload));\n * ```\n */\n public override subscribe(\n callback: ListenerCallback<ChannelMessage<TMap>>,\n options?: SubscribeOptions,\n ): SubscribeResult {\n this.logger_.logMethodArgs?.('subscribe', options);\n return super.subscribe(callback, options);\n }\n\n /**\n * Core routing method — called inside the microtask scheduled by `dispatch`.\n *\n * 1. Looks up the per-name handler set in O(1).\n * 2. Invokes each handler, removing `once` entries after their first call.\n * 3. Notifies raw-stream subscribers via `SignalBase.notify_()`.\n *\n * @template K The specific message name key.\n * @param name The message name to route.\n * @param payload The payload associated with the message name.\n * @private\n */\n private route__<K extends keyof TMap>(name: K, payload: TMap[K] | undefined): void {\n if (this.isDestroyed) return;\n // ── Named handlers (O(1) lookup) ──────────────────────────────────────────\n const handlerSet = this.namedHandlers__.get(name);\n if (handlerSet?.size) {\n for (const entry of handlerSet) {\n if (entry.once) {\n handlerSet.delete(entry);\n if (handlerSet.size === 0) this.namedHandlers__.delete(name);\n }\n try {\n entry.handler(payload);\n } catch (err) {\n this.logger_.error('route__', 'sync_named_handler_failed', err);\n }\n }\n }\n\n // ── Raw-stream subscribers (SignalBase observers) ─────────────────────────\n this.notify_({name, payload} as ChannelMessage<TMap>);\n }\n\n /**\n * Destroys the signal, clearing all named handlers and raw-stream subscribers.\n */\n public override destroy(): void {\n this.namedHandlers__.clear();\n super.destroy();\n }\n}\n",
|
|
13
14
|
"import {EventSignal} from '../core/event-signal.js';\n\nimport type {SignalConfig} from '../type.js';\n\n/**\n * Creates a stateless signal for dispatching transient events.\n *\n * `EventSignal` is ideal for broadcasting events that do not have a persistent state.\n * Unlike `StateSignal`, it does not hold a value. Listeners are only notified of new\n * events as they are dispatched. This makes it suitable for modeling user interactions,\n * system notifications, or any one-off message.\n *\n * @template T The type of the payload for the events.\n *\n * @param config The configuration for the event signal.\n * @returns A new instance of EventSignal.\n *\n * @example\n * const onUserClick = createEventSignal<{ x: number, y: number }>({\n * name: 'on-user-click'\n * });\n *\n * onUserClick.subscribe(pos => {\n * console.log(`User clicked at: ${pos.x}, ${pos.y}`);\n * });\n *\n * onUserClick.dispatch({ x: 100, y: 250 });\n */\nexport function createEventSignal<T = void>(config: SignalConfig): EventSignal<T> {\n return new EventSignal<T>(config);\n}\n",
|
|
14
15
|
"import {StateSignal} from '../core/state-signal.js';\n\nimport type {StateSignalConfig} from '../type.js';\n\n/**\n * Creates a stateful signal that holds a value and notifies listeners when the value changes.\n *\n * `StateSignal` is the core of the signal library, representing a piece of mutable state.\n * It always has a value, and new subscribers immediately receive the current value by default.\n *\n * @template T The type of the state it holds.\n *\n * @param config The configuration for the state signal.\n * @returns A new instance of StateSignal.\n *\n * @example\n * const counter = createStateSignal({\n * name: 'counter-signal',\n * initialValue: 0,\n * });\n *\n * console.log(counter.get()); // Outputs: 0\n * counter.set(1);\n * console.log(counter.get()); // Outputs: 1\n */\nexport function createStateSignal<T>(config: StateSignalConfig<T>): StateSignal<T> {\n return new StateSignal(config);\n}\n",
|
|
15
16
|
"import {ComputedSignal} from '../core/computed-signal.js';\n\nimport type {ComputedSignalConfig} from '../type.js';\n\n/**\n * Creates a read-only signal that derives its value from a set of dependency signals.\n *\n * `ComputedSignal` is a powerful tool for creating values that reactively update when their underlying\n * data sources change. Its value is memoized, meaning the `get` function is only re-evaluated when\n * one of its dependencies has actually changed.\n *\n * A key feature is its lifecycle management: a `ComputedSignal` **must** be destroyed when no longer\n * needed to prevent memory leaks from its subscriptions to dependency signals.\n *\n * @template T The type of the computed value.\n *\n * @param config The configuration for the computed signal.\n * @returns A new, read-only computed signal.\n *\n * @example\n * const firstName = createStateSignal({ name: 'firstName', initialValue: 'John' });\n * const lastName = createStateSignal({ name: 'lastName', initialValue: 'Doe' });\n *\n * const fullName = createComputedSignal({\n * name: 'fullName',\n * deps: [firstName, lastName],\n * get: () => `${firstName.get()} ${lastName.get()}`,\n * });\n *\n * console.log(fullName.get()); // \"John Doe\"\n *\n * // IMPORTANT: Always destroy a computed signal when no longer needed.\n * // fullName.destroy();\n */\nexport function createComputedSignal<T>(config: ComputedSignalConfig<T>): ComputedSignal<T> {\n return new ComputedSignal(config);\n}\n",
|
|
17
|
+
"import {DerivedSignal} from '../core/derived-signal.js';\n\nimport type {DerivedSignalConfig} from '../type.js';\n\n/**\n * Creates a read-only signal mapping exactly 1-to-1 over a single upstream source.\n *\n * `createDerivedSignal` is a utility function to instantiate `DerivedSignal` without using the `new` keyword.\n * A derived signal wraps a source signal and maps its value to a new representation using a projector function.\n * It uses the \"Cold Awakening Lifecycle\" pattern, which avoids subscribing to the source signal until the derived\n * signal has at least one subscriber of its own, saving processing cycles.\n *\n * @template S The type of the source signal's state.\n * @template T The type of the projected derived state.\n *\n * @param config Configuration options including name, source, and projector.\n * @returns A new, readonly derived signal.\n *\n * @example\n * ```typescript\n * const countSignal = createStateSignal({ name: 'count', initialValue: 5 });\n *\n * const isEvenSignal = createDerivedSignal({\n * name: 'is-even-signal',\n * source: countSignal,\n * projector: (count) => count % 2 === 0\n * });\n *\n * console.log(isEvenSignal.get()); // false\n * ```\n */\nexport function createDerivedSignal<S, T>(config: DerivedSignalConfig<S, T>): DerivedSignal<S, T> {\n return new DerivedSignal(config);\n}\n",
|
|
16
18
|
"import {EffectSignal} from '../core/effect-signal.js';\n\nimport type {EffectSignalConfig} from '../type.js';\n\n/**\n * Creates a side-effect that runs in response to changes in dependency signals.\n *\n * `EffectSignal` is designed for running logic that interacts with the \"outside world\"—such as\n * logging, network requests, or DOM manipulation—whenever its dependencies are updated.\n * It encapsulates the subscription and cleanup logic, providing a robust and memory-safe\n * way to handle reactive side-effects.\n *\n * A key feature is its lifecycle management: an `EffectSignal` **must** be destroyed when no longer\n * needed to prevent memory leaks and stop the effect from running unnecessarily.\n *\n * @param config The configuration for the effect.\n * @returns An object with a `destroy` method to stop the effect.\n *\n * @example\n * // --- Create dependency signals ---\n * const counter = createStateSignal({ initialValue: 0, name: 'counter' });\n * const user = createStateSignal({ initialValue: 'guest', name: 'user' });\n *\n * // --- Create an effect ---\n * const analyticsEffect = createEffect({\n * deps: [counter, user],\n * run: () => {\n * console.log(`Analytics: User '${user.get()}' clicked ${counter.get()} times.`);\n * },\n * runImmediately: true, // Optional: run once on creation\n * });\n * // Immediately logs: \"Analytics: User 'guest' clicked 0 times.\"\n *\n * // --- Trigger the effect by updating a dependency ---\n * counter.set(1);\n * // After a macrotask, logs: \"Analytics: User 'guest' clicked 1 times.\"\n *\n * // --- IMPORTANT: Clean up when the effect is no longer needed ---\n * analyticsEffect.destroy();\n *\n * // Further updates will not trigger the effect.\n * counter.set(2); // Nothing is logged.\n */\nexport function createEffect(config: EffectSignalConfig): EffectSignal {\n return new EffectSignal(config);\n}\n",
|
|
17
19
|
"import {PersistentStateSignal} from '../core/persistent-state-signal.js';\n\nimport type {PersistentStateSignalConfig} from '../type.js';\n\n/**\n * Creates a stateful signal that persists its value in localStorage.\n *\n * This function provides a clean, declarative API for creating state that\n * survives page reloads. It automatically handles reading the initial state\n * from localStorage and saving subsequent updates.\n *\n * @template T The type of the state it holds.\n *\n * @param {PersistentStateSignalConfig<T>} config The configuration for the persistent state signal.\n * @returns {PersistentStateSignal<T>} A new instance of PersistentStateSignal.\n *\n * @example\n * // Create a signal to store user's preferred theme.\n * const userThemeSignal = createPersistentStateSignal<string>({\n * name: 'user-theme',\n * schemaVersion: 1,\n * initialValue: 'light',\n * });\n *\n * // The initial value is read from localStorage, or 'light' if not present.\n * console.log(userThemeSignal.get());\n *\n * // Setting a new value updates the in-memory state and writes to localStorage.\n * userThemeSignal.set('dark');\n */\nexport function createPersistentStateSignal<T>(config: PersistentStateSignalConfig<T>): PersistentStateSignal<T> {\n return new PersistentStateSignal(config);\n}\n",
|
|
18
20
|
"import {SessionStateSignal} from '../core/session-state-signal.js';\n\nimport type {SessionStateSignalConfig} from '../type.js';\n\n/**\n * Creates a stateful signal that persists its value in `sessionStorage`.\n *\n * The stored data survives soft navigations and page refreshes within the same browser tab,\n * but is automatically cleared when the tab or window is closed.\n *\n * Use this for transient UI state such as:\n * - Multi-step wizard progress\n * - Unsaved form drafts\n * - Scroll position or active tab indices\n *\n * @template T The type of the state it holds. Must be JSON-serializable.\n *\n * @param {SessionStateSignalConfig<T>} config The configuration for the session state signal.\n * @returns {SessionStateSignal<T>} A new `SessionStateSignal` instance.\n *\n * @example\n * ```typescript\n * import {createSessionStateSignal} from '@alwatr/signal';\n *\n * const checkoutWizard = createSessionStateSignal<{step: number}>({\n * name: 'checkout-wizard',\n * initialValue: {step: 1},\n * });\n *\n * // State is restored from sessionStorage if it exists.\n * console.log(checkoutWizard.get()); // {step: 1} or last saved value\n *\n * // Update state — automatically saved to sessionStorage.\n * checkoutWizard.set({step: 2});\n *\n * // Cleanup when no longer needed.\n * checkoutWizard.destroy();\n * ```\n */\nexport function createSessionStateSignal<T>(config: SessionStateSignalConfig<T>): SessionStateSignal<T> {\n return new SessionStateSignal(config);\n}\n",
|
|
19
|
-
"import {ChannelSignal} from '../core/channel-signal.js';\
|
|
20
|
-
"import {createDebouncer} from '@alwatr/debounce';\
|
|
21
|
-
"import {
|
|
22
|
-
"import {createComputedSignal} from '../creators/computed.js';\n\nimport type {ComputedSignal} from '../core/computed-signal.js';\nimport type {IReadonlySignal} from '../type.js';\n\n/**\n * Creates a new read-only computed signal that transforms the value of a source\n * signal using a projection function.\n *\n * This operator is analogous to `Array.prototype.map`. It applies a function to\n * each value emitted by the source signal and emits the result.\n *\n * @template T The type of the source signal's value.\n * @template R The type of the projected value.\n *\n * @param sourceSignal The original signal to transform.\n * @param projectFunction A function to apply to each value from the source signal.\n * @param [name] An optional, unique identifier for the new signal for debugging. default: `${sourceSignal.name}-mapped`\n *\n * @returns A new, read-only computed signal with the transformed values.\n *\n * @example\n * const userSignal = createStateSignal({\n * name: 'user',\n * initialValue: { name: 'John', age: 30 },\n * });\n *\n * const userNameSignal = createMappedSignal(\n * userSignal,\n * (user) => user.name,\n * );\n *\n * console.log(userNameSignal.get()); // Outputs: \"John\"\n * // in next macro-task ...\n * userSignal.set({ name: 'Jane', age: 32 });\n * console.log(userNameSignal.get()); // Outputs: \"Jane\"\n */\nexport function createMappedSignal<T, R>(\n sourceSignal: IReadonlySignal<T>,\n projectFunction: (value: T) => R,\n name = `${sourceSignal.name}-mapped`,\n): ComputedSignal<R> {\n return createComputedSignal({\n name: name,\n deps: [sourceSignal],\n get: () => projectFunction(sourceSignal.get()),\n });\n}\n"
|
|
21
|
+
"import {ChannelSignal} from '../core/channel-signal.js';\nimport type {ChannelSignalConfig} from '../type.js';\n\n/**\n * Creates a stateless multi-channel signal that acts as a typed message bus.\n *\n * `ChannelSignal` is ideal when you need a single signal to carry multiple\n * distinct message types — each identified by a `name` — rather than creating\n * a separate `EventSignal` for every event.\n *\n * The generic parameter `TMap` is a record that maps every valid message name\n * to its payload type, giving you full type safety at both dispatch and subscribe sites.\n *\n * @template TMap A record mapping message names to their payload types.\n *\n * @param config The configuration for the channel signal.\n * @returns A new instance of `ChannelSignal`.\n *\n * @example\n * ```ts\n * interface AppMessages {\n * 'open-drawer': {panel: string};\n * 'close-drawer': void;\n * 'show-toast': {message: string; type: 'info' | 'error'};\n * }\n *\n * const appChannel = createChannelSignal<AppMessages>({name: 'app-channel'});\n *\n * // Subscribe to a specific message\n * appChannel.on('show-toast', (payload) => {\n * toast.show(payload!.message, payload!.type);\n * });\n *\n * // Dispatch a message\n * appChannel.dispatch('show-toast', {message: 'Saved!', type: 'info'});\n * appChannel.dispatch('close-drawer');\n * ```\n */\nexport function createChannelSignal<TMap extends object>(config: ChannelSignalConfig): ChannelSignal<TMap> {\n return new ChannelSignal<TMap>(config);\n}\n",
|
|
22
|
+
"import {createDebouncer} from '@alwatr/debounce';\nimport {StateSignal} from '../core/state-signal.js';\nimport type {IReadonlySignal, DebounceSignalConfig} from '../type.js';\n\n/**\n * Creates a new computed signal that debounces updates from a source signal.\n *\n * The returned signal is a `ComputedSignal`, meaning it is read-only and its value is\n * derived from the source. It only updates its value after a specified period of\n * inactivity from the source signal.\n *\n * This operator is essential for handling high-frequency events, such as user input\n * in a search box, resizing a window, or any other event that fires rapidly.\n * By debouncing, you can ensure that expensive operations (like API calls or heavy\n * computations) are only executed once the events have settled.\n *\n * @template T The type of the signal's value.\n *\n * @param {IReadonlySignal<T>} source The original signal to debounce.\n * It can be a `StateSignal`, `ComputedSignal`, or any signal implementing `IReadonlySignal`.\n * @param {DebounceSignalConfig} config Configuration object for the debouncer,\n * including `delay`, `leading`, and `trailing` options from `@alwatr/debounce`.\n *\n * @returns {IComputedSignal<T>} A new, read-only computed signal that emits debounced values.\n * Crucially, you **must** call `.destroy()` on this signal when it's no longer\n * needed to prevent memory leaks by cleaning up internal subscriptions and timers.\n *\n * @example\n * ```typescript\n * // Create a source signal for user input.\n * const searchInput = createStateSignal({\n * name: 'search-input',\n * initialValue: '',\n * });\n *\n * // Create a debounced signal that waits 300ms after the user stops typing.\n * const debouncedSearch = createDebouncedSignal(searchInput, { delay: 300 });\n *\n * // Use an effect to react to the debounced value.\n * createEffect({\n * deps: [debouncedSearch],\n * run: () => {\n * if (debouncedSearch.get()) {\n * console.log(`🚀 Sending API request for: \"${debouncedSearch.get()}\"`);\n * }\n * },\n * });\n *\n * searchInput.set('Alwatr');\n * searchInput.set('Alwatr Signal');\n * // (after 300ms of inactivity)\n * // Logs: \"🚀 Sending API request for: \"Alwatr Signal\"\"\n *\n * // IMPORTANT: Clean up when the component unmounts.\n * // debouncedSearch.destroy();\n * ```\n */\nexport function createDebouncedSignal<T>(source: IReadonlySignal<T>, config: DebounceSignalConfig): IReadonlySignal<T> {\n const name = config.name ?? `${source.name}_debounced`;\n\n const internalSignal = new StateSignal<T>({\n name,\n initialValue: source.get(),\n onDestroy() {\n subscription.unsubscribe();\n debouncer.cancel();\n config.onDestroy?.();\n config = null as unknown as DebounceSignalConfig;\n },\n });\n\n const debouncer = createDebouncer({\n ...config,\n thisContext: internalSignal,\n func: internalSignal.set,\n });\n\n const subscription = source.subscribe(debouncer.trigger, {receivePrevious: false});\n\n return internalSignal;\n}\n",
|
|
23
|
+
"import {createStateSignal} from '../creators/state.js';\nimport type {IReadonlySignal} from '../type.js';\n\n/**\n * Creates a new computed signal that only emits values from a source signal\n * that satisfy a predicate function.\n *\n * This operator is analogous to `Array.prototype.filter`. It is particularly\n * useful for creating effects or other computed signals that should only react\n * to a specific subset of state changes.\n *\n * Note: The resulting signal's value will be `undefined` until the source\n * emits a value that passes the filter.\n *\n * @template T The type of the signal's value.\n *\n * @param sourceSignal The original signal to filter.\n * @param predicate A function that returns `true` if the value should be passed.\n * @param name An optional, unique identifier for the new signal for debugging. default: `${sourceSignal.name}-filtered`\n *\n * @returns A new computed signal that emits filtered values.\n *\n * @example\n * ```typescript\n * const numberSignal = createStateSignal({ name: 'number', initialValue: 0 });\n *\n * const evenNumberSignal = createFilteredSignal(\n * numberSignal,\n * (num) => num % 2 === 0,\n * );\n *\n * createEffect({\n * deps: [evenNumberSignal],\n * run: () => {\n * // This effect only runs for even numbers.\n * // The value can be `undefined` on the first run if initialValue is not even.\n * if (evenNumberSignal.get() !== undefined) {\n * console.log(`Even number detected: ${evenNumberSignal.get()}`);\n * }\n * },\n * runImmediately: true,\n * });\n * // Logs: \"Even number detected: 0\"\n *\n * numberSignal.set(1); // Effect does not run\n * numberSignal.set(2); // Logs: \"Even number detected: 2\"\n * ```\n */\nexport function createFilteredSignal<T>(\n sourceSignal: IReadonlySignal<T>,\n predicate: (value: T) => boolean,\n name = `${sourceSignal.name}_filtered`,\n): IReadonlySignal<T | undefined> {\n const sourceValue = sourceSignal.get();\n const initialValue = predicate(sourceValue) ? sourceValue : undefined;\n\n const internalSignal = createStateSignal({\n name,\n initialValue,\n onDestroy() {\n subscription.unsubscribe();\n },\n });\n\n const subscription = sourceSignal.subscribe((newValue) => {\n if (predicate(newValue)) {\n internalSignal.set(newValue);\n }\n });\n\n return internalSignal;\n}\n"
|
|
23
24
|
],
|
|
24
|
-
"mappings": ";AASO,MAAe,CAAc,CAoCZ,QA/BN,KAYG,mBAAqB,IAAI,IACzB,WAAa,IAAI,IAM5B,cAAgB,MAQb,YAAW,EAAY,CAChC,OAAO,KAAK,cAGd,WAAW,CAAW,EAAuB,CAAvB,eACpB,KAAK,KAAO,EAAQ,KASZ,eAAe,CAAC,EAA8B,CAGtD,GAFA,KAAK,QAAQ,YAAY,iBAAiB,EAEtC,KAAK,cAAe,CACtB,KAAK,QAAQ,WAAW,kBAAmB,qCAAqC,EAChF,OAGF,KAAK,mBAAmB,OAAO,CAAQ,EACvC,KAAK,WAAW,OAAO,CAAQ,EAY1B,SAAS,CAAC,EAA+B,EAA6C,CAC3F,KAAK,QAAQ,gBAAgB,iBAAkB,CAAO,EACtD,KAAK,gBAAgB,EAErB,IAAM,EAAyB,CAAC,WAAU,SAAO,EAEjD,GAAI,GAAS,SACX,KAAK,mBAAmB,IAAI,CAAQ,EAEpC,UAAK,WAAW,IAAI,CAAQ,EAI9B,MAAO,CACL,YAAa,IAAY,KAAK,gBAAgB,CAAQ,CACxD,EAYQ,OAAO,CAAC,EAAgB,CAGhC,GAFA,KAAK,QAAQ,gBAAgB,UAAW,CAAK,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AAO,YAAY,EACnB,EAAS,KAEb,CAAC,EAEK,EAAY,EAAgB,IAC7B,EACH,YAAa,EACb,KAAM,EAAe,GACvB,CAAC,EAEK,EAAe,EAAO,UAAU,EAAU,QAAS,CAAC,gBAAiB,EAAK,CAAC,EAEjF,OAAO,EC/BF,SAAS,EAAuB,CACrC,EACA,EACA,EAAO,GAAG,EAAa,gBACS,CAChC,IAAM,EAAc,EAAa,IAAI,EAC/B,EAAe,EAAU,CAAW,EAAI,EAAc,OAEtD,EAAiB,EAAkB,CACvC,OACA,eACA,SAAS,EAAG,CACV,EAAa,YAAY,EAE7B,CAAC,EAEK,EAAe,EAAa,UAAU,CAAC,IAAa,CACxD,GAAI,EAAU,CAAQ,EACpB,EAAe,IAAI,CAAQ,EAE9B,EAED,OAAO",
|
|
26
|
+
"debugId": "1C7A5CD19792362B64756E2164756E21",
|
|
26
27
|
"names": []
|
|
27
28
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { ComputedSignal } from '../core/computed-signal.js';
|
|
2
1
|
import type { IReadonlySignal, DebounceSignalConfig } from '../type.js';
|
|
3
2
|
/**
|
|
4
3
|
* Creates a new computed signal that debounces updates from a source signal.
|
|
@@ -14,7 +13,7 @@ import type { IReadonlySignal, DebounceSignalConfig } from '../type.js';
|
|
|
14
13
|
*
|
|
15
14
|
* @template T The type of the signal's value.
|
|
16
15
|
*
|
|
17
|
-
* @param {IReadonlySignal<T>}
|
|
16
|
+
* @param {IReadonlySignal<T>} source The original signal to debounce.
|
|
18
17
|
* It can be a `StateSignal`, `ComputedSignal`, or any signal implementing `IReadonlySignal`.
|
|
19
18
|
* @param {DebounceSignalConfig} config Configuration object for the debouncer,
|
|
20
19
|
* including `delay`, `leading`, and `trailing` options from `@alwatr/debounce`.
|
|
@@ -53,5 +52,5 @@ import type { IReadonlySignal, DebounceSignalConfig } from '../type.js';
|
|
|
53
52
|
* // debouncedSearch.destroy();
|
|
54
53
|
* ```
|
|
55
54
|
*/
|
|
56
|
-
export declare function createDebouncedSignal<T>(
|
|
55
|
+
export declare function createDebouncedSignal<T>(source: IReadonlySignal<T>, config: DebounceSignalConfig): IReadonlySignal<T>;
|
|
57
56
|
//# sourceMappingURL=debounce.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debounce.d.ts","sourceRoot":"","sources":["../../src/operators/debounce.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"debounce.d.ts","sourceRoot":"","sources":["../../src/operators/debounce.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,eAAe,EAAE,oBAAoB,EAAC,MAAM,YAAY,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,oBAAoB,GAAG,eAAe,CAAC,CAAC,CAAC,CAuBrH"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { ComputedSignal } from '../core/computed-signal.js';
|
|
2
1
|
import type { IReadonlySignal } from '../type.js';
|
|
3
2
|
/**
|
|
4
3
|
* Creates a new computed signal that only emits values from a source signal
|
|
@@ -20,28 +19,30 @@ import type { IReadonlySignal } from '../type.js';
|
|
|
20
19
|
* @returns A new computed signal that emits filtered values.
|
|
21
20
|
*
|
|
22
21
|
* @example
|
|
22
|
+
* ```typescript
|
|
23
23
|
* const numberSignal = createStateSignal({ name: 'number', initialValue: 0 });
|
|
24
24
|
*
|
|
25
25
|
* const evenNumberSignal = createFilteredSignal(
|
|
26
|
-
*
|
|
27
|
-
*
|
|
26
|
+
* numberSignal,
|
|
27
|
+
* (num) => num % 2 === 0,
|
|
28
28
|
* );
|
|
29
29
|
*
|
|
30
30
|
* createEffect({
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
31
|
+
* deps: [evenNumberSignal],
|
|
32
|
+
* run: () => {
|
|
33
|
+
* // This effect only runs for even numbers.
|
|
34
|
+
* // The value can be `undefined` on the first run if initialValue is not even.
|
|
35
|
+
* if (evenNumberSignal.get() !== undefined) {
|
|
36
|
+
* console.log(`Even number detected: ${evenNumberSignal.get()}`);
|
|
37
|
+
* }
|
|
38
|
+
* },
|
|
39
|
+
* runImmediately: true,
|
|
40
40
|
* });
|
|
41
41
|
* // Logs: "Even number detected: 0"
|
|
42
42
|
*
|
|
43
43
|
* numberSignal.set(1); // Effect does not run
|
|
44
44
|
* numberSignal.set(2); // Logs: "Even number detected: 2"
|
|
45
|
+
* ```
|
|
45
46
|
*/
|
|
46
|
-
export declare function createFilteredSignal<T>(sourceSignal: IReadonlySignal<T>, predicate: (value: T) => boolean, name?: string):
|
|
47
|
+
export declare function createFilteredSignal<T>(sourceSignal: IReadonlySignal<T>, predicate: (value: T) => boolean, name?: string): IReadonlySignal<T | undefined>;
|
|
47
48
|
//# sourceMappingURL=filter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../src/operators/filter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../src/operators/filter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,YAAY,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EACpC,YAAY,EAAE,eAAe,CAAC,CAAC,CAAC,EAChC,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,EAChC,IAAI,SAAkC,GACrC,eAAe,CAAC,CAAC,GAAG,SAAS,CAAC,CAmBhC"}
|