@flex-development/mlly 1.0.0-beta.5 → 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 +31 -0
- package/README.md +92 -36
- package/dist/index.d.mts +868 -845
- 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 +9 -7
- 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}
|
|
@@ -605,7 +1137,7 @@ declare function readPackageJson<T extends Awaitable<PackageJson | null>>(this:
|
|
|
605
1137
|
* @param {string} specifier
|
|
606
1138
|
* The specifier using an alias
|
|
607
1139
|
* @param {ResolveAliasOptions | null | undefined} [options]
|
|
608
|
-
*
|
|
1140
|
+
* Options for alias resolution
|
|
609
1141
|
* @return {string | null}
|
|
610
1142
|
* The specifier of the aliased module
|
|
611
1143
|
*/
|
|
@@ -641,17 +1173,17 @@ 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
|
|
648
1180
|
* @param {ResolveModuleOptions | null | undefined} [options]
|
|
649
|
-
*
|
|
1181
|
+
* Options for module resolution
|
|
650
1182
|
* @return {T}
|
|
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
|
|
@@ -992,896 +1524,387 @@ declare function packageSelfResolve<T extends Awaitable<URL | undefined>>(this:
|
|
|
992
1524
|
* The URL of the parent module
|
|
993
1525
|
* @param {FileSystem | null | undefined} [fs]
|
|
994
1526
|
* 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 - ChangeExtFn
|
|
1114
|
-
* @module mlly/types/ChangeExtFn
|
|
1115
|
-
*/
|
|
1116
|
-
/**
|
|
1117
|
-
* Get a new file extension for `url`.
|
|
1118
|
-
*
|
|
1119
|
-
* Returning an empty string (`''`), `null`, or `undefined` will remove the
|
|
1120
|
-
* current file extension.
|
|
1121
|
-
*
|
|
1122
|
-
* ::: info
|
|
1123
|
-
* The new file extension need not begin with a dot character (`'.'`).
|
|
1124
|
-
* :::
|
|
1125
|
-
*
|
|
1126
|
-
* @see {@linkcode URL}
|
|
1127
|
-
* @see https://github.com/flex-development/pathe/tree/1.0.3#changeextpath-string-ext-nullablestring-string
|
|
1128
|
-
*
|
|
1129
|
-
* @template {string | null | undefined} Ext
|
|
1130
|
-
* The new file extension
|
|
1131
|
-
*
|
|
1132
|
-
* @param {URL} url
|
|
1133
|
-
* The resolved module URL
|
|
1134
|
-
* @param {string} specifier
|
|
1135
|
-
* The module specifier being resolved
|
|
1136
|
-
* @return {Ext}
|
|
1137
|
-
* The new file extension
|
|
1138
|
-
*/
|
|
1139
|
-
type ChangeExtFn<Ext extends string | null | undefined = string | null | undefined> = (this: void, url: URL, specifier: string) => Ext;
|
|
1140
|
-
|
|
1141
|
-
/**
|
|
1142
|
-
* @file Type Aliases - Condition
|
|
1143
|
-
* @module mlly/types/Condition
|
|
1144
|
-
*/
|
|
1145
|
-
|
|
1146
|
-
/**
|
|
1147
|
-
* Union of values that can occur where a export/import condition is expected.
|
|
1148
|
-
*
|
|
1149
|
-
* To register new conditions, augment {@linkcode ConditionMap}.
|
|
1150
|
-
* They will be added to this union automatically.
|
|
1151
|
-
*/
|
|
1152
|
-
type Condition = ConditionMap[keyof ConditionMap];
|
|
1153
|
-
|
|
1154
|
-
/**
|
|
1155
|
-
* @file Type Aliases - Dot
|
|
1156
|
-
* @module mlly/types/Dot
|
|
1157
|
-
*/
|
|
1158
|
-
/**
|
|
1159
|
-
* A dot character (`'.'`).
|
|
1160
|
-
*/
|
|
1161
|
-
type Dot = '.';
|
|
1162
|
-
|
|
1163
|
-
/**
|
|
1164
|
-
* @file Type Aliases - EmptyArray
|
|
1165
|
-
* @module mlly/types/EmptyArray
|
|
1166
|
-
*/
|
|
1167
|
-
/**
|
|
1168
|
-
* An empty array.
|
|
1169
|
-
*/
|
|
1170
|
-
type EmptyArray = [];
|
|
1171
|
-
|
|
1172
|
-
/**
|
|
1173
|
-
* @file Type Aliases - EmptyObject
|
|
1174
|
-
* @module mlly/types/EmptyObject
|
|
1175
|
-
*/
|
|
1176
|
-
/**
|
|
1177
|
-
* The empty object symbol.
|
|
1178
|
-
*
|
|
1179
|
-
* @internal
|
|
1180
|
-
*
|
|
1181
|
-
* @const {symbol} tag
|
|
1182
|
-
*/
|
|
1183
|
-
declare const tag: unique symbol;
|
|
1184
|
-
/**
|
|
1185
|
-
* An empty object.
|
|
1186
|
-
*/
|
|
1187
|
-
type EmptyObject = {
|
|
1188
|
-
[tag]?: never;
|
|
1189
|
-
};
|
|
1190
|
-
|
|
1191
|
-
/**
|
|
1192
|
-
* @file Type Aliases - EmptyString
|
|
1193
|
-
* @module mlly/types/EmptyString
|
|
1194
|
-
*/
|
|
1195
|
-
/**
|
|
1196
|
-
* An empty string.
|
|
1197
|
-
*/
|
|
1198
|
-
type EmptyString = '';
|
|
1199
|
-
|
|
1200
|
-
/**
|
|
1201
|
-
* @file Type Aliases - Ext
|
|
1202
|
-
* @module mlly/types/Ext
|
|
1527
|
+
* @return {T}
|
|
1528
|
+
* The resolved package target URL
|
|
1529
|
+
* @throws {ErrInvalidPackageConfig}
|
|
1530
|
+
* @throws {ErrInvalidPackageTarget}
|
|
1203
1531
|
*/
|
|
1532
|
+
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;
|
|
1204
1533
|
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1534
|
+
declare const resolver_d_legacyMainResolve: typeof legacyMainResolve;
|
|
1535
|
+
declare const resolver_d_moduleResolve: typeof moduleResolve;
|
|
1536
|
+
declare const resolver_d_packageExportsResolve: typeof packageExportsResolve;
|
|
1537
|
+
declare const resolver_d_packageImportsExportsResolve: typeof packageImportsExportsResolve;
|
|
1538
|
+
declare const resolver_d_packageImportsResolve: typeof packageImportsResolve;
|
|
1539
|
+
declare const resolver_d_packageResolve: typeof packageResolve;
|
|
1540
|
+
declare const resolver_d_packageSelfResolve: typeof packageSelfResolve;
|
|
1541
|
+
declare const resolver_d_packageTargetResolve: typeof packageTargetResolve;
|
|
1542
|
+
declare namespace resolver_d {
|
|
1543
|
+
export {
|
|
1544
|
+
resolver_d_legacyMainResolve as legacyMainResolve,
|
|
1545
|
+
resolver_d_moduleResolve as moduleResolve,
|
|
1546
|
+
resolver_d_packageExportsResolve as packageExportsResolve,
|
|
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
|
+
}
|
|
1211
1554
|
|
|
1212
1555
|
/**
|
|
1213
|
-
* @file
|
|
1214
|
-
* @module mlly/
|
|
1556
|
+
* @file root
|
|
1557
|
+
* @module mlly/lib/root
|
|
1215
1558
|
*/
|
|
1216
1559
|
/**
|
|
1217
|
-
*
|
|
1560
|
+
* The URL of the file system root.
|
|
1218
1561
|
*
|
|
1219
|
-
* @
|
|
1562
|
+
* @const {URL} root
|
|
1220
1563
|
*/
|
|
1221
|
-
|
|
1564
|
+
declare const root: URL;
|
|
1222
1565
|
|
|
1223
1566
|
/**
|
|
1224
|
-
* @file
|
|
1225
|
-
* @module mlly/
|
|
1567
|
+
* @file toRelativeSpecifier
|
|
1568
|
+
* @module mlly/lib/toRelativeSpecifier
|
|
1226
1569
|
*/
|
|
1227
1570
|
|
|
1228
1571
|
/**
|
|
1229
|
-
*
|
|
1572
|
+
* Turn `url` into a *relative specifier*.
|
|
1230
1573
|
*
|
|
1231
|
-
*
|
|
1232
|
-
*
|
|
1233
|
-
*
|
|
1234
|
-
*
|
|
1574
|
+
* ::: info
|
|
1575
|
+
* The relative specifier will only have a file extension
|
|
1576
|
+
* if `specifier` also has an extension.
|
|
1577
|
+
* :::
|
|
1235
1578
|
*
|
|
1236
|
-
* @
|
|
1237
|
-
*
|
|
1579
|
+
* @see {@linkcode ModuleId}
|
|
1580
|
+
* @see https://nodejs.org/api/esm.html#terminology
|
|
1238
1581
|
*
|
|
1239
|
-
* @
|
|
1240
|
-
*
|
|
1241
|
-
* @
|
|
1242
|
-
* The
|
|
1582
|
+
* @this {void}
|
|
1583
|
+
*
|
|
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
|
|
1243
1590
|
*/
|
|
1244
|
-
|
|
1591
|
+
declare function toRelativeSpecifier(this: void, url: ModuleId, parent: ModuleId): string;
|
|
1245
1592
|
|
|
1246
1593
|
/**
|
|
1247
|
-
* @file
|
|
1248
|
-
* @module mlly/
|
|
1594
|
+
* @file toUrl
|
|
1595
|
+
* @module mlly/lib/toUrl
|
|
1249
1596
|
*/
|
|
1250
1597
|
|
|
1251
1598
|
/**
|
|
1252
|
-
*
|
|
1599
|
+
* Convert `id` to a {@linkcode URL}.
|
|
1253
1600
|
*
|
|
1254
|
-
*
|
|
1255
|
-
*
|
|
1256
|
-
|
|
1257
|
-
type GetSourceHandlers = {
|
|
1258
|
-
[H in Protocol]?: GetSourceHandler | null | undefined;
|
|
1259
|
-
};
|
|
1260
|
-
|
|
1261
|
-
/**
|
|
1262
|
-
* @file Type Aliases - List
|
|
1263
|
-
* @module mlly/types/List
|
|
1264
|
-
*/
|
|
1265
|
-
/**
|
|
1266
|
-
* A list.
|
|
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].
|
|
1267
1604
|
*
|
|
1268
|
-
*
|
|
1269
|
-
*
|
|
1270
|
-
*/
|
|
1271
|
-
type List<T = unknown> = ReadonlySet<T> | readonly T[];
|
|
1272
|
-
|
|
1273
|
-
/**
|
|
1274
|
-
* @file Type Aliases - MainField
|
|
1275
|
-
* @module mlly/types/MainField
|
|
1276
|
-
*/
|
|
1277
|
-
|
|
1278
|
-
/**
|
|
1279
|
-
* Union of values that can occur where a main field is expected.
|
|
1605
|
+
* [builtin-module]: https://nodejs.org/api/esm.html#builtin-modules
|
|
1606
|
+
* [file-url]: https://nodejs.org/api/esm.html#file-urls
|
|
1280
1607
|
*
|
|
1281
|
-
*
|
|
1282
|
-
* They will be added to this union automatically.
|
|
1283
|
-
*/
|
|
1284
|
-
type MainField = MainFieldMap[keyof MainFieldMap];
|
|
1285
|
-
|
|
1286
|
-
/**
|
|
1287
|
-
* @file Type Aliases - ModuleFormat
|
|
1288
|
-
* @module mlly/types/ModuleFormat
|
|
1289
|
-
*/
|
|
1290
|
-
|
|
1291
|
-
/**
|
|
1292
|
-
* Union of values that can occur where a module format is expected.
|
|
1608
|
+
* @this {void}
|
|
1293
1609
|
*
|
|
1294
|
-
*
|
|
1295
|
-
*
|
|
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
|
|
1296
1616
|
*/
|
|
1297
|
-
|
|
1617
|
+
declare function toUrl(this: void, id: ModuleId, parent?: ModuleId | null | undefined): URL;
|
|
1298
1618
|
|
|
1299
1619
|
/**
|
|
1300
|
-
* @file Type Aliases -
|
|
1301
|
-
* @module mlly/types/
|
|
1620
|
+
* @file Type Aliases - Awaitable
|
|
1621
|
+
* @module mlly/types/Awaitable
|
|
1302
1622
|
*/
|
|
1303
1623
|
/**
|
|
1304
|
-
*
|
|
1305
|
-
* ECMAScript (ES) module identifier is expected.
|
|
1624
|
+
* Create a union of `T` and `T` as a promise-like object.
|
|
1306
1625
|
*
|
|
1307
|
-
* @
|
|
1308
|
-
|
|
1309
|
-
type ModuleId = URL | string;
|
|
1310
|
-
|
|
1311
|
-
/**
|
|
1312
|
-
* @file Type Aliases - Numeric
|
|
1313
|
-
* @module mlly/types/Numeric
|
|
1314
|
-
*/
|
|
1315
|
-
/**
|
|
1316
|
-
* String containing only numbers (not including the leading `-` if negative).
|
|
1626
|
+
* @template {any} T
|
|
1627
|
+
* The value
|
|
1317
1628
|
*/
|
|
1318
|
-
type
|
|
1629
|
+
type Awaitable<T> = PromiseLike<T> | T;
|
|
1319
1630
|
|
|
1320
1631
|
/**
|
|
1321
|
-
* @file Type Aliases -
|
|
1322
|
-
* @module mlly/types/
|
|
1632
|
+
* @file Type Aliases - BufferEncoding
|
|
1633
|
+
* @module mlly/types/BufferEncoding
|
|
1323
1634
|
*/
|
|
1324
1635
|
|
|
1325
1636
|
/**
|
|
1326
|
-
* Union of values that can occur
|
|
1327
|
-
* where a `PATTERN_KEY_COMPARE` algorithm result is expected.
|
|
1637
|
+
* Union of values that can occur where a buffer encoding is expected.
|
|
1328
1638
|
*
|
|
1329
|
-
* To register new
|
|
1639
|
+
* To register new encodings, augment {@linkcode BufferEncodingMap}.
|
|
1330
1640
|
* They will be added to this union automatically.
|
|
1331
1641
|
*/
|
|
1332
|
-
type
|
|
1333
|
-
|
|
1334
|
-
/**
|
|
1335
|
-
* @file Type Aliases - PatternMatch
|
|
1336
|
-
* @module mlly/types/PatternMatch
|
|
1337
|
-
*/
|
|
1338
|
-
/**
|
|
1339
|
-
* List, where the first item is the key of a package `exports` or `imports`
|
|
1340
|
-
* target object, and the last is a subpath pattern match.
|
|
1341
|
-
*/
|
|
1342
|
-
type PatternMatch = [expansionKey: string, patternMatch: string | null];
|
|
1642
|
+
type BufferEncoding = BufferEncodingMap[keyof BufferEncodingMap];
|
|
1343
1643
|
|
|
1344
1644
|
/**
|
|
1345
|
-
* @file Type Aliases -
|
|
1346
|
-
* @module mlly/types/
|
|
1645
|
+
* @file Type Aliases - Condition
|
|
1646
|
+
* @module mlly/types/Condition
|
|
1347
1647
|
*/
|
|
1348
1648
|
|
|
1349
1649
|
/**
|
|
1350
|
-
* Union of values that can occur where a
|
|
1650
|
+
* Union of values that can occur where a export/import condition is expected.
|
|
1351
1651
|
*
|
|
1352
|
-
* To register new
|
|
1652
|
+
* To register new conditions, augment {@linkcode ConditionMap}.
|
|
1353
1653
|
* They will be added to this union automatically.
|
|
1354
1654
|
*/
|
|
1355
|
-
type
|
|
1356
|
-
|
|
1357
|
-
/**
|
|
1358
|
-
* @file Interfaces - FileSystem
|
|
1359
|
-
* @module mlly/interfaces/FileSystem
|
|
1360
|
-
*/
|
|
1655
|
+
type Condition = ConditionMap[keyof ConditionMap];
|
|
1361
1656
|
|
|
1362
1657
|
/**
|
|
1363
|
-
*
|
|
1658
|
+
* @file Type Aliases - Dot
|
|
1659
|
+
* @module mlly/types/Dot
|
|
1364
1660
|
*/
|
|
1365
|
-
interface FileSystem {
|
|
1366
|
-
/**
|
|
1367
|
-
* Read the entire contents of a file.
|
|
1368
|
-
*
|
|
1369
|
-
* @see {@linkcode ReadFile}
|
|
1370
|
-
*/
|
|
1371
|
-
readFile: ReadFile;
|
|
1372
|
-
/**
|
|
1373
|
-
* Compute a canonical pathname by resolving `.`, `..`, and symbolic links.
|
|
1374
|
-
*
|
|
1375
|
-
* @see {@linkcode Realpath}
|
|
1376
|
-
*/
|
|
1377
|
-
realpath: Realpath;
|
|
1378
|
-
/**
|
|
1379
|
-
* Get information about a directory or file.
|
|
1380
|
-
*
|
|
1381
|
-
* @see {@linkcode Stat}
|
|
1382
|
-
*/
|
|
1383
|
-
stat: Stat;
|
|
1384
|
-
}
|
|
1385
|
-
|
|
1386
1661
|
/**
|
|
1387
|
-
*
|
|
1388
|
-
* @module mlly/interfaces/GetSourceContext
|
|
1662
|
+
* A dot character (`'.'`).
|
|
1389
1663
|
*/
|
|
1664
|
+
type Dot = '.';
|
|
1390
1665
|
|
|
1391
1666
|
/**
|
|
1392
|
-
*
|
|
1393
|
-
*
|
|
1394
|
-
* @see {@linkcode GetSourceOptions}
|
|
1395
|
-
*
|
|
1396
|
-
* @extends {GetSourceOptions}
|
|
1667
|
+
* @file Type Aliases - EmptyArray
|
|
1668
|
+
* @module mlly/types/EmptyArray
|
|
1397
1669
|
*/
|
|
1398
|
-
interface GetSourceContext extends GetSourceOptions {
|
|
1399
|
-
/**
|
|
1400
|
-
* The file system API.
|
|
1401
|
-
*
|
|
1402
|
-
* @see {@linkcode FileSystem}
|
|
1403
|
-
*
|
|
1404
|
-
* @override
|
|
1405
|
-
*/
|
|
1406
|
-
fs: FileSystem;
|
|
1407
|
-
/**
|
|
1408
|
-
* Record, where each key is a URL protocol
|
|
1409
|
-
* and each value is a source code handler.
|
|
1410
|
-
*
|
|
1411
|
-
* @see {@linkcode GetSourceHandlers}
|
|
1412
|
-
*
|
|
1413
|
-
* @override
|
|
1414
|
-
*/
|
|
1415
|
-
handlers: GetSourceHandlers;
|
|
1416
|
-
/**
|
|
1417
|
-
* Request options for network based modules.
|
|
1418
|
-
*
|
|
1419
|
-
* @override
|
|
1420
|
-
*/
|
|
1421
|
-
req: RequestInit;
|
|
1422
|
-
/**
|
|
1423
|
-
* The list of supported URL schemes.
|
|
1424
|
-
*
|
|
1425
|
-
* @override
|
|
1426
|
-
*/
|
|
1427
|
-
schemes: Set<string>;
|
|
1428
|
-
}
|
|
1429
|
-
|
|
1430
1670
|
/**
|
|
1431
|
-
*
|
|
1432
|
-
* @module mlly/interfaces/GetSourceOptions
|
|
1671
|
+
* An empty array.
|
|
1433
1672
|
*/
|
|
1673
|
+
type EmptyArray = [];
|
|
1434
1674
|
|
|
1435
1675
|
/**
|
|
1436
|
-
*
|
|
1676
|
+
* @file Type Aliases - EmptyObject
|
|
1677
|
+
* @module mlly/types/EmptyObject
|
|
1437
1678
|
*/
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
format?: ModuleFormat | null | undefined;
|
|
1453
|
-
/**
|
|
1454
|
-
* The file system API.
|
|
1455
|
-
*
|
|
1456
|
-
* @see {@linkcode FileSystem}
|
|
1457
|
-
*/
|
|
1458
|
-
fs?: FileSystem | null | undefined;
|
|
1459
|
-
/**
|
|
1460
|
-
* Record, where each key is a URL protocol
|
|
1461
|
-
* and each value is a source code handler.
|
|
1462
|
-
*
|
|
1463
|
-
* @see {@linkcode GetSourceHandlers}
|
|
1464
|
-
*/
|
|
1465
|
-
handlers?: GetSourceHandlers | null | undefined;
|
|
1466
|
-
/**
|
|
1467
|
-
* Whether to ignore [`ERR_UNSUPPORTED_ESM_URL_SCHEME`][err] if thrown.
|
|
1468
|
-
*
|
|
1469
|
-
* [err]: https://nodejs.org/api/errors.html#err_unsupported_esm_url_scheme
|
|
1470
|
-
*/
|
|
1471
|
-
ignoreErrors?: boolean | null | undefined;
|
|
1472
|
-
/**
|
|
1473
|
-
* Request options for network based modules.
|
|
1474
|
-
*/
|
|
1475
|
-
req?: RequestInit | null | undefined;
|
|
1476
|
-
/**
|
|
1477
|
-
* The list of supported URL schemes.
|
|
1478
|
-
*
|
|
1479
|
-
* @see {@linkcode List}
|
|
1480
|
-
*
|
|
1481
|
-
* @default ['data','file','http','https','node']
|
|
1482
|
-
*/
|
|
1483
|
-
schemes?: List<string> | null | undefined;
|
|
1484
|
-
}
|
|
1679
|
+
/**
|
|
1680
|
+
* The empty object symbol.
|
|
1681
|
+
*
|
|
1682
|
+
* @internal
|
|
1683
|
+
*
|
|
1684
|
+
* @const {symbol} tag
|
|
1685
|
+
*/
|
|
1686
|
+
declare const tag: unique symbol;
|
|
1687
|
+
/**
|
|
1688
|
+
* An empty object.
|
|
1689
|
+
*/
|
|
1690
|
+
type EmptyObject = {
|
|
1691
|
+
[tag]?: never;
|
|
1692
|
+
};
|
|
1485
1693
|
|
|
1486
1694
|
/**
|
|
1487
|
-
* @file
|
|
1488
|
-
* @module mlly/
|
|
1695
|
+
* @file Type Aliases - EmptyString
|
|
1696
|
+
* @module mlly/types/EmptyString
|
|
1489
1697
|
*/
|
|
1490
1698
|
/**
|
|
1491
|
-
*
|
|
1699
|
+
* An empty string.
|
|
1492
1700
|
*/
|
|
1493
|
-
|
|
1494
|
-
/**
|
|
1495
|
-
* @this {unknown}
|
|
1496
|
-
*
|
|
1497
|
-
* @return {boolean}
|
|
1498
|
-
* `true` if stats describes directory, `false` otherwise
|
|
1499
|
-
*/
|
|
1500
|
-
(): boolean;
|
|
1501
|
-
}
|
|
1701
|
+
type EmptyString = '';
|
|
1502
1702
|
|
|
1503
1703
|
/**
|
|
1504
|
-
* @file
|
|
1505
|
-
* @module mlly/
|
|
1704
|
+
* @file Type Aliases - Ext
|
|
1705
|
+
* @module mlly/types/Ext
|
|
1506
1706
|
*/
|
|
1707
|
+
|
|
1507
1708
|
/**
|
|
1508
|
-
*
|
|
1709
|
+
* A file extension.
|
|
1710
|
+
*
|
|
1711
|
+
* @see {@linkcode Dot}
|
|
1509
1712
|
*/
|
|
1510
|
-
|
|
1511
|
-
/**
|
|
1512
|
-
* @this {void}
|
|
1513
|
-
*
|
|
1514
|
-
* @return {boolean}
|
|
1515
|
-
* `true` if stats object describes regular file, `false` otherwise
|
|
1516
|
-
*/
|
|
1517
|
-
(): boolean;
|
|
1518
|
-
}
|
|
1713
|
+
type Ext = `${Dot}${string}`;
|
|
1519
1714
|
|
|
1520
1715
|
/**
|
|
1521
|
-
* @file
|
|
1522
|
-
* @module mlly/
|
|
1716
|
+
* @file Type Aliases - ExtensionRewrites
|
|
1717
|
+
* @module mlly/types/ExtensionRewrites
|
|
1523
1718
|
*/
|
|
1719
|
+
|
|
1524
1720
|
/**
|
|
1525
|
-
*
|
|
1721
|
+
* Record, where each key is the file extension of a module specifier and
|
|
1722
|
+
* each value is a replacement file extension.
|
|
1526
1723
|
*
|
|
1527
|
-
*
|
|
1724
|
+
* > 👉 **Note**: Replacement file extensions are normalized and do not need to
|
|
1725
|
+
* > begin with a dot character (`'.'`); falsy values will remove an extension.
|
|
1528
1726
|
*
|
|
1529
|
-
* @
|
|
1530
|
-
*
|
|
1531
|
-
* interface MainFieldMap {
|
|
1532
|
-
* unpkg: 'unpkg'
|
|
1533
|
-
* }
|
|
1534
|
-
* }
|
|
1727
|
+
* @see {@linkcode EmptyString}
|
|
1728
|
+
* @see {@linkcode Ext}
|
|
1535
1729
|
*/
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
types: 'types';
|
|
1540
|
-
}
|
|
1730
|
+
type ExtensionRewrites = {
|
|
1731
|
+
[K in EmptyString | Ext]?: string | false | null | undefined;
|
|
1732
|
+
};
|
|
1541
1733
|
|
|
1542
1734
|
/**
|
|
1543
|
-
* @file
|
|
1544
|
-
* @module mlly/
|
|
1735
|
+
* @file Type Aliases - FileContent
|
|
1736
|
+
* @module mlly/types/FileContent
|
|
1545
1737
|
*/
|
|
1546
1738
|
/**
|
|
1547
|
-
*
|
|
1548
|
-
*
|
|
1549
|
-
* This interface can be augmented to register custom module formats.
|
|
1739
|
+
* Union of values that can occur where file content is expected.
|
|
1550
1740
|
*
|
|
1551
|
-
* @
|
|
1552
|
-
* declare module '@flex-development/mlly' {
|
|
1553
|
-
* interface ModuleFormatMap {
|
|
1554
|
-
* custom: 'custom'
|
|
1555
|
-
* }
|
|
1556
|
-
* }
|
|
1741
|
+
* @see {@linkcode Uint8Array}
|
|
1557
1742
|
*/
|
|
1558
|
-
|
|
1559
|
-
builtin: 'builtin';
|
|
1560
|
-
commonjs: 'commonjs';
|
|
1561
|
-
cts: 'commonjs-typescript';
|
|
1562
|
-
json: 'json';
|
|
1563
|
-
module: 'module';
|
|
1564
|
-
mts: 'module-typescript';
|
|
1565
|
-
wasm: 'wasm';
|
|
1566
|
-
}
|
|
1743
|
+
type FileContent = Uint8Array | string;
|
|
1567
1744
|
|
|
1568
1745
|
/**
|
|
1569
|
-
* @file
|
|
1570
|
-
* @module mlly/
|
|
1746
|
+
* @file Type Aliases - GetNewExtension
|
|
1747
|
+
* @module mlly/types/GetNewExtension
|
|
1571
1748
|
*/
|
|
1572
1749
|
/**
|
|
1573
|
-
*
|
|
1750
|
+
* Get a new file extension for a `url`.
|
|
1574
1751
|
*
|
|
1575
|
-
*
|
|
1752
|
+
* Returning an empty string (`''`), `false`, `null`, or `undefined`
|
|
1753
|
+
* will remove the current file extension.
|
|
1576
1754
|
*
|
|
1577
|
-
*
|
|
1578
|
-
*
|
|
1579
|
-
*
|
|
1580
|
-
*
|
|
1581
|
-
*
|
|
1582
|
-
*
|
|
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
|
|
1583
1772
|
*/
|
|
1584
|
-
|
|
1585
|
-
/**
|
|
1586
|
-
* `a` should come after `b`.
|
|
1587
|
-
*/
|
|
1588
|
-
after: 1;
|
|
1589
|
-
/**
|
|
1590
|
-
* `a` should come before `b`.
|
|
1591
|
-
*/
|
|
1592
|
-
before: -1;
|
|
1593
|
-
/**
|
|
1594
|
-
* `a` and `b` are equal.
|
|
1595
|
-
*/
|
|
1596
|
-
equal: 0;
|
|
1597
|
-
}
|
|
1773
|
+
type GetNewExtension<T extends string | false | null | undefined = string | false | null | undefined> = (this: void, url: URL, specifier: string) => T;
|
|
1598
1774
|
|
|
1599
1775
|
/**
|
|
1600
|
-
* @file
|
|
1601
|
-
* @module mlly/
|
|
1776
|
+
* @file Type Aliases - GetSourceHandler
|
|
1777
|
+
* @module mlly/types/GetSourceHandler
|
|
1602
1778
|
*/
|
|
1779
|
+
|
|
1603
1780
|
/**
|
|
1604
|
-
*
|
|
1781
|
+
* Get the source code for a module.
|
|
1605
1782
|
*
|
|
1606
|
-
*
|
|
1783
|
+
* @see {@linkcode Awaitable}
|
|
1784
|
+
* @see {@linkcode FileContent}
|
|
1785
|
+
* @see {@linkcode GetSourceContext}
|
|
1786
|
+
* @see {@linkcode URL}
|
|
1607
1787
|
*
|
|
1608
|
-
* @
|
|
1609
|
-
*
|
|
1610
|
-
* @see https://url.spec.whatwg.org/#special-scheme
|
|
1788
|
+
* @this {GetSourceContext}
|
|
1789
|
+
* The retrieval context
|
|
1611
1790
|
*
|
|
1612
|
-
* @
|
|
1613
|
-
*
|
|
1614
|
-
*
|
|
1615
|
-
*
|
|
1616
|
-
* }
|
|
1617
|
-
* }
|
|
1791
|
+
* @param {URL} url
|
|
1792
|
+
* The module URL
|
|
1793
|
+
* @return {Awaitable<FileContent | null | undefined>}
|
|
1794
|
+
* The source code
|
|
1618
1795
|
*/
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1796
|
+
type GetSourceHandler = (this: GetSourceContext, url: URL) => Awaitable<FileContent | null | undefined>;
|
|
1797
|
+
|
|
1798
|
+
/**
|
|
1799
|
+
* @file Type Aliases - GetSourceHandlers
|
|
1800
|
+
* @module mlly/types/GetSourceHandlers
|
|
1801
|
+
*/
|
|
1802
|
+
|
|
1803
|
+
/**
|
|
1804
|
+
* Record, where key is a URL protocol and each value is a source code handler.
|
|
1805
|
+
*
|
|
1806
|
+
* @see {@linkcode GetSourceHandler}
|
|
1807
|
+
* @see {@linkcode Protocol}
|
|
1808
|
+
*/
|
|
1809
|
+
type GetSourceHandlers = {
|
|
1810
|
+
[H in Protocol]?: GetSourceHandler | null | undefined;
|
|
1811
|
+
};
|
|
1812
|
+
|
|
1813
|
+
/**
|
|
1814
|
+
* @file Type Aliases - List
|
|
1815
|
+
* @module mlly/types/List
|
|
1816
|
+
*/
|
|
1817
|
+
/**
|
|
1818
|
+
* A list.
|
|
1819
|
+
*
|
|
1820
|
+
* @template {any} [T=unknown]
|
|
1821
|
+
* The list item type
|
|
1822
|
+
*/
|
|
1823
|
+
type List<T = unknown> = ReadonlySet<T> | readonly T[];
|
|
1642
1824
|
|
|
1643
1825
|
/**
|
|
1644
|
-
* @file
|
|
1645
|
-
* @module mlly/
|
|
1826
|
+
* @file Type Aliases - MainField
|
|
1827
|
+
* @module mlly/types/MainField
|
|
1646
1828
|
*/
|
|
1647
1829
|
|
|
1648
1830
|
/**
|
|
1649
|
-
*
|
|
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.
|
|
1650
1835
|
*/
|
|
1651
|
-
|
|
1652
|
-
/**
|
|
1653
|
-
* @see {@linkcode ModuleId}
|
|
1654
|
-
*
|
|
1655
|
-
* @this {unknown}
|
|
1656
|
-
*
|
|
1657
|
-
* @param {ModuleId} id
|
|
1658
|
-
* The module id
|
|
1659
|
-
* @param {BufferEncoding} encoding
|
|
1660
|
-
* The encoding of the file contents
|
|
1661
|
-
* @return {Awaitable<string>}
|
|
1662
|
-
* The file contents
|
|
1663
|
-
*/
|
|
1664
|
-
(id: ModuleId, encoding: BufferEncoding): Awaitable<string>;
|
|
1665
|
-
/**
|
|
1666
|
-
* @see {@linkcode Awaitable}
|
|
1667
|
-
* @see {@linkcode FileContent}
|
|
1668
|
-
* @see {@linkcode ModuleId}
|
|
1669
|
-
*
|
|
1670
|
-
* @template {Awaitable<FileContent | null | undefined>} T
|
|
1671
|
-
* The file contents
|
|
1672
|
-
*
|
|
1673
|
-
* @this {unknown}
|
|
1674
|
-
*
|
|
1675
|
-
* @param {ModuleId} id
|
|
1676
|
-
* The module id
|
|
1677
|
-
* @param {BufferEncoding | null | undefined} [encoding]
|
|
1678
|
-
* The encoding of the file contents
|
|
1679
|
-
* @return {T}
|
|
1680
|
-
* The file contents
|
|
1681
|
-
*/
|
|
1682
|
-
<T extends Awaitable<FileContent | null | undefined>>(id: ModuleId, encoding?: BufferEncoding | null | undefined): T;
|
|
1683
|
-
}
|
|
1836
|
+
type MainField = MainFieldMap[keyof MainFieldMap];
|
|
1684
1837
|
|
|
1685
1838
|
/**
|
|
1686
|
-
* @file
|
|
1687
|
-
* @module mlly/
|
|
1839
|
+
* @file Type Aliases - ModuleFormat
|
|
1840
|
+
* @module mlly/types/ModuleFormat
|
|
1688
1841
|
*/
|
|
1689
1842
|
|
|
1690
1843
|
/**
|
|
1691
|
-
*
|
|
1844
|
+
* Union of values that can occur where a module format is expected.
|
|
1692
1845
|
*
|
|
1693
|
-
*
|
|
1694
|
-
*
|
|
1846
|
+
* To register new formats, augment {@linkcode ModuleFormatMap}.
|
|
1847
|
+
* They will be added to this union automatically.
|
|
1695
1848
|
*/
|
|
1696
|
-
|
|
1697
|
-
/**
|
|
1698
|
-
* @see {@linkcode Awaitable}
|
|
1699
|
-
* @see {@linkcode ModuleId}
|
|
1700
|
-
*
|
|
1701
|
-
* @template {Awaitable<string>} T
|
|
1702
|
-
* The canonical pathname
|
|
1703
|
-
*
|
|
1704
|
-
* @this {unknown}
|
|
1705
|
-
*
|
|
1706
|
-
* @param {ModuleId} id
|
|
1707
|
-
* The module id
|
|
1708
|
-
* @return {T}
|
|
1709
|
-
* The canonical pathname
|
|
1710
|
-
*/
|
|
1711
|
-
<T extends Awaitable<string>>(id: ModuleId): T;
|
|
1712
|
-
}
|
|
1849
|
+
type ModuleFormat = ModuleFormatMap[keyof ModuleFormatMap];
|
|
1713
1850
|
|
|
1714
1851
|
/**
|
|
1715
|
-
* @file
|
|
1716
|
-
* @module mlly/
|
|
1852
|
+
* @file Type Aliases - ModuleId
|
|
1853
|
+
* @module mlly/types/ModuleId
|
|
1717
1854
|
*/
|
|
1718
|
-
|
|
1719
1855
|
/**
|
|
1720
|
-
*
|
|
1856
|
+
* Union of values that can occur where a
|
|
1857
|
+
* ECMAScript (ES) module identifier is expected.
|
|
1858
|
+
*
|
|
1859
|
+
* @see {@linkcode URL}
|
|
1721
1860
|
*/
|
|
1722
|
-
|
|
1723
|
-
/**
|
|
1724
|
-
* Whether the resolved specifier should be absolute.
|
|
1725
|
-
*
|
|
1726
|
-
* If `true`, the resolved specifier will be a [`file:` URL][file-url].
|
|
1727
|
-
*
|
|
1728
|
-
* [file-url]: https://nodejs.org/api/esm.html#file-urls
|
|
1729
|
-
*
|
|
1730
|
-
* @see https://nodejs.org/api/esm.html#terminology
|
|
1731
|
-
*/
|
|
1732
|
-
absolute?: boolean | null | undefined;
|
|
1733
|
-
/**
|
|
1734
|
-
* The path mappings dictionary.
|
|
1735
|
-
*
|
|
1736
|
-
* > 👉 **Note**: Paths should be relative to {@linkcode cwd}.
|
|
1737
|
-
*
|
|
1738
|
-
* @see {@linkcode Aliases}
|
|
1739
|
-
*/
|
|
1740
|
-
aliases?: Aliases | null | undefined;
|
|
1741
|
-
/**
|
|
1742
|
-
* The URL of the directory to resolve non-absolute modules from.
|
|
1743
|
-
*
|
|
1744
|
-
* @see {@linkcode ModuleId}
|
|
1745
|
-
*
|
|
1746
|
-
* @default cwd()
|
|
1747
|
-
*/
|
|
1748
|
-
cwd?: ModuleId | null | undefined;
|
|
1749
|
-
/**
|
|
1750
|
-
* The URL of the parent module.
|
|
1751
|
-
*
|
|
1752
|
-
* @see {@linkcode ModuleId}
|
|
1753
|
-
*/
|
|
1754
|
-
parent?: ModuleId | null | undefined;
|
|
1755
|
-
}
|
|
1861
|
+
type ModuleId = URL | string;
|
|
1756
1862
|
|
|
1757
1863
|
/**
|
|
1758
|
-
* @file
|
|
1759
|
-
* @module mlly/
|
|
1864
|
+
* @file Type Aliases - Numeric
|
|
1865
|
+
* @module mlly/types/Numeric
|
|
1866
|
+
*/
|
|
1867
|
+
/**
|
|
1868
|
+
* String containing only numbers (not including the leading `-` if negative).
|
|
1760
1869
|
*/
|
|
1870
|
+
type Numeric = `${number}`;
|
|
1761
1871
|
|
|
1762
1872
|
/**
|
|
1763
|
-
*
|
|
1873
|
+
* @file Type Aliases - PatternKeyComparison
|
|
1874
|
+
* @module mlly/types/PatternKeyComparison
|
|
1764
1875
|
*/
|
|
1765
|
-
interface ResolveModuleOptions {
|
|
1766
|
-
/**
|
|
1767
|
-
* The path mappings dictionary.
|
|
1768
|
-
*
|
|
1769
|
-
* > 👉 **Note**: Paths should be relative to {@linkcode cwd}.
|
|
1770
|
-
*
|
|
1771
|
-
* @see {@linkcode Aliases}
|
|
1772
|
-
*/
|
|
1773
|
-
aliases?: Aliases | null | undefined;
|
|
1774
|
-
/**
|
|
1775
|
-
* The list of export/import conditions.
|
|
1776
|
-
*
|
|
1777
|
-
* > 👉 **Note**: Should be sorted by priority.
|
|
1778
|
-
*
|
|
1779
|
-
* @see {@linkcode Condition}
|
|
1780
|
-
* @see {@linkcode List}
|
|
1781
|
-
* @see https://nodejs.org/api/packages.html#conditional-exports
|
|
1782
|
-
*
|
|
1783
|
-
* @default defaultConditions
|
|
1784
|
-
*/
|
|
1785
|
-
conditions?: List<Condition> | null | undefined;
|
|
1786
|
-
/**
|
|
1787
|
-
* The URL of the directory to resolve path {@linkcode aliases} from.
|
|
1788
|
-
*
|
|
1789
|
-
* @see {@linkcode ModuleId}
|
|
1790
|
-
*
|
|
1791
|
-
* @default cwd()
|
|
1792
|
-
*/
|
|
1793
|
-
cwd?: ModuleId | null | undefined;
|
|
1794
|
-
/**
|
|
1795
|
-
* A replacement file extension or a function that returns a file extension.
|
|
1796
|
-
*
|
|
1797
|
-
* > 👉 **Note**: An empty string (`''`) or `null` will
|
|
1798
|
-
* > remove a file extension.
|
|
1799
|
-
*
|
|
1800
|
-
* @see {@linkcode ChangeExtFn}
|
|
1801
|
-
*/
|
|
1802
|
-
ext?: ChangeExtFn | string | null | undefined;
|
|
1803
|
-
/**
|
|
1804
|
-
* The module extensions to probe for.
|
|
1805
|
-
*
|
|
1806
|
-
* > 👉 **Note**: Should be sorted by priority.
|
|
1807
|
-
*
|
|
1808
|
-
* @see {@linkcode List}
|
|
1809
|
-
*
|
|
1810
|
-
* @default defaultExtensions
|
|
1811
|
-
*/
|
|
1812
|
-
extensions?: List<string> | null | undefined;
|
|
1813
|
-
/**
|
|
1814
|
-
* The file system API.
|
|
1815
|
-
*
|
|
1816
|
-
* @see {@linkcode FileSystem}
|
|
1817
|
-
*/
|
|
1818
|
-
fs?: FileSystem | null | undefined;
|
|
1819
|
-
/**
|
|
1820
|
-
* The list of legacy `main` fields.
|
|
1821
|
-
*
|
|
1822
|
-
* > 👉 **Note**: Should be sorted by priority.
|
|
1823
|
-
*
|
|
1824
|
-
* @see {@linkcode List}
|
|
1825
|
-
* @see {@linkcode MainField}
|
|
1826
|
-
*
|
|
1827
|
-
* @default defaultMainFields
|
|
1828
|
-
*/
|
|
1829
|
-
mainFields?: List<MainField> | null | undefined;
|
|
1830
|
-
/**
|
|
1831
|
-
* Whether to keep symlinks instead of resolving them.
|
|
1832
|
-
*/
|
|
1833
|
-
preserveSymlinks?: boolean | null | undefined;
|
|
1834
|
-
}
|
|
1835
1876
|
|
|
1836
1877
|
/**
|
|
1837
|
-
*
|
|
1838
|
-
*
|
|
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.
|
|
1839
1883
|
*/
|
|
1884
|
+
type PatternKeyComparison = PatternKeyComparisonMap[keyof PatternKeyComparisonMap];
|
|
1840
1885
|
|
|
1841
1886
|
/**
|
|
1842
|
-
*
|
|
1887
|
+
* @file Type Aliases - PatternMatch
|
|
1888
|
+
* @module mlly/types/PatternMatch
|
|
1843
1889
|
*/
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
*
|
|
1850
|
-
* @template {Awaitable<Stats>} T
|
|
1851
|
-
* The info
|
|
1852
|
-
*
|
|
1853
|
-
* @this {unknown}
|
|
1854
|
-
*
|
|
1855
|
-
* @param {ModuleId} id
|
|
1856
|
-
* The module id
|
|
1857
|
-
* @return {T}
|
|
1858
|
-
* The info
|
|
1859
|
-
*/
|
|
1860
|
-
<T extends Awaitable<Stats>>(id: ModuleId): T;
|
|
1861
|
-
}
|
|
1890
|
+
/**
|
|
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.
|
|
1893
|
+
*/
|
|
1894
|
+
type PatternMatch = [expansionKey: string, patternMatch: string | null];
|
|
1862
1895
|
|
|
1863
1896
|
/**
|
|
1864
|
-
* @file
|
|
1865
|
-
* @module mlly/
|
|
1897
|
+
* @file Type Aliases - Protocol
|
|
1898
|
+
* @module mlly/types/Protocol
|
|
1866
1899
|
*/
|
|
1867
1900
|
|
|
1868
1901
|
/**
|
|
1869
|
-
*
|
|
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.
|
|
1870
1906
|
*/
|
|
1871
|
-
|
|
1872
|
-
/**
|
|
1873
|
-
* Check if the stats object describes a directory.
|
|
1874
|
-
*
|
|
1875
|
-
* @see {@linkcode IsDirectory}
|
|
1876
|
-
*/
|
|
1877
|
-
isDirectory: IsDirectory;
|
|
1878
|
-
/**
|
|
1879
|
-
* Check if the stats object describes a file.
|
|
1880
|
-
*
|
|
1881
|
-
* @see {@linkcode IsFile}
|
|
1882
|
-
*/
|
|
1883
|
-
isFile: IsFile;
|
|
1884
|
-
}
|
|
1907
|
+
type Protocol = ProtocolMap[keyof ProtocolMap];
|
|
1885
1908
|
|
|
1886
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 };
|
|
1887
|
-
export type { Aliases, Awaitable, BufferEncoding, BufferEncodingMap,
|
|
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 };
|