@digdir/designsystemet 1.1.3 → 1.1.4
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/bin/designsystemet.js +130 -186
- package/dist/src/index.js +88 -145
- package/dist/src/scripts/update-preview-tokens.d.ts +3 -0
- package/dist/src/scripts/update-preview-tokens.d.ts.map +1 -0
- package/dist/src/scripts/update-preview-tokens.js +3446 -0
- package/dist/src/tokens/build.d.ts +1 -1
- package/dist/src/tokens/build.d.ts.map +1 -1
- package/dist/src/tokens/build.js +98 -154
- package/dist/src/tokens/create/generators/$designsystemet.js +6 -6
- package/dist/src/tokens/create/write.js +6 -6
- package/dist/src/tokens/format.d.ts +1 -1
- package/dist/src/tokens/format.d.ts.map +1 -1
- package/dist/src/tokens/format.js +88 -145
- package/dist/src/tokens/index.js +88 -145
- package/dist/src/tokens/process/configs/color.js +234 -293
- package/dist/src/tokens/process/configs/semantic.js +509 -113
- package/dist/src/tokens/process/configs/typography.d.ts.map +1 -1
- package/dist/src/tokens/process/configs/typography.js +504 -110
- package/dist/src/tokens/process/configs.d.ts +0 -1
- package/dist/src/tokens/process/configs.d.ts.map +1 -1
- package/dist/src/tokens/process/configs.js +231 -290
- package/dist/src/tokens/process/formats/css/color.d.ts.map +1 -1
- package/dist/src/tokens/process/formats/css/color.js +644 -12
- package/dist/src/tokens/process/formats/css/semantic.d.ts.map +1 -1
- package/dist/src/tokens/process/formats/css/semantic.js +679 -23
- package/dist/src/tokens/process/formats/css/typography.d.ts.map +1 -1
- package/dist/src/tokens/process/formats/css/typography.js +741 -8
- package/dist/src/tokens/process/formats/css.js +549 -38
- package/dist/src/tokens/process/output/declarations.js +60 -121
- package/dist/src/tokens/process/output/theme.js +6 -6
- package/dist/src/tokens/process/platform.d.ts +9 -4
- package/dist/src/tokens/process/platform.d.ts.map +1 -1
- package/dist/src/tokens/process/platform.js +76 -133
- package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +62 -123
- package/package.json +6 -6
- package/dist/src/tokens/process/configs/storefront.d.ts +0 -3
- package/dist/src/tokens/process/configs/storefront.d.ts.map +0 -1
- package/dist/src/tokens/process/configs/storefront.js +0 -234
- package/dist/src/tokens/process/formats/js-tokens.d.ts +0 -6
- package/dist/src/tokens/process/formats/js-tokens.d.ts.map +0 -1
- package/dist/src/tokens/process/formats/js-tokens.js +0 -123
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/tokens/format.ts
|
|
2
|
-
import * as
|
|
2
|
+
import * as R18 from "ramda";
|
|
3
3
|
|
|
4
4
|
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BoxShadowTypes.js
|
|
5
5
|
var BoxShadowTypes;
|
|
@@ -2413,11 +2413,11 @@ import * as R7 from "ramda";
|
|
|
2413
2413
|
// package.json
|
|
2414
2414
|
var package_default = {
|
|
2415
2415
|
name: "@digdir/designsystemet",
|
|
2416
|
-
version: "1.1.
|
|
2416
|
+
version: "1.1.4",
|
|
2417
2417
|
description: "CLI for Designsystemet",
|
|
2418
2418
|
author: "Designsystemet team",
|
|
2419
2419
|
engines: {
|
|
2420
|
-
node: ">=22.
|
|
2420
|
+
node: ">=22.17.0"
|
|
2421
2421
|
},
|
|
2422
2422
|
repository: {
|
|
2423
2423
|
type: "git",
|
|
@@ -2466,6 +2466,7 @@ var package_default = {
|
|
|
2466
2466
|
"digdir:tokens-build": "pnpm run designsystemet tokens build -t ../../internal/design-tokens -o ../../packages/theme/brand --clean --experimental-tailwind",
|
|
2467
2467
|
"digdir:tokens-create": "pnpm run designsystemet tokens create --config ./configs/digdir.config.json",
|
|
2468
2468
|
"update:template": "tsx ./src/scripts/update-template.ts",
|
|
2469
|
+
"update:preview-tokens": "tsx ./src/scripts/update-preview-tokens.ts",
|
|
2469
2470
|
"update:theme-digdir": "pnpm digdir:tokens-create && tsx ./src/scripts/update-design-tokens.ts && pnpm digdir:tokens-build",
|
|
2470
2471
|
verify: "pnpm test && pnpm update:template && pnpm update:theme-digdir && pnpm build:tokens"
|
|
2471
2472
|
},
|
|
@@ -2483,8 +2484,8 @@ var package_default = {
|
|
|
2483
2484
|
"object-hash": "^3.0.0",
|
|
2484
2485
|
postcss: "^8.5.6",
|
|
2485
2486
|
ramda: "^0.31.3",
|
|
2486
|
-
"style-dictionary": "^5.0.
|
|
2487
|
-
zod: "^3.25.
|
|
2487
|
+
"style-dictionary": "^5.0.1",
|
|
2488
|
+
zod: "^3.25.74",
|
|
2488
2489
|
"zod-validation-error": "^3.5.2"
|
|
2489
2490
|
},
|
|
2490
2491
|
devDependencies: {
|
|
@@ -2492,8 +2493,7 @@ var package_default = {
|
|
|
2492
2493
|
"@types/apca-w3": "^0.1.3",
|
|
2493
2494
|
"@types/chroma-js": "^3.1.1",
|
|
2494
2495
|
"@types/fs-extra": "^11.0.4",
|
|
2495
|
-
"@types/
|
|
2496
|
-
"@types/node": "^22.15.32",
|
|
2496
|
+
"@types/node": "^22.16.0",
|
|
2497
2497
|
"@types/object-hash": "^3.0.6",
|
|
2498
2498
|
"@types/ramda": "^0.30.2",
|
|
2499
2499
|
"fs-extra": "^11.3.0",
|
|
@@ -2508,7 +2508,7 @@ var package_default = {
|
|
|
2508
2508
|
var defaultFileHeader = `build: v${package_default.version}`;
|
|
2509
2509
|
var createThemeCSSFiles = ({
|
|
2510
2510
|
processedBuilds,
|
|
2511
|
-
fileHeader
|
|
2511
|
+
fileHeader = defaultFileHeader
|
|
2512
2512
|
}) => {
|
|
2513
2513
|
const groupedByTheme = {};
|
|
2514
2514
|
for (const [_, buildResults] of Object.entries(processedBuilds)) {
|
|
@@ -2555,7 +2555,7 @@ order may change due to nondeterminism.`.trim()
|
|
|
2555
2555
|
});
|
|
2556
2556
|
const header = `@charset "UTF-8";
|
|
2557
2557
|
/*
|
|
2558
|
-
${
|
|
2558
|
+
${fileHeader}
|
|
2559
2559
|
*/
|
|
2560
2560
|
|
|
2561
2561
|
`;
|
|
@@ -2577,7 +2577,7 @@ ${fileHeader2}
|
|
|
2577
2577
|
|
|
2578
2578
|
// src/tokens/process/platform.ts
|
|
2579
2579
|
import chalk3 from "chalk";
|
|
2580
|
-
import * as
|
|
2580
|
+
import * as R17 from "ramda";
|
|
2581
2581
|
import StyleDictionary2 from "style-dictionary";
|
|
2582
2582
|
|
|
2583
2583
|
// src/tokens/types.ts
|
|
@@ -2588,7 +2588,7 @@ var colorCategories = {
|
|
|
2588
2588
|
|
|
2589
2589
|
// src/tokens/process/configs.ts
|
|
2590
2590
|
import { register } from "@tokens-studio/sd-transforms";
|
|
2591
|
-
import * as
|
|
2591
|
+
import * as R16 from "ramda";
|
|
2592
2592
|
import StyleDictionary from "style-dictionary";
|
|
2593
2593
|
|
|
2594
2594
|
// src/tokens/utils.ts
|
|
@@ -2699,7 +2699,11 @@ var colorScheme = {
|
|
|
2699
2699
|
(t) => !isColorCategoryToken(t)
|
|
2700
2700
|
])
|
|
2701
2701
|
);
|
|
2702
|
-
const
|
|
2702
|
+
const formattedMap = filteredAllTokens.map((token) => ({
|
|
2703
|
+
token,
|
|
2704
|
+
formatted: format(token)
|
|
2705
|
+
}));
|
|
2706
|
+
const formattedTokens = formattedMap.map(R9.view(R9.lensProp("formatted"))).join("\n");
|
|
2703
2707
|
const content = `{
|
|
2704
2708
|
${formattedTokens}
|
|
2705
2709
|
${colorSchemeProperty}}
|
|
@@ -2717,7 +2721,8 @@ var colorCategory = {
|
|
|
2717
2721
|
name: "ds/css-colorcategory",
|
|
2718
2722
|
format: async ({ dictionary, options, platform }) => {
|
|
2719
2723
|
const { outputReferences, usesDtcg } = options;
|
|
2720
|
-
const { selector, layer } = platform;
|
|
2724
|
+
const { selector, layer, files } = platform;
|
|
2725
|
+
const destination = files?.[0]?.destination;
|
|
2721
2726
|
const format = R9.compose(
|
|
2722
2727
|
createPropertyFormatter({
|
|
2723
2728
|
outputReferences,
|
|
@@ -2734,7 +2739,12 @@ var colorCategory = {
|
|
|
2734
2739
|
}
|
|
2735
2740
|
})
|
|
2736
2741
|
);
|
|
2737
|
-
const
|
|
2742
|
+
const formattedMap = dictionary.allTokens.map((token) => ({
|
|
2743
|
+
token,
|
|
2744
|
+
formatted: format(token)
|
|
2745
|
+
}));
|
|
2746
|
+
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
2747
|
+
const formattedTokens = formattedMap.map(R9.view(R9.lensProp("formatted"))).join("\n");
|
|
2738
2748
|
const content = `{
|
|
2739
2749
|
${formattedTokens}
|
|
2740
2750
|
}
|
|
@@ -2765,30 +2775,30 @@ var overrideSizingFormula = (format, token) => {
|
|
|
2765
2775
|
calc
|
|
2766
2776
|
};
|
|
2767
2777
|
};
|
|
2768
|
-
var formatSizingTokens = (format, tokens) =>
|
|
2769
|
-
|
|
2770
|
-
(
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2778
|
+
var formatSizingTokens = (format, tokens) => R10.reduce(
|
|
2779
|
+
(acc, token) => {
|
|
2780
|
+
const { round, calc, name } = overrideSizingFormula(format, token);
|
|
2781
|
+
return {
|
|
2782
|
+
tokens: [...acc.tokens, token],
|
|
2783
|
+
round: [...acc.round, `${name}: ${round};`],
|
|
2784
|
+
calc: [...acc.calc, `${name}: ${calc};`]
|
|
2785
|
+
};
|
|
2786
|
+
},
|
|
2787
|
+
{ tokens: [], round: [], calc: [] },
|
|
2788
|
+
tokens
|
|
2789
|
+
);
|
|
2790
|
+
var sizingTemplate = ({ round, calc }) => `
|
|
2781
2791
|
${calc.join("\n")}
|
|
2782
2792
|
|
|
2783
2793
|
@supports (width: round(down, .1em, 1px)) {
|
|
2784
2794
|
${round.join("\n")}
|
|
2785
2795
|
}`;
|
|
2786
|
-
};
|
|
2787
2796
|
var semantic = {
|
|
2788
2797
|
name: "ds/css-semantic",
|
|
2789
2798
|
format: async ({ dictionary, options, platform }) => {
|
|
2790
2799
|
const { outputReferences, usesDtcg } = options;
|
|
2791
|
-
const { selector, layer } = platform;
|
|
2800
|
+
const { selector, layer, files } = platform;
|
|
2801
|
+
const destination = files?.[0]?.destination;
|
|
2792
2802
|
const format = createPropertyFormatter2({
|
|
2793
2803
|
outputReferences,
|
|
2794
2804
|
dictionary,
|
|
@@ -2801,7 +2811,18 @@ var semantic = {
|
|
|
2801
2811
|
(t) => pathStartsWithOneOf(["_size"], t) && isDigit(t.path[1]),
|
|
2802
2812
|
filteredTokens
|
|
2803
2813
|
);
|
|
2804
|
-
const
|
|
2814
|
+
const formattedSizingTokens = formatSizingTokens(format, sizingTokens);
|
|
2815
|
+
const formattedMap = restTokens.map((token) => ({
|
|
2816
|
+
token,
|
|
2817
|
+
formatted: format(token)
|
|
2818
|
+
}));
|
|
2819
|
+
const formattedSizingMap = formattedSizingTokens.round.map((t, i) => ({
|
|
2820
|
+
token: formattedSizingTokens.tokens[i],
|
|
2821
|
+
formatted: t
|
|
2822
|
+
}));
|
|
2823
|
+
buildOptions.buildTokenFormats[destination] = [...formattedMap, ...formattedSizingMap];
|
|
2824
|
+
const sizingSnippet = sizingTemplate(formattedSizingTokens);
|
|
2825
|
+
const formattedTokens = formattedMap.map(R10.view(R10.lensProp("formatted"))).concat(sizingSnippet);
|
|
2805
2826
|
const content = `{
|
|
2806
2827
|
${formattedTokens.join("\n")}
|
|
2807
2828
|
}
|
|
@@ -2826,7 +2847,8 @@ var typography = {
|
|
|
2826
2847
|
name: "ds/css-typography",
|
|
2827
2848
|
format: async ({ dictionary, options, platform }) => {
|
|
2828
2849
|
const { outputReferences, usesDtcg } = options;
|
|
2829
|
-
const { selector, layer } = platform;
|
|
2850
|
+
const { selector, layer, files } = platform;
|
|
2851
|
+
const destination = files?.[0]?.destination;
|
|
2830
2852
|
const format = createPropertyFormatter3({
|
|
2831
2853
|
outputReferences,
|
|
2832
2854
|
dictionary,
|
|
@@ -2834,7 +2856,12 @@ var typography = {
|
|
|
2834
2856
|
usesDtcg
|
|
2835
2857
|
});
|
|
2836
2858
|
const filteredTokens = R11.reject(typographyFontFamilyPredicate, dictionary.allTokens);
|
|
2837
|
-
const
|
|
2859
|
+
const formattedMap = filteredTokens.map((token) => ({
|
|
2860
|
+
token,
|
|
2861
|
+
formatted: format(token)
|
|
2862
|
+
}));
|
|
2863
|
+
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
2864
|
+
const formattedTokens = formattedMap.map(R11.view(R11.lensProp("formatted"))).join("\n");
|
|
2838
2865
|
const content = selector ? `${selector} {
|
|
2839
2866
|
${formattedTokens}
|
|
2840
2867
|
}` : formattedTokens;
|
|
@@ -3041,90 +3068,6 @@ var semanticVariables = ({ theme }) => {
|
|
|
3041
3068
|
};
|
|
3042
3069
|
};
|
|
3043
3070
|
|
|
3044
|
-
// src/tokens/process/configs/storefront.ts
|
|
3045
|
-
import * as R16 from "ramda";
|
|
3046
|
-
import { outputReferencesFilter as outputReferencesFilter2 } from "style-dictionary/utils";
|
|
3047
|
-
|
|
3048
|
-
// src/tokens/process/formats/js-tokens.ts
|
|
3049
|
-
import * as R15 from "ramda";
|
|
3050
|
-
import { createPropertyFormatter as createPropertyFormatter4, fileHeader } from "style-dictionary/utils";
|
|
3051
|
-
var groupByType = R15.groupBy((token) => getType(token));
|
|
3052
|
-
var removeUnwatedTokens = R15.pipe(
|
|
3053
|
-
R15.reject((token) => isColorCategoryToken(token)),
|
|
3054
|
-
R15.reject((token) => R15.any((path) => path.startsWith("_"))(token.path))
|
|
3055
|
-
);
|
|
3056
|
-
var dissocExtensions = R15.pipe(R15.dissoc("$extensions"), R15.dissocPath(["original", "$extensions"]));
|
|
3057
|
-
var removeUnwatedProps = R15.map((token) => dissocExtensions(token));
|
|
3058
|
-
var toCssVarName = R15.pipe(R15.split(":"), R15.head, R15.trim);
|
|
3059
|
-
var jsTokens = {
|
|
3060
|
-
name: "ds/js-tokens",
|
|
3061
|
-
format: async ({ dictionary, file, options }) => {
|
|
3062
|
-
const { usesDtcg, outputReferences } = options;
|
|
3063
|
-
const format = createPropertyFormatter4({
|
|
3064
|
-
outputReferences,
|
|
3065
|
-
dictionary,
|
|
3066
|
-
format: "css",
|
|
3067
|
-
usesDtcg
|
|
3068
|
-
});
|
|
3069
|
-
const formatTokens2 = R15.map((token) => {
|
|
3070
|
-
if (pathStartsWithOneOf(["size", "_size"], token)) {
|
|
3071
|
-
const { calc, name } = overrideSizingFormula(format, token);
|
|
3072
|
-
return {
|
|
3073
|
-
...token,
|
|
3074
|
-
name: name.trim(),
|
|
3075
|
-
$value: calc.trim()
|
|
3076
|
-
};
|
|
3077
|
-
}
|
|
3078
|
-
return {
|
|
3079
|
-
...token,
|
|
3080
|
-
name: toCssVarName(format(token))
|
|
3081
|
-
};
|
|
3082
|
-
});
|
|
3083
|
-
const processTokens = R15.pipe(removeUnwatedTokens, removeUnwatedProps, formatTokens2, groupByType);
|
|
3084
|
-
const tokens = processTokens(inlineTokens(isInlineTokens, dictionary.allTokens));
|
|
3085
|
-
const content = Object.entries(tokens).map(
|
|
3086
|
-
([name, token]) => `export const ${name} = ${JSON.stringify(token, null, 2).replace(/"([^"]+)":/g, "$1:")}
|
|
3087
|
-
`
|
|
3088
|
-
).join("\n");
|
|
3089
|
-
return fileHeader({ file }).then((fileHeaderText) => fileHeaderText + content);
|
|
3090
|
-
}
|
|
3091
|
-
};
|
|
3092
|
-
|
|
3093
|
-
// src/tokens/process/configs/storefront.ts
|
|
3094
|
-
var typescriptTokens = ({ "color-scheme": colorScheme2, theme }) => {
|
|
3095
|
-
return {
|
|
3096
|
-
preprocessors: ["tokens-studio"],
|
|
3097
|
-
platforms: {
|
|
3098
|
-
ts: {
|
|
3099
|
-
prefix,
|
|
3100
|
-
basePxFontSize,
|
|
3101
|
-
transforms: dsTransformers,
|
|
3102
|
-
buildPath: `${theme}/`,
|
|
3103
|
-
files: [
|
|
3104
|
-
{
|
|
3105
|
-
destination: `${colorScheme2}.ts`,
|
|
3106
|
-
format: jsTokens.name,
|
|
3107
|
-
filter: (token) => {
|
|
3108
|
-
if (pathStartsWithOneOf(["border-width", "letter-spacing", "border-radius"], token) && !R16.includes("semantic", token.filePath))
|
|
3109
|
-
return false;
|
|
3110
|
-
const isSemanticColor = R16.includes("semantic", token.filePath) && typeEquals(["color"], token);
|
|
3111
|
-
const wantedTypes = typeEquals(["shadow", "dimension", "typography", "opacity"], token);
|
|
3112
|
-
return isSemanticColor || wantedTypes;
|
|
3113
|
-
}
|
|
3114
|
-
}
|
|
3115
|
-
],
|
|
3116
|
-
options: {
|
|
3117
|
-
outputReferences: (token, options) => {
|
|
3118
|
-
const include = pathStartsWithOneOf(["border-radius"], token);
|
|
3119
|
-
const isWantedSize = pathStartsWithOneOf(["size", "_size"], token) && isDigit(token.path[1]);
|
|
3120
|
-
return (include || isWantedSize) && outputReferencesFilter2(token, options);
|
|
3121
|
-
}
|
|
3122
|
-
}
|
|
3123
|
-
}
|
|
3124
|
-
}
|
|
3125
|
-
};
|
|
3126
|
-
};
|
|
3127
|
-
|
|
3128
3071
|
// src/tokens/process/configs/typography.ts
|
|
3129
3072
|
import { expandTypesMap } from "@tokens-studio/sd-transforms";
|
|
3130
3073
|
var typographyVariables = ({ theme, typography: typography2 }) => {
|
|
@@ -3151,6 +3094,7 @@ var typographyVariables = ({ theme, typography: typography2 }) => {
|
|
|
3151
3094
|
sizeRem.name,
|
|
3152
3095
|
"ts/size/lineheight",
|
|
3153
3096
|
"ts/typography/fontWeight",
|
|
3097
|
+
"ts/size/css/letterspacing",
|
|
3154
3098
|
typographyName.name
|
|
3155
3099
|
],
|
|
3156
3100
|
files: [
|
|
@@ -3175,13 +3119,13 @@ var typographyVariables = ({ theme, typography: typography2 }) => {
|
|
|
3175
3119
|
// src/tokens/process/utils/getMultidimensionalThemes.ts
|
|
3176
3120
|
import chalk2 from "chalk";
|
|
3177
3121
|
import { kebabCase } from "change-case";
|
|
3178
|
-
import * as
|
|
3122
|
+
import * as R15 from "ramda";
|
|
3179
3123
|
var getMultidimensionalThemes = (processed$themes, dimensions) => {
|
|
3180
3124
|
const verboseLogging = buildOptions?.verbose;
|
|
3181
3125
|
const grouped$themes = groupThemes(processed$themes);
|
|
3182
3126
|
const permutations = permutateThemes(grouped$themes);
|
|
3183
3127
|
const ALL_DEPENDENT_ON = ["theme"];
|
|
3184
|
-
const keys2 =
|
|
3128
|
+
const keys2 = R15.keys(grouped$themes);
|
|
3185
3129
|
const nonDependentKeys = keys2.filter((x) => ![...ALL_DEPENDENT_ON, ...dimensions].includes(x));
|
|
3186
3130
|
if (verboseLogging) {
|
|
3187
3131
|
console.log(chalk2.cyan(`\u{1F50E} Finding theme permutations for ${dimensions}`));
|
|
@@ -3221,7 +3165,7 @@ function groupThemes(themes) {
|
|
|
3221
3165
|
}
|
|
3222
3166
|
return groups;
|
|
3223
3167
|
}
|
|
3224
|
-
var hasUnknownProps =
|
|
3168
|
+
var hasUnknownProps = R15.pipe(R15.values, R15.none(R15.equals("unknown")), R15.not);
|
|
3225
3169
|
function permutateThemes(groups) {
|
|
3226
3170
|
const separator = "_";
|
|
3227
3171
|
const permutations = cartesian(Object.values(groups));
|
|
@@ -3231,8 +3175,8 @@ function permutateThemes(groups) {
|
|
|
3231
3175
|
const { group, name, selectedTokenSets } = theme;
|
|
3232
3176
|
let updatedPermutation = acc.permutation;
|
|
3233
3177
|
if (group) {
|
|
3234
|
-
const groupProp =
|
|
3235
|
-
updatedPermutation =
|
|
3178
|
+
const groupProp = R15.lensProp(group);
|
|
3179
|
+
updatedPermutation = R15.set(groupProp, name, updatedPermutation);
|
|
3236
3180
|
}
|
|
3237
3181
|
const updatedName = `${String(acc.name)}${acc ? separator : ""}${name}`;
|
|
3238
3182
|
const sets = [...acc.selectedTokenSets, ...filterTokenSets(selectedTokenSets)];
|
|
@@ -3291,7 +3235,6 @@ StyleDictionary.registerTransform(sizeRem);
|
|
|
3291
3235
|
StyleDictionary.registerTransform(typographyName);
|
|
3292
3236
|
StyleDictionary.registerTransform(resolveMath);
|
|
3293
3237
|
StyleDictionary.registerTransform(unitless);
|
|
3294
|
-
StyleDictionary.registerFormat(jsTokens);
|
|
3295
3238
|
for (const format of Object.values(formats)) {
|
|
3296
3239
|
StyleDictionary.registerFormat(format);
|
|
3297
3240
|
}
|
|
@@ -3305,8 +3248,7 @@ var configs = {
|
|
|
3305
3248
|
warningColorVariables: colorCategoryVariables({ category: "builtin", color: "warning" }),
|
|
3306
3249
|
infoColorVariables: colorCategoryVariables({ category: "builtin", color: "info" }),
|
|
3307
3250
|
typographyVariables,
|
|
3308
|
-
semanticVariables
|
|
3309
|
-
typescriptTokens
|
|
3251
|
+
semanticVariables
|
|
3310
3252
|
};
|
|
3311
3253
|
var getConfigsForThemeDimensions = (getConfig, processed$themes, dimensions, options) => {
|
|
3312
3254
|
const { tokensDir, tokenSets } = options;
|
|
@@ -3322,7 +3264,7 @@ var getConfigsForThemeDimensions = (getConfig, processed$themes, dimensions, opt
|
|
|
3322
3264
|
obj.filePath = tokenSet;
|
|
3323
3265
|
}
|
|
3324
3266
|
});
|
|
3325
|
-
tokenSource.tokens =
|
|
3267
|
+
tokenSource.tokens = R16.mergeDeepRight(tokenSource.tokens, tokensWithFilePath);
|
|
3326
3268
|
}
|
|
3327
3269
|
}
|
|
3328
3270
|
} else {
|
|
@@ -3354,6 +3296,7 @@ var getConfigsForThemeDimensions = (getConfig, processed$themes, dimensions, opt
|
|
|
3354
3296
|
// src/tokens/process/platform.ts
|
|
3355
3297
|
var initResult = {
|
|
3356
3298
|
formatted: [],
|
|
3299
|
+
tokens: [],
|
|
3357
3300
|
permutation: {
|
|
3358
3301
|
"color-scheme": "",
|
|
3359
3302
|
"main-color": "",
|
|
@@ -3364,7 +3307,11 @@ var initResult = {
|
|
|
3364
3307
|
typography: ""
|
|
3365
3308
|
}
|
|
3366
3309
|
};
|
|
3367
|
-
var buildOptions
|
|
3310
|
+
var buildOptions = {
|
|
3311
|
+
verbose: false,
|
|
3312
|
+
processed$themes: [],
|
|
3313
|
+
buildTokenFormats: {}
|
|
3314
|
+
};
|
|
3368
3315
|
var sd = new StyleDictionary2();
|
|
3369
3316
|
var buildConfigs = {
|
|
3370
3317
|
typography: { getConfig: configs.typographyVariables, dimensions: ["typography"] },
|
|
@@ -3397,19 +3344,15 @@ var buildConfigs = {
|
|
|
3397
3344
|
log: ({ permutation: { theme } }) => `${theme} - info`
|
|
3398
3345
|
},
|
|
3399
3346
|
semantic: { getConfig: configs.semanticVariables, dimensions: ["semantic"] }
|
|
3400
|
-
// storefront: {
|
|
3401
|
-
// name: 'Storefront preview tokens',
|
|
3402
|
-
// getConfig: configs.typescriptTokens,
|
|
3403
|
-
// dimensions: ['color-scheme'],
|
|
3404
|
-
// options: { outPath: path.resolve('../../apps/storefront/tokens') },
|
|
3405
|
-
// enabled: () => buildOptions?.preview ?? false,
|
|
3406
|
-
// },
|
|
3407
3347
|
};
|
|
3408
3348
|
async function processPlatform(options) {
|
|
3409
3349
|
const { type, processed$themes } = options;
|
|
3410
3350
|
const platform = "css";
|
|
3411
3351
|
const tokenSets = type === "format" ? options.tokenSets : void 0;
|
|
3412
3352
|
const tokensDir = type === "build" ? options.tokensDir : void 0;
|
|
3353
|
+
const filteredProcessed$themes = processed$themes.filter(
|
|
3354
|
+
(theme) => R17.not(theme.group === "size" && theme.name !== "medium")
|
|
3355
|
+
);
|
|
3413
3356
|
const UNSAFE_DEFAULT_COLOR = process.env.UNSAFE_DEFAULT_COLOR ?? "";
|
|
3414
3357
|
if (UNSAFE_DEFAULT_COLOR) {
|
|
3415
3358
|
console.warn(
|
|
@@ -3432,19 +3375,16 @@ async function processPlatform(options) {
|
|
|
3432
3375
|
buildOptions = options;
|
|
3433
3376
|
buildOptions.defaultColor = UNSAFE_DEFAULT_COLOR;
|
|
3434
3377
|
buildOptions.colorGroups = colorGroups;
|
|
3435
|
-
const filteredProcessed$themes = processed$themes.filter(
|
|
3436
|
-
(theme) => R19.not(theme.group === "size" && theme.name !== "medium")
|
|
3437
|
-
);
|
|
3438
|
-
const customColors = getCustomColors(filteredProcessed$themes, colorGroups);
|
|
3439
3378
|
if (!buildOptions.defaultColor) {
|
|
3440
|
-
const
|
|
3379
|
+
const customColors = getCustomColors(filteredProcessed$themes, colorGroups);
|
|
3380
|
+
const firstMainColor = R17.head(customColors);
|
|
3441
3381
|
buildOptions.defaultColor = firstMainColor;
|
|
3442
3382
|
}
|
|
3443
3383
|
if (buildOptions.defaultColor) {
|
|
3444
3384
|
console.log(`
|
|
3445
3385
|
\u{1F3A8} Using ${chalk3.blue(buildOptions.defaultColor)} as default color`);
|
|
3446
3386
|
}
|
|
3447
|
-
const buildAndSdConfigs =
|
|
3387
|
+
const buildAndSdConfigs = R17.map((buildConfig) => {
|
|
3448
3388
|
const sdConfigs = getConfigsForThemeDimensions(
|
|
3449
3389
|
buildConfig.getConfig,
|
|
3450
3390
|
filteredProcessed$themes,
|
|
@@ -3480,7 +3420,7 @@ async function processPlatform(options) {
|
|
|
3480
3420
|
typography: [initResult]
|
|
3481
3421
|
};
|
|
3482
3422
|
try {
|
|
3483
|
-
for (const [buildName, { buildConfig, sdConfigs }] of
|
|
3423
|
+
for (const [buildName, { buildConfig, sdConfigs }] of R17.toPairs(buildAndSdConfigs)) {
|
|
3484
3424
|
if (!(buildConfig.enabled?.() ?? true)) {
|
|
3485
3425
|
continue;
|
|
3486
3426
|
}
|
|
@@ -3492,13 +3432,16 @@ async function processPlatform(options) {
|
|
|
3492
3432
|
const { config, permutation } = sdConfig;
|
|
3493
3433
|
const modes = ["theme", ...buildConfig.dimensions];
|
|
3494
3434
|
const modeMessage = modes.map((x) => permutation[x]).join(" - ");
|
|
3495
|
-
const logMessage =
|
|
3435
|
+
const logMessage = R17.isNil(buildConfig.log) ? modeMessage : buildConfig?.log(sdConfig);
|
|
3496
3436
|
console.log(logMessage);
|
|
3497
3437
|
const sdOptions = { cache: true };
|
|
3498
3438
|
const sdExtended = await sd.extend(config);
|
|
3439
|
+
const formatted = await sdExtended.formatPlatform(platform, sdOptions);
|
|
3440
|
+
const tokens = (await sdExtended.getPlatformTokens(platform, sdOptions)).allTokens;
|
|
3499
3441
|
const result = {
|
|
3500
3442
|
permutation,
|
|
3501
|
-
formatted
|
|
3443
|
+
formatted,
|
|
3444
|
+
tokens
|
|
3502
3445
|
};
|
|
3503
3446
|
return Promise.resolve(result);
|
|
3504
3447
|
})
|
|
@@ -3519,6 +3462,7 @@ async function processPlatform(options) {
|
|
|
3519
3462
|
var formatTokens = async (options) => {
|
|
3520
3463
|
const processedBuilds = await processPlatform({
|
|
3521
3464
|
type: "format",
|
|
3465
|
+
buildTokenFormats: {},
|
|
3522
3466
|
...options
|
|
3523
3467
|
});
|
|
3524
3468
|
return processedBuilds;
|
|
@@ -3530,15 +3474,14 @@ var formatTheme = async (themeConfig) => {
|
|
|
3530
3474
|
const processedBuilds = await formatTokens({
|
|
3531
3475
|
tokenSets,
|
|
3532
3476
|
processed$themes,
|
|
3533
|
-
verbose: false
|
|
3534
|
-
preview: false
|
|
3477
|
+
verbose: false
|
|
3535
3478
|
});
|
|
3536
3479
|
return processedBuilds;
|
|
3537
3480
|
};
|
|
3538
3481
|
var formatThemeCSS = async (themeConfig) => {
|
|
3539
3482
|
const processedBuilds = await formatTheme(themeConfig);
|
|
3540
3483
|
const themeCSSFiles = createThemeCSSFiles({ processedBuilds });
|
|
3541
|
-
return
|
|
3484
|
+
return R18.head(themeCSSFiles)?.output ?? "";
|
|
3542
3485
|
};
|
|
3543
3486
|
export {
|
|
3544
3487
|
formatTheme,
|