@adea-ai/ui 0.151.10 → 0.151.12

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 (67) hide show
  1. package/dist/components/composites/appearance-editor/appearance-rows.d.ts.map +1 -1
  2. package/dist/components/composites/appearance-editor/appearance-rows.js +16 -3
  3. package/dist/components/composites/appearance-editor/appearance-rows.js.map +1 -1
  4. package/dist/components/layout/contextual-sidebar/contextual-sidebar.d.ts +12 -0
  5. package/dist/components/layout/contextual-sidebar/contextual-sidebar.d.ts.map +1 -1
  6. package/dist/components/layout/contextual-sidebar/contextual-sidebar.js +51 -16
  7. package/dist/components/layout/contextual-sidebar/contextual-sidebar.js.map +1 -1
  8. package/dist/components/layout/contextual-sidebar/index.d.ts +1 -1
  9. package/dist/components/layout/contextual-sidebar/index.d.ts.map +1 -1
  10. package/dist/components/layout/shell-top-bar/shell-top-bar.d.ts +16 -10
  11. package/dist/components/layout/shell-top-bar/shell-top-bar.d.ts.map +1 -1
  12. package/dist/components/layout/shell-top-bar/shell-top-bar.js +2 -1
  13. package/dist/components/layout/shell-top-bar/shell-top-bar.js.map +1 -1
  14. package/dist/components/theme/script-projection.d.ts +17 -0
  15. package/dist/components/theme/script-projection.d.ts.map +1 -0
  16. package/dist/components/theme/script-projection.js +16 -0
  17. package/dist/components/theme/script-projection.js.map +1 -0
  18. package/dist/components/theme/theme-document-core.d.ts +5 -4
  19. package/dist/components/theme/theme-document-core.d.ts.map +1 -1
  20. package/dist/components/theme/theme-document-core.js +13 -3
  21. package/dist/components/theme/theme-document-core.js.map +1 -1
  22. package/dist/components/theme/theme-provider-value.d.ts +2 -1
  23. package/dist/components/theme/theme-provider-value.d.ts.map +1 -1
  24. package/dist/components/theme/theme-provider-value.js +7 -0
  25. package/dist/components/theme/theme-provider-value.js.map +1 -1
  26. package/dist/components/theme/theme-script.d.ts +12 -0
  27. package/dist/components/theme/theme-script.d.ts.map +1 -1
  28. package/dist/components/theme/theme-script.js +14 -5
  29. package/dist/components/theme/theme-script.js.map +1 -1
  30. package/dist/components/theme/theme-state-core.d.ts +6 -0
  31. package/dist/components/theme/theme-state-core.d.ts.map +1 -1
  32. package/dist/components/theme/theme-state-core.js.map +1 -1
  33. package/dist/components/theme/token-projection-options.d.ts +3 -0
  34. package/dist/components/theme/token-projection-options.d.ts.map +1 -0
  35. package/dist/components/theme/token-projection-options.js +9 -0
  36. package/dist/components/theme/token-projection-options.js.map +1 -0
  37. package/dist/components/theme/token-projection.d.ts +22 -0
  38. package/dist/components/theme/token-projection.d.ts.map +1 -0
  39. package/dist/components/theme/token-projection.js +1 -0
  40. package/dist/r/appearance-editor.json +1 -1
  41. package/dist/r/lib.json +1 -1
  42. package/dist/r/registry.json +18 -3
  43. package/dist/r/src/components/composites/appearance-editor/appearance-rows.tsx +17 -9
  44. package/dist/r/src/components/layout/contextual-sidebar/contextual-sidebar.tsx +76 -19
  45. package/dist/r/src/components/layout/contextual-sidebar/index.ts +1 -0
  46. package/dist/r/src/components/layout/shell-top-bar/shell-top-bar.tsx +22 -14
  47. package/dist/r/src/components/theme/script-projection.ts +40 -0
  48. package/dist/r/src/components/theme/theme-document-core.ts +17 -4
  49. package/dist/r/src/components/theme/theme-provider-value.ts +11 -1
  50. package/dist/r/src/components/theme/theme-script.ts +52 -4
  51. package/dist/r/src/components/theme/theme-state-core.ts +6 -0
  52. package/dist/r/src/components/theme/token-projection-options.ts +14 -0
  53. package/dist/r/src/components/theme/token-projection.ts +37 -0
  54. package/dist/r/theming.json +16 -1
  55. package/package.json +14 -2
  56. package/registry.json +18 -3
  57. package/src/components/composites/appearance-editor/appearance-rows.tsx +17 -9
  58. package/src/components/layout/contextual-sidebar/contextual-sidebar.tsx +76 -19
  59. package/src/components/layout/contextual-sidebar/index.ts +1 -0
  60. package/src/components/layout/shell-top-bar/shell-top-bar.tsx +22 -14
  61. package/src/components/theme/script-projection.ts +40 -0
  62. package/src/components/theme/theme-document-core.ts +17 -4
  63. package/src/components/theme/theme-provider-value.ts +11 -1
  64. package/src/components/theme/theme-script.ts +52 -4
  65. package/src/components/theme/theme-state-core.ts +6 -0
  66. package/src/components/theme/token-projection-options.ts +14 -0
  67. package/src/components/theme/token-projection.ts +37 -0
