@powerlines/plugin-webpack 0.5.126 → 0.5.128

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 (87) hide show
  1. package/dist/_virtual/rolldown_runtime.cjs +29 -1
  2. package/dist/helpers/index.cjs +3 -1
  3. package/dist/helpers/index.mjs +3 -1
  4. package/dist/helpers/unplugin.cjs +12 -1
  5. package/dist/helpers/unplugin.mjs +11 -1
  6. package/dist/index.cjs +39 -1
  7. package/dist/index.mjs +33 -1
  8. package/dist/powerlines/schemas/fs.cjs +226 -1
  9. package/dist/powerlines/schemas/fs.mjs +224 -1
  10. package/dist/powerlines/src/api.cjs +576 -9
  11. package/dist/powerlines/src/api.mjs +578 -1
  12. package/dist/powerlines/src/internal/babel/module-resolver-plugin.cjs +86 -1
  13. package/dist/powerlines/src/internal/babel/module-resolver-plugin.mjs +84 -1
  14. package/dist/powerlines/src/internal/helpers/environment.cjs +52 -1
  15. package/dist/powerlines/src/internal/helpers/environment.mjs +48 -1
  16. package/dist/powerlines/src/internal/helpers/generate-types.cjs +50 -7
  17. package/dist/powerlines/src/internal/helpers/generate-types.mjs +48 -7
  18. package/dist/powerlines/src/internal/helpers/hooks.cjs +63 -1
  19. package/dist/powerlines/src/internal/helpers/hooks.mjs +61 -1
  20. package/dist/powerlines/src/internal/helpers/install-dependencies.cjs +25 -3
  21. package/dist/powerlines/src/internal/helpers/install-dependencies.mjs +24 -3
  22. package/dist/powerlines/src/internal/helpers/install.cjs +37 -1
  23. package/dist/powerlines/src/internal/helpers/install.mjs +36 -1
  24. package/dist/powerlines/src/internal/helpers/resolve-tsconfig.cjs +97 -7
  25. package/dist/powerlines/src/internal/helpers/resolve-tsconfig.mjs +93 -7
  26. package/dist/powerlines/src/internal/helpers/resolver.cjs +43 -1
  27. package/dist/powerlines/src/internal/helpers/resolver.mjs +41 -1
  28. package/dist/powerlines/src/lib/build/webpack.cjs +47 -1
  29. package/dist/powerlines/src/lib/build/webpack.mjs +45 -1
  30. package/dist/powerlines/src/lib/config-file.cjs +79 -1
  31. package/dist/powerlines/src/lib/config-file.mjs +76 -1
  32. package/dist/powerlines/src/lib/contexts/api-context.cjs +184 -1
  33. package/dist/powerlines/src/lib/contexts/api-context.mjs +182 -1
  34. package/dist/powerlines/src/lib/contexts/context.cjs +931 -1
  35. package/dist/powerlines/src/lib/contexts/context.mjs +929 -1
  36. package/dist/powerlines/src/lib/contexts/environment-context.cjs +160 -1
  37. package/dist/powerlines/src/lib/contexts/environment-context.mjs +159 -1
  38. package/dist/powerlines/src/lib/contexts/plugin-context.cjs +75 -1
  39. package/dist/powerlines/src/lib/contexts/plugin-context.mjs +74 -1
  40. package/dist/powerlines/src/lib/entry.cjs +69 -1
  41. package/dist/powerlines/src/lib/entry.mjs +67 -1
  42. package/dist/powerlines/src/lib/fs/helpers.cjs +85 -1
  43. package/dist/powerlines/src/lib/fs/helpers.mjs +81 -1
  44. package/dist/powerlines/src/lib/fs/storage/base.cjs +196 -1
  45. package/dist/powerlines/src/lib/fs/storage/base.mjs +195 -1
  46. package/dist/powerlines/src/lib/fs/storage/file-system.cjs +170 -1
  47. package/dist/powerlines/src/lib/fs/storage/file-system.mjs +169 -1
  48. package/dist/powerlines/src/lib/fs/storage/virtual.cjs +88 -1
  49. package/dist/powerlines/src/lib/fs/storage/virtual.mjs +87 -1
  50. package/dist/powerlines/src/lib/fs/vfs.cjs +830 -1
  51. package/dist/powerlines/src/lib/fs/vfs.mjs +828 -1
  52. package/dist/powerlines/src/lib/logger.cjs +58 -1
  53. package/dist/powerlines/src/lib/logger.mjs +55 -1
  54. package/dist/powerlines/src/lib/typescript/ts-morph.cjs +104 -1
  55. package/dist/powerlines/src/lib/typescript/ts-morph.mjs +102 -1
  56. package/dist/powerlines/src/lib/typescript/tsconfig.cjs +149 -4
  57. package/dist/powerlines/src/lib/typescript/tsconfig.mjs +144 -4
  58. package/dist/powerlines/src/lib/unplugin/factory.cjs +6 -1
  59. package/dist/powerlines/src/lib/unplugin/factory.mjs +8 -1
  60. package/dist/powerlines/src/lib/unplugin/helpers.cjs +17 -1
  61. package/dist/powerlines/src/lib/unplugin/helpers.mjs +16 -1
  62. package/dist/powerlines/src/lib/unplugin/index.cjs +3 -1
  63. package/dist/powerlines/src/lib/unplugin/index.mjs +5 -1
  64. package/dist/powerlines/src/lib/unplugin/plugin.cjs +127 -5
  65. package/dist/powerlines/src/lib/unplugin/plugin.mjs +126 -5
  66. package/dist/powerlines/src/lib/utilities/file-header.cjs +19 -7
  67. package/dist/powerlines/src/lib/utilities/file-header.mjs +18 -7
  68. package/dist/powerlines/src/lib/utilities/meta.cjs +45 -1
  69. package/dist/powerlines/src/lib/utilities/meta.mjs +41 -1
  70. package/dist/powerlines/src/lib/utilities/source-file.cjs +22 -1
  71. package/dist/powerlines/src/lib/utilities/source-file.mjs +21 -1
  72. package/dist/powerlines/src/plugin-utils/helpers.cjs +148 -1
  73. package/dist/powerlines/src/plugin-utils/helpers.mjs +138 -1
  74. package/dist/powerlines/src/plugin-utils/paths.cjs +36 -1
  75. package/dist/powerlines/src/plugin-utils/paths.mjs +35 -1
  76. package/dist/powerlines/src/types/build.cjs +15 -1
  77. package/dist/powerlines/src/types/build.mjs +14 -1
  78. package/dist/powerlines/src/types/commands.cjs +16 -1
  79. package/dist/powerlines/src/types/commands.mjs +15 -1
  80. package/dist/powerlines/src/types/config.d.mts +1 -0
  81. package/dist/powerlines/src/types/context.d.cts +27 -3
  82. package/dist/powerlines/src/types/context.d.mts +27 -3
  83. package/dist/powerlines/src/types/plugin.cjs +32 -1
  84. package/dist/powerlines/src/types/plugin.mjs +31 -1
  85. package/dist/types/index.mjs +1 -1
  86. package/dist/types/plugin.mjs +1 -1
  87. package/package.json +9 -9
