@powerlines/plugin-webpack 0.5.132 → 0.5.134

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 (130) hide show
  1. package/dist/_virtual/rolldown_runtime.cjs +29 -0
  2. package/dist/helpers/index.cjs +2 -3
  3. package/dist/helpers/index.d.cts +1 -3
  4. package/dist/helpers/index.d.mts +1 -3
  5. package/dist/helpers/index.mjs +1 -2
  6. package/dist/helpers/unplugin.cjs +11 -2
  7. package/dist/helpers/unplugin.d.cts +6 -2
  8. package/dist/helpers/unplugin.d.mts +6 -2
  9. package/dist/helpers/unplugin.mjs +9 -1
  10. package/dist/index.cjs +8 -50
  11. package/dist/index.d.cts +3 -4
  12. package/dist/index.d.mts +5 -5
  13. package/dist/index.mjs +3 -46
  14. package/dist/powerlines/schemas/fs.cjs +226 -0
  15. package/dist/powerlines/schemas/fs.mjs +224 -0
  16. package/dist/powerlines/src/api.cjs +580 -0
  17. package/dist/powerlines/src/api.mjs +578 -0
  18. package/dist/powerlines/src/internal/babel/module-resolver-plugin.cjs +86 -0
  19. package/dist/powerlines/src/internal/babel/module-resolver-plugin.mjs +84 -0
  20. package/dist/powerlines/src/internal/helpers/environment.cjs +52 -0
  21. package/dist/powerlines/src/internal/helpers/environment.mjs +48 -0
  22. package/dist/powerlines/src/internal/helpers/generate-types.cjs +51 -0
  23. package/dist/powerlines/src/internal/helpers/generate-types.mjs +49 -0
  24. package/dist/powerlines/src/internal/helpers/hooks.cjs +63 -0
  25. package/dist/powerlines/src/internal/helpers/hooks.mjs +61 -0
  26. package/dist/powerlines/src/internal/helpers/install-dependencies.cjs +25 -0
  27. package/dist/powerlines/src/internal/helpers/install-dependencies.mjs +24 -0
  28. package/dist/powerlines/src/internal/helpers/install.cjs +37 -0
  29. package/dist/powerlines/src/internal/helpers/install.mjs +36 -0
  30. package/dist/powerlines/src/internal/helpers/resolve-tsconfig.cjs +98 -0
  31. package/dist/powerlines/src/internal/helpers/resolve-tsconfig.mjs +94 -0
  32. package/dist/powerlines/src/internal/helpers/resolver.cjs +43 -0
  33. package/dist/powerlines/src/internal/helpers/resolver.mjs +41 -0
  34. package/dist/powerlines/src/lib/build/webpack.cjs +47 -0
  35. package/dist/powerlines/src/lib/build/webpack.mjs +45 -0
  36. package/dist/powerlines/src/lib/config-file.cjs +79 -0
  37. package/dist/powerlines/src/lib/config-file.mjs +76 -0
  38. package/dist/powerlines/src/lib/contexts/api-context.cjs +184 -0
  39. package/dist/powerlines/src/lib/contexts/api-context.mjs +182 -0
  40. package/dist/powerlines/src/lib/contexts/context.cjs +933 -0
  41. package/dist/powerlines/src/lib/contexts/context.mjs +931 -0
  42. package/dist/powerlines/src/lib/contexts/environment-context.cjs +160 -0
  43. package/dist/powerlines/src/lib/contexts/environment-context.mjs +159 -0
  44. package/dist/powerlines/src/lib/contexts/plugin-context.cjs +75 -0
  45. package/dist/powerlines/src/lib/contexts/plugin-context.mjs +74 -0
  46. package/dist/powerlines/src/lib/entry.cjs +69 -0
  47. package/dist/powerlines/src/lib/entry.mjs +67 -0
  48. package/dist/powerlines/src/lib/fs/helpers.cjs +85 -0
  49. package/dist/powerlines/src/lib/fs/helpers.mjs +81 -0
  50. package/dist/powerlines/src/lib/fs/storage/base.cjs +196 -0
  51. package/dist/powerlines/src/lib/fs/storage/base.mjs +195 -0
  52. package/dist/powerlines/src/lib/fs/storage/file-system.cjs +170 -0
  53. package/dist/powerlines/src/lib/fs/storage/file-system.mjs +169 -0
  54. package/dist/powerlines/src/lib/fs/storage/virtual.cjs +88 -0
  55. package/dist/powerlines/src/lib/fs/storage/virtual.mjs +87 -0
  56. package/dist/powerlines/src/lib/fs/vfs.cjs +830 -0
  57. package/dist/powerlines/src/lib/fs/vfs.mjs +828 -0
  58. package/dist/powerlines/src/lib/logger.cjs +58 -0
  59. package/dist/powerlines/src/lib/logger.mjs +55 -0
  60. package/dist/powerlines/src/lib/typescript/ts-morph.cjs +104 -0
  61. package/dist/powerlines/src/lib/typescript/ts-morph.mjs +102 -0
  62. package/dist/powerlines/src/lib/typescript/tsconfig.cjs +149 -0
  63. package/dist/powerlines/src/lib/typescript/tsconfig.mjs +144 -0
  64. package/dist/powerlines/src/lib/unplugin/factory.cjs +6 -0
  65. package/dist/powerlines/src/lib/unplugin/factory.mjs +8 -0
  66. package/dist/powerlines/src/lib/unplugin/helpers.cjs +17 -0
  67. package/dist/powerlines/src/lib/unplugin/helpers.mjs +16 -0
  68. package/dist/powerlines/src/lib/unplugin/index.cjs +3 -0
  69. package/dist/powerlines/src/lib/unplugin/index.mjs +5 -0
  70. package/dist/powerlines/src/lib/unplugin/plugin.cjs +128 -0
  71. package/dist/powerlines/src/lib/unplugin/plugin.mjs +127 -0
  72. package/dist/powerlines/src/lib/utilities/file-header.cjs +22 -0
  73. package/dist/powerlines/src/lib/utilities/file-header.mjs +21 -0
  74. package/dist/powerlines/src/lib/utilities/meta.cjs +45 -0
  75. package/dist/powerlines/src/lib/utilities/meta.mjs +41 -0
  76. package/dist/powerlines/src/lib/utilities/source-file.cjs +22 -0
  77. package/dist/powerlines/src/lib/utilities/source-file.mjs +21 -0
  78. package/dist/powerlines/src/plugin-utils/helpers.cjs +148 -0
  79. package/dist/powerlines/src/plugin-utils/helpers.mjs +138 -0
  80. package/dist/powerlines/src/plugin-utils/paths.cjs +36 -0
  81. package/dist/powerlines/src/plugin-utils/paths.mjs +35 -0
  82. package/dist/powerlines/src/types/babel.d.mts +4 -0
  83. package/dist/powerlines/src/types/build.cjs +15 -0
  84. package/dist/powerlines/src/types/build.d.cts +149 -0
  85. package/dist/powerlines/src/types/build.d.mts +149 -0
  86. package/dist/powerlines/src/types/build.mjs +14 -0
  87. package/dist/powerlines/src/types/commands.cjs +16 -0
  88. package/dist/powerlines/src/types/commands.d.cts +8 -0
  89. package/dist/powerlines/src/types/commands.d.mts +9 -0
  90. package/dist/powerlines/src/types/commands.mjs +15 -0
  91. package/dist/powerlines/src/types/config.d.cts +377 -0
  92. package/dist/powerlines/src/types/config.d.mts +379 -0
  93. package/dist/powerlines/src/types/context.d.cts +403 -0
  94. package/dist/powerlines/src/types/context.d.mts +405 -0
  95. package/dist/powerlines/src/types/fs.d.cts +486 -0
  96. package/dist/powerlines/src/types/fs.d.mts +486 -0
  97. package/dist/powerlines/src/types/hooks.d.mts +2 -0
  98. package/dist/powerlines/src/types/plugin.cjs +32 -0
  99. package/dist/powerlines/src/types/plugin.d.cts +231 -0
  100. package/dist/powerlines/src/types/plugin.d.mts +231 -0
  101. package/dist/powerlines/src/types/plugin.mjs +31 -0
  102. package/dist/powerlines/src/types/resolved.d.cts +82 -0
  103. package/dist/powerlines/src/types/resolved.d.mts +83 -0
  104. package/dist/powerlines/src/types/tsconfig.d.cts +69 -0
  105. package/dist/powerlines/src/types/tsconfig.d.mts +69 -0
  106. package/dist/types/index.cjs +0 -2
  107. package/dist/types/index.d.cts +1 -2
  108. package/dist/types/index.d.mts +1 -2
  109. package/dist/types/index.mjs +0 -3
  110. package/dist/types/plugin.cjs +0 -1
  111. package/dist/types/plugin.d.cts +12 -1
  112. package/dist/types/plugin.d.mts +12 -1
  113. package/dist/types/plugin.mjs +0 -2
  114. package/package.json +5 -5
  115. package/dist/helpers-B15z10jN.mjs +0 -1
  116. package/dist/helpers-LF26RHol.cjs +0 -0
  117. package/dist/index-9iG2qHLe.d.mts +0 -1
  118. package/dist/index-D4ELpJXS.d.cts +0 -1
  119. package/dist/index-D6CnpA_r.d.cts +0 -1
  120. package/dist/index-DL0uimUT.d.mts +0 -1
  121. package/dist/plugin-C5bG6Zu0.d.mts +0 -1772
  122. package/dist/plugin-Cl1J-dKa.d.cts +0 -1769
  123. package/dist/plugin-ifZVa20V.mjs +0 -1
  124. package/dist/plugin-pBKbb5K9.cjs +0 -0
  125. package/dist/types-U3zd8PTP.mjs +0 -1
  126. package/dist/types-o3zWarRp.cjs +0 -0
  127. package/dist/unplugin-Bo9KoKSB.d.cts +0 -7
  128. package/dist/unplugin-Ct4wZxE5.d.mts +0 -7
  129. package/dist/unplugin-GJmHohOE.mjs +0 -4617
  130. package/dist/unplugin-bKYETUU8.cjs +0 -4661
