powerlines 0.40.2 → 0.40.4

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 (132) hide show
  1. package/dist/{api-CHXfSSj6.mjs → api-BaHkkIMl.mjs} +5 -5
  2. package/dist/{api-CHXfSSj6.mjs.map → api-BaHkkIMl.mjs.map} +1 -1
  3. package/dist/{api-DtumO6qc.cjs → api-XX-usBTN.cjs} +4 -4
  4. package/dist/astro.cjs +5 -5
  5. package/dist/astro.d.cts +1 -1
  6. package/dist/astro.d.mts +5 -5
  7. package/dist/astro.mjs +5 -5
  8. package/dist/{config-CY-rNoQX.d.cts → config-BNcBL0tI.d.cts} +23 -1
  9. package/dist/config-BNcBL0tI.d.cts.map +1 -0
  10. package/dist/{config-BYUOZn2-.d.mts → config-Bu97tgeF.d.cts} +2 -2
  11. package/dist/{config-BYUOZn2-.d.mts.map → config-Bu97tgeF.d.cts.map} +1 -1
  12. package/dist/{config-tAvhtoU3.d.cts → config-D2cqq84p.d.mts} +2 -2
  13. package/dist/{config-tAvhtoU3.d.cts.map → config-D2cqq84p.d.mts.map} +1 -1
  14. package/dist/{config-B76VxuFj.d.mts → config-jcYnkMvq.d.mts} +23 -1
  15. package/dist/config-jcYnkMvq.d.mts.map +1 -0
  16. package/dist/config.d.cts +1 -1
  17. package/dist/config.d.mts +2 -2
  18. package/dist/context/index.cjs +3 -3
  19. package/dist/context/index.d.cts +1 -1
  20. package/dist/context/index.d.mts +4 -4
  21. package/dist/context/index.mjs +3 -3
  22. package/dist/{esbuild-ChH1x8Hc.mjs → esbuild-aZZE7sY8.mjs} +3 -3
  23. package/dist/{esbuild-ChH1x8Hc.mjs.map → esbuild-aZZE7sY8.mjs.map} +1 -1
  24. package/dist/{esbuild-BVasizva.cjs → esbuild-osvOb1W1.cjs} +2 -2
  25. package/dist/esbuild.cjs +5 -5
  26. package/dist/esbuild.d.cts +1 -1
  27. package/dist/esbuild.d.mts +4 -4
  28. package/dist/esbuild.mjs +5 -5
  29. package/dist/farm.cjs +3 -3
  30. package/dist/farm.d.cts +1 -1
  31. package/dist/farm.d.mts +4 -4
  32. package/dist/farm.mjs +3 -3
  33. package/dist/{index-C60deASW.d.mts → index-4WNH8dg3.d.mts} +2 -2
  34. package/dist/{index-C60deASW.d.mts.map → index-4WNH8dg3.d.mts.map} +1 -1
  35. package/dist/{index-BbFz3REx.d.mts → index-BjLkEvse.d.mts} +2 -2
  36. package/dist/{index-BbFz3REx.d.mts.map → index-BjLkEvse.d.mts.map} +1 -1
  37. package/dist/{index-DkZkdzSQ.d.cts → index-Cie2X8UH.d.cts} +2 -2
  38. package/dist/{index-DkZkdzSQ.d.cts.map → index-Cie2X8UH.d.cts.map} +1 -1
  39. package/dist/{write-file-gkuvUoFn.d.cts → index-DP6juTGE.d.mts} +35 -6
  40. package/dist/index-DP6juTGE.d.mts.map +1 -0
  41. package/dist/index.cjs +3 -3
  42. package/dist/index.d.cts +6 -6
  43. package/dist/index.d.mts +6 -6
  44. package/dist/index.mjs +3 -3
  45. package/dist/next.cjs +4 -4
  46. package/dist/next.mjs +4 -4
  47. package/dist/nuxt.cjs +6 -6
  48. package/dist/nuxt.d.cts +1 -1
  49. package/dist/nuxt.d.mts +4 -4
  50. package/dist/nuxt.mjs +6 -6
  51. package/dist/{plugin-DE7BXFkV.d.mts → plugin-CO_BQ0th.d.cts} +2 -2
  52. package/dist/{plugin-DE7BXFkV.d.mts.map → plugin-CO_BQ0th.d.cts.map} +1 -1
  53. package/dist/{plugin-C4Et_TED.d.cts → plugin-CvPFipli.d.cts} +2 -2
  54. package/dist/{plugin-C4Et_TED.d.cts.map → plugin-CvPFipli.d.cts.map} +1 -1
  55. package/dist/plugin-utils.d.cts +1 -1
  56. package/dist/plugin-utils.d.mts +5 -5
  57. package/dist/{plugin-XET4WKK4.d.cts → plugin-xJ2LIFca.d.mts} +2 -2
  58. package/dist/{plugin-XET4WKK4.d.cts.map → plugin-xJ2LIFca.d.mts.map} +1 -1
  59. package/dist/{resolve-options-B1gzDFxb.cjs → resolve-options-BQnTgg3V.cjs} +1 -1
  60. package/dist/{resolve-options-Ym_q-Hb7.mjs → resolve-options-DHL3RM8F.mjs} +2 -2
  61. package/dist/{resolve-options-Ym_q-Hb7.mjs.map → resolve-options-DHL3RM8F.mjs.map} +1 -1
  62. package/dist/{rolldown-BEruRGiG.cjs → rolldown-Bn7LucRb.cjs} +1 -1
  63. package/dist/{rolldown-B9d-UBOh.mjs → rolldown-DW7PjwCw.mjs} +2 -2
  64. package/dist/{rolldown-B9d-UBOh.mjs.map → rolldown-DW7PjwCw.mjs.map} +1 -1
  65. package/dist/rolldown.cjs +4 -4
  66. package/dist/rolldown.d.cts +1 -1
  67. package/dist/rolldown.d.mts +4 -4
  68. package/dist/rolldown.mjs +4 -4
  69. package/dist/rollup.cjs +3 -3
  70. package/dist/rollup.d.cts +1 -1
  71. package/dist/rollup.d.mts +4 -4
  72. package/dist/rollup.mjs +3 -3
  73. package/dist/rspack.cjs +3 -3
  74. package/dist/rspack.d.cts +1 -1
  75. package/dist/rspack.d.mts +4 -4
  76. package/dist/rspack.mjs +3 -3
  77. package/dist/storage/index.cjs +3 -1
  78. package/dist/storage/index.d.cts +1 -1
  79. package/dist/storage/index.d.cts.map +1 -1
  80. package/dist/storage/index.d.mts +4 -4
  81. package/dist/storage/index.d.mts.map +1 -1
  82. package/dist/storage/index.mjs +3 -1
  83. package/dist/tsdown.cjs +4 -4
  84. package/dist/tsdown.d.cts +1 -1
  85. package/dist/tsdown.d.mts +4 -4
  86. package/dist/tsdown.mjs +4 -4
  87. package/dist/tsup.cjs +5 -5
  88. package/dist/tsup.d.cts +1 -1
  89. package/dist/tsup.d.mts +4 -4
  90. package/dist/tsup.mjs +5 -5
  91. package/dist/typescript/index.d.cts +1 -1
  92. package/dist/typescript/index.d.mts +4 -4
  93. package/dist/unloader.cjs +3 -3
  94. package/dist/unloader.d.cts +1 -1
  95. package/dist/unloader.d.mts +4 -4
  96. package/dist/unloader.mjs +3 -3
  97. package/dist/unplugin.cjs +3 -3
  98. package/dist/unplugin.d.cts +2 -2
  99. package/dist/unplugin.d.mts +4 -4
  100. package/dist/unplugin.mjs +3 -3
  101. package/dist/{utils-CxKWmhs2.cjs → utils-BbDma_5Y.cjs} +54 -9
  102. package/dist/{utils-RU0EjpzP.mjs → utils-DoQcX7Sk.mjs} +40 -7
  103. package/dist/{utils-RU0EjpzP.mjs.map → utils-DoQcX7Sk.mjs.map} +1 -1
  104. package/dist/utils.cjs +4 -2
  105. package/dist/utils.d.cts +2 -2
  106. package/dist/utils.d.mts +3 -3
  107. package/dist/utils.mjs +2 -2
  108. package/dist/{virtual-D8bn8LRN.cjs → virtual-B1MLgqnQ.cjs} +10 -2
  109. package/dist/{virtual-D-9vfvVY.mjs → virtual-B9imjOqe.mjs} +11 -3
  110. package/dist/virtual-B9imjOqe.mjs.map +1 -0
  111. package/dist/{vite-BF6-Ngk0.cjs → vite-BqvfCVtZ.cjs} +2 -2
  112. package/dist/{vite-DOMQMT51.mjs → vite-D-iV7jRu.mjs} +3 -3
  113. package/dist/{vite-DOMQMT51.mjs.map → vite-D-iV7jRu.mjs.map} +1 -1
  114. package/dist/vite.cjs +5 -5
  115. package/dist/vite.d.cts +2 -2
  116. package/dist/vite.d.mts +5 -5
  117. package/dist/vite.mjs +5 -5
  118. package/dist/{webpack-u38abx-b.cjs → webpack-D8CVT5MS.cjs} +1 -1
  119. package/dist/{webpack-Bm8A2hrJ.mjs → webpack-HfqSdyWi.mjs} +2 -2
  120. package/dist/{webpack-Bm8A2hrJ.mjs.map → webpack-HfqSdyWi.mjs.map} +1 -1
  121. package/dist/webpack.cjs +4 -4
  122. package/dist/webpack.d.cts +1 -1
  123. package/dist/webpack.d.mts +4 -4
  124. package/dist/webpack.mjs +4 -4
  125. package/dist/{index-TMfRNrCg.d.mts → write-file-DKA8GehT.d.cts} +35 -6
  126. package/dist/write-file-DKA8GehT.d.cts.map +1 -0
  127. package/package.json +13 -13
  128. package/dist/config-B76VxuFj.d.mts.map +0 -1
  129. package/dist/config-CY-rNoQX.d.cts.map +0 -1
  130. package/dist/index-TMfRNrCg.d.mts.map +0 -1
  131. package/dist/virtual-D-9vfvVY.mjs.map +0 -1
  132. package/dist/write-file-gkuvUoFn.d.cts.map +0 -1
package/dist/unloader.mjs CHANGED
@@ -1,12 +1,12 @@
1
- import { a as createUnpluginFactory } from "./api-CHXfSSj6.mjs";
1
+ import { a as createUnpluginFactory } from "./api-BaHkkIMl.mjs";
2
2
  import "./tsconfig-B92heKit.mjs";
3
3
  import "./plugin-utils-C3HnZJl1.mjs";
4
4
  import "./plugin-E5foRD0k.mjs";
5
5
  import "./paths-CS8ecCnW.mjs";
6
6
  import "./constants-cXxSHhNp.mjs";
7
7
  import "./config-D4Fh2gQL.mjs";
8
- import "./virtual-D-9vfvVY.mjs";
9
- import "./utils-RU0EjpzP.mjs";
8
+ import "./utils-DoQcX7Sk.mjs";
9
+ import "./virtual-B9imjOqe.mjs";
10
10
  import { createUnloaderPlugin } from "unplugin";
11
11
 
12
12
  //#region src/unloader.ts
package/dist/unplugin.cjs CHANGED
@@ -1,12 +1,12 @@
1
- const require_api = require('./api-DtumO6qc.cjs');
1
+ const require_api = require('./api-XX-usBTN.cjs');
2
2
  require('./tsconfig-C8M8X6U0.cjs');
3
3
  require('./plugin-utils-Ck3cx3w6.cjs');
4
4
  require('./plugin-CZ_PJPpQ.cjs');
5
5
  require('./paths-YmyIGEVo.cjs');
6
6
  require('./constants-CZh5rsgh.cjs');
7
7
  require('./config-D86Vw7SC.cjs');
8
- require('./virtual-D8bn8LRN.cjs');
9
- require('./utils-CxKWmhs2.cjs');
8
+ require('./utils-BbDma_5Y.cjs');
9
+ require('./virtual-B1MLgqnQ.cjs');
10
10
 
11
11
  exports.combineContexts = require_api.combineContexts;
12
12
  exports.createUnplugin = require_api.createUnplugin;
