@capybara-hq/plugin-sdk 0.1.0-rc.88 → 0.1.0-rc.89
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/api/plugin-sdk.api.md +14 -7
- package/dist/inbox.d.ts +13 -5
- package/dist/inbox.js +30 -9
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/theme-tokens.generated.d.ts +8 -4
- package/dist/theme-tokens.generated.js +14 -3
- package/dist/theme.d.ts +8 -0
- package/dist/theme.js +17 -2
- package/package.json +1 -1
package/api/plugin-sdk.api.md
CHANGED
|
@@ -2527,13 +2527,13 @@ export type InboxErrorCode = "invalid_item" | "org_disabled" | "not_found";
|
|
|
2527
2527
|
export interface InboxPost {
|
|
2528
2528
|
accountId: string;
|
|
2529
2529
|
actions?: InboxAction[];
|
|
2530
|
-
body?:
|
|
2530
|
+
body?: LocalizedText;
|
|
2531
2531
|
dedupeKey?: string;
|
|
2532
2532
|
expiresInSeconds?: number;
|
|
2533
2533
|
kind: string;
|
|
2534
2534
|
link?: string;
|
|
2535
2535
|
orgId: string;
|
|
2536
|
-
title:
|
|
2536
|
+
title: LocalizedText;
|
|
2537
2537
|
}
|
|
2538
2538
|
|
|
2539
2539
|
// @public
|
|
@@ -4362,7 +4362,7 @@ export function sanitizeThemeSvg(bytes: Uint8Array): {
|
|
|
4362
4362
|
};
|
|
4363
4363
|
|
|
4364
4364
|
// @public
|
|
4365
|
-
export const SDK_VERSION = "0.1.0-rc.
|
|
4365
|
+
export const SDK_VERSION = "0.1.0-rc.89";
|
|
4366
4366
|
|
|
4367
4367
|
// @public
|
|
4368
4368
|
export function secret<T extends z.ZodTypeAny>(schema: T): T;
|
|
@@ -4776,7 +4776,7 @@ export const THEME_LIMITS: {
|
|
|
4776
4776
|
|
|
4777
4777
|
// @public
|
|
4778
4778
|
export const THEME_OVERRIDABLE: {
|
|
4779
|
-
readonly color: readonly ["bg", "panel", "panel-2", "sidebar", "sidebar-active", "raised", "selected", "hover", "line-soft", "line", "line-strong", "line-card", "scroll-thumb", "ink", "muted", "faint", "disabled", "accent", "accent-hover", "accent-press", "on-accent", "focus-ring", "ok", "fail", "warn", "scrim", "lightbox", "float-ground", "float-line", "diff-add", "diff-del"];
|
|
4779
|
+
readonly color: readonly ["bg", "panel", "panel-2", "sidebar", "sidebar-active", "raised", "field", "selected", "hover", "line-soft", "line", "line-strong", "line-card", "scroll-thumb", "ink", "muted", "faint", "disabled", "accent", "accent-hover", "accent-press", "on-accent", "focus-ring", "ok", "fail", "warn", "scrim", "lightbox", "float-ground", "float-line", "diff-add", "diff-del"];
|
|
4780
4780
|
readonly shadow: readonly ["shadow-1", "shadow-2", "shadow-sheet", "shadow-float", "shadow-float-touch"];
|
|
4781
4781
|
readonly radius: readonly ["sm", "md", "bubble"];
|
|
4782
4782
|
};
|
|
@@ -4793,11 +4793,11 @@ export const THEME_TOKENS: {
|
|
|
4793
4793
|
};
|
|
4794
4794
|
readonly panel: {
|
|
4795
4795
|
readonly dark: "#111110";
|
|
4796
|
-
readonly light: "#
|
|
4796
|
+
readonly light: "#F9F8F5";
|
|
4797
4797
|
};
|
|
4798
4798
|
readonly "panel-2": {
|
|
4799
4799
|
readonly dark: "#0E0E0D";
|
|
4800
|
-
readonly light: "#
|
|
4800
|
+
readonly light: "#FBFAF8";
|
|
4801
4801
|
};
|
|
4802
4802
|
readonly sidebar: {
|
|
4803
4803
|
readonly dark: "#171716";
|
|
@@ -4811,6 +4811,10 @@ export const THEME_TOKENS: {
|
|
|
4811
4811
|
readonly dark: "#141413";
|
|
4812
4812
|
readonly light: "#FFFFFF";
|
|
4813
4813
|
};
|
|
4814
|
+
readonly field: {
|
|
4815
|
+
readonly dark: "rgba(0,0,0,0)";
|
|
4816
|
+
readonly light: "#FFFFFF";
|
|
4817
|
+
};
|
|
4814
4818
|
readonly selected: {
|
|
4815
4819
|
readonly dark: "#21211F";
|
|
4816
4820
|
readonly light: "rgba(26,26,24,0.07)";
|
|
@@ -4885,7 +4889,7 @@ export const THEME_TOKENS: {
|
|
|
4885
4889
|
};
|
|
4886
4890
|
readonly fail: {
|
|
4887
4891
|
readonly dark: "#FF5C52";
|
|
4888
|
-
readonly light: "#
|
|
4892
|
+
readonly light: "#C42E28";
|
|
4889
4893
|
};
|
|
4890
4894
|
readonly warn: {
|
|
4891
4895
|
readonly dark: "#F2C14B";
|
|
@@ -5131,6 +5135,9 @@ export interface ThemeLogo {
|
|
|
5131
5135
|
// @public
|
|
5132
5136
|
export type ThemeScheme = "dark" | "light";
|
|
5133
5137
|
|
|
5138
|
+
// @public
|
|
5139
|
+
export function themeSchemeFallbacks(overridden: ReadonlySet<string>): Record<string, string>;
|
|
5140
|
+
|
|
5134
5141
|
// @public
|
|
5135
5142
|
export interface ThemeSchemeOverride {
|
|
5136
5143
|
color?: Record<string, string>;
|
package/dist/inbox.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { LocalizedName } from "./plugin-package.js";
|
|
2
|
+
import type { LocalizedText } from "./tool.js";
|
|
2
3
|
/**
|
|
3
4
|
* One button on an inbox item: clicking it calls `uiAction.actionId` of the extension's UI
|
|
4
5
|
* contribution `uiAction.contribution` (registered with `ctx.ui.action`) as the person who
|
|
@@ -24,10 +25,16 @@ export interface InboxPost {
|
|
|
24
25
|
accountId: string;
|
|
25
26
|
/** What kind of item it is, for the extension ({@link INBOX_KIND_RE}). */
|
|
26
27
|
kind: string;
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
/**
|
|
29
|
+
* A single string shown as is, or `{ zh, en }` shown in the reader's language; each text at
|
|
30
|
+
* most {@link INBOX_LIMITS}.titleChars characters.
|
|
31
|
+
*/
|
|
32
|
+
title: LocalizedText;
|
|
33
|
+
/**
|
|
34
|
+
* A single string or `{ zh, en }`, like `title`; each text at most
|
|
35
|
+
* {@link INBOX_LIMITS}.bodyChars characters.
|
|
36
|
+
*/
|
|
37
|
+
body?: LocalizedText;
|
|
31
38
|
/**
|
|
32
39
|
* An in-app path opened from the item: an extension's item may only link to its own pages,
|
|
33
40
|
* `/p/<extension name>/...` (at most {@link INBOX_LIMITS}.linkChars characters).
|
|
@@ -88,7 +95,8 @@ export declare const INBOX_KIND_RE: RegExp;
|
|
|
88
95
|
export declare const INBOX_ID_RE: RegExp;
|
|
89
96
|
/**
|
|
90
97
|
* Checks a post before it is stored; returns error codes (empty = valid): `missing_<field>`,
|
|
91
|
-
* `<field>_too_long`, `
|
|
98
|
+
* `<field>_too_long`, `title_invalid` / `body_invalid` (not a string or `{ zh, en }`),
|
|
99
|
+
* `kind_invalid`, `link_invalid` (not a path of the extension's own pages
|
|
92
100
|
* `/p/<plugin>/`), `too_many_actions`, `action_invalid`, `action_duplicate`, `payload_too_large`,
|
|
93
101
|
* `expiry_invalid`. `plugin` is the posting extension's name.
|
|
94
102
|
*/
|
package/dist/inbox.js
CHANGED
|
@@ -30,7 +30,8 @@ export const INBOX_KIND_RE = /^[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)*$/;
|
|
|
30
30
|
export const INBOX_ID_RE = /^[A-Za-z0-9][A-Za-z0-9_.-]*$/;
|
|
31
31
|
/**
|
|
32
32
|
* Checks a post before it is stored; returns error codes (empty = valid): `missing_<field>`,
|
|
33
|
-
* `<field>_too_long`, `
|
|
33
|
+
* `<field>_too_long`, `title_invalid` / `body_invalid` (not a string or `{ zh, en }`),
|
|
34
|
+
* `kind_invalid`, `link_invalid` (not a path of the extension's own pages
|
|
34
35
|
* `/p/<plugin>/`), `too_many_actions`, `action_invalid`, `action_duplicate`, `payload_too_large`,
|
|
35
36
|
* `expiry_invalid`. `plugin` is the posting extension's name.
|
|
36
37
|
*/
|
|
@@ -46,15 +47,13 @@ export function validateInboxPost(p, plugin) {
|
|
|
46
47
|
errs.push("missing_kind");
|
|
47
48
|
else if (p.kind.length > INBOX_LIMITS.kindChars || !INBOX_KIND_RE.test(p.kind))
|
|
48
49
|
errs.push("kind_invalid");
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
errs.push("title_too_long");
|
|
50
|
+
const title = textProblem(p.title, INBOX_LIMITS.titleChars, true);
|
|
51
|
+
if (title !== null)
|
|
52
|
+
errs.push(`${title === "missing" ? "missing_title" : `title_${title}`}`);
|
|
53
53
|
if (p.body !== undefined) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
errs.push("body_too_long");
|
|
54
|
+
const body = textProblem(p.body, INBOX_LIMITS.bodyChars, false);
|
|
55
|
+
if (body !== null)
|
|
56
|
+
errs.push(body === "missing" ? "body_invalid" : `body_${body}`);
|
|
58
57
|
}
|
|
59
58
|
if (p.link !== undefined) {
|
|
60
59
|
if (!str(p.link) || p.link.length > INBOX_LIMITS.linkChars || !ownPageLink(p.link, plugin))
|
|
@@ -90,6 +89,28 @@ export function validateInboxPost(p, plugin) {
|
|
|
90
89
|
}
|
|
91
90
|
return [...new Set(errs)];
|
|
92
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* What is wrong with a title or body (a string, or `{ zh, en }` with both strings): `missing` (a
|
|
94
|
+
* required text that is not a string or object, or blank), `invalid` (an object with another
|
|
95
|
+
* shape, or a blank language of a required text), `too_long`; null when it is fine.
|
|
96
|
+
*/
|
|
97
|
+
function textProblem(v, max, required) {
|
|
98
|
+
const blank = (t) => required && t.trim() === "";
|
|
99
|
+
if (typeof v === "string") {
|
|
100
|
+
if (blank(v))
|
|
101
|
+
return "missing";
|
|
102
|
+
return v.length > max ? "too_long" : null;
|
|
103
|
+
}
|
|
104
|
+
if (typeof v !== "object" || v === null || Array.isArray(v))
|
|
105
|
+
return "missing";
|
|
106
|
+
const keys = Object.keys(v);
|
|
107
|
+
const { zh, en } = v;
|
|
108
|
+
if (keys.length !== 2 || typeof zh !== "string" || typeof en !== "string")
|
|
109
|
+
return "invalid";
|
|
110
|
+
if (blank(zh) || blank(en))
|
|
111
|
+
return "invalid";
|
|
112
|
+
return zh.length > max || en.length > max ? "too_long" : null;
|
|
113
|
+
}
|
|
93
114
|
const idOk = (v) => typeof v === "string" && v.length <= INBOX_LIMITS.idChars && INBOX_ID_RE.test(v);
|
|
94
115
|
const labelOk = (v) => typeof v === "string" && v.trim() !== "" && v.length <= INBOX_LIMITS.labelChars;
|
|
95
116
|
function actionProblem(a) {
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -7,11 +7,11 @@ export declare const THEME_TOKENS: {
|
|
|
7
7
|
};
|
|
8
8
|
readonly panel: {
|
|
9
9
|
readonly dark: "#111110";
|
|
10
|
-
readonly light: "#
|
|
10
|
+
readonly light: "#F9F8F5";
|
|
11
11
|
};
|
|
12
12
|
readonly "panel-2": {
|
|
13
13
|
readonly dark: "#0E0E0D";
|
|
14
|
-
readonly light: "#
|
|
14
|
+
readonly light: "#FBFAF8";
|
|
15
15
|
};
|
|
16
16
|
readonly sidebar: {
|
|
17
17
|
readonly dark: "#171716";
|
|
@@ -25,6 +25,10 @@ export declare const THEME_TOKENS: {
|
|
|
25
25
|
readonly dark: "#141413";
|
|
26
26
|
readonly light: "#FFFFFF";
|
|
27
27
|
};
|
|
28
|
+
readonly field: {
|
|
29
|
+
readonly dark: "rgba(0,0,0,0)";
|
|
30
|
+
readonly light: "#FFFFFF";
|
|
31
|
+
};
|
|
28
32
|
readonly selected: {
|
|
29
33
|
readonly dark: "#21211F";
|
|
30
34
|
readonly light: "rgba(26,26,24,0.07)";
|
|
@@ -99,7 +103,7 @@ export declare const THEME_TOKENS: {
|
|
|
99
103
|
};
|
|
100
104
|
readonly fail: {
|
|
101
105
|
readonly dark: "#FF5C52";
|
|
102
|
-
readonly light: "#
|
|
106
|
+
readonly light: "#C42E28";
|
|
103
107
|
};
|
|
104
108
|
readonly warn: {
|
|
105
109
|
readonly dark: "#F2C14B";
|
|
@@ -289,7 +293,7 @@ export declare const THEME_FONTS: {
|
|
|
289
293
|
};
|
|
290
294
|
/** The tokens a theme may override: no avatar colors, no color-mix values (they derive). */
|
|
291
295
|
export declare const THEME_OVERRIDABLE: {
|
|
292
|
-
readonly color: readonly ["bg", "panel", "panel-2", "sidebar", "sidebar-active", "raised", "selected", "hover", "line-soft", "line", "line-strong", "line-card", "scroll-thumb", "ink", "muted", "faint", "disabled", "accent", "accent-hover", "accent-press", "on-accent", "focus-ring", "ok", "fail", "warn", "scrim", "lightbox", "float-ground", "float-line", "diff-add", "diff-del"];
|
|
296
|
+
readonly color: readonly ["bg", "panel", "panel-2", "sidebar", "sidebar-active", "raised", "field", "selected", "hover", "line-soft", "line", "line-strong", "line-card", "scroll-thumb", "ink", "muted", "faint", "disabled", "accent", "accent-hover", "accent-press", "on-accent", "focus-ring", "ok", "fail", "warn", "scrim", "lightbox", "float-ground", "float-line", "diff-add", "diff-del"];
|
|
293
297
|
readonly shadow: readonly ["shadow-1", "shadow-2", "shadow-sheet", "shadow-float", "shadow-float-touch"];
|
|
294
298
|
readonly radius: readonly ["sm", "md", "bubble"];
|
|
295
299
|
};
|
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
export const THEME_TOKENS = {
|
|
5
5
|
color: {
|
|
6
6
|
"bg": { dark: "#0A0A0A", light: "#FDFDFC" },
|
|
7
|
-
"panel": { dark: "#111110", light: "#
|
|
8
|
-
"panel-2": { dark: "#0E0E0D", light: "#
|
|
7
|
+
"panel": { dark: "#111110", light: "#F9F8F5" },
|
|
8
|
+
"panel-2": { dark: "#0E0E0D", light: "#FBFAF8" },
|
|
9
9
|
"sidebar": { dark: "#171716", light: "#EDECE7" },
|
|
10
10
|
"sidebar-active": { dark: "rgba(255,255,255,0.07)", light: "rgba(26,26,24,0.09)" },
|
|
11
11
|
"raised": { dark: "#141413", light: "#FFFFFF" },
|
|
12
|
+
"field": { dark: "rgba(0,0,0,0)", light: "#FFFFFF" },
|
|
12
13
|
"selected": { dark: "#21211F", light: "rgba(26,26,24,0.07)" },
|
|
13
14
|
"hover": { dark: "rgba(255,255,255,0.04)", light: "rgba(26,26,24,0.045)" },
|
|
14
15
|
"line-soft": { dark: "#1C1C1A", light: "#E8E7E2" },
|
|
@@ -27,7 +28,7 @@ export const THEME_TOKENS = {
|
|
|
27
28
|
"accent-tint": { dark: "color-mix(in srgb, var(--cb-accent) 12%, transparent)", light: "color-mix(in srgb, var(--cb-accent) 12%, transparent)" },
|
|
28
29
|
"focus-ring": { dark: "rgba(255,106,19,.25)", light: "rgba(204,70,9,.18)" },
|
|
29
30
|
"ok": { dark: "#3FD483", light: "#16803F" },
|
|
30
|
-
"fail": { dark: "#FF5C52", light: "#
|
|
31
|
+
"fail": { dark: "#FF5C52", light: "#C42E28" },
|
|
31
32
|
"warn": { dark: "#F2C14B", light: "#8F6500" },
|
|
32
33
|
"scrim": { dark: "rgba(0,0,0,.60)", light: "rgba(10,10,10,.25)" },
|
|
33
34
|
"preview-light": { dark: "#FAF9F6", light: "#FAF9F6" },
|
|
@@ -90,6 +91,7 @@ export const THEME_OVERRIDABLE = {
|
|
|
90
91
|
"sidebar",
|
|
91
92
|
"sidebar-active",
|
|
92
93
|
"raised",
|
|
94
|
+
"field",
|
|
93
95
|
"selected",
|
|
94
96
|
"hover",
|
|
95
97
|
"line-soft",
|
|
@@ -140,6 +142,13 @@ export const THEME_CONTRAST = [
|
|
|
140
142
|
["ink", "hover", 4.5, "panel"],
|
|
141
143
|
["ink", "selected", 4.5, "panel"],
|
|
142
144
|
["muted", "hover", 4.5, "panel"],
|
|
145
|
+
["ink", "field", 4.5, "panel"],
|
|
146
|
+
["muted", "field", 4.5, "panel"],
|
|
147
|
+
["disabled", "field", 3, "panel"],
|
|
148
|
+
["ink", "hover", 4.5, "raised"],
|
|
149
|
+
["ink", "selected", 4.5, "raised"],
|
|
150
|
+
["fail", "raised", 4.5],
|
|
151
|
+
["disabled", "raised", 3],
|
|
143
152
|
["fail", "selected", 4.5, "panel"],
|
|
144
153
|
["accent", "selected", 3, "panel"],
|
|
145
154
|
["disabled", "bg", 3],
|
|
@@ -181,4 +190,6 @@ export const THEME_SEPARATION = [
|
|
|
181
190
|
["selected", "panel", 2.5],
|
|
182
191
|
["selected", "sidebar", 2.5],
|
|
183
192
|
["sidebar-active", "sidebar", 2.5],
|
|
193
|
+
["hover", "raised", 2.5],
|
|
194
|
+
["selected", "raised", 2.5],
|
|
184
195
|
];
|
package/dist/theme.d.ts
CHANGED
|
@@ -168,6 +168,14 @@ export declare function isThemeFontFamily(v: unknown): v is string;
|
|
|
168
168
|
* every segment of `[A-Za-z0-9._-]`, no `.` / `..` segments (the extension is not checked).
|
|
169
169
|
*/
|
|
170
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>;
|
|
171
179
|
/**
|
|
172
180
|
* Each scheme the theme defines, merged onto the current built-in values (for swatches, the
|
|
173
181
|
* readability check and anything else that needs full values). A stored theme is read leniently:
|
package/dist/theme.js
CHANGED
|
@@ -289,6 +289,16 @@ export function isThemeFontFamily(v) {
|
|
|
289
289
|
export function isThemeAssetPath(v) {
|
|
290
290
|
return typeof v === "string" && v.length <= 512 && isPlainAssetPath(v);
|
|
291
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
|
+
}
|
|
292
302
|
/**
|
|
293
303
|
* Each scheme the theme defines, merged onto the current built-in values (for swatches, the
|
|
294
304
|
* readability check and anything else that needs full values). A stored theme is read leniently:
|
|
@@ -305,6 +315,7 @@ export function mergeThemeSchemes(theme) {
|
|
|
305
315
|
if (over === null || typeof over !== "object")
|
|
306
316
|
continue;
|
|
307
317
|
const m = builtIn(scheme);
|
|
318
|
+
const colors = new Set();
|
|
308
319
|
for (const group of ["color", "shadow"]) {
|
|
309
320
|
const values = over[group];
|
|
310
321
|
if (values === null || typeof values !== "object")
|
|
@@ -313,10 +324,14 @@ export function mergeThemeSchemes(theme) {
|
|
|
313
324
|
if (!OVERRIDABLE[group].has(name))
|
|
314
325
|
continue;
|
|
315
326
|
const v = canonicalThemeValue(group, raw);
|
|
316
|
-
if (v
|
|
317
|
-
|
|
327
|
+
if (v === undefined)
|
|
328
|
+
continue;
|
|
329
|
+
m[group][name] = v;
|
|
330
|
+
if (group === "color")
|
|
331
|
+
colors.add(name);
|
|
318
332
|
}
|
|
319
333
|
}
|
|
334
|
+
Object.assign(m.color, themeSchemeFallbacks(colors));
|
|
320
335
|
const radii = over.radius;
|
|
321
336
|
if (radii !== null && typeof radii === "object") {
|
|
322
337
|
for (const key of ["sm", "md", "bubble"]) {
|