@adea-ai/ui 0.123.1 → 0.124.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/dist/NOTICE +18 -0
  2. package/dist/components/theme/appearance-panel.js +1 -1
  3. package/dist/components/theme/index.d.ts +1 -1
  4. package/dist/components/theme/index.d.ts.map +1 -1
  5. package/dist/components/theme/index.js +5 -2
  6. package/dist/components/theme/theme-context.d.ts +13 -0
  7. package/dist/components/theme/theme-context.d.ts.map +1 -0
  8. package/dist/components/theme/theme-context.js +41 -0
  9. package/dist/components/theme/theme-context.js.map +1 -0
  10. package/dist/components/theme/theme-document.d.ts +76 -0
  11. package/dist/components/theme/theme-document.d.ts.map +1 -0
  12. package/dist/components/theme/theme-document.js +93 -0
  13. package/dist/components/theme/theme-document.js.map +1 -0
  14. package/dist/components/theme/theme-persistence.d.ts +50 -0
  15. package/dist/components/theme/theme-persistence.d.ts.map +1 -0
  16. package/dist/components/theme/theme-persistence.js +86 -0
  17. package/dist/components/theme/theme-persistence.js.map +1 -0
  18. package/dist/components/theme/theme-provider.d.ts +43 -75
  19. package/dist/components/theme/theme-provider.d.ts.map +1 -1
  20. package/dist/components/theme/theme-provider.js +50 -116
  21. package/dist/components/theme/theme-provider.js.map +1 -1
  22. package/dist/components/theme/theme-state.d.ts +142 -0
  23. package/dist/components/theme/theme-state.d.ts.map +1 -0
  24. package/dist/components/theme/theme-state.js +104 -0
  25. package/dist/components/theme/theme-state.js.map +1 -0
  26. package/dist/components/theme/theme-toggle.js +1 -1
  27. package/dist/index.d.ts +1 -1
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +6 -3
  30. package/dist/lib/appearance-font-settings.d.ts +1 -1
  31. package/dist/lib/appearance-font-settings.d.ts.map +1 -1
  32. package/dist/lib/appearance-font-settings.js.map +1 -1
  33. package/dist/lib/themes.d.ts +48 -0
  34. package/dist/lib/themes.d.ts.map +1 -1
  35. package/dist/lib/themes.js +150 -36
  36. package/dist/lib/themes.js.map +1 -1
  37. package/dist/r/registry.json +20 -0
  38. package/dist/r/src/components/theme/index.ts +3 -0
  39. package/dist/r/src/components/theme/theme-context.ts +43 -0
  40. package/dist/r/src/components/theme/theme-document.ts +168 -0
  41. package/dist/r/src/components/theme/theme-persistence.ts +140 -0
  42. package/dist/r/src/components/theme/theme-provider.tsx +126 -253
  43. package/dist/r/src/components/theme/theme-state.ts +225 -0
  44. package/dist/r/src/lib/appearance-font-settings.ts +1 -1
  45. package/dist/r/src/lib/themes.ts +181 -40
  46. package/dist/r/theming.json +20 -0
  47. package/package.json +1 -1
  48. package/registry.json +20 -0
  49. package/src/components/theme/index.ts +3 -0
  50. package/src/components/theme/theme-context.ts +43 -0
  51. package/src/components/theme/theme-document.ts +168 -0
  52. package/src/components/theme/theme-persistence.ts +140 -0
  53. package/src/components/theme/theme-provider.tsx +126 -253
  54. package/src/components/theme/theme-state.ts +225 -0
  55. package/src/index.ts +3 -0
  56. package/src/lib/appearance-font-settings.ts +1 -1
  57. package/src/lib/themes.ts +181 -40
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,cAAc,2BAA2B,CAAA;AACzC,cAAc,uBAAuB,CAAA;AACrC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,oCAAoC,CAAA;AAClD,cAAc,8BAA8B,CAAA;AAC5C,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,uBAAuB,CAAA;AACrC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,wBAAwB,CAAA;AACtC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,0BAA0B,CAAA;AACxC,cAAc,sBAAsB,CAAA;AACpC,cAAc,0BAA0B,CAAA;AACxC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,0BAA0B,CAAA;AACxC,cAAc,4BAA4B,CAAA;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AE,MAAM,iBAAiB,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAC3F,OAAO,EACL,aAAa,EACb,SAAS,EACT,WAAW,EACX,aAAa,EACb,YAAY,EACZ,eAAe,EACf,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,wBAAwB,EACxB,YAAY,EACZ,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,SAAS,GACf,MAAM,cAAc,CAAA"}
package/dist/index.js CHANGED
@@ -104,11 +104,14 @@ import { PASTE_THRESHOLD_CHARS, PASTE_THRESHOLD_LINES, PASTE_TOKEN_REGEX, countL
104
104
  import { fontOptions } from "./lib/font-catalog.js";
105
105
  import { accentPresets, allTokens, colorTokens, densityTokens, designTokens, elevationTokens, motionTokens, radiusTokens, typographyTokens, undocumentedTokenAliases, zIndexTokens } from "./lib/tokens.js";
106
106
  import { isThemeAccentId } from "./lib/theme-accents.js";
107
- import { appearancePreviewThemes, builtinThemes, contrastRatio, defaultDarkThemeId, defaultLightThemeId, resolveAccentPreset, themeAccentsFor, themeById, themeCssVariables, themeFamilies, themeRecordById, themeRecords, themesForAppearance, validateTheme, validateThemeRegistry, withAccent } from "./lib/themes.js";
107
+ import { appearancePreviewThemes, builtinThemes, contrastRatio, defaultDarkThemeId, defaultLightThemeId, resolveAccentPreset, resolveVariant, themeAccentsFor, themeById, themeCssVariables, themeFamilies, themeRecordById, themeRecords, themesForAppearance, tokensAsHex, validateTheme, validateThemeRegistry, variantFromRecord, withAccent } from "./lib/themes.js";
108
108
  import { APPEARANCE_EDITOR_FONT_AXES, APPEARANCE_EDITOR_FONT_SIZE_MAX, APPEARANCE_EDITOR_FONT_SIZE_MIN, DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS, applyAppearanceFontSettings, fontSettingsBootstrapScript, normalizeAppearanceEditorFontSettings, normalizeAppearanceEditorFontSize } from "./lib/appearance-font-settings.js";
109
109
  import { AppearanceFontSettingsGroup } from "./components/composites/appearance-editor/font-settings-group.js";
110
110
  import { ThemePicker, ThemePreview, ThemeSwatch } from "./components/theme/theme-picker.js";
111
- import { ThemeProvider, defaultThemeSelection, inlineScriptLiteral, resolvedDensity, themeScript, useTheme } from "./components/theme/theme-provider.js";
111
+ import { useOptionalTheme, useTheme } from "./components/theme/theme-context.js";
112
+ import { defaultThemeSelection, resolvedDensity } from "./components/theme/theme-state.js";
113
+ import { localStoragePersistence } from "./components/theme/theme-persistence.js";
114
+ import { ThemeProvider, inlineScriptLiteral, themeScript } from "./components/theme/theme-provider.js";
112
115
  import { AppearancePanel } from "./components/theme/appearance-panel.js";
113
116
  import { ThemeToggle } from "./components/theme/theme-toggle.js";
114
117
  import { ThemeModeToggle } from "./components/theme/theme-mode-toggle.js";
@@ -133,4 +136,4 @@ import { AboutDialog } from "./components/composites/about-dialog/about-dialog.j
133
136
  import { HelpCenter } from "./components/composites/help-center/help-center.js";
134
137
  import { WorkspaceMark } from "./components/composites/workspace-mark/workspace-mark.js";
135
138
  import { writeClipboardText } from "./lib/clipboard.js";
136
- export { APPEARANCE_EDITOR_FONT_AXES, APPEARANCE_EDITOR_FONT_SIZE_MAX, APPEARANCE_EDITOR_FONT_SIZE_MIN, AboutDialog, Accordion, AccordionContent, AccordionItem, AccordionTrigger, AccountMenu, ActionButton, Alert, AlertAction, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AnnotationSurface, AppShell, AppShellBody, AppShellContent, AppShellMain, AppearanceEditor, AppearanceEditorActions, AppearanceFontSettingsGroup, AppearancePanel, AppearancePopover, AspectRatio, AttachmentCard, Avatar, AvatarFallback, AvatarImage, Badge, Board, BoardCardBody, BoardCardTitle, BoardCardTrigger, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, BusySendButton, Button, ButtonGroup, ButtonGroupSeparator, ButtonGroupText, CalendarSurface, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, CatalogBrowser, CatalogDetail, CatalogDetailSection, ChatComposer, Checkbox, CheckboxDescription, CheckboxLabel, CodeBlock, Collapsible, CollapsibleContent, CollapsibleTrigger, Combobox, ComboboxClear, ComboboxContent, ComboboxControl, ComboboxInput, ComboboxItem, ComboboxSection, ComboboxTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandHint, CommandInput, CommandItem, CommandList, CommandLoading, CommandSeparator, CommandShortcut, CommandStatus, ComposerAttachmentButton, ComposerHint, ComposerMenu, ComposerMenuItem, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, ContextualSidebar, ConversationAvatar, ConversationPane, ConversationSurface, DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS, DatePicker, DetailPanel, DetailPanelBody, DetailPanelField, DetailPanelHeader, DetailPanelSection, Dialog, DialogClose, DialogCloseButton, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DiffBlock, DiffSummary, Drawer, DrawerBody, DrawerCloseButton, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyState, EmptyTitle, EntityIcon, FLOATING_PREVIEW_CORNER_RADIUS, FLOATING_PREVIEW_EDGE_GAP, Field, FieldDescription, FieldError, FieldGroup, FieldInput, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTextArea, FloatingPreview, FormField, Heading, HelpCenter, HoverCard, HoverCardContent, HoverCardTrigger, InlineCode, Input, InputControl, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputOtp, InputOtpCaret, Item, ItemDescription, ItemEmpty, ItemGroup, ItemGroupEntry, ItemTitle, Kbd, KbdChord, KbdGroup, Label, ListGroup, ListRow, ListRowControl, MAX_LAYOUT_DEPTH, MAX_LAYOUT_LEAVES, MAX_SPLIT_RATIO, MIN_SPLIT_RATIO, Menubar, MenubarCheckboxItem, MenubarContent, MenubarGroup, MenubarItem, MenubarLabel, MenubarMenu, MenubarRadioGroup, MenubarRadioItem, MenubarSeparator, MenubarSub, MenubarSubContent, MenubarSubTrigger, MenubarTrigger, MessageBody, MessageComposer, MessageDayDivider, MessageGroup, MessageRow, ModalDialog, Motion, NO_FLOATING_PREVIEW_OBSTACLES, NO_PREVIEW_MINI_PLAYER_OBSTACLES, NativeSelect, NavigationMenu, NavigationMenuContent, NavigationMenuGroup, NavigationMenuGroupLabel, NavigationMenuItem, NavigationMenuMenu, NavigationMenuSeparator, NavigationMenuTrigger, NavigationMenuViewport, NumberField, OrbitItem, OrbitLayout, PASTE_THRESHOLD_CHARS, PASTE_THRESHOLD_LINES, PASTE_TOKEN_REGEX, PREVIEW_MINI_PLAYER_CORNER_RADIUS, PREVIEW_MINI_PLAYER_EDGE_GAP, Page, PageHeader, PageHeaderActions, PageHeaderContent, PageHeaderDescription, PageHeaderTitle, PageSection, Pagination, PaginationEllipsis, PaginationItem, PaginationNext, PaginationPrevious, PalettePreview, Panel, PanelActions, PanelBody, PanelCard, PanelDescription, PanelFooter, PanelHeader, PanelPlaceholder, PanelTitle, PanelToolbar, PixelResizeHandle, Popover, PopoverAnchor, PopoverCloseButton, PopoverContent, PopoverDescription, PopoverTitle, PopoverTrigger, Presence, Progress, PropertyList, PropertyRow, PropertyTerm, PropertyValue, RadioGroup, RadioGroupItem, ResizableHandle, ResizablePanel, ResizablePanelGroup, SceneControls, ScrollArea, SecretInputGroup, Select, SelectChevronsUpDown, SelectContent, SelectItem, SelectLabel, SelectSection, SelectTrigger, SelectValue, Separator, SettingsField, SettingsLayout, SettingsNavigation, SettingsPage, SettingsRow, SettingsSection, Sheet, SheetBody, SheetCloseButton, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, SideRail, SideRailButton, SideRailContent, SideRailFooter, SideRailHeader, SideRailItem, SideRailSection, SidebarNav, SidebarNavButton, SidebarNavContent, SidebarNavFooter, SidebarNavHeader, SidebarNavItem, SidebarNavLabel, SidebarNavResizeHandle, SidebarNavRow, SidebarNavSection, SidebarNavTitle, Skeleton, SkipLink, Slider, Spinner, SplitLayout, Stat, StatGroup, StatusBar, StatusBarItem, StatusBarSpacer, StatusChip, StatusList, Switch, SwitchDescription, SwitchLabel, TALL_CODE_BLOCK_PX, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableNumericCell, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Text, TextLink, Textarea, ThemeMiniature, ThemeMiniatureSplit, ThemeModeToggle, ThemePicker, ThemePreview, ThemeProvider, ThemeSwatch, ThemeToggle, ThreadPanel, Toaster, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TopBar, TopBarBreadcrumb, TopBarPill, TopBarSearch, TopBarSection, TopBarTitle, TranscriptComposition, Tree, TreeRow, TreeRowActions, UpdateChannelControl, UpdateDialog, ValueCombobox, VirtualWindow, WorkspaceMark, accentPresets, alertVariants, allTokens, appearancePreviewThemes, applyAppearanceFontSettings, badgeVariants, boardCardTitleVariants, builtinThemes, buttonVariants, cardVariants, clampFloatingPreviewPosition, clampPreviewMiniPlayerPosition, closePane, cn, colorTokens, computeLayoutFrames, contrastRatio, controlInteractive, controlSize, controlSizeIcon, controlSizes, countLeaves, countLines, createAppMenuItems, createLayoutState, cva, defaultDarkThemeId, defaultLightThemeId, defaultThemeSelection, densityTokens, designTokens, diffLineVariants, diffStats, diffTargetPath, elevationTokens, entityIconVariants, expandAll, findTokenRanges, focusPane, fontOptions, fontSettingsBootstrapScript, formatBytes, formatReleaseDate, formatToken, headingElement, headingVariants, initialsFrom, inlineScriptLiteral, isPasteBlock, isThemeAccentId, itemVariants, kbdChordKeys, kbdGroupVariants, kbdVariants, keyedRows, layoutDepth, listLeaves, monogram, motionTokens, movePane, neighborLeaf, nextSeq, normalizeAppearanceEditorFontSettings, normalizeAppearanceEditorFontSize, normalizeLayout, parseDiff, plainTextFromMarkdown, platformModifierKey, pruneBlocks, radiusTokens, recollapsePastes, remapCarriedBlocks, resizeFloatingPreview, resizePreviewMiniPlayer, resizeSplit, resolveAccentPreset, resolveFloatingPreviewFrame, resolvePreviewMiniPlayerFrame, resolvedDensity, searchShortcutKeyshortcuts, searchShortcutLabel, sheetVariants, shouldCollapse, sidebarNavItemClass, sidebarNavItemStateClass, splitPane, splitPaneBalanced, statusDotVariants, stripTrailingBlankLines, surfaceInteractive, swapPanes, textElement, textVariants, textareaVariants, themeAccentsFor, themeById, themeCssVariables, themeFamilies, themeRecordById, themeRecords, themeScript, themesForAppearance, toast, toaster, toggleVariants, tokenRangeAt, transcriptDisclosureKey, typographyTokens, undoClosePane, undocumentedTokenAliases, useSideRail, useTheme, validateTheme, validateThemeRegistry, withAccent, writeClipboardText, zIndexTokens };
139
+ export { APPEARANCE_EDITOR_FONT_AXES, APPEARANCE_EDITOR_FONT_SIZE_MAX, APPEARANCE_EDITOR_FONT_SIZE_MIN, AboutDialog, Accordion, AccordionContent, AccordionItem, AccordionTrigger, AccountMenu, ActionButton, Alert, AlertAction, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AnnotationSurface, AppShell, AppShellBody, AppShellContent, AppShellMain, AppearanceEditor, AppearanceEditorActions, AppearanceFontSettingsGroup, AppearancePanel, AppearancePopover, AspectRatio, AttachmentCard, Avatar, AvatarFallback, AvatarImage, Badge, Board, BoardCardBody, BoardCardTitle, BoardCardTrigger, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, BusySendButton, Button, ButtonGroup, ButtonGroupSeparator, ButtonGroupText, CalendarSurface, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, CatalogBrowser, CatalogDetail, CatalogDetailSection, ChatComposer, Checkbox, CheckboxDescription, CheckboxLabel, CodeBlock, Collapsible, CollapsibleContent, CollapsibleTrigger, Combobox, ComboboxClear, ComboboxContent, ComboboxControl, ComboboxInput, ComboboxItem, ComboboxSection, ComboboxTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandHint, CommandInput, CommandItem, CommandList, CommandLoading, CommandSeparator, CommandShortcut, CommandStatus, ComposerAttachmentButton, ComposerHint, ComposerMenu, ComposerMenuItem, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, ContextualSidebar, ConversationAvatar, ConversationPane, ConversationSurface, DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS, DatePicker, DetailPanel, DetailPanelBody, DetailPanelField, DetailPanelHeader, DetailPanelSection, Dialog, DialogClose, DialogCloseButton, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DiffBlock, DiffSummary, Drawer, DrawerBody, DrawerCloseButton, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyState, EmptyTitle, EntityIcon, FLOATING_PREVIEW_CORNER_RADIUS, FLOATING_PREVIEW_EDGE_GAP, Field, FieldDescription, FieldError, FieldGroup, FieldInput, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTextArea, FloatingPreview, FormField, Heading, HelpCenter, HoverCard, HoverCardContent, HoverCardTrigger, InlineCode, Input, InputControl, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputOtp, InputOtpCaret, Item, ItemDescription, ItemEmpty, ItemGroup, ItemGroupEntry, ItemTitle, Kbd, KbdChord, KbdGroup, Label, ListGroup, ListRow, ListRowControl, MAX_LAYOUT_DEPTH, MAX_LAYOUT_LEAVES, MAX_SPLIT_RATIO, MIN_SPLIT_RATIO, Menubar, MenubarCheckboxItem, MenubarContent, MenubarGroup, MenubarItem, MenubarLabel, MenubarMenu, MenubarRadioGroup, MenubarRadioItem, MenubarSeparator, MenubarSub, MenubarSubContent, MenubarSubTrigger, MenubarTrigger, MessageBody, MessageComposer, MessageDayDivider, MessageGroup, MessageRow, ModalDialog, Motion, NO_FLOATING_PREVIEW_OBSTACLES, NO_PREVIEW_MINI_PLAYER_OBSTACLES, NativeSelect, NavigationMenu, NavigationMenuContent, NavigationMenuGroup, NavigationMenuGroupLabel, NavigationMenuItem, NavigationMenuMenu, NavigationMenuSeparator, NavigationMenuTrigger, NavigationMenuViewport, NumberField, OrbitItem, OrbitLayout, PASTE_THRESHOLD_CHARS, PASTE_THRESHOLD_LINES, PASTE_TOKEN_REGEX, PREVIEW_MINI_PLAYER_CORNER_RADIUS, PREVIEW_MINI_PLAYER_EDGE_GAP, Page, PageHeader, PageHeaderActions, PageHeaderContent, PageHeaderDescription, PageHeaderTitle, PageSection, Pagination, PaginationEllipsis, PaginationItem, PaginationNext, PaginationPrevious, PalettePreview, Panel, PanelActions, PanelBody, PanelCard, PanelDescription, PanelFooter, PanelHeader, PanelPlaceholder, PanelTitle, PanelToolbar, PixelResizeHandle, Popover, PopoverAnchor, PopoverCloseButton, PopoverContent, PopoverDescription, PopoverTitle, PopoverTrigger, Presence, Progress, PropertyList, PropertyRow, PropertyTerm, PropertyValue, RadioGroup, RadioGroupItem, ResizableHandle, ResizablePanel, ResizablePanelGroup, SceneControls, ScrollArea, SecretInputGroup, Select, SelectChevronsUpDown, SelectContent, SelectItem, SelectLabel, SelectSection, SelectTrigger, SelectValue, Separator, SettingsField, SettingsLayout, SettingsNavigation, SettingsPage, SettingsRow, SettingsSection, Sheet, SheetBody, SheetCloseButton, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, SideRail, SideRailButton, SideRailContent, SideRailFooter, SideRailHeader, SideRailItem, SideRailSection, SidebarNav, SidebarNavButton, SidebarNavContent, SidebarNavFooter, SidebarNavHeader, SidebarNavItem, SidebarNavLabel, SidebarNavResizeHandle, SidebarNavRow, SidebarNavSection, SidebarNavTitle, Skeleton, SkipLink, Slider, Spinner, SplitLayout, Stat, StatGroup, StatusBar, StatusBarItem, StatusBarSpacer, StatusChip, StatusList, Switch, SwitchDescription, SwitchLabel, TALL_CODE_BLOCK_PX, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableNumericCell, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Text, TextLink, Textarea, ThemeMiniature, ThemeMiniatureSplit, ThemeModeToggle, ThemePicker, ThemePreview, ThemeProvider, ThemeSwatch, ThemeToggle, ThreadPanel, Toaster, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TopBar, TopBarBreadcrumb, TopBarPill, TopBarSearch, TopBarSection, TopBarTitle, TranscriptComposition, Tree, TreeRow, TreeRowActions, UpdateChannelControl, UpdateDialog, ValueCombobox, VirtualWindow, WorkspaceMark, accentPresets, alertVariants, allTokens, appearancePreviewThemes, applyAppearanceFontSettings, badgeVariants, boardCardTitleVariants, builtinThemes, buttonVariants, cardVariants, clampFloatingPreviewPosition, clampPreviewMiniPlayerPosition, closePane, cn, colorTokens, computeLayoutFrames, contrastRatio, controlInteractive, controlSize, controlSizeIcon, controlSizes, countLeaves, countLines, createAppMenuItems, createLayoutState, cva, defaultDarkThemeId, defaultLightThemeId, defaultThemeSelection, densityTokens, designTokens, diffLineVariants, diffStats, diffTargetPath, elevationTokens, entityIconVariants, expandAll, findTokenRanges, focusPane, fontOptions, fontSettingsBootstrapScript, formatBytes, formatReleaseDate, formatToken, headingElement, headingVariants, initialsFrom, inlineScriptLiteral, isPasteBlock, isThemeAccentId, itemVariants, kbdChordKeys, kbdGroupVariants, kbdVariants, keyedRows, layoutDepth, listLeaves, localStoragePersistence, monogram, motionTokens, movePane, neighborLeaf, nextSeq, normalizeAppearanceEditorFontSettings, normalizeAppearanceEditorFontSize, normalizeLayout, parseDiff, plainTextFromMarkdown, platformModifierKey, pruneBlocks, radiusTokens, recollapsePastes, remapCarriedBlocks, resizeFloatingPreview, resizePreviewMiniPlayer, resizeSplit, resolveAccentPreset, resolveFloatingPreviewFrame, resolvePreviewMiniPlayerFrame, resolveVariant, resolvedDensity, searchShortcutKeyshortcuts, searchShortcutLabel, sheetVariants, shouldCollapse, sidebarNavItemClass, sidebarNavItemStateClass, splitPane, splitPaneBalanced, statusDotVariants, stripTrailingBlankLines, surfaceInteractive, swapPanes, textElement, textVariants, textareaVariants, themeAccentsFor, themeById, themeCssVariables, themeFamilies, themeRecordById, themeRecords, themeScript, themesForAppearance, toast, toaster, toggleVariants, tokenRangeAt, tokensAsHex, transcriptDisclosureKey, typographyTokens, undoClosePane, undocumentedTokenAliases, useOptionalTheme, useSideRail, useTheme, validateTheme, validateThemeRegistry, variantFromRecord, withAccent, writeClipboardText, zIndexTokens };
@@ -38,7 +38,7 @@ export declare function normalizeAppearanceEditorFontSettings(value: unknown, le
38
38
  * sizes, and projected CSS variables. The marker activates the optional role
39
39
  * stylesheet and survives CSS import reordering.
40
40
  */
41
- export declare function applyAppearanceFontSettings(root: HTMLElement, value: unknown): NormalizedAppearanceEditorFontSettings;
41
+ export declare function applyAppearanceFontSettings(root: Pick<HTMLElement, 'removeAttribute' | 'setAttribute' | 'style'>, value: unknown): NormalizedAppearanceEditorFontSettings;
42
42
  /**
43
43
  * Generate a safe inline prepaint script for a host-owned appearance record.
44
44
  *
@@ -1 +1 @@
1
- {"version":3,"file":"appearance-font-settings.d.ts","sourceRoot":"","sources":["../../src/lib/appearance-font-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAGhE,eAAO,MAAM,2BAA2B,oCAAqC,CAAA;AAE7E,MAAM,MAAM,wBAAwB,GAAG,CAAC,OAAO,2BAA2B,CAAC,CAAC,MAAM,CAAC,CAAA;AACnF,MAAM,MAAM,4BAA4B,GAAG,UAAU,CAAC,IAAI,CAAC,CAAA;AAE3D,MAAM,MAAM,2BAA2B,GAAG,QAAQ,CAAC;IACjD,6EAA6E;IAC7E,MAAM,EAAE,4BAA4B,CAAA;IACpC,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAA;CACb,CAAC,CAAA;AAEF,0EAA0E;AAC1E,MAAM,MAAM,4BAA4B,GAAG,QAAQ,CACjD,MAAM,CAAC,wBAAwB,EAAE,2BAA2B,CAAC,CAC9D,CAAA;AAED,eAAO,MAAM,+BAA+B,KAAK,CAAA;AACjD,eAAO,MAAM,+BAA+B,KAAK,CAAA;AAEjD,+DAA+D;AAC/D,eAAO,MAAM,uCAAuC,EAAE,4BAI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,MAAM,+BAA+B,KAAK,CAAA;AACjD,eAAO,MAAM,+BAA+B,KAAK,CAAA;AAEjD,+DAA+D;AAC/D,eAAO,MAAM,uCAAuC,EAAE,4BAIpD,CAAA;AAEF,MAAM,MAAM,sCAAsC,GAAG,QAAQ,CAAC;IAC5D,QAAQ,EAAE,4BAA4B,CAAA;IACtC,iFAAiF;IACjF,aAAa,EAAE,SAAS,wBAAwB,EAAE,CAAA;CACnD,CAAC,CAAA;AAqEF,oFAAoF;AACpF,wBAAgB,iCAAiC,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAQ1F;AAED;;;;;;;GAOG;AACH,wBAAgB,qCAAqC,CACnD,KAAK,EAAE,OAAO,EACd,cAAc,CAAC,EAAE,OAAO,GACvB,sCAAsC,CA+CxC;AAED;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,iBAAiB,GAAG,cAAc,GAAG,OAAO,CAAC,EACrE,KAAK,EAAE,OAAO,GACb,sCAAsC,CAsBxC;AAED;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,MAAM,EAAE,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM,CAajG"}
@@ -1 +1 @@
1
- {"version":3,"file":"appearance-font-settings.js","names":[],"sources":["../../src/lib/appearance-font-settings.ts"],"sourcesContent":["import { fontOptions, type FontOption } from '#lib/font-catalog'\nimport { safeScriptStringLiteral } from '#lib/safe-script'\n\nexport const APPEARANCE_EDITOR_FONT_AXES = ['ui', 'content', 'code'] as const\n\nexport type AppearanceEditorFontAxis = (typeof APPEARANCE_EDITOR_FONT_AXES)[number]\nexport type AppearanceEditorFontFamilyId = FontOption['id']\n\nexport type AppearanceEditorFontSetting = Readonly<{\n /** A stable id from the shared font catalogue, never a CSS family string. */\n family: AppearanceEditorFontFamilyId\n /** A pixel size, normalized to the supported range. */\n size: number\n}>\n\n/** The host-owned choices edited by the shared appearance composition. */\nexport type AppearanceEditorFontSettings = Readonly<\n Record<AppearanceEditorFontAxis, AppearanceEditorFontSetting>\n>\n\nexport const APPEARANCE_EDITOR_FONT_SIZE_MIN = 10\nexport const APPEARANCE_EDITOR_FONT_SIZE_MAX = 32\n\n/** New preferences use the platform face in each text role. */\nexport const DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS: AppearanceEditorFontSettings = Object.freeze({\n ui: Object.freeze({ family: 'system', size: 14 }),\n content: Object.freeze({ family: 'system', size: 14 }),\n code: Object.freeze({ family: 'system', size: 12 }),\n})\n\nexport type NormalizedAppearanceEditorFontSettings = Readonly<{\n settings: AppearanceEditorFontSettings\n /** Axes whose persisted family or size was unavailable or outside its limits. */\n recoveredAxes: readonly AppearanceEditorFontAxis[]\n}>\n\nconst fontFamilyIds: ReadonlySet<string> = new Set(fontOptions.map((option) => option.id))\nconst fontOptionsById = Object.freeze(\n Object.fromEntries(fontOptions.map((option) => [option.id, option])) as Record<\n AppearanceEditorFontFamilyId,\n FontOption\n >\n)\nconst fontProjectionById = Object.freeze(\n Object.fromEntries(\n fontOptions.map((option) => [\n option.id,\n {\n familyVariables: option.familyVariables,\n uiTracking: option.uiTracking,\n uiWordSpacing: option.uiWordSpacing,\n },\n ])\n ) as Record<\n AppearanceEditorFontFamilyId,\n Pick<FontOption, 'familyVariables' | 'uiTracking' | 'uiWordSpacing'>\n >\n)\nconst fontAxisProjection = Object.freeze({\n ui: Object.freeze({\n familyAttribute: 'data-ui-font',\n familyProperty: '--font-ui',\n sizeProperty: '--font-ui-size',\n scaleProperty: '--font-ui-scale',\n defaultSize: DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS.ui.size,\n }),\n content: Object.freeze({\n familyAttribute: 'data-content-font',\n familyProperty: '--font-content',\n sizeProperty: '--font-content-size',\n scaleProperty: '--font-content-scale',\n defaultSize: DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS.content.size,\n }),\n code: Object.freeze({\n familyAttribute: 'data-code-font',\n familyProperty: '--font-code',\n sizeProperty: '--font-code-size',\n scaleProperty: '--font-code-scale',\n defaultSize: DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS.code.size,\n }),\n})\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction hasOwn(value: Record<string, unknown>, key: string): boolean {\n return Object.prototype.hasOwnProperty.call(value, key)\n}\n\nfunction normalizeFamily(value: unknown): AppearanceEditorFontFamilyId | undefined {\n return typeof value === 'string' && fontFamilyIds.has(value)\n ? (value as AppearanceEditorFontFamilyId)\n : undefined\n}\n\nfunction clampFontSize(value: number): number {\n return Math.min(\n APPEARANCE_EDITOR_FONT_SIZE_MAX,\n Math.max(APPEARANCE_EDITOR_FONT_SIZE_MIN, Math.round(value))\n )\n}\n\n/** Normalize a single number-input value; invalid edits return the current size. */\nexport function normalizeAppearanceEditorFontSize(value: unknown, fallback: number): number {\n const parsed =\n typeof value === 'number'\n ? value\n : typeof value === 'string' && value.trim() !== ''\n ? Number(value)\n : Number.NaN\n return Number.isFinite(parsed) ? clampFontSize(parsed) : clampFontSize(fallback)\n}\n\n/**\n * Recover persisted font choices against the shared font catalogue.\n *\n * `legacyUiFamily` lets a host migrate its previous single font field into the\n * UI axis. Content and code remain on the new System defaults during that\n * migration. Missing settings are ordinary defaults; an unknown saved id or an\n * invalid size is reported through `recoveredAxes` for the host's notice.\n */\nexport function normalizeAppearanceEditorFontSettings(\n value: unknown,\n legacyUiFamily?: unknown\n): NormalizedAppearanceEditorFontSettings {\n const source = isRecord(value) ? value : undefined\n const malformedRoot = value !== undefined && value !== null && source === undefined\n const recovered = new Set<AppearanceEditorFontAxis>()\n const settings = {} as Record<AppearanceEditorFontAxis, AppearanceEditorFontSetting>\n\n for (const axis of APPEARANCE_EDITOR_FONT_AXES) {\n const axisPresent = source ? hasOwn(source, axis) : false\n const axisValue = source?.[axis]\n const axisSource = isRecord(axisValue) ? axisValue : undefined\n const fallback = DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS[axis]\n\n if (malformedRoot || (axisPresent && axisSource === undefined)) recovered.add(axis)\n\n const hasFamily = axisSource ? hasOwn(axisSource, 'family') : false\n const familyInput = hasFamily\n ? axisSource?.['family']\n : axis === 'ui' && legacyUiFamily !== undefined\n ? legacyUiFamily\n : undefined\n const family = normalizeFamily(familyInput) ?? fallback.family\n if (\n (hasFamily || (axis === 'ui' && legacyUiFamily !== undefined)) &&\n !normalizeFamily(familyInput)\n ) {\n recovered.add(axis)\n }\n\n const hasSize = axisSource ? hasOwn(axisSource, 'size') : false\n const sizeInput = axisSource?.['size']\n const size = hasSize\n ? normalizeAppearanceEditorFontSize(sizeInput, fallback.size)\n : fallback.size\n if (\n hasSize &&\n (typeof sizeInput !== 'number' || !Number.isFinite(sizeInput) || sizeInput !== size)\n ) {\n recovered.add(axis)\n }\n\n settings[axis] = Object.freeze({ family, size })\n }\n\n return Object.freeze({\n settings: Object.freeze(settings),\n recoveredAxes: Object.freeze(APPEARANCE_EDITOR_FONT_AXES.filter((axis) => recovered.has(axis))),\n })\n}\n\n/**\n * Project normalized font preferences onto a document root.\n *\n * This is shared by `ThemeProvider` and hosts that own their own appearance\n * persistence, so UI/content/code use the same catalogue ids, theme tokens,\n * sizes, and projected CSS variables. The marker activates the optional role\n * stylesheet and survives CSS import reordering.\n */\nexport function applyAppearanceFontSettings(\n root: HTMLElement,\n value: unknown\n): NormalizedAppearanceEditorFontSettings {\n const normalized = normalizeAppearanceEditorFontSettings(value)\n const { settings } = normalized\n\n root.removeAttribute('data-font')\n root.setAttribute('data-font-settings', '')\n for (const axis of APPEARANCE_EDITOR_FONT_AXES) {\n const projection = fontAxisProjection[axis]\n const setting = settings[axis]\n const option = fontOptionsById[setting.family]\n if (setting.family === 'system') root.removeAttribute(projection.familyAttribute)\n else root.setAttribute(projection.familyAttribute, setting.family)\n root.style.setProperty(projection.familyProperty, `var(${option.familyVariables[axis]})`)\n root.style.setProperty(projection.sizeProperty, String(setting.size) + 'px')\n root.style.setProperty(projection.scaleProperty, String(setting.size / projection.defaultSize))\n if (axis === 'ui') {\n root.style.setProperty('--ui-tracking', option.uiTracking)\n root.style.setProperty('--ui-word-spacing', option.uiWordSpacing)\n }\n }\n\n return normalized\n}\n\n/**\n * Generate a safe inline prepaint script for a host-owned appearance record.\n *\n * The stored object is read from `localStorage[storageKey].fonts`. A legacy\n * top-level `font` family migrates into UI only; content/code use the shared\n * defaults. The script applies the same catalogue whitelist, limits, attributes,\n * and CSS properties as `applyAppearanceFontSettings` before styles paint. When\n * `persistedVersion` is supplied, only a record with that exact top-level version\n * is used; absent or mismatched records receive the System defaults.\n */\nexport function fontSettingsBootstrapScript(storageKey: string, persistedVersion?: number): string {\n if (persistedVersion !== undefined && !Number.isSafeInteger(persistedVersion)) {\n throw new RangeError('persistedVersion must be a safe integer')\n }\n const axisConfig = JSON.stringify(fontAxisProjection)\n const fontProjection = JSON.stringify(fontProjectionById)\n const fontIds = `[${fontOptions.map((option) => safeScriptStringLiteral(option.id)).join(',')}]`\n const persistedVersionGuard =\n persistedVersion === undefined\n ? ''\n : `&&parsed.version===Number(${safeScriptStringLiteral(String(persistedVersion))})`\n\n return `(function(){var r=document.documentElement;var axes=JSON.parse(${safeScriptStringLiteral(axisConfig)});var projection=JSON.parse(${safeScriptStringLiteral(fontProjection)});var ids=${fontIds};var has=function(v,k){return Object.prototype.hasOwnProperty.call(v,k)};var record=function(v){return typeof v==='object'&&v!==null&&!Array.isArray(v)};var p={};try{var raw=localStorage.getItem(${safeScriptStringLiteral(storageKey)});var parsed=raw?JSON.parse(raw):{};if(record(parsed)${persistedVersionGuard})p=parsed;}catch(e){}var saved=record(p.fonts)?p.fonts:{};var valid=function(v,d){return ids.indexOf(v)!==-1?v:d};var size=function(v,d){var n=typeof v==='number'?v:typeof v==='string'&&v.trim()!==''?Number(v):NaN;return Number.isFinite(n)?Math.min(${APPEARANCE_EDITOR_FONT_SIZE_MAX},Math.max(${APPEARANCE_EDITOR_FONT_SIZE_MIN},Math.round(n))):d};r.setAttribute('data-font-settings','');for(var axis in axes){if(!has(axes,axis))continue;var spec=axes[axis];var candidate=saved[axis];var value=record(candidate)?candidate:{};var legacyUi=axis==='ui'&&!has(value,'family');var family=legacyUi?valid(p.font,'system'):valid(value.family,'system');var font=projection[family];if(family==='system')r.removeAttribute(spec.familyAttribute);else r.setAttribute(spec.familyAttribute,family);r.style.setProperty(spec.familyProperty,'var('+font.familyVariables[axis]+')');var px=size(value.size,spec.defaultSize);r.style.setProperty(spec.sizeProperty,px+'px');r.style.setProperty(spec.scaleProperty,String(px/spec.defaultSize));if(axis==='ui'){r.style.setProperty('--ui-tracking',font.uiTracking);r.style.setProperty('--ui-word-spacing',font.uiWordSpacing);}}r.removeAttribute('data-font');})();`\n}\n"],"mappings":";;;AAGA,IAAa,8BAA8B;CAAC;CAAM;CAAW;AAAM;AAiBnE,IAAa,kCAAkC;AAC/C,IAAa,kCAAkC;;AAG/C,IAAa,0CAAwE,OAAO,OAAO;CACjG,IAAI,OAAO,OAAO;EAAE,QAAQ;EAAU,MAAM;CAAG,CAAC;CAChD,SAAS,OAAO,OAAO;EAAE,QAAQ;EAAU,MAAM;CAAG,CAAC;CACrD,MAAM,OAAO,OAAO;EAAE,QAAQ;EAAU,MAAM;CAAG,CAAC;AACpD,CAAC;AAQD,IAAM,gBAAqC,IAAI,IAAI,YAAY,KAAK,WAAW,OAAO,EAAE,CAAC;AACzF,IAAM,kBAAkB,OAAO,OAC7B,OAAO,YAAY,YAAY,KAAK,WAAW,CAAC,OAAO,IAAI,MAAM,CAAC,CAAC,CAIrE;AACA,IAAM,qBAAqB,OAAO,OAChC,OAAO,YACL,YAAY,KAAK,WAAW,CAC1B,OAAO,IACP;CACE,iBAAiB,OAAO;CACxB,YAAY,OAAO;CACnB,eAAe,OAAO;AACxB,CACF,CAAC,CACH,CAIF;AACA,IAAM,qBAAqB,OAAO,OAAO;CACvC,IAAI,OAAO,OAAO;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WAAW,iBAAiB,QAAQ,MAAM;EACjE,KAAK,MAAM,YAAY,WAAW,gBAAgB,OAAO,OAAO,gBAAgB,MAAM,EAAE;EACxF,KAAK,MAAM,YAAY,WAAW,cAAc,OAAO,QAAQ,IAAI,IAAI,IAAI;EAC3E,KAAK,MAAM,YAAY,WAAW,eAAe,OAAO,QAAQ,OAAO,WAAW,WAAW,CAAC;EAC9F,IAAI,SAAS,MAAM;GACjB,KAAK,MAAM,YAAY,iBAAiB,OAAO,UAAU;GACzD,KAAK,MAAM,YAAY,qBAAqB,OAAO,aAAa;EAClE;CACF;CAEA,OAAO;AACT;;;;;;;;;;;AAYA,SAAgB,4BAA4B,YAAoB,kBAAmC;CACjG,IAAI,qBAAqB,KAAA,KAAa,CAAC,OAAO,cAAc,gBAAgB,GAC1E,MAAM,IAAI,WAAW,yCAAyC;CAEhE,MAAM,aAAa,KAAK,UAAU,kBAAkB;CACpD,MAAM,iBAAiB,KAAK,UAAU,kBAAkB;CACxD,MAAM,UAAU,IAAI,YAAY,KAAK,WAAW,wBAAwB,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;CAC9F,MAAM,wBACJ,qBAAqB,KAAA,IACjB,KACA,6BAA6B,wBAAwB,OAAO,gBAAgB,CAAC,EAAE;CAErF,OAAO,kEAAkE,wBAAwB,UAAU,EAAE,8BAA8B,wBAAwB,cAAc,EAAE,YAAY,QAAQ,qMAAqM,wBAAwB,UAAU,EAAE,uDAAuD,sBAAsB;AAC/f"}
1
+ {"version":3,"file":"appearance-font-settings.js","names":[],"sources":["../../src/lib/appearance-font-settings.ts"],"sourcesContent":["import { fontOptions, type FontOption } from '#lib/font-catalog'\nimport { safeScriptStringLiteral } from '#lib/safe-script'\n\nexport const APPEARANCE_EDITOR_FONT_AXES = ['ui', 'content', 'code'] as const\n\nexport type AppearanceEditorFontAxis = (typeof APPEARANCE_EDITOR_FONT_AXES)[number]\nexport type AppearanceEditorFontFamilyId = FontOption['id']\n\nexport type AppearanceEditorFontSetting = Readonly<{\n /** A stable id from the shared font catalogue, never a CSS family string. */\n family: AppearanceEditorFontFamilyId\n /** A pixel size, normalized to the supported range. */\n size: number\n}>\n\n/** The host-owned choices edited by the shared appearance composition. */\nexport type AppearanceEditorFontSettings = Readonly<\n Record<AppearanceEditorFontAxis, AppearanceEditorFontSetting>\n>\n\nexport const APPEARANCE_EDITOR_FONT_SIZE_MIN = 10\nexport const APPEARANCE_EDITOR_FONT_SIZE_MAX = 32\n\n/** New preferences use the platform face in each text role. */\nexport const DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS: AppearanceEditorFontSettings = Object.freeze({\n ui: Object.freeze({ family: 'system', size: 14 }),\n content: Object.freeze({ family: 'system', size: 14 }),\n code: Object.freeze({ family: 'system', size: 12 }),\n})\n\nexport type NormalizedAppearanceEditorFontSettings = Readonly<{\n settings: AppearanceEditorFontSettings\n /** Axes whose persisted family or size was unavailable or outside its limits. */\n recoveredAxes: readonly AppearanceEditorFontAxis[]\n}>\n\nconst fontFamilyIds: ReadonlySet<string> = new Set(fontOptions.map((option) => option.id))\nconst fontOptionsById = Object.freeze(\n Object.fromEntries(fontOptions.map((option) => [option.id, option])) as Record<\n AppearanceEditorFontFamilyId,\n FontOption\n >\n)\nconst fontProjectionById = Object.freeze(\n Object.fromEntries(\n fontOptions.map((option) => [\n option.id,\n {\n familyVariables: option.familyVariables,\n uiTracking: option.uiTracking,\n uiWordSpacing: option.uiWordSpacing,\n },\n ])\n ) as Record<\n AppearanceEditorFontFamilyId,\n Pick<FontOption, 'familyVariables' | 'uiTracking' | 'uiWordSpacing'>\n >\n)\nconst fontAxisProjection = Object.freeze({\n ui: Object.freeze({\n familyAttribute: 'data-ui-font',\n familyProperty: '--font-ui',\n sizeProperty: '--font-ui-size',\n scaleProperty: '--font-ui-scale',\n defaultSize: DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS.ui.size,\n }),\n content: Object.freeze({\n familyAttribute: 'data-content-font',\n familyProperty: '--font-content',\n sizeProperty: '--font-content-size',\n scaleProperty: '--font-content-scale',\n defaultSize: DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS.content.size,\n }),\n code: Object.freeze({\n familyAttribute: 'data-code-font',\n familyProperty: '--font-code',\n sizeProperty: '--font-code-size',\n scaleProperty: '--font-code-scale',\n defaultSize: DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS.code.size,\n }),\n})\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction hasOwn(value: Record<string, unknown>, key: string): boolean {\n return Object.prototype.hasOwnProperty.call(value, key)\n}\n\nfunction normalizeFamily(value: unknown): AppearanceEditorFontFamilyId | undefined {\n return typeof value === 'string' && fontFamilyIds.has(value)\n ? (value as AppearanceEditorFontFamilyId)\n : undefined\n}\n\nfunction clampFontSize(value: number): number {\n return Math.min(\n APPEARANCE_EDITOR_FONT_SIZE_MAX,\n Math.max(APPEARANCE_EDITOR_FONT_SIZE_MIN, Math.round(value))\n )\n}\n\n/** Normalize a single number-input value; invalid edits return the current size. */\nexport function normalizeAppearanceEditorFontSize(value: unknown, fallback: number): number {\n const parsed =\n typeof value === 'number'\n ? value\n : typeof value === 'string' && value.trim() !== ''\n ? Number(value)\n : Number.NaN\n return Number.isFinite(parsed) ? clampFontSize(parsed) : clampFontSize(fallback)\n}\n\n/**\n * Recover persisted font choices against the shared font catalogue.\n *\n * `legacyUiFamily` lets a host migrate its previous single font field into the\n * UI axis. Content and code remain on the new System defaults during that\n * migration. Missing settings are ordinary defaults; an unknown saved id or an\n * invalid size is reported through `recoveredAxes` for the host's notice.\n */\nexport function normalizeAppearanceEditorFontSettings(\n value: unknown,\n legacyUiFamily?: unknown\n): NormalizedAppearanceEditorFontSettings {\n const source = isRecord(value) ? value : undefined\n const malformedRoot = value !== undefined && value !== null && source === undefined\n const recovered = new Set<AppearanceEditorFontAxis>()\n const settings = {} as Record<AppearanceEditorFontAxis, AppearanceEditorFontSetting>\n\n for (const axis of APPEARANCE_EDITOR_FONT_AXES) {\n const axisPresent = source ? hasOwn(source, axis) : false\n const axisValue = source?.[axis]\n const axisSource = isRecord(axisValue) ? axisValue : undefined\n const fallback = DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS[axis]\n\n if (malformedRoot || (axisPresent && axisSource === undefined)) recovered.add(axis)\n\n const hasFamily = axisSource ? hasOwn(axisSource, 'family') : false\n const familyInput = hasFamily\n ? axisSource?.['family']\n : axis === 'ui' && legacyUiFamily !== undefined\n ? legacyUiFamily\n : undefined\n const family = normalizeFamily(familyInput) ?? fallback.family\n if (\n (hasFamily || (axis === 'ui' && legacyUiFamily !== undefined)) &&\n !normalizeFamily(familyInput)\n ) {\n recovered.add(axis)\n }\n\n const hasSize = axisSource ? hasOwn(axisSource, 'size') : false\n const sizeInput = axisSource?.['size']\n const size = hasSize\n ? normalizeAppearanceEditorFontSize(sizeInput, fallback.size)\n : fallback.size\n if (\n hasSize &&\n (typeof sizeInput !== 'number' || !Number.isFinite(sizeInput) || sizeInput !== size)\n ) {\n recovered.add(axis)\n }\n\n settings[axis] = Object.freeze({ family, size })\n }\n\n return Object.freeze({\n settings: Object.freeze(settings),\n recoveredAxes: Object.freeze(APPEARANCE_EDITOR_FONT_AXES.filter((axis) => recovered.has(axis))),\n })\n}\n\n/**\n * Project normalized font preferences onto a document root.\n *\n * This is shared by `ThemeProvider` and hosts that own their own appearance\n * persistence, so UI/content/code use the same catalogue ids, theme tokens,\n * sizes, and projected CSS variables. The marker activates the optional role\n * stylesheet and survives CSS import reordering.\n */\nexport function applyAppearanceFontSettings(\n root: Pick<HTMLElement, 'removeAttribute' | 'setAttribute' | 'style'>,\n value: unknown\n): NormalizedAppearanceEditorFontSettings {\n const normalized = normalizeAppearanceEditorFontSettings(value)\n const { settings } = normalized\n\n root.removeAttribute('data-font')\n root.setAttribute('data-font-settings', '')\n for (const axis of APPEARANCE_EDITOR_FONT_AXES) {\n const projection = fontAxisProjection[axis]\n const setting = settings[axis]\n const option = fontOptionsById[setting.family]\n if (setting.family === 'system') root.removeAttribute(projection.familyAttribute)\n else root.setAttribute(projection.familyAttribute, setting.family)\n root.style.setProperty(projection.familyProperty, `var(${option.familyVariables[axis]})`)\n root.style.setProperty(projection.sizeProperty, String(setting.size) + 'px')\n root.style.setProperty(projection.scaleProperty, String(setting.size / projection.defaultSize))\n if (axis === 'ui') {\n root.style.setProperty('--ui-tracking', option.uiTracking)\n root.style.setProperty('--ui-word-spacing', option.uiWordSpacing)\n }\n }\n\n return normalized\n}\n\n/**\n * Generate a safe inline prepaint script for a host-owned appearance record.\n *\n * The stored object is read from `localStorage[storageKey].fonts`. A legacy\n * top-level `font` family migrates into UI only; content/code use the shared\n * defaults. The script applies the same catalogue whitelist, limits, attributes,\n * and CSS properties as `applyAppearanceFontSettings` before styles paint. When\n * `persistedVersion` is supplied, only a record with that exact top-level version\n * is used; absent or mismatched records receive the System defaults.\n */\nexport function fontSettingsBootstrapScript(storageKey: string, persistedVersion?: number): string {\n if (persistedVersion !== undefined && !Number.isSafeInteger(persistedVersion)) {\n throw new RangeError('persistedVersion must be a safe integer')\n }\n const axisConfig = JSON.stringify(fontAxisProjection)\n const fontProjection = JSON.stringify(fontProjectionById)\n const fontIds = `[${fontOptions.map((option) => safeScriptStringLiteral(option.id)).join(',')}]`\n const persistedVersionGuard =\n persistedVersion === undefined\n ? ''\n : `&&parsed.version===Number(${safeScriptStringLiteral(String(persistedVersion))})`\n\n return `(function(){var r=document.documentElement;var axes=JSON.parse(${safeScriptStringLiteral(axisConfig)});var projection=JSON.parse(${safeScriptStringLiteral(fontProjection)});var ids=${fontIds};var has=function(v,k){return Object.prototype.hasOwnProperty.call(v,k)};var record=function(v){return typeof v==='object'&&v!==null&&!Array.isArray(v)};var p={};try{var raw=localStorage.getItem(${safeScriptStringLiteral(storageKey)});var parsed=raw?JSON.parse(raw):{};if(record(parsed)${persistedVersionGuard})p=parsed;}catch(e){}var saved=record(p.fonts)?p.fonts:{};var valid=function(v,d){return ids.indexOf(v)!==-1?v:d};var size=function(v,d){var n=typeof v==='number'?v:typeof v==='string'&&v.trim()!==''?Number(v):NaN;return Number.isFinite(n)?Math.min(${APPEARANCE_EDITOR_FONT_SIZE_MAX},Math.max(${APPEARANCE_EDITOR_FONT_SIZE_MIN},Math.round(n))):d};r.setAttribute('data-font-settings','');for(var axis in axes){if(!has(axes,axis))continue;var spec=axes[axis];var candidate=saved[axis];var value=record(candidate)?candidate:{};var legacyUi=axis==='ui'&&!has(value,'family');var family=legacyUi?valid(p.font,'system'):valid(value.family,'system');var font=projection[family];if(family==='system')r.removeAttribute(spec.familyAttribute);else r.setAttribute(spec.familyAttribute,family);r.style.setProperty(spec.familyProperty,'var('+font.familyVariables[axis]+')');var px=size(value.size,spec.defaultSize);r.style.setProperty(spec.sizeProperty,px+'px');r.style.setProperty(spec.scaleProperty,String(px/spec.defaultSize));if(axis==='ui'){r.style.setProperty('--ui-tracking',font.uiTracking);r.style.setProperty('--ui-word-spacing',font.uiWordSpacing);}}r.removeAttribute('data-font');})();`\n}\n"],"mappings":";;;AAGA,IAAa,8BAA8B;CAAC;CAAM;CAAW;AAAM;AAiBnE,IAAa,kCAAkC;AAC/C,IAAa,kCAAkC;;AAG/C,IAAa,0CAAwE,OAAO,OAAO;CACjG,IAAI,OAAO,OAAO;EAAE,QAAQ;EAAU,MAAM;CAAG,CAAC;CAChD,SAAS,OAAO,OAAO;EAAE,QAAQ;EAAU,MAAM;CAAG,CAAC;CACrD,MAAM,OAAO,OAAO;EAAE,QAAQ;EAAU,MAAM;CAAG,CAAC;AACpD,CAAC;AAQD,IAAM,gBAAqC,IAAI,IAAI,YAAY,KAAK,WAAW,OAAO,EAAE,CAAC;AACzF,IAAM,kBAAkB,OAAO,OAC7B,OAAO,YAAY,YAAY,KAAK,WAAW,CAAC,OAAO,IAAI,MAAM,CAAC,CAAC,CAIrE;AACA,IAAM,qBAAqB,OAAO,OAChC,OAAO,YACL,YAAY,KAAK,WAAW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C,MAAM,aAAa,mBAAmB;EACtC,MAAM,UAAU,SAAS;EACzB,MAAM,SAAS,gBAAgB,QAAQ;EACvC,IAAI,QAAQ,WAAW,UAAU,KAAK,gBAAgB,WAAW,eAAe;OAC3E,KAAK,aAAa,WAAW,iBAAiB,QAAQ,MAAM;EACjE,KAAK,MAAM,YAAY,WAAW,gBAAgB,OAAO,OAAO,gBAAgB,MAAM,EAAE;EACxF,KAAK,MAAM,YAAY,WAAW,cAAc,OAAO,QAAQ,IAAI,IAAI,IAAI;EAC3E,KAAK,MAAM,YAAY,WAAW,eAAe,OAAO,QAAQ,OAAO,WAAW,WAAW,CAAC;EAC9F,IAAI,SAAS,MAAM;GACjB,KAAK,MAAM,YAAY,iBAAiB,OAAO,UAAU;GACzD,KAAK,MAAM,YAAY,qBAAqB,OAAO,aAAa;EAClE;CACF;CAEA,OAAO;AACT;;;;;;;;;;;AAYA,SAAgB,4BAA4B,YAAoB,kBAAmC;CACjG,IAAI,qBAAqB,KAAA,KAAa,CAAC,OAAO,cAAc,gBAAgB,GAC1E,MAAM,IAAI,WAAW,yCAAyC;CAEhE,MAAM,aAAa,KAAK,UAAU,kBAAkB;CACpD,MAAM,iBAAiB,KAAK,UAAU,kBAAkB;CACxD,MAAM,UAAU,IAAI,YAAY,KAAK,WAAW,wBAAwB,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;CAC9F,MAAM,wBACJ,qBAAqB,KAAA,IACjB,KACA,6BAA6B,wBAAwB,OAAO,gBAAgB,CAAC,EAAE;CAErF,OAAO,kEAAkE,wBAAwB,UAAU,EAAE,8BAA8B,wBAAwB,cAAc,EAAE,YAAY,QAAQ,qMAAqM,wBAAwB,UAAU,EAAE,uDAAuD,sBAAsB;AAC/f"}
@@ -147,7 +147,26 @@ export type ThemeVariant = {
147
147
  /** The categorical series, in order. */
148
148
  chart: readonly string[];
149
149
  provenance: ThemeProvenance;
150
+ /**
151
+ * Custom properties written verbatim over {@link themeCssVariables}, last.
152
+ *
153
+ * For a variant a host built from data it does not control the derivation of —
154
+ * an imported theme whose painted colours must stay exactly what the user
155
+ * imported. The catalogue's own variants never carry it, so the derived roles
156
+ * stay the only source of truth for them.
157
+ */
158
+ tokens?: Readonly<Record<string, string>>;
150
159
  };
160
+ /**
161
+ * The design system's view of one catalogue record, built in full and at once.
162
+ *
163
+ * For a host that holds a record the catalogue does not — an imported theme, a
164
+ * reconstruction from stored data — and wants a variant it can hand to
165
+ * `ThemeProvider`'s `themes`. It throws for a record the shadcn projection cannot
166
+ * map, here and now, rather than on first paint. The catalogue itself goes through
167
+ * {@link lazyVariant} instead.
168
+ */
169
+ export declare function variantFromRecord(theme: AdeaThemeRecord): ThemeVariant;
151
170
  /**
152
171
  * A variant's `--primary-subtle`: the tint over `var(--primary)` at the strength its
153
172
  * catalogue record measures (`primarySubtleAlpha`). A variant that is not in the
@@ -157,6 +176,24 @@ export declare function primarySubtleFor(theme: Pick<ThemeVariant, 'id' | 'appea
157
176
  /** The catalogue, in catalogue order. */
158
177
  export declare const builtinThemes: readonly ThemeVariant[];
159
178
  export declare function themeById(id: string): ThemeVariant | undefined;
179
+ /**
180
+ * The variant a stored id means, or the default of the same appearance.
181
+ *
182
+ * An id the registry does not hold — an imported theme that was deleted, a
183
+ * catalogue entry that was renamed — must still paint *something of the appearance
184
+ * being shown*. Falling back to whichever variant happens to be first in the
185
+ * registry painted a dark palette under a light `color-scheme` for a light id, so
186
+ * the fallback is the appearance's own default, then any variant of that
187
+ * appearance, then the registry's first entry only when it holds nothing else.
188
+ *
189
+ * `registry` is the builtin catalogue plus whatever extras the host supplies; the
190
+ * stored id is never rewritten, only resolved, so a host that keeps an unknown id
191
+ * keeps resolving it if the theme comes back.
192
+ *
193
+ * The fallback order is translated from Zeron's `ThemeRegistry::resolve` (MIT,
194
+ * Copyright (c) 2026 Wing); see NOTICE.
195
+ */
196
+ export declare function resolveVariant(registry: readonly ThemeVariant[], id: string, appearance: ThemeAppearance): ThemeVariant;
160
197
  /** The variants of one appearance, which is what a picker for that mode shows. */
161
198
  export declare function themesForAppearance(appearance: ThemeAppearance): readonly ThemeVariant[];
162
199
  /** The families in the catalogue, in catalogue order. */
@@ -262,6 +299,17 @@ export declare function accentVariables(accentId: string, appearance: ThemeAppea
262
299
  * than separate roles, which is why they are built here and not in the catalogue.
263
300
  */
264
301
  export declare function themeCssVariables(theme: ThemeVariant): Record<string, string>;
302
+ /**
303
+ * Token values with every `oklch()` colour written as `#rrggbb`.
304
+ *
305
+ * For a host whose stylesheet, tests or native shell speak hex: the catalogue's
306
+ * roles are `oklch()` strings, and this is the one conversion, gamut-mapped by the
307
+ * catalogue's own `oklchToHex`. A value that is already hex, carries alpha
308
+ * (`rgba()`), or is not a plain colour (`color-mix()`, `var()`) is left byte for
309
+ * byte, because converting would either lose the alpha or be a guess. Suitable as
310
+ * `ThemeProvider`'s `transformTokens`.
311
+ */
312
+ export declare function tokensAsHex(tokens: Readonly<Record<string, string>>): Record<string, string>;
265
313
  export type ThemeFinding = {
266
314
  themeId: string;
267
315
  role: string;
@@ -1 +1 @@
1
- {"version":3,"file":"themes.d.ts","sourceRoot":"","sources":["../../src/lib/themes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAkBL,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,eAAe,EAErB,MAAM,iBAAiB,CAAA;AAIxB,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,MAAM,CAAA;AAE9C;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,cAAc,EAAE,MAAM,CAAA;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,iBAAiB,EAAE,MAAM,CAAA;IACzB,OAAO,E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,CAAA;CACf,GAAG;IAAE,UAAU,EAAE,eAAe,CAAC;IAAC,SAAS,EAAE,eAAe,CAAA;CAAE,CAI9D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,eAAe,EAC3B,IAAI,GAAE;IAAE,YAAY,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAGhD,GACA,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAmBpC;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA8G7E;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAU5F;AAUD,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAMD,+FAA+F;AAC/F,wBAAgB,aAAa,CAAC,KAAK,EAAE,YAAY,GAAG,YAAY,EAAE,CAMjE;AAED,8EAA8E;AAC9E,wBAAgB,qBAAqB,CACnC,MAAM,GAAE,SAAS,YAAY,EAAkB,GAC9C,YAAY,EAAE,CAchB;AAED,eAAO,MAAM,mBAAmB,eAAe,CAAA;AAC/C,eAAO,MAAM,kBAAkB,cAAc,CAAA;AAE7C,kFAAkF;AAClF,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA"}
@@ -1,6 +1,7 @@
1
1
  import { isThemeAccentId } from "./theme-accents.js";
2
2
  import { accentForeground, accentRoles, chartSeries, contrastRatio, getAccent, getTheme, hasTheme, primaryHover, primarySubtleCss, shadcnDestructiveProjection, statusForeground, syntaxRoles, themeAccentPresets, themes, themesByAppearance, tint, validateCatalogue } from "@adea-ai/themes";
3
3
  import { shadcnVariables } from "@adea-ai/themes/adapters/shadcn";
4
+ import { oklchToHex, parseColor } from "@adea-ai/themes/oklch";
4
5
  //#region src/lib/themes.ts
5
6
  /**
6
7
  * The theme registry, now a bridge.
@@ -36,8 +37,13 @@ import { shadcnVariables } from "@adea-ai/themes/adapters/shadcn";
36
37
  * the former, so it goes to `--primary`, and `--accent` is filled from
37
38
  * `surfaceHover`, which is what shadcn components actually use it for.
38
39
  */
39
- /** Builds the design system's view of one catalogue entry. */
40
- function toVariant(theme) {
40
+ /**
41
+ * The shadcn-vocabulary roles of one catalogue entry.
42
+ *
43
+ * The expensive half of a variant: `shadcnVariables` projects the whole palette
44
+ * (about 4 ms a theme), which is why {@link lazyVariant} defers it.
45
+ */
46
+ function colorsOf(theme) {
41
47
  const projected = shadcnVariables(theme);
42
48
  const token = (name) => {
43
49
  const value = projected[`--${name}`];
@@ -45,7 +51,7 @@ function toVariant(theme) {
45
51
  return value;
46
52
  };
47
53
  const destructiveAction = shadcnDestructiveProjection(theme);
48
- const colors = {
54
+ return {
49
55
  background: token("background"),
50
56
  foreground: token("foreground"),
51
57
  card: token("card"),
@@ -83,7 +89,54 @@ function toVariant(theme) {
83
89
  sidebarBorder: token("sidebar-border"),
84
90
  sidebarMutedForeground: token("sidebar-muted-foreground")
85
91
  };
92
+ }
93
+ function terminalOf(theme) {
94
+ return {
95
+ background: theme.colors.background,
96
+ foreground: theme.colors.foreground,
97
+ cursor: theme.cursor,
98
+ selection: theme.selection,
99
+ ...theme.ansi
100
+ };
101
+ }
102
+ function editorOf(theme) {
86
103
  const syntax = syntaxRoles(theme);
104
+ return {
105
+ keyword: syntax.keyword,
106
+ string: syntax.string,
107
+ number: syntax.number,
108
+ comment: syntax.comment,
109
+ function: syntax.function,
110
+ variable: syntax.variable,
111
+ type: syntax.type,
112
+ tag: syntax.tag,
113
+ attribute: syntax.attribute,
114
+ operator: syntax.operator,
115
+ heading: syntax.heading,
116
+ link: syntax.link,
117
+ diffAdd: syntax.diffAdd,
118
+ diffDelete: syntax.diffDelete,
119
+ diffHunk: syntax.diffHunk,
120
+ searchMatch: syntax.searchMatch
121
+ };
122
+ }
123
+ function provenanceOf(theme) {
124
+ return {
125
+ source: theme.provenance.project,
126
+ url: theme.provenance.url,
127
+ license: theme.provenance.license
128
+ };
129
+ }
130
+ /**
131
+ * The design system's view of one catalogue record, built in full and at once.
132
+ *
133
+ * For a host that holds a record the catalogue does not — an imported theme, a
134
+ * reconstruction from stored data — and wants a variant it can hand to
135
+ * `ThemeProvider`'s `themes`. It throws for a record the shadcn projection cannot
136
+ * map, here and now, rather than on first paint. The catalogue itself goes through
137
+ * {@link lazyVariant} instead.
138
+ */
139
+ function variantFromRecord(theme) {
87
140
  return {
88
141
  id: theme.id,
89
142
  family: theme.family,
@@ -91,40 +144,55 @@ function toVariant(theme) {
91
144
  label: theme.label,
92
145
  appearance: theme.appearance,
93
146
  description: theme.description,
94
- colors,
95
- terminal: {
96
- background: theme.colors.background,
97
- foreground: theme.colors.foreground,
98
- cursor: theme.cursor,
99
- selection: theme.selection,
100
- ...theme.ansi
101
- },
102
- editor: {
103
- keyword: syntax.keyword,
104
- string: syntax.string,
105
- number: syntax.number,
106
- comment: syntax.comment,
107
- function: syntax.function,
108
- variable: syntax.variable,
109
- type: syntax.type,
110
- tag: syntax.tag,
111
- attribute: syntax.attribute,
112
- operator: syntax.operator,
113
- heading: syntax.heading,
114
- link: syntax.link,
115
- diffAdd: syntax.diffAdd,
116
- diffDelete: syntax.diffDelete,
117
- diffHunk: syntax.diffHunk,
118
- searchMatch: syntax.searchMatch
119
- },
147
+ colors: colorsOf(theme),
148
+ terminal: terminalOf(theme),
149
+ editor: editorOf(theme),
120
150
  chart: chartSeries(theme),
121
- provenance: {
122
- source: theme.provenance.project,
123
- url: theme.provenance.url,
124
- license: theme.provenance.license
151
+ provenance: provenanceOf(theme)
152
+ };
153
+ }
154
+ /** Runs `build` on first call and returns that value from then on. A throw is not cached. */
155
+ function once(build) {
156
+ let built = false;
157
+ let value;
158
+ return () => {
159
+ if (!built) {
160
+ value = build();
161
+ built = true;
125
162
  }
163
+ return value;
126
164
  };
127
165
  }
166
+ var lazy = (build) => ({
167
+ get: once(build),
168
+ enumerable: true
169
+ });
170
+ /**
171
+ * {@link variantFromRecord} with the four derived palettes built on first read.
172
+ *
173
+ * Evaluating this module used to project all 34 catalogue themes up front, about
174
+ * 155 ms before a single one was needed, on the hydration path of every consumer.
175
+ * A page paints one variant, and a picker's labels and appearance are plain
176
+ * fields, so only a variant whose `colors`, `terminal`, `editor` or `chart` is read
177
+ * pays for them, once. The properties stay enumerable data-shaped accessors, so
178
+ * spreading, `Object.entries` and JSON see the same object they always did.
179
+ */
180
+ function lazyVariant(theme) {
181
+ return Object.defineProperties({
182
+ id: theme.id,
183
+ family: theme.family,
184
+ familyLabel: theme.familyLabel,
185
+ label: theme.label,
186
+ appearance: theme.appearance,
187
+ description: theme.description,
188
+ provenance: provenanceOf(theme)
189
+ }, {
190
+ colors: lazy(() => colorsOf(theme)),
191
+ terminal: lazy(() => terminalOf(theme)),
192
+ editor: lazy(() => editorOf(theme)),
193
+ chart: lazy(() => chartSeries(theme))
194
+ });
195
+ }
128
196
  /**
129
197
  * A variant's `--primary-subtle`: the tint over `var(--primary)` at the strength its
130
198
  * catalogue record measures (`primarySubtleAlpha`). A variant that is not in the
@@ -135,11 +203,34 @@ function primarySubtleFor(theme) {
135
203
  return record ? primarySubtleCss(record) : primarySubtleCss(theme.appearance);
136
204
  }
137
205
  /** The catalogue, in catalogue order. */
138
- var builtinThemes = Object.freeze(themes.map(toVariant));
206
+ var builtinThemes = Object.freeze(themes.map(lazyVariant));
139
207
  function themeById(id) {
140
208
  if (!hasTheme(id)) return void 0;
141
209
  return builtinThemes.find((theme) => theme.id === id);
142
210
  }
211
+ /**
212
+ * The variant a stored id means, or the default of the same appearance.
213
+ *
214
+ * An id the registry does not hold — an imported theme that was deleted, a
215
+ * catalogue entry that was renamed — must still paint *something of the appearance
216
+ * being shown*. Falling back to whichever variant happens to be first in the
217
+ * registry painted a dark palette under a light `color-scheme` for a light id, so
218
+ * the fallback is the appearance's own default, then any variant of that
219
+ * appearance, then the registry's first entry only when it holds nothing else.
220
+ *
221
+ * `registry` is the builtin catalogue plus whatever extras the host supplies; the
222
+ * stored id is never rewritten, only resolved, so a host that keeps an unknown id
223
+ * keeps resolving it if the theme comes back.
224
+ *
225
+ * The fallback order is translated from Zeron's `ThemeRegistry::resolve` (MIT,
226
+ * Copyright (c) 2026 Wing); see NOTICE.
227
+ */
228
+ function resolveVariant(registry, id, appearance) {
229
+ const found = registry.find((variant) => variant.id === id);
230
+ if (found) return found;
231
+ const defaultId = appearance === "dark" ? defaultDarkThemeId : defaultLightThemeId;
232
+ return registry.find((variant) => variant.id === defaultId) ?? registry.find((variant) => variant.appearance === appearance) ?? registry[0];
233
+ }
143
234
  /** The variants of one appearance, which is what a picker for that mode shows. */
144
235
  function themesForAppearance(appearance) {
145
236
  const ids = new Set(themesByAppearance(appearance).map((theme) => theme.id));
@@ -298,7 +389,7 @@ function themeCssVariables(theme) {
298
389
  const c = theme.colors;
299
390
  const t = theme.terminal;
300
391
  const e = theme.editor;
301
- return {
392
+ const derived = {
302
393
  "--background": c.background,
303
394
  "--foreground": c.foreground,
304
395
  "--card": c.card,
@@ -387,6 +478,29 @@ function themeCssVariables(theme) {
387
478
  "--chart-5": theme.chart[4] ?? c.destructive,
388
479
  "--chart-6": theme.chart[5] ?? c.mutedForeground
389
480
  };
481
+ return theme.tokens ? {
482
+ ...derived,
483
+ ...theme.tokens
484
+ } : derived;
485
+ }
486
+ /**
487
+ * Token values with every `oklch()` colour written as `#rrggbb`.
488
+ *
489
+ * For a host whose stylesheet, tests or native shell speak hex: the catalogue's
490
+ * roles are `oklch()` strings, and this is the one conversion, gamut-mapped by the
491
+ * catalogue's own `oklchToHex`. A value that is already hex, carries alpha
492
+ * (`rgba()`), or is not a plain colour (`color-mix()`, `var()`) is left byte for
493
+ * byte, because converting would either lose the alpha or be a guess. Suitable as
494
+ * `ThemeProvider`'s `transformTokens`.
495
+ */
496
+ function tokensAsHex(tokens) {
497
+ const converted = {};
498
+ for (const [name, value] of Object.entries(tokens)) {
499
+ const trimmed = value.trim();
500
+ const parsed = trimmed.startsWith("oklch(") && !trimmed.includes("/") ? parseColor(trimmed) : void 0;
501
+ converted[name] = parsed ? oklchToHex(parsed) : value;
502
+ }
503
+ return converted;
390
504
  }
391
505
  function toFinding(finding) {
392
506
  return {
@@ -417,6 +531,6 @@ function validateThemeRegistry(themes$1 = builtinThemes) {
417
531
  var defaultLightThemeId = "adea-light";
418
532
  var defaultDarkThemeId = "adea-dark";
419
533
  //#endregion
420
- export { accentVariables, appearancePreviewThemes, builtinThemes, contrastRatio, defaultDarkThemeId, defaultLightThemeId, isThemeAccentId, primarySubtleFor, resolveAccentPreset, themeAccentsFor, themeById, themeCssVariables, themeFamilies, themeRecordById, themeRecords, themesForAppearance, validateTheme, validateThemeRegistry, withAccent };
534
+ export { accentVariables, appearancePreviewThemes, builtinThemes, contrastRatio, defaultDarkThemeId, defaultLightThemeId, isThemeAccentId, primarySubtleFor, resolveAccentPreset, resolveVariant, themeAccentsFor, themeById, themeCssVariables, themeFamilies, themeRecordById, themeRecords, themesForAppearance, tokensAsHex, validateTheme, validateThemeRegistry, variantFromRecord, withAccent };
421
535
 
422
536
  //# sourceMappingURL=themes.js.map