@@ -1,5 +1,5 @@
1
- import { _t as Context, br as UnpluginOptions$1, kr as API, vr as UnpluginBuilderVariant, yr as UnpluginFactory } from "./config-CY-rNoQX.cjs";
2
- import { a as createUnplugin, c as __ΩCreateUnpluginModuleResolutionFunctionsOptions, d as isUnpluginBuilderVariant, i as __ΩCreateUnpluginResolverOptions, l as createUnpluginModuleResolutionFunctions, n as CreateUnpluginResolverOptions, o as createUnpluginResolver, r as __ΩCreateUnpluginOptions, s as CreateUnpluginModuleResolutionFunctionsOptions, t as CreateUnpluginOptions, u as combineContexts } from "./plugin-C4Et_TED.cjs";
1
+ import { _t as Context, br as UnpluginOptions$1, kr as API, vr as UnpluginBuilderVariant, yr as UnpluginFactory } from "./config-BNcBL0tI.cjs";
2
+ import { a as createUnplugin, c as __ΩCreateUnpluginModuleResolutionFunctionsOptions, d as isUnpluginBuilderVariant, i as __ΩCreateUnpluginResolverOptions, l as createUnpluginModuleResolutionFunctions, n as CreateUnpluginResolverOptions, o as createUnpluginResolver, r as __ΩCreateUnpluginOptions, s as CreateUnpluginModuleResolutionFunctionsOptions, t as CreateUnpluginOptions, u as combineContexts } from "./plugin-CvPFipli.cjs";
3
3
  import { UnpluginOptions } from "unplugin";
4
4
 
5
5
  //#region src/unplugin.d.ts
@@ -1,7 +1,7 @@
1
- import { _t as Context, br as UnpluginOptions$1, kr as API, vr as UnpluginBuilderVariant, yr as UnpluginFactory } from "./config-B76VxuFj.mjs";
2
- import "./config-BYUOZn2-.mjs";
3
- import "./index-TMfRNrCg.mjs";
4
- import { a as createUnplugin, c as __ΩCreateUnpluginModuleResolutionFunctionsOptions, d as isUnpluginBuilderVariant, i as __ΩCreateUnpluginResolverOptions, l as createUnpluginModuleResolutionFunctions, n as CreateUnpluginResolverOptions, o as createUnpluginResolver, r as __ΩCreateUnpluginOptions, s as CreateUnpluginModuleResolutionFunctionsOptions, t as CreateUnpluginOptions, u as combineContexts } from "./index-BbFz3REx.mjs";
1
+ import { _t as Context, br as UnpluginOptions$1, kr as API, vr as UnpluginBuilderVariant, yr as UnpluginFactory } from "./config-jcYnkMvq.mjs";
2
+ import "./config-D2cqq84p.mjs";
3
+ import "./index-DP6juTGE.mjs";
4
+ import { a as createUnplugin, c as __ΩCreateUnpluginModuleResolutionFunctionsOptions, d as isUnpluginBuilderVariant, i as __ΩCreateUnpluginResolverOptions, l as createUnpluginModuleResolutionFunctions, n as CreateUnpluginResolverOptions, o as createUnpluginResolver, r as __ΩCreateUnpluginOptions, s as CreateUnpluginModuleResolutionFunctionsOptions, t as CreateUnpluginOptions, u as combineContexts } from "./index-BjLkEvse.mjs";
5
5
  import { UnpluginOptions } from "unplugin";
6
6
 
7
7
  //#region src/unplugin.d.ts
package/dist/unplugin.mjs CHANGED
@@ -1,11 +1,11 @@
1
- import { a as createUnpluginFactory, c as createUnpluginModuleResolutionFunctions, l as combineContexts, o as createUnplugin, s as createUnpluginResolver, u as isUnpluginBuilderVariant } from "./api-CHXfSSj6.mjs";
1
+ import { a as createUnpluginFactory, c as createUnpluginModuleResolutionFunctions, l as combineContexts, o as createUnplugin, s as createUnpluginResolver, u as isUnpluginBuilderVariant } from "./api-BaHkkIMl.mjs";
2
2
  import "./tsconfig-B92heKit.mjs";
3
3
  import "./plugin-utils-C3HnZJl1.mjs";
4
4
  import "./plugin-E5foRD0k.mjs";
5
5
  import "./paths-CS8ecCnW.mjs";
6
6
  import "./constants-cXxSHhNp.mjs";
7
7
  import "./config-D4Fh2gQL.mjs";
8
- import "./virtual-D-9vfvVY.mjs";
9
- import "./utils-RU0EjpzP.mjs";
8
+ import "./utils-DoQcX7Sk.mjs";
9
+ import "./virtual-B9imjOqe.mjs";
10
10
 
11
11
  export { combineContexts, createUnplugin, createUnpluginFactory, createUnpluginModuleResolutionFunctions, createUnpluginResolver, isUnpluginBuilderVariant };
