@digdir/designsystemet 1.0.7 → 1.1.0

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 (71) hide show
  1. package/dist/bin/config.d.ts +12 -0
  2. package/dist/bin/config.d.ts.map +1 -0
  3. package/dist/bin/config.js +517 -0
  4. package/dist/bin/designsystemet.js +3699 -3572
  5. package/dist/config.schema.json +1 -0
  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 +25 -14
  12. package/dist/src/config.d.ts.map +1 -1
  13. package/dist/src/config.js +68 -24
  14. package/dist/src/index.js +431 -404
  15. package/dist/src/migrations/beta-to-v1.js +9 -2
  16. package/dist/src/migrations/codemods/css/run.js +9 -2
  17. package/dist/src/migrations/color-rename-next49.js +9 -2
  18. package/dist/src/migrations/index.js +9 -2
  19. package/dist/src/scripts/createJsonSchema.js +28 -23
  20. package/dist/src/scripts/update-template.d.ts.map +1 -1
  21. package/dist/src/scripts/update-template.js +9 -2
  22. package/dist/src/tokens/build.d.ts +1 -1
  23. package/dist/src/tokens/build.d.ts.map +1 -1
  24. package/dist/src/tokens/build.js +140 -57
  25. package/dist/src/tokens/create/generators/$designsystemet.js +13 -14
  26. package/dist/src/tokens/create/generators/color.js +21 -21
  27. package/dist/src/tokens/create/write.js +23 -17
  28. package/dist/src/tokens/create.d.ts +1 -0
  29. package/dist/src/tokens/create.d.ts.map +1 -1
  30. package/dist/src/tokens/create.js +22 -21
  31. package/dist/src/tokens/format.d.ts +1 -1
  32. package/dist/src/tokens/format.d.ts.map +1 -1
  33. package/dist/src/tokens/format.js +916 -890
  34. package/dist/src/tokens/index.d.ts +2 -2
  35. package/dist/src/tokens/index.d.ts.map +1 -1
  36. package/dist/src/tokens/index.js +308 -281
  37. package/dist/src/tokens/process/configs/color.d.ts.map +1 -1
  38. package/dist/src/tokens/process/configs/color.js +17 -15
  39. package/dist/src/tokens/process/configs/semantic.d.ts.map +1 -1
  40. package/dist/src/tokens/process/configs/semantic.js +16 -14
  41. package/dist/src/tokens/process/configs/storefront.d.ts.map +1 -1
  42. package/dist/src/tokens/process/configs/storefront.js +12 -2
  43. package/dist/src/tokens/process/configs/typography.d.ts.map +1 -1
  44. package/dist/src/tokens/process/configs/typography.js +16 -14
  45. package/dist/src/tokens/process/configs.d.ts.map +1 -1
  46. package/dist/src/tokens/process/configs.js +18 -31
  47. package/dist/src/tokens/process/formats/css/color.js +5 -3
  48. package/dist/src/tokens/process/formats/css/semantic.js +2 -2
  49. package/dist/src/tokens/process/formats/css/typography.js +1 -1
  50. package/dist/src/tokens/process/formats/css.js +8 -6
  51. package/dist/src/tokens/process/formats/js-tokens.js +12 -2
  52. package/dist/src/tokens/process/output/tailwind.d.ts +3 -0
  53. package/dist/src/tokens/process/output/tailwind.d.ts.map +1 -0
  54. package/dist/src/tokens/process/output/tailwind.js +59 -0
  55. package/dist/src/tokens/process/{theme.d.ts → output/theme.d.ts} +2 -2
  56. package/dist/src/tokens/process/output/theme.d.ts.map +1 -0
  57. package/dist/src/tokens/process/{theme.js → output/theme.js} +16 -17
  58. package/dist/src/tokens/process/platform.d.ts +6 -6
  59. package/dist/src/tokens/process/platform.d.ts.map +1 -1
  60. package/dist/src/tokens/process/platform.js +46 -19
  61. package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +10 -9
  62. package/dist/src/tokens/types.d.ts +3 -3
  63. package/dist/src/tokens/types.d.ts.map +1 -1
  64. package/dist/src/tokens/utils.d.ts +2 -2
  65. package/dist/src/tokens/utils.d.ts.map +1 -1
  66. package/dist/src/tokens/utils.js +11 -1
  67. package/dist/src/utils.d.ts +1 -1
  68. package/dist/src/utils.d.ts.map +1 -1
  69. package/dist/src/utils.js +9 -2
  70. package/package.json +13 -14
  71. 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,176 @@ 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.0",
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
+ build: "tsup && pnpm build:types && pnpm build:json-schema",
2468
+ "build:types": "tsc --emitDeclarationOnly --declaration",
2469
+ "build:json-schema": "tsx ./src/scripts/createJsonSchema.ts",
2470
+ types: "tsc --noEmit",
2471
+ "test:tokens-create-options": 'pnpm run designsystemet tokens create -m dominant:"#007682" -n "#003333" -b 99 -o ./temp/options/design-tokens --theme options --clean',
2472
+ "test:tokens-create-config": "pnpm run designsystemet tokens create --config ./configs/test-tokens.config.json",
2473
+ "test:tokens-build": "pnpm run designsystemet tokens build -t ./temp/options/design-tokens -o ./temp/options/build --clean",
2474
+ "test:tokens-build-tailwind": "pnpm run designsystemet tokens build -t ./temp/options/design-tokens -o ./temp/options/build --clean --experimental-tailwind",
2475
+ "test:tokens-build-config": "pnpm run designsystemet tokens build -t ./temp/config/design-tokens -o ./temp/config/build --clean",
2476
+ "test:tokens-build-config-tailwind": "pnpm run designsystemet tokens build -t ./temp/config/design-tokens -o ./temp/config/build --clean --experimental-tailwind",
2477
+ "test:tokens-create-and-build-options": "pnpm test:tokens-create-options && pnpm test:tokens-build",
2478
+ "test:tokens-create-and-build-config": "pnpm test:tokens-create-config && pnpm test:tokens-build-config",
2479
+ test: "pnpm test:tokens-create-and-build-options && pnpm test:tokens-create-and-build-config",
2480
+ "digdir:tokens-build": "pnpm run designsystemet tokens build -t ../../internal/design-tokens -o ../../packages/theme/brand --clean --experimental-tailwind",
2481
+ "digdir:tokens-create": "pnpm run designsystemet tokens create --config ./configs/digdir.config.json",
2482
+ "update:template": "tsx ./src/scripts/update-template.ts",
2483
+ "update:theme-digdir": "pnpm digdir:tokens-create && tsx ./src/scripts/update-design-tokens.ts && pnpm digdir:tokens-build",
2484
+ verify: "pnpm test && pnpm update:template && pnpm update:theme-digdir && pnpm build:tokens"
2485
+ },
2486
+ dependencies: {
2487
+ "@commander-js/extra-typings": "^14.0.0",
2488
+ "@tokens-studio/sd-transforms": "1.3.0",
2489
+ "apca-w3": "^0.1.9",
2490
+ chalk: "^5.4.1",
2491
+ "change-case": "^5.4.4",
2492
+ "chroma-js": "^3.1.2",
2493
+ "colorjs.io": "^0.6.0-alpha.1",
2494
+ commander: "^13.1.0",
2495
+ "fast-glob": "^3.3.3",
2496
+ hsluv: "^1.0.1",
2497
+ "object-hash": "^3.0.0",
2498
+ postcss: "^8.5.5",
2499
+ ramda: "^0.30.1",
2500
+ "style-dictionary": "^4.4.0",
2501
+ zod: "^3.25.64",
2502
+ "zod-validation-error": "^3.5.0"
2503
+ },
2504
+ devDependencies: {
2505
+ "@tokens-studio/types": "0.5.2",
2506
+ "@types/apca-w3": "^0.1.3",
2507
+ "@types/chroma-js": "^3.1.1",
2508
+ "@types/fs-extra": "^11.0.4",
2509
+ "@types/glob": "^8.1.0",
2510
+ "@types/node": "^22.15.31",
2511
+ "@types/object-hash": "^3.0.6",
2512
+ "@types/ramda": "^0.30.2",
2513
+ "fs-extra": "^11.3.0",
2514
+ tslib: "^2.8.1",
2515
+ tsup: "^8.5.0",
2516
+ tsx: "^4.20.3",
2517
+ typescript: "^5.8.3"
2518
+ }
2519
+ };
2520
+
2521
+ // src/tokens/process/output/theme.ts
2522
+ var defaultFileHeader = `build: v${package_default.version}`;
2523
+ var createThemeCSSFiles = ({
2524
+ processedBuilds,
2525
+ fileHeader: fileHeader2 = defaultFileHeader
2526
+ }) => {
2527
+ const groupedByTheme = {};
2528
+ for (const [_, buildResults] of Object.entries(R7.dissoc("types", processedBuilds))) {
2529
+ for (const buildResult of buildResults) {
2530
+ const themeName = buildResult.permutation.theme;
2531
+ const newOutputs = buildResult.formatted;
2532
+ if (R7.isNotEmpty(newOutputs)) {
2533
+ const currentOutputs = groupedByTheme[themeName] ?? [];
2534
+ groupedByTheme[themeName] = R7.concat(currentOutputs, newOutputs);
2535
+ }
2536
+ }
2537
+ }
2538
+ const sortOrder = [
2539
+ "color-scheme/light",
2540
+ "typography/secondary",
2541
+ "semantic",
2542
+ "color-scheme/dark",
2543
+ "color-scheme/contrast",
2544
+ "typography/primary",
2545
+ "color/"
2546
+ ];
2547
+ const sortByDefinedOrder = R7.sortBy((file) => {
2548
+ const filePath = file.destination || "";
2549
+ const sortIndex = sortOrder.findIndex((sortElement) => {
2550
+ if (sortElement.endsWith("/")) {
2551
+ return filePath.includes(sortElement);
2552
+ }
2553
+ return filePath.includes(`${sortElement}.css`);
2554
+ });
2555
+ if (sortIndex === -1) {
2556
+ console.error(
2557
+ chalk.yellow("WARNING: CSS section does not have a defined sort order:", filePath.replace(".css", ""))
2558
+ );
2559
+ console.log(
2560
+ chalk.dim(
2561
+ `
2562
+ The section will currently be added to the end of the entry file, but the exact
2563
+ order may change due to nondeterminism.`.trim()
2564
+ )
2565
+ );
2566
+ return Infinity;
2567
+ }
2568
+ return sortIndex;
2569
+ });
2570
+ const header = `@charset "UTF-8";
2571
+ /*
2572
+ ${fileHeader2}
2573
+ */
2574
+
2575
+ `;
2576
+ const sortAlphabetically = R7.sort(R7.ascend((x) => x.destination || ""));
2577
+ const pickOutputs = R7.map(R7.view(R7.lensProp("output")));
2578
+ const themeCSSFile = R7.pipe(
2579
+ sortAlphabetically,
2580
+ sortByDefinedOrder,
2581
+ pickOutputs,
2582
+ R7.join("\n"),
2583
+ (content) => header + content
2584
+ );
2585
+ const themeCSSFiles = Object.entries(groupedByTheme).map(([theme, files]) => ({
2586
+ destination: `${theme}.css`,
2587
+ output: themeCSSFile(files)
2588
+ }));
2589
+ return themeCSSFiles;
2590
+ };
2591
+
2424
2592
  // src/tokens/process/platform.ts
