nanoeffects 0.23.0 → 0.23.1
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/actions.js +1 -1
- package/dist/notrace/actions.js +1 -1
- package/docs/server.md +1 -4
- package/llms-full.txt +1 -4
- package/package.json +2 -2
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-0RIBGYqS.js";import{r as o}from"./bus-hHp-T7JV.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);function h(e,t,n){let r=typeof t==`function`?t:void 0,i=typeof t==`function`?n:t;return Object.assign(f((...t)=>f({type:e,payload:r?r(...t).payload:t[0]},i),i),{type:e,match:t=>t.type===e,toString:()=>e})}var g=class extends Error{};function _(e,t,n){let r=t=>t.type===e;function i(r,i){if(typeof i==`object`){if(!t)throw new g(`No handler for command "${e}"`);return t(r,i)}return f(o(s,e,r),n)}let a=Object.assign(i,{type:e,match:r}),s=f(a,n);return s}const v=(e,t)=>[e,t],y=e=>typeof Reflect.get(e??{},`handle`)==`function`,b=(e=[])=>t=>{let n=t.commands;if(y(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};return t.commands=s,s},x=()=>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})},S=e=>typeof e==`string`?h(e):e,C=(e,t,n,r)=>{let i=m(t);e.emit(Reflect.apply(t,null,[n]),r&&i?p(r,i):r)},w=(t,r,i,a)=>{let o=t;o[n]=!0;try{C(t,r,i,a)}catch(t){e(`cancel listener`,t)}o[n]=!1},T=e=>{try{return Promise.resolve(e())}catch(e){if(e instanceof g)throw e;return Promise.reject(e)}},E=(t,n,r={},a)=>{let l=_(t,n),u=e=>S(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(),w(s,h,e,a))},_=()=>{l===`idle`&&(l=`started`,u=i(s,g),C(s,d,n,a))},v=e=>{l===`started`&&(f(),s.signal.aborted?w(s,h,s.signal.reason,a):`error`in e?C(s,m,e.error,a):C(s,p,e.value,a))};return Reflect.set(s,c,{start:_,cancel:g,done:v,drop:()=>{l===`idle`&&(l=`closed`)}}),T(()=>(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})})},v=e=>{let t=Reflect.get(e,s)===!0;return(n,r)=>g(e,n,r,t)};function
|
|
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-0RIBGYqS.js";import{r as o}from"./bus-hHp-T7JV.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);function h(e,t,n){let r=typeof t==`function`?t:void 0,i=typeof t==`function`?n:t;return Object.assign(f((...t)=>f({type:e,payload:r?r(...t).payload:t[0]},i),i),{type:e,match:t=>t.type===e,toString:()=>e})}var g=class extends Error{};function _(e,t,n){let r=t=>t.type===e;function i(r,i){if(typeof i==`object`){if(!t)throw new g(`No handler for command "${e}"`);return t(r,i)}return f(o(s,e,r),n)}let a=Object.assign(i,{type:e,match:r}),s=f(a,n);return s}const v=(e,t)=>[e,t],y=e=>typeof Reflect.get(e??{},`handle`)==`function`,b=(e=[])=>t=>{let n=t.commands;if(y(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};return t.commands=s,s},x=()=>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})},S=e=>typeof e==`string`?h(e):e,C=(e,t,n,r)=>{let i=m(t);e.emit(Reflect.apply(t,null,[n]),r&&i?p(r,i):r)},w=(t,r,i,a)=>{let o=t;o[n]=!0;try{C(t,r,i,a)}catch(t){e(`cancel listener`,t)}o[n]=!1},T=e=>{try{return Promise.resolve(e())}catch(e){if(e instanceof g)throw e;return Promise.reject(e)}},E=(t,n,r={},a)=>{let l=_(t,n),u=e=>S(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(),w(s,h,e,a))},_=()=>{l===`idle`&&(l=`started`,u=i(s,g),C(s,d,n,a))},v=e=>{l===`started`&&(f(),s.signal.aborted?w(s,h,s.signal.reason,a):`error`in e?C(s,m,e.error,a):C(s,p,e.value,a))};return Reflect.set(s,c,{start:_,cancel:g,done:v,drop:()=>{l===`idle`&&(l=`closed`)}}),T(()=>(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})})},v=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(E,t,e),a)}let x=Object.assign(b,{type:t,match:l.match,wrap:v,pending:d,success:p,fail:m,cancel:h}),E=f(x,a);return E},D=e=>typeof e==`object`&&!!e,O=e=>{if(typeof e==`string`)return e;if(D(e)||typeof e==`function`){let t=Reflect.get(e,`type`);return typeof t==`string`?t:e}return e},k=(e,t)=>{let[n,r]=e;return n===void 0||Object.is(O(n),O(t[0]))&&(r===void 0||Object.is(r,t[1]))},A=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`&&k(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 j(e,t,n){return n?{name:e,setup:t,scope:n}:{name:e,setup:t}}const M=(e,t)=>n=>t?e.fitScope?.(t,n)??n:n,N=(e,t,n)=>{n&&e.applyScope?.(t,n)},P=(e,t,n)=>Array.isArray(t)?[t.map(([t,n])=>[t,e(n)]),n]:[t,e(n)],F=(e,t)=>{let n=e.on;return(...e)=>{let[r,i,...a]=e;return Reflect.apply(n,null,[r,t(i),...a])}},I=e=>(t,...n)=>{e.run(t,...n).catch(t=>{if(!e.signal.aborted)throw t})},L=(n=[])=>a=>{let o=a.commands??b()(a),s={handle:(...e)=>{if(!o.handle)throw Error("modulePlugin: the `commands` of the bus is not a registry from `commandsPlugin()`");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=M(a,h),_=(e,t)=>{let n=Reflect.apply(s.handle,null,P(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=I(f),b=F(f,g);try{N(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=A(a),u=a.emit,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:d(c(t.ctx))};try{e&&f.apps.mount(...n)}finally{l.replay()}return f},m=(...e)=>(p(),Reflect.apply(u,a,e));a.emit=m,n.length>0&&queueMicrotask(()=>{try{p()}catch(t){e(`the modules of the app could not start`,t)}});let h={get commands(){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:j};return a.app=h,h};export{v as bindHandler,b as commandsPlugin,h as createAction,_ as createCommand,E as createJob,j as createModule,x as emitterPlugin,L as modulePlugin};
|
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-BdyvumpX.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);function m(e,t,n){let r=typeof t==`function`?t:void 0,i=typeof t==`function`?n:t;return Object.assign(d((...t)=>d({type:e,payload:r?r(...t).payload:t[0]},i),i),{type:e,match:t=>t.type===e,toString:()=>e})}var h=class extends Error{};function g(e,t,n){let r=t=>t.type===e;function i(r,i){if(typeof i==`object`){if(!t)throw new h(`No handler for command "${e}"`);return t(r,i)}return d(a(s,e,r),n)}let o=Object.assign(i,{type:e,match:r}),s=d(o,n);return s}const _=(e,t)=>[e,t],v=e=>typeof Reflect.get(e??{},`handle`)==`function`,y=(e=[])=>t=>{let n=t.commands;if(v(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};return t.commands=s,s},b=()=>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})},x=e=>typeof e==`string`?m(e):e,S=(e,t,n,r)=>{let i=p(t);e.emit(Reflect.apply(t,null,[n]),r&&i?f(r,i):r)},C=(e,t,r,a)=>{let o=e;o[i]=!0;try{S(e,t,r,a)}catch(e){n(`cancel listener`,e)}o[i]=!1},w=e=>{try{return Promise.resolve(e())}catch(e){if(e instanceof h)throw e;return Promise.reject(e)}},T=(t,r,i={},o)=>{let l=g(t,r),u=e=>x(i[e]??`${t}/${e}`),f=u(`pending`),p=u(`success`),m=u(`fail`),h=u(`cancel`),_=(t,r,i,a)=>{let s=i,l=`idle`,u=()=>{},d=()=>{l=`closed`,u()},g=e=>{l===`started`&&(d(),C(s,h,e,o))},_=()=>{l===`idle`&&(l=`started`,u=e(s,g),S(s,f,r,o))},v=e=>{l===`started`&&(d(),s.signal.aborted?C(s,h,s.signal.reason,o):`error`in e?S(s,m,e.error,o):S(s,p,e.value,o))};return Reflect.set(s,c,{start:_,cancel:g,done:v,drop:()=>{l===`idle`&&(l=`closed`)}}),w(()=>(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)=>_(e,n,r,t)};function
|
|
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-BdyvumpX.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);function m(e,t,n){let r=typeof t==`function`?t:void 0,i=typeof t==`function`?n:t;return Object.assign(d((...t)=>d({type:e,payload:r?r(...t).payload:t[0]},i),i),{type:e,match:t=>t.type===e,toString:()=>e})}var h=class extends Error{};function g(e,t,n){let r=t=>t.type===e;function i(r,i){if(typeof i==`object`){if(!t)throw new h(`No handler for command "${e}"`);return t(r,i)}return d(a(s,e,r),n)}let o=Object.assign(i,{type:e,match:r}),s=d(o,n);return s}const _=(e,t)=>[e,t],v=e=>typeof Reflect.get(e??{},`handle`)==`function`,y=(e=[])=>t=>{let n=t.commands;if(v(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};return t.commands=s,s},b=()=>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})},x=e=>typeof e==`string`?m(e):e,S=(e,t,n,r)=>{let i=p(t);e.emit(Reflect.apply(t,null,[n]),r&&i?f(r,i):r)},C=(e,t,r,a)=>{let o=e;o[i]=!0;try{S(e,t,r,a)}catch(e){n(`cancel listener`,e)}o[i]=!1},w=e=>{try{return Promise.resolve(e())}catch(e){if(e instanceof h)throw e;return Promise.reject(e)}},T=(t,r,i={},o)=>{let l=g(t,r),u=e=>x(i[e]??`${t}/${e}`),f=u(`pending`),p=u(`success`),m=u(`fail`),h=u(`cancel`),_=(t,r,i,a)=>{let s=i,l=`idle`,u=()=>{},d=()=>{l=`closed`,u()},g=e=>{l===`started`&&(d(),C(s,h,e,o))},_=()=>{l===`idle`&&(l=`started`,u=e(s,g),S(s,f,r,o))},v=e=>{l===`started`&&(d(),s.signal.aborted?C(s,h,s.signal.reason,o):`error`in e?S(s,m,e.error,o):S(s,p,e.value,o))};return Reflect.set(s,c,{start:_,cancel:g,done:v,drop:()=>{l===`idle`&&(l=`closed`)}}),w(()=>(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)=>_(e,n,r,t)},y=Reflect.get(r??{},s)===!0;function b(e,n){return typeof n==`object`?r?_(l,e,n,y):Reflect.apply(l,null,[e,n]):d(a(E,t,e),o)}let T=Object.assign(b,{type:t,match:l.match,wrap:v,pending:f,success:p,fail:m,cancel:h}),E=d(T,o);return E},E=e=>typeof e==`object`&&!!e,D=e=>{if(typeof e==`string`)return e;if(E(e)||typeof e==`function`){let t=Reflect.get(e,`type`);return typeof t==`string`?t:e}return e},O=(e,t)=>{let[n,r]=e;return n===void 0||Object.is(D(n),D(t[0]))&&(r===void 0||Object.is(r,t[1]))},k=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`&&O(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)}}}}},A=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 j(e,t,n){return n?{name:e,setup:t,scope:n}:{name:e,setup:t}}const M=(e,t)=>n=>t?e.fitScope?.(t,n)??n:n,N=(e,t,n)=>{n&&e.applyScope?.(t,n)},P=(e,t,n)=>Array.isArray(t)?[t.map(([t,n])=>[t,e(n)]),n]:[t,e(n)],F=(e,t)=>{let n=e.on;return(...e)=>{let[r,i,...a]=e;return Reflect.apply(n,null,[r,t(i),...a])}},I=e=>(t,...n)=>{e.run(t,...n).catch(t=>{if(!e.signal.aborted)throw t})},L=(i=[])=>a=>{let o=a.commands??y()(a),s={handle:(...e)=>{if(!o.handle)throw Error("modulePlugin: the `commands` of the bus is not a registry from `commandsPlugin()`");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=M(a,h),_=(t,n)=>{let r=Reflect.apply(s.handle,null,P(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=I(f),b=F(f,g);try{N(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=k(a),u=a.emit,d,f=(e=!0)=>{if(d)return d;l.release(),a.emit===p&&(a.emit=u);let t=r({event:{type:`app`,payload:void 0},bus:a,tracer:a.trace});d={root:t,apps:A(c(t.ctx))};try{e&&d.apps.mount(...i)}finally{l.replay()}return d},p=(...e)=>(f(),Reflect.apply(u,a,e));a.emit=p,i.length>0&&queueMicrotask(()=>{try{f()}catch(e){n(`the modules of the app could not start`,e)}});let m={get commands(){return f(),o},mount:(...e)=>{let{root:t,apps:n}=f();return t.ctx.signal.throwIfAborted(),n.mount(...e)},unmount:(...e)=>f().apps.unmount(...e),isMounted:e=>f().apps.isMounted(e),dispose:()=>f(!1).root.ctx.abort(),createModule:j};return a.app=m,m};export{_ as bindHandler,y as commandsPlugin,m as createAction,g as createCommand,T as createJob,j as createModule,b as emitterPlugin,L as modulePlugin};
|
package/docs/server.md
CHANGED
|
@@ -189,10 +189,7 @@ The [ws-server example](../examples/ws-server) adds a close for a silent socket,
|
|
|
189
189
|
|
|
190
190
|
A worker takes jobs from a client and answers at once, and the work goes on in the background. Use `createJob` with `queue` to limit how many run together, `retry` and `timeout` to give up, and the outcomes of the job (`pending`, `success`, `fail`, `cancel`) to count them. Give every `emit` of the job the same signal; aborting it at shutdown cancels the jobs that are left.
|
|
191
191
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
- Bind the handler with `commands.handle(job, queue(...))` (or `m.handle` in a module), not as the second argument of `createJob`. Only a bound handler lets the job learn from the policy when a call really starts, so `pending` is sent at the start and not at the call.
|
|
195
|
-
- A call that is still waiting in the queue when the signal aborts never starts, and the job sends no outcome for it. Count such calls yourself if you need the totals to add up.
|
|
192
|
+
One detail matters: a call that is still waiting in the queue when the signal aborts never starts, and the job sends no outcome for it. Count such calls yourself if you need the totals to add up.
|
|
196
193
|
|
|
197
194
|
The [job-worker example](../examples/job-worker) has all of it: the counts, `GET /stats`, and a shutdown in three steps (stop taking jobs, wait, abort the rest).
|
|
198
195
|
|
package/llms-full.txt
CHANGED
|
@@ -3288,10 +3288,7 @@ The [ws-server example](../examples/ws-server) adds a close for a silent socket,
|
|
|
3288
3288
|
|
|
3289
3289
|
A worker takes jobs from a client and answers at once, and the work goes on in the background. Use `createJob` with `queue` to limit how many run together, `retry` and `timeout` to give up, and the outcomes of the job (`pending`, `success`, `fail`, `cancel`) to count them. Give every `emit` of the job the same signal; aborting it at shutdown cancels the jobs that are left.
|
|
3290
3290
|
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
- Bind the handler with `commands.handle(job, queue(...))` (or `m.handle` in a module), not as the second argument of `createJob`. Only a bound handler lets the job learn from the policy when a call really starts, so `pending` is sent at the start and not at the call.
|
|
3294
|
-
- A call that is still waiting in the queue when the signal aborts never starts, and the job sends no outcome for it. Count such calls yourself if you need the totals to add up.
|
|
3291
|
+
One detail matters: a call that is still waiting in the queue when the signal aborts never starts, and the job sends no outcome for it. Count such calls yourself if you need the totals to add up.
|
|
3295
3292
|
|
|
3296
3293
|
The [job-worker example](../examples/job-worker) has all of it: the counts, `GET /stats`, and a shutdown in three steps (stop taking jobs, wait, abort the rest).
|
|
3297
3294
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nanoeffects",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.1",
|
|
4
4
|
"description": "Cancel stale async work and fix race conditions in event handlers: a typed event bus where every handler is a task with an AbortSignal, plus latest, debounce, throttle, queue, retry, timeout and poll. About 1.4 kB gzip.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"event-bus",
|
|
@@ -225,7 +225,7 @@
|
|
|
225
225
|
{
|
|
226
226
|
"name": "actions (all)",
|
|
227
227
|
"path": "dist/actions.js",
|
|
228
|
-
"limit": "3.
|
|
228
|
+
"limit": "3.1 kB"
|
|
229
229
|
},
|
|
230
230
|
{
|
|
231
231
|
"name": "match (plugin)",
|