powerlines 0.23.9 → 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/babel-types.d.ts +292 -0
- package/dist/chunk-2TWFBWKA.cjs +133 -0
- package/dist/{chunk-UYJXRMS3.js → chunk-7V3LWCLB.js} +1 -1
- package/dist/chunk-EXQM3KGH.js +130 -0
- package/dist/{chunk-6ZKM7WOB.cjs → chunk-FGH3MZTQ.cjs} +535 -659
- package/dist/{chunk-ITL6JGKX.cjs → chunk-FPB2O7FD.cjs} +2 -2
- package/dist/{chunk-KOBCKTHY.js → chunk-H74SWU2C.js} +1 -1
- package/dist/{chunk-2QLM4MYP.cjs → chunk-HTGCHSLH.cjs} +2 -2
- package/dist/{chunk-G5K3I7JU.cjs → chunk-TIBYAWZZ.cjs} +2 -2
- package/dist/{chunk-S47BU5QR.js → chunk-ZEE73BCY.js} +1 -1
- package/dist/{chunk-FDEGM4CR.js → chunk-ZT2J55YE.js} +538 -659
- 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-OI7EHXNE.js → chunk-7CVPZOH4.js} +3 -3
- package/dist/lib/{chunk-7XHBIYIN.cjs → chunk-7VJ42H2I.cjs} +0 -16
- package/dist/lib/{chunk-SEWUUTNA.js → chunk-A2NFSQ5K.js} +1 -1
- package/dist/lib/{chunk-B3DJ4CXY.cjs → chunk-AA6RBP44.cjs} +10 -10
- package/dist/lib/{chunk-BGGENJH4.js → chunk-CGRHZJY5.js} +42 -83
- package/dist/lib/{chunk-AHONHQGB.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-YH5GOJS3.js → chunk-FQLZZYYO.js} +1 -16
- package/dist/lib/{chunk-54XNJQTH.js → chunk-HAXL7QE7.js} +3 -3
- package/dist/lib/chunk-K3NBD5LL.cjs +75 -0
- package/dist/lib/{chunk-63MH3ERQ.js → chunk-KFWMKDJQ.js} +395 -591
- package/dist/lib/{chunk-3KR6TYGW.cjs → chunk-MS3CD2U6.cjs} +52 -94
- package/dist/lib/{chunk-LQEGZT5U.cjs → chunk-RNHKEPFD.cjs} +397 -594
- 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-SMZ672RP.cjs → chunk-VMLQATMA.cjs} +6 -6
- package/dist/lib/{chunk-IBPA3VN5.cjs → chunk-WUYK74EH.cjs} +3 -3
- package/dist/lib/chunk-XBM7FHNK.js +68 -0
- 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.cjs +3 -3
- package/dist/lib/config-file.d.cts +3 -1
- package/dist/lib/config-file.d.ts +3 -1
- package/dist/lib/config-file.js +1 -1
- package/dist/lib/contexts/api-context.cjs +7 -6
- 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 +6 -5
- package/dist/lib/contexts/context.cjs +5 -4
- package/dist/lib/contexts/context.d.cts +47 -4
- package/dist/lib/contexts/context.d.ts +47 -4
- package/dist/lib/contexts/context.js +4 -3
- package/dist/lib/contexts/environment-context.cjs +6 -5
- 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 +5 -4
- package/dist/lib/contexts/index.cjs +9 -8
- package/dist/lib/contexts/index.d.cts +5 -3
- package/dist/lib/contexts/index.d.ts +5 -3
- package/dist/lib/contexts/index.js +6 -5
- 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 +49 -59
- package/dist/lib/index.d.cts +68 -49
- package/dist/lib/index.d.ts +68 -49
- package/dist/lib/index.js +14 -16
- 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 +8 -8
- package/dist/lib/unplugin/factory.d.cts +5 -3
- package/dist/lib/unplugin/factory.d.ts +5 -3
- package/dist/lib/unplugin/factory.js +7 -7
- package/dist/lib/unplugin/helpers.d.cts +3 -1
- package/dist/lib/unplugin/helpers.d.ts +3 -1
- package/dist/lib/unplugin/index.cjs +13 -13
- package/dist/lib/unplugin/index.d.cts +6 -4
- package/dist/lib/unplugin/index.d.ts +6 -4
- package/dist/lib/unplugin/index.js +9 -9
- 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 +21 -30
- package/dist/lib/utilities/index.d.cts +4 -3
- package/dist/lib/utilities/index.d.ts +4 -3
- package/dist/lib/utilities/index.js +5 -6
- package/dist/lib/utilities/meta.cjs +7 -11
- package/dist/lib/utilities/meta.d.cts +4 -3
- package/dist/lib/utilities/meta.d.ts +4 -3
- package/dist/lib/utilities/meta.js +1 -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.ts → context-BITGF5LZ.d.cts} +118 -39
- package/dist/plugin-utils/{context-Cg11S-CE.d.cts → 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 -14
- package/schemas/fs.capnp +35 -38
- package/dist/chunk-FJWXCUGQ.cjs +0 -234
- package/dist/chunk-RKMUBSYG.js +0 -230
- package/dist/lib/chunk-7JAGT5GC.cjs +0 -74
- 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-PVCAB6BZ.js +0 -67
- 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,7 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunk7VJ42H2I_cjs = require('./chunk-7VJ42H2I.cjs');
|
|
4
|
+
var chunkSAS5EPBD_cjs = require('./chunk-SAS5EPBD.cjs');
|
|
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');
|
|
7
8
|
var chunkUSNT2KNT_cjs = require('./chunk-USNT2KNT.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');
|
|
@@ -71,6 +75,7 @@ var _fs__default = /*#__PURE__*/_interopDefault(_fs);
|
|
|
71
75
|
|
|
72
76
|
function resolveOptions(options) {
|
|
73
77
|
return defu2__default.default(options, {
|
|
78
|
+
debug: options.logLevel === "trace",
|
|
74
79
|
interopDefault: true,
|
|
75
80
|
fsCache: options.mode !== "development" ? joinPaths.joinPaths(options.cacheDir, "jiti") : false,
|
|
76
81
|
moduleCache: options.mode !== "development"
|
|
@@ -257,187 +262,6 @@ var FileMetadata = class _FileMetadata extends $__namespace.Struct {
|
|
|
257
262
|
return "FileMetadata_" + super.toString();
|
|
258
263
|
}
|
|
259
264
|
};
|
|
260
|
-
var ChunkData = class extends $__namespace.Struct {
|
|
261
|
-
static {
|
|
262
|
-
chunkUSNT2KNT_cjs.__name(this, "ChunkData");
|
|
263
|
-
}
|
|
264
|
-
static _capnp = {
|
|
265
|
-
displayName: "ChunkData",
|
|
266
|
-
id: "84076f13b057f83a",
|
|
267
|
-
size: new $__namespace.ObjectSize(8, 4)
|
|
268
|
-
};
|
|
269
|
-
/**
|
|
270
|
-
* An additional name for the file.
|
|
271
|
-
*
|
|
272
|
-
*/
|
|
273
|
-
get id() {
|
|
274
|
-
return $__namespace.utils.getText(0, this);
|
|
275
|
-
}
|
|
276
|
-
set id(value) {
|
|
277
|
-
$__namespace.utils.setText(0, value, this);
|
|
278
|
-
}
|
|
279
|
-
/**
|
|
280
|
-
* Files that are implicitly loaded after one of the specified files.
|
|
281
|
-
*
|
|
282
|
-
*/
|
|
283
|
-
get name() {
|
|
284
|
-
return $__namespace.utils.getText(1, this);
|
|
285
|
-
}
|
|
286
|
-
set name(value) {
|
|
287
|
-
$__namespace.utils.setText(1, value, this);
|
|
288
|
-
}
|
|
289
|
-
_adoptImplicitlyLoadedAfterOneOf(value) {
|
|
290
|
-
$__namespace.utils.adopt(value, $__namespace.utils.getPointer(2, this));
|
|
291
|
-
}
|
|
292
|
-
_disownImplicitlyLoadedAfterOneOf() {
|
|
293
|
-
return $__namespace.utils.disown(this.implicitlyLoadedAfterOneOf);
|
|
294
|
-
}
|
|
295
|
-
/**
|
|
296
|
-
* The importer of the file.
|
|
297
|
-
*
|
|
298
|
-
*/
|
|
299
|
-
get implicitlyLoadedAfterOneOf() {
|
|
300
|
-
return $__namespace.utils.getList(2, $__namespace.TextList, this);
|
|
301
|
-
}
|
|
302
|
-
_hasImplicitlyLoadedAfterOneOf() {
|
|
303
|
-
return !$__namespace.utils.isNull($__namespace.utils.getPointer(2, this));
|
|
304
|
-
}
|
|
305
|
-
_initImplicitlyLoadedAfterOneOf(length) {
|
|
306
|
-
return $__namespace.utils.initList(2, $__namespace.TextList, length, this);
|
|
307
|
-
}
|
|
308
|
-
set implicitlyLoadedAfterOneOf(value) {
|
|
309
|
-
$__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(2, this));
|
|
310
|
-
}
|
|
311
|
-
/**
|
|
312
|
-
* The signature preservation mode for the file.
|
|
313
|
-
*
|
|
314
|
-
*/
|
|
315
|
-
get importer() {
|
|
316
|
-
return $__namespace.utils.getText(3, this);
|
|
317
|
-
}
|
|
318
|
-
set importer(value) {
|
|
319
|
-
$__namespace.utils.setText(3, value, this);
|
|
320
|
-
}
|
|
321
|
-
get preserveSignature() {
|
|
322
|
-
return $__namespace.utils.getUint16(0, this);
|
|
323
|
-
}
|
|
324
|
-
set preserveSignature(value) {
|
|
325
|
-
$__namespace.utils.setUint16(0, value, this);
|
|
326
|
-
}
|
|
327
|
-
toString() {
|
|
328
|
-
return "ChunkData_" + super.toString();
|
|
329
|
-
}
|
|
330
|
-
};
|
|
331
|
-
var PrebuiltData = class extends $__namespace.Struct {
|
|
332
|
-
static {
|
|
333
|
-
chunkUSNT2KNT_cjs.__name(this, "PrebuiltData");
|
|
334
|
-
}
|
|
335
|
-
static _capnp = {
|
|
336
|
-
displayName: "PrebuiltData",
|
|
337
|
-
id: "c5b1a6ca696328ee",
|
|
338
|
-
size: new $__namespace.ObjectSize(0, 4)
|
|
339
|
-
};
|
|
340
|
-
/**
|
|
341
|
-
* An additional name for the file.
|
|
342
|
-
*
|
|
343
|
-
*/
|
|
344
|
-
get id() {
|
|
345
|
-
return $__namespace.utils.getText(0, this);
|
|
346
|
-
}
|
|
347
|
-
set id(value) {
|
|
348
|
-
$__namespace.utils.setText(0, value, this);
|
|
349
|
-
}
|
|
350
|
-
/**
|
|
351
|
-
* The file exports.
|
|
352
|
-
*
|
|
353
|
-
*/
|
|
354
|
-
get name() {
|
|
355
|
-
return $__namespace.utils.getText(1, this);
|
|
356
|
-
}
|
|
357
|
-
set name(value) {
|
|
358
|
-
$__namespace.utils.setText(1, value, this);
|
|
359
|
-
}
|
|
360
|
-
_adoptExports(value) {
|
|
361
|
-
$__namespace.utils.adopt(value, $__namespace.utils.getPointer(2, this));
|
|
362
|
-
}
|
|
363
|
-
_disownExports() {
|
|
364
|
-
return $__namespace.utils.disown(this.exports);
|
|
365
|
-
}
|
|
366
|
-
/**
|
|
367
|
-
* The source map for the file.
|
|
368
|
-
*
|
|
369
|
-
*/
|
|
370
|
-
get exports() {
|
|
371
|
-
return $__namespace.utils.getList(2, $__namespace.TextList, this);
|
|
372
|
-
}
|
|
373
|
-
_hasExports() {
|
|
374
|
-
return !$__namespace.utils.isNull($__namespace.utils.getPointer(2, this));
|
|
375
|
-
}
|
|
376
|
-
_initExports(length) {
|
|
377
|
-
return $__namespace.utils.initList(2, $__namespace.TextList, length, this);
|
|
378
|
-
}
|
|
379
|
-
set exports(value) {
|
|
380
|
-
$__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(2, this));
|
|
381
|
-
}
|
|
382
|
-
get map() {
|
|
383
|
-
return $__namespace.utils.getText(3, this);
|
|
384
|
-
}
|
|
385
|
-
set map(value) {
|
|
386
|
-
$__namespace.utils.setText(3, value, this);
|
|
387
|
-
}
|
|
388
|
-
toString() {
|
|
389
|
-
return "PrebuiltData_" + super.toString();
|
|
390
|
-
}
|
|
391
|
-
};
|
|
392
|
-
var AssetData = class extends $__namespace.Struct {
|
|
393
|
-
static {
|
|
394
|
-
chunkUSNT2KNT_cjs.__name(this, "AssetData");
|
|
395
|
-
}
|
|
396
|
-
static _capnp = {
|
|
397
|
-
displayName: "AssetData",
|
|
398
|
-
id: "da660c6c1fa4c830",
|
|
399
|
-
size: new $__namespace.ObjectSize(8, 3)
|
|
400
|
-
};
|
|
401
|
-
/**
|
|
402
|
-
* An additional name for the file.
|
|
403
|
-
*
|
|
404
|
-
*/
|
|
405
|
-
get id() {
|
|
406
|
-
return $__namespace.utils.getText(0, this);
|
|
407
|
-
}
|
|
408
|
-
set id(value) {
|
|
409
|
-
$__namespace.utils.setText(0, value, this);
|
|
410
|
-
}
|
|
411
|
-
/**
|
|
412
|
-
* Indicates whether the file needs a code reference.
|
|
413
|
-
*
|
|
414
|
-
*/
|
|
415
|
-
get name() {
|
|
416
|
-
return $__namespace.utils.getText(1, this);
|
|
417
|
-
}
|
|
418
|
-
set name(value) {
|
|
419
|
-
$__namespace.utils.setText(1, value, this);
|
|
420
|
-
}
|
|
421
|
-
/**
|
|
422
|
-
* The original file name before any transformations.
|
|
423
|
-
*
|
|
424
|
-
*/
|
|
425
|
-
get needsCodeReference() {
|
|
426
|
-
return $__namespace.utils.getBit(0, this);
|
|
427
|
-
}
|
|
428
|
-
set needsCodeReference(value) {
|
|
429
|
-
$__namespace.utils.setBit(0, value, this);
|
|
430
|
-
}
|
|
431
|
-
get originalFileName() {
|
|
432
|
-
return $__namespace.utils.getText(2, this);
|
|
433
|
-
}
|
|
434
|
-
set originalFileName(value) {
|
|
435
|
-
$__namespace.utils.setText(2, value, this);
|
|
436
|
-
}
|
|
437
|
-
toString() {
|
|
438
|
-
return "AssetData_" + super.toString();
|
|
439
|
-
}
|
|
440
|
-
};
|
|
441
265
|
var FileId = class extends $__namespace.Struct {
|
|
442
266
|
static {
|
|
443
267
|
chunkUSNT2KNT_cjs.__name(this, "FileId");
|
|
@@ -503,14 +327,11 @@ var FileSystem = class _FileSystem extends $__namespace.Struct {
|
|
|
503
327
|
static _capnp = {
|
|
504
328
|
displayName: "FileSystem",
|
|
505
329
|
id: "ae0c23d43e56abcf",
|
|
506
|
-
size: new $__namespace.ObjectSize(0,
|
|
330
|
+
size: new $__namespace.ObjectSize(0, 3)
|
|
507
331
|
};
|
|
508
332
|
static _Ids;
|
|
509
333
|
static _Files;
|
|
510
334
|
static _Metadata;
|
|
511
|
-
static _Assets;
|
|
512
|
-
static _Chunks;
|
|
513
|
-
static _Prebuilt;
|
|
514
335
|
_adoptIds(value) {
|
|
515
336
|
$__namespace.utils.adopt(value, $__namespace.utils.getPointer(0, this));
|
|
516
337
|
}
|
|
@@ -565,60 +386,6 @@ var FileSystem = class _FileSystem extends $__namespace.Struct {
|
|
|
565
386
|
set metadata(value) {
|
|
566
387
|
$__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(2, this));
|
|
567
388
|
}
|
|
568
|
-
_adoptAssets(value) {
|
|
569
|
-
$__namespace.utils.adopt(value, $__namespace.utils.getPointer(3, this));
|
|
570
|
-
}
|
|
571
|
-
_disownAssets() {
|
|
572
|
-
return $__namespace.utils.disown(this.assets);
|
|
573
|
-
}
|
|
574
|
-
get assets() {
|
|
575
|
-
return $__namespace.utils.getList(3, _FileSystem._Assets, this);
|
|
576
|
-
}
|
|
577
|
-
_hasAssets() {
|
|
578
|
-
return !$__namespace.utils.isNull($__namespace.utils.getPointer(3, this));
|
|
579
|
-
}
|
|
580
|
-
_initAssets(length) {
|
|
581
|
-
return $__namespace.utils.initList(3, _FileSystem._Assets, length, this);
|
|
582
|
-
}
|
|
583
|
-
set assets(value) {
|
|
584
|
-
$__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(3, this));
|
|
585
|
-
}
|
|
586
|
-
_adoptChunks(value) {
|
|
587
|
-
$__namespace.utils.adopt(value, $__namespace.utils.getPointer(4, this));
|
|
588
|
-
}
|
|
589
|
-
_disownChunks() {
|
|
590
|
-
return $__namespace.utils.disown(this.chunks);
|
|
591
|
-
}
|
|
592
|
-
get chunks() {
|
|
593
|
-
return $__namespace.utils.getList(4, _FileSystem._Chunks, this);
|
|
594
|
-
}
|
|
595
|
-
_hasChunks() {
|
|
596
|
-
return !$__namespace.utils.isNull($__namespace.utils.getPointer(4, this));
|
|
597
|
-
}
|
|
598
|
-
_initChunks(length) {
|
|
599
|
-
return $__namespace.utils.initList(4, _FileSystem._Chunks, length, this);
|
|
600
|
-
}
|
|
601
|
-
set chunks(value) {
|
|
602
|
-
$__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(4, this));
|
|
603
|
-
}
|
|
604
|
-
_adoptPrebuilt(value) {
|
|
605
|
-
$__namespace.utils.adopt(value, $__namespace.utils.getPointer(5, this));
|
|
606
|
-
}
|
|
607
|
-
_disownPrebuilt() {
|
|
608
|
-
return $__namespace.utils.disown(this.prebuilt);
|
|
609
|
-
}
|
|
610
|
-
get prebuilt() {
|
|
611
|
-
return $__namespace.utils.getList(5, _FileSystem._Prebuilt, this);
|
|
612
|
-
}
|
|
613
|
-
_hasPrebuilt() {
|
|
614
|
-
return !$__namespace.utils.isNull($__namespace.utils.getPointer(5, this));
|
|
615
|
-
}
|
|
616
|
-
_initPrebuilt(length) {
|
|
617
|
-
return $__namespace.utils.initList(5, _FileSystem._Prebuilt, length, this);
|
|
618
|
-
}
|
|
619
|
-
set prebuilt(value) {
|
|
620
|
-
$__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(5, this));
|
|
621
|
-
}
|
|
622
389
|
toString() {
|
|
623
390
|
return "FileSystem_" + super.toString();
|
|
624
391
|
}
|
|
@@ -627,9 +394,6 @@ FileMetadata._Properties = $__namespace.CompositeList(FileMetadata_KeyValuePair)
|
|
|
627
394
|
FileSystem._Ids = $__namespace.CompositeList(FileId);
|
|
628
395
|
FileSystem._Files = $__namespace.CompositeList(FileData);
|
|
629
396
|
FileSystem._Metadata = $__namespace.CompositeList(FileMetadata);
|
|
630
|
-
FileSystem._Assets = $__namespace.CompositeList(AssetData);
|
|
631
|
-
FileSystem._Chunks = $__namespace.CompositeList(ChunkData);
|
|
632
|
-
FileSystem._Prebuilt = $__namespace.CompositeList(PrebuiltData);
|
|
633
397
|
|
|
634
398
|
// src/types/fs.ts
|
|
635
399
|
var __VFS_PATCH__ = "__VFS_PATCH__";
|
|
@@ -639,13 +403,9 @@ function isBufferEncoding(options) {
|
|
|
639
403
|
}
|
|
640
404
|
chunkUSNT2KNT_cjs.__name(isBufferEncoding, "isBufferEncoding");
|
|
641
405
|
function isPowerlinesWriteFileOptions(options) {
|
|
642
|
-
return !isBufferEncoding(options) && isSetObject.isSetObject(options) &&
|
|
406
|
+
return !isBufferEncoding(options) && isSetObject.isSetObject(options) && "mode" in options && (options.mode === "fs" || options.mode === "virtual");
|
|
643
407
|
}
|
|
644
408
|
chunkUSNT2KNT_cjs.__name(isPowerlinesWriteFileOptions, "isPowerlinesWriteFileOptions");
|
|
645
|
-
function isNodeWriteFileOptions(options) {
|
|
646
|
-
return !isUndefined.isUndefined(options) && (isBufferEncoding(options) || !isPowerlinesWriteFileOptions(options));
|
|
647
|
-
}
|
|
648
|
-
chunkUSNT2KNT_cjs.__name(isNodeWriteFileOptions, "isNodeWriteFileOptions");
|
|
649
409
|
function isVirtualFileData(obj) {
|
|
650
410
|
return !!(isSetObject.isSetObject(obj) && "code" in obj && obj.code);
|
|
651
411
|
}
|
|
@@ -782,6 +542,18 @@ function patchFS(originalFS, vfs) {
|
|
|
782
542
|
};
|
|
783
543
|
}
|
|
784
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");
|
|
785
557
|
var UnifiedFS = class _UnifiedFS extends unionfs.Union {
|
|
786
558
|
static {
|
|
787
559
|
chunkUSNT2KNT_cjs.__name(this, "UnifiedFS");
|
|
@@ -958,9 +730,9 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
958
730
|
*/
|
|
959
731
|
#paths;
|
|
960
732
|
/**
|
|
961
|
-
* A
|
|
733
|
+
* A cache for module resolution results.
|
|
962
734
|
*/
|
|
963
|
-
#
|
|
735
|
+
#resolverCache;
|
|
964
736
|
/**
|
|
965
737
|
* The unified volume that combines the virtual file system with the real file system.
|
|
966
738
|
*
|
|
@@ -995,189 +767,35 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
995
767
|
* @returns `true` if the path exists, otherwise `false`.
|
|
996
768
|
*/
|
|
997
769
|
#existsSync(path) {
|
|
998
|
-
|
|
999
|
-
return this.#unifiedFS.virtual.existsSync(formattedPath) || this.#unifiedFS.physical.existsSync(formattedPath) || this.#unifiedFS.resolveFS(path).existsSync(formattedPath);
|
|
1000
|
-
}
|
|
1001
|
-
/**
|
|
1002
|
-
* Builds a regular expression from a string pattern for path matching.
|
|
1003
|
-
*
|
|
1004
|
-
* @param strPattern - The string pattern to convert.
|
|
1005
|
-
* @returns A regular expression for matching paths.
|
|
1006
|
-
*/
|
|
1007
|
-
#buildRegex(strPattern) {
|
|
1008
|
-
const token = "::GLOBSTAR::";
|
|
1009
|
-
return new RegExp(`^${this.formatPath(strPattern).replace(/\*\*/g, token).replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]").replace(new RegExp(token, "g"), ".*")}$`);
|
|
1010
|
-
}
|
|
1011
|
-
/**
|
|
1012
|
-
* Formats a file id by removing the file extension and prepending the runtime prefix.
|
|
1013
|
-
*
|
|
1014
|
-
* @param id - The file ID to format.
|
|
1015
|
-
* @returns The formatted file ID.
|
|
1016
|
-
*/
|
|
1017
|
-
#formatId(id) {
|
|
1018
|
-
const formattedId = toFilePath(id);
|
|
1019
|
-
return `${this.#context.config.output.builtinPrefix}:${formattedId.replace(new RegExp(`^${this.#context.config.output.builtinPrefix}:`), "").replace(/^\\0/, "").replace(filePathFns.findFileDotExtensionSafe(formattedId), "")}`;
|
|
1020
|
-
}
|
|
1021
|
-
/**
|
|
1022
|
-
* Resolves an id parameter to a corresponding virtual file path in the virtual file system (VFS).
|
|
1023
|
-
*
|
|
1024
|
-
* @param id - The id to resolve.
|
|
1025
|
-
* @returns The resolved file id if it exists, otherwise undefined.
|
|
1026
|
-
*/
|
|
1027
|
-
#resolveId(id) {
|
|
1028
|
-
if (this.#ids[this.#formatId(id)]) {
|
|
1029
|
-
return this.#ids[this.#formatId(id)] || false;
|
|
1030
|
-
}
|
|
1031
|
-
return false;
|
|
1032
|
-
}
|
|
1033
|
-
/**
|
|
1034
|
-
* Resolves a path parameter to a corresponding virtual file path in the virtual file system (VFS).
|
|
1035
|
-
*
|
|
1036
|
-
* @param path - The path to resolve.
|
|
1037
|
-
* @param options - Optional parameters for resolving the path.
|
|
1038
|
-
* @returns The resolved file path if it exists, otherwise undefined.
|
|
1039
|
-
*/
|
|
1040
|
-
#resolvePath(path, options = {}) {
|
|
1041
|
-
if (isType.isAbsolutePath(path)) {
|
|
1042
|
-
if (this.#existsSync(path)) {
|
|
1043
|
-
return path;
|
|
1044
|
-
}
|
|
1045
|
-
const result = this.#checkVariants(path);
|
|
1046
|
-
if (result) {
|
|
1047
|
-
return result;
|
|
1048
|
-
}
|
|
1049
|
-
}
|
|
1050
|
-
for (const parentPath of this.#resolveParentPaths(path, options.paths)) {
|
|
1051
|
-
const request = joinPaths.joinPaths(parentPath, path);
|
|
1052
|
-
if (this.#existsSync(request)) {
|
|
1053
|
-
return request;
|
|
1054
|
-
}
|
|
1055
|
-
const result = this.#checkVariants(request);
|
|
1056
|
-
if (result) {
|
|
1057
|
-
return result;
|
|
1058
|
-
}
|
|
1059
|
-
}
|
|
1060
|
-
return false;
|
|
1061
|
-
}
|
|
1062
|
-
/**
|
|
1063
|
-
* Resolves parent paths for a given request.
|
|
1064
|
-
*
|
|
1065
|
-
* @param request - The request path to resolve parent paths for.
|
|
1066
|
-
* @param parents - An optional array of parent paths to consider.
|
|
1067
|
-
* @returns An array of resolved parent paths.
|
|
1068
|
-
*/
|
|
1069
|
-
#resolveParentPaths(request, parents = []) {
|
|
1070
|
-
let paths = [
|
|
1071
|
-
this.#context.workspaceConfig.workspaceRoot,
|
|
1072
|
-
joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.projectRoot)
|
|
1073
|
-
];
|
|
1074
|
-
if (this.#context.tsconfig.options.paths) {
|
|
1075
|
-
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) => {
|
|
1076
|
-
if (path && !ret.includes(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, path))) {
|
|
1077
|
-
ret.push(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, path));
|
|
1078
|
-
}
|
|
1079
|
-
return ret;
|
|
1080
|
-
}, paths) : paths;
|
|
1081
|
-
}
|
|
1082
|
-
return paths.reduce((ret, path) => {
|
|
1083
|
-
if (!ret.includes(path)) {
|
|
1084
|
-
ret.push(path);
|
|
1085
|
-
}
|
|
1086
|
-
return ret;
|
|
1087
|
-
}, parents.filter(Boolean).map((p) => this.formatPath(p)));
|
|
1088
|
-
}
|
|
1089
|
-
/**
|
|
1090
|
-
* Clears the resolver cache for a given path.
|
|
1091
|
-
*
|
|
1092
|
-
* @param path - The path to clear the resolver cache for.
|
|
1093
|
-
*/
|
|
1094
|
-
#clearResolverCache(path) {
|
|
1095
|
-
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));
|
|
1096
771
|
}
|
|
1097
772
|
/**
|
|
1098
|
-
*
|
|
773
|
+
* Normalizes a given module id by resolving it against the built-ins path.
|
|
1099
774
|
*
|
|
1100
|
-
* @param
|
|
1101
|
-
* @
|
|
1102
|
-
* @returns The file path if it exists, otherwise false.
|
|
775
|
+
* @param id - The module id to normalize.
|
|
776
|
+
* @returns The normalized module id.
|
|
1103
777
|
*/
|
|
1104
|
-
#
|
|
1105
|
-
|
|
1106
|
-
let file = this.#checkExtensions(path);
|
|
1107
|
-
if (file) {
|
|
1108
|
-
return file;
|
|
1109
|
-
}
|
|
1110
|
-
file = this.#checkIndex(path);
|
|
1111
|
-
if (file) {
|
|
1112
|
-
return file;
|
|
1113
|
-
}
|
|
1114
|
-
return false;
|
|
778
|
+
#normalizeId(id) {
|
|
779
|
+
return normalizeId(id, this.#context.config.output.builtinPrefix);
|
|
1115
780
|
}
|
|
1116
781
|
/**
|
|
1117
|
-
*
|
|
782
|
+
* Normalizes a given path by resolving it against the project root, workspace root, and built-ins path.
|
|
1118
783
|
*
|
|
1119
|
-
* @param
|
|
1120
|
-
* @returns The
|
|
784
|
+
* @param path - The path to normalize.
|
|
785
|
+
* @returns The normalized path.
|
|
1121
786
|
*/
|
|
1122
|
-
#
|
|
1123
|
-
|
|
1124
|
-
if (this.#existsSync(file)) {
|
|
1125
|
-
return file;
|
|
1126
|
-
}
|
|
1127
|
-
file = this.#checkExtensions(file);
|
|
1128
|
-
if (file) {
|
|
1129
|
-
return file;
|
|
1130
|
-
}
|
|
1131
|
-
return false;
|
|
787
|
+
#normalizePath(path) {
|
|
788
|
+
return normalizePath(path, this.#context.builtinsPath, this.#context.config.output.builtinPrefix);
|
|
1132
789
|
}
|
|
1133
790
|
/**
|
|
1134
|
-
*
|
|
791
|
+
* Builds a regular expression from a string pattern for path matching.
|
|
1135
792
|
*
|
|
1136
|
-
* @param
|
|
1137
|
-
* @returns
|
|
793
|
+
* @param path - The string pattern to convert.
|
|
794
|
+
* @returns A regular expression for matching paths.
|
|
1138
795
|
*/
|
|
1139
|
-
#
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
return file;
|
|
1143
|
-
}
|
|
1144
|
-
file = `${request}.mts`;
|
|
1145
|
-
if (this.#existsSync(file)) {
|
|
1146
|
-
return file;
|
|
1147
|
-
}
|
|
1148
|
-
file = `${request}.cts`;
|
|
1149
|
-
if (this.#existsSync(file)) {
|
|
1150
|
-
return file;
|
|
1151
|
-
}
|
|
1152
|
-
file = `${request}.tsx`;
|
|
1153
|
-
if (this.#existsSync(file)) {
|
|
1154
|
-
return file;
|
|
1155
|
-
}
|
|
1156
|
-
file = `${request}.js`;
|
|
1157
|
-
if (this.#existsSync(file)) {
|
|
1158
|
-
return file;
|
|
1159
|
-
}
|
|
1160
|
-
file = `${request}.mjs`;
|
|
1161
|
-
if (this.#existsSync(file)) {
|
|
1162
|
-
return file;
|
|
1163
|
-
}
|
|
1164
|
-
file = `${request}.cjs`;
|
|
1165
|
-
if (this.#existsSync(file)) {
|
|
1166
|
-
return file;
|
|
1167
|
-
}
|
|
1168
|
-
file = `${request}.jsx`;
|
|
1169
|
-
if (this.#existsSync(file)) {
|
|
1170
|
-
return file;
|
|
1171
|
-
}
|
|
1172
|
-
file = `${request}.json`;
|
|
1173
|
-
if (this.#existsSync(file)) {
|
|
1174
|
-
return file;
|
|
1175
|
-
}
|
|
1176
|
-
file = `${request}.d.ts`;
|
|
1177
|
-
if (this.#existsSync(file)) {
|
|
1178
|
-
return file;
|
|
1179
|
-
}
|
|
1180
|
-
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"), ".*")}$`);
|
|
1181
799
|
}
|
|
1182
800
|
/**
|
|
1183
801
|
* Creates a virtual file system (VFS) that is backed up to a Cap'n Proto message buffer.
|
|
@@ -1186,8 +804,8 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1186
804
|
* @returns A promise that resolves to a new virtual file system instance.
|
|
1187
805
|
*/
|
|
1188
806
|
static async create(context) {
|
|
1189
|
-
if (!context.config.skipCache && exists.existsSync(joinPaths.joinPaths(context.
|
|
1190
|
-
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"));
|
|
1191
809
|
const message2 = new $__namespace.Message(buffer$1, false);
|
|
1192
810
|
return new _VirtualFileSystem(context, message2.getRoot(FileSystem));
|
|
1193
811
|
}
|
|
@@ -1201,8 +819,8 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1201
819
|
* @returns A new virtual file system instance.
|
|
1202
820
|
*/
|
|
1203
821
|
static createSync(context) {
|
|
1204
|
-
if (!context.config.skipCache && exists.existsSync(joinPaths.joinPaths(context.
|
|
1205
|
-
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"));
|
|
1206
824
|
const message2 = new $__namespace.Message(buffer$1, false);
|
|
1207
825
|
return new _VirtualFileSystem(context, message2.getRoot(FileSystem));
|
|
1208
826
|
}
|
|
@@ -1213,19 +831,43 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1213
831
|
* A map of file ids to their metadata.
|
|
1214
832
|
*/
|
|
1215
833
|
get metadata() {
|
|
1216
|
-
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
|
+
});
|
|
1217
839
|
}
|
|
1218
840
|
/**
|
|
1219
|
-
* A map of
|
|
841
|
+
* A map of file paths to their module ids.
|
|
1220
842
|
*/
|
|
1221
843
|
get ids() {
|
|
1222
|
-
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
|
+
});
|
|
1223
849
|
}
|
|
1224
850
|
/**
|
|
1225
|
-
* A map of
|
|
851
|
+
* A map of module ids to their file paths.
|
|
1226
852
|
*/
|
|
1227
853
|
get paths() {
|
|
1228
|
-
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;
|
|
1229
871
|
}
|
|
1230
872
|
/**
|
|
1231
873
|
* Creates a new instance of the {@link VirtualFileSystem}.
|
|
@@ -1270,17 +912,13 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1270
912
|
* Check if a path or id corresponds to a virtual file **(does not actually exists on disk)**.
|
|
1271
913
|
*
|
|
1272
914
|
* @param pathOrId - The path or id to check.
|
|
1273
|
-
* @param options - Optional parameters for resolving the path.
|
|
1274
915
|
* @returns Whether the path or id corresponds to a virtual file **(does not actually exists on disk)**.
|
|
1275
916
|
*/
|
|
1276
|
-
isVirtual(pathOrId, options = {}) {
|
|
917
|
+
isVirtual(pathOrId, importer, options = {}) {
|
|
1277
918
|
if (!pathOrId) {
|
|
1278
919
|
return false;
|
|
1279
920
|
}
|
|
1280
|
-
const resolvedPath = this.
|
|
1281
|
-
...options,
|
|
1282
|
-
pathType: "file"
|
|
1283
|
-
});
|
|
921
|
+
const resolvedPath = this.resolveSync(pathOrId, importer, options);
|
|
1284
922
|
if (!resolvedPath) {
|
|
1285
923
|
return false;
|
|
1286
924
|
}
|
|
@@ -1290,17 +928,13 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1290
928
|
* Check if a path or id corresponds to a file written to the file system **(actually exists on disk)**.
|
|
1291
929
|
*
|
|
1292
930
|
* @param pathOrId - The path or id to check.
|
|
1293
|
-
* @param options - Optional parameters for resolving the path.
|
|
1294
931
|
* @returns Whether the path or id corresponds to a file written to the file system **(actually exists on disk)**.
|
|
1295
932
|
*/
|
|
1296
|
-
isPhysical(pathOrId, options = {}) {
|
|
933
|
+
isPhysical(pathOrId, importer, options = {}) {
|
|
1297
934
|
if (!pathOrId) {
|
|
1298
935
|
return false;
|
|
1299
936
|
}
|
|
1300
|
-
const resolvedPath = this.
|
|
1301
|
-
...options,
|
|
1302
|
-
pathType: "file"
|
|
1303
|
-
});
|
|
937
|
+
const resolvedPath = this.resolveSync(pathOrId, importer, options);
|
|
1304
938
|
if (!resolvedPath) {
|
|
1305
939
|
return false;
|
|
1306
940
|
}
|
|
@@ -1322,16 +956,17 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1322
956
|
* @param path - The path to create the directory at.
|
|
1323
957
|
*/
|
|
1324
958
|
unlinkSync(path, options) {
|
|
1325
|
-
|
|
1326
|
-
if (!this.isFile(formattedPath)) {
|
|
959
|
+
if (!this.isFile(this.#normalizePath(path))) {
|
|
1327
960
|
return;
|
|
1328
961
|
}
|
|
1329
|
-
this.#log(types.LogLevelLabel.TRACE, `Synchronously removing file: ${
|
|
1330
|
-
this.#unifiedFS.resolveFS(path, options).unlinkSync(
|
|
1331
|
-
if (this
|
|
1332
|
-
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));
|
|
1333
969
|
}
|
|
1334
|
-
this.#clearResolverCache(formattedPath);
|
|
1335
970
|
}
|
|
1336
971
|
/**
|
|
1337
972
|
* Removes a file in the virtual file system (VFS).
|
|
@@ -1339,19 +974,17 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1339
974
|
* @param path - The path to create the directory at.
|
|
1340
975
|
*/
|
|
1341
976
|
async unlink(path, options) {
|
|
1342
|
-
|
|
1343
|
-
if (!this.isFile(formattedPath)) {
|
|
977
|
+
if (!this.isFile(this.#normalizePath(path))) {
|
|
1344
978
|
return;
|
|
1345
979
|
}
|
|
1346
|
-
this.#log(types.LogLevelLabel.TRACE, `Removing file: ${
|
|
980
|
+
this.#log(types.LogLevelLabel.TRACE, `Removing file: ${this.#normalizePath(path)}`);
|
|
1347
981
|
if (isFunction.isFunction(this.#unifiedFS.resolveFS(path, options).promises.unlink)) {
|
|
1348
|
-
await this.#unifiedFS.resolveFS(path, options).promises.unlink(
|
|
1349
|
-
if (this
|
|
1350
|
-
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)]];
|
|
1351
985
|
}
|
|
1352
|
-
this.#clearResolverCache(formattedPath);
|
|
1353
986
|
} else {
|
|
1354
|
-
this.unlinkSync(
|
|
987
|
+
this.unlinkSync(this.#normalizePath(path), options);
|
|
1355
988
|
}
|
|
1356
989
|
}
|
|
1357
990
|
/**
|
|
@@ -1361,15 +994,13 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1361
994
|
* @param options - Options for creating the directory.
|
|
1362
995
|
*/
|
|
1363
996
|
rmdirSync(path, options = {}) {
|
|
1364
|
-
|
|
1365
|
-
if (!this.isDirectory(formattedPath)) {
|
|
997
|
+
if (!this.isDirectory(this.#normalizePath(path))) {
|
|
1366
998
|
return;
|
|
1367
999
|
}
|
|
1368
|
-
this.#log(types.LogLevelLabel.TRACE, `Synchronously removing directory: ${
|
|
1369
|
-
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, {
|
|
1370
1002
|
recursive: true
|
|
1371
1003
|
}));
|
|
1372
|
-
this.#clearResolverCache(formattedPath);
|
|
1373
1004
|
}
|
|
1374
1005
|
/**
|
|
1375
1006
|
* Removes a directory in the virtual file system (VFS).
|
|
@@ -1379,19 +1010,17 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1379
1010
|
* @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
|
|
1380
1011
|
*/
|
|
1381
1012
|
async rmdir(path, options = {}) {
|
|
1382
|
-
|
|
1383
|
-
if (!this.isDirectory(formattedPath)) {
|
|
1013
|
+
if (!this.isDirectory(this.#normalizePath(path))) {
|
|
1384
1014
|
return;
|
|
1385
1015
|
}
|
|
1386
|
-
this.#log(types.LogLevelLabel.TRACE, `Removing directory: ${
|
|
1016
|
+
this.#log(types.LogLevelLabel.TRACE, `Removing directory: ${this.#normalizePath(path)}`);
|
|
1387
1017
|
if (isFunction.isFunction(this.#unifiedFS.resolveFS(path, options).promises.rm)) {
|
|
1388
|
-
await this.#unifiedFS.resolveFS(path, options).promises.rm(
|
|
1018
|
+
await this.#unifiedFS.resolveFS(path, options).promises.rm(this.#normalizePath(path), defu2__default.default(options, {
|
|
1389
1019
|
force: true,
|
|
1390
1020
|
recursive: true
|
|
1391
1021
|
}));
|
|
1392
|
-
this.#clearResolverCache(formattedPath);
|
|
1393
1022
|
} else {
|
|
1394
|
-
this.rmdirSync(
|
|
1023
|
+
this.rmdirSync(this.#normalizePath(path), defu2__default.default(options ?? {}, {
|
|
1395
1024
|
force: true,
|
|
1396
1025
|
recursive: true
|
|
1397
1026
|
}));
|
|
@@ -1405,11 +1034,11 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1405
1034
|
* @returns A promise that resolves when the file is removed.
|
|
1406
1035
|
*/
|
|
1407
1036
|
async rm(path, options = {}) {
|
|
1408
|
-
this.#log(types.LogLevelLabel.TRACE, `Removing: ${
|
|
1409
|
-
if (this.isDirectory(path)) {
|
|
1410
|
-
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);
|
|
1411
1040
|
}
|
|
1412
|
-
return this.unlink(path, options);
|
|
1041
|
+
return this.unlink(this.#normalizePath(path), options);
|
|
1413
1042
|
}
|
|
1414
1043
|
/**
|
|
1415
1044
|
* Synchronously removes a file or directory in the virtual file system (VFS).
|
|
@@ -1418,11 +1047,11 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1418
1047
|
* @param options - Options for removing the file or directory.
|
|
1419
1048
|
*/
|
|
1420
1049
|
rmSync(path, options = {}) {
|
|
1421
|
-
this.#log(types.LogLevelLabel.TRACE, `Removing: ${
|
|
1422
|
-
if (this.isDirectory(path)) {
|
|
1423
|
-
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);
|
|
1424
1053
|
}
|
|
1425
|
-
return this.unlinkSync(path, options);
|
|
1054
|
+
return this.unlinkSync(this.#normalizePath(path), options);
|
|
1426
1055
|
}
|
|
1427
1056
|
/**
|
|
1428
1057
|
* Creates a directory in the virtual file system (VFS).
|
|
@@ -1432,9 +1061,9 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1432
1061
|
* @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
|
|
1433
1062
|
*/
|
|
1434
1063
|
mkdirSync(path, options = {}) {
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1064
|
+
return this.#unifiedFS.resolveFS(this.#normalizePath(path), options).mkdirSync(this.#normalizePath(path), defu2__default.default(omit.omit(options, [
|
|
1065
|
+
"mode"
|
|
1066
|
+
]), {
|
|
1438
1067
|
recursive: true
|
|
1439
1068
|
}));
|
|
1440
1069
|
}
|
|
@@ -1447,17 +1076,19 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1447
1076
|
*/
|
|
1448
1077
|
async mkdir(path, options = {}) {
|
|
1449
1078
|
let result;
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
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
|
+
]), {
|
|
1453
1083
|
recursive: true
|
|
1454
1084
|
}));
|
|
1455
1085
|
} else {
|
|
1456
|
-
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
|
+
]), {
|
|
1457
1089
|
recursive: true
|
|
1458
1090
|
}));
|
|
1459
1091
|
}
|
|
1460
|
-
this.#clearResolverCache(filePath);
|
|
1461
1092
|
return result;
|
|
1462
1093
|
}
|
|
1463
1094
|
/**
|
|
@@ -1469,17 +1100,15 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1469
1100
|
async glob(patterns) {
|
|
1470
1101
|
const results = [];
|
|
1471
1102
|
for (const pattern of toArray.toArray(patterns)) {
|
|
1472
|
-
const normalized = this
|
|
1103
|
+
const normalized = this.#normalizePath(pattern);
|
|
1473
1104
|
if (!/[*?[\]{}]/.test(normalized) && !normalized.includes("**")) {
|
|
1474
|
-
const resolved = this.
|
|
1475
|
-
pathType: "file"
|
|
1476
|
-
});
|
|
1105
|
+
const resolved = this.resolveSync(normalized);
|
|
1477
1106
|
if (resolved && !results.includes(resolved)) {
|
|
1478
1107
|
results.push(resolved);
|
|
1479
1108
|
}
|
|
1480
1109
|
continue;
|
|
1481
1110
|
}
|
|
1482
|
-
const absPattern = isType.isAbsolutePath(normalized) ? normalized : this
|
|
1111
|
+
const absPattern = isType.isAbsolutePath(normalized) ? normalized : this.#normalizePath(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, normalized));
|
|
1483
1112
|
const firstGlobIdx = absPattern.search(/[*?[\]{}]/);
|
|
1484
1113
|
const baseDir = firstGlobIdx === -1 ? filePathFns.findFilePath(absPattern) : absPattern.slice(0, Math.max(0, absPattern.lastIndexOf("/", firstGlobIdx)));
|
|
1485
1114
|
const stack = [
|
|
@@ -1494,7 +1123,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1494
1123
|
continue;
|
|
1495
1124
|
}
|
|
1496
1125
|
for (const entry of entries) {
|
|
1497
|
-
const full = this
|
|
1126
|
+
const full = this.#normalizePath(joinPaths.joinPaths(dir, entry));
|
|
1498
1127
|
let stats;
|
|
1499
1128
|
try {
|
|
1500
1129
|
stats = this.#unifiedFS.lstatSync(full);
|
|
@@ -1506,9 +1135,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1506
1135
|
stack.push(full);
|
|
1507
1136
|
} else if (stats.isFile()) {
|
|
1508
1137
|
if (this.#buildRegex(absPattern).test(full)) {
|
|
1509
|
-
const resolved = this.
|
|
1510
|
-
pathType: "file"
|
|
1511
|
-
});
|
|
1138
|
+
const resolved = this.resolveSync(full);
|
|
1512
1139
|
if (resolved && !results.includes(resolved)) {
|
|
1513
1140
|
results.push(resolved);
|
|
1514
1141
|
}
|
|
@@ -1528,17 +1155,15 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1528
1155
|
globSync(patterns) {
|
|
1529
1156
|
const results = [];
|
|
1530
1157
|
for (const pattern of toArray.toArray(patterns)) {
|
|
1531
|
-
const normalized = this
|
|
1158
|
+
const normalized = this.#normalizePath(pattern);
|
|
1532
1159
|
if (!/[*?[\]{}]/.test(normalized) && !normalized.includes("**")) {
|
|
1533
|
-
const resolved = this.
|
|
1534
|
-
pathType: "file"
|
|
1535
|
-
});
|
|
1160
|
+
const resolved = this.resolveSync(normalized);
|
|
1536
1161
|
if (resolved && !results.includes(resolved)) {
|
|
1537
1162
|
results.push(resolved);
|
|
1538
1163
|
}
|
|
1539
1164
|
continue;
|
|
1540
1165
|
}
|
|
1541
|
-
const absPattern = isType.isAbsolutePath(normalized) ? normalized : this
|
|
1166
|
+
const absPattern = isType.isAbsolutePath(normalized) ? normalized : this.#normalizePath(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, normalized));
|
|
1542
1167
|
const firstGlobIdx = absPattern.search(/[*?[\]{}]/);
|
|
1543
1168
|
const baseDir = firstGlobIdx === -1 ? filePathFns.findFilePath(absPattern) : absPattern.slice(0, Math.max(0, absPattern.lastIndexOf("/", firstGlobIdx)));
|
|
1544
1169
|
const stack = [
|
|
@@ -1553,7 +1178,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1553
1178
|
continue;
|
|
1554
1179
|
}
|
|
1555
1180
|
for (const entry of entries) {
|
|
1556
|
-
const full = this
|
|
1181
|
+
const full = this.#normalizePath(joinPaths.joinPaths(dir, entry));
|
|
1557
1182
|
let stats;
|
|
1558
1183
|
try {
|
|
1559
1184
|
stats = this.#unifiedFS.lstatSync(full);
|
|
@@ -1565,9 +1190,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1565
1190
|
stack.push(full);
|
|
1566
1191
|
} else if (stats.isFile()) {
|
|
1567
1192
|
if (this.#buildRegex(absPattern).test(full)) {
|
|
1568
|
-
const resolved = this.
|
|
1569
|
-
pathType: "file"
|
|
1570
|
-
});
|
|
1193
|
+
const resolved = this.resolveSync(full);
|
|
1571
1194
|
if (resolved && !results.includes(resolved)) {
|
|
1572
1195
|
results.push(resolved);
|
|
1573
1196
|
}
|
|
@@ -1637,21 +1260,15 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1637
1260
|
* @returns A promise that resolves to the contents of the file as a string, or undefined if the file does not exist.
|
|
1638
1261
|
*/
|
|
1639
1262
|
async readFile(pathOrId, options = "utf8") {
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
}
|
|
1643
|
-
const filePath = this.resolve(toFilePath(pathOrId), {
|
|
1644
|
-
pathType: "file"
|
|
1645
|
-
});
|
|
1646
|
-
if (filePath) {
|
|
1263
|
+
const filePath = await this.resolve(pathOrId);
|
|
1264
|
+
if (filePath && this.isFile(filePath)) {
|
|
1647
1265
|
let result;
|
|
1648
1266
|
if (isFunction.isFunction(this.#unifiedFS.resolveFS(filePath).promises.readFile)) {
|
|
1649
1267
|
result = (await this.#unifiedFS.resolveFS(filePath).promises.readFile(filePath, options))?.toString("utf8");
|
|
1650
1268
|
} else {
|
|
1651
1269
|
result = this.#unifiedFS.resolveFS(filePath).readFileSync(filePath, options);
|
|
1652
1270
|
}
|
|
1653
|
-
|
|
1654
|
-
return content;
|
|
1271
|
+
return isBuffer.isBuffer(result) ? bufferToString.bufferToString(result) : result;
|
|
1655
1272
|
}
|
|
1656
1273
|
return void 0;
|
|
1657
1274
|
}
|
|
@@ -1662,16 +1279,10 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1662
1279
|
* @returns The contents of the file as a string, or undefined if the file does not exist.
|
|
1663
1280
|
*/
|
|
1664
1281
|
readFileSync(pathOrId, options = "utf8") {
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
}
|
|
1668
|
-
const filePath = this.resolve(toFilePath(pathOrId), {
|
|
1669
|
-
pathType: "file"
|
|
1670
|
-
});
|
|
1671
|
-
if (filePath) {
|
|
1282
|
+
const filePath = this.resolveSync(pathOrId);
|
|
1283
|
+
if (filePath && this.isFile(filePath)) {
|
|
1672
1284
|
const result = this.#unifiedFS.resolveFS(filePath).readFileSync(filePath, options);
|
|
1673
|
-
|
|
1674
|
-
return content;
|
|
1285
|
+
return isBuffer.isBuffer(result) ? bufferToString.bufferToString(result) : result;
|
|
1675
1286
|
}
|
|
1676
1287
|
return void 0;
|
|
1677
1288
|
}
|
|
@@ -1684,34 +1295,40 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1684
1295
|
* @returns A promise that resolves when the file is written.
|
|
1685
1296
|
*/
|
|
1686
1297
|
async writeFile(path, data = "", options = "utf8") {
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
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);
|
|
1690
1300
|
}
|
|
1691
|
-
|
|
1301
|
+
const metadata = isVirtualFileData(data) ? data : {};
|
|
1302
|
+
metadata.id = this.#normalizeId(path);
|
|
1303
|
+
let code = isVirtualFileData(data) ? metadata.code : data;
|
|
1692
1304
|
if ((!isPowerlinesWriteFileOptions(options) || !options.skipFormat) && isSetString.isSetString(code)) {
|
|
1693
|
-
const resolvedConfig = await prettier.resolveConfig(
|
|
1305
|
+
const resolvedConfig = await prettier.resolveConfig(this.#normalizePath(path));
|
|
1694
1306
|
if (resolvedConfig) {
|
|
1695
1307
|
code = await prettier.format(code, {
|
|
1696
|
-
absolutePath:
|
|
1308
|
+
absolutePath: this.#normalizePath(path),
|
|
1697
1309
|
...resolvedConfig
|
|
1698
1310
|
});
|
|
1699
1311
|
}
|
|
1700
1312
|
}
|
|
1701
|
-
const outputMode = this.#unifiedFS.resolveMode(
|
|
1702
|
-
this.#log(types.LogLevelLabel.TRACE, `Writing ${
|
|
1703
|
-
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] = {
|
|
1704
1316
|
mode: outputMode,
|
|
1705
1317
|
variant: "normal",
|
|
1706
1318
|
timestamp: Date.now(),
|
|
1707
|
-
...
|
|
1319
|
+
...metadata
|
|
1708
1320
|
};
|
|
1709
|
-
this.#
|
|
1710
|
-
|
|
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);
|
|
1711
1324
|
if (isFunction.isFunction(ifs.promises.writeFile)) {
|
|
1712
|
-
return ifs.promises.writeFile(
|
|
1325
|
+
return ifs.promises.writeFile(this.#normalizePath(path), code, isSetObject.isSetObject(options) ? omit.omit(options, [
|
|
1326
|
+
"mode"
|
|
1327
|
+
]) : "utf8");
|
|
1713
1328
|
}
|
|
1714
|
-
return ifs.writeFileSync(
|
|
1329
|
+
return ifs.writeFileSync(this.#normalizePath(path), code, isSetObject.isSetObject(options) ? omit.omit(options, [
|
|
1330
|
+
"mode"
|
|
1331
|
+
]) : "utf8");
|
|
1715
1332
|
}
|
|
1716
1333
|
/**
|
|
1717
1334
|
* Synchronously writes a file to the virtual file system (VFS).
|
|
@@ -1721,21 +1338,23 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1721
1338
|
* @param options - Optional parameters for writing the file.
|
|
1722
1339
|
*/
|
|
1723
1340
|
writeFileSync(path, data = "", options = "utf8") {
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
}
|
|
1728
|
-
|
|
1729
|
-
const
|
|
1730
|
-
this.#
|
|
1731
|
-
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] = {
|
|
1732
1350
|
mode: outputMode,
|
|
1733
1351
|
variant: "normal",
|
|
1734
1352
|
timestamp: Date.now(),
|
|
1735
|
-
...
|
|
1353
|
+
...metadata
|
|
1736
1354
|
};
|
|
1737
|
-
this.#
|
|
1738
|
-
|
|
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));
|
|
1739
1358
|
try {
|
|
1740
1359
|
writeStream.write(code);
|
|
1741
1360
|
} finally {
|
|
@@ -1749,7 +1368,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1749
1368
|
* @returns `true` if the file exists, otherwise `false`.
|
|
1750
1369
|
*/
|
|
1751
1370
|
existsSync(pathOrId) {
|
|
1752
|
-
return this.
|
|
1371
|
+
return !!this.resolveSync(pathOrId);
|
|
1753
1372
|
}
|
|
1754
1373
|
/**
|
|
1755
1374
|
* Retrieves the metadata of a file in the virtual file system (VFS).
|
|
@@ -1758,7 +1377,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1758
1377
|
* @returns The metadata of the file, or undefined if the file does not exist.
|
|
1759
1378
|
*/
|
|
1760
1379
|
getMetadata(pathOrId) {
|
|
1761
|
-
const resolved = this.
|
|
1380
|
+
const resolved = this.resolveSync(pathOrId);
|
|
1762
1381
|
if (resolved && this.metadata[resolved]) {
|
|
1763
1382
|
return this.metadata[resolved];
|
|
1764
1383
|
}
|
|
@@ -1774,7 +1393,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1774
1393
|
* @returns `true` if the file exists, otherwise `false`.
|
|
1775
1394
|
*/
|
|
1776
1395
|
isFile(pathOrId) {
|
|
1777
|
-
const resolved = this.
|
|
1396
|
+
const resolved = this.resolveSync(pathOrId);
|
|
1778
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()));
|
|
1779
1398
|
}
|
|
1780
1399
|
/**
|
|
@@ -1784,7 +1403,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1784
1403
|
* @returns `true` if the directory exists, otherwise `false`.
|
|
1785
1404
|
*/
|
|
1786
1405
|
isDirectory(pathOrId) {
|
|
1787
|
-
const resolved = this.
|
|
1406
|
+
const resolved = this.resolveSync(pathOrId);
|
|
1788
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()));
|
|
1789
1408
|
}
|
|
1790
1409
|
/**
|
|
@@ -1794,7 +1413,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1794
1413
|
* @returns A promise that resolves to the file's status information, or false if the file does not exist.
|
|
1795
1414
|
*/
|
|
1796
1415
|
async stat(pathOrId, options) {
|
|
1797
|
-
return this.#unifiedFS.resolveFS(pathOrId).promises.stat(this.resolve(
|
|
1416
|
+
return this.#unifiedFS.resolveFS(pathOrId).promises.stat(await this.resolve(pathOrId) || pathOrId, options);
|
|
1798
1417
|
}
|
|
1799
1418
|
/**
|
|
1800
1419
|
* Synchronously retrieves the status of a file in the virtual file system (VFS).
|
|
@@ -1803,7 +1422,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1803
1422
|
* @returns The file's status information, or false if the file does not exist.
|
|
1804
1423
|
*/
|
|
1805
1424
|
statSync(pathOrId) {
|
|
1806
|
-
return this.#unifiedFS.resolveFS(pathOrId).statSync(this.
|
|
1425
|
+
return this.#unifiedFS.resolveFS(pathOrId).statSync(this.resolveSync(pathOrId) || pathOrId);
|
|
1807
1426
|
}
|
|
1808
1427
|
/**
|
|
1809
1428
|
* Retrieves the status of a symbolic link in the virtual file system (VFS).
|
|
@@ -1812,7 +1431,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1812
1431
|
* @returns A promise that resolves to the symbolic link's status information, or false if the link does not exist.
|
|
1813
1432
|
*/
|
|
1814
1433
|
async lstat(pathOrId, options) {
|
|
1815
|
-
return this.#unifiedFS.resolveFS(pathOrId).promises.lstat(this.resolve(
|
|
1434
|
+
return this.#unifiedFS.resolveFS(pathOrId).promises.lstat(await this.resolve(pathOrId) || pathOrId, options);
|
|
1816
1435
|
}
|
|
1817
1436
|
/**
|
|
1818
1437
|
* Synchronously retrieves the status of a symbolic link in the virtual file system (VFS).
|
|
@@ -1821,7 +1440,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1821
1440
|
* @returns The symbolic link's status information, or false if the link does not exist.
|
|
1822
1441
|
*/
|
|
1823
1442
|
lstatSync(pathOrId, options) {
|
|
1824
|
-
return this.#unifiedFS.resolveFS(pathOrId).lstatSync(this.
|
|
1443
|
+
return this.#unifiedFS.resolveFS(pathOrId).lstatSync(this.resolveSync(pathOrId) || pathOrId, options);
|
|
1825
1444
|
}
|
|
1826
1445
|
/**
|
|
1827
1446
|
* Resolves a path or ID to its real path in the virtual file system (VFS).
|
|
@@ -1830,52 +1449,113 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1830
1449
|
* @returns The resolved real path if it exists, otherwise undefined.
|
|
1831
1450
|
*/
|
|
1832
1451
|
realpathSync(pathOrId) {
|
|
1833
|
-
const filePath = this.
|
|
1452
|
+
const filePath = this.resolveSync(pathOrId);
|
|
1834
1453
|
if (!filePath) {
|
|
1835
|
-
throw new Error(`File not found: ${
|
|
1454
|
+
throw new Error(`File not found: ${pathOrId}`);
|
|
1836
1455
|
}
|
|
1837
1456
|
return filePath;
|
|
1838
1457
|
}
|
|
1839
1458
|
/**
|
|
1840
|
-
*
|
|
1459
|
+
* A helper function to resolve modules in the virtual file system (VFS).
|
|
1841
1460
|
*
|
|
1842
|
-
* @
|
|
1843
|
-
*
|
|
1844
|
-
*
|
|
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.
|
|
1845
1473
|
*/
|
|
1846
|
-
resolve(
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
return this.#cachedResolver.get(resolverKey);
|
|
1851
|
-
}
|
|
1852
|
-
let result = this.#resolveId(formattedPathOrId);
|
|
1853
|
-
if (!result) {
|
|
1854
|
-
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;
|
|
1855
1478
|
}
|
|
1479
|
+
result = this.paths[this.#normalizeId(id)];
|
|
1856
1480
|
if (!result) {
|
|
1857
|
-
|
|
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
|
+
}
|
|
1858
1502
|
}
|
|
1859
|
-
if (result
|
|
1860
|
-
|
|
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);
|
|
1861
1506
|
}
|
|
1862
|
-
this.#cachedResolver.set(resolverKey, result);
|
|
1863
1507
|
return result;
|
|
1864
1508
|
}
|
|
1865
1509
|
/**
|
|
1866
|
-
*
|
|
1510
|
+
* A synchronous helper function to resolve modules using the Jiti resolver
|
|
1867
1511
|
*
|
|
1868
|
-
* @
|
|
1869
|
-
*
|
|
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.
|
|
1870
1524
|
*/
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
if (
|
|
1874
|
-
return
|
|
1875
|
-
} else if (formattedPath.startsWith(this.#context.config.projectRoot)) {
|
|
1876
|
-
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;
|
|
1877
1529
|
}
|
|
1878
|
-
|
|
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;
|
|
1879
1559
|
}
|
|
1880
1560
|
/**
|
|
1881
1561
|
* Disposes of the virtual file system (VFS) by saving its state to disk.
|
|
@@ -1884,7 +1564,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1884
1564
|
if (!this.#isDisposed) {
|
|
1885
1565
|
this.#isDisposed = true;
|
|
1886
1566
|
this.#log(types.LogLevelLabel.DEBUG, "Disposing virtual file system...");
|
|
1887
|
-
await this.unlink(joinPaths.joinPaths(this.#context.
|
|
1567
|
+
await this.unlink(joinPaths.joinPaths(this.#context.dataPath, "fs.bin"));
|
|
1888
1568
|
const message = new $__namespace.Message();
|
|
1889
1569
|
const fs2 = message.initRoot(FileSystem);
|
|
1890
1570
|
const virtualFS = this.#unifiedFS.toJSON();
|
|
@@ -1893,7 +1573,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1893
1573
|
virtualFiles.forEach(([path, code], index) => {
|
|
1894
1574
|
const fd = files.get(index);
|
|
1895
1575
|
fd.path = path;
|
|
1896
|
-
fd.code = code;
|
|
1576
|
+
fd.code = code || "";
|
|
1897
1577
|
});
|
|
1898
1578
|
const ids = fs2._initIds(Object.keys(this.ids).length);
|
|
1899
1579
|
Object.entries(this.ids).forEach(([id, path], index) => {
|
|
@@ -1917,7 +1597,9 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1917
1597
|
});
|
|
1918
1598
|
}
|
|
1919
1599
|
});
|
|
1920
|
-
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.");
|
|
1921
1603
|
}
|
|
1922
1604
|
}
|
|
1923
1605
|
/**
|
|
@@ -1966,6 +1648,8 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
1966
1648
|
#envPaths;
|
|
1967
1649
|
#fs;
|
|
1968
1650
|
#tsconfig;
|
|
1651
|
+
#program;
|
|
1652
|
+
#resolvePatterns = [];
|
|
1969
1653
|
#getConfigProps(config = {}) {
|
|
1970
1654
|
return {
|
|
1971
1655
|
variant: config.build?.variant,
|
|
@@ -2000,7 +1684,7 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
2000
1684
|
* @returns A promise that resolves to the new context.
|
|
2001
1685
|
*/
|
|
2002
1686
|
static async from(workspaceRoot, config) {
|
|
2003
|
-
const context = new _PowerlinesContext(await
|
|
1687
|
+
const context = new _PowerlinesContext(await chunkK3NBD5LL_cjs.loadWorkspaceConfig(workspaceRoot, config.root));
|
|
2004
1688
|
await context.withUserConfig(config);
|
|
2005
1689
|
context.powerlinesPath = await resolve.resolvePackage("powerlines");
|
|
2006
1690
|
if (!context.powerlinesPath) {
|
|
@@ -2057,7 +1741,7 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
2057
1741
|
*/
|
|
2058
1742
|
get tsconfig() {
|
|
2059
1743
|
if (!this.#tsconfig) {
|
|
2060
|
-
this
|
|
1744
|
+
this.tsconfig = {
|
|
2061
1745
|
tsconfigFilePath: this.config.tsconfig
|
|
2062
1746
|
};
|
|
2063
1747
|
}
|
|
@@ -2068,6 +1752,7 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
2068
1752
|
*/
|
|
2069
1753
|
set tsconfig(value) {
|
|
2070
1754
|
this.#tsconfig = value;
|
|
1755
|
+
this.#resolvePatterns = bundleRequire.tsconfigPathsToRegExp(value?.options?.paths ?? {});
|
|
2071
1756
|
}
|
|
2072
1757
|
/**
|
|
2073
1758
|
* The virtual file system interface for the project
|
|
@@ -2097,10 +1782,10 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
2097
1782
|
workspaceRoot: this.workspaceConfig?.workspaceRoot,
|
|
2098
1783
|
projectRoot: this.config?.projectRoot
|
|
2099
1784
|
}, {
|
|
2100
|
-
maxLength:
|
|
1785
|
+
maxLength: chunk7VJ42H2I_cjs.PROJECT_ROOT_HASH_LENGTH
|
|
2101
1786
|
}),
|
|
2102
1787
|
configHash: murmurhash.murmurhash(this.config, {
|
|
2103
|
-
maxLength:
|
|
1788
|
+
maxLength: chunk7VJ42H2I_cjs.CACHE_HASH_LENGTH
|
|
2104
1789
|
})
|
|
2105
1790
|
};
|
|
2106
1791
|
}
|
|
@@ -2160,7 +1845,7 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
2160
1845
|
* Get the path to the data directory for the project
|
|
2161
1846
|
*/
|
|
2162
1847
|
get dataPath() {
|
|
2163
|
-
return join.joinPaths(this.envPaths.data, "projects",
|
|
1848
|
+
return join.joinPaths(this.envPaths.data, "projects", chunk7VJ42H2I_cjs.getPrefixedProjectRootHash(this.config.name, this.meta.projectRootHash));
|
|
2164
1849
|
}
|
|
2165
1850
|
/**
|
|
2166
1851
|
* Get the path to the cache directory for the project
|
|
@@ -2170,7 +1855,7 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
2170
1855
|
checksum: this.#checksum,
|
|
2171
1856
|
config: this.meta.configHash
|
|
2172
1857
|
}, {
|
|
2173
|
-
maxLength:
|
|
1858
|
+
maxLength: chunk7VJ42H2I_cjs.CACHE_HASH_LENGTH
|
|
2174
1859
|
}));
|
|
2175
1860
|
}
|
|
2176
1861
|
/**
|
|
@@ -2192,6 +1877,106 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
2192
1877
|
return Object.values(this.fs.metadata).filter((meta) => meta && meta.type === "builtin").map((meta) => meta?.id).filter(Boolean);
|
|
2193
1878
|
}
|
|
2194
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
|
+
/**
|
|
2195
1980
|
* Get the builtin virtual files that exist in the Powerlines virtual file system
|
|
2196
1981
|
*/
|
|
2197
1982
|
async getBuiltins() {
|
|
@@ -2414,9 +2199,10 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
2414
2199
|
projectRoot: cacheKey.projectRoot,
|
|
2415
2200
|
cacheDir: this.cachePath,
|
|
2416
2201
|
mode: cacheKey.mode,
|
|
2202
|
+
logLevel: config.logLevel || this.config?.logLevel || this.workspaceConfig.logLevel || "info",
|
|
2417
2203
|
skipCache: cacheKey.skipCache
|
|
2418
2204
|
});
|
|
2419
|
-
const userConfig = await
|
|
2205
|
+
const userConfig = await chunkK3NBD5LL_cjs.loadUserConfigFile(cacheKey.projectRoot, this.workspaceConfig.workspaceRoot, this.resolver, cacheKey.command, cacheKey.mode, cacheKey.configFile, cacheKey.framework);
|
|
2420
2206
|
this.mergeUserConfig(userConfig.config);
|
|
2421
2207
|
configCache.set(cacheKey, {
|
|
2422
2208
|
projectJson: this.projectJson,
|
|
@@ -2527,6 +2313,24 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
2527
2313
|
ret.push(plugin);
|
|
2528
2314
|
return ret;
|
|
2529
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
|
+
}
|
|
2530
2334
|
this.#fs ??= await VirtualFileSystem.create(this);
|
|
2531
2335
|
}
|
|
2532
2336
|
mergeUserConfig(from = {}, into = this.config.userConfig ?? {}) {
|
|
@@ -2552,7 +2356,6 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
2552
2356
|
|
|
2553
2357
|
exports.PowerlinesContext = PowerlinesContext;
|
|
2554
2358
|
exports.VirtualFileSystem = VirtualFileSystem;
|
|
2555
|
-
exports.__VFS_PATCH__ = __VFS_PATCH__;
|
|
2556
2359
|
exports.__VFS_REVERT__ = __VFS_REVERT__;
|
|
2557
2360
|
exports.addPluginHook = addPluginHook;
|
|
2558
2361
|
exports.checkDedupe = checkDedupe;
|