@flex-development/mlly 1.0.0-alpha.5 → 1.0.0-alpha.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.
Files changed (263) hide show
  1. package/CHANGELOG.md +200 -0
  2. package/README.md +1 -1
  3. package/changelog.config.ts +404 -0
  4. package/dist/enums/assert-type.d.mts +21 -0
  5. package/dist/enums/assert-type.mjs +10 -0
  6. package/dist/enums/assert-type.mjs.map +6 -0
  7. package/dist/enums/format.d.mts +17 -0
  8. package/dist/enums/format.mjs +13 -0
  9. package/dist/enums/format.mjs.map +6 -0
  10. package/dist/enums/index.d.mts +4 -1
  11. package/dist/enums/index.mjs +13 -6
  12. package/dist/enums/index.mjs.map +6 -0
  13. package/dist/enums/kind-specifier-syntax.d.mts +14 -0
  14. package/dist/enums/kind-specifier-syntax.mjs +10 -0
  15. package/dist/enums/kind-specifier-syntax.mjs.map +6 -0
  16. package/dist/enums/kind-specifier.d.mts +6 -3
  17. package/dist/enums/kind-specifier.mjs +4 -2
  18. package/dist/enums/kind-specifier.mjs.map +6 -0
  19. package/dist/enums/{kind-syntax.d.mts → kind-statement-syntax.d.mts} +4 -4
  20. package/dist/enums/kind-statement-syntax.mjs +18 -0
  21. package/dist/enums/kind-statement-syntax.mjs.map +6 -0
  22. package/dist/enums/kind-statement.mjs +1 -0
  23. package/dist/enums/kind-statement.mjs.map +6 -0
  24. package/dist/index.d.mts +1 -2
  25. package/dist/index.mjs +2 -2
  26. package/dist/index.mjs.map +6 -0
  27. package/dist/interfaces/import-assertions.d.mts +20 -0
  28. package/dist/interfaces/import-dynamic.d.mts +4 -2
  29. package/dist/interfaces/import-static.d.mts +4 -2
  30. package/dist/interfaces/index.d.mts +12 -0
  31. package/dist/interfaces/index.mjs +1 -0
  32. package/dist/interfaces/index.mjs.map +6 -0
  33. package/dist/interfaces/options-fill-module.d.mts +23 -0
  34. package/dist/interfaces/options-find-subpath.d.mts +49 -0
  35. package/dist/interfaces/options-get-format.d.mts +83 -0
  36. package/dist/interfaces/options-get-source.d.mts +63 -0
  37. package/dist/interfaces/options-parse-module-id.d.mts +33 -0
  38. package/dist/interfaces/options-parse-subpath.d.mts +31 -0
  39. package/dist/interfaces/options-resolve-alias.d.mts +26 -42
  40. package/dist/interfaces/options-resolve-module.d.mts +64 -0
  41. package/dist/interfaces/options-resolve.d.mts +7 -53
  42. package/dist/interfaces/package-scope.d.mts +25 -0
  43. package/dist/interfaces/parsed-data-url.d.mts +56 -0
  44. package/dist/interfaces/parsed-module-id.d.mts +80 -0
  45. package/dist/interfaces/parsed-subpath.d.mts +40 -0
  46. package/dist/interfaces/statement-import.d.mts +2 -2
  47. package/dist/interfaces/statement-require.d.mts +2 -2
  48. package/dist/interfaces/statement.d.mts +10 -5
  49. package/dist/internal/escape-reg-exp.d.mts +16 -0
  50. package/dist/internal/escape-reg-exp.mjs +10 -0
  51. package/dist/internal/escape-reg-exp.mjs.map +6 -0
  52. package/dist/internal/format-type-map.d.mts +17 -0
  53. package/dist/internal/format-type-map.mjs +13 -0
  54. package/dist/internal/format-type-map.mjs.map +6 -0
  55. package/dist/internal/get-specifier-kind.d.mts +17 -0
  56. package/dist/internal/get-specifier-kind.mjs +14 -0
  57. package/dist/internal/get-specifier-kind.mjs.map +6 -0
  58. package/dist/internal/get-subpaths.d.mts +25 -0
  59. package/dist/internal/get-subpaths.mjs +10 -0
  60. package/dist/internal/get-subpaths.mjs.map +6 -0
  61. package/dist/internal/is-array-index.d.mts +15 -0
  62. package/dist/internal/is-array-index.mjs +9 -0
  63. package/dist/internal/is-array-index.mjs.map +6 -0
  64. package/dist/internal/is-directory.d.mts +13 -0
  65. package/dist/internal/is-directory.mjs +16 -0
  66. package/dist/internal/is-directory.mjs.map +6 -0
  67. package/dist/internal/is-file.d.mts +13 -0
  68. package/dist/internal/is-file.mjs +16 -0
  69. package/dist/internal/is-file.mjs.map +6 -0
  70. package/dist/internal/is-function.d.mts +12 -0
  71. package/dist/internal/is-function.mjs +8 -0
  72. package/dist/internal/is-function.mjs.map +6 -0
  73. package/dist/internal/regex-encoded-sep.d.mts +13 -0
  74. package/dist/internal/regex-encoded-sep.mjs +6 -0
  75. package/dist/internal/regex-encoded-sep.mjs.map +6 -0
  76. package/dist/internal/regex-internal-specifier.d.mts +14 -0
  77. package/dist/internal/regex-internal-specifier.mjs +6 -0
  78. package/dist/internal/regex-internal-specifier.mjs.map +6 -0
  79. package/dist/internal/regex-package-name.d.mts +13 -0
  80. package/dist/internal/regex-package-name.mjs +6 -0
  81. package/dist/internal/regex-package-name.mjs.map +6 -0
  82. package/dist/internal/regex-package-path.d.mts +15 -0
  83. package/dist/internal/regex-package-path.mjs +6 -0
  84. package/dist/internal/regex-package-path.mjs.map +6 -0
  85. package/dist/internal/resolver.d.mts +130 -0
  86. package/dist/internal/resolver.mjs +486 -0
  87. package/dist/internal/resolver.mjs.map +6 -0
  88. package/dist/internal/validate-boolean.d.mts +20 -0
  89. package/dist/internal/validate-boolean.mjs +11 -0
  90. package/dist/internal/validate-boolean.mjs.map +6 -0
  91. package/dist/internal/validate-object.d.mts +23 -0
  92. package/dist/internal/validate-object.mjs +11 -0
  93. package/dist/internal/validate-object.mjs.map +6 -0
  94. package/dist/internal/validate-set.d.mts +23 -0
  95. package/dist/internal/validate-set.mjs +11 -0
  96. package/dist/internal/validate-set.mjs.map +6 -0
  97. package/dist/internal/validate-string.d.mts +20 -0
  98. package/dist/internal/validate-string.mjs +11 -0
  99. package/dist/internal/validate-string.mjs.map +6 -0
  100. package/dist/internal/validate-url-string.d.mts +22 -0
  101. package/dist/internal/validate-url-string.mjs +12 -0
  102. package/dist/internal/validate-url-string.mjs.map +6 -0
  103. package/dist/types/fn-change-ext.d.mts +28 -0
  104. package/dist/types/index.d.mts +4 -1
  105. package/dist/types/index.mjs +1 -0
  106. package/dist/types/index.mjs.map +6 -0
  107. package/dist/types/mime-type.d.mts +7 -5
  108. package/dist/types/module-id.d.mts +13 -0
  109. package/dist/types/protocol.d.mts +14 -0
  110. package/dist/types/syntax-kind-export.d.mts +3 -3
  111. package/dist/types/syntax-kind-import.d.mts +3 -3
  112. package/dist/types/syntax-kind-require.d.mts +3 -3
  113. package/dist/utils/compare-subpaths.d.mts +25 -0
  114. package/dist/utils/compare-subpaths.mjs +24 -0
  115. package/dist/utils/compare-subpaths.mjs.map +6 -0
  116. package/dist/utils/conditions.d.mts +13 -0
  117. package/dist/utils/conditions.mjs +6 -0
  118. package/dist/utils/conditions.mjs.map +6 -0
  119. package/dist/{lib → utils}/detect-syntax.d.mts +1 -1
  120. package/dist/{lib → utils}/detect-syntax.mjs +1 -0
  121. package/dist/utils/detect-syntax.mjs.map +6 -0
  122. package/dist/utils/extension-format-map.d.mts +16 -0
  123. package/dist/utils/extension-format-map.mjs +22 -0
  124. package/dist/utils/extension-format-map.mjs.map +6 -0
  125. package/dist/{lib → utils}/extract-statements.d.mts +2 -1
  126. package/dist/{lib → utils}/extract-statements.mjs +3 -0
  127. package/dist/utils/extract-statements.mjs.map +6 -0
  128. package/dist/utils/fill-modules.d.mts +23 -0
  129. package/dist/utils/fill-modules.mjs +62 -0
  130. package/dist/utils/fill-modules.mjs.map +6 -0
  131. package/dist/{lib → utils}/find-dynamic-imports.d.mts +4 -3
  132. package/dist/{lib → utils}/find-dynamic-imports.mjs +14 -4
  133. package/dist/utils/find-dynamic-imports.mjs.map +6 -0
  134. package/dist/{lib → utils}/find-exports.d.mts +4 -3
  135. package/dist/{lib → utils}/find-exports.mjs +29 -12
  136. package/dist/utils/find-exports.mjs.map +6 -0
  137. package/dist/{lib → utils}/find-requires.d.mts +4 -3
  138. package/dist/{lib → utils}/find-requires.mjs +14 -4
  139. package/dist/utils/find-requires.mjs.map +6 -0
  140. package/dist/{lib → utils}/find-static-imports.d.mts +4 -3
  141. package/dist/utils/find-static-imports.mjs +34 -0
  142. package/dist/utils/find-static-imports.mjs.map +6 -0
  143. package/dist/utils/find-subpath.d.mts +30 -0
  144. package/dist/utils/find-subpath.mjs +106 -0
  145. package/dist/utils/find-subpath.mjs.map +6 -0
  146. package/dist/utils/get-format.d.mts +24 -0
  147. package/dist/utils/get-format.mjs +111 -0
  148. package/dist/utils/get-format.mjs.map +6 -0
  149. package/dist/utils/get-source.d.mts +22 -0
  150. package/dist/utils/get-source.mjs +63 -0
  151. package/dist/utils/get-source.mjs.map +6 -0
  152. package/dist/{lib → utils}/has-cjs-syntax.d.mts +2 -1
  153. package/dist/{lib → utils}/has-cjs-syntax.mjs +3 -0
  154. package/dist/utils/has-cjs-syntax.mjs.map +6 -0
  155. package/dist/{lib → utils}/has-esm-syntax.d.mts +2 -1
  156. package/dist/{lib → utils}/has-esm-syntax.mjs +3 -0
  157. package/dist/utils/has-esm-syntax.mjs.map +6 -0
  158. package/dist/utils/index.d.mts +42 -0
  159. package/dist/utils/index.mjs +79 -0
  160. package/dist/utils/index.mjs.map +6 -0
  161. package/dist/utils/is-absolute-specifier.d.mts +19 -0
  162. package/dist/utils/is-absolute-specifier.mjs +25 -0
  163. package/dist/utils/is-absolute-specifier.mjs.map +6 -0
  164. package/dist/utils/is-bare-specifier.d.mts +19 -0
  165. package/dist/utils/is-bare-specifier.mjs +10 -0
  166. package/dist/utils/is-bare-specifier.mjs.map +6 -0
  167. package/dist/utils/is-exports-sugar.d.mts +25 -0
  168. package/dist/utils/is-exports-sugar.mjs +26 -0
  169. package/dist/utils/is-exports-sugar.mjs.map +6 -0
  170. package/dist/utils/is-relative-specifier.d.mts +20 -0
  171. package/dist/utils/is-relative-specifier.mjs +11 -0
  172. package/dist/utils/is-relative-specifier.mjs.map +6 -0
  173. package/dist/utils/lookup-package-scope.d.mts +24 -0
  174. package/dist/utils/lookup-package-scope.mjs +34 -0
  175. package/dist/utils/lookup-package-scope.mjs.map +6 -0
  176. package/dist/utils/parse-data-url.d.mts +25 -0
  177. package/dist/utils/parse-data-url.mjs +25 -0
  178. package/dist/utils/parse-data-url.mjs.map +6 -0
  179. package/dist/utils/parse-module-id.d.mts +22 -0
  180. package/dist/utils/parse-module-id.mjs +122 -0
  181. package/dist/utils/parse-module-id.mjs.map +6 -0
  182. package/dist/utils/parse-subpath.d.mts +35 -0
  183. package/dist/utils/parse-subpath.mjs +54 -0
  184. package/dist/utils/parse-subpath.mjs.map +6 -0
  185. package/dist/utils/pattern-character.d.mts +11 -0
  186. package/dist/utils/pattern-character.mjs +6 -0
  187. package/dist/utils/pattern-character.mjs.map +6 -0
  188. package/dist/utils/read-package-json.d.mts +26 -0
  189. package/dist/utils/read-package-json.mjs +43 -0
  190. package/dist/utils/read-package-json.mjs.map +6 -0
  191. package/dist/utils/resolve-alias.d.mts +20 -0
  192. package/dist/utils/resolve-alias.mjs +106 -0
  193. package/dist/utils/resolve-alias.mjs.map +6 -0
  194. package/dist/{lib → utils}/resolve-aliases.d.mts +7 -5
  195. package/dist/utils/resolve-aliases.mjs +28 -0
  196. package/dist/utils/resolve-aliases.mjs.map +6 -0
  197. package/dist/utils/resolve-extensions.d.mts +14 -0
  198. package/dist/utils/resolve-extensions.mjs +22 -0
  199. package/dist/utils/resolve-extensions.mjs.map +6 -0
  200. package/dist/utils/resolve-module.d.mts +39 -0
  201. package/dist/utils/resolve-module.mjs +64 -0
  202. package/dist/utils/resolve-module.mjs.map +6 -0
  203. package/dist/utils/resolve-modules.d.mts +25 -0
  204. package/dist/utils/resolve-modules.mjs +26 -0
  205. package/dist/utils/resolve-modules.mjs.map +6 -0
  206. package/dist/{lib → utils}/to-absolute-specifier.d.mts +6 -6
  207. package/dist/utils/to-absolute-specifier.mjs +8 -0
  208. package/dist/utils/to-absolute-specifier.mjs.map +6 -0
  209. package/dist/utils/to-bare-specifier.d.mts +42 -0
  210. package/dist/utils/to-bare-specifier.mjs +90 -0
  211. package/dist/utils/to-bare-specifier.mjs.map +6 -0
  212. package/dist/{lib → utils}/to-data-url.d.mts +6 -5
  213. package/dist/{lib → utils}/to-data-url.mjs +4 -0
  214. package/dist/utils/to-data-url.mjs.map +6 -0
  215. package/dist/utils/to-node-url.d.mts +19 -0
  216. package/dist/utils/to-node-url.mjs +10 -0
  217. package/dist/utils/to-node-url.mjs.map +6 -0
  218. package/dist/{lib → utils}/to-relative-specifier.d.mts +6 -6
  219. package/dist/{lib → utils}/to-relative-specifier.mjs +6 -2
  220. package/dist/utils/to-relative-specifier.mjs.map +6 -0
  221. package/dist/utils/to-url.d.mts +22 -0
  222. package/dist/utils/to-url.mjs +12 -0
  223. package/dist/utils/to-url.mjs.map +6 -0
  224. package/dist/utils/validate-assertions.d.mts +23 -0
  225. package/dist/utils/validate-assertions.mjs +52 -0
  226. package/dist/utils/validate-assertions.mjs.map +6 -0
  227. package/dist/utils/validate-exports.d.mts +24 -0
  228. package/dist/utils/validate-exports.mjs +72 -0
  229. package/dist/utils/validate-exports.mjs.map +6 -0
  230. package/package.json +67 -63
  231. package/changelog.config.cts +0 -204
  232. package/dist/constants.d.mts +0 -21
  233. package/dist/constants.mjs +0 -24
  234. package/dist/enums/kind-syntax.mjs +0 -17
  235. package/dist/interfaces/import-dynamic.mjs +0 -0
  236. package/dist/interfaces/import-static.mjs +0 -0
  237. package/dist/interfaces/options-resolve-alias.mjs +0 -0
  238. package/dist/interfaces/options-resolve.mjs +0 -0
  239. package/dist/interfaces/statement-export.mjs +0 -0
  240. package/dist/interfaces/statement-import.mjs +0 -0
  241. package/dist/interfaces/statement-require.mjs +0 -0
  242. package/dist/interfaces/statement.mjs +0 -0
  243. package/dist/internal/get-compiler-options.d.mts +0 -21
  244. package/dist/internal/get-compiler-options.mjs +0 -14
  245. package/dist/lib/find-static-imports.mjs +0 -25
  246. package/dist/lib/index.d.mts +0 -20
  247. package/dist/lib/index.mjs +0 -34
  248. package/dist/lib/resolve-alias.d.mts +0 -20
  249. package/dist/lib/resolve-alias.mjs +0 -41
  250. package/dist/lib/resolve-aliases.mjs +0 -34
  251. package/dist/lib/resolve-module.d.mts +0 -31
  252. package/dist/lib/resolve-module.mjs +0 -74
  253. package/dist/lib/resolve-modules.d.mts +0 -19
  254. package/dist/lib/resolve-modules.mjs +0 -30
  255. package/dist/lib/to-absolute-specifier.mjs +0 -20
  256. package/dist/lib/to-bare-specifier.d.mts +0 -28
  257. package/dist/lib/to-bare-specifier.mjs +0 -78
  258. package/dist/types/declaration.mjs +0 -0
  259. package/dist/types/mime-type.mjs +0 -0
  260. package/dist/types/module-specifier-type.mjs +0 -0
  261. package/dist/types/syntax-kind-export.mjs +0 -0
  262. package/dist/types/syntax-kind-import.mjs +0 -0
  263. package/dist/types/syntax-kind-require.mjs +0 -0
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @file Interfaces - ParseSubpathOptions
3
+ * @module mlly/interfaces/ParseSubpathOptions
4
+ */
5
+ import type { ModuleId } from '../types/index.mjs';
6
+ /**
7
+ * Subpath parsing options.
8
+ *
9
+ * @see {@linkcode ModuleId}
10
+ */
11
+ interface ParseSubpathOptions {
12
+ /**
13
+ * URL of directory containing relevant `package.json` file.
14
+ */
15
+ dir: ModuleId;
16
+ /**
17
+ * Package [`imports`][1] hint.
18
+ *
19
+ * [1]: https://nodejs.org/api/packages.html#imports
20
+ *
21
+ * @default specifier.startsWith('#')
22
+ */
23
+ internal?: boolean | undefined;
24
+ /**
25
+ * URL of module to resolve from.
26
+ *
27
+ * **Note**: Used for error reporting only.
28
+ */
29
+ parent: ModuleId;
30
+ }
31
+ export type { ParseSubpathOptions as default };
@@ -2,68 +2,52 @@
2
2
  * @file Interfaces - ResolveAliasOptions
