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

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 CHANGED
@@ -1,3 +1,26 @@
1
+ ## [1.0.0-beta.3](https://github.com/flex-development/mlly/compare/1.0.0-beta.2...1.0.0-beta.3) (2026-02-03)
2
+
3
+ ### ⚠ BREAKING CHANGES
4
+
5
+ - **lib:** [`getSource`] return `FileContent`
6
+ - **ts:** [`ReadFile`] return string given `encoding`
7
+
8
+ ### :package: Build
9
+
10
+ - [[`2a5ffdb`](https://github.com/flex-development/mlly/commit/2a5ffdb20ce9b1fc5be481bd1de15cf429d0aafa)] **deps-dev:** Bump cspell from 9.6.2 to 9.6.3 ([#960](https://github.com/flex-development/mlly/issues/960))
11
+
12
+ ### :mechanical_arm: Refactors
13
+
14
+ - [[`eaca2a7`](https://github.com/flex-development/mlly/commit/eaca2a7549deadd7362f8a2f5993167d9313bb45)] **lib:** [`getSource`] return `FileContent`
15
+ - [[`490d72c`](https://github.com/flex-development/mlly/commit/490d72cba0f59cb4f2fe4ff27cac4b81fa597cc6)] **ts:** match `this` context to node
16
+ - [[`cd54387`](https://github.com/flex-development/mlly/commit/cd54387ed7324085ed94d7b5ebb996e5cac85b4e)] **ts:** [`ReadFile`] return string given `encoding`
17
+
18
+ ## [1.0.0-beta.2](https://github.com/flex-development/mlly/compare/1.0.0-beta.1...1.0.0-beta.2) (2026-02-02)
19
+
20
+ ### :sparkles: Features
21
+
22
+ - [[`a799aef`](https://github.com/flex-development/mlly/commit/a799aef04f5fa6033297c362474047acaaeb0e1f)] **ts:** generic fs methods
23
+
1
24
  ## [1.0.0-beta.1](https://github.com/flex-development/mlly/compare/1.0.0-alpha.20...1.0.0-beta.1) (2026-02-02)
2
25
 
3
26
  ### ⚠ BREAKING CHANGES
@@ -1253,3 +1276,5 @@
1253
1276
  - [[`0266ca9`](https://github.com/flex-development/mlly/commit/0266ca9a5593d0c66e950ba1fe2c8f6df8422ff9)] **resolve:** sort `RESOLVE_EXTENSIONS` according to priority
1254
1277
  - [[`36c4b74`](https://github.com/flex-development/mlly/commit/36c4b7475c9bb6c924f5e75c8d6d215a8d23e79c)] **specifiers:** [`toBareSpecifier`] improve `exports` path search
1255
1278
 
1279
+
1280
+
package/README.md CHANGED
@@ -57,6 +57,8 @@
57
57
  - [Types](#types)
58
58
  - [`Aliases`](#aliases)
59
59
  - [`Awaitable<T>`](#awaitablet)
60
+ - [`BufferEncodingMap`](#bufferencodingmap)
61
+ - [`BufferEncoding`](#bufferencoding)
60
62
  - [`ChangeExtFn<[Ext]>`](#changeextfnext)
61
63
  - [`ConditionMap`](#conditionmap)
62
64
  - [`Condition`](#condition)
@@ -65,6 +67,7 @@
65
67
  - [`EmptyObject`](#emptyobject)
66
68
  - [`EmptyString`](#emptystring)
67
69
  - [`Ext`](#ext)
70
+ - [`FileContent`](#filecontent)
68
71
  - [`FileSystem`](#filesystem)
69
72
  - [`GetSourceContext`](#getsourcecontext)
70
73
  - [`GetSourceHandler`](#getsourcehandler)
@@ -84,11 +87,11 @@
84
87
  - [`PatternMatch`](#patternmatch)
85
88
  - [`ProtocolMap`](#protocolmap)
86
89
  - [`Protocol`](#protocol)
87
- - [`ReadFile`](#readfile)
88
- - [`Realpath`](#realpath)
90
+ - [`ReadFile<[T]>`](#readfilet)
91
+ - [`Realpath<[T]>`](#realpatht)
89
92
  - [`ResolveAliasOptions`](#resolvealiasoptions)
90
93
  - [`ResolveModuleOptions`](#resolvemoduleoptions)
91
- - [`Stat`](#stat)
94
+ - [`Stat<[T]>`](#statt)
92
95
  - [`Stats`](#stats)
93
96
  - Additional Documentation
94
97
  - [Resolution Algorithm](./docs/resolution-algorithm.md)
@@ -271,7 +274,7 @@ Get the source code for a module.
271
274
 
272
275
  #### Type Parameters
273
276
 
274
- - `T` ([`Awaitable<string | null | undefined>`](#awaitablet))
277
+ - `T` ([`Awaitable<FileContent | null | undefined>`](#filecontent))
275
278
  — the module source code
276
279
 
277
280
  #### Parameters
@@ -1039,6 +1042,31 @@ type Awaitable<T> = PromiseLike<T> | T
1039
1042
  - `T` (`any`)
1040
1043
  - the value
1041
1044
 
1045
+ ### `BufferEncodingMap`
1046
+
1047
+ Registry of character encodings that can be used when working with `Buffer` objects (`interface`).
1048
+
1049
+ When developing extensions that use additional encodings, augment `BufferEncodingMap` to register custom encodings:
1050
+
1051
+ ```ts
1052
+ declare module '@flex-development/mlly' {
1053
+ interface BufferEncodingMap {
1054
+ custom: 'custom'
1055
+ }
1056
+ }
1057
+ ```
1058
+
1059
+ ### `BufferEncoding`
1060
+
1061
+ Union of values that can occur where a buffer encoding is expected (`type`).
1062
+
1063
+ To register new encodings, augment [`BufferEncodingMap`](#bufferencodingmap).
1064
+ They will be added to this union automatically.
1065
+
1066
+ ```ts
1067
+ type BufferEncoding = BufferEncodingMap[keyof BufferEncodingMap]
1068
+ ```
1069
+
1042
1070
  ### `ChangeExtFn<[Ext]>`
1043
1071
 
1044
1072
  Get a new file extension for `url` (`type`).
@@ -1132,17 +1160,25 @@ A file extension (`type`).
1132
1160
  type Ext = `${Dot}${string}`
1133
1161
  ```
1134
1162
 
1163
+ ### `FileContent`
1164
+
1165
+ Union of values that can occur where file content is expected (`type`).
1166
+
1167
+ ```ts
1168
+ type FileContent = Uint8Array | string
1169
+ ```
1170
+
1135
1171
  ### `FileSystem`
1136
1172
 
1137
1173
  The file system API (`interface`).
1138
1174
 
1139
1175
  #### Properties
1140
1176
 
1141
- - `readFile` ([`ReadFile`](#readfile))
1177
+ - `readFile` ([`ReadFile`](#readfilet))
1142
1178
  — read the entire contents of a file
1143
- - `realpath` ([`Realpath`](#realpath))
1179
+ - `realpath` ([`Realpath`](#realpatht))
1144
1180
  — compute a canonical pathname by resolving `.`, `..`, and symbolic links
1145
- - `stat` ([`Stat`](#stat))
1181
+ - `stat` ([`Stat`](#statt))
1146
1182
  — get information about a directory or file
1147
1183
 
1148
1184
  ### `GetSourceContext`
@@ -1172,7 +1208,7 @@ Get the source code for a module (`type`).
1172
1208
  type GetSourceHandler = (
1173
1209
  this: GetSourceContext,
1174
1210
  url: URL
1175
- ) => Awaitable<Uint8Array | string | null | undefined>
1211
+ ) => Awaitable<FileContent | null | undefined>
1176
1212
  ```
1177
1213
 
1178
1214
  #### Parameters
@@ -1184,7 +1220,7 @@ type GetSourceHandler = (
1184
1220
 
1185
1221
  #### Returns
1186
1222
 
1187
- ([`Awaitable<Uint8Array | string | null | undefined>`](#awaitablet)) The source code
1223
+ ([`Awaitable<FileContent | null | undefined>`](#filecontent)) The source code
1188
1224
 
1189
1225
  ### `GetSourceHandlers`
1190
1226
 
@@ -1202,6 +1238,9 @@ Options for retrieving source code (`interface`).
1202
1238
 
1203
1239
  #### Properties
1204
1240
 
1241
+ - `encoding?` ([`BufferEncoding`](#bufferencoding) | `null` | `undefined`)
1242
+ — the encoding of the result
1243
+ > 👉 **note**: used when the `file:` handler is called
1205
1244
  - `format?` ([`ModuleFormat`](#moduleformat) | `null` | `undefined`)
1206
1245
  — the module format hint
1207
1246
  - `fs?` ([`FileSystem`](#filesystem) | `null` | `undefined`)
@@ -1372,26 +1411,46 @@ They will be added to this union automatically.
1372
1411
  type Protocol = ProtocolMap[keyof ProtocolMap]
1373
1412
  ```
1374
1413
 
1375
- ### `ReadFile`
1414
+ ### `ReadFile<[T]>`
1376
1415
 
1377
1416
  Read the entire contents of a file (`interface`).
1378
1417
 
1418
+ #### Overloads
1419
+
1420
+ ```ts
1421
+ (id: ModuleId, encoding: BufferEncoding): Awaitable<string>
1422
+ (id: ModuleId, encoding?: BufferEncoding | null | undefined): T
1423
+ ```
1424
+
1425
+ #### Type Parameters
1426
+
1427
+ - `T` ([`Awaitable<FileContent | null | undefined>`](#filecontent), optional)
1428
+ — the file contents
1429
+ - **default**: [`Awaitable<FileContent>`](#filecontent)
1430
+
1379
1431
  #### Parameters
1380
1432
 
1381
1433
  - `id` ([`ModuleId`](#moduleid))
1382
1434
  — the module id
1435
+ - `encoding` ([`BufferEncoding`](#bufferencoding))
1436
+ — the encoding of the file contents
1383
1437
 
1384
1438
  #### Returns
1385
1439
 
1386
- ([`Awaitable<Buffer | string>`](#awaitablet)) The file contents
1440
+ (`T`) The file contents
1387
1441
 
1388
- ### `Realpath`
1442
+ ### `Realpath<[T]>`
1389
1443
 
1390
1444
  Compute a canonical pathname by resolving `.`, `..`, and symbolic links (`interface`).
1391
1445
 
1392
1446
  > 👉 **Note**: A canonical pathname is not necessarily unique.
1393
1447
  > Hard links and bind mounts can expose an entity through many pathnames.
1394
1448
 
1449
+ #### Type Parameters
1450
+
1451
+ - `T` ([`Awaitable<string>`](#awaitablet), optional)
1452
+ — the canonical pathname
1453
+
1395
1454
  #### Parameters
1396
1455
 
1397
1456
  - `id` ([`ModuleId`](#moduleid))
@@ -1399,7 +1458,7 @@ Compute a canonical pathname by resolving `.`, `..`, and symbolic links (`interf
1399
1458
 
1400
1459
  #### Returns
1401
1460
 
1402
- ([`Awaitable<string>`](#awaitablet)) The canonical pathname
1461
+ (`T`) The canonical pathname
1403
1462
 
1404
1463
  ### `ResolveAliasOptions`
1405
1464
 
@@ -1451,10 +1510,15 @@ Options for path alias resolution (`interface`).
1451
1510
  - `preserveSymlinks?` (`boolean` | `null` | `undefined`)
1452
1511
  — whether to keep symlinks instead of resolving them
1453
1512
 
1454
- ### `Stat`
1513
+ ### `Stat<[T]>`
1455
1514
 
1456
1515
  Get information about a directory or file (`interface`).
1457
1516
 
1517
+ #### Type Parameters
1518
+
1519
+ - `T` ([`Awaitable<Stats>`](#stats), optional)
1520
+ — the info
1521
+
1458
1522
  #### Parameters
1459
1523
 
1460
1524
  - `id` ([`ModuleId`](#moduleid))
@@ -1462,7 +1526,7 @@ Get information about a directory or file (`interface`).
1462
1526
 
1463
1527
  #### Returns
1464
1528
 
1465
- ([`Awaitable<Stats>`](#stats)) The info
1529
+ (`T`) The info
1466
1530
 
1467
1531
  ### `Stats`
1468
1532
 
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @file Interfaces - BufferEncodingMap
3
+ * @module mlly/interfaces/BufferEncodingMap
4
+ */
5
+ /**
6
+ * Registry of character encodings that can be used when working
7
+ * with {@linkcode Buffer} objects.
8
+ *
9
+ * This interface can be augmented to register custom encodings.
10
+ *
11
+ * @example
12
+ * declare module '@flex-development/mlly' {
13
+ * interface BufferEncodingMap {
14
+ * custom: 'custom'
15
+ * }
16
+ * }
17
+ */
18
+ interface BufferEncodingMap {
19
+ ascii: 'ascii';
20
+ base64: 'base64';
21
+ base64url: 'base64url';
22
+ binary: 'binary';
23
+ hex: 'hex';
24
+ latin1: 'latin1';
25
+ ucs2: 'ucs2' | 'ucs-2';
26
+ utf16le: 'utf16le' | 'utf-16le';
27
+ utf8: 'utf8' | 'utf-8';
28
+ }
29
+ export type { BufferEncodingMap as default };
@@ -2,11 +2,19 @@
2
2
  * @file Interfaces - GetSourceOptions
3
3
  * @module mlly/interfaces/GetSourceOptions
4
4
  */
5
- import type { FileSystem, GetSourceHandlers, List, ModuleFormat } from '@flex-development/mlly';
5
+ import type { BufferEncoding, FileSystem, GetSourceHandlers, List, ModuleFormat } from '@flex-development/mlly';
6
6
  /**
7
7
  * Options for retrieving source code.
8
8
  */
9
9
  interface GetSourceOptions {
10
+ /**
11
+ * The encoding of the result.
12
+ *
13
+ * > 👉 **Note**: Used when the `file:` handler is called.
14
+ *
15
+ * @see {@linkcode BufferEncoding}
16
+ */
17
+ encoding?: BufferEncoding | null | undefined;
10
18
  /**
11
19
  * The module format hint.
12
20
  *
@@ -3,6 +3,7 @@
3
3
  * @module mlly/interfaces
4
4
  */
5
5
  export type { default as Aliases } from '#interfaces/aliases';
6
+ export type { default as BufferEncodingMap } from '#interfaces/buffer-encoding-map';
6
7
  export type { default as ConditionMap } from '#interfaces/condition-map';
7
8
  export type { default as FileSystem } from '#interfaces/file-system';
8
9
  export type { default as GetSourceContext } from '#interfaces/get-source-context';
@@ -7,11 +7,11 @@
7
7
  */
8
8
  interface IsDirectory {
9
9
  /**
10
- * @this {void}
10
+ * @this {unknown}
11
11
  *
12
12
  * @return {boolean}
13
13
  * `true` if stats describes directory, `false` otherwise
14
14
  */
15
- (this: void): boolean;
15
+ (): boolean;
16
16
  }
17
17
  export type { IsDirectory as default };
@@ -12,6 +12,6 @@ interface IsFile {
12
12
  * @return {boolean}
13
13
  * `true` if stats object describes regular file, `false` otherwise
14
14
  */
15
- (this: void): boolean;
15
+ (): boolean;
16
16
  }
17
17
  export type { IsFile as default };
@@ -2,23 +2,42 @@
2
2
  * @file Interfaces - ReadFile
3
3
  * @module mlly/interfaces/ReadFile
4
4
  */
5
- import type { Awaitable, ModuleId } from '@flex-development/mlly';
5
+ import type { Awaitable, BufferEncoding, FileContent, ModuleId } from '@flex-development/mlly';
6
6
  /**
7
7
  * Read the entire contents of a file.
8
+ *
9
+ * @see {@linkcode Awaitable}
10
+ * @see {@linkcode Buffer}
11
+ *
12
+ * @template {Awaitable<FileContent | null | undefined>} [T]
13
+ * The file contents
8
14
  */
9
- interface ReadFile {
15
+ interface ReadFile<T extends Awaitable<FileContent | null | undefined> = Awaitable<FileContent>> {
10
16
  /**
11
- * @see {@linkcode Awaitable}
12
- * @see {@linkcode Buffer}
13
17
  * @see {@linkcode ModuleId}
14
18
  *
15
- * @this {void}
19
+ * @this {unknown}
16
20
  *
17
21
  * @param {ModuleId} id
18
22
  * The module id
19
- * @return {Awaitable<Buffer | string>}
23
+ * @param {BufferEncoding} encoding
24
+ * The encoding of the file contents
25
+ * @return {Awaitable<string>}
20
26
  * The file contents
21
27
  */
22
- (this: void, id: ModuleId): Awaitable<Buffer | string>;
28
+ (id: ModuleId, encoding: BufferEncoding): Awaitable<string>;
29
+ /**
30
+ * @see {@linkcode ModuleId}
31
+ *
32
+ * @this {unknown}
33
+ *
34
+ * @param {ModuleId} id
35
+ * The module id
36
+ * @param {BufferEncoding | null | undefined} [encoding]
37
+ * The encoding of the file contents
38
+ * @return {T}
39
+ * The file contents
40
+ */
41
+ (id: ModuleId, encoding?: BufferEncoding | null | undefined): T;
23
42
  }
24
43
  export type { ReadFile as default };
@@ -8,19 +8,23 @@ import type { Awaitable, ModuleId } from '@flex-development/mlly';
8
8
  *
9
9
  * > 👉 **Note**: A canonical pathname is not necessarily unique.
10
10
  * > Hard links and bind mounts can expose an entity through many pathnames.
11
+ *
12
+ * @see {@linkcode Awaitable}
13
+ *
14
+ * @template {Awaitable<string>} [T]
15
+ * The canonical pathname
11
16
  */
12
- interface Realpath {
17
+ interface Realpath<T extends Awaitable<string> = Awaitable<string>> {
13
18
  /**
14
- * @see {@linkcode Awaitable}
15
19
  * @see {@linkcode ModuleId}
16
20
  *
17
- * @this {void}
21
+ * @this {unknown}
18
22
  *
19
23
  * @param {ModuleId} id
20
24
  * The module id
21
- * @return {Awaitable<string>}
25
+ * @return {T}
22
26
  * The canonical pathname
23
27
  */
24
- (this: void, id: ModuleId): Awaitable<string>;
28
+ (id: ModuleId): T;
25
29
  }
26
30
  export type { Realpath as default };
@@ -5,20 +5,24 @@
5
5
  import type { Awaitable, ModuleId, Stats } from '@flex-development/mlly';
6
6
  /**
7
7
  * Get information about a directory or file.
8
+ *
9
+ * @see {@linkcode Awaitable}
10
+ * @see {@linkcode Stats}
11
+ *
12
+ * @template {Awaitable<Stats>} [T]
13
+ * The info
8
14
  */
9
- interface Stat {
15
+ interface Stat<T extends Awaitable<Stats> = Awaitable<Stats>> {
10
16
  /**
11
- * @see {@linkcode Awaitable}
12
17
  * @see {@linkcode ModuleId}
13
- * @see {@linkcode Stats}
14
18
  *
15
- * @this {void}
19
+ * @this {unknown}
16
20
  *
17
21
  * @param {ModuleId} id
18
22
  * The module id
19
- * @return {Awaitable<Stats>}
23
+ * @return {T}
20
24
  * The info
21
25
  */
22
- (this: void, id: ModuleId): Awaitable<Stats>;
26
+ (id: ModuleId): T;
23
27
  }
24
28
  export type { Stat as default };
@@ -2,7 +2,7 @@
2
2
  * @file getSource
3
3
  * @module mlly/lib/getSource
4
4
  */
5
- import type { Awaitable, EmptyString, GetSourceOptions, ModuleId } from '@flex-development/mlly';
5
+ import type { Awaitable, EmptyString, FileContent, GetSourceOptions, ModuleId } from '@flex-development/mlly';
6
6
  export default getSource;
7
7
  /**
8
8
  * Get the source code for a module.
@@ -30,7 +30,7 @@ declare function getSource(this: void, id: EmptyString | null | undefined, optio
30
30
  * @see {@linkcode GetSourceOptions}
31
31
  * @see {@linkcode ModuleId}
32
32
  *
33
- * @template {Awaitable<string | null | undefined>} T
33
+ * @template {Awaitable<FileContent | null | undefined>} T
34
34
  * The module source code
35
35
  *
36
36
  * @this {void}
@@ -43,4 +43,4 @@ declare function getSource(this: void, id: EmptyString | null | undefined, optio
43
43
  * The module source code
44
44
  * @throws {ErrUnsupportedEsmUrlScheme}
45
45
  */
46
- declare function getSource<T extends Awaitable<string | null | undefined>>(this: void, id: ModuleId | null | undefined, options?: GetSourceOptions | null | undefined): T;
46
+ declare function getSource<T extends Awaitable<FileContent | null | undefined>>(this: void, id: ModuleId | null | undefined, options?: GetSourceOptions | null | undefined): T;
@@ -28,7 +28,7 @@ export default getSource;
28
28
  * The module id
29
29
  * @param {GetSourceOptions | null | undefined} [options]
30
30
  * Source code retrieval options
31
- * @return {Awaitable<string | null | undefined>}
31
+ * @return {Awaitable<FileContent | null | undefined>}
32
32
  * The module source code
33
33
  * @throws {ErrUnsupportedEsmUrlScheme}
34
34
  */
@@ -79,7 +79,7 @@ function getSource(id, options) {
79
79
  /**
80
80
  * The source code.
81
81
  *
82
- * @var {Awaitable<Uint8Array | string | null | undefined>} code
82
+ * @var {ReturnType<GetSourceHandler>} code
83
83
  */
84
84
  let code = handle.call(context, url);
85
85
  // resolve source code.
@@ -87,10 +87,7 @@ function getSource(id, options) {
87
87
  void code.then(resolved => (code = resolved));
88
88
  }
89
89
  return chainOrCall(code, () => {
90
- ok(!isPromise(code), 'expected `code` to be resolved');
91
- if (code !== null && code !== undefined)
92
- code = String(code);
93
- return code;
90
+ return ok(!isPromise(code), 'expected `code` to be resolved'), code;
94
91
  });
95
92
  }
96
93
  /**
@@ -115,7 +112,7 @@ function data(url) {
115
112
  *
116
113
  * @param {URL} url
117
114
  * The module URL
118
- * @return {Awaitable<Buffer | string | null>}
115
+ * @return {Awaitable<FileContent | null>}
119
116
  * The source code
120
117
  */
121
118
  function file(url) {
@@ -127,7 +124,7 @@ function file(url) {
127
124
  */
128
125
  const exists = isFile(url, this.fs);
129
126
  return chainOrCall(exists, isFile => {
130
- return isFile ?? exists ? this.fs.readFile(url) : null;
127
+ return isFile ?? exists ? this.fs.readFile(url, this.encoding) : null;
131
128
  });
132
129
  }
133
130
  /**
@@ -62,19 +62,18 @@ function readPackageJson(id, specifier, parent, fs) {
62
62
  /**
63
63
  * The stringified contents of the package manifest file.
64
64
  *
65
- * @const {Awaitable<Buffer | string>} contents
65
+ * @const {Awaitable<string>} contents
66
66
  */
67
- const contents = fs.readFile(url);
67
+ const contents = fs.readFile(url, 'utf8');
68
68
  // parse file content.
69
- return chainOrCall(contents, data => {
70
- data ??= contents;
69
+ return chainOrCall(contents, (data = contents) => {
71
70
  try {
72
71
  /**
73
72
  * The parsed file contents.
74
73
  *
75
- * @const {any} parsed
74
+ * @const {unknown} parsed
76
75
  */
77
- const parsed = JSON.parse(String(data));
76
+ const parsed = JSON.parse(data);
78
77
  if (isPackageJson(parsed))
79
78
  return parsed;
80
79
  throw new Error('Invalid package manifest object', { cause: parsed });
@@ -0,0 +1,13 @@
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 };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @file Type Aliases - FileContent
3
+ * @module mlly/types/FileContent
4
+ */
5
+ /**
6
+ * Union of values that can occur where file content is expected.
7
+ *
8
+ * @see {@linkcode Uint8Array}
9
+ */
10
+ type FileContent = Uint8Array | string;
11
+ export type { FileContent as default };
@@ -2,11 +2,12 @@
2
2
  * @file Type Aliases - GetSourceHandler
3
3
  * @module mlly/types/GetSourceHandler
4
4
  */
5
- import type { Awaitable, GetSourceContext } from '@flex-development/mlly';
5
+ import type { Awaitable, FileContent, GetSourceContext } from '@flex-development/mlly';
6
6
  /**
7
7
  * Get the source code for a module.
8
8
  *
9
9
  * @see {@linkcode Awaitable}
10
+ * @see {@linkcode FileContent}
10
11
  * @see {@linkcode GetSourceContext}
11
12
  * @see {@linkcode URL}
12
13
  *
@@ -15,8 +16,8 @@ import type { Awaitable, GetSourceContext } from '@flex-development/mlly';
15
16
  *
16
17
  * @param {URL} url
17
18
  * The module URL
18
- * @return {Awaitable<Uint8Array | string | null | undefined>}
19
+ * @return {Awaitable<FileContent | null | undefined>}
19
20
  * The source code
20
21
  */
21
- type GetSourceHandler = (this: GetSourceContext, url: URL) => Awaitable<Uint8Array | string | null | undefined>;
22
+ type GetSourceHandler = (this: GetSourceContext, url: URL) => Awaitable<FileContent | null | undefined>;
22
23
  export type { GetSourceHandler as default };
@@ -3,6 +3,7 @@
3
3
  * @module mlly/types
4
4
  */
5
5
  export type { default as Awaitable } from '#types/awaitable';
6
+ export type { default as BufferEncoding } from '#types/buffer-encoding';
6
7
  export type { default as ChangeExtFn } from '#types/change-ext-fn';
7
8
  export type { default as Condition } from '#types/condition';
8
9
  export type { default as Dot } from '#types/dot';
@@ -10,6 +11,7 @@ export type { default as EmptyArray } from '#types/empty-array';
10
11
  export type { default as EmptyObject } from '#types/empty-object';
11
12
  export type { default as EmptyString } from '#types/empty-string';
12
13
  export type { default as Ext } from '#types/ext';
14
+ export type { default as FileContent } from '#types/file-content';
13
15
  export type { default as GetSourceHandler } from '#types/get-source-handler';
14
16
  export type { default as GetSourceHandlers } from '#types/get-source-handlers';
15
17
  export type { default as List } from '#types/list';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@flex-development/mlly",
3
3
  "description": "ECMAScript module utilities",
4
- "version": "1.0.0-beta.1",
4
+ "version": "1.0.0-beta.3",
5
5
  "keywords": [
6
6
  "ecmascript",
7
7
  "esm",
@@ -180,7 +180,7 @@
180
180
  "chai-string": "1.6.0",
181
181
  "concat-stream": "2.0.0",
182
182
  "cross-env": "10.1.0",
183
- "cspell": "9.6.2",
183
+ "cspell": "9.6.3",
184
184
  "dprint": "0.51.1",
185
185
  "editorconfig": "3.0.1",
186
186
  "eslint": "9.39.2",