@cognitap/radiant 0.0.4 → 0.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 (85) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +9 -0
  3. package/dist/library/Card.d.ts.map +1 -1
  4. package/dist/library/Card.js +8 -6
  5. package/dist/library/Card.js.map +1 -1
  6. package/dist/library/Checkbox.js +2 -2
  7. package/dist/library/Checkbox.js.map +1 -1
  8. package/dist/library/Collapsible.d.ts.map +1 -1
  9. package/dist/library/Collapsible.js +5 -4
  10. package/dist/library/Collapsible.js.map +1 -1
  11. package/dist/library/Dialog.d.ts.map +1 -1
  12. package/dist/library/Dialog.js +8 -6
  13. package/dist/library/Dialog.js.map +1 -1
  14. package/dist/library/Field.js +4 -4
  15. package/dist/library/Field.js.map +1 -1
  16. package/dist/library/Input.d.ts.map +1 -1
  17. package/dist/library/Input.js +4 -3
  18. package/dist/library/Input.js.map +1 -1
  19. package/dist/library/Link.d.ts.map +1 -1
  20. package/dist/library/Link.js +0 -1
  21. package/dist/library/Link.js.map +1 -1
  22. package/dist/library/RadioGroup.js +2 -2
  23. package/dist/library/RadioGroup.js.map +1 -1
  24. package/dist/library/ThemeScope.js +1 -1
  25. package/dist/library/ThemeScope.js.map +1 -1
  26. package/dist/library/actionStyles.js +2 -2
  27. package/dist/library/actionStyles.js.map +1 -1
  28. package/dist/library/cn.d.ts +2 -1
  29. package/dist/library/cn.d.ts.map +1 -1
  30. package/dist/library/cn.js +22 -1
  31. package/dist/library/cn.js.map +1 -1
  32. package/dist/library/index.d.ts +3 -1
  33. package/dist/library/index.d.ts.map +1 -1
  34. package/dist/library/index.js +1 -0
  35. package/dist/library/index.js.map +1 -1
  36. package/dist/library/styles.css +1 -1
  37. package/dist/library/themes/defineTheme.d.ts.map +1 -1
  38. package/dist/library/themes/defineTheme.js +5 -1
  39. package/dist/library/themes/defineTheme.js.map +1 -1
  40. package/dist/library/themes/index.d.ts +1 -1
  41. package/dist/library/themes/index.d.ts.map +1 -1
  42. package/dist/library/themes/index.js.map +1 -1
  43. package/dist/library/themes/themeDocument.d.ts.map +1 -1
  44. package/dist/library/themes/themeDocument.js +29 -4
  45. package/dist/library/themes/themeDocument.js.map +1 -1
  46. package/dist/library/themes/themeDocumentTypes.d.ts +11 -0
  47. package/dist/library/themes/themeDocumentTypes.d.ts.map +1 -1
  48. package/dist/library/themes/themeDocumentTypes.js.map +1 -1
  49. package/dist/library/themes/tokens.d.ts +7 -0
  50. package/dist/library/themes/tokens.d.ts.map +1 -1
  51. package/dist/library/themes/tokens.js +99 -0
  52. package/dist/library/themes/tokens.js.map +1 -1
  53. package/dist/library/typography/index.d.ts +72 -0
  54. package/dist/library/typography/index.d.ts.map +1 -0
  55. package/dist/library/typography/index.js +160 -0
  56. package/dist/library/typography/index.js.map +1 -0
  57. package/dist/library/typography/types.d.ts +78 -0
  58. package/dist/library/typography/types.d.ts.map +1 -0
  59. package/dist/library/typography/types.js +2 -0
  60. package/dist/library/typography/types.js.map +1 -0
  61. package/docs/system.md +7 -0
  62. package/docs/theming.md +204 -0
  63. package/package.json +7 -2
  64. package/src/Card.tsx +8 -6
  65. package/src/Checkbox.tsx +2 -2
  66. package/src/Collapsible.tsx +5 -4
  67. package/src/Dialog.tsx +8 -6
  68. package/src/Field.tsx +4 -4
  69. package/src/Input.tsx +4 -3
  70. package/src/Link.tsx +0 -1
  71. package/src/RadioGroup.tsx +2 -2
  72. package/src/ThemeScope.tsx +1 -1
  73. package/src/actionStyles.ts +2 -2
  74. package/src/cn.ts +25 -1
  75. package/src/index.ts +3 -0
  76. package/src/styles.css +1 -0
  77. package/src/themes/baseline.css +131 -0
  78. package/src/themes/defineTheme.ts +5 -1
  79. package/src/themes/index.ts +1 -0
  80. package/src/themes/themeDocument.ts +34 -4
  81. package/src/themes/themeDocumentTypes.ts +12 -0
  82. package/src/themes/tokens.ts +137 -0
  83. package/src/typography/index.ts +199 -0
  84. package/src/typography/types.ts +92 -0
  85. package/src/typography.css +336 -0