@@ -1 +1 @@
1
- {"version":3,"file":"theme-state-core.js","names":[],"sources":["../../../src/components/theme/theme-state-core.ts"],"sourcesContent":["import {\n DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS,\n normalizeAppearanceEditorFontSettings,\n type AppearanceEditorFontSettings,\n} from '#lib/appearance-font-settings'\nimport type { AccentPreset } from '@adea-ai/themes'\nimport { normalizeCustomAccent, type AccentRoles } from '#lib/accent-roles'\nimport { stepAppearanceFontSizes, type FontZoomIntent } from '#lib/font-zoom'\nimport type { ThemeSurface } from '#lib/theme-surface'\nimport { defaultDarkThemeId, defaultLightThemeId, resolveVariant } from '#lib/theme-defaults'\nimport type { ThemeEngine } from '#lib/theme-engine'\nimport type { ThemeAppearance, ThemeVariant } from '#lib/themes'\n\n/**\n * The pure half of the theme provider: what a selection is, how two selections\n * merge, and what a selection resolves to.\n *\n * Nothing here touches the document, storage or a signal, so each rule can be\n * tested by calling it. `ThemeProvider` owns the reactivity and wires these to it;\n * `theme-document.ts` owns the writes; `theme-persistence.ts` owns the store.\n *\n * This is the catalogue-free half: it imports no catalogue code or data, so the lazy\n * provider can use it at start-up. `theme-state.ts` re-exports it and adds\n * {@link accentRolesForState} bound to the full catalogue.\n */\n\n/**\n * Four independent choices, and keeping them independent is the point:\n *\n * - **appearance** — light, dark, or follow the system.\n * - **a theme per appearance** — so a user can run Catppuccin Mocha by night and\n * Solarized Light by day without re-choosing when the system flips.\n * - **an accent** — adea's six presets, or one of the accents the selected theme\n * pair carries itself (`ansi-blue`…), which re-colour the interactive roles on\n * top of whichever theme is active.\n * - **fonts** — separate family and size choices for UI, content and code.\n */\nexport type ThemeSelection = {\n /** `system` follows `prefers-color-scheme` and updates when it changes. */\n appearance: ThemeAppearance | 'system'\n /** The variant to use when the resolved appearance is light. */\n lightThemeId: string\n /** The variant to use when the resolved appearance is dark. */\n darkThemeId: string\n /**\n * An `accentPresets` id, a theme accent id from `themeAccents()` (`ansi-blue`…),\n * `theme` for the variant's own primary, or a custom colour as `#rrggbb`. A theme\n * accent the current pair does not offer falls back to the variant's own primary.\n *\n * A custom colour is stored lower case and is raised to the contrast floor when it\n * is painted, never when it is stored: the selection keeps what the user chose.\n * Anything else that is not an id is dropped at paint, not rejected here.\n */\n accent: string\n /** UI-family alias for consumers of the original single-font preference. */\n font: string\n /** UI, content and code font settings. Omitted legacy records are migrated from `font`. */\n fonts?: AppearanceEditorFontSettings\n /**\n * `comfortable` is the system's default geometry; `compact` moves the control\n * ladder down one rung.\n *\n * Optional, and defaulted on read, so a preference stored before density existed\n * keeps working and `ThemeSelection` stays assignable without it.\n */\n density?: ThemeDensity\n /**\n * The terminal either follows the interface theme (`theme`, or absent) or is pinned\n * to another theme's terminal palette by that theme's id. The pin is written over\n * the interface variant's own `--terminal-*` properties, so a light interface can\n * carry a dark terminal.\n *\n * An id the registry does not hold paints the interface palette and stays in the\n * selection, the same rule as an unknown theme id.\n *\n * Optional and not defaulted: see {@link defaultThemeSelection}.\n */\n terminalThemeId?: string\n /**\n * How opaque elevated panels are. Written to `<html>` only when the provider's\n * `surface` prop is on or this is set; absent, a host paints no surface axis at\n * all. Resolved against the OS and the host's capability before it is painted —\n * see `resolveSurface` — so the value stored is a preference, never the outcome.\n */\n surface?: ThemeSurface\n /**\n * The user's own Reduce Transparency switch, which forces the `opaque` surface the\n * same way the operating system's setting does.\n */\n reduceTransparency?: boolean\n}\n\n/**\n * The two density rungs.\n *\n * `comfortable` is the geometry in `theme.css`, so it is the absence of an\n * attribute rather than a value: a document that ships no `data-density` at all\n * renders correctly, which is what keeps this additive.\n */\nexport type ThemeDensity = 'comfortable' | 'compact'\n\n/**\n * Deliberately lists only the fields every consumer has always had. A field added\n * to {@link ThemeSelection} later gets no default here: `JSON.stringify` drops an\n * `undefined`, so a store written by a consumer that never sets the field stays\n * byte-identical to what it was before the field existed.\n */\nexport const defaultThemeSelection: ThemeSelection = {\n appearance: 'system',\n lightThemeId: defaultLightThemeId,\n darkThemeId: defaultDarkThemeId,\n accent: 'theme',\n font: 'system',\n fonts: DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS,\n density: 'comfortable',\n}\n\n/**\n * A stored selection's density, defaulted.\n *\n * The stored value is read through here rather than trusted, because a preference\n * written before density existed has no `density` key and a hand-edited store may\n * hold anything.\n */\nexport function resolvedDensity(selection: ThemeSelection): ThemeDensity {\n return selection.density === 'compact' ? 'compact' : 'comfortable'\n}\n\nexport type ThemeContextValue = {\n /** The preference as stored. A {@link ThemeContextValue.preview} does not change it. */\n selection: () => ThemeSelection\n /** What the preference resolves to right now, after `system`. */\n resolvedAppearance: () => ThemeAppearance\n /** The variant in use. */\n variant: () => ThemeVariant\n /** Update part of the preference. */\n setSelection: (patch: Partial<ThemeSelection>) => void\n /**\n * The built-in catalogue, so a picker does not import it separately. A plain\n * array: {@link ThemeContextValue.allThemes} is the one that follows a host's\n * extra themes. Under the lazy provider it holds only the default pair until\n * {@link ThemeContextValue.catalogueReady}; read it again afterwards.\n */\n themes: readonly ThemeVariant[]\n /**\n * The accents the selected light/dark pair carries, offered beside the presets.\n * Follows the selection: a different theme pair may offer different slots.\n */\n themeAccents: () => readonly AccentPreset[]\n /**\n * The built-in catalogue followed by the provider's `themes` prop. Reactive when\n * that prop is a function that reads signals.\n */\n allThemes: () => readonly ThemeVariant[]\n /**\n * Paint the document from `draft` laid over the stored selection, without\n * persisting it or changing what {@link ThemeContextValue.selection} returns.\n * `undefined` ends the preview. A {@link ThemeContextValue.setSelection} ends it\n * too, because the committed selection is then what should be showing.\n */\n preview: (draft: Partial<ThemeSelection> | undefined) => void\n /** True while a {@link ThemeContextValue.preview} draft is on the document. */\n previewing: () => boolean\n /**\n * The roles `accent` paints over `variantId` (default: the variant in use), held\n * to the provider's `accentContrastFloor`, for an element-scoped override with\n * `paintAccentRoles` — a workspace that carries its own colour. `undefined` for\n * `null`, for `theme`, for an id that resolves to nothing, and for a variant the\n * registry does not hold: each means \"keep the inherited accent\".\n */\n accentRolesFor: (accent: string | null, variantId?: string) => AccentRoles | undefined\n /**\n * The surface the committed selection paints, after Reduce Transparency and the\n * host's translucency capability. `opaque` when the axis is off. Follows the\n * committed selection, not a preview, like {@link ThemeContextValue.variant}.\n */\n effectiveSurface: () => ThemeSurface\n /**\n * True while the operating system or the selection's `reduceTransparency` forces\n * opaque surfaces. Always false when the surface axis is off, because nothing is\n * then listening to the operating system.\n */\n reduceTransparencyActive: () => boolean\n /**\n * Step the three text sizes together, or put them back to the defaults: what the\n * `fontZoom` prop's chords do, for a host that binds its own keys or a menu. Goes\n * through {@link ThemeContextValue.setSelection}, so it persists and ends a preview.\n */\n zoomFonts: (intent: FontZoomIntent) => void\n /**\n * True when `themes`, `allThemes()` and the variants they resolve are backed by the\n * whole catalogue. Always true under `ThemeProvider`. Under the lazy provider\n * (`@adea-ai/ui/components/theme/lazy`) it turns true once the catalogue has loaded,\n * and until then only the default light and dark themes are available: a stored\n * theme beyond them resolves to its appearance's default (the document keeps painting\n * what the stylesheet gave it) until `catalogueReady()` is true. Absent on a context\n * a host builds itself, where it should be read as true.\n */\n catalogueReady?: () => boolean\n /**\n * Start loading the whole catalogue (idempotent) and resolve when it is available.\n * A picker, a preview or a settings page calls it when it mounts. A no-op under\n * `ThemeProvider`, whose catalogue is already loaded.\n */\n loadCatalogue?: () => Promise<void>\n}\n\n/** A selection with the `undefined` keys of a patch left out. */\nfunction definedOnly<T extends object>(value: T): Partial<T> {\n return Object.fromEntries(\n Object.entries(value).filter(([, entry]) => entry !== undefined)\n ) as Partial<T>\n}\n\n/** Keep the deprecated single-font view synchronized with the UI axis. */\nexport function mergeThemeSelection(\n base: ThemeSelection,\n patch: Partial<ThemeSelection>\n): ThemeSelection {\n const merged = { ...base, ...patch }\n let fonts: AppearanceEditorFontSettings\n\n if (patch.fonts !== undefined) {\n fonts = normalizeAppearanceEditorFontSettings(patch.fonts).settings\n } else if (patch.font !== undefined) {\n const currentFonts = normalizeAppearanceEditorFontSettings(base.fonts, base.font).settings\n fonts = normalizeAppearanceEditorFontSettings({\n ...currentFonts,\n ui: { ...currentFonts.ui, family: patch.font },\n }).settings\n } else {\n fonts = normalizeAppearanceEditorFontSettings(merged.fonts, merged.font).settings\n }\n\n return {\n ...merged,\n // One spelling for a custom colour, so equal choices compare and store equal.\n accent: normalizeCustomAccent(merged.accent) ?? merged.accent,\n fonts,\n font: fonts.ui.family,\n }\n}\n\n/**\n * The selection a provider starts from: the defaults, then whatever the store\n * returned, then `initial`.\n *\n * `initial` wins over the store on every mount. That precedence is part of the\n * contract Cortana relies on (its `initial` pins `appearance` and `font`), and it\n * is why the store's answer is only the middle layer. A store that returned\n * nothing, or threw, or answered with explicit `undefined`s, leaves the defaults\n * standing for those fields.\n */\nexport function initialThemeSelection(\n stored: Partial<ThemeSelection> | undefined,\n initial: Partial<ThemeSelection> | undefined\n): ThemeSelection {\n const base = mergeThemeSelection(defaultThemeSelection, definedOnly(stored ?? {}))\n return mergeThemeSelection(base, initial ?? {})\n}\n\n/** `system` resolved against what the operating system reports. */\nexport function resolveAppearance(\n preference: ThemeSelection['appearance'],\n system: ThemeAppearance\n): ThemeAppearance {\n return preference === 'system' ? system : preference\n}\n\n/** The theme id the selection names for a resolved appearance. */\nexport function selectedThemeId(selection: ThemeSelection, appearance: ThemeAppearance): string {\n return appearance === 'dark' ? selection.darkThemeId : selection.lightThemeId\n}\n\n/**\n * What a selection paints: the resolved appearance and the variant for it.\n *\n * An id the registry does not hold resolves to the appearance's default rather than\n * being rewritten (see `resolveVariant`), so the selection a host stores is never\n * changed by being unresolvable.\n */\nexport function resolveThemeState(\n selection: ThemeSelection,\n system: ThemeAppearance,\n registry: readonly ThemeVariant[]\n): { appearance: ThemeAppearance; variant: ThemeVariant } {\n const appearance = resolveAppearance(selection.appearance, system)\n return {\n appearance,\n variant: resolveVariant(registry, selectedThemeId(selection, appearance), appearance),\n }\n}\n\n/**\n * The variant whose terminal palette is pinned, or `undefined` when the terminal\n * follows the interface theme.\n *\n * `theme`, an absent id and an id the registry does not hold all mean the interface\n * palette: a terminal must never resolve to a blank or half-painted palette because a\n * theme was deleted after it was pinned.\n */\nexport function resolveTerminalVariant(\n terminalThemeId: string | undefined,\n registry: readonly ThemeVariant[]\n): ThemeVariant | undefined {\n if (terminalThemeId === undefined || terminalThemeId === 'theme') return undefined\n return registry.find((candidate) => candidate.id === terminalThemeId)\n}\n\n/**\n * The font settings a zoom chord asks for: one pixel up or down on every axis, or\n * the defaults for `reset`.\n */\nexport function zoomedFontSettings(\n selection: ThemeSelection,\n intent: FontZoomIntent\n): AppearanceEditorFontSettings {\n if (intent === 'reset') return { ...DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS }\n return stepAppearanceFontSizes(selection.fonts, intent === 'in' ? 1 : -1)\n}\n\n/**\n * The registry a provider resolves against: the catalogue, then the host's extras.\n *\n * The catalogue wins an id collision, because it is listed first and `resolveVariant`\n * takes the first match: a host's variant can add a theme but cannot shadow one.\n */\nexport function mergeRegistry(\n builtin: readonly ThemeVariant[],\n extra: readonly ThemeVariant[] | undefined\n): readonly ThemeVariant[] {\n return extra && extra.length > 0 ? [...builtin, ...extra] : builtin\n}\n\n/**\n * The roles an accent paints over a variant, for {@link ThemeContextValue.accentRolesFor}.\n *\n * Resolved against the committed selection's theme pair, so an `ansi-*` accent means\n * the same colour here as it does on `<html>`. `engine` answers the catalogue\n * questions; `theme-state.ts` binds the full catalogue for callers that have none.\n */\nexport function accentRolesForStateWith(\n engine: Pick<ThemeEngine, 'accentRolesForSelection'>,\n accent: string | null,\n variantId: string | undefined,\n state: {\n selection: ThemeSelection\n variant: ThemeVariant\n registry: readonly ThemeVariant[]\n accentContrastFloor?: number\n }\n): AccentRoles | undefined {\n if (accent === null) return undefined\n const variant =\n variantId === undefined\n ? state.variant\n : state.registry.find((candidate) => candidate.id === variantId)\n if (!variant) return undefined\n return engine.accentRolesForSelection(accent, variant.appearance, state.selection, {\n background: variant.colors.background,\n floor: state.accentContrastFloor,\n variantId: variant.id,\n })\n}\n"],"mappings":";;;;;;;;;;;AA2GA,IAAa,wBAAwC;CACnD,YAAY;CACZ,cAAc;CACd,aAAa;CACb,QAAQ;CACR,MAAM;CACN,OAAO;CACP,SAAS;AACX;;;;;;;;AASA,SAAgB,gBAAgB,WAAyC;CACvE,OAAO,UAAU,YAAY,YAAY,YAAY;AACvD;;AAkFA,SAAS,YAA8B,OAAsB;CAC3D,OAAO,OAAO,YACZ,OAAO,QAAQ,KAAK,CAAC,CAAC,QAAQ,GAAG,WAAW,UAAU,KAAA,CAAS,CACjE;AACF;;AAGA,SAAgB,oBACd,MACA,OACgB;CAChB,MAAM,SAAS;EAAE,GAAG;EAAM,GAAG;CAAM;CACnC,IAAI;CAEJ,IAAI,MAAM,UAAU,KAAA,GAClB,QAAQ,sCAAsC,MAAM,KAAK,CAAC,CAAC;MACtD,IAAI,MAAM,SAAS,KAAA,GAAW;EACnC,MAAM,eAAe,sCAAsC,KAAK,OAAO,KAAK,IAAI,CAAC,CAAC;EAClF,QAAQ,sCAAsC;GAC5C,GAAG;GACH,IAAI;IAAE,GAAG,aAAa;IAAI,QAAQ,MAAM;GAAK;EAC/C,CAAC,CAAC,CAAC;CACL,OACE,QAAQ,sCAAsC,OAAO,OAAO,OAAO,IAAI,CAAC,CAAC;CAG3E,OAAO;EACL,GAAG;EAEH,QAAQ,sBAAsB,OAAO,MAAM,KAAK,OAAO;EACvD;EACA,MAAM,MAAM,GAAG;CACjB;AACF;;;;;;;;;;;AAYA,SAAgB,sBACd,QACA,SACgB;CAEhB,OAAO,oBADM,oBAAoB,uBAAuB,YAAY,UAAU,CAAC,CAAC,CACrD,GAAM,WAAW,CAAC,CAAC;AAChD;;AAGA,SAAgB,kBACd,YACA,QACiB;CACjB,OAAO,eAAe,WAAW,SAAS;AAC5C;;AAGA,SAAgB,gBAAgB,WAA2B,YAAqC;CAC9F,OAAO,eAAe,SAAS,UAAU,cAAc,UAAU;AACnE;;;;;;;;AASA,SAAgB,kBACd,WACA,QACA,UACwD;CACxD,MAAM,aAAa,kBAAkB,UAAU,YAAY,MAAM;CACjE,OAAO;EACL;EACA,SAAS,eAAe,UAAU,gBAAgB,WAAW,UAAU,GAAG,UAAU;CACtF;AACF;;;;;;;;;AAUA,SAAgB,uBACd,iBACA,UAC0B;CAC1B,IAAI,oBAAoB,KAAA,KAAa,oBAAoB,SAAS,OAAO,KAAA;CACzE,OAAO,SAAS,MAAM,cAAc,UAAU,OAAO,eAAe;AACtE;;;;;AAMA,SAAgB,mBACd,WACA,QAC8B;CAC9B,IAAI,WAAW,SAAS,OAAO,EAAE,GAAG,wCAAwC;CAC5E,OAAO,wBAAwB,UAAU,OAAO,WAAW,OAAO,IAAI,EAAE;AAC1E;;;;;;;AAQA,SAAgB,cACd,SACA,OACyB;CACzB,OAAO,SAAS,MAAM,SAAS,IAAI,CAAC,GAAG,SAAS,GAAG,KAAK,IAAI;AAC9D;;;;;;;;AASA,SAAgB,wBACd,QACA,QACA,WACA,OAMyB;CACzB,IAAI,WAAW,MAAM,OAAO,KAAA;CAC5B,MAAM,UACJ,cAAc,KAAA,IACV,MAAM,UACN,MAAM,SAAS,MAAM,cAAc,UAAU,OAAO,SAAS;CACnE,IAAI,CAAC,SAAS,OAAO,KAAA;CACrB,OAAO,OAAO,wBAAwB,QAAQ,QAAQ,YAAY,MAAM,WAAW;EACjF,YAAY,QAAQ,OAAO;EAC3B,OAAO,MAAM;EACb,WAAW,QAAQ;CACrB,CAAC;AACH"}
1
+ {"version":3,"file":"theme-state-core.js","names":[],"sources":["../../../src/components/theme/theme-state-core.ts"],"sourcesContent":["import {\n DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS,\n normalizeAppearanceEditorFontSettings,\n type AppearanceEditorFontSettings,\n} from '#lib/appearance-font-settings'\nimport type { AccentPreset } from '@adea-ai/themes'\nimport { normalizeCustomAccent, type AccentRoles } from '#lib/accent-roles'\nimport { stepAppearanceFontSizes, type FontZoomIntent } from '#lib/font-zoom'\nimport type { ThemeSurface } from '#lib/theme-surface'\nimport { defaultDarkThemeId, defaultLightThemeId, resolveVariant } from '#lib/theme-defaults'\nimport type { ThemeEngine } from '#lib/theme-engine'\nimport type { ThemeAppearance, ThemeVariant } from '#lib/themes'\n\n/**\n * The pure half of the theme provider: what a selection is, how two selections\n * merge, and what a selection resolves to.\n *\n * Nothing here touches the document, storage or a signal, so each rule can be\n * tested by calling it. `ThemeProvider` owns the reactivity and wires these to it;\n * `theme-document.ts` owns the writes; `theme-persistence.ts` owns the store.\n *\n * This is the catalogue-free half: it imports no catalogue code or data, so the lazy\n * provider can use it at start-up. `theme-state.ts` re-exports it and adds\n * {@link accentRolesForState} bound to the full catalogue.\n */\n\n/**\n * Four independent choices, and keeping them independent is the point:\n *\n * - **appearance** — light, dark, or follow the system.\n * - **a theme per appearance** — so a user can run Catppuccin Mocha by night and\n * Solarized Light by day without re-choosing when the system flips.\n * - **an accent** — adea's six presets, or one of the accents the selected theme\n * pair carries itself (`ansi-blue`…), which re-colour the interactive roles on\n * top of whichever theme is active.\n * - **fonts** — separate family and size choices for UI, content and code.\n */\nexport type ThemeSelection = {\n /** `system` follows `prefers-color-scheme` and updates when it changes. */\n appearance: ThemeAppearance | 'system'\n /** The variant to use when the resolved appearance is light. */\n lightThemeId: string\n /** The variant to use when the resolved appearance is dark. */\n darkThemeId: string\n /**\n * An `accentPresets` id, a theme accent id from `themeAccents()` (`ansi-blue`…),\n * `theme` for the variant's own primary, or a custom colour as `#rrggbb`. A theme\n * accent the current pair does not offer falls back to the variant's own primary.\n *\n * A custom colour is stored lower case and is raised to the contrast floor when it\n * is painted, never when it is stored: the selection keeps what the user chose.\n * Anything else that is not an id is dropped at paint, not rejected here.\n */\n accent: string\n /** UI-family alias for consumers of the original single-font preference. */\n font: string\n /** UI, content and code font settings. Omitted legacy records are migrated from `font`. */\n fonts?: AppearanceEditorFontSettings\n /**\n * `comfortable` is the system's default geometry; `compact` moves the control\n * ladder down one rung.\n *\n * Optional, and defaulted on read, so a preference stored before density existed\n * keeps working and `ThemeSelection` stays assignable without it.\n */\n density?: ThemeDensity\n /**\n * The terminal either follows the interface theme (`theme`, or absent) or is pinned\n * to another theme's terminal palette by that theme's id. The pin is written over\n * the interface variant's own `--terminal-*` properties, so a light interface can\n * carry a dark terminal.\n *\n * An id the registry does not hold paints the interface palette and stays in the\n * selection, the same rule as an unknown theme id.\n *\n * Optional and not defaulted: see {@link defaultThemeSelection}.\n */\n terminalThemeId?: string\n /**\n * How opaque elevated panels are. Written to `<html>` only when the provider's\n * `surface` prop is on or this is set; absent, a host paints no surface axis at\n * all. Resolved against the OS and the host's capability before it is painted —\n * see `resolveSurface` — so the value stored is a preference, never the outcome.\n */\n surface?: ThemeSurface\n /**\n * The user's own Reduce Transparency switch, which forces the `opaque` surface the\n * same way the operating system's setting does.\n */\n reduceTransparency?: boolean\n}\n\n/**\n * The two density rungs.\n *\n * `comfortable` is the geometry in `theme.css`, so it is the absence of an\n * attribute rather than a value: a document that ships no `data-density` at all\n * renders correctly, which is what keeps this additive.\n */\nexport type ThemeDensity = 'comfortable' | 'compact'\n\n/**\n * Deliberately lists only the fields every consumer has always had. A field added\n * to {@link ThemeSelection} later gets no default here: `JSON.stringify` drops an\n * `undefined`, so a store written by a consumer that never sets the field stays\n * byte-identical to what it was before the field existed.\n */\nexport const defaultThemeSelection: ThemeSelection = {\n appearance: 'system',\n lightThemeId: defaultLightThemeId,\n darkThemeId: defaultDarkThemeId,\n accent: 'theme',\n font: 'system',\n fonts: DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS,\n density: 'comfortable',\n}\n\n/**\n * A stored selection's density, defaulted.\n *\n * The stored value is read through here rather than trusted, because a preference\n * written before density existed has no `density` key and a hand-edited store may\n * hold anything.\n */\nexport function resolvedDensity(selection: ThemeSelection): ThemeDensity {\n return selection.density === 'compact' ? 'compact' : 'comfortable'\n}\n\nexport type ThemeContextValue = {\n /** The preference as stored. A {@link ThemeContextValue.preview} does not change it. */\n selection: () => ThemeSelection\n /** What the preference resolves to right now, after `system`. */\n resolvedAppearance: () => ThemeAppearance\n /**\n * The appearance currently shown by the provider, including an active preview.\n * Optional for compatibility with values supplied by an older copy of the UI\n * package or by a host-owned context mock; providers always expose it.\n */\n shownAppearance?: () => ThemeAppearance\n /** The variant in use. */\n variant: () => ThemeVariant\n /** Update part of the preference. */\n setSelection: (patch: Partial<ThemeSelection>) => void\n /**\n * The built-in catalogue, so a picker does not import it separately. A plain\n * array: {@link ThemeContextValue.allThemes} is the one that follows a host's\n * extra themes. Under the lazy provider it holds only the default pair until\n * {@link ThemeContextValue.catalogueReady}; read it again afterwards.\n */\n themes: readonly ThemeVariant[]\n /**\n * The accents the selected light/dark pair carries, offered beside the presets.\n * Follows the selection: a different theme pair may offer different slots.\n */\n themeAccents: () => readonly AccentPreset[]\n /**\n * The built-in catalogue followed by the provider's `themes` prop. Reactive when\n * that prop is a function that reads signals.\n */\n allThemes: () => readonly ThemeVariant[]\n /**\n * Paint the document from `draft` laid over the stored selection, without\n * persisting it or changing what {@link ThemeContextValue.selection} returns.\n * `undefined` ends the preview. A {@link ThemeContextValue.setSelection} ends it\n * too, because the committed selection is then what should be showing.\n */\n preview: (draft: Partial<ThemeSelection> | undefined) => void\n /** True while a {@link ThemeContextValue.preview} draft is on the document. */\n previewing: () => boolean\n /**\n * The roles `accent` paints over `variantId` (default: the variant in use), held\n * to the provider's `accentContrastFloor`, for an element-scoped override with\n * `paintAccentRoles` — a workspace that carries its own colour. `undefined` for\n * `null`, for `theme`, for an id that resolves to nothing, and for a variant the\n * registry does not hold: each means \"keep the inherited accent\".\n */\n accentRolesFor: (accent: string | null, variantId?: string) => AccentRoles | undefined\n /**\n * The surface the committed selection paints, after Reduce Transparency and the\n * host's translucency capability. `opaque` when the axis is off. Follows the\n * committed selection, not a preview, like {@link ThemeContextValue.variant}.\n */\n effectiveSurface: () => ThemeSurface\n /**\n * True while the operating system or the selection's `reduceTransparency` forces\n * opaque surfaces. Always false when the surface axis is off, because nothing is\n * then listening to the operating system.\n */\n reduceTransparencyActive: () => boolean\n /**\n * Step the three text sizes together, or put them back to the defaults: what the\n * `fontZoom` prop's chords do, for a host that binds its own keys or a menu. Goes\n * through {@link ThemeContextValue.setSelection}, so it persists and ends a preview.\n */\n zoomFonts: (intent: FontZoomIntent) => void\n /**\n * True when `themes`, `allThemes()` and the variants they resolve are backed by the\n * whole catalogue. Always true under `ThemeProvider`. Under the lazy provider\n * (`@adea-ai/ui/components/theme/lazy`) it turns true once the catalogue has loaded,\n * and until then only the default light and dark themes are available: a stored\n * theme beyond them resolves to its appearance's default (the document keeps painting\n * what the stylesheet gave it) until `catalogueReady()` is true. Absent on a context\n * a host builds itself, where it should be read as true.\n */\n catalogueReady?: () => boolean\n /**\n * Start loading the whole catalogue (idempotent) and resolve when it is available.\n * A picker, a preview or a settings page calls it when it mounts. A no-op under\n * `ThemeProvider`, whose catalogue is already loaded.\n */\n loadCatalogue?: () => Promise<void>\n}\n\n/** A selection with the `undefined` keys of a patch left out. */\nfunction definedOnly<T extends object>(value: T): Partial<T> {\n return Object.fromEntries(\n Object.entries(value).filter(([, entry]) => entry !== undefined)\n ) as Partial<T>\n}\n\n/** Keep the deprecated single-font view synchronized with the UI axis. */\nexport function mergeThemeSelection(\n base: ThemeSelection,\n patch: Partial<ThemeSelection>\n): ThemeSelection {\n const merged = { ...base, ...patch }\n let fonts: AppearanceEditorFontSettings\n\n if (patch.fonts !== undefined) {\n fonts = normalizeAppearanceEditorFontSettings(patch.fonts).settings\n } else if (patch.font !== undefined) {\n const currentFonts = normalizeAppearanceEditorFontSettings(base.fonts, base.font).settings\n fonts = normalizeAppearanceEditorFontSettings({\n ...currentFonts,\n ui: { ...currentFonts.ui, family: patch.font },\n }).settings\n } else {\n fonts = normalizeAppearanceEditorFontSettings(merged.fonts, merged.font).settings\n }\n\n return {\n ...merged,\n // One spelling for a custom colour, so equal choices compare and store equal.\n accent: normalizeCustomAccent(merged.accent) ?? merged.accent,\n fonts,\n font: fonts.ui.family,\n }\n}\n\n/**\n * The selection a provider starts from: the defaults, then whatever the store\n * returned, then `initial`.\n *\n * `initial` wins over the store on every mount. That precedence is part of the\n * contract Cortana relies on (its `initial` pins `appearance` and `font`), and it\n * is why the store's answer is only the middle layer. A store that returned\n * nothing, or threw, or answered with explicit `undefined`s, leaves the defaults\n * standing for those fields.\n */\nexport function initialThemeSelection(\n stored: Partial<ThemeSelection> | undefined,\n initial: Partial<ThemeSelection> | undefined\n): ThemeSelection {\n const base = mergeThemeSelection(defaultThemeSelection, definedOnly(stored ?? {}))\n return mergeThemeSelection(base, initial ?? {})\n}\n\n/** `system` resolved against what the operating system reports. */\nexport function resolveAppearance(\n preference: ThemeSelection['appearance'],\n system: ThemeAppearance\n): ThemeAppearance {\n return preference === 'system' ? system : preference\n}\n\n/** The theme id the selection names for a resolved appearance. */\nexport function selectedThemeId(selection: ThemeSelection, appearance: ThemeAppearance): string {\n return appearance === 'dark' ? selection.darkThemeId : selection.lightThemeId\n}\n\n/**\n * What a selection paints: the resolved appearance and the variant for it.\n *\n * An id the registry does not hold resolves to the appearance's default rather than\n * being rewritten (see `resolveVariant`), so the selection a host stores is never\n * changed by being unresolvable.\n */\nexport function resolveThemeState(\n selection: ThemeSelection,\n system: ThemeAppearance,\n registry: readonly ThemeVariant[]\n): { appearance: ThemeAppearance; variant: ThemeVariant } {\n const appearance = resolveAppearance(selection.appearance, system)\n return {\n appearance,\n variant: resolveVariant(registry, selectedThemeId(selection, appearance), appearance),\n }\n}\n\n/**\n * The variant whose terminal palette is pinned, or `undefined` when the terminal\n * follows the interface theme.\n *\n * `theme`, an absent id and an id the registry does not hold all mean the interface\n * palette: a terminal must never resolve to a blank or half-painted palette because a\n * theme was deleted after it was pinned.\n */\nexport function resolveTerminalVariant(\n terminalThemeId: string | undefined,\n registry: readonly ThemeVariant[]\n): ThemeVariant | undefined {\n if (terminalThemeId === undefined || terminalThemeId === 'theme') return undefined\n return registry.find((candidate) => candidate.id === terminalThemeId)\n}\n\n/**\n * The font settings a zoom chord asks for: one pixel up or down on every axis, or\n * the defaults for `reset`.\n */\nexport function zoomedFontSettings(\n selection: ThemeSelection,\n intent: FontZoomIntent\n): AppearanceEditorFontSettings {\n if (intent === 'reset') return { ...DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS }\n return stepAppearanceFontSizes(selection.fonts, intent === 'in' ? 1 : -1)\n}\n\n/**\n * The registry a provider resolves against: the catalogue, then the host's extras.\n *\n * The catalogue wins an id collision, because it is listed first and `resolveVariant`\n * takes the first match: a host's variant can add a theme but cannot shadow one.\n */\nexport function mergeRegistry(\n builtin: readonly ThemeVariant[],\n extra: readonly ThemeVariant[] | undefined\n): readonly ThemeVariant[] {\n return extra && extra.length > 0 ? [...builtin, ...extra] : builtin\n}\n\n/**\n * The roles an accent paints over a variant, for {@link ThemeContextValue.accentRolesFor}.\n *\n * Resolved against the committed selection's theme pair, so an `ansi-*` accent means\n * the same colour here as it does on `<html>`. `engine` answers the catalogue\n * questions; `theme-state.ts` binds the full catalogue for callers that have none.\n */\nexport function accentRolesForStateWith(\n engine: Pick<ThemeEngine, 'accentRolesForSelection'>,\n accent: string | null,\n variantId: string | undefined,\n state: {\n selection: ThemeSelection\n variant: ThemeVariant\n registry: readonly ThemeVariant[]\n accentContrastFloor?: number\n }\n): AccentRoles | undefined {\n if (accent === null) return undefined\n const variant =\n variantId === undefined\n ? state.variant\n : state.registry.find((candidate) => candidate.id === variantId)\n if (!variant) return undefined\n return engine.accentRolesForSelection(accent, variant.appearance, state.selection, {\n background: variant.colors.background,\n floor: state.accentContrastFloor,\n variantId: variant.id,\n })\n}\n"],"mappings":";;;;;;;;;;;AA2GA,IAAa,wBAAwC;CACnD,YAAY;CACZ,cAAc;CACd,aAAa;CACb,QAAQ;CACR,MAAM;CACN,OAAO;CACP,SAAS;AACX;;;;;;;;AASA,SAAgB,gBAAgB,WAAyC;CACvE,OAAO,UAAU,YAAY,YAAY,YAAY;AACvD;;AAwFA,SAAS,YAA8B,OAAsB;CAC3D,OAAO,OAAO,YACZ,OAAO,QAAQ,KAAK,CAAC,CAAC,QAAQ,GAAG,WAAW,UAAU,KAAA,CAAS,CACjE;AACF;;AAGA,SAAgB,oBACd,MACA,OACgB;CAChB,MAAM,SAAS;EAAE,GAAG;EAAM,GAAG;CAAM;CACnC,IAAI;CAEJ,IAAI,MAAM,UAAU,KAAA,GAClB,QAAQ,sCAAsC,MAAM,KAAK,CAAC,CAAC;MACtD,IAAI,MAAM,SAAS,KAAA,GAAW;EACnC,MAAM,eAAe,sCAAsC,KAAK,OAAO,KAAK,IAAI,CAAC,CAAC;EAClF,QAAQ,sCAAsC;GAC5C,GAAG;GACH,IAAI;IAAE,GAAG,aAAa;IAAI,QAAQ,MAAM;GAAK;EAC/C,CAAC,CAAC,CAAC;CACL,OACE,QAAQ,sCAAsC,OAAO,OAAO,OAAO,IAAI,CAAC,CAAC;CAG3E,OAAO;EACL,GAAG;EAEH,QAAQ,sBAAsB,OAAO,MAAM,KAAK,OAAO;EACvD;EACA,MAAM,MAAM,GAAG;CACjB;AACF;;;;;;;;;;;AAYA,SAAgB,sBACd,QACA,SACgB;CAEhB,OAAO,oBADM,oBAAoB,uBAAuB,YAAY,UAAU,CAAC,CAAC,CACrD,GAAM,WAAW,CAAC,CAAC;AAChD;;AAGA,SAAgB,kBACd,YACA,QACiB;CACjB,OAAO,eAAe,WAAW,SAAS;AAC5C;;AAGA,SAAgB,gBAAgB,WAA2B,YAAqC;CAC9F,OAAO,eAAe,SAAS,UAAU,cAAc,UAAU;AACnE;;;;;;;;AASA,SAAgB,kBACd,WACA,QACA,UACwD;CACxD,MAAM,aAAa,kBAAkB,UAAU,YAAY,MAAM;CACjE,OAAO;EACL;EACA,SAAS,eAAe,UAAU,gBAAgB,WAAW,UAAU,GAAG,UAAU;CACtF;AACF;;;;;;;;;AAUA,SAAgB,uBACd,iBACA,UAC0B;CAC1B,IAAI,oBAAoB,KAAA,KAAa,oBAAoB,SAAS,OAAO,KAAA;CACzE,OAAO,SAAS,MAAM,cAAc,UAAU,OAAO,eAAe;AACtE;;;;;AAMA,SAAgB,mBACd,WACA,QAC8B;CAC9B,IAAI,WAAW,SAAS,OAAO,EAAE,GAAG,wCAAwC;CAC5E,OAAO,wBAAwB,UAAU,OAAO,WAAW,OAAO,IAAI,EAAE;AAC1E;;;;;;;AAQA,SAAgB,cACd,SACA,OACyB;CACzB,OAAO,SAAS,MAAM,SAAS,IAAI,CAAC,GAAG,SAAS,GAAG,KAAK,IAAI;AAC9D;;;;;;;;AASA,SAAgB,wBACd,QACA,QACA,WACA,OAMyB;CACzB,IAAI,WAAW,MAAM,OAAO,KAAA;CAC5B,MAAM,UACJ,cAAc,KAAA,IACV,MAAM,UACN,MAAM,SAAS,MAAM,cAAc,UAAU,OAAO,SAAS;CACnE,IAAI,CAAC,SAAS,OAAO,KAAA;CACrB,OAAO,OAAO,wBAAwB,QAAQ,QAAQ,YAAY,MAAM,WAAW;EACjF,YAAY,QAAQ,OAAO;EAC3B,OAAO,MAAM;EACb,WAAW,QAAQ;CACrB,CAAC;AACH"}
@@ -0,0 +1,3 @@
1
+ /** Keep the runtime configuration check free of the optional Themes projector import. */
2
+ export declare function assertThemeTokenProjectionConfig(config: unknown): void;
3
+ //# sourceMappingURL=token-projection-options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token-projection-options.d.ts","sourceRoot":"","sources":["../../../src/components/theme/token-projection-options.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,wBAAgB,gCAAgC,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAYtE"}
@@ -0,0 +1,9 @@
1
+ // src/components/theme/token-projection-options.ts
2
+ /** Keep the runtime configuration check free of the optional Themes projector import. */
3
+ function assertThemeTokenProjectionConfig(config) {
4
+ if (config === void 0) return;
5
+ if (!config || typeof config !== "object" || !("rules" in config) || !Array.isArray(config.rules) || !("project" in config) || typeof config.project !== "function") throw new TypeError("tokenProjection requires both rules and project");
6
+ }
7
+ export { assertThemeTokenProjectionConfig };
8
+
9
+ //# sourceMappingURL=token-projection-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token-projection-options.js","names":[],"sources":["../../../src/components/theme/token-projection-options.ts"],"sourcesContent":["/** Keep the runtime configuration check free of the optional Themes projector import. */\nexport function assertThemeTokenProjectionConfig(config: unknown): void {\n if (config === undefined) return\n if (\n !config ||\n typeof config !== 'object' ||\n !('rules' in config) ||\n !Array.isArray(config.rules) ||\n !('project' in config) ||\n typeof config.project !== 'function'\n ) {\n throw new TypeError('tokenProjection requires both rules and project')\n }\n}\n"],"mappings":";;AACA,SAAgB,iCAAiC,QAAuB;CACtE,IAAI,WAAW,KAAA,GAAW;CAC1B,IACE,CAAC,UACD,OAAO,WAAW,YAClB,EAAE,WAAW,WACb,CAAC,MAAM,QAAQ,OAAO,KAAK,KAC3B,EAAE,aAAa,WACf,OAAO,OAAO,YAAY,YAE1B,MAAM,IAAI,UAAU,iDAAiD;AAEzE"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Runtime token projection for hosts that opt in to projecting legacy theme maps.
3
+ * The default provider and boot script do not import this entry.
4
+ */
5
+ import type { ThemeTokenProjection } from '@adea-ai/themes/theme-token-projection';
6
+ export { projectThemeTokens, projectThemeTokensDetailed, } from '@adea-ai/themes/theme-token-projection';
7
+ export type { ThemeTokenContrastRule, ThemeTokenProjection, ThemeTokenProjectionFailure, ThemeTokenProjectionResult, ThemeTokenProjectionRule, } from '@adea-ai/themes/theme-token-projection';
8
+ /** Function type for the shared projector supplied by opt-in hosts. */
9
+ export type ThemeTokenProjector = (tokens: Readonly<Record<string, string>>, projection: ThemeTokenProjection) => Record<string, string>;
10
+ /** Rules and their projector travel together through provider/document options. */
11
+ export type ThemeTokenProjectionConfig = Readonly<{
12
+ rules: ThemeTokenProjection;
13
+ project: ThemeTokenProjector;
14
+ }>;
15
+ /**
16
+ * Projection rules and their runtime; hosts that opt in provide both. The rules operate
17
+ * on each custom variant's raw `tokens` map, preserving the prepaint source's availability.
18
+ */
19
+ export type ThemeTokenProjectionOptions = {
20
+ tokenProjection?: ThemeTokenProjectionConfig;
21
+ };
22
+ //# sourceMappingURL=token-projection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token-projection.d.ts","sourceRoot":"","sources":["../../../src/components/theme/token-projection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAA;AAElF,OAAO,EACL,kBAAkB,EAClB,0BAA0B,GAC3B,MAAM,wCAAwC,CAAA;AAC/C,YAAY,EACV,sBAAsB,EACtB,oBAAoB,EACpB,2BAA2B,EAC3B,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,wCAAwC,CAAA;AAE/C,uEAAuE;AACvE,MAAM,MAAM,mBAAmB,GAAG,CAChC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EACxC,UAAU,EAAE,oBAAoB,KAC7B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAE3B,mFAAmF;AACnF,MAAM,MAAM,0BAA0B,GAAG,QAAQ,CAAC;IAChD,KAAK,EAAE,oBAAoB,CAAA;IAC3B,OAAO,EAAE,mBAAmB,CAAA;CAC7B,CAAC,CAAA;AAEF;;;GAGG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,eAAe,CAAC,EAAE,0BAA0B,CAAA;CAC7C,CAAA"}
@@ -0,0 +1 @@
1
+ export { projectThemeTokens, projectThemeTokensDetailed } from "@adea-ai/themes/theme-token-projection";
@@ -4,7 +4,7 @@
4
4
  "title": "Appearance Editor",
