@capybara-hq/plugin-sdk 0.1.0-rc.9 → 0.1.0-rc.90

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.
Files changed (159) hide show
  1. package/README.md +3 -1
  2. package/agent-docs/agent-templates.md +14 -2
  3. package/agent-docs/concepts.md +14 -5
  4. package/agent-docs/connector-templates.md +11 -3
  5. package/agent-docs/extension-points/channel.md +1 -1
  6. package/agent-docs/extension-points/context.md +15 -0
  7. package/agent-docs/extension-points/device-provider.md +15 -0
  8. package/agent-docs/extension-points/file-preview.md +3 -1
  9. package/agent-docs/extension-points/identity-source.md +2 -0
  10. package/agent-docs/extension-points/model-provider.md +5 -1
  11. package/agent-docs/extension-points/object-store.md +2 -0
  12. package/agent-docs/extension-points/push-provider.md +17 -0
  13. package/agent-docs/extension-points/trigger-source.md +19 -0
  14. package/agent-docs/extensions.md +98 -4
  15. package/agent-docs/plugin-format.md +45 -10
  16. package/agent-docs/setup.md +54 -0
  17. package/api/plugin-sdk.api.md +5983 -0
  18. package/dist/agent-template.d.ts +15 -6
  19. package/dist/agent-template.js +32 -13
  20. package/dist/agents-ctx.d.ts +116 -0
  21. package/dist/agents-ctx.js +22 -0
  22. package/dist/avatar-presets.d.ts +8 -0
  23. package/dist/avatar-presets.js +17 -0
  24. package/dist/bootstrap.d.ts +109 -1
  25. package/dist/bootstrap.js +185 -2
  26. package/dist/cards.d.ts +121 -13
  27. package/dist/cards.js +161 -19
  28. package/dist/channel.d.ts +133 -47
  29. package/dist/channel.js +10 -5
  30. package/dist/client-css.d.ts +36 -0
  31. package/dist/client-css.js +326 -0
  32. package/dist/client-section.d.ts +35 -0
  33. package/dist/client-section.js +133 -0
  34. package/dist/config-ui.d.ts +28 -6
  35. package/dist/config-ui.js +88 -25
  36. package/dist/config-url-fetch.d.ts +19 -0
  37. package/dist/config-url-fetch.js +43 -0
  38. package/dist/connector-auth.d.ts +13 -2
  39. package/dist/connector-auth.js +82 -8
  40. package/dist/connector.d.ts +74 -32
  41. package/dist/context.d.ts +40 -0
  42. package/dist/context.js +2 -0
  43. package/dist/ctx.d.ts +344 -31
  44. package/dist/ctx.js +9 -1
  45. package/dist/define-extension.d.ts +18 -12
  46. package/dist/define-extension.js +18 -5
  47. package/dist/device-denied-paths.d.ts +20 -0
  48. package/dist/device-denied-paths.js +118 -0
  49. package/dist/device-operation.d.ts +348 -0
  50. package/dist/device-operation.js +312 -0
  51. package/dist/device-protocol.d.ts +286 -49
  52. package/dist/device-protocol.js +766 -89
  53. package/dist/device-provider.d.ts +820 -0
  54. package/dist/device-provider.js +432 -0
  55. package/dist/device-service.d.ts +204 -0
  56. package/dist/device-service.js +291 -0
  57. package/dist/dial-in.d.ts +286 -0
  58. package/dist/dial-in.js +213 -0
  59. package/dist/directory.d.ts +15 -12
  60. package/dist/extension-point.d.ts +2 -0
  61. package/dist/extension-point.js +8 -3
  62. package/dist/field-meta.d.ts +19 -0
  63. package/dist/field-meta.js +54 -0
  64. package/dist/file-preview.d.ts +46 -9
  65. package/dist/git-hosts.d.ts +53 -0
  66. package/dist/git-hosts.js +98 -0
  67. package/dist/hooks.d.ts +185 -22
  68. package/dist/hooks.js +6 -0
  69. package/dist/http-access.d.ts +71 -0
  70. package/dist/http-access.js +12 -0
  71. package/dist/identity.d.ts +70 -9
  72. package/dist/identity.js +46 -1
  73. package/dist/inbox.d.ts +103 -0
  74. package/dist/inbox.js +173 -0
  75. package/dist/index.d.ts +30 -4
  76. package/dist/index.js +30 -4
  77. package/dist/model-params.d.ts +41 -22
  78. package/dist/model-params.js +28 -15
  79. package/dist/model.d.ts +295 -77
  80. package/dist/model.js +249 -21
  81. package/dist/native-failure.d.ts +13 -0
  82. package/dist/native-failure.js +31 -0
  83. package/dist/net.d.ts +52 -0
  84. package/dist/net.js +34 -0
  85. package/dist/network-classes.d.ts +98 -0
  86. package/dist/network-classes.js +291 -0
  87. package/dist/permissions.d.ts +95 -25
  88. package/dist/permissions.js +175 -54
  89. package/dist/platform-only.d.ts +27 -0
  90. package/dist/platform-only.js +35 -0
  91. package/dist/plugin-manifest.d.ts +30 -6
  92. package/dist/plugin-manifest.js +147 -55
  93. package/dist/plugin-package.d.ts +82 -39
  94. package/dist/plugin-package.js +68 -41
  95. package/dist/push.d.ts +75 -0
  96. package/dist/push.js +87 -0
  97. package/dist/sandbox-linux-runtime-source.d.ts +1 -0
  98. package/dist/sandbox-linux-runtime-source.js +2343 -0
  99. package/dist/sandbox-native-runtime-source.d.ts +10 -0
  100. package/dist/sandbox-native-runtime-source.js +480 -0
  101. package/dist/sandbox-runtime-source.d.ts +47 -0
  102. package/dist/sandbox-runtime-source.js +73 -0
  103. package/dist/sandbox-write-denies.d.ts +139 -0
  104. package/dist/sandbox-write-denies.js +869 -0
  105. package/dist/secret.d.ts +8 -2
  106. package/dist/secret.js +11 -4
  107. package/dist/setup-check.d.ts +128 -0
  108. package/dist/setup-check.js +142 -0
  109. package/dist/setup-guide-parse.d.ts +121 -0
  110. package/dist/setup-guide-parse.js +356 -0
  111. package/dist/setup-guide-render.d.ts +45 -0
  112. package/dist/setup-guide-render.js +351 -0
  113. package/dist/setup-guide.d.ts +86 -72
  114. package/dist/setup-guide.js +340 -108
  115. package/dist/shell-capabilities.d.ts +216 -0
  116. package/dist/shell-capabilities.js +44 -0
  117. package/dist/shell-environment.d.ts +57 -0
  118. package/dist/shell-environment.js +21 -0
  119. package/dist/skill-invocation.d.ts +5 -0
  120. package/dist/skill-invocation.js +4 -3
  121. package/dist/skill.d.ts +27 -17
  122. package/dist/skill.js +40 -26
  123. package/dist/storage.d.ts +52 -25
  124. package/dist/svg-viewbox.d.ts +10 -0
  125. package/dist/svg-viewbox.js +24 -0
  126. package/dist/theme-assets.d.ts +25 -9
  127. package/dist/theme-assets.js +87 -47
  128. package/dist/theme-tokens.generated.d.ts +40 -12
  129. package/dist/theme-tokens.generated.js +36 -8
  130. package/dist/theme.d.ts +56 -10
  131. package/dist/theme.js +117 -23
  132. package/dist/tool.d.ts +242 -28
  133. package/dist/tool.js +135 -13
  134. package/dist/trigger-source.d.ts +35 -0
  135. package/dist/trigger-source.js +2 -0
  136. package/dist/triggers.d.ts +88 -0
  137. package/dist/triggers.js +71 -0
  138. package/dist/ui-parts.d.ts +23 -0
  139. package/dist/ui-parts.js +374 -0
  140. package/dist/ui-resolve.d.ts +2 -7
  141. package/dist/ui-resolve.js +7 -19
  142. package/dist/ui-slots.d.ts +27 -5
  143. package/dist/ui-slots.js +112 -19
  144. package/dist/ui.d.ts +203 -64
  145. package/dist/ui.js +117 -23
  146. package/dist/url.d.ts +4 -1
  147. package/dist/url.js +4 -1
  148. package/dist/web.d.ts +26 -20
  149. package/package.json +13 -1
  150. package/schemas/bootstrap-extra.v1.schema.json +186 -0
  151. package/schemas/bootstrap.v1.schema.json +20 -0
  152. package/schemas/connector-template.v1.schema.json +62 -4
  153. package/schemas/plugin.v1.schema.json +74 -143
  154. package/schemas/theme.v1.schema.json +77 -0
  155. package/agent-docs/extension-points/sandbox.md +0 -15
  156. package/dist/org-access.d.ts +0 -27
  157. package/dist/org-access.js +0 -35
  158. package/dist/sandbox.d.ts +0 -254
  159. package/dist/sandbox.js +0 -153
