@cmodjs/core 6.3.0 → 8.0.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/commands.md +123 -65
- package/docs/dependencies.md +189 -4
- package/docs/index.md +56 -12
- package/docs/install-steps.md +20 -17
- package/docs/jobs.md +43 -16
- package/docs/mod.md +43 -27
- package/docs/options.md +2 -2
- package/docs/session.md +58 -32
- package/docs/testing.md +88 -24
- package/docs/ui.md +128 -58
- package/installer.d.ts +2 -2
- package/jobs/context.js +1 -1
- package/jobs/program.d.ts +4 -1
- package/jobs/program.d.ts.map +1 -1
- package/jobs/program.js +79 -20
- package/mod.d.ts +59 -9
- package/mod.d.ts.map +1 -1
- package/mod.js +5 -3
- package/package.json +1 -1
- package/records.d.ts +15 -2
- package/records.d.ts.map +1 -1
- package/records.js +24 -10
- package/register.d.ts.map +1 -1
- package/register.js +7 -4
- package/rpc.d.ts +7 -0
- package/rpc.d.ts.map +1 -0
- package/rpc.js +59 -0
- package/runtime/bound.d.ts +1 -0
- package/runtime/bound.d.ts.map +1 -1
- package/runtime/bound.js +10 -0
- package/runtime/bun.d.ts +20 -0
- package/runtime/bun.d.ts.map +1 -0
- package/runtime/bun.js +20 -0
- package/runtime/claude.d.ts +1 -0
- package/runtime/claude.d.ts.map +1 -1
- package/runtime/conversations.d.ts +12 -1
- package/runtime/conversations.d.ts.map +1 -1
- package/runtime/conversations.js +472 -362
- package/runtime/deadline.d.ts +4 -3
- package/runtime/deadline.d.ts.map +1 -1
- package/runtime/deadline.js +10 -4
- package/runtime/engine.d.ts +5 -4
- package/runtime/engine.d.ts.map +1 -1
- package/runtime/installer.d.ts +3 -3
- package/runtime/installer.d.ts.map +1 -1
- package/runtime/installer.js +10 -9
- package/runtime/interfaces.d.ts +262 -0
- package/runtime/interfaces.d.ts.map +1 -0
- package/runtime/interfaces.js +935 -0
- package/runtime/lifecycle.d.ts +3 -3
- package/runtime/lifecycle.d.ts.map +1 -1
- package/runtime/lifecycle.js +83 -52
- package/runtime/options.d.ts.map +1 -1
- package/runtime/options.js +2 -6
- package/runtime/parts.d.ts +64 -1
- package/runtime/parts.d.ts.map +1 -1
- package/runtime/parts.js +311 -4
- package/runtime/programs.d.ts +1 -0
- package/runtime/programs.d.ts.map +1 -1
- package/runtime/programs.js +5 -3
- package/runtime/rpc.d.ts +111 -0
- package/runtime/rpc.d.ts.map +1 -0
- package/runtime/rpc.js +387 -0
- package/runtime/sessions.d.ts +6 -4
- package/runtime/sessions.d.ts.map +1 -1
- package/runtime/sessions.js +59 -80
- package/runtime/toaster.js +1 -1
- package/runtime/ui.d.ts +23 -10
- package/runtime/ui.d.ts.map +1 -1
- package/runtime/ui.js +63 -52
- package/runtime/web.d.ts +0 -73
- package/runtime/web.d.ts.map +1 -1
- package/runtime/web.js +9 -5
- package/runtime/widgets.d.ts +4 -2
- package/runtime/widgets.d.ts.map +1 -1
- package/runtime/widgets.js +17 -16
- package/session/conversation.d.ts +7 -1
- package/session/conversation.d.ts.map +1 -1
- package/session/session.d.ts +31 -7
- package/session/session.d.ts.map +1 -1
- package/session/session.js +1 -0
- package/src/installer.ts +2 -2
- package/src/jobs/context.ts +1 -1
- package/src/jobs/program.ts +76 -21
- package/src/mod.ts +51 -10
- package/src/records.ts +33 -9
- package/src/register.ts +7 -4
- package/src/rpc.ts +67 -0
- package/src/runtime/bound.ts +10 -0
- package/src/runtime/bun.ts +40 -0
- package/src/runtime/claude.ts +1 -0
- package/src/runtime/conversations.ts +470 -352
- package/src/runtime/deadline.ts +13 -6
- package/src/runtime/engine.ts +5 -4
- package/src/runtime/installer.ts +13 -12
- package/src/runtime/interfaces.ts +1161 -0
- package/src/runtime/lifecycle.ts +102 -59
- package/src/runtime/options.ts +2 -5
- package/src/runtime/parts.ts +364 -5
- package/src/runtime/programs.ts +6 -3
- package/src/runtime/rpc.ts +457 -0
- package/src/runtime/sessions.ts +63 -83
- package/src/runtime/toaster.ts +1 -1
- package/src/runtime/ui.ts +82 -61
- package/src/runtime/web.ts +10 -39
- package/src/runtime/widgets.ts +20 -18
- package/src/session/conversation.ts +7 -1
- package/src/session/session.ts +22 -7
- package/src/testing/fake-claude.ts +38 -7
- package/src/testing/fake-serve.ts +144 -0
- package/src/testing/fake-sessions.ts +21 -6
- package/src/testing.ts +156 -68
- package/src/ui/areas.ts +2 -2
- package/src/ui/elements.ts +21 -16
- package/src/ui/panes.ts +14 -7
- package/testing/fake-claude.d.ts +6 -0
- package/testing/fake-claude.d.ts.map +1 -1
- package/testing/fake-claude.js +34 -7
- package/testing/fake-serve.d.ts +39 -0
- package/testing/fake-serve.d.ts.map +1 -0
- package/testing/fake-serve.js +110 -0
- package/testing/fake-sessions.d.ts.map +1 -1
- package/testing/fake-sessions.js +22 -6
- package/testing.d.ts +21 -4
- package/testing.d.ts.map +1 -1
- package/testing.js +138 -56
- package/ui/areas.d.ts +3 -1
- package/ui/areas.d.ts.map +1 -1
- package/ui/elements.d.ts +18 -9
- package/ui/elements.d.ts.map +1 -1
- package/ui/elements.js +9 -8
- package/ui/panes.d.ts +10 -6
- package/ui/panes.d.ts.map +1 -1
- package/ui/panes.js +5 -3
- package/runtime/pages.d.ts +0 -32
- package/runtime/pages.d.ts.map +0 -1
- package/runtime/pages.js +0 -142
- package/src/runtime/pages.ts +0 -183
package/ui/panes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"panes.d.ts","sourceRoot":"","sources":["../src/ui/panes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AACvF,OAAO,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAE7C,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,aAAa,CAAC,CAAA;AAE9C,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC,CAAA;AAE9C,MAAM,MAAM,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AAA;AAEpD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAIlH;AAED,wBAAgB,SAAS,CAAC,KAAK,SAAS,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAMtI"}
|
package/ui/panes.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
const partId = /^[A-Za-z0-9_-]{1,64}$/;
|
|
2
2
|
export const sizeKeys = ['columns', 'rows'];
|
|
3
|
-
export function checkPart(name, kind, id, title) {
|
|
3
|
+
export function checkPart(name, kind, id, title, takenBy) {
|
|
4
4
|
if (!partId.test(id))
|
|
5
5
|
throw new Error(`${name}: "${id}" is not a ${kind} id. Use 1 to 64 letters, digits, "_", or "-".`);
|
|
6
6
|
if (title.trim() === '')
|
|
7
7
|
throw new Error(`${name}: the ${kind} "${id}" needs a title, the label its tab shows.`);
|
|
8
|
+
if (takenBy !== undefined)
|
|
9
|
+
throw new Error(`${name}: the ${takenBy} "${id}" is already added. Give the ${kind} another id.`);
|
|
8
10
|
}
|
|
9
|
-
export function checkPane(name, pane) {
|
|
10
|
-
checkPart(name, 'pane', pane.id, pane.title);
|
|
11
|
+
export function checkPane(name, pane, takenBy) {
|
|
12
|
+
checkPart(name, 'pane', pane.id, pane.title, takenBy);
|
|
11
13
|
for (const key of sizeKeys) {
|
|
12
14
|
const size = pane[key];
|
|
13
15
|
if (typeof size !== 'function' && size !== undefined && (!Number.isInteger(size) || size <= 0))
|
package/runtime/pages.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { RenderElement } from 'claude-code';
|
|
2
|
-
import type { Claude } from './claude.js';
|
|
3
|
-
import type { DrawnParts } from './parts.js';
|
|
4
|
-
import type { Router } from './router.js';
|
|
5
|
-
import { type PageDeclaration, type PageRequest, type PartPress, type PartsUpdate, type ShownPages } from './ui.js';
|
|
6
|
-
import type { Widgets } from './widgets.js';
|
|
7
|
-
export type ModPages = {
|
|
8
|
-
readonly mod: string;
|
|
9
|
-
readonly pages: readonly PageDeclaration[];
|
|
10
|
-
};
|
|
11
|
-
export type PageApply = (mod: string, requests: readonly PageRequest[]) => Promise<void>;
|
|
12
|
-
export type Pages = {
|
|
13
|
-
declared(): readonly ModPages[];
|
|
14
|
-
stylers(): readonly string[];
|
|
15
|
-
element(mod: string, page: string, params: unknown, columns: number, isFocused: boolean): RenderElement | undefined;
|
|
16
|
-
press(mod: string, press: PartPress): void;
|
|
17
|
-
update(mod: string, update: PartsUpdate): boolean;
|
|
18
|
-
tell(mod: string, shown: ShownPages): void;
|
|
19
|
-
apply(listener: PageApply): void;
|
|
20
|
-
onStart(listener: (mod: string) => void): void;
|
|
21
|
-
};
|
|
22
|
-
export declare function pagesOf(input: unknown): PageDeclaration[];
|
|
23
|
-
export declare function servePages({ claude, router, report, tellRefusedPress, widgets, parts, tellStylers, }: {
|
|
24
|
-
readonly claude: Claude;
|
|
25
|
-
readonly router: Router;
|
|
26
|
-
readonly report: (id: string, message: string, error: unknown) => void;
|
|
27
|
-
readonly tellRefusedPress: (mod: string, error: unknown) => void;
|
|
28
|
-
readonly widgets: Pick<Widgets, 'update'>;
|
|
29
|
-
readonly parts: DrawnParts;
|
|
30
|
-
readonly tellStylers: (stylers: readonly string[]) => void;
|
|
31
|
-
}): Pages;
|
|
32
|
-
//# sourceMappingURL=pages.d.ts.map
|
package/runtime/pages.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pages.d.ts","sourceRoot":"","sources":["../src/runtime/pages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;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AG,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI,CAAA;CAC/C,CAAA;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,EAAE,CAGzD;AAED,wBAAgB,UAAU,CAAC,EACzB,MAAM,EACN,MAAM,EACN,MAAM,EACN,gBAAgB,EAChB,OAAO,EACP,KAAK,EACL,WAAW,GACZ,EAAE;IACD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IACtE,QAAQ,CAAC,gBAAgB,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAA;IAChE,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;IACzC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAA;IAC1B,QAAQ,CAAC,WAAW,EAAE,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,KAAK,IAAI,CAAA;CAC3D,GAAG,KAAK,CAqIR"}
|
package/runtime/pages.js
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { isObject } from '../records.js';
|
|
2
|
-
import { Text } from '../ui/elements.js';
|
|
3
|
-
import { messageOf } from '../utils/text.js';
|
|
4
|
-
import { cmodPluginName, isNotInstalled, isStillInstalling } from './dependencies.js';
|
|
5
|
-
import { partMethods } from './ui.js';
|
|
6
|
-
const askedWaitMs = 1000;
|
|
7
|
-
export function pagesOf(input) {
|
|
8
|
-
const listed = isObject(input) && Array.isArray(input['pages']) ? input['pages'] : [];
|
|
9
|
-
return listed.filter(isObject).flatMap((each) => (typeof each['id'] === 'string' && typeof each['title'] === 'string' && (each['place'] === 'sidebar' || each['place'] === 'settings') ? [{ id: each['id'], title: each['title'], place: each['place'] }] : []));
|
|
10
|
-
}
|
|
11
|
-
export function servePages({ claude, router, report, tellRefusedPress, widgets, parts, tellStylers, }) {
|
|
12
|
-
const declared = new Map();
|
|
13
|
-
const stylers = new Set();
|
|
14
|
-
const asking = new Map();
|
|
15
|
-
const pressing = new Set();
|
|
16
|
-
let waiting = [];
|
|
17
|
-
let inputDepth = 0;
|
|
18
|
-
let applyTo = async () => undefined;
|
|
19
|
-
let started = () => undefined;
|
|
20
|
-
const run = (mod, requests) => applyTo(mod, requests).catch((error) => report(`pages:${mod}`, `Could not show the page ${mod} asked for`, error));
|
|
21
|
-
const takeWaiting = async () => {
|
|
22
|
-
const taken = waiting;
|
|
23
|
-
waiting = [];
|
|
24
|
-
for (const { mod, requests } of taken)
|
|
25
|
-
await run(mod, requests);
|
|
26
|
-
};
|
|
27
|
-
const settle = async (earlier) => {
|
|
28
|
-
const own = () => [...pressing].filter((pending) => !earlier.has(pending));
|
|
29
|
-
for (let pending = own(); pending.length > 0; pending = own())
|
|
30
|
-
await Promise.allSettled(pending);
|
|
31
|
-
await takeWaiting();
|
|
32
|
-
};
|
|
33
|
-
const wrapped = async (next) => {
|
|
34
|
-
inputDepth += 1;
|
|
35
|
-
const earlier = new Set(pressing);
|
|
36
|
-
try {
|
|
37
|
-
const answer = await next();
|
|
38
|
-
await settle(earlier);
|
|
39
|
-
return answer;
|
|
40
|
-
}
|
|
41
|
-
finally {
|
|
42
|
-
inputDepth -= 1;
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
router.add('command.run', (e, next) => wrapped(async () => (waiting.length > 0 ? {} : next(e))));
|
|
46
|
-
router.add('ui.press', (e, next) => wrapped(() => next(e)));
|
|
47
|
-
const ask = (mod) => {
|
|
48
|
-
const pending = asking.get(mod) ??
|
|
49
|
-
claude.cmod
|
|
50
|
-
.call({ to: mod, method: partMethods.list, input: null })
|
|
51
|
-
.then((parts) => void declared.set(mod, pagesOf(parts)), (error) => {
|
|
52
|
-
if (!isNotInstalled(mod, error) && !isStillInstalling(mod, error))
|
|
53
|
-
claude.ui.warn(`pages:list:${mod}`, `cmod: ${mod} did not list its pages: ${messageOf(error)}`);
|
|
54
|
-
})
|
|
55
|
-
.finally(() => asking.delete(mod));
|
|
56
|
-
asking.set(mod, pending);
|
|
57
|
-
return pending;
|
|
58
|
-
};
|
|
59
|
-
const restyle = (mod, isStyler) => {
|
|
60
|
-
if (!isStyler && !stylers.delete(mod))
|
|
61
|
-
return;
|
|
62
|
-
if (isStyler)
|
|
63
|
-
stylers.add(mod);
|
|
64
|
-
parts.forget(mod);
|
|
65
|
-
const listed = [...stylers];
|
|
66
|
-
tellStylers(listed);
|
|
67
|
-
for (const told of declared.keys()) {
|
|
68
|
-
if (told === cmodPluginName)
|
|
69
|
-
continue;
|
|
70
|
-
void claude.cmod.call({ to: told, method: partMethods.stylers, input: listed }).catch((error) => {
|
|
71
|
-
if (!isStillInstalling(told, error))
|
|
72
|
-
claude.ui.warn(`pages:stylers:${told}`, `cmod: ${told} did not hear which mods style markdown: ${messageOf(error)}`);
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
const update = (mod, { parts: listing, redraw, requests, isAsked, isStart }) => {
|
|
77
|
-
if (isStart === true)
|
|
78
|
-
started(mod);
|
|
79
|
-
if (listing !== undefined)
|
|
80
|
-
declared.set(mod, pagesOf(listing));
|
|
81
|
-
if (listing !== undefined)
|
|
82
|
-
restyle(mod, isObject(listing) && listing['stylesMarkdown'] === true);
|
|
83
|
-
const isRedrawn = redraw === true || requests?.some((request) => 'open' in request) === true;
|
|
84
|
-
if (listing !== undefined || isRedrawn)
|
|
85
|
-
widgets.update(mod, { ...(listing === undefined ? {} : { parts: listing }), ...(isRedrawn ? { redraw: true } : {}) });
|
|
86
|
-
if (requests === undefined || requests.length === 0)
|
|
87
|
-
return false;
|
|
88
|
-
if (isAsked !== true)
|
|
89
|
-
return (void run(mod, requests), false);
|
|
90
|
-
waiting.push({ mod, requests });
|
|
91
|
-
if (inputDepth > 0)
|
|
92
|
-
return true;
|
|
93
|
-
claude.clock.after(askedWaitMs, () => void takeWaiting());
|
|
94
|
-
return false;
|
|
95
|
-
};
|
|
96
|
-
const press = (mod, input) => {
|
|
97
|
-
const pending = claude.cmod
|
|
98
|
-
.call({ to: mod, method: partMethods.press, input })
|
|
99
|
-
.then((answer) => void update(mod, (isObject(answer) ? answer : {})), (error) => {
|
|
100
|
-
parts.forget(mod);
|
|
101
|
-
claude.ui.invalidate('ui.render');
|
|
102
|
-
tellRefusedPress(mod, error);
|
|
103
|
-
})
|
|
104
|
-
.finally(() => pressing.delete(pending));
|
|
105
|
-
pressing.add(pending);
|
|
106
|
-
if (inputDepth === 0)
|
|
107
|
-
void pending.then(takeWaiting);
|
|
108
|
-
};
|
|
109
|
-
const lastDrawn = new Map();
|
|
110
|
-
const plain = (data) => JSON.parse(JSON.stringify(data));
|
|
111
|
-
return {
|
|
112
|
-
declared: () => [...declared].map(([mod, pages]) => ({ mod, pages })),
|
|
113
|
-
stylers: () => [...stylers],
|
|
114
|
-
element(mod, page, params, columns, isFocused) {
|
|
115
|
-
if (!declared.has(mod))
|
|
116
|
-
void ask(mod);
|
|
117
|
-
const given = JSON.stringify(params ?? null);
|
|
118
|
-
const cached = `${page}\u0000${given}\u0000${columns}\u0000${isFocused}`;
|
|
119
|
-
const name = `The ${page} page of ${mod}`;
|
|
120
|
-
const keyPrefix = `${mod}/${page}:`;
|
|
121
|
-
void parts.fill(mod, cached, { page, params: plain(params ?? null), columns, isFocused }, name)?.then(() => claude.ui.invalidate('ui.render'));
|
|
122
|
-
const failure = parts.failure(mod, cached);
|
|
123
|
-
const drawnAt = (key) => parts.element(mod, key, keyPrefix, name, `page:${mod}/${page}`);
|
|
124
|
-
const last = lastDrawn.get(keyPrefix);
|
|
125
|
-
const drawn = drawnAt(cached);
|
|
126
|
-
if (drawn !== undefined)
|
|
127
|
-
lastDrawn.set(keyPrefix, { params: given, cached });
|
|
128
|
-
return drawn ?? (last?.params === given ? drawnAt(last.cached) : undefined) ?? (failure === undefined ? undefined : Text({ color: 'error', children: `${name} could not draw: ${failure}` }));
|
|
129
|
-
},
|
|
130
|
-
press,
|
|
131
|
-
update,
|
|
132
|
-
tell(mod, shown) {
|
|
133
|
-
void claude.cmod.call({ to: mod, method: partMethods.shown, input: plain(shown) }).catch((error) => claude.ui.warn(`pages:shown:${mod}`, `cmod: ${mod} did not hear which of its pages show: ${messageOf(error)}`));
|
|
134
|
-
},
|
|
135
|
-
apply(listener) {
|
|
136
|
-
applyTo = listener;
|
|
137
|
-
},
|
|
138
|
-
onStart(listener) {
|
|
139
|
-
started = listener;
|
|
140
|
-
},
|
|
141
|
-
};
|
|
142
|
-
}
|
package/src/runtime/pages.ts
DELETED
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import type { RenderElement } from 'claude-code'
|
|
2
|
-
import { isObject } from '../records.js'
|
|
3
|
-
import { Text } from '../ui/elements.js'
|
|
4
|
-
import { messageOf } from '../utils/text.js'
|
|
5
|
-
import type { Claude } from './claude.js'
|
|
6
|
-
import { cmodPluginName, isNotInstalled, isStillInstalling } from './dependencies.js'
|
|
7
|
-
import type { DrawnParts } from './parts.js'
|
|
8
|
-
import type { Router } from './router.js'
|
|
9
|
-
import { partMethods, type PageDeclaration, type PageRequest, type PartPress, type PartsUpdate, type ShownPages } from './ui.js'
|
|
10
|
-
import type { Widgets } from './widgets.js'
|
|
11
|
-
|
|
12
|
-
const askedWaitMs = 1000
|
|
13
|
-
|
|
14
|
-
export type ModPages = { readonly mod: string; readonly pages: readonly PageDeclaration[] }
|
|
15
|
-
|
|
16
|
-
export type PageApply = (mod: string, requests: readonly PageRequest[]) => Promise<void>
|
|
17
|
-
|
|
18
|
-
export type Pages = {
|
|
19
|
-
declared(): readonly ModPages[]
|
|
20
|
-
stylers(): readonly string[]
|
|
21
|
-
element(mod: string, page: string, params: unknown, columns: number, isFocused: boolean): RenderElement | undefined
|
|
22
|
-
press(mod: string, press: PartPress): void
|
|
23
|
-
update(mod: string, update: PartsUpdate): boolean
|
|
24
|
-
tell(mod: string, shown: ShownPages): void
|
|
25
|
-
apply(listener: PageApply): void
|
|
26
|
-
onStart(listener: (mod: string) => void): void
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function pagesOf(input: unknown): PageDeclaration[] {
|
|
30
|
-
const listed = isObject(input) && Array.isArray(input['pages']) ? (input['pages'] as unknown[]) : []
|
|
31
|
-
return listed.filter(isObject).flatMap((each) => (typeof each['id'] === 'string' && typeof each['title'] === 'string' && (each['place'] === 'sidebar' || each['place'] === 'settings') ? [{ id: each['id'], title: each['title'], place: each['place'] }] : []))
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function servePages({
|
|
35
|
-
claude,
|
|
36
|
-
router,
|
|
37
|
-
report,
|
|
38
|
-
tellRefusedPress,
|
|
39
|
-
widgets,
|
|
40
|
-
parts,
|
|
41
|
-
tellStylers,
|
|
42
|
-
}: {
|
|
43
|
-
readonly claude: Claude
|
|
44
|
-
readonly router: Router
|
|
45
|
-
readonly report: (id: string, message: string, error: unknown) => void
|
|
46
|
-
readonly tellRefusedPress: (mod: string, error: unknown) => void
|
|
47
|
-
readonly widgets: Pick<Widgets, 'update'>
|
|
48
|
-
readonly parts: DrawnParts
|
|
49
|
-
readonly tellStylers: (stylers: readonly string[]) => void
|
|
50
|
-
}): Pages {
|
|
51
|
-
const declared = new Map<string, readonly PageDeclaration[]>()
|
|
52
|
-
const stylers = new Set<string>()
|
|
53
|
-
const asking = new Map<string, Promise<void>>()
|
|
54
|
-
const pressing = new Set<Promise<void>>()
|
|
55
|
-
let waiting: { readonly mod: string; readonly requests: readonly PageRequest[] }[] = []
|
|
56
|
-
let inputDepth = 0
|
|
57
|
-
let applyTo: PageApply = async () => undefined
|
|
58
|
-
let started: (mod: string) => void = () => undefined
|
|
59
|
-
|
|
60
|
-
const run = (mod: string, requests: readonly PageRequest[]) =>
|
|
61
|
-
applyTo(mod, requests).catch((error: unknown) => report(`pages:${mod}`, `Could not show the page ${mod} asked for`, error))
|
|
62
|
-
|
|
63
|
-
const takeWaiting = async () => {
|
|
64
|
-
const taken = waiting
|
|
65
|
-
waiting = []
|
|
66
|
-
for (const { mod, requests } of taken) await run(mod, requests)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const settle = async (earlier: ReadonlySet<Promise<void>>) => {
|
|
70
|
-
const own = () => [...pressing].filter((pending) => !earlier.has(pending))
|
|
71
|
-
for (let pending = own(); pending.length > 0; pending = own()) await Promise.allSettled(pending)
|
|
72
|
-
await takeWaiting()
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const wrapped = async <Answer>(next: () => Promise<Answer>): Promise<Answer> => {
|
|
76
|
-
inputDepth += 1
|
|
77
|
-
const earlier = new Set(pressing)
|
|
78
|
-
try {
|
|
79
|
-
const answer = await next()
|
|
80
|
-
await settle(earlier)
|
|
81
|
-
return answer
|
|
82
|
-
} finally {
|
|
83
|
-
inputDepth -= 1
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
router.add('command.run', (e, next) => wrapped(async () => (waiting.length > 0 ? {} : next(e))))
|
|
88
|
-
router.add('ui.press', (e, next) => wrapped(() => next(e)))
|
|
89
|
-
|
|
90
|
-
const ask = (mod: string) => {
|
|
91
|
-
const pending =
|
|
92
|
-
asking.get(mod) ??
|
|
93
|
-
claude.cmod
|
|
94
|
-
.call({ to: mod, method: partMethods.list, input: null })
|
|
95
|
-
.then(
|
|
96
|
-
(parts) => void declared.set(mod, pagesOf(parts)),
|
|
97
|
-
(error: unknown) => {
|
|
98
|
-
if (!isNotInstalled(mod, error) && !isStillInstalling(mod, error)) claude.ui.warn(`pages:list:${mod}`, `cmod: ${mod} did not list its pages: ${messageOf(error)}`)
|
|
99
|
-
},
|
|
100
|
-
)
|
|
101
|
-
.finally(() => asking.delete(mod))
|
|
102
|
-
asking.set(mod, pending)
|
|
103
|
-
return pending
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const restyle = (mod: string, isStyler: boolean) => {
|
|
107
|
-
if (!isStyler && !stylers.delete(mod)) return
|
|
108
|
-
if (isStyler) stylers.add(mod)
|
|
109
|
-
parts.forget(mod)
|
|
110
|
-
const listed = [...stylers]
|
|
111
|
-
tellStylers(listed)
|
|
112
|
-
for (const told of declared.keys()) {
|
|
113
|
-
if (told === cmodPluginName) continue
|
|
114
|
-
void claude.cmod.call({ to: told, method: partMethods.stylers, input: listed }).catch((error: unknown) => {
|
|
115
|
-
if (!isStillInstalling(told, error)) claude.ui.warn(`pages:stylers:${told}`, `cmod: ${told} did not hear which mods style markdown: ${messageOf(error)}`)
|
|
116
|
-
})
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
const update = (mod: string, { parts: listing, redraw, requests, isAsked, isStart }: PartsUpdate) => {
|
|
121
|
-
if (isStart === true) started(mod)
|
|
122
|
-
if (listing !== undefined) declared.set(mod, pagesOf(listing))
|
|
123
|
-
if (listing !== undefined) restyle(mod, isObject(listing) && listing['stylesMarkdown'] === true)
|
|
124
|
-
const isRedrawn = redraw === true || requests?.some((request) => 'open' in request) === true
|
|
125
|
-
if (listing !== undefined || isRedrawn) widgets.update(mod, { ...(listing === undefined ? {} : { parts: listing }), ...(isRedrawn ? { redraw: true } : {}) })
|
|
126
|
-
if (requests === undefined || requests.length === 0) return false
|
|
127
|
-
if (isAsked !== true) return (void run(mod, requests), false)
|
|
128
|
-
waiting.push({ mod, requests })
|
|
129
|
-
if (inputDepth > 0) return true
|
|
130
|
-
claude.clock.after(askedWaitMs, () => void takeWaiting())
|
|
131
|
-
return false
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
const press = (mod: string, input: PartPress) => {
|
|
135
|
-
const pending = claude.cmod
|
|
136
|
-
.call({ to: mod, method: partMethods.press, input })
|
|
137
|
-
.then(
|
|
138
|
-
(answer) => void update(mod, (isObject(answer) ? answer : {}) as PartsUpdate),
|
|
139
|
-
(error: unknown) => {
|
|
140
|
-
parts.forget(mod)
|
|
141
|
-
claude.ui.invalidate('ui.render')
|
|
142
|
-
tellRefusedPress(mod, error)
|
|
143
|
-
},
|
|
144
|
-
)
|
|
145
|
-
.finally(() => pressing.delete(pending))
|
|
146
|
-
pressing.add(pending)
|
|
147
|
-
if (inputDepth === 0) void pending.then(takeWaiting)
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
const lastDrawn = new Map<string, { readonly params: string; readonly cached: string }>()
|
|
151
|
-
|
|
152
|
-
const plain = <Data,>(data: Data): Data => JSON.parse(JSON.stringify(data)) as Data
|
|
153
|
-
|
|
154
|
-
return {
|
|
155
|
-
declared: () => [...declared].map(([mod, pages]) => ({ mod, pages })),
|
|
156
|
-
stylers: () => [...stylers],
|
|
157
|
-
element(mod, page, params, columns, isFocused) {
|
|
158
|
-
if (!declared.has(mod)) void ask(mod)
|
|
159
|
-
const given = JSON.stringify(params ?? null)
|
|
160
|
-
const cached = `${page}\u0000${given}\u0000${columns}\u0000${isFocused}`
|
|
161
|
-
const name = `The ${page} page of ${mod}`
|
|
162
|
-
const keyPrefix = `${mod}/${page}:`
|
|
163
|
-
void parts.fill(mod, cached, { page, params: plain(params ?? null), columns, isFocused }, name)?.then(() => claude.ui.invalidate('ui.render'))
|
|
164
|
-
const failure = parts.failure(mod, cached)
|
|
165
|
-
const drawnAt = (key: string) => parts.element(mod, key, keyPrefix, name, `page:${mod}/${page}`)
|
|
166
|
-
const last = lastDrawn.get(keyPrefix)
|
|
167
|
-
const drawn = drawnAt(cached)
|
|
168
|
-
if (drawn !== undefined) lastDrawn.set(keyPrefix, { params: given, cached })
|
|
169
|
-
return drawn ?? (last?.params === given ? drawnAt(last.cached) : undefined) ?? (failure === undefined ? undefined : Text({ color: 'error', children: `${name} could not draw: ${failure}` }))
|
|
170
|
-
},
|
|
171
|
-
press,
|
|
172
|
-
update,
|
|
173
|
-
tell(mod, shown) {
|
|
174
|
-
void claude.cmod.call({ to: mod, method: partMethods.shown, input: plain(shown) }).catch((error: unknown) => claude.ui.warn(`pages:shown:${mod}`, `cmod: ${mod} did not hear which of its pages show: ${messageOf(error)}`))
|
|
175
|
-
},
|
|
176
|
-
apply(listener) {
|
|
177
|
-
applyTo = listener
|
|
178
|
-
},
|
|
179
|
-
onStart(listener) {
|
|
180
|
-
started = listener
|
|
181
|
-
},
|
|
182
|
-
}
|
|
183
|
-
}
|