@powerlines/plugin-webpack 0.5.130 → 0.5.131

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/dist/helpers/index.cjs +3 -2
  2. package/dist/helpers/index.d.cts +3 -1
  3. package/dist/helpers/index.d.mts +3 -1
  4. package/dist/helpers/index.mjs +2 -1
  5. package/dist/helpers/unplugin.cjs +2 -11
  6. package/dist/helpers/unplugin.d.cts +2 -6
  7. package/dist/helpers/unplugin.d.mts +2 -6
  8. package/dist/helpers/unplugin.mjs +1 -9
  9. package/dist/helpers-B15z10jN.mjs +1 -0
  10. package/dist/helpers-LF26RHol.cjs +0 -0
  11. package/dist/index-9iG2qHLe.d.mts +1 -0
  12. package/dist/index-D4ELpJXS.d.cts +1 -0
  13. package/dist/index-D6CnpA_r.d.cts +1 -0
  14. package/dist/index-DL0uimUT.d.mts +1 -0
  15. package/dist/index.cjs +50 -8
  16. package/dist/index.d.cts +4 -3
  17. package/dist/index.d.mts +5 -5
  18. package/dist/index.mjs +46 -3
  19. package/dist/plugin-CsQFPhIt.d.cts +1762 -0
  20. package/dist/plugin-ifZVa20V.mjs +1 -0
  21. package/dist/plugin-pBKbb5K9.cjs +0 -0
  22. package/dist/plugin-wiaZGMv0.d.mts +1764 -0
  23. package/dist/types/index.cjs +2 -0
  24. package/dist/types/index.d.cts +2 -1
  25. package/dist/types/index.d.mts +2 -1
  26. package/dist/types/index.mjs +3 -0
  27. package/dist/types/plugin.cjs +1 -0
  28. package/dist/types/plugin.d.cts +1 -12
  29. package/dist/types/plugin.d.mts +1 -12
  30. package/dist/types/plugin.mjs +2 -0
  31. package/dist/types-U3zd8PTP.mjs +1 -0
  32. package/dist/types-o3zWarRp.cjs +0 -0
  33. package/dist/unplugin-BVSyqmCe.d.cts +7 -0
  34. package/dist/unplugin-CVrlqRhX.mjs +4615 -0
  35. package/dist/unplugin-Cemsz8kP.cjs +4659 -0
  36. package/dist/unplugin-vRGq3odL.d.mts +7 -0
  37. package/package.json +3 -3
  38. package/dist/_virtual/rolldown_runtime.cjs +0 -29
  39. package/dist/powerlines/schemas/fs.cjs +0 -226
  40. package/dist/powerlines/schemas/fs.mjs +0 -224
  41. package/dist/powerlines/src/api.cjs +0 -580
  42. package/dist/powerlines/src/api.mjs +0 -578
  43. package/dist/powerlines/src/internal/babel/module-resolver-plugin.cjs +0 -86
  44. package/dist/powerlines/src/internal/babel/module-resolver-plugin.mjs +0 -84
  45. package/dist/powerlines/src/internal/helpers/environment.cjs +0 -52
  46. package/dist/powerlines/src/internal/helpers/environment.mjs +0 -48
  47. package/dist/powerlines/src/internal/helpers/generate-types.cjs +0 -51
  48. package/dist/powerlines/src/internal/helpers/generate-types.mjs +0 -49
  49. package/dist/powerlines/src/internal/helpers/hooks.cjs +0 -63
  50. package/dist/powerlines/src/internal/helpers/hooks.mjs +0 -61
  51. package/dist/powerlines/src/internal/helpers/install-dependencies.cjs +0 -25
  52. package/dist/powerlines/src/internal/helpers/install-dependencies.mjs +0 -24
  53. package/dist/powerlines/src/internal/helpers/install.cjs +0 -37
  54. package/dist/powerlines/src/internal/helpers/install.mjs +0 -36
  55. package/dist/powerlines/src/internal/helpers/resolve-tsconfig.cjs +0 -98
  56. package/dist/powerlines/src/internal/helpers/resolve-tsconfig.mjs +0 -94
  57. package/dist/powerlines/src/internal/helpers/resolver.cjs +0 -43
  58. package/dist/powerlines/src/internal/helpers/resolver.mjs +0 -41
  59. package/dist/powerlines/src/lib/build/webpack.cjs +0 -47
  60. package/dist/powerlines/src/lib/build/webpack.mjs +0 -45
  61. package/dist/powerlines/src/lib/config-file.cjs +0 -79
  62. package/dist/powerlines/src/lib/config-file.mjs +0 -76
  63. package/dist/powerlines/src/lib/contexts/api-context.cjs +0 -184
  64. package/dist/powerlines/src/lib/contexts/api-context.mjs +0 -182
  65. package/dist/powerlines/src/lib/contexts/context.cjs +0 -931
  66. package/dist/powerlines/src/lib/contexts/context.mjs +0 -929
  67. package/dist/powerlines/src/lib/contexts/environment-context.cjs +0 -160
  68. package/dist/powerlines/src/lib/contexts/environment-context.mjs +0 -159
  69. package/dist/powerlines/src/lib/contexts/plugin-context.cjs +0 -75
  70. package/dist/powerlines/src/lib/contexts/plugin-context.mjs +0 -74
  71. package/dist/powerlines/src/lib/entry.cjs +0 -69
  72. package/dist/powerlines/src/lib/entry.mjs +0 -67
  73. package/dist/powerlines/src/lib/fs/helpers.cjs +0 -85
  74. package/dist/powerlines/src/lib/fs/helpers.mjs +0 -81
  75. package/dist/powerlines/src/lib/fs/storage/base.cjs +0 -196
  76. package/dist/powerlines/src/lib/fs/storage/base.mjs +0 -195
  77. package/dist/powerlines/src/lib/fs/storage/file-system.cjs +0 -170
  78. package/dist/powerlines/src/lib/fs/storage/file-system.mjs +0 -169
  79. package/dist/powerlines/src/lib/fs/storage/virtual.cjs +0 -88
  80. package/dist/powerlines/src/lib/fs/storage/virtual.mjs +0 -87
  81. package/dist/powerlines/src/lib/fs/vfs.cjs +0 -830
  82. package/dist/powerlines/src/lib/fs/vfs.mjs +0 -828
  83. package/dist/powerlines/src/lib/logger.cjs +0 -58
  84. package/dist/powerlines/src/lib/logger.mjs +0 -55
  85. package/dist/powerlines/src/lib/typescript/ts-morph.cjs +0 -104
  86. package/dist/powerlines/src/lib/typescript/ts-morph.mjs +0 -102
  87. package/dist/powerlines/src/lib/typescript/tsconfig.cjs +0 -149
  88. package/dist/powerlines/src/lib/typescript/tsconfig.mjs +0 -144
  89. package/dist/powerlines/src/lib/unplugin/factory.cjs +0 -6
  90. package/dist/powerlines/src/lib/unplugin/factory.mjs +0 -8
  91. package/dist/powerlines/src/lib/unplugin/helpers.cjs +0 -17
  92. package/dist/powerlines/src/lib/unplugin/helpers.mjs +0 -16
  93. package/dist/powerlines/src/lib/unplugin/index.cjs +0 -3
  94. package/dist/powerlines/src/lib/unplugin/index.mjs +0 -5
  95. package/dist/powerlines/src/lib/unplugin/plugin.cjs +0 -128
  96. package/dist/powerlines/src/lib/unplugin/plugin.mjs +0 -127
  97. package/dist/powerlines/src/lib/utilities/file-header.cjs +0 -22
  98. package/dist/powerlines/src/lib/utilities/file-header.mjs +0 -21
  99. package/dist/powerlines/src/lib/utilities/meta.cjs +0 -45
  100. package/dist/powerlines/src/lib/utilities/meta.mjs +0 -41
  101. package/dist/powerlines/src/lib/utilities/source-file.cjs +0 -22
  102. package/dist/powerlines/src/lib/utilities/source-file.mjs +0 -21
  103. package/dist/powerlines/src/plugin-utils/helpers.cjs +0 -148
  104. package/dist/powerlines/src/plugin-utils/helpers.mjs +0 -138
  105. package/dist/powerlines/src/plugin-utils/paths.cjs +0 -36
  106. package/dist/powerlines/src/plugin-utils/paths.mjs +0 -35
  107. package/dist/powerlines/src/types/babel.d.mts +0 -4
  108. package/dist/powerlines/src/types/build.cjs +0 -15
  109. package/dist/powerlines/src/types/build.d.cts +0 -149
  110. package/dist/powerlines/src/types/build.d.mts +0 -149
  111. package/dist/powerlines/src/types/build.mjs +0 -14
  112. package/dist/powerlines/src/types/commands.cjs +0 -16
  113. package/dist/powerlines/src/types/commands.d.cts +0 -8
  114. package/dist/powerlines/src/types/commands.d.mts +0 -9
  115. package/dist/powerlines/src/types/commands.mjs +0 -15
  116. package/dist/powerlines/src/types/config.d.cts +0 -370
  117. package/dist/powerlines/src/types/config.d.mts +0 -372
  118. package/dist/powerlines/src/types/context.d.cts +0 -403
  119. package/dist/powerlines/src/types/context.d.mts +0 -405
  120. package/dist/powerlines/src/types/fs.d.cts +0 -486
  121. package/dist/powerlines/src/types/fs.d.mts +0 -486
  122. package/dist/powerlines/src/types/hooks.d.mts +0 -2
  123. package/dist/powerlines/src/types/plugin.cjs +0 -32
  124. package/dist/powerlines/src/types/plugin.d.cts +0 -231
  125. package/dist/powerlines/src/types/plugin.d.mts +0 -231
  126. package/dist/powerlines/src/types/plugin.mjs +0 -31
  127. package/dist/powerlines/src/types/resolved.d.cts +0 -82
  128. package/dist/powerlines/src/types/resolved.d.mts +0 -83
  129. package/dist/powerlines/src/types/tsconfig.d.cts +0 -69
  130. package/dist/powerlines/src/types/tsconfig.d.mts +0 -69
