@adonisjs/assembler 8.0.0-next.6 → 8.0.0-next.8

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.
@@ -0,0 +1,224 @@
1
+ import { type AsyncOrSync } from '@poppinss/utils/types';
2
+ import { type HookParams } from './types/hooks.ts';
3
+ /**
4
+ * Collection of hooks that can be used to listen for various events during
5
+ * the application lifecycle. These hooks allow you to execute custom logic
6
+ * at specific points in the development server, build process, and testing.
7
+ *
8
+ * @example
9
+ * ```js
10
+ * const { hooks } = await import('@adonisjs/assembler/hooks')
11
+ *
12
+ * hooks.init((app) => {
13
+ * console.log('Application initialized')
14
+ * })
15
+ *
16
+ * hooks.devServerStarted((server) => {
17
+ * console.log('Dev server started on port', server.port)
18
+ * })
19
+ * ```
20
+ */
21
+ export declare const hooks: {
22
+ /**
23
+ * Hook called during application initialization. This is the first hook
24
+ * that gets executed when the assembler starts up.
25
+ *
26
+ * @param callback - Function to execute when the init event occurs
27
+ *
28
+ * @example
29
+ * ```js
30
+ * hooks.init((app) => {
31
+ * console.log('Application is initializing')
32
+ * // Setup global configurations
33
+ * })
34
+ * ```
35
+ */
36
+ init(callback: (...args: HookParams<"init">) => AsyncOrSync<void>): (parent: import("./dev_server.ts").DevServer | import("./test_runner.ts").TestRunner | import("./bundler.ts").Bundler, indexGenerator: import("./index_generator/main.ts").IndexGenerator) => AsyncOrSync<void>;
37
+ /**
38
+ * Hook called after routes have been committed to the router.
39
+ * This occurs after all route definitions have been processed.
40
+ *
41
+ * @param callback - Function to execute when routes are committed
42
+ *
43
+ * @example
44
+ * ```js
45
+ * hooks.routesCommitted((router) => {
46
+ * console.log('All routes have been committed to the router')
47
+ * // Perform route-based setup
48
+ * })
49
+ * ```
50
+ */
51
+ routesCommitted(callback: (...args: HookParams<"routesCommitted">) => AsyncOrSync<void>): (parent: import("./dev_server.ts").DevServer, routes: Record<string, import("./types/code_scanners.ts").RoutesListItem[]>) => AsyncOrSync<void>;
52
+ /**
53
+ * Hook called when the assembler starts scanning for route files.
54
+ * This happens before any route files are actually processed.
55
+ *
56
+ * @param callback - Function to execute when route scanning begins
57
+ *
58
+ * @example
59
+ * ```js
60
+ * hooks.routesScanning(() => {
61
+ * console.log('Starting to scan for route files')
62
+ * // Setup route scanning configurations
63
+ * })
64
+ * ```
65
+ */
66
+ routesScanning(callback: (...args: HookParams<"routesScanning">) => AsyncOrSync<void>): (parent: import("./dev_server.ts").DevServer, routesScanner: import("./code_scanners/routes_scanner/main.ts").RoutesScanner) => AsyncOrSync<void>;
67
+ /**
68
+ * Hook called after all route files have been scanned and processed.
69
+ * This occurs once the route scanning phase is complete.
70
+ *
71
+ * @param callback - Function to execute when route scanning is finished
72
+ *
73
+ * @example
74
+ * ```js
75
+ * hooks.routesScanned((scannedRoutes) => {
76
+ * console.log('Route scanning completed')
77
+ * // Process scanned route information
78
+ * })
79
+ * ```
80
+ */
81
+ routesScanned(callback: (...args: HookParams<"routesScanned">) => AsyncOrSync<void>): (parent: import("./dev_server.ts").DevServer, routesScanner: import("./code_scanners/routes_scanner/main.ts").RoutesScanner) => AsyncOrSync<void>;
82
+ /**
83
+ * Hook called when a file is modified during development.
84
+ * This is triggered by the file watcher when changes are detected.
85
+ *
86
+ * @param callback - Function to execute when a file changes
87
+ *
88
+ * @example
89
+ * ```js
90
+ * hooks.fileChanged((filePath, stats) => {
91
+ * console.log(`File changed: ${filePath}`)
92
+ * // Handle file change logic
93
+ * })
94
+ * ```
95
+ */
96
+ fileChanged(callback: (...args: HookParams<"fileChanged">) => AsyncOrSync<void>): (relativePath: string, absolutePath: string, info: {
97
+ source: "hot-hook" | "watcher";
98
+ hotReloaded: boolean;
99
+ fullReload: boolean;
100
+ }, parent: import("./dev_server.ts").DevServer | import("./test_runner.ts").TestRunner) => AsyncOrSync<void>;
101
+ /**
102
+ * Hook called when a new file is added during development.
103
+ * This is triggered by the file watcher when new files are created.
104
+ *
105
+ * @param callback - Function to execute when a file is added
106
+ *
107
+ * @example
108
+ * ```js
109
+ * hooks.fileAdded((filePath, stats) => {
110
+ * console.log(`New file added: ${filePath}`)
111
+ * // Handle new file logic
112
+ * })
113
+ * ```
114
+ */
115
+ fileAdded(callback: (...args: HookParams<"fileAdded">) => AsyncOrSync<void>): (relativePath: string, absolutePath: string, server: import("./dev_server.ts").DevServer | import("./test_runner.ts").TestRunner) => AsyncOrSync<void>;
116
+ /**
117
+ * Hook called when a file is removed during development.
118
+ * This is triggered by the file watcher when files are deleted.
119
+ *
120
+ * @param callback - Function to execute when a file is removed
121
+ *
122
+ * @example
123
+ * ```js
124
+ * hooks.fileRemoved((filePath) => {
125
+ * console.log(`File removed: ${filePath}`)
126
+ * // Handle file removal logic
127
+ * })
128
+ * ```
129
+ */
130
+ fileRemoved(callback: (...args: HookParams<"fileRemoved">) => AsyncOrSync<void>): (relativePath: string, absolutePath: string, server: import("./dev_server.ts").DevServer | import("./test_runner.ts").TestRunner) => AsyncOrSync<void>;
131
+ /**
132
+ * Hook called when the development server is about to start.
133
+ * This occurs before the server begins listening for connections.
134
+ *
135
+ * @param callback - Function to execute when dev server is starting
136
+ *
137
+ * @example
138
+ * ```js
139
+ * hooks.devServerStarting((server) => {
140
+ * console.log('Development server is starting')
141
+ * // Setup server configurations
142
+ * })
143
+ * ```
144
+ */
145
+ devServerStarting(callback: (...args: HookParams<"devServerStarting">) => AsyncOrSync<void>): (server: import("./dev_server.ts").DevServer) => AsyncOrSync<void>;
146
+ /**
147
+ * Hook called after the development server has successfully started.
148
+ * This occurs once the server is listening and ready to accept requests.
149
+ *
150
+ * @param callback - Function to execute when dev server has started
151
+ *
152
+ * @example
153
+ * ```js
154
+ * hooks.devServerStarted((server) => {
155
+ * console.log(`Development server started on port ${server.port}`)
156
+ * // Notify external services or open browser
157
+ * })
158
+ * ```
159
+ */
160
+ devServerStarted(callback: (...args: HookParams<"devServerStarted">) => AsyncOrSync<void>): (server: import("./dev_server.ts").DevServer, info: {
161
+ port: number;
162
+ host: string;
163
+ }, uiInstructions: import("@poppinss/cliui").Instructions) => AsyncOrSync<void>;
164
+ /**
165
+ * Hook called when the build process is about to start.
166
+ * This occurs before any build tasks are executed.
167
+ *
168
+ * @param callback - Function to execute when build is starting
169
+ *
170
+ * @example
171
+ * ```js
172
+ * hooks.buildStarting((buildConfig) => {
173
+ * console.log('Build process is starting')
174
+ * // Setup build configurations or clean directories
175
+ * })
176
+ * ```
177
+ */
178
+ buildStarting(callback: (...args: HookParams<"buildStarting">) => AsyncOrSync<void>): (server: import("./bundler.ts").Bundler) => AsyncOrSync<void>;
179
+ /**
180
+ * Hook called after the build process has completed.
181
+ * This occurs once all build tasks have finished executing.
182
+ *
183
+ * @param callback - Function to execute when build is finished
184
+ *
185
+ * @example
186
+ * ```js
187
+ * hooks.buildFinished((buildResult) => {
188
+ * console.log('Build process completed')
189
+ * // Deploy artifacts or notify build completion
190
+ * })
191
+ * ```
192
+ */
193
+ buildFinished(callback: (...args: HookParams<"buildFinished">) => AsyncOrSync<void>): (server: import("./bundler.ts").Bundler, uiInstructions: import("@poppinss/cliui").Instructions) => AsyncOrSync<void>;
194
+ /**
195
+ * Hook called when the test suite is about to start.
196
+ * This occurs before any test files are executed.
197
+ *
198
+ * @param callback - Function to execute when tests are starting
199
+ *
200
+ * @example
201
+ * ```js
202
+ * hooks.testsStarting((testConfig) => {
203
+ * console.log('Test suite is starting')
204
+ * // Setup test database or mock services
205
+ * })
206
+ * ```
207
+ */
208
+ testsStarting(callback: (...args: HookParams<"testsStarting">) => AsyncOrSync<void>): (server: import("./test_runner.ts").TestRunner) => AsyncOrSync<void>;
209
+ /**
210
+ * Hook called after the test suite has completed.
211
+ * This occurs once all test files have finished executing.
212
+ *
213
+ * @param callback - Function to execute when tests are finished
214
+ *
215
+ * @example
216
+ * ```js
217
+ * hooks.testsFinished((testResults) => {
218
+ * console.log('Test suite completed')
219
+ * // Generate test reports or cleanup test resources
220
+ * })
221
+ * ```
222
+ */
223
+ testsFinished(callback: (...args: HookParams<"testsFinished">) => AsyncOrSync<void>): (server: import("./test_runner.ts").TestRunner) => AsyncOrSync<void>;
224
+ };
@@ -19,6 +19,10 @@ import { type IndexGeneratorSourceConfig } from '../types/common.ts';
19
19
  */
