@powerlines/plugin-style-dictionary 0.3.23 → 0.3.25

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 (52) hide show
  1. package/dist/_virtual/rolldown_runtime.cjs +29 -0
  2. package/dist/index.cjs +13 -210
  3. package/dist/index.d.cts +2 -2
  4. package/dist/index.d.mts +3 -2
  5. package/dist/index.mjs +2 -173
  6. package/dist/powerlines/src/lib/build/esbuild.cjs +102 -0
  7. package/dist/powerlines/src/lib/build/esbuild.mjs +100 -0
  8. package/dist/powerlines/src/lib/entry.cjs +12 -0
  9. package/dist/powerlines/src/lib/entry.mjs +14 -0
  10. package/dist/powerlines/src/lib/utilities/bundle.cjs +35 -0
  11. package/dist/powerlines/src/lib/utilities/bundle.mjs +34 -0
  12. package/dist/powerlines/src/lib/utilities/resolve.cjs +30 -0
  13. package/dist/powerlines/src/lib/utilities/resolve.mjs +29 -0
  14. package/dist/powerlines/src/plugin-utils/paths.cjs +1 -0
  15. package/dist/powerlines/src/plugin-utils/paths.mjs +3 -0
  16. package/dist/powerlines/src/types/babel.d.mts +2 -0
  17. package/dist/powerlines/src/types/build.d.cts +145 -0
  18. package/dist/powerlines/src/types/build.d.mts +147 -0
  19. package/dist/powerlines/src/types/commands.d.cts +8 -0
  20. package/dist/powerlines/src/types/commands.d.mts +9 -0
  21. package/dist/powerlines/src/types/config.d.cts +376 -0
  22. package/dist/powerlines/src/types/config.d.mts +376 -0
  23. package/dist/powerlines/src/types/context.d.cts +403 -0
  24. package/dist/powerlines/src/types/context.d.mts +405 -0
  25. package/dist/powerlines/src/types/fs.d.cts +486 -0
  26. package/dist/powerlines/src/types/fs.d.mts +486 -0
  27. package/dist/powerlines/src/types/hooks.d.mts +2 -0
  28. package/dist/powerlines/src/types/plugin.d.cts +231 -0
  29. package/dist/powerlines/src/types/plugin.d.mts +231 -0
  30. package/dist/powerlines/src/types/resolved.d.cts +81 -0
  31. package/dist/powerlines/src/types/resolved.d.mts +82 -0
  32. package/dist/powerlines/src/types/tsconfig.d.cts +69 -0
  33. package/dist/powerlines/src/types/tsconfig.d.mts +69 -0
  34. package/dist/style-dictionary/file-header.cjs +15 -0
  35. package/dist/style-dictionary/file-header.mjs +14 -0
  36. package/dist/types/index.cjs +0 -2
  37. package/dist/types/index.d.cts +1 -2
  38. package/dist/types/index.d.mts +1 -2
  39. package/dist/types/index.mjs +0 -3
  40. package/dist/types/plugin.cjs +0 -1
  41. package/dist/types/plugin.d.cts +117 -1
  42. package/dist/types/plugin.d.mts +117 -1
  43. package/dist/types/plugin.mjs +0 -2
  44. package/package.json +5 -5
  45. package/dist/index-BgAdqTbb.d.mts +0 -1
  46. package/dist/index-CEgs-Dz2.d.cts +0 -1
  47. package/dist/plugin-C3MaN5jp.mjs +0 -1
  48. package/dist/plugin-DHXHjv16.cjs +0 -0
  49. package/dist/plugin-DoaM1stj.d.cts +0 -1861
  50. package/dist/plugin-stDuO5l1.d.mts +0 -1862
  51. package/dist/types-CTUnla4x.mjs +0 -1
  52. package/dist/types-DHkg7xmX.cjs +0 -0
@@ -0,0 +1,29 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) {
13
+ __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ }
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+
27
+ //#endregion
28
+
29
+ exports.__toESM = __toESM;
package/dist/index.cjs CHANGED
@@ -1,211 +1,14 @@
1
1
  Object.defineProperty(exports, '__esModule', { value: true });
2
- //#region rolldown:runtime
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
- key = keys[i];
13
- if (!__hasOwnProp.call(to, key) && key !== except) {
14
- __defProp(to, key, {
15
- get: ((k) => from[k]).bind(null, key),
16
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
- });
18
- }
19
- }
20
- }
21
- return to;
22
- };
23
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24
- value: mod,
25
- enumerable: true
26
- }) : target, mod));
27
-
28
- //#endregion
29
- require('./plugin-DHXHjv16.cjs');
30
- require('./types-DHkg7xmX.cjs');
2
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
3
+ const require_resolve = require('./powerlines/src/lib/utilities/resolve.cjs');
4
+ const require_file_header = require('./style-dictionary/file-header.cjs');
31
5
  let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
32
6
  let __stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
33
7
  let defu = require("defu");
