@pioneercompany/app-sdk 0.1.3 → 0.3.0
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/README.md +33 -11
- package/dist/client/index.d.ts +3 -14
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +6 -19
- package/dist/client/index.js.map +1 -1
- package/dist/client/theme.d.ts +59 -0
- package/dist/client/theme.d.ts.map +1 -0
- package/dist/client/theme.js +392 -0
- package/dist/client/theme.js.map +1 -0
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +4 -0
- package/dist/server/index.js.map +1 -1
- package/dist/server/render.d.ts +18 -0
- package/dist/server/render.d.ts.map +1 -0
- package/dist/server/render.js +83 -0
- package/dist/server/render.js.map +1 -0
- package/dist-cjs/client/index.d.ts +3 -14
- package/dist-cjs/client/index.d.ts.map +1 -1
- package/dist-cjs/client/index.js +9 -20
- package/dist-cjs/client/index.js.map +1 -1
- package/dist-cjs/client/theme.d.ts +59 -0
- package/dist-cjs/client/theme.d.ts.map +1 -0
- package/dist-cjs/client/theme.js +396 -0
- package/dist-cjs/client/theme.js.map +1 -0
- package/dist-cjs/server/index.d.ts +3 -0
- package/dist-cjs/server/index.d.ts.map +1 -1
- package/dist-cjs/server/index.js +4 -0
- package/dist-cjs/server/index.js.map +1 -1
- package/dist-cjs/server/render.d.ts +18 -0
- package/dist-cjs/server/render.d.ts.map +1 -0
- package/dist-cjs/server/render.js +86 -0
- package/dist-cjs/server/render.js.map +1 -0
- package/docs/contract.md +27 -19
- package/docs/theme.md +56 -0
- package/fixtures/protocol.json +603 -18
- package/package.json +1 -1
- package/src/client/index.ts +11 -31
- package/src/client/theme.ts +418 -0
- package/src/server/index.ts +6 -0
- package/src/server/render.ts +87 -0
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ const app = await connectApp({ baseUrl: './' }); // Only for a root document!
|
|
|
27
27
|
// For nested documents render an authenticated <base href="../.../"> or pass
|
|
28
28
|
// the exact view root. Do not infer a grant token from pathname segments.
|
|
29
29
|
const unsubscribe = app.theme.subscribe(theme => {
|
|
30
|
-
document.body.style.background = theme.background;
|
|
30
|
+
document.body.style.background = theme.colors.background;
|
|
31
31
|
});
|
|
32
32
|
const stateUrl = app.url('/state');
|
|
33
33
|
const terminalUrl = app.webSocketUrl('/terminal');
|
|
@@ -70,16 +70,19 @@ not close the view.
|
|
|
70
70
|
`connectApp` installs its listener synchronously before its promise is awaited.
|
|
71
71
|
Call it during browser module initialization, before iframe load or the dev
|
|
72
72
|
page's DOMContentLoaded. SSR imports are safe; connecting requires a browser.
|
|
73
|
-
Theme starts null.
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
73
|
+
Theme starts null. SDK 0.2 exposes the complete native theme through
|
|
74
|
+
`app.theme.current` and `app.theme.subscribe`: `mode`, all resolved `colors`,
|
|
75
|
+
`light_theme`, `dark_theme`, fonts, radii, tokens, highlighting and other settings.
|
|
76
|
+
For example, use `theme.colors.success`, `theme.colors.tab_bar`, or
|
|
77
|
+
`theme.dark_theme.colors["base.blue.light"]`. The whole nested snapshot is cloned
|
|
78
|
+
and deep-frozen, including unknown future fields; it is never reduced to a list
|
|
79
|
+
of selected keys. See [all fields and the 0.1 migration](docs/theme.md).
|
|
80
|
+
|
|
81
|
+
Iframes accept their parent, including opaque origins; direct pages require self
|
|
82
|
+
and exact origin. Late subscribers receive the current snapshot immediately.
|
|
83
|
+
Connections are independent and disposable. No theme handshake/resend request or
|
|
84
|
+
DOM/style mutation is performed. Theme grants no backend authority. SDK 0.2
|
|
85
|
+
requires the updated Desktop theme bridge; old flat `palette` messages are ignored.
|
|
83
86
|
URL methods return strings, reject external/protocol-relative/traversal paths,
|
|
84
87
|
and interpret a leading slash relative to the configured view root. A base URL
|
|
85
88
|
is required (explicit option or HTML base element), including outside Pioneer.
|
|
@@ -171,3 +174,22 @@ package tracing and runtime acceptance require external verification.
|
|
|
171
174
|
Streaming has no capability subversion on Gateway;
|
|
172
175
|
older `host.pty` implementations may reject subscribe. New dev registration,
|
|
173
176
|
Terminal integration and future Python/Rust implementations are out of scope.
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
### Server-side rendering
|
|
180
|
+
|
|
181
|
+
Gateway installations that advertise `host.render` let the app's backend render
|
|
182
|
+
PNG and PDF without bundling a browser.
|
|
183
|
+
|
|
184
|
+
```ts
|
|
185
|
+
const { data: png, metadata } = await app.host.render.screenshot({
|
|
186
|
+
path: "/agent-render",
|
|
187
|
+
input: { snapshot, range: "A1:H20" },
|
|
188
|
+
});
|
|
189
|
+
const pdf = await app.host.render.pdf({ html });
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
The screenshot page implements `window.__pioneerRender.prepare(input)` to return
|
|
193
|
+
the viewport dimensions and `window.__pioneerRender.capture()` to return
|
|
194
|
+
`{ clip: { x, y, width, height }, metadata }`. Gateway resolves the path in the
|
|
195
|
+
current app execution. Both operations accept an optional `AbortSignal`.
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
export { PioneerError } from "../error.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
readonly foreground: string;
|
|
6
|
-
readonly muted: string;
|
|
7
|
-
readonly border: string;
|
|
8
|
-
readonly accent: string;
|
|
9
|
-
readonly "accent-foreground": string;
|
|
10
|
-
/** Semantic status colors; absent on older Pioneer hosts. */
|
|
11
|
-
readonly success?: string;
|
|
12
|
-
readonly warning?: string;
|
|
13
|
-
readonly danger?: string;
|
|
14
|
-
readonly info?: string;
|
|
15
|
-
}
|
|
2
|
+
import { type Theme } from "./theme.js";
|
|
3
|
+
export { THEME_COLOR_KEYS, THEME_CONFIG_COLOR_KEYS } from "./theme.js";
|
|
4
|
+
export type { Theme, ThemeMode, ThemeValue, ThemeObject, ThemeColorName, ThemeColors, ThemeConfig, ThemeConfigColors, ThemeConfigColorName, ThemeToken, } from "./theme.js";
|
|
16
5
|
export interface ConnectAppOptions {
|
|
17
6
|
/** Exact grant root, absolute or relative to document URL; must end in /. */
|
|
18
7
|
baseUrl?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAe,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACvE,YAAY,EACV,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EACtE,WAAW,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,UAAU,GACjE,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,iBAAiB;IAChC,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AACD,oFAAoF;AACpF,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG,QAAQ,GAAG,OAAO,CAAC;AAC7D,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE;QACb,6EAA6E;QAC7E,YAAY,CAAC,SAAS,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QACrD,kEAAkE;QAClE,KAAK,IAAI,IAAI,CAAC;KACf,CAAC;IACF,QAAQ,CAAC,KAAK,EAAE;QACd,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;QACzC,oEAAoE;QACpE,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;KACnE,CAAC;IACF,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACnC,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,+EAA+E;AAC/E,wBAAsB,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,SAAS,CAAC,CA2HpF"}
|
package/dist/client/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { failure } from "../error.js";
|
|
2
2
|
export { PioneerError } from "../error.js";
|
|
3
|
+
import { decodeTheme } from "./theme.js";
|
|
4
|
+
export { THEME_COLOR_KEYS, THEME_CONFIG_COLOR_KEYS } from "./theme.js";
|
|
3
5
|
/** Resolves immediately: Pioneer has no theme handshake or readiness event. */
|
|
4
6
|
export async function connectApp(options = {}) {
|
|
5
7
|
if (typeof window === "undefined")
|
|
@@ -51,27 +53,12 @@ export async function connectApp(options = {}) {
|
|
|
51
53
|
}
|
|
52
54
|
return;
|
|
53
55
|
}
|
|
54
|
-
if (!data || data.type !== "pioneer.theme"
|
|
56
|
+
if (!data || data.type !== "pioneer.theme")
|
|
55
57
|
return;
|
|
56
|
-
const
|
|
57
|
-
if (
|
|
58
|
+
const theme = decodeTheme(data.theme);
|
|
59
|
+
if (!theme)
|
|
58
60
|
return;
|
|
59
|
-
|
|
60
|
-
for (const key of colors) {
|
|
61
|
-
if (typeof value[key] !== "string" || value[key].length > 128 || !CSS.supports("color", value[key]))
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
const statusColors = ["success", "warning", "danger", "info"];
|
|
65
|
-
for (const key of statusColors) {
|
|
66
|
-
if (value[key] !== undefined &&
|
|
67
|
-
(typeof value[key] !== "string" || value[key].length > 128 || !CSS.supports("color", value[key])))
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
current = Object.freeze({
|
|
71
|
-
appearance: value.appearance,
|
|
72
|
-
...Object.fromEntries(colors.map(key => [key, value[key]])),
|
|
73
|
-
...Object.fromEntries(statusColors.filter(key => value[key] !== undefined).map(key => [key, value[key]])),
|
|
74
|
-
});
|
|
61
|
+
current = theme;
|
|
75
62
|
for (const listener of [...listeners]) {
|
|
76
63
|
if (disposed)
|
|
77
64
|
break;
|
package/dist/client/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAc,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AA6BvE,+EAA+E;AAC/E,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,UAA6B,EAAE;IAC9D,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,MAAM,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACzE,4EAA4E;IAC5E,+EAA+E;IAC/E,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,IAAI,QAAQ,CAAC,aAAa,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;IACjG,IAAI,CAAC,UAAU;QAAE,MAAM,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACxD,IAAI,IAAS,CAAC;IACd,IAAI,CAAC;QAAC,IAAI,GAAG,IAAI,GAAG,CAAC,UAAU,EAAE,MAAM,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AC,mBAAmB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YAC/C,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;gBACpC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACzB,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC;YACrC,CAAC;YACD,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/** JSON theme snapshot: native field names are retained without aliases. */
|
|
2
|
+
export type ThemeMode = "light" | "dark";
|
|
3
|
+
export type ThemeValue = null | boolean | number | string | readonly ThemeValue[] | ThemeObject;
|
|
4
|
+
export interface ThemeObject {
|
|
5
|
+
readonly [key: string]: ThemeValue | undefined;
|
|
6
|
+
}
|
|
7
|
+
/** Resolved native colors, including roles absent from a user's theme file. */
|
|
8
|
+
export declare const THEME_COLOR_KEYS: readonly ["accent", "accent_foreground", "accordion", "background", "border", "button", "button_active", "button_foreground", "button_hover", "button_danger", "button_danger_active", "button_danger_foreground", "button_danger_hover", "button_info", "button_info_active", "button_info_foreground", "button_info_hover", "button_primary", "button_primary_active", "button_primary_foreground", "button_primary_hover", "button_secondary", "button_secondary_active", "button_secondary_foreground", "button_secondary_hover", "button_success", "button_success_active", "button_success_foreground", "button_success_hover", "button_warning", "button_warning_active", "button_warning_foreground", "button_warning_hover", "group_box", "group_box_foreground", "caret", "chart_1", "chart_2", "chart_3", "chart_4", "chart_5", "chart_bullish", "chart_bearish", "chart_grid", "danger", "danger_active", "danger_foreground", "danger_hover", "description_list_label", "description_list_label_foreground", "drag_border", "drop_target", "foreground", "info", "info_active", "info_foreground", "info_hover", "input", "link", "link_active", "link_hover", "list", "list_active", "list_active_border", "list_even", "list_head", "list_hover", "muted", "muted_foreground", "popover", "popover_foreground", "primary", "primary_active", "primary_foreground", "primary_hover", "progress_bar", "ring", "scrollbar", "scrollbar_thumb", "scrollbar_thumb_hover", "secondary", "secondary_active", "secondary_foreground", "secondary_hover", "selection", "sidebar", "sidebar_accent", "sidebar_accent_foreground", "sidebar_border", "sidebar_foreground", "sidebar_primary", "sidebar_primary_foreground", "skeleton", "slider_bar", "slider_thumb", "success", "success_foreground", "success_hover", "success_active", "switch", "switch_thumb", "tab", "tab_active", "tab_active_foreground", "tab_bar", "tab_bar_segmented", "tab_foreground", "table", "table_active", "table_active_border", "table_even", "table_head", "table_head_foreground", "table_foot", "table_foot_foreground", "table_hover", "table_row_border", "title_bar", "title_bar_border", "status_bar", "status_bar_border", "warning", "warning_active", "warning_hover", "warning_foreground", "overlay", "window_border", "red", "red_light", "green", "green_light", "blue", "blue_light", "yellow", "yellow_light", "magenta", "magenta_light", "cyan", "cyan_light"];
|
|
9
|
+
export type ThemeColorName = typeof THEME_COLOR_KEYS[number];
|
|
10
|
+
export type ThemeColors = Readonly<Record<ThemeColorName, string> & Record<string, string>>;
|
|
11
|
+
/** Theme-file keys from the complete GPUI ThemeConfigColors schema. */
|
|
12
|
+
export declare const THEME_CONFIG_COLOR_KEYS: readonly ["accent.background", "accent.foreground", "accordion.background", "background", "border", "button.background", "button.active.background", "button.foreground", "button.hover.background", "button.danger.background", "button.danger.active.background", "button.danger.foreground", "button.danger.hover.background", "button.info.background", "button.info.active.background", "button.info.foreground", "button.info.hover.background", "button.primary.background", "button.primary.active.background", "button.primary.foreground", "button.primary.hover.background", "button.secondary.background", "button.secondary.active.background", "button.secondary.foreground", "button.secondary.hover.background", "button.success.background", "button.success.active.background", "button.success.foreground", "button.success.hover.background", "button.warning.background", "button.warning.active.background", "button.warning.foreground", "button.warning.hover.background", "group_box.background", "group_box.foreground", "group_box.title.foreground", "caret", "chart.1", "chart.2", "chart.3", "chart.4", "chart.5", "chart.bullish", "chart.bearish", "chart.grid", "danger.background", "danger.active.background", "danger.foreground", "danger.hover.background", "description_list.label.background", "description_list.label.foreground", "drag.border", "drop_target.background", "foreground", "info.background", "info.active.background", "info.foreground", "info.hover.background", "input.border", "link", "link.active", "link.hover", "list.background", "list.active.background", "list.active.border", "list.even.background", "list.head.background", "list.hover.background", "muted.background", "muted.foreground", "popover.background", "popover.foreground", "primary.background", "primary.active.background", "primary.foreground", "primary.hover.background", "progress.bar.background", "ring", "scrollbar.background", "scrollbar.thumb.background", "scrollbar.thumb.hover.background", "secondary.background", "secondary.active.background", "secondary.foreground", "secondary.hover.background", "selection.background", "sidebar.background", "sidebar.accent.background", "sidebar.accent.foreground", "sidebar.border", "sidebar.foreground", "sidebar.primary.background", "sidebar.primary.foreground", "skeleton.background", "slider.background", "slider.thumb.background", "success.background", "success.foreground", "success.hover.background", "success.active.background", "switch.background", "switch.thumb.background", "tab.background", "tab.active.background", "tab.active.foreground", "tab_bar.background", "tab_bar.segmented.background", "tab.foreground", "table.background", "table.active.background", "table.active.border", "table.even.background", "table.head.background", "table.head.foreground", "table.foot.background", "table.foot.foreground", "table.hover.background", "table.row.border", "title_bar.background", "title_bar.border", "status_bar.background", "status_bar.border", "warning.background", "warning.active.background", "warning.hover.background", "warning.foreground", "overlay", "window.border", "base.blue", "base.blue.light", "base.cyan", "base.cyan.light", "base.green", "base.green.light", "base.magenta", "base.magenta.light", "base.red", "base.red.light", "base.yellow", "base.yellow.light"];
|
|
13
|
+
export type ThemeConfigColorName = typeof THEME_CONFIG_COLOR_KEYS[number];
|
|
14
|
+
export type ThemeConfigColors = Readonly<Partial<Record<ThemeConfigColorName, string | null>> & ThemeObject>;
|
|
15
|
+
export interface ThemeConfig extends ThemeObject {
|
|
16
|
+
readonly name: string;
|
|
17
|
+
readonly mode: ThemeMode;
|
|
18
|
+
readonly is_default?: boolean;
|
|
19
|
+
readonly "font.size"?: number | null;
|
|
20
|
+
readonly "font.family"?: string | null;
|
|
21
|
+
readonly "mono_font.size"?: number | null;
|
|
22
|
+
readonly "mono_font.family"?: string | null;
|
|
23
|
+
readonly radius?: number | null;
|
|
24
|
+
readonly "radius.lg"?: number | null;
|
|
25
|
+
readonly "window.radius"?: number | null;
|
|
26
|
+
readonly shadow?: boolean | null;
|
|
27
|
+
readonly colors: ThemeConfigColors;
|
|
28
|
+
readonly highlight?: ThemeObject | null;
|
|
29
|
+
}
|
|
30
|
+
export interface ThemeToken extends ThemeObject {
|
|
31
|
+
readonly color: string;
|
|
32
|
+
readonly background: ThemeValue;
|
|
33
|
+
}
|
|
34
|
+
/** All serializable native Theme fields, plus its full semantic projection. */
|
|
35
|
+
export interface Theme extends ThemeObject {
|
|
36
|
+
readonly mode: ThemeMode;
|
|
37
|
+
readonly colors: ThemeColors;
|
|
38
|
+
readonly light_theme: ThemeConfig;
|
|
39
|
+
readonly dark_theme: ThemeConfig;
|
|
40
|
+
readonly tokens: Readonly<Record<string, ThemeToken>>;
|
|
41
|
+
readonly semantic_tokens: ThemeObject;
|
|
42
|
+
readonly highlight_theme: ThemeObject;
|
|
43
|
+
readonly font_family: string;
|
|
44
|
+
readonly font_size: number;
|
|
45
|
+
readonly mono_font_family: string;
|
|
46
|
+
readonly mono_font_size: number;
|
|
47
|
+
readonly radius: number;
|
|
48
|
+
readonly radius_lg: number;
|
|
49
|
+
readonly window_radius: number;
|
|
50
|
+
readonly shadow: boolean;
|
|
51
|
+
readonly focus_ring: boolean;
|
|
52
|
+
readonly transparent: string;
|
|
53
|
+
readonly scrollbar_mode: string;
|
|
54
|
+
readonly list: ThemeObject;
|
|
55
|
+
readonly sheet: ThemeObject;
|
|
56
|
+
}
|
|
57
|
+
/** Clone/freeze the complete JSON tree; never project it onto a field whitelist. */
|
|
58
|
+
export declare function decodeTheme(value: unknown): Readonly<Theme> | null;
|
|
59
|
+
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/client/theme.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,MAAM,CA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IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;CAC7B;AASD,oFAAoF;AACpF,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,IAAI,CAsElE"}
|
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
/** Resolved native colors, including roles absent from a user's theme file. */
|
|
2
|
+
export const THEME_COLOR_KEYS = [
|
|
3
|
+
"accent",
|
|
4
|
+
"accent_foreground",
|
|
5
|
+
"accordion",
|
|
6
|
+
"background",
|
|
7
|
+
"border",
|
|
8
|
+
"button",
|
|
9
|
+
"button_active",
|
|
10
|
+
"button_foreground",
|
|
11
|
+
"button_hover",
|
|
12
|
+
"button_danger",
|
|
13
|
+
"button_danger_active",
|
|
14
|
+
"button_danger_foreground",
|
|
15
|
+
"button_danger_hover",
|
|
16
|
+
"button_info",
|
|
17
|
+
"button_info_active",
|
|
18
|
+
"button_info_foreground",
|
|
19
|
+
"button_info_hover",
|
|
20
|
+
"button_primary",
|
|
21
|
+
"button_primary_active",
|
|
22
|
+
"button_primary_foreground",
|
|
23
|
+
"button_primary_hover",
|
|
24
|
+
"button_secondary",
|
|
25
|
+
"button_secondary_active",
|
|
26
|
+
"button_secondary_foreground",
|
|
27
|
+
"button_secondary_hover",
|
|
28
|
+
"button_success",
|
|
29
|
+
"button_success_active",
|
|
30
|
+
"button_success_foreground",
|
|
31
|
+
"button_success_hover",
|
|
32
|
+
"button_warning",
|
|
33
|
+
"button_warning_active",
|
|
34
|
+
"button_warning_foreground",
|
|
35
|
+
"button_warning_hover",
|
|
36
|
+
"group_box",
|
|
37
|
+
"group_box_foreground",
|
|
38
|
+
"caret",
|
|
39
|
+
"chart_1",
|
|
40
|
+
"chart_2",
|
|
41
|
+
"chart_3",
|
|
42
|
+
"chart_4",
|
|
43
|
+
"chart_5",
|
|
44
|
+
"chart_bullish",
|
|
45
|
+
"chart_bearish",
|
|
46
|
+
"chart_grid",
|
|
47
|
+
"danger",
|
|
48
|
+
"danger_active",
|
|
49
|
+
"danger_foreground",
|
|
50
|
+
"danger_hover",
|
|
51
|
+
"description_list_label",
|
|
52
|
+
"description_list_label_foreground",
|
|
53
|
+
"drag_border",
|
|
54
|
+
"drop_target",
|
|
55
|
+
"foreground",
|
|
56
|
+
"info",
|
|
57
|
+
"info_active",
|
|
58
|
+
"info_foreground",
|
|
59
|
+
"info_hover",
|
|
60
|
+
"input",
|
|
61
|
+
"link",
|
|
62
|
+
"link_active",
|
|
63
|
+
"link_hover",
|
|
64
|
+
"list",
|
|
65
|
+
"list_active",
|
|
66
|
+
"list_active_border",
|
|
67
|
+
"list_even",
|
|
68
|
+
"list_head",
|
|
69
|
+
"list_hover",
|
|
70
|
+
"muted",
|
|
71
|
+
"muted_foreground",
|
|
72
|
+
"popover",
|
|
73
|
+
"popover_foreground",
|
|
74
|
+
"primary",
|
|
75
|
+
"primary_active",
|
|
76
|
+
"primary_foreground",
|
|
77
|
+
"primary_hover",
|
|
78
|
+
"progress_bar",
|
|
79
|
+
"ring",
|
|
80
|
+
"scrollbar",
|
|
81
|
+
"scrollbar_thumb",
|
|
82
|
+
"scrollbar_thumb_hover",
|
|
83
|
+
"secondary",
|
|
84
|
+
"secondary_active",
|
|
85
|
+
"secondary_foreground",
|
|
86
|
+
"secondary_hover",
|
|
87
|
+
"selection",
|
|
88
|
+
"sidebar",
|
|
89
|
+
"sidebar_accent",
|
|
90
|
+
"sidebar_accent_foreground",
|
|
91
|
+
"sidebar_border",
|
|
92
|
+
"sidebar_foreground",
|
|
93
|
+
"sidebar_primary",
|
|
94
|
+
"sidebar_primary_foreground",
|
|
95
|
+
"skeleton",
|
|
96
|
+
"slider_bar",
|
|
97
|
+
"slider_thumb",
|
|
98
|
+
"success",
|
|
99
|
+
"success_foreground",
|
|
100
|
+
"success_hover",
|
|
101
|
+
"success_active",
|
|
102
|
+
"switch",
|
|
103
|
+
"switch_thumb",
|
|
104
|
+
"tab",
|
|
105
|
+
"tab_active",
|
|
106
|
+
"tab_active_foreground",
|
|
107
|
+
"tab_bar",
|
|
108
|
+
"tab_bar_segmented",
|
|
109
|
+
"tab_foreground",
|
|
110
|
+
"table",
|
|
111
|
+
"table_active",
|
|
112
|
+
"table_active_border",
|
|
113
|
+
"table_even",
|
|
114
|
+
"table_head",
|
|
115
|
+
"table_head_foreground",
|
|
116
|
+
"table_foot",
|
|
117
|
+
"table_foot_foreground",
|
|
118
|
+
"table_hover",
|
|
119
|
+
"table_row_border",
|
|
120
|
+
"title_bar",
|
|
121
|
+
"title_bar_border",
|
|
122
|
+
"status_bar",
|
|
123
|
+
"status_bar_border",
|
|
124
|
+
"warning",
|
|
125
|
+
"warning_active",
|
|
126
|
+
"warning_hover",
|
|
127
|
+
"warning_foreground",
|
|
128
|
+
"overlay",
|
|
129
|
+
"window_border",
|
|
130
|
+
"red",
|
|
131
|
+
"red_light",
|
|
132
|
+
"green",
|
|
133
|
+
"green_light",
|
|
134
|
+
"blue",
|
|
135
|
+
"blue_light",
|
|
136
|
+
"yellow",
|
|
137
|
+
"yellow_light",
|
|
138
|
+
"magenta",
|
|
139
|
+
"magenta_light",
|
|
140
|
+
"cyan",
|
|
141
|
+
"cyan_light",
|
|
142
|
+
];
|
|
143
|
+
/** Theme-file keys from the complete GPUI ThemeConfigColors schema. */
|
|
144
|
+
export const THEME_CONFIG_COLOR_KEYS = [
|
|
145
|
+
"accent.background",
|
|
146
|
+
"accent.foreground",
|
|
147
|
+
"accordion.background",
|
|
148
|
+
"background",
|
|
149
|
+
"border",
|
|
150
|
+
"button.background",
|
|
151
|
+
"button.active.background",
|
|
152
|
+
"button.foreground",
|
|
153
|
+
"button.hover.background",
|
|
154
|
+
"button.danger.background",
|
|
155
|
+
"button.danger.active.background",
|
|
156
|
+
"button.danger.foreground",
|
|
157
|
+
"button.danger.hover.background",
|
|
158
|
+
"button.info.background",
|
|
159
|
+
"button.info.active.background",
|
|
160
|
+
"button.info.foreground",
|
|
161
|
+
"button.info.hover.background",
|
|
162
|
+
"button.primary.background",
|
|
163
|
+
"button.primary.active.background",
|
|
164
|
+
"button.primary.foreground",
|
|
165
|
+
"button.primary.hover.background",
|
|
166
|
+
"button.secondary.background",
|
|
167
|
+
"button.secondary.active.background",
|
|
168
|
+
"button.secondary.foreground",
|
|
169
|
+
"button.secondary.hover.background",
|
|
170
|
+
"button.success.background",
|
|
171
|
+
"button.success.active.background",
|
|
172
|
+
"button.success.foreground",
|
|
173
|
+
"button.success.hover.background",
|
|
174
|
+
"button.warning.background",
|
|
175
|
+
"button.warning.active.background",
|
|
176
|
+
"button.warning.foreground",
|
|
177
|
+
"button.warning.hover.background",
|
|
178
|
+
"group_box.background",
|
|
179
|
+
"group_box.foreground",
|
|
180
|
+
"group_box.title.foreground",
|
|
181
|
+
"caret",
|
|
182
|
+
"chart.1",
|
|
183
|
+
"chart.2",
|
|
184
|
+
"chart.3",
|
|
185
|
+
"chart.4",
|
|
186
|
+
"chart.5",
|
|
187
|
+
"chart.bullish",
|
|
188
|
+
"chart.bearish",
|
|
189
|
+
"chart.grid",
|
|
190
|
+
"danger.background",
|
|
191
|
+
"danger.active.background",
|
|
192
|
+
"danger.foreground",
|
|
193
|
+
"danger.hover.background",
|
|
194
|
+
"description_list.label.background",
|
|
195
|
+
"description_list.label.foreground",
|
|
196
|
+
"drag.border",
|
|
197
|
+
"drop_target.background",
|
|
198
|
+
"foreground",
|
|
199
|
+
"info.background",
|
|
200
|
+
"info.active.background",
|
|
201
|
+
"info.foreground",
|
|
202
|
+
"info.hover.background",
|
|
203
|
+
"input.border",
|
|
204
|
+
"link",
|
|
205
|
+
"link.active",
|
|
206
|
+
"link.hover",
|
|
207
|
+
"list.background",
|
|
208
|
+
"list.active.background",
|
|
209
|
+
"list.active.border",
|
|
210
|
+
"list.even.background",
|
|
211
|
+
"list.head.background",
|
|
212
|
+
"list.hover.background",
|
|
213
|
+
"muted.background",
|
|
214
|
+
"muted.foreground",
|
|
215
|
+
"popover.background",
|
|
216
|
+
"popover.foreground",
|
|
217
|
+
"primary.background",
|
|
218
|
+
"primary.active.background",
|
|
219
|
+
"primary.foreground",
|
|
220
|
+
"primary.hover.background",
|
|
221
|
+
"progress.bar.background",
|
|
222
|
+
"ring",
|
|
223
|
+
"scrollbar.background",
|
|
224
|
+
"scrollbar.thumb.background",
|
|
225
|
+
"scrollbar.thumb.hover.background",
|
|
226
|
+
"secondary.background",
|
|
227
|
+
"secondary.active.background",
|
|
228
|
+
"secondary.foreground",
|
|
229
|
+
"secondary.hover.background",
|
|
230
|
+
"selection.background",
|
|
231
|
+
"sidebar.background",
|
|
232
|
+
"sidebar.accent.background",
|
|
233
|
+
"sidebar.accent.foreground",
|
|
234
|
+
"sidebar.border",
|
|
235
|
+
"sidebar.foreground",
|
|
236
|
+
"sidebar.primary.background",
|
|
237
|
+
"sidebar.primary.foreground",
|
|
238
|
+
"skeleton.background",
|
|
239
|
+
"slider.background",
|
|
240
|
+
"slider.thumb.background",
|
|
241
|
+
"success.background",
|
|
242
|
+
"success.foreground",
|
|
243
|
+
"success.hover.background",
|
|
244
|
+
"success.active.background",
|
|
245
|
+
"switch.background",
|
|
246
|
+
"switch.thumb.background",
|
|
247
|
+
"tab.background",
|
|
248
|
+
"tab.active.background",
|
|
249
|
+
"tab.active.foreground",
|
|
250
|
+
"tab_bar.background",
|
|
251
|
+
"tab_bar.segmented.background",
|
|
252
|
+
"tab.foreground",
|
|
253
|
+
"table.background",
|
|
254
|
+
"table.active.background",
|
|
255
|
+
"table.active.border",
|
|
256
|
+
"table.even.background",
|
|
257
|
+
"table.head.background",
|
|
258
|
+
"table.head.foreground",
|
|
259
|
+
"table.foot.background",
|
|
260
|
+
"table.foot.foreground",
|
|
261
|
+
"table.hover.background",
|
|
262
|
+
"table.row.border",
|
|
263
|
+
"title_bar.background",
|
|
264
|
+
"title_bar.border",
|
|
265
|
+
"status_bar.background",
|
|
266
|
+
"status_bar.border",
|
|
267
|
+
"warning.background",
|
|
268
|
+
"warning.active.background",
|
|
269
|
+
"warning.hover.background",
|
|
270
|
+
"warning.foreground",
|
|
271
|
+
"overlay",
|
|
272
|
+
"window.border",
|
|
273
|
+
"base.blue",
|
|
274
|
+
"base.blue.light",
|
|
275
|
+
"base.cyan",
|
|
276
|
+
"base.cyan.light",
|
|
277
|
+
"base.green",
|
|
278
|
+
"base.green.light",
|
|
279
|
+
"base.magenta",
|
|
280
|
+
"base.magenta.light",
|
|
281
|
+
"base.red",
|
|
282
|
+
"base.red.light",
|
|
283
|
+
"base.yellow",
|
|
284
|
+
"base.yellow.light",
|
|
285
|
+
];
|
|
286
|
+
function object(value) {
|
|
287
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
288
|
+
}
|
|
289
|
+
const mode = (value) => value === "light" || value === "dark";
|
|
290
|
+
const color = (value) => typeof value === "string" && value.length <= 128 && CSS.supports("color", value);
|
|
291
|
+
/** Clone/freeze the complete JSON tree; never project it onto a field whitelist. */
|
|
292
|
+
export function decodeTheme(value) {
|
|
293
|
+
let nodes = 0;
|
|
294
|
+
let characters = 0;
|
|
295
|
+
const ancestors = new Set();
|
|
296
|
+
const clone = (value, depth) => {
|
|
297
|
+
if (++nodes > 50000 || depth > 32)
|
|
298
|
+
throw new Error("Theme exceeds limits");
|
|
299
|
+
if (value === null || typeof value === "boolean")
|
|
300
|
+
return value;
|
|
301
|
+
if (typeof value === "number" && Number.isFinite(value))
|
|
302
|
+
return value;
|
|
303
|
+
if (typeof value === "string") {
|
|
304
|
+
characters += value.length;
|
|
305
|
+
if (value.length > 65536 || characters > 1024 * 1024)
|
|
306
|
+
throw new Error("Theme exceeds limits");
|
|
307
|
+
return value;
|
|
308
|
+
}
|
|
309
|
+
if (typeof value !== "object" || ancestors.has(value))
|
|
310
|
+
throw new Error("Invalid theme JSON");
|
|
311
|
+
const prototype = Object.getPrototypeOf(value);
|
|
312
|
+
if (!Array.isArray(value) && prototype !== Object.prototype && prototype !== null)
|
|
313
|
+
throw new Error("Invalid theme object");
|
|
314
|
+
ancestors.add(value);
|
|
315
|
+
try {
|
|
316
|
+
if (Array.isArray(value)) {
|
|
317
|
+
if (value.length > 50000 - nodes)
|
|
318
|
+
throw new Error("Theme exceeds limits");
|
|
319
|
+
return Object.freeze(Array.from(value, item => clone(item, depth + 1)));
|
|
320
|
+
}
|
|
321
|
+
const source = Object.entries(value);
|
|
322
|
+
if (source.length > 50000 - nodes)
|
|
323
|
+
throw new Error("Theme exceeds limits");
|
|
324
|
+
const entries = source.map(([key, item]) => {
|
|
325
|
+
characters += key.length;
|
|
326
|
+
if (key.length > 256 || characters > 1024 * 1024)
|
|
327
|
+
throw new Error("Theme exceeds limits");
|
|
328
|
+
return [key, clone(item, depth + 1)];
|
|
329
|
+
});
|
|
330
|
+
return Object.freeze(Object.fromEntries(entries));
|
|
331
|
+
}
|
|
332
|
+
finally {
|
|
333
|
+
ancestors.delete(value);
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
try {
|
|
337
|
+
const theme = clone(value, 0);
|
|
338
|
+
if (!object(theme) || !mode(theme.mode))
|
|
339
|
+
return null;
|
|
340
|
+
const colors = theme.colors;
|
|
341
|
+
if (!object(colors) || !THEME_COLOR_KEYS.every(key => color(colors[key])))
|
|
342
|
+
return null;
|
|
343
|
+
if (!Object.values(colors).every(color))
|
|
344
|
+
return null;
|
|
345
|
+
for (const [key, expected] of [["light_theme", "light"], ["dark_theme", "dark"]]) {
|
|
346
|
+
const config = theme[key];
|
|
347
|
+
if (!object(config) || config.mode !== expected || typeof config.name !== "string" || !object(config.colors))
|
|
348
|
+
return null;
|
|
349
|
+
if (!Object.values(config.colors).every(value => value === null || typeof value === "string"))
|
|
350
|
+
return null;
|
|
351
|
+
for (const key of ["font.size", "mono_font.size", "radius", "radius.lg", "window.radius"]) {
|
|
352
|
+
const value = config[key];
|
|
353
|
+
if (value !== undefined && value !== null && (typeof value !== "number" || value < 0))
|
|
354
|
+
return null;
|
|
355
|
+
}
|
|
356
|
+
for (const key of ["font.family", "mono_font.family"]) {
|
|
357
|
+
if (config[key] !== undefined && config[key] !== null && typeof config[key] !== "string")
|
|
358
|
+
return null;
|
|
359
|
+
}
|
|
360
|
+
if (config.is_default !== undefined && typeof config.is_default !== "boolean")
|
|
361
|
+
return null;
|
|
362
|
+
if (config.shadow !== undefined && config.shadow !== null && typeof config.shadow !== "boolean")
|
|
363
|
+
return null;
|
|
364
|
+
if (config.highlight !== undefined && config.highlight !== null && !object(config.highlight))
|
|
365
|
+
return null;
|
|
366
|
+
}
|
|
367
|
+
for (const key of ["font_family", "mono_font_family", "scrollbar_mode"]) {
|
|
368
|
+
if (typeof theme[key] !== "string")
|
|
369
|
+
return null;
|
|
370
|
+
}
|
|
371
|
+
for (const key of ["font_size", "mono_font_size", "radius", "radius_lg", "window_radius"]) {
|
|
372
|
+
const value = theme[key];
|
|
373
|
+
if (typeof value !== "number" || value < 0)
|
|
374
|
+
return null;
|
|
375
|
+
}
|
|
376
|
+
if (typeof theme.shadow !== "boolean" || typeof theme.focus_ring !== "boolean" || !color(theme.transparent))
|
|
377
|
+
return null;
|
|
378
|
+
for (const key of ["tokens", "semantic_tokens", "highlight_theme", "list", "sheet"]) {
|
|
379
|
+
if (!object(theme[key]))
|
|
380
|
+
return null;
|
|
381
|
+
}
|
|
382
|
+
for (const token of Object.values(theme.tokens)) {
|
|
383
|
+
if (!object(token) || !color(token.color) || !("background" in token))
|
|
384
|
+
return null;
|
|
385
|
+
}
|
|
386
|
+
return theme;
|
|
387
|
+
}
|
|
388
|
+
catch {
|
|
389
|
+
return null;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
//# sourceMappingURL=theme.js.map
|