@qilin-agent/client-ui-theme 3.1.4 → 3.1.6

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.
@@ -1,11 +1,53 @@
1
- /** Host registration for the browser theme preference and pre-plugin palette. */
1
+ import type { Volatile } from '@qilin-agent/kylin';
2
+ import type { ThemePreference } from './theme-settings.ts';
3
+ import z from '@qilin-agent/schemastery';
2
4
  import type { Context } from '@qilin-agent/kylin';
3
- export { DEFAULT_FONT_SIZE, DEFAULT_PREFERENCE, FONT_SIZE_FIELD, FONT_SIZE_MAX, FONT_SIZE_MIN, THEME_PREFERENCE_FIELD, THEME_PREFERENCES, THEME_SETTINGS_NAMESPACE, type ThemePreference, type ThemeSettings, } from './theme-settings.ts';
5
+ import { type FontFamilies } from './theme-settings.ts';
6
+ export { DEFAULT_FONT_SIZE, DEFAULT_PREFERENCE, FONT_FAMILY_FIELDS, FONT_SIZE_FIELD, FONT_SIZE_MAX, FONT_SIZE_MIN, FONT_ROLES, FONT_SIZE_SPECS, THEME_PREFERENCE_FIELD, THEME_PREFERENCES, THEME_SETTINGS_NAMESPACE, type FontFamilies, type FontRole, type FontSizes, type ThemePreference, type ThemeSettings, } from './theme-settings.ts';
4
7
  /**
5
- * Register the durable theme section when the optional settings service is
6
- * composed, and answer every index injection collection with the current
7
- * theme bootstrap row.
8
- * @param ctx - Host context that may acquire the settings service.
8
+ * Font-family lists read from the live config, keyed by role.
9
+ * @param families - the detached per-role lists.
10
+ * @returns the frozen per-role font-family lists.
9
11
  */
10
- export declare function apply(ctx: Context): void;
12
+ export declare function sectionFontFamilies(families: FontFamilies): FontFamilies;
13
+ /** Runtime preferences projected to the browser. */
14
+ export interface Config {
15
+ /** Browser palette preference. */
16
+ preference: Volatile<ThemePreference>;
17
+ /** Browser font size in pixels. */
18
+ fontSize: Volatile<number>;
19
+ /** Code-block font size in pixels. */
20
+ codeFontSize: Volatile<number>;
21
+ /** Sidebar terminal font size in pixels. */
22
+ terminalFontSize: Volatile<number>;
23
+ /** Interface and body text font list; `''` keeps the built-in stack. */
24
+ textFontFamily: Volatile<string>;
25
+ /** Code font list; `''` keeps the built-in stack. */
26
+ codeFontFamily: Volatile<string>;
27
+ /** Sidebar terminal font list; `''` keeps the built-in stack. */
28
+ terminalFontFamily: Volatile<string>;
29
+ }
30
+ /** Live theme and typography preferences. */
31
+ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
32
+ preference: z<"light" | "dark" | "system", "light" | "dark" | "system", "volatile-defined">;
33
+ fontSize: z<number, number, "volatile">;
34
+ codeFontSize: z<number, number, "volatile">;
35
+ terminalFontSize: z<number, number, "volatile">;
36
+ textFontFamily: z<string, string, "volatile-defined">;
37
+ codeFontFamily: z<string, string, "volatile-defined">;
38
+ terminalFontFamily: z<string, string, "volatile-defined">;
39
+ }>>, Schemastery.ObjectT<NoInfer<{
40
+ preference: z<"light" | "dark" | "system", "light" | "dark" | "system", "volatile-defined">;
41
+ fontSize: z<number, number, "volatile">;
42
+ codeFontSize: z<number, number, "volatile">;
43
+ terminalFontSize: z<number, number, "volatile">;
44
+ textFontFamily: z<string, string, "volatile-defined">;
45
+ codeFontFamily: z<string, string, "volatile-defined">;
46
+ terminalFontFamily: z<string, string, "volatile-defined">;
47
+ }>>, "plain">;
48
+ /** Supply the current palette before browser plugins start.
49
+ * @param ctx Host plugin context.
50
+ * @param config Validated live theme preferences.
51
+ */
52
+ export declare function apply(ctx: Context, config: Config): void;
11
53
  //# sourceMappingURL=index.d.ts.map
@@ -18,15 +18,117 @@ export declare const FONT_SIZE_MIN = 10;
18
18
  export declare const FONT_SIZE_MAX = 22;