@@ -0,0 +1,933 @@
1
+ const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
2
+ const require_ts_morph = require('../typescript/ts-morph.cjs');
3
+ const require_tsconfig = require('../typescript/tsconfig.cjs');
4
+ const require_config_file = require('../config-file.cjs');
5
+ const require_resolver = require('../../internal/helpers/resolver.cjs');
6
+ const require_helpers = require('../../plugin-utils/helpers.cjs');
7
+ const require_paths = require('../../plugin-utils/paths.cjs');
8
+ const require_entry = require('../entry.cjs');
9
+ const require_logger = require('../logger.cjs');
10
+ const require_vfs = require('../fs/vfs.cjs');
11
+ const require_meta = require('../utilities/meta.cjs');
12
+ let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
13
+ let defu = require("defu");
14
+ defu = require_rolldown_runtime.__toESM(defu);
15
+ let __stryke_helpers_omit = require("@stryke/helpers/omit");
16
+ let __stryke_fs_get_workspace_root = require("@stryke/fs/get-workspace-root");
17
+ let __stryke_convert_to_array = require("@stryke/convert/to-array");
18
+ let __stryke_fs_resolve = require("@stryke/fs/resolve");
19
+ let __stryke_path_append = require("@stryke/path/append");
20
+ let __stryke_path_replace = require("@stryke/path/replace");
21
+ let __stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
22
+ let __stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
23
+ let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
24
+ let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
25
+ let __stryke_fs_json = require("@stryke/fs/json");
26
+ let __stryke_json_storm_json = require("@stryke/json/storm-json");
27
+ let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
28
+ let __stryke_fs_exists = require("@stryke/fs/exists");
29
+ let __stryke_env_get_env_paths = require("@stryke/env/get-env-paths");
30
+ let __stryke_hash_hash_files = require("@stryke/hash/hash-files");
31
+ let __stryke_hash_murmurhash = require("@stryke/hash/murmurhash");
32
+ let __stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
33
+ let __stryke_http_fetch = require("@stryke/http/fetch");
34
+ let __stryke_path_is_parent_path = require("@stryke/path/is-parent-path");
35
+ let __stryke_path_is_type = require("@stryke/path/is-type");
36
+ let __stryke_path_join = require("@stryke/path/join");
37
+ let __stryke_type_checks_is_null = require("@stryke/type-checks/is-null");
38
+ let __stryke_unique_id_uuid = require("@stryke/unique-id/uuid");
39
+ let bundle_require = require("bundle-require");
40
+ let flat_cache = require("flat-cache");
41
+ let oxc_parser = require("oxc-parser");
42
+ let undici = require("undici");
43
+
44
+ //#region ../powerlines/src/lib/contexts/context.ts
45
+ const configCache = /* @__PURE__ */ new WeakMap();
46
+ const envPathCache = /* @__PURE__ */ new WeakMap();
47
+ (0, undici.setGlobalDispatcher)(new undici.Agent({ keepAliveTimeout: 1e4 }).compose(undici.interceptors.retry({
48
+ maxRetries: 3,
49
+ minTimeout: 1e3,
50
+ maxTimeout: 1e4,
51
+ timeoutFactor: 2,
52
+ retryAfter: true
53
+ })));
54
+ var PowerlinesContext = class PowerlinesContext {
55
+ /**
56
+ * Internal references storage
57
+ *
58
+ * @danger
59
+ * This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.
60
+ *
61
+ * @internal
62
+ */
63
+ #internal = {};
64
+ #workspaceConfig;
65
+ #checksum = null;
66
+ #buildId = (0, __stryke_unique_id_uuid.uuid)();
67
+ #releaseId = (0, __stryke_unique_id_uuid.uuid)();
68
+ #timestamp = Date.now();
69
+ #entry = null;
70
+ #fs;
71
+ #tsconfig;
72
+ #program;
73
+ #parserCache;
74
+ #requestCache;
75
+ #getConfigProps(config = {}) {
76
+ return (0, defu.default)({
77
+ variant: config.build?.variant,
78
+ projectType: config.type,
79
+ projectRoot: config.root,
80
+ name: config.name,
81
+ title: config.title,
82
+ organization: config.organization,
83
+ compatibilityDate: config.compatibilityDate,
84
+ description: config.description,
85
+ sourceRoot: config.sourceRoot,
86
+ configFile: config.configFile,
87
+ customLogger: config.customLogger,
88
+ logLevel: config.logLevel,
89
+ tsconfig: config.tsconfig,
90
+ tsconfigRaw: config.tsconfigRaw,
91
+ skipCache: config.skipCache,
92
+ skipInstalls: config.skipInstalls,
93
+ entry: config.entry,
94
+ output: config.output,
95
+ plugins: config.plugins,
96
+ mode: config.mode,
97
+ lint: config.lint,
98
+ transform: config.transform,
99
+ build: config.build,
100
+ framework: config.framework,
101
+ ...config
102
+ }, { output: config.framework ? {
103
+ artifactsPath: (0, __stryke_path_join.joinPaths)(config.root ?? this.config.projectRoot, `.${config.framework ?? "powerlines"}`),
104
+ dts: (0, __stryke_path_join.joinPaths)(config.root ?? this.config.projectRoot, `${config.framework ?? "powerlines"}.d.ts`),
105
+ builtinPrefix: config.framework ?? "powerlines"
106
+ } : {} });
107
+ }
108
+ /**
109
+ * Create a new Storm context from the workspace root and user config.
110
+ *
111
+ * @param workspaceRoot - The root directory of the workspace.
112
+ * @param config - The user configuration options.
113
+ * @returns A promise that resolves to the new context.
114
+ */
115
+ static async from(workspaceRoot, config) {
116
+ const context = new PowerlinesContext(await require_config_file.loadWorkspaceConfig(workspaceRoot, config.root));
117
+ await context.withUserConfig(config);
118
+ const powerlinesPath = await (0, __stryke_fs_resolve.resolvePackage)("powerlines");
119
+ if (!powerlinesPath) throw new Error("Could not resolve `powerlines` package location.");
120
+ context.powerlinesPath = powerlinesPath;
121
+ return context;
122
+ }
123
+ /**
124
+ * An object containing the dependencies that should be installed for the project
125
+ */
126
+ dependencies = {};
127
+ /**
128
+ * An object containing the development dependencies that should be installed for the project
129
+ */
130
+ devDependencies = {};
131
+ /**
132
+ * The persisted meta information about the current build
133
+ */
134
+ persistedMeta = void 0;
135
+ /**
136
+ * The path to the Powerlines package
137
+ */
138
+ powerlinesPath;
139
+ /**
140
+ * The parsed `package.json` file for the project
141
+ */
142
+ packageJson;
143
+ /**
144
+ * The parsed `project.json` file for the project
145
+ */
146
+ projectJson = void 0;
147
+ /**
148
+ * The module resolver for the project
149
+ */
150
+ resolver;
151
+ /**
152
+ * The resolved configuration options
153
+ */
154
+ resolvePatterns = [];
155
+ /**
156
+ * Internal context fields and methods
157
+ *
158
+ * @danger
159
+ * This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.
160
+ *
161
+ * @internal
162
+ */
163
+ get $$internal() {
164
+ return this.#internal;
165
+ }
166
+ /**
167
+ * Internal context fields and methods
168
+ *
169
+ * @danger
170
+ * This field is for internal use only and should not be accessed or modified directly. It is unstable and can be changed at anytime.
171
+ *
172
+ * @internal
173
+ */
174
+ set $$internal(value) {
175
+ this.#internal = value;
176
+ }
177
+ /**
178
+ * The resolved entry type definitions for the project
179
+ */
180
+ get entry() {
181
+ return require_entry.resolveEntriesSync(this, !this.#entry ? (0, __stryke_convert_to_array.toArray)(this.config.entry) : this.#entry);
182
+ }
183
+ /**
184
+ * Sets the resolved entry type definitions for the project
185
+ */
186
+ set entry(value) {
187
+ this.#entry = value;
188
+ }
189
+ /**
190
+ * The TypeScript configuration parsed from the tsconfig file
191
+ */
192
+ get tsconfig() {
193
+ if (!this.#tsconfig) this.tsconfig = { tsconfigFilePath: this.config.tsconfig };
194
+ return this.#tsconfig;
195
+ }
196
+ /**
197
+ * Sets the TypeScript configuration parsed from the tsconfig file
198
+ */
199
+ set tsconfig(value) {
200
+ this.#tsconfig = value;
201
+ this.resolvePatterns = (0, bundle_require.tsconfigPathsToRegExp)(value?.options?.paths ?? {});
202
+ }
203
+ /**
204
+ * The virtual file system interface for the project
205
+ */
206
+ get fs() {
207
+ if (!this.#fs) this.#fs = require_vfs.VirtualFileSystem.createSync(this);
208
+ return this.#fs;
209
+ }
210
+ /**
211
+ * Get the checksum of the project's current state
212
+ */
213
+ get checksum() {
214
+ return this.#checksum;
215
+ }
216
+ /**
217
+ * The meta information about the current build
218
+ */
219
+ get meta() {
220
+ return {
221
+ buildId: this.#buildId,
222
+ releaseId: this.#releaseId,
223
+ checksum: this.#checksum,
224
+ timestamp: this.#timestamp,
225
+ projectRootHash: (0, __stryke_hash_murmurhash.murmurhash)({
226
+ workspaceRoot: this.workspaceConfig?.workspaceRoot,
227
+ projectRoot: this.config?.projectRoot
228
+ }, { maxLength: require_meta.PROJECT_ROOT_HASH_LENGTH }),
229
+ configHash: (0, __stryke_hash_murmurhash.murmurhash)(this.config, { maxLength: require_meta.CACHE_HASH_LENGTH })
230
+ };
231
+ }
232
+ /**
233
+ * The resolved configuration options
234
+ */
235
+ get config() {
236
+ return this.resolvedConfig ?? {};
237
+ }
238
+ /**
239
+ * The logger function
240
+ */
241
+ get log() {
242
+ if (!this.logFn) this.logFn = this.createLog();
243
+ return this.logFn;
244
+ }
245
+ /**
246
+ * The workspace configuration
247
+ */
248
+ get workspaceConfig() {
249
+ return this.#workspaceConfig;
250
+ }
251
+ /**
252
+ * The environment paths for the project
253
+ */
254
+ get envPaths() {
255
+ if (envPathCache.has({
256
+ workspaceRoot: this.workspaceConfig.workspaceRoot,
257
+ framework: this.config?.framework || "powerlines"
258
+ })) return envPathCache.get({
259
+ workspaceRoot: this.workspaceConfig.workspaceRoot,
260
+ framework: this.config?.framework || "powerlines"
261
+ });
262
+ const envPaths = (0, __stryke_env_get_env_paths.getEnvPaths)({
263
+ orgId: "storm-software",
264
+ appId: this.config?.framework || "powerlines",
265
+ workspaceRoot: this.workspaceConfig.workspaceRoot
266
+ });
267
+ envPathCache.set({
268
+ workspaceRoot: this.workspaceConfig.workspaceRoot,
269
+ framework: this.config?.framework || "powerlines"
270
+ }, envPaths);
271
+ return envPaths;
272
+ }
273
+ /**
274
+ * Get the path to the artifacts directory for the project
275
+ */
276
+ get artifactsPath() {
277
+ return (0, __stryke_path_join.joinPaths)(this.workspaceConfig.workspaceRoot, this.config.projectRoot, this.config.output.artifactsPath);
278
+ }
279
+ /**
280
+ * Get the path to the builtin modules used by the project
281
+ */
282
+ get builtinsPath() {
283
+ return (0, __stryke_path_join.joinPaths)(this.artifactsPath, "builtins");
284
+ }
285
+ /**
286
+ * Get the path to the entry directory for the project
287
+ */
288
+ get entryPath() {
289
+ return (0, __stryke_path_join.joinPaths)(this.artifactsPath, "entry");
290
+ }
291
+ /**
292
+ * Get the path to the data directory for the project
293
+ */
294
+ get dataPath() {
295
+ return (0, __stryke_path_join.joinPaths)(this.envPaths.data, "projects", require_meta.getPrefixedProjectRootHash(this.config.name, this.meta.projectRootHash));
296
+ }
297
+ /**
298
+ * Get the path to the cache directory for the project
299
+ */
300
+ get cachePath() {
301
+ return (0, __stryke_path_join.joinPaths)(this.envPaths.cache, "projects", (0, __stryke_hash_murmurhash.murmurhash)({
302
+ checksum: this.#checksum,
303
+ config: this.meta.configHash
304
+ }, { maxLength: require_meta.CACHE_HASH_LENGTH }));
305
+ }
306
+ /**
307
+ * Get the path to the generated declaration file for the project
308
+ */
309
+ get dtsPath() {
310
+ return this.config.output.dts ? (0, __stryke_path_append.appendPath)(this.config.output.dts, this.workspaceConfig.workspaceRoot) : (0, __stryke_path_join.joinPaths)(this.workspaceConfig.workspaceRoot, this.config.projectRoot, "powerlines.d.ts");
311
+ }
312
+ /**
313
+ * Get the project root relative to the workspace root
314
+ */
315
+ get relativeToWorkspaceRoot() {
316
+ return (0, __stryke_fs_get_workspace_root.relativeToWorkspaceRoot)(this.config.projectRoot);
317
+ }
318
+ /**
319
+ * The builtin module id that exist in the Powerlines virtual file system
320
+ */
321
+ get builtins() {
322
+ return Object.values(this.fs.metadata).filter((meta) => meta && meta.type === "builtin").map((meta) => meta?.id).filter(Boolean);
323
+ }
324
+ /**
325
+ * The {@link Project} instance used for type reflection and module manipulation
326
+ *
327
+ * @see https://ts-morph.com/
328
+ *
329
+ * @remarks
330
+ * This instance is created lazily on first access.
331
+ */
332
+ get program() {
333
+ if (!this.#program) this.#program = require_ts_morph.createProgram(this, { skipAddingFilesFromTsConfig: true });
334
+ return this.#program;
335
+ }
336
+ /**
337
+ * Gets the parser cache.
338
+ */
339
+ get parserCache() {
340
+ if (!this.#parserCache) this.#parserCache = (0, flat_cache.create)({
341
+ cacheId: "parser",
342
+ cacheDir: this.cachePath,
343
+ ttl: 7200 * 1e3,
344
+ lruSize: 5e3,
345
+ persistInterval: 250
346
+ });
347
+ return this.#parserCache;
348
+ }
349
+ /**
350
+ * Gets the request cache.
351
+ */
352
+ get requestCache() {
353
+ if (!this.#requestCache) this.#requestCache = (0, flat_cache.create)({
354
+ cacheId: "http",
355
+ cacheDir: this.cachePath,
356
+ ttl: 360 * 60 * 1e3,
357
+ lruSize: 5e3,
358
+ persistInterval: 250
359
+ });
360
+ return this.#requestCache;
361
+ }
362
+ /**
363
+ * A function to perform HTTP fetch requests
364
+ *
365
+ * @remarks
366
+ * This function uses a caching layer to avoid duplicate requests during the Powerlines process.
367
+ *
368
+ * @example
369
+ * ```ts
370
+ * const response = await context.fetch("https://api.example.com/data");
371
+ * const data = await response.json();
372
+ * ```
373
+ *
374
+ * @see https://github.com/nodejs/undici
375
+ *
376
+ * @param input - The URL to fetch.
377
+ * @param options - The fetch request options.
378
+ * @returns A promise that resolves to a response returned by the fetch.
379
+ */
380
+ async fetch(input, options = {}) {
381
+ const cacheKey = (0, __stryke_hash_murmurhash.murmurhash)({
382
+ input: input.toString(),
383
+ options: JSON.stringify(options)
384
+ });
385
+ if (!this.config.skipCache && !options.skipCache) {
386
+ const cached = this.requestCache.get(cacheKey);
387
+ if (cached) return new undici.Response(cached.body, {
388
+ status: cached.status,
389
+ statusText: cached.statusText,
390
+ headers: cached.headers
391
+ });
392
+ }
393
+ const response = await (0, __stryke_http_fetch.fetchRequest)(input, {
394
+ timeout: 12e3,
395
+ ...options
396
+ });
397
+ const result = {
398
+ body: await response.text(),
399
+ status: response.status,
400
+ statusText: response.statusText,
401
+ headers: Object.fromEntries(response.headers.entries())
402
+ };
403
+ if (!this.config.skipCache && !options.skipCache) try {
404
+ this.requestCache.set(cacheKey, result);
405
+ } catch {}
406
+ return new undici.Response(result.body, {
407
+ status: result.status,
408
+ statusText: result.statusText,
409
+ headers: result.headers
410
+ });
411
+ }
412
+ /**
413
+ * Parse code using [Oxc-Parser](https://github.com/oxc/oxc) into an (ESTree-compatible)[https://github.com/estree/estree] AST object.
414
+ *
415
+ * @remarks
416
+ * This function can be used to parse TypeScript code into an AST for further analysis or transformation.
417
+ *
418
+ * @example
419
+ * ```ts
420
+ * const ast = context.parse("const x: number = 42;");
421
+ * ```
422
+ *
423
+ * @see https://rollupjs.org/plugin-development/#this-parse
424
+ * @see https://github.com/oxc/oxc
425
+ *
426
+ * @param code - The source code to parse.
427
+ * @param options - The options to pass to the parser.
428
+ * @returns An (ESTree-compatible)[https://github.com/estree/estree] AST object.
429
+ */
430
+ async parse(code, options = {}) {
431
+ const cacheKey = (0, __stryke_hash_murmurhash.murmurhash)({
432
+ code,
433
+ options
434
+ });
435
+ let result;
436
+ if (!this.config.skipCache) {
437
+ result = this.parserCache.get(cacheKey);
438
+ if (result) return result;
439
+ }
440
+ result = await (0, oxc_parser.parse)(`source.${options.lang || "ts"}`, code, {
441
+ ...options,
442
+ sourceType: "module",
443
+ showSemanticErrors: this.config.mode === "development"
444
+ });
445
+ if (!this.config.skipCache) this.parserCache.set(cacheKey, result);
446
+ return result;
447
+ }
448
+ /**
449
+ * A helper function to resolve modules in the Virtual File System
450
+ *
451
+ * @remarks
452
+ * This function can be used to resolve modules relative to the project root directory.
453
+ *
454
+ * @example
455
+ * ```ts
456
+ * const resolved = await context.resolve("some-module", "/path/to/importer");
457
+ * ```
458
+ *
459
+ * @param id - The module to resolve.
460
+ * @param importer - An optional path to the importer module.
461
+ * @param options - Additional resolution options.
462
+ * @returns A promise that resolves to the resolved module path.
463
+ */
464
+ async resolve(id, importer, options = {}) {
465
+ let moduleId = id;
466
+ if (this.config.build.alias) {
467
+ if (Array.isArray(this.config.build.alias)) {
468
+ const alias = this.config.build.alias.find((a) => (0, bundle_require.match)(moduleId, [a.find]));
469
+ if (alias) moduleId = alias.replacement;
470
+ } else if ((0, __stryke_type_checks_is_set_object.isSetObject)(this.config.build.alias) && this.config.build.alias[id]) moduleId = this.config.build.alias[id];
471
+ }
472
+ if (this.fs.isVirtual(moduleId)) {
473
+ const result = await this.fs.resolve(moduleId, importer, {
474
+ conditions: this.config.build.conditions,
475
+ extensions: this.config.build.extensions,
476
+ ...options
477
+ });
478
+ if (!result) return;
479
+ return {
480
+ id: `\0${result}`,
481
+ external: this.config.projectType !== "application"
482
+ };
483
+ }
484
+ if (this.config.build.skipNodeModulesBundle) {
485
+ if ((0, bundle_require.match)(moduleId, this.resolvePatterns) || (0, bundle_require.match)(moduleId, this.config.build.noExternal)) return;
486
+ if ((0, bundle_require.match)(moduleId, this.config.build.external) || moduleId.startsWith("node:")) return {
487
+ id: moduleId,
488
+ external: true
489
+ };
490
+ if (!/^[A-Z]:[/\\]|^\.{0,2}\/|^\.{1,2}$/.test(moduleId)) return {
491
+ id: moduleId,
492
+ external: true
493
+ };
494
+ } else {
495
+ if ((0, bundle_require.match)(moduleId, this.config.build.noExternal)) return;
496
+ if ((0, bundle_require.match)(moduleId, this.config.build.external) || moduleId.startsWith("node:")) return {
497
+ id: moduleId,
498
+ external: true
499
+ };
500
+ }
501
+ }
502
+ /**
503
+ * A helper function to load modules from the Virtual File System
504
+ *
505
+ * @remarks
506
+ * This function can be used to load modules relative to the project root directory.
507
+ *
508
+ * @example
509
+ * ```ts
510
+ * const module = await context.load("some-module", "/path/to/importer");
511
+ * ```
512
+ *
513
+ * @param id - The module to load.
514
+ * @returns A promise that resolves to the loaded module.
515
+ */
516
+ async load(id) {
517
+ const resolvedId = await this.fs.resolve(id);
518
+ if (!resolvedId) return;
519
+ const code = await this.fs.read(resolvedId);
520
+ if (!code) return;
521
+ return {
522
+ code,
523
+ map: null
524
+ };
525
+ }
526
+ /**
527
+ * Get the builtin virtual files that exist in the Powerlines virtual file system
528
+ */
529
+ async getBuiltins() {
530
+ return Promise.all(Object.entries(this.fs.metadata).filter(([, meta]) => meta && meta.type === "builtin").map(async ([path, meta]) => {
531
+ const code = await this.fs.read(path);
532
+ return {
533
+ ...meta,
534
+ path,
535
+ code
536
+ };
537
+ }));
538
+ }
539
+ /**
540
+ * Resolves a file and writes it to the VFS if it does not already exist
541
+ *
542
+ * @param code - The source code of the file
543
+ * @param path - The path to write the file to
544
+ * @param options - Additional options for writing the file
545
+ */
546
+ async emit(code, path, options = {}) {
547
+ if ((0, __stryke_type_checks_is_function.isFunction)(this.emitFile) && options.emitWithBundler) return this.emitFile({
548
+ needsCodeReference: options.needsCodeReference,
549
+ originalFileName: options.originalFileName,
550
+ fileName: path,
551
+ source: code,
552
+ type: "asset"
553
+ });
554
+ return this.fs.write(path, code, options);
555
+ }
556
+ /**
557
+ * Synchronously resolves a file and writes it to the VFS if it does not already exist
558
+ *
559
+ * @param code - The source code of the file
560
+ * @param path - The path to write the file to
561
+ * @param options - Additional options for writing the file
562
+ */
563
+ emitSync(code, path, options = {}) {
564
+ if ((0, __stryke_type_checks_is_function.isFunction)(this.emitFile) && options.emitWithBundler) return this.emitFile({
565
+ needsCodeReference: options.needsCodeReference,
566
+ originalFileName: options.originalFileName,
567
+ fileName: path,
568
+ source: code,
569
+ type: "asset"
570
+ });
571
+ return this.fs.writeSync(path, code, options);
572
+ }
573
+ /**
574
+ * Resolves a entry virtual file and writes it to the VFS if it does not already exist
575
+ *
576
+ * @param code - The source code of the entry file
577
+ * @param path - A path to write the entry file to
578
+ * @param options - Optional write file options
579
+ */
580
+ async emitEntry(code, path, options = {}) {
581
+ const entryPath = (0, __stryke_path_is_type.isAbsolute)(path) ? path : (0, __stryke_path_append.appendPath)(path, this.entryPath);
582
+ this.entry ??= [];
583
+ this.entry.push({
584
+ name: options.name,
585
+ file: entryPath,
586
+ input: options.input,
587
+ output: options.output
588
+ });
589
+ return this.emit(code, entryPath, (0, defu.default)((0, __stryke_helpers_omit.omit)(options, ["name"]), { meta: {
590
+ type: "entry",
591
+ properties: {
592
+ name: options.name,
593
+ output: options.output,
594
+ "input.file": options.input?.file,
595
+ "input.name": options.input?.name
596
+ }
597
+ } }));
598
+ }
599
+ /**
600
+ * Synchronously resolves a entry virtual file and writes it to the VFS if it does not already exist
601
+ *
602
+ * @param code - The source code of the entry file
603
+ * @param path - A path to write the entry file to
604
+ * @param options - Optional write file options
605
+ */
606
+ emitEntrySync(code, path, options = {}) {
607
+ const entryPath = (0, __stryke_path_is_type.isAbsolute)(path) ? path : (0, __stryke_path_append.appendPath)(path, this.entryPath);
608
+ this.entry ??= [];
609
+ this.entry.push({
610
+ name: options?.name,
611
+ file: entryPath,
612
+ input: options?.input,
613
+ output: options?.output
614
+ });
615
+ return this.emitSync(code, entryPath, (0, defu.default)((0, __stryke_helpers_omit.omit)(options, ["name"]), { meta: {
616
+ type: "entry",
617
+ properties: {
618
+ name: options?.name,
619
+ output: options?.output,
620
+ "input.file": options?.input?.file,
621
+ "input.name": options?.input?.name
622
+ }
623
+ } }));
624
+ }
625
+ /**
626
+ * Resolves a builtin virtual file and writes it to the VFS if it does not already exist
627
+ *
628
+ * @param code - The source code of the builtin file
629
+ * @param id - The unique identifier of the builtin file
630
+ * @param path - An optional path to write the builtin file to
631
+ * @param options - Optional write file options
632
+ */
633
+ async emitBuiltin(code, id, path, options = {}) {
634
+ return this.emit(code, path ? (0, __stryke_path_is_type.isAbsolute)(path) ? path : (0, __stryke_path_join.joinPaths)(this.builtinsPath, path) : (0, __stryke_path_append.appendPath)(id, this.builtinsPath), (0, defu.default)(options, { meta: { type: "builtin" } }));
635
+ }
636
+ /**
637
+ * Synchronously resolves a builtin virtual file and writes it to the VFS if it does not already exist
638
+ *
639
+ * @param code - The source code of the builtin file
640
+ * @param id - The unique identifier of the builtin file
641
+ * @param path - An optional path to write the builtin file to
642
+ * @param options - Optional write file options
643
+ */
644
+ emitBuiltinSync(code, id, path, options = {}) {
645
+ return this.emitSync(code, path ? (0, __stryke_path_is_type.isAbsolute)(path) ? path : (0, __stryke_path_join.joinPaths)(this.builtinsPath, path) : (0, __stryke_path_append.appendPath)(id, this.builtinsPath), (0, defu.default)(options, { meta: { type: "builtin" } }));
646
+ }
647
+ /**
648
+ * Update the context using a new user configuration options
649
+ *
650
+ * @param userConfig - The new user configuration options.
651
+ */
652
+ async withUserConfig(userConfig, options = { isHighPriority: true }) {
653
+ this.mergeUserConfig(userConfig);
654
+ await this.init(this.config.userConfig, options);
655
+ }
656
+ /**
657
+ * Update the context using a new inline configuration options
658
+ *
659
+ * @param inlineConfig - The new inline configuration options.
660
+ */
661
+ async withInlineConfig(inlineConfig, options = { isHighPriority: true }) {
662
+ this.config.inlineConfig = inlineConfig;
663
+ if (inlineConfig.command === "new") {
664
+ const workspacePackageJsonPath = (0, __stryke_path_join.joinPaths)(this.workspaceConfig.workspaceRoot, "package.json");
665
+ if (!(0, __stryke_fs_exists.existsSync)(workspacePackageJsonPath)) throw new Error(`The workspace package.json file could not be found at ${workspacePackageJsonPath}`);
666
+ this.packageJson = await (0, __stryke_fs_json.readJsonFile)(workspacePackageJsonPath);
667
+ this.workspaceConfig.repository ??= (0, __stryke_type_checks_is_set_string.isSetString)(this.packageJson?.repository) ? this.packageJson.repository : this.packageJson?.repository?.url;
668
+ }
669
+ await this.init(this.config.inlineConfig, options);
670
+ }
671
+ /**
672
+ * A logging function for fatal messages
673
+ *
674
+ * @param message - The message to log.
675
+ */
676
+ fatal(message) {
677
+ this.log(__storm_software_config_tools_types.LogLevelLabel.FATAL, (0, __stryke_type_checks_is_string.isString)(message) ? message : __stryke_json_storm_json.StormJSON.stringify(message));
678
+ }
679
+ /**
680
+ * A logging function for error messages
681
+ *
682
+ * @param message - The message to log.
683
+ */
684
+ error(message) {
685
+ this.log(__storm_software_config_tools_types.LogLevelLabel.ERROR, (0, __stryke_type_checks_is_string.isString)(message) ? message : __stryke_json_storm_json.StormJSON.stringify(message));
686
+ }
687
+ /**
688
+ * A logging function for warning messages
689
+ *
690
+ * @param message - The message to log.
691
+ */
692
+ warn(message) {
693
+ this.log(__storm_software_config_tools_types.LogLevelLabel.WARN, (0, __stryke_type_checks_is_string.isString)(message) ? message : __stryke_json_storm_json.StormJSON.stringify(message));
694
+ }
695
+ /**
696
+ * A logging function for informational messages
697
+ *
698
+ * @param message - The message to log.
699
+ */
700
+ info(message) {
701
+ this.log(__storm_software_config_tools_types.LogLevelLabel.INFO, (0, __stryke_type_checks_is_string.isString)(message) ? message : __stryke_json_storm_json.StormJSON.stringify(message));
702
+ }
703
+ /**
704
+ * A logging function for debug messages
705
+ *
706
+ * @param message - The message to log.
707
+ */
708
+ debug(message) {
709
+ this.log(__storm_software_config_tools_types.LogLevelLabel.DEBUG, (0, __stryke_type_checks_is_string.isString)(message) ? message : __stryke_json_storm_json.StormJSON.stringify(message));
710
+ }
711
+ /**
712
+ * A logging function for trace messages
713
+ *
714
+ * @param message - The message to log.
715
+ */
716
+ trace(message) {
717
+ this.log(__storm_software_config_tools_types.LogLevelLabel.TRACE, (0, __stryke_type_checks_is_string.isString)(message) ? message : __stryke_json_storm_json.StormJSON.stringify(message));
718
+ }
719
+ /**
720
+ * Create a new logger instance
721
+ *
722
+ * @param name - The name to use for the logger instance
723
+ * @returns A logger function
724
+ */
725
+ createLog(name = null) {
726
+ return require_logger.createLog(name, {
727
+ ...this.config,
728
+ logLevel: (0, __stryke_type_checks_is_null.isNull)(this.config.logLevel) ? "silent" : this.config.logLevel
729
+ });
730
+ }
731
+ /**
732
+ * Extend the current logger instance with a new name
733
+ *
734
+ * @param name - The name to use for the extended logger instance
735
+ * @returns A logger function
736
+ */
737
+ extendLog(name) {
738
+ return require_logger.extendLog(this.log, name);
739
+ }
740
+ /**
741
+ * Generates a checksum representing the current context state
742
+ *
743
+ * @param root - The root directory of the project to generate the checksum for
744
+ * @returns A promise that resolves to a string representing the checksum
745
+ */
746
+ async generateChecksum(root = this.config.projectRoot) {
747
+ this.#checksum = await (0, __stryke_hash_hash_files.hashDirectory)(root, { ignore: [
748
+ "node_modules",
749
+ ".git",
750
+ ".nx",
751
+ ".cache",
752
+ ".storm",
753
+ "tmp",
754
+ "dist"
755
+ ] });
756
+ return this.#checksum;
757
+ }
758
+ /**
759
+ * Creates a new StormContext instance.
760
+ *
761
+ * @param workspaceConfig - The workspace configuration.
762
+ */
763
+ constructor(workspaceConfig) {
764
+ this.#workspaceConfig = workspaceConfig;
765
+ envPathCache.set({
766
+ workspaceRoot: workspaceConfig.workspaceRoot,
767
+ framework: "powerlines"
768
+ }, (0, __stryke_env_get_env_paths.getEnvPaths)({
769
+ orgId: ((0, __stryke_type_checks_is_set_object.isSetObject)(workspaceConfig.organization) ? workspaceConfig.organization.name : workspaceConfig.organization) || "storm-software",
770
+ appId: "powerlines",
771
+ workspaceRoot: workspaceConfig.workspaceRoot
772
+ }));
773
+ }
774
+ /**
775
+ * The resolved configuration for this context
776
+ */
777
+ resolvedConfig = {};
778
+ /**
779
+ * A logger function specific to this context
780
+ */
781
+ logFn;
782
+ /**
783
+ * Initialize the context with the provided configuration options
784
+ *
785
+ * @param config - The partial user configuration to use for initialization.
786
+ */
787
+ async init(config = {}, options = { isHighPriority: true }) {
788
+ const cacheKey = {
789
+ projectRoot: config.root ?? this.config.projectRoot ?? this.config.userConfig?.root ?? this.config.inlineConfig?.root,
790
+ mode: (config.mode ?? this.config.mode) || this.workspaceConfig.mode,
791
+ skipCache: config.skipCache ?? this.config.skipCache ?? false,
792
+ configFile: config.configFile ?? this.config.configFile,
793
+ framework: config.framework ?? this.config.framework ?? "powerlines",
794
+ command: this.config.inlineConfig?.command
795
+ };
796
+ if (configCache.has(cacheKey)) {
797
+ const result = configCache.get(cacheKey);
798
+ this.projectJson = result.projectJson;
799
+ this.packageJson = result.packageJson;
800
+ this.#checksum = result.checksum;
801
+ this.resolver = result.resolver;
802
+ this.mergeUserConfig(result.userConfig.config, this.config.userConfig);
803
+ } else {
804
+ const projectJsonPath = (0, __stryke_path_join.joinPaths)(cacheKey.projectRoot, "project.json");
805
+ if ((0, __stryke_fs_exists.existsSync)(projectJsonPath)) this.projectJson = await (0, __stryke_fs_json.readJsonFile)(projectJsonPath);
806
+ const packageJsonPath = (0, __stryke_path_join.joinPaths)(cacheKey.projectRoot, "package.json");
807
+ if ((0, __stryke_fs_exists.existsSync)(packageJsonPath)) this.packageJson = await (0, __stryke_fs_json.readJsonFile)(packageJsonPath);
808
+ this.#checksum = await this.generateChecksum(cacheKey.projectRoot);
809
+ this.resolver = require_resolver.createResolver({
810
+ workspaceRoot: this.workspaceConfig.workspaceRoot,
811
+ projectRoot: cacheKey.projectRoot,
812
+ cacheDir: this.cachePath,
813
+ mode: cacheKey.mode,
814
+ logLevel: config.logLevel || this.config?.logLevel || this.workspaceConfig.logLevel || "info",
815
+ skipCache: cacheKey.skipCache
816
+ });
817
+ const userConfig = await require_config_file.loadUserConfigFile(cacheKey.projectRoot, this.workspaceConfig.workspaceRoot, this.resolver, cacheKey.command, cacheKey.mode, cacheKey.configFile, cacheKey.framework);
818
+ this.mergeUserConfig(userConfig.config);
819
+ configCache.set(cacheKey, {
820
+ projectJson: this.projectJson,
821
+ packageJson: this.packageJson,
822
+ checksum: this.#checksum,
823
+ resolver: this.resolver,
824
+ userConfig
825
+ });
826
+ }
827
+ config.tsconfig ??= require_tsconfig.getTsconfigFilePath(this.workspaceConfig.workspaceRoot, cacheKey.projectRoot, config.tsconfig);
828
+ if ((0, __stryke_type_checks_is_set_object.isSetObject)(config)) this.resolvedConfig = (0, defu.default)({
829
+ inlineConfig: this.config.inlineConfig,
830
+ userConfig: this.config.userConfig
831
+ }, options.isHighPriority ? this.#getConfigProps(config) : {}, {
832
+ command: this.config.inlineConfig?.command,
833
+ ...this.#getConfigProps(this.config.inlineConfig)
834
+ }, this.#getConfigProps(this.config.userConfig), {
835
+ mode: this.workspaceConfig?.mode,
836
+ logLevel: this.workspaceConfig?.logLevel,
837
+ skipCache: this.workspaceConfig?.skipCache
838
+ }, {
839
+ name: this.projectJson?.name || this.packageJson?.name,
840
+ version: this.packageJson?.version,
841
+ description: this.packageJson?.description,
842
+ sourceRoot: this.projectJson?.sourceRoot || (0, __stryke_path_append.appendPath)("src", cacheKey.projectRoot),
843
+ output: (0, defu.default)(config.output ?? {}, {
844
+ outputPath: cacheKey.projectRoot ? (0, __stryke_path_join.joinPaths)(this.workspaceConfig?.directories?.build || "dist", cacheKey.projectRoot) : this.workspaceConfig?.directories?.build || "dist",
845
+ artifactsPath: (0, __stryke_path_join.joinPaths)(cacheKey.projectRoot, `.${config.framework ?? "powerlines"}`),
846
+ dts: (0, __stryke_path_join.joinPaths)(cacheKey.projectRoot, `${config.framework ?? "powerlines"}.d.ts`),
847
+ builtinPrefix: config.framework ?? "powerlines",
848
+ assets: [
849
+ { glob: "LICENSE" },
850
+ {
851
+ input: cacheKey.projectRoot,
852
+ glob: "*.md"
853
+ },
854
+ {
855
+ input: cacheKey.projectRoot,
856
+ glob: "package.json"
857
+ }
858
+ ]
859
+ })
860
+ }, options.isHighPriority ? {} : this.#getConfigProps(config), {
861
+ inlineConfig: {},
862
+ userConfig: {},
863
+ framework: "powerlines",
864
+ platform: "neutral",
865
+ mode: "production",
866
+ projectType: "application",
867
+ logLevel: "info",
868
+ preview: false,
869
+ environments: {},
870
+ transform: { babel: {
871
+ plugins: [],
872
+ presets: []
873
+ } },
874
+ lint: { eslint: {} },
875
+ build: {
876
+ target: "esnext",
877
+ override: {}
878
+ }
879
+ });
880
+ this.config.entry = require_entry.getUniqueEntries(this.config.entry);
881
+ if (this.config.name?.startsWith("@") && this.config.name.split("/").filter(Boolean).length > 1) this.config.name = this.config.name.split("/").filter(Boolean)[1];
882
+ this.config.title ??= (0, __stryke_string_format_title_case.titleCase)(this.config.name);
883
+ this.config.organization ??= ((0, __stryke_type_checks_is_set_object.isSetObject)(this.workspaceConfig.organization) ? this.workspaceConfig.organization.name : this.workspaceConfig.organization) || ((0, __stryke_type_checks_is_set_object.isSetObject)(this.packageJson?.author) ? this.packageJson?.author?.name : this.packageJson?.author) || this.config.name;
884
+ if (this.config.userConfig.build?.external) this.config.userConfig.build.external = (0, __stryke_helpers_get_unique.getUnique)(this.config.userConfig.build.external);
885
+ if (this.config.userConfig.build?.noExternal) this.config.userConfig.build.noExternal = (0, __stryke_helpers_get_unique.getUnique)(this.config.userConfig.build.noExternal);
886
+ if (this.config.build.external) this.config.build.external = (0, __stryke_helpers_get_unique.getUnique)(this.config.build.external);
887
+ if (this.config.build.noExternal) this.config.build.noExternal = (0, __stryke_helpers_get_unique.getUnique)(this.config.build.noExternal);
888
+ this.config.output.format = (0, __stryke_helpers_get_unique.getUnique)((0, __stryke_convert_to_array.toArray)(this.config.output?.format ?? (this.config.projectType === "library" ? ["cjs", "esm"] : ["esm"])));
889
+ if (this.config.projectRoot && this.config.projectRoot !== "." && this.config.projectRoot !== "./" && this.config.projectRoot !== this.workspaceConfig.workspaceRoot) {
890
+ this.config.output.outputPath ??= (0, __stryke_path_join.joinPaths)("dist", this.config.projectRoot);
891
+ this.config.output.buildPath ??= (0, __stryke_path_join.joinPaths)(this.config.projectRoot, "dist");
892
+ } else {
893
+ this.config.output.outputPath ??= "dist";
894
+ this.config.output.buildPath ??= "dist";
895
+ }
896
+ this.config.output.assets = (0, __stryke_helpers_get_unique.getUniqueBy)(this.config.output.assets.map((asset) => {
897
+ return {
898
+ glob: (0, __stryke_type_checks_is_set_object.isSetObject)(asset) ? asset.glob : asset,
899
+ input: (0, __stryke_type_checks_is_string.isString)(asset) || !asset.input || asset.input === "." || asset.input === "/" || asset.input === "./" ? this.workspaceConfig.workspaceRoot : (0, __stryke_path_is_parent_path.isParentPath)(asset.input, this.workspaceConfig.workspaceRoot) || asset.input === this.workspaceConfig.workspaceRoot ? asset.input : (0, __stryke_path_append.appendPath)(asset.input, this.workspaceConfig.workspaceRoot),
900
+ output: (0, __stryke_type_checks_is_set_object.isSetObject)(asset) && asset.output ? (0, __stryke_path_is_parent_path.isParentPath)(asset.output, this.workspaceConfig.workspaceRoot) ? asset.output : (0, __stryke_path_append.appendPath)((0, __stryke_path_join.joinPaths)(this.config.output.outputPath, (0, __stryke_path_replace.replacePath)((0, __stryke_path_replace.replacePath)(asset.output, (0, __stryke_path_replace.replacePath)(this.config.output.outputPath, this.workspaceConfig.workspaceRoot)), this.config.output.outputPath)), this.workspaceConfig.workspaceRoot) : (0, __stryke_path_append.appendPath)(this.config.output.outputPath, this.workspaceConfig.workspaceRoot),
901
+ ignore: (0, __stryke_type_checks_is_set_object.isSetObject)(asset) && asset.ignore ? (0, __stryke_convert_to_array.toArray)(asset.ignore) : void 0
902
+ };
903
+ }), (a) => `${a.input}-${a.glob}-${a.output}`);
904
+ this.config.plugins = (this.config.plugins ?? []).filter(Boolean).reduce((ret, plugin) => {
905
+ if (require_helpers.isPlugin(plugin) && require_helpers.checkDedupe(plugin, ret.filter((p) => require_helpers.isPlugin(p)))) return ret;
906
+ ret.push(plugin);
907
+ return ret;
908
+ }, []);
909
+ if (this.config.tsconfig) this.config.tsconfig = require_paths.replacePathTokens(this, this.config.tsconfig);
910
+ if (this.config.output.dts) this.config.output.dts = require_paths.replacePathTokens(this, this.config.output.dts);
911
+ if (this.config.build.polyfill) this.config.build.polyfill = this.config.build.polyfill.map((polyfill) => require_paths.replacePathTokens(this, polyfill));
912
+ if (this.config.output.assets) this.config.output.assets = this.config.output.assets.map((asset) => ({
913
+ ...asset,
914
+ glob: require_paths.replacePathTokens(this, asset.glob),
915
+ ignore: asset.ignore ? asset.ignore.map((ignore) => require_paths.replacePathTokens(this, ignore)) : void 0,
916
+ input: require_paths.replacePathTokens(this, asset.input),
917
+ output: require_paths.replacePathTokens(this, asset.output)
918
+ }));
919
+ this.#fs ??= await require_vfs.VirtualFileSystem.create(this);
920
+ }
921
+ mergeUserConfig(from = {}, into = this.config.userConfig ?? {}) {
922
+ this.config.userConfig = (0, defu.default)({ entry: Array.isArray(from.entry) && from.entry.length > 0 ? from.entry : Array.isArray(into?.entry) && into.entry.length > 0 ? into.entry : [] }, (0, __stryke_helpers_omit.omit)(from ?? {}, ["entry"]), (0, __stryke_helpers_omit.omit)(into ?? {}, ["entry"]));
923
+ if (this.config.userConfig.output?.format) this.config.userConfig.output.format = (0, __stryke_helpers_get_unique.getUnique)((0, __stryke_convert_to_array.toArray)(this.config.userConfig.output?.format));
924
+ this.config.userConfig.plugins = (this.config.userConfig.plugins ?? []).filter(Boolean).reduce((ret, plugin) => {
925
+ if (require_helpers.isPlugin(plugin) && require_helpers.checkDedupe(plugin, ret.filter((p) => require_helpers.isPlugin(p)))) return ret;
926
+ ret.push(plugin);
927
+ return ret;
928
+ }, []);
929
+ }
930
+ };
931
+
932
+ //#endregion
933
+ exports.PowerlinesContext = PowerlinesContext;