@callbag-recharge/callbag-recharge 0.19.0 → 0.20.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/{checkpoint-Bycg2nWZ.d.ts → checkpoint-DYPJl1rB.d.ts} +1 -1
- package/dist/{checkpoint-pDVUAV4-.d.cts → checkpoint-Dy-WJA3r.d.cts} +1 -1
- package/dist/chunk-I3EB4ACM.js +1 -0
- package/dist/chunk-OLY7RFGZ.js +1 -0
- package/dist/{retry-CFYCmi5U.d.cts → circuitBreaker--CJqUJ4u.d.cts} +30 -1
- package/dist/{retry-uvt4L9x2.d.ts → circuitBreaker-eEj1lt8U.d.ts} +30 -1
- package/dist/compat/vue/index.cjs +1 -1
- package/dist/compat/vue/index.d.cts +37 -3
- package/dist/compat/vue/index.d.ts +37 -3
- package/dist/compat/vue/index.js +1 -1
- package/dist/extra/index.d.cts +2 -42
- package/dist/extra/index.d.ts +2 -42
- package/dist/extra/index.js +1 -1
- package/dist/fromTrigger-CPwRyr-E.d.cts +44 -0
- package/dist/fromTrigger-NowLcn6v.d.ts +44 -0
- package/dist/index.d.cts +4 -130
- package/dist/index.d.ts +4 -130
- package/dist/messaging/index.d.cts +1 -1
- package/dist/messaging/index.d.ts +1 -1
- package/dist/orchestrate/index.cjs +8 -8
- package/dist/orchestrate/index.d.cts +105 -3
- package/dist/orchestrate/index.d.ts +105 -3
- package/dist/orchestrate/index.js +5 -5
- package/dist/state-Ct6sOlOt.d.cts +131 -0
- package/dist/state-MV8qYwm5.d.ts +131 -0
- package/dist/utils/index.cjs +9 -6
- package/dist/utils/index.d.cts +94 -33
- package/dist/utils/index.d.ts +94 -33
- package/dist/utils/index.js +6 -3
- package/package.json +1 -1
- package/dist/chunk-BKJEZSZY.js +0 -1
- package/dist/chunk-RVW6YZVJ.js +0 -1
|
@@ -67,4 +67,4 @@ declare function checkpoint<A>(id: string, adapter: CheckpointAdapter, opts?: {
|
|
|
67
67
|
*/
|
|
68
68
|
declare function memoryAdapter(): CheckpointAdapter;
|
|
69
69
|
|
|
70
|
-
export { type CheckpointAdapter as C, type
|
|
70
|
+
export { type CheckpointAdapter as C, type CheckpointedStore as a, type CheckpointMeta as b, checkpoint as c, memoryAdapter as m };
|
|
@@ -67,4 +67,4 @@ declare function checkpoint<A>(id: string, adapter: CheckpointAdapter, opts?: {
|
|
|
67
67
|
*/
|
|
68
68
|
declare function memoryAdapter(): CheckpointAdapter;
|
|
69
69
|
|
|
70
|
-
export { type CheckpointAdapter as C, type
|
|
70
|
+
export { type CheckpointAdapter as C, type CheckpointedStore as a, type CheckpointMeta as b, checkpoint as c, memoryAdapter as m };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as v}from"./chunk-YBVQC3GP.js";import{i as T}from"./chunk-2F6QWERG.js";import{b as a,s as g,t as S,u as p}from"./chunk-TUPD47IE.js";function x(t,e){return T(({emit:i,complete:f})=>{if(e?.aborted){i(void 0),f();return}let o=!1,u=setTimeout(()=>{o||(o=!0,d(),i(void 0),f())},t);function r(){o||(o=!0,clearTimeout(u),i(void 0),f())}e?.addEventListener("abort",r,{once:!0});function d(){e?.removeEventListener("abort",r)}return()=>{o||(o=!0,clearTimeout(u),d())}})}function A(t){let e=null,i=t?.initial,f=T(({emit:u})=>(e=u,()=>{e=null}),{initial:t?.initial,name:t?.name??"trigger",kind:"trigger",equals:()=>!1,getter:()=>i});return{get(){return i},source:f.source,fire(u){i=u,e&&e(u)}}}function L(t,e,i){let f=i?.name??"route",o=v([t],({emit:r,signal:d,complete:m,error:c})=>(b,s,n)=>{if(s===p)d(n);else if(s===g)try{e(n)?r(n):d(a)}catch(l){c(l)}else s===S&&(n!==void 0?c(n):m())},{name:`${f}:match`,kind:"route",getter:()=>{try{let r=t.get();return e(r)?r:void 0}catch{return}}}),u=v([t],({emit:r,signal:d,complete:m,error:c})=>(b,s,n)=>{if(s===p)d(n);else if(s===g)try{e(n)?d(a):r(n)}catch(l){c(l)}else s===S&&(n!==void 0?c(n):m())},{name:`${f}:miss`,kind:"route",getter:()=>{try{let r=t.get();return e(r)?void 0:r}catch{return}}});return[o,u]}export{x as a,A as b,L as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as R}from"./chunk-QSFTSBDR.js";import{a as k}from"./chunk-EAK2HKAD.js";import{B as S}from"./chunk-TUPD47IE.js";function O(n,p){let i=Math.max(1,p?.concurrency??1),a=p?.strategy??"fifo",l=p?.name??"asyncQueue",m=k(0,{name:`${l}.size`}),e=k(0,{name:`${l}.running`}),c=k(0,{name:`${l}.completed`}),b=k(0,{name:`${l}.failed`}),y=k(!1,{name:`${l}.paused`}),u=[],t=0,d=!1;function h(o,r){d||(t--,e.set(t),c.update(s=>s+1),o.done$.set({ok:!0,result:r}),f())}function w(o,r){d||(t--,e.set(t),b.update(s=>s+1),o.done$.set({ok:!1,error:r}),f())}function f(){if(!(d||y.get()))for(;t<i&&u.length>0;){let o=a==="lifo"?u.pop():u.shift();m.set(u.length),t++,e.set(t);try{n(o.task).then(r=>h(o,r),r=>w(o,r))}catch(r){w(o,r)}}}function C(o){if(d)return Promise.reject(new Error("Queue is disposed"));let r=k(null,{name:`${l}.task`});return u.push({task:o,done$:r}),m.set(u.length),f(),R(r,s=>s!==null).then(s=>{if(S(r),s.ok)return s.result;throw s.error},s=>{throw S(r),s})}function v(){y.set(!0)}function T(){y.set(!1),f()}function g(){let o=u.splice(0,u.length);m.set(0);for(let r of o)r.done$.set({ok:!1,error:new Error("Queue cleared")})}function x(){d||(d=!0,g())}return{enqueue:C,size:m,running:e,completed:c,failed:b,pause:v,resume:T,paused:y,clear:g,dispose:x}}function M(n){let p=n?.failureThreshold??5,i=n?.cooldownMs??3e4,a=n?.cooldown??null,l=n?.halfOpenMax??1,m=n?.now??Date.now,e="closed",c=0,b=0,y=0,u=i,t=0;function d(){if(!a)return i;let f=a(b);return f!==null?f:i}function h(){e="open",u=d(),y=m(),t=0}return{canExecute(){return e==="closed"?!0:e==="open"?m()-y>=u?(e="half-open",t=1,!0):!1:t<l?(t++,!0):!1},recordSuccess(){e==="half-open"?(e="closed",c=0,b=0):e==="closed"&&(c=0)},recordFailure(f){if(e==="half-open"){b++,h();return}e==="closed"&&(c++,c>=p&&h())},get state(){return e},get failureCount(){return c},reset(){e="closed",c=0,b=0,t=0}}}function A(n){return(p,i)=>{if(p!==0)return;let a=!1;i(0,l=>{l===2&&(a=!0)}),n.onsuccess=()=>{a||(a=!0,i(1,n.result),i(2))},n.onerror=()=>{a||(a=!0,i(2,n.error))}}}export{O as a,A as b,M as c};
|
|
@@ -37,4 +37,33 @@ interface RetryMeta {
|
|
|
37
37
|
*/
|
|
38
38
|
declare function retry<A>(config: number | RetryOptions): StoreOperator<A, A>;
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
type CircuitState = "closed" | "open" | "half-open";
|
|
41
|
+
interface CircuitBreakerOptions {
|
|
42
|
+
/** Number of consecutive failures before opening. Default: 5 */
|
|
43
|
+
failureThreshold?: number;
|
|
44
|
+
/** Base cooldown in ms before transitioning to half-open. Default: 30_000 */
|
|
45
|
+
cooldownMs?: number;
|
|
46
|
+
/** Backoff strategy for cooldown escalation across consecutive open cycles. */
|
|
47
|
+
cooldown?: BackoffStrategy;
|
|
48
|
+
/** Max trial requests allowed in half-open state. Default: 1 */
|
|
49
|
+
halfOpenMax?: number;
|
|
50
|
+
/** Optional clock function for testing. Default: Date.now */
|
|
51
|
+
now?: () => number;
|
|
52
|
+
}
|
|
53
|
+
interface CircuitBreaker {
|
|
54
|
+
/** Whether a request should be allowed through. */
|
|
55
|
+
canExecute(): boolean;
|
|
56
|
+
/** Record a successful execution. */
|
|
57
|
+
recordSuccess(): void;
|
|
58
|
+
/** Record a failed execution. */
|
|
59
|
+
recordFailure(error?: unknown): void;
|
|
60
|
+
/** Current circuit state. */
|
|
61
|
+
readonly state: CircuitState;
|
|
62
|
+
/** Number of consecutive failures in current closed period. */
|
|
63
|
+
readonly failureCount: number;
|
|
64
|
+
/** Manually reset to closed state. */
|
|
65
|
+
reset(): void;
|
|
66
|
+
}
|
|
67
|
+
declare function circuitBreaker(opts?: CircuitBreakerOptions): CircuitBreaker;
|
|
68
|
+
|
|
69
|
+
export { type CircuitBreakerOptions as C, type DelayStrategy as D, type RetryOptions as R, type CircuitBreaker as a, type CircuitState as b, type RetryMeta as c, circuitBreaker as d, retry as r };
|
|
@@ -37,4 +37,33 @@ interface RetryMeta {
|
|
|
37
37
|
*/
|
|
38
38
|
declare function retry<A>(config: number | RetryOptions): StoreOperator<A, A>;
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
type CircuitState = "closed" | "open" | "half-open";
|
|
41
|
+
interface CircuitBreakerOptions {
|
|
42
|
+
/** Number of consecutive failures before opening. Default: 5 */
|
|
43
|
+
failureThreshold?: number;
|
|
44
|
+
/** Base cooldown in ms before transitioning to half-open. Default: 30_000 */
|
|
45
|
+
cooldownMs?: number;
|
|
46
|
+
/** Backoff strategy for cooldown escalation across consecutive open cycles. */
|
|
47
|
+
cooldown?: BackoffStrategy;
|
|
48
|
+
/** Max trial requests allowed in half-open state. Default: 1 */
|
|
49
|
+
halfOpenMax?: number;
|
|
50
|
+
/** Optional clock function for testing. Default: Date.now */
|
|
51
|
+
now?: () => number;
|
|
52
|
+
}
|
|
53
|
+
interface CircuitBreaker {
|
|
54
|
+
/** Whether a request should be allowed through. */
|
|
55
|
+
canExecute(): boolean;
|
|
56
|
+
/** Record a successful execution. */
|
|
57
|
+
recordSuccess(): void;
|
|
58
|
+
/** Record a failed execution. */
|
|
59
|
+
recordFailure(error?: unknown): void;
|
|
60
|
+
/** Current circuit state. */
|
|
61
|
+
readonly state: CircuitState;
|
|
62
|
+
/** Number of consecutive failures in current closed period. */
|
|
63
|
+
readonly failureCount: number;
|
|
64
|
+
/** Manually reset to closed state. */
|
|
65
|
+
reset(): void;
|
|
66
|
+
}
|
|
67
|
+
declare function circuitBreaker(opts?: CircuitBreakerOptions): CircuitBreaker;
|
|
68
|
+
|
|
69
|
+
export { type CircuitBreakerOptions as C, type DelayStrategy as D, type RetryOptions as R, type CircuitBreaker as a, type CircuitState as b, type RetryMeta as c, circuitBreaker as d, retry as r };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var R=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var _=(e,t)=>{for(var r in t)R(e,r,{get:t[r],enumerable:!0})},I=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of N(t))!K.call(e,s)&&s!==r&&R(e,s,{get:()=>t[s],enumerable:!(o=A(t,s))||o.enumerable});return e};var k=e=>I(R({},"__esModule",{value:!0}),e);var U={};_(U,{useStore:()=>C,useSubscribe:()=>w,useSubscribeRecord:()=>M});module.exports=k(U);var n=require("vue");var P=7,W=7<<P;var b=0;var T=2,g=3;var y=0,E=[];function m(){y++}function v(){if(y--,y===0){for(let e=0;e<E.length;e++)E[e]();E.length=0}}function p(e,t,r){let o=null;m(),e.source(b,(i,a)=>{if(i===b&&(o=a),i===T){o=null,r?.onEnd?.(a);return}if(i===1){let c=a,u=s;s=c,t(c,u)}});let s;try{s=e.get()}catch{}return v(),{unsubscribe(){o?.(T),o=null},signal(i){o?.(g,i)}}}function w(e){let t=(0,n.shallowRef)(e.get()),r=p(e,o=>{t.value=o});return(0,n.getCurrentScope)()?(0,n.onScopeDispose)(()=>r.unsubscribe()):typeof console<"u"&&console.warn("[callbag-recharge] useSubscribe called outside a Vue scope \u2014 subscription will not be auto-disposed."),(0,n.readonly)(t)}function C(e){let t=(0,n.shallowRef)(e.get()),r=p(e,o=>{t.value=o});return(0,n.getCurrentScope)()?(0,n.onScopeDispose)(()=>r.unsubscribe()):typeof console<"u"&&console.warn("[callbag-recharge] useStore called outside a Vue scope \u2014 subscription will not be auto-disposed."),(0,n.computed)({get:()=>t.value,set:o=>e.set(o)})}function M(e,t){let r=(0,n.shallowRef)({}),o=new Map,s=!1;function i(){s||(s=!0,queueMicrotask(()=>{s=!1;let c={};for(let[u,f]of o)c[u]={...f.values};r.value=c}))}function a(c){for(let f of o.values())for(let l of f.subs)l.unsubscribe();o.clear();for(let f of c){let l=t(f),h=Object.keys(l),S={},D=[];for(let d of h){let x=l[d];S[d]=x.get();let L=p(x,O=>{S[d]=O,i()});D.push(L)}o.set(f,{subs:D,values:S})}let u={};for(let[f,l]of o)u[f]={...l.values};r.value=u}return(0,n.watch)(e,c=>a(c),{immediate:!0}),(0,n.getCurrentScope)()&&(0,n.onScopeDispose)(()=>{for(let c of o.values())for(let u of c.subs)u.unsubscribe();o.clear()}),(0,n.readonly)(r)}0&&(module.exports={useStore,useSubscribe,useSubscribeRecord});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Ref } from 'vue';
|
|
2
|
-
import {
|
|
1
|
+
import { Ref, WatchSource } from 'vue';
|
|
2
|
+
import { S as Store, W as WritableStore } from '../../types-BohB8jJr.cjs';
|
|
3
3
|
import '../../protocol-fwiQ1TAS.cjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -38,5 +38,39 @@ declare function useSubscribe<T>(store: Store<T>): Readonly<Ref<T>>;
|
|
|
38
38
|
* @category compat/vue
|
|
39
39
|
*/
|
|
40
40
|
declare function useStore<T>(store: WritableStore<T>): Ref<T>;
|
|
41
|
+
/** Maps a key to an object of stores. Used by `useSubscribeRecord` factory. */
|
|
42
|
+
type StoreFactory<K, R extends Record<string, any>> = (key: K) => {
|
|
43
|
+
[P in keyof R]: Store<R[P]>;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Subscribe to a dynamic set of keyed store records. When keys change,
|
|
47
|
+
* old subscriptions are torn down and new ones created automatically.
|
|
48
|
+
*
|
|
49
|
+
* Solves the common pattern of rendering a list where each item owns
|
|
50
|
+
* multiple reactive stores (e.g., DAG nodes with status + breaker + log).
|
|
51
|
+
*
|
|
52
|
+
* Must be called during Vue `setup()`.
|
|
53
|
+
*
|
|
54
|
+
* @param keys - Reactive source of current keys (e.g., node IDs).
|
|
55
|
+
* @param factory - Function that returns a `{ [field]: Store<V> }` object per key.
|
|
56
|
+
*
|
|
57
|
+
* @returns `Readonly<Ref<Record<K, R>>>` — reactive record of resolved values.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* const nodes = useSubscribe(wb.nodes); // Ref<WorkflowNode[]>
|
|
62
|
+
* const nodeData = useSubscribeRecord(
|
|
63
|
+
* () => nodes.value.map(n => n.id),
|
|
64
|
+
* (id) => {
|
|
65
|
+
* const n = nodes.value.find(n => n.id === id)!;
|
|
66
|
+
* return { status: n.task.status, breaker: n.breakerState };
|
|
67
|
+
* },
|
|
68
|
+
* );
|
|
69
|
+
* // Template: {{ nodeData["extract"].status }}
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @category compat/vue
|
|
73
|
+
*/
|
|
74
|
+
declare function useSubscribeRecord<K extends string, R extends Record<string, any>>(keys: WatchSource<K[]>, factory: StoreFactory<K, R>): Readonly<Ref<Record<K, R>>>;
|
|
41
75
|
|
|
42
|
-
export { useStore, useSubscribe };
|
|
76
|
+
export { type StoreFactory, useStore, useSubscribe, useSubscribeRecord };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Ref } from 'vue';
|
|
2
|
-
import {
|
|
1
|
+
import { Ref, WatchSource } from 'vue';
|
|
2
|
+
import { S as Store, W as WritableStore } from '../../types-CB1htCM8.js';
|
|
3
3
|
import '../../protocol-fwiQ1TAS.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -38,5 +38,39 @@ declare function useSubscribe<T>(store: Store<T>): Readonly<Ref<T>>;
|
|
|
38
38
|
* @category compat/vue
|
|
39
39
|
*/
|
|
40
40
|
declare function useStore<T>(store: WritableStore<T>): Ref<T>;
|
|
41
|
+
/** Maps a key to an object of stores. Used by `useSubscribeRecord` factory. */
|
|
42
|
+
type StoreFactory<K, R extends Record<string, any>> = (key: K) => {
|
|
43
|
+
[P in keyof R]: Store<R[P]>;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Subscribe to a dynamic set of keyed store records. When keys change,
|
|
47
|
+
* old subscriptions are torn down and new ones created automatically.
|
|
48
|
+
*
|
|
49
|
+
* Solves the common pattern of rendering a list where each item owns
|
|
50
|
+
* multiple reactive stores (e.g., DAG nodes with status + breaker + log).
|
|
51
|
+
*
|
|
52
|
+
* Must be called during Vue `setup()`.
|
|
53
|
+
*
|
|
54
|
+
* @param keys - Reactive source of current keys (e.g., node IDs).
|
|
55
|
+
* @param factory - Function that returns a `{ [field]: Store<V> }` object per key.
|
|
56
|
+
*
|
|
57
|
+
* @returns `Readonly<Ref<Record<K, R>>>` — reactive record of resolved values.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* const nodes = useSubscribe(wb.nodes); // Ref<WorkflowNode[]>
|
|
62
|
+
* const nodeData = useSubscribeRecord(
|
|
63
|
+
* () => nodes.value.map(n => n.id),
|
|
64
|
+
* (id) => {
|
|
65
|
+
* const n = nodes.value.find(n => n.id === id)!;
|
|
66
|
+
* return { status: n.task.status, breaker: n.breakerState };
|
|
67
|
+
* },
|
|
68
|
+
* );
|
|
69
|
+
* // Template: {{ nodeData["extract"].status }}
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @category compat/vue
|
|
73
|
+
*/
|
|
74
|
+
declare function useSubscribeRecord<K extends string, R extends Record<string, any>>(keys: WatchSource<K[]>, factory: StoreFactory<K, R>): Readonly<Ref<Record<K, R>>>;
|
|
41
75
|
|
|
42
|
-
export { useStore, useSubscribe };
|
|
76
|
+
export { type StoreFactory, useStore, useSubscribe, useSubscribeRecord };
|
package/dist/compat/vue/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a
|
|
1
|
+
import{a}from"../../chunk-GMLWTZFM.js";import"../../chunk-TUPD47IE.js";import"../../chunk-I7AUKTXE.js";import{computed as h,getCurrentScope as b,onScopeDispose as R,readonly as S,shallowRef as d,watch as k}from"vue";function W(o){let r=d(o.get()),n=a(o,e=>{r.value=e});return b()?R(()=>n.unsubscribe()):typeof console<"u"&&console.warn("[callbag-recharge] useSubscribe called outside a Vue scope \u2014 subscription will not be auto-disposed."),S(r)}function P(o){let r=d(o.get()),n=a(o,e=>{r.value=e});return b()?R(()=>n.unsubscribe()):typeof console<"u"&&console.warn("[callbag-recharge] useStore called outside a Vue scope \u2014 subscription will not be auto-disposed."),h({get:()=>r.value,set:e=>o.set(e)})}function F(o,r){let n=d({}),e=new Map,i=!1;function g(){i||(i=!0,queueMicrotask(()=>{i=!1;let s={};for(let[c,t]of e)s[c]={...t.values};n.value=s}))}function K(s){for(let t of e.values())for(let u of t.subs)u.unsubscribe();e.clear();for(let t of s){let u=r(t),v=Object.keys(u),f={},p=[];for(let l of v){let y=u[l];f[l]=y.get();let m=a(y,T=>{f[l]=T,g()});p.push(m)}e.set(t,{subs:p,values:f})}let c={};for(let[t,u]of e)c[t]={...u.values};n.value=c}return k(o,s=>K(s),{immediate:!0}),b()&&R(()=>{for(let s of e.values())for(let c of s.subs)c.unsubscribe();e.clear()}),S(n)}export{P as useStore,W as useSubscribe,F as useSubscribeRecord};
|
package/dist/extra/index.d.cts
CHANGED
|
@@ -19,6 +19,7 @@ export { fromEvent } from './fromEvent.cjs';
|
|
|
19
19
|
export { fromIter } from './fromIter.cjs';
|
|
20
20
|
export { fromObs } from './fromObs.cjs';
|
|
21
21
|
export { fromPromise } from './fromPromise.cjs';
|
|
22
|
+
export { T as TriggerStore, f as fromTrigger } from '../fromTrigger-CPwRyr-E.cjs';
|
|
22
23
|
export { interval } from './interval.cjs';
|
|
23
24
|
export { last } from './last.cjs';
|
|
24
25
|
export { map } from './map.cjs';
|
|
@@ -173,47 +174,6 @@ declare function fromCron(expr: string, opts?: FromCronOptions): Store<Date | un
|
|
|
173
174
|
*/
|
|
174
175
|
declare function fromTimer(ms: number, signal?: AbortSignal): ProducerStore<void>;
|
|
175
176
|
|
|
176
|
-
interface TriggerStore<T> extends Store<T | undefined> {
|
|
177
|
-
/** Emit a value to all subscribers. */
|
|
178
|
-
fire(value: T): void;
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Creates a manual trigger source. `.fire(value)` emits into the stream without equality dedup.
|
|
182
|
-
*
|
|
183
|
-
* @param opts - Optional configuration.
|
|
184
|
-
*
|
|
185
|
-
* @returns `TriggerStore<T>` — a store with:
|
|
186
|
-
*
|
|
187
|
-
* @returnsTable get() | () => T \| undefined | Last fired value (or initial).
|
|
188
|
-
* fire(value) | (value: T) => void | Emit a value to all subscribers.
|
|
189
|
-
* source | callbag | Underlying callbag source for subscriptions.
|
|
190
|
-
*
|
|
191
|
-
* @option name | string | undefined | Debug name for Inspector.
|
|
192
|
-
* @option initial | T | undefined | Value before first fire().
|
|
193
|
-
*
|
|
194
|
-
* @remarks **No dedup:** Every `fire()` call emits, even if the value is the same as the previous one.
|
|
195
|
-
* @remarks **Pulse semantics:** Backed by producer() — an event source, not persistent state.
|
|
196
|
-
*
|
|
197
|
-
* @example
|
|
198
|
-
* ```ts
|
|
199
|
-
* import { fromTrigger } from 'callbag-recharge/orchestrate';
|
|
200
|
-
* import { subscribe } from 'callbag-recharge';
|
|
201
|
-
*
|
|
202
|
-
* const trigger = fromTrigger<string>();
|
|
203
|
-
* subscribe(trigger, v => console.log(v));
|
|
204
|
-
* trigger.fire("go"); // logs "go"
|
|
205
|
-
* trigger.fire("go"); // logs "go" again
|
|
206
|
-
* ```
|
|
207
|
-
*
|
|
208
|
-
* @seeAlso [producer](./producer) — general-purpose source
|
|
209
|
-
*
|
|
210
|
-
* @category orchestrate
|
|
211
|
-
*/
|
|
212
|
-
declare function fromTrigger<T>(opts?: {
|
|
213
|
-
initial?: T;
|
|
214
|
-
name?: string;
|
|
215
|
-
}): TriggerStore<T>;
|
|
216
|
-
|
|
217
177
|
/**
|
|
218
178
|
* Partitions upstream into a reactive `Map` of per-key stores (Tier 2).
|
|
219
179
|
*
|
|
@@ -404,4 +364,4 @@ type Callbag = (type: number, payload?: any) => void;
|
|
|
404
364
|
declare function wrap<T>(rawSource: Callbag): Store<T>;
|
|
405
365
|
declare function wrap<A, B>(input: Store<A>, rawOp: (source: Callbag) => Callbag): Store<B>;
|
|
406
366
|
|
|
407
|
-
export { type CronSchedule, type FromCronOptions, type PausableStore,
|
|
367
|
+
export { type CronSchedule, type FromCronOptions, type PausableStore, audit, bufferCount, cached, firstValueFrom, fromAny, fromAsyncIter, fromCron, fromTimer, groupBy, matchesCron, parseCron, pausable, race, reduce, route, toArray, window, windowCount, windowTime, withLatestFrom, wrap };
|
package/dist/extra/index.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export { fromEvent } from './fromEvent.js';
|
|
|
19
19
|
export { fromIter } from './fromIter.js';
|
|
20
20
|
export { fromObs } from './fromObs.js';
|
|
21
21
|
export { fromPromise } from './fromPromise.js';
|
|
22
|
+
export { T as TriggerStore, f as fromTrigger } from '../fromTrigger-NowLcn6v.js';
|
|
22
23
|
export { interval } from './interval.js';
|
|
23
24
|
export { last } from './last.js';
|
|
24
25
|
export { map } from './map.js';
|
|
@@ -173,47 +174,6 @@ declare function fromCron(expr: string, opts?: FromCronOptions): Store<Date | un
|
|
|
173
174
|
*/
|
|
174
175
|
declare function fromTimer(ms: number, signal?: AbortSignal): ProducerStore<void>;
|
|
175
176
|
|
|
176
|
-
interface TriggerStore<T> extends Store<T | undefined> {
|
|
177
|
-
/** Emit a value to all subscribers. */
|
|
178
|
-
fire(value: T): void;
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Creates a manual trigger source. `.fire(value)` emits into the stream without equality dedup.
|
|
182
|
-
*
|
|
183
|
-
* @param opts - Optional configuration.
|
|
184
|
-
*
|
|
185
|
-
* @returns `TriggerStore<T>` — a store with:
|
|
186
|
-
*
|
|
187
|
-
* @returnsTable get() | () => T \| undefined | Last fired value (or initial).
|
|
188
|
-
* fire(value) | (value: T) => void | Emit a value to all subscribers.
|
|
189
|
-
* source | callbag | Underlying callbag source for subscriptions.
|
|
190
|
-
*
|
|
191
|
-
* @option name | string | undefined | Debug name for Inspector.
|
|
192
|
-
* @option initial | T | undefined | Value before first fire().
|
|
193
|
-
*
|
|
194
|
-
* @remarks **No dedup:** Every `fire()` call emits, even if the value is the same as the previous one.
|
|
195
|
-
* @remarks **Pulse semantics:** Backed by producer() — an event source, not persistent state.
|
|
196
|
-
*
|
|
197
|
-
* @example
|
|
198
|
-
* ```ts
|
|
199
|
-
* import { fromTrigger } from 'callbag-recharge/orchestrate';
|
|
200
|
-
* import { subscribe } from 'callbag-recharge';
|
|
201
|
-
*
|
|
202
|
-
* const trigger = fromTrigger<string>();
|
|
203
|
-
* subscribe(trigger, v => console.log(v));
|
|
204
|
-
* trigger.fire("go"); // logs "go"
|
|
205
|
-
* trigger.fire("go"); // logs "go" again
|
|
206
|
-
* ```
|
|
207
|
-
*
|
|
208
|
-
* @seeAlso [producer](./producer) — general-purpose source
|
|
209
|
-
*
|
|
210
|
-
* @category orchestrate
|
|
211
|
-
*/
|
|
212
|
-
declare function fromTrigger<T>(opts?: {
|
|
213
|
-
initial?: T;
|
|
214
|
-
name?: string;
|
|
215
|
-
}): TriggerStore<T>;
|
|
216
|
-
|
|
217
177
|
/**
|
|
218
178
|
* Partitions upstream into a reactive `Map` of per-key stores (Tier 2).
|
|
219
179
|
*
|
|
@@ -404,4 +364,4 @@ type Callbag = (type: number, payload?: any) => void;
|
|
|
404
364
|
declare function wrap<T>(rawSource: Callbag): Store<T>;
|
|
405
365
|
declare function wrap<A, B>(input: Store<A>, rawOp: (source: Callbag) => Callbag): Store<B>;
|
|
406
366
|
|
|
407
|
-
export { type CronSchedule, type FromCronOptions, type PausableStore,
|
|
367
|
+
export { type CronSchedule, type FromCronOptions, type PausableStore, audit, bufferCount, cached, firstValueFrom, fromAny, fromAsyncIter, fromCron, fromTimer, groupBy, matchesCron, parseCron, pausable, race, reduce, route, toArray, window, windowCount, windowTime, withLatestFrom, wrap };
|
package/dist/extra/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Be}from"../chunk-W7A67MEA.js";import{a as Pe,b as Me}from"../chunk-7BXTCJFE.js";import{a as B,b as P,c as ie}from"../chunk-2QHNHL5Y.js";import{a as ge}from"../chunk-RVW6YZVJ.js";import{a as ne}from"../chunk-QSFTSBDR.js";import{a as Ee}from"../chunk-4RCV2AVX.js";import{a as Oe}from"../chunk-RWOVH7KX.js";import{a as Ce}from"../chunk-CNTT2H6Y.js";import{a as ve}from"../chunk-JTNG3QAI.js";import{a as Ie}from"../chunk-JVKWUVKQ.js";import{a as Re}from"../chunk-VEJRX4GP.js";import{a as De}from"../chunk-OA7V2X54.js";import{a as Se}from"../chunk-WEPYOEEV.js";import{a as Ae}from"../chunk-E2AW7OYE.js";import{a as xe}from"../chunk-35BBDNSG.js";import{a as ye}from"../chunk-4CA73RLN.js";import{a as Te}from"../chunk-22CAZLO3.js";import{a as we}from"../chunk-VWMY3GUZ.js";import{a as he}from"../chunk-ODNVGOOO.js";import{a as ke}from"../chunk-EV5DA5VJ.js";import{a as ue}from"../chunk-3VEB4GWB.js";import{a as se}from"../chunk-SWGLEZSU.js";import{a as le}from"../chunk-ABE7NDDH.js";import{a as ae}from"../chunk-LQ4T5H3N.js";import{a as me}from"../chunk-F5UMSRLI.js";import{a as pe}from"../chunk-6QFOVQRL.js";import{a as ce,b as de}from"../chunk-QX7UQF6F.js";import{a as be}from"../chunk-GI7IGLWO.js";import{a as Z}from"../chunk-5WFSQQDI.js";import{a as ee}from"../chunk-22FZRVAU.js";import{a as re}from"../chunk-TLLIQ7WA.js";import{a as te}from"../chunk-UVORPAQM.js";import{a as oe}from"../chunk-LHEDPW3C.js";import{a as M}from"../chunk-JW2KZLSD.js";import{a as fe}from"../chunk-VFXNSORS.js";import{a as U}from"../chunk-YXMKE3MO.js";import{a as Y}from"../chunk-HHJFEHV3.js";import{a as $}from"../chunk-HTZLRRTE.js";import{a as H}from"../chunk-54BT6MU4.js";import{a as G}from"../chunk-SFO5COGM.js";import{a as J}from"../chunk-5JSJZFLR.js";import{a as Q}from"../chunk-5I4THZPQ.js";import{a as X}from"../chunk-3TGYRIQB.js";import{a as F}from"../chunk-A4HLU3K4.js";import{a as K}from"../chunk-OGDTSFTW.js";import{a as V}from"../chunk-ODEEQ7UH.js";import{a as j}from"../chunk-PKAASLJ7.js";import{a as q}from"../chunk-TPKLTDRR.js";import{a as N}from"../chunk-KJW2EGU5.js";import{a as z}from"../chunk-FLKDEQGB.js";import"../chunk-XFA2D6KP.js";import{a as v}from"../chunk-YBVQC3GP.js";import"../chunk-PV347CGV.js";import{a as I}from"../chunk-HK7DRUNM.js";import"../chunk-LLARZ7J7.js";import{a as x}from"../chunk-GMLWTZFM.js";import{a as k}from"../chunk-EAK2HKAD.js";import{i as b}from"../chunk-2F6QWERG.js";import{a as g}from"../chunk-2L6223KN.js";import{a as C,b as E,d as T,e as R,f as D,r as y,s as w,t as A,u as O,y as W,z as _}from"../chunk-TUPD47IE.js";import"../chunk-I7AUKTXE.js";function We(n){return u=>{let m=b(({emit:p,error:l,complete:s,onSignal:f})=>{let e=null,t,i=!1,r;return f(o=>{r.signal(o),o===T&&(e!==null&&(clearTimeout(e),e=null),i=!1,t=void 0)}),r=x(u,o=>{t=o,i=!0,e===null&&(e=setTimeout(()=>{e=null,i&&(i=!1,p(t))},n))},{onEnd:o=>{e!==null&&(clearTimeout(e),e=null),o!==void 0?l(o):(i&&(i=!1,p(t)),s())}}),()=>{e!==null&&(clearTimeout(e),e=null),i=!1,r.unsubscribe()}});return g.register(m,{kind:"audit"}),m}}function _e(n,u){return m=>{let p=b(({emit:l,error:s,complete:f,onSignal:e})=>{if(u!==void 0&&u>0){let r=[],o=0,a=x(m,c=>{o%u===0&&r.push([]),o++;for(let S of r)S.push(c);let d=[];r=r.filter(S=>S.length>=n?(d.push(S),!1):!0);for(let S of d)Object.freeze(S),l(S)},{onEnd:c=>{if(c!==void 0)r=[],s(c);else{let d=r;r=[];for(let S of d)S.length>0&&(Object.freeze(S),l(S));f()}}});return e(c=>{a.signal(c),c===T&&(r=[],o=0)}),()=>{r=[],a.unsubscribe()}}let t=[],i=x(m,r=>{if(t.push(r),t.length>=n){let o=t;Object.freeze(o),t=[],l(o)}},{onEnd:r=>{if(r!==void 0)t=[],s(r);else{if(t.length>0){let o=t;Object.freeze(o),t=[],l(o)}f()}}});return e(r=>{i.signal(r),r===T&&(t=[])}),()=>{t=[],i.unsubscribe()}},{initial:[]});return g.register(p,{kind:"bufferCount"}),p}}function Le(...n){return Array.isArray(n[0])?Fe(n[0],n[1],n[2]):Ke(n[0])}function Fe(n,u,m){let p=m?.equals,l=new Array(n.length),s,f=!1;s=u(),f=!0;for(let e=0;e<n.length;e++)l[e]=n[e].get();return v(n,({emit:e,signal:t,complete:i,error:r})=>{let o=new I(n.length),a=!1;function c(){let d=u();for(let S=0;S<n.length;S++)l[S]=n[S].get();p&&f&&p(s,d)?t(E):(s=d,f=!0,e(d))}return(d,S,h)=>{S===O&&(h===C?(o.empty()&&(a=!1),o.set(d)):h===E&&o.test(d)&&(o.clear(d),o.empty()&&(a?c():t(E))),t(h)),S===w&&(o.test(d)?(o.clear(d),a=!0,o.empty()&&c()):o.empty()?c():a=!0),S===A&&(h!==void 0?r(h):i())}},{...m,kind:"cached",initial:s,getter:()=>{if(f){let t=!0;for(let i=0;i<n.length;i++)if(!Object.is(n[i].get(),l[i])){t=!1;break}if(t)return s}let e=u();for(let t=0;t<n.length;t++)l[t]=n[t].get();return s=e,f=!0,e}})}function Ke(n){return u=>{let m=n??Object.is,p=u.get();return v([u],({emit:l,signal:s,complete:f,error:e})=>(t,i,r)=>{i===O&&s(r),i===w&&(m(p,r)?s(E):(p=r,l(r))),i===A&&(r!==void 0?e(r):f())},{kind:"cached",initial:p,getter:()=>{let l=u.get();return m(p,l)?p:(p=l,l)}})}}function Ve(n){let u=b(({emit:m,complete:p,error:l})=>{let s=new AbortController,f=s.signal,e=!1,i=(typeof n=="function"?n():n)[Symbol.asyncIterator]();async function r(){try{for(;!e&&!f.aborted;){let o=await i.next();if(e||f.aborted)break;if(o.done){p();return}m(o.value)}}catch(o){!e&&!f.aborted&&l(o)}}return r(),()=>{e=!0,s.abort(),Promise.resolve(i.return?.()).catch(()=>{})}},{resubscribable:!0});return g.register(u,{kind:"fromAsyncIter"}),u}function je(n,u){let m=B(n),p=u?.tickMs??6e4;return b(({emit:l})=>{let s=-1,f=()=>{let t=new Date,i=t.getFullYear()*1e8+(t.getMonth()+1)*1e6+t.getDate()*1e4+t.getHours()*100+t.getMinutes();i!==s&&P(m,t)&&(s=i,l(t))};f();let e=setInterval(f,p);return()=>clearInterval(e)},{name:u?.id??`cron:${n}`})}function qe(n,u){return b(({emit:m,complete:p})=>{if(u?.aborted){m(void 0),p();return}let l=!1,s=setTimeout(()=>{l||(l=!0,e(),m(void 0),p())},n);function f(){l||(l=!0,clearTimeout(s),m(void 0),p())}u?.addEventListener("abort",f,{once:!0});function e(){u?.removeEventListener("abort",f)}return()=>{l||(l=!0,clearTimeout(s),e())}})}function Ne(n){let u=null,m=n?.initial,p=b(({emit:s})=>(u=s,()=>{u=null}),{initial:n?.initial,name:n?.name??"trigger",kind:"trigger",equals:()=>!1,getter:()=>m});return{get(){return m},source:p.source,fire(s){m=s,u&&u(s)}}}function ze(n){return u=>{let m=b(({emit:p,error:l,complete:s,onSignal:f})=>{let e=new Map,t=new Map,i=x(u,r=>{let o;try{o=n(r)}catch(d){l(d);return}let a=e.get(o),c=!1;a?a.set(r):(a=k(r),e.set(o,a),c=!0),c&&(t=new Map(e),p(t))},{onEnd:r=>{r!==void 0?l(r):s()}});return f(r=>{i.signal(r),r===T&&(e.clear(),t=new Map)}),()=>{e.clear(),t=new Map,i.unsubscribe()}},{initial:new Map});return g.register(m,{kind:"groupBy"}),m}}var Ue=0;function Ye(n){return u=>{let m=k(!1,{name:`${n?.name??"pausable"}:paused`}),p=u.get(),l=!1,s=null,f=null,e=null,i=v([u],({emit:r,signal:o,complete:a,error:c})=>(f=o,e=r,(d,S,h)=>{if(S===O){h===R?l||(l=!0,m.set(!0)):h===D&&l&&s===null&&(l=!1,m.set(!1),o(C),r(p)),o(h);return}if(S===w){p=h,l?o(E):r(h);return}S===A&&(h!==void 0?c(h):a())}),{kind:"pausable",name:n?.name??"pausable",initial:u.get(),equals:n?.equals,getter:()=>u.get()});return i.pause=()=>(l&&s!==null||(l=!0,s=`pause-${++Ue}`,m.set(!0),f?.(R)),s),i.resume=r=>{!l||s!==r||(l=!1,s=null,m.set(!1),f?.(D),f&&f(C),e?.(p))},Object.defineProperty(i,"paused",{get:()=>m,enumerable:!0}),i}}function $e(...n){let u=b(({emit:m,error:p,complete:l,onSignal:s})=>{if(n.length===0){l();return}let f=-1,e=!1,t=0,i=new Array(n.length).fill(null);function r(o){for(let a=0;a<i.length;a++)a!==o&&i[a]&&(i[a](A),i[a]=null)}W();for(let o=0;o<n.length;o++){let a=o;n[a].source(y,(c,d)=>{if(c===y){i[a]=d,f!==-1&&f!==a&&(i[a](A),i[a]=null);return}if(c===1){if(e)return;f===-1&&(f=a,r(a)),f===a&&m(d)}if(c===A){if(i[a]=null,e)return;d!==void 0?(f===-1||f===a)&&(e=!0,r(-1),p(d)):f===a?(e=!0,l()):f===-1&&(t++,t===n.length&&(e=!0,l()))}})}return _(),s(o=>{for(let a of i)a&&a(O,o)}),()=>{e=!0,r(-1)}},{resubscribable:!0});return g.register(u,{kind:"race"}),u}function He(n,u){return m=>{let p=b(({emit:l,error:s,complete:f})=>{let e=u,t=x(m,i=>{e=n(e,i)},{onEnd:i=>{i!==void 0?s(i):(l(e),f())}});return()=>{t.unsubscribe()}},{initial:u});return g.register(p,{kind:"reduce"}),p}}function Ge(){return n=>{let u=b(({emit:m,error:p,complete:l,onSignal:s})=>{let f=[],e=x(n,t=>{f.push(t)},{onEnd:t=>{if(t!==void 0)f=[],p(t);else{let i=f;Object.freeze(i),f=[],m(i),l()}}});return s(t=>{e.signal(t),t===T&&(f=[])}),()=>{f=[],e.unsubscribe()}},{initial:[]});return g.register(u,{kind:"toArray"}),u}}function Je(n){return u=>{let m=b(({emit:p,error:l,complete:s,onSignal:f})=>{let e=k(u.get()),t=!1,i=null;function r(){e=k(void 0),p(e)}p(e);let o=x(u,a=>{e&&!t&&e.set(a)},{onEnd:a=>{t||(t=!0,i&&(i(A),i=null),a!==void 0?l(a):s())}});return n.source(y,(a,c)=>{if(a===y&&(i=c),a===1&&!t&&r(),a===A){if(i=null,t)return;c!==void 0?(t=!0,o.unsubscribe(),l(c)):(t=!0,o.unsubscribe(),s())}}),f(a=>{o.signal(a),a===T&&(e=null)}),()=>{t=!0,e=null,i&&i(A),i=null,o.unsubscribe()}});return g.register(m,{kind:"window"}),m}}function Qe(n){return u=>{let m=b(({emit:p,error:l,complete:s,onSignal:f})=>{let e=k(u.get()),t=0;p(e);let i=x(u,r=>{e&&(e.set(r),t++,t>=n&&(t=0,e=k(void 0),p(e)))},{onEnd:r=>{e=null,r!==void 0?l(r):s()}});return f(r=>{i.signal(r),r===T&&(e=null)}),()=>{e=null,t=0,i.unsubscribe()}});return g.register(m,{kind:"windowCount"}),m}}function Xe(n){return u=>{let m=b(({emit:p,error:l,complete:s,onSignal:f})=>{let e=k(u.get());p(e);let t=M(n),i=x(t,()=>{e=k(void 0),p(e)}),r=x(u,o=>{e&&e.set(o)},{onEnd:o=>{i.unsubscribe(),e=null,o!==void 0?l(o):s()}});return f(o=>{r.signal(o),o===T&&(e=null,i.unsubscribe())}),()=>{i.unsubscribe(),e=null,r.unsubscribe()}});return g.register(m,{kind:"windowTime"}),m}}function Ze(...n){let u=n[n.length-1],m=n.slice(0,-1);return p=>{let l=[p,...m],s=()=>u(p.get(),...m.map(f=>f.get()));return v(l,({emit:f,signal:e,complete:t,error:i})=>{let r=new I(l.length),o=!1;return(a,c,d)=>{if(c===O)if(d===C){let S=r.empty();r.set(a),S&&(o=!1,e(C))}else d===E?r.test(a)&&(r.clear(a),r.empty()&&(o?f(s()):e(E))):e(d);c===w&&(a===0&&(o=!0),r.test(a)?(r.clear(a),r.empty()&&(o?f(s()):e(E))):a===0?r.empty()&&(e(C),f(s())):r.empty()&&(e(C),e(E))),c===A&&(d!==void 0?i(d):t())}},{kind:"withLatestFrom",name:"withLatestFrom",initial:s(),getter:()=>s()})}}function er(n,u){return u?tr(n,u):rr(n)}function rr(n){let u=b(({emit:m,complete:p,error:l,onSignal:s})=>{let f;return n(y,(e,t)=>{e===y?f=t:e===w?m(t):e===A&&(t!==void 0?l(t):p())}),s(()=>{}),()=>{f?.(A)}});return g.register(u,{kind:"wrap"}),u}function L(n,u){let m;return u((s,f)=>{if(s!==y)return;let e=f;e(y,()=>{}),e(w,n),e(A)})(y,(s,f)=>{s===w&&(m=f)}),m}function tr(n,u){let m=L(n.get(),u);return v([n],({emit:p,signal:l,complete:s,error:f})=>{let e=null;return u((r,o)=>{if(r!==y)return;let a=o;e=a,a(y,c=>{c===A&&(e=null)})})(y,(r,o)=>{r===y||(r===w?p(o):r===A&&(o!==void 0?f(o):s()))}),(r,o,a)=>{o===O?l(a):o===w?e?.(w,a):o===A&&(e?e(A,a):a!==void 0?f(a):s())}},{kind:"wrap",initial:m,getter:()=>L(n.get(),u)})}export{ce as SKIP,Pe as TimeoutError,We as audit,F as buffer,_e as bufferCount,K as bufferTime,Le as cached,V as combine,j as concat,q as concatMap,N as debounce,z as delay,U as distinctUntilChanged,Y as elementAt,$ as empty,H as exhaustMap,G as filter,J as find,Q as first,ne as firstValueFrom,X as flat,Z as forEach,ie as fromAny,Ve as fromAsyncIter,je as fromCron,ee as fromEvent,re as fromIter,te as fromObs,oe as fromPromise,qe as fromTimer,Ne as fromTrigger,ze as groupBy,M as interval,fe as last,ue as map,P as matchesCron,se as merge,le as never,ae as of,me as pairwise,B as parseCron,pe as partition,Ye as pausable,de as pipeRaw,$e as race,He as reduce,be as remember,Se as repeat,Ae as rescue,ge as route,xe as sample,ye as scan,Te as share,we as skip,he as startWith,ke as streamParse,Ee as subject,x as subscribe,Oe as switchMap,Ce as take,ve as takeUntil,Ie as takeWhile,Re as tap,De as throttle,Be as throwError,Me as timeout,Ge as toArray,Je as window,Qe as windowCount,Xe as windowTime,Ze as withLatestFrom,er as wrap};
|
|
1
|
+
import{a as Pe}from"../chunk-W7A67MEA.js";import{a as We,b as _e}from"../chunk-7BXTCJFE.js";import{a as v,b as M,c as ie}from"../chunk-2QHNHL5Y.js";import{a as fe,b as ue,c as ge}from"../chunk-I3EB4ACM.js";import{a as ne}from"../chunk-QSFTSBDR.js";import{a as Ce}from"../chunk-4RCV2AVX.js";import{a as Ie}from"../chunk-RWOVH7KX.js";import{a as Re}from"../chunk-CNTT2H6Y.js";import{a as De}from"../chunk-JTNG3QAI.js";import{a as Be}from"../chunk-JVKWUVKQ.js";import{a as ve}from"../chunk-VEJRX4GP.js";import{a as Me}from"../chunk-OA7V2X54.js";import{a as xe}from"../chunk-WEPYOEEV.js";import{a as ye}from"../chunk-E2AW7OYE.js";import{a as Te}from"../chunk-35BBDNSG.js";import{a as we}from"../chunk-4CA73RLN.js";import{a as he}from"../chunk-22CAZLO3.js";import{a as ke}from"../chunk-VWMY3GUZ.js";import{a as Ee}from"../chunk-ODNVGOOO.js";import{a as Oe}from"../chunk-EV5DA5VJ.js";import{a as le}from"../chunk-3VEB4GWB.js";import{a as ae}from"../chunk-SWGLEZSU.js";import{a as me}from"../chunk-ABE7NDDH.js";import{a as pe}from"../chunk-LQ4T5H3N.js";import{a as ce}from"../chunk-F5UMSRLI.js";import{a as be}from"../chunk-6QFOVQRL.js";import{a as Se,b as de}from"../chunk-QX7UQF6F.js";import{a as Ae}from"../chunk-GI7IGLWO.js";import{a as Z}from"../chunk-5WFSQQDI.js";import{a as ee}from"../chunk-22FZRVAU.js";import{a as re}from"../chunk-TLLIQ7WA.js";import{a as te}from"../chunk-UVORPAQM.js";import{a as oe}from"../chunk-LHEDPW3C.js";import{a as P}from"../chunk-JW2KZLSD.js";import{a as se}from"../chunk-VFXNSORS.js";import{a as U}from"../chunk-YXMKE3MO.js";import{a as Y}from"../chunk-HHJFEHV3.js";import{a as $}from"../chunk-HTZLRRTE.js";import{a as H}from"../chunk-54BT6MU4.js";import{a as G}from"../chunk-SFO5COGM.js";import{a as J}from"../chunk-5JSJZFLR.js";import{a as Q}from"../chunk-5I4THZPQ.js";import{a as X}from"../chunk-3TGYRIQB.js";import{a as K}from"../chunk-A4HLU3K4.js";import{a as L}from"../chunk-OGDTSFTW.js";import{a as j}from"../chunk-ODEEQ7UH.js";import{a as V}from"../chunk-PKAASLJ7.js";import{a as N}from"../chunk-TPKLTDRR.js";import{a as q}from"../chunk-KJW2EGU5.js";import{a as z}from"../chunk-FLKDEQGB.js";import"../chunk-XFA2D6KP.js";import{a as I}from"../chunk-YBVQC3GP.js";import"../chunk-PV347CGV.js";import{a as R}from"../chunk-HK7DRUNM.js";import"../chunk-LLARZ7J7.js";import{a as y}from"../chunk-GMLWTZFM.js";import{a as k}from"../chunk-EAK2HKAD.js";import{i as d}from"../chunk-2F6QWERG.js";import{a as x}from"../chunk-2L6223KN.js";import{a as C,b as E,d as T,e as D,f as B,r as g,s as w,t as A,u as O,y as W,z as _}from"../chunk-TUPD47IE.js";import"../chunk-I7AUKTXE.js";function Fe(i){return s=>{let m=d(({emit:p,error:a,complete:l,onSignal:f})=>{let e=null,t,n=!1,r;return f(o=>{r.signal(o),o===T&&(e!==null&&(clearTimeout(e),e=null),n=!1,t=void 0)}),r=y(s,o=>{t=o,n=!0,e===null&&(e=setTimeout(()=>{e=null,n&&(n=!1,p(t))},i))},{onEnd:o=>{e!==null&&(clearTimeout(e),e=null),o!==void 0?a(o):(n&&(n=!1,p(t)),l())}}),()=>{e!==null&&(clearTimeout(e),e=null),n=!1,r.unsubscribe()}});return x.register(m,{kind:"audit"}),m}}function Ke(i,s){return m=>{let p=d(({emit:a,error:l,complete:f,onSignal:e})=>{if(s!==void 0&&s>0){let r=[],o=0,u=y(m,c=>{o%s===0&&r.push([]),o++;for(let S of r)S.push(c);let b=[];r=r.filter(S=>S.length>=i?(b.push(S),!1):!0);for(let S of b)Object.freeze(S),a(S)},{onEnd:c=>{if(c!==void 0)r=[],l(c);else{let b=r;r=[];for(let S of b)S.length>0&&(Object.freeze(S),a(S));f()}}});return e(c=>{u.signal(c),c===T&&(r=[],o=0)}),()=>{r=[],u.unsubscribe()}}let t=[],n=y(m,r=>{if(t.push(r),t.length>=i){let o=t;Object.freeze(o),t=[],a(o)}},{onEnd:r=>{if(r!==void 0)t=[],l(r);else{if(t.length>0){let o=t;Object.freeze(o),t=[],a(o)}f()}}});return e(r=>{n.signal(r),r===T&&(t=[])}),()=>{t=[],n.unsubscribe()}},{initial:[]});return x.register(p,{kind:"bufferCount"}),p}}function Le(...i){return Array.isArray(i[0])?je(i[0],i[1],i[2]):Ve(i[0])}function je(i,s,m){let p=m?.equals,a=new Array(i.length),l,f=!1;l=s(),f=!0;for(let e=0;e<i.length;e++)a[e]=i[e].get();return I(i,({emit:e,signal:t,complete:n,error:r})=>{let o=new R(i.length),u=!1;function c(){let b=s();for(let S=0;S<i.length;S++)a[S]=i[S].get();p&&f&&p(l,b)?t(E):(l=b,f=!0,e(b))}return(b,S,h)=>{S===O&&(h===C?(o.empty()&&(u=!1),o.set(b)):h===E&&o.test(b)&&(o.clear(b),o.empty()&&(u?c():t(E))),t(h)),S===w&&(o.test(b)?(o.clear(b),u=!0,o.empty()&&c()):o.empty()?c():u=!0),S===A&&(h!==void 0?r(h):n())}},{...m,kind:"cached",initial:l,getter:()=>{if(f){let t=!0;for(let n=0;n<i.length;n++)if(!Object.is(i[n].get(),a[n])){t=!1;break}if(t)return l}let e=s();for(let t=0;t<i.length;t++)a[t]=i[t].get();return l=e,f=!0,e}})}function Ve(i){return s=>{let m=i??Object.is,p=s.get();return I([s],({emit:a,signal:l,complete:f,error:e})=>(t,n,r)=>{n===O&&l(r),n===w&&(m(p,r)?l(E):(p=r,a(r))),n===A&&(r!==void 0?e(r):f())},{kind:"cached",initial:p,getter:()=>{let a=s.get();return m(p,a)?p:(p=a,a)}})}}function Ne(i){let s=d(({emit:m,complete:p,error:a})=>{let l=new AbortController,f=l.signal,e=!1,n=(typeof i=="function"?i():i)[Symbol.asyncIterator]();async function r(){try{for(;!e&&!f.aborted;){let o=await n.next();if(e||f.aborted)break;if(o.done){p();return}m(o.value)}}catch(o){!e&&!f.aborted&&a(o)}}return r(),()=>{e=!0,l.abort(),Promise.resolve(n.return?.()).catch(()=>{})}},{resubscribable:!0});return x.register(s,{kind:"fromAsyncIter"}),s}function qe(i,s){let m=v(i),p=s?.tickMs??6e4;return d(({emit:a})=>{let l=-1,f=()=>{let t=new Date,n=t.getFullYear()*1e8+(t.getMonth()+1)*1e6+t.getDate()*1e4+t.getHours()*100+t.getMinutes();n!==l&&M(m,t)&&(l=n,a(t))};f();let e=setInterval(f,p);return()=>clearInterval(e)},{name:s?.id??`cron:${i}`})}function ze(i){return s=>{let m=d(({emit:p,error:a,complete:l,onSignal:f})=>{let e=new Map,t=new Map,n=y(s,r=>{let o;try{o=i(r)}catch(b){a(b);return}let u=e.get(o),c=!1;u?u.set(r):(u=k(r),e.set(o,u),c=!0),c&&(t=new Map(e),p(t))},{onEnd:r=>{r!==void 0?a(r):l()}});return f(r=>{n.signal(r),r===T&&(e.clear(),t=new Map)}),()=>{e.clear(),t=new Map,n.unsubscribe()}},{initial:new Map});return x.register(m,{kind:"groupBy"}),m}}var Ue=0;function Ye(i){return s=>{let m=k(!1,{name:`${i?.name??"pausable"}:paused`}),p=s.get(),a=!1,l=null,f=null,e=null,n=I([s],({emit:r,signal:o,complete:u,error:c})=>(f=o,e=r,(b,S,h)=>{if(S===O){h===D?a||(a=!0,m.set(!0)):h===B&&a&&l===null&&(a=!1,m.set(!1),o(C),r(p)),o(h);return}if(S===w){p=h,a?o(E):r(h);return}S===A&&(h!==void 0?c(h):u())}),{kind:"pausable",name:i?.name??"pausable",initial:s.get(),equals:i?.equals,getter:()=>s.get()});return n.pause=()=>(a&&l!==null||(a=!0,l=`pause-${++Ue}`,m.set(!0),f?.(D)),l),n.resume=r=>{!a||l!==r||(a=!1,l=null,m.set(!1),f?.(B),f&&f(C),e?.(p))},Object.defineProperty(n,"paused",{get:()=>m,enumerable:!0}),n}}function $e(...i){let s=d(({emit:m,error:p,complete:a,onSignal:l})=>{if(i.length===0){a();return}let f=-1,e=!1,t=0,n=new Array(i.length).fill(null);function r(o){for(let u=0;u<n.length;u++)u!==o&&n[u]&&(n[u](A),n[u]=null)}W();for(let o=0;o<i.length;o++){let u=o;i[u].source(g,(c,b)=>{if(c===g){n[u]=b,f!==-1&&f!==u&&(n[u](A),n[u]=null);return}if(c===1){if(e)return;f===-1&&(f=u,r(u)),f===u&&m(b)}if(c===A){if(n[u]=null,e)return;b!==void 0?(f===-1||f===u)&&(e=!0,r(-1),p(b)):f===u?(e=!0,a()):f===-1&&(t++,t===i.length&&(e=!0,a()))}})}return _(),l(o=>{for(let u of n)u&&u(O,o)}),()=>{e=!0,r(-1)}},{resubscribable:!0});return x.register(s,{kind:"race"}),s}function He(i,s){return m=>{let p=d(({emit:a,error:l,complete:f})=>{let e=s,t=y(m,n=>{e=i(e,n)},{onEnd:n=>{n!==void 0?l(n):(a(e),f())}});return()=>{t.unsubscribe()}},{initial:s});return x.register(p,{kind:"reduce"}),p}}function Ge(){return i=>{let s=d(({emit:m,error:p,complete:a,onSignal:l})=>{let f=[],e=y(i,t=>{f.push(t)},{onEnd:t=>{if(t!==void 0)f=[],p(t);else{let n=f;Object.freeze(n),f=[],m(n),a()}}});return l(t=>{e.signal(t),t===T&&(f=[])}),()=>{f=[],e.unsubscribe()}},{initial:[]});return x.register(s,{kind:"toArray"}),s}}function Je(i){return s=>{let m=d(({emit:p,error:a,complete:l,onSignal:f})=>{let e=k(s.get()),t=!1,n=null;function r(){e=k(void 0),p(e)}p(e);let o=y(s,u=>{e&&!t&&e.set(u)},{onEnd:u=>{t||(t=!0,n&&(n(A),n=null),u!==void 0?a(u):l())}});return i.source(g,(u,c)=>{if(u===g&&(n=c),u===1&&!t&&r(),u===A){if(n=null,t)return;c!==void 0?(t=!0,o.unsubscribe(),a(c)):(t=!0,o.unsubscribe(),l())}}),f(u=>{o.signal(u),u===T&&(e=null)}),()=>{t=!0,e=null,n&&n(A),n=null,o.unsubscribe()}});return x.register(m,{kind:"window"}),m}}function Qe(i){return s=>{let m=d(({emit:p,error:a,complete:l,onSignal:f})=>{let e=k(s.get()),t=0;p(e);let n=y(s,r=>{e&&(e.set(r),t++,t>=i&&(t=0,e=k(void 0),p(e)))},{onEnd:r=>{e=null,r!==void 0?a(r):l()}});return f(r=>{n.signal(r),r===T&&(e=null)}),()=>{e=null,t=0,n.unsubscribe()}});return x.register(m,{kind:"windowCount"}),m}}function Xe(i){return s=>{let m=d(({emit:p,error:a,complete:l,onSignal:f})=>{let e=k(s.get());p(e);let t=P(i),n=y(t,()=>{e=k(void 0),p(e)}),r=y(s,o=>{e&&e.set(o)},{onEnd:o=>{n.unsubscribe(),e=null,o!==void 0?a(o):l()}});return f(o=>{r.signal(o),o===T&&(e=null,n.unsubscribe())}),()=>{n.unsubscribe(),e=null,r.unsubscribe()}});return x.register(m,{kind:"windowTime"}),m}}function Ze(...i){let s=i[i.length-1],m=i.slice(0,-1);return p=>{let a=[p,...m],l=()=>s(p.get(),...m.map(f=>f.get()));return I(a,({emit:f,signal:e,complete:t,error:n})=>{let r=new R(a.length),o=!1;return(u,c,b)=>{if(c===O)if(b===C){let S=r.empty();r.set(u),S&&(o=!1,e(C))}else b===E?r.test(u)&&(r.clear(u),r.empty()&&(o?f(l()):e(E))):e(b);c===w&&(u===0&&(o=!0),r.test(u)?(r.clear(u),r.empty()&&(o?f(l()):e(E))):u===0?r.empty()&&(e(C),f(l())):r.empty()&&(e(C),e(E))),c===A&&(b!==void 0?n(b):t())}},{kind:"withLatestFrom",name:"withLatestFrom",initial:l(),getter:()=>l()})}}function er(i,s){return s?tr(i,s):rr(i)}function rr(i){let s=d(({emit:m,complete:p,error:a,onSignal:l})=>{let f;return i(g,(e,t)=>{e===g?f=t:e===w?m(t):e===A&&(t!==void 0?a(t):p())}),l(()=>{}),()=>{f?.(A)}});return x.register(s,{kind:"wrap"}),s}function F(i,s){let m;return s((l,f)=>{if(l!==g)return;let e=f;e(g,()=>{}),e(w,i),e(A)})(g,(l,f)=>{l===w&&(m=f)}),m}function tr(i,s){let m=F(i.get(),s);return I([i],({emit:p,signal:a,complete:l,error:f})=>{let e=null;return s((r,o)=>{if(r!==g)return;let u=o;e=u,u(g,c=>{c===A&&(e=null)})})(g,(r,o)=>{r===g||(r===w?p(o):r===A&&(o!==void 0?f(o):l()))}),(r,o,u)=>{o===O?a(u):o===w?e?.(w,u):o===A&&(e?e(A,u):u!==void 0?f(u):l())}},{kind:"wrap",initial:m,getter:()=>F(i.get(),s)})}export{Se as SKIP,We as TimeoutError,Fe as audit,K as buffer,Ke as bufferCount,L as bufferTime,Le as cached,j as combine,V as concat,N as concatMap,q as debounce,z as delay,U as distinctUntilChanged,Y as elementAt,$ as empty,H as exhaustMap,G as filter,J as find,Q as first,ne as firstValueFrom,X as flat,Z as forEach,ie as fromAny,Ne as fromAsyncIter,qe as fromCron,ee as fromEvent,re as fromIter,te as fromObs,oe as fromPromise,fe as fromTimer,ue as fromTrigger,ze as groupBy,P as interval,se as last,le as map,M as matchesCron,ae as merge,me as never,pe as of,ce as pairwise,v as parseCron,be as partition,Ye as pausable,de as pipeRaw,$e as race,He as reduce,Ae as remember,xe as repeat,ye as rescue,ge as route,Te as sample,we as scan,he as share,ke as skip,Ee as startWith,Oe as streamParse,Ce as subject,y as subscribe,Ie as switchMap,Re as take,De as takeUntil,Be as takeWhile,ve as tap,Me as throttle,Pe as throwError,_e as timeout,Ge as toArray,Je as window,Qe as windowCount,Xe as windowTime,Ze as withLatestFrom,er as wrap};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { S as Store } from './types-BohB8jJr.cjs';
|
|
2
|
+
|
|
3
|
+
interface TriggerStore<T> extends Store<T | undefined> {
|
|
4
|
+
/** Emit a value to all subscribers. */
|
|
5
|
+
fire(value: T): void;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Creates a manual trigger source. `.fire(value)` emits into the stream without equality dedup.
|
|
9
|
+
*
|
|
10
|
+
* @param opts - Optional configuration.
|
|
11
|
+
*
|
|
12
|
+
* @returns `TriggerStore<T>` — a store with:
|
|
13
|
+
*
|
|
14
|
+
* @returnsTable get() | () => T \| undefined | Last fired value (or initial).
|
|
15
|
+
* fire(value) | (value: T) => void | Emit a value to all subscribers.
|
|
16
|
+
* source | callbag | Underlying callbag source for subscriptions.
|
|
17
|
+
*
|
|
18
|
+
* @option name | string | undefined | Debug name for Inspector.
|
|
19
|
+
* @option initial | T | undefined | Value before first fire().
|
|
20
|
+
*
|
|
21
|
+
* @remarks **No dedup:** Every `fire()` call emits, even if the value is the same as the previous one.
|
|
22
|
+
* @remarks **Pulse semantics:** Backed by producer() — an event source, not persistent state.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* import { fromTrigger } from 'callbag-recharge/orchestrate';
|
|
27
|
+
* import { subscribe } from 'callbag-recharge';
|
|
28
|
+
*
|
|
29
|
+
* const trigger = fromTrigger<string>();
|
|
30
|
+
* subscribe(trigger, v => console.log(v));
|
|
31
|
+
* trigger.fire("go"); // logs "go"
|
|
32
|
+
* trigger.fire("go"); // logs "go" again
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @seeAlso [producer](./producer) — general-purpose source
|
|
36
|
+
*
|
|
37
|
+
* @category orchestrate
|
|
38
|
+
*/
|
|
39
|
+
declare function fromTrigger<T>(opts?: {
|
|
40
|
+
initial?: T;
|
|
41
|
+
name?: string;
|
|
42
|
+
}): TriggerStore<T>;
|
|
43
|
+
|
|
44
|
+
export { type TriggerStore as T, fromTrigger as f };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { S as Store } from './types-CB1htCM8.js';
|
|
2
|
+
|
|
3
|
+
interface TriggerStore<T> extends Store<T | undefined> {
|
|
4
|
+
/** Emit a value to all subscribers. */
|
|
5
|
+
fire(value: T): void;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Creates a manual trigger source. `.fire(value)` emits into the stream without equality dedup.
|
|
9
|
+
*
|
|
10
|
+
* @param opts - Optional configuration.
|
|
11
|
+
*
|
|
12
|
+
* @returns `TriggerStore<T>` — a store with:
|
|
13
|
+
*
|
|
14
|
+
* @returnsTable get() | () => T \| undefined | Last fired value (or initial).
|
|
15
|
+
* fire(value) | (value: T) => void | Emit a value to all subscribers.
|
|
16
|
+
* source | callbag | Underlying callbag source for subscriptions.
|
|
17
|
+
*
|
|
18
|
+
* @option name | string | undefined | Debug name for Inspector.
|
|
19
|
+
* @option initial | T | undefined | Value before first fire().
|
|
20
|
+
*
|
|
21
|
+
* @remarks **No dedup:** Every `fire()` call emits, even if the value is the same as the previous one.
|
|
22
|
+
* @remarks **Pulse semantics:** Backed by producer() — an event source, not persistent state.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* import { fromTrigger } from 'callbag-recharge/orchestrate';
|
|
27
|
+
* import { subscribe } from 'callbag-recharge';
|
|
28
|
+
*
|
|
29
|
+
* const trigger = fromTrigger<string>();
|
|
30
|
+
* subscribe(trigger, v => console.log(v));
|
|
31
|
+
* trigger.fire("go"); // logs "go"
|
|
32
|
+
* trigger.fire("go"); // logs "go" again
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @seeAlso [producer](./producer) — general-purpose source
|
|
36
|
+
*
|
|
37
|
+
* @category orchestrate
|
|
38
|
+
*/
|
|
39
|
+
declare function fromTrigger<T>(opts?: {
|
|
40
|
+
initial?: T;
|
|
41
|
+
name?: string;
|
|
42
|
+
}): TriggerStore<T>;
|
|
43
|
+
|
|
44
|
+
export { type TriggerStore as T, fromTrigger as f };
|