@powerlines/nx 0.10.10 → 0.10.12

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.
Files changed (36) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/{chunk-MCZLD3NY.js → chunk-32RH3DSY.js} +1022 -906
  3. package/dist/{chunk-OUNXRMS7.js → chunk-7SWNXVZN.js} +2 -2
  4. package/dist/{chunk-EOLGFIVC.js → chunk-DKRIOFPB.js} +2 -2
  5. package/dist/{chunk-DVGRVHRD.mjs → chunk-FMYWKI25.mjs} +2 -14
  6. package/dist/{chunk-UMVPNWWR.js → chunk-FZWXH2M7.js} +2 -2
  7. package/dist/{chunk-L5RBARDS.js → chunk-HAP4APOA.js} +3 -3
  8. package/dist/{chunk-Y4AEEMCT.mjs → chunk-IWLY4VEK.mjs} +1 -1
  9. package/dist/{chunk-XO3MCKAF.mjs → chunk-K7X3KSVW.mjs} +1 -1
  10. package/dist/{chunk-NXUUFBCT.js → chunk-KJAIPQKC.js} +2 -2
  11. package/dist/{chunk-ODVN2Q6Y.mjs → chunk-KNIZUAS5.mjs} +1 -1
  12. package/dist/{chunk-UOTRU26N.js → chunk-LTCZN4I4.js} +1 -19
  13. package/dist/{chunk-AO7OQ26C.mjs → chunk-NSFCCGL7.mjs} +1 -1
  14. package/dist/{chunk-QWEMU3V4.mjs → chunk-NSLIDWKJ.mjs} +1 -1
  15. package/dist/{chunk-CYH2EFG7.js → chunk-QJLAFC2D.js} +2 -2
  16. package/dist/{chunk-RJP4IZYY.mjs → chunk-RIB65IPA.mjs} +1 -1
  17. package/dist/{chunk-72SMJRRS.mjs → chunk-WMZ45WVV.mjs} +1049 -933
  18. package/dist/executors.js +12 -12
  19. package/dist/executors.mjs +7 -7
  20. package/dist/index.js +14 -14
  21. package/dist/index.mjs +8 -8
  22. package/dist/src/base/base-executor.js +3 -3
  23. package/dist/src/base/base-executor.mjs +2 -2
  24. package/dist/src/executors/build/executor.js +5 -5
  25. package/dist/src/executors/build/executor.mjs +3 -3
  26. package/dist/src/executors/clean/executor.js +5 -5
  27. package/dist/src/executors/clean/executor.mjs +3 -3
  28. package/dist/src/executors/docs/executor.js +5 -5
  29. package/dist/src/executors/docs/executor.mjs +3 -3
  30. package/dist/src/executors/lint/executor.js +5 -5
  31. package/dist/src/executors/lint/executor.mjs +3 -3
  32. package/dist/src/executors/prepare/executor.js +5 -5
  33. package/dist/src/executors/prepare/executor.mjs +3 -3
  34. package/dist/src/plugin/index.js +3 -3
  35. package/dist/src/plugin/index.mjs +2 -2
  36. package/package.json +7 -7
@@ -1,9 +1,9 @@
1
- import { __VFS_CACHE__, __VFS_RESOLVER__, __VFS_VIRTUAL__, __VFS_UNIFIED__, __VFS_INIT__, __VFS_REVERT__, loadWorkspaceConfig, CACHE_HASH_LENGTH, PROJECT_ROOT_HASH_LENGTH, getPrefixedProjectRootHash, getChecksum, loadUserConfigFile, writeMetaFile } from './chunk-DVGRVHRD.mjs';
1
+ import { loadWorkspaceConfig, CACHE_HASH_LENGTH, PROJECT_ROOT_HASH_LENGTH, getPrefixedProjectRootHash, getChecksum, loadUserConfigFile, writeMetaFile } from './chunk-FMYWKI25.mjs';
2
2
  import { __name } from './chunk-O6YSETKJ.mjs';
3
3
  import { getLogFn, getLogLevel, writeError } from '@storm-software/config-tools/logger';
4
4
  import { withRunExecutor } from '@storm-software/workspace-tools/base/base-executor';
5
5
  import { isError } from '@stryke/type-checks/is-error';
6
- import defu3, { defu } from 'defu';
6
+ import defu2, { defu } from 'defu';
7
7
  import { transformAsync } from '@babel/core';
8
8
  import { formatLogMessage } from '@storm-software/config-tools/logger/console';
9
9
  import { LogLevelLabel } from '@storm-software/config-tools/types';
@@ -15,7 +15,7 @@ import { install } from '@stryke/fs/install';
15
15
  import { listFiles, listFilesSync } from '@stryke/fs/list-files';
16
16
  import { isPackageExists, isPackageListed, doesPackageMatch, getPackageListing } from '@stryke/fs/package-fns';
17
17
  import { resolvePackage } from '@stryke/fs/resolve';
18
- import { joinPaths } from '@stryke/path/join-paths';
18
+ import { joinPaths as joinPaths$1 } from '@stryke/path/join-paths';
19
19
  import { replacePath, replaceExtension } from '@stryke/path/replace';
20
20
  import { isFunction } from '@stryke/type-checks/is-function';
21
21
  import { isNumber } from '@stryke/type-checks/is-number';
@@ -36,28 +36,30 @@ import { getUnique, getUniqueBy } from '@stryke/helpers/get-unique';
36
36
  import { omit } from '@stryke/helpers/omit';
37
37
  import { StormJSON } from '@stryke/json/storm-json';
38
38
  import { appendPath } from '@stryke/path/append';
39
- import { findFilePath, findFileDotExtensionSafe, hasFileExtension, relativePath, findFileName } from '@stryke/path/file-path-fns';
39
+ import { findFileDotExtensionSafe, findFilePath, hasFileExtension, relativePath, findFileName } from '@stryke/path/file-path-fns';
40
40
  import { isAbsolutePath, isAbsolute } from '@stryke/path/is-type';
41
- import { joinPaths as joinPaths$1 } from '@stryke/path/join';
41
+ import { joinPaths } from '@stryke/path/join';
42
42
  import { isNull } from '@stryke/type-checks/is-null';
43
43
  import { isString } from '@stryke/type-checks/is-string';
44
44
  import { uuid } from '@stryke/unique-id/uuid';
45
45
  import { parseAsync } from 'oxc-parser';
46
46
  import { parseTypeDefinition } from '@stryke/convert/parse-type-definition';
47
47
  import { isFile } from '@stryke/fs/is-file';
48
- import { getColor } from '@storm-software/config-tools/utilities/colors';
49
- import { noop } from '@stryke/helpers/noop';
50
- import { isUndefined } from '@stryke/type-checks/is-undefined';
51
- import { createJiti } from 'jiti';
48
+ import * as $ from '@stryke/capnp';
52
49
  import { bufferToString } from '@stryke/convert/buffer-to-string';
53
- import { isParentPath } from '@stryke/path/is-parent-path';
50
+ import { readFileBuffer, readFileBufferSync, writeFileBuffer } from '@stryke/fs/buffer';
54
51
  import { prettyBytes } from '@stryke/string-format/pretty-bytes';
55
52
  import { isBuffer } from '@stryke/type-checks/is-buffer';
56
- import { Volume } from 'memfs';
57
53
  import { Blob } from 'node:buffer';
58
54
  import fs from 'node:fs';
59
55
  import { resolveConfig, format } from 'prettier';
56
+ import { getColor } from '@storm-software/config-tools/utilities/colors';
57
+ import { noop } from '@stryke/helpers/noop';
58
+ import { isUndefined } from '@stryke/type-checks/is-undefined';
59
+ import { isParentPath } from '@stryke/path/is-parent-path';
60
+ import { Volume } from 'memfs/lib/node/volume';
60
61
  import { Union } from 'unionfs';
62
+ import { createJiti } from 'jiti';
61
63
  import { isObject } from '@stryke/type-checks/is-object';
62
64
  import ts2, { createProgram, createCompilerHost, getPreEmitDiagnostics, getLineAndCharacterOfPosition, flattenDiagnosticMessageText } from 'typescript';
63
65
  import { getPackageName, hasPackageVersion, getPackageVersion } from '@stryke/string-format/package';
@@ -72,7 +74,6 @@ import '@stryke/fs/read-file';
72
74
  import 'magic-string';
73
75
  import { defineNuxtModule, addVitePlugin, addWebpackPlugin } from '@nuxt/kit';
74
76
  import '@nuxt/schema';
75
- import * as $ from '@stryke/capnp';
76
77
 
