@powerlines/plugin-style-dictionary 0.3.22 → 0.3.24
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.
- package/dist/index-BgAdqTbb.d.mts +1 -0
- package/dist/index-CEgs-Dz2.d.cts +1 -0
- package/dist/index.cjs +210 -13
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -3
- package/dist/index.mjs +173 -2
- package/dist/plugin-C3MaN5jp.mjs +1 -0
- package/dist/plugin-CXsNgnqK.d.mts +1869 -0
- package/dist/plugin-DHXHjv16.cjs +0 -0
- package/dist/plugin-DOb20y5l.d.cts +1868 -0
- package/dist/types/index.cjs +2 -0
- package/dist/types/index.d.cts +2 -1
- package/dist/types/index.d.mts +2 -1
- package/dist/types/index.mjs +3 -0
- package/dist/types/plugin.cjs +1 -0
- package/dist/types/plugin.d.cts +1 -117
- package/dist/types/plugin.d.mts +1 -117
- package/dist/types/plugin.mjs +2 -0
- package/dist/types-CTUnla4x.mjs +1 -0
- package/dist/types-DHkg7xmX.cjs +0 -0
- package/package.json +5 -5
- package/dist/_virtual/rolldown_runtime.cjs +0 -29
- package/dist/powerlines/src/lib/build/esbuild.cjs +0 -102
- package/dist/powerlines/src/lib/build/esbuild.mjs +0 -100
- package/dist/powerlines/src/lib/entry.cjs +0 -12
- package/dist/powerlines/src/lib/entry.mjs +0 -14
- package/dist/powerlines/src/lib/utilities/bundle.cjs +0 -35
- package/dist/powerlines/src/lib/utilities/bundle.mjs +0 -34
- package/dist/powerlines/src/lib/utilities/resolve.cjs +0 -30
- package/dist/powerlines/src/lib/utilities/resolve.mjs +0 -29
- package/dist/powerlines/src/plugin-utils/paths.cjs +0 -1
- package/dist/powerlines/src/plugin-utils/paths.mjs +0 -3
- package/dist/powerlines/src/types/babel.d.mts +0 -2
- package/dist/powerlines/src/types/build.d.cts +0 -145
- package/dist/powerlines/src/types/build.d.mts +0 -147
- package/dist/powerlines/src/types/commands.d.cts +0 -8
- package/dist/powerlines/src/types/commands.d.mts +0 -9
- package/dist/powerlines/src/types/config.d.cts +0 -369
- package/dist/powerlines/src/types/config.d.mts +0 -369
- package/dist/powerlines/src/types/context.d.cts +0 -403
- package/dist/powerlines/src/types/context.d.mts +0 -405
- package/dist/powerlines/src/types/fs.d.cts +0 -486
- package/dist/powerlines/src/types/fs.d.mts +0 -486
- package/dist/powerlines/src/types/hooks.d.mts +0 -2
- package/dist/powerlines/src/types/plugin.d.cts +0 -231
- package/dist/powerlines/src/types/plugin.d.mts +0 -231
- package/dist/powerlines/src/types/resolved.d.cts +0 -81
- package/dist/powerlines/src/types/resolved.d.mts +0 -82
- package/dist/powerlines/src/types/tsconfig.d.cts +0 -69
- package/dist/powerlines/src/types/tsconfig.d.mts +0 -69
- package/dist/style-dictionary/file-header.cjs +0 -15
- package/dist/style-dictionary/file-header.mjs +0 -14
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/index.cjs
CHANGED
|
@@ -1,14 +1,211 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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');
|
|
5
31
|
let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
|
|
6
32
|
let __stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
|
|
7
33
|
let defu = require("defu");
|
|
8
|
-
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");
|
|
9
49
|
let style_dictionary = require("style-dictionary");
|
|
10
|
-
style_dictionary =
|
|
50
|
+
style_dictionary = __toESM(style_dictionary);
|
|
11
51
|
|
|
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
|
|
12
209
|
//#region src/index.ts
|
|
13
210
|
/**
|
|
14
211
|
* A Powerlines plugin to integrate style-dictionary for code generation.
|
|
@@ -27,11 +224,11 @@ const plugin = (options = {}) => {
|
|
|
27
224
|
},
|
|
28
225
|
async configResolved() {
|
|
29
226
|
this.styleDictionary = this.config.styleDictionary.instance ?? new style_dictionary.default(this.config.styleDictionary);
|
|
30
|
-
this.styleDictionary.registerFileHeader(
|
|
227
|
+
this.styleDictionary.registerFileHeader(fileHeader(this));
|
|
31
228
|
if (this.config.styleDictionary.customActions) {
|
|
32
229
|
let builder;
|
|
33
230
|
if ((0, __stryke_type_checks_is_function.isFunction)(this.config.styleDictionary.customActions)) builder = this.config.styleDictionary.customActions;
|
|
34
|
-
else builder = await
|
|
231
|
+
else builder = await resolve(this, this.config.styleDictionary.customActions);
|
|
35
232
|
Object.entries((0, __stryke_type_checks_is_function.isFunction)(builder) ? builder(this) : builder).forEach(([name, action]) => {
|
|
36
233
|
this.styleDictionary.registerAction({
|
|
37
234
|
...action,
|
|
@@ -42,7 +239,7 @@ const plugin = (options = {}) => {
|
|
|
42
239
|
if (this.config.styleDictionary.customFileHeaders) {
|
|
43
240
|
let builder;
|
|
44
241
|
if ((0, __stryke_type_checks_is_function.isFunction)(this.config.styleDictionary.customFileHeaders)) builder = this.config.styleDictionary.customFileHeaders;
|
|
45
|
-
else builder = await
|
|
242
|
+
else builder = await resolve(this, this.config.styleDictionary.customFileHeaders);
|
|
46
243
|
Object.entries((0, __stryke_type_checks_is_function.isFunction)(builder) ? builder(this) : builder).forEach(([name, fileHeader$1]) => {
|
|
47
244
|
this.styleDictionary.registerFileHeader({
|
|
48
245
|
name,
|
|
@@ -53,7 +250,7 @@ const plugin = (options = {}) => {
|
|
|
53
250
|
if (this.config.styleDictionary.customFilters) {
|
|
54
251
|
let builder;
|
|
55
252
|
if ((0, __stryke_type_checks_is_function.isFunction)(this.config.styleDictionary.customFilters)) builder = this.config.styleDictionary.customFilters;
|
|
56
|
-
else builder = await
|
|
253
|
+
else builder = await resolve(this, this.config.styleDictionary.customFilters);
|
|
57
254
|
Object.entries((0, __stryke_type_checks_is_function.isFunction)(builder) ? builder(this) : builder).forEach(([name, filter]) => {
|
|
58
255
|
this.styleDictionary.registerFilter({
|
|
59
256
|
...filter,
|
|
@@ -64,7 +261,7 @@ const plugin = (options = {}) => {
|
|
|
64
261
|
if (this.config.styleDictionary.customPreprocessors) {
|
|
65
262
|
let builder;
|
|
66
263
|
if ((0, __stryke_type_checks_is_function.isFunction)(this.config.styleDictionary.customPreprocessors)) builder = this.config.styleDictionary.customPreprocessors;
|
|
67
|
-
else builder = await
|
|
264
|
+
else builder = await resolve(this, this.config.styleDictionary.customPreprocessors);
|
|
68
265
|
Object.entries((0, __stryke_type_checks_is_function.isFunction)(builder) ? builder(this) : builder).forEach(([name, preprocessor]) => {
|
|
69
266
|
this.styleDictionary.registerPreprocessor({
|
|
70
267
|
...preprocessor,
|
|
@@ -75,7 +272,7 @@ const plugin = (options = {}) => {
|
|
|
75
272
|
if (this.config.styleDictionary.customParsers) {
|
|
76
273
|
let builder;
|
|
77
274
|
if ((0, __stryke_type_checks_is_function.isFunction)(this.config.styleDictionary.customParsers)) builder = this.config.styleDictionary.customParsers;
|
|
78
|
-
else builder = await
|
|
275
|
+
else builder = await resolve(this, this.config.styleDictionary.customParsers);
|
|
79
276
|
Object.entries((0, __stryke_type_checks_is_function.isFunction)(builder) ? builder(this) : builder).forEach(([name, parser]) => {
|
|
80
277
|
this.styleDictionary.registerParser({
|
|
81
278
|
...parser,
|
|
@@ -86,7 +283,7 @@ const plugin = (options = {}) => {
|
|
|
86
283
|
if (this.config.styleDictionary.customTransforms) {
|
|
87
284
|
let builder;
|
|
88
285
|
if ((0, __stryke_type_checks_is_function.isFunction)(this.config.styleDictionary.customTransforms)) builder = this.config.styleDictionary.customTransforms;
|
|
89
|
-
else builder = await
|
|
286
|
+
else builder = await resolve(this, this.config.styleDictionary.customTransforms);
|
|
90
287
|
Object.entries((0, __stryke_type_checks_is_function.isFunction)(builder) ? builder(this) : builder).forEach(([name, transform]) => {
|
|
91
288
|
this.styleDictionary.registerTransform({
|
|
92
289
|
...transform,
|
|
@@ -97,7 +294,7 @@ const plugin = (options = {}) => {
|
|
|
97
294
|
if (this.config.styleDictionary.customTransformGroups) {
|
|
98
295
|
let builder;
|
|
99
296
|
if ((0, __stryke_type_checks_is_function.isFunction)(this.config.styleDictionary.customTransformGroups)) builder = this.config.styleDictionary.customTransformGroups;
|
|
100
|
-
else builder = await
|
|
297
|
+
else builder = await resolve(this, this.config.styleDictionary.customTransformGroups);
|
|
101
298
|
Object.entries((0, __stryke_type_checks_is_function.isFunction)(builder) ? builder(this) : builder).forEach(([name, transformGroup]) => {
|
|
102
299
|
this.styleDictionary.registerTransformGroup({
|
|
103
300
|
name,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Plugin } from "./
|
|
2
|
-
import
|
|
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-DOb20y5l.cjs";
|
|
2
|
+
import "./index-CEgs-Dz2.cjs";
|
|
3
3
|
|
|
4
4
|
//#region src/index.d.ts
|
|
5
5
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Plugin } from "./
|
|
2
|
-
import
|
|
3
|
-
import "./types/index.mjs";
|
|
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-CXsNgnqK.mjs";
|
|
2
|
+
import "./index-BgAdqTbb.mjs";
|
|
4
3
|
|
|
5
4
|
//#region src/index.d.ts
|
|
6
5
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,181 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import "./plugin-C3MaN5jp.mjs";
|
|
2
|
+
import "./types-CTUnla4x.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";
|
|
6
20
|
import StyleDictionary from "style-dictionary";
|
|
7
21
|
|
|
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
|
|
8
179
|
//#region src/index.ts
|
|
9
180
|
/**
|
|
10
181
|
* A Powerlines plugin to integrate style-dictionary for code generation.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|