signalium 4.0.1 → 4.0.2
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/CHANGELOG.md +6 -0
- package/dist/cjs/development/utils.js +11 -6
- package/dist/cjs/development/utils.js.map +1 -1
- package/dist/cjs/production/utils.js +11 -6
- package/dist/cjs/production/utils.js.map +1 -1
- package/dist/esm/development/utils.js +11 -6
- package/dist/esm/development/utils.js.map +1 -1
- package/dist/esm/production/utils.js +11 -6
- package/dist/esm/production/utils.js.map +1 -1
- package/dist/esm/utils.d.ts +3 -1
- package/dist/esm/utils.d.ts.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,21 +3,26 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const snapshot = require("./snapshot-BLa9mv8h.js");
|
|
4
4
|
const debug = require("./debug-BS6RdX4D.js");
|
|
5
5
|
const config = require("./config-D6wyrhrW.js");
|
|
6
|
+
const pendingOnceWatchers = /* @__PURE__ */ new Set();
|
|
6
7
|
function watchOnce(fn) {
|
|
7
8
|
const signal = snapshot.watcher(fn);
|
|
9
|
+
pendingOnceWatchers.add(signal);
|
|
10
|
+
const release = () => {
|
|
11
|
+
if (pendingOnceWatchers.delete(signal)) {
|
|
12
|
+
debug.unwatchSignal(signal);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
8
15
|
try {
|
|
9
16
|
debug.watchSignal(signal);
|
|
10
17
|
let result = debug.getSignal(signal);
|
|
11
|
-
if (debug.isReactivePromise(result) || debug.isPromise(result)) {
|
|
12
|
-
result = result.finally(
|
|
13
|
-
debug.unwatchSignal(signal);
|
|
14
|
-
});
|
|
18
|
+
if (result !== null && typeof result === "object" && (debug.isReactivePromise(result) || debug.isPromise(result))) {
|
|
19
|
+
result = result.finally(release);
|
|
15
20
|
} else {
|
|
16
|
-
|
|
21
|
+
release();
|
|
17
22
|
}
|
|
18
23
|
return result;
|
|
19
24
|
} catch (error) {
|
|
20
|
-
|
|
25
|
+
release();
|
|
21
26
|
throw error;
|
|
22
27
|
}
|
|
23
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../.tsc-out/utils.js"],"sourcesContent":["export { hashValue, registerCustomHash } from './internals/utils/hash.js';\nexport { snapshot, registerCustomSnapshot, snapshotArray, snapshotPlainObject, } from './internals/utils/snapshot.js';\nimport { watcher } from './internals/core-api.js';\nimport { watchSignal, unwatchSignal } from './internals/watch.js';\nimport { getSignal } from './internals/get.js';\nimport { isReactivePromise } from './internals/async.js';\nimport { isPromise } from './internals/utils/type-utils.js';\nimport { MAX_TIMEOUT } from './internals/config.js';\n/**\n * Watches a function once in a reactive context, activating any relays,\n * then automatically tears down the watcher when complete.\n *\n * This is useful for testing or one-time reactive operations where you need\n * relays to be active but don't want the watcher to reschedule on updates.\n *\n * @param fn - A sync or async function to watch once\n * @returns
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../.tsc-out/utils.js"],"sourcesContent":["export { hashValue, registerCustomHash } from './internals/utils/hash.js';\nexport { snapshot, registerCustomSnapshot, snapshotArray, snapshotPlainObject, } from './internals/utils/snapshot.js';\nimport { watcher } from './internals/core-api.js';\nimport { watchSignal, unwatchSignal } from './internals/watch.js';\nimport { getSignal } from './internals/get.js';\nimport { isReactivePromise } from './internals/async.js';\nimport { isPromise } from './internals/utils/type-utils.js';\nimport { MAX_TIMEOUT } from './internals/config.js';\n// Promise reactions and weak graph edges do not root their producing watcher.\nconst pendingOnceWatchers = new Set();\n/**\n * Watches a function once in a reactive context, activating any relays,\n * then automatically tears down the watcher when complete.\n *\n * This is useful for testing or one-time reactive operations where you need\n * relays to be active but don't want the watcher to reschedule on updates.\n * Pending operations keep their watcher alive until fulfillment or rejection.\n * There is no timeout or cancellation; work that never settles remains watched.\n *\n * @param fn - A sync or async function to watch once\n * @returns The synchronous value, or a native promise for an asynchronous result\n *\n * @example\n * ```ts\n * await watchOnce(async () => {\n * const data = relay((state) => {\n * // relay will be activated during watchOnce\n * fetch('/api/data').then(res => state.value = res.data);\n * });\n * await data;\n * return data.value;\n * });\n * ```\n */\nexport function watchOnce(fn) {\n // Create a watcher signal\n const signal = watcher(fn);\n pendingOnceWatchers.add(signal);\n const release = () => {\n if (pendingOnceWatchers.delete(signal)) {\n unwatchSignal(signal);\n }\n };\n try {\n // Watch the signal to activate any relays\n watchSignal(signal);\n // Get the value, which runs the function\n let result = getSignal(signal);\n if (result !== null && typeof result === 'object' && (isReactivePromise(result) || isPromise(result))) {\n result = result.finally(release);\n }\n else {\n release();\n }\n return result;\n }\n catch (error) {\n release();\n throw error;\n }\n}\n/**\n * Keeps `fn`'s dependencies (relays, queries) watched until `ttl` ms pass or the returned\n * `release` is called. Without a `ttl`, or with `Infinity`, it lasts until released. A `ttl` above\n * 2^31 - 1 ms is clamped; a negative or `NaN` one throws a `RangeError`.\n *\n * Use it to keep data warm without rendering it, e.g. prefetching a likely next screen. `fn` runs\n * now, in the current scope, and again when its dependencies change.\n *\n * @example\n * ```ts\n * const release = retain(() => fetchTokenDetail(id), { ttl: 30_000 });\n * ```\n */\nexport function retain(fn, opts) {\n const ttl = opts?.ttl;\n if (ttl !== undefined && (typeof ttl !== 'number' || Number.isNaN(ttl) || ttl < 0)) {\n throw new RangeError(`signalium: retain() ttl must be a non-negative number of milliseconds, got ${String(ttl)}`);\n }\n const signal = watcher(fn);\n const unsubscribe = signal.addListener(noop);\n let timer;\n const release = () => {\n if (timer !== undefined) {\n clearTimeout(timer);\n timer = undefined;\n }\n unsubscribe();\n };\n try {\n // Run now so relays activate immediately, not on the next flush.\n getSignal(signal);\n }\n catch (error) {\n release();\n throw error;\n }\n // `setTimeout` fires immediately for delays above MAX_TIMEOUT.\n if (ttl !== undefined && ttl !== Infinity) {\n timer = setTimeout(release, Math.min(ttl, MAX_TIMEOUT));\n }\n return release;\n}\nconst noop = () => { };\nexport { setReactivePromise } from './internals/async.js';\n/**\n * Forwards state from a source relay to the target relay's state.\n * This enables composition patterns where relays can add side effects\n * while transparently forwarding state from another relay.\n *\n * The forwarding is automatically tracked through the signal graph.\n * When the source relay updates, the target relay will re-run its\n * activation function, and forwardRelay will forward the new state.\n * No cleanup is needed - dependencies are managed automatically.\n *\n * @param state - The target relay's state object\n * @param sourceRelay - The source relay to forward state from\n *\n * @example\n * ```ts\n * const sourceRelay = relay(state => {\n * // ... source relay logic\n * });\n *\n * const forwardedRelay = relay(state => {\n * // Add additional side effect\n * const cleanup = setupSomeEffect();\n *\n * // Forward state from source relay (automatically tracked and cleaned up)\n * forwardRelay(state, sourceRelay);\n *\n * return cleanup; // Only return cleanup for the additional effect\n * });\n * ```\n */\nexport function forwardRelay(state, sourceRelay) {\n // Verify that sourceRelay is actually a ReactivePromiseImpl\n if (!isReactivePromise(sourceRelay)) {\n throw new Error('forwardRelay: sourceRelay must be a ReactivePromise');\n }\n // Read from source relay to establish dependency and forward state\n // When sourceRelay updates, this relay's activation function will be called again,\n // and forwardRelay will be called again, forwarding the new state\n if (sourceRelay.isPending) {\n // For pending state, try to forward the promise if available\n // Accessing isPending establishes the dependency\n const source = sourceRelay;\n const promise = source['_promise'];\n if (promise) {\n state.setPromise(promise);\n }\n }\n else if (sourceRelay.isRejected) {\n // Accessing error establishes dependency and forwards it\n const error = sourceRelay.error;\n if (error !== undefined) {\n state.setError(error);\n }\n }\n else if (sourceRelay.isResolved && sourceRelay.isReady) {\n // Accessing value establishes dependency and forwards it\n const value = sourceRelay.value;\n if (value !== undefined) {\n state.value = value;\n }\n }\n}\n"],"names":["watcher","unwatchSignal","watchSignal","getSignal","isReactivePromise","isPromise","MAX_TIMEOUT"],"mappings":";;;;;AASA,MAAM,sBAAsB,oBAAI,IAAG;AAyB5B,SAAS,UAAU,IAAI;AAE1B,QAAM,SAASA,SAAAA,QAAQ,EAAE;AACzB,sBAAoB,IAAI,MAAM;AAC9B,QAAM,UAAU,MAAM;AAClB,QAAI,oBAAoB,OAAO,MAAM,G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AS;AACT,YAAM,WAAW,OAAO;AAAA,IAC5B;AAAA,EACJ,WACS,YAAY,YAAY;AAE7B,UAAM,QAAQ,YAAY;AAC1B,QAAI,UAAU,QAAW;AACrB,YAAM,SAAS,KAAK;AAAA,IACxB;AAAA,EACJ,WACS,YAAY,cAAc,YAAY,SAAS;AAEpD,UAAM,QAAQ,YAAY;AAC1B,QAAI,UAAU,QAAW;AACrB,YAAM,QAAQ;AAAA,IAClB;AAAA,EACJ;AACJ;;;;;;;;;;;"}
|
|
@@ -3,21 +3,26 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const snapshot = require("./snapshot-gv-aZDmB.js");
|
|
4
4
|
const contexts = require("./contexts-Bkwv59kH.js");
|
|
5
5
|
const config = require("./config-BHvmcsLQ.js");
|
|
6
|
+
const pendingOnceWatchers = /* @__PURE__ */ new Set();
|
|
6
7
|
function watchOnce(fn) {
|
|
7
8
|
const signal = snapshot.watcher(fn);
|
|
9
|
+
pendingOnceWatchers.add(signal);
|
|
10
|
+
const release = () => {
|
|
11
|
+
if (pendingOnceWatchers.delete(signal)) {
|
|
12
|
+
contexts.unwatchSignal(signal);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
8
15
|
try {
|
|
9
16
|
contexts.watchSignal(signal);
|
|
10
17
|
let result = contexts.getSignal(signal);
|
|
11
|
-
if (contexts.isReactivePromise(result) || contexts.isPromise(result)) {
|
|
12
|
-
result = result.finally(
|
|
13
|
-
contexts.unwatchSignal(signal);
|
|
14
|
-
});
|
|
18
|
+
if (result !== null && typeof result === "object" && (contexts.isReactivePromise(result) || contexts.isPromise(result))) {
|
|
19
|
+
result = result.finally(release);
|
|
15
20
|
} else {
|
|
16
|
-
|
|
21
|
+
release();
|
|
17
22
|
}
|
|
18
23
|
return result;
|
|
19
24
|
} catch (error) {
|
|
20
|
-
|
|
25
|
+
release();
|
|
21
26
|
throw error;
|
|
22
27
|
}
|
|
23
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../.tsc-out/utils.js"],"sourcesContent":["export { hashValue, registerCustomHash } from './internals/utils/hash.js';\nexport { snapshot, registerCustomSnapshot, snapshotArray, snapshotPlainObject, } from './internals/utils/snapshot.js';\nimport { watcher } from './internals/core-api.js';\nimport { watchSignal, unwatchSignal } from './internals/watch.js';\nimport { getSignal } from './internals/get.js';\nimport { isReactivePromise } from './internals/async.js';\nimport { isPromise } from './internals/utils/type-utils.js';\nimport { MAX_TIMEOUT } from './internals/config.js';\n/**\n * Watches a function once in a reactive context, activating any relays,\n * then automatically tears down the watcher when complete.\n *\n * This is useful for testing or one-time reactive operations where you need\n * relays to be active but don't want the watcher to reschedule on updates.\n *\n * @param fn - A sync or async function to watch once\n * @returns
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../.tsc-out/utils.js"],"sourcesContent":["export { hashValue, registerCustomHash } from './internals/utils/hash.js';\nexport { snapshot, registerCustomSnapshot, snapshotArray, snapshotPlainObject, } from './internals/utils/snapshot.js';\nimport { watcher } from './internals/core-api.js';\nimport { watchSignal, unwatchSignal } from './internals/watch.js';\nimport { getSignal } from './internals/get.js';\nimport { isReactivePromise } from './internals/async.js';\nimport { isPromise } from './internals/utils/type-utils.js';\nimport { MAX_TIMEOUT } from './internals/config.js';\n// Promise reactions and weak graph edges do not root their producing watcher.\nconst pendingOnceWatchers = new Set();\n/**\n * Watches a function once in a reactive context, activating any relays,\n * then automatically tears down the watcher when complete.\n *\n * This is useful for testing or one-time reactive operations where you need\n * relays to be active but don't want the watcher to reschedule on updates.\n * Pending operations keep their watcher alive until fulfillment or rejection.\n * There is no timeout or cancellation; work that never settles remains watched.\n *\n * @param fn - A sync or async function to watch once\n * @returns The synchronous value, or a native promise for an asynchronous result\n *\n * @example\n * ```ts\n * await watchOnce(async () => {\n * const data = relay((state) => {\n * // relay will be activated during watchOnce\n * fetch('/api/data').then(res => state.value = res.data);\n * });\n * await data;\n * return data.value;\n * });\n * ```\n */\nexport function watchOnce(fn) {\n // Create a watcher signal\n const signal = watcher(fn);\n pendingOnceWatchers.add(signal);\n const release = () => {\n if (pendingOnceWatchers.delete(signal)) {\n unwatchSignal(signal);\n }\n };\n try {\n // Watch the signal to activate any relays\n watchSignal(signal);\n // Get the value, which runs the function\n let result = getSignal(signal);\n if (result !== null && typeof result === 'object' && (isReactivePromise(result) || isPromise(result))) {\n result = result.finally(release);\n }\n else {\n release();\n }\n return result;\n }\n catch (error) {\n release();\n throw error;\n }\n}\n/**\n * Keeps `fn`'s dependencies (relays, queries) watched until `ttl` ms pass or the returned\n * `release` is called. Without a `ttl`, or with `Infinity`, it lasts until released. A `ttl` above\n * 2^31 - 1 ms is clamped; a negative or `NaN` one throws a `RangeError`.\n *\n * Use it to keep data warm without rendering it, e.g. prefetching a likely next screen. `fn` runs\n * now, in the current scope, and again when its dependencies change.\n *\n * @example\n * ```ts\n * const release = retain(() => fetchTokenDetail(id), { ttl: 30_000 });\n * ```\n */\nexport function retain(fn, opts) {\n const ttl = opts?.ttl;\n if (ttl !== undefined && (typeof ttl !== 'number' || Number.isNaN(ttl) || ttl < 0)) {\n throw new RangeError(`signalium: retain() ttl must be a non-negative number of milliseconds, got ${String(ttl)}`);\n }\n const signal = watcher(fn);\n const unsubscribe = signal.addListener(noop);\n let timer;\n const release = () => {\n if (timer !== undefined) {\n clearTimeout(timer);\n timer = undefined;\n }\n unsubscribe();\n };\n try {\n // Run now so relays activate immediately, not on the next flush.\n getSignal(signal);\n }\n catch (error) {\n release();\n throw error;\n }\n // `setTimeout` fires immediately for delays above MAX_TIMEOUT.\n if (ttl !== undefined && ttl !== Infinity) {\n timer = setTimeout(release, Math.min(ttl, MAX_TIMEOUT));\n }\n return release;\n}\nconst noop = () => { };\nexport { setReactivePromise } from './internals/async.js';\n/**\n * Forwards state from a source relay to the target relay's state.\n * This enables composition patterns where relays can add side effects\n * while transparently forwarding state from another relay.\n *\n * The forwarding is automatically tracked through the signal graph.\n * When the source relay updates, the target relay will re-run its\n * activation function, and forwardRelay will forward the new state.\n * No cleanup is needed - dependencies are managed automatically.\n *\n * @param state - The target relay's state object\n * @param sourceRelay - The source relay to forward state from\n *\n * @example\n * ```ts\n * const sourceRelay = relay(state => {\n * // ... source relay logic\n * });\n *\n * const forwardedRelay = relay(state => {\n * // Add additional side effect\n * const cleanup = setupSomeEffect();\n *\n * // Forward state from source relay (automatically tracked and cleaned up)\n * forwardRelay(state, sourceRelay);\n *\n * return cleanup; // Only return cleanup for the additional effect\n * });\n * ```\n */\nexport function forwardRelay(state, sourceRelay) {\n // Verify that sourceRelay is actually a ReactivePromiseImpl\n if (!isReactivePromise(sourceRelay)) {\n throw new Error('forwardRelay: sourceRelay must be a ReactivePromise');\n }\n // Read from source relay to establish dependency and forward state\n // When sourceRelay updates, this relay's activation function will be called again,\n // and forwardRelay will be called again, forwarding the new state\n if (sourceRelay.isPending) {\n // For pending state, try to forward the promise if available\n // Accessing isPending establishes the dependency\n const source = sourceRelay;\n const promise = source['_promise'];\n if (promise) {\n state.setPromise(promise);\n }\n }\n else if (sourceRelay.isRejected) {\n // Accessing error establishes dependency and forwards it\n const error = sourceRelay.error;\n if (error !== undefined) {\n state.setError(error);\n }\n }\n else if (sourceRelay.isResolved && sourceRelay.isReady) {\n // Accessing value establishes dependency and forwards it\n const value = sourceRelay.value;\n if (value !== undefined) {\n state.value = value;\n }\n }\n}\n"],"names":["watcher","unwatchSignal","watchSignal","getSignal","isReactivePromise","isPromise","MAX_TIMEOUT"],"mappings":";;;;;AASA,MAAM,sBAAsB,oBAAI,IAAG;AAyB5B,SAAS,UAAU,IAAI;AAE1B,QAAM,SAASA,SAAAA,QAAQ,EAAE;AACzB,sBAAoB,IAAI,MAAM;AAC9B,QAAM,UAAU,MAAM;AAClB,QAAI,oBAAoB,OAAO,MAAM,GAAG;AACpCC,eAAAA,cAAc,MAAM;AAAA,IACxB;AAAA,EACJ;AACA,MAAI;AAEAC,aAAAA,YAAY,MAAM;AAElB,QAAI,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AI,UAAU,QAAW;AACrB,YAAM,SAAS,KAAK;AAAA,IACxB;AAAA,EACJ,WACS,YAAY,cAAc,YAAY,SAAS;AAEpD,UAAM,QAAQ,YAAY;AAC1B,QAAI,UAAU,QAAW;AACrB,YAAM,QAAQ;AAAA,IAClB;AAAA,EACJ;AACJ;;;;;;;;;;;"}
|
|
@@ -3,21 +3,26 @@ import { a, s, b, c } from "./snapshot-CMsut-I_.js";
|
|
|
3
3
|
import { z as watchSignal, B as getSignal, j as isReactivePromise, r as isPromise, C as unwatchSignal } from "./debug-D7mtRqCt.js";
|
|
4
4
|
import { l, D, E } from "./debug-D7mtRqCt.js";
|
|
5
5
|
import { M as MAX_TIMEOUT } from "./config-CQLKpPRj.js";
|
|
6
|
+
const pendingOnceWatchers = /* @__PURE__ */ new Set();
|
|
6
7
|
function watchOnce(fn) {
|
|
7
8
|
const signal = watcher(fn);
|
|
9
|
+
pendingOnceWatchers.add(signal);
|
|
10
|
+
const release = () => {
|
|
11
|
+
if (pendingOnceWatchers.delete(signal)) {
|
|
12
|
+
unwatchSignal(signal);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
8
15
|
try {
|
|
9
16
|
watchSignal(signal);
|
|
10
17
|
let result = getSignal(signal);
|
|
11
|
-
if (isReactivePromise(result) || isPromise(result)) {
|
|
12
|
-
result = result.finally(
|
|
13
|
-
unwatchSignal(signal);
|
|
14
|
-
});
|
|
18
|
+
if (result !== null && typeof result === "object" && (isReactivePromise(result) || isPromise(result))) {
|
|
19
|
+
result = result.finally(release);
|
|
15
20
|
} else {
|
|
16
|
-
|
|
21
|
+
release();
|
|
17
22
|
}
|
|
18
23
|
return result;
|
|
19
24
|
} catch (error) {
|
|
20
|
-
|
|
25
|
+
release();
|
|
21
26
|
throw error;
|
|
22
27
|
}
|
|
23
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../.tsc-out/utils.js"],"sourcesContent":["export { hashValue, registerCustomHash } from './internals/utils/hash.js';\nexport { snapshot, registerCustomSnapshot, snapshotArray, snapshotPlainObject, } from './internals/utils/snapshot.js';\nimport { watcher } from './internals/core-api.js';\nimport { watchSignal, unwatchSignal } from './internals/watch.js';\nimport { getSignal } from './internals/get.js';\nimport { isReactivePromise } from './internals/async.js';\nimport { isPromise } from './internals/utils/type-utils.js';\nimport { MAX_TIMEOUT } from './internals/config.js';\n/**\n * Watches a function once in a reactive context, activating any relays,\n * then automatically tears down the watcher when complete.\n *\n * This is useful for testing or one-time reactive operations where you need\n * relays to be active but don't want the watcher to reschedule on updates.\n *\n * @param fn - A sync or async function to watch once\n * @returns
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../.tsc-out/utils.js"],"sourcesContent":["export { hashValue, registerCustomHash } from './internals/utils/hash.js';\nexport { snapshot, registerCustomSnapshot, snapshotArray, snapshotPlainObject, } from './internals/utils/snapshot.js';\nimport { watcher } from './internals/core-api.js';\nimport { watchSignal, unwatchSignal } from './internals/watch.js';\nimport { getSignal } from './internals/get.js';\nimport { isReactivePromise } from './internals/async.js';\nimport { isPromise } from './internals/utils/type-utils.js';\nimport { MAX_TIMEOUT } from './internals/config.js';\n// Promise reactions and weak graph edges do not root their producing watcher.\nconst pendingOnceWatchers = new Set();\n/**\n * Watches a function once in a reactive context, activating any relays,\n * then automatically tears down the watcher when complete.\n *\n * This is useful for testing or one-time reactive operations where you need\n * relays to be active but don't want the watcher to reschedule on updates.\n * Pending operations keep their watcher alive until fulfillment or rejection.\n * There is no timeout or cancellation; work that never settles remains watched.\n *\n * @param fn - A sync or async function to watch once\n * @returns The synchronous value, or a native promise for an asynchronous result\n *\n * @example\n * ```ts\n * await watchOnce(async () => {\n * const data = relay((state) => {\n * // relay will be activated during watchOnce\n * fetch('/api/data').then(res => state.value = res.data);\n * });\n * await data;\n * return data.value;\n * });\n * ```\n */\nexport function watchOnce(fn) {\n // Create a watcher signal\n const signal = watcher(fn);\n pendingOnceWatchers.add(signal);\n const release = () => {\n if (pendingOnceWatchers.delete(signal)) {\n unwatchSignal(signal);\n }\n };\n try {\n // Watch the signal to activate any relays\n watchSignal(signal);\n // Get the value, which runs the function\n let result = getSignal(signal);\n if (result !== null && typeof result === 'object' && (isReactivePromise(result) || isPromise(result))) {\n result = result.finally(release);\n }\n else {\n release();\n }\n return result;\n }\n catch (error) {\n release();\n throw error;\n }\n}\n/**\n * Keeps `fn`'s dependencies (relays, queries) watched until `ttl` ms pass or the returned\n * `release` is called. Without a `ttl`, or with `Infinity`, it lasts until released. A `ttl` above\n * 2^31 - 1 ms is clamped; a negative or `NaN` one throws a `RangeError`.\n *\n * Use it to keep data warm without rendering it, e.g. prefetching a likely next screen. `fn` runs\n * now, in the current scope, and again when its dependencies change.\n *\n * @example\n * ```ts\n * const release = retain(() => fetchTokenDetail(id), { ttl: 30_000 });\n * ```\n */\nexport function retain(fn, opts) {\n const ttl = opts?.ttl;\n if (ttl !== undefined && (typeof ttl !== 'number' || Number.isNaN(ttl) || ttl < 0)) {\n throw new RangeError(`signalium: retain() ttl must be a non-negative number of milliseconds, got ${String(ttl)}`);\n }\n const signal = watcher(fn);\n const unsubscribe = signal.addListener(noop);\n let timer;\n const release = () => {\n if (timer !== undefined) {\n clearTimeout(timer);\n timer = undefined;\n }\n unsubscribe();\n };\n try {\n // Run now so relays activate immediately, not on the next flush.\n getSignal(signal);\n }\n catch (error) {\n release();\n throw error;\n }\n // `setTimeout` fires immediately for delays above MAX_TIMEOUT.\n if (ttl !== undefined && ttl !== Infinity) {\n timer = setTimeout(release, Math.min(ttl, MAX_TIMEOUT));\n }\n return release;\n}\nconst noop = () => { };\nexport { setReactivePromise } from './internals/async.js';\n/**\n * Forwards state from a source relay to the target relay's state.\n * This enables composition patterns where relays can add side effects\n * while transparently forwarding state from another relay.\n *\n * The forwarding is automatically tracked through the signal graph.\n * When the source relay updates, the target relay will re-run its\n * activation function, and forwardRelay will forward the new state.\n * No cleanup is needed - dependencies are managed automatically.\n *\n * @param state - The target relay's state object\n * @param sourceRelay - The source relay to forward state from\n *\n * @example\n * ```ts\n * const sourceRelay = relay(state => {\n * // ... source relay logic\n * });\n *\n * const forwardedRelay = relay(state => {\n * // Add additional side effect\n * const cleanup = setupSomeEffect();\n *\n * // Forward state from source relay (automatically tracked and cleaned up)\n * forwardRelay(state, sourceRelay);\n *\n * return cleanup; // Only return cleanup for the additional effect\n * });\n * ```\n */\nexport function forwardRelay(state, sourceRelay) {\n // Verify that sourceRelay is actually a ReactivePromiseImpl\n if (!isReactivePromise(sourceRelay)) {\n throw new Error('forwardRelay: sourceRelay must be a ReactivePromise');\n }\n // Read from source relay to establish dependency and forward state\n // When sourceRelay updates, this relay's activation function will be called again,\n // and forwardRelay will be called again, forwarding the new state\n if (sourceRelay.isPending) {\n // For pending state, try to forward the promise if available\n // Accessing isPending establishes the dependency\n const source = sourceRelay;\n const promise = source['_promise'];\n if (promise) {\n state.setPromise(promise);\n }\n }\n else if (sourceRelay.isRejected) {\n // Accessing error establishes dependency and forwards it\n const error = sourceRelay.error;\n if (error !== undefined) {\n state.setError(error);\n }\n }\n else if (sourceRelay.isResolved && sourceRelay.isReady) {\n // Accessing value establishes dependency and forwards it\n const value = sourceRelay.value;\n if (value !== undefined) {\n state.value = value;\n }\n }\n}\n"],"names":[],"mappings":";;;;;AASA,MAAM,sBAAsB,oBAAI,IAAG;AAyB5B,SAAS,UAAU,IAAI;AAE1B,QAAM,SAAS,QAAQ,EAAE;AACzB,sBAAoB,IAAI,MAAM;AAC9B,QAAM,UAAU,MAAM;AAClB,QAAI,oBAAoB,OAAO,MAAM,GAAG;AACpC,oBAAc,MAAM;AAAA,IACxB;AAAA,EACJ;AACA,MAAI;AAEA,gBAAY,MAAM;AAElB,QAAI,SAAS,UAAU,MAAM;AAC7B,QAAI,WAAW,QAAQ,OAAO,WAAW,aAAa,kBAAkB,MAAM,KAAK,UAAU,MAAM,IAAI;AACnG,eAAS,OAAO,QAAQ,OAAO;AAAA,IACnC,OACK;AACD,cAAO;AAAA,IACX;A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 import { a, s, b, c } from "./snapshot-Bx73RooF.js";
|
|
|
3
3
|
import { D as watchSignal, E as getSignal, l as isReactivePromise, v as isPromise, F as unwatchSignal } from "./contexts-D2PPNujL.js";
|
|
4
4
|
import { n, G, H } from "./contexts-D2PPNujL.js";
|
|
5
5
|
import { M as MAX_TIMEOUT } from "./config-BhtwQYAN.js";
|
|
6
|
+
const pendingOnceWatchers = /* @__PURE__ */ new Set();
|
|
6
7
|
function watchOnce(fn) {
|
|
7
8
|
const signal = watcher(fn);
|
|
9
|
+
pendingOnceWatchers.add(signal);
|
|
10
|
+
const release = () => {
|
|
11
|
+
if (pendingOnceWatchers.delete(signal)) {
|
|
12
|
+
unwatchSignal(signal);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
8
15
|
try {
|
|
9
16
|
watchSignal(signal);
|
|
10
17
|
let result = getSignal(signal);
|
|
11
|
-
if (isReactivePromise(result) || isPromise(result)) {
|
|
12
|
-
result = result.finally(
|
|
13
|
-
unwatchSignal(signal);
|
|
14
|
-
});
|
|
18
|
+
if (result !== null && typeof result === "object" && (isReactivePromise(result) || isPromise(result))) {
|
|
19
|
+
result = result.finally(release);
|
|
15
20
|
} else {
|
|
16
|
-
|
|
21
|
+
release();
|
|
17
22
|
}
|
|
18
23
|
return result;
|
|
19
24
|
} catch (error) {
|
|
20
|
-
|
|
25
|
+
release();
|
|
21
26
|
throw error;
|
|
22
27
|
}
|
|
23
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../.tsc-out/utils.js"],"sourcesContent":["export { hashValue, registerCustomHash } from './internals/utils/hash.js';\nexport { snapshot, registerCustomSnapshot, snapshotArray, snapshotPlainObject, } from './internals/utils/snapshot.js';\nimport { watcher } from './internals/core-api.js';\nimport { watchSignal, unwatchSignal } from './internals/watch.js';\nimport { getSignal } from './internals/get.js';\nimport { isReactivePromise } from './internals/async.js';\nimport { isPromise } from './internals/utils/type-utils.js';\nimport { MAX_TIMEOUT } from './internals/config.js';\n/**\n * Watches a function once in a reactive context, activating any relays,\n * then automatically tears down the watcher when complete.\n *\n * This is useful for testing or one-time reactive operations where you need\n * relays to be active but don't want the watcher to reschedule on updates.\n *\n * @param fn - A sync or async function to watch once\n * @returns
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../.tsc-out/utils.js"],"sourcesContent":["export { hashValue, registerCustomHash } from './internals/utils/hash.js';\nexport { snapshot, registerCustomSnapshot, snapshotArray, snapshotPlainObject, } from './internals/utils/snapshot.js';\nimport { watcher } from './internals/core-api.js';\nimport { watchSignal, unwatchSignal } from './internals/watch.js';\nimport { getSignal } from './internals/get.js';\nimport { isReactivePromise } from './internals/async.js';\nimport { isPromise } from './internals/utils/type-utils.js';\nimport { MAX_TIMEOUT } from './internals/config.js';\n// Promise reactions and weak graph edges do not root their producing watcher.\nconst pendingOnceWatchers = new Set();\n/**\n * Watches a function once in a reactive context, activating any relays,\n * then automatically tears down the watcher when complete.\n *\n * This is useful for testing or one-time reactive operations where you need\n * relays to be active but don't want the watcher to reschedule on updates.\n * Pending operations keep their watcher alive until fulfillment or rejection.\n * There is no timeout or cancellation; work that never settles remains watched.\n *\n * @param fn - A sync or async function to watch once\n * @returns The synchronous value, or a native promise for an asynchronous result\n *\n * @example\n * ```ts\n * await watchOnce(async () => {\n * const data = relay((state) => {\n * // relay will be activated during watchOnce\n * fetch('/api/data').then(res => state.value = res.data);\n * });\n * await data;\n * return data.value;\n * });\n * ```\n */\nexport function watchOnce(fn) {\n // Create a watcher signal\n const signal = watcher(fn);\n pendingOnceWatchers.add(signal);\n const release = () => {\n if (pendingOnceWatchers.delete(signal)) {\n unwatchSignal(signal);\n }\n };\n try {\n // Watch the signal to activate any relays\n watchSignal(signal);\n // Get the value, which runs the function\n let result = getSignal(signal);\n if (result !== null && typeof result === 'object' && (isReactivePromise(result) || isPromise(result))) {\n result = result.finally(release);\n }\n else {\n release();\n }\n return result;\n }\n catch (error) {\n release();\n throw error;\n }\n}\n/**\n * Keeps `fn`'s dependencies (relays, queries) watched until `ttl` ms pass or the returned\n * `release` is called. Without a `ttl`, or with `Infinity`, it lasts until released. A `ttl` above\n * 2^31 - 1 ms is clamped; a negative or `NaN` one throws a `RangeError`.\n *\n * Use it to keep data warm without rendering it, e.g. prefetching a likely next screen. `fn` runs\n * now, in the current scope, and again when its dependencies change.\n *\n * @example\n * ```ts\n * const release = retain(() => fetchTokenDetail(id), { ttl: 30_000 });\n * ```\n */\nexport function retain(fn, opts) {\n const ttl = opts?.ttl;\n if (ttl !== undefined && (typeof ttl !== 'number' || Number.isNaN(ttl) || ttl < 0)) {\n throw new RangeError(`signalium: retain() ttl must be a non-negative number of milliseconds, got ${String(ttl)}`);\n }\n const signal = watcher(fn);\n const unsubscribe = signal.addListener(noop);\n let timer;\n const release = () => {\n if (timer !== undefined) {\n clearTimeout(timer);\n timer = undefined;\n }\n unsubscribe();\n };\n try {\n // Run now so relays activate immediately, not on the next flush.\n getSignal(signal);\n }\n catch (error) {\n release();\n throw error;\n }\n // `setTimeout` fires immediately for delays above MAX_TIMEOUT.\n if (ttl !== undefined && ttl !== Infinity) {\n timer = setTimeout(release, Math.min(ttl, MAX_TIMEOUT));\n }\n return release;\n}\nconst noop = () => { };\nexport { setReactivePromise } from './internals/async.js';\n/**\n * Forwards state from a source relay to the target relay's state.\n * This enables composition patterns where relays can add side effects\n * while transparently forwarding state from another relay.\n *\n * The forwarding is automatically tracked through the signal graph.\n * When the source relay updates, the target relay will re-run its\n * activation function, and forwardRelay will forward the new state.\n * No cleanup is needed - dependencies are managed automatically.\n *\n * @param state - The target relay's state object\n * @param sourceRelay - The source relay to forward state from\n *\n * @example\n * ```ts\n * const sourceRelay = relay(state => {\n * // ... source relay logic\n * });\n *\n * const forwardedRelay = relay(state => {\n * // Add additional side effect\n * const cleanup = setupSomeEffect();\n *\n * // Forward state from source relay (automatically tracked and cleaned up)\n * forwardRelay(state, sourceRelay);\n *\n * return cleanup; // Only return cleanup for the additional effect\n * });\n * ```\n */\nexport function forwardRelay(state, sourceRelay) {\n // Verify that sourceRelay is actually a ReactivePromiseImpl\n if (!isReactivePromise(sourceRelay)) {\n throw new Error('forwardRelay: sourceRelay must be a ReactivePromise');\n }\n // Read from source relay to establish dependency and forward state\n // When sourceRelay updates, this relay's activation function will be called again,\n // and forwardRelay will be called again, forwarding the new state\n if (sourceRelay.isPending) {\n // For pending state, try to forward the promise if available\n // Accessing isPending establishes the dependency\n const source = sourceRelay;\n const promise = source['_promise'];\n if (promise) {\n state.setPromise(promise);\n }\n }\n else if (sourceRelay.isRejected) {\n // Accessing error establishes dependency and forwards it\n const error = sourceRelay.error;\n if (error !== undefined) {\n state.setError(error);\n }\n }\n else if (sourceRelay.isResolved && sourceRelay.isReady) {\n // Accessing value establishes dependency and forwards it\n const value = sourceRelay.value;\n if (value !== undefined) {\n state.value = value;\n }\n }\n}\n"],"names":[],"mappings":";;;;;AASA,MAAM,sBAAsB,oBAAI,IAAG;AAyB5B,SAAS,UAAU,IAAI;AAE1B,QAAM,SAAS,QAAQ,EAAE;AACzB,sBAAoB,IAAI,MAAM;AAC9B,QAAM,UAAU,MAAM;AAClB,QAAI,oBAAoB,OAAO,MAAM,GAAG;AACpC,oBAAc,MAAM;AAAA,IACxB;AAAA,EACJ;AACA,MAAI;AAEA,gBAAY,MAAM;AAElB,QAAI,SAAS,UAAU,MAAM;AAC7B,QAAI,WAAW,QAAQ,OAAO,WAAW,aAAa,kBAAkB,MAAM,KAAK,UAAU,MAAM,IAAI;AACnG,eAAS,OAAO,QAAQ,OAAO;AAAA,IACnC,OACK;AACD,cAAO;AAAA,IACX;AACA,WAAO;AAAA,EACX,SACO,OAAO;AACV,YAAO;AACP,UAAM;AAAA,EACV;AACJ;AAcO,SAAS,OAAO,IAAI,MAAM;AAC7B,QAAM,MAAM,MAAM;AAClB,MAAI,QAAQ,WAAc,OAAO,QAAQ,YAAY,OAAO,MAAM,GAAG,KAAK,MAAM,IAAI;AAChF,UAAM,IAAI,WAAW,8EAA8E,OAAO,GAAG,CAAC,EAAE;AAAA,EACpH;AACA,QAAM,SAAS,QAAQ,EAAE;AACzB,QAAM,cAAc,OAAO,YAAY,IAAI;AAC3C,MAAI;AACJ,QAAM,UAAU,MAAM;AAClB,QAAI,UAAU,QAAW;AACrB,mBAAa,KAAK;AAClB,cAAQ;AAAA,IACZ;AACA,gBAAW;AAAA,EACf;AACA,MAAI;AAEA,cAAU,MAAM;AAAA,EACpB,SACO,OAAO;AACV,YAAO;AACP,UAAM;AAAA,EACV;AAEA,MAAI,QAAQ,UAAa,QAAQ,UAAU;AACvC,YAAQ,WAAW,SAAS,KAAK,IAAI,KAAK,WAAW,CAAC;AAAA,EAC1D;AACA,SAAO;AACX;AACA,MAAM,OAAO,MAAM;AAAE;AAgCd,SAAS,aAAa,OAAO,aAAa;AAE7C,MAAI,CAAC,kBAAkB,WAAW,GAAG;AACjC,UAAM,IAAI,MAAM,qDAAqD;AAAA,EACzE;AAIA,MAAI,YAAY,WAAW;AAGvB,UAAM,SAAS;AACf,UAAM,UAAU,OAAO,UAAU;AACjC,QAAI,SAAS;AACT,YAAM,WAAW,OAAO;AAAA,IAC5B;AAAA,EACJ,WACS,YAAY,YAAY;AAE7B,UAAM,QAAQ,YAAY;AAC1B,QAAI,UAAU,QAAW;AACrB,YAAM,SAAS,KAAK;AAAA,IACxB;AAAA,EACJ,WACS,YAAY,cAAc,YAAY,SAAS;AAEpD,UAAM,QAAQ,YAAY;AAC1B,QAAI,UAAU,QAAW;AACrB,YAAM,QAAQ;AAAA,IAClB;AAAA,EACJ;AACJ;"}
|
package/dist/esm/utils.d.ts
CHANGED
|
@@ -7,9 +7,11 @@ import { RelayState, ReactivePromise } from './types.js';
|
|
|
7
7
|
*
|
|
8
8
|
* This is useful for testing or one-time reactive operations where you need
|
|
9
9
|
* relays to be active but don't want the watcher to reschedule on updates.
|
|
10
|
+
* Pending operations keep their watcher alive until fulfillment or rejection.
|
|
11
|
+
* There is no timeout or cancellation; work that never settles remains watched.
|
|
10
12
|
*
|
|
11
13
|
* @param fn - A sync or async function to watch once
|
|
12
|
-
* @returns
|
|
14
|
+
* @returns The synchronous value, or a native promise for an asynchronous result
|
|
13
15
|
*
|
|
14
16
|
* @example
|
|
15
17
|
* ```ts
|
package/dist/esm/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,EACL,QAAQ,EACR,sBAAsB,EACtB,aAAa,EACb,mBAAmB,EACnB,KAAK,UAAU,GAChB,MAAM,+BAA+B,CAAC;AASvC,OAAO,EAAiB,UAAU,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,EACL,QAAQ,EACR,sBAAsB,EACtB,aAAa,EACb,mBAAmB,EACnB,KAAK,UAAU,GAChB,MAAM,+BAA+B,CAAC;AASvC,OAAO,EAAiB,UAAU,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAMxE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CA6B3C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,MAAM,CAAC,EAAE,EAAE,MAAM,OAAO,EAAE,IAAI,CAAC,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,IAAI,CAkC7E;AAID,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,IAAI,CA8B3F"}
|