@opencode/theme 0.0.0-dev-19794 → 0.0.0-dev-19808
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/categorical.d.ts +1 -0
- package/dist/tui/categorical.js +1 -0
- package/dist/tui/expand.js +7 -7
- package/dist/tui/index.d.ts +2 -2
- package/dist/tui/index.js +2 -2
- package/dist/tui/resolve.d.ts +1 -1
- package/dist/tui/resolve.js +16 -28
- package/dist/tui/schema.d.ts +1034 -2485
- package/dist/tui/schema.js +82 -42
- package/dist/tui/select.d.ts +3 -8
- package/dist/tui/select.js +2 -20
- package/dist/tui/syntax.d.ts +2 -2
- package/dist/tui/syntax.js +19 -19
- package/dist/tui/types.d.ts +9 -17
- package/dist/tui/v1-migrate.js +79 -53
- package/package.json +1 -1
- package/dist/tui/defaults.d.ts +0 -546
- package/dist/tui/defaults.js +0 -441
- package/dist/tui/fallback.d.ts +0 -2
- package/dist/tui/fallback.js +0 -56
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DEFAULT_CATEGORICAL: readonly ["blue", "purple", "green", "orange", "red", "cyan"];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const DEFAULT_CATEGORICAL = ["blue", "purple", "green", "orange", "red", "cyan"];
|
package/dist/tui/expand.js
CHANGED
|
@@ -18,7 +18,7 @@ export function mergeTheme(...values) {
|
|
|
18
18
|
if (!isRecord(value))
|
|
19
19
|
return result;
|
|
20
20
|
return Object.entries(value).reduce((next, [key, item]) => {
|
|
21
|
-
if (item === undefined
|
|
21
|
+
if (item === undefined)
|
|
22
22
|
return next;
|
|
23
23
|
return {
|
|
24
24
|
...next,
|
|
@@ -32,7 +32,7 @@ function expandText(definition) {
|
|
|
32
32
|
return;
|
|
33
33
|
return {
|
|
34
34
|
...definition,
|
|
35
|
-
|
|
35
|
+
muted: definition.muted ?? (definition.base ? "$text.base" : undefined),
|
|
36
36
|
action: expandActions(definition.action, "text.action"),
|
|
37
37
|
formfield: expandFormfield(definition.formfield, "text.formfield"),
|
|
38
38
|
feedback: definition.feedback
|
|
@@ -41,7 +41,7 @@ function expandText(definition) {
|
|
|
41
41
|
kind,
|
|
42
42
|
{
|
|
43
43
|
...feedback,
|
|
44
|
-
|
|
44
|
+
muted: feedback.muted ?? (feedback.base ? `$text.feedback.${kind}.base` : undefined),
|
|
45
45
|
},
|
|
46
46
|
];
|
|
47
47
|
}))
|
|
@@ -58,24 +58,24 @@ function expandBackground(definition) {
|
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
60
|
function expandFormfield(definition, path) {
|
|
61
|
-
if (!definition?.
|
|
61
|
+
if (!definition?.base)
|
|
62
62
|
return definition;
|
|
63
63
|
return {
|
|
64
64
|
...definition,
|
|
65
|
-
...Object.fromEntries(ActionState.literals.map((state) => [`$${state}`, definition[`$${state}`] ?? `$${path}.
|
|
65
|
+
...Object.fromEntries(ActionState.literals.map((state) => [`$${state}`, definition[`$${state}`] ?? `$${path}.base`])),
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
68
|
function expandActions(definition, path) {
|
|
69
69
|
if (!definition)
|
|
70
70
|
return;
|
|
71
71
|
return Object.fromEntries(Object.entries(definition).map(([variant, value]) => {
|
|
72
|
-
if (!value?.
|
|
72
|
+
if (!value?.base)
|
|
73
73
|
return [variant, value];
|
|
74
74
|
return [
|
|
75
75
|
variant,
|
|
76
76
|
{
|
|
77
77
|
...value,
|
|
78
|
-
...Object.fromEntries(ActionState.literals.map((state) => [`$${state}`, value[`$${state}`] ?? `$${path}.${variant}.
|
|
78
|
+
...Object.fromEntries(ActionState.literals.map((state) => [`$${state}`, value[`$${state}`] ?? `$${path}.${variant}.base`])),
|
|
79
79
|
},
|
|
80
80
|
];
|
|
81
81
|
}));
|
package/dist/tui/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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
|
|
1
|
+
export { ActionState, type ActionStateKey, ActionVariant, BaseHue, BaseThemeDefinition, CategoricalDefinition, FeedbackKind, FormfieldState, type FormfieldStateKey, HueAlias, HueName, HueStep, MarkdownDefinition, MarkdownToken, ModeDefinition, SurfaceName, SyntaxDefinition, SyntaxToken, ThemeDefinition, ThemeDocument, type BackgroundDefinition, type DiffDefinition, type FormfieldColorDefinition, type HueDefinition, type Mode, type StatefulColorDefinition, type TextDefinition, type ThemeTokensDefinition, } from "./schema.js";
|
|
2
2
|
export type { ActionStates, Categorical, FormfieldColor, Hue, HueSource, HueScale, ResolvedActionState, ResolvedFormfieldState, ResolvedTheme, ResolvedThemeTokens, StatefulColor, } from "./types.js";
|
|
3
|
-
export { DEFAULT_CATEGORICAL
|
|
3
|
+
export { DEFAULT_CATEGORICAL } from "./categorical.js";
|
|
4
4
|
export { expandTheme } from "./expand.js";
|
|
5
5
|
export { migrateV1 } from "./v1-migrate.js";
|
|
6
6
|
export { resolveTheme, resolveThemeDocument, themeDecodeError } from "./resolve.js";
|
package/dist/tui/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { ActionState, ActionVariant, BaseHue, CategoricalDefinition, FeedbackKind, FormfieldState, HueAlias, HueName, HueStep, MarkdownDefinition, MarkdownToken, ModeDefinition, SurfaceName, SyntaxDefinition, SyntaxToken, ThemeDefinition, ThemeDocument, } from "./schema.js";
|
|
2
|
-
export { DEFAULT_CATEGORICAL
|
|
1
|
+
export { ActionState, ActionVariant, BaseHue, BaseThemeDefinition, CategoricalDefinition, FeedbackKind, FormfieldState, HueAlias, HueName, HueStep, MarkdownDefinition, MarkdownToken, ModeDefinition, SurfaceName, SyntaxDefinition, SyntaxToken, ThemeDefinition, ThemeDocument, } from "./schema.js";
|
|
2
|
+
export { DEFAULT_CATEGORICAL } from "./categorical.js";
|
|
3
3
|
export { expandTheme } from "./expand.js";
|
|
4
4
|
export { migrateV1 } from "./v1-migrate.js";
|
|
5
5
|
export { resolveTheme, resolveThemeDocument, themeDecodeError } from "./resolve.js";
|
package/dist/tui/resolve.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ import { ThemeDefinition, ThemeDocument } from "./schema.js";
|
|
|
2
2
|
import type { Mode, ResolvedTheme } from "./index.js";
|
|
3
3
|
export declare function themeDecodeError(error: unknown, name: string): Error;
|
|
4
4
|
export declare function resolveThemeDocument(document: ThemeDocument, mode?: Mode): ResolvedTheme;
|
|
5
|
-
export declare function resolveTheme(definition: ThemeDefinition
|
|
5
|
+
export declare function resolveTheme(definition: ThemeDefinition): ResolvedTheme;
|
package/dist/tui/resolve.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { RGBA } from "@opentui/core";
|
|
2
2
|
import { Schema } from "effect";
|
|
3
|
-
import {
|
|
4
|
-
import { expandTheme, expandTokens, mergeTheme } from "./expand.js";
|
|
5
|
-
import { fallback } from "./fallback.js";
|
|
3
|
+
import { expandTheme, mergeTheme } from "./expand.js";
|
|
6
4
|
import { ActionState, ActionVariant, BaseHue, HueAlias, HueStep, SurfaceName, ThemeDefinition, ThemeDocument, } from "./schema.js";
|
|
7
|
-
import {
|
|
5
|
+
import { selectThemeMode } from "./select.js";
|
|
8
6
|
const decodeThemeDefinitionSchema = Schema.decodeUnknownSync(ThemeDefinition, { reportInput: true });
|
|
9
7
|
function decodeThemeDefinition(input) {
|
|
10
8
|
try {
|
|
@@ -21,30 +19,20 @@ export function themeDecodeError(error, name) {
|
|
|
21
19
|
}
|
|
22
20
|
export function resolveThemeDocument(document, mode) {
|
|
23
21
|
const selected = selectThemeMode(document, mode);
|
|
24
|
-
const definition =
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
...merged,
|
|
32
|
-
categorical: merged["categorical"] ?? DEFAULT_CATEGORICAL,
|
|
33
|
-
}, selected.mode);
|
|
34
|
-
}
|
|
35
|
-
export function resolveTheme(definition, mode) {
|
|
36
|
-
return resolveExpandedTheme(expandTheme(decodeThemeDefinition(definition)), mode);
|
|
37
|
-
}
|
|
38
|
-
function resolveExpandedTheme(definition, mode) {
|
|
22
|
+
const definition = expandTheme(selected.theme);
|
|
23
|
+
return resolveExpandedTheme(definition);
|
|
24
|
+
}
|
|
25
|
+
export function resolveTheme(definition) {
|
|
26
|
+
return resolveExpandedTheme(expandTheme(decodeThemeDefinition(definition)));
|
|
27
|
+
}
|
|
28
|
+
function resolveExpandedTheme(definition) {
|
|
39
29
|
const hue = resolveHue(definition.hue);
|
|
40
|
-
const categorical =
|
|
30
|
+
const categorical = definition.categorical.map((name) => hue[name]);
|
|
41
31
|
const hueSteps = compileHueSteps(hue);
|
|
42
|
-
const raise = (color) => (mode === "light" ? hueSteps.increase(color) : hueSteps.decrease(color));
|
|
43
32
|
const base = tokens(definition);
|
|
44
33
|
const views = {};
|
|
45
34
|
const view = (tokens) => ({
|
|
46
35
|
...resolveView(tokens, hue, categorical, hueSteps),
|
|
47
|
-
raise,
|
|
48
36
|
surface: (name) => views[name],
|
|
49
37
|
});
|
|
50
38
|
views.dialog = definition["@dialog"] ? view(contextualize(base, definition["@dialog"])) : view(base);
|
|
@@ -77,14 +65,14 @@ function contextualActions(base, surface) {
|
|
|
77
65
|
const surfaceVariant = surface?.[variant];
|
|
78
66
|
return [
|
|
79
67
|
variant,
|
|
80
|
-
Object.fromEntries(["
|
|
81
|
-
const key = state === "
|
|
68
|
+
Object.fromEntries(["base", ...ActionState.literals].map((state) => {
|
|
69
|
+
const key = state === "base" ? undefined : `$${state}`;
|
|
82
70
|
return [
|
|
83
|
-
key ?? "
|
|
71
|
+
key ?? "base",
|
|
84
72
|
(key ? surfaceVariant?.[key] : undefined) ??
|
|
85
|
-
surfaceVariant?.
|
|
73
|
+
surfaceVariant?.base ??
|
|
86
74
|
(key ? baseVariant?.[key] : undefined) ??
|
|
87
|
-
baseVariant?.
|
|
75
|
+
baseVariant?.base,
|
|
88
76
|
];
|
|
89
77
|
})),
|
|
90
78
|
];
|
|
@@ -116,7 +104,7 @@ function statefulActions(actions) {
|
|
|
116
104
|
function statefulColor(color) {
|
|
117
105
|
return {
|
|
118
106
|
...color,
|
|
119
|
-
state: (states) => color[ActionState.literals.find((state) => states[state]) ?? "
|
|
107
|
+
state: (states) => color[ActionState.literals.find((state) => states[state]) ?? "base"],
|
|
120
108
|
};
|
|
121
109
|
}
|
|
122
110
|
function compileHueSteps(hue) {
|