nanoeffects 0.28.0 → 0.29.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/{action-creator-CcAEvUnw.d.ts → action-creator-jeEqIKgK.d.ts} +34 -32
- package/dist/actions.d.ts +18 -18
- package/dist/actions.js +1 -1
- package/dist/bus-0uYn_kRj.js +1 -0
- package/dist/context-DtUnzC-1.js +1 -0
- package/dist/context-types-Bme1mzkn.d.ts +31 -0
- package/dist/context.d.ts +8 -3
- package/dist/context.js +1 -1
- package/dist/{delay-18LJ8jSk.js → delay-5OhJZZQ0.js} +1 -1
- package/dist/dev.d.ts +2 -2
- package/dist/effects.d.ts +2 -2
- package/dist/effects.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/match.d.ts +3 -3
- package/dist/match.js +1 -1
- package/dist/{module-C_oEXw1n.d.ts → module-BWMW83qk.d.ts} +38 -38
- package/dist/notrace/{action-creator-DxOvVo8I.d.ts → action-creator-xpQ_I2h8.d.ts} +34 -32
- package/dist/notrace/actions.d.ts +52 -52
- package/dist/notrace/actions.js +1 -1
- package/dist/notrace/{bus-DmKn4SDD.js → bus-37nlVljc.js} +1 -1
- package/dist/notrace/effects.d.ts +2 -2
- package/dist/notrace/index.d.ts +2 -2
- package/dist/notrace/index.js +1 -1
- package/dist/notrace/{plugin-lJjjd-SN.d.ts → plugin-6LhNx0th.d.ts} +1 -1
- package/dist/notrace/policies.d.ts +1 -1
- package/dist/notrace/redux.d.ts +1 -1
- package/dist/observable.d.ts +43 -1
- package/dist/observable.js +1 -1
- package/dist/onAbort-BgMfspK4.js +1 -0
- package/dist/oop.d.ts +3 -3
- package/dist/oop.js +1 -1
- package/dist/{plugin-CuvIgjnX.d.ts → plugin-BaErevLy.d.ts} +2 -2
- package/dist/policies.d.ts +2 -2
- package/dist/policies.js +1 -1
- package/dist/react.d.ts +2 -2
- package/dist/react.js +1 -1
- package/dist/redux.d.ts +1 -1
- package/dist/scope.d.ts +9 -9
- package/dist/signal-field-key-CWT-3OXC.js +1 -0
- package/dist/signal.d.ts +34 -6
- package/dist/signal.js +1 -1
- package/dist/svelte.d.ts +1 -1
- package/dist/trace.d.ts +20 -5
- package/dist/trace.js +1 -1
- package/dist/{types-FV8fuvI9.d.ts → types-D5xsR37j.d.ts} +2 -2
- package/dist/vue.d.ts +1 -1
- package/dist/{with-policy-3bhFLEXs.d.ts → with-policy-BZVRBUOm.d.ts} +1 -1
- package/dist/{with-policy-D-SQRkPh.js → with-policy-C6BIiPIi.js} +1 -1
- package/docs/README.md +13 -1
- package/docs/actions.md +27 -1
- package/docs/chat-example.md +12 -0
- package/docs/chat-widget.md +7 -7
- package/docs/context.md +33 -1
- package/docs/effects.md +20 -9
- package/docs/guide.md +20 -2
- package/docs/migrating-from-effector.md +11 -0
- package/docs/observable.md +43 -0
- package/docs/oop.md +17 -0
- package/docs/package.md +22 -13
- package/docs/plugins.md +69 -11
- package/docs/query-libraries.md +273 -5
- package/docs/react.md +12 -2
- package/docs/scope.md +14 -2
- package/docs/semantics.md +10 -0
- package/docs/server.md +3 -3
- package/docs/stability.md +2 -2
- package/docs/tracing.md +74 -6
- package/docs/typescript.md +1 -1
- package/llms-full.txt +671 -66
- package/llms.txt +7 -7
- package/package.json +4 -4
- package/skills/nanoeffects/SKILL.md +2 -2
- package/dist/bus-DlpEluzd.js +0 -1
- package/dist/context-UcmrAIhP.js +0 -1
- package/dist/context-types-hCKgU8sC.d.ts +0 -14
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-37nlVljc.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 action "${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};
|
|
@@ -1 +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,`
|
|
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,`action`,()=>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,
|
|
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, _ as Context, u as Effect } from "./action-creator-xpQ_I2h8.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-6LhNx0th.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
|
|
2
|
-
export { type Action, type Actions, type AnyEvent, type Bus, type BusOptions, type Call, type
|
|
1
|
+
import { A as Off, B as Task, C as EventLike, D as HandledCall, E as Handled, F as createBus, L as EventMap, M as WithContext, N as WithSignal, O as Handler, P as WithType, R as Keys, S as EventKey, T as EventsOf, V as UnsubscribeCallback, _ as Context, a as WithPayload, b as Emit, 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 ContextOf, w as EventPayload, x as Emittable, y as ContextOption, z as PayloadOf } from "./action-creator-xpQ_I2h8.js";
|
|
2
|
+
export { type Action, type Actions, type AnyEvent, type Bus, type BusOptions, type Call, type Context, type ContextOf, type ContextOption, type Emit, type Emittable, type EventKey, type EventLike, type EventMap, type EventPayload, type EventsOf, type Handled, type HandledCall, 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-37nlVljc.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { L as EventMap, M as WithContext, R as Keys,
|
|
1
|
+
import { L as EventMap, M as WithContext, R as Keys, _ as Context, d as Effects, h as Bus, i as FreeActionCreator, l as BoundForm, t as ActionCreator, v as ContextOf } from "./action-creator-xpQ_I2h8.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-xpQ_I2h8.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/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-xpQ_I2h8.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, P as On, U as Keys, a as FreeActionCreator, k as Handled, r as DataOf, t as ActionCreator, v as Bus } from "./action-creator-jeEqIKgK.js";
|
|
2
2
|
//#region src/observable.d.ts
|
|
3
3
|
declare global {
|
|
4
4
|
interface SymbolConstructor {
|
|
@@ -46,4 +46,46 @@ export declare class Subject<E extends EventMap, K extends Keys<E>> implements O
|
|
|
46
46
|
};
|
|
47
47
|
next(payload: DataOf<E[K]>): void;
|
|
48
48
|
}
|
|
49
|
+
/** What `events` reads: a bus, or a task context, which also ends the stream when its task aborts. */
|
|
50
|
+
export type EventSource<E extends EventMap> = {
|
|
51
|
+
on: On<E>;
|
|
52
|
+
signal?: AbortSignal | undefined;
|
|
53
|
+
};
|
|
54
|
+
/** What `events` does when the loop is slower than the emits and the buffer is full. */
|
|
55
|
+
export type Overflow = "drop-oldest" | "drop-newest";
|
|
56
|
+
export type EventsOptions = {
|
|
57
|
+
/** Ends the stream: a waiting or next read rejects with the abort reason. */
|
|
58
|
+
signal?: AbortSignal | undefined;
|
|
59
|
+
/** The most payloads held while the loop is busy. Default: `Infinity`. */
|
|
60
|
+
buffer?: number | undefined;
|
|
61
|
+
/** Which payload is lost when the buffer is full. Default: `"drop-oldest"`. */
|
|
62
|
+
overflow?: Overflow | undefined;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* One event of a bus as an async iterator, for `for await`. It listens from the
|
|
66
|
+
* call, not from the first read, so a payload between the two is not lost. The
|
|
67
|
+
* loop ends with `break`, with the `signal` (the read rejects with the abort
|
|
68
|
+
* reason) or, when `source` is a task context, with its task.
|
|
69
|
+
*
|
|
70
|
+
* While the loop is busy the payloads wait in a buffer that has no limit unless
|
|
71
|
+
* `buffer` is set; when it is full `overflow` says which payload goes. An event of
|
|
72
|
+
* a bus does not end, so the stream does not either.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* const controller = new AbortController();
|
|
77
|
+
*
|
|
78
|
+
* // events — the "query/changed" payloads one by one; at most the last 3 are kept
|
|
79
|
+
* const queries = events(bus, "query/changed", {
|
|
80
|
+
* signal: controller.signal,
|
|
81
|
+
* buffer: 3,
|
|
82
|
+
* });
|
|
83
|
+
* for await (const query of queries) {
|
|
84
|
+
* await search(query);
|
|
85
|
+
* }
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
export declare function events<E extends EventMap, K extends Keys<E>>(source: EventSource<E>, event: K, options?: EventsOptions): AsyncIterableIterator<DataOf<E[K]>>;
|
|
89
|
+
export declare function events<E extends EventMap, K extends Keys<E>>(source: EventSource<E>, event: FreeActionCreator<K>, options?: EventsOptions): AsyncIterableIterator<DataOf<E[K]>>;
|
|
90
|
+
export declare function events<E extends EventMap, P>(source: EventSource<E>, event: ActionCreator<P> | Handled<P, unknown>, options?: EventsOptions): AsyncIterableIterator<P>;
|
|
49
91
|
//#endregion
|
package/dist/observable.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
import{t as e}from"./onAbort-BgMfspK4.js";const t=typeof Symbol==`function`&&Symbol.observable||`@@observable`,n=e=>t=>{typeof e==`function`?e(t):e.next?.(t)},r=e=>r=>({subscribe:t=>({unsubscribe:e.on(r,n(t))}),[t](){return this}});var i=class{source;event;constructor(e,t){this.source=e,this.event=t,this.next=this.next.bind(this)}subscribe(e){return{unsubscribe:this.source.on(this.event,n(e))}}next(e){let t=this.source.emit;Reflect.apply(t,this.source,[this.event,e])}[t](){return this}};function a(t,n,r={}){let i=r.buffer??1/0,a=r.overflow===`drop-newest`,o=[],s=0,c=[],l=!1,u,d=[],f=e=>{if(l)return;l=!0;for(let e of d)e();o=[],s=0;let t=c.shift();e&&t?t.reject(e.reason):e&&(u=e);for(let e of c.splice(0))e.resolve({done:!0,value:void 0});t?.resolve({done:!0,value:void 0})},p=e=>{let t=c.shift();if(t)t.resolve({done:!1,value:e});else if(!(i<1)){if(o.length-s>=i){if(a)return;o[s++]=void 0}o.push(e)}},m=t.on;d.push(m(n,p)),d.push(e(t,e=>f({reason:e}))),d.push(e(r,e=>f({reason:e})));let h={next:()=>{if(s<o.length){let e=o[s];return o[s++]=void 0,s>1024&&s*2>o.length&&(o=o.slice(s),s=0),Promise.resolve({done:!1,value:e})}if(u){let{reason:e}=u;return u=void 0,Promise.reject(e)}return l?Promise.resolve({done:!0,value:void 0}):new Promise((e,t)=>{c.push({resolve:e,reject:t})})},return:()=>(f(),Promise.resolve({done:!0,value:void 0})),[Symbol.asyncIterator]:()=>h};return h}export{t as $$observable,i as Subject,r as createObserve,a as events};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=(e,t)=>{globalThis.console?.error(`[nanoeffects] ${e}`,t)},t=()=>{},n=/* @__PURE__ */ new WeakMap,r=t=>{let r=n.get(t);if(r)return r;let i=/* @__PURE__ */ new Set;return n.set(t,i),t.addEventListener(`abort`,()=>{let n=[...i];i.clear();for(let{fn:r}of n)try{r(t.reason)}catch(t){e(`abort callback failed`,t)}},{once:!0}),i},i=(e,n)=>{let{signal:i}=e;if(!i)return t;if(i.aborted)return n(i.reason),t;let a=r(i),o={fn:n};return a.add(o),()=>{a.delete(o)}};export{e as n,i as t};
|
package/dist/oop.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as EventMap, W as ListenerOptions,
|
|
1
|
+
import { H as EventMap, W as ListenerOptions, k as Handled, t as ActionCreator, v as Bus } from "./action-creator-jeEqIKgK.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;
|
|
@@ -32,14 +32,14 @@ type Handler<P> = (payload: P, ctx: never) => unknown;
|
|
|
32
32
|
/**
|
|
33
33
|
* What `@On(event)` and `@Once(event)` return: a method decorator of the
|
|
34
34
|
* language and of `experimentalDecorators`. The payload of the method is
|
|
35
|
-
* checked against the event when the event is an action creator
|
|
35
|
+
* checked against the event when the event is an action creator.
|
|
36
36
|
*/
|
|
37
37
|
interface MethodDecorator<P> {
|
|
38
38
|
(value: Handler<P>, context: ClassMethodDecoratorContext): void;
|
|
39
39
|
(target: object, key: string | symbol, descriptor: TypedPropertyDescriptor<Handler<P>>): void;
|
|
40
40
|
}
|
|
41
41
|
/** The events a decorator takes. */
|
|
42
|
-
type EventOf<P> = ActionCreator<P> |
|
|
42
|
+
type EventOf<P> = ActionCreator<P> | Handled<P, unknown>;
|
|
43
43
|
//#endregion
|
|
44
44
|
//#region src/oop/decorators.d.ts
|
|
45
45
|
/**
|
package/dist/oop.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{t as e}from"./bus-0uYn_kRj.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,
|
|
2
|
-
import {
|
|
1
|
+
import { F as WithContext, H as EventMap, U as Keys, a as FreeActionCreator, b as Context, d as BoundForm, p as Effects, t as ActionCreator, v as Bus } from "./action-creator-jeEqIKgK.js";
|
|
2
|
+
import { r as NoClash } from "./context-types-Bme1mzkn.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-jeEqIKgK.js";
|
|
2
|
+
import { n as withPolicy, t as PolicyFunction } from "./with-policy-BZVRBUOm.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/policies.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,r as t,t as n}from"./delay-
|
|
1
|
+
import{n as e,r as t,t as n}from"./delay-5OhJZZQ0.js";import{t as r}from"./onAbort-BgMfspK4.js";import{i,o as a,s as o,t as s}from"./context-DtUnzC-1.js";import{n as c,t as l}from"./promise-CSLpzwSR.js";import{n as u,t as d}from"./lifecycle-key-8iX8RUVD.js";import{t as f}from"./with-policy-C6BIiPIi.js";const p=e=>Reflect.get(e,d),m=e=>{p(e)?.start()},h=(e,t,n)=>(m(e),a(e,t,n)),g=(e,t)=>{o(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,u,!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 a=null;return(l,u)=>{if(a?.abort(),u.signal.aborted)return;let{ctx:d,unlink:f}=i(u);a=d;let p=s(d,e),h=!1,g=()=>{d.signal.aborted||(h=!0,m(d),o(d,e,`start`))};r(d,e=>{v(d,h,e),p(h?`cancel`:`drop`)});let _=()=>{f(),a===d&&(a=null,n())},y=e=>{if(!d.signal.aborted)return p(h?`done`:`drop`),e};try{let e=t(l,d,g);return c(e)?Promise.resolve(e).then(y,e=>{if(!d.signal.aborted)throw p(`error`,e),e}).finally(_):(_(),y(e))}catch(e){if(_(),d.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,i,a)=>{let o=i.leading??!1,s=i.trailing??!0;if(!s)return k(e,t,o,a);let c=!1,l=0,u=E(`debounce`,([i,a],o,u)=>{let d=l;return r(o,()=>{l===d&&(c=!1)}),n(o,e).then(()=>{if(c=!1,s&&!a)return u(),t(i,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(i,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=r(a,s);try{return l(h(a,`leading`,()=>e(i,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 i=t.concurrency??1,a=t.limit??1/0,o=[],s=0,c=()=>{for(;s<i;){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,i=()=>{c(),s===0&&o.length===0&&n()},a=(e=!1)=>{t&&(t=!1,s--,e?queueMicrotask(i):i())},g=r(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<i){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=r(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)}};export{D as debounce,w as latest,j as leading,N as queue,I as throttle,f as withPolicy};
|
package/dist/react.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { H as EventMap, T as EventKey, a as FreeActionCreator, q as Task, t as ActionCreator, v as Bus } from "./action-creator-jeEqIKgK.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-BZVRBUOm.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/react.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./with-policy-
|
|
1
|
+
import{t as e}from"./with-policy-C6BIiPIi.js";import{t}from"./origin-key-BbWN3gmN.js";import{useEffect as n,useMemo as r,useRef as i,useState as a}from"react";const o=()=>e=>{function r(r,a,o){let s=i(a),c=i({event:r,options:o});n(()=>{c.current={event:r,options:o}}),n(()=>{let{event:n,options:r}=c.current,i=r?.equals??Object.is,o=s.current;if(i(o,a))return;s.current=a;let l=typeof n==`function`?n(a):{type:n,payload:a},u=Reflect.get(e,t);u?u(l,r??{}):e.emit(l)},[a])}function o(t,r){let[i,o]=a(r);return n(()=>{let n=t;return e.on(n,e=>{let t=e;o(()=>t)})},[t]),[i,o]}return Object.assign(e,{useEmitter:r,useEventState:o})},s=(t,a,o=[])=>{let s=i(t);n(()=>{s.current=t});let c=r(()=>e(a((e,t)=>s.current(e,t))),o);return n(()=>()=>c.cancel(),[c]),c};export{o as reactPlugin,s as usePolicy};
|
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-jeEqIKgK.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-jeEqIKgK.js";
|
|
2
|
+
import { n as ScopeSlots, r as Scoped } from "./types-D5xsR37j.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
|
|
@@ -16,7 +16,7 @@ import { n as ScopeSlots, r as Scoped } from "./types-FV8fuvI9.js";
|
|
|
16
16
|
* ```ts
|
|
17
17
|
* const first = effect(<T>(ctx: WithSignal, items: T[]) => items[0]);
|
|
18
18
|
*
|
|
19
|
-
* const getUser =
|
|
19
|
+
* const getUser = createAction(
|
|
20
20
|
* "user/get",
|
|
21
21
|
* (id: string, { first }) => first([id]), // first: <T>(items: T[]) => T
|
|
22
22
|
* { first },
|
|
@@ -27,11 +27,11 @@ export declare function effect<A extends unknown[], R>(fn: (ctx: WithSignal, ...
|
|
|
27
27
|
//#endregion
|
|
28
28
|
//#region src/scope/plugin.d.ts
|
|
29
29
|
/**
|
|
30
|
-
* Switches scopes on for a bus: the scope given to
|
|
31
|
-
*
|
|
30
|
+
* Switches scopes on for a bus: the scope given to an action, a job
|
|
31
|
+
* or a module (an object whose keys go on `ctx`, with `$effects` bound to
|
|
32
32
|
* the task), and the second argument of `emit`, put fields on
|
|
33
33
|
* the context of the tasks they are for. A stronger layer replaces a field of
|
|
34
|
-
* the same name: `emit`, then action /
|
|
34
|
+
* the same name: `emit`, then action / job, then module, then the bus.
|
|
35
35
|
* Fields of the library (`signal`, `emit`, `run`, …) are never replaced. Returns
|
|
36
36
|
* the same bus.
|
|
37
37
|
*
|
|
@@ -41,13 +41,13 @@ export declare function effect<A extends unknown[], R>(fn: (ctx: WithSignal, ...
|
|
|
41
41
|
* @example
|
|
42
42
|
* ```ts
|
|
43
43
|
* import { createBus } from "nanoeffects";
|
|
44
|
-
* import {
|
|
44
|
+
* import { createAction } from "nanoeffects/actions";
|
|
45
45
|
* import { scopePlugin } from "nanoeffects/scope";
|
|
46
46
|
*
|
|
47
47
|
* const bus = createBus().use(scopePlugin()); // scopes work on this bus
|
|
48
48
|
*
|
|
49
|
-
* const getUser =
|
|
50
|
-
* http, // a field of this
|
|
49
|
+
* const getUser = createAction("user/get", (id: string, { http }) => http.get(id), {
|
|
50
|
+
* http, // a field of this action only
|
|
51
51
|
* });
|
|
52
52
|
* bus.emit(getUser("1"), { http: fakeHttp }); // this call only
|
|
53
53
|
* ```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=Symbol.for(`nanoeffects.signalField`);export{e as t};
|
package/dist/signal.d.ts
CHANGED
|
@@ -1,4 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as HandledCall, C as Emit, E as EventLike, H as EventMap, s as EmitScope, u as WithScope, v as Bus } from "./action-creator-jeEqIKgK.js";
|
|
2
|
+
import { n as FromSignal } from "./context-types-Bme1mzkn.js";
|
|
3
|
+
//#region src/signal/from-signal.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Marks a field of `contextPlugin` as a value that needs the signal of its task: a
|
|
6
|
+
* client, a database handle. `make` runs when the task first reads the field, with the
|
|
7
|
+
* `ctx.signal` of that task, and runs once for it. A child task (`ctx.run`) makes its
|
|
8
|
+
* own with its own signal. Without `contextPlugin` the marker means nothing.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const bus = createBus().use(
|
|
13
|
+
* contextPlugin({
|
|
14
|
+
* logger, // a plain field, the same for every task
|
|
15
|
+
* http: fromSignal((signal) => axios.create({ signal })), // one client per task, aborted with it
|
|
16
|
+
* }),
|
|
17
|
+
* );
|
|
18
|
+
*
|
|
19
|
+
* bus.on("user/open", (id, { http }) => http.get(`/users/${id}`));
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare const fromSignal: <T>(make: (signal: AbortSignal) => T) => FromSignal<T>;
|
|
23
|
+
//#endregion
|
|
2
24
|
//#region src/signal/plugin.d.ts
|
|
3
25
|
/** What the second argument of `emit` takes besides the fields of a scope. */
|
|
4
26
|
type SignalOption = {
|
|
@@ -7,8 +29,8 @@ type SignalOption = {
|
|
|
7
29
|
};
|
|
8
30
|
/** `emit` of a bus with `signalPlugin`: the call forms take `{ signal }` as their second argument. */
|
|
9
31
|
type SignalEmit<E extends EventMap> = Emit<E> & {
|
|
10
|
-
<P, R, F>(call:
|
|
11
|
-
<P, R>(call:
|
|
32
|
+
<P, R, F>(call: HandledCall<P, R> & WithScope<F>, options: SignalOption & EmitScope<E, F>): R;
|
|
33
|
+
<P, R>(call: HandledCall<P, R>, options: SignalOption & EmitScope<E>): R;
|
|
12
34
|
(event: EventLike<E>, options: SignalOption & EmitScope<E>): void;
|
|
13
35
|
};
|
|
14
36
|
/** A bus with `signalPlugin`: the same bus, with the `emit` that takes a signal. */
|
|
@@ -16,16 +38,22 @@ type SignalBus<E extends EventMap> = Bus<E> & {
|
|
|
16
38
|
emit: SignalEmit<E>;
|
|
17
39
|
};
|
|
18
40
|
/**
|
|
41
|
+
* Also lets `bus.on(event, handler, { signal })` and `bus.once` remove the
|
|
42
|
+
* listener when the signal aborts, as `addEventListener` does, so a component or
|
|
43
|
+
* a script that holds a signal keeps no `unbind`. A handler that already runs is
|
|
44
|
+
* not aborted; a signal that is aborted already adds no listener. `off(event, fn)`
|
|
45
|
+
* does not end the link: the returned function does.
|
|
46
|
+
*
|
|
19
47
|
* Lets `bus.emit(call, { signal })` tie the tasks that this emit starts to an
|
|
20
48
|
* outside `AbortSignal`: when it aborts, their `ctx.signal` aborts with the same
|
|
21
49
|
* reason, so a handler, `latest`, `retry` and `timeout` stop as for any abort. It
|
|
22
50
|
* is made for libraries that own the request and give you a signal, such as the
|
|
23
51
|
* `queryFn` of React Query. The tasks that count are those made while the call
|
|
24
|
-
* to `emit` runs (the
|
|
52
|
+
* to `emit` runs (the action or job and the listeners of its type, and their
|
|
25
53
|
* `ctx.run` children); a separate `emit` that a handler makes later is not
|
|
26
54
|
* linked. `emit` returns what it returns without the plugin.
|
|
27
55
|
*
|
|
28
|
-
* For
|
|
56
|
+
* For an action or a job the link ends when its promise settles; a handler
|
|
29
57
|
* that returns without a promise is finished with the call, so it is not
|
|
30
58
|
* linked after it. For an event the link stays until the signal aborts, so
|
|
31
59
|
* give each request its own signal.
|
|
@@ -48,4 +76,4 @@ type SignalBus<E extends EventMap> = Bus<E> & {
|
|
|
48
76
|
*/
|
|
49
77
|
export declare const signalPlugin: () => <E extends EventMap>(bus: Bus<E>) => SignalBus<E>;
|
|
50
78
|
//#endregion
|
|
51
|
-
export type { SignalBus, SignalEmit, SignalOption };
|
|
79
|
+
export type { FromSignal, SignalBus, SignalEmit, SignalOption };
|
package/dist/signal.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{t as e}from"./onAbort-BgMfspK4.js";import{n as t}from"./promise-CSLpzwSR.js";import{n}from"./bus-0uYn_kRj.js";import{t as r}from"./signal-field-key-CWT-3OXC.js";const i=e=>({[r]:e}),a=(t,n)=>(r,i,a)=>{let o=a?.signal;if(!o)return t(r,i,a);let s=t(r,n?(e,t)=>(c(),i(e,t)):i,a),c=e({signal:o},s);return()=>{c(),s()}},o=e=>typeof e==`object`&&!!e,s=(e,t)=>{let n=t[0];if(!o(n)||!o(e)&&typeof e!=`function`)return;let r=Reflect.get(n,`signal`);return r instanceof AbortSignal?r:void 0},c=(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},l=()=>e=>{let t,n,r=e.addContext;e.addContext=e=>{r?.(e),t?.push({target:e}),n?.aborted&&e.abort(n.reason)};let i=e.emit;e.emit=(e,...r)=>{let a=s(e,r);if(!(a||t))return i(e,...r);let o=t,l=n,u=[];t=a?u:void 0,n=a;let d;try{d=i(e,...r)}finally{t=o,n=l}return a?c(a,u,e,d):d};let o=e.on,l=e.once;return e.on=a(o,!1),e.once=a(l,!0),e};export{i as fromSignal,l as signalPlugin};
|
package/dist/svelte.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { H as EventMap, T as EventKey, a as FreeActionCreator, t as ActionCreator, v as Bus } from "./action-creator-jeEqIKgK.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-jeEqIKgK.js";
|
|
2
2
|
//#region src/trace/console.d.ts
|
|
3
3
|
type ConsoleLoggerOptions = {
|
|
4
4
|
/** Defaults to `globalThis.console`. */
|
|
@@ -52,7 +52,7 @@ export declare const performanceLogger: (options?: PerformanceLoggerOptions) =>
|
|
|
52
52
|
/**
|
|
53
53
|
* Names and groups what the trace shows, on a bus that has a tracer:
|
|
54
54
|
*
|
|
55
|
-
* - `traceGroupId` in the scope of
|
|
55
|
+
* - `traceGroupId` in the scope of an action, a job or an action goes to every
|
|
56
56
|
* task that the call starts;
|
|
57
57
|
* - `useEmitter` and `bus.emitter` emit from a root task named by their
|
|
58
58
|
* `traceId`, so a chain says which subscription began it;
|
|
@@ -80,12 +80,21 @@ export declare const tracePlugin: () => <E extends EventMap>(bus: Bus<E>) => Bus
|
|
|
80
80
|
//#endregion
|
|
81
81
|
//#region src/trace/recorder.d.ts
|
|
82
82
|
type Recorder<E = Record<string, unknown>> = TraceLogger<E> & {
|
|
83
|
-
/**
|
|
83
|
+
/**
|
|
84
|
+
* The events received so far, oldest first. Without a `capacity` it is one
|
|
85
|
+
* live array; with one, each read is a new array that is a snapshot.
|
|
86
|
+
*/
|
|
84
87
|
readonly events: TraceEvent<E>[];
|
|
85
88
|
clear: () => void;
|
|
86
89
|
};
|
|
87
90
|
/**
|
|
88
|
-
* Trace logger that keeps events in memory
|
|
91
|
+
* Trace logger that keeps events in memory. With no option it keeps all of
|
|
92
|
+
* them, for tests. With `capacity` it keeps the last events, to send when
|
|
93
|
+
* something goes wrong.
|
|
94
|
+
*
|
|
95
|
+
* `payload` and `error` are kept as they are, and can hold private data: cut
|
|
96
|
+
* what you send. An event has no time, and a `parentId` can name an event that
|
|
97
|
+
* was pushed out: read it as a root.
|
|
89
98
|
*
|
|
90
99
|
* @example
|
|
91
100
|
* ```ts
|
|
@@ -95,9 +104,15 @@ type Recorder<E = Record<string, unknown>> = TraceLogger<E> & {
|
|
|
95
104
|
* bus.emit("search", "re");
|
|
96
105
|
* bus.emit("search", "redux");
|
|
97
106
|
* recorder.events.map((e) => e.phase); // ["start", "cancel", "start", "done"]
|
|
107
|
+
*
|
|
108
|
+
* const lastEvents = createTraceRecorder<Events>({ capacity: 500 });
|
|
98
109
|
* ```
|
|
99
110
|
*/
|
|
100
|
-
export declare const createTraceRecorder: <E = Record<string, unknown>>(
|
|
111
|
+
export declare const createTraceRecorder: <E = Record<string, unknown>>(
|
|
112
|
+
/** `capacity`: keep the last N events (a ring buffer); not a positive integer, or left out: keep all. */
|
|
113
|
+
options?: {
|
|
114
|
+
capacity?: number;
|
|
115
|
+
}) => Recorder<E>;
|
|
101
116
|
//#endregion
|
|
102
117
|
//#region src/trace/redux.d.ts
|
|
103
118
|
type ReduxConnection = {
|
package/dist/trace.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{n as e,t}from"./onAbort-BgMfspK4.js";import{a as n,c as r,n as i,o as a,r as o,s}from"./context-DtUnzC-1.js";import{n as c}from"./promise-CSLpzwSR.js";import{t as l}from"./origin-key-BbWN3gmN.js";import{t as u}from"./scope-key-B7l7mUS5.js";const d=(e={})=>{let t=e.console??globalThis.console,n=e.prefix??`[nanoeffects]`,r=/* @__PURE__ */ new Map;return({id:e,parentId:i,type:a,effect:o,phase:s,payload:c,error:l,traceGroupId:u})=>{r.has(e)||r.set(e,typeof i==`number`?(r.get(i)??0)+1:0);let d=` `.repeat(r.get(e)??0);s!==`start`&&r.delete(e);let f=u===void 0?``:` [${u}]`,p=`${n}${f} ${d}${a} · ${o} ${s}`;s===`error`?t?.error(p,l):t?.debug(p,c)}},f=(e={})=>{let t=e.performance??globalThis.performance,n=/* @__PURE__ */ new Map;return({id:e,parentId:r,rootId:i,traceGroupId:a,type:o,effect:s,phase:c,error:l})=>{if(!t)return;if(c===`start`){n.set(e,t.now());return}let u=`${o} · ${s} (${c})`,d={id:e,parentId:r,...i!==void 0&&{rootId:i},...a!==void 0&&{traceGroupId:a},phase:c,...c===`error`&&{error:String(l)}},f=n.get(e);n.delete(e),typeof f==`number`?t.measure(u,{start:f,end:t.now(),detail:d}):t.mark(u,{detail:d})}};let p;const m=()=>p,h=(e,t)=>{let n=p;p=e;try{return t()}finally{p=n}},g=(e,t,n={})=>{let{trace:r}=e;if(!r){e.emit(t);return}let{traceId:a,traceGroupId:o}=n,{ctx:c,unlink:l}=i({event:{type:a??t.type,payload:t,...o===void 0?{}:{traceGroupId:o}},bus:{emit:e.emit,on:e.on,off:e.off,ctx:e.ctx,addContext:e.addContext},tracer:r});s(c,`run`,`start`);try{c.emit(t),s(c,`run`,`done`)}catch(e){throw s(c,`run`,`error`,e),e}finally{l()}},_=e=>typeof e==`string`?e:Reflect.get(Object(e),`type`),v=(e,t)=>typeof e==`object`?Reflect.get(Object(e),`payload`):t[0],y=()=>e=>{if(!(r&&e.trace))return e;let{trace:t}=e,i=(e,n)=>{let r=t.task({type:_(e),payload:v(e,n)},o());t.report(r,`emit`,`done`)},s=e.emit;e.emit=(e,...t)=>h(e,()=>(i(e,t),s(e,...t))),Reflect.set(e,l,(t,n)=>{g(e,t,n)});let c=/* @__PURE__ */ new WeakMap,u=(e,t,n)=>{let r=c.get(t)??/* @__PURE__ */ new Map,i=_(e);r.set(i,[...r.get(i)??[],n]),c.set(t,r)},d=(e,t)=>(c.get(t)?.get(_(e)))?.pop(),f=(e,t)=>(r,i)=>(n(i,t),a(i,`run`,()=>e(r,i))),p=(e,t)=>(n,r,i)=>{let a=Reflect.get(Object(i),`traceId`);if(typeof a!=`string`)return e(n,r,i);let o=t?(e,t)=>(d(n,r),f(r,a)(e,t)):f(r,a);u(n,r,o);let s=e(n,o,i);return()=>{s()}},m=e.off,y=(e,t)=>{t===void 0?m(e):m(e,d(e,t)??t)},b=e.on,x=e.once;return e.on=p(b,!1),e.once=p(x,!0),e.off=y,e},b=e=>{let t=e?.capacity??0,n=Number.isInteger(t)&&t>0?t:0,r=[],i=0,a=e=>{n===0?r.push(e):(r[i%n]=e,i+=1)},o=()=>{r.length=0,i=0},s=()=>{let e=Math.min(i,n),t=i>n?i%n:0,a=[];for(let i=0;i<e;i+=1){let e=r[(t+i)%n];e&&a.push(e)}return a},c=Object.assign(a,{clear:o,events:r});return n>0&&Object.defineProperty(c,"events",{get:s}),c},x=()=>{},S=/* @__PURE__ */ new Set([`cancel`,`drop`,`error`]),C=()=>!1,w=()=>!0,T=e=>{if(typeof e==`function`)return e;if(Array.isArray(e)){let t=new Set(e);return({phase:e})=>t.has(e)}return e?w:C},E=(e={})=>{let t=e.extension??globalThis.__REDUX_DEVTOOLS_EXTENSION__;if(!t)return x;let{starts:n=!1,depth:r=0,maxAge:i}=e,a=T(e.policies),o=e.payload??`essential`,s=t.connect({name:e.name??`nanoeffects`,...i!==void 0&&{maxAge:i}}),c=/* @__PURE__ */ new Map,l=/* @__PURE__ */ new Map,u=()=>({running:Object.fromEntries(c)});s.init(u());let d=(e,t,n)=>n===0?a({effect:e,phase:t}):n<=r,f=(e,t)=>{e.phase===`start`?(l.set(e.id,t),d(e.effect,`start`,t)&&c.set(e.id,{type:e.type,effect:e.effect,...e.traceGroupId!==void 0&&{traceGroupId:e.traceGroupId}})):(l.delete(e.id),c.delete(e.id))},p=!1,m=!1,h=(e,t)=>{p||m||t!==0||e===`start`||(m=!0,globalThis.console?.warn(`[nanoeffects] reduxDevtools got a task but no emit event: add bus.use(tracePlugin()) to see the emits.`))},g=e=>{let{payload:t,...n}=e;return o===`all`||o===`essential`&&(e.effect===`emit`||S.has(e.phase))?{...n,payload:t}:n},_=(e,t)=>{s.send({...g(e),type:`${e.type}/${e.effect}/${e.phase}`,event:e.type,...e.phase===`error`&&{error:t instanceof Error?t.message:t}},u())};return({error:e,...t})=>{if(t.effect===`emit`){p=!0,s.send({...g(t),event:t.type},u());return}let r=(t.parentId===void 0?-1:l.get(t.parentId)??-1)+1;f(t,r),h(t.phase,r),(t.phase===`error`&&r===0||d(t.effect,t.phase,r))&&(t.phase!==`start`||n)&&_(t,e)}},D=t=>{let n=typeof t==`function`?[t]:[...t??[]];return n.length===0?null:t=>{for(let r of n)try{r(t)}catch(t){e(`trace logger failed`,t)}}},O=()=>{},k=e=>{if(typeof e.traceGroupId==`string`)return e.traceGroupId;let t=m();if(typeof t!=`object`&&typeof t!=`function`||t===null)return;let n=Reflect.get(t,u),r=typeof n==`object`&&n?Reflect.get(n,`traceGroupId`):void 0;return typeof r==`string`?r:void 0},A=(e,n={})=>{let r=D(e),{filter:i,sample:a=1}=n,o=0,s=e=>typeof a==`function`?a({type:e.type,payload:e.payload}):Math.random()<a,l={task:(e,t)=>({id:++o,root:t?.root??o,parent:t?.id,type:e.type,payload:e.payload,sampled:t?.sampled??s(e),group:k(e)??t?.group}),rename:(e,t)=>{e.type=t},report:(e,t,n,a)=>{if(!e.sampled)return;let o={id:e.id,type:e.type,effect:t,phase:n,payload:e.payload};typeof e.parent==`number`&&(o.parentId=e.parent),e.root!==e.id&&(o.rootId=e.root),e.group!==void 0&&(o.traceGroupId=e.group),n===`error`&&(o.error=a),(!i||i(o))&&r?.(o)},settler:(e,t)=>{if(!e.sampled)return O;let n=!1;return(r,i)=>{n||(n=!0,l.report(e,t,r,i))}},run:(e,n,r,i)=>{if(!e.sampled)return i();let a=l.settler(e,n);l.report(e,n,`start`),t({signal:r},()=>a(`cancel`));let o;try{o=i()}catch(e){throw a(`error`,e),e}return c(o)?Promise.resolve(o).then(e=>(a(`done`),e),e=>{throw a(`error`,e),e}):(a(`done`),o)}};return l};export{d as consoleLogger,b as createTraceRecorder,A as createTracer,f as performanceLogger,E as reduxDevtools,y as tracePlugin};
|
|
@@ -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-jeEqIKgK.js";
|
|
2
|
+
import { t as BoundOf } from "./plugin-BaErevLy.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 {
|
|
1
|
+
import { H as EventMap, T as EventKey, a as FreeActionCreator, t as ActionCreator, v as Bus } from "./action-creator-jeEqIKgK.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-jeEqIKgK.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> = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./context-
|
|
1
|
+
import{n as e}from"./context-DtUnzC-1.js";const t=Reflect.get(Symbol,`dispose`),n=n=>{let r=new AbortController,i=async(...t)=>{let i=t[0],{ctx:a,unlink:o}=e({event:{type:`withPolicy`,payload:i},parent:{signal:r.signal}});try{return await n(i,a)}finally{o()}},a=e=>{r.abort(e),r=new AbortController},o=Object.assign(i,{cancel:a});return t&&Reflect.set(o,t,()=>a()),o};export{n as t};
|
package/docs/README.md
CHANGED
|
@@ -8,6 +8,18 @@ Why the library exists (logic and side effects outside React, Vue and Svelte com
|
|
|
8
8
|
|
|
9
9
|
Code for every guide step: [`examples/guide.ts`](../examples/guide.ts) (type-checked and tested).
|
|
10
10
|
|
|
11
|
+
## Start with three imports
|
|
12
|
+
|
|
13
|
+
Most apps need only these. Everything else is optional; read it when you hit its need.
|
|
14
|
+
|
|
15
|
+
| Import | Gives you |
|
|
16
|
+
| ------ | --------- |
|
|
17
|
+
| `nanoeffects` | `createBus`: `on`, `emit`, `ctx` |
|
|
18
|
+
| `nanoeffects/policies` | `latest`, `debounce`, ... for races in async UI |
|
|
19
|
+
| `nanoeffects/effects` | `retry`, `timeout`, `poll`, ... for an unreliable network |
|
|
20
|
+
|
|
21
|
+
The other entries and plugins: [Package entries](package.md) and [Plugins](plugins.md#pick-a-plugin-by-task).
|
|
22
|
+
|
|
11
23
|
## Jump by project need
|
|
12
24
|
|
|
13
25
|
| Project shape | First page |
|
|
@@ -40,7 +52,7 @@ Code for every guide step: [`examples/guide.ts`](../examples/guide.ts) (type-che
|
|
|
40
52
|
- [nanoeffects in a Svelte app](svelte.md) — `eventStore`
|
|
41
53
|
- [Context fields](context.md) — store or client on every task
|
|
42
54
|
- [Use the bus from a class](oop.md) — `extendBus`, `@WithBus`, `@On`, and `dispose()` for the subscriptions of an instance
|
|
43
|
-
- [TypeScript in many files](typescript.md) — keep the types of the bus in
|
|
55
|
+
- [TypeScript in many files](typescript.md) — keep the types of the bus in actions and modules
|
|
44
56
|
- [Errors and unheard events](errors.md)
|
|
45
57
|
- [Package entries](package.md) — which import holds what
|
|
46
58
|
- [Stability](stability.md) — which entries are stable, what is breaking, supported versions
|