@digdir/designsystemet 1.0.3 → 1.0.5

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 (189) hide show
  1. package/dist/bin/designsystemet.js +4287 -45
  2. package/dist/bin/options.js +5 -4
  3. package/dist/src/colors/colorMetadata.js +5 -4
  4. package/dist/src/colors/index.js +470 -4
  5. package/dist/src/colors/theme.js +286 -20
  6. package/dist/src/colors/utils.js +16 -15
  7. package/dist/{bin → src}/config.d.ts +46 -1
  8. package/dist/src/config.d.ts.map +1 -0
  9. package/dist/src/config.js +377 -0
  10. package/dist/src/index.js +3682 -2
  11. package/dist/src/migrations/beta-to-v1.js +85 -4
  12. package/dist/src/migrations/codemods/css/plugins.js +5 -4
  13. package/dist/src/migrations/codemods/css/run.d.ts.map +1 -1
  14. package/dist/src/migrations/codemods/css/run.js +18 -4
  15. package/dist/src/migrations/color-rename-next49.js +77 -6
  16. package/dist/src/migrations/index.d.ts +0 -1
  17. package/dist/src/migrations/index.d.ts.map +1 -1
  18. package/dist/src/migrations/index.js +461 -6
  19. package/dist/src/scripts/createJsonSchema.js +1608 -4
  20. package/dist/src/scripts/update-design-tokens.d.ts +2 -0
  21. package/dist/src/scripts/update-design-tokens.d.ts.map +1 -0
  22. package/dist/src/scripts/update-design-tokens.js +37 -0
  23. package/dist/src/{tokens/template.d.ts → scripts/update-template.d.ts} +1 -1
  24. package/dist/src/scripts/update-template.d.ts.map +1 -0
  25. package/dist/src/scripts/update-template.js +1200 -0
  26. package/dist/src/tokens/build.d.ts +2 -19
  27. package/dist/src/tokens/build.d.ts.map +1 -1
  28. package/dist/src/tokens/build.js +1268 -70
  29. package/dist/src/tokens/create/defaults.d.ts +7 -0
  30. package/dist/src/tokens/create/defaults.d.ts.map +1 -0
  31. package/dist/src/tokens/create/defaults.js +994 -0
  32. package/dist/src/tokens/create/generators/$designsystemet.d.ts +5 -0
  33. package/dist/src/tokens/create/generators/$designsystemet.d.ts.map +1 -0
  34. package/dist/src/tokens/create/generators/$designsystemet.js +101 -0
  35. package/dist/src/tokens/create/generators/$metadata.d.ts +8 -0
  36. package/dist/src/tokens/create/generators/$metadata.d.ts.map +1 -0
  37. package/dist/src/tokens/{write/generate$metadata.js → create/generators/$metadata.js} +3 -2
  38. package/dist/src/tokens/create/generators/$themes.d.ts +12 -0
  39. package/dist/src/tokens/create/generators/$themes.d.ts.map +1 -0
  40. package/dist/src/tokens/create/generators/$themes.js +333 -0
  41. package/dist/src/tokens/create/generators/color.d.ts +5 -0
  42. package/dist/src/tokens/create/generators/color.d.ts.map +1 -0
  43. package/dist/src/tokens/create/generators/color.js +374 -0
  44. package/dist/src/tokens/create/generators/semantic.d.ts +296 -0
  45. package/dist/src/tokens/create/generators/semantic.d.ts.map +1 -0
  46. package/dist/src/tokens/create/generators/semantic.js +483 -0
  47. package/dist/src/tokens/create/generators/theme.d.ts +3 -0
  48. package/dist/src/tokens/create/generators/theme.d.ts.map +1 -0
  49. package/dist/src/tokens/create/generators/theme.js +168 -0
  50. package/dist/src/tokens/create/generators/typography.d.ts +3 -0
  51. package/dist/src/tokens/create/generators/typography.d.ts.map +1 -0
  52. package/dist/src/tokens/create/generators/typography.js +33 -0
  53. package/dist/src/tokens/{write.d.ts → create/write.d.ts} +2 -2
  54. package/dist/src/tokens/create/write.d.ts.map +1 -0
  55. package/dist/src/tokens/create/write.js +547 -0
  56. package/dist/src/tokens/create.d.ts +4 -2
  57. package/dist/src/tokens/create.d.ts.map +1 -1
  58. package/dist/src/tokens/create.js +2049 -59
  59. package/dist/src/tokens/format.d.ts +15 -0
  60. package/dist/src/tokens/format.d.ts.map +1 -0
  61. package/dist/src/tokens/format.js +3529 -0
  62. package/dist/src/tokens/index.d.ts +1 -0
  63. package/dist/src/tokens/index.d.ts.map +1 -1
  64. package/dist/src/tokens/index.js +3542 -2
  65. package/dist/src/tokens/process/configs/color.d.ts +12 -0
  66. package/dist/src/tokens/process/configs/color.d.ts.map +1 -0
  67. package/dist/src/tokens/process/configs/color.js +823 -0
  68. package/dist/src/tokens/process/configs/semantic.d.ts +3 -0
  69. package/dist/src/tokens/process/configs/semantic.d.ts.map +1 -0
  70. package/dist/src/tokens/process/configs/semantic.js +367 -0
  71. package/dist/src/tokens/process/configs/shared.d.ts +10 -0
  72. package/dist/src/tokens/process/configs/shared.d.ts.map +1 -0
  73. package/dist/src/tokens/process/configs/shared.js +99 -0
  74. package/dist/src/tokens/process/configs/storefront.d.ts +3 -0
  75. package/dist/src/tokens/process/configs/storefront.d.ts.map +1 -0
  76. package/dist/src/tokens/process/configs/storefront.js +220 -0
  77. package/dist/src/tokens/process/configs/typography.d.ts +3 -0
  78. package/dist/src/tokens/process/configs/typography.d.ts.map +1 -0
  79. package/dist/src/tokens/process/configs/typography.js +369 -0
  80. package/dist/src/tokens/{build → process}/configs.d.ts +3 -11
  81. package/dist/src/tokens/process/configs.d.ts.map +1 -0
  82. package/dist/src/tokens/process/configs.js +976 -0
  83. package/dist/src/tokens/process/formats/css/color.d.ts +4 -0
  84. package/dist/src/tokens/process/formats/css/color.d.ts.map +1 -0
  85. package/dist/src/tokens/process/formats/css/color.js +128 -0
  86. package/dist/src/tokens/process/formats/css/semantic.d.ts +17 -0
  87. package/dist/src/tokens/process/formats/css/semantic.d.ts.map +1 -0
  88. package/dist/src/tokens/process/formats/css/semantic.js +109 -0
  89. package/dist/src/tokens/process/formats/css/typography.d.ts +3 -0
  90. package/dist/src/tokens/process/formats/css/typography.d.ts.map +1 -0
  91. package/dist/src/tokens/process/formats/css/typography.js +32 -0
  92. package/dist/src/tokens/process/formats/css.d.ts +8 -0
  93. package/dist/src/tokens/process/formats/css.d.ts.map +1 -0
  94. package/dist/src/tokens/{build → process}/formats/css.js +94 -57
  95. package/dist/src/tokens/process/formats/js-tokens.d.ts.map +1 -0
  96. package/dist/src/tokens/process/formats/js-tokens.js +109 -0
  97. package/dist/src/tokens/process/platform.d.ts +87 -0
  98. package/dist/src/tokens/process/platform.d.ts.map +1 -0
  99. package/dist/src/tokens/process/platform.js +1090 -0
  100. package/dist/src/tokens/process/theme.d.ts +27 -0
  101. package/dist/src/tokens/process/theme.d.ts.map +1 -0
  102. package/dist/src/tokens/process/theme.js +172 -0
  103. package/dist/src/tokens/process/transformers.d.ts.map +1 -0
  104. package/dist/src/tokens/{build → process}/transformers.js +29 -6
  105. package/dist/src/tokens/{build → process}/utils/getMultidimensionalThemes.d.ts +3 -3
  106. package/dist/src/tokens/process/utils/getMultidimensionalThemes.d.ts.map +1 -0
  107. package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +922 -0
  108. package/dist/src/tokens/template/design-tokens/primitives/globals.js +5 -0
  109. package/dist/src/tokens/template/design-tokens/primitives/modes/size/global.js +5 -0
  110. package/dist/src/tokens/template/design-tokens/primitives/modes/size/large.js +5 -0
  111. package/dist/src/tokens/template/design-tokens/primitives/modes/size/medium.js +5 -0
  112. package/dist/src/tokens/template/design-tokens/primitives/modes/size/small.js +5 -0
  113. package/dist/src/tokens/template/design-tokens/primitives/modes/typography/size/large.js +5 -0
  114. package/dist/src/tokens/template/design-tokens/primitives/modes/typography/size/medium.js +5 -0
  115. package/dist/src/tokens/template/design-tokens/primitives/modes/typography/size/small.js +5 -0
  116. package/dist/src/tokens/template/design-tokens/primitives/modes/typography/typography.template.js +5 -0
  117. package/dist/src/tokens/template/design-tokens/semantic/color.base.template.js +5 -0
  118. package/dist/src/tokens/template/design-tokens/semantic/color.template.js +5 -0
  119. package/dist/src/tokens/template/design-tokens/semantic/modes/color.template.js +5 -0
  120. package/dist/src/tokens/template/design-tokens/semantic/style.js +5 -0
  121. package/dist/src/tokens/template/design-tokens/themes/theme.base.template.js +5 -0
  122. package/dist/src/tokens/template/design-tokens/themes/theme.template.js +5 -0
  123. package/dist/src/tokens/types.d.ts +58 -38
  124. package/dist/src/tokens/types.d.ts.map +1 -1
  125. package/dist/src/tokens/types.js +8 -0
  126. package/dist/src/tokens/utils.d.ts +30 -5
  127. package/dist/src/tokens/utils.d.ts.map +1 -1
  128. package/dist/src/tokens/utils.js +36 -50
  129. package/dist/src/utils.d.ts +18 -0
  130. package/dist/src/utils.d.ts.map +1 -0
  131. package/dist/src/utils.js +63 -0
  132. package/dist/typography.template-4N5YLH7F.json +22 -0
  133. package/package.json +22 -20
  134. package/dist/bin/config.d.ts.map +0 -1
  135. package/dist/bin/config.js +0 -71
  136. package/dist/src/migrations/codemods/jsx/classname-prefix.d.ts +0 -10
  137. package/dist/src/migrations/codemods/jsx/classname-prefix.d.ts.map +0 -1
  138. package/dist/src/migrations/codemods/jsx/classname-prefix.js +0 -64
  139. package/dist/src/migrations/codemods/jsx/run.d.ts +0 -7
  140. package/dist/src/migrations/codemods/jsx/run.d.ts.map +0 -1
  141. package/dist/src/migrations/codemods/jsx/run.js +0 -22
  142. package/dist/src/migrations/react-beta-to-v1.d.ts +0 -3
  143. package/dist/src/migrations/react-beta-to-v1.d.ts.map +0 -1
  144. package/dist/src/migrations/react-beta-to-v1.js +0 -5
  145. package/dist/src/scripts/copy-internal-tokens.d.ts +0 -2
  146. package/dist/src/scripts/copy-internal-tokens.d.ts.map +0 -1
  147. package/dist/src/scripts/copy-internal-tokens.js +0 -28
  148. package/dist/src/tokens/build/configs.d.ts.map +0 -1
  149. package/dist/src/tokens/build/configs.js +0 -280
  150. package/dist/src/tokens/build/formats/css.d.ts +0 -53
  151. package/dist/src/tokens/build/formats/css.d.ts.map +0 -1
  152. package/dist/src/tokens/build/formats/js-tokens.d.ts.map +0 -1
  153. package/dist/src/tokens/build/formats/js-tokens.js +0 -48
  154. package/dist/src/tokens/build/transformers.d.ts.map +0 -1
  155. package/dist/src/tokens/build/types.d.ts +0 -48
  156. package/dist/src/tokens/build/types.d.ts.map +0 -1
  157. package/dist/src/tokens/build/types.js +0 -7
  158. package/dist/src/tokens/build/utils/entryfile.d.ts +0 -12
  159. package/dist/src/tokens/build/utils/entryfile.d.ts.map +0 -1
  160. package/dist/src/tokens/build/utils/entryfile.js +0 -67
  161. package/dist/src/tokens/build/utils/getMultidimensionalThemes.d.ts.map +0 -1
  162. package/dist/src/tokens/build/utils/getMultidimensionalThemes.js +0 -112
  163. package/dist/src/tokens/design-tokens/template/$metadata.json +0 -25
  164. package/dist/src/tokens/design-tokens/template/$themes.json +0 -1498
  165. package/dist/src/tokens/template.d.ts.map +0 -1
  166. package/dist/src/tokens/template.js +0 -99
  167. package/dist/src/tokens/write/generate$metadata.d.ts +0 -9
  168. package/dist/src/tokens/write/generate$metadata.d.ts.map +0 -1
  169. package/dist/src/tokens/write/generate$themes.d.ts +0 -12
  170. package/dist/src/tokens/write/generate$themes.d.ts.map +0 -1
  171. package/dist/src/tokens/write/generate$themes.js +0 -161
  172. package/dist/src/tokens/write.d.ts.map +0 -1
  173. package/dist/src/tokens/write.js +0 -177
  174. /package/dist/{src/tokens/design-tokens/template/semantic/color-base-file.json → color.base.template-M7BHS4OV.json} +0 -0
  175. /package/dist/{src/tokens/design-tokens/template/semantic/modes/category-color/category-color-template.json → color.template-LMPUQ72A.json} +0 -0
  176. /package/dist/{src/tokens/design-tokens/template/semantic/semantic-color-template.json → color.template-XQNSHLTU.json} +0 -0
  177. /package/dist/{src/tokens/design-tokens/default/primitives/modes/size/global.json → global-XVXVBKM6.json} +0 -0
  178. /package/dist/{src/tokens/design-tokens/default/primitives/globals.json → globals-76VAFMDF.json} +0 -0
  179. /package/dist/{src/tokens/design-tokens/default/primitives/modes/typography/size/large.json → large-CIIHO7AY.json} +0 -0
  180. /package/dist/{src/tokens/design-tokens/default/primitives/modes/size/large.json → large-UUOZ6DYI.json} +0 -0
  181. /package/dist/{src/tokens/design-tokens/default/primitives/modes/size/medium.json → medium-OQ7S7P4P.json} +0 -0
  182. /package/dist/{src/tokens/design-tokens/default/primitives/modes/typography/size/medium.json → medium-VSB2S4X3.json} +0 -0
  183. /package/dist/{src/tokens/design-tokens/default/primitives/modes/typography/size/small.json → small-AEXJ6U7Z.json} +0 -0
  184. /package/dist/{src/tokens/design-tokens/default/primitives/modes/size/small.json → small-ZY4KOJWX.json} +0 -0
  185. /package/dist/src/tokens/{build → process}/formats/js-tokens.d.ts +0 -0
  186. /package/dist/src/tokens/{build → process}/transformers.d.ts +0 -0
  187. /package/dist/{src/tokens/design-tokens/default/semantic/style.json → style-FP5XVCUD.json} +0 -0
  188. /package/dist/{src/tokens/design-tokens/template/themes/theme-base-file.json → theme.base.template-Y4RMFBQY.json} +0 -0
  189. /package/dist/{src/tokens/design-tokens/template/themes/theme-color-template.json → theme.template-CTQRNOMO.json} +0 -0