5
5
  "description": "",
6
6
  "dependencies": [
7
- "@adea-ai/themes@^0.11.7",
7
+ "@adea-ai/themes@>0.11.7 <0.12.0",
8
8
  "@kobalte/core@^0.13.14",
9
9
  "lucide-solid@^1.65.0"
10
10
  ],
package/dist/r/lib.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "title": "Class-name and token helpers",
5
5
  "description": "The private helpers the components import: the class-name merge, the variant recipes, the token manifest and the theme bridge. Installed automatically as a peer of any component that needs it.",
6
6
  "dependencies": [
7
- "@adea-ai/themes@^0.11.7",
7
+ "@adea-ai/themes@>0.11.7 <0.12.0",
8
8
  "class-variance-authority@^0.7.1",
9
9
  "cn@^0.5.1"
10
10
  ],
@@ -2298,7 +2298,7 @@
2298
2298
  "title": "Appearance Editor",
2299
2299
  "description": "",
2300
2300
  "dependencies": [
2301
- "@adea-ai/themes@^0.11.7",
2301
+ "@adea-ai/themes@>0.11.7 <0.12.0",
2302
2302
  "@kobalte/core@^0.13.14",
2303
2303
  "lucide-solid@^1.65.0"
2304
2304
  ],
@@ -3458,7 +3458,7 @@
3458
3458
  "title": "Theming",
