powerlines 0.23.10 → 0.24.1
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 +17 -16
- 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,7 +1,8 @@
|
|
|
1
1
|
import { CACHE_HASH_LENGTH, PROJECT_ROOT_HASH_LENGTH, getPrefixedProjectRootHash } from './chunk-FQLZZYYO.js';
|
|
2
|
+
import { createProgram } from './chunk-YQ3ODCHV.js';
|
|
2
3
|
import { loadWorkspaceConfig, loadUserConfigFile } from './chunk-XBM7FHNK.js';
|
|
3
4
|
import { extendLog, createLog } from './chunk-ENRLU4UR.js';
|
|
4
|
-
import { resolveEntriesSync, getUniqueEntries } from './chunk-XZFEHPYE.js';
|
|
5
|
+
import { resolveEntriesSync, getUniqueEntries, replacePathTokens } from './chunk-XZFEHPYE.js';
|
|
5
6
|
import { __name } from './chunk-SHUYVCID.js';
|
|
6
7
|
import { LogLevelLabel } from '@storm-software/config-tools/types';
|
|
7
8
|
import { toArray } from '@stryke/convert/to-array';
|
|
@@ -9,7 +10,7 @@ import { getEnvPaths } from '@stryke/env/get-env-paths';
|
|
|
9
10
|
import { existsSync } from '@stryke/fs/exists';
|
|
10
11
|
import { relativeToWorkspaceRoot } from '@stryke/fs/get-workspace-root';
|
|
11
12
|
import { readJsonFile } from '@stryke/fs/json';
|
|
12
|
-
import { resolvePackage } from '@stryke/fs/resolve';
|
|
13
|
+
import { getResolutionCombinations, resolve, resolveSync, resolvePackage } from '@stryke/fs/resolve';
|
|
13
14
|
import { hashDirectory } from '@stryke/hash/hash-files';
|
|
14
15
|
import { murmurhash } from '@stryke/hash/murmurhash';
|
|
15
16
|
import { getUnique } from '@stryke/helpers/get-unique';
|
|
@@ -25,6 +26,7 @@ import { isSetObject } from '@stryke/type-checks/is-set-object';
|
|
|
25
26
|
import { isSetString } from '@stryke/type-checks/is-set-string';
|
|
26
27
|
import { isString } from '@stryke/type-checks/is-string';
|
|
27
28
|
import { uuid } from '@stryke/unique-id/uuid';
|
|
29
|
+
import { tsconfigPathsToRegExp, match } from 'bundle-require';
|
|
28
30
|
import defu2 from 'defu';
|
|
29
31
|
import { joinPaths as joinPaths$1 } from '@stryke/path/join-paths';
|
|
30
32
|
import { createJiti } from 'jiti';
|
|
@@ -33,9 +35,11 @@ import { isUndefined } from '@stryke/type-checks/is-undefined';
|
|
|
33
35
|
import * as $ from '@stryke/capnp';
|
|
34
36
|
import { bufferToString } from '@stryke/convert/buffer-to-string';
|
|
35
37
|
import { readFileBuffer, readFileBufferSync, writeFileBuffer } from '@stryke/fs/buffer';
|
|
36
|
-
import {
|
|
38
|
+
import { toAbsolutePath } from '@stryke/path/correct-path';
|
|
39
|
+
import { findFilePath, findFileDotExtensionSafe } from '@stryke/path/file-path-fns';
|
|
37
40
|
import { prettyBytes } from '@stryke/string-format/pretty-bytes';
|
|
38
41
|
import { isBuffer } from '@stryke/type-checks/is-buffer';
|
|
42
|
+
import { create } from 'flat-cache';
|
|
39
43
|
import { Blob } from 'node:buffer';
|
|
40
44
|
import _fs from 'node:fs';
|
|
41
45
|
import { resolveConfig, format } from 'prettier';
|
|
@@ -232,187 +236,6 @@ var FileMetadata = class _FileMetadata extends $.Struct {
|
|
|
232
236
|
return "FileMetadata_" + super.toString();
|
|
233
237
|
}
|
|
234
238
|
};
|
|
235
|
-
var ChunkData = class extends $.Struct {
|
|
236
|
-
static {
|
|
237
|
-
__name(this, "ChunkData");
|
|
238
|
-
}
|
|
239
|
-
static _capnp = {
|
|
240
|
-
displayName: "ChunkData",
|
|
241
|
-
id: "84076f13b057f83a",
|
|
242
|
-
size: new $.ObjectSize(8, 4)
|
|
243
|
-
};
|
|
244
|
-
/**
|
|
245
|
-
* An additional name for the file.
|
|
246
|
-
*
|
|
247
|
-
*/
|
|
248
|
-
get id() {
|
|
249
|
-
return $.utils.getText(0, this);
|
|
250
|
-
}
|
|
251
|
-
set id(value) {
|
|
252
|
-
$.utils.setText(0, value, this);
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* Files that are implicitly loaded after one of the specified files.
|
|
256
|
-
*
|
|
257
|
-
*/
|
|
258
|
-
get name() {
|
|
259
|
-
return $.utils.getText(1, this);
|
|
260
|
-
}
|
|
261
|
-
set name(value) {
|
|
262
|
-
$.utils.setText(1, value, this);
|
|
263
|
-
}
|
|
264
|
-
_adoptImplicitlyLoadedAfterOneOf(value) {
|
|
265
|
-
$.utils.adopt(value, $.utils.getPointer(2, this));
|
|
266
|
-
}
|
|
267
|
-
_disownImplicitlyLoadedAfterOneOf() {
|
|
268
|
-
return $.utils.disown(this.implicitlyLoadedAfterOneOf);
|
|
269
|
-
}
|
|
270
|
-
/**
|
|
271
|
-
* The importer of the file.
|
|
272
|
-
*
|
|
273
|
-
*/
|
|
274
|
-
get implicitlyLoadedAfterOneOf() {
|
|
275
|
-
return $.utils.getList(2, $.TextList, this);
|
|
276
|
-
}
|
|
277
|
-
_hasImplicitlyLoadedAfterOneOf() {
|
|
278
|
-
return !$.utils.isNull($.utils.getPointer(2, this));
|
|
279
|
-
}
|
|
280
|
-
_initImplicitlyLoadedAfterOneOf(length) {
|
|
281
|
-
return $.utils.initList(2, $.TextList, length, this);
|
|
282
|
-
}
|
|
283
|
-
set implicitlyLoadedAfterOneOf(value) {
|
|
284
|
-
$.utils.copyFrom(value, $.utils.getPointer(2, this));
|
|
285
|
-
}
|
|
286
|
-
/**
|
|
287
|
-
* The signature preservation mode for the file.
|
|
288
|
-
*
|
|
289
|
-
*/
|
|
290
|
-
get importer() {
|
|
291
|
-
return $.utils.getText(3, this);
|
|
292
|
-
}
|
|
293
|
-
set importer(value) {
|
|
294
|
-
$.utils.setText(3, value, this);
|
|
295
|
-
}
|
|
296
|
-
get preserveSignature() {
|
|
297
|
-
return $.utils.getUint16(0, this);
|
|
298
|
-
}
|
|
299
|
-
set preserveSignature(value) {
|
|
300
|
-
$.utils.setUint16(0, value, this);
|
|
301
|
-
}
|
|
302
|
-
toString() {
|
|
303
|
-
return "ChunkData_" + super.toString();
|
|
304
|
-
}
|
|
305
|
-
};
|
|
306
|
-
var PrebuiltData = class extends $.Struct {
|
|
307
|
-
static {
|
|
308
|
-
__name(this, "PrebuiltData");
|
|
309
|
-
}
|
|
310
|
-
static _capnp = {
|
|
311
|
-
displayName: "PrebuiltData",
|
|
312
|
-
id: "c5b1a6ca696328ee",
|
|
313
|
-
size: new $.ObjectSize(0, 4)
|
|
314
|
-
};
|
|
315
|
-
/**
|
|
316
|
-
* An additional name for the file.
|
|
317
|
-
*
|
|
318
|
-
*/
|
|
319
|
-
get id() {
|
|
320
|
-
return $.utils.getText(0, this);
|
|
321
|
-
}
|
|
322
|
-
set id(value) {
|
|
323
|
-
$.utils.setText(0, value, this);
|
|
324
|
-
}
|
|
325
|
-
/**
|
|
326
|
-
* The file exports.
|
|
327
|
-
*
|
|
328
|
-
*/
|
|
329
|
-
get name() {
|
|
330
|
-
return $.utils.getText(1, this);
|
|
331
|
-
}
|
|
332
|
-
set name(value) {
|
|
333
|
-
$.utils.setText(1, value, this);
|
|
334
|
-
}
|
|
335
|
-
_adoptExports(value) {
|
|
336
|
-
$.utils.adopt(value, $.utils.getPointer(2, this));
|
|
337
|
-
}
|
|
338
|
-
_disownExports() {
|
|
339
|
-
return $.utils.disown(this.exports);
|
|
340
|
-
}
|
|
341
|
-
/**
|
|
342
|
-
* The source map for the file.
|
|
343
|
-
*
|
|
344
|
-
*/
|
|
345
|
-
get exports() {
|
|
346
|
-
return $.utils.getList(2, $.TextList, this);
|
|
347
|
-
}
|
|
348
|
-
_hasExports() {
|
|
349
|
-
return !$.utils.isNull($.utils.getPointer(2, this));
|
|
350
|
-
}
|
|
351
|
-
_initExports(length) {
|
|
352
|
-
return $.utils.initList(2, $.TextList, length, this);
|
|
353
|
-
}
|
|
354
|
-
set exports(value) {
|
|
355
|
-
$.utils.copyFrom(value, $.utils.getPointer(2, this));
|
|
356
|
-
}
|
|
357
|
-
get map() {
|
|
358
|
-
return $.utils.getText(3, this);
|
|
359
|
-
}
|
|
360
|
-
set map(value) {
|
|
361
|
-
$.utils.setText(3, value, this);
|
|
362
|
-
}
|
|
363
|
-
toString() {
|
|
364
|
-
return "PrebuiltData_" + super.toString();
|
|
365
|
-
}
|
|
366
|
-
};
|
|
367
|
-
var AssetData = class extends $.Struct {
|
|
368
|
-
static {
|
|
369
|
-
__name(this, "AssetData");
|
|
370
|
-
}
|
|
371
|
-
static _capnp = {
|
|
372
|
-
displayName: "AssetData",
|
|
373
|
-
id: "da660c6c1fa4c830",
|
|
374
|
-
size: new $.ObjectSize(8, 3)
|
|
375
|
-
};
|
|
376
|
-
/**
|
|
377
|
-
* An additional name for the file.
|
|
378
|
-
*
|
|
379
|
-
*/
|
|
380
|
-
get id() {
|
|
381
|
-
return $.utils.getText(0, this);
|
|
382
|
-
}
|
|
383
|
-
set id(value) {
|
|
384
|
-
$.utils.setText(0, value, this);
|
|
385
|
-
}
|
|
386
|
-
/**
|
|
387
|
-
* Indicates whether the file needs a code reference.
|
|
388
|
-
*
|
|
389
|
-
*/
|
|
390
|
-
get name() {
|
|
391
|
-
return $.utils.getText(1, this);
|
|
392
|
-
}
|
|
393
|
-
set name(value) {
|
|
394
|
-
$.utils.setText(1, value, this);
|
|
395
|
-
}
|
|
396
|
-
/**
|
|
397
|
-
* The original file name before any transformations.
|
|
398
|
-
*
|
|
399
|
-
*/
|
|
400
|
-
get needsCodeReference() {
|
|
401
|
-
return $.utils.getBit(0, this);
|
|
402
|
-
}
|
|
403
|
-
set needsCodeReference(value) {
|
|
404
|
-
$.utils.setBit(0, value, this);
|
|
405
|
-
}
|
|
406
|
-
get originalFileName() {
|
|
407
|
-
return $.utils.getText(2, this);
|
|
408
|
-
}
|
|
409
|
-
set originalFileName(value) {
|
|
410
|
-
$.utils.setText(2, value, this);
|
|
411
|
-
}
|
|
412
|
-
toString() {
|
|
413
|
-
return "AssetData_" + super.toString();
|
|
414
|
-
}
|
|
415
|
-
};
|
|
416
239
|
var FileId = class extends $.Struct {
|
|
417
240
|
static {
|
|
418
241
|
__name(this, "FileId");
|
|
@@ -478,14 +301,11 @@ var FileSystem = class _FileSystem extends $.Struct {
|
|
|
478
301
|
static _capnp = {
|
|
479
302
|
displayName: "FileSystem",
|
|
480
303
|
id: "ae0c23d43e56abcf",
|
|
481
|
-
size: new $.ObjectSize(0,
|
|
304
|
+
size: new $.ObjectSize(0, 3)
|
|
482
305
|
};
|
|
483
306
|
static _Ids;
|
|
484
307
|
static _Files;
|
|
485
308
|
static _Metadata;
|
|
486
|
-
static _Assets;
|
|
487
|
-
static _Chunks;
|
|
488
|
-
static _Prebuilt;
|
|
489
309
|
_adoptIds(value) {
|
|
490
310
|
$.utils.adopt(value, $.utils.getPointer(0, this));
|
|
491
311
|
}
|
|
@@ -540,60 +360,6 @@ var FileSystem = class _FileSystem extends $.Struct {
|
|
|
540
360
|
set metadata(value) {
|
|
541
361
|
$.utils.copyFrom(value, $.utils.getPointer(2, this));
|
|
542
362
|
}
|
|
543
|
-
_adoptAssets(value) {
|
|
544
|
-
$.utils.adopt(value, $.utils.getPointer(3, this));
|
|
545
|
-
}
|
|
546
|
-
_disownAssets() {
|
|
547
|
-
return $.utils.disown(this.assets);
|
|
548
|
-
}
|
|
549
|
-
get assets() {
|
|
550
|
-
return $.utils.getList(3, _FileSystem._Assets, this);
|
|
551
|
-
}
|
|
552
|
-
_hasAssets() {
|
|
553
|
-
return !$.utils.isNull($.utils.getPointer(3, this));
|
|
554
|
-
}
|
|
555
|
-
_initAssets(length) {
|
|
556
|
-
return $.utils.initList(3, _FileSystem._Assets, length, this);
|
|
557
|
-
}
|
|
558
|
-
set assets(value) {
|
|
559
|
-
$.utils.copyFrom(value, $.utils.getPointer(3, this));
|
|
560
|
-
}
|
|
561
|
-
_adoptChunks(value) {
|
|
562
|
-
$.utils.adopt(value, $.utils.getPointer(4, this));
|
|
563
|
-
}
|
|
564
|
-
_disownChunks() {
|
|
565
|
-
return $.utils.disown(this.chunks);
|
|
566
|
-
}
|
|
567
|
-
get chunks() {
|
|
568
|
-
return $.utils.getList(4, _FileSystem._Chunks, this);
|
|
569
|
-
}
|
|
570
|
-
_hasChunks() {
|
|
571
|
-
return !$.utils.isNull($.utils.getPointer(4, this));
|
|
572
|
-
}
|
|
573
|
-
_initChunks(length) {
|
|
574
|
-
return $.utils.initList(4, _FileSystem._Chunks, length, this);
|
|
575
|
-
}
|
|
576
|
-
set chunks(value) {
|
|
577
|
-
$.utils.copyFrom(value, $.utils.getPointer(4, this));
|
|
578
|
-
}
|
|
579
|
-
_adoptPrebuilt(value) {
|
|
580
|
-
$.utils.adopt(value, $.utils.getPointer(5, this));
|
|
581
|
-
}
|
|
582
|
-
_disownPrebuilt() {
|
|
583
|
-
return $.utils.disown(this.prebuilt);
|
|
584
|
-
}
|
|
585
|
-
get prebuilt() {
|
|
586
|
-
return $.utils.getList(5, _FileSystem._Prebuilt, this);
|
|
587
|
-
}
|
|
588
|
-
_hasPrebuilt() {
|
|
589
|
-
return !$.utils.isNull($.utils.getPointer(5, this));
|
|
590
|
-
}
|
|
591
|
-
_initPrebuilt(length) {
|
|
592
|
-
return $.utils.initList(5, _FileSystem._Prebuilt, length, this);
|
|
593
|
-
}
|
|
594
|
-
set prebuilt(value) {
|
|
595
|
-
$.utils.copyFrom(value, $.utils.getPointer(5, this));
|
|
596
|
-
}
|
|
597
363
|
toString() {
|
|
598
364
|
return "FileSystem_" + super.toString();
|
|
599
365
|
}
|
|
@@ -602,9 +368,6 @@ FileMetadata._Properties = $.CompositeList(FileMetadata_KeyValuePair);
|
|
|
602
368
|
FileSystem._Ids = $.CompositeList(FileId);
|
|
603
369
|
FileSystem._Files = $.CompositeList(FileData);
|
|
604
370
|
FileSystem._Metadata = $.CompositeList(FileMetadata);
|
|
605
|
-
FileSystem._Assets = $.CompositeList(AssetData);
|
|
606
|
-
FileSystem._Chunks = $.CompositeList(ChunkData);
|
|
607
|
-
FileSystem._Prebuilt = $.CompositeList(PrebuiltData);
|
|
608
371
|
|
|
609
372
|
// src/types/fs.ts
|
|
610
373
|
var __VFS_PATCH__ = "__VFS_PATCH__";
|
|
@@ -614,13 +377,9 @@ function isBufferEncoding(options) {
|
|
|
614
377
|
}
|
|
615
378
|
__name(isBufferEncoding, "isBufferEncoding");
|
|
616
379
|
function isPowerlinesWriteFileOptions(options) {
|
|
617
|
-
return !isBufferEncoding(options) && isSetObject(options) &&
|
|
380
|
+
return !isBufferEncoding(options) && isSetObject(options) && "mode" in options && (options.mode === "fs" || options.mode === "virtual");
|
|
618
381
|
}
|
|
619
382
|
__name(isPowerlinesWriteFileOptions, "isPowerlinesWriteFileOptions");
|
|
620
|
-
function isNodeWriteFileOptions(options) {
|
|
621
|
-
return !isUndefined(options) && (isBufferEncoding(options) || !isPowerlinesWriteFileOptions(options));
|
|
622
|
-
}
|
|
623
|
-
__name(isNodeWriteFileOptions, "isNodeWriteFileOptions");
|
|
624
383
|
function isVirtualFileData(obj) {
|
|
625
384
|
return !!(isSetObject(obj) && "code" in obj && obj.code);
|
|
626
385
|
}
|
|
@@ -757,6 +516,18 @@ function patchFS(originalFS, vfs) {
|
|
|
757
516
|
};
|
|
758
517
|
}
|
|
759
518
|
__name(patchFS, "patchFS");
|
|
519
|
+
function isValidId(id, prefix = "powerlines") {
|
|
520
|
+
return id.replace(/^\\0/, "").startsWith(`${prefix.replace(/:$/, "")}`);
|
|
521
|
+
}
|
|
522
|
+
__name(isValidId, "isValidId");
|
|
523
|
+
function normalizeId(id, prefix = "powerlines") {
|
|
524
|
+
return `${prefix.replace(/:$/, "")}:${toFilePath(id).replace(new RegExp(`^${prefix.replace(/:$/, "")}:`), "").replace(/^\\0/, "").replace(findFileDotExtensionSafe(toFilePath(id)), "")}`;
|
|
525
|
+
}
|
|
526
|
+
__name(normalizeId, "normalizeId");
|
|
527
|
+
function normalizePath(path, builtinsPath, prefix = "powerlines") {
|
|
528
|
+
return isValidId(toFilePath(path), prefix) ? normalizeId(toFilePath(path), prefix).replace(new RegExp(`^${prefix.replace(/:$/, "")}:`), builtinsPath) : toFilePath(path);
|
|
529
|
+
}
|
|
530
|
+
__name(normalizePath, "normalizePath");
|
|
760
531
|
var UnifiedFS = class _UnifiedFS extends Union {
|
|
761
532
|
static {
|
|
762
533
|
__name(this, "UnifiedFS");
|
|
@@ -933,9 +704,9 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
933
704
|
*/
|
|
934
705
|
#paths;
|
|
935
706
|
/**
|
|
936
|
-
* A
|
|
707
|
+
* A cache for module resolution results.
|
|
937
708
|
*/
|
|
938
|
-
#
|
|
709
|
+
#resolverCache;
|
|
939
710
|
/**
|
|
940
711
|
* The unified volume that combines the virtual file system with the real file system.
|
|
941
712
|
*
|
|
@@ -970,189 +741,35 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
970
741
|
* @returns `true` if the path exists, otherwise `false`.
|
|
971
742
|
*/
|
|
972
743
|
#existsSync(path) {
|
|
973
|
-
|
|
974
|
-
return this.#unifiedFS.virtual.existsSync(formattedPath) || this.#unifiedFS.physical.existsSync(formattedPath) || this.#unifiedFS.resolveFS(path).existsSync(formattedPath);
|
|
975
|
-
}
|
|
976
|
-
/**
|
|
977
|
-
* Builds a regular expression from a string pattern for path matching.
|
|
978
|
-
*
|
|
979
|
-
* @param strPattern - The string pattern to convert.
|
|
980
|
-
* @returns A regular expression for matching paths.
|
|
981
|
-
*/
|
|
982
|
-
#buildRegex(strPattern) {
|
|
983
|
-
const token = "::GLOBSTAR::";
|
|
984
|
-
return new RegExp(`^${this.formatPath(strPattern).replace(/\*\*/g, token).replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]").replace(new RegExp(token, "g"), ".*")}$`);
|
|
985
|
-
}
|
|
986
|
-
/**
|
|
987
|
-
* Formats a file id by removing the file extension and prepending the runtime prefix.
|
|
988
|
-
*
|
|
989
|
-
* @param id - The file ID to format.
|
|
990
|
-
* @returns The formatted file ID.
|
|
991
|
-
*/
|
|
992
|
-
#formatId(id) {
|
|
993
|
-
const formattedId = toFilePath(id);
|
|
994
|
-
return `${this.#context.config.output.builtinPrefix}:${formattedId.replace(new RegExp(`^${this.#context.config.output.builtinPrefix}:`), "").replace(/^\\0/, "").replace(findFileDotExtensionSafe(formattedId), "")}`;
|
|
995
|
-
}
|
|
996
|
-
/**
|
|
997
|
-
* Resolves an id parameter to a corresponding virtual file path in the virtual file system (VFS).
|
|
998
|
-
*
|
|
999
|
-
* @param id - The id to resolve.
|
|
1000
|
-
* @returns The resolved file id if it exists, otherwise undefined.
|
|
1001
|
-
*/
|
|
1002
|
-
#resolveId(id) {
|
|
1003
|
-
if (this.#ids[this.#formatId(id)]) {
|
|
1004
|
-
return this.#ids[this.#formatId(id)] || false;
|
|
1005
|
-
}
|
|
1006
|
-
return false;
|
|
1007
|
-
}
|
|
1008
|
-
/**
|
|
1009
|
-
* Resolves a path parameter to a corresponding virtual file path in the virtual file system (VFS).
|
|
1010
|
-
*
|
|
1011
|
-
* @param path - The path to resolve.
|
|
1012
|
-
* @param options - Optional parameters for resolving the path.
|
|
1013
|
-
* @returns The resolved file path if it exists, otherwise undefined.
|
|
1014
|
-
*/
|
|
1015
|
-
#resolvePath(path, options = {}) {
|
|
1016
|
-
if (isAbsolutePath(path)) {
|
|
1017
|
-
if (this.#existsSync(path)) {
|
|
1018
|
-
return path;
|
|
1019
|
-
}
|
|
1020
|
-
const result = this.#checkVariants(path);
|
|
1021
|
-
if (result) {
|
|
1022
|
-
return result;
|
|
1023
|
-
}
|
|
1024
|
-
}
|
|
1025
|
-
for (const parentPath of this.#resolveParentPaths(path, options.paths)) {
|
|
1026
|
-
const request = joinPaths$1(parentPath, path);
|
|
1027
|
-
if (this.#existsSync(request)) {
|
|
1028
|
-
return request;
|
|
1029
|
-
}
|
|
1030
|
-
const result = this.#checkVariants(request);
|
|
1031
|
-
if (result) {
|
|
1032
|
-
return result;
|
|
1033
|
-
}
|
|
1034
|
-
}
|
|
1035
|
-
return false;
|
|
1036
|
-
}
|
|
1037
|
-
/**
|
|
1038
|
-
* Resolves parent paths for a given request.
|
|
1039
|
-
*
|
|
1040
|
-
* @param request - The request path to resolve parent paths for.
|
|
1041
|
-
* @param parents - An optional array of parent paths to consider.
|
|
1042
|
-
* @returns An array of resolved parent paths.
|
|
1043
|
-
*/
|
|
1044
|
-
#resolveParentPaths(request, parents = []) {
|
|
1045
|
-
let paths = [
|
|
1046
|
-
this.#context.workspaceConfig.workspaceRoot,
|
|
1047
|
-
joinPaths$1(this.#context.workspaceConfig.workspaceRoot, this.#context.config.projectRoot)
|
|
1048
|
-
];
|
|
1049
|
-
if (this.#context.tsconfig.options.paths) {
|
|
1050
|
-
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) => {
|
|
1051
|
-
if (path && !ret.includes(joinPaths$1(this.#context.workspaceConfig.workspaceRoot, path))) {
|
|
1052
|
-
ret.push(joinPaths$1(this.#context.workspaceConfig.workspaceRoot, path));
|
|
1053
|
-
}
|
|
1054
|
-
return ret;
|
|
1055
|
-
}, paths) : paths;
|
|
1056
|
-
}
|
|
1057
|
-
return paths.reduce((ret, path) => {
|
|
1058
|
-
if (!ret.includes(path)) {
|
|
1059
|
-
ret.push(path);
|
|
1060
|
-
}
|
|
1061
|
-
return ret;
|
|
1062
|
-
}, parents.filter(Boolean).map((p) => this.formatPath(p)));
|
|
1063
|
-
}
|
|
1064
|
-
/**
|
|
1065
|
-
* Clears the resolver cache for a given path.
|
|
1066
|
-
*
|
|
1067
|
-
* @param path - The path to clear the resolver cache for.
|
|
1068
|
-
*/
|
|
1069
|
-
#clearResolverCache(path) {
|
|
1070
|
-
this.#cachedResolver.keys().filter((key) => key.startsWith(toFilePath(path))).forEach((key) => this.#cachedResolver.delete(key));
|
|
744
|
+
return this.#unifiedFS.virtual.existsSync(this.#normalizePath(path)) || this.#unifiedFS.physical.existsSync(this.#normalizePath(path)) || this.#unifiedFS.resolveFS(path).existsSync(this.#normalizePath(path));
|
|
1071
745
|
}
|
|
1072
746
|
/**
|
|
1073
|
-
*
|
|
747
|
+
* Normalizes a given module id by resolving it against the built-ins path.
|
|
1074
748
|
*
|
|
1075
|
-
* @param
|
|
1076
|
-
* @
|
|
1077
|
-
* @returns The file path if it exists, otherwise false.
|
|
749
|
+
* @param id - The module id to normalize.
|
|
750
|
+
* @returns The normalized module id.
|
|
1078
751
|
*/
|
|
1079
|
-
#
|
|
1080
|
-
|
|
1081
|
-
let file = this.#checkExtensions(path);
|
|
1082
|
-
if (file) {
|
|
1083
|
-
return file;
|
|
1084
|
-
}
|
|
1085
|
-
file = this.#checkIndex(path);
|
|
1086
|
-
if (file) {
|
|
1087
|
-
return file;
|
|
1088
|
-
}
|
|
1089
|
-
return false;
|
|
752
|
+
#normalizeId(id) {
|
|
753
|
+
return normalizeId(id, this.#context.config.output.builtinPrefix);
|
|
1090
754
|
}
|
|
1091
755
|
/**
|
|
1092
|
-
*
|
|
756
|
+
* Normalizes a given path by resolving it against the project root, workspace root, and built-ins path.
|
|
1093
757
|
*
|
|
1094
|
-
* @param
|
|
1095
|
-
* @returns The
|
|
758
|
+
* @param path - The path to normalize.
|
|
759
|
+
* @returns The normalized path.
|
|
1096
760
|
*/
|
|
1097
|
-
#
|
|
1098
|
-
|
|
1099
|
-
if (this.#existsSync(file)) {
|
|
1100
|
-
return file;
|
|
1101
|
-
}
|
|
1102
|
-
file = this.#checkExtensions(file);
|
|
1103
|
-
if (file) {
|
|
1104
|
-
return file;
|
|
1105
|
-
}
|
|
1106
|
-
return false;
|
|
761
|
+
#normalizePath(path) {
|
|
762
|
+
return normalizePath(path, this.#context.builtinsPath, this.#context.config.output.builtinPrefix);
|
|
1107
763
|
}
|
|
1108
764
|
/**
|
|
1109
|
-
*
|
|
765
|
+
* Builds a regular expression from a string pattern for path matching.
|
|
1110
766
|
*
|
|
1111
|
-
* @param
|
|
1112
|
-
* @returns
|
|
767
|
+
* @param path - The string pattern to convert.
|
|
768
|
+
* @returns A regular expression for matching paths.
|
|
1113
769
|
*/
|
|
1114
|
-
#
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
return file;
|
|
1118
|
-
}
|
|
1119
|
-
file = `${request}.mts`;
|
|
1120
|
-
if (this.#existsSync(file)) {
|
|
1121
|
-
return file;
|
|
1122
|
-
}
|
|
1123
|
-
file = `${request}.cts`;
|
|
1124
|
-
if (this.#existsSync(file)) {
|
|
1125
|
-
return file;
|
|
1126
|
-
}
|
|
1127
|
-
file = `${request}.tsx`;
|
|
1128
|
-
if (this.#existsSync(file)) {
|
|
1129
|
-
return file;
|
|
1130
|
-
}
|
|
1131
|
-
file = `${request}.js`;
|
|
1132
|
-
if (this.#existsSync(file)) {
|
|
1133
|
-
return file;
|
|
1134
|
-
}
|
|
1135
|
-
file = `${request}.mjs`;
|
|
1136
|
-
if (this.#existsSync(file)) {
|
|
1137
|
-
return file;
|
|
1138
|
-
}
|
|
1139
|
-
file = `${request}.cjs`;
|
|
1140
|
-
if (this.#existsSync(file)) {
|
|
1141
|
-
return file;
|
|
1142
|
-
}
|
|
1143
|
-
file = `${request}.jsx`;
|
|
1144
|
-
if (this.#existsSync(file)) {
|
|
1145
|
-
return file;
|
|
1146
|
-
}
|
|
1147
|
-
file = `${request}.json`;
|
|
1148
|
-
if (this.#existsSync(file)) {
|
|
1149
|
-
return file;
|
|
1150
|
-
}
|
|
1151
|
-
file = `${request}.d.ts`;
|
|
1152
|
-
if (this.#existsSync(file)) {
|
|
1153
|
-
return file;
|
|
1154
|
-
}
|
|
1155
|
-
return false;
|
|
770
|
+
#buildRegex(path) {
|
|
771
|
+
const token = "::GLOBSTAR::";
|
|
772
|
+
return new RegExp(`^${this.#normalizePath(path).replace(/\*\*/g, token).replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]").replace(new RegExp(token, "g"), ".*")}$`);
|
|
1156
773
|
}
|
|
1157
774
|
/**
|
|
1158
775
|
* Creates a virtual file system (VFS) that is backed up to a Cap'n Proto message buffer.
|
|
@@ -1161,8 +778,8 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1161
778
|
* @returns A promise that resolves to a new virtual file system instance.
|
|
1162
779
|
*/
|
|
1163
780
|
static async create(context) {
|
|
1164
|
-
if (!context.config.skipCache && existsSync(joinPaths$1(context.
|
|
1165
|
-
const buffer = await readFileBuffer(joinPaths$1(context.
|
|
781
|
+
if (!context.config.skipCache && existsSync(joinPaths$1(context.dataPath, "fs.bin"))) {
|
|
782
|
+
const buffer = await readFileBuffer(joinPaths$1(context.dataPath, "fs.bin"));
|
|
1166
783
|
const message2 = new $.Message(buffer, false);
|
|
1167
784
|
return new _VirtualFileSystem(context, message2.getRoot(FileSystem));
|
|
1168
785
|
}
|
|
@@ -1176,8 +793,8 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1176
793
|
* @returns A new virtual file system instance.
|
|
1177
794
|
*/
|
|
1178
795
|
static createSync(context) {
|
|
1179
|
-
if (!context.config.skipCache && existsSync(joinPaths$1(context.
|
|
1180
|
-
const buffer = readFileBufferSync(joinPaths$1(context.
|
|
796
|
+
if (!context.config.skipCache && existsSync(joinPaths$1(context.dataPath, "fs.bin"))) {
|
|
797
|
+
const buffer = readFileBufferSync(joinPaths$1(context.dataPath, "fs.bin"));
|
|
1181
798
|
const message2 = new $.Message(buffer, false);
|
|
1182
799
|
return new _VirtualFileSystem(context, message2.getRoot(FileSystem));
|
|
1183
800
|
}
|
|
@@ -1188,19 +805,43 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1188
805
|
* A map of file ids to their metadata.
|
|
1189
806
|
*/
|
|
1190
807
|
get metadata() {
|
|
1191
|
-
return this.#metadata
|
|
808
|
+
return new Proxy(this.#metadata, {
|
|
809
|
+
get: /* @__PURE__ */ __name((target, prop) => {
|
|
810
|
+
return target[this.#normalizeId(prop)];
|
|
811
|
+
}, "get")
|
|
812
|
+
});
|
|
1192
813
|
}
|
|
1193
814
|
/**
|
|
1194
|
-
* A map of
|
|
815
|
+
* A map of file paths to their module ids.
|
|
1195
816
|
*/
|
|
1196
817
|
get ids() {
|
|
1197
|
-
return this.#
|
|
818
|
+
return new Proxy(this.#paths, {
|
|
819
|
+
get: /* @__PURE__ */ __name((target, prop) => {
|
|
820
|
+
return target[this.#normalizePath(prop)];
|
|
821
|
+
}, "get")
|
|
822
|
+
});
|
|
1198
823
|
}
|
|
1199
824
|
/**
|
|
1200
|
-
* A map of
|
|
825
|
+
* A map of module ids to their file paths.
|
|
1201
826
|
*/
|
|
1202
827
|
get paths() {
|
|
1203
|
-
return this.#paths
|
|
828
|
+
return new Proxy(this.#paths, {
|
|
829
|
+
get: /* @__PURE__ */ __name((target, prop) => {
|
|
830
|
+
return target[this.#normalizeId(prop)];
|
|
831
|
+
}, "get")
|
|
832
|
+
});
|
|
833
|
+
}
|
|
834
|
+
get resolverCache() {
|
|
835
|
+
if (!this.#resolverCache) {
|
|
836
|
+
this.#resolverCache = create({
|
|
837
|
+
cacheId: "module-resolution",
|
|
838
|
+
cacheDir: this.#context.cachePath,
|
|
839
|
+
ttl: 60 * 60 * 1e3,
|
|
840
|
+
lruSize: 5e3,
|
|
841
|
+
persistInterval: 100
|
|
842
|
+
});
|
|
843
|
+
}
|
|
844
|
+
return this.#resolverCache;
|
|
1204
845
|
}
|
|
1205
846
|
/**
|
|
1206
847
|
* Creates a new instance of the {@link VirtualFileSystem}.
|
|
@@ -1245,17 +886,13 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1245
886
|
* Check if a path or id corresponds to a virtual file **(does not actually exists on disk)**.
|
|
1246
887
|
*
|
|
1247
888
|
* @param pathOrId - The path or id to check.
|
|
1248
|
-
* @param options - Optional parameters for resolving the path.
|
|
1249
889
|
* @returns Whether the path or id corresponds to a virtual file **(does not actually exists on disk)**.
|
|
1250
890
|
*/
|
|
1251
|
-
isVirtual(pathOrId, options = {}) {
|
|
891
|
+
isVirtual(pathOrId, importer, options = {}) {
|
|
1252
892
|
if (!pathOrId) {
|
|
1253
893
|
return false;
|
|
1254
894
|
}
|
|
1255
|
-
const resolvedPath = this.
|
|
1256
|
-
...options,
|
|
1257
|
-
pathType: "file"
|
|
1258
|
-
});
|
|
895
|
+
const resolvedPath = this.resolveSync(pathOrId, importer, options);
|
|
1259
896
|
if (!resolvedPath) {
|
|
1260
897
|
return false;
|
|
1261
898
|
}
|
|
@@ -1265,17 +902,13 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1265
902
|
* Check if a path or id corresponds to a file written to the file system **(actually exists on disk)**.
|
|
1266
903
|
*
|
|
1267
904
|
* @param pathOrId - The path or id to check.
|
|
1268
|
-
* @param options - Optional parameters for resolving the path.
|
|
1269
905
|
* @returns Whether the path or id corresponds to a file written to the file system **(actually exists on disk)**.
|
|
1270
906
|
*/
|
|
1271
|
-
isPhysical(pathOrId, options = {}) {
|
|
907
|
+
isPhysical(pathOrId, importer, options = {}) {
|
|
1272
908
|
if (!pathOrId) {
|
|
1273
909
|
return false;
|
|
1274
910
|
}
|
|
1275
|
-
const resolvedPath = this.
|
|
1276
|
-
...options,
|
|
1277
|
-
pathType: "file"
|
|
1278
|
-
});
|
|
911
|
+
const resolvedPath = this.resolveSync(pathOrId, importer, options);
|
|
1279
912
|
if (!resolvedPath) {
|
|
1280
913
|
return false;
|
|
1281
914
|
}
|
|
@@ -1297,16 +930,17 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1297
930
|
* @param path - The path to create the directory at.
|
|
1298
931
|
*/
|
|
1299
932
|
unlinkSync(path, options) {
|
|
1300
|
-
|
|
1301
|
-
if (!this.isFile(formattedPath)) {
|
|
933
|
+
if (!this.isFile(this.#normalizePath(path))) {
|
|
1302
934
|
return;
|
|
1303
935
|
}
|
|
1304
|
-
this.#log(LogLevelLabel.TRACE, `Synchronously removing file: ${
|
|
1305
|
-
this.#unifiedFS.resolveFS(path, options).unlinkSync(
|
|
1306
|
-
if (this
|
|
1307
|
-
delete this
|
|
936
|
+
this.#log(LogLevelLabel.TRACE, `Synchronously removing file: ${this.#normalizePath(path)}`);
|
|
937
|
+
this.#unifiedFS.resolveFS(path, options).unlinkSync(this.#normalizePath(path));
|
|
938
|
+
if (this.#ids[this.#normalizePath(path)] && this.#metadata[this.#ids[this.#normalizePath(path)]]) {
|
|
939
|
+
delete this.#metadata[this.#ids[this.#normalizePath(path)]];
|
|
940
|
+
delete this.#ids[this.#normalizePath(path)];
|
|
941
|
+
delete this.#paths[this.#normalizeId(path)];
|
|
942
|
+
this.#resolverCache.delete(this.#normalizePath(path));
|
|
1308
943
|
}
|
|
1309
|
-
this.#clearResolverCache(formattedPath);
|
|
1310
944
|
}
|
|
1311
945
|
/**
|
|
1312
946
|
* Removes a file in the virtual file system (VFS).
|
|
@@ -1314,19 +948,17 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1314
948
|
* @param path - The path to create the directory at.
|
|
1315
949
|
*/
|
|
1316
950
|
async unlink(path, options) {
|
|
1317
|
-
|
|
1318
|
-
if (!this.isFile(formattedPath)) {
|
|
951
|
+
if (!this.isFile(this.#normalizePath(path))) {
|
|
1319
952
|
return;
|
|
1320
953
|
}
|
|
1321
|
-
this.#log(LogLevelLabel.TRACE, `Removing file: ${
|
|
954
|
+
this.#log(LogLevelLabel.TRACE, `Removing file: ${this.#normalizePath(path)}`);
|
|
1322
955
|
if (isFunction(this.#unifiedFS.resolveFS(path, options).promises.unlink)) {
|
|
1323
|
-
await this.#unifiedFS.resolveFS(path, options).promises.unlink(
|
|
1324
|
-
if (this
|
|
1325
|
-
delete this
|
|
956
|
+
await this.#unifiedFS.resolveFS(path, options).promises.unlink(this.#normalizePath(path));
|
|
957
|
+
if (this.#ids[this.#normalizePath(path)] && this.#metadata[this.#ids[this.#normalizePath(path)]]) {
|
|
958
|
+
delete this.#metadata[this.#ids[this.#normalizePath(path)]];
|
|
1326
959
|
}
|
|
1327
|
-
this.#clearResolverCache(formattedPath);
|
|
1328
960
|
} else {
|
|
1329
|
-
this.unlinkSync(
|
|
961
|
+
this.unlinkSync(this.#normalizePath(path), options);
|
|
1330
962
|
}
|
|
1331
963
|
}
|
|
1332
964
|
/**
|
|
@@ -1336,15 +968,13 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1336
968
|
* @param options - Options for creating the directory.
|
|
1337
969
|
*/
|
|
1338
970
|
rmdirSync(path, options = {}) {
|
|
1339
|
-
|
|
1340
|
-
if (!this.isDirectory(formattedPath)) {
|
|
971
|
+
if (!this.isDirectory(this.#normalizePath(path))) {
|
|
1341
972
|
return;
|
|
1342
973
|
}
|
|
1343
|
-
this.#log(LogLevelLabel.TRACE, `Synchronously removing directory: ${
|
|
1344
|
-
this.#unifiedFS.resolveFS(path, options).rmdirSync(
|
|
974
|
+
this.#log(LogLevelLabel.TRACE, `Synchronously removing directory: ${this.#normalizePath(path)}`);
|
|
975
|
+
this.#unifiedFS.resolveFS(path, options).rmdirSync(this.#normalizePath(path), defu2(options, {
|
|
1345
976
|
recursive: true
|
|
1346
977
|
}));
|
|
1347
|
-
this.#clearResolverCache(formattedPath);
|
|
1348
978
|
}
|
|
1349
979
|
/**
|
|
1350
980
|
* Removes a directory in the virtual file system (VFS).
|
|
@@ -1354,19 +984,17 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1354
984
|
* @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
|
|
1355
985
|
*/
|
|
1356
986
|
async rmdir(path, options = {}) {
|
|
1357
|
-
|
|
1358
|
-
if (!this.isDirectory(formattedPath)) {
|
|
987
|
+
if (!this.isDirectory(this.#normalizePath(path))) {
|
|
1359
988
|
return;
|
|
1360
989
|
}
|
|
1361
|
-
this.#log(LogLevelLabel.TRACE, `Removing directory: ${
|
|
990
|
+
this.#log(LogLevelLabel.TRACE, `Removing directory: ${this.#normalizePath(path)}`);
|
|
1362
991
|
if (isFunction(this.#unifiedFS.resolveFS(path, options).promises.rm)) {
|
|
1363
|
-
await this.#unifiedFS.resolveFS(path, options).promises.rm(
|
|
992
|
+
await this.#unifiedFS.resolveFS(path, options).promises.rm(this.#normalizePath(path), defu2(options, {
|
|
1364
993
|
force: true,
|
|
1365
994
|
recursive: true
|
|
1366
995
|
}));
|
|
1367
|
-
this.#clearResolverCache(formattedPath);
|
|
1368
996
|
} else {
|
|
1369
|
-
this.rmdirSync(
|
|
997
|
+
this.rmdirSync(this.#normalizePath(path), defu2(options ?? {}, {
|
|
1370
998
|
force: true,
|
|
1371
999
|
recursive: true
|
|
1372
1000
|
}));
|
|
@@ -1380,11 +1008,11 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1380
1008
|
* @returns A promise that resolves when the file is removed.
|
|
1381
1009
|
*/
|
|
1382
1010
|
async rm(path, options = {}) {
|
|
1383
|
-
this.#log(LogLevelLabel.TRACE, `Removing: ${
|
|
1384
|
-
if (this.isDirectory(path)) {
|
|
1385
|
-
return this.rmdir(path, options);
|
|
1011
|
+
this.#log(LogLevelLabel.TRACE, `Removing: ${this.#normalizePath(path)}`);
|
|
1012
|
+
if (this.isDirectory(this.#normalizePath(path))) {
|
|
1013
|
+
return this.rmdir(this.#normalizePath(path), options);
|
|
1386
1014
|
}
|
|
1387
|
-
return this.unlink(path, options);
|
|
1015
|
+
return this.unlink(this.#normalizePath(path), options);
|
|
1388
1016
|
}
|
|
1389
1017
|
/**
|
|
1390
1018
|
* Synchronously removes a file or directory in the virtual file system (VFS).
|
|
@@ -1393,11 +1021,11 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1393
1021
|
* @param options - Options for removing the file or directory.
|
|
1394
1022
|
*/
|
|
1395
1023
|
rmSync(path, options = {}) {
|
|
1396
|
-
this.#log(LogLevelLabel.TRACE, `Removing: ${
|
|
1397
|
-
if (this.isDirectory(path)) {
|
|
1398
|
-
return this.rmdirSync(path, options);
|
|
1024
|
+
this.#log(LogLevelLabel.TRACE, `Removing: ${this.#normalizePath(path)}`);
|
|
1025
|
+
if (this.isDirectory(this.#normalizePath(path))) {
|
|
1026
|
+
return this.rmdirSync(this.#normalizePath(path), options);
|
|
1399
1027
|
}
|
|
1400
|
-
return this.unlinkSync(path, options);
|
|
1028
|
+
return this.unlinkSync(this.#normalizePath(path), options);
|
|
1401
1029
|
}
|
|
1402
1030
|
/**
|
|
1403
1031
|
* Creates a directory in the virtual file system (VFS).
|
|
@@ -1407,9 +1035,9 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1407
1035
|
* @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
|
|
1408
1036
|
*/
|
|
1409
1037
|
mkdirSync(path, options = {}) {
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1038
|
+
return this.#unifiedFS.resolveFS(this.#normalizePath(path), options).mkdirSync(this.#normalizePath(path), defu2(omit(options, [
|
|
1039
|
+
"mode"
|
|
1040
|
+
]), {
|
|
1413
1041
|
recursive: true
|
|
1414
1042
|
}));
|
|
1415
1043
|
}
|
|
@@ -1422,17 +1050,19 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1422
1050
|
*/
|
|
1423
1051
|
async mkdir(path, options = {}) {
|
|
1424
1052
|
let result;
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1053
|
+
if (isFunction(this.#unifiedFS.resolveFS(this.#normalizePath(path), options).promises.mkdir)) {
|
|
1054
|
+
result = await this.#unifiedFS.resolveFS(this.#normalizePath(path), options).promises.mkdir(this.#normalizePath(path), defu2(omit(options, [
|
|
1055
|
+
"mode"
|
|
1056
|
+
]), {
|
|
1428
1057
|
recursive: true
|
|
1429
1058
|
}));
|
|
1430
1059
|
} else {
|
|
1431
|
-
result = this.#unifiedFS.resolveFS(
|
|
1060
|
+
result = this.#unifiedFS.resolveFS(this.#normalizePath(path), options).mkdirSync(this.#normalizePath(path), defu2(omit(options, [
|
|
1061
|
+
"mode"
|
|
1062
|
+
]), {
|
|
1432
1063
|
recursive: true
|
|
1433
1064
|
}));
|
|
1434
1065
|
}
|
|
1435
|
-
this.#clearResolverCache(filePath);
|
|
1436
1066
|
return result;
|
|
1437
1067
|
}
|
|
1438
1068
|
/**
|
|
@@ -1444,17 +1074,15 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1444
1074
|
async glob(patterns) {
|
|
1445
1075
|
const results = [];
|
|
1446
1076
|
for (const pattern of toArray(patterns)) {
|
|
1447
|
-
const normalized = this
|
|
1077
|
+
const normalized = this.#normalizePath(pattern);
|
|
1448
1078
|
if (!/[*?[\]{}]/.test(normalized) && !normalized.includes("**")) {
|
|
1449
|
-
const resolved = this.
|
|
1450
|
-
pathType: "file"
|
|
1451
|
-
});
|
|
1079
|
+
const resolved = this.resolveSync(normalized);
|
|
1452
1080
|
if (resolved && !results.includes(resolved)) {
|
|
1453
1081
|
results.push(resolved);
|
|
1454
1082
|
}
|
|
1455
1083
|
continue;
|
|
1456
1084
|
}
|
|
1457
|
-
const absPattern = isAbsolutePath(normalized) ? normalized : this
|
|
1085
|
+
const absPattern = isAbsolutePath(normalized) ? normalized : this.#normalizePath(joinPaths$1(this.#context.workspaceConfig.workspaceRoot, normalized));
|
|
1458
1086
|
const firstGlobIdx = absPattern.search(/[*?[\]{}]/);
|
|
1459
1087
|
const baseDir = firstGlobIdx === -1 ? findFilePath(absPattern) : absPattern.slice(0, Math.max(0, absPattern.lastIndexOf("/", firstGlobIdx)));
|
|
1460
1088
|
const stack = [
|
|
@@ -1469,7 +1097,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1469
1097
|
continue;
|
|
1470
1098
|
}
|
|
1471
1099
|
for (const entry of entries) {
|
|
1472
|
-
const full = this
|
|
1100
|
+
const full = this.#normalizePath(joinPaths$1(dir, entry));
|
|
1473
1101
|
let stats;
|
|
1474
1102
|
try {
|
|
1475
1103
|
stats = this.#unifiedFS.lstatSync(full);
|
|
@@ -1481,9 +1109,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1481
1109
|
stack.push(full);
|
|
1482
1110
|
} else if (stats.isFile()) {
|
|
1483
1111
|
if (this.#buildRegex(absPattern).test(full)) {
|
|
1484
|
-
const resolved = this.
|
|
1485
|
-
pathType: "file"
|
|
1486
|
-
});
|
|
1112
|
+
const resolved = this.resolveSync(full);
|
|
1487
1113
|
if (resolved && !results.includes(resolved)) {
|
|
1488
1114
|
results.push(resolved);
|
|
1489
1115
|
}
|
|
@@ -1503,17 +1129,15 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1503
1129
|
globSync(patterns) {
|
|
1504
1130
|
const results = [];
|
|
1505
1131
|
for (const pattern of toArray(patterns)) {
|
|
1506
|
-
const normalized = this
|
|
1132
|
+
const normalized = this.#normalizePath(pattern);
|
|
1507
1133
|
if (!/[*?[\]{}]/.test(normalized) && !normalized.includes("**")) {
|
|
1508
|
-
const resolved = this.
|
|
1509
|
-
pathType: "file"
|
|
1510
|
-
});
|
|
1134
|
+
const resolved = this.resolveSync(normalized);
|
|
1511
1135
|
if (resolved && !results.includes(resolved)) {
|
|
1512
1136
|
results.push(resolved);
|
|
1513
1137
|
}
|
|
1514
1138
|
continue;
|
|
1515
1139
|
}
|
|
1516
|
-
const absPattern = isAbsolutePath(normalized) ? normalized : this
|
|
1140
|
+
const absPattern = isAbsolutePath(normalized) ? normalized : this.#normalizePath(joinPaths$1(this.#context.workspaceConfig.workspaceRoot, normalized));
|
|
1517
1141
|
const firstGlobIdx = absPattern.search(/[*?[\]{}]/);
|
|
1518
1142
|
const baseDir = firstGlobIdx === -1 ? findFilePath(absPattern) : absPattern.slice(0, Math.max(0, absPattern.lastIndexOf("/", firstGlobIdx)));
|
|
1519
1143
|
const stack = [
|
|
@@ -1528,7 +1152,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1528
1152
|
continue;
|
|
1529
1153
|
}
|
|
1530
1154
|
for (const entry of entries) {
|
|
1531
|
-
const full = this
|
|
1155
|
+
const full = this.#normalizePath(joinPaths$1(dir, entry));
|
|
1532
1156
|
let stats;
|
|
1533
1157
|
try {
|
|
1534
1158
|
stats = this.#unifiedFS.lstatSync(full);
|
|
@@ -1540,9 +1164,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1540
1164
|
stack.push(full);
|
|
1541
1165
|
} else if (stats.isFile()) {
|
|
1542
1166
|
if (this.#buildRegex(absPattern).test(full)) {
|
|
1543
|
-
const resolved = this.
|
|
1544
|
-
pathType: "file"
|
|
1545
|
-
});
|
|
1167
|
+
const resolved = this.resolveSync(full);
|
|
1546
1168
|
if (resolved && !results.includes(resolved)) {
|
|
1547
1169
|
results.push(resolved);
|
|
1548
1170
|
}
|
|
@@ -1612,21 +1234,15 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1612
1234
|
* @returns A promise that resolves to the contents of the file as a string, or undefined if the file does not exist.
|
|
1613
1235
|
*/
|
|
1614
1236
|
async readFile(pathOrId, options = "utf8") {
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
}
|
|
1618
|
-
const filePath = this.resolve(toFilePath(pathOrId), {
|
|
1619
|
-
pathType: "file"
|
|
1620
|
-
});
|
|
1621
|
-
if (filePath) {
|
|
1237
|
+
const filePath = await this.resolve(pathOrId);
|
|
1238
|
+
if (filePath && this.isFile(filePath)) {
|
|
1622
1239
|
let result;
|
|
1623
1240
|
if (isFunction(this.#unifiedFS.resolveFS(filePath).promises.readFile)) {
|
|
1624
1241
|
result = (await this.#unifiedFS.resolveFS(filePath).promises.readFile(filePath, options))?.toString("utf8");
|
|
1625
1242
|
} else {
|
|
1626
1243
|
result = this.#unifiedFS.resolveFS(filePath).readFileSync(filePath, options);
|
|
1627
1244
|
}
|
|
1628
|
-
|
|
1629
|
-
return content;
|
|
1245
|
+
return isBuffer(result) ? bufferToString(result) : result;
|
|
1630
1246
|
}
|
|
1631
1247
|
return void 0;
|
|
1632
1248
|
}
|
|
@@ -1637,16 +1253,10 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1637
1253
|
* @returns The contents of the file as a string, or undefined if the file does not exist.
|
|
1638
1254
|
*/
|
|
1639
1255
|
readFileSync(pathOrId, options = "utf8") {
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
}
|
|
1643
|
-
const filePath = this.resolve(toFilePath(pathOrId), {
|
|
1644
|
-
pathType: "file"
|
|
1645
|
-
});
|
|
1646
|
-
if (filePath) {
|
|
1256
|
+
const filePath = this.resolveSync(pathOrId);
|
|
1257
|
+
if (filePath && this.isFile(filePath)) {
|
|
1647
1258
|
const result = this.#unifiedFS.resolveFS(filePath).readFileSync(filePath, options);
|
|
1648
|
-
|
|
1649
|
-
return content;
|
|
1259
|
+
return isBuffer(result) ? bufferToString(result) : result;
|
|
1650
1260
|
}
|
|
1651
1261
|
return void 0;
|
|
1652
1262
|
}
|
|
@@ -1659,34 +1269,40 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1659
1269
|
* @returns A promise that resolves when the file is written.
|
|
1660
1270
|
*/
|
|
1661
1271
|
async writeFile(path, data = "", options = "utf8") {
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
await this.mkdir(findFilePath(formattedPath), isPowerlinesWriteFileOptions(options) ? options : void 0);
|
|
1272
|
+
if (!this.isDirectory(findFilePath(this.#normalizePath(path)))) {
|
|
1273
|
+
await this.mkdir(findFilePath(this.#normalizePath(path)), isPowerlinesWriteFileOptions(options) ? options : void 0);
|
|
1665
1274
|
}
|
|
1666
|
-
|
|
1275
|
+
const metadata = isVirtualFileData(data) ? data : {};
|
|
1276
|
+
metadata.id = this.#normalizeId(path);
|
|
1277
|
+
let code = isVirtualFileData(data) ? metadata.code : data;
|
|
1667
1278
|
if ((!isPowerlinesWriteFileOptions(options) || !options.skipFormat) && isSetString(code)) {
|
|
1668
|
-
const resolvedConfig = await resolveConfig(
|
|
1279
|
+
const resolvedConfig = await resolveConfig(this.#normalizePath(path));
|
|
1669
1280
|
if (resolvedConfig) {
|
|
1670
1281
|
code = await format(code, {
|
|
1671
|
-
absolutePath:
|
|
1282
|
+
absolutePath: this.#normalizePath(path),
|
|
1672
1283
|
...resolvedConfig
|
|
1673
1284
|
});
|
|
1674
1285
|
}
|
|
1675
1286
|
}
|
|
1676
|
-
const outputMode = this.#unifiedFS.resolveMode(
|
|
1677
|
-
this.#log(LogLevelLabel.TRACE, `Writing ${
|
|
1678
|
-
this
|
|
1287
|
+
const outputMode = this.#unifiedFS.resolveMode(this.#normalizePath(path), isPowerlinesWriteFileOptions(options) ? options : void 0);
|
|
1288
|
+
this.#log(LogLevelLabel.TRACE, `Writing ${this.#normalizePath(path)} file to the ${outputMode === "fs" ? "" : "virtual "}file system (size: ${prettyBytes(new Blob(toArray(code)).size)})`);
|
|
1289
|
+
this.#metadata[metadata.id] = {
|
|
1679
1290
|
mode: outputMode,
|
|
1680
1291
|
variant: "normal",
|
|
1681
1292
|
timestamp: Date.now(),
|
|
1682
|
-
...
|
|
1293
|
+
...metadata
|
|
1683
1294
|
};
|
|
1684
|
-
this.#
|
|
1685
|
-
|
|
1295
|
+
this.#paths[metadata.id] = this.#normalizePath(path);
|
|
1296
|
+
this.#ids[this.#normalizePath(path)] = metadata.id;
|
|
1297
|
+
const ifs = this.#unifiedFS.resolveFS(this.#normalizePath(path), isPowerlinesWriteFileOptions(options) ? options : void 0);
|
|
1686
1298
|
if (isFunction(ifs.promises.writeFile)) {
|
|
1687
|
-
return ifs.promises.writeFile(
|
|
1299
|
+
return ifs.promises.writeFile(this.#normalizePath(path), code, isSetObject(options) ? omit(options, [
|
|
1300
|
+
"mode"
|
|
1301
|
+
]) : "utf8");
|
|
1688
1302
|
}
|
|
1689
|
-
return ifs.writeFileSync(
|
|
1303
|
+
return ifs.writeFileSync(this.#normalizePath(path), code, isSetObject(options) ? omit(options, [
|
|
1304
|
+
"mode"
|
|
1305
|
+
]) : "utf8");
|
|
1690
1306
|
}
|
|
1691
1307
|
/**
|
|
1692
1308
|
* Synchronously writes a file to the virtual file system (VFS).
|
|
@@ -1696,21 +1312,23 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1696
1312
|
* @param options - Optional parameters for writing the file.
|
|
1697
1313
|
*/
|
|
1698
1314
|
writeFileSync(path, data = "", options = "utf8") {
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
}
|
|
1703
|
-
|
|
1704
|
-
const
|
|
1705
|
-
this.#
|
|
1706
|
-
this.
|
|
1315
|
+
if (!this.isDirectory(findFilePath(this.#normalizePath(path)))) {
|
|
1316
|
+
this.mkdirSync(findFilePath(this.#normalizePath(path)), isPowerlinesWriteFileOptions(options) ? options : void 0);
|
|
1317
|
+
}
|
|
1318
|
+
const metadata = isVirtualFileData(data) ? data : {};
|
|
1319
|
+
metadata.id = this.#normalizeId(path);
|
|
1320
|
+
const code = isVirtualFileData(data) ? metadata.code : data;
|
|
1321
|
+
const outputMode = this.#unifiedFS.resolveMode(this.#normalizePath(path), isPowerlinesWriteFileOptions(options) ? options : void 0);
|
|
1322
|
+
this.#log(LogLevelLabel.TRACE, `Writing ${this.#normalizePath(path)} file to the ${outputMode === "fs" ? "" : "virtual "}file system (size: ${prettyBytes(new Blob(toArray(code)).size)})`);
|
|
1323
|
+
this.#metadata[metadata.id] = {
|
|
1707
1324
|
mode: outputMode,
|
|
1708
1325
|
variant: "normal",
|
|
1709
1326
|
timestamp: Date.now(),
|
|
1710
|
-
...
|
|
1327
|
+
...metadata
|
|
1711
1328
|
};
|
|
1712
|
-
this.#
|
|
1713
|
-
|
|
1329
|
+
this.#paths[metadata.id] = this.#normalizePath(path);
|
|
1330
|
+
this.#ids[this.#normalizePath(path)] = metadata.id;
|
|
1331
|
+
const writeStream = this.#unifiedFS.resolveFS(this.#normalizePath(path), isPowerlinesWriteFileOptions(options) ? options : void 0).createWriteStream(this.#normalizePath(path));
|
|
1714
1332
|
try {
|
|
1715
1333
|
writeStream.write(code);
|
|
1716
1334
|
} finally {
|
|
@@ -1724,7 +1342,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1724
1342
|
* @returns `true` if the file exists, otherwise `false`.
|
|
1725
1343
|
*/
|
|
1726
1344
|
existsSync(pathOrId) {
|
|
1727
|
-
return this.
|
|
1345
|
+
return !!this.resolveSync(pathOrId);
|
|
1728
1346
|
}
|
|
1729
1347
|
/**
|
|
1730
1348
|
* Retrieves the metadata of a file in the virtual file system (VFS).
|
|
@@ -1733,7 +1351,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1733
1351
|
* @returns The metadata of the file, or undefined if the file does not exist.
|
|
1734
1352
|
*/
|
|
1735
1353
|
getMetadata(pathOrId) {
|
|
1736
|
-
const resolved = this.
|
|
1354
|
+
const resolved = this.resolveSync(pathOrId);
|
|
1737
1355
|
if (resolved && this.metadata[resolved]) {
|
|
1738
1356
|
return this.metadata[resolved];
|
|
1739
1357
|
}
|
|
@@ -1749,7 +1367,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1749
1367
|
* @returns `true` if the file exists, otherwise `false`.
|
|
1750
1368
|
*/
|
|
1751
1369
|
isFile(pathOrId) {
|
|
1752
|
-
const resolved = this.
|
|
1370
|
+
const resolved = this.resolveSync(pathOrId);
|
|
1753
1371
|
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()));
|
|
1754
1372
|
}
|
|
1755
1373
|
/**
|
|
@@ -1759,7 +1377,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1759
1377
|
* @returns `true` if the directory exists, otherwise `false`.
|
|
1760
1378
|
*/
|
|
1761
1379
|
isDirectory(pathOrId) {
|
|
1762
|
-
const resolved = this.
|
|
1380
|
+
const resolved = this.resolveSync(pathOrId);
|
|
1763
1381
|
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()));
|
|
1764
1382
|
}
|
|
1765
1383
|
/**
|
|
@@ -1769,7 +1387,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1769
1387
|
* @returns A promise that resolves to the file's status information, or false if the file does not exist.
|
|
1770
1388
|
*/
|
|
1771
1389
|
async stat(pathOrId, options) {
|
|
1772
|
-
return this.#unifiedFS.resolveFS(pathOrId).promises.stat(this.resolve(
|
|
1390
|
+
return this.#unifiedFS.resolveFS(pathOrId).promises.stat(await this.resolve(pathOrId) || pathOrId, options);
|
|
1773
1391
|
}
|
|
1774
1392
|
/**
|
|
1775
1393
|
* Synchronously retrieves the status of a file in the virtual file system (VFS).
|
|
@@ -1778,7 +1396,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1778
1396
|
* @returns The file's status information, or false if the file does not exist.
|
|
1779
1397
|
*/
|
|
1780
1398
|
statSync(pathOrId) {
|
|
1781
|
-
return this.#unifiedFS.resolveFS(pathOrId).statSync(this.
|
|
1399
|
+
return this.#unifiedFS.resolveFS(pathOrId).statSync(this.resolveSync(pathOrId) || pathOrId);
|
|
1782
1400
|
}
|
|
1783
1401
|
/**
|
|
1784
1402
|
* Retrieves the status of a symbolic link in the virtual file system (VFS).
|
|
@@ -1787,7 +1405,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1787
1405
|
* @returns A promise that resolves to the symbolic link's status information, or false if the link does not exist.
|
|
1788
1406
|
*/
|
|
1789
1407
|
async lstat(pathOrId, options) {
|
|
1790
|
-
return this.#unifiedFS.resolveFS(pathOrId).promises.lstat(this.resolve(
|
|
1408
|
+
return this.#unifiedFS.resolveFS(pathOrId).promises.lstat(await this.resolve(pathOrId) || pathOrId, options);
|
|
1791
1409
|
}
|
|
1792
1410
|
/**
|
|
1793
1411
|
* Synchronously retrieves the status of a symbolic link in the virtual file system (VFS).
|
|
@@ -1796,7 +1414,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1796
1414
|
* @returns The symbolic link's status information, or false if the link does not exist.
|
|
1797
1415
|
*/
|
|
1798
1416
|
lstatSync(pathOrId, options) {
|
|
1799
|
-
return this.#unifiedFS.resolveFS(pathOrId).lstatSync(this.
|
|
1417
|
+
return this.#unifiedFS.resolveFS(pathOrId).lstatSync(this.resolveSync(pathOrId) || pathOrId, options);
|
|
1800
1418
|
}
|
|
1801
1419
|
/**
|
|
1802
1420
|
* Resolves a path or ID to its real path in the virtual file system (VFS).
|
|
@@ -1805,52 +1423,113 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1805
1423
|
* @returns The resolved real path if it exists, otherwise undefined.
|
|
1806
1424
|
*/
|
|
1807
1425
|
realpathSync(pathOrId) {
|
|
1808
|
-
const filePath = this.
|
|
1426
|
+
const filePath = this.resolveSync(pathOrId);
|
|
1809
1427
|
if (!filePath) {
|
|
1810
|
-
throw new Error(`File not found: ${
|
|
1428
|
+
throw new Error(`File not found: ${pathOrId}`);
|
|
1811
1429
|
}
|
|
1812
1430
|
return filePath;
|
|
1813
1431
|
}
|
|
1814
1432
|
/**
|
|
1815
|
-
*
|
|
1433
|
+
* A helper function to resolve modules in the virtual file system (VFS).
|
|
1816
1434
|
*
|
|
1817
|
-
* @
|
|
1818
|
-
*
|
|
1819
|
-
*
|
|
1435
|
+
* @remarks
|
|
1436
|
+
* This function can be used to resolve modules relative to the project root directory.
|
|
1437
|
+
*
|
|
1438
|
+
* @example
|
|
1439
|
+
* ```ts
|
|
1440
|
+
* const resolved = await context.resolvePath("some-module", "/path/to/importer");
|
|
1441
|
+
* ```
|
|
1442
|
+
*
|
|
1443
|
+
* @param id - The module to resolve.
|
|
1444
|
+
* @param importer - An optional path to the importer module.
|
|
1445
|
+
* @param options - Additional resolution options.
|
|
1446
|
+
* @returns A promise that resolves to the resolved module path.
|
|
1820
1447
|
*/
|
|
1821
|
-
resolve(
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
return this.#cachedResolver.get(resolverKey);
|
|
1826
|
-
}
|
|
1827
|
-
let result = this.#resolveId(formattedPathOrId);
|
|
1828
|
-
if (!result) {
|
|
1829
|
-
result = this.#resolvePath(formattedPathOrId, options);
|
|
1448
|
+
async resolve(id, importer, options = {}) {
|
|
1449
|
+
let result = this.resolverCache.get(this.#normalizeId(id));
|
|
1450
|
+
if (result) {
|
|
1451
|
+
return result;
|
|
1830
1452
|
}
|
|
1453
|
+
result = this.paths[this.#normalizeId(id)];
|
|
1831
1454
|
if (!result) {
|
|
1832
|
-
|
|
1455
|
+
const paths = options.paths ?? [];
|
|
1456
|
+
if (importer && !paths.includes(importer)) {
|
|
1457
|
+
paths.push(importer);
|
|
1458
|
+
}
|
|
1459
|
+
paths.push(this.#context.workspaceConfig.workspaceRoot);
|
|
1460
|
+
paths.push(joinPaths$1(this.#context.workspaceConfig.workspaceRoot, this.#context.config.projectRoot));
|
|
1461
|
+
paths.push(joinPaths$1(this.#context.workspaceConfig.workspaceRoot, this.#context.config.sourceRoot));
|
|
1462
|
+
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) => appendPath(tsconfigPath, this.#context.workspaceConfig.workspaceRoot)));
|
|
1463
|
+
for (const combination of getResolutionCombinations(id, {
|
|
1464
|
+
paths
|
|
1465
|
+
})) {
|
|
1466
|
+
if (this.#existsSync(combination)) {
|
|
1467
|
+
result = combination;
|
|
1468
|
+
}
|
|
1469
|
+
}
|
|
1470
|
+
try {
|
|
1471
|
+
result = await resolve(id, {
|
|
1472
|
+
paths
|
|
1473
|
+
});
|
|
1474
|
+
} catch {
|
|
1475
|
+
}
|
|
1833
1476
|
}
|
|
1834
|
-
if (result
|
|
1835
|
-
|
|
1477
|
+
if (result) {
|
|
1478
|
+
result = toAbsolutePath(appendPath(result, this.#context.config.projectRoot), this.#context.workspaceConfig.workspaceRoot);
|
|
1479
|
+
this.resolverCache.set(this.#normalizeId(id), result);
|
|
1836
1480
|
}
|
|
1837
|
-
this.#cachedResolver.set(resolverKey, result);
|
|
1838
1481
|
return result;
|
|
1839
1482
|
}
|
|
1840
1483
|
/**
|
|
1841
|
-
*
|
|
1484
|
+
* A synchronous helper function to resolve modules using the Jiti resolver
|
|
1842
1485
|
*
|
|
1843
|
-
* @
|
|
1844
|
-
*
|
|
1486
|
+
* @remarks
|
|
1487
|
+
* This function can be used to resolve modules relative to the project root directory.
|
|
1488
|
+
*
|
|
1489
|
+
* @example
|
|
1490
|
+
* ```ts
|
|
1491
|
+
* const resolvedPath = context.resolveSync("some-module", "/path/to/importer");
|
|
1492
|
+
* ```
|
|
1493
|
+
*
|
|
1494
|
+
* @param id - The module to resolve.
|
|
1495
|
+
* @param importer - An optional path to the importer module.
|
|
1496
|
+
* @param options - Additional resolution options.
|
|
1497
|
+
* @returns The resolved module path.
|
|
1845
1498
|
*/
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
if (
|
|
1849
|
-
return
|
|
1850
|
-
} else if (formattedPath.startsWith(this.#context.config.projectRoot)) {
|
|
1851
|
-
return joinPaths$1(this.#context.workspaceConfig.workspaceRoot, formattedPath);
|
|
1499
|
+
resolveSync(id, importer, options = {}) {
|
|
1500
|
+
let result = this.resolverCache.get(this.#normalizeId(id));
|
|
1501
|
+
if (result) {
|
|
1502
|
+
return result;
|
|
1852
1503
|
}
|
|
1853
|
-
|
|
1504
|
+
result = this.paths[this.#normalizeId(id)];
|
|
1505
|
+
if (!result) {
|
|
1506
|
+
const paths = options.paths ?? [];
|
|
1507
|
+
if (importer && !paths.includes(importer)) {
|
|
1508
|
+
paths.push(importer);
|
|
1509
|
+
}
|
|
1510
|
+
paths.push(this.#context.workspaceConfig.workspaceRoot);
|
|
1511
|
+
paths.push(joinPaths$1(this.#context.workspaceConfig.workspaceRoot, this.#context.config.projectRoot));
|
|
1512
|
+
paths.push(joinPaths$1(this.#context.workspaceConfig.workspaceRoot, this.#context.config.sourceRoot));
|
|
1513
|
+
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) => appendPath(tsconfigPath, this.#context.workspaceConfig.workspaceRoot)));
|
|
1514
|
+
for (const combination of getResolutionCombinations(id, {
|
|
1515
|
+
paths
|
|
1516
|
+
})) {
|
|
1517
|
+
if (this.#existsSync(combination)) {
|
|
1518
|
+
result = combination;
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
try {
|
|
1522
|
+
result = resolveSync(id, {
|
|
1523
|
+
paths
|
|
1524
|
+
});
|
|
1525
|
+
} catch {
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
if (result) {
|
|
1529
|
+
result = toAbsolutePath(appendPath(result, this.#context.config.projectRoot), this.#context.workspaceConfig.workspaceRoot);
|
|
1530
|
+
this.resolverCache.set(this.#normalizeId(id), result);
|
|
1531
|
+
}
|
|
1532
|
+
return result;
|
|
1854
1533
|
}
|
|
1855
1534
|
/**
|
|
1856
1535
|
* Disposes of the virtual file system (VFS) by saving its state to disk.
|
|
@@ -1859,7 +1538,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1859
1538
|
if (!this.#isDisposed) {
|
|
1860
1539
|
this.#isDisposed = true;
|
|
1861
1540
|
this.#log(LogLevelLabel.DEBUG, "Disposing virtual file system...");
|
|
1862
|
-
await this.unlink(joinPaths$1(this.#context.
|
|
1541
|
+
await this.unlink(joinPaths$1(this.#context.dataPath, "fs.bin"));
|
|
1863
1542
|
const message = new $.Message();
|
|
1864
1543
|
const fs2 = message.initRoot(FileSystem);
|
|
1865
1544
|
const virtualFS = this.#unifiedFS.toJSON();
|
|
@@ -1868,7 +1547,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1868
1547
|
virtualFiles.forEach(([path, code], index) => {
|
|
1869
1548
|
const fd = files.get(index);
|
|
1870
1549
|
fd.path = path;
|
|
1871
|
-
fd.code = code;
|
|
1550
|
+
fd.code = code || "";
|
|
1872
1551
|
});
|
|
1873
1552
|
const ids = fs2._initIds(Object.keys(this.ids).length);
|
|
1874
1553
|
Object.entries(this.ids).forEach(([id, path], index) => {
|
|
@@ -1892,7 +1571,9 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1892
1571
|
});
|
|
1893
1572
|
}
|
|
1894
1573
|
});
|
|
1895
|
-
await writeFileBuffer(joinPaths$1(this.#context.
|
|
1574
|
+
await writeFileBuffer(joinPaths$1(this.#context.dataPath, "fs.bin"), message.toArrayBuffer());
|
|
1575
|
+
this.#resolverCache.save(true);
|
|
1576
|
+
this.#log(LogLevelLabel.DEBUG, "Virtual file system disposed.");
|
|
1896
1577
|
}
|
|
1897
1578
|
}
|
|
1898
1579
|
/**
|
|
@@ -1941,6 +1622,8 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
1941
1622
|
#envPaths;
|
|
1942
1623
|
#fs;
|
|
1943
1624
|
#tsconfig;
|
|
1625
|
+
#program;
|
|
1626
|
+
#resolvePatterns = [];
|
|
1944
1627
|
#getConfigProps(config = {}) {
|
|
1945
1628
|
return {
|
|
1946
1629
|
variant: config.build?.variant,
|
|
@@ -2032,7 +1715,7 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
2032
1715
|
*/
|
|
2033
1716
|
get tsconfig() {
|
|
2034
1717
|
if (!this.#tsconfig) {
|
|
2035
|
-
this
|
|
1718
|
+
this.tsconfig = {
|
|
2036
1719
|
tsconfigFilePath: this.config.tsconfig
|
|
2037
1720
|
};
|
|
2038
1721
|
}
|
|
@@ -2043,6 +1726,7 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
2043
1726
|
*/
|
|
2044
1727
|
set tsconfig(value) {
|
|
2045
1728
|
this.#tsconfig = value;
|
|
1729
|
+
this.#resolvePatterns = tsconfigPathsToRegExp(value?.options?.paths ?? {});
|
|
2046
1730
|
}
|
|
2047
1731
|
/**
|
|
2048
1732
|
* The virtual file system interface for the project
|
|
@@ -2167,6 +1851,106 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
2167
1851
|
return Object.values(this.fs.metadata).filter((meta) => meta && meta.type === "builtin").map((meta) => meta?.id).filter(Boolean);
|
|
2168
1852
|
}
|
|
2169
1853
|
/**
|
|
1854
|
+
* The {@link Project} instance used for type reflection and module manipulation
|
|
1855
|
+
*
|
|
1856
|
+
* @see https://ts-morph.com/
|
|
1857
|
+
*
|
|
1858
|
+
* @remarks
|
|
1859
|
+
* This instance is created lazily on first access.
|
|
1860
|
+
*/
|
|
1861
|
+
get program() {
|
|
1862
|
+
if (!this.#program) {
|
|
1863
|
+
this.#program = createProgram(this, {
|
|
1864
|
+
skipAddingFilesFromTsConfig: true
|
|
1865
|
+
});
|
|
1866
|
+
}
|
|
1867
|
+
return this.#program;
|
|
1868
|
+
}
|
|
1869
|
+
/**
|
|
1870
|
+
* A helper function to resolve modules in the Virtual File System
|
|
1871
|
+
*
|
|
1872
|
+
* @remarks
|
|
1873
|
+
* This function can be used to resolve modules relative to the project root directory.
|
|
1874
|
+
*
|
|
1875
|
+
* @example
|
|
1876
|
+
* ```ts
|
|
1877
|
+
* const resolved = await context.resolve("some-module", "/path/to/importer");
|
|
1878
|
+
* ```
|
|
1879
|
+
*
|
|
1880
|
+
* @param id - The module to resolve.
|
|
1881
|
+
* @param importer - An optional path to the importer module.
|
|
1882
|
+
* @param options - Additional resolution options.
|
|
1883
|
+
* @returns A promise that resolves to the resolved module path.
|
|
1884
|
+
*/
|
|
1885
|
+
async resolveId(id, importer, options = {}) {
|
|
1886
|
+
if (this.fs.isVirtual(id)) {
|
|
1887
|
+
const result = await this.fs.resolve(id, importer, options);
|
|
1888
|
+
if (!result) {
|
|
1889
|
+
return void 0;
|
|
1890
|
+
}
|
|
1891
|
+
return {
|
|
1892
|
+
id: `\0${result}`,
|
|
1893
|
+
external: this.config.projectType !== "application"
|
|
1894
|
+
};
|
|
1895
|
+
}
|
|
1896
|
+
if (this.config.build.skipNodeModulesBundle) {
|
|
1897
|
+
if (match(id, this.#resolvePatterns) || match(id, this.config.build.noExternal)) {
|
|
1898
|
+
return void 0;
|
|
1899
|
+
}
|
|
1900
|
+
if (match(id, this.config.build.external) || id.startsWith("node:")) {
|
|
1901
|
+
return {
|
|
1902
|
+
id,
|
|
1903
|
+
external: true
|
|
1904
|
+
};
|
|
1905
|
+
}
|
|
1906
|
+
if (!/^[A-Z]:[/\\]|^\.{0,2}\/|^\.{1,2}$/.test(id)) {
|
|
1907
|
+
return {
|
|
1908
|
+
id,
|
|
1909
|
+
external: true
|
|
1910
|
+
};
|
|
1911
|
+
}
|
|
1912
|
+
} else {
|
|
1913
|
+
if (match(id, this.config.build.noExternal)) {
|
|
1914
|
+
return void 0;
|
|
1915
|
+
}
|
|
1916
|
+
if (match(id, this.config.build.external) || id.startsWith("node:")) {
|
|
1917
|
+
return {
|
|
1918
|
+
id,
|
|
1919
|
+
external: true
|
|
1920
|
+
};
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
return void 0;
|
|
1924
|
+
}
|
|
1925
|
+
/**
|
|
1926
|
+
* A helper function to load modules from the Virtual File System
|
|
1927
|
+
*
|
|
1928
|
+
* @remarks
|
|
1929
|
+
* This function can be used to load modules relative to the project root directory.
|
|
1930
|
+
*
|
|
1931
|
+
* @example
|
|
1932
|
+
* ```ts
|
|
1933
|
+
* const module = await context.load("some-module", "/path/to/importer");
|
|
1934
|
+
* ```
|
|
1935
|
+
*
|
|
1936
|
+
* @param id - The module to load.
|
|
1937
|
+
* @returns A promise that resolves to the loaded module.
|
|
1938
|
+
*/
|
|
1939
|
+
async load(id) {
|
|
1940
|
+
const resolvedId = await this.fs.resolve(id);
|
|
1941
|
+
if (!resolvedId) {
|
|
1942
|
+
return void 0;
|
|
1943
|
+
}
|
|
1944
|
+
const code = await this.fs.readFile(resolvedId);
|
|
1945
|
+
if (!code) {
|
|
1946
|
+
return void 0;
|
|
1947
|
+
}
|
|
1948
|
+
return {
|
|
1949
|
+
code,
|
|
1950
|
+
map: null
|
|
1951
|
+
};
|
|
1952
|
+
}
|
|
1953
|
+
/**
|
|
2170
1954
|
* Get the builtin virtual files that exist in the Powerlines virtual file system
|
|
2171
1955
|
*/
|
|
2172
1956
|
async getBuiltins() {
|
|
@@ -2503,6 +2287,24 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
2503
2287
|
ret.push(plugin);
|
|
2504
2288
|
return ret;
|
|
2505
2289
|
}, []);
|
|
2290
|
+
if (this.config.tsconfig) {
|
|
2291
|
+
this.config.tsconfig = replacePathTokens(this, this.config.tsconfig);
|
|
2292
|
+
}
|
|
2293
|
+
if (this.config.output.dts) {
|
|
2294
|
+
this.config.output.dts = replacePathTokens(this, this.config.output.dts);
|
|
2295
|
+
}
|
|
2296
|
+
if (this.config.build.polyfill) {
|
|
2297
|
+
this.config.build.polyfill = this.config.build.polyfill.map((polyfill) => replacePathTokens(this, polyfill));
|
|
2298
|
+
}
|
|
2299
|
+
if (this.config.output.assets) {
|
|
2300
|
+
this.config.output.assets = this.config.output.assets.map((asset) => ({
|
|
2301
|
+
...asset,
|
|
2302
|
+
glob: replacePathTokens(this, asset.glob),
|
|
2303
|
+
ignore: asset.ignore ? asset.ignore.map((ignore) => replacePathTokens(this, ignore)) : void 0,
|
|
2304
|
+
input: replacePathTokens(this, asset.input),
|
|
2305
|
+
output: replacePathTokens(this, asset.output)
|
|
2306
|
+
}));
|
|
2307
|
+
}
|
|
2506
2308
|
this.#fs ??= await VirtualFileSystem.create(this);
|
|
2507
2309
|
}
|
|
2508
2310
|
mergeUserConfig(from = {}, into = this.config.userConfig ?? {}) {
|
|
@@ -2526,4 +2328,4 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
2526
2328
|
}
|
|
2527
2329
|
};
|
|
2528
2330
|
|
|
2529
|
-
export { PowerlinesContext, VirtualFileSystem,
|
|
2331
|
+
export { PowerlinesContext, VirtualFileSystem, __VFS_REVERT__, addPluginHook, checkDedupe, getHookHandler, isHookExternal, isPlugin, isPluginConfig, isPluginConfigObject, isPluginConfigTuple, isPluginHook };
|