@logosdx/hooks 1.0.0-beta.3 → 1.0.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 (2) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,75 @@
1
1
  # @logosdx/hooks
2
2
 
3
+ ## 1.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 2f9c85c: ## Breaking Changes
8
+
9
+ ### API verbs renamed
10
+
11
+ Methods renamed to distinguish from Observer (`on`/`emit`):
12
+
13
+ | Before | After |
14
+ | ---------------------------- | -------------------------------------- |
15
+ | `engine.on(name, cb)` | `engine.add(name, cb, options?)` |
16
+ | `engine.once(name, cb)` | `engine.add(name, cb, { once: true })` |
17
+ | `engine.emit(name, ...args)` | `engine.run(name, ...args)` |
18
+
19
+ ### Callback signature changed
20
+
21
+ Callbacks now receive spread args with ctx as the last parameter instead of a context object:
22
+
23
+ **Before:**
24
+
25
+ ```ts
26
+ hooks.on("beforeRequest", async (ctx) => {
27
+ const [url, opts] = ctx.args;
28
+ ctx.setArgs([url, { ...opts, cache: "no-store" }]);
29
+ });
30
+ ```
31
+
32
+ **After:**
33
+
34
+ ```ts
35
+ hooks.add("beforeRequest", (url, opts, ctx) => {
36
+ ctx.args(url, { ...opts, cache: "no-store" });
37
+ });
38
+ ```
39
+
40
+ ### Context methods replaced
41
+
42
+ | Before | After |
43
+ | ---------------------- | ----------------------------------------------------- |
44
+ | `ctx.args` (property) | `ctx.args(...)` (method — replaces args) |
45
+ | `ctx.setArgs([...])` | `ctx.args(...)` (spread, no array wrapper) |
46
+ | `ctx.setResult(value)` | `return ctx.returns(value)` |
47
+ | `ctx.returnEarly()` | `return ctx.args(...)` or `return ctx.returns(value)` |
48
+
49
+ ### Return type renamed
50
+
51
+ `EmitResult` → `RunResult`, `earlyReturn` → `returned`:
52
+
53
+ ```ts
54
+ // Before
55
+ const { args, result, earlyReturn } = await hooks.emit("hook", data);
56
+ // After
57
+ const { args, result, returned } = await hooks.run("hook", data);
58
+ ```
59
+
60
+ ## Added
61
+
62
+ - `feat(hooks):` Sync execution via `runSync()` and `wrapSync()` for non-async hook chains
63
+ - `feat(hooks):` Priority ordering — `add(name, cb, { priority: -10 })`, lower runs first
64
+ - `feat(hooks):` `times` option — run a callback N times then auto-remove
65
+ - `feat(hooks):` Per-request ephemeral hooks via `RunOptions.append`
66
+ - `feat(hooks):` `HookContext` is now a class (exported for `instanceof` checks)
67
+
68
+ ### Patch Changes
69
+
70
+ - Updated dependencies [879cea2]
71
+ - @logosdx/utils@6.1.0
72
+
3
73
  ## 1.0.0-beta.3
4
74
 
5
75
  ### Major Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logosdx/hooks",
3
- "version": "1.0.0-beta.3",
3
+ "version": "1.0.0",
4
4
  "description": "A lightweight, type-safe hook system for extending function behavior",
5
5
  "license": "BSD-3-Clause",
6
6
  "homepage": "https://logosdx.dev/",
@@ -38,6 +38,6 @@
38
38
  "unpkg": "./dist/browser/bundle.js",
39
39
  "jsdelivr": "./dist/browser/bundle.js",
40
40
  "dependencies": {
41
- "@logosdx/utils": "^6.1.0-beta.1"
41
+ "@logosdx/utils": "^6.1.0"
42
42
  }
43
43
  }