package/dist/theme.d.ts CHANGED
@@ -1,20 +1,22 @@
1
1
  import { z } from "zod";
2
+ import { type BuiltinAvatarPresetId } from "./avatar-presets.js";
2
3
  import { type LocalizedName } from "./plugin-package.js";
3
4
  import { type MergedScheme, type ThemeScheme } from "./theme-readability.js";
4
5
  /**
5
6
  * A theme file `themes/<id>.json` (themes spec §4): a partial override of the design tokens per
6
- * scheme, optional fonts and an optional logo. The id is the file's base name
7
+ * scheme, optional fonts, an optional logo and the brand fields (theme brand coverage spec §1:
8
+ * illustration, app icons, decoration, avatar presets). The id is the file's base name
7
9
  * ({@link themeIdOf}, `CATALOG_ITEM_NAME_RE`).
8
10
  *
9
11
  * {@link parseThemeFile} is the CSS-injection boundary: every token value is parsed against the
10
12
  * grammar `tokens.json` uses (`#RRGGBB`, `rgba(r,g,b,a)`, shadows `<x> <y> <blur> [<spread>]
11
13
  * <color>`) and re-rendered from its parts in canonical form. Asset paths (`fonts[].file`,
12
- * `logo.*`) are relative to the plugin root (an optional leading `./`) and every segment is limited
13
- * to `[A-Za-z0-9._-]`, so they need no escaping inside `url(...)`. Font families are limited to
14
- * letters, digits, spaces and `-`. Free text (`name`, `description`, `logo.wordmark`) carries no
15
- * control, format, line / paragraph separator or lone surrogate characters; it is text for the UI,
16
- * never CSS. Whether the files exist and their size / signature / SVG rules are checked by
17
- * the reader of the package, with {@link THEME_LIMITS}.
14
+ * `logo.*`, `avatars[].file`) are relative to the plugin root (an optional leading `./`) and every
15
+ * segment is limited to `[A-Za-z0-9._-]`, so they need no escaping inside `url(...)`. Font
16
+ * families are limited to letters, digits, spaces and `-`. Free text (`name`, `description`,
17
+ * `logo.wordmark`, `avatars[].name`) carries no control, format, line / paragraph separator or
18
+ * lone surrogate characters; it is text for the UI, never CSS. Whether the files exist and their
19
+ * size / signature / SVG rules are checked by the reader of the package, with {@link THEME_LIMITS}.
18
20
  *
19
21
  * The committed JSON Schema (`schemas/theme.v1.schema.json`) is generated from
20
22
  * {@link ThemeFileSchema} (the shape only) by `pnpm gen:package-schemas`; token names, value
@@ -26,7 +28,7 @@ export declare const THEME_LIMITS: {
26
28
  readonly fileBytes: number;
27
29
  /** Themes per plugin. */