2425
- import chalk2 from "chalk";
2426
- import * as R18 from "ramda";
2593
+ import chalk3 from "chalk";
2594
+ import * as R19 from "ramda";
2427
2595
  import StyleDictionary2 from "style-dictionary";
2428
2596
 
2429
2597
  // src/tokens/types.ts
@@ -2434,30 +2602,30 @@ var colorCategories = {
2434
2602
 
2435
2603
  // src/tokens/process/configs.ts
2436
2604
  import { register } from "@tokens-studio/sd-transforms";
2437
- import * as R17 from "ramda";
2605
+ import * as R18 from "ramda";
2438
2606
  import StyleDictionary from "style-dictionary";
2439
2607
 
2440
2608
  // 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));
2609
+ import * as R8 from "ramda";
2610
+ var mapToLowerCase = R8.map(R8.toLower);
2611
+ var hasAnyTruth = R8.any(R8.equals(true));
2444
2612
  var getType = (token) => (token.$type ?? token.type) || "";
2445
2613
  var getValue = (token) => token.$value ?? token.value;
2446
- var typeEquals = R7.curry(
2614
+ var typeEquals = R8.curry(
2447
2615
  (types, token) => {
2448
- if (R7.isNil(token)) {
2616
+ if (R8.isNil(token)) {
2449
2617
  return false;
2450
2618
  }
2451
- return R7.includes(R7.toLower(getType(token)), R7.map(R7.toLower, Array.isArray(types) ? types : [types]));
2619
+ return R8.includes(R8.toLower(getType(token)), R8.map(R8.toLower, Array.isArray(types) ? types : [types]));
2452
2620
  }
2453
2621
  );
2454
- var pathStartsWithOneOf = R7.curry(
2622
+ var pathStartsWithOneOf = R8.curry(
2455
2623
  (paths, token) => {
2456
- if (R7.isNil(token)) {
2624
+ if (R8.isNil(token)) {
2457
2625
  return false;
2458
2626
  }
2459
2627
  const tokenPath = mapToLowerCase(token.path);
2460
- const matchPathsStartingWith = R7.map((path) => R7.startsWith([path], tokenPath), mapToLowerCase(paths));
2628
+ const matchPathsStartingWith = R8.map((path) => R8.startsWith([path], tokenPath), mapToLowerCase(paths));
2461
2629
  return hasAnyTruth(matchPathsStartingWith);
2462
2630
  }
2463
2631
  );
@@ -2465,16 +2633,18 @@ function isSemanticToken(token) {
2465
2633
  return token.filePath.includes("semantic/");
2466
2634
  }
2467
2635
  function isSemanticColorToken(token, color) {
2468
- return token.filePath.includes("semantic/") && R7.startsWith(["color", color], token.path);
2636
+ return token.filePath.includes("semantic/") && R8.startsWith(["color", color], token.path);
2469
2637
  }
2470
2638
  function isGlobalColorToken(token) {
2471
2639
  return typeEquals("color", token) && pathStartsWithOneOf(["global"], token);
2472
2640
  }
2473
2641
  function isColorCategoryToken(token, category) {
2474
2642
  if (!category) {
2475
- return ["main", "support"].some((c) => isColorCategoryToken(token, c));
2643
+ return Object.keys(colorCategories).some(
2644
+ (colorCategory2) => isColorCategoryToken(token, colorCategory2)
2645
+ );
2476
2646
  }
2477
- return R7.startsWith(["color", category], token.path);
2647
+ return R8.startsWith(["color", category], token.path);
2478
2648
  }
2479
2649
  var isDigit = (s) => /^\d+$/.test(s);
2480
2650
  function traverseObj(obj, fn) {
@@ -2490,7 +2660,7 @@ function traverseObj(obj, fn) {
2490
2660
  return obj;
2491
2661
  }
2492
2662
  function inlineTokens(shouldInline, tokens) {
2493
- const [inlineableTokens, otherTokens] = R7.partition(shouldInline, tokens);
2663
+ const [inlineableTokens, otherTokens] = R8.partition(shouldInline, tokens);
2494
2664
  return otherTokens.map((token) => {
2495
2665
  let transformed = getValue(token.original);
2496
2666
  for (const ref of inlineableTokens) {
@@ -2499,16 +2669,16 @@ function inlineTokens(shouldInline, tokens) {
2499
2669
  transformed = transformed.replaceAll(`{${refName}}`, getValue(ref.original));
2500
2670
  }
2501
2671
  }
2502
- const tokenWithInlinedRefs = R7.set(R7.lensPath(["original", "$value"]), transformed, token);
2672
+ const tokenWithInlinedRefs = R8.set(R8.lensPath(["original", "$value"]), transformed, token);
2503
2673
  return tokenWithInlinedRefs;
2504
2674
  });
2505
2675
  }
2506
2676
 
2507
2677
  // src/tokens/process/configs/color.ts
2508
- import * as R12 from "ramda";
2678
+ import * as R13 from "ramda";
2509
2679
 
2510
2680
  // src/tokens/process/formats/css/color.ts
2511
- import * as R8 from "ramda";
2681
+ import * as R9 from "ramda";
2512
2682
  import { createPropertyFormatter } from "style-dictionary/utils";
2513
2683
  var prefersColorScheme = (colorScheme2, content) => `
2514
2684
  @media (prefers-color-scheme: ${colorScheme2}) {
@@ -2517,7 +2687,7 @@ var prefersColorScheme = (colorScheme2, content) => `
2517
2687
  `;
2518
2688
  var colorScheme = {
2519
2689
  name: "ds/css-colorscheme",
2520
- format: async ({ dictionary, file, options, platform }) => {
2690
+ format: async ({ dictionary, options, platform }) => {
2521
2691
  const { allTokens } = dictionary;
2522
2692
  const { outputReferences, usesDtcg } = options;
2523
2693
  const { selector, colorScheme: colorScheme2, layer } = platform;
@@ -2532,8 +2702,8 @@ var colorScheme = {
2532
2702
  color-scheme: ${colorScheme_};
2533
2703
  ` : "";
2534
2704
  const filteredAllTokens = allTokens.filter(
2535
- R8.allPass([
2536
- R8.anyPass([
2705
+ R9.allPass([
2706
+ R9.anyPass([
2537
2707
  // Include semantic tokens in the output
2538
2708
  isSemanticToken,
2539
2709
  // Include global color tokens
@@ -2549,7 +2719,7 @@ ${formattedTokens}
2549
2719
  ${colorSchemeProperty}}
2550
2720
  `;
2551
2721
  const autoSelectorContent = ["light", "dark"].includes(colorScheme_) ? prefersColorScheme(colorScheme_, content) : "";
2552
- const body = R8.isNotNil(layer) ? `@layer ${layer} {
2722
+ const body = R9.isNotNil(layer) ? `@layer ${layer} {
2553
2723
  ${selector} ${content} ${autoSelectorContent}
2554
2724
  }
2555
2725
  ` : `${selector} ${content} ${autoSelectorContent}
@@ -2559,10 +2729,10 @@ ${selector} ${content} ${autoSelectorContent}
2559
2729
  };
2560
2730
  var colorCategory = {
2561
2731
  name: "ds/css-colorcategory",
2562
- format: async ({ dictionary, file, options, platform }) => {
2732
+ format: async ({ dictionary, options, platform }) => {
2563
2733
  const { outputReferences, usesDtcg } = options;
2564
2734
  const { selector, layer } = platform;
2565
- const format = R8.compose(
2735
+ const format = R9.compose(
2566
2736
  createPropertyFormatter({
2567
2737
  outputReferences,
2568
2738
  dictionary,
@@ -2583,7 +2753,7 @@ var colorCategory = {
2583
2753
  ${formattedTokens}
2584
2754
  }
2585
2755
  `;
2586
- const body = R8.isNotNil(layer) ? `@layer ${layer} {
2756
+ const body = R9.isNotNil(layer) ? `@layer ${layer} {
2587
2757
  ${selector} ${content}
2588
2758
  }
2589
2759
  ` : `${selector} ${content}
@@ -2593,16 +2763,16 @@ ${selector} ${content}
2593
2763
  };
2594
2764
 
2595
2765
  // src/tokens/process/formats/css/semantic.ts
2596
- import * as R9 from "ramda";
2766
+ import * as R10 from "ramda";
2597
2767
  import { createPropertyFormatter as createPropertyFormatter2 } from "style-dictionary/utils";
2598
2768
  var isNumericBorderRadiusToken = (t) => t.path[0] === "border-radius" && isDigit(t.path[1]);
2599
2769
  var isNumericSizeToken = (t) => pathStartsWithOneOf(["size"], t) && isDigit(t.path[1]);
2600
2770
  var isSizeToken = (t) => pathStartsWithOneOf(["size"], t);
2601
- var isInlineTokens = R9.anyPass([isNumericBorderRadiusToken, isNumericSizeToken, isSizeToken]);
2771
+ var isInlineTokens = R10.anyPass([isNumericBorderRadiusToken, isNumericSizeToken, isSizeToken]);
2602
2772
  var overrideSizingFormula = (format, token) => {
2603
2773
  const [name, value] = format(token).split(":");
2604
2774
  const calc = value.replace(`var(--ds-size-mode-font-size)`, "1em").replace(/floor\((.*)\);/, "calc($1)");
2605
- const round = `round(down, ${calc}, 0.0625rem)`;
2775
+ const round = `round(down, ${calc}, 1px)`;
2606
2776
  return {
2607
2777
  name,
2608
2778
  round,
@@ -2610,7 +2780,7 @@ var overrideSizingFormula = (format, token) => {
2610
2780
  };
2611
2781
  };
2612
2782
  var formatSizingTokens = (format, tokens) => {
2613
- const { round, calc } = R9.reduce(
2783
+ const { round, calc } = R10.reduce(
2614
2784
  (acc, token) => {
2615
2785
  const { round: round2, calc: calc2, name } = overrideSizingFormula(format, token);
2616
2786
  return {
@@ -2630,7 +2800,7 @@ ${round.join("\n")}
2630
2800
  };
2631
2801
  var semantic = {
2632
2802
  name: "ds/css-semantic",
2633
- format: async ({ dictionary, file, options, platform }) => {
2803
+ format: async ({ dictionary, options, platform }) => {
2634
2804
  const { outputReferences, usesDtcg } = options;
2635
2805
  const { selector, layer } = platform;
2636
2806
  const format = createPropertyFormatter2({
@@ -2640,17 +2810,17 @@ var semantic = {
2640
2810
  usesDtcg
2641
2811
  });
2642
2812
  const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
2643
- const filteredTokens = R9.reject((token) => token.name.includes("ds-size-mode-font-size"), tokens);
2644
- const [sizingTokens, restTokens] = R9.partition(
2813
+ const filteredTokens = R10.reject((token) => token.name.includes("ds-size-mode-font-size"), tokens);
2814
+ const [sizingTokens, restTokens] = R10.partition(
2645
2815
  (t) => pathStartsWithOneOf(["_size"], t) && isDigit(t.path[1]),
2646
2816
  filteredTokens
2647
2817
  );
2648
- const formattedTokens = [R9.map(format, restTokens).join("\n"), formatSizingTokens(format, sizingTokens)];
2818
+ const formattedTokens = [R10.map(format, restTokens).join("\n"), formatSizingTokens(format, sizingTokens)];
2649
2819
  const content = `{
2650
2820
  ${formattedTokens.join("\n")}
2651
2821
  }
2652
2822
  `;
2653
- const body = R9.isNotNil(layer) ? `@layer ${layer} {
2823
+ const body = R10.isNotNil(layer) ? `@layer ${layer} {
2654
2824
  ${selector} ${content}
2655
2825
  }
2656
2826
  ` : `${selector} ${content}
@@ -2660,15 +2830,15 @@ ${selector} ${content}
2660
2830
  };
2661
2831
 
2662
2832
  // src/tokens/process/formats/css/typography.ts
2663
- import * as R10 from "ramda";
2833
+ import * as R11 from "ramda";
2664
2834
  import { createPropertyFormatter as createPropertyFormatter3 } from "style-dictionary/utils";
2665
- var typographyFontFamilyPredicate = R10.allPass([
2666
- R10.pathSatisfies(R10.includes("typography"), ["path"]),
2667
- R10.pathSatisfies(R10.includes("fontFamily"), ["path"])
2835
+ var typographyFontFamilyPredicate = R11.allPass([
2836
+ R11.pathSatisfies(R11.includes("typography"), ["path"]),
2837
+ R11.pathSatisfies(R11.includes("fontFamily"), ["path"])
2668
2838
  ]);
2669
2839
  var typography = {
2670
2840
  name: "ds/css-typography",
2671
- format: async ({ dictionary, file, options, platform }) => {
2841
+ format: async ({ dictionary, options, platform }) => {
2672
2842
  const { outputReferences, usesDtcg } = options;
2673
2843
  const { selector, layer } = platform;
2674
2844
  const format = createPropertyFormatter3({
@@ -2677,12 +2847,12 @@ var typography = {
2677
2847
  format: "css",
2678
2848
  usesDtcg
2679
2849
  });
2680
- const filteredTokens = R10.reject(typographyFontFamilyPredicate, dictionary.allTokens);
2681
- const formattedTokens = R10.pipe(R10.map(format), R10.join("\n"))(filteredTokens);
2850
+ const filteredTokens = R11.reject(typographyFontFamilyPredicate, dictionary.allTokens);
2851
+ const formattedTokens = R11.pipe(R11.map(format), R11.join("\n"))(filteredTokens);
2682
2852
  const content = selector ? `${selector} {
2683
2853
  ${formattedTokens}
2684
2854
  }` : formattedTokens;
2685
- const body = R10.isNotNil(layer) ? `@layer ${layer} {
2855
+ const body = R11.isNotNil(layer) ? `@layer ${layer} {
2686
2856
  ${content}
2687
2857
  }` : content;
2688
2858
  return body;
@@ -2699,8 +2869,8 @@ var formats = {
2699
2869
 
2700
2870
  // src/tokens/process/transformers.ts
2701
2871
  import { checkAndEvaluateMath } from "@tokens-studio/sd-transforms";
2702
- import * as R11 from "ramda";
2703
- var isPx = R11.test(/\b\d+px\b/g);
2872
+ import * as R12 from "ramda";
2873
+ var isPx = R12.test(/\b\d+px\b/g);
2704
2874
  var sizeRem = {
2705
2875
  name: "ds/size/toRem",
2706
2876
  type: "value",
@@ -2790,7 +2960,7 @@ var colorSchemeVariables = ({ "color-scheme": colorScheme2 = "light", theme }) =
2790
2960
  {
2791
2961
  destination: `color-scheme/${colorScheme2}.css`,
2792
2962
  format: formats.colorScheme.name,
2793
- filter: (token) => typeEquals("color", token) && !R12.startsWith(["global"], token.path)
2963
+ filter: (token) => typeEquals("color", token) && !R13.startsWith(["global"], token.path)
2794
2964
  }
2795
2965
  ],
2796
2966
  options: {
@@ -2809,7 +2979,7 @@ var colorCategoryVariables = (opts) => ({ "color-scheme": colorScheme2, theme, .
2809
2979
  );
2810
2980
  }
2811
2981
  const layer = `ds.theme.color`;
2812
- const isRootColor = color === buildOptions?.rootColor;
2982
+ const isRootColor = color === buildOptions?.defaultColor;
2813
2983
  const selector = isRootColor ? `:root, [data-color-scheme], [data-color="${color}"]` : `[data-color="${color}"], [data-color-scheme][data-color="${color}"]`;
2814
2984
  const config = {
2815
2985
  preprocessors: ["tokens-studio"],
@@ -2841,7 +3011,7 @@ var colorCategoryVariables = (opts) => ({ "color-scheme": colorScheme2, theme, .
2841
3011
  };
2842
3012
 
2843
3013
  // src/tokens/process/configs/semantic.ts
2844
- import * as R13 from "ramda";
3014
+ import * as R14 from "ramda";
2845
3015
  import { outputReferencesFilter } from "style-dictionary/utils";
2846
3016
  var semanticVariables = ({ theme }) => {
2847
3017
  const selector = `:root`;
@@ -2864,8 +3034,8 @@ var semanticVariables = ({ theme }) => {
2864
3034
  destination: `semantic.css`,
2865
3035
  format: formats.semantic.name,
2866
3036
  filter: (token) => {
2867
- const isUwantedToken = R13.anyPass([R13.includes("primitives/global")])(token.filePath);
2868
- const isPrivateToken = R13.includes("_", token.path);
3037
+ const isUwantedToken = R14.anyPass([R14.includes("primitives/global")])(token.filePath);
3038
+ const isPrivateToken = R14.includes("_", token.path);
2869
3039
  const unwantedPaths = pathStartsWithOneOf(["font-size", "line-height", "letter-spacing"], token);
2870
3040
  const unwantedTypes = typeEquals(["color", "fontWeight", "fontFamily", "typography"], token);
2871
3041
  const unwantedTokens = !(unwantedPaths || unwantedTypes || isPrivateToken || isUwantedToken);
@@ -2886,20 +3056,20 @@ var semanticVariables = ({ theme }) => {
2886
3056
  };
2887
3057
 
2888
3058
  // src/tokens/process/configs/storefront.ts
2889
- import * as R15 from "ramda";
3059
+ import * as R16 from "ramda";
2890
3060
  import { outputReferencesFilter as outputReferencesFilter2 } from "style-dictionary/utils";
2891
3061
 
2892
3062
  // src/tokens/process/formats/js-tokens.ts
2893
- import * as R14 from "ramda";
3063
+ import * as R15 from "ramda";
2894
3064
  import { createPropertyFormatter as createPropertyFormatter4, fileHeader } from "style-dictionary/utils";
2895
- var groupByType = R14.groupBy((token) => getType(token));
2896
- var removeUnwatedTokens = R14.pipe(
2897
- R14.reject((token) => isColorCategoryToken(token)),
2898
- R14.reject((token) => R14.any((path) => path.startsWith("_"))(token.path))
3065
+ var groupByType = R15.groupBy((token) => getType(token));
3066
+ var removeUnwatedTokens = R15.pipe(
3067
+ R15.reject((token) => isColorCategoryToken(token)),
3068
+ R15.reject((token) => R15.any((path) => path.startsWith("_"))(token.path))
2899
3069
  );
2900
- var dissocExtensions = R14.pipe(R14.dissoc("$extensions"), R14.dissocPath(["original", "$extensions"]));
2901
- var removeUnwatedProps = R14.map((token) => dissocExtensions(token));
2902
- var toCssVarName = R14.pipe(R14.split(":"), R14.head, R14.trim);
3070
+ var dissocExtensions = R15.pipe(R15.dissoc("$extensions"), R15.dissocPath(["original", "$extensions"]));
3071
+ var removeUnwatedProps = R15.map((token) => dissocExtensions(token));
3072
+ var toCssVarName = R15.pipe(R15.split(":"), R15.head, R15.trim);
2903
3073
  var jsTokens = {
2904
3074
  name: "ds/js-tokens",
2905
3075
  format: async ({ dictionary, file, options }) => {
@@ -2910,7 +3080,7 @@ var jsTokens = {
2910
3080
  format: "css",
2911
3081
  usesDtcg
2912
3082
  });
2913
- const formatTokens2 = R14.map((token) => {
3083
+ const formatTokens2 = R15.map((token) => {
2914
3084
  if (pathStartsWithOneOf(["size", "_size"], token)) {
2915
3085
  const { calc, name } = overrideSizingFormula(format, token);
2916
3086
  return {
@@ -2924,7 +3094,7 @@ var jsTokens = {
2924
3094
  name: toCssVarName(format(token))
2925
3095
  };
2926
3096
  });
2927
- const processTokens = R14.pipe(removeUnwatedTokens, removeUnwatedProps, formatTokens2, groupByType);
3097
+ const processTokens = R15.pipe(removeUnwatedTokens, removeUnwatedProps, formatTokens2, groupByType);
2928
3098
  const tokens = processTokens(inlineTokens(isInlineTokens, dictionary.allTokens));
2929
3099
  const content = Object.entries(tokens).map(
2930
3100
  ([name, token]) => `export const ${name} = ${JSON.stringify(token, null, 2).replace(/"([^"]+)":/g, "$1:")}
@@ -2949,9 +3119,9 @@ var typescriptTokens = ({ "color-scheme": colorScheme2, theme }) => {
2949
3119
  destination: `${colorScheme2}.ts`,
2950
3120
  format: jsTokens.name,
2951
3121
  filter: (token) => {
2952
- if (pathStartsWithOneOf(["border-width", "letter-spacing", "border-radius"], token) && !R15.includes("semantic", token.filePath))
3122
+ if (pathStartsWithOneOf(["border-width", "letter-spacing", "border-radius"], token) && !R16.includes("semantic", token.filePath))
2953
3123
  return false;
2954
- const isSemanticColor = R15.includes("semantic", token.filePath) && typeEquals(["color"], token);
3124
+ const isSemanticColor = R16.includes("semantic", token.filePath) && typeEquals(["color"], token);
2955
3125
  const wantedTypes = typeEquals(["shadow", "dimension", "typography", "opacity"], token);
2956
3126
  return isSemanticColor || wantedTypes;
2957
3127
  }
@@ -3017,19 +3187,19 @@ var typographyVariables = ({ theme, typography: typography2 }) => {
3017
3187
  };
3018
3188
 
3019
3189
  // src/tokens/process/utils/getMultidimensionalThemes.ts
3020
- import chalk from "chalk";
3190
+ import chalk2 from "chalk";
3021
3191
  import { kebabCase } from "change-case";
3022
- import * as R16 from "ramda";
3192
+ import * as R17 from "ramda";
3023
3193
  var getMultidimensionalThemes = (processed$themes, dimensions) => {
3024
3194
  const verboseLogging = buildOptions?.verbose;
3025
3195
  const grouped$themes = groupThemes(processed$themes);
3026
3196
  const permutations = permutateThemes(grouped$themes);
3027
3197
  const ALL_DEPENDENT_ON = ["theme"];
3028
- const keys2 = R16.keys(grouped$themes);
3198
+ const keys2 = R17.keys(grouped$themes);
3029
3199
  const nonDependentKeys = keys2.filter((x) => ![...ALL_DEPENDENT_ON, ...dimensions].includes(x));
3030
3200
  if (verboseLogging) {
3031
- console.log(chalk.cyan(`\u{1F50E} Finding theme permutations for ${dimensions}`));
3032
- console.log(chalk.cyan(` (ignoring permutations for ${nonDependentKeys})`));
3201
+ console.log(chalk2.cyan(`\u{1F50E} Finding theme permutations for ${dimensions}`));
3202
+ console.log(chalk2.cyan(` (ignoring permutations for ${nonDependentKeys})`));
3033
3203
  }
3034
3204
  return permutations.filter((val) => {
3035
3205
  const filters = nonDependentKeys.map((x) => val.permutation[x] === grouped$themes[x][0].name);
@@ -3053,8 +3223,7 @@ function processThemeObject(theme) {
3053
3223
  }
3054
3224
  function groupThemes(themes) {
3055
3225
  const groups = {};
3056
- for (const rawTheme of themes) {
3057
- const theme = processThemeObject(rawTheme);
3226
+ for (const theme of themes) {
3058
3227
  if (theme.group) {
3059
3228
  const groupKey = theme.group;
3060
3229
  groups[groupKey] = [...groups[groupKey] ?? [], theme];
@@ -3066,7 +3235,7 @@ function groupThemes(themes) {
3066
3235
  }
3067
3236
  return groups;
3068
3237
  }
3069
- var hasUnknownProps = R16.pipe(R16.values, R16.none(R16.equals("unknown")), R16.not);
3238
+ var hasUnknownProps = R17.pipe(R17.values, R17.none(R17.equals("unknown")), R17.not);
3070
3239
  function permutateThemes(groups) {
3071
3240
  const separator = "_";
3072
3241
  const permutations = cartesian(Object.values(groups));
@@ -3076,8 +3245,8 @@ function permutateThemes(groups) {
3076
3245
  const { group, name, selectedTokenSets } = theme;
3077
3246
  let updatedPermutation = acc.permutation;
3078
3247
  if (group) {
3079
- const groupProp = R16.lensProp(group);
3080
- updatedPermutation = R16.set(groupProp, name, updatedPermutation);
3248
+ const groupProp = R17.lensProp(group);
3249
+ updatedPermutation = R17.set(groupProp, name, updatedPermutation);
3081
3250
  }
3082
3251
  const updatedName = `${String(acc.name)}${acc ? separator : ""}${name}`;
3083
3252
  const sets = [...acc.selectedTokenSets, ...filterTokenSets(selectedTokenSets)];
@@ -3161,7 +3330,7 @@ var getConfigsForThemeDimensions = (getConfig, processed$themes, dimensions, opt
3161
3330
  obj.filePath = tokenSet;
3162
3331
  }
3163
3332
  });
3164
- tokenSource.tokens = R17.mergeDeepRight(tokenSource.tokens, tokensWithFilePath);
3333
+ tokenSource.tokens = R18.mergeDeepRight(tokenSource.tokens, tokensWithFilePath);
3165
3334
  }
3166
3335
  }
3167
3336
  } else {
@@ -3205,9 +3374,12 @@ var initResult = {
3205
3374
  };
3206
3375
  var buildOptions;
3207
3376
  var sd = new StyleDictionary2();
3208
- var getCustomColors = (processed$themes) => processed$themes.filter(
3209
- (x) => x.group && [colorCategories.main, colorCategories.support].map((c) => `${c}-color`).includes(x.group)
3210
- ).map((x) => x.name);
3377
+ var getCustomColors = (processed$themes, colorGroups) => processed$themes.filter((x) => {
3378
+ if (!x.group) {
3379
+ return false;
3380
+ }
3381
+ return colorGroups.includes(x.group);
3382
+ }).map((x) => x.name);
3211
3383
  var buildConfigs = {
3212
3384
  typography: { getConfig: configs.typographyVariables, dimensions: ["typography"] },
3213
3385
  "color-scheme": { getConfig: configs.colorSchemeVariables, dimensions: ["color-scheme"] },
@@ -3248,19 +3420,42 @@ var buildConfigs = {
3248
3420
  // },
3249
3421
  };
3250
3422
  async function processPlatform(options) {
3251
- const { process, $themes } = options;
3423
+ const { type, $themes } = options;
3252
3424
  const platform = "css";
3253
- const tokenSets = process === "format" ? options.tokenSets : void 0;
3254
- const tokensDir = process === "build" ? options.tokensDir : void 0;
3425
+ const tokenSets = type === "format" ? options.tokenSets : void 0;
3426
+ const tokensDir = type === "build" ? options.tokensDir : void 0;
3427
+ const UNSAFE_DEFAULT_COLOR = process.env.UNSAFE_DEFAULT_COLOR ?? "";
3428
+ if (UNSAFE_DEFAULT_COLOR) {
3429
+ console.warn(
3430
+ chalk3.yellow(
3431
+ `
3432
+ \u26A0\uFE0F UNSAFE_DEFAULT_COLOR is set to ${chalk3.blue(UNSAFE_DEFAULT_COLOR)}. This will override the default color.`
3433
+ )
3434
+ );
3435
+ }
3436
+ const UNSAFE_COLOR_GROUPS = Array.from(process.env.UNSAFE_COLOR_GROUPS?.split(",") ?? []);
3437
+ if (UNSAFE_COLOR_GROUPS.length > 0) {
3438
+ console.warn(
3439
+ chalk3.yellow(
3440
+ `
3441
+ \u26A0\uFE0F UNSAFE_COLOR_GROUPS is set to ${chalk3.blue(`[${UNSAFE_COLOR_GROUPS.join(", ")}]`)}. This will override the default color groups.`
3442
+ )
3443
+ );
3444
+ }
3445
+ const colorGroups = UNSAFE_COLOR_GROUPS.length > 0 ? UNSAFE_COLOR_GROUPS : [colorCategories.main, colorCategories.support].map((c) => `${c}-color`);
3255
3446
  buildOptions = options;
3256
- const processed$themes = $themes.map(processThemeObject).filter((theme) => R18.not(theme.group === "size" && theme.name !== "medium"));
3257
- const customColors = getCustomColors(processed$themes);
3258
- if (!buildOptions.rootColor) {
3259
- const firstMainColor = R18.head(customColors);
3260
- buildOptions.rootColor = firstMainColor;
3261
- console.log(`Using first main color; ${chalk2.blue(firstMainColor)}, as ${chalk2.green(`":root"`)} color`);
3447
+ buildOptions.defaultColor = UNSAFE_DEFAULT_COLOR;
3448
+ const processed$themes = $themes.map(processThemeObject).filter((theme) => R19.not(theme.group === "size" && theme.name !== "medium"));
3449
+ const customColors = getCustomColors(processed$themes, colorGroups);
3450
+ if (!buildOptions.defaultColor) {
3451
+ const firstMainColor = R19.head(customColors);
3452
+ buildOptions.defaultColor = firstMainColor;
3453
+ }
3454
+ if (buildOptions.defaultColor) {
3455
+ console.log(`
3456
+ \u{1F3A8} Using ${chalk3.blue(buildOptions.defaultColor)} as default color`);
3262
3457
  }
3263
- const buildAndSdConfigs = R18.map((buildConfig) => {
3458
+ const buildAndSdConfigs = R19.map((buildConfig) => {
3264
3459
  const sdConfigs = getConfigsForThemeDimensions(buildConfig.getConfig, processed$themes, buildConfig.dimensions, {
3265
3460
  tokensDir,
3266
3461
  tokenSets
@@ -3292,19 +3487,19 @@ async function processPlatform(options) {
3292
3487
  types: [initResult]
3293
3488
  };
3294
3489
  try {
3295
- for (const [buildName, { buildConfig, sdConfigs }] of R18.toPairs(buildAndSdConfigs)) {
3490
+ for (const [buildName, { buildConfig, sdConfigs }] of R19.toPairs(buildAndSdConfigs)) {
3296
3491
  if (!(buildConfig.enabled?.() ?? true)) {
3297
3492
  continue;
3298
3493
  }
3299
3494
  if (sdConfigs.length > 0) {
3300
3495
  console.log(`
3301
- \u{1F371} Building ${chalk2.green(buildConfig.name ?? buildName)}`);
3496
+ \u{1F371} Building ${chalk3.green(buildConfig.name ?? buildName)}`);
3302
3497
  const results = await Promise.all(
3303
3498
  sdConfigs.map(async (sdConfig) => {
3304
3499
  const { config, permutation } = sdConfig;
3305
3500
  const modes = ["theme", ...buildConfig.dimensions];
3306
3501
  const modeMessage = modes.map((x) => permutation[x]).join(" - ");
3307
- const logMessage = R18.isNil(buildConfig.log) ? modeMessage : buildConfig?.log(sdConfig);
3502
+ const logMessage = R19.isNil(buildConfig.log) ? modeMessage : buildConfig?.log(sdConfig);
3308
3503
  console.log(logMessage);
3309
3504
  const sdOptions = { cache: true };
3310
3505
  const sdExtended = await sd.extend(config);
@@ -3336,7 +3531,7 @@ async function processPlatform(options) {
3336
3531
  }
3337
3532
  async function createColorTypeDeclaration(colors) {
3338
3533
  console.log(`
3339
- \u{1F371} Building ${chalk2.green("type declarations")}`);
3534
+ \u{1F371} Building ${chalk3.green("type declarations")}`);
3340
3535
  const typeDeclaration = `
3341
3536
  import type {} from '@digdir/designsystemet-react/colors';
3342
3537
 
@@ -3349,178 +3544,10 @@ ${colors.map((color) => ` ${color}: never;`).join("\n")}
3349
3544
  return typeDeclaration;
3350
3545
  }
3351
3546
 
3352
- // src/tokens/process/theme.ts
3353
- import * as R19 from "ramda";
3354
- import chalk3 from "chalk";
3355
-
3356
- // package.json
3357
- var package_default = {
3358
- name: "@digdir/designsystemet",
3359
- version: "1.0.7",
3360
- description: "CLI for Designsystemet",
3361
- author: "Designsystemet team",
3362
- engines: {
3363
- node: ">=22.16.0"
3364
- },
3365
- repository: {
3366
- type: "git",
3367
- url: "git+https://github.com/digdir/designsystemet.git"
3368
- },
3369
- homepage: "https://github.com/digdir/designsystemet/tree/main/scripts/cli",
3370
- license: "MIT",
3371
- type: "module",
3372
- main: "./dist/src/index.js",
3373
- files: [
3374
- "./dist/**",
3375
- "./configs/**"
3376
- ],
3377
- bin: "dist/bin/designsystemet.js",
3378
- exports: {
3379
- ".": {
3380
- import: "./dist/src/index.js"
3381
- },
3382
- "./color": {
3383
- import: "./dist/src/colors/index.js"
3384
- },
3385
- "./tokens": {
3386
- import: "./dist/src/tokens/index.js"
3387
- }
3388
- },
3389
- publishConfig: {
3390
- access: "public"
3391
- },
3392
- scripts: {
3393
- designsystemet: "tsx ./bin/designsystemet.ts",
3394
- "build:tokens": "pnpm run designsystemet tokens build -p -t ../../internal/design-tokens -o ../../packages/theme/brand --clean",
3395
- "build:tokens:debug": "tsx --inspect-brk ./bin/designsystemet.ts tokens build -p -t ../../internal/design-tokens -o ../../packages/theme/brand --clean",
3396
- build: "tsup && pnpm build:types && pnpm build:json-schema",
3397
- "build:types": "tsc --emitDeclarationOnly --declaration",
3398
- "build:json-schema": "tsx ./src/scripts/createJsonSchema.ts",
3399
- types: "tsc --noEmit",
3400
- "test:tokens-create-options": 'pnpm run designsystemet tokens create -m dominant:"#007682" -n "#003333" -b 99 -o ./temp/options/design-tokens --theme options --clean',
3401
- "test:tokens-create-config": "pnpm run designsystemet tokens create --config ./configs/test-tokens.config.json",
3402
- "test:tokens-build": "pnpm run designsystemet tokens build -t ./temp/options/design-tokens -o ./temp/options/build --clean",
3403
- "test:tokens-build-config": "pnpm run designsystemet tokens build -t ./temp/config/design-tokens -o ./temp/config/build --clean",
3404
- "test:tokens-create-and-build-options": "pnpm test:tokens-create-options && pnpm test:tokens-build",
3405
- "test:tokens-create-and-build-config": "pnpm test:tokens-create-config && pnpm test:tokens-build-config",
3406
- test: "pnpm test:tokens-create-and-build-options && pnpm test:tokens-create-and-build-config",
3407
- "digdir:tokens-create": "pnpm run designsystemet tokens create --config ./configs/digdir.config.json",
3408
- "update:template": "tsx ./src/scripts/update-template.ts",
3409
- "update:design-tokens": "pnpm digdir:tokens-create && tsx ./src/scripts/update-design-tokens.ts",
3410
- verify: "pnpm test && pnpm update:template && pnpm update:design-tokens"
3411
- },
3412
- dependencies: {
3413
- "@commander-js/extra-typings": "^13.1.0",
3414
- "@tokens-studio/sd-transforms": "1.3.0",
3415
- "apca-w3": "^0.1.9",
3416
- chalk: "^5.4.1",
3417
- "change-case": "^5.4.4",
3418
- "chroma-js": "^3.1.2",
3419
- "colorjs.io": "^0.6.0-alpha.1",
3420
- commander: "^13.1.0",
3421
- "fast-glob": "^3.3.3",
3422
- hsluv: "^1.0.1",
3423
- "object-hash": "^3.0.0",
3424
- postcss: "^8.5.3",
3425
- ramda: "^0.30.1",
3426
- "style-dictionary": "^4.4.0",
3427
- zod: "^3.25.30",
3428
- "zod-validation-error": "^3.4.1"
3429
- },
3430
- devDependencies: {
3431
- "@tokens-studio/types": "0.5.2",
3432
- "@types/apca-w3": "^0.1.3",
3433
- "@types/chroma-js": "^3.1.1",
3434
- "@types/fs-extra": "^11.0.4",
3435
- "@types/glob": "^8.1.0",
3436
- "@types/jscodeshift": "^0.12.0",
3437
- "@types/node": "^22.15.21",
3438
- "@types/object-hash": "^3.0.6",
3439
- "@types/ramda": "^0.30.2",
3440
- "fs-extra": "^11.3.0",
3441
- "ts-toolbelt": "^9.6.0",
3442
- tslib: "^2.8.1",
3443
- tsup: "^8.5.0",
3444
- tsx: "^4.19.4",
3445
- typescript: "^5.8.3"
3446
- }
3447
- };
3448
-
3449
- // src/tokens/process/theme.ts
3450
- var defaultFileHeader = `build: v${package_default.version}`;
3451
- var createThemeCSSFiles = ({
3452
- processedBuilds,
3453
- fileHeader: fileHeader2 = defaultFileHeader
3454
- }) => {
3455
- const groupedByTheme = {};
3456
- for (const [_, buildResults] of Object.entries(R19.dissoc("types", processedBuilds))) {
3457
- for (const buildResult of buildResults) {
3458
- const themeName = buildResult.permutation.theme;
3459
- const newOutputs = buildResult.formatted;
3460
- if (R19.isNotEmpty(newOutputs)) {
3461
- const currentOutputs = groupedByTheme[themeName] ?? [];
3462
- groupedByTheme[themeName] = R19.concat(currentOutputs, newOutputs);
3463
- }
3464
- }
3465
- }
3466
- const sortOrder = [
3467
- "color-scheme/light",
3468
- "typography/secondary",
3469
- "semantic",
3470
- "color-scheme/dark",
3471
- "color-scheme/contrast",
3472
- "typography/primary",
3473
- "color/"
3474
- ];
3475
- const sortByDefinedOrder = R19.sortBy((file) => {
3476
- const filePath = file.destination || "";
3477
- const sortIndex = sortOrder.findIndex((sortElement) => {
3478
- if (sortElement.endsWith("/")) {
3479
- return filePath.includes(sortElement);
3480
- }
3481
- return filePath.includes(`${sortElement}.css`);
3482
- });
3483
- if (sortIndex === -1) {
3484
- console.error(
3485
- chalk3.yellow("WARNING: CSS section does not have a defined sort order:", filePath.replace(".css", ""))
3486
- );
3487
- console.log(
3488
- chalk3.dim(
3489
- `
3490
- The section will currently be added to the end of the entry file, but the exact
3491
- order may change due to nondeterminism.`.trim()
3492
- )
3493
- );
3494
- return Infinity;
3495
- }
3496
- return sortIndex;
3497
- });
3498
- const header = `@charset "UTF-8";
3499
- /*
3500
- ${fileHeader2}
3501
- */
3502
-
3503
- `;
3504
- const sortAlphabetically = R19.sort(R19.ascend((x) => x.destination || ""));
3505
- const pickOutputs = R19.map(R19.view(R19.lensProp("output")));
3506
- const themeCSSFile = R19.pipe(
3507
- sortAlphabetically,
3508
- sortByDefinedOrder,
3509
- pickOutputs,
3510
- R19.join("\n"),
3511
- (content) => header + content
3512
- );
3513
- const themeCSSFiles = Object.entries(groupedByTheme).map(([theme, files]) => ({
3514
- destination: `${theme}.css`,
3515
- output: themeCSSFile(files)
3516
- }));
3517
- return themeCSSFiles;
3518
- };
3519
-
3520
3547
  // src/tokens/format.ts
3521
3548
  var formatTokens = async (options) => {
3522
3549
  const processedBuilds = await processPlatform({
3523
- process: "format",
3550
+ type: "format",
3524
3551
  ...options
3525
3552
  });
3526
3553
  return processedBuilds;