@pioneercompany/app-sdk 0.1.3 → 0.2.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 +14 -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-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/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/docs/contract.md
CHANGED
|
@@ -36,25 +36,33 @@ view URL, never execution credentials.
|
|
|
36
36
|
## Theme
|
|
37
37
|
|
|
38
38
|
The iframe parent, or the direct dev page's own window, posts
|
|
39
|
-
{type:'pioneer.theme',
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
39
|
+
`{type:'pioneer.theme', theme: snapshot}`. SDK 0.2 uses the complete serialized native
|
|
40
|
+
Theme, rather than 0.1's selected flat `palette`. Native names and nesting remain
|
|
41
|
+
intact: `mode`, resolved `colors`, `light_theme`, `dark_theme`, `tokens`, fonts,
|
|
42
|
+
radii, shadow/focus/scrollbar settings, list/sheet settings and syntax highlighting.
|
|
43
|
+
`semantic_tokens` also carries the full native semantic projection. Both theme
|
|
44
|
+
configs retain all theme-file keys, including nullable inherited colors and
|
|
45
|
+
highlight settings. Resolved colors are CSS strings; raw config values may use
|
|
46
|
+
native color names or gradients. Unknown fields and nested JSON values survive.
|
|
47
|
+
|
|
48
|
+
The source is checked before decoding: embedded pages accept only their parent;
|
|
49
|
+
top-level pages require self plus exact origin. The SDK validates the snapshot's
|
|
50
|
+
required shape, resolved CSS colors and finite numeric settings, then clones and
|
|
51
|
+
deep-freezes the entire tree without a projection whitelist. JSON is bounded to
|
|
52
|
+
50,000 values, 32 nesting levels, 1 MiB of key/string characters and 64 KiB per
|
|
53
|
+
string. Invalid, oversized or cyclic snapshots do not replace the last valid one.
|
|
54
|
+
Theme remains public styling data, never an identity proof or backend authority.
|
|
55
|
+
|
|
56
|
+
Connect during module initialization before iframe load (production) or
|
|
57
|
+
DOMContentLoaded (dev). The listener installs synchronously; `current` starts null
|
|
58
|
+
and late subscribers receive the known immutable snapshot immediately. Clients
|
|
59
|
+
are independent; disposal removes their listeners. There is no handshake/resend,
|
|
60
|
+
DOM mutation or synthesized host palette. Full snapshots update on native theme
|
|
61
|
+
changes, including edits only to the inactive Light/Dark config. Native delivery
|
|
62
|
+
caches snapshots on theme notifications rather than serializing them each poll.
|
|
63
|
+
|
|
64
|
+
SDK 0.2 intentionally does not interpret old `palette` messages. Update Desktop
|
|
65
|
+
and the SDK together. See [the complete format and migration](theme.md).
|
|
58
66
|
|
|
59
67
|
## View presentation
|
|
60
68
|
|
package/docs/theme.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Complete application theme (SDK 0.2)
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
const app = await connectApp();
|
|
5
|
+
app.theme.subscribe(theme => {
|
|
6
|
+
theme.mode; // "light" | "dark"
|
|
7
|
+
theme.colors.success; // resolved current CSS color
|
|
8
|
+
theme.colors.tab_bar;
|
|
9
|
+
theme.colors.scrollbar_thumb;
|
|
10
|
+
theme.light_theme.colors["base.blue.light"];
|
|
11
|
+
theme.dark_theme.colors["success.background"];
|
|
12
|
+
theme.dark_theme["font.size"];
|
|
13
|
+
theme.dark_theme.highlight;
|
|
14
|
+
theme.tokens.background; // solid color + native background data
|
|
15
|
+
theme.semantic_tokens; // complete colors/radius/spacing/etc.
|
|
16
|
+
theme.highlight_theme;
|
|
17
|
+
theme.font_family;
|
|
18
|
+
theme.mono_font_family;
|
|
19
|
+
theme.radius;
|
|
20
|
+
});
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The message is `{ type: "pioneer.theme", theme: { ... } }`. `theme.current` is that
|
|
24
|
+
complete snapshot, not a selected color palette. It is recursively immutable and
|
|
25
|
+
retains every serializable field, including future fields unknown to this SDK.
|
|
26
|
+
Both Light and Dark configs are included regardless of which mode is active.
|
|
27
|
+
Config color keys use the original dotted spelling from the theme-file schema;
|
|
28
|
+
resolved current colors use native ThemeColor names. Config values can be null
|
|
29
|
+
when inherited. Use resolved `theme.colors` to render the current appearance.
|
|
30
|
+
|
|
31
|
+
The exported `Theme`, `ThemeColors`, `ThemeConfig` and `ThemeConfigColors` types
|
|
32
|
+
cover the complete known schema. `THEME_COLOR_KEYS` lists all 139 resolved color
|
|
33
|
+
roles, and `THEME_CONFIG_COLOR_KEYS` lists all 140 theme-file roles from the pinned
|
|
34
|
+
GPUI schema, including every color in Pioneer's theme template. Open JSON index
|
|
35
|
+
signatures preserve access to future keys without requiring another transport
|
|
36
|
+
change. Native delivery serializes the theme directly; those SDK lists validate
|
|
37
|
+
and describe known fields, and never filter unknown fields out of a snapshot.
|
|
38
|
+
|
|
39
|
+
Font sizes and radii are numeric pixels. Colors serialized by native GPUI use
|
|
40
|
+
`#RRGGBBAA`; other CSS color strings are accepted for resolved colors. Native
|
|
41
|
+
background/gradient and highlighting objects are retained as JSON data. SDK
|
|
42
|
+
performs no CSS injection or implicit conversion of native drawing structures.
|
|
43
|
+
|
|
44
|
+
## Migrating from 0.1
|
|
45
|
+
|
|
46
|
+
| Previous | 0.2 |
|
|
47
|
+
| --- | --- |
|
|
48
|
+
| `theme.appearance` | `theme.mode` |
|
|
49
|
+
| `theme.background` / `foreground` / `border` | `theme.colors.background` / `foreground` / `border` |
|
|
50
|
+
| `theme.muted` | `theme.colors.muted_foreground` |
|
|
51
|
+
| `theme.accent` / `theme["accent-foreground"]` | `theme.colors.primary` / `primary_foreground` |
|
|
52
|
+
| `theme.success`, `warning`, `danger`, `info` | `theme.colors.success`, `warning`, `danger`, `info` |
|
|
53
|
+
|
|
54
|
+
No flat aliases or old-palette adapter are provided. Use the updated Desktop
|
|
55
|
+
bridge and SDK 0.2 together. Outside Pioneer, `theme.current` remains null until a
|
|
56
|
+
complete valid snapshot arrives; applications own any standalone defaults.
|