20
20
  export declare class IndexGenerator {
21
21
  #private;
22
+ /**
23
+ * The application root directory path
24
+ */
25
+ appRoot: string;
22
26
  /**
23
27
  * Create a new IndexGenerator instance
24
28
  *
@@ -26,15 +30,6 @@ export declare class IndexGenerator {
26
30
  * @param cliLogger - Logger instance for CLI output
27
31
  */
28
32
  constructor(appRoot: string, cliLogger: Logger);
29
- /**
30
- * Set the logger instance used for CLI output
31
- *
32
- * Updates the CLI logger instance for this index generator and all
33
- * registered sources to use the new logger for output.
34
- *
35
- * @param cliLogger - New logger instance to use
36
- */
37
- setLogger(cliLogger: Logger): void;
38
33
  /**
39
34
  * Add a new index generator source
40
35
  *
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  IndexGenerator
3
- } from "../../chunk-MC3FJR62.js";
4
- import "../../chunk-F4RAGKQN.js";
3
+ } from "../../chunk-N6H4XTTC.js";
4
+ import "../../chunk-PORDZS62.js";
5
5
  export {
6
6
  IndexGenerator
7
7
  };
@@ -32,12 +32,6 @@ export declare class IndexGeneratorSource {
32
32
  * @param config - Configuration for this index generator source
33
33
  */
34
34
  constructor(name: string, appRoot: string, cliLogger: Logger, config: IndexGeneratorSourceConfig);
35
- /**
36
- * Set the logger instance used for CLI output
37
- *
38
- * @param cliLogger - New logger instance to use
39
- */
40
- setLogger(cliLogger: Logger): void;
41
35
  /**
42
36
  * Add a file to the virtual file system and regenerate index if needed
43
37
  *
@@ -1,5 +1,4 @@
1
1
  import type tsStatic from 'typescript';
2
- import { cliui } from '@poppinss/cliui';
3
2
  import type { TestRunnerOptions } from './types/common.ts';
4
3
  /**
5
4
  * Exposes the API to run Japa tests and optionally watch for file
@@ -27,13 +26,29 @@ import type { TestRunnerOptions } from './types/common.ts';
27
26
  export declare class TestRunner {
28
27
  #private;
29
28
  /**
30
- * CLI UI instance to log colorful messages and progress information
29
+ * CLI UI instance for displaying colorful messages and progress information
31
30
  */
32
- get ui(): ReturnType<typeof cliui>;
33
- /**
34
- * CLI UI instance to log colorful messages and progress information
35
- */
36
- set ui(ui: ReturnType<typeof cliui>);
31
+ ui: {
32
+ colors: import("@poppinss/colors/types").Colors;
33
+ logger: import("@poppinss/cliui").Logger;
34
+ table: (tableOptions?: Partial<import("@poppinss/cliui/types").TableOptions>) => import("@poppinss/cliui").Table;
35
+ tasks: (tasksOptions?: Partial<import("@poppinss/cliui/types").TaskManagerOptions>) => import("@poppinss/cliui").TaskManager;
36
+ icons: {
37
+ tick: string;
38
+ cross: string;
39
+ bullet: string;
40
+ nodejs: string;
41
+ pointer: string;
42
+ info: string;
43
+ warning: string;
44
+ squareSmallFilled: string;
45
+ };
46
+ sticker: () => import("@poppinss/cliui").Instructions;
47
+ instructions: () => import("@poppinss/cliui").Instructions;
48
+ switchMode(modeToUse: "raw" | "silent" | "normal"): void;
49
+ useRenderer(rendererToUse: import("@poppinss/cliui/types").RendererContract): void;
50
+ useColors(colorsToUse: import("@poppinss/colors/types").Colors): void;
51
+ };
37
52
  /**
38
53
  * The script file to run as a child process
39
54
  */
@@ -42,6 +57,10 @@ export declare class TestRunner {
42
57
  * The current working directory URL
43
58
  */
44
59
  cwd: URL;
60
+ /**
61
+ * The current working directory path as a string
62
+ */
63
+ cwdPath: string;
45
64
  /**
46
65
  * Test runner configuration options including filters, reporters, and hooks
47
66
  */
@@ -1,8 +1,9 @@
1
1
  import type { Logger } from '@poppinss/cliui';
2
2
  import { type Prettify } from '@poppinss/utils/types';
3
+ import type StringBuilder from '@poppinss/utils/string_builder';
4
+ import { type AllHooks } from './hooks.ts';
3
5
  import { type FileBuffer } from '../file_buffer.ts';
4
6
  import { type VirtualFileSystem } from '../virtual_file_system.ts';
5
- import { type CommonHooks, type RouterHooks, type BundlerHooks, type WatcherHooks, type DevServerHooks, type TestRunnerHooks } from './hooks.ts';
6
7
  /**
7
8
  * Recursive file tree structure for representing nested directory hierarchies
8
9
  */
@@ -22,8 +23,11 @@ export type IndexGeneratorSourceConfig = ({
22
23
  exportName: string;
23
24
  as: 'barrelFile';
24
25
  } | {
25
- as: (vfs: VirtualFileSystem, buffer: FileBuffer, config: IndexGeneratorSourceConfig) => void;
26
+ as: (vfs: VirtualFileSystem, buffer: FileBuffer, config: IndexGeneratorSourceConfig, helpers: {
27
+ toImportPath(filePath: string): string;
28
+ }) => void;
26
29
  }) & {
30
+ computeBaseName?: (baseName: StringBuilder) => StringBuilder;
27
31
  source: string;
28
32
  output: string;
29
33
  glob?: string[];
@@ -121,7 +125,7 @@ export type AssemblerRcFile = {
121
125
  /**
122
126
  * Hooks to execute at different stages of development and build processes
123
127
  */
124
- hooks?: Partial<CommonHooks & WatcherHooks & DevServerHooks & BundlerHooks & TestRunnerHooks & RouterHooks>;
128
+ hooks?: Partial<AllHooks>;
125
129
  /**
126
130
  * An array of test suites configuration
127
131
  */
@@ -4,8 +4,27 @@ import { type Bundler } from '../bundler.ts';
4
4
  import { type DevServer } from '../dev_server.ts';
5
5
  import { type TestRunner } from '../test_runner.ts';
6
6
  import { type RoutesListItem } from './code_scanners.ts';
7
- import { type RoutesScanner } from '../code_scanners/routes_scanner/main.ts';
8
7
  import { type IndexGenerator } from '../index_generator/main.ts';
8
+ import { type RoutesScanner } from '../code_scanners/routes_scanner/main.ts';
9
+ /**
10
+ * Defines a hook that can be either a lazy import or an object with a run method.
11
+ * This type provides flexibility in how hooks are defined and imported, supporting
12
+ * both dynamic imports for code splitting and direct object definitions.
13
+ *
14
+ * @template Fn - The function signature that the hook must conform to
15
+ *
16
+ * @example
17
+ * // Using lazy import
18
+ * const hook: DefineHook<(server: DevServer) => void> = () => import('./my-hook')
19
+ *
20
+ * // Using direct object
21
+ * const hook: DefineHook<(server: DevServer) => void> = {
22
+ * run: (server) => console.log('Hook executed')
23
+ * }
24
+ */
25
+ type DefineHook<Fn extends (...args: any) => any> = LazyImport<Fn> | {
26
+ run: Fn;
27
+ };
9
28
  /**
10
29
  * Common hooks executed by the dev-server, test runner and the bundler.
11
30
  * These hooks are shared across all assembler operations and provide
@@ -26,7 +45,7 @@ export type CommonHooks = {
26
45
  *
27
46
  * @param parent - The parent instance (DevServer, TestRunner, or Bundler)
28
47
  */
29
- init: LazyImport<(parent: DevServer | TestRunner | Bundler, indexGenerator: IndexGenerator) => AsyncOrSync<void>>[];
48
+ init: DefineHook<(parent: DevServer | TestRunner | Bundler, indexGenerator: IndexGenerator) => AsyncOrSync<void>>[];
30
49
  };
31
50
  /**
32
51
  * Hooks executed by the dev server around the router.
@@ -53,7 +72,7 @@ export type RouterHooks = {
53
72
  * @param parent - The DevServer instance
54
73
  * @param routes - Record of routes grouped by domain or method
55
74
  */
56
- routesCommitted: LazyImport<(parent: DevServer, routes: Record<string, RoutesListItem[]>) => AsyncOrSync<void>>[];
75
+ routesCommitted: DefineHook<(parent: DevServer, routes: Record<string, RoutesListItem[]>) => AsyncOrSync<void>>[];
57
76
  /**
58
77
  * The hook is executed when dev server begins the routes scanning process.
59
78
  * Use this hook to prepare for route scanning or modify scanner configuration.
@@ -61,7 +80,7 @@ export type RouterHooks = {
61
80
  * @param parent - The DevServer instance
62
81
  * @param routesScanner - The RoutesScanner instance being used
63
82
  */
64
- routesScanning: LazyImport<(parent: DevServer, routesScanner: RoutesScanner) => AsyncOrSync<void>>[];
83
+ routesScanning: DefineHook<(parent: DevServer, routesScanner: RoutesScanner) => AsyncOrSync<void>>[];
65
84
  /**
66
85
  * The hook is executed when routes scanning process has finished.
67
86
  * Use this hook to process the scanned routes or clean up resources.
@@ -69,7 +88,7 @@ export type RouterHooks = {
69
88
  * @param parent - The DevServer instance
70
89
  * @param routesScanner - The RoutesScanner instance that was used
71
90
  */
72
- routesScanned: LazyImport<(parent: DevServer, routesScanner: RoutesScanner) => AsyncOrSync<void>>[];
91
+ routesScanned: DefineHook<(parent: DevServer, routesScanner: RoutesScanner) => AsyncOrSync<void>>[];
73
92
  };
74
93
  /**
75
94
  * Hooks executed by the file watcher during development and testing.
@@ -103,7 +122,7 @@ export type WatcherHooks = {
103
122
  * @param info.fullReload - Whether a full server reload is required
104
123
  * @param parent - The parent DevServer or TestRunner instance
105
124
  */
106
- fileChanged: LazyImport<(relativePath: string, absolutePath: string, info: {
125
+ fileChanged: DefineHook<(relativePath: string, absolutePath: string, info: {
107
126
  /** Source of the file change notification */
108
127
  source: 'hot-hook' | 'watcher';
109
128
  /** Whether the file was hot reloaded without server restart */
@@ -118,7 +137,7 @@ export type WatcherHooks = {
118
137
  * @param filePath - The absolute path to the added file
119
138
  * @param server - The DevServer or TestRunner instance
120
139
  */
121
- fileAdded: LazyImport<(relativePath: string, absolutePath: string, server: DevServer | TestRunner) => AsyncOrSync<void>>[];
140
+ fileAdded: DefineHook<(relativePath: string, absolutePath: string, server: DevServer | TestRunner) => AsyncOrSync<void>>[];
122
141
  /**
123
142
  * The hook is executed after a file has been removed from the filesystem.
124
143
  * Use this hook to clean up resources or update caches when files are deleted.
@@ -126,7 +145,7 @@ export type WatcherHooks = {
126
145
  * @param filePath - The absolute path to the removed file
127
146
  * @param server - The DevServer or TestRunner instance
128
147
  */
129
- fileRemoved: LazyImport<(relativePath: string, absolutePath: string, server: DevServer | TestRunner) => AsyncOrSync<void>>[];
148
+ fileRemoved: DefineHook<(relativePath: string, absolutePath: string, server: DevServer | TestRunner) => AsyncOrSync<void>>[];
130
149
  };
131
150
  /**
132
151
  * Hooks executed when running the development server.
@@ -148,7 +167,7 @@ export type DevServerHooks = {
148
167
  *
149
168
  * @param server - The DevServer instance that is about to start
150
169
  */
151
- devServerStarting: LazyImport<(server: DevServer) => AsyncOrSync<void>>[];
170
+ devServerStarting: DefineHook<(server: DevServer) => AsyncOrSync<void>>[];
152
171
  /**
153
172
  * The hook is executed after the child process has been started.
154
173
  * Use this hook to display additional information or perform post-startup tasks.
@@ -159,7 +178,7 @@ export type DevServerHooks = {
159
178
  * @param info.host - The host address the server is bound to
160
179
  * @param uiInstructions - UI instructions for displaying server information
161
180
  */
162
- devServerStarted: LazyImport<(server: DevServer, info: {
181
+ devServerStarted: DefineHook<(server: DevServer, info: {
163
182
  port: number;
164
183
  host: string;
165
184
  }, uiInstructions: Instructions) => AsyncOrSync<void>>[];
@@ -184,7 +203,7 @@ export type BundlerHooks = {
184
203
  *
185
204
  * @param server - The Bundler instance that will create the build
186
205
  */
187
- buildStarting: LazyImport<(server: Bundler) => AsyncOrSync<void>>[];
206
+ buildStarting: DefineHook<(server: Bundler) => AsyncOrSync<void>>[];
188
207
  /**
189
208
  * The hook is executed after the production build has been created.
190
209
  * Use this hook to perform post-build tasks or display build statistics.
@@ -192,7 +211,7 @@ export type BundlerHooks = {
192
211
  * @param server - The Bundler instance that created the build
193
212
  * @param uiInstructions - UI instructions for displaying build information
194
213
  */
195
- buildFinished: LazyImport<(server: Bundler, uiInstructions: Instructions) => AsyncOrSync<void>>[];
214
+ buildFinished: DefineHook<(server: Bundler, uiInstructions: Instructions) => AsyncOrSync<void>>[];
196
215
  };
197
216
  /**
198
217
  * Hooks executed when running the test suite.
@@ -214,12 +233,50 @@ export type TestRunnerHooks = {
214
233
  *
215
234
  * @param server - The TestRunner instance that will execute the tests
216
235
  */
217
- testsStarting: LazyImport<(server: TestRunner) => AsyncOrSync<void>>[];
236
+ testsStarting: DefineHook<(server: TestRunner) => AsyncOrSync<void>>[];
218
237
  /**
219
238
  * The hook is executed after the tests have been executed.
220
239
  * Use this hook to clean up resources or generate test reports.
221
240
  *
222
241
  * @param server - The TestRunner instance that executed the tests
223
242
  */
224
- testsFinished: LazyImport<(server: TestRunner) => AsyncOrSync<void>>[];
243
+ testsFinished: DefineHook<(server: TestRunner) => AsyncOrSync<void>>[];
225
244
  };
245
+ /**
246
+ * Combined type representing all available hooks across the assembler ecosystem.
247
+ * This intersection type merges all hook categories into a single type for
248
+ * comprehensive hook management and type safety.
249
+ *
250
+ * @example
251
+ * ```js
252
+ * const allHooks: AllHooks = {
253
+ * init: [() => import('./hooks/init')],
254
+ * fileChanged: [() => import('./hooks/file_changed')],
255
+ * devServerStarted: [() => import('./hooks/dev_server_started')],
256
+ * buildFinished: [() => import('./hooks/build_finished')],
257
+ * testsFinished: [() => import('./hooks/tests_finished')],
258
+ * routesCommitted: [() => import('./hooks/routes_committed')]
259
+ * }
260
+ * ```
261
+ */
262
+ export type AllHooks = CommonHooks & WatcherHooks & DevServerHooks & BundlerHooks & TestRunnerHooks & RouterHooks;
263
+ /**
264
+ * Utility type that extracts the parameter types for a specific hook.
265
+ * This type helps maintain type safety when working with hook callbacks
266
+ * by providing the exact parameter signature for any given hook name.
267
+ *
268
+ * @template Hook - The name of the hook to extract parameters for
269
+ *
270
+ * @example
271
+ * ```js
272
+ * // Get parameters for the fileChanged hook
273
+ * type FileChangedParams = HookParams<'fileChanged'>
274
+ * // Result: [string, string, {...}, DevServer | TestRunner]
275
+ *
276
+ * // Get parameters for the devServerStarted hook
277
+ * type DevServerStartedParams = HookParams<'devServerStarted')
278
+ * // Result: [DevServer, {port: number, host: string}, Instructions]
279
+ * ```
280
+ */
281
+ export type HookParams<Hook extends keyof AllHooks> = AllHooks[Hook][number] extends DefineHook<infer A> ? Parameters<A> : never;
282
+ export {};
@@ -1,9 +1,8 @@
1
1
  import Hooks from '@poppinss/hooks';
2
2
  import type tsStatic from 'typescript';
3
3
  import { type ChokidarOptions } from 'chokidar';
4
- import { type UnWrapLazyImport } from '@poppinss/utils/types';
5
4
  import type { RunScriptOptions } from './types/common.ts';
6
- import { type CommonHooks, type RouterHooks, type WatcherHooks, type BundlerHooks, type DevServerHooks, type TestRunnerHooks } from './types/hooks.ts';
5
+ import { type AllHooks, type HookParams } from './types/hooks.ts';
7
6
  /**
8
7
  * Parses tsconfig.json and prints errors using typescript compiler host
9
8
  *
@@ -145,8 +144,7 @@ export declare function isRelative(pathValue: string): boolean;
145
144
  * @param names - Array of hook names to load
146
145
  * @returns Promise resolving to configured Hooks instance
147
146
  */
148
- type AllHooks = CommonHooks & RouterHooks & WatcherHooks & DevServerHooks & BundlerHooks & TestRunnerHooks;
149
- export declare function loadHooks<K extends keyof AllHooks>(rcFileHooks: Partial<AllHooks> | undefined, names: K[]): Promise<Hooks<{ [P in K]: [Parameters<UnWrapLazyImport<AllHooks[K][number]>>, Parameters<UnWrapLazyImport<AllHooks[K][number]>>]; }>>;
147
+ export declare function loadHooks<K extends keyof AllHooks>(rcFileHooks: Partial<AllHooks> | undefined, names: K[]): Promise<Hooks<{ [P in K]: [HookParams<P>, HookParams<P>]; }>>;
150
148
  /**
151
149
  * Wraps a function inside another function that throttles the concurrent
152
150
  * executions of a function. If the function is called too quickly, then
@@ -167,4 +165,3 @@ export declare function throttle<Args extends any[]>(fn: (...args: Args) => Prom
167
165
  * @returns The file path without extension
168
166
  */
169
167
  export declare function removeExtension(filePath: string): string;
170
- export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@adonisjs/assembler",
3
3
  "description": "Provides utilities to run AdonisJS development server and build project for production",
4
- "version": "8.0.0-next.6",
4
+ "version": "8.0.0-next.8",
5
5
  "engines": {
6
6
  "node": ">=24.0.0"
7
7
  },
@@ -33,6 +33,7 @@
33
33
  "precompile": "npm run lint && npm run clean",
34
34
  "compile": "tsup-node && tsc --emitDeclarationOnly --declaration",
35
35
  "build": "npm run compile",
36
+ "docs": "typedoc",
36
37
  "release": "release-it",
37
38
  "version": "npm run build",
38
39
  "prepublishOnly": "npm run build",
@@ -48,18 +49,19 @@
48
49
  "@japa/snapshot": "^2.0.9",
49
50
  "@poppinss/ts-exec": "^1.4.1",
50
51
  "@release-it/conventional-changelog": "^10.0.1",
51
- "@types/node": "^24.3.0",
52
+ "@types/node": "^24.3.1",
52
53
  "@types/picomatch": "^4.0.2",
53
54
  "@types/pretty-hrtime": "^1.0.3",
54
55
  "c8": "^10.1.3",
55
56
  "cross-env": "^10.0.0",
56
57
  "del-cli": "^6.0.0",
57
- "eslint": "^9.34.0",
58
+ "eslint": "^9.35.0",
58
59
  "hot-hook": "^0.4.1-next.0",
59
60
  "p-event": "^6.0.1",
60
61
  "prettier": "^3.6.2",
61
62
  "release-it": "^19.0.4",
62
63
  "tsup": "^8.5.0",
64
+ "typedoc": "^0.28.12",
63
65
  "typescript": "^5.9.2"
64
66
  },
65
67
  "dependencies": {
@@ -70,7 +72,7 @@
70
72
  "@poppinss/hooks": "^7.2.6",
71
73
  "@poppinss/utils": "^7.0.0-next.3",
72
74
  "chokidar": "^4.0.3",
73
- "dedent": "^1.6.0",
75
+ "dedent": "^1.7.0",
74
76
  "execa": "^9.6.0",
75
77
  "fast-glob": "^3.3.3",
76
78
  "fdir": "^6.5.0",