19
19
  /** Content font size when the user-settings document has no override (px). */
20
20
  export declare const DEFAULT_FONT_SIZE = 14;
21
+ /** Independently configurable font roles. */
22
+ export declare const FONT_ROLES: readonly ["text", "code", "terminal"];
23
+ /** One configurable font role: interface text, code, or the sidebar terminal. */
24
+ export type FontRole = typeof FONT_ROLES[number];
25
+ /** Settings field, body variable, and accepted integer px range of one role's font size. */
26
+ export interface FontSizeSpec {
27
+ /** Settings field carrying the size. */
28
+ field: string;
29
+ /** Body variable carrying the size in px. */
30
+ variable: string;
31
+ /** Smallest accepted size. */
32
+ min: number;
33
+ /** Largest accepted size. */
34
+ max: number;
35
+ /** Size when the user-settings document has no override. */
36
+ default: number;
37
+ }
38
+ /**
39
+ * Font sizes by role. `text` is the conversation content size; `code` is the
40
+ * code-block size (inline code stays 1px larger); `terminal` is the sidebar
41
+ * terminal cell font size.
42
+ */
43
+ export declare const FONT_SIZE_SPECS: {
44
+ readonly text: {
45
+ readonly field: "fontSize";
46
+ readonly variable: "--qilin-content-font-size";
47
+ readonly min: 10;
48
+ readonly max: 22;
49
+ readonly default: 14;
50
+ };
51
+ readonly code: {
52
+ readonly field: "codeFontSize";
53
+ readonly variable: "--qilin-code-font-size";
54
+ readonly min: 10;
55
+ readonly max: 16;
56
+ readonly default: 11;
57
+ };
58
+ readonly terminal: {
59
+ readonly field: "terminalFontSize";
60
+ readonly variable: "--qilin-terminal-font-size";
61
+ readonly min: 10;
62
+ readonly max: 20;
63
+ readonly default: 13;
64
+ };
65
+ };
66
+ /** Integer px font sizes by role. */
67
+ export type FontSizes = Readonly<Record<FontRole, number>>;
68
+ /** Default font sizes by role. */
69
+ export declare const DEFAULT_FONT_SIZES: FontSizes;
70
+ /** Settings field carrying each role's font-family list. */
71
+ export declare const FONT_FAMILY_FIELDS: {
72
+ readonly text: "textFontFamily";
73
+ readonly code: "codeFontFamily";
74
+ readonly terminal: "terminalFontFamily";
75
+ };
76
+ /**
77
+ * Body variable carrying one role's normalized font list; the token sheet
78
+ * places it ahead of that role's built-in stack.
79
+ * @param kind - font role.
80
+ * @returns the CSS custom property name.
81
+ */
82
+ export declare function fontFamilyVariable(kind: FontRole): string;
83
+ /** Normalized CSS font-family lists by role; `''` selects the built-in stack. */
84
+ export type FontFamilies = Readonly<Record<FontRole, string>>;
21
85
  /** Durable theme section shared by the Host schema and the browser scope. */
22
86
  export interface ThemeSettings {
23
87
  /** Selected built-in preference. */
24
88
  preference: ThemePreference;
25
89
  /** Conversation content font size in px (integer within {@link FONT_SIZE_MIN}..{@link FONT_SIZE_MAX}). */
26
90
  fontSize: number;
91
+ /** Code-block font size in px (integer within the {@link FONT_SIZE_SPECS} `code` range). */
92
+ codeFontSize: number;
93
+ /** Sidebar terminal font size in px (integer within the {@link FONT_SIZE_SPECS} `terminal` range). */
94
+ terminalFontSize: number;
95
+ /** Interface and body text fonts placed before the built-in stack; `''` keeps the built-in stack. */
96
+ textFontFamily: string;
97
+ /** Code fonts placed before the built-in code stack; `''` keeps the built-in stack. */
98
+ codeFontFamily: string;
99
+ /** Sidebar terminal fonts placed before the built-in terminal stack; `''` keeps the built-in stack. */
100
+ terminalFontFamily: string;
27
101
  }
