powerlines 0.23.10 → 0.24.0
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/dist/{api-5H3zEedD.d.ts → api-C32Buv5_.d.ts} +1 -1
- package/dist/{api-B77aqxGC.d.cts → api-wzd5AREv.d.cts} +1 -1
- package/dist/api.cjs +2 -2
- package/dist/api.d.cts +4 -2
- package/dist/api.d.ts +4 -2
- package/dist/api.js +1 -1
- package/dist/astro.cjs +4 -4
- package/dist/astro.d.cts +3 -1
- package/dist/astro.d.ts +3 -1
- package/dist/astro.js +3 -3
- package/dist/chunk-2TWFBWKA.cjs +133 -0
- package/dist/{chunk-3W5CN3M3.js → chunk-7V3LWCLB.js} +1 -1
- package/dist/chunk-EXQM3KGH.js +130 -0
- package/dist/{chunk-4EIGDACJ.cjs → chunk-FGH3MZTQ.cjs} +523 -649
- package/dist/{chunk-SNHUEYEP.cjs → chunk-FPB2O7FD.cjs} +2 -2
- package/dist/{chunk-ZIWN73GA.js → chunk-H74SWU2C.js} +1 -1
- package/dist/{chunk-WBC2XOMT.cjs → chunk-HTGCHSLH.cjs} +2 -2
- package/dist/{chunk-PR3JGGAL.cjs → chunk-TIBYAWZZ.cjs} +2 -2
- package/dist/{chunk-SS5AXCGJ.js → chunk-ZEE73BCY.js} +1 -1
- package/dist/{chunk-MUNYXQYT.js → chunk-ZT2J55YE.js} +526 -649
- package/dist/config.d.cts +3 -1
- package/dist/config.d.ts +3 -1
- package/dist/esbuild.cjs +6 -6
- package/dist/esbuild.d.cts +3 -1
- package/dist/esbuild.d.ts +3 -1
- package/dist/esbuild.js +3 -3
- package/dist/farm.cjs +3 -3
- package/dist/farm.d.cts +3 -1
- package/dist/farm.d.ts +3 -1
- package/dist/farm.js +2 -2
- package/dist/index.cjs +11 -23
- package/dist/index.d.cts +6 -135
- package/dist/index.d.ts +6 -135
- package/dist/index.js +2 -2
- package/dist/lib/{api-Cm51oVbC.d.cts → api-BRMITKt-.d.cts} +1 -1
- package/dist/lib/{api-mja4jirh.d.ts → api-CDUN9en8.d.ts} +1 -1
- package/dist/lib/build/esbuild.d.cts +3 -1
- package/dist/lib/build/esbuild.d.ts +3 -1
- package/dist/lib/build/index.d.cts +5 -3
- package/dist/lib/build/index.d.ts +5 -3
- package/dist/lib/build/rolldown.d.cts +3 -1
- package/dist/lib/build/rolldown.d.ts +3 -1
- package/dist/lib/build/rollup.d.cts +3 -1
- package/dist/lib/build/rollup.d.ts +3 -1
- package/dist/lib/build/rspack.d.cts +3 -1
- package/dist/lib/build/rspack.d.ts +3 -1
- package/dist/lib/build/tsup.d.cts +3 -1
- package/dist/lib/build/tsup.d.ts +3 -1
- package/dist/lib/build/unbuild.d.cts +5 -3
- package/dist/lib/build/unbuild.d.ts +5 -3
- package/dist/lib/build/vite.d.cts +3 -1
- package/dist/lib/build/vite.d.ts +3 -1
- package/dist/lib/build/webpack.d.cts +3 -1
- package/dist/lib/build/webpack.d.ts +3 -1
- package/dist/lib/{chunk-52VDUP5J.js → chunk-6I5PL7H2.js} +5 -17
- package/dist/lib/{chunk-UPVFKXB7.cjs → chunk-6PPZCPME.cjs} +1 -2
- package/dist/lib/{chunk-HNOAMIRO.js → chunk-7CVPZOH4.js} +2 -2
- package/dist/lib/{chunk-SEWUUTNA.js → chunk-A2NFSQ5K.js} +1 -1
- package/dist/lib/{chunk-I6TJUFA6.cjs → chunk-AA6RBP44.cjs} +10 -10
- package/dist/lib/{chunk-VDPCG3RR.js → chunk-CGRHZJY5.js} +41 -82
- package/dist/lib/{chunk-OJ5XFCZN.js → chunk-DFW5FGEO.js} +1 -1
- package/dist/lib/{chunk-VL63QEPF.cjs → chunk-DUZJ7ZF2.cjs} +2 -2
- package/dist/lib/{chunk-EFYMNU53.cjs → chunk-EV357RFB.cjs} +5 -17
- package/dist/lib/{chunk-54XNJQTH.js → chunk-HAXL7QE7.js} +3 -3
- package/dist/lib/{chunk-XG4CC73V.js → chunk-KFWMKDJQ.js} +391 -589
- package/dist/lib/{chunk-RBSNQFLF.cjs → chunk-MS3CD2U6.cjs} +49 -91
- package/dist/lib/{chunk-QABAD5RE.cjs → chunk-RNHKEPFD.cjs} +387 -586
- package/dist/lib/{chunk-4EIXDLFP.cjs → chunk-SAS5EPBD.cjs} +7 -5
- package/dist/lib/{chunk-EUDKQWSB.js → chunk-VHLINWXG.js} +1 -2
- package/dist/lib/{chunk-VLOUSKRX.cjs → chunk-VMLQATMA.cjs} +4 -4
- package/dist/lib/{chunk-IBPA3VN5.cjs → chunk-WUYK74EH.cjs} +3 -3
- package/dist/lib/{chunk-RD5AUWXN.js → chunk-YQ3ODCHV.js} +7 -5
- package/dist/lib/{config-BnJpgcGr.d.cts → config-D8KrE7SZ.d.cts} +109 -35
- package/dist/lib/{config-7Q2dBjJE.d.ts → config-DBIFdRoq.d.ts} +109 -35
- package/dist/lib/config-file.d.cts +3 -1
- package/dist/lib/config-file.d.ts +3 -1
- package/dist/lib/contexts/api-context.cjs +5 -4
- package/dist/lib/contexts/api-context.d.cts +5 -3
- package/dist/lib/contexts/api-context.d.ts +5 -3
- package/dist/lib/contexts/api-context.js +4 -3
- package/dist/lib/contexts/context.cjs +3 -2
- package/dist/lib/contexts/context.d.cts +47 -4
- package/dist/lib/contexts/context.d.ts +47 -4
- package/dist/lib/contexts/context.js +2 -1
- package/dist/lib/contexts/environment-context.cjs +4 -3
- package/dist/lib/contexts/environment-context.d.cts +5 -3
- package/dist/lib/contexts/environment-context.d.ts +5 -3
- package/dist/lib/contexts/environment-context.js +3 -2
- package/dist/lib/contexts/index.cjs +7 -6
- package/dist/lib/contexts/index.d.cts +5 -3
- package/dist/lib/contexts/index.d.ts +5 -3
- package/dist/lib/contexts/index.js +4 -3
- package/dist/lib/contexts/plugin-context.d.cts +5 -3
- package/dist/lib/contexts/plugin-context.d.ts +5 -3
- package/dist/lib/entry.d.cts +3 -1
- package/dist/lib/entry.d.ts +3 -1
- package/dist/lib/index.cjs +39 -45
- package/dist/lib/index.d.cts +67 -48
- package/dist/lib/index.d.ts +67 -48
- package/dist/lib/index.js +12 -14
- package/dist/lib/{internal-BEygquYh.d.ts → internal-1qCyw7bA.d.ts} +2 -2
- package/dist/lib/{internal-BeR8fOB1.d.cts → internal-CaGANOWK.d.cts} +2 -2
- package/dist/lib/logger.d.cts +3 -1
- package/dist/lib/logger.d.ts +3 -1
- package/dist/lib/typescript/compiler-host.cjs +7 -7
- package/dist/lib/typescript/compiler-host.d.cts +3 -1
- package/dist/lib/typescript/compiler-host.d.ts +3 -1
- package/dist/lib/typescript/compiler-host.js +6 -6
- package/dist/lib/typescript/import-transformer.cjs +1 -1
- package/dist/lib/typescript/import-transformer.d.cts +3 -1
- package/dist/lib/typescript/import-transformer.d.ts +3 -1
- package/dist/lib/typescript/import-transformer.js +1 -1
- package/dist/lib/typescript/index.cjs +8 -8
- package/dist/lib/typescript/index.d.cts +3 -2
- package/dist/lib/typescript/index.d.ts +3 -2
- package/dist/lib/typescript/index.js +2 -2
- package/dist/lib/typescript/program.cjs +6 -6
- package/dist/lib/typescript/program.d.cts +3 -1
- package/dist/lib/typescript/program.d.ts +3 -1
- package/dist/lib/typescript/program.js +1 -1
- package/dist/lib/typescript/ts-morph.cjs +2 -2
- package/dist/lib/typescript/ts-morph.d.cts +5 -3
- package/dist/lib/typescript/ts-morph.d.ts +5 -3
- package/dist/lib/typescript/ts-morph.js +1 -1
- package/dist/lib/unplugin/factory.cjs +6 -6
- package/dist/lib/unplugin/factory.d.cts +5 -3
- package/dist/lib/unplugin/factory.d.ts +5 -3
- package/dist/lib/unplugin/factory.js +5 -5
- package/dist/lib/unplugin/helpers.d.cts +3 -1
- package/dist/lib/unplugin/helpers.d.ts +3 -1
- package/dist/lib/unplugin/index.cjs +11 -11
- package/dist/lib/unplugin/index.d.cts +6 -4
- package/dist/lib/unplugin/index.d.ts +6 -4
- package/dist/lib/unplugin/index.js +7 -7
- package/dist/lib/unplugin/plugin.cjs +2 -3
- package/dist/lib/unplugin/plugin.d.cts +6 -4
- package/dist/lib/unplugin/plugin.d.ts +6 -4
- package/dist/lib/unplugin/plugin.js +1 -2
- package/dist/lib/{unplugin-CbbNDduM.d.ts → unplugin-CEeJqADD.d.ts} +2 -2
- package/dist/lib/{unplugin-ppAOzR__.d.cts → unplugin-bUSyjd0S.d.cts} +2 -2
- package/dist/lib/utilities/bundle.cjs +2 -3
- package/dist/lib/utilities/bundle.d.cts +3 -1
- package/dist/lib/utilities/bundle.d.ts +3 -1
- package/dist/lib/utilities/bundle.js +1 -2
- package/dist/lib/utilities/cache.d.cts +3 -1
- package/dist/lib/utilities/cache.d.ts +3 -1
- package/dist/lib/utilities/file-header.d.cts +3 -1
- package/dist/lib/utilities/file-header.d.ts +3 -1
- package/dist/lib/utilities/index.cjs +14 -19
- package/dist/lib/utilities/index.d.cts +3 -2
- package/dist/lib/utilities/index.d.ts +3 -2
- package/dist/lib/utilities/index.js +4 -5
- package/dist/lib/utilities/meta.d.cts +3 -1
- package/dist/lib/utilities/meta.d.ts +3 -1
- package/dist/lib/utilities/resolve.cjs +3 -4
- package/dist/lib/utilities/resolve.d.cts +3 -1
- package/dist/lib/utilities/resolve.d.ts +3 -1
- package/dist/lib/utilities/resolve.js +2 -3
- package/dist/lib/utilities/source-file.d.cts +3 -1
- package/dist/lib/utilities/source-file.d.ts +3 -1
- package/dist/lib/utilities/source-map.d.cts +3 -1
- package/dist/lib/utilities/source-map.d.ts +3 -1
- package/dist/lib/utilities/worker.d.cts +3 -1
- package/dist/lib/utilities/worker.d.ts +3 -1
- package/dist/lib/utilities/write-file.d.cts +3 -1
- package/dist/lib/utilities/write-file.d.ts +3 -1
- package/dist/next.cjs +4 -4
- package/dist/next.js +3 -3
- package/dist/nuxt.cjs +6 -6
- package/dist/nuxt.js +4 -4
- package/dist/plugin-utils/{context-Cg11S-CE.d.cts → context-BITGF5LZ.d.cts} +118 -39
- package/dist/plugin-utils/{context-Cg11S-CE.d.ts → context-BITGF5LZ.d.ts} +118 -39
- package/dist/plugin-utils/context-helpers.d.cts +4 -1
- package/dist/plugin-utils/context-helpers.d.ts +4 -1
- package/dist/plugin-utils/enforce.d.cts +4 -1
- package/dist/plugin-utils/enforce.d.ts +4 -1
- package/dist/plugin-utils/extend.d.cts +4 -1
- package/dist/plugin-utils/extend.d.ts +4 -1
- package/dist/plugin-utils/get-config-path.d.cts +4 -1
- package/dist/plugin-utils/get-config-path.d.ts +4 -1
- package/dist/plugin-utils/helpers.d.cts +4 -1
- package/dist/plugin-utils/helpers.d.ts +4 -1
- package/dist/plugin-utils/index.d.cts +4 -1
- package/dist/plugin-utils/index.d.ts +4 -1
- package/dist/plugin-utils/merge.d.cts +4 -1
- package/dist/plugin-utils/merge.d.ts +4 -1
- package/dist/plugin-utils/paths.d.cts +4 -1
- package/dist/plugin-utils/paths.d.ts +4 -1
- package/dist/{resolved-B3BSdXCt.d.ts → resolved-BABoCnXm.d.ts} +43 -1
- package/dist/{resolved-DGrpILrS.d.cts → resolved-CSqGKlA5.d.cts} +43 -1
- package/dist/rolldown.cjs +3 -3
- package/dist/rolldown.d.cts +3 -1
- package/dist/rolldown.d.ts +3 -1
- package/dist/rolldown.js +2 -2
- package/dist/rollup.cjs +3 -3
- package/dist/rollup.d.cts +3 -1
- package/dist/rollup.d.ts +3 -1
- package/dist/rollup.js +2 -2
- package/dist/rspack.cjs +3 -3
- package/dist/rspack.d.cts +3 -1
- package/dist/rspack.d.ts +3 -1
- package/dist/rspack.js +2 -2
- package/dist/tsup.cjs +4 -4
- package/dist/tsup.js +3 -3
- package/dist/types/api.d.cts +4 -2
- package/dist/types/api.d.ts +4 -2
- package/dist/types/babel.d.cts +3 -1
- package/dist/types/babel.d.ts +3 -1
- package/dist/types/commands.d.cts +3 -1
- package/dist/types/commands.d.ts +3 -1
- package/dist/types/config.d.cts +3 -1
- package/dist/types/config.d.ts +3 -1
- package/dist/types/context.d.cts +3 -1
- package/dist/types/context.d.ts +3 -1
- package/dist/types/fs.d.cts +68 -36
- package/dist/types/fs.d.ts +68 -36
- package/dist/types/hooks.d.cts +3 -1
- package/dist/types/hooks.d.ts +3 -1
- package/dist/types/index.d.cts +5 -3
- package/dist/types/index.d.ts +5 -3
- package/dist/types/internal.d.cts +4 -2
- package/dist/types/internal.d.ts +4 -2
- package/dist/types/plugin.d.cts +3 -1
- package/dist/types/plugin.d.ts +3 -1
- package/dist/types/resolved.d.cts +3 -1
- package/dist/types/resolved.d.ts +3 -1
- package/dist/types/unplugin.d.cts +4 -2
- package/dist/types/unplugin.d.ts +4 -2
- package/dist/unloader.cjs +3 -3
- package/dist/unloader.d.cts +3 -1
- package/dist/unloader.d.ts +3 -1
- package/dist/unloader.js +2 -2
- package/dist/unplugin.cjs +12 -28
- package/dist/unplugin.d.cts +104 -31
- package/dist/unplugin.d.ts +104 -31
- package/dist/unplugin.js +10 -23
- package/dist/vite.cjs +6 -6
- package/dist/vite.d.cts +3 -1
- package/dist/vite.d.ts +3 -1
- package/dist/vite.js +3 -3
- package/dist/webpack.cjs +6 -6
- package/dist/webpack.d.cts +3 -1
- package/dist/webpack.d.ts +3 -1
- package/dist/webpack.js +3 -3
- package/package.json +16 -15
- package/schemas/fs.capnp +35 -38
- package/dist/chunk-4TBQYHPZ.cjs +0 -234
- package/dist/chunk-7G7OFGGH.js +0 -230
- package/dist/lib/chunk-G7S5PIAC.js +0 -89
- package/dist/lib/chunk-MZJWK36Q.cjs +0 -37
- package/dist/lib/chunk-NWAD7K4D.js +0 -35
- package/dist/lib/chunk-ZBDVQVUK.cjs +0 -91
- package/dist/lib/unplugin/resolve-id.cjs +0 -11
- package/dist/lib/unplugin/resolve-id.d.cts +0 -57
- package/dist/lib/unplugin/resolve-id.d.ts +0 -57
- package/dist/lib/unplugin/resolve-id.js +0 -2
- package/dist/lib/utilities/resolve-path.cjs +0 -11
- package/dist/lib/utilities/resolve-path.d.cts +0 -40
- package/dist/lib/utilities/resolve-path.d.ts +0 -40
- package/dist/lib/utilities/resolve-path.js +0 -2
- /package/dist/lib/{chunk-HMO3LAYL.js → chunk-I2DQRMX3.js} +0 -0
- /package/dist/lib/{chunk-EJ25PQEL.cjs → chunk-YK4PYVLM.cjs} +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunk7VJ42H2I_cjs = require('./chunk-7VJ42H2I.cjs');
|
|
4
|
+
var chunkSAS5EPBD_cjs = require('./chunk-SAS5EPBD.cjs');
|
|
4
5
|
var chunkK3NBD5LL_cjs = require('./chunk-K3NBD5LL.cjs');
|
|
5
6
|
var chunkJA4HSQRN_cjs = require('./chunk-JA4HSQRN.cjs');
|
|
6
7
|
var chunkISBHXSDH_cjs = require('./chunk-ISBHXSDH.cjs');
|
|
@@ -27,6 +28,7 @@ var isSetObject = require('@stryke/type-checks/is-set-object');
|
|
|
27
28
|
var isSetString = require('@stryke/type-checks/is-set-string');
|
|
28
29
|
var isString = require('@stryke/type-checks/is-string');
|
|
29
30
|
var uuid = require('@stryke/unique-id/uuid');
|
|
31
|
+
var bundleRequire = require('bundle-require');
|
|
30
32
|
var defu2 = require('defu');
|
|
31
33
|
var joinPaths = require('@stryke/path/join-paths');
|
|
32
34
|
var jiti = require('jiti');
|
|
@@ -35,9 +37,11 @@ var isUndefined = require('@stryke/type-checks/is-undefined');
|
|
|
35
37
|
var $ = require('@stryke/capnp');
|
|
36
38
|
var bufferToString = require('@stryke/convert/buffer-to-string');
|
|
37
39
|
var buffer = require('@stryke/fs/buffer');
|
|
40
|
+
var correctPath = require('@stryke/path/correct-path');
|
|
38
41
|
var filePathFns = require('@stryke/path/file-path-fns');
|
|
39
42
|
var prettyBytes = require('@stryke/string-format/pretty-bytes');
|
|
40
43
|
var isBuffer = require('@stryke/type-checks/is-buffer');
|
|
44
|
+
var flatCache = require('flat-cache');
|
|
41
45
|
var buffer$1 = require('buffer');
|
|
42
46
|
var _fs = require('fs');
|
|
43
47
|
var prettier = require('prettier');
|
|
@@ -258,187 +262,6 @@ var FileMetadata = class _FileMetadata extends $__namespace.Struct {
|
|
|
258
262
|
return "FileMetadata_" + super.toString();
|
|
259
263
|
}
|
|
260
264
|
};
|
|
261
|
-
var ChunkData = class extends $__namespace.Struct {
|
|
262
|
-
static {
|
|
263
|
-
chunkUSNT2KNT_cjs.__name(this, "ChunkData");
|
|
264
|
-
}
|
|
265
|
-
static _capnp = {
|
|
266
|
-
displayName: "ChunkData",
|
|
267
|
-
id: "84076f13b057f83a",
|
|
268
|
-
size: new $__namespace.ObjectSize(8, 4)
|
|
269
|
-
};
|
|
270
|
-
/**
|
|
271
|
-
* An additional name for the file.
|
|
272
|
-
*
|
|
273
|
-
*/
|
|
274
|
-
get id() {
|
|
275
|
-
return $__namespace.utils.getText(0, this);
|
|
276
|
-
}
|
|
277
|
-
set id(value) {
|
|
278
|
-
$__namespace.utils.setText(0, value, this);
|
|
279
|
-
}
|
|
280
|
-
/**
|
|
281
|
-
* Files that are implicitly loaded after one of the specified files.
|
|
282
|
-
*
|
|
283
|
-
*/
|
|
284
|
-
get name() {
|
|
285
|
-
return $__namespace.utils.getText(1, this);
|
|
286
|
-
}
|
|
287
|
-
set name(value) {
|
|
288
|
-
$__namespace.utils.setText(1, value, this);
|
|
289
|
-
}
|
|
290
|
-
_adoptImplicitlyLoadedAfterOneOf(value) {
|
|
291
|
-
$__namespace.utils.adopt(value, $__namespace.utils.getPointer(2, this));
|
|
292
|
-
}
|
|
293
|
-
_disownImplicitlyLoadedAfterOneOf() {
|
|
294
|
-
return $__namespace.utils.disown(this.implicitlyLoadedAfterOneOf);
|
|
295
|
-
}
|
|
296
|
-
/**
|
|
297
|
-
* The importer of the file.
|
|
298
|
-
*
|
|
299
|
-
*/
|
|
300
|
-
get implicitlyLoadedAfterOneOf() {
|
|
301
|
-
return $__namespace.utils.getList(2, $__namespace.TextList, this);
|
|
302
|
-
}
|
|
303
|
-
_hasImplicitlyLoadedAfterOneOf() {
|
|
304
|
-
return !$__namespace.utils.isNull($__namespace.utils.getPointer(2, this));
|
|
305
|
-
}
|
|
306
|
-
_initImplicitlyLoadedAfterOneOf(length) {
|
|
307
|
-
return $__namespace.utils.initList(2, $__namespace.TextList, length, this);
|
|
308
|
-
}
|
|
309
|
-
set implicitlyLoadedAfterOneOf(value) {
|
|
310
|
-
$__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(2, this));
|
|
311
|
-
}
|
|
312
|
-
/**
|
|
313
|
-
* The signature preservation mode for the file.
|
|
314
|
-
*
|
|
315
|
-
*/
|
|
316
|
-
get importer() {
|
|
317
|
-
return $__namespace.utils.getText(3, this);
|
|
318
|
-
}
|
|
319
|
-
set importer(value) {
|
|
320
|
-
$__namespace.utils.setText(3, value, this);
|
|
321
|
-
}
|
|
322
|
-
get preserveSignature() {
|
|
323
|
-
return $__namespace.utils.getUint16(0, this);
|
|
324
|
-
}
|
|
325
|
-
set preserveSignature(value) {
|
|
326
|
-
$__namespace.utils.setUint16(0, value, this);
|
|
327
|
-
}
|
|
328
|
-
toString() {
|
|
329
|
-
return "ChunkData_" + super.toString();
|
|
330
|
-
}
|
|
331
|
-
};
|
|
332
|
-
var PrebuiltData = class extends $__namespace.Struct {
|
|
333
|
-
static {
|
|
334
|
-
chunkUSNT2KNT_cjs.__name(this, "PrebuiltData");
|
|
335
|
-
}
|
|
336
|
-
static _capnp = {
|
|
337
|
-
displayName: "PrebuiltData",
|
|
338
|
-
id: "c5b1a6ca696328ee",
|
|
339
|
-
size: new $__namespace.ObjectSize(0, 4)
|
|
340
|
-
};
|
|
341
|
-
/**
|
|
342
|
-
* An additional name for the file.
|
|
343
|
-
*
|
|
344
|
-
*/
|
|
345
|
-
get id() {
|
|
346
|
-
return $__namespace.utils.getText(0, this);
|
|
347
|
-
}
|
|
348
|
-
set id(value) {
|
|
349
|
-
$__namespace.utils.setText(0, value, this);
|
|
350
|
-
}
|
|
351
|
-
/**
|
|
352
|
-
* The file exports.
|
|
353
|
-
*
|
|
354
|
-
*/
|
|
355
|
-
get name() {
|
|
356
|
-
return $__namespace.utils.getText(1, this);
|
|
357
|
-
}
|
|
358
|
-
set name(value) {
|
|
359
|
-
$__namespace.utils.setText(1, value, this);
|
|
360
|
-
}
|
|
361
|
-
_adoptExports(value) {
|
|
362
|
-
$__namespace.utils.adopt(value, $__namespace.utils.getPointer(2, this));
|
|
363
|
-
}
|
|
364
|
-
_disownExports() {
|
|
365
|
-
return $__namespace.utils.disown(this.exports);
|
|
366
|
-
}
|
|
367
|
-
/**
|
|
368
|
-
* The source map for the file.
|
|
369
|
-
*
|
|
370
|
-
*/
|
|
371
|
-
get exports() {
|
|
372
|
-
return $__namespace.utils.getList(2, $__namespace.TextList, this);
|
|
373
|
-
}
|
|
374
|
-
_hasExports() {
|
|
375
|
-
return !$__namespace.utils.isNull($__namespace.utils.getPointer(2, this));
|
|
376
|
-
}
|
|
377
|
-
_initExports(length) {
|
|
378
|
-
return $__namespace.utils.initList(2, $__namespace.TextList, length, this);
|
|
379
|
-
}
|
|
380
|
-
set exports(value) {
|
|
381
|
-
$__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(2, this));
|
|
382
|
-
}
|
|
383
|
-
get map() {
|
|
384
|
-
return $__namespace.utils.getText(3, this);
|
|
385
|
-
}
|
|
386
|
-
set map(value) {
|
|
387
|
-
$__namespace.utils.setText(3, value, this);
|
|
388
|
-
}
|
|
389
|
-
toString() {
|
|
390
|
-
return "PrebuiltData_" + super.toString();
|
|
391
|
-
}
|
|
392
|
-
};
|
|
393
|
-
var AssetData = class extends $__namespace.Struct {
|
|
394
|
-
static {
|
|
395
|
-
chunkUSNT2KNT_cjs.__name(this, "AssetData");
|
|
396
|
-
}
|
|
397
|
-
static _capnp = {
|
|
398
|
-
displayName: "AssetData",
|
|
399
|
-
id: "da660c6c1fa4c830",
|
|
400
|
-
size: new $__namespace.ObjectSize(8, 3)
|
|
401
|
-
};
|
|
402
|
-
/**
|
|
403
|
-
* An additional name for the file.
|
|
404
|
-
*
|
|
405
|
-
*/
|
|
406
|
-
get id() {
|
|
407
|
-
return $__namespace.utils.getText(0, this);
|
|
408
|
-
}
|
|
409
|
-
set id(value) {
|
|
410
|
-
$__namespace.utils.setText(0, value, this);
|
|
411
|
-
}
|
|
412
|
-
/**
|
|
413
|
-
* Indicates whether the file needs a code reference.
|
|
414
|
-
*
|
|
415
|
-
*/
|
|
416
|
-
get name() {
|
|
417
|
-
return $__namespace.utils.getText(1, this);
|
|
418
|
-
}
|
|
419
|
-
set name(value) {
|
|
420
|
-
$__namespace.utils.setText(1, value, this);
|
|
421
|
-
}
|
|
422
|
-
/**
|
|
423
|
-
* The original file name before any transformations.
|
|
424
|
-
*
|
|
425
|
-
*/
|
|
426
|
-
get needsCodeReference() {
|
|
427
|
-
return $__namespace.utils.getBit(0, this);
|
|
428
|
-
}
|
|
429
|
-
set needsCodeReference(value) {
|
|
430
|
-
$__namespace.utils.setBit(0, value, this);
|
|
431
|
-
}
|
|
432
|
-
get originalFileName() {
|
|
433
|
-
return $__namespace.utils.getText(2, this);
|
|
434
|
-
}
|
|
435
|
-
set originalFileName(value) {
|
|
436
|
-
$__namespace.utils.setText(2, value, this);
|
|
437
|
-
}
|
|
438
|
-
toString() {
|
|
439
|
-
return "AssetData_" + super.toString();
|
|
440
|
-
}
|
|
441
|
-
};
|
|
442
265
|
var FileId = class extends $__namespace.Struct {
|
|
443
266
|
static {
|
|
444
267
|
chunkUSNT2KNT_cjs.__name(this, "FileId");
|
|
@@ -504,14 +327,11 @@ var FileSystem = class _FileSystem extends $__namespace.Struct {
|
|
|
504
327
|
static _capnp = {
|
|
505
328
|
displayName: "FileSystem",
|
|
506
329
|
id: "ae0c23d43e56abcf",
|
|
507
|
-
size: new $__namespace.ObjectSize(0,
|
|
330
|
+
size: new $__namespace.ObjectSize(0, 3)
|
|
508
331
|
};
|
|
509
332
|
static _Ids;
|
|
510
333
|
static _Files;
|
|
511
334
|
static _Metadata;
|
|
512
|
-
static _Assets;
|
|
513
|
-
static _Chunks;
|
|
514
|
-
static _Prebuilt;
|
|
515
335
|
_adoptIds(value) {
|
|
516
336
|
$__namespace.utils.adopt(value, $__namespace.utils.getPointer(0, this));
|
|
517
337
|
}
|
|
@@ -566,60 +386,6 @@ var FileSystem = class _FileSystem extends $__namespace.Struct {
|
|
|
566
386
|
set metadata(value) {
|
|
567
387
|
$__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(2, this));
|
|
568
388
|
}
|
|
569
|
-
_adoptAssets(value) {
|
|
570
|
-
$__namespace.utils.adopt(value, $__namespace.utils.getPointer(3, this));
|
|
571
|
-
}
|
|
572
|
-
_disownAssets() {
|
|
573
|
-
return $__namespace.utils.disown(this.assets);
|
|
574
|
-
}
|
|
575
|
-
get assets() {
|
|
576
|
-
return $__namespace.utils.getList(3, _FileSystem._Assets, this);
|
|
577
|
-
}
|
|
578
|
-
_hasAssets() {
|
|
579
|
-
return !$__namespace.utils.isNull($__namespace.utils.getPointer(3, this));
|
|
580
|
-
}
|
|
581
|
-
_initAssets(length) {
|
|
582
|
-
return $__namespace.utils.initList(3, _FileSystem._Assets, length, this);
|
|
583
|
-
}
|
|
584
|
-
set assets(value) {
|
|
585
|
-
$__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(3, this));
|
|
586
|
-
}
|
|
587
|
-
_adoptChunks(value) {
|
|
588
|
-
$__namespace.utils.adopt(value, $__namespace.utils.getPointer(4, this));
|
|
589
|
-
}
|
|
590
|
-
_disownChunks() {
|
|
591
|
-
return $__namespace.utils.disown(this.chunks);
|
|
592
|
-
}
|
|
593
|
-
get chunks() {
|
|
594
|
-
return $__namespace.utils.getList(4, _FileSystem._Chunks, this);
|
|
595
|
-
}
|
|
596
|
-
_hasChunks() {
|
|
597
|
-
return !$__namespace.utils.isNull($__namespace.utils.getPointer(4, this));
|
|
598
|
-
}
|
|
599
|
-
_initChunks(length) {
|
|
600
|
-
return $__namespace.utils.initList(4, _FileSystem._Chunks, length, this);
|
|
601
|
-
}
|
|
602
|
-
set chunks(value) {
|
|
603
|
-
$__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(4, this));
|
|
604
|
-
}
|
|
605
|
-
_adoptPrebuilt(value) {
|
|
606
|
-
$__namespace.utils.adopt(value, $__namespace.utils.getPointer(5, this));
|
|
607
|
-
}
|
|
608
|
-
_disownPrebuilt() {
|
|
609
|
-
return $__namespace.utils.disown(this.prebuilt);
|
|
610
|
-
}
|
|
611
|
-
get prebuilt() {
|
|
612
|
-
return $__namespace.utils.getList(5, _FileSystem._Prebuilt, this);
|
|
613
|
-
}
|
|
614
|
-
_hasPrebuilt() {
|
|
615
|
-
return !$__namespace.utils.isNull($__namespace.utils.getPointer(5, this));
|
|
616
|
-
}
|
|
617
|
-
_initPrebuilt(length) {
|
|
618
|
-
return $__namespace.utils.initList(5, _FileSystem._Prebuilt, length, this);
|
|
619
|
-
}
|
|
620
|
-
set prebuilt(value) {
|
|
621
|
-
$__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(5, this));
|
|
622
|
-
}
|
|
623
389
|
toString() {
|
|
624
390
|
return "FileSystem_" + super.toString();
|
|
625
391
|
}
|
|
@@ -628,9 +394,6 @@ FileMetadata._Properties = $__namespace.CompositeList(FileMetadata_KeyValuePair)
|
|
|
628
394
|
FileSystem._Ids = $__namespace.CompositeList(FileId);
|
|
629
395
|
FileSystem._Files = $__namespace.CompositeList(FileData);
|
|
630
396
|
FileSystem._Metadata = $__namespace.CompositeList(FileMetadata);
|
|
631
|
-
FileSystem._Assets = $__namespace.CompositeList(AssetData);
|
|
632
|
-
FileSystem._Chunks = $__namespace.CompositeList(ChunkData);
|
|
633
|
-
FileSystem._Prebuilt = $__namespace.CompositeList(PrebuiltData);
|
|
634
397
|
|
|
635
398
|
// src/types/fs.ts
|
|
636
399
|
var __VFS_PATCH__ = "__VFS_PATCH__";
|
|
@@ -640,13 +403,9 @@ function isBufferEncoding(options) {
|
|
|
640
403
|
}
|
|
641
404
|
chunkUSNT2KNT_cjs.__name(isBufferEncoding, "isBufferEncoding");
|
|
642
405
|
function isPowerlinesWriteFileOptions(options) {
|
|
643
|
-
return !isBufferEncoding(options) && isSetObject.isSetObject(options) &&
|
|
406
|
+
return !isBufferEncoding(options) && isSetObject.isSetObject(options) && "mode" in options && (options.mode === "fs" || options.mode === "virtual");
|
|
644
407
|
}
|
|
645
408
|
chunkUSNT2KNT_cjs.__name(isPowerlinesWriteFileOptions, "isPowerlinesWriteFileOptions");
|
|
646
|
-
function isNodeWriteFileOptions(options) {
|
|
647
|
-
return !isUndefined.isUndefined(options) && (isBufferEncoding(options) || !isPowerlinesWriteFileOptions(options));
|
|
648
|
-
}
|
|
649
|
-
chunkUSNT2KNT_cjs.__name(isNodeWriteFileOptions, "isNodeWriteFileOptions");
|
|
650
409
|
function isVirtualFileData(obj) {
|
|
651
410
|
return !!(isSetObject.isSetObject(obj) && "code" in obj && obj.code);
|
|
652
411
|
}
|
|
@@ -783,6 +542,18 @@ function patchFS(originalFS, vfs) {
|
|
|
783
542
|
};
|
|
784
543
|
}
|
|
785
544
|
chunkUSNT2KNT_cjs.__name(patchFS, "patchFS");
|
|
545
|
+
function isValidId(id, prefix = "powerlines") {
|
|
546
|
+
return id.replace(/^\\0/, "").startsWith(`${prefix.replace(/:$/, "")}`);
|
|
547
|
+
}
|
|
548
|
+
chunkUSNT2KNT_cjs.__name(isValidId, "isValidId");
|
|
549
|
+
function normalizeId(id, prefix = "powerlines") {
|
|
550
|
+
return `${prefix.replace(/:$/, "")}:${toFilePath(id).replace(new RegExp(`^${prefix.replace(/:$/, "")}:`), "").replace(/^\\0/, "").replace(filePathFns.findFileDotExtensionSafe(toFilePath(id)), "")}`;
|
|
551
|
+
}
|
|
552
|
+
chunkUSNT2KNT_cjs.__name(normalizeId, "normalizeId");
|
|
553
|
+
function normalizePath(path, builtinsPath, prefix = "powerlines") {
|
|
554
|
+
return isValidId(toFilePath(path), prefix) ? normalizeId(toFilePath(path), prefix).replace(new RegExp(`^${prefix.replace(/:$/, "")}:`), builtinsPath) : toFilePath(path);
|
|
555
|
+
}
|
|
556
|
+
chunkUSNT2KNT_cjs.__name(normalizePath, "normalizePath");
|
|
786
557
|
var UnifiedFS = class _UnifiedFS extends unionfs.Union {
|
|
787
558
|
static {
|
|
788
559
|
chunkUSNT2KNT_cjs.__name(this, "UnifiedFS");
|
|
@@ -959,9 +730,9 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
959
730
|
*/
|
|
960
731
|
#paths;
|
|
961
732
|
/**
|
|
962
|
-
* A
|
|
733
|
+
* A cache for module resolution results.
|
|
963
734
|
*/
|
|
964
|
-
#
|
|
735
|
+
#resolverCache;
|
|
965
736
|
/**
|
|
966
737
|
* The unified volume that combines the virtual file system with the real file system.
|
|
967
738
|
*
|
|
@@ -996,189 +767,35 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
996
767
|
* @returns `true` if the path exists, otherwise `false`.
|
|
997
768
|
*/
|
|
998
769
|
#existsSync(path) {
|
|
999
|
-
|
|
1000
|
-
return this.#unifiedFS.virtual.existsSync(formattedPath) || this.#unifiedFS.physical.existsSync(formattedPath) || this.#unifiedFS.resolveFS(path).existsSync(formattedPath);
|
|
1001
|
-
}
|
|
1002
|
-
/**
|
|
1003
|
-
* Builds a regular expression from a string pattern for path matching.
|
|
1004
|
-
*
|
|
1005
|
-
* @param strPattern - The string pattern to convert.
|
|
1006
|
-
* @returns A regular expression for matching paths.
|
|
1007
|
-
*/
|
|
1008
|
-
#buildRegex(strPattern) {
|
|
1009
|
-
const token = "::GLOBSTAR::";
|
|
1010
|
-
return new RegExp(`^${this.formatPath(strPattern).replace(/\*\*/g, token).replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]").replace(new RegExp(token, "g"), ".*")}$`);
|
|
1011
|
-
}
|
|
1012
|
-
/**
|
|
1013
|
-
* Formats a file id by removing the file extension and prepending the runtime prefix.
|
|
1014
|
-
*
|
|
1015
|
-
* @param id - The file ID to format.
|
|
1016
|
-
* @returns The formatted file ID.
|
|
1017
|
-
*/
|
|
1018
|
-
#formatId(id) {
|
|
1019
|
-
const formattedId = toFilePath(id);
|
|
1020
|
-
return `${this.#context.config.output.builtinPrefix}:${formattedId.replace(new RegExp(`^${this.#context.config.output.builtinPrefix}:`), "").replace(/^\\0/, "").replace(filePathFns.findFileDotExtensionSafe(formattedId), "")}`;
|
|
1021
|
-
}
|
|
1022
|
-
/**
|
|
1023
|
-
* Resolves an id parameter to a corresponding virtual file path in the virtual file system (VFS).
|
|
1024
|
-
*
|
|
1025
|
-
* @param id - The id to resolve.
|
|
1026
|
-
* @returns The resolved file id if it exists, otherwise undefined.
|
|
1027
|
-
*/
|
|
1028
|
-
#resolveId(id) {
|
|
1029
|
-
if (this.#ids[this.#formatId(id)]) {
|
|
1030
|
-
return this.#ids[this.#formatId(id)] || false;
|
|
1031
|
-
}
|
|
1032
|
-
return false;
|
|
1033
|
-
}
|
|
1034
|
-
/**
|
|
1035
|
-
* Resolves a path parameter to a corresponding virtual file path in the virtual file system (VFS).
|
|
1036
|
-
*
|
|
1037
|
-
* @param path - The path to resolve.
|
|
1038
|
-
* @param options - Optional parameters for resolving the path.
|
|
1039
|
-
* @returns The resolved file path if it exists, otherwise undefined.
|
|
1040
|
-
*/
|
|
1041
|
-
#resolvePath(path, options = {}) {
|
|
1042
|
-
if (isType.isAbsolutePath(path)) {
|
|
1043
|
-
if (this.#existsSync(path)) {
|
|
1044
|
-
return path;
|
|
1045
|
-
}
|
|
1046
|
-
const result = this.#checkVariants(path);
|
|
1047
|
-
if (result) {
|
|
1048
|
-
return result;
|
|
1049
|
-
}
|
|
1050
|
-
}
|
|
1051
|
-
for (const parentPath of this.#resolveParentPaths(path, options.paths)) {
|
|
1052
|
-
const request = joinPaths.joinPaths(parentPath, path);
|
|
1053
|
-
if (this.#existsSync(request)) {
|
|
1054
|
-
return request;
|
|
1055
|
-
}
|
|
1056
|
-
const result = this.#checkVariants(request);
|
|
1057
|
-
if (result) {
|
|
1058
|
-
return result;
|
|
1059
|
-
}
|
|
1060
|
-
}
|
|
1061
|
-
return false;
|
|
1062
|
-
}
|
|
1063
|
-
/**
|
|
1064
|
-
* Resolves parent paths for a given request.
|
|
1065
|
-
*
|
|
1066
|
-
* @param request - The request path to resolve parent paths for.
|
|
1067
|
-
* @param parents - An optional array of parent paths to consider.
|
|
1068
|
-
* @returns An array of resolved parent paths.
|
|
1069
|
-
*/
|
|
1070
|
-
#resolveParentPaths(request, parents = []) {
|
|
1071
|
-
let paths = [
|
|
1072
|
-
this.#context.workspaceConfig.workspaceRoot,
|
|
1073
|
-
joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.projectRoot)
|
|
1074
|
-
];
|
|
1075
|
-
if (this.#context.tsconfig.options.paths) {
|
|
1076
|
-
paths = this.#context.tsconfig.options.paths ? Object.keys(this.#context.tsconfig.options.paths).filter((tsconfigPath) => request.startsWith(tsconfigPath.replaceAll("*", ""))).map((tsconfigPath) => this.#context.tsconfig.options.paths?.[tsconfigPath]).flat().reduce((ret, path) => {
|
|
1077
|
-
if (path && !ret.includes(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, path))) {
|
|
1078
|
-
ret.push(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, path));
|
|
1079
|
-
}
|
|
1080
|
-
return ret;
|
|
1081
|
-
}, paths) : paths;
|
|
1082
|
-
}
|
|
1083
|
-
return paths.reduce((ret, path) => {
|
|
1084
|
-
if (!ret.includes(path)) {
|
|
1085
|
-
ret.push(path);
|
|
1086
|
-
}
|
|
1087
|
-
return ret;
|
|
1088
|
-
}, parents.filter(Boolean).map((p) => this.formatPath(p)));
|
|
1089
|
-
}
|
|
1090
|
-
/**
|
|
1091
|
-
* Clears the resolver cache for a given path.
|
|
1092
|
-
*
|
|
1093
|
-
* @param path - The path to clear the resolver cache for.
|
|
1094
|
-
*/
|
|
1095
|
-
#clearResolverCache(path) {
|
|
1096
|
-
this.#cachedResolver.keys().filter((key) => key.startsWith(toFilePath(path))).forEach((key) => this.#cachedResolver.delete(key));
|
|
770
|
+
return this.#unifiedFS.virtual.existsSync(this.#normalizePath(path)) || this.#unifiedFS.physical.existsSync(this.#normalizePath(path)) || this.#unifiedFS.resolveFS(path).existsSync(this.#normalizePath(path));
|
|
1097
771
|
}
|
|
1098
772
|
/**
|
|
1099
|
-
*
|
|
773
|
+
* Normalizes a given module id by resolving it against the built-ins path.
|
|
1100
774
|
*
|
|
1101
|
-
* @param
|
|
1102
|
-
* @
|
|
1103
|
-
* @returns The file path if it exists, otherwise false.
|
|
775
|
+
* @param id - The module id to normalize.
|
|
776
|
+
* @returns The normalized module id.
|
|
1104
777
|
*/
|
|
1105
|
-
#
|
|
1106
|
-
|
|
1107
|
-
let file = this.#checkExtensions(path);
|
|
1108
|
-
if (file) {
|
|
1109
|
-
return file;
|
|
1110
|
-
}
|
|
1111
|
-
file = this.#checkIndex(path);
|
|
1112
|
-
if (file) {
|
|
1113
|
-
return file;
|
|
1114
|
-
}
|
|
1115
|
-
return false;
|
|
778
|
+
#normalizeId(id) {
|
|
779
|
+
return normalizeId(id, this.#context.config.output.builtinPrefix);
|
|
1116
780
|
}
|
|
1117
781
|
/**
|
|
1118
|
-
*
|
|
782
|
+
* Normalizes a given path by resolving it against the project root, workspace root, and built-ins path.
|
|
1119
783
|
*
|
|
1120
|
-
* @param
|
|
1121
|
-
* @returns The
|
|
784
|
+
* @param path - The path to normalize.
|
|
785
|
+
* @returns The normalized path.
|
|
1122
786
|
*/
|
|
1123
|
-
#
|
|
1124
|
-
|
|
1125
|
-
if (this.#existsSync(file)) {
|
|
1126
|
-
return file;
|
|
1127
|
-
}
|
|
1128
|
-
file = this.#checkExtensions(file);
|
|
1129
|
-
if (file) {
|
|
1130
|
-
return file;
|
|
1131
|
-
}
|
|
1132
|
-
return false;
|
|
787
|
+
#normalizePath(path) {
|
|
788
|
+
return normalizePath(path, this.#context.builtinsPath, this.#context.config.output.builtinPrefix);
|
|
1133
789
|
}
|
|
1134
790
|
/**
|
|
1135
|
-
*
|
|
791
|
+
* Builds a regular expression from a string pattern for path matching.
|
|
1136
792
|
*
|
|
1137
|
-
* @param
|
|
1138
|
-
* @returns
|
|
793
|
+
* @param path - The string pattern to convert.
|
|
794
|
+
* @returns A regular expression for matching paths.
|
|
1139
795
|
*/
|
|
1140
|
-
#
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
return file;
|
|
1144
|
-
}
|
|
1145
|
-
file = `${request}.mts`;
|
|
1146
|
-
if (this.#existsSync(file)) {
|
|
1147
|
-
return file;
|
|
1148
|
-
}
|
|
1149
|
-
file = `${request}.cts`;
|
|
1150
|
-
if (this.#existsSync(file)) {
|
|
1151
|
-
return file;
|
|
1152
|
-
}
|
|
1153
|
-
file = `${request}.tsx`;
|
|
1154
|
-
if (this.#existsSync(file)) {
|
|
1155
|
-
return file;
|
|
1156
|
-
}
|
|
1157
|
-
file = `${request}.js`;
|
|
1158
|
-
if (this.#existsSync(file)) {
|
|
1159
|
-
return file;
|
|
1160
|
-
}
|
|
1161
|
-
file = `${request}.mjs`;
|
|
1162
|
-
if (this.#existsSync(file)) {
|
|
1163
|
-
return file;
|
|
1164
|
-
}
|
|
1165
|
-
file = `${request}.cjs`;
|
|
1166
|
-
if (this.#existsSync(file)) {
|
|
1167
|
-
return file;
|
|
1168
|
-
}
|
|
1169
|
-
file = `${request}.jsx`;
|
|
1170
|
-
if (this.#existsSync(file)) {
|
|
1171
|
-
return file;
|
|
1172
|
-
}
|
|
1173
|
-
file = `${request}.json`;
|
|
1174
|
-
if (this.#existsSync(file)) {
|
|
1175
|
-
return file;
|
|
1176
|
-
}
|
|
1177
|
-
file = `${request}.d.ts`;
|
|
1178
|
-
if (this.#existsSync(file)) {
|
|
1179
|
-
return file;
|
|
1180
|
-
}
|
|
1181
|
-
return false;
|
|
796
|
+
#buildRegex(path) {
|
|
797
|
+
const token = "::GLOBSTAR::";
|
|
798
|
+
return new RegExp(`^${this.#normalizePath(path).replace(/\*\*/g, token).replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]").replace(new RegExp(token, "g"), ".*")}$`);
|
|
1182
799
|
}
|
|
1183
800
|
/**
|
|
1184
801
|
* Creates a virtual file system (VFS) that is backed up to a Cap'n Proto message buffer.
|
|
@@ -1187,8 +804,8 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1187
804
|
* @returns A promise that resolves to a new virtual file system instance.
|
|
1188
805
|
*/
|
|
1189
806
|
static async create(context) {
|
|
1190
|
-
if (!context.config.skipCache && exists.existsSync(joinPaths.joinPaths(context.
|
|
1191
|
-
const buffer$1 = await buffer.readFileBuffer(joinPaths.joinPaths(context.
|
|
807
|
+
if (!context.config.skipCache && exists.existsSync(joinPaths.joinPaths(context.dataPath, "fs.bin"))) {
|
|
808
|
+
const buffer$1 = await buffer.readFileBuffer(joinPaths.joinPaths(context.dataPath, "fs.bin"));
|
|
1192
809
|
const message2 = new $__namespace.Message(buffer$1, false);
|
|
1193
810
|
return new _VirtualFileSystem(context, message2.getRoot(FileSystem));
|
|
1194
811
|
}
|
|
@@ -1202,8 +819,8 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1202
819
|
* @returns A new virtual file system instance.
|
|
1203
820
|
*/
|
|
1204
821
|
static createSync(context) {
|
|
1205
|
-
if (!context.config.skipCache && exists.existsSync(joinPaths.joinPaths(context.
|
|
1206
|
-
const buffer$1 = buffer.readFileBufferSync(joinPaths.joinPaths(context.
|
|
822
|
+
if (!context.config.skipCache && exists.existsSync(joinPaths.joinPaths(context.dataPath, "fs.bin"))) {
|
|
823
|
+
const buffer$1 = buffer.readFileBufferSync(joinPaths.joinPaths(context.dataPath, "fs.bin"));
|
|
1207
824
|
const message2 = new $__namespace.Message(buffer$1, false);
|
|
1208
825
|
return new _VirtualFileSystem(context, message2.getRoot(FileSystem));
|
|
1209
826
|
}
|
|
@@ -1214,19 +831,43 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1214
831
|
* A map of file ids to their metadata.
|
|
1215
832
|
*/
|
|
1216
833
|
get metadata() {
|
|
1217
|
-
return this.#metadata
|
|
834
|
+
return new Proxy(this.#metadata, {
|
|
835
|
+
get: /* @__PURE__ */ chunkUSNT2KNT_cjs.__name((target, prop) => {
|
|
836
|
+
return target[this.#normalizeId(prop)];
|
|
837
|
+
}, "get")
|
|
838
|
+
});
|
|
1218
839
|
}
|
|
1219
840
|
/**
|
|
1220
|
-
* A map of
|
|
841
|
+
* A map of file paths to their module ids.
|
|
1221
842
|
*/
|
|
1222
843
|
get ids() {
|
|
1223
|
-
return this.#
|
|
844
|
+
return new Proxy(this.#paths, {
|
|
845
|
+
get: /* @__PURE__ */ chunkUSNT2KNT_cjs.__name((target, prop) => {
|
|
846
|
+
return target[this.#normalizePath(prop)];
|
|
847
|
+
}, "get")
|
|
848
|
+
});
|
|
1224
849
|
}
|
|
1225
850
|
/**
|
|
1226
|
-
* A map of
|
|
851
|
+
* A map of module ids to their file paths.
|
|
1227
852
|
*/
|
|
1228
853
|
get paths() {
|
|
1229
|
-
return this.#paths
|
|
854
|
+
return new Proxy(this.#paths, {
|
|
855
|
+
get: /* @__PURE__ */ chunkUSNT2KNT_cjs.__name((target, prop) => {
|
|
856
|
+
return target[this.#normalizeId(prop)];
|
|
857
|
+
}, "get")
|
|
858
|
+
});
|
|
859
|
+
}
|
|
860
|
+
get resolverCache() {
|
|
861
|
+
if (!this.#resolverCache) {
|
|
862
|
+
this.#resolverCache = flatCache.create({
|
|
863
|
+
cacheId: "module-resolution",
|
|
864
|
+
cacheDir: this.#context.cachePath,
|
|
865
|
+
ttl: 60 * 60 * 1e3,
|
|
866
|
+
lruSize: 5e3,
|
|
867
|
+
persistInterval: 100
|
|
868
|
+
});
|
|
869
|
+
}
|
|
870
|
+
return this.#resolverCache;
|
|
1230
871
|
}
|
|
1231
872
|
/**
|
|
1232
873
|
* Creates a new instance of the {@link VirtualFileSystem}.
|
|
@@ -1271,17 +912,13 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1271
912
|
* Check if a path or id corresponds to a virtual file **(does not actually exists on disk)**.
|
|
1272
913
|
*
|
|
1273
914
|
* @param pathOrId - The path or id to check.
|
|
1274
|
-
* @param options - Optional parameters for resolving the path.
|
|
1275
915
|
* @returns Whether the path or id corresponds to a virtual file **(does not actually exists on disk)**.
|
|
1276
916
|
*/
|
|
1277
|
-
isVirtual(pathOrId, options = {}) {
|
|
917
|
+
isVirtual(pathOrId, importer, options = {}) {
|
|
1278
918
|
if (!pathOrId) {
|
|
1279
919
|
return false;
|
|
1280
920
|
}
|
|
1281
|
-
const resolvedPath = this.
|
|
1282
|
-
...options,
|
|
1283
|
-
pathType: "file"
|
|
1284
|
-
});
|
|
921
|
+
const resolvedPath = this.resolveSync(pathOrId, importer, options);
|
|
1285
922
|
if (!resolvedPath) {
|
|
1286
923
|
return false;
|
|
1287
924
|
}
|
|
@@ -1291,17 +928,13 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1291
928
|
* Check if a path or id corresponds to a file written to the file system **(actually exists on disk)**.
|
|
1292
929
|
*
|
|
1293
930
|
* @param pathOrId - The path or id to check.
|
|
1294
|
-
* @param options - Optional parameters for resolving the path.
|
|
1295
931
|
* @returns Whether the path or id corresponds to a file written to the file system **(actually exists on disk)**.
|
|
1296
932
|
*/
|
|
1297
|
-
isPhysical(pathOrId, options = {}) {
|
|
933
|
+
isPhysical(pathOrId, importer, options = {}) {
|
|
1298
934
|
if (!pathOrId) {
|
|
1299
935
|
return false;
|
|
1300
936
|
}
|
|
1301
|
-
const resolvedPath = this.
|
|
1302
|
-
...options,
|
|
1303
|
-
pathType: "file"
|
|
1304
|
-
});
|
|
937
|
+
const resolvedPath = this.resolveSync(pathOrId, importer, options);
|
|
1305
938
|
if (!resolvedPath) {
|
|
1306
939
|
return false;
|
|
1307
940
|
}
|
|
@@ -1323,16 +956,17 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1323
956
|
* @param path - The path to create the directory at.
|
|
1324
957
|
*/
|
|
1325
958
|
unlinkSync(path, options) {
|
|
1326
|
-
|
|
1327
|
-
if (!this.isFile(formattedPath)) {
|
|
959
|
+
if (!this.isFile(this.#normalizePath(path))) {
|
|
1328
960
|
return;
|
|
1329
961
|
}
|
|
1330
|
-
this.#log(types.LogLevelLabel.TRACE, `Synchronously removing file: ${
|
|
1331
|
-
this.#unifiedFS.resolveFS(path, options).unlinkSync(
|
|
1332
|
-
if (this
|
|
1333
|
-
delete this
|
|
962
|
+
this.#log(types.LogLevelLabel.TRACE, `Synchronously removing file: ${this.#normalizePath(path)}`);
|
|
963
|
+
this.#unifiedFS.resolveFS(path, options).unlinkSync(this.#normalizePath(path));
|
|
964
|
+
if (this.#ids[this.#normalizePath(path)] && this.#metadata[this.#ids[this.#normalizePath(path)]]) {
|
|
965
|
+
delete this.#metadata[this.#ids[this.#normalizePath(path)]];
|
|
966
|
+
delete this.#ids[this.#normalizePath(path)];
|
|
967
|
+
delete this.#paths[this.#normalizeId(path)];
|
|
968
|
+
this.#resolverCache.delete(this.#normalizePath(path));
|
|
1334
969
|
}
|
|
1335
|
-
this.#clearResolverCache(formattedPath);
|
|
1336
970
|
}
|
|
1337
971
|
/**
|
|
1338
972
|
* Removes a file in the virtual file system (VFS).
|
|
@@ -1340,19 +974,17 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1340
974
|
* @param path - The path to create the directory at.
|
|
1341
975
|
*/
|
|
1342
976
|
async unlink(path, options) {
|
|
1343
|
-
|
|
1344
|
-
if (!this.isFile(formattedPath)) {
|
|
977
|
+
if (!this.isFile(this.#normalizePath(path))) {
|
|
1345
978
|
return;
|
|
1346
979
|
}
|
|
1347
|
-
this.#log(types.LogLevelLabel.TRACE, `Removing file: ${
|
|
980
|
+
this.#log(types.LogLevelLabel.TRACE, `Removing file: ${this.#normalizePath(path)}`);
|
|
1348
981
|
if (isFunction.isFunction(this.#unifiedFS.resolveFS(path, options).promises.unlink)) {
|
|
1349
|
-
await this.#unifiedFS.resolveFS(path, options).promises.unlink(
|
|
1350
|
-
if (this
|
|
1351
|
-
delete this
|
|
982
|
+
await this.#unifiedFS.resolveFS(path, options).promises.unlink(this.#normalizePath(path));
|
|
983
|
+
if (this.#ids[this.#normalizePath(path)] && this.#metadata[this.#ids[this.#normalizePath(path)]]) {
|
|
984
|
+
delete this.#metadata[this.#ids[this.#normalizePath(path)]];
|
|
1352
985
|
}
|
|
1353
|
-
this.#clearResolverCache(formattedPath);
|
|
1354
986
|
} else {
|
|
1355
|
-
this.unlinkSync(
|
|
987
|
+
this.unlinkSync(this.#normalizePath(path), options);
|
|
1356
988
|
}
|
|
1357
989
|
}
|
|
1358
990
|
/**
|
|
@@ -1362,15 +994,13 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1362
994
|
* @param options - Options for creating the directory.
|
|
1363
995
|
*/
|
|
1364
996
|
rmdirSync(path, options = {}) {
|
|
1365
|
-
|
|
1366
|
-
if (!this.isDirectory(formattedPath)) {
|
|
997
|
+
if (!this.isDirectory(this.#normalizePath(path))) {
|
|
1367
998
|
return;
|
|
1368
999
|
}
|
|
1369
|
-
this.#log(types.LogLevelLabel.TRACE, `Synchronously removing directory: ${
|
|
1370
|
-
this.#unifiedFS.resolveFS(path, options).rmdirSync(
|
|
1000
|
+
this.#log(types.LogLevelLabel.TRACE, `Synchronously removing directory: ${this.#normalizePath(path)}`);
|
|
1001
|
+
this.#unifiedFS.resolveFS(path, options).rmdirSync(this.#normalizePath(path), defu2__default.default(options, {
|
|
1371
1002
|
recursive: true
|
|
1372
1003
|
}));
|
|
1373
|
-
this.#clearResolverCache(formattedPath);
|
|
1374
1004
|
}
|
|
1375
1005
|
/**
|
|
1376
1006
|
* Removes a directory in the virtual file system (VFS).
|
|
@@ -1380,19 +1010,17 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1380
1010
|
* @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
|
|
1381
1011
|
*/
|
|
1382
1012
|
async rmdir(path, options = {}) {
|
|
1383
|
-
|
|
1384
|
-
if (!this.isDirectory(formattedPath)) {
|
|
1013
|
+
if (!this.isDirectory(this.#normalizePath(path))) {
|
|
1385
1014
|
return;
|
|
1386
1015
|
}
|
|
1387
|
-
this.#log(types.LogLevelLabel.TRACE, `Removing directory: ${
|
|
1016
|
+
this.#log(types.LogLevelLabel.TRACE, `Removing directory: ${this.#normalizePath(path)}`);
|
|
1388
1017
|
if (isFunction.isFunction(this.#unifiedFS.resolveFS(path, options).promises.rm)) {
|
|
1389
|
-
await this.#unifiedFS.resolveFS(path, options).promises.rm(
|
|
1018
|
+
await this.#unifiedFS.resolveFS(path, options).promises.rm(this.#normalizePath(path), defu2__default.default(options, {
|
|
1390
1019
|
force: true,
|
|
1391
1020
|
recursive: true
|
|
1392
1021
|
}));
|
|
1393
|
-
this.#clearResolverCache(formattedPath);
|
|
1394
1022
|
} else {
|
|
1395
|
-
this.rmdirSync(
|
|
1023
|
+
this.rmdirSync(this.#normalizePath(path), defu2__default.default(options ?? {}, {
|
|
1396
1024
|
force: true,
|
|
1397
1025
|
recursive: true
|
|
1398
1026
|
}));
|
|
@@ -1406,11 +1034,11 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1406
1034
|
* @returns A promise that resolves when the file is removed.
|
|
1407
1035
|
*/
|
|
1408
1036
|
async rm(path, options = {}) {
|
|
1409
|
-
this.#log(types.LogLevelLabel.TRACE, `Removing: ${
|
|
1410
|
-
if (this.isDirectory(path)) {
|
|
1411
|
-
return this.rmdir(path, options);
|
|
1037
|
+
this.#log(types.LogLevelLabel.TRACE, `Removing: ${this.#normalizePath(path)}`);
|
|
1038
|
+
if (this.isDirectory(this.#normalizePath(path))) {
|
|
1039
|
+
return this.rmdir(this.#normalizePath(path), options);
|
|
1412
1040
|
}
|
|
1413
|
-
return this.unlink(path, options);
|
|
1041
|
+
return this.unlink(this.#normalizePath(path), options);
|
|
1414
1042
|
}
|
|
1415
1043
|
/**
|
|
1416
1044
|
* Synchronously removes a file or directory in the virtual file system (VFS).
|
|
@@ -1419,11 +1047,11 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1419
1047
|
* @param options - Options for removing the file or directory.
|
|
1420
1048
|
*/
|
|
1421
1049
|
rmSync(path, options = {}) {
|
|
1422
|
-
this.#log(types.LogLevelLabel.TRACE, `Removing: ${
|
|
1423
|
-
if (this.isDirectory(path)) {
|
|
1424
|
-
return this.rmdirSync(path, options);
|
|
1050
|
+
this.#log(types.LogLevelLabel.TRACE, `Removing: ${this.#normalizePath(path)}`);
|
|
1051
|
+
if (this.isDirectory(this.#normalizePath(path))) {
|
|
1052
|
+
return this.rmdirSync(this.#normalizePath(path), options);
|
|
1425
1053
|
}
|
|
1426
|
-
return this.unlinkSync(path, options);
|
|
1054
|
+
return this.unlinkSync(this.#normalizePath(path), options);
|
|
1427
1055
|
}
|
|
1428
1056
|
/**
|
|
1429
1057
|
* Creates a directory in the virtual file system (VFS).
|
|
@@ -1433,9 +1061,9 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1433
1061
|
* @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
|
|
1434
1062
|
*/
|
|
1435
1063
|
mkdirSync(path, options = {}) {
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1064
|
+
return this.#unifiedFS.resolveFS(this.#normalizePath(path), options).mkdirSync(this.#normalizePath(path), defu2__default.default(omit.omit(options, [
|
|
1065
|
+
"mode"
|
|
1066
|
+
]), {
|
|
1439
1067
|
recursive: true
|
|
1440
1068
|
}));
|
|
1441
1069
|
}
|
|
@@ -1448,17 +1076,19 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1448
1076
|
*/
|
|
1449
1077
|
async mkdir(path, options = {}) {
|
|
1450
1078
|
let result;
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1079
|
+
if (isFunction.isFunction(this.#unifiedFS.resolveFS(this.#normalizePath(path), options).promises.mkdir)) {
|
|
1080
|
+
result = await this.#unifiedFS.resolveFS(this.#normalizePath(path), options).promises.mkdir(this.#normalizePath(path), defu2__default.default(omit.omit(options, [
|
|
1081
|
+
"mode"
|
|
1082
|
+
]), {
|
|
1454
1083
|
recursive: true
|
|
1455
1084
|
}));
|
|
1456
1085
|
} else {
|
|
1457
|
-
result = this.#unifiedFS.resolveFS(
|
|
1086
|
+
result = this.#unifiedFS.resolveFS(this.#normalizePath(path), options).mkdirSync(this.#normalizePath(path), defu2__default.default(omit.omit(options, [
|
|
1087
|
+
"mode"
|
|
1088
|
+
]), {
|
|
1458
1089
|
recursive: true
|
|
1459
1090
|
}));
|
|
1460
1091
|
}
|
|
1461
|
-
this.#clearResolverCache(filePath);
|
|
1462
1092
|
return result;
|
|
1463
1093
|
}
|
|
1464
1094
|
/**
|
|
@@ -1470,17 +1100,15 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1470
1100
|
async glob(patterns) {
|
|
1471
1101
|
const results = [];
|
|
1472
1102
|
for (const pattern of toArray.toArray(patterns)) {
|
|
1473
|
-
const normalized = this
|
|
1103
|
+
const normalized = this.#normalizePath(pattern);
|
|
1474
1104
|
if (!/[*?[\]{}]/.test(normalized) && !normalized.includes("**")) {
|
|
1475
|
-
const resolved = this.
|
|
1476
|
-
pathType: "file"
|
|
1477
|
-
});
|
|
1105
|
+
const resolved = this.resolveSync(normalized);
|
|
1478
1106
|
if (resolved && !results.includes(resolved)) {
|
|
1479
1107
|
results.push(resolved);
|
|
1480
1108
|
}
|
|
1481
1109
|
continue;
|
|
1482
1110
|
}
|
|
1483
|
-
const absPattern = isType.isAbsolutePath(normalized) ? normalized : this
|
|
1111
|
+
const absPattern = isType.isAbsolutePath(normalized) ? normalized : this.#normalizePath(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, normalized));
|
|
1484
1112
|
const firstGlobIdx = absPattern.search(/[*?[\]{}]/);
|
|
1485
1113
|
const baseDir = firstGlobIdx === -1 ? filePathFns.findFilePath(absPattern) : absPattern.slice(0, Math.max(0, absPattern.lastIndexOf("/", firstGlobIdx)));
|
|
1486
1114
|
const stack = [
|
|
@@ -1495,7 +1123,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1495
1123
|
continue;
|
|
1496
1124
|
}
|
|
1497
1125
|
for (const entry of entries) {
|
|
1498
|
-
const full = this
|
|
1126
|
+
const full = this.#normalizePath(joinPaths.joinPaths(dir, entry));
|
|
1499
1127
|
let stats;
|
|
1500
1128
|
try {
|
|
1501
1129
|
stats = this.#unifiedFS.lstatSync(full);
|
|
@@ -1507,9 +1135,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1507
1135
|
stack.push(full);
|
|
1508
1136
|
} else if (stats.isFile()) {
|
|
1509
1137
|
if (this.#buildRegex(absPattern).test(full)) {
|
|
1510
|
-
const resolved = this.
|
|
1511
|
-
pathType: "file"
|
|
1512
|
-
});
|
|
1138
|
+
const resolved = this.resolveSync(full);
|
|
1513
1139
|
if (resolved && !results.includes(resolved)) {
|
|
1514
1140
|
results.push(resolved);
|
|
1515
1141
|
}
|
|
@@ -1529,17 +1155,15 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1529
1155
|
globSync(patterns) {
|
|
1530
1156
|
const results = [];
|
|
1531
1157
|
for (const pattern of toArray.toArray(patterns)) {
|
|
1532
|
-
const normalized = this
|
|
1158
|
+
const normalized = this.#normalizePath(pattern);
|
|
1533
1159
|
if (!/[*?[\]{}]/.test(normalized) && !normalized.includes("**")) {
|
|
1534
|
-
const resolved = this.
|
|
1535
|
-
pathType: "file"
|
|
1536
|
-
});
|
|
1160
|
+
const resolved = this.resolveSync(normalized);
|
|
1537
1161
|
if (resolved && !results.includes(resolved)) {
|
|
1538
1162
|
results.push(resolved);
|
|
1539
1163
|
}
|
|
1540
1164
|
continue;
|
|
1541
1165
|
}
|
|
1542
|
-
const absPattern = isType.isAbsolutePath(normalized) ? normalized : this
|
|
1166
|
+
const absPattern = isType.isAbsolutePath(normalized) ? normalized : this.#normalizePath(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, normalized));
|
|
1543
1167
|
const firstGlobIdx = absPattern.search(/[*?[\]{}]/);
|
|
1544
1168
|
const baseDir = firstGlobIdx === -1 ? filePathFns.findFilePath(absPattern) : absPattern.slice(0, Math.max(0, absPattern.lastIndexOf("/", firstGlobIdx)));
|
|
1545
1169
|
const stack = [
|
|
@@ -1554,7 +1178,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1554
1178
|
continue;
|
|
1555
1179
|
}
|
|
1556
1180
|
for (const entry of entries) {
|
|
1557
|
-
const full = this
|
|
1181
|
+
const full = this.#normalizePath(joinPaths.joinPaths(dir, entry));
|
|
1558
1182
|
let stats;
|
|
1559
1183
|
try {
|
|
1560
1184
|
stats = this.#unifiedFS.lstatSync(full);
|
|
@@ -1566,9 +1190,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1566
1190
|
stack.push(full);
|
|
1567
1191
|
} else if (stats.isFile()) {
|
|
1568
1192
|
if (this.#buildRegex(absPattern).test(full)) {
|
|
1569
|
-
const resolved = this.
|
|
1570
|
-
pathType: "file"
|
|
1571
|
-
});
|
|
1193
|
+
const resolved = this.resolveSync(full);
|
|
1572
1194
|
if (resolved && !results.includes(resolved)) {
|
|
1573
1195
|
results.push(resolved);
|
|
1574
1196
|
}
|
|
@@ -1638,21 +1260,15 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1638
1260
|
* @returns A promise that resolves to the contents of the file as a string, or undefined if the file does not exist.
|
|
1639
1261
|
*/
|
|
1640
1262
|
async readFile(pathOrId, options = "utf8") {
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
}
|
|
1644
|
-
const filePath = this.resolve(toFilePath(pathOrId), {
|
|
1645
|
-
pathType: "file"
|
|
1646
|
-
});
|
|
1647
|
-
if (filePath) {
|
|
1263
|
+
const filePath = await this.resolve(pathOrId);
|
|
1264
|
+
if (filePath && this.isFile(filePath)) {
|
|
1648
1265
|
let result;
|
|
1649
1266
|
if (isFunction.isFunction(this.#unifiedFS.resolveFS(filePath).promises.readFile)) {
|
|
1650
1267
|
result = (await this.#unifiedFS.resolveFS(filePath).promises.readFile(filePath, options))?.toString("utf8");
|
|
1651
1268
|
} else {
|
|
1652
1269
|
result = this.#unifiedFS.resolveFS(filePath).readFileSync(filePath, options);
|
|
1653
1270
|
}
|
|
1654
|
-
|
|
1655
|
-
return content;
|
|
1271
|
+
return isBuffer.isBuffer(result) ? bufferToString.bufferToString(result) : result;
|
|
1656
1272
|
}
|
|
1657
1273
|
return void 0;
|
|
1658
1274
|
}
|
|
@@ -1663,16 +1279,10 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1663
1279
|
* @returns The contents of the file as a string, or undefined if the file does not exist.
|
|
1664
1280
|
*/
|
|
1665
1281
|
readFileSync(pathOrId, options = "utf8") {
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
}
|
|
1669
|
-
const filePath = this.resolve(toFilePath(pathOrId), {
|
|
1670
|
-
pathType: "file"
|
|
1671
|
-
});
|
|
1672
|
-
if (filePath) {
|
|
1282
|
+
const filePath = this.resolveSync(pathOrId);
|
|
1283
|
+
if (filePath && this.isFile(filePath)) {
|
|
1673
1284
|
const result = this.#unifiedFS.resolveFS(filePath).readFileSync(filePath, options);
|
|
1674
|
-
|
|
1675
|
-
return content;
|
|
1285
|
+
return isBuffer.isBuffer(result) ? bufferToString.bufferToString(result) : result;
|
|
1676
1286
|
}
|
|
1677
1287
|
return void 0;
|
|
1678
1288
|
}
|
|
@@ -1685,34 +1295,40 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1685
1295
|
* @returns A promise that resolves when the file is written.
|
|
1686
1296
|
*/
|
|
1687
1297
|
async writeFile(path, data = "", options = "utf8") {
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
await this.mkdir(filePathFns.findFilePath(formattedPath), isPowerlinesWriteFileOptions(options) ? options : void 0);
|
|
1298
|
+
if (!this.isDirectory(filePathFns.findFilePath(this.#normalizePath(path)))) {
|
|
1299
|
+
await this.mkdir(filePathFns.findFilePath(this.#normalizePath(path)), isPowerlinesWriteFileOptions(options) ? options : void 0);
|
|
1691
1300
|
}
|
|
1692
|
-
|
|
1301
|
+
const metadata = isVirtualFileData(data) ? data : {};
|
|
1302
|
+
metadata.id = this.#normalizeId(path);
|
|
1303
|
+
let code = isVirtualFileData(data) ? metadata.code : data;
|
|
1693
1304
|
if ((!isPowerlinesWriteFileOptions(options) || !options.skipFormat) && isSetString.isSetString(code)) {
|
|
1694
|
-
const resolvedConfig = await prettier.resolveConfig(
|
|
1305
|
+
const resolvedConfig = await prettier.resolveConfig(this.#normalizePath(path));
|
|
1695
1306
|
if (resolvedConfig) {
|
|
1696
1307
|
code = await prettier.format(code, {
|
|
1697
|
-
absolutePath:
|
|
1308
|
+
absolutePath: this.#normalizePath(path),
|
|
1698
1309
|
...resolvedConfig
|
|
1699
1310
|
});
|
|
1700
1311
|
}
|
|
1701
1312
|
}
|
|
1702
|
-
const outputMode = this.#unifiedFS.resolveMode(
|
|
1703
|
-
this.#log(types.LogLevelLabel.TRACE, `Writing ${
|
|
1704
|
-
this
|
|
1313
|
+
const outputMode = this.#unifiedFS.resolveMode(this.#normalizePath(path), isPowerlinesWriteFileOptions(options) ? options : void 0);
|
|
1314
|
+
this.#log(types.LogLevelLabel.TRACE, `Writing ${this.#normalizePath(path)} file to the ${outputMode === "fs" ? "" : "virtual "}file system (size: ${prettyBytes.prettyBytes(new buffer$1.Blob(toArray.toArray(code)).size)})`);
|
|
1315
|
+
this.#metadata[metadata.id] = {
|
|
1705
1316
|
mode: outputMode,
|
|
1706
1317
|
variant: "normal",
|
|
1707
1318
|
timestamp: Date.now(),
|
|
1708
|
-
...
|
|
1319
|
+
...metadata
|
|
1709
1320
|
};
|
|
1710
|
-
this.#
|
|
1711
|
-
|
|
1321
|
+
this.#paths[metadata.id] = this.#normalizePath(path);
|
|
1322
|
+
this.#ids[this.#normalizePath(path)] = metadata.id;
|
|
1323
|
+
const ifs = this.#unifiedFS.resolveFS(this.#normalizePath(path), isPowerlinesWriteFileOptions(options) ? options : void 0);
|
|
1712
1324
|
if (isFunction.isFunction(ifs.promises.writeFile)) {
|
|
1713
|
-
return ifs.promises.writeFile(
|
|
1325
|
+
return ifs.promises.writeFile(this.#normalizePath(path), code, isSetObject.isSetObject(options) ? omit.omit(options, [
|
|
1326
|
+
"mode"
|
|
1327
|
+
]) : "utf8");
|
|
1714
1328
|
}
|
|
1715
|
-
return ifs.writeFileSync(
|
|
1329
|
+
return ifs.writeFileSync(this.#normalizePath(path), code, isSetObject.isSetObject(options) ? omit.omit(options, [
|
|
1330
|
+
"mode"
|
|
1331
|
+
]) : "utf8");
|
|
1716
1332
|
}
|
|
1717
1333
|
/**
|
|
1718
1334
|
* Synchronously writes a file to the virtual file system (VFS).
|
|
@@ -1722,21 +1338,23 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1722
1338
|
* @param options - Optional parameters for writing the file.
|
|
1723
1339
|
*/
|
|
1724
1340
|
writeFileSync(path, data = "", options = "utf8") {
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
}
|
|
1729
|
-
|
|
1730
|
-
const
|
|
1731
|
-
this.#
|
|
1732
|
-
this.
|
|
1341
|
+
if (!this.isDirectory(filePathFns.findFilePath(this.#normalizePath(path)))) {
|
|
1342
|
+
this.mkdirSync(filePathFns.findFilePath(this.#normalizePath(path)), isPowerlinesWriteFileOptions(options) ? options : void 0);
|
|
1343
|
+
}
|
|
1344
|
+
const metadata = isVirtualFileData(data) ? data : {};
|
|
1345
|
+
metadata.id = this.#normalizeId(path);
|
|
1346
|
+
const code = isVirtualFileData(data) ? metadata.code : data;
|
|
1347
|
+
const outputMode = this.#unifiedFS.resolveMode(this.#normalizePath(path), isPowerlinesWriteFileOptions(options) ? options : void 0);
|
|
1348
|
+
this.#log(types.LogLevelLabel.TRACE, `Writing ${this.#normalizePath(path)} file to the ${outputMode === "fs" ? "" : "virtual "}file system (size: ${prettyBytes.prettyBytes(new buffer$1.Blob(toArray.toArray(code)).size)})`);
|
|
1349
|
+
this.#metadata[metadata.id] = {
|
|
1733
1350
|
mode: outputMode,
|
|
1734
1351
|
variant: "normal",
|
|
1735
1352
|
timestamp: Date.now(),
|
|
1736
|
-
...
|
|
1353
|
+
...metadata
|
|
1737
1354
|
};
|
|
1738
|
-
this.#
|
|
1739
|
-
|
|
1355
|
+
this.#paths[metadata.id] = this.#normalizePath(path);
|
|
1356
|
+
this.#ids[this.#normalizePath(path)] = metadata.id;
|
|
1357
|
+
const writeStream = this.#unifiedFS.resolveFS(this.#normalizePath(path), isPowerlinesWriteFileOptions(options) ? options : void 0).createWriteStream(this.#normalizePath(path));
|
|
1740
1358
|
try {
|
|
1741
1359
|
writeStream.write(code);
|
|
1742
1360
|
} finally {
|
|
@@ -1750,7 +1368,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1750
1368
|
* @returns `true` if the file exists, otherwise `false`.
|
|
1751
1369
|
*/
|
|
1752
1370
|
existsSync(pathOrId) {
|
|
1753
|
-
return this.
|
|
1371
|
+
return !!this.resolveSync(pathOrId);
|
|
1754
1372
|
}
|
|
1755
1373
|
/**
|
|
1756
1374
|
* Retrieves the metadata of a file in the virtual file system (VFS).
|
|
@@ -1759,7 +1377,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1759
1377
|
* @returns The metadata of the file, or undefined if the file does not exist.
|
|
1760
1378
|
*/
|
|
1761
1379
|
getMetadata(pathOrId) {
|
|
1762
|
-
const resolved = this.
|
|
1380
|
+
const resolved = this.resolveSync(pathOrId);
|
|
1763
1381
|
if (resolved && this.metadata[resolved]) {
|
|
1764
1382
|
return this.metadata[resolved];
|
|
1765
1383
|
}
|
|
@@ -1775,7 +1393,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1775
1393
|
* @returns `true` if the file exists, otherwise `false`.
|
|
1776
1394
|
*/
|
|
1777
1395
|
isFile(pathOrId) {
|
|
1778
|
-
const resolved = this.
|
|
1396
|
+
const resolved = this.resolveSync(pathOrId);
|
|
1779
1397
|
return !!(resolved && (this.#unifiedFS.virtual.existsSync(resolved) && this.#unifiedFS.virtual.lstatSync(resolved).isFile() || this.#unifiedFS.physical.existsSync(resolved) && this.#unifiedFS.physical.lstatSync(resolved).isFile() || this.#unifiedFS.resolveFS(resolved).existsSync(resolved) && this.#unifiedFS.resolveFS(resolved).lstatSync(resolved).isFile()));
|
|
1780
1398
|
}
|
|
1781
1399
|
/**
|
|
@@ -1785,7 +1403,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1785
1403
|
* @returns `true` if the directory exists, otherwise `false`.
|
|
1786
1404
|
*/
|
|
1787
1405
|
isDirectory(pathOrId) {
|
|
1788
|
-
const resolved = this.
|
|
1406
|
+
const resolved = this.resolveSync(pathOrId);
|
|
1789
1407
|
return !!(resolved && (this.#unifiedFS.virtual.existsSync(resolved) && this.#unifiedFS.virtual.lstatSync(resolved).isDirectory() || this.#unifiedFS.physical.existsSync(resolved) && this.#unifiedFS.physical.lstatSync(resolved).isDirectory() || this.#unifiedFS.resolveFS(resolved).existsSync(resolved) && this.#unifiedFS.resolveFS(resolved).lstatSync(resolved).isDirectory()));
|
|
1790
1408
|
}
|
|
1791
1409
|
/**
|
|
@@ -1795,7 +1413,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1795
1413
|
* @returns A promise that resolves to the file's status information, or false if the file does not exist.
|
|
1796
1414
|
*/
|
|
1797
1415
|
async stat(pathOrId, options) {
|
|
1798
|
-
return this.#unifiedFS.resolveFS(pathOrId).promises.stat(this.resolve(
|
|
1416
|
+
return this.#unifiedFS.resolveFS(pathOrId).promises.stat(await this.resolve(pathOrId) || pathOrId, options);
|
|
1799
1417
|
}
|
|
1800
1418
|
/**
|
|
1801
1419
|
* Synchronously retrieves the status of a file in the virtual file system (VFS).
|
|
@@ -1804,7 +1422,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1804
1422
|
* @returns The file's status information, or false if the file does not exist.
|
|
1805
1423
|
*/
|
|
1806
1424
|
statSync(pathOrId) {
|
|
1807
|
-
return this.#unifiedFS.resolveFS(pathOrId).statSync(this.
|
|
1425
|
+
return this.#unifiedFS.resolveFS(pathOrId).statSync(this.resolveSync(pathOrId) || pathOrId);
|
|
1808
1426
|
}
|
|
1809
1427
|
/**
|
|
1810
1428
|
* Retrieves the status of a symbolic link in the virtual file system (VFS).
|
|
@@ -1813,7 +1431,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1813
1431
|
* @returns A promise that resolves to the symbolic link's status information, or false if the link does not exist.
|
|
1814
1432
|
*/
|
|
1815
1433
|
async lstat(pathOrId, options) {
|
|
1816
|
-
return this.#unifiedFS.resolveFS(pathOrId).promises.lstat(this.resolve(
|
|
1434
|
+
return this.#unifiedFS.resolveFS(pathOrId).promises.lstat(await this.resolve(pathOrId) || pathOrId, options);
|
|
1817
1435
|
}
|
|
1818
1436
|
/**
|
|
1819
1437
|
* Synchronously retrieves the status of a symbolic link in the virtual file system (VFS).
|
|
@@ -1822,7 +1440,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1822
1440
|
* @returns The symbolic link's status information, or false if the link does not exist.
|
|
1823
1441
|
*/
|
|
1824
1442
|
lstatSync(pathOrId, options) {
|
|
1825
|
-
return this.#unifiedFS.resolveFS(pathOrId).lstatSync(this.
|
|
1443
|
+
return this.#unifiedFS.resolveFS(pathOrId).lstatSync(this.resolveSync(pathOrId) || pathOrId, options);
|
|
1826
1444
|
}
|
|
1827
1445
|
/**
|
|
1828
1446
|
* Resolves a path or ID to its real path in the virtual file system (VFS).
|
|
@@ -1831,52 +1449,113 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1831
1449
|
* @returns The resolved real path if it exists, otherwise undefined.
|
|
1832
1450
|
*/
|
|
1833
1451
|
realpathSync(pathOrId) {
|
|
1834
|
-
const filePath = this.
|
|
1452
|
+
const filePath = this.resolveSync(pathOrId);
|
|
1835
1453
|
if (!filePath) {
|
|
1836
|
-
throw new Error(`File not found: ${
|
|
1454
|
+
throw new Error(`File not found: ${pathOrId}`);
|
|
1837
1455
|
}
|
|
1838
1456
|
return filePath;
|
|
1839
1457
|
}
|
|
1840
1458
|
/**
|
|
1841
|
-
*
|
|
1459
|
+
* A helper function to resolve modules in the virtual file system (VFS).
|
|
1842
1460
|
*
|
|
1843
|
-
* @
|
|
1844
|
-
*
|
|
1845
|
-
*
|
|
1461
|
+
* @remarks
|
|
1462
|
+
* This function can be used to resolve modules relative to the project root directory.
|
|
1463
|
+
*
|
|
1464
|
+
* @example
|
|
1465
|
+
* ```ts
|
|
1466
|
+
* const resolved = await context.resolvePath("some-module", "/path/to/importer");
|
|
1467
|
+
* ```
|
|
1468
|
+
*
|
|
1469
|
+
* @param id - The module to resolve.
|
|
1470
|
+
* @param importer - An optional path to the importer module.
|
|
1471
|
+
* @param options - Additional resolution options.
|
|
1472
|
+
* @returns A promise that resolves to the resolved module path.
|
|
1846
1473
|
*/
|
|
1847
|
-
resolve(
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
return this.#cachedResolver.get(resolverKey);
|
|
1852
|
-
}
|
|
1853
|
-
let result = this.#resolveId(formattedPathOrId);
|
|
1854
|
-
if (!result) {
|
|
1855
|
-
result = this.#resolvePath(formattedPathOrId, options);
|
|
1474
|
+
async resolve(id, importer, options = {}) {
|
|
1475
|
+
let result = this.resolverCache.get(this.#normalizeId(id));
|
|
1476
|
+
if (result) {
|
|
1477
|
+
return result;
|
|
1856
1478
|
}
|
|
1479
|
+
result = this.paths[this.#normalizeId(id)];
|
|
1857
1480
|
if (!result) {
|
|
1858
|
-
|
|
1481
|
+
const paths = options.paths ?? [];
|
|
1482
|
+
if (importer && !paths.includes(importer)) {
|
|
1483
|
+
paths.push(importer);
|
|
1484
|
+
}
|
|
1485
|
+
paths.push(this.#context.workspaceConfig.workspaceRoot);
|
|
1486
|
+
paths.push(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.projectRoot));
|
|
1487
|
+
paths.push(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.sourceRoot));
|
|
1488
|
+
paths.push(...Object.keys(this.#context.tsconfig.options.paths ?? {}).filter((tsconfigPath) => id.startsWith(tsconfigPath.replace(/\*$/, ""))).map((tsconfigPath) => this.#context.tsconfig.options.paths?.[tsconfigPath]).flat().filter(Boolean).map((tsconfigPath) => append.appendPath(tsconfigPath, this.#context.workspaceConfig.workspaceRoot)));
|
|
1489
|
+
for (const combination of resolve.getResolutionCombinations(id, {
|
|
1490
|
+
paths
|
|
1491
|
+
})) {
|
|
1492
|
+
if (this.#existsSync(combination)) {
|
|
1493
|
+
result = combination;
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
try {
|
|
1497
|
+
result = await resolve.resolve(id, {
|
|
1498
|
+
paths
|
|
1499
|
+
});
|
|
1500
|
+
} catch {
|
|
1501
|
+
}
|
|
1859
1502
|
}
|
|
1860
|
-
if (result
|
|
1861
|
-
|
|
1503
|
+
if (result) {
|
|
1504
|
+
result = correctPath.toAbsolutePath(append.appendPath(result, this.#context.config.projectRoot), this.#context.workspaceConfig.workspaceRoot);
|
|
1505
|
+
this.resolverCache.set(this.#normalizeId(id), result);
|
|
1862
1506
|
}
|
|
1863
|
-
this.#cachedResolver.set(resolverKey, result);
|
|
1864
1507
|
return result;
|
|
1865
1508
|
}
|
|
1866
1509
|
/**
|
|
1867
|
-
*
|
|
1510
|
+
* A synchronous helper function to resolve modules using the Jiti resolver
|
|
1868
1511
|
*
|
|
1869
|
-
* @
|
|
1870
|
-
*
|
|
1512
|
+
* @remarks
|
|
1513
|
+
* This function can be used to resolve modules relative to the project root directory.
|
|
1514
|
+
*
|
|
1515
|
+
* @example
|
|
1516
|
+
* ```ts
|
|
1517
|
+
* const resolvedPath = context.resolveSync("some-module", "/path/to/importer");
|
|
1518
|
+
* ```
|
|
1519
|
+
*
|
|
1520
|
+
* @param id - The module to resolve.
|
|
1521
|
+
* @param importer - An optional path to the importer module.
|
|
1522
|
+
* @param options - Additional resolution options.
|
|
1523
|
+
* @returns The resolved module path.
|
|
1871
1524
|
*/
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
if (
|
|
1875
|
-
return
|
|
1876
|
-
} else if (formattedPath.startsWith(this.#context.config.projectRoot)) {
|
|
1877
|
-
return joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, formattedPath);
|
|
1525
|
+
resolveSync(id, importer, options = {}) {
|
|
1526
|
+
let result = this.resolverCache.get(this.#normalizeId(id));
|
|
1527
|
+
if (result) {
|
|
1528
|
+
return result;
|
|
1878
1529
|
}
|
|
1879
|
-
|
|
1530
|
+
result = this.paths[this.#normalizeId(id)];
|
|
1531
|
+
if (!result) {
|
|
1532
|
+
const paths = options.paths ?? [];
|
|
1533
|
+
if (importer && !paths.includes(importer)) {
|
|
1534
|
+
paths.push(importer);
|
|
1535
|
+
}
|
|
1536
|
+
paths.push(this.#context.workspaceConfig.workspaceRoot);
|
|
1537
|
+
paths.push(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.projectRoot));
|
|
1538
|
+
paths.push(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.sourceRoot));
|
|
1539
|
+
paths.push(...Object.keys(this.#context.tsconfig?.options?.paths ?? {}).filter((tsconfigPath) => id.startsWith(tsconfigPath.replace(/\*$/, ""))).map((tsconfigPath) => this.#context.tsconfig?.options?.paths?.[tsconfigPath]).flat().filter(Boolean).map((tsconfigPath) => append.appendPath(tsconfigPath, this.#context.workspaceConfig.workspaceRoot)));
|
|
1540
|
+
for (const combination of resolve.getResolutionCombinations(id, {
|
|
1541
|
+
paths
|
|
1542
|
+
})) {
|
|
1543
|
+
if (this.#existsSync(combination)) {
|
|
1544
|
+
result = combination;
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
try {
|
|
1548
|
+
result = resolve.resolveSync(id, {
|
|
1549
|
+
paths
|
|
1550
|
+
});
|
|
1551
|
+
} catch {
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
if (result) {
|
|
1555
|
+
result = correctPath.toAbsolutePath(append.appendPath(result, this.#context.config.projectRoot), this.#context.workspaceConfig.workspaceRoot);
|
|
1556
|
+
this.resolverCache.set(this.#normalizeId(id), result);
|
|
1557
|
+
}
|
|
1558
|
+
return result;
|
|
1880
1559
|
}
|
|
1881
1560
|
/**
|
|
1882
1561
|
* Disposes of the virtual file system (VFS) by saving its state to disk.
|
|
@@ -1885,7 +1564,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1885
1564
|
if (!this.#isDisposed) {
|
|
1886
1565
|
this.#isDisposed = true;
|
|
1887
1566
|
this.#log(types.LogLevelLabel.DEBUG, "Disposing virtual file system...");
|
|
1888
|
-
await this.unlink(joinPaths.joinPaths(this.#context.
|
|
1567
|
+
await this.unlink(joinPaths.joinPaths(this.#context.dataPath, "fs.bin"));
|
|
1889
1568
|
const message = new $__namespace.Message();
|
|
1890
1569
|
const fs2 = message.initRoot(FileSystem);
|
|
1891
1570
|
const virtualFS = this.#unifiedFS.toJSON();
|
|
@@ -1894,7 +1573,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1894
1573
|
virtualFiles.forEach(([path, code], index) => {
|
|
1895
1574
|
const fd = files.get(index);
|
|
1896
1575
|
fd.path = path;
|
|
1897
|
-
fd.code = code;
|
|
1576
|
+
fd.code = code || "";
|
|
1898
1577
|
});
|
|
1899
1578
|
const ids = fs2._initIds(Object.keys(this.ids).length);
|
|
1900
1579
|
Object.entries(this.ids).forEach(([id, path], index) => {
|
|
@@ -1918,7 +1597,9 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1918
1597
|
});
|
|
1919
1598
|
}
|
|
1920
1599
|
});
|
|
1921
|
-
await buffer.writeFileBuffer(joinPaths.joinPaths(this.#context.
|
|
1600
|
+
await buffer.writeFileBuffer(joinPaths.joinPaths(this.#context.dataPath, "fs.bin"), message.toArrayBuffer());
|
|
1601
|
+
this.#resolverCache.save(true);
|
|
1602
|
+
this.#log(types.LogLevelLabel.DEBUG, "Virtual file system disposed.");
|
|
1922
1603
|
}
|
|
1923
1604
|
}
|
|
1924
1605
|
/**
|
|
@@ -1967,6 +1648,8 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
1967
1648
|
#envPaths;
|
|
1968
1649
|
#fs;
|
|
1969
1650
|
#tsconfig;
|
|
1651
|
+
#program;
|
|
1652
|
+
#resolvePatterns = [];
|
|
1970
1653
|
#getConfigProps(config = {}) {
|
|
1971
1654
|
return {
|
|
1972
1655
|
variant: config.build?.variant,
|
|
@@ -2058,7 +1741,7 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
2058
1741
|
*/
|
|
2059
1742
|
get tsconfig() {
|
|
2060
1743
|
if (!this.#tsconfig) {
|
|
2061
|
-
this
|
|
1744
|
+
this.tsconfig = {
|
|
2062
1745
|
tsconfigFilePath: this.config.tsconfig
|
|
2063
1746
|
};
|
|
2064
1747
|
}
|
|
@@ -2069,6 +1752,7 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
2069
1752
|
*/
|
|
2070
1753
|
set tsconfig(value) {
|
|
2071
1754
|
this.#tsconfig = value;
|
|
1755
|
+
this.#resolvePatterns = bundleRequire.tsconfigPathsToRegExp(value?.options?.paths ?? {});
|
|
2072
1756
|
}
|
|
2073
1757
|
/**
|
|
2074
1758
|
* The virtual file system interface for the project
|
|
@@ -2193,6 +1877,106 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
2193
1877
|
return Object.values(this.fs.metadata).filter((meta) => meta && meta.type === "builtin").map((meta) => meta?.id).filter(Boolean);
|
|
2194
1878
|
}
|
|
2195
1879
|
/**
|
|
1880
|
+
* The {@link Project} instance used for type reflection and module manipulation
|
|
1881
|
+
*
|
|
1882
|
+
* @see https://ts-morph.com/
|
|
1883
|
+
*
|
|
1884
|
+
* @remarks
|
|
1885
|
+
* This instance is created lazily on first access.
|
|
1886
|
+
*/
|
|
1887
|
+
get program() {
|
|
1888
|
+
if (!this.#program) {
|
|
1889
|
+
this.#program = chunkSAS5EPBD_cjs.createProgram(this, {
|
|
1890
|
+
skipAddingFilesFromTsConfig: true
|
|
1891
|
+
});
|
|
1892
|
+
}
|
|
1893
|
+
return this.#program;
|
|
1894
|
+
}
|
|
1895
|
+
/**
|
|
1896
|
+
* A helper function to resolve modules in the Virtual File System
|
|
1897
|
+
*
|
|
1898
|
+
* @remarks
|
|
1899
|
+
* This function can be used to resolve modules relative to the project root directory.
|
|
1900
|
+
*
|
|
1901
|
+
* @example
|
|
1902
|
+
* ```ts
|
|
1903
|
+
* const resolved = await context.resolve("some-module", "/path/to/importer");
|
|
1904
|
+
* ```
|
|
1905
|
+
*
|
|
1906
|
+
* @param id - The module to resolve.
|
|
1907
|
+
* @param importer - An optional path to the importer module.
|
|
1908
|
+
* @param options - Additional resolution options.
|
|
1909
|
+
* @returns A promise that resolves to the resolved module path.
|
|
1910
|
+
*/
|
|
1911
|
+
async resolveId(id, importer, options = {}) {
|
|
1912
|
+
if (this.fs.isVirtual(id)) {
|
|
1913
|
+
const result = await this.fs.resolve(id, importer, options);
|
|
1914
|
+
if (!result) {
|
|
1915
|
+
return void 0;
|
|
1916
|
+
}
|
|
1917
|
+
return {
|
|
1918
|
+
id: `\0${result}`,
|
|
1919
|
+
external: this.config.projectType !== "application"
|
|
1920
|
+
};
|
|
1921
|
+
}
|
|
1922
|
+
if (this.config.build.skipNodeModulesBundle) {
|
|
1923
|
+
if (bundleRequire.match(id, this.#resolvePatterns) || bundleRequire.match(id, this.config.build.noExternal)) {
|
|
1924
|
+
return void 0;
|
|
1925
|
+
}
|
|
1926
|
+
if (bundleRequire.match(id, this.config.build.external) || id.startsWith("node:")) {
|
|
1927
|
+
return {
|
|
1928
|
+
id,
|
|
1929
|
+
external: true
|
|
1930
|
+
};
|
|
1931
|
+
}
|
|
1932
|
+
if (!/^[A-Z]:[/\\]|^\.{0,2}\/|^\.{1,2}$/.test(id)) {
|
|
1933
|
+
return {
|
|
1934
|
+
id,
|
|
1935
|
+
external: true
|
|
1936
|
+
};
|
|
1937
|
+
}
|
|
1938
|
+
} else {
|
|
1939
|
+
if (bundleRequire.match(id, this.config.build.noExternal)) {
|
|
1940
|
+
return void 0;
|
|
1941
|
+
}
|
|
1942
|
+
if (bundleRequire.match(id, this.config.build.external) || id.startsWith("node:")) {
|
|
1943
|
+
return {
|
|
1944
|
+
id,
|
|
1945
|
+
external: true
|
|
1946
|
+
};
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
return void 0;
|
|
1950
|
+
}
|
|
1951
|
+
/**
|
|
1952
|
+
* A helper function to load modules from the Virtual File System
|
|
1953
|
+
*
|
|
1954
|
+
* @remarks
|
|
1955
|
+
* This function can be used to load modules relative to the project root directory.
|
|
1956
|
+
*
|
|
1957
|
+
* @example
|
|
1958
|
+
* ```ts
|
|
1959
|
+
* const module = await context.load("some-module", "/path/to/importer");
|
|
1960
|
+
* ```
|
|
1961
|
+
*
|
|
1962
|
+
* @param id - The module to load.
|
|
1963
|
+
* @returns A promise that resolves to the loaded module.
|
|
1964
|
+
*/
|
|
1965
|
+
async load(id) {
|
|
1966
|
+
const resolvedId = await this.fs.resolve(id);
|
|
1967
|
+
if (!resolvedId) {
|
|
1968
|
+
return void 0;
|
|
1969
|
+
}
|
|
1970
|
+
const code = await this.fs.readFile(resolvedId);
|
|
1971
|
+
if (!code) {
|
|
1972
|
+
return void 0;
|
|
1973
|
+
}
|
|
1974
|
+
return {
|
|
1975
|
+
code,
|
|
1976
|
+
map: null
|
|
1977
|
+
};
|
|
1978
|
+
}
|
|
1979
|
+
/**
|
|
2196
1980
|
* Get the builtin virtual files that exist in the Powerlines virtual file system
|
|
2197
1981
|
*/
|
|
2198
1982
|
async getBuiltins() {
|
|
@@ -2529,6 +2313,24 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
2529
2313
|
ret.push(plugin);
|
|
2530
2314
|
return ret;
|
|
2531
2315
|
}, []);
|
|
2316
|
+
if (this.config.tsconfig) {
|
|
2317
|
+
this.config.tsconfig = chunkISBHXSDH_cjs.replacePathTokens(this, this.config.tsconfig);
|
|
2318
|
+
}
|
|
2319
|
+
if (this.config.output.dts) {
|
|
2320
|
+
this.config.output.dts = chunkISBHXSDH_cjs.replacePathTokens(this, this.config.output.dts);
|
|
2321
|
+
}
|
|
2322
|
+
if (this.config.build.polyfill) {
|
|
2323
|
+
this.config.build.polyfill = this.config.build.polyfill.map((polyfill) => chunkISBHXSDH_cjs.replacePathTokens(this, polyfill));
|
|
2324
|
+
}
|
|
2325
|
+
if (this.config.output.assets) {
|
|
2326
|
+
this.config.output.assets = this.config.output.assets.map((asset) => ({
|
|
2327
|
+
...asset,
|
|
2328
|
+
glob: chunkISBHXSDH_cjs.replacePathTokens(this, asset.glob),
|
|
2329
|
+
ignore: asset.ignore ? asset.ignore.map((ignore) => chunkISBHXSDH_cjs.replacePathTokens(this, ignore)) : void 0,
|
|
2330
|
+
input: chunkISBHXSDH_cjs.replacePathTokens(this, asset.input),
|
|
2331
|
+
output: chunkISBHXSDH_cjs.replacePathTokens(this, asset.output)
|
|
2332
|
+
}));
|
|
2333
|
+
}
|
|
2532
2334
|
this.#fs ??= await VirtualFileSystem.create(this);
|
|
2533
2335
|
}
|
|
2534
2336
|
mergeUserConfig(from = {}, into = this.config.userConfig ?? {}) {
|
|
@@ -2554,7 +2356,6 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
2554
2356
|
|
|
2555
2357
|
exports.PowerlinesContext = PowerlinesContext;
|
|
2556
2358
|
exports.VirtualFileSystem = VirtualFileSystem;
|
|
2557
|
-
exports.__VFS_PATCH__ = __VFS_PATCH__;
|
|
2558
2359
|
exports.__VFS_REVERT__ = __VFS_REVERT__;
|
|
2559
2360
|
exports.addPluginHook = addPluginHook;
|
|
2560
2361
|
exports.checkDedupe = checkDedupe;
|