@vanyamate/sec 0.3.1-batch-beta.3 → 0.3.1-batch-beta.4
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/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +111 -109
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let d=0,
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let d=0,E=new Map;const S=()=>d+=1,k=()=>{d-=1,m()&&B()},m=()=>d===0,p=(o,t)=>{S(),E.set(o,t),queueMicrotask(k)},B=()=>{E.forEach(o=>o()),E.clear()},i=function(o,t){o&&t()},w=function(o,t={enabled:!0,instantListenerExecution:!1}){const f=new Set;let s=o,{enabled:c=!0,instantListenerExecution:l=!1}=t;const r={on:(e,n,u)=>(n==="onBefore"?e.onBefore((...a)=>i(c,()=>r.set(u(o,{args:a})))):n==="onSuccess"?e.onSuccess((a,...b)=>i(c,()=>r.set(u(o,{result:a,args:b})))):n==="onError"?e.onError((a,...b)=>i(c,()=>r.set(u(o,{error:a,args:b})))):e.onFinally((...a)=>i(c,()=>r.set(u(o,{args:a})))),r),get(){return o},set(e){o=e,p(this,()=>{s!==o&&(s=o,f.forEach(n=>n(o)))})},subscribe(e){return f.add(e),l&&e(o),()=>f.delete(e)},enableOn(e,n){return e.subscribe(()=>{c=!0,n!==void 0&&r.set(n)}),r},disableOn(e,n){return e.subscribe(()=>{c=!1,n!==void 0&&r.set(n)}),r}};return r},h=function(){return{afterAll:[],beforeAll:[],other:[]}},y=function(o){const t=h(),f=h(),s=h(),c=h(),l=async function(...r){return t.beforeAll.forEach(e=>e(...r)),t.other.forEach(e=>e(...r)),t.afterAll.forEach(e=>e(...r)),o(...r).then(e=>(f.beforeAll.forEach(n=>n(e,...r)),f.other.forEach(n=>n(e,...r)),f.afterAll.forEach(n=>n(e,...r)),e)).catch(e=>{throw s.beforeAll.forEach(n=>n(e,...r)),s.other.forEach(n=>n(e,...r)),s.afterAll.forEach(n=>n(e,...r)),e}).finally(()=>{c.beforeAll.forEach(e=>e(...r)),c.other.forEach(e=>e(...r)),c.afterAll.forEach(e=>e(...r))})};return l.onBefore=(r,e)=>{switch(e){case"beforeAll":t.beforeAll.push(r);break;case"afterAll":t.afterAll.push(r);break;default:t.other.push(r)}},l.onSuccess=(r,e)=>{switch(e){case"beforeAll":f.beforeAll.push(r);break;case"afterAll":f.afterAll.push(r);break;default:f.other.push(r)}},l.onError=(r,e)=>{switch(e){case"beforeAll":s.beforeAll.push(r);break;case"afterAll":s.afterAll.push(r);break;default:s.other.push(r)}},l.onFinally=(r,e)=>{switch(e){case"beforeAll":c.beforeAll.push(r);break;case"afterAll":c.afterAll.push(r);break;default:c.other.push(r)}},l},C=function(o,t,f={enabled:!0,instantListenerExecution:!1}){let s,c;s=c=t(o);const l=new Set;let{enabled:r=!0,instantListenerExecution:e=!1}=f;o.forEach(u=>{u.subscribe(()=>{i(r,()=>{p(n,()=>{s=t(o),s!==c&&(c=s,l.forEach(a=>a(s)))})})})});const n={on:()=>{throw new Error("Cannot call 'on' on combined store")},get(){return s},set(){throw new Error("Cannot call 'set' on combined store")},subscribe(u){return l.add(u),e&&u(s),()=>l.delete(u)},enableOn(u){return u.subscribe(()=>r=!0),n},disableOn(u){return u.subscribe(()=>r=!1),n}};return n},F=function(o){const t=[],f={on:(s,c)=>(s==="onBefore"?c.onBefore(()=>t.forEach(l=>l()),o):s==="onSuccess"?c.onSuccess(()=>t.forEach(l=>l()),o):s==="onError"?c.onError(()=>t.forEach(l=>l()),o):c.onFinally(()=>t.forEach(l=>l()),o),f),subscribe:s=>{t.push(s)}};return f},A=function(o){return()=>o},L=function(o){const t=w(!1);return o.forEach(f=>{t.on(f,"onBefore",A(!0)),t.on(f,"onFinally",A(!1))}),t},x=function(){return(o,{result:t})=>t};exports.combine=C;exports.effect=y;exports.enableCheck=i;exports.marker=F;exports.pending=L;exports.result=x;exports.store=w;exports.to=A;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const combine: <State, States extends Array<any>>(stores: { [Index in keyof States]: Store<States[Index]>; }, callback: (stores: { [K in keyof States]: Store<States[K]>; }) => State,
|
|
1
|
+
export declare const combine: <State, States extends Array<any>>(stores: { [Index in keyof States]: Store<States[Index]>; }, callback: (stores: { [K in keyof States]: Store<States[K]>; }) => State, options?: StoreOptions) => Store<State>;
|
|
2
2
|
|
|
3
3
|
export declare type Effect<AsyncAction extends EffectAction> = {
|
|
4
4
|
(...args: Parameters<AsyncAction>): Promise<Awaited<ReturnType<AsyncAction>>>;
|
package/dist/index.js
CHANGED
|
@@ -1,191 +1,193 @@
|
|
|
1
|
-
let
|
|
2
|
-
const w = () =>
|
|
3
|
-
|
|
4
|
-
}, S = () =>
|
|
5
|
-
w(),
|
|
1
|
+
let A = 0, E = /* @__PURE__ */ new Map();
|
|
2
|
+
const w = () => A += 1, B = () => {
|
|
3
|
+
A -= 1, S() && k();
|
|
4
|
+
}, S = () => A === 0, p = (o, t) => {
|
|
5
|
+
w(), E.set(o, t), queueMicrotask(B);
|
|
6
6
|
}, k = () => {
|
|
7
|
-
|
|
8
|
-
},
|
|
9
|
-
o &&
|
|
10
|
-
}, C = function(o,
|
|
11
|
-
const
|
|
12
|
-
let
|
|
13
|
-
const
|
|
14
|
-
on: (
|
|
15
|
-
(...
|
|
16
|
-
|
|
17
|
-
() =>
|
|
18
|
-
|
|
7
|
+
E.forEach((o) => o()), E.clear();
|
|
8
|
+
}, i = function(o, t) {
|
|
9
|
+
o && t();
|
|
10
|
+
}, C = function(o, t = { enabled: !0, instantListenerExecution: !1 }) {
|
|
11
|
+
const f = /* @__PURE__ */ new Set();
|
|
12
|
+
let s = o, { enabled: c = !0, instantListenerExecution: l = !1 } = t;
|
|
13
|
+
const r = {
|
|
14
|
+
on: (e, n, u) => (n === "onBefore" ? e.onBefore(
|
|
15
|
+
(...a) => i(
|
|
16
|
+
c,
|
|
17
|
+
() => r.set(
|
|
18
|
+
u(o, { args: a })
|
|
19
19
|
)
|
|
20
20
|
)
|
|
21
|
-
) :
|
|
22
|
-
(
|
|
23
|
-
|
|
24
|
-
() =>
|
|
25
|
-
|
|
26
|
-
result:
|
|
21
|
+
) : n === "onSuccess" ? e.onSuccess(
|
|
22
|
+
(a, ...b) => i(
|
|
23
|
+
c,
|
|
24
|
+
() => r.set(
|
|
25
|
+
u(o, {
|
|
26
|
+
result: a,
|
|
27
27
|
args: b
|
|
28
28
|
})
|
|
29
29
|
)
|
|
30
30
|
)
|
|
31
|
-
) :
|
|
32
|
-
(
|
|
33
|
-
|
|
34
|
-
() =>
|
|
35
|
-
|
|
36
|
-
error:
|
|
31
|
+
) : n === "onError" ? e.onError(
|
|
32
|
+
(a, ...b) => i(
|
|
33
|
+
c,
|
|
34
|
+
() => r.set(
|
|
35
|
+
u(o, {
|
|
36
|
+
error: a,
|
|
37
37
|
args: b
|
|
38
38
|
})
|
|
39
39
|
)
|
|
40
40
|
)
|
|
41
|
-
) :
|
|
42
|
-
(...
|
|
43
|
-
|
|
44
|
-
() =>
|
|
45
|
-
|
|
41
|
+
) : e.onFinally(
|
|
42
|
+
(...a) => i(
|
|
43
|
+
c,
|
|
44
|
+
() => r.set(
|
|
45
|
+
u(o, { args: a })
|
|
46
46
|
)
|
|
47
47
|
)
|
|
48
|
-
),
|
|
48
|
+
), r),
|
|
49
49
|
get() {
|
|
50
50
|
return o;
|
|
51
51
|
},
|
|
52
|
-
set(
|
|
53
|
-
o =
|
|
54
|
-
|
|
52
|
+
set(e) {
|
|
53
|
+
o = e, p(this, () => {
|
|
54
|
+
s !== o && (s = o, f.forEach((n) => n(o)));
|
|
55
55
|
});
|
|
56
56
|
},
|
|
57
|
-
subscribe(
|
|
58
|
-
return
|
|
57
|
+
subscribe(e) {
|
|
58
|
+
return f.add(e), l && e(o), () => f.delete(e);
|
|
59
59
|
},
|
|
60
|
-
enableOn(
|
|
61
|
-
return
|
|
62
|
-
|
|
63
|
-
}),
|
|
60
|
+
enableOn(e, n) {
|
|
61
|
+
return e.subscribe(() => {
|
|
62
|
+
c = !0, n !== void 0 && r.set(n);
|
|
63
|
+
}), r;
|
|
64
64
|
},
|
|
65
|
-
disableOn(
|
|
66
|
-
return
|
|
67
|
-
|
|
68
|
-
}),
|
|
65
|
+
disableOn(e, n) {
|
|
66
|
+
return e.subscribe(() => {
|
|
67
|
+
c = !1, n !== void 0 && r.set(n);
|
|
68
|
+
}), r;
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
|
-
return
|
|
72
|
-
},
|
|
71
|
+
return r;
|
|
72
|
+
}, h = function() {
|
|
73
73
|
return {
|
|
74
74
|
afterAll: [],
|
|
75
75
|
beforeAll: [],
|
|
76
76
|
other: []
|
|
77
77
|
};
|
|
78
78
|
}, m = function(o) {
|
|
79
|
-
const
|
|
80
|
-
return
|
|
81
|
-
throw
|
|
79
|
+
const t = h(), f = h(), s = h(), c = h(), l = async function(...r) {
|
|
80
|
+
return t.beforeAll.forEach((e) => e(...r)), t.other.forEach((e) => e(...r)), t.afterAll.forEach((e) => e(...r)), o(...r).then((e) => (f.beforeAll.forEach((n) => n(e, ...r)), f.other.forEach((n) => n(e, ...r)), f.afterAll.forEach((n) => n(e, ...r)), e)).catch((e) => {
|
|
81
|
+
throw s.beforeAll.forEach((n) => n(e, ...r)), s.other.forEach((n) => n(e, ...r)), s.afterAll.forEach((n) => n(e, ...r)), e;
|
|
82
82
|
}).finally(() => {
|
|
83
|
-
|
|
83
|
+
c.beforeAll.forEach((e) => e(...r)), c.other.forEach((e) => e(...r)), c.afterAll.forEach((e) => e(...r));
|
|
84
84
|
});
|
|
85
85
|
};
|
|
86
|
-
return
|
|
87
|
-
switch (
|
|
86
|
+
return l.onBefore = (r, e) => {
|
|
87
|
+
switch (e) {
|
|
88
88
|
case "beforeAll":
|
|
89
|
-
|
|
89
|
+
t.beforeAll.push(r);
|
|
90
90
|
break;
|
|
91
91
|
case "afterAll":
|
|
92
|
-
|
|
92
|
+
t.afterAll.push(r);
|
|
93
93
|
break;
|
|
94
94
|
default:
|
|
95
|
-
|
|
95
|
+
t.other.push(r);
|
|
96
96
|
}
|
|
97
|
-
},
|
|
98
|
-
switch (
|
|
97
|
+
}, l.onSuccess = (r, e) => {
|
|
98
|
+
switch (e) {
|
|
99
99
|
case "beforeAll":
|
|
100
|
-
|
|
100
|
+
f.beforeAll.push(r);
|
|
101
101
|
break;
|
|
102
102
|
case "afterAll":
|
|
103
|
-
|
|
103
|
+
f.afterAll.push(r);
|
|
104
104
|
break;
|
|
105
105
|
default:
|
|
106
|
-
|
|
106
|
+
f.other.push(r);
|
|
107
107
|
}
|
|
108
|
-
},
|
|
109
|
-
switch (
|
|
108
|
+
}, l.onError = (r, e) => {
|
|
109
|
+
switch (e) {
|
|
110
110
|
case "beforeAll":
|
|
111
|
-
|
|
111
|
+
s.beforeAll.push(r);
|
|
112
112
|
break;
|
|
113
113
|
case "afterAll":
|
|
114
|
-
|
|
114
|
+
s.afterAll.push(r);
|
|
115
115
|
break;
|
|
116
116
|
default:
|
|
117
|
-
|
|
117
|
+
s.other.push(r);
|
|
118
118
|
}
|
|
119
|
-
},
|
|
120
|
-
switch (
|
|
119
|
+
}, l.onFinally = (r, e) => {
|
|
120
|
+
switch (e) {
|
|
121
121
|
case "beforeAll":
|
|
122
|
-
|
|
122
|
+
c.beforeAll.push(r);
|
|
123
123
|
break;
|
|
124
124
|
case "afterAll":
|
|
125
|
-
|
|
125
|
+
c.afterAll.push(r);
|
|
126
126
|
break;
|
|
127
127
|
default:
|
|
128
|
-
|
|
128
|
+
c.other.push(r);
|
|
129
129
|
}
|
|
130
|
-
},
|
|
131
|
-
}, y = function(o,
|
|
132
|
-
let
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
130
|
+
}, l;
|
|
131
|
+
}, y = function(o, t, f = { enabled: !0, instantListenerExecution: !1 }) {
|
|
132
|
+
let s, c;
|
|
133
|
+
s = c = t(o);
|
|
134
|
+
const l = /* @__PURE__ */ new Set();
|
|
135
|
+
let { enabled: r = !0, instantListenerExecution: e = !1 } = f;
|
|
136
|
+
o.forEach((u) => {
|
|
137
|
+
u.subscribe(() => {
|
|
138
|
+
i(r, () => {
|
|
139
|
+
p(n, () => {
|
|
140
|
+
s = t(o), s !== c && (c = s, l.forEach((a) => a(s)));
|
|
139
141
|
});
|
|
140
142
|
});
|
|
141
143
|
});
|
|
142
144
|
});
|
|
143
|
-
const
|
|
145
|
+
const n = {
|
|
144
146
|
on: () => {
|
|
145
147
|
throw new Error("Cannot call 'on' on combined store");
|
|
146
148
|
},
|
|
147
149
|
get() {
|
|
148
|
-
return
|
|
150
|
+
return s;
|
|
149
151
|
},
|
|
150
152
|
set() {
|
|
151
153
|
throw new Error("Cannot call 'set' on combined store");
|
|
152
154
|
},
|
|
153
|
-
subscribe(
|
|
154
|
-
return
|
|
155
|
+
subscribe(u) {
|
|
156
|
+
return l.add(u), e && u(s), () => l.delete(u);
|
|
155
157
|
},
|
|
156
|
-
enableOn(
|
|
157
|
-
return
|
|
158
|
+
enableOn(u) {
|
|
159
|
+
return u.subscribe(() => r = !0), n;
|
|
158
160
|
},
|
|
159
|
-
disableOn(
|
|
160
|
-
return
|
|
161
|
+
disableOn(u) {
|
|
162
|
+
return u.subscribe(() => r = !1), n;
|
|
161
163
|
}
|
|
162
164
|
};
|
|
163
|
-
return
|
|
164
|
-
},
|
|
165
|
-
const
|
|
166
|
-
on: (
|
|
167
|
-
subscribe: (
|
|
168
|
-
|
|
165
|
+
return n;
|
|
166
|
+
}, x = function(o) {
|
|
167
|
+
const t = [], f = {
|
|
168
|
+
on: (s, c) => (s === "onBefore" ? c.onBefore(() => t.forEach((l) => l()), o) : s === "onSuccess" ? c.onSuccess(() => t.forEach((l) => l()), o) : s === "onError" ? c.onError(() => t.forEach((l) => l()), o) : c.onFinally(() => t.forEach((l) => l()), o), f),
|
|
169
|
+
subscribe: (s) => {
|
|
170
|
+
t.push(s);
|
|
169
171
|
}
|
|
170
172
|
};
|
|
171
|
-
return
|
|
172
|
-
},
|
|
173
|
+
return f;
|
|
174
|
+
}, d = function(o) {
|
|
173
175
|
return () => o;
|
|
174
|
-
},
|
|
175
|
-
const
|
|
176
|
-
return o.forEach((
|
|
177
|
-
|
|
178
|
-
}),
|
|
176
|
+
}, F = function(o) {
|
|
177
|
+
const t = C(!1);
|
|
178
|
+
return o.forEach((f) => {
|
|
179
|
+
t.on(f, "onBefore", d(!0)), t.on(f, "onFinally", d(!1));
|
|
180
|
+
}), t;
|
|
179
181
|
}, L = function() {
|
|
180
|
-
return (o, { result:
|
|
182
|
+
return (o, { result: t }) => t;
|
|
181
183
|
};
|
|
182
184
|
export {
|
|
183
185
|
y as combine,
|
|
184
186
|
m as effect,
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
187
|
+
i as enableCheck,
|
|
188
|
+
x as marker,
|
|
189
|
+
F as pending,
|
|
188
190
|
L as result,
|
|
189
191
|
C as store,
|
|
190
|
-
|
|
192
|
+
d as to
|
|
191
193
|
};
|