3459
3459
  "description": "",
3460
3460
  "dependencies": [
3461
- "@adea-ai/themes@^0.11.7",
3461
+ "@adea-ai/themes@>0.11.7 <0.12.0",
3462
3462
  "@kobalte/core@^0.13.14",
3463
3463
  "lucide-solid@^1.65.0"
3464
3464
  ],
@@ -3487,6 +3487,11 @@
3487
3487
  "type": "registry:ui",
3488
3488
  "target": "components/theming/lazy.ts"
3489
3489
  },
3490
+ {
3491
+ "path": "src/components/theme/script-projection.ts",
3492
+ "type": "registry:ui",
3493
+ "target": "components/theming/script-projection.ts"
3494
+ },
3490
3495
  {
3491
3496
  "path": "src/components/theme/script.ts",
3492
3497
  "type": "registry:ui",
@@ -3566,6 +3571,16 @@
3566
3571
  "path": "src/components/theme/theme-toggle.tsx",
3567
3572
  "type": "registry:ui",
3568
3573
  "target": "components/theming/theme-toggle.tsx"
3574
+ },
3575
+ {
3576
+ "path": "src/components/theme/token-projection-options.ts",
3577
+ "type": "registry:ui",
3578
+ "target": "components/theming/token-projection-options.ts"
3579
+ },
3580
+ {
3581
+ "path": "src/components/theme/token-projection.ts",
3582
+ "type": "registry:ui",
3583
+ "target": "components/theming/token-projection.ts"
3569
3584
  }
