@powerlines/plugin-style-dictionary 0.3.17 → 0.3.19

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.
@@ -1 +1,29 @@
1
- var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));exports.__toESM=s;
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 +1,124 @@
1
- Object.defineProperty(exports,`__esModule`,{value:!0});const e=require(`./_virtual/rolldown_runtime.cjs`),t=require(`./powerlines/src/lib/utilities/resolve.cjs`),n=require(`./style-dictionary/file-header.cjs`);let r=require(`@storm-software/config-tools/types`),i=require(`@stryke/type-checks/is-function`),a=require(`defu`);a=e.__toESM(a);let o=require(`style-dictionary`);o=e.__toESM(o);const s=(e={})=>({name:`style-dictionary`,config(){return{styleDictionary:(0,a.default)(e,{log:{verbosity:this.config.logLevel===r.LogLevelLabel.DEBUG||this.config.logLevel===r.LogLevelLabel.TRACE?`verbose`:this.config.logLevel===null?`silent`:void 0},fileHeader:`powerlines/file-header`})}},async configResolved(){if(this.styleDictionary=this.config.styleDictionary.instance??new o.default(this.config.styleDictionary),this.styleDictionary.registerFileHeader(n.fileHeader(this)),this.config.styleDictionary.customActions){let e;e=(0,i.isFunction)(this.config.styleDictionary.customActions)?this.config.styleDictionary.customActions:await t.resolve(this,this.config.styleDictionary.customActions),Object.entries((0,i.isFunction)(e)?e(this):e).forEach(([e,t])=>{this.styleDictionary.registerAction({...t,name:e})})}if(this.config.styleDictionary.customFileHeaders){let e;e=(0,i.isFunction)(this.config.styleDictionary.customFileHeaders)?this.config.styleDictionary.customFileHeaders:await t.resolve(this,this.config.styleDictionary.customFileHeaders),Object.entries((0,i.isFunction)(e)?e(this):e).forEach(([e,t])=>{this.styleDictionary.registerFileHeader({name:e,fileHeader:t})})}if(this.config.styleDictionary.customFilters){let e;e=(0,i.isFunction)(this.config.styleDictionary.customFilters)?this.config.styleDictionary.customFilters:await t.resolve(this,this.config.styleDictionary.customFilters),Object.entries((0,i.isFunction)(e)?e(this):e).forEach(([e,t])=>{this.styleDictionary.registerFilter({...t,name:e})})}if(this.config.styleDictionary.customPreprocessors){let e;e=(0,i.isFunction)(this.config.styleDictionary.customPreprocessors)?this.config.styleDictionary.customPreprocessors:await t.resolve(this,this.config.styleDictionary.customPreprocessors),Object.entries((0,i.isFunction)(e)?e(this):e).forEach(([e,t])=>{this.styleDictionary.registerPreprocessor({...t,name:e})})}if(this.config.styleDictionary.customParsers){let e;e=(0,i.isFunction)(this.config.styleDictionary.customParsers)?this.config.styleDictionary.customParsers:await t.resolve(this,this.config.styleDictionary.customParsers),Object.entries((0,i.isFunction)(e)?e(this):e).forEach(([e,t])=>{this.styleDictionary.registerParser({...t,name:e})})}if(this.config.styleDictionary.customTransforms){let e;e=(0,i.isFunction)(this.config.styleDictionary.customTransforms)?this.config.styleDictionary.customTransforms:await t.resolve(this,this.config.styleDictionary.customTransforms),Object.entries((0,i.isFunction)(e)?e(this):e).forEach(([e,t])=>{this.styleDictionary.registerTransform({...t,name:e})})}if(this.config.styleDictionary.customTransformGroups){let e;e=(0,i.isFunction)(this.config.styleDictionary.customTransformGroups)?this.config.styleDictionary.customTransformGroups:await t.resolve(this,this.config.styleDictionary.customTransformGroups),Object.entries((0,i.isFunction)(e)?e(this):e).forEach(([e,t])=>{this.styleDictionary.registerTransformGroup({name:e,transforms:t})})}},async clean(){await this.styleDictionary.cleanAllPlatforms({cache:!this.config.skipCache})},prepare:{order:`pre`,async handler(){await this.styleDictionary.buildAllPlatforms({cache:!this.config.skipCache})}}});var c=s;exports.default=c,exports.plugin=s;
1
+ Object.defineProperty(exports, '__esModule', { value: true });
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');
5
+ 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
+ let defu = require("defu");
8
+ defu = require_rolldown_runtime.__toESM(defu);
9
+ let style_dictionary = require("style-dictionary");
10
+ style_dictionary = require_rolldown_runtime.__toESM(style_dictionary);
11
+
12
+ //#region src/index.ts
13
+ /**
14
+ * A Powerlines plugin to integrate style-dictionary for code generation.
15
+ *
16
+ * @param options - The plugin options.
17
+ * @returns A Powerlines plugin instance.
18
+ */
19
+ const plugin = (options = {}) => {
20
+ return {
21
+ name: "style-dictionary",
22
+ config() {
23
+ return { styleDictionary: (0, defu.default)(options, {
24
+ log: { verbosity: this.config.logLevel === __storm_software_config_tools_types.LogLevelLabel.DEBUG || this.config.logLevel === __storm_software_config_tools_types.LogLevelLabel.TRACE ? "verbose" : this.config.logLevel === null ? "silent" : void 0 },
25
+ fileHeader: "powerlines/file-header"
26
+ }) };
27
+ },
28
+ async configResolved() {
29
+ this.styleDictionary = this.config.styleDictionary.instance ?? new style_dictionary.default(this.config.styleDictionary);
30
+ this.styleDictionary.registerFileHeader(require_file_header.fileHeader(this));
31
+ if (this.config.styleDictionary.customActions) {
32
+ let builder;
33
+ if ((0, __stryke_type_checks_is_function.isFunction)(this.config.styleDictionary.customActions)) builder = this.config.styleDictionary.customActions;
34
+ else builder = await require_resolve.resolve(this, this.config.styleDictionary.customActions);
35
+ Object.entries((0, __stryke_type_checks_is_function.isFunction)(builder) ? builder(this) : builder).forEach(([name, action]) => {
36
+ this.styleDictionary.registerAction({
37
+ ...action,
38
+ name
39
+ });
40
+ });
41
+ }
42
+ if (this.config.styleDictionary.customFileHeaders) {
43
+ let builder;
44
+ if ((0, __stryke_type_checks_is_function.isFunction)(this.config.styleDictionary.customFileHeaders)) builder = this.config.styleDictionary.customFileHeaders;
45
+ else builder = await require_resolve.resolve(this, this.config.styleDictionary.customFileHeaders);
46
+ Object.entries((0, __stryke_type_checks_is_function.isFunction)(builder) ? builder(this) : builder).forEach(([name, fileHeader$1]) => {
47
+ this.styleDictionary.registerFileHeader({
48
+ name,
49
+ fileHeader: fileHeader$1
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 require_resolve.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 require_resolve.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 require_resolve.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 require_resolve.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 require_resolve.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 });
111
+ },
112
+ prepare: {
113
+ order: "pre",
114
+ async handler() {
115
+ await this.styleDictionary.buildAllPlatforms({ cache: !this.config.skipCache });
116
+ }
117
+ }
118
+ };
119
+ };
120
+ var src_default = plugin;
121
+
122
+ //#endregion
123
+ exports.default = src_default;
124
+ exports.plugin = plugin;
package/dist/index.mjs CHANGED
@@ -1 +1,119 @@
1
- import{resolve as e}from"./powerlines/src/lib/utilities/resolve.mjs";import{fileHeader as t}from"./style-dictionary/file-header.mjs";import{LogLevelLabel as n}from"@storm-software/config-tools/types";import{isFunction as r}from"@stryke/type-checks/is-function";import i from"defu";import a from"style-dictionary";const o=(o={})=>({name:`style-dictionary`,config(){return{styleDictionary:i(o,{log:{verbosity:this.config.logLevel===n.DEBUG||this.config.logLevel===n.TRACE?`verbose`:this.config.logLevel===null?`silent`:void 0},fileHeader:`powerlines/file-header`})}},async configResolved(){if(this.styleDictionary=this.config.styleDictionary.instance??new a(this.config.styleDictionary),this.styleDictionary.registerFileHeader(t(this)),this.config.styleDictionary.customActions){let t;t=r(this.config.styleDictionary.customActions)?this.config.styleDictionary.customActions:await e(this,this.config.styleDictionary.customActions),Object.entries(r(t)?t(this):t).forEach(([e,t])=>{this.styleDictionary.registerAction({...t,name:e})})}if(this.config.styleDictionary.customFileHeaders){let t;t=r(this.config.styleDictionary.customFileHeaders)?this.config.styleDictionary.customFileHeaders:await e(this,this.config.styleDictionary.customFileHeaders),Object.entries(r(t)?t(this):t).forEach(([e,t])=>{this.styleDictionary.registerFileHeader({name:e,fileHeader:t})})}if(this.config.styleDictionary.customFilters){let t;t=r(this.config.styleDictionary.customFilters)?this.config.styleDictionary.customFilters:await e(this,this.config.styleDictionary.customFilters),Object.entries(r(t)?t(this):t).forEach(([e,t])=>{this.styleDictionary.registerFilter({...t,name:e})})}if(this.config.styleDictionary.customPreprocessors){let t;t=r(this.config.styleDictionary.customPreprocessors)?this.config.styleDictionary.customPreprocessors:await e(this,this.config.styleDictionary.customPreprocessors),Object.entries(r(t)?t(this):t).forEach(([e,t])=>{this.styleDictionary.registerPreprocessor({...t,name:e})})}if(this.config.styleDictionary.customParsers){let t;t=r(this.config.styleDictionary.customParsers)?this.config.styleDictionary.customParsers:await e(this,this.config.styleDictionary.customParsers),Object.entries(r(t)?t(this):t).forEach(([e,t])=>{this.styleDictionary.registerParser({...t,name:e})})}if(this.config.styleDictionary.customTransforms){let t;t=r(this.config.styleDictionary.customTransforms)?this.config.styleDictionary.customTransforms:await e(this,this.config.styleDictionary.customTransforms),Object.entries(r(t)?t(this):t).forEach(([e,t])=>{this.styleDictionary.registerTransform({...t,name:e})})}if(this.config.styleDictionary.customTransformGroups){let t;t=r(this.config.styleDictionary.customTransformGroups)?this.config.styleDictionary.customTransformGroups:await e(this,this.config.styleDictionary.customTransformGroups),Object.entries(r(t)?t(this):t).forEach(([e,t])=>{this.styleDictionary.registerTransformGroup({name:e,transforms:t})})}},async clean(){await this.styleDictionary.cleanAllPlatforms({cache:!this.config.skipCache})},prepare:{order:`pre`,async handler(){await this.styleDictionary.buildAllPlatforms({cache:!this.config.skipCache})}}});var s=o;export{s as default,o as plugin};
1
+ import { resolve } from "./powerlines/src/lib/utilities/resolve.mjs";
2
+ import { fileHeader } from "./style-dictionary/file-header.mjs";
3
+ import { LogLevelLabel } from "@storm-software/config-tools/types";
4
+ import { isFunction } from "@stryke/type-checks/is-function";
5
+ import defu from "defu";
6
+ import StyleDictionary from "style-dictionary";
7
+
8
+ //#region src/index.ts
9
+ /**
10
+ * A Powerlines plugin to integrate style-dictionary for code generation.
11
+ *
12
+ * @param options - The plugin options.
13
+ * @returns A Powerlines plugin instance.
14
+ */
15
+ const plugin = (options = {}) => {
16
+ return {
17
+ name: "style-dictionary",
18
+ config() {
19
+ return { styleDictionary: defu(options, {
20
+ log: { verbosity: this.config.logLevel === LogLevelLabel.DEBUG || this.config.logLevel === LogLevelLabel.TRACE ? "verbose" : this.config.logLevel === null ? "silent" : void 0 },
21
+ fileHeader: "powerlines/file-header"
22
+ }) };
23
+ },
24
+ async configResolved() {
25
+ this.styleDictionary = this.config.styleDictionary.instance ?? new StyleDictionary(this.config.styleDictionary);
26
+ this.styleDictionary.registerFileHeader(fileHeader(this));
27
+ if (this.config.styleDictionary.customActions) {
28
+ let builder;
29
+ if (isFunction(this.config.styleDictionary.customActions)) builder = this.config.styleDictionary.customActions;
30
+ else builder = await resolve(this, this.config.styleDictionary.customActions);
31
+ Object.entries(isFunction(builder) ? builder(this) : builder).forEach(([name, action]) => {
32
+ this.styleDictionary.registerAction({
33
+ ...action,
34
+ name
35
+ });
36
+ });
37
+ }
38
+ if (this.config.styleDictionary.customFileHeaders) {
39
+ let builder;
40
+ if (isFunction(this.config.styleDictionary.customFileHeaders)) builder = this.config.styleDictionary.customFileHeaders;
41
+ else builder = await resolve(this, this.config.styleDictionary.customFileHeaders);
42
+ Object.entries(isFunction(builder) ? builder(this) : builder).forEach(([name, fileHeader$1]) => {
43
+ this.styleDictionary.registerFileHeader({
44
+ name,
45
+ fileHeader: fileHeader$1
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 });
107
+ },
108
+ prepare: {
109
+ order: "pre",
110
+ async handler() {
111
+ await this.styleDictionary.buildAllPlatforms({ cache: !this.config.skipCache });
112
+ }
113
+ }
114
+ };
115
+ };
116
+ var src_default = plugin;
117
+
118
+ //#endregion
119
+ export { src_default as default, plugin };
@@ -1,14 +1,102 @@
1
- const e=require(`../../../../_virtual/rolldown_runtime.cjs`);require(`../entry.cjs`);let t=require(`defu`);t=e.__toESM(t);let n=require(`@stryke/helpers/omit`),r=require(`@stryke/path/join-paths`);require(`@stryke/path/replace`);let i=require(`@stryke/string-format/camel-case`);require(`@stryke/type-checks/is-string`);const a={target:`esnext`,platform:`neutral`,format:`esm`,write:!0,minify:!0,sourcemap:!1,bundle:!0,treeShaking:!0,keepNames:!0,splitting:!0,logLevel:`silent`};function o(e){let o=e.config.build.override.inject??e.config.build.inject;return o&&Object.keys(o).length>0&&e.fs.writeSync((0,r.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.artifactsPath,`inject-shim.js`),Object.entries(o).map(([e,t])=>{if(t)if(Array.isArray(t)){if((0,i.camelCase)(e)!==e){if(t.length===1)return`
2
- import ${(0,i.camelCase)(e)} from "${t[0]}";
3
- export { ${(0,i.camelCase)(e)} as "${e}" }`;if(t.length>1)return`
4
- import ${t[1]===`*`?`* as ${(0,i.camelCase)(e)}`:`{ ${t[1]} as ${(0,i.camelCase)(e)} }`} from "${t[0]}";
5
- export { ${(0,i.camelCase)(e)} as "${e}" }`}else if(t.length===1)return`
6
- import ${e} from "${t[0]}";
7
- export { ${e} };`;else if(t.length>1)return`
8
- import ${t[1]===`*`?`* as ${e}`:`{ ${t[1]} as ${e} }`} from "${t[0]}";
9
- export { ${e} };`}else if((0,i.camelCase)(e)!==e)return`
10
- import ${(0,i.camelCase)(e)} from "${t[0]}";
11
- export { ${(0,i.camelCase)(e)} as "${e}" }`;else return`
12
- import ${e} from "${t}";
13
- export { ${e} };`;return``}).join(`
14
- `)),(0,t.default)({alias:e.builtins.reduce((t,n)=>{if(!t[n]){let r=e.fs.ids[n];r&&(t[n]=r)}return t},e.config.build.alias?Array.isArray(e.config.build.alias)?e.config.build.alias.reduce((e,t)=>(e[t.find.toString()]||(e[t.find.toString()]=t.replacement),e),{}):e.config.build.alias:{}),inject:o&&Object.keys(o).length>0?[(0,r.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,e.artifactsPath,`inject-shim.js`)]:void 0},e.config.build.variant===`esbuild`?(0,n.omit)(e.config.build.override,[`alias`,`inject`,`external`,`noExternal`,`skipNodeModulesBundle`,`extensions`]):{},e.config.build.variant===`esbuild`?(0,n.omit)(e.config.build,[`alias`,`inject`,`external`,`noExternal`,`skipNodeModulesBundle`,`extensions`,`variant`,`override`]):{},{mainFields:e.config.build.mainFields,conditions:e.config.build.conditions,define:e.config.build.define,resolveExtensions:e.config.build.extensions,packages:e.config.build.skipNodeModulesBundle?`external`:e.config.build.variant===`esbuild`?e.config.build.packages:void 0,format:Array.isArray(e.config.output.format)?e.config.output.format[0]:e.config.output.format,platform:e.config.build.platform,treeShaking:!!e.config.build?.treeshake||e.config.build?.treeShaking,outdir:e.config.output.buildPath,tsconfig:e.tsconfig.tsconfigFilePath,minify:e.config.mode!==`development`,metafile:e.config.mode===`development`,sourcemap:e.config.mode===`development`},a)}exports.extractESBuildConfig=o;
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;
@@ -1,14 +1,100 @@
1
- import"../entry.mjs";import e from"defu";import{omit as t}from"@stryke/helpers/omit";import{joinPaths as n}from"@stryke/path/join-paths";import"@stryke/path/replace";import{camelCase as r}from"@stryke/string-format/camel-case";import"@stryke/type-checks/is-string";const i={target:`esnext`,platform:`neutral`,format:`esm`,write:!0,minify:!0,sourcemap:!1,bundle:!0,treeShaking:!0,keepNames:!0,splitting:!0,logLevel:`silent`};function a(a){let o=a.config.build.override.inject??a.config.build.inject;return o&&Object.keys(o).length>0&&a.fs.writeSync(n(a.workspaceConfig.workspaceRoot,a.config.projectRoot,a.artifactsPath,`inject-shim.js`),Object.entries(o).map(([e,t])=>{if(t)if(Array.isArray(t)){if(r(e)!==e){if(t.length===1)return`
2
- import ${r(e)} from "${t[0]}";
3
- export { ${r(e)} as "${e}" }`;if(t.length>1)return`
4
- import ${t[1]===`*`?`* as ${r(e)}`:`{ ${t[1]} as ${r(e)} }`} from "${t[0]}";
5
- export { ${r(e)} as "${e}" }`}else if(t.length===1)return`
6
- import ${e} from "${t[0]}";
7
- export { ${e} };`;else if(t.length>1)return`
8
- import ${t[1]===`*`?`* as ${e}`:`{ ${t[1]} as ${e} }`} from "${t[0]}";
9
- export { ${e} };`}else if(r(e)!==e)return`
10
- import ${r(e)} from "${t[0]}";
11
- export { ${r(e)} as "${e}" }`;else return`
12
- import ${e} from "${t}";
13
- export { ${e} };`;return``}).join(`
14
- `)),e({alias:a.builtins.reduce((e,t)=>{if(!e[t]){let n=a.fs.ids[t];n&&(e[t]=n)}return e},a.config.build.alias?Array.isArray(a.config.build.alias)?a.config.build.alias.reduce((e,t)=>(e[t.find.toString()]||(e[t.find.toString()]=t.replacement),e),{}):a.config.build.alias:{}),inject:o&&Object.keys(o).length>0?[n(a.workspaceConfig.workspaceRoot,a.config.projectRoot,a.artifactsPath,`inject-shim.js`)]:void 0},a.config.build.variant===`esbuild`?t(a.config.build.override,[`alias`,`inject`,`external`,`noExternal`,`skipNodeModulesBundle`,`extensions`]):{},a.config.build.variant===`esbuild`?t(a.config.build,[`alias`,`inject`,`external`,`noExternal`,`skipNodeModulesBundle`,`extensions`,`variant`,`override`]):{},{mainFields:a.config.build.mainFields,conditions:a.config.build.conditions,define:a.config.build.define,resolveExtensions:a.config.build.extensions,packages:a.config.build.skipNodeModulesBundle?`external`:a.config.build.variant===`esbuild`?a.config.build.packages:void 0,format:Array.isArray(a.config.output.format)?a.config.output.format[0]:a.config.output.format,platform:a.config.build.platform,treeShaking:!!a.config.build?.treeshake||a.config.build?.treeShaking,outdir:a.config.output.buildPath,tsconfig:a.tsconfig.tsconfigFilePath,minify:a.config.mode!==`development`,metafile:a.config.mode===`development`,sourcemap:a.config.mode===`development`},i)}export{a as extractESBuildConfig};
1
+ import "../entry.mjs";
2
+ import defu from "defu";
3
+ import { omit } from "@stryke/helpers/omit";
4
+ import { joinPaths } from "@stryke/path/join-paths";
5
+ import "@stryke/path/replace";
6
+ import { camelCase } from "@stryke/string-format/camel-case";
7
+ import "@stryke/type-checks/is-string";
8
+
9
+ //#region ../powerlines/src/lib/build/esbuild.ts
10
+ const DEFAULT_ESBUILD_CONFIG = {
11
+ target: "esnext",
12
+ platform: "neutral",
13
+ format: "esm",
14
+ write: true,
15
+ minify: true,
16
+ sourcemap: false,
17
+ bundle: true,
18
+ treeShaking: true,
19
+ keepNames: true,
20
+ splitting: true,
21
+ logLevel: "silent"
22
+ };
23
+ /**
24
+ * Resolves the esbuild options.
25
+ *
26
+ * @param context - The build context.
27
+ * @returns The resolved esbuild options.
28
+ */
29
+ function extractESBuildConfig(context) {
30
+ const inject = context.config.build.override.inject ?? context.config.build.inject;
31
+ 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]) => {
32
+ if (value) if (Array.isArray(value)) {
33
+ if (camelCase(key) !== key) {
34
+ if (value.length === 1) return `
35
+ import ${camelCase(key)} from "${value[0]}";
36
+ export { ${camelCase(key)} as "${key}" }`;
37
+ else if (value.length > 1) return `
38
+ import ${value[1] === "*" ? `* as ${camelCase(key)}` : `{ ${value[1]} as ${camelCase(key)} }`} from "${value[0]}";
39
+ export { ${camelCase(key)} as "${key}" }`;
40
+ } else if (value.length === 1) return `
41
+ import ${key} from "${value[0]}";
42
+ export { ${key} };`;
43
+ else if (value.length > 1) return `
44
+ import ${value[1] === "*" ? `* as ${key}` : `{ ${value[1]} as ${key} }`} from "${value[0]}";
45
+ export { ${key} };`;
46
+ } else if (camelCase(key) !== key) return `
47
+ import ${camelCase(key)} from "${value[0]}";
48
+ export { ${camelCase(key)} as "${key}" }`;
49
+ else return `
50
+ import ${key} from "${value}";
51
+ export { ${key} };`;
52
+ return "";
53
+ }).join("\n"));
54
+ return defu({
55
+ alias: context.builtins.reduce((ret, id) => {
56
+ if (!ret[id]) {
57
+ const path = context.fs.ids[id];
58
+ if (path) ret[id] = path;
59
+ }
60
+ return ret;
61
+ }, context.config.build.alias ? Array.isArray(context.config.build.alias) ? context.config.build.alias.reduce((ret, alias) => {
62
+ if (!ret[alias.find.toString()]) ret[alias.find.toString()] = alias.replacement;
63
+ return ret;
64
+ }, {}) : context.config.build.alias : {}),
65
+ inject: inject && Object.keys(inject).length > 0 ? [joinPaths(context.workspaceConfig.workspaceRoot, context.config.projectRoot, context.artifactsPath, "inject-shim.js")] : void 0
66
+ }, context.config.build.variant === "esbuild" ? omit(context.config.build.override, [
67
+ "alias",
68
+ "inject",
69
+ "external",
70
+ "noExternal",
71
+ "skipNodeModulesBundle",
72
+ "extensions"
73
+ ]) : {}, context.config.build.variant === "esbuild" ? omit(context.config.build, [
74
+ "alias",
75
+ "inject",
76
+ "external",
77
+ "noExternal",
78
+ "skipNodeModulesBundle",
79
+ "extensions",
80
+ "variant",
81
+ "override"
82
+ ]) : {}, {
83
+ mainFields: context.config.build.mainFields,
84
+ conditions: context.config.build.conditions,
85
+ define: context.config.build.define,
86
+ resolveExtensions: context.config.build.extensions,
87
+ packages: context.config.build.skipNodeModulesBundle ? "external" : context.config.build.variant === "esbuild" ? context.config.build.packages : void 0,
88
+ format: Array.isArray(context.config.output.format) ? context.config.output.format[0] : context.config.output.format,
89
+ platform: context.config.build.platform,
90
+ treeShaking: Boolean(context.config.build?.treeshake) || context.config.build?.treeShaking,
91
+ outdir: context.config.output.buildPath,
92
+ tsconfig: context.tsconfig.tsconfigFilePath,
93
+ minify: context.config.mode !== "development",
94
+ metafile: context.config.mode === "development",
95
+ sourcemap: context.config.mode === "development"
96
+ }, DEFAULT_ESBUILD_CONFIG);
97
+ }
98
+
99
+ //#endregion
100
+ export { extractESBuildConfig };
@@ -1 +1,12 @@
1
- require(`../plugin-utils/paths.cjs`);let e=require(`@stryke/convert/parse-type-definition`),t=require(`@stryke/type-checks/is-set-string`),n=require(`@stryke/path/join-paths`);require(`@stryke/path/replace`),require(`@stryke/type-checks/is-string`),require(`@stryke/convert/to-array`),require(`@stryke/fs/is-file`),require(`@stryke/fs/list-files`),require(`@stryke/hash/murmurhash`),require(`@stryke/helpers/get-unique`),require(`@stryke/path/append`);
1
+ require('../plugin-utils/paths.cjs');
2
+ let __stryke_convert_parse_type_definition = require("@stryke/convert/parse-type-definition");
3
+ let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
4
+ let __stryke_path_join_paths = require("@stryke/path/join-paths");
5
+ require("@stryke/path/replace");
6
+ require("@stryke/type-checks/is-string");
7
+ require("@stryke/convert/to-array");
8
+ require("@stryke/fs/is-file");
9
+ require("@stryke/fs/list-files");
10
+ require("@stryke/hash/murmurhash");
11
+ require("@stryke/helpers/get-unique");
12
+ require("@stryke/path/append");
@@ -1 +1,14 @@
1
- import"../plugin-utils/paths.mjs";import{parseTypeDefinition as e}from"@stryke/convert/parse-type-definition";import{isSetString as t}from"@stryke/type-checks/is-set-string";import{joinPaths as n}from"@stryke/path/join-paths";import"@stryke/path/replace";import"@stryke/type-checks/is-string";import"@stryke/convert/to-array";import"@stryke/fs/is-file";import"@stryke/fs/list-files";import"@stryke/hash/murmurhash";import"@stryke/helpers/get-unique";import"@stryke/path/append";export{};
1
+ import "../plugin-utils/paths.mjs";
2
+ import { parseTypeDefinition } from "@stryke/convert/parse-type-definition";
3
+ import { isSetString } from "@stryke/type-checks/is-set-string";
4
+ import { joinPaths } from "@stryke/path/join-paths";
5
+ import "@stryke/path/replace";
6
+ import "@stryke/type-checks/is-string";
7
+ import "@stryke/convert/to-array";
8
+ import "@stryke/fs/is-file";
9
+ import "@stryke/fs/list-files";
10
+ import "@stryke/hash/murmurhash";
11
+ import "@stryke/helpers/get-unique";
12
+ import "@stryke/path/append";
13
+
14
+ export { };
@@ -1 +1,35 @@
1
- const e=require(`../../../../_virtual/rolldown_runtime.cjs`),t=require(`../build/esbuild.cjs`);let n=require(`@storm-software/config-tools/types`),r=require(`esbuild`);async function i(e,i,a={}){let o=await e.fs.resolve(i);if(!o||!e.fs.existsSync(o))throw Error(`Module not found: "${i}". Please check the path and try again.`);let s=await(0,r.build)({...t.extractESBuildConfig(e),entryPoints:[o],write:!1,sourcemap:!1,splitting:!1,treeShaking:!1,bundle:!0,...a});if(s.errors.length>0)throw Error(`Failed to transpile ${i}: ${s.errors.map(e=>e.text).join(`, `)}`);if(s.warnings.length>0&&e.log(n.LogLevelLabel.WARN,`Warnings while transpiling ${i}: ${s.warnings.map(e=>e.text).join(`, `)}`),!s.outputFiles||s.outputFiles.filter(Boolean).length===0)throw Error(`No output files generated for ${i}. Please check the configuration and try again.`);return s.outputFiles.filter(Boolean)[0]}exports.bundle=i;
1
+ const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
2
+ const require_esbuild = require('../build/esbuild.cjs');
3
+ let __storm_software_config_tools_types = require("@storm-software/config-tools/types");
4
+ let esbuild = require("esbuild");
5
+
6
+ //#region ../powerlines/src/lib/utilities/bundle.ts
7
+ /**
8
+ * Bundle a type definition to a module.
9
+ *
10
+ * @param context - The context object containing the environment paths.
11
+ * @param file - The file path to bundle.
12
+ * @param overrides - Optional overrides for the ESBuild configuration.
13
+ * @returns A promise that resolves to the bundled module.
14
+ */
15
+ async function bundle(context, file, overrides = {}) {
16
+ const path = await context.fs.resolve(file);
17
+ if (!path || !context.fs.existsSync(path)) throw new Error(`Module not found: "${file}". Please check the path and try again.`);
18
+ const result = await (0, esbuild.build)({
19
+ ...require_esbuild.extractESBuildConfig(context),
20
+ entryPoints: [path],
21
+ write: false,
22
+ sourcemap: false,
23
+ splitting: false,
24
+ treeShaking: false,
25
+ bundle: true,
26
+ ...overrides
27
+ });
28
+ if (result.errors.length > 0) throw new Error(`Failed to transpile ${file}: ${result.errors.map((error) => error.text).join(", ")}`);
29
+ 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(", ")}`);
30
+ 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.`);
31
+ return result.outputFiles.filter(Boolean)[0];
32
+ }
33
+
34
+ //#endregion
35
+ exports.bundle = bundle;
@@ -1 +1,34 @@
1
- import{extractESBuildConfig as e}from"../build/esbuild.mjs";import{LogLevelLabel as t}from"@storm-software/config-tools/types";import{build as n}from"esbuild";async function r(r,i,a={}){let o=await r.fs.resolve(i);if(!o||!r.fs.existsSync(o))throw Error(`Module not found: "${i}". Please check the path and try again.`);let s=await n({...e(r),entryPoints:[o],write:!1,sourcemap:!1,splitting:!1,treeShaking:!1,bundle:!0,...a});if(s.errors.length>0)throw Error(`Failed to transpile ${i}: ${s.errors.map(e=>e.text).join(`, `)}`);if(s.warnings.length>0&&r.log(t.WARN,`Warnings while transpiling ${i}: ${s.warnings.map(e=>e.text).join(`, `)}`),!s.outputFiles||s.outputFiles.filter(Boolean).length===0)throw Error(`No output files generated for ${i}. Please check the configuration and try again.`);return s.outputFiles.filter(Boolean)[0]}export{r as bundle};
1
+ import { extractESBuildConfig } from "../build/esbuild.mjs";
2
+ import { LogLevelLabel } from "@storm-software/config-tools/types";
3
+ import { build } from "esbuild";
4
+
5
+ //#region ../powerlines/src/lib/utilities/bundle.ts
6
+ /**
7
+ * Bundle a type definition to a module.
8
+ *
9
+ * @param context - The context object containing the environment paths.
10
+ * @param file - The file path to bundle.
11
+ * @param overrides - Optional overrides for the ESBuild configuration.
12
+ * @returns A promise that resolves to the bundled module.
13
+ */
14
+ async function bundle(context, file, overrides = {}) {
15
+ const path = await context.fs.resolve(file);
16
+ if (!path || !context.fs.existsSync(path)) throw new Error(`Module not found: "${file}". Please check the path and try again.`);
17
+ const result = await build({
18
+ ...extractESBuildConfig(context),
19
+ entryPoints: [path],
20
+ write: false,
21
+ sourcemap: false,
22
+ splitting: false,
23
+ treeShaking: false,
24
+ bundle: true,
25
+ ...overrides
26
+ });
27
+ if (result.errors.length > 0) throw new Error(`Failed to transpile ${file}: ${result.errors.map((error) => error.text).join(", ")}`);
28
+ if (result.warnings.length > 0) context.log(LogLevelLabel.WARN, `Warnings while transpiling ${file}: ${result.warnings.map((warning) => warning.text).join(", ")}`);
29
+ 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.`);
30
+ return result.outputFiles.filter(Boolean)[0];
31
+ }
32
+
33
+ //#endregion
34
+ export { bundle };
@@ -1 +1,30 @@
1
- const e=require(`../../../../_virtual/rolldown_runtime.cjs`),t=require(`./bundle.cjs`);let n=require(`@stryke/convert/parse-type-definition`),r=require(`@stryke/type-checks/is-set-string`);async function i(e,i,a={}){let o;o=(0,r.isSetString)(i)?(0,n.parseTypeDefinition)(i):i;let s=await t.bundle(e,o.file,a),c=await e.resolver.evalModule(s.text,{filename:s.path,forceTranspile:!0}),l=o.name;return l||=`default`,c[l]??c[`__Ω${l}`]}exports.resolve=i;
1
+ const require_rolldown_runtime = require('../../../../_virtual/rolldown_runtime.cjs');
2
+ const require_bundle = require('./bundle.cjs');
3
+ let __stryke_convert_parse_type_definition = require("@stryke/convert/parse-type-definition");
4
+ let __stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
5
+
6
+ //#region ../powerlines/src/lib/utilities/resolve.ts
7
+ /**
8
+ * Compiles a type definition to a module.
9
+ *
10
+ * @param context - The context object containing the environment paths.
11
+ * @param type - The type definition to compile. This can be either a string or a {@link TypeDefinition} object.
12
+ * @param overrides - Optional overrides for the ESBuild configuration.
13
+ * @returns A promise that resolves to the compiled module.
14
+ */
15
+ async function resolve(context, type, overrides = {}) {
16
+ let typeDefinition;
17
+ if ((0, __stryke_type_checks_is_set_string.isSetString)(type)) typeDefinition = (0, __stryke_convert_parse_type_definition.parseTypeDefinition)(type);
18
+ else typeDefinition = type;
19
+ const result = await require_bundle.bundle(context, typeDefinition.file, overrides);
20
+ const resolved = await context.resolver.evalModule(result.text, {
21
+ filename: result.path,
22
+ forceTranspile: true
23
+ });
24
+ let exportName = typeDefinition.name;
25
+ if (!exportName) exportName = "default";
26
+ return resolved[exportName] ?? resolved[`__Ω${exportName}`];
27
+ }
28
+
29
+ //#endregion
30
+ exports.resolve = resolve;
@@ -1 +1,29 @@
1
- import{bundle as e}from"./bundle.mjs";import{parseTypeDefinition as t}from"@stryke/convert/parse-type-definition";import{isSetString as n}from"@stryke/type-checks/is-set-string";async function r(r,i,a={}){let o;o=n(i)?t(i):i;let s=await e(r,o.file,a),c=await r.resolver.evalModule(s.text,{filename:s.path,forceTranspile:!0}),l=o.name;return l||=`default`,c[l]??c[`__Ω${l}`]}export{r as resolve};
1
+ import { bundle } from "./bundle.mjs";
2
+ import { parseTypeDefinition } from "@stryke/convert/parse-type-definition";
3
+ import { isSetString } from "@stryke/type-checks/is-set-string";
4
+
5
+ //#region ../powerlines/src/lib/utilities/resolve.ts
6
+ /**
7
+ * Compiles a type definition to a module.
8
+ *
9
+ * @param context - The context object containing the environment paths.
10
+ * @param type - The type definition to compile. This can be either a string or a {@link TypeDefinition} object.
11
+ * @param overrides - Optional overrides for the ESBuild configuration.
12
+ * @returns A promise that resolves to the compiled module.
13
+ */
14
+ async function resolve(context, type, overrides = {}) {
15
+ let typeDefinition;
16
+ if (isSetString(type)) typeDefinition = parseTypeDefinition(type);
17
+ else typeDefinition = type;
18
+ const result = await bundle(context, typeDefinition.file, overrides);
19
+ const resolved = await context.resolver.evalModule(result.text, {
20
+ filename: result.path,
21
+ forceTranspile: true
22
+ });
23
+ let exportName = typeDefinition.name;
24
+ if (!exportName) exportName = "default";
25
+ return resolved[exportName] ?? resolved[`__Ω${exportName}`];
26
+ }
27
+
28
+ //#endregion
29
+ export { resolve };
@@ -1 +1 @@
1
- require(`@stryke/path/replace`);
1
+ require("@stryke/path/replace");
@@ -1 +1,3 @@
1
- import"@stryke/path/replace";export{};
1
+ import "@stryke/path/replace";
2
+
3
+ export { };
@@ -78,10 +78,18 @@ interface ParseOptions extends ParserOptions {
78
78
  */
79
79
  allowReturnOutsideFunction?: boolean;
80
80
  }
81
+ interface EmitOptions extends WriteOptions {
82
+ /**
83
+ * If true, will emit the file using {@link UnpluginBuildContext.emitFile | the bundler's emit function}.
84
+ */
85
+ emitWithBundler?: boolean;
86
+ needsCodeReference?: Parameters<UnpluginBuildContext["emitFile"]>[0]["needsCodeReference"];
87
+ originalFileName?: Parameters<UnpluginBuildContext["emitFile"]>[0]["originalFileName"];
88
+ }
81
89
  /**
82
90
  * Options for emitting entry virtual files
83
91
  */
84
- type EmitEntryOptions = WriteOptions & Omit<ResolvedEntryTypeDefinition, "file">;
92
+ type EmitEntryOptions = EmitOptions & Omit<ResolvedEntryTypeDefinition, "file">;
85
93
  /**
86
94
  * The unresolved Powerlines context.
87
95
  *
@@ -292,6 +300,22 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
292
300
  * The Powerlines builtin virtual files
293
301
  */
294
302
  getBuiltins: () => Promise<VirtualFile[]>;
303
+ /**
304
+ * Resolves a file and writes it to the VFS if it does not already exist
305
+ *
306
+ * @param code - The source code of the file
307
+ * @param path - The path to write the file to
308
+ * @param options - Additional options for writing the file
309
+ */
310
+ emit: (code: string, path: string, options?: EmitOptions) => Promise<void>;
311
+ /**
312
+ * Synchronously resolves a file and writes it to the VFS if it does not already exist
313
+ *
314
+ * @param code - The source code of the file
315
+ * @param path - The path to write the file to
316
+ * @param options - Additional options for writing the file
317
+ */
318
+ emitSync: (code: string, path: string, options?: EmitOptions) => void;
295
319
  /**
296
320
  * Resolves a builtin virtual file and writes it to the VFS if it does not already exist
297
321
  *
@@ -300,7 +324,16 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
300
324
  * @param path - An optional path to write the builtin file to
301
325
  * @param options - Additional options for writing the builtin file
302
326
  */
303
- emitBuiltin: (code: string, id: string, path?: string, options?: WriteOptions) => Promise<void>;
327
+ emitBuiltin: (code: string, id: string, path?: string, options?: EmitOptions) => Promise<void>;
328
+ /**
329
+ * Synchronously resolves a builtin virtual file and writes it to the VFS if it does not already exist
330
+ *
331
+ * @param code - The source code of the builtin file
332
+ * @param id - The unique identifier of the builtin file
333
+ * @param path - An optional path to write the builtin file to
334
+ * @param options - Additional options for writing the builtin file
335
+ */
336
+ emitBuiltinSync: (code: string, id: string, path?: string, options?: EmitOptions) => void;
304
337
  /**
305
338
  * Resolves a entry virtual file and writes it to the VFS if it does not already exist
306
339
  *
@@ -309,6 +342,14 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
309
342
  * @param options - Additional options for writing the entry file
310
343
  */
311
344
  emitEntry: (code: string, path: string, options?: EmitEntryOptions) => Promise<void>;
345
+ /**
346
+ * Synchronously resolves a entry virtual file and writes it to the VFS if it does not already exist
347
+ *
348
+ * @param code - The source code of the entry file
349
+ * @param path - An optional path to write the entry file to
350
+ * @param options - Additional options for writing the entry file
351
+ */
352
+ emitEntrySync: (code: string, path: string, options?: EmitEntryOptions) => void;
312
353
  /**
313
354
  * A function to update the context fields using a new user configuration options
314
355
  */
@@ -80,10 +80,18 @@ interface ParseOptions extends ParserOptions {
80
80
  */
81
81
  allowReturnOutsideFunction?: boolean;
82
82
  }
83
+ interface EmitOptions extends WriteOptions {
84
+ /**
85
+ * If true, will emit the file using {@link UnpluginBuildContext.emitFile | the bundler's emit function}.
86
+ */
87
+ emitWithBundler?: boolean;
88
+ needsCodeReference?: Parameters<UnpluginBuildContext["emitFile"]>[0]["needsCodeReference"];
89
+ originalFileName?: Parameters<UnpluginBuildContext["emitFile"]>[0]["originalFileName"];
90
+ }
83
91
  /**
84
92
  * Options for emitting entry virtual files
85
93
  */
86
- type EmitEntryOptions = WriteOptions & Omit<ResolvedEntryTypeDefinition, "file">;
94
+ type EmitEntryOptions = EmitOptions & Omit<ResolvedEntryTypeDefinition, "file">;
87
95
  /**
88
96
  * The unresolved Powerlines context.
89
97
  *
@@ -294,6 +302,22 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
294
302
  * The Powerlines builtin virtual files
295
303
  */
296
304
  getBuiltins: () => Promise<VirtualFile[]>;
305
+ /**
306
+ * Resolves a file and writes it to the VFS if it does not already exist
307
+ *
308
+ * @param code - The source code of the file
309
+ * @param path - The path to write the file to
310
+ * @param options - Additional options for writing the file
311
+ */
312
+ emit: (code: string, path: string, options?: EmitOptions) => Promise<void>;
313
+ /**
314
+ * Synchronously resolves a file and writes it to the VFS if it does not already exist
315
+ *
316
+ * @param code - The source code of the file
317
+ * @param path - The path to write the file to
318
+ * @param options - Additional options for writing the file
319
+ */
320
+ emitSync: (code: string, path: string, options?: EmitOptions) => void;
297
321
  /**
298
322
  * Resolves a builtin virtual file and writes it to the VFS if it does not already exist
299
323
  *
@@ -302,7 +326,16 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
302
326
  * @param path - An optional path to write the builtin file to
303
327
  * @param options - Additional options for writing the builtin file
304
328
  */
305
- emitBuiltin: (code: string, id: string, path?: string, options?: WriteOptions) => Promise<void>;
329
+ emitBuiltin: (code: string, id: string, path?: string, options?: EmitOptions) => Promise<void>;
330
+ /**
331
+ * Synchronously resolves a builtin virtual file and writes it to the VFS if it does not already exist
332
+ *
333
+ * @param code - The source code of the builtin file
334
+ * @param id - The unique identifier of the builtin file
335
+ * @param path - An optional path to write the builtin file to
336
+ * @param options - Additional options for writing the builtin file
337
+ */
338
+ emitBuiltinSync: (code: string, id: string, path?: string, options?: EmitOptions) => void;
306
339
  /**
307
340
  * Resolves a entry virtual file and writes it to the VFS if it does not already exist
308
341
  *
@@ -311,6 +344,14 @@ interface UnresolvedContext<TResolvedConfig extends ResolvedConfig = ResolvedCon
311
344
  * @param options - Additional options for writing the entry file
312
345
  */
313
346
  emitEntry: (code: string, path: string, options?: EmitEntryOptions) => Promise<void>;
347
+ /**
348
+ * Synchronously resolves a entry virtual file and writes it to the VFS if it does not already exist
349
+ *
350
+ * @param code - The source code of the entry file
351
+ * @param path - An optional path to write the entry file to
352
+ * @param options - Additional options for writing the entry file
353
+ */
354
+ emitEntrySync: (code: string, path: string, options?: EmitEntryOptions) => void;
314
355
  /**
315
356
  * A function to update the context fields using a new user configuration options
316
357
  */
@@ -13,6 +13,13 @@ interface StorageAdapter {
13
13
  * A name identifying the storage adapter type.
14
14
  */
15
15
  name: string;
16
+ /**
17
+ * The storage preset for the adapter.
18
+ *
19
+ * @remarks
20
+ * This can be used as an alternate way to identify the type of storage being used.
21
+ */
22
+ preset?: StoragePreset | null;
16
23
  /**
17
24
  * Checks if a key exists in the storage.
18
25
  *
@@ -207,6 +214,13 @@ interface WriteOptions {
207
214
  * @defaultValue false
208
215
  */
209
216
  skipFormat?: boolean;
217
+ /**
218
+ * The storage preset or adapter name for the output file.
219
+ *
220
+ * @remarks
221
+ * If not specified, the output mode will be determined by the provided `output.mode` value.
222
+ */
223
+ storage?: StoragePreset | string;
210
224
  /**
211
225
  * Additional metadata for the file.
212
226
  */
@@ -13,6 +13,13 @@ interface StorageAdapter {
13
13
  * A name identifying the storage adapter type.
14
14
  */
15
15
  name: string;
16
+ /**
17
+ * The storage preset for the adapter.
18
+ *
19
+ * @remarks
20
+ * This can be used as an alternate way to identify the type of storage being used.
21
+ */
22
+ preset?: StoragePreset | null;
16
23
  /**
17
24
  * Checks if a key exists in the storage.
18
25
  *
@@ -207,6 +214,13 @@ interface WriteOptions {
207
214
  * @defaultValue false
208
215
  */
209
216
  skipFormat?: boolean;
217
+ /**
218
+ * The storage preset or adapter name for the output file.
219
+ *
220
+ * @remarks
221
+ * If not specified, the output mode will be determined by the provided `output.mode` value.
222
+ */
223
+ storage?: StoragePreset | string;
210
224
  /**
211
225
  * Additional metadata for the file.
212
226
  */
@@ -1 +1,15 @@
1
- const e=e=>({name:`powerlines/file-header`,fileHeader:(t=[])=>[`Generated by ${e.config.framework||`Powerlines`}`,`NOTE: Do not edit this file manually - it will be overwritten automatically by the "prepare" command`,...t]});exports.fileHeader=e;
1
+
2
+ //#region src/style-dictionary/file-header.ts
3
+ const fileHeader = (context) => ({
4
+ name: "powerlines/file-header",
5
+ fileHeader: (defaultMessages = []) => {
6
+ return [
7
+ `Generated by ${context.config.framework || "Powerlines"}`,
8
+ "NOTE: Do not edit this file manually - it will be overwritten automatically by the \"prepare\" command",
9
+ ...defaultMessages
10
+ ];
11
+ }
12
+ });
13
+
14
+ //#endregion
15
+ exports.fileHeader = fileHeader;
@@ -1 +1,14 @@
1
- const e=e=>({name:`powerlines/file-header`,fileHeader:(t=[])=>[`Generated by ${e.config.framework||`Powerlines`}`,`NOTE: Do not edit this file manually - it will be overwritten automatically by the "prepare" command`,...t]});export{e as fileHeader};
1
+ //#region src/style-dictionary/file-header.ts
2
+ const fileHeader = (context) => ({
3
+ name: "powerlines/file-header",
4
+ fileHeader: (defaultMessages = []) => {
5
+ return [
6
+ `Generated by ${context.config.framework || "Powerlines"}`,
7
+ "NOTE: Do not edit this file manually - it will be overwritten automatically by the \"prepare\" command",
8
+ ...defaultMessages
9
+ ];
10
+ }
11
+ });
12
+
13
+ //#endregion
14
+ export { fileHeader };
@@ -1 +1 @@
1
- export{};
1
+ export { };
@@ -1 +1 @@
1
- export{};
1
+ export { };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-style-dictionary",
3
- "version": "0.3.17",
3
+ "version": "0.3.19",
4
4
  "type": "module",
5
5
  "description": "A Powerlines plugin to generate project code with Style Dictionary.",
6
6
  "repository": {
@@ -122,19 +122,19 @@
122
122
  "powerlines-plugin"
123
123
  ],
124
124
  "dependencies": {
125
- "@stryke/path": "^0.24.0",
126
- "@stryke/type-checks": "^0.5.14",
127
- "@stryke/types": "^0.10.28",
125
+ "@stryke/path": "^0.24.1",
126
+ "@stryke/type-checks": "^0.5.15",
127
+ "@stryke/types": "^0.10.29",
128
128
  "defu": "^6.1.4",
129
129
  "jiti": "^2.6.1",
130
- "powerlines": "^0.36.21",
130
+ "powerlines": "^0.36.23",
131
131
  "style-dictionary": "^5.1.1"
132
132
  },
133
133
  "devDependencies": {
134
- "@powerlines/nx": "^0.11.47",
135
- "@powerlines/plugin-plugin": "^0.12.68",
134
+ "@powerlines/nx": "^0.11.49",
135
+ "@powerlines/plugin-plugin": "^0.12.70",
136
136
  "@types/node": "^24.10.4"
137
137
  },
138
138
  "publishConfig": { "access": "public" },
139
- "gitHead": "b16324cf857ea5743fd7ad06e18607b1ba32abe0"
139
+ "gitHead": "be47e546b48b9a82e460b5c5d4f02fb66e821f18"
140
140
  }