@opencode/theme 0.0.0-dev-19795 → 0.0.0-dev-19812
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.js +11 -21
- 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.js +17 -17
- package/dist/tui/types.d.ts +9 -15
- package/dist/tui/v1-migrate.js +67 -41
- 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.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,23 +19,15 @@ 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
|
-
const core = expandTokens(fallback(selected.mode));
|
|
27
|
-
const merged = document.standalone ? mergeTheme(core, definition) : mergeTheme(core, defaults, definition);
|
|
28
|
-
if (!merged["hue"])
|
|
29
|
-
throw new Error("Standalone themes must provide hues");
|
|
30
|
-
return resolveExpandedTheme({
|
|
31
|
-
...merged,
|
|
32
|
-
categorical: merged["categorical"] ?? DEFAULT_CATEGORICAL,
|
|
33
|
-
});
|
|
22
|
+
const definition = expandTheme(selected.theme);
|
|
23
|
+
return resolveExpandedTheme(definition);
|
|
34
24
|
}
|
|
35
25
|
export function resolveTheme(definition) {
|
|
36
26
|
return resolveExpandedTheme(expandTheme(decodeThemeDefinition(definition)));
|
|
37
27
|
}
|
|
38
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
32
|
const base = tokens(definition);
|
|
43
33
|
const views = {};
|
|
@@ -75,14 +65,14 @@ function contextualActions(base, surface) {
|
|
|
75
65
|
const surfaceVariant = surface?.[variant];
|
|
76
66
|
return [
|
|
77
67
|
variant,
|
|
78
|
-
Object.fromEntries(["
|
|
79
|
-
const key = state === "
|
|
68
|
+
Object.fromEntries(["base", ...ActionState.literals].map((state) => {
|
|
69
|
+
const key = state === "base" ? undefined : `$${state}`;
|
|
80
70
|
return [
|
|
81
|
-
key ?? "
|
|
71
|
+
key ?? "base",
|
|
82
72
|
(key ? surfaceVariant?.[key] : undefined) ??
|
|
83
|
-
surfaceVariant?.
|
|
73
|
+
surfaceVariant?.base ??
|
|
84
74
|
(key ? baseVariant?.[key] : undefined) ??
|
|
85
|
-
baseVariant?.
|
|
75
|
+
baseVariant?.base,
|
|
86
76
|
];
|
|
87
77
|
})),
|
|
88
78
|
];
|
|
@@ -114,7 +104,7 @@ function statefulActions(actions) {
|
|
|
114
104
|
function statefulColor(color) {
|
|
115
105
|
return {
|
|
116
106
|
...color,
|
|
117
|
-
state: (states) => color[ActionState.literals.find((state) => states[state]) ?? "
|
|
107
|
+
state: (states) => color[ActionState.literals.find((state) => states[state]) ?? "base"],
|
|
118
108
|
};
|
|
119
109
|
}
|
|
120
110
|
function compileHueSteps(hue) {
|