nanoeffects 0.27.0 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -24
- package/dist/{action-creator-D_c223C7.d.ts → action-creator-CcAEvUnw.d.ts} +39 -0
- package/dist/actions.d.ts +3 -3
- package/dist/actions.js +1 -1
- package/dist/bus-DlpEluzd.js +1 -0
- package/dist/{context-types-nGtzhjxD.d.ts → context-types-hCKgU8sC.d.ts} +1 -1
- package/dist/context.d.ts +2 -2
- package/dist/dev.d.ts +2 -2
- package/dist/dev.js +1 -1
- package/dist/effects.d.ts +2 -2
- package/dist/event-DVcW0mME.js +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/match.d.ts +1 -1
- package/dist/{module-WX0Gngnt.d.ts → module-C_oEXw1n.d.ts} +2 -2
- package/dist/notrace/{action-creator-Bux7Zzsl.d.ts → action-creator-DxOvVo8I.d.ts} +39 -0
- package/dist/notrace/actions.d.ts +2 -2
- package/dist/notrace/actions.js +1 -1
- package/dist/notrace/bus-DmKn4SDD.js +1 -0
- package/dist/notrace/effects.d.ts +2 -2
- package/dist/notrace/index.d.ts +1 -1
- package/dist/notrace/index.js +1 -1
- package/dist/notrace/{plugin-CATXOxtj.d.ts → plugin-lJjjd-SN.d.ts} +1 -1
- package/dist/notrace/policies.d.ts +1 -1
- package/dist/notrace/policies.js +1 -1
- package/dist/notrace/redux.d.ts +1 -1
- package/dist/observable.d.ts +1 -1
- package/dist/oop.d.ts +1 -1
- package/dist/oop.js +1 -1
- package/dist/{plugin-vvkmIIz2.d.ts → plugin-CuvIgjnX.d.ts} +2 -2
- package/dist/policies.d.ts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/redux.d.ts +1 -1
- package/dist/scope.d.ts +2 -2
- package/dist/signal.d.ts +1 -1
- package/dist/signal.js +1 -1
- package/dist/svelte.d.ts +1 -1
- package/dist/trace.d.ts +1 -1
- package/dist/{types-Bf-LX_tE.d.ts → types-FV8fuvI9.d.ts} +2 -2
- package/dist/vue.d.ts +1 -1
- package/dist/{with-policy-CPjx0sLm.d.ts → with-policy-3bhFLEXs.d.ts} +1 -1
- package/docs/README.md +1 -0
- package/docs/actions.md +1 -1
- package/docs/chat-example.md +4 -4
- package/docs/chat-widget.md +135 -0
- package/docs/guide.md +1 -1
- package/docs/oop.md +1 -1
- package/docs/package.md +1 -1
- package/docs/starter.md +3 -3
- package/docs/tracing.md +3 -3
- package/llms-full.txt +153 -14
- package/llms.txt +1 -0
- package/package.json +3 -3
- package/dist/bus-DQDHUN5e.js +0 -1
- package/dist/event-0RIBGYqS.js +0 -1
- package/dist/notrace/bus-CGi2lrd5.js +0 -1
- package/dist/notrace/promise-CSLpzwSR.js +0 -1
package/README.md
CHANGED
|
@@ -19,23 +19,22 @@ New project: `npm create nanoeffects@latest my-app` ([Docs](docs/starter.md)). T
|
|
|
19
19
|
|
|
20
20
|
## Create a bus
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
The project is built on the event emitter pattern, also known as [publish–subscribe](https://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern): every handler is an `on` listener and every message an `emit`. You rarely need to think about it, because policies, actions and modules (below) do the work. Full API of the bus (`once`, `off`, options): [Guide](docs/guide.md#1-create-a-bus).
|
|
23
23
|
|
|
24
24
|
```js
|
|
25
25
|
import { createBus } from "nanoeffects";
|
|
26
26
|
|
|
27
27
|
const bus = createBus(); // event bus; each handler call is a task
|
|
28
|
+
const cart = [];
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
// two independent listeners of one event; on returns the function that unsubscribes
|
|
31
|
+
const unbind = bus.on("cart/added", (item) => analytics.track("add", item));
|
|
32
|
+
bus.on("cart/added", (item) => cart.push(item));
|
|
32
33
|
|
|
33
|
-
bus.emit("
|
|
34
|
-
unbind();
|
|
34
|
+
bus.emit("cart/added", { id: "p1" }); // both listeners run, cart has the item
|
|
35
|
+
unbind(); // stop tracking
|
|
35
36
|
```
|
|
36
37
|
|
|
37
|
-
That is enough for a small app or a widget. The handler’s second argument is a task context (`signal`, `emit`, …).
|
|
38
|
-
|
|
39
38
|
## Keep the logic out of the component
|
|
40
39
|
|
|
41
40
|
A newer search should abort the older one. Put it in a handler outside the component, wrapped in `latest`.
|
|
@@ -61,7 +60,7 @@ bus.on(
|
|
|
61
60
|
|
|
62
61
|
`ctx.signal` is a standard [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal), built into browsers and Node: `fetch` and many other APIs accept it and stop when it aborts.
|
|
63
62
|
|
|
64
|
-
The handler knows nothing about the UI: it only emits `results`. The component sends `search` and listens to `results` ([Vue](docs/vue.md) and [Svelte](docs/svelte.md)
|
|
63
|
+
The handler knows nothing about the UI: it only emits `results`. The component sends `search` and listens to `results`. React has hooks for it (`useEventState`, `useEmitter`: [React](docs/react.md#show-the-last-value-of-an-event-as-state)), and [Vue](docs/vue.md) and [Svelte](docs/svelte.md) have their own helpers:
|
|
65
64
|
|
|
66
65
|
```jsx
|
|
67
66
|
// SearchBox.jsx
|
|
@@ -87,21 +86,6 @@ export function SearchBox() {
|
|
|
87
86
|
}
|
|
88
87
|
```
|
|
89
88
|
|
|
90
|
-
## Take dependencies from the context
|
|
91
|
-
|
|
92
|
-
Put the API client, a store or a logger on every task once. A test passes a fake one.
|
|
93
|
-
|
|
94
|
-
```js
|
|
95
|
-
import { createBus } from "nanoeffects";
|
|
96
|
-
|
|
97
|
-
// context — every task gets these fields: the bus is the container for your dependencies
|
|
98
|
-
const bus = createBus({ context: { api } });
|
|
99
|
-
|
|
100
|
-
bus.on("save", async (draft, ctx) => {
|
|
101
|
-
await ctx.api.put(draft, { signal: ctx.signal });
|
|
102
|
-
});
|
|
103
|
-
```
|
|
104
|
-
|
|
105
89
|
## Load data and await the result
|
|
106
90
|
|
|
107
91
|
Give an action a handler, and `emit` returns its result. The caller does not import the request.
|
|
@@ -123,6 +107,24 @@ const user = await bus.emit(getUser("1"));
|
|
|
123
107
|
|
|
124
108
|
This is one way to load data. If you already use React Query or SWR, keep them: see [Query libraries](docs/query-libraries.md).
|
|
125
109
|
|
|
110
|
+
## Take dependencies from the context
|
|
111
|
+
|
|
112
|
+
Put an API client, a store or a logger on every task once. A test passes a fake one. Here the client is an [axios](https://axios-http.com) instance, but any object works.
|
|
113
|
+
|
|
114
|
+
```js
|
|
115
|
+
import axios from "axios";
|
|
116
|
+
import { createBus } from "nanoeffects";
|
|
117
|
+
|
|
118
|
+
const api = axios.create({ baseURL: "/api" });
|
|
119
|
+
|
|
120
|
+
// context — every task gets these fields: the bus is the container for your dependencies
|
|
121
|
+
const bus = createBus({ context: { api } });
|
|
122
|
+
|
|
123
|
+
bus.on("save", async (draft, ctx) => {
|
|
124
|
+
await ctx.api.put("/drafts", draft, { signal: ctx.signal });
|
|
125
|
+
});
|
|
126
|
+
```
|
|
127
|
+
|
|
126
128
|
## Docs
|
|
127
129
|
|
|
128
130
|
Start with the [Guide](docs/guide.md), or jump by need:
|
|
@@ -36,6 +36,27 @@ type UnsubscribeCallback = () => void;
|
|
|
36
36
|
//#endregion
|
|
37
37
|
//#region src/core/store.d.ts
|
|
38
38
|
declare const anyEventType = "*";
|
|
39
|
+
type AnyType = "*";
|
|
40
|
+
interface UnsubscribeTask<E extends EventMap> {
|
|
41
|
+
(task: Task<DataOf<E[Keys<E>]>, E>): void;
|
|
42
|
+
<K extends AnyType>(key: K, task?: Task<DataOf<E[Keys<E>]>, E>): void;
|
|
43
|
+
<K extends Keys<E>>(key: K, task?: Task<DataOf<E[K]>, E>): void;
|
|
44
|
+
}
|
|
45
|
+
type Store<E extends EventMap> = {
|
|
46
|
+
get: {
|
|
47
|
+
/** Every listener of every event, in the order of the events. */
|
|
48
|
+
(): Task<DataOf<E[Keys<E>]>, E>[];
|
|
49
|
+
(key: AnyType): Task<DataOf<E[Keys<E>]>, E>[];
|
|
50
|
+
<K extends Keys<E>>(key: K): Task<DataOf<E[K]>, E>[];
|
|
51
|
+
};
|
|
52
|
+
add: {
|
|
53
|
+
(key: AnyType, task: Task<DataOf<E[Keys<E>]>, E>): UnsubscribeCallback;
|
|
54
|
+
<K extends Keys<E>>(key: K, task: Task<DataOf<E[K]>, E>): UnsubscribeCallback;
|
|
55
|
+
};
|
|
56
|
+
remove: UnsubscribeTask<E>;
|
|
57
|
+
/** Drops every key; lists already handed out by `get` stay as they were. */
|
|
58
|
+
clear: () => void;
|
|
59
|
+
};
|
|
39
60
|
//#endregion
|
|
40
61
|
//#region src/core/tracer.d.ts
|
|
41
62
|
/**
|
|
@@ -249,6 +270,24 @@ interface Bus<E extends EventMap> {
|
|
|
249
270
|
*/
|
|
250
271
|
once: On<E>;
|
|
251
272
|
off: Off<E>;
|
|
273
|
+
/**
|
|
274
|
+
* The listeners an event has right now, in the order they run: what `on`,
|
|
275
|
+
* `once`, `ctx.on` and the `on` of a module registered, as the bus holds them
|
|
276
|
+
* (a plugin may have wrapped a function, so compare the length, not the
|
|
277
|
+
* functions). It takes the event name as a string, as the bus stores it, not
|
|
278
|
+
* an action creator: use `creator.type`. `"*"` gives the any-event listeners,
|
|
279
|
+
* which a named event does not include. The array is not changed afterwards: a later `on` or unbind
|
|
280
|
+
* gives the next `get` a new one.
|
|
281
|
+
*
|
|
282
|
+
* @example
|
|
283
|
+
* ```ts
|
|
284
|
+
* const unbind = bus.on("saved", save);
|
|
285
|
+
* bus.get("saved").length; // 1
|
|
286
|
+
* unbind();
|
|
287
|
+
* bus.get("saved").length; // 0
|
|
288
|
+
* ```
|
|
289
|
+
*/
|
|
290
|
+
get: Store<E>["get"];
|
|
252
291
|
emit: Emit<E>;
|
|
253
292
|
/**
|
|
254
293
|
* Calls `plugin` with the bus and returns what it returns: an api, a
|
package/dist/actions.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { D as EventKey, G as PayloadOf, H as EventMap, a as FreeActionCreator, c as Scope, i as Free, n as Call, q as Task, t as ActionCreator, u as WithScope, v as Bus } from "./action-creator-
|
|
2
|
-
import { r as Scoped, t as FieldsOfScope } from "./types-
|
|
3
|
-
import { a as createModule, c as CarryingCalls, d as actionsPlugin, f as setHandler, l as MadeCommand, n as ModuleApi, o as modulePlugin, r as ModuleContext, s as Binding, t as Module, u as ScopedCommand } from "./module-
|
|
1
|
+
import { D as EventKey, G as PayloadOf, H as EventMap, a as FreeActionCreator, c as Scope, i as Free, n as Call, q as Task, t as ActionCreator, u as WithScope, v as Bus } from "./action-creator-CcAEvUnw.js";
|
|
2
|
+
import { r as Scoped, t as FieldsOfScope } from "./types-FV8fuvI9.js";
|
|
3
|
+
import { a as createModule, c as CarryingCalls, d as actionsPlugin, f as setHandler, l as MadeCommand, n as ModuleApi, o as modulePlugin, r as ModuleContext, s as Binding, t as Module, u as ScopedCommand } from "./module-C_oEXw1n.js";
|
|
4
4
|
import { t as OriginOptions } from "./origin-key-CxK0SkeG.js";
|
|
5
5
|
//#region src/actions/action.d.ts
|
|
6
6
|
type Reserved = "handle" | "prepare";
|
package/dist/actions.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e,i as t,l as n,n as r,u as i}from"./context-UcmrAIhP.js";import{t as a}from"./event-
|
|
1
|
+
import{d as e,i as t,l as n,n as r,u as i}from"./context-UcmrAIhP.js";import{t as a}from"./event-DVcW0mME.js";import{r as o}from"./bus-DlpEluzd.js";import{n as s,t as c}from"./lifecycle-key-8iX8RUVD.js";import{t as l}from"./origin-key-BbWN3gmN.js";import{t as u}from"./scope-key-B7l7mUS5.js";import{t as d}from"./mount-each-D54UqAhZ.js";const f=(e,t)=>(t&&Object.defineProperty(e,u,{value:t}),e),p=(e,t)=>({...e,...t,$effects:{...e.$effects,...t.$effects}}),m=e=>Reflect.get(e,u),h=e=>{let t=Object.assign(n=>o(t,e,n),{type:e});return t},g=e=>typeof e==`object`&&!!e&&Reflect.get(e,`signal`)instanceof AbortSignal&&typeof Reflect.get(e,`emit`)==`function`;var _=class extends Error{};function v(e,t,n){return y(e,t,n)}function y(e,t,n,r){let i=t=>t.type===e,a=e=>r?e.length===2&&g(e[1]):typeof e[1]==`object`;function s(...i){let[s,c]=i;if(a(i)){if(!t)throw new _(`No handler for command "${e}"`);return t(s,c)}let u=r&&Reflect.apply(r,null,i),d=u?u.payload:s;return f(o(l,e,d),n)}let c=Object.assign(s,{type:e,match:i,toString:()=>e}),l=f(c,n);return l}function b(e,t){return[e,t]}const x=e=>typeof Reflect.get(e??{},`handle`)==`function`,S=(e=[])=>t=>{let n=t.actions;if(x(n))return n.handle(e),n;let r=/* @__PURE__ */ new Map,i=(e,t)=>{let n={fn:t};return r.set(e,[...r.get(e)??[],n]),()=>{let t=(r.get(e)??[]).filter(e=>e!==n);t.length>0?r.set(e,t):r.delete(e)}};function o(e,t){if(t)return i(a(e),t);let n=e.map(([e,t])=>i(a(e),t));return()=>{for(let e of n)e()}}o(e);let s={run:(e,t,n)=>{let i=(r.get(e.type)??[]).at(-1)?.fn,a=i&&e.wrap?e.wrap(i):i??e;return Reflect.apply(a,null,[t,n])},handle:o,bound:e=>r.has(e)?h(e):void 0};return t.actions=s,s};function C(e,t,n){let{handle:r,prepare:i,scope:a}=w(typeof t==`function`?n:t),o=typeof t==`function`?t:r;return o?y(e,o,a,i):Object.assign(f((...t)=>{let n=i&&Reflect.apply(i,null,t);return f({type:e,payload:n?n.payload:t[0]},a)},a),{type:e,match:t=>t.type===e,toString:()=>e})}const w=e=>{if(!e)return{};let{handle:t,prepare:n,...r}=e,i=typeof t==`function`,a=typeof n==`function`;if(!i&&!a)return{scope:e};let o=Object.keys(r).length>0?r:void 0;return{...i&&{handle:t},...a&&{prepare:n},...o&&{scope:o}}},T=()=>e=>{function t(t,n){return(...r)=>{let i=t(...r),a=Reflect.get(e,l);a?a(i,n):e.emit(i)}}return Object.assign(e,{emitter:t})},E=e=>typeof e==`string`?C(e):e,D=(e,t,n,r)=>{let i=m(t);e.emit(Reflect.apply(t,null,[n]),r&&i?p(r,i):r)},O=(t,r,i,a)=>{let o=t;o[n]=!0;try{D(t,r,i,a)}catch(t){e(`cancel listener`,t)}o[n]=!1},k=e=>{try{return Promise.resolve(e())}catch(e){if(e instanceof _)throw e;return Promise.reject(e)}},A=(t,n,r={},a)=>{let l=v(t,n),u=e=>E(r[e]??`${t}/${e}`),d=u(`pending`),p=u(`success`),m=u(`fail`),h=u(`cancel`),g=(t,n,r,o)=>{let s=r,l=`idle`,u=()=>{},f=()=>{l=`closed`,u()},g=e=>{l===`started`&&(f(),O(s,h,e,a))},_=()=>{l===`idle`&&(l=`started`,u=i(s,g),D(s,d,n,a))},v=e=>{l===`started`&&(f(),s.signal.aborted?O(s,h,s.signal.reason,a):`error`in e?D(s,m,e.error,a):D(s,p,e.value,a))};return Reflect.set(s,c,{start:_,cancel:g,done:v,drop:()=>{l===`idle`&&(l=`closed`)}}),k(()=>(o||_(),Reflect.apply(t,null,[n,r]))).then(e=>(v({value:e}),e),t=>{if(l===`idle`)try{_()}catch(t){e(`pending listener`,t)}v({error:t})})},_=e=>{let t=Reflect.get(e,s)===!0;return(n,r)=>g(e,n,r,t)},y=Reflect.get(n??{},s)===!0;function b(e,r){return typeof r==`object`?n?g(l,e,r,y):Reflect.apply(l,null,[e,r]):f(o(S,t,e),a)}let x=Object.assign(b,{type:t,match:l.match,wrap:_,pending:d,success:p,fail:m,cancel:h}),S=f(x,a);return S},j=e=>typeof e==`object`&&!!e,M=e=>{if(typeof e==`string`)return e;if(j(e)||typeof e==`function`){let t=Reflect.get(e,`type`);return typeof t==`string`?t:e}return e},N=(e,t)=>{let[n,r]=e;return n===void 0||Object.is(M(n),M(t[0]))&&(r===void 0||Object.is(r,t[1]))},P=e=>{let t={on:e.on,once:e.once,off:e.off},n=[],r=!0,i=(t,n)=>Reflect.apply(t,e,n),a=(e,t)=>(...a)=>{if(!r)return i(t,a);let o={kind:e,args:a,dropped:!1};return n.push(o),()=>{o.live?o.live():o.dropped=!0}},o=e=>(...t)=>{if(!r)return i(e,t);for(let e of n)e.kind!==`off`&&N(t,e.args)&&(e.dropped=!0);n.push({kind:`off`,args:t,dropped:!1})},s=a(`on`,t.on),c=a(`once`,t.once),l=o(t.off);return e.on=s,e.once=c,e.off=l,{release:()=>{r=!1,e.on===s&&(e.on=t.on),e.once===c&&(e.once=t.once),e.off===l&&(e.off=t.off)},replay:()=>{for(let e of n.splice(0))if(!e.dropped){if(e.kind===`off`)i(t.off,e.args);else{let n=e.kind===`on`?t.on:t.once;e.live=i(n,e.args)}}}}};function F(e,t,n){return n?{name:e,setup:t,scope:n}:{name:e,setup:t}}const I=(e,t)=>n=>t?e.fitScope?.(t,n)??n:n,L=(e,t,n)=>{n&&e.applyScope?.(t,n)},R=(e,t,n)=>Array.isArray(t)?[t.map(([t,n])=>[t,e(n)]),n]:[t,e(n)],z=(e,t)=>{let n=e.on;return(...e)=>{let[r,i,...a]=e;return Reflect.apply(n,null,[r,t(i),...a])}},B=e=>(t,...n)=>{e.run(t,...n).catch(t=>{if(!e.signal.aborted)throw t})},V=(n=[])=>a=>{let o=a.actions??S()(a),s={handle:(...e)=>{if(!o.handle)throw Error("modulePlugin: the `actions` of the bus is not a registry from `actionsPlugin()`");return Reflect.apply(o.handle,null,e)}},c=e=>{let n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Map;return{mount:o=>{let l=n.get(o);if(l)return l;let u=r.get(o.name);u&&n.get(u)?.();let d=t(e,o.name),f=d.ctx,p=c(f),m=()=>{n.delete(o),r.get(o.name)===o&&r.delete(o.name),f.abort(),d.unlink()};n.set(o,m),r.set(o.name,o);let h=o.scope,g=I(a,h),_=(e,t)=>{let n=Reflect.apply(s.handle,null,R(g,e,t));return i(f,n),n},v=(...e)=>{let t=e.map(e=>typeof e==`function`?_(e,e):p.mount(e));return()=>{for(let e of t)e()}},y=B(f),b=z(f,g);try{L(a,f,h),o.setup(Object.assign(f,{handle:_,use:v,spawn:y,on:b}))}catch(e){throw m(),e}return m},unmount:e=>n.get(e)?.(),isMounted:e=>n.has(e)}},l=P(a),u=a.emit,f=a.get,p,m=(e=!0)=>{if(p)return p;l.release(),a.emit===h&&(a.emit=u);let t=r({event:{type:`app`,payload:void 0},bus:a,tracer:a.trace});p={root:t,apps:d(c(t.ctx))};try{e&&p.apps.mount(...n)}finally{l.replay()}return p},h=(...e)=>(m(),Reflect.apply(u,a,e));a.emit=h,a.get=((...e)=>(m(),Reflect.apply(f,a,e))),n.length>0&&queueMicrotask(()=>{try{m()}catch(t){e(`the modules of the app could not start`,t)}});let g={get actions(){return m(),o},mount:(...e)=>{let{root:t,apps:n}=m();return t.ctx.signal.throwIfAborted(),n.mount(...e)},unmount:(...e)=>m().apps.unmount(...e),isMounted:e=>m().apps.isMounted(e),dispose:()=>m(!1).root.ctx.abort(),createModule:F};return a.app=g,g};export{S as actionsPlugin,C as createAction,A as createJob,F as createModule,T as emitterPlugin,V as modulePlugin,b as setHandler};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as e,n as t,o as n,r}from"./context-UcmrAIhP.js";import{n as i,t as a}from"./event-DVcW0mME.js";const o=()=>{let e={},t={},n=n=>(t[n]=void 0,e[n]??=/* @__PURE__ */ new Map,e[n]),r=(e,t)=>{let r=n(e),i=r.get(t)??0;i>1?r.set(t,i-1):t?r.delete(t):r.clear()},i=()=>{e={},t={}},a=n=>n===void 0?Object.keys(e).flatMap(a):(t[n]??=[...e[n]??[]].flatMap(([e,t])=>Array(t).fill(e)),t[n]);return{get:a,add:(e,t)=>{let i=n(e);return i.set(t,(i.get(t)??0)+1),()=>r(e,t)},remove:r,clear:i}},s=Symbol(),c=(e,t,n)=>{let r={type:t,payload:n};return Object.defineProperty(r,s,{value:e,enumerable:!1}),r},l=e=>{if(typeof e==`function`)return e;if(typeof e==`object`&&e&&s in e)return e[s]},u=(e,t,n)=>Reflect.apply(e,null,[t,n]),d=(s={})=>{let c=o(),d=(e,t)=>c.add(a(e),t),f=(e,t)=>{let n=d(e,(e,r)=>(n(),t(e,r)));return n},p=(e,t)=>{e===void 0?c.clear():c.remove(a(e),t)},m=e=>t({event:e,bus:g,tracer:s.trace,parent:{ref:r()}}).ctx,h=(t,n)=>{let{onError:r}=s,i=m(n);if(!r){t(n.payload,i);return}let a=t=>{try{r(t,n)}catch(t){e(`onError failed`,t)}};try{let e=t(n.payload,i);typeof e?.then==`function`&&Promise.resolve(e).catch(a)}catch(e){a(e)}},g={get:c.get,on:d,off:p,once:f,emit:(e,t)=>{let r=a(e),o=i(e,t),d={type:r,payload:o},f=l(e);f||=g.actions?.bound?.(r);let p=[...c.get(r),...c.get(`*`)];p.length===0&&!f&&s.onUnhandled?.(d);for(let e of p)h(e,d);if(f){let e=m(d),t=g.actions?.run??u;return n(e,`command`,()=>t(f,o,e))}},use:e=>e(g),ctx:s.context,trace:s.trace};return g};export{d as n,c as r,l as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as ContextOf, H as EventMap } from "./action-creator-
|
|
1
|
+
import { C as ContextOf, H as EventMap } from "./action-creator-CcAEvUnw.js";
|
|
2
2
|
//#region src/core/context-types.d.ts
|
|
3
3
|
/** What a function that makes the fields of a task gets to see. */
|
|
4
4
|
type ContextTask = {
|
package/dist/context.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as WithContext, H as EventMap, v as Bus } from "./action-creator-
|
|
2
|
-
import { n as NoClash, t as ContextTask } from "./context-types-
|
|
1
|
+
import { F as WithContext, H as EventMap, v as Bus } from "./action-creator-CcAEvUnw.js";
|
|
2
|
+
import { n as NoClash, t as ContextTask } from "./context-types-hCKgU8sC.js";
|
|
3
3
|
//#region src/context/plugin.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Puts `fields` on the context of every task of the bus: a store, a client, a
|
package/dist/dev.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { H as EventMap, Z as UnsubscribeCallback, v as Bus } from "./action-creator-
|
|
2
|
-
import { i as WithApp, n as ModuleApi } from "./module-
|
|
1
|
+
import { H as EventMap, Z as UnsubscribeCallback, v as Bus } from "./action-creator-CcAEvUnw.js";
|
|
2
|
+
import { i as WithApp, n as ModuleApi } from "./module-C_oEXw1n.js";
|
|
3
3
|
//#region src/dev/types.d.ts
|
|
4
4
|
/** The parts of what `modulePlugin` returned that the diagnostics report. */
|
|
5
5
|
type ReportedApp<E extends EventMap> = Pick<ModuleApi<E>, "mount" | "unmount" | "isMounted">;
|
package/dist/dev.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./event-
|
|
1
|
+
import{t as e}from"./event-DVcW0mME.js";import{t}from"./mount-each-D54UqAhZ.js";const n=`[nanoeffects]`,r=(e={})=>t=>{let{maxListeners:n=10,leaks:r=!0,modules:i=!0,app:s}=e,c=e.log??(e=>console.warn(e)),l=e.log??(e=>console.info(e)),u=[];return r&&u.push(a(t,n,c)),i&&u.push(o(t,s,l)),()=>{for(let e of u.splice(0))e()}},i=t=>typeof t==`function`&&typeof Reflect.get(t,`type`)!=`string`?`*`:e(t),a=(e,t,r)=>{let a=e.on,o=/* @__PURE__ */ new Map,s=/* @__PURE__ */ new Set,c=!0,l=(...l)=>{if(!c)return Reflect.apply(a,e,l);let[u]=l,d=i(u),f=(o.get(d)??0)+1;o.set(d,f),f>t&&!s.has(d)&&(s.add(d),r(`${n} ${f} listeners of "${d}" were added and not unsubscribed (more than ${t}). A file that is reloaded and subscribes again, or an unsubscribe that is never called?`));let p=Reflect.apply(a,e,l),m=!1;return()=>{if(!m){m=!0;let e=(o.get(d)??1)-1;o.set(d,e),e<=t&&s.delete(d)}p()}};return e.on=l,()=>{c=!1,e.on===l&&(e.on=a)}},o=(e,t,n)=>{let r=t??e.app;if(r)return s(r,n);let i,a;return Object.defineProperty(e,"app",{configurable:!0,enumerable:!0,get:()=>i,set:e=>{a?.(),i=e,a=e?s(e,n):void 0}}),()=>{a?.(),Object.defineProperty(e,"app",{configurable:!0,enumerable:!0,writable:!0,value:i})}},s=(e,r)=>{let{mount:i,unmount:a}=e,o=/* @__PURE__ */ new Map,s=t({mount:t=>{let a=o.get(t.name);if(a===t&&e.isMounted(t))return i(t);let s=a!==void 0&&e.isMounted(a),c=i(t);return o.set(t.name,t),r(`${n} module "${t.name}" ${s?`replaced`:`mounted`}`),()=>{e.isMounted(t)&&r(`${n} module "${t.name}" unmounted`),c()}},unmount:t=>{e.isMounted(t)&&r(`${n} module "${t.name}" unmounted`),a(t)},isMounted:t=>e.isMounted(t)});return e.mount=s.mount,e.unmount=s.unmount,()=>{e.mount=i,e.unmount=a}};export{r as devPlugin};
|
package/dist/effects.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { H as EventMap, I as WithSignal, S as Context, f as Effect, q as Task } from "./action-creator-
|
|
2
|
-
import { a as RaceStarter, c as all, d as GroupOptions, f as Starter, i as take, l as ChildOf, m as delay, n as effectsPlugin, o as race, p as StarterOf, r as TakeOptions, s as allSettled, u as EffectContext } from "./plugin-
|
|
1
|
+
import { H as EventMap, I as WithSignal, S as Context, f as Effect, q as Task } from "./action-creator-CcAEvUnw.js";
|
|
2
|
+
import { a as RaceStarter, c as all, d as GroupOptions, f as Starter, i as take, l as ChildOf, m as delay, n as effectsPlugin, o as race, p as StarterOf, r as TakeOptions, s as allSettled, u as EffectContext } from "./plugin-CuvIgjnX.js";
|
|
3
3
|
//#region src/utils/onAbort.d.ts
|
|
4
4
|
export declare const onAbort: (ctx: {
|
|
5
5
|
signal?: AbortSignal | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=e=>e.type??e,t=(e,t)=>typeof e==`object`?e.payload:t;export{t as n,e as t};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as EventsOf, C as ContextOf, D as EventKey, E as Emittable, F as WithContext, G as PayloadOf, H as EventMap, I as WithSignal, L as WithType, M as HandlerRef, N as Off, O as EventLike, P as On, S as Context, T as Emit, U as Keys, Z as UnsubscribeCallback, _ as AnyEvent, b as Command, g as Actions, h as Action, j as Handler, k as EventPayload, n as Call, o as WithPayload, q as Task, v as Bus, w as ContextOption, x as CommandCall, y as BusOptions, z as createBus } from "./action-creator-
|
|
1
|
+
import { A as EventsOf, C as ContextOf, D as EventKey, E as Emittable, F as WithContext, G as PayloadOf, H as EventMap, I as WithSignal, L as WithType, M as HandlerRef, N as Off, O as EventLike, P as On, S as Context, T as Emit, U as Keys, Z as UnsubscribeCallback, _ as AnyEvent, b as Command, g as Actions, h as Action, j as Handler, k as EventPayload, n as Call, o as WithPayload, q as Task, v as Bus, w as ContextOption, x as CommandCall, y as BusOptions, z as createBus } from "./action-creator-CcAEvUnw.js";
|
|
2
2
|
export { type Action, type Actions, type AnyEvent, type Bus, type BusOptions, type Call, type Command, type CommandCall, type Context, type ContextOf, type ContextOption, type Emit, type Emittable, type EventKey, type EventLike, type EventMap, type EventPayload, type EventsOf, type Handler, type HandlerRef, type Keys, type Off, type On, type PayloadOf, type Task, type UnsubscribeCallback, type WithContext, type WithPayload, type WithSignal, type WithType, createBus };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{n as createBus}from"./bus-
|
|
1
|
+
export{n as createBus}from"./bus-DlpEluzd.js";
|
package/dist/match.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as EventMap, Z as UnsubscribeCallback, h as Action, k as EventPayload, q as Task, v as Bus } from "./action-creator-
|
|
1
|
+
import { H as EventMap, Z as UnsubscribeCallback, h as Action, k as EventPayload, q as Task, v as Bus } from "./action-creator-CcAEvUnw.js";
|
|
2
2
|
//#region src/match/plugin.d.ts
|
|
3
3
|
/** A function over the action of an event: `{ type, payload }`. */
|
|
4
4
|
type Predicate<E extends EventMap> = (action: Action<E>) => boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { G as PayloadOf, H as EventMap, R as commandCall, S as Context, Z as UnsubscribeCallback, b as Command, c as Scope, g as Actions, q as Task, u as WithScope, v as Bus, x as CommandCall } from "./action-creator-
|
|
2
|
-
import { n as ScopeSlots, r as Scoped } from "./types-
|
|
1
|
+
import { G as PayloadOf, H as EventMap, R as commandCall, S as Context, Z as UnsubscribeCallback, b as Command, c as Scope, g as Actions, q as Task, u as WithScope, v as Bus, x as CommandCall } from "./action-creator-CcAEvUnw.js";
|
|
2
|
+
import { n as ScopeSlots, r as Scoped } from "./types-FV8fuvI9.js";
|
|
3
3
|
//#region src/actions/command.d.ts
|
|
4
4
|
/** What `createCommand` returns: a command that also tells whether an action is of its type. */
|
|
5
5
|
type MadeCommand<P, R, T extends string> = Command<P, R> & {
|
|
@@ -14,6 +14,27 @@ type UnsubscribeCallback = () => void;
|
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region src/core/store.d.ts
|
|
16
16
|
declare const anyEventType = "*";
|
|
17
|
+
type AnyType = "*";
|
|
18
|
+
interface UnsubscribeTask<E extends EventMap> {
|
|
19
|
+
(task: Task<DataOf<E[Keys<E>]>, E>): void;
|
|
20
|
+
<K extends AnyType>(key: K, task?: Task<DataOf<E[Keys<E>]>, E>): void;
|
|
21
|
+
<K extends Keys<E>>(key: K, task?: Task<DataOf<E[K]>, E>): void;
|
|
22
|
+
}
|
|
23
|
+
type Store<E extends EventMap> = {
|
|
24
|
+
get: {
|
|
25
|
+
/** Every listener of every event, in the order of the events. */
|
|
26
|
+
(): Task<DataOf<E[Keys<E>]>, E>[];
|
|
27
|
+
(key: AnyType): Task<DataOf<E[Keys<E>]>, E>[];
|
|
28
|
+
<K extends Keys<E>>(key: K): Task<DataOf<E[K]>, E>[];
|
|
29
|
+
};
|
|
30
|
+
add: {
|
|
31
|
+
(key: AnyType, task: Task<DataOf<E[Keys<E>]>, E>): UnsubscribeCallback;
|
|
32
|
+
<K extends Keys<E>>(key: K, task: Task<DataOf<E[K]>, E>): UnsubscribeCallback;
|
|
33
|
+
};
|
|
34
|
+
remove: UnsubscribeTask<E>;
|
|
35
|
+
/** Drops every key; lists already handed out by `get` stay as they were. */
|
|
36
|
+
clear: () => void;
|
|
37
|
+
};
|
|
17
38
|
//#endregion
|
|
18
39
|
//#region src/core/tracer.d.ts
|
|
19
40
|
/**
|
|
@@ -227,6 +248,24 @@ interface Bus<E extends EventMap> {
|
|
|
227
248
|
*/
|
|
228
249
|
once: On<E>;
|
|
229
250
|
off: Off<E>;
|
|
251
|
+
/**
|
|
252
|
+
* The listeners an event has right now, in the order they run: what `on`,
|
|
253
|
+
* `once`, `ctx.on` and the `on` of a module registered, as the bus holds them
|
|
254
|
+
* (a plugin may have wrapped a function, so compare the length, not the
|
|
255
|
+
* functions). It takes the event name as a string, as the bus stores it, not
|
|
256
|
+
* an action creator: use `creator.type`. `"*"` gives the any-event listeners,
|
|
257
|
+
* which a named event does not include. The array is not changed afterwards: a later `on` or unbind
|
|
258
|
+
* gives the next `get` a new one.
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* ```ts
|
|
262
|
+
* const unbind = bus.on("saved", save);
|
|
263
|
+
* bus.get("saved").length; // 1
|
|
264
|
+
* unbind();
|
|
265
|
+
* bus.get("saved").length; // 0
|
|
266
|
+
* ```
|
|
267
|
+
*/
|
|
268
|
+
get: Store<E>["get"];
|
|
230
269
|
emit: Emit<E>;
|
|
231
270
|
/**
|
|
232
271
|
* Calls `plugin` with the bus and returns what it returns: an api, a
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as Task, F as commandCall, L as EventMap, V as UnsubscribeCallback, _ as Command, c as WithScope, d as Effects, h as Bus, i as FreeActionCreator, n as Call, o as Scope, p as Actions, r as Free, s as WithFields, t as ActionCreator, v as CommandCall, w as EventKey, y as Context, z as PayloadOf } from "./action-creator-
|
|
2
|
-
import { t as BoundOf } from "./plugin-
|
|
1
|
+
import { B as Task, F as commandCall, L as EventMap, V as UnsubscribeCallback, _ as Command, c as WithScope, d as Effects, h as Bus, i as FreeActionCreator, n as Call, o as Scope, p as Actions, r as Free, s as WithFields, t as ActionCreator, v as CommandCall, w as EventKey, y as Context, z as PayloadOf } from "./action-creator-DxOvVo8I.js";
|
|
2
|
+
import { t as BoundOf } from "./plugin-lJjjd-SN.js";
|
|
3
3
|
import { t as OriginOptions } from "./origin-key-CxK0SkeG.js";
|
|
4
4
|
//#region src/scope/types.d.ts
|
|
5
5
|
/**
|
package/dist/notrace/actions.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,i as t,l as n,n as r,s as i}from"./context-_HWcdjZf.js";import{n as a,r as o}from"./bus-
|
|
1
|
+
import{c as e,i as t,l as n,n as r,s as i}from"./context-_HWcdjZf.js";import{n as a,r as o}from"./bus-DmKn4SDD.js";import{n as s,t as c}from"./lifecycle-key-8iX8RUVD.js";import{t as l}from"./origin-key-BbWN3gmN.js";const u=Symbol.for(`nanoeffects.scope`),d=(e,t)=>(t&&Object.defineProperty(e,u,{value:t}),e),f=(e,t)=>({...e,...t,$effects:{...e.$effects,...t.$effects}}),p=e=>Reflect.get(e,u),m=e=>{let t=Object.assign(n=>a(t,e,n),{type:e});return t},h=e=>typeof e==`object`&&!!e&&Reflect.get(e,`signal`)instanceof AbortSignal&&typeof Reflect.get(e,`emit`)==`function`;var g=class extends Error{};function _(e,t,n){return v(e,t,n)}function v(e,t,n,r){let i=t=>t.type===e,o=e=>r?e.length===2&&h(e[1]):typeof e[1]==`object`;function s(...i){let[s,c]=i;if(o(i)){if(!t)throw new g(`No handler for command "${e}"`);return t(s,c)}let u=r&&Reflect.apply(r,null,i),f=u?u.payload:s;return d(a(l,e,f),n)}let c=Object.assign(s,{type:e,match:i,toString:()=>e}),l=d(c,n);return l}function y(e,t){return[e,t]}const b=e=>typeof Reflect.get(e??{},`handle`)==`function`,x=(e=[])=>t=>{let n=t.actions;if(b(n))return n.handle(e),n;let r=/* @__PURE__ */ new Map,i=(e,t)=>{let n={fn:t};return r.set(e,[...r.get(e)??[],n]),()=>{let t=(r.get(e)??[]).filter(e=>e!==n);t.length>0?r.set(e,t):r.delete(e)}};function a(e,t){if(t)return i(o(e),t);let n=e.map(([e,t])=>i(o(e),t));return()=>{for(let e of n)e()}}a(e);let s={run:(e,t,n)=>{let i=(r.get(e.type)??[]).at(-1)?.fn,a=i&&e.wrap?e.wrap(i):i??e;return Reflect.apply(a,null,[t,n])},handle:a,bound:e=>r.has(e)?m(e):void 0};return t.actions=s,s};function S(e,t,n){let{handle:r,prepare:i,scope:a}=C(typeof t==`function`?n:t),o=typeof t==`function`?t:r;return o?v(e,o,a,i):Object.assign(d((...t)=>{let n=i&&Reflect.apply(i,null,t);return d({type:e,payload:n?n.payload:t[0]},a)},a),{type:e,match:t=>t.type===e,toString:()=>e})}const C=e=>{if(!e)return{};let{handle:t,prepare:n,...r}=e,i=typeof t==`function`,a=typeof n==`function`;if(!i&&!a)return{scope:e};let o=Object.keys(r).length>0?r:void 0;return{...i&&{handle:t},...a&&{prepare:n},...o&&{scope:o}}},w=()=>e=>{function t(t,n){return(...r)=>{let i=t(...r),a=Reflect.get(e,l);a?a(i,n):e.emit(i)}}return Object.assign(e,{emitter:t})},T=e=>typeof e==`string`?S(e):e,E=(e,t,n,r)=>{let i=p(t);e.emit(Reflect.apply(t,null,[n]),r&&i?f(r,i):r)},D=(e,t,r,a)=>{let o=e;o[i]=!0;try{E(e,t,r,a)}catch(e){n(`cancel listener`,e)}o[i]=!1},O=e=>{try{return Promise.resolve(e())}catch(e){if(e instanceof g)throw e;return Promise.reject(e)}},k=(t,r,i={},o)=>{let l=_(t,r),u=e=>T(i[e]??`${t}/${e}`),f=u(`pending`),p=u(`success`),m=u(`fail`),h=u(`cancel`),g=(t,r,i,a)=>{let s=i,l=`idle`,u=()=>{},d=()=>{l=`closed`,u()},g=e=>{l===`started`&&(d(),D(s,h,e,o))},_=()=>{l===`idle`&&(l=`started`,u=e(s,g),E(s,f,r,o))},v=e=>{l===`started`&&(d(),s.signal.aborted?D(s,h,s.signal.reason,o):`error`in e?E(s,m,e.error,o):E(s,p,e.value,o))};return Reflect.set(s,c,{start:_,cancel:g,done:v,drop:()=>{l===`idle`&&(l=`closed`)}}),O(()=>(a||_(),Reflect.apply(t,null,[r,i]))).then(e=>(v({value:e}),e),e=>{if(l===`idle`)try{_()}catch(e){n(`pending listener`,e)}v({error:e})})},v=e=>{let t=Reflect.get(e,s)===!0;return(n,r)=>g(e,n,r,t)},y=Reflect.get(r??{},s)===!0;function b(e,n){return typeof n==`object`?r?g(l,e,n,y):Reflect.apply(l,null,[e,n]):d(a(S,t,e),o)}let x=Object.assign(b,{type:t,match:l.match,wrap:v,pending:f,success:p,fail:m,cancel:h}),S=d(x,o);return S},A=e=>typeof e==`object`&&!!e,j=e=>{if(typeof e==`string`)return e;if(A(e)||typeof e==`function`){let t=Reflect.get(e,`type`);return typeof t==`string`?t:e}return e},M=(e,t)=>{let[n,r]=e;return n===void 0||Object.is(j(n),j(t[0]))&&(r===void 0||Object.is(r,t[1]))},N=e=>{let t={on:e.on,once:e.once,off:e.off},n=[],r=!0,i=(t,n)=>Reflect.apply(t,e,n),a=(e,t)=>(...a)=>{if(!r)return i(t,a);let o={kind:e,args:a,dropped:!1};return n.push(o),()=>{o.live?o.live():o.dropped=!0}},o=e=>(...t)=>{if(!r)return i(e,t);for(let e of n)e.kind!==`off`&&M(t,e.args)&&(e.dropped=!0);n.push({kind:`off`,args:t,dropped:!1})},s=a(`on`,t.on),c=a(`once`,t.once),l=o(t.off);return e.on=s,e.once=c,e.off=l,{release:()=>{r=!1,e.on===s&&(e.on=t.on),e.once===c&&(e.once=t.once),e.off===l&&(e.off=t.off)},replay:()=>{for(let e of n.splice(0))if(!e.dropped){if(e.kind===`off`)i(t.off,e.args);else{let n=e.kind===`on`?t.on:t.once;e.live=i(n,e.args)}}}}},P=e=>({mount:(...t)=>{let[n]=t;if(t.length===1&&n!==void 0)return e.mount(n);let r=[],i=()=>{for(let e of r.splice(0).reverse())e()};try{for(let n of t)e.isMounted(n)||r.push(e.mount(n))}catch(e){throw i(),e}return i},unmount:(...t)=>{for(let n of[...t].reverse())e.unmount(n)},isMounted:e.isMounted});function F(e,t,n){return n?{name:e,setup:t,scope:n}:{name:e,setup:t}}const I=(e,t)=>n=>t?e.fitScope?.(t,n)??n:n,L=(e,t,n)=>{n&&e.applyScope?.(t,n)},R=(e,t,n)=>Array.isArray(t)?[t.map(([t,n])=>[t,e(n)]),n]:[t,e(n)],z=(e,t)=>{let n=e.on;return(...e)=>{let[r,i,...a]=e;return Reflect.apply(n,null,[r,t(i),...a])}},B=e=>(t,...n)=>{e.run(t,...n).catch(t=>{if(!e.signal.aborted)throw t})},V=(i=[])=>a=>{let o=a.actions??x()(a),s={handle:(...e)=>{if(!o.handle)throw Error("modulePlugin: the `actions` of the bus is not a registry from `actionsPlugin()`");return Reflect.apply(o.handle,null,e)}},c=n=>{let r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Map;return{mount:o=>{let l=r.get(o);if(l)return l;let u=i.get(o.name);u&&r.get(u)?.();let d=t(n,o.name),f=d.ctx,p=c(f),m=()=>{r.delete(o),i.get(o.name)===o&&i.delete(o.name),f.abort(),d.unlink()};r.set(o,m),i.set(o.name,o);let h=o.scope,g=I(a,h),_=(t,n)=>{let r=Reflect.apply(s.handle,null,R(g,t,n));return e(f,r),r},v=(...e)=>{let t=e.map(e=>typeof e==`function`?_(e,e):p.mount(e));return()=>{for(let e of t)e()}},y=B(f),b=z(f,g);try{L(a,f,h),o.setup(Object.assign(f,{handle:_,use:v,spawn:y,on:b}))}catch(e){throw m(),e}return m},unmount:e=>r.get(e)?.(),isMounted:e=>r.has(e)}},l=N(a),u=a.emit,d=a.get,f,p=(e=!0)=>{if(f)return f;l.release(),a.emit===m&&(a.emit=u);let t=r({event:{type:`app`,payload:void 0},bus:a,tracer:a.trace});f={root:t,apps:P(c(t.ctx))};try{e&&f.apps.mount(...i)}finally{l.replay()}return f},m=(...e)=>(p(),Reflect.apply(u,a,e));a.emit=m,a.get=((...e)=>(p(),Reflect.apply(d,a,e))),i.length>0&&queueMicrotask(()=>{try{p()}catch(e){n(`the modules of the app could not start`,e)}});let h={get actions(){return p(),o},mount:(...e)=>{let{root:t,apps:n}=p();return t.ctx.signal.throwIfAborted(),n.mount(...e)},unmount:(...e)=>p().apps.unmount(...e),isMounted:e=>p().apps.isMounted(e),dispose:()=>p(!1).root.ctx.abort(),createModule:F};return a.app=h,h};export{x as actionsPlugin,S as createAction,k as createJob,F as createModule,w as emitterPlugin,V as modulePlugin,y as setHandler};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,l as t,n,r}from"./context-_HWcdjZf.js";const i=e=>e.type??e,a=(e,t)=>typeof e==`object`?e.payload:t,o=()=>{let e={},t={},n=n=>(t[n]=void 0,e[n]??=/* @__PURE__ */ new Map,e[n]),r=(e,t)=>{let r=n(e),i=r.get(t)??0;i>1?r.set(t,i-1):t?r.delete(t):r.clear()},i=()=>{e={},t={}},a=n=>n===void 0?Object.keys(e).flatMap(a):(t[n]??=[...e[n]??[]].flatMap(([e,t])=>Array(t).fill(e)),t[n]);return{get:a,add:(e,t)=>{let i=n(e);return i.set(t,(i.get(t)??0)+1),()=>r(e,t)},remove:r,clear:i}},s=Symbol(),c=(e,t,n)=>{let r={type:t,payload:n};return Object.defineProperty(r,s,{value:e,enumerable:!1}),r},l=e=>{if(typeof e==`function`)return e;if(typeof e==`object`&&e&&s in e)return e[s]},u=(e,t,n)=>Reflect.apply(e,null,[t,n]),d=(s={})=>{let c=o(),d=(e,t)=>c.add(i(e),t),f=(e,t)=>{let n=d(e,(e,r)=>(n(),t(e,r)));return n},p=(e,t)=>{e===void 0?c.clear():c.remove(i(e),t)},m=e=>n({event:e,bus:g,tracer:s.trace,parent:{ref:r()}}).ctx,h=(e,n)=>{let{onError:r}=s,i=m(n);if(!r){e(n.payload,i);return}let a=e=>{try{r(e,n)}catch(e){t(`onError failed`,e)}};try{let t=e(n.payload,i);typeof t?.then==`function`&&Promise.resolve(t).catch(a)}catch(e){a(e)}},g={get:c.get,on:d,off:p,once:f,emit:(t,n)=>{let r=i(t),o=a(t,n),d={type:r,payload:o},f=l(t);f||=g.actions?.bound?.(r);let p=[...c.get(r),...c.get(`*`)];p.length===0&&!f&&s.onUnhandled?.(d);for(let e of p)h(e,d);if(f){let t=m(d),n=g.actions?.run??u;return e(t,`command`,()=>n(f,o,t))}},use:e=>e(g),ctx:s.context,trace:s.trace};return g};export{c as n,i as r,d as t};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as Task, L as EventMap, N as WithSignal, u as Effect, y as Context } from "./action-creator-
|
|
2
|
-
import { a as RaceStarter, c as all, d as GroupOptions, f as Starter, i as take, l as ChildOf, m as delay, n as effectsPlugin, o as race, p as StarterOf, r as TakeOptions, s as allSettled, u as EffectContext } from "./plugin-
|
|
1
|
+
import { B as Task, L as EventMap, N as WithSignal, u as Effect, y as Context } from "./action-creator-DxOvVo8I.js";
|
|
2
|
+
import { a as RaceStarter, c as all, d as GroupOptions, f as Starter, i as take, l as ChildOf, m as delay, n as effectsPlugin, o as race, p as StarterOf, r as TakeOptions, s as allSettled, u as EffectContext } from "./plugin-lJjjd-SN.js";
|
|
3
3
|
//#region src/utils/onAbort.d.ts
|
|
4
4
|
export declare const onAbort: (ctx: {
|
|
5
5
|
signal?: AbortSignal | undefined;
|
package/dist/notrace/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as Off, B as Task, C as Emittable, D as EventsOf, E as EventPayload, I as createBus, L as EventMap, M as WithContext, N as WithSignal, O as Handler, P as WithType, R as Keys, S as Emit, T as EventLike, V as UnsubscribeCallback, _ as Command, a as WithPayload, b as ContextOf, f as Action, g as BusOptions, h as Bus, j as On, k as HandlerRef, m as AnyEvent, n as Call, p as Actions, v as CommandCall, w as EventKey, x as ContextOption, y as Context, z as PayloadOf } from "./action-creator-
|
|
1
|
+
import { A as Off, B as Task, C as Emittable, D as EventsOf, E as EventPayload, I as createBus, L as EventMap, M as WithContext, N as WithSignal, O as Handler, P as WithType, R as Keys, S as Emit, T as EventLike, V as UnsubscribeCallback, _ as Command, a as WithPayload, b as ContextOf, f as Action, g as BusOptions, h as Bus, j as On, k as HandlerRef, m as AnyEvent, n as Call, p as Actions, v as CommandCall, w as EventKey, x as ContextOption, y as Context, z as PayloadOf } from "./action-creator-DxOvVo8I.js";
|
|
2
2
|
export { type Action, type Actions, type AnyEvent, type Bus, type BusOptions, type Call, type Command, type CommandCall, type Context, type ContextOf, type ContextOption, type Emit, type Emittable, type EventKey, type EventLike, type EventMap, type EventPayload, type EventsOf, type Handler, type HandlerRef, type Keys, type Off, type On, type PayloadOf, type Task, type UnsubscribeCallback, type WithContext, type WithPayload, type WithSignal, type WithType, createBus };
|
package/dist/notrace/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{t as createBus}from"./bus-
|
|
1
|
+
export{t as createBus}from"./bus-DmKn4SDD.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { L as EventMap, M as WithContext, R as Keys, b as ContextOf, d as Effects, h as Bus, i as FreeActionCreator, l as BoundForm, t as ActionCreator, y as Context } from "./action-creator-
|
|
1
|
+
import { L as EventMap, M as WithContext, R as Keys, b as ContextOf, d as Effects, h as Bus, i as FreeActionCreator, l as BoundForm, t as ActionCreator, y as Context } from "./action-creator-DxOvVo8I.js";
|
|
2
2
|
//#region src/core/context-types.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* `unknown` when none of the `fields` is already a context field of the bus,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as Task, L as EventMap, z as PayloadOf } from "./action-creator-
|
|
1
|
+
import { B as Task, L as EventMap, z as PayloadOf } from "./action-creator-DxOvVo8I.js";
|
|
2
2
|
//#region src/policies/keyed.d.ts
|
|
3
3
|
/** Options shared by every policy that can keep its state per key. */
|
|
4
4
|
type KeyOption<P> = {
|
package/dist/notrace/policies.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,r as t,t as n}from"./delay-Besb3X1O.js";import{a as r,c as i,i as a,n as o,o as s,t as c}from"./context-_HWcdjZf.js";import{n as l,t as u}from"./
|
|
1
|
+
import{n as e,r as t,t as n}from"./delay-Besb3X1O.js";import{a as r,c as i,i as a,n as o,o as s,t as c}from"./context-_HWcdjZf.js";import{n as l,t as u}from"./lifecycle-key-8iX8RUVD.js";const d=e=>typeof e!=`object`||!e?!1:`then`in e&&typeof e.then==`function`,f=(e,t)=>d(e)?Promise.resolve(e).finally(t):(t(),e),p=e=>Reflect.get(e,u),m=e=>{p(e)?.start()},h=(e,t,n)=>(m(e),r(e,t,n)),g=(e,t)=>{s(e,t,`drop`),p(e)?.drop()},_=(e,t)=>{p(e)?.done(t)},v=(e,t,n)=>{let r=p(e);t?r?.cancel(n):r?.drop()},y=e=>(Reflect.set(e,l,!0),e),b=()=>{},x=(e,t,n)=>typeof e==`function`?n(e,t??{}):t=>n(t,e??{}),S=(e,t)=>{let n=/* @__PURE__ */ new Map;return(r,i)=>{let a=e(r),o=n.get(a);if(!o){let e=t(()=>{n.get(a)===e&&n.delete(a)});o=e,n.set(a,e)}return o(r,i)}},C=(e,t)=>y(e?S(e,t):t(b));function w(e,t){return x(e,t,T)}const T=(e,t)=>C(t.key,t=>E(`latest`,(t,n,r)=>(r(),e(t,n)),t)),E=(e,t,n=b)=>{let r=null;return(o,l)=>{if(r?.abort(),l.signal.aborted)return;let{ctx:u,unlink:f}=a(l);r=u;let p=c(u,e),h=!1,g=()=>{u.signal.aborted||(h=!0,m(u),s(u,e,`start`))};i(u,e=>{v(u,h,e),p(h?`cancel`:`drop`)});let _=()=>{f(),r===u&&(r=null,n())},y=e=>{if(!u.signal.aborted)return p(h?`done`:`drop`),e};try{let e=t(o,u,g);return d(e)?Promise.resolve(e).then(y,e=>{if(!u.signal.aborted)throw p(`error`,e),e}).finally(_):(_(),y(e))}catch(e){if(_(),u.signal.aborted)return;throw p(`error`,e),e}}};function D(e,t,n){return x(t,n,(t,n)=>O(e,t,n))}const O=(e,t,n)=>C(n.key,r=>A(e,t,n,r)),k=(n,r,i,a)=>{let o=a!==b,s=null,c=null;return(l,u)=>{if(u.signal.aborted)return;let d=Date.now(),f=s===null||d-s>=n||d-s<0;return s=d,c!==null&&e(c),c=o?t(a,n):null,i&&f?Promise.resolve(h(u,`debounce`,()=>r(l,u))):(g(u,`debounce`),Promise.resolve(void 0))}},A=(e,t,r,a)=>{let o=r.leading??!1,s=r.trailing??!0;if(!s)return k(e,t,o,a);let c=!1,l=0,u=E(`debounce`,([r,a],o,u)=>{let d=l;return i(o,()=>{l===d&&(c=!1)}),n(o,e).then(()=>{if(c=!1,s&&!a)return u(),t(r,o)})},a);return(e,n)=>{if(n.signal.aborted)return;let r=o&&!c;c=!0,l++;let i=u([e,r],n);return r?Promise.resolve(h(n,`debounce`,()=>t(e,n))):i}};function j(e,t){return x(e,t,M)}const M=(e,t)=>C(t.key,t=>{let n=null;return(r,a)=>{if(a.signal.aborted)return;if(n){g(a,`leading`);return}let o={};n=o;let s=()=>{c(),n===o&&(n=null,t())},c=i(a,s);try{return f(h(a,`leading`,()=>e(r,a)),s)}catch(e){throw s(),e}}});function N(e,t){return x(e,t,P)}const P=(e,t)=>C(t.key,n=>F(e,t,n)),F=(e,t,n)=>{let r=t.concurrency??1,a=t.limit??1/0,o=[],s=0,c=()=>{for(;s<r;){let e=o.shift();if(!e)return;e.start()}};return(l,u)=>new Promise((d,f)=>{if(u.signal.aborted){d(void 0);return}let p=b,m=()=>{p(),g(u,`queue`),d(void 0)},v=()=>{if(p(),u.signal.aborted){m();return}s++;let t=!0,r=()=>{c(),s===0&&o.length===0&&n()},a=(e=!1)=>{t&&(t=!1,s--,e?queueMicrotask(r):r())},g=i(u,()=>{a(!0),d(void 0)}),v;try{v=Promise.resolve(h(u,`queue`,()=>e(l,u)))}catch(e){v=Promise.reject(e)}let y=()=>{g(),a()};v.then(e=>{_(u,{value:e}),y(),d(u.signal.aborted?void 0:e)},e=>{_(u,{error:e}),y(),u.signal.aborted?d(void 0):f(e)})};if(s<r){v();return}if(o.length>=a){if(t.overflow!==`drop-old`||a<=0){m();return}o.shift()?.drop()}let y={start:v,drop:m};o.push(y),p=i(u,()=>{let e=o.indexOf(y);e>=0&&o.splice(e,1),m()})})};function I(e,t,n){return x(t,n,(t,n)=>L(e,t,n))}const L=(e,t,n)=>C(n.key,r=>R(e,t,n,r)),R=(n,r,i,a)=>{let o=i.leading??!0,s=i.trailing??!0,c=a!==b,l=null,u=0,d=null,f=null,p=null,m=!1,_=e=>l===null||e-l>=n||e-l<0||e-u>=n,v=e=>g(e,`throttle`),y=()=>{let e=p;p=null,e&&(v(e.ctx),e.resolve())},x=(e,t)=>(y(),new Promise((n,r)=>{p={payload:e,ctx:t,resolve:n,reject:r}})),S=(e,t,n)=>{y(),u=n,m=!0;try{return h(t,`throttle`,()=>r(e,t))}finally{m=!1}},C=()=>{c&&(f=t(w,n))},w=()=>{if(f=null,!c||d!==null||p)return;let e=Date.now(),r=Math.max(n-(e-(l??-1/0)),n-(e-u));r<=0?a():f=t(w,r)},T=e=>{d=null;let t=p;if(s&&t&&!t.ctx.signal.aborted){p=null;try{t.resolve(S(t.payload,t.ctx,e))}catch(e){t.reject(e)}}else y();w()},E=()=>{let e=Date.now();_(e)?T(e):d=t(E,Math.min(n-(e-(l??e)),n-(e-u)))},D=()=>{f!==null&&(e(f),f=null)},O=(e,t)=>{if(!s)v(t);else return x(e,t)},k=(e,t,n,r)=>{if(!r)v(t);else if(u=n,C(),!o)v(t);else return S(e,t,n)},A=(r,i,a,s)=>s&&d!==null?(e(d),d=t(E,n),S(r,i,a)):d===null&&(d=t(E,n),s&&(u=a,o))?S(r,i,a):O(r,i);return(e,t)=>{if(t.signal.aborted)return;let n=Date.now(),r=!m&&_(n);return l=n,D(),s?A(e,t,n,r):k(e,t,n,r)}},z=Reflect.get(Symbol,`dispose`),B=e=>{let t=new AbortController,n=async(...n)=>{let r=n[0],{ctx:i,unlink:a}=o({event:{type:`withPolicy`,payload:r},parent:{signal:t.signal}});try{return await e(r,i)}finally{a()}},r=e=>{t.abort(e),t=new AbortController},i=Object.assign(n,{cancel:r});return z&&Reflect.set(i,z,()=>r()),i};export{D as debounce,w as latest,j as leading,N as queue,I as throttle,B as withPolicy};
|
package/dist/notrace/redux.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { L as EventMap, h as Bus } from "./action-creator-
|
|
1
|
+
import { L as EventMap, h as Bus } from "./action-creator-DxOvVo8I.js";
|
|
2
2
|
import { t as OriginOptions } from "./origin-key-CxK0SkeG.js";
|
|
3
3
|
//#region src/store/redux/middleware.d.ts
|
|
4
4
|
/** What Redux passes through a middleware: an action is a plain object with a `type`. */
|
package/dist/observable.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as EventMap, U as Keys, r as DataOf, v as Bus } from "./action-creator-
|
|
1
|
+
import { H as EventMap, U as Keys, r as DataOf, v as Bus } from "./action-creator-CcAEvUnw.js";
|
|
2
2
|
//#region src/observable.d.ts
|
|
3
3
|
declare global {
|
|
4
4
|
interface SymbolConstructor {
|
package/dist/oop.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as EventMap, W as ListenerOptions, b as Command, t as ActionCreator, v as Bus } from "./action-creator-
|
|
1
|
+
import { H as EventMap, W as ListenerOptions, b as Command, t as ActionCreator, v as Bus } from "./action-creator-CcAEvUnw.js";
|
|
2
2
|
//#region src/oop/types.d.ts
|
|
3
3
|
type Slots = "ctx" | "actions" | "trace" | "addContext" | "applyScope" | "fitScope" | "app" | "use";
|
|
4
4
|
type AnyFunction = (...args: never[]) => unknown;
|
package/dist/oop.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./bus-
|
|
1
|
+
import{n as e}from"./bus-DlpEluzd.js";const t=/* @__PURE__ */ new WeakMap,n=e=>typeof e==`function`,r=e=>Reflect.ownKeys(e).flatMap(t=>{let r=Reflect.getOwnPropertyDescriptor(e,t)?.value;return n(r)?[{key:t,value:r}]:[]}),i=/* @__PURE__ */ new WeakMap,a=e=>{let n=i.get(e);if(n)return n;let a=/* @__PURE__ */ new Set,o=[];for(let n=e;n&&n!==Object.prototype;n=Reflect.getPrototypeOf(n))for(let{key:e,value:i}of r(n)){if(e===`constructor`||a.has(e))continue;a.add(e);let n=t.get(i);n&&o.push({key:e,method:i,spec:n})}return i.set(e,o),o},o=/* @__PURE__ */ new WeakMap,s=e=>typeof e==`object`&&!!e||typeof e==`function`,c=e=>{let t=o.get(e);if(t)return t;let n=/* @__PURE__ */ new Set;return o.set(e,n),n},l=e=>{if(typeof e==`string`)return e;if(s(e)){let t=Reflect.get(e,`type`);return typeof t==`string`?t:e}return e},u=(e,t,n)=>Reflect.apply(Reflect.get(e,t),e,n),d=(e,t,n,r)=>{let[i,a,...o]=r,s=c(e),l={event:i,handler:a,off:()=>{}},d=u(t,n,[i,n===`once`?(e,t)=>(s.delete(l),typeof a==`function`?Reflect.apply(a,null,[e,t]):void 0):a,...o]),f=typeof d==`function`?()=>d():()=>{};return l.off=f,s.add(l),()=>{s.delete(l),f()}},f=(e,t,n)=>{let[r,i]=n,a=c(e);r===void 0&&a.clear();for(let e of[...a])Object.is(l(e.event),l(r))&&(i===void 0||e.handler===i)&&(a.delete(e),e.off());return u(t,`off`,n)},p=e=>{if(!s(e))return;let t=o.get(e);if(t){o.delete(e);for(let e of t)e.off()}},m=/* @__PURE__ */ new Set([`on`,`once`,`off`,`emit`,`ctx`,`actions`,`trace`,`addContext`,`applyScope`,`fitScope`,`app`,`use`]),h=Reflect.get(Symbol,`dispose`),g=e=>typeof e==`function`;var _=class{};const v=(e,t,n,r)=>{n in t||Object.defineProperty(e,n,{configurable:!0,enumerable:!1,...r})},y=/* @__PURE__ */ new WeakMap,b=(e,t)=>{let n=y.get(e);if(n)return n;let r={on:(...n)=>d(e,t,`on`,n),once:(...n)=>d(e,t,`once`,n),off:(...n)=>f(e,t,n)};return y.set(e,r),r},x=(e,t)=>(...n)=>Reflect.apply(Reflect.get(e,t),e,n),S=(e,t)=>{for(let{method:n,spec:r}of a(Reflect.getPrototypeOf(e)??{})){let i=(t,r)=>Reflect.apply(n,e,[t,r]),a=r.wrap?r.wrap(i):i,o=r.once?`once`:`on`;d(e,t,o,[r.event,a,r.options])}},C=(e,t,n)=>{for(let r of[`on`,`once`,`off`])v(e,t,r,{get(){return b(this,n)[r]}});v(e,t,`emit`,{value:x(n,`emit`)});for(let[r,i]of Object.entries(n))typeof i==`function`&&!m.has(r)&&v(e,t,r,{value:x(n,r)});let r=function(){p(this)};v(e,t,`dispose`,{value:r}),h&&v(e,t,h,{value:r}),v(e,t,`bus`,{get:()=>n})},w=(e,t)=>{let n=function(...r){let i=Reflect.construct(t,r,new.target??n);return S(i,e),i};return Object.setPrototypeOf(n,t),n.prototype=Object.create(t.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"name",{value:t.name,configurable:!0}),`bus`in t||Object.defineProperty(n,"bus",{value:e,configurable:!0}),C(n.prototype,t.prototype,e),n};function T(t,n){return g(t)?w(e(),t):w(t,n??_)}function E(e){return t=>e?T(e,t):T(t)}const D=e=>{let[t,n,r]=e;return typeof n==`string`||typeof n==`symbol`?Reflect.get(Object(r),`value`):t},O=(e,n,r,i)=>((...a)=>{let o=D(a);if(typeof o==`function`){let a=typeof n==`function`?n:void 0,s=typeof n==`function`?r:n??r;t.set(o,{event:e,wrap:a,once:i,options:s})}});function k(e,t,n){return O(e,t,n,!1)}function A(e,t,n){return O(e,t,n,!0)}const j=/* @__PURE__ */ new WeakMap,M=t=>{let n=j.get(t);if(n)return n;let r=e();return j.set(t,r),r},N=[`on`,`once`,`off`,`emit`],P=e=>{for(let t of N){let n=Reflect.get(e,t);Reflect.set(e,t,n.bind(e))}};var F=class{constructor(){P(this),S(this,M(this))}get bus(){return M(this)}dispose(){p(this)}};const I={on(...e){return d(this,M(this),`on`,e)},once(...e){return d(this,M(this),`once`,e)},off(...e){return f(this,M(this),e)},emit(...e){let t=M(this);return Reflect.apply(Reflect.get(t,`emit`),t,e)}};for(let e of N)Object.defineProperty(F.prototype,e,{configurable:!0,writable:!0,value:I[e]});h&&Object.defineProperty(F.prototype,h,{configurable:!0,value:function(){this.dispose()}});export{F as Emitter,k as On,A as Once,E as WithBus,p as disposeBus,T as extendBus};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as WithContext, H as EventMap, S as Context, U as Keys, a as FreeActionCreator, d as BoundForm, p as Effects, t as ActionCreator, v as Bus } from "./action-creator-
|
|
2
|
-
import { n as NoClash } from "./context-types-
|
|
1
|
+
import { F as WithContext, H as EventMap, S as Context, U as Keys, a as FreeActionCreator, d as BoundForm, p as Effects, t as ActionCreator, v as Bus } from "./action-creator-CcAEvUnw.js";
|
|
2
|
+
import { n as NoClash } from "./context-types-hCKgU8sC.js";
|
|
3
3
|
//#region src/utils/delay.d.ts
|
|
4
4
|
type Milliseconds = number | (() => number);
|
|
5
5
|
/**
|
package/dist/policies.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { H as EventMap, q as Task } from "./action-creator-
|
|
2
|
-
import { n as withPolicy, t as PolicyFunction } from "./with-policy-
|
|
1
|
+
import { H as EventMap, q as Task } from "./action-creator-CcAEvUnw.js";
|
|
2
|
+
import { n as withPolicy, t as PolicyFunction } from "./with-policy-3bhFLEXs.js";
|
|
3
3
|
//#region src/policies/keyed.d.ts
|
|
4
4
|
/** Options shared by every policy that can keep its state per key. */
|
|
5
5
|
type KeyOption<P> = {
|
package/dist/react.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { D as EventKey, H as EventMap, a as FreeActionCreator, q as Task, t as ActionCreator, v as Bus } from "./action-creator-
|
|
1
|
+
import { D as EventKey, H as EventMap, a as FreeActionCreator, q as Task, t as ActionCreator, v as Bus } from "./action-creator-CcAEvUnw.js";
|
|
2
2
|
import { t as OriginOptions } from "./origin-key-CxK0SkeG.js";
|
|
3
|
-
import { t as PolicyFunction } from "./with-policy-
|
|
3
|
+
import { t as PolicyFunction } from "./with-policy-3bhFLEXs.js";
|
|
4
4
|
import { t as StateOf } from "./state-of-C19H6BoV.js";
|
|
5
5
|
//#region src/react/plugin.d.ts
|
|
6
6
|
/** Tells whether two values are the same: `Object.is` unless the caller gives another. */
|
package/dist/redux.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as EventMap, v as Bus } from "./action-creator-
|
|
1
|
+
import { H as EventMap, v as Bus } from "./action-creator-CcAEvUnw.js";
|
|
2
2
|
import { t as OriginOptions } from "./origin-key-CxK0SkeG.js";
|
|
3
3
|
//#region src/store/redux/middleware.d.ts
|
|
4
4
|
/** What Redux passes through a middleware: an action is a plain object with a `type`. */
|
package/dist/scope.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { H as EventMap, I as WithSignal, c as Scope, f as Effect, m as Signaled, p as Effects, s as EmitScope, v as Bus } from "./action-creator-
|
|
2
|
-
import { n as ScopeSlots, r as Scoped } from "./types-
|
|
1
|
+
import { H as EventMap, I as WithSignal, c as Scope, f as Effect, m as Signaled, p as Effects, s as EmitScope, v as Bus } from "./action-creator-CcAEvUnw.js";
|
|
2
|
+
import { n as ScopeSlots, r as Scoped } from "./types-FV8fuvI9.js";
|
|
3
3
|
//#region src/scope/effect.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Marks a function whose first parameter is `{ signal }` as an effect, so that
|
package/dist/signal.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as EventMap, O as EventLike, T as Emit, s as EmitScope, u as WithScope, v as Bus, x as CommandCall } from "./action-creator-
|
|
1
|
+
import { H as EventMap, O as EventLike, T as Emit, s as EmitScope, u as WithScope, v as Bus, x as CommandCall } from "./action-creator-CcAEvUnw.js";
|
|
2
2
|
//#region src/signal/plugin.d.ts
|
|
3
3
|
/** What the second argument of `emit` takes besides the fields of a scope. */
|
|
4
4
|
type SignalOption = {
|
package/dist/signal.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as e}from"./context-UcmrAIhP.js";import{n as t}from"./promise-CSLpzwSR.js";import{t as n}from"./bus-
|
|
1
|
+
import{u as e}from"./context-UcmrAIhP.js";import{n as t}from"./promise-CSLpzwSR.js";import{t as n}from"./bus-DlpEluzd.js";const r=e=>typeof e==`object`&&!!e,i=(e,t)=>{let n=t[0];if(!r(n)||!r(e)&&typeof e!=`function`)return;let i=Reflect.get(n,`signal`);return i instanceof AbortSignal?i:void 0},a=(r,i,a,o)=>{let s=e({signal:r},e=>{for(let{target:t}of i)t.abort(e)});return t(o)?o.then(s,s):n(a)&&s(),o},o=()=>e=>{let t,n,r=e.addContext;e.addContext=e=>{r?.(e),t?.push({target:e}),n?.aborted&&e.abort(n.reason)};let o=e.emit;return e.emit=(e,...r)=>{let s=i(e,r);if(!(s||t))return o(e,...r);let c=t,l=n,u=[];t=s?u:void 0,n=s;let d;try{d=o(e,...r)}finally{t=c,n=l}return s?a(s,u,e,d):d},e};export{o as signalPlugin};
|
package/dist/svelte.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as EventKey, H as EventMap, a as FreeActionCreator, t as ActionCreator, v as Bus } from "./action-creator-
|
|
1
|
+
import { D as EventKey, H as EventMap, a as FreeActionCreator, t as ActionCreator, v as Bus } from "./action-creator-CcAEvUnw.js";
|
|
2
2
|
import { t as StateOf } from "./state-of-C19H6BoV.js";
|
|
3
3
|
import { Readable } from "svelte/store";
|
|
4
4
|
//#region src/svelte/plugin.d.ts
|
package/dist/trace.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as Tracer, H as EventMap, J as Trace, K as Phase, V as EffectName, X as TraceLogger, Y as TraceEvent, v as Bus } from "./action-creator-
|
|
1
|
+
import { B as Tracer, H as EventMap, J as Trace, K as Phase, V as EffectName, X as TraceLogger, Y as TraceEvent, v as Bus } from "./action-creator-CcAEvUnw.js";
|
|
2
2
|
//#region src/trace/console.d.ts
|
|
3
3
|
type ConsoleLoggerOptions = {
|
|
4
4
|
/** Defaults to `globalThis.console`. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { H as EventMap, c as Scope, l as WithFields, p as Effects } from "./action-creator-
|
|
2
|
-
import { t as BoundOf } from "./plugin-
|
|
1
|
+
import { H as EventMap, c as Scope, l as WithFields, p as Effects } from "./action-creator-CcAEvUnw.js";
|
|
2
|
+
import { t as BoundOf } from "./plugin-CuvIgjnX.js";
|
|
3
3
|
//#region src/scope/types.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* The slots `scopePlugin` fills for `modulePlugin`. They are not on `Bus`: a bus
|
package/dist/vue.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as EventKey, H as EventMap, a as FreeActionCreator, t as ActionCreator, v as Bus } from "./action-creator-
|
|
1
|
+
import { D as EventKey, H as EventMap, a as FreeActionCreator, t as ActionCreator, v as Bus } from "./action-creator-CcAEvUnw.js";
|
|
2
2
|
import { t as OriginOptions } from "./origin-key-CxK0SkeG.js";
|
|
3
3
|
import { t as StateOf } from "./state-of-C19H6BoV.js";
|
|
4
4
|
import { ShallowRef, WatchSource, WatchStopHandle } from "vue";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { G as PayloadOf, H as EventMap, q as Task } from "./action-creator-
|
|
1
|
+
import { G as PayloadOf, H as EventMap, q as Task } from "./action-creator-CcAEvUnw.js";
|
|
2
2
|
//#region src/policies/with-policy.d.ts
|
|
3
3
|
/** What `withPolicy` returns: the task as a plain function that can be cancelled. */
|
|
4
4
|
type PolicyFunction<P, R> = {
|
package/docs/README.md
CHANGED
|
@@ -19,6 +19,7 @@ Code for every guide step: [`examples/guide.ts`](../examples/guide.ts) (type-che
|
|
|
19
19
|
| Already on Redux / Zustand / MobX / Pinia | [Stores](stores.md) |
|
|
20
20
|
| A Node server (Fastify) whose work must stop when the client leaves | [Stop work on a server](server.md) |
|
|
21
21
|
| A React form with async checks | [Build a sign-up form in React](react.md) |
|
|
22
|
+
| A site widget that listens only while open | [Build a chat widget](chat-widget.md) |
|
|
22
23
|
| A Vue app | [Use nanoeffects in a Vue app](vue.md) |
|
|
23
24
|
| A Svelte app | [Use nanoeffects in a Svelte app](svelte.md) |
|
|
24
25
|
| Old responses overwrite new ones | [Cancel stale requests](cancel-stale-requests.md) |
|