34
- defu = __toESM(defu);
35
- let __stryke_convert_parse_type_definition = require("@stryke/convert/parse-type-definition");
36
- let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
37
- let esbuild = require("esbuild");
38
- let __stryke_helpers_omit = require("@stryke/helpers/omit");
39
- let __stryke_path_join_paths = require("@stryke/path/join-paths");
40
- require("@stryke/path/replace");
41
- let __stryke_string_format_camel_case = require("@stryke/string-format/camel-case");
42
- require("@stryke/type-checks/is-string");
43
- require("@stryke/convert/to-array");
44
- require("@stryke/fs/is-file");
45
- require("@stryke/fs/list-files");
46
- require("@stryke/hash/murmurhash");
47
- require("@stryke/helpers/get-unique");
48
- require("@stryke/path/append");
8
+ defu = require_rolldown_runtime.__toESM(defu);
49
9
  let style_dictionary = require("style-dictionary");
50
- style_dictionary = __toESM(style_dictionary);
10
+ style_dictionary = require_rolldown_runtime.__toESM(style_dictionary);
51
11
 
52
- //#region ../powerlines/src/lib/build/esbuild.ts
53
- const DEFAULT_ESBUILD_CONFIG = {
54
- target: "esnext",
55
- platform: "neutral",
56
- format: "esm",
57
- write: true,
58
- minify: true,
59
- sourcemap: false,
60
- bundle: true,
61
- treeShaking: true,
62
- keepNames: true,
63
- splitting: true,
64
- logLevel: "silent"
65
- };
66
- /**
67
- * Resolves the esbuild options.
68
- *
69
- * @param context - The build context.
70
- * @returns The resolved esbuild options.
71
- */
72
- function extractESBuildConfig(context) {
73
- const inject = context.config.build.override.inject ?? context.config.build.inject;
74
- if (inject && Object.keys(inject).length > 0) context.fs.writeSync((0, __stryke_path_join_paths.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.artifactsPath, "inject-shim.js"), Object.entries(inject).map(([key, value]) => {
75
- if (value) if (Array.isArray(value)) {
76
- if ((0, __stryke_string_format_camel_case.camelCase)(key) !== key) {
77
- if (value.length === 1) return `
78
- import ${(0, __stryke_string_format_camel_case.camelCase)(key)} from "${value[0]}";
79
- export { ${(0, __stryke_string_format_camel_case.camelCase)(key)} as "${key}" }`;
80
- else if (value.length > 1) return `
81
- import ${value[1] === "*" ? `* as ${(0, __stryke_string_format_camel_case.camelCase)(key)}` : `{ ${value[1]} as ${(0, __stryke_string_format_camel_case.camelCase)(key)} }`} from "${value[0]}";
82
- export { ${(0, __stryke_string_format_camel_case.camelCase)(key)} as "${key}" }`;
83
- } else if (value.length === 1) return `
84
- import ${key} from "${value[0]}";
85
- export { ${key} };`;
86
- else if (value.length > 1) return `
87
- import ${value[1] === "*" ? `* as ${key}` : `{ ${value[1]} as ${key} }`} from "${value[0]}";
88
- export { ${key} };`;
89
- } else if ((0, __stryke_string_format_camel_case.camelCase)(key) !== key) return `
90
- import ${(0, __stryke_string_format_camel_case.camelCase)(key)} from "${value[0]}";
91
- export { ${(0, __stryke_string_format_camel_case.camelCase)(key)} as "${key}" }`;
92
- else return `
93
- import ${key} from "${value}";
94
- export { ${key} };`;
95
- return "";
96
- }).join("\n"));
97
- return (0, defu.default)({
98
- alias: context.builtins.reduce((ret, id) => {
99
- if (!ret[id]) {
100
- const path = context.fs.ids[id];
101
- if (path) ret[id] = path;
102
- }
103
- return ret;
104
- }, context.config.build.alias ? Array.isArray(context.config.build.alias) ? context.config.build.alias.reduce((ret, alias) => {
105
- if (!ret[alias.find.toString()]) ret[alias.find.toString()] = alias.replacement;
106
- return ret;
107
- }, {}) : context.config.build.alias : {}),
108
- inject: inject && Object.keys(inject).length > 0 ? [(0, __stryke_path_join_paths.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.artifactsPath, "inject-shim.js")] : void 0
109
- }, context.config.build.variant === "esbuild" ? (0, __stryke_helpers_omit.omit)(context.config.build.override, [
110
- "alias",
111
- "inject",
112
- "external",
113
- "noExternal",
114
- "skipNodeModulesBundle",
115
- "extensions"
116
- ]) : {}, context.config.build.variant === "esbuild" ? (0, __stryke_helpers_omit.omit)(context.config.build, [
117
- "alias",
118
- "inject",
119
- "external",
120
- "noExternal",
121
- "skipNodeModulesBundle",
122
- "extensions",
123
- "variant",
124
- "override"
125
- ]) : {}, {
126
- mainFields: context.config.build.mainFields,
127
- conditions: context.config.build.conditions,
128
- define: context.config.build.define,
129
- resolveExtensions: context.config.build.extensions,
130
- packages: context.config.build.skipNodeModulesBundle ? "external" : context.config.build.variant === "esbuild" ? context.config.build.packages : void 0,
131
- format: Array.isArray(context.config.output.format) ? context.config.output.format[0] : context.config.output.format,
132
- platform: context.config.build.platform,
133
- treeShaking: Boolean(context.config.build?.treeshake) || context.config.build?.treeShaking,
134
- outdir: context.config.output.buildPath,
135
- tsconfig: context.tsconfig.tsconfigFilePath,
136
- minify: context.config.mode !== "development",
137
- metafile: context.config.mode === "development",
138
- sourcemap: context.config.mode === "development"
139
- }, DEFAULT_ESBUILD_CONFIG);
140
- }
141
-
142
- //#endregion
143
- //#region ../powerlines/src/lib/utilities/bundle.ts
144
- /**
145
- * Bundle a type definition to a module.
146
- *
147
- * @param context - The context object containing the environment paths.
148
- * @param file - The file path to bundle.
149
- * @param overrides - Optional overrides for the ESBuild configuration.
150
- * @returns A promise that resolves to the bundled module.
151
- */
152
- async function bundle(context, file, overrides = {}) {
153
- const path = await context.fs.resolve(file);
154
- if (!path || !context.fs.existsSync(path)) throw new Error(`Module not found: "${file}". Please check the path and try again.`);
155
- const result = await (0, esbuild.build)({
156
- ...extractESBuildConfig(context),
157
- entryPoints: [path],
158
- write: false,
159
- sourcemap: false,
160
- splitting: false,
161
- treeShaking: false,
162
- bundle: true,
163
- ...overrides
164
- });
165
- if (result.errors.length > 0) throw new Error(`Failed to transpile ${file}: ${result.errors.map((error) => error.text).join(", ")}`);
166
- if (result.warnings.length > 0) context.log(__storm_software_config_tools_types.LogLevelLabel.WARN, `Warnings while transpiling ${file}: ${result.warnings.map((warning) => warning.text).join(", ")}`);
167
- if (!result.outputFiles || result.outputFiles.filter(Boolean).length === 0) throw new Error(`No output files generated for ${file}. Please check the configuration and try again.`);
168
- return result.outputFiles.filter(Boolean)[0];
169
- }
170
-
171
- //#endregion
172
- //#region ../powerlines/src/lib/utilities/resolve.ts
173
- /**
174
- * Compiles a type definition to a module.
175
- *
176
- * @param context - The context object containing the environment paths.
177
- * @param type - The type definition to compile. This can be either a string or a {@link TypeDefinition} object.
178
- * @param overrides - Optional overrides for the ESBuild configuration.
179
- * @returns A promise that resolves to the compiled module.
180
- */
181
- async function resolve(context, type, overrides = {}) {
182
- let typeDefinition;
183
- if ((0, __stryke_type_checks_is_set_string.isSetString)(type)) typeDefinition = (0, __stryke_convert_parse_type_definition.parseTypeDefinition)(type);
184
- else typeDefinition = type;
185
- const result = await bundle(context, typeDefinition.file, overrides);
186
- const resolved = await context.resolver.evalModule(result.text, {
187
- filename: result.path,
188
- forceTranspile: true
189
- });
190
- let exportName = typeDefinition.name;
191
- if (!exportName) exportName = "default";
192
- return resolved[exportName] ?? resolved[`__Ω${exportName}`];
193
- }
194
-
195
- //#endregion
196
- //#region src/style-dictionary/file-header.ts
197
- const fileHeader = (context) => ({
198
- name: "powerlines/file-header",
199
- fileHeader: (defaultMessages = []) => {
200
- return [
201
- `Generated by ${context.config.framework || "Powerlines"}`,
202
- "NOTE: Do not edit this file manually - it will be overwritten automatically by the \"prepare\" command",
203
- ...defaultMessages
204
- ];
205
- }
206
- });
207
-
208
- //#endregion
209
12
  //#region src/index.ts