@@ -1,11 +1,11 @@
1
- import type { Theme, Tokens } from './types.js';
1
+ import type { Theme, TokenSets } from '../types.js';
2
2
  export declare const stringify: (data: unknown) => string;
3
3
  type WriteTokensOptions = {
4
4
  outDir: string;
5
- tokens: Tokens;
6
5
  theme: Theme;
7
6
  /** Dry run, no files will be written */
8
7
  dry?: boolean;
8
+ tokenSets: TokenSets;
9
9
  };
10
10
  export declare const writeTokens: (options: WriteTokensOptions) => Promise<void>;
11
11
  export {};
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../../../src/tokens/create/write.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAKpD,eAAO,MAAM,SAAS,GAAI,MAAM,OAAO,WAAkC,CAAC;AAE1E,KAAK,kBAAkB,GAAG;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;IACb,wCAAwC;IACxC,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,SAAS,EAAE,SAAS,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,WAAW,GAAU,SAAS,kBAAkB,kBAwD5D,CAAC"}
@@ -0,0 +1,547 @@
1
+ // src/tokens/create/write.ts
2
+ import path from "node:path";
3
+ import chalk2 from "chalk";
4
+ import * as R from "ramda";
5
+
6
+ // src/utils.ts
7
+ import fs from "node:fs/promises";
8
+ import chalk from "chalk";
9
+ var mkdir = async (dir, dry) => {
10
+ if (dry) {
11
+ console.log(`${chalk.blue("mkdir")} ${dir}`);
12
+ return Promise.resolve();
13
+ }
14
+ const exists = await fs.access(dir, fs.constants.F_OK).then(() => true).catch(() => false);
15
+ if (exists) {
16
+ return Promise.resolve();
17
+ }
18
+ return fs.mkdir(dir, { recursive: true });
19
+ };
20
+ var writeFile = async (path2, data, dry) => {
21
+ if (dry) {
22
+ console.log(`${chalk.blue("writeFile")} ${path2}`);
23
+ return Promise.resolve();
24
+ }
25
+ return fs.writeFile(path2, data, { encoding: "utf-8" }).catch((error) => {
26
+ console.error(chalk.red(`Error writing file: ${path2}`));
27
+ console.error(chalk.red(error));
28
+ throw error;
29
+ });
30
+ };
31
+ var readFile = async (path2, dry) => {
32
+ if (dry) {
33
+ console.log(`${chalk.blue("readFile")} ${path2}`);
34
+ return Promise.resolve("");
35
+ }
36
+ return fs.readFile(path2, "utf-8");
37
+ };
38
+
39
+ // package.json
40
+ var package_default = {
41
+ name: "@digdir/designsystemet",
42
+ version: "1.0.5",
43
+ description: "CLI for Designsystemet",
44
+ author: "Designsystemet team",
45
+ engines: {
46
+ node: ">=22.14.0"
47
+ },
48
+ repository: {
49
+ type: "git",
50
+ url: "git+https://github.com/digdir/designsystemet.git"
51
+ },
52
+ homepage: "https://github.com/digdir/designsystemet/tree/main/scripts/cli",
53
+ license: "MIT",
54
+ type: "module",
55
+ main: "./dist/src/index.js",
56
+ files: [
57
+ "./dist/**"
58
+ ],
59
+ bin: "dist/bin/designsystemet.js",
60
+ exports: {
61
+ ".": {
62
+ import: "./dist/src/index.js"
63
+ },
64
+ "./color": {
65
+ import: "./dist/src/colors/index.js"
66
+ },
67
+ "./tokens": {
68
+ import: "./dist/src/tokens/index.js"
69
+ }
70
+ },
71
+ publishConfig: {
72
+ access: "public"
73
+ },
74
+ scripts: {
75
+ designsystemet: "tsx ./bin/designsystemet.ts",
76
+ "build:tokens": "yarn designsystemet tokens build -p -t ../../design-tokens -o ../../packages/theme/brand --clean",
77
+ "build:tokens:debug": "tsx --inspect-brk ./bin/designsystemet.ts tokens build -p -t ../../design-tokens -o ../../packages/theme/brand --clean",
78
+ build: "tsup && yarn build:types && yarn build:json-schema",
79
+ "build:types": "tsc --emitDeclarationOnly --declaration",
80
+ "build:json-schema": "tsx ./src/scripts/createJsonSchema.ts",
81
+ types: "tsc --noEmit",
82
+ "test:tokens-create-options": "yarn designsystemet tokens create -m dominant:#007682 -n #003333 -b 99 -o ./test-tokens/options --theme options --clean",
83
+ "test:tokens-create-config": "yarn designsystemet tokens create --config ./test/test-tokens.config.json",
84
+ "test:tokens-build": "yarn designsystemet tokens build -t ./test-tokens/options -o ./test-tokens/options-build --clean",
85
+ "test:tokens-build-config": "yarn designsystemet tokens build -t ./test-tokens/config -o ./test-tokens/config-build --clean",
86
+ "test:tokens-create-and-build-options": "yarn test:tokens-create-options && yarn test:tokens-build",
87
+ "test:tokens-create-and-build-config": "yarn test:tokens-create-config && yarn test:tokens-build-config",
88
+ test: "yarn test:tokens-create-and-build-options && yarn test:tokens-create-and-build-config",
89
+ "internal:tokens-create": "yarn designsystemet tokens create --config ./internal.config.json",
90
+ "update:template": "tsx ./src/scripts/update-template.ts",
91
+ "update:design-tokens": "yarn internal:tokens-create && tsx ./src/scripts/update-design-tokens.ts",
92
+ verify: "yarn test && yarn update:template && yarn update:design-tokens"
93
+ },
94
+ dependencies: {
95
+ "@commander-js/extra-typings": "^13.1.0",
96
+ "@tokens-studio/sd-transforms": "1.2.12",
97
+ "apca-w3": "^0.1.9",
98
+ chalk: "^5.4.1",
99
+ "change-case": "^5.4.4",
100
+ "chroma-js": "^3.1.2",
101
+ commander: "^13.1.0",
102
+ "fast-glob": "^3.3.3",
103
+ hsluv: "^1.0.1",
104
+ "object-hash": "^3.0.0",
105
+ postcss: "^8.5.3",
106
+ ramda: "^0.30.1",
107
+ "style-dictionary": "^4.3.3",
108
+ zod: "^3.24.2",
109
+ "zod-validation-error": "^3.4.0"
110
+ },
111
+ devDependencies: {
112
+ "@types/apca-w3": "^0.1.3",
113
+ "@types/chroma-js": "^3.1.1",
114
+ "@types/fs-extra": "^11.0.4",
115
+ "@types/glob": "^8.1.0",
116
+ "@types/jscodeshift": "^0.12.0",
117
+ "@types/node": "^22.14.0",
118
+ "@types/object-hash": "^3.0.6",
119
+ "@types/ramda": "^0.30.2",
120
+ "fs-extra": "^11.3.0",
121
+ "ts-toolbelt": "^9.6.0",
122
+ tslib: "^2.8.1",
123
+ tsup: "^8.4.0",
124
+ tsx: "^4.19.3",
125
+ typescript: "^5.8.2",
126
+ "zod-to-json-schema": "^3.24.5"
127
+ }
128
+ };
129
+
130
+ // src/tokens/create/generators/$designsystemet.ts
131
+ function generate$Designsystemet() {
132
+ return {
133
+ name: package_default.name,
134
+ version: package_default.version
135
+ };
136
+ }
137
+
138
+ // src/tokens/create/generators/$metadata.ts
139
+ function generate$Metadata(schemes, themes, colors) {
140
+ return {
141
+ tokenSetOrder: [
142
+ "primitives/globals",
143
+ "primitives/modes/size/small",
144
+ "primitives/modes/size/medium",
145
+ "primitives/modes/size/large",
146
+ "primitives/modes/size/global",
147
+ "primitives/modes/typography/size/small",
148
+ "primitives/modes/typography/size/medium",
149
+ "primitives/modes/typography/size/large",
150
+ ...themes.map((theme) => `primitives/modes/typography/primary/${theme}`),
151
+ ...themes.map((theme) => `primitives/modes/typography/secondary/${theme}`),
152
+ ...schemes.flatMap((scheme) => [
153
+ `primitives/modes/color-scheme/${scheme}/global`,
154
+ ...themes.map((theme) => `primitives/modes/color-scheme/${scheme}/${theme}`)
155
+ ]),
156
+ ...themes.map((theme) => `themes/${theme}`),
157
+ "semantic/color",
158
+ ...Object.entries(colors.main).map(([color]) => `semantic/modes/main-color/${color}`),
159
+ ...Object.entries(colors.support).map(([color]) => `semantic/modes/support-color/${color}`),
160
+ "semantic/style"
161
+ ]
162
+ };
163
+ }
164
+
165
+ // ../../node_modules/@tokens-studio/types/dist/constants/BoxShadowTypes.js
166
+ var BoxShadowTypes;
167
+ (function(BoxShadowTypes2) {
168
+ BoxShadowTypes2["DROP_SHADOW"] = "dropShadow";
169
+ BoxShadowTypes2["INNER_SHADOW"] = "innerShadow";
170
+ })(BoxShadowTypes || (BoxShadowTypes = {}));
171
+
172
+ // ../../node_modules/@tokens-studio/types/dist/constants/ColorModifierTypes.js
173
+ var ColorModifierTypes;
174
+ (function(ColorModifierTypes2) {
175
+ ColorModifierTypes2["LIGHTEN"] = "lighten";
176
+ ColorModifierTypes2["DARKEN"] = "darken";
177
+ ColorModifierTypes2["MIX"] = "mix";
178
+ ColorModifierTypes2["ALPHA"] = "alpha";
179
+ })(ColorModifierTypes || (ColorModifierTypes = {}));
180
+
181
+ // ../../node_modules/@tokens-studio/types/dist/constants/ColorSpaceTypes.js
182
+ var ColorSpaceTypes;
183
+ (function(ColorSpaceTypes2) {
184
+ ColorSpaceTypes2["LCH"] = "lch";
185
+ ColorSpaceTypes2["SRGB"] = "srgb";
186
+ ColorSpaceTypes2["P3"] = "p3";
187
+ ColorSpaceTypes2["HSL"] = "hsl";
188
+ })(ColorSpaceTypes || (ColorSpaceTypes = {}));
189
+
190
+ // ../../node_modules/@tokens-studio/types/dist/constants/Properties.js
191
+ var Properties;
192
+ (function(Properties2) {
193
+ Properties2["sizing"] = "sizing";
194
+ Properties2["height"] = "height";
195
+ Properties2["width"] = "width";
196
+ Properties2["spacing"] = "spacing";
197
+ Properties2["verticalPadding"] = "verticalPadding";
198
+ Properties2["horizontalPadding"] = "horizontalPadding";
199
+ Properties2["paddingTop"] = "paddingTop";
200
+ Properties2["paddingRight"] = "paddingRight";
201
+ Properties2["paddingBottom"] = "paddingBottom";
202
+ Properties2["paddingLeft"] = "paddingLeft";
203
+ Properties2["itemSpacing"] = "itemSpacing";
204
+ Properties2["fill"] = "fill";
205
+ Properties2["backgroundBlur"] = "backgroundBlur";
206
+ Properties2["border"] = "border";
207
+ Properties2["borderTop"] = "borderTop";
208
+ Properties2["borderRight"] = "borderRight";
209
+ Properties2["borderBottom"] = "borderBottom";
210
+ Properties2["borderLeft"] = "borderLeft";
211
+ Properties2["borderColor"] = "borderColor";
212
+ Properties2["borderRadius"] = "borderRadius";
213
+ Properties2["borderRadiusTopLeft"] = "borderRadiusTopLeft";
214
+ Properties2["borderRadiusTopRight"] = "borderRadiusTopRight";
215
+ Properties2["borderRadiusBottomRight"] = "borderRadiusBottomRight";
216
+ Properties2["borderRadiusBottomLeft"] = "borderRadiusBottomLeft";
217
+ Properties2["borderWidth"] = "borderWidth";
218
+ Properties2["borderWidthTop"] = "borderWidthTop";
219
+ Properties2["borderWidthRight"] = "borderWidthRight";
220
+ Properties2["borderWidthBottom"] = "borderWidthBottom";
221
+ Properties2["borderWidthLeft"] = "borderWidthLeft";
222
+ Properties2["boxShadow"] = "boxShadow";
223
+ Properties2["opacity"] = "opacity";
224
+ Properties2["fontFamilies"] = "fontFamilies";
225
+ Properties2["fontWeights"] = "fontWeights";
226
+ Properties2["fontSizes"] = "fontSizes";
227
+ Properties2["lineHeights"] = "lineHeights";
228
+ Properties2["typography"] = "typography";
229
+ Properties2["composition"] = "composition";
230
+ Properties2["letterSpacing"] = "letterSpacing";
231
+ Properties2["paragraphSpacing"] = "paragraphSpacing";
232
+ Properties2["textCase"] = "textCase";
233
+ Properties2["dimension"] = "dimension";
234
+ Properties2["textDecoration"] = "textDecoration";
235
+ Properties2["asset"] = "asset";
236
+ Properties2["tokenValue"] = "tokenValue";
237
+ Properties2["value"] = "value";
238
+ Properties2["tokenName"] = "tokenName";
239
+ Properties2["description"] = "description";
240
+ })(Properties || (Properties = {}));
241
+
242
+ // ../../node_modules/@tokens-studio/types/dist/constants/TokenSetStatus.js
243
+ var TokenSetStatus;
244
+ (function(TokenSetStatus2) {
245
+ TokenSetStatus2["DISABLED"] = "disabled";
246
+ TokenSetStatus2["SOURCE"] = "source";
247
+ TokenSetStatus2["ENABLED"] = "enabled";
248
+ })(TokenSetStatus || (TokenSetStatus = {}));
249
+
250
+ // ../../node_modules/@tokens-studio/types/dist/constants/TokenTypes.js
251
+ var TokenTypes;
252
+ (function(TokenTypes2) {
253
+ TokenTypes2["OTHER"] = "other";
254
+ TokenTypes2["COLOR"] = "color";
255
+ TokenTypes2["BORDER_RADIUS"] = "borderRadius";
256
+ TokenTypes2["SIZING"] = "sizing";
257
+ TokenTypes2["SPACING"] = "spacing";
258
+ TokenTypes2["TEXT"] = "text";
259
+ TokenTypes2["TYPOGRAPHY"] = "typography";
260
+ TokenTypes2["OPACITY"] = "opacity";
261
+ TokenTypes2["BORDER_WIDTH"] = "borderWidth";
262
+ TokenTypes2["STROKE_STYLE"] = "strokeStyle";
263
+ TokenTypes2["BOX_SHADOW"] = "boxShadow";
264
+ TokenTypes2["FONT_FAMILIES"] = "fontFamilies";
265
+ TokenTypes2["FONT_WEIGHTS"] = "fontWeights";
266
+ TokenTypes2["LINE_HEIGHTS"] = "lineHeights";
267
+ TokenTypes2["FONT_SIZES"] = "fontSizes";
268
+ TokenTypes2["LETTER_SPACING"] = "letterSpacing";
269
+ TokenTypes2["PARAGRAPH_SPACING"] = "paragraphSpacing";
270
+ TokenTypes2["PARAGRAPH_INDENT"] = "paragraphIndent";
271
+ TokenTypes2["TEXT_DECORATION"] = "textDecoration";
272
+ TokenTypes2["TEXT_CASE"] = "textCase";
273
+ TokenTypes2["COMPOSITION"] = "composition";
274
+ TokenTypes2["DIMENSION"] = "dimension";
275
+ TokenTypes2["BORDER"] = "border";
276
+ TokenTypes2["ASSET"] = "asset";
277
+ TokenTypes2["BOOLEAN"] = "boolean";
278
+ TokenTypes2["NUMBER"] = "number";
279
+ })(TokenTypes || (TokenTypes = {}));
280
+
281
+ // ../../node_modules/@tokens-studio/types/dist/constants/BorderValues.js
282
+ var BorderValues;
283
+ (function(BorderValues2) {
284
+ BorderValues2["BORDER_COLOR"] = "color";
285
+ BorderValues2["BORDER_WIDTH"] = "width";
286
+ BorderValues2["BORDER_STYLE"] = "style";
287
+ })(BorderValues || (BorderValues = {}));
288
+
289
+ // ../../node_modules/@tokens-studio/types/dist/constants/StrokeStyleValues.js
290
+ var StrokeStyleValues;
291
+ (function(StrokeStyleValues2) {
292
+ StrokeStyleValues2["SOLID"] = "solid";
293
+ StrokeStyleValues2["DASHED"] = "dashed";
294
+ StrokeStyleValues2["DOTTED"] = "dotted";
295
+ StrokeStyleValues2["DOUBLE"] = "double";
296
+ StrokeStyleValues2["GROOVE"] = "groove";
297
+ StrokeStyleValues2["RIDGE"] = "ridge";
298
+ StrokeStyleValues2["OUTSET"] = "outset";
299
+ StrokeStyleValues2["INSET"] = "inset";
300
+ })(StrokeStyleValues || (StrokeStyleValues = {}));
301
+
302
+ // ../../node_modules/@tokens-studio/types/dist/constants/BoxShadowValues.js
303
+ var BoxShadowValues;
304
+ (function(BoxShadowValues2) {
305
+ BoxShadowValues2["TYPE"] = "type";
306
+ BoxShadowValues2["COLOR"] = "color";
307
+ BoxShadowValues2["X"] = "x";
308
+ BoxShadowValues2["Y"] = "y";
309
+ BoxShadowValues2["BLUR"] = "blur";
310
+ BoxShadowValues2["SPREAD"] = "spread";
311
+ BoxShadowValues2["BLEND_MODE"] = "blendMode";
312
+ })(BoxShadowValues || (BoxShadowValues = {}));
313
+
314
+ // ../../node_modules/@tokens-studio/types/dist/constants/TypographyValues.js
315
+ var TypographyValues;
316
+ (function(TypographyValues2) {
317
+ TypographyValues2["FONT_FAMILY"] = "fontFamily";
318
+ TypographyValues2["FONT_WEIGHT"] = "fontWeight";
319
+ TypographyValues2["LINE_HEIGHT"] = "lineHeight";
320
+ TypographyValues2["FONT_SIZE"] = "fontSize";
321
+ TypographyValues2["LETTER_SPACING"] = "letterSpacing";
322
+ TypographyValues2["PARAGRAPH_SPACING"] = "paragraphSpacing";
323
+ TypographyValues2["PARAGRAPH_INDENT"] = "paragraphIndent";
324
+ TypographyValues2["TEXT_DECORATION"] = "textDecoration";
325
+ TypographyValues2["TEXT_CASE"] = "textCase";
326
+ })(TypographyValues || (TypographyValues = {}));
327
+
328
+ // src/tokens/create/generators/$themes.ts
329
+ var capitalize = (word) => word.charAt(0).toUpperCase() + word.slice(1);
330
+ async function createHash(text, algo = "SHA-1") {
331
+ const crypto = globalThis.crypto;
332
+ return Array.from(
333
+ new Uint8Array(await crypto.subtle.digest(algo, new TextEncoder().encode(text))),
334
+ (byte) => byte.toString(16).padStart(2, "0")
335
+ ).join("");
336
+ }
337
+ async function generate$Themes(colorSchemes, themes, colors) {
338
+ return [
339
+ ...generateSizeGroup(),
340
+ ...await generateThemesGroup(themes),
341
+ ...generateTypographyGroup(themes),
342
+ ...generateColorSchemesGroup(colorSchemes, themes),
343
+ generateSemanticGroup(),
344
+ ...await generateColorGroup("main", colors),
345
+ ...await generateColorGroup("support", colors)
346
+ ];
347
+ }
348
+ function generateSizeGroup() {
349
+ return [
350
+ {
351
+ id: "8b2c8cc86611a34b135cb22948666779361fd729",
352
+ name: "medium",
353
+ $figmaStyleReferences: {},
354
+ selectedTokenSets: {
355
+ "primitives/modes/size/medium": TokenSetStatus.SOURCE,
356
+ "primitives/modes/size/global": TokenSetStatus.ENABLED,
357
+ "primitives/modes/typography/size/medium": TokenSetStatus.ENABLED
358
+ },
359
+ $figmaCollectionId: "VariableCollectionId:36248:20757",
360
+ $figmaModeId: "41630:1",
361
+ group: "Size"
362
+ },
363
+ {
364
+ id: "d49b9eebeb48a4f165a74b7261733d0a73370f0e",
365
+ name: "large",
366
+ $figmaStyleReferences: {},
367
+ selectedTokenSets: {
368
+ "primitives/modes/size/large": TokenSetStatus.SOURCE,
369
+ "primitives/modes/size/global": TokenSetStatus.ENABLED,
370
+ "primitives/modes/typography/size/large": TokenSetStatus.ENABLED
371
+ },
372
+ $figmaCollectionId: "VariableCollectionId:36248:20757",
373
+ $figmaModeId: "41630:2",
374
+ group: "Size"
375
+ },
376
+ {
377
+ id: "fb11567729c298ca37c9da4e3a27716a23480824",
378
+ name: "small",
379
+ $figmaStyleReferences: {},
380
+ selectedTokenSets: {
381
+ "primitives/modes/size/small": TokenSetStatus.SOURCE,
382
+ "primitives/modes/size/global": TokenSetStatus.ENABLED,
383
+ "primitives/modes/typography/size/small": TokenSetStatus.ENABLED
384
+ },
385
+ $figmaCollectionId: "VariableCollectionId:36248:20757",
386
+ $figmaModeId: "41630:3",
387
+ group: "Size"
388
+ }
389
+ ];
390
+ }
391
+ var colorSchemeDefaults = {
392
+ light: {
393
+ name: "Light",
394
+ selectedTokenSets: {},
395
+ id: "0daa3ca0b427b9349da7e7dc00101b5668972926",
396
+ $figmaCollectionId: "VariableCollectionId:34811:5472",
397
+ $figmaModeId: "34811:0"
398
+ },
399
+ dark: {
400
+ name: "Dark",
401
+ selectedTokenSets: {},
402
+ id: "9ebd8aed52afbffc17e2666e8b4653a53498b257",
403
+ $figmaCollectionId: "VariableCollectionId:34811:5472",
404
+ $figmaModeId: "34811:1"
405
+ },
406
+ contrast: {
407
+ name: "Contrast",
408
+ selectedTokenSets: {},
409
+ id: "9ebd8aed52afbffc17e2666e8b4653a53498b123",
410
+ $figmaCollectionId: "VariableCollectionId:34811:5472",
411
+ $figmaModeId: "34811:2"
412
+ }
413
+ };
414
+ function generateColorSchemesGroup(colorSchemes, themes) {
415
+ return colorSchemes.map(
416
+ (scheme) => ({
417
+ ...colorSchemeDefaults[scheme],
418
+ selectedTokenSets: Object.fromEntries([
419
+ [`primitives/modes/color-scheme/${scheme}/global`, TokenSetStatus.ENABLED],
420
+ ...themes.map((theme) => [`primitives/modes/color-scheme/${scheme}/${theme}`, TokenSetStatus.ENABLED])
421
+ ]),
422
+ group: "Color scheme"
423
+ })
424
+ );
425
+ }
426
+ async function generateThemesGroup(themes) {
427
+ return Promise.all(
428
+ themes.map(
429
+ async (theme, index) => ({
430
+ id: await createHash(theme),
431
+ $figmaCollectionId: "VariableCollectionId:36528:61712",
432
+ $figmaModeId: `40960:${index + 6}`,
433
+ // Start on 6 in Token Studio and Community file for some reason
434
+ name: theme,
435
+ selectedTokenSets: {
436
+ [`themes/${theme}`]: TokenSetStatus.ENABLED
437
+ },
438
+ group: "Theme"
439
+ })
440
+ )
441
+ );
442
+ }
443
+ function generateSemanticGroup() {
444
+ return {
445
+ id: "541629445ef90ad5363f9e88f52a1ccb617e6f84",
446
+ name: "Semantic",
447
+ selectedTokenSets: {
448
+ "semantic/style": TokenSetStatus.ENABLED,
449
+ "semantic/color": TokenSetStatus.ENABLED,
450
+ "primitives/globals": TokenSetStatus.SOURCE
451
+ },
452
+ $figmaCollectionId: "VariableCollectionId:34811:5976",
453
+ $figmaModeId: "34811:5",
454
+ group: "Semantic"
455
+ };
456
+ }
457
+ async function generateColorGroup(group, colors) {
458
+ return Promise.all(
459
+ Object.entries(colors[group]).map(
460
+ async ([color]) => ({
461
+ id: await createHash(`${group}-${color}`),
462
+ name: color,
463
+ selectedTokenSets: {
464
+ [`semantic/modes/${group}-color/${color}`]: TokenSetStatus.ENABLED
465
+ },
466
+ group: `${capitalize(group)} color`
467
+ })
468
+ )
469
+ );
470
+ }
471
+ function generateTypographyGroup(themes) {
472
+ return [
473
+ {
474
+ id: "368d753fcac4455f289500eaa42e70dc0a03522f",
475
+ $figmaCollectionId: "VariableCollectionId:36248:20769",
476
+ $figmaModeId: "36248:2",
477
+ name: "Primary",
478
+ selectedTokenSets: Object.fromEntries(
479
+ themes.map((theme) => [`primitives/modes/typography/primary/${theme}`, TokenSetStatus.ENABLED])
480
+ ),
481
+ group: "Typography"
482
+ },
483
+ {
484
+ id: "264b8bd1d40b364e1ea3acf09e49795ddd4c513c",
485
+ $figmaCollectionId: "VariableCollectionId:36248:20769",
486
+ $figmaModeId: "36248:3",
487
+ name: "Secondary",
488
+ selectedTokenSets: Object.fromEntries(
489
+ themes.map((theme) => [`primitives/modes/typography/secondary/${theme}`, TokenSetStatus.ENABLED])
490
+ ),
491
+ group: "Typography"
492
+ }
493
+ ];
494
+ }
495
+
496
+ // src/tokens/create/write.ts
497
+ var stringify = (data) => JSON.stringify(data, null, 2);
498
+ var writeTokens = async (options) => {
499
+ const {
500
+ outDir,
501
+ tokenSets,
502
+ theme: { name: themeName, colors },
503
+ dry
504
+ } = options;
505
+ const targetDir = path.resolve(process.cwd(), String(outDir));
506
+ const $themesPath = path.join(targetDir, "$themes.json");
507
+ const $metadataPath = path.join(targetDir, "$metadata.json");
508
+ const $designsystemetPath = path.join(targetDir, "$designsystemet.json");
509
+ let themeObjects = [];
510
+ await mkdir(targetDir, dry);
511
+ try {
512
+ const $themes2 = await readFile($themesPath);
513
+ if ($themes2) {
514
+ themeObjects = JSON.parse($themes2);
515
+ }
516
+ } catch (error) {
517
+ }
518
+ const concatThemeNames = R.pipe(
519
+ R.filter((obj) => R.toLower(obj.group || "") === "theme"),
520
+ R.map(R.prop("name")),
521
+ // New theme is added to the end of the list so we keep the same order from config and Token Studio
522
+ R.append(themeName),
523
+ R.uniq
524
+ );
525
+ const themes = concatThemeNames(themeObjects);
526
+ console.log(`
527
+ Themes: ${chalk2.blue(themes.join(", "))}`);
528
+ const $themes = await generate$Themes(["dark", "light"], themes, colors);
529
+ const $metadata = generate$Metadata(["dark", "light"], themes, colors);
530
+ const $designsystemet = generate$Designsystemet();
531
+ await writeFile($themesPath, stringify($themes), dry);
532
+ await writeFile($metadataPath, stringify($metadata), dry);
533
+ await writeFile($designsystemetPath, stringify($designsystemet), dry);
534
+ for (const [set, tokens] of tokenSets) {
535
+ const fileDir = path.join(targetDir, path.dirname(set));
536
+ await mkdir(fileDir, dry);
537
+ const filePath = path.join(targetDir, `${set}.json`);
538
+ await writeFile(filePath, stringify(tokens), dry);
539
+ }
540
+ console.log(
541
+ `Finished creating Designsystem design tokens in ${chalk2.green(outDir)} for theme ${chalk2.blue(themeName)}`
542
+ );
543
+ };
544
+ export {
545
+ stringify,
546
+ writeTokens
547
+ };
@@ -1,4 +1,4 @@
1
- import type { Theme, Tokens } from './types.js';
1
+ import type { Theme, TokenSets } from './types.js';
2
2
  export declare const cliOptions: {
3
3
  readonly outDir: "out-dir";
4
4
  readonly clean: "clean";
@@ -14,5 +14,7 @@ export declare const cliOptions: {
14
14
  readonly borderRadius: "border-radius";
15
15
  };
16
16
  };
17
- export declare const createTokens: (opts: Theme) => Tokens;
17
+ export declare const createTokens: (opts: Theme) => Promise<{
18
+ tokenSets: TokenSets;
19
+ }>;
18
20
  //# sourceMappingURL=create.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/tokens/create.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAU,KAAK,EAAE,MAAM,EAAyB,MAAM,YAAY,CAAC;AAE/E,eAAO,MAAM,UAAU;;;;;;;;;;;;;;CAcb,CAAC;AAoEX,eAAO,MAAM,YAAY,GAAI,MAAM,KAAK,WAqBvC,CAAC"}
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/tokens/create.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,KAAK,EAAY,SAAS,EAAE,MAAM,YAAY,CAAC;AAE7D,eAAO,MAAM,UAAU;;;;;;;;;;;;;;CAcb,CAAC;AAEX,eAAO,MAAM,YAAY,GAAU,MAAM,KAAK;;EAiC7C,CAAC"}