nanoeffects 0.19.0 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/{action-creator-HFA_LZOH.d.ts → action-creator-Bpa8BUS9.d.ts} +18 -7
  2. package/dist/actions.d.ts +3 -3
  3. package/dist/actions.js +1 -1
  4. package/dist/{context-types-BNcs43eY.d.ts → context-types-BKIH5a8s.d.ts} +1 -1
  5. package/dist/context.d.ts +2 -2
  6. package/dist/dev.d.ts +2 -2
  7. package/dist/dev.js +1 -1
  8. package/dist/effects.d.ts +4 -8
  9. package/dist/index.d.ts +2 -2
  10. package/dist/match.d.ts +1 -1
  11. package/dist/{module-DTf73Wdq.d.ts → module-B0KVDNjY.d.ts} +14 -9
  12. package/dist/mount-each-D54UqAhZ.js +1 -0
  13. package/dist/notrace/{action-creator-CbFf398i.d.ts → action-creator-D2CotugT.d.ts} +16 -7
  14. package/dist/notrace/actions.d.ts +14 -9
  15. package/dist/notrace/actions.js +1 -1
  16. package/dist/notrace/effects.d.ts +4 -8
  17. package/dist/notrace/index.d.ts +2 -2
  18. package/dist/notrace/{plugin-C5vIjxhR.d.ts → plugin-C6KA4dX-.d.ts} +1 -1
  19. package/dist/notrace/policies.d.ts +1 -1
  20. package/dist/notrace/redux.d.ts +1 -1
  21. package/dist/observable.d.ts +1 -1
  22. package/dist/oop.d.ts +1 -1
  23. package/dist/{plugin-Sy8z9IId.d.ts → plugin-D9UTzGRG.d.ts} +2 -2
  24. package/dist/policies.d.ts +2 -2
  25. package/dist/react.d.ts +3 -4
  26. package/dist/redux.d.ts +1 -1
  27. package/dist/scope.d.ts +4 -4
  28. package/dist/signal.d.ts +1 -1
  29. package/dist/state-of-C19H6BoV.d.ts +10 -0
  30. package/dist/trace.d.ts +1 -1
  31. package/dist/{types-DaZT158m.d.ts → types-CbdJKC2z.d.ts} +2 -2
  32. package/dist/vue.d.ts +72 -0
  33. package/dist/vue.js +1 -0
  34. package/dist/{with-policy-C_mX7S54.d.ts → with-policy-BeH8wCkX.d.ts} +1 -1
  35. package/docs/README.md +2 -0
  36. package/docs/actions.md +31 -1
  37. package/docs/chat-example.md +241 -0
  38. package/docs/migrating-from-rxjs.md +58 -1
  39. package/docs/package.md +1 -0
  40. package/docs/plugins.md +3 -3
  41. package/docs/starter.md +14 -1
  42. package/docs/typescript.md +14 -0
  43. package/docs/vue.md +96 -0
  44. package/llms-full.txt +467 -7
  45. package/llms.txt +4 -2
  46. package/package.json +23 -3
  47. package/skills/nanoeffects/SKILL.md +12 -18
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nanoeffects",
3
- "version": "0.19.0",
3
+ "version": "0.20.0",
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",
@@ -126,6 +126,10 @@
126
126
  "types": "./dist/react.d.ts",
127
127
  "import": "./dist/react.js"
128
128
  },
