@bitbaum/design-tokens 1.2.0 → 1.3.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 (79) hide show
  1. package/README.md +53 -1
  2. package/fonts/cormorant-garamond/OFL.txt +93 -0
  3. package/fonts/cormorant-garamond/cormorant-garamond-cyrillic-ext.woff2 +0 -0
  4. package/fonts/cormorant-garamond/cormorant-garamond-cyrillic.woff2 +0 -0
  5. package/fonts/cormorant-garamond/cormorant-garamond-italic-cyrillic-ext.woff2 +0 -0
  6. package/fonts/cormorant-garamond/cormorant-garamond-italic-cyrillic.woff2 +0 -0
  7. package/fonts/cormorant-garamond/cormorant-garamond-italic-latin-ext.woff2 +0 -0
  8. package/fonts/cormorant-garamond/cormorant-garamond-italic-latin.woff2 +0 -0
  9. package/fonts/cormorant-garamond/cormorant-garamond-italic-vietnamese.woff2 +0 -0
  10. package/fonts/cormorant-garamond/cormorant-garamond-latin-ext.woff2 +0 -0
  11. package/fonts/cormorant-garamond/cormorant-garamond-latin.woff2 +0 -0
  12. package/fonts/cormorant-garamond/cormorant-garamond-vietnamese.woff2 +0 -0
  13. package/fonts/dm-sans/OFL.txt +93 -0
  14. package/fonts/dm-sans/dm-sans-latin-ext.woff2 +0 -0
  15. package/fonts/dm-sans/dm-sans-latin.woff2 +0 -0
  16. package/fonts/faces.json +612 -0
  17. package/fonts/fraunces/OFL.txt +93 -0
  18. package/fonts/fraunces/fraunces-italic-latin-ext.woff2 +0 -0
  19. package/fonts/fraunces/fraunces-italic-latin.woff2 +0 -0
  20. package/fonts/fraunces/fraunces-italic-vietnamese.woff2 +0 -0
  21. package/fonts/fraunces/fraunces-latin-ext.woff2 +0 -0
  22. package/fonts/fraunces/fraunces-latin.woff2 +0 -0
  23. package/fonts/fraunces/fraunces-vietnamese.woff2 +0 -0
  24. package/fonts/geist/OFL.txt +93 -0
  25. package/fonts/geist/geist-cyrillic-ext.woff2 +0 -0
  26. package/fonts/geist/geist-cyrillic.woff2 +0 -0
  27. package/fonts/geist/geist-latin-ext.woff2 +0 -0
  28. package/fonts/geist/geist-latin.woff2 +0 -0
  29. package/fonts/geist/geist-vietnamese.woff2 +0 -0
  30. package/fonts/geist-mono/OFL.txt +93 -0
  31. package/fonts/geist-mono/geist-mono-cyrillic-ext.woff2 +0 -0
  32. package/fonts/geist-mono/geist-mono-cyrillic.woff2 +0 -0
  33. package/fonts/geist-mono/geist-mono-latin-ext.woff2 +0 -0
  34. package/fonts/geist-mono/geist-mono-latin.woff2 +0 -0
  35. package/fonts/geist-mono/geist-mono-symbols2.woff2 +0 -0
  36. package/fonts/geist-mono/geist-mono-vietnamese.woff2 +0 -0
  37. package/fonts/ibm-plex-mono/OFL.txt +93 -0
  38. package/fonts/ibm-plex-mono/ibm-plex-mono-400-cyrillic-ext.woff2 +0 -0
  39. package/fonts/ibm-plex-mono/ibm-plex-mono-400-cyrillic.woff2 +0 -0
  40. package/fonts/ibm-plex-mono/ibm-plex-mono-400-latin-ext.woff2 +0 -0
  41. package/fonts/ibm-plex-mono/ibm-plex-mono-400-latin.woff2 +0 -0
  42. package/fonts/ibm-plex-mono/ibm-plex-mono-400-vietnamese.woff2 +0 -0
  43. package/fonts/ibm-plex-mono/ibm-plex-mono-500-cyrillic-ext.woff2 +0 -0
  44. package/fonts/ibm-plex-mono/ibm-plex-mono-500-cyrillic.woff2 +0 -0
  45. package/fonts/ibm-plex-mono/ibm-plex-mono-500-latin-ext.woff2 +0 -0
  46. package/fonts/ibm-plex-mono/ibm-plex-mono-500-latin.woff2 +0 -0
  47. package/fonts/ibm-plex-mono/ibm-plex-mono-500-vietnamese.woff2 +0 -0
  48. package/fonts/ibm-plex-mono/ibm-plex-mono-600-cyrillic-ext.woff2 +0 -0
  49. package/fonts/ibm-plex-mono/ibm-plex-mono-600-cyrillic.woff2 +0 -0
  50. package/fonts/ibm-plex-mono/ibm-plex-mono-600-latin-ext.woff2 +0 -0
  51. package/fonts/ibm-plex-mono/ibm-plex-mono-600-latin.woff2 +0 -0
  52. package/fonts/ibm-plex-mono/ibm-plex-mono-600-vietnamese.woff2 +0 -0
  53. package/fonts/inter/OFL.txt +93 -0
  54. package/fonts/inter/inter-cyrillic-ext.woff2 +0 -0
  55. package/fonts/inter/inter-cyrillic.woff2 +0 -0
  56. package/fonts/inter/inter-greek-ext.woff2 +0 -0
  57. package/fonts/inter/inter-greek.woff2 +0 -0
  58. package/fonts/inter/inter-latin-ext.woff2 +0 -0
  59. package/fonts/inter/inter-latin.woff2 +0 -0
  60. package/fonts/inter/inter-vietnamese.woff2 +0 -0
  61. package/fonts/jetbrains-mono/OFL.txt +93 -0
  62. package/fonts/jetbrains-mono/jetbrains-mono-cyrillic-ext.woff2 +0 -0
  63. package/fonts/jetbrains-mono/jetbrains-mono-cyrillic.woff2 +0 -0
  64. package/fonts/jetbrains-mono/jetbrains-mono-greek.woff2 +0 -0
  65. package/fonts/jetbrains-mono/jetbrains-mono-latin-ext.woff2 +0 -0
  66. package/fonts/jetbrains-mono/jetbrains-mono-latin.woff2 +0 -0
  67. package/fonts/jetbrains-mono/jetbrains-mono-vietnamese.woff2 +0 -0
  68. package/fonts/montserrat/OFL.txt +93 -0
  69. package/fonts/montserrat/montserrat-cyrillic-ext.woff2 +0 -0
  70. package/fonts/montserrat/montserrat-cyrillic.woff2 +0 -0
  71. package/fonts/montserrat/montserrat-latin-ext.woff2 +0 -0
  72. package/fonts/montserrat/montserrat-latin.woff2 +0 -0
  73. package/fonts/montserrat/montserrat-vietnamese.woff2 +0 -0
  74. package/fonts/space-grotesk/OFL.txt +93 -0
  75. package/fonts/space-grotesk/space-grotesk-latin-ext.woff2 +0 -0
  76. package/fonts/space-grotesk/space-grotesk-latin.woff2 +0 -0
  77. package/fonts/space-grotesk/space-grotesk-vietnamese.woff2 +0 -0
  78. package/next-fonts.mjs +224 -0
  79. package/package.json +12 -5
