@powerlines/plugin-style-dictionary 0.3.513 → 0.3.515
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/helpers/resolve-hooks.cjs +92 -0
- package/dist/helpers/resolve-hooks.mjs +93 -0
- package/dist/helpers/resolve-hooks.mjs.map +1 -0
- package/dist/index.cjs +34 -93
- package/dist/index.d.cts +3 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +32 -92
- package/dist/types/plugin.d.cts +15 -15
- package/dist/types/plugin.d.cts.map +1 -1
- package/dist/types/plugin.d.mts +15 -15
- package/package.json +11 -9
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
const require_file_header = require('../style-dictionary/file-header.cjs');
|
|
2
|
+
let _stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
|
|
3
|
+
let powerlines_schema = require("powerlines/schema");
|
|
4
|
+
|
|
5
|
+
//#region src/helpers/resolve-hooks.ts
|
|
6
|
+
async function resolveBuilder(context, input) {
|
|
7
|
+
if ((0, _stryke_type_checks_is_function.isFunction)(input)) return input;
|
|
8
|
+
return (0, powerlines_schema.resolve)(context, input);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Resolves Powerlines Style Dictionary custom hook builders into a Style
|
|
12
|
+
* Dictionary {@link Hooks} config object for `@power-plant/style-dictionary`.
|
|
13
|
+
*/
|
|
14
|
+
async function resolveStyleDictionaryHooks(context, options) {
|
|
15
|
+
const hooks = {};
|
|
16
|
+
const defaultFileHeader = require_file_header.fileHeader(context);
|
|
17
|
+
hooks.fileHeaders = { [defaultFileHeader.name]: defaultFileHeader.fileHeader };
|
|
18
|
+
if (options.customActions) {
|
|
19
|
+
const builder = await resolveBuilder(context, options.customActions);
|
|
20
|
+
const actions = (0, _stryke_type_checks_is_function.isFunction)(builder) ? builder(context) : builder;
|
|
21
|
+
hooks.actions = {
|
|
22
|
+
...hooks.actions,
|
|
23
|
+
...Object.fromEntries(Object.entries(actions).map(([name, action]) => {
|
|
24
|
+
const { name: _actionName, ...rest } = action;
|
|
25
|
+
return [name, rest];
|
|
26
|
+
}))
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
if (options.customFileHeaders) {
|
|
30
|
+
const builder = await resolveBuilder(context, options.customFileHeaders);
|
|
31
|
+
const fileHeaders = (0, _stryke_type_checks_is_function.isFunction)(builder) ? builder(context) : builder;
|
|
32
|
+
hooks.fileHeaders = {
|
|
33
|
+
...hooks.fileHeaders,
|
|
34
|
+
...fileHeaders
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
if (options.customFilters) {
|
|
38
|
+
const builder = await resolveBuilder(context, options.customFilters);
|
|
39
|
+
const filters = (0, _stryke_type_checks_is_function.isFunction)(builder) ? builder(context) : builder;
|
|
40
|
+
hooks.filters = {
|
|
41
|
+
...hooks.filters,
|
|
42
|
+
...Object.fromEntries(Object.entries(filters).map(([name, filter]) => [name, filter.filter]))
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
if (options.customFormats) {
|
|
46
|
+
const builder = await resolveBuilder(context, options.customFormats);
|
|
47
|
+
const formats = (0, _stryke_type_checks_is_function.isFunction)(builder) ? builder(context) : builder;
|
|
48
|
+
hooks.formats = {
|
|
49
|
+
...hooks.formats,
|
|
50
|
+
...Object.fromEntries(Object.entries(formats).map(([name, format]) => [name, format.format]))
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
if (options.customPreprocessors) {
|
|
54
|
+
const builder = await resolveBuilder(context, options.customPreprocessors);
|
|
55
|
+
const preprocessors = (0, _stryke_type_checks_is_function.isFunction)(builder) ? builder(context) : builder;
|
|
56
|
+
hooks.preprocessors = {
|
|
57
|
+
...hooks.preprocessors,
|
|
58
|
+
...Object.fromEntries(Object.entries(preprocessors).map(([name, preprocessor]) => [name, preprocessor.preprocessor]))
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
if (options.customParsers) {
|
|
62
|
+
const builder = await resolveBuilder(context, options.customParsers);
|
|
63
|
+
const parsers = (0, _stryke_type_checks_is_function.isFunction)(builder) ? builder(context) : builder;
|
|
64
|
+
hooks.parsers = {
|
|
65
|
+
...hooks.parsers,
|
|
66
|
+
...Object.fromEntries(parsers.map(({ name, ...parser }) => [name, parser]))
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
if (options.customTransforms) {
|
|
70
|
+
const builder = await resolveBuilder(context, options.customTransforms);
|
|
71
|
+
const transforms = (0, _stryke_type_checks_is_function.isFunction)(builder) ? builder(context) : builder;
|
|
72
|
+
hooks.transforms = {
|
|
73
|
+
...hooks.transforms,
|
|
74
|
+
...Object.fromEntries(Object.entries(transforms).map(([name, transform]) => {
|
|
75
|
+
const { name: _transformName, ...rest } = transform;
|
|
76
|
+
return [name, rest];
|
|
77
|
+
}))
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
if (options.customTransformGroups) {
|
|
81
|
+
const builder = await resolveBuilder(context, options.customTransformGroups);
|
|
82
|
+
const transformGroups = (0, _stryke_type_checks_is_function.isFunction)(builder) ? builder(context) : builder;
|
|
83
|
+
hooks.transformGroups = {
|
|
84
|
+
...hooks.transformGroups,
|
|
85
|
+
...transformGroups
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
return hooks;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
//#endregion
|
|
92
|
+
exports.resolveStyleDictionaryHooks = resolveStyleDictionaryHooks;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { fileHeader } from "../style-dictionary/file-header.mjs";
|
|
2
|
+
import { isFunction } from "@stryke/type-checks/is-function";
|
|
3
|
+
import { resolve } from "powerlines/schema";
|
|
4
|
+
|
|
5
|
+
//#region src/helpers/resolve-hooks.ts
|
|
6
|
+
async function resolveBuilder(context, input) {
|
|
7
|
+
if (isFunction(input)) return input;
|
|
8
|
+
return resolve(context, input);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Resolves Powerlines Style Dictionary custom hook builders into a Style
|
|
12
|
+
* Dictionary {@link Hooks} config object for `@power-plant/style-dictionary`.
|
|
13
|
+
*/
|
|
14
|
+
async function resolveStyleDictionaryHooks(context, options) {
|
|
15
|
+
const hooks = {};
|
|
16
|
+
const defaultFileHeader = fileHeader(context);
|
|
17
|
+
hooks.fileHeaders = { [defaultFileHeader.name]: defaultFileHeader.fileHeader };
|
|
18
|
+
if (options.customActions) {
|
|
19
|
+
const builder = await resolveBuilder(context, options.customActions);
|
|
20
|
+
const actions = isFunction(builder) ? builder(context) : builder;
|
|
21
|
+
hooks.actions = {
|
|
22
|
+
...hooks.actions,
|
|
23
|
+
...Object.fromEntries(Object.entries(actions).map(([name, action]) => {
|
|
24
|
+
const { name: _actionName, ...rest } = action;
|
|
25
|
+
return [name, rest];
|
|
26
|
+
}))
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
if (options.customFileHeaders) {
|
|
30
|
+
const builder = await resolveBuilder(context, options.customFileHeaders);
|
|
31
|
+
const fileHeaders = isFunction(builder) ? builder(context) : builder;
|
|
32
|
+
hooks.fileHeaders = {
|
|
33
|
+
...hooks.fileHeaders,
|
|
34
|
+
...fileHeaders
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
if (options.customFilters) {
|
|
38
|
+
const builder = await resolveBuilder(context, options.customFilters);
|
|
39
|
+
const filters = isFunction(builder) ? builder(context) : builder;
|
|
40
|
+
hooks.filters = {
|
|
41
|
+
...hooks.filters,
|
|
42
|
+
...Object.fromEntries(Object.entries(filters).map(([name, filter]) => [name, filter.filter]))
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
if (options.customFormats) {
|
|
46
|
+
const builder = await resolveBuilder(context, options.customFormats);
|
|
47
|
+
const formats = isFunction(builder) ? builder(context) : builder;
|
|
48
|
+
hooks.formats = {
|
|
49
|
+
...hooks.formats,
|
|
50
|
+
...Object.fromEntries(Object.entries(formats).map(([name, format]) => [name, format.format]))
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
if (options.customPreprocessors) {
|
|
54
|
+
const builder = await resolveBuilder(context, options.customPreprocessors);
|
|
55
|
+
const preprocessors = isFunction(builder) ? builder(context) : builder;
|
|
56
|
+
hooks.preprocessors = {
|
|
57
|
+
...hooks.preprocessors,
|
|
58
|
+
...Object.fromEntries(Object.entries(preprocessors).map(([name, preprocessor]) => [name, preprocessor.preprocessor]))
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
if (options.customParsers) {
|
|
62
|
+
const builder = await resolveBuilder(context, options.customParsers);
|
|
63
|
+
const parsers = isFunction(builder) ? builder(context) : builder;
|
|
64
|
+
hooks.parsers = {
|
|
65
|
+
...hooks.parsers,
|
|
66
|
+
...Object.fromEntries(parsers.map(({ name, ...parser }) => [name, parser]))
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
if (options.customTransforms) {
|
|
70
|
+
const builder = await resolveBuilder(context, options.customTransforms);
|
|
71
|
+
const transforms = isFunction(builder) ? builder(context) : builder;
|
|
72
|
+
hooks.transforms = {
|
|
73
|
+
...hooks.transforms,
|
|
74
|
+
...Object.fromEntries(Object.entries(transforms).map(([name, transform]) => {
|
|
75
|
+
const { name: _transformName, ...rest } = transform;
|
|
76
|
+
return [name, rest];
|
|
77
|
+
}))
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
if (options.customTransformGroups) {
|
|
81
|
+
const builder = await resolveBuilder(context, options.customTransformGroups);
|
|
82
|
+
const transformGroups = isFunction(builder) ? builder(context) : builder;
|
|
83
|
+
hooks.transformGroups = {
|
|
84
|
+
...hooks.transformGroups,
|
|
85
|
+
...transformGroups
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
return hooks;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
//#endregion
|
|
92
|
+
export { resolveStyleDictionaryHooks };
|
|
93
|
+
//# sourceMappingURL=resolve-hooks.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-hooks.mjs","names":[],"sources":[],"mappings":""}
|
package/dist/index.cjs
CHANGED
|
@@ -1,121 +1,62 @@
|
|
|
1
1
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
2
|
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
const
|
|
4
|
-
let
|
|
3
|
+
const require_resolve_hooks = require('./helpers/resolve-hooks.cjs');
|
|
4
|
+
let _power_plant_style_dictionary = require("@power-plant/style-dictionary");
|
|
5
|
+
_power_plant_style_dictionary = require_runtime.__toESM(_power_plant_style_dictionary, 1);
|
|
6
|
+
let _powerlines_plugin_power_plant = require("@powerlines/plugin-power-plant");
|
|
7
|
+
_powerlines_plugin_power_plant = require_runtime.__toESM(_powerlines_plugin_power_plant, 1);
|
|
5
8
|
let _storm_software_config_tools_types = require("@storm-software/config-tools/types");
|
|
6
|
-
let _stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
|
|
7
9
|
let defu = require("defu");
|
|
8
10
|
defu = require_runtime.__toESM(defu, 1);
|
|
9
|
-
let style_dictionary = require("style-dictionary");
|
|
10
|
-
style_dictionary = require_runtime.__toESM(style_dictionary, 1);
|
|
11
11
|
|
|
12
12
|
//#region src/index.ts
|
|
13
13
|
/**
|
|
14
|
-
* A Powerlines plugin to integrate
|
|
14
|
+
* A Powerlines plugin to integrate Style Dictionary for code generation via Power Plant.
|
|
15
15
|
*
|
|
16
16
|
* @param options - The plugin options.
|
|
17
|
-
* @returns
|
|
17
|
+
* @returns Powerlines plugin instances.
|
|
18
18
|
*/
|
|
19
19
|
const plugin = (options = {}) => {
|
|
20
|
-
|
|
20
|
+
const generatorConfig = { ..._power_plant_style_dictionary.default };
|
|
21
|
+
return [(0, _powerlines_plugin_power_plant.default)(generatorConfig), {
|
|
21
22
|
name: "style-dictionary",
|
|
22
23
|
config() {
|
|
23
24
|
return { styleDictionary: (0, defu.default)(options, {
|
|
24
25
|
log: { verbosity: this.config.logLevel.general === _storm_software_config_tools_types.LogLevelLabel.TRACE ? "verbose" : this.config.logLevel.general === _storm_software_config_tools_types.LogLevelLabel.DEBUG ? "default" : "silent" },
|
|
25
|
-
|
|
26
|
+
usesDtcg: true
|
|
26
27
|
}) };
|
|
27
28
|
},
|
|
28
29
|
async configResolved() {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
name,
|
|
49
|
-
fileHeader
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
if (this.config.styleDictionary.customFilters) {
|
|
54
|
-
let builder;
|
|
55
|
-
if ((0, _stryke_type_checks_is_function.isFunction)(this.config.styleDictionary.customFilters)) builder = this.config.styleDictionary.customFilters;
|
|
56
|
-
else builder = await (0, _powerlines_schema.resolve)(this, this.config.styleDictionary.customFilters);
|
|
57
|
-
Object.entries((0, _stryke_type_checks_is_function.isFunction)(builder) ? builder(this) : builder).forEach(([name, filter]) => {
|
|
58
|
-
this.styleDictionary.registerFilter({
|
|
59
|
-
...filter,
|
|
60
|
-
name
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
if (this.config.styleDictionary.customPreprocessors) {
|
|
65
|
-
let builder;
|
|
66
|
-
if ((0, _stryke_type_checks_is_function.isFunction)(this.config.styleDictionary.customPreprocessors)) builder = this.config.styleDictionary.customPreprocessors;
|
|
67
|
-
else builder = await (0, _powerlines_schema.resolve)(this, this.config.styleDictionary.customPreprocessors);
|
|
68
|
-
Object.entries((0, _stryke_type_checks_is_function.isFunction)(builder) ? builder(this) : builder).forEach(([name, preprocessor]) => {
|
|
69
|
-
this.styleDictionary.registerPreprocessor({
|
|
70
|
-
...preprocessor,
|
|
71
|
-
name
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
if (this.config.styleDictionary.customParsers) {
|
|
76
|
-
let builder;
|
|
77
|
-
if ((0, _stryke_type_checks_is_function.isFunction)(this.config.styleDictionary.customParsers)) builder = this.config.styleDictionary.customParsers;
|
|
78
|
-
else builder = await (0, _powerlines_schema.resolve)(this, this.config.styleDictionary.customParsers);
|
|
79
|
-
Object.entries((0, _stryke_type_checks_is_function.isFunction)(builder) ? builder(this) : builder).forEach(([name, parser]) => {
|
|
80
|
-
this.styleDictionary.registerParser({
|
|
81
|
-
...parser,
|
|
82
|
-
name
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
if (this.config.styleDictionary.customTransforms) {
|
|
87
|
-
let builder;
|
|
88
|
-
if ((0, _stryke_type_checks_is_function.isFunction)(this.config.styleDictionary.customTransforms)) builder = this.config.styleDictionary.customTransforms;
|
|
89
|
-
else builder = await (0, _powerlines_schema.resolve)(this, this.config.styleDictionary.customTransforms);
|
|
90
|
-
Object.entries((0, _stryke_type_checks_is_function.isFunction)(builder) ? builder(this) : builder).forEach(([name, transform]) => {
|
|
91
|
-
this.styleDictionary.registerTransform({
|
|
92
|
-
...transform,
|
|
93
|
-
name
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
if (this.config.styleDictionary.customTransformGroups) {
|
|
98
|
-
let builder;
|
|
99
|
-
if ((0, _stryke_type_checks_is_function.isFunction)(this.config.styleDictionary.customTransformGroups)) builder = this.config.styleDictionary.customTransformGroups;
|
|
100
|
-
else builder = await (0, _powerlines_schema.resolve)(this, this.config.styleDictionary.customTransformGroups);
|
|
101
|
-
Object.entries((0, _stryke_type_checks_is_function.isFunction)(builder) ? builder(this) : builder).forEach(([name, transformGroup]) => {
|
|
102
|
-
this.styleDictionary.registerTransformGroup({
|
|
103
|
-
name,
|
|
104
|
-
transforms: transformGroup
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
async clean() {
|
|
110
|
-
await this.styleDictionary.cleanAllPlatforms({ cache: !this.config.skipCache });
|
|
30
|
+
const { skipBuild: _skipBuild, tokens, customActions, customFileHeaders, customFilters, customFormats, customPreprocessors, customParsers, customTransforms, customTransformGroups, hooks: existingHooks, ...styleDictionaryOptions } = this.config.styleDictionary;
|
|
31
|
+
const resolvedHooks = await require_resolve_hooks.resolveStyleDictionaryHooks(this, {
|
|
32
|
+
customActions,
|
|
33
|
+
customFileHeaders,
|
|
34
|
+
customFilters,
|
|
35
|
+
customFormats,
|
|
36
|
+
customPreprocessors,
|
|
37
|
+
customParsers,
|
|
38
|
+
customTransforms,
|
|
39
|
+
customTransformGroups
|
|
40
|
+
});
|
|
41
|
+
this.config.powerplant = {
|
|
42
|
+
...generatorConfig,
|
|
43
|
+
input: tokens ?? {}
|
|
44
|
+
};
|
|
45
|
+
this.powerplant.options = {
|
|
46
|
+
...styleDictionaryOptions,
|
|
47
|
+
hooks: (0, defu.default)(resolvedHooks, existingHooks)
|
|
48
|
+
};
|
|
111
49
|
},
|
|
112
50
|
prepare: {
|
|
113
51
|
order: "pre",
|
|
114
52
|
async handler() {
|
|
115
|
-
if (
|
|
53
|
+
if (this.config.styleDictionary.skipBuild) {
|
|
54
|
+
const noopExecute = async () => ({});
|
|
55
|
+
this.powerplant.execute = noopExecute;
|
|
56
|
+
}
|
|
116
57
|
}
|
|
117
58
|
}
|
|
118
|
-
};
|
|
59
|
+
}];
|
|
119
60
|
};
|
|
120
61
|
|
|
121
62
|
//#endregion
|
package/dist/index.d.cts
CHANGED
|
@@ -8,12 +8,12 @@ declare module "powerlines" {
|
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
* A Powerlines plugin to integrate
|
|
11
|
+
* A Powerlines plugin to integrate Style Dictionary for code generation via Power Plant.
|
|
12
12
|
*
|
|
13
13
|
* @param options - The plugin options.
|
|
14
|
-
* @returns
|
|
14
|
+
* @returns Powerlines plugin instances.
|
|
15
15
|
*/
|
|
16
|
-
declare const plugin: <TContext extends StyleDictionaryPluginContext = StyleDictionaryPluginContext>(options?: StyleDictionaryPluginOptions) => Plugin<TContext
|
|
16
|
+
declare const plugin: <TContext extends StyleDictionaryPluginContext = StyleDictionaryPluginContext>(options?: StyleDictionaryPluginOptions) => Plugin<TContext>[];
|
|
17
17
|
//#endregion
|
|
18
18
|
export { CustomActionsBuilder, CustomFileHeadersBuilder, CustomFiltersBuilder, CustomFormatsBuilder, CustomParsersBuilder, CustomPreprocessorsBuilder, CustomTransformGroupsBuilder, CustomTransformsBuilder, StyleDictionaryPluginContext, StyleDictionaryPluginEnvironmentConfig, StyleDictionaryPluginOptions, StyleDictionaryPluginResolvedConfig, StyleDictionaryPluginUserConfig, plugin as default, plugin };
|
|
19
19
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;YAmCY;IACR,kBAAkB;;;;;;;;;cAUT,SACX,iBAAiB,+BAA+B,8BAEhD,UAAS,iCACR,OAAO"}
|
package/dist/index.d.mts
CHANGED
|
@@ -8,12 +8,12 @@ declare module "powerlines" {
|
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
* A Powerlines plugin to integrate
|
|
11
|
+
* A Powerlines plugin to integrate Style Dictionary for code generation via Power Plant.
|
|
12
12
|
*
|
|
13
13
|
* @param options - The plugin options.
|
|
14
|
-
* @returns
|
|
14
|
+
* @returns Powerlines plugin instances.
|
|
15
15
|
*/
|
|
16
|
-
declare const plugin: <TContext extends StyleDictionaryPluginContext = StyleDictionaryPluginContext>(options?: StyleDictionaryPluginOptions) => Plugin<TContext
|
|
16
|
+
declare const plugin: <TContext extends StyleDictionaryPluginContext = StyleDictionaryPluginContext>(options?: StyleDictionaryPluginOptions) => Plugin<TContext>[];
|
|
17
17
|
//#endregion
|
|
18
18
|
export { CustomActionsBuilder, CustomFileHeadersBuilder, CustomFiltersBuilder, CustomFormatsBuilder, CustomParsersBuilder, CustomPreprocessorsBuilder, CustomTransformGroupsBuilder, CustomTransformsBuilder, StyleDictionaryPluginContext, StyleDictionaryPluginEnvironmentConfig, StyleDictionaryPluginOptions, StyleDictionaryPluginResolvedConfig, StyleDictionaryPluginUserConfig, plugin as default, plugin };
|
|
19
19
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -1,117 +1,57 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { resolveStyleDictionaryHooks } from "./helpers/resolve-hooks.mjs";
|
|
2
|
+
import styleDictionaryGenerator from "@power-plant/style-dictionary";
|
|
3
|
+
import powerPlant from "@powerlines/plugin-power-plant";
|
|
3
4
|
import { LogLevelLabel } from "@storm-software/config-tools/types";
|
|
4
|
-
import { isFunction } from "@stryke/type-checks/is-function";
|
|
5
5
|
import defu from "defu";
|
|
6
|
-
import StyleDictionary from "style-dictionary";
|
|
7
6
|
|
|
8
7
|
//#region src/index.ts
|
|
9
8
|
/**
|
|
10
|
-
* A Powerlines plugin to integrate
|
|
9
|
+
* A Powerlines plugin to integrate Style Dictionary for code generation via Power Plant.
|
|
11
10
|
*
|
|
12
11
|
* @param options - The plugin options.
|
|
13
|
-
* @returns
|
|
12
|
+
* @returns Powerlines plugin instances.
|
|
14
13
|
*/
|
|
15
14
|
const plugin = (options = {}) => {
|
|
16
|
-
|
|
15
|
+
const generatorConfig = { ...styleDictionaryGenerator };
|
|
16
|
+
return [powerPlant(generatorConfig), {
|
|
17
17
|
name: "style-dictionary",
|
|
18
18
|
config() {
|
|
19
19
|
return { styleDictionary: defu(options, {
|
|
20
20
|
log: { verbosity: this.config.logLevel.general === LogLevelLabel.TRACE ? "verbose" : this.config.logLevel.general === LogLevelLabel.DEBUG ? "default" : "silent" },
|
|
21
|
-
|
|
21
|
+
usesDtcg: true
|
|
22
22
|
}) };
|
|
23
23
|
},
|
|
24
24
|
async configResolved() {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
name,
|
|
45
|
-
fileHeader
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
if (this.config.styleDictionary.customFilters) {
|
|
50
|
-
let builder;
|
|
51
|
-
if (isFunction(this.config.styleDictionary.customFilters)) builder = this.config.styleDictionary.customFilters;
|
|
52
|
-
else builder = await resolve(this, this.config.styleDictionary.customFilters);
|
|
53
|
-
Object.entries(isFunction(builder) ? builder(this) : builder).forEach(([name, filter]) => {
|
|
54
|
-
this.styleDictionary.registerFilter({
|
|
55
|
-
...filter,
|
|
56
|
-
name
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
if (this.config.styleDictionary.customPreprocessors) {
|
|
61
|
-
let builder;
|
|
62
|
-
if (isFunction(this.config.styleDictionary.customPreprocessors)) builder = this.config.styleDictionary.customPreprocessors;
|
|
63
|
-
else builder = await resolve(this, this.config.styleDictionary.customPreprocessors);
|
|
64
|
-
Object.entries(isFunction(builder) ? builder(this) : builder).forEach(([name, preprocessor]) => {
|
|
65
|
-
this.styleDictionary.registerPreprocessor({
|
|
66
|
-
...preprocessor,
|
|
67
|
-
name
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
if (this.config.styleDictionary.customParsers) {
|
|
72
|
-
let builder;
|
|
73
|
-
if (isFunction(this.config.styleDictionary.customParsers)) builder = this.config.styleDictionary.customParsers;
|
|
74
|
-
else builder = await resolve(this, this.config.styleDictionary.customParsers);
|
|
75
|
-
Object.entries(isFunction(builder) ? builder(this) : builder).forEach(([name, parser]) => {
|
|
76
|
-
this.styleDictionary.registerParser({
|
|
77
|
-
...parser,
|
|
78
|
-
name
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
if (this.config.styleDictionary.customTransforms) {
|
|
83
|
-
let builder;
|
|
84
|
-
if (isFunction(this.config.styleDictionary.customTransforms)) builder = this.config.styleDictionary.customTransforms;
|
|
85
|
-
else builder = await resolve(this, this.config.styleDictionary.customTransforms);
|
|
86
|
-
Object.entries(isFunction(builder) ? builder(this) : builder).forEach(([name, transform]) => {
|
|
87
|
-
this.styleDictionary.registerTransform({
|
|
88
|
-
...transform,
|
|
89
|
-
name
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
if (this.config.styleDictionary.customTransformGroups) {
|
|
94
|
-
let builder;
|
|
95
|
-
if (isFunction(this.config.styleDictionary.customTransformGroups)) builder = this.config.styleDictionary.customTransformGroups;
|
|
96
|
-
else builder = await resolve(this, this.config.styleDictionary.customTransformGroups);
|
|
97
|
-
Object.entries(isFunction(builder) ? builder(this) : builder).forEach(([name, transformGroup]) => {
|
|
98
|
-
this.styleDictionary.registerTransformGroup({
|
|
99
|
-
name,
|
|
100
|
-
transforms: transformGroup
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
async clean() {
|
|
106
|
-
await this.styleDictionary.cleanAllPlatforms({ cache: !this.config.skipCache });
|
|
25
|
+
const { skipBuild: _skipBuild, tokens, customActions, customFileHeaders, customFilters, customFormats, customPreprocessors, customParsers, customTransforms, customTransformGroups, hooks: existingHooks, ...styleDictionaryOptions } = this.config.styleDictionary;
|
|
26
|
+
const resolvedHooks = await resolveStyleDictionaryHooks(this, {
|
|
27
|
+
customActions,
|
|
28
|
+
customFileHeaders,
|
|
29
|
+
customFilters,
|
|
30
|
+
customFormats,
|
|
31
|
+
customPreprocessors,
|
|
32
|
+
customParsers,
|
|
33
|
+
customTransforms,
|
|
34
|
+
customTransformGroups
|
|
35
|
+
});
|
|
36
|
+
this.config.powerplant = {
|
|
37
|
+
...generatorConfig,
|
|
38
|
+
input: tokens ?? {}
|
|
39
|
+
};
|
|
40
|
+
this.powerplant.options = {
|
|
41
|
+
...styleDictionaryOptions,
|
|
42
|
+
hooks: defu(resolvedHooks, existingHooks)
|
|
43
|
+
};
|
|
107
44
|
},
|
|
108
45
|
prepare: {
|
|
109
46
|
order: "pre",
|
|
110
47
|
async handler() {
|
|
111
|
-
if (
|
|
48
|
+
if (this.config.styleDictionary.skipBuild) {
|
|
49
|
+
const noopExecute = async () => ({});
|
|
50
|
+
this.powerplant.execute = noopExecute;
|
|
51
|
+
}
|
|
112
52
|
}
|
|
113
53
|
}
|
|
114
|
-
};
|
|
54
|
+
}];
|
|
115
55
|
};
|
|
116
56
|
|
|
117
57
|
//#endregion
|
package/dist/types/plugin.d.cts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { EnvironmentConfig,
|
|
1
|
+
import { EnvironmentConfig, ResolvedConfig, UserConfig } from "powerlines";
|
|
2
|
+
import { Options } from "@power-plant/style-dictionary";
|
|
3
|
+
import { PowerPlantPluginContext, PowerPlantPluginResolvedConfig } from "@powerlines/plugin-power-plant/types/plugin";
|
|
2
4
|
import { FileReferenceInput } from "@stryke/types/configuration";
|
|
3
|
-
import
|
|
4
|
-
import { Action, FileHeader, Filter, Format, Parser, PlatformConfig, Preprocessor, Transform } from "style-dictionary/types";
|
|
5
|
+
import { Action, DesignTokens, FileHeader, Filter, Format, Parser, PlatformConfig, Preprocessor, Transform } from "style-dictionary/types";
|
|
5
6
|
//#region src/types/plugin.d.ts
|
|
6
7
|
type StyleDictionaryExtensionBuilder<T> = (extensionContext: StyleDictionaryPluginContext) => Record<string, T>;
|
|
7
8
|
type CustomActionsBuilder = StyleDictionaryExtensionBuilder<Action>;
|
|
@@ -12,7 +13,15 @@ type CustomFileHeadersBuilder = StyleDictionaryExtensionBuilder<FileHeader>;
|
|
|
12
13
|
type CustomFiltersBuilder = StyleDictionaryExtensionBuilder<Filter>;
|
|
13
14
|
type CustomParsersBuilder = (extensionContext: StyleDictionaryPluginContext) => Parser[];
|
|
14
15
|
type CustomPreprocessorsBuilder = StyleDictionaryExtensionBuilder<Preprocessor>;
|
|
15
|
-
type StyleDictionaryPluginOptions =
|
|
16
|
+
type StyleDictionaryPluginOptions = Options & {
|
|
17
|
+
/**
|
|
18
|
+
* Design tokens passed to the Style Dictionary generator.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* When omitted, tokens are loaded from `source` / `include` paths in the
|
|
22
|
+
* Style Dictionary config.
|
|
23
|
+
*/
|
|
24
|
+
tokens?: DesignTokens;
|
|
16
25
|
/**
|
|
17
26
|
* Whether to skip the Style Dictionary build process.
|
|
18
27
|
*
|
|
@@ -78,26 +87,17 @@ type StyleDictionaryPluginOptions = Omit<Config, "platforms"> & {
|
|
|
78
87
|
* This value can be a {@link FileReferenceInput} pointing to a module export or an actual builder function.
|
|
79
88
|
*/
|
|
80
89
|
customTransforms?: FileReferenceInput | CustomTransformsBuilder;
|
|
81
|
-
/**
|
|
82
|
-
* An existing Style Dictionary instance to use.
|
|
83
|
-
*
|
|
84
|
-
* @remarks
|
|
85
|
-
* If provided, this instance will be used instead of creating a new one.
|
|
86
|
-
*/
|
|
87
|
-
instance?: StyleDictionary;
|
|
88
90
|
};
|
|
89
91
|
type StyleDictionaryPluginEnvironmentConfig = EnvironmentConfig & PlatformConfig;
|
|
90
92
|
type StyleDictionaryPluginUserConfig = UserConfig & {
|
|
91
93
|
styleDictionary?: StyleDictionaryPluginOptions;
|
|
92
94
|
environments?: Record<string, StyleDictionaryPluginEnvironmentConfig>;
|
|
93
95
|
};
|
|
94
|
-
type StyleDictionaryPluginResolvedConfig = ResolvedConfig & {
|
|
96
|
+
type StyleDictionaryPluginResolvedConfig = ResolvedConfig & PowerPlantPluginResolvedConfig<DesignTokens, Options> & {
|
|
95
97
|
styleDictionary: StyleDictionaryPluginOptions;
|
|
96
98
|
environments: Record<string, StyleDictionaryPluginEnvironmentConfig>;
|
|
97
99
|
};
|
|
98
|
-
type StyleDictionaryPluginContext<TResolvedConfig extends StyleDictionaryPluginResolvedConfig = StyleDictionaryPluginResolvedConfig> =
|
|
99
|
-
styleDictionary: StyleDictionary;
|
|
100
|
-
};
|
|
100
|
+
type StyleDictionaryPluginContext<TResolvedConfig extends StyleDictionaryPluginResolvedConfig = StyleDictionaryPluginResolvedConfig> = PowerPlantPluginContext<DesignTokens, Options, TResolvedConfig>;
|
|
101
101
|
//#endregion
|
|
102
102
|
export { CustomActionsBuilder, CustomFileHeadersBuilder, CustomFiltersBuilder, CustomFormatsBuilder, CustomParsersBuilder, CustomPreprocessorsBuilder, CustomTransformGroupsBuilder, CustomTransformsBuilder, StyleDictionaryPluginContext, StyleDictionaryPluginEnvironmentConfig, StyleDictionaryPluginOptions, StyleDictionaryPluginResolvedConfig, StyleDictionaryPluginUserConfig };
|
|
103
103
|
//# sourceMappingURL=plugin.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"mappings":";;;;;;KAqCK,gCAAgC,MACnC,kBAAkB,iCACf,eAAe;KAER,uBAAuB,gCAAgC;KACvD,0BACV,gCAAgC;KACtB,uBAAuB,gCAAgC;KACvD,+BAA+B;KAG/B,2BACV,gCAAgC;KACtB,uBAAuB,gCAAgC;KACvD,wBACV,kBAAkB,iCACf;KACO,6BACV,gCAAgC;KAEtB,+BAA+B;;;;;;;;EAQzC,SAAS;;;;;;;;;EAUT;;;;;;;EAQA,gBAAgB,qBAAqB;;;;;;;EAQrC,oBAAoB,qBAAqB;;;;;;;EAQzC,gBAAgB,qBAAqB;;;;;;;EAQrC,gBAAgB,qBAAqB;;;;;;;EAQrC,sBAAsB,qBAAqB;;;;;;;EAQ3C,gBAAgB,qBAAqB;;;;;;;EAQrC,wBAAwB,qBAAqB;;;;;;;EAQ7C,mBAAmB,qBAAqB;;KAG9B,yCAAyC,oBACnD;KAEU,kCAAkC;EAC5C,kBAAkB;EAClB,eAAe,eAAe;;KAGpB,sCAAsC,iBAChD,+BAA+B,cAAc;EAC3C,iBAAiB;EACjB,cAAc,eAAe;;KAGrB,6BACV,wBAAwB,sCACtB,uCACA,wBACF,cACA,SACA"}
|
package/dist/types/plugin.d.mts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { EnvironmentConfig,
|
|
1
|
+
import { Options } from "@power-plant/style-dictionary";
|
|
2
|
+
import { EnvironmentConfig, ResolvedConfig, UserConfig } from "powerlines";
|
|
3
|
+
import { PowerPlantPluginContext, PowerPlantPluginResolvedConfig } from "@powerlines/plugin-power-plant/types/plugin";
|
|
3
4
|
import { FileReferenceInput } from "@stryke/types/configuration";
|
|
4
|
-
import { Action, FileHeader, Filter, Format, Parser, PlatformConfig, Preprocessor, Transform } from "style-dictionary/types";
|
|
5
|
+
import { Action, DesignTokens, FileHeader, Filter, Format, Parser, PlatformConfig, Preprocessor, Transform } from "style-dictionary/types";
|
|
5
6
|
//#region src/types/plugin.d.ts
|
|
6
7
|
type StyleDictionaryExtensionBuilder<T> = (extensionContext: StyleDictionaryPluginContext) => Record<string, T>;
|
|
7
8
|
type CustomActionsBuilder = StyleDictionaryExtensionBuilder<Action>;
|
|
@@ -12,7 +13,15 @@ type CustomFileHeadersBuilder = StyleDictionaryExtensionBuilder<FileHeader>;
|
|
|
12
13
|
type CustomFiltersBuilder = StyleDictionaryExtensionBuilder<Filter>;
|
|
13
14
|
type CustomParsersBuilder = (extensionContext: StyleDictionaryPluginContext) => Parser[];
|
|
14
15
|
type CustomPreprocessorsBuilder = StyleDictionaryExtensionBuilder<Preprocessor>;
|
|
15
|
-
type StyleDictionaryPluginOptions =
|
|
16
|
+
type StyleDictionaryPluginOptions = Options & {
|
|
17
|
+
/**
|
|
18
|
+
* Design tokens passed to the Style Dictionary generator.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* When omitted, tokens are loaded from `source` / `include` paths in the
|
|
22
|
+
* Style Dictionary config.
|
|
23
|
+
*/
|
|
24
|
+
tokens?: DesignTokens;
|
|
16
25
|
/**
|
|
17
26
|
* Whether to skip the Style Dictionary build process.
|
|
18
27
|
*
|
|
@@ -78,26 +87,17 @@ type StyleDictionaryPluginOptions = Omit<Config, "platforms"> & {
|
|
|
78
87
|
* This value can be a {@link FileReferenceInput} pointing to a module export or an actual builder function.
|
|
79
88
|
*/
|
|
80
89
|
customTransforms?: FileReferenceInput | CustomTransformsBuilder;
|
|
81
|
-
/**
|
|
82
|
-
* An existing Style Dictionary instance to use.
|
|
83
|
-
*
|
|
84
|
-
* @remarks
|
|
85
|
-
* If provided, this instance will be used instead of creating a new one.
|
|
86
|
-
*/
|
|
87
|
-
instance?: StyleDictionary;
|
|
88
90
|
};
|
|
89
91
|
type StyleDictionaryPluginEnvironmentConfig = EnvironmentConfig & PlatformConfig;
|
|
90
92
|
type StyleDictionaryPluginUserConfig = UserConfig & {
|
|
91
93
|
styleDictionary?: StyleDictionaryPluginOptions;
|
|
92
94
|
environments?: Record<string, StyleDictionaryPluginEnvironmentConfig>;
|
|
93
95
|
};
|
|
94
|
-
type StyleDictionaryPluginResolvedConfig = ResolvedConfig & {
|
|
96
|
+
type StyleDictionaryPluginResolvedConfig = ResolvedConfig & PowerPlantPluginResolvedConfig<DesignTokens, Options> & {
|
|
95
97
|
styleDictionary: StyleDictionaryPluginOptions;
|
|
96
98
|
environments: Record<string, StyleDictionaryPluginEnvironmentConfig>;
|
|
97
99
|
};
|
|
98
|
-
type StyleDictionaryPluginContext<TResolvedConfig extends StyleDictionaryPluginResolvedConfig = StyleDictionaryPluginResolvedConfig> =
|
|
99
|
-
styleDictionary: StyleDictionary;
|
|
100
|
-
};
|
|
100
|
+
type StyleDictionaryPluginContext<TResolvedConfig extends StyleDictionaryPluginResolvedConfig = StyleDictionaryPluginResolvedConfig> = PowerPlantPluginContext<DesignTokens, Options, TResolvedConfig>;
|
|
101
101
|
//#endregion
|
|
102
102
|
export { CustomActionsBuilder, CustomFileHeadersBuilder, CustomFiltersBuilder, CustomFormatsBuilder, CustomParsersBuilder, CustomPreprocessorsBuilder, CustomTransformGroupsBuilder, CustomTransformsBuilder, StyleDictionaryPluginContext, StyleDictionaryPluginEnvironmentConfig, StyleDictionaryPluginOptions, StyleDictionaryPluginResolvedConfig, StyleDictionaryPluginUserConfig };
|
|
103
103
|
//# sourceMappingURL=plugin.d.mts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-style-dictionary",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.515",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A Powerlines plugin to generate project code with Style Dictionary.",
|
|
6
6
|
"keywords": [
|
|
@@ -95,19 +95,21 @@
|
|
|
95
95
|
"typings": "dist/index.d.mts",
|
|
96
96
|
"files": ["dist"],
|
|
97
97
|
"dependencies": {
|
|
98
|
-
"@
|
|
99
|
-
"@
|
|
100
|
-
"@
|
|
101
|
-
"@
|
|
102
|
-
"@stryke/
|
|
98
|
+
"@power-plant/core": "^0.0.23",
|
|
99
|
+
"@power-plant/style-dictionary": "^0.0.8",
|
|
100
|
+
"@powerlines/plugin-power-plant": "^0.1.2",
|
|
101
|
+
"@storm-software/config-tools": "^1.190.109",
|
|
102
|
+
"@stryke/string-format": "^0.17.38",
|
|
103
|
+
"@stryke/type-checks": "^0.6.29",
|
|
104
|
+
"@stryke/types": "^0.12.24",
|
|
103
105
|
"defu": "^6.1.7",
|
|
104
|
-
"powerlines": "^0.47.
|
|
106
|
+
"powerlines": "^0.47.146",
|
|
105
107
|
"style-dictionary": "^5.5.0"
|
|
106
108
|
},
|
|
107
109
|
"devDependencies": {
|
|
108
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
110
|
+
"@powerlines/plugin-plugin": "^0.12.558",
|
|
109
111
|
"@types/node": "^25.9.5"
|
|
110
112
|
},
|
|
111
113
|
"publishConfig": { "access": "public" },
|
|
112
|
-
"gitHead": "
|
|
114
|
+
"gitHead": "e86d6fab3bd4d2e2f9f6d05df8df7a07d399857e"
|
|
113
115
|
}
|