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
|
@@ -26,11 +26,11 @@ var isSet = require('@stryke/type-checks/is-set');
|
|
|
26
26
|
var isSetObject = require('@stryke/type-checks/is-set-object');
|
|
27
27
|
var isSetString = require('@stryke/type-checks/is-set-string');
|
|
28
28
|
var chalk5 = require('chalk');
|
|
29
|
-
var defu6 = require('defu');
|
|
30
29
|
var Handlebars = require('handlebars');
|
|
31
30
|
var helperPluginUtils = require('@babel/helper-plugin-utils');
|
|
32
31
|
var t = require('@babel/types');
|
|
33
32
|
var ts2 = require('typescript');
|
|
33
|
+
var defu6 = require('defu');
|
|
34
34
|
var _package = require('@stryke/string-format/package');
|
|
35
35
|
var superdiff = require('@donedeal0/superdiff');
|
|
36
36
|
var json = require('@stryke/fs/json');
|
|
@@ -53,6 +53,7 @@ var join = require('@stryke/path/join');
|
|
|
53
53
|
var isNull = require('@stryke/type-checks/is-null');
|
|
54
54
|
var isString = require('@stryke/type-checks/is-string');
|
|
55
55
|
var uuid = require('@stryke/unique-id/uuid');
|
|
56
|
+
var bundleRequire = require('bundle-require');
|
|
56
57
|
var jiti = require('jiti');
|
|
57
58
|
var isUndefined = require('@stryke/type-checks/is-undefined');
|
|
58
59
|
var parseTypeDefinition = require('@stryke/convert/parse-type-definition');
|
|
@@ -60,8 +61,10 @@ var isFile = require('@stryke/fs/is-file');
|
|
|
60
61
|
var $ = require('@stryke/capnp');
|
|
61
62
|
var bufferToString = require('@stryke/convert/buffer-to-string');
|
|
62
63
|
var buffer = require('@stryke/fs/buffer');
|
|
64
|
+
var correctPath = require('@stryke/path/correct-path');
|
|
63
65
|
var prettyBytes = require('@stryke/string-format/pretty-bytes');
|
|
64
66
|
var isBuffer = require('@stryke/type-checks/is-buffer');
|
|
67
|
+
var flatCache = require('flat-cache');
|
|
65
68
|
var buffer$1 = require('buffer');
|
|
66
69
|
var _fs = require('fs');
|
|
67
70
|
var logger = require('@storm-software/config-tools/logger');
|
|
@@ -70,6 +73,7 @@ var noop = require('@stryke/helpers/noop');
|
|
|
70
73
|
var isParentPath = require('@stryke/path/is-parent-path');
|
|
71
74
|
var memfs = require('memfs');
|
|
72
75
|
var unionfs = require('unionfs');
|
|
76
|
+
var tsMorph = require('ts-morph');
|
|
73
77
|
require('@stryke/fs/remove-file');
|
|
74
78
|
var kebabCase = require('@stryke/string-format/kebab-case');
|
|
75
79
|
var isObject = require('@stryke/type-checks/is-object');
|
|
@@ -95,10 +99,10 @@ function _interopNamespace(e) {
|
|
|
95
99
|
}
|
|
96
100
|
|
|
97
101
|
var chalk5__default = /*#__PURE__*/_interopDefault(chalk5);
|
|
98
|
-
var defu6__default = /*#__PURE__*/_interopDefault(defu6);
|
|
99
102
|
var Handlebars__default = /*#__PURE__*/_interopDefault(Handlebars);
|
|
100
103
|
var t__namespace = /*#__PURE__*/_interopNamespace(t);
|
|
101
104
|
var ts2__default = /*#__PURE__*/_interopDefault(ts2);
|
|
105
|
+
var defu6__default = /*#__PURE__*/_interopDefault(defu6);
|
|
102
106
|
var $__namespace = /*#__PURE__*/_interopNamespace($);
|
|
103
107
|
var _fs__default = /*#__PURE__*/_interopDefault(_fs);
|
|
104
108
|
|
|
@@ -107,7 +111,7 @@ function resolveModulePath(nodePath, state) {
|
|
|
107
111
|
return;
|
|
108
112
|
}
|
|
109
113
|
const sourcePath = nodePath.node.value;
|
|
110
|
-
const resolvedPath = state.context?.fs.
|
|
114
|
+
const resolvedPath = state.context?.fs.resolveSync(sourcePath);
|
|
111
115
|
if (resolvedPath) {
|
|
112
116
|
nodePath.replaceWith(t__namespace.stringLiteral(
|
|
113
117
|
// Remove the file extension if it exists
|
|
@@ -211,33 +215,31 @@ function formatTypes(code) {
|
|
|
211
215
|
).replaceAll("#private;", "").replace(/__Ω/g, "");
|
|
212
216
|
}
|
|
213
217
|
chunkUSNT2KNT_cjs.__name(formatTypes, "formatTypes");
|
|
214
|
-
async function emitTypes(context,
|
|
215
|
-
context.log(types.LogLevelLabel.TRACE,
|
|
216
|
-
|
|
217
|
-
|
|
218
|
+
async function emitTypes(context, files) {
|
|
219
|
+
context.log(types.LogLevelLabel.TRACE, `Running the TypeScript compiler for ${files.length} generated runtime files.`);
|
|
220
|
+
context.program.addSourceFilesAtPaths(files);
|
|
221
|
+
const result = context.program.emitToMemory({
|
|
222
|
+
emitOnlyDtsFiles: true
|
|
223
|
+
});
|
|
218
224
|
let builtinModules = "";
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
225
|
+
for (const file of result.getFiles()) {
|
|
226
|
+
if (!file.filePath.endsWith(".map")) {
|
|
227
|
+
if (context.builtins.some((builtin) => builtin === file.filePath || context.fs.metadata[builtin]?.id && context.fs.metadata[builtin]?.id === file.filePath)) {
|
|
228
|
+
const module = await context.fs.resolve(file.filePath);
|
|
223
229
|
builtinModules += `
|
|
224
|
-
declare module "${
|
|
225
|
-
|
|
226
|
-
}
|
|
227
|
-
`;
|
|
230
|
+
declare module "${module}" {
|
|
231
|
+
${file.text.trim().replace(/^\s*export\s*declare\s*/gm, "export ").replace(/^\s*declare\s*/gm, "")}
|
|
232
|
+
}
|
|
233
|
+
`;
|
|
228
234
|
}
|
|
229
235
|
}
|
|
230
|
-
}
|
|
231
|
-
const diagnostics = ts2.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
|
|
236
|
+
}
|
|
232
237
|
const diagnosticMessages = [];
|
|
233
|
-
|
|
234
|
-
if (diagnostic.
|
|
235
|
-
|
|
236
|
-
const message = ts2.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
|
|
237
|
-
diagnosticMessages.push(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
|
|
238
|
+
result.getDiagnostics().forEach((diagnostic) => {
|
|
239
|
+
if (diagnostic.getSourceFile()?.getBaseName()) {
|
|
240
|
+
diagnosticMessages.push(`${diagnostic.getSourceFile()?.getBaseName()} (${(diagnostic.getLineNumber() ?? 0) + 1}): ${ts2.flattenDiagnosticMessageText(diagnostic.getMessageText().toString(), "\n")}`);
|
|
238
241
|
} else {
|
|
239
|
-
|
|
240
|
-
diagnosticMessages.push(message);
|
|
242
|
+
diagnosticMessages.push(ts2.flattenDiagnosticMessageText(diagnostic.getMessageText().toString(), "\n"));
|
|
241
243
|
}
|
|
242
244
|
});
|
|
243
245
|
const diagnosticMessage = diagnosticMessages.join("\n");
|
|
@@ -552,6 +554,7 @@ async function initializeTsconfig(context) {
|
|
|
552
554
|
const tsconfigFilePath = getTsconfigFilePath(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig);
|
|
553
555
|
context.tsconfig.originalTsconfigJson = await json.readJsonFile(tsconfigFilePath);
|
|
554
556
|
context.tsconfig.tsconfigJson = await resolveTsconfigChanges(context);
|
|
557
|
+
context.log(types.LogLevelLabel.TRACE, "Writing updated TypeScript configuration (tsconfig.json) file to disk.");
|
|
555
558
|
await context.fs.writeFile(tsconfigFilePath, stormJson.StormJSON.stringify(context.tsconfig.tsconfigJson), {
|
|
556
559
|
mode: "fs"
|
|
557
560
|
});
|
|
@@ -667,23 +670,23 @@ async function loadWorkspaceConfig(workspaceRoot, cwd) {
|
|
|
667
670
|
}));
|
|
668
671
|
}
|
|
669
672
|
chunkUSNT2KNT_cjs.__name(loadWorkspaceConfig, "loadWorkspaceConfig");
|
|
670
|
-
async function loadUserConfigFile(projectRoot, workspaceRoot, jiti, command, mode, configFile, framework = "powerlines") {
|
|
673
|
+
async function loadUserConfigFile(projectRoot, workspaceRoot, jiti, command, mode = "production", configFile, framework = "powerlines") {
|
|
671
674
|
let resolvedUserConfig = {};
|
|
672
|
-
|
|
675
|
+
let resolvedUserConfigFile;
|
|
676
|
+
if (configFile) {
|
|
677
|
+
resolvedUserConfigFile = exists.existsSync(replace.replacePath(configFile, projectRoot)) ? replace.replacePath(configFile, projectRoot) : exists.existsSync(joinPaths.joinPaths(append.appendPath(projectRoot, workspaceRoot), replace.replacePath(configFile, projectRoot))) ? joinPaths.joinPaths(append.appendPath(projectRoot, workspaceRoot), replace.replacePath(configFile, projectRoot)) : exists.existsSync(joinPaths.joinPaths(append.appendPath(projectRoot, workspaceRoot), configFile)) ? joinPaths.joinPaths(append.appendPath(projectRoot, workspaceRoot), configFile) : void 0;
|
|
678
|
+
}
|
|
679
|
+
if (!resolvedUserConfigFile) {
|
|
680
|
+
resolvedUserConfigFile = exists.existsSync(joinPaths.joinPaths(append.appendPath(projectRoot, workspaceRoot), `${framework}.${mode}.config.ts`)) ? joinPaths.joinPaths(append.appendPath(projectRoot, workspaceRoot), `${framework}.${mode}.config.ts`) : exists.existsSync(joinPaths.joinPaths(append.appendPath(projectRoot, workspaceRoot), `${framework}.${mode}.config.js`)) ? joinPaths.joinPaths(append.appendPath(projectRoot, workspaceRoot), `${framework}.${mode}.config.js`) : exists.existsSync(joinPaths.joinPaths(append.appendPath(projectRoot, workspaceRoot), `${framework}.${mode}.config.mts`)) ? joinPaths.joinPaths(append.appendPath(projectRoot, workspaceRoot), `${framework}.${mode}.config.mts`) : exists.existsSync(joinPaths.joinPaths(append.appendPath(projectRoot, workspaceRoot), `${framework}.${mode}.config.mjs`)) ? joinPaths.joinPaths(append.appendPath(projectRoot, workspaceRoot), `${framework}.${mode}.config.mjs`) : exists.existsSync(joinPaths.joinPaths(append.appendPath(projectRoot, workspaceRoot), `${framework}.config.ts`)) ? joinPaths.joinPaths(append.appendPath(projectRoot, workspaceRoot), `${framework}.config.ts`) : exists.existsSync(joinPaths.joinPaths(append.appendPath(projectRoot, workspaceRoot), `${framework}.config.js`)) ? joinPaths.joinPaths(append.appendPath(projectRoot, workspaceRoot), `${framework}.config.js`) : exists.existsSync(joinPaths.joinPaths(append.appendPath(projectRoot, workspaceRoot), `${framework}.config.mts`)) ? joinPaths.joinPaths(append.appendPath(projectRoot, workspaceRoot), `${framework}.config.mts`) : exists.existsSync(joinPaths.joinPaths(append.appendPath(projectRoot, workspaceRoot), `${framework}.config.mjs`)) ? joinPaths.joinPaths(append.appendPath(projectRoot, workspaceRoot), `${framework}.config.mjs`) : void 0;
|
|
681
|
+
}
|
|
673
682
|
if (resolvedUserConfigFile) {
|
|
674
|
-
|
|
675
|
-
try {
|
|
676
|
-
resolvedPath = jiti.esmResolve(resolvedUserConfigFile);
|
|
677
|
-
} catch {
|
|
678
|
-
resolvedPath = resolvedUserConfigFile;
|
|
679
|
-
}
|
|
680
|
-
const resolved = await jiti.import(resolvedPath);
|
|
683
|
+
const resolved = await jiti.import(jiti.esmResolve(resolvedUserConfigFile));
|
|
681
684
|
if (resolved) {
|
|
682
685
|
let config = {};
|
|
683
686
|
if (isFunction.isFunction(resolved)) {
|
|
684
687
|
config = await Promise.resolve(resolved({
|
|
685
688
|
command,
|
|
686
|
-
mode
|
|
689
|
+
mode,
|
|
687
690
|
isSsrBuild: false,
|
|
688
691
|
isPreview: false
|
|
689
692
|
}));
|
|
@@ -714,6 +717,7 @@ async function loadUserConfigFile(projectRoot, workspaceRoot, jiti, command, mod
|
|
|
714
717
|
chunkUSNT2KNT_cjs.__name(loadUserConfigFile, "loadUserConfigFile");
|
|
715
718
|
function resolveOptions(options) {
|
|
716
719
|
return defu6__default.default(options, {
|
|
720
|
+
debug: options.logLevel === "trace",
|
|
717
721
|
interopDefault: true,
|
|
718
722
|
fsCache: options.mode !== "development" ? joinPaths.joinPaths(options.cacheDir, "jiti") : false,
|
|
719
723
|
moduleCache: options.mode !== "development"
|
|
@@ -792,8 +796,6 @@ function replacePathTokens(context, path) {
|
|
|
792
796
|
return path.replaceAll("{workspaceRoot}", context.workspaceConfig.workspaceRoot).replaceAll("{root}", context.config.projectRoot).replaceAll("{projectRoot}", context.config.projectRoot).replaceAll("{powerlinesPath}", context.powerlinesPath).replaceAll("{cachePath}", context.cachePath).replaceAll("{dataPath}", context.dataPath).replaceAll("{logPath}", context.envPaths.log).replaceAll("{tempPath}", context.envPaths.temp).replaceAll("{configPath}", context.envPaths.config).replaceAll("{outputPath}", context.config.output.outputPath).replaceAll("{distPath}", context.config.output.distPath).replaceAll("{artifactsPath}", replace.replacePath(context.artifactsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{builtinPath}", replace.replacePath(context.builtinsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{entryPath}", replace.replacePath(context.entryPath, context.workspaceConfig.workspaceRoot));
|
|
793
797
|
}
|
|
794
798
|
chunkUSNT2KNT_cjs.__name(replacePathTokens, "replacePathTokens");
|
|
795
|
-
|
|
796
|
-
// src/lib/entry.ts
|
|
797
799
|
function resolveEntryInputFile(context, typeDefinition) {
|
|
798
800
|
return replace.replacePath(typeDefinition.file, joinPaths.joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot));
|
|
799
801
|
}
|
|
@@ -954,187 +956,6 @@ var FileMetadata = class _FileMetadata extends $__namespace.Struct {
|
|
|
954
956
|
return "FileMetadata_" + super.toString();
|
|
955
957
|
}
|
|
956
958
|
};
|
|
957
|
-
var ChunkData = class extends $__namespace.Struct {
|
|
958
|
-
static {
|
|
959
|
-
chunkUSNT2KNT_cjs.__name(this, "ChunkData");
|
|
960
|
-
}
|
|
961
|
-
static _capnp = {
|
|
962
|
-
displayName: "ChunkData",
|
|
963
|
-
id: "84076f13b057f83a",
|
|
964
|
-
size: new $__namespace.ObjectSize(8, 4)
|
|
965
|
-
};
|
|
966
|
-
/**
|
|
967
|
-
* An additional name for the file.
|
|
968
|
-
*
|
|
969
|
-
*/
|
|
970
|
-
get id() {
|
|
971
|
-
return $__namespace.utils.getText(0, this);
|
|
972
|
-
}
|
|
973
|
-
set id(value) {
|
|
974
|
-
$__namespace.utils.setText(0, value, this);
|
|
975
|
-
}
|
|
976
|
-
/**
|
|
977
|
-
* Files that are implicitly loaded after one of the specified files.
|
|
978
|
-
*
|
|
979
|
-
*/
|
|
980
|
-
get name() {
|
|
981
|
-
return $__namespace.utils.getText(1, this);
|
|
982
|
-
}
|
|
983
|
-
set name(value) {
|
|
984
|
-
$__namespace.utils.setText(1, value, this);
|
|
985
|
-
}
|
|
986
|
-
_adoptImplicitlyLoadedAfterOneOf(value) {
|
|
987
|
-
$__namespace.utils.adopt(value, $__namespace.utils.getPointer(2, this));
|
|
988
|
-
}
|
|
989
|
-
_disownImplicitlyLoadedAfterOneOf() {
|
|
990
|
-
return $__namespace.utils.disown(this.implicitlyLoadedAfterOneOf);
|
|
991
|
-
}
|
|
992
|
-
/**
|
|
993
|
-
* The importer of the file.
|
|
994
|
-
*
|
|
995
|
-
*/
|
|
996
|
-
get implicitlyLoadedAfterOneOf() {
|
|
997
|
-
return $__namespace.utils.getList(2, $__namespace.TextList, this);
|
|
998
|
-
}
|
|
999
|
-
_hasImplicitlyLoadedAfterOneOf() {
|
|
1000
|
-
return !$__namespace.utils.isNull($__namespace.utils.getPointer(2, this));
|
|
1001
|
-
}
|
|
1002
|
-
_initImplicitlyLoadedAfterOneOf(length) {
|
|
1003
|
-
return $__namespace.utils.initList(2, $__namespace.TextList, length, this);
|
|
1004
|
-
}
|
|
1005
|
-
set implicitlyLoadedAfterOneOf(value) {
|
|
1006
|
-
$__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(2, this));
|
|
1007
|
-
}
|
|
1008
|
-
/**
|
|
1009
|
-
* The signature preservation mode for the file.
|
|
1010
|
-
*
|
|
1011
|
-
*/
|
|
1012
|
-
get importer() {
|
|
1013
|
-
return $__namespace.utils.getText(3, this);
|
|
1014
|
-
}
|
|
1015
|
-
set importer(value) {
|
|
1016
|
-
$__namespace.utils.setText(3, value, this);
|
|
1017
|
-
}
|
|
1018
|
-
get preserveSignature() {
|
|
1019
|
-
return $__namespace.utils.getUint16(0, this);
|
|
1020
|
-
}
|
|
1021
|
-
set preserveSignature(value) {
|
|
1022
|
-
$__namespace.utils.setUint16(0, value, this);
|
|
1023
|
-
}
|
|
1024
|
-
toString() {
|
|
1025
|
-
return "ChunkData_" + super.toString();
|
|
1026
|
-
}
|
|
1027
|
-
};
|
|
1028
|
-
var PrebuiltData = class extends $__namespace.Struct {
|
|
1029
|
-
static {
|
|
1030
|
-
chunkUSNT2KNT_cjs.__name(this, "PrebuiltData");
|
|
1031
|
-
}
|
|
1032
|
-
static _capnp = {
|
|
1033
|
-
displayName: "PrebuiltData",
|
|
1034
|
-
id: "c5b1a6ca696328ee",
|
|
1035
|
-
size: new $__namespace.ObjectSize(0, 4)
|
|
1036
|
-
};
|
|
1037
|
-
/**
|
|
1038
|
-
* An additional name for the file.
|
|
1039
|
-
*
|
|
1040
|
-
*/
|
|
1041
|
-
get id() {
|
|
1042
|
-
return $__namespace.utils.getText(0, this);
|
|
1043
|
-
}
|
|
1044
|
-
set id(value) {
|
|
1045
|
-
$__namespace.utils.setText(0, value, this);
|
|
1046
|
-
}
|
|
1047
|
-
/**
|
|
1048
|
-
* The file exports.
|
|
1049
|
-
*
|
|
1050
|
-
*/
|
|
1051
|
-
get name() {
|
|
1052
|
-
return $__namespace.utils.getText(1, this);
|
|
1053
|
-
}
|
|
1054
|
-
set name(value) {
|
|
1055
|
-
$__namespace.utils.setText(1, value, this);
|
|
1056
|
-
}
|
|
1057
|
-
_adoptExports(value) {
|
|
1058
|
-
$__namespace.utils.adopt(value, $__namespace.utils.getPointer(2, this));
|
|
1059
|
-
}
|
|
1060
|
-
_disownExports() {
|
|
1061
|
-
return $__namespace.utils.disown(this.exports);
|
|
1062
|
-
}
|
|
1063
|
-
/**
|
|
1064
|
-
* The source map for the file.
|
|
1065
|
-
*
|
|
1066
|
-
*/
|
|
1067
|
-
get exports() {
|
|
1068
|
-
return $__namespace.utils.getList(2, $__namespace.TextList, this);
|
|
1069
|
-
}
|
|
1070
|
-
_hasExports() {
|
|
1071
|
-
return !$__namespace.utils.isNull($__namespace.utils.getPointer(2, this));
|
|
1072
|
-
}
|
|
1073
|
-
_initExports(length) {
|
|
1074
|
-
return $__namespace.utils.initList(2, $__namespace.TextList, length, this);
|
|
1075
|
-
}
|
|
1076
|
-
set exports(value) {
|
|
1077
|
-
$__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(2, this));
|
|
1078
|
-
}
|
|
1079
|
-
get map() {
|
|
1080
|
-
return $__namespace.utils.getText(3, this);
|
|
1081
|
-
}
|
|
1082
|
-
set map(value) {
|
|
1083
|
-
$__namespace.utils.setText(3, value, this);
|
|
1084
|
-
}
|
|
1085
|
-
toString() {
|
|
1086
|
-
return "PrebuiltData_" + super.toString();
|
|
1087
|
-
}
|
|
1088
|
-
};
|
|
1089
|
-
var AssetData = class extends $__namespace.Struct {
|
|
1090
|
-
static {
|
|
1091
|
-
chunkUSNT2KNT_cjs.__name(this, "AssetData");
|
|
1092
|
-
}
|
|
1093
|
-
static _capnp = {
|
|
1094
|
-
displayName: "AssetData",
|
|
1095
|
-
id: "da660c6c1fa4c830",
|
|
1096
|
-
size: new $__namespace.ObjectSize(8, 3)
|
|
1097
|
-
};
|
|
1098
|
-
/**
|
|
1099
|
-
* An additional name for the file.
|
|
1100
|
-
*
|
|
1101
|
-
*/
|
|
1102
|
-
get id() {
|
|
1103
|
-
return $__namespace.utils.getText(0, this);
|
|
1104
|
-
}
|
|
1105
|
-
set id(value) {
|
|
1106
|
-
$__namespace.utils.setText(0, value, this);
|
|
1107
|
-
}
|
|
1108
|
-
/**
|
|
1109
|
-
* Indicates whether the file needs a code reference.
|
|
1110
|
-
*
|
|
1111
|
-
*/
|
|
1112
|
-
get name() {
|
|
1113
|
-
return $__namespace.utils.getText(1, this);
|
|
1114
|
-
}
|
|
1115
|
-
set name(value) {
|
|
1116
|
-
$__namespace.utils.setText(1, value, this);
|
|
1117
|
-
}
|
|
1118
|
-
/**
|
|
1119
|
-
* The original file name before any transformations.
|
|
1120
|
-
*
|
|
1121
|
-
*/
|
|
1122
|
-
get needsCodeReference() {
|
|
1123
|
-
return $__namespace.utils.getBit(0, this);
|
|
1124
|
-
}
|
|
1125
|
-
set needsCodeReference(value) {
|
|
1126
|
-
$__namespace.utils.setBit(0, value, this);
|
|
1127
|
-
}
|
|
1128
|
-
get originalFileName() {
|
|
1129
|
-
return $__namespace.utils.getText(2, this);
|
|
1130
|
-
}
|
|
1131
|
-
set originalFileName(value) {
|
|
1132
|
-
$__namespace.utils.setText(2, value, this);
|
|
1133
|
-
}
|
|
1134
|
-
toString() {
|
|
1135
|
-
return "AssetData_" + super.toString();
|
|
1136
|
-
}
|
|
1137
|
-
};
|
|
1138
959
|
var FileId = class extends $__namespace.Struct {
|
|
1139
960
|
static {
|
|
1140
961
|
chunkUSNT2KNT_cjs.__name(this, "FileId");
|
|
@@ -1200,14 +1021,11 @@ var FileSystem = class _FileSystem extends $__namespace.Struct {
|
|
|
1200
1021
|
static _capnp = {
|
|
1201
1022
|
displayName: "FileSystem",
|
|
1202
1023
|
id: "ae0c23d43e56abcf",
|
|
1203
|
-
size: new $__namespace.ObjectSize(0,
|
|
1024
|
+
size: new $__namespace.ObjectSize(0, 3)
|
|
1204
1025
|
};
|
|
1205
1026
|
static _Ids;
|
|
1206
1027
|
static _Files;
|
|
1207
1028
|
static _Metadata;
|
|
1208
|
-
static _Assets;
|
|
1209
|
-
static _Chunks;
|
|
1210
|
-
static _Prebuilt;
|
|
1211
1029
|
_adoptIds(value) {
|
|
1212
1030
|
$__namespace.utils.adopt(value, $__namespace.utils.getPointer(0, this));
|
|
1213
1031
|
}
|
|
@@ -1262,60 +1080,6 @@ var FileSystem = class _FileSystem extends $__namespace.Struct {
|
|
|
1262
1080
|
set metadata(value) {
|
|
1263
1081
|
$__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(2, this));
|
|
1264
1082
|
}
|
|
1265
|
-
_adoptAssets(value) {
|
|
1266
|
-
$__namespace.utils.adopt(value, $__namespace.utils.getPointer(3, this));
|
|
1267
|
-
}
|
|
1268
|
-
_disownAssets() {
|
|
1269
|
-
return $__namespace.utils.disown(this.assets);
|
|
1270
|
-
}
|
|
1271
|
-
get assets() {
|
|
1272
|
-
return $__namespace.utils.getList(3, _FileSystem._Assets, this);
|
|
1273
|
-
}
|
|
1274
|
-
_hasAssets() {
|
|
1275
|
-
return !$__namespace.utils.isNull($__namespace.utils.getPointer(3, this));
|
|
1276
|
-
}
|
|
1277
|
-
_initAssets(length) {
|
|
1278
|
-
return $__namespace.utils.initList(3, _FileSystem._Assets, length, this);
|
|
1279
|
-
}
|
|
1280
|
-
set assets(value) {
|
|
1281
|
-
$__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(3, this));
|
|
1282
|
-
}
|
|
1283
|
-
_adoptChunks(value) {
|
|
1284
|
-
$__namespace.utils.adopt(value, $__namespace.utils.getPointer(4, this));
|
|
1285
|
-
}
|
|
1286
|
-
_disownChunks() {
|
|
1287
|
-
return $__namespace.utils.disown(this.chunks);
|
|
1288
|
-
}
|
|
1289
|
-
get chunks() {
|
|
1290
|
-
return $__namespace.utils.getList(4, _FileSystem._Chunks, this);
|
|
1291
|
-
}
|
|
1292
|
-
_hasChunks() {
|
|
1293
|
-
return !$__namespace.utils.isNull($__namespace.utils.getPointer(4, this));
|
|
1294
|
-
}
|
|
1295
|
-
_initChunks(length) {
|
|
1296
|
-
return $__namespace.utils.initList(4, _FileSystem._Chunks, length, this);
|
|
1297
|
-
}
|
|
1298
|
-
set chunks(value) {
|
|
1299
|
-
$__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(4, this));
|
|
1300
|
-
}
|
|
1301
|
-
_adoptPrebuilt(value) {
|
|
1302
|
-
$__namespace.utils.adopt(value, $__namespace.utils.getPointer(5, this));
|
|
1303
|
-
}
|
|
1304
|
-
_disownPrebuilt() {
|
|
1305
|
-
return $__namespace.utils.disown(this.prebuilt);
|
|
1306
|
-
}
|
|
1307
|
-
get prebuilt() {
|
|
1308
|
-
return $__namespace.utils.getList(5, _FileSystem._Prebuilt, this);
|
|
1309
|
-
}
|
|
1310
|
-
_hasPrebuilt() {
|
|
1311
|
-
return !$__namespace.utils.isNull($__namespace.utils.getPointer(5, this));
|
|
1312
|
-
}
|
|
1313
|
-
_initPrebuilt(length) {
|
|
1314
|
-
return $__namespace.utils.initList(5, _FileSystem._Prebuilt, length, this);
|
|
1315
|
-
}
|
|
1316
|
-
set prebuilt(value) {
|
|
1317
|
-
$__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(5, this));
|
|
1318
|
-
}
|
|
1319
1083
|
toString() {
|
|
1320
1084
|
return "FileSystem_" + super.toString();
|
|
1321
1085
|
}
|
|
@@ -1324,9 +1088,6 @@ FileMetadata._Properties = $__namespace.CompositeList(FileMetadata_KeyValuePair)
|
|
|
1324
1088
|
FileSystem._Ids = $__namespace.CompositeList(FileId);
|
|
1325
1089
|
FileSystem._Files = $__namespace.CompositeList(FileData);
|
|
1326
1090
|
FileSystem._Metadata = $__namespace.CompositeList(FileMetadata);
|
|
1327
|
-
FileSystem._Assets = $__namespace.CompositeList(AssetData);
|
|
1328
|
-
FileSystem._Chunks = $__namespace.CompositeList(ChunkData);
|
|
1329
|
-
FileSystem._Prebuilt = $__namespace.CompositeList(PrebuiltData);
|
|
1330
1091
|
var createLog = /* @__PURE__ */ chunkUSNT2KNT_cjs.__name((name, options = {}) => {
|
|
1331
1092
|
const logLevel = options.logLevel === null ? types.LogLevelLabel.SILENT : options.logLevel || types.LogLevelLabel.INFO;
|
|
1332
1093
|
if (logLevel === types.LogLevelLabel.SILENT) {
|
|
@@ -1370,13 +1131,9 @@ function isBufferEncoding(options) {
|
|
|
1370
1131
|
}
|
|
1371
1132
|
chunkUSNT2KNT_cjs.__name(isBufferEncoding, "isBufferEncoding");
|
|
1372
1133
|
function isPowerlinesWriteFileOptions(options) {
|
|
1373
|
-
return !isBufferEncoding(options) && isSetObject.isSetObject(options) &&
|
|
1134
|
+
return !isBufferEncoding(options) && isSetObject.isSetObject(options) && "mode" in options && (options.mode === "fs" || options.mode === "virtual");
|
|
1374
1135
|
}
|
|
1375
1136
|
chunkUSNT2KNT_cjs.__name(isPowerlinesWriteFileOptions, "isPowerlinesWriteFileOptions");
|
|
1376
|
-
function isNodeWriteFileOptions(options) {
|
|
1377
|
-
return !isUndefined.isUndefined(options) && (isBufferEncoding(options) || !isPowerlinesWriteFileOptions(options));
|
|
1378
|
-
}
|
|
1379
|
-
chunkUSNT2KNT_cjs.__name(isNodeWriteFileOptions, "isNodeWriteFileOptions");
|
|
1380
1137
|
function isVirtualFileData(obj) {
|
|
1381
1138
|
return !!(isSetObject.isSetObject(obj) && "code" in obj && obj.code);
|
|
1382
1139
|
}
|
|
@@ -1513,6 +1270,18 @@ function patchFS(originalFS, vfs) {
|
|
|
1513
1270
|
};
|
|
1514
1271
|
}
|
|
1515
1272
|
chunkUSNT2KNT_cjs.__name(patchFS, "patchFS");
|
|
1273
|
+
function isValidId(id, prefix = "powerlines") {
|
|
1274
|
+
return id.replace(/^\\0/, "").startsWith(`${prefix.replace(/:$/, "")}`);
|
|
1275
|
+
}
|
|
1276
|
+
chunkUSNT2KNT_cjs.__name(isValidId, "isValidId");
|
|
1277
|
+
function normalizeId(id, prefix = "powerlines") {
|
|
1278
|
+
return `${prefix.replace(/:$/, "")}:${toFilePath(id).replace(new RegExp(`^${prefix.replace(/:$/, "")}:`), "").replace(/^\\0/, "").replace(filePathFns.findFileDotExtensionSafe(toFilePath(id)), "")}`;
|
|
1279
|
+
}
|
|
1280
|
+
chunkUSNT2KNT_cjs.__name(normalizeId, "normalizeId");
|
|
1281
|
+
function normalizePath(path, builtinsPath, prefix = "powerlines") {
|
|
1282
|
+
return isValidId(toFilePath(path), prefix) ? normalizeId(toFilePath(path), prefix).replace(new RegExp(`^${prefix.replace(/:$/, "")}:`), builtinsPath) : toFilePath(path);
|
|
1283
|
+
}
|
|
1284
|
+
chunkUSNT2KNT_cjs.__name(normalizePath, "normalizePath");
|
|
1516
1285
|
var UnifiedFS = class _UnifiedFS extends unionfs.Union {
|
|
1517
1286
|
static {
|
|
1518
1287
|
chunkUSNT2KNT_cjs.__name(this, "UnifiedFS");
|
|
@@ -1689,9 +1458,9 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1689
1458
|
*/
|
|
1690
1459
|
#paths;
|
|
1691
1460
|
/**
|
|
1692
|
-
* A
|
|
1461
|
+
* A cache for module resolution results.
|
|
1693
1462
|
*/
|
|
1694
|
-
#
|
|
1463
|
+
#resolverCache;
|
|
1695
1464
|
/**
|
|
1696
1465
|
* The unified volume that combines the virtual file system with the real file system.
|
|
1697
1466
|
*
|
|
@@ -1726,189 +1495,35 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1726
1495
|
* @returns `true` if the path exists, otherwise `false`.
|
|
1727
1496
|
*/
|
|
1728
1497
|
#existsSync(path) {
|
|
1729
|
-
|
|
1730
|
-
return this.#unifiedFS.virtual.existsSync(formattedPath) || this.#unifiedFS.physical.existsSync(formattedPath) || this.#unifiedFS.resolveFS(path).existsSync(formattedPath);
|
|
1731
|
-
}
|
|
1732
|
-
/**
|
|
1733
|
-
* Builds a regular expression from a string pattern for path matching.
|
|
1734
|
-
*
|
|
1735
|
-
* @param strPattern - The string pattern to convert.
|
|
1736
|
-
* @returns A regular expression for matching paths.
|
|
1737
|
-
*/
|
|
1738
|
-
#buildRegex(strPattern) {
|
|
1739
|
-
const token = "::GLOBSTAR::";
|
|
1740
|
-
return new RegExp(`^${this.formatPath(strPattern).replace(/\*\*/g, token).replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]").replace(new RegExp(token, "g"), ".*")}$`);
|
|
1741
|
-
}
|
|
1742
|
-
/**
|
|
1743
|
-
* Formats a file id by removing the file extension and prepending the runtime prefix.
|
|
1744
|
-
*
|
|
1745
|
-
* @param id - The file ID to format.
|
|
1746
|
-
* @returns The formatted file ID.
|
|
1747
|
-
*/
|
|
1748
|
-
#formatId(id) {
|
|
1749
|
-
const formattedId = toFilePath(id);
|
|
1750
|
-
return `${this.#context.config.output.builtinPrefix}:${formattedId.replace(new RegExp(`^${this.#context.config.output.builtinPrefix}:`), "").replace(/^\\0/, "").replace(filePathFns.findFileDotExtensionSafe(formattedId), "")}`;
|
|
1751
|
-
}
|
|
1752
|
-
/**
|
|
1753
|
-
* Resolves an id parameter to a corresponding virtual file path in the virtual file system (VFS).
|
|
1754
|
-
*
|
|
1755
|
-
* @param id - The id to resolve.
|
|
1756
|
-
* @returns The resolved file id if it exists, otherwise undefined.
|
|
1757
|
-
*/
|
|
1758
|
-
#resolveId(id) {
|
|
1759
|
-
if (this.#ids[this.#formatId(id)]) {
|
|
1760
|
-
return this.#ids[this.#formatId(id)] || false;
|
|
1761
|
-
}
|
|
1762
|
-
return false;
|
|
1763
|
-
}
|
|
1764
|
-
/**
|
|
1765
|
-
* Resolves a path parameter to a corresponding virtual file path in the virtual file system (VFS).
|
|
1766
|
-
*
|
|
1767
|
-
* @param path - The path to resolve.
|
|
1768
|
-
* @param options - Optional parameters for resolving the path.
|
|
1769
|
-
* @returns The resolved file path if it exists, otherwise undefined.
|
|
1770
|
-
*/
|
|
1771
|
-
#resolvePath(path, options = {}) {
|
|
1772
|
-
if (isType.isAbsolutePath(path)) {
|
|
1773
|
-
if (this.#existsSync(path)) {
|
|
1774
|
-
return path;
|
|
1775
|
-
}
|
|
1776
|
-
const result = this.#checkVariants(path);
|
|
1777
|
-
if (result) {
|
|
1778
|
-
return result;
|
|
1779
|
-
}
|
|
1780
|
-
}
|
|
1781
|
-
for (const parentPath of this.#resolveParentPaths(path, options.paths)) {
|
|
1782
|
-
const request = joinPaths.joinPaths(parentPath, path);
|
|
1783
|
-
if (this.#existsSync(request)) {
|
|
1784
|
-
return request;
|
|
1785
|
-
}
|
|
1786
|
-
const result = this.#checkVariants(request);
|
|
1787
|
-
if (result) {
|
|
1788
|
-
return result;
|
|
1789
|
-
}
|
|
1790
|
-
}
|
|
1791
|
-
return false;
|
|
1792
|
-
}
|
|
1793
|
-
/**
|
|
1794
|
-
* Resolves parent paths for a given request.
|
|
1795
|
-
*
|
|
1796
|
-
* @param request - The request path to resolve parent paths for.
|
|
1797
|
-
* @param parents - An optional array of parent paths to consider.
|
|
1798
|
-
* @returns An array of resolved parent paths.
|
|
1799
|
-
*/
|
|
1800
|
-
#resolveParentPaths(request, parents = []) {
|
|
1801
|
-
let paths = [
|
|
1802
|
-
this.#context.workspaceConfig.workspaceRoot,
|
|
1803
|
-
joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.projectRoot)
|
|
1804
|
-
];
|
|
1805
|
-
if (this.#context.tsconfig.options.paths) {
|
|
1806
|
-
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) => {
|
|
1807
|
-
if (path && !ret.includes(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, path))) {
|
|
1808
|
-
ret.push(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, path));
|
|
1809
|
-
}
|
|
1810
|
-
return ret;
|
|
1811
|
-
}, paths) : paths;
|
|
1812
|
-
}
|
|
1813
|
-
return paths.reduce((ret, path) => {
|
|
1814
|
-
if (!ret.includes(path)) {
|
|
1815
|
-
ret.push(path);
|
|
1816
|
-
}
|
|
1817
|
-
return ret;
|
|
1818
|
-
}, parents.filter(Boolean).map((p) => this.formatPath(p)));
|
|
1498
|
+
return this.#unifiedFS.virtual.existsSync(this.#normalizePath(path)) || this.#unifiedFS.physical.existsSync(this.#normalizePath(path)) || this.#unifiedFS.resolveFS(path).existsSync(this.#normalizePath(path));
|
|
1819
1499
|
}
|
|
1820
1500
|
/**
|
|
1821
|
-
*
|
|
1501
|
+
* Normalizes a given module id by resolving it against the built-ins path.
|
|
1822
1502
|
*
|
|
1823
|
-
* @param
|
|
1503
|
+
* @param id - The module id to normalize.
|
|
1504
|
+
* @returns The normalized module id.
|
|
1824
1505
|
*/
|
|
1825
|
-
#
|
|
1826
|
-
|
|
1506
|
+
#normalizeId(id) {
|
|
1507
|
+
return normalizeId(id, this.#context.config.output.builtinPrefix);
|
|
1827
1508
|
}
|
|
1828
1509
|
/**
|
|
1829
|
-
*
|
|
1510
|
+
* Normalizes a given path by resolving it against the project root, workspace root, and built-ins path.
|
|
1830
1511
|
*
|
|
1831
|
-
* @param
|
|
1832
|
-
* @
|
|
1833
|
-
* @returns The file path if it exists, otherwise false.
|
|
1834
|
-
*/
|
|
1835
|
-
#checkVariants(request, parentPath) {
|
|
1836
|
-
const path = parentPath ? joinPaths.joinPaths(parentPath, request) : request;
|
|
1837
|
-
let file = this.#checkExtensions(path);
|
|
1838
|
-
if (file) {
|
|
1839
|
-
return file;
|
|
1840
|
-
}
|
|
1841
|
-
file = this.#checkIndex(path);
|
|
1842
|
-
if (file) {
|
|
1843
|
-
return file;
|
|
1844
|
-
}
|
|
1845
|
-
return false;
|
|
1846
|
-
}
|
|
1847
|
-
/**
|
|
1848
|
-
* Check if the index file exists in the given request path.
|
|
1849
|
-
*
|
|
1850
|
-
* @param request - The request path to check.
|
|
1851
|
-
* @returns The index file path if it exists, otherwise false.
|
|
1512
|
+
* @param path - The path to normalize.
|
|
1513
|
+
* @returns The normalized path.
|
|
1852
1514
|
*/
|
|
1853
|
-
#
|
|
1854
|
-
|
|
1855
|
-
if (this.#existsSync(file)) {
|
|
1856
|
-
return file;
|
|
1857
|
-
}
|
|
1858
|
-
file = this.#checkExtensions(file);
|
|
1859
|
-
if (file) {
|
|
1860
|
-
return file;
|
|
1861
|
-
}
|
|
1862
|
-
return false;
|
|
1515
|
+
#normalizePath(path) {
|
|
1516
|
+
return normalizePath(path, this.#context.builtinsPath, this.#context.config.output.builtinPrefix);
|
|
1863
1517
|
}
|
|
1864
1518
|
/**
|
|
1865
|
-
*
|
|
1519
|
+
* Builds a regular expression from a string pattern for path matching.
|
|
1866
1520
|
*
|
|
1867
|
-
* @param
|
|
1868
|
-
* @returns
|
|
1521
|
+
* @param path - The string pattern to convert.
|
|
1522
|
+
* @returns A regular expression for matching paths.
|
|
1869
1523
|
*/
|
|
1870
|
-
#
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
return file;
|
|
1874
|
-
}
|
|
1875
|
-
file = `${request}.mts`;
|
|
1876
|
-
if (this.#existsSync(file)) {
|
|
1877
|
-
return file;
|
|
1878
|
-
}
|
|
1879
|
-
file = `${request}.cts`;
|
|
1880
|
-
if (this.#existsSync(file)) {
|
|
1881
|
-
return file;
|
|
1882
|
-
}
|
|
1883
|
-
file = `${request}.tsx`;
|
|
1884
|
-
if (this.#existsSync(file)) {
|
|
1885
|
-
return file;
|
|
1886
|
-
}
|
|
1887
|
-
file = `${request}.js`;
|
|
1888
|
-
if (this.#existsSync(file)) {
|
|
1889
|
-
return file;
|
|
1890
|
-
}
|
|
1891
|
-
file = `${request}.mjs`;
|
|
1892
|
-
if (this.#existsSync(file)) {
|
|
1893
|
-
return file;
|
|
1894
|
-
}
|
|
1895
|
-
file = `${request}.cjs`;
|
|
1896
|
-
if (this.#existsSync(file)) {
|
|
1897
|
-
return file;
|
|
1898
|
-
}
|
|
1899
|
-
file = `${request}.jsx`;
|
|
1900
|
-
if (this.#existsSync(file)) {
|
|
1901
|
-
return file;
|
|
1902
|
-
}
|
|
1903
|
-
file = `${request}.json`;
|
|
1904
|
-
if (this.#existsSync(file)) {
|
|
1905
|
-
return file;
|
|
1906
|
-
}
|
|
1907
|
-
file = `${request}.d.ts`;
|
|
1908
|
-
if (this.#existsSync(file)) {
|
|
1909
|
-
return file;
|
|
1910
|
-
}
|
|
1911
|
-
return false;
|
|
1524
|
+
#buildRegex(path) {
|
|
1525
|
+
const token = "::GLOBSTAR::";
|
|
1526
|
+
return new RegExp(`^${this.#normalizePath(path).replace(/\*\*/g, token).replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]").replace(new RegExp(token, "g"), ".*")}$`);
|
|
1912
1527
|
}
|
|
1913
1528
|
/**
|
|
1914
1529
|
* Creates a virtual file system (VFS) that is backed up to a Cap'n Proto message buffer.
|
|
@@ -1917,8 +1532,8 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1917
1532
|
* @returns A promise that resolves to a new virtual file system instance.
|
|
1918
1533
|
*/
|
|
1919
1534
|
static async create(context) {
|
|
1920
|
-
if (!context.config.skipCache && exists.existsSync(joinPaths.joinPaths(context.
|
|
1921
|
-
const buffer$1 = await buffer.readFileBuffer(joinPaths.joinPaths(context.
|
|
1535
|
+
if (!context.config.skipCache && exists.existsSync(joinPaths.joinPaths(context.dataPath, "fs.bin"))) {
|
|
1536
|
+
const buffer$1 = await buffer.readFileBuffer(joinPaths.joinPaths(context.dataPath, "fs.bin"));
|
|
1922
1537
|
const message2 = new $__namespace.Message(buffer$1, false);
|
|
1923
1538
|
return new _VirtualFileSystem(context, message2.getRoot(FileSystem));
|
|
1924
1539
|
}
|
|
@@ -1932,8 +1547,8 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1932
1547
|
* @returns A new virtual file system instance.
|
|
1933
1548
|
*/
|
|
1934
1549
|
static createSync(context) {
|
|
1935
|
-
if (!context.config.skipCache && exists.existsSync(joinPaths.joinPaths(context.
|
|
1936
|
-
const buffer$1 = buffer.readFileBufferSync(joinPaths.joinPaths(context.
|
|
1550
|
+
if (!context.config.skipCache && exists.existsSync(joinPaths.joinPaths(context.dataPath, "fs.bin"))) {
|
|
1551
|
+
const buffer$1 = buffer.readFileBufferSync(joinPaths.joinPaths(context.dataPath, "fs.bin"));
|
|
1937
1552
|
const message2 = new $__namespace.Message(buffer$1, false);
|
|
1938
1553
|
return new _VirtualFileSystem(context, message2.getRoot(FileSystem));
|
|
1939
1554
|
}
|
|
@@ -1944,19 +1559,43 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1944
1559
|
* A map of file ids to their metadata.
|
|
1945
1560
|
*/
|
|
1946
1561
|
get metadata() {
|
|
1947
|
-
return this.#metadata
|
|
1562
|
+
return new Proxy(this.#metadata, {
|
|
1563
|
+
get: /* @__PURE__ */ chunkUSNT2KNT_cjs.__name((target, prop) => {
|
|
1564
|
+
return target[this.#normalizeId(prop)];
|
|
1565
|
+
}, "get")
|
|
1566
|
+
});
|
|
1948
1567
|
}
|
|
1949
1568
|
/**
|
|
1950
|
-
* A map of
|
|
1569
|
+
* A map of file paths to their module ids.
|
|
1951
1570
|
*/
|
|
1952
1571
|
get ids() {
|
|
1953
|
-
return this.#
|
|
1572
|
+
return new Proxy(this.#paths, {
|
|
1573
|
+
get: /* @__PURE__ */ chunkUSNT2KNT_cjs.__name((target, prop) => {
|
|
1574
|
+
return target[this.#normalizePath(prop)];
|
|
1575
|
+
}, "get")
|
|
1576
|
+
});
|
|
1954
1577
|
}
|
|
1955
1578
|
/**
|
|
1956
|
-
* A map of
|
|
1579
|
+
* A map of module ids to their file paths.
|
|
1957
1580
|
*/
|
|
1958
1581
|
get paths() {
|
|
1959
|
-
return this.#paths
|
|
1582
|
+
return new Proxy(this.#paths, {
|
|
1583
|
+
get: /* @__PURE__ */ chunkUSNT2KNT_cjs.__name((target, prop) => {
|
|
1584
|
+
return target[this.#normalizeId(prop)];
|
|
1585
|
+
}, "get")
|
|
1586
|
+
});
|
|
1587
|
+
}
|
|
1588
|
+
get resolverCache() {
|
|
1589
|
+
if (!this.#resolverCache) {
|
|
1590
|
+
this.#resolverCache = flatCache.create({
|
|
1591
|
+
cacheId: "module-resolution",
|
|
1592
|
+
cacheDir: this.#context.cachePath,
|
|
1593
|
+
ttl: 60 * 60 * 1e3,
|
|
1594
|
+
lruSize: 5e3,
|
|
1595
|
+
persistInterval: 100
|
|
1596
|
+
});
|
|
1597
|
+
}
|
|
1598
|
+
return this.#resolverCache;
|
|
1960
1599
|
}
|
|
1961
1600
|
/**
|
|
1962
1601
|
* Creates a new instance of the {@link VirtualFileSystem}.
|
|
@@ -2001,17 +1640,13 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2001
1640
|
* Check if a path or id corresponds to a virtual file **(does not actually exists on disk)**.
|
|
2002
1641
|
*
|
|
2003
1642
|
* @param pathOrId - The path or id to check.
|
|
2004
|
-
* @param options - Optional parameters for resolving the path.
|
|
2005
1643
|
* @returns Whether the path or id corresponds to a virtual file **(does not actually exists on disk)**.
|
|
2006
1644
|
*/
|
|
2007
|
-
isVirtual(pathOrId, options = {}) {
|
|
1645
|
+
isVirtual(pathOrId, importer, options = {}) {
|
|
2008
1646
|
if (!pathOrId) {
|
|
2009
1647
|
return false;
|
|
2010
1648
|
}
|
|
2011
|
-
const resolvedPath = this.
|
|
2012
|
-
...options,
|
|
2013
|
-
pathType: "file"
|
|
2014
|
-
});
|
|
1649
|
+
const resolvedPath = this.resolveSync(pathOrId, importer, options);
|
|
2015
1650
|
if (!resolvedPath) {
|
|
2016
1651
|
return false;
|
|
2017
1652
|
}
|
|
@@ -2021,17 +1656,13 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2021
1656
|
* Check if a path or id corresponds to a file written to the file system **(actually exists on disk)**.
|
|
2022
1657
|
*
|
|
2023
1658
|
* @param pathOrId - The path or id to check.
|
|
2024
|
-
* @param options - Optional parameters for resolving the path.
|
|
2025
1659
|
* @returns Whether the path or id corresponds to a file written to the file system **(actually exists on disk)**.
|
|
2026
1660
|
*/
|
|
2027
|
-
isPhysical(pathOrId, options = {}) {
|
|
1661
|
+
isPhysical(pathOrId, importer, options = {}) {
|
|
2028
1662
|
if (!pathOrId) {
|
|
2029
1663
|
return false;
|
|
2030
1664
|
}
|
|
2031
|
-
const resolvedPath = this.
|
|
2032
|
-
...options,
|
|
2033
|
-
pathType: "file"
|
|
2034
|
-
});
|
|
1665
|
+
const resolvedPath = this.resolveSync(pathOrId, importer, options);
|
|
2035
1666
|
if (!resolvedPath) {
|
|
2036
1667
|
return false;
|
|
2037
1668
|
}
|
|
@@ -2053,16 +1684,17 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2053
1684
|
* @param path - The path to create the directory at.
|
|
2054
1685
|
*/
|
|
2055
1686
|
unlinkSync(path, options) {
|
|
2056
|
-
|
|
2057
|
-
if (!this.isFile(formattedPath)) {
|
|
1687
|
+
if (!this.isFile(this.#normalizePath(path))) {
|
|
2058
1688
|
return;
|
|
2059
1689
|
}
|
|
2060
|
-
this.#log(types.LogLevelLabel.TRACE, `Synchronously removing file: ${
|
|
2061
|
-
this.#unifiedFS.resolveFS(path, options).unlinkSync(
|
|
2062
|
-
if (this
|
|
2063
|
-
delete this
|
|
1690
|
+
this.#log(types.LogLevelLabel.TRACE, `Synchronously removing file: ${this.#normalizePath(path)}`);
|
|
1691
|
+
this.#unifiedFS.resolveFS(path, options).unlinkSync(this.#normalizePath(path));
|
|
1692
|
+
if (this.#ids[this.#normalizePath(path)] && this.#metadata[this.#ids[this.#normalizePath(path)]]) {
|
|
1693
|
+
delete this.#metadata[this.#ids[this.#normalizePath(path)]];
|
|
1694
|
+
delete this.#ids[this.#normalizePath(path)];
|
|
1695
|
+
delete this.#paths[this.#normalizeId(path)];
|
|
1696
|
+
this.#resolverCache.delete(this.#normalizePath(path));
|
|
2064
1697
|
}
|
|
2065
|
-
this.#clearResolverCache(formattedPath);
|
|
2066
1698
|
}
|
|
2067
1699
|
/**
|
|
2068
1700
|
* Removes a file in the virtual file system (VFS).
|
|
@@ -2070,19 +1702,17 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2070
1702
|
* @param path - The path to create the directory at.
|
|
2071
1703
|
*/
|
|
2072
1704
|
async unlink(path, options) {
|
|
2073
|
-
|
|
2074
|
-
if (!this.isFile(formattedPath)) {
|
|
1705
|
+
if (!this.isFile(this.#normalizePath(path))) {
|
|
2075
1706
|
return;
|
|
2076
1707
|
}
|
|
2077
|
-
this.#log(types.LogLevelLabel.TRACE, `Removing file: ${
|
|
1708
|
+
this.#log(types.LogLevelLabel.TRACE, `Removing file: ${this.#normalizePath(path)}`);
|
|
2078
1709
|
if (isFunction.isFunction(this.#unifiedFS.resolveFS(path, options).promises.unlink)) {
|
|
2079
|
-
await this.#unifiedFS.resolveFS(path, options).promises.unlink(
|
|
2080
|
-
if (this
|
|
2081
|
-
delete this
|
|
1710
|
+
await this.#unifiedFS.resolveFS(path, options).promises.unlink(this.#normalizePath(path));
|
|
1711
|
+
if (this.#ids[this.#normalizePath(path)] && this.#metadata[this.#ids[this.#normalizePath(path)]]) {
|
|
1712
|
+
delete this.#metadata[this.#ids[this.#normalizePath(path)]];
|
|
2082
1713
|
}
|
|
2083
|
-
this.#clearResolverCache(formattedPath);
|
|
2084
1714
|
} else {
|
|
2085
|
-
this.unlinkSync(
|
|
1715
|
+
this.unlinkSync(this.#normalizePath(path), options);
|
|
2086
1716
|
}
|
|
2087
1717
|
}
|
|
2088
1718
|
/**
|
|
@@ -2092,15 +1722,13 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2092
1722
|
* @param options - Options for creating the directory.
|
|
2093
1723
|
*/
|
|
2094
1724
|
rmdirSync(path, options = {}) {
|
|
2095
|
-
|
|
2096
|
-
if (!this.isDirectory(formattedPath)) {
|
|
1725
|
+
if (!this.isDirectory(this.#normalizePath(path))) {
|
|
2097
1726
|
return;
|
|
2098
1727
|
}
|
|
2099
|
-
this.#log(types.LogLevelLabel.TRACE, `Synchronously removing directory: ${
|
|
2100
|
-
this.#unifiedFS.resolveFS(path, options).rmdirSync(
|
|
1728
|
+
this.#log(types.LogLevelLabel.TRACE, `Synchronously removing directory: ${this.#normalizePath(path)}`);
|
|
1729
|
+
this.#unifiedFS.resolveFS(path, options).rmdirSync(this.#normalizePath(path), defu6__default.default(options, {
|
|
2101
1730
|
recursive: true
|
|
2102
1731
|
}));
|
|
2103
|
-
this.#clearResolverCache(formattedPath);
|
|
2104
1732
|
}
|
|
2105
1733
|
/**
|
|
2106
1734
|
* Removes a directory in the virtual file system (VFS).
|
|
@@ -2110,19 +1738,17 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2110
1738
|
* @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
|
|
2111
1739
|
*/
|
|
2112
1740
|
async rmdir(path, options = {}) {
|
|
2113
|
-
|
|
2114
|
-
if (!this.isDirectory(formattedPath)) {
|
|
1741
|
+
if (!this.isDirectory(this.#normalizePath(path))) {
|
|
2115
1742
|
return;
|
|
2116
1743
|
}
|
|
2117
|
-
this.#log(types.LogLevelLabel.TRACE, `Removing directory: ${
|
|
1744
|
+
this.#log(types.LogLevelLabel.TRACE, `Removing directory: ${this.#normalizePath(path)}`);
|
|
2118
1745
|
if (isFunction.isFunction(this.#unifiedFS.resolveFS(path, options).promises.rm)) {
|
|
2119
|
-
await this.#unifiedFS.resolveFS(path, options).promises.rm(
|
|
1746
|
+
await this.#unifiedFS.resolveFS(path, options).promises.rm(this.#normalizePath(path), defu6__default.default(options, {
|
|
2120
1747
|
force: true,
|
|
2121
1748
|
recursive: true
|
|
2122
1749
|
}));
|
|
2123
|
-
this.#clearResolverCache(formattedPath);
|
|
2124
1750
|
} else {
|
|
2125
|
-
this.rmdirSync(
|
|
1751
|
+
this.rmdirSync(this.#normalizePath(path), defu6__default.default(options ?? {}, {
|
|
2126
1752
|
force: true,
|
|
2127
1753
|
recursive: true
|
|
2128
1754
|
}));
|
|
@@ -2136,11 +1762,11 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2136
1762
|
* @returns A promise that resolves when the file is removed.
|
|
2137
1763
|
*/
|
|
2138
1764
|
async rm(path, options = {}) {
|
|
2139
|
-
this.#log(types.LogLevelLabel.TRACE, `Removing: ${
|
|
2140
|
-
if (this.isDirectory(path)) {
|
|
2141
|
-
return this.rmdir(path, options);
|
|
1765
|
+
this.#log(types.LogLevelLabel.TRACE, `Removing: ${this.#normalizePath(path)}`);
|
|
1766
|
+
if (this.isDirectory(this.#normalizePath(path))) {
|
|
1767
|
+
return this.rmdir(this.#normalizePath(path), options);
|
|
2142
1768
|
}
|
|
2143
|
-
return this.unlink(path, options);
|
|
1769
|
+
return this.unlink(this.#normalizePath(path), options);
|
|
2144
1770
|
}
|
|
2145
1771
|
/**
|
|
2146
1772
|
* Synchronously removes a file or directory in the virtual file system (VFS).
|
|
@@ -2149,11 +1775,11 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2149
1775
|
* @param options - Options for removing the file or directory.
|
|
2150
1776
|
*/
|
|
2151
1777
|
rmSync(path, options = {}) {
|
|
2152
|
-
this.#log(types.LogLevelLabel.TRACE, `Removing: ${
|
|
2153
|
-
if (this.isDirectory(path)) {
|
|
2154
|
-
return this.rmdirSync(path, options);
|
|
1778
|
+
this.#log(types.LogLevelLabel.TRACE, `Removing: ${this.#normalizePath(path)}`);
|
|
1779
|
+
if (this.isDirectory(this.#normalizePath(path))) {
|
|
1780
|
+
return this.rmdirSync(this.#normalizePath(path), options);
|
|
2155
1781
|
}
|
|
2156
|
-
return this.unlinkSync(path, options);
|
|
1782
|
+
return this.unlinkSync(this.#normalizePath(path), options);
|
|
2157
1783
|
}
|
|
2158
1784
|
/**
|
|
2159
1785
|
* Creates a directory in the virtual file system (VFS).
|
|
@@ -2163,9 +1789,9 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2163
1789
|
* @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
|
|
2164
1790
|
*/
|
|
2165
1791
|
mkdirSync(path, options = {}) {
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
1792
|
+
return this.#unifiedFS.resolveFS(this.#normalizePath(path), options).mkdirSync(this.#normalizePath(path), defu6__default.default(omit.omit(options, [
|
|
1793
|
+
"mode"
|
|
1794
|
+
]), {
|
|
2169
1795
|
recursive: true
|
|
2170
1796
|
}));
|
|
2171
1797
|
}
|
|
@@ -2178,17 +1804,19 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2178
1804
|
*/
|
|
2179
1805
|
async mkdir(path, options = {}) {
|
|
2180
1806
|
let result;
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
1807
|
+
if (isFunction.isFunction(this.#unifiedFS.resolveFS(this.#normalizePath(path), options).promises.mkdir)) {
|
|
1808
|
+
result = await this.#unifiedFS.resolveFS(this.#normalizePath(path), options).promises.mkdir(this.#normalizePath(path), defu6__default.default(omit.omit(options, [
|
|
1809
|
+
"mode"
|
|
1810
|
+
]), {
|
|
2184
1811
|
recursive: true
|
|
2185
1812
|
}));
|
|
2186
1813
|
} else {
|
|
2187
|
-
result = this.#unifiedFS.resolveFS(
|
|
1814
|
+
result = this.#unifiedFS.resolveFS(this.#normalizePath(path), options).mkdirSync(this.#normalizePath(path), defu6__default.default(omit.omit(options, [
|
|
1815
|
+
"mode"
|
|
1816
|
+
]), {
|
|
2188
1817
|
recursive: true
|
|
2189
1818
|
}));
|
|
2190
1819
|
}
|
|
2191
|
-
this.#clearResolverCache(filePath);
|
|
2192
1820
|
return result;
|
|
2193
1821
|
}
|
|
2194
1822
|
/**
|
|
@@ -2200,17 +1828,15 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2200
1828
|
async glob(patterns) {
|
|
2201
1829
|
const results = [];
|
|
2202
1830
|
for (const pattern of toArray.toArray(patterns)) {
|
|
2203
|
-
const normalized = this
|
|
1831
|
+
const normalized = this.#normalizePath(pattern);
|
|
2204
1832
|
if (!/[*?[\]{}]/.test(normalized) && !normalized.includes("**")) {
|
|
2205
|
-
const resolved = this.
|
|
2206
|
-
pathType: "file"
|
|
2207
|
-
});
|
|
1833
|
+
const resolved = this.resolveSync(normalized);
|
|
2208
1834
|
if (resolved && !results.includes(resolved)) {
|
|
2209
1835
|
results.push(resolved);
|
|
2210
1836
|
}
|
|
2211
1837
|
continue;
|
|
2212
1838
|
}
|
|
2213
|
-
const absPattern = isType.isAbsolutePath(normalized) ? normalized : this
|
|
1839
|
+
const absPattern = isType.isAbsolutePath(normalized) ? normalized : this.#normalizePath(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, normalized));
|
|
2214
1840
|
const firstGlobIdx = absPattern.search(/[*?[\]{}]/);
|
|
2215
1841
|
const baseDir = firstGlobIdx === -1 ? filePathFns.findFilePath(absPattern) : absPattern.slice(0, Math.max(0, absPattern.lastIndexOf("/", firstGlobIdx)));
|
|
2216
1842
|
const stack = [
|
|
@@ -2225,7 +1851,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2225
1851
|
continue;
|
|
2226
1852
|
}
|
|
2227
1853
|
for (const entry of entries) {
|
|
2228
|
-
const full = this
|
|
1854
|
+
const full = this.#normalizePath(joinPaths.joinPaths(dir, entry));
|
|
2229
1855
|
let stats;
|
|
2230
1856
|
try {
|
|
2231
1857
|
stats = this.#unifiedFS.lstatSync(full);
|
|
@@ -2237,9 +1863,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2237
1863
|
stack.push(full);
|
|
2238
1864
|
} else if (stats.isFile()) {
|
|
2239
1865
|
if (this.#buildRegex(absPattern).test(full)) {
|
|
2240
|
-
const resolved = this.
|
|
2241
|
-
pathType: "file"
|
|
2242
|
-
});
|
|
1866
|
+
const resolved = this.resolveSync(full);
|
|
2243
1867
|
if (resolved && !results.includes(resolved)) {
|
|
2244
1868
|
results.push(resolved);
|
|
2245
1869
|
}
|
|
@@ -2259,17 +1883,15 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2259
1883
|
globSync(patterns) {
|
|
2260
1884
|
const results = [];
|
|
2261
1885
|
for (const pattern of toArray.toArray(patterns)) {
|
|
2262
|
-
const normalized = this
|
|
1886
|
+
const normalized = this.#normalizePath(pattern);
|
|
2263
1887
|
if (!/[*?[\]{}]/.test(normalized) && !normalized.includes("**")) {
|
|
2264
|
-
const resolved = this.
|
|
2265
|
-
pathType: "file"
|
|
2266
|
-
});
|
|
1888
|
+
const resolved = this.resolveSync(normalized);
|
|
2267
1889
|
if (resolved && !results.includes(resolved)) {
|
|
2268
1890
|
results.push(resolved);
|
|
2269
1891
|
}
|
|
2270
1892
|
continue;
|
|
2271
1893
|
}
|
|
2272
|
-
const absPattern = isType.isAbsolutePath(normalized) ? normalized : this
|
|
1894
|
+
const absPattern = isType.isAbsolutePath(normalized) ? normalized : this.#normalizePath(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, normalized));
|
|
2273
1895
|
const firstGlobIdx = absPattern.search(/[*?[\]{}]/);
|
|
2274
1896
|
const baseDir = firstGlobIdx === -1 ? filePathFns.findFilePath(absPattern) : absPattern.slice(0, Math.max(0, absPattern.lastIndexOf("/", firstGlobIdx)));
|
|
2275
1897
|
const stack = [
|
|
@@ -2284,7 +1906,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2284
1906
|
continue;
|
|
2285
1907
|
}
|
|
2286
1908
|
for (const entry of entries) {
|
|
2287
|
-
const full = this
|
|
1909
|
+
const full = this.#normalizePath(joinPaths.joinPaths(dir, entry));
|
|
2288
1910
|
let stats;
|
|
2289
1911
|
try {
|
|
2290
1912
|
stats = this.#unifiedFS.lstatSync(full);
|
|
@@ -2296,9 +1918,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2296
1918
|
stack.push(full);
|
|
2297
1919
|
} else if (stats.isFile()) {
|
|
2298
1920
|
if (this.#buildRegex(absPattern).test(full)) {
|
|
2299
|
-
const resolved = this.
|
|
2300
|
-
pathType: "file"
|
|
2301
|
-
});
|
|
1921
|
+
const resolved = this.resolveSync(full);
|
|
2302
1922
|
if (resolved && !results.includes(resolved)) {
|
|
2303
1923
|
results.push(resolved);
|
|
2304
1924
|
}
|
|
@@ -2368,21 +1988,15 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2368
1988
|
* @returns A promise that resolves to the contents of the file as a string, or undefined if the file does not exist.
|
|
2369
1989
|
*/
|
|
2370
1990
|
async readFile(pathOrId, options = "utf8") {
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
}
|
|
2374
|
-
const filePath = this.resolve(toFilePath(pathOrId), {
|
|
2375
|
-
pathType: "file"
|
|
2376
|
-
});
|
|
2377
|
-
if (filePath) {
|
|
1991
|
+
const filePath = await this.resolve(pathOrId);
|
|
1992
|
+
if (filePath && this.isFile(filePath)) {
|
|
2378
1993
|
let result;
|
|
2379
1994
|
if (isFunction.isFunction(this.#unifiedFS.resolveFS(filePath).promises.readFile)) {
|
|
2380
1995
|
result = (await this.#unifiedFS.resolveFS(filePath).promises.readFile(filePath, options))?.toString("utf8");
|
|
2381
1996
|
} else {
|
|
2382
1997
|
result = this.#unifiedFS.resolveFS(filePath).readFileSync(filePath, options);
|
|
2383
1998
|
}
|
|
2384
|
-
|
|
2385
|
-
return content;
|
|
1999
|
+
return isBuffer.isBuffer(result) ? bufferToString.bufferToString(result) : result;
|
|
2386
2000
|
}
|
|
2387
2001
|
return void 0;
|
|
2388
2002
|
}
|
|
@@ -2393,16 +2007,10 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2393
2007
|
* @returns The contents of the file as a string, or undefined if the file does not exist.
|
|
2394
2008
|
*/
|
|
2395
2009
|
readFileSync(pathOrId, options = "utf8") {
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
}
|
|
2399
|
-
const filePath = this.resolve(toFilePath(pathOrId), {
|
|
2400
|
-
pathType: "file"
|
|
2401
|
-
});
|
|
2402
|
-
if (filePath) {
|
|
2010
|
+
const filePath = this.resolveSync(pathOrId);
|
|
2011
|
+
if (filePath && this.isFile(filePath)) {
|
|
2403
2012
|
const result = this.#unifiedFS.resolveFS(filePath).readFileSync(filePath, options);
|
|
2404
|
-
|
|
2405
|
-
return content;
|
|
2013
|
+
return isBuffer.isBuffer(result) ? bufferToString.bufferToString(result) : result;
|
|
2406
2014
|
}
|
|
2407
2015
|
return void 0;
|
|
2408
2016
|
}
|
|
@@ -2415,34 +2023,40 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2415
2023
|
* @returns A promise that resolves when the file is written.
|
|
2416
2024
|
*/
|
|
2417
2025
|
async writeFile(path, data = "", options = "utf8") {
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
await this.mkdir(filePathFns.findFilePath(formattedPath), isPowerlinesWriteFileOptions(options) ? options : void 0);
|
|
2026
|
+
if (!this.isDirectory(filePathFns.findFilePath(this.#normalizePath(path)))) {
|
|
2027
|
+
await this.mkdir(filePathFns.findFilePath(this.#normalizePath(path)), isPowerlinesWriteFileOptions(options) ? options : void 0);
|
|
2421
2028
|
}
|
|
2422
|
-
|
|
2029
|
+
const metadata = isVirtualFileData(data) ? data : {};
|
|
2030
|
+
metadata.id = this.#normalizeId(path);
|
|
2031
|
+
let code = isVirtualFileData(data) ? metadata.code : data;
|
|
2423
2032
|
if ((!isPowerlinesWriteFileOptions(options) || !options.skipFormat) && isSetString.isSetString(code)) {
|
|
2424
|
-
const resolvedConfig = await prettier.resolveConfig(
|
|
2033
|
+
const resolvedConfig = await prettier.resolveConfig(this.#normalizePath(path));
|
|
2425
2034
|
if (resolvedConfig) {
|
|
2426
2035
|
code = await prettier.format(code, {
|
|
2427
|
-
absolutePath:
|
|
2036
|
+
absolutePath: this.#normalizePath(path),
|
|
2428
2037
|
...resolvedConfig
|
|
2429
2038
|
});
|
|
2430
2039
|
}
|
|
2431
2040
|
}
|
|
2432
|
-
const outputMode = this.#unifiedFS.resolveMode(
|
|
2433
|
-
this.#log(types.LogLevelLabel.TRACE, `Writing ${
|
|
2434
|
-
this
|
|
2041
|
+
const outputMode = this.#unifiedFS.resolveMode(this.#normalizePath(path), isPowerlinesWriteFileOptions(options) ? options : void 0);
|
|
2042
|
+
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)})`);
|
|
2043
|
+
this.#metadata[metadata.id] = {
|
|
2435
2044
|
mode: outputMode,
|
|
2436
2045
|
variant: "normal",
|
|
2437
2046
|
timestamp: Date.now(),
|
|
2438
|
-
...
|
|
2047
|
+
...metadata
|
|
2439
2048
|
};
|
|
2440
|
-
this.#
|
|
2441
|
-
|
|
2049
|
+
this.#paths[metadata.id] = this.#normalizePath(path);
|
|
2050
|
+
this.#ids[this.#normalizePath(path)] = metadata.id;
|
|
2051
|
+
const ifs = this.#unifiedFS.resolveFS(this.#normalizePath(path), isPowerlinesWriteFileOptions(options) ? options : void 0);
|
|
2442
2052
|
if (isFunction.isFunction(ifs.promises.writeFile)) {
|
|
2443
|
-
return ifs.promises.writeFile(
|
|
2053
|
+
return ifs.promises.writeFile(this.#normalizePath(path), code, isSetObject.isSetObject(options) ? omit.omit(options, [
|
|
2054
|
+
"mode"
|
|
2055
|
+
]) : "utf8");
|
|
2444
2056
|
}
|
|
2445
|
-
return ifs.writeFileSync(
|
|
2057
|
+
return ifs.writeFileSync(this.#normalizePath(path), code, isSetObject.isSetObject(options) ? omit.omit(options, [
|
|
2058
|
+
"mode"
|
|
2059
|
+
]) : "utf8");
|
|
2446
2060
|
}
|
|
2447
2061
|
/**
|
|
2448
2062
|
* Synchronously writes a file to the virtual file system (VFS).
|
|
@@ -2452,21 +2066,23 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2452
2066
|
* @param options - Optional parameters for writing the file.
|
|
2453
2067
|
*/
|
|
2454
2068
|
writeFileSync(path, data = "", options = "utf8") {
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
}
|
|
2459
|
-
|
|
2460
|
-
const
|
|
2461
|
-
this.#
|
|
2462
|
-
this.
|
|
2069
|
+
if (!this.isDirectory(filePathFns.findFilePath(this.#normalizePath(path)))) {
|
|
2070
|
+
this.mkdirSync(filePathFns.findFilePath(this.#normalizePath(path)), isPowerlinesWriteFileOptions(options) ? options : void 0);
|
|
2071
|
+
}
|
|
2072
|
+
const metadata = isVirtualFileData(data) ? data : {};
|
|
2073
|
+
metadata.id = this.#normalizeId(path);
|
|
2074
|
+
const code = isVirtualFileData(data) ? metadata.code : data;
|
|
2075
|
+
const outputMode = this.#unifiedFS.resolveMode(this.#normalizePath(path), isPowerlinesWriteFileOptions(options) ? options : void 0);
|
|
2076
|
+
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)})`);
|
|
2077
|
+
this.#metadata[metadata.id] = {
|
|
2463
2078
|
mode: outputMode,
|
|
2464
2079
|
variant: "normal",
|
|
2465
2080
|
timestamp: Date.now(),
|
|
2466
|
-
...
|
|
2081
|
+
...metadata
|
|
2467
2082
|
};
|
|
2468
|
-
this.#
|
|
2469
|
-
|
|
2083
|
+
this.#paths[metadata.id] = this.#normalizePath(path);
|
|
2084
|
+
this.#ids[this.#normalizePath(path)] = metadata.id;
|
|
2085
|
+
const writeStream = this.#unifiedFS.resolveFS(this.#normalizePath(path), isPowerlinesWriteFileOptions(options) ? options : void 0).createWriteStream(this.#normalizePath(path));
|
|
2470
2086
|
try {
|
|
2471
2087
|
writeStream.write(code);
|
|
2472
2088
|
} finally {
|
|
@@ -2480,7 +2096,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2480
2096
|
* @returns `true` if the file exists, otherwise `false`.
|
|
2481
2097
|
*/
|
|
2482
2098
|
existsSync(pathOrId) {
|
|
2483
|
-
return this.
|
|
2099
|
+
return !!this.resolveSync(pathOrId);
|
|
2484
2100
|
}
|
|
2485
2101
|
/**
|
|
2486
2102
|
* Retrieves the metadata of a file in the virtual file system (VFS).
|
|
@@ -2489,7 +2105,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2489
2105
|
* @returns The metadata of the file, or undefined if the file does not exist.
|
|
2490
2106
|
*/
|
|
2491
2107
|
getMetadata(pathOrId) {
|
|
2492
|
-
const resolved = this.
|
|
2108
|
+
const resolved = this.resolveSync(pathOrId);
|
|
2493
2109
|
if (resolved && this.metadata[resolved]) {
|
|
2494
2110
|
return this.metadata[resolved];
|
|
2495
2111
|
}
|
|
@@ -2505,7 +2121,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2505
2121
|
* @returns `true` if the file exists, otherwise `false`.
|
|
2506
2122
|
*/
|
|
2507
2123
|
isFile(pathOrId) {
|
|
2508
|
-
const resolved = this.
|
|
2124
|
+
const resolved = this.resolveSync(pathOrId);
|
|
2509
2125
|
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()));
|
|
2510
2126
|
}
|
|
2511
2127
|
/**
|
|
@@ -2515,7 +2131,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2515
2131
|
* @returns `true` if the directory exists, otherwise `false`.
|
|
2516
2132
|
*/
|
|
2517
2133
|
isDirectory(pathOrId) {
|
|
2518
|
-
const resolved = this.
|
|
2134
|
+
const resolved = this.resolveSync(pathOrId);
|
|
2519
2135
|
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()));
|
|
2520
2136
|
}
|
|
2521
2137
|
/**
|
|
@@ -2525,7 +2141,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2525
2141
|
* @returns A promise that resolves to the file's status information, or false if the file does not exist.
|
|
2526
2142
|
*/
|
|
2527
2143
|
async stat(pathOrId, options) {
|
|
2528
|
-
return this.#unifiedFS.resolveFS(pathOrId).promises.stat(this.resolve(
|
|
2144
|
+
return this.#unifiedFS.resolveFS(pathOrId).promises.stat(await this.resolve(pathOrId) || pathOrId, options);
|
|
2529
2145
|
}
|
|
2530
2146
|
/**
|
|
2531
2147
|
* Synchronously retrieves the status of a file in the virtual file system (VFS).
|
|
@@ -2534,7 +2150,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2534
2150
|
* @returns The file's status information, or false if the file does not exist.
|
|
2535
2151
|
*/
|
|
2536
2152
|
statSync(pathOrId) {
|
|
2537
|
-
return this.#unifiedFS.resolveFS(pathOrId).statSync(this.
|
|
2153
|
+
return this.#unifiedFS.resolveFS(pathOrId).statSync(this.resolveSync(pathOrId) || pathOrId);
|
|
2538
2154
|
}
|
|
2539
2155
|
/**
|
|
2540
2156
|
* Retrieves the status of a symbolic link in the virtual file system (VFS).
|
|
@@ -2543,7 +2159,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2543
2159
|
* @returns A promise that resolves to the symbolic link's status information, or false if the link does not exist.
|
|
2544
2160
|
*/
|
|
2545
2161
|
async lstat(pathOrId, options) {
|
|
2546
|
-
return this.#unifiedFS.resolveFS(pathOrId).promises.lstat(this.resolve(
|
|
2162
|
+
return this.#unifiedFS.resolveFS(pathOrId).promises.lstat(await this.resolve(pathOrId) || pathOrId, options);
|
|
2547
2163
|
}
|
|
2548
2164
|
/**
|
|
2549
2165
|
* Synchronously retrieves the status of a symbolic link in the virtual file system (VFS).
|
|
@@ -2552,7 +2168,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2552
2168
|
* @returns The symbolic link's status information, or false if the link does not exist.
|
|
2553
2169
|
*/
|
|
2554
2170
|
lstatSync(pathOrId, options) {
|
|
2555
|
-
return this.#unifiedFS.resolveFS(pathOrId).lstatSync(this.
|
|
2171
|
+
return this.#unifiedFS.resolveFS(pathOrId).lstatSync(this.resolveSync(pathOrId) || pathOrId, options);
|
|
2556
2172
|
}
|
|
2557
2173
|
/**
|
|
2558
2174
|
* Resolves a path or ID to its real path in the virtual file system (VFS).
|
|
@@ -2561,52 +2177,113 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2561
2177
|
* @returns The resolved real path if it exists, otherwise undefined.
|
|
2562
2178
|
*/
|
|
2563
2179
|
realpathSync(pathOrId) {
|
|
2564
|
-
const filePath = this.
|
|
2180
|
+
const filePath = this.resolveSync(pathOrId);
|
|
2565
2181
|
if (!filePath) {
|
|
2566
|
-
throw new Error(`File not found: ${
|
|
2182
|
+
throw new Error(`File not found: ${pathOrId}`);
|
|
2567
2183
|
}
|
|
2568
2184
|
return filePath;
|
|
2569
2185
|
}
|
|
2570
2186
|
/**
|
|
2571
|
-
*
|
|
2187
|
+
* A helper function to resolve modules in the virtual file system (VFS).
|
|
2572
2188
|
*
|
|
2573
|
-
* @
|
|
2574
|
-
*
|
|
2575
|
-
*
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2189
|
+
* @remarks
|
|
2190
|
+
* This function can be used to resolve modules relative to the project root directory.
|
|
2191
|
+
*
|
|
2192
|
+
* @example
|
|
2193
|
+
* ```ts
|
|
2194
|
+
* const resolved = await context.resolvePath("some-module", "/path/to/importer");
|
|
2195
|
+
* ```
|
|
2196
|
+
*
|
|
2197
|
+
* @param id - The module to resolve.
|
|
2198
|
+
* @param importer - An optional path to the importer module.
|
|
2199
|
+
* @param options - Additional resolution options.
|
|
2200
|
+
* @returns A promise that resolves to the resolved module path.
|
|
2201
|
+
*/
|
|
2202
|
+
async resolve(id, importer, options = {}) {
|
|
2203
|
+
let result = this.resolverCache.get(this.#normalizeId(id));
|
|
2204
|
+
if (result) {
|
|
2205
|
+
return result;
|
|
2586
2206
|
}
|
|
2207
|
+
result = this.paths[this.#normalizeId(id)];
|
|
2587
2208
|
if (!result) {
|
|
2588
|
-
|
|
2209
|
+
const paths = options.paths ?? [];
|
|
2210
|
+
if (importer && !paths.includes(importer)) {
|
|
2211
|
+
paths.push(importer);
|
|
2212
|
+
}
|
|
2213
|
+
paths.push(this.#context.workspaceConfig.workspaceRoot);
|
|
2214
|
+
paths.push(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.projectRoot));
|
|
2215
|
+
paths.push(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.sourceRoot));
|
|
2216
|
+
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)));
|
|
2217
|
+
for (const combination of resolve.getResolutionCombinations(id, {
|
|
2218
|
+
paths
|
|
2219
|
+
})) {
|
|
2220
|
+
if (this.#existsSync(combination)) {
|
|
2221
|
+
result = combination;
|
|
2222
|
+
}
|
|
2223
|
+
}
|
|
2224
|
+
try {
|
|
2225
|
+
result = await resolve.resolve(id, {
|
|
2226
|
+
paths
|
|
2227
|
+
});
|
|
2228
|
+
} catch {
|
|
2229
|
+
}
|
|
2589
2230
|
}
|
|
2590
|
-
if (result
|
|
2591
|
-
|
|
2231
|
+
if (result) {
|
|
2232
|
+
result = correctPath.toAbsolutePath(append.appendPath(result, this.#context.config.projectRoot), this.#context.workspaceConfig.workspaceRoot);
|
|
2233
|
+
this.resolverCache.set(this.#normalizeId(id), result);
|
|
2592
2234
|
}
|
|
2593
|
-
this.#cachedResolver.set(resolverKey, result);
|
|
2594
2235
|
return result;
|
|
2595
2236
|
}
|
|
2596
2237
|
/**
|
|
2597
|
-
*
|
|
2238
|
+
* A synchronous helper function to resolve modules using the Jiti resolver
|
|
2239
|
+
*
|
|
2240
|
+
* @remarks
|
|
2241
|
+
* This function can be used to resolve modules relative to the project root directory.
|
|
2598
2242
|
*
|
|
2599
|
-
* @
|
|
2600
|
-
*
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2243
|
+
* @example
|
|
2244
|
+
* ```ts
|
|
2245
|
+
* const resolvedPath = context.resolveSync("some-module", "/path/to/importer");
|
|
2246
|
+
* ```
|
|
2247
|
+
*
|
|
2248
|
+
* @param id - The module to resolve.
|
|
2249
|
+
* @param importer - An optional path to the importer module.
|
|
2250
|
+
* @param options - Additional resolution options.
|
|
2251
|
+
* @returns The resolved module path.
|
|
2252
|
+
*/
|
|
2253
|
+
resolveSync(id, importer, options = {}) {
|
|
2254
|
+
let result = this.resolverCache.get(this.#normalizeId(id));
|
|
2255
|
+
if (result) {
|
|
2256
|
+
return result;
|
|
2257
|
+
}
|
|
2258
|
+
result = this.paths[this.#normalizeId(id)];
|
|
2259
|
+
if (!result) {
|
|
2260
|
+
const paths = options.paths ?? [];
|
|
2261
|
+
if (importer && !paths.includes(importer)) {
|
|
2262
|
+
paths.push(importer);
|
|
2263
|
+
}
|
|
2264
|
+
paths.push(this.#context.workspaceConfig.workspaceRoot);
|
|
2265
|
+
paths.push(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.projectRoot));
|
|
2266
|
+
paths.push(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.sourceRoot));
|
|
2267
|
+
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)));
|
|
2268
|
+
for (const combination of resolve.getResolutionCombinations(id, {
|
|
2269
|
+
paths
|
|
2270
|
+
})) {
|
|
2271
|
+
if (this.#existsSync(combination)) {
|
|
2272
|
+
result = combination;
|
|
2273
|
+
}
|
|
2274
|
+
}
|
|
2275
|
+
try {
|
|
2276
|
+
result = resolve.resolveSync(id, {
|
|
2277
|
+
paths
|
|
2278
|
+
});
|
|
2279
|
+
} catch {
|
|
2280
|
+
}
|
|
2608
2281
|
}
|
|
2609
|
-
|
|
2282
|
+
if (result) {
|
|
2283
|
+
result = correctPath.toAbsolutePath(append.appendPath(result, this.#context.config.projectRoot), this.#context.workspaceConfig.workspaceRoot);
|
|
2284
|
+
this.resolverCache.set(this.#normalizeId(id), result);
|
|
2285
|
+
}
|
|
2286
|
+
return result;
|
|
2610
2287
|
}
|
|
2611
2288
|
/**
|
|
2612
2289
|
* Disposes of the virtual file system (VFS) by saving its state to disk.
|
|
@@ -2615,7 +2292,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2615
2292
|
if (!this.#isDisposed) {
|
|
2616
2293
|
this.#isDisposed = true;
|
|
2617
2294
|
this.#log(types.LogLevelLabel.DEBUG, "Disposing virtual file system...");
|
|
2618
|
-
await this.unlink(joinPaths.joinPaths(this.#context.
|
|
2295
|
+
await this.unlink(joinPaths.joinPaths(this.#context.dataPath, "fs.bin"));
|
|
2619
2296
|
const message = new $__namespace.Message();
|
|
2620
2297
|
const fs2 = message.initRoot(FileSystem);
|
|
2621
2298
|
const virtualFS = this.#unifiedFS.toJSON();
|
|
@@ -2624,7 +2301,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2624
2301
|
virtualFiles.forEach(([path, code], index) => {
|
|
2625
2302
|
const fd = files.get(index);
|
|
2626
2303
|
fd.path = path;
|
|
2627
|
-
fd.code = code;
|
|
2304
|
+
fd.code = code || "";
|
|
2628
2305
|
});
|
|
2629
2306
|
const ids = fs2._initIds(Object.keys(this.ids).length);
|
|
2630
2307
|
Object.entries(this.ids).forEach(([id, path], index) => {
|
|
@@ -2648,7 +2325,9 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2648
2325
|
});
|
|
2649
2326
|
}
|
|
2650
2327
|
});
|
|
2651
|
-
await buffer.writeFileBuffer(joinPaths.joinPaths(this.#context.
|
|
2328
|
+
await buffer.writeFileBuffer(joinPaths.joinPaths(this.#context.dataPath, "fs.bin"), message.toArrayBuffer());
|
|
2329
|
+
this.#resolverCache.save(true);
|
|
2330
|
+
this.#log(types.LogLevelLabel.DEBUG, "Virtual file system disposed.");
|
|
2652
2331
|
}
|
|
2653
2332
|
}
|
|
2654
2333
|
/**
|
|
@@ -2676,6 +2355,105 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2676
2355
|
return this.dispose();
|
|
2677
2356
|
}
|
|
2678
2357
|
};
|
|
2358
|
+
var VirtualFileSystemHost = class VirtualFileSystemHost2 extends tsMorph.InMemoryFileSystemHost {
|
|
2359
|
+
static {
|
|
2360
|
+
chunkUSNT2KNT_cjs.__name(this, "VirtualFileSystemHost");
|
|
2361
|
+
}
|
|
2362
|
+
#fs;
|
|
2363
|
+
constructor(fs2) {
|
|
2364
|
+
super();
|
|
2365
|
+
this.#fs = fs2;
|
|
2366
|
+
}
|
|
2367
|
+
deleteSync(path) {
|
|
2368
|
+
this.#fs.rmSync(path);
|
|
2369
|
+
}
|
|
2370
|
+
readDirSync(dirPath) {
|
|
2371
|
+
return this.#fs.readdirSync(dirPath).reduce((ret, entry) => {
|
|
2372
|
+
const fullPath = this.#fs.resolveSync(join.joinPaths(dirPath, entry));
|
|
2373
|
+
if (fullPath) {
|
|
2374
|
+
ret.push({
|
|
2375
|
+
name: entry,
|
|
2376
|
+
isDirectory: this.#fs.isDirectory(fullPath),
|
|
2377
|
+
isFile: this.#fs.isFile(fullPath),
|
|
2378
|
+
isSymlink: false
|
|
2379
|
+
});
|
|
2380
|
+
}
|
|
2381
|
+
return ret;
|
|
2382
|
+
}, []);
|
|
2383
|
+
}
|
|
2384
|
+
async readFile(filePath) {
|
|
2385
|
+
if (!this.#fs.existsSync(filePath)) {
|
|
2386
|
+
throw new Error(`File not found: '${filePath}'. Please check the path and try again.`);
|
|
2387
|
+
}
|
|
2388
|
+
return await this.#fs.readFile(filePath);
|
|
2389
|
+
}
|
|
2390
|
+
readFileSync(filePath) {
|
|
2391
|
+
if (!this.#fs.existsSync(filePath)) {
|
|
2392
|
+
throw new Error(`File not found: '${filePath}'. Please check the path and try again.`);
|
|
2393
|
+
}
|
|
2394
|
+
return this.#fs.readFileSync(filePath);
|
|
2395
|
+
}
|
|
2396
|
+
async writeFile(filePath, fileText) {
|
|
2397
|
+
return this.#fs.writeFile(filePath, fileText);
|
|
2398
|
+
}
|
|
2399
|
+
writeFileSync(filePath, fileText) {
|
|
2400
|
+
this.#fs.writeFileSync(filePath, fileText);
|
|
2401
|
+
}
|
|
2402
|
+
async mkdir(dirPath) {
|
|
2403
|
+
await this.#fs.mkdir(dirPath);
|
|
2404
|
+
}
|
|
2405
|
+
mkdirSync(dirPath) {
|
|
2406
|
+
this.#fs.mkdirSync(dirPath);
|
|
2407
|
+
}
|
|
2408
|
+
async move(srcPath, destPath) {
|
|
2409
|
+
await this.#fs.move(srcPath, destPath);
|
|
2410
|
+
}
|
|
2411
|
+
moveSync(srcPath, destPath) {
|
|
2412
|
+
this.#fs.moveSync(srcPath, destPath);
|
|
2413
|
+
}
|
|
2414
|
+
async copy(srcPath, destPath) {
|
|
2415
|
+
await this.#fs.copy(srcPath, destPath);
|
|
2416
|
+
}
|
|
2417
|
+
copySync(srcPath, destPath) {
|
|
2418
|
+
this.#fs.copySync(srcPath, destPath);
|
|
2419
|
+
}
|
|
2420
|
+
async fileExists(filePath) {
|
|
2421
|
+
return this.#fs.isFile(filePath);
|
|
2422
|
+
}
|
|
2423
|
+
fileExistsSync(filePath) {
|
|
2424
|
+
return this.#fs.isFile(filePath);
|
|
2425
|
+
}
|
|
2426
|
+
async directoryExists(dirPath) {
|
|
2427
|
+
return this.#fs.isDirectory(dirPath);
|
|
2428
|
+
}
|
|
2429
|
+
directoryExistsSync(dirPath) {
|
|
2430
|
+
return this.#fs.isDirectory(dirPath);
|
|
2431
|
+
}
|
|
2432
|
+
realpathSync(path) {
|
|
2433
|
+
return this.#fs.resolveSync(path) || path;
|
|
2434
|
+
}
|
|
2435
|
+
getCurrentDirectory() {
|
|
2436
|
+
return "/";
|
|
2437
|
+
}
|
|
2438
|
+
async glob(patterns) {
|
|
2439
|
+
return this.#fs.glob(patterns);
|
|
2440
|
+
}
|
|
2441
|
+
globSync(patterns) {
|
|
2442
|
+
return this.#fs.globSync(patterns);
|
|
2443
|
+
}
|
|
2444
|
+
};
|
|
2445
|
+
function createProgram(context, override) {
|
|
2446
|
+
const project = new tsMorph.Project({
|
|
2447
|
+
compilerOptions: {
|
|
2448
|
+
...context.tsconfig.options
|
|
2449
|
+
},
|
|
2450
|
+
tsConfigFilePath: context.tsconfig.tsconfigFilePath,
|
|
2451
|
+
fileSystem: new VirtualFileSystemHost(context.fs),
|
|
2452
|
+
...override
|
|
2453
|
+
});
|
|
2454
|
+
return project;
|
|
2455
|
+
}
|
|
2456
|
+
chunkUSNT2KNT_cjs.__name(createProgram, "createProgram");
|
|
2679
2457
|
var PROJECT_ROOT_HASH_LENGTH = 45;
|
|
2680
2458
|
var CACHE_HASH_LENGTH = 62;
|
|
2681
2459
|
function getPrefixedProjectRootHash(name, projectRootHash) {
|
|
@@ -2712,6 +2490,8 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
2712
2490
|
#envPaths;
|
|
2713
2491
|
#fs;
|
|
2714
2492
|
#tsconfig;
|
|
2493
|
+
#program;
|
|
2494
|
+
#resolvePatterns = [];
|
|
2715
2495
|
#getConfigProps(config = {}) {
|
|
2716
2496
|
return {
|
|
2717
2497
|
variant: config.build?.variant,
|
|
@@ -2803,7 +2583,7 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
2803
2583
|
*/
|
|
2804
2584
|
get tsconfig() {
|
|
2805
2585
|
if (!this.#tsconfig) {
|
|
2806
|
-
this
|
|
2586
|
+
this.tsconfig = {
|
|
2807
2587
|
tsconfigFilePath: this.config.tsconfig
|
|
2808
2588
|
};
|
|
2809
2589
|
}
|
|
@@ -2814,6 +2594,7 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
2814
2594
|
*/
|
|
2815
2595
|
set tsconfig(value) {
|
|
2816
2596
|
this.#tsconfig = value;
|
|
2597
|
+
this.#resolvePatterns = bundleRequire.tsconfigPathsToRegExp(value?.options?.paths ?? {});
|
|
2817
2598
|
}
|
|
2818
2599
|
/**
|
|
2819
2600
|
* The virtual file system interface for the project
|
|
@@ -2938,6 +2719,106 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
2938
2719
|
return Object.values(this.fs.metadata).filter((meta) => meta && meta.type === "builtin").map((meta) => meta?.id).filter(Boolean);
|
|
2939
2720
|
}
|
|
2940
2721
|
/**
|
|
2722
|
+
* The {@link Project} instance used for type reflection and module manipulation
|
|
2723
|
+
*
|
|
2724
|
+
* @see https://ts-morph.com/
|
|
2725
|
+
*
|
|
2726
|
+
* @remarks
|
|
2727
|
+
* This instance is created lazily on first access.
|
|
2728
|
+
*/
|
|
2729
|
+
get program() {
|
|
2730
|
+
if (!this.#program) {
|
|
2731
|
+
this.#program = createProgram(this, {
|
|
2732
|
+
skipAddingFilesFromTsConfig: true
|
|
2733
|
+
});
|
|
2734
|
+
}
|
|
2735
|
+
return this.#program;
|
|
2736
|
+
}
|
|
2737
|
+
/**
|
|
2738
|
+
* A helper function to resolve modules in the Virtual File System
|
|
2739
|
+
*
|
|
2740
|
+
* @remarks
|
|
2741
|
+
* This function can be used to resolve modules relative to the project root directory.
|
|
2742
|
+
*
|
|
2743
|
+
* @example
|
|
2744
|
+
* ```ts
|
|
2745
|
+
* const resolved = await context.resolve("some-module", "/path/to/importer");
|
|
2746
|
+
* ```
|
|
2747
|
+
*
|
|
2748
|
+
* @param id - The module to resolve.
|
|
2749
|
+
* @param importer - An optional path to the importer module.
|
|
2750
|
+
* @param options - Additional resolution options.
|
|
2751
|
+
* @returns A promise that resolves to the resolved module path.
|
|
2752
|
+
*/
|
|
2753
|
+
async resolveId(id, importer, options = {}) {
|
|
2754
|
+
if (this.fs.isVirtual(id)) {
|
|
2755
|
+
const result = await this.fs.resolve(id, importer, options);
|
|
2756
|
+
if (!result) {
|
|
2757
|
+
return void 0;
|
|
2758
|
+
}
|
|
2759
|
+
return {
|
|
2760
|
+
id: `\0${result}`,
|
|
2761
|
+
external: this.config.projectType !== "application"
|
|
2762
|
+
};
|
|
2763
|
+
}
|
|
2764
|
+
if (this.config.build.skipNodeModulesBundle) {
|
|
2765
|
+
if (bundleRequire.match(id, this.#resolvePatterns) || bundleRequire.match(id, this.config.build.noExternal)) {
|
|
2766
|
+
return void 0;
|
|
2767
|
+
}
|
|
2768
|
+
if (bundleRequire.match(id, this.config.build.external) || id.startsWith("node:")) {
|
|
2769
|
+
return {
|
|
2770
|
+
id,
|
|
2771
|
+
external: true
|
|
2772
|
+
};
|
|
2773
|
+
}
|
|
2774
|
+
if (!/^[A-Z]:[/\\]|^\.{0,2}\/|^\.{1,2}$/.test(id)) {
|
|
2775
|
+
return {
|
|
2776
|
+
id,
|
|
2777
|
+
external: true
|
|
2778
|
+
};
|
|
2779
|
+
}
|
|
2780
|
+
} else {
|
|
2781
|
+
if (bundleRequire.match(id, this.config.build.noExternal)) {
|
|
2782
|
+
return void 0;
|
|
2783
|
+
}
|
|
2784
|
+
if (bundleRequire.match(id, this.config.build.external) || id.startsWith("node:")) {
|
|
2785
|
+
return {
|
|
2786
|
+
id,
|
|
2787
|
+
external: true
|
|
2788
|
+
};
|
|
2789
|
+
}
|
|
2790
|
+
}
|
|
2791
|
+
return void 0;
|
|
2792
|
+
}
|
|
2793
|
+
/**
|
|
2794
|
+
* A helper function to load modules from the Virtual File System
|
|
2795
|
+
*
|
|
2796
|
+
* @remarks
|
|
2797
|
+
* This function can be used to load modules relative to the project root directory.
|
|
2798
|
+
*
|
|
2799
|
+
* @example
|
|
2800
|
+
* ```ts
|
|
2801
|
+
* const module = await context.load("some-module", "/path/to/importer");
|
|
2802
|
+
* ```
|
|
2803
|
+
*
|
|
2804
|
+
* @param id - The module to load.
|
|
2805
|
+
* @returns A promise that resolves to the loaded module.
|
|
2806
|
+
*/
|
|
2807
|
+
async load(id) {
|
|
2808
|
+
const resolvedId = await this.fs.resolve(id);
|
|
2809
|
+
if (!resolvedId) {
|
|
2810
|
+
return void 0;
|
|
2811
|
+
}
|
|
2812
|
+
const code = await this.fs.readFile(resolvedId);
|
|
2813
|
+
if (!code) {
|
|
2814
|
+
return void 0;
|
|
2815
|
+
}
|
|
2816
|
+
return {
|
|
2817
|
+
code,
|
|
2818
|
+
map: null
|
|
2819
|
+
};
|
|
2820
|
+
}
|
|
2821
|
+
/**
|
|
2941
2822
|
* Get the builtin virtual files that exist in the Powerlines virtual file system
|
|
2942
2823
|
*/
|
|
2943
2824
|
async getBuiltins() {
|
|
@@ -3160,6 +3041,7 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
3160
3041
|
projectRoot: cacheKey.projectRoot,
|
|
3161
3042
|
cacheDir: this.cachePath,
|
|
3162
3043
|
mode: cacheKey.mode,
|
|
3044
|
+
logLevel: config.logLevel || this.config?.logLevel || this.workspaceConfig.logLevel || "info",
|
|
3163
3045
|
skipCache: cacheKey.skipCache
|
|
3164
3046
|
});
|
|
3165
3047
|
const userConfig = await loadUserConfigFile(cacheKey.projectRoot, this.workspaceConfig.workspaceRoot, this.resolver, cacheKey.command, cacheKey.mode, cacheKey.configFile, cacheKey.framework);
|
|
@@ -3273,6 +3155,24 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
3273
3155
|
ret.push(plugin);
|
|
3274
3156
|
return ret;
|
|
3275
3157
|
}, []);
|
|
3158
|
+
if (this.config.tsconfig) {
|
|
3159
|
+
this.config.tsconfig = replacePathTokens(this, this.config.tsconfig);
|
|
3160
|
+
}
|
|
3161
|
+
if (this.config.output.dts) {
|
|
3162
|
+
this.config.output.dts = replacePathTokens(this, this.config.output.dts);
|
|
3163
|
+
}
|
|
3164
|
+
if (this.config.build.polyfill) {
|
|
3165
|
+
this.config.build.polyfill = this.config.build.polyfill.map((polyfill) => replacePathTokens(this, polyfill));
|
|
3166
|
+
}
|
|
3167
|
+
if (this.config.output.assets) {
|
|
3168
|
+
this.config.output.assets = this.config.output.assets.map((asset) => ({
|
|
3169
|
+
...asset,
|
|
3170
|
+
glob: replacePathTokens(this, asset.glob),
|
|
3171
|
+
ignore: asset.ignore ? asset.ignore.map((ignore) => replacePathTokens(this, ignore)) : void 0,
|
|
3172
|
+
input: replacePathTokens(this, asset.input),
|
|
3173
|
+
output: replacePathTokens(this, asset.output)
|
|
3174
|
+
}));
|
|
3175
|
+
}
|
|
3276
3176
|
this.#fs ??= await VirtualFileSystem.create(this);
|
|
3277
3177
|
}
|
|
3278
3178
|
mergeUserConfig(from = {}, into = this.config.userConfig ?? {}) {
|
|
@@ -3693,13 +3593,9 @@ ${context.entry.map((entry) => `- ${entry.input.file || entry.file}${entry.outpu
|
|
|
3693
3593
|
await resolveTsconfig(context);
|
|
3694
3594
|
await installDependencies(context);
|
|
3695
3595
|
await this.callPostHook(context, "configResolved");
|
|
3696
|
-
if (context.config.build.polyfill) {
|
|
3697
|
-
context.config.build.polyfill = context.config.build.polyfill.map((polyfill) => replacePathTokens(context, polyfill));
|
|
3698
|
-
}
|
|
3699
3596
|
context.log(types.LogLevelLabel.TRACE, `Powerlines configuration has been resolved:
|
|
3700
3597
|
|
|
3701
3598
|
${console.formatLogMessage(context.config)}`);
|
|
3702
|
-
context.fs[chunkAYKZK666_cjs.__VFS_PATCH__]();
|
|
3703
3599
|
await writeMetaFile(context);
|
|
3704
3600
|
context.persistedMeta = context.meta;
|
|
3705
3601
|
if (!exists.existsSync(context.cachePath)) {
|
|
@@ -3749,35 +3645,19 @@ ${console.formatLogMessage(context.config)}`);
|
|
|
3749
3645
|
if (!typescriptPath) {
|
|
3750
3646
|
throw new Error("Could not resolve TypeScript package location. Please ensure TypeScript is installed.");
|
|
3751
3647
|
}
|
|
3752
|
-
const files = builtinFilePaths.reduce(
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
ret.
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
joinPaths.joinPaths(typescriptPath, "lib", "lib.esnext.full.d.ts")
|
|
3760
|
-
]);
|
|
3761
|
-
context.log(types.LogLevelLabel.TRACE, "Parsing TypeScript configuration for the Powerlines project.");
|
|
3762
|
-
const resolvedTsconfig = getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.tsconfig.tsconfigFilePath, defu6__default.default({
|
|
3763
|
-
compilerOptions: {
|
|
3764
|
-
strict: false,
|
|
3765
|
-
noEmit: false,
|
|
3766
|
-
declaration: true,
|
|
3767
|
-
declarationMap: false,
|
|
3768
|
-
emitDeclarationOnly: true,
|
|
3769
|
-
skipLibCheck: true
|
|
3648
|
+
const files = builtinFilePaths.reduce(
|
|
3649
|
+
(ret, fileName) => {
|
|
3650
|
+
const formatted = replace.replacePath(fileName, context.workspaceConfig.workspaceRoot);
|
|
3651
|
+
if (!ret.includes(formatted)) {
|
|
3652
|
+
ret.push(formatted);
|
|
3653
|
+
}
|
|
3654
|
+
return ret;
|
|
3770
3655
|
},
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
}, context.config.tsconfigRaw ?? {}));
|
|
3777
|
-
resolvedTsconfig.options.configFilePath = joinPaths.joinPaths(context.workspaceConfig.workspaceRoot, context.tsconfig.tsconfigFilePath);
|
|
3778
|
-
resolvedTsconfig.options.pathsBasePath = context.workspaceConfig.workspaceRoot;
|
|
3779
|
-
resolvedTsconfig.options.suppressOutputPathCheck = true;
|
|
3780
|
-
let generatedTypes = await emitTypes(context, resolvedTsconfig, files);
|
|
3656
|
+
[]
|
|
3657
|
+
// [joinPaths(typescriptPath, "lib", "lib.esnext.full.d.ts")]
|
|
3658
|
+
);
|
|
3659
|
+
context.log(types.LogLevelLabel.TRACE, "Parsing TypeScript configuration for the Powerlines project.");
|
|
3660
|
+
let generatedTypes = await emitTypes(context, files);
|
|
3781
3661
|
context.log(types.LogLevelLabel.TRACE, `Generating TypeScript declaration file in ${context.config.output.dts}.`);
|
|
3782
3662
|
const directives = [];
|
|
3783
3663
|
let result = await this.callPreHook(context, "generateTypes", generatedTypes);
|
|
@@ -3831,7 +3711,6 @@ ${formatTypes(generatedTypes)}
|
|
|
3831
3711
|
}
|
|
3832
3712
|
await this.callPostHook(context, "prepare");
|
|
3833
3713
|
await writeMetaFile(context);
|
|
3834
|
-
context.fs[chunkAYKZK666_cjs.__VFS_REVERT__]();
|
|
3835
3714
|
});
|
|
3836
3715
|
this.context.log(types.LogLevelLabel.INFO, "Powerlines API has been prepared successfully");
|
|
3837
3716
|
}
|
|
@@ -4270,8 +4149,6 @@ Note: Please ensure the plugin package's default export is a class that extends
|
|
|
4270
4149
|
}
|
|
4271
4150
|
};
|
|
4272
4151
|
|
|
4273
|
-
exports.AssetData = AssetData;
|
|
4274
|
-
exports.ChunkData = ChunkData;
|
|
4275
4152
|
exports.FileData = FileData;
|
|
4276
4153
|
exports.FileId = FileId;
|
|
4277
4154
|
exports.FileMetadata = FileMetadata;
|
|
@@ -4279,7 +4156,6 @@ exports.FileMetadata_KeyValuePair = FileMetadata_KeyValuePair;
|
|
|
4279
4156
|
exports.FileSystem = FileSystem;
|
|
4280
4157
|
exports.FileType = FileType;
|
|
4281
4158
|
exports.PowerlinesAPI = PowerlinesAPI;
|
|
4282
|
-
exports.PrebuiltData = PrebuiltData;
|
|
4283
4159
|
exports.PreserveSignatureType = PreserveSignatureType;
|
|
4284
4160
|
exports._capnpFileId = _capnpFileId;
|
|
4285
4161
|
exports.createLog = createLog;
|