@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/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',palette:{appearance,background,foreground,
40
- muted,border,accent,'accent-foreground'}}. appearance is light/dark; colors are
41
- valid CSS colors of at most 128 characters. Optional `success`, `warning`, `danger`
42
- and `info` tokens carry the active desktop theme's semantic status colors. A
43
- present status token must obey the same CSS color validation. Older palettes
44
- without these fields remain valid; the SDK preserves absence instead of inventing
45
- colors. Embedded pages check source===parent
46
- without demanding a non-opaque origin. Top-level pages check source===window AND
47
- origin===location.origin. Theme is public styling data, never an identity proof.
48
- No environment variable, handshake or ready event is involved. Import is inert
49
- and SSR-safe; call connectApp at browser module initialization before iframe load
50
- (production) or DOMContentLoaded (dev). It installs its listener synchronously,
51
- before awaiting the returned promise. Dev injection sends at initialization and
52
- DOMContentLoaded; native load/theme updates may send again, but a late connection
53
- cannot request a resend. current starts null until a valid message. subscribe
54
- immediately delivers known current, then future updates. Connections own separate
55
- state/listeners; disposing one leaves another active. Reconnecting after disposal
56
- starts null. No palette is synthesized outside Pioneer. SDK never mutates DOM,
57
- styles or hydration markup: the application owns state and rendering.
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.