@@ -177,18 +177,51 @@ const extendLog = (logFn, name) => {
177
177
 
178
178
  //#endregion
179
179
  //#region ../core/src/lib/utilities/file-header.ts
180
- function getBaseFileHeader(context) {
180
+ /**
181
+ * Generates a file header comment with a warning about automatic overwriting.
182
+ *
183
+ * @param overwrite - Whether the file will be automatically overwritten. If `false`, the warning will indicate that the file will not be overwritten. If `true` or omitted, the warning will indicate that the file will be overwritten.
184
+ * @param framework - The name of the framework to include in the warning message. Defaults to "powerlines".
185
+ * @returns A string containing the file header warning message.
186
+ */
187
+ function getFileHeaderWarningText(overwrite = true, framework = "powerlines") {
188
+ return overwrite !== false ? `Do not edit this file manually - it will be overwritten automatically. Automatic overwrites can be disabled by using the \`output.overwrite\` option.` : `This file was generated on ${(/* @__PURE__ */ new Date()).toLocaleString()} - it will not be overwritten by ${(0, __stryke_string_format_title_case.titleCase)(framework)} while the \`output.overwrite\` option is set to \`true\`.`;
189
+ }
190
+ /**
191
+ * Generates a file header warning message based on the provided context.
192
+ *
193
+ * @param context - The Powerlines context.
194
+ * @returns A string containing the file header warning message.
195
+ */
196
+ function getFileHeaderWarning(context) {
197
+ return getFileHeaderWarningText(context.config.output?.overwrite, context.config.framework);
198
+ }
199
+ /**
200
+ * Generates a file header comment for a generated source file, including a warning about automatic overwriting.
201
+ *
202
+ * @param context - The Powerlines context.
203
+ * @param comment - The comment syntax to use for the header (e.g., `//` for JavaScript/TypeScript, `#` for Python). Defaults to `//`.
204
+ * @returns A string containing the file header comment.
205
+ */
206
+ function getFileHeader(context, comment = "//") {
181
207
  return `
182
- // Generated by ${(0, __stryke_string_format_title_case.titleCase)(context.config.framework) || "Powerlines"}
183
- ${context.config.output?.overwrite !== false ? `// Do not edit this file manually - it will be overwritten automatically. Automatic overwrites can be disabled by using the \`output.overwrite\` option.` : `// This file was generated on ${(/* @__PURE__ */ new Date()).toLocaleString()} - it will not be overwritten by ${(0, __stryke_string_format_title_case.titleCase)(context.config.framework)} while the \`output.overwrite\` option is set to \`true\`.`}
208
+ ${comment} Generated by ${(0, __stryke_string_format_title_case.titleCase)(context.config.framework) || "Powerlines"}
209
+ ${comment} ${getFileHeaderWarning(context)}
184
210
  `;
185
211
  }
186
- function getFileHeader(context, options = {}) {
212
+ /**
213
+ * Generates a file header comment for a generated TypeScript source file, including a warning about automatic overwriting.
214
+ *
215
+ * @param context - The Powerlines context.
216
+ * @param options - Additional options for generating the file header, such as a directive to include and whether to add a Prettier ignore comment.
217
+ * @returns A string containing the file header comment for a TypeScript file.
218
+ */
219
+ function getTypescriptFileHeader(context, options = {}) {
187
220
  const { directive = null, prettierIgnore = false } = options;
188
221
  return `/* eslint-disable */
189
222
  // biome-ignore lint: disable
190
223
  ${prettierIgnore ? `// prettier-ignore` : ""}${directive ? `\n\n${directive}\n` : "\n"}
191
- ${getBaseFileHeader(context)}
224
+ ${getFileHeader(context)}
192
225
 
193
226
  `;
194
227
  }
@@ -324,16 +357,22 @@ Object.defineProperty(exports, 'generateSourceMap', {
324
357
  return generateSourceMap;
325
358
  }
326
359
  });
327
- Object.defineProperty(exports, 'getBaseFileHeader', {
360
+ Object.defineProperty(exports, 'getFileHeader', {
328
361
  enumerable: true,
329
362
  get: function () {
330
- return getBaseFileHeader;
363
+ return getFileHeader;
331
364
  }
332
365
  });
333
- Object.defineProperty(exports, 'getFileHeader', {
366
+ Object.defineProperty(exports, 'getFileHeaderWarning', {
334
367
  enumerable: true,
335
368
  get: function () {
336
- return getFileHeader;
369
+ return getFileHeaderWarning;
370
+ }
371
+ });
372
+ Object.defineProperty(exports, 'getFileHeaderWarningText', {
373
+ enumerable: true,
374
+ get: function () {
375
+ return getFileHeaderWarningText;
337
376
  }
338
377
  });
339
378
  Object.defineProperty(exports, 'getMagicString', {
@@ -354,6 +393,12 @@ Object.defineProperty(exports, 'getString', {
354
393
  return getString;
355
394
  }
356
395
  });
396
+ Object.defineProperty(exports, 'getTypescriptFileHeader', {
397
+ enumerable: true,
398
+ get: function () {
399
+ return getTypescriptFileHeader;
400
+ }
401
+ });
357
402
  Object.defineProperty(exports, 'getUniqueInputs', {
358
403
  enumerable: true,
359
404
  get: function () {
@@ -173,18 +173,51 @@ const extendLog = (logFn, name) => {
173
173
 
174
174
  //#endregion
175
175
  //#region ../core/src/lib/utilities/file-header.ts
176
- function getBaseFileHeader(context) {
176
+ /**
177
+ * Generates a file header comment with a warning about automatic overwriting.
178
+ *
179
+ * @param overwrite - Whether the file will be automatically overwritten. If `false`, the warning will indicate that the file will not be overwritten. If `true` or omitted, the warning will indicate that the file will be overwritten.
180
+ * @param framework - The name of the framework to include in the warning message. Defaults to "powerlines".
181
+ * @returns A string containing the file header warning message.
182
+ */
183
+ function getFileHeaderWarningText(overwrite = true, framework = "powerlines") {
184
+ return overwrite !== false ? `Do not edit this file manually - it will be overwritten automatically. Automatic overwrites can be disabled by using the \`output.overwrite\` option.` : `This file was generated on ${(/* @__PURE__ */ new Date()).toLocaleString()} - it will not be overwritten by ${titleCase(framework)} while the \`output.overwrite\` option is set to \`true\`.`;
185
+ }
186
+ /**
187
+ * Generates a file header warning message based on the provided context.
188
+ *
189
+ * @param context - The Powerlines context.
190
+ * @returns A string containing the file header warning message.
191
+ */
192
+ function getFileHeaderWarning(context) {
193
+ return getFileHeaderWarningText(context.config.output?.overwrite, context.config.framework);
194
+ }
195
+ /**
196
+ * Generates a file header comment for a generated source file, including a warning about automatic overwriting.
197
+ *
198
+ * @param context - The Powerlines context.
199
+ * @param comment - The comment syntax to use for the header (e.g., `//` for JavaScript/TypeScript, `#` for Python). Defaults to `//`.
200
+ * @returns A string containing the file header comment.
201
+ */
202
+ function getFileHeader(context, comment = "//") {
177
203
  return `
178
- // Generated by ${titleCase(context.config.framework) || "Powerlines"}
179
- ${context.config.output?.overwrite !== false ? `// Do not edit this file manually - it will be overwritten automatically. Automatic overwrites can be disabled by using the \`output.overwrite\` option.` : `// This file was generated on ${(/* @__PURE__ */ new Date()).toLocaleString()} - it will not be overwritten by ${titleCase(context.config.framework)} while the \`output.overwrite\` option is set to \`true\`.`}
204
+ ${comment} Generated by ${titleCase(context.config.framework) || "Powerlines"}
205
+ ${comment} ${getFileHeaderWarning(context)}
180
206
  `;
181
207
  }
182
- function getFileHeader(context, options = {}) {
208
+ /**
209
+ * Generates a file header comment for a generated TypeScript source file, including a warning about automatic overwriting.
210
+ *
211
+ * @param context - The Powerlines context.
212
+ * @param options - Additional options for generating the file header, such as a directive to include and whether to add a Prettier ignore comment.
213
+ * @returns A string containing the file header comment for a TypeScript file.
214
+ */
215
+ function getTypescriptFileHeader(context, options = {}) {
183
216
  const { directive = null, prettierIgnore = false } = options;
184
217
  return `/* eslint-disable */
185
218
  // biome-ignore lint: disable
186
219
  ${prettierIgnore ? `// prettier-ignore` : ""}${directive ? `\n\n${directive}\n` : "\n"}
187
- ${getBaseFileHeader(context)}
220
+ ${getFileHeader(context)}
188
221
 
189
222
  `;
190
223
  }
@@ -302,5 +335,5 @@ async function writeFile$1(log, filepath, content, skipFormat = false) {
302
335
  }
303
336
 
304
337
  //#endregion
305
- export { getString as a, createLog as c, isResolvedEntryTypeDefinition as d, isTypeDefinition as f, resolveInputsSync as g, resolveInputs as h, getSourceFile as i, extendLog as l, resolveInput as m, generateSourceMap as n, getBaseFileHeader as o, resolveEntryOutput as p, getMagicString as r, getFileHeader as s, writeFile$1 as t, getUniqueInputs as u };
306
- //# sourceMappingURL=utils-RU0EjpzP.mjs.map
338
+ export { resolveInputs as _, getString as a, getFileHeaderWarningText as c, extendLog as d, getUniqueInputs as f, resolveInput as g, resolveEntryOutput as h, getSourceFile as i, getTypescriptFileHeader as l, isTypeDefinition as m, generateSourceMap as n, getFileHeader as o, isResolvedEntryTypeDefinition as p, getMagicString as r, getFileHeaderWarning as s, writeFile$1 as t, createLog as u, resolveInputsSync as v };
339
+ //# sourceMappingURL=utils-DoQcX7Sk.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils-RU0EjpzP.mjs","names":["typeDefinition: TypeDefinition","writeFile","writeFileBase"],"sources":["../../core/src/lib/entry.ts","../../core/src/lib/logger.ts","../../core/src/lib/utilities/file-header.ts","../../core/src/lib/utilities/source-file.ts","../../core/src/lib/utilities/source-map.ts","../../core/src/lib/utilities/write-file.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { parseTypeDefinition } from \"@stryke/convert/parse-type-definition\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { murmurhash } from \"@stryke/hash\";\nimport { getUniqueBy } from \"@stryke/helpers/get-unique\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { isAbsolutePath } from \"@stryke/path/is-type\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replaceExtension, replacePath } from \"@stryke/path/replace\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport type {\n TypeDefinition,\n TypeDefinitionParameter\n} from \"@stryke/types/configuration\";\nimport { replacePathTokens } from \"../plugin-utils/paths\";\nimport { BaseConfig } from \"../types\";\nimport { ResolvedEntryTypeDefinition } from \"../types/config\";\nimport type { Context } from \"../types/context\";\n\nexport function resolveEntryOutput(\n context: Context,\n typeDefinition: TypeDefinition\n): string {\n return replaceExtension(\n replacePath(\n replacePath(\n replacePath(\n replacePath(\n replacePath(\n typeDefinition.file,\n joinPaths(\n context.workspaceConfig.workspaceRoot,\n context.config.root,\n \"src\"\n )\n ),\n joinPaths(\n context.workspaceConfig.workspaceRoot,\n context.config.root\n )\n ),\n joinPaths(context.config.root, \"src\")\n ),\n context.config.root\n ),\n \"src\"\n )\n );\n}\n\nexport function resolveInput(\n context: Context,\n typeDefinition: TypeDefinition,\n input?: TypeDefinitionParameter,\n output?: string\n): ResolvedEntryTypeDefinition {\n return {\n ...typeDefinition,\n input: isSetString(input) ? { file: String(input) } : typeDefinition,\n output: output || resolveEntryOutput(context, typeDefinition)\n };\n}\n\n/**\n * Resolves multiple type definitions into their corresponding resolved entry type definitions.\n *\n * @param context - The current context\n * @param typeDefinitions - The type definitions to resolve.\n * @returns A promise that resolves to an array of resolved entry type definitions.\n */\nexport async function resolveInputs(\n context: Context,\n typeDefinitions:\n | TypeDefinitionParameter\n | TypeDefinitionParameter[]\n | Record<string, TypeDefinitionParameter | TypeDefinitionParameter[]>\n): Promise<ResolvedEntryTypeDefinition[]> {\n return (\n await Promise.all(\n (isObject(typeDefinitions) && !isTypeDefinition(typeDefinitions)\n ? Object.values(typeDefinitions).flat()\n : toArray(typeDefinitions)\n )\n .map(async entry => {\n if (isResolvedEntryTypeDefinition(entry)) {\n return {\n ...entry,\n output: entry.output\n ? replacePathTokens(context, entry.output)\n : undefined,\n file: replacePathTokens(context, entry.file)\n };\n }\n\n let typeDefinition: TypeDefinition;\n if (isString(entry)) {\n typeDefinition = parseTypeDefinition(\n replacePathTokens(context, entry)\n )!;\n } else {\n typeDefinition = entry;\n typeDefinition.file = replacePathTokens(\n context,\n typeDefinition.file\n );\n }\n\n const filePath = isAbsolutePath(typeDefinition.file)\n ? typeDefinition.file\n : appendPath(typeDefinition.file, context.config.root);\n if (await context.fs.isFile(filePath)) {\n return resolveInput(\n context,\n {\n file: replacePath(filePath, context.config.root),\n name: typeDefinition.name\n },\n (entry as ResolvedEntryTypeDefinition).input,\n (entry as ResolvedEntryTypeDefinition).output\n );\n }\n\n return (\n await context.fs.glob(\n appendPath(filePath, context.workspaceConfig.workspaceRoot)\n )\n ).map(file =>\n resolveInput(\n context,\n {\n file: replacePath(file, context.config.root),\n name: typeDefinition.name\n },\n (entry as ResolvedEntryTypeDefinition).input,\n (entry as ResolvedEntryTypeDefinition).output\n )\n );\n })\n .flat()\n .filter(Boolean)\n )\n ).flat();\n}\n\n/**\n * Resolves multiple type definitions into their corresponding resolved entry type definitions.\n *\n * @param context - The current context\n * @param typeDefinitions - The type definitions to resolve.\n * @returns A promise that resolves to an array of resolved entry type definitions.\n */\nexport function resolveInputsSync(\n context: Context,\n typeDefinitions:\n | TypeDefinitionParameter\n | TypeDefinitionParameter[]\n | Record<string, TypeDefinitionParameter | TypeDefinitionParameter[]>\n): ResolvedEntryTypeDefinition[] {\n return (\n isObject(typeDefinitions) && !isTypeDefinition(typeDefinitions)\n ? Object.values(typeDefinitions).flat()\n : toArray(typeDefinitions)\n )\n .map(entry => {\n if (isResolvedEntryTypeDefinition(entry)) {\n return {\n ...entry,\n output: entry.output\n ? replacePathTokens(context, entry.output)\n : undefined,\n file: replacePathTokens(context, entry.file)\n };\n }\n\n let typeDefinition: TypeDefinition;\n if (isString(entry)) {\n typeDefinition = parseTypeDefinition(\n replacePathTokens(context, entry)\n )!;\n } else {\n typeDefinition = entry;\n typeDefinition.file = replacePathTokens(context, typeDefinition.file);\n }\n\n const filePath = isAbsolutePath(typeDefinition.file)\n ? typeDefinition.file\n : appendPath(typeDefinition.file, context.config.root);\n if (context.fs.isFileSync(filePath)) {\n return resolveInput(context, {\n file: appendPath(filePath, context.workspaceConfig.workspaceRoot),\n name: typeDefinition.name\n });\n }\n\n return context.fs\n .globSync(appendPath(filePath, context.workspaceConfig.workspaceRoot))\n .map(file =>\n resolveInput(context, {\n file,\n name: typeDefinition.name\n })\n );\n })\n .flat()\n .filter(Boolean);\n}\n\n/**\n * Checks if the provided entry is a type definition.\n *\n * @param entry - The entry to check.\n * @returns True if the entry is a type definition, false otherwise.\n */\nexport function isTypeDefinition(entry: any): entry is TypeDefinition {\n return !isString(entry) && entry.file !== undefined;\n}\n\n/**\n * Checks if the provided entry is a resolved entry type definition.\n *\n * @param entry - The entry to check.\n * @returns True if the entry is a resolved entry type definition, false otherwise.\n */\nexport function isResolvedEntryTypeDefinition(\n entry: TypeDefinitionParameter | ResolvedEntryTypeDefinition\n): entry is ResolvedEntryTypeDefinition {\n return (\n isTypeDefinition(entry) &&\n (entry as ResolvedEntryTypeDefinition).output !== undefined\n );\n}\n\n/**\n * Get unique inputs from the provided list.\n *\n * @param inputs - The entry points to process.\n * @returns An array of unique inputs (by file path or content hash).\n */\nexport function getUniqueInputs(\n inputs: BaseConfig[\"input\"] = []\n): BaseConfig[\"input\"] {\n return isObject(inputs)\n ? inputs\n : getUniqueBy(toArray(inputs), (item: TypeDefinitionParameter) =>\n isSetString(item) ? item : murmurhash(item ?? {}, { maxLength: 24 })\n );\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { getLogFn, getLogLevel } from \"@storm-software/config-tools/logger\";\nimport { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport { getColor } from \"@storm-software/config-tools/utilities/colors\";\nimport { noop } from \"@stryke/helpers/noop\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport chalk from \"chalk\";\nimport type { LogFn, WorkspaceConfig } from \"../types\";\n\nexport interface CreateLogOptions {\n name?: string;\n logLevel?: LogLevelLabel | null;\n customLogger?: LogFn;\n colors?: WorkspaceConfig[\"colors\"];\n}\n\n/**\n * Create a logging function with a specific name and options.\n *\n * @param name - The name of the logging function.\n * @param options - The options to configure the logging function.\n * @returns A logging function.\n */\nexport const createLog = (\n name: string | null,\n options: CreateLogOptions = {}\n): LogFn => {\n const logLevel =\n options.logLevel === null\n ? LogLevelLabel.SILENT\n : options.logLevel || LogLevelLabel.INFO;\n if (logLevel === LogLevelLabel.SILENT) {\n return noop;\n }\n\n if (options.customLogger) {\n return options.customLogger;\n }\n\n return (type: LogLevelLabel, ...args: string[]) =>\n getLogFn(getLogLevel(type), {\n ...options,\n logLevel\n })(\n `${chalk.bold.hex(\n getColor(\"brand\", options as Parameters<typeof getColor>[1])\n )(\n `${name ? kebabCase(name) : \"\"}${options.name ? `${name ? chalk.gray(\" > \") : \"\"}${kebabCase(options.name)}` : \"\"}${chalk.gray(\" > \")}`\n )}${args.join(\" \")} `.trim()\n );\n};\n\nconst BADGE_COLORS = [\n \"#00A0DD\",\n \"#6FCE4E\",\n \"#FBBF24\",\n \"#F43F5E\",\n \"#3B82F6\",\n \"#A855F7\",\n \"#469592\",\n \"#288EDF\",\n \"#D8B4FE\",\n \"#10B981\",\n \"#EF4444\",\n \"#F0EC56\",\n \"#F472B6\",\n \"#22D3EE\",\n \"#EAB308\",\n \"#84CC16\",\n \"#F87171\",\n \"#0EA5E9\",\n \"#D946EF\",\n \"#FACC15\",\n \"#34D399\",\n \"#8B5CF6\"\n] as const;\n\nexport const extendLog = (logFn: LogFn, name: string): LogFn => {\n return (type: LogLevelLabel, ...args: string[]) =>\n logFn(\n type,\n ` ${chalk.inverse.hex(\n BADGE_COLORS[\n name\n .split(\"\")\n .map(char => char.charCodeAt(0))\n .reduce((ret, charCode) => ret + charCode, 0) % BADGE_COLORS.length\n ] || BADGE_COLORS[0]\n )(` ${titleCase(name)} `)} ${args.join(\" \")} `\n );\n};\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { Context } from \"../../types/context\";\n\nexport interface FileHeaderOptions {\n directive?: string | null;\n prettierIgnore?: boolean;\n}\n\nexport function getBaseFileHeader(context: Context): string {\n return `\n// Generated by ${titleCase(context.config.framework) || \"Powerlines\"}\n${\n context.config.output?.overwrite !== false\n ? `// Do not edit this file manually - it will be overwritten automatically. Automatic overwrites can be disabled by using the \\`output.overwrite\\` option.`\n : `// This file was generated on ${new Date().toLocaleString()} - it will not be overwritten by ${titleCase(context.config.framework)} while the \\`output.overwrite\\` option is set to \\`true\\`.`\n}\n`;\n}\n\nexport function getFileHeader(\n context: Context,\n options: FileHeaderOptions = {}\n): string {\n const { directive = null, prettierIgnore = false } = options;\n\n return `/* eslint-disable */\n// biome-ignore lint: disable\n${prettierIgnore ? `// prettier-ignore` : \"\"}${directive ? `\\n\\n${directive}\\n` : \"\\n\"}\n${getBaseFileHeader(context)}\n\n`;\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { readFileIfExistingSync } from \"@stryke/fs/read-file\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport MagicString from \"magic-string\";\nimport { TransformResult } from \"unplugin\";\nimport { SourceFile } from \"../../types/context\";\n\n/**\n * Get the string from the source.\n *\n * @param code - The source string or magic string.\n * @returns The source string.\n */\nexport function getString(\n code: string | MagicString | TransformResult\n): string {\n if (!code) {\n return \"\";\n }\n\n if (isString(code)) {\n return code;\n }\n\n if (isSetObject(code) && \"code\" in code) {\n return code.code;\n }\n\n return code.toString();\n}\n\n/**\n * Get the magic string.\n *\n * @param code - The source string or magic string.\n * @returns The magic string.\n */\nexport function getMagicString(code: string | MagicString): MagicString {\n if (isString(code)) {\n return new MagicString(code);\n }\n\n return code;\n}\n\n/**\n * Get the source file.\n *\n * @param code - The source code.\n * @param id - The name of the file.\n * @returns The source file.\n */\nexport function getSourceFile(\n code: string | MagicString,\n id: string\n): SourceFile {\n const content = code ?? readFileIfExistingSync(id);\n\n return {\n id,\n code: getMagicString(content),\n env: []\n };\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport Diff from \"diff-match-patch\";\nimport type MagicString from \"magic-string\";\nimport type { TransformResult } from \"../../types/context\";\n\nconst dmp = new Diff();\n\n/**\n * Generate code with source map.\n *\n * @param code - The source code.\n * @param id - The file name.\n * @param transpiled - The transpiled code.\n * @returns The compiler result.\n */\nexport function generateSourceMap(\n code: MagicString,\n id: string,\n transpiled?: string\n): TransformResult | undefined {\n if (!transpiled) {\n return;\n }\n\n const diff = dmp.diff_main(code.toString(), transpiled);\n dmp.diff_cleanupSemantic(diff);\n\n let offset = 0;\n\n for (let index = 0; index < diff.length; index++) {\n if (diff[index]) {\n const [type, text] = diff[index]!;\n const textLength = text.length;\n\n switch (type) {\n case 0: {\n offset += textLength;\n break;\n }\n case 1: {\n code.prependLeft(offset, text);\n break;\n }\n case -1: {\n const next = diff.at(index + 1);\n\n if (next && next[0] === 1) {\n const replaceText = next[1];\n\n const firstNonWhitespaceIndexOfText = text.search(/\\S/);\n const offsetStart =\n offset + Math.max(firstNonWhitespaceIndexOfText, 0);\n\n code.update(offsetStart, offset + textLength, replaceText);\n index += 1;\n } else {\n code.remove(offset, offset + textLength);\n }\n\n offset += textLength;\n\n break;\n }\n }\n }\n }\n\n if (!code.hasChanged()) {\n return;\n }\n\n return {\n code: code.toString(),\n map: code.generateMap({\n source: id,\n file: `${id}.map`,\n includeContent: true\n })\n };\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport { writeFile as writeFileBase } from \"@stryke/fs/write-file\";\nimport { format, resolveConfig } from \"prettier\";\nimport type { LogFn } from \"../../types/config\";\n\n/**\n * Writes and formats a file to the file system\n *\n * @param log - The logging function to use for logging errors\n * @param filepath - The file path to write the file\n * @param content - The content to write to the file\n * @param skipFormat - Should the plugin skip formatting the `content` string with Prettier\n */\nexport async function writeFile(\n log: LogFn,\n filepath: string,\n content: string,\n skipFormat = false\n) {\n try {\n if (skipFormat) {\n await writeFileBase(filepath, content);\n } else {\n const config = await resolveConfig(filepath);\n const formatted = await format(content, {\n ...(config ?? {}),\n filepath\n });\n\n await writeFileBase(filepath, formatted || \"\");\n }\n } catch (error) {\n log(\n LogLevelLabel.ERROR,\n `Failed to write file ${filepath} to disk \\n${(error as Error)?.message ? (error as Error).message : \"\"}`\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,SAAgB,mBACd,SACA,gBACQ;AACR,QAAO,iBACL,YACE,YACE,YACE,YACE,YACE,eAAe,MACf,UACE,QAAQ,gBAAgB,eACxB,QAAQ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AAG;KACzB,MAAM,cAAc,KAAK;KAEzB,MAAM,gCAAgC,KAAK,OAAO,KAAK;KACvD,MAAM,cACJ,SAAS,KAAK,IAAI,+BAA+B,EAAE;AAErD,UAAK,OAAO,aAAa,SAAS,YAAY,YAAY;AAC1D,cAAS;UAET,MAAK,OAAO,QAAQ,SAAS,WAAW;AAG1C,cAAU;AAEV;;;;AAMR,KAAI,CAAC,KAAK,YAAY,CACpB;AAGF,QAAO;EACL,MAAM,KAAK,UAAU;EACrB,KAAK,KAAK,YAAY;GACpB,QAAQ;GACR,MAAM,GAAG,GAAG;GACZ,gBAAgB;GACjB,CAAC;EACH;;;;;;;;;;;;;AChEH,eAAsBC,YACpB,KACA,UACA,SACA,aAAa,OACb;AACA,KAAI;AACF,MAAI,WACF,OAAMC,UAAc,UAAU,QAAQ;MAQtC,OAAMA,UAAc,UALF,MAAM,OAAO,SAAS;GACtC,GAFa,MAAM,cAAc,SAAS,IAE5B,EAAE;GAChB;GACD,CAAC,IAEyC,GAAG;UAEzC,OAAO;AACd,MACE,cAAc,OACd,wBAAwB,SAAS,aAAc,OAAiB,UAAW,MAAgB,UAAU,KACtG"}
1
+ {"version":3,"file":"utils-DoQcX7Sk.mjs","names":["typeDefinition: TypeDefinition","writeFile","writeFileBase"],"sources":["../../core/src/lib/entry.ts","../../core/src/lib/logger.ts","../../core/src/lib/utilities/file-header.ts","../../core/src/lib/utilities/source-file.ts","../../core/src/lib/utilities/source-map.ts","../../core/src/lib/utilities/write-file.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { parseTypeDefinition } from \"@stryke/convert/parse-type-definition\";\nimport { toArray } from \"@stryke/convert/to-array\";\nimport { murmurhash } from \"@stryke/hash\";\nimport { getUniqueBy } from \"@stryke/helpers/get-unique\";\nimport { appendPath } from \"@stryke/path/append\";\nimport { isAbsolutePath } from \"@stryke/path/is-type\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { replaceExtension, replacePath } from \"@stryke/path/replace\";\nimport { isObject } from \"@stryke/type-checks/is-object\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport type {\n TypeDefinition,\n TypeDefinitionParameter\n} from \"@stryke/types/configuration\";\nimport { replacePathTokens } from \"../plugin-utils/paths\";\nimport { BaseConfig } from \"../types\";\nimport { ResolvedEntryTypeDefinition } from \"../types/config\";\nimport type { Context } from \"../types/context\";\n\nexport function resolveEntryOutput(\n context: Context,\n typeDefinition: TypeDefinition\n): string {\n return replaceExtension(\n replacePath(\n replacePath(\n replacePath(\n replacePath(\n replacePath(\n typeDefinition.file,\n joinPaths(\n context.workspaceConfig.workspaceRoot,\n context.config.root,\n \"src\"\n )\n ),\n joinPaths(\n context.workspaceConfig.workspaceRoot,\n context.config.root\n )\n ),\n joinPaths(context.config.root, \"src\")\n ),\n context.config.root\n ),\n \"src\"\n )\n );\n}\n\nexport function resolveInput(\n context: Context,\n typeDefinition: TypeDefinition,\n input?: TypeDefinitionParameter,\n output?: string\n): ResolvedEntryTypeDefinition {\n return {\n ...typeDefinition,\n input: isSetString(input) ? { file: String(input) } : typeDefinition,\n output: output || resolveEntryOutput(context, typeDefinition)\n };\n}\n\n/**\n * Resolves multiple type definitions into their corresponding resolved entry type definitions.\n *\n * @param context - The current context\n * @param typeDefinitions - The type definitions to resolve.\n * @returns A promise that resolves to an array of resolved entry type definitions.\n */\nexport async function resolveInputs(\n context: Context,\n typeDefinitions:\n | TypeDefinitionParameter\n | TypeDefinitionParameter[]\n | Record<string, TypeDefinitionParameter | TypeDefinitionParameter[]>\n): Promise<ResolvedEntryTypeDefinition[]> {\n return (\n await Promise.all(\n (isObject(typeDefinitions) && !isTypeDefinition(typeDefinitions)\n ? Object.values(typeDefinitions).flat()\n : toArray(typeDefinitions)\n )\n .map(async entry => {\n if (isResolvedEntryTypeDefinition(entry)) {\n return {\n ...entry,\n output: entry.output\n ? replacePathTokens(context, entry.output)\n : undefined,\n file: replacePathTokens(context, entry.file)\n };\n }\n\n let typeDefinition: TypeDefinition;\n if (isString(entry)) {\n typeDefinition = parseTypeDefinition(\n replacePathTokens(context, entry)\n )!;\n } else {\n typeDefinition = entry;\n typeDefinition.file = replacePathTokens(\n context,\n typeDefinition.file\n );\n }\n\n const filePath = isAbsolutePath(typeDefinition.file)\n ? typeDefinition.file\n : appendPath(typeDefinition.file, context.config.root);\n if (await context.fs.isFile(filePath)) {\n return resolveInput(\n context,\n {\n file: replacePath(filePath, context.config.root),\n name: typeDefinition.name\n },\n (entry as ResolvedEntryTypeDefinition).input,\n (entry as ResolvedEntryTypeDefinition).output\n );\n }\n\n return (\n await context.fs.glob(\n appendPath(filePath, context.workspaceConfig.workspaceRoot)\n )\n ).map(file =>\n resolveInput(\n context,\n {\n file: replacePath(file, context.config.root),\n name: typeDefinition.name\n },\n (entry as ResolvedEntryTypeDefinition).input,\n (entry as ResolvedEntryTypeDefinition).output\n )\n );\n })\n .flat()\n .filter(Boolean)\n )\n ).flat();\n}\n\n/**\n * Resolves multiple type definitions into their corresponding resolved entry type definitions.\n *\n * @param context - The current context\n * @param typeDefinitions - The type definitions to resolve.\n * @returns A promise that resolves to an array of resolved entry type definitions.\n */\nexport function resolveInputsSync(\n context: Context,\n typeDefinitions:\n | TypeDefinitionParameter\n | TypeDefinitionParameter[]\n | Record<string, TypeDefinitionParameter | TypeDefinitionParameter[]>\n): ResolvedEntryTypeDefinition[] {\n return (\n isObject(typeDefinitions) && !isTypeDefinition(typeDefinitions)\n ? Object.values(typeDefinitions).flat()\n : toArray(typeDefinitions)\n )\n .map(entry => {\n if (isResolvedEntryTypeDefinition(entry)) {\n return {\n ...entry,\n output: entry.output\n ? replacePathTokens(context, entry.output)\n : undefined,\n file: replacePathTokens(context, entry.file)\n };\n }\n\n let typeDefinition: TypeDefinition;\n if (isString(entry)) {\n typeDefinition = parseTypeDefinition(\n replacePathTokens(context, entry)\n )!;\n } else {\n typeDefinition = entry;\n typeDefinition.file = replacePathTokens(context, typeDefinition.file);\n }\n\n const filePath = isAbsolutePath(typeDefinition.file)\n ? typeDefinition.file\n : appendPath(typeDefinition.file, context.config.root);\n if (context.fs.isFileSync(filePath)) {\n return resolveInput(context, {\n file: appendPath(filePath, context.workspaceConfig.workspaceRoot),\n name: typeDefinition.name\n });\n }\n\n return context.fs\n .globSync(appendPath(filePath, context.workspaceConfig.workspaceRoot))\n .map(file =>\n resolveInput(context, {\n file,\n name: typeDefinition.name\n })\n );\n })\n .flat()\n .filter(Boolean);\n}\n\n/**\n * Checks if the provided entry is a type definition.\n *\n * @param entry - The entry to check.\n * @returns True if the entry is a type definition, false otherwise.\n */\nexport function isTypeDefinition(entry: any): entry is TypeDefinition {\n return !isString(entry) && entry.file !== undefined;\n}\n\n/**\n * Checks if the provided entry is a resolved entry type definition.\n *\n * @param entry - The entry to check.\n * @returns True if the entry is a resolved entry type definition, false otherwise.\n */\nexport function isResolvedEntryTypeDefinition(\n entry: TypeDefinitionParameter | ResolvedEntryTypeDefinition\n): entry is ResolvedEntryTypeDefinition {\n return (\n isTypeDefinition(entry) &&\n (entry as ResolvedEntryTypeDefinition).output !== undefined\n );\n}\n\n/**\n * Get unique inputs from the provided list.\n *\n * @param inputs - The entry points to process.\n * @returns An array of unique inputs (by file path or content hash).\n */\nexport function getUniqueInputs(\n inputs: BaseConfig[\"input\"] = []\n): BaseConfig[\"input\"] {\n return isObject(inputs)\n ? inputs\n : getUniqueBy(toArray(inputs), (item: TypeDefinitionParameter) =>\n isSetString(item) ? item : murmurhash(item ?? {}, { maxLength: 24 })\n );\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { getLogFn, getLogLevel } from \"@storm-software/config-tools/logger\";\nimport { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport { getColor } from \"@storm-software/config-tools/utilities/colors\";\nimport { noop } from \"@stryke/helpers/noop\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport chalk from \"chalk\";\nimport type { LogFn, WorkspaceConfig } from \"../types\";\n\nexport interface CreateLogOptions {\n name?: string;\n logLevel?: LogLevelLabel | null;\n customLogger?: LogFn;\n colors?: WorkspaceConfig[\"colors\"];\n}\n\n/**\n * Create a logging function with a specific name and options.\n *\n * @param name - The name of the logging function.\n * @param options - The options to configure the logging function.\n * @returns A logging function.\n */\nexport const createLog = (\n name: string | null,\n options: CreateLogOptions = {}\n): LogFn => {\n const logLevel =\n options.logLevel === null\n ? LogLevelLabel.SILENT\n : options.logLevel || LogLevelLabel.INFO;\n if (logLevel === LogLevelLabel.SILENT) {\n return noop;\n }\n\n if (options.customLogger) {\n return options.customLogger;\n }\n\n return (type: LogLevelLabel, ...args: string[]) =>\n getLogFn(getLogLevel(type), {\n ...options,\n logLevel\n })(\n `${chalk.bold.hex(\n getColor(\"brand\", options as Parameters<typeof getColor>[1])\n )(\n `${name ? kebabCase(name) : \"\"}${options.name ? `${name ? chalk.gray(\" > \") : \"\"}${kebabCase(options.name)}` : \"\"}${chalk.gray(\" > \")}`\n )}${args.join(\" \")} `.trim()\n );\n};\n\nconst BADGE_COLORS = [\n \"#00A0DD\",\n \"#6FCE4E\",\n \"#FBBF24\",\n \"#F43F5E\",\n \"#3B82F6\",\n \"#A855F7\",\n \"#469592\",\n \"#288EDF\",\n \"#D8B4FE\",\n \"#10B981\",\n \"#EF4444\",\n \"#F0EC56\",\n \"#F472B6\",\n \"#22D3EE\",\n \"#EAB308\",\n \"#84CC16\",\n \"#F87171\",\n \"#0EA5E9\",\n \"#D946EF\",\n \"#FACC15\",\n \"#34D399\",\n \"#8B5CF6\"\n] as const;\n\nexport const extendLog = (logFn: LogFn, name: string): LogFn => {\n return (type: LogLevelLabel, ...args: string[]) =>\n logFn(\n type,\n ` ${chalk.inverse.hex(\n BADGE_COLORS[\n name\n .split(\"\")\n .map(char => char.charCodeAt(0))\n .reduce((ret, charCode) => ret + charCode, 0) % BADGE_COLORS.length\n ] || BADGE_COLORS[0]\n )(` ${titleCase(name)} `)} ${args.join(\" \")} `\n );\n};\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { Context } from \"../../types/context\";\n\nexport interface FileHeaderOptions {\n directive?: string | null;\n prettierIgnore?: boolean;\n}\n\n/**\n * Generates a file header comment with a warning about automatic overwriting.\n *\n * @param overwrite - Whether the file will be automatically overwritten. If `false`, the warning will indicate that the file will not be overwritten. If `true` or omitted, the warning will indicate that the file will be overwritten.\n * @param framework - The name of the framework to include in the warning message. Defaults to \"powerlines\".\n * @returns A string containing the file header warning message.\n */\nexport function getFileHeaderWarningText(\n overwrite = true,\n framework = \"powerlines\"\n): string {\n return overwrite !== false\n ? `Do not edit this file manually - it will be overwritten automatically. Automatic overwrites can be disabled by using the \\`output.overwrite\\` option.`\n : `This file was generated on ${new Date().toLocaleString()} - it will not be overwritten by ${titleCase(framework)} while the \\`output.overwrite\\` option is set to \\`true\\`.`;\n}\n\n/**\n * Generates a file header warning message based on the provided context.\n *\n * @param context - The Powerlines context.\n * @returns A string containing the file header warning message.\n */\nexport function getFileHeaderWarning(context: Context): string {\n return getFileHeaderWarningText(\n context.config.output?.overwrite,\n context.config.framework\n );\n}\n\n/**\n * Generates a file header comment for a generated source file, including a warning about automatic overwriting.\n *\n * @param context - The Powerlines context.\n * @param comment - The comment syntax to use for the header (e.g., `//` for JavaScript/TypeScript, `#` for Python). Defaults to `//`.\n * @returns A string containing the file header comment.\n */\nexport function getFileHeader(context: Context, comment = \"//\"): string {\n return `\n${comment} Generated by ${titleCase(context.config.framework) || \"Powerlines\"}\n${comment} ${getFileHeaderWarning(context)}\n`;\n}\n\n/**\n * Generates a file header comment for a generated TypeScript source file, including a warning about automatic overwriting.\n *\n * @param context - The Powerlines context.\n * @param options - Additional options for generating the file header, such as a directive to include and whether to add a Prettier ignore comment.\n * @returns A string containing the file header comment for a TypeScript file.\n */\nexport function getTypescriptFileHeader(\n context: Context,\n options: FileHeaderOptions = {}\n): string {\n const { directive = null, prettierIgnore = false } = options;\n\n return `/* eslint-disable */\n// biome-ignore lint: disable\n${prettierIgnore ? `// prettier-ignore` : \"\"}${directive ? `\\n\\n${directive}\\n` : \"\\n\"}\n${getFileHeader(context)}\n\n`;\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { readFileIfExistingSync } from \"@stryke/fs/read-file\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport MagicString from \"magic-string\";\nimport { TransformResult } from \"unplugin\";\nimport { SourceFile } from \"../../types/context\";\n\n/**\n * Get the string from the source.\n *\n * @param code - The source string or magic string.\n * @returns The source string.\n */\nexport function getString(\n code: string | MagicString | TransformResult\n): string {\n if (!code) {\n return \"\";\n }\n\n if (isString(code)) {\n return code;\n }\n\n if (isSetObject(code) && \"code\" in code) {\n return code.code;\n }\n\n return code.toString();\n}\n\n/**\n * Get the magic string.\n *\n * @param code - The source string or magic string.\n * @returns The magic string.\n */\nexport function getMagicString(code: string | MagicString): MagicString {\n if (isString(code)) {\n return new MagicString(code);\n }\n\n return code;\n}\n\n/**\n * Get the source file.\n *\n * @param code - The source code.\n * @param id - The name of the file.\n * @returns The source file.\n */\nexport function getSourceFile(\n code: string | MagicString,\n id: string\n): SourceFile {\n const content = code ?? readFileIfExistingSync(id);\n\n return {\n id,\n code: getMagicString(content),\n env: []\n };\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport Diff from \"diff-match-patch\";\nimport type MagicString from \"magic-string\";\nimport type { TransformResult } from \"../../types/context\";\n\nconst dmp = new Diff();\n\n/**\n * Generate code with source map.\n *\n * @param code - The source code.\n * @param id - The file name.\n * @param transpiled - The transpiled code.\n * @returns The compiler result.\n */\nexport function generateSourceMap(\n code: MagicString,\n id: string,\n transpiled?: string\n): TransformResult | undefined {\n if (!transpiled) {\n return;\n }\n\n const diff = dmp.diff_main(code.toString(), transpiled);\n dmp.diff_cleanupSemantic(diff);\n\n let offset = 0;\n\n for (let index = 0; index < diff.length; index++) {\n if (diff[index]) {\n const [type, text] = diff[index]!;\n const textLength = text.length;\n\n switch (type) {\n case 0: {\n offset += textLength;\n break;\n }\n case 1: {\n code.prependLeft(offset, text);\n break;\n }\n case -1: {\n const next = diff.at(index + 1);\n\n if (next && next[0] === 1) {\n const replaceText = next[1];\n\n const firstNonWhitespaceIndexOfText = text.search(/\\S/);\n const offsetStart =\n offset + Math.max(firstNonWhitespaceIndexOfText, 0);\n\n code.update(offsetStart, offset + textLength, replaceText);\n index += 1;\n } else {\n code.remove(offset, offset + textLength);\n }\n\n offset += textLength;\n\n break;\n }\n }\n }\n }\n\n if (!code.hasChanged()) {\n return;\n }\n\n return {\n code: code.toString(),\n map: code.generateMap({\n source: id,\n file: `${id}.map`,\n includeContent: true\n })\n };\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport { writeFile as writeFileBase } from \"@stryke/fs/write-file\";\nimport { format, resolveConfig } from \"prettier\";\nimport type { LogFn } from \"../../types/config\";\n\n/**\n * Writes and formats a file to the file system\n *\n * @param log - The logging function to use for logging errors\n * @param filepath - The file path to write the file\n * @param content - The content to write to the file\n * @param skipFormat - Should the plugin skip formatting the `content` string with Prettier\n */\nexport async function writeFile(\n log: LogFn,\n filepath: string,\n content: string,\n skipFormat = false\n) {\n try {\n if (skipFormat) {\n await writeFileBase(filepath, content);\n } else {\n const config = await resolveConfig(filepath);\n const formatted = await format(content, {\n ...(config ?? {}),\n filepath\n });\n\n await writeFileBase(filepath, formatted || \"\");\n }\n } catch (error) {\n log(\n LogLevelLabel.ERROR,\n `Failed to write file ${filepath} to disk \\n${(error as Error)?.message ? (error as Error).message : \"\"}`\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,SAAgB,mBACd,SACA,gBACQ;AACR,QAAO,iBACL,YACE,YACE,YACE,YACE,YACE,eAAe,MACf,UACE,QAAQ,gBAAgB,eACxB,QAAQ,OAAO,MACf,MACD,CACF,EACD,UACE,QAAQ,gBAAgB,eACxB,QAAQ,OAAO,KAChB,CACF,EACD,UAAU,QAAQ,OAAO,MAAM,MAAM,CACtC,EACD,QAAQ,OAAO,KAChB,EACD,MACD,CACF;;AAGH,SAAgB,aACd,SACA,gBACA,OACA,QAC6B;AAC7B,QAAO;EACL,GAAG;EACH,OAAO,YAAY,MAAM,GAAG,EAAE,MAAM,OAAO,MAAM,EAAE,GAAG;EACtD,QAAQ,UAAU,mBAAmB,SAAS,eAAe;EAC9D;;;;;;;;;AAUH,eAAsB,cACpB,SACA,iBAIwC;AACxC,SACE,MAAM,QAAQ,KACX,SAAS,gBAAgB,IAAI,CAAC,iBAAiB,gBAAgB,GAC5D,OAAO,OAAO,gBAAgB,CAAC,MAAM,GACrC,QAAQ,gBAAgB,EAEzB,IAAI,OAAM,UAAS;AAClB,MAAI,8BAA8B,MAAM,CACtC,QAAO;GACL,GAAG;GACH,QAAQ,MAAM,SACV,kBAAkB,SAAS,MAAM,OAAO,GACxC;GACJ,MAAM,kBAAkB,SAAS,MAAM,KAAK;GAC7C;EAGH,IAAIA;AACJ,MAAI,SAAS,MAAM,CACjB,kBAAiB,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AM,OAAO,SAAS;GACtC,GAFa,MAAM,cAAc,SAAS,IAE5B,EAAE;GAChB;GACD,CAAC,IAEyC,GAAG;UAEzC,OAAO;AACd,MACE,cAAc,OACd,wBAAwB,SAAS,aAAc,OAAiB,UAAW,MAAgB,UAAU,KACtG"}
package/dist/utils.cjs CHANGED
@@ -1,16 +1,18 @@
1
1
  const require_paths = require('./paths-YmyIGEVo.cjs');
2
- const require_utils = require('./utils-CxKWmhs2.cjs');
2
+ const require_utils = require('./utils-BbDma_5Y.cjs');
3
3
 
4
4
  exports.createLog = require_utils.createLog;
5
5
  exports.extendLog = require_utils.extendLog;
6
6
  exports.format = require_paths.format;
7
7
  exports.formatFolder = require_paths.formatFolder;
8
8
  exports.generateSourceMap = require_utils.generateSourceMap;
9
- exports.getBaseFileHeader = require_utils.getBaseFileHeader;
10
9
  exports.getFileHeader = require_utils.getFileHeader;
10
+ exports.getFileHeaderWarning = require_utils.getFileHeaderWarning;
11
+ exports.getFileHeaderWarningText = require_utils.getFileHeaderWarningText;
11
12
  exports.getMagicString = require_utils.getMagicString;
12
13
  exports.getSourceFile = require_utils.getSourceFile;
13
14
  exports.getString = require_utils.getString;
15
+ exports.getTypescriptFileHeader = require_utils.getTypescriptFileHeader;
14
16
  exports.getUniqueInputs = require_utils.getUniqueInputs;
15
17
  exports.isResolvedEntryTypeDefinition = require_utils.isResolvedEntryTypeDefinition;
16
18
  exports.isTypeDefinition = require_utils.isTypeDefinition;
package/dist/utils.d.cts CHANGED
@@ -1,2 +1,2 @@
1
- import { S as resolveInputsSync, _ as isResolvedEntryTypeDefinition, a as getString, b as resolveInput, c as FileHeaderOptions, d as getFileHeader, f as CreateLogOptions, g as getUniqueInputs, h as extendLog, i as getSourceFile, l as __ΩFileHeaderOptions, m as createLog, n as generateSourceMap, o as format, p as __ΩCreateLogOptions, r as getMagicString, s as formatFolder, t as writeFile, u as getBaseFileHeader, v as isTypeDefinition, x as resolveInputs, y as resolveEntryOutput } from "./write-file-gkuvUoFn.cjs";
2
- export { CreateLogOptions, FileHeaderOptions, __ΩCreateLogOptions, __ΩFileHeaderOptions, createLog, extendLog, format, formatFolder, generateSourceMap, getBaseFileHeader, getFileHeader, getMagicString, getSourceFile, getString, getUniqueInputs, isResolvedEntryTypeDefinition, isTypeDefinition, resolveEntryOutput, resolveInput, resolveInputs, resolveInputsSync, writeFile };
1
+ import { C as resolveInputs, S as resolveInput, _ as extendLog, a as getString, b as isTypeDefinition, c as FileHeaderOptions, d as getFileHeaderWarning, f as getFileHeaderWarningText, g as createLog, h as __ΩCreateLogOptions, i as getSourceFile, l as __ΩFileHeaderOptions, m as CreateLogOptions, n as generateSourceMap, o as format, p as getTypescriptFileHeader, r as getMagicString, s as formatFolder, t as writeFile, u as getFileHeader, v as getUniqueInputs, w as resolveInputsSync, x as resolveEntryOutput, y as isResolvedEntryTypeDefinition } from "./write-file-DKA8GehT.cjs";
2
+ export { CreateLogOptions, FileHeaderOptions, __ΩCreateLogOptions, __ΩFileHeaderOptions, createLog, extendLog, format, formatFolder, generateSourceMap, getFileHeader, getFileHeaderWarning, getFileHeaderWarningText, getMagicString, getSourceFile, getString, getTypescriptFileHeader, getUniqueInputs, isResolvedEntryTypeDefinition, isTypeDefinition, resolveEntryOutput, resolveInput, resolveInputs, resolveInputsSync, writeFile };
package/dist/utils.d.mts CHANGED
@@ -1,3 +1,3 @@
1
- import "./config-B76VxuFj.mjs";
2
- import { S as resolveInputsSync, _ as isResolvedEntryTypeDefinition, a as getString, b as resolveInput, c as FileHeaderOptions, d as getFileHeader, f as CreateLogOptions, g as getUniqueInputs, h as extendLog, i as getSourceFile, l as __ΩFileHeaderOptions, m as createLog, n as generateSourceMap, o as format, p as __ΩCreateLogOptions, r as getMagicString, s as formatFolder, t as writeFile, u as getBaseFileHeader, v as isTypeDefinition, x as resolveInputs, y as resolveEntryOutput } from "./index-TMfRNrCg.mjs";
3
- export { CreateLogOptions, FileHeaderOptions, __ΩCreateLogOptions, __ΩFileHeaderOptions, createLog, extendLog, format, formatFolder, generateSourceMap, getBaseFileHeader, getFileHeader, getMagicString, getSourceFile, getString, getUniqueInputs, isResolvedEntryTypeDefinition, isTypeDefinition, resolveEntryOutput, resolveInput, resolveInputs, resolveInputsSync, writeFile };
1
+ import "./config-jcYnkMvq.mjs";
2
+ import { C as resolveInputs, S as resolveInput, _ as extendLog, a as getString, b as isTypeDefinition, c as FileHeaderOptions, d as getFileHeaderWarning, f as getFileHeaderWarningText, g as createLog, h as __ΩCreateLogOptions, i as getSourceFile, l as __ΩFileHeaderOptions, m as CreateLogOptions, n as generateSourceMap, o as format, p as getTypescriptFileHeader, r as getMagicString, s as formatFolder, t as writeFile, u as getFileHeader, v as getUniqueInputs, w as resolveInputsSync, x as resolveEntryOutput, y as isResolvedEntryTypeDefinition } from "./index-DP6juTGE.mjs";
3
+ export { CreateLogOptions, FileHeaderOptions, __ΩCreateLogOptions, __ΩFileHeaderOptions, createLog, extendLog, format, formatFolder, generateSourceMap, getFileHeader, getFileHeaderWarning, getFileHeaderWarningText, getMagicString, getSourceFile, getString, getTypescriptFileHeader, getUniqueInputs, isResolvedEntryTypeDefinition, isTypeDefinition, resolveEntryOutput, resolveInput, resolveInputs, resolveInputsSync, writeFile };
package/dist/utils.mjs CHANGED
@@ -1,4 +1,4 @@
1
1
  import { n as format, r as formatFolder } from "./paths-CS8ecCnW.mjs";
2
- import { a as getString, c as createLog, d as isResolvedEntryTypeDefinition, f as isTypeDefinition, g as resolveInputsSync, h as resolveInputs, i as getSourceFile, l as extendLog, m as resolveInput, n as generateSourceMap, o as getBaseFileHeader, p as resolveEntryOutput, r as getMagicString, s as getFileHeader, t as writeFile, u as getUniqueInputs } from "./utils-RU0EjpzP.mjs";
2
+ import { _ as resolveInputs, a as getString, c as getFileHeaderWarningText, d as extendLog, f as getUniqueInputs, g as resolveInput, h as resolveEntryOutput, i as getSourceFile, l as getTypescriptFileHeader, m as isTypeDefinition, n as generateSourceMap, o as getFileHeader, p as isResolvedEntryTypeDefinition, r as getMagicString, s as getFileHeaderWarning, t as writeFile, u as createLog, v as resolveInputsSync } from "./utils-DoQcX7Sk.mjs";
3
3
 
4
- export { createLog, extendLog, format, formatFolder, generateSourceMap, getBaseFileHeader, getFileHeader, getMagicString, getSourceFile, getString, getUniqueInputs, isResolvedEntryTypeDefinition, isTypeDefinition, resolveEntryOutput, resolveInput, resolveInputs, resolveInputsSync, writeFile };
4
+ export { createLog, extendLog, format, formatFolder, generateSourceMap, getFileHeader, getFileHeaderWarning, getFileHeaderWarningText, getMagicString, getSourceFile, getString, getTypescriptFileHeader, getUniqueInputs, isResolvedEntryTypeDefinition, isTypeDefinition, resolveEntryOutput, resolveInput, resolveInputs, resolveInputsSync, writeFile };
@@ -1,8 +1,10 @@
1
1
  const require_chunk = require('./chunk-CbDLau6x.cjs');
2
+ const require_utils = require('./utils-BbDma_5Y.cjs');
2
3
  let __stryke_fs_helpers = require("@stryke/fs/helpers");
3
4
  let __stryke_fs_list_files = require("@stryke/fs/list-files");
4
5
  let __stryke_path_append = require("@stryke/path/append");
5
6
  let __stryke_type_checks_is_error = require("@stryke/type-checks/is-error");
7
+ let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
6
8
  let __stryke_path_is_parent_path = require("@stryke/path/is-parent-path");
7
9
  let __stryke_path_join = require("@stryke/path/join");
8
10
  let node_fs = require("node:fs");
@@ -320,7 +322,10 @@ var FileSystemStorageAdapter = class extends BaseStorageAdapter {
320
322
  * @param value - The value to set.
321
323
  */
322
324
  setSync(key, value) {
323
- if (!this.isReadOnly && (!this.existsSync(key) || this.overwrite)) return (0, __stryke_fs_write_file.writeFileSync)(this.resolve(key), value);
325
+ if (!this.isReadOnly) if (this.existsSync(this.resolve(key)) && !this.overwrite) {
326
+ const existingValue = this.getSync(this.resolve(key));
327
+ if ((0, __stryke_type_checks_is_set_string.isSetString)(existingValue) && existingValue.includes(require_utils.getFileHeaderWarningText(true, this.context.config.framework))) return (0, __stryke_fs_write_file.writeFileSync)(this.resolve(key), existingValue.replace(require_utils.getFileHeaderWarningText(true, this.context.config.framework), require_utils.getFileHeaderWarningText(false, this.context.config.framework)));
328
+ } else return (0, __stryke_fs_write_file.writeFileSync)(this.resolve(key), value);
324
329
  }
325
330
  /**
326
331
  * Asynchronously sets the value for a given key.
@@ -329,7 +334,10 @@ var FileSystemStorageAdapter = class extends BaseStorageAdapter {
329
334
  * @param value - The value to set.
330
335
  */
331
336
  async set(key, value) {
332
- if (!this.isReadOnly && this.overwrite) return (0, __stryke_fs_write_file.writeFile)(this.resolve(key), value);
337
+ if (!this.isReadOnly) if (this.existsSync(this.resolve(key)) && !this.overwrite) {
338
+ const existingValue = await this.get(this.resolve(key));
339
+ if ((0, __stryke_type_checks_is_set_string.isSetString)(existingValue) && existingValue.includes(require_utils.getFileHeaderWarningText(true, this.context.config.framework))) return (0, __stryke_fs_write_file.writeFile)(this.resolve(key), existingValue.replace(require_utils.getFileHeaderWarningText(true, this.context.config.framework), require_utils.getFileHeaderWarningText(false, this.context.config.framework)));
340
+ } else return (0, __stryke_fs_write_file.writeFile)(this.resolve(key), value);
333
341
  }
334
342
  /**
335
343
  * Synchronously removes a key from the storage.
@@ -1,7 +1,9 @@
1
+ import { c as getFileHeaderWarningText } from "./utils-DoQcX7Sk.mjs";
1
2
  import { createDirectory, createDirectorySync } from "@stryke/fs/helpers";
2
3
  import { listFiles, listFilesSync } from "@stryke/fs/list-files";
3
4
  import { appendPath } from "@stryke/path/append";
4
5
  import { isError } from "@stryke/type-checks/is-error";
6
+ import { isSetString } from "@stryke/type-checks/is-set-string";
5
7
  import { isParentPath } from "@stryke/path/is-parent-path";
6
8
  import { joinPaths } from "@stryke/path/join";
7
9
  import { unlinkSync } from "node:fs";
@@ -319,7 +321,10 @@ var FileSystemStorageAdapter = class extends BaseStorageAdapter {
319
321
  * @param value - The value to set.
320
322
  */
321
323
  setSync(key, value) {
322
- if (!this.isReadOnly && (!this.existsSync(key) || this.overwrite)) return writeFileSync(this.resolve(key), value);
324
+ if (!this.isReadOnly) if (this.existsSync(this.resolve(key)) && !this.overwrite) {
325
+ const existingValue = this.getSync(this.resolve(key));
326
+ if (isSetString(existingValue) && existingValue.includes(getFileHeaderWarningText(true, this.context.config.framework))) return writeFileSync(this.resolve(key), existingValue.replace(getFileHeaderWarningText(true, this.context.config.framework), getFileHeaderWarningText(false, this.context.config.framework)));
327
+ } else return writeFileSync(this.resolve(key), value);
323
328
  }
324
329
  /**
325
330
  * Asynchronously sets the value for a given key.
@@ -328,7 +333,10 @@ var FileSystemStorageAdapter = class extends BaseStorageAdapter {
328
333
  * @param value - The value to set.
329
334
  */
330
335
  async set(key, value) {
331
- if (!this.isReadOnly && this.overwrite) return writeFile(this.resolve(key), value);
336
+ if (!this.isReadOnly) if (this.existsSync(this.resolve(key)) && !this.overwrite) {
337
+ const existingValue = await this.get(this.resolve(key));
338
+ if (isSetString(existingValue) && existingValue.includes(getFileHeaderWarningText(true, this.context.config.framework))) return writeFile(this.resolve(key), existingValue.replace(getFileHeaderWarningText(true, this.context.config.framework), getFileHeaderWarningText(false, this.context.config.framework)));
339
+ } else return writeFile(this.resolve(key), value);
332
340
  }
333
341
  /**
334
342
  * Synchronously removes a key from the storage.
@@ -502,4 +510,4 @@ var VirtualStorageAdapter = class extends BaseStorageAdapter {
502
510
 
503
511
  //#endregion
504
512
  export { isFileError as a, ignoreNotfound as i, FileSystemStorageAdapter as n, BaseStorageAdapter as o, ignoreExists as r, VirtualStorageAdapter as t };
505
- //# sourceMappingURL=virtual-D-9vfvVY.mjs.map
513
+ //# sourceMappingURL=virtual-B9imjOqe.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"virtual-B9imjOqe.mjs","names":["context: Context","#isDisposed","existsSync"],"sources":["../src/storage/base.ts","../src/storage/helpers.ts","../src/storage/file-system.ts","../src/storage/virtual.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { appendPath } from \"@stryke/path/append\";\nimport { correctPath } from \"@stryke/path/correct-path\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { MaybePromise } from \"@stryke/types/base\";\nimport { resolve } from \"node:path\";\nimport type { Context, StorageAdapter, StoragePreset } from \"../types\";\n\nexport interface StorageAdapterOptions {\n base: string;\n isReadOnly?: boolean;\n ignore?: string | string[];\n}\n\n/**\n * Abstract base class for storage adapters, providing a template for storage operations.\n */\nexport abstract class BaseStorageAdapter<\n TOptions extends StorageAdapterOptions = StorageAdapterOptions\n> implements StorageAdapter {\n /**\n * Indicates whether the storage adapter has been disposed.\n */\n #isDisposed = false;\n\n /**\n * A name identifying the storage adapter type.\n */\n public abstract name: string;\n\n /**\n * Configuration options for the storage adapter.\n */\n public options: TOptions;\n\n /**\n * The storage preset for the adapter.\n *\n * @remarks\n * This can be used as an alternate way to identify the type of storage being used.\n */\n public readonly preset?: StoragePreset | null = null;\n\n /**\n * Constructor for the BaseStorageAdapter.\n *\n * @param context - The Powerlines context.\n * @param options - Configuration options for the storage adapter.\n */\n public constructor(\n protected context: Context,\n options: TOptions = { base: \"/\" } as TOptions\n ) {\n this.options = options;\n this.options.base = resolve(options.base);\n this.options.isReadOnly = !!options.isReadOnly;\n }\n\n /**\n * Synchronously checks if a key exists in the storage.\n *\n * @param key - The key to check for existence.\n * @returns Returns `true` if the key exists, otherwise `false`.\n */\n public abstract existsSync(key: string): boolean;\n\n /**\n * Asynchronously checks if a key exists in the storage.\n *\n * @param key - The key to check for existence.\n * @returns A promise that resolves to `true` if the key exists, otherwise `false`.\n */\n public async exists(key: string): Promise<boolean> {\n return this.existsSync(key);\n }\n\n /**\n * Synchronously retrieves the value associated with a given key.\n *\n * @param key - The key whose value is to be retrieved.\n * @returns The value associated with the key, or `null` if the key does not exist.\n */\n public abstract getSync(key: string): string | null;\n\n /**\n * Asynchronously retrieves the value associated with a given key.\n *\n * @param key - The key whose value is to be retrieved.\n * @returns A promise that resolves to the value associated with the key, or `null` if the key does not exist.\n */\n public async get(key: string): Promise<string | null> {\n return this.getSync(key);\n }\n\n /**\n * Synchronously sets the value for a given key.\n *\n * @param key - The key to set the value for.\n * @param value - The value to set.\n */\n public abstract setSync(key: string, value: string): void;\n\n /**\n * Asynchronously sets the value for a given key.\n *\n * @param key - The key to set the value for.\n * @param value - The value to set.\n */\n public async set(key: string, value: string): Promise<void> {\n if (!this.isReadOnly && (!this.existsSync(key) || this.overwrite)) {\n this.setSync(key, value);\n }\n }\n\n /**\n * Synchronously creates a directory at the specified path.\n *\n * @param _ - The path of the directory to create.\n */\n public mkdirSync(_: string) {}\n\n /**\n * Creates a directory at the specified path.\n *\n * @param dirPath - The path of the directory to create.\n */\n public async mkdir(dirPath: string): Promise<void> {\n return Promise.resolve(this.mkdirSync(dirPath));\n }\n\n /**\n * Synchronously removes a key from the storage.\n *\n * @param key - The key to remove.\n */\n public abstract removeSync(key: string): void;\n\n /**\n * Asynchronously removes a key from the storage.\n *\n * @param key - The key to remove.\n */\n public async remove(key: string): Promise<void> {\n if (!this.isReadOnly && this.overwrite) {\n this.removeSync(key);\n }\n }\n\n /**\n * Synchronously removes all entries from the storage that match the provided base path.\n *\n * @param base - The base path to clear keys from.\n */\n public clearSync(base?: string) {\n if (!this.isReadOnly && this.overwrite) {\n const keys = this.listSync(base || this.options.base);\n if (!keys.length) {\n return;\n }\n\n keys.map(key =>\n this.removeSync(\n base && !key.startsWith(base) ? joinPaths(base, key) : key\n )\n );\n }\n }\n\n /**\n * Asynchronously removes all entries from the storage that match the provided base path.\n *\n * @param base - The base path to clear keys from.\n * @returns A promise that resolves when the operation is complete.\n */\n public async clear(base?: string): Promise<void> {\n if (!this.isReadOnly && this.overwrite) {\n const keys = await this.list(base || this.options.base);\n if (!keys.length) {\n return;\n }\n\n await Promise.all(\n keys.map(async key =>\n this.remove(\n base && !key.startsWith(base) ? joinPaths(base, key) : key\n )\n )\n );\n }\n }\n\n /**\n * Lists all keys under a given base path synchronously.\n *\n * @param base - The base path to list keys from.\n * @returns An array of keys under the specified base path.\n */\n public abstract listSync(base?: string): string[];\n\n /**\n * Asynchronously lists all keys under a given base path.\n *\n * @param base - The base path to list keys from.\n * @returns A promise that resolves to an array of keys under the specified base path.\n */\n public async list(base?: string): Promise<string[]> {\n return this.listSync(base);\n }\n\n /**\n * Synchronously checks if the given key is a directory.\n *\n * @param _ - The key to check.\n * @returns `true` if the key is a directory, otherwise `false`.\n */\n public isDirectorySync(_: string): boolean {\n return false;\n }\n\n /**\n * Checks if the given key is a directory.\n *\n * @param key - The key to check.\n * @returns A promise that resolves to `true` if the key is a directory, otherwise `false`.\n */\n public async isDirectory(key: string) {\n return Promise.resolve(this.isDirectorySync(key));\n }\n\n /**\n * Synchronously checks if the given key is a file.\n *\n * @param key - The key to check.\n * @returns `true` if the key is a file, otherwise `false`.\n */\n public isFileSync(key: string): boolean {\n return this.existsSync(key) && !this.isDirectorySync(key);\n }\n\n /**\n * Checks if the given key is a file.\n *\n * @param key - The key to check.\n * @returns A promise that resolves to `true` if the key is a file, otherwise `false`.\n */\n public async isFile(key: string) {\n return Promise.resolve(this.isFileSync(key));\n }\n\n /**\n * Disposes of the storage adapter, releasing any held resources.\n *\n * @returns A promise that resolves when the disposal is complete.\n */\n public dispose(): MaybePromise<void> {\n return Promise.resolve();\n }\n\n /**\n * Async dispose method to clean up resources.\n *\n * @returns A promise that resolves when disposal is complete.\n */\n public async [Symbol.asyncDispose]() {\n return this._dispose();\n }\n\n /**\n * Determines if the storage adapter is read-only based on the provided options.\n *\n * @returns `true` if the storage adapter is read-only, otherwise `false`.\n */\n protected get isReadOnly() {\n return !!this.options.isReadOnly;\n }\n\n /**\n * Determines if the storage adapter should overwrite existing keys based on the provided options and context configuration.\n *\n * @returns `true` if the storage adapter should overwrite existing keys, otherwise `false`.\n */\n protected get overwrite() {\n return !this.isReadOnly && this.context.config.output.overwrite !== false;\n }\n\n /**\n * Resolves a given key to its full path within the storage adapter.\n *\n * @param key - The key to resolve.\n * @returns The resolved full path for the key.\n */\n protected resolve(key?: string) {\n if (!key) {\n return this.options.base;\n }\n\n if (/\\.\\.:|\\.\\.$/.test(key)) {\n throw new Error(\n `[${this.name}]: Invalid key: ${JSON.stringify(key)} provided to storage adapter.`\n );\n }\n\n return appendPath(correctPath(key).replace(/:/g, \"/\"), this.options.base);\n }\n\n /**\n * Disposes of the storage adapter, releasing any held resources.\n *\n * @returns A promise that resolves when the disposal is complete.\n */\n protected async _dispose(): Promise<void> {\n if (!this.#isDisposed) {\n await Promise.resolve(this.dispose());\n this.#isDisposed = true;\n }\n }\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isError } from \"@stryke/type-checks/is-error\";\n\n/**\n * Checks if an error is a file system error.\n *\n * @param err - The error to check.\n * @returns `true` if the error is a file system error, otherwise `false`.\n */\nexport function isFileError(err: any) {\n return isError(err) && \"code\" in err && err.code;\n}\n\n/**\n * Ignores file not found errors.\n *\n * @param err - The error to check.\n * @returns `null` if the error is a file not found error, otherwise returns the error.\n */\nexport function ignoreNotfound(err: any) {\n return (\n isFileError(err) &&\n (err.code === \"ENOENT\" || err.code === \"EISDIR\" ? null : err)\n );\n}\n\n/**\n * Ignores file exists errors.\n *\n * @param err - The error to check.\n * @returns `null` if the error is a file exists error, otherwise returns the error.\n */\nexport function ignoreExists(err: any) {\n return isFileError(err) && err.code === \"EEXIST\" ? null : err;\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { exists, existsSync } from \"@stryke/fs/exists\";\nimport { createDirectory, createDirectorySync } from \"@stryke/fs/helpers\";\nimport { isDirectory, isFile } from \"@stryke/fs/is-file\";\nimport { listFiles, listFilesSync } from \"@stryke/fs/list-files\";\nimport { readFile, readFileSync } from \"@stryke/fs/read-file\";\nimport { writeFile, writeFileSync } from \"@stryke/fs/write-file\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { unlinkSync } from \"node:fs\";\nimport { unlink } from \"node:fs/promises\";\nimport type { Context } from \"../types\";\nimport { getFileHeaderWarningText } from \"../utils\";\nimport { BaseStorageAdapter, StorageAdapterOptions } from \"./base\";\nimport { ignoreNotfound } from \"./helpers\";\n\nexport type SetSyncOptions = Parameters<typeof writeFileSync>[2];\nexport type SetOptions = Parameters<typeof writeFile>[2];\n\n/**\n * File system storage adapter implementation.\n */\nexport class FileSystemStorageAdapter extends BaseStorageAdapter {\n /**\n * A name identifying the storage adapter type.\n */\n public name = \"file-system\";\n\n /**\n * The storage preset for the adapter.\n *\n * @remarks\n * This can be used as an alternate way to identify the type of storage being used.\n */\n public override readonly preset = \"fs\";\n\n /**\n * Constructor for the FileSystemStorageAdapter.\n *\n * @param context - The Powerlines context.\n * @param options - Configuration options for the storage adapter.\n */\n public constructor(context: Context, options?: StorageAdapterOptions) {\n super(context, options);\n }\n\n /**\n * Synchronously checks if a key exists in the storage.\n *\n * @param key - The key to check for existence.\n * @returns Returns `true` if the key exists, otherwise `false`.\n */\n public existsSync(key: string): boolean {\n return existsSync(this.resolve(key));\n }\n\n /**\n * Asynchronously checks if a key exists in the storage.\n *\n * @param key - The key to check for existence.\n * @returns A promise that resolves to `true` if the key exists, otherwise `false`.\n */\n public override async exists(key: string): Promise<boolean> {\n return exists(this.resolve(key));\n }\n\n /**\n * Synchronously retrieves the value associated with a given key.\n *\n * @param key - The key whose value is to be retrieved.\n * @returns The value associated with the key, or `null` if the key does not exist.\n */\n public getSync(key: string): string | null {\n return readFileSync(this.resolve(key));\n }\n\n /**\n * Asynchronously retrieves the value associated with a given key.\n *\n * @param key - The key whose value is to be retrieved.\n * @returns A promise that resolves to the value associated with the key, or `null` if the key does not exist.\n */\n public override async get(key: string): Promise<string | null> {\n return readFile(this.resolve(key));\n }\n\n /**\n * Synchronously sets the value for a given key.\n *\n * @param key - The key to set the value for.\n * @param value - The value to set.\n */\n public setSync(key: string, value: string) {\n if (!this.isReadOnly) {\n if (this.existsSync(this.resolve(key)) && !this.overwrite) {\n const existingValue = this.getSync(this.resolve(key));\n if (\n isSetString(existingValue) &&\n existingValue.includes(\n getFileHeaderWarningText(true, this.context.config.framework)\n )\n ) {\n return writeFileSync(\n this.resolve(key),\n existingValue.replace(\n getFileHeaderWarningText(true, this.context.config.framework),\n getFileHeaderWarningText(false, this.context.config.framework)\n )\n );\n }\n } else {\n return writeFileSync(this.resolve(key), value);\n }\n }\n }\n\n /**\n * Asynchronously sets the value for a given key.\n *\n * @param key - The key to set the value for.\n * @param value - The value to set.\n */\n public override async set(key: string, value: string): Promise<void> {\n if (!this.isReadOnly) {\n if (this.existsSync(this.resolve(key)) && !this.overwrite) {\n const existingValue = await this.get(this.resolve(key));\n if (\n isSetString(existingValue) &&\n existingValue.includes(\n getFileHeaderWarningText(true, this.context.config.framework)\n )\n ) {\n return writeFile(\n this.resolve(key),\n existingValue.replace(\n getFileHeaderWarningText(true, this.context.config.framework),\n getFileHeaderWarningText(false, this.context.config.framework)\n )\n );\n }\n } else {\n return writeFile(this.resolve(key), value);\n }\n }\n }\n\n /**\n * Synchronously removes a key from the storage.\n *\n * @param key - The key to remove.\n */\n public removeSync(key: string) {\n if (!this.isReadOnly && this.overwrite) {\n try {\n return unlinkSync(this.resolve(key));\n } catch (err) {\n return ignoreNotfound(err);\n }\n }\n }\n\n /**\n * Asynchronously removes a key from the storage.\n *\n * @param key - The key to remove.\n */\n public override async remove(key: string): Promise<void> {\n if (!this.isReadOnly && this.overwrite) {\n return unlink(this.resolve(key)).catch(ignoreNotfound);\n }\n }\n\n /**\n * Synchronously creates a directory at the specified path.\n *\n * @param dirPath - The path of the directory to create.\n */\n public override mkdirSync(dirPath: string) {\n createDirectorySync(this.resolve(dirPath));\n }\n\n /**\n * Creates a directory at the specified path.\n *\n * @param dirPath - The path of the directory to create.\n */\n public override async mkdir(dirPath: string): Promise<void> {\n await createDirectory(this.resolve(dirPath));\n }\n\n /**\n * Lists all keys under a given base path synchronously.\n *\n * @param base - The base path to list keys from.\n * @returns An array of keys under the specified base path.\n */\n public listSync(base?: string): string[] {\n try {\n return listFilesSync(this.resolve(base), {\n ignore: this.options.ignore\n });\n } catch (err) {\n return ignoreNotfound(err) ?? [];\n }\n }\n\n /**\n * Asynchronously lists all keys under a given base path.\n *\n * @param base - The base path to list keys from.\n * @returns A promise that resolves to an array of keys under the specified base path.\n */\n public override async list(base?: string): Promise<string[]> {\n return listFiles(this.resolve(base), {\n ignore: this.options.ignore\n })\n .catch(ignoreNotfound)\n .then(r => r || []);\n }\n\n /**\n * Synchronously checks if the given key is a directory.\n *\n * @param key - The key to check.\n * @returns `true` if the key is a directory, otherwise `false`.\n */\n public override isDirectorySync(key: string): boolean {\n return isDirectory(this.resolve(key));\n }\n\n /**\n * Synchronously checks if the given key is a file.\n *\n * @param key - The key to check.\n * @returns `true` if the key is a file, otherwise `false`.\n */\n public override isFileSync(key: string): boolean {\n return isFile(this.resolve(key));\n }\n}\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isParentPath } from \"@stryke/path/is-parent-path\";\nimport type { Context } from \"../types\";\nimport { BaseStorageAdapter, StorageAdapterOptions } from \"./base\";\n\n/**\n * Virtual/in-memory storage adapter implementation.\n */\nexport class VirtualStorageAdapter extends BaseStorageAdapter {\n /**\n * A name identifying the storage adapter type.\n */\n public name = \"virtual\";\n\n /**\n * The storage preset for the adapter.\n *\n * @remarks\n * This can be used as an alternate way to identify the type of storage being used.\n */\n public override readonly preset = \"virtual\";\n\n /**\n * In-memory data storage.\n */\n protected data = new Map<string, any>();\n\n /**\n * Constructor for the VirtualStorageAdapter.\n *\n * @param context - The Powerlines context.\n * @param options - Configuration options for the storage adapter.\n */\n public constructor(context: Context, options?: StorageAdapterOptions) {\n super(context, options);\n }\n\n /**\n * Synchronously checks if a key exists in the storage.\n *\n * @param key - The key to check for existence.\n * @returns Returns `true` if the key exists, otherwise `false`.\n */\n public existsSync(key: string): boolean {\n return this.data.has(this.resolve(key));\n }\n\n /**\n * Synchronously retrieves the value associated with a given key.\n *\n * @param key - The key whose value is to be retrieved.\n * @returns The value associated with the key, or `null` if the key does not exist.\n */\n public getSync(key: string): string | null {\n return this.data.get(this.resolve(key)) ?? null;\n }\n\n /**\n * Synchronously sets the value for a given key.\n *\n * @param key - The key to set the value for.\n * @param value - The value to set.\n */\n public setSync(key: string, value: string) {\n if (!this.isReadOnly && (!this.existsSync(key) || this.overwrite)) {\n this.data.set(this.resolve(key), value);\n }\n }\n\n /**\n * Synchronously removes a key from the storage.\n *\n * @param key - The key to remove.\n */\n public removeSync(key: string) {\n if (!this.isReadOnly && this.overwrite) {\n this.data.delete(this.resolve(key));\n }\n }\n\n /**\n * Lists all keys under a given base path synchronously.\n *\n * @param base - The base path to list keys from.\n * @returns An array of keys under the specified base path.\n */\n public listSync(base?: string): string[] {\n return [\n ...this.data\n .keys()\n .filter(key => (!base ? true : isParentPath(key, this.resolve(base))))\n ];\n }\n\n /**\n * Disposes of the storage adapter, releasing any held resources.\n *\n * @returns A promise that resolves when the disposal is complete.\n */\n public override async dispose(): Promise<void> {\n return this.clear();\n }\n\n /**\n * Determines if the storage adapter should overwrite existing keys based on the provided options and context configuration.\n *\n * @returns `true` if the storage adapter should overwrite existing keys, otherwise `false`.\n */\n protected override get overwrite() {\n return !this.isReadOnly;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAkCA,IAAsB,qBAAtB,MAE4B;;;;CAI1B,cAAc;;;;CAUd,AAAO;;;;;;;CAQP,AAAgB,SAAgC;;;;;;;CAQhD,AAAO,YACL,AAAUA,SACV,UAAoB,EAAE,MAAM,KAAK,EACjC;EAFU;AAGV,OAAK,UAAU;AACf,OAAK,QAAQ,OAAO,QAAQ,QAAQ,KAAK;AACzC,OAAK,QAAQ,aAAa,CAAC,CAAC,QAAQ;;;;;;;;CAiBtC,MAAa,OAAO,KAA+B;AACjD,SAAO,KAAK,WAAW,IAAI;;;;;;;;CAiB7B,MAAa,IAAI,KAAqC;AACpD,SAAO,KAAK,QAAQ,IAAI;;;;;;;;CAiB1B,MAAa,IAAI,KAAa,OAA8B;AAC1D,MAAI,CAAC,KAAK,eAAe,CAAC,KAAK,WAAW,IAAI,IAAI,KAAK,WACrD,MAAK,QAAQ,KAAK,MAAM;;;;;;;CAS5B,AAAO,UAAU,GAAW;;;;;;CAO5B,MAAa,MAAM,SAAgC;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K,WAAW,IAAI,IAAI,KAAK,WACrD,MAAK,KAAK,IAAI,KAAK,QAAQ,IAAI,EAAE,MAAM;;;;;;;CAS3C,AAAO,WAAW,KAAa;AAC7B,MAAI,CAAC,KAAK,cAAc,KAAK,UAC3B,MAAK,KAAK,OAAO,KAAK,QAAQ,IAAI,CAAC;;;;;;;;CAUvC,AAAO,SAAS,MAAyB;AACvC,SAAO,CACL,GAAG,KAAK,KACL,MAAM,CACN,QAAO,QAAQ,CAAC,OAAO,OAAO,aAAa,KAAK,KAAK,QAAQ,KAAK,CAAC,CAAE,CACzE;;;;;;;CAQH,MAAsB,UAAyB;AAC7C,SAAO,KAAK,OAAO;;;;;;;CAQrB,IAAuB,YAAY;AACjC,SAAO,CAAC,KAAK"}
@@ -1,6 +1,6 @@
1
1
  const require_chunk = require('./chunk-CbDLau6x.cjs');
2
- const require_api = require('./api-DtumO6qc.cjs');
3
- const require_resolve_options = require('./resolve-options-B1gzDFxb.cjs');
2
+ const require_api = require('./api-XX-usBTN.cjs');
3
+ const require_resolve_options = require('./resolve-options-BQnTgg3V.cjs');
4
4
  const require_resolve_options$1 = require('./resolve-options-vyFhhkLp.cjs');
5
5
  const require_resolve_options$2 = require('./resolve-options-lxQ2pm0W.cjs');
6
6
  let __stryke_path_join_paths = require("@stryke/path/join-paths");
@@ -1,5 +1,5 @@
1
- import { a as createUnpluginFactory, o as createUnplugin } from "./api-CHXfSSj6.mjs";
2
- import { r as resolveOptions$1 } from "./resolve-options-Ym_q-Hb7.mjs";
1
+ import { a as createUnpluginFactory, o as createUnplugin } from "./api-BaHkkIMl.mjs";
2
+ import { r as resolveOptions$1 } from "./resolve-options-DHL3RM8F.mjs";
3
3
  import { n as resolveOptions$3 } from "./resolve-options-6sXFqzEA.mjs";
4
4
  import { t as resolveOptions$2 } from "./resolve-options-D-RGs8j8.mjs";
5
5
  import { joinPaths } from "@stryke/path/join-paths";
@@ -168,4 +168,4 @@ var vite_default = unplugin;
168
168
 
169
169
  //#endregion
170
170
  export { vite_default as n, src_default as r, unplugin as t };
171
- //# sourceMappingURL=vite-DOMQMT51.mjs.map
171
+ //# sourceMappingURL=vite-D-iV7jRu.mjs.map