@flex-development/mlly 1.0.0-beta.4 → 1.0.0-beta.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.
- package/CHANGELOG.md +30 -0
- package/README.md +252 -113
- package/dist/index.d.mts +1908 -5
- package/dist/index.mjs +1 -5
- package/dist/internal/chain-or-call.d.mts +51 -0
- package/dist/internal/chain-or-call.mjs +1 -34
- package/dist/internal/chars.d.mts +16 -0
- package/dist/internal/chars.mjs +1 -17
- package/dist/internal/check-invalid-segments.d.mts +18 -0
- package/dist/internal/check-invalid-segments.mjs +1 -49
- package/dist/internal/constant.d.mts +21 -0
- package/dist/internal/constant.mjs +1 -23
- package/dist/internal/fs.browser.d.mts +12 -0
- package/dist/internal/fs.browser.mjs +1 -42
- package/dist/internal/fs.node.d.mts +12 -0
- package/dist/internal/fs.node.mjs +1 -16
- package/dist/internal/identity.d.mts +21 -0
- package/dist/internal/identity.mjs +1 -23
- package/dist/internal/invalid-package-target.d.mts +31 -0
- package/dist/internal/invalid-package-target.mjs +1 -36
- package/dist/internal/invalid-subpath.d.mts +32 -0
- package/dist/internal/invalid-subpath.mjs +1 -37
- package/dist/internal/is-promise.d.mts +21 -0
- package/dist/internal/is-promise.mjs +1 -26
- package/dist/internal/process.browser.d.mts +9 -0
- package/dist/internal/process.browser.mjs +1 -8
- package/dist/lib/can-parse-url.mjs +1 -31
- package/dist/lib/cwd.mjs +1 -17
- package/dist/lib/default-conditions.mjs +1 -14
- package/dist/lib/default-extensions.mjs +1 -29
- package/dist/lib/default-main-fields.mjs +1 -13
- package/dist/lib/extension-format-map.mjs +1 -31
- package/dist/lib/formats.mjs +1 -22
- package/dist/lib/get-source.mjs +1 -153
- package/dist/lib/index.mjs +1 -41
- package/dist/lib/is-absolute-specifier.mjs +1 -34
- package/dist/lib/is-array-index.mjs +1 -28
- package/dist/lib/is-bare-specifier.mjs +1 -33
- package/dist/lib/is-directory.mjs +1 -54
- package/dist/lib/is-file.mjs +1 -54
- package/dist/lib/is-imports-subpath.mjs +1 -28
- package/dist/lib/is-module-id.mjs +1 -24
- package/dist/lib/is-relative-specifier.mjs +1 -36
- package/dist/lib/lookup-package-scope.mjs +1 -102
- package/dist/lib/pattern-key-compare.mjs +1 -71
- package/dist/lib/pattern-match.mjs +1 -85
- package/dist/lib/read-package-json.mjs +1 -114
- package/dist/lib/resolve-alias.mjs +1 -102
- package/dist/lib/resolve-module.mjs +1 -186
- package/dist/lib/resolver.mjs +1 -1015
- package/dist/lib/root.mjs +1 -12
- package/dist/lib/to-relative-specifier.mjs +1 -63
- package/dist/lib/to-url.mjs +1 -34
- package/package.json +29 -13
- package/dist/interfaces/aliases.d.mts +0 -21
- package/dist/interfaces/buffer-encoding-map.d.mts +0 -29
- package/dist/interfaces/condition-map.d.mts +0 -24
- package/dist/interfaces/file-system.d.mts +0 -29
- package/dist/interfaces/get-source-context.d.mts +0 -44
- package/dist/interfaces/get-source-options.d.mts +0 -56
- package/dist/interfaces/index.d.mts +0 -22
- package/dist/interfaces/is-directory.d.mts +0 -17
- package/dist/interfaces/is-file.d.mts +0 -17
- package/dist/interfaces/main-field-map.d.mts +0 -22
- package/dist/interfaces/module-format-map.d.mts +0 -26
- package/dist/interfaces/pattern-key-comparison-map.d.mts +0 -31
- package/dist/interfaces/protocol-map.d.mts +0 -44
- package/dist/interfaces/read-file.d.mts +0 -42
- package/dist/interfaces/realpath.d.mts +0 -29
- package/dist/interfaces/resolve-alias-options.d.mts +0 -43
- package/dist/interfaces/resolve-module-options.d.mts +0 -79
- package/dist/interfaces/stat.d.mts +0 -27
- package/dist/interfaces/stats.d.mts +0 -23
- package/dist/lib/can-parse-url.d.mts +0 -23
- package/dist/lib/cwd.d.mts +0 -14
- package/dist/lib/default-conditions.d.mts +0 -15
- package/dist/lib/default-extensions.d.mts +0 -14
- package/dist/lib/default-main-fields.d.mts +0 -14
- package/dist/lib/extension-format-map.d.mts +0 -16
- package/dist/lib/formats.d.mts +0 -21
- package/dist/lib/get-source.d.mts +0 -46
- package/dist/lib/index.d.mts +0 -41
- package/dist/lib/is-absolute-specifier.d.mts +0 -23
- package/dist/lib/is-array-index.d.mts +0 -19
- package/dist/lib/is-bare-specifier.d.mts +0 -23
- package/dist/lib/is-directory.d.mts +0 -27
- package/dist/lib/is-file.d.mts +0 -27
- package/dist/lib/is-imports-subpath.d.mts +0 -26
- package/dist/lib/is-module-id.d.mts +0 -23
- package/dist/lib/is-relative-specifier.d.mts +0 -23
- package/dist/lib/lookup-package-scope.d.mts +0 -49
- package/dist/lib/pattern-key-compare.d.mts +0 -28
- package/dist/lib/pattern-match.d.mts +0 -22
- package/dist/lib/read-package-json.d.mts +0 -63
- package/dist/lib/resolve-alias.d.mts +0 -21
- package/dist/lib/resolve-module.d.mts +0 -43
- package/dist/lib/resolver.d.mts +0 -346
- package/dist/lib/root.d.mts +0 -11
- package/dist/lib/to-relative-specifier.d.mts +0 -27
- package/dist/lib/to-url.d.mts +0 -26
- package/dist/types/awaitable.d.mts +0 -12
- package/dist/types/buffer-encoding.d.mts +0 -13
- package/dist/types/change-ext-fn.d.mts +0 -29
- package/dist/types/condition.d.mts +0 -13
- package/dist/types/dot.d.mts +0 -9
- package/dist/types/empty-array.d.mts +0 -9
- package/dist/types/empty-object.d.mts +0 -19
- package/dist/types/empty-string.d.mts +0 -9
- package/dist/types/ext.d.mts +0 -12
- package/dist/types/file-content.d.mts +0 -11
- package/dist/types/get-source-handler.d.mts +0 -23
- package/dist/types/get-source-handlers.d.mts +0 -15
- package/dist/types/index.d.mts +0 -24
- package/dist/types/list.d.mts +0 -12
- package/dist/types/main-field.d.mts +0 -13
- package/dist/types/module-format.d.mts +0 -13
- package/dist/types/module-id.d.mts +0 -12
- package/dist/types/numeric.d.mts +0 -9
- package/dist/types/pattern-key-comparison.d.mts +0 -14
- package/dist/types/pattern-match.d.mts +0 -10
- package/dist/types/protocol.d.mts +0 -13
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,1910 @@
|
|
|
1
|
+
import * as pkgTypes from '@flex-development/pkg-types';
|
|
2
|
+
import { ImportsSubpath, PackageJson, Exports, ExportsObject, Imports } from '@flex-development/pkg-types';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
|
-
* @file
|
|
3
|
-
* @module mlly
|
|
5
|
+
* @file Interfaces - Aliases
|
|
6
|
+
* @module mlly/interfaces/Aliases
|
|
4
7
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Record, where each key is a path alias or pattern and each value
|
|
10
|
+
* is a path mapping configuration.
|
|
11
|
+
*
|
|
12
|
+
* This interface can be augmented to register custom aliases.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* declare module '@flex-development/mlly' {
|
|
16
|
+
* interface Aliases {
|
|
17
|
+
* custom?: string[] | string | null
|
|
18
|
+
* }
|
|
19
|
+
* }
|
|
20
|
+
*/
|
|
21
|
+
interface Aliases {
|
|
22
|
+
[alias: string]: (string | null | undefined)[] | string | null | undefined;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @file Interfaces - BufferEncodingMap
|
|
27
|
+
* @module mlly/interfaces/BufferEncodingMap
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* Registry of character encodings that can be used when working
|
|
31
|
+
* with {@linkcode Buffer} objects.
|
|
32
|
+
*
|
|
33
|
+
* This interface can be augmented to register custom encodings.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* declare module '@flex-development/mlly' {
|
|
37
|
+
* interface BufferEncodingMap {
|
|
38
|
+
* custom: 'custom'
|
|
39
|
+
* }
|
|
40
|
+
* }
|
|
41
|
+
*/
|
|
42
|
+
interface BufferEncodingMap {
|
|
43
|
+
ascii: 'ascii';
|
|
44
|
+
base64: 'base64';
|
|
45
|
+
base64url: 'base64url';
|
|
46
|
+
binary: 'binary';
|
|
47
|
+
hex: 'hex';
|
|
48
|
+
latin1: 'latin1';
|
|
49
|
+
ucs2: 'ucs2' | 'ucs-2';
|
|
50
|
+
utf16le: 'utf16le' | 'utf-16le';
|
|
51
|
+
utf8: 'utf8' | 'utf-8';
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @file Interfaces - ConditionMap
|
|
56
|
+
* @module mlly/interfaces/ConditionMap
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Registry of export/import conditions.
|
|
61
|
+
*
|
|
62
|
+
* This interface can be augmented to register custom conditions.
|
|
63
|
+
*
|
|
64
|
+
* @see {@linkcode pkgTypes.ConditionMap}
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* declare module '@flex-development/mlly' {
|
|
68
|
+
* interface ConditionMap {
|
|
69
|
+
* custom: 'custom'
|
|
70
|
+
* }
|
|
71
|
+
* }
|
|
72
|
+
*
|
|
73
|
+
* @extends {pkgTypes.ConditionMap}
|
|
74
|
+
*/
|
|
75
|
+
interface ConditionMap extends pkgTypes.ConditionMap {
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @file canParseUrl
|
|
80
|
+
* @module mlly/lib/canParseUrl
|
|
81
|
+
*/
|
|
82
|
+
/**
|
|
83
|
+
* Check if `input` can be parsed to a {@linkcode URL}.
|
|
84
|
+
*
|
|
85
|
+
* > 👉 **Note**: If `input` is relative, `base` is required.
|
|
86
|
+
* > If `input` is absolute, `base` is ignored.
|
|
87
|
+
*
|
|
88
|
+
* @see {@linkcode ModuleId}
|
|
89
|
+
*
|
|
90
|
+
* @this {void}
|
|
91
|
+
*
|
|
92
|
+
* @param {unknown} input
|
|
93
|
+
* The input URL
|
|
94
|
+
* @param {unknown} [base]
|
|
95
|
+
* The base URL to resolve against if `input` is not absolute
|
|
96
|
+
* @return {boolean}
|
|
97
|
+
* `true` if `input` can be parsed to a `URL`, `false` otherwise
|
|
98
|
+
*/
|
|
99
|
+
declare function canParseUrl(this: void, input: unknown, base?: unknown): boolean;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @file cwd
|
|
103
|
+
* @module mlly/lib/cwd
|
|
104
|
+
*/
|
|
105
|
+
/**
|
|
106
|
+
* Get the URL of the current working directory.
|
|
107
|
+
*
|
|
108
|
+
* @this {void}
|
|
109
|
+
*
|
|
110
|
+
* @return {URL}
|
|
111
|
+
* The current working directory URL
|
|
112
|
+
*/
|
|
113
|
+
declare function cwd(this: void): URL;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* @file defaultConditions
|
|
117
|
+
* @module mlly/lib/defaultConditions
|
|
118
|
+
*/
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* The default list of conditions.
|
|
122
|
+
*
|
|
123
|
+
* @see {@linkcode Condition}
|
|
124
|
+
* @see https://nodejs.org/api/packages.html#conditional-exports
|
|
125
|
+
*
|
|
126
|
+
* @const {Set<Condition>} defaultConditions
|
|
127
|
+
*/
|
|
128
|
+
declare const defaultConditions: Set<Condition>;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* @file defaultExtensions
|
|
132
|
+
* @module mlly/lib/defaultExtensions
|
|
133
|
+
*/
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* The default list of resolvable file extensions.
|
|
137
|
+
*
|
|
138
|
+
* @see {@linkcode Ext}
|
|
139
|
+
*
|
|
140
|
+
* @const {Set<Ext>} defaultExtensions
|
|
141
|
+
*/
|
|
142
|
+
declare const defaultExtensions: Set<Ext>;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* @file defaultMainFields
|
|
146
|
+
* @module mlly/lib/defaultMainFields
|
|
147
|
+
*/
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* The default list of main fields.
|
|
151
|
+
*
|
|
152
|
+
* @see {@linkcode MainField}
|
|
153
|
+
*
|
|
154
|
+
* @const {Set<MainField>} defaultMainFields
|
|
155
|
+
*/
|
|
156
|
+
declare const defaultMainFields: Set<MainField>;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* @file extensionFormatMap
|
|
160
|
+
* @module mlly/lib/extensionFormatMap
|
|
161
|
+
*/
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Map, where each key is a file extension
|
|
165
|
+
* and each value is a default module format.
|
|
166
|
+
*
|
|
167
|
+
* @see {@linkcode Ext}
|
|
168
|
+
* @see {@linkcode ModuleFormat}
|
|
169
|
+
*
|
|
170
|
+
* @const {Map<Ext, ModuleFormat>} extensionFormatMap
|
|
171
|
+
*/
|
|
172
|
+
declare const extensionFormatMap: Map<Ext, ModuleFormat>;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* @file formats
|
|
176
|
+
* @module mlly/lib/formats
|
|
177
|
+
*/
|
|
178
|
+
/**
|
|
179
|
+
* Default module formats.
|
|
180
|
+
*
|
|
181
|
+
* @see {@linkcode ModuleFormat}
|
|
182
|
+
*
|
|
183
|
+
* @enum {ModuleFormat}
|
|
184
|
+
*/
|
|
185
|
+
declare const enum formats {
|
|
186
|
+
builtin = "builtin",
|
|
187
|
+
commonjs = "commonjs",
|
|
188
|
+
cts = "commonjs-typescript",
|
|
189
|
+
json = "json",
|
|
190
|
+
module = "module",
|
|
191
|
+
mts = "module-typescript",
|
|
192
|
+
wasm = "wasm"
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* @file getSource
|
|
197
|
+
* @module mlly/lib/getSource
|
|
198
|
+
*/
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Get the source code for a module.
|
|
202
|
+
*
|
|
203
|
+
* @see {@linkcode EmptyString}
|
|
204
|
+
* @see {@linkcode GetSourceOptions}
|
|
205
|
+
*
|
|
206
|
+
* @this {void}
|
|
207
|
+
*
|
|
208
|
+
* @param {EmptyString | null | undefined} id
|
|
209
|
+
* The module id
|
|
210
|
+
* @param {GetSourceOptions | null | undefined} [options]
|
|
211
|
+
* Source code retrieval options
|
|
212
|
+
* @return {null}
|
|
213
|
+
* The module source code
|
|
214
|
+
*/
|
|
215
|
+
declare function getSource(this: void, id: EmptyString | null | undefined, options?: GetSourceOptions | null | undefined): null;
|
|
216
|
+
/**
|
|
217
|
+
* Get the source code for a module.
|
|
218
|
+
*
|
|
219
|
+
* > 👉 **Note**: Returns a promise if the handler for `id` is async.
|
|
220
|
+
*
|
|
221
|
+
* @see {@linkcode Awaitable}
|
|
222
|
+
* @see {@linkcode ErrUnsupportedEsmUrlScheme}
|
|
223
|
+
* @see {@linkcode GetSourceOptions}
|
|
224
|
+
* @see {@linkcode ModuleId}
|
|
225
|
+
*
|
|
226
|
+
* @template {Awaitable<FileContent | null | undefined>} T
|
|
227
|
+
* The module source code
|
|
228
|
+
*
|
|
229
|
+
* @this {void}
|
|
230
|
+
*
|
|
231
|
+
* @param {ModuleId | null | undefined} id
|
|
232
|
+
* The module id
|
|
233
|
+
* @param {GetSourceOptions | null | undefined} [options]
|
|
234
|
+
* Source code retrieval options
|
|
235
|
+
* @return {T}
|
|
236
|
+
* The module source code
|
|
237
|
+
* @throws {ErrUnsupportedEsmUrlScheme}
|
|
238
|
+
*/
|
|
239
|
+
declare function getSource<T extends Awaitable<FileContent | null | undefined>>(this: void, id: ModuleId | null | undefined, options?: GetSourceOptions | null | undefined): T;
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* @file isAbsoluteSpecifier
|
|
243
|
+
* @module mlly/lib/isAbsoluteSpecifier
|
|
244
|
+
*/
|
|
245
|
+
/**
|
|
246
|
+
* Check if `value` is an *absolute specifier*.
|
|
247
|
+
*
|
|
248
|
+
* ::: warning
|
|
249
|
+
* Only checks specifier syntax.
|
|
250
|
+
* Does **not** guarantee the specifier references an existing module.
|
|
251
|
+
* :::
|
|
252
|
+
*
|
|
253
|
+
* @see https://nodejs.org/api/esm.html#terminology
|
|
254
|
+
*
|
|
255
|
+
* @this {void}
|
|
256
|
+
*
|
|
257
|
+
* @param {unknown} value
|
|
258
|
+
* The value to check
|
|
259
|
+
* @return {boolean}
|
|
260
|
+
* `true` if `value` is absolute specifier, `false` otherwise
|
|
261
|
+
*/
|
|
262
|
+
declare function isAbsoluteSpecifier(this: void, value: unknown): boolean;
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* @file isArrayIndex
|
|
266
|
+
* @module mlly/lib/isArrayIndex
|
|
267
|
+
*/
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Check if `value` is a valid array index.
|
|
271
|
+
*
|
|
272
|
+
* @see {@linkcode Numeric}
|
|
273
|
+
*
|
|
274
|
+
* @this {void}
|
|
275
|
+
*
|
|
276
|
+
* @param {unknown} value
|
|
277
|
+
* The value to check
|
|
278
|
+
* @return {value is Numeric}
|
|
279
|
+
* `true` if `value` is valid array index, `false` otherwise
|
|
280
|
+
*/
|
|
281
|
+
declare function isArrayIndex(this: void, value: unknown): value is Numeric;
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* @file isBareSpecifier
|
|
285
|
+
* @module mlly/lib/isBareSpecifier
|
|
286
|
+
*/
|
|
287
|
+
/**
|
|
288
|
+
* Check if `value` is a *bare specifier*.
|
|
289
|
+
*
|
|
290
|
+
* ::: warning
|
|
291
|
+
* Only checks specifier syntax.
|
|
292
|
+
* Does **not** guarantee the specifier references an existing module.
|
|
293
|
+
* :::
|
|
294
|
+
*
|
|
295
|
+
* @see https://nodejs.org/api/esm.html#terminology
|
|
296
|
+
*
|
|
297
|
+
* @this {void}
|
|
298
|
+
*
|
|
299
|
+
* @param {unknown} value
|
|
300
|
+
* The value to check
|
|
301
|
+
* @return {boolean}
|
|
302
|
+
* `true` if `value` is bare specifier, `false` otherwise
|
|
303
|
+
*/
|
|
304
|
+
declare function isBareSpecifier(this: void, value: unknown): boolean;
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* @file isDirectory
|
|
308
|
+
* @module mlly/lib/isDirectory
|
|
309
|
+
*/
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Check if a directory exists.
|
|
313
|
+
*
|
|
314
|
+
* > 👉 **Note**: Returns a promise if `fs.stat` is async.
|
|
315
|
+
*
|
|
316
|
+
* @see {@linkcode Awaitable}
|
|
317
|
+
* @see {@linkcode FileSystem}
|
|
318
|
+
*
|
|
319
|
+
* @template {Awaitable<boolean>} T
|
|
320
|
+
* The result of the check
|
|
321
|
+
*
|
|
322
|
+
* @this {void}
|
|
323
|
+
*
|
|
324
|
+
* @param {unknown} id
|
|
325
|
+
* The module id to check
|
|
326
|
+
* @param {FileSystem | null | undefined} fs
|
|
327
|
+
* The file system API
|
|
328
|
+
* @return {T}
|
|
329
|
+
* `true` if directory exists at `id`, `false` otherwise
|
|
330
|
+
*/
|
|
331
|
+
declare function isDirectory<T extends Awaitable<boolean>>(this: void, id: unknown, fs?: FileSystem | null | undefined): T;
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* @file isFile
|
|
335
|
+
* @module mlly/lib/isFile
|
|
336
|
+
*/
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Check if a file exists.
|
|
340
|
+
*
|
|
341
|
+
* > 👉 **Note**: Returns a promise if `fs.stat` is async.
|
|
342
|
+
*
|
|
343
|
+
* @see {@linkcode Awaitable}
|
|
344
|
+
* @see {@linkcode FileSystem}
|
|
345
|
+
*
|
|
346
|
+
* @template {Awaitable<boolean>} T
|
|
347
|
+
* The result of the check
|
|
348
|
+
*
|
|
349
|
+
* @this {void}
|
|
350
|
+
*
|
|
351
|
+
* @param {unknown} id
|
|
352
|
+
* The module id to check
|
|
353
|
+
* @param {FileSystem | null | undefined} fs
|
|
354
|
+
* The file system API
|
|
355
|
+
* @return {T}
|
|
356
|
+
* `true` if file exists at `id`, `false` otherwise
|
|
357
|
+
*/
|
|
358
|
+
declare function isFile<T extends Awaitable<boolean>>(this: void, id: unknown, fs?: FileSystem | null | undefined): T;
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* @file isImportsSubpath
|
|
362
|
+
* @module mlly/lib/isImportsSubpath
|
|
363
|
+
*/
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Check if `value` is an [`imports`][subpath-imports] subpath.
|
|
367
|
+
*
|
|
368
|
+
* ::: warning
|
|
369
|
+
* Only checks specifier syntax.
|
|
370
|
+
* Does **not** guarantee the specifier references an existing module.
|
|
371
|
+
* :::
|
|
372
|
+
*
|
|
373
|
+
* [subpath-imports]: https://nodejs.org/api/packages.html#subpath-imports
|
|
374
|
+
*
|
|
375
|
+
* @see {@linkcode ImportsSubpath}
|
|
376
|
+
*
|
|
377
|
+
* @this {void}
|
|
378
|
+
*
|
|
379
|
+
* @param {unknown} value
|
|
380
|
+
* The value to check
|
|
381
|
+
* @return {value is ImportsSubpath}
|
|
382
|
+
* `true` if `value` is `imports` subpath, `false` otherwise
|
|
383
|
+
*/
|
|
384
|
+
declare function isImportsSubpath(this: void, value: unknown): value is ImportsSubpath;
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* @file isModuleId
|
|
388
|
+
* @module mlly/lib/isModuleId
|
|
389
|
+
*/
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Check if `value` is a module id.
|
|
393
|
+
*
|
|
394
|
+
* ::: warning
|
|
395
|
+
* Does **not** guarantee `value` references an existing file or directory.
|
|
396
|
+
* :::
|
|
397
|
+
*
|
|
398
|
+
* @see {@linkcode ModuleId}
|
|
399
|
+
*
|
|
400
|
+
* @this {void}
|
|
401
|
+
*
|
|
402
|
+
* @param {unknown} value
|
|
403
|
+
* The value to check
|
|
404
|
+
* @return {value is ModuleId}
|
|
405
|
+
* `true` if `value` is module id, `false` otherwise
|
|
406
|
+
*/
|
|
407
|
+
declare function isModuleId(this: void, value: unknown): value is ModuleId;
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* @file isRelativeSpecifier
|
|
411
|
+
* @module mlly/lib/isRelativeSpecifier
|
|
412
|
+
*/
|
|
413
|
+
/**
|
|
414
|
+
* Check if `value` is a *relative specifier*.
|
|
415
|
+
*
|
|
416
|
+
* ::: warning
|
|
417
|
+
* Only checks specifier syntax.
|
|
418
|
+
* Does **not** guarantee the specifier references an existing module.
|
|
419
|
+
* :::
|
|
420
|
+
*
|
|
421
|
+
* @see https://nodejs.org/api/esm.html#terminology
|
|
422
|
+
*
|
|
423
|
+
* @this {void}
|
|
424
|
+
*
|
|
425
|
+
* @param {unknown} value
|
|
426
|
+
* The value to check
|
|
427
|
+
* @return {boolean}
|
|
428
|
+
* `true` if `value` is relative specifier, `false` otherwise
|
|
429
|
+
*/
|
|
430
|
+
declare function isRelativeSpecifier(this: void, value: unknown): boolean;
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* @file lookupPackageScope
|
|
434
|
+
* @module mlly/lib/lookupPackageScope
|
|
435
|
+
*/
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Get the package scope URL for a module `url`.
|
|
439
|
+
*
|
|
440
|
+
* @see {@linkcode EmptyString}
|
|
441
|
+
*
|
|
442
|
+
* @this {void}
|
|
443
|
+
*
|
|
444
|
+
* @param {EmptyString | null | undefined} url
|
|
445
|
+
* The URL of the module to scope
|
|
446
|
+
* @param {ModuleId | null | undefined} [end]
|
|
447
|
+
* The URL of the directory to end search at, defaults to {@linkcode root}
|
|
448
|
+
* @param {FileSystem | null | undefined} [fs]
|
|
449
|
+
* The file system API
|
|
450
|
+
* @return {null}
|
|
451
|
+
* The URL of nearest directory containing a `package.json` file
|
|
452
|
+
*/
|
|
453
|
+
declare function lookupPackageScope(this: void, url: EmptyString | null | undefined, end?: ModuleId | null | undefined, fs?: FileSystem | null | undefined): null;
|
|
454
|
+
/**
|
|
455
|
+
* Get the package scope URL for a module `url`.
|
|
456
|
+
*
|
|
457
|
+
* Implements the `LOOKUP_PACKAGE_SCOPE` algorithm.
|
|
458
|
+
*
|
|
459
|
+
* > 👉 **Note**: Returns a promise if `fs.stat` is async.
|
|
460
|
+
*
|
|
461
|
+
* @see {@linkcode Awaitable}
|
|
462
|
+
* @see {@linkcode FileSystem}
|
|
463
|
+
* @see {@linkcode ModuleId}
|
|
464
|
+
*
|
|
465
|
+
* @template {Awaitable<URL | null>} T
|
|
466
|
+
* The resolved package scope URL
|
|
467
|
+
*
|
|
468
|
+
* @this {void}
|
|
469
|
+
*
|
|
470
|
+
* @param {ModuleId | null | undefined} url
|
|
471
|
+
* The URL of the module to scope
|
|
472
|
+
* @param {ModuleId | null | undefined} [end]
|
|
473
|
+
* The URL of the directory to end search at, defaults to {@linkcode root}
|
|
474
|
+
* @param {FileSystem | null | undefined} [fs]
|
|
475
|
+
* The file system API
|
|
476
|
+
* @return {T}
|
|
477
|
+
* The URL of nearest directory containing a `package.json` file
|
|
478
|
+
*/
|
|
479
|
+
declare function lookupPackageScope<T extends Awaitable<URL | null>>(this: void, url: ModuleId | null | undefined, end?: ModuleId | null | undefined, fs?: FileSystem | null | undefined): T;
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* @file patternKeyCompare
|
|
483
|
+
* @module mlly/lib/patternKeyCompare
|
|
484
|
+
*/
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Compare two pattern keys and return a value indicating their order.
|
|
488
|
+
*
|
|
489
|
+
* Implements the `PATTERN_KEY_COMPARE` algorithm.
|
|
490
|
+
*
|
|
491
|
+
* @see {@linkcode PatternKeyComparison}
|
|
492
|
+
*
|
|
493
|
+
* @this {void}
|
|
494
|
+
*
|
|
495
|
+
* @param {string} a
|
|
496
|
+
* The first key
|
|
497
|
+
* @param {string} b
|
|
498
|
+
* The key to compare against `a`
|
|
499
|
+
* @return {PatternKeyComparison}
|
|
500
|
+
* The pattern key comparsion result
|
|
501
|
+
*/
|
|
502
|
+
declare function patternKeyCompare(this: void, a: string, b: string): PatternKeyComparison;
|
|
503
|
+
declare namespace patternKeyCompare {
|
|
504
|
+
var EQUAL: 0;
|
|
505
|
+
var GREATER_THAN: 1;
|
|
506
|
+
var LESS_THAN: -1;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* @file patternMatch
|
|
511
|
+
* @module mlly/lib/patternMatch
|
|
512
|
+
*/
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Get a subpath pattern match for `matchKey`.
|
|
516
|
+
*
|
|
517
|
+
* @see {@linkcode PatternMatch}
|
|
518
|
+
*
|
|
519
|
+
* @this {void}
|
|
520
|
+
*
|
|
521
|
+
* @param {string} matchKey
|
|
522
|
+
* The key to expand
|
|
523
|
+
* @param {unknown} matchObject
|
|
524
|
+
* The match keys object
|
|
525
|
+
* @return {PatternMatch | null}
|
|
526
|
+
* List, where the first item is the key of a package exports
|
|
527
|
+
* or imports target object, and the last is a subpath pattern match
|
|
528
|
+
*/
|
|
529
|
+
declare function patternMatch(this: void, matchKey: string, matchObject: unknown): PatternMatch | null;
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* @file readPackageJson
|
|
533
|
+
* @module mlly/lib/readPackageJson
|
|
534
|
+
*/
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* Read a `package.json` file.
|
|
538
|
+
*
|
|
539
|
+
* @see {@linkcode EmptyString}
|
|
540
|
+
*
|
|
541
|
+
* @this {void}
|
|
542
|
+
*
|
|
543
|
+
* @param {EmptyString | null | undefined} id
|
|
544
|
+
* The URL of the package directory, the `package.json` file,
|
|
545
|
+
* or a module in the same directory as a `package.json`
|
|
546
|
+
* @param {string | null | undefined} [specifier]
|
|
547
|
+
* The module specifier that initiated the reading of the `package.json` file
|
|
548
|
+
* > 👉 **Note**: Should be a `file:` URL if `parent` is not a URL
|
|
549
|
+
* @param {ModuleId | null | undefined} [parent]
|
|
550
|
+
* The URL of the parent module
|
|
551
|
+
* @param {FileSystem | null | undefined} [fs]
|
|
552
|
+
* The file system API
|
|
553
|
+
* @return {null}
|
|
554
|
+
* The parsed file contents
|
|
555
|
+
*/
|
|
556
|
+
declare function readPackageJson(this: void, id: EmptyString | null | undefined, specifier?: string | null | undefined, parent?: ModuleId | null | undefined, fs?: FileSystem | null | undefined): null;
|
|
557
|
+
/**
|
|
558
|
+
* Read a `package.json` file.
|
|
559
|
+
*
|
|
560
|
+
* Implements the `READ_PACKAGE_JSON` algorithm.
|
|
561
|
+
*
|
|
562
|
+
* > 👉 **Note**: Returns a promise if `fs.readFile` or `fs.stat` is async.
|
|
563
|
+
*
|
|
564
|
+
* @see {@linkcode Awaitable}
|
|
565
|
+
* @see {@linkcode ErrInvalidPackageConfig}
|
|
566
|
+
* @see {@linkcode FileSystem}
|
|
567
|
+
* @see {@linkcode ModuleId}
|
|
568
|
+
* @see {@linkcode PackageJson}
|
|
569
|
+
*
|
|
570
|
+
* @template {Awaitable<PackageJson | null>} T
|
|
571
|
+
* The parsed file contents
|
|
572
|
+
*
|
|
573
|
+
* @this {void}
|
|
574
|
+
*
|
|
575
|
+
* @param {ModuleId | null | undefined} id
|
|
576
|
+
* The URL of the package directory, the `package.json` file,
|
|
577
|
+
* or a module in the same directory as a `package.json`
|
|
578
|
+
* @param {string | null | undefined} [specifier]
|
|
579
|
+
* The module specifier that initiated the reading of the `package.json` file
|
|
580
|
+
* > 👉 **Note**: Should be a `file:` URL if `parent` is not a URL
|
|
581
|
+
* @param {ModuleId | null | undefined} [parent]
|
|
582
|
+
* The URL of the parent module
|
|
583
|
+
* @param {FileSystem | null | undefined} [fs]
|
|
584
|
+
* The file system API
|
|
585
|
+
* @return {T}
|
|
586
|
+
* The parsed file contents
|
|
587
|
+
* @throws {ErrInvalidPackageConfig}
|
|
588
|
+
* If `package.json` file does not parse as valid JSON
|
|
589
|
+
* or package manifest object is not a JSON object
|
|
590
|
+
*/
|
|
591
|
+
declare function readPackageJson<T extends Awaitable<PackageJson | null>>(this: void, id: ModuleId | null | undefined, specifier?: string | null | undefined, parent?: ModuleId | null | undefined, fs?: FileSystem | null | undefined): T;
|
|
592
|
+
|
|
593
|
+
/**
|
|
594
|
+
* @file resolveAlias
|
|
595
|
+
* @module mlly/lib/resolveAlias
|
|
596
|
+
*/
|
|
597
|
+
|
|
598
|
+
/**
|
|
599
|
+
* Resolve an aliased `specifier`.
|
|
600
|
+
*
|
|
601
|
+
* @see {@linkcode ResolveAliasOptions}
|
|
602
|
+
*
|
|
603
|
+
* @this {void}
|
|
604
|
+
*
|
|
605
|
+
* @param {string} specifier
|
|
606
|
+
* The specifier using an alias
|
|
607
|
+
* @param {ResolveAliasOptions | null | undefined} [options]
|
|
608
|
+
* Options for alias resolution
|
|
609
|
+
* @return {string | null}
|
|
610
|
+
* The specifier of the aliased module
|
|
611
|
+
*/
|
|
612
|
+
declare function resolveAlias(this: void, specifier: string, options?: ResolveAliasOptions | null | undefined): string | null;
|
|
613
|
+
|
|
614
|
+
/**
|
|
615
|
+
* @file resolveModule
|
|
616
|
+
* @module mlly/lib/resolveModule
|
|
617
|
+
*/
|
|
618
|
+
|
|
619
|
+
/**
|
|
620
|
+
* Resolve a module `specifier`.
|
|
621
|
+
*
|
|
622
|
+
* Implements the `ESM_RESOLVE` algorithm, mostly 😉.
|
|
623
|
+
*
|
|
624
|
+
* Adds support for:
|
|
625
|
+
*
|
|
626
|
+
* - Extensionless and directory index resolution
|
|
627
|
+
* - Path alias resolution
|
|
628
|
+
* - Rewrite file extensions
|
|
629
|
+
* - Scopeless `@types/*` resolution (i.e. `unist` -> `@types/unist`)
|
|
630
|
+
*
|
|
631
|
+
* > 👉 **Note**: Returns a promise if {@linkcode moduleResolve}
|
|
632
|
+
* > returns a promise.
|
|
633
|
+
*
|
|
634
|
+
* @see {@linkcode Awaitable}
|
|
635
|
+
* @see {@linkcode ModuleId}
|
|
636
|
+
* @see {@linkcode NodeError}
|
|
637
|
+
* @see {@linkcode ResolveModuleOptions}
|
|
638
|
+
*
|
|
639
|
+
* @template {Awaitable<URL>} T
|
|
640
|
+
* The resolved URL
|
|
641
|
+
*
|
|
642
|
+
* @this {void}
|
|
643
|
+
*
|
|
644
|
+
* @param {string} specifier
|
|
645
|
+
* The module specifier to resolve
|
|
646
|
+
* @param {ModuleId} parent
|
|
647
|
+
* The URL of the parent module
|
|
648
|
+
* @param {ResolveModuleOptions | null | undefined} [options]
|
|
649
|
+
* Options for module resolution
|
|
650
|
+
* @return {T}
|
|
651
|
+
* The resolved URL
|
|
652
|
+
* @throws {NodeError}
|
|
653
|
+
*/
|
|
654
|
+
declare function resolveModule<T extends Awaitable<URL>>(this: void, specifier: string, parent: ModuleId, options?: ResolveModuleOptions | null | undefined): T;
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
* @file resolver
|
|
658
|
+
* @module mlly/lib/resolver
|
|
659
|
+
*/
|
|
660
|
+
|
|
661
|
+
declare module '@flex-development/errnode' {
|
|
662
|
+
interface ErrUnsupportedDirImport {
|
|
663
|
+
/**
|
|
664
|
+
* The directory URL.
|
|
665
|
+
*/
|
|
666
|
+
url?: string | null | undefined;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
/**
|
|
671
|
+
* Resolve a [`main`][main]-like package entry point.
|
|
672
|
+
*
|
|
673
|
+
* Implements the `LEGACY_MAIN_RESOLVE` algorithm.
|
|
674
|
+
*
|
|
675
|
+
* > 👉 **Note**: Returns a promise if `fs.stat` is async.
|
|
676
|
+
*
|
|
677
|
+
* [main]: https://github.com/nodejs/node/blob/v22.9.0/doc/api/packages.md#main
|
|
678
|
+
*
|
|
679
|
+
* @see {@linkcode Awaitable}
|
|
680
|
+
* @see {@linkcode ErrModuleNotFound}
|
|
681
|
+
* @see {@linkcode FileSystem}
|
|
682
|
+
* @see {@linkcode List}
|
|
683
|
+
* @see {@linkcode MainField}
|
|
684
|
+
* @see {@linkcode ModuleId}
|
|
685
|
+
* @see {@linkcode PackageJson}
|
|
686
|
+
*
|
|
687
|
+
* @template {Awaitable<URL>} T
|
|
688
|
+
* The resolved entry point URL
|
|
689
|
+
*
|
|
690
|
+
* @this {void}
|
|
691
|
+
*
|
|
692
|
+
* @param {ModuleId} packageUrl
|
|
693
|
+
* The URL of the package directory, the `package.json` file,
|
|
694
|
+
* or a module in the same directory as a `package.json`
|
|
695
|
+
* @param {PackageJson | null | undefined} [manifest]
|
|
696
|
+
* The package manifest
|
|
697
|
+
* @param {List<MainField> | null | undefined} [mainFields]
|
|
698
|
+
* The list of legacy main fields
|
|
699
|
+
* @param {ModuleId | null | undefined} [parent]
|
|
700
|
+
* The URL of the parent module
|
|
701
|
+
* @param {FileSystem | null | undefined} [fs]
|
|
702
|
+
* The file system API
|
|
703
|
+
* @return {Awaitable<URL>}
|
|
704
|
+
* The resolved entry point URL
|
|
705
|
+
* @throws {ErrModuleNotFound}
|
|
706
|
+
* If the entry point cannot be resolved
|
|
707
|
+
*/
|
|
708
|
+
declare function legacyMainResolve<T extends Awaitable<URL>>(this: void, packageUrl: ModuleId, manifest?: PackageJson | null | undefined, mainFields?: List<MainField> | null | undefined, parent?: ModuleId | null | undefined, fs?: FileSystem | null | undefined): T;
|
|
709
|
+
/**
|
|
710
|
+
* Resolve a module `specifier`.
|
|
711
|
+
*
|
|
712
|
+
* Implements the `ESM_RESOLVE` algorithm.
|
|
713
|
+
*
|
|
714
|
+
* > 👉 **Note**: Returns a promise if `fs.realpath` or `fs.stat` is async,
|
|
715
|
+
* > or one of the following methods returns a promise:
|
|
716
|
+
* > {@linkcode packageImportsResolve}, {@linkcode packageResolve}.
|
|
717
|
+
*
|
|
718
|
+
* @see {@linkcode Awaitable}
|
|
719
|
+
* @see {@linkcode Condition}
|
|
720
|
+
* @see {@linkcode ErrInvalidModuleSpecifier}
|
|
721
|
+
* @see {@linkcode ErrModuleNotFound}
|
|
722
|
+
* @see {@linkcode ErrUnsupportedDirImport}
|
|
723
|
+
* @see {@linkcode FileSystem}
|
|
724
|
+
* @see {@linkcode List}
|
|
725
|
+
* @see {@linkcode ModuleId}
|
|
726
|
+
*
|
|
727
|
+
* @template {Awaitable<URL>} T
|
|
728
|
+
* The resolved URL
|
|
729
|
+
*
|
|
730
|
+
* @this {void}
|
|
731
|
+
*
|
|
732
|
+
* @param {string} specifier
|
|
733
|
+
* The module specifier to resolve
|
|
734
|
+
* @param {ModuleId} parent
|
|
735
|
+
* The URL of the parent module
|
|
736
|
+
* @param {List<Condition> | null | undefined} [conditions]
|
|
737
|
+
* The list of export/import conditions
|
|
738
|
+
* @param {List<MainField> | null | undefined} [mainFields]
|
|
739
|
+
* The list of legacy main fields
|
|
740
|
+
* @param {boolean | null | undefined} [preserveSymlinks]
|
|
741
|
+
* Whether to keep symlinks instead of resolving them
|
|
742
|
+
* @param {FileSystem | null | undefined} [fs]
|
|
743
|
+
* The file system API
|
|
744
|
+
* @return {T}
|
|
745
|
+
* The resolved URL
|
|
746
|
+
* @throws {ErrInvalidModuleSpecifier}
|
|
747
|
+
* @throws {ErrModuleNotFound}
|
|
748
|
+
* @throws {ErrUnsupportedDirImport}
|
|
749
|
+
*/
|
|
750
|
+
declare function moduleResolve<T extends Awaitable<URL>>(this: void, specifier: string, parent: ModuleId, conditions?: List<Condition> | null | undefined, mainFields?: List<MainField> | null | undefined, preserveSymlinks?: boolean | null | undefined, fs?: FileSystem | null | undefined): T;
|
|
751
|
+
/**
|
|
752
|
+
* Resolve a package export.
|
|
753
|
+
*
|
|
754
|
+
* Implements the `PACKAGE_EXPORTS_RESOLVE` algorithm.
|
|
755
|
+
*
|
|
756
|
+
* > 👉 **Note**: Never returns a promise.
|
|
757
|
+
*
|
|
758
|
+
* @see {@linkcode Awaitable}
|
|
759
|
+
* @see {@linkcode Condition}
|
|
760
|
+
* @see {@linkcode ErrInvalidPackageConfig}
|
|
761
|
+
* @see {@linkcode ErrPackagePathNotExported}
|
|
762
|
+
* @see {@linkcode Exports}
|
|
763
|
+
* @see {@linkcode FileSystem}
|
|
764
|
+
* @see {@linkcode Imports}
|
|
765
|
+
* @see {@linkcode List}
|
|
766
|
+
* @see {@linkcode ModuleId}
|
|
767
|
+
*
|
|
768
|
+
* @template {Awaitable<URL>} T
|
|
769
|
+
* The resolved package export URL
|
|
770
|
+
*
|
|
771
|
+
* @this {void}
|
|
772
|
+
*
|
|
773
|
+
* @param {ModuleId} packageUrl
|
|
774
|
+
* The URL of the package directory, the `package.json` file,
|
|
775
|
+
* or a module in the same directory as a `package.json`
|
|
776
|
+
* @param {string} subpath
|
|
777
|
+
* The package subpath
|
|
778
|
+
* @param {Exports | undefined} exports
|
|
779
|
+
* The package exports
|
|
780
|
+
* @param {List<Condition> | null | undefined} [conditions]
|
|
781
|
+
* The list of export/import conditions
|
|
782
|
+
* @param {ModuleId | null | undefined} [parent]
|
|
783
|
+
* The URL of the parent module
|
|
784
|
+
* @param {FileSystem | null | undefined} [fs]
|
|
785
|
+
* The file system API
|
|
786
|
+
* @return {Awaitable<URL>}
|
|
787
|
+
* The resolved package export URL
|
|
788
|
+
* @throws {ErrInvalidPackageConfig}
|
|
789
|
+
* @throws {ErrPackagePathNotExported}
|
|
790
|
+
*/
|
|
791
|
+
declare function packageExportsResolve<T extends Awaitable<URL>>(this: void, packageUrl: ModuleId, subpath: string, // eslint-disable-next-line unicorn/prefer-module
|
|
792
|
+
exports: Exports | undefined, conditions?: List<Condition> | null | undefined, parent?: ModuleId | null | undefined, fs?: FileSystem | null | undefined): T;
|
|
793
|
+
/**
|
|
794
|
+
* Resolve a package export or import.
|
|
795
|
+
*
|
|
796
|
+
* Implements the `PACKAGE_IMPORTS_EXPORTS_RESOLVE` algorithm.
|
|
797
|
+
*
|
|
798
|
+
* > 👉 **Note**: Returns a promise if {@linkcode packageTargetResolve}
|
|
799
|
+
* > returns a promise.
|
|
800
|
+
*
|
|
801
|
+
* @see {@linkcode Awaitable}
|
|
802
|
+
* @see {@linkcode Condition}
|
|
803
|
+
* @see {@linkcode ExportsObject}
|
|
804
|
+
* @see {@linkcode FileSystem}
|
|
805
|
+
* @see {@linkcode Imports}
|
|
806
|
+
* @see {@linkcode List}
|
|
807
|
+
* @see {@linkcode ModuleId}
|
|
808
|
+
*
|
|
809
|
+
* @template {Awaitable<URL | null | undefined>} T
|
|
810
|
+
* The resolved package export or import URL
|
|
811
|
+
*
|
|
812
|
+
* @this {void}
|
|
813
|
+
*
|
|
814
|
+
* @param {string} matchKey
|
|
815
|
+
* The package subpath extracted from a module specifier,
|
|
816
|
+
* or a dot character (`.`)
|
|
817
|
+
* @param {ExportsObject | Imports | null | undefined} matchObject
|
|
818
|
+
* The package exports or imports
|
|
819
|
+
* @param {ModuleId} packageUrl
|
|
820
|
+
* The URL of the directory containing the `package.json` file
|
|
821
|
+
* @param {boolean | null | undefined} [isImports]
|
|
822
|
+
* Whether `matchObject` is internal to the package
|
|
823
|
+
* @param {List<Condition> | null | undefined} [conditions]
|
|
824
|
+
* The list of export/import conditions
|
|
825
|
+
* @param {List<MainField> | null | undefined} [mainFields]
|
|
826
|
+
* The list of legacy main fields
|
|
827
|
+
* @param {ModuleId | null | undefined} [parent]
|
|
828
|
+
* The URL of the parent module
|
|
829
|
+
* @param {FileSystem | null | undefined} [fs]
|
|
830
|
+
* The file system API
|
|
831
|
+
* @return {T}
|
|
832
|
+
* The resolved package export or import URL
|
|
833
|
+
*/
|
|
834
|
+
declare function packageImportsExportsResolve<T extends Awaitable<URL | null | undefined>>(this: void, matchKey: string, matchObject: ExportsObject | Imports | null | undefined, packageUrl: ModuleId, isImports?: boolean | null | undefined, conditions?: List<Condition> | null | undefined, mainFields?: List<MainField> | null | undefined, parent?: ModuleId | null | undefined, fs?: FileSystem | null | undefined): T;
|
|
835
|
+
/**
|
|
836
|
+
* Resolve a package import.
|
|
837
|
+
*
|
|
838
|
+
* Implements the `PACKAGE_IMPORTS_RESOLVE` algorithm.
|
|
839
|
+
*
|
|
840
|
+
* > 👉 **Note**: Returns a promise if {@linkcode lookupPackageScope},
|
|
841
|
+
* > {@linkcode packageImportsExportsResolve}, or {@linkcode readPackageJson}
|
|
842
|
+
* > returns a promise.
|
|
843
|
+
*
|
|
844
|
+
* @see {@linkcode Awaitable}
|
|
845
|
+
* @see {@linkcode Condition}
|
|
846
|
+
* @see {@linkcode ErrInvalidModuleSpecifier}
|
|
847
|
+
* @see {@linkcode ErrPackageImportNotDefined}
|
|
848
|
+
* @see {@linkcode FileSystem}
|
|
849
|
+
* @see {@linkcode List}
|
|
850
|
+
* @see {@linkcode ModuleId}
|
|
851
|
+
*
|
|
852
|
+
* @template {Awaitable<URL>} T
|
|
853
|
+
* The resolved package import URL
|
|
854
|
+
*
|
|
855
|
+
* @this {void}
|
|
856
|
+
*
|
|
857
|
+
* @param {string} specifier
|
|
858
|
+
* The import specifier to resolve
|
|
859
|
+
* @param {ModuleId} parent
|
|
860
|
+
* The URL of the parent module
|
|
861
|
+
* @param {List<Condition> | null | undefined} [conditions]
|
|
862
|
+
* The list of export/import conditions
|
|
863
|
+
* @param {List<MainField> | null | undefined} [mainFields]
|
|
864
|
+
* The list of legacy main fields
|
|
865
|
+
* @param {FileSystem | null | undefined} [fs]
|
|
866
|
+
* The file system API
|
|
867
|
+
* @return {T}
|
|
868
|
+
* The resolved package import URL
|
|
869
|
+
* @throws {ErrInvalidModuleSpecifier}
|
|
870
|
+
* @throws {ErrPackageImportNotDefined}
|
|
871
|
+
*/
|
|
872
|
+
declare function packageImportsResolve<T extends Awaitable<URL>>(this: void, specifier: string, parent: ModuleId, conditions?: List<Condition> | null | undefined, mainFields?: List<MainField> | null | undefined, fs?: FileSystem | null | undefined): T;
|
|
873
|
+
/**
|
|
874
|
+
* Resolve a *bare specifier*.
|
|
875
|
+
*
|
|
876
|
+
* Implements the `PACKAGE_RESOLVE` algorithm.
|
|
877
|
+
*
|
|
878
|
+
* > *Bare specifiers* like `'some-package'` or `'some-package/shuffle'` refer
|
|
879
|
+
* > to the main entry point of a package by package name, or a specific feature
|
|
880
|
+
* > module within a package prefixed by the package name. Including the file
|
|
881
|
+
* > extension is only necessary for packages without an [`"exports"`][exports]
|
|
882
|
+
* > field.
|
|
883
|
+
*
|
|
884
|
+
* > 👉 **Note**: Returns a promise if `fs.stat` is async or one of the
|
|
885
|
+
* > following methods returns a promise: {@linkcode legacyMainResolve},
|
|
886
|
+
* > {@linkcode packageExportsResolve}, {@linkcode packageSelfResolve},
|
|
887
|
+
* > {@linkcode readPackageJson}.
|
|
888
|
+
*
|
|
889
|
+
* [exports]: https://nodejs.org/api/packages.html#exports
|
|
890
|
+
*
|
|
891
|
+
* @see {@linkcode Awaitable}
|
|
892
|
+
* @see {@linkcode Condition}
|
|
893
|
+
* @see {@linkcode ErrInvalidModuleSpecifier}
|
|
894
|
+
* @see {@linkcode ErrModuleNotFound}
|
|
895
|
+
* @see {@linkcode FileSystem}
|
|
896
|
+
* @see {@linkcode List}
|
|
897
|
+
* @see {@linkcode MainField}
|
|
898
|
+
* @see {@linkcode ModuleId}
|
|
899
|
+
*
|
|
900
|
+
* @template {Awaitable<URL>} T
|
|
901
|
+
* The resolved package URL
|
|
902
|
+
*
|
|
903
|
+
* @this {void}
|
|
904
|
+
*
|
|
905
|
+
* @param {string} specifier
|
|
906
|
+
* The package specifier
|
|
907
|
+
* @param {ModuleId} parent
|
|
908
|
+
* The URL of the parent module
|
|
909
|
+
* @param {List<Condition> | null | undefined} [conditions]
|
|
910
|
+
* The list of export conditions
|
|
911
|
+
* @param {List<MainField> | null | undefined} [mainFields]
|
|
912
|
+
* The list of legacy main fields
|
|
913
|
+
* @param {FileSystem | null | undefined} [fs]
|
|
914
|
+
* The file system API
|
|
915
|
+
* @return {T}
|
|
916
|
+
* The resolved package URL
|
|
917
|
+
* @throws {ErrInvalidModuleSpecifier}
|
|
918
|
+
* @throws {ErrModuleNotFound}
|
|
919
|
+
*/
|
|
920
|
+
declare function packageResolve<T extends Awaitable<URL>>(this: void, specifier: string, parent: ModuleId, conditions?: List<Condition> | null | undefined, mainFields?: List<MainField> | null | undefined, fs?: FileSystem | null | undefined): T;
|
|
921
|
+
/**
|
|
922
|
+
* Resolve the self-import of a package.
|
|
923
|
+
*
|
|
924
|
+
* Implements the `PACKAGE_SELF_RESOLVE` algorithm.
|
|
925
|
+
*
|
|
926
|
+
* > 👉 **Note**: Returns a promise if {@linkcode lookupPackageScope},
|
|
927
|
+
* > {@linkcode packageExportsResolve}, or {@linkcode readPackageJson}
|
|
928
|
+
* > returns a promise.
|
|
929
|
+
*
|
|
930
|
+
* @see {@linkcode Awaitable}
|
|
931
|
+
* @see {@linkcode Condition}
|
|
932
|
+
* @see {@linkcode FileSystem}
|
|
933
|
+
* @see {@linkcode List}
|
|
934
|
+
* @see {@linkcode ModuleId}
|
|
935
|
+
*
|
|
936
|
+
* @template {Awaitable<URL | undefined>} T
|
|
937
|
+
* The resolved package URL
|
|
938
|
+
*
|
|
939
|
+
* @this {void}
|
|
940
|
+
*
|
|
941
|
+
* @param {string} name
|
|
942
|
+
* The package name
|
|
943
|
+
* @param {string} subpath
|
|
944
|
+
* The package subpath
|
|
945
|
+
* @param {ModuleId} parent
|
|
946
|
+
* The URL of the parent module
|
|
947
|
+
* @param {List<Condition> | null | undefined} [conditions]
|
|
948
|
+
* The list of export conditions
|
|
949
|
+
* @param {FileSystem | null | undefined} [fs]
|
|
950
|
+
* The file system API
|
|
951
|
+
* @return {T}
|
|
952
|
+
* The resolved package URL
|
|
953
|
+
*/
|
|
954
|
+
declare function packageSelfResolve<T extends Awaitable<URL | undefined>>(this: void, name: string, subpath: string, parent: ModuleId, conditions?: List<Condition> | null | undefined, fs?: FileSystem | null | undefined): T;
|
|
955
|
+
/**
|
|
956
|
+
* Resolve a package target.
|
|
957
|
+
*
|
|
958
|
+
* Implements the `PACKAGE_TARGET_RESOLVE` algorithm.
|
|
959
|
+
*
|
|
960
|
+
* > 👉 **Note**: Returns a promise if `target` is internal to the package and
|
|
961
|
+
* > {@linkcode packageResolve} returns a promise.
|
|
962
|
+
*
|
|
963
|
+
* @see {@linkcode Awaitable}
|
|
964
|
+
* @see {@linkcode Condition}
|
|
965
|
+
* @see {@linkcode ErrInvalidPackageConfig}
|
|
966
|
+
* @see {@linkcode ErrInvalidPackageTarget}
|
|
967
|
+
* @see {@linkcode FileSystem}
|
|
968
|
+
* @see {@linkcode List}
|
|
969
|
+
* @see {@linkcode ModuleId}
|
|
970
|
+
* @see {@linkcode Target}
|
|
971
|
+
*
|
|
972
|
+
* @template {Awaitable<URL | null | undefined>} T
|
|
973
|
+
* The resolved package target URL
|
|
974
|
+
*
|
|
975
|
+
* @this {void}
|
|
976
|
+
*
|
|
977
|
+
* @param {ModuleId} packageUrl
|
|
978
|
+
* The URL of the directory containing the `package.json` file
|
|
979
|
+
* @param {unknown} target
|
|
980
|
+
* The package target (i.e. a `exports`/`imports` value)
|
|
981
|
+
* @param {string} subpath
|
|
982
|
+
* The package subpath (i.e. a `exports`/`imports` key)
|
|
983
|
+
* @param {string | null | undefined} [patternMatch]
|
|
984
|
+
* The `subpath` pattern match
|
|
985
|
+
* @param {boolean | null | undefined} [isImports]
|
|
986
|
+
* Whether `target` is internal to the package
|
|
987
|
+
* @param {List<Condition> | null | undefined} [conditions]
|
|
988
|
+
* The list of export/import conditions
|
|
989
|
+
* @param {List<MainField> | null | undefined} [mainFields]
|
|
990
|
+
* The list of legacy main fields
|
|
991
|
+
* @param {ModuleId | null | undefined} [parent]
|
|
992
|
+
* The URL of the parent module
|
|
993
|
+
* @param {FileSystem | null | undefined} [fs]
|
|
994
|
+
* The file system API
|
|
995
|
+
* @return {T}
|
|
996
|
+
* The resolved package target URL
|
|
997
|
+
* @throws {ErrInvalidPackageConfig}
|
|
998
|
+
* @throws {ErrInvalidPackageTarget}
|
|
999
|
+
*/
|
|
1000
|
+
declare function packageTargetResolve<T extends Awaitable<URL | null | undefined>>(this: void, packageUrl: ModuleId, target: unknown, subpath: string, patternMatch?: string | null | undefined, isImports?: boolean | null | undefined, conditions?: List<Condition> | null | undefined, mainFields?: List<MainField> | null | undefined, parent?: ModuleId | null | undefined, fs?: FileSystem | null | undefined): T;
|
|
1001
|
+
|
|
1002
|
+
declare const resolver_d_legacyMainResolve: typeof legacyMainResolve;
|
|
1003
|
+
declare const resolver_d_moduleResolve: typeof moduleResolve;
|
|
1004
|
+
declare const resolver_d_packageExportsResolve: typeof packageExportsResolve;
|
|
1005
|
+
declare const resolver_d_packageImportsExportsResolve: typeof packageImportsExportsResolve;
|
|
1006
|
+
declare const resolver_d_packageImportsResolve: typeof packageImportsResolve;
|
|
1007
|
+
declare const resolver_d_packageResolve: typeof packageResolve;
|
|
1008
|
+
declare const resolver_d_packageSelfResolve: typeof packageSelfResolve;
|
|
1009
|
+
declare const resolver_d_packageTargetResolve: typeof packageTargetResolve;
|
|
1010
|
+
declare namespace resolver_d {
|
|
1011
|
+
export {
|
|
1012
|
+
resolver_d_legacyMainResolve as legacyMainResolve,
|
|
1013
|
+
resolver_d_moduleResolve as moduleResolve,
|
|
1014
|
+
resolver_d_packageExportsResolve as packageExportsResolve,
|
|
1015
|
+
resolver_d_packageImportsExportsResolve as packageImportsExportsResolve,
|
|
1016
|
+
resolver_d_packageImportsResolve as packageImportsResolve,
|
|
1017
|
+
resolver_d_packageResolve as packageResolve,
|
|
1018
|
+
resolver_d_packageSelfResolve as packageSelfResolve,
|
|
1019
|
+
resolver_d_packageTargetResolve as packageTargetResolve,
|
|
1020
|
+
};
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
/**
|
|
1024
|
+
* @file root
|
|
1025
|
+
* @module mlly/lib/root
|
|
1026
|
+
*/
|
|
1027
|
+
/**
|
|
1028
|
+
* The URL of the file system root.
|
|
1029
|
+
*
|
|
1030
|
+
* @const {URL} root
|
|
1031
|
+
*/
|
|
1032
|
+
declare const root: URL;
|
|
1033
|
+
|
|
1034
|
+
/**
|
|
1035
|
+
* @file toRelativeSpecifier
|
|
1036
|
+
* @module mlly/lib/toRelativeSpecifier
|
|
1037
|
+
*/
|
|
1038
|
+
|
|
1039
|
+
/**
|
|
1040
|
+
* Turn `url` into a *relative specifier*.
|
|
1041
|
+
*
|
|
1042
|
+
* ::: info
|
|
1043
|
+
* The relative specifier will only have a file extension
|
|
1044
|
+
* if `specifier` also has an extension.
|
|
1045
|
+
* :::
|
|
1046
|
+
*
|
|
1047
|
+
* @see {@linkcode ModuleId}
|
|
1048
|
+
* @see https://nodejs.org/api/esm.html#terminology
|
|
1049
|
+
*
|
|
1050
|
+
* @this {void}
|
|
1051
|
+
*
|
|
1052
|
+
* @param {ModuleId} url
|
|
1053
|
+
* The `file:` URL to convert
|
|
1054
|
+
* @param {ModuleId} parent
|
|
1055
|
+
* The parent module id
|
|
1056
|
+
* @return {string}
|
|
1057
|
+
* The relative specifier
|
|
1058
|
+
*/
|
|
1059
|
+
declare function toRelativeSpecifier(this: void, url: ModuleId, parent: ModuleId): string;
|
|
1060
|
+
|
|
1061
|
+
/**
|
|
1062
|
+
* @file toUrl
|
|
1063
|
+
* @module mlly/lib/toUrl
|
|
1064
|
+
*/
|
|
1065
|
+
|
|
1066
|
+
/**
|
|
1067
|
+
* Convert `id` to a {@linkcode URL}.
|
|
1068
|
+
*
|
|
1069
|
+
* > 👉 **Note**: If `id` cannot be parsed as a `URL`, and is also not a
|
|
1070
|
+
* > [builtin module][builtin-module], it will be assumed to be a path and
|
|
1071
|
+
* > converted to a [`file:` URL][file-url].
|
|
1072
|
+
*
|
|
1073
|
+
* [builtin-module]: https://nodejs.org/api/esm.html#builtin-modules
|
|
1074
|
+
* [file-url]: https://nodejs.org/api/esm.html#file-urls
|
|
1075
|
+
*
|
|
1076
|
+
* @this {void}
|
|
1077
|
+
*
|
|
1078
|
+
* @param {ModuleId} id
|
|
1079
|
+
* The module id to convert
|
|
1080
|
+
* @param {ModuleId | null | undefined} [parent]
|
|
1081
|
+
* The base URL to resolve against if `id` is not absolute
|
|
1082
|
+
* @return {URL}
|
|
1083
|
+
* The new URL
|
|
1084
|
+
*/
|
|
1085
|
+
declare function toUrl(this: void, id: ModuleId, parent?: ModuleId | null | undefined): URL;
|
|
1086
|
+
|
|
1087
|
+
/**
|
|
1088
|
+
* @file Type Aliases - Awaitable
|
|
1089
|
+
* @module mlly/types/Awaitable
|
|
1090
|
+
*/
|
|
1091
|
+
/**
|
|
1092
|
+
* Create a union of `T` and `T` as a promise-like object.
|
|
1093
|
+
*
|
|
1094
|
+
* @template {any} T
|
|
1095
|
+
* The value
|
|
1096
|
+
*/
|
|
1097
|
+
type Awaitable<T> = PromiseLike<T> | T;
|
|
1098
|
+
|
|
1099
|
+
/**
|
|
1100
|
+
* @file Type Aliases - BufferEncoding
|
|
1101
|
+
* @module mlly/types/BufferEncoding
|
|
1102
|
+
*/
|
|
1103
|
+
|
|
1104
|
+
/**
|
|
1105
|
+
* Union of values that can occur where a buffer encoding is expected.
|
|
1106
|
+
*
|
|
1107
|
+
* To register new encodings, augment {@linkcode BufferEncodingMap}.
|
|
1108
|
+
* They will be added to this union automatically.
|
|
1109
|
+
*/
|
|
1110
|
+
type BufferEncoding = BufferEncodingMap[keyof BufferEncodingMap];
|
|
1111
|
+
|
|
1112
|
+
/**
|
|
1113
|
+
* @file Type Aliases - Condition
|
|
1114
|
+
* @module mlly/types/Condition
|
|
1115
|
+
*/
|
|
1116
|
+
|
|
1117
|
+
/**
|
|
1118
|
+
* Union of values that can occur where a export/import condition is expected.
|
|
1119
|
+
*
|
|
1120
|
+
* To register new conditions, augment {@linkcode ConditionMap}.
|
|
1121
|
+
* They will be added to this union automatically.
|
|
1122
|
+
*/
|
|
1123
|
+
type Condition = ConditionMap[keyof ConditionMap];
|
|
1124
|
+
|
|
1125
|
+
/**
|
|
1126
|
+
* @file Type Aliases - Dot
|
|
1127
|
+
* @module mlly/types/Dot
|
|
1128
|
+
*/
|
|
1129
|
+
/**
|
|
1130
|
+
* A dot character (`'.'`).
|
|
1131
|
+
*/
|
|
1132
|
+
type Dot = '.';
|
|
1133
|
+
|
|
1134
|
+
/**
|
|
1135
|
+
* @file Type Aliases - EmptyArray
|
|
1136
|
+
* @module mlly/types/EmptyArray
|
|
1137
|
+
*/
|
|
1138
|
+
/**
|
|
1139
|
+
* An empty array.
|
|
1140
|
+
*/
|
|
1141
|
+
type EmptyArray = [];
|
|
1142
|
+
|
|
1143
|
+
/**
|
|
1144
|
+
* @file Type Aliases - EmptyObject
|
|
1145
|
+
* @module mlly/types/EmptyObject
|
|
1146
|
+
*/
|
|
1147
|
+
/**
|
|
1148
|
+
* The empty object symbol.
|
|
1149
|
+
*
|
|
1150
|
+
* @internal
|
|
1151
|
+
*
|
|
1152
|
+
* @const {symbol} tag
|
|
1153
|
+
*/
|
|
1154
|
+
declare const tag: unique symbol;
|
|
1155
|
+
/**
|
|
1156
|
+
* An empty object.
|
|
1157
|
+
*/
|
|
1158
|
+
type EmptyObject = {
|
|
1159
|
+
[tag]?: never;
|
|
1160
|
+
};
|
|
1161
|
+
|
|
1162
|
+
/**
|
|
1163
|
+
* @file Type Aliases - EmptyString
|
|
1164
|
+
* @module mlly/types/EmptyString
|
|
1165
|
+
*/
|
|
1166
|
+
/**
|
|
1167
|
+
* An empty string.
|
|
1168
|
+
*/
|
|
1169
|
+
type EmptyString = '';
|
|
1170
|
+
|
|
1171
|
+
/**
|
|
1172
|
+
* @file Type Aliases - Ext
|
|
1173
|
+
* @module mlly/types/Ext
|
|
1174
|
+
*/
|
|
1175
|
+
|
|
1176
|
+
/**
|
|
1177
|
+
* A file extension.
|
|
1178
|
+
*
|
|
1179
|
+
* @see {@linkcode Dot}
|
|
1180
|
+
*/
|
|
1181
|
+
type Ext = `${Dot}${string}`;
|
|
1182
|
+
|
|
1183
|
+
/**
|
|
1184
|
+
* @file Type Aliases - ExtensionRewrites
|
|
1185
|
+
* @module mlly/types/ExtensionRewrites
|
|
1186
|
+
*/
|
|
1187
|
+
|
|
1188
|
+
/**
|
|
1189
|
+
* Record, where each key is the file extension of a module specifier and
|
|
1190
|
+
* each value is a replacement file extension.
|
|
1191
|
+
*
|
|
1192
|
+
* > 👉 **Note**: Replacement file extensions are normalized and do not need to
|
|
1193
|
+
* > begin with a dot character (`'.'`); falsy values will remove an extension.
|
|
1194
|
+
*
|
|
1195
|
+
* @see {@linkcode EmptyString}
|
|
1196
|
+
* @see {@linkcode Ext}
|
|
1197
|
+
*/
|
|
1198
|
+
type ExtensionRewrites = {
|
|
1199
|
+
[K in EmptyString | Ext]?: string | false | null | undefined;
|
|
1200
|
+
};
|
|
1201
|
+
|
|
1202
|
+
/**
|
|
1203
|
+
* @file Type Aliases - FileContent
|
|
1204
|
+
* @module mlly/types/FileContent
|
|
1205
|
+
*/
|
|
1206
|
+
/**
|
|
1207
|
+
* Union of values that can occur where file content is expected.
|
|
1208
|
+
*
|
|
1209
|
+
* @see {@linkcode Uint8Array}
|
|
1210
|
+
*/
|
|
1211
|
+
type FileContent = Uint8Array | string;
|
|
1212
|
+
|
|
1213
|
+
/**
|
|
1214
|
+
* @file Type Aliases - GetNewExtension
|
|
1215
|
+
* @module mlly/types/GetNewExtension
|
|
1216
|
+
*/
|
|
1217
|
+
/**
|
|
1218
|
+
* Get a new file extension for a `url`.
|
|
1219
|
+
*
|
|
1220
|
+
* Returning an empty string (`''`), `false`, `null`, or `undefined`
|
|
1221
|
+
* will remove the current file extension.
|
|
1222
|
+
*
|
|
1223
|
+
* ::: info
|
|
1224
|
+
* File extensions are normalized and
|
|
1225
|
+
* do not need to begin with a dot character (`'.'`).
|
|
1226
|
+
* :::
|
|
1227
|
+
*
|
|
1228
|
+
* @see {@linkcode URL}
|
|
1229
|
+
* @see https://github.com/flex-development/pathe/tree/1.0.3#changeextpath-string-ext-nullablestring-string
|
|
1230
|
+
*
|
|
1231
|
+
* @template {string | false | null | undefined} [T]
|
|
1232
|
+
* The new file extension
|
|
1233
|
+
*
|
|
1234
|
+
* @param {URL} url
|
|
1235
|
+
* The resolved module URL
|
|
1236
|
+
* @param {string} specifier
|
|
1237
|
+
* The module specifier being resolved
|
|
1238
|
+
* @return {T}
|
|
1239
|
+
* The new file extension
|
|
1240
|
+
*/
|
|
1241
|
+
type GetNewExtension<T extends string | false | null | undefined = string | false | null | undefined> = (this: void, url: URL, specifier: string) => T;
|
|
1242
|
+
|
|
1243
|
+
/**
|
|
1244
|
+
* @file Type Aliases - GetSourceHandler
|
|
1245
|
+
* @module mlly/types/GetSourceHandler
|
|
1246
|
+
*/
|
|
1247
|
+
|
|
1248
|
+
/**
|
|
1249
|
+
* Get the source code for a module.
|
|
1250
|
+
*
|
|
1251
|
+
* @see {@linkcode Awaitable}
|
|
1252
|
+
* @see {@linkcode FileContent}
|
|
1253
|
+
* @see {@linkcode GetSourceContext}
|
|
1254
|
+
* @see {@linkcode URL}
|
|
1255
|
+
*
|
|
1256
|
+
* @this {GetSourceContext}
|
|
1257
|
+
* The retrieval context
|
|
1258
|
+
*
|
|
1259
|
+
* @param {URL} url
|
|
1260
|
+
* The module URL
|
|
1261
|
+
* @return {Awaitable<FileContent | null | undefined>}
|
|
1262
|
+
* The source code
|
|
1263
|
+
*/
|
|
1264
|
+
type GetSourceHandler = (this: GetSourceContext, url: URL) => Awaitable<FileContent | null | undefined>;
|
|
1265
|
+
|
|
1266
|
+
/**
|
|
1267
|
+
* @file Type Aliases - GetSourceHandlers
|
|
1268
|
+
* @module mlly/types/GetSourceHandlers
|
|
1269
|
+
*/
|
|
1270
|
+
|
|
1271
|
+
/**
|
|
1272
|
+
* Record, where key is a URL protocol and each value is a source code handler.
|
|
1273
|
+
*
|
|
1274
|
+
* @see {@linkcode GetSourceHandler}
|
|
1275
|
+
* @see {@linkcode Protocol}
|
|
1276
|
+
*/
|
|
1277
|
+
type GetSourceHandlers = {
|
|
1278
|
+
[H in Protocol]?: GetSourceHandler | null | undefined;
|
|
1279
|
+
};
|
|
1280
|
+
|
|
1281
|
+
/**
|
|
1282
|
+
* @file Type Aliases - List
|
|
1283
|
+
* @module mlly/types/List
|
|
1284
|
+
*/
|
|
1285
|
+
/**
|
|
1286
|
+
* A list.
|
|
1287
|
+
*
|
|
1288
|
+
* @template {any} [T=unknown]
|
|
1289
|
+
* The list item type
|
|
1290
|
+
*/
|
|
1291
|
+
type List<T = unknown> = ReadonlySet<T> | readonly T[];
|
|
1292
|
+
|
|
1293
|
+
/**
|
|
1294
|
+
* @file Type Aliases - MainField
|
|
1295
|
+
* @module mlly/types/MainField
|
|
1296
|
+
*/
|
|
1297
|
+
|
|
1298
|
+
/**
|
|
1299
|
+
* Union of values that can occur where a main field is expected.
|
|
1300
|
+
*
|
|
1301
|
+
* To register new fields, augment {@linkcode MainFieldMap}.
|
|
1302
|
+
* They will be added to this union automatically.
|
|
1303
|
+
*/
|
|
1304
|
+
type MainField = MainFieldMap[keyof MainFieldMap];
|
|
1305
|
+
|
|
1306
|
+
/**
|
|
1307
|
+
* @file Type Aliases - ModuleFormat
|
|
1308
|
+
* @module mlly/types/ModuleFormat
|
|
1309
|
+
*/
|
|
1310
|
+
|
|
1311
|
+
/**
|
|
1312
|
+
* Union of values that can occur where a module format is expected.
|
|
1313
|
+
*
|
|
1314
|
+
* To register new formats, augment {@linkcode ModuleFormatMap}.
|
|
1315
|
+
* They will be added to this union automatically.
|
|
1316
|
+
*/
|
|
1317
|
+
type ModuleFormat = ModuleFormatMap[keyof ModuleFormatMap];
|
|
1318
|
+
|
|
1319
|
+
/**
|
|
1320
|
+
* @file Type Aliases - ModuleId
|
|
1321
|
+
* @module mlly/types/ModuleId
|
|
1322
|
+
*/
|
|
1323
|
+
/**
|
|
1324
|
+
* Union of values that can occur where a
|
|
1325
|
+
* ECMAScript (ES) module identifier is expected.
|
|
1326
|
+
*
|
|
1327
|
+
* @see {@linkcode URL}
|
|
1328
|
+
*/
|
|
1329
|
+
type ModuleId = URL | string;
|
|
1330
|
+
|
|
1331
|
+
/**
|
|
1332
|
+
* @file Type Aliases - Numeric
|
|
1333
|
+
* @module mlly/types/Numeric
|
|
1334
|
+
*/
|
|
1335
|
+
/**
|
|
1336
|
+
* String containing only numbers (not including the leading `-` if negative).
|
|
1337
|
+
*/
|
|
1338
|
+
type Numeric = `${number}`;
|
|
1339
|
+
|
|
1340
|
+
/**
|
|
1341
|
+
* @file Type Aliases - PatternKeyComparison
|
|
1342
|
+
* @module mlly/types/PatternKeyComparison
|
|
1343
|
+
*/
|
|
1344
|
+
|
|
1345
|
+
/**
|
|
1346
|
+
* Union of values that can occur
|
|
1347
|
+
* where a `PATTERN_KEY_COMPARE` algorithm result is expected.
|
|
1348
|
+
*
|
|
1349
|
+
* To register new results, augment {@linkcode PatternKeyComparisonMap}.
|
|
1350
|
+
* They will be added to this union automatically.
|
|
1351
|
+
*/
|
|
1352
|
+
type PatternKeyComparison = PatternKeyComparisonMap[keyof PatternKeyComparisonMap];
|
|
1353
|
+
|
|
1354
|
+
/**
|
|
1355
|
+
* @file Type Aliases - PatternMatch
|
|
1356
|
+
* @module mlly/types/PatternMatch
|
|
1357
|
+
*/
|
|
1358
|
+
/**
|
|
1359
|
+
* List, where the first item is the key of a package `exports` or `imports`
|
|
1360
|
+
* target object, and the last is a subpath pattern match.
|
|
1361
|
+
*/
|
|
1362
|
+
type PatternMatch = [expansionKey: string, patternMatch: string | null];
|
|
1363
|
+
|
|
1364
|
+
/**
|
|
1365
|
+
* @file Type Aliases - Protocol
|
|
1366
|
+
* @module mlly/types/Protocol
|
|
1367
|
+
*/
|
|
1368
|
+
|
|
1369
|
+
/**
|
|
1370
|
+
* Union of values that can occur where a URL protocol is expected.
|
|
1371
|
+
*
|
|
1372
|
+
* To register new protocols, augment {@linkcode ProtocolMap}.
|
|
1373
|
+
* They will be added to this union automatically.
|
|
1374
|
+
*/
|
|
1375
|
+
type Protocol = ProtocolMap[keyof ProtocolMap];
|
|
1376
|
+
|
|
1377
|
+
/**
|
|
1378
|
+
* @file Interfaces - FileSystem
|
|
1379
|
+
* @module mlly/interfaces/FileSystem
|
|
1380
|
+
*/
|
|
1381
|
+
|
|
1382
|
+
/**
|
|
1383
|
+
* The file system API.
|
|
1384
|
+
*/
|
|
1385
|
+
interface FileSystem {
|
|
1386
|
+
/**
|
|
1387
|
+
* Read the entire contents of a file.
|
|
1388
|
+
*
|
|
1389
|
+
* @see {@linkcode ReadFile}
|
|
1390
|
+
*/
|
|
1391
|
+
readFile: ReadFile;
|
|
1392
|
+
/**
|
|
1393
|
+
* Compute a canonical pathname by resolving `.`, `..`, and symbolic links.
|
|
1394
|
+
*
|
|
1395
|
+
* @see {@linkcode Realpath}
|
|
1396
|
+
*/
|
|
1397
|
+
realpath: Realpath;
|
|
1398
|
+
/**
|
|
1399
|
+
* Get information about a directory or file.
|
|
1400
|
+
*
|
|
1401
|
+
* @see {@linkcode Stat}
|
|
1402
|
+
*/
|
|
1403
|
+
stat: Stat;
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
/**
|
|
1407
|
+
* @file Interfaces - GetSourceContext
|
|
1408
|
+
* @module mlly/interfaces/GetSourceContext
|
|
1409
|
+
*/
|
|
1410
|
+
|
|
1411
|
+
/**
|
|
1412
|
+
* Source code retrieval context.
|
|
1413
|
+
*
|
|
1414
|
+
* @see {@linkcode GetSourceOptions}
|
|
1415
|
+
*
|
|
1416
|
+
* @extends {GetSourceOptions}
|
|
1417
|
+
*/
|
|
1418
|
+
interface GetSourceContext extends GetSourceOptions {
|
|
1419
|
+
/**
|
|
1420
|
+
* The file system API.
|
|
1421
|
+
*
|
|
1422
|
+
* @see {@linkcode FileSystem}
|
|
1423
|
+
*
|
|
1424
|
+
* @override
|
|
1425
|
+
*/
|
|
1426
|
+
fs: FileSystem;
|
|
1427
|
+
/**
|
|
1428
|
+
* Record, where each key is a URL protocol
|
|
1429
|
+
* and each value is a source code handler.
|
|
1430
|
+
*
|
|
1431
|
+
* @see {@linkcode GetSourceHandlers}
|
|
1432
|
+
*
|
|
1433
|
+
* @override
|
|
1434
|
+
*/
|
|
1435
|
+
handlers: GetSourceHandlers;
|
|
1436
|
+
/**
|
|
1437
|
+
* Request options for network based modules.
|
|
1438
|
+
*
|
|
1439
|
+
* @override
|
|
1440
|
+
*/
|
|
1441
|
+
req: RequestInit;
|
|
1442
|
+
/**
|
|
1443
|
+
* The list of supported URL schemes.
|
|
1444
|
+
*
|
|
1445
|
+
* @override
|
|
1446
|
+
*/
|
|
1447
|
+
schemes: Set<string>;
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
/**
|
|
1451
|
+
* @file Interfaces - GetSourceOptions
|
|
1452
|
+
* @module mlly/interfaces/GetSourceOptions
|
|
1453
|
+
*/
|
|
1454
|
+
|
|
1455
|
+
/**
|
|
1456
|
+
* Options for retrieving source code.
|
|
1457
|
+
*/
|
|
1458
|
+
interface GetSourceOptions {
|
|
1459
|
+
/**
|
|
1460
|
+
* The encoding of the result.
|
|
1461
|
+
*
|
|
1462
|
+
* > 👉 **Note**: Used when the `file:` handler is called.
|
|
1463
|
+
*
|
|
1464
|
+
* @see {@linkcode BufferEncoding}
|
|
1465
|
+
*/
|
|
1466
|
+
encoding?: BufferEncoding | null | undefined;
|
|
1467
|
+
/**
|
|
1468
|
+
* The module format hint.
|
|
1469
|
+
*
|
|
1470
|
+
* @see {@linkcode ModuleFormat}
|
|
1471
|
+
*/
|
|
1472
|
+
format?: ModuleFormat | null | undefined;
|
|
1473
|
+
/**
|
|
1474
|
+
* The file system API.
|
|
1475
|
+
*
|
|
1476
|
+
* @see {@linkcode FileSystem}
|
|
1477
|
+
*/
|
|
1478
|
+
fs?: FileSystem | null | undefined;
|
|
1479
|
+
/**
|
|
1480
|
+
* Record, where each key is a URL protocol
|
|
1481
|
+
* and each value is a source code handler.
|
|
1482
|
+
*
|
|
1483
|
+
* @see {@linkcode GetSourceHandlers}
|
|
1484
|
+
*/
|
|
1485
|
+
handlers?: GetSourceHandlers | null | undefined;
|
|
1486
|
+
/**
|
|
1487
|
+
* Whether to ignore [`ERR_UNSUPPORTED_ESM_URL_SCHEME`][err] if thrown.
|
|
1488
|
+
*
|
|
1489
|
+
* [err]: https://nodejs.org/api/errors.html#err_unsupported_esm_url_scheme
|
|
1490
|
+
*/
|
|
1491
|
+
ignoreErrors?: boolean | null | undefined;
|
|
1492
|
+
/**
|
|
1493
|
+
* Request options for network based modules.
|
|
1494
|
+
*/
|
|
1495
|
+
req?: RequestInit | null | undefined;
|
|
1496
|
+
/**
|
|
1497
|
+
* The list of supported URL schemes.
|
|
1498
|
+
*
|
|
1499
|
+
* @see {@linkcode List}
|
|
1500
|
+
*
|
|
1501
|
+
* @default ['data','file','http','https','node']
|
|
1502
|
+
*/
|
|
1503
|
+
schemes?: List<string> | null | undefined;
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
/**
|
|
1507
|
+
* @file Interfaces - IsDirectory
|
|
1508
|
+
* @module mlly/interfaces/IsDirectory
|
|
1509
|
+
*/
|
|
1510
|
+
/**
|
|
1511
|
+
* Check if a stats object describes a directory.
|
|
1512
|
+
*/
|
|
1513
|
+
interface IsDirectory {
|
|
1514
|
+
/**
|
|
1515
|
+
* @this {unknown}
|
|
1516
|
+
*
|
|
1517
|
+
* @return {boolean}
|
|
1518
|
+
* `true` if stats describes directory, `false` otherwise
|
|
1519
|
+
*/
|
|
1520
|
+
(): boolean;
|
|
1521
|
+
}
|
|
1522
|
+
|
|
1523
|
+
/**
|
|
1524
|
+
* @file Interfaces - IsFile
|
|
1525
|
+
* @module mlly/interfaces/IsFile
|
|
1526
|
+
*/
|
|
1527
|
+
/**
|
|
1528
|
+
* Check if a stats object describes a file.
|
|
1529
|
+
*/
|
|
1530
|
+
interface IsFile {
|
|
1531
|
+
/**
|
|
1532
|
+
* @this {void}
|
|
1533
|
+
*
|
|
1534
|
+
* @return {boolean}
|
|
1535
|
+
* `true` if stats object describes regular file, `false` otherwise
|
|
1536
|
+
*/
|
|
1537
|
+
(): boolean;
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1540
|
+
/**
|
|
1541
|
+
* @file Interfaces - MainFieldMap
|
|
1542
|
+
* @module mlly/interfaces/MainFieldMap
|
|
1543
|
+
*/
|
|
1544
|
+
/**
|
|
1545
|
+
* Registry of main fields.
|
|
1546
|
+
*
|
|
1547
|
+
* This interface can be augmented to register custom main fields.
|
|
1548
|
+
*
|
|
1549
|
+
* @example
|
|
1550
|
+
* declare module '@flex-development/mlly' {
|
|
1551
|
+
* interface MainFieldMap {
|
|
1552
|
+
* unpkg: 'unpkg'
|
|
1553
|
+
* }
|
|
1554
|
+
* }
|
|
1555
|
+
*/
|
|
1556
|
+
interface MainFieldMap {
|
|
1557
|
+
main: 'main';
|
|
1558
|
+
module: 'module';
|
|
1559
|
+
types: 'types';
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1562
|
+
/**
|
|
1563
|
+
* @file Interfaces - ModuleFormatMap
|
|
1564
|
+
* @module mlly/interfaces/ModuleFormatMap
|
|
1565
|
+
*/
|
|
1566
|
+
/**
|
|
1567
|
+
* Registry of module formats.
|
|
1568
|
+
*
|
|
1569
|
+
* This interface can be augmented to register custom module formats.
|
|
1570
|
+
*
|
|
1571
|
+
* @example
|
|
1572
|
+
* declare module '@flex-development/mlly' {
|
|
1573
|
+
* interface ModuleFormatMap {
|
|
1574
|
+
* custom: 'custom'
|
|
1575
|
+
* }
|
|
1576
|
+
* }
|
|
1577
|
+
*/
|
|
1578
|
+
interface ModuleFormatMap {
|
|
1579
|
+
builtin: 'builtin';
|
|
1580
|
+
commonjs: 'commonjs';
|
|
1581
|
+
cts: 'commonjs-typescript';
|
|
1582
|
+
json: 'json';
|
|
1583
|
+
module: 'module';
|
|
1584
|
+
mts: 'module-typescript';
|
|
1585
|
+
wasm: 'wasm';
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1588
|
+
/**
|
|
1589
|
+
* @file Interfaces - PatternKeyComparisonMap
|
|
1590
|
+
* @module mlly/interfaces/PatternKeyComparisonMap
|
|
1591
|
+
*/
|
|
1592
|
+
/**
|
|
1593
|
+
* Registry of `PATTERN_KEY_COMPARE` algorithm results.
|
|
1594
|
+
*
|
|
1595
|
+
* This interface can be augmented to register custom results.
|
|
1596
|
+
*
|
|
1597
|
+
* @example
|
|
1598
|
+
* declare module '@flex-development/mlly' {
|
|
1599
|
+
* interface PatternKeyComparisonMap {
|
|
1600
|
+
* afterThree: 3
|
|
1601
|
+
* }
|
|
1602
|
+
* }
|
|
1603
|
+
*/
|
|
1604
|
+
interface PatternKeyComparisonMap {
|
|
1605
|
+
/**
|
|
1606
|
+
* `a` should come after `b`.
|
|
1607
|
+
*/
|
|
1608
|
+
after: 1;
|
|
1609
|
+
/**
|
|
1610
|
+
* `a` should come before `b`.
|
|
1611
|
+
*/
|
|
1612
|
+
before: -1;
|
|
1613
|
+
/**
|
|
1614
|
+
* `a` and `b` are equal.
|
|
1615
|
+
*/
|
|
1616
|
+
equal: 0;
|
|
1617
|
+
}
|
|
1618
|
+
|
|
1619
|
+
/**
|
|
1620
|
+
* @file Interfaces - ProtocolMap
|
|
1621
|
+
* @module mlly/interfaces/ProtocolMap
|
|
1622
|
+
*/
|
|
1623
|
+
/**
|
|
1624
|
+
* Registry of URL protocols.
|
|
1625
|
+
*
|
|
1626
|
+
* This interface can be augmented to register custom protocols.
|
|
1627
|
+
*
|
|
1628
|
+
* @see https://nodejs.org/api/url.html#urlprotocol
|
|
1629
|
+
* @see https://iana.org/assignments/uri-schemes/uri-schemes.xhtml
|
|
1630
|
+
* @see https://url.spec.whatwg.org/#special-scheme
|
|
1631
|
+
*
|
|
1632
|
+
* @example
|
|
1633
|
+
* declare module '@flex-development/mlly' {
|
|
1634
|
+
* interface ProtocolMap {
|
|
1635
|
+
* custom: 'custom:'
|
|
1636
|
+
* }
|
|
1637
|
+
* }
|
|
1638
|
+
*/
|
|
1639
|
+
interface ProtocolMap {
|
|
1640
|
+
blob: 'blob:';
|
|
1641
|
+
content: 'content:';
|
|
1642
|
+
cvs: 'cvs:';
|
|
1643
|
+
data: 'data:';
|
|
1644
|
+
dns: 'dns:';
|
|
1645
|
+
file: 'file:';
|
|
1646
|
+
fish: 'fish:';
|
|
1647
|
+
ftp: 'ftp:';
|
|
1648
|
+
git: 'git:';
|
|
1649
|
+
http: 'http:';
|
|
1650
|
+
https: 'https:';
|
|
1651
|
+
mvn: 'mvn:';
|
|
1652
|
+
node: 'node:';
|
|
1653
|
+
redis: 'redis:';
|
|
1654
|
+
sftp: 'sftp:';
|
|
1655
|
+
ssh: 'ssh:';
|
|
1656
|
+
svn: 'svn:';
|
|
1657
|
+
urn: 'urn:';
|
|
1658
|
+
viewSource: 'view-source:';
|
|
1659
|
+
ws: 'ws:';
|
|
1660
|
+
wss: 'wss:';
|
|
1661
|
+
}
|
|
1662
|
+
|
|
1663
|
+
/**
|
|
1664
|
+
* @file Interfaces - ReadFile
|
|
1665
|
+
* @module mlly/interfaces/ReadFile
|
|
1666
|
+
*/
|
|
1667
|
+
|
|
1668
|
+
/**
|
|
1669
|
+
* Read the entire contents of a file.
|
|
1670
|
+
*/
|
|
1671
|
+
interface ReadFile {
|
|
1672
|
+
/**
|
|
1673
|
+
* @see {@linkcode ModuleId}
|
|
1674
|
+
*
|
|
1675
|
+
* @this {unknown}
|
|
1676
|
+
*
|
|
1677
|
+
* @param {ModuleId} id
|
|
1678
|
+
* The module id
|
|
1679
|
+
* @param {BufferEncoding} encoding
|
|
1680
|
+
* The encoding of the file contents
|
|
1681
|
+
* @return {Awaitable<string>}
|
|
1682
|
+
* The file contents
|
|
1683
|
+
*/
|
|
1684
|
+
(id: ModuleId, encoding: BufferEncoding): Awaitable<string>;
|
|
1685
|
+
/**
|
|
1686
|
+
* @see {@linkcode Awaitable}
|
|
1687
|
+
* @see {@linkcode FileContent}
|
|
1688
|
+
* @see {@linkcode ModuleId}
|
|
1689
|
+
*
|
|
1690
|
+
* @template {Awaitable<FileContent | null | undefined>} T
|
|
1691
|
+
* The file contents
|
|
1692
|
+
*
|
|
1693
|
+
* @this {unknown}
|
|
1694
|
+
*
|
|
1695
|
+
* @param {ModuleId} id
|
|
1696
|
+
* The module id
|
|
1697
|
+
* @param {BufferEncoding | null | undefined} [encoding]
|
|
1698
|
+
* The encoding of the file contents
|
|
1699
|
+
* @return {T}
|
|
1700
|
+
* The file contents
|
|
1701
|
+
*/
|
|
1702
|
+
<T extends Awaitable<FileContent | null | undefined>>(id: ModuleId, encoding?: BufferEncoding | null | undefined): T;
|
|
1703
|
+
}
|
|
1704
|
+
|
|
1705
|
+
/**
|
|
1706
|
+
* @file Interfaces - Realpath
|
|
1707
|
+
* @module mlly/interfaces/Realpath
|
|
1708
|
+
*/
|
|
1709
|
+
|
|
1710
|
+
/**
|
|
1711
|
+
* Compute a canonical pathname by resolving `.`, `..`, and symbolic links.
|
|
1712
|
+
*
|
|
1713
|
+
* > 👉 **Note**: A canonical pathname is not necessarily unique.
|
|
1714
|
+
* > Hard links and bind mounts can expose an entity through many pathnames.
|
|
1715
|
+
*/
|
|
1716
|
+
interface Realpath {
|
|
1717
|
+
/**
|
|
1718
|
+
* @see {@linkcode Awaitable}
|
|
1719
|
+
* @see {@linkcode ModuleId}
|
|
1720
|
+
*
|
|
1721
|
+
* @template {Awaitable<string>} T
|
|
1722
|
+
* The canonical pathname
|
|
1723
|
+
*
|
|
1724
|
+
* @this {unknown}
|
|
1725
|
+
*
|
|
1726
|
+
* @param {ModuleId} id
|
|
1727
|
+
* The module id
|
|
1728
|
+
* @return {T}
|
|
1729
|
+
* The canonical pathname
|
|
1730
|
+
*/
|
|
1731
|
+
<T extends Awaitable<string>>(id: ModuleId): T;
|
|
1732
|
+
}
|
|
1733
|
+
|
|
1734
|
+
/**
|
|
1735
|
+
* @file Interfaces - ResolveAliasOptions
|
|
1736
|
+
* @module mlly/interfaces/ResolveAliasOptions
|
|
1737
|
+
*/
|
|
1738
|
+
|
|
1739
|
+
/**
|
|
1740
|
+
* Options for path alias resolution.
|
|
1741
|
+
*/
|
|
1742
|
+
interface ResolveAliasOptions {
|
|
1743
|
+
/**
|
|
1744
|
+
* Whether the resolved specifier should be absolute.
|
|
1745
|
+
*
|
|
1746
|
+
* If `true`, the resolved specifier will be a [`file:` URL][file-url].
|
|
1747
|
+
*
|
|
1748
|
+
* [file-url]: https://nodejs.org/api/esm.html#file-urls
|
|
1749
|
+
*
|
|
1750
|
+
* @see https://nodejs.org/api/esm.html#terminology
|
|
1751
|
+
*/
|
|
1752
|
+
absolute?: boolean | null | undefined;
|
|
1753
|
+
/**
|
|
1754
|
+
* The path mappings dictionary.
|
|
1755
|
+
*
|
|
1756
|
+
* > 👉 **Note**: Paths should be relative to {@linkcode cwd}.
|
|
1757
|
+
*
|
|
1758
|
+
* @see {@linkcode Aliases}
|
|
1759
|
+
*/
|
|
1760
|
+
aliases?: Aliases | null | undefined;
|
|
1761
|
+
/**
|
|
1762
|
+
* The URL of the directory to resolve non-absolute modules from.
|
|
1763
|
+
*
|
|
1764
|
+
* @see {@linkcode ModuleId}
|
|
1765
|
+
*
|
|
1766
|
+
* @default cwd()
|
|
1767
|
+
*/
|
|
1768
|
+
cwd?: ModuleId | null | undefined;
|
|
1769
|
+
/**
|
|
1770
|
+
* The URL of the parent module.
|
|
1771
|
+
*
|
|
1772
|
+
* @see {@linkcode ModuleId}
|
|
1773
|
+
*/
|
|
1774
|
+
parent?: ModuleId | null | undefined;
|
|
1775
|
+
}
|
|
1776
|
+
|
|
1777
|
+
/**
|
|
1778
|
+
* @file Interfaces - ResolveModuleOptions
|
|
1779
|
+
* @module mlly/interfaces/ResolveModuleOptions
|
|
1780
|
+
*/
|
|
1781
|
+
|
|
1782
|
+
/**
|
|
1783
|
+
* Options for module resolution.
|
|
1784
|
+
*/
|
|
1785
|
+
interface ResolveModuleOptions {
|
|
1786
|
+
/**
|
|
1787
|
+
* The path mappings dictionary.
|
|
1788
|
+
*
|
|
1789
|
+
* > 👉 **Note**: Paths should be relative to {@linkcode cwd}.
|
|
1790
|
+
*
|
|
1791
|
+
* @see {@linkcode Aliases}
|
|
1792
|
+
*/
|
|
1793
|
+
aliases?: Aliases | null | undefined;
|
|
1794
|
+
/**
|
|
1795
|
+
* The list of export/import conditions.
|
|
1796
|
+
*
|
|
1797
|
+
* > 👉 **Note**: Should be sorted by priority.
|
|
1798
|
+
*
|
|
1799
|
+
* @see {@linkcode Condition}
|
|
1800
|
+
* @see {@linkcode List}
|
|
1801
|
+
* @see https://nodejs.org/api/packages.html#conditional-exports
|
|
1802
|
+
*
|
|
1803
|
+
* @default defaultConditions
|
|
1804
|
+
*/
|
|
1805
|
+
conditions?: List<Condition> | null | undefined;
|
|
1806
|
+
/**
|
|
1807
|
+
* The URL of the directory to resolve path {@linkcode aliases} from.
|
|
1808
|
+
*
|
|
1809
|
+
* @see {@linkcode ModuleId}
|
|
1810
|
+
*
|
|
1811
|
+
* @default cwd()
|
|
1812
|
+
*/
|
|
1813
|
+
cwd?: ModuleId | null | undefined;
|
|
1814
|
+
/**
|
|
1815
|
+
* A replacement file extension, a record of replacement file extensions,
|
|
1816
|
+
* or a function that returns a replacement file extension.
|
|
1817
|
+
*
|
|
1818
|
+
* > 👉 **Note**: Replacement file extensions are normalized and do not
|
|
1819
|
+
* > need to begin with a dot character (`'.'`); an empty string (`''`),
|
|
1820
|
+
* > `false`, or `null` will remove an extension.
|
|
1821
|
+
*
|
|
1822
|
+
* @see {@linkcode ExtensionRewrites}
|
|
1823
|
+
* @see {@linkcode GetNewExtension}
|
|
1824
|
+
*/
|
|
1825
|
+
ext?: ExtensionRewrites | GetNewExtension | string | false | null | undefined;
|
|
1826
|
+
/**
|
|
1827
|
+
* The module extensions to probe for.
|
|
1828
|
+
*
|
|
1829
|
+
* > 👉 **Note**: Should be sorted by priority.
|
|
1830
|
+
*
|
|
1831
|
+
* @see {@linkcode List}
|
|
1832
|
+
*
|
|
1833
|
+
* @default defaultExtensions
|
|
1834
|
+
*/
|
|
1835
|
+
extensions?: List<string> | null | undefined;
|
|
1836
|
+
/**
|
|
1837
|
+
* The file system API.
|
|
1838
|
+
*
|
|
1839
|
+
* @see {@linkcode FileSystem}
|
|
1840
|
+
*/
|
|
1841
|
+
fs?: FileSystem | null | undefined;
|
|
1842
|
+
/**
|
|
1843
|
+
* The list of legacy `main` fields.
|
|
1844
|
+
*
|
|
1845
|
+
* > 👉 **Note**: Should be sorted by priority.
|
|
1846
|
+
*
|
|
1847
|
+
* @see {@linkcode List}
|
|
1848
|
+
* @see {@linkcode MainField}
|
|
1849
|
+
*
|
|
1850
|
+
* @default defaultMainFields
|
|
1851
|
+
*/
|
|
1852
|
+
mainFields?: List<MainField> | null | undefined;
|
|
1853
|
+
/**
|
|
1854
|
+
* Whether to keep symlinks instead of resolving them.
|
|
1855
|
+
*/
|
|
1856
|
+
preserveSymlinks?: boolean | null | undefined;
|
|
1857
|
+
}
|
|
1858
|
+
|
|
1859
|
+
/**
|
|
1860
|
+
* @file Interfaces - Stat
|
|
1861
|
+
* @module mlly/interfaces/Stat
|
|
1862
|
+
*/
|
|
1863
|
+
|
|
1864
|
+
/**
|
|
1865
|
+
* Get information about a directory or file.
|
|
1866
|
+
*/
|
|
1867
|
+
interface Stat {
|
|
1868
|
+
/**
|
|
1869
|
+
* @see {@linkcode Awaitable}
|
|
1870
|
+
* @see {@linkcode ModuleId}
|
|
1871
|
+
* @see {@linkcode Stats}
|
|
1872
|
+
*
|
|
1873
|
+
* @template {Awaitable<Stats>} T
|
|
1874
|
+
* The info
|
|
1875
|
+
*
|
|
1876
|
+
* @this {unknown}
|
|
1877
|
+
*
|
|
1878
|
+
* @param {ModuleId} id
|
|
1879
|
+
* The module id
|
|
1880
|
+
* @return {T}
|
|
1881
|
+
* The info
|
|
1882
|
+
*/
|
|
1883
|
+
<T extends Awaitable<Stats>>(id: ModuleId): T;
|
|
1884
|
+
}
|
|
1885
|
+
|
|
1886
|
+
/**
|
|
1887
|
+
* @file Interfaces - Stats
|
|
1888
|
+
* @module mlly/interfaces/Stats
|
|
1889
|
+
*/
|
|
1890
|
+
|
|
1891
|
+
/**
|
|
1892
|
+
* An object describing a directory or file.
|
|
1893
|
+
*/
|
|
1894
|
+
interface Stats {
|
|
1895
|
+
/**
|
|
1896
|
+
* Check if the stats object describes a directory.
|
|
1897
|
+
*
|
|
1898
|
+
* @see {@linkcode IsDirectory}
|
|
1899
|
+
*/
|
|
1900
|
+
isDirectory: IsDirectory;
|
|
1901
|
+
/**
|
|
1902
|
+
* Check if the stats object describes a file.
|
|
1903
|
+
*
|
|
1904
|
+
* @see {@linkcode IsFile}
|
|
1905
|
+
*/
|
|
1906
|
+
isFile: IsFile;
|
|
1907
|
+
}
|
|
1908
|
+
|
|
1909
|
+
export { canParseUrl, cwd, defaultConditions, defaultExtensions, defaultMainFields, extensionFormatMap, formats, getSource, isAbsoluteSpecifier, isArrayIndex, isBareSpecifier, isDirectory, isFile, isImportsSubpath, isModuleId, isRelativeSpecifier, legacyMainResolve, lookupPackageScope, moduleResolve, packageExportsResolve, packageImportsExportsResolve, packageImportsResolve, packageResolve, packageSelfResolve, packageTargetResolve, patternKeyCompare, patternMatch, readPackageJson, resolveAlias, resolveModule, resolver_d as resolver, root, toRelativeSpecifier, toUrl };
|
|
1910
|
+
export type { Aliases, Awaitable, BufferEncoding, BufferEncodingMap, Condition, ConditionMap, Dot, EmptyArray, EmptyObject, EmptyString, Ext, ExtensionRewrites, FileContent, FileSystem, GetNewExtension, GetSourceContext, GetSourceHandler, GetSourceHandlers, GetSourceOptions, IsDirectory, IsFile, List, MainField, MainFieldMap, ModuleFormat, ModuleFormatMap, ModuleId, Numeric, PatternKeyComparison, PatternKeyComparisonMap, PatternMatch, Protocol, ProtocolMap, ReadFile, Realpath, ResolveAliasOptions, ResolveModuleOptions, Stat, Stats };
|