28
30
  readonly perPlugin: 10;
29
- /** Total bytes of a plugin's theme assets (fonts and logos). */
31
+ /** Total bytes of a plugin's theme assets (fonts, logos, app icons and avatars). */
30
32
  readonly assetsBytes: number;
31
33
  /** Fonts per theme. */
32
34
  readonly fonts: 8;
@@ -38,9 +40,21 @@ export declare const THEME_LIMITS: {
38
40
  readonly pngBytes: number;
39
41
  /** Minimum pixel height of a logo PNG. */
40
42
  readonly pngMinHeight: 64;
41
- /** Characters of the wordmark. */
43
+ /** Characters of the wordmark (and of each avatar preset name). */
42
44
  readonly wordmark: 24;
45
+ /** Avatar presets per theme. */
46
+ readonly avatars: 12;
47
+ /** Bytes of an app icon PNG. */
48
+ readonly appIconBytes: 1048576;
49
+ /** Minimum pixel size of an app icon PNG (square). */
50
+ readonly appIconMinSize: 512;
43
51
  };
52
+ /** The id of a theme's avatar preset (`avatars[].id`); never a built-in preset id. */
53
+ export declare const THEME_AVATAR_ID_RE: RegExp;
54
+ /** The sign-in page background decoration (the dither columns) a theme asks for; omitted means
55
+ * `dither`. */
56
+ export declare const THEME_DECORATIONS: readonly ["dither", "none"];
57
+ export type ThemeDecoration = (typeof THEME_DECORATIONS)[number];
44
58
  /** A theme of the plugin: a `./…/<id>.json` file ({@link ThemeFile}). */