210
13
  /**
211
14
  * A Powerlines plugin to integrate style-dictionary for code generation.
@@ -224,11 +27,11 @@ const plugin = (options = {}) => {
224
27
  },
225
28
  async configResolved() {
226
29
  this.styleDictionary = this.config.styleDictionary.instance ?? new style_dictionary.default(this.config.styleDictionary);
227
- this.styleDictionary.registerFileHeader(fileHeader(this));
30
+ this.styleDictionary.registerFileHeader(require_file_header.fileHeader(this));
228
31
  if (this.config.styleDictionary.customActions) {
229
32
  let builder;
230
33
  if ((0, __stryke_type_checks_is_function.isFunction)(this.config.styleDictionary.customActions)) builder = this.config.styleDictionary.customActions;
231
- else builder = await resolve(this, this.config.styleDictionary.customActions);
34
+ else builder = await require_resolve.resolve(this, this.config.styleDictionary.customActions);
232
35
  Object.entries((0, __stryke_type_checks_is_function.isFunction)(builder) ? builder(this) : builder).forEach(([name, action]) => {
233
36
  this.styleDictionary.registerAction({
234
37
  ...action,
@@ -239,7 +42,7 @@ const plugin = (options = {}) => {
239
42
  if (this.config.styleDictionary.customFileHeaders) {
240
43
  let builder;
241
44
  if ((0, __stryke_type_checks_is_function.isFunction)(this.config.styleDictionary.customFileHeaders)) builder = this.config.styleDictionary.customFileHeaders;
242
- else builder = await resolve(this, this.config.styleDictionary.customFileHeaders);
45
+ else builder = await require_resolve.resolve(this, this.config.styleDictionary.customFileHeaders);
243
46
  Object.entries((0, __stryke_type_checks_is_function.isFunction)(builder) ? builder(this) : builder).forEach(([name, fileHeader$1]) => {
244
47
  this.styleDictionary.registerFileHeader({
245
48
  name,
@@ -250,7 +53,7 @@ const plugin = (options = {}) => {
250
53
  if (this.config.styleDictionary.customFilters) {
251
54
  let builder;
252
55
  if ((0, __stryke_type_checks_is_function.isFunction)(this.config.styleDictionary.customFilters)) builder = this.config.styleDictionary.customFilters;
253
- else builder = await resolve(this, this.config.styleDictionary.customFilters);
56
+ else builder = await require_resolve.resolve(this, this.config.styleDictionary.customFilters);
254
57
  Object.entries((0, __stryke_type_checks_is_function.isFunction)(builder) ? builder(this) : builder).forEach(([name, filter]) => {
255
58
  this.styleDictionary.registerFilter({
256
59
  ...filter,
@@ -261,7 +64,7 @@ const plugin = (options = {}) => {
261
64
  if (this.config.styleDictionary.customPreprocessors) {
262
65
  let builder;
263
66
  if ((0, __stryke_type_checks_is_function.isFunction)(this.config.styleDictionary.customPreprocessors)) builder = this.config.styleDictionary.customPreprocessors;
264
- else builder = await resolve(this, this.config.styleDictionary.customPreprocessors);
67
+ else builder = await require_resolve.resolve(this, this.config.styleDictionary.customPreprocessors);
265
68
  Object.entries((0, __stryke_type_checks_is_function.isFunction)(builder) ? builder(this) : builder).forEach(([name, preprocessor]) => {
266
69
  this.styleDictionary.registerPreprocessor({
267
70
  ...preprocessor,
@@ -272,7 +75,7 @@ const plugin = (options = {}) => {
272
75
  if (this.config.styleDictionary.customParsers) {
273
76
  let builder;
274
77
  if ((0, __stryke_type_checks_is_function.isFunction)(this.config.styleDictionary.customParsers)) builder = this.config.styleDictionary.customParsers;
275
- else builder = await resolve(this, this.config.styleDictionary.customParsers);
78
+ else builder = await require_resolve.resolve(this, this.config.styleDictionary.customParsers);
276
79
  Object.entries((0, __stryke_type_checks_is_function.isFunction)(builder) ? builder(this) : builder).forEach(([name, parser]) => {
277
80
  this.styleDictionary.registerParser({
278
81
  ...parser,
@@ -283,7 +86,7 @@ const plugin = (options = {}) => {
283
86
  if (this.config.styleDictionary.customTransforms) {
284
87
  let builder;
285
88
  if ((0, __stryke_type_checks_is_function.isFunction)(this.config.styleDictionary.customTransforms)) builder = this.config.styleDictionary.customTransforms;
286
- else builder = await resolve(this, this.config.styleDictionary.customTransforms);
89
+ else builder = await require_resolve.resolve(this, this.config.styleDictionary.customTransforms);
287
90
  Object.entries((0, __stryke_type_checks_is_function.isFunction)(builder) ? builder(this) : builder).forEach(([name, transform]) => {
288
91
  this.styleDictionary.registerTransform({
289
92
  ...transform,
@@ -294,7 +97,7 @@ const plugin = (options = {}) => {
294
97
  if (this.config.styleDictionary.customTransformGroups) {
295
98
  let builder;
296
99
  if ((0, __stryke_type_checks_is_function.isFunction)(this.config.styleDictionary.customTransformGroups)) builder = this.config.styleDictionary.customTransformGroups;
297
- else builder = await resolve(this, this.config.styleDictionary.customTransformGroups);
100
+ else builder = await require_resolve.resolve(this, this.config.styleDictionary.customTransformGroups);
298
101
  Object.entries((0, __stryke_type_checks_is_function.isFunction)(builder) ? builder(this) : builder).forEach(([name, transformGroup]) => {
299
102
  this.styleDictionary.registerTransformGroup({
300
103
  name,
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as __ΩStyleDictionaryPluginEnvironmentConfig, D as Plugin, E as __ΩStyleDictionaryPluginUserConfig, S as __ΩStyleDictionaryPluginContext, T as __ΩStyleDictionaryPluginResolvedConfig, _ as __ΩCustomFormatsBuilder, a as CustomParsersBuilder, b as __ΩCustomTransformGroupsBuilder, c as CustomTransformsBuilder, d as StyleDictionaryPluginOptions, f as StyleDictionaryPluginResolvedConfig, g as __ΩCustomFiltersBuilder, h as __ΩCustomFileHeadersBuilder, i as CustomFormatsBuilder, l as StyleDictionaryPluginContext, m as __ΩCustomActionsBuilder, n as CustomFileHeadersBuilder, o as CustomPreprocessorsBuilder, p as StyleDictionaryPluginUserConfig, r as CustomFiltersBuilder, s as CustomTransformGroupsBuilder, t as CustomActionsBuilder, u as StyleDictionaryPluginEnvironmentConfig, v as __ΩCustomParsersBuilder, w as __ΩStyleDictionaryPluginOptions, x as __ΩCustomTransformsBuilder, y as __ΩCustomPreprocessorsBuilder } from "./plugin-DoaM1stj.cjs";
2
- import "./index-CEgs-Dz2.cjs";
1
+ import { Plugin } from "./powerlines/src/types/plugin.cjs";
2
+ import { CustomActionsBuilder, CustomFileHeadersBuilder, CustomFiltersBuilder, CustomFormatsBuilder, CustomParsersBuilder, CustomPreprocessorsBuilder, CustomTransformGroupsBuilder, CustomTransformsBuilder, StyleDictionaryPluginContext, StyleDictionaryPluginEnvironmentConfig, StyleDictionaryPluginOptions, StyleDictionaryPluginResolvedConfig, StyleDictionaryPluginUserConfig, __ΩCustomActionsBuilder, __ΩCustomFileHeadersBuilder, __ΩCustomFiltersBuilder, __ΩCustomFormatsBuilder, __ΩCustomParsersBuilder, __ΩCustomPreprocessorsBuilder, __ΩCustomTransformGroupsBuilder, __ΩCustomTransformsBuilder, __ΩStyleDictionaryPluginContext, __ΩStyleDictionaryPluginEnvironmentConfig, __ΩStyleDictionaryPluginOptions, __ΩStyleDictionaryPluginResolvedConfig, __ΩStyleDictionaryPluginUserConfig } from "./types/plugin.cjs";
3
3
 
4
4
  //#region src/index.d.ts
5
5
 
package/dist/index.d.mts CHANGED
@@ -1,5 +1,6 @@
1
- import { C as __ΩStyleDictionaryPluginEnvironmentConfig, D as Plugin, E as __ΩStyleDictionaryPluginUserConfig, S as __ΩStyleDictionaryPluginContext, T as __ΩStyleDictionaryPluginResolvedConfig, _ as __ΩCustomFormatsBuilder, a as CustomParsersBuilder, b as __ΩCustomTransformGroupsBuilder, c as CustomTransformsBuilder, d as StyleDictionaryPluginOptions, f as StyleDictionaryPluginResolvedConfig, g as __ΩCustomFiltersBuilder, h as __ΩCustomFileHeadersBuilder, i as CustomFormatsBuilder, l as StyleDictionaryPluginContext, m as __ΩCustomActionsBuilder, n as CustomFileHeadersBuilder, o as CustomPreprocessorsBuilder, p as StyleDictionaryPluginUserConfig, r as CustomFiltersBuilder, s as CustomTransformGroupsBuilder, t as CustomActionsBuilder, u as StyleDictionaryPluginEnvironmentConfig, v as __ΩCustomParsersBuilder, w as __ΩStyleDictionaryPluginOptions, x as __ΩCustomTransformsBuilder, y as __ΩCustomPreprocessorsBuilder } from "./plugin-stDuO5l1.mjs";
2
- import "./index-BgAdqTbb.mjs";
1
+ import { Plugin } from "./powerlines/src/types/plugin.mjs";
2
+ import { CustomActionsBuilder, CustomFileHeadersBuilder, CustomFiltersBuilder, CustomFormatsBuilder, CustomParsersBuilder, CustomPreprocessorsBuilder, CustomTransformGroupsBuilder, CustomTransformsBuilder, StyleDictionaryPluginContext, StyleDictionaryPluginEnvironmentConfig, StyleDictionaryPluginOptions, StyleDictionaryPluginResolvedConfig, StyleDictionaryPluginUserConfig, __ΩCustomActionsBuilder, __ΩCustomFileHeadersBuilder, __ΩCustomFiltersBuilder, __ΩCustomFormatsBuilder, __ΩCustomParsersBuilder, __ΩCustomPreprocessorsBuilder, __ΩCustomTransformGroupsBuilder, __ΩCustomTransformsBuilder, __ΩStyleDictionaryPluginContext, __ΩStyleDictionaryPluginEnvironmentConfig, __ΩStyleDictionaryPluginOptions, __ΩStyleDictionaryPluginResolvedConfig, __ΩStyleDictionaryPluginUserConfig } from "./types/plugin.mjs";
3
+ import "./types/index.mjs";
3
4
 
4
5
  //#region src/index.d.ts
5
6
 
package/dist/index.mjs CHANGED
@@ -1,181 +1,10 @@
1
- import "./plugin-C3MaN5jp.mjs";
2
- import "./types-CTUnla4x.mjs";
1
+ import { resolve } from "./powerlines/src/lib/utilities/resolve.mjs";
2
+ import { fileHeader } from "./style-dictionary/file-header.mjs";
3
3
  import { LogLevelLabel } from "@storm-software/config-tools/types";
4
4
  import { isFunction } from "@stryke/type-checks/is-function";
5
5
  import defu from "defu";
6
- import { parseTypeDefinition } from "@stryke/convert/parse-type-definition";
7
- import { isSetString } from "@stryke/type-checks/is-set-string";
8
- import { build } from "esbuild";
9
- import { omit } from "@stryke/helpers/omit";
10
- import { joinPaths } from "@stryke/path/join-paths";
11
- import "@stryke/path/replace";
12
- import { camelCase } from "@stryke/string-format/camel-case";
13
- import "@stryke/type-checks/is-string";
14
- import "@stryke/convert/to-array";
15
- import "@stryke/fs/is-file";
16
- import "@stryke/fs/list-files";
17
- import "@stryke/hash/murmurhash";
18
- import "@stryke/helpers/get-unique";
19
- import "@stryke/path/append";
20
6
  import StyleDictionary from "style-dictionary";
21
7
 
22
- //#region ../powerlines/src/lib/build/esbuild.ts
23
- const DEFAULT_ESBUILD_CONFIG = {
24
- target: "esnext",
25
- platform: "neutral",
26
- format: "esm",
27
- write: true,
28
- minify: true,
29
- sourcemap: false,
30
- bundle: true,
31
- treeShaking: true,
32
- keepNames: true,
33
- splitting: true,
34
- logLevel: "silent"
35
- };
36
- /**
37
- * Resolves the esbuild options.
38
- *
39
- * @param context - The build context.
40
- * @returns The resolved esbuild options.
41
- */
42
- function extractESBuildConfig(context) {
43
- const inject = context.config.build.override.inject ?? context.config.build.inject;
44
- if (inject && Object.keys(inject).length > 0) context.fs.writeSync(joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.artifactsPath, "inject-shim.js"), Object.entries(inject).map(([key, value]) => {
45
- if (value) if (Array.isArray(value)) {
46
- if (camelCase(key) !== key) {
47
- if (value.length === 1) return `
48
- import ${camelCase(key)} from "${value[0]}";
49
- export { ${camelCase(key)} as "${key}" }`;
50
- else if (value.length > 1) return `
51
- import ${value[1] === "*" ? `* as ${camelCase(key)}` : `{ ${value[1]} as ${camelCase(key)} }`} from "${value[0]}";
52
- export { ${camelCase(key)} as "${key}" }`;
53
- } else if (value.length === 1) return `
54
- import ${key} from "${value[0]}";
55
- export { ${key} };`;
56
- else if (value.length > 1) return `
57
- import ${value[1] === "*" ? `* as ${key}` : `{ ${value[1]} as ${key} }`} from "${value[0]}";
58
- export { ${key} };`;
59
- } else if (camelCase(key) !== key) return `
60
- import ${camelCase(key)} from "${value[0]}";
61
- export { ${camelCase(key)} as "${key}" }`;
62
- else return `
63
- import ${key} from "${value}";
64
- export { ${key} };`;
65
- return "";
66
- }).join("\n"));
67
- return defu({
68
- alias: context.builtins.reduce((ret, id) => {
69
- if (!ret[id]) {
70
- const path = context.fs.ids[id];
71
- if (path) ret[id] = path;
72
- }
73
- return ret;
74
- }, context.config.build.alias ? Array.isArray(context.config.build.alias) ? context.config.build.alias.reduce((ret, alias) => {
75
- if (!ret[alias.find.toString()]) ret[alias.find.toString()] = alias.replacement;
76
- return ret;
77
- }, {}) : context.config.build.alias : {}),
78
- inject: inject && Object.keys(inject).length > 0 ? [joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.artifactsPath, "inject-shim.js")] : void 0
79
- }, context.config.build.variant === "esbuild" ? omit(context.config.build.override, [
80
- "alias",
81
- "inject",
82
- "external",
83
- "noExternal",
84
- "skipNodeModulesBundle",
85
- "extensions"
86
- ]) : {}, context.config.build.variant === "esbuild" ? omit(context.config.build, [
87
- "alias",
88
- "inject",
89
- "external",
90
- "noExternal",
91
- "skipNodeModulesBundle",
92
- "extensions",
93
- "variant",
94
- "override"
95
- ]) : {}, {
96
- mainFields: context.config.build.mainFields,
97
- conditions: context.config.build.conditions,
98
- define: context.config.build.define,
99
- resolveExtensions: context.config.build.extensions,
100
- packages: context.config.build.skipNodeModulesBundle ? "external" : context.config.build.variant === "esbuild" ? context.config.build.packages : void 0,
101
- format: Array.isArray(context.config.output.format) ? context.config.output.format[0] : context.config.output.format,
102
- platform: context.config.build.platform,
103
- treeShaking: Boolean(context.config.build?.treeshake) || context.config.build?.treeShaking,
104
- outdir: context.config.output.buildPath,
105
- tsconfig: context.tsconfig.tsconfigFilePath,
106
- minify: context.config.mode !== "development",
107
- metafile: context.config.mode === "development",
108
- sourcemap: context.config.mode === "development"
109
- }, DEFAULT_ESBUILD_CONFIG);
110
- }
111
-
112
- //#endregion
113
- //#region ../powerlines/src/lib/utilities/bundle.ts
114
- /**
115
- * Bundle a type definition to a module.
116
- *
117
- * @param context - The context object containing the environment paths.
118
- * @param file - The file path to bundle.
119
- * @param overrides - Optional overrides for the ESBuild configuration.
120
- * @returns A promise that resolves to the bundled module.
121
- */
122
- async function bundle(context, file, overrides = {}) {
123
- const path = await context.fs.resolve(file);
124
- if (!path || !context.fs.existsSync(path)) throw new Error(`Module not found: "${file}". Please check the path and try again.`);
125
- const result = await build({
126
- ...extractESBuildConfig(context),
127
- entryPoints: [path],
128
- write: false,
129
- sourcemap: false,
130
- splitting: false,
131
- treeShaking: false,
132
- bundle: true,
133
- ...overrides
134
- });
135
- if (result.errors.length > 0) throw new Error(`Failed to transpile ${file}: ${result.errors.map((error) => error.text).join(", ")}`);
136
- if (result.warnings.length > 0) context.log(LogLevelLabel.WARN, `Warnings while transpiling ${file}: ${result.warnings.map((warning) => warning.text).join(", ")}`);
137
- if (!result.outputFiles || result.outputFiles.filter(Boolean).length === 0) throw new Error(`No output files generated for ${file}. Please check the configuration and try again.`);
138
- return result.outputFiles.filter(Boolean)[0];
139
- }
140
-
141
- //#endregion
142
- //#region ../powerlines/src/lib/utilities/resolve.ts
143
- /**
144
- * Compiles a type definition to a module.
145
- *
146
- * @param context - The context object containing the environment paths.
147
- * @param type - The type definition to compile. This can be either a string or a {@link TypeDefinition} object.
148
- * @param overrides - Optional overrides for the ESBuild configuration.
149
- * @returns A promise that resolves to the compiled module.
150
- */
151
- async function resolve(context, type, overrides = {}) {
152
- let typeDefinition;
153
- if (isSetString(type)) typeDefinition = parseTypeDefinition(type);
154
- else typeDefinition = type;
155
- const result = await bundle(context, typeDefinition.file, overrides);
156
- const resolved = await context.resolver.evalModule(result.text, {
157
- filename: result.path,
158
- forceTranspile: true
159
- });
160
- let exportName = typeDefinition.name;
161
- if (!exportName) exportName = "default";
162
- return resolved[exportName] ?? resolved[`__Ω${exportName}`];
163
- }
164
-
165
- //#endregion
166
- //#region src/style-dictionary/file-header.ts
167
- const fileHeader = (context) => ({
168
- name: "powerlines/file-header",
169
- fileHeader: (defaultMessages = []) => {
170
- return [
171
- `Generated by ${context.config.framework || "Powerlines"}`,
172
- "NOTE: Do not edit this file manually - it will be overwritten automatically by the \"prepare\" command",
173
- ...defaultMessages
174
- ];
175
- }
176
- });
177
-
178
- //#endregion
179
8
  //#region src/index.ts