3570
3585
  ]
3571
3586
  },
@@ -3643,7 +3658,7 @@
3643
3658
  "title": "Class-name and token helpers",
3644
3659
  "description": "The private helpers the components import: the class-name merge, the variant recipes, the token manifest and the theme bridge. Installed automatically as a peer of any component that needs it.",
3645
3660
  "dependencies": [
3646
- "@adea-ai/themes@^0.11.7",
3661
+ "@adea-ai/themes@>0.11.7 <0.12.0",
3647
3662
  "class-variance-authority@^0.7.1",
3648
3663
  "cn@^0.5.1"
3649
3664
  ],
@@ -127,11 +127,14 @@ function ThemeSelectMenu(props: {
127
127
  onCleanup(() => {
128
128
  focusLifecycleVersion += 1
129
129
  })
130
- const selected = createMemo(
131
- () =>
132
- props.options.find((option) => option.id === props.selectedId) ??
133
- props.options.find((option) => option.id === props.triggerPreview.id)
134
- )
130
+ const selected = createMemo(() => {
131
+ const options = props.options
132
+ const selectedId = props.selectedId
133
+ const matched = options.find((option) => option.id === selectedId)
134
+ if (matched) return matched
135
+ const previewId = props.triggerPreview.id
136
+ return options.find((option) => option.id === previewId)
137
+ })
135
138
  const selectedName = () => selected()?.name ?? props.triggerPreview.name
136
139
  const closeMenu = () => {
137
140
  if (menuOpen()) focusLifecycleVersion += 1
@@ -418,11 +421,16 @@ export function TerminalRow(props: {
418
421
  preview: theme,
419
422
  })),
420
423
  ])
