@powerlines/nx 0.10.27 → 0.10.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/{chunk-LQRLEK65.mjs → chunk-5WHBT2BW.mjs} +1 -1
- package/dist/{chunk-ELZO2KAE.js → chunk-7E3PRE6W.js} +2 -2
- package/dist/{chunk-LH6XKDMA.mjs → chunk-DLZ7E67Y.mjs} +1 -1
- package/dist/{chunk-YPABMWPC.js → chunk-GVA7U7C4.js} +2 -2
- package/dist/{chunk-UAUZWBTW.js → chunk-HLYNF7YE.js} +521 -644
- package/dist/{chunk-V5EQMHJX.js → chunk-HVWVP6CD.js} +2 -2
- package/dist/{chunk-I7QVZOFS.js → chunk-ND7VF7PZ.js} +2 -2
- package/dist/{chunk-2W5L3QE3.js → chunk-PM5JBU7Z.js} +2 -2
- package/dist/{chunk-U2ZZ4QLS.mjs → chunk-QE2RQBEB.mjs} +524 -647
- package/dist/{chunk-WAXOGGDZ.mjs → chunk-RIM7CNHX.mjs} +1 -1
- package/dist/{chunk-WNLIJGN4.mjs → chunk-VQX5TBLP.mjs} +1 -1
- package/dist/{chunk-EWXGKWHK.mjs → chunk-ZIBEDH47.mjs} +1 -1
- package/dist/executors.js +13 -13
- package/dist/executors.mjs +6 -6
- package/dist/index.js +13 -13
- package/dist/index.mjs +6 -6
- package/dist/src/base/base-executor.js +2 -2
- package/dist/src/base/base-executor.mjs +1 -1
- package/dist/src/executors/build/executor.js +4 -4
- package/dist/src/executors/build/executor.mjs +2 -2
- package/dist/src/executors/clean/executor.js +4 -4
- package/dist/src/executors/clean/executor.mjs +2 -2
- package/dist/src/executors/docs/executor.js +4 -4
- package/dist/src/executors/docs/executor.mjs +2 -2
- package/dist/src/executors/lint/executor.js +4 -4
- package/dist/src/executors/lint/executor.mjs +2 -2
- package/dist/src/executors/prepare/executor.js +4 -4
- package/dist/src/executors/prepare/executor.mjs +2 -2
- package/package.json +8 -8
|
@@ -51,6 +51,7 @@ var join = require('@stryke/path/join');
|
|
|
51
51
|
var isNull = require('@stryke/type-checks/is-null');
|
|
52
52
|
var isString = require('@stryke/type-checks/is-string');
|
|
53
53
|
var uuid = require('@stryke/unique-id/uuid');
|
|
54
|
+
var bundleRequire = require('bundle-require');
|
|
54
55
|
var jiti = require('jiti');
|
|
55
56
|
var isUndefined = require('@stryke/type-checks/is-undefined');
|
|
56
57
|
var parseTypeDefinition = require('@stryke/convert/parse-type-definition');
|
|
@@ -58,8 +59,10 @@ var isFile = require('@stryke/fs/is-file');
|
|
|
58
59
|
var $ = require('@stryke/capnp');
|
|
59
60
|
var bufferToString = require('@stryke/convert/buffer-to-string');
|
|
60
61
|
var buffer = require('@stryke/fs/buffer');
|
|
62
|
+
var correctPath = require('@stryke/path/correct-path');
|
|
61
63
|
var prettyBytes = require('@stryke/string-format/pretty-bytes');
|
|
62
64
|
var isBuffer = require('@stryke/type-checks/is-buffer');
|
|
65
|
+
var flatCache = require('flat-cache');
|
|
63
66
|
var buffer$1 = require('buffer');
|
|
64
67
|
var _fs = require('fs');
|
|
65
68
|
var colors = require('@storm-software/config-tools/utilities/colors');
|
|
@@ -67,6 +70,7 @@ var noop = require('@stryke/helpers/noop');
|
|
|
67
70
|
var isParentPath = require('@stryke/path/is-parent-path');
|
|
68
71
|
var memfs = require('memfs');
|
|
69
72
|
var unionfs = require('unionfs');
|
|
73
|
+
var tsMorph = require('ts-morph');
|
|
70
74
|
var isObject = require('@stryke/type-checks/is-object');
|
|
71
75
|
|
|
72
76
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -102,7 +106,7 @@ function resolveModulePath(nodePath, state) {
|
|
|
102
106
|
return;
|
|
103
107
|
}
|
|
104
108
|
const sourcePath = nodePath.node.value;
|
|
105
|
-
const resolvedPath = state.context?.fs.
|
|
109
|
+
const resolvedPath = state.context?.fs.resolveSync(sourcePath);
|
|
106
110
|
if (resolvedPath) {
|
|
107
111
|
nodePath.replaceWith(t__namespace.stringLiteral(
|
|
108
112
|
// Remove the file extension if it exists
|
|
@@ -206,33 +210,31 @@ function formatTypes(code) {
|
|
|
206
210
|
).replaceAll("#private;", "").replace(/__Ω/g, "");
|
|
207
211
|
}
|
|
208
212
|
chunkSHUYVCID_js.__name(formatTypes, "formatTypes");
|
|
209
|
-
async function emitTypes(context,
|
|
210
|
-
context.log(types.LogLevelLabel.TRACE,
|
|
211
|
-
|
|
212
|
-
|
|
213
|
+
async function emitTypes(context, files) {
|
|
214
|
+
context.log(types.LogLevelLabel.TRACE, `Running the TypeScript compiler for ${files.length} generated runtime files.`);
|
|
215
|
+
context.program.addSourceFilesAtPaths(files);
|
|
216
|
+
const result = context.program.emitToMemory({
|
|
217
|
+
emitOnlyDtsFiles: true
|
|
218
|
+
});
|
|
213
219
|
let builtinModules = "";
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
220
|
+
for (const file of result.getFiles()) {
|
|
221
|
+
if (!file.filePath.endsWith(".map")) {
|
|
222
|
+
if (context.builtins.some((builtin) => builtin === file.filePath || context.fs.metadata[builtin]?.id && context.fs.metadata[builtin]?.id === file.filePath)) {
|
|
223
|
+
const module = await context.fs.resolve(file.filePath);
|
|
218
224
|
builtinModules += `
|
|
219
|
-
declare module "${
|
|
220
|
-
|
|
221
|
-
}
|
|
222
|
-
`;
|
|
225
|
+
declare module "${module}" {
|
|
226
|
+
${file.text.trim().replace(/^\s*export\s*declare\s*/gm, "export ").replace(/^\s*declare\s*/gm, "")}
|
|
227
|
+
}
|
|
228
|
+
`;
|
|
223
229
|
}
|
|
224
230
|
}
|
|
225
|
-
}
|
|
226
|
-
const diagnostics = ts2.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
|
|
231
|
+
}
|
|
227
232
|
const diagnosticMessages = [];
|
|
228
|
-
|
|
229
|
-
if (diagnostic.
|
|
230
|
-
|
|
231
|
-
const message = ts2.flattenDiagnosticMessageText(diagnostic.messageText, "\n");
|
|
232
|
-
diagnosticMessages.push(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`);
|
|
233
|
+
result.getDiagnostics().forEach((diagnostic) => {
|
|
234
|
+
if (diagnostic.getSourceFile()?.getBaseName()) {
|
|
235
|
+
diagnosticMessages.push(`${diagnostic.getSourceFile()?.getBaseName()} (${(diagnostic.getLineNumber() ?? 0) + 1}): ${ts2.flattenDiagnosticMessageText(diagnostic.getMessageText().toString(), "\n")}`);
|
|
233
236
|
} else {
|
|
234
|
-
|
|
235
|
-
diagnosticMessages.push(message);
|
|
237
|
+
diagnosticMessages.push(ts2.flattenDiagnosticMessageText(diagnostic.getMessageText().toString(), "\n"));
|
|
236
238
|
}
|
|
237
239
|
});
|
|
238
240
|
const diagnosticMessage = diagnosticMessages.join("\n");
|
|
@@ -547,6 +549,7 @@ async function initializeTsconfig(context) {
|
|
|
547
549
|
const tsconfigFilePath = getTsconfigFilePath(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.config.tsconfig);
|
|
548
550
|
context.tsconfig.originalTsconfigJson = await json.readJsonFile(tsconfigFilePath);
|
|
549
551
|
context.tsconfig.tsconfigJson = await resolveTsconfigChanges(context);
|
|
552
|
+
context.log(types.LogLevelLabel.TRACE, "Writing updated TypeScript configuration (tsconfig.json) file to disk.");
|
|
550
553
|
await context.fs.writeFile(tsconfigFilePath, stormJson.StormJSON.stringify(context.tsconfig.tsconfigJson), {
|
|
551
554
|
mode: "fs"
|
|
552
555
|
});
|
|
@@ -748,8 +751,6 @@ function replacePathTokens(context, path) {
|
|
|
748
751
|
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));
|
|
749
752
|
}
|
|
750
753
|
chunkSHUYVCID_js.__name(replacePathTokens, "replacePathTokens");
|
|
751
|
-
|
|
752
|
-
// ../powerlines/src/lib/entry.ts
|
|
753
754
|
function resolveEntryInputFile(context, typeDefinition) {
|
|
754
755
|
return replace.replacePath(typeDefinition.file, joinPaths.joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot));
|
|
755
756
|
}
|
|
@@ -897,187 +898,6 @@ var FileMetadata = class _FileMetadata extends $__namespace.Struct {
|
|
|
897
898
|
return "FileMetadata_" + super.toString();
|
|
898
899
|
}
|
|
899
900
|
};
|
|
900
|
-
var ChunkData = class extends $__namespace.Struct {
|
|
901
|
-
static {
|
|
902
|
-
chunkSHUYVCID_js.__name(this, "ChunkData");
|
|
903
|
-
}
|
|
904
|
-
static _capnp = {
|
|
905
|
-
displayName: "ChunkData",
|
|
906
|
-
id: "84076f13b057f83a",
|
|
907
|
-
size: new $__namespace.ObjectSize(8, 4)
|
|
908
|
-
};
|
|
909
|
-
/**
|
|
910
|
-
* An additional name for the file.
|
|
911
|
-
*
|
|
912
|
-
*/
|
|
913
|
-
get id() {
|
|
914
|
-
return $__namespace.utils.getText(0, this);
|
|
915
|
-
}
|
|
916
|
-
set id(value) {
|
|
917
|
-
$__namespace.utils.setText(0, value, this);
|
|
918
|
-
}
|
|
919
|
-
/**
|
|
920
|
-
* Files that are implicitly loaded after one of the specified files.
|
|
921
|
-
*
|
|
922
|
-
*/
|
|
923
|
-
get name() {
|
|
924
|
-
return $__namespace.utils.getText(1, this);
|
|
925
|
-
}
|
|
926
|
-
set name(value) {
|
|
927
|
-
$__namespace.utils.setText(1, value, this);
|
|
928
|
-
}
|
|
929
|
-
_adoptImplicitlyLoadedAfterOneOf(value) {
|
|
930
|
-
$__namespace.utils.adopt(value, $__namespace.utils.getPointer(2, this));
|
|
931
|
-
}
|
|
932
|
-
_disownImplicitlyLoadedAfterOneOf() {
|
|
933
|
-
return $__namespace.utils.disown(this.implicitlyLoadedAfterOneOf);
|
|
934
|
-
}
|
|
935
|
-
/**
|
|
936
|
-
* The importer of the file.
|
|
937
|
-
*
|
|
938
|
-
*/
|
|
939
|
-
get implicitlyLoadedAfterOneOf() {
|
|
940
|
-
return $__namespace.utils.getList(2, $__namespace.TextList, this);
|
|
941
|
-
}
|
|
942
|
-
_hasImplicitlyLoadedAfterOneOf() {
|
|
943
|
-
return !$__namespace.utils.isNull($__namespace.utils.getPointer(2, this));
|
|
944
|
-
}
|
|
945
|
-
_initImplicitlyLoadedAfterOneOf(length) {
|
|
946
|
-
return $__namespace.utils.initList(2, $__namespace.TextList, length, this);
|
|
947
|
-
}
|
|
948
|
-
set implicitlyLoadedAfterOneOf(value) {
|
|
949
|
-
$__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(2, this));
|
|
950
|
-
}
|
|
951
|
-
/**
|
|
952
|
-
* The signature preservation mode for the file.
|
|
953
|
-
*
|
|
954
|
-
*/
|
|
955
|
-
get importer() {
|
|
956
|
-
return $__namespace.utils.getText(3, this);
|
|
957
|
-
}
|
|
958
|
-
set importer(value) {
|
|
959
|
-
$__namespace.utils.setText(3, value, this);
|
|
960
|
-
}
|
|
961
|
-
get preserveSignature() {
|
|
962
|
-
return $__namespace.utils.getUint16(0, this);
|
|
963
|
-
}
|
|
964
|
-
set preserveSignature(value) {
|
|
965
|
-
$__namespace.utils.setUint16(0, value, this);
|
|
966
|
-
}
|
|
967
|
-
toString() {
|
|
968
|
-
return "ChunkData_" + super.toString();
|
|
969
|
-
}
|
|
970
|
-
};
|
|
971
|
-
var PrebuiltData = class extends $__namespace.Struct {
|
|
972
|
-
static {
|
|
973
|
-
chunkSHUYVCID_js.__name(this, "PrebuiltData");
|
|
974
|
-
}
|
|
975
|
-
static _capnp = {
|
|
976
|
-
displayName: "PrebuiltData",
|
|
977
|
-
id: "c5b1a6ca696328ee",
|
|
978
|
-
size: new $__namespace.ObjectSize(0, 4)
|
|
979
|
-
};
|
|
980
|
-
/**
|
|
981
|
-
* An additional name for the file.
|
|
982
|
-
*
|
|
983
|
-
*/
|
|
984
|
-
get id() {
|
|
985
|
-
return $__namespace.utils.getText(0, this);
|
|
986
|
-
}
|
|
987
|
-
set id(value) {
|
|
988
|
-
$__namespace.utils.setText(0, value, this);
|
|
989
|
-
}
|
|
990
|
-
/**
|
|
991
|
-
* The file exports.
|
|
992
|
-
*
|
|
993
|
-
*/
|
|
994
|
-
get name() {
|
|
995
|
-
return $__namespace.utils.getText(1, this);
|
|
996
|
-
}
|
|
997
|
-
set name(value) {
|
|
998
|
-
$__namespace.utils.setText(1, value, this);
|
|
999
|
-
}
|
|
1000
|
-
_adoptExports(value) {
|
|
1001
|
-
$__namespace.utils.adopt(value, $__namespace.utils.getPointer(2, this));
|
|
1002
|
-
}
|
|
1003
|
-
_disownExports() {
|
|
1004
|
-
return $__namespace.utils.disown(this.exports);
|
|
1005
|
-
}
|
|
1006
|
-
/**
|
|
1007
|
-
* The source map for the file.
|
|
1008
|
-
*
|
|
1009
|
-
*/
|
|
1010
|
-
get exports() {
|
|
1011
|
-
return $__namespace.utils.getList(2, $__namespace.TextList, this);
|
|
1012
|
-
}
|
|
1013
|
-
_hasExports() {
|
|
1014
|
-
return !$__namespace.utils.isNull($__namespace.utils.getPointer(2, this));
|
|
1015
|
-
}
|
|
1016
|
-
_initExports(length) {
|
|
1017
|
-
return $__namespace.utils.initList(2, $__namespace.TextList, length, this);
|
|
1018
|
-
}
|
|
1019
|
-
set exports(value) {
|
|
1020
|
-
$__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(2, this));
|
|
1021
|
-
}
|
|
1022
|
-
get map() {
|
|
1023
|
-
return $__namespace.utils.getText(3, this);
|
|
1024
|
-
}
|
|
1025
|
-
set map(value) {
|
|
1026
|
-
$__namespace.utils.setText(3, value, this);
|
|
1027
|
-
}
|
|
1028
|
-
toString() {
|
|
1029
|
-
return "PrebuiltData_" + super.toString();
|
|
1030
|
-
}
|
|
1031
|
-
};
|
|
1032
|
-
var AssetData = class extends $__namespace.Struct {
|
|
1033
|
-
static {
|
|
1034
|
-
chunkSHUYVCID_js.__name(this, "AssetData");
|
|
1035
|
-
}
|
|
1036
|
-
static _capnp = {
|
|
1037
|
-
displayName: "AssetData",
|
|
1038
|
-
id: "da660c6c1fa4c830",
|
|
1039
|
-
size: new $__namespace.ObjectSize(8, 3)
|
|
1040
|
-
};
|
|
1041
|
-
/**
|
|
1042
|
-
* An additional name for the file.
|
|
1043
|
-
*
|
|
1044
|
-
*/
|
|
1045
|
-
get id() {
|
|
1046
|
-
return $__namespace.utils.getText(0, this);
|
|
1047
|
-
}
|
|
1048
|
-
set id(value) {
|
|
1049
|
-
$__namespace.utils.setText(0, value, this);
|
|
1050
|
-
}
|
|
1051
|
-
/**
|
|
1052
|
-
* Indicates whether the file needs a code reference.
|
|
1053
|
-
*
|
|
1054
|
-
*/
|
|
1055
|
-
get name() {
|
|
1056
|
-
return $__namespace.utils.getText(1, this);
|
|
1057
|
-
}
|
|
1058
|
-
set name(value) {
|
|
1059
|
-
$__namespace.utils.setText(1, value, this);
|
|
1060
|
-
}
|
|
1061
|
-
/**
|
|
1062
|
-
* The original file name before any transformations.
|
|
1063
|
-
*
|
|
1064
|
-
*/
|
|
1065
|
-
get needsCodeReference() {
|
|
1066
|
-
return $__namespace.utils.getBit(0, this);
|
|
1067
|
-
}
|
|
1068
|
-
set needsCodeReference(value) {
|
|
1069
|
-
$__namespace.utils.setBit(0, value, this);
|
|
1070
|
-
}
|
|
1071
|
-
get originalFileName() {
|
|
1072
|
-
return $__namespace.utils.getText(2, this);
|
|
1073
|
-
}
|
|
1074
|
-
set originalFileName(value) {
|
|
1075
|
-
$__namespace.utils.setText(2, value, this);
|
|
1076
|
-
}
|
|
1077
|
-
toString() {
|
|
1078
|
-
return "AssetData_" + super.toString();
|
|
1079
|
-
}
|
|
1080
|
-
};
|
|
1081
901
|
var FileId = class extends $__namespace.Struct {
|
|
1082
902
|
static {
|
|
1083
903
|
chunkSHUYVCID_js.__name(this, "FileId");
|
|
@@ -1143,14 +963,11 @@ var FileSystem = class _FileSystem extends $__namespace.Struct {
|
|
|
1143
963
|
static _capnp = {
|
|
1144
964
|
displayName: "FileSystem",
|
|
1145
965
|
id: "ae0c23d43e56abcf",
|
|
1146
|
-
size: new $__namespace.ObjectSize(0,
|
|
966
|
+
size: new $__namespace.ObjectSize(0, 3)
|
|
1147
967
|
};
|
|
1148
968
|
static _Ids;
|
|
1149
969
|
static _Files;
|
|
1150
970
|
static _Metadata;
|
|
1151
|
-
static _Assets;
|
|
1152
|
-
static _Chunks;
|
|
1153
|
-
static _Prebuilt;
|
|
1154
971
|
_adoptIds(value) {
|
|
1155
972
|
$__namespace.utils.adopt(value, $__namespace.utils.getPointer(0, this));
|
|
1156
973
|
}
|
|
@@ -1205,60 +1022,6 @@ var FileSystem = class _FileSystem extends $__namespace.Struct {
|
|
|
1205
1022
|
set metadata(value) {
|
|
1206
1023
|
$__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(2, this));
|
|
1207
1024
|
}
|
|
1208
|
-
_adoptAssets(value) {
|
|
1209
|
-
$__namespace.utils.adopt(value, $__namespace.utils.getPointer(3, this));
|
|
1210
|
-
}
|
|
1211
|
-
_disownAssets() {
|
|
1212
|
-
return $__namespace.utils.disown(this.assets);
|
|
1213
|
-
}
|
|
1214
|
-
get assets() {
|
|
1215
|
-
return $__namespace.utils.getList(3, _FileSystem._Assets, this);
|
|
1216
|
-
}
|
|
1217
|
-
_hasAssets() {
|
|
1218
|
-
return !$__namespace.utils.isNull($__namespace.utils.getPointer(3, this));
|
|
1219
|
-
}
|
|
1220
|
-
_initAssets(length) {
|
|
1221
|
-
return $__namespace.utils.initList(3, _FileSystem._Assets, length, this);
|
|
1222
|
-
}
|
|
1223
|
-
set assets(value) {
|
|
1224
|
-
$__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(3, this));
|
|
1225
|
-
}
|
|
1226
|
-
_adoptChunks(value) {
|
|
1227
|
-
$__namespace.utils.adopt(value, $__namespace.utils.getPointer(4, this));
|
|
1228
|
-
}
|
|
1229
|
-
_disownChunks() {
|
|
1230
|
-
return $__namespace.utils.disown(this.chunks);
|
|
1231
|
-
}
|
|
1232
|
-
get chunks() {
|
|
1233
|
-
return $__namespace.utils.getList(4, _FileSystem._Chunks, this);
|
|
1234
|
-
}
|
|
1235
|
-
_hasChunks() {
|
|
1236
|
-
return !$__namespace.utils.isNull($__namespace.utils.getPointer(4, this));
|
|
1237
|
-
}
|
|
1238
|
-
_initChunks(length) {
|
|
1239
|
-
return $__namespace.utils.initList(4, _FileSystem._Chunks, length, this);
|
|
1240
|
-
}
|
|
1241
|
-
set chunks(value) {
|
|
1242
|
-
$__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(4, this));
|
|
1243
|
-
}
|
|
1244
|
-
_adoptPrebuilt(value) {
|
|
1245
|
-
$__namespace.utils.adopt(value, $__namespace.utils.getPointer(5, this));
|
|
1246
|
-
}
|
|
1247
|
-
_disownPrebuilt() {
|
|
1248
|
-
return $__namespace.utils.disown(this.prebuilt);
|
|
1249
|
-
}
|
|
1250
|
-
get prebuilt() {
|
|
1251
|
-
return $__namespace.utils.getList(5, _FileSystem._Prebuilt, this);
|
|
1252
|
-
}
|
|
1253
|
-
_hasPrebuilt() {
|
|
1254
|
-
return !$__namespace.utils.isNull($__namespace.utils.getPointer(5, this));
|
|
1255
|
-
}
|
|
1256
|
-
_initPrebuilt(length) {
|
|
1257
|
-
return $__namespace.utils.initList(5, _FileSystem._Prebuilt, length, this);
|
|
1258
|
-
}
|
|
1259
|
-
set prebuilt(value) {
|
|
1260
|
-
$__namespace.utils.copyFrom(value, $__namespace.utils.getPointer(5, this));
|
|
1261
|
-
}
|
|
1262
1025
|
toString() {
|
|
1263
1026
|
return "FileSystem_" + super.toString();
|
|
1264
1027
|
}
|
|
@@ -1267,9 +1030,6 @@ FileMetadata._Properties = $__namespace.CompositeList(FileMetadata_KeyValuePair)
|
|
|
1267
1030
|
FileSystem._Ids = $__namespace.CompositeList(FileId);
|
|
1268
1031
|
FileSystem._Files = $__namespace.CompositeList(FileData);
|
|
1269
1032
|
FileSystem._Metadata = $__namespace.CompositeList(FileMetadata);
|
|
1270
|
-
FileSystem._Assets = $__namespace.CompositeList(AssetData);
|
|
1271
|
-
FileSystem._Chunks = $__namespace.CompositeList(ChunkData);
|
|
1272
|
-
FileSystem._Prebuilt = $__namespace.CompositeList(PrebuiltData);
|
|
1273
1033
|
|
|
1274
1034
|
// ../powerlines/src/types/fs.ts
|
|
1275
1035
|
var __VFS_PATCH__ = "__VFS_PATCH__";
|
|
@@ -1317,13 +1077,9 @@ function isBufferEncoding(options) {
|
|
|
1317
1077
|
}
|
|
1318
1078
|
chunkSHUYVCID_js.__name(isBufferEncoding, "isBufferEncoding");
|
|
1319
1079
|
function isPowerlinesWriteFileOptions(options) {
|
|
1320
|
-
return !isBufferEncoding(options) && isSetObject.isSetObject(options) &&
|
|
1080
|
+
return !isBufferEncoding(options) && isSetObject.isSetObject(options) && "mode" in options && (options.mode === "fs" || options.mode === "virtual");
|
|
1321
1081
|
}
|
|
1322
1082
|
chunkSHUYVCID_js.__name(isPowerlinesWriteFileOptions, "isPowerlinesWriteFileOptions");
|
|
1323
|
-
function isNodeWriteFileOptions(options) {
|
|
1324
|
-
return !isUndefined.isUndefined(options) && (isBufferEncoding(options) || !isPowerlinesWriteFileOptions(options));
|
|
1325
|
-
}
|
|
1326
|
-
chunkSHUYVCID_js.__name(isNodeWriteFileOptions, "isNodeWriteFileOptions");
|
|
1327
1083
|
function isVirtualFileData(obj) {
|
|
1328
1084
|
return !!(isSetObject.isSetObject(obj) && "code" in obj && obj.code);
|
|
1329
1085
|
}
|
|
@@ -1460,6 +1216,18 @@ function patchFS(originalFS, vfs) {
|
|
|
1460
1216
|
};
|
|
1461
1217
|
}
|
|
1462
1218
|
chunkSHUYVCID_js.__name(patchFS, "patchFS");
|
|
1219
|
+
function isValidId(id, prefix = "powerlines") {
|
|
1220
|
+
return id.replace(/^\\0/, "").startsWith(`${prefix.replace(/:$/, "")}`);
|
|
1221
|
+
}
|
|
1222
|
+
chunkSHUYVCID_js.__name(isValidId, "isValidId");
|
|
1223
|
+
function normalizeId(id, prefix = "powerlines") {
|
|
1224
|
+
return `${prefix.replace(/:$/, "")}:${toFilePath(id).replace(new RegExp(`^${prefix.replace(/:$/, "")}:`), "").replace(/^\\0/, "").replace(filePathFns.findFileDotExtensionSafe(toFilePath(id)), "")}`;
|
|
1225
|
+
}
|
|
1226
|
+
chunkSHUYVCID_js.__name(normalizeId, "normalizeId");
|
|
1227
|
+
function normalizePath(path, builtinsPath, prefix = "powerlines") {
|
|
1228
|
+
return isValidId(toFilePath(path), prefix) ? normalizeId(toFilePath(path), prefix).replace(new RegExp(`^${prefix.replace(/:$/, "")}:`), builtinsPath) : toFilePath(path);
|
|
1229
|
+
}
|
|
1230
|
+
chunkSHUYVCID_js.__name(normalizePath, "normalizePath");
|
|
1463
1231
|
var UnifiedFS = class _UnifiedFS extends unionfs.Union {
|
|
1464
1232
|
static {
|
|
1465
1233
|
chunkSHUYVCID_js.__name(this, "UnifiedFS");
|
|
@@ -1636,9 +1404,9 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1636
1404
|
*/
|
|
1637
1405
|
#paths;
|
|
1638
1406
|
/**
|
|
1639
|
-
* A
|
|
1407
|
+
* A cache for module resolution results.
|
|
1640
1408
|
*/
|
|
1641
|
-
#
|
|
1409
|
+
#resolverCache;
|
|
1642
1410
|
/**
|
|
1643
1411
|
* The unified volume that combines the virtual file system with the real file system.
|
|
1644
1412
|
*
|
|
@@ -1673,189 +1441,35 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1673
1441
|
* @returns `true` if the path exists, otherwise `false`.
|
|
1674
1442
|
*/
|
|
1675
1443
|
#existsSync(path) {
|
|
1676
|
-
|
|
1677
|
-
return this.#unifiedFS.virtual.existsSync(formattedPath) || this.#unifiedFS.physical.existsSync(formattedPath) || this.#unifiedFS.resolveFS(path).existsSync(formattedPath);
|
|
1678
|
-
}
|
|
1679
|
-
/**
|
|
1680
|
-
* Builds a regular expression from a string pattern for path matching.
|
|
1681
|
-
*
|
|
1682
|
-
* @param strPattern - The string pattern to convert.
|
|
1683
|
-
* @returns A regular expression for matching paths.
|
|
1684
|
-
*/
|
|
1685
|
-
#buildRegex(strPattern) {
|
|
1686
|
-
const token = "::GLOBSTAR::";
|
|
1687
|
-
return new RegExp(`^${this.formatPath(strPattern).replace(/\*\*/g, token).replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]").replace(new RegExp(token, "g"), ".*")}$`);
|
|
1444
|
+
return this.#unifiedFS.virtual.existsSync(this.#normalizePath(path)) || this.#unifiedFS.physical.existsSync(this.#normalizePath(path)) || this.#unifiedFS.resolveFS(path).existsSync(this.#normalizePath(path));
|
|
1688
1445
|
}
|
|
1689
1446
|
/**
|
|
1690
|
-
*
|
|
1447
|
+
* Normalizes a given module id by resolving it against the built-ins path.
|
|
1691
1448
|
*
|
|
1692
|
-
* @param id - The
|
|
1693
|
-
* @returns The
|
|
1449
|
+
* @param id - The module id to normalize.
|
|
1450
|
+
* @returns The normalized module id.
|
|
1694
1451
|
*/
|
|
1695
|
-
#
|
|
1696
|
-
|
|
1697
|
-
return `${this.#context.config.output.builtinPrefix}:${formattedId.replace(new RegExp(`^${this.#context.config.output.builtinPrefix}:`), "").replace(/^\\0/, "").replace(filePathFns.findFileDotExtensionSafe(formattedId), "")}`;
|
|
1698
|
-
}
|
|
1699
|
-
/**
|
|
1700
|
-
* Resolves an id parameter to a corresponding virtual file path in the virtual file system (VFS).
|
|
1701
|
-
*
|
|
1702
|
-
* @param id - The id to resolve.
|
|
1703
|
-
* @returns The resolved file id if it exists, otherwise undefined.
|
|
1704
|
-
*/
|
|
1705
|
-
#resolveId(id) {
|
|
1706
|
-
if (this.#ids[this.#formatId(id)]) {
|
|
1707
|
-
return this.#ids[this.#formatId(id)] || false;
|
|
1708
|
-
}
|
|
1709
|
-
return false;
|
|
1710
|
-
}
|
|
1711
|
-
/**
|
|
1712
|
-
* Resolves a path parameter to a corresponding virtual file path in the virtual file system (VFS).
|
|
1713
|
-
*
|
|
1714
|
-
* @param path - The path to resolve.
|
|
1715
|
-
* @param options - Optional parameters for resolving the path.
|
|
1716
|
-
* @returns The resolved file path if it exists, otherwise undefined.
|
|
1717
|
-
*/
|
|
1718
|
-
#resolvePath(path, options = {}) {
|
|
1719
|
-
if (isType.isAbsolutePath(path)) {
|
|
1720
|
-
if (this.#existsSync(path)) {
|
|
1721
|
-
return path;
|
|
1722
|
-
}
|
|
1723
|
-
const result = this.#checkVariants(path);
|
|
1724
|
-
if (result) {
|
|
1725
|
-
return result;
|
|
1726
|
-
}
|
|
1727
|
-
}
|
|
1728
|
-
for (const parentPath of this.#resolveParentPaths(path, options.paths)) {
|
|
1729
|
-
const request = joinPaths.joinPaths(parentPath, path);
|
|
1730
|
-
if (this.#existsSync(request)) {
|
|
1731
|
-
return request;
|
|
1732
|
-
}
|
|
1733
|
-
const result = this.#checkVariants(request);
|
|
1734
|
-
if (result) {
|
|
1735
|
-
return result;
|
|
1736
|
-
}
|
|
1737
|
-
}
|
|
1738
|
-
return false;
|
|
1739
|
-
}
|
|
1740
|
-
/**
|
|
1741
|
-
* Resolves parent paths for a given request.
|
|
1742
|
-
*
|
|
1743
|
-
* @param request - The request path to resolve parent paths for.
|
|
1744
|
-
* @param parents - An optional array of parent paths to consider.
|
|
1745
|
-
* @returns An array of resolved parent paths.
|
|
1746
|
-
*/
|
|
1747
|
-
#resolveParentPaths(request, parents = []) {
|
|
1748
|
-
let paths = [
|
|
1749
|
-
this.#context.workspaceConfig.workspaceRoot,
|
|
1750
|
-
joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.projectRoot)
|
|
1751
|
-
];
|
|
1752
|
-
if (this.#context.tsconfig.options.paths) {
|
|
1753
|
-
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) => {
|
|
1754
|
-
if (path && !ret.includes(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, path))) {
|
|
1755
|
-
ret.push(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, path));
|
|
1756
|
-
}
|
|
1757
|
-
return ret;
|
|
1758
|
-
}, paths) : paths;
|
|
1759
|
-
}
|
|
1760
|
-
return paths.reduce((ret, path) => {
|
|
1761
|
-
if (!ret.includes(path)) {
|
|
1762
|
-
ret.push(path);
|
|
1763
|
-
}
|
|
1764
|
-
return ret;
|
|
1765
|
-
}, parents.filter(Boolean).map((p) => this.formatPath(p)));
|
|
1452
|
+
#normalizeId(id) {
|
|
1453
|
+
return normalizeId(id, this.#context.config.output.builtinPrefix);
|
|
1766
1454
|
}
|
|
1767
1455
|
/**
|
|
1768
|
-
*
|
|
1456
|
+
* Normalizes a given path by resolving it against the project root, workspace root, and built-ins path.
|
|
1769
1457
|
*
|
|
1770
|
-
* @param path - The path to
|
|
1458
|
+
* @param path - The path to normalize.
|
|
1459
|
+
* @returns The normalized path.
|
|
1771
1460
|
*/
|
|
1772
|
-
#
|
|
1773
|
-
|
|
1461
|
+
#normalizePath(path) {
|
|
1462
|
+
return normalizePath(path, this.#context.builtinsPath, this.#context.config.output.builtinPrefix);
|
|
1774
1463
|
}
|
|
1775
1464
|
/**
|
|
1776
|
-
*
|
|
1777
|
-
*
|
|
1778
|
-
* @param request - The request path to check.
|
|
1779
|
-
* @param parentPath - An optional parent path to prepend to the request.
|
|
1780
|
-
* @returns The file path if it exists, otherwise false.
|
|
1781
|
-
*/
|
|
1782
|
-
#checkVariants(request, parentPath) {
|
|
1783
|
-
const path = parentPath ? joinPaths.joinPaths(parentPath, request) : request;
|
|
1784
|
-
let file = this.#checkExtensions(path);
|
|
1785
|
-
if (file) {
|
|
1786
|
-
return file;
|
|
1787
|
-
}
|
|
1788
|
-
file = this.#checkIndex(path);
|
|
1789
|
-
if (file) {
|
|
1790
|
-
return file;
|
|
1791
|
-
}
|
|
1792
|
-
return false;
|
|
1793
|
-
}
|
|
1794
|
-
/**
|
|
1795
|
-
* Check if the index file exists in the given request path.
|
|
1796
|
-
*
|
|
1797
|
-
* @param request - The request path to check.
|
|
1798
|
-
* @returns The index file path if it exists, otherwise false.
|
|
1799
|
-
*/
|
|
1800
|
-
#checkIndex(request) {
|
|
1801
|
-
let file = joinPaths.joinPaths(request, "index");
|
|
1802
|
-
if (this.#existsSync(file)) {
|
|
1803
|
-
return file;
|
|
1804
|
-
}
|
|
1805
|
-
file = this.#checkExtensions(file);
|
|
1806
|
-
if (file) {
|
|
1807
|
-
return file;
|
|
1808
|
-
}
|
|
1809
|
-
return false;
|
|
1810
|
-
}
|
|
1811
|
-
/**
|
|
1812
|
-
* Check if the file exists with different extensions.
|
|
1465
|
+
* Builds a regular expression from a string pattern for path matching.
|
|
1813
1466
|
*
|
|
1814
|
-
* @param
|
|
1815
|
-
* @returns
|
|
1467
|
+
* @param path - The string pattern to convert.
|
|
1468
|
+
* @returns A regular expression for matching paths.
|
|
1816
1469
|
*/
|
|
1817
|
-
#
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
return file;
|
|
1821
|
-
}
|
|
1822
|
-
file = `${request}.mts`;
|
|
1823
|
-
if (this.#existsSync(file)) {
|
|
1824
|
-
return file;
|
|
1825
|
-
}
|
|
1826
|
-
file = `${request}.cts`;
|
|
1827
|
-
if (this.#existsSync(file)) {
|
|
1828
|
-
return file;
|
|
1829
|
-
}
|
|
1830
|
-
file = `${request}.tsx`;
|
|
1831
|
-
if (this.#existsSync(file)) {
|
|
1832
|
-
return file;
|
|
1833
|
-
}
|
|
1834
|
-
file = `${request}.js`;
|
|
1835
|
-
if (this.#existsSync(file)) {
|
|
1836
|
-
return file;
|
|
1837
|
-
}
|
|
1838
|
-
file = `${request}.mjs`;
|
|
1839
|
-
if (this.#existsSync(file)) {
|
|
1840
|
-
return file;
|
|
1841
|
-
}
|
|
1842
|
-
file = `${request}.cjs`;
|
|
1843
|
-
if (this.#existsSync(file)) {
|
|
1844
|
-
return file;
|
|
1845
|
-
}
|
|
1846
|
-
file = `${request}.jsx`;
|
|
1847
|
-
if (this.#existsSync(file)) {
|
|
1848
|
-
return file;
|
|
1849
|
-
}
|
|
1850
|
-
file = `${request}.json`;
|
|
1851
|
-
if (this.#existsSync(file)) {
|
|
1852
|
-
return file;
|
|
1853
|
-
}
|
|
1854
|
-
file = `${request}.d.ts`;
|
|
1855
|
-
if (this.#existsSync(file)) {
|
|
1856
|
-
return file;
|
|
1857
|
-
}
|
|
1858
|
-
return false;
|
|
1470
|
+
#buildRegex(path) {
|
|
1471
|
+
const token = "::GLOBSTAR::";
|
|
1472
|
+
return new RegExp(`^${this.#normalizePath(path).replace(/\*\*/g, token).replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]").replace(new RegExp(token, "g"), ".*")}$`);
|
|
1859
1473
|
}
|
|
1860
1474
|
/**
|
|
1861
1475
|
* Creates a virtual file system (VFS) that is backed up to a Cap'n Proto message buffer.
|
|
@@ -1864,8 +1478,8 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1864
1478
|
* @returns A promise that resolves to a new virtual file system instance.
|
|
1865
1479
|
*/
|
|
1866
1480
|
static async create(context) {
|
|
1867
|
-
if (!context.config.skipCache && exists.existsSync(joinPaths.joinPaths(context.
|
|
1868
|
-
const buffer$1 = await buffer.readFileBuffer(joinPaths.joinPaths(context.
|
|
1481
|
+
if (!context.config.skipCache && exists.existsSync(joinPaths.joinPaths(context.dataPath, "fs.bin"))) {
|
|
1482
|
+
const buffer$1 = await buffer.readFileBuffer(joinPaths.joinPaths(context.dataPath, "fs.bin"));
|
|
1869
1483
|
const message2 = new $__namespace.Message(buffer$1, false);
|
|
1870
1484
|
return new _VirtualFileSystem(context, message2.getRoot(FileSystem));
|
|
1871
1485
|
}
|
|
@@ -1879,8 +1493,8 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1879
1493
|
* @returns A new virtual file system instance.
|
|
1880
1494
|
*/
|
|
1881
1495
|
static createSync(context) {
|
|
1882
|
-
if (!context.config.skipCache && exists.existsSync(joinPaths.joinPaths(context.
|
|
1883
|
-
const buffer$1 = buffer.readFileBufferSync(joinPaths.joinPaths(context.
|
|
1496
|
+
if (!context.config.skipCache && exists.existsSync(joinPaths.joinPaths(context.dataPath, "fs.bin"))) {
|
|
1497
|
+
const buffer$1 = buffer.readFileBufferSync(joinPaths.joinPaths(context.dataPath, "fs.bin"));
|
|
1884
1498
|
const message2 = new $__namespace.Message(buffer$1, false);
|
|
1885
1499
|
return new _VirtualFileSystem(context, message2.getRoot(FileSystem));
|
|
1886
1500
|
}
|
|
@@ -1891,19 +1505,43 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1891
1505
|
* A map of file ids to their metadata.
|
|
1892
1506
|
*/
|
|
1893
1507
|
get metadata() {
|
|
1894
|
-
return this.#metadata
|
|
1508
|
+
return new Proxy(this.#metadata, {
|
|
1509
|
+
get: /* @__PURE__ */ chunkSHUYVCID_js.__name((target, prop) => {
|
|
1510
|
+
return target[this.#normalizeId(prop)];
|
|
1511
|
+
}, "get")
|
|
1512
|
+
});
|
|
1895
1513
|
}
|
|
1896
1514
|
/**
|
|
1897
|
-
* A map of
|
|
1515
|
+
* A map of file paths to their module ids.
|
|
1898
1516
|
*/
|
|
1899
1517
|
get ids() {
|
|
1900
|
-
return this.#
|
|
1518
|
+
return new Proxy(this.#paths, {
|
|
1519
|
+
get: /* @__PURE__ */ chunkSHUYVCID_js.__name((target, prop) => {
|
|
1520
|
+
return target[this.#normalizePath(prop)];
|
|
1521
|
+
}, "get")
|
|
1522
|
+
});
|
|
1901
1523
|
}
|
|
1902
1524
|
/**
|
|
1903
|
-
* A map of
|
|
1525
|
+
* A map of module ids to their file paths.
|
|
1904
1526
|
*/
|
|
1905
1527
|
get paths() {
|
|
1906
|
-
return this.#paths
|
|
1528
|
+
return new Proxy(this.#paths, {
|
|
1529
|
+
get: /* @__PURE__ */ chunkSHUYVCID_js.__name((target, prop) => {
|
|
1530
|
+
return target[this.#normalizeId(prop)];
|
|
1531
|
+
}, "get")
|
|
1532
|
+
});
|
|
1533
|
+
}
|
|
1534
|
+
get resolverCache() {
|
|
1535
|
+
if (!this.#resolverCache) {
|
|
1536
|
+
this.#resolverCache = flatCache.create({
|
|
1537
|
+
cacheId: "module-resolution",
|
|
1538
|
+
cacheDir: this.#context.cachePath,
|
|
1539
|
+
ttl: 60 * 60 * 1e3,
|
|
1540
|
+
lruSize: 5e3,
|
|
1541
|
+
persistInterval: 100
|
|
1542
|
+
});
|
|
1543
|
+
}
|
|
1544
|
+
return this.#resolverCache;
|
|
1907
1545
|
}
|
|
1908
1546
|
/**
|
|
1909
1547
|
* Creates a new instance of the {@link VirtualFileSystem}.
|
|
@@ -1948,17 +1586,13 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1948
1586
|
* Check if a path or id corresponds to a virtual file **(does not actually exists on disk)**.
|
|
1949
1587
|
*
|
|
1950
1588
|
* @param pathOrId - The path or id to check.
|
|
1951
|
-
* @param options - Optional parameters for resolving the path.
|
|
1952
1589
|
* @returns Whether the path or id corresponds to a virtual file **(does not actually exists on disk)**.
|
|
1953
1590
|
*/
|
|
1954
|
-
isVirtual(pathOrId, options = {}) {
|
|
1591
|
+
isVirtual(pathOrId, importer, options = {}) {
|
|
1955
1592
|
if (!pathOrId) {
|
|
1956
1593
|
return false;
|
|
1957
1594
|
}
|
|
1958
|
-
const resolvedPath = this.
|
|
1959
|
-
...options,
|
|
1960
|
-
pathType: "file"
|
|
1961
|
-
});
|
|
1595
|
+
const resolvedPath = this.resolveSync(pathOrId, importer, options);
|
|
1962
1596
|
if (!resolvedPath) {
|
|
1963
1597
|
return false;
|
|
1964
1598
|
}
|
|
@@ -1968,17 +1602,13 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
1968
1602
|
* Check if a path or id corresponds to a file written to the file system **(actually exists on disk)**.
|
|
1969
1603
|
*
|
|
1970
1604
|
* @param pathOrId - The path or id to check.
|
|
1971
|
-
* @param options - Optional parameters for resolving the path.
|
|
1972
1605
|
* @returns Whether the path or id corresponds to a file written to the file system **(actually exists on disk)**.
|
|
1973
1606
|
*/
|
|
1974
|
-
isPhysical(pathOrId, options = {}) {
|
|
1607
|
+
isPhysical(pathOrId, importer, options = {}) {
|
|
1975
1608
|
if (!pathOrId) {
|
|
1976
1609
|
return false;
|
|
1977
1610
|
}
|
|
1978
|
-
const resolvedPath = this.
|
|
1979
|
-
...options,
|
|
1980
|
-
pathType: "file"
|
|
1981
|
-
});
|
|
1611
|
+
const resolvedPath = this.resolveSync(pathOrId, importer, options);
|
|
1982
1612
|
if (!resolvedPath) {
|
|
1983
1613
|
return false;
|
|
1984
1614
|
}
|
|
@@ -2000,16 +1630,17 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2000
1630
|
* @param path - The path to create the directory at.
|
|
2001
1631
|
*/
|
|
2002
1632
|
unlinkSync(path, options) {
|
|
2003
|
-
|
|
2004
|
-
if (!this.isFile(formattedPath)) {
|
|
1633
|
+
if (!this.isFile(this.#normalizePath(path))) {
|
|
2005
1634
|
return;
|
|
2006
1635
|
}
|
|
2007
|
-
this.#log(types.LogLevelLabel.TRACE, `Synchronously removing file: ${
|
|
2008
|
-
this.#unifiedFS.resolveFS(path, options).unlinkSync(
|
|
2009
|
-
if (this
|
|
2010
|
-
delete this
|
|
1636
|
+
this.#log(types.LogLevelLabel.TRACE, `Synchronously removing file: ${this.#normalizePath(path)}`);
|
|
1637
|
+
this.#unifiedFS.resolveFS(path, options).unlinkSync(this.#normalizePath(path));
|
|
1638
|
+
if (this.#ids[this.#normalizePath(path)] && this.#metadata[this.#ids[this.#normalizePath(path)]]) {
|
|
1639
|
+
delete this.#metadata[this.#ids[this.#normalizePath(path)]];
|
|
1640
|
+
delete this.#ids[this.#normalizePath(path)];
|
|
1641
|
+
delete this.#paths[this.#normalizeId(path)];
|
|
1642
|
+
this.#resolverCache.delete(this.#normalizePath(path));
|
|
2011
1643
|
}
|
|
2012
|
-
this.#clearResolverCache(formattedPath);
|
|
2013
1644
|
}
|
|
2014
1645
|
/**
|
|
2015
1646
|
* Removes a file in the virtual file system (VFS).
|
|
@@ -2017,19 +1648,17 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2017
1648
|
* @param path - The path to create the directory at.
|
|
2018
1649
|
*/
|
|
2019
1650
|
async unlink(path, options) {
|
|
2020
|
-
|
|
2021
|
-
if (!this.isFile(formattedPath)) {
|
|
1651
|
+
if (!this.isFile(this.#normalizePath(path))) {
|
|
2022
1652
|
return;
|
|
2023
1653
|
}
|
|
2024
|
-
this.#log(types.LogLevelLabel.TRACE, `Removing file: ${
|
|
1654
|
+
this.#log(types.LogLevelLabel.TRACE, `Removing file: ${this.#normalizePath(path)}`);
|
|
2025
1655
|
if (isFunction.isFunction(this.#unifiedFS.resolveFS(path, options).promises.unlink)) {
|
|
2026
|
-
await this.#unifiedFS.resolveFS(path, options).promises.unlink(
|
|
2027
|
-
if (this
|
|
2028
|
-
delete this
|
|
1656
|
+
await this.#unifiedFS.resolveFS(path, options).promises.unlink(this.#normalizePath(path));
|
|
1657
|
+
if (this.#ids[this.#normalizePath(path)] && this.#metadata[this.#ids[this.#normalizePath(path)]]) {
|
|
1658
|
+
delete this.#metadata[this.#ids[this.#normalizePath(path)]];
|
|
2029
1659
|
}
|
|
2030
|
-
this.#clearResolverCache(formattedPath);
|
|
2031
1660
|
} else {
|
|
2032
|
-
this.unlinkSync(
|
|
1661
|
+
this.unlinkSync(this.#normalizePath(path), options);
|
|
2033
1662
|
}
|
|
2034
1663
|
}
|
|
2035
1664
|
/**
|
|
@@ -2039,15 +1668,13 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2039
1668
|
* @param options - Options for creating the directory.
|
|
2040
1669
|
*/
|
|
2041
1670
|
rmdirSync(path, options = {}) {
|
|
2042
|
-
|
|
2043
|
-
if (!this.isDirectory(formattedPath)) {
|
|
1671
|
+
if (!this.isDirectory(this.#normalizePath(path))) {
|
|
2044
1672
|
return;
|
|
2045
1673
|
}
|
|
2046
|
-
this.#log(types.LogLevelLabel.TRACE, `Synchronously removing directory: ${
|
|
2047
|
-
this.#unifiedFS.resolveFS(path, options).rmdirSync(
|
|
1674
|
+
this.#log(types.LogLevelLabel.TRACE, `Synchronously removing directory: ${this.#normalizePath(path)}`);
|
|
1675
|
+
this.#unifiedFS.resolveFS(path, options).rmdirSync(this.#normalizePath(path), defu5__default.default(options, {
|
|
2048
1676
|
recursive: true
|
|
2049
1677
|
}));
|
|
2050
|
-
this.#clearResolverCache(formattedPath);
|
|
2051
1678
|
}
|
|
2052
1679
|
/**
|
|
2053
1680
|
* Removes a directory in the virtual file system (VFS).
|
|
@@ -2057,19 +1684,17 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2057
1684
|
* @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
|
|
2058
1685
|
*/
|
|
2059
1686
|
async rmdir(path, options = {}) {
|
|
2060
|
-
|
|
2061
|
-
if (!this.isDirectory(formattedPath)) {
|
|
1687
|
+
if (!this.isDirectory(this.#normalizePath(path))) {
|
|
2062
1688
|
return;
|
|
2063
1689
|
}
|
|
2064
|
-
this.#log(types.LogLevelLabel.TRACE, `Removing directory: ${
|
|
1690
|
+
this.#log(types.LogLevelLabel.TRACE, `Removing directory: ${this.#normalizePath(path)}`);
|
|
2065
1691
|
if (isFunction.isFunction(this.#unifiedFS.resolveFS(path, options).promises.rm)) {
|
|
2066
|
-
await this.#unifiedFS.resolveFS(path, options).promises.rm(
|
|
1692
|
+
await this.#unifiedFS.resolveFS(path, options).promises.rm(this.#normalizePath(path), defu5__default.default(options, {
|
|
2067
1693
|
force: true,
|
|
2068
1694
|
recursive: true
|
|
2069
1695
|
}));
|
|
2070
|
-
this.#clearResolverCache(formattedPath);
|
|
2071
1696
|
} else {
|
|
2072
|
-
this.rmdirSync(
|
|
1697
|
+
this.rmdirSync(this.#normalizePath(path), defu5__default.default(options ?? {}, {
|
|
2073
1698
|
force: true,
|
|
2074
1699
|
recursive: true
|
|
2075
1700
|
}));
|
|
@@ -2083,11 +1708,11 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2083
1708
|
* @returns A promise that resolves when the file is removed.
|
|
2084
1709
|
*/
|
|
2085
1710
|
async rm(path, options = {}) {
|
|
2086
|
-
this.#log(types.LogLevelLabel.TRACE, `Removing: ${
|
|
2087
|
-
if (this.isDirectory(path)) {
|
|
2088
|
-
return this.rmdir(path, options);
|
|
1711
|
+
this.#log(types.LogLevelLabel.TRACE, `Removing: ${this.#normalizePath(path)}`);
|
|
1712
|
+
if (this.isDirectory(this.#normalizePath(path))) {
|
|
1713
|
+
return this.rmdir(this.#normalizePath(path), options);
|
|
2089
1714
|
}
|
|
2090
|
-
return this.unlink(path, options);
|
|
1715
|
+
return this.unlink(this.#normalizePath(path), options);
|
|
2091
1716
|
}
|
|
2092
1717
|
/**
|
|
2093
1718
|
* Synchronously removes a file or directory in the virtual file system (VFS).
|
|
@@ -2096,11 +1721,11 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2096
1721
|
* @param options - Options for removing the file or directory.
|
|
2097
1722
|
*/
|
|
2098
1723
|
rmSync(path, options = {}) {
|
|
2099
|
-
this.#log(types.LogLevelLabel.TRACE, `Removing: ${
|
|
2100
|
-
if (this.isDirectory(path)) {
|
|
2101
|
-
return this.rmdirSync(path, options);
|
|
1724
|
+
this.#log(types.LogLevelLabel.TRACE, `Removing: ${this.#normalizePath(path)}`);
|
|
1725
|
+
if (this.isDirectory(this.#normalizePath(path))) {
|
|
1726
|
+
return this.rmdirSync(this.#normalizePath(path), options);
|
|
2102
1727
|
}
|
|
2103
|
-
return this.unlinkSync(path, options);
|
|
1728
|
+
return this.unlinkSync(this.#normalizePath(path), options);
|
|
2104
1729
|
}
|
|
2105
1730
|
/**
|
|
2106
1731
|
* Creates a directory in the virtual file system (VFS).
|
|
@@ -2110,9 +1735,9 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2110
1735
|
* @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
|
|
2111
1736
|
*/
|
|
2112
1737
|
mkdirSync(path, options = {}) {
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
1738
|
+
return this.#unifiedFS.resolveFS(this.#normalizePath(path), options).mkdirSync(this.#normalizePath(path), defu5__default.default(omit.omit(options, [
|
|
1739
|
+
"mode"
|
|
1740
|
+
]), {
|
|
2116
1741
|
recursive: true
|
|
2117
1742
|
}));
|
|
2118
1743
|
}
|
|
@@ -2125,17 +1750,19 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2125
1750
|
*/
|
|
2126
1751
|
async mkdir(path, options = {}) {
|
|
2127
1752
|
let result;
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
1753
|
+
if (isFunction.isFunction(this.#unifiedFS.resolveFS(this.#normalizePath(path), options).promises.mkdir)) {
|
|
1754
|
+
result = await this.#unifiedFS.resolveFS(this.#normalizePath(path), options).promises.mkdir(this.#normalizePath(path), defu5__default.default(omit.omit(options, [
|
|
1755
|
+
"mode"
|
|
1756
|
+
]), {
|
|
2131
1757
|
recursive: true
|
|
2132
1758
|
}));
|
|
2133
1759
|
} else {
|
|
2134
|
-
result = this.#unifiedFS.resolveFS(
|
|
1760
|
+
result = this.#unifiedFS.resolveFS(this.#normalizePath(path), options).mkdirSync(this.#normalizePath(path), defu5__default.default(omit.omit(options, [
|
|
1761
|
+
"mode"
|
|
1762
|
+
]), {
|
|
2135
1763
|
recursive: true
|
|
2136
1764
|
}));
|
|
2137
1765
|
}
|
|
2138
|
-
this.#clearResolverCache(filePath);
|
|
2139
1766
|
return result;
|
|
2140
1767
|
}
|
|
2141
1768
|
/**
|
|
@@ -2147,17 +1774,15 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2147
1774
|
async glob(patterns) {
|
|
2148
1775
|
const results = [];
|
|
2149
1776
|
for (const pattern of toArray.toArray(patterns)) {
|
|
2150
|
-
const normalized = this
|
|
1777
|
+
const normalized = this.#normalizePath(pattern);
|
|
2151
1778
|
if (!/[*?[\]{}]/.test(normalized) && !normalized.includes("**")) {
|
|
2152
|
-
const resolved = this.
|
|
2153
|
-
pathType: "file"
|
|
2154
|
-
});
|
|
1779
|
+
const resolved = this.resolveSync(normalized);
|
|
2155
1780
|
if (resolved && !results.includes(resolved)) {
|
|
2156
1781
|
results.push(resolved);
|
|
2157
1782
|
}
|
|
2158
1783
|
continue;
|
|
2159
1784
|
}
|
|
2160
|
-
const absPattern = isType.isAbsolutePath(normalized) ? normalized : this
|
|
1785
|
+
const absPattern = isType.isAbsolutePath(normalized) ? normalized : this.#normalizePath(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, normalized));
|
|
2161
1786
|
const firstGlobIdx = absPattern.search(/[*?[\]{}]/);
|
|
2162
1787
|
const baseDir = firstGlobIdx === -1 ? filePathFns.findFilePath(absPattern) : absPattern.slice(0, Math.max(0, absPattern.lastIndexOf("/", firstGlobIdx)));
|
|
2163
1788
|
const stack = [
|
|
@@ -2172,7 +1797,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2172
1797
|
continue;
|
|
2173
1798
|
}
|
|
2174
1799
|
for (const entry of entries) {
|
|
2175
|
-
const full = this
|
|
1800
|
+
const full = this.#normalizePath(joinPaths.joinPaths(dir, entry));
|
|
2176
1801
|
let stats;
|
|
2177
1802
|
try {
|
|
2178
1803
|
stats = this.#unifiedFS.lstatSync(full);
|
|
@@ -2184,9 +1809,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2184
1809
|
stack.push(full);
|
|
2185
1810
|
} else if (stats.isFile()) {
|
|
2186
1811
|
if (this.#buildRegex(absPattern).test(full)) {
|
|
2187
|
-
const resolved = this.
|
|
2188
|
-
pathType: "file"
|
|
2189
|
-
});
|
|
1812
|
+
const resolved = this.resolveSync(full);
|
|
2190
1813
|
if (resolved && !results.includes(resolved)) {
|
|
2191
1814
|
results.push(resolved);
|
|
2192
1815
|
}
|
|
@@ -2206,17 +1829,15 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2206
1829
|
globSync(patterns) {
|
|
2207
1830
|
const results = [];
|
|
2208
1831
|
for (const pattern of toArray.toArray(patterns)) {
|
|
2209
|
-
const normalized = this
|
|
1832
|
+
const normalized = this.#normalizePath(pattern);
|
|
2210
1833
|
if (!/[*?[\]{}]/.test(normalized) && !normalized.includes("**")) {
|
|
2211
|
-
const resolved = this.
|
|
2212
|
-
pathType: "file"
|
|
2213
|
-
});
|
|
1834
|
+
const resolved = this.resolveSync(normalized);
|
|
2214
1835
|
if (resolved && !results.includes(resolved)) {
|
|
2215
1836
|
results.push(resolved);
|
|
2216
1837
|
}
|
|
2217
1838
|
continue;
|
|
2218
1839
|
}
|
|
2219
|
-
const absPattern = isType.isAbsolutePath(normalized) ? normalized : this
|
|
1840
|
+
const absPattern = isType.isAbsolutePath(normalized) ? normalized : this.#normalizePath(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, normalized));
|
|
2220
1841
|
const firstGlobIdx = absPattern.search(/[*?[\]{}]/);
|
|
2221
1842
|
const baseDir = firstGlobIdx === -1 ? filePathFns.findFilePath(absPattern) : absPattern.slice(0, Math.max(0, absPattern.lastIndexOf("/", firstGlobIdx)));
|
|
2222
1843
|
const stack = [
|
|
@@ -2231,7 +1852,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2231
1852
|
continue;
|
|
2232
1853
|
}
|
|
2233
1854
|
for (const entry of entries) {
|
|
2234
|
-
const full = this
|
|
1855
|
+
const full = this.#normalizePath(joinPaths.joinPaths(dir, entry));
|
|
2235
1856
|
let stats;
|
|
2236
1857
|
try {
|
|
2237
1858
|
stats = this.#unifiedFS.lstatSync(full);
|
|
@@ -2243,9 +1864,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2243
1864
|
stack.push(full);
|
|
2244
1865
|
} else if (stats.isFile()) {
|
|
2245
1866
|
if (this.#buildRegex(absPattern).test(full)) {
|
|
2246
|
-
const resolved = this.
|
|
2247
|
-
pathType: "file"
|
|
2248
|
-
});
|
|
1867
|
+
const resolved = this.resolveSync(full);
|
|
2249
1868
|
if (resolved && !results.includes(resolved)) {
|
|
2250
1869
|
results.push(resolved);
|
|
2251
1870
|
}
|
|
@@ -2315,21 +1934,15 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2315
1934
|
* @returns A promise that resolves to the contents of the file as a string, or undefined if the file does not exist.
|
|
2316
1935
|
*/
|
|
2317
1936
|
async readFile(pathOrId, options = "utf8") {
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
}
|
|
2321
|
-
const filePath = this.resolve(toFilePath(pathOrId), {
|
|
2322
|
-
pathType: "file"
|
|
2323
|
-
});
|
|
2324
|
-
if (filePath) {
|
|
1937
|
+
const filePath = await this.resolve(pathOrId);
|
|
1938
|
+
if (filePath && this.isFile(filePath)) {
|
|
2325
1939
|
let result;
|
|
2326
1940
|
if (isFunction.isFunction(this.#unifiedFS.resolveFS(filePath).promises.readFile)) {
|
|
2327
1941
|
result = (await this.#unifiedFS.resolveFS(filePath).promises.readFile(filePath, options))?.toString("utf8");
|
|
2328
1942
|
} else {
|
|
2329
1943
|
result = this.#unifiedFS.resolveFS(filePath).readFileSync(filePath, options);
|
|
2330
1944
|
}
|
|
2331
|
-
|
|
2332
|
-
return content;
|
|
1945
|
+
return isBuffer.isBuffer(result) ? bufferToString.bufferToString(result) : result;
|
|
2333
1946
|
}
|
|
2334
1947
|
return void 0;
|
|
2335
1948
|
}
|
|
@@ -2340,16 +1953,10 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2340
1953
|
* @returns The contents of the file as a string, or undefined if the file does not exist.
|
|
2341
1954
|
*/
|
|
2342
1955
|
readFileSync(pathOrId, options = "utf8") {
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
}
|
|
2346
|
-
const filePath = this.resolve(toFilePath(pathOrId), {
|
|
2347
|
-
pathType: "file"
|
|
2348
|
-
});
|
|
2349
|
-
if (filePath) {
|
|
1956
|
+
const filePath = this.resolveSync(pathOrId);
|
|
1957
|
+
if (filePath && this.isFile(filePath)) {
|
|
2350
1958
|
const result = this.#unifiedFS.resolveFS(filePath).readFileSync(filePath, options);
|
|
2351
|
-
|
|
2352
|
-
return content;
|
|
1959
|
+
return isBuffer.isBuffer(result) ? bufferToString.bufferToString(result) : result;
|
|
2353
1960
|
}
|
|
2354
1961
|
return void 0;
|
|
2355
1962
|
}
|
|
@@ -2362,34 +1969,40 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2362
1969
|
* @returns A promise that resolves when the file is written.
|
|
2363
1970
|
*/
|
|
2364
1971
|
async writeFile(path, data = "", options = "utf8") {
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
await this.mkdir(filePathFns.findFilePath(formattedPath), isPowerlinesWriteFileOptions(options) ? options : void 0);
|
|
1972
|
+
if (!this.isDirectory(filePathFns.findFilePath(this.#normalizePath(path)))) {
|
|
1973
|
+
await this.mkdir(filePathFns.findFilePath(this.#normalizePath(path)), isPowerlinesWriteFileOptions(options) ? options : void 0);
|
|
2368
1974
|
}
|
|
2369
|
-
|
|
1975
|
+
const metadata = isVirtualFileData(data) ? data : {};
|
|
1976
|
+
metadata.id = this.#normalizeId(path);
|
|
1977
|
+
let code = isVirtualFileData(data) ? metadata.code : data;
|
|
2370
1978
|
if ((!isPowerlinesWriteFileOptions(options) || !options.skipFormat) && isSetString.isSetString(code)) {
|
|
2371
|
-
const resolvedConfig = await prettier.resolveConfig(
|
|
1979
|
+
const resolvedConfig = await prettier.resolveConfig(this.#normalizePath(path));
|
|
2372
1980
|
if (resolvedConfig) {
|
|
2373
1981
|
code = await prettier.format(code, {
|
|
2374
|
-
absolutePath:
|
|
1982
|
+
absolutePath: this.#normalizePath(path),
|
|
2375
1983
|
...resolvedConfig
|
|
2376
1984
|
});
|
|
2377
1985
|
}
|
|
2378
1986
|
}
|
|
2379
|
-
const outputMode = this.#unifiedFS.resolveMode(
|
|
2380
|
-
this.#log(types.LogLevelLabel.TRACE, `Writing ${
|
|
2381
|
-
this
|
|
1987
|
+
const outputMode = this.#unifiedFS.resolveMode(this.#normalizePath(path), isPowerlinesWriteFileOptions(options) ? options : void 0);
|
|
1988
|
+
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)})`);
|
|
1989
|
+
this.#metadata[metadata.id] = {
|
|
2382
1990
|
mode: outputMode,
|
|
2383
1991
|
variant: "normal",
|
|
2384
1992
|
timestamp: Date.now(),
|
|
2385
|
-
...
|
|
1993
|
+
...metadata
|
|
2386
1994
|
};
|
|
2387
|
-
this.#
|
|
2388
|
-
|
|
1995
|
+
this.#paths[metadata.id] = this.#normalizePath(path);
|
|
1996
|
+
this.#ids[this.#normalizePath(path)] = metadata.id;
|
|
1997
|
+
const ifs = this.#unifiedFS.resolveFS(this.#normalizePath(path), isPowerlinesWriteFileOptions(options) ? options : void 0);
|
|
2389
1998
|
if (isFunction.isFunction(ifs.promises.writeFile)) {
|
|
2390
|
-
return ifs.promises.writeFile(
|
|
1999
|
+
return ifs.promises.writeFile(this.#normalizePath(path), code, isSetObject.isSetObject(options) ? omit.omit(options, [
|
|
2000
|
+
"mode"
|
|
2001
|
+
]) : "utf8");
|
|
2391
2002
|
}
|
|
2392
|
-
return ifs.writeFileSync(
|
|
2003
|
+
return ifs.writeFileSync(this.#normalizePath(path), code, isSetObject.isSetObject(options) ? omit.omit(options, [
|
|
2004
|
+
"mode"
|
|
2005
|
+
]) : "utf8");
|
|
2393
2006
|
}
|
|
2394
2007
|
/**
|
|
2395
2008
|
* Synchronously writes a file to the virtual file system (VFS).
|
|
@@ -2399,21 +2012,23 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2399
2012
|
* @param options - Optional parameters for writing the file.
|
|
2400
2013
|
*/
|
|
2401
2014
|
writeFileSync(path, data = "", options = "utf8") {
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
}
|
|
2406
|
-
|
|
2407
|
-
const
|
|
2408
|
-
this.#
|
|
2409
|
-
this.
|
|
2015
|
+
if (!this.isDirectory(filePathFns.findFilePath(this.#normalizePath(path)))) {
|
|
2016
|
+
this.mkdirSync(filePathFns.findFilePath(this.#normalizePath(path)), isPowerlinesWriteFileOptions(options) ? options : void 0);
|
|
2017
|
+
}
|
|
2018
|
+
const metadata = isVirtualFileData(data) ? data : {};
|
|
2019
|
+
metadata.id = this.#normalizeId(path);
|
|
2020
|
+
const code = isVirtualFileData(data) ? metadata.code : data;
|
|
2021
|
+
const outputMode = this.#unifiedFS.resolveMode(this.#normalizePath(path), isPowerlinesWriteFileOptions(options) ? options : void 0);
|
|
2022
|
+
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)})`);
|
|
2023
|
+
this.#metadata[metadata.id] = {
|
|
2410
2024
|
mode: outputMode,
|
|
2411
2025
|
variant: "normal",
|
|
2412
2026
|
timestamp: Date.now(),
|
|
2413
|
-
...
|
|
2027
|
+
...metadata
|
|
2414
2028
|
};
|
|
2415
|
-
this.#
|
|
2416
|
-
|
|
2029
|
+
this.#paths[metadata.id] = this.#normalizePath(path);
|
|
2030
|
+
this.#ids[this.#normalizePath(path)] = metadata.id;
|
|
2031
|
+
const writeStream = this.#unifiedFS.resolveFS(this.#normalizePath(path), isPowerlinesWriteFileOptions(options) ? options : void 0).createWriteStream(this.#normalizePath(path));
|
|
2417
2032
|
try {
|
|
2418
2033
|
writeStream.write(code);
|
|
2419
2034
|
} finally {
|
|
@@ -2427,7 +2042,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2427
2042
|
* @returns `true` if the file exists, otherwise `false`.
|
|
2428
2043
|
*/
|
|
2429
2044
|
existsSync(pathOrId) {
|
|
2430
|
-
return this.
|
|
2045
|
+
return !!this.resolveSync(pathOrId);
|
|
2431
2046
|
}
|
|
2432
2047
|
/**
|
|
2433
2048
|
* Retrieves the metadata of a file in the virtual file system (VFS).
|
|
@@ -2436,7 +2051,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2436
2051
|
* @returns The metadata of the file, or undefined if the file does not exist.
|
|
2437
2052
|
*/
|
|
2438
2053
|
getMetadata(pathOrId) {
|
|
2439
|
-
const resolved = this.
|
|
2054
|
+
const resolved = this.resolveSync(pathOrId);
|
|
2440
2055
|
if (resolved && this.metadata[resolved]) {
|
|
2441
2056
|
return this.metadata[resolved];
|
|
2442
2057
|
}
|
|
@@ -2452,7 +2067,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2452
2067
|
* @returns `true` if the file exists, otherwise `false`.
|
|
2453
2068
|
*/
|
|
2454
2069
|
isFile(pathOrId) {
|
|
2455
|
-
const resolved = this.
|
|
2070
|
+
const resolved = this.resolveSync(pathOrId);
|
|
2456
2071
|
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()));
|
|
2457
2072
|
}
|
|
2458
2073
|
/**
|
|
@@ -2462,7 +2077,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2462
2077
|
* @returns `true` if the directory exists, otherwise `false`.
|
|
2463
2078
|
*/
|
|
2464
2079
|
isDirectory(pathOrId) {
|
|
2465
|
-
const resolved = this.
|
|
2080
|
+
const resolved = this.resolveSync(pathOrId);
|
|
2466
2081
|
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()));
|
|
2467
2082
|
}
|
|
2468
2083
|
/**
|
|
@@ -2472,7 +2087,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2472
2087
|
* @returns A promise that resolves to the file's status information, or false if the file does not exist.
|
|
2473
2088
|
*/
|
|
2474
2089
|
async stat(pathOrId, options) {
|
|
2475
|
-
return this.#unifiedFS.resolveFS(pathOrId).promises.stat(this.resolve(
|
|
2090
|
+
return this.#unifiedFS.resolveFS(pathOrId).promises.stat(await this.resolve(pathOrId) || pathOrId, options);
|
|
2476
2091
|
}
|
|
2477
2092
|
/**
|
|
2478
2093
|
* Synchronously retrieves the status of a file in the virtual file system (VFS).
|
|
@@ -2481,7 +2096,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2481
2096
|
* @returns The file's status information, or false if the file does not exist.
|
|
2482
2097
|
*/
|
|
2483
2098
|
statSync(pathOrId) {
|
|
2484
|
-
return this.#unifiedFS.resolveFS(pathOrId).statSync(this.
|
|
2099
|
+
return this.#unifiedFS.resolveFS(pathOrId).statSync(this.resolveSync(pathOrId) || pathOrId);
|
|
2485
2100
|
}
|
|
2486
2101
|
/**
|
|
2487
2102
|
* Retrieves the status of a symbolic link in the virtual file system (VFS).
|
|
@@ -2490,7 +2105,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2490
2105
|
* @returns A promise that resolves to the symbolic link's status information, or false if the link does not exist.
|
|
2491
2106
|
*/
|
|
2492
2107
|
async lstat(pathOrId, options) {
|
|
2493
|
-
return this.#unifiedFS.resolveFS(pathOrId).promises.lstat(this.resolve(
|
|
2108
|
+
return this.#unifiedFS.resolveFS(pathOrId).promises.lstat(await this.resolve(pathOrId) || pathOrId, options);
|
|
2494
2109
|
}
|
|
2495
2110
|
/**
|
|
2496
2111
|
* Synchronously retrieves the status of a symbolic link in the virtual file system (VFS).
|
|
@@ -2499,7 +2114,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2499
2114
|
* @returns The symbolic link's status information, or false if the link does not exist.
|
|
2500
2115
|
*/
|
|
2501
2116
|
lstatSync(pathOrId, options) {
|
|
2502
|
-
return this.#unifiedFS.resolveFS(pathOrId).lstatSync(this.
|
|
2117
|
+
return this.#unifiedFS.resolveFS(pathOrId).lstatSync(this.resolveSync(pathOrId) || pathOrId, options);
|
|
2503
2118
|
}
|
|
2504
2119
|
/**
|
|
2505
2120
|
* Resolves a path or ID to its real path in the virtual file system (VFS).
|
|
@@ -2508,52 +2123,113 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2508
2123
|
* @returns The resolved real path if it exists, otherwise undefined.
|
|
2509
2124
|
*/
|
|
2510
2125
|
realpathSync(pathOrId) {
|
|
2511
|
-
const filePath = this.
|
|
2126
|
+
const filePath = this.resolveSync(pathOrId);
|
|
2512
2127
|
if (!filePath) {
|
|
2513
|
-
throw new Error(`File not found: ${
|
|
2128
|
+
throw new Error(`File not found: ${pathOrId}`);
|
|
2514
2129
|
}
|
|
2515
2130
|
return filePath;
|
|
2516
2131
|
}
|
|
2517
2132
|
/**
|
|
2518
|
-
*
|
|
2133
|
+
* A helper function to resolve modules in the virtual file system (VFS).
|
|
2519
2134
|
*
|
|
2520
|
-
* @
|
|
2521
|
-
*
|
|
2522
|
-
*
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2135
|
+
* @remarks
|
|
2136
|
+
* This function can be used to resolve modules relative to the project root directory.
|
|
2137
|
+
*
|
|
2138
|
+
* @example
|
|
2139
|
+
* ```ts
|
|
2140
|
+
* const resolved = await context.resolvePath("some-module", "/path/to/importer");
|
|
2141
|
+
* ```
|
|
2142
|
+
*
|
|
2143
|
+
* @param id - The module to resolve.
|
|
2144
|
+
* @param importer - An optional path to the importer module.
|
|
2145
|
+
* @param options - Additional resolution options.
|
|
2146
|
+
* @returns A promise that resolves to the resolved module path.
|
|
2147
|
+
*/
|
|
2148
|
+
async resolve(id, importer, options = {}) {
|
|
2149
|
+
let result = this.resolverCache.get(this.#normalizeId(id));
|
|
2150
|
+
if (result) {
|
|
2151
|
+
return result;
|
|
2533
2152
|
}
|
|
2153
|
+
result = this.paths[this.#normalizeId(id)];
|
|
2534
2154
|
if (!result) {
|
|
2535
|
-
|
|
2155
|
+
const paths = options.paths ?? [];
|
|
2156
|
+
if (importer && !paths.includes(importer)) {
|
|
2157
|
+
paths.push(importer);
|
|
2158
|
+
}
|
|
2159
|
+
paths.push(this.#context.workspaceConfig.workspaceRoot);
|
|
2160
|
+
paths.push(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.projectRoot));
|
|
2161
|
+
paths.push(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.sourceRoot));
|
|
2162
|
+
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)));
|
|
2163
|
+
for (const combination of resolve.getResolutionCombinations(id, {
|
|
2164
|
+
paths
|
|
2165
|
+
})) {
|
|
2166
|
+
if (this.#existsSync(combination)) {
|
|
2167
|
+
result = combination;
|
|
2168
|
+
}
|
|
2169
|
+
}
|
|
2170
|
+
try {
|
|
2171
|
+
result = await resolve.resolve(id, {
|
|
2172
|
+
paths
|
|
2173
|
+
});
|
|
2174
|
+
} catch {
|
|
2175
|
+
}
|
|
2536
2176
|
}
|
|
2537
|
-
if (result
|
|
2538
|
-
|
|
2177
|
+
if (result) {
|
|
2178
|
+
result = correctPath.toAbsolutePath(append.appendPath(result, this.#context.config.projectRoot), this.#context.workspaceConfig.workspaceRoot);
|
|
2179
|
+
this.resolverCache.set(this.#normalizeId(id), result);
|
|
2539
2180
|
}
|
|
2540
|
-
this.#cachedResolver.set(resolverKey, result);
|
|
2541
2181
|
return result;
|
|
2542
2182
|
}
|
|
2543
2183
|
/**
|
|
2544
|
-
*
|
|
2184
|
+
* A synchronous helper function to resolve modules using the Jiti resolver
|
|
2185
|
+
*
|
|
2186
|
+
* @remarks
|
|
2187
|
+
* This function can be used to resolve modules relative to the project root directory.
|
|
2545
2188
|
*
|
|
2546
|
-
* @
|
|
2547
|
-
*
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2189
|
+
* @example
|
|
2190
|
+
* ```ts
|
|
2191
|
+
* const resolvedPath = context.resolveSync("some-module", "/path/to/importer");
|
|
2192
|
+
* ```
|
|
2193
|
+
*
|
|
2194
|
+
* @param id - The module to resolve.
|
|
2195
|
+
* @param importer - An optional path to the importer module.
|
|
2196
|
+
* @param options - Additional resolution options.
|
|
2197
|
+
* @returns The resolved module path.
|
|
2198
|
+
*/
|
|
2199
|
+
resolveSync(id, importer, options = {}) {
|
|
2200
|
+
let result = this.resolverCache.get(this.#normalizeId(id));
|
|
2201
|
+
if (result) {
|
|
2202
|
+
return result;
|
|
2203
|
+
}
|
|
2204
|
+
result = this.paths[this.#normalizeId(id)];
|
|
2205
|
+
if (!result) {
|
|
2206
|
+
const paths = options.paths ?? [];
|
|
2207
|
+
if (importer && !paths.includes(importer)) {
|
|
2208
|
+
paths.push(importer);
|
|
2209
|
+
}
|
|
2210
|
+
paths.push(this.#context.workspaceConfig.workspaceRoot);
|
|
2211
|
+
paths.push(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.projectRoot));
|
|
2212
|
+
paths.push(joinPaths.joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.sourceRoot));
|
|
2213
|
+
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)));
|
|
2214
|
+
for (const combination of resolve.getResolutionCombinations(id, {
|
|
2215
|
+
paths
|
|
2216
|
+
})) {
|
|
2217
|
+
if (this.#existsSync(combination)) {
|
|
2218
|
+
result = combination;
|
|
2219
|
+
}
|
|
2220
|
+
}
|
|
2221
|
+
try {
|
|
2222
|
+
result = resolve.resolveSync(id, {
|
|
2223
|
+
paths
|
|
2224
|
+
});
|
|
2225
|
+
} catch {
|
|
2226
|
+
}
|
|
2555
2227
|
}
|
|
2556
|
-
|
|
2228
|
+
if (result) {
|
|
2229
|
+
result = correctPath.toAbsolutePath(append.appendPath(result, this.#context.config.projectRoot), this.#context.workspaceConfig.workspaceRoot);
|
|
2230
|
+
this.resolverCache.set(this.#normalizeId(id), result);
|
|
2231
|
+
}
|
|
2232
|
+
return result;
|
|
2557
2233
|
}
|
|
2558
2234
|
/**
|
|
2559
2235
|
* Disposes of the virtual file system (VFS) by saving its state to disk.
|
|
@@ -2562,7 +2238,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2562
2238
|
if (!this.#isDisposed) {
|
|
2563
2239
|
this.#isDisposed = true;
|
|
2564
2240
|
this.#log(types.LogLevelLabel.DEBUG, "Disposing virtual file system...");
|
|
2565
|
-
await this.unlink(joinPaths.joinPaths(this.#context.
|
|
2241
|
+
await this.unlink(joinPaths.joinPaths(this.#context.dataPath, "fs.bin"));
|
|
2566
2242
|
const message = new $__namespace.Message();
|
|
2567
2243
|
const fs2 = message.initRoot(FileSystem);
|
|
2568
2244
|
const virtualFS = this.#unifiedFS.toJSON();
|
|
@@ -2571,7 +2247,7 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2571
2247
|
virtualFiles.forEach(([path, code], index) => {
|
|
2572
2248
|
const fd = files.get(index);
|
|
2573
2249
|
fd.path = path;
|
|
2574
|
-
fd.code = code;
|
|
2250
|
+
fd.code = code || "";
|
|
2575
2251
|
});
|
|
2576
2252
|
const ids = fs2._initIds(Object.keys(this.ids).length);
|
|
2577
2253
|
Object.entries(this.ids).forEach(([id, path], index) => {
|
|
@@ -2595,7 +2271,9 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2595
2271
|
});
|
|
2596
2272
|
}
|
|
2597
2273
|
});
|
|
2598
|
-
await buffer.writeFileBuffer(joinPaths.joinPaths(this.#context.
|
|
2274
|
+
await buffer.writeFileBuffer(joinPaths.joinPaths(this.#context.dataPath, "fs.bin"), message.toArrayBuffer());
|
|
2275
|
+
this.#resolverCache.save(true);
|
|
2276
|
+
this.#log(types.LogLevelLabel.DEBUG, "Virtual file system disposed.");
|
|
2599
2277
|
}
|
|
2600
2278
|
}
|
|
2601
2279
|
/**
|
|
@@ -2623,6 +2301,105 @@ var VirtualFileSystem = class _VirtualFileSystem {
|
|
|
2623
2301
|
return this.dispose();
|
|
2624
2302
|
}
|
|
2625
2303
|
};
|
|
2304
|
+
var VirtualFileSystemHost = class VirtualFileSystemHost2 extends tsMorph.InMemoryFileSystemHost {
|
|
2305
|
+
static {
|
|
2306
|
+
chunkSHUYVCID_js.__name(this, "VirtualFileSystemHost");
|
|
2307
|
+
}
|
|
2308
|
+
#fs;
|
|
2309
|
+
constructor(fs2) {
|
|
2310
|
+
super();
|
|
2311
|
+
this.#fs = fs2;
|
|
2312
|
+
}
|
|
2313
|
+
deleteSync(path) {
|
|
2314
|
+
this.#fs.rmSync(path);
|
|
2315
|
+
}
|
|
2316
|
+
readDirSync(dirPath) {
|
|
2317
|
+
return this.#fs.readdirSync(dirPath).reduce((ret, entry) => {
|
|
2318
|
+
const fullPath = this.#fs.resolveSync(join.joinPaths(dirPath, entry));
|
|
2319
|
+
if (fullPath) {
|
|
2320
|
+
ret.push({
|
|
2321
|
+
name: entry,
|
|
2322
|
+
isDirectory: this.#fs.isDirectory(fullPath),
|
|
2323
|
+
isFile: this.#fs.isFile(fullPath),
|
|
2324
|
+
isSymlink: false
|
|
2325
|
+
});
|
|
2326
|
+
}
|
|
2327
|
+
return ret;
|
|
2328
|
+
}, []);
|
|
2329
|
+
}
|
|
2330
|
+
async readFile(filePath) {
|
|
2331
|
+
if (!this.#fs.existsSync(filePath)) {
|
|
2332
|
+
throw new Error(`File not found: '${filePath}'. Please check the path and try again.`);
|
|
2333
|
+
}
|
|
2334
|
+
return await this.#fs.readFile(filePath);
|
|
2335
|
+
}
|
|
2336
|
+
readFileSync(filePath) {
|
|
2337
|
+
if (!this.#fs.existsSync(filePath)) {
|
|
2338
|
+
throw new Error(`File not found: '${filePath}'. Please check the path and try again.`);
|
|
2339
|
+
}
|
|
2340
|
+
return this.#fs.readFileSync(filePath);
|
|
2341
|
+
}
|
|
2342
|
+
async writeFile(filePath, fileText) {
|
|
2343
|
+
return this.#fs.writeFile(filePath, fileText);
|
|
2344
|
+
}
|
|
2345
|
+
writeFileSync(filePath, fileText) {
|
|
2346
|
+
this.#fs.writeFileSync(filePath, fileText);
|
|
2347
|
+
}
|
|
2348
|
+
async mkdir(dirPath) {
|
|
2349
|
+
await this.#fs.mkdir(dirPath);
|
|
2350
|
+
}
|
|
2351
|
+
mkdirSync(dirPath) {
|
|
2352
|
+
this.#fs.mkdirSync(dirPath);
|
|
2353
|
+
}
|
|
2354
|
+
async move(srcPath, destPath) {
|
|
2355
|
+
await this.#fs.move(srcPath, destPath);
|
|
2356
|
+
}
|
|
2357
|
+
moveSync(srcPath, destPath) {
|
|
2358
|
+
this.#fs.moveSync(srcPath, destPath);
|
|
2359
|
+
}
|
|
2360
|
+
async copy(srcPath, destPath) {
|
|
2361
|
+
await this.#fs.copy(srcPath, destPath);
|
|
2362
|
+
}
|
|
2363
|
+
copySync(srcPath, destPath) {
|
|
2364
|
+
this.#fs.copySync(srcPath, destPath);
|
|
2365
|
+
}
|
|
2366
|
+
async fileExists(filePath) {
|
|
2367
|
+
return this.#fs.isFile(filePath);
|
|
2368
|
+
}
|
|
2369
|
+
fileExistsSync(filePath) {
|
|
2370
|
+
return this.#fs.isFile(filePath);
|
|
2371
|
+
}
|
|
2372
|
+
async directoryExists(dirPath) {
|
|
2373
|
+
return this.#fs.isDirectory(dirPath);
|
|
2374
|
+
}
|
|
2375
|
+
directoryExistsSync(dirPath) {
|
|
2376
|
+
return this.#fs.isDirectory(dirPath);
|
|
2377
|
+
}
|
|
2378
|
+
realpathSync(path) {
|
|
2379
|
+
return this.#fs.resolveSync(path) || path;
|
|
2380
|
+
}
|
|
2381
|
+
getCurrentDirectory() {
|
|
2382
|
+
return "/";
|
|
2383
|
+
}
|
|
2384
|
+
async glob(patterns) {
|
|
2385
|
+
return this.#fs.glob(patterns);
|
|
2386
|
+
}
|
|
2387
|
+
globSync(patterns) {
|
|
2388
|
+
return this.#fs.globSync(patterns);
|
|
2389
|
+
}
|
|
2390
|
+
};
|
|
2391
|
+
function createProgram(context, override) {
|
|
2392
|
+
const project = new tsMorph.Project({
|
|
2393
|
+
compilerOptions: {
|
|
2394
|
+
...context.tsconfig.options
|
|
2395
|
+
},
|
|
2396
|
+
tsConfigFilePath: context.tsconfig.tsconfigFilePath,
|
|
2397
|
+
fileSystem: new VirtualFileSystemHost(context.fs),
|
|
2398
|
+
...override
|
|
2399
|
+
});
|
|
2400
|
+
return project;
|
|
2401
|
+
}
|
|
2402
|
+
chunkSHUYVCID_js.__name(createProgram, "createProgram");
|
|
2626
2403
|
|
|
2627
2404
|
// ../powerlines/src/lib/contexts/context.ts
|
|
2628
2405
|
var configCache = /* @__PURE__ */ new WeakMap();
|
|
@@ -2644,6 +2421,8 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
2644
2421
|
#envPaths;
|
|
2645
2422
|
#fs;
|
|
2646
2423
|
#tsconfig;
|
|
2424
|
+
#program;
|
|
2425
|
+
#resolvePatterns = [];
|
|
2647
2426
|
#getConfigProps(config = {}) {
|
|
2648
2427
|
return {
|
|
2649
2428
|
variant: config.build?.variant,
|
|
@@ -2735,7 +2514,7 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
2735
2514
|
*/
|
|
2736
2515
|
get tsconfig() {
|
|
2737
2516
|
if (!this.#tsconfig) {
|
|
2738
|
-
this
|
|
2517
|
+
this.tsconfig = {
|
|
2739
2518
|
tsconfigFilePath: this.config.tsconfig
|
|
2740
2519
|
};
|
|
2741
2520
|
}
|
|
@@ -2746,6 +2525,7 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
2746
2525
|
*/
|
|
2747
2526
|
set tsconfig(value) {
|
|
2748
2527
|
this.#tsconfig = value;
|
|
2528
|
+
this.#resolvePatterns = bundleRequire.tsconfigPathsToRegExp(value?.options?.paths ?? {});
|
|
2749
2529
|
}
|
|
2750
2530
|
/**
|
|
2751
2531
|
* The virtual file system interface for the project
|
|
@@ -2870,6 +2650,106 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
2870
2650
|
return Object.values(this.fs.metadata).filter((meta) => meta && meta.type === "builtin").map((meta) => meta?.id).filter(Boolean);
|
|
2871
2651
|
}
|
|
2872
2652
|
/**
|
|
2653
|
+
* The {@link Project} instance used for type reflection and module manipulation
|
|
2654
|
+
*
|
|
2655
|
+
* @see https://ts-morph.com/
|
|
2656
|
+
*
|
|
2657
|
+
* @remarks
|
|
2658
|
+
* This instance is created lazily on first access.
|
|
2659
|
+
*/
|
|
2660
|
+
get program() {
|
|
2661
|
+
if (!this.#program) {
|
|
2662
|
+
this.#program = createProgram(this, {
|
|
2663
|
+
skipAddingFilesFromTsConfig: true
|
|
2664
|
+
});
|
|
2665
|
+
}
|
|
2666
|
+
return this.#program;
|
|
2667
|
+
}
|
|
2668
|
+
/**
|
|
2669
|
+
* A helper function to resolve modules in the Virtual File System
|
|
2670
|
+
*
|
|
2671
|
+
* @remarks
|
|
2672
|
+
* This function can be used to resolve modules relative to the project root directory.
|
|
2673
|
+
*
|
|
2674
|
+
* @example
|
|
2675
|
+
* ```ts
|
|
2676
|
+
* const resolved = await context.resolve("some-module", "/path/to/importer");
|
|
2677
|
+
* ```
|
|
2678
|
+
*
|
|
2679
|
+
* @param id - The module to resolve.
|
|
2680
|
+
* @param importer - An optional path to the importer module.
|
|
2681
|
+
* @param options - Additional resolution options.
|
|
2682
|
+
* @returns A promise that resolves to the resolved module path.
|
|
2683
|
+
*/
|
|
2684
|
+
async resolveId(id, importer, options = {}) {
|
|
2685
|
+
if (this.fs.isVirtual(id)) {
|
|
2686
|
+
const result = await this.fs.resolve(id, importer, options);
|
|
2687
|
+
if (!result) {
|
|
2688
|
+
return void 0;
|
|
2689
|
+
}
|
|
2690
|
+
return {
|
|
2691
|
+
id: `\0${result}`,
|
|
2692
|
+
external: this.config.projectType !== "application"
|
|
2693
|
+
};
|
|
2694
|
+
}
|
|
2695
|
+
if (this.config.build.skipNodeModulesBundle) {
|
|
2696
|
+
if (bundleRequire.match(id, this.#resolvePatterns) || bundleRequire.match(id, this.config.build.noExternal)) {
|
|
2697
|
+
return void 0;
|
|
2698
|
+
}
|
|
2699
|
+
if (bundleRequire.match(id, this.config.build.external) || id.startsWith("node:")) {
|
|
2700
|
+
return {
|
|
2701
|
+
id,
|
|
2702
|
+
external: true
|
|
2703
|
+
};
|
|
2704
|
+
}
|
|
2705
|
+
if (!/^[A-Z]:[/\\]|^\.{0,2}\/|^\.{1,2}$/.test(id)) {
|
|
2706
|
+
return {
|
|
2707
|
+
id,
|
|
2708
|
+
external: true
|
|
2709
|
+
};
|
|
2710
|
+
}
|
|
2711
|
+
} else {
|
|
2712
|
+
if (bundleRequire.match(id, this.config.build.noExternal)) {
|
|
2713
|
+
return void 0;
|
|
2714
|
+
}
|
|
2715
|
+
if (bundleRequire.match(id, this.config.build.external) || id.startsWith("node:")) {
|
|
2716
|
+
return {
|
|
2717
|
+
id,
|
|
2718
|
+
external: true
|
|
2719
|
+
};
|
|
2720
|
+
}
|
|
2721
|
+
}
|
|
2722
|
+
return void 0;
|
|
2723
|
+
}
|
|
2724
|
+
/**
|
|
2725
|
+
* A helper function to load modules from the Virtual File System
|
|
2726
|
+
*
|
|
2727
|
+
* @remarks
|
|
2728
|
+
* This function can be used to load modules relative to the project root directory.
|
|
2729
|
+
*
|
|
2730
|
+
* @example
|
|
2731
|
+
* ```ts
|
|
2732
|
+
* const module = await context.load("some-module", "/path/to/importer");
|
|
2733
|
+
* ```
|
|
2734
|
+
*
|
|
2735
|
+
* @param id - The module to load.
|
|
2736
|
+
* @returns A promise that resolves to the loaded module.
|
|
2737
|
+
*/
|
|
2738
|
+
async load(id) {
|
|
2739
|
+
const resolvedId = await this.fs.resolve(id);
|
|
2740
|
+
if (!resolvedId) {
|
|
2741
|
+
return void 0;
|
|
2742
|
+
}
|
|
2743
|
+
const code = await this.fs.readFile(resolvedId);
|
|
2744
|
+
if (!code) {
|
|
2745
|
+
return void 0;
|
|
2746
|
+
}
|
|
2747
|
+
return {
|
|
2748
|
+
code,
|
|
2749
|
+
map: null
|
|
2750
|
+
};
|
|
2751
|
+
}
|
|
2752
|
+
/**
|
|
2873
2753
|
* Get the builtin virtual files that exist in the Powerlines virtual file system
|
|
2874
2754
|
*/
|
|
2875
2755
|
async getBuiltins() {
|
|
@@ -3206,6 +3086,24 @@ var PowerlinesContext = class _PowerlinesContext {
|
|
|
3206
3086
|
ret.push(plugin);
|
|
3207
3087
|
return ret;
|
|
3208
3088
|
}, []);
|
|
3089
|
+
if (this.config.tsconfig) {
|
|
3090
|
+
this.config.tsconfig = replacePathTokens(this, this.config.tsconfig);
|
|
3091
|
+
}
|
|
3092
|
+
if (this.config.output.dts) {
|
|
3093
|
+
this.config.output.dts = replacePathTokens(this, this.config.output.dts);
|
|
3094
|
+
}
|
|
3095
|
+
if (this.config.build.polyfill) {
|
|
3096
|
+
this.config.build.polyfill = this.config.build.polyfill.map((polyfill) => replacePathTokens(this, polyfill));
|
|
3097
|
+
}
|
|
3098
|
+
if (this.config.output.assets) {
|
|
3099
|
+
this.config.output.assets = this.config.output.assets.map((asset) => ({
|
|
3100
|
+
...asset,
|
|
3101
|
+
glob: replacePathTokens(this, asset.glob),
|
|
3102
|
+
ignore: asset.ignore ? asset.ignore.map((ignore) => replacePathTokens(this, ignore)) : void 0,
|
|
3103
|
+
input: replacePathTokens(this, asset.input),
|
|
3104
|
+
output: replacePathTokens(this, asset.output)
|
|
3105
|
+
}));
|
|
3106
|
+
}
|
|
3209
3107
|
this.#fs ??= await VirtualFileSystem.create(this);
|
|
3210
3108
|
}
|
|
3211
3109
|
mergeUserConfig(from = {}, into = this.config.userConfig ?? {}) {
|
|
@@ -3635,13 +3533,9 @@ ${context.entry.map((entry) => `- ${entry.input.file || entry.file}${entry.outpu
|
|
|
3635
3533
|
await resolveTsconfig(context);
|
|
3636
3534
|
await installDependencies(context);
|
|
3637
3535
|
await this.callPostHook(context, "configResolved");
|
|
3638
|
-
if (context.config.build.polyfill) {
|
|
3639
|
-
context.config.build.polyfill = context.config.build.polyfill.map((polyfill) => replacePathTokens(context, polyfill));
|
|
3640
|
-
}
|
|
3641
3536
|
context.log(types.LogLevelLabel.TRACE, `Powerlines configuration has been resolved:
|
|
3642
3537
|
|
|
3643
3538
|
${console.formatLogMessage(context.config)}`);
|
|
3644
|
-
context.fs[__VFS_PATCH__]();
|
|
3645
3539
|
await chunk2PYUYDPD_js.writeMetaFile(context);
|
|
3646
3540
|
context.persistedMeta = context.meta;
|
|
3647
3541
|
if (!exists.existsSync(context.cachePath)) {
|
|
@@ -3691,35 +3585,19 @@ ${console.formatLogMessage(context.config)}`);
|
|
|
3691
3585
|
if (!typescriptPath) {
|
|
3692
3586
|
throw new Error("Could not resolve TypeScript package location. Please ensure TypeScript is installed.");
|
|
3693
3587
|
}
|
|
3694
|
-
const files = builtinFilePaths.reduce(
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
ret.
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
joinPaths.joinPaths(typescriptPath, "lib", "lib.esnext.full.d.ts")
|
|
3702
|
-
]);
|
|
3703
|
-
context.log(types.LogLevelLabel.TRACE, "Parsing TypeScript configuration for the Powerlines project.");
|
|
3704
|
-
const resolvedTsconfig = getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.tsconfig.tsconfigFilePath, defu5__default.default({
|
|
3705
|
-
compilerOptions: {
|
|
3706
|
-
strict: false,
|
|
3707
|
-
noEmit: false,
|
|
3708
|
-
declaration: true,
|
|
3709
|
-
declarationMap: false,
|
|
3710
|
-
emitDeclarationOnly: true,
|
|
3711
|
-
skipLibCheck: true
|
|
3588
|
+
const files = builtinFilePaths.reduce(
|
|
3589
|
+
(ret, fileName) => {
|
|
3590
|
+
const formatted = replace.replacePath(fileName, context.workspaceConfig.workspaceRoot);
|
|
3591
|
+
if (!ret.includes(formatted)) {
|
|
3592
|
+
ret.push(formatted);
|
|
3593
|
+
}
|
|
3594
|
+
return ret;
|
|
3712
3595
|
},
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
}, context.config.tsconfigRaw ?? {}));
|
|
3719
|
-
resolvedTsconfig.options.configFilePath = joinPaths.joinPaths(context.workspaceConfig.workspaceRoot, context.tsconfig.tsconfigFilePath);
|
|
3720
|
-
resolvedTsconfig.options.pathsBasePath = context.workspaceConfig.workspaceRoot;
|
|
3721
|
-
resolvedTsconfig.options.suppressOutputPathCheck = true;
|
|
3722
|
-
let generatedTypes = await emitTypes(context, resolvedTsconfig, files);
|
|
3596
|
+
[]
|
|
3597
|
+
// [joinPaths(typescriptPath, "lib", "lib.esnext.full.d.ts")]
|
|
3598
|
+
);
|
|
3599
|
+
context.log(types.LogLevelLabel.TRACE, "Parsing TypeScript configuration for the Powerlines project.");
|
|
3600
|
+
let generatedTypes = await emitTypes(context, files);
|
|
3723
3601
|
context.log(types.LogLevelLabel.TRACE, `Generating TypeScript declaration file in ${context.config.output.dts}.`);
|
|
3724
3602
|
const directives = [];
|
|
3725
3603
|
let result = await this.callPreHook(context, "generateTypes", generatedTypes);
|
|
@@ -3773,7 +3651,6 @@ ${formatTypes(generatedTypes)}
|
|
|
3773
3651
|
}
|
|
3774
3652
|
await this.callPostHook(context, "prepare");
|
|
3775
3653
|
await chunk2PYUYDPD_js.writeMetaFile(context);
|
|
3776
|
-
context.fs[__VFS_REVERT__]();
|
|
3777
3654
|
});
|
|
3778
3655
|
this.context.log(types.LogLevelLabel.INFO, "Powerlines API has been prepared successfully");
|
|
3779
3656
|
}
|