77
78
  function resolveModulePath(nodePath, state) {
78
79
  if (!t.isStringLiteral(nodePath.node)) {
@@ -177,7 +178,7 @@ var moduleResolverBabelPlugin = /* @__PURE__ */ __name((context) => {
177
178
  }, "moduleResolverBabelPlugin");
178
179
  var DEFAULT_ENVIRONMENT = "default";
179
180
  function createEnvironment(name, userConfig) {
180
- return defu3(userConfig.environments?.[name] ?? {}, {
181
+ return defu2(userConfig.environments?.[name] ?? {}, {
181
182
  name,
182
183
  title: userConfig.title || titleCase(userConfig.name),
183
184
  ssr: false,
@@ -220,8 +221,17 @@ function createDefaultEnvironment(userConfig) {
220
221
  return createEnvironment(DEFAULT_ENVIRONMENT, userConfig);
221
222
  }
222
223
  __name(createDefaultEnvironment, "createDefaultEnvironment");
224
+ function replacePathTokens(context, path) {
225
+ if (!path) {
226
+ return path;
227
+ }
228
+ 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("{artifactsPath}", replacePath(context.artifactsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{builtinPath}", replacePath(context.builtinsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{entryPath}", replacePath(context.entryPath, context.workspaceConfig.workspaceRoot));
229
+ }
230
+ __name(replacePathTokens, "replacePathTokens");
231
+
232
+ // ../powerlines/src/lib/entry.ts
223
233
  function resolveEntryInputFile(context, typeDefinition) {
224
- return replacePath(typeDefinition.file, joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot));
234
+ return replacePath(typeDefinition.file, joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot));
225
235
  }
226
236
  __name(resolveEntryInputFile, "resolveEntryInputFile");
227
237
  function resolveEntryInput(context, typeDefinition) {
@@ -232,7 +242,7 @@ function resolveEntryInput(context, typeDefinition) {
232
242
  }
233
243
  __name(resolveEntryInput, "resolveEntryInput");
234
244
  function resolveEntryOutput(context, typeDefinition) {
235
- return replaceExtension(replacePath(replacePath(replacePath(replacePath(replacePath(typeDefinition.file, joinPaths(context.workspaceConfig.workspaceRoot, context.config.sourceRoot)), joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot)), context.config.sourceRoot), context.config.projectRoot), replacePath(context.config.sourceRoot, context.config.projectRoot)));
245
+ return replaceExtension(replacePath(replacePath(replacePath(replacePath(replacePath(typeDefinition.file, joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.sourceRoot)), joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot)), context.config.sourceRoot), context.config.projectRoot), replacePath(context.config.sourceRoot, context.config.projectRoot)));
236
246
  }
237
247
  __name(resolveEntryOutput, "resolveEntryOutput");
238
248
  function resolveEntry(context, typeDefinition) {
@@ -245,7 +255,7 @@ function resolveEntry(context, typeDefinition) {
245
255
  }
246
256
  __name(resolveEntry, "resolveEntry");
247
257
  function resolveEntriesSync(context, typeDefinitions) {
248
- return typeDefinitions.map((typeDefinition) => {
258
+ return typeDefinitions.map((entry) => isString(entry) ? replacePathTokens(context, entry) : replacePathTokens(context, entry.file)).map((typeDefinition) => {
249
259
  const parsed = parseTypeDefinition(typeDefinition);
250
260
  const filePath = appendPath(parsed.file, context.config.projectRoot);
251
261
  if (isFile(filePath)) {
@@ -267,6 +277,232 @@ function getUniqueEntries(entries = []) {
267
277
  }));
268
278
  }
269
279
  __name(getUniqueEntries, "getUniqueEntries");
280
+ BigInt("0xa56c61324b9d6e49");
281
+ var FileMetadata_KeyValuePair = class extends $.Struct {
282
+ static {
283
+ __name(this, "FileMetadata_KeyValuePair");
284
+ }
285
+ static _capnp = {
286
+ displayName: "KeyValuePair",
287
+ id: "eabb26cf58b2a14c",
288
+ size: new $.ObjectSize(0, 2)
289
+ };
290
+ get key() {
291
+ return $.utils.getText(0, this);
292
+ }
293
+ set key(value) {
294
+ $.utils.setText(0, value, this);
295
+ }
296
+ get value() {
297
+ return $.utils.getText(1, this);
298
+ }
299
+ set value(value) {
300
+ $.utils.setText(1, value, this);
301
+ }
302
+ toString() {
303
+ return "FileMetadata_KeyValuePair_" + super.toString();
304
+ }
305
+ };
306
+ var FileMetadata = class _FileMetadata extends $.Struct {
307
+ static {
308
+ __name(this, "FileMetadata");
309
+ }
310
+ static KeyValuePair = FileMetadata_KeyValuePair;
311
+ static _capnp = {
312
+ displayName: "FileMetadata",
313
+ id: "8e2cab5d7e28c7b3",
314
+ size: new $.ObjectSize(0, 4),
315
+ defaultVariant: "normal"
316
+ };
317
+ static _Properties;
318
+ /**
319
+ * The variant of the file.
320
+ *
321
+ */
322
+ get id() {
323
+ return $.utils.getText(0, this);
324
+ }
325
+ set id(value) {
326
+ $.utils.setText(0, value, this);
327
+ }
328
+ /**
329
+ * The output mode of the file.
330
+ *
331
+ */
332
+ get variant() {
333
+ return $.utils.getText(1, this, _FileMetadata._capnp.defaultVariant);
334
+ }
335
+ set variant(value) {
336
+ $.utils.setText(1, value, this);
337
+ }
338
+ /**
339
+ * Additional metadata associated with the file.
340
+ *
341
+ */
342
+ get mode() {
343
+ return $.utils.getText(2, this);
344
+ }
345
+ set mode(value) {
346
+ $.utils.setText(2, value, this);
347
+ }
348
+ _adoptProperties(value) {
349
+ $.utils.adopt(value, $.utils.getPointer(3, this));
350
+ }
351
+ _disownProperties() {
352
+ return $.utils.disown(this.properties);
353
+ }
354
+ get properties() {
355
+ return $.utils.getList(3, _FileMetadata._Properties, this);
356
+ }
357
+ _hasProperties() {
358
+ return !$.utils.isNull($.utils.getPointer(3, this));
359
+ }
360
+ _initProperties(length) {
361
+ return $.utils.initList(3, _FileMetadata._Properties, length, this);
362
+ }
363
+ set properties(value) {
364
+ $.utils.copyFrom(value, $.utils.getPointer(3, this));
365
+ }
366
+ toString() {
367
+ return "FileMetadata_" + super.toString();
368
+ }
369
+ };
370
+ var FileIdentifier = class extends $.Struct {
371
+ static {
372
+ __name(this, "FileIdentifier");
373
+ }
374
+ static _capnp = {
375
+ displayName: "FileIdentifier",
376
+ id: "e12b8732389d7406",
377
+ size: new $.ObjectSize(0, 2)
378
+ };
379
+ /**
380
+ * An additional identifier for the file.
381
+ *
382
+ */
383
+ get path() {
384
+ return $.utils.getText(0, this);
385
+ }
386
+ set path(value) {
387
+ $.utils.setText(0, value, this);
388
+ }
389
+ get id() {
390
+ return $.utils.getText(1, this);
391
+ }
392
+ set id(value) {
393
+ $.utils.setText(1, value, this);
394
+ }
395
+ toString() {
396
+ return "FileIdentifier_" + super.toString();
397
+ }
398
+ };
399
+ var FileData = class extends $.Struct {
400
+ static {
401
+ __name(this, "FileData");
402
+ }
403
+ static _capnp = {
404
+ displayName: "FileData",
405
+ id: "fa6725c8a360f9a2",
406
+ size: new $.ObjectSize(0, 2)
407
+ };
408
+ /**
409
+ * The contents of the file.
410
+ *
411
+ */
412
+ get path() {
413
+ return $.utils.getText(0, this);
414
+ }
415
+ set path(value) {
416
+ $.utils.setText(0, value, this);
417
+ }
418
+ get content() {
419
+ return $.utils.getText(1, this);
420
+ }
421
+ set content(value) {
422
+ $.utils.setText(1, value, this);
423
+ }
424
+ toString() {
425
+ return "FileData_" + super.toString();
426
+ }
427
+ };
428
+ var FileSystemData = class _FileSystemData extends $.Struct {
429
+ static {
430
+ __name(this, "FileSystemData");
431
+ }
432
+ static _capnp = {
433
+ displayName: "FileSystemData",
434
+ id: "aaa72a672ac0732f",
435
+ size: new $.ObjectSize(0, 3)
436
+ };
437
+ static _Ids;
438
+ static _Metadata;
439
+ static _Files;
440
+ _adoptIds(value) {
441
+ $.utils.adopt(value, $.utils.getPointer(0, this));
442
+ }
443
+ _disownIds() {
444
+ return $.utils.disown(this.ids);
445
+ }
446
+ get ids() {
447
+ return $.utils.getList(0, _FileSystemData._Ids, this);
448
+ }
449
+ _hasIds() {
450
+ return !$.utils.isNull($.utils.getPointer(0, this));
451
+ }
452
+ _initIds(length) {
453
+ return $.utils.initList(0, _FileSystemData._Ids, length, this);
454
+ }
455
+ set ids(value) {
456
+ $.utils.copyFrom(value, $.utils.getPointer(0, this));
457
+ }
458
+ _adoptMetadata(value) {
459
+ $.utils.adopt(value, $.utils.getPointer(1, this));
460
+ }
461
+ _disownMetadata() {
462
+ return $.utils.disown(this.metadata);
463
+ }
464
+ get metadata() {
465
+ return $.utils.getList(1, _FileSystemData._Metadata, this);
466
+ }
467
+ _hasMetadata() {
468
+ return !$.utils.isNull($.utils.getPointer(1, this));
469
+ }
470
+ _initMetadata(length) {
471
+ return $.utils.initList(1, _FileSystemData._Metadata, length, this);
472
+ }
473
+ set metadata(value) {
474
+ $.utils.copyFrom(value, $.utils.getPointer(1, this));
475
+ }
476
+ _adoptFiles(value) {
477
+ $.utils.adopt(value, $.utils.getPointer(2, this));
478
+ }
479
+ _disownFiles() {
480
+ return $.utils.disown(this.files);
481
+ }
482
+ get files() {
483
+ return $.utils.getList(2, _FileSystemData._Files, this);
484
+ }
485
+ _hasFiles() {
486
+ return !$.utils.isNull($.utils.getPointer(2, this));
487
+ }
488
+ _initFiles(length) {
489
+ return $.utils.initList(2, _FileSystemData._Files, length, this);
490
+ }
491
+ set files(value) {
492
+ $.utils.copyFrom(value, $.utils.getPointer(2, this));
493
+ }
494
+ toString() {
495
+ return "FileSystemData_" + super.toString();
496
+ }
497
+ };
498
+ FileMetadata._Properties = $.CompositeList(FileMetadata_KeyValuePair);
499
+ FileSystemData._Ids = $.CompositeList(FileIdentifier);
500
+ FileSystemData._Metadata = $.CompositeList(FileMetadata);
501
+ FileSystemData._Files = $.CompositeList(FileData);
502
+
503
+ // ../powerlines/src/types/vfs.ts
504
+ var __VFS_PATCH__ = Symbol("__VFS_PATCH__");
505
+ var __VFS_REVERT__ = Symbol("__VFS_REVERT__");
270
506
  var createLog = /* @__PURE__ */ __name((name, options = {}) => {
271
507
  const logLevel = options.logLevel === null ? LogLevelLabel.SILENT : options.logLevel || LogLevelLabel.INFO;
272
508
  if (logLevel === LogLevelLabel.SILENT) {
@@ -305,96 +541,8 @@ var BADGE_COLORS = [
305
541
  var extendLog = /* @__PURE__ */ __name((logFn, name) => {
306
542
  return (type, ...args) => logFn(type, ` ${chalk5.inverse.hex(BADGE_COLORS[name.split("").map((char) => char.charCodeAt(0)).reduce((ret, charCode) => ret + charCode, 0) % BADGE_COLORS.length] || BADGE_COLORS[0])(` ${titleCase(name)} `)} ${args.join(" ")} `);
307
543
  }, "extendLog");
308
-
309
- // ../powerlines/src/types/commands.ts
310
- var SUPPORTED_COMMANDS = [
311
- "new",
312
- "clean",
313
- "prepare",
314
- "lint",
315
- "test",
316
- "build",
317
- "docs",
318
- "release",
319
- "finalize"
320
- ];
321
-
322
- // ../powerlines/src/plugin-utils/helpers.ts
323
- function isPlugin(value) {
324
- return isSetObject(value) && "name" in value && isSetString(value.name) && (isUndefined(value.applyToEnvironment) || "applyToEnvironment" in value && isFunction(value.applyToEnvironment)) && (isUndefined(value.dedupe) || "dedupe" in value && isFunction(value.dedupe)) && (isUndefined(value.dependsOn) || "dependsOn" in value && Array.isArray(value.dependsOn) && value.dependsOn.every(isPluginConfig)) && SUPPORTED_COMMANDS.every((command) => isUndefined(value[command]) || command in value && (isFunction(value[command]) || isSetObject(value[command]) && "handler" in value[command] && isFunction(value[command].handler)));
325
- }
326
- __name(isPlugin, "isPlugin");
327
- function isPluginConfigObject(value) {
328
- return isSetObject(value) && "plugin" in value && ((isSetString(value.plugin) || isFunction(value.plugin)) && "options" in value && isSetObject(value.options) || isPlugin(value.plugin));
329
- }
330
- __name(isPluginConfigObject, "isPluginConfigObject");
331
- function isPluginConfigTuple(value) {
332
- return Array.isArray(value) && (value.length === 1 || value.length === 2) && ((isSetString(value[0]) || isFunction(value[0])) && value.length > 1 && isSetObject(value[1]) || isPlugin(value[0]));
333
- }
334
- __name(isPluginConfigTuple, "isPluginConfigTuple");
335
- function isPluginConfig(value) {
336
- return isSetString(value) || isFunction(value) || isPlugin(value) || isPluginConfigObject(value) || isPluginConfigTuple(value);
337
- }
338
- __name(isPluginConfig, "isPluginConfig");
339
- function isPluginHookFunction(value) {
340
- return isFunction(value) || isSetObject(value) && "handler" in value && isFunction(value.handler);
341
- }
342
- __name(isPluginHookFunction, "isPluginHookFunction");
343
- function isPluginHookObject(value) {
344
- return isSetObject(value) && "handler" in value && isFunction(value.handler);
345
- }
346
- __name(isPluginHookObject, "isPluginHookObject");
347
- function isPluginHook(value) {
348
- return isPluginHookFunction(value) || isPluginHookObject(value);
349
- }
350
- __name(isPluginHook, "isPluginHook");
351
- function getHookHandler(pluginHook) {
352
- return isFunction(pluginHook) ? pluginHook : pluginHook.handler;
353
- }
354
- __name(getHookHandler, "getHookHandler");
355
- function isHookExternal(hook) {
356
- return hook.startsWith("vite:") || hook.startsWith("esbuild:") || hook.startsWith("rolldown:") || hook.startsWith("rollup:") || hook.startsWith("webpack:") || hook.startsWith("rspack:") || hook.startsWith("farm:");
357
- }
358
- __name(isHookExternal, "isHookExternal");
359
- function checkDedupe(plugin, plugins2) {
360
- return plugin.dedupe === false || plugins2.some((p) => p.dedupe !== false && (isFunction(p.dedupe) && p.dedupe(plugin) || p.name === plugin.name));
361
- }
362
- __name(checkDedupe, "checkDedupe");
363
- function addPluginHook(context, plugin, pluginHook, hooksList) {
364
- if (!checkDedupe(plugin, hooksList.map((hook) => hook.plugin))) {
365
- hooksList.push(isFunction(pluginHook) ? {
366
- plugin,
367
- handler: getHookHandler(pluginHook).bind(context)
368
- } : {
369
- plugin,
370
- ...pluginHook,
371
- handler: getHookHandler(pluginHook).bind(context)
372
- });
373
- }
374
- }
375
- __name(addPluginHook, "addPluginHook");
376
- function resolveOptions(options) {
377
- return defu3(options, {
378
- interopDefault: true,
379
- fsCache: options.mode !== "development" ? joinPaths(options.cacheDir, "jiti") : false,
380
- moduleCache: options.mode !== "development"
381
- });
382
- }
383
- __name(resolveOptions, "resolveOptions");
384
- function createPluginResolver(options) {
385
- return createJiti(joinPaths(options.workspaceRoot, options.projectRoot), resolveOptions({
386
- ...options
387
- }));
388
- }
389
- __name(createPluginResolver, "createPluginResolver");
390
- function createResolver(options) {
391
- const baseResolver = createJiti(joinPaths(options.workspaceRoot, options.projectRoot), resolveOptions(options));
392
- baseResolver.plugin = createPluginResolver(options);
393
- return baseResolver;
394
- }
395
- __name(createResolver, "createResolver");
396
- function isBufferEncoding(options) {
397
- return isSetString(options) || options === null;
544
+ function isBufferEncoding(options) {
545
+ return isSetString(options) || options === null;
398
546
  }
399
547
  __name(isBufferEncoding, "isBufferEncoding");
400
548
  function isPowerlinesWriteFileOptions(options) {
@@ -541,160 +689,71 @@ function patchFS(originalFS, vfs) {
541
689
  };
542
690
  }
543
691
  __name(patchFS, "patchFS");
544
- var VirtualFileSystem = class {
692
+ var UnifiedFS = class _UnifiedFS extends Union {
545
693
  static {
546
- __name(this, "VirtualFileSystem");
694
+ __name(this, "UnifiedFS");
547
695
  }
548
696
  /**
549
697
  * The internal map of virtual files.
550
698
  */
551
- #meta = {};
552
- /**
553
- * A map of unique identifiers to their virtual file paths.
554
- */
555
- #ids = {};
556
- /**
557
- * A map of virtual file paths to their underlying file content.
558
- */
559
- #cachedFS = /* @__PURE__ */ new Map();
560
- /**
561
- * A map of virtual file paths to their underlying file content.
562
- */
563
- #cachedResolver = /* @__PURE__ */ new Map();
564
- /**
565
- * The internal map of virtual files.
566
- */
567
699
  #virtualFS = new Volume();
568
700
  /**
569
701
  * The physical file system.
570
702
  */
571
- #fs = cloneFS(fs);
572
- /**
573
- * The unified volume that combines the virtual file system with the real file system.
574
- *
575
- * @remarks
576
- * This volume allows for seamless access to both virtual and real files.
577
- */
578
- #unifiedFS = new Union();
579
- /**
580
- * Indicator specifying if the file system module is patched
581
- */
582
- #isPatched = false;
583
- /**
584
- * Function to revert require patch
585
- */
586
- #revert;
703
+ #physicalFS = cloneFS(fs);
587
704
  /**
588
- * The context of the virtual file system.
705
+ * The context of the unified file system.
589
706
  */
590
707
  #context;
591
- /**
592
- * The file system's logging function.
593
- */
594
- #log;
595
- /**
596
- * Checks if a path exists in the virtual file system (VFS).
597
- *
598
- * @param path - The path to check.
599
- * @returns `true` if the path exists, otherwise `false`.
600
- */
601
- #existsSync(path) {
602
- const formattedPath = this.formatPath(path);
603
- return this.#virtualFS.existsSync(formattedPath) || this.#fs.existsSync(formattedPath) || this.resolveFS(path).existsSync(formattedPath);
604
- }
605
- /**
606
- * Exposes the internal VFS map for advanced usage.
607
- */
608
- get [__VFS_CACHE__]() {
609
- return this.#cachedFS;
610
- }
611
- /**
612
- * Exposes the internal VFS resolver cache for advanced usage.
613
- */
614
- get [__VFS_RESOLVER__]() {
615
- return this.#cachedResolver;
708
+ static create(context, data) {
709
+ let result = new _UnifiedFS(context, data);
710
+ result = result.use(result.#physicalFS);
711
+ if (result.#context.config.output.mode !== "fs") {
712
+ result = result.use(result.#virtualFS);
713
+ }
714
+ return result;
616
715
  }
617
716
  /**
618
- * Exposes the internal VFS map for advanced usage.
717
+ * Gets the virtual file system (VFS).
619
718
  */
620
- get [__VFS_VIRTUAL__]() {
719
+ get virtual() {
621
720
  return this.#virtualFS;
622
721
  }
623
722
  /**
624
- * Exposes the internal UFS map for advanced usage.
625
- */
626
- get [__VFS_UNIFIED__]() {
627
- return this.#unifiedFS;
628
- }
629
- /**
630
- * A proxy to access the underlying file metadata.
631
- */
632
- get meta() {
633
- return new Proxy(this.#meta, {
634
- get: /* @__PURE__ */ __name((target, prop) => {
635
- if (target[prop]) {
636
- return {
637
- id: prop,
638
- mode: this.#virtualFS.existsSync(prop) ? "virtual" : this.#fs.existsSync(prop) ? "fs" : this.#context.config.output.mode,
639
- details: {},
640
- variant: "normal",
641
- ...target[prop]
642
- };
643
- }
644
- return void 0;
645
- }, "get"),
646
- set: /* @__PURE__ */ __name((target, prop, value) => {
647
- target[prop] = value;
648
- this.#ids[value.id || prop] = prop;
649
- return true;
650
- }, "set"),
651
- deleteProperty: /* @__PURE__ */ __name((target, prop) => {
652
- delete this.#ids[target[prop]?.id || prop];
653
- delete target[prop];
654
- return true;
655
- }, "deleteProperty")
656
- });
657
- }
658
- /**
659
- * A map of module ids to their file paths.
723
+ * Gets the physical file system (FS).
660
724
  */
661
- get ids() {
662
- return this.#ids;
725
+ get physical() {
726
+ return this.#physicalFS;
663
727
  }
664
728
  /**
665
729
  * Creates a new instance of the VirtualFileSystem.
666
730
  *
667
731
  * @param context - The context of the virtual file system, typically containing options and logging functions.
668
- * @param serialized - A map of files/file contents to populate in cache
732
+ * @param data - A buffer containing the serialized virtual file system data.
669
733
  */
670
- constructor(context, serialized = {}) {
734
+ constructor(context, data) {
735
+ super();
671
736
  this.#context = context;
672
- this.#cachedFS = /* @__PURE__ */ new Map();
673
- this.#meta = Object.fromEntries(Object.entries(serialized.virtualFilesMeta ?? {}));
674
- this.#ids = Object.fromEntries(Object.entries(this.#meta).map(([path, data]) => [
675
- data.id || path,
676
- path
677
- ]));
678
- if (!this.#fs.existsSync(this.#context.dataPath)) {
679
- this.#fs.mkdirSync(this.#context.dataPath, {
737
+ if (!this.#physicalFS.existsSync(this.#context.dataPath)) {
738
+ this.#physicalFS.mkdirSync(this.#context.dataPath, {
680
739
  recursive: true
681
740
  });
682
741
  }
683
- if (!this.#fs.existsSync(this.#context.cachePath)) {
684
- this.#fs.mkdirSync(this.#context.cachePath, {
742
+ if (!this.#physicalFS.existsSync(this.#context.cachePath)) {
743
+ this.#physicalFS.mkdirSync(this.#context.cachePath, {
685
744
  recursive: true
686
745
  });
687
746
  }
688
- if (!this.#fs.existsSync(joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.output.outputPath))) {
689
- this.#fs.mkdirSync(joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.output.outputPath), {
747
+ if (!this.#physicalFS.existsSync(joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.output.outputPath))) {
748
+ this.#physicalFS.mkdirSync(joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.output.outputPath), {
690
749
  recursive: true
691
750
  });
692
751
  }
693
- this.#unifiedFS = this.#unifiedFS.use(this.#fs);
694
752
  if (this.#context.config.output.mode !== "fs") {
695
- if (serialized?.virtualFiles && Object.keys(serialized.virtualFiles).length > 0) {
696
- this.#virtualFS = Volume.fromJSON(serialized.virtualFiles);
697
- }
753
+ this.#virtualFS = Volume.fromJSON(data._hasFiles() && data.files.length > 0 ? data.files.values().reduce((ret, file) => {
754
+ ret[file.path] = file.content;
755
+ return ret;
756
+ }, {}) : {});
698
757
  if (!this.#virtualFS.existsSync(this.#context.artifactsPath)) {
699
758
  this.#virtualFS.mkdirSync(this.#context.artifactsPath, {
700
759
  recursive: true
@@ -715,181 +774,531 @@ var VirtualFileSystem = class {
715
774
  recursive: true
716
775
  });
717
776
  }
718
- this.#unifiedFS = this.#unifiedFS.use(this.#virtualFS);
719
777
  } else if (this.#context.config.projectType === "application") {
720
- if (!this.#fs.existsSync(this.#context.artifactsPath)) {
721
- this.#fs.mkdirSync(this.#context.artifactsPath, {
778
+ if (!this.#physicalFS.existsSync(this.#context.artifactsPath)) {
779
+ this.#physicalFS.mkdirSync(this.#context.artifactsPath, {
722
780
  recursive: true
723
781
  });
724
782
  }
725
- if (!this.#fs.existsSync(this.#context.builtinsPath)) {
726
- this.#fs.mkdirSync(this.#context.builtinsPath, {
783
+ if (!this.#physicalFS.existsSync(this.#context.builtinsPath)) {
784
+ this.#physicalFS.mkdirSync(this.#context.builtinsPath, {
727
785
  recursive: true
728
786
  });
729
787
  }
730
- if (!this.#fs.existsSync(this.#context.entryPath)) {
731
- this.#fs.mkdirSync(this.#context.entryPath, {
788
+ if (!this.#physicalFS.existsSync(this.#context.entryPath)) {
789
+ this.#physicalFS.mkdirSync(this.#context.entryPath, {
732
790
  recursive: true
733
791
  });
734
792
  }
735
- if (!this.#fs.existsSync(this.#context.dtsPath)) {
736
- this.#fs.mkdirSync(this.#context.dtsPath, {
793
+ if (!this.#physicalFS.existsSync(this.#context.dtsPath)) {
794
+ this.#physicalFS.mkdirSync(this.#context.dtsPath, {
737
795
  recursive: true
738
796
  });
739
797
  }
740
798
  }
741
- this.#log = extendLog(this.#context.log, "virtual-file-system");
742
- }
743
- [__VFS_INIT__]() {
744
- if (!this.#isPatched && this.#context.config.output.mode !== "fs") {
745
- this.#revert = patchFS(fs, this);
746
- this.#isPatched = true;
747
- }
748
- }
749
- [__VFS_REVERT__]() {
750
- if (this.#isPatched && this.#context.config.output.mode !== "fs") {
751
- if (!this.#revert) {
752
- throw new Error("Attempting to revert File System patch prior to calling `__init__` function");
753
- }
754
- this.#revert?.();
755
- this.#isPatched = false;
756
- }
757
799
  }
758
800
  /**
759
- * Check if a path or id corresponds to a virtual file **(does not actually exists on disk)**.
801
+ * Select the file system module to use for the operation based on the path or URL.
760
802
  *
761
- * @param pathOrId - The path or id to check.
762
- * @param options - Optional parameters for resolving the path.
763
- * @returns Whether the path or id corresponds to a virtual file **(does not actually exists on disk)**.
803
+ * @param pathOrUrl - The path to perform the file system operation on.
804
+ * @param options - Options for the operation, such as output mode.
805
+ * @returns The file system module used for the operation.
764
806
  */
765
- isVirtual(pathOrId, options = {}) {
766
- if (!pathOrId) {
767
- return false;
768
- }
769
- const resolvedPath = this.resolve(pathOrId, {
770
- ...options,
771
- type: "file"
772
- });
773
- if (!resolvedPath) {
774
- return false;
807
+ resolveFS(pathOrUrl, options = {}) {
808
+ const mode = this.resolveMode(pathOrUrl, options);
809
+ if (mode === "virtual") {
810
+ return {
811
+ ...this.#virtualFS,
812
+ mode: "virtual"
813
+ };
814
+ } else if (mode === "fs") {
815
+ return {
816
+ ...this.#physicalFS,
817
+ mode: "fs"
818
+ };
775
819
  }
776
- return this.meta[resolvedPath]?.mode === "virtual";
820
+ return {
821
+ ...this,
822
+ mode: this.#context.config.output.mode
823
+ };
777
824
  }
778
825
  /**
779
- * Check if a path or id corresponds to a file written to the file system **(actually exists on disk)**.
826
+ * Select the file system module to use for the operation based on the path or URL.
780
827
  *
781
- * @param pathOrId - The path or id to check.
782
- * @param options - Optional parameters for resolving the path.
783
- * @returns Whether the path or id corresponds to a file written to the file system **(actually exists on disk)**.
828
+ * @param pathOrUrl - The path to perform the file system operation on.
829
+ * @param options - Options for the operation, such as output mode.
830
+ * @returns The file system module used for the operation.
784
831
  */
785
- isFs(pathOrId, options = {}) {
786
- if (!pathOrId) {
787
- return false;
788
- }
789
- const resolvedPath = this.resolve(pathOrId, {
790
- ...options,
791
- type: "file"
792
- });
793
- if (!resolvedPath) {
794
- return false;
832
+ resolveMode(pathOrUrl, options = {}) {
833
+ if (options.mode === "virtual" && this.#context.config.output.mode !== "fs" && isParentPath(toFilePath(pathOrUrl), this.#context.artifactsPath)) {
834
+ return "virtual";
835
+ } else if (options.mode === "fs" || this.#context.config.output.mode === "fs" || isParentPath(toFilePath(pathOrUrl), this.#context.dataPath) || isParentPath(toFilePath(pathOrUrl), this.#context.cachePath) || isParentPath(toFilePath(pathOrUrl), joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.output.outputPath))) {
836
+ return "fs";
795
837
  }
796
- return this.meta[resolvedPath]?.mode === "fs";
838
+ return void 0;
797
839
  }
798
840
  /**
799
- * Check if a path exists within one of the directories specified in the tsconfig.json's `path` field.
841
+ * Serializes the virtual file system (VFS) to a JSON object.
800
842
  *
801
- * @see https://www.typescriptlang.org/tsconfig#paths
802
- *
803
- * @param pathOrId - The path or ID to check.
804
- * @returns Whether the path or ID corresponds to a virtual file.
843
+ * @returns A JSON representation of the virtual file system.
805
844
  */
806
- isTsconfigPath(pathOrId) {
807
- return !!this.#context.tsconfig.options.paths && Object.keys(this.#context.tsconfig.options.paths).some((path) => pathOrId.startsWith(path.replaceAll("*", "")));
845
+ toJSON() {
846
+ return this.#virtualFS.toJSON();
847
+ }
848
+ };
849
+
850
+ // ../powerlines/src/lib/fs/vfs.ts
851
+ var VirtualFileSystem = class _VirtualFileSystem {
852
+ static {
853
+ __name(this, "VirtualFileSystem");
808
854
  }
809
855
  /**
810
- * Lists files in a given path.
811
- *
812
- * @param path - The path to list files from.
813
- * @param options - Options for listing files, such as encoding and recursion.
814
- * @returns An array of file names in the specified path.
856
+ * A map of virtual file IDs to their associated metadata.
815
857
  */
816
- readdirSync(path, options = "utf8") {
817
- return this.resolveFS(path).readdirSync(toFilePath(path), options);
818
- }
858
+ #metadata;
819
859
  /**
820
- * Removes a file in the virtual file system (VFS).
821
- *
822
- * @param path - The path to create the directory at.
860
+ * A map of virtual file IDs to their underlying file paths.
823
861
  */
824
- unlinkSync(path, options) {
825
- const formattedPath = toFilePath(path);
826
- if (!this.isFile(formattedPath)) {
827
- return;
828
- }
829
- this.#log(LogLevelLabel.TRACE, `Synchronously removing file: ${formattedPath}`);
830
- this.resolveFS(path, options).unlinkSync(formattedPath);
831
- this.#cachedFS.delete(formattedPath);
832
- this.clearResolverCache(formattedPath);
833
- }
862
+ #ids;
834
863
  /**
835
- * Removes a file in the virtual file system (VFS).
836
- *
837
- * @param path - The path to create the directory at.
864
+ * A map of underlying file paths to their virtual file IDs.
838
865
  */
839
- async unlink(path, options) {
840
- const formattedPath = toFilePath(path);
841
- if (!this.isFile(formattedPath)) {
842
- return;
843
- }
844
- this.#log(LogLevelLabel.TRACE, `Removing file: ${formattedPath}`);
845
- if (isFunction(this.resolveFS(path, options).promises.unlink)) {
846
- await this.resolveFS(path, options).promises.unlink(formattedPath);
847
- this.#cachedFS.delete(formattedPath);
848
- this.clearResolverCache(formattedPath);
849
- } else {
850
- this.unlinkSync(formattedPath, options);
851
- }
852
- }
866
+ #paths;
853
867
  /**
854
- * Removes a directory in the virtual file system (VFS).
855
- *
856
- * @param path - The path to create the directory at.
857
- * @param options - Options for creating the directory.
868
+ * A map of virtual file paths to their underlying file content.
858
869
  */
859
- rmdirSync(path, options = {}) {
860
- const formattedPath = toFilePath(path);
861
- if (!this.isDirectory(formattedPath)) {
862
- return;
863
- }
864
- this.#log(LogLevelLabel.TRACE, `Synchronously removing directory: ${formattedPath}`);
865
- this.resolveFS(path, options).rmdirSync(formattedPath, defu3(options, {
866
- recursive: true
867
- }));
868
- this.#cachedFS.delete(formattedPath);
869
- this.clearResolverCache(formattedPath);
870
- }
870
+ #cachedResolver = /* @__PURE__ */ new Map();
871
871
  /**
872
- * Removes a directory in the virtual file system (VFS).
872
+ * The unified volume that combines the virtual file system with the real file system.
873
873
  *
874
- * @param path - The path to create the directory at.
875
- * @param options - Options for creating the directory.
876
- * @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
874
+ * @remarks
875
+ * This volume allows for seamless access to both virtual and real files.
877
876
  */
878
- async rmdir(path, options = {}) {
879
- const formattedPath = toFilePath(path);
877
+ #unifiedFS;
878
+ /**
879
+ * Indicator specifying if the file system module is patched
880
+ */
881
+ #isPatched = false;
882
+ /**
883
+ * Indicator specifying if the virtual file system (VFS) is disposed
884
+ */
885
+ #isDisposed = false;
886
+ /**
887
+ * Function to revert require patch
888
+ */
889
+ #revert;
890
+ /**
891
+ * The context of the virtual file system.
892
+ */
893
+ #context;
894
+ /**
895
+ * The file system's logging function.
896
+ */
897
+ #log;
898
+ /**
899
+ * Checks if a path exists in the virtual file system (VFS).
900
+ *
901
+ * @param path - The path to check.
902
+ * @returns `true` if the path exists, otherwise `false`.
903
+ */
904
+ #existsSync(path) {
905
+ const formattedPath = this.formatPath(path);
906
+ return this.#unifiedFS.virtual.existsSync(formattedPath) || this.#unifiedFS.physical.existsSync(formattedPath) || this.#unifiedFS.resolveFS(path).existsSync(formattedPath);
907
+ }
908
+ /**
909
+ * Builds a regular expression from a string pattern for path matching.
910
+ *
911
+ * @param strPattern - The string pattern to convert.
912
+ * @returns A regular expression for matching paths.
913
+ */
914
+ #buildRegex(strPattern) {
915
+ const token = "::GLOBSTAR::";
916
+ return new RegExp(`^${this.formatPath(strPattern).replace(/\*\*/g, token).replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]").replace(new RegExp(token, "g"), ".*")}$`);
917
+ }
918
+ /**
919
+ * Formats a file id by removing the file extension and prepending the runtime prefix.
920
+ *
921
+ * @param id - The file ID to format.
922
+ * @returns The formatted file ID.
923
+ */
924
+ #formatId(id) {
925
+ const formattedId = toFilePath(id);
926
+ return `${this.#context.config.output.builtinPrefix}:${formattedId.replace(new RegExp(`^${this.#context.config.output.builtinPrefix}:`), "").replace(/^\\0/, "").replace(findFileDotExtensionSafe(formattedId), "")}`;
927
+ }
928
+ /**
929
+ * Resolves an id parameter to a corresponding virtual file path in the virtual file system (VFS).
930
+ *
931
+ * @param id - The id to resolve.
932
+ * @returns The resolved file id if it exists, otherwise undefined.
933
+ */
934
+ #resolveId(id) {
935
+ if (this.#ids[this.#formatId(id)]) {
936
+ return this.#ids[this.#formatId(id)] || false;
937
+ }
938
+ return false;
939
+ }
940
+ /**
941
+ * Resolves a path parameter to a corresponding virtual file path in the virtual file system (VFS).
942
+ *
943
+ * @param path - The path to resolve.
944
+ * @param options - Optional parameters for resolving the path.
945
+ * @returns The resolved file path if it exists, otherwise undefined.
946
+ */
947
+ #resolvePath(path, options = {}) {
948
+ if (isAbsolutePath(path)) {
949
+ if (this.#existsSync(path)) {
950
+ return path;
951
+ }
952
+ const result = this.#checkVariants(path);
953
+ if (result) {
954
+ return result;
955
+ }
956
+ }
957
+ for (const parentPath of this.#resolveParentPaths(path, options.paths)) {
958
+ const request = joinPaths$1(parentPath, path);
959
+ if (this.#existsSync(request)) {
960
+ return request;
961
+ }
962
+ const result = this.#checkVariants(request);
963
+ if (result) {
964
+ return result;
965
+ }
966
+ }
967
+ return false;
968
+ }
969
+ /**
970
+ * Resolves parent paths for a given request.
971
+ *
972
+ * @param request - The request path to resolve parent paths for.
973
+ * @param parents - An optional array of parent paths to consider.
974
+ * @returns An array of resolved parent paths.
975
+ */
976
+ #resolveParentPaths(request, parents = []) {
977
+ let paths = [
978
+ this.#context.workspaceConfig.workspaceRoot,
979
+ joinPaths$1(this.#context.workspaceConfig.workspaceRoot, this.#context.config.projectRoot)
980
+ ];
981
+ if (this.#context.tsconfig.options.paths) {
982
+ 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) => {
983
+ if (path && !ret.includes(joinPaths$1(this.#context.workspaceConfig.workspaceRoot, path))) {
984
+ ret.push(joinPaths$1(this.#context.workspaceConfig.workspaceRoot, path));
985
+ }
986
+ return ret;
987
+ }, paths) : paths;
988
+ }
989
+ return paths.reduce((ret, path) => {
990
+ if (!ret.includes(path)) {
991
+ ret.push(path);
992
+ }
993
+ return ret;
994
+ }, parents.filter(Boolean).map((p) => this.formatPath(p)));
995
+ }
996
+ /**
997
+ * Clears the resolver cache for a given path.
998
+ *
999
+ * @param path - The path to clear the resolver cache for.
1000
+ */
1001
+ #clearResolverCache(path) {
1002
+ this.#cachedResolver.keys().filter((key) => key.startsWith(toFilePath(path))).forEach((key) => this.#cachedResolver.delete(key));
1003
+ }
1004
+ /**
1005
+ * Check if the file exists with different variants (index, extensions).
1006
+ *
1007
+ * @param request - The request path to check.
1008
+ * @param parentPath - An optional parent path to prepend to the request.
1009
+ * @returns The file path if it exists, otherwise false.
1010
+ */
1011
+ #checkVariants(request, parentPath) {
1012
+ const path = parentPath ? joinPaths$1(parentPath, request) : request;
1013
+ let file = this.#checkExtensions(path);
1014
+ if (file) {
1015
+ return file;
1016
+ }
1017
+ file = this.#checkIndex(path);
1018
+ if (file) {
1019
+ return file;
1020
+ }
1021
+ return false;
1022
+ }
1023
+ /**
1024
+ * Check if the index file exists in the given request path.
1025
+ *
1026
+ * @param request - The request path to check.
1027
+ * @returns The index file path if it exists, otherwise false.
1028
+ */
1029
+ #checkIndex(request) {
1030
+ let file = joinPaths$1(request, "index");
1031
+ if (this.#existsSync(file)) {
1032
+ return file;
1033
+ }
1034
+ file = this.#checkExtensions(file);
1035
+ if (file) {
1036
+ return file;
1037
+ }
1038
+ return false;
1039
+ }
1040
+ /**
1041
+ * Check if the file exists with different extensions.
1042
+ *
1043
+ * @param request - The request path to check.
1044
+ * @returns The file path if it exists with any of the checked extensions, otherwise false.
1045
+ */
1046
+ #checkExtensions(request) {
1047
+ let file = `${request}.ts`;
1048
+ if (this.#existsSync(file)) {
1049
+ return file;
1050
+ }
1051
+ file = `${request}.mts`;
1052
+ if (this.#existsSync(file)) {
1053
+ return file;
1054
+ }
1055
+ file = `${request}.cts`;
1056
+ if (this.#existsSync(file)) {
1057
+ return file;
1058
+ }
1059
+ file = `${request}.tsx`;
1060
+ if (this.#existsSync(file)) {
1061
+ return file;
1062
+ }
1063
+ file = `${request}.js`;
1064
+ if (this.#existsSync(file)) {
1065
+ return file;
1066
+ }
1067
+ file = `${request}.mjs`;
1068
+ if (this.#existsSync(file)) {
1069
+ return file;
1070
+ }
1071
+ file = `${request}.cjs`;
1072
+ if (this.#existsSync(file)) {
1073
+ return file;
1074
+ }
1075
+ file = `${request}.jsx`;
1076
+ if (this.#existsSync(file)) {
1077
+ return file;
1078
+ }
1079
+ file = `${request}.json`;
1080
+ if (this.#existsSync(file)) {
1081
+ return file;
1082
+ }
1083
+ file = `${request}.d.ts`;
1084
+ if (this.#existsSync(file)) {
1085
+ return file;
1086
+ }
1087
+ return false;
1088
+ }
1089
+ /**
1090
+ * Creates a virtual file system (VFS) that is backed up to a Cap'n Proto message buffer.
1091
+ *
1092
+ * @param context - The context of the virtual file system, typically containing options and logging functions.
1093
+ * @returns A promise that resolves to a new virtual file system instance.
1094
+ */
1095
+ static async create(context) {
1096
+ if (!context.config.skipCache && existsSync(joinPaths$1(context.cachePath, "fs.bin"))) {
1097
+ const buffer = await readFileBuffer(joinPaths$1(context.cachePath, "fs.bin"));
1098
+ const message2 = new $.Message(buffer, false);
1099
+ return new _VirtualFileSystem(context, message2.getRoot(FileSystemData));
1100
+ }
1101
+ const message = new $.Message();
1102
+ return new _VirtualFileSystem(context, message.initRoot(FileSystemData));
1103
+ }
1104
+ /**
1105
+ * Synchronously creates a virtual file system (VFS) that is backed up to a Cap'n Proto message buffer.
1106
+ *
1107
+ * @param context - The context of the virtual file system, typically containing options and logging functions.
1108
+ * @returns A new virtual file system instance.
1109
+ */
1110
+ static createSync(context) {
1111
+ if (!context.config.skipCache && existsSync(joinPaths$1(context.cachePath, "fs.bin"))) {
1112
+ const buffer = readFileBufferSync(joinPaths$1(context.cachePath, "fs.bin"));
1113
+ const message2 = new $.Message(buffer, false);
1114
+ return new _VirtualFileSystem(context, message2.getRoot(FileSystemData));
1115
+ }
1116
+ const message = new $.Message();
1117
+ return new _VirtualFileSystem(context, message.initRoot(FileSystemData));
1118
+ }
1119
+ /**
1120
+ * A map of file ids to their metadata.
1121
+ */
1122
+ get metadata() {
1123
+ return this.#metadata;
1124
+ }
1125
+ /**
1126
+ * A map of module ids to their file paths.
1127
+ */
1128
+ get ids() {
1129
+ return this.#ids;
1130
+ }
1131
+ /**
1132
+ * A map of virtual file paths to their IDs.
1133
+ */
1134
+ get paths() {
1135
+ return this.#paths;
1136
+ }
1137
+ /**
1138
+ * Creates a new instance of the {@link VirtualFileSystem}.
1139
+ *
1140
+ * @param context - The context of the virtual file system, typically containing options and logging functions.
1141
+ * @param data - A buffer containing the serialized virtual file system data.
1142
+ */
1143
+ constructor(context, data) {
1144
+ this.#context = context;
1145
+ this.#unifiedFS = UnifiedFS.create(context, data);
1146
+ this.#metadata = {};
1147
+ if (data._hasMetadata()) {
1148
+ this.#metadata = data.metadata.values().reduce((ret, data2) => {
1149
+ ret[data2.id] = {
1150
+ id: data2.id,
1151
+ variant: data2.variant,
1152
+ mode: data2.mode,
1153
+ properties: data2._hasProperties() ? data2.properties.values().reduce((ret2, item) => {
1154
+ ret2[item.key] = item.value;
1155
+ return ret2;
1156
+ }, {}) : {}
1157
+ };
1158
+ return ret;
1159
+ }, {});
1160
+ }
1161
+ this.#ids = {};
1162
+ this.#paths = {};
1163
+ if (data._hasIds()) {
1164
+ this.#ids = data.ids.values().reduce((ret, data2) => {
1165
+ ret[data2.id] ??= data2.path;
1166
+ ret[data2.path] ??= data2.path;
1167
+ return ret;
1168
+ }, {});
1169
+ this.#paths = data.ids.values().reduce((ret, data2) => {
1170
+ ret[data2.path] ??= data2.id;
1171
+ return ret;
1172
+ }, {});
1173
+ }
1174
+ this.#log = extendLog(this.#context.log, "file-system");
1175
+ }
1176
+ /**
1177
+ * Check if a path or id corresponds to a virtual file **(does not actually exists on disk)**.
1178
+ *
1179
+ * @param pathOrId - The path or id to check.
1180
+ * @param options - Optional parameters for resolving the path.
1181
+ * @returns Whether the path or id corresponds to a virtual file **(does not actually exists on disk)**.
1182
+ */
1183
+ isVirtual(pathOrId, options = {}) {
1184
+ if (!pathOrId) {
1185
+ return false;
1186
+ }
1187
+ const resolvedPath = this.resolve(pathOrId, {
1188
+ ...options,
1189
+ type: "file"
1190
+ });
1191
+ if (!resolvedPath) {
1192
+ return false;
1193
+ }
1194
+ return this.metadata[resolvedPath]?.mode === "virtual";
1195
+ }
1196
+ /**
1197
+ * Check if a path or id corresponds to a file written to the file system **(actually exists on disk)**.
1198
+ *
1199
+ * @param pathOrId - The path or id to check.
1200
+ * @param options - Optional parameters for resolving the path.
1201
+ * @returns Whether the path or id corresponds to a file written to the file system **(actually exists on disk)**.
1202
+ */
1203
+ isPhysical(pathOrId, options = {}) {
1204
+ if (!pathOrId) {
1205
+ return false;
1206
+ }
1207
+ const resolvedPath = this.resolve(pathOrId, {
1208
+ ...options,
1209
+ type: "file"
1210
+ });
1211
+ if (!resolvedPath) {
1212
+ return false;
1213
+ }
1214
+ return this.metadata[resolvedPath]?.mode === "fs";
1215
+ }
1216
+ /**
1217
+ * Lists files in a given path.
1218
+ *
1219
+ * @param path - The path to list files from.
1220
+ * @param options - Options for listing files, such as encoding and recursion.
1221
+ * @returns An array of file names in the specified path.
1222
+ */
1223
+ readdirSync(path, options = "utf8") {
1224
+ return this.#unifiedFS.resolveFS(path).readdirSync(toFilePath(path), options);
1225
+ }
1226
+ /**
1227
+ * Removes a file in the virtual file system (VFS).
1228
+ *
1229
+ * @param path - The path to create the directory at.
1230
+ */
1231
+ unlinkSync(path, options) {
1232
+ const formattedPath = toFilePath(path);
1233
+ if (!this.isFile(formattedPath)) {
1234
+ return;
1235
+ }
1236
+ this.#log(LogLevelLabel.TRACE, `Synchronously removing file: ${formattedPath}`);
1237
+ this.#unifiedFS.resolveFS(path, options).unlinkSync(formattedPath);
1238
+ if (this.paths[formattedPath] && this.metadata[this.paths[formattedPath]]) {
1239
+ delete this.metadata[this.paths[formattedPath]];
1240
+ }
1241
+ this.#clearResolverCache(formattedPath);
1242
+ }
1243
+ /**
1244
+ * Removes a file in the virtual file system (VFS).
1245
+ *
1246
+ * @param path - The path to create the directory at.
1247
+ */
1248
+ async unlink(path, options) {
1249
+ const formattedPath = toFilePath(path);
1250
+ if (!this.isFile(formattedPath)) {
1251
+ return;
1252
+ }
1253
+ this.#log(LogLevelLabel.TRACE, `Removing file: ${formattedPath}`);
1254
+ if (isFunction(this.#unifiedFS.resolveFS(path, options).promises.unlink)) {
1255
+ await this.#unifiedFS.resolveFS(path, options).promises.unlink(formattedPath);
1256
+ if (this.paths[formattedPath] && this.metadata[this.paths[formattedPath]]) {
1257
+ delete this.metadata[this.paths[formattedPath]];
1258
+ }
1259
+ this.#clearResolverCache(formattedPath);
1260
+ } else {
1261
+ this.unlinkSync(formattedPath, options);
1262
+ }
1263
+ }
1264
+ /**
1265
+ * Removes a directory in the virtual file system (VFS).
1266
+ *
1267
+ * @param path - The path to create the directory at.
1268
+ * @param options - Options for creating the directory.
1269
+ */
1270
+ rmdirSync(path, options = {}) {
1271
+ const formattedPath = toFilePath(path);
1272
+ if (!this.isDirectory(formattedPath)) {
1273
+ return;
1274
+ }
1275
+ this.#log(LogLevelLabel.TRACE, `Synchronously removing directory: ${formattedPath}`);
1276
+ this.#unifiedFS.resolveFS(path, options).rmdirSync(formattedPath, defu2(options, {
1277
+ recursive: true
1278
+ }));
1279
+ this.#clearResolverCache(formattedPath);
1280
+ }
1281
+ /**
1282
+ * Removes a directory in the virtual file system (VFS).
1283
+ *
1284
+ * @param path - The path to create the directory at.
1285
+ * @param options - Options for creating the directory.
1286
+ * @returns A promise that resolves to the path of the created directory, or undefined if the directory could not be created.
1287
+ */
1288
+ async rmdir(path, options = {}) {
1289
+ const formattedPath = toFilePath(path);
880
1290
  if (!this.isDirectory(formattedPath)) {
881
1291
  return;
882
1292
  }
883
1293
  this.#log(LogLevelLabel.TRACE, `Removing directory: ${formattedPath}`);
884
- if (isFunction(this.resolveFS(path, options).promises.rm)) {
885
- await this.resolveFS(path, options).promises.rm(formattedPath, defu3(options, {
1294
+ if (isFunction(this.#unifiedFS.resolveFS(path, options).promises.rm)) {
1295
+ await this.#unifiedFS.resolveFS(path, options).promises.rm(formattedPath, defu2(options, {
886
1296
  force: true,
887
1297
  recursive: true
888
1298
  }));
889
- this.#cachedFS.delete(formattedPath);
890
- this.clearResolverCache(formattedPath);
1299
+ this.#clearResolverCache(formattedPath);
891
1300
  } else {
892
- this.rmdirSync(formattedPath, defu3(options ?? {}, {
1301
+ this.rmdirSync(formattedPath, defu2(options ?? {}, {
893
1302
  force: true,
894
1303
  recursive: true
895
1304
  }));
@@ -931,8 +1340,8 @@ var VirtualFileSystem = class {
931
1340
  */
932
1341
  mkdirSync(path, options = {}) {
933
1342
  const filePath = toFilePath(path);
934
- this.clearResolverCache(filePath);
935
- return this.resolveFS(filePath, options).mkdirSync(filePath, defu3(options ?? {}, {
1343
+ this.#clearResolverCache(filePath);
1344
+ return this.#unifiedFS.resolveFS(filePath, options).mkdirSync(filePath, defu2(options ?? {}, {
936
1345
  recursive: true
937
1346
  }));
938
1347
  }
@@ -946,16 +1355,16 @@ var VirtualFileSystem = class {
946
1355
  async mkdir(path, options = {}) {
947
1356
  let result;
948
1357
  const filePath = toFilePath(path);
949
- if (isFunction(this.resolveFS(filePath, options).promises.mkdir)) {
950
- result = await this.resolveFS(filePath, options).promises.mkdir(filePath, defu3(options ?? {}, {
1358
+ if (isFunction(this.#unifiedFS.resolveFS(filePath, options).promises.mkdir)) {
1359
+ result = await this.#unifiedFS.resolveFS(filePath, options).promises.mkdir(filePath, defu2(options ?? {}, {
951
1360
  recursive: true
952
1361
  }));
953
1362
  } else {
954
- result = this.resolveFS(filePath, options).mkdirSync(filePath, defu3(options ?? {}, {
1363
+ result = this.#unifiedFS.resolveFS(filePath, options).mkdirSync(filePath, defu2(options ?? {}, {
955
1364
  recursive: true
956
1365
  }));
957
1366
  }
958
- this.clearResolverCache(filePath);
1367
+ this.#clearResolverCache(filePath);
959
1368
  return result;
960
1369
  }
961
1370
  /**
@@ -977,7 +1386,7 @@ var VirtualFileSystem = class {
977
1386
  }
978
1387
  continue;
979
1388
  }
980
- const absPattern = isAbsolutePath(normalized) ? normalized : this.formatPath(joinPaths(this.#context.workspaceConfig.workspaceRoot, normalized));
1389
+ const absPattern = isAbsolutePath(normalized) ? normalized : this.formatPath(joinPaths$1(this.#context.workspaceConfig.workspaceRoot, normalized));
981
1390
  const firstGlobIdx = absPattern.search(/[*?[\]{}]/);
982
1391
  const baseDir = firstGlobIdx === -1 ? findFilePath(absPattern) : absPattern.slice(0, Math.max(0, absPattern.lastIndexOf("/", firstGlobIdx)));
983
1392
  const stack = [
@@ -992,7 +1401,7 @@ var VirtualFileSystem = class {
992
1401
  continue;
993
1402
  }
994
1403
  for (const entry of entries) {
995
- const full = this.formatPath(joinPaths(dir, entry));
1404
+ const full = this.formatPath(joinPaths$1(dir, entry));
996
1405
  let stats;
997
1406
  try {
998
1407
  stats = this.#unifiedFS.lstatSync(full);
@@ -1003,7 +1412,7 @@ var VirtualFileSystem = class {
1003
1412
  if (stats.isDirectory()) {
1004
1413
  stack.push(full);
1005
1414
  } else if (stats.isFile()) {
1006
- if (this.buildRegex(absPattern).test(full)) {
1415
+ if (this.#buildRegex(absPattern).test(full)) {
1007
1416
  const resolved = this.resolve(full, {
1008
1417
  type: "file"
1009
1418
  });
@@ -1036,7 +1445,7 @@ var VirtualFileSystem = class {
1036
1445
  }
1037
1446
  continue;
1038
1447
  }
1039
- const absPattern = isAbsolutePath(normalized) ? normalized : this.formatPath(joinPaths(this.#context.workspaceConfig.workspaceRoot, normalized));
1448
+ const absPattern = isAbsolutePath(normalized) ? normalized : this.formatPath(joinPaths$1(this.#context.workspaceConfig.workspaceRoot, normalized));
1040
1449
  const firstGlobIdx = absPattern.search(/[*?[\]{}]/);
1041
1450
  const baseDir = firstGlobIdx === -1 ? findFilePath(absPattern) : absPattern.slice(0, Math.max(0, absPattern.lastIndexOf("/", firstGlobIdx)));
1042
1451
  const stack = [
@@ -1051,7 +1460,7 @@ var VirtualFileSystem = class {
1051
1460
  continue;
1052
1461
  }
1053
1462
  for (const entry of entries) {
1054
- const full = this.formatPath(joinPaths(dir, entry));
1463
+ const full = this.formatPath(joinPaths$1(dir, entry));
1055
1464
  let stats;
1056
1465
  try {
1057
1466
  stats = this.#unifiedFS.lstatSync(full);
@@ -1062,7 +1471,7 @@ var VirtualFileSystem = class {
1062
1471
  if (stats.isDirectory()) {
1063
1472
  stack.push(full);
1064
1473
  } else if (stats.isFile()) {
1065
- if (this.buildRegex(absPattern).test(full)) {
1474
+ if (this.#buildRegex(absPattern).test(full)) {
1066
1475
  const resolved = this.resolve(full, {
1067
1476
  type: "file"
1068
1477
  });
@@ -1126,7 +1535,7 @@ var VirtualFileSystem = class {
1126
1535
  * @returns An array of file names in the specified path.
1127
1536
  */
1128
1537
  async readdir(pathOrId, options = "utf8") {
1129
- return this.resolveFS(pathOrId).promises.readdir(toFilePath(pathOrId), options);
1538
+ return this.#unifiedFS.resolveFS(pathOrId).promises.readdir(toFilePath(pathOrId), options);
1130
1539
  }
1131
1540
  /**
1132
1541
  * Asynchronously reads a file from the virtual file system (VFS).
@@ -1142,17 +1551,13 @@ var VirtualFileSystem = class {
1142
1551
  type: "file"
1143
1552
  });
1144
1553
  if (filePath) {
1145
- if (this.#cachedFS.has(filePath)) {
1146
- return this.#cachedFS.get(filePath);
1147
- }
1148
1554
  let result;
1149
- if (isFunction(this.resolveFS(filePath).promises.readFile)) {
1150
- result = (await this.resolveFS(filePath).promises.readFile(filePath, options))?.toString("utf8");
1555
+ if (isFunction(this.#unifiedFS.resolveFS(filePath).promises.readFile)) {
1556
+ result = (await this.#unifiedFS.resolveFS(filePath).promises.readFile(filePath, options))?.toString("utf8");
1151
1557
  } else {
1152
- result = this.resolveFS(filePath).readFileSync(filePath, options);
1558
+ result = this.#unifiedFS.resolveFS(filePath).readFileSync(filePath, options);
1153
1559
  }
1154
1560
  const content = isBuffer(result) ? bufferToString(result) : result;
1155
- this.#cachedFS.set(filePath, content);
1156
1561
  return content;
1157
1562
  }
1158
1563
  return void 0;
@@ -1171,12 +1576,8 @@ var VirtualFileSystem = class {
1171
1576
  type: "file"
1172
1577
  });
1173
1578
  if (filePath) {
1174
- if (this.#cachedFS.has(filePath)) {
1175
- return this.#cachedFS.get(filePath);
1176
- }
1177
- const result = this.resolveFS(filePath).readFileSync(filePath, options);
1579
+ const result = this.#unifiedFS.resolveFS(filePath).readFileSync(filePath, options);
1178
1580
  const content = isBuffer(result) ? bufferToString(result) : result;
1179
- this.#cachedFS.set(filePath, content);
1180
1581
  return content;
1181
1582
  }
1182
1583
  return void 0;
@@ -1204,17 +1605,15 @@ var VirtualFileSystem = class {
1204
1605
  });
1205
1606
  }
1206
1607
  }
1207
- const outputMode = this.resolveOutputMode(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0);
1608
+ const outputMode = this.#unifiedFS.resolveMode(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0);
1208
1609
  this.#log(LogLevelLabel.TRACE, `Writing ${formattedPath} file to the ${outputMode === "fs" ? "" : "virtual "}file system (size: ${prettyBytes(new Blob(toArray(code)).size)})`);
1209
- this.meta[formattedPath] = {
1210
- path: formattedPath,
1211
- code,
1610
+ this.metadata[formattedPath] = {
1212
1611
  mode: outputMode,
1213
1612
  variant: "normal",
1214
1613
  ...isPowerLinesWriteFileData(data) ? data : {}
1215
1614
  };
1216
- this.clearResolverCache(formattedPath);
1217
- const ifs = this.resolveFS(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0);
1615
+ this.#clearResolverCache(formattedPath);
1616
+ const ifs = this.#unifiedFS.resolveFS(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0);
1218
1617
  if (isFunction(ifs.promises.writeFile)) {
1219
1618
  return ifs.promises.writeFile(formattedPath, code, isNodeWriteFileOptions(options) ? options : "utf8");
1220
1619
  }
@@ -1233,17 +1632,15 @@ var VirtualFileSystem = class {
1233
1632
  this.mkdirSync(findFilePath(formattedPath), isPowerlinesWriteFileOptions(options) ? options : void 0);
1234
1633
  }
1235
1634
  const code = isPowerLinesWriteFileData(data) ? data.code : data;
1236
- const outputMode = this.resolveOutputMode(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0);
1635
+ const outputMode = this.#unifiedFS.resolveMode(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0);
1237
1636
  this.#log(LogLevelLabel.TRACE, `Writing ${formattedPath} file to the ${outputMode === "fs" ? "" : "virtual "}file system (size: ${prettyBytes(new Blob(toArray(code)).size)})`);
1238
- this.meta[formattedPath] = {
1239
- path: formattedPath,
1240
- code,
1637
+ this.metadata[formattedPath] = {
1241
1638
  mode: outputMode,
1242
1639
  variant: "normal",
1243
1640
  ...isPowerLinesWriteFileData(data) ? data : {}
1244
1641
  };
1245
- this.clearResolverCache(formattedPath);
1246
- const writeStream = this.resolveFS(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0).createWriteStream(formattedPath);
1642
+ this.#clearResolverCache(formattedPath);
1643
+ const writeStream = this.#unifiedFS.resolveFS(formattedPath, isPowerlinesWriteFileOptions(options) ? options : void 0).createWriteStream(formattedPath);
1247
1644
  try {
1248
1645
  writeStream.write(code);
1249
1646
  } finally {
@@ -1267,8 +1664,8 @@ var VirtualFileSystem = class {
1267
1664
  */
1268
1665
  getMetadata(pathOrId) {
1269
1666
  const resolved = this.resolve(pathOrId);
1270
- if (resolved && this.meta[resolved]) {
1271
- return this.meta[resolved];
1667
+ if (resolved && this.metadata[resolved]) {
1668
+ return this.metadata[resolved];
1272
1669
  }
1273
1670
  return void 0;
1274
1671
  }
@@ -1283,7 +1680,7 @@ var VirtualFileSystem = class {
1283
1680
  */
1284
1681
  isFile(pathOrId) {
1285
1682
  const resolved = this.resolve(pathOrId);
1286
- return !!(resolved && (this.#virtualFS.existsSync(resolved) && this.#virtualFS.lstatSync(resolved).isFile() || this.#fs.existsSync(resolved) && this.#fs.lstatSync(resolved).isFile() || this.resolveFS(resolved).existsSync(resolved) && this.resolveFS(resolved).lstatSync(resolved).isFile()));
1683
+ 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()));
1287
1684
  }
1288
1685
  /**
1289
1686
  * Checks if a directory exists in the virtual file system (VFS).
@@ -1293,7 +1690,7 @@ var VirtualFileSystem = class {
1293
1690
  */
1294
1691
  isDirectory(pathOrId) {
1295
1692
  const resolved = this.resolve(pathOrId);
1296
- return !!(resolved && (this.#virtualFS.existsSync(resolved) && this.#virtualFS.lstatSync(resolved).isDirectory() || this.#fs.existsSync(resolved) && this.#fs.lstatSync(resolved).isDirectory() || this.resolveFS(resolved).existsSync(resolved) && this.resolveFS(resolved).lstatSync(resolved).isDirectory()));
1693
+ 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()));
1297
1694
  }
1298
1695
  /**
1299
1696
  * Retrieves the status of a file in the virtual file system (VFS).
@@ -1302,7 +1699,7 @@ var VirtualFileSystem = class {
1302
1699
  * @returns A promise that resolves to the file's status information, or false if the file does not exist.
1303
1700
  */
1304
1701
  async stat(pathOrId, options) {
1305
- return this.resolveFS(pathOrId).promises.stat(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId), options);
1702
+ return this.#unifiedFS.resolveFS(pathOrId).promises.stat(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId), options);
1306
1703
  }
1307
1704
  /**
1308
1705
  * Synchronously retrieves the status of a file in the virtual file system (VFS).
@@ -1311,7 +1708,7 @@ var VirtualFileSystem = class {
1311
1708
  * @returns The file's status information, or false if the file does not exist.
1312
1709
  */
1313
1710
  statSync(pathOrId) {
1314
- return this.resolveFS(pathOrId).statSync(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId));
1711
+ return this.#unifiedFS.resolveFS(pathOrId).statSync(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId));
1315
1712
  }
1316
1713
  /**
1317
1714
  * Retrieves the status of a symbolic link in the virtual file system (VFS).
@@ -1320,52 +1717,16 @@ var VirtualFileSystem = class {
1320
1717
  * @returns A promise that resolves to the symbolic link's status information, or false if the link does not exist.
1321
1718
  */
1322
1719
  async lstat(pathOrId, options) {
1323
- return this.resolveFS(pathOrId).promises.lstat(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId), options);
1720
+ return this.#unifiedFS.resolveFS(pathOrId).promises.lstat(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId), options);
1324
1721
  }
1325
1722
  /**
1326
1723
  * Synchronously retrieves the status of a symbolic link in the virtual file system (VFS).
1327
- *
1328
- * @param pathOrId - The path or ID of the symbolic link to retrieve status for.
1329
- * @returns The symbolic link's status information, or false if the link does not exist.
1330
- */
1331
- lstatSync(pathOrId, options) {
1332
- return this.resolveFS(pathOrId).lstatSync(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId), options);
1333
- }
1334
- /**
1335
- * Resolves a path based on TypeScript's `tsconfig.json` paths.
1336
- *
1337
- * @see https://www.typescriptlang.org/tsconfig#paths
1338
- *
1339
- * @param path - The path to check.
1340
- * @returns The resolved file path if it exists, otherwise undefined.
1341
- */
1342
- resolveTsconfigPath(path) {
1343
- if (this.#context.tsconfig.options.paths) {
1344
- for (const tsconfigPathKey of Object.keys(this.#context.tsconfig.options.paths).filter((tsconfigPath) => path.startsWith(tsconfigPath.replaceAll("*", "")))) {
1345
- const resolvedPath = this.#context.tsconfig.options.paths[tsconfigPathKey]?.find((tsconfigPath) => this.resolvePath(joinPaths(this.#context.workspaceConfig.workspaceRoot, tsconfigPath.replaceAll("*", ""), path.replace(tsconfigPathKey.replaceAll("*", ""), ""))) || this.formatPath(tsconfigPath) === this.formatPath(path));
1346
- if (resolvedPath) {
1347
- return this.formatPath(resolvedPath) === this.formatPath(path) ? this.formatPath(resolvedPath) : this.resolvePath(joinPaths(this.#context.workspaceConfig.workspaceRoot, resolvedPath.replaceAll("*", ""), path.replace(tsconfigPathKey.replaceAll("*", ""), "")));
1348
- }
1349
- }
1350
- }
1351
- return false;
1352
- }
1353
- /**
1354
- * Resolves a path based on TypeScript's `tsconfig.json` paths.
1355
- *
1356
- * @see https://www.typescriptlang.org/tsconfig#paths
1357
- *
1358
- * @param path - The path to check.
1359
- * @returns The resolved file path if it exists, otherwise undefined.
1724
+ *
1725
+ * @param pathOrId - The path or ID of the symbolic link to retrieve status for.
1726
+ * @returns The symbolic link's status information, or false if the link does not exist.
1360
1727
  */
1361
- resolveTsconfigPathPackage(path) {
1362
- if (this.#context.tsconfig.options.paths) {
1363
- const tsconfigPathKeys = Object.keys(this.#context.tsconfig.options.paths).filter((tsconfigPath) => path.startsWith(tsconfigPath.replaceAll("*", "")));
1364
- if (tsconfigPathKeys.length > 0 && tsconfigPathKeys[0]) {
1365
- return tsconfigPathKeys[0].replace(/\/\*$/, "");
1366
- }
1367
- }
1368
- return false;
1728
+ lstatSync(pathOrId, options) {
1729
+ return this.#unifiedFS.resolveFS(pathOrId).lstatSync(this.resolve(toFilePath(pathOrId)) || toFilePath(pathOrId), options);
1369
1730
  }
1370
1731
  /**
1371
1732
  * Resolves a path or ID to its real path in the virtual file system (VFS).
@@ -1393,9 +1754,9 @@ var VirtualFileSystem = class {
1393
1754
  if (this.#cachedResolver.has(resolverKey)) {
1394
1755
  return this.#cachedResolver.get(resolverKey);
1395
1756
  }
1396
- let result = this.resolveId(formattedPathOrId);
1757
+ let result = this.#resolveId(formattedPathOrId);
1397
1758
  if (!result) {
1398
- result = this.resolvePath(formattedPathOrId, options);
1759
+ result = this.#resolvePath(formattedPathOrId, options);
1399
1760
  }
1400
1761
  if (!result) {
1401
1762
  result = false;
@@ -1407,18 +1768,6 @@ var VirtualFileSystem = class {
1407
1768
  return result;
1408
1769
  }
1409
1770
  /**
1410
- * Retrieves the partial metadata for all files in the virtual file system (VFS).
1411
- *
1412
- * @returns A record containing the partial metadata for all files.
1413
- */
1414
- getPartialMeta() {
1415
- return Object.fromEntries(Object.entries(this.#meta).filter(([_, data]) => isSetObject(data)));
1416
- }
1417
- buildRegex(strPattern) {
1418
- const token = "::GLOBSTAR::";
1419
- return new RegExp(`^${this.formatPath(strPattern).replace(/\*\*/g, token).replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, "[^/]*").replace(/\?/g, "[^/]").replace(new RegExp(token, "g"), ".*")}$`);
1420
- }
1421
- /**
1422
1771
  * Converts a relative path to an absolute path based on the workspace and project root.
1423
1772
  *
1424
1773
  * @param path - The relative path to convert.
@@ -1429,212 +1778,164 @@ var VirtualFileSystem = class {
1429
1778
  if (isAbsolutePath(formattedPath) || formattedPath.startsWith(this.#context.workspaceConfig.workspaceRoot)) {
1430
1779
  return formattedPath;
1431
1780
  } else if (formattedPath.startsWith(this.#context.config.projectRoot)) {
1432
- return joinPaths(this.#context.workspaceConfig.workspaceRoot, formattedPath);
1781
+ return joinPaths$1(this.#context.workspaceConfig.workspaceRoot, formattedPath);
1433
1782
  }
1434
1783
  return formattedPath;
1435
1784
  }
1436
1785
  /**
1437
- * Formats a file id by removing the file extension and prepending the runtime prefix.
1438
- *
1439
- * @param id - The file ID to format.
1440
- * @returns The formatted file ID.
1441
- */
1442
- formatId(id) {
1443
- const formattedId = toFilePath(id);
1444
- return `${this.#context.config.output.builtinPrefix}:${formattedId.replace(new RegExp(`^${this.#context.config.output.builtinPrefix}:`), "").replace(/^\\0/, "").replace(findFileDotExtensionSafe(formattedId), "")}`;
1445
- }
1446
- /**
1447
- * Resolves an id parameter to a corresponding virtual file path in the virtual file system (VFS).
1448
- *
1449
- * @param id - The id to resolve.
1450
- * @returns The resolved file id if it exists, otherwise undefined.
1451
- */
1452
- resolveId(id) {
1453
- if (this.#ids[this.formatId(id)]) {
1454
- return this.#ids[this.formatId(id)] || false;
1455
- }
1456
- return false;
1457
- }
1458
- /**
1459
- * Resolves a path parameter to a corresponding virtual file path in the virtual file system (VFS).
1460
- *
1461
- * @param path - The path to resolve.
1462
- * @param options - Optional parameters for resolving the path.
1463
- * @returns The resolved file path if it exists, otherwise undefined.
1464
- */
1465
- resolvePath(path, options = {}) {
1466
- if (isAbsolutePath(path)) {
1467
- if (this.#existsSync(path)) {
1468
- return path;
1469
- }
1470
- const result = this.checkVariants(path);
1471
- if (result) {
1472
- return result;
1473
- }
1474
- }
1475
- for (const parentPath of this.resolveParentPaths(path, options.paths)) {
1476
- const request = joinPaths(parentPath, path);
1477
- if (this.#existsSync(request)) {
1478
- return request;
1479
- }
1480
- const result = this.checkVariants(request);
1481
- if (result) {
1482
- return result;
1483
- }
1484
- }
1485
- return false;
1486
- }
1487
- resolveParentPaths(request, parents = []) {
1488
- let paths = [
1489
- this.#context.workspaceConfig.workspaceRoot,
1490
- joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.projectRoot)
1491
- ];
1492
- if (this.#context.tsconfig.options.paths) {
1493
- 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) => {
1494
- if (path && !ret.includes(joinPaths(this.#context.workspaceConfig.workspaceRoot, path))) {
1495
- ret.push(joinPaths(this.#context.workspaceConfig.workspaceRoot, path));
1786
+ * Disposes of the virtual file system (VFS) by saving its state to disk.
1787
+ */
1788
+ async dispose() {
1789
+ if (!this.#isDisposed) {
1790
+ this.#isDisposed = true;
1791
+ this.#log(LogLevelLabel.DEBUG, "Disposing virtual file system...");
1792
+ await this.unlink(joinPaths$1(this.#context.cachePath, "fs.bin"));
1793
+ const message = new $.Message();
1794
+ const data = message.initRoot(FileSystemData);
1795
+ const virtualFS = this.#unifiedFS.toJSON();
1796
+ const files = data._initFiles(Object.keys(virtualFS).length);
1797
+ Object.entries(virtualFS).filter(([_, content]) => content).forEach(([path, content], index) => {
1798
+ const fileData = files.get(index);
1799
+ fileData.path = path;
1800
+ fileData.content = content;
1801
+ });
1802
+ const ids = data._initIds(Object.keys(this.ids).length);
1803
+ Object.entries(this.ids).forEach(([id, path], index) => {
1804
+ const fileId = ids.get(index);
1805
+ fileId.id = id;
1806
+ fileId.path = path;
1807
+ });
1808
+ const metadata = data._initMetadata(Object.keys(this.metadata).length);
1809
+ Object.entries(this.metadata).forEach(([id, value], index) => {
1810
+ const fileMetadata = metadata.get(index);
1811
+ fileMetadata.id = id;
1812
+ fileMetadata.mode = value.mode;
1813
+ fileMetadata.variant = value.variant;
1814
+ if (value.properties) {
1815
+ const props = fileMetadata._initProperties(Object.keys(value.properties).length);
1816
+ Object.entries(value.properties).forEach(([key, val], propIndex) => {
1817
+ const propData = props.get(propIndex);
1818
+ propData.key = key;
1819
+ propData.value = val;
1820
+ });
1496
1821
  }
1497
- return ret;
1498
- }, paths) : paths;
1499
- }
1500
- return paths.reduce((ret, path) => {
1501
- if (!ret.includes(path)) {
1502
- ret.push(path);
1503
- }
1504
- return ret;
1505
- }, parents.filter(Boolean).map((p) => this.formatPath(p)));
1506
- }
1507
- /**
1508
- * Select the file system module to use for the operation based on the path or URL.
1509
- *
1510
- * @param pathOrUrl - The path to perform the file system operation on.
1511
- * @param options - Options for the operation, such as output mode.
1512
- * @returns The file system module used for the operation.
1513
- */
1514
- resolveFS(pathOrUrl, options = {}) {
1515
- const mode = this.resolveOutputMode(pathOrUrl, options);
1516
- if (mode === "virtual") {
1517
- return this.#virtualFS;
1518
- } else if (mode === "fs") {
1519
- return this.#fs;
1520
- }
1521
- return this.#unifiedFS;
1522
- }
1523
- /**
1524
- * Select the file system module to use for the operation based on the path or URL.
1525
- *
1526
- * @param pathOrUrl - The path to perform the file system operation on.
1527
- * @param options - Options for the operation, such as output mode.
1528
- * @returns The file system module used for the operation.
1529
- */
1530
- resolveOutputMode(pathOrUrl, options = {}) {
1531
- if (options.mode === "virtual" && this.#context.config.output.mode !== "fs" && isParentPath(toFilePath(pathOrUrl), this.#context.artifactsPath)) {
1532
- return "virtual";
1533
- } else if (options.mode === "fs" || this.#context.config.output.mode === "fs" || isParentPath(toFilePath(pathOrUrl), this.#context.dataPath) || isParentPath(toFilePath(pathOrUrl), this.#context.cachePath) || isParentPath(toFilePath(pathOrUrl), joinPaths(this.#context.workspaceConfig.workspaceRoot, this.#context.config.output.outputPath))) {
1534
- return "fs";
1822
+ });
1823
+ await writeFileBuffer(joinPaths$1(this.#context.cachePath, "fs.bin"), message.toArrayBuffer());
1535
1824
  }
1536
- return void 0;
1537
- }
1538
- /**
1539
- * Clears the resolver cache for a given path.
1540
- *
1541
- * @param path - The path to clear the resolver cache for.
1542
- */
1543
- clearResolverCache(path) {
1544
- this.#cachedResolver.keys().filter((key) => key.startsWith(toFilePath(path))).forEach((key) => this.#cachedResolver.delete(key));
1545
1825
  }
1546
1826
  /**
1547
- * Check if the file exists with different variants (index, extensions).
1548
- *
1549
- * @param request - The request path to check.
1550
- * @param parentPath - An optional parent path to prepend to the request.
1551
- * @returns The file path if it exists, otherwise false.
1827
+ * Initializes the virtual file system (VFS) by patching the file system module if necessary.
1552
1828
  */
1553
- checkVariants(request, parentPath) {
1554
- const path = parentPath ? joinPaths(parentPath, request) : request;
1555
- let file = this.checkExtensions(path);
1556
- if (file) {
1557
- return file;
1558
- }
1559
- file = this.checkIndex(path);
1560
- if (file) {
1561
- return file;
1829
+ [__VFS_PATCH__]() {
1830
+ if (!this.#isPatched && this.#context.config.output.mode !== "fs") {
1831
+ this.#revert = patchFS(fs, this);
1832
+ this.#isPatched = true;
1562
1833
  }
1563
- return false;
1564
1834
  }
1565
1835
  /**
1566
- * Check if the index file exists in the given request path.
1567
- *
1568
- * @param request - The request path to check.
1569
- * @returns The index file path if it exists, otherwise false.
1836
+ * Reverts the file system module to its original state if it was previously patched.
1570
1837
  */
1571
- checkIndex(request) {
1572
- let file = joinPaths(request, "index");
1573
- if (this.#existsSync(file)) {
1574
- return file;
1575
- }
1576
- file = this.checkExtensions(file);
1577
- if (file) {
1578
- return file;
1838
+ [__VFS_REVERT__]() {
1839
+ if (this.#isPatched && this.#context.config.output.mode !== "fs") {
1840
+ if (!this.#revert) {
1841
+ throw new Error("Attempting to revert File System patch prior to calling `__init__` function");
1842
+ }
1843
+ this.#revert?.();
1844
+ this.#isPatched = false;
1579
1845
  }
1580
- return false;
1581
1846
  }
1582
- /**
1583
- * Check if the file exists with different extensions.
1584
- *
1585
- * @param request - The request path to check.
1586
- * @param vfs - The file system module to use for checking file existence.
1587
- * @returns The file path if it exists with any of the checked extensions, otherwise false.
1588
- */
1589
- checkExtensions(request) {
1590
- let file = `${request}.ts`;
1591
- if (this.#existsSync(file)) {
1592
- return file;
1593
- }
1594
- file = `${request}.mts`;
1595
- if (this.#existsSync(file)) {
1596
- return file;
1597
- }
1598
- file = `${request}.cts`;
1599
- if (this.#existsSync(file)) {
1600
- return file;
1601
- }
1602
- file = `${request}.tsx`;
1603
- if (this.#existsSync(file)) {
1604
- return file;
1605
- }
1606
- file = `${request}.js`;
1607
- if (this.#existsSync(file)) {
1608
- return file;
1609
- }
1610
- file = `${request}.mjs`;
1611
- if (this.#existsSync(file)) {
1612
- return file;
1613
- }
1614
- file = `${request}.cjs`;
1615
- if (this.#existsSync(file)) {
1616
- return file;
1617
- }
1618
- file = `${request}.jsx`;
1619
- if (this.#existsSync(file)) {
1620
- return file;
1621
- }
1622
- file = `${request}.json`;
1623
- if (this.#existsSync(file)) {
1624
- return file;
1625
- }
1626
- file = `${request}.d.ts`;
1627
- if (this.#existsSync(file)) {
1628
- return file;
1629
- }
1630
- return false;
1847
+ async [Symbol.asyncDispose]() {
1848
+ return this.dispose();
1631
1849
  }
1632
1850
  };
1633
- function createVfs(context) {
1634
- const vfs = new VirtualFileSystem(context);
1635
- return vfs;
1851
+
1852
+ // ../powerlines/src/types/commands.ts
1853
+ var SUPPORTED_COMMANDS = [
1854
+ "new",
1855
+ "clean",
1856
+ "prepare",
1857
+ "lint",
1858
+ "test",
1859
+ "build",
1860
+ "docs",
1861
+ "deploy",
1862
+ "finalize"
1863
+ ];
1864
+
1865
+ // ../powerlines/src/plugin-utils/helpers.ts
1866
+ function isPlugin(value) {
1867
+ return isSetObject(value) && "name" in value && isSetString(value.name) && (isUndefined(value.applyToEnvironment) || "applyToEnvironment" in value && isFunction(value.applyToEnvironment)) && (isUndefined(value.dedupe) || "dedupe" in value && isFunction(value.dedupe)) && (isUndefined(value.dependsOn) || "dependsOn" in value && Array.isArray(value.dependsOn) && value.dependsOn.every(isPluginConfig)) && SUPPORTED_COMMANDS.every((command) => isUndefined(value[command]) || command in value && (isFunction(value[command]) || isSetObject(value[command]) && "handler" in value[command] && isFunction(value[command].handler)));
1868
+ }
1869
+ __name(isPlugin, "isPlugin");
1870
+ function isPluginConfigObject(value) {
1871
+ return isSetObject(value) && "plugin" in value && ((isSetString(value.plugin) || isFunction(value.plugin)) && "options" in value && isSetObject(value.options) || isPlugin(value.plugin));
1872
+ }
1873
+ __name(isPluginConfigObject, "isPluginConfigObject");
1874
+ function isPluginConfigTuple(value) {
1875
+ return Array.isArray(value) && (value.length === 1 || value.length === 2) && ((isSetString(value[0]) || isFunction(value[0])) && value.length > 1 && isSetObject(value[1]) || isPlugin(value[0]));
1876
+ }
1877
+ __name(isPluginConfigTuple, "isPluginConfigTuple");
1878
+ function isPluginConfig(value) {
1879
+ return isSetString(value) || isFunction(value) || isPlugin(value) || isPluginConfigObject(value) || isPluginConfigTuple(value);
1880
+ }
1881
+ __name(isPluginConfig, "isPluginConfig");
1882
+ function isPluginHookFunction(value) {
1883
+ return isFunction(value) || isSetObject(value) && "handler" in value && isFunction(value.handler);
1884
+ }
1885
+ __name(isPluginHookFunction, "isPluginHookFunction");
1886
+ function isPluginHookObject(value) {
1887
+ return isSetObject(value) && "handler" in value && isFunction(value.handler);
1888
+ }
1889
+ __name(isPluginHookObject, "isPluginHookObject");
1890
+ function isPluginHook(value) {
1891
+ return isPluginHookFunction(value) || isPluginHookObject(value);
1892
+ }
1893
+ __name(isPluginHook, "isPluginHook");
1894
+ function getHookHandler(pluginHook) {
1895
+ return isFunction(pluginHook) ? pluginHook : pluginHook.handler;
1896
+ }
1897
+ __name(getHookHandler, "getHookHandler");
1898
+ function isHookExternal(hook) {
1899
+ return hook.startsWith("vite:") || hook.startsWith("esbuild:") || hook.startsWith("rolldown:") || hook.startsWith("rollup:") || hook.startsWith("webpack:") || hook.startsWith("rspack:") || hook.startsWith("farm:");
1900
+ }
1901
+ __name(isHookExternal, "isHookExternal");
1902
+ function checkDedupe(plugin, plugins2) {
1903
+ return plugin.dedupe === false || plugins2.some((p) => p.dedupe !== false && (isFunction(p.dedupe) && p.dedupe(plugin) || p.name === plugin.name));
1904
+ }
1905
+ __name(checkDedupe, "checkDedupe");
1906
+ function addPluginHook(context, plugin, pluginHook, hooksList) {
1907
+ if (!checkDedupe(plugin, hooksList.map((hook) => hook.plugin))) {
1908
+ hooksList.push(isFunction(pluginHook) ? {
1909
+ plugin,
1910
+ handler: getHookHandler(pluginHook).bind(context)
1911
+ } : {
1912
+ plugin,
1913
+ ...pluginHook,
1914
+ handler: getHookHandler(pluginHook).bind(context)
1915
+ });
1916
+ }
1917
+ }
1918
+ __name(addPluginHook, "addPluginHook");
1919
+ function resolveOptions(options) {
1920
+ return defu2(options, {
1921
+ interopDefault: true,
1922
+ fsCache: options.mode !== "development" ? joinPaths$1(options.cacheDir, "jiti") : false,
1923
+ moduleCache: options.mode !== "development"
1924
+ });
1636
1925
  }
1637
- __name(createVfs, "createVfs");
1926
+ __name(resolveOptions, "resolveOptions");
1927
+ function createPluginResolver(options) {
1928
+ return createJiti(joinPaths$1(options.workspaceRoot, options.projectRoot), resolveOptions({
1929
+ ...options
1930
+ }));
1931
+ }
1932
+ __name(createPluginResolver, "createPluginResolver");
1933
+ function createResolver(options) {
1934
+ const baseResolver = createJiti(joinPaths$1(options.workspaceRoot, options.projectRoot), resolveOptions(options));
1935
+ baseResolver.plugin = createPluginResolver(options);
1936
+ return baseResolver;
1937
+ }
1938
+ __name(createResolver, "createResolver");
1638
1939
 
1639
1940
  // ../powerlines/src/internal/contexts/context.ts
1640
1941
  var configCache = /* @__PURE__ */ new WeakMap();
@@ -1749,7 +2050,7 @@ var PowerlinesContext = class _PowerlinesContext {
1749
2050
  */
1750
2051
  get fs() {
1751
2052
  if (!this.#fs) {
1752
- this.#fs = createVfs(this);
2053
+ this.#fs = VirtualFileSystem.createSync(this);
1753
2054
  }
1754
2055
  return this.#fs;
1755
2056
  }
@@ -1776,9 +2077,7 @@ var PowerlinesContext = class _PowerlinesContext {
1776
2077
  }),
1777
2078
  configHash: murmurhash(this.config, {
1778
2079
  maxLength: CACHE_HASH_LENGTH
1779
- }),
1780
- builtinIdMap: {},
1781
- virtualFiles: {}
2080
+ })
1782
2081
  };
1783
2082
  }
1784
2083
  /**
@@ -1819,31 +2118,31 @@ var PowerlinesContext = class _PowerlinesContext {
1819
2118
  * Get the path to the artifacts directory for the project
1820
2119
  */
1821
2120
  get artifactsPath() {
1822
- return joinPaths$1(this.workspaceConfig.workspaceRoot, this.config.projectRoot, this.config.output.artifactsFolder);
2121
+ return joinPaths(this.workspaceConfig.workspaceRoot, this.config.projectRoot, this.config.output.artifactsFolder);
1823
2122
  }
1824
2123
  /**
1825
2124
  * Get the path to the builtin modules used by the project
1826
2125
  */
1827
2126
  get builtinsPath() {
1828
- return joinPaths$1(this.artifactsPath, "builtins");
2127
+ return joinPaths(this.artifactsPath, "builtins");
1829
2128
  }
1830
2129
  /**
1831
2130
  * Get the path to the entry directory for the project
1832
2131
  */
1833
2132
  get entryPath() {
1834
- return joinPaths$1(this.artifactsPath, "entry");
2133
+ return joinPaths(this.artifactsPath, "entry");
1835
2134
  }
1836
2135
  /**
1837
2136
  * Get the path to the data directory for the project
1838
2137
  */
1839
2138
  get dataPath() {
1840
- return joinPaths$1(this.envPaths.data, "projects", getPrefixedProjectRootHash(this.config.name, this.meta.projectRootHash));
2139
+ return joinPaths(this.envPaths.data, "projects", getPrefixedProjectRootHash(this.config.name, this.meta.projectRootHash));
1841
2140
  }
1842
2141
  /**
1843
2142
  * Get the path to the cache directory for the project
1844
2143
  */
1845
2144
  get cachePath() {
1846
- return joinPaths$1(this.envPaths.cache, "projects", murmurhash({
2145
+ return joinPaths(this.envPaths.cache, "projects", murmurhash({
1847
2146
  checksum: this.#checksum,
1848
2147
  config: this.meta.configHash
1849
2148
  }, {
@@ -1854,7 +2153,7 @@ var PowerlinesContext = class _PowerlinesContext {
1854
2153
  * Get the path to the generated declaration file for the project
1855
2154
  */
1856
2155
  get dtsPath() {
1857
- return this.config.output.dts ? appendPath(this.config.output.dts, this.workspaceConfig.workspaceRoot) : joinPaths$1(this.workspaceConfig.workspaceRoot, this.config.projectRoot, "storm.d.ts");
2156
+ return this.config.output.dts ? appendPath(this.config.output.dts, this.workspaceConfig.workspaceRoot) : joinPaths(this.workspaceConfig.workspaceRoot, this.config.projectRoot, "storm.d.ts");
1858
2157
  }
1859
2158
  /**
1860
2159
  * Get the project root relative to the workspace root
@@ -1866,13 +2165,13 @@ var PowerlinesContext = class _PowerlinesContext {
1866
2165
  * The builtin module id that exist in the Powerlines virtual file system
1867
2166
  */
1868
2167
  get builtins() {
1869
- return Object.values(this.fs.meta).filter((meta) => meta && meta.variant === "builtin").map((meta) => meta?.id).filter(Boolean);
2168
+ return Object.values(this.fs.metadata).filter((meta) => meta && meta.variant === "builtin").map((meta) => meta?.id).filter(Boolean);
1870
2169
  }
1871
2170
  /**
1872
- * Get the project root relative to the workspace root
2171
+ * Get the builtin virtual files that exist in the Powerlines virtual file system
1873
2172
  */
1874
2173
  async getBuiltins() {
1875
- return Promise.all(Object.entries(this.fs.meta).filter(([, meta]) => meta && meta.variant === "builtin").map(async ([path, meta]) => {
2174
+ return Promise.all(Object.entries(this.fs.metadata).filter(([, meta]) => meta && meta.variant === "builtin").map(async ([path, meta]) => {
1876
2175
  const code = await this.fs.readFile(path);
1877
2176
  return {
1878
2177
  ...meta,
@@ -1892,7 +2191,7 @@ var PowerlinesContext = class _PowerlinesContext {
1892
2191
  return this.fs.writeFile(isAbsolute(path) ? path : appendPath(path, this.entryPath), {
1893
2192
  code,
1894
2193
  variant: "entry"
1895
- }, defu3(options, {
2194
+ }, defu2(options, {
1896
2195
  mode: this.config.output.mode
1897
2196
  }));
1898
2197
  }
@@ -1905,11 +2204,11 @@ var PowerlinesContext = class _PowerlinesContext {
1905
2204
  * @param options - Optional write file options
1906
2205
  */
1907
2206
  async writeBuiltin(code, id, path, options = {}) {
1908
- return this.fs.writeFile(path ? isAbsolute(path) ? path : joinPaths$1(this.builtinsPath, path) : appendPath(id, this.builtinsPath), {
2207
+ return this.fs.writeFile(path ? isAbsolute(path) ? path : joinPaths(this.builtinsPath, path) : appendPath(id, this.builtinsPath), {
1909
2208
  id,
1910
2209
  code,
1911
2210
  variant: "builtin"
1912
- }, defu3(options, {
2211
+ }, defu2(options, {
1913
2212
  mode: this.config.output.mode
1914
2213
  }));
1915
2214
  }
@@ -1931,7 +2230,7 @@ var PowerlinesContext = class _PowerlinesContext {
1931
2230
  options
1932
2231
  });
1933
2232
  }
1934
- const result = await parseAsync(id, code, defu3(options ?? {}, {
2233
+ const result = await parseAsync(id, code, defu2(options ?? {}, {
1935
2234
  lang: hasFileExtension(id) ? void 0 : "ts",
1936
2235
  astType: hasFileExtension(id) ? void 0 : "ts",
1937
2236
  sourceType: "module",
@@ -1969,7 +2268,7 @@ ${result.errors.map((error) => ` [${error.severity}] ${error.message}${error.co
1969
2268
  }) {
1970
2269
  this.config.inlineConfig = inlineConfig;
1971
2270
  if (inlineConfig.command === "new") {
1972
- const workspacePackageJsonPath = joinPaths$1(this.workspaceConfig.workspaceRoot, "package.json");
2271
+ const workspacePackageJsonPath = joinPaths(this.workspaceConfig.workspaceRoot, "package.json");
1973
2272
  if (!existsSync(workspacePackageJsonPath)) {
1974
2273
  throw new Error(`The workspace package.json file could not be found at ${workspacePackageJsonPath}`);
1975
2274
  }
@@ -2092,11 +2391,11 @@ ${result.errors.map((error) => ` [${error.severity}] ${error.message}${error.co
2092
2391
  this.resolver = result.resolver;
2093
2392
  this.mergeUserConfig(result.userConfig.config, this.config.userConfig);
2094
2393
  } else {
2095
- const projectJsonPath = joinPaths$1(cacheKey.projectRoot, "project.json");
2394
+ const projectJsonPath = joinPaths(cacheKey.projectRoot, "project.json");
2096
2395
  if (existsSync(projectJsonPath)) {
2097
2396
  this.projectJson = await readJsonFile(projectJsonPath);
2098
2397
  }
2099
- const packageJsonPath = joinPaths$1(cacheKey.projectRoot, "package.json");
2398
+ const packageJsonPath = joinPaths(cacheKey.projectRoot, "package.json");
2100
2399
  if (existsSync(packageJsonPath)) {
2101
2400
  this.packageJson = await readJsonFile(packageJsonPath);
2102
2401
  }
@@ -2119,7 +2418,7 @@ ${result.errors.map((error) => ` [${error.severity}] ${error.message}${error.co
2119
2418
  });
2120
2419
  }
2121
2420
  if (isSetObject(config)) {
2122
- this.resolvedConfig = defu3({
2421
+ this.resolvedConfig = defu2({
2123
2422
  inlineConfig: this.config.inlineConfig,
2124
2423
  userConfig: this.config.userConfig
2125
2424
  }, options.isHighPriority ? this.#getConfigProps(config) : {}, {
@@ -2136,11 +2435,11 @@ ${result.errors.map((error) => ` [${error.severity}] ${error.message}${error.co
2136
2435
  tsconfig: appendPath("tsconfig.json", cacheKey.projectRoot),
2137
2436
  sourceRoot: this.projectJson?.sourceRoot || appendPath("src", cacheKey.projectRoot),
2138
2437
  output: {
2139
- outputPath: joinPaths$1("dist", cacheKey.projectRoot),
2438
+ outputPath: joinPaths("dist", cacheKey.projectRoot),
2140
2439
  mode: "virtual",
2141
- dts: joinPaths$1(cacheKey.projectRoot, `${config.framework ?? "powerlines"}.d.ts`),
2440
+ dts: joinPaths(cacheKey.projectRoot, `${config.framework ?? "powerlines"}.d.ts`),
2142
2441
  builtinPrefix: config.framework ?? "powerlines",
2143
- artifactsFolder: joinPaths$1(cacheKey.projectRoot, `.${config.framework ?? "powerlines"}`),
2442
+ artifactsFolder: joinPaths(cacheKey.projectRoot, `.${config.framework ?? "powerlines"}`),
2144
2443
  assets: [
2145
2444
  {
2146
2445
  glob: "LICENSE"
@@ -2197,12 +2496,12 @@ ${result.errors.map((error) => ` [${error.severity}] ${error.message}${error.co
2197
2496
  ] : [
2198
2497
  "esm"
2199
2498
  ])));
2200
- this.config.output.outputPath ??= joinPaths$1("dist", this.config.projectRoot || ".");
2499
+ this.config.output.outputPath ??= joinPaths("dist", this.config.projectRoot || ".");
2201
2500
  this.config.output.assets = getUnique(this.config.output.assets.map((asset) => {
2202
2501
  return {
2203
2502
  glob: isSetObject(asset) ? asset.glob : asset,
2204
2503
  input: isString(asset) || !asset.input || asset.input === "." || asset.input === "/" || asset.input === "./" ? this.workspaceConfig.workspaceRoot : appendPath(asset.input, this.workspaceConfig.workspaceRoot),
2205
- output: appendPath(isSetObject(asset) && asset.output ? joinPaths$1(this.config.output.outputPath, replacePath(asset.output, this.config.output.outputPath)) : this.config.output.outputPath, this.workspaceConfig.workspaceRoot),
2504
+ output: appendPath(isSetObject(asset) && asset.output ? joinPaths(this.config.output.outputPath, replacePath(asset.output, this.config.output.outputPath)) : this.config.output.outputPath, this.workspaceConfig.workspaceRoot),
2206
2505
  ignore: isSetObject(asset) && asset.ignore ? toArray(asset.ignore) : void 0
2207
2506
  };
2208
2507
  }));
@@ -2213,9 +2512,10 @@ ${result.errors.map((error) => ` [${error.severity}] ${error.message}${error.co
2213
2512
  ret.push(plugin);
2214
2513
  return ret;
2215
2514
  }, []);
2515
+ this.#fs ??= await VirtualFileSystem.create(this);
2216
2516
  }
2217
2517
  mergeUserConfig(from = {}, into = this.config.userConfig ?? {}) {
2218
- this.config.userConfig = defu3({
2518
+ this.config.userConfig = defu2({
2219
2519
  entry: Array.isArray(from.entry) && from.entry.length > 0 ? from.entry : Array.isArray(into?.entry) && into.entry.length > 0 ? into.entry : []
2220
2520
  }, omit(from ?? {}, [
2221
2521
  "entry"
@@ -2580,7 +2880,7 @@ async function emitTypes(context, tsconfig, files) {
2580
2880
  const emitResult = program.emit(void 0, (fileName, text, _, __, sourceFiles, _data) => {
2581
2881
  const sourceFile = sourceFiles?.[0];
2582
2882
  if (sourceFile?.fileName && !fileName.endsWith(".map")) {
2583
- if (context.builtins.some((file) => file === sourceFile.fileName || context.fs.meta[file]?.id && context.fs.meta[file]?.id === sourceFile.fileName)) {
2883
+ if (context.builtins.some((file) => file === sourceFile.fileName || context.fs.metadata[file]?.id && context.fs.metadata[file]?.id === sourceFile.fileName)) {
2584
2884
  builtinModules += `
2585
2885
  declare module "${context.fs.resolve(sourceFile.fileName)}" {
2586
2886
  ${text.trim().replace(/^\s*export\s*declare\s*/gm, "export ").replace(/^\s*declare\s*/gm, "")}
@@ -2669,7 +2969,7 @@ function getTsconfigFilePath(workspaceRoot, projectRoot, tsconfig = "tsconfig.js
2669
2969
  if (!existsSync(tsconfigFilePath)) {
2670
2970
  tsconfigFilePath = appendPath(tsconfig, workspaceRoot);
2671
2971
  if (!existsSync(tsconfigFilePath)) {
2672
- tsconfigFilePath = appendPath(tsconfig, joinPaths(workspaceRoot, projectRoot));
2972
+ tsconfigFilePath = appendPath(tsconfig, joinPaths$1(workspaceRoot, projectRoot));
2673
2973
  if (!existsSync(tsconfigFilePath)) {
2674
2974
  throw new Error(`Cannot find the \`tsconfig.json\` configuration file at ${tsconfig}, ${appendPath(tsconfig, projectRoot)}, ${appendPath(tsconfig, workspaceRoot)}, or ${tsconfigFilePath}`);
2675
2975
  }
@@ -2727,9 +3027,9 @@ function getParsedTypeScriptConfig(workspaceRoot, projectRoot, tsconfig, tsconfi
2727
3027
  const tsconfigFilePath = getTsconfigFilePath(workspaceRoot, projectRoot, tsconfig);
2728
3028
  const tsconfigJson = readJsonFileSync(tsconfigFilePath);
2729
3029
  if (!tsconfigJson) {
2730
- throw new Error(`Cannot find the \`tsconfig.json\` configuration file at ${joinPaths(projectRoot, tsconfig ?? "tsconfig.json")}`);
3030
+ throw new Error(`Cannot find the \`tsconfig.json\` configuration file at ${joinPaths$1(projectRoot, tsconfig ?? "tsconfig.json")}`);
2731
3031
  }
2732
- const parsedCommandLine = ts2.parseJsonConfigFileContent(defu3(tsconfigRaw ?? {}, tsconfigJson), host, appendPath(projectRoot, workspaceRoot));
3032
+ const parsedCommandLine = ts2.parseJsonConfigFileContent(defu2(tsconfigRaw ?? {}, tsconfigJson), host, appendPath(projectRoot, workspaceRoot));
2733
3033
  if (parsedCommandLine.errors.length > 0) {
2734
3034
  const errorMessage = `Cannot parse the TypeScript compiler options. Please investigate the following issues:
2735
3035
  ${parsedCommandLine.errors.map((error) => `- ${(error.category !== void 0 && error.code ? `[${error.category}-${error.code}]: ` : "") + error.messageText.toString()}`).join("\n")}
@@ -2781,8 +3081,8 @@ async function resolveTsconfigChanges(context) {
2781
3081
  tsconfigJson.compilerOptions.emitDecoratorMetadata = true;
2782
3082
  }
2783
3083
  if (context.config.output.dts) {
2784
- const dtsFilePath = context.config.output.dts ? context.config.output.dts.startsWith(context.workspaceConfig.workspaceRoot) ? context.config.output.dts : joinPaths(context.workspaceConfig.workspaceRoot, context.config.output.dts) : joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, "storm.d.ts");
2785
- const dtsRelativePath = joinPaths(relativePath(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot), findFilePath(dtsFilePath)), findFileName(dtsFilePath));
3084
+ const dtsFilePath = context.config.output.dts ? context.config.output.dts.startsWith(context.workspaceConfig.workspaceRoot) ? context.config.output.dts : joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.output.dts) : joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot, "storm.d.ts");
3085
+ const dtsRelativePath = joinPaths$1(relativePath(joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot), findFilePath(dtsFilePath)), findFileName(dtsFilePath));
2786
3086
  if (!tsconfigJson.include?.some((filePattern) => isIncludeMatchFound(filePattern, [
2787
3087
  dtsFilePath,
2788
3088
  dtsRelativePath,
@@ -3021,10 +3321,13 @@ ${context.entry.map((entry) => `- ${entry.input.file || entry.file}${entry.outpu
3021
3321
  await resolveTsconfig(context);
3022
3322
  await installDependencies(context);
3023
3323
  await this.callPostHook(context, "configResolved");
3324
+ if (context.config.build.polyfill) {
3325
+ context.config.build.polyfill = context.config.build.polyfill.map((polyfill) => replacePathTokens(context, polyfill));
3326
+ }
3024
3327
  context.log(LogLevelLabel.TRACE, `Powerlines configuration has been resolved:
3025
3328
 
3026
3329
  ${formatLogMessage(context.config)}`);
3027
- context.fs[__VFS_INIT__]();
3330
+ context.fs[__VFS_PATCH__]();
3028
3331
  await writeMetaFile(context);
3029
3332
  context.persistedMeta = context.meta;
3030
3333
  if (!existsSync(context.cachePath)) {
@@ -3081,10 +3384,10 @@ ${formatLogMessage(context.config)}`);
3081
3384
  }
3082
3385
  return ret;
3083
3386
  }, [
3084
- joinPaths(typescriptPath, "lib", "lib.esnext.full.d.ts")
3387
+ joinPaths$1(typescriptPath, "lib", "lib.esnext.full.d.ts")
3085
3388
  ]);
3086
3389
  context.log(LogLevelLabel.TRACE, "Parsing TypeScript configuration for the Powerlines project.");
3087
- const resolvedTsconfig = getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.tsconfig.tsconfigFilePath, defu3({
3390
+ const resolvedTsconfig = getParsedTypeScriptConfig(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.tsconfig.tsconfigFilePath, defu2({
3088
3391
  compilerOptions: {
3089
3392
  strict: false,
3090
3393
  noEmit: false,
@@ -3099,7 +3402,7 @@ ${formatLogMessage(context.config)}`);
3099
3402
  ],
3100
3403
  include: files
3101
3404
  }, context.config.tsconfigRaw ?? {}));
3102
- resolvedTsconfig.options.configFilePath = joinPaths(context.workspaceConfig.workspaceRoot, context.tsconfig.tsconfigFilePath);
3405
+ resolvedTsconfig.options.configFilePath = joinPaths$1(context.workspaceConfig.workspaceRoot, context.tsconfig.tsconfigFilePath);
3103
3406
  resolvedTsconfig.options.pathsBasePath = context.workspaceConfig.workspaceRoot;
3104
3407
  resolvedTsconfig.options.suppressOutputPathCheck = true;
3105
3408
  let generatedTypes = await emitTypes(context, resolvedTsconfig, files);
@@ -3175,26 +3478,26 @@ ${formatTypes(generatedTypes)}
3175
3478
  await this.#executeEnvironments(async (context) => {
3176
3479
  context.log(LogLevelLabel.TRACE, `Initializing the processing options for the Powerlines project.`);
3177
3480
  await this.callPreHook(context, "new");
3178
- const files = await listFiles(joinPaths(context.powerlinesPath, "files/common/**/*.hbs"));
3481
+ const files = await listFiles(joinPaths$1(context.powerlinesPath, "files/common/**/*.hbs"));
3179
3482
  for (const file of files) {
3180
3483
  context.log(LogLevelLabel.TRACE, `Adding template file: ${file}`);
3181
3484
  const template = Handlebars.compile(file);
3182
- await writeFile(context.log, joinPaths(context.config.projectRoot, file.replace(".hbs", "")), template(context));
3485
+ await writeFile(context.log, joinPaths$1(context.config.projectRoot, file.replace(".hbs", "")), template(context));
3183
3486
  }
3184
3487
  await this.callNormalHook(context, "new");
3185
3488
  if (context.config.projectType === "application") {
3186
- const files2 = await listFiles(joinPaths(context.powerlinesPath, "files/application/**/*.hbs"));
3489
+ const files2 = await listFiles(joinPaths$1(context.powerlinesPath, "files/application/**/*.hbs"));
3187
3490
  for (const file of files2) {
3188
3491
  context.log(LogLevelLabel.TRACE, `Adding application template file: ${file}`);
3189
3492
  const template = Handlebars.compile(file);
3190
- await writeFile(context.log, joinPaths(context.config.projectRoot, file.replace(".hbs", "")), template(context));
3493
+ await writeFile(context.log, joinPaths$1(context.config.projectRoot, file.replace(".hbs", "")), template(context));
3191
3494
  }
3192
3495
  } else {
3193
- const files2 = await listFiles(joinPaths(context.powerlinesPath, "files/library/**/*.hbs"));
3496
+ const files2 = await listFiles(joinPaths$1(context.powerlinesPath, "files/library/**/*.hbs"));
3194
3497
  for (const file of files2) {
3195
3498
  context.log(LogLevelLabel.TRACE, `Adding library template file: ${file}`);
3196
3499
  const template = Handlebars.compile(file);
3197
- await writeFile(context.log, joinPaths(context.config.projectRoot, file.replace(".hbs", "")), template(context));
3500
+ await writeFile(context.log, joinPaths$1(context.config.projectRoot, file.replace(".hbs", "")), template(context));
3198
3501
  }
3199
3502
  }
3200
3503
  await this.callPostHook(context, "new");
@@ -3258,7 +3561,7 @@ ${formatTypes(generatedTypes)}
3258
3561
  await this.callPreHook(context, "build");
3259
3562
  await this.callNormalHook(context, "build");
3260
3563
  await Promise.all(context.config.output.assets.map(async (asset) => {
3261
- context.log(LogLevelLabel.DEBUG, `Copying asset(s): ${chalk5.redBright(context.workspaceConfig.workspaceRoot === asset.input ? asset.glob : joinPaths(replacePath(asset.input, context.workspaceConfig.workspaceRoot), asset.glob))} -> ${chalk5.greenBright(joinPaths(replacePath(asset.output, context.workspaceConfig.workspaceRoot), asset.glob))} ${Array.isArray(asset.ignore) && asset.ignore.length > 0 ? ` (ignoring: ${asset.ignore.map((i) => chalk5.yellowBright(i)).join(", ")})` : ""}`);
3564
+ context.log(LogLevelLabel.DEBUG, `Copying asset(s): ${chalk5.redBright(context.workspaceConfig.workspaceRoot === asset.input ? asset.glob : joinPaths$1(replacePath(asset.input, context.workspaceConfig.workspaceRoot), asset.glob))} -> ${chalk5.greenBright(joinPaths$1(replacePath(asset.output, context.workspaceConfig.workspaceRoot), asset.glob))} ${Array.isArray(asset.ignore) && asset.ignore.length > 0 ? ` (ignoring: ${asset.ignore.map((i) => chalk5.yellowBright(i)).join(", ")})` : ""}`);
3262
3565
  await copyFiles(asset, asset.output);
3263
3566
  }));
3264
3567
  await this.callPostHook(context, "build");
@@ -3286,22 +3589,22 @@ ${formatTypes(generatedTypes)}
3286
3589
  this.#context.log(LogLevelLabel.TRACE, "Powerlines documentation generation completed");
3287
3590
  }
3288
3591
  /**
3289
- * Release the project
3592
+ * Deploy the project source code
3290
3593
  *
3291
3594
  * @remarks
3292
- * This method will prepare and build the Powerlines project, generating the necessary artifacts for release.
3595
+ * This method will prepare and build the Powerlines project, generating the necessary artifacts for the deployment.
3293
3596
  *
3294
- * @param inlineConfig - The inline configuration for the release command
3597
+ * @param inlineConfig - The inline configuration for the deploy command
3295
3598
  */
3296
- async release(inlineConfig = {
3297
- command: "release"
3599
+ async deploy(inlineConfig = {
3600
+ command: "deploy"
3298
3601
  }) {
3299
- this.context.log(LogLevelLabel.INFO, "\u{1F4E6} Releasing the Powerlines project");
3602
+ this.context.log(LogLevelLabel.INFO, "\u{1F4E6} Deploying the Powerlines project");
3300
3603
  await this.prepare(inlineConfig);
3301
3604
  await this.#executeEnvironments(async (context) => {
3302
- await this.callHook(context, "release");
3605
+ await this.callHook(context, "deploy");
3303
3606
  });
3304
- this.context.log(LogLevelLabel.TRACE, "Powerlines release completed");
3607
+ this.context.log(LogLevelLabel.TRACE, "Powerlines deploy completed");
3305
3608
  }
3306
3609
  /**
3307
3610
  * Finalization process
@@ -3316,6 +3619,7 @@ ${formatTypes(generatedTypes)}
3316
3619
  await this.#executeEnvironments(async (context) => {
3317
3620
  await this.callHook(context, "finalize");
3318
3621
  context.fs[__VFS_REVERT__]();
3622
+ await context.fs.dispose();
3319
3623
  });
3320
3624
  this.context.log(LogLevelLabel.TRACE, "Powerlines finalize execution completed");
3321
3625
  }
@@ -3546,7 +3850,7 @@ ${formatTypes(generatedTypes)}
3546
3850
  }
3547
3851
  }
3548
3852
  try {
3549
- const module = await this.context.resolver.plugin.import(this.context.resolver.plugin.esmResolve(joinPaths(pluginPath, "plugin")));
3853
+ const module = await this.context.resolver.plugin.import(this.context.resolver.plugin.esmResolve(joinPaths$1(pluginPath, "plugin")));
3550
3854
  const result = module.plugin ?? module.default;
3551
3855
  if (!result) {
3552
3856
  throw new Error(`The plugin package "${pluginPath}" does not export a valid module.`);
@@ -3589,7 +3893,7 @@ var DEFAULT_ESBUILD_CONFIG = {
3589
3893
  function extractESBuildConfig(context) {
3590
3894
  const inject = context.config.build.override.inject ?? context.config.build.inject;
3591
3895
  if (inject && Object.keys(inject).length > 0) {
3592
- context.fs.writeFileSync(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.artifactsPath, "inject-shim.js"), Object.entries(inject).map(([key, value]) => {
3896
+ context.fs.writeFileSync(joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.artifactsPath, "inject-shim.js"), Object.entries(inject).map(([key, value]) => {
3593
3897
  if (value) {
3594
3898
  if (Array.isArray(value)) {
3595
3899
  if (camelCase(key) !== key) {
@@ -3624,16 +3928,23 @@ export { ${key} };`;
3624
3928
  return "";
3625
3929
  }).join("\n"));
3626
3930
  }
3627
- return defu3({
3931
+ return defu2({
3628
3932
  alias: context.builtins.reduce((ret, id) => {
3629
- const path = context.fs.ids[id];
3630
- if (path) {
3631
- ret[id] = path;
3933
+ if (!ret[id]) {
3934
+ const path = context.fs.ids[id];
3935
+ if (path) {
3936
+ ret[id] = path;
3937
+ }
3938
+ }
3939
+ return ret;
3940
+ }, context.config.build.alias ? Array.isArray(context.config.build.alias) ? context.config.build.alias.reduce((ret, alias) => {
3941
+ if (!ret[alias.find.toString()]) {
3942
+ ret[alias.find.toString()] = alias.replacement;
3632
3943
  }
3633
3944
  return ret;
3634
- }, context.config.build.override.alias ?? context.config.build.alias ?? {}),
3945
+ }, {}) : context.config.build.alias : {}),
3635
3946
  inject: inject && Object.keys(inject).length > 0 ? [
3636
- joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.artifactsPath, "inject-shim.js")
3947
+ joinPaths$1(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.artifactsPath, "inject-shim.js")
3637
3948
  ] : void 0
3638
3949
  }, context.config.build.variant === "esbuild" ? omit(context.config.build.override, [
3639
3950
  "alias",
@@ -3689,15 +4000,28 @@ var DEFAULT_VITE_CONFIG = {
3689
4000
  clearScreen: true
3690
4001
  };
3691
4002
  function extractViteConfig(context) {
3692
- return defu3({
4003
+ return defu2({
3693
4004
  resolve: {
3694
4005
  alias: context.builtins.reduce((ret, id) => {
3695
- const path = context.fs.ids[id];
3696
- if (path) {
3697
- ret[id] = path;
4006
+ if (!ret.find((e) => e.find === id)) {
4007
+ const path = context.fs.ids[id];
4008
+ if (path) {
4009
+ ret.push({
4010
+ find: id,
4011
+ replacement: path
4012
+ });
4013
+ }
4014
+ }
4015
+ return ret;
4016
+ }, context.config.build.alias ? Array.isArray(context.config.build.alias) ? context.config.build.alias : Object.entries(context.config.build.alias).reduce((ret, [id, path]) => {
4017
+ if (!ret.find((e) => e.find === id)) {
4018
+ ret.push({
4019
+ find: id,
4020
+ replacement: path
4021
+ });
3698
4022
  }
3699
4023
  return ret;
3700
- }, {}),
4024
+ }, []) : []),
3701
4025
  dedupe: context.config.build.dedupe,
3702
4026
  mainFields: context.config.build.mainFields,
3703
4027
  conditions: context.config.build.conditions,
@@ -3708,7 +4032,7 @@ function extractViteConfig(context) {
3708
4032
  rootDir: context.config.sourceRoot,
3709
4033
  platform: context.config.build.platform,
3710
4034
  mode: context.config.mode === "development" ? "development" : "production",
3711
- cacheDir: joinPaths(context.cachePath, "vite"),
4035
+ cacheDir: joinPaths$1(context.cachePath, "vite"),
3712
4036
  build: {
3713
4037
  outDir: context.config.output.outputPath,
3714
4038
  tsconfig: context.tsconfig.tsconfigFilePath,
@@ -3759,9 +4083,23 @@ async function handleResolveId(context, args, options = {}) {
3759
4083
  };
3760
4084
  }
3761
4085
  }
3762
- if (context.fs.isTsconfigPath(args.id)) {
3763
- const tsconfigPath = context.fs.resolveTsconfigPath(args.id);
3764
- const tsconfigPathPackage = context.fs.resolveTsconfigPathPackage(args.id);
4086
+ if (!!context.tsconfig.options.paths && Object.keys(context.tsconfig.options.paths).some((path) => args.id.startsWith(path.replaceAll("*", "")))) {
4087
+ let tsconfigPath = false;
4088
+ if (context.tsconfig.options.paths) {
4089
+ for (const tsconfigPathKey of Object.keys(context.tsconfig.options.paths).filter((tsconfigPath2) => args.id.startsWith(tsconfigPath2.replaceAll("*", "")))) {
4090
+ const resolvedPath = context.tsconfig.options.paths[tsconfigPathKey]?.find((tsconfigPath2) => context.fs.resolve(joinPaths(context.workspaceConfig.workspaceRoot, tsconfigPath2.replaceAll("*", ""), args.id.replace(tsconfigPathKey.replaceAll("*", ""), ""))) || context.fs.formatPath(tsconfigPath2) === context.fs.formatPath(args.id));
4091
+ if (resolvedPath) {
4092
+ tsconfigPath = context.fs.formatPath(resolvedPath) === context.fs.formatPath(args.id) ? context.fs.formatPath(resolvedPath) : context.fs.resolve(joinPaths(context.workspaceConfig.workspaceRoot, resolvedPath.replaceAll("*", ""), args.id.replace(tsconfigPathKey.replaceAll("*", ""), "")));
4093
+ }
4094
+ }
4095
+ }
4096
+ let tsconfigPathPackage = false;
4097
+ if (context.tsconfig.options.paths) {
4098
+ const tsconfigPathKeys = Object.keys(context.tsconfig.options.paths).filter((tsconfigPath2) => args.id.startsWith(tsconfigPath2.replaceAll("*", "")));
4099
+ if (tsconfigPathKeys.length > 0 && tsconfigPathKeys[0]) {
4100
+ tsconfigPathPackage = tsconfigPathKeys[0].replace(/\/\*$/, "");
4101
+ }
4102
+ }
3765
4103
  if (tsconfigPath && tsconfigPathPackage) {
3766
4104
  return {
3767
4105
  id: tsconfigPath,
@@ -3794,7 +4132,7 @@ async function handleResolveId(context, args, options = {}) {
3794
4132
  args.importer
3795
4133
  ] : []
3796
4134
  });
3797
- if (match(args.id, options.noExternal) || resolvedPath && context.fs.meta[resolvedPath]?.variant === "builtin") {
4135
+ if (match(args.id, options.noExternal) || resolvedPath && context.fs.metadata[resolvedPath]?.variant === "builtin") {
3798
4136
  return void 0;
3799
4137
  }
3800
4138
  if (match(args.id, options.external) || args.id.startsWith("node:")) {
@@ -3943,7 +4281,7 @@ var vite = createVitePlugin(createUnpluginFactory("vite", (api, plugin) => {
3943
4281
  api.context.config.mode = isDevelopmentMode(env.mode) ? "development" : isTestMode(env.mode) ? "test" : "production";
3944
4282
  const environment = await api.context.getEnvironment();
3945
4283
  const result = await api.callHook(environment, "config");
3946
- return defu3(
4284
+ return defu2(
3947
4285
  extractViteConfig(api.context),
3948
4286
  // Need to use `any` here to avoid excessive type complexity
3949
4287
  result?.build ?? {},
@@ -4011,228 +4349,6 @@ createRolldownPlugin(createUnpluginFactory("rolldown"));
4011
4349
  createRollupPlugin(createUnpluginFactory("rollup"));
4012
4350
  createRspackPlugin(createUnpluginFactory("rspack"));
4013
4351
  createUnloaderPlugin(createUnpluginFactory("unloader"));
4014
- BigInt("0xa56c61324b9d6e49");
4015
- var FileMetadata_KeyValuePair = class extends $.Struct {
4016
- static {
4017
- __name(this, "FileMetadata_KeyValuePair");
4018
- }
4019
- static _capnp = {
4020
- displayName: "KeyValuePair",
4021
- id: "eabb26cf58b2a14c",
4022
- size: new $.ObjectSize(0, 2)
4023
- };
4024
- get key() {
4025
- return $.utils.getText(0, this);
4026
- }
4027
- set key(value) {
4028
- $.utils.setText(0, value, this);
4029
- }
4030
- get value() {
4031
- return $.utils.getText(1, this);
4032
- }
4033
- set value(value) {
4034
- $.utils.setText(1, value, this);
4035
- }
4036
- toString() {
4037
- return "FileMetadata_KeyValuePair_" + super.toString();
4038
- }
4039
- };
4040
- var FileMetadata = class _FileMetadata extends $.Struct {
4041
- static {
4042
- __name(this, "FileMetadata");
4043
- }
4044
- static KeyValuePair = FileMetadata_KeyValuePair;
4045
- static _capnp = {
4046
- displayName: "FileMetadata",
4047
- id: "8e2cab5d7e28c7b3",
4048
- size: new $.ObjectSize(0, 4),
4049
- defaultVariant: "normal"
4050
- };
4051
- static _Properties;
4052
- /**
4053
- * The variant of the file.
4054
- *
4055
- */
4056
- get id() {
4057
- return $.utils.getText(0, this);
4058
- }
4059
- set id(value) {
4060
- $.utils.setText(0, value, this);
4061
- }
4062
- /**
4063
- * The output mode of the file.
4064
- *
4065
- */
4066
- get variant() {
4067
- return $.utils.getText(1, this, _FileMetadata._capnp.defaultVariant);
4068
- }
4069
- set variant(value) {
4070
- $.utils.setText(1, value, this);
4071
- }
4072
- /**
4073
- * Additional metadata associated with the file.
4074
- *
4075
- */
4076
- get mode() {
4077
- return $.utils.getText(2, this);
4078
- }
4079
- set mode(value) {
4080
- $.utils.setText(2, value, this);
4081
- }
4082
- _adoptProperties(value) {
4083
- $.utils.adopt(value, $.utils.getPointer(3, this));
4084
- }
4085
- _disownProperties() {
4086
- return $.utils.disown(this.properties);
4087
- }
4088
- get properties() {
4089
- return $.utils.getList(3, _FileMetadata._Properties, this);
4090
- }
4091
- _hasProperties() {
4092
- return !$.utils.isNull($.utils.getPointer(3, this));
4093
- }
4094
- _initProperties(length) {
4095
- return $.utils.initList(3, _FileMetadata._Properties, length, this);
4096
- }
4097
- set properties(value) {
4098
- $.utils.copyFrom(value, $.utils.getPointer(3, this));
4099
- }
4100
- toString() {
4101
- return "FileMetadata_" + super.toString();
4102
- }
4103
- };
4104
- var FileIdentifier = class extends $.Struct {
4105
- static {
4106
- __name(this, "FileIdentifier");
4107
- }
4108
- static _capnp = {
4109
- displayName: "FileIdentifier",
4110
- id: "e12b8732389d7406",
4111
- size: new $.ObjectSize(0, 2)
4112
- };
4113
- /**
4114
- * An additional identifier for the file.
4115
- *
4116
- */
4117
- get path() {
4118
- return $.utils.getText(0, this);
4119
- }
4120
- set path(value) {
4121
- $.utils.setText(0, value, this);
4122
- }
4123
- get id() {
4124
- return $.utils.getText(1, this);
4125
- }
4126
- set id(value) {
4127
- $.utils.setText(1, value, this);
4128
- }
4129
- toString() {
4130
- return "FileIdentifier_" + super.toString();
4131
- }
4132
- };
4133
- var FileData = class extends $.Struct {
4134
- static {
4135
- __name(this, "FileData");
4136
- }
4137
- static _capnp = {
4138
- displayName: "FileData",
4139
- id: "fa6725c8a360f9a2",
4140
- size: new $.ObjectSize(0, 2)
4141
- };
4142
- /**
4143
- * The contents of the file.
4144
- *
4145
- */
4146
- get path() {
4147
- return $.utils.getText(0, this);
4148
- }
4149
- set path(value) {
4150
- $.utils.setText(0, value, this);
4151
- }
4152
- get content() {
4153
- return $.utils.getText(1, this);
4154
- }
4155
- set content(value) {
4156
- $.utils.setText(1, value, this);
4157
- }
4158
- toString() {
4159
- return "FileData_" + super.toString();
4160
- }
4161
- };
4162
- var FileSystemData = class _FileSystemData extends $.Struct {
4163
- static {
4164
- __name(this, "FileSystemData");
4165
- }
4166
- static _capnp = {
4167
- displayName: "FileSystemData",
4168
- id: "aaa72a672ac0732f",
4169
- size: new $.ObjectSize(0, 3)
4170
- };
4171
- static _Ids;
4172
- static _Metadata;
4173
- static _Files;
4174
- _adoptIds(value) {
4175
- $.utils.adopt(value, $.utils.getPointer(0, this));
4176
- }
4177
- _disownIds() {
4178
- return $.utils.disown(this.ids);
4179
- }
4180
- get ids() {
4181
- return $.utils.getList(0, _FileSystemData._Ids, this);
4182
- }
4183
- _hasIds() {
4184
- return !$.utils.isNull($.utils.getPointer(0, this));
4185
- }
4186
- _initIds(length) {
4187
- return $.utils.initList(0, _FileSystemData._Ids, length, this);
4188
- }
4189
- set ids(value) {
4190
- $.utils.copyFrom(value, $.utils.getPointer(0, this));
4191
- }
4192
- _adoptMetadata(value) {
4193
- $.utils.adopt(value, $.utils.getPointer(1, this));
4194
- }
4195
- _disownMetadata() {
4196
- return $.utils.disown(this.metadata);
4197
- }
4198
- get metadata() {
4199
- return $.utils.getList(1, _FileSystemData._Metadata, this);
4200
- }
4201
- _hasMetadata() {
4202
- return !$.utils.isNull($.utils.getPointer(1, this));
4203
- }
4204
- _initMetadata(length) {
4205
- return $.utils.initList(1, _FileSystemData._Metadata, length, this);
4206
- }
4207
- set metadata(value) {
4208
- $.utils.copyFrom(value, $.utils.getPointer(1, this));
4209
- }
4210
- _adoptFiles(value) {
4211
- $.utils.adopt(value, $.utils.getPointer(2, this));
4212
- }
4213
- _disownFiles() {
4214
- return $.utils.disown(this.files);
4215
- }
4216
- get files() {
4217
- return $.utils.getList(2, _FileSystemData._Files, this);
4218
- }
4219
- _hasFiles() {
4220
- return !$.utils.isNull($.utils.getPointer(2, this));
4221
- }
4222
- _initFiles(length) {
4223
- return $.utils.initList(2, _FileSystemData._Files, length, this);
4224
- }
4225
- set files(value) {
4226
- $.utils.copyFrom(value, $.utils.getPointer(2, this));
4227
- }
4228
- toString() {
4229
- return "FileSystemData_" + super.toString();
4230
- }
4231
- };
4232
- FileMetadata._Properties = $.CompositeList(FileMetadata_KeyValuePair);
4233
- FileSystemData._Ids = $.CompositeList(FileIdentifier);
4234
- FileSystemData._Metadata = $.CompositeList(FileMetadata);
4235
- FileSystemData._Files = $.CompositeList(FileData);
4236
4352
 
4237
4353
  // ../powerlines/src/index.ts
4238
4354
  var src_default = PowerlinesAPI;
@@ -4247,7 +4363,7 @@ function withExecutor(command, executorFn) {
4247
4363
  throw new Error("The executor requires `projectsConfigurations` on the context object.");
4248
4364
  }
4249
4365
  const projectConfig = context.projectsConfigurations.projects[context.projectName];
4250
- const api = await src_default.from(workspaceConfig.workspaceRoot, defu3({
4366
+ const api = await src_default.from(workspaceConfig.workspaceRoot, defu2({
4251
4367
  root: projectConfig.root,
4252
4368
  type: projectConfig.projectType,
4253
4369
  sourceRoot: projectConfig.sourceRoot,
@@ -4260,7 +4376,7 @@ function withExecutor(command, executorFn) {
4260
4376
  }
4261
4377
  }, options));
4262
4378
  try {
4263
- return await Promise.resolve(executorFn(defu3({
4379
+ return await Promise.resolve(executorFn(defu2({
4264
4380
  projectName: context.projectName,
4265
4381
  options,
4266
4382
  workspaceConfig,