@link-foundation/ui-tokens 0.0.0-stage → 0.0.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.
@@ -0,0 +1,153 @@
1
+ /**
2
+ * What the Swift and Kotlin writers share: the constants come in sections
3
+ * (the resolved tokens, then one nested namespace per mode with the tokens
4
+ * the mode changes), a whole-token alias refers to the constant of its
5
+ * target, and values are converted to the units of the platforms (1rem is
6
+ * 16 points, durations are numbers).
7
+ */
8
+
9
+ import { values as coreValues } from '@link-foundation/ui-core';
10
+ import { FONT_WEIGHTS } from '../values.js';
11
+ import { upperCamel } from '../names.js';
12
+
13
+ const { oklchToSrgb } = coreValues;
14
+
15
+ /**
16
+ * @typedef {import('../types.js').ResolvedTokens} ResolvedTokens
17
+ * @typedef {import('../types.js').ResolvedToken} ResolvedToken
18
+ * @typedef {import('../types.js').TokenValue} TokenValue
19
+ *
20
+ * @typedef {object} Section
21
+ * @property {string|null} mode
22
+ * @property {string[]} scope the qualified name: `['Tokens', 'Dark']`
23
+ * @property {Map<string, ResolvedToken>} tokens
24
+ */
25
+
26
+ /** The points of one rem (the CSS default root font size). */
27
+ export const REM = 16;
28
+
29
+ /** A number without float noise: `0.15`, not `0.15000000000000002`. */
30
+ export const num = (x) => String(Number(x.toPrecision(12)));
31
+
32
+ /** A dimension in points (px and pt are the same at 1x). */
33
+ export const points = (d) => (d.unit === 'rem' ? d.value * REM : d.value);
34
+
35
+ /** A duration in milliseconds. */
36
+ export const millis = (d) => (d.unit === 's' ? d.value * 1000 : d.value);
37
+
38
+ /** A font weight as a number 1..1000. */
39
+ export const weight = (w) =>
40
+ typeof w.value === 'number' ? w.value : FONT_WEIGHTS[w.value];
41
+
42
+ /** sRGB channels 0..1 (oklch converted, out-of-gamut clamped). */
43
+ export function rgba(color) {
44
+ const c = color.space === 'oklch' ? oklchToSrgb(color) : color;
45
+ const clamp = (x) => Math.min(1, Math.max(0, x));
46
+ return { r: clamp(c.r), g: clamp(c.g), b: clamp(c.b), a: clamp(c.a) };
47
+ }
48
+
49
+ /** The layers of a resolved shadow. */
50
+ export const layers = (shadow) => [shadow.value].flat();
51
+
52
+ /**
53
+ * The tokens in their order, except that an alias comes after the token of
54
+ * the same section it refers to: a Kotlin `object` initialises its
55
+ * properties in order, so `val A = Tokens.B` before `val B` would read an
56
+ * uninitialised `B`. (Aliases have no cycles once resolved.)
57
+ * @param {Map<string, ResolvedToken>} tokens
58
+ * @returns {Map<string, ResolvedToken>}
59
+ */
60
+ export function targetsFirst(tokens) {
61
+ const out = new Map();
62
+ const add = (token) => {
63
+ if (out.has(token.path)) {
64
+ return;
65
+ }
66
+ const target =
67
+ token.alias === undefined ? undefined : tokens.get(token.alias);
68
+ if (target !== undefined) {
69
+ add(target);
70
+ }
71
+ out.set(token.path, token);
72
+ };
73
+ for (const token of tokens.values()) {
74
+ add(token);
75
+ }
76
+ return out;
77
+ }
78
+
79
+ /**
80
+ * The resolved tokens and, per mode, the tokens the mode changes, each with
81
+ * the alias targets first ({@link targetsFirst}).
82
+ * @param {ResolvedTokens} resolved
83
+ * @param {string} name the name of the outer namespace
84
+ * @returns {Section[]}
85
+ */
86
+ export function sections(resolved, name) {
87
+ return [
88
+ { mode: null, scope: [name], tokens: targetsFirst(resolved) },
89
+ ...[...(resolved.modes ?? [])]
90
+ .filter(([, tokens]) => tokens.size > 0)
91
+ .map(([mode, tokens]) => ({
92
+ mode,
93
+ scope: [name, upperCamel(mode)],
94
+ tokens: targetsFirst(tokens),
95
+ })),
96
+ ];
97
+ }
98
+
99
+ /**
100
+ * The qualified constant an alias token refers to: the mode's own constant
101
+ * when the mode changes the target, otherwise the outer one.
102
+ * @param {ResolvedToken} token a token with `alias`
103
+ * @param {Section} section
104
+ * @param {(token: ResolvedToken) => string} constant the constant name
105
+ * @param {ResolvedTokens} resolved
106
+ */
107
+ export function aliasReference(token, section, constant, resolved) {
108
+ const local = section.tokens.get(token.alias);
109
+ const target = local ?? resolved.get(token.alias);
110
+ const scope = local === undefined ? section.scope.slice(0, 1) : section.scope;
111
+ return [...scope, constant(target)].join('.');
112
+ }
113
+
114
+ /**
115
+ * Throw when two tokens of a section get the same constant name
116
+ * (`color.on-primary` and `color.onPrimary`).
117
+ * @param {Section[]} all
118
+ * @param {(token: ResolvedToken) => string} constant
119
+ */
120
+ export function checkNames(all, constant) {
121
+ for (const { tokens } of all) {
122
+ const seen = new Map();
123
+ for (const token of tokens.values()) {
124
+ const name = constant(token);
125
+ if (seen.has(name)) {
126
+ throw new TypeError(
127
+ `The tokens "${seen.get(name)}" and "${token.path}" are both ${name}`
128
+ );
129
+ }
130
+ seen.set(name, token.path);
131
+ }
132
+ }
133
+ }
134
+
135
+ /** Every type the sections use, with the fields of composites. */
136
+ export function usedTypes(all) {
137
+ const types = new Set();
138
+ for (const { tokens } of all) {
139
+ for (const token of tokens.values()) {
140
+ types.add(token.type);
141
+ }
142
+ }
143
+ if (types.has('shadow')) {
144
+ types.add('color').add('dimension');
145
+ }
146
+ if (types.has('typography')) {
147
+ types.add('fontFamily').add('dimension').add('fontWeight');
148
+ }
149
+ return types;
150
+ }
151
+
152
+ /** The lines of a description, for doc comments. */
153
+ export const descriptionLines = (text) => text.split(/\r?\n/u);
@@ -0,0 +1,187 @@
1
+ /**
2
+ * `toSwift(resolved, { name })`: the tokens as SwiftUI constants.
3
+ *
4
+ * ```swift
5
+ * import SwiftUI
6
+ *
7
+ * public enum Tokens {
8
+ * public static let colorPrimary = Color(red: 0.404, green: 0.314, blue: 0.643, opacity: 1)
9
+ * public static let spaceMedium: CGFloat = 16
10
+ * public static let motionDurationShort: TimeInterval = 0.15
11
+ * }
12
+ * ```
13
+ *
14
+ * colour -> `Color` (sRGB, 3 decimals), dimension -> `CGFloat` points
15
+ * (1rem = 16), duration -> `TimeInterval` seconds, number -> `Double`,
16
+ * fontFamily -> `[String]`, fontWeight -> `Font.Weight` (nearest),
17
+ * cubicBezier -> a labelled tuple of `Double`, shadow -> `Shadow` or
18
+ * `[Shadow]`, typography -> `Typography` (both structs are generated when
19
+ * used). An alias is its target's constant; a mode is a nested enum
20
+ * (`Tokens.Dark`) with the constants the mode changes.
21
+ */
22
+
23
+ import { lowerCamel } from '../names.js';
24
+ import { COMPOSITE_FIELDS } from '../values.js';
25
+ import {
26
+ aliasReference,
27
+ checkNames,
28
+ descriptionLines,
29
+ layers,
30
+ millis,
31
+ num,
32
+ points,
33
+ rgba,
34
+ sections,
35
+ usedTypes,
36
+ weight,
37
+ } from './native.js';
38
+
39
+ /** @typedef {import('../types.js').ResolvedTokens} ResolvedTokens */
40
+
41
+ /** Swift keywords that are names of their own and need backticks. */
42
+ const KEYWORDS = new Set(
43
+ 'associatedtype class deinit enum extension fileprivate func import init inout internal let open operator private protocol public rethrows static struct subscript typealias var break case continue default defer do else fallthrough for guard if in repeat return switch where while as Any catch false is nil super self Self throw throws true try'.split(
44
+ ' '
45
+ )
46
+ );
47
+
48
+ const constant = (token) => {
49
+ const name = lowerCamel(token.path);
50
+ return KEYWORDS.has(name) ? `\`${name}\`` : name;
51
+ };
52
+
53
+ /** `Font.Weight` by the nearest hundred. */
54
+ const FONT_WEIGHT_NAMES = [
55
+ 'ultraLight',
56
+ 'thin',
57
+ 'light',
58
+ 'regular',
59
+ 'medium',
60
+ 'semibold',
61
+ 'bold',
62
+ 'heavy',
63
+ 'black',
64
+ ];
65
+
66
+ const fontWeight = (w) => {
67
+ const i = Math.min(8, Math.max(0, Math.round(weight(w) / 100) - 1));
68
+ return `.${FONT_WEIGHT_NAMES[i]}`;
69
+ };
70
+
71
+ const swiftString = (s) => JSON.stringify(s);
72
+
73
+ const color = (c) => {
74
+ const { r, g, b, a } = rgba(c);
75
+ const d = (x) => num(Math.round(x * 1000) / 1000);
76
+ return `Color(red: ${d(r)}, green: ${d(g)}, blue: ${d(b)}, opacity: ${d(a)})`;
77
+ };
78
+
79
+ const shadowLayer = (l) =>
80
+ `Shadow(color: ${color(l.color)}, offsetX: ${num(points(l.offsetX))}, offsetY: ${num(points(l.offsetY))}, blur: ${num(points(l.blur))}, spread: ${num(points(l.spread))}, inset: ${l.inset === true})`;
81
+
82
+ const fontFamily = (f) => `[${[f.value].flat().map(swiftString).join(', ')}]`;
83
+
84
+ /** `[Swift type, expression]` of a resolved value. */
85
+ function swiftValue(value) {
86
+ switch (value.type) {
87
+ case 'color':
88
+ return ['Color', color(value)];
89
+ case 'dimension':
90
+ return ['CGFloat', num(points(value))];
91
+ case 'duration':
92
+ return ['TimeInterval', num(millis(value) / 1000)];
93
+ case 'number':
94
+ return ['Double', num(value.value)];
95
+ case 'fontFamily':
96
+ return ['[String]', fontFamily(value)];
97
+ case 'fontWeight':
98
+ return ['Font.Weight', fontWeight(value)];
99
+ case 'cubicBezier':
100
+ return [
101
+ '(x1: Double, y1: Double, x2: Double, y2: Double)',
102
+ `(${value.value.map(num).join(', ')})`,
103
+ ];
104
+ case 'shadow': {
105
+ const all = layers(value).map(shadowLayer);
106
+ return Array.isArray(value.value)
107
+ ? ['[Shadow]', `[${all.join(', ')}]`]
108
+ : ['Shadow', all[0]];
109
+ }
110
+ default: {
111
+ const t = value.value;
112
+ return [
113
+ 'Typography',
114
+ `Typography(fontFamily: ${fontFamily(t.fontFamily)}, fontSize: ${num(points(t.fontSize))}, fontWeight: ${fontWeight(t.fontWeight)}, letterSpacing: ${num(points(t.letterSpacing))}, lineHeight: ${num(t.lineHeight.value)})`,
115
+ ];
116
+ }
117
+ }
118
+ }
119
+
120
+ const SWIFT_FIELD_TYPES = {
121
+ color: 'Color',
122
+ dimension: 'CGFloat',
123
+ fontFamily: '[String]',
124
+ fontWeight: 'Font.Weight',
125
+ number: 'Double',
126
+ };
127
+
128
+ function struct(name, kind, pad, extra = []) {
129
+ return [
130
+ `${pad}public struct ${name} {`,
131
+ ...COMPOSITE_FIELDS[kind].map(
132
+ ([, key, type]) => `${pad} public let ${key}: ${SWIFT_FIELD_TYPES[type]}`
133
+ ),
134
+ ...extra.map((line) => `${pad} ${line}`),
135
+ `${pad}}`,
136
+ ];
137
+ }
138
+
139
+ /**
140
+ * The tokens as a Swift source file.
141
+ * @param {ResolvedTokens} resolved
142
+ * @param {{ name?: string }} [options] the enum name (default `Tokens`)
143
+ * @returns {string}
144
+ */
145
+ export function toSwift(resolved, { name = 'Tokens' } = {}) {
146
+ const all = sections(resolved, name);
147
+ checkNames(all, constant);
148
+ const types = usedTypes(all);
149
+ const lines = ['import SwiftUI', '', `public enum ${name} {`];
150
+ if (types.has('shadow')) {
151
+ lines.push(
152
+ ...struct('Shadow', 'shadow', ' ', ['public let inset: Bool']),
153
+ ''
154
+ );
155
+ }
156
+ if (types.has('typography')) {
157
+ lines.push(...struct('Typography', 'typography', ' '), '');
158
+ }
159
+ for (const section of all) {
160
+ const pad = section.mode === null ? ' ' : ' ';
161
+ if (section.mode !== null) {
162
+ lines.push('', ` /// The tokens the mode "${section.mode}" changes.`);
163
+ lines.push(` public enum ${section.scope[1]} {`);
164
+ }
165
+ for (const token of section.tokens.values()) {
166
+ if (token.description !== undefined) {
167
+ lines.push(
168
+ ...descriptionLines(token.description).map((l) => `${pad}/// ${l}`)
169
+ );
170
+ }
171
+ const [type, expression] = swiftValue(token.value);
172
+ const value =
173
+ token.alias === undefined
174
+ ? expression
175
+ : aliasReference(token, section, constant, resolved);
176
+ const annotation = token.type === 'color' ? '' : `: ${type}`;
177
+ lines.push(
178
+ `${pad}public static let ${constant(token)}${annotation} = ${value}`
179
+ );
180
+ }
181
+ if (section.mode !== null) {
182
+ lines.push(' }');
183
+ }
184
+ }
185
+ lines.push('}');
186
+ return `${lines.join('\n')}\n`;
187
+ }
@@ -0,0 +1,258 @@
1
+ /**
2
+ * `fromDtcg(json, { id })`: a DTCG 2025.10 token file as a Links Notation
3
+ * token set, the inverse of `toDtcg`.
4
+ *
5
+ * - Groups give the dotted path; `$root` tokens (section 6.2) are the
6
+ * group's own token; a group's `$type` is inherited (section 5.2.2).
7
+ * - `"{a.b}"` (section 7.1.1) and `{ "$ref": "#/a/b/$value" }` (section
8
+ * 7.1.2) become `(token a.b)`.
9
+ * - `$extensions["com.github.link-foundation.ui"].modes` (written by
10
+ * `toDtcg`) become `(mode NAME ...)` links.
11
+ * - `(type T)` is written only when the value alone would read as another
12
+ * type, and always on aliases, whose DTCG `$type` is checked by the
13
+ * resolver.
14
+ *
15
+ * Throws a `TypeError` naming the token for what has no Links Notation
16
+ * form: a token without a type, a value that does not fit its type, a
17
+ * colour space other than srgb or oklch without a `hex` fallback, a group
18
+ * `$extends`.
19
+ */
20
+
21
+ import { formatLinks, values as coreValues } from '@link-foundation/ui-core';
22
+ import { DTCG_EXTENSION } from '../export/dtcg.js';
23
+ import {
24
+ COMPOSITE_FIELDS,
25
+ TOKEN_TYPES,
26
+ inferredType,
27
+ tokenValueRaw,
28
+ typeTokenValue,
29
+ } from '../values.js';
30
+
31
+ const { parseColor } = coreValues;
32
+
33
+ /** @typedef {import('../types.js').TokenValue} TokenValue */
34
+
35
+ const fail = (path, message) => {
36
+ throw new TypeError(`DTCG token "${path}": ${message}`);
37
+ };
38
+
39
+ const isObject = (x) =>
40
+ typeof x === 'object' && x !== null && !Array.isArray(x);
41
+
42
+ /** `a.b.$root` -> `a.b`. */
43
+ const stripRoot = (path) => path.replace(/(^|\.)\$root$/u, '');
44
+
45
+ /** `#/a/b/$value` (JSON Pointer, RFC 6901) -> `a.b`. */
46
+ function pointerPath(pointer, path) {
47
+ const parts = /^#\/(.+)\/\$value$/u.exec(pointer);
48
+ if (parts === null) {
49
+ fail(path, `the $ref "${pointer}" is not a "#/.../$value" pointer`);
50
+ }
51
+ const names = parts[1]
52
+ .split('/')
53
+ .map((p) => p.replaceAll('~1', '/').replaceAll('~0', '~'));
54
+ return stripRoot(names.join('.'));
55
+ }
56
+
57
+ /** A reference (`"{a.b}"` or `{ $ref }`) as a `token-ref`, else `null`. */
58
+ function referenceOf(value, path) {
59
+ if (typeof value === 'string') {
60
+ const match = /^\{([^{}]+)\}$/u.exec(value);
61
+ return match === null
62
+ ? null
63
+ : { type: 'token-ref', path: stripRoot(match[1]) };
64
+ }
65
+ if (isObject(value) && typeof value.$ref === 'string') {
66
+ return { type: 'token-ref', path: pointerPath(value.$ref, path) };
67
+ }
68
+ return null;
69
+ }
70
+
71
+ /** A number of 0..1 that is a hex byte up to 4 decimals, as that byte. */
72
+ const snap = (x) => {
73
+ const byte = Math.round(x * 255);
74
+ return Math.abs(x - byte / 255) <= 5.1e-5 ? byte / 255 : x;
75
+ };
76
+
77
+ const componentNumber = (c) => (c === 'none' ? 0 : c);
78
+
79
+ /** A Color Module object as a colour token value. */
80
+ function colorValue(color, path) {
81
+ if (typeof color === 'string') {
82
+ return parseColor(color) ?? fail(path, `"${color}" is not a colour`);
83
+ }
84
+ if (!isObject(color) || !Array.isArray(color.components)) {
85
+ fail(path, 'a colour is { colorSpace, components, alpha?, hex? }');
86
+ }
87
+ const [x, y, z] = color.components.map(componentNumber);
88
+ const a = color.alpha ?? 1;
89
+ switch (color.colorSpace) {
90
+ case 'srgb':
91
+ return {
92
+ type: 'color',
93
+ space: 'srgb',
94
+ r: snap(x),
95
+ g: snap(y),
96
+ b: snap(z),
97
+ a: snap(a),
98
+ };
99
+ case 'oklch':
100
+ return { type: 'color', space: 'oklch', l: x, c: y, h: z, a };
101
+ default: {
102
+ const hex = typeof color.hex === 'string' ? parseColor(color.hex) : null;
103
+ if (hex === null) {
104
+ fail(
105
+ path,
106
+ `the colour space "${color.colorSpace}" needs a hex fallback`
107
+ );
108
+ }
109
+ return { ...hex, a: snap(a) };
110
+ }
111
+ }
112
+ }
113
+
114
+ const quantity = (type, value) =>
115
+ isObject(value) ? `${value.value}${value.unit}` : value;
116
+
117
+ /**
118
+ * A DTCG `$value` as a token value of `type`, via its Links Notation form,
119
+ * so that it is checked exactly like a value read from text.
120
+ * @returns {TokenValue}
121
+ */
122
+ function tokenValue(value, type, path) {
123
+ const ref = referenceOf(value, path);
124
+ if (ref !== null) {
125
+ return ref;
126
+ }
127
+ const typed = (raw, t) =>
128
+ typeTokenValue(raw, t) ?? fail(path, `the value is not a ${t}`);
129
+ const field = (kind, object) => {
130
+ if (!isObject(object)) {
131
+ fail(path, `a ${kind} value is an object`);
132
+ }
133
+ return COMPOSITE_FIELDS[kind].map(([name, key, fieldType]) => {
134
+ const v = tokenValue(object[key], fieldType, path);
135
+ return [
136
+ name,
137
+ ...[tokenValueRaw(v)].flat(v.type === 'fontFamily' ? 1 : 0),
138
+ ];
139
+ });
140
+ };
141
+ const layer = (object) => {
142
+ const r = referenceOf(object, path);
143
+ if (r !== null) {
144
+ return tokenValueRaw(r);
145
+ }
146
+ const inset = isObject(object) && object.inset !== undefined;
147
+ return [
148
+ 'shadow',
149
+ ...field('shadow', object),
150
+ ...(inset ? [['inset', String(object.inset)]] : []),
151
+ ];
152
+ };
153
+ switch (type) {
154
+ case 'color':
155
+ return colorValue(value, path);
156
+ case 'dimension':
157
+ case 'duration':
158
+ return typed(quantity(type, value), type);
159
+ case 'number':
160
+ case 'fontWeight':
161
+ return typed(String(value), type);
162
+ case 'fontFamily':
163
+ return typed(value, type);
164
+ case 'cubicBezier':
165
+ return typed(['cubic-bezier', ...[value].flat().map(String)], type);
166
+ case 'shadow':
167
+ return typed(
168
+ Array.isArray(value) ? value.map(layer) : layer(value),
169
+ type
170
+ );
171
+ case 'typography':
172
+ return typed(['typography', ...field('typography', value)], type);
173
+ default:
174
+ return fail(
175
+ path,
176
+ `the type "${type}" is not one of ${TOKEN_TYPES.join(', ')}`
177
+ );
178
+ }
179
+ }
180
+
181
+ /** Every token of a group, depth first: `{ path, type, value, description }`. */
182
+ function tokensOf(group, prefix, inherited, out) {
183
+ if (group.$extends !== undefined) {
184
+ fail(
185
+ prefix,
186
+ 'group $extends is not supported; write (extends ...) instead'
187
+ );
188
+ }
189
+ const type = group.$type ?? inherited;
190
+ if (Object.hasOwn(group, '$value')) {
191
+ const path = stripRoot(prefix);
192
+ const ref = referenceOf(group.$value, path);
193
+ if (type === undefined && ref === null) {
194
+ fail(
195
+ path,
196
+ 'no $type (DTCG 2025.10 section 5.2.2: tools must not guess it)'
197
+ );
198
+ }
199
+ out.push({
200
+ path,
201
+ type: type ?? null,
202
+ value: ref ?? tokenValue(group.$value, type, path),
203
+ description: group.$description,
204
+ });
205
+ return out;
206
+ }
207
+ for (const [name, child] of Object.entries(group)) {
208
+ if ((!name.startsWith('$') || name === '$root') && isObject(child)) {
209
+ tokensOf(child, prefix === '' ? name : `${prefix}.${name}`, type, out);
210
+ }
211
+ }
212
+ return out;
213
+ }
214
+
215
+ /** One `token PATH VALUE...` link, with `type T` and `description '...'`. */
216
+ function tokenLink({ path, type, value, description }) {
217
+ const raw = tokenValueRaw(value);
218
+ const spread =
219
+ Array.isArray(value.value) &&
220
+ (value.type === 'fontFamily' || value.type === 'shadow');
221
+ const typeLink =
222
+ type !== null && (value.type === 'token-ref' || inferredType(raw) !== type)
223
+ ? [['type', type]]
224
+ : [];
225
+ const describe =
226
+ description === undefined ? [] : [['description', String(description)]];
227
+ return ['token', path, ...(spread ? raw : [raw]), ...typeLink, ...describe];
228
+ }
229
+
230
+ /**
231
+ * A DTCG 2025.10 token file as a Links Notation token set, written in the
232
+ * nested form (#133):
233
+ *
234
+ * ```lino
235
+ * material3: theme
236
+ * token color.primary '#6750A4'
237
+ * mode dark
238
+ * token color.primary '#D0BCFF'
239
+ * ```
240
+ * @param {string|Record<string, any>} json the file text or its object
241
+ * @param {{ id?: string }} [options] `id` names the set (default `tokens`)
242
+ * @returns {string}
243
+ */
244
+ export function fromDtcg(json, { id = 'tokens' } = {}) {
245
+ const root = typeof json === 'string' ? JSON.parse(json) : json;
246
+ if (!isObject(root)) {
247
+ throw new TypeError('A DTCG token file is a JSON object');
248
+ }
249
+ const tokens = tokensOf(root, '', undefined, []).map(tokenLink);
250
+ const modes = Object.entries(
251
+ root.$extensions?.[DTCG_EXTENSION]?.modes ?? {}
252
+ ).map(([mode, group]) => [
253
+ 'mode',
254
+ mode,
255
+ ...tokensOf(group, '', undefined, []).map(tokenLink),
256
+ ]);
257
+ return formatLinks([{ id, values: ['theme', ...tokens, ...modes] }]);
258
+ }