sideby 0.22.0 → 0.23.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/ai-tasks.json +14 -0
- package/dist/build.json +1 -1
- package/dist/src/cli/commands.d.ts +7 -0
- package/dist/src/cli/commands.js +326 -21
- package/dist/src/cli/json-schemas.js +76 -1
- package/dist/src/cli/main.js +32 -4
- package/dist/src/core/ask.js +6 -1
- package/dist/src/core/config.d.ts +5 -1
- package/dist/src/core/config.js +18 -3
- package/dist/src/core/quota-levels.d.ts +7 -2
- package/dist/src/core/quota-levels.js +13 -3
- package/dist/src/core/themes.d.ts +107 -0
- package/dist/src/core/themes.js +463 -0
- package/dist/src/menubar/snapshot.d.ts +10 -0
- package/dist/src/menubar/snapshot.js +14 -6
- package/dist/src/menubar/strings.d.ts +6 -0
- package/dist/src/menubar/strings.js +6 -0
- package/dist/src/panel/handler.d.ts +2 -0
- package/dist/src/panel/handler.js +125 -1
- package/dist/src/panel/i18n.d.ts +49 -0
- package/dist/src/panel/i18n.js +104 -6
- package/dist/src/panel/page-logic.d.ts +20 -1
- package/dist/src/panel/page-logic.js +41 -0
- package/dist/src/panel/page-script.js +264 -35
- package/dist/src/panel/page-styles.d.ts +2 -0
- package/dist/src/panel/page-styles.js +57 -31
- package/dist/src/panel/theme.d.ts +6 -1
- package/dist/src/panel/theme.js +4 -0
- package/dist/src/panel/themes.d.ts +14 -0
- package/dist/src/panel/themes.js +162 -0
- package/dist/src/runtime.d.ts +4 -0
- package/package.json +1 -1
- package/schemas/config.json +29 -1
- package/schemas/families.json +5 -0
- package/schemas/hide.json +157 -0
- package/schemas/list.json +10 -0
- package/schemas/order.json +26 -1
- package/schemas/pin.json +17 -0
- package/schemas/theme-check.json +140 -0
- package/schemas/theme-export.json +86 -0
- package/schemas/theme-import.json +92 -0
- package/schemas/theme-preview.json +86 -0
- package/schemas/theme-remove.json +87 -0
- package/schemas/theme-use.json +88 -0
- package/schemas/theme.json +137 -0
- package/schemas/unhide.json +157 -0
- package/schemas/unpin.json +17 -0
- package/skills/sideby/SKILL.md +3 -1
- package/skills/sideby/references/ai-tasks.md +1 -1
- package/skills/sideby/references/panel.md +9 -0
- package/skills/sideby/references/quota.md +1 -1
- package/skills/sideby/references/themes.md +47 -0
package/dist/src/cli/main.js
CHANGED
|
@@ -12,6 +12,7 @@ Usage:
|
|
|
12
12
|
sideby key <account> [--var <NAME>] enter an API key without echo
|
|
13
13
|
sideby try <account> [--yes] try the Host with a short paid request
|
|
14
14
|
sideby list accounts (same as \`sideby list\`)
|
|
15
|
+
sideby list --all also list hidden families and accounts
|
|
15
16
|
sideby run <account> [-- args] start the host CLI for one account
|
|
16
17
|
sideby new <family> <name>|--next [--api] [--alias <short>]
|
|
17
18
|
create an account (families: claude, codex, grok, pi);
|
|
@@ -19,10 +20,12 @@ Usage:
|
|
|
19
20
|
--alias also adds a short command such as cc008
|
|
20
21
|
sideby pin|unpin <account|short command> [--json]
|
|
21
22
|
pin or unpin a Same Login (at most 3 per family)
|
|
22
|
-
sideby
|
|
23
|
+
sideby hide|unhide <family|account> [--json]
|
|
24
|
+
hide a family or an account from the Panel, menu bar and list
|
|
25
|
+
sideby order [--json] show display order, with pinned and hidden accounts marked
|
|
23
26
|
sideby order <family> <name>... set account order within a family
|
|
24
27
|
sideby order --families <id>... set family order
|
|
25
|
-
sideby order --reset restore default order, keeping pins
|
|
28
|
+
sideby order --reset restore default order, keeping pins and hidden ones
|
|
26
29
|
sideby quota check <family> on|off turn quota fetching on or off
|
|
27
30
|
sideby update --auto on|off set Auto Update without running an update
|
|
28
31
|
sideby update --skill [--yes] update only the installed sideby skill to this version
|
|
@@ -115,6 +118,9 @@ Usage:
|
|
|
115
118
|
file first)
|
|
116
119
|
sideby menubar [on|off] [--yes] show quota in the macOS menu bar; click an account to start it
|
|
117
120
|
sideby menubar hotkey [<keys>|off] show or change the shortcut that opens that menu (⌥X)
|
|
121
|
+
sideby theme [list] the Panel's Themes; use <name> switches, use --undo goes back, use default clears
|
|
122
|
+
sideby theme check|preview <name|file> contrast report, or one look in the Panel without switching
|
|
123
|
+
sideby theme import <file> | export <name> | remove <name> your own Themes (JSON, colors only)
|
|
118
124
|
sideby config get [<key>] every setting with its value and meaning, or one setting
|
|
119
125
|
sideby config set <key> <value> [--yes]
|
|
120
126
|
change any setting (sideby config set panel.theme dark)
|
|
@@ -144,7 +150,7 @@ Updates: once a day sideby asks the npm registry for its newest version and says
|
|
|
144
150
|
Turn it off with NO_UPDATE_NOTIFIER=1 or config "update": { "check": false }; "auto": true installs by itself.`;
|
|
145
151
|
/** `sideby <command> --help` for the commands agents use to set up and repair accounts (spec §3.16). */
|
|
146
152
|
const COMMAND_HELP = {
|
|
147
|
-
ask: 'sideby ask [<text>] [--task free|fix|quota|account|host|plugin|terminal|handoff|menubar|hotkey] [--account <ref>] [--terminal <id>] [--attach <file>]... [--print] [--json]\nsideby ask --run <id> [--state-dir <dir>]\nsideby ask --spec - [--print] --json\nsideby ask --choices --json\nOpen a task in your terminal. --spec reads a Task Spec (one JSON object, at most 1 MB) from stdin, as a Portal sends it; --choices lists the accounts and terminals a task can use. --attach adds an image (PNG, JPEG, GIF, WebP; up to 20 MB) or a video (MP4, MOV, WebM; up to 200 MB), at most 5. --print prints only the prompt. If opening fails, paste the command into a terminal.',
|
|
153
|
+
ask: 'sideby ask [<text>] [--task free|fix|quota|account|host|plugin|terminal|handoff|theme|menubar|hotkey] [--account <ref>] [--terminal <id>] [--attach <file>]... [--print] [--json]\nsideby ask --run <id> [--state-dir <dir>]\nsideby ask --spec - [--print] --json\nsideby ask --choices --json\nOpen a task in your terminal. --spec reads a Task Spec (one JSON object, at most 1 MB) from stdin, as a Portal sends it; --choices lists the accounts and terminals a task can use. --attach adds an image (PNG, JPEG, GIF, WebP; up to 20 MB) or a video (MP4, MOV, WebM; up to 200 MB), at most 5. --print prints only the prompt. If opening fails, paste the command into a terminal.',
|
|
148
154
|
terminal: "sideby terminal [--set <id>|--custom '<program> … {cwd} … {cmd}'|--unset] [--json]\nList terminals or save your preference; --custom saves and selects your own launch command.",
|
|
149
155
|
key: 'sideby key <account> [--var <NAME>] [--json]\nEnter an API key without echo. Run in a terminal or use the Panel key box.',
|
|
150
156
|
try: 'sideby try <account> [--yes] [--json]\nSend a short request through the Host. This spends a few tokens. Exit 10 waits for --yes.',
|
|
@@ -393,6 +399,20 @@ Examples:
|
|
|
393
399
|
Exit: 0 shown, done or nothing to change; 10 a change was shown and waits for --yes; 1 refused (not macOS, sideby
|
|
394
400
|
in the npx cache or a temporary folder, a file that is not sideby's), failed, or the terminal did not open; 2
|
|
395
401
|
malformed command line.`,
|
|
402
|
+
theme: `sideby theme [list] [--json]
|
|
403
|
+
sideby theme use <name> [--json] | sideby theme use --undo | sideby theme use default
|
|
404
|
+
sideby theme check <name|file> [--json]
|
|
405
|
+
sideby theme preview <name|file>
|
|
406
|
+
sideby theme import <file> [--id <name>] [--yes] [--json]
|
|
407
|
+
sideby theme export <name> [--out <file>] [--json]
|
|
408
|
+
sideby theme remove <name> [--yes] [--json]
|
|
409
|
+
|
|
410
|
+
The Panel's colors. Built-in Themes: sky (default) and leaf. A Theme File is JSON in <config>/themes/<name>.json:
|
|
411
|
+
{"schemaVersion": 1, "name": "My blue", "base": "sky", "accent": "#2f7fbf", "light": {...}, "dark": {...}}
|
|
412
|
+
base and accent are optional; light and dark take the same tokens as a Portal Theme. Files hold colors only, never code.
|
|
413
|
+
check reports text and control contrast in light and dark with a value that would pass (exit 1 when any fails); the
|
|
414
|
+
Panel moves failing colors itself. preview shows a Theme once in the running Panel without switching. Exit 10: import
|
|
415
|
+
over an existing name or remove waits for --yes.`,
|
|
396
416
|
config: `sideby config get [<key>] [--json]
|
|
397
417
|
sideby config set <key> <value> [--yes] [--json]
|
|
398
418
|
sideby config unset <key> [--yes] [--json]
|
|
@@ -476,8 +496,11 @@ const COMMANDS = {
|
|
|
476
496
|
autostart: { flags: ['json', 'yes', 'refresh'] },
|
|
477
497
|
menubar: { flags: ['json', 'yes', 'refresh'], valued: ['lang', 'hotkey', 'hotkey-label', 'icon'] },
|
|
478
498
|
config: { flags: ['json', 'yes'] },
|
|
479
|
-
|
|
499
|
+
theme: { flags: ['json', 'yes', 'undo'], valued: ['id', 'out'] },
|
|
500
|
+
list: { flags: ['json', 'all'] },
|
|
480
501
|
pin: { flags: ['json'] },
|
|
502
|
+
hide: { flags: ['json'] },
|
|
503
|
+
unhide: { flags: ['json'] },
|
|
481
504
|
unpin: { flags: ['json'] },
|
|
482
505
|
order: { flags: ['json', 'families', 'reset'] },
|
|
483
506
|
run: { flags: [] },
|
|
@@ -723,6 +746,9 @@ async function dispatch(cmd, parsed, io, cmds) {
|
|
|
723
746
|
case 'pin':
|
|
724
747
|
case 'unpin':
|
|
725
748
|
return await cmds.cmdPin(parsed, io, cmd === 'pin');
|
|
749
|
+
case 'hide':
|
|
750
|
+
case 'unhide':
|
|
751
|
+
return await cmds.cmdHide(parsed, io, cmd === 'hide');
|
|
726
752
|
case 'order':
|
|
727
753
|
return await cmds.cmdOrder(parsed, io);
|
|
728
754
|
case 'list':
|
|
@@ -787,6 +813,8 @@ async function dispatch(cmd, parsed, io, cmds) {
|
|
|
787
813
|
return await cmds.cmdMenubar(parsed, io);
|
|
788
814
|
case 'config':
|
|
789
815
|
return await cmds.cmdConfig(parsed, io);
|
|
816
|
+
case 'theme':
|
|
817
|
+
return await cmds.cmdTheme(parsed, io);
|
|
790
818
|
}
|
|
791
819
|
return 2;
|
|
792
820
|
}
|
package/dist/src/core/ask.js
CHANGED
|
@@ -260,7 +260,12 @@ export function taskContext(c, fail) {
|
|
|
260
260
|
return v;
|
|
261
261
|
};
|
|
262
262
|
for (const [k, v] of Object.entries(c)) {
|
|
263
|
-
if (k === 'account' ||
|
|
263
|
+
if (k === 'account' ||
|
|
264
|
+
k === 'family' ||
|
|
265
|
+
k === 'quotaReason' ||
|
|
266
|
+
k === 'version' ||
|
|
267
|
+
k === 'terminalCustom' ||
|
|
268
|
+
k === 'theme')
|
|
264
269
|
out[k] = str(v, `"context.${k}"`);
|
|
265
270
|
else if (k === 'terminals') {
|
|
266
271
|
if (!Array.isArray(v) || v.length > 50)
|
|
@@ -43,6 +43,7 @@ export declare const ConfigSchema: Type.TObject<{
|
|
|
43
43
|
panel: Type.TOptional<Type.TObject<{
|
|
44
44
|
theme: Type.TOptional<Type.TString>;
|
|
45
45
|
language: Type.TOptional<Type.TString>;
|
|
46
|
+
colorTheme: Type.TOptional<Type.TString>;
|
|
46
47
|
}>>;
|
|
47
48
|
menubar: Type.TOptional<Type.TObject<{
|
|
48
49
|
hotkey: Type.TOptional<Type.TString>;
|
|
@@ -106,6 +107,8 @@ export declare const ConfigSchema: Type.TObject<{
|
|
|
106
107
|
families: Type.TOptional<Type.TArray<Type.TString>>;
|
|
107
108
|
accounts: Type.TOptional<Type.TRecord<"^.*$", Type.TArray<Type.TString>>>;
|
|
108
109
|
pinned: Type.TOptional<Type.TRecord<"^.*$", Type.TArray<Type.TString>>>;
|
|
110
|
+
hiddenFamilies: Type.TOptional<Type.TArray<Type.TString>>;
|
|
111
|
+
hidden: Type.TOptional<Type.TRecord<"^.*$", Type.TArray<Type.TString>>>;
|
|
109
112
|
}>>;
|
|
110
113
|
quota: Type.TOptional<Type.TObject<{
|
|
111
114
|
check: Type.TOptional<Type.TRecord<"^.*$", Type.TBoolean>>;
|
|
@@ -243,12 +246,13 @@ export declare function editConfigAsk(file: string, account?: string): Promise<{
|
|
|
243
246
|
}>;
|
|
244
247
|
export type PanelConfig = NonNullable<Config['panel']>;
|
|
245
248
|
/**
|
|
246
|
-
* The Panel's
|
|
249
|
+
* The Panel's light/dark, language and Theme (spec §3.29, §3.34): a value sets the key, null removes it (back to the default), and an
|
|
247
250
|
* empty `panel` goes away with it (see `editConfigKey` for how the file is written).
|
|
248
251
|
*/
|
|
249
252
|
export declare function editConfigPanel(file: string, patch: {
|
|
250
253
|
theme?: PanelConfig['theme'] | null;
|
|
251
254
|
language?: PanelConfig['language'] | null;
|
|
255
|
+
colorTheme?: PanelConfig['colorTheme'] | null;
|
|
252
256
|
}, opts?: {
|
|
253
257
|
dryRun?: boolean;
|
|
254
258
|
}): Promise<{
|
package/dist/src/core/config.js
CHANGED
|
@@ -122,6 +122,10 @@ export const ConfigSchema = Type.Object({
|
|
|
122
122
|
enum: ['auto', 'en', 'zh'],
|
|
123
123
|
description: "Panel language: the browser's (default), English, or Chinese.",
|
|
124
124
|
})),
|
|
125
|
+
colorTheme: Type.Optional(Type.String({
|
|
126
|
+
pattern: '^[a-z0-9][a-z0-9-]{0,39}$',
|
|
127
|
+
description: 'Panel Theme: a Built-in Theme (sky, the default, or leaf) or a Theme File in <config>/themes (spec §3.34).',
|
|
128
|
+
})),
|
|
125
129
|
}, { additionalProperties: false, description: 'How the Panel looks (spec §3.29).' })),
|
|
126
130
|
menubar: Type.Optional(Type.Object({
|
|
127
131
|
hotkey: Type.Optional(Type.String({
|
|
@@ -214,9 +218,16 @@ export const ConfigSchema = Type.Object({
|
|
|
214
218
|
pinned: Type.Optional(Type.Record(Type.String(), Type.Array(Type.String({ minLength: 1 }), { uniqueItems: true }), {
|
|
215
219
|
description: 'Per family, the names of the accounts pinned to the top of their group, in the order they are shown; they lead the group in every sort. Resetting the order keeps them.',
|
|
216
220
|
})),
|
|
221
|
+
hiddenFamilies: Type.Optional(Type.Array(Type.String({ minLength: 1 }), {
|
|
222
|
+
uniqueItems: true,
|
|
223
|
+
description: 'Family ids hidden from the Panel, the menu bar and `sideby list` (spec §3.25). Display only: they can still be started and picked by a Handoff.',
|
|
224
|
+
})),
|
|
225
|
+
hidden: Type.Optional(Type.Record(Type.String(), Type.Array(Type.String({ minLength: 1 }), { uniqueItems: true }), {
|
|
226
|
+
description: 'Per family, the names of the accounts hidden from the Panel, the menu bar and `sideby list`. Display only: they can still be started and picked by a Handoff.',
|
|
227
|
+
})),
|
|
217
228
|
}, {
|
|
218
229
|
additionalProperties: false,
|
|
219
|
-
description: 'Display Order (spec §3.25): the order you gave families and accounts in the Panel,
|
|
230
|
+
description: 'Display Order (spec §3.25): the order you gave families and accounts in the Panel, the accounts you pinned, and what you hid. Display only: it never changes which account a Handoff picks.',
|
|
220
231
|
})),
|
|
221
232
|
quota: Type.Optional(Type.Object({
|
|
222
233
|
check: Type.Optional(Type.Record(Type.String(), Type.Boolean(), {
|
|
@@ -409,10 +420,13 @@ export function editConfigDisplay(file, display) {
|
|
|
409
420
|
const lists = (r) => Object.fromEntries(Object.entries(r ?? {}).filter(([, names]) => names.length));
|
|
410
421
|
const accounts = lists(display?.accounts);
|
|
411
422
|
const pinned = lists(display?.pinned);
|
|
423
|
+
const hidden = lists(display?.hidden);
|
|
412
424
|
const next = {
|
|
413
425
|
...(display?.families?.length ? { families: [...display.families] } : {}),
|
|
414
426
|
...(Object.keys(accounts).length ? { accounts } : {}),
|
|
415
427
|
...(Object.keys(pinned).length ? { pinned } : {}),
|
|
428
|
+
...(display?.hiddenFamilies?.length ? { hiddenFamilies: [...display.hiddenFamilies] } : {}),
|
|
429
|
+
...(Object.keys(hidden).length ? { hidden } : {}),
|
|
416
430
|
};
|
|
417
431
|
return editConfigKey(file, 'display', 'move it again', () => (Object.keys(next).length ? next : undefined));
|
|
418
432
|
}
|
|
@@ -519,13 +533,13 @@ export function editConfigAsk(file, account) {
|
|
|
519
533
|
return editConfigKey(file, 'ask', 'run `sideby ask`', () => (account ? { account } : undefined));
|
|
520
534
|
}
|
|
521
535
|
/**
|
|
522
|
-
* The Panel's
|
|
536
|
+
* The Panel's light/dark, language and Theme (spec §3.29, §3.34): a value sets the key, null removes it (back to the default), and an
|
|
523
537
|
* empty `panel` goes away with it (see `editConfigKey` for how the file is written).
|
|
524
538
|
*/
|
|
525
539
|
export function editConfigPanel(file, patch, opts = {}) {
|
|
526
540
|
return editConfigKey(file, 'panel', 'change the setting', (current) => {
|
|
527
541
|
const next = { ...current };
|
|
528
|
-
for (const k of ['theme', 'language'])
|
|
542
|
+
for (const k of ['theme', 'language', 'colorTheme'])
|
|
529
543
|
if (patch[k] === null)
|
|
530
544
|
delete next[k];
|
|
531
545
|
else if (patch[k] !== undefined)
|
|
@@ -543,6 +557,7 @@ const PLACEHOLDERS = {
|
|
|
543
557
|
'handoff.families': '<family>',
|
|
544
558
|
'display.accounts': '<family>',
|
|
545
559
|
'display.pinned': '<family>',
|
|
560
|
+
'display.hidden': '<family>',
|
|
546
561
|
'quota.check': '<family>',
|
|
547
562
|
};
|
|
548
563
|
const BAD_SEGMENT = new Set(['__proto__', 'constructor', 'prototype']);
|
|
@@ -14,11 +14,16 @@ export declare function takeoverLimit(threshold: number): number;
|
|
|
14
14
|
/** Days of Usage every Family reports. */
|
|
15
15
|
export declare const USAGE_DAYS = 7;
|
|
16
16
|
export type QuotaLevel = 'ok' | 'warn' | 'fail';
|
|
17
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* Shared by the Panel and menu bar. Self-contained so the Panel can inline it without other module state.
|
|
19
|
+
* A reading over an hour old is still current when `lastUseAt`, the newest use of its login on this computer, came at
|
|
20
|
+
* most 10 minutes after it (a session's last records land after its last status line): nothing here has used the
|
|
21
|
+
* Quota since (spec §3.31). Use on the web or another computer cannot be seen; the hover text says so.
|
|
22
|
+
*/
|
|
18
23
|
export declare function quotaIsStale(quota: {
|
|
19
24
|
observedAt: string;
|
|
20
25
|
fetchError?: string;
|
|
21
|
-
}, now: number): boolean;
|
|
26
|
+
}, now: number, lastUseAt?: string | null): boolean;
|
|
22
27
|
export declare function quotaLevel(usedPercent: number): QuotaLevel;
|
|
23
28
|
/** True once a window's reset time has passed; an unreadable time never counts as reset. */
|
|
24
29
|
export declare function windowReset(resetsAt: string, now: Date): boolean;
|
|
@@ -14,10 +14,20 @@ export function takeoverLimit(threshold) {
|
|
|
14
14
|
}
|
|
15
15
|
/** Days of Usage every Family reports. */
|
|
16
16
|
export const USAGE_DAYS = 7;
|
|
17
|
-
/**
|
|
18
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Shared by the Panel and menu bar. Self-contained so the Panel can inline it without other module state.
|
|
19
|
+
* A reading over an hour old is still current when `lastUseAt`, the newest use of its login on this computer, came at
|
|
20
|
+
* most 10 minutes after it (a session's last records land after its last status line): nothing here has used the
|
|
21
|
+
* Quota since (spec §3.31). Use on the web or another computer cannot be seen; the hover text says so.
|
|
22
|
+
*/
|
|
23
|
+
export function quotaIsStale(quota, now, lastUseAt) {
|
|
19
24
|
const at = Date.parse(quota.observedAt);
|
|
20
|
-
|
|
25
|
+
if (quota.fetchError || !Number.isFinite(at) || at - now > 60_000)
|
|
26
|
+
return true;
|
|
27
|
+
if (now - at <= 3600_000)
|
|
28
|
+
return false;
|
|
29
|
+
const used = lastUseAt ? Date.parse(lastUseAt) : Number.NaN;
|
|
30
|
+
return !(Number.isFinite(used) && used - at <= 600_000);
|
|
21
31
|
}
|
|
22
32
|
export function quotaLevel(usedPercent) {
|
|
23
33
|
if (usedPercent >= QUOTA_FAIL_PERCENT)
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { type PanelThemeTokens } from '../panel/theme.ts';
|
|
2
|
+
import type { Paths } from './paths.ts';
|
|
3
|
+
export declare const THEME_ID_RE: RegExp;
|
|
4
|
+
export interface ThemeFile {
|
|
5
|
+
schemaVersion: 1;
|
|
6
|
+
name: string;
|
|
7
|
+
base?: string;
|
|
8
|
+
accent?: string;
|
|
9
|
+
light?: PanelThemeTokens;
|
|
10
|
+
dark?: PanelThemeTokens;
|
|
11
|
+
}
|
|
12
|
+
export interface ThemeEntry {
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
source: 'builtin' | 'file';
|
|
16
|
+
path?: string;
|
|
17
|
+
/** Page, card, accent tint, main button, dark page; for the Theme's card in Settings. */
|
|
18
|
+
swatches: string[];
|
|
19
|
+
/** Why this Theme cannot be used; empty when it can. */
|
|
20
|
+
problems: string[];
|
|
21
|
+
/** Keys that were ignored. */
|
|
22
|
+
warnings: string[];
|
|
23
|
+
}
|
|
24
|
+
export interface ResolvedColors {
|
|
25
|
+
id: string;
|
|
26
|
+
light: PanelThemeTokens;
|
|
27
|
+
dark: PanelThemeTokens;
|
|
28
|
+
/** How many colors were moved to pass the contrast check. */
|
|
29
|
+
adjusted: number;
|
|
30
|
+
/** Set when the chosen Theme could not be used and Sky stands in. */
|
|
31
|
+
fallback?: string;
|
|
32
|
+
}
|
|
33
|
+
export declare const themesDir: (paths: Paths) => string;
|
|
34
|
+
/**
|
|
35
|
+
* The name `sideby theme use` takes for "no Theme chosen": the Panel then shows the Default Theme on its own and,
|
|
36
|
+
* inside a Portal, the Portal's colors. It names no Theme File.
|
|
37
|
+
*/
|
|
38
|
+
export declare const NO_THEME = "default";
|
|
39
|
+
/** Checks parsed JSON as a Theme File. Problems make it unusable; warnings are keys that were ignored. */
|
|
40
|
+
export declare function checkThemeData(data: unknown): {
|
|
41
|
+
theme?: ThemeFile;
|
|
42
|
+
problems: string[];
|
|
43
|
+
warnings: string[];
|
|
44
|
+
};
|
|
45
|
+
/** Reads one Theme File: a regular file of at most 64 KB, never followed through a link. */
|
|
46
|
+
export declare function readThemeFile(path: string): Promise<{
|
|
47
|
+
theme?: ThemeFile;
|
|
48
|
+
problems: string[];
|
|
49
|
+
warnings: string[];
|
|
50
|
+
}>;
|
|
51
|
+
export declare function listThemes(paths: Paths): Promise<ThemeEntry[]>;
|
|
52
|
+
/** A Theme File's colors before the contrast check: base, then accent roles, then the file's own tokens. */
|
|
53
|
+
export declare function themeColors(theme: ThemeFile): {
|
|
54
|
+
light: PanelThemeTokens;
|
|
55
|
+
dark: PanelThemeTokens;
|
|
56
|
+
};
|
|
57
|
+
/** The colors for a Theme id (Built-in or file), with failing pairs moved until they pass. Unknown or broken: Sky. */
|
|
58
|
+
export declare function resolveColors(paths: Paths, id: string | undefined): Promise<ResolvedColors>;
|
|
59
|
+
/** A 12-step scale around one color: step 9 is the color, the others follow the template's lightness. */
|
|
60
|
+
export declare function accentScale(hex: string, dark: boolean): string[];
|
|
61
|
+
/** The accent roles of a Theme generated from one color; neutrals and warning colors stay the base Theme's. */
|
|
62
|
+
export declare function accentTokens(hex: string): {
|
|
63
|
+
light: PanelThemeTokens;
|
|
64
|
+
dark: PanelThemeTokens;
|
|
65
|
+
};
|
|
66
|
+
export interface ContrastPair {
|
|
67
|
+
mode: 'light' | 'dark';
|
|
68
|
+
fg: keyof PanelThemeTokens;
|
|
69
|
+
bg: keyof PanelThemeTokens;
|
|
70
|
+
ratio?: number;
|
|
71
|
+
min: number;
|
|
72
|
+
ok: boolean;
|
|
73
|
+
/** A value for `fg` that passes; only when it fails. */
|
|
74
|
+
suggest?: string;
|
|
75
|
+
}
|
|
76
|
+
export declare function contrastPairs(c: {
|
|
77
|
+
light: PanelThemeTokens;
|
|
78
|
+
dark: PanelThemeTokens;
|
|
79
|
+
}): ContrastPair[];
|
|
80
|
+
/** Sets `panel.colorTheme`, keeping what it was so `undo` can put it back. */
|
|
81
|
+
export declare function useTheme(paths: Paths, id: string): Promise<{
|
|
82
|
+
before: string;
|
|
83
|
+
after: string;
|
|
84
|
+
changed: boolean;
|
|
85
|
+
}>;
|
|
86
|
+
/** Puts back the Theme from before the last `use`, only while config still holds what that `use` wrote. */
|
|
87
|
+
export declare function undoTheme(paths: Paths): Promise<{
|
|
88
|
+
before: string;
|
|
89
|
+
after: string;
|
|
90
|
+
}>;
|
|
91
|
+
/** Writes a checked Theme File into the themes folder. */
|
|
92
|
+
export declare function saveThemeFile(paths: Paths, id: string, theme: ThemeFile): Promise<string>;
|
|
93
|
+
export declare function removeThemeFile(paths: Paths, id: string): Promise<{
|
|
94
|
+
path: string;
|
|
95
|
+
wasActive: boolean;
|
|
96
|
+
}>;
|
|
97
|
+
/** A full Theme File for an id: a Built-in Theme gets every token, so it can be the start of the user's own. */
|
|
98
|
+
export declare function exportTheme(paths: Paths, id: string): Promise<ThemeFile>;
|
|
99
|
+
/** Keeps a Theme for one look at the Panel without choosing it (`sideby theme preview`). */
|
|
100
|
+
export declare function setPreview(paths: Paths, theme: ThemeFile): Promise<void>;
|
|
101
|
+
/** The previewed Theme's colors, if one was set in the last ten minutes. */
|
|
102
|
+
export declare function previewColors(paths: Paths): Promise<ResolvedColors | undefined>;
|
|
103
|
+
export declare function toOklch(hex: string): [number, number, number];
|
|
104
|
+
/** OKLCH to #rrggbb, lowering chroma until the color fits sRGB. */
|
|
105
|
+
export declare function fromOklch(L: number, C: number, H: number): string;
|
|
106
|
+
/** WCAG 2 contrast ratio of two #rrggbb colors. */
|
|
107
|
+
export declare function contrast(a: string, b: string): number;
|