@alwatr/signal 9.33.1 → 9.35.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/dist/dev/main.js +2 -2
- package/dist/dev/main.js.map +3 -3
- package/dist/main.js +3 -3
- package/dist/main.js.map +3 -3
- package/package.json +2 -2
- package/src/core/signal-base.ts +1 -1
package/dist/dev/main.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* 📦 @alwatr/signal v9.
|
|
1
|
+
/* 📦 @alwatr/signal v9.35.0 */
|
|
2
2
|
class K{config_;name;priorityObservers_;observers_;isDestroyed__=!1;get isDestroyed(){return this.isDestroyed__}constructor(G){this.config_=G;this.name=G.name}removeObserver_(G){if(this.logger_.logMethod?.("removeObserver_"),this.isDestroyed__){this.logger_.incident?.("removeObserver_","remove_observer_on_destroyed_signal");return}if(G.options?.priority){if(this.priorityObservers_?.delete(G),this.priorityObservers_?.size===0)this.priorityObservers_=void 0}else if(this.observers_?.delete(G),this.observers_?.size===0)this.observers_=void 0}subscribe(G,H){this.logger_.logMethodArgs?.("subscribe.base",H),this.checkDestroyed_();let Q={callback:G,options:H};if(H?.priority)this.priorityObservers_??=new Set,this.priorityObservers_.add(Q);else this.observers_??=new Set,this.observers_.add(Q);return{unsubscribe:()=>this.removeObserver_(Q)}}notify_(G){if(this.logger_.logMethodArgs?.("notify_",G),this.isDestroyed__){this.logger_.incident?.("notify_","notify_on_destroyed_signal");return}if(this.priorityObservers_?.size)for(let H of this.priorityObservers_)this.executeObserver__(H,G);if(this.observers_?.size)for(let H of this.observers_)this.executeObserver__(H,G)}executeObserver__(G,H){if(G.options?.once)this.removeObserver_(G);try{G.callback(H)}catch(Q){this.logger_.error("notify_","sync_callback_failed",Q)}}pendingRejects__;untilNext(){return this.logger_.logMethod?.("untilNext"),this.checkDestroyed_(),new Promise((G,H)=>{this.pendingRejects__??=new Set,this.pendingRejects__.add(H),this.subscribe((Q)=>{this.pendingRejects__?.delete(H),G(Q)},{once:!0,priority:!0,receivePrevious:!1})})}destroy(){if(this.logger_.logMethod?.("destroy"),this.isDestroyed__){this.logger_.incident?.("destroy_","double_destroy_attempt");return}if(this.isDestroyed__=!0,this.pendingRejects__?.size){let G=Error("signal_destroyed");for(let H of this.pendingRejects__)H(G);this.pendingRejects__.clear()}this.priorityObservers_?.clear(),this.observers_?.clear(),this.config_.onDestroy?.(),this.config_=null}checkDestroyed_(){if(this.isDestroyed__)throw this.logger_.accident("checkDestroyed_","attempt_to_use_destroyed_signal"),Error(`Cannot interact with a destroyed signal (id: ${this.name})`)}}import{queueMicrotask as x}from"@alwatr/delay";import{createLogger as E}from"@alwatr/logger";class O extends K{logger_;constructor(G){super(G);this.logger_=E(`event_signal:${this.name}`),this.logger_.logMethod?.("constructor")}dispatch(G){this.logger_.logMethodArgs?.("dispatch",{payload:G}),this.checkDestroyed_(),x(()=>this.notify_(G))}}import{queueMicrotask as M}from"@alwatr/delay";import{createLogger as D}from"@alwatr/logger";class Z extends K{value__;logger_;notifyPending__=!1;notifyVersion__=0;constructor(G){super({name:G.name,onDestroy:G.onDestroy});this.logger_=D(`state_signal:${this.name}`),this.value__=G.initialValue,this.logger_.logMethodArgs?.("constructor",{initialValue:this.value__})}get(){return this.checkDestroyed_(),this.value__}set(G){if(this.logger_.logMethodArgs?.("set",{newValue:G}),Object.is(this.value__,G)&&(typeof G!=="object"||G===null))return;this.value__=G,this.notifyChange()}notifyChange(){if(this.logger_.logMethod?.("notifyChange"),this.checkDestroyed_(),this.notifyVersion__++,this.notifyPending__)return;this.notifyPending__=!0,M(()=>{this.notifyPending__=!1,this.notify_(this.value__)})}update(G){this.checkDestroyed_();let H=G(this.value__);this.logger_.logMethodFull?.("update",this.value__,H),this.set(H)}subscribe(G,H={}){this.logger_.logMethodArgs?.("subscribe",H),this.checkDestroyed_();let Q=super.subscribe(G,H);if(H.receivePrevious===!1)return Q;if(this.notifyPending__)return Q;let X=this.notifyVersion__;return M(()=>{if(this.logger_.logStep?.("subscribe","immediate_callback"),this.notifyVersion__!==X)return;if(H.once)Q.unsubscribe();try{G(this.value__)}catch(Y){this.logger_.error("subscribe","immediate_callback_failed",Y)}}),Q}destroy(){this.value__=null,super.destroy()}asReadonly(){return this}}import{queueMicrotask as N}from"@alwatr/delay";import{createLogger as I}from"@alwatr/logger";class R{config_;name;logger_;internalSignal_;dependencySubscriptions__=[];isRecalculating__=!1;constructor(G){this.config_=G;this.name=G.name,this.logger_=I(`computed_signal:${this.name}`),this.recalculate_=this.recalculate_.bind(this),this.logger_.logMethod?.("constructor"),this.internalSignal_=new Z({name:`compute_internal:${this.name}`,initialValue:this.config_.get()});for(let H=0;H<this.config_.deps.length;H++){let Q=this.config_.deps[H];this.logger_.logStep?.("constructor","subscribing_to_dependency",{signal:Q.name}),this.dependencySubscriptions__.push(Q.subscribe(this.recalculate_,{receivePrevious:!1}))}}get(){return this.internalSignal_.get()}get isDestroyed(){return this.internalSignal_.isDestroyed}subscribe(G,H){return this.internalSignal_.subscribe(G,H)}untilNext(){return this.internalSignal_.untilNext()}destroy(){if(this.logger_.logMethod?.("destroy"),this.isDestroyed){this.logger_.incident?.("destroy","already_destroyed");return}for(let G=0;G<this.dependencySubscriptions__.length;G++)this.dependencySubscriptions__[G].unsubscribe();this.dependencySubscriptions__.length=0,this.internalSignal_.destroy(),this.config_.onDestroy?.(),this.config_=null}recalculate_(){if(this.logger_.logMethod?.("recalculate_"),this.isRecalculating__){this.logger_.logStep?.("recalculate_","skipping_recalculation_already_scheduled");return}this.isRecalculating__=!0,N(()=>{if(this.isDestroyed){this.logger_.incident?.("recalculate_","destroyed_during_delay"),this.isRecalculating__=!1;return}this.logger_.logStep?.("recalculate_","recalculating_value");try{this.internalSignal_.set(this.config_.get())}catch(G){this.logger_.error("recalculate_","projection_evaluation_failed",G)}this.isRecalculating__=!1})}}import{createLogger as A}from"@alwatr/logger";class z{config_;name;logger_;internalSignal_;sourceSubscription__;activeConsumerCount__=0;constructor(G){this.config_=G;this.name=this.config_.name,this.logger_=A(`derived_signal:${this.name}`)}untilNext(){return this.logger_.logMethod?.("untilNext"),this.checkDestroyed__(),new Promise((G)=>{this.subscribe((H)=>{G(H)},{receivePrevious:!1,once:!0})})}get(){if(this.logger_.logMethod?.("get"),this.checkDestroyed__(),this.activeConsumerCount__===0)return this.config_.projector(this.config_.source.get());return this.internalSignal_.get()}get isDestroyed(){return this.config_===null}subscribe(G,H){if(this.logger_.logMethod?.("subscribe"),this.checkDestroyed__(),this.activeConsumerCount__++,this.activeConsumerCount__===1)this.logger_.logMethod?.("wakeUp_"),this.internalSignal_=new Z({name:`derived-internal:${this.name}`,initialValue:this.config_.projector(this.config_.source.get())}),this.sourceSubscription__=this.config_.source.subscribe((X)=>{this.internalSignal_.set(this.config_.projector(X))},{receivePrevious:!1});let Q=this.internalSignal_.subscribe(G,H);return{unsubscribe:()=>{if(this.logger_.logMethod?.("unsubscribe"),Q.unsubscribe(),this.activeConsumerCount__--,this.activeConsumerCount__===0&&this.sourceSubscription__)this.logger_.logMethod?.("sleepCleanup_"),this.sourceSubscription__.unsubscribe(),this.sourceSubscription__=void 0,this.internalSignal_?.destroy(),this.internalSignal_=void 0}}}destroy(){if(this.logger_.logMethod?.("destroy"),this.isDestroyed)return;if(this.sourceSubscription__)this.sourceSubscription__.unsubscribe(),this.sourceSubscription__=void 0;this.internalSignal_?.destroy(),this.config_.onDestroy?.(),this.config_=null}checkDestroyed__(){if(this.logger_.logMethod?.("checkDestroyed__"),this.isDestroyed)throw Error(`Cannot interact with a destroyed signal (id: ${this.name})`)}}import{delay as j}from"@alwatr/delay";import{createLogger as C}from"@alwatr/logger";class ${config_;name;logger_;dependencySubscriptions__=[];isRunning__=!1;isDestroyed__=!1;get isDestroyed(){return this.isDestroyed__}constructor(G){this.config_=G;this.name=G.name??`[${G.deps.map((H)=>H.name).join(", ")}]`,this.logger_=C(`effect-signal:${this.name}`),this.scheduleExecution_=this.scheduleExecution_.bind(this),this.logger_.logMethod?.("constructor");for(let H of G.deps)this.logger_.logStep?.("constructor","subscribing_to_dependency",{signal:H.name}),this.dependencySubscriptions__.push(H.subscribe(this.scheduleExecution_,{receivePrevious:!1}));if(G.runImmediately===!0)this.logger_.logStep?.("constructor","scheduling_initial_execution"),this.scheduleExecution_()}async scheduleExecution_(){if(this.logger_.logMethod?.("scheduleExecution_"),this.isDestroyed__){this.logger_.incident?.("scheduleExecution_","schedule_execution_on_destroyed_signal");return}if(this.isRunning__){this.logger_.logStep?.("scheduleExecution_","skipped_because_already_running");return}this.isRunning__=!0;try{if(await j.nextMicrotask(),this.isDestroyed__){this.logger_.incident?.("scheduleExecution_","destroyed_during_delay"),this.isRunning__=!1;return}this.logger_.logStep?.("scheduleExecution_","executing_effect"),this.config_.run()}catch(G){this.logger_.error("scheduleExecution_","effect_failed",G)}this.isRunning__=!1}destroy(){if(this.logger_.logMethod?.("destroy"),this.isDestroyed__){this.logger_.incident?.("destroy","already_destroyed");return}this.isDestroyed__=!0;for(let G of this.dependencySubscriptions__)G.unsubscribe();this.dependencySubscriptions__.length=0,this.config_.onDestroy?.(),this.config_=null}}import{createDebouncer as V}from"@alwatr/debounce";import{createLocalStorageProvider as T}from"@alwatr/local-storage";class q extends Z{storageProvider__;storageDebouncer__;storageSyncSubscription__;windowPageHideListener_=()=>{this.storageDebouncer__.flush()};windowPageShowListener_=(G)=>{if(G.persisted){this.logger_.logMethod?.("windowPageShowListener_//restored_from_bfcache");let H=this.storageProvider__.read();if(H!==null)this.set(H)}};constructor(G){let{name:H,storageKey:Q=H,saveDebounceDelay:X=1000,initialValue:Y,onDestroy:F,schemaVersion:B,parse:J,stringify:W}=G,P=T({name:Q,schemaVersion:B,parse:J,stringify:W});super({name:H,initialValue:P.read()??Y,onDestroy:F});if(this.logger_.logMethodArgs?.("constructor",G),this.storageProvider__=P,this.storageDebouncer__=V({delay:X,leading:!1,trailing:!0,thisContext:this,func:this.syncStorage__}),this.storageSyncSubscription__=this.subscribe(this.storageDebouncer__.trigger,{receivePrevious:!1}),typeof globalThis.addEventListener==="function")globalThis.addEventListener("pagehide",this.windowPageHideListener_,{passive:!0}),globalThis.addEventListener("pageshow",this.windowPageShowListener_,{passive:!0})}syncStorage__(G){this.logger_.logMethodArgs?.("syncStorage__",G),this.storageProvider__.write(G)}remove(){this.checkDestroyed_(),this.logger_.logMethod?.("remove"),this.storageProvider__.remove()}destroy(){if(this.logger_.logMethod?.("destroy"),typeof globalThis.removeEventListener==="function")globalThis.removeEventListener("pagehide",this.windowPageHideListener_),globalThis.removeEventListener("pageshow",this.windowPageShowListener_);this.storageDebouncer__.flush(),this.storageSyncSubscription__.unsubscribe(),super.destroy()}}import{createDebouncer as k}from"@alwatr/debounce";import{createSessionStorageProvider as w}from"@alwatr/session-storage";class _ extends Z{storageProvider__;storageDebouncer__;storageSyncSubscription__;windowPageHideListener__=()=>{this.storageDebouncer__.flush()};windowPageShowListener__=(G)=>{if(G.persisted){this.logger_.logMethod?.("windowPageShowListener__//restored_from_bfcache");let H=this.storageProvider__.read();if(H!==null)this.set(H)}};constructor(G){let{name:H,storageKey:Q=H,saveDebounceDelay:X=1000,initialValue:Y,onDestroy:F,parse:B,stringify:J}=G,W=w({name:Q,parse:B,stringify:J});super({name:H,initialValue:W.read()??Y,onDestroy:F});if(this.logger_.logMethodArgs?.("constructor",G),this.storageProvider__=W,this.storageDebouncer__=k({delay:X,leading:!1,trailing:!0,thisContext:this,func:this.syncStorage__}),this.storageSyncSubscription__=this.subscribe(this.storageDebouncer__.trigger,{receivePrevious:!1}),typeof globalThis.addEventListener==="function")globalThis.addEventListener("pagehide",this.windowPageHideListener__,{passive:!0}),globalThis.addEventListener("pageshow",this.windowPageShowListener__,{passive:!0})}syncStorage__(G){this.logger_.logMethodArgs?.("syncStorage__",G),this.storageProvider__.write(G)}remove(){this.checkDestroyed_(),this.logger_.logMethod?.("remove"),this.storageProvider__.remove()}destroy(){if(this.logger_.logMethod?.("destroy"),typeof globalThis.removeEventListener==="function")globalThis.removeEventListener("pagehide",this.windowPageHideListener__),globalThis.removeEventListener("pageshow",this.windowPageShowListener__);this.storageDebouncer__.flush(),this.storageSyncSubscription__.unsubscribe(),super.destroy()}}import{queueMicrotask as b}from"@alwatr/delay";import{createLogger as S}from"@alwatr/logger";class L extends K{logger_;namedHandlers__=new Map;constructor(G){super(G);this.logger_=S(`channel_signal:${this.name}`),this.logger_.logMethod?.("constructor")}dispatch(...G){let[H,Q]=G;this.logger_.logMethodArgs?.("dispatch",{name:H,payload:Q}),this.checkDestroyed_(),b(()=>this.route__(H,Q))}on(G,H,Q){this.logger_.logMethodArgs?.("on",{name:G}),this.checkDestroyed_();let X=this.namedHandlers__.get(G);if(!X)X=new Set,this.namedHandlers__.set(G,X);let Y={handler:H,once:Q?.once??!1};return X.add(Y),{unsubscribe:()=>{if(X.delete(Y),X.size===0)this.namedHandlers__.delete(G)}}}subscribe(G,H){return this.logger_.logMethodArgs?.("subscribe",H),super.subscribe(G,H)}route__(G,H){if(this.isDestroyed)return;let Q=this.namedHandlers__.get(G);if(Q?.size)for(let X of Q){if(X.once){if(Q.delete(X),Q.size===0)this.namedHandlers__.delete(G)}try{X.handler(H)}catch(Y){this.logger_.error("route__","sync_named_handler_failed",Y)}}this.notify_({name:G,payload:H})}destroy(){this.namedHandlers__.clear(),super.destroy()}}function $G(G){return new O(G)}function U(G){return new Z(G)}function MG(G){return new R(G)}function EG(G){return new z(G)}function IG(G){return new $(G)}function CG(G){return new q(G)}function kG(G){return new _(G)}function SG(G){return new L(G)}import{createDebouncer as v}from"@alwatr/debounce";function hG(G,H){let Q=H.name??`${G.name}_debounced`,X=new Z({name:Q,initialValue:G.get(),onDestroy(){F.unsubscribe(),Y.cancel(),H.onDestroy?.(),H=null}}),Y=v({...H,thisContext:X,func:X.set}),F=G.subscribe(Y.trigger,{receivePrevious:!1});return X}function dG(G,H,Q=`${G.name}_filtered`){let X=G.get(),Y=H(X)?X:void 0,F=U({name:Q,initialValue:Y,onDestroy(){B.unsubscribe()}}),B=G.subscribe((J)=>{if(H(J))F.set(J)});return F}export{U as createStateSignal,kG as createSessionStateSignal,CG as createPersistentStateSignal,dG as createFilteredSignal,$G as createEventSignal,IG as createEffect,EG as createDerivedSignal,hG as createDebouncedSignal,MG as createComputedSignal,SG as createChannelSignal,Z as StateSignal,K as SignalBase,_ as SessionStateSignal,q as PersistentStateSignal,O as EventSignal,$ as EffectSignal,z as DerivedSignal,R as ComputedSignal,L as ChannelSignal};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
4
|
+
//# debugId=CF8A0F4B4F268C1B64756E2164756E21
|
|
5
5
|
//# sourceMappingURL=main.js.map
|
package/dist/dev/main.js.map
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"version": 3,
|
|
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/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 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 DEV_MODE && this.logger_.logMethod?.('removeObserver_');\n\n if (this.isDestroyed__) {\n DEV_MODE && 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 DEV_MODE && 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 DEV_MODE && this.logger_.logMethodArgs?.('notify_', value);\n\n if (this.isDestroyed__) {\n DEV_MODE && 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 DEV_MODE && 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 DEV_MODE && this.logger_.logMethod?.('destroy');\n if (this.isDestroyed__) {\n DEV_MODE && 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",
|
|
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 DEV_MODE && this.logger_.logMethod?.('removeObserver_');\n\n if (this.isDestroyed__) {\n DEV_MODE && 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 DEV_MODE && 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 DEV_MODE && this.logger_.logMethodArgs?.('notify_', value);\n\n if (this.isDestroyed__) {\n DEV_MODE && 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 DEV_MODE && 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 DEV_MODE && this.logger_.logMethod?.('destroy');\n if (this.isDestroyed__) {\n DEV_MODE && 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 DEV_MODE && 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
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 DEV_MODE && 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 DEV_MODE && 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
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 DEV_MODE && 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 DEV_MODE && 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 DEV_MODE && 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 DEV_MODE && 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 DEV_MODE && 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 DEV_MODE && 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
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 DEV_MODE && 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 DEV_MODE && 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 DEV_MODE && this.logger_.logMethod?.('destroy');\n if (this.isDestroyed) {\n DEV_MODE && 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 DEV_MODE && this.logger_.logMethod?.('recalculate_');\n\n if (this.isRecalculating__) {\n // If a recalculation is already scheduled, do nothing.\n DEV_MODE && this.logger_.logStep?.('recalculate_', 'skipping_recalculation_already_scheduled');\n return;\n }\n\n this.isRecalculating__ = true;\n\n queueMicrotask(() => {\n if (this.isDestroyed) {\n DEV_MODE && this.logger_.incident?.('recalculate_', 'destroyed_during_delay');\n this.isRecalculating__ = false;\n return;\n }\n\n DEV_MODE && 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",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
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
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"
|
|
24
24
|
],
|
|
25
|
-
"mappings": ";AAYO,MAAe,CAAc,CAqDZ,QAhDN,KAgBN,mBAQA,WAOF,cAAgB,MAQb,YAAW,EAAY,CAChC,OAAO,KAAK,cAQd,WAAW,CAAW,EAAuB,CAAvB,eACpB,KAAK,KAAO,EAAQ,KASZ,eAAe,CAAC,EAA8B,CAGtD,GAFY,KAAK,QAAQ,YAAY,iBAAiB,EAElD,KAAK,cAAe,CACV,KAAK,QAAQ,WAAW,kBAAmB,qCAAqC,EAC5F,OAGF,GAAI,EAAS,SAAS,UAEpB,GADA,KAAK,oBAAoB,OAAO,CAAQ,EACpC,KAAK,oBAAoB,OAAS,EACpC,KAAK,mBAAqB,OAI5B,QADA,KAAK,YAAY,OAAO,CAAQ,EAC5B,KAAK,YAAY,OAAS,EAC5B,KAAK,WAAa,OAcjB,SAAS,CAAC,EAA+B,EAA6C,CAC/E,KAAK,QAAQ,gBAAgB,iBAAkB,CAAO,EAClE,KAAK,gBAAgB,EAErB,IAAM,EAAyB,CAAC,WAAU,SAAO,EAEjD,GAAI,GAAS,SACX,KAAK,qBAAuB,IAAI,IAChC,KAAK,mBAAmB,IAAI,CAAQ,EAEpC,UAAK,aAAe,IAAI,IACxB,KAAK,WAAW,IAAI,CAAQ,EAI9B,MAAO,CACL,YAAa,IAAY,KAAK,gBAAgB,CAAQ,CACxD,EAUQ,OAAO,CAAC,EAAgB,CAGhC,GAFY,KAAK,QAAQ,gBAAgB,UAAW,CAAK,EAErD,KAAK,cAAe,CACV,KAAK,QAAQ,WAAW,UAAW,4BAA4B,EAC3E,OAIF,GAAI,KAAK,oBAAoB,KAC3B,QAAW,KAAY,KAAK,mBAC1B,KAAK,kBAAkB,EAAU,CAAK,EAK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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": "CF8A0F4B4F268C1B64756E2164756E21",
|
|
27
27
|
"names": []
|
|
28
28
|
}
|
package/dist/main.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* 📦 @alwatr/signal v9.
|
|
2
|
-
class K{config_;name;priorityObservers_;observers_;isDestroyed__=!1;get isDestroyed(){return this.isDestroyed__}constructor(G){this.config_=G;this.name=G.name}removeObserver_(G){if(this.isDestroyed__)return;if(G.options?.priority){if(this.priorityObservers_?.delete(G),this.priorityObservers_?.size===0)this.priorityObservers_=void 0}else if(this.observers_?.delete(G),this.observers_?.size===0)this.observers_=void 0}subscribe(G,H){this.checkDestroyed_();let Q={callback:G,options:H};if(H?.priority)this.priorityObservers_??=new Set,this.priorityObservers_.add(Q);else this.observers_??=new Set,this.observers_.add(Q);return{unsubscribe:()=>this.removeObserver_(Q)}}notify_(G){if(this.isDestroyed__)return;if(this.priorityObservers_?.size)for(let H of this.priorityObservers_)this.executeObserver__(H,G);if(this.observers_?.size)for(let H of this.observers_)this.executeObserver__(H,G)}executeObserver__(G,H){if(G.options?.once)this.removeObserver_(G);try{G.callback(H)}catch(Q){this.logger_.error("notify_","sync_callback_failed",Q)}}pendingRejects__;untilNext(){return this.checkDestroyed_(),new Promise((G,H)=>{this.pendingRejects__??=new Set,this.pendingRejects__.add(H),this.subscribe((Q)=>{this.pendingRejects__?.delete(H),G(Q)},{once:!0,priority:!0,receivePrevious:!1})})}destroy(){if(this.isDestroyed__)return;if(this.isDestroyed__=!0,this.pendingRejects__?.size){let G=Error("signal_destroyed");for(let H of this.pendingRejects__)H(G);this.pendingRejects__.clear()}this.priorityObservers_?.clear(),this.observers_?.clear(),this.config_.onDestroy?.(),this.config_=null}checkDestroyed_(){if(this.isDestroyed__)throw this.logger_.accident("checkDestroyed_","attempt_to_use_destroyed_signal"),Error(`Cannot interact with a destroyed signal (id: ${this.name})`)}}import{queueMicrotask as x}from"@alwatr/delay";import{createLogger as E}from"@alwatr/logger";class O extends K{logger_;constructor(G){super(G);this.logger_=E(`event_signal:${this.name}`)}dispatch(G){this.checkDestroyed_(),x(()=>this.notify_(G))}}import{queueMicrotask as M}from"@alwatr/delay";import{createLogger as D}from"@alwatr/logger";class Z extends K{value__;logger_;notifyPending__=!1;notifyVersion__=0;constructor(G){super({name:G.name,onDestroy:G.onDestroy});this.logger_=D(`state_signal:${this.name}`),this.value__=G.initialValue}get(){return this.checkDestroyed_(),this.value__}set(G){if(Object.is(this.value__,G)&&(typeof G!=="object"||G===null))return;this.value__=G,this.notifyChange()}notifyChange(){if(this.checkDestroyed_(),this.notifyVersion__++,this.notifyPending__)return;this.notifyPending__=!0,M(()=>{this.notifyPending__=!1,this.notify_(this.value__)})}update(G){this.checkDestroyed_();let H=G(this.value__);this.set(H)}subscribe(G,H={}){this.checkDestroyed_();let Q=super.subscribe(G,H);if(H.receivePrevious===!1)return Q;if(this.notifyPending__)return Q;let X=this.notifyVersion__;return M(()=>{if(this.notifyVersion__!==X)return;if(H.once)Q.unsubscribe();try{G(this.value__)}catch(Y){this.logger_.error("subscribe","immediate_callback_failed",Y)}}),Q}destroy(){this.value__=null,super.destroy()}asReadonly(){return this}}import{queueMicrotask as N}from"@alwatr/delay";import{createLogger as I}from"@alwatr/logger";class R{config_;name;logger_;internalSignal_;dependencySubscriptions__=[];isRecalculating__=!1;constructor(G){this.config_=G;this.name=G.name,this.logger_=I(`computed_signal:${this.name}`),this.recalculate_=this.recalculate_.bind(this),this.internalSignal_=new Z({name:`compute_internal:${this.name}`,initialValue:this.config_.get()});for(let H=0;H<this.config_.deps.length;H++){let Q=this.config_.deps[H];this.dependencySubscriptions__.push(Q.subscribe(this.recalculate_,{receivePrevious:!1}))}}get(){return this.internalSignal_.get()}get isDestroyed(){return this.internalSignal_.isDestroyed}subscribe(G,H){return this.internalSignal_.subscribe(G,H)}untilNext(){return this.internalSignal_.untilNext()}destroy(){if(this.isDestroyed)return;for(let G=0;G<this.dependencySubscriptions__.length;G++)this.dependencySubscriptions__[G].unsubscribe();this.dependencySubscriptions__.length=0,this.internalSignal_.destroy(),this.config_.onDestroy?.(),this.config_=null}recalculate_(){if(this.isRecalculating__)return;this.isRecalculating__=!0,N(()=>{if(this.isDestroyed){this.isRecalculating__=!1;return}try{this.internalSignal_.set(this.config_.get())}catch(G){this.logger_.error("recalculate_","projection_evaluation_failed",G)}this.isRecalculating__=!1})}}import{createLogger as A}from"@alwatr/logger";class z{config_;name;logger_;internalSignal_;sourceSubscription__;activeConsumerCount__=0;constructor(G){this.config_=G;this.name=this.config_.name,this.logger_=A(`derived_signal:${this.name}`)}untilNext(){return this.checkDestroyed__(),new Promise((G)=>{this.subscribe((H)=>{G(H)},{receivePrevious:!1,once:!0})})}get(){if(this.checkDestroyed__(),this.activeConsumerCount__===0)return this.config_.projector(this.config_.source.get());return this.internalSignal_.get()}get isDestroyed(){return this.config_===null}subscribe(G,H){if(this.checkDestroyed__(),this.activeConsumerCount__++,this.activeConsumerCount__===1)this.internalSignal_=new Z({name:`derived-internal:${this.name}`,initialValue:this.config_.projector(this.config_.source.get())}),this.sourceSubscription__=this.config_.source.subscribe((X)=>{this.internalSignal_.set(this.config_.projector(X))},{receivePrevious:!1});let Q=this.internalSignal_.subscribe(G,H);return{unsubscribe:()=>{if(Q.unsubscribe(),this.activeConsumerCount__--,this.activeConsumerCount__===0&&this.sourceSubscription__)this.sourceSubscription__.unsubscribe(),this.sourceSubscription__=void 0,this.internalSignal_?.destroy(),this.internalSignal_=void 0}}}destroy(){if(this.isDestroyed)return;if(this.sourceSubscription__)this.sourceSubscription__.unsubscribe(),this.sourceSubscription__=void 0;this.internalSignal_?.destroy(),this.config_.onDestroy?.(),this.config_=null}checkDestroyed__(){if(this.isDestroyed)throw Error(`Cannot interact with a destroyed signal (id: ${this.name})`)}}import{delay as V}from"@alwatr/delay";import{createLogger as j}from"@alwatr/logger";class ${config_;name;logger_;dependencySubscriptions__=[];isRunning__=!1;isDestroyed__=!1;get isDestroyed(){return this.isDestroyed__}constructor(G){this.config_=G;this.name=G.name??`[${G.deps.map((H)=>H.name).join(", ")}]`,this.logger_=j(`effect-signal:${this.name}`),this.scheduleExecution_=this.scheduleExecution_.bind(this);for(let H of G.deps)this.dependencySubscriptions__.push(H.subscribe(this.scheduleExecution_,{receivePrevious:!1}));if(G.runImmediately===!0)this.scheduleExecution_()}async scheduleExecution_(){if(this.isDestroyed__)return;if(this.isRunning__)return;this.isRunning__=!0;try{if(await V.nextMicrotask(),this.isDestroyed__){this.isRunning__=!1;return}this.config_.run()}catch(G){this.logger_.error("scheduleExecution_","effect_failed",G)}this.isRunning__=!1}destroy(){if(this.isDestroyed__)return;this.isDestroyed__=!0;for(let G of this.dependencySubscriptions__)G.unsubscribe();this.dependencySubscriptions__.length=0,this.config_.onDestroy?.(),this.config_=null}}import{createDebouncer as C}from"@alwatr/debounce";import{createLocalStorageProvider as T}from"@alwatr/local-storage";class q extends Z{storageProvider__;storageDebouncer__;storageSyncSubscription__;windowPageHideListener_=()=>{this.storageDebouncer__.flush()};windowPageShowListener_=(G)=>{if(G.persisted){let H=this.storageProvider__.read();if(H!==null)this.set(H)}};constructor(G){let{name:H,storageKey:Q=H,saveDebounceDelay:X=1000,initialValue:Y,onDestroy:F,schemaVersion:B,parse:J,stringify:W}=G,P=T({name:Q,schemaVersion:B,parse:J,stringify:W});super({name:H,initialValue:P.read()??Y,onDestroy:F});if(this.storageProvider__=P,this.storageDebouncer__=C({delay:X,leading:!1,trailing:!0,thisContext:this,func:this.syncStorage__}),this.storageSyncSubscription__=this.subscribe(this.storageDebouncer__.trigger,{receivePrevious:!1}),typeof globalThis.addEventListener==="function")globalThis.addEventListener("pagehide",this.windowPageHideListener_,{passive:!0}),globalThis.addEventListener("pageshow",this.windowPageShowListener_,{passive:!0})}syncStorage__(G){this.storageProvider__.write(G)}remove(){this.checkDestroyed_(),this.storageProvider__.remove()}destroy(){if(typeof globalThis.removeEventListener==="function")globalThis.removeEventListener("pagehide",this.windowPageHideListener_),globalThis.removeEventListener("pageshow",this.windowPageShowListener_);this.storageDebouncer__.flush(),this.storageSyncSubscription__.unsubscribe(),super.destroy()}}import{createDebouncer as k}from"@alwatr/debounce";import{createSessionStorageProvider as w}from"@alwatr/session-storage";class _ extends Z{storageProvider__;storageDebouncer__;storageSyncSubscription__;windowPageHideListener__=()=>{this.storageDebouncer__.flush()};windowPageShowListener__=(G)=>{if(G.persisted){let H=this.storageProvider__.read();if(H!==null)this.set(H)}};constructor(G){let{name:H,storageKey:Q=H,saveDebounceDelay:X=1000,initialValue:Y,onDestroy:F,parse:B,stringify:J}=G,W=w({name:Q,parse:B,stringify:J});super({name:H,initialValue:W.read()??Y,onDestroy:F});if(this.storageProvider__=W,this.storageDebouncer__=k({delay:X,leading:!1,trailing:!0,thisContext:this,func:this.syncStorage__}),this.storageSyncSubscription__=this.subscribe(this.storageDebouncer__.trigger,{receivePrevious:!1}),typeof globalThis.addEventListener==="function")globalThis.addEventListener("pagehide",this.windowPageHideListener__,{passive:!0}),globalThis.addEventListener("pageshow",this.windowPageShowListener__,{passive:!0})}syncStorage__(G){this.storageProvider__.write(G)}remove(){this.checkDestroyed_(),this.storageProvider__.remove()}destroy(){if(typeof globalThis.removeEventListener==="function")globalThis.removeEventListener("pagehide",this.windowPageHideListener__),globalThis.removeEventListener("pageshow",this.windowPageShowListener__);this.storageDebouncer__.flush(),this.storageSyncSubscription__.unsubscribe(),super.destroy()}}import{queueMicrotask as b}from"@alwatr/delay";import{createLogger as v}from"@alwatr/logger";class L extends K{logger_;namedHandlers__=new Map;constructor(G){super(G);this.logger_=v(`channel_signal:${this.name}`)}dispatch(...G){let[H,Q]=G;this.checkDestroyed_(),b(()=>this.route__(H,Q))}on(G,H,Q){this.checkDestroyed_();let X=this.namedHandlers__.get(G);if(!X)X=new Set,this.namedHandlers__.set(G,X);let Y={handler:H,once:Q?.once??!1};return X.add(Y),{unsubscribe:()=>{if(X.delete(Y),X.size===0)this.namedHandlers__.delete(G)}}}subscribe(G,H){return super.subscribe(G,H)}route__(G,H){if(this.isDestroyed)return;let Q=this.namedHandlers__.get(G);if(Q?.size)for(let X of Q){if(X.once){if(Q.delete(X),Q.size===0)this.namedHandlers__.delete(G)}try{X.handler(H)}catch(Y){this.logger_.error("route__","sync_named_handler_failed",Y)}}this.notify_({name:G,payload:H})}destroy(){this.namedHandlers__.clear(),super.destroy()}}function $G(G){return new O(G)}function U(G){return new Z(G)}function MG(G){return new R(G)}function EG(G){return new z(G)}function IG(G){return new $(G)}function jG(G){return new q(G)}function kG(G){return new _(G)}function vG(G){return new L(G)}import{createDebouncer as S}from"@alwatr/debounce";function hG(G,H){let Q=H.name??`${G.name}_debounced`,X=new Z({name:Q,initialValue:G.get(),onDestroy(){F.unsubscribe(),Y.cancel(),H.onDestroy?.(),H=null}}),Y=S({...H,thisContext:X,func:X.set}),F=G.subscribe(Y.trigger,{receivePrevious:!1});return X}function dG(G,H,Q=`${G.name}_filtered`){let X=G.get(),Y=H(X)?X:void 0,F=U({name:Q,initialValue:Y,onDestroy(){B.unsubscribe()}}),B=G.subscribe((J)=>{if(H(J))F.set(J)});return F}export{U as createStateSignal,kG as createSessionStateSignal,jG as createPersistentStateSignal,dG as createFilteredSignal,$G as createEventSignal,IG as createEffect,EG as createDerivedSignal,hG as createDebouncedSignal,MG as createComputedSignal,vG as createChannelSignal,Z as StateSignal,K as SignalBase,_ as SessionStateSignal,q as PersistentStateSignal,O as EventSignal,$ as EffectSignal,z as DerivedSignal,R as ComputedSignal,L as ChannelSignal};
|
|
1
|
+
/* 📦 @alwatr/signal v9.35.0 */
|
|
2
|
+
class K{config_;name;priorityObservers_;observers_;isDestroyed__=!1;get isDestroyed(){return this.isDestroyed__}constructor(G){this.config_=G;this.name=G.name}removeObserver_(G){if(this.isDestroyed__)return;if(G.options?.priority){if(this.priorityObservers_?.delete(G),this.priorityObservers_?.size===0)this.priorityObservers_=void 0}else if(this.observers_?.delete(G),this.observers_?.size===0)this.observers_=void 0}subscribe(G,H){this.checkDestroyed_();let Q={callback:G,options:H};if(H?.priority)this.priorityObservers_??=new Set,this.priorityObservers_.add(Q);else this.observers_??=new Set,this.observers_.add(Q);return{unsubscribe:()=>this.removeObserver_(Q)}}notify_(G){if(this.isDestroyed__)return;if(this.priorityObservers_?.size)for(let H of this.priorityObservers_)this.executeObserver__(H,G);if(this.observers_?.size)for(let H of this.observers_)this.executeObserver__(H,G)}executeObserver__(G,H){if(G.options?.once)this.removeObserver_(G);try{G.callback(H)}catch(Q){this.logger_.error("notify_","sync_callback_failed",Q)}}pendingRejects__;untilNext(){return this.checkDestroyed_(),new Promise((G,H)=>{this.pendingRejects__??=new Set,this.pendingRejects__.add(H),this.subscribe((Q)=>{this.pendingRejects__?.delete(H),G(Q)},{once:!0,priority:!0,receivePrevious:!1})})}destroy(){if(this.isDestroyed__)return;if(this.isDestroyed__=!0,this.pendingRejects__?.size){let G=Error("signal_destroyed");for(let H of this.pendingRejects__)H(G);this.pendingRejects__.clear()}this.priorityObservers_?.clear(),this.observers_?.clear(),this.config_.onDestroy?.(),this.config_=null}checkDestroyed_(){if(this.isDestroyed__)throw Error(`Cannot interact with a destroyed signal (id: ${this.name})`)}}import{queueMicrotask as x}from"@alwatr/delay";import{createLogger as E}from"@alwatr/logger";class O extends K{logger_;constructor(G){super(G);this.logger_=E(`event_signal:${this.name}`)}dispatch(G){this.checkDestroyed_(),x(()=>this.notify_(G))}}import{queueMicrotask as M}from"@alwatr/delay";import{createLogger as D}from"@alwatr/logger";class Z extends K{value__;logger_;notifyPending__=!1;notifyVersion__=0;constructor(G){super({name:G.name,onDestroy:G.onDestroy});this.logger_=D(`state_signal:${this.name}`),this.value__=G.initialValue}get(){return this.checkDestroyed_(),this.value__}set(G){if(Object.is(this.value__,G)&&(typeof G!=="object"||G===null))return;this.value__=G,this.notifyChange()}notifyChange(){if(this.checkDestroyed_(),this.notifyVersion__++,this.notifyPending__)return;this.notifyPending__=!0,M(()=>{this.notifyPending__=!1,this.notify_(this.value__)})}update(G){this.checkDestroyed_();let H=G(this.value__);this.set(H)}subscribe(G,H={}){this.checkDestroyed_();let Q=super.subscribe(G,H);if(H.receivePrevious===!1)return Q;if(this.notifyPending__)return Q;let X=this.notifyVersion__;return M(()=>{if(this.notifyVersion__!==X)return;if(H.once)Q.unsubscribe();try{G(this.value__)}catch(Y){this.logger_.error("subscribe","immediate_callback_failed",Y)}}),Q}destroy(){this.value__=null,super.destroy()}asReadonly(){return this}}import{queueMicrotask as N}from"@alwatr/delay";import{createLogger as I}from"@alwatr/logger";class R{config_;name;logger_;internalSignal_;dependencySubscriptions__=[];isRecalculating__=!1;constructor(G){this.config_=G;this.name=G.name,this.logger_=I(`computed_signal:${this.name}`),this.recalculate_=this.recalculate_.bind(this),this.internalSignal_=new Z({name:`compute_internal:${this.name}`,initialValue:this.config_.get()});for(let H=0;H<this.config_.deps.length;H++){let Q=this.config_.deps[H];this.dependencySubscriptions__.push(Q.subscribe(this.recalculate_,{receivePrevious:!1}))}}get(){return this.internalSignal_.get()}get isDestroyed(){return this.internalSignal_.isDestroyed}subscribe(G,H){return this.internalSignal_.subscribe(G,H)}untilNext(){return this.internalSignal_.untilNext()}destroy(){if(this.isDestroyed)return;for(let G=0;G<this.dependencySubscriptions__.length;G++)this.dependencySubscriptions__[G].unsubscribe();this.dependencySubscriptions__.length=0,this.internalSignal_.destroy(),this.config_.onDestroy?.(),this.config_=null}recalculate_(){if(this.isRecalculating__)return;this.isRecalculating__=!0,N(()=>{if(this.isDestroyed){this.isRecalculating__=!1;return}try{this.internalSignal_.set(this.config_.get())}catch(G){this.logger_.error("recalculate_","projection_evaluation_failed",G)}this.isRecalculating__=!1})}}import{createLogger as A}from"@alwatr/logger";class z{config_;name;logger_;internalSignal_;sourceSubscription__;activeConsumerCount__=0;constructor(G){this.config_=G;this.name=this.config_.name,this.logger_=A(`derived_signal:${this.name}`)}untilNext(){return this.checkDestroyed__(),new Promise((G)=>{this.subscribe((H)=>{G(H)},{receivePrevious:!1,once:!0})})}get(){if(this.checkDestroyed__(),this.activeConsumerCount__===0)return this.config_.projector(this.config_.source.get());return this.internalSignal_.get()}get isDestroyed(){return this.config_===null}subscribe(G,H){if(this.checkDestroyed__(),this.activeConsumerCount__++,this.activeConsumerCount__===1)this.internalSignal_=new Z({name:`derived-internal:${this.name}`,initialValue:this.config_.projector(this.config_.source.get())}),this.sourceSubscription__=this.config_.source.subscribe((X)=>{this.internalSignal_.set(this.config_.projector(X))},{receivePrevious:!1});let Q=this.internalSignal_.subscribe(G,H);return{unsubscribe:()=>{if(Q.unsubscribe(),this.activeConsumerCount__--,this.activeConsumerCount__===0&&this.sourceSubscription__)this.sourceSubscription__.unsubscribe(),this.sourceSubscription__=void 0,this.internalSignal_?.destroy(),this.internalSignal_=void 0}}}destroy(){if(this.isDestroyed)return;if(this.sourceSubscription__)this.sourceSubscription__.unsubscribe(),this.sourceSubscription__=void 0;this.internalSignal_?.destroy(),this.config_.onDestroy?.(),this.config_=null}checkDestroyed__(){if(this.isDestroyed)throw Error(`Cannot interact with a destroyed signal (id: ${this.name})`)}}import{delay as V}from"@alwatr/delay";import{createLogger as j}from"@alwatr/logger";class ${config_;name;logger_;dependencySubscriptions__=[];isRunning__=!1;isDestroyed__=!1;get isDestroyed(){return this.isDestroyed__}constructor(G){this.config_=G;this.name=G.name??`[${G.deps.map((H)=>H.name).join(", ")}]`,this.logger_=j(`effect-signal:${this.name}`),this.scheduleExecution_=this.scheduleExecution_.bind(this);for(let H of G.deps)this.dependencySubscriptions__.push(H.subscribe(this.scheduleExecution_,{receivePrevious:!1}));if(G.runImmediately===!0)this.scheduleExecution_()}async scheduleExecution_(){if(this.isDestroyed__)return;if(this.isRunning__)return;this.isRunning__=!0;try{if(await V.nextMicrotask(),this.isDestroyed__){this.isRunning__=!1;return}this.config_.run()}catch(G){this.logger_.error("scheduleExecution_","effect_failed",G)}this.isRunning__=!1}destroy(){if(this.isDestroyed__)return;this.isDestroyed__=!0;for(let G of this.dependencySubscriptions__)G.unsubscribe();this.dependencySubscriptions__.length=0,this.config_.onDestroy?.(),this.config_=null}}import{createDebouncer as C}from"@alwatr/debounce";import{createLocalStorageProvider as T}from"@alwatr/local-storage";class q extends Z{storageProvider__;storageDebouncer__;storageSyncSubscription__;windowPageHideListener_=()=>{this.storageDebouncer__.flush()};windowPageShowListener_=(G)=>{if(G.persisted){let H=this.storageProvider__.read();if(H!==null)this.set(H)}};constructor(G){let{name:H,storageKey:Q=H,saveDebounceDelay:X=1000,initialValue:Y,onDestroy:F,schemaVersion:B,parse:J,stringify:W}=G,P=T({name:Q,schemaVersion:B,parse:J,stringify:W});super({name:H,initialValue:P.read()??Y,onDestroy:F});if(this.storageProvider__=P,this.storageDebouncer__=C({delay:X,leading:!1,trailing:!0,thisContext:this,func:this.syncStorage__}),this.storageSyncSubscription__=this.subscribe(this.storageDebouncer__.trigger,{receivePrevious:!1}),typeof globalThis.addEventListener==="function")globalThis.addEventListener("pagehide",this.windowPageHideListener_,{passive:!0}),globalThis.addEventListener("pageshow",this.windowPageShowListener_,{passive:!0})}syncStorage__(G){this.storageProvider__.write(G)}remove(){this.checkDestroyed_(),this.storageProvider__.remove()}destroy(){if(typeof globalThis.removeEventListener==="function")globalThis.removeEventListener("pagehide",this.windowPageHideListener_),globalThis.removeEventListener("pageshow",this.windowPageShowListener_);this.storageDebouncer__.flush(),this.storageSyncSubscription__.unsubscribe(),super.destroy()}}import{createDebouncer as k}from"@alwatr/debounce";import{createSessionStorageProvider as w}from"@alwatr/session-storage";class _ extends Z{storageProvider__;storageDebouncer__;storageSyncSubscription__;windowPageHideListener__=()=>{this.storageDebouncer__.flush()};windowPageShowListener__=(G)=>{if(G.persisted){let H=this.storageProvider__.read();if(H!==null)this.set(H)}};constructor(G){let{name:H,storageKey:Q=H,saveDebounceDelay:X=1000,initialValue:Y,onDestroy:F,parse:B,stringify:J}=G,W=w({name:Q,parse:B,stringify:J});super({name:H,initialValue:W.read()??Y,onDestroy:F});if(this.storageProvider__=W,this.storageDebouncer__=k({delay:X,leading:!1,trailing:!0,thisContext:this,func:this.syncStorage__}),this.storageSyncSubscription__=this.subscribe(this.storageDebouncer__.trigger,{receivePrevious:!1}),typeof globalThis.addEventListener==="function")globalThis.addEventListener("pagehide",this.windowPageHideListener__,{passive:!0}),globalThis.addEventListener("pageshow",this.windowPageShowListener__,{passive:!0})}syncStorage__(G){this.storageProvider__.write(G)}remove(){this.checkDestroyed_(),this.storageProvider__.remove()}destroy(){if(typeof globalThis.removeEventListener==="function")globalThis.removeEventListener("pagehide",this.windowPageHideListener__),globalThis.removeEventListener("pageshow",this.windowPageShowListener__);this.storageDebouncer__.flush(),this.storageSyncSubscription__.unsubscribe(),super.destroy()}}import{queueMicrotask as b}from"@alwatr/delay";import{createLogger as v}from"@alwatr/logger";class L extends K{logger_;namedHandlers__=new Map;constructor(G){super(G);this.logger_=v(`channel_signal:${this.name}`)}dispatch(...G){let[H,Q]=G;this.checkDestroyed_(),b(()=>this.route__(H,Q))}on(G,H,Q){this.checkDestroyed_();let X=this.namedHandlers__.get(G);if(!X)X=new Set,this.namedHandlers__.set(G,X);let Y={handler:H,once:Q?.once??!1};return X.add(Y),{unsubscribe:()=>{if(X.delete(Y),X.size===0)this.namedHandlers__.delete(G)}}}subscribe(G,H){return super.subscribe(G,H)}route__(G,H){if(this.isDestroyed)return;let Q=this.namedHandlers__.get(G);if(Q?.size)for(let X of Q){if(X.once){if(Q.delete(X),Q.size===0)this.namedHandlers__.delete(G)}try{X.handler(H)}catch(Y){this.logger_.error("route__","sync_named_handler_failed",Y)}}this.notify_({name:G,payload:H})}destroy(){this.namedHandlers__.clear(),super.destroy()}}function $G(G){return new O(G)}function U(G){return new Z(G)}function MG(G){return new R(G)}function EG(G){return new z(G)}function IG(G){return new $(G)}function jG(G){return new q(G)}function kG(G){return new _(G)}function vG(G){return new L(G)}import{createDebouncer as S}from"@alwatr/debounce";function hG(G,H){let Q=H.name??`${G.name}_debounced`,X=new Z({name:Q,initialValue:G.get(),onDestroy(){F.unsubscribe(),Y.cancel(),H.onDestroy?.(),H=null}}),Y=S({...H,thisContext:X,func:X.set}),F=G.subscribe(Y.trigger,{receivePrevious:!1});return X}function dG(G,H,Q=`${G.name}_filtered`){let X=G.get(),Y=H(X)?X:void 0,F=U({name:Q,initialValue:Y,onDestroy(){B.unsubscribe()}}),B=G.subscribe((J)=>{if(H(J))F.set(J)});return F}export{U as createStateSignal,kG as createSessionStateSignal,jG as createPersistentStateSignal,dG as createFilteredSignal,$G as createEventSignal,IG as createEffect,EG as createDerivedSignal,hG as createDebouncedSignal,MG as createComputedSignal,vG as createChannelSignal,Z as StateSignal,K as SignalBase,_ as SessionStateSignal,q as PersistentStateSignal,O as EventSignal,$ as EffectSignal,z as DerivedSignal,R as ComputedSignal,L as ChannelSignal};
|
|
3
3
|
|
|
4
|
-
//# debugId=
|
|
4
|
+
//# debugId=D0461B0B932E440E64756E2164756E21
|
|
5
5
|
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"version": 3,
|
|
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/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 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 DEV_MODE && this.logger_.logMethod?.('removeObserver_');\n\n if (this.isDestroyed__) {\n DEV_MODE && 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 DEV_MODE && 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 DEV_MODE && this.logger_.logMethodArgs?.('notify_', value);\n\n if (this.isDestroyed__) {\n DEV_MODE && 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 DEV_MODE && 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 DEV_MODE && this.logger_.logMethod?.('destroy');\n if (this.isDestroyed__) {\n DEV_MODE && 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",
|
|
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 DEV_MODE && this.logger_.logMethod?.('removeObserver_');\n\n if (this.isDestroyed__) {\n DEV_MODE && 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 DEV_MODE && 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 DEV_MODE && this.logger_.logMethodArgs?.('notify_', value);\n\n if (this.isDestroyed__) {\n DEV_MODE && 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 DEV_MODE && 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 DEV_MODE && this.logger_.logMethod?.('destroy');\n if (this.isDestroyed__) {\n DEV_MODE && 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 DEV_MODE && 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
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 DEV_MODE && 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 DEV_MODE && 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
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 DEV_MODE && 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 DEV_MODE && 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 DEV_MODE && 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 DEV_MODE && 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 DEV_MODE && 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 DEV_MODE && 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
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 DEV_MODE && 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 DEV_MODE && 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 DEV_MODE && this.logger_.logMethod?.('destroy');\n if (this.isDestroyed) {\n DEV_MODE && 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 DEV_MODE && this.logger_.logMethod?.('recalculate_');\n\n if (this.isRecalculating__) {\n // If a recalculation is already scheduled, do nothing.\n DEV_MODE && this.logger_.logStep?.('recalculate_', 'skipping_recalculation_already_scheduled');\n return;\n }\n\n this.isRecalculating__ = true;\n\n queueMicrotask(() => {\n if (this.isDestroyed) {\n DEV_MODE && this.logger_.incident?.('recalculate_', 'destroyed_during_delay');\n this.isRecalculating__ = false;\n return;\n }\n\n DEV_MODE && 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",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
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
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"
|
|
24
24
|
],
|
|
25
|
-
"mappings": ";AAYO,MAAe,CAAc,CAqDZ,QAhDN,KAgBN,mBAQA,WAOF,cAAgB,MAQb,YAAW,EAAY,CAChC,OAAO,KAAK,cAQd,WAAW,CAAW,EAAuB,CAAvB,eACpB,KAAK,KAAO,EAAQ,KASZ,eAAe,CAAC,EAA8B,CAGtD,GAAI,KAAK,cAEP,OAGF,GAAI,EAAS,SAAS,UAEpB,GADA,KAAK,oBAAoB,OAAO,CAAQ,EACpC,KAAK,oBAAoB,OAAS,EACpC,KAAK,mBAAqB,OAI5B,QADA,KAAK,YAAY,OAAO,CAAQ,EAC5B,KAAK,YAAY,OAAS,EAC5B,KAAK,WAAa,OAcjB,SAAS,CAAC,EAA+B,EAA6C,CAE3F,KAAK,gBAAgB,EAErB,IAAM,EAAyB,CAAC,WAAU,SAAO,EAEjD,GAAI,GAAS,SACX,KAAK,qBAAuB,IAAI,IAChC,KAAK,mBAAmB,IAAI,CAAQ,EAEpC,UAAK,aAAe,IAAI,IACxB,KAAK,WAAW,IAAI,CAAQ,EAI9B,MAAO,CACL,YAAa,IAAY,KAAK,gBAAgB,CAAQ,CAC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,SAAS,EAAY,CAAC,EAA0C,CACrE,OAAO,IAAI,EAAa,CAAM,ECdzB,SAAS,EAA8B,CAAC,EAAkE,CAC/G,OAAO,IAAI,EAAsB,CAAM,ECQlC,SAAS,EAA2B,CAAC,EAA4D,CACtG,OAAO,IAAI,EAAmB,CAAM,ECF/B,SAAS,EAAwC,CAAC,EAAkD,CACzG,OAAO,IAAI,EAAoB,CAAM,ECvCvC,0BAAQ,yBAyDD,SAAS,EAAwB,CAAC,EAA4B,EAAkD,CACrH,IAAM,EAAO,EAAO,MAAQ,GAAG,EAAO,iBAEhC,EAAiB,IAAI,EAAe,CACxC,OACA,aAAc,EAAO,IAAI,EACzB,SAAS,EAAG,CACV,EAAa,YAAY,EACzB,EAAU,OAAO,EACjB,EAAO,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": "D0461B0B932E440E64756E2164756E21",
|
|
27
27
|
"names": []
|
|
28
28
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alwatr/signal",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.35.0",
|
|
4
4
|
"description": "Alwatr Signal is a powerful, lightweight, and modern reactive programming library. It is inspired by the best concepts from major reactive libraries but engineered to be faster and more efficient than all of them. It provides a robust and elegant way to manage application state through a system of signals, offering fine-grained reactivity, predictability, and excellent performance.",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"author": "S. Ali Mihandoost <ali.mihandoost@gmail.com> (https://ali.mihandoost.com)",
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"signal",
|
|
70
70
|
"typescript"
|
|
71
71
|
],
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "85e47c26720607e780d06e568a6734ac20e5bc82"
|
|
73
73
|
}
|
package/src/core/signal-base.ts
CHANGED
|
@@ -241,7 +241,7 @@ export abstract class SignalBase<T> {
|
|
|
241
241
|
*/
|
|
242
242
|
protected checkDestroyed_(): void {
|
|
243
243
|
if (this.isDestroyed__) {
|
|
244
|
-
this.logger_.accident('checkDestroyed_', 'attempt_to_use_destroyed_signal');
|
|
244
|
+
DEV_MODE && this.logger_.accident('checkDestroyed_', 'attempt_to_use_destroyed_signal');
|
|
245
245
|
throw new Error(`Cannot interact with a destroyed signal (id: ${this.name})`);
|
|
246
246
|
}
|
|
247
247
|
}
|