@flex-development/mlly 1.0.0-beta.6 → 1.0.0-beta.7
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 +16 -0
- package/README.md +1 -1
- package/dist/index.d.mts +831 -831
- package/dist/lib/get-source.mjs +1 -1
- package/dist/lib/is-directory.mjs +1 -1
- package/dist/lib/is-file.mjs +1 -1
- package/dist/lib/lookup-package-scope.mjs +1 -1
- package/dist/lib/read-package-json.mjs +1 -1
- package/dist/lib/resolve-module.mjs +1 -1
- package/dist/lib/resolver.mjs +1 -1
- package/package.json +7 -3
- package/dist/internal/chain-or-call.d.mts +0 -51
- package/dist/internal/chain-or-call.mjs +0 -1
- package/dist/internal/chars.d.mts +0 -16
- package/dist/internal/check-invalid-segments.d.mts +0 -18
- package/dist/internal/constant.d.mts +0 -21
- package/dist/internal/fs.browser.d.mts +0 -12
- package/dist/internal/fs.node.d.mts +0 -12
- package/dist/internal/identity.d.mts +0 -21
- package/dist/internal/invalid-package-target.d.mts +0 -31
- package/dist/internal/invalid-subpath.d.mts +0 -32
- package/dist/internal/is-promise.d.mts +0 -21
- package/dist/internal/is-promise.mjs +0 -1
- package/dist/internal/process.browser.d.mts +0 -9
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as pkgTypes from '@flex-development/pkg-types';
|
|
2
|
-
import { ImportsSubpath, PackageJson, Exports, ExportsObject, Imports } from '@flex-development/pkg-types';
|
|
1
|
+
import type * as pkgTypes from '@flex-development/pkg-types';
|
|
2
|
+
import type { ImportsSubpath, PackageJson, Exports, ExportsObject, Imports } from '@flex-development/pkg-types';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @file Interfaces - Aliases
|
|
@@ -76,137 +76,669 @@ interface ConditionMap extends pkgTypes.ConditionMap {
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
|
-
* @file
|
|
80
|
-
* @module mlly/
|
|
79
|
+
* @file Interfaces - FileSystem
|
|
80
|
+
* @module mlly/interfaces/FileSystem
|
|
81
81
|
*/
|
|
82
|
+
|
|
82
83
|
/**
|
|
83
|
-
*
|
|
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
|
|
84
|
+
* The file system API.
|
|
98
85
|
*/
|
|
99
|
-
|
|
86
|
+
interface FileSystem {
|
|
87
|
+
/**
|
|
88
|
+
* Read the entire contents of a file.
|
|
89
|
+
*
|
|
90
|
+
* @see {@linkcode ReadFile}
|
|
91
|
+
*/
|
|
92
|
+
readFile: ReadFile;
|
|
93
|
+
/**
|
|
94
|
+
* Compute a canonical pathname by resolving `.`, `..`, and symbolic links.
|
|
95
|
+
*
|
|
96
|
+
* @see {@linkcode Realpath}
|
|
97
|
+
*/
|
|
98
|
+
realpath: Realpath;
|
|
99
|
+
/**
|
|
100
|
+
* Get information about a directory or file.
|
|
101
|
+
*
|
|
102
|
+
* @see {@linkcode Stat}
|
|
103
|
+
*/
|
|
104
|
+
stat: Stat;
|
|
105
|
+
}
|
|
100
106
|
|
|
101
107
|
/**
|
|
102
|
-
* @file
|
|
103
|
-
* @module mlly/
|
|
108
|
+
* @file Interfaces - GetSourceContext
|
|
109
|
+
* @module mlly/interfaces/GetSourceContext
|
|
104
110
|
*/
|
|
111
|
+
|
|
105
112
|
/**
|
|
106
|
-
*
|
|
113
|
+
* Source code retrieval context.
|
|
107
114
|
*
|
|
108
|
-
* @
|
|
115
|
+
* @see {@linkcode GetSourceOptions}
|
|
109
116
|
*
|
|
110
|
-
* @
|
|
111
|
-
* The current working directory URL
|
|
117
|
+
* @extends {GetSourceOptions}
|
|
112
118
|
*/
|
|
113
|
-
|
|
119
|
+
interface GetSourceContext extends GetSourceOptions {
|
|
120
|
+
/**
|
|
121
|
+
* The file system API.
|
|
122
|
+
*
|
|
123
|
+
* @see {@linkcode FileSystem}
|
|
124
|
+
*
|
|
125
|
+
* @override
|
|
126
|
+
*/
|
|
127
|
+
fs: FileSystem;
|
|
128
|
+
/**
|
|
129
|
+
* Record, where each key is a URL protocol
|
|
130
|
+
* and each value is a source code handler.
|
|
131
|
+
*
|
|
132
|
+
* @see {@linkcode GetSourceHandlers}
|
|
133
|
+
*
|
|
134
|
+
* @override
|
|
135
|
+
*/
|
|
136
|
+
handlers: GetSourceHandlers;
|
|
137
|
+
/**
|
|
138
|
+
* Request options for network based modules.
|
|
139
|
+
*
|
|
140
|
+
* @override
|
|
141
|
+
*/
|
|
142
|
+
req: RequestInit;
|
|
143
|
+
/**
|
|
144
|
+
* The list of supported URL schemes.
|
|
145
|
+
*
|
|
146
|
+
* @override
|
|
147
|
+
*/
|
|
148
|
+
schemes: Set<string>;
|
|
149
|
+
}
|
|
114
150
|
|
|
115
151
|
/**
|
|
116
|
-
* @file
|
|
117
|
-
* @module mlly/
|
|
152
|
+
* @file Interfaces - GetSourceOptions
|
|
153
|
+
* @module mlly/interfaces/GetSourceOptions
|
|
118
154
|
*/
|
|
119
155
|
|
|
120
156
|
/**
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
* @see {@linkcode Condition}
|
|
124
|
-
* @see https://nodejs.org/api/packages.html#conditional-exports
|
|
125
|
-
*
|
|
126
|
-
* @const {Set<Condition>} defaultConditions
|
|
157
|
+
* Options for retrieving source code.
|
|
127
158
|
*/
|
|
128
|
-
|
|
159
|
+
interface GetSourceOptions {
|
|
160
|
+
/**
|
|
161
|
+
* The encoding of the result.
|
|
162
|
+
*
|
|
163
|
+
* > 👉 **Note**: Used when the `file:` handler is called.
|
|
164
|
+
*
|
|
165
|
+
* @see {@linkcode BufferEncoding}
|
|
166
|
+
*/
|
|
167
|
+
encoding?: BufferEncoding | null | undefined;
|
|
168
|
+
/**
|
|
169
|
+
* The module format hint.
|
|
170
|
+
*
|
|
171
|
+
* @see {@linkcode ModuleFormat}
|
|
172
|
+
*/
|
|
173
|
+
format?: ModuleFormat | null | undefined;
|
|
174
|
+
/**
|
|
175
|
+
* The file system API.
|
|
176
|
+
*
|
|
177
|
+
* @see {@linkcode FileSystem}
|
|
178
|
+
*/
|
|
179
|
+
fs?: FileSystem | null | undefined;
|
|
180
|
+
/**
|
|
181
|
+
* Record, where each key is a URL protocol
|
|
182
|
+
* and each value is a source code handler.
|
|
183
|
+
*
|
|
184
|
+
* @see {@linkcode GetSourceHandlers}
|
|
185
|
+
*/
|
|
186
|
+
handlers?: GetSourceHandlers | null | undefined;
|
|
187
|
+
/**
|
|
188
|
+
* Whether to ignore [`ERR_UNSUPPORTED_ESM_URL_SCHEME`][err] if thrown.
|
|
189
|
+
*
|
|
190
|
+
* [err]: https://nodejs.org/api/errors.html#err_unsupported_esm_url_scheme
|
|
191
|
+
*/
|
|
192
|
+
ignoreErrors?: boolean | null | undefined;
|
|
193
|
+
/**
|
|
194
|
+
* Request options for network based modules.
|
|
195
|
+
*/
|
|
196
|
+
req?: RequestInit | null | undefined;
|
|
197
|
+
/**
|
|
198
|
+
* The list of supported URL schemes.
|
|
199
|
+
*
|
|
200
|
+
* @see {@linkcode List}
|
|
201
|
+
*
|
|
202
|
+
* @default ['data','file','http','https','node']
|
|
203
|
+
*/
|
|
204
|
+
schemes?: List<string> | null | undefined;
|
|
205
|
+
}
|
|
129
206
|
|
|
130
207
|
/**
|
|
131
|
-
* @file
|
|
132
|
-
* @module mlly/
|
|
208
|
+
* @file Interfaces - IsDirectory
|
|
209
|
+
* @module mlly/interfaces/IsDirectory
|
|
133
210
|
*/
|
|
134
|
-
|
|
135
211
|
/**
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
* @see {@linkcode Ext}
|
|
139
|
-
*
|
|
140
|
-
* @const {Set<Ext>} defaultExtensions
|
|
212
|
+
* Check if a stats object describes a directory.
|
|
141
213
|
*/
|
|
142
|
-
|
|
214
|
+
interface IsDirectory {
|
|
215
|
+
/**
|
|
216
|
+
* @this {unknown}
|
|
217
|
+
*
|
|
218
|
+
* @return {boolean}
|
|
219
|
+
* `true` if stats describes directory, `false` otherwise
|
|
220
|
+
*/
|
|
221
|
+
(): boolean;
|
|
222
|
+
}
|
|
143
223
|
|
|
144
224
|
/**
|
|
145
|
-
* @file
|
|
146
|
-
* @module mlly/
|
|
225
|
+
* @file Interfaces - IsFile
|
|
226
|
+
* @module mlly/interfaces/IsFile
|
|
147
227
|
*/
|
|
148
|
-
|
|
149
228
|
/**
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
* @see {@linkcode MainField}
|
|
153
|
-
*
|
|
154
|
-
* @const {Set<MainField>} defaultMainFields
|
|
229
|
+
* Check if a stats object describes a file.
|
|
155
230
|
*/
|
|
156
|
-
|
|
231
|
+
interface IsFile {
|
|
232
|
+
/**
|
|
233
|
+
* @this {void}
|
|
234
|
+
*
|
|
235
|
+
* @return {boolean}
|
|
236
|
+
* `true` if stats object describes regular file, `false` otherwise
|
|
237
|
+
*/
|
|
238
|
+
(): boolean;
|
|
239
|
+
}
|
|
157
240
|
|
|
158
241
|
/**
|
|
159
|
-
* @file
|
|
160
|
-
* @module mlly/
|
|
242
|
+
* @file Interfaces - MainFieldMap
|
|
243
|
+
* @module mlly/interfaces/MainFieldMap
|
|
161
244
|
*/
|
|
162
|
-
|
|
163
245
|
/**
|
|
164
|
-
*
|
|
165
|
-
* and each value is a default module format.
|
|
246
|
+
* Registry of main fields.
|
|
166
247
|
*
|
|
167
|
-
*
|
|
168
|
-
* @see {@linkcode ModuleFormat}
|
|
248
|
+
* This interface can be augmented to register custom main fields.
|
|
169
249
|
*
|
|
170
|
-
* @
|
|
250
|
+
* @example
|
|
251
|
+
* declare module '@flex-development/mlly' {
|
|
252
|
+
* interface MainFieldMap {
|
|
253
|
+
* unpkg: 'unpkg'
|
|
254
|
+
* }
|
|
255
|
+
* }
|
|
171
256
|
*/
|
|
172
|
-
|
|
257
|
+
interface MainFieldMap {
|
|
258
|
+
main: 'main';
|
|
259
|
+
module: 'module';
|
|
260
|
+
types: 'types';
|
|
261
|
+
}
|
|
173
262
|
|
|
174
263
|
/**
|
|
175
|
-
* @file
|
|
176
|
-
* @module mlly/
|
|
264
|
+
* @file Interfaces - ModuleFormatMap
|
|
265
|
+
* @module mlly/interfaces/ModuleFormatMap
|
|
177
266
|
*/
|
|
178
267
|
/**
|
|
179
|
-
*
|
|
268
|
+
* Registry of module formats.
|
|
180
269
|
*
|
|
181
|
-
*
|
|
270
|
+
* This interface can be augmented to register custom module formats.
|
|
182
271
|
*
|
|
183
|
-
* @
|
|
272
|
+
* @example
|
|
273
|
+
* declare module '@flex-development/mlly' {
|
|
274
|
+
* interface ModuleFormatMap {
|
|
275
|
+
* custom: 'custom'
|
|
276
|
+
* }
|
|
277
|
+
* }
|
|
184
278
|
*/
|
|
185
|
-
|
|
186
|
-
builtin
|
|
187
|
-
commonjs
|
|
188
|
-
cts
|
|
189
|
-
json
|
|
190
|
-
module
|
|
191
|
-
mts
|
|
192
|
-
wasm
|
|
279
|
+
interface ModuleFormatMap {
|
|
280
|
+
builtin: 'builtin';
|
|
281
|
+
commonjs: 'commonjs';
|
|
282
|
+
cts: 'commonjs-typescript';
|
|
283
|
+
json: 'json';
|
|
284
|
+
module: 'module';
|
|
285
|
+
mts: 'module-typescript';
|
|
286
|
+
wasm: 'wasm';
|
|
193
287
|
}
|
|
194
288
|
|
|
195
289
|
/**
|
|
196
|
-
* @file
|
|
197
|
-
* @module mlly/
|
|
290
|
+
* @file Interfaces - PatternKeyComparisonMap
|
|
291
|
+
* @module mlly/interfaces/PatternKeyComparisonMap
|
|
198
292
|
*/
|
|
199
|
-
|
|
200
293
|
/**
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
* @see {@linkcode EmptyString}
|
|
204
|
-
* @see {@linkcode GetSourceOptions}
|
|
294
|
+
* Registry of `PATTERN_KEY_COMPARE` algorithm results.
|
|
205
295
|
*
|
|
206
|
-
*
|
|
296
|
+
* This interface can be augmented to register custom results.
|
|
207
297
|
*
|
|
208
|
-
* @
|
|
209
|
-
*
|
|
298
|
+
* @example
|
|
299
|
+
* declare module '@flex-development/mlly' {
|
|
300
|
+
* interface PatternKeyComparisonMap {
|
|
301
|
+
* afterThree: 3
|
|
302
|
+
* }
|
|
303
|
+
* }
|
|
304
|
+
*/
|
|
305
|
+
interface PatternKeyComparisonMap {
|
|
306
|
+
/**
|
|
307
|
+
* `a` should come after `b`.
|
|
308
|
+
*/
|
|
309
|
+
after: 1;
|
|
310
|
+
/**
|
|
311
|
+
* `a` should come before `b`.
|
|
312
|
+
*/
|
|
313
|
+
before: -1;
|
|
314
|
+
/**
|
|
315
|
+
* `a` and `b` are equal.
|
|
316
|
+
*/
|
|
317
|
+
equal: 0;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* @file Interfaces - ProtocolMap
|
|
322
|
+
* @module mlly/interfaces/ProtocolMap
|
|
323
|
+
*/
|
|
324
|
+
/**
|
|
325
|
+
* Registry of URL protocols.
|
|
326
|
+
*
|
|
327
|
+
* This interface can be augmented to register custom protocols.
|
|
328
|
+
*
|
|
329
|
+
* @see https://nodejs.org/api/url.html#urlprotocol
|
|
330
|
+
* @see https://iana.org/assignments/uri-schemes/uri-schemes.xhtml
|
|
331
|
+
* @see https://url.spec.whatwg.org/#special-scheme
|
|
332
|
+
*
|
|
333
|
+
* @example
|
|
334
|
+
* declare module '@flex-development/mlly' {
|
|
335
|
+
* interface ProtocolMap {
|
|
336
|
+
* custom: 'custom:'
|
|
337
|
+
* }
|
|
338
|
+
* }
|
|
339
|
+
*/
|
|
340
|
+
interface ProtocolMap {
|
|
341
|
+
blob: 'blob:';
|
|
342
|
+
content: 'content:';
|
|
343
|
+
cvs: 'cvs:';
|
|
344
|
+
data: 'data:';
|
|
345
|
+
dns: 'dns:';
|
|
346
|
+
file: 'file:';
|
|
347
|
+
fish: 'fish:';
|
|
348
|
+
ftp: 'ftp:';
|
|
349
|
+
git: 'git:';
|
|
350
|
+
http: 'http:';
|
|
351
|
+
https: 'https:';
|
|
352
|
+
mvn: 'mvn:';
|
|
353
|
+
node: 'node:';
|
|
354
|
+
redis: 'redis:';
|
|
355
|
+
sftp: 'sftp:';
|
|
356
|
+
ssh: 'ssh:';
|
|
357
|
+
svn: 'svn:';
|
|
358
|
+
urn: 'urn:';
|
|
359
|
+
viewSource: 'view-source:';
|
|
360
|
+
ws: 'ws:';
|
|
361
|
+
wss: 'wss:';
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* @file Interfaces - ReadFile
|
|
366
|
+
* @module mlly/interfaces/ReadFile
|
|
367
|
+
*/
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* Read the entire contents of a file.
|
|
371
|
+
*/
|
|
372
|
+
interface ReadFile {
|
|
373
|
+
/**
|
|
374
|
+
* @see {@linkcode ModuleId}
|
|
375
|
+
*
|
|
376
|
+
* @this {unknown}
|
|
377
|
+
*
|
|
378
|
+
* @param {ModuleId} id
|
|
379
|
+
* The module id
|
|
380
|
+
* @param {BufferEncoding} encoding
|
|
381
|
+
* The encoding of the file contents
|
|
382
|
+
* @return {Awaitable<string>}
|
|
383
|
+
* The file contents
|
|
384
|
+
*/
|
|
385
|
+
(id: ModuleId, encoding: BufferEncoding): Awaitable<string>;
|
|
386
|
+
/**
|
|
387
|
+
* @see {@linkcode Awaitable}
|
|
388
|
+
* @see {@linkcode FileContent}
|
|
389
|
+
* @see {@linkcode ModuleId}
|
|
390
|
+
*
|
|
391
|
+
* @template {Awaitable<FileContent | null | undefined>} T
|
|
392
|
+
* The file contents
|
|
393
|
+
*
|
|
394
|
+
* @this {unknown}
|
|
395
|
+
*
|
|
396
|
+
* @param {ModuleId} id
|
|
397
|
+
* The module id
|
|
398
|
+
* @param {BufferEncoding | null | undefined} [encoding]
|
|
399
|
+
* The encoding of the file contents
|
|
400
|
+
* @return {T}
|
|
401
|
+
* The file contents
|
|
402
|
+
*/
|
|
403
|
+
<T extends Awaitable<FileContent | null | undefined>>(id: ModuleId, encoding?: BufferEncoding | null | undefined): T;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* @file Interfaces - Realpath
|
|
408
|
+
* @module mlly/interfaces/Realpath
|
|
409
|
+
*/
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Compute a canonical pathname by resolving `.`, `..`, and symbolic links.
|
|
413
|
+
*
|
|
414
|
+
* > 👉 **Note**: A canonical pathname is not necessarily unique.
|
|
415
|
+
* > Hard links and bind mounts can expose an entity through many pathnames.
|
|
416
|
+
*/
|
|
417
|
+
interface Realpath {
|
|
418
|
+
/**
|
|
419
|
+
* @see {@linkcode Awaitable}
|
|
420
|
+
* @see {@linkcode ModuleId}
|
|
421
|
+
*
|
|
422
|
+
* @template {Awaitable<string>} T
|
|
423
|
+
* The canonical pathname
|
|
424
|
+
*
|
|
425
|
+
* @this {unknown}
|
|
426
|
+
*
|
|
427
|
+
* @param {ModuleId} id
|
|
428
|
+
* The module id
|
|
429
|
+
* @return {T}
|
|
430
|
+
* The canonical pathname
|
|
431
|
+
*/
|
|
432
|
+
<T extends Awaitable<string>>(id: ModuleId): T;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* @file Interfaces - ResolveAliasOptions
|
|
437
|
+
* @module mlly/interfaces/ResolveAliasOptions
|
|
438
|
+
*/
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* Options for path alias resolution.
|
|
442
|
+
*/
|
|
443
|
+
interface ResolveAliasOptions {
|
|
444
|
+
/**
|
|
445
|
+
* Whether the resolved specifier should be absolute.
|
|
446
|
+
*
|
|
447
|
+
* If `true`, the resolved specifier will be a [`file:` URL][file-url].
|
|
448
|
+
*
|
|
449
|
+
* [file-url]: https://nodejs.org/api/esm.html#file-urls
|
|
450
|
+
*
|
|
451
|
+
* @see https://nodejs.org/api/esm.html#terminology
|
|
452
|
+
*/
|
|
453
|
+
absolute?: boolean | null | undefined;
|
|
454
|
+
/**
|
|
455
|
+
* The path mappings dictionary.
|
|
456
|
+
*
|
|
457
|
+
* > 👉 **Note**: Paths should be relative to {@linkcode cwd}.
|
|
458
|
+
*
|
|
459
|
+
* @see {@linkcode Aliases}
|
|
460
|
+
*/
|
|
461
|
+
aliases?: Aliases | null | undefined;
|
|
462
|
+
/**
|
|
463
|
+
* The URL of the directory to resolve non-absolute modules from.
|
|
464
|
+
*
|
|
465
|
+
* @see {@linkcode ModuleId}
|
|
466
|
+
*
|
|
467
|
+
* @default cwd()
|
|
468
|
+
*/
|
|
469
|
+
cwd?: ModuleId | null | undefined;
|
|
470
|
+
/**
|
|
471
|
+
* The URL of the parent module.
|
|
472
|
+
*
|
|
473
|
+
* @see {@linkcode ModuleId}
|
|
474
|
+
*/
|
|
475
|
+
parent?: ModuleId | null | undefined;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* @file Interfaces - ResolveModuleOptions
|
|
480
|
+
* @module mlly/interfaces/ResolveModuleOptions
|
|
481
|
+
*/
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* Options for module resolution.
|
|
485
|
+
*/
|
|
486
|
+
interface ResolveModuleOptions {
|
|
487
|
+
/**
|
|
488
|
+
* The path mappings dictionary.
|
|
489
|
+
*
|
|
490
|
+
* > 👉 **Note**: Paths should be relative to {@linkcode cwd}.
|
|
491
|
+
*
|
|
492
|
+
* @see {@linkcode Aliases}
|
|
493
|
+
*/
|
|
494
|
+
aliases?: Aliases | null | undefined;
|
|
495
|
+
/**
|
|
496
|
+
* The list of export/import conditions.
|
|
497
|
+
*
|
|
498
|
+
* > 👉 **Note**: Should be sorted by priority.
|
|
499
|
+
*
|
|
500
|
+
* @see {@linkcode Condition}
|
|
501
|
+
* @see {@linkcode List}
|
|
502
|
+
* @see https://nodejs.org/api/packages.html#conditional-exports
|
|
503
|
+
*
|
|
504
|
+
* @default defaultConditions
|
|
505
|
+
*/
|
|
506
|
+
conditions?: List<Condition> | null | undefined;
|
|
507
|
+
/**
|
|
508
|
+
* The URL of the directory to resolve path {@linkcode aliases} from.
|
|
509
|
+
*
|
|
510
|
+
* @see {@linkcode ModuleId}
|
|
511
|
+
*
|
|
512
|
+
* @default cwd()
|
|
513
|
+
*/
|
|
514
|
+
cwd?: ModuleId | null | undefined;
|
|
515
|
+
/**
|
|
516
|
+
* A replacement file extension, a record of replacement file extensions,
|
|
517
|
+
* or a function that returns a replacement file extension.
|
|
518
|
+
*
|
|
519
|
+
* > 👉 **Note**: Replacement file extensions are normalized and do not
|
|
520
|
+
* > need to begin with a dot character (`'.'`); an empty string (`''`),
|
|
521
|
+
* > `false`, or `null` will remove an extension.
|
|
522
|
+
*
|
|
523
|
+
* @see {@linkcode ExtensionRewrites}
|
|
524
|
+
* @see {@linkcode GetNewExtension}
|
|
525
|
+
*/
|
|
526
|
+
ext?: ExtensionRewrites | GetNewExtension | string | false | null | undefined;
|
|
527
|
+
/**
|
|
528
|
+
* The module extensions to probe for.
|
|
529
|
+
*
|
|
530
|
+
* > 👉 **Note**: Should be sorted by priority.
|
|
531
|
+
*
|
|
532
|
+
* @see {@linkcode List}
|
|
533
|
+
*
|
|
534
|
+
* @default defaultExtensions
|
|
535
|
+
*/
|
|
536
|
+
extensions?: List<string> | null | undefined;
|
|
537
|
+
/**
|
|
538
|
+
* The file system API.
|
|
539
|
+
*
|
|
540
|
+
* @see {@linkcode FileSystem}
|
|
541
|
+
*/
|
|
542
|
+
fs?: FileSystem | null | undefined;
|
|
543
|
+
/**
|
|
544
|
+
* The list of legacy `main` fields.
|
|
545
|
+
*
|
|
546
|
+
* > 👉 **Note**: Should be sorted by priority.
|
|
547
|
+
*
|
|
548
|
+
* @see {@linkcode List}
|
|
549
|
+
* @see {@linkcode MainField}
|
|
550
|
+
*
|
|
551
|
+
* @default defaultMainFields
|
|
552
|
+
*/
|
|
553
|
+
mainFields?: List<MainField> | null | undefined;
|
|
554
|
+
/**
|
|
555
|
+
* Whether to keep symlinks instead of resolving them.
|
|
556
|
+
*/
|
|
557
|
+
preserveSymlinks?: boolean | null | undefined;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* @file Interfaces - Stat
|
|
562
|
+
* @module mlly/interfaces/Stat
|
|
563
|
+
*/
|
|
564
|
+
|
|
565
|
+
/**
|
|
566
|
+
* Get information about a directory or file.
|
|
567
|
+
*/
|
|
568
|
+
interface Stat {
|
|
569
|
+
/**
|
|
570
|
+
* @see {@linkcode Awaitable}
|
|
571
|
+
* @see {@linkcode ModuleId}
|
|
572
|
+
* @see {@linkcode Stats}
|
|
573
|
+
*
|
|
574
|
+
* @template {Awaitable<Stats>} T
|
|
575
|
+
* The info
|
|
576
|
+
*
|
|
577
|
+
* @this {unknown}
|
|
578
|
+
*
|
|
579
|
+
* @param {ModuleId} id
|
|
580
|
+
* The module id
|
|
581
|
+
* @return {T}
|
|
582
|
+
* The info
|
|
583
|
+
*/
|
|
584
|
+
<T extends Awaitable<Stats>>(id: ModuleId): T;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* @file Interfaces - Stats
|
|
589
|
+
* @module mlly/interfaces/Stats
|
|
590
|
+
*/
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* An object describing a directory or file.
|
|
594
|
+
*/
|
|
595
|
+
interface Stats {
|
|
596
|
+
/**
|
|
597
|
+
* Check if the stats object describes a directory.
|
|
598
|
+
*
|
|
599
|
+
* @see {@linkcode IsDirectory}
|
|
600
|
+
*/
|
|
601
|
+
isDirectory: IsDirectory;
|
|
602
|
+
/**
|
|
603
|
+
* Check if the stats object describes a file.
|
|
604
|
+
*
|
|
605
|
+
* @see {@linkcode IsFile}
|
|
606
|
+
*/
|
|
607
|
+
isFile: IsFile;
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
* @file canParseUrl
|
|
612
|
+
* @module mlly/lib/canParseUrl
|
|
613
|
+
*/
|
|
614
|
+
/**
|
|
615
|
+
* Check if `input` can be parsed to a {@linkcode URL}.
|
|
616
|
+
*
|
|
617
|
+
* > 👉 **Note**: If `input` is relative, `base` is required.
|
|
618
|
+
* > If `input` is absolute, `base` is ignored.
|
|
619
|
+
*
|
|
620
|
+
* @see {@linkcode ModuleId}
|
|
621
|
+
*
|
|
622
|
+
* @this {void}
|
|
623
|
+
*
|
|
624
|
+
* @param {unknown} input
|
|
625
|
+
* The input URL
|
|
626
|
+
* @param {unknown} [base]
|
|
627
|
+
* The base URL to resolve against if `input` is not absolute
|
|
628
|
+
* @return {boolean}
|
|
629
|
+
* `true` if `input` can be parsed to a `URL`, `false` otherwise
|
|
630
|
+
*/
|
|
631
|
+
declare function canParseUrl(this: void, input: unknown, base?: unknown): boolean;
|
|
632
|
+
|
|
633
|
+
/**
|
|
634
|
+
* @file cwd
|
|
635
|
+
* @module mlly/lib/cwd
|
|
636
|
+
*/
|
|
637
|
+
/**
|
|
638
|
+
* Get the URL of the current working directory.
|
|
639
|
+
*
|
|
640
|
+
* @this {void}
|
|
641
|
+
*
|
|
642
|
+
* @return {URL}
|
|
643
|
+
* The current working directory URL
|
|
644
|
+
*/
|
|
645
|
+
declare function cwd(this: void): URL;
|
|
646
|
+
|
|
647
|
+
/**
|
|
648
|
+
* @file defaultConditions
|
|
649
|
+
* @module mlly/lib/defaultConditions
|
|
650
|
+
*/
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
* The default list of conditions.
|
|
654
|
+
*
|
|
655
|
+
* @see {@linkcode Condition}
|
|
656
|
+
* @see https://nodejs.org/api/packages.html#conditional-exports
|
|
657
|
+
*
|
|
658
|
+
* @const {Set<Condition>} defaultConditions
|
|
659
|
+
*/
|
|
660
|
+
declare const defaultConditions: Set<Condition>;
|
|
661
|
+
|
|
662
|
+
/**
|
|
663
|
+
* @file defaultExtensions
|
|
664
|
+
* @module mlly/lib/defaultExtensions
|
|
665
|
+
*/
|
|
666
|
+
|
|
667
|
+
/**
|
|
668
|
+
* The default list of resolvable file extensions.
|
|
669
|
+
*
|
|
670
|
+
* @see {@linkcode Ext}
|
|
671
|
+
*
|
|
672
|
+
* @const {Set<Ext>} defaultExtensions
|
|
673
|
+
*/
|
|
674
|
+
declare const defaultExtensions: Set<Ext>;
|
|
675
|
+
|
|
676
|
+
/**
|
|
677
|
+
* @file defaultMainFields
|
|
678
|
+
* @module mlly/lib/defaultMainFields
|
|
679
|
+
*/
|
|
680
|
+
|
|
681
|
+
/**
|
|
682
|
+
* The default list of main fields.
|
|
683
|
+
*
|
|
684
|
+
* @see {@linkcode MainField}
|
|
685
|
+
*
|
|
686
|
+
* @const {Set<MainField>} defaultMainFields
|
|
687
|
+
*/
|
|
688
|
+
declare const defaultMainFields: Set<MainField>;
|
|
689
|
+
|
|
690
|
+
/**
|
|
691
|
+
* @file extensionFormatMap
|
|
692
|
+
* @module mlly/lib/extensionFormatMap
|
|
693
|
+
*/
|
|
694
|
+
|
|
695
|
+
/**
|
|
696
|
+
* Map, where each key is a file extension
|
|
697
|
+
* and each value is a default module format.
|
|
698
|
+
*
|
|
699
|
+
* @see {@linkcode Ext}
|
|
700
|
+
* @see {@linkcode ModuleFormat}
|
|
701
|
+
*
|
|
702
|
+
* @const {Map<Ext, ModuleFormat>} extensionFormatMap
|
|
703
|
+
*/
|
|
704
|
+
declare const extensionFormatMap: Map<Ext, ModuleFormat>;
|
|
705
|
+
|
|
706
|
+
/**
|
|
707
|
+
* @file formats
|
|
708
|
+
* @module mlly/lib/formats
|
|
709
|
+
*/
|
|
710
|
+
/**
|
|
711
|
+
* Default module formats.
|
|
712
|
+
*
|
|
713
|
+
* @see {@linkcode ModuleFormat}
|
|
714
|
+
*
|
|
715
|
+
* @enum {ModuleFormat}
|
|
716
|
+
*/
|
|
717
|
+
declare const enum formats {
|
|
718
|
+
builtin = "builtin",
|
|
719
|
+
commonjs = "commonjs",
|
|
720
|
+
cts = "commonjs-typescript",
|
|
721
|
+
json = "json",
|
|
722
|
+
module = "module",
|
|
723
|
+
mts = "module-typescript",
|
|
724
|
+
wasm = "wasm"
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
/**
|
|
728
|
+
* @file getSource
|
|
729
|
+
* @module mlly/lib/getSource
|
|
730
|
+
*/
|
|
731
|
+
|
|
732
|
+
/**
|
|
733
|
+
* Get the source code for a module.
|
|
734
|
+
*
|
|
735
|
+
* @see {@linkcode EmptyString}
|
|
736
|
+
* @see {@linkcode GetSourceOptions}
|
|
737
|
+
*
|
|
738
|
+
* @this {void}
|
|
739
|
+
*
|
|
740
|
+
* @param {EmptyString | null | undefined} id
|
|
741
|
+
* The module id
|
|
210
742
|
* @param {GetSourceOptions | null | undefined} [options]
|
|
211
743
|
* Source code retrieval options
|
|
212
744
|
* @return {null}
|
|
@@ -641,7 +1173,7 @@ declare function resolveAlias(this: void, specifier: string, options?: ResolveAl
|
|
|
641
1173
|
*
|
|
642
1174
|
* @this {void}
|
|
643
1175
|
*
|
|
644
|
-
* @param {
|
|
1176
|
+
* @param {ModuleId} specifier
|
|
645
1177
|
* The module specifier to resolve
|
|
646
1178
|
* @param {ModuleId} parent
|
|
647
1179
|
* The URL of the parent module
|
|
@@ -651,7 +1183,7 @@ declare function resolveAlias(this: void, specifier: string, options?: ResolveAl
|
|
|
651
1183
|
* The resolved URL
|
|
652
1184
|
* @throws {NodeError}
|
|
653
1185
|
*/
|
|
654
|
-
declare function resolveModule<T extends Awaitable<URL>>(this: void, specifier:
|
|
1186
|
+
declare function resolveModule<T extends Awaitable<URL>>(this: void, specifier: ModuleId, parent: ModuleId, options?: ResolveModuleOptions | null | undefined): T;
|
|
655
1187
|
|
|
656
1188
|
/**
|
|
657
1189
|
* @file resolver
|
|
@@ -1012,899 +1544,367 @@ declare namespace resolver_d {
|
|
|
1012
1544
|
resolver_d_legacyMainResolve as legacyMainResolve,
|
|
1013
1545
|
resolver_d_moduleResolve as moduleResolve,
|
|
1014
1546
|
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
|
-
};
|
|
1547
|
+
resolver_d_packageImportsExportsResolve as packageImportsExportsResolve,
|
|
1548
|
+
resolver_d_packageImportsResolve as packageImportsResolve,
|
|
1549
|
+
resolver_d_packageResolve as packageResolve,
|
|
1550
|
+
resolver_d_packageSelfResolve as packageSelfResolve,
|
|
1551
|
+
resolver_d_packageTargetResolve as packageTargetResolve,
|
|
1552
|
+
};
|
|
1553
|
+
}
|
|
1201
1554
|
|
|
1202
1555
|
/**
|
|
1203
|
-
* @file
|
|
1204
|
-
* @module mlly/
|
|
1556
|
+
* @file root
|
|
1557
|
+
* @module mlly/lib/root
|
|
1205
1558
|
*/
|
|
1206
1559
|
/**
|
|
1207
|
-
*
|
|
1560
|
+
* The URL of the file system root.
|
|
1208
1561
|
*
|
|
1209
|
-
* @
|
|
1562
|
+
* @const {URL} root
|
|
1210
1563
|
*/
|
|
1211
|
-
|
|
1564
|
+
declare const root: URL;
|
|
1212
1565
|
|
|
1213
1566
|
/**
|
|
1214
|
-
* @file
|
|
1215
|
-
* @module mlly/
|
|
1567
|
+
* @file toRelativeSpecifier
|
|
1568
|
+
* @module mlly/lib/toRelativeSpecifier
|
|
1216
1569
|
*/
|
|
1570
|
+
|
|
1217
1571
|
/**
|
|
1218
|
-
*
|
|
1219
|
-
*
|
|
1220
|
-
* Returning an empty string (`''`), `false`, `null`, or `undefined`
|
|
1221
|
-
* will remove the current file extension.
|
|
1572
|
+
* Turn `url` into a *relative specifier*.
|
|
1222
1573
|
*
|
|
1223
1574
|
* ::: info
|
|
1224
|
-
*
|
|
1225
|
-
*
|
|
1575
|
+
* The relative specifier will only have a file extension
|
|
1576
|
+
* if `specifier` also has an extension.
|
|
1226
1577
|
* :::
|
|
1227
1578
|
*
|
|
1228
|
-
* @see {@linkcode
|
|
1229
|
-
* @see https://
|
|
1579
|
+
* @see {@linkcode ModuleId}
|
|
1580
|
+
* @see https://nodejs.org/api/esm.html#terminology
|
|
1230
1581
|
*
|
|
1231
|
-
* @
|
|
1232
|
-
* The new file extension
|
|
1582
|
+
* @this {void}
|
|
1233
1583
|
*
|
|
1234
|
-
* @param {
|
|
1235
|
-
* The
|
|
1236
|
-
* @param {
|
|
1237
|
-
* The module
|
|
1238
|
-
* @return {
|
|
1239
|
-
* The
|
|
1584
|
+
* @param {ModuleId} url
|
|
1585
|
+
* The `file:` URL to convert
|
|
1586
|
+
* @param {ModuleId} parent
|
|
1587
|
+
* The parent module id
|
|
1588
|
+
* @return {string}
|
|
1589
|
+
* The relative specifier
|
|
1240
1590
|
*/
|
|
1241
|
-
|
|
1591
|
+
declare function toRelativeSpecifier(this: void, url: ModuleId, parent: ModuleId): string;
|
|
1242
1592
|
|
|
1243
1593
|
/**
|
|
1244
|
-
* @file
|
|
1245
|
-
* @module mlly/
|
|
1594
|
+
* @file toUrl
|
|
1595
|
+
* @module mlly/lib/toUrl
|
|
1246
1596
|
*/
|
|
1247
1597
|
|
|
1248
1598
|
/**
|
|
1249
|
-
*
|
|
1599
|
+
* Convert `id` to a {@linkcode URL}.
|
|
1250
1600
|
*
|
|
1251
|
-
*
|
|
1252
|
-
*
|
|
1253
|
-
*
|
|
1254
|
-
* @see {@linkcode URL}
|
|
1601
|
+
* > 👉 **Note**: If `id` cannot be parsed as a `URL`, and is also not a
|
|
1602
|
+
* > [builtin module][builtin-module], it will be assumed to be a path and
|
|
1603
|
+
* > converted to a [`file:` URL][file-url].
|
|
1255
1604
|
*
|
|
1256
|
-
*
|
|
1257
|
-
*
|
|
1605
|
+
* [builtin-module]: https://nodejs.org/api/esm.html#builtin-modules
|
|
1606
|
+
* [file-url]: https://nodejs.org/api/esm.html#file-urls
|
|
1258
1607
|
*
|
|
1259
|
-
* @
|
|
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.
|
|
1608
|
+
* @this {void}
|
|
1273
1609
|
*
|
|
1274
|
-
* @
|
|
1275
|
-
*
|
|
1610
|
+
* @param {ModuleId} id
|
|
1611
|
+
* The module id to convert
|
|
1612
|
+
* @param {ModuleId | null | undefined} [parent]
|
|
1613
|
+
* The base URL to resolve against if `id` is not absolute
|
|
1614
|
+
* @return {URL}
|
|
1615
|
+
* The new URL
|
|
1276
1616
|
*/
|
|
1277
|
-
|
|
1278
|
-
[H in Protocol]?: GetSourceHandler | null | undefined;
|
|
1279
|
-
};
|
|
1617
|
+
declare function toUrl(this: void, id: ModuleId, parent?: ModuleId | null | undefined): URL;
|
|
1280
1618
|
|
|
1281
1619
|
/**
|
|
1282
|
-
* @file Type Aliases -
|
|
1283
|
-
* @module mlly/types/
|
|
1620
|
+
* @file Type Aliases - Awaitable
|
|
1621
|
+
* @module mlly/types/Awaitable
|
|
1284
1622
|
*/
|
|
1285
1623
|
/**
|
|
1286
|
-
*
|
|
1624
|
+
* Create a union of `T` and `T` as a promise-like object.
|
|
1287
1625
|
*
|
|
1288
|
-
* @template {any}
|
|
1289
|
-
* The
|
|
1626
|
+
* @template {any} T
|
|
1627
|
+
* The value
|
|
1290
1628
|
*/
|
|
1291
|
-
type
|
|
1629
|
+
type Awaitable<T> = PromiseLike<T> | T;
|
|
1292
1630
|
|
|
1293
1631
|
/**
|
|
1294
|
-
* @file Type Aliases -
|
|
1295
|
-
* @module mlly/types/
|
|
1632
|
+
* @file Type Aliases - BufferEncoding
|
|
1633
|
+
* @module mlly/types/BufferEncoding
|
|
1296
1634
|
*/
|
|
1297
1635
|
|
|
1298
1636
|
/**
|
|
1299
|
-
* Union of values that can occur where a
|
|
1637
|
+
* Union of values that can occur where a buffer encoding is expected.
|
|
1300
1638
|
*
|
|
1301
|
-
* To register new
|
|
1639
|
+
* To register new encodings, augment {@linkcode BufferEncodingMap}.
|
|
1302
1640
|
* They will be added to this union automatically.
|
|
1303
1641
|
*/
|
|
1304
|
-
type
|
|
1642
|
+
type BufferEncoding = BufferEncodingMap[keyof BufferEncodingMap];
|
|
1305
1643
|
|
|
1306
1644
|
/**
|
|
1307
|
-
* @file Type Aliases -
|
|
1308
|
-
* @module mlly/types/
|
|
1645
|
+
* @file Type Aliases - Condition
|
|
1646
|
+
* @module mlly/types/Condition
|
|
1309
1647
|
*/
|
|
1310
1648
|
|
|
1311
1649
|
/**
|
|
1312
|
-
* Union of values that can occur where a
|
|
1650
|
+
* Union of values that can occur where a export/import condition is expected.
|
|
1313
1651
|
*
|
|
1314
|
-
* To register new
|
|
1652
|
+
* To register new conditions, augment {@linkcode ConditionMap}.
|
|
1315
1653
|
* They will be added to this union automatically.
|
|
1316
1654
|
*/
|
|
1317
|
-
type
|
|
1655
|
+
type Condition = ConditionMap[keyof ConditionMap];
|
|
1318
1656
|
|
|
1319
1657
|
/**
|
|
1320
|
-
* @file Type Aliases -
|
|
1321
|
-
* @module mlly/types/
|
|
1658
|
+
* @file Type Aliases - Dot
|
|
1659
|
+
* @module mlly/types/Dot
|
|
1322
1660
|
*/
|
|
1323
1661
|
/**
|
|
1324
|
-
*
|
|
1325
|
-
* ECMAScript (ES) module identifier is expected.
|
|
1326
|
-
*
|
|
1327
|
-
* @see {@linkcode URL}
|
|
1662
|
+
* A dot character (`'.'`).
|
|
1328
1663
|
*/
|
|
1329
|
-
type
|
|
1664
|
+
type Dot = '.';
|
|
1330
1665
|
|
|
1331
1666
|
/**
|
|
1332
|
-
* @file Type Aliases -
|
|
1333
|
-
* @module mlly/types/
|
|
1667
|
+
* @file Type Aliases - EmptyArray
|
|
1668
|
+
* @module mlly/types/EmptyArray
|
|
1334
1669
|
*/
|
|
1335
1670
|
/**
|
|
1336
|
-
*
|
|
1671
|
+
* An empty array.
|
|
1337
1672
|
*/
|
|
1338
|
-
type
|
|
1673
|
+
type EmptyArray = [];
|
|
1339
1674
|
|
|
1340
1675
|
/**
|
|
1341
|
-
* @file Type Aliases -
|
|
1342
|
-
* @module mlly/types/
|
|
1676
|
+
* @file Type Aliases - EmptyObject
|
|
1677
|
+
* @module mlly/types/EmptyObject
|
|
1343
1678
|
*/
|
|
1344
|
-
|
|
1345
1679
|
/**
|
|
1346
|
-
*
|
|
1347
|
-
* where a `PATTERN_KEY_COMPARE` algorithm result is expected.
|
|
1680
|
+
* The empty object symbol.
|
|
1348
1681
|
*
|
|
1349
|
-
*
|
|
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.
|
|
1682
|
+
* @internal
|
|
1371
1683
|
*
|
|
1372
|
-
*
|
|
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
|
|
1684
|
+
* @const {symbol} tag
|
|
1380
1685
|
*/
|
|
1381
|
-
|
|
1686
|
+
declare const tag: unique symbol;
|
|
1382
1687
|
/**
|
|
1383
|
-
*
|
|
1688
|
+
* An empty object.
|
|
1384
1689
|
*/
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
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
|
-
}
|
|
1690
|
+
type EmptyObject = {
|
|
1691
|
+
[tag]?: never;
|
|
1692
|
+
};
|
|
1405
1693
|
|
|
1406
1694
|
/**
|
|
1407
|
-
* @file
|
|
1408
|
-
* @module mlly/
|
|
1695
|
+
* @file Type Aliases - EmptyString
|
|
1696
|
+
* @module mlly/types/EmptyString
|
|
1409
1697
|
*/
|
|
1410
|
-
|
|
1411
1698
|
/**
|
|
1412
|
-
*
|
|
1413
|
-
*
|
|
1414
|
-
* @see {@linkcode GetSourceOptions}
|
|
1415
|
-
*
|
|
1416
|
-
* @extends {GetSourceOptions}
|
|
1699
|
+
* An empty string.
|
|
1417
1700
|
*/
|
|
1418
|
-
|
|
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
|
-
}
|
|
1701
|
+
type EmptyString = '';
|
|
1449
1702
|
|
|
1450
1703
|
/**
|
|
1451
|
-
* @file
|
|
1452
|
-
* @module mlly/
|
|
1704
|
+
* @file Type Aliases - Ext
|
|
1705
|
+
* @module mlly/types/Ext
|
|
1453
1706
|
*/
|
|
1454
1707
|
|
|
1455
1708
|
/**
|
|
1456
|
-
*
|
|
1709
|
+
* A file extension.
|
|
1710
|
+
*
|
|
1711
|
+
* @see {@linkcode Dot}
|
|
1457
1712
|
*/
|
|
1458
|
-
|
|
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
|
-
}
|
|
1713
|
+
type Ext = `${Dot}${string}`;
|
|
1505
1714
|
|
|
1506
1715
|
/**
|
|
1507
|
-
* @file
|
|
1508
|
-
* @module mlly/
|
|
1716
|
+
* @file Type Aliases - ExtensionRewrites
|
|
1717
|
+
* @module mlly/types/ExtensionRewrites
|
|
1509
1718
|
*/
|
|
1719
|
+
|
|
1510
1720
|
/**
|
|
1511
|
-
*
|
|
1721
|
+
* Record, where each key is the file extension of a module specifier and
|
|
1722
|
+
* each value is a replacement file extension.
|
|
1723
|
+
*
|
|
1724
|
+
* > 👉 **Note**: Replacement file extensions are normalized and do not need to
|
|
1725
|
+
* > begin with a dot character (`'.'`); falsy values will remove an extension.
|
|
1726
|
+
*
|
|
1727
|
+
* @see {@linkcode EmptyString}
|
|
1728
|
+
* @see {@linkcode Ext}
|
|
1512
1729
|
*/
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
*
|
|
1517
|
-
* @return {boolean}
|
|
1518
|
-
* `true` if stats describes directory, `false` otherwise
|
|
1519
|
-
*/
|
|
1520
|
-
(): boolean;
|
|
1521
|
-
}
|
|
1730
|
+
type ExtensionRewrites = {
|
|
1731
|
+
[K in EmptyString | Ext]?: string | false | null | undefined;
|
|
1732
|
+
};
|
|
1522
1733
|
|
|
1523
1734
|
/**
|
|
1524
|
-
* @file
|
|
1525
|
-
* @module mlly/
|
|
1735
|
+
* @file Type Aliases - FileContent
|
|
1736
|
+
* @module mlly/types/FileContent
|
|
1526
1737
|
*/
|
|
1527
1738
|
/**
|
|
1528
|
-
*
|
|
1739
|
+
* Union of values that can occur where file content is expected.
|
|
1740
|
+
*
|
|
1741
|
+
* @see {@linkcode Uint8Array}
|
|
1529
1742
|
*/
|
|
1530
|
-
|
|
1531
|
-
/**
|
|
1532
|
-
* @this {void}
|
|
1533
|
-
*
|
|
1534
|
-
* @return {boolean}
|
|
1535
|
-
* `true` if stats object describes regular file, `false` otherwise
|
|
1536
|
-
*/
|
|
1537
|
-
(): boolean;
|
|
1538
|
-
}
|
|
1743
|
+
type FileContent = Uint8Array | string;
|
|
1539
1744
|
|
|
1540
1745
|
/**
|
|
1541
|
-
* @file
|
|
1542
|
-
* @module mlly/
|
|
1746
|
+
* @file Type Aliases - GetNewExtension
|
|
1747
|
+
* @module mlly/types/GetNewExtension
|
|
1543
1748
|
*/
|
|
1544
1749
|
/**
|
|
1545
|
-
*
|
|
1750
|
+
* Get a new file extension for a `url`.
|
|
1546
1751
|
*
|
|
1547
|
-
*
|
|
1752
|
+
* Returning an empty string (`''`), `false`, `null`, or `undefined`
|
|
1753
|
+
* will remove the current file extension.
|
|
1548
1754
|
*
|
|
1549
|
-
*
|
|
1550
|
-
*
|
|
1551
|
-
*
|
|
1552
|
-
*
|
|
1553
|
-
*
|
|
1554
|
-
*
|
|
1755
|
+
* ::: info
|
|
1756
|
+
* File extensions are normalized and
|
|
1757
|
+
* do not need to begin with a dot character (`'.'`).
|
|
1758
|
+
* :::
|
|
1759
|
+
*
|
|
1760
|
+
* @see {@linkcode URL}
|
|
1761
|
+
* @see https://github.com/flex-development/pathe/tree/1.0.3#changeextpath-string-ext-nullablestring-string
|
|
1762
|
+
*
|
|
1763
|
+
* @template {string | false | null | undefined} [T]
|
|
1764
|
+
* The new file extension
|
|
1765
|
+
*
|
|
1766
|
+
* @param {URL} url
|
|
1767
|
+
* The resolved module URL
|
|
1768
|
+
* @param {string} specifier
|
|
1769
|
+
* The module specifier being resolved
|
|
1770
|
+
* @return {T}
|
|
1771
|
+
* The new file extension
|
|
1555
1772
|
*/
|
|
1556
|
-
|
|
1557
|
-
main: 'main';
|
|
1558
|
-
module: 'module';
|
|
1559
|
-
types: 'types';
|
|
1560
|
-
}
|
|
1773
|
+
type GetNewExtension<T extends string | false | null | undefined = string | false | null | undefined> = (this: void, url: URL, specifier: string) => T;
|
|
1561
1774
|
|
|
1562
1775
|
/**
|
|
1563
|
-
* @file
|
|
1564
|
-
* @module mlly/
|
|
1776
|
+
* @file Type Aliases - GetSourceHandler
|
|
1777
|
+
* @module mlly/types/GetSourceHandler
|
|
1565
1778
|
*/
|
|
1779
|
+
|
|
1566
1780
|
/**
|
|
1567
|
-
*
|
|
1781
|
+
* Get the source code for a module.
|
|
1568
1782
|
*
|
|
1569
|
-
*
|
|
1783
|
+
* @see {@linkcode Awaitable}
|
|
1784
|
+
* @see {@linkcode FileContent}
|
|
1785
|
+
* @see {@linkcode GetSourceContext}
|
|
1786
|
+
* @see {@linkcode URL}
|
|
1570
1787
|
*
|
|
1571
|
-
* @
|
|
1572
|
-
*
|
|
1573
|
-
*
|
|
1574
|
-
*
|
|
1575
|
-
*
|
|
1576
|
-
*
|
|
1788
|
+
* @this {GetSourceContext}
|
|
1789
|
+
* The retrieval context
|
|
1790
|
+
*
|
|
1791
|
+
* @param {URL} url
|
|
1792
|
+
* The module URL
|
|
1793
|
+
* @return {Awaitable<FileContent | null | undefined>}
|
|
1794
|
+
* The source code
|
|
1577
1795
|
*/
|
|
1578
|
-
|
|
1579
|
-
builtin: 'builtin';
|
|
1580
|
-
commonjs: 'commonjs';
|
|
1581
|
-
cts: 'commonjs-typescript';
|
|
1582
|
-
json: 'json';
|
|
1583
|
-
module: 'module';
|
|
1584
|
-
mts: 'module-typescript';
|
|
1585
|
-
wasm: 'wasm';
|
|
1586
|
-
}
|
|
1796
|
+
type GetSourceHandler = (this: GetSourceContext, url: URL) => Awaitable<FileContent | null | undefined>;
|
|
1587
1797
|
|
|
1588
1798
|
/**
|
|
1589
|
-
* @file
|
|
1590
|
-
* @module mlly/
|
|
1799
|
+
* @file Type Aliases - GetSourceHandlers
|
|
1800
|
+
* @module mlly/types/GetSourceHandlers
|
|
1591
1801
|
*/
|
|
1802
|
+
|
|
1592
1803
|
/**
|
|
1593
|
-
*
|
|
1594
|
-
*
|
|
1595
|
-
* This interface can be augmented to register custom results.
|
|
1804
|
+
* Record, where key is a URL protocol and each value is a source code handler.
|
|
1596
1805
|
*
|
|
1597
|
-
* @
|
|
1598
|
-
*
|
|
1599
|
-
* interface PatternKeyComparisonMap {
|
|
1600
|
-
* afterThree: 3
|
|
1601
|
-
* }
|
|
1602
|
-
* }
|
|
1806
|
+
* @see {@linkcode GetSourceHandler}
|
|
1807
|
+
* @see {@linkcode Protocol}
|
|
1603
1808
|
*/
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
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
|
-
}
|
|
1809
|
+
type GetSourceHandlers = {
|
|
1810
|
+
[H in Protocol]?: GetSourceHandler | null | undefined;
|
|
1811
|
+
};
|
|
1618
1812
|
|
|
1619
1813
|
/**
|
|
1620
|
-
* @file
|
|
1621
|
-
* @module mlly/
|
|
1814
|
+
* @file Type Aliases - List
|
|
1815
|
+
* @module mlly/types/List
|
|
1622
1816
|
*/
|
|
1623
1817
|
/**
|
|
1624
|
-
*
|
|
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
|
|
1818
|
+
* A list.
|
|
1631
1819
|
*
|
|
1632
|
-
* @
|
|
1633
|
-
*
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1820
|
+
* @template {any} [T=unknown]
|
|
1821
|
+
* The list item type
|
|
1822
|
+
*/
|
|
1823
|
+
type List<T = unknown> = ReadonlySet<T> | readonly T[];
|
|
1824
|
+
|
|
1825
|
+
/**
|
|
1826
|
+
* @file Type Aliases - MainField
|
|
1827
|
+
* @module mlly/types/MainField
|
|
1638
1828
|
*/
|
|
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
1829
|
|
|
1663
1830
|
/**
|
|
1664
|
-
*
|
|
1665
|
-
*
|
|
1831
|
+
* Union of values that can occur where a main field is expected.
|
|
1832
|
+
*
|
|
1833
|
+
* To register new fields, augment {@linkcode MainFieldMap}.
|
|
1834
|
+
* They will be added to this union automatically.
|
|
1666
1835
|
*/
|
|
1836
|
+
type MainField = MainFieldMap[keyof MainFieldMap];
|
|
1667
1837
|
|
|
1668
1838
|
/**
|
|
1669
|
-
*
|
|
1839
|
+
* @file Type Aliases - ModuleFormat
|
|
1840
|
+
* @module mlly/types/ModuleFormat
|
|
1670
1841
|
*/
|
|
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
1842
|
|
|
1705
1843
|
/**
|
|
1706
|
-
*
|
|
1707
|
-
*
|
|
1844
|
+
* Union of values that can occur where a module format is expected.
|
|
1845
|
+
*
|
|
1846
|
+
* To register new formats, augment {@linkcode ModuleFormatMap}.
|
|
1847
|
+
* They will be added to this union automatically.
|
|
1708
1848
|
*/
|
|
1849
|
+
type ModuleFormat = ModuleFormatMap[keyof ModuleFormatMap];
|
|
1709
1850
|
|
|
1710
1851
|
/**
|
|
1711
|
-
*
|
|
1852
|
+
* @file Type Aliases - ModuleId
|
|
1853
|
+
* @module mlly/types/ModuleId
|
|
1854
|
+
*/
|
|
1855
|
+
/**
|
|
1856
|
+
* Union of values that can occur where a
|
|
1857
|
+
* ECMAScript (ES) module identifier is expected.
|
|
1712
1858
|
*
|
|
1713
|
-
*
|
|
1714
|
-
* > Hard links and bind mounts can expose an entity through many pathnames.
|
|
1859
|
+
* @see {@linkcode URL}
|
|
1715
1860
|
*/
|
|
1716
|
-
|
|
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
|
-
}
|
|
1861
|
+
type ModuleId = URL | string;
|
|
1733
1862
|
|
|
1734
1863
|
/**
|
|
1735
|
-
* @file
|
|
1736
|
-
* @module mlly/
|
|
1864
|
+
* @file Type Aliases - Numeric
|
|
1865
|
+
* @module mlly/types/Numeric
|
|
1737
1866
|
*/
|
|
1738
|
-
|
|
1739
1867
|
/**
|
|
1740
|
-
*
|
|
1868
|
+
* String containing only numbers (not including the leading `-` if negative).
|
|
1741
1869
|
*/
|
|
1742
|
-
|
|
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
|
-
}
|
|
1870
|
+
type Numeric = `${number}`;
|
|
1776
1871
|
|
|
1777
1872
|
/**
|
|
1778
|
-
* @file
|
|
1779
|
-
* @module mlly/
|
|
1873
|
+
* @file Type Aliases - PatternKeyComparison
|
|
1874
|
+
* @module mlly/types/PatternKeyComparison
|
|
1780
1875
|
*/
|
|
1781
1876
|
|
|
1782
1877
|
/**
|
|
1783
|
-
*
|
|
1878
|
+
* Union of values that can occur
|
|
1879
|
+
* where a `PATTERN_KEY_COMPARE` algorithm result is expected.
|
|
1880
|
+
*
|
|
1881
|
+
* To register new results, augment {@linkcode PatternKeyComparisonMap}.
|
|
1882
|
+
* They will be added to this union automatically.
|
|
1784
1883
|
*/
|
|
1785
|
-
|
|
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
|
-
}
|
|
1884
|
+
type PatternKeyComparison = PatternKeyComparisonMap[keyof PatternKeyComparisonMap];
|
|
1858
1885
|
|
|
1859
1886
|
/**
|
|
1860
|
-
* @file
|
|
1861
|
-
* @module mlly/
|
|
1887
|
+
* @file Type Aliases - PatternMatch
|
|
1888
|
+
* @module mlly/types/PatternMatch
|
|
1862
1889
|
*/
|
|
1863
|
-
|
|
1864
1890
|
/**
|
|
1865
|
-
*
|
|
1891
|
+
* List, where the first item is the key of a package `exports` or `imports`
|
|
1892
|
+
* target object, and the last is a subpath pattern match.
|
|
1866
1893
|
*/
|
|
1867
|
-
|
|
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
|
-
}
|
|
1894
|
+
type PatternMatch = [expansionKey: string, patternMatch: string | null];
|
|
1885
1895
|
|
|
1886
1896
|
/**
|
|
1887
|
-
* @file
|
|
1888
|
-
* @module mlly/
|
|
1897
|
+
* @file Type Aliases - Protocol
|
|
1898
|
+
* @module mlly/types/Protocol
|
|
1889
1899
|
*/
|
|
1890
1900
|
|
|
1891
1901
|
/**
|
|
1892
|
-
*
|
|
1902
|
+
* Union of values that can occur where a URL protocol is expected.
|
|
1903
|
+
*
|
|
1904
|
+
* To register new protocols, augment {@linkcode ProtocolMap}.
|
|
1905
|
+
* They will be added to this union automatically.
|
|
1893
1906
|
*/
|
|
1894
|
-
|
|
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
|
-
}
|
|
1907
|
+
type Protocol = ProtocolMap[keyof ProtocolMap];
|
|
1908
1908
|
|
|
1909
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
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 };
|