@@ -1 +1,17 @@
1
- const e=require(`../../../../_virtual/rolldown_runtime.cjs`);let t=require(`defu`);function n(e,n){return(0,t.defu)(e,n)}exports.combineContexts=n;
1
+ const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
2
+ let defu = require("defu");
3
+
4
+ //#region ../powerlines/src/lib/unplugin/helpers.ts
5
+ /**
6
+ * Merges a base plugin context with an unplugin context, combining their properties.
7
+ *
8
+ * @param context - The base plugin context to merge into.
9
+ * @param unplugin - The unplugin context to merge from.
10
+ * @returns The merged context.
11
+ */
12
+ function combineContexts(context, unplugin) {
13
+ return (0, defu.defu)(context, unplugin);
14
+ }
15
+
16
+ //#endregion
17
+ exports.combineContexts = combineContexts;
@@ -1 +1,16 @@
1
- import{defu as e}from"defu";function t(t,n){return e(t,n)}export{t as combineContexts};
1
+ import { defu } from "defu";
2
+
3
+ //#region ../powerlines/src/lib/unplugin/helpers.ts
4
+ /**
5
+ * Merges a base plugin context with an unplugin context, combining their properties.
6
+ *
7
+ * @param context - The base plugin context to merge into.
8
+ * @param unplugin - The unplugin context to merge from.
9
+ * @returns The merged context.
10
+ */
11
+ function combineContexts(context, unplugin) {
12
+ return defu(context, unplugin);
13
+ }
14
+
15
+ //#endregion
16
+ export { combineContexts };
@@ -1 +1,3 @@
1
- require(`./factory.cjs`);const e=require(`./helpers.cjs`),t=require(`./plugin.cjs`);
1
+ require('./factory.cjs');
2
+ const require_helpers = require('./helpers.cjs');
3
+ const require_plugin = require('./plugin.cjs');
@@ -1 +1,5 @@
1
- import"./factory.mjs";import{combineContexts as e}from"./helpers.mjs";import{createUnplugin as t}from"./plugin.mjs";export{};
1
+ import "./factory.mjs";
2
+ import { combineContexts } from "./helpers.mjs";
3
+ import { createUnplugin } from "./plugin.mjs";
4
+
5
+ export { };
@@ -1,6 +1,128 @@
1
- const e=require(`../../../../_virtual/rolldown_runtime.cjs`),t=require(`../logger.cjs`),n=require(`../utilities/source-file.cjs`),r=require(`./helpers.cjs`);let i=require(`@storm-software/config-tools/types`),a=require(`unplugin`),o=require(`@stryke/path/replace`),s=require(`@stryke/type-checks/is-string`),c=require(`@stryke/path/file-path-fns`);function l(e){let l=e;return(0,a.setParseImpl)(l.parse),()=>{let e=t.extendLog(l.log,`unplugin`);e(i.LogLevelLabel.DEBUG,`Initializing Unplugin`);try{async function t(){e(i.LogLevelLabel.DEBUG,`Powerlines build plugin starting...`),await l.$$internal.callHook(`buildStart`,{sequential:!0})}async function a(e,t,n={isEntry:!1}){let r=await(async()=>{let r=await l.$$internal.callHook(`resolveId`,{sequential:!0,result:`first`,order:`pre`},e,t,n);return r||(r=await l.$$internal.callHook(`resolveId`,{sequential:!0,result:`first`,order:`normal`},e,t,n),r)||(r=await l.resolve(e,t,n),r)?r:l.$$internal.callHook(`resolveId`,{sequential:!0,result:`first`,order:`post`},e,t,n)})();if(r&&n.isEntry&&l.config.build.polyfill&&l.config.build.polyfill.length>0){let e=l.entry.find(e=>e.file===((0,s.isString)(r)?r:r.id));if(e)return e.file=`${(0,o.replaceExtension)((0,s.isString)(r)?r:r.id)}-polyfill.ts`,e.output||=e.output?.replace((0,c.findFileName)(e.output,{withExtension:!0}),e.file),await l.emitEntry(`
2
- ${l.config.build.polyfill.map(e=>`import "${e}";`).join(`
3
- `)}
1
+ const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
2
+ const require_logger = require('../logger.cjs');
3
+ const require_source_file = require('../utilities/source-file.cjs');
4
+ const require_helpers = require('./helpers.cjs');
5
+ let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
6
+ let unplugin = require("unplugin");
7
+ let __stryke_path_replace = require("@stryke/path/replace");
8
+ let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
9
+ let __stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
4
10
 
5
- export * from "${(0,s.isString)(r)?r:r.id}";
6
- `,e.file),e.file}return r}async function u(e){let t=await l.$$internal.callHook(`load`,{sequential:!0,result:`first`,order:`pre`},e);return t||(t=await l.$$internal.callHook(`load`,{sequential:!0,result:`first`,order:`normal`},e),t)||(t=await l.load(e),t)?t:l.$$internal.callHook(`load`,{sequential:!0,result:`first`,order:`post`},e)}async function d(e,t){let i=e;for(let e of l.$$internal.environment.selectHooks(`transform`)){let a=await e.handle.apply(r.combineContexts(l,this),[n.getString(i),t]);a&&(i=a)}return i}async function f(){return e(i.LogLevelLabel.DEBUG,`Powerlines build plugin finishing...`),l.$$internal.callHook(`buildEnd`,{sequential:!0})}async function p(){return e(i.LogLevelLabel.DEBUG,`Finalizing Powerlines project output...`),l.$$internal.callHook(`writeBundle`,{sequential:!0})}return{name:`powerlines`,api:l.$$internal.api,resolveId:{filter:{id:{include:[/.*/]}},handler:a},load:{filter:{id:{include:[/.*/]}},handler:u},transform:d,buildStart:t,buildEnd:f,writeBundle:p,vite:{sharedDuringBuild:!0}}}catch(t){throw e(i.LogLevelLabel.FATAL,t?.message),t}}}exports.createUnplugin=l;
11
+ //#region ../powerlines/src/lib/unplugin/plugin.ts
12
+ /**
13
+ * Creates a Powerlines unplugin instance.
14
+ *
15
+ * @param context - The plugin context.
16
+ * @returns The unplugin instance.
17
+ */
18
+ function createUnplugin(context) {
19
+ const ctx = context;
20
+ (0, unplugin.setParseImpl)(ctx.parse);
21
+ return () => {
22
+ const log = require_logger.extendLog(ctx.log, "unplugin");
23
+ log(__storm_software_config_tools_types.LogLevelLabel.DEBUG, "Initializing Unplugin");
24
+ try {
25
+ async function buildStart() {
26
+ log(__storm_software_config_tools_types.LogLevelLabel.DEBUG, "Powerlines build plugin starting...");
27
+ await ctx.$$internal.callHook("buildStart", { sequential: true });
28
+ }
29
+ async function resolveId(id, importer, opts = { isEntry: false }) {
30
+ const resolved = await (async () => {
31
+ let result = await ctx.$$internal.callHook("resolveId", {
32
+ sequential: true,
33
+ result: "first",
34
+ order: "pre"
35
+ }, id, importer, opts);
36
+ if (result) return result;
37
+ result = await ctx.$$internal.callHook("resolveId", {
38
+ sequential: true,
39
+ result: "first",
40
+ order: "normal"
41
+ }, id, importer, opts);
42
+ if (result) return result;
43
+ result = await ctx.resolve(id, importer, opts);
44
+ if (result) return result;
45
+ return ctx.$$internal.callHook("resolveId", {
46
+ sequential: true,
47
+ result: "first",
48
+ order: "post"
49
+ }, id, importer, opts);
50
+ })();
51
+ if (resolved && opts.isEntry && ctx.config.build.polyfill && ctx.config.build.polyfill.length > 0) {
52
+ const entry = ctx.entry.find((entry$1) => entry$1.file === ((0, __stryke_type_checks_is_string.isString)(resolved) ? resolved : resolved.id));
53
+ if (entry) {
54
+ entry.file = `${(0, __stryke_path_replace.replaceExtension)((0, __stryke_type_checks_is_string.isString)(resolved) ? resolved : resolved.id)}-polyfill.ts`;
55
+ entry.output ||= entry.output?.replace((0, __stryke_path_file_path_fns.findFileName)(entry.output, { withExtension: true }), entry.file);
56
+ await ctx.emitEntry(`
57
+ ${ctx.config.build.polyfill.map((p) => `import "${p}";`).join("\n")}
58
+
59
+ export * from "${(0, __stryke_type_checks_is_string.isString)(resolved) ? resolved : resolved.id}";
60
+ `, entry.file);
61
+ return entry.file;
62
+ }
63
+ }
64
+ return resolved;
65
+ }
66
+ async function load(id) {
67
+ let result = await ctx.$$internal.callHook("load", {
68
+ sequential: true,
69
+ result: "first",
70
+ order: "pre"
71
+ }, id);
72
+ if (result) return result;
73
+ result = await ctx.$$internal.callHook("load", {
74
+ sequential: true,
75
+ result: "first",
76
+ order: "normal"
77
+ }, id);
78
+ if (result) return result;
79
+ result = await ctx.load(id);
80
+ if (result) return result;
81
+ return ctx.$$internal.callHook("load", {
82
+ sequential: true,
83
+ result: "first",
84
+ order: "post"
85
+ }, id);
86
+ }
87
+ async function transform(code, id) {
88
+ let transformed = code;
89
+ for (const handler of ctx.$$internal.environment.selectHooks("transform")) {
90
+ const result = await handler.handle.apply(require_helpers.combineContexts(ctx, this), [require_source_file.getString(transformed), id]);
91
+ if (result) transformed = result;
92
+ }
93
+ return transformed;
94
+ }
95
+ async function buildEnd() {
96
+ log(__storm_software_config_tools_types.LogLevelLabel.DEBUG, "Powerlines build plugin finishing...");
97
+ return ctx.$$internal.callHook("buildEnd", { sequential: true });
98
+ }
99
+ async function writeBundle() {
100
+ log(__storm_software_config_tools_types.LogLevelLabel.DEBUG, "Finalizing Powerlines project output...");
101
+ return ctx.$$internal.callHook("writeBundle", { sequential: true });
102
+ }
103
+ return {
104
+ name: "powerlines",
105
+ api: ctx.$$internal.api,
106
+ resolveId: {
107
+ filter: { id: { include: [/.*/] } },
108
+ handler: resolveId
109
+ },
110
+ load: {
111
+ filter: { id: { include: [/.*/] } },
112
+ handler: load
113
+ },
114
+ transform,
115
+ buildStart,
116
+ buildEnd,
117
+ writeBundle,
118
+ vite: { sharedDuringBuild: true }
119
+ };
120
+ } catch (error) {
121
+ log(__storm_software_config_tools_types.LogLevelLabel.FATAL, error?.message);
122
+ throw error;
123
+ }
124
+ };
125
+ }
126
+
127
+ //#endregion
128
+ exports.createUnplugin = createUnplugin;
@@ -1,6 +1,127 @@
1
- import{extendLog as e}from"../logger.mjs";import{getString as t}from"../utilities/source-file.mjs";import{combineContexts as n}from"./helpers.mjs";import{LogLevelLabel as r}from"@storm-software/config-tools/types";import{setParseImpl as i}from"unplugin";import{replaceExtension as a}from"@stryke/path/replace";import{isString as o}from"@stryke/type-checks/is-string";import{findFileName as s}from"@stryke/path/file-path-fns";function c(c){let l=c;return i(l.parse),()=>{let i=e(l.log,`unplugin`);i(r.DEBUG,`Initializing Unplugin`);try{async function e(){i(r.DEBUG,`Powerlines build plugin starting...`),await l.$$internal.callHook(`buildStart`,{sequential:!0})}async function c(e,t,n={isEntry:!1}){let r=await(async()=>{let r=await l.$$internal.callHook(`resolveId`,{sequential:!0,result:`first`,order:`pre`},e,t,n);return r||(r=await l.$$internal.callHook(`resolveId`,{sequential:!0,result:`first`,order:`normal`},e,t,n),r)||(r=await l.resolve(e,t,n),r)?r:l.$$internal.callHook(`resolveId`,{sequential:!0,result:`first`,order:`post`},e,t,n)})();if(r&&n.isEntry&&l.config.build.polyfill&&l.config.build.polyfill.length>0){let e=l.entry.find(e=>e.file===(o(r)?r:r.id));if(e)return e.file=`${a(o(r)?r:r.id)}-polyfill.ts`,e.output||=e.output?.replace(s(e.output,{withExtension:!0}),e.file),await l.emitEntry(`
2
- ${l.config.build.polyfill.map(e=>`import "${e}";`).join(`
3
- `)}
1
+ import { extendLog } from "../logger.mjs";
2
+ import { getString } from "../utilities/source-file.mjs";
3
+ import { combineContexts } from "./helpers.mjs";
4
+ import { LogLevelLabel } from "@storm-software/config-tools/types";
5
+ import { setParseImpl } from "unplugin";
6
+ import { replaceExtension } from "@stryke/path/replace";
7
+ import { isString } from "@stryke/type-checks/is-string";
8
+ import { findFileName } from "@stryke/path/file-path-fns";
4
9
 
5
- export * from "${o(r)?r:r.id}";
6
- `,e.file),e.file}return r}async function u(e){let t=await l.$$internal.callHook(`load`,{sequential:!0,result:`first`,order:`pre`},e);return t||(t=await l.$$internal.callHook(`load`,{sequential:!0,result:`first`,order:`normal`},e),t)||(t=await l.load(e),t)?t:l.$$internal.callHook(`load`,{sequential:!0,result:`first`,order:`post`},e)}async function d(e,r){let i=e;for(let e of l.$$internal.environment.selectHooks(`transform`)){let a=await e.handle.apply(n(l,this),[t(i),r]);a&&(i=a)}return i}async function f(){return i(r.DEBUG,`Powerlines build plugin finishing...`),l.$$internal.callHook(`buildEnd`,{sequential:!0})}async function p(){return i(r.DEBUG,`Finalizing Powerlines project output...`),l.$$internal.callHook(`writeBundle`,{sequential:!0})}return{name:`powerlines`,api:l.$$internal.api,resolveId:{filter:{id:{include:[/.*/]}},handler:c},load:{filter:{id:{include:[/.*/]}},handler:u},transform:d,buildStart:e,buildEnd:f,writeBundle:p,vite:{sharedDuringBuild:!0}}}catch(e){throw i(r.FATAL,e?.message),e}}}export{c as createUnplugin};
10
+ //#region ../powerlines/src/lib/unplugin/plugin.ts
11
+ /**
12
+ * Creates a Powerlines unplugin instance.
13
+ *
14
+ * @param context - The plugin context.
15
+ * @returns The unplugin instance.
16
+ */
17
+ function createUnplugin(context) {
18
+ const ctx = context;
19
+ setParseImpl(ctx.parse);
20
+ return () => {
21
+ const log = extendLog(ctx.log, "unplugin");
22
+ log(LogLevelLabel.DEBUG, "Initializing Unplugin");
23
+ try {
24
+ async function buildStart() {
25
+ log(LogLevelLabel.DEBUG, "Powerlines build plugin starting...");
26
+ await ctx.$$internal.callHook("buildStart", { sequential: true });
27
+ }
28
+ async function resolveId(id, importer, opts = { isEntry: false }) {
29
+ const resolved = await (async () => {
30
+ let result = await ctx.$$internal.callHook("resolveId", {
31
+ sequential: true,
32
+ result: "first",
33
+ order: "pre"
34
+ }, id, importer, opts);
35
+ if (result) return result;
36
+ result = await ctx.$$internal.callHook("resolveId", {
37
+ sequential: true,
38
+ result: "first",
39
+ order: "normal"
40
+ }, id, importer, opts);
41
+ if (result) return result;
42
+ result = await ctx.resolve(id, importer, opts);
43
+ if (result) return result;
44
+ return ctx.$$internal.callHook("resolveId", {
45
+ sequential: true,
46
+ result: "first",
47
+ order: "post"
48
+ }, id, importer, opts);
49
+ })();
50
+ if (resolved && opts.isEntry && ctx.config.build.polyfill && ctx.config.build.polyfill.length > 0) {
51
+ const entry = ctx.entry.find((entry$1) => entry$1.file === (isString(resolved) ? resolved : resolved.id));
52
+ if (entry) {
53
+ entry.file = `${replaceExtension(isString(resolved) ? resolved : resolved.id)}-polyfill.ts`;
54
+ entry.output ||= entry.output?.replace(findFileName(entry.output, { withExtension: true }), entry.file);
55
+ await ctx.emitEntry(`
56
+ ${ctx.config.build.polyfill.map((p) => `import "${p}";`).join("\n")}
57
+
58
+ export * from "${isString(resolved) ? resolved : resolved.id}";
59
+ `, entry.file);
60
+ return entry.file;
61
+ }
62
+ }
63
+ return resolved;
64
+ }
65
+ async function load(id) {
66
+ let result = await ctx.$$internal.callHook("load", {
67
+ sequential: true,
68
+ result: "first",
69
+ order: "pre"
70
+ }, id);
71
+ if (result) return result;
72
+ result = await ctx.$$internal.callHook("load", {
73
+ sequential: true,
74
+ result: "first",
75
+ order: "normal"
76
+ }, id);
77
+ if (result) return result;
78
+ result = await ctx.load(id);
79
+ if (result) return result;
80
+ return ctx.$$internal.callHook("load", {
81
+ sequential: true,
82
+ result: "first",
83
+ order: "post"
84
+ }, id);
85
+ }
86
+ async function transform(code, id) {
87
+ let transformed = code;
88
+ for (const handler of ctx.$$internal.environment.selectHooks("transform")) {
89
+ const result = await handler.handle.apply(combineContexts(ctx, this), [getString(transformed), id]);
90
+ if (result) transformed = result;
91
+ }
92
+ return transformed;
93
+ }
94
+ async function buildEnd() {
95
+ log(LogLevelLabel.DEBUG, "Powerlines build plugin finishing...");
96
+ return ctx.$$internal.callHook("buildEnd", { sequential: true });
97
+ }
98
+ async function writeBundle() {
99
+ log(LogLevelLabel.DEBUG, "Finalizing Powerlines project output...");
100
+ return ctx.$$internal.callHook("writeBundle", { sequential: true });
101
+ }
102
+ return {
103
+ name: "powerlines",
104
+ api: ctx.$$internal.api,
105
+ resolveId: {
106
+ filter: { id: { include: [/.*/] } },
107
+ handler: resolveId
108
+ },
109
+ load: {
110
+ filter: { id: { include: [/.*/] } },
111
+ handler: load
112
+ },
113
+ transform,
114
+ buildStart,
115
+ buildEnd,
116
+ writeBundle,
117
+ vite: { sharedDuringBuild: true }
118
+ };
119
+ } catch (error) {
120
+ log(LogLevelLabel.FATAL, error?.message);
121
+ throw error;
122
+ }
123
+ };
124
+ }
125
+
126
+ //#endregion
127
+ export { createUnplugin };
@@ -1,10 +1,22 @@
1
- const e=require(`../../../../_virtual/rolldown_runtime.cjs`);let t=require(`@stryke/string-format/title-case`);function n(e){return`
2
- // Generated with ${(0,t.titleCase)(e.config.framework)}
1
+ const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
2
+ let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
3
+
4
+ //#region ../powerlines/src/lib/utilities/file-header.ts
5
+ function getBaseFileHeader(context) {
6
+ return `
7
+ // Generated with ${(0, __stryke_string_format_title_case.titleCase)(context.config.framework)}
3
8
  // Note: Do not edit this file manually - it will be overwritten automatically
4
- `}function r(e,t={}){let{directive:r=null,prettierIgnore:i=!1}=t;return`/* eslint-disable */
9
+ `;
10
+ }
11
+ function getFileHeader(context, options = {}) {
12
+ const { directive = null, prettierIgnore = false } = options;
13
+ return `/* eslint-disable */
5
14
  // biome-ignore lint: disable
6
- ${i?`// prettier-ignore`:``}${r?`\n\n${r}\n`:`
7
- `}
8
- ${n(e)}
15
+ ${prettierIgnore ? `// prettier-ignore` : ""}${directive ? `\n\n${directive}\n` : "\n"}
16
+ ${getBaseFileHeader(context)}
17
+
18
+ `;
19
+ }
9
20
 
10
- `}exports.getFileHeader=r;
21
+ //#endregion
22
+ exports.getFileHeader = getFileHeader;
@@ -1,10 +1,21 @@
1
- import{titleCase as e}from"@stryke/string-format/title-case";function t(t){return`
2
- // Generated with ${e(t.config.framework)}
1
+ import { titleCase } from "@stryke/string-format/title-case";
2
+
3
+ //#region ../powerlines/src/lib/utilities/file-header.ts
4
+ function getBaseFileHeader(context) {
5
+ return `
6
+ // Generated with ${titleCase(context.config.framework)}
3
7
  // Note: Do not edit this file manually - it will be overwritten automatically
4
- `}function n(e,n={}){let{directive:r=null,prettierIgnore:i=!1}=n;return`/* eslint-disable */
8
+ `;
9
+ }
10
+ function getFileHeader(context, options = {}) {
11
+ const { directive = null, prettierIgnore = false } = options;
12
+ return `/* eslint-disable */
5
13
  // biome-ignore lint: disable
6
- ${i?`// prettier-ignore`:``}${r?`\n\n${r}\n`:`
7
- `}
8
- ${t(e)}
14
+ ${prettierIgnore ? `// prettier-ignore` : ""}${directive ? `\n\n${directive}\n` : "\n"}
15
+ ${getBaseFileHeader(context)}
16
+
17
+ `;
18
+ }
9
19
 
10
- `}export{n as getFileHeader};
20
+ //#endregion
21
+ export { getFileHeader };
@@ -1 +1,45 @@
1
- const e=require(`../../../../_virtual/rolldown_runtime.cjs`);let t=require(`@storm-software/config-tools/types`),n=require(`@stryke/path/join-paths`),r=require(`@stryke/fs/list-files`),i=require(`@stryke/fs/json`),a=require(`@stryke/path/file-path-fns`),o=require(`@stryke/fs/exists`),s=require(`@stryke/helpers/get-unique`),c=require(`@stryke/string-format/kebab-case`);require(`@stryke/fs/remove-file`);const l=45,u=62;function d(e,t){let n=`${(0,c.kebabCase)(e)}_${t}`;return n.length>45?n.slice(0,45):n}async function f(e){let r=(0,n.joinPaths)(e.dataPath,`meta.json`);e.log(t.LogLevelLabel.DEBUG,`Writing runtime metadata to ${r}`),await e.fs.write(r,JSON.stringify(e.meta,null,2))}exports.CACHE_HASH_LENGTH=62,exports.PROJECT_ROOT_HASH_LENGTH=45,exports.getPrefixedProjectRootHash=d,exports.writeMetaFile=f;
1
+ const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
2
+ let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
3
+ let __stryke_path_join_paths = require("@stryke/path/join-paths");
4
+ let __stryke_fs_list_files = require("@stryke/fs/list-files");
5
+ let __stryke_fs_json = require("@stryke/fs/json");
6
+ let __stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
7
+ let __stryke_fs_exists = require("@stryke/fs/exists");
8
+ let __stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
9
+ let __stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case");
10
+ require("@stryke/fs/remove-file");
11
+
12
+ //#region ../powerlines/src/lib/utilities/meta.ts
13
+ const PROJECT_ROOT_HASH_LENGTH = 45;
14
+ const CACHE_HASH_LENGTH = 62;
15
+ /**
16
+ * Generates a prefixed project root hash object.
17
+ *
18
+ * @remarks
19
+ * This function returns a string where the project root hash is prefixed with the project name plus a hyphen. If the total length of this string combination exceeds 45 characters, it will truncate the hash.
20
+ *
21
+ * @param name - The name of the project.
22
+ * @param projectRootHash - The hash of the project root.
23
+ * @returns An object containing the name and project root hash.
24
+ */
25
+ function getPrefixedProjectRootHash(name, projectRootHash) {
26
+ const combined = `${(0, __stryke_string_format_kebab_case.kebabCase)(name)}_${projectRootHash}`;
27
+ return combined.length > PROJECT_ROOT_HASH_LENGTH ? combined.slice(0, PROJECT_ROOT_HASH_LENGTH) : combined;
28
+ }
29
+ /**
30
+ * Writes the meta file for the context.
31
+ *
32
+ * @param context - The context to write the meta file for.
33
+ * @returns A promise that resolves when the meta file has been written.
34
+ */
35
+ async function writeMetaFile(context) {
36
+ const metaFilePath = (0, __stryke_path_join_paths.joinPaths)(context.dataPath, "meta.json");
37
+ context.log(__storm_software_config_tools_types.LogLevelLabel.DEBUG, `Writing runtime metadata to ${metaFilePath}`);
38
+ await context.fs.write(metaFilePath, JSON.stringify(context.meta, null, 2));
39
+ }
40
+
41
+ //#endregion
42
+ exports.CACHE_HASH_LENGTH = CACHE_HASH_LENGTH;
43
+ exports.PROJECT_ROOT_HASH_LENGTH = PROJECT_ROOT_HASH_LENGTH;
44
+ exports.getPrefixedProjectRootHash = getPrefixedProjectRootHash;
45
+ exports.writeMetaFile = writeMetaFile;
@@ -1 +1,41 @@
1
- import{LogLevelLabel as e}from"@storm-software/config-tools/types";import{joinPaths as t}from"@stryke/path/join-paths";import{listFiles as n}from"@stryke/fs/list-files";import{readJsonFile as r}from"@stryke/fs/json";import{hasFileExtension as i}from"@stryke/path/file-path-fns";import{existsSync as a}from"@stryke/fs/exists";import{getUnique as o}from"@stryke/helpers/get-unique";import{kebabCase as s}from"@stryke/string-format/kebab-case";import"@stryke/fs/remove-file";const c=45,l=62;function u(e,t){let n=`${s(e)}_${t}`;return n.length>45?n.slice(0,45):n}async function d(n){let r=t(n.dataPath,`meta.json`);n.log(e.DEBUG,`Writing runtime metadata to ${r}`),await n.fs.write(r,JSON.stringify(n.meta,null,2))}export{l as CACHE_HASH_LENGTH,c as PROJECT_ROOT_HASH_LENGTH,u as getPrefixedProjectRootHash,d as writeMetaFile};
1
+ import { LogLevelLabel } from "@storm-software/config-tools/types";
2
+ import { joinPaths } from "@stryke/path/join-paths";
3
+ import { listFiles } from "@stryke/fs/list-files";
4
+ import { readJsonFile } from "@stryke/fs/json";
5
+ import { hasFileExtension } from "@stryke/path/file-path-fns";
6
+ import { existsSync } from "@stryke/fs/exists";
7
+ import { getUnique } from "@stryke/helpers/get-unique";
8
+ import { kebabCase } from "@stryke/string-format/kebab-case";
9
+ import "@stryke/fs/remove-file";
10
+
11
+ //#region ../powerlines/src/lib/utilities/meta.ts
12
+ const PROJECT_ROOT_HASH_LENGTH = 45;
13
+ const CACHE_HASH_LENGTH = 62;
14
+ /**
15
+ * Generates a prefixed project root hash object.
16
+ *
17
+ * @remarks
18
+ * This function returns a string where the project root hash is prefixed with the project name plus a hyphen. If the total length of this string combination exceeds 45 characters, it will truncate the hash.
19
+ *
20
+ * @param name - The name of the project.
21
+ * @param projectRootHash - The hash of the project root.
22
+ * @returns An object containing the name and project root hash.
23
+ */
24
+ function getPrefixedProjectRootHash(name, projectRootHash) {
25
+ const combined = `${kebabCase(name)}_${projectRootHash}`;
26
+ return combined.length > PROJECT_ROOT_HASH_LENGTH ? combined.slice(0, PROJECT_ROOT_HASH_LENGTH) : combined;
27
+ }
28
+ /**
29
+ * Writes the meta file for the context.
30
+ *
31
+ * @param context - The context to write the meta file for.
32
+ * @returns A promise that resolves when the meta file has been written.
33
+ */
34
+ async function writeMetaFile(context) {
35
+ const metaFilePath = joinPaths(context.dataPath, "meta.json");
36
+ context.log(LogLevelLabel.DEBUG, `Writing runtime metadata to ${metaFilePath}`);
37
+ await context.fs.write(metaFilePath, JSON.stringify(context.meta, null, 2));
38
+ }
39
+
40
+ //#endregion
41
+ export { CACHE_HASH_LENGTH, PROJECT_ROOT_HASH_LENGTH, getPrefixedProjectRootHash, writeMetaFile };
@@ -1 +1,22 @@
1
- const e=require(`../../../../_virtual/rolldown_runtime.cjs`);let t=require(`@stryke/type-checks/is-set-object`),n=require(`@stryke/type-checks/is-string`),r=require(`@stryke/fs/read-file`);require(`magic-string`);function i(e){return e?(0,n.isString)(e)?e:(0,t.isSetObject)(e)&&`code`in e?e.code:e.toString():``}exports.getString=i;
1
+ const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
2
+ let __stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
3
+ let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
4
+ let __stryke_fs_read_file = require("@stryke/fs/read-file");
5
+ require("magic-string");
6
+
7
+ //#region ../powerlines/src/lib/utilities/source-file.ts
8
+ /**
9
+ * Get the string from the source.
10
+ *
11
+ * @param code - The source string or magic string.
12
+ * @returns The source string.
13
+ */
14
+ function getString(code) {
15
+ if (!code) return "";
16
+ if ((0, __stryke_type_checks_is_string.isString)(code)) return code;
17
+ if ((0, __stryke_type_checks_is_set_object.isSetObject)(code) && "code" in code) return code.code;
18
+ return code.toString();
19
+ }
20
+
21
+ //#endregion
22
+ exports.getString = getString;
@@ -1 +1,21 @@
1
- import{isSetObject as e}from"@stryke/type-checks/is-set-object";import{isString as t}from"@stryke/type-checks/is-string";import"@stryke/fs/read-file";import"magic-string";function n(n){return n?t(n)?n:e(n)&&`code`in n?n.code:n.toString():``}export{n as getString};
1
+ import { isSetObject } from "@stryke/type-checks/is-set-object";
2
+ import { isString } from "@stryke/type-checks/is-string";
3
+ import "@stryke/fs/read-file";
4
+ import "magic-string";
5
+
6
+ //#region ../powerlines/src/lib/utilities/source-file.ts
7
+ /**
8
+ * Get the string from the source.
9
+ *
10
+ * @param code - The source string or magic string.
11
+ * @returns The source string.
12
+ */
13
+ function getString(code) {
14
+ if (!code) return "";
15
+ if (isString(code)) return code;
16
+ if (isSetObject(code) && "code" in code) return code.code;
17
+ return code.toString();
18
+ }
19
+
20
+ //#endregion
21
+ export { getString };