@@ -1,128 +0,0 @@
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");
10
-
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,127 +0,0 @@
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";
9
-
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,22 +0,0 @@
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)}
8
- // Note: Do not edit this file manually - it will be overwritten automatically
9
- `;
10
- }
11
- function getFileHeader(context, options = {}) {
12
- const { directive = null, prettierIgnore = false } = options;
13
- return `/* eslint-disable */
14
- // biome-ignore lint: disable
15
- ${prettierIgnore ? `// prettier-ignore` : ""}${directive ? `\n\n${directive}\n` : "\n"}
16
- ${getBaseFileHeader(context)}
17
-
18
- `;
19
- }
20
-
21
- //#endregion
22
- exports.getFileHeader = getFileHeader;
@@ -1,21 +0,0 @@
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)}
7
- // Note: Do not edit this file manually - it will be overwritten automatically
8
- `;
9
- }
10
- function getFileHeader(context, options = {}) {
11
- const { directive = null, prettierIgnore = false } = options;
12
- return `/* eslint-disable */
13
- // biome-ignore lint: disable
14
- ${prettierIgnore ? `// prettier-ignore` : ""}${directive ? `\n\n${directive}\n` : "\n"}
15
- ${getBaseFileHeader(context)}
16
-
17
- `;
18
- }
19
-
20
- //#endregion
21
- export { getFileHeader };
@@ -1,45 +0,0 @@
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,41 +0,0 @@
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,22 +0,0 @@
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,21 +0,0 @@
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 };
@@ -1,148 +0,0 @@
1
- const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
2
- const require_build = require('../types/build.cjs');
3
- const require_plugin = require('../types/plugin.cjs');
4
- let __stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
5
- let __stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
6
- let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
7
- let __stryke_type_checks_is_undefined = require("@stryke/type-checks/is-undefined");
8
-
9
- //#region ../powerlines/src/plugin-utils/helpers.ts
10
- /**
11
- * Type guard to check if an object is a {@link Plugin}
12
- *
13
- * @param value - The object to check
14
- * @returns True if the object is a {@link Plugin}, false otherwise
15
- */
16
- function isPlugin(value) {
17
- return (0, __stryke_type_checks_is_set_object.isSetObject)(value) && "name" in value && (0, __stryke_type_checks_is_set_string.isSetString)(value.name) && ((0, __stryke_type_checks_is_undefined.isUndefined)(value.api) || "api" in value && (0, __stryke_type_checks_is_set_object.isSetObject)(value.api)) && ((0, __stryke_type_checks_is_undefined.isUndefined)(value.applyToEnvironment) || "applyToEnvironment" in value && (0, __stryke_type_checks_is_function.isFunction)(value.applyToEnvironment)) && ((0, __stryke_type_checks_is_undefined.isUndefined)(value.dedupe) || "dedupe" in value && (0, __stryke_type_checks_is_function.isFunction)(value.dedupe)) && require_plugin.KNOWN_HOOKS.every((hook) => (0, __stryke_type_checks_is_undefined.isUndefined)(value[hook]) || hook in value && (isPluginHookFunction(value[hook]) || hook === "config" && (0, __stryke_type_checks_is_set_object.isSetObject)(value[hook]))) && require_build.UNPLUGIN_BUILD_VARIANTS.every((variant) => (0, __stryke_type_checks_is_undefined.isUndefined)(value[variant]) || variant in value && (0, __stryke_type_checks_is_set_object.isSetObject)(value[variant]));
18
- }
19
- /**
20
- * Type guard to check if an object is a {@link PluginConfigObject}
21
- *
22
- * @param value - The object to check
23
- * @returns True if the object is a {@link PluginConfigObject}, false otherwise
24
- */
25
- function isPluginConfigObject(value) {
26
- return (0, __stryke_type_checks_is_set_object.isSetObject)(value) && "plugin" in value && (((0, __stryke_type_checks_is_set_string.isSetString)(value.plugin) || (0, __stryke_type_checks_is_function.isFunction)(value.plugin)) && "options" in value && (0, __stryke_type_checks_is_set_object.isSetObject)(value.options) || isPlugin(value.plugin));
27
- }
28
- /**
29
- * Type guard to check if an object is a {@link PluginConfigTuple}
30
- *
31
- * @param value - The object to check
32
- * @returns True if the object is a {@link PluginConfigTuple}, false otherwise
33
- */
34
- function isPluginConfigTuple(value) {
35
- return Array.isArray(value) && (value.length === 1 || value.length === 2) && (((0, __stryke_type_checks_is_set_string.isSetString)(value[0]) || (0, __stryke_type_checks_is_function.isFunction)(value[0])) && value.length > 1 && (0, __stryke_type_checks_is_set_object.isSetObject)(value[1]) || isPlugin(value[0]));
36
- }
37
- /**
38
- * Type guard to check if an object is a {@link PluginConfig}
39
- *
40
- * @param value - The object to check
41
- * @returns True if the object is a {@link PluginConfig}, false otherwise
42
- */
43
- function isPluginConfig(value) {
44
- return (0, __stryke_type_checks_is_set_string.isSetString)(value) || (0, __stryke_type_checks_is_function.isFunction)(value) || isPlugin(value) || isPluginConfigObject(value) || isPluginConfigTuple(value) || Array.isArray(value) && value.every((item) => isPluginConfig(item));
45
- }
46
- /**
47
- * Type guard to check if an value is a {@link PluginHook} function
48
- *
49
- * @param value - The value to check
50
- * @returns True if the value is a {@link PluginHook} function, false otherwise
51
- */
52
- function isPluginHookObject(value) {
53
- return (0, __stryke_type_checks_is_set_object.isSetObject)(value) && "handler" in value && (0, __stryke_type_checks_is_function.isFunction)(value.handler);
54
- }
55
- /**
56
- * Type guard to check if an value is a {@link PluginHook} function
57
- *
58
- * @param value - The value to check
59
- * @returns True if the value is a {@link PluginHook} function, false otherwise
60
- */
61
- function isPluginHookFunction(value) {
62
- return (0, __stryke_type_checks_is_function.isFunction)(value) || isPluginHookObject(value);
63
- }
64
- /**
65
- * Type guard to check if an object is a {@link PluginHook}
66
- *
67
- * @param value - The object to check
68
- * @returns True if the object is a {@link PluginHook}, false otherwise
69
- */
70
- function isPluginHook(value) {
71
- return isPluginHookFunction(value) || isPluginHookObject(value);
72
- }
73
- /**
74
- * Extract the hook handler function from a plugin hook
75
- *
76
- * @param pluginHook - The plugin hook to extract the handler function from
77
- * @returns The hook handler function
78
- */
79
- function getHookHandler(pluginHook) {
80
- return (0, __stryke_type_checks_is_function.isFunction)(pluginHook) ? pluginHook : pluginHook.handler;
81
- }
82
- /**
83
- * Check if a hook is external.
84
- *
85
- * @param hook - The name of the hook to check.
86
- * @returns True if the hook is external, false otherwise.
87
- */
88
- function isHookExternal(hook) {
89
- return hook.startsWith("vite:") || hook.startsWith("esbuild:") || hook.startsWith("rolldown:") || hook.startsWith("rollup:") || hook.startsWith("webpack:") || hook.startsWith("rspack:") || hook.startsWith("farm:");
90
- }
91
- /**
92
- * Check if a plugin should be deduplicated.
93
- *
94
- * @param plugin - The plugin to check
95
- * @param plugins - The list of plugins to check against
96
- * @returns True if the plugin should be deduplicated, false otherwise
97
- */
98
- function checkDedupe(plugin, plugins) {
99
- return plugin.dedupe === false || plugins.some((p) => p.dedupe !== false && ((0, __stryke_type_checks_is_function.isFunction)(p.dedupe) && p.dedupe(plugin) || p.name === plugin.name));
100
- }
101
- /**
102
- * Add a plugin hook to the hooks list.
103
- *
104
- * @param context - The plugin context
105
- * @param plugin - The plugin to add the hook from
106
- * @param pluginHook - The plugin hook to add
107
- * @param hooksList - The list of hooks to add to
108
- */
109
- function addPluginHook(context, plugin, pluginHook, hooksList) {
110
- if (!checkDedupe(plugin, hooksList.map((hook) => hook.plugin))) hooksList.push((0, __stryke_type_checks_is_function.isFunction)(pluginHook) ? {
111
- plugin,
112
- handler: getHookHandler(pluginHook).bind(context)
113
- } : {
114
- plugin,
115
- ...pluginHook,
116
- handler: getHookHandler(pluginHook).bind(context)
117
- });
118
- }
119
- /**
120
- * Check the provided {@link PluginConfig}, and return a stringified version of the invalid configuration. If an array is provided, check each item in the array.
121
- *
122
- * @param config - The plugin configuration to check
123
- * @returns Null if the configuration is valid, otherwise an array of stringified invalid configurations
124
- */
125
- function findInvalidPluginConfig(config) {
126
- if (isPluginConfig(config)) return null;
127
- if (Array.isArray(config)) {
128
- const invalidItems = [];
129
- config.forEach((item) => {
130
- const invalid = findInvalidPluginConfig(item);
131
- if (invalid) invalidItems.push(...invalid.map((i) => JSON.stringify(i, null, 2)));
132
- });
133
- return invalidItems.length > 0 ? invalidItems : null;
134
- }
135
- return [JSON.stringify(config, null, 2)];
136
- }
137
-
138
- //#endregion
139
- exports.addPluginHook = addPluginHook;
140
- exports.checkDedupe = checkDedupe;
141
- exports.findInvalidPluginConfig = findInvalidPluginConfig;
142
- exports.getHookHandler = getHookHandler;
143
- exports.isHookExternal = isHookExternal;
144
- exports.isPlugin = isPlugin;
145
- exports.isPluginConfig = isPluginConfig;
146
- exports.isPluginConfigObject = isPluginConfigObject;
147
- exports.isPluginConfigTuple = isPluginConfigTuple;
148
- exports.isPluginHook = isPluginHook;