codemod 2.0.0-alpha.1 → 2.0.0-alpha.2
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/README.md +57 -2
- package/codemod +17 -30
- package/package.json +78 -10
- package/register.d.mts +11 -0
- package/register.mjs +60 -0
- package/runtime/addon.mjs +59 -0
- package/runtime/ast-grep.mjs +93 -0
- package/runtime/context.mjs +77 -0
- package/runtime/hooks.mjs +9 -0
- package/runtime/host.d.mts +120 -0
- package/runtime/host.mjs +390 -0
- package/runtime/llm.mjs +11 -0
- package/runtime/metrics.mjs +45 -0
- package/runtime/modules.mjs +19 -0
- package/runtime/orchestrator.mjs +657 -0
- package/runtime/runtime.mjs +48 -0
- package/runtime/workflow.mjs +135 -0
- package/testing/index.d.mts +203 -0
- package/testing/index.mjs +638 -0
- package/types/index.d.ts +8 -0
- package/types/langs/angular.d.ts +5 -0
- package/types/langs/c.d.ts +5 -0
- package/types/langs/c_sharp.d.ts +5 -0
- package/types/langs/cpp.d.ts +5 -0
- package/types/langs/css.d.ts +5 -0
- package/types/langs/elixir.d.ts +5 -0
- package/types/langs/go.d.ts +5 -0
- package/types/langs/html.d.ts +5 -0
- package/types/langs/java.d.ts +5 -0
- package/types/langs/javascript.d.ts +5 -0
- package/types/langs/json.d.ts +5 -0
- package/types/langs/kotlin.d.ts +5 -0
- package/types/langs/php.d.ts +5 -0
- package/types/langs/python.d.ts +5 -0
- package/types/langs/ruby.d.ts +5 -0
- package/types/langs/rust.d.ts +5 -0
- package/types/langs/scala.d.ts +5 -0
- package/types/langs/toml.d.ts +5 -0
- package/types/langs/tsx.d.ts +5 -0
- package/types/langs/typescript.d.ts +5 -0
- package/types/langs/xml.d.ts +5 -0
- package/types/langs/yaml.d.ts +5 -0
- package/types/llm.d.ts +6 -0
- package/types/llrt/abort.d.ts +69 -0
- package/types/llrt/assert.d.ts +39 -0
- package/types/llrt/async_hooks.d.ts +210 -0
- package/types/llrt/buffer.d.ts +1186 -0
- package/types/llrt/child_process.d.ts +447 -0
- package/types/llrt/console.d.ts +210 -0
- package/types/llrt/crypto.d.ts +854 -0
- package/types/llrt/dgram.d.ts +381 -0
- package/types/llrt/dns.d.ts +124 -0
- package/types/llrt/dom-events.d.ts +51 -0
- package/types/llrt/events.d.ts +245 -0
- package/types/llrt/exceptions.d.ts +26 -0
- package/types/llrt/fetch.d.ts +332 -0
- package/types/llrt/fs/promises.d.ts +554 -0
- package/types/llrt/fs.d.ts +360 -0
- package/types/llrt/globals.d.ts +23 -0
- package/types/llrt/https.d.ts +27 -0
- package/types/llrt/index.d.ts +33 -0
- package/types/llrt/module.d.ts +285 -0
- package/types/llrt/navigator.d.ts +9 -0
- package/types/llrt/net.d.ts +488 -0
- package/types/llrt/os.d.ts +293 -0
- package/types/llrt/path.d.ts +150 -0
- package/types/llrt/perf_hooks.d.ts +23 -0
- package/types/llrt/process.d.ts +502 -0
- package/types/llrt/stream/web.d.ts +526 -0
- package/types/llrt/stream.d.ts +366 -0
- package/types/llrt/string_decoder.d.ts +63 -0
- package/types/llrt/timers.d.ts +72 -0
- package/types/llrt/timezone.d.ts +101 -0
- package/types/llrt/tty.d.ts +11 -0
- package/types/llrt/url.d.ts +774 -0
- package/types/llrt/util.d.ts +240 -0
- package/types/llrt/zlib.d.ts +177 -0
- package/types/main.d.ts +5 -0
- package/types/metrics.d.ts +5 -0
- package/types/modules/ast-grep.d.ts +634 -0
- package/types/modules/langs.d.ts +87 -0
- package/types/modules/llm.d.ts +23 -0
- package/types/modules/metrics.d.ts +107 -0
- package/types/modules/runtime.d.ts +66 -0
- package/types/modules/workflow.d.ts +750 -0
- package/types/runtime.d.ts +6 -0
- package/types/workflow.d.ts +5 -0
- package/vite.d.mts +24 -0
- package/vite.mjs +26 -0
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @since v0.3.7
|
|
3
|
+
*/
|
|
4
|
+
declare module "module" {
|
|
5
|
+
import { URL } from "node:url";
|
|
6
|
+
class Module {
|
|
7
|
+
constructor(id: string, parent?: Module);
|
|
8
|
+
}
|
|
9
|
+
interface Module extends NodeJS.Module {}
|
|
10
|
+
namespace Module {
|
|
11
|
+
export { Module };
|
|
12
|
+
}
|
|
13
|
+
namespace Module {
|
|
14
|
+
/**
|
|
15
|
+
* A list of the names of all modules provided by Node.js. Can be used to verify
|
|
16
|
+
* if a module is maintained by a third party or not.
|
|
17
|
+
*
|
|
18
|
+
* Note: the list doesn't contain prefix-only modules like `node:test`.
|
|
19
|
+
*/
|
|
20
|
+
const builtinModules: readonly string[];
|
|
21
|
+
/**
|
|
22
|
+
* @param path Filename to be used to construct the require
|
|
23
|
+
* function. Must be a file URL object, file URL string, or absolute path
|
|
24
|
+
* string.
|
|
25
|
+
*/
|
|
26
|
+
function createRequire(path: string | URL): NodeJS.Require;
|
|
27
|
+
/**
|
|
28
|
+
*/
|
|
29
|
+
function isBuiltin(moduleName: string): boolean;
|
|
30
|
+
interface RegisterOptions<Data> {
|
|
31
|
+
/**
|
|
32
|
+
* If you want to resolve `specifier` relative to a
|
|
33
|
+
* base URL, such as `import.meta.url`, you can pass that URL here. This
|
|
34
|
+
* property is ignored if the `parentURL` is supplied as the second argument.
|
|
35
|
+
* @default 'data:'
|
|
36
|
+
*/
|
|
37
|
+
parentURL?: string | URL | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Any arbitrary, cloneable JavaScript value to pass into the
|
|
40
|
+
* {@link initialize} hook.
|
|
41
|
+
*/
|
|
42
|
+
data?: Data | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* [Transferable objects](https://nodejs.org/docs/latest-v24.x/api/worker_threads.html#portpostmessagevalue-transferlist)
|
|
45
|
+
* to be passed into the `initialize` hook.
|
|
46
|
+
*/
|
|
47
|
+
transferList?: any[] | undefined;
|
|
48
|
+
}
|
|
49
|
+
interface RegisterHooksOptions {
|
|
50
|
+
/**
|
|
51
|
+
* See [load hook](https://nodejs.org/docs/latest-v24.x/api/module.html#loadurl-context-nextload).
|
|
52
|
+
* @default undefined
|
|
53
|
+
*/
|
|
54
|
+
load?: LoadHookSync | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* See [resolve hook](https://nodejs.org/docs/latest-v24.x/api/module.html#resolvespecifier-context-nextresolve).
|
|
57
|
+
* @default undefined
|
|
58
|
+
*/
|
|
59
|
+
resolve?: ResolveHookSync | undefined;
|
|
60
|
+
}
|
|
61
|
+
interface ModuleHooks {
|
|
62
|
+
/**
|
|
63
|
+
* Deregister the hook instance.
|
|
64
|
+
*/
|
|
65
|
+
deregister(): void;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Register [hooks](https://nodejs.org/docs/latest-v24.x/api/module.html#customization-hooks)
|
|
69
|
+
* that customize Node.js module resolution and loading behavior.
|
|
70
|
+
* @experimental
|
|
71
|
+
*/
|
|
72
|
+
function registerHooks(options: RegisterHooksOptions): ModuleHooks;
|
|
73
|
+
interface ImportAttributes extends NodeJS.Dict<string> {
|
|
74
|
+
type?: string | undefined;
|
|
75
|
+
}
|
|
76
|
+
type ImportPhase = "source" | "evaluation";
|
|
77
|
+
type ModuleFormat =
|
|
78
|
+
| "addon"
|
|
79
|
+
| "builtin"
|
|
80
|
+
| "commonjs"
|
|
81
|
+
| "commonjs-typescript"
|
|
82
|
+
| "json"
|
|
83
|
+
| "module"
|
|
84
|
+
| "module-typescript"
|
|
85
|
+
| "wasm";
|
|
86
|
+
type ModuleSource = string | ArrayBuffer | NodeJS.TypedArray;
|
|
87
|
+
interface ResolveHookContext {
|
|
88
|
+
/**
|
|
89
|
+
* Export conditions of the relevant `package.json`
|
|
90
|
+
*/
|
|
91
|
+
conditions: string[];
|
|
92
|
+
/**
|
|
93
|
+
* An object whose key-value pairs represent the assertions for the module to import
|
|
94
|
+
*/
|
|
95
|
+
importAttributes: ImportAttributes;
|
|
96
|
+
/**
|
|
97
|
+
* The module importing this one, or undefined if this is the Node.js entry point
|
|
98
|
+
*/
|
|
99
|
+
parentURL: string | undefined;
|
|
100
|
+
}
|
|
101
|
+
interface ResolveFnOutput {
|
|
102
|
+
/**
|
|
103
|
+
* A hint to the load hook (it might be ignored); can be an intermediary value.
|
|
104
|
+
*/
|
|
105
|
+
format?: string | null | undefined;
|
|
106
|
+
/**
|
|
107
|
+
* The import attributes to use when caching the module (optional; if excluded the input will be used)
|
|
108
|
+
*/
|
|
109
|
+
importAttributes?: ImportAttributes | undefined;
|
|
110
|
+
/**
|
|
111
|
+
* A signal that this hook intends to terminate the chain of `resolve` hooks.
|
|
112
|
+
* @default false
|
|
113
|
+
*/
|
|
114
|
+
shortCircuit?: boolean | undefined;
|
|
115
|
+
/**
|
|
116
|
+
* The absolute URL to which this input resolves
|
|
117
|
+
*/
|
|
118
|
+
url: string;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* The `resolve` hook chain is responsible for telling Node.js where to find and
|
|
122
|
+
* how to cache a given `import` statement or expression, or `require` call. It can
|
|
123
|
+
* optionally return a format (such as `'module'`) as a hint to the `load` hook. If
|
|
124
|
+
* a format is specified, the `load` hook is ultimately responsible for providing
|
|
125
|
+
* the final `format` value (and it is free to ignore the hint provided by
|
|
126
|
+
* `resolve`); if `resolve` provides a `format`, a custom `load` hook is required
|
|
127
|
+
* even if only to pass the value to the Node.js default `load` hook.
|
|
128
|
+
*/
|
|
129
|
+
type ResolveHook = (
|
|
130
|
+
specifier: string,
|
|
131
|
+
context: ResolveHookContext,
|
|
132
|
+
nextResolve: (
|
|
133
|
+
specifier: string,
|
|
134
|
+
context?: Partial<ResolveHookContext>
|
|
135
|
+
) => ResolveFnOutput | Promise<ResolveFnOutput>
|
|
136
|
+
) => ResolveFnOutput | Promise<ResolveFnOutput>;
|
|
137
|
+
type ResolveHookSync = (
|
|
138
|
+
specifier: string,
|
|
139
|
+
context: ResolveHookContext,
|
|
140
|
+
nextResolve: (
|
|
141
|
+
specifier: string,
|
|
142
|
+
context?: Partial<ResolveHookContext>
|
|
143
|
+
) => ResolveFnOutput
|
|
144
|
+
) => ResolveFnOutput;
|
|
145
|
+
interface LoadHookContext {
|
|
146
|
+
/**
|
|
147
|
+
* Export conditions of the relevant `package.json`
|
|
148
|
+
*/
|
|
149
|
+
conditions: string[];
|
|
150
|
+
/**
|
|
151
|
+
* The format optionally supplied by the `resolve` hook chain (can be an intermediary value).
|
|
152
|
+
*/
|
|
153
|
+
format: string | null | undefined;
|
|
154
|
+
/**
|
|
155
|
+
* An object whose key-value pairs represent the assertions for the module to import
|
|
156
|
+
*/
|
|
157
|
+
importAttributes: ImportAttributes;
|
|
158
|
+
}
|
|
159
|
+
interface LoadFnOutput {
|
|
160
|
+
format: string | null | undefined;
|
|
161
|
+
/**
|
|
162
|
+
* A signal that this hook intends to terminate the chain of `resolve` hooks.
|
|
163
|
+
* @default false
|
|
164
|
+
*/
|
|
165
|
+
shortCircuit?: boolean | undefined;
|
|
166
|
+
/**
|
|
167
|
+
* The source for Node.js to evaluate
|
|
168
|
+
*/
|
|
169
|
+
source?: ModuleSource | undefined;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* The `load` hook provides a way to define a custom method of determining how a
|
|
173
|
+
* URL should be interpreted, retrieved, and parsed. It is also in charge of
|
|
174
|
+
* validating the import attributes.
|
|
175
|
+
*/
|
|
176
|
+
type LoadHook = (
|
|
177
|
+
url: string,
|
|
178
|
+
context: LoadHookContext,
|
|
179
|
+
nextLoad: (
|
|
180
|
+
url: string,
|
|
181
|
+
context?: Partial<LoadHookContext>
|
|
182
|
+
) => LoadFnOutput | Promise<LoadFnOutput>
|
|
183
|
+
) => LoadFnOutput | Promise<LoadFnOutput>;
|
|
184
|
+
type LoadHookSync = (
|
|
185
|
+
url: string,
|
|
186
|
+
context: LoadHookContext,
|
|
187
|
+
nextLoad: (
|
|
188
|
+
url: string,
|
|
189
|
+
context?: Partial<LoadHookContext>
|
|
190
|
+
) => LoadFnOutput
|
|
191
|
+
) => LoadFnOutput;
|
|
192
|
+
}
|
|
193
|
+
global {
|
|
194
|
+
interface ImportMeta {
|
|
195
|
+
/**
|
|
196
|
+
* The absolute `file:` URL of the module.
|
|
197
|
+
*
|
|
198
|
+
* This is defined exactly the same as it is in browsers providing the URL of the
|
|
199
|
+
* current module file.
|
|
200
|
+
*
|
|
201
|
+
* This enables useful patterns such as relative file loading:
|
|
202
|
+
*
|
|
203
|
+
* ```js
|
|
204
|
+
* import { readFileSync } from 'node:fs';
|
|
205
|
+
* const buffer = readFileSync(new URL('./data.proto', import.meta.url));
|
|
206
|
+
* ```
|
|
207
|
+
*/
|
|
208
|
+
url: string;
|
|
209
|
+
}
|
|
210
|
+
namespace NodeJS {
|
|
211
|
+
interface Module {
|
|
212
|
+
/**
|
|
213
|
+
* The `module.exports` object is created by the `Module` system. Sometimes this is
|
|
214
|
+
* not acceptable; many want their module to be an instance of some class. To do
|
|
215
|
+
* this, assign the desired export object to `module.exports`.
|
|
216
|
+
*/
|
|
217
|
+
exports: any;
|
|
218
|
+
/**
|
|
219
|
+
* The directory name of the module. This is usually the same as the
|
|
220
|
+
* `path.dirname()` of the `module.id`.
|
|
221
|
+
*/
|
|
222
|
+
path: string;
|
|
223
|
+
/**
|
|
224
|
+
* The `module.require()` method provides a way to load a module as if
|
|
225
|
+
* `require()` was called from the original module.
|
|
226
|
+
*/
|
|
227
|
+
require(id: string): any;
|
|
228
|
+
}
|
|
229
|
+
interface Require {
|
|
230
|
+
/**
|
|
231
|
+
*/
|
|
232
|
+
resolve: RequireResolve;
|
|
233
|
+
}
|
|
234
|
+
interface RequireResolveOptions {
|
|
235
|
+
/**
|
|
236
|
+
* Paths to resolve module location from. If present, these
|
|
237
|
+
* paths are used instead of the default resolution paths, with the exception
|
|
238
|
+
* of
|
|
239
|
+
* [GLOBAL\_FOLDERS](https://nodejs.org/docs/latest-v24.x/api/modules.html#loading-from-the-global-folders)
|
|
240
|
+
* like `$HOME/.node_modules`, which are
|
|
241
|
+
* always included. Each of these paths is used as a starting point for
|
|
242
|
+
* the module resolution algorithm, meaning that the `node_modules` hierarchy
|
|
243
|
+
* is checked from this location.
|
|
244
|
+
*/
|
|
245
|
+
paths?: string[] | undefined;
|
|
246
|
+
}
|
|
247
|
+
interface RequireResolve {
|
|
248
|
+
/**
|
|
249
|
+
* Use the internal `require()` machinery to look up the location of a module,
|
|
250
|
+
* but rather than loading the module, just return the resolved filename.
|
|
251
|
+
*
|
|
252
|
+
* If the module can not be found, a `MODULE_NOT_FOUND` error is thrown.
|
|
253
|
+
* @param request The module path to resolve.
|
|
254
|
+
*/
|
|
255
|
+
(request: string, options?: RequireResolveOptions): string;
|
|
256
|
+
/**
|
|
257
|
+
* Returns an array containing the paths searched during resolution of `request` or
|
|
258
|
+
* `null` if the `request` string references a core module, for example `http` or
|
|
259
|
+
* `fs`.
|
|
260
|
+
* @param request The module path whose lookup paths are being retrieved.
|
|
261
|
+
*/
|
|
262
|
+
paths(request: string): string[] | null;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* The `exports` variable is available within a module's file-level scope, and is
|
|
267
|
+
* assigned the value of `module.exports` before the module is evaluated.
|
|
268
|
+
*/
|
|
269
|
+
var exports: NodeJS.Module["exports"];
|
|
270
|
+
/**
|
|
271
|
+
* A reference to the current module.
|
|
272
|
+
* @since v0.1.16
|
|
273
|
+
*/
|
|
274
|
+
var module: NodeJS.Module;
|
|
275
|
+
/**
|
|
276
|
+
* @since v0.1.13
|
|
277
|
+
*/
|
|
278
|
+
var require: NodeJS.Require;
|
|
279
|
+
}
|
|
280
|
+
export = Module;
|
|
281
|
+
}
|
|
282
|
+
declare module "node:module" {
|
|
283
|
+
import module = require("module");
|
|
284
|
+
export = module;
|
|
285
|
+
}
|