102
+ /**
103
+ * Integer px schema for one role's font size.
104
+ * @param spec - the role's range and default.
105
+ * @returns the validated number schema.
106
+ */
107
+ export declare function fontSizeSchema(spec: FontSizeSpec): z<number>;
108
+ /**
109
+ * Collect every role's size from a settings section.
110
+ * @param section - accepted theme settings.
111
+ * @returns integer px sizes by role.
112
+ */
113
+ export declare function sectionFontSizes(section: ThemeSettings): FontSizes;
114
+ /**
115
+ * Whether one value is an accepted size for a role.
116
+ * @param role - font role.
117
+ * @param px - candidate size.
118
+ * @returns true for an integer within the role's range.
119
+ */
120
+ export declare function isFontSize(role: FontRole, px: number): boolean;
28
121
  /** Durable theme schema; also the wire envelope the browser scope validates against. */
29
122
  export declare const ThemeSettingsSchema: z<ThemeSettings>;
123
+ /**
124
+ * Normalize user input into a CSS font-family list. Names are comma separated;
125
+ * quotes, backslashes, angle brackets, and control characters are dropped, and
126
+ * every non-generic name is double-quoted, so the result is always a valid list
127
+ * safe to embed in inline CSS and boot scripts. Normalizing a result returns it unchanged.
128
+ * @param value - user-entered or stored font list.
129
+ * @returns the normalized list, or `''` when no family name remains.
130
+ */
131
+ export declare function normalizeFontFamily(value: string): string;
30
132
  /**
31
133
  * Narrow one wire or registry value to a persistable preference.
32
134
  * @param value - value crossing the settings or registry boundary.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@qilin-agent/client-ui-theme",
3
3
  "description": "Theme plugin: Host bootstrap for the pre-plugin palette; DOM-free ThemeRuntime for light/dark/system state; --qilin-* token styles and Appearance settings row",
4
- "version": "3.1.4",
4
+ "version": "3.1.6",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -35,6 +35,7 @@
35
35
  "@qilin-agent/client-locale",
36
36
  "@qilin-agent/client-ui-renderer",
37
37
  "@qilin-agent/client-ui-settings",
38
+ "@qilin-agent/client-shortcuts",
38
39
  "@qilin-agent/api-remotes"
39
40
  ],
40
41
  "platform": "web",
@@ -43,24 +44,25 @@
43
44
  },
44
45
  "license": "MIT",
45
46
  "peerDependencies": {
46
- "@qilin-agent/kylin": "~4.0.3"
47
+ "@qilin-agent/kylin": "~4.0.5"
47
48
  },
48
49
  "devDependencies": {
49
50
  "@types/react": "~18.3.1",
50
51
  "react": "^18.2.0",
51
52
  "clsx": "^2.0.0",
52
- "@qilin-agent/api-remotes": "3.1.4",
53
- "@qilin-agent/kylin": "~4.0.3",
54
- "@qilin-agent/client-connection": "3.1.4",
55
- "@qilin-agent/client-locale": "3.1.4",
56
- "@qilin-agent/client-store": "3.1.4",
57
- "@qilin-agent/client-test-runtime": "3.1.4",
58
- "@qilin-agent/client-ui-settings": "3.1.4",
59
- "@qilin-agent/client-ui-renderer": "3.1.4",
60
- "@qilin-agent/client-ui-slots": "3.1.4",
61
- "@qilin-agent/settings": "3.1.4",
62
- "@qilin-agent/host-webserver": "3.1.4",
63
- "@qilin-agent/client-ui-primitives": "3.1.4"
53
+ "@qilin-agent/kylin": "~4.0.5",
54
+ "@qilin-agent/api-remotes": "3.1.6",
55
+ "@qilin-agent/client-locale": "3.1.6",
56
+ "@qilin-agent/client-store": "3.1.6",
57
+ "@qilin-agent/client-shortcuts": "3.1.6",
58
+ "@qilin-agent/client-connection": "3.1.6",
59
+ "@qilin-agent/client-test-runtime": "3.1.6",
60
+ "@qilin-agent/client-ui-primitives": "3.1.6",
61
+ "@qilin-agent/client-ui-settings": "3.1.6",
62
+ "@qilin-agent/client-ui-slots": "3.1.6",
63
+ "@qilin-agent/settings": "3.1.6",
64
+ "@qilin-agent/client-ui-renderer": "3.1.6",
65
+ "@qilin-agent/host-webserver": "3.1.6"
64
66
  },
65
67
  "files": [
66
68
  "lib/index.js",
@@ -69,7 +71,7 @@
69
71
  "lib/types/**/*.d.ts"
70
72
  ],
71
73
  "dependencies": {
72
- "@qilin-agent/schemastery": "~3.18.3"
74
+ "@qilin-agent/schemastery": "~3.18.5"
73
75
  },
74
76
  "scripts": {
75
77
  "bundle": "tsdown",