@flex-development/mlly 1.0.0-beta.3 → 1.0.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +172 -89
  3. package/dist/index.d.mts +1885 -5
  4. package/dist/index.mjs +1 -5
  5. package/dist/internal/chain-or-call.d.mts +51 -0
  6. package/dist/internal/chain-or-call.mjs +1 -34
  7. package/dist/internal/chars.d.mts +16 -0
  8. package/dist/internal/chars.mjs +1 -17
  9. package/dist/internal/check-invalid-segments.d.mts +18 -0
  10. package/dist/internal/check-invalid-segments.mjs +1 -49
  11. package/dist/internal/constant.d.mts +21 -0
  12. package/dist/internal/constant.mjs +1 -23
  13. package/dist/internal/fs.browser.d.mts +12 -0
  14. package/dist/internal/fs.browser.mjs +1 -42
  15. package/dist/internal/fs.node.d.mts +12 -0
  16. package/dist/internal/fs.node.mjs +1 -16
  17. package/dist/internal/identity.d.mts +21 -0
  18. package/dist/internal/identity.mjs +1 -23
  19. package/dist/internal/invalid-package-target.d.mts +31 -0
  20. package/dist/internal/invalid-package-target.mjs +1 -36
  21. package/dist/internal/invalid-subpath.d.mts +32 -0
  22. package/dist/internal/invalid-subpath.mjs +1 -37
  23. package/dist/internal/is-promise.d.mts +21 -0
  24. package/dist/internal/is-promise.mjs +1 -26
  25. package/dist/internal/process.browser.d.mts +9 -0
  26. package/dist/internal/process.browser.mjs +1 -8
  27. package/dist/lib/can-parse-url.mjs +1 -31
  28. package/dist/lib/cwd.mjs +1 -17
  29. package/dist/lib/default-conditions.mjs +1 -14
  30. package/dist/lib/default-extensions.mjs +1 -29
  31. package/dist/lib/default-main-fields.mjs +1 -13
  32. package/dist/lib/extension-format-map.mjs +1 -31
  33. package/dist/lib/formats.mjs +1 -22
  34. package/dist/lib/get-source.mjs +1 -153
  35. package/dist/lib/index.mjs +1 -41
  36. package/dist/lib/is-absolute-specifier.mjs +1 -34
  37. package/dist/lib/is-array-index.mjs +1 -28
  38. package/dist/lib/is-bare-specifier.mjs +1 -33
  39. package/dist/lib/is-directory.mjs +1 -54
  40. package/dist/lib/is-file.mjs +1 -54
  41. package/dist/lib/is-imports-subpath.mjs +1 -28
  42. package/dist/lib/is-module-id.mjs +1 -24
  43. package/dist/lib/is-relative-specifier.mjs +1 -36
  44. package/dist/lib/lookup-package-scope.mjs +1 -102
  45. package/dist/lib/pattern-key-compare.mjs +1 -71
  46. package/dist/lib/pattern-match.mjs +1 -85
  47. package/dist/lib/read-package-json.mjs +1 -114
  48. package/dist/lib/resolve-alias.mjs +1 -102
  49. package/dist/lib/resolve-module.mjs +1 -186
  50. package/dist/lib/resolver.mjs +1 -1015
  51. package/dist/lib/root.mjs +1 -12
  52. package/dist/lib/to-relative-specifier.mjs +1 -63
  53. package/dist/lib/to-url.mjs +1 -34
  54. package/package.json +30 -12
  55. package/dist/interfaces/aliases.d.mts +0 -21
  56. package/dist/interfaces/buffer-encoding-map.d.mts +0 -29
  57. package/dist/interfaces/condition-map.d.mts +0 -24
  58. package/dist/interfaces/file-system.d.mts +0 -29
  59. package/dist/interfaces/get-source-context.d.mts +0 -44
  60. package/dist/interfaces/get-source-options.d.mts +0 -56
  61. package/dist/interfaces/index.d.mts +0 -22
  62. package/dist/interfaces/is-directory.d.mts +0 -17
  63. package/dist/interfaces/is-file.d.mts +0 -17
  64. package/dist/interfaces/main-field-map.d.mts +0 -22
  65. package/dist/interfaces/module-format-map.d.mts +0 -26
  66. package/dist/interfaces/pattern-key-comparison-map.d.mts +0 -31
  67. package/dist/interfaces/protocol-map.d.mts +0 -44
  68. package/dist/interfaces/read-file.d.mts +0 -43
  69. package/dist/interfaces/realpath.d.mts +0 -30
  70. package/dist/interfaces/resolve-alias-options.d.mts +0 -43
  71. package/dist/interfaces/resolve-module-options.d.mts +0 -79
  72. package/dist/interfaces/stat.d.mts +0 -28
  73. package/dist/interfaces/stats.d.mts +0 -23
  74. package/dist/lib/can-parse-url.d.mts +0 -23
  75. package/dist/lib/cwd.d.mts +0 -14
  76. package/dist/lib/default-conditions.d.mts +0 -15
  77. package/dist/lib/default-extensions.d.mts +0 -14
  78. package/dist/lib/default-main-fields.d.mts +0 -14
  79. package/dist/lib/extension-format-map.d.mts +0 -16
  80. package/dist/lib/formats.d.mts +0 -21
  81. package/dist/lib/get-source.d.mts +0 -46
  82. package/dist/lib/index.d.mts +0 -41
  83. package/dist/lib/is-absolute-specifier.d.mts +0 -23
  84. package/dist/lib/is-array-index.d.mts +0 -19
  85. package/dist/lib/is-bare-specifier.d.mts +0 -23
  86. package/dist/lib/is-directory.d.mts +0 -27
  87. package/dist/lib/is-file.d.mts +0 -27
  88. package/dist/lib/is-imports-subpath.d.mts +0 -26
  89. package/dist/lib/is-module-id.d.mts +0 -23
  90. package/dist/lib/is-relative-specifier.d.mts +0 -23
  91. package/dist/lib/lookup-package-scope.d.mts +0 -49
  92. package/dist/lib/pattern-key-compare.d.mts +0 -28
  93. package/dist/lib/pattern-match.d.mts +0 -22
  94. package/dist/lib/read-package-json.d.mts +0 -63
  95. package/dist/lib/resolve-alias.d.mts +0 -21
  96. package/dist/lib/resolve-module.d.mts +0 -43
  97. package/dist/lib/resolver.d.mts +0 -346
  98. package/dist/lib/root.d.mts +0 -11
  99. package/dist/lib/to-relative-specifier.d.mts +0 -27
  100. package/dist/lib/to-url.d.mts +0 -26
  101. package/dist/types/awaitable.d.mts +0 -12
  102. package/dist/types/buffer-encoding.d.mts +0 -13
  103. package/dist/types/change-ext-fn.d.mts +0 -29
  104. package/dist/types/condition.d.mts +0 -13
  105. package/dist/types/dot.d.mts +0 -9
  106. package/dist/types/empty-array.d.mts +0 -9
  107. package/dist/types/empty-object.d.mts +0 -19
  108. package/dist/types/empty-string.d.mts +0 -9
  109. package/dist/types/ext.d.mts +0 -12
  110. package/dist/types/file-content.d.mts +0 -11
  111. package/dist/types/get-source-handler.d.mts +0 -23
  112. package/dist/types/get-source-handlers.d.mts +0 -15
  113. package/dist/types/index.d.mts +0 -24
  114. package/dist/types/list.d.mts +0 -12
  115. package/dist/types/main-field.d.mts +0 -13
  116. package/dist/types/module-format.d.mts +0 -13
  117. package/dist/types/module-id.d.mts +0 -12
  118. package/dist/types/numeric.d.mts +0 -9
  119. package/dist/types/pattern-key-comparison.d.mts +0 -14
  120. package/dist/types/pattern-match.d.mts +0 -10
  121. package/dist/types/protocol.d.mts +0 -13
