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

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 (35) hide show
  1. package/README.md +87 -59
  2. package/build/chunk-F4RAGKQN.js +387 -0
  3. package/build/chunk-MC3FJR62.js +411 -0
  4. package/build/chunk-TIKQQRMX.js +116 -0
  5. package/build/index.d.ts +1 -0
  6. package/build/index.js +606 -410
  7. package/build/src/bundler.d.ts +40 -3
  8. package/build/src/code_scanners/routes_scanner/main.d.ts +49 -9
  9. package/build/src/code_scanners/routes_scanner/main.js +445 -0
  10. package/build/src/code_scanners/routes_scanner/validator_extractor.d.ts +12 -4
  11. package/build/src/code_transformer/main.d.ts +44 -43
  12. package/build/src/code_transformer/main.js +123 -101
  13. package/build/src/code_transformer/rc_file_transformer.d.ts +56 -4
  14. package/build/src/debug.d.ts +12 -0
  15. package/build/src/dev_server.d.ts +40 -30
  16. package/build/src/file_buffer.d.ts +67 -0
  17. package/build/src/file_system.d.ts +45 -7
  18. package/build/src/helpers.d.ts +79 -4
  19. package/build/src/helpers.js +16 -0
  20. package/build/src/index_generator/main.d.ts +73 -0
  21. package/build/src/index_generator/main.js +7 -0
  22. package/build/src/index_generator/source.d.ts +66 -0
  23. package/build/src/paths_resolver.d.ts +27 -2
  24. package/build/src/shortcuts_manager.d.ts +42 -4
  25. package/build/src/test_runner.d.ts +58 -31
  26. package/build/src/types/code_scanners.d.ts +138 -24
  27. package/build/src/types/code_transformer.d.ts +61 -19
  28. package/build/src/types/common.d.ts +199 -55
  29. package/build/src/types/hooks.d.ts +173 -17
  30. package/build/src/types/main.d.ts +13 -0
  31. package/build/src/utils.d.ts +88 -10
  32. package/build/src/virtual_file_system.d.ts +112 -0
  33. package/package.json +9 -3
  34. package/build/chunk-RR4HCA4M.js +0 -7
  35. package/build/src/ast_file_system.d.ts +0 -17
@@ -1,4 +1,5 @@
1
1
  import type tsStatic from 'typescript';
2
+ import { cliui } from '@poppinss/cliui';
2
3
  import type { DevServerOptions } from './types/common.ts';
3
4
  /**
4
5
  * Exposes the API to start the development server in HMR, watch or static mode.
@@ -9,35 +10,21 @@ import type { DevServerOptions } from './types/common.ts';
9
10
  * In watch mode, the DevServer will start an internal watcher and restarts the after
10
11
  * every file change. The files must be part of the TypeScript project (via tsconfig.json),
11
12
  * or registered as metaFiles.
13
+ *
14
+ * @example
15
+ * const devServer = new DevServer(cwd, { hmr: true, hooks: [] })
16
+ * await devServer.start(ts)
12
17
  */