@@ -1 +1 @@
1
- {"version":3,"file":"themeDocument.js","sourceRoot":"","sources":["../../../src/themes/themeDocument.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAqD,MAAM,kBAAkB,CAAA;AACjG,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAWvD,MAAM,YAAY,GAAgC;IAChD,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;IACnC,YAAY;CACS,CAAA;AACvB,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAA;AAG7E,SAAS,MAAM,CAAC,KAAc,EAAE,IAAY;IAC1C,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAChE,MAAM,IAAI,SAAS,CAAC,GAAG,IAAI,qBAAqB,CAAC,CAAA;IACnD,CAAC;AACH,CAAC;AAED,SAAS,IAAI,CAAC,KAAkB,EAAE,OAA0B,EAAE,IAAY;IACxE,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACrC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC;YAAE,MAAM,IAAI,SAAS,CAAC,gBAAgB,IAAI,IAAI,GAAG,GAAG,CAAC,CAAA;IACjF,CAAC;AACH,CAAC;AAED,SAAS,SAAS,CAAC,KAAc,EAAE,IAAY;IAC7C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;QAC/C,MAAM,IAAI,SAAS,CAAC,GAAG,IAAI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ACjD,MAAM,KAAK,GAAgB,EAAE,CAAA;QAC7B,KAAK,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,MAAM,CAAU,EAAE,CAAC;YAC9C,MAAM,MAAM,GACV,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,IAAI,CAAC,CAAA;YAC7F,IAAI,MAAM,KAAK,SAAS;gBAAE,KAAK,CAAC,IAAI,CAAC,GAAG,MAAM,CAAA;QAChD,CAAC;QACD,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM;YAAE,OAAO,CAAC,KAAK,GAAG,KAAK,CAAA;QACpD,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM;YAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,OAAO,CAAA;IAC3D,CAAC;IACD,OAAO,mBAAmB,CAAC;QACzB,IAAI,EAAE,eAAe;QACrB,OAAO,EAAE,CAAC;QACV,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,QAAQ;KACT,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { defineTheme, type Theme, type ThemeDefinition, type ThemeLayer } from './defineTheme.js'\nimport { freezeTree, tokenDefaults } from './tokens.js'\nimport type {\n ThemeColorSection,\n ThemeDocument,\n ThemeSectionExport,\n ThemeSectionName,\n ThemeSections\n} from './themeDocumentTypes.js'\n\nexport type * from './themeDocumentTypes.js'\n\nconst sectionNames: readonly ThemeSectionName[] = [\n ...Object.keys(tokenDefaults.light),\n 'components'\n] as ThemeSectionName[]\nconst stops = new Set([50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950])\ntype RecordValue = Record<string, unknown>\n\nfunction record(value: unknown, path: string): asserts value is RecordValue {\n if (!value || typeof value !== 'object' || Array.isArray(value)) {\n throw new TypeError(`${path} must be an object.`)\n }\n}\n\nfunction keys(value: RecordValue, allowed: readonly string[], path: string) {\n for (const key of Object.keys(value)) {\n if (!allowed.includes(key)) throw new TypeError(`Unknown key: ${path}.${key}.`)\n }\n}\n\nfunction textValue(value: unknown, path: string) {\n if (typeof value !== 'string' || !value.trim()) {\n throw new TypeError(`${path} must be a nonempty string.`)\n }\n}\n\nfunction choice(value: unknown, allowed: readonly unknown[], path: string) {\n if (!allowed.includes(value)) {\n throw new TypeError(`${path} must be one of: ${allowed.join(', ')}.`)\n }\n}\n\nfunction list(value: unknown, path: string): asserts value is unknown[] {\n if (!Array.isArray(value)) throw new TypeError(`${path} must be an array.`)\n}\n\nfunction unique(value: unknown, seen: Set<unknown>, path: string) {\n if (seen.has(value)) throw new TypeError(`Duplicate value at ${path}: ${String(value)}.`)\n seen.add(value)\n}\n\n/** Copy data without running getters/toJSON or silently losing functions and binaries. */\nfunction jsonCopy(value: unknown, path: string, ancestors = new Set<object>()): unknown {\n if (value === null || typeof value === 'string' || typeof value === 'boolean') return value\n if (typeof value === 'number' && Number.isFinite(value)) return value === 0 ? 0 : value\n if (!value || typeof value !== 'object')\n throw new TypeError(`${path} must contain JSON data only.`)\n if (ancestors.has(value)) throw new TypeError(`Circular reference at ${path}.`)\n const array = Array.isArray(value)\n const prototype = Object.getPrototypeOf(value)\n if (\n array ? prototype !== Array.prototype : prototype !== Object.prototype && prototype !== null\n ) {\n throw new TypeError(`${path} must contain plain JSON objects, not class instances or binaries.`)\n }\n ancestors.add(value)\n const result: RecordValue | unknown[] = array ? [] : {}\n if (Object.getOwnPropertySymbols(value).length)\n throw new TypeError(`${path} cannot contain symbol keys.`)\n const descriptors = Object.getOwnPropertyDescriptors(value)\n for (const key of Object.keys(descriptors).sort()) {\n if (array && key === 'length') continue\n if (['__proto__', 'constructor', 'prototype'].includes(key))\n throw new TypeError(`Forbidden key: ${path}.${key}.`)\n const descriptor = descriptors[key]\n if (!('value' in descriptor) || !descriptor.enumerable) {\n throw new TypeError(`${path}.${key} must be an enumerable data property.`)\n }\n if (array && (!/^(0|[1-9][0-9]*)$/.test(key) || Number(key) >= value.length)) {\n throw new TypeError(`${path}.${key} is not an array index.`)\n }\n // Optional object properties follow JSON omission rules; array holes/undefined are invalid.\n if (descriptor.value === undefined && !array) continue\n const copy = jsonCopy(descriptor.value, `${path}.${key}`, ancestors)\n Object.defineProperty(result, key, {\n value: copy,\n enumerable: true,\n writable: true,\n configurable: true\n })\n }\n if (array && Object.keys(result).length !== value.length)\n throw new TypeError(`${path} cannot contain array holes.`)\n ancestors.delete(value)\n return result\n}\n\nfunction validateColor(value: RecordValue, path: string) {\n if (value.brand !== undefined) {\n record(value.brand, `${path}.brand`)\n keys(value.brand, ['value', 'gamut', 'srgbFallback'], `${path}.brand`)\n textValue(value.brand.value, `${path}.brand.value`)\n choice(value.brand.gamut, ['srgb', 'display-p3'], `${path}.brand.gamut`)\n if (value.brand.srgbFallback !== undefined)\n textValue(value.brand.srgbFallback, `${path}.brand.srgbFallback`)\n if (value.fidelity === undefined) value.fidelity = 'anchored'\n }\n if (value.fidelity !== undefined)\n choice(value.fidelity, ['anchored', 'unanchored'], `${path}.fidelity`)\n if (value.palettes !== undefined) {\n list(value.palettes, `${path}.palettes`)\n const ids = new Set<unknown>()\n for (const [i, palette] of value.palettes.entries()) {\n const p = `${path}.palettes.${i}`\n record(palette, p)\n keys(palette, ['id', 'name', 'swatches'], p)\n textValue(palette.id, `${p}.id`)\n textValue(palette.name, `${p}.name`)\n unique(palette.id, ids, `${p}.id`)\n list(palette.swatches, `${p}.swatches`)\n if (!palette.swatches.length) throw new TypeError(`${p}.swatches must not be empty.`)\n const seen = new Set<unknown>()\n for (const [j, swatch] of palette.swatches.entries()) {\n const s = `${p}.swatches.${j}`\n record(swatch, s)\n keys(swatch, ['stop', 'value', 'srgbFallback'], s)\n if (!stops.has(swatch.stop as number))\n throw new TypeError(`${s}.stop must be a numbered color stop (50–950).`)\n unique(swatch.stop, seen, `${s}.stop`)\n textValue(swatch.value, `${s}.value`)\n if (swatch.srgbFallback !== undefined) textValue(swatch.srgbFallback, `${s}.srgbFallback`)\n }\n }\n }\n if (value.anchor !== undefined) {\n record(value.anchor, `${path}.anchor`)\n keys(value.anchor, ['paletteId', 'stop'], `${path}.anchor`)\n textValue(value.anchor.paletteId, `${path}.anchor.paletteId`)\n if (!stops.has(value.anchor.stop as number))\n throw new TypeError(`${path}.anchor.stop must be a numbered color stop (50–950).`)\n const color = value as ThemeColorSection\n const swatch = color.palettes\n ?.find(p => p.id === color.anchor!.paletteId)\n ?.swatches.find(s => s.stop === color.anchor!.stop)\n if (!color.brand || color.fidelity !== 'anchored' || swatch?.value !== color.brand.value) {\n throw new TypeError(\n `${path}.anchor must reference a swatch containing the exact brand.value with anchored fidelity. Regenerate or replace the color section.`\n )\n }\n }\n}\n\nfunction validateFonts(value: unknown, path: string) {\n list(value, path)\n const ids = new Set<unknown>()\n for (const [i, font] of value.entries()) {\n const p = `${path}.${i}`\n record(font, p)\n keys(font, ['id', 'family', 'source', 'weights', 'styles'], p)\n textValue(font.id, `${p}.id`)\n textValue(font.family, `${p}.family`)\n unique(font.id, ids, `${p}.id`)\n choice(font.source, ['system', 'catalog', 'local'], `${p}.source`)\n for (const key of ['weights', 'styles']) {\n if (font[key] === undefined) continue\n list(font[key], `${p}.${key}`)\n const seen = new Set<unknown>()\n for (const [j, item] of font[key].entries()) {\n const at = `${p}.${key}.${j}`\n if (key === 'styles') choice(item, ['normal', 'italic'], at)\n else if (typeof item !== 'number' || item < 1 || item > 1000)\n throw new TypeError(`${at} must be a weight from 1 to 1000.`)\n unique(item, seen, at)\n }\n }\n }\n}\n\nfunction toDefinition(sections: ThemeSections, id: string, name: string): ThemeDefinition {\n const common: { tokens: RecordValue; components?: ThemeLayer['components'] } = { tokens: {} }\n const modes = { light: { tokens: {} } as typeof common, dark: { tokens: {} } as typeof common }\n for (const sectionName of sectionNames) {\n const section = sections[sectionName]\n if (!section) continue\n for (const mode of ['common', 'light', 'dark'] as const) {\n const values = mode === 'common' ? section.values : section.modes?.[mode]\n if (values === undefined) continue\n const layer = mode === 'common' ? common : modes[mode]\n if (sectionName === 'components') layer.components = values as ThemeLayer['components']\n else layer.tokens[sectionName] = values\n }\n }\n return { id, name, ...common, modes }\n}\n\n/** Read JSON.parse output (or data objects); unknown versions/keys fail with a path. */\nexport function parseThemeDocument(input: unknown): ThemeDocument | ThemeSectionExport {\n const value = jsonCopy(input, 'document')\n record(value, 'document')\n choice(value.kind, ['radiant-theme', 'radiant-theme-sections'], 'document.kind')\n if (value.version !== 1)\n throw new TypeError(\n `Unsupported document.version: ${String(value.version)}. Expected 1; migrate the configuration before importing.`\n )\n const full = value.kind === 'radiant-theme'\n keys(\n value,\n full ? ['kind', 'version', 'id', 'name', 'sections'] : ['kind', 'version', 'sections'],\n 'document'\n )\n record(value.sections, 'document.sections')\n keys(value.sections, sectionNames, 'document.sections')\n for (const [name, section] of Object.entries(value.sections)) {\n const path = `document.sections.${name}`\n record(section, path)\n keys(\n section,\n [\n 'values',\n 'modes',\n ...(name === 'color'\n ? ['brand', 'fidelity', 'palettes', 'anchor']\n : name === 'typography'\n ? ['fonts']\n : [])\n ],\n path\n )\n if (section.modes !== undefined) {\n record(section.modes, `${path}.modes`)\n keys(section.modes, ['light', 'dark'], `${path}.modes`)\n }\n if (name === 'color') validateColor(section, path)\n if (name === 'typography' && section.fonts !== undefined)\n validateFonts(section.fonts, `${path}.fonts`)\n }\n // Reuse the canonical token/component validation and resolution; no second token schema.\n defineTheme(\n toDefinition(\n value.sections as ThemeSections,\n full ? (value.id as string) : 'section-export',\n full ? (value.name as string) : 'Section export'\n )\n )\n return freezeTree(jsonCopy(value, 'document') as object) as ThemeDocument | ThemeSectionExport\n}\n\n/** Validate and detach an immutable, portable authoring snapshot. */\nexport function defineThemeDocument(document: ThemeDocument): ThemeDocument {\n const result = parseThemeDocument(document)\n if (result.kind !== 'radiant-theme')\n throw new TypeError('Expected a radiant-theme document with id and name.')\n return result\n}\n\n/** Compile only authored semantic values through the existing application theme runtime. */\nexport function compileThemeDocument(document: ThemeDocument): Theme {\n const validated = defineThemeDocument(document)\n return defineTheme(toDefinition(validated.sections, validated.id, validated.name))\n}\n\nfunction merge(base: unknown, patch: unknown): unknown {\n if (\n !base ||\n !patch ||\n typeof base !== 'object' ||\n typeof patch !== 'object' ||\n Array.isArray(base) ||\n Array.isArray(patch)\n )\n return patch\n const result: RecordValue = { ...base }\n for (const [key, value] of Object.entries(patch)) result[key] = merge(result[key], value)\n return result\n}\n\n/** Merge leaves/replace arrays, or replace only supplied sections. Empty replacement resets. */\nexport function updateThemeDocument(\n document: ThemeDocument,\n sections: ThemeSections,\n mode: 'merge' | 'replace' = 'merge'\n): ThemeDocument {\n const base = defineThemeDocument(document)\n choice(mode, ['merge', 'replace'], 'update mode')\n // Check the patch's JSON boundary before merging, including keys a spread would discard.\n const patch = jsonCopy(sections, 'sections')\n record(patch, 'sections')\n keys(patch, sectionNames, 'sections')\n const next = { ...base.sections } as RecordValue\n for (const [name, section] of Object.entries(patch))\n next[name] = mode === 'replace' ? section : merge(next[name], section)\n return defineThemeDocument({ ...base, sections: next })\n}\n\n/** Export exactly these sections, with no document identity or implicit component exceptions. */\nexport function exportThemeSections(\n document: ThemeDocument,\n names: readonly ThemeSectionName[]\n): ThemeSectionExport {\n const base = defineThemeDocument(document)\n list(names, 'section names')\n const sections: RecordValue = {}\n for (const name of names) {\n choice(name, sectionNames, 'section name')\n if (base.sections[name] !== undefined) sections[name] = base.sections[name]\n }\n return parseThemeDocument({\n kind: 'radiant-theme-sections',\n version: 1,\n sections\n }) as ThemeSectionExport\n}\n\n/** Bring existing authored themes into the workshop without materialising defaults as overrides. */\nexport function themeDocumentFromDefinition(definition: ThemeDefinition): ThemeDocument {\n const copy = jsonCopy(definition, 'theme') as ThemeDefinition\n defineTheme(copy)\n const sections: RecordValue = {}\n for (const name of sectionNames) {\n const section: RecordValue = {}\n const values = name === 'components' ? copy.components : copy.tokens?.[name]\n if (values !== undefined) section.values = values\n const modes: RecordValue = {}\n for (const mode of ['light', 'dark'] as const) {\n const values =\n name === 'components' ? copy.modes?.[mode]?.components : copy.modes?.[mode]?.tokens?.[name]\n if (values !== undefined) modes[mode] = values\n }\n if (Object.keys(modes).length) section.modes = modes\n if (Object.keys(section).length) sections[name] = section\n }\n return defineThemeDocument({\n kind: 'radiant-theme',\n version: 1,\n id: copy.id,\n name: copy.name,\n sections\n })\n}\n"]}
1
+ {"version":3,"file":"themeDocument.js","sourceRoot":"","sources":["../../../src/themes/themeDocument.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAqD,MAAM,kBAAkB,CAAA;AACjG,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAW3D,MAAM,YAAY,GAAgC;IAChD,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;IACnC,YAAY;CACS,CAAA;AACvB,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAA;AAG7E,SAAS,MAAM,CAAC,KAAc,EAAE,IAAY;IAC1C,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAChE,MAAM,IAAI,SAAS,CAAC,GAAG,IAAI,qBAAqB,CAAC,CAAA;IACnD,CAAC;AACH,CAAC;AAED,SAAS,IAAI,CAAC,KAAkB,EAAE,OAA0B,EAAE,IAAY;IACxE,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAA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EAAE,MAAM,EAAE,CAAC,IAAI,CAAC,CAAA;YAC7F,IAAI,MAAM,KAAK,SAAS;gBAAE,KAAK,CAAC,IAAI,CAAC,GAAG,MAAM,CAAA;QAChD,CAAC;QACD,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM;YAAE,OAAO,CAAC,KAAK,GAAG,KAAK,CAAA;QACpD,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM;YAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,OAAO,CAAA;IAC3D,CAAC;IACD,OAAO,mBAAmB,CAAC;QACzB,IAAI,EAAE,eAAe;QACrB,OAAO,EAAE,CAAC;QACV,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,QAAQ;KACT,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { defineTheme, type Theme, type ThemeDefinition, type ThemeLayer } from './defineTheme.js'\nimport { freezeTree, tokenDefaults } from './tokens.js'\nimport { generateTypography } from '../typography/index.js'\nimport type {\n ThemeColorSection,\n ThemeDocument,\n ThemeSectionExport,\n ThemeSectionName,\n ThemeSections\n} from './themeDocumentTypes.js'\n\nexport type * from './themeDocumentTypes.js'\n\nconst sectionNames: readonly ThemeSectionName[] = [\n ...Object.keys(tokenDefaults.light),\n 'components'\n] as ThemeSectionName[]\nconst stops = new Set([50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950])\ntype RecordValue = Record<string, unknown>\n\nfunction record(value: unknown, path: string): asserts value is RecordValue {\n if (!value || typeof value !== 'object' || Array.isArray(value)) {\n throw new TypeError(`${path} must be an object.`)\n }\n}\n\nfunction keys(value: RecordValue, allowed: readonly string[], path: string) {\n for (const key of Object.keys(value)) {\n if (!allowed.includes(key)) throw new TypeError(`Unknown key: ${path}.${key}.`)\n }\n}\n\nfunction textValue(value: unknown, path: string) {\n if (typeof value !== 'string' || !value.trim()) {\n throw new TypeError(`${path} must be a nonempty string.`)\n }\n}\n\nfunction choice(value: unknown, allowed: readonly unknown[], path: string) {\n if (!allowed.includes(value)) {\n throw new TypeError(`${path} must be one of: ${allowed.join(', ')}.`)\n }\n}\n\nfunction list(value: unknown, path: string): asserts value is unknown[] {\n if (!Array.isArray(value)) throw new TypeError(`${path} must be an array.`)\n}\n\nfunction unique(value: unknown, seen: Set<unknown>, path: string) {\n if (seen.has(value)) throw new TypeError(`Duplicate value at ${path}: ${String(value)}.`)\n seen.add(value)\n}\n\n/** Copy data without running getters/toJSON or silently losing functions and binaries. */\nfunction jsonCopy(value: unknown, path: string, ancestors = new Set<object>()): unknown {\n if (value === null || typeof value === 'string' || typeof value === 'boolean') return value\n if (typeof value === 'number' && Number.isFinite(value)) return value === 0 ? 0 : value\n if (!value || typeof value !== 'object')\n throw new TypeError(`${path} must contain JSON data only.`)\n if (ancestors.has(value)) throw new TypeError(`Circular reference at ${path}.`)\n const array = Array.isArray(value)\n const prototype = Object.getPrototypeOf(value)\n if (\n array ? prototype !== Array.prototype : prototype !== Object.prototype && prototype !== null\n ) {\n throw new TypeError(`${path} must contain plain JSON objects, not class instances or binaries.`)\n }\n ancestors.add(value)\n const result: RecordValue | unknown[] = array ? [] : {}\n if (Object.getOwnPropertySymbols(value).length)\n throw new TypeError(`${path} cannot contain symbol keys.`)\n const descriptors = Object.getOwnPropertyDescriptors(value)\n for (const key of Object.keys(descriptors).sort()) {\n if (array && key === 'length') continue\n if (['__proto__', 'constructor', 'prototype'].includes(key))\n throw new TypeError(`Forbidden key: ${path}.${key}.`)\n const descriptor = descriptors[key]\n if (!('value' in descriptor) || !descriptor.enumerable) {\n throw new TypeError(`${path}.${key} must be an enumerable data property.`)\n }\n if (array && (!/^(0|[1-9][0-9]*)$/.test(key) || Number(key) >= value.length)) {\n throw new TypeError(`${path}.${key} is not an array index.`)\n }\n // Optional object properties follow JSON omission rules; array holes/undefined are invalid.\n if (descriptor.value === undefined && !array) continue\n const copy = jsonCopy(descriptor.value, `${path}.${key}`, ancestors)\n Object.defineProperty(result, key, {\n value: copy,\n enumerable: true,\n writable: true,\n configurable: true\n })\n }\n if (array && Object.keys(result).length !== value.length)\n throw new TypeError(`${path} cannot contain array holes.`)\n ancestors.delete(value)\n return result\n}\n\nfunction validateColor(value: RecordValue, path: string) {\n if (value.brand !== undefined) {\n record(value.brand, `${path}.brand`)\n keys(value.brand, ['value', 'gamut', 'srgbFallback'], `${path}.brand`)\n textValue(value.brand.value, `${path}.brand.value`)\n choice(value.brand.gamut, ['srgb', 'display-p3'], `${path}.brand.gamut`)\n if (value.brand.srgbFallback !== undefined)\n textValue(value.brand.srgbFallback, `${path}.brand.srgbFallback`)\n if (value.fidelity === undefined) value.fidelity = 'anchored'\n }\n if (value.fidelity !== undefined)\n choice(value.fidelity, ['anchored', 'unanchored'], `${path}.fidelity`)\n if (value.palettes !== undefined) {\n list(value.palettes, `${path}.palettes`)\n const ids = new Set<unknown>()\n for (const [i, palette] of value.palettes.entries()) {\n const p = `${path}.palettes.${i}`\n record(palette, p)\n keys(palette, ['id', 'name', 'swatches'], p)\n textValue(palette.id, `${p}.id`)\n textValue(palette.name, `${p}.name`)\n unique(palette.id, ids, `${p}.id`)\n list(palette.swatches, `${p}.swatches`)\n if (!palette.swatches.length) throw new TypeError(`${p}.swatches must not be empty.`)\n const seen = new Set<unknown>()\n for (const [j, swatch] of palette.swatches.entries()) {\n const s = `${p}.swatches.${j}`\n record(swatch, s)\n keys(swatch, ['stop', 'value', 'srgbFallback'], s)\n if (!stops.has(swatch.stop as number))\n throw new TypeError(`${s}.stop must be a numbered color stop (50–950).`)\n unique(swatch.stop, seen, `${s}.stop`)\n textValue(swatch.value, `${s}.value`)\n if (swatch.srgbFallback !== undefined) textValue(swatch.srgbFallback, `${s}.srgbFallback`)\n }\n }\n }\n if (value.anchor !== undefined) {\n record(value.anchor, `${path}.anchor`)\n keys(value.anchor, ['paletteId', 'stop'], `${path}.anchor`)\n textValue(value.anchor.paletteId, `${path}.anchor.paletteId`)\n if (!stops.has(value.anchor.stop as number))\n throw new TypeError(`${path}.anchor.stop must be a numbered color stop (50–950).`)\n const color = value as ThemeColorSection\n const swatch = color.palettes\n ?.find(p => p.id === color.anchor!.paletteId)\n ?.swatches.find(s => s.stop === color.anchor!.stop)\n if (!color.brand || color.fidelity !== 'anchored' || swatch?.value !== color.brand.value) {\n throw new TypeError(\n `${path}.anchor must reference a swatch containing the exact brand.value with anchored fidelity. Regenerate or replace the color section.`\n )\n }\n }\n}\n\nfunction validateFonts(value: unknown, path: string) {\n list(value, path)\n const ids = new Set<unknown>()\n for (const [i, font] of value.entries()) {\n const p = `${path}.${i}`\n record(font, p)\n keys(font, ['id', 'family', 'source', 'weights', 'styles', 'axes'], p)\n textValue(font.id, `${p}.id`)\n textValue(font.family, `${p}.family`)\n unique(font.id, ids, `${p}.id`)\n choice(font.source, ['system', 'catalog', 'local'], `${p}.source`)\n if (font.axes !== undefined) {\n list(font.axes, `${p}.axes`)\n if (font.axes.length > 32) throw new TypeError(`${p}.axes supports at most 32 axes.`)\n const tags = new Set<unknown>()\n for (const [j, axis] of font.axes.entries()) {\n const at = `${p}.axes.${j}`\n record(axis, at)\n keys(axis, ['tag', 'min', 'default', 'max'], at)\n if (typeof axis.tag !== 'string' || !/^[A-Za-z][A-Za-z0-9]{3}$/.test(axis.tag))\n throw new TypeError(\n `${at}.tag must contain four ASCII letters/digits, starting with a letter.`\n )\n unique(axis.tag, tags, `${at}.tag`)\n for (const key of ['min', 'default', 'max'])\n if (\n typeof axis[key] !== 'number' ||\n !Number.isFinite(axis[key]) ||\n Math.abs(axis[key]) > 1000000\n )\n throw new TypeError(\n `${at}.${key} must be a finite number between -1000000 and 1000000.`\n )\n if (Number(axis.min) > Number(axis.default) || Number(axis.default) > Number(axis.max))\n throw new TypeError(`${at} must satisfy min <= default <= max.`)\n }\n }\n for (const key of ['weights', 'styles']) {\n if (font[key] === undefined) continue\n list(font[key], `${p}.${key}`)\n const seen = new Set<unknown>()\n for (const [j, item] of font[key].entries()) {\n const at = `${p}.${key}.${j}`\n if (key === 'styles') choice(item, ['normal', 'italic'], at)\n else if (typeof item !== 'number' || !Number.isFinite(item) || item < 1 || item > 1000)\n throw new TypeError(`${at} must be a weight from 1 to 1000.`)\n unique(item, seen, at)\n }\n }\n }\n}\n\nfunction toDefinition(sections: ThemeSections, id: string, name: string): ThemeDefinition {\n const common: { tokens: RecordValue; components?: ThemeLayer['components'] } = { tokens: {} }\n const modes = { light: { tokens: {} } as typeof common, dark: { tokens: {} } as typeof common }\n for (const sectionName of sectionNames) {\n const section = sections[sectionName]\n if (!section) continue\n if (sectionName === 'typography' && sections.typography?.typesetting !== undefined) {\n common.tokens.typography = generateTypography(sections.typography.typesetting).tokens\n }\n for (const mode of ['common', 'light', 'dark'] as const) {\n const values = mode === 'common' ? section.values : section.modes?.[mode]\n if (values === undefined) continue\n const layer = mode === 'common' ? common : modes[mode]\n if (sectionName === 'components') layer.components = values as ThemeLayer['components']\n else layer.tokens[sectionName] = merge(layer.tokens[sectionName], values)\n }\n }\n return { id, name, ...common, modes }\n}\n\n/** Read JSON.parse output (or data objects); unknown versions/keys fail with a path. */\nexport function parseThemeDocument(input: unknown): ThemeDocument | ThemeSectionExport {\n const value = jsonCopy(input, 'document')\n record(value, 'document')\n choice(value.kind, ['radiant-theme', 'radiant-theme-sections'], 'document.kind')\n if (value.version !== 1)\n throw new TypeError(\n `Unsupported document.version: ${String(value.version)}. Expected 1; migrate the configuration before importing.`\n )\n const full = value.kind === 'radiant-theme'\n keys(\n value,\n full ? ['kind', 'version', 'id', 'name', 'sections'] : ['kind', 'version', 'sections'],\n 'document'\n )\n record(value.sections, 'document.sections')\n keys(value.sections, sectionNames, 'document.sections')\n for (const [name, section] of Object.entries(value.sections)) {\n const path = `document.sections.${name}`\n record(section, path)\n keys(\n section,\n [\n 'values',\n 'modes',\n ...(name === 'color'\n ? ['brand', 'fidelity', 'palettes', 'anchor']\n : name === 'typography'\n ? ['fonts', 'typesetting']\n : [])\n ],\n path\n )\n if (section.modes !== undefined) {\n record(section.modes, `${path}.modes`)\n keys(section.modes, ['light', 'dark'], `${path}.modes`)\n }\n if (name === 'color') validateColor(section, path)\n if (name === 'typography' && section.fonts !== undefined)\n validateFonts(section.fonts, `${path}.fonts`)\n }\n // Reuse the canonical token/component validation and resolution; no second token schema.\n defineTheme(\n toDefinition(\n value.sections as ThemeSections,\n full ? (value.id as string) : 'section-export',\n full ? (value.name as string) : 'Section export'\n )\n )\n return freezeTree(jsonCopy(value, 'document') as object) as ThemeDocument | ThemeSectionExport\n}\n\n/** Validate and detach an immutable, portable authoring snapshot. */\nexport function defineThemeDocument(document: ThemeDocument): ThemeDocument {\n const result = parseThemeDocument(document)\n if (result.kind !== 'radiant-theme')\n throw new TypeError('Expected a radiant-theme document with id and name.')\n return result\n}\n\n/** Compile only authored semantic values through the existing application theme runtime. */\nexport function compileThemeDocument(document: ThemeDocument): Theme {\n const validated = defineThemeDocument(document)\n return defineTheme(toDefinition(validated.sections, validated.id, validated.name))\n}\n\nfunction merge(base: unknown, patch: unknown): unknown {\n if (\n !base ||\n !patch ||\n typeof base !== 'object' ||\n typeof patch !== 'object' ||\n Array.isArray(base) ||\n Array.isArray(patch)\n )\n return patch\n const result: RecordValue = { ...base }\n for (const [key, value] of Object.entries(patch)) result[key] = merge(result[key], value)\n return result\n}\n\n/** Merge leaves/replace arrays, or replace only supplied sections. Empty replacement resets. */\nexport function updateThemeDocument(\n document: ThemeDocument,\n sections: ThemeSections,\n mode: 'merge' | 'replace' = 'merge'\n): ThemeDocument {\n const base = defineThemeDocument(document)\n choice(mode, ['merge', 'replace'], 'update mode')\n // Check the patch's JSON boundary before merging, including keys a spread would discard.\n const patch = jsonCopy(sections, 'sections')\n record(patch, 'sections')\n keys(patch, sectionNames, 'sections')\n const next = { ...base.sections } as RecordValue\n for (const [name, section] of Object.entries(patch))\n next[name] = mode === 'replace' ? section : merge(next[name], section)\n return defineThemeDocument({ ...base, sections: next })\n}\n\n/** Export exactly these sections, with no document identity or implicit component exceptions. */\nexport function exportThemeSections(\n document: ThemeDocument,\n names: readonly ThemeSectionName[]\n): ThemeSectionExport {\n const base = defineThemeDocument(document)\n list(names, 'section names')\n const sections: RecordValue = {}\n for (const name of names) {\n choice(name, sectionNames, 'section name')\n if (base.sections[name] !== undefined) sections[name] = base.sections[name]\n }\n return parseThemeDocument({\n kind: 'radiant-theme-sections',\n version: 1,\n sections\n }) as ThemeSectionExport\n}\n\n/** Bring existing authored themes into the workshop without materialising defaults as overrides. */\nexport function themeDocumentFromDefinition(definition: ThemeDefinition): ThemeDocument {\n const copy = jsonCopy(definition, 'theme') as ThemeDefinition\n defineTheme(copy)\n const sections: RecordValue = {}\n for (const name of sectionNames) {\n const section: RecordValue = {}\n const values = name === 'components' ? copy.components : copy.tokens?.[name]\n if (values !== undefined) section.values = values\n const modes: RecordValue = {}\n for (const mode of ['light', 'dark'] as const) {\n const values =\n name === 'components' ? copy.modes?.[mode]?.components : copy.modes?.[mode]?.tokens?.[name]\n if (values !== undefined) modes[mode] = values\n }\n if (Object.keys(modes).length) section.modes = modes\n if (Object.keys(section).length) sections[name] = section\n }\n return defineThemeDocument({\n kind: 'radiant-theme',\n version: 1,\n id: copy.id,\n name: copy.name,\n sections\n })\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  import type { ThemeComponentOverrides } from './components.js';
2
2
  import type { ThemeTokens } from './tokens.js';
3
+ import type { TypographyInput } from '../typography/types.js';
3
4
  /** One existing token group, with independently authored mode layers. */
4
5
  export interface ThemeSection<T> {
5
6
  readonly values?: T;
@@ -35,6 +36,13 @@ export interface ThemeColorSection extends ThemeSection<ThemeTokens['color']> {
35
36
  readonly stop: ThemeColorStop;
36
37
  };
37
38
  }
39
+ /** Available OpenType axis range, never a font file or a trial-only setting. */
40
+ export interface ThemeFontAxis {
41
+ readonly tag: string;
42
+ readonly min: number;
43
+ readonly default: number;
44
+ readonly max: number;
45
+ }
38
46
  /** Portable descriptors only. The consuming application owns loading and local availability. */
39
47
  export interface ThemeFontMetadata {
40
48
  readonly id: string;
@@ -42,9 +50,12 @@ export interface ThemeFontMetadata {
42
50
  readonly source: 'system' | 'catalog' | 'local';
43
51
  readonly weights?: readonly number[];
44
52
  readonly styles?: readonly ('normal' | 'italic')[];
53
+ readonly axes?: readonly ThemeFontAxis[];
45
54
  }
46
55
  export interface ThemeTypographySection extends ThemeSection<ThemeTokens['typography']> {
47
56
  readonly fonts?: readonly ThemeFontMetadata[];
57
+ /** Generated defaults; explicit values and mode values override these leaves. */
58
+ readonly typesetting?: TypographyInput;
48
59
  }
49
60
  /** Token groups are the extension seams for richer typesetting and spring authoring. */
50
61
  export type ThemeSections = {
@@ -1 +1 @@
1
- {"version":3,"file":"themeDocumentTypes.d.ts","sourceRoot":"","sources":["../../../src/themes/themeDocumentTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAA;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAE9C,yEAAyE;AACzE,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IACnB,QAAQ,CAAC,KAAK,CAAC,EAAE;QAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;KAAE,CAAA;CAC3D;AAED,MAAM,MAAM,cAAc,GAAG,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;AAE3F,MAAM,WAAW,gBAAgB;IAC/B,2EAA2E;IAC3E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAAA;IACrC,QAAQ,CAAC,YAAY,CAAC,EAAE,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C,IAAI,EAAE,eAAe,CAAA;IAC9B,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAA;IACnB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAA;CACjC;AAED,6FAA6F;AAC7F,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,wBAAwB,CAAA;IACvC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAA;IACnB,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAA;CACjC"}
@@ -1 +1 @@
1
- {"version":3,"file":"themeDocumentTypes.js","sourceRoot":"","sources":["../../../src/themes/themeDocumentTypes.ts"],"names":[],"mappings":"","sourcesContent":["import type { ThemeComponentOverrides } from './components.js'\nimport type { ThemeTokens } from './tokens.js'\n\n/** One existing token group, with independently authored mode layers. */\nexport interface ThemeSection<T> {\n readonly values?: T\n readonly modes?: { readonly light?: T; readonly dark?: T }\n}\n\nexport type ThemeColorStop = 50 | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 950\n\nexport interface ThemeBrandSource {\n /** Unmodified source text. A mapped fallback never replaces this value. */\n readonly value: string\n readonly gamut: 'srgb' | 'display-p3'\n readonly srgbFallback?: string\n}\n\nexport interface ThemePalette {\n readonly id: string\n readonly name: string\n readonly swatches: readonly {\n readonly stop: ThemeColorStop\n readonly value: string\n readonly srgbFallback?: string\n }[]\n}\n\nexport interface ThemeColorSection extends ThemeSection<ThemeTokens['color']> {\n readonly brand?: ThemeBrandSource\n /** Defaults to anchored when a brand is present. Generation belongs to the color engine. */\n readonly fidelity?: 'anchored' | 'unanchored'\n readonly palettes?: readonly ThemePalette[]\n /** Optional until generation; references the exact original, never its fallback. */\n readonly anchor?: { readonly paletteId: string; readonly stop: ThemeColorStop }\n}\n\n/** Portable descriptors only. The consuming application owns loading and local availability. */\nexport interface ThemeFontMetadata {\n readonly id: string\n readonly family: string\n readonly source: 'system' | 'catalog' | 'local'\n readonly weights?: readonly number[]\n readonly styles?: readonly ('normal' | 'italic')[]\n}\n\nexport interface ThemeTypographySection extends ThemeSection<ThemeTokens['typography']> {\n readonly fonts?: readonly ThemeFontMetadata[]\n}\n\n/** Token groups are the extension seams for richer typesetting and spring authoring. */\nexport type ThemeSections = {\n readonly [K in keyof ThemeTokens]?: K extends 'color'\n ? ThemeColorSection\n : K extends 'typography'\n ? ThemeTypographySection\n : ThemeSection<ThemeTokens[K]>\n} & {\n readonly components?: ThemeSection<ThemeComponentOverrides>\n}\nexport type ThemeSectionName = keyof ThemeSections\n\nexport interface ThemeDocument {\n readonly kind: 'radiant-theme'\n readonly version: 1\n readonly id: string\n readonly name: string\n readonly sections: ThemeSections\n}\n\n/** A selective export has no identity and cannot accidentally replace an entire document. */\nexport interface ThemeSectionExport {\n readonly kind: 'radiant-theme-sections'\n readonly version: 1\n readonly sections: ThemeSections\n}\n"]}
1
+ {"version":3,"file":"themeDocumentTypes.js","sourceRoot":"","sources":["../../../src/themes/themeDocumentTypes.ts"],"names":[],"mappings":"","sourcesContent":["import type { ThemeComponentOverrides } from './components.js'\nimport type { ThemeTokens } from './tokens.js'\nimport type { TypographyInput } from '../typography/types.js'\n\n/** One existing token group, with independently authored mode layers. */\nexport interface ThemeSection<T> {\n readonly values?: T\n readonly modes?: { readonly light?: T; readonly dark?: T }\n}\n\nexport type ThemeColorStop = 50 | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 950\n\nexport interface ThemeBrandSource {\n /** Unmodified source text. A mapped fallback never replaces this value. */\n readonly value: string\n readonly gamut: 'srgb' | 'display-p3'\n readonly srgbFallback?: string\n}\n\nexport interface ThemePalette {\n readonly id: string\n readonly name: string\n readonly swatches: readonly {\n readonly stop: ThemeColorStop\n readonly value: string\n readonly srgbFallback?: string\n }[]\n}\n\nexport interface ThemeColorSection extends ThemeSection<ThemeTokens['color']> {\n readonly brand?: ThemeBrandSource\n /** Defaults to anchored when a brand is present. Generation belongs to the color engine. */\n readonly fidelity?: 'anchored' | 'unanchored'\n readonly palettes?: readonly ThemePalette[]\n /** Optional until generation; references the exact original, never its fallback. */\n readonly anchor?: { readonly paletteId: string; readonly stop: ThemeColorStop }\n}\n\n/** Available OpenType axis range, never a font file or a trial-only setting. */\nexport interface ThemeFontAxis {\n readonly tag: string\n readonly min: number\n readonly default: number\n readonly max: number\n}\n\n/** Portable descriptors only. The consuming application owns loading and local availability. */\nexport interface ThemeFontMetadata {\n readonly id: string\n readonly family: string\n readonly source: 'system' | 'catalog' | 'local'\n readonly weights?: readonly number[]\n readonly styles?: readonly ('normal' | 'italic')[]\n readonly axes?: readonly ThemeFontAxis[]\n}\n\nexport interface ThemeTypographySection extends ThemeSection<ThemeTokens['typography']> {\n readonly fonts?: readonly ThemeFontMetadata[]\n /** Generated defaults; explicit values and mode values override these leaves. */\n readonly typesetting?: TypographyInput\n}\n\n/** Token groups are the extension seams for richer typesetting and spring authoring. */\nexport type ThemeSections = {\n readonly [K in keyof ThemeTokens]?: K extends 'color'\n ? ThemeColorSection\n : K extends 'typography'\n ? ThemeTypographySection\n : ThemeSection<ThemeTokens[K]>\n} & {\n readonly components?: ThemeSection<ThemeComponentOverrides>\n}\nexport type ThemeSectionName = keyof ThemeSections\n\nexport interface ThemeDocument {\n readonly kind: 'radiant-theme'\n readonly version: 1\n readonly id: string\n readonly name: string\n readonly sections: ThemeSections\n}\n\n/** A selective export has no identity and cannot accidentally replace an entire document. */\nexport interface ThemeSectionExport {\n readonly kind: 'radiant-theme-sections'\n readonly version: 1\n readonly sections: ThemeSections\n}\n"]}
@@ -1,3 +1,8 @@
1
+ import type { TypographyProseRhythm, TypographyUIRhythm, TypographyStyle, TypographyRole, TypographyTokens, TypographyAssignment } from '../typography/types.js';
2
+ /** Canonical calculations live beside the defaults so source CSS generation stays self-contained. */
3
+ export declare function typographyStyles(prose: TypographyProseRhythm, ui: TypographyUIRhythm): Record<TypographyRole, TypographyStyle>;
4
+ export declare const typographyRoles: readonly TypographyRole[];
5
+ export declare function typographyTokens(styles: Readonly<Record<TypographyRole, TypographyStyle>>, families: Readonly<Record<TypographyAssignment, string>>, flow: number): TypographyTokens;
1
6
  /** The complete shared-token registry. CSS names are derived from these paths. */
2
7
  export interface SharedTokens {
3
8
  color: {
@@ -28,6 +33,8 @@ export interface SharedTokens {
28
33
  labelWeight: string | number;
29
34
  headingWeight: string | number;
30
35
  letterSpacing: string;
36
+ roles: TypographyTokens['roles'];
37
+ flow: TypographyTokens['flow'];
31
38
  };
32
39
  control: {
33
40
  small: ControlMetrics;
@@ -1 +1 @@
1
- {"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../../src/themes/tokens.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE;QACL,OAAO,EAAE,MAAM,CAAA;QACf,UAAU,EAAE,MAAM,CAAA;QAClB,eAAe,EAAE,MAAM,CAAA;QACvB,MAAM,EAAE,MAAM,CAAA;QACd,WAAW,EAAE,MAAM,CAAA;QACnB,kBAAkB,EAAE,MAAM,CAAA;QAC1B,cAAc,EAAE,MAAM,CAAA;QACtB,OAAO,EAAE,MAAM,CAAA;QACf,KAAK,EAAE,MAAM,CAAA;QACb,MAAM,EAAE,MAAM,CAAA;QACd,gBAAgB,EAAE,MAAM,CAAA;QACxB,OAAO,EAAE,MAAM,CAAA;QACf,iBAAiB,EAAE,MAAM,CAAA;QACzB,OAAO,EAAE,MAAM,CAAA;QACf,iBAAiB,EAAE,MAAM,CAAA;QACzB,MAAM,EAAE,MAAM,CAAA;QACd,gBAAgB,EAAE,MAAM,CAAA;KACzB,CAAA;IACD,UAAU,EAAE;QACV,MAAM,EAAE,MAAM,CAAA;QACd,QAAQ,EAAE,MAAM,CAAA;QAChB,SAAS,EAAE,MAAM,CAAA;QACjB,WAAW,EAAE,MAAM,CAAA;QACnB,UAAU,EAAE,MAAM,GAAG,MAAM,C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AE,MAAM,CAAA;KAClB,CAAA;IACD,KAAK,EAAE;QAAE,eAAe,EAAE,MAAM,CAAA;KAAE,CAAA;CACnC;AAED,UAAU,cAAc;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,aAAa,EAAE,MAAM,CAAA;IACrB,QAAQ,EAAE,MAAM,CAAA;IAChB,aAAa,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IAC3B,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACzE,CAAA;AACD,MAAM,MAAM,WAAW,GAAG,WAAW,CAAC,YAAY,CAAC,CAAA;AACnD,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,SAAS,MAAM,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC,CAAA;AAsH5E,2FAA2F;AAC3F,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAKlE;AAkCD,eAAO,MAAM,aAAa;;;EAA8B,CAAA;AAExD,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE/C;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,WAAW,GAAG,mBAAmB,CAYtE;AAiBD,eAAO,MAAM,cAAc,6CAA8C,CAAA;AAEzE,+FAA+F;AAC/F,wBAAgB,SAAS,CACvB,KAAK,EAAE,QAAQ,CAAC,mBAAmB,CAAC,EACpC,IAAI,EAAE,QAAQ,CAAC,mBAAmB,CAAC,GAClC,mBAAmB,CAarB"}
@@ -1,3 +1,74 @@
1
+ /** Canonical calculations live beside the defaults so source CSS generation stays self-contained. */
2
+ export function typographyStyles(prose, ui) {
3
+ const { size: r, lineHeight, measure, headingScale: q } = prose;
4
+ const u = ui.size;
5
+ const style = (assignment, narrow, wide, weight, leading, tracking = 0, width = 0) => ({
6
+ assignment,
7
+ narrow,
8
+ wide,
9
+ weight,
10
+ lineHeight: leading,
11
+ tracking,
12
+ measure: width
13
+ });
14
+ return {
15
+ 'prose-title': style('headings', r * q ** 3, r * q ** 5, 600, 1.12, -0.025, 22),
16
+ 'prose-heading': style('headings', r * q, r * q ** 2, 600, 1.25, -0.015, 30),
17
+ 'prose-subheading': style('headings', r * 1.1, r * q, 600, 1.3, -0.01, 36),
18
+ 'prose-body': style('body', r, r, 400, lineHeight, 0, measure),
19
+ 'prose-lead': style('body', r * 1.125, r * 1.125, 400, 1.5, 0, 55),
20
+ 'prose-small': style('body', r * 0.8, r * 0.8, 400, 1.5, 0, measure),
21
+ 'prose-quote': style('body', r * 1.25, r * 1.25, 400, 1.4, -0.01, measure),
22
+ 'ui-title': style('ui', u * 1.25, u * 1.25, 600, 1.3, -0.015),
23
+ 'ui-body': style('ui', u, u, 400, ui.lineHeight),
24
+ 'ui-label': style('ui', u, u, 500, 1.4),
25
+ 'ui-supporting': style('ui', u * 0.9375, u * 0.9375, 400, 1.5),
26
+ 'ui-caption': style('ui', u * 0.875, u * 0.875, 400, 1.5),
27
+ 'ui-metric': style('ui', u * 2, u * 2, 600, 1.15, -0.03),
28
+ 'ui-eyebrow': style('ui', u * 0.75, u * 0.75, 600, 1.4, 0.1),
29
+ display: style('headings', r * q ** 3, r * q ** 6, 600, 1.06, -0.035, 18),
30
+ code: style('code', 14, 14, 400, 1.65, 0, 80)
31
+ };
32
+ }
33
+ const baselineProse = {
34
+ size: 20,
35
+ lineHeight: 1.6,
36
+ paragraphSpacing: 1.25,
37
+ measure: 64,
38
+ headingScale: 1.25
39
+ };
40
+ export const typographyRoles = Object.freeze(Object.keys(typographyStyles(baselineProse, { size: 16, lineHeight: 1.5 })));
41
+ function decimal(value) {
42
+ return String(Number(value.toFixed(8)));
43
+ }
44
+ export function typographyTokens(styles, families, flow) {
45
+ const roles = {};
46
+ for (const role of typographyRoles) {
47
+ const s = styles[role];
48
+ const slope = (s.wide - s.narrow) / 512;
49
+ const intercept = s.narrow / 16 - slope * 24;
50
+ const size = `${decimal(s.narrow / 16)}rem`;
51
+ roles[role] = {
52
+ family: families[s.assignment],
53
+ size,
54
+ fluidSize: s.narrow === s.wide
55
+ ? size
56
+ : `clamp(${size}, calc(${decimal(intercept)}rem + ${decimal(slope * 100)}cqi), ${decimal(s.wide / 16)}rem)`,
57
+ weight: s.weight,
58
+ lineHeight: decimal(s.lineHeight),
59
+ letterSpacing: `${decimal(s.tracking)}em`,
60
+ measure: s.measure ? `${decimal(s.measure)}ch` : 'none'
61
+ };
62
+ }
63
+ return {
64
+ roles,
65
+ flow: {
66
+ paragraph: `${decimal(flow)}em`,
67
+ headingBefore: `${decimal(flow * 1.6)}em`,
68
+ headingAfter: `${decimal(flow * 0.5)}em`
69
+ }
70
+ };
71
+ }
1
72
  const light = {
2
73
  color: {
3
74
  surface: 'oklch(1 0 0)',
@@ -19,6 +90,7 @@ const light = {
19
90
  dangerForeground: 'oklch(0.99 0 0)'
20
91
  },
21
92
  typography: {
93
+ ...baselineTypographyTokens(),
22
94
  family: 'system-ui, sans-serif',
23
95
  bodySize: '0.875rem',
24
96
  smallSize: '0.8125rem',
@@ -119,6 +191,33 @@ export function freezeTree(value) {
119
191
  }
120
192
  return Object.freeze(value);
121
193
  }
194
+ // Legacy/preset leaves remain a bridge until a recipe or explicit role owns them.
195
+ // UI measures stay layout-owned; controls retain their independent size metrics.
196
+ function baselineTypographyTokens() {
197
+ const tokens = typographyTokens(typographyStyles(baselineProse, { size: 16, lineHeight: 1.5 }), {
198
+ body: 'var(--rad-typography-family)',
199
+ headings: 'var(--rad-typography-family)',
200
+ ui: 'var(--rad-typography-family)',
201
+ code: 'ui-monospace, monospace'
202
+ }, baselineProse.paragraphSpacing);
203
+ const roles = { ...tokens.roles };
204
+ for (const [role, size, weight] of [
205
+ ['ui-body', 'bodySize', 'bodyWeight'],
206
+ ['ui-label', 'bodySize', 'labelWeight'],
207
+ ['ui-title', 'headingSize', 'headingWeight'],
208
+ ['ui-supporting', 'smallSize', 'bodyWeight']
209
+ ]) {
210
+ const leaf = (name) => `var(--rad-typography-${kebabCase(name)})`;
211
+ roles[role] = {
212
+ ...tokens.roles[role],
213
+ size: leaf(size),
214
+ fluidSize: leaf(size),
215
+ weight: leaf(weight),
216
+ letterSpacing: leaf('letterSpacing')
217
+ };
218
+ }
219
+ return { ...tokens, roles };
220
+ }
122
221
  export const tokenDefaults = freezeTree({ light, dark });
123
222
  export function kebabCase(value) {
124
223
  return value.replace(/[A-Z]/g, letter => `-${letter.toLowerCase()}`);
@@ -1 +1 @@
1
- {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../src/themes/tokens.ts"],"names":[],"mappings":"AAoFA,MAAM,KAAK,GAAiB;IAC1B,KAAK,EAAE;QACL,OAAO,EAAE,cAAc;QACvB,UAAU,EAAE,uBAAuB;QACnC,eAAe,EAAE,sBAAsB;QACvC,MAAM,EAAE,wBAAwB;QAChC,WAAW,EAAE,qBAAqB;QAClC,kBAAkB,EAAE,uBAAuB;QAC3C,cAAc,EAAE,uBAAuB;QACvC,OAAO,EAAE,qBAAqB;QAC9B,KAAK,EAAE,sBAAsB;QAC7B,MAAM,EAAE,uBAAuB;QAC/B,gBAAgB,EAAE,kBAAkB;QACpC,OAAO,EAAE,wBAAwB;QACjC,iBAAiB,EAAE,uBAAuB;QAC1C,OAAO,EAAE,oBAAoB;QAC7B,iBAAiB,EAAE,oBAAoB;QACvC,MAAM,EAAE,qBAAqB;QAC7B,gBAAgB,EAAE,iBAAiB;KACpC;IACD,UAAU,EAAE;QACV,MAAM,EAAE,uBAAuB;QAC/B,QAAQ,EAAE,UAAU;QACpB,SAAS,EAAE,WAAW;QACtB,WAAW,EAAE,UAAU;QACvB,UAAU,EAAE,GAAG;QACf,WAAW,EAAE,GAAG;QAChB,aAAa,EAAE,GAAG;QAClB,aAAa,E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S,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAA;IAC3E,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAA;AAEzE,+FAA+F;AAC/F,MAAM,UAAU,SAAS,CACvB,KAAoC,EACpC,IAAmC;IAEnC,MAAM,KAAK,GAAwB,EAAE,CAAA;IACrC,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAqC,EAAE,CAAC;QAC9E,MAAM,UAAU,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAA;QAClC,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAA;QAChC,IAAI,UAAU,KAAK,SAAS;YAAE,KAAK,CAAC,QAAQ,CAAC,GAAG,UAAU,CAAA;aACrD,CAAC;YACJ,MAAM,WAAW,GAAG,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,UAAU,CAAA;YAC/E,MAAM,UAAU,GAAG,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,SAAS,CAAA;YAC5E,KAAK,CAAC,QAAQ,CAAC,GAAG,qBAAqB,WAAW,sBAAsB,UAAU,GAAG,CAAA;QACvF,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC","sourcesContent":["/** The complete shared-token registry. CSS names are derived from these paths. */\nexport interface SharedTokens {\n color: {\n surface: string\n foreground: string\n mutedForeground: string\n border: string\n placeholder: string\n disabledBackground: string\n disabledBorder: string\n invalid: string\n focus: string\n accent: string\n accentForeground: string\n neutral: string\n neutralForeground: string\n warning: string\n warningForeground: string\n danger: string\n dangerForeground: string\n }\n typography: {\n family: string\n bodySize: string\n smallSize: string\n headingSize: string\n bodyWeight: string | number\n labelWeight: string | number\n headingWeight: string | number\n letterSpacing: string\n }\n control: {\n small: ControlMetrics\n medium: ControlMetrics\n large: ControlMetrics\n radius: string\n cornerShape: string\n borderWidth: string\n borderStyle: string\n }\n surface: {\n canvas: string\n radius: string\n cornerShape: string\n borderWidth: string\n borderStyle: string\n padding: string\n gap: string\n shadow: string\n overlayShadow: string\n backdrop: string\n }\n focus: { width: string; offset: string; style: string }\n motion: {\n pressDuration: string\n pressEase: string\n releaseDuration: string\n releaseEase: string\n colorDuration: string\n disclosureDuration: string\n }\n spacing: {\n labelGap: string\n fieldGap: string\n groupGap: string\n headerGap: string\n footerGap: string\n }\n state: { disabledOpacity: number }\n}\n\ninterface ControlMetrics {\n height: string\n paddingInline: string\n fontSize: string\n indicatorSize: string\n}\n\nexport type PartialTree<T> = {\n readonly [K in keyof T]?: T[K] extends object ? PartialTree<T[K]> : T[K]\n}\nexport type ThemeTokens = PartialTree<SharedTokens>\nexport type ThemeVariableValues = Record<`--rad-${string}`, string | number>\n\nconst light: SharedTokens = {\n color: {\n surface: 'oklch(1 0 0)',\n foreground: 'oklch(0.21 0.006 286)',\n mutedForeground: 'oklch(0.45 0.01 286)',\n border: 'oklch(0.885 0.005 286)',\n placeholder: 'oklch(0.5 0.01 286)',\n disabledBackground: 'oklch(0.96 0.005 286)',\n disabledBorder: 'oklch(0.88 0.005 286)',\n invalid: 'oklch(0.56 0.19 25)',\n focus: 'oklch(0.55 0.13 255)',\n accent: 'oklch(0.21 0.006 286)',\n accentForeground: 'oklch(0.985 0 0)',\n neutral: 'oklch(0.955 0.004 286)',\n neutralForeground: 'oklch(0.21 0.006 286)',\n warning: 'oklch(0.8 0.14 78)',\n warningForeground: 'oklch(0.3 0.07 55)',\n danger: 'oklch(0.56 0.19 25)',\n dangerForeground: 'oklch(0.99 0 0)'\n },\n typography: {\n family: 'system-ui, sans-serif',\n bodySize: '0.875rem',\n smallSize: '0.8125rem',\n headingSize: '1.125rem',\n bodyWeight: 400,\n labelWeight: 550,\n headingWeight: 600,\n letterSpacing: '-0.011em'\n },\n control: {\n small: {\n height: '2rem',\n paddingInline: '0.75rem',\n fontSize: '0.8125rem',\n indicatorSize: '1rem'\n },\n medium: {\n height: '2.5rem',\n paddingInline: '1rem',\n fontSize: '0.875rem',\n indicatorSize: '1.125rem'\n },\n large: {\n height: '3rem',\n paddingInline: '1.375rem',\n fontSize: '0.9375rem',\n indicatorSize: '1.25rem'\n },\n radius: '0.5rem',\n cornerShape: 'round',\n borderWidth: '1px',\n borderStyle: 'solid'\n },\n surface: {\n canvas: 'oklch(1 0 0)',\n radius: '0.75rem',\n cornerShape: 'round',\n borderWidth: '1px',\n borderStyle: 'solid',\n padding: '1.5rem',\n gap: '1rem',\n shadow: '0 1px 2px 0 rgb(0 0 0 / 0.06)',\n overlayShadow: '0 24px 64px -16px rgb(0 0 0 / 0.3)',\n backdrop: 'rgb(0 0 0 / 0.45)'\n },\n focus: { width: '2px', offset: '2px', style: 'solid' },\n motion: {\n pressDuration: '80ms',\n pressEase: 'cubic-bezier(0.3, 0, 0, 1)',\n releaseDuration: '160ms',\n releaseEase: 'cubic-bezier(0.2, 0.8, 0.2, 1)',\n colorDuration: '150ms',\n disclosureDuration: '150ms'\n },\n spacing: {\n labelGap: '0.5rem',\n fieldGap: '0.375rem',\n groupGap: '0.75rem',\n headerGap: '0.375rem',\n footerGap: '0.5rem'\n },\n state: { disabledOpacity: 0.5 }\n}\n\nconst dark: SharedTokens = {\n ...light,\n color: {\n surface: 'oklch(0.21 0.006 286)',\n foreground: 'oklch(0.985 0 0)',\n mutedForeground: 'oklch(0.75 0.01 286)',\n border: 'oklch(0.4 0.008 286)',\n placeholder: 'oklch(0.7 0.01 286)',\n disabledBackground: 'oklch(0.26 0.006 286)',\n disabledBorder: 'oklch(0.38 0.006 286)',\n invalid: 'oklch(0.75 0.16 25)',\n focus: 'oklch(0.75 0.13 255)',\n accent: 'oklch(0.92 0.005 286)',\n accentForeground: 'oklch(0.21 0.006 286)',\n neutral: 'oklch(0.3 0.006 286)',\n neutralForeground: 'oklch(0.985 0 0)',\n warning: 'oklch(0.8 0.14 78)',\n warningForeground: 'oklch(0.3 0.07 55)',\n danger: 'oklch(0.72 0.17 25)',\n dangerForeground: 'oklch(0.2 0.04 25)'\n },\n surface: {\n ...light.surface,\n canvas: 'oklch(0.16 0.006 286)',\n shadow: '0 1px 2px 0 rgb(0 0 0 / 0.25)',\n overlayShadow: '0 24px 64px -16px rgb(0 0 0 / 0.6)',\n backdrop: 'rgb(0 0 0 / 0.65)'\n }\n}\n\n/** Immutable at runtime as well as in declarations: defaults are shared by every theme. */\nexport function freezeTree<T extends object>(value: T): Readonly<T> {\n for (const item of Object.values(value)) {\n if (item && typeof item === 'object') freezeTree(item)\n }\n return Object.freeze(value)\n}\n\nexport const tokenDefaults = freezeTree({ light, dark })\n\nexport function kebabCase(value: string): string {\n return value.replace(/[A-Z]/g, letter => `-${letter.toLowerCase()}`)\n}\n\nexport function flattenTokens(tokens: ThemeTokens): ThemeVariableValues {\n const result: ThemeVariableValues = {}\n function visit(tree: object, path: string[]) {\n for (const [key, value] of Object.entries(tree)) {\n if (value === undefined) continue\n const next = [...path, kebabCase(key)]\n if (typeof value === 'object' && value !== null) visit(value, next)\n else result[`--rad-${next.join('-')}`] = value\n }\n }\n visit(tokens, [])\n return result\n}\n\n/** Registry-derived CSS names keyed by canonical dotted authoring paths. */\nfunction collectTokenVariables(\n tree: object,\n path: string[] = []\n): Record<string, `--rad-${string}`> {\n const variables: Record<string, `--rad-${string}`> = {}\n for (const [key, value] of Object.entries(tree)) {\n const next = [...path, key]\n if (typeof value === 'object' && value !== null)\n Object.assign(variables, collectTokenVariables(value, next))\n else variables[next.join('.')] = `--rad-${next.map(kebabCase).join('-')}`\n }\n return variables\n}\n\nexport const tokenVariables = Object.freeze(collectTokenVariables(light))\n\n/** Select values through inherited CSS flags; no browser APIs or first-render mode guesses. */\nexport function modeStyle(\n light: Readonly<ThemeVariableValues>,\n dark: Readonly<ThemeVariableValues>\n): ThemeVariableValues {\n const style: ThemeVariableValues = {}\n for (const variable of Object.keys(light) as Array<keyof ThemeVariableValues>) {\n const lightValue = light[variable]\n const darkValue = dark[variable]\n if (lightValue === darkValue) style[variable] = lightValue\n else {\n const lightBranch = lightValue === 'initial' ? 'var(--_rad-unset)' : lightValue\n const darkBranch = darkValue === 'initial' ? 'var(--_rad-unset)' : darkValue\n style[variable] = `var(--_rad-light, ${lightBranch}) var(--_rad-dark, ${darkBranch})`\n }\n }\n return style\n}\n"]}
1
+ {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../src/themes/tokens.ts"],"names":[],"mappings":"AASA,qGAAqG;AACrG,MAAM,UAAU,gBAAgB,CAC9B,KAA4B,EAC5B,EAAsB;IAEtB,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC,EAAE,GAAG,KAAK,CAAA;IAC/D,MAAM,CAAC,GAAG,EAAE,CAAC,IAAI,CAAA;IACjB,MAAM,KAAK,GAAG,CACZ,UAAgC,EAChC,MAAc,EACd,IAAY,EACZ,MAAc,EACd,OAAe,EACf,QAAQ,GAAG,CAAC,EACZ,KAAK,GAAG,CAAC,EACQ,EAAE,CAAC,CAAC;QACrB,UAAU;QACV,MAAM;QACN,IAAI;QACJ,MAAM;QACN,UAAU,EAAE,OAAO;QACnB,QAAQ;QACR,OAAO,EAAE,KAAK;KACf,CAAC,CAAA;IACF,OAAO;QACL,aAAa,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC;QAC/E,eAAe,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC;QAC5E,kBAAkB,EAAE,KAAK,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,mBAAmB,CAAC,CAAC,CAAC,UAAU,CAAA;YAC/E,MAAM,UAAU,GAAG,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,SAAS,CAAA;YAC5E,KAAK,CAAC,QAAQ,CAAC,GAAG,qBAAqB,WAAW,sBAAsB,UAAU,GAAG,CAAA;QACvF,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC","sourcesContent":["import type {\n TypographyProseRhythm,\n TypographyUIRhythm,\n TypographyStyle,\n TypographyRole,\n TypographyTokens,\n TypographyAssignment\n} from '../typography/types.js'\n\n/** Canonical calculations live beside the defaults so source CSS generation stays self-contained. */\nexport function typographyStyles(\n prose: TypographyProseRhythm,\n ui: TypographyUIRhythm\n): Record<TypographyRole, TypographyStyle> {\n const { size: r, lineHeight, measure, headingScale: q } = prose\n const u = ui.size\n const style = (\n assignment: TypographyAssignment,\n narrow: number,\n wide: number,\n weight: number,\n leading: number,\n tracking = 0,\n width = 0\n ): TypographyStyle => ({\n assignment,\n narrow,\n wide,\n weight,\n lineHeight: leading,\n tracking,\n measure: width\n })\n return {\n 'prose-title': style('headings', r * q ** 3, r * q ** 5, 600, 1.12, -0.025, 22),\n 'prose-heading': style('headings', r * q, r * q ** 2, 600, 1.25, -0.015, 30),\n 'prose-subheading': style('headings', r * 1.1, r * q, 600, 1.3, -0.01, 36),\n 'prose-body': style('body', r, r, 400, lineHeight, 0, measure),\n 'prose-lead': style('body', r * 1.125, r * 1.125, 400, 1.5, 0, 55),\n 'prose-small': style('body', r * 0.8, r * 0.8, 400, 1.5, 0, measure),\n 'prose-quote': style('body', r * 1.25, r * 1.25, 400, 1.4, -0.01, measure),\n 'ui-title': style('ui', u * 1.25, u * 1.25, 600, 1.3, -0.015),\n 'ui-body': style('ui', u, u, 400, ui.lineHeight),\n 'ui-label': style('ui', u, u, 500, 1.4),\n 'ui-supporting': style('ui', u * 0.9375, u * 0.9375, 400, 1.5),\n 'ui-caption': style('ui', u * 0.875, u * 0.875, 400, 1.5),\n 'ui-metric': style('ui', u * 2, u * 2, 600, 1.15, -0.03),\n 'ui-eyebrow': style('ui', u * 0.75, u * 0.75, 600, 1.4, 0.1),\n display: style('headings', r * q ** 3, r * q ** 6, 600, 1.06, -0.035, 18),\n code: style('code', 14, 14, 400, 1.65, 0, 80)\n }\n}\n\nconst baselineProse: TypographyProseRhythm = {\n size: 20,\n lineHeight: 1.6,\n paragraphSpacing: 1.25,\n measure: 64,\n headingScale: 1.25\n}\nexport const typographyRoles = Object.freeze(\n Object.keys(typographyStyles(baselineProse, { size: 16, lineHeight: 1.5 })) as TypographyRole[]\n)\n\nfunction decimal(value: number): string {\n return String(Number(value.toFixed(8)))\n}\n\nexport function typographyTokens(\n styles: Readonly<Record<TypographyRole, TypographyStyle>>,\n families: Readonly<Record<TypographyAssignment, string>>,\n flow: number\n): TypographyTokens {\n const roles = {} as Record<TypographyRole, TypographyTokens['roles'][TypographyRole]>\n for (const role of typographyRoles) {\n const s = styles[role]\n const slope = (s.wide - s.narrow) / 512\n const intercept = s.narrow / 16 - slope * 24\n const size = `${decimal(s.narrow / 16)}rem`\n roles[role] = {\n family: families[s.assignment],\n size,\n fluidSize:\n s.narrow === s.wide\n ? size\n : `clamp(${size}, calc(${decimal(intercept)}rem + ${decimal(slope * 100)}cqi), ${decimal(s.wide / 16)}rem)`,\n weight: s.weight,\n lineHeight: decimal(s.lineHeight),\n letterSpacing: `${decimal(s.tracking)}em`,\n measure: s.measure ? `${decimal(s.measure)}ch` : 'none'\n }\n }\n return {\n roles,\n flow: {\n paragraph: `${decimal(flow)}em`,\n headingBefore: `${decimal(flow * 1.6)}em`,\n headingAfter: `${decimal(flow * 0.5)}em`\n }\n }\n}\n\n/** The complete shared-token registry. CSS names are derived from these paths. */\nexport interface SharedTokens {\n color: {\n surface: string\n foreground: string\n mutedForeground: string\n border: string\n placeholder: string\n disabledBackground: string\n disabledBorder: string\n invalid: string\n focus: string\n accent: string\n accentForeground: string\n neutral: string\n neutralForeground: string\n warning: string\n warningForeground: string\n danger: string\n dangerForeground: string\n }\n typography: {\n family: string\n bodySize: string\n smallSize: string\n headingSize: string\n bodyWeight: string | number\n labelWeight: string | number\n headingWeight: string | number\n letterSpacing: string\n roles: TypographyTokens['roles']\n flow: TypographyTokens['flow']\n }\n control: {\n small: ControlMetrics\n medium: ControlMetrics\n large: ControlMetrics\n radius: string\n cornerShape: string\n borderWidth: string\n borderStyle: string\n }\n surface: {\n canvas: string\n radius: string\n cornerShape: string\n borderWidth: string\n borderStyle: string\n padding: string\n gap: string\n shadow: string\n overlayShadow: string\n backdrop: string\n }\n focus: { width: string; offset: string; style: string }\n motion: {\n pressDuration: string\n pressEase: string\n releaseDuration: string\n releaseEase: string\n colorDuration: string\n disclosureDuration: string\n }\n spacing: {\n labelGap: string\n fieldGap: string\n groupGap: string\n headerGap: string\n footerGap: string\n }\n state: { disabledOpacity: number }\n}\n\ninterface ControlMetrics {\n height: string\n paddingInline: string\n fontSize: string\n indicatorSize: string\n}\n\nexport type PartialTree<T> = {\n readonly [K in keyof T]?: T[K] extends object ? PartialTree<T[K]> : T[K]\n}\nexport type ThemeTokens = PartialTree<SharedTokens>\nexport type ThemeVariableValues = Record<`--rad-${string}`, string | number>\n\nconst light: SharedTokens = {\n color: {\n surface: 'oklch(1 0 0)',\n foreground: 'oklch(0.21 0.006 286)',\n mutedForeground: 'oklch(0.45 0.01 286)',\n border: 'oklch(0.885 0.005 286)',\n placeholder: 'oklch(0.5 0.01 286)',\n disabledBackground: 'oklch(0.96 0.005 286)',\n disabledBorder: 'oklch(0.88 0.005 286)',\n invalid: 'oklch(0.56 0.19 25)',\n focus: 'oklch(0.55 0.13 255)',\n accent: 'oklch(0.21 0.006 286)',\n accentForeground: 'oklch(0.985 0 0)',\n neutral: 'oklch(0.955 0.004 286)',\n neutralForeground: 'oklch(0.21 0.006 286)',\n warning: 'oklch(0.8 0.14 78)',\n warningForeground: 'oklch(0.3 0.07 55)',\n danger: 'oklch(0.56 0.19 25)',\n dangerForeground: 'oklch(0.99 0 0)'\n },\n typography: {\n ...baselineTypographyTokens(),\n family: 'system-ui, sans-serif',\n bodySize: '0.875rem',\n smallSize: '0.8125rem',\n headingSize: '1.125rem',\n bodyWeight: 400,\n labelWeight: 550,\n headingWeight: 600,\n letterSpacing: '-0.011em'\n },\n control: {\n small: {\n height: '2rem',\n paddingInline: '0.75rem',\n fontSize: '0.8125rem',\n indicatorSize: '1rem'\n },\n medium: {\n height: '2.5rem',\n paddingInline: '1rem',\n fontSize: '0.875rem',\n indicatorSize: '1.125rem'\n },\n large: {\n height: '3rem',\n paddingInline: '1.375rem',\n fontSize: '0.9375rem',\n indicatorSize: '1.25rem'\n },\n radius: '0.5rem',\n cornerShape: 'round',\n borderWidth: '1px',\n borderStyle: 'solid'\n },\n surface: {\n canvas: 'oklch(1 0 0)',\n radius: '0.75rem',\n cornerShape: 'round',\n borderWidth: '1px',\n borderStyle: 'solid',\n padding: '1.5rem',\n gap: '1rem',\n shadow: '0 1px 2px 0 rgb(0 0 0 / 0.06)',\n overlayShadow: '0 24px 64px -16px rgb(0 0 0 / 0.3)',\n backdrop: 'rgb(0 0 0 / 0.45)'\n },\n focus: { width: '2px', offset: '2px', style: 'solid' },\n motion: {\n pressDuration: '80ms',\n pressEase: 'cubic-bezier(0.3, 0, 0, 1)',\n releaseDuration: '160ms',\n releaseEase: 'cubic-bezier(0.2, 0.8, 0.2, 1)',\n colorDuration: '150ms',\n disclosureDuration: '150ms'\n },\n spacing: {\n labelGap: '0.5rem',\n fieldGap: '0.375rem',\n groupGap: '0.75rem',\n headerGap: '0.375rem',\n footerGap: '0.5rem'\n },\n state: { disabledOpacity: 0.5 }\n}\n\nconst dark: SharedTokens = {\n ...light,\n color: {\n surface: 'oklch(0.21 0.006 286)',\n foreground: 'oklch(0.985 0 0)',\n mutedForeground: 'oklch(0.75 0.01 286)',\n border: 'oklch(0.4 0.008 286)',\n placeholder: 'oklch(0.7 0.01 286)',\n disabledBackground: 'oklch(0.26 0.006 286)',\n disabledBorder: 'oklch(0.38 0.006 286)',\n invalid: 'oklch(0.75 0.16 25)',\n focus: 'oklch(0.75 0.13 255)',\n accent: 'oklch(0.92 0.005 286)',\n accentForeground: 'oklch(0.21 0.006 286)',\n neutral: 'oklch(0.3 0.006 286)',\n neutralForeground: 'oklch(0.985 0 0)',\n warning: 'oklch(0.8 0.14 78)',\n warningForeground: 'oklch(0.3 0.07 55)',\n danger: 'oklch(0.72 0.17 25)',\n dangerForeground: 'oklch(0.2 0.04 25)'\n },\n surface: {\n ...light.surface,\n canvas: 'oklch(0.16 0.006 286)',\n shadow: '0 1px 2px 0 rgb(0 0 0 / 0.25)',\n overlayShadow: '0 24px 64px -16px rgb(0 0 0 / 0.6)',\n backdrop: 'rgb(0 0 0 / 0.65)'\n }\n}\n\n/** Immutable at runtime as well as in declarations: defaults are shared by every theme. */\nexport function freezeTree<T extends object>(value: T): Readonly<T> {\n for (const item of Object.values(value)) {\n if (item && typeof item === 'object') freezeTree(item)\n }\n return Object.freeze(value)\n}\n\n// Legacy/preset leaves remain a bridge until a recipe or explicit role owns them.\n// UI measures stay layout-owned; controls retain their independent size metrics.\nfunction baselineTypographyTokens(): TypographyTokens {\n const tokens = typographyTokens(\n typographyStyles(baselineProse, { size: 16, lineHeight: 1.5 }),\n {\n body: 'var(--rad-typography-family)',\n headings: 'var(--rad-typography-family)',\n ui: 'var(--rad-typography-family)',\n code: 'ui-monospace, monospace'\n },\n baselineProse.paragraphSpacing\n )\n const roles = { ...tokens.roles }\n for (const [role, size, weight] of [\n ['ui-body', 'bodySize', 'bodyWeight'],\n ['ui-label', 'bodySize', 'labelWeight'],\n ['ui-title', 'headingSize', 'headingWeight'],\n ['ui-supporting', 'smallSize', 'bodyWeight']\n ] as const) {\n const leaf = (name: string) => `var(--rad-typography-${kebabCase(name)})`\n roles[role] = {\n ...tokens.roles[role],\n size: leaf(size),\n fluidSize: leaf(size),\n weight: leaf(weight),\n letterSpacing: leaf('letterSpacing')\n }\n }\n return { ...tokens, roles }\n}\n\nexport const tokenDefaults = freezeTree({ light, dark })\n\nexport function kebabCase(value: string): string {\n return value.replace(/[A-Z]/g, letter => `-${letter.toLowerCase()}`)\n}\n\nexport function flattenTokens(tokens: ThemeTokens): ThemeVariableValues {\n const result: ThemeVariableValues = {}\n function visit(tree: object, path: string[]) {\n for (const [key, value] of Object.entries(tree)) {\n if (value === undefined) continue\n const next = [...path, kebabCase(key)]\n if (typeof value === 'object' && value !== null) visit(value, next)\n else result[`--rad-${next.join('-')}`] = value\n }\n }\n visit(tokens, [])\n return result\n}\n\n/** Registry-derived CSS names keyed by canonical dotted authoring paths. */\nfunction collectTokenVariables(\n tree: object,\n path: string[] = []\n): Record<string, `--rad-${string}`> {\n const variables: Record<string, `--rad-${string}`> = {}\n for (const [key, value] of Object.entries(tree)) {\n const next = [...path, key]\n if (typeof value === 'object' && value !== null)\n Object.assign(variables, collectTokenVariables(value, next))\n else variables[next.join('.')] = `--rad-${next.map(kebabCase).join('-')}`\n }\n return variables\n}\n\nexport const tokenVariables = Object.freeze(collectTokenVariables(light))\n\n/** Select values through inherited CSS flags; no browser APIs or first-render mode guesses. */\nexport function modeStyle(\n light: Readonly<ThemeVariableValues>,\n dark: Readonly<ThemeVariableValues>\n): ThemeVariableValues {\n const style: ThemeVariableValues = {}\n for (const variable of Object.keys(light) as Array<keyof ThemeVariableValues>) {\n const lightValue = light[variable]\n const darkValue = dark[variable]\n if (lightValue === darkValue) style[variable] = lightValue\n else {\n const lightBranch = lightValue === 'initial' ? 'var(--_rad-unset)' : lightValue\n const darkBranch = darkValue === 'initial' ? 'var(--_rad-unset)' : darkValue\n style[variable] = `var(--_rad-light, ${lightBranch}) var(--_rad-dark, ${darkBranch})`\n }\n }\n return style\n}\n"]}
@@ -0,0 +1,72 @@
1
+ import { typographyRoles } from '../themes/tokens.js';
2
+ import type { TypographyInput, TypographyResult } from './types.js';
3
+ export type * from './types.js';
4
+ export { typographyRoles };
5
+ export declare const typographyPresets: Readonly<{
6
+ readonly inter: {
7
+ readonly name: "Inter";
8
+ readonly fonts: {
9
+ readonly body: {
10
+ readonly family: "Inter, system-ui, sans-serif";
11
+ readonly profile: "inter";
12
+ };
13
+ readonly headings: {
14
+ readonly family: "Inter, system-ui, sans-serif";
15
+ readonly profile: "inter";
16
+ };
17
+ readonly ui: {
18
+ readonly family: "Inter, system-ui, sans-serif";
19
+ readonly profile: "inter";
20
+ };
21
+ readonly code: {
22
+ readonly family: "\"IBM Plex Mono\", ui-monospace, monospace";
23
+ readonly profile: "plex-mono";
24
+ };
25
+ };
26
+ };
27
+ readonly 'source-serif': {
28
+ readonly name: "Source Serif 4 + Inter";
29
+ readonly fonts: {
30
+ readonly body: {
31
+ readonly family: "\"Source Serif 4\", Georgia, serif";
32
+ readonly profile: "source-serif-4";
33
+ };
34
+ readonly headings: {
35
+ readonly family: "\"Source Serif 4\", Georgia, serif";
36
+ readonly profile: "source-serif-4";
37
+ };
38
+ readonly ui: {
39
+ readonly family: "Inter, system-ui, sans-serif";
40
+ readonly profile: "inter";
41
+ };
42
+ readonly code: {
43
+ readonly family: "\"IBM Plex Mono\", ui-monospace, monospace";
44
+ readonly profile: "plex-mono";
45
+ };
46
+ };
47
+ };
48
+ readonly plex: {
49
+ readonly name: "Plex Sans + Plex Mono";
50
+ readonly fonts: {
51
+ readonly body: {
52
+ readonly family: "\"IBM Plex Sans\", system-ui, sans-serif";
53
+ readonly profile: "plex-sans";
54
+ };
55
+ readonly headings: {
56
+ readonly family: "\"IBM Plex Sans\", system-ui, sans-serif";
57
+ readonly profile: "plex-sans";
58
+ };
59
+ readonly ui: {
60
+ readonly family: "\"IBM Plex Sans\", system-ui, sans-serif";
61
+ readonly profile: "plex-sans";
62
+ };
63
+ readonly code: {
64
+ readonly family: "\"IBM Plex Mono\", ui-monospace, monospace";
65
+ readonly profile: "plex-mono";
66
+ };
67
+ };
68
+ };
69
+ }>;
70
+ /** Pure, server-safe calculations. Input omits automatic metrics; output never loads a font. */
71
+ export declare function generateTypography(input?: TypographyInput): TypographyResult;
72
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/typography/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,EAGhB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAGV,eAAe,EAGf,gBAAgB,EACjB,MAAM,YAAY,CAAA;AACnB,mBAAmB,YAAY,CAAA;AAC/B,OAAO,EAAE,eAAe,EAAE,CAAA;AAM1B,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAUnB,CAAA;AA4CX,gGAAgG;AAChG,wBAAgB,kBAAkB,CAAC,KAAK,GAAE,eAAoB,GAAG,gBAAgB,CAuHhF"}