@@ -1,28 +0,0 @@
1
- /**
2
- * @file patternKeyCompare
3
- * @module mlly/lib/patternKeyCompare
4
- */
5
- import type { PatternKeyComparison } from '@flex-development/mlly';
6
- /**
7
- * Compare two pattern keys and return a value indicating their order.
8
- *
9
- * Implements the `PATTERN_KEY_COMPARE` algorithm.
10
- *
11
- * @see {@linkcode PatternKeyComparison}
12
- *
13
- * @this {void}
14
- *
15
- * @param {string} a
16
- * The first key
17
- * @param {string} b
18
- * The key to compare against `a`
19
- * @return {PatternKeyComparison}
20
- * The pattern key comparsion result
21
- */
22
- declare function patternKeyCompare(this: void, a: string, b: string): PatternKeyComparison;
23
- declare namespace patternKeyCompare {
24
- var EQUAL: 0;
25
- var GREATER_THAN: 1;
26
- var LESS_THAN: -1;
27
- }
28
- export default patternKeyCompare;
@@ -1,22 +0,0 @@
1
- /**
2
- * @file patternMatch
3
- * @module mlly/lib/patternMatch
4
- */
5
- import type { PatternMatch } from '@flex-development/mlly';
6
- /**
7
- * Get a subpath pattern match for `matchKey`.
8
- *
9
- * @see {@linkcode PatternMatch}
10
- *
11
- * @this {void}
12
- *
13
- * @param {string} matchKey
14
- * The key to expand
15
- * @param {unknown} matchObject
16
- * The match keys object
17
- * @return {PatternMatch | null}
18
- * List, where the first item is the key of a package exports
19
- * or imports target object, and the last is a subpath pattern match
20
- */
21
- declare function patternMatch(this: void, matchKey: string, matchObject: unknown): PatternMatch | null;
22
- export default patternMatch;
@@ -1,63 +0,0 @@
1
- /**
2
- * @file readPackageJson
3
- * @module mlly/lib/readPackageJson
4
- */
5
- import type { Awaitable, EmptyString, FileSystem, ModuleId } from '@flex-development/mlly';
6
- import type { PackageJson } from '@flex-development/pkg-types';
7
- export default readPackageJson;
8
- /**
9
- * Read a `package.json` file.
10
- *
11
- * @see {@linkcode EmptyString}
12
- *
13
- * @this {void}
14
- *
15
- * @param {EmptyString | null | undefined} id
16
- * The URL of the package directory, the `package.json` file,
17
- * or a module in the same directory as a `package.json`
18
- * @param {string | null | undefined} [specifier]
19
- * The module specifier that initiated the reading of the `package.json` file
20
- * > 👉 **Note**: Should be a `file:` URL if `parent` is not a URL
21
- * @param {ModuleId | null | undefined} [parent]
22
- * The URL of the parent module
23
- * @param {FileSystem | null | undefined} [fs]
24
- * The file system API
25
- * @return {null}
26
- * The parsed file contents
27
- */
28
- declare function readPackageJson(this: void, id: EmptyString | null | undefined, specifier?: string | null | undefined, parent?: ModuleId | null | undefined, fs?: FileSystem | null | undefined): null;
29
- /**
30
- * Read a `package.json` file.
31
- *
32
- * Implements the `READ_PACKAGE_JSON` algorithm.
33
- *
34
- * > 👉 **Note**: Returns a promise if `fs.readFile` or `fs.stat` is async.
35
- *
36
- * @see {@linkcode Awaitable}
37
- * @see {@linkcode ErrInvalidPackageConfig}
38
- * @see {@linkcode FileSystem}
39
- * @see {@linkcode ModuleId}
40
- * @see {@linkcode PackageJson}
41
- *
42
- * @template {Awaitable<PackageJson | null>} T
43
- * The parsed file contents
44
- *
45
- * @this {void}
46
- *
47
- * @param {ModuleId | null | undefined} id
48
- * The URL of the package directory, the `package.json` file,
49
- * or a module in the same directory as a `package.json`
50
- * @param {string | null | undefined} [specifier]
51
- * The module specifier that initiated the reading of the `package.json` file
52
- * > 👉 **Note**: Should be a `file:` URL if `parent` is not a URL
53
- * @param {ModuleId | null | undefined} [parent]
54
- * The URL of the parent module
55
- * @param {FileSystem | null | undefined} [fs]
56
- * The file system API
57
- * @return {T}
58
- * The parsed file contents
59
- * @throws {ErrInvalidPackageConfig}
60
- * If `package.json` file does not parse as valid JSON
61
- * or package manifest object is not a JSON object
62
- */
63
- declare function readPackageJson<T extends Awaitable<PackageJson | null>>(this: void, id: ModuleId | null | undefined, specifier?: string | null | undefined, parent?: ModuleId | null | undefined, fs?: FileSystem | null | undefined): T;
@@ -1,21 +0,0 @@
1
- /**
2
- * @file resolveAlias
3
- * @module mlly/lib/resolveAlias
4
- */
5
- import type { ResolveAliasOptions } from '@flex-development/mlly';
6
- export default resolveAlias;
7
- /**
8
- * Resolve an aliased `specifier`.
9
- *
10
- * @see {@linkcode ResolveAliasOptions}
11
- *
12
- * @this {void}
13
- *
14
- * @param {string} specifier
15
- * The specifier using an alias
16
- * @param {ResolveAliasOptions | null | undefined} [options]
17
- * Alias resolution options
18
- * @return {string | null}
19
- * The specifier of the aliased module
20
- */
21
- declare function resolveAlias(this: void, specifier: string, options?: ResolveAliasOptions | null | undefined): string | null;
@@ -1,43 +0,0 @@
1
- /**
2
- * @file resolveModule
3
- * @module mlly/lib/resolveModule
4
- */
5
- import type { Awaitable, ModuleId, ResolveModuleOptions } from '@flex-development/mlly';
6
- export default resolveModule;
7
- /**
8
- * Resolve a module `specifier`.
9
- *
10
- * Implements the `ESM_RESOLVE` algorithm, mostly 😉.
11
- *
12
- * Adds support for:
13
- *
14
- * - Changing file extensions
15
- * - Directory index resolution
16
- * - Extensionless file resolution
17
- * - Path alias resolution
18
- * - Scopeless `@types/*` resolution (i.e. `unist` -> `@types/unist`)
19
- *
20
- * > 👉 **Note**: Returns a promise if {@linkcode moduleResolve}
21
- * > returns a promise.
22
- *
23
- * @see {@linkcode Awaitable}
24
- * @see {@linkcode ModuleId}
25
- * @see {@linkcode NodeError}
26
- * @see {@linkcode ResolveModuleOptions}
27
- *
28
- * @template {Awaitable<URL>} T
29
- * The resolved URL
30
- *
31
- * @this {void}
32
- *
33
- * @param {string} specifier
34
- * The module specifier to resolve
35
- * @param {ModuleId} parent
36
- * The URL of the parent module
37
- * @param {ResolveModuleOptions | null | undefined} [options]
38
- * Module resolution options
39
- * @return {T}
40
- * The resolved URL
41
- * @throws {NodeError}
42
- */
43
- declare function resolveModule<T extends Awaitable<URL>>(this: void, specifier: string, parent: ModuleId, options?: ResolveModuleOptions | null | undefined): T;
@@ -1,346 +0,0 @@
1
- /**
2
- * @file resolver
3
- * @module mlly/lib/resolver
4
- */
5
- import type { Awaitable, Condition, FileSystem, List, MainField, ModuleId } from '@flex-development/mlly';
6
- import type { Exports, ExportsObject, Imports, PackageJson } from '@flex-development/pkg-types';
7
- declare module '@flex-development/errnode' {
8
- interface ErrUnsupportedDirImport {
9
- /**
10
- * The directory URL.
11
- */
12
- url?: string | null | undefined;
13
- }
14
- }
15
- export { legacyMainResolve, moduleResolve, packageExportsResolve, packageImportsExportsResolve, packageImportsResolve, packageResolve, packageSelfResolve, packageTargetResolve };
16
- /**
17
- * Resolve a [`main`][main]-like package entry point.
18
- *
19
- * Implements the `LEGACY_MAIN_RESOLVE` algorithm.
20
- *
21
- * > 👉 **Note**: Returns a promise if `fs.stat` is async.
22
- *
23
- * [main]: https://github.com/nodejs/node/blob/v22.9.0/doc/api/packages.md#main
24
- *
25
- * @see {@linkcode Awaitable}
26
- * @see {@linkcode ErrModuleNotFound}
27
- * @see {@linkcode FileSystem}
28
- * @see {@linkcode List}
29
- * @see {@linkcode MainField}
30
- * @see {@linkcode ModuleId}
31
- * @see {@linkcode PackageJson}
32
- *
33
- * @template {Awaitable<URL>} T
34
- * The resolved entry point URL
35
- *
36
- * @this {void}
37
- *
38
- * @param {ModuleId} packageUrl
39
- * The URL of the package directory, the `package.json` file,
40
- * or a module in the same directory as a `package.json`
41
- * @param {PackageJson | null | undefined} [manifest]
42
- * The package manifest
43
- * @param {List<MainField> | null | undefined} [mainFields]
44
- * The list of legacy main fields
45
- * @param {ModuleId | null | undefined} [parent]
46
- * The URL of the parent module
47
- * @param {FileSystem | null | undefined} [fs]
48
- * The file system API
49
- * @return {Awaitable<URL>}
50
- * The resolved entry point URL
51
- * @throws {ErrModuleNotFound}
52
- * If the entry point cannot be resolved
53
- */
54
- declare function legacyMainResolve<T extends Awaitable<URL>>(this: void, packageUrl: ModuleId, manifest?: PackageJson | null | undefined, mainFields?: List<MainField> | null | undefined, parent?: ModuleId | null | undefined, fs?: FileSystem | null | undefined): T;
55
- /**
56
- * Resolve a module `specifier`.
57
- *
58
- * Implements the `ESM_RESOLVE` algorithm.
59
- *
60
- * > 👉 **Note**: Returns a promise if `fs.realpath` or `fs.stat` is async,
61
- * > or one of the following methods returns a promise:
62
- * > {@linkcode packageImportsResolve}, {@linkcode packageResolve}.
63
- *
64
- * @see {@linkcode Awaitable}
65
- * @see {@linkcode Condition}
66
- * @see {@linkcode ErrInvalidModuleSpecifier}
67
- * @see {@linkcode ErrModuleNotFound}
68
- * @see {@linkcode ErrUnsupportedDirImport}
69
- * @see {@linkcode FileSystem}
70
- * @see {@linkcode List}
71
- * @see {@linkcode ModuleId}
72
- *
73
- * @template {Awaitable<URL>} T
74
- * The resolved URL
75
- *
76
- * @this {void}
77
- *
78
- * @param {string} specifier
79
- * The module specifier to resolve
80
- * @param {ModuleId} parent
81
- * The URL of the parent module
82
- * @param {List<Condition> | null | undefined} [conditions]
83
- * The list of export/import conditions
84
- * @param {List<MainField> | null | undefined} [mainFields]
85
- * The list of legacy main fields
86
- * @param {boolean | null | undefined} [preserveSymlinks]
87
- * Whether to keep symlinks instead of resolving them
88
- * @param {FileSystem | null | undefined} [fs]
89
- * The file system API
90
- * @return {T}
91
- * The resolved URL
92
- * @throws {ErrInvalidModuleSpecifier}
93
- * @throws {ErrModuleNotFound}
94
- * @throws {ErrUnsupportedDirImport}
95
- */
96
- declare function moduleResolve<T extends Awaitable<URL>>(this: void, specifier: string, parent: ModuleId, conditions?: List<Condition> | null | undefined, mainFields?: List<MainField> | null | undefined, preserveSymlinks?: boolean | null | undefined, fs?: FileSystem | null | undefined): T;
97
- /**
98
- * Resolve a package export.
99
- *
100
- * Implements the `PACKAGE_EXPORTS_RESOLVE` algorithm.
101
- *
102
- * > 👉 **Note**: Never returns a promise.
103
- *
104
- * @see {@linkcode Awaitable}
105
- * @see {@linkcode Condition}
106
- * @see {@linkcode ErrInvalidPackageConfig}
107
- * @see {@linkcode ErrPackagePathNotExported}
108
- * @see {@linkcode Exports}
109
- * @see {@linkcode FileSystem}
110
- * @see {@linkcode Imports}
111
- * @see {@linkcode List}
112
- * @see {@linkcode ModuleId}
113
- *
114
- * @template {Awaitable<URL>} T
115
- * The resolved package export URL
116
- *
117
- * @this {void}
118
- *
119
- * @param {ModuleId} packageUrl
120
- * The URL of the package directory, the `package.json` file,
121
- * or a module in the same directory as a `package.json`
122
- * @param {string} subpath
123
- * The package subpath
124
- * @param {Exports | undefined} exports
125
- * The package exports
126
- * @param {List<Condition> | null | undefined} [conditions]
127
- * The list of export/import conditions
128
- * @param {ModuleId | null | undefined} [parent]
129
- * The URL of the parent module
130
- * @param {FileSystem | null | undefined} [fs]
131
- * The file system API
132
- * @return {Awaitable<URL>}
133
- * The resolved package export URL
134
- * @throws {ErrInvalidPackageConfig}
135
- * @throws {ErrPackagePathNotExported}
136
- */
137
- declare function packageExportsResolve<T extends Awaitable<URL>>(this: void, packageUrl: ModuleId, subpath: string, // eslint-disable-next-line unicorn/prefer-module
138
- exports: Exports | undefined, conditions?: List<Condition> | null | undefined, parent?: ModuleId | null | undefined, fs?: FileSystem | null | undefined): T;
139
- /**
140
- * Resolve a package export or import.
141
- *
142
- * Implements the `PACKAGE_IMPORTS_EXPORTS_RESOLVE` algorithm.
143
- *
144
- * > 👉 **Note**: Returns a promise if {@linkcode packageTargetResolve}
145
- * > returns a promise.
146
- *
147
- * @see {@linkcode Awaitable}
148
- * @see {@linkcode Condition}
149
- * @see {@linkcode ExportsObject}
150
- * @see {@linkcode FileSystem}
151
- * @see {@linkcode Imports}
152
- * @see {@linkcode List}
153
- * @see {@linkcode ModuleId}
154
- *
155
- * @template {Awaitable<URL | null | undefined>} T
156
- * The resolved package export or import URL
157
- *
158
- * @this {void}
159
- *
160
- * @param {string} matchKey
161
- * The package subpath extracted from a module specifier,
162
- * or a dot character (`.`)
163
- * @param {ExportsObject | Imports | null | undefined} matchObject
164
- * The package exports or imports
165
- * @param {ModuleId} packageUrl
166
- * The URL of the directory containing the `package.json` file
167
- * @param {boolean | null | undefined} [isImports]
168
- * Whether `matchObject` is internal to the package
169
- * @param {List<Condition> | null | undefined} [conditions]
170
- * The list of export/import conditions
171
- * @param {List<MainField> | null | undefined} [mainFields]
172
- * The list of legacy main fields
173
- * @param {ModuleId | null | undefined} [parent]
174
- * The URL of the parent module
175
- * @param {FileSystem | null | undefined} [fs]
176
- * The file system API
177
- * @return {T}
178
- * The resolved package export or import URL
179
- */
180
- declare function packageImportsExportsResolve<T extends Awaitable<URL | null | undefined>>(this: void, matchKey: string, matchObject: ExportsObject | Imports | null | undefined, packageUrl: ModuleId, isImports?: boolean | null | undefined, conditions?: List<Condition> | null | undefined, mainFields?: List<MainField> | null | undefined, parent?: ModuleId | null | undefined, fs?: FileSystem | null | undefined): T;
181
- /**
182
- * Resolve a package import.
183
- *
184
- * Implements the `PACKAGE_IMPORTS_RESOLVE` algorithm.
185
- *
186
- * > 👉 **Note**: Returns a promise if {@linkcode lookupPackageScope},
187
- * > {@linkcode packageImportsExportsResolve}, or {@linkcode readPackageJson}
188
- * > returns a promise.
189
- *
190
- * @see {@linkcode Awaitable}
191
- * @see {@linkcode Condition}
192
- * @see {@linkcode ErrInvalidModuleSpecifier}
193
- * @see {@linkcode ErrPackageImportNotDefined}
194
- * @see {@linkcode FileSystem}
195
- * @see {@linkcode List}
196
- * @see {@linkcode ModuleId}
197
- *
198
- * @template {Awaitable<URL>} T
199
- * The resolved package import URL
200
- *
201
- * @this {void}
202
- *
203
- * @param {string} specifier
204
- * The import specifier to resolve
205
- * @param {ModuleId} parent
206
- * The URL of the parent module
207
- * @param {List<Condition> | null | undefined} [conditions]
208
- * The list of export/import conditions
209
- * @param {List<MainField> | null | undefined} [mainFields]
210
- * The list of legacy main fields
211
- * @param {FileSystem | null | undefined} [fs]
212
- * The file system API
213
- * @return {T}
214
- * The resolved package import URL
215
- * @throws {ErrInvalidModuleSpecifier}
216
- * @throws {ErrPackageImportNotDefined}
217
- */
218
- declare function packageImportsResolve<T extends Awaitable<URL>>(this: void, specifier: string, parent: ModuleId, conditions?: List<Condition> | null | undefined, mainFields?: List<MainField> | null | undefined, fs?: FileSystem | null | undefined): T;
219
- /**
220
- * Resolve a *bare specifier*.
221
- *
222
- * Implements the `PACKAGE_RESOLVE` algorithm.
223
- *
224
- * > *Bare specifiers* like `'some-package'` or `'some-package/shuffle'` refer
225
- * > to the main entry point of a package by package name, or a specific feature
226
- * > module within a package prefixed by the package name. Including the file
227
- * > extension is only necessary for packages without an [`"exports"`][exports]
228
- * > field.
229
- *
230
- * > 👉 **Note**: Returns a promise if `fs.stat` is async or one of the
231
- * > following methods returns a promise: {@linkcode legacyMainResolve},
232
- * > {@linkcode packageExportsResolve}, {@linkcode packageSelfResolve},
233
- * > {@linkcode readPackageJson}.
234
- *
235
- * [exports]: https://nodejs.org/api/packages.html#exports
236
- *
237
- * @see {@linkcode Awaitable}
238
- * @see {@linkcode Condition}
239
- * @see {@linkcode ErrInvalidModuleSpecifier}
240
- * @see {@linkcode ErrModuleNotFound}
241
- * @see {@linkcode FileSystem}
242
- * @see {@linkcode List}
243
- * @see {@linkcode MainField}
244
- * @see {@linkcode ModuleId}
245
- *
246
- * @template {Awaitable<URL>} T
247
- * The resolved package URL
248
- *
249
- * @this {void}
250
- *
251
- * @param {string} specifier
252
- * The package specifier
253
- * @param {ModuleId} parent
254
- * The URL of the parent module
255
- * @param {List<Condition> | null | undefined} [conditions]
256
- * The list of export conditions
257
- * @param {List<MainField> | null | undefined} [mainFields]
258
- * The list of legacy main fields
259
- * @param {FileSystem | null | undefined} [fs]
260
- * The file system API
261
- * @return {T}
262
- * The resolved package URL
263
- * @throws {ErrInvalidModuleSpecifier}
264
- * @throws {ErrModuleNotFound}
265
- */
266
- declare function packageResolve<T extends Awaitable<URL>>(this: void, specifier: string, parent: ModuleId, conditions?: List<Condition> | null | undefined, mainFields?: List<MainField> | null | undefined, fs?: FileSystem | null | undefined): T;
267
- /**
268
- * Resolve the self-import of a package.
269
- *
270
- * Implements the `PACKAGE_SELF_RESOLVE` algorithm.
271
- *
272
- * > 👉 **Note**: Returns a promise if {@linkcode lookupPackageScope},
273
- * > {@linkcode packageExportsResolve}, or {@linkcode readPackageJson}
274
- * > returns a promise.
275
- *
276
- * @see {@linkcode Awaitable}
277
- * @see {@linkcode Condition}
278
- * @see {@linkcode FileSystem}
279
- * @see {@linkcode List}
280
- * @see {@linkcode ModuleId}
281
- *
282
- * @template {Awaitable<URL | undefined>} T
283
- * The resolved package URL
284
- *
285
- * @this {void}
286
- *
287
- * @param {string} name
288
- * The package name
289
- * @param {string} subpath
290
- * The package subpath
291
- * @param {ModuleId} parent
292
- * The URL of the parent module
293
- * @param {List<Condition> | null | undefined} [conditions]
294
- * The list of export conditions
295
- * @param {FileSystem | null | undefined} [fs]
296
- * The file system API
297
- * @return {T}
298
- * The resolved package URL
299
- */
300
- declare function packageSelfResolve<T extends Awaitable<URL | undefined>>(this: void, name: string, subpath: string, parent: ModuleId, conditions?: List<Condition> | null | undefined, fs?: FileSystem | null | undefined): T;
301
- /**
302
- * Resolve a package target.
303
- *
304
- * Implements the `PACKAGE_TARGET_RESOLVE` algorithm.
305
- *
306
- * > 👉 **Note**: Returns a promise if `target` is internal to the package and
307
- * > {@linkcode packageResolve} returns a promise.
308
- *
309
- * @see {@linkcode Awaitable}
310
- * @see {@linkcode Condition}
311
- * @see {@linkcode ErrInvalidPackageConfig}
312
- * @see {@linkcode ErrInvalidPackageTarget}
313
- * @see {@linkcode FileSystem}
314
- * @see {@linkcode List}
315
- * @see {@linkcode ModuleId}
316
- * @see {@linkcode Target}
317
- *
318
- * @template {Awaitable<URL | null | undefined>} T
319
- * The resolved package target URL
320
- *
321
- * @this {void}
322
- *
323
- * @param {ModuleId} packageUrl
324
- * The URL of the directory containing the `package.json` file
325
- * @param {unknown} target
326
- * The package target (i.e. a `exports`/`imports` value)
327
- * @param {string} subpath
328
- * The package subpath (i.e. a `exports`/`imports` key)
329
- * @param {string | null | undefined} [patternMatch]
330
- * The `subpath` pattern match
331
- * @param {boolean | null | undefined} [isImports]
332
- * Whether `target` is internal to the package
333
- * @param {List<Condition> | null | undefined} [conditions]
334
- * The list of export/import conditions
335
- * @param {List<MainField> | null | undefined} [mainFields]
336
- * The list of legacy main fields
337
- * @param {ModuleId | null | undefined} [parent]
338
- * The URL of the parent module
339
- * @param {FileSystem | null | undefined} [fs]
340
- * The file system API
341
- * @return {T}
342
- * The resolved package target URL
343
- * @throws {ErrInvalidPackageConfig}
344
- * @throws {ErrInvalidPackageTarget}
345
- */
346
- 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;
@@ -1,11 +0,0 @@
1
- /**
2
- * @file root
3
- * @module mlly/lib/root
4
- */
5
- /**
6
- * The URL of the file system root.
7
- *
8
- * @const {URL} root
9
- */
10
- declare const root: URL;
11
- export default root;
@@ -1,27 +0,0 @@
1
- /**
2
- * @file toRelativeSpecifier
3
- * @module mlly/lib/toRelativeSpecifier
4
- */
5
- import type { ModuleId } from '@flex-development/mlly';
6
- /**
7
- * Turn `url` into a *relative specifier*.
8
- *
9
- * ::: info
10
- * The relative specifier will only have a file extension
11
- * if `specifier` also has an extension.
12
- * :::
13
- *
14
- * @see {@linkcode ModuleId}
15
- * @see https://nodejs.org/api/esm.html#terminology
16
- *
17
- * @this {void}
18
- *
19
- * @param {ModuleId} url
20
- * The `file:` URL to convert
21
- * @param {ModuleId} parent
22
- * The parent module id
23
- * @return {string}
24
- * The relative specifier
25
- */
26
- declare function toRelativeSpecifier(this: void, url: ModuleId, parent: ModuleId): string;
27
- export default toRelativeSpecifier;
@@ -1,26 +0,0 @@
1
- /**
2
- * @file toUrl
3
- * @module mlly/lib/toUrl
4
- */
5
- import type { ModuleId } from '@flex-development/mlly';
6
- /**
7
- * Convert `id` to a {@linkcode URL}.
8
- *
9
- * > 👉 **Note**: If `id` cannot be parsed as a `URL`, and is also not a
10
- * > [builtin module][builtin-module], it will be assumed to be a path and
11
- * > converted to a [`file:` URL][file-url].
12
- *
13
- * [builtin-module]: https://nodejs.org/api/esm.html#builtin-modules
14
- * [file-url]: https://nodejs.org/api/esm.html#file-urls
15
- *
16
- * @this {void}
17
- *
18
- * @param {ModuleId} id
19
- * The module id to convert
20
- * @param {ModuleId | null | undefined} [parent]
21
- * The base URL to resolve against if `id` is not absolute
22
- * @return {URL}
23
- * The new URL
24
- */
25
- declare function toUrl(this: void, id: ModuleId, parent?: ModuleId | null | undefined): URL;
26
- export default toUrl;
@@ -1,12 +0,0 @@
1
- /**
2
- * @file Type Aliases - Awaitable
3
- * @module mlly/types/Awaitable
4
- */
5
- /**
6
- * Create a union of `T` and `T` as a promise-like object.
7
- *
8
- * @template {any} T
9
- * The value
10
- */
11
- type Awaitable<T> = PromiseLike<T> | T;
12
- export type { Awaitable as default };
@@ -1,13 +0,0 @@
1
- /**
2
- * @file Type Aliases - BufferEncoding
3
- * @module mlly/types/BufferEncoding
4
- */
5
- import type { BufferEncodingMap } from '@flex-development/mlly';
6
- /**
7
- * Union of values that can occur where a buffer encoding is expected.
8
- *
9
- * To register new encodings, augment {@linkcode BufferEncodingMap}.
10
- * They will be added to this union automatically.
11
- */
12
- type BufferEncoding = BufferEncodingMap[keyof BufferEncodingMap];
13
- export type { BufferEncoding as default };
@@ -1,29 +0,0 @@
1
- /**
2
- * @file Type Aliases - ChangeExtFn
3
- * @module mlly/types/ChangeExtFn
4
- */
5
- /**
6
- * Get a new file extension for `url`.
7
- *
8
- * Returning an empty string (`''`), `null`, or `undefined` will remove the
9
- * current file extension.
10
- *
11
- * ::: info
12
- * The new file extension need not begin with a dot character (`'.'`).
13
- * :::
14
- *
15
- * @see {@linkcode URL}
16
- * @see https://github.com/flex-development/pathe/tree/1.0.3#changeextpath-string-ext-nullablestring-string
17
- *
18
- * @template {string | null | undefined} Ext
19
- * The new file extension
20
- *
21
- * @param {URL} url
22
- * The resolved module URL
23
- * @param {string} specifier
24
- * The module specifier being resolved
25
- * @return {Ext}
26
- * The new file extension
27
- */
28
- type ChangeExtFn<Ext extends string | null | undefined = string | null | undefined> = (this: void, url: URL, specifier: string) => Ext;
29
- export type { ChangeExtFn as default };
@@ -1,13 +0,0 @@
1
- /**
2
- * @file Type Aliases - Condition
3
- * @module mlly/types/Condition
4
- */
5
- import type { ConditionMap } from '@flex-development/mlly';
6
- /**
7
- * Union of values that can occur where a export/import condition is expected.
8
- *
9
- * To register new conditions, augment {@linkcode ConditionMap}.
10
- * They will be added to this union automatically.
11
- */
12
- type Condition = ConditionMap[keyof ConditionMap];
13
- export type { Condition as default };
@@ -1,9 +0,0 @@
1
- /**
2
- * @file Type Aliases - Dot
3
- * @module mlly/types/Dot
4
- */
5
- /**
6
- * A dot character (`'.'`).
7
- */
8
- type Dot = '.';
9
- export type { Dot as default };
@@ -1,9 +0,0 @@
1
- /**
2
- * @file Type Aliases - EmptyArray
3
- * @module mlly/types/EmptyArray
4
- */
5
- /**
6
- * An empty array.
7
- */
8
- type EmptyArray = [];
9
- export type { EmptyArray as default };