@gesslar/actioneer 2.3.1 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "name": "gesslar",
6
6
  "url": "https://gesslar.dev"
7
7
  },
8
- "version": "2.3.1",
8
+ "version": "2.4.0",
9
9
  "license": "Unlicense",
10
10
  "homepage": "https://github.com/gesslar/toolkit#readme",
11
11
  "repository": {
@@ -22,7 +22,6 @@
22
22
  "composition",
23
23
  "lasagna"
24
24
  ],
25
- "main": "./src/index.js",
26
25
  "type": "module",
27
26
  "exports": {
28
27
  ".": {
@@ -46,28 +45,28 @@
46
45
  ],
47
46
  "sideEffects": false,
48
47
  "engines": {
49
- "node": ">=22"
50
- },
51
- "dependencies": {
52
- "@gesslar/toolkit": "^3.34.0"
53
- },
54
- "devDependencies": {
55
- "@gesslar/uglier": "^1.4.1",
56
- "eslint": "^10.0.0",
57
- "typescript": "^5.9.3"
48
+ "node": ">=24.13.0"
58
49
  },
59
50
  "scripts": {
60
51
  "lint": "eslint src/",
61
52
  "lint:fix": "eslint src/ --fix",
62
53
  "types": "node -e \"require('fs').rmSync('types',{recursive:true,force:true});\" && tsc -p tsconfig.types.json",
63
- "submit": "pnpm publish --access public --//registry.npmjs.org/:_authToken=\"${NPM_ACCESS_TOKEN}\"",
64
- "update": "pnpm self-update && pnpx npm-check-updates -u && pnpm install",
54
+ "submit": "npm publish --access public --//registry.npmjs.org/:_authToken=\"${NPM_ACCESS_TOKEN}\"",
55
+ "update": "npx npm-check-updates -u && npm install",
65
56
  "test": "node --test tests/**/*.test.js",
66
57
  "test:browser": "node --test tests/browser/*.test.js",
67
58
  "test:node": "node --test tests/node/*.test.js",
68
59
  "pr": "gt submit -p --ai",
69
- "patch": "pnpm version patch",
70
- "minor": "pnpm version minor",
71
- "major": "pnpm version major"
60
+ "patch": "npm version patch",
61
+ "minor": "npm version minor",
62
+ "major": "npm version major"
63
+ },
64
+ "dependencies": {
65
+ "@gesslar/toolkit": "^3.37.0"
66
+ },
67
+ "devDependencies": {
68
+ "@gesslar/uglier": "^1.6.2",
69
+ "eslint": "^10.0.0",
70
+ "typescript": "^5.9.3"
72
71
  }
73
- }
72
+ }
@@ -229,10 +229,10 @@ export default class ActionBuilder {
229
229
  * @throws {Sass} If hooks have already been configured with a different instance.
230
230
  */
231
231
  withHooks(hooks) {
232
- // If the same hooks instance is already set, this is idempotent - just return
233
- if(this.#hooks === hooks) {
232
+ // If the same hooks instance is already set, this is idempotent -just
233
+ // return.
234
+ if(this.#hooks === hooks)
234
235
  return this
235
- }
236
236
 
237
237
  Valid.assert(this.#hooksFile === null, "Hooks have already been configured.")
238
238
  Valid.assert(this.#hooksKind === null, "Hooks have already been configured.")
@@ -294,6 +294,7 @@ export default class ActionBuilder {
294
294
  * Finalises the builder and returns a payload that can be consumed by the
295
295
  * runner.
296
296
  *
297
+ * @param {ActionRunner} runner - The runner invoking the build.
297
298
  * @returns {Promise<ActionWrapper>} Payload consumed by the {@link ActionRunner} constructor.
298
299
  */
299
300
  async build(runner) {
@@ -351,4 +352,14 @@ export default class ActionBuilder {
351
352
  if(hooksFile && hooksKind)
352
353
  return await newHooks({hooksFile,hooksKind}, this.#debug)
353
354
  }
355
+
356
+ /**
357
+ * Returns the raw hooks value configured on this builder.
358
+ * Used by {@link ActionRunner} to access setup/cleanup lifecycle hooks.
359
+ *
360
+ * @returns {object|Function|null} Raw hooks value, or null if not configured.
361
+ */
362
+ get hooks() {
363
+ return this.#hooks
364
+ }
354
365
  }
@@ -9,7 +9,7 @@ import {Data, Sass, Promised, Time, Util, Valid} from "@gesslar/toolkit"
9
9
  *
10
10
  * @typedef {object} ActionHooksConfig
11
11
  * @property {string} actionKind - Action identifier shared between runner and hooks.
12
- * @property {unknown} hooks - Already-instantiated hooks implementation.
12
+ * @property {object|Function|null} hooks - Pre-instantiated hooks object, a constructor to instantiate, or null.
13
13
  * @property {number} [hookTimeout] - Timeout applied to hook execution in milliseconds.
14
14
  * @property {DebugFn} debug - Logger to emit diagnostics.
15
15
  */
@@ -54,10 +54,18 @@ export default class ActionHooks {
54
54
 
55
55
  /**
56
56
  * Gets the loaded hooks object.
57
+ * If the stored value is a plain object it is returned as-is.
58
+ * If it is a constructor function a new instance is created and returned.
57
59
  *
58
60
  * @returns {object?} Hooks object or null if not loaded
59
61
  */
60
62
  get hooks() {
63
+ if(Data.isType(this.#hooks, "Object"))
64
+ return this.#hooks
65
+
66
+ else if(Data.isType(this.#hooks, "Function"))
67
+ return new this.#hooks()
68
+
61
69
  return this.#hooks
62
70
  }
63
71
 
@@ -97,7 +105,7 @@ export default class ActionHooks {
97
105
  * @returns {Promise<ActionHooks?>} Initialized hook manager or null if no hooks provided
98
106
  */
99
107
  static async new(config, debug) {
100
- debug("Creating new HookManager instance with args: %o", 2, config)
108
+ debug("Creating new ActionHooks instance with args: %o", 2, config)
101
109
 
102
110
  if(!config.hooks) {
103
111
  debug("No hooks provided (browser mode requires pre-instantiated hooks)", 2)
@@ -117,10 +125,11 @@ export default class ActionHooks {
117
125
  *
118
126
  * @param {string} kind - Hook namespace.
119
127
  * @param {string|symbol} activityName - Activity identifier.
120
- * @param {unknown} context - Pipeline context supplied to the hook.
128
+ * @param {unknown} oldContext - Pipeline context supplied to the hook.
129
+ * @param {unknown} newContext - For after$ hooks, the result of the op
121
130
  * @returns {Promise<void>}
122
131
  */
123
- async callHook(kind, activityName, context) {
132
+ async callHook(kind, activityName, oldContext, newContext) {
124
133
  try {
125
134
  const debug = this.#debug
126
135
  const hooks = this.#hooks
@@ -147,7 +156,11 @@ export default class ActionHooks {
147
156
  debug("Hook function starting execution: %o", 4, hookName)
148
157
 
149
158
  const duration = (
150
- await Util.time(() => hook.call(this.#hooks, context))
159
+ newContext
160
+ ? await Util.time(
161
+ () => hook.call(this.#hooks, newContext, oldContext)
162
+ )
163
+ : await Util.time(() => hook.call(this.#hooks, oldContext))
151
164
  ).cost
152
165
 
153
166
  debug("Hook function completed successfully: %o, after %oms", 4, hookName, duration)
@@ -168,9 +181,6 @@ export default class ActionHooks {
168
181
  } catch(error) {
169
182
  throw Sass.new(`Processing hook ${kind}$${activityName}`, error)
170
183
  }
171
-
172
- debug("We made it throoough the wildernessss", 4)
173
-
174
184
  } catch(error) {
175
185
  throw Sass.new(`Processing hook ${kind}$${activityName}`, error)
176
186
  }
@@ -55,9 +55,45 @@ export default class ActionRunner extends Piper {
55
55
 
56
56
  this.#actionBuilder = actionBuilder
57
57
 
58
+ this.addSetup(this.#setupHooks)
58
59
  this.addStep(this.run, {
59
60
  name: `ActionRunner for ${actionBuilder.tag.description}`
60
61
  })
62
+ this.addCleanup(this.#cleanupHooks)
63
+ }
64
+
65
+ /**
66
+ * Invokes the `setup` lifecycle hook on the raw hooks object, if defined.
67
+ * Registered as a Piper setup step so it fires before any items are processed.
68
+ *
69
+ * @param {unknown} ctx - Value passed by {@link Piper#pipe} (the items array).
70
+ * @returns {Promise<void>}
71
+ * @private
72
+ */
73
+ async #setupHooks(ctx) {
74
+ const ab = this.#actionBuilder
75
+ const ah = ab?.hooks
76
+ const setup = ah?.setup
77
+
78
+ if(setup)
79
+ await setup.call(ah, ctx)
80
+ }
81
+
82
+ /**
83
+ * Invokes the `cleanup` lifecycle hook on the raw hooks object, if defined.
84
+ * Registered as a Piper teardown step so it fires after all items are processed.
85
+ *
86
+ * @param {unknown} ctx - Value passed by {@link Piper#pipe} (the items array).
87
+ * @returns {Promise<void>}
88
+ * @private
89
+ */
90
+ async #cleanupHooks(ctx) {
91
+ const ab = this.#actionBuilder
92
+ const ah = ab?.hooks
93
+ const cleanup = ah?.cleanup
94
+
95
+ if(cleanup)
96
+ await cleanup.call(ah, ctx)
61
97
  }
62
98
 
63
99
  /**
@@ -4,7 +4,6 @@ import Activity from "./Activity.js"
4
4
  * Type imports
5
5
  *
6
6
  * @import {default as ActionHooks} from "./ActionHooks.js"
7
- * @import {default as ActionRunner} from "./ActionRunner.js"
8
7
  */
9
8
 
10
9
  /**
@@ -43,13 +42,16 @@ export default class ActionWrapper {
43
42
  #action = null
44
43
  /** @type {symbol} */
45
44
  #id = Symbol(performance.now())
46
- /** @type {ActionRunner} */
47
- #runner
48
45
 
49
46
  /**
50
47
  * Create a wrapper from the builder payload.
51
48
  *
52
- * @param {{activities: Map<string|symbol, WrappedActivityConfig>, debug: (message: string, level?: number, ...args: Array<unknown>) => void}} init Builder payload containing activities + logger.
49
+ * @param {object} init - Builder payload.
50
+ * @param {Map<string|symbol, WrappedActivityConfig>} init.activities - Registered activities.
51
+ * @param {(message: string, level?: number, ...args: Array<unknown>) => void} init.debug - Logger.
52
+ * @param {import("./ActionHooks.js").default?} init.hooks - Optional hooks instance.
53
+ * @param {((context: unknown) => unknown|Promise<unknown>)|null} [init.done] - Optional done callback.
54
+ * @param {unknown} [init.action] - Optional parent action instance.
53
55
  */
54
56
  constructor({activities,hooks,debug,done: doneCallback,action}) {
55
57
  this.#debug = debug
@@ -192,7 +192,7 @@ export default class Activity {
192
192
  const result = await this.#op.call(this.#action, context)
193
193
 
194
194
  // after hook
195
- await this.#hooks?.callHook("after", this.#name, context)
195
+ await this.#hooks?.callHook("after", this.#name, result, context)
196
196
 
197
197
  return result
198
198
  }
@@ -9,7 +9,11 @@
9
9
  * - Error handling and reporting
10
10
  */
11
11
 
12
- import {Data, Disposer, NotifyClass, Promised, Sass, Tantrum} from "@gesslar/toolkit"
12
+ import {Data, Disposer, NotifyClass, Promised, Sass} from "@gesslar/toolkit"
13
+
14
+ /**
15
+ * @import {Tantrum} from "@gesslar/toolkit"
16
+ */
13
17
 
14
18
  export default class Piper extends NotifyClass {
15
19
  #debug
@@ -67,7 +71,7 @@ export default class Piper extends NotifyClass {
67
71
  /**
68
72
  * Add setup hook that runs before processing starts.
69
73
  *
70
- * @param {() => Promise<void>|void} fn - Setup function executed before processing
74
+ * @param {(items: Array<unknown>) => Promise<void>|void} fn - Setup function executed before processing; receives the full items array.
71
75
  * @param {unknown} [thisArg] - Optional this binding for the setup function
72
76
  * @returns {Piper} - The pipeline instance
73
77
  */
@@ -80,7 +84,7 @@ export default class Piper extends NotifyClass {
80
84
  /**
81
85
  * Add cleanup hook that runs after processing completes
82
86
  *
83
- * @param {() => Promise<void>|void} fn - Cleanup function executed after processing
87
+ * @param {(items: Array<unknown>) => Promise<void>|void} fn - Cleanup function executed after processing; receives the full items array.
84
88
  * @param {unknown} [thisArg] - Optional this binding for the cleanup function
85
89
  * @returns {Piper} - The pipeline instance
86
90
  */
@@ -128,7 +132,7 @@ export default class Piper extends NotifyClass {
128
132
  }
129
133
 
130
134
  const setupResult = await Promised.settle(
131
- [...this.#lifeCycle.get("setup")].map(e => Promise.resolve(e()))
135
+ [...this.#lifeCycle.get("setup")].map(e => Promise.resolve(e(items)))
132
136
  )
133
137
 
134
138
  this.#processResult("Setting up the pipeline.", setupResult)
@@ -146,7 +150,7 @@ export default class Piper extends NotifyClass {
146
150
  } finally {
147
151
  // Run cleanup hooks
148
152
  const teardownResult = await Promised.settle(
149
- [...this.#lifeCycle.get("teardown")].map(e => Promise.resolve(e()))
153
+ [...this.#lifeCycle.get("teardown")].map(e => Promise.resolve(e(items)))
150
154
  )
151
155
 
152
156
  this.#processResult("Tearing down the pipeline.", teardownResult)
@@ -164,9 +168,9 @@ export default class Piper extends NotifyClass {
164
168
  * @private
165
169
  * @param {string} message - Context message
166
170
  * @param {Array<unknown>} settled - Results from settleAll
167
- * @throws {Tantrum} - If any rejected
171
+ * @throws {Tantrum} - If any settled result was rejected
168
172
  */
169
- #processResult(message, settled) {
173
+ #processResult(_message, settled) {
170
174
  if(Promised.hasRejected(settled))
171
175
  Promised.throw(settled)
172
176
  }
@@ -130,9 +130,17 @@ export default class ActionBuilder {
130
130
  * Finalises the builder and returns a payload that can be consumed by the
131
131
  * runner.
132
132
  *
133
+ * @param {ActionRunner} runner - The runner invoking the build.
133
134
  * @returns {Promise<ActionWrapper>} Payload consumed by the {@link ActionRunner} constructor.
134
135
  */
135
- build(runner: any): Promise<ActionWrapper>;
136
+ build(runner: ActionRunner): Promise<ActionWrapper>;
137
+ /**
138
+ * Returns the raw hooks value configured on this builder.
139
+ * Used by {@link ActionRunner} to access setup/cleanup lifecycle hooks.
140
+ *
141
+ * @returns {object|Function|null} Raw hooks value, or null if not configured.
142
+ */
143
+ get hooks(): object | Function | null;
136
144
  #private;
137
145
  }
138
146
  /**
@@ -199,5 +207,6 @@ export type ActivityDefinition = {
199
207
  */
200
208
  export type ActionFunction = (context: unknown) => unknown | Promise<unknown>;
201
209
  import ActionHooks from "./ActionHooks.js";
210
+ import type { default as ActionRunner } from "./ActionRunner.js";
202
211
  import ActionWrapper from "./ActionWrapper.js";
203
212
  //# sourceMappingURL=ActionBuilder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ActionBuilder.d.ts","sourceRoot":"","sources":["../../../browser/lib/ActionBuilder.js"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH;;;;;;;;;;;;;;;;;;;GAmBG;AACH;IAkBE;;;;;OAKG;IACH,qBAHW,mBAAmB,mBACnB,mBAAmB,EAkB7B;IAED,yBAEC;;;;;;;;;;;;;;;IAWE,SACQ,MAAM,GAAC,MAAM,MACb,cAAc,GACZ,aAAa,CACzB;;;;;;;;IAGE,SACQ,MAAM,GAAC,MAAM,QACb,MAAM,QACN,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,GAAC,OAAO,CAAC,OAAO,CAAC,GAC5C,aAAa,CACzB;;;;;;;;;IAGE,SACQ,MAAM,GAAC,MAAM,QACb,MAAM,QACN,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,GAAC,OAAO,CAAC,OAAO,CAAC,MAC9C,cAAc,GAAC,aAAa,GAC1B,aAAa,CACzB;;;;;;;;;;IAGE,SACQ,MAAM,GAAC,MAAM,QACb,MAAM,YACN,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,YAC7B,CAAC,eAAe,EAAE,OAAO,EAAE,YAA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AO,CAAC;;;;;6BAE/C,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,GAAC,OAAO,CAAC,OAAO,CAAC;wBA1BnC,kBAAkB;6CAMA,mBAAmB;0BAPnC,oBAAoB"}
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @typedef {object} ActionHooksConfig
8
8
  * @property {string} actionKind - Action identifier shared between runner and hooks.
9
- * @property {unknown} hooks - Already-instantiated hooks implementation.
9
+ * @property {object|Function|null} hooks - Pre-instantiated hooks object, a constructor to instantiate, or null.
10
10
  * @property {number} [hookTimeout] - Timeout applied to hook execution in milliseconds.
11
11
  * @property {DebugFn} debug - Logger to emit diagnostics.
12
12
  */
@@ -41,6 +41,8 @@ export default class ActionHooks {
41
41
  get actionKind(): string;
42
42
  /**
43
43
  * Gets the loaded hooks object.
44
+ * If the stored value is a plain object it is returned as-is.
45
+ * If it is a constructor function a new instance is created and returned.
44
46
  *
45
47
  * @returns {object?} Hooks object or null if not loaded
46
48
  */
@@ -68,10 +70,11 @@ export default class ActionHooks {
68
70
  *
69
71
  * @param {string} kind - Hook namespace.
70
72
  * @param {string|symbol} activityName - Activity identifier.
71
- * @param {unknown} context - Pipeline context supplied to the hook.
73
+ * @param {unknown} oldContext - Pipeline context supplied to the hook.
74
+ * @param {unknown} newContext - For after$ hooks, the result of the op
72
75
  * @returns {Promise<void>}
73
76
  */
74
- callHook(kind: string, activityName: string | symbol, context: unknown): Promise<void>;
77
+ callHook(kind: string, activityName: string | symbol, oldContext: unknown, newContext: unknown): Promise<void>;
75
78
  #private;
76
79
  }
77
80
  export type DebugFn = (message: string, level?: number, ...args: Array<unknown>) => void;
@@ -82,9 +85,9 @@ export type ActionHooksConfig = {
82
85
  */
83
86
  actionKind: string;
84
87
  /**
85
- * - Already-instantiated hooks implementation.
88
+ * - Pre-instantiated hooks object, a constructor to instantiate, or null.
86
89
  */
87
- hooks: unknown;
90
+ hooks: object | Function | null;
88
91
  /**
89
92
  * - Timeout applied to hook execution in milliseconds.
90
93
  */
@@ -1 +1 @@
1
- {"version":3,"file":"ActionHooks.d.ts","sourceRoot":"","sources":["../../../browser/lib/ActionHooks.js"],"names":[],"mappings":"AAEA;;GAEG;AAEH;;;;;;;;GAQG;AAEH;;;;;;GAMG;AACH;IAmEE;;;;;;;OAOG;IACH,qBAJW,iBAAiB,SACjB,OAAO,GACL,OAAO,CAAC,WAAW,OAAC,CAAC,CAgBjC;IA/ED;;;;OAIG;IACH,uDAFW,iBAAiB,EAO3B;IAED;;;;OAIG;IACH,kBAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,aAFa,MAAM,OAAC,CAInB;IAED;;;;OAIG;IACH,eAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,aAFa,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAIrC;IAED;;;;OAIG;IACH,eAFa,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAIrC;IA0BD;;;;;;;OAOG;IACH,eALW,MAAM,gBACN,MAAM,GAAC,MAAM,WACb,OAAO,GACL,OAAO,CAAC,IAAI,CAAC,CAwDzB;;CAmBF;sBAhMY,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI;yBAIlE,MAAM,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,GAAC,OAAO,CAAC;;;;;gBAG7D,MAAM;;;;WACN,OAAO;;;;;;;;WAEP,OAAO"}
1
+ {"version":3,"file":"ActionHooks.d.ts","sourceRoot":"","sources":["../../../browser/lib/ActionHooks.js"],"names":[],"mappings":"AAEA;;GAEG;AAEH;;;;;;;;GAQG;AAEH;;;;;;GAMG;AACH;IA2EE;;;;;;;OAOG;IACH,qBAJW,iBAAiB,SACjB,OAAO,GACL,OAAO,CAAC,WAAW,OAAC,CAAC,CAgBjC;IAvFD;;;;OAIG;IACH,uDAFW,iBAAiB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ActionRunner.d.ts","sourceRoot":"","sources":["../../../browser/lib/ActionRunner.js"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH;;;;;GAKG;AAEH;;;;;;GAMG;AACH;IAaE;;;;;OAKG;IACH,2BAHW,OAAO,oBAAoB,EAAE,OAAO,GAAC,IAAI,cACzC,mBAAmB,EAoB7B;IAoCD;;;;;;;;;;OAUG;IACH,aANW,OAAO,kBACP,OAAO,oBAAoB,EAAE,OAAO,GAAC,IAAI,GACvC,OAAO,CAAC,OAAO,CAAC,CAoJ5B;;CAiGF;sBAlVY,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI;;;;;;;kBAT7D,YAAY"}
@@ -2,7 +2,6 @@
2
2
  * Type imports
3
3
  *
4
4
  * @import {default as ActionHooks} from "./ActionHooks.js"
5
- * @import {default as ActionRunner} from "./ActionRunner.js"
6
5
  */
7
6
  /**
8
7
  * @typedef {object} WrappedActivityConfig
@@ -20,11 +19,19 @@ export default class ActionWrapper {
20
19
  /**
21
20
  * Create a wrapper from the builder payload.
22
21
  *
23
- * @param {{activities: Map<string|symbol, WrappedActivityConfig>, debug: (message: string, level?: number, ...args: Array<unknown>) => void}} init Builder payload containing activities + logger.
22
+ * @param {object} init - Builder payload.
23
+ * @param {Map<string|symbol, WrappedActivityConfig>} init.activities - Registered activities.
24
+ * @param {(message: string, level?: number, ...args: Array<unknown>) => void} init.debug - Logger.
25
+ * @param {import("./ActionHooks.js").default?} init.hooks - Optional hooks instance.
26
+ * @param {((context: unknown) => unknown|Promise<unknown>)|null} [init.done] - Optional done callback.
27
+ * @param {unknown} [init.action] - Optional parent action instance.
24
28
  */
25
29
  constructor({ activities, hooks, debug, done: doneCallback, action }: {
26
30
  activities: Map<string | symbol, WrappedActivityConfig>;
27
31
  debug: (message: string, level?: number, ...args: Array<unknown>) => void;
32
+ hooks: import("./ActionHooks.js").default | null;
33
+ done?: ((context: unknown) => unknown | Promise<unknown>) | null | undefined;
34
+ action?: unknown;
28
35
  });
29
36
  /**
30
37
  * Unique identifier for this wrapper instance.
@@ -1 +1 @@
1
- {"version":3,"file":"ActionWrapper.d.ts","sourceRoot":"","sources":["../../../browser/lib/ActionWrapper.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH;;;;;;;;GAQG;AAEH;;GAEG;AACH;IA0BE;;;;OAIG;IACH,sEAFW;QAAC,UAAU,EAAE,GAAG,CAAC,MAAM,GAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;QAAC,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI,CAAA;KAAC,EAwB5I;IAED;;;;;OAKG;IACH,UAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,kBAFa,QAAQ,CAAC,QAAQ,CAAC,CAI9B;IAED;;;;OAIG;IACH,YAFa,CAAC,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,GAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GAAC,IAAI,CAIjE;IAED;;;;OAIG;IACH,cAFa,OAAO,GAAC,IAAI,CAIxB;;CACF;;;;;UAtGa,MAAM,GAAC,MAAM;;;;QACb,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,GAAC,OAAO,CAAC,OAAO,CAAC,GAAC,aAAa;;;;;;;;sBAElD,OAAO,KAAK,OAAO,GAAC,OAAO,CAAC,OAAO,CAAC;;;;aAC9C,OAAO;;;;uBACG,MAAM,UAAU,MAAM,WAAW,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI;;qBAhB3D,eAAe"}
1
+ {"version":3,"file":"ActionWrapper.d.ts","sourceRoot":"","sources":["../../../browser/lib/ActionWrapper.js"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH;;;;;;;;GAQG;AAEH;;GAEG;AACH;IAwBE;;;;;;;;;OASG;IACH,sEANG;QAAwD,UAAU,EAA1D,GAAG,CAAC,MAAM,GAAC,MAAM,EAAE,qBAAqB,CAAC;QACgC,KAAK,EAA9E,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI;QACxB,KAAK,EAA/C,OAAO,kBAAkB,EAAE,OAAO,OAAC;QAC0B,IAAI,cAAtD,OAAO,KAAK,OAAO,GAAC,OAAO,CAAC,OAAO,CAAC;QAChC,MAAM,GAArB,OAAO;KACjB,EAuBA;IAED;;;;;OAKG;IACH,UAFa,MAAM,CAIlB;IAED;;;;OAIG;IACH,kBAFa,QAAQ,CAAC,QAAQ,CAAC,CAI9B;IAED;;;;OAIG;IACH,YAFa,CAAC,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,GAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GAAC,IAAI,CAIjE;IAED;;;;OAIG;IACH,cAFa,OAAO,GAAC,IAAI,CAIxB;;CACF;;;;;UAzGa,MAAM,GAAC,MAAM;;;;QACb,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,GAAC,OAAO,CAAC,OAAO,CAAC,GAAC,aAAa;;;;;;;;sBAElD,OAAO,KAAK,OAAO,GAAC,OAAO,CAAC,OAAO,CAAC;;;;aAC9C,OAAO;;;;uBACG,MAAM,UAAU,MAAM,WAAW,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI;;qBAf3D,eAAe"}
@@ -1,3 +1,6 @@
1
+ /**
2
+ * @import {Tantrum} from "@gesslar/toolkit"
3
+ */
1
4
  export default class Piper extends NotifyClass {
2
5
  /**
3
6
  * Create a Piper instance.
@@ -23,19 +26,19 @@ export default class Piper extends NotifyClass {
23
26
  /**
24
27
  * Add setup hook that runs before processing starts.
25
28
  *
26
- * @param {() => Promise<void>|void} fn - Setup function executed before processing
29
+ * @param {(items: Array<unknown>) => Promise<void>|void} fn - Setup function executed before processing; receives the full items array.
27
30
  * @param {unknown} [thisArg] - Optional this binding for the setup function
28
31
  * @returns {Piper} - The pipeline instance
29
32
  */
30
- addSetup(fn: () => Promise<void> | void, thisArg?: unknown): Piper;
33
+ addSetup(fn: (items: Array<unknown>) => Promise<void> | void, thisArg?: unknown): Piper;
31
34
  /**
32
35
  * Add cleanup hook that runs after processing completes
33
36
  *
34
- * @param {() => Promise<void>|void} fn - Cleanup function executed after processing
37
+ * @param {(items: Array<unknown>) => Promise<void>|void} fn - Cleanup function executed after processing; receives the full items array.
35
38
  * @param {unknown} [thisArg] - Optional this binding for the cleanup function
36
39
  * @returns {Piper} - The pipeline instance
37
40
  */
38
- addCleanup(fn: () => Promise<void> | void, thisArg?: unknown): Piper;
41
+ addCleanup(fn: (items: Array<unknown>) => Promise<void> | void, thisArg?: unknown): Piper;
39
42
  /**
40
43
  * Process items through the pipeline with concurrency control
41
44
  *
@@ -1 +1 @@
1
- {"version":3,"file":"Piper.d.ts","sourceRoot":"","sources":["../../../browser/lib/Piper.js"],"names":[],"mappings":"AAaA;IAWE;;;;OAIG;IACH,wBAFW;QAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI,CAAA;KAAC,EAUtF;IAMD,kBAEC;IAED;;;;;;;OAOG;IACH,YALW,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,GAAC,OAAO,YAC9C;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAC,YACnC,OAAO,GACL,KAAK,CAWjB;IAED;;;;;;OAMG;IACH,aAJW,MAAM,OAAO,CAAC,IAAI,CAAC,GAAC,IAAI,YACxB,OAAO,GACL,KAAK,CAMjB;IAED;;;;;;OAMG;IACH,eAJW,MAAM,OAAO,CAAC,IAAI,CAAC,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