@digdir/designsystemet 1.0.8 → 1.1.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.
Files changed (65) hide show
  1. package/dist/bin/config.d.ts +3 -3
  2. package/dist/bin/config.d.ts.map +1 -1
  3. package/dist/bin/config.js +45 -45
  4. package/dist/bin/designsystemet.js +827 -748
  5. package/dist/config.schema.json +4 -4
  6. package/dist/src/colors/index.d.ts +2 -2
  7. package/dist/src/colors/index.d.ts.map +1 -1
  8. package/dist/src/colors/index.js +143 -143
  9. package/dist/src/colors/theme.d.ts +1 -2
  10. package/dist/src/colors/theme.d.ts.map +1 -1
  11. package/dist/src/config.d.ts +6 -21
  12. package/dist/src/config.d.ts.map +1 -1
  13. package/dist/src/config.js +43 -40
  14. package/dist/src/index.js +418 -430
  15. package/dist/src/scripts/createJsonSchema.js +23 -24
  16. package/dist/src/scripts/update-template.d.ts.map +1 -1
  17. package/dist/src/tokens/build.d.ts +1 -1
  18. package/dist/src/tokens/build.d.ts.map +1 -1
  19. package/dist/src/tokens/build.js +359 -280
  20. package/dist/src/tokens/create/generators/$designsystemet.js +16 -15
  21. package/dist/src/tokens/create/generators/color.js +21 -21
  22. package/dist/src/tokens/create/write.js +17 -16
  23. package/dist/src/tokens/create.d.ts +1 -0
  24. package/dist/src/tokens/create.d.ts.map +1 -1
  25. package/dist/src/tokens/create.js +22 -21
  26. package/dist/src/tokens/format.d.ts.map +1 -1
  27. package/dist/src/tokens/format.js +931 -944
  28. package/dist/src/tokens/index.d.ts +2 -2
  29. package/dist/src/tokens/index.d.ts.map +1 -1
  30. package/dist/src/tokens/index.js +295 -307
  31. package/dist/src/tokens/process/configs/color.d.ts.map +1 -1
  32. package/dist/src/tokens/process/configs/color.js +5 -5
  33. package/dist/src/tokens/process/configs/semantic.d.ts.map +1 -1
  34. package/dist/src/tokens/process/configs/semantic.js +5 -5
  35. package/dist/src/tokens/process/configs/storefront.d.ts.map +1 -1
  36. package/dist/src/tokens/process/configs/storefront.js +1 -1
  37. package/dist/src/tokens/process/configs/typography.d.ts.map +1 -1
  38. package/dist/src/tokens/process/configs/typography.js +5 -5
  39. package/dist/src/tokens/process/configs.d.ts.map +1 -1
  40. package/dist/src/tokens/process/configs.js +5 -5
  41. package/dist/src/tokens/process/formats/css/color.js +2 -2
  42. package/dist/src/tokens/process/formats/css/semantic.js +2 -2
  43. package/dist/src/tokens/process/formats/css/typography.js +1 -1
  44. package/dist/src/tokens/process/formats/css.js +5 -5
  45. package/dist/src/tokens/process/formats/js-tokens.js +1 -1
  46. package/dist/src/tokens/process/output/declarations.d.ts +4 -0
  47. package/dist/src/tokens/process/output/declarations.d.ts.map +1 -0
  48. package/dist/src/tokens/process/output/declarations.js +860 -0
  49. package/dist/src/tokens/process/output/tailwind.d.ts +3 -0
  50. package/dist/src/tokens/process/output/tailwind.d.ts.map +1 -0
  51. package/dist/src/tokens/process/output/tailwind.js +59 -0
  52. package/dist/src/tokens/process/{theme.d.ts → output/theme.d.ts} +2 -2
  53. package/dist/src/tokens/process/output/theme.d.ts.map +1 -0
  54. package/dist/src/tokens/process/{theme.js → output/theme.js} +20 -19
  55. package/dist/src/tokens/process/platform.d.ts +8 -4
  56. package/dist/src/tokens/process/platform.d.ts.map +1 -1
  57. package/dist/src/tokens/process/platform.js +27 -56
  58. package/dist/src/tokens/process/utils/getMultidimensionalThemes.d.ts +1 -0
  59. package/dist/src/tokens/process/utils/getMultidimensionalThemes.d.ts.map +1 -1
  60. package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +12 -5
  61. package/dist/src/tokens/types.d.ts +1 -1
  62. package/dist/src/tokens/types.d.ts.map +1 -1
  63. package/dist/src/tokens/utils.d.ts.map +1 -1
  64. package/package.json +16 -15
  65. package/dist/src/tokens/process/theme.d.ts.map +0 -1
