@dsai-io/tools 1.3.0 → 1.3.1
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/cli/index.cjs +104 -77
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +104 -77
- package/dist/cli/index.js.map +1 -1
- package/dist/index.cjs +104 -69
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +104 -67
- package/dist/index.js.map +1 -1
- package/dist/tokens/index.cjs +104 -69
- package/dist/tokens/index.cjs.map +1 -1
- package/dist/tokens/index.d.cts +6 -0
- package/dist/tokens/index.d.ts +6 -0
- package/dist/tokens/index.js +104 -67
- package/dist/tokens/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -4566,13 +4566,98 @@ var init_groups = __esm({
|
|
|
4566
4566
|
];
|
|
4567
4567
|
}
|
|
4568
4568
|
});
|
|
4569
|
+
|
|
4570
|
+
// src/tokens/style-dictionary/preprocessors/fix-references.ts
|
|
4571
|
+
function fixValue(value, mappings) {
|
|
4572
|
+
if (typeof value !== "string" || !value.startsWith("{")) {
|
|
4573
|
+
return value;
|
|
4574
|
+
}
|
|
4575
|
+
let result = value;
|
|
4576
|
+
for (const mapping of mappings) {
|
|
4577
|
+
result = result.split(mapping[0]).join(mapping[1]);
|
|
4578
|
+
}
|
|
4579
|
+
return result;
|
|
4580
|
+
}
|
|
4581
|
+
function processTokens(obj, mappings) {
|
|
4582
|
+
for (const key of Object.keys(obj)) {
|
|
4583
|
+
const value = obj[key];
|
|
4584
|
+
if (value && typeof value === "object") {
|
|
4585
|
+
const typedValue = value;
|
|
4586
|
+
if ("$value" in typedValue) {
|
|
4587
|
+
typedValue["$value"] = fixValue(typedValue["$value"], mappings);
|
|
4588
|
+
} else if ("value" in typedValue) {
|
|
4589
|
+
typedValue["value"] = fixValue(typedValue["value"], mappings);
|
|
4590
|
+
} else {
|
|
4591
|
+
processTokens(typedValue, mappings);
|
|
4592
|
+
}
|
|
4593
|
+
}
|
|
4594
|
+
}
|
|
4595
|
+
}
|
|
4596
|
+
function createFixReferencesPreprocessor(mappings) {
|
|
4597
|
+
return {
|
|
4598
|
+
name: "fix-references-custom",
|
|
4599
|
+
preprocessor: (dictionary) => {
|
|
4600
|
+
processTokens(dictionary, mappings);
|
|
4601
|
+
return dictionary;
|
|
4602
|
+
}
|
|
4603
|
+
};
|
|
4604
|
+
}
|
|
4605
|
+
var DEFAULT_PATH_MAPPINGS, fixReferences;
|
|
4606
|
+
var init_fix_references = __esm({
|
|
4607
|
+
"src/tokens/style-dictionary/preprocessors/fix-references.ts"() {
|
|
4608
|
+
DEFAULT_PATH_MAPPINGS = [
|
|
4609
|
+
["{colors.brand.", "{color."],
|
|
4610
|
+
["{colors.neutral.", "{neutral."],
|
|
4611
|
+
["{borders.width.", "{border.width."]
|
|
4612
|
+
];
|
|
4613
|
+
fixReferences = {
|
|
4614
|
+
name: "fix-references",
|
|
4615
|
+
preprocessor: (dictionary) => {
|
|
4616
|
+
processTokens(dictionary, DEFAULT_PATH_MAPPINGS);
|
|
4617
|
+
return dictionary;
|
|
4618
|
+
}
|
|
4619
|
+
};
|
|
4620
|
+
}
|
|
4621
|
+
});
|
|
4622
|
+
|
|
4623
|
+
// src/tokens/style-dictionary/preprocessors/index.ts
|
|
4624
|
+
var preprocessors_exports = {};
|
|
4625
|
+
__export(preprocessors_exports, {
|
|
4626
|
+
builtInPreprocessors: () => builtInPreprocessors,
|
|
4627
|
+
createFixReferencesPreprocessor: () => createFixReferencesPreprocessor,
|
|
4628
|
+
fixReferences: () => fixReferences,
|
|
4629
|
+
registerPreprocessors: () => registerPreprocessors
|
|
4630
|
+
});
|
|
4631
|
+
function registerPreprocessors(sd, customPreprocessors = []) {
|
|
4632
|
+
const allPreprocessors = [...builtInPreprocessors, ...customPreprocessors];
|
|
4633
|
+
for (const preprocessor of allPreprocessors) {
|
|
4634
|
+
sd.registerPreprocessor({
|
|
4635
|
+
name: preprocessor.name,
|
|
4636
|
+
preprocessor: preprocessor.preprocessor
|
|
4637
|
+
});
|
|
4638
|
+
}
|
|
4639
|
+
}
|
|
4640
|
+
var builtInPreprocessors;
|
|
4641
|
+
var init_preprocessors = __esm({
|
|
4642
|
+
"src/tokens/style-dictionary/preprocessors/index.ts"() {
|
|
4643
|
+
init_fix_references();
|
|
4644
|
+
init_fix_references();
|
|
4645
|
+
builtInPreprocessors = [fixReferences];
|
|
4646
|
+
}
|
|
4647
|
+
});
|
|
4569
4648
|
function generateThemeBuildConfig(options) {
|
|
4570
4649
|
const { themeDefinition, files, outputDir, config } = options;
|
|
4571
4650
|
const isDefault = themeDefinition.isDefault;
|
|
4572
4651
|
const platformsMap = /* @__PURE__ */ new Map();
|
|
4573
4652
|
const enabledFormats = config.formats;
|
|
4574
4653
|
for (const format of enabledFormats) {
|
|
4575
|
-
const platformConfig = generatePlatformConfig(
|
|
4654
|
+
const platformConfig = generatePlatformConfig(
|
|
4655
|
+
format,
|
|
4656
|
+
themeDefinition,
|
|
4657
|
+
outputDir,
|
|
4658
|
+
isDefault,
|
|
4659
|
+
config.prefix
|
|
4660
|
+
);
|
|
4576
4661
|
if (platformConfig) {
|
|
4577
4662
|
platformsMap.set(format, platformConfig);
|
|
4578
4663
|
}
|
|
@@ -4581,6 +4666,7 @@ function generateThemeBuildConfig(options) {
|
|
|
4581
4666
|
return {
|
|
4582
4667
|
source: files,
|
|
4583
4668
|
platforms,
|
|
4669
|
+
preprocessors: ["fix-references"],
|
|
4584
4670
|
// Enable DTCG format support (tokens with $value, $type, etc.)
|
|
4585
4671
|
usesDtcg: true,
|
|
4586
4672
|
// Configure logging to not throw on broken references (they'll be logged but build continues)
|
|
@@ -4593,7 +4679,7 @@ function generateThemeBuildConfig(options) {
|
|
|
4593
4679
|
}
|
|
4594
4680
|
};
|
|
4595
4681
|
}
|
|
4596
|
-
function generatePlatformConfig(format, themeDefinition, outputDir, isDefault) {
|
|
4682
|
+
function generatePlatformConfig(format, themeDefinition, outputDir, isDefault, prefix) {
|
|
4597
4683
|
const formatConfig = FORMAT_MAPPING.get(format);
|
|
4598
4684
|
if (!formatConfig) {
|
|
4599
4685
|
console.warn(`Unknown format: ${format}`);
|
|
@@ -4608,8 +4694,15 @@ function generatePlatformConfig(format, themeDefinition, outputDir, isDefault) {
|
|
|
4608
4694
|
destination: outputFile,
|
|
4609
4695
|
format: sdFormat
|
|
4610
4696
|
};
|
|
4697
|
+
if (prefix && (format === "css" || format === "scss")) {
|
|
4698
|
+
fileConfig.options = {
|
|
4699
|
+
...fileConfig.options,
|
|
4700
|
+
prefix
|
|
4701
|
+
};
|
|
4702
|
+
}
|
|
4611
4703
|
if (format === "css" && !isDefault) {
|
|
4612
4704
|
fileConfig.options = {
|
|
4705
|
+
...fileConfig.options,
|
|
4613
4706
|
selector: themeDefinition.selector
|
|
4614
4707
|
};
|
|
4615
4708
|
}
|
|
@@ -4722,6 +4815,8 @@ async function runStyleDictionaryBuild(sdConfig, options) {
|
|
|
4722
4815
|
registerCustomTransforms(StyleDictionary);
|
|
4723
4816
|
const { registerTransformGroups: registerTransformGroups2 } = await Promise.resolve().then(() => (init_groups(), groups_exports));
|
|
4724
4817
|
registerTransformGroups2(StyleDictionary);
|
|
4818
|
+
const { registerPreprocessors: registerPreprocessors2 } = await Promise.resolve().then(() => (init_preprocessors(), preprocessors_exports));
|
|
4819
|
+
registerPreprocessors2(StyleDictionary);
|
|
4725
4820
|
if (options.verbose) {
|
|
4726
4821
|
console.warn(` \u{1F527} Style Dictionary platforms:`);
|
|
4727
4822
|
for (const [platform, config] of Object.entries(sdConfig.platforms)) {
|
|
@@ -4915,7 +5010,7 @@ var init_theme_builder = __esm({
|
|
|
4915
5010
|
["ios", { default: "ios/macros", themed: "ios/macros" }]
|
|
4916
5011
|
]);
|
|
4917
5012
|
TRANSFORM_GROUPS = /* @__PURE__ */ new Map([
|
|
4918
|
-
["css", "css"],
|
|
5013
|
+
["css", "custom/css"],
|
|
4919
5014
|
["scss", "scss"],
|
|
4920
5015
|
["js", "js-custom"],
|
|
4921
5016
|
// Use custom transform group for valid JS identifiers
|
|
@@ -5154,7 +5249,7 @@ function getPipelinePaths(customPaths) {
|
|
|
5154
5249
|
...customPaths
|
|
5155
5250
|
};
|
|
5156
5251
|
}
|
|
5157
|
-
function createStepFromName(stepName, tokensPackageDir, figmaExportsDir, tokensDir, paths, sdConfigFile, strict, snapshotService, themesConfig, outputDir, formats = ["css", "scss", "json"], cssOutputDir, postprocessConfig) {
|
|
5252
|
+
function createStepFromName(stepName, tokensPackageDir, figmaExportsDir, tokensDir, paths, sdConfigFile, strict, snapshotService, themesConfig, outputDir, formats = ["css", "scss", "json"], cssOutputDir, postprocessConfig, prefix) {
|
|
5158
5253
|
const displayName = STEP_DISPLAY_NAMES.get(stepName) ?? `Unknown: ${stepName}`;
|
|
5159
5254
|
switch (stepName) {
|
|
5160
5255
|
case "validate":
|
|
@@ -5359,6 +5454,7 @@ function createStepFromName(stepName, tokensPackageDir, figmaExportsDir, tokensD
|
|
|
5359
5454
|
const result = await buildAllThemes({
|
|
5360
5455
|
config: {
|
|
5361
5456
|
formats,
|
|
5457
|
+
prefix,
|
|
5362
5458
|
themes: {
|
|
5363
5459
|
definitions: themeDefinitions
|
|
5364
5460
|
}
|
|
@@ -5474,7 +5570,8 @@ function createBuildSteps(tokensDir, _toolsDir, options, pipeline) {
|
|
|
5474
5570
|
options.outputDir,
|
|
5475
5571
|
formats,
|
|
5476
5572
|
options.cssOutputDir,
|
|
5477
|
-
options.postprocessConfig
|
|
5573
|
+
options.postprocessConfig,
|
|
5574
|
+
options.prefix
|
|
5478
5575
|
);
|
|
5479
5576
|
if (stepName === "validate" && skipValidate) {
|
|
5480
5577
|
step.skip = true;
|
|
@@ -6859,78 +6956,6 @@ var init_types2 = __esm({
|
|
|
6859
6956
|
}
|
|
6860
6957
|
});
|
|
6861
6958
|
|
|
6862
|
-
// src/tokens/style-dictionary/preprocessors/fix-references.ts
|
|
6863
|
-
function fixValue(value, mappings) {
|
|
6864
|
-
if (typeof value !== "string" || !value.startsWith("{")) {
|
|
6865
|
-
return value;
|
|
6866
|
-
}
|
|
6867
|
-
let result = value;
|
|
6868
|
-
for (const mapping of mappings) {
|
|
6869
|
-
result = result.split(mapping[0]).join(mapping[1]);
|
|
6870
|
-
}
|
|
6871
|
-
return result;
|
|
6872
|
-
}
|
|
6873
|
-
function processTokens(obj, mappings) {
|
|
6874
|
-
for (const key of Object.keys(obj)) {
|
|
6875
|
-
const value = obj[key];
|
|
6876
|
-
if (value && typeof value === "object") {
|
|
6877
|
-
const typedValue = value;
|
|
6878
|
-
if ("$value" in typedValue) {
|
|
6879
|
-
typedValue["$value"] = fixValue(typedValue["$value"], mappings);
|
|
6880
|
-
} else if ("value" in typedValue) {
|
|
6881
|
-
typedValue["value"] = fixValue(typedValue["value"], mappings);
|
|
6882
|
-
} else {
|
|
6883
|
-
processTokens(typedValue, mappings);
|
|
6884
|
-
}
|
|
6885
|
-
}
|
|
6886
|
-
}
|
|
6887
|
-
}
|
|
6888
|
-
function createFixReferencesPreprocessor(mappings) {
|
|
6889
|
-
return {
|
|
6890
|
-
name: "fix-references-custom",
|
|
6891
|
-
preprocessor: (dictionary) => {
|
|
6892
|
-
processTokens(dictionary, mappings);
|
|
6893
|
-
return dictionary;
|
|
6894
|
-
}
|
|
6895
|
-
};
|
|
6896
|
-
}
|
|
6897
|
-
var DEFAULT_PATH_MAPPINGS, fixReferences;
|
|
6898
|
-
var init_fix_references = __esm({
|
|
6899
|
-
"src/tokens/style-dictionary/preprocessors/fix-references.ts"() {
|
|
6900
|
-
DEFAULT_PATH_MAPPINGS = [
|
|
6901
|
-
["{colors.brand.", "{color."],
|
|
6902
|
-
["{colors.neutral.", "{neutral."],
|
|
6903
|
-
["{borders.width.", "{border.width."]
|
|
6904
|
-
];
|
|
6905
|
-
fixReferences = {
|
|
6906
|
-
name: "fix-references",
|
|
6907
|
-
preprocessor: (dictionary) => {
|
|
6908
|
-
processTokens(dictionary, DEFAULT_PATH_MAPPINGS);
|
|
6909
|
-
return dictionary;
|
|
6910
|
-
}
|
|
6911
|
-
};
|
|
6912
|
-
}
|
|
6913
|
-
});
|
|
6914
|
-
|
|
6915
|
-
// src/tokens/style-dictionary/preprocessors/index.ts
|
|
6916
|
-
function registerPreprocessors(sd, customPreprocessors = []) {
|
|
6917
|
-
const allPreprocessors = [...builtInPreprocessors, ...customPreprocessors];
|
|
6918
|
-
for (const preprocessor of allPreprocessors) {
|
|
6919
|
-
sd.registerPreprocessor({
|
|
6920
|
-
name: preprocessor.name,
|
|
6921
|
-
preprocessor: preprocessor.preprocessor
|
|
6922
|
-
});
|
|
6923
|
-
}
|
|
6924
|
-
}
|
|
6925
|
-
var builtInPreprocessors;
|
|
6926
|
-
var init_preprocessors = __esm({
|
|
6927
|
-
"src/tokens/style-dictionary/preprocessors/index.ts"() {
|
|
6928
|
-
init_fix_references();
|
|
6929
|
-
init_fix_references();
|
|
6930
|
-
builtInPreprocessors = [fixReferences];
|
|
6931
|
-
}
|
|
6932
|
-
});
|
|
6933
|
-
|
|
6934
6959
|
// src/tokens/style-dictionary/config.ts
|
|
6935
6960
|
function createStyleDictionaryConfig(dsaiConfig, options = {}) {
|
|
6936
6961
|
const {
|
|
@@ -9365,6 +9390,8 @@ async function runTokensBuild(options) {
|
|
|
9365
9390
|
pipeline: config.tokens.pipeline,
|
|
9366
9391
|
// Pass formats from config (default: css, scss, json)
|
|
9367
9392
|
formats: config.tokens.formats,
|
|
9393
|
+
// Pass CSS custom property prefix from config
|
|
9394
|
+
prefix: config.tokens.prefix,
|
|
9368
9395
|
// Pass output directory from config
|
|
9369
9396
|
outputDir: config.tokens.outputDir ? resolve(configDir, config.tokens.outputDir) : resolve(configDir, "dist"),
|
|
9370
9397
|
// Pass themes config for multi-theme builds
|