45
59
  export interface PluginThemeRef {
46
60
  path: string;
@@ -74,6 +88,24 @@ export interface ThemeLogo {
74
88
  wordmark?: string;
75
89
  /** `.svg` or `.png` path inside the plugin. */
76
90
  favicon?: string;
91
+ /** The empty-state art: `.svg` or `.png` path inside the plugin, the `mark` rules. */
92
+ illustration?: string;
93
+ /** Apple touch and manifest `any` icon: a square `.png` path, ≥ 512 px, ≤ 1 MiB. */
94
+ appIcon?: string;
95
+ /** Manifest `maskable` icon: a square `.png` path, ≥ 512 px, ≤ 1 MiB; requires `appIcon`. */
96
+ appIconMaskable?: string;
97
+ }
98
+ /** An agent avatar preset the theme adds to the picker. */
99
+ export interface ThemeAvatarPreset {
100
+ /** {@link THEME_AVATAR_ID_RE}, unique in the theme, not a built-in preset id. */
101
+ id: string;
102
+ /** Each ≤ 24 characters, the wordmark's character rules. */
103
+ name: {
104
+ en: string;
105
+ zh?: string;
106
+ };
107
+ /** A square `.svg` or `.png` path inside the plugin (PNG ≥ 64 px, the `mark` size limits). */
108
+ file: string;
77
109
  }
78
110
  /** `themes/<id>.json`. */
79
111
  export interface ThemeFile {
@@ -86,6 +118,12 @@ export interface ThemeFile {
86
118
  schemes: Partial<Record<ThemeScheme, ThemeSchemeOverride>>;
87
119
  fonts?: ThemeFont[];
88
120
  logo?: ThemeLogo;
121
+ /** Omitted means `dither`; readers apply the default. */
122
+ decoration?: ThemeDecoration;
123
+ /** At most {@link THEME_LIMITS}`.avatars`. */
124
+ avatars?: ThemeAvatarPreset[];
125
+ /** Built-in presets not offered; hiding all of them requires at least one `avatars` entry. */
126
+ hideAvatarPresets?: BuiltinAvatarPresetId[];
89
127
  }
90
128
  /**
91
129
  * A theme file after {@link parseThemeFile}: values canonical. It holds only the file's own
@@ -108,7 +146,7 @@ export interface ParseThemeOptions {
108
146
  */
109
147
  readability?: boolean;
110
148
  }
111
- /** `themes/night-city.json` → `night-city`. */
149
+ /** `themes/neon-grid.json` → `neon-grid`. */
112
150
  export declare function themeIdOf(path: string): string;
113
151
  /**
114
152
  * The zod schema of a theme file's shape (strict objects). Token names and values are only
@@ -130,6 +168,14 @@ export declare function isThemeFontFamily(v: unknown): v is string;
130
168
  * every segment of `[A-Za-z0-9._-]`, no `.` / `..` segments (the extension is not checked).
131
169
  */
132
170
  export declare function isThemeAssetPath(v: unknown): v is string;
171
+ /**
172
+ * Values a theme scheme takes for tokens it leaves out but whose built-in value only suits the
173
+ * built-in palette. `field` (the ground of a form control) is white in the built-in light scheme
174
+ * because the built-in cards are grey: a scheme that recolours `panel` without naming `field`
175
+ * keeps clear fields, so its controls show its own card through, as they did before `field`
176
+ * existed. A theme that wants filled fields names `field` itself.
177
+ */
178
+ export declare function themeSchemeFallbacks(overridden: ReadonlySet<string>): Record<string, string>;
133
179
  /**
134
180
  * Each scheme the theme defines, merged onto the current built-in values (for swatches, the
135
181
  * readability check and anything else that needs full values). A stored theme is read leniently:
package/dist/theme.js CHANGED
@@ -1,21 +1,23 @@
1
1
  import { z } from "zod";
2
+ import { BUILTIN_AVATAR_PRESET_IDS } from "./avatar-presets.js";
2
3
  import { CATALOG_ITEM_NAME_RE, isSafePackagePath } from "./plugin-package.js";
3
4
  import { checkThemeReadability } from "./theme-readability.js";
4
5
  import { THEME_OVERRIDABLE, THEME_TOKENS } from "./theme-tokens.generated.js";
5
6
  /**
6
7
  * A theme file `themes/<id>.json` (themes spec §4): a partial override of the design tokens per
7
- * scheme, optional fonts and an optional logo. The id is the file's base name
8
+ * scheme, optional fonts, an optional logo and the brand fields (theme brand coverage spec §1:
9
+ * illustration, app icons, decoration, avatar presets). The id is the file's base name
8
10
  * ({@link themeIdOf}, `CATALOG_ITEM_NAME_RE`).
9
11
  *
10
12
  * {@link parseThemeFile} is the CSS-injection boundary: every token value is parsed against the
11
13
  * grammar `tokens.json` uses (`#RRGGBB`, `rgba(r,g,b,a)`, shadows `<x> <y> <blur> [<spread>]
12
14
  * <color>`) and re-rendered from its parts in canonical form. Asset paths (`fonts[].file`,
13
- * `logo.*`) are relative to the plugin root (an optional leading `./`) and every segment is limited
14
- * to `[A-Za-z0-9._-]`, so they need no escaping inside `url(...)`. Font families are limited to
15
- * letters, digits, spaces and `-`. Free text (`name`, `description`, `logo.wordmark`) carries no
16
- * control, format, line / paragraph separator or lone surrogate characters; it is text for the UI,
17
- * never CSS. Whether the files exist and their size / signature / SVG rules are checked by
18
- * the reader of the package, with {@link THEME_LIMITS}.
15
+ * `logo.*`, `avatars[].file`) are relative to the plugin root (an optional leading `./`) and every
16
+ * segment is limited to `[A-Za-z0-9._-]`, so they need no escaping inside `url(...)`. Font
17
+ * families are limited to letters, digits, spaces and `-`. Free text (`name`, `description`,
18
+ * `logo.wordmark`, `avatars[].name`) carries no control, format, line / paragraph separator or
19
+ * lone surrogate characters; it is text for the UI, never CSS. Whether the files exist and their
20
+ * size / signature / SVG rules are checked by the reader of the package, with {@link THEME_LIMITS}.
19
21
  *
20
22
  * The committed JSON Schema (`schemas/theme.v1.schema.json`) is generated from
21
23
  * {@link ThemeFileSchema} (the shape only) by `pnpm gen:package-schemas`; token names, value
@@ -27,7 +29,7 @@ export const THEME_LIMITS = {
27
29
  fileBytes: 64 * 1024,
28
30
  /** Themes per plugin. */
29
31
  perPlugin: 10,
30
- /** Total bytes of a plugin's theme assets (fonts and logos). */
32
+ /** Total bytes of a plugin's theme assets (fonts, logos, app icons and avatars). */
31
33
  assetsBytes: 16 * 1024 * 1024,
32
34
  /** Fonts per theme. */
33
35
  fonts: 8,
@@ -39,10 +41,21 @@ export const THEME_LIMITS = {
39
41
  pngBytes: 256 * 1024,
40
42
  /** Minimum pixel height of a logo PNG. */
41
43
  pngMinHeight: 64,
42
- /** Characters of the wordmark. */
44
+ /** Characters of the wordmark (and of each avatar preset name). */
43
45
  wordmark: 24,
46
+ /** Avatar presets per theme. */
47
+ avatars: 12,
48
+ /** Bytes of an app icon PNG. */
49
+ appIconBytes: 1_048_576,
50
+ /** Minimum pixel size of an app icon PNG (square). */
51
+ appIconMinSize: 512,
44
52
  };
45
- /** `themes/night-city.json` → `night-city`. */
53
+ /** The id of a theme's avatar preset (`avatars[].id`); never a built-in preset id. */
54
+ export const THEME_AVATAR_ID_RE = /^[a-z0-9][a-z0-9-]{0,31}$/;
55
+ /** The sign-in page background decoration (the dither columns) a theme asks for; omitted means
56
+ * `dither`. */
57
+ export const THEME_DECORATIONS = ["dither", "none"];
58
+ /** `themes/neon-grid.json` → `neon-grid`. */
46
59
  export function themeIdOf(path) {
47
60
  return (path.split("/").pop() ?? "").replace(/\.json$/, "");
48
61
  }
@@ -53,6 +66,8 @@ const FORBIDDEN_CHARS_RE = /[\p{Cc}\p{Cf}\p{Zl}\p{Zp}\p{Cs}]/u;
53
66
  const PATH_SEGMENT_RE = /^[A-Za-z0-9._-]+$/;
54
67
  const FORBIDDEN_CHARS_MESSAGE = "must not contain control, format, line / paragraph separator or lone surrogate characters";
55
68
  const IMAGE_RE = /\.(?:svg|png)$/i;
69
+ const PNG_RE = /\.png$/i;
70
+ const BUILTIN_AVATARS = new Set(BUILTIN_AVATAR_PRESET_IDS);
56
71
  const MAX_VALUE_CHARS = 256;
57
72
  const text = (max, what) => z
58
73
  .string()
@@ -60,6 +75,14 @@ const text = (max, what) => z
60
75
  .max(max)
61
76
  .regex(/\S/, { message: `${what} must not be blank` })
62
77
  .refine((t) => !FORBIDDEN_CHARS_RE.test(t), { message: `${what} ${FORBIDDEN_CHARS_MESSAGE}` });
78
+ /** Short free text (the wordmark, avatar names): not blank, ≤ 24 characters, no forbidden ones. */
79
+ const shortText = (what) => z
80
+ .string()
81
+ .regex(/\S/, { message: `${what} must not be blank` })
82
+ .refine((w) => [...w].length <= THEME_LIMITS.wordmark, {
83
+ message: `${what} must be at most ${THEME_LIMITS.wordmark} characters`,
84
+ })
85
+ .refine((w) => !FORBIDDEN_CHARS_RE.test(w), { message: `${what} ${FORBIDDEN_CHARS_MESSAGE}` });
63
86
  /** A plugin-root relative path (optional `./`), each segment `[A-Za-z0-9._-]`, no `.` / `..`. */
64
87
  const isPlainAssetPath = (p) => {
65
88
  const rest = p.replace(/^\.\//, "");
@@ -81,7 +104,15 @@ const schemeOverride = z.strictObject({
81
104
  .strictObject({ sm: radius.optional(), md: radius.optional(), bubble: radius.optional() })
82
105
  .optional(),
83
106
  });
84
- const shape = z.strictObject({
107
+ const avatarPreset = z.strictObject({
108
+ id: z.string().regex(THEME_AVATAR_ID_RE, {
109
+ message: "id must match ^[a-z0-9][a-z0-9-]{0,31}$",
110
+ }),
111
+ name: z.strictObject({ en: shortText("name.en"), zh: shortText("name.zh").optional() }),
112
+ file: assetPath("file", IMAGE_RE, ".svg or .png"),
113
+ });
114
+ const shape = z
115
+ .strictObject({
85
116
  $schema: z.string().max(512).optional(),
86
117
  name: z.strictObject({ zh: text(100, "name.zh"), en: text(100, "name.en") }),
87
118
  description: z
@@ -110,19 +141,67 @@ const shape = z.strictObject({
110
141
  logo: z
111
142
  .strictObject({
112
143
  mark: assetPath("mark", IMAGE_RE, ".svg or .png").optional(),
113
- wordmark: z
114
- .string()
115
- .regex(/\S/, { message: "wordmark must not be blank" })
116
- .refine((w) => [...w].length <= THEME_LIMITS.wordmark, {
117
- message: `wordmark must be at most ${THEME_LIMITS.wordmark} characters`,
118
- })
119
- .refine((w) => !FORBIDDEN_CHARS_RE.test(w), {
120
- message: `wordmark ${FORBIDDEN_CHARS_MESSAGE}`,
121
- })
122
- .optional(),
144
+ wordmark: shortText("wordmark").optional(),
123
145
  favicon: assetPath("favicon", IMAGE_RE, ".svg or .png").optional(),
146
+ illustration: assetPath("illustration", IMAGE_RE, ".svg or .png").optional(),
147
+ appIcon: assetPath("appIcon", PNG_RE, ".png").optional(),
148
+ appIconMaskable: assetPath("appIconMaskable", PNG_RE, ".png").optional(),
149
+ })
150
+ .superRefine((l, ctx) => {
151
+ if (l.appIconMaskable !== undefined && l.appIcon === undefined) {
152
+ ctx.addIssue({
153
+ code: "custom",
154
+ path: ["appIconMaskable"],
155
+ message: "appIconMaskable requires appIcon",
156
+ });
157
+ }
158
+ })
159
+ .optional(),
160
+ decoration: z.enum(THEME_DECORATIONS).optional(),
161
+ avatars: z
162
+ .array(avatarPreset)
163
+ .max(THEME_LIMITS.avatars)
164
+ .superRefine((list, ctx) => {
165
+ const seen = new Set();
166
+ list.forEach((a, i) => {
167
+ if (BUILTIN_AVATARS.has(a.id)) {
168
+ ctx.addIssue({
169
+ code: "custom",
170
+ path: [i, "id"],
171
+ message: `id must not be a built-in avatar preset id (${a.id})`,
172
+ });
173
+ }
174
+ else if (seen.has(a.id)) {
175
+ ctx.addIssue({
176
+ code: "custom",
177
+ path: [i, "id"],
178
+ message: `duplicate avatar id ${a.id}`,
179
+ });
180
+ }
181
+ seen.add(a.id);
182
+ });
124
183
  })
125
184
  .optional(),
185
+ hideAvatarPresets: z
186
+ .array(z.enum(BUILTIN_AVATAR_PRESET_IDS))
187
+ .superRefine((list, ctx) => {
188
+ list.forEach((id, i) => {
189
+ if (list.indexOf(id) !== i) {
190
+ ctx.addIssue({ code: "custom", path: [i], message: `duplicate hidden preset ${id}` });
191
+ }
192
+ });
193
+ })
194
+ .optional(),
195
+ })
196
+ .superRefine((t, ctx) => {
197
+ const hidden = new Set(t.hideAvatarPresets ?? []);
198
+ if (hidden.size === BUILTIN_AVATAR_PRESET_IDS.length && (t.avatars?.length ?? 0) === 0) {
199
+ ctx.addIssue({
200
+ code: "custom",
201
+ path: ["hideAvatarPresets"],
202
+ message: "hiding every built-in avatar preset requires at least one entry in avatars",
203
+ });
204
+ }
126
205
  });
127
206
  /**
128
207
  * The zod schema of a theme file's shape (strict objects). Token names and values are only
@@ -210,6 +289,16 @@ export function isThemeFontFamily(v) {
210
289
  export function isThemeAssetPath(v) {
211
290
  return typeof v === "string" && v.length <= 512 && isPlainAssetPath(v);
212
291
  }
292
+ /**
293
+ * Values a theme scheme takes for tokens it leaves out but whose built-in value only suits the
294
+ * built-in palette. `field` (the ground of a form control) is white in the built-in light scheme
295
+ * because the built-in cards are grey: a scheme that recolours `panel` without naming `field`
296
+ * keeps clear fields, so its controls show its own card through, as they did before `field`
297
+ * existed. A theme that wants filled fields names `field` itself.
298
+ */
299
+ export function themeSchemeFallbacks(overridden) {
300
+ return overridden.has("panel") && !overridden.has("field") ? { field: "rgba(0,0,0,0)" } : {};
301
+ }
213
302
  /**
214
303
  * Each scheme the theme defines, merged onto the current built-in values (for swatches, the
215
304
  * readability check and anything else that needs full values). A stored theme is read leniently:
@@ -226,6 +315,7 @@ export function mergeThemeSchemes(theme) {
226
315
  if (over === null || typeof over !== "object")
227
316
  continue;
228
317
  const m = builtIn(scheme);
318
+ const colors = new Set();
229
319
  for (const group of ["color", "shadow"]) {
230
320
  const values = over[group];
231
321
  if (values === null || typeof values !== "object")
@@ -234,10 +324,14 @@ export function mergeThemeSchemes(theme) {
234
324
  if (!OVERRIDABLE[group].has(name))
235
325
  continue;
236
326
  const v = canonicalThemeValue(group, raw);
237
- if (v !== undefined)
238
- m[group][name] = v;
327
+ if (v === undefined)
328
+ continue;
329
+ m[group][name] = v;
330
+ if (group === "color")
331
+ colors.add(name);
239
332
  }
240
333
  }
334
+ Object.assign(m.color, themeSchemeFallbacks(colors));
241
335
  const radii = over.radius;
242
336
  if (radii !== null && typeof radii === "object") {
243
337
  for (const key of ["sm", "md", "bubble"]) {