@@ -992,27 +992,6 @@ var getDefaultToken = (tokenPath) => {
992
992
  // src/tokens/create/generators/color.ts
993
993
  import * as R4 from "ramda";
994
994
 
995
- // src/colors/utils.ts
996
- import chroma from "chroma-js";
997
- import Colorjs from "colorjs.io";
998
- import { Hsluv } from "hsluv";
999
- var getLuminanceFromLightness = (lightness) => {
1000
- const conv = new Hsluv();
1001
- conv.hsluv_l = lightness;
1002
- conv.hsluvToHex();
1003
- return chroma(conv.hex).luminance();
1004
- };
1005
- var getLightnessFromHex = (hex) => {
1006
- const conv = new Hsluv();
1007
- conv.hex = hex;
1008
- conv.hexToHsluv();
1009
- return conv.hsluv_l;
1010
- };
1011
-
1012
- // src/colors/theme.ts
1013
- import chroma2 from "chroma-js";
1014
- import * as R3 from "ramda";
1015
-
1016
995
  // src/colors/colorMetadata.ts
1017
996
  import * as R2 from "ramda";
1018
997
  var baseColors = {
@@ -1266,6 +1245,27 @@ var colorMetadata = {
1266
1245
  };
1267
1246
  var colorMetadataByNumber = R2.indexBy((metadata) => metadata.number, Object.values(colorMetadata));
1268
1247
 
1248
+ // src/colors/theme.ts
1249
+ import chroma2 from "chroma-js";
1250
+ import * as R3 from "ramda";
1251
+
1252
+ // src/colors/utils.ts
1253
+ import chroma from "chroma-js";
1254
+ import Colorjs from "colorjs.io";
1255
+ import { Hsluv } from "hsluv";
1256
+ var getLuminanceFromLightness = (lightness) => {
1257
+ const conv = new Hsluv();
1258
+ conv.hsluv_l = lightness;
1259
+ conv.hsluvToHex();
1260
+ return chroma(conv.hex).luminance();
1261
+ };
1262
+ var getLightnessFromHex = (hex) => {
1263
+ const conv = new Hsluv();
1264
+ conv.hex = hex;
1265
+ conv.hexToHsluv();
1266
+ return conv.hsluv_l;
1267
+ };
1268
+
1269
1269
  // src/colors/theme.ts
1270
1270
  var generateColorScale = (color, colorScheme2) => {
1271
1271
  let interpolationColor = color;
@@ -2043,6 +2043,7 @@ var generateTypography = (themeName, { fontFamily }) => {
2043
2043
  var cliOptions = {
2044
2044
  outDir: "out-dir",
2045
2045
  clean: "clean",
2046
+ tailwind: "tailwind",
2046
2047
  theme: {
2047
2048
  colors: {
2048
2049
  main: "main-colors",
@@ -2421,9 +2422,178 @@ function generateTypographyGroup(themes) {
2421
2422
  ];
2422
2423
  }
2423
2424
 
2425
+ // src/tokens/process/output/theme.ts
2426
+ import chalk from "chalk";
2427
+ import * as R7 from "ramda";
2428
+
2429
+ // package.json
2430
+ var package_default = {
2431
+ name: "@digdir/designsystemet",
2432
+ version: "1.1.1",
2433
+ description: "CLI for Designsystemet",
2434
+ author: "Designsystemet team",
2435
+ engines: {
2436
+ node: ">=22.16.0"
2437
+ },
2438
+ repository: {
2439
+ type: "git",
2440
+ url: "git+https://github.com/digdir/designsystemet.git"
2441
+ },
2442
+ homepage: "https://github.com/digdir/designsystemet/tree/main/packages/cli",
2443
+ license: "MIT",
2444
+ type: "module",
2445
+ main: "./dist/src/index.js",
2446
+ files: [
2447
+ "./dist/**",
2448
+ "./configs/**"
2449
+ ],
2450
+ bin: "dist/bin/designsystemet.js",
2451
+ exports: {
2452
+ ".": {
2453
+ import: "./dist/src/index.js"
2454
+ },
2455
+ "./color": {
2456
+ import: "./dist/src/colors/index.js"
2457
+ },
2458
+ "./tokens": {
2459
+ import: "./dist/src/tokens/index.js"
2460
+ }
2461
+ },
2462
+ publishConfig: {
2463
+ access: "public"
2464
+ },
2465
+ scripts: {
2466
+ designsystemet: "tsx ./bin/designsystemet.ts",
2467
+ "designsystemet:inspect": "tsx --inspect-brk ./bin/designsystemet.ts",
2468
+ build: "tsup && pnpm build:types && pnpm build:json-schema",
2469
+ "build:types": "tsc --emitDeclarationOnly --declaration",
2470
+ "build:json-schema": "tsx ./src/scripts/createJsonSchema.ts",
2471
+ types: "tsc --noEmit",
2472
+ "test:tokens-create-options": 'pnpm run designsystemet tokens create -m dominant:"#007682" -n "#003333" -b 99 -o ./temp/options/design-tokens --theme options --clean',
2473
+ "test:tokens-create-config": "pnpm run designsystemet tokens create --config ./configs/test-tokens.config.json",
2474
+ "test:tokens-build": "pnpm run designsystemet tokens build -t ./temp/options/design-tokens -o ./temp/options/build --clean",
2475
+ "test:tokens-build-tailwind": "pnpm run designsystemet tokens build -t ./temp/options/design-tokens -o ./temp/options/build --clean --experimental-tailwind",
2476
+ "test:tokens-build-config": "pnpm run designsystemet tokens build -t ./temp/config/design-tokens -o ./temp/config/build --clean",
2477
+ "test:tokens-build-config:inspect": "pnpm run designsystemet:inspect tokens build -t ./temp/config/design-tokens -o ./temp/config/build --clean",
2478
+ "test:tokens-build-config-tailwind": "pnpm run designsystemet tokens build -t ./temp/config/design-tokens -o ./temp/config/build --clean --experimental-tailwind",
2479
+ "test:tokens-create-and-build-options": "pnpm test:tokens-create-options && pnpm test:tokens-build",
2480
+ "test:tokens-create-and-build-config": "pnpm test:tokens-create-config && pnpm test:tokens-build-config",
2481
+ test: "pnpm test:tokens-create-and-build-options && pnpm test:tokens-create-and-build-config",
2482
+ "digdir:tokens-build": "pnpm run designsystemet tokens build -t ../../internal/design-tokens -o ../../packages/theme/brand --clean --experimental-tailwind",
2483
+ "digdir:tokens-create": "pnpm run designsystemet tokens create --config ./configs/digdir.config.json",
2484
+ "update:template": "tsx ./src/scripts/update-template.ts",
2485
+ "update:theme-digdir": "pnpm digdir:tokens-create && tsx ./src/scripts/update-design-tokens.ts && pnpm digdir:tokens-build",
2486
+ verify: "pnpm test && pnpm update:template && pnpm update:theme-digdir && pnpm build:tokens"
2487
+ },
2488
+ dependencies: {
2489
+ "@commander-js/extra-typings": "^14.0.0",
2490
+ "@tokens-studio/sd-transforms": "1.3.0",
2491
+ "apca-w3": "^0.1.9",
2492
+ chalk: "^5.4.1",
2493
+ "change-case": "^5.4.4",
2494
+ "chroma-js": "^3.1.2",
2495
+ "colorjs.io": "^0.6.0-alpha.1",
2496
+ commander: "^14.0.0",
2497
+ "fast-glob": "^3.3.3",
2498
+ hsluv: "^1.0.1",
2499
+ "object-hash": "^3.0.0",
2500
+ postcss: "^8.5.6",
2501
+ ramda: "^0.30.1",
2502
+ "style-dictionary": "^5.0.0",
2503
+ zod: "^3.25.67",
2504
+ "zod-validation-error": "^3.5.2"
2505
+ },
2506
+ devDependencies: {
2507
+ "@tokens-studio/types": "0.5.2",
2508
+ "@types/apca-w3": "^0.1.3",
2509
+ "@types/chroma-js": "^3.1.1",
2510
+ "@types/fs-extra": "^11.0.4",
2511
+ "@types/glob": "^8.1.0",
2512
+ "@types/node": "^22.15.32",
2513
+ "@types/object-hash": "^3.0.6",
2514
+ "@types/ramda": "^0.30.2",
2515
+ "fs-extra": "^11.3.0",
2516
+ tslib: "^2.8.1",
2517
+ tsup: "^8.5.0",
2518
+ tsx: "^4.20.3",
2519
+ typescript: "^5.8.3"
2520
+ }
2521
+ };
2522
+
2523
+ // src/tokens/process/output/theme.ts
2524
+ var defaultFileHeader = `build: v${package_default.version}`;
2525
+ var createThemeCSSFiles = ({
2526
+ processedBuilds,
2527
+ fileHeader: fileHeader2 = defaultFileHeader
2528
+ }) => {
2529
+ const groupedByTheme = {};
2530
+ for (const [_, buildResults] of Object.entries(processedBuilds)) {
2531
+ for (const buildResult of buildResults) {
2532
+ const themeName = buildResult.permutation.theme;
2533
+ const newOutputs = buildResult.formatted;
2534
+ if (R7.isNotEmpty(newOutputs)) {
2535
+ const currentOutputs = groupedByTheme[themeName] ?? [];
2536
+ groupedByTheme[themeName] = R7.concat(currentOutputs, newOutputs);
2537
+ }
2538
+ }
2539
+ }
2540
+ const sortOrder = [
2541
+ "color-scheme/light",
2542
+ "typography/secondary",
2543
+ "semantic",
2544
+ "color-scheme/dark",
2545
+ "color-scheme/contrast",
2546
+ "typography/primary",
2547
+ "color/"
2548
+ ];
2549
+ const sortByDefinedOrder = R7.sortBy((file) => {
2550
+ const filePath = file.destination || "";
2551
+ const sortIndex = sortOrder.findIndex((sortElement) => {
2552
+ if (sortElement.endsWith("/")) {
2553
+ return filePath.includes(sortElement);
2554
+ }
2555
+ return filePath.includes(`${sortElement}.css`);
2556
+ });
2557
+ if (sortIndex === -1) {
2558
+ console.error(
2559
+ chalk.yellow("WARNING: CSS section does not have a defined sort order:", filePath.replace(".css", ""))
2560
+ );
2561
+ console.log(
2562
+ chalk.dim(
2563
+ `
2564
+ The section will currently be added to the end of the entry file, but the exact
2565
+ order may change due to nondeterminism.`.trim()
2566
+ )
2567
+ );
2568
+ return Infinity;
2569
+ }
2570
+ return sortIndex;
2571
+ });
2572
+ const header = `@charset "UTF-8";
2573
+ /*
2574
+ ${fileHeader2}
2575
+ */
2576
+
2577
+ `;
2578
+ const sortAlphabetically = R7.sort(R7.ascend((x) => x.destination || ""));
2579
+ const pickOutputs = R7.map(R7.view(R7.lensProp("output")));
2580
+ const themeCSSFile = R7.pipe(
2581
+ sortAlphabetically,
2582
+ sortByDefinedOrder,
2583
+ pickOutputs,
2584
+ R7.join("\n"),
2585
+ (content) => header + content
2586
+ );
2587
+ const themeCSSFiles = Object.entries(groupedByTheme).map(([theme, files]) => ({
2588
+ destination: `${theme}.css`,
2589
+ output: themeCSSFile(files)
2590
+ }));
2591
+ return themeCSSFiles;
2592
+ };
2593
+
2424
2594
  // src/tokens/process/platform.ts
2425
- import chalk2 from "chalk";
2426
- import * as R18 from "ramda";
2595
+ import chalk3 from "chalk";
2596
+ import * as R19 from "ramda";
2427
2597
  import StyleDictionary2 from "style-dictionary";
2428
2598
 
2429
2599
  // src/tokens/types.ts
@@ -2434,30 +2604,30 @@ var colorCategories = {
2434
2604
 
2435
2605
  // src/tokens/process/configs.ts
2436
2606
  import { register } from "@tokens-studio/sd-transforms";
2437
- import * as R17 from "ramda";
2607
+ import * as R18 from "ramda";
2438
2608
  import StyleDictionary from "style-dictionary";
2439
2609
 
2440
2610
  // src/tokens/utils.ts
2441
- import * as R7 from "ramda";
2442
- var mapToLowerCase = R7.map(R7.toLower);
2443
- var hasAnyTruth = R7.any(R7.equals(true));
2611
+ import * as R8 from "ramda";
2612
+ var mapToLowerCase = R8.map(R8.toLower);
2613
+ var hasAnyTruth = R8.any(R8.equals(true));
2444
2614
  var getType = (token) => (token.$type ?? token.type) || "";
2445
2615
  var getValue = (token) => token.$value ?? token.value;
2446
- var typeEquals = R7.curry(
2616
+ var typeEquals = R8.curry(
2447
2617
  (types, token) => {
2448
- if (R7.isNil(token)) {
2618
+ if (R8.isNil(token)) {
2449
2619
  return false;
2450
2620
  }
2451
- return R7.includes(R7.toLower(getType(token)), R7.map(R7.toLower, Array.isArray(types) ? types : [types]));
2621
+ return R8.includes(R8.toLower(getType(token)), R8.map(R8.toLower, Array.isArray(types) ? types : [types]));
2452
2622
  }
2453
2623
  );
2454
- var pathStartsWithOneOf = R7.curry(
2624
+ var pathStartsWithOneOf = R8.curry(
2455
2625
  (paths, token) => {
2456
- if (R7.isNil(token)) {
2626
+ if (R8.isNil(token)) {
2457
2627
  return false;
2458
2628
  }
2459
2629
  const tokenPath = mapToLowerCase(token.path);
2460
- const matchPathsStartingWith = R7.map((path) => R7.startsWith([path], tokenPath), mapToLowerCase(paths));
2630
+ const matchPathsStartingWith = R8.map((path) => R8.startsWith([path], tokenPath), mapToLowerCase(paths));
2461
2631
  return hasAnyTruth(matchPathsStartingWith);
2462
2632
  }
2463
2633
  );
@@ -2465,7 +2635,7 @@ function isSemanticToken(token) {
2465
2635
  return token.filePath.includes("semantic/");
2466
2636
  }
2467
2637
  function isSemanticColorToken(token, color) {
2468
- return token.filePath.includes("semantic/") && R7.startsWith(["color", color], token.path);
2638
+ return token.filePath.includes("semantic/") && R8.startsWith(["color", color], token.path);
2469
2639
  }
2470
2640
  function isGlobalColorToken(token) {
2471
2641
  return typeEquals("color", token) && pathStartsWithOneOf(["global"], token);
@@ -2476,7 +2646,7 @@ function isColorCategoryToken(token, category) {
2476
2646
  (colorCategory2) => isColorCategoryToken(token, colorCategory2)
2477
2647
  );
2478
2648
  }
2479
- return R7.startsWith(["color", category], token.path);
2649
+ return R8.startsWith(["color", category], token.path);
2480
2650
  }
2481
2651
  var isDigit = (s) => /^\d+$/.test(s);
2482
2652
  function traverseObj(obj, fn) {
@@ -2492,7 +2662,7 @@ function traverseObj(obj, fn) {
2492
2662
  return obj;
2493
2663
  }
2494
2664
  function inlineTokens(shouldInline, tokens) {
2495
- const [inlineableTokens, otherTokens] = R7.partition(shouldInline, tokens);
2665
+ const [inlineableTokens, otherTokens] = R8.partition(shouldInline, tokens);
2496
2666
  return otherTokens.map((token) => {
2497
2667
  let transformed = getValue(token.original);
2498
2668
  for (const ref of inlineableTokens) {
@@ -2501,16 +2671,16 @@ function inlineTokens(shouldInline, tokens) {
2501
2671
  transformed = transformed.replaceAll(`{${refName}}`, getValue(ref.original));
2502
2672
  }
2503
2673
  }
2504
- const tokenWithInlinedRefs = R7.set(R7.lensPath(["original", "$value"]), transformed, token);
2674
+ const tokenWithInlinedRefs = R8.set(R8.lensPath(["original", "$value"]), transformed, token);
2505
2675
  return tokenWithInlinedRefs;
2506
2676
  });
2507
2677
  }
2508
2678
 
2509
2679
  // src/tokens/process/configs/color.ts
2510
- import * as R12 from "ramda";
2680
+ import * as R13 from "ramda";
2511
2681
 
2512
2682
  // src/tokens/process/formats/css/color.ts
2513
- import * as R8 from "ramda";
2683
+ import * as R9 from "ramda";
2514
2684
  import { createPropertyFormatter } from "style-dictionary/utils";
2515
2685
  var prefersColorScheme = (colorScheme2, content) => `
2516
2686
  @media (prefers-color-scheme: ${colorScheme2}) {
@@ -2519,7 +2689,7 @@ var prefersColorScheme = (colorScheme2, content) => `
2519
2689
  `;
2520
2690
  var colorScheme = {
2521
2691
  name: "ds/css-colorscheme",
2522
- format: async ({ dictionary, file, options, platform }) => {
2692
+ format: async ({ dictionary, options, platform }) => {
2523
2693
  const { allTokens } = dictionary;
2524
2694
  const { outputReferences, usesDtcg } = options;
2525
2695
  const { selector, colorScheme: colorScheme2, layer } = platform;
@@ -2534,8 +2704,8 @@ var colorScheme = {
2534
2704
  color-scheme: ${colorScheme_};
2535
2705
  ` : "";
2536
2706
  const filteredAllTokens = allTokens.filter(
2537
- R8.allPass([
2538
- R8.anyPass([
2707
+ R9.allPass([
2708
+ R9.anyPass([
2539
2709
  // Include semantic tokens in the output
2540
2710
  isSemanticToken,
2541
2711
  // Include global color tokens
@@ -2551,7 +2721,7 @@ ${formattedTokens}
2551
2721
  ${colorSchemeProperty}}
2552
2722
  `;
2553
2723
  const autoSelectorContent = ["light", "dark"].includes(colorScheme_) ? prefersColorScheme(colorScheme_, content) : "";
2554
- const body = R8.isNotNil(layer) ? `@layer ${layer} {
2724
+ const body = R9.isNotNil(layer) ? `@layer ${layer} {
2555
2725
  ${selector} ${content} ${autoSelectorContent}
2556
2726
  }
2557
2727
  ` : `${selector} ${content} ${autoSelectorContent}
@@ -2561,10 +2731,10 @@ ${selector} ${content} ${autoSelectorContent}
2561
2731
  };
2562
2732
  var colorCategory = {
2563
2733
  name: "ds/css-colorcategory",
2564
- format: async ({ dictionary, file, options, platform }) => {
2734
+ format: async ({ dictionary, options, platform }) => {
2565
2735
  const { outputReferences, usesDtcg } = options;
2566
2736
  const { selector, layer } = platform;
2567
- const format = R8.compose(
2737
+ const format = R9.compose(
2568
2738
  createPropertyFormatter({
2569
2739
  outputReferences,
2570
2740
  dictionary,
@@ -2585,7 +2755,7 @@ var colorCategory = {
2585
2755
  ${formattedTokens}
2586
2756
  }
2587
2757
  `;
2588
- const body = R8.isNotNil(layer) ? `@layer ${layer} {
2758
+ const body = R9.isNotNil(layer) ? `@layer ${layer} {
2589
2759
  ${selector} ${content}
2590
2760
  }
2591
2761
  ` : `${selector} ${content}
@@ -2595,16 +2765,16 @@ ${selector} ${content}
2595
2765
  };
2596
2766
 
2597
2767
  // src/tokens/process/formats/css/semantic.ts
2598
- import * as R9 from "ramda";
2768
+ import * as R10 from "ramda";
2599
2769
  import { createPropertyFormatter as createPropertyFormatter2 } from "style-dictionary/utils";
2600
2770
  var isNumericBorderRadiusToken = (t) => t.path[0] === "border-radius" && isDigit(t.path[1]);
2601
2771
  var isNumericSizeToken = (t) => pathStartsWithOneOf(["size"], t) && isDigit(t.path[1]);
2602
2772
  var isSizeToken = (t) => pathStartsWithOneOf(["size"], t);
2603
- var isInlineTokens = R9.anyPass([isNumericBorderRadiusToken, isNumericSizeToken, isSizeToken]);
2773
+ var isInlineTokens = R10.anyPass([isNumericBorderRadiusToken, isNumericSizeToken, isSizeToken]);
2604
2774
  var overrideSizingFormula = (format, token) => {
2605
2775
  const [name, value] = format(token).split(":");
2606
2776
  const calc = value.replace(`var(--ds-size-mode-font-size)`, "1em").replace(/floor\((.*)\);/, "calc($1)");
2607
- const round = `round(down, ${calc}, 0.0625rem)`;
2777
+ const round = `round(down, ${calc}, 1px)`;
2608
2778
  return {
2609
2779
  name,
2610
2780
  round,
@@ -2612,7 +2782,7 @@ var overrideSizingFormula = (format, token) => {
2612
2782
  };
2613
2783
  };
2614
2784
  var formatSizingTokens = (format, tokens) => {
2615
- const { round, calc } = R9.reduce(
2785
+ const { round, calc } = R10.reduce(
2616
2786
  (acc, token) => {
2617
2787
  const { round: round2, calc: calc2, name } = overrideSizingFormula(format, token);
2618
2788
  return {
@@ -2632,7 +2802,7 @@ ${round.join("\n")}
2632
2802
  };
2633
2803
  var semantic = {
2634
2804
  name: "ds/css-semantic",
2635
- format: async ({ dictionary, file, options, platform }) => {
2805
+ format: async ({ dictionary, options, platform }) => {
2636
2806
  const { outputReferences, usesDtcg } = options;
2637
2807
  const { selector, layer } = platform;
2638
2808
  const format = createPropertyFormatter2({
@@ -2642,17 +2812,17 @@ var semantic = {
2642
2812
  usesDtcg
2643
2813
  });
2644
2814
  const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
2645
- const filteredTokens = R9.reject((token) => token.name.includes("ds-size-mode-font-size"), tokens);
2646
- const [sizingTokens, restTokens] = R9.partition(
2815
+ const filteredTokens = R10.reject((token) => token.name.includes("ds-size-mode-font-size"), tokens);
2816
+ const [sizingTokens, restTokens] = R10.partition(
2647
2817
  (t) => pathStartsWithOneOf(["_size"], t) && isDigit(t.path[1]),
2648
2818
  filteredTokens
2649
2819
  );
2650
- const formattedTokens = [R9.map(format, restTokens).join("\n"), formatSizingTokens(format, sizingTokens)];
2820
+ const formattedTokens = [R10.map(format, restTokens).join("\n"), formatSizingTokens(format, sizingTokens)];
2651
2821
  const content = `{
2652
2822
  ${formattedTokens.join("\n")}
2653
2823
  }
2654
2824
  `;
2655
- const body = R9.isNotNil(layer) ? `@layer ${layer} {
2825
+ const body = R10.isNotNil(layer) ? `@layer ${layer} {
2656
2826
  ${selector} ${content}
2657
2827
  }
2658
2828
  ` : `${selector} ${content}
@@ -2662,15 +2832,15 @@ ${selector} ${content}
2662
2832
  };
2663
2833
 
2664
2834
  // src/tokens/process/formats/css/typography.ts
2665
- import * as R10 from "ramda";
2835
+ import * as R11 from "ramda";
2666
2836
  import { createPropertyFormatter as createPropertyFormatter3 } from "style-dictionary/utils";
2667
- var typographyFontFamilyPredicate = R10.allPass([
2668
- R10.pathSatisfies(R10.includes("typography"), ["path"]),
2669
- R10.pathSatisfies(R10.includes("fontFamily"), ["path"])
2837
+ var typographyFontFamilyPredicate = R11.allPass([
2838
+ R11.pathSatisfies(R11.includes("typography"), ["path"]),
2839
+ R11.pathSatisfies(R11.includes("fontFamily"), ["path"])
2670
2840
  ]);
2671
2841
  var typography = {
2672
2842
  name: "ds/css-typography",
2673
- format: async ({ dictionary, file, options, platform }) => {
2843
+ format: async ({ dictionary, options, platform }) => {
2674
2844
  const { outputReferences, usesDtcg } = options;
2675
2845
  const { selector, layer } = platform;
2676
2846
  const format = createPropertyFormatter3({
@@ -2679,12 +2849,12 @@ var typography = {
2679
2849
  format: "css",
2680
2850
  usesDtcg
2681
2851
  });
2682
- const filteredTokens = R10.reject(typographyFontFamilyPredicate, dictionary.allTokens);
2683
- const formattedTokens = R10.pipe(R10.map(format), R10.join("\n"))(filteredTokens);
2852
+ const filteredTokens = R11.reject(typographyFontFamilyPredicate, dictionary.allTokens);
2853
+ const formattedTokens = R11.pipe(R11.map(format), R11.join("\n"))(filteredTokens);
2684
2854
  const content = selector ? `${selector} {
2685
2855
  ${formattedTokens}
2686
2856
  }` : formattedTokens;
2687
- const body = R10.isNotNil(layer) ? `@layer ${layer} {
2857
+ const body = R11.isNotNil(layer) ? `@layer ${layer} {
2688
2858
  ${content}
2689
2859
  }` : content;
2690
2860
  return body;
@@ -2701,8 +2871,8 @@ var formats = {
2701
2871
 
2702
2872
  // src/tokens/process/transformers.ts
2703
2873
  import { checkAndEvaluateMath } from "@tokens-studio/sd-transforms";
2704
- import * as R11 from "ramda";
2705
- var isPx = R11.test(/\b\d+px\b/g);
2874
+ import * as R12 from "ramda";
2875
+ var isPx = R12.test(/\b\d+px\b/g);
2706
2876
  var sizeRem = {
2707
2877
  name: "ds/size/toRem",
2708
2878
  type: "value",
@@ -2792,7 +2962,7 @@ var colorSchemeVariables = ({ "color-scheme": colorScheme2 = "light", theme }) =
2792
2962
  {
2793
2963
  destination: `color-scheme/${colorScheme2}.css`,
2794
2964
  format: formats.colorScheme.name,
2795
- filter: (token) => typeEquals("color", token) && !R12.startsWith(["global"], token.path)
2965
+ filter: (token) => typeEquals("color", token) && !R13.startsWith(["global"], token.path)
2796
2966
  }
2797
2967
  ],
2798
2968
  options: {
@@ -2843,7 +3013,7 @@ var colorCategoryVariables = (opts) => ({ "color-scheme": colorScheme2, theme, .
2843
3013
  };
2844
3014
 
2845
3015
  // src/tokens/process/configs/semantic.ts
2846
- import * as R13 from "ramda";
3016
+ import * as R14 from "ramda";
2847
3017
  import { outputReferencesFilter } from "style-dictionary/utils";
2848
3018
  var semanticVariables = ({ theme }) => {
2849
3019
  const selector = `:root`;
@@ -2866,8 +3036,8 @@ var semanticVariables = ({ theme }) => {
2866
3036
  destination: `semantic.css`,
2867
3037
  format: formats.semantic.name,
2868
3038
  filter: (token) => {
2869
- const isUwantedToken = R13.anyPass([R13.includes("primitives/global")])(token.filePath);
2870
- const isPrivateToken = R13.includes("_", token.path);
3039
+ const isUwantedToken = R14.anyPass([R14.includes("primitives/global")])(token.filePath);
3040
+ const isPrivateToken = R14.includes("_", token.path);
2871
3041
  const unwantedPaths = pathStartsWithOneOf(["font-size", "line-height", "letter-spacing"], token);
2872
3042
  const unwantedTypes = typeEquals(["color", "fontWeight", "fontFamily", "typography"], token);
2873
3043
  const unwantedTokens = !(unwantedPaths || unwantedTypes || isPrivateToken || isUwantedToken);
@@ -2888,20 +3058,20 @@ var semanticVariables = ({ theme }) => {
2888
3058
  };
2889
3059
 
2890
3060
  // src/tokens/process/configs/storefront.ts
2891
- import * as R15 from "ramda";
3061
+ import * as R16 from "ramda";
2892
3062
  import { outputReferencesFilter as outputReferencesFilter2 } from "style-dictionary/utils";
2893
3063
 
2894
3064
  // src/tokens/process/formats/js-tokens.ts
2895
- import * as R14 from "ramda";
3065
+ import * as R15 from "ramda";
2896
3066
  import { createPropertyFormatter as createPropertyFormatter4, fileHeader } from "style-dictionary/utils";
2897
- var groupByType = R14.groupBy((token) => getType(token));
2898
- var removeUnwatedTokens = R14.pipe(
2899
- R14.reject((token) => isColorCategoryToken(token)),
2900
- R14.reject((token) => R14.any((path) => path.startsWith("_"))(token.path))
3067
+ var groupByType = R15.groupBy((token) => getType(token));
3068
+ var removeUnwatedTokens = R15.pipe(
3069
+ R15.reject((token) => isColorCategoryToken(token)),
3070
+ R15.reject((token) => R15.any((path) => path.startsWith("_"))(token.path))
2901
3071
  );
2902
- var dissocExtensions = R14.pipe(R14.dissoc("$extensions"), R14.dissocPath(["original", "$extensions"]));
2903
- var removeUnwatedProps = R14.map((token) => dissocExtensions(token));
2904
- var toCssVarName = R14.pipe(R14.split(":"), R14.head, R14.trim);
3072
+ var dissocExtensions = R15.pipe(R15.dissoc("$extensions"), R15.dissocPath(["original", "$extensions"]));
3073
+ var removeUnwatedProps = R15.map((token) => dissocExtensions(token));
3074
+ var toCssVarName = R15.pipe(R15.split(":"), R15.head, R15.trim);
2905
3075
  var jsTokens = {
2906
3076
  name: "ds/js-tokens",
2907
3077
  format: async ({ dictionary, file, options }) => {
@@ -2912,7 +3082,7 @@ var jsTokens = {
2912
3082
  format: "css",
2913
3083
  usesDtcg
2914
3084
  });
2915
- const formatTokens2 = R14.map((token) => {
3085
+ const formatTokens2 = R15.map((token) => {
2916
3086
  if (pathStartsWithOneOf(["size", "_size"], token)) {
2917
3087
  const { calc, name } = overrideSizingFormula(format, token);
2918
3088
  return {
@@ -2926,7 +3096,7 @@ var jsTokens = {
2926
3096
  name: toCssVarName(format(token))
2927
3097
  };
2928
3098
  });
2929
- const processTokens = R14.pipe(removeUnwatedTokens, removeUnwatedProps, formatTokens2, groupByType);
3099
+ const processTokens = R15.pipe(removeUnwatedTokens, removeUnwatedProps, formatTokens2, groupByType);
2930
3100
  const tokens = processTokens(inlineTokens(isInlineTokens, dictionary.allTokens));
2931
3101
  const content = Object.entries(tokens).map(
2932
3102
  ([name, token]) => `export const ${name} = ${JSON.stringify(token, null, 2).replace(/"([^"]+)":/g, "$1:")}
@@ -2951,9 +3121,9 @@ var typescriptTokens = ({ "color-scheme": colorScheme2, theme }) => {
2951
3121
  destination: `${colorScheme2}.ts`,
2952
3122
  format: jsTokens.name,
2953
3123
  filter: (token) => {
2954
- if (pathStartsWithOneOf(["border-width", "letter-spacing", "border-radius"], token) && !R15.includes("semantic", token.filePath))
3124
+ if (pathStartsWithOneOf(["border-width", "letter-spacing", "border-radius"], token) && !R16.includes("semantic", token.filePath))
2955
3125
  return false;
2956
- const isSemanticColor = R15.includes("semantic", token.filePath) && typeEquals(["color"], token);
3126
+ const isSemanticColor = R16.includes("semantic", token.filePath) && typeEquals(["color"], token);
2957
3127
  const wantedTypes = typeEquals(["shadow", "dimension", "typography", "opacity"], token);
2958
3128
  return isSemanticColor || wantedTypes;
2959
3129
  }
@@ -3019,19 +3189,19 @@ var typographyVariables = ({ theme, typography: typography2 }) => {
3019
3189
  };
3020
3190
 
3021
3191
  // src/tokens/process/utils/getMultidimensionalThemes.ts
3022
- import chalk from "chalk";
3192
+ import chalk2 from "chalk";
3023
3193
  import { kebabCase } from "change-case";
3024
- import * as R16 from "ramda";
3194
+ import * as R17 from "ramda";
3025
3195
  var getMultidimensionalThemes = (processed$themes, dimensions) => {
3026
3196
  const verboseLogging = buildOptions?.verbose;
3027
3197
  const grouped$themes = groupThemes(processed$themes);
3028
3198
  const permutations = permutateThemes(grouped$themes);
3029
3199
  const ALL_DEPENDENT_ON = ["theme"];
3030
- const keys2 = R16.keys(grouped$themes);
3200
+ const keys2 = R17.keys(grouped$themes);
3031
3201
  const nonDependentKeys = keys2.filter((x) => ![...ALL_DEPENDENT_ON, ...dimensions].includes(x));
3032
3202
  if (verboseLogging) {
3033
- console.log(chalk.cyan(`\u{1F50E} Finding theme permutations for ${dimensions}`));
3034
- console.log(chalk.cyan(` (ignoring permutations for ${nonDependentKeys})`));
3203
+ console.log(chalk2.cyan(`\u{1F50E} Finding theme permutations for ${dimensions}`));
3204
+ console.log(chalk2.cyan(` (ignoring permutations for ${nonDependentKeys})`));
3035
3205
  }
3036
3206
  return permutations.filter((val) => {
3037
3207
  const filters = nonDependentKeys.map((x) => val.permutation[x] === grouped$themes[x][0].name);
@@ -3067,7 +3237,7 @@ function groupThemes(themes) {
3067
3237
  }
3068
3238
  return groups;
3069
3239
  }
3070
- var hasUnknownProps = R16.pipe(R16.values, R16.none(R16.equals("unknown")), R16.not);
3240
+ var hasUnknownProps = R17.pipe(R17.values, R17.none(R17.equals("unknown")), R17.not);
3071
3241
  function permutateThemes(groups) {
3072
3242
  const separator = "_";
3073
3243
  const permutations = cartesian(Object.values(groups));
@@ -3077,8 +3247,8 @@ function permutateThemes(groups) {
3077
3247
  const { group, name, selectedTokenSets } = theme;
3078
3248
  let updatedPermutation = acc.permutation;
3079
3249
  if (group) {
3080
- const groupProp = R16.lensProp(group);
3081
- updatedPermutation = R16.set(groupProp, name, updatedPermutation);
3250
+ const groupProp = R17.lensProp(group);
3251
+ updatedPermutation = R17.set(groupProp, name, updatedPermutation);
3082
3252
  }
3083
3253
  const updatedName = `${String(acc.name)}${acc ? separator : ""}${name}`;
3084
3254
  const sets = [...acc.selectedTokenSets, ...filterTokenSets(selectedTokenSets)];
@@ -3124,6 +3294,12 @@ function filterTokenSets(tokensets) {
3124
3294
  function cartesian(a) {
3125
3295
  return a.reduce((a2, b) => a2.flatMap((d) => b.map((e) => [d, e].flat())));
3126
3296
  }
3297
+ var getCustomColors = (processed$themes, colorGroups) => processed$themes.filter((x) => {
3298
+ if (!x.group) {
3299
+ return false;
3300
+ }
3301
+ return colorGroups.includes(x.group);
3302
+ }).map((x) => x.name);
3127
3303
 
3128
3304
  // src/tokens/process/configs.ts
3129
3305
  void register(StyleDictionary, { withSDBuiltins: false });
@@ -3162,7 +3338,7 @@ var getConfigsForThemeDimensions = (getConfig, processed$themes, dimensions, opt
3162
3338
  obj.filePath = tokenSet;
3163
3339
  }
3164
3340
  });
3165
- tokenSource.tokens = R17.mergeDeepRight(tokenSource.tokens, tokensWithFilePath);
3341
+ tokenSource.tokens = R18.mergeDeepRight(tokenSource.tokens, tokensWithFilePath);
3166
3342
  }
3167
3343
  }
3168
3344
  } else {
@@ -3206,12 +3382,6 @@ var initResult = {
3206
3382
  };
3207
3383
  var buildOptions;
3208
3384
  var sd = new StyleDictionary2();
3209
- var getCustomColors = (processed$themes, colorGroups) => processed$themes.filter((x) => {
3210
- if (!x.group) {
3211
- return false;
3212
- }
3213
- return colorGroups.includes(x.group);
3214
- }).map((x) => x.name);
3215
3385
  var buildConfigs = {
3216
3386
  typography: { getConfig: configs.typographyVariables, dimensions: ["typography"] },
3217
3387
  "color-scheme": { getConfig: configs.colorSchemeVariables, dimensions: ["color-scheme"] },
@@ -3252,46 +3422,54 @@ var buildConfigs = {
3252
3422
  // },
3253
3423
  };
3254
3424
  async function processPlatform(options) {
3255
- const { type, $themes } = options;
3425
+ const { type, processed$themes } = options;
3256
3426
  const platform = "css";
3257
3427
  const tokenSets = type === "format" ? options.tokenSets : void 0;
3258
3428
  const tokensDir = type === "build" ? options.tokensDir : void 0;
3259
3429
  const UNSAFE_DEFAULT_COLOR = process.env.UNSAFE_DEFAULT_COLOR ?? "";
3260
3430
  if (UNSAFE_DEFAULT_COLOR) {
3261
3431
  console.warn(
3262
- chalk2.yellow(
3432
+ chalk3.yellow(
3263
3433
  `
3264
- \u26A0\uFE0F UNSAFE_DEFAULT_COLOR is set to ${chalk2.blue(UNSAFE_DEFAULT_COLOR)}. This will override the default color.`
3434
+ \u26A0\uFE0F UNSAFE_DEFAULT_COLOR is set to ${chalk3.blue(UNSAFE_DEFAULT_COLOR)}. This will override the default color.`
3265
3435
  )
3266
3436
  );
3267
3437
  }
3268
3438
  const UNSAFE_COLOR_GROUPS = Array.from(process.env.UNSAFE_COLOR_GROUPS?.split(",") ?? []);
3269
3439
  if (UNSAFE_COLOR_GROUPS.length > 0) {
3270
3440
  console.warn(
3271
- chalk2.yellow(
3441
+ chalk3.yellow(
3272
3442
  `
3273
- \u26A0\uFE0F UNSAFE_COLOR_GROUPS is set to ${chalk2.blue(`[${UNSAFE_COLOR_GROUPS.join(", ")}]`)}. This will override the default color groups.`
3443
+ \u26A0\uFE0F UNSAFE_COLOR_GROUPS is set to ${chalk3.blue(`[${UNSAFE_COLOR_GROUPS.join(", ")}]`)}. This will override the default color groups.`
3274
3444
  )
3275
3445
  );
3276
3446
  }
3277
3447
  const colorGroups = UNSAFE_COLOR_GROUPS.length > 0 ? UNSAFE_COLOR_GROUPS : [colorCategories.main, colorCategories.support].map((c) => `${c}-color`);
3278
3448
  buildOptions = options;
3279
3449
  buildOptions.defaultColor = UNSAFE_DEFAULT_COLOR;
3280
- const processed$themes = $themes.map(processThemeObject).filter((theme) => R18.not(theme.group === "size" && theme.name !== "medium"));
3281
- const customColors = getCustomColors(processed$themes, colorGroups);
3450
+ buildOptions.colorGroups = colorGroups;
3451
+ const filteredProcessed$themes = processed$themes.filter(
3452
+ (theme) => R19.not(theme.group === "size" && theme.name !== "medium")
3453
+ );
3454
+ const customColors = getCustomColors(filteredProcessed$themes, colorGroups);
3282
3455
  if (!buildOptions.defaultColor) {
3283
- const firstMainColor = R18.head(customColors);
3456
+ const firstMainColor = R19.head(customColors);
3284
3457
  buildOptions.defaultColor = firstMainColor;
3285
3458
  }
3286
3459
  if (buildOptions.defaultColor) {
3287
3460
  console.log(`
3288
- \u{1F3A8} Using ${chalk2.blue(buildOptions.defaultColor)} as default color`);
3461
+ \u{1F3A8} Using ${chalk3.blue(buildOptions.defaultColor)} as default color`);
3289
3462
  }
3290
- const buildAndSdConfigs = R18.map((buildConfig) => {
3291
- const sdConfigs = getConfigsForThemeDimensions(buildConfig.getConfig, processed$themes, buildConfig.dimensions, {
3292
- tokensDir,
3293
- tokenSets
3294
- });
3463
+ const buildAndSdConfigs = R19.map((buildConfig) => {
3464
+ const sdConfigs = getConfigsForThemeDimensions(
3465
+ buildConfig.getConfig,
3466
+ filteredProcessed$themes,
3467
+ buildConfig.dimensions,
3468
+ {
3469
+ tokensDir,
3470
+ tokenSets
3471
+ }
3472
+ );
3295
3473
  const unknownConfigs = buildConfig.dimensions.map(
3296
3474
  (dimension) => sdConfigs.filter((x) => x.permutation[dimension] === "unknown")
3297
3475
  );
@@ -3315,23 +3493,22 @@ async function processPlatform(options) {
3315
3493
  "warning-color": [initResult],
3316
3494
  "info-color": [initResult],
3317
3495
  semantic: [initResult],
3318
- typography: [initResult],
3319
- types: [initResult]
3496
+ typography: [initResult]
3320
3497
  };
3321
3498
  try {
3322
- for (const [buildName, { buildConfig, sdConfigs }] of R18.toPairs(buildAndSdConfigs)) {
3499
+ for (const [buildName, { buildConfig, sdConfigs }] of R19.toPairs(buildAndSdConfigs)) {
3323
3500
  if (!(buildConfig.enabled?.() ?? true)) {
3324
3501
  continue;
3325
3502
  }
3326
3503
  if (sdConfigs.length > 0) {
3327
3504
  console.log(`
3328
- \u{1F371} Building ${chalk2.green(buildConfig.name ?? buildName)}`);
3505
+ \u{1F371} Building ${chalk3.green(buildConfig.name ?? buildName)}`);
3329
3506
  const results = await Promise.all(
3330
3507
  sdConfigs.map(async (sdConfig) => {
3331
3508
  const { config, permutation } = sdConfig;
3332
3509
  const modes = ["theme", ...buildConfig.dimensions];
3333
3510
  const modeMessage = modes.map((x) => permutation[x]).join(" - ");
3334
- const logMessage = R18.isNil(buildConfig.log) ? modeMessage : buildConfig?.log(sdConfig);
3511
+ const logMessage = R19.isNil(buildConfig.log) ? modeMessage : buildConfig?.log(sdConfig);
3335
3512
  console.log(logMessage);
3336
3513
  const sdOptions = { cache: true };
3337
3514
  const sdExtended = await sd.extend(config);
@@ -3351,198 +3528,8 @@ async function processPlatform(options) {
3351
3528
  }
3352
3529
  throw err;
3353
3530
  }
3354
- const colorsFileName = "colors.d.ts";
3355
- const reactColorTypes = await createColorTypeDeclaration(customColors);
3356
- processedBuilds.types = [
3357
- {
3358
- ...initResult,
3359
- formatted: [{ output: reactColorTypes, destination: colorsFileName }]
3360
- }
3361
- ];
3362
3531
  return processedBuilds;
3363
3532
  }
3364
- async function createColorTypeDeclaration(colors) {
3365
- console.log(`
3366
- \u{1F371} Building ${chalk2.green("type declarations")}`);
3367
- const typeDeclaration = `
3368
- import type {} from '@digdir/designsystemet-react/colors';
3369
-
3370
- declare module '@digdir/designsystemet-react/colors' {
3371
- export interface MainAndSupportColors {
3372
- ${colors.map((color) => ` ${color}: never;`).join("\n")}
3373
- }
3374
- }
3375
- `.trimStart();
3376
- return typeDeclaration;
3377
- }
3378
-
3379
- // src/tokens/process/theme.ts
3380
- import * as R19 from "ramda";
3381
- import chalk3 from "chalk";
3382
-
3383
- // package.json
3384
- var package_default = {
3385
- name: "@digdir/designsystemet",
3386
- version: "1.0.8",
3387
- description: "CLI for Designsystemet",
3388
- author: "Designsystemet team",
3389
- engines: {
3390
- node: ">=22.16.0"
3391
- },
3392
- repository: {
3393
- type: "git",
3394
- url: "git+https://github.com/digdir/designsystemet.git"
3395
- },
3396
- homepage: "https://github.com/digdir/designsystemet/tree/main/scripts/cli",
3397
- license: "MIT",
3398
- type: "module",
3399
- main: "./dist/src/index.js",
3400
- files: [
3401
- "./dist/**",
3402
- "./configs/**"
3403
- ],
3404
- bin: "dist/bin/designsystemet.js",
3405
- exports: {
3406
- ".": {
3407
- import: "./dist/src/index.js"
3408
- },
3409
- "./color": {
3410
- import: "./dist/src/colors/index.js"
3411
- },
3412
- "./tokens": {
3413
- import: "./dist/src/tokens/index.js"
3414
- }
3415
- },
3416
- publishConfig: {
3417
- access: "public"
3418
- },
3419
- scripts: {
3420
- designsystemet: "tsx ./bin/designsystemet.ts",
3421
- "build:tokens": "pnpm run designsystemet tokens build -p -t ../../internal/design-tokens -o ../../packages/theme/brand --clean",
3422
- "build:tokens:debug": "tsx --inspect-brk ./bin/designsystemet.ts tokens build -p -t ../../internal/design-tokens -o ../../packages/theme/brand --clean",
3423
- build: "tsup && pnpm build:types && pnpm build:json-schema",
3424
- "build:types": "tsc --emitDeclarationOnly --declaration",
3425
- "build:json-schema": "tsx ./src/scripts/createJsonSchema.ts",
3426
- types: "tsc --noEmit",
3427
- "test:tokens-create-options": 'pnpm run designsystemet tokens create -m dominant:"#007682" -n "#003333" -b 99 -o ./temp/options/design-tokens --theme options --clean',
3428
- "test:tokens-create-config": "pnpm run designsystemet tokens create --config ./configs/test-tokens.config.json",
3429
- "test:tokens-build": "pnpm run designsystemet tokens build -t ./temp/options/design-tokens -o ./temp/options/build --clean",
3430
- "test:tokens-build-config": "pnpm run designsystemet tokens build -t ./temp/config/design-tokens -o ./temp/config/build --clean",
3431
- "test:tokens-create-and-build-options": "pnpm test:tokens-create-options && pnpm test:tokens-build",
3432
- "test:tokens-create-and-build-config": "pnpm test:tokens-create-config && pnpm test:tokens-build-config",
3433
- test: "pnpm test:tokens-create-and-build-options && pnpm test:tokens-create-and-build-config",
3434
- "digdir:tokens-create": "pnpm run designsystemet tokens create --config ./configs/digdir.config.json",
3435
- "update:template": "tsx ./src/scripts/update-template.ts",
3436
- "update:theme-digdir": "pnpm digdir:tokens-create && tsx ./src/scripts/update-design-tokens.ts",
3437
- verify: "pnpm test && pnpm update:template && pnpm update:theme-digdir && pnpm build:tokens"
3438
- },
3439
- dependencies: {
3440
- "@commander-js/extra-typings": "^13.1.0",
3441
- "@tokens-studio/sd-transforms": "1.3.0",
3442
- "apca-w3": "^0.1.9",
3443
- chalk: "^5.4.1",
3444
- "change-case": "^5.4.4",
3445
- "chroma-js": "^3.1.2",
3446
- "colorjs.io": "^0.6.0-alpha.1",
3447
- commander: "^13.1.0",
3448
- "fast-glob": "^3.3.3",
3449
- hsluv: "^1.0.1",
3450
- "object-hash": "^3.0.0",
3451
- postcss: "^8.5.3",
3452
- ramda: "^0.30.1",
3453
- "style-dictionary": "^4.4.0",
3454
- zod: "^3.25.30",
3455
- "zod-validation-error": "^3.4.1"
3456
- },
3457
- devDependencies: {
3458
- "@tokens-studio/types": "0.5.2",
3459
- "@types/apca-w3": "^0.1.3",
3460
- "@types/chroma-js": "^3.1.1",
3461
- "@types/fs-extra": "^11.0.4",
3462
- "@types/glob": "^8.1.0",
3463
- "@types/jscodeshift": "^0.12.0",
3464
- "@types/node": "^22.15.21",
3465
- "@types/object-hash": "^3.0.6",
3466
- "@types/ramda": "^0.30.2",
3467
- "fs-extra": "^11.3.0",
3468
- "ts-toolbelt": "^9.6.0",
3469
- tslib: "^2.8.1",
3470
- tsup: "^8.5.0",
3471
- tsx: "^4.19.4",
3472
- typescript: "^5.8.3"
3473
- }
3474
- };
3475
-
3476
- // src/tokens/process/theme.ts
3477
- var defaultFileHeader = `build: v${package_default.version}`;
3478
- var createThemeCSSFiles = ({
3479
- processedBuilds,
3480
- fileHeader: fileHeader2 = defaultFileHeader
3481
- }) => {
3482
- const groupedByTheme = {};
3483
- for (const [_, buildResults] of Object.entries(R19.dissoc("types", processedBuilds))) {
3484
- for (const buildResult of buildResults) {
3485
- const themeName = buildResult.permutation.theme;
3486
- const newOutputs = buildResult.formatted;
3487
- if (R19.isNotEmpty(newOutputs)) {
3488
- const currentOutputs = groupedByTheme[themeName] ?? [];
3489
- groupedByTheme[themeName] = R19.concat(currentOutputs, newOutputs);
3490
- }
3491
- }
3492
- }
3493
- const sortOrder = [
3494
- "color-scheme/light",
3495
- "typography/secondary",
3496
- "semantic",
3497
- "color-scheme/dark",
3498
- "color-scheme/contrast",
3499
- "typography/primary",
3500
- "color/"
3501
- ];
3502
- const sortByDefinedOrder = R19.sortBy((file) => {
3503
- const filePath = file.destination || "";
3504
- const sortIndex = sortOrder.findIndex((sortElement) => {
3505
- if (sortElement.endsWith("/")) {
3506
- return filePath.includes(sortElement);
3507
- }
3508
- return filePath.includes(`${sortElement}.css`);
3509
- });
3510
- if (sortIndex === -1) {
3511
- console.error(
3512
- chalk3.yellow("WARNING: CSS section does not have a defined sort order:", filePath.replace(".css", ""))
3513
- );
3514
- console.log(
3515
- chalk3.dim(
3516
- `
3517
- The section will currently be added to the end of the entry file, but the exact
3518
- order may change due to nondeterminism.`.trim()
3519
- )
3520
- );
3521
- return Infinity;
3522
- }
3523
- return sortIndex;
3524
- });
3525
- const header = `@charset "UTF-8";
3526
- /*
3527
- ${fileHeader2}
3528
- */
3529
-
3530
- `;
3531
- const sortAlphabetically = R19.sort(R19.ascend((x) => x.destination || ""));
3532
- const pickOutputs = R19.map(R19.view(R19.lensProp("output")));
3533
- const themeCSSFile = R19.pipe(
3534
- sortAlphabetically,
3535
- sortByDefinedOrder,
3536
- pickOutputs,
3537
- R19.join("\n"),
3538
- (content) => header + content
3539
- );
3540
- const themeCSSFiles = Object.entries(groupedByTheme).map(([theme, files]) => ({
3541
- destination: `${theme}.css`,
3542
- output: themeCSSFile(files)
3543
- }));
3544
- return themeCSSFiles;
3545
- };
3546
3533
 
3547
3534
  // src/tokens/format.ts
3548
3535
  var formatTokens = async (options) => {
@@ -3555,9 +3542,10 @@ var formatTokens = async (options) => {
3555
3542
  var formatTheme = async (themeConfig) => {
3556
3543
  const { tokenSets } = await createTokens(themeConfig);
3557
3544
  const $themes = await generate$Themes(["dark", "light"], [themeConfig.name], themeConfig.colors);
3545
+ const processed$themes = $themes.map(processThemeObject);
3558
3546
  const processedBuilds = await formatTokens({
3559
3547
  tokenSets,
3560
- $themes,
3548
+ processed$themes,
3561
3549
  verbose: false,
3562
3550
  preview: false
3563
3551
  });