nanoeffects 0.28.0 → 0.30.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.
Files changed (139) hide show
  1. package/README.md +6 -5
  2. package/dist/{action-creator-CcAEvUnw.d.ts → action-creator-6rlBTmH9.d.ts} +60 -33
  3. package/dist/actions.d.ts +18 -18
  4. package/dist/actions.js +1 -1
  5. package/dist/bus-DFlmNJ6h.js +1 -0
  6. package/dist/context-B5Z2RpJt.js +1 -0
  7. package/dist/context-types-DKNc5mkS.d.ts +31 -0
  8. package/dist/context.d.ts +8 -3
  9. package/dist/context.js +1 -1
  10. package/dist/{delay-18LJ8jSk.js → delay-5OhJZZQ0.js} +1 -1
  11. package/dist/dev.d.ts +44 -3
  12. package/dist/dev.js +2 -1
  13. package/dist/effects.d.ts +2 -2
  14. package/dist/effects.js +1 -1
  15. package/dist/emit-key-C6FL7Ewn.js +1 -0
  16. package/dist/guard.d.ts +59 -0
  17. package/dist/guard.js +1 -0
  18. package/dist/index.d.ts +2 -2
  19. package/dist/index.js +1 -1
  20. package/dist/match.d.ts +3 -3
  21. package/dist/match.js +1 -1
  22. package/dist/{module-C_oEXw1n.d.ts → module-G39MaVOt.d.ts} +38 -38
  23. package/dist/notrace/{action-creator-DxOvVo8I.d.ts → action-creator-BrMSO3RP.d.ts} +35 -32
  24. package/dist/notrace/actions.d.ts +52 -52
  25. package/dist/notrace/actions.js +1 -1
  26. package/dist/notrace/{bus-DmKn4SDD.js → bus-37nlVljc.js} +1 -1
  27. package/dist/notrace/effects.d.ts +2 -2
  28. package/dist/notrace/index.d.ts +2 -2
  29. package/dist/notrace/index.js +1 -1
  30. package/dist/notrace/{plugin-lJjjd-SN.d.ts → plugin-7GUL2EW5.d.ts} +1 -1
  31. package/dist/notrace/policies.d.ts +1 -1
  32. package/dist/notrace/redux.d.ts +1 -1
  33. package/dist/observable.d.ts +43 -1
  34. package/dist/observable.js +1 -1
  35. package/dist/onAbort-BgMfspK4.js +1 -0
  36. package/dist/oop.d.ts +3 -3
  37. package/dist/oop.js +1 -1
  38. package/dist/{plugin-CuvIgjnX.d.ts → plugin-BWNP23hr.d.ts} +2 -2
  39. package/dist/policies.d.ts +2 -2
  40. package/dist/policies.js +1 -1
  41. package/dist/production/dev.js +1 -1
  42. package/dist/react.d.ts +2 -2
  43. package/dist/react.js +1 -1
  44. package/dist/redux.d.ts +1 -1
  45. package/dist/scope.d.ts +9 -9
  46. package/dist/signal-field-key-CWT-3OXC.js +1 -0
  47. package/dist/signal.d.ts +34 -6
  48. package/dist/signal.js +1 -1
  49. package/dist/site-DLvUoXs3.js +1 -0
  50. package/dist/svelte.d.ts +1 -1
  51. package/dist/trace.d.ts +170 -6
  52. package/dist/trace.js +3 -1
  53. package/dist/{types-FV8fuvI9.d.ts → types-N_cdRr1r.d.ts} +2 -2
  54. package/dist/vue.d.ts +1 -1
  55. package/dist/{with-policy-D-SQRkPh.js → with-policy-CeM1rtES.js} +1 -1
  56. package/dist/{with-policy-3bhFLEXs.d.ts → with-policy-CthiBp_z.d.ts} +1 -1
  57. package/docs/README.md +65 -22
  58. package/docs/actions.md +56 -13
  59. package/docs/cancel-stale-requests.md +2 -0
  60. package/docs/chat-example.md +15 -1
  61. package/docs/chat-widget.md +9 -7
  62. package/docs/context.md +352 -8
  63. package/docs/debounce-and-abort.md +3 -1
  64. package/docs/debugging-loops.md +283 -0
  65. package/docs/effects.md +259 -131
  66. package/docs/errors.md +4 -2
  67. package/docs/examples.md +60 -0
  68. package/docs/guide.md +57 -22
  69. package/docs/hmr.md +35 -1
  70. package/docs/loop-guard.md +109 -0
  71. package/docs/migrating-from-effector.md +15 -2
  72. package/docs/migrating-from-mitt.md +6 -4
  73. package/docs/migrating-from-rxjs.md +2 -0
  74. package/docs/migrating-from-saga.md +2 -0
  75. package/docs/motivation.md +14 -21
  76. package/docs/observable.md +45 -0
  77. package/docs/oop.md +20 -1
  78. package/docs/package.md +25 -13
  79. package/docs/pass-the-signal.md +281 -0
  80. package/docs/plugins.md +90 -15
  81. package/docs/policies.md +73 -46
  82. package/docs/prevent-double-submit.md +3 -1
  83. package/docs/query-libraries.md +276 -6
  84. package/docs/react.md +50 -11
  85. package/docs/recipes.md +528 -0
  86. package/docs/ru/README.md +62 -0
  87. package/docs/ru/actions.md +412 -0
  88. package/docs/ru/cancel-stale-requests.md +106 -0
  89. package/docs/ru/chat-example.md +259 -0
  90. package/docs/ru/chat-widget.md +131 -0
  91. package/docs/ru/context.md +401 -0
  92. package/docs/ru/debounce-and-abort.md +105 -0
  93. package/docs/ru/debugging-loops.md +283 -0
  94. package/docs/ru/effects.md +538 -0
  95. package/docs/ru/errors.md +36 -0
  96. package/docs/ru/examples.md +60 -0
  97. package/docs/ru/guide.md +530 -0
  98. package/docs/ru/hmr.md +83 -0
  99. package/docs/ru/loop-guard.md +109 -0
  100. package/docs/ru/migrating-from-effector.md +339 -0
  101. package/docs/ru/migrating-from-mitt.md +99 -0
  102. package/docs/ru/migrating-from-rxjs.md +197 -0
  103. package/docs/ru/migrating-from-saga.md +97 -0
  104. package/docs/ru/motivation.md +47 -0
  105. package/docs/ru/observable.md +233 -0
  106. package/docs/ru/oop.md +431 -0
  107. package/docs/ru/package.md +42 -0
  108. package/docs/ru/pass-the-signal.md +281 -0
  109. package/docs/ru/plugins.md +398 -0
  110. package/docs/ru/policies.md +201 -0
  111. package/docs/ru/prevent-double-submit.md +122 -0
  112. package/docs/ru/query-libraries.md +392 -0
  113. package/docs/ru/react.md +309 -0
  114. package/docs/ru/recipes.md +528 -0
  115. package/docs/ru/semantics.md +19 -0
  116. package/docs/ru/server.md +204 -0
  117. package/docs/ru/starter.md +118 -0
  118. package/docs/ru/stores.md +673 -0
  119. package/docs/ru/svelte.md +78 -0
  120. package/docs/ru/tracing.md +466 -0
  121. package/docs/ru/typescript.md +170 -0
  122. package/docs/ru/vue.md +92 -0
  123. package/docs/semantics.md +12 -0
  124. package/docs/server.md +5 -3
  125. package/docs/starter.md +2 -0
  126. package/docs/stores.md +2 -0
  127. package/docs/svelte.md +3 -1
  128. package/docs/tracing.md +132 -7
  129. package/docs/typescript.md +3 -1
  130. package/docs/vue.md +3 -1
  131. package/llms-full.txt +2718 -545
  132. package/llms.txt +17 -14
  133. package/package.json +25 -8
  134. package/skills/nanoeffects/SKILL.md +2 -2
  135. package/dist/bus-DlpEluzd.js +0 -1
  136. package/dist/context-UcmrAIhP.js +0 -1
  137. package/dist/context-types-hCKgU8sC.d.ts +0 -14
  138. package/docs/scope.md +0 -266
  139. package/docs/stability.md +0 -90