421
- const selectedOption = () => options().find((option) => option.id === props.selectedId)
422
- const description = () =>
423
- selectedOption() && selectedOption()?.id !== 'theme'
424
- ? `The terminal follows ${selectedOption()?.name}.`
424
+ const selectedOption = createMemo(() => {
425
+ const selectedId = props.selectedId
426
+ return options().find((option) => option.id === selectedId)
427
+ })
428
+ const description = () => {
429
+ const option = selectedOption()
430
+ return option && option.id !== 'theme'
431
+ ? `The terminal follows ${option.name}.`
425
432
  : 'The terminal follows the interface theme.'
433
+ }
426
434
  return (
427
435
  <SettingsRow title="Terminal" icon={<SquareTerminal />} description={description()}>
428
436
  <ThemeSelectMenu
@@ -1,5 +1,13 @@
1
1
  import type { Accessor, JSX } from 'solid-js'
2
- import { Show, createEffect, createSignal, createUniqueId, onCleanup, untrack } from 'solid-js'
2
+ import {
3
+ Show,
4
+ createEffect,
5
+ createMemo,
6
+ createSignal,
7
+ createUniqueId,
8
+ onCleanup,
9
+ untrack,
10
+ } from 'solid-js'
3
11
  import { cn } from '../../../lib/utils'
4
12
  import {
5
13
  SidebarNav,
@@ -20,6 +28,13 @@ export type ContextualSidebarRenderContext = {
20
28
  portalMount(): HTMLElement | undefined
21
29
  }
22
30
 
31
+ export type ContextualSidebarModeTransition = {
32
+ phase: 'before' | 'after'
33
+ from: 'desktop' | 'mobile'
34
+ to: 'desktop' | 'mobile'
35
+ desktopSidebar: HTMLElement | undefined
36
+ }
37
+
23
38
  export type ContextualSidebarProps = {
24
39
  /** Stable host id prefix; generated when omitted. */
25
40
  id?: string
@@ -42,6 +57,12 @@ export type ContextualSidebarProps = {
42
57
  * hosts can select `desktop` or the shared mobile `Sheet` themselves.
43
58
  */
44
59
  responsiveMode?: 'auto' | 'desktop' | 'mobile'
60
+ /**
61
+ * Coordinate host layout before a runtime mode change and after its DOM settles.
62
+ * A superseded transition or unmounted sidebar does not emit an after phase.
63
+ * Initial mode resolution does not emit either phase.
64
+ */
65
+ onResponsiveModeTransition?(event: ContextualSidebarModeTransition): void
45
66
  /** Current host-owned pixel width, reflected by the resize handle. */
46
67
  width: number
47
68
  minimum: number
@@ -91,6 +112,46 @@ export function ContextualSidebar(props: ContextualSidebarProps) {
91
112
  let mobileLoadPending = false
92
113
  let mobileLoadSettled = false
93
114
  let responsiveModeInitialized = false
115
+ let desktopSidebar: HTMLElement | undefined
116
+ let transitionGeneration = 0
117
+ let pendingMode: boolean | undefined
118
+ let disposed = false
119
+ onCleanup(() => {
120
+ disposed = true
121
+ transitionGeneration += 1
122
+ })
123
+
124
+ const transition = (next: boolean, closeStaleOpen: boolean) => {
125
+ // The host may synchronously update its props from either callback, which
126
+ // re-enters the responsive effect before this transition has finished.
127
+ if (pendingMode === next) return
128
+ const previous = untrack(isMobile)
129
+ const changed = responsiveModeInitialized && previous !== next
130
+ const generation =
131
+ changed || pendingMode !== undefined ? ++transitionGeneration : transitionGeneration
132
+ pendingMode = next
133
+ const event = {
134
+ from: previous ? ('mobile' as const) : ('desktop' as const),
135
+ to: next ? ('mobile' as const) : ('desktop' as const),
136
+ desktopSidebar,
137
+ }
138
+ try {
139
+ if (changed) untrack(() => props.onResponsiveModeTransition?.({ ...event, phase: 'before' }))
140
+ if (disposed || generation !== transitionGeneration) return
141
+ if (closeStaleOpen) untrack(() => props.onOpenChange(false))
142
+ if (disposed || generation !== transitionGeneration) return
143
+ if (next) loadMobile()
144
+ setIsMobile(next)
145
+ if (changed) {
146
+ queueMicrotask(() => {
147
+ if (!disposed && generation === transitionGeneration && untrack(isMobile) === next)
148
+ untrack(() => props.onResponsiveModeTransition?.({ ...event, phase: 'after' }))
149
+ })
150
+ }
151
+ } finally {
152
+ if (generation === transitionGeneration) pendingMode = undefined
153
+ }
154
+ }
94
155
  // Keep the resolved component mounted across viewport changes for Sheet cleanup.
95
156
  const loadMobile = () => {
96
157
  if (mobileLoadPending || mobileLoadSettled) return
@@ -124,8 +185,9 @@ export function ContextualSidebar(props: ContextualSidebarProps) {
124
185
  return mount?.connected && mount.element.isConnected ? mount.element : undefined
125
186
  }
126
187
 
188
+ const responsiveMode = createMemo(() => props.responsiveMode ?? 'auto')
127
189
  createEffect(() => {
128
- const mode = props.responsiveMode ?? 'auto'
190
+ const mode = responsiveMode()
129
191
  const wasMobile = untrack(isMobile)
130
192
  let media: MediaQueryList | undefined
131
193
  let viewportListener: (() => void) | undefined
@@ -137,7 +199,7 @@ export function ContextualSidebar(props: ContextualSidebarProps) {
137
199
  })
138
200
 
139
201
  if (mode === 'desktop') {
140
- setIsMobile(false)
202
+ transition(false, false)
141
203
  } else if (mode === 'mobile') {
142
204
  // An explicit host transition into mobile must not briefly open a Sheet
143
205
  // with stale desktop-expanded state. An initial wide-loaded seed still
@@ -145,35 +207,28 @@ export function ContextualSidebar(props: ContextualSidebarProps) {
145
207
  const shouldCloseStaleOpen = responsiveModeInitialized
146
208
  ? !wasMobile && untrack(() => props.open)
147
209
  : untrack(() => props.wideViewportAtLoad && props.open)
148
- if (shouldCloseStaleOpen) untrack(() => props.onOpenChange(false))
149
- loadMobile()
150
- setIsMobile(true)
210
+ transition(true, Boolean(shouldCloseStaleOpen))
151
211
  } else {
152
212
  const mediaQuery = window.matchMedia('(max-width: 48rem)')
153
213
  media = mediaQuery
154
214
  const updateViewport = () => {
155
215
  const nextIsMobile = mediaQuery.matches
156
216
  const wasNarrow = untrack(isMobile)
157
- if (nextIsMobile) loadMobile()
158
217
  // Close before mounting a modal. A desktop-expanded host state is not
159
218
  // mobile intent, and opening the Sheet for one frame can steal focus.
160
- if (nextIsMobile && !wasNarrow) props.onOpenChange(false)
161
- setIsMobile(nextIsMobile)
219
+ transition(nextIsMobile, nextIsMobile && !wasNarrow)
162
220
  }
163
221
  viewportListener = updateViewport
164
222
 
165
223
  // Preserve a narrow-boot open intent. Initial auto and mobile modes use
166
224
  // the viewport seed to clear stale state; runtime transitions close it.
167
- if (media.matches) {
168
- if (!responsiveModeInitialized && untrack(() => props.wideViewportAtLoad && props.open)) {
169
- untrack(() => props.onOpenChange(false))
170
- } else if (responsiveModeInitialized && !wasMobile) {
171
- untrack(() => props.onOpenChange(false))
172
- }
173
- loadMobile()
174
- }
175
- setIsMobile(mediaQuery.matches)
176
- mediaQuery.addEventListener('change', updateViewport)
225
+ const shouldCloseStaleOpen =
226
+ media.matches &&
227
+ (!responsiveModeInitialized
228
+ ? untrack(() => props.wideViewportAtLoad && props.open)
229
+ : !wasMobile)
230
+ transition(media.matches, Boolean(shouldCloseStaleOpen))
231
+ if (!disposed) mediaQuery.addEventListener('change', updateViewport)
177
232
  }
178
233
 
179
234
  responsiveModeInitialized = true
@@ -189,6 +244,7 @@ export function ContextualSidebar(props: ContextualSidebarProps) {
189
244
 
190
245
  onCleanup(() => {
191
246
  if (mobile && mobileMount()?.element === element) setMobileMount(undefined)
247
+ if (!mobile && desktopSidebar === element) desktopSidebar = undefined
192
248
  element = undefined
193
249
  props.onSidebarElement?.(undefined, mobile)
194
250
  })
@@ -204,6 +260,7 @@ export function ContextualSidebar(props: ContextualSidebarProps) {
204
260
  data-open={mobile ? undefined : String(props.open)}
205
261
  ref={(node) => {
206
262
  element = node
263
+ if (!mobile) desktopSidebar = node
207
264
  if (mobile) {
208
265
  setMobileMount({ element: node, connected: node.isConnected })
209
266
  queueMicrotask(() => {
@@ -2,5 +2,6 @@ export {
2
2
  ContextualSidebar,
3
3
  type ContextualSidebarProps,
4
4
  type ContextualSidebarRenderContext,
5
+ type ContextualSidebarModeTransition,
5
6
  } from './contextual-sidebar'
6
7
  export { PixelResizeHandle, type PixelResizeHandleProps } from '../pixel-resize-handle'
@@ -16,14 +16,15 @@ import { Separator } from '../../ui/separator'
16
16
  *
17
17
  * ## Why the divider tracks the sidebar
18
18
  *
19
- * With the sidebar open the divider lands on the sidebar's trailing edge, so the
20
- * bar reads as the rail and sidebar's header on one side and the content's
21
- * header on the other. The bar spans the rail and the sidebar (they sit under
22
- * it), so the leading half is as wide as `--rail-width` plus the sidebar's width
23
- * less the bar's own start padding. The host publishes the width as
24
- * `--shell-sidebar-width` on an ancestor; the fallback of 17rem matches the
25
- * default sidebar. Below the 48rem breakpoint the sidebar is a drawer and the
26
- * leading half is only as wide as its controls.
19
+ * When the host marks an inline sidebar open, the divider lands on the sidebar's
20
+ * trailing edge, so the bar reads as the rail and sidebar's header on one side
21
+ * and the content's header on the other. The bar spans the rail and the sidebar
22
+ * (they sit under it), so the leading half is as wide as `--rail-width` plus the
23
+ * sidebar's width less the bar's own start padding. The host publishes the width
24
+ * as `--shell-sidebar-width` on an ancestor; the fallback of 17rem matches the
25
+ * default sidebar. The default behavior keeps the leading half with its controls
26
+ * below 48rem. A host that keeps the sidebar inline at narrow widths opts into
27
+ * `alignSidebarAtNarrow` so the divider still tracks it.
27
28
  *
28
29
  * ## Narrow windows
29
30
  *
@@ -48,10 +49,15 @@ export type ShellTopBarProps = Omit<ComponentProps<'header'>, 'children'> & {
48
49
  /** The workspace switcher. */
49
50
  workspace?: JSX.Element
50
51
  /**
51
- * Whether the sidebar is open at wide widths. Open, the divider aligns with
52
- * the sidebar's edge; closed, the leading half hugs its controls.
52
+ * Whether the sidebar is open. Its width applies at wide widths by default.
53
53
  */
54
54
  sidebarOpen?: boolean
55
+ /**
56
+ * Also align the open sidebar below the default 48rem breakpoint. Use this
57
+ * when the host keeps the sidebar inline at narrow widths; drawer layouts keep
58
+ * the default controls-only leading half.
59
+ */
60
+ alignSidebarAtNarrow?: boolean
55
61
  /**
56
62
  * The open sidebar's width in pixels. Published as `--shell-sidebar-width` on
57
63
  * the bar so the divider tracks a resizable sidebar; leave it unset to use an
@@ -81,6 +87,7 @@ export function ShellTopBar(props: ShellTopBarProps) {
81
87
  'sidebarToggle',
82
88
  'workspace',
83
89
  'sidebarOpen',
90
+ 'alignSidebarAtNarrow',
84
91
  'sidebarWidth',
85
92
  'breadcrumb',
86
93
  'search',
@@ -132,11 +139,12 @@ export function ShellTopBar(props: ShellTopBarProps) {
132
139
  data-sidebar-open={local.sidebarOpen ? 'true' : 'false'}
133
140
  class={cn(
134
141
  'window-no-drag flex min-h-[calc(var(--topbar-height)-1px)] max-w-full min-w-0 shrink-0 flex-wrap items-center gap-x-2 gap-y-1 pe-3',
135
- /* Wide and open: span the rail and the sidebar so the divider lands on
136
- the sidebar's edge. The sidebar's own border is the 1px the divider
137
- overlaps, so no extra allowance is needed. */
142
+ /* Open sidebar: preserve wide-only alignment unless the host opts into
143
+ the same geometry below the breakpoint. */
138
144
  local.sidebarOpen &&
139
- 'md:w-[calc(var(--rail-width)+var(--shell-sidebar-width,17rem)-var(--shell-top-bar-inset))]'
145
+ (local.alignSidebarAtNarrow
146
+ ? 'w-[calc(var(--rail-width)+var(--shell-sidebar-width,17rem)-var(--shell-top-bar-inset))]'
147
+ : 'md:w-[calc(var(--rail-width)+var(--shell-sidebar-width,17rem)-var(--shell-top-bar-inset))]')
140
148
  )}
141
149
  >
142
150
  <Show when={navigation()}>
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Opt-in no-flash script entry that can project imported token maps synchronously.
3
+ * Import this path only when the host supplies declarative projection rules; the
4
+ * ordinary `components/theme/script` entry stays free of the browser bundle.
5
+ */
6
+ import { themeTokenProjectionBundle } from '@adea-ai/themes/theme-token-projection/script'
7
+ import {
8
+ inlineScriptLiteral,
9
+ themeScriptWithProjection,
10
+ type ThemeScriptOptions as BaseThemeScriptOptions,
11
+ type ThemeTokenProjectionFallback,
12
+ } from './theme-script'
13
+ import type { ThemeTokenProjection } from './token-projection'
14
+
15
+ const tokenProjectionFallbackScript = `if(storedTheme&&tokenProjectionFallbacks.length){var sourceTokens=Object.create(null);for(var sourceName in tokens){if(Object.prototype.hasOwnProperty.call(tokens,sourceName))sourceTokens[sourceName]=tokens[sourceName]}for(var fi=0;fi<tokenProjectionFallbacks.length;fi++){var fallbackToken=tokenProjectionFallbacks[fi];if(!fallbackToken||typeof fallbackToken.token!=='string'||!/^--[A-Za-z0-9_-]+$/.test(fallbackToken.token)||Object.prototype.hasOwnProperty.call(sourceTokens,fallbackToken.token)||!Array.isArray(fallbackToken.path)||fallbackToken.path.length===0)continue;var sourceValue=storedTheme;for(var pi=0;pi<fallbackToken.path.length;pi++){var pathKey=fallbackToken.path[pi];if(typeof pathKey!=='string'||!sourceValue||typeof sourceValue!=='object'||!Object.prototype.hasOwnProperty.call(sourceValue,pathKey)){sourceValue=undefined;break}sourceValue=sourceValue[pathKey]}if(typeof sourceValue==='string')sourceTokens[fallbackToken.token]=sourceValue}tokens=sourceTokens}`
16
+
17
+ /** Options for the projection-enabled boot script. */
18
+ export type ThemeScriptOptions = Omit<BaseThemeScriptOptions, 'libraryKey'> & {
19
+ libraryKey: string
20
+ tokenProjection: ThemeTokenProjection
21
+ /** Optional serialized-record sources for projection tokens omitted by flatTokens. */
22
+ tokenProjectionFallbacks?: readonly ThemeTokenProjectionFallback[]
23
+ }
24
+
25
+ /** Alias that makes the opt-in projection requirement explicit at call sites. */
26
+ export type ThemeScriptProjectionOptions = ThemeScriptOptions
27
+
28
+ /** Emit a no-flash script with the same projector used by provider hydration. */
29
+ export function themeScript(options: ThemeScriptOptions): string {
30
+ return themeScriptWithProjection(
31
+ options,
32
+ options.tokenProjection,
33
+ themeTokenProjectionBundle,
34
+ tokenProjectionFallbackScript
35
+ )
36
+ }
37
+
38
+ export { inlineScriptLiteral }
39
+ export type { ThemeTokenProjectionFallback }
40
+ export type { ThemeStorageSchema } from './theme-persistence'
@@ -3,6 +3,8 @@ import {
3
3
  normalizeAppearanceEditorFontSettings,
4
4
  } from '../../lib/appearance-font-settings'
5
5
  import { terminalCssVariables } from '../../lib/theme-css'
6
+ import type { ThemeTokenProjectionOptions } from './token-projection'
7
+ import { assertThemeTokenProjectionConfig } from './token-projection-options'
6
8
  import type { ThemeEngine } from '../../lib/theme-engine'
7
9
  import type { EditorRolesMode, ThemeAppearance, ThemeVariant } from '../../lib/themes'
8
10
  import { isCustomAccent } from '../../lib/accent-roles'
@@ -78,7 +80,7 @@ export type ThemeDocumentOptions = {
78
80
  * palette stays in the stylesheet.
79
81
  */
80
82
  editorRoles?: EditorRolesMode
81
- }
83
+ } & ThemeTokenProjectionOptions
82
84
 
83
85
  /**
84
86
  * What a catalogue variant still writes inline when its palette is the stylesheet's:
@@ -99,9 +101,9 @@ function stylesheetOverrides(
99
101
  }
100
102
 
101
103
  /**
102
- * The custom properties a state paints: the variant's roles, with the accent
103
- * selection laid over them, the pinned terminal palette over that, the surface
104
- * alpha, then `transformTokens`.
104
+ * The custom properties a state paints: the variant's roles, an optional projection
105
+ * from the raw host map, the accent, the pinned terminal palette, the surface alpha,
106
+ * then `transformTokens`.
105
107
  *
106
108
  * The accent is applied *here* rather than left to the `[data-accent]` blocks in
107
109
  * `theme.css`, because the properties are written inline and an inline declaration
@@ -115,11 +117,22 @@ export function themeDocumentTokensWith(
115
117
  state: ThemeDocumentState,
116
118
  options: ThemeDocumentOptions = {}
117
119
  ): { tokens: Record<string, string>; accented: boolean } {
120
+ assertThemeTokenProjectionConfig(options.tokenProjection)
118
121
  const fromStylesheet =
119
122
  options.palette === 'stylesheet' && engine.isCatalogueVariant(state.variant)
120
123
  const properties = fromStylesheet
121
124
  ? stylesheetOverrides(engine, state.variant, options.editorRoles)
122
125
  : { ...engine.themeCssVariables(state.variant, { editor: options.editorRoles }) }
126
+ if (options.tokenProjection && !engine.isCatalogueVariant(state.variant)) {
127
+ const rawTokens = state.variant.tokens ?? {}
128
+ const projected = options.tokenProjection.project(rawTokens, options.tokenProjection.rules)
129
+ for (const rule of options.tokenProjection.rules) {
130
+ if (!rule || typeof rule.target !== 'string') continue
131
+ if (Object.hasOwn(projected, rule.target)) {
132
+ properties[rule.target] = projected[rule.target]!
133
+ }
134
+ }
135
+ }
123
136
  const accent = engine.accentVariables(state.selection.accent, state.appearance, state.selection, {
124
137
  background: state.variant.colors.background,
125
138
  floor: options.accentContrastFloor,