@deepseek-ai/dsh-client-ui-theme 0.0.1-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,85 @@
1
+ /* Scrollbar skin: the sole consumer of the four --dsw-alias-scrollbar-*
2
+ * tokens. Without it every scrolling region renders the UA scrollbar, which
3
+ * ignores the theme — a light native bar over the dark palette.
4
+ *
5
+ * The rules sit on `body`, not `html`: design-platform.css declares the
6
+ * --dsw-alias-* tokens on `body` (and the dark overrides on
7
+ * `body[data-ds-dark-theme]`), and custom properties only inherit downward,
8
+ * so an `html` rule resolves them to the guaranteed-invalid value and
9
+ * `scrollbar-color` falls back to `auto`.
10
+ *
11
+ * Surfaces pick their elevation by rebinding --dsh-scrollbar-thumb{,-hover}:
12
+ * the l1 pair here is the base-surface default, and an elevated surface
13
+ * (menu, popover, dialog) rebinds to the l2 pair on its own container. Both
14
+ * rendering paths below read the indirection, so one rebind reaches whichever
15
+ * path the engine took. */
16
+
17
+ body {
18
+ --dsh-scrollbar-thumb: var(--dsw-alias-scrollbar-bg-l1);
19
+ --dsh-scrollbar-thumb-hover: var(--dsw-alias-scrollbar-hover-l1);
20
+ }
21
+
22
+ /* The two paths are mutually exclusive, and the gate is load-bearing rather
23
+ than defensive. A non-`auto` `scrollbar-width` or `scrollbar-color` makes
24
+ Chromium and Safari drop every `::-webkit-scrollbar*` rule for that
25
+ element, including `::-webkit-scrollbar-thumb:hover` — measured in chromium
26
+ as an 8px `::-webkit-scrollbar` width taking effect on its own and being
27
+ ignored as soon as `scrollbar-width: thin` is added. Declaring both
28
+ unconditionally therefore leaves the hover tokens with no rendering at all,
29
+ because the engines that implement the hover pseudo-element are exactly the
30
+ ones the standard properties silence, and Firefox has no hover
31
+ pseudo-element to fall back on.
32
+
33
+ `not selector(::-webkit-scrollbar)` is true only where the pseudo-element
34
+ is unimplemented, so Firefox takes the standard path and WebKit-based
35
+ engines take the pseudo-element path. An engine too old for the
36
+ `selector()` function makes the condition invalid, which evaluates false
37
+ and selects the pseudo-element path — the correct side for the pre-16.4
38
+ Safari that is the realistic case. */
39
+ @supports not selector(::-webkit-scrollbar) {
40
+ /* Declared on every element rather than inherited from `body`. Inheriting
41
+ would pass down the COLOUR already substituted at `body`, so a descendant
42
+ rebinding --dsh-scrollbar-thumb could not change it; re-declaring makes
43
+ each element substitute the variable as it sees it, which is what gives
44
+ an elevated surface a working rebind. `scrollbar-width` is not an
45
+ inherited property at all, so it needs the per-element declaration
46
+ regardless.
47
+
48
+ No hover counterpart exists on this path: `scrollbar-color` states one
49
+ thumb colour and the engine derives its own hover treatment. */
50
+ body,
51
+ body * {
52
+ scrollbar-width: thin;
53
+ scrollbar-color: var(--dsh-scrollbar-thumb) transparent;
54
+ }
55
+ }
56
+
57
+ /* Not gated in turn: an engine that does not implement these pseudo-elements
58
+ drops the rules as unknown selectors, so the gate would only restate what
59
+ selector matching already does. Not inherited either, hence the unscoped
60
+ selectors. */
61
+ ::-webkit-scrollbar {
62
+ width: 8px;
63
+ height: 8px;
64
+ }
65
+
66
+ /* Track stays transparent so the thumb reads against whatever surface scrolls
67
+ under it; only the thumb carries a token colour. */
68
+ ::-webkit-scrollbar-track {
69
+ background: transparent;
70
+ }
71
+
72
+ ::-webkit-scrollbar-thumb {
73
+ border-radius: 4px;
74
+ background: var(--dsh-scrollbar-thumb);
75
+ }
76
+
77
+ ::-webkit-scrollbar-thumb:hover {
78
+ background: var(--dsh-scrollbar-thumb-hover);
79
+ }
80
+
81
+ /* Both scrollbars meeting in a corner: no separate token, so the corner
82
+ matches the transparent track rather than the UA's opaque default. */
83
+ ::-webkit-scrollbar-corner {
84
+ background: transparent;
85
+ }
@@ -0,0 +1,31 @@
1
+ /* Syntax-highlight token palette: the values behind shiki's css-variables
2
+ theme (--shiki-* custom properties emitted by the ui-primitives CodeBlock).
3
+ Light values on :root, dark overrides on the body attribute — the same
4
+ cascade as every other token sheet. Background/foreground deliberately
5
+ alias the markdown code-block tokens so highlighted and plain blocks agree. */
6
+
7
+ :root {
8
+ --shiki-foreground: var(--dsw-alias-label-primary);
9
+ --shiki-background: var(--dsw-alias-markdown-code-block);
10
+ --shiki-token-constant: #1c7ed6;
11
+ --shiki-token-string: #2f9e44;
12
+ --shiki-token-comment: #868e96;
13
+ --shiki-token-keyword: #d6336c;
14
+ --shiki-token-parameter: #e8590c;
15
+ --shiki-token-function: #6741d9;
16
+ --shiki-token-string-expression: #2b8a3e;
17
+ --shiki-token-punctuation: #495057;
18
+ --shiki-token-link: #1971c2;
19
+ }
20
+
21
+ body[data-ds-dark-theme] {
22
+ --shiki-token-constant: #4dabf7;
23
+ --shiki-token-string: #69db7c;
24
+ --shiki-token-comment: #adb5bd;
25
+ --shiki-token-keyword: #faa2c1;
26
+ --shiki-token-parameter: #ffa94d;
27
+ --shiki-token-function: #b197fc;
28
+ --shiki-token-string-expression: #8ce99a;
29
+ --shiki-token-punctuation: #ced4da;
30
+ --shiki-token-link: #74c0fc;
31
+ }
@@ -0,0 +1,17 @@
1
+ import type { PropsLocale, PropsRuntime, PropsStore } from '@deepseek-ai/dsh-client-ui-slots';
2
+ import type { ThemePreference } from '../theme-settings.ts';
3
+ import type { createAppearanceRowStore } from './settings-store.ts';
4
+ /** Injected business face: the preference write (t rides the standard locale seat). */
5
+ export interface AppearanceRowInjected {
6
+ /** Switch the theme preference. */
7
+ setTheme: (id: ThemePreference) => void;
8
+ }
9
+ /** Full component props: runtime share + store share + locale seat + injected face. */
10
+ export type AppearanceRowComponentProps = PropsRuntime<'settings.general.item'> & PropsStore<ReturnType<typeof createAppearanceRowStore>> & PropsLocale<'settings.theme'> & AppearanceRowInjected;
11
+ /**
12
+ * Render the Appearance row.
13
+ * @param props - composed slot props.
14
+ * @returns the row element tree.
15
+ */
16
+ export declare function AppearanceRow({ t, setTheme, useStore }: AppearanceRowComponentProps): import("react").JSX.Element;
17
+ //# sourceMappingURL=AppearanceRow.d.ts.map
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Browser theme registry over the `--dsw-*` token stylesheets. The service
3
+ * owns the live theme preference (light/dark/system), resolves `system` through
4
+ * `prefers-color-scheme`, and publishes immutable snapshots; it never touches
5
+ * the DOM — ui-layout's presenter consumes the resolved snapshot. The Host
6
+ * settings scope loads and stores the preference in the user-settings
7
+ * document. The plugin also registers the Appearance preference row into the
8
+ * settings General section — the theme feature owns its own settings surface.
9
+ */
10
+ import type { Context } from '@deepseek-ai/cordis';
11
+ import { type ClientContext, type SettingsScope } from '@deepseek-ai/dsh-client-runtime/client';
12
+ import { type ThemeKey } from './locales.ts';
13
+ import { type ThemePreference, type ThemeSettings } from '../theme-settings.ts';
14
+ export type { AppearanceRowComponentProps, AppearanceRowInjected } from './AppearanceRow.tsx';
15
+ export type { AppearanceRowState } from './settings-store.ts';
16
+ export type { ThemeKey } from './locales.ts';
17
+ export type { ThemePreference, ThemeSettings } from '../theme-settings.ts';
18
+ /** Namespace owning this feature's settings-row copy. */
19
+ export declare const SETTINGS_NS = "settings.theme";
20
+ declare module '@deepseek-ai/dsh-client-ui-slots' {
21
+ interface LocaleNamespaceMap {
22
+ /** The Appearance settings row's copy. */
23
+ 'settings.theme': ThemeKey;
24
+ }
25
+ }
26
+ /** Theme token dictionary: --dsw-alias-* overrides keyed by variable name. */
27
+ export type ThemeTokens = Record<string, string>;
28
+ /** One selectable theme: id, dark/light semantics, and alias-token overrides. */
29
+ export interface ThemeDefinition {
30
+ /** Theme id (the setTheme argument for concrete themes). */
31
+ id: string;
32
+ /**
33
+ * Which base palette this theme builds on. The presenter switches
34
+ * `body[data-ds-dark-theme]` from this field — never from the id.
35
+ */
36
+ colorScheme: 'light' | 'dark';
37
+ /** Alias-layer overrides applied as inline CSS variables over the base palette. */
38
+ tokens: ThemeTokens;
39
+ }
40
+ /** Immutable theme state published on every change. */
41
+ export interface ThemeSnapshot {
42
+ /** The persisted preference (may be `system`). */
43
+ preference: ThemePreference;
44
+ /** The resolved active theme (`system` resolved via prefers-color-scheme). */
45
+ active: ThemeDefinition;
46
+ /** Registered themes in registration order. */
47
+ themes: readonly ThemeDefinition[];
48
+ /** Monotonic change counter (registry or active changes). */
49
+ revision: number;
50
+ }
51
+ declare module '@deepseek-ai/cordis' {
52
+ interface Context {
53
+ theme: ThemeService;
54
+ }
55
+ interface Events {
56
+ /**
57
+ * Theme state changed (preference switched, registry updated, or the OS
58
+ * color scheme changed while the preference is `system`).
59
+ * @param snapshot - Current immutable theme snapshot.
60
+ * @mode emit
61
+ */
62
+ 'theme/change'(snapshot: ThemeSnapshot): void;
63
+ }
64
+ }
65
+ /**
66
+ * Theme registry and preference owner. `light`/`dark` are built in (the base
67
+ * stylesheets carry both palettes); third-party themes register alias-layer
68
+ * overrides. Reads go through {@link getTheme}; writes only through
69
+ * {@link setTheme}; continuous sync only through the `theme/change` event.
70
+ * The service holds the `prefers-color-scheme` media query (environment
71
+ * sensing, not presentation) and re-emits when the OS scheme flips while the
72
+ * preference is `system`.
73
+ */
74
+ export declare class ThemeService {
75
+ private readonly ctx;
76
+ private readonly host;
77
+ private themes;
78
+ private preference;
79
+ private revision;
80
+ private snapshot;
81
+ private readonly media;
82
+ /**
83
+ * @param ctx - owning context (change events are emitted on it; the
84
+ * media-query and scope listeners are released through ctx.effect on dispose).
85
+ * @param host - durable preference scope owned by the same plugin.
86
+ */
87
+ constructor(ctx: Context, host: SettingsScope<ThemeSettings>);
88
+ /**
89
+ * Read the current immutable theme snapshot.
90
+ * @returns the current snapshot (stable reference until the next change).
91
+ */
92
+ getTheme(): ThemeSnapshot;
93
+ /**
94
+ * Switch the theme preference — the only user preference write entry.
95
+ * Built-in preferences are written through the settings scope and every
96
+ * accepted value emits `theme/change`.
97
+ * @param id - a registered theme id or `system`; unknown ids throw.
98
+ */
99
+ setTheme(id: string): void;
100
+ /** Adopt the scope's accepted durable preference without writing it back. */
101
+ private adopt;
102
+ /**
103
+ * Register a theme. Duplicate id throws (single occupant per id; the
104
+ * built-in pair counts; `system` is a preference, not a registrable id).
105
+ * @param definition - theme id, colorScheme, and alias-token overrides.
106
+ * @returns disposer. Disposing the theme backing the active preference
107
+ * resets the preference to the default so the UI never keeps tokens of an
108
+ * unregistered theme.
109
+ */
110
+ register(definition: ThemeDefinition): () => void;
111
+ private buildSnapshot;
112
+ private publish;
113
+ }
114
+ /** Required services: settings transport plus slots/locale for the Appearance row. */
115
+ export declare const inject: string[];
116
+ /**
117
+ * Client plugin body: provide the theme service and register the
118
+ * feature-owned Appearance preference row into the General section's item
119
+ * slot (a feature owns its settings surface).
120
+ * @param ctx - client cordis context.
121
+ */
122
+ export declare function apply(ctx: ClientContext): void;
123
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,18 @@
1
+ /** `settings.theme` namespace dictionaries (the Appearance row's copy). */
2
+ /** Simplified Chinese dictionary (the key-set source of truth). */
3
+ export declare const zh: {
4
+ 'appearance.title': string;
5
+ 'appearance.light': string;
6
+ 'appearance.dark': string;
7
+ 'appearance.system': string;
8
+ };
9
+ /** The settings.theme namespace key union. */
10
+ export type ThemeKey = keyof typeof zh;
11
+ /** English dictionary, checked complete against the zh key set. */
12
+ export declare const en: {
13
+ 'appearance.title': string;
14
+ 'appearance.light': string;
15
+ 'appearance.dark': string;
16
+ 'appearance.system': string;
17
+ };
18
+ //# sourceMappingURL=locales.d.ts.map
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Re-export outlet for the `settings.general.item` slot type consumed by this
3
+ * package's Appearance row. The canonical home is the locale package (the
4
+ * common dependency of every item registrant); this file exists so row
5
+ * modules import the type from within their own package.
6
+ */
7
+ export type { SettingsGeneralItemOwnerProps } from '@deepseek-ai/dsh-client-locale/client';
8
+ //# sourceMappingURL=settings-contract.d.ts.map
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Appearance row slot store: a mirror of the theme service snapshot. The
3
+ * plugin's apply-world change listener is the only writer; the row component
4
+ * reads via props.useStore.
5
+ */
6
+ import { type EngineStoreHandle } from '@deepseek-ai/dsh-client-runtime/client';
7
+ import type { ThemePreference } from '../theme-settings.ts';
8
+ /** Store state mirrored from the theme snapshot. */
9
+ export interface AppearanceRowState {
10
+ /** Persisted preference (selection state reads this, never the resolved active theme). */
11
+ preference: ThemePreference;
12
+ /** Service revision; -1 until first sync so revision 0 lands as a change. */
13
+ revision: number;
14
+ }
15
+ /** Declared action shape giving the exported factory a stable return type. */
16
+ type AppearanceRowActions = {
17
+ sync: (draft: AppearanceRowState, preference: ThemePreference, revision: number) => void;
18
+ };
19
+ /**
20
+ * Declares the Appearance row state and write surface.
21
+ * @returns the store handle.
22
+ */
23
+ export declare function createAppearanceRowStore(): EngineStoreHandle<AppearanceRowState, AppearanceRowActions>;
24
+ export {};
25
+ //# sourceMappingURL=settings-store.d.ts.map
@@ -0,0 +1,9 @@
1
+ /** Host registration for the browser theme preference. */
2
+ import type { Context } from '@deepseek-ai/cordis';
3
+ export { DEFAULT_PREFERENCE, THEME_PREFERENCE_FIELD, THEME_PREFERENCES, THEME_SETTINGS_NAMESPACE, type ThemePreference, type ThemeSettings, } from './theme-settings.ts';
4
+ /**
5
+ * Register the durable theme section when a settings provider exists.
6
+ * @param ctx - Host context whose optional settings service owns the section.
7
+ */
8
+ export declare function apply(ctx: Context): void;
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Package-owned invariant companion for `@deepseek-ai/dsh-client-ui-theme`.
3
+ * @module @deepseek-ai/dsh-client-ui-theme/invariant
4
+ */
5
+ import type { Context } from '@deepseek-ai/cordis';
6
+ /** Cordis companion plugin name. */
7
+ export declare const name = "client-ui-theme-invariant";
8
+ /** Service required before the companion can reserve package ownership. */
9
+ export declare const inject: string[];
10
+ /**
11
+ * Register this package's invariant companion.
12
+ * @param ctx - Cordis context carrying the invariant service.
13
+ * @returns the installed registration's disposer after setup succeeds.
14
+ */
15
+ export declare const apply: (ctx: Context) => Promise<() => void>;
16
+ //# sourceMappingURL=invariant.d.ts.map
@@ -0,0 +1,26 @@
1
+ /** Theme preferences stored in the Host user-settings document. */
2
+ import z from '@deepseek-ai/schemastery';
3
+ /** Built-in preferences accepted at the registry and settings boundaries. */
4
+ export declare const THEME_PREFERENCES: readonly ["light", "dark", "system"];
5
+ /** Settings namespace owned by the theme plugin. */
6
+ export declare const THEME_SETTINGS_NAMESPACE = "ui-theme";
7
+ /** Field carrying the selected built-in theme preference. */
8
+ export declare const THEME_PREFERENCE_FIELD = "preference";
9
+ /** Theme preference persisted by the product Appearance row. */
10
+ export type ThemePreference = typeof THEME_PREFERENCES[number];
11
+ /** Default preference when the user-settings document has no override. */
12
+ export declare const DEFAULT_PREFERENCE: ThemePreference;
13
+ /** Durable theme section shared by the Host schema and the browser scope. */
14
+ export interface ThemeSettings {
15
+ /** Selected built-in preference. */
16
+ preference: ThemePreference;
17
+ }
18
+ /** Durable theme schema; also the wire envelope the browser scope validates against. */
19
+ export declare const ThemeSettingsSchema: z<ThemeSettings>;
20
+ /**
21
+ * Narrow one wire or registry value to a persistable preference.
22
+ * @param value - value crossing the settings or registry boundary.
23
+ * @returns whether the value is a built-in preference.
24
+ */
25
+ export declare function isThemePreference(value: unknown): value is ThemePreference;
26
+ //# sourceMappingURL=theme-settings.d.ts.map
package/package.json ADDED
@@ -0,0 +1,82 @@
1
+ {
2
+ "name": "@deepseek-ai/dsh-client-ui-theme",
3
+ "description": "Theme plugin: ThemeService (light/dark/system preference, prefers-color-scheme resolution, theme/change snapshots; no DOM), --dsw-* token base stylesheets; registers the Appearance settings row",
4
+ "version": "0.0.1-rc.1",
5
+ "publishConfig": {
6
+ "access": "restricted"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/deepseek-ai/deepseek-harness.git",
11
+ "directory": "packages/client/ui-theme"
12
+ },
13
+ "type": "module",
14
+ "main": "lib/index.js",
15
+ "types": "lib/types/index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./lib/types/index.d.ts",
19
+ "default": "./lib/index.js"
20
+ },
21
+ "./invariant": {
22
+ "types": "./lib/types/invariant.d.ts",
23
+ "default": "./lib/invariant.js"
24
+ },
25
+ "./client": {
26
+ "types": "./lib/types/client/index.d.ts",
27
+ "default": "./lib/client.js"
28
+ },
29
+ "./styles/*": "./lib/styles/*",
30
+ "./src/*": "./src/*",
31
+ "./package.json": "./package.json"
32
+ },
33
+ "dsh": {
34
+ "client": {
35
+ "inject": [
36
+ "@deepseek-ai/dsh-client-connection",
37
+ "@deepseek-ai/dsh-client-runtime",
38
+ "@deepseek-ai/dsh-client-locale"
39
+ ],
40
+ "platform": "web",
41
+ "immediately": true
42
+ }
43
+ },
44
+ "license": "BSD-3-Clause",
45
+ "peerDependencies": {
46
+ "react": "^18.2.0",
47
+ "@deepseek-ai/dsh-client-connection": "^0.0.1-rc.1",
48
+ "@deepseek-ai/dsh-client-locale": "^0.0.1-rc.1",
49
+ "@deepseek-ai/dsh-client-runtime": "^0.0.1-rc.1",
50
+ "@deepseek-ai/dsh-client-ui-primitives": "^0.0.1-rc.1",
51
+ "@deepseek-ai/dsh-client-ui-slots": "^0.0.1-rc.1",
52
+ "@deepseek-ai/dsh-invariants": "^0.0.1-rc.1",
53
+ "@deepseek-ai/cordis": "^4.0.1-rc.1"
54
+ },
55
+ "devDependencies": {
56
+ "@types/react": "~18.3.1",
57
+ "react": "^18.2.0",
58
+ "@deepseek-ai/dsh-client-runtime": "^0.0.1-rc.1",
59
+ "@deepseek-ai/dsh-client-test-runtime": "^0.0.1-rc.1",
60
+ "@deepseek-ai/dsh-client-ui-primitives": "^0.0.1-rc.1",
61
+ "@deepseek-ai/dsh-client-locale": "^0.0.1-rc.1",
62
+ "@deepseek-ai/dsh-client-ui-slots": "^0.0.1-rc.1",
63
+ "@deepseek-ai/dsh-invariants": "^0.0.1-rc.1",
64
+ "@deepseek-ai/cordis": "^4.0.1-rc.1"
65
+ },
66
+ "files": [
67
+ "lib/index.js",
68
+ "lib/invariant.js",
69
+ "lib/client.js",
70
+ "lib/styles",
71
+ "lib/types/**/*.d.ts"
72
+ ],
73
+ "dependencies": {
74
+ "clsx": "^2.0.0",
75
+ "@deepseek-ai/dsh-settings": "^0.0.1-rc.1",
76
+ "@deepseek-ai/schemastery": "^3.18.1-rc.1"
77
+ },
78
+ "scripts": {
79
+ "bundle": "tsdown",
80
+ "watch": "tsdown --watch"
81
+ }
82
+ }