@@ -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-DxOvVo8I.js";
2
- import { t as BoundOf } from "./plugin-lJjjd-SN.js";
1
+ import { B as Task, D as HandledCall, E as Handled, I as handledCall, L as EventMap, S as EventKey, V as UnsubscribeCallback, _ as Context, 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, z as PayloadOf } from "./action-creator-BrMSO3RP.js";
2
+ import { t as BoundOf } from "./plugin-7GUL2EW5.js";
3
3
  import { t as OriginOptions } from "./origin-key-CxK0SkeG.js";
4
4
  //#region src/scope/types.d.ts
5
5
  /**
@@ -23,11 +23,11 @@ type FieldsOfScope<E extends EventMap, S extends Scope> = [keyof S] extends [nev
23
23
  */
24
24
  type Scoped<E extends EventMap, S extends Scope> = WithFields<E, FieldsOfScope<E, S>>;
25
25
  //#endregion
26
- //#region src/actions/command.d.ts
27
- /** What `createCommand` returns: a command that also tells whether an action is of its type. */
28
- type MadeCommand<P, R, T extends string> = Command<P, R> & {
26
+ //#region src/actions/handled.d.ts
27
+ /** What `createAction` returns: an action that also tells whether an action is of its type. */
28
+ type MadeHandled<P, R, T extends string> = Handled<P, R> & {
29
29
  readonly type: T;
30
- /** Tells whether an action has the type of this command, and narrows its type. */
30
+ /** Tells whether an action has the type of this action, and narrows its type. */
31
31
  match(action: {
32
32
  type: string;
33
33
  payload?: unknown;
@@ -37,14 +37,14 @@ type MadeCommand<P, R, T extends string> = Command<P, R> & {
37
37
  };
38
38
  };
39
39
  /** `Made`, called so that its calls carry the scope fields `F`; `Made` itself when there are none. */
40
- type CarryingCalls<Made, P, R, F> = [unknown] extends [F] ? Made : ((payload: P) => CommandCall<P, R> & WithScope<F>) & Made & WithScope<F>;
41
- /** A command made with a scope: its calls carry the fields of that scope, for the checker. */
42
- type ScopedCommand<P, R, T extends string, F> = ((payload: P) => CommandCall<P, R> & WithScope<F>) & MadeCommand<P, R, T> & WithScope<F>;
43
- /** A command (or its type) with the handler to bind to it; `setHandler` makes one. */
44
- type Binding<E extends EventMap = EventMap> = readonly [Command<never, unknown> | string, Task<never, E, unknown>];
40
+ type CarryingCalls<Made, P, R, F> = [unknown] extends [F] ? Made : ((payload: P) => HandledCall<P, R> & WithScope<F>) & Made & WithScope<F>;
41
+ /** An action made with a scope: its calls carry the fields of that scope, for the checker. */
42
+ type ScopedHandled<P, R, T extends string, F> = ((payload: P) => HandledCall<P, R> & WithScope<F>) & MadeHandled<P, R, T> & WithScope<F>;
43
+ /** An action (or its type) with the handler to bind to it; `setHandler` makes one. */
44
+ type Binding<E extends EventMap = EventMap> = readonly [Handled<never, unknown> | string, Task<never, E, unknown>];
45
45
  /**
46
46
  * Pairs an action with the handler to bind to it, for `actionsPlugin`. For a
47
- * command (an action made with a handler, or with a `Call` type) it checks that
47
+ * action (an action made with a handler, or with a `Call` type) it checks that
48
48
  * the handler fits; any other action is accepted with a handler of any payload.
49
49
  *
50
50
  * @example
@@ -52,21 +52,21 @@ type Binding<E extends EventMap = EventMap> = readonly [Command<never, unknown>
52
52
  * bus.use(actionsPlugin([setHandler(sendMail, smtpSend)]));
53
53
  * ```
54
54
  */
55
- export declare function setHandler<P, R, E extends EventMap>(command: Command<P, R>, fn: Task<P, E, R>): Binding<E>;
55
+ export declare function setHandler<P, R, E extends EventMap>(handled: Handled<P, R>, fn: Task<P, E, R>): Binding<E>;
56
56
  export declare function setHandler<A extends {
57
57
  readonly type: string;
58
58
  }, E extends EventMap>(action: A, fn: LooseHandler<A, E>): Binding<E>;
59
59
  /**
60
- * The handler an action that is not a command can have: any. A command
61
- * (a creator whose calls are command calls) is not accepted here, so its own
60
+ * The handler an action that is not an action can have: any. An action
61
+ * (a creator whose calls are calls of an action with a handler) is not accepted here, so its own
62
62
  * overload checks the handler against its payload and result.
63
63
  */
64
64
  type LooseHandler<A, E extends EventMap> = A extends ((...args: never[]) => {
65
- readonly [commandCall]: unknown;
65
+ readonly [handledCall]: unknown;
66
66
  }) ? never : Task<never, E, unknown>;
67
67
  /** The registry of handlers that `actionsPlugin` returns: `run` for the bus, `handle` to bind more. */
68
68
  interface Registry$1<E extends EventMap> extends Actions {
69
- handle<P, R>(command: Command<P, R>, fn: Task<P, E, R>): UnsubscribeCallback;
69
+ handle<P, R>(handled: Handled<P, R>, fn: Task<P, E, R>): UnsubscribeCallback;
70
70
  /** Also an action made without a handler: what is emitted for its type runs `fn` and returns its result. */
71
71
  handle<A extends {
72
72
  readonly type: string;
@@ -75,38 +75,38 @@ interface Registry$1<E extends EventMap> extends Actions {
75
75
  handle(bindings: readonly Binding<E>[]): UnsubscribeCallback;
76
76
  }
77
77
  /**
78
- * The plugin that gives a bus the handlers bound to commands:
78
+ * The plugin that gives a bus the handlers bound to actions:
79
79
  * `bus.use(actionsPlugin(bindings))` makes the registry, sets it as the
80
- * commands of the bus and returns it. Each bus has its own, so each test can
80
+ * actions of the bus and returns it. Each bus has its own, so each test can
81
81
  * have its own implementation. `handle` binds more later and returns the
82
82
  * function that unbinds. A second `actionsPlugin` on the same bus binds its
83
83
  * list in the registry that is there and returns it, so the order of the
84
- * plugins does not matter. A `commands` that is not such a registry (a custom
84
+ * plugins does not matter. A `actions` that is not such a registry (a custom
85
85
  * runner) is replaced.
86
86
  *
87
- * What the bus runs for a command: the handler bound last, else the one the
88
- * command was created with, else it throws `No handler for command "..."`.
87
+ * What the bus runs for an action: the handler bound last, else the one the
88
+ * action was created with, else it throws `No handler for action "..."`.
89
89
  *
90
90
  * @example
91
91
  * ```ts
92
92
  * const bus = createBus<Events>();
93
- * const commands = bus.use(actionsPlugin([setHandler(sendMail, smtpSend)]));
93
+ * const actions = bus.use(actionsPlugin([setHandler(sendMail, smtpSend)]));
94
94
  *
95
- * const unbind = commands.handle(getUser, async () => fakeUser);
96
- * unbind(); // the command's own handler is back
95
+ * const unbind = actions.handle(getUser, async () => fakeUser);
96
+ * unbind(); // the action's own handler is back
97
97
  * ```
98
98
  */
99
99
  export declare const actionsPlugin: <E extends EventMap>(bindings?: readonly Binding<E>[]) => (bus: Bus<E>) => Registry$1<E>;
100
100
  //#endregion
101
101
  //#region src/actions/action.d.ts
102
102
  type Reserved = "handle" | "prepare";
103
- type Made<P, T extends string> = [P] extends [Free] ? FreeActionCreator<T> : [P] extends [Call<infer Q, infer R>] ? MadeCommand<Q, R, T> : ActionCreator<P, T>;
103
+ type Made<P, T extends string> = [P] extends [Free] ? FreeActionCreator<T> : [P] extends [Call<infer Q, infer R>] ? MadeHandled<Q, R, T> : ActionCreator<P, T>;
104
104
  type ScopedCreator<P, T extends string, F> = [P] extends [Free] ? FreeActionCreator<T, F> & WithScope<F> : ActionCreator<P, T, PayloadOf<P>, F> & WithScope<F>;
105
105
  type ScopeOf<S> = Omit<S, Reserved>;
106
- type PreparedCommand<P, R, T extends string, A extends unknown[], F> = ((...args: A) => ReturnType<MadeCommand<P, R, T>> & WithScope<F>) & Omit<MadeCommand<P, R, T>, never> & WithScope<F>;
106
+ type PreparedHandled<P, R, T extends string, A extends unknown[], F> = ((...args: A) => ReturnType<MadeHandled<P, R, T>> & WithScope<F>) & Omit<MadeHandled<P, R, T>, never> & WithScope<F>;
107
107
  /**
108
108
  * Creates an action creator, as in Redux Toolkit. With a handler it makes a
109
- * command: `bus.emit(getUser("1"))` runs the handler and returns its result.
109
+ * action: `bus.emit(getUser("1"))` runs the handler and returns its result.
110
110
  *
111
111
  * - `createAction("user/loaded")` needs no generics: the payload type comes
112
112
  * from the event map of the bus that the action goes to, and the literal
@@ -150,22 +150,22 @@ type PreparedCommand<P, R, T extends string, A extends unknown[], F> = ((...args
150
150
  * ```
151
151
  */
152
152
  export declare function createAction<P = Free, T extends string = string>(type: T): Made<P, T>;
153
- export declare function createAction<P = void, R = void, T extends string = string, E extends EventMap = EventMap>(type: T, handler: Task<P, E, R>): MadeCommand<P, R, T>;
153
+ export declare function createAction<P = void, R = void, T extends string = string, E extends EventMap = EventMap>(type: T, handler: Task<P, E, R>): MadeHandled<P, R, T>;
154
154
  export declare function createAction<P, R, A extends unknown[], T extends string, S extends Scope = Record<never, never>>(type: T, handler: Task<P, Scoped<EventMap, ScopeOf<S>>, R>, options: {
155
155
  prepare: (...args: A) => {
156
156
  payload: P;
157
157
  };
158
- } & S): PreparedCommand<P, R, T, A, FieldsOfScope<EventMap, ScopeOf<S>>>;
158
+ } & S): PreparedHandled<P, R, T, A, FieldsOfScope<EventMap, ScopeOf<S>>>;
159
159
  export declare function createAction<P, R, A extends unknown[], T extends string, S extends Scope = Record<never, never>>(type: T, options: {
160
160
  handle: Task<P, Scoped<EventMap, ScopeOf<S>>, R>;
161
161
  prepare: (...args: A) => {
162
162
  payload: P;
163
163
  };
164
- } & S): PreparedCommand<P, R, T, A, FieldsOfScope<EventMap, ScopeOf<S>>>;
165
- export declare function createAction<P, R, T extends string, S extends Scope = Record<never, never>>(type: T, handler: Task<P, Scoped<EventMap, S>, R>, scope: S): ScopedCommand<P, R, T, FieldsOfScope<EventMap, S>>;
164
+ } & S): PreparedHandled<P, R, T, A, FieldsOfScope<EventMap, ScopeOf<S>>>;
165
+ export declare function createAction<P, R, T extends string, S extends Scope = Record<never, never>>(type: T, handler: Task<P, Scoped<EventMap, S>, R>, scope: S): ScopedHandled<P, R, T, FieldsOfScope<EventMap, S>>;
166
166
  export declare function createAction<P, R, T extends string, S extends Scope = Record<never, never>>(type: T, options: {
167
167
  handle: Task<P, Scoped<EventMap, ScopeOf<S>>, R>;
168
- } & S): ScopedCommand<P, R, T, FieldsOfScope<EventMap, ScopeOf<S>>>;
168
+ } & S): ScopedHandled<P, R, T, FieldsOfScope<EventMap, ScopeOf<S>>>;
169
169
  export declare function createAction<A extends unknown[], P, T extends string, S extends Scope = Record<never, never>>(type: T, options: {
170
170
  prepare: (...args: A) => {
171
171
  payload: P;
@@ -223,8 +223,8 @@ type Creator = {
223
223
  readonly type: string;
224
224
  };
225
225
  type Outcome = string | Creator;
226
- /** What `createJob` returns: the command of the job, with its four actions as properties. */
227
- type Job<P, R, T extends string, S extends Outcome, F extends Outcome, PE extends Outcome = `${T}/pending`, CE extends Outcome = `${T}/cancel`> = MadeCommand<P, Promise<Awaited<R> | undefined>, T> & {
226
+ /** What `createJob` returns: the action of the job, with its four outcome creators as properties. */
227
+ type Job<P, R, T extends string, S extends Outcome, F extends Outcome, PE extends Outcome = `${T}/pending`, CE extends Outcome = `${T}/cancel`> = MadeHandled<P, Promise<Awaited<R> | undefined>, T> & {
228
228
  /** Made from a string with the payload of the call as its payload, or the creator that was given. */
229
229
  readonly pending: PE extends string ? ActionCreator<P, PE> : PE;
230
230
  /** Made from a string with the result as its payload, or the creator that was given. */
@@ -235,13 +235,13 @@ type Job<P, R, T extends string, S extends Outcome, F extends Outcome, PE extend
235
235
  readonly cancel: CE extends string ? ActionCreator<unknown, CE> : CE;
236
236
  };
237
237
  /**
238
- * Creates a job: a command whose outcome is sent on as actions. When the
238
+ * Creates a job: an action whose outcome is sent on as actions. When the
239
239
  * handler starts, `job.pending(payload)` is emitted on the bus. When it
240
240
  * succeeds, `job.success(result)` follows, and when it fails, `job.fail(error)`.
241
241
  * When the task is aborted after it started, `job.cancel(reason)` follows
242
242
  * instead. After `pending`, exactly one of the three closes the call. A job is
243
243
  * made for the case where nobody waits for the result and the bus carries it
244
- * on, like `createAsyncThunk` or an effector effect. It returns the command,
244
+ * on, like `createAsyncThunk` or an effector effect. It returns the action,
245
245
  * with the four actions on it.
246
246
  *
247
247
  * A scope as the last argument, `{ cache, $effects: { race } }`, gives the handler
@@ -255,14 +255,14 @@ type Job<P, R, T extends string, S extends Outcome, F extends Outcome, PE extend
255
255
  *
256
256
  * `bus.emit(job(payload))` returns a promise of the result. An error of the
257
257
  * handler always counts as handled: it goes to `job.fail` and the promise
258
- * resolves with `undefined`; a command is the tool for a result that must reject.
258
+ * resolves with `undefined`; an action is the tool for a result that must reject.
259
259
  * The actions are emitted as the task that ran the job, also for a handler bound
260
- * with `commands.handle`. Once the task is aborted, `success` and `fail` are
260
+ * with `actions.handle`. Once the task is aborted, `success` and `fail` are
261
261
  * skipped and `cancel` is sent when the handler settles (a handler that never
262
262
  * settles sends nothing). A call that does not start, because a policy drops it
263
263
  * or it is aborted while it waits in a `queue`, sends none of the four. A
264
264
  * missing handler is not an outcome: `emit` throws `MissingHandlerError`.
265
- * Calling the job builds `{ type, payload }` like a command; it does not run
265
+ * Calling the job builds `{ type, payload }` like an action; it does not run
266
266
  * the handler.
267
267
  *
268
268
  * @example
@@ -293,23 +293,23 @@ scope?: X) => CarryingCalls<Job<P, R, T, S, F, PE, CE>, P, Promise<Awaited<R> |
293
293
  //#region src/actions/module.d.ts
294
294
  /**
295
295
  * What a module's `setup` gets: the context of the module's task, so `on`,
296
- * `emit` and `run` work as in a handler, plus `handle` to bind commands, `use`
296
+ * `emit` and `run` work as in a handler, plus `handle` to bind actions, `use`
297
297
  * to mount sub-modules and `spawn` to start a background task. Everything the
298
298
  * module does is undone when it is unmounted.
299
299
  */
300
300
  type ModuleContext<E extends EventMap = EventMap> = Context<E> & {
301
- /** Binds the handler of a command, or a list of them; undone on unmount. */
302
- handle<P, R>(command: Command<P, R>, fn: Task<P, E, R>): UnsubscribeCallback;
303
- /** Also an action made without a handler: the handler answers it as it would a command. */
301
+ /** Binds the handler of an action, or a list of them; undone on unmount. */
302
+ handle<P, R>(handled: Handled<P, R>, fn: Task<P, E, R>): UnsubscribeCallback;
303
+ /** Also an action made without a handler: the handler answers it as it would one made with a handler. */
304
304
  handle<A extends {
305
305
  readonly type: string;
306
306
  }>(action: A, fn: LooseHandler<A, E>): UnsubscribeCallback;
307
307
  handle(type: string, fn: Task<never, E, unknown>): UnsubscribeCallback;
308
308
  handle(bindings: readonly Binding<E>[]): UnsubscribeCallback;
309
309
  /**
310
- * Brings sub-modules and commands, in any order. A sub-module is mounted and
311
- * unmounted with this one. A command is bound to the handler it carries, for
312
- * as long as this module is mounted; a command that answers by itself keeps
310
+ * Brings sub-modules and actions, in any order. A sub-module is mounted and
311
+ * unmounted with this one. An action is bound to the handler it carries, for
312
+ * as long as this module is mounted; an action that answers by itself keeps
313
313
  * answering after the module is gone, since the handler is its own. The
314
314
  * returned function undoes just this call, e.g. for what was added later from
315
315
  * a listener.
@@ -331,7 +331,7 @@ type Module<E extends EventMap = EventMap> = {
331
331
  readonly scope?: Scope;
332
332
  };
333
333
  /**
334
- * Describes one domain of an app: the commands it handles, the events it
334
+ * Describes one domain of an app: the actions it handles, the events it
335
335
  * listens to, its sub-modules and its background tasks. The `name` shows up as
336
336
  * the type of the module's tasks in the trace.
337
337
  *
@@ -373,7 +373,7 @@ interface WithApp {
373
373
  }
374
374
  /** What `modulePlugin` returns. */
375
375
  type ModuleApi<E extends EventMap = EventMap> = {
376
- /** The registry of command handlers of the bus: the one it was made with, or the app's own. */
376
+ /** The registry of action handlers of the bus: the one it was made with, or the app's own. */
377
377
  actions: Registry<E>;
378
378
  /**
379
379
  * Mounts modules, in the order given, and returns the function that unmounts them, last
@@ -402,17 +402,17 @@ type ModuleApi<E extends EventMap = EventMap> = {
402
402
  * of one of its methods. By then every plugin is on the bus, so the plugins can
403
403
  * be used in any order. The `on`, `once` and `off` calls made in between are
404
404
  * held and made right after the modules, so the listeners of a module stay
405
- * ahead of them. The bus runs the commands that the modules bind: the registry
405
+ * ahead of them. The bus runs the actions that the modules bind: the registry
406
406
  * that the bus has is used (a later `actionsPlugin` binds in it), otherwise the
407
407
  * app attaches its own, as `app.actions`. The app is also `bus.app`.
408
408
  *
409
409
  * A module is known by its `name`: mounting a module whose name is taken
410
410
  * replaces the mounted one, which is unmounted first. That is what hot reload
411
411
  * needs (see `docs/hmr.md`): the new version of a module file mounts again and
412
- * the old version goes away with its subscriptions, commands and tasks.
412
+ * the old version goes away with its subscriptions, actions and tasks.
413
413
  *
414
414
  * Unmounting undoes everything the module did: its subscriptions, its bound
415
- * commands, its sub-modules and its background tasks. `dispose` unmounts them
415
+ * actions, its sub-modules and its background tasks. `dispose` unmounts them
416
416
  * all, and a disposed app cannot mount modules.
417
417
  *
418
418
  * @example
@@ -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-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};
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,`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
+ 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, 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";
1
+ import { B as Task, L as EventMap, N as WithSignal, _ as Context, u as Effect } from "./action-creator-BrMSO3RP.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-7GUL2EW5.js";
3
3
  //#region src/utils/onAbort.d.ts
4
4
  export declare const onAbort: (ctx: {
5
5
  signal?: AbortSignal | undefined;
@@ -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-DxOvVo8I.js";
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 };
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-BrMSO3RP.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 };
@@ -1 +1 @@
1
- export{t as createBus}from"./bus-DmKn4SDD.js";
1
+ export{t as createBus}from"./bus-37nlVljc.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-DxOvVo8I.js";
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-BrMSO3RP.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-DxOvVo8I.js";
1
+ import { B as Task, L as EventMap, z as PayloadOf } from "./action-creator-BrMSO3RP.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> = {
@@ -1,4 +1,4 @@
1
- import { L as EventMap, h as Bus } from "./action-creator-DxOvVo8I.js";
1
+ import { L as EventMap, h as Bus } from "./action-creator-BrMSO3RP.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`. */
@@ -1,4 +1,4 @@
1
- import { H as EventMap, U as Keys, r as DataOf, v as Bus } from "./action-creator-CcAEvUnw.js";
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-6rlBTmH9.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
@@ -1 +1 @@
1
- const e=typeof Symbol==`function`&&Symbol.observable||`@@observable`,t=e=>t=>{typeof e==`function`?e(t):e.next?.(t)},n=n=>r=>({subscribe:e=>({unsubscribe:n.on(r,t(e))}),[e](){return this}});var r=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,t(e))}}next(e){let t=this.source.emit;Reflect.apply(t,this.source,[this.event,e])}[e](){return this}};export{e as $$observable,r as Subject,n as createObserve};
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, b as Command, t as ActionCreator, v as Bus } from "./action-creator-CcAEvUnw.js";
1
+ import { H as EventMap, W as ListenerOptions, k as Handled, t as ActionCreator, v as Bus } from "./action-creator-6rlBTmH9.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 or a command.
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> | Command<P, unknown>;
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{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
+ import{t as e}from"./bus-DFlmNJ6h.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-CcAEvUnw.js";
2
- import { n as NoClash } from "./context-types-hCKgU8sC.js";
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-6rlBTmH9.js";
2
+ import { r as NoClash } from "./context-types-DKNc5mkS.js";
3
3
  //#region src/utils/delay.d.ts
4
4
  type Milliseconds = number | (() => number);
5
5
  /**
@@ -1,5 +1,5 @@
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";
1
+ import { H as EventMap, q as Task } from "./action-creator-6rlBTmH9.js";
2
+ import { n as withPolicy, t as PolicyFunction } from "./with-policy-CthiBp_z.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-18LJ8jSk.js";import{i as r,o as i,s as a,t as o,u as s}from"./context-UcmrAIhP.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-D-SQRkPh.js";const p=e=>Reflect.get(e,d),m=e=>{p(e)?.start()},h=(e,t,n)=>(m(e),i(e,t,n)),g=(e,t)=>{a(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 i=null;return(l,u)=>{if(i?.abort(),u.signal.aborted)return;let{ctx:d,unlink:f}=r(u);i=d;let p=o(d,e),h=!1,g=()=>{d.signal.aborted||(h=!0,m(d),a(d,e,`start`))};s(d,e=>{v(d,h,e),p(h?`cancel`:`drop`)});let _=()=>{f(),i===d&&(i=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,r,i)=>{let a=r.leading??!1,o=r.trailing??!0;if(!o)return k(e,t,a,i);let c=!1,l=0,u=E(`debounce`,([r,i],a,u)=>{let d=l;return s(a,()=>{l===d&&(c=!1)}),n(a,e).then(()=>{if(c=!1,o&&!i)return u(),t(r,a)})},i);return(e,n)=>{if(n.signal.aborted)return;let r=a&&!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,i)=>{if(i.signal.aborted)return;if(n){g(i,`leading`);return}let a={};n=a;let o=()=>{c(),n===a&&(n=null,t())},c=s(i,o);try{return l(h(i,`leading`,()=>e(r,i)),o)}catch(e){throw o(),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,i=t.limit??1/0,a=[],o=0,c=()=>{for(;o<r;){let e=a.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}o++;let t=!0,r=()=>{c(),o===0&&a.length===0&&n()},i=(e=!1)=>{t&&(t=!1,o--,e?queueMicrotask(r):r())},g=s(u,()=>{i(!0),d(void 0)}),v;try{v=Promise.resolve(h(u,`queue`,()=>e(l,u)))}catch(e){v=Promise.reject(e)}let y=()=>{g(),i()};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(o<r){v();return}if(a.length>=i){if(t.overflow!==`drop-old`||i<=0){m();return}a.shift()?.drop()}let y={start:v,drop:m};a.push(y),p=s(u,()=>{let e=a.indexOf(y);e>=0&&a.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};
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-B5Z2RpJt.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-CeM1rtES.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};
@@ -1 +1 @@
1
- const e=()=>{},t=()=>e,n=()=>t;export{n as devPlugin};
1
+ const e=()=>{},t=()=>e,n=()=>t,r=async()=>[],i=async()=>0;export{n as devPlugin,r as getLostSignals,i as getLostSignalsCount};
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-CcAEvUnw.js";
1
+ import { H as EventMap, T as EventKey, a as FreeActionCreator, q as Task, t as ActionCreator, v as Bus } from "./action-creator-6rlBTmH9.js";
2
2
  import { t as OriginOptions } from "./origin-key-CxK0SkeG.js";
3
- import { t as PolicyFunction } from "./with-policy-3bhFLEXs.js";
3
+ import { t as PolicyFunction } from "./with-policy-CthiBp_z.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-D-SQRkPh.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};
1
+ import{t as e}from"./with-policy-CeM1rtES.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-CcAEvUnw.js";
1
+ import { H as EventMap, v as Bus } from "./action-creator-6rlBTmH9.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-CcAEvUnw.js";
2
- import { n as ScopeSlots, r as Scoped } from "./types-FV8fuvI9.js";
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-6rlBTmH9.js";
2
+ import { n as ScopeSlots, r as Scoped } from "./types-N_cdRr1r.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 = createCommand(
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 a command, a job, an
31
- * action or a module (an object whose keys go on `ctx`, with `$effects` bound to
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 / command / job, then module, then the bus.
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 { createCommand } from "nanoeffects/actions";
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 = createCommand("user/get", (id: string, { http }) => http.get(id), {
50
- * http, // a field of this command only
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};