@digdir/designsystemet 1.1.2 → 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 +131 -187
- package/dist/src/index.js +89 -146
- 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 +99 -155
- package/dist/src/tokens/create/generators/$designsystemet.js +7 -7
- package/dist/src/tokens/create/write.js +7 -7
- 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 +89 -146
- package/dist/src/tokens/index.js +89 -146
- 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 +7 -7
- 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 +7 -7
- 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
package/dist/src/index.js
CHANGED
|
@@ -2232,7 +2232,7 @@ var createTokens = async (opts) => {
|
|
|
2232
2232
|
};
|
|
2233
2233
|
|
|
2234
2234
|
// src/tokens/format.ts
|
|
2235
|
-
import * as
|
|
2235
|
+
import * as R18 from "ramda";
|
|
2236
2236
|
|
|
2237
2237
|
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BoxShadowTypes.js
|
|
2238
2238
|
var BoxShadowTypes;
|
|
@@ -2572,11 +2572,11 @@ import * as R7 from "ramda";
|
|
|
2572
2572
|
// package.json
|
|
2573
2573
|
var package_default = {
|
|
2574
2574
|
name: "@digdir/designsystemet",
|
|
2575
|
-
version: "1.1.
|
|
2575
|
+
version: "1.1.4",
|
|
2576
2576
|
description: "CLI for Designsystemet",
|
|
2577
2577
|
author: "Designsystemet team",
|
|
2578
2578
|
engines: {
|
|
2579
|
-
node: ">=22.
|
|
2579
|
+
node: ">=22.17.0"
|
|
2580
2580
|
},
|
|
2581
2581
|
repository: {
|
|
2582
2582
|
type: "git",
|
|
@@ -2625,6 +2625,7 @@ var package_default = {
|
|
|
2625
2625
|
"digdir:tokens-build": "pnpm run designsystemet tokens build -t ../../internal/design-tokens -o ../../packages/theme/brand --clean --experimental-tailwind",
|
|
2626
2626
|
"digdir:tokens-create": "pnpm run designsystemet tokens create --config ./configs/digdir.config.json",
|
|
2627
2627
|
"update:template": "tsx ./src/scripts/update-template.ts",
|
|
2628
|
+
"update:preview-tokens": "tsx ./src/scripts/update-preview-tokens.ts",
|
|
2628
2629
|
"update:theme-digdir": "pnpm digdir:tokens-create && tsx ./src/scripts/update-design-tokens.ts && pnpm digdir:tokens-build",
|
|
2629
2630
|
verify: "pnpm test && pnpm update:template && pnpm update:theme-digdir && pnpm build:tokens"
|
|
2630
2631
|
},
|
|
@@ -2641,9 +2642,9 @@ var package_default = {
|
|
|
2641
2642
|
hsluv: "^1.0.1",
|
|
2642
2643
|
"object-hash": "^3.0.0",
|
|
2643
2644
|
postcss: "^8.5.6",
|
|
2644
|
-
ramda: "^0.
|
|
2645
|
-
"style-dictionary": "^5.0.
|
|
2646
|
-
zod: "^3.25.
|
|
2645
|
+
ramda: "^0.31.3",
|
|
2646
|
+
"style-dictionary": "^5.0.1",
|
|
2647
|
+
zod: "^3.25.74",
|
|
2647
2648
|
"zod-validation-error": "^3.5.2"
|
|
2648
2649
|
},
|
|
2649
2650
|
devDependencies: {
|
|
@@ -2651,8 +2652,7 @@ var package_default = {
|
|
|
2651
2652
|
"@types/apca-w3": "^0.1.3",
|
|
2652
2653
|
"@types/chroma-js": "^3.1.1",
|
|
2653
2654
|
"@types/fs-extra": "^11.0.4",
|
|
2654
|
-
"@types/
|
|
2655
|
-
"@types/node": "^22.15.32",
|
|
2655
|
+
"@types/node": "^22.16.0",
|
|
2656
2656
|
"@types/object-hash": "^3.0.6",
|
|
2657
2657
|
"@types/ramda": "^0.30.2",
|
|
2658
2658
|
"fs-extra": "^11.3.0",
|
|
@@ -2667,7 +2667,7 @@ var package_default = {
|
|
|
2667
2667
|
var defaultFileHeader = `build: v${package_default.version}`;
|
|
2668
2668
|
var createThemeCSSFiles = ({
|
|
2669
2669
|
processedBuilds,
|
|
2670
|
-
fileHeader
|
|
2670
|
+
fileHeader = defaultFileHeader
|
|
2671
2671
|
}) => {
|
|
2672
2672
|
const groupedByTheme = {};
|
|
2673
2673
|
for (const [_, buildResults] of Object.entries(processedBuilds)) {
|
|
@@ -2714,7 +2714,7 @@ order may change due to nondeterminism.`.trim()
|
|
|
2714
2714
|
});
|
|
2715
2715
|
const header = `@charset "UTF-8";
|
|
2716
2716
|
/*
|
|
2717
|
-
${
|
|
2717
|
+
${fileHeader}
|
|
2718
2718
|
*/
|
|
2719
2719
|
|
|
2720
2720
|
`;
|
|
@@ -2736,7 +2736,7 @@ ${fileHeader2}
|
|
|
2736
2736
|
|
|
2737
2737
|
// src/tokens/process/platform.ts
|
|
2738
2738
|
import chalk3 from "chalk";
|
|
2739
|
-
import * as
|
|
2739
|
+
import * as R17 from "ramda";
|
|
2740
2740
|
import StyleDictionary2 from "style-dictionary";
|
|
2741
2741
|
|
|
2742
2742
|
// src/tokens/types.ts
|
|
@@ -2747,7 +2747,7 @@ var colorCategories = {
|
|
|
2747
2747
|
|
|
2748
2748
|
// src/tokens/process/configs.ts
|
|
2749
2749
|
import { register } from "@tokens-studio/sd-transforms";
|
|
2750
|
-
import * as
|
|
2750
|
+
import * as R16 from "ramda";
|
|
2751
2751
|
import StyleDictionary from "style-dictionary";
|
|
2752
2752
|
|
|
2753
2753
|
// src/tokens/utils.ts
|
|
@@ -2858,7 +2858,11 @@ var colorScheme = {
|
|
|
2858
2858
|
(t) => !isColorCategoryToken(t)
|
|
2859
2859
|
])
|
|
2860
2860
|
);
|
|
2861
|
-
const
|
|
2861
|
+
const formattedMap = filteredAllTokens.map((token) => ({
|
|
2862
|
+
token,
|
|
2863
|
+
formatted: format(token)
|
|
2864
|
+
}));
|
|
2865
|
+
const formattedTokens = formattedMap.map(R9.view(R9.lensProp("formatted"))).join("\n");
|
|
2862
2866
|
const content = `{
|
|
2863
2867
|
${formattedTokens}
|
|
2864
2868
|
${colorSchemeProperty}}
|
|
@@ -2876,7 +2880,8 @@ var colorCategory = {
|
|
|
2876
2880
|
name: "ds/css-colorcategory",
|
|
2877
2881
|
format: async ({ dictionary, options, platform }) => {
|
|
2878
2882
|
const { outputReferences, usesDtcg } = options;
|
|
2879
|
-
const { selector, layer } = platform;
|
|
2883
|
+
const { selector, layer, files } = platform;
|
|
2884
|
+
const destination = files?.[0]?.destination;
|
|
2880
2885
|
const format = R9.compose(
|
|
2881
2886
|
createPropertyFormatter({
|
|
2882
2887
|
outputReferences,
|
|
@@ -2893,7 +2898,12 @@ var colorCategory = {
|
|
|
2893
2898
|
}
|
|
2894
2899
|
})
|
|
2895
2900
|
);
|
|
2896
|
-
const
|
|
2901
|
+
const formattedMap = dictionary.allTokens.map((token) => ({
|
|
2902
|
+
token,
|
|
2903
|
+
formatted: format(token)
|
|
2904
|
+
}));
|
|
2905
|
+
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
2906
|
+
const formattedTokens = formattedMap.map(R9.view(R9.lensProp("formatted"))).join("\n");
|
|
2897
2907
|
const content = `{
|
|
2898
2908
|
${formattedTokens}
|
|
2899
2909
|
}
|
|
@@ -2924,30 +2934,30 @@ var overrideSizingFormula = (format, token) => {
|
|
|
2924
2934
|
calc
|
|
2925
2935
|
};
|
|
2926
2936
|
};
|
|
2927
|
-
var formatSizingTokens = (format, tokens) =>
|
|
2928
|
-
|
|
2929
|
-
(
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2937
|
+
var formatSizingTokens = (format, tokens) => R10.reduce(
|
|
2938
|
+
(acc, token) => {
|
|
2939
|
+
const { round, calc, name } = overrideSizingFormula(format, token);
|
|
2940
|
+
return {
|
|
2941
|
+
tokens: [...acc.tokens, token],
|
|
2942
|
+
round: [...acc.round, `${name}: ${round};`],
|
|
2943
|
+
calc: [...acc.calc, `${name}: ${calc};`]
|
|
2944
|
+
};
|
|
2945
|
+
},
|
|
2946
|
+
{ tokens: [], round: [], calc: [] },
|
|
2947
|
+
tokens
|
|
2948
|
+
);
|
|
2949
|
+
var sizingTemplate = ({ round, calc }) => `
|
|
2940
2950
|
${calc.join("\n")}
|
|
2941
2951
|
|
|
2942
2952
|
@supports (width: round(down, .1em, 1px)) {
|
|
2943
2953
|
${round.join("\n")}
|
|
2944
2954
|
}`;
|
|
2945
|
-
};
|
|
2946
2955
|
var semantic = {
|
|
2947
2956
|
name: "ds/css-semantic",
|
|
2948
2957
|
format: async ({ dictionary, options, platform }) => {
|
|
2949
2958
|
const { outputReferences, usesDtcg } = options;
|
|
2950
|
-
const { selector, layer } = platform;
|
|
2959
|
+
const { selector, layer, files } = platform;
|
|
2960
|
+
const destination = files?.[0]?.destination;
|
|
2951
2961
|
const format = createPropertyFormatter2({
|
|
2952
2962
|
outputReferences,
|
|
2953
2963
|
dictionary,
|
|
@@ -2960,7 +2970,18 @@ var semantic = {
|
|
|
2960
2970
|
(t) => pathStartsWithOneOf(["_size"], t) && isDigit(t.path[1]),
|
|
2961
2971
|
filteredTokens
|
|
2962
2972
|
);
|
|
2963
|
-
const
|
|
2973
|
+
const formattedSizingTokens = formatSizingTokens(format, sizingTokens);
|
|
2974
|
+
const formattedMap = restTokens.map((token) => ({
|
|
2975
|
+
token,
|
|
2976
|
+
formatted: format(token)
|
|
2977
|
+
}));
|
|
2978
|
+
const formattedSizingMap = formattedSizingTokens.round.map((t, i) => ({
|
|
2979
|
+
token: formattedSizingTokens.tokens[i],
|
|
2980
|
+
formatted: t
|
|
2981
|
+
}));
|
|
2982
|
+
buildOptions.buildTokenFormats[destination] = [...formattedMap, ...formattedSizingMap];
|
|
2983
|
+
const sizingSnippet = sizingTemplate(formattedSizingTokens);
|
|
2984
|
+
const formattedTokens = formattedMap.map(R10.view(R10.lensProp("formatted"))).concat(sizingSnippet);
|
|
2964
2985
|
const content = `{
|
|
2965
2986
|
${formattedTokens.join("\n")}
|
|
2966
2987
|
}
|
|
@@ -2985,7 +3006,8 @@ var typography = {
|
|
|
2985
3006
|
name: "ds/css-typography",
|
|
2986
3007
|
format: async ({ dictionary, options, platform }) => {
|
|
2987
3008
|
const { outputReferences, usesDtcg } = options;
|
|
2988
|
-
const { selector, layer } = platform;
|
|
3009
|
+
const { selector, layer, files } = platform;
|
|
3010
|
+
const destination = files?.[0]?.destination;
|
|
2989
3011
|
const format = createPropertyFormatter3({
|
|
2990
3012
|
outputReferences,
|
|
2991
3013
|
dictionary,
|
|
@@ -2993,7 +3015,12 @@ var typography = {
|
|
|
2993
3015
|
usesDtcg
|
|
2994
3016
|
});
|
|
2995
3017
|
const filteredTokens = R11.reject(typographyFontFamilyPredicate, dictionary.allTokens);
|
|
2996
|
-
const
|
|
3018
|
+
const formattedMap = filteredTokens.map((token) => ({
|
|
3019
|
+
token,
|
|
3020
|
+
formatted: format(token)
|
|
3021
|
+
}));
|
|
3022
|
+
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
3023
|
+
const formattedTokens = formattedMap.map(R11.view(R11.lensProp("formatted"))).join("\n");
|
|
2997
3024
|
const content = selector ? `${selector} {
|
|
2998
3025
|
${formattedTokens}
|
|
2999
3026
|
}` : formattedTokens;
|
|
@@ -3200,90 +3227,6 @@ var semanticVariables = ({ theme }) => {
|
|
|
3200
3227
|
};
|
|
3201
3228
|
};
|
|
3202
3229
|
|
|
3203
|
-
// src/tokens/process/configs/storefront.ts
|
|
3204
|
-
import * as R16 from "ramda";
|
|
3205
|
-
import { outputReferencesFilter as outputReferencesFilter2 } from "style-dictionary/utils";
|
|
3206
|
-
|
|
3207
|
-
// src/tokens/process/formats/js-tokens.ts
|
|
3208
|
-
import * as R15 from "ramda";
|
|
3209
|
-
import { createPropertyFormatter as createPropertyFormatter4, fileHeader } from "style-dictionary/utils";
|
|
3210
|
-
var groupByType = R15.groupBy((token) => getType(token));
|
|
3211
|
-
var removeUnwatedTokens = R15.pipe(
|
|
3212
|
-
R15.reject((token) => isColorCategoryToken(token)),
|
|
3213
|
-
R15.reject((token) => R15.any((path) => path.startsWith("_"))(token.path))
|
|
3214
|
-
);
|
|
3215
|
-
var dissocExtensions = R15.pipe(R15.dissoc("$extensions"), R15.dissocPath(["original", "$extensions"]));
|
|
3216
|
-
var removeUnwatedProps = R15.map((token) => dissocExtensions(token));
|
|
3217
|
-
var toCssVarName = R15.pipe(R15.split(":"), R15.head, R15.trim);
|
|
3218
|
-
var jsTokens = {
|
|
3219
|
-
name: "ds/js-tokens",
|
|
3220
|
-
format: async ({ dictionary, file, options }) => {
|
|
3221
|
-
const { usesDtcg, outputReferences } = options;
|
|
3222
|
-
const format = createPropertyFormatter4({
|
|
3223
|
-
outputReferences,
|
|
3224
|
-
dictionary,
|
|
3225
|
-
format: "css",
|
|
3226
|
-
usesDtcg
|
|
3227
|
-
});
|
|
3228
|
-
const formatTokens2 = R15.map((token) => {
|
|
3229
|
-
if (pathStartsWithOneOf(["size", "_size"], token)) {
|
|
3230
|
-
const { calc, name } = overrideSizingFormula(format, token);
|
|
3231
|
-
return {
|
|
3232
|
-
...token,
|
|
3233
|
-
name: name.trim(),
|
|
3234
|
-
$value: calc.trim()
|
|
3235
|
-
};
|
|
3236
|
-
}
|
|
3237
|
-
return {
|
|
3238
|
-
...token,
|
|
3239
|
-
name: toCssVarName(format(token))
|
|
3240
|
-
};
|
|
3241
|
-
});
|
|
3242
|
-
const processTokens = R15.pipe(removeUnwatedTokens, removeUnwatedProps, formatTokens2, groupByType);
|
|
3243
|
-
const tokens = processTokens(inlineTokens(isInlineTokens, dictionary.allTokens));
|
|
3244
|
-
const content = Object.entries(tokens).map(
|
|
3245
|
-
([name, token]) => `export const ${name} = ${JSON.stringify(token, null, 2).replace(/"([^"]+)":/g, "$1:")}
|
|
3246
|
-
`
|
|
3247
|
-
).join("\n");
|
|
3248
|
-
return fileHeader({ file }).then((fileHeaderText) => fileHeaderText + content);
|
|
3249
|
-
}
|
|
3250
|
-
};
|
|
3251
|
-
|
|
3252
|
-
// src/tokens/process/configs/storefront.ts
|
|
3253
|
-
var typescriptTokens = ({ "color-scheme": colorScheme2, theme }) => {
|
|
3254
|
-
return {
|
|
3255
|
-
preprocessors: ["tokens-studio"],
|
|
3256
|
-
platforms: {
|
|
3257
|
-
ts: {
|
|
3258
|
-
prefix,
|
|
3259
|
-
basePxFontSize,
|
|
3260
|
-
transforms: dsTransformers,
|
|
3261
|
-
buildPath: `${theme}/`,
|
|
3262
|
-
files: [
|
|
3263
|
-
{
|
|
3264
|
-
destination: `${colorScheme2}.ts`,
|
|
3265
|
-
format: jsTokens.name,
|
|
3266
|
-
filter: (token) => {
|
|
3267
|
-
if (pathStartsWithOneOf(["border-width", "letter-spacing", "border-radius"], token) && !R16.includes("semantic", token.filePath))
|
|
3268
|
-
return false;
|
|
3269
|
-
const isSemanticColor = R16.includes("semantic", token.filePath) && typeEquals(["color"], token);
|
|
3270
|
-
const wantedTypes = typeEquals(["shadow", "dimension", "typography", "opacity"], token);
|
|
3271
|
-
return isSemanticColor || wantedTypes;
|
|
3272
|
-
}
|
|
3273
|
-
}
|
|
3274
|
-
],
|
|
3275
|
-
options: {
|
|
3276
|
-
outputReferences: (token, options) => {
|
|
3277
|
-
const include = pathStartsWithOneOf(["border-radius"], token);
|
|
3278
|
-
const isWantedSize = pathStartsWithOneOf(["size", "_size"], token) && isDigit(token.path[1]);
|
|
3279
|
-
return (include || isWantedSize) && outputReferencesFilter2(token, options);
|
|
3280
|
-
}
|
|
3281
|
-
}
|
|
3282
|
-
}
|
|
3283
|
-
}
|
|
3284
|
-
};
|
|
3285
|
-
};
|
|
3286
|
-
|
|
3287
3230
|
// src/tokens/process/configs/typography.ts
|
|
3288
3231
|
import { expandTypesMap } from "@tokens-studio/sd-transforms";
|
|
3289
3232
|
var typographyVariables = ({ theme, typography: typography2 }) => {
|
|
@@ -3310,6 +3253,7 @@ var typographyVariables = ({ theme, typography: typography2 }) => {
|
|
|
3310
3253
|
sizeRem.name,
|
|
3311
3254
|
"ts/size/lineheight",
|
|
3312
3255
|
"ts/typography/fontWeight",
|
|
3256
|
+
"ts/size/css/letterspacing",
|
|
3313
3257
|
typographyName.name
|
|
3314
3258
|
],
|
|
3315
3259
|
files: [
|
|
@@ -3334,13 +3278,13 @@ var typographyVariables = ({ theme, typography: typography2 }) => {
|
|
|
3334
3278
|
// src/tokens/process/utils/getMultidimensionalThemes.ts
|
|
3335
3279
|
import chalk2 from "chalk";
|
|
3336
3280
|
import { kebabCase } from "change-case";
|
|
3337
|
-
import * as
|
|
3281
|
+
import * as R15 from "ramda";
|
|
3338
3282
|
var getMultidimensionalThemes = (processed$themes, dimensions) => {
|
|
3339
3283
|
const verboseLogging = buildOptions?.verbose;
|
|
3340
3284
|
const grouped$themes = groupThemes(processed$themes);
|
|
3341
3285
|
const permutations = permutateThemes(grouped$themes);
|
|
3342
3286
|
const ALL_DEPENDENT_ON = ["theme"];
|
|
3343
|
-
const keys2 =
|
|
3287
|
+
const keys2 = R15.keys(grouped$themes);
|
|
3344
3288
|
const nonDependentKeys = keys2.filter((x) => ![...ALL_DEPENDENT_ON, ...dimensions].includes(x));
|
|
3345
3289
|
if (verboseLogging) {
|
|
3346
3290
|
console.log(chalk2.cyan(`\u{1F50E} Finding theme permutations for ${dimensions}`));
|
|
@@ -3380,7 +3324,7 @@ function groupThemes(themes) {
|
|
|
3380
3324
|
}
|
|
3381
3325
|
return groups;
|
|
3382
3326
|
}
|
|
3383
|
-
var hasUnknownProps =
|
|
3327
|
+
var hasUnknownProps = R15.pipe(R15.values, R15.none(R15.equals("unknown")), R15.not);
|
|
3384
3328
|
function permutateThemes(groups) {
|
|
3385
3329
|
const separator = "_";
|
|
3386
3330
|
const permutations = cartesian(Object.values(groups));
|
|
@@ -3390,8 +3334,8 @@ function permutateThemes(groups) {
|
|
|
3390
3334
|
const { group, name, selectedTokenSets } = theme;
|
|
3391
3335
|
let updatedPermutation = acc.permutation;
|
|
3392
3336
|
if (group) {
|
|
3393
|
-
const groupProp =
|
|
3394
|
-
updatedPermutation =
|
|
3337
|
+
const groupProp = R15.lensProp(group);
|
|
3338
|
+
updatedPermutation = R15.set(groupProp, name, updatedPermutation);
|
|
3395
3339
|
}
|
|
3396
3340
|
const updatedName = `${String(acc.name)}${acc ? separator : ""}${name}`;
|
|
3397
3341
|
const sets = [...acc.selectedTokenSets, ...filterTokenSets(selectedTokenSets)];
|
|
@@ -3450,7 +3394,6 @@ StyleDictionary.registerTransform(sizeRem);
|
|
|
3450
3394
|
StyleDictionary.registerTransform(typographyName);
|
|
3451
3395
|
StyleDictionary.registerTransform(resolveMath);
|
|
3452
3396
|
StyleDictionary.registerTransform(unitless);
|
|
3453
|
-
StyleDictionary.registerFormat(jsTokens);
|
|
3454
3397
|
for (const format of Object.values(formats)) {
|
|
3455
3398
|
StyleDictionary.registerFormat(format);
|
|
3456
3399
|
}
|
|
@@ -3464,8 +3407,7 @@ var configs = {
|
|
|
3464
3407
|
warningColorVariables: colorCategoryVariables({ category: "builtin", color: "warning" }),
|
|
3465
3408
|
infoColorVariables: colorCategoryVariables({ category: "builtin", color: "info" }),
|
|
3466
3409
|
typographyVariables,
|
|
3467
|
-
semanticVariables
|
|
3468
|
-
typescriptTokens
|
|
3410
|
+
semanticVariables
|
|
3469
3411
|
};
|
|
3470
3412
|
var getConfigsForThemeDimensions = (getConfig, processed$themes, dimensions, options) => {
|
|
3471
3413
|
const { tokensDir, tokenSets } = options;
|
|
@@ -3481,7 +3423,7 @@ var getConfigsForThemeDimensions = (getConfig, processed$themes, dimensions, opt
|
|
|
3481
3423
|
obj.filePath = tokenSet;
|
|
3482
3424
|
}
|
|
3483
3425
|
});
|
|
3484
|
-
tokenSource.tokens =
|
|
3426
|
+
tokenSource.tokens = R16.mergeDeepRight(tokenSource.tokens, tokensWithFilePath);
|
|
3485
3427
|
}
|
|
3486
3428
|
}
|
|
3487
3429
|
} else {
|
|
@@ -3513,6 +3455,7 @@ var getConfigsForThemeDimensions = (getConfig, processed$themes, dimensions, opt
|
|
|
3513
3455
|
// src/tokens/process/platform.ts
|
|
3514
3456
|
var initResult = {
|
|
3515
3457
|
formatted: [],
|
|
3458
|
+
tokens: [],
|
|
3516
3459
|
permutation: {
|
|
3517
3460
|
"color-scheme": "",
|
|
3518
3461
|
"main-color": "",
|
|
@@ -3523,7 +3466,11 @@ var initResult = {
|
|
|
3523
3466
|
typography: ""
|
|
3524
3467
|
}
|
|
3525
3468
|
};
|
|
3526
|
-
var buildOptions
|
|
3469
|
+
var buildOptions = {
|
|
3470
|
+
verbose: false,
|
|
3471
|
+
processed$themes: [],
|
|
3472
|
+
buildTokenFormats: {}
|
|
3473
|
+
};
|
|
3527
3474
|
var sd = new StyleDictionary2();
|
|
3528
3475
|
var buildConfigs = {
|
|
3529
3476
|
typography: { getConfig: configs.typographyVariables, dimensions: ["typography"] },
|
|
@@ -3556,19 +3503,15 @@ var buildConfigs = {
|
|
|
3556
3503
|
log: ({ permutation: { theme } }) => `${theme} - info`
|
|
3557
3504
|
},
|
|
3558
3505
|
semantic: { getConfig: configs.semanticVariables, dimensions: ["semantic"] }
|
|
3559
|
-
// storefront: {
|
|
3560
|
-
// name: 'Storefront preview tokens',
|
|
3561
|
-
// getConfig: configs.typescriptTokens,
|
|
3562
|
-
// dimensions: ['color-scheme'],
|
|
3563
|
-
// options: { outPath: path.resolve('../../apps/storefront/tokens') },
|
|
3564
|
-
// enabled: () => buildOptions?.preview ?? false,
|
|
3565
|
-
// },
|
|
3566
3506
|
};
|
|
3567
3507
|
async function processPlatform(options) {
|
|
3568
3508
|
const { type, processed$themes } = options;
|
|
3569
3509
|
const platform = "css";
|
|
3570
3510
|
const tokenSets = type === "format" ? options.tokenSets : void 0;
|
|
3571
3511
|
const tokensDir = type === "build" ? options.tokensDir : void 0;
|
|
3512
|
+
const filteredProcessed$themes = processed$themes.filter(
|
|
3513
|
+
(theme) => R17.not(theme.group === "size" && theme.name !== "medium")
|
|
3514
|
+
);
|
|
3572
3515
|
const UNSAFE_DEFAULT_COLOR = process.env.UNSAFE_DEFAULT_COLOR ?? "";
|
|
3573
3516
|
if (UNSAFE_DEFAULT_COLOR) {
|
|
3574
3517
|
console.warn(
|
|
@@ -3591,19 +3534,16 @@ async function processPlatform(options) {
|
|
|
3591
3534
|
buildOptions = options;
|
|
3592
3535
|
buildOptions.defaultColor = UNSAFE_DEFAULT_COLOR;
|
|
3593
3536
|
buildOptions.colorGroups = colorGroups;
|
|
3594
|
-
const filteredProcessed$themes = processed$themes.filter(
|
|
3595
|
-
(theme) => R19.not(theme.group === "size" && theme.name !== "medium")
|
|
3596
|
-
);
|
|
3597
|
-
const customColors = getCustomColors(filteredProcessed$themes, colorGroups);
|
|
3598
3537
|
if (!buildOptions.defaultColor) {
|
|
3599
|
-
const
|
|
3538
|
+
const customColors = getCustomColors(filteredProcessed$themes, colorGroups);
|
|
3539
|
+
const firstMainColor = R17.head(customColors);
|
|
3600
3540
|
buildOptions.defaultColor = firstMainColor;
|
|
3601
3541
|
}
|
|
3602
3542
|
if (buildOptions.defaultColor) {
|
|
3603
3543
|
console.log(`
|
|
3604
3544
|
\u{1F3A8} Using ${chalk3.blue(buildOptions.defaultColor)} as default color`);
|
|
3605
3545
|
}
|
|
3606
|
-
const buildAndSdConfigs =
|
|
3546
|
+
const buildAndSdConfigs = R17.map((buildConfig) => {
|
|
3607
3547
|
const sdConfigs = getConfigsForThemeDimensions(
|
|
3608
3548
|
buildConfig.getConfig,
|
|
3609
3549
|
filteredProcessed$themes,
|
|
@@ -3639,7 +3579,7 @@ async function processPlatform(options) {
|
|
|
3639
3579
|
typography: [initResult]
|
|
3640
3580
|
};
|
|
3641
3581
|
try {
|
|
3642
|
-
for (const [buildName, { buildConfig, sdConfigs }] of
|
|
3582
|
+
for (const [buildName, { buildConfig, sdConfigs }] of R17.toPairs(buildAndSdConfigs)) {
|
|
3643
3583
|
if (!(buildConfig.enabled?.() ?? true)) {
|
|
3644
3584
|
continue;
|
|
3645
3585
|
}
|
|
@@ -3651,13 +3591,16 @@ async function processPlatform(options) {
|
|
|
3651
3591
|
const { config, permutation } = sdConfig;
|
|
3652
3592
|
const modes = ["theme", ...buildConfig.dimensions];
|
|
3653
3593
|
const modeMessage = modes.map((x) => permutation[x]).join(" - ");
|
|
3654
|
-
const logMessage =
|
|
3594
|
+
const logMessage = R17.isNil(buildConfig.log) ? modeMessage : buildConfig?.log(sdConfig);
|
|
3655
3595
|
console.log(logMessage);
|
|
3656
3596
|
const sdOptions = { cache: true };
|
|
3657
3597
|
const sdExtended = await sd.extend(config);
|
|
3598
|
+
const formatted = await sdExtended.formatPlatform(platform, sdOptions);
|
|
3599
|
+
const tokens = (await sdExtended.getPlatformTokens(platform, sdOptions)).allTokens;
|
|
3658
3600
|
const result = {
|
|
3659
3601
|
permutation,
|
|
3660
|
-
formatted
|
|
3602
|
+
formatted,
|
|
3603
|
+
tokens
|
|
3661
3604
|
};
|
|
3662
3605
|
return Promise.resolve(result);
|
|
3663
3606
|
})
|
|
@@ -3678,6 +3621,7 @@ async function processPlatform(options) {
|
|
|
3678
3621
|
var formatTokens = async (options) => {
|
|
3679
3622
|
const processedBuilds = await processPlatform({
|
|
3680
3623
|
type: "format",
|
|
3624
|
+
buildTokenFormats: {},
|
|
3681
3625
|
...options
|
|
3682
3626
|
});
|
|
3683
3627
|
return processedBuilds;
|
|
@@ -3689,15 +3633,14 @@ var formatTheme = async (themeConfig) => {
|
|
|
3689
3633
|
const processedBuilds = await formatTokens({
|
|
3690
3634
|
tokenSets,
|
|
3691
3635
|
processed$themes,
|
|
3692
|
-
verbose: false
|
|
3693
|
-
preview: false
|
|
3636
|
+
verbose: false
|
|
3694
3637
|
});
|
|
3695
3638
|
return processedBuilds;
|
|
3696
3639
|
};
|
|
3697
3640
|
var formatThemeCSS = async (themeConfig) => {
|
|
3698
3641
|
const processedBuilds = await formatTheme(themeConfig);
|
|
3699
3642
|
const themeCSSFiles = createThemeCSSFiles({ processedBuilds });
|
|
3700
|
-
return
|
|
3643
|
+
return R18.head(themeCSSFiles)?.output ?? "";
|
|
3701
3644
|
};
|
|
3702
3645
|
export {
|
|
3703
3646
|
HSLToHex,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-preview-tokens.d.ts","sourceRoot":"","sources":["../../../src/scripts/update-preview-tokens.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAc,KAAK,EAAE,MAAM,oBAAoB,CAAC;AA8B5D,eAAO,MAAM,WAAW,GAAU,aAAa,KAAK,kBAqEnD,CAAC"}
|