129
+ "./vue": {
130
+ "types": "./dist/vue.d.ts",
131
+ "import": "./dist/vue.js"
132
+ },
129
133
  "./dev": {
130
134
  "production": {
131
135
  "types": "./dist/dev.d.ts",
@@ -167,6 +171,7 @@
167
171
  "@vitejs/plugin-react": "^6.1.2",
168
172
  "archunit": "^2.5.4",
169
173
  "happy-dom": "^21.0.4",
174
+ "immer": "^10.2.0",
170
175
  "jotai": "^3.0.1",
171
176
  "lefthook": "2.2.1",
172
177
  "lodash": "4.17.21",
@@ -179,9 +184,12 @@
179
184
  "size-limit": "^14.2.0",
180
185
  "tsdown": "0.23.1",
181
186
  "typescript": "7.0.2",
187
+ "typescript-5": "npm:typescript@^5.9.3",
182
188
  "unplugin-unused": "^0.6.0",
183
189
  "vite": "^8.3.4",
184
190
  "vitest": "5.0.5",
191
+ "vue": "^3.5.44",
192
+ "vue-tsc": "^3.3.13",
185
193
  "webpack": "^5.112.0",
186
194
  "zustand": "^5.0.15"
187
195
  },
@@ -208,7 +216,7 @@
208
216
  {
209
217
  "name": "actions (all)",
210
218
  "path": "dist/actions.js",
211
- "limit": "2.87 kB"
219
+ "limit": "3.02 kB"
212
220
  },
213
221
  {
214
222
  "name": "match (plugin)",
@@ -253,6 +261,14 @@
253
261
  ],
254
262
  "limit": "1.24 kB"
255
263
  },
264
+ {
265
+ "name": "vue",
266
+ "path": "dist/vue.js",
267
+ "ignore": [
268
+ "vue"
269
+ ],
270
+ "limit": "0.4 kB"
271
+ },
256
272
  {
257
273
  "name": "dev",
258
274
  "path": "dist/dev.js",
@@ -265,11 +281,15 @@
265
281
  }
266
282
  ],
267
283
  "peerDependencies": {
268
- "react": ">=18"
284
+ "react": ">=18",
285
+ "vue": ">=3.3"
269
286
  },
270
287
  "peerDependenciesMeta": {
271
288
  "react": {
272
289
  "optional": true
290
+ },
291
+ "vue": {
292
+ "optional": true
273
293
  }
274
294
  }
275
295
  }
@@ -20,6 +20,16 @@ A typed event bus where each handler is a task with an `AbortSignal`. Policies (
20
20
  - The job is combining or transforming streams of values: keep RxJS.
21
21
  - The job is server state caching (stale-while-revalidate, pagination): use a query library.
22
22
 
23
+ ## Start a new project
24
+
25
+ Do not write the setup by hand. `npm create nanoeffects@latest my-app -- --template <name>` makes a working Vite project:
26
+
27
+ - `vanilla`, `react`: JavaScript, one search handler with `debounce` and `latest`.
28
+ - `vanilla-ts`, `react-ts`: the same apps in TypeScript.
29
+ - `domains-ts`: React and TypeScript with the logic split by domain (commands, a job, modules). Pick it for an app with several features.
30
+
31
+ In an existing project, start from `docs/cancel-stale-requests.md` (races) or `docs/guide.md`.
32
+
23
33
  ## Rules that generated code often gets wrong
24
34
 
25
35
  - ESM only. No default export, no `require`.
@@ -29,24 +39,8 @@ A typed event bus where each handler is a task with an `AbortSignal`. Policies (
29
39
  - Policies wrap a handler: `bus.on("search", latest(async (query, ctx) => { ... }))`.
30
40
  - Import each part from its path: `nanoeffects`, `nanoeffects/policies`, `nanoeffects/effects`, `nanoeffects/actions`, `nanoeffects/redux`, `nanoeffects/react`.
31
41
  - `bus.emit(command(payload))` returns the command's result. Plain events return nothing.
32
-
33
- ## Minimal example
34
-
35
- ```js
36
- import { createBus } from "nanoeffects";
37
- import { latest } from "nanoeffects/policies";
38
-
39
- const bus = createBus();
40
-
41
- bus.on(
42
- "search",
43
- latest(async (query, { signal }) => {
44
- const items = await api.search(query, { signal });
45
- bus.emit("results", items);
46
- }),
47
- );
48
- ```
42
+ - The bus keeps no values: an event emitted before a listener exists is lost. `useEventState(event, initial)` (`nanoeffects/react`) is state of one component, not a store. Share a value through a Context provider at the root or a state manager.
49
43
 
50
44
  ## Where to read more
51
45
 
52
- The package ships `llms.txt` (index of the docs) and `llms-full.txt` (all docs in one file). Start with `docs/cancel-stale-requests.md` for races and `docs/guide.md` for the step-by-step guide.
46
+ The package ships `llms.txt` (index of the docs) and `llms-full.txt` (all docs in one file).