@@ -0,0 +1,93 @@
1
+ Copyright 2024 The Montserrat.Git Project Authors (https://github.com/JulietaUla/Montserrat.git)
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ https://openfontlicense.org
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -0,0 +1,93 @@
1
+ Copyright 2020 The Space Grotesk Project Authors (https://github.com/floriankarsten/space-grotesk)
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ http://scripts.sil.org/OFL
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.
package/next-fonts.mjs ADDED
@@ -0,0 +1,224 @@
1
+ #!/usr/bin/env node
2
+ // Write an app's `next/font/local` module for faces this package ships.
3
+ //
4
+ // design-tokens-next-fonts <out-file> "<export>=<face>[;key=value]..." ... [--check]
5
+ //
6
+ // keys: weight=500,700 weights to declare (default: the face's whole range)
7
+ // style=normal,italic styles to declare (default: normal)
8
+ // variable=--font-x the CSS variable the export sets
9
+ // subsets=latin,... subsets to declare (default: every subset shipped)
10
+ // preload=latin,... subsets to preload (default: latin; "none" for none)
11
+ // display=swap font-display (default: swap)
12
+ //
13
+ // --check exit 1 if <out-file> is not what this command would write
14
+ //
15
+ // WHY A GENERATOR
16
+ //
17
+ // `next/font/google` downloads its faces at build time, so a build depends on
18
+ // Google answering; these faces are committed in fonts/ instead. `next/font`
19
+ // accepts only literal options in the calling module, so no helper can call
20
+ // `localFont` for an app. And one call can carry only one `unicode-range`,
21
+ // while Google splits a face into subsets (latin, latin-ext, cyrillic …) that
22
+ // a page downloads only when its text needs them. Keeping that split means one
23
+ // call per subset, all naming the same family — the same @font-face rules
24
+ // `next/font/google` produced: the same files, weights, styles, ranges and
25
+ // preloads. That is long and mechanical, so it is written by this command from
26
+ // fonts/faces.json and checked with --check, not typed by hand.
27
+ //
28
+ // The family is the export's name, not "Inter": Turbopack names the family in
29
+ // `.variable` after the const and ignores a `font-family` declaration there
30
+ // (webpack honours it), so the export carries no declaration and every other
31
+ // subset declares the export's name. Both bundlers then agree. The fallback
32
+ // face is measured from the file (next/font/local) rather than taken from
33
+ // Google's table, so it differs by about one percent; it shows only until the
34
+ // face has loaded.
35
+ //
36
+ // The export named in the spec is the call for the first preloaded subset
37
+ // (latin): it carries `.variable`, `.className` and `.style`. The other
38
+ // subsets are exported as `<export><Subset>` because next/font requires every
39
+ // call to be assigned to a module-level const; nothing needs to read them.
40
+ import { existsSync, readFileSync, realpathSync, writeFileSync } from 'node:fs';
41
+ import { createRequire } from 'node:module';
42
+ import { dirname, join, relative, resolve, sep } from 'node:path';
43
+ import { fileURLToPath } from 'node:url';
44
+
45
+ const here = dirname(fileURLToPath(import.meta.url));
46
+ const PKG = '@bitbaum/design-tokens';
47
+ export const faces = JSON.parse(readFileSync(join(here, 'fonts', 'faces.json'), 'utf8'));
48
+
49
+ /** "sans=inter;weight=500,700;variable=--font-inter" → a spec object. */
50
+ export function parseSpec(text) {
51
+ const [head, ...pairs] = text.split(';').map((s) => s.trim());
52
+ const [name, face] = head.split('=');
53
+ if (!/^[A-Za-z_$][\w$]*$/.test(name ?? ''))
54
+ throw new Error(`"${text}": the export name must be an identifier`);
55
+ // The export's name becomes the font-family name, so it must not be a CSS generic family.
56
+ if (
57
+ /^(serif|sans-serif|monospace|cursive|fantasy|system-ui|math|emoji|fangsong|ui-\w+|inherit|initial|unset|default)$/i.test(
58
+ name,
59
+ )
60
+ )
61
+ throw new Error(
62
+ `"${text}": "${name}" is a CSS keyword; it names the font family, so pick another`,
63
+ );
64
+ if (!faces[face])
65
+ throw new Error(`"${text}": no face "${face}"; shipped: ${Object.keys(faces).join(', ')}`);
66
+ const spec = { name, face };
67
+ for (const pair of pairs) {
68
+ const [key, value] = pair.split('=');
69
+ if (!['weight', 'style', 'variable', 'subsets', 'preload', 'display'].includes(key))
70
+ throw new Error(`"${text}": unknown key "${key}"`);
71
+ spec[key] = value;
72
+ }
73
+ return spec;
74
+ }
75
+
76
+ const list = (v) =>
77
+ v
78
+ ? v
79
+ .split(',')
80
+ .map((s) => s.trim())
81
+ .filter(Boolean)
82
+ : undefined;
83
+ const camel = (s) => s.replace(/(^|-)(\w)/g, (_, __, c) => c.toUpperCase());
84
+
85
+ /** The localFont calls for one spec, as plain data. */
86
+ export function calls(spec) {
87
+ const face = faces[spec.face];
88
+ const styles = list(spec.style) ?? ['normal'];
89
+ const weights = list(spec.weight);
90
+ const preload = spec.preload === 'none' ? [] : (list(spec.preload) ?? ['latin']);
91
+ const shipped = [...new Set(face.files.map((f) => f.subset))];
92
+ const subsets = list(spec.subsets) ?? shipped;
93
+ for (const s of [...subsets, ...preload])
94
+ if (!shipped.includes(s))
95
+ throw new Error(`${spec.face} has no subset "${s}"; shipped: ${shipped.join(', ')}`);
96
+ // Google's order is kept, because it decides which file wins a character two
97
+ // subsets both list. The export itself is latin when latin is declared,
98
+ // else the first preloaded subset, else the first: it is the file measured
99
+ // for the fallback metrics, and a cyrillic file has no latin letters to
100
+ // measure (Inter's gives size-adjust 100% where latin gives 107.89%).
101
+ const ordered = shipped.filter((s) => subsets.includes(s));
102
+ const primary = ordered.includes('latin')
103
+ ? 'latin'
104
+ : (ordered.find((s) => preload.includes(s)) ?? ordered[0]);
105
+ return ordered.map((subset) => {
106
+ const isPrimary = subset === primary;
107
+ const src = [];
108
+ for (const style of styles) {
109
+ const files = face.files.filter((f) => f.subset === subset && f.style === style);
110
+ if (!files.length) throw new Error(`${spec.face} has no ${style} ${subset} file`);
111
+ if (face.variable) {
112
+ for (const weight of weights ?? [files[0].weight])
113
+ src.push({ file: files[0].file, weight, style });
114
+ } else {
115
+ for (const weight of weights ?? files.map((f) => f.weight)) {
116
+ const file = files.find((f) => f.weight === weight);
117
+ if (!file)
118
+ throw new Error(
119
+ `${spec.face} has no ${style} ${weight} file; shipped: ${files.map((f) => f.weight)}`,
120
+ );
121
+ src.push({ file: file.file, weight, style });
122
+ }
123
+ }
124
+ }
125
+ return {
126
+ name: isPrimary ? spec.name : spec.name + camel(subset),
127
+ primary: isPrimary,
128
+ src,
129
+ variable: isPrimary ? spec.variable : undefined,
130
+ display: spec.display ?? 'swap',
131
+ preload: preload.includes(subset),
132
+ adjustFontFallback: isPrimary
133
+ ? face.category === 'serif'
134
+ ? 'Times New Roman'
135
+ : undefined
136
+ : false,
137
+ family: spec.name,
138
+ unicodeRange: face.files.find((f) => f.subset === subset).unicodeRange,
139
+ };
140
+ });
141
+ }
142
+
143
+ /** Where the package sits as seen from `dir`: node_modules/@bitbaum/design-tokens, not its realpath. */
144
+ export function packageDir(dir) {
145
+ for (let d = resolve(dir); ; d = dirname(d)) {
146
+ const candidate = join(d, 'node_modules', ...PKG.split('/'));
147
+ if (existsSync(join(candidate, 'package.json'))) return candidate;
148
+ if (dirname(d) === d) throw new Error(`${PKG} is not installed above ${dir}`);
149
+ }
150
+ }
151
+
152
+ export function render(out, specs, argv) {
153
+ const base = relative(dirname(resolve(out)), packageDir(dirname(resolve(out))))
154
+ .split(sep)
155
+ .join('/');
156
+ const q = JSON.stringify;
157
+ const lines = [
158
+ '// Generated by @bitbaum/design-tokens. Do not edit; to change it, run:',
159
+ `// pnpm exec design-tokens-next-fonts ${argv.map((a) => (/^[\w./@-]+$/.test(a) ? a : `'${a}'`)).join(' ')}`,
160
+ '// The faces ship in the package (fonts/faces.json): no build fetches fonts.',
161
+ 'import localFont from "next/font/local";',
162
+ ];
163
+ for (const spec of specs) {
164
+ for (const c of calls(spec)) {
165
+ const opts = [
166
+ `src: [${c.src.map((s) => `{ path: ${q(`${base}/fonts/${s.file}`)}, weight: ${q(s.weight)}, style: ${q(s.style)} }`).join(', ')}]`,
167
+ c.variable ? `variable: ${q(c.variable)}` : null,
168
+ `display: ${q(c.display)}`,
169
+ c.preload ? null : 'preload: false',
170
+ c.adjustFontFallback === false
171
+ ? 'adjustFontFallback: false'
172
+ : c.adjustFontFallback
173
+ ? `adjustFontFallback: ${q(c.adjustFontFallback)}`
174
+ : null,
175
+ `declarations: [${c.primary ? '' : `{ prop: "font-family", value: ${q(`'${c.family}'`)} }, `}{ prop: "unicode-range", value: ${q(c.unicodeRange)} }]`,
176
+ ].filter(Boolean);
177
+ lines.push('', `export const ${c.name} = localFont({ ${opts.join(', ')} });`);
178
+ }
179
+ }
180
+ return lines.join('\n') + '\n';
181
+ }
182
+
183
+ /** Format with the app's own prettier and config, when it has one, so its format check passes. */
184
+ async function format(out, code) {
185
+ try {
186
+ const require = createRequire(resolve(out));
187
+ const mod = await import(require.resolve('prettier'));
188
+ const prettier = mod.default ?? mod;
189
+ const config = (await prettier.resolveConfig(resolve(out))) ?? {};
190
+ return await prettier.format(code, { ...config, filepath: resolve(out) });
191
+ } catch {
192
+ return code;
193
+ }
194
+ }
195
+
196
+ async function main(argv) {
197
+ const check = argv.includes('--check');
198
+ const args = argv.filter((a) => a !== '--check');
199
+ const [out, ...specTexts] = args;
200
+ if (!out || !specTexts.length) {
201
+ console.error(
202
+ 'usage: design-tokens-next-fonts <out-file> "<export>=<face>[;key=value]..." ... [--check]',
203
+ );
204
+ process.exit(2);
205
+ }
206
+ const code = await format(out, render(out, specTexts.map(parseSpec), args));
207
+ if (check) {
208
+ const current = existsSync(out) ? readFileSync(out, 'utf8') : '';
209
+ if (current !== code) {
210
+ console.error(
211
+ `${out} is not what design-tokens-next-fonts writes; re-run the command in its first lines.`,
212
+ );
213
+ process.exit(1);
214
+ }
215
+ return;
216
+ }
217
+ writeFileSync(out, code);
218
+ }
219
+
220
+ if (
221
+ process.argv[1] &&
222
+ realpathSync(process.argv[1]) === realpathSync(fileURLToPath(import.meta.url))
223
+ )
224
+ await main(process.argv.slice(2));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bitbaum/design-tokens",
3
- "version": "1.2.0",
3
+ "version": "1.3.1",
4
4
  "packageManager": "pnpm@11.25.0",
5
5
  "engines": {
6
6
  "node": ">=20"
@@ -9,7 +9,7 @@
9
9
  "access": "public",
10
10
  "provenance": true
11
11
  },
12
- "description": "Design SSOT for OrangeCat, Loki and Solon — tokens, self-hosted faces, and the Tailwind preset that maps them.",
12
+ "description": "Design SSOT for OrangeCat, Loki and Solon — tokens, self-hosted faces, the Tailwind preset that maps them, and next/font/local calls for every face the fleet's apps use.",
13
13
  "license": "MIT",
14
14
  "repository": {
15
15
  "type": "git",
@@ -19,13 +19,19 @@
19
19
  "tokens.css",
20
20
  "composition.css",
21
21
  "tailwind-preset.js",
22
+ "next-fonts.mjs",
22
23
  "fonts"
23
24
  ],
24
25
  "exports": {
25
26
  "./tokens.css": "./tokens.css",
26
27
  "./composition.css": "./composition.css",
27
28
  "./tailwind-preset": "./tailwind-preset.js",
28
- "./fonts/*": "./fonts/*"
29
+ "./fonts/*": "./fonts/*",
30
+ "./next-fonts": "./next-fonts.mjs",
31
+ "./package.json": "./package.json"
32
+ },
33
+ "bin": {
34
+ "design-tokens-next-fonts": "./next-fonts.mjs"
29
35
  },
30
36
  "sideEffects": [
31
37
  "*.css"
@@ -36,12 +42,13 @@
36
42
  "test": "node --test test/*.test.js",
37
43
  "verify": "pnpm run format:check && pnpm run lint && pnpm run typecheck && pnpm test",
38
44
  "format": "prettier --write .",
39
- "format:check": "prettier --check ."
45
+ "format:check": "prettier --check .",
46
+ "fonts:fetch": "node scripts/fetch-fonts.mjs"
40
47
  },
41
48
  "devDependencies": {
42
49
  "@eslint/js": "^10.0.1",
43
50
  "@types/node": "^26.6.5",
44
- "eslint": "^10.12.0",
51
+ "eslint": "^10.13.0",
45
52
  "globals": "^17.13.0",
46
53
  "prettier": "3.9.10",
47
54
  "typescript": "^6.0.3"