180
9
  /**
181
10
  * A Powerlines plugin to integrate style-dictionary for code generation.
@@ -0,0 +1,102 @@
1
+ const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
2
+ require('../entry.cjs');
3
+ let defu = require("defu");
4
+ defu = require_rolldown_runtime.__toESM(defu);
5
+ let __stryke_helpers_omit = require("@stryke/helpers/omit");
6
+ let __stryke_path_join_paths = require("@stryke/path/join-paths");
7
+ require("@stryke/path/replace");
8
+ let __stryke_string_format_camel_case = require("@stryke/string-format/camel-case");
9
+ require("@stryke/type-checks/is-string");
10
+
11
+ //#region ../powerlines/src/lib/build/esbuild.ts
12
+ const DEFAULT_ESBUILD_CONFIG = {
13
+ target: "esnext",
14
+ platform: "neutral",
15
+ format: "esm",
16
+ write: true,
17
+ minify: true,
18
+ sourcemap: false,
19
+ bundle: true,
20
+ treeShaking: true,
21
+ keepNames: true,
22
+ splitting: true,
23
+ logLevel: "silent"
24
+ };
25
+ /**
26
+ * Resolves the esbuild options.
27
+ *
28
+ * @param context - The build context.
29
+ * @returns The resolved esbuild options.
30
+ */
31
+ function extractESBuildConfig(context) {
32
+ const inject = context.config.build.override.inject ?? context.config.build.inject;
33
+ if (inject && Object.keys(inject).length > 0) context.fs.writeSync((0, __stryke_path_join_paths.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.artifactsPath, "inject-shim.js"), Object.entries(inject).map(([key, value]) => {
34
+ if (value) if (Array.isArray(value)) {
35
+ if ((0, __stryke_string_format_camel_case.camelCase)(key) !== key) {
36
+ if (value.length === 1) return `
37
+ import ${(0, __stryke_string_format_camel_case.camelCase)(key)} from "${value[0]}";
38
+ export { ${(0, __stryke_string_format_camel_case.camelCase)(key)} as "${key}" }`;
39
+ else if (value.length > 1) return `
40
+ import ${value[1] === "*" ? `* as ${(0, __stryke_string_format_camel_case.camelCase)(key)}` : `{ ${value[1]} as ${(0, __stryke_string_format_camel_case.camelCase)(key)} }`} from "${value[0]}";
41
+ export { ${(0, __stryke_string_format_camel_case.camelCase)(key)} as "${key}" }`;
42
+ } else if (value.length === 1) return `
43
+ import ${key} from "${value[0]}";
44
+ export { ${key} };`;
45
+ else if (value.length > 1) return `
46
+ import ${value[1] === "*" ? `* as ${key}` : `{ ${value[1]} as ${key} }`} from "${value[0]}";
47
+ export { ${key} };`;
48
+ } else if ((0, __stryke_string_format_camel_case.camelCase)(key) !== key) return `
49
+ import ${(0, __stryke_string_format_camel_case.camelCase)(key)} from "${value[0]}";
50
+ export { ${(0, __stryke_string_format_camel_case.camelCase)(key)} as "${key}" }`;
51
+ else return `
52
+ import ${key} from "${value}";
53
+ export { ${key} };`;
54
+ return "";
55
+ }).join("\n"));
56
+ return (0, defu.default)({
57
+ alias: context.builtins.reduce((ret, id) => {
58
+ if (!ret[id]) {
59
+ const path = context.fs.ids[id];
60
+ if (path) ret[id] = path;
61
+ }
62
+ return ret;
63
+ }, context.config.build.alias ? Array.isArray(context.config.build.alias) ? context.config.build.alias.reduce((ret, alias) => {
64
+ if (!ret[alias.find.toString()]) ret[alias.find.toString()] = alias.replacement;
65
+ return ret;
66
+ }, {}) : context.config.build.alias : {}),
67
+ inject: inject && Object.keys(inject).length > 0 ? [(0, __stryke_path_join_paths.joinPaths)(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.artifactsPath, "inject-shim.js")] : void 0
68
+ }, context.config.build.variant === "esbuild" ? (0, __stryke_helpers_omit.omit)(context.config.build.override, [
69
+ "alias",
70
+ "inject",
71
+ "external",
72
+ "noExternal",
73
+ "skipNodeModulesBundle",
74
+ "extensions"
75
+ ]) : {}, context.config.build.variant === "esbuild" ? (0, __stryke_helpers_omit.omit)(context.config.build, [
76
+ "alias",
77
+ "inject",
78
+ "external",
79
+ "noExternal",
80
+ "skipNodeModulesBundle",
81
+ "extensions",
82
+ "variant",
83
+ "override"
84
+ ]) : {}, {
85
+ mainFields: context.config.build.mainFields,
86
+ conditions: context.config.build.conditions,
87
+ define: context.config.build.define,
88
+ resolveExtensions: context.config.build.extensions,
89
+ packages: context.config.build.skipNodeModulesBundle ? "external" : context.config.build.variant === "esbuild" ? context.config.build.packages : void 0,
90
+ format: Array.isArray(context.config.output.format) ? context.config.output.format[0] : context.config.output.format,
91
+ platform: context.config.build.platform,
92
+ treeShaking: Boolean(context.config.build?.treeshake) || context.config.build?.treeShaking,
93
+ outdir: context.config.output.buildPath,
94
+ tsconfig: context.tsconfig.tsconfigFilePath,
95
+ minify: context.config.mode !== "development",
96
+ metafile: context.config.mode === "development",
97
+ sourcemap: context.config.mode === "development"
98
+ }, DEFAULT_ESBUILD_CONFIG);
99
+ }
100
+
101
+ //#endregion
102
+ exports.extractESBuildConfig = extractESBuildConfig;