@opencode/theme 0.0.0-dev-19788 → 0.0.0-dev-19793
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.
- package/dist/tui/defaults.d.ts +2 -36
- package/dist/tui/defaults.js +2 -16
- package/dist/tui/expand.js +1 -3
- package/dist/tui/index.d.ts +2 -2
- package/dist/tui/index.js +1 -1
- package/dist/tui/resolve.d.ts +3 -3
- package/dist/tui/resolve.js +20 -27
- package/dist/tui/schema.d.ts +1132 -3108
- package/dist/tui/schema.js +4 -7
- package/dist/tui/types.d.ts +5 -3
- package/dist/tui/v1-migrate.js +1 -2
- package/package.json +1 -1
package/dist/tui/defaults.d.ts
CHANGED
|
@@ -253,7 +253,7 @@ export declare const DEFAULT_THEME: {
|
|
|
253
253
|
imageText: string;
|
|
254
254
|
codeBlock: string;
|
|
255
255
|
};
|
|
256
|
-
"@
|
|
256
|
+
"@dialog": {
|
|
257
257
|
text: {
|
|
258
258
|
action: {
|
|
259
259
|
primary: {
|
|
@@ -271,23 +271,6 @@ export declare const DEFAULT_THEME: {
|
|
|
271
271
|
};
|
|
272
272
|
};
|
|
273
273
|
};
|
|
274
|
-
"@context:overlay": {
|
|
275
|
-
text: {
|
|
276
|
-
action: {
|
|
277
|
-
primary: {
|
|
278
|
-
default: string;
|
|
279
|
-
};
|
|
280
|
-
};
|
|
281
|
-
};
|
|
282
|
-
background: {
|
|
283
|
-
default: string;
|
|
284
|
-
action: {
|
|
285
|
-
primary: {
|
|
286
|
-
default: string;
|
|
287
|
-
};
|
|
288
|
-
};
|
|
289
|
-
};
|
|
290
|
-
};
|
|
291
274
|
};
|
|
292
275
|
dark: {
|
|
293
276
|
hue: {
|
|
@@ -541,7 +524,7 @@ export declare const DEFAULT_THEME: {
|
|
|
541
524
|
imageText: string;
|
|
542
525
|
codeBlock: string;
|
|
543
526
|
};
|
|
544
|
-
"@
|
|
527
|
+
"@dialog": {
|
|
545
528
|
text: {
|
|
546
529
|
action: {
|
|
547
530
|
primary: {
|
|
@@ -559,22 +542,5 @@ export declare const DEFAULT_THEME: {
|
|
|
559
542
|
};
|
|
560
543
|
};
|
|
561
544
|
};
|
|
562
|
-
"@context:overlay": {
|
|
563
|
-
text: {
|
|
564
|
-
action: {
|
|
565
|
-
primary: {
|
|
566
|
-
default: string;
|
|
567
|
-
};
|
|
568
|
-
};
|
|
569
|
-
};
|
|
570
|
-
background: {
|
|
571
|
-
default: string;
|
|
572
|
-
action: {
|
|
573
|
-
primary: {
|
|
574
|
-
default: string;
|
|
575
|
-
};
|
|
576
|
-
};
|
|
577
|
-
};
|
|
578
|
-
};
|
|
579
545
|
};
|
|
580
546
|
};
|
package/dist/tui/defaults.js
CHANGED
|
@@ -215,20 +215,13 @@ export const DEFAULT_THEME = {
|
|
|
215
215
|
imageText: "$hue.cyan.600",
|
|
216
216
|
codeBlock: "$hue.neutral.900",
|
|
217
217
|
},
|
|
218
|
-
"@
|
|
218
|
+
"@dialog": {
|
|
219
219
|
text: { action: { primary: { default: "$hue.neutral.100" } } },
|
|
220
220
|
background: {
|
|
221
221
|
default: "$background.raised.base",
|
|
222
222
|
action: { primary: { default: "$hue.interactive.500", $hovered: "$background.raised.high" } },
|
|
223
223
|
},
|
|
224
224
|
},
|
|
225
|
-
"@context:overlay": {
|
|
226
|
-
text: { action: { primary: { default: "$hue.neutral.100" } } },
|
|
227
|
-
background: {
|
|
228
|
-
default: "$background.raised.high",
|
|
229
|
-
action: { primary: { default: "$hue.interactive.500" } },
|
|
230
|
-
},
|
|
231
|
-
},
|
|
232
225
|
},
|
|
233
226
|
dark: {
|
|
234
227
|
hue: {
|
|
@@ -437,19 +430,12 @@ export const DEFAULT_THEME = {
|
|
|
437
430
|
imageText: "$hue.cyan.400",
|
|
438
431
|
codeBlock: "$hue.neutral.100",
|
|
439
432
|
},
|
|
440
|
-
"@
|
|
433
|
+
"@dialog": {
|
|
441
434
|
text: { action: { primary: { default: "$hue.neutral.200" } } },
|
|
442
435
|
background: {
|
|
443
436
|
default: "$background.raised.base",
|
|
444
437
|
action: { primary: { default: "$hue.interactive.400", $hovered: "$background.raised.high" } },
|
|
445
438
|
},
|
|
446
439
|
},
|
|
447
|
-
"@context:overlay": {
|
|
448
|
-
text: { action: { primary: { default: "$hue.neutral.200" } } },
|
|
449
|
-
background: {
|
|
450
|
-
default: "$background.raised.high",
|
|
451
|
-
action: { primary: { default: "$hue.interactive.400" } },
|
|
452
|
-
},
|
|
453
|
-
},
|
|
454
440
|
},
|
|
455
441
|
};
|
package/dist/tui/expand.js
CHANGED
|
@@ -3,9 +3,7 @@ export function expandTheme(definition) {
|
|
|
3
3
|
return {
|
|
4
4
|
...definition,
|
|
5
5
|
...expandTokens(definition),
|
|
6
|
-
...
|
|
7
|
-
.filter(([key]) => key.startsWith("@context:"))
|
|
8
|
-
.map(([key, value]) => [key, expandTokens(value)])),
|
|
6
|
+
...(definition["@dialog"] ? { "@dialog": expandTokens(definition["@dialog"]) } : {}),
|
|
9
7
|
};
|
|
10
8
|
}
|
|
11
9
|
export function expandTokens(definition) {
|
package/dist/tui/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { ActionState, type ActionStateKey, ActionVariant, BaseHue, CategoricalDefinition, FeedbackKind, FormfieldState, type FormfieldStateKey, HueAlias, HueName, HueStep, MarkdownDefinition, MarkdownToken, ModeDefinition, SyntaxDefinition, SyntaxToken, ThemeDefinition, ThemeDocument, type BackgroundDefinition, type DiffDefinition, type FileThemeDefinition, type FormfieldColorDefinition, type HueDefinition, type HueOverrideDefinition, type MergeModeDefinition, type Mode, type StatefulColorDefinition, type
|
|
2
|
-
export type { Categorical,
|
|
1
|
+
export { ActionState, type ActionStateKey, ActionVariant, BaseHue, CategoricalDefinition, FeedbackKind, FormfieldState, type FormfieldStateKey, HueAlias, HueName, HueStep, MarkdownDefinition, MarkdownToken, ModeDefinition, SurfaceName, SyntaxDefinition, SyntaxToken, ThemeDefinition, ThemeDocument, type BackgroundDefinition, type DiffDefinition, type FileThemeDefinition, type FormfieldColorDefinition, type HueDefinition, type HueOverrideDefinition, type MergeModeDefinition, type Mode, type StatefulColorDefinition, type TextDefinition, type ThemeTokensDefinition, } from "./schema.js";
|
|
2
|
+
export type { Categorical, FormfieldColor, Hue, HueSource, HueScale, ResolvedActionState, ResolvedFormfieldState, ResolvedTheme, ResolvedThemeTokens, StatefulColor, } from "./types.js";
|
|
3
3
|
export { DEFAULT_CATEGORICAL, DEFAULT_THEME } from "./defaults.js";
|
|
4
4
|
export { expandTheme } from "./expand.js";
|
|
5
5
|
export { migrateV1 } from "./v1-migrate.js";
|
package/dist/tui/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { ActionState, ActionVariant, BaseHue, CategoricalDefinition, FeedbackKind, FormfieldState, HueAlias, HueName, HueStep, MarkdownDefinition, MarkdownToken, ModeDefinition, SyntaxDefinition, SyntaxToken, ThemeDefinition, ThemeDocument, } from "./schema.js";
|
|
1
|
+
export { ActionState, ActionVariant, BaseHue, CategoricalDefinition, FeedbackKind, FormfieldState, HueAlias, HueName, HueStep, MarkdownDefinition, MarkdownToken, ModeDefinition, SurfaceName, SyntaxDefinition, SyntaxToken, ThemeDefinition, ThemeDocument, } from "./schema.js";
|
|
2
2
|
export { DEFAULT_CATEGORICAL, DEFAULT_THEME } from "./defaults.js";
|
|
3
3
|
export { expandTheme } from "./expand.js";
|
|
4
4
|
export { migrateV1 } from "./v1-migrate.js";
|
package/dist/tui/resolve.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ThemeDefinition, ThemeDocument } from "./schema.js";
|
|
2
|
-
import type { ResolvedTheme } from "./index.js";
|
|
2
|
+
import type { Mode, ResolvedTheme } from "./index.js";
|
|
3
3
|
export declare function themeDecodeError(error: unknown, name: string): Error;
|
|
4
|
-
export declare function resolveThemeDocument(document: ThemeDocument, mode?:
|
|
5
|
-
export declare function resolveTheme(definition: ThemeDefinition): ResolvedTheme;
|
|
4
|
+
export declare function resolveThemeDocument(document: ThemeDocument, mode?: Mode): ResolvedTheme;
|
|
5
|
+
export declare function resolveTheme(definition: ThemeDefinition, mode: Mode): ResolvedTheme;
|
package/dist/tui/resolve.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Schema } from "effect";
|
|
|
3
3
|
import { DEFAULT_CATEGORICAL, DEFAULT_THEME } from "./defaults.js";
|
|
4
4
|
import { expandTheme, expandTokens, mergeTheme } from "./expand.js";
|
|
5
5
|
import { fallback } from "./fallback.js";
|
|
6
|
-
import { ActionState, ActionVariant, BaseHue,
|
|
6
|
+
import { ActionState, ActionVariant, BaseHue, HueAlias, HueStep, SurfaceName, ThemeDefinition, ThemeDocument, } from "./schema.js";
|
|
7
7
|
import { selectTheme, selectThemeMode } from "./select.js";
|
|
8
8
|
const decodeThemeDefinitionSchema = Schema.decodeUnknownSync(ThemeDefinition, { reportInput: true });
|
|
9
9
|
function decodeThemeDefinition(input) {
|
|
@@ -30,28 +30,25 @@ export function resolveThemeDocument(document, mode) {
|
|
|
30
30
|
return resolveExpandedTheme({
|
|
31
31
|
...merged,
|
|
32
32
|
categorical: merged["categorical"] ?? DEFAULT_CATEGORICAL,
|
|
33
|
-
});
|
|
33
|
+
}, selected.mode);
|
|
34
34
|
}
|
|
35
|
-
export function resolveTheme(definition) {
|
|
36
|
-
return resolveExpandedTheme(expandTheme(decodeThemeDefinition(definition)));
|
|
35
|
+
export function resolveTheme(definition, mode) {
|
|
36
|
+
return resolveExpandedTheme(expandTheme(decodeThemeDefinition(definition)), mode);
|
|
37
37
|
}
|
|
38
|
-
function resolveExpandedTheme(definition) {
|
|
38
|
+
function resolveExpandedTheme(definition, mode) {
|
|
39
39
|
const hue = resolveHue(definition.hue);
|
|
40
40
|
const categorical = (definition.categorical ?? DEFAULT_CATEGORICAL).map((name) => hue[name]);
|
|
41
41
|
const hueSteps = compileHueSteps(hue);
|
|
42
|
+
const raise = (color) => (mode === "light" ? hueSteps.increase(color) : hueSteps.decrease(color));
|
|
42
43
|
const base = tokens(definition);
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
elevated: context("elevated"),
|
|
52
|
-
overlay: context("overlay"),
|
|
53
|
-
};
|
|
54
|
-
return { ...resolved, contextual };
|
|
44
|
+
const views = {};
|
|
45
|
+
const view = (tokens) => ({
|
|
46
|
+
...resolveView(tokens, hue, categorical, hueSteps),
|
|
47
|
+
raise,
|
|
48
|
+
surface: (name) => views[name],
|
|
49
|
+
});
|
|
50
|
+
views.dialog = definition["@dialog"] ? view(contextualize(base, definition["@dialog"])) : view(base);
|
|
51
|
+
return view(base);
|
|
55
52
|
}
|
|
56
53
|
function tokens(definition) {
|
|
57
54
|
return {
|
|
@@ -66,30 +63,26 @@ function tokens(definition) {
|
|
|
66
63
|
}
|
|
67
64
|
function contextualize(base, override) {
|
|
68
65
|
const result = mergeTheme(base, override);
|
|
69
|
-
const baseText = base.text?.action;
|
|
70
|
-
const contextText = override.text?.action;
|
|
71
|
-
const baseBackground = base.background?.action;
|
|
72
|
-
const contextBackground = override.background?.action;
|
|
73
66
|
const text = result["text"];
|
|
74
67
|
const background = result["background"];
|
|
75
68
|
return {
|
|
76
69
|
...result,
|
|
77
|
-
text: { ...text, action: contextualActions(
|
|
78
|
-
background: { ...background, action: contextualActions(
|
|
70
|
+
text: { ...text, action: contextualActions(base.text?.action, override.text?.action) },
|
|
71
|
+
background: { ...background, action: contextualActions(base.background?.action, override.background?.action) },
|
|
79
72
|
};
|
|
80
73
|
}
|
|
81
|
-
function contextualActions(base,
|
|
74
|
+
function contextualActions(base, surface) {
|
|
82
75
|
return Object.fromEntries(ActionVariant.literals.map((variant) => {
|
|
83
76
|
const baseVariant = base?.[variant];
|
|
84
|
-
const
|
|
77
|
+
const surfaceVariant = surface?.[variant];
|
|
85
78
|
return [
|
|
86
79
|
variant,
|
|
87
80
|
Object.fromEntries(["default", ...ActionState.literals].map((state) => {
|
|
88
81
|
const key = state === "default" ? undefined : `$${state}`;
|
|
89
82
|
return [
|
|
90
83
|
key ?? "default",
|
|
91
|
-
(key ?
|
|
92
|
-
|
|
84
|
+
(key ? surfaceVariant?.[key] : undefined) ??
|
|
85
|
+
surfaceVariant?.default ??
|
|
93
86
|
(key ? baseVariant?.[key] : undefined) ??
|
|
94
87
|
baseVariant?.default,
|
|
95
88
|
];
|