13
18
  export declare class DevServer {
14
19
  #private;
15
- cwd: URL;
16
- options: DevServerOptions;
17
20
  /**
18
- * CLI UI to log colorful messages
21
+ * CLI UI instance to log colorful messages and progress information
19
22
  */
20
- ui: {
21
- colors: import("@poppinss/colors/types").Colors;
22
- logger: import("@poppinss/cliui").Logger;
23
- table: (tableOptions?: Partial<import("@poppinss/cliui/types").TableOptions>) => import("@poppinss/cliui").Table;
24
- tasks: (tasksOptions?: Partial<import("@poppinss/cliui/types").TaskManagerOptions>) => import("@poppinss/cliui").TaskManager;
25
- icons: {
26
- tick: string;
27
- cross: string;
28
- bullet: string;
29
- nodejs: string;
30
- pointer: string;
31
- info: string;
32
- warning: string;
33
- squareSmallFilled: string;
34
- };
35
- sticker: () => import("@poppinss/cliui").Instructions;
36
- instructions: () => import("@poppinss/cliui").Instructions;
37
- switchMode(modeToUse: "raw" | "silent" | "normal"): void;
38
- useRenderer(rendererToUse: import("@poppinss/cliui/types").RendererContract): void;
39
- useColors(colorsToUse: import("@poppinss/colors/types").Colors): void;
40
- };
23
+ get ui(): ReturnType<typeof cliui>;
24
+ /**
25
+ * CLI UI instance to log colorful messages and progress information
26
+ */
27
+ set ui(ui: ReturnType<typeof cliui>);
41
28
  /**
42
29
  * The mode in which the DevServer is running.
43
30
  */
@@ -46,15 +33,33 @@ export declare class DevServer {
46
33
  * Script file to start the development server
47
34
  */
48
35
  scriptFile: string;
36
+ /**
37
+ * The current working directory URL
38
+ */
39
+ cwd: URL;
40
+ /**
41
+ * Development server configuration options including hooks and environment variables
42
+ */
43
+ options: DevServerOptions;
44
+ /**
45
+ * Create a new DevServer instance
46
+ *
47
+ * @param cwd - The current working directory URL
48
+ * @param options - Development server configuration options
49
+ */
49
50
  constructor(cwd: URL, options: DevServerOptions);
50
51
  /**
51
- * Add listener to get notified when dev server is
52
- * closed
52
+ * Add listener to get notified when dev server is closed
53
+ *
54
+ * @param callback - Function to call when dev server closes
55
+ * @returns This DevServer instance for method chaining
53
56
  */
54
57
  onClose(callback: (exitCode: number) => any): this;
55
58
  /**
56
- * Add listener to get notified when dev server exists
57
- * with an error
59
+ * Add listener to get notified when dev server encounters an error
60
+ *
61
+ * @param callback - Function to call when dev server encounters an error
62
+ * @returns This DevServer instance for method chaining
58
63
  */
59
64
  onError(callback: (error: any) => any): this;
60
65
  /**
@@ -62,11 +67,16 @@ export declare class DevServer {
62
67
  */
63
68
  close(): Promise<void>;
64
69
  /**
65
- * Start the development server
70
+ * Start the development server in static or HMR mode
71
+ *
72
+ * @param ts - TypeScript module reference
66
73
  */
67
74
  start(ts: typeof tsStatic): Promise<void>;
68
75
  /**
69
- * Start the development server in watch mode
76
+ * Start the development server in watch mode and restart on file changes
77
+ *
78
+ * @param ts - TypeScript module reference
79
+ * @param options - Watch options including polling mode
70
80
  */
71
81
  startAndWatch(ts: typeof tsStatic, options?: {
72
82
  poll: boolean;
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Buffer class to construct template output with proper indentation and formatting.
3
+ *
4
+ * The FileBuffer class provides a fluent API for building text output with automatic
5
+ * indentation management. It's commonly used for generating code or template files
6
+ * where proper formatting is important.
7
+ *
8
+ * @example
9
+ * const buffer = new FileBuffer()
10
+ * buffer
11
+ * .writeLine('function example() {')
12
+ * .indent()
13
+ * .writeLine('return "Hello World"')
14
+ * .dedent()
15
+ * .writeLine('}')
16
+ * console.log(buffer.flush())
17
+ */
18
+ export declare class FileBuffer {
19
+ #private;
20
+ /**
21
+ * Creates a new child buffer instance
22
+ *
23
+ * @returns A new FileBuffer instance
24
+ */
25
+ create(): FileBuffer;
26
+ /**
27
+ * Returns the size of buffer text
28
+ *
29
+ * @returns The number of lines in the buffer
30
+ */
31
+ get size(): number;
32
+ /**
33
+ * Write a new line to the output with current indentation
34
+ *
35
+ * @param text - The text to write as a new line
36
+ * @returns This FileBuffer instance for method chaining
37
+ */
38
+ writeLine(text: string): this;
39
+ /**
40
+ * Write text to the output without adding a new line
41
+ *
42
+ * @param text - The text to write without a newline
43
+ * @returns This FileBuffer instance for method chaining
44
+ */
45
+ write(text: string): this;
46
+ /**
47
+ * Increase indentation by 2 spaces
48
+ *
49
+ * @returns This FileBuffer instance for method chaining
50
+ */
51
+ indent(): this;
52
+ /**
53
+ * Decrease indentation by 2 spaces (minimum of 0)
54
+ *
55
+ * @returns This FileBuffer instance for method chaining
56
+ */
57
+ dedent(): this;
58
+ /**
59
+ * Return template as a string, joining all buffer lines
60
+ *
61
+ * Once called, the output is cached and subsequent calls return the same result.
62
+ * The flush method becomes a no-op after the first call.
63
+ *
64
+ * @returns The complete buffer content as a string
65
+ */
66
+ flush(): string;
67
+ }
@@ -14,6 +14,10 @@ import { type InspectedFile, type AssemblerRcFile } from './types/common.ts';
14
14
  *
15
15
  * Using FileSystem you can register actions to be executed when a file changes in
16
16
  * one of the above categories.
17
+ *
18
+ * @example
19
+ * const fs = new FileSystem(cwd, tsConfig, rcFile)
20
+ * const file = fs.inspect('./app/controllers/users_controller.ts')
17
21
  */
18
22
  export declare class FileSystem {
19
23
  #private;
@@ -37,24 +41,58 @@ export declare class FileSystem {
37
41
  */
38
42
  get excludes(): string[];
39
43
  /**
40
- * Inspect a relative path to find its source in the project
44
+ * Inspect a file path to determine its type and properties within the project.
45
+ *
46
+ * This method analyzes a file to categorize it as a script file, test file, or meta file,
47
+ * and determines whether changes to the file should trigger server restarts. Results
48
+ * are memoized for performance optimization.
49
+ *
50
+ * @param absolutePath - The absolute Unix path to the file
51
+ * @param relativePath - The relative Unix path from the project root
52
+ * @returns File inspection result or null if the file should be ignored
53
+ *
54
+ * @example
55
+ * const file = fileSystem.inspect('/project/app/models/user.ts', 'app/models/user.ts')
56
+ * if (file) {
57
+ * console.log(file.fileType) // 'script'
58
+ * console.log(file.reloadServer) // true
59
+ * }
41
60
  */
42
- inspect: (input: string) => InspectedFile | null;
61
+ inspect: (input: string, args_0?: string | undefined) => InspectedFile | null;
43
62
  /**
44
- * Returns true if the directory should be watched. Chokidar sends
45
- * absolute unix paths to the ignored callback.
63
+ * Determines if a directory should be watched by the file watcher.
64
+ *
65
+ * This method checks if a directory should be monitored for file changes
66
+ * based on the TypeScript configuration includes/excludes patterns.
67
+ * Results are memoized for performance. Chokidar sends absolute Unix paths.
46
68
  *
47
- * You must use "shouldWatchFile" method for files and call this method
48
- * for directories only.
69
+ * Note: Use shouldWatchFile for files and this method for directories only.
70
+ *
71
+ * @param absolutePath - The absolute Unix path to the directory
72
+ * @returns True if the directory should be watched
73
+ *
74
+ * @example
75
+ * const shouldWatch = fileSystem.shouldWatchDirectory('/project/app/controllers')
76
+ * console.log(shouldWatch) // true
49
77
  */
50
78
  shouldWatchDirectory: (input: string) => unknown;
51
- constructor(cwd: URL | string, tsConfig: tsStatic.ParsedCommandLine, rcFile: AssemblerRcFile);
79
+ /**
80
+ * Create a new FileSystem instance
81
+ *
82
+ * @param cwd - The current working directory URL or string path
83
+ * @param tsConfig - Parsed TypeScript configuration
84
+ * @param rcFile - AdonisJS RC file configuration
85
+ */
86
+ constructor(cwd: string, tsConfig: tsStatic.ParsedCommandLine, rcFile: AssemblerRcFile);
52
87
  /**
53
88
  * Returns true if the file should be watched. Chokidar sends
54
89
  * absolute unix paths to the ignored callback.
55
90
  *
56
91
  * You must use "shouldWatchDirectory" method for directories and call
57
92
  * this method for files only.
93
+ *
94
+ * @param absolutePath - The absolute path to the file
95
+ * @returns True if the file should be watched
58
96
  */
59
97
  shouldWatchFile(absolutePath: string): boolean;
60
98
  }
@@ -1,26 +1,76 @@
1
1
  import { type SgNode } from '@ast-grep/napi';
2
2
  import type { Import } from './types/common.ts';
3
3
  /**
4
- * Finds an import reference inside a code snippet
4
+ * Finds an import reference inside a code snippet by analyzing the import statements
5
+ * and matching against the provided import reference identifier.
6
+ *
7
+ * The function searches through all import statements in the code and matches
8
+ * against default, namespace, or named imports based on the import reference.
9
+ *
10
+ * @param code - The code snippet to search for imports
11
+ * @param importReference - The import reference identifier to find (can include dot notation)
12
+ * @returns Promise that resolves to an Import object or null if not found
13
+ *
14
+ * @example
15
+ * const importInfo = await findImport(code, 'validateUser')
16
+ * if (importInfo) {
17
+ * console.log(importInfo.specifier) // '@/validators/user'
18
+ * }
5
19
  */
6
20
  export declare function findImport(code: string, importReference: string): Promise<Import | null>;
7
21
  /**
8
22
  * Returns a node that represents a TypeScript class or null
9
23
  * when unable to find the class.
24
+ *
25
+ * This function searches for class declarations within the provided AST node
26
+ * using ast-grep's pattern matching capabilities.
27
+ *
28
+ * @param node - The AST node to search within for class declarations
29
+ * @returns The SgNode representing the class or null if not found
30
+ *
31
+ * @example
32
+ * const classNode = inspectClass(rootNode)
33
+ * if (classNode) {
34
+ * console.log('Found class:', classNode.text())
35
+ * }
10
36
  */
11
37
  export declare function inspectClass(node: SgNode): SgNode | null;
12
38
  /**
13
39
  * Returns an array of SgNodes for class methods. The input node
14
40
  * must represent a class.
41
+ *
42
+ * This function finds all method definitions within a class node,
43
+ * including both regular methods and static methods.
44
+ *
45
+ * @param node - The AST node representing a class to search for methods
46
+ * @returns Array of SgNodes representing method definitions within the class
47
+ *
48
+ * @example
49
+ * const classNode = inspectClass(rootNode)
50
+ * if (classNode) {
51
+ * const methods = inspectClassMethods(classNode)
52
+ * methods.forEach(method => console.log('Method:', method.text()))
53
+ * }
15
54
  */
16
55
  export declare function inspectClassMethods(node: SgNode): SgNode[];
17
56
  /**
18
- * Converts an array of SgNode to plain text by removing whitespaces,
19
- * identation and comments in between. Tested with the following
57
+ * Converts an SgNode to plain text by removing whitespaces,
58
+ * indentation and comments in between. Tested with the following
20
59
  * children nodes only.
21
60
  *
22
61
  * - MemberExpression
23
- * - Identifer
62
+ * - Identifier
63
+ *
64
+ * This function recursively traverses the AST node and extracts only
65
+ * the meaningful text content without any formatting or whitespace.
66
+ *
67
+ * @param node - The AST node to convert to plain text
68
+ * @returns String representation of the node without formatting
69
+ *
70
+ * @example
71
+ * const memberExpression = node.find({ rule: { kind: 'member_expression' } })
72
+ * const plainText = nodeToPlainText(memberExpression)
73
+ * console.log(plainText) // 'user.validate'
24
74
  */
25
75
  export declare function nodeToPlainText(node: SgNode): string;
26
76
  /**
@@ -30,11 +80,36 @@ export declare function nodeToPlainText(node: SgNode): string;
30
80
  *
31
81
  * For example: In case of validators, we will first find the Controller
32
82
  * method for which we want the validation method calls.
83
+ *
84
+ * This function searches for call expressions that match the provided method
85
+ * names and returns their argument nodes for further analysis.
86
+ *
87
+ * @param node - The AST node to search within for method calls
88
+ * @param methodCalls - Array of method call names to search for (supports dot notation)
89
+ * @returns Array of SgNodes representing the arguments of matching method calls
90
+ *
91
+ * @example
92
+ * const controllerMethod = classNode.find({ rule: { kind: 'method_definition' } })
93
+ * const validatorArgs = inspectMethodArguments(controllerMethod, ['validate', 'request.validate'])
94
+ * validatorArgs.forEach(arg => console.log('Validator argument:', arg.text()))
33
95
  */
34
96
  export declare function inspectMethodArguments(node: SgNode, methodCalls: string[]): SgNode[];
35
97
  /**
36
98
  * Inspect the validator direct usage code snippets. A member expression
37
99
  * calling the ".validate" method is considered as direct usage of
38
100
  * the validator.
101
+ *
102
+ * This function specifically looks for patterns where validators are called
103
+ * directly with the `.validate()` method, which is common in AdonisJS applications.
104
+ *
105
+ * @param node - The AST node to search within for validator direct usage
106
+ * @returns Array of SgNodes representing validator expressions that call validate method
107
+ *
108
+ * @example
109
+ * const methodNode = classNode.find({ rule: { kind: 'method_definition' } })
110
+ * const validators = searchValidatorDirectUsage(methodNode)
111
+ * validators.forEach(validator => {
112
+ * console.log('Direct validator usage:', nodeToPlainText(validator))
113
+ * })
39
114
  */
40
115
  export declare function searchValidatorDirectUsage(node: SgNode): SgNode[];
@@ -0,0 +1,16 @@
1
+ import {
2
+ findImport,
3
+ inspectClass,
4
+ inspectClassMethods,
5
+ inspectMethodArguments,
6
+ nodeToPlainText,
7
+ searchValidatorDirectUsage
8
+ } from "../chunk-TIKQQRMX.js";
9
+ export {
10
+ findImport,
11
+ inspectClass,
12
+ inspectClassMethods,
13
+ inspectMethodArguments,
14
+ nodeToPlainText,
15
+ searchValidatorDirectUsage
16
+ };
@@ -0,0 +1,73 @@
1
+ import { type Logger } from '@poppinss/cliui';
2
+ import { type IndexGeneratorSourceConfig } from '../types/common.ts';
3
+ /**
4
+ * IndexGenerator manages the generation of index files for AdonisJS applications.
5
+ *
6
+ * This class provides a way to configure multiple sources and generate index files
7
+ * that export collections of modules, typically used for barrel exports or
8
+ * auto-discovery patterns in AdonisJS applications.
9
+ *
10
+ * @example
11
+ * const generator = new IndexGenerator(appRoot)
12
+ * generator.add('controllers', {
13
+ * source: 'app/controllers',
14
+ * output: 'app/controllers/index.ts',
15
+ * as: 'barrelFile',
16
+ * exportName: 'controllers'
17
+ * })
18
+ * await generator.generate()
19
+ */
20
+ export declare class IndexGenerator {
21
+ #private;
22
+ /**
23
+ * Create a new IndexGenerator instance
24
+ *
25
+ * @param appRoot - The application root directory path
26
+ * @param cliLogger - Logger instance for CLI output
27
+ */
28
+ 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
+ /**
39
+ * Add a new index generator source
40
+ *
41
+ * @param name - Unique name for the source
42
+ * @param config - Configuration for the index generator source
43
+ * @returns This IndexGenerator instance for method chaining
44
+ */
45
+ add(name: string, config: IndexGeneratorSourceConfig): this;
46
+ /**
47
+ * Add a file to all registered index generator sources
48
+ *
49
+ * This method propagates the file addition to all registered sources,
50
+ * allowing them to regenerate their index files if the new file matches
51
+ * their glob patterns.
52
+ *
53
+ * @param filePath - Absolute path of the file to add
54
+ */
55
+ addFile(filePath: string): Promise<void>;
56
+ /**
57
+ * Remove a file from all registered index generator sources
58
+ *
59
+ * This method propagates the file removal to all registered sources,
60
+ * allowing them to regenerate their index files if the removed file
61
+ * was previously tracked.
62
+ *
63
+ * @param filePath - Absolute path of the file to remove
64
+ */
65
+ removeFile(filePath: string): Promise<void>;
66
+ /**
67
+ * Generate all registered index files
68
+ *
69
+ * Iterates through all registered sources and generates their
70
+ * corresponding index files.
71
+ */
72
+ generate(): Promise<void>;
73
+ }
@@ -0,0 +1,7 @@
1
+ import {
2
+ IndexGenerator
3
+ } from "../../chunk-MC3FJR62.js";
4
+ import "../../chunk-F4RAGKQN.js";
5
+ export {
6
+ IndexGenerator
7
+ };
@@ -0,0 +1,66 @@
1
+ import { type Logger } from '@poppinss/cliui';
2
+ import { type IndexGeneratorSourceConfig } from '../types/common.ts';
3
+ /**
4
+ * IndexGeneratorSource handles the generation of a single index file.
5
+ *
6
+ * This class is responsible for scanning a source directory, processing files
7
+ * according to configuration, and generating an index file that exports the
8
+ * discovered modules. It supports both barrel file generation and custom
9
+ * generation strategies.
10
+ *
11
+ * @example
12
+ * const source = new IndexGeneratorSource(appRoot, {
13
+ * source: 'app/controllers',
14
+ * output: 'app/controllers/index.ts',
15
+ * as: 'barrelFile',
16
+ * exportName: 'controllers'
17
+ * })
18
+ * await source.generate()
19
+ */
20
+ export declare class IndexGeneratorSource {
21
+ #private;
22
+ /**
23
+ * Unique name for this index generator source
24
+ */
25
+ name: string;
26
+ /**
27
+ * Create a new IndexGeneratorSource instance
28
+ *
29
+ * @param name - Unique name for this index generator source
30
+ * @param appRoot - The application root directory path
31
+ * @param cliLogger - Logger instance for CLI output
32
+ * @param config - Configuration for this index generator source
33
+ */
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
+ /**
42
+ * Add a file to the virtual file system and regenerate index if needed
43
+ *
44
+ * If the file matches the configured glob patterns, it will be added
45
+ * to the virtual file system and the index file will be regenerated.
46
+ *
47
+ * @param filePath - Absolute path of the file to add
48
+ */
49
+ addFile(filePath: string): Promise<void>;
50
+ /**
51
+ * Remove a file from the virtual file system and regenerate index if needed
52
+ *
53
+ * If the file was previously tracked, it will be removed from the
54
+ * virtual file system and the index file will be regenerated.
55
+ *
56
+ * @param filePath - Absolute path of the file to remove
57
+ */
58
+ removeFile(filePath: string): Promise<void>;
59
+ /**
60
+ * Generate the index file
61
+ *
62
+ * This method scans the source directory, processes files according to
63
+ * the configuration, and writes the generated index file to disk.
64
+ */
65
+ generate(): Promise<void>;
66
+ }
@@ -1,15 +1,40 @@
1
1
  /**
2
2
  * Encapsulates the API to resolve import specifiers with the ability
3
- * to define customer resolver.
3
+ * to define custom resolver functions.
4
+ *
5
+ * The PathsResolver provides a caching mechanism to avoid resolving the same
6
+ * specifier multiple times and supports custom resolvers for handling
7
+ * special import patterns like path aliases.
8
+ *
9
+ * @example
10
+ * const resolver = new PathsResolver()
11
+ * resolver.use((specifier) => '/custom/path/' + specifier)
12
+ * const resolved = resolver.resolve('#app/models/user')
4
13
  */
5
14
  export declare class PathsResolver {
6
15
  #private;
7
16
  /**
8
17
  * Define a custom resolver that resolves a path
18
+ *
19
+ * The custom resolver function will be used instead of the default
20
+ * import.meta.resolve() for resolving import specifiers.
21
+ *
22
+ * @param resolver - Function that takes a specifier and returns resolved path
9
23
  */
10
24
  use(resolver: (specifier: string) => string): void;
11
25
  /**
12
- * Resolve import specifier
26
+ * Resolve import specifier to an absolute file path
27
+ *
28
+ * This method caches resolved paths to improve performance on repeated
29
+ * resolutions. Relative paths are not supported and will throw an error.
30
+ *
31
+ * @param specifier - The import specifier to resolve (must not be relative)
32
+ * @returns The resolved absolute file path
33
+ * @throws Error when attempting to resolve relative paths
34
+ *
35
+ * @example
36
+ * const path = resolver.resolve('#app/models/user')
37
+ * const path2 = resolver.resolve('@/utils/helper')
13
38
  */
14
39
  resolve(specifier: string): string;
15
40
  }
@@ -1,24 +1,62 @@
1
1
  import { type ShortcutsManagerOptions } from './types/common.ts';
2
2
  /**
3
- * Manages keyboard shortcuts for development server
3
+ * Manages keyboard shortcuts for development server interaction.
4
+ *
5
+ * The ShortcutsManager provides a convenient way to handle keyboard inputs
6
+ * during development, allowing users to restart servers, clear console,
7
+ * open browsers, and perform other common development tasks through simple
8
+ * key presses.
9
+ *
10
+ * @example
11
+ * const shortcuts = new ShortcutsManager({
12
+ * logger: ui.logger,
13
+ * callbacks: {
14
+ * onRestart: () => server.restart(),
15
+ * onClear: () => console.clear(),
16
+ * onQuit: () => process.exit()
17
+ * }
18
+ * })
19
+ * shortcuts.setup()
4
20
  */
5
21
  export declare class ShortcutsManager {
6
22
  #private;
23
+ /**
24
+ * Create a new ShortcutsManager instance
25
+ *
26
+ * @param options - Configuration options for the shortcuts manager
27
+ */
7
28
  constructor(options: ShortcutsManagerOptions);
8
29
  /**
9
30
  * Set server url for opening in browser
31
+ *
32
+ * This URL will be used when the user presses 'o' to open the
33
+ * development server in their default browser.
34
+ *
35
+ * @param url - The server URL to open when 'o' key is pressed
10
36
  */
11
37
  setServerUrl(url: string): void;
12
38
  /**
13
- * Initialize keyboard shortcuts
39
+ * Initialize keyboard shortcuts by setting up raw mode on stdin
40
+ *
41
+ * This method enables raw mode on stdin to capture individual keypresses
42
+ * and sets up the event listener for handling keyboard input. Only works
43
+ * in TTY environments.
14
44
  */
15
45
  setup(): void;
16
46
  /**
17
- * Show available keyboard shortcuts
47
+ * Show available keyboard shortcuts in the console
48
+ *
49
+ * Displays a formatted list of all available keyboard shortcuts
50
+ * and their descriptions to help users understand what actions
51
+ * are available.
18
52
  */
19
53
  showHelp(): void;
20
54
  /**
21
- * Cleanup keyboard shortcuts
55
+ * Cleanup keyboard shortcuts and restore terminal state
56
+ *
57
+ * Disables raw mode on stdin, removes event listeners, and restores
58
+ * the terminal to its normal state. Should be called when shutting down
59
+ * the development server.
22
60
  */
23
61
  cleanup(): void;
24
62
  }