3
3
  * @module mlly/interfaces/ResolveAliasOptions
4
4
  */
5
- import type { OneOrMany } from '@flex-development/tutils';
5
+ import type { ModuleId } from '../types/index.mjs';
6
+ import type { MapLike, OneOrMany } from '@flex-development/tutils';
7
+ import type ResolveModuleOptions from './options-resolve-module.mjs';
6
8
  /**
7
9
  * Path alias resolution options.
8
10
  *
9
- * @see https://github.com/dividab/tsconfig-paths
11
+ * @see {@linkcode ModuleId}
12
+ *
13
+ * @extends {ResolveModuleOptions}
10
14
  */
11
- interface ResolveAliasOptions {
12
- /**
13
- * Base directory to resolve non-absolute module names.
14
- *
15
- * @see https://www.typescriptlang.org/tsconfig#baseUrl
16
- *
17
- * @default process.cwd()
18
- */
19
- baseUrl?: string | undefined;
15
+ interface ResolveAliasOptions extends ResolveModuleOptions {
20
16
  /**
21
- * Module extensions to probe for.
22
- *
23
- * **Note**: Should be sorted by priority.
17
+ * Return resolved module URL as absolute specifier (a [`file:` URL][1]).
24
18
  *
25
- * @default RESOLVE_EXTENSIONS
26
- */
27
- extensions?: string[] | readonly string[] | undefined;
28
- /**
29
- * Checks for the existence of a file at `path`.
19
+ * If `false`, return resolved module URL as bare or relative specifier.
30
20
  *
31
- * @param {string} path - Path to check
32
- * @return {boolean} `true` if file exists, `false` otherwise
33
- */
34
- fileExists?(this: void, path: string): boolean;
35
- /**
36
- * `package.json` fields to check when resolving modules.
21
+ * [1]: https://nodejs.org/api/esm.html#file-urls
37
22
  *
38
- * A nested field can be selected by passing an array of field names.
23
+ * @see https://nodejs.org/api/esm.html#terminology
39
24
  *
40
- * @default ['main', 'module']
41
- */
42
- mainFields?: OneOrMany<string>[] | undefined;
43
- /**
44
- * Absolute path to file containing path alias.
25
+ * @default true
45
26
  */
46
- parent?: string | undefined;
27
+ absolute?: boolean | undefined;
47
28
  /**
48
29
  * Path mappings.
49
30
  *
50
- * **Note**: Should be relative to {@linkcode baseUrl}.
51
- *
52
- * @see https://www.typescriptlang.org/tsconfig#paths
31
+ * **Note**: Paths should be relative to {@linkcode cwd}.
53
32
  *
54
33
  * @default {}
55
34
  */
56
- paths?: Record<string, string[]> | undefined;
35
+ aliases?: MapLike<OneOrMany<string>> | undefined;
57
36
  /**
58
- * Synchronously returns the contents of `filename`.
37
+ * Directory to resolve non-absolute modules from.
59
38
  *
60
- * @param {string} filename - Filename
61
- * @return {string} Contents of `filename`
39
+ * @default pathToFileURL('.')
62
40
  */
63
- readFile?(this: void, filename: string): string;
41
+ cwd?: ModuleId | undefined;
64
42
  /**
65
- * Absolute path to tsconfig file.
43
+ * Id of module to resolve from.
44
+ *
45
+ * **Note**: Should be an absolute path or [`file:` URL][1].
46
+ *
47
+ * [1]: https://nodejs.org/api/esm.html#file-urls
48
+ *
49
+ * @default import.meta.url
66
50
  */
67
- tsconfig?: string | undefined;
51
+ parent?: ModuleId | undefined;
68
52
  }
69
53
  export type { ResolveAliasOptions as default };
@@ -0,0 +1,64 @@
1
+ /**
2
+ * @file Interfaces - ResolveModuleOptions
3
+ * @module mlly/interfaces/ResolveModuleOptions
4
+ */
5
+ import type { ChangeExtFn, ModuleId } from '../types/index.mjs';
6
+ import type { Nilable } from '@flex-development/tutils';
7
+ /**
8
+ * Module resolution options.
9
+ *
10
+ * @see {@linkcode ChangeExtFn}
11
+ * @see {@linkcode ModuleId}
12
+ */
13
+ interface ResolveModuleOptions {
14
+ /**
15
+ * Export condition to apply.
16
+ *
17
+ * @see https://nodejs.org/api/packages.html#conditional-exports
18
+ *
19
+ * @default 'default'
20
+ */
21
+ condition?: string | undefined;
22
+ /**
23
+ * Export conditions.
24
+ *
25
+ * **Note**: Should be sorted by priority.
26
+ *
27
+ * @see https://nodejs.org/api/packages.html#conditional-exports
28
+ *
29
+ * @default CONDITIONS
30
+ */
31
+ conditions?: Set<string> | string[] | undefined;
32
+ /**
33
+ * Replacement file extension or function that returns a file extension.
34
+ *
35
+ * An empty string (`''`) will remove a file extension; `null` or `undefined`
36
+ * will skip extension replacement.
37
+ *
38
+ * @default undefined
39
+ */
40
+ ext?: ChangeExtFn | Nilable<string>;
41
+ /**
42
+ * Module extensions to probe for.
43
+ *
44
+ * **Note**: Should be sorted by priority.
45
+ *
46
+ * @default RESOLVE_EXTENSIONS
47
+ */
48
+ extensions?: Set<string> | string[] | undefined;
49
+ /**
50
+ * URL of module to resolve from.
51
+ *
52
+ * @see {@linkcode ModuleId}
53
+ *
54
+ * @default import.meta.url
55
+ */
56
+ parent?: ModuleId | undefined;
57
+ /**
58
+ * Keep symlinks instead of resolving them.
59
+ *
60
+ * @default false
61
+ */
62
+ preserveSymlinks?: boolean | undefined;
63
+ }
64
+ export type { ResolveModuleOptions as default };
@@ -2,60 +2,14 @@
2
2
  * @file Interfaces - ResolveOptions
3
3
  * @module mlly/interfaces/ResolveOptions
4
4
  */
5
- /// <reference types="node" />
6
- import type { ModuleSpecifierType } from '../types/index.mjs';
7
- import type { Ext } from '@flex-development/pathe';
8
- import type { EmptyString } from '@flex-development/tutils';
9
- import type { URL } from 'node:url';
5
+ import type ResolveModuleOptions from './options-resolve-module.mjs';
10
6
  /**
11
- * Module resolution options.
7
+ * Resolution options.
8
+ *
9
+ * @see {@linkcode ResolveModuleOptions}
10
+ *
11
+ * @extends {ResolveModuleOptions}
12
12
  */
13
- interface ResolveOptions {
14
- /**
15
- * Export conditions.
16
- *
17
- * **Note**: Should be sorted by priority.
18
- *
19
- * @see https://nodejs.org/api/packages.html#conditional-exports
20
- *
21
- * @default CONDITIONS
22
- */
23
- conditions?: Set<string> | string[] | readonly string[] | undefined;
24
- /**
25
- * Remove or replace file extension.
26
- *
27
- * **Note**: {@linkcode type} must be set to `relative`.
28
- *
29
- * @see {@linkcode Ext}
30
- */
31
- ext?: Ext | false | ((specifier: string, resolved: string) => EmptyString | Ext | PromiseLike<EmptyString | Ext>) | undefined;
32
- /**
33
- * Module extensions to probe for.
34
- *
35
- * **Note**: Should be sorted by priority.
36
- *
37
- * @default RESOLVE_EXTENSIONS
38
- */
39
- extensions?: string[] | readonly string[] | undefined;
40
- /**
41
- * Parent module URL or path to resolve from.
42
- *
43
- * @default import.meta.url
44
- */
45
- parent?: URL | string | undefined;
46
- /**
47
- * Keep symlinks instead of resolving them.
48
- *
49
- * @default false
50
- */
51
- preserveSymlinks?: boolean | undefined;
52
- /**
53
- * Module specifier type or a function to determine module specifier type.
54
- *
55
- * @see {@linkcode ModuleSpecifierType}
56
- *
57
- * @default 'absolute'
58
- */
59
- type?: ModuleSpecifierType | ((resolved: string) => ModuleSpecifierType | PromiseLike<ModuleSpecifierType>) | undefined;
13
+ interface ResolveOptions extends ResolveModuleOptions {
60
14
  }
61
15
  export type { ResolveOptions as default };
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @file Interfaces - PackageScope
3
+ * @module mlly/interfaces/PackageScope
4
+ */
5
+ import type { PackageJson } from '@flex-development/pkg-types';
6
+ /**
7
+ * Object representing a package scope.
8
+ *
9
+ * @see {@linkcode PackageJson}
10
+ */
11
+ interface PackageScope {
12
+ /**
13
+ * URL of directory containing `package.json` file.
14
+ */
15
+ dir: string;
16
+ /**
17
+ * URL of `package.json` file.
18
+ */
19
+ pkg: string;
20
+ /**
21
+ * `package.json` object.
22
+ */
23
+ pkgjson: PackageJson;
24
+ }
25
+ export type { PackageScope as default };
@@ -0,0 +1,56 @@
1
+ /**
2
+ * @file Interfaces - ParsedDataUrl
3
+ * @module mlly/interfaces/ParsedDataUrl
4
+ */
5
+ /// <reference types="node" />
6
+ import type { MimeType, Protocol } from '../types/index.mjs';
7
+ import type { EmptyString, LiteralUnion } from '@flex-development/tutils';
8
+ import type { URL } from 'node:url';
9
+ /**
10
+ * Object representing a [`data:` URL][1].
11
+ *
12
+ * [1]: https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URLs
13
+ *
14
+ * @see {@linkcode Protocol}
15
+ * @see {@linkcode MimeType}
16
+ * @see https://nodejs.org/api/esm.html#data-imports
17
+ */
18
+ interface ParsedDataUrl {
19
+ /**
20
+ * [base64][1] encoding check.
21
+ *
22
+ * [1]: https://developer.mozilla.org/docs/Glossary/Base64
23
+ */
24
+ base64: boolean;
25
+ /**
26
+ * Data portion of URL.
27
+ *
28
+ * If {@linkcode base64} is `true`, `data` is base64-encoded.
29
+ */
30
+ data: LiteralUnion<EmptyString, string>;
31
+ /**
32
+ * Serialized `data:` URL.
33
+ *
34
+ * @see https://nodejs.org/api/url.html#urlhref
35
+ */
36
+ href: URL['href'];
37
+ /**
38
+ * MIME type.
39
+ *
40
+ * @see https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/MIME_types
41
+ */
42
+ mime: LiteralUnion<MimeType, string>;
43
+ /**
44
+ * Path portion of URL.
45
+ *
46
+ * @see https://nodejs.org/api/url.html#urlpathname
47
+ */
48
+ pathname: URL['pathname'];
49
+ /**
50
+ * Protocol portion of URL.
51
+ *
52
+ * @see https://nodejs.org/api/url.html#urlprotocol
53
+ */
54
+ protocol: Extract<Protocol, 'data:'>;
55
+ }
56
+ export type { ParsedDataUrl as default };
@@ -0,0 +1,80 @@
1
+ /**
2
+ * @file Interfaces - ParsedModuleId
3
+ * @module mlly/interfaces/ParsedModuleId
4
+ */
5
+ import type { Protocol } from '../types/index.mjs';
6
+ import type { SemanticVersion } from '@flex-development/pkg-types';
7
+ import type { EmptyString, LiteralUnion } from '@flex-development/tutils';
8
+ /**
9
+ * Object representing a ECMAScript module id.
10
+ *
11
+ * @see {@linkcode Protocol}
12
+ * @see {@linkcode SemanticVersion}
13
+ */
14
+ interface ParsedModuleId {
15
+ /**
16
+ * Subpath import (internal specifier) check.
17
+ *
18
+ * @see https://nodejs.org/api/packages.html#imports
19
+ * @see https://nodejs.org/api/packages.html#subpath-imports
20
+ */
21
+ internal: boolean;
22
+ /**
23
+ * One of the following:
24
+ *
25
+ * - Possible [subpath export][1] (includes leading `'.'`)
26
+ * - Possible [subpath import][2]
27
+ * - URL [`host`][3], [`pathname`][4], and [`port`][5]
28
+ * - Raw module id ({@linkcode raw})
29
+ *
30
+ * [1]: https://nodejs.org/api/packages.html#subpath-exports
31
+ * [2]: https://nodejs.org/api/packages.html#subpath-imports
32
+ * [3]: https://nodejs.org/api/url.html#urlhost
33
+ * [4]: https://nodejs.org/api/url.html#urlpathname
34
+ * [5]: https://nodejs.org/api/url.html#urlport
35
+ */
36
+ path: string;
37
+ /**
38
+ * Package name if module id begins with valid package name (e.g. is a [bare
39
+ * specifier][1]).
40
+ *
41
+ * If the module id is a bare specifier *and* [internal][2], this value will
42
+ * instead be the first path segement in the module id (i.e. `'#src'` given
43
+ * `'#src/foo'`). This **may or may not** be the subpath defined by the
44
+ * package maintainer.
45
+ *
46
+ * [1]: https://nodejs.org/api/esm.html#terminology
47
+ * [2]: https://nodejs.org/api/packages.html#subpath-imports
48
+ */
49
+ pkg: LiteralUnion<EmptyString, string>;
50
+ /**
51
+ * URL scheme if module id is a URL.
52
+ */
53
+ protocol: LiteralUnion<EmptyString | Protocol, string>;
54
+ /**
55
+ * Raw module id.
56
+ */
57
+ raw: string;
58
+ /**
59
+ * Package scope if module id begins with valid package name (e.g. is a [bare
60
+ * specifier][1]).
61
+ *
62
+ * [1]: https://nodejs.org/api/esm.html#terminology
63
+ */
64
+ scope: LiteralUnion<EmptyString, string>;
65
+ /**
66
+ * Package version if specified and module id begins with valid package name
67
+ * (e.g. is a [bare specifier][1]).
68
+ *
69
+ * **Note**: Version follows [Semantic Versioning 2.0.0][2] specification.
70
+ *
71
+ * [1]: https://nodejs.org/api/esm.html#terminology
72
+ * [2]: https://semver.org/spec/v2.0.0.html
73
+ */
74
+ version: LiteralUnion<EmptyString | SemanticVersion, string>;
75
+ /**
76
+ * Package {@linkcode version} prefix.
77
+ */
78
+ version_prefix: LiteralUnion<EmptyString | 'v', string>;
79
+ }
80
+ export type { ParsedModuleId as default };
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @file Interfaces - ParsedSubpath
3
+ * @module mlly/interfaces/ParsedSubpath
4
+ */
5
+ import type { EmptyString, LiteralUnion } from '@flex-development/tutils';
6
+ /**
7
+ * Object representing a package subpath.
8
+ *
9
+ * @see https://nodejs.org/api/packages.html#subpath-exports
10
+ * @see https://nodejs.org/api/packages.html#subpath-imports
11
+ */
12
+ interface ParsedSubpath {
13
+ /**
14
+ * Subpath without entry prefix ({@linkcode key}).
15
+ */
16
+ base: LiteralUnion<EmptyString, string>;
17
+ /**
18
+ * Subpath import check.
19
+ *
20
+ * @see https://nodejs.org/api/packages.html#imports
21
+ * @see https://nodejs.org/api/packages.html#subpath-imports
22
+ */
23
+ internal: boolean;
24
+ /**
25
+ * Subpath defined in `package.json` file.
26
+ *
27
+ * @see https://nodejs.org/api/packages.html#exports
28
+ * @see https://nodejs.org/api/packages.html#imports
29
+ */
30
+ key: string;
31
+ /**
32
+ * Subpath passed by user in module specifier.
33
+ */
34
+ raw: string;
35
+ /**
36
+ * Module specifier passed by user.
37
+ */
38
+ specifier: string;
39
+ }
40
+ export type { ParsedSubpath as default };
@@ -27,9 +27,9 @@ interface ImportStatement extends Statement {
27
27
  */
28
28
  specifier: NonNullable<Statement['specifier']>;
29
29
  /**
30
- * Module specifier kind.
30
+ * Module specifier syntax type.
31
31
  */
32
- specifier_kind: NonNullable<Statement['specifier_kind']>;
32
+ specifier_syntax: NonNullable<Statement['specifier_syntax']>;
33
33
  /**
34
34
  * Statement syntax kind.
35
35
  */
@@ -27,9 +27,9 @@ interface RequireStatement extends Statement {
27
27
  */
28
28
  specifier: NonNullable<Statement['specifier']>;
29
29
  /**
30
- * Module specifier kind.
30
+ * Module specifier syntax type.
31
31
  */
32
- specifier_kind: NonNullable<Statement['specifier_kind']>;
32
+ specifier_syntax: NonNullable<Statement['specifier_syntax']>;
33
33
  /**
34
34
  * Statement syntax kind.
35
35
  */
@@ -2,14 +2,15 @@
2
2
  * @file Interfaces - Statement
3
3
  * @module mlly/interfaces/Statement
4
4
  */
5
- import type { SpecifierKind, StatementKind, SyntaxKind } from '../enums/index.mjs';
5
+ import type { SpecifierKind, SpecifierSyntaxKind, StatementKind, StatementSyntaxKind } from '../enums/index.mjs';
6
6
  import type { Nullable } from '@flex-development/tutils';
7
7
  /**
8
8
  * CommonJS or ESM statement object.
9
9
  *
10
10
  * @see {@linkcode SpecifierKind}
11
+ * @see {@linkcode SpecifierSyntaxKind}
11
12
  * @see {@linkcode StatementKind}
12
- * @see {@linkcode SyntaxKind}
13
+ * @see {@linkcode StatementSyntaxKind}
13
14
  */
14
15
  interface Statement {
15
16
  /**
@@ -29,16 +30,20 @@ interface Statement {
29
30
  */
30
31
  specifier: Nullable<string>;
31
32
  /**
32
- * Module specifier kind.
33
+ * Module specifier type.
33
34
  */
34
35
  specifier_kind: Nullable<SpecifierKind>;
35
36
  /**
36
- * Statement syntax kind.
37
+ * Module specifier syntax type.
37
38
  */
38
- syntax: SyntaxKind;
39
+ specifier_syntax: Nullable<SpecifierSyntaxKind>;
39
40
  /**
40
41
  * Start index of {@linkcode code} in source content.
41
42
  */
42
43
  start: number;
44
+ /**
45
+ * Statement syntax kind.
46
+ */
47
+ syntax: StatementSyntaxKind;
43
48
  }
44
49
  export type { Statement as default };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @file Internal - escapeRegExp
3
+ * @module mlly/internal/escapeRegExp
4
+ */
5
+ /**
6
+ * Escapes special characters in the given regex `pattern`.
7
+ *
8
+ * A backslash escape (`\\`) is used when valid. A `\x2d` escape is used when
9
+ * the former would be disallowed by stricter Unicode pattern grammar.
10
+ *
11
+ * @param {string} pattern - Regex pattern to escape
12
+ * @return {string} `pattern` with special characters escaped
13
+ * @throws {NodeError<TypeError>} If `pattern` is not a string
14
+ */
15
+ declare const escapeRegExp: (pattern: string) => string;
16
+ export default escapeRegExp;
@@ -0,0 +1,10 @@
1
+ import validateString from "./validate-string.mjs";
2
+ const escapeRegExp = (pattern) => {
3
+ validateString(pattern, "pattern");
4
+ return pattern.replace(/[$()*+.?[\\\]^{|}]/g, "\\$&").replace(/-/g, "\\x2d");
5
+ };
6
+ var escape_reg_exp_default = escapeRegExp;
7
+ export {
8
+ escape_reg_exp_default as default
9
+ };
10
+ //# sourceMappingURL=escape-reg-exp.mjs.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/internal/escape-reg-exp.ts"],
4
+ "mappings": "AAMA,OAAO,oBAAoB;AAY3B,MAAM,eAAe,CAAC,YAA4B;AAChD,iBAAe,SAAS,SAAS;AACjC,SAAO,QAAQ,QAAQ,uBAAuB,MAAM,EAAE,QAAQ,MAAM,OAAO;AAC7E;AAEA,IAAO,yBAAQ;",
5
+ "names": []
6
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @file Internal - FORMAT_TYPE_MAP
3
+ * @module mlly/internal/FORMAT_TYPE_MAP
4
+ */
5
+ import { AssertType, Format } from '../enums/index.mjs';
6
+ /**
7
+ * Module format to `import` assertion type map.
8
+ *
9
+ * **Note**: It's unclear whether or not the HTML spec will require assertion
10
+ * types for WebAssembly modules.
11
+ *
12
+ * @see https://github.com/WebAssembly/esm-integration/issues/42
13
+ *
14
+ * @const {Map<Format, AssertType>} FORMAT_TYPE_MAP
15
+ */
16
+ declare const FORMAT_TYPE_MAP: Map<Format, AssertType>;
17
+ export default FORMAT_TYPE_MAP;
@@ -0,0 +1,13 @@
1
+ import { AssertType, Format } from "../enums/index.mjs";
2
+ const FORMAT_TYPE_MAP = /* @__PURE__ */ new Map([
3
+ [Format.BUILTIN, AssertType.IMPLICIT],
4
+ [Format.COMMONJS, AssertType.IMPLICIT],
5
+ [Format.JSON, AssertType.JSON],
6
+ [Format.MODULE, AssertType.IMPLICIT],
7
+ [Format.WASM, AssertType.IMPLICIT]
8
+ ]);
9
+ var format_type_map_default = FORMAT_TYPE_MAP;
10
+ export {
11
+ format_type_map_default as default
12
+ };
13
+ //# sourceMappingURL=format-type-map.mjs.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/internal/format-type-map.ts"],
4
+ "mappings": "AAKA,SAAS,YAAY,cAAc;AAYnC,MAAM,kBAA2C,oBAAI,IAAwB;AAAA,EAC3E,CAAC,OAAO,SAAS,WAAW,QAAQ;AAAA,EACpC,CAAC,OAAO,UAAU,WAAW,QAAQ;AAAA,EACrC,CAAC,OAAO,MAAM,WAAW,IAAI;AAAA,EAC7B,CAAC,OAAO,QAAQ,WAAW,QAAQ;AAAA,EACnC,CAAC,OAAO,MAAM,WAAW,QAAQ;AACnC,CAAC;AAED,IAAO,0BAAQ;",
5
+ "names": []
6
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @file Internal - getSpecifierKind
3
+ * @module mlly/internal/getSpecifierKind
4
+ */
5
+ import { SpecifierKind } from '../enums/index.mjs';
6
+ import type { Nullable } from '@flex-development/tutils';
7
+ /**
8
+ * Determines a specifier type for the given module `specifier`.
9
+ *
10
+ * @see {@linkcode SpecifierKind}
11
+ *
12
+ * @param {string} specifier - Module specifier to evaluate
13
+ * @return {Nullable<SpecifierKind>} Module `specifier` type or `null`
14
+ * @throws {NodeError<TypeError>} If `specifier` is not a string
15
+ */
16
+ declare const getSpecifierKind: (specifier: string) => Nullable<SpecifierKind>;
17
+ export default getSpecifierKind;
@@ -0,0 +1,14 @@
1
+ import { SpecifierKind } from "../enums/index.mjs";
2
+ import validateString from "./validate-string.mjs";
3
+ import isAbsoluteSpecifier from "../utils/is-absolute-specifier.mjs";
4
+ import isRelativeSpecifier from "../utils/is-relative-specifier.mjs";
5
+ const getSpecifierKind = (specifier) => {
6
+ validateString(specifier, "specifier");
7
+ specifier = specifier.trim().replace(/^["']|["']$/g, "");
8
+ return specifier ? isAbsoluteSpecifier(specifier) ? SpecifierKind.ABSOLUTE : isRelativeSpecifier(specifier) ? SpecifierKind.RELATIVE : SpecifierKind.BARE : null;
9
+ };
10
+ var get_specifier_kind_default = getSpecifierKind;
11
+ export {
12
+ get_specifier_kind_default as default
13
+ };
14
+ //# sourceMappingURL=get-specifier-kind.mjs.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/internal/get-specifier-kind.ts"],
4
+ "mappings": "AAKA,SAAS,qBAAqB;AAC9B,OAAO,oBAAoB;AAC3B,OAAO,yBAAyB;AAChC,OAAO,yBAAyB;AAahC,MAAM,mBAAmB,CAAC,cAA+C;AACvE,iBAAe,WAAW,WAAW;AAIrC,cAAY,UAAU,KAAK,EAAE,QAAQ,gBAAgB,EAAE;AAEvD,SAAO,YACH,oBAAoB,SAAS,IAC3B,cAAc,WACd,oBAAoB,SAAS,IAC7B,cAAc,WACd,cAAc,OAChB;AACN;AAEA,IAAO,6BAAQ;",
5
+ "names": []
6
+ }