@cmodjs/core 5.13.3 → 6.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 +4 -4
- package/docs/index.md +7 -5
- package/docs/install-steps.md +1 -1
- package/docs/mod.md +17 -16
- package/docs/testing.md +1 -1
- package/docs/ui.md +27 -16
- package/installer.d.ts +1 -2
- package/installer.d.ts.map +1 -1
- package/mod.d.ts +13 -7
- package/mod.d.ts.map +1 -1
- package/mod.js +3 -3
- package/package.json +1 -1
- package/records.d.ts +16 -3
- package/records.d.ts.map +1 -1
- package/records.js +25 -4
- package/register.d.ts +5 -3
- package/register.d.ts.map +1 -1
- package/register.js +4 -0
- package/runtime/claude.d.ts +4 -0
- package/runtime/claude.d.ts.map +1 -1
- package/runtime/lifecycle.d.ts.map +1 -1
- package/runtime/lifecycle.js +8 -3
- package/runtime/pages.d.ts +1 -0
- package/runtime/pages.d.ts.map +1 -1
- package/runtime/pages.js +7 -1
- package/runtime/toaster.d.ts +1 -1
- package/runtime/toaster.d.ts.map +1 -1
- package/runtime/toaster.js +4 -4
- package/runtime/ui.d.ts +3 -1
- package/runtime/ui.d.ts.map +1 -1
- package/runtime/ui.js +17 -3
- package/runtime/web.js +3 -0
- package/src/installer.ts +1 -2
- package/src/mod.ts +21 -10
- package/src/records.ts +26 -4
- package/src/register.ts +11 -3
- package/src/runtime/claude.ts +4 -0
- package/src/runtime/lifecycle.ts +12 -3
- package/src/runtime/pages.ts +7 -1
- package/src/runtime/toaster.ts +4 -4
- package/src/runtime/ui.ts +18 -5
- package/src/runtime/web.ts +2 -0
- package/src/testing/fake-claude.ts +4 -0
- package/src/testing.ts +11 -5
- package/src/ui/areas.ts +1 -2
- package/src/ui/components.ts +10 -11
- package/src/ui/elements.ts +51 -3
- package/src/ui/panes.ts +9 -5
- package/src/ui/styles.ts +3 -3
- package/testing/fake-claude.d.ts.map +1 -1
- package/testing/fake-claude.js +4 -0
- package/testing.d.ts +2 -2
- package/testing.d.ts.map +1 -1
- package/testing.js +10 -4
- package/ui/areas.d.ts +1 -2
- package/ui/areas.d.ts.map +1 -1
- package/ui/components.d.ts +15 -16
- package/ui/components.d.ts.map +1 -1
- package/ui/elements.d.ts +32 -13
- package/ui/elements.d.ts.map +1 -1
- package/ui/elements.js +15 -1
- package/ui/panes.d.ts +7 -5
- package/ui/panes.d.ts.map +1 -1
- package/ui/styles.d.ts +3 -3
- package/ui/styles.d.ts.map +1 -1
package/src/runtime/claude.ts
CHANGED
|
@@ -114,6 +114,10 @@ export type Claude = {
|
|
|
114
114
|
home(): Promise<string | undefined>
|
|
115
115
|
dataHome(): Promise<string | undefined>
|
|
116
116
|
configHome(): Promise<string | undefined>
|
|
117
|
+
browser(): Promise<string | undefined>
|
|
118
|
+
sshConnection(): Promise<string | undefined>
|
|
119
|
+
display(): Promise<string | undefined>
|
|
120
|
+
waylandDisplay(): Promise<string | undefined>
|
|
117
121
|
}
|
|
118
122
|
readonly device: { read(): Promise<Device> }
|
|
119
123
|
readonly cmod: { call(input: Args<'cmod.call'>): Promise<unknown> }
|
package/src/runtime/lifecycle.ts
CHANGED
|
@@ -33,10 +33,10 @@ import { createHotkeys } from './hotkeys.js'
|
|
|
33
33
|
import type { Pages } from './pages.js'
|
|
34
34
|
import { drawnParts, type DrawnParts } from './parts.js'
|
|
35
35
|
import { createWatches } from './watches.js'
|
|
36
|
-
import { createUi, partMethods, stalePress, type BorrowedMarkdown, type PartDraw, type PartPress, type PartsUpdate, type ShownPages, type UiArea } from './ui.js'
|
|
36
|
+
import { createUi, openLink, partMethods, stalePress, type BorrowedMarkdown, type PartDraw, type PartPress, type PartsUpdate, type ShownPages, type UiArea } from './ui.js'
|
|
37
37
|
import type { Widgets } from './widgets.js'
|
|
38
38
|
import { Progress } from '../ui/components.js'
|
|
39
|
-
import { Box, Text } from '../ui/elements.js'
|
|
39
|
+
import { Box, Text, withLinks, type Press } from '../ui/elements.js'
|
|
40
40
|
|
|
41
41
|
export type Plugin = {
|
|
42
42
|
readonly name: string
|
|
@@ -698,9 +698,18 @@ export function createLifecycle<State extends object, Declared extends Options =
|
|
|
698
698
|
},
|
|
699
699
|
async start(claudeCalls, read) {
|
|
700
700
|
if (runtime !== undefined) return
|
|
701
|
+
const open = (href: string, press: Press) =>
|
|
702
|
+
void openLink(claudeCalls, href, press.surface).then(
|
|
703
|
+
(done) => done === 'copied' && runtime?.toaster.toast.success('Copied the link', { description: 'Paste it in your browser.' }),
|
|
704
|
+
(error: unknown) => toastFailure({ id: 'open-link', message: 'Could not open the link', error, isCritical: true }),
|
|
705
|
+
)
|
|
701
706
|
const naming: Claude = {
|
|
702
707
|
...claudeCalls,
|
|
703
|
-
ui: {
|
|
708
|
+
ui: {
|
|
709
|
+
...claudeCalls.ui,
|
|
710
|
+
warn: (id, text) => (runtime === undefined ? claudeCalls.ui.warn(id, text) : runtime.toaster.warn(id, text)),
|
|
711
|
+
resolve: (e) => withLinks(claudeCalls.ui.resolve(e), e.surface, open),
|
|
712
|
+
},
|
|
704
713
|
session: { ...claudeCalls.session, id: async () => startingSession ?? claudeCalls.session.id() },
|
|
705
714
|
}
|
|
706
715
|
programs = locatingPrograms(naming)
|
package/src/runtime/pages.ts
CHANGED
|
@@ -23,6 +23,7 @@ export type Pages = {
|
|
|
23
23
|
update(mod: string, update: PartsUpdate): boolean
|
|
24
24
|
tell(mod: string, shown: ShownPages): void
|
|
25
25
|
apply(listener: PageApply): void
|
|
26
|
+
onStart(listener: (mod: string) => void): void
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
export function pagesOf(input: unknown): PageDeclaration[] {
|
|
@@ -54,6 +55,7 @@ export function servePages({
|
|
|
54
55
|
let waiting: { readonly mod: string; readonly requests: readonly PageRequest[] }[] = []
|
|
55
56
|
let inputDepth = 0
|
|
56
57
|
let applyTo: PageApply = async () => undefined
|
|
58
|
+
let started: (mod: string) => void = () => undefined
|
|
57
59
|
|
|
58
60
|
const run = (mod: string, requests: readonly PageRequest[]) =>
|
|
59
61
|
applyTo(mod, requests).catch((error: unknown) => report(`pages:${mod}`, `Could not show the page ${mod} asked for`, error))
|
|
@@ -115,7 +117,8 @@ export function servePages({
|
|
|
115
117
|
}
|
|
116
118
|
}
|
|
117
119
|
|
|
118
|
-
const update = (mod: string, { parts: listing, redraw, requests, isAsked }: PartsUpdate) => {
|
|
120
|
+
const update = (mod: string, { parts: listing, redraw, requests, isAsked, isStart }: PartsUpdate) => {
|
|
121
|
+
if (isStart === true) started(mod)
|
|
119
122
|
if (listing !== undefined) declared.set(mod, pagesOf(listing))
|
|
120
123
|
if (listing !== undefined) restyle(mod, isObject(listing) && listing['stylesMarkdown'] === true)
|
|
121
124
|
const isRedrawn = redraw === true || requests?.some((request) => 'open' in request) === true
|
|
@@ -173,5 +176,8 @@ export function servePages({
|
|
|
173
176
|
apply(listener) {
|
|
174
177
|
applyTo = listener
|
|
175
178
|
},
|
|
179
|
+
onStart(listener) {
|
|
180
|
+
started = listener
|
|
181
|
+
},
|
|
176
182
|
}
|
|
177
183
|
}
|
package/src/runtime/toaster.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ElementTable, RenderElement, RenderPropsOf, Timer } from 'claude-code'
|
|
2
2
|
import type { Toast, ToastId, ToastOptions, ToastType } from '../mod.js'
|
|
3
|
-
import { Box, Button, drawWith,
|
|
3
|
+
import { Box, Button, drawWith, Text } from '../ui/elements.js'
|
|
4
4
|
import { coreVersion, installFix, isObject, secretFix, type Contact, type LogLevel } from '../records.js'
|
|
5
5
|
import { firstLine, messageOf } from '../utils/text.js'
|
|
6
6
|
import type { Claude } from './claude.js'
|
|
@@ -389,7 +389,7 @@ export function createToaster(claude: Claude, name: string, version: () => strin
|
|
|
389
389
|
const copied = await claude.ui.copy({ text: details })
|
|
390
390
|
say(copied.isCopied ? 'Copied the error.' : `Could not copy it: ${copied.reason}`)
|
|
391
391
|
}
|
|
392
|
-
const report = contact === undefined ? [] : [reportLink(contact, name, entry.message, details)]
|
|
392
|
+
const report = contact === undefined ? [] : [reportLink(`toast:${entry.id}:report`, contact, name, entry.message, details)]
|
|
393
393
|
return [
|
|
394
394
|
Text({ dimColor: true, children: 'Claude writes up the problem and files it with your tools. You approve each step before anything is posted.' }),
|
|
395
395
|
Box({
|
|
@@ -461,7 +461,7 @@ async function contactOf(claude: Claude): Promise<Contact | undefined> {
|
|
|
461
461
|
return typeof address === 'string' && address !== '' ? { kind: 'email', address } : undefined
|
|
462
462
|
}
|
|
463
463
|
|
|
464
|
-
export function reportLink(contact: Contact, name: string, message: string, details: string): RenderElement {
|
|
464
|
+
export function reportLink(key: string, contact: Contact, name: string, message: string, details: string): RenderElement {
|
|
465
465
|
const title = `${name}: ${message}`.slice(0, 120)
|
|
466
466
|
const linkOf = (body: string) =>
|
|
467
467
|
contact.kind === 'github'
|
|
@@ -469,7 +469,7 @@ export function reportLink(contact: Contact, name: string, message: string, deta
|
|
|
469
469
|
: `mailto:${contact.address}?subject=${encodeURIComponent(title)}&body=${encodeURIComponent(body)}`
|
|
470
470
|
let body = details
|
|
471
471
|
while (linkOf(body).length > linkLimit && body.length > 0) body = `${body.slice(0, Math.floor(body.length * 0.8))}…`
|
|
472
|
-
return
|
|
472
|
+
return Button({ plain: true, key, href: linkOf(body), label: contact.kind === 'github' ? 'Report it on GitHub (opens your browser)' : 'Email the author (opens your mail app)' })
|
|
473
473
|
}
|
|
474
474
|
|
|
475
475
|
export function reportPrompt(name: string, contact: Contact | undefined, details: string): string {
|
package/src/runtime/ui.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Args, ElementTable, Frozen, MarkdownProps, PaneOpenArgs, RenderElement } from 'claude-code'
|
|
1
|
+
import type { Args, ElementTable, Frozen, MarkdownProps, PaneOpenArgs, RenderElement, RenderSurface } from 'claude-code'
|
|
2
2
|
import type { Mod, Turn } from '../mod.js'
|
|
3
|
-
import { isObject } from '../records.js'
|
|
3
|
+
import { browserCommand, isObject } from '../records.js'
|
|
4
4
|
import { TurnEnd, type Area, type Widget, type WidgetContext, type WidgetInit } from '../ui/areas.js'
|
|
5
5
|
import { Box, drawKeyed, drawsFocusable, drawWith, elementData, Markdown, Text, type Handler } from '../ui/elements.js'
|
|
6
6
|
import type { Block, MarkdownPiece, MarkdownReader } from '../ui/markdown.js'
|
|
@@ -49,6 +49,18 @@ export function styledAt(e: Frozen<Args<'ui.render'>>, columns = viewportColumns
|
|
|
49
49
|
return { surface: e.surface, columns: Math.max(columns, 0) }
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
export async function openLink(claude: Claude, href: string, surface: RenderSurface): Promise<'opened' | 'copied'> {
|
|
53
|
+
if (surface === 'terminal') {
|
|
54
|
+
const [browser, sshConnection, display, waylandDisplay] = await Promise.all([claude.env.browser(), claude.env.sshConnection(), claude.env.display(), claude.env.waylandDisplay()])
|
|
55
|
+
const os = browser || sshConnection ? '' : (await claude.process.run(['uname', '-s'])).stdout.trim().toLowerCase()
|
|
56
|
+
const command = browserCommand({ os, browser, sshConnection, display, waylandDisplay }, href)
|
|
57
|
+
if (command !== undefined && (await claude.process.run(command)).exitCode === 0) return 'opened'
|
|
58
|
+
}
|
|
59
|
+
const copied = await claude.ui.copy({ text: href, surface })
|
|
60
|
+
if (!copied.isCopied) throw new Error(`cmod could not open ${href} or copy it: ${copied.reason}`)
|
|
61
|
+
return 'copied'
|
|
62
|
+
}
|
|
63
|
+
|
|
52
64
|
export type PartPress = { readonly draw: number; readonly handler: number; readonly args: readonly unknown[] }
|
|
53
65
|
|
|
54
66
|
export type DrawnPart = { readonly draw: number; readonly tree: unknown }
|
|
@@ -62,7 +74,7 @@ export type PageRequest =
|
|
|
62
74
|
|
|
63
75
|
export type SettingsTab = 'changelog' | 'permissions'
|
|
64
76
|
|
|
65
|
-
export type PartsUpdate = { readonly parts?: PartList; readonly redraw?: true; readonly requests?: readonly PageRequest[]; readonly isAsked?: true }
|
|
77
|
+
export type PartsUpdate = { readonly parts?: PartList; readonly redraw?: true; readonly requests?: readonly PageRequest[]; readonly isAsked?: true; readonly isStart?: true }
|
|
66
78
|
|
|
67
79
|
export type ShownPages = { readonly open: readonly { readonly id: string; readonly params: unknown }[]; readonly shown: string | null; readonly isFocused: boolean }
|
|
68
80
|
|
|
@@ -166,7 +178,8 @@ export function merged(updates: readonly PartsUpdate[]): PartsUpdate {
|
|
|
166
178
|
const parts = updates.findLast((update) => update.parts !== undefined)?.parts
|
|
167
179
|
const requests = updates.flatMap((update) => update.requests ?? [])
|
|
168
180
|
const isRedrawn = updates.some((update) => update.redraw === true)
|
|
169
|
-
|
|
181
|
+
const isStart = updates.some((update) => update.isStart === true)
|
|
182
|
+
return { ...(parts === undefined ? {} : { parts }), ...(isRedrawn ? { redraw: true } : {}), ...(requests.length === 0 ? {} : { requests }), ...(isStart ? { isStart } : {}) }
|
|
170
183
|
}
|
|
171
184
|
|
|
172
185
|
type MarkdownRender = {
|
|
@@ -760,7 +773,7 @@ export function createUi<State extends object>({ name, claude, router, report, a
|
|
|
760
773
|
started() {
|
|
761
774
|
const held = merged(beforeStart ?? [])
|
|
762
775
|
beforeStart = undefined
|
|
763
|
-
void send({ ...held, parts: partList() })
|
|
776
|
+
void send({ ...held, parts: partList(), isStart: true })
|
|
764
777
|
},
|
|
765
778
|
changed() {
|
|
766
779
|
if (widgets.size > 0 || pages.size > 0) void send({ redraw: true })
|
package/src/runtime/web.ts
CHANGED
|
@@ -125,6 +125,8 @@ const elements: Readonly<Record<string, (props: Props, drawing: Drawing) => stri
|
|
|
125
125
|
const hover = hoverClasses(props['hover'], textHover({}), drawing, drawing.scope)
|
|
126
126
|
const classes = ['button', ...(props['plain'] === true ? ['plain'] : props['variant'] === 'primary' ? ['primary'] : []), ...(props['dimColor'] === true ? ['dim'] : []), ...hover]
|
|
127
127
|
const key = keyOf(props) ?? label ?? (typeof props['children'] === 'string' ? props['children'] : undefined)
|
|
128
|
+
const href = typeof props['href'] === 'string' && linkSchemes.test(props['href']) ? props['href'] : undefined
|
|
129
|
+
if (href !== undefined) return `<a class="${classes.join(' ')}" href="${escaped(href)}" target="_blank" rel="noopener noreferrer"${attribute('aria-label', drawn === '' ? undefined : label)}${attribute('data-key', key)}>${prefix}${shown}</a>`
|
|
128
130
|
return `<button type="button" class="${classes.join(' ')}"${attribute('aria-label', drawn === '' ? undefined : label)}${attribute('data-key', key)}${handlerAttribute('data-press', props['onPress'])}${attribute('data-hotkey', hotkey)}${props['autoFocus'] === true ? ' autofocus' : ''}>${prefix}${shown}</button>`
|
|
129
131
|
},
|
|
130
132
|
Link: (props, drawing) => {
|
|
@@ -235,6 +235,10 @@ export function fakeClaude(plugin: { readonly name: string; readonly root: strin
|
|
|
235
235
|
home: async () => '/test/home',
|
|
236
236
|
dataHome: async () => undefined,
|
|
237
237
|
configHome: async () => undefined,
|
|
238
|
+
browser: async () => undefined,
|
|
239
|
+
sshConnection: async () => undefined,
|
|
240
|
+
display: async () => undefined,
|
|
241
|
+
waylandDisplay: async () => undefined,
|
|
238
242
|
},
|
|
239
243
|
device: { read: rejected('device.read', () => fakes.device.read ?? (async () => testDevice)) },
|
|
240
244
|
cmod: { call: async (args) => cmodCall(clonedAsClaudeCodeDoes(args)) },
|
package/src/testing.ts
CHANGED
|
@@ -53,12 +53,12 @@ import { fakeSessions, type FakeSession, type FakeSessions, type MessageDraft, t
|
|
|
53
53
|
import { listed, messageOf } from './utils/text.js'
|
|
54
54
|
import { componentOf, type KindProps, type Row, type StyledAt } from './ui/styles.js'
|
|
55
55
|
import { AbovePrompt, areas, BelowPrompt, Dashboard, TurnEnd as TurnEndArea, Working, type Area } from './ui/areas.js'
|
|
56
|
-
import { drawWith, elementOf } from './ui/elements.js'
|
|
56
|
+
import { drawWith, elementOf, withLinks, type Press } from './ui/elements.js'
|
|
57
57
|
import { drawnParts } from './runtime/parts.js'
|
|
58
58
|
import { serveWidgets, type Widgets } from './runtime/widgets.js'
|
|
59
59
|
import { engineOf } from './runtime/engine.js'
|
|
60
60
|
import { pagesOf, servePages } from './runtime/pages.js'
|
|
61
|
-
import { inheriting, partMethods, type DrawnPart, type PageRequest, type PartPress, type PartsUpdate } from './runtime/ui.js'
|
|
61
|
+
import { inheriting, openLink, partMethods, type DrawnPart, type PageRequest, type PartPress, type PartsUpdate } from './runtime/ui.js'
|
|
62
62
|
|
|
63
63
|
export type { Fakes, TestCall } from './testing/fake-claude.js'
|
|
64
64
|
export type { FakeSession, MessageDraft, StartedTask } from './testing/fake-sessions.js'
|
|
@@ -70,7 +70,7 @@ export type ShownPart = {
|
|
|
70
70
|
readonly params: unknown
|
|
71
71
|
lines(options?: { readonly columns?: number }): Promise<string[]>
|
|
72
72
|
press(key: string, link?: string): Promise<void>
|
|
73
|
-
input(key: string, text: string, type?:
|
|
73
|
+
input(key: string, text: string, type?: 'change' | 'submit'): Promise<void>
|
|
74
74
|
select(key: string, value: string): Promise<void>
|
|
75
75
|
focusedKey(): Promise<string | undefined>
|
|
76
76
|
}
|
|
@@ -281,8 +281,13 @@ export function testMod<State extends object, Declared extends Options = Options
|
|
|
281
281
|
missedMarkdown.clear()
|
|
282
282
|
return draw()
|
|
283
283
|
}
|
|
284
|
-
const cmodClaude: Claude = { ...fake.claude, cmod: { call: async (input) => (input.to === name ? callMod(input.method, input.input) : fake.claude.cmod.call(input)) } }
|
|
285
284
|
const reportPart = (_id: string, message: string, error: unknown) => fake.claude.ui.log(`cmod: ${message}: ${messageOf(error)}`, { to: 'debug' })
|
|
285
|
+
const openFromCmod = (href: string, press: Press) => void openLink(fake.claude, href, press.surface).catch((error: unknown) => reportPart('open-link', 'Could not open the link', error))
|
|
286
|
+
const cmodClaude: Claude = {
|
|
287
|
+
...fake.claude,
|
|
288
|
+
ui: { ...fake.claude.ui, resolve: (e) => withLinks(fake.claude.ui.resolve(e), e.surface, openFromCmod) },
|
|
289
|
+
cmod: { call: async (input) => (input.to === name ? callMod(input.method, input.input) : fake.claude.cmod.call(input)) },
|
|
290
|
+
}
|
|
286
291
|
const tellRefusedPress = (_mod: string, error: unknown) => fake.claude.ui.log(`cmod: ${name} did not take the press: ${messageOf(error)}`, { to: 'debug' })
|
|
287
292
|
const parts = drawnParts({ claude: cmodClaude, report: reportPart, press: (mod: string, input: PartPress) => void pressPart(input).catch((error: unknown) => tellRefusedPress(mod, error)) })
|
|
288
293
|
const servedWidgets = async (): Promise<Widgets> => {
|
|
@@ -503,7 +508,8 @@ export function testMod<State extends object, Declared extends Options = Options
|
|
|
503
508
|
const drawn = (await callMod(partMethods.draw, { page: pageId, params: page.params, columns, isFocused: page.isFocused })) as DrawnPart | null
|
|
504
509
|
await fake.settle()
|
|
505
510
|
const tree = drawn?.tree ?? null
|
|
506
|
-
const
|
|
511
|
+
const table = withLinks(elements, 'terminal', openFromCmod)
|
|
512
|
+
const drawing = tree === null || drawn === null ? elements.Box({}) : await withOwnMarkdown(async () => drawWith(table, () => elementOf(tree, `${name}/${pageId}:`, (handler, args) => void modeling(pressPart({ draw: drawn.draw, handler, args }))), markdownIn(table, { surface: 'terminal', columns })) as RenderElement)
|
|
507
513
|
checkKeys(drawing, cmodPluginName, 'Pane')
|
|
508
514
|
return { drawing, columns }
|
|
509
515
|
}
|
package/src/ui/areas.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { RenderElement } from 'claude-code'
|
|
2
1
|
import type { Mod, Turn } from '../mod.js'
|
|
3
2
|
|
|
4
3
|
export const AbovePrompt = 'abovePrompt'
|
|
@@ -18,7 +17,7 @@ export type WidgetInit<State extends object = Record<never, never>> = {
|
|
|
18
17
|
readonly title: string
|
|
19
18
|
readonly areas: readonly [Area, ...Area[]]
|
|
20
19
|
readonly place?: { readonly side?: 'left' | 'right'; readonly size?: 'fit' | 'fill' }
|
|
21
|
-
render(mod: Mod<State>, context: WidgetContext):
|
|
20
|
+
render(mod: Mod<State>, context: WidgetContext): JSX.Element | undefined
|
|
22
21
|
}
|
|
23
22
|
|
|
24
23
|
export type Widget = {
|
package/src/ui/components.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { RenderChildren, RenderElement } from 'claude-code'
|
|
2
1
|
import { Box, Button, Text } from './elements.js'
|
|
3
2
|
|
|
4
3
|
export type Tab = { readonly key: string; readonly label: string; readonly hotkey?: string }
|
|
5
4
|
|
|
6
|
-
export function Tabs({ tabs, selected, onSelect, children }: { readonly tabs: readonly Tab[]; readonly selected: string; readonly onSelect: (key: string) => void; readonly children?:
|
|
5
|
+
export function Tabs({ tabs, selected, onSelect, children }: { readonly tabs: readonly Tab[]; readonly selected: string; readonly onSelect: (key: string) => void; readonly children?: JSX.Children }): JSX.Element {
|
|
7
6
|
const row = tabs.map(({ key, label, hotkey }) =>
|
|
8
7
|
key === selected
|
|
9
8
|
? Text({ children: [...(hotkey === undefined ? [] : [Text({ color: 'claude', children: hotkey }), ': ']), Text({ bold: true, underline: true, children: label })] })
|
|
@@ -12,12 +11,12 @@ export function Tabs({ tabs, selected, onSelect, children }: { readonly tabs: re
|
|
|
12
11
|
return Box({ flexDirection: 'column', gap: 1, children: [Box({ gap: 3, children: row }), children] })
|
|
13
12
|
}
|
|
14
13
|
|
|
15
|
-
export function Split({ children }: { readonly children: readonly
|
|
14
|
+
export function Split({ children }: { readonly children: readonly JSX.Element[] }): JSX.Element {
|
|
16
15
|
const width = `${Math.floor(100 / Math.max(children.length, 1))}%`
|
|
17
16
|
return Box({ gap: 1, children: children.map((child) => Box({ width, children: child })) })
|
|
18
17
|
}
|
|
19
18
|
|
|
20
|
-
export function Panel({ title, children }: { readonly title: string; readonly children?:
|
|
19
|
+
export function Panel({ title, children }: { readonly title: string; readonly children?: JSX.Children }): JSX.Element {
|
|
21
20
|
return Box({
|
|
22
21
|
flexDirection: 'column',
|
|
23
22
|
flexGrow: 1,
|
|
@@ -28,23 +27,23 @@ export function Panel({ title, children }: { readonly title: string; readonly ch
|
|
|
28
27
|
})
|
|
29
28
|
}
|
|
30
29
|
|
|
31
|
-
export function Toggle({ label, checked, onChange }: { readonly label: string; readonly checked: boolean; readonly onChange: (checked: boolean) => void }):
|
|
30
|
+
export function Toggle({ label, checked, onChange }: { readonly label: string; readonly checked: boolean; readonly onChange: (checked: boolean) => void }): JSX.Element {
|
|
32
31
|
return Button({ plain: true, key: `toggle:${label}`, label: `${checked ? '[x]' : '[ ]'} ${label}`, onPress: () => onChange(!checked) })
|
|
33
32
|
}
|
|
34
33
|
|
|
35
|
-
export function Tooltip({ text, children }: { readonly text: string; readonly children?:
|
|
34
|
+
export function Tooltip({ text, children }: { readonly text: string; readonly children?: JSX.Children }): JSX.Element {
|
|
36
35
|
return Box({ key: `tooltip:${text}`, children: [children, card(text, false)] })
|
|
37
36
|
}
|
|
38
37
|
|
|
39
|
-
export function Help({ text, isOpen, onOpenChange }: { readonly text: string; readonly isOpen: boolean; readonly onOpenChange: (isOpen: boolean) => void }):
|
|
38
|
+
export function Help({ text, isOpen, onOpenChange }: { readonly text: string; readonly isOpen: boolean; readonly onOpenChange: (isOpen: boolean) => void }): JSX.Element {
|
|
40
39
|
return Box({ key: `help:${text}`, children: [Button({ plain: true, key: `help-button:${text}`, label: '?', onPress: () => onOpenChange(!isOpen) }), card(text, isOpen)] })
|
|
41
40
|
}
|
|
42
41
|
|
|
43
|
-
export function Dialog({ title, children, actions }: { readonly title: string; readonly children?:
|
|
42
|
+
export function Dialog({ title, children, actions }: { readonly title: string; readonly children?: JSX.Children; readonly actions: JSX.Children }): JSX.Element {
|
|
44
43
|
return Box({ flexDirection: 'column', gap: 1, paddingX: 1, children: [Text({ bold: true, children: title }), children, Box({ gap: 2, children: actions })] })
|
|
45
44
|
}
|
|
46
45
|
|
|
47
|
-
export function Pagination({ page, pages, onPage }: { readonly page: number; readonly pages: number; readonly onPage: (page: number) => void }):
|
|
46
|
+
export function Pagination({ page, pages, onPage }: { readonly page: number; readonly pages: number; readonly onPage: (page: number) => void }): JSX.Element {
|
|
48
47
|
return Box({
|
|
49
48
|
gap: 2,
|
|
50
49
|
children: [
|
|
@@ -55,14 +54,14 @@ export function Pagination({ page, pages, onPage }: { readonly page: number; rea
|
|
|
55
54
|
})
|
|
56
55
|
}
|
|
57
56
|
|
|
58
|
-
export function Progress({ value, width = 24 }: { readonly value: number; readonly width?: number }):
|
|
57
|
+
export function Progress({ value, width = 24 }: { readonly value: number; readonly width?: number }): JSX.Element {
|
|
59
58
|
const filled = Math.round((Math.min(Math.max(value, 0), 100) / 100) * width)
|
|
60
59
|
return Text({ children: [Text({ color: 'claude', children: '█'.repeat(filled) }), Text({ color: 'subtle', children: '░'.repeat(width - filled) })] })
|
|
61
60
|
}
|
|
62
61
|
|
|
63
62
|
const cardColumns = 36
|
|
64
63
|
|
|
65
|
-
function card(text: string, isShown: boolean):
|
|
64
|
+
function card(text: string, isShown: boolean): JSX.Element {
|
|
66
65
|
return Box({
|
|
67
66
|
position: 'absolute',
|
|
68
67
|
bottom: 1,
|
package/src/ui/elements.ts
CHANGED
|
@@ -1,4 +1,39 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
BoxProps as ClaudeBoxProps,
|
|
3
|
+
ButtonProps as ClaudeButtonProps,
|
|
4
|
+
ClientProps as ClaudeClientProps,
|
|
5
|
+
CodeProps as ClaudeCodeProps,
|
|
6
|
+
Color as ClaudeColor,
|
|
7
|
+
ElementConstructor,
|
|
8
|
+
ElementName,
|
|
9
|
+
ElementTable,
|
|
10
|
+
Elements,
|
|
11
|
+
ImageProps as ClaudeImageProps,
|
|
12
|
+
InputProps as ClaudeInputProps,
|
|
13
|
+
MarkdownProps as ClaudeMarkdownProps,
|
|
14
|
+
RasterProps as ClaudeRasterProps,
|
|
15
|
+
RenderElement,
|
|
16
|
+
RenderSurface,
|
|
17
|
+
SelectProps as ClaudeSelectProps,
|
|
18
|
+
SvgProps as ClaudeSvgProps,
|
|
19
|
+
TextProps as ClaudeTextProps,
|
|
20
|
+
UiPressArgument,
|
|
21
|
+
} from 'claude-code'
|
|
22
|
+
|
|
23
|
+
export type BoxProps = ClaudeBoxProps
|
|
24
|
+
export type TextProps = ClaudeTextProps
|
|
25
|
+
export type CodeProps = ClaudeCodeProps
|
|
26
|
+
export type MarkdownProps = ClaudeMarkdownProps
|
|
27
|
+
export type InputProps = ClaudeInputProps
|
|
28
|
+
export type SelectProps = ClaudeSelectProps
|
|
29
|
+
export type ImageProps = ClaudeImageProps
|
|
30
|
+
export type SvgProps = ClaudeSvgProps
|
|
31
|
+
export type RasterProps = ClaudeRasterProps
|
|
32
|
+
export type ClientProps = ClaudeClientProps
|
|
33
|
+
export type Color = ClaudeColor
|
|
34
|
+
export type Press = UiPressArgument
|
|
35
|
+
|
|
36
|
+
export type ButtonProps = Omit<ClaudeButtonProps, 'onPress'> & ({ readonly onPress: (press: Press) => void; readonly href?: never } | { readonly href: string; readonly onPress?: never })
|
|
2
37
|
|
|
3
38
|
type Terminal = Elements['terminal'] & Elements['desktop']
|
|
4
39
|
|
|
@@ -104,10 +139,23 @@ export function drawsFocusable(data: unknown, key: string): boolean {
|
|
|
104
139
|
return Object.values(fields).some((each) => drawsFocusable(each, key))
|
|
105
140
|
}
|
|
106
141
|
|
|
142
|
+
export function withLinks(table: ElementTable, surface: RenderSurface, open: (href: string, press: Press) => void): ElementTable {
|
|
143
|
+
const { Button: button, Link: link } = table as CompletedTable
|
|
144
|
+
const opening = (props: Readonly<Record<string, unknown>>) => {
|
|
145
|
+
const { href, ...rest } = props
|
|
146
|
+
if (typeof href !== 'string') return button(props)
|
|
147
|
+
const { label, children } = rest
|
|
148
|
+
const hasChildren = children !== undefined && !(Array.isArray(children) && children.length === 0)
|
|
149
|
+
if (surface !== 'terminal' && href.startsWith('https:')) return link({ href, ...(typeof label === 'string' ? { label } : {}), ...(hasChildren ? { children } : {}) })
|
|
150
|
+
return button({ ...rest, onPress: (press: Press) => open(href, press) })
|
|
151
|
+
}
|
|
152
|
+
return { ...table, Button: opening }
|
|
153
|
+
}
|
|
154
|
+
|
|
107
155
|
export const Box = element('Box')
|
|
108
156
|
export const Text = element('Text')
|
|
109
|
-
export const Button = element('Button')
|
|
110
|
-
|
|
157
|
+
export const Button = element('Button') as unknown as ElementConstructor<ButtonProps>
|
|
158
|
+
const Link = element('Link')
|
|
111
159
|
export const Code = element('Code')
|
|
112
160
|
export const Markdown = element('Markdown')
|
|
113
161
|
export const Input = element('Input')
|
package/src/ui/panes.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import type { Frozen, PaneCloseInput,
|
|
1
|
+
import type { Frozen, PaneCloseInput, RenderPropsOf, UiScrollInput } from 'claude-code'
|
|
2
2
|
import type { Mod, Surface } from '../mod.js'
|
|
3
3
|
|
|
4
|
+
export type PaneScroll = Frozen<UiScrollInput>
|
|
5
|
+
|
|
6
|
+
export type PaneClose = Frozen<PaneCloseInput>
|
|
7
|
+
|
|
4
8
|
export type ScrollTarget = 'start' | 'end' | { readonly key: string }
|
|
5
9
|
|
|
6
10
|
export type ScrollOptions = { readonly block?: 'start' | 'center' | 'end' | 'nearest' }
|
|
@@ -16,9 +20,9 @@ export type PaneInit<State extends object = Record<never, never>, Params = undef
|
|
|
16
20
|
readonly rows?: number | ((state: State) => number | undefined)
|
|
17
21
|
readonly closeOnEscape?: true
|
|
18
22
|
readonly holdToasts?: true
|
|
19
|
-
render(mod: Mod<State>, props: PaneProps<Params>):
|
|
20
|
-
onScroll?(mod: Mod<State>,
|
|
21
|
-
onClose?(mod: Mod<State>,
|
|
23
|
+
render(mod: Mod<State>, props: PaneProps<Params>): JSX.Element
|
|
24
|
+
onScroll?(mod: Mod<State>, scroll: PaneScroll): void | Promise<void>
|
|
25
|
+
onClose?(mod: Mod<State>, close: PaneClose): void | Promise<void>
|
|
22
26
|
}
|
|
23
27
|
|
|
24
28
|
export type Pane<Params = undefined> = {
|
|
@@ -40,7 +44,7 @@ export type PageProps<Params> = { readonly params: Params; readonly isFocused: b
|
|
|
40
44
|
export type PageInit<State extends object = Record<never, never>, Params = undefined> = {
|
|
41
45
|
readonly id: string
|
|
42
46
|
readonly title: string
|
|
43
|
-
render(mod: Mod<State>, props: PageProps<Params>):
|
|
47
|
+
render(mod: Mod<State>, props: PageProps<Params>): JSX.Element
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
export type Page<Params = undefined> = {
|
package/src/ui/styles.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Frozen, RenderComponent,
|
|
1
|
+
import type { Frozen, RenderComponent, RenderPropsOf } from 'claude-code'
|
|
2
2
|
import type { Mod, Surface } from '../mod.js'
|
|
3
3
|
import { TurnEnd, Working } from './areas.js'
|
|
4
4
|
import type { Block, BlockProps } from './markdown.js'
|
|
@@ -32,7 +32,7 @@ type PropsOf<K extends Kind> = K extends Row ? RowProps[K] : K extends Block<inf
|
|
|
32
32
|
|
|
33
33
|
type DefaultOf<K extends Kind> = K extends Row ? Partial<Omit<RowProps[K], 'onScreen'>> : { readonly source?: string }
|
|
34
34
|
|
|
35
|
-
export type StyleProps<K extends Kind> = Frozen<PropsOf<K>> & StyledAt & (K extends Row ? { readonly id: string } : { readonly id?: string }) & { readonly Default: (props: Frozen<DefaultOf<K>>) =>
|
|
35
|
+
export type StyleProps<K extends Kind> = Frozen<PropsOf<K>> & StyledAt & (K extends Row ? { readonly id: string } : { readonly id?: string }) & { readonly Default: (props: Frozen<DefaultOf<K>>) => JSX.Element }
|
|
36
36
|
|
|
37
37
|
export type KindProps<K extends Kind> = Omit<StyleProps<K>, 'Default' | 'surface' | 'columns' | 'id'>
|
|
38
38
|
|
|
@@ -40,7 +40,7 @@ export type StyledAt = { readonly surface: Surface; readonly columns: number }
|
|
|
40
40
|
|
|
41
41
|
export type StyleInit<K extends Kind, State extends object = Record<never, never>> = {
|
|
42
42
|
readonly kind: K
|
|
43
|
-
render(mod: Mod<State>, props: StyleProps<K>):
|
|
43
|
+
render(mod: Mod<State>, props: StyleProps<K>): JSX.Element
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
export type Style = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fake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Y,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,WAAW,CAAC,GAAG,OAAO,CAGtF;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,UAAU,CAoM/F"}
|
package/testing/fake-claude.js
CHANGED
|
@@ -185,6 +185,10 @@ export function fakeClaude(plugin) {
|
|
|
185
185
|
home: async () => '/test/home',
|
|
186
186
|
dataHome: async () => undefined,
|
|
187
187
|
configHome: async () => undefined,
|
|
188
|
+
browser: async () => undefined,
|
|
189
|
+
sshConnection: async () => undefined,
|
|
190
|
+
display: async () => undefined,
|
|
191
|
+
waylandDisplay: async () => undefined,
|
|
188
192
|
},
|
|
189
193
|
device: { read: rejected('device.read', () => fakes.device.read ?? (async () => testDevice)) },
|
|
190
194
|
cmod: { call: async (args) => cmodCall(clonedAsClaudeCodeDoes(args)) },
|
package/testing.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Args, CmodDependencies, EventResult
|
|
1
|
+
import type { Args, CmodDependencies, EventResult } from 'claude-code';
|
|
2
2
|
import type { CommandReply } from './jobs/slash-command.js';
|
|
3
3
|
import type { ModDefinition } from './mod.js';
|
|
4
4
|
import type { Options, OptionValues } from './options.js';
|
|
@@ -21,7 +21,7 @@ export type ShownPart = {
|
|
|
21
21
|
readonly columns?: number;
|
|
22
22
|
}): Promise<string[]>;
|
|
23
23
|
press(key: string, link?: string): Promise<void>;
|
|
24
|
-
input(key: string, text: string, type?:
|
|
24
|
+
input(key: string, text: string, type?: 'change' | 'submit'): Promise<void>;
|
|
25
25
|
select(key: string, value: string): Promise<void>;
|
|
26
26
|
focusedKey(): Promise<string | undefined>;
|
|
27
27
|
};
|
package/testing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.d.ts","sourceRo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AO,CAAC,IAAI,CAAC,CAAA;IACxD,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;IAC7E,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAA;IAC/B,QAAQ,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,CAAA;IACnC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;IACrB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;CACtB,CAAA;AAqBD,wBAAgB,OAAO,CAAC,KAAK,SAAS,MAAM,EAAE,QAAQ,SAAS,OAAO,GAAG,OAAO,EAAE,UAAU,EAAE,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAE,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAM,GAAG,SAAS,CAAC,KAAK,CAAC,CAkpBlM"}
|
package/testing.js
CHANGED
|
@@ -26,12 +26,12 @@ import { fakeSessions } from './testing/fake-sessions.js';
|
|
|
26
26
|
import { listed, messageOf } from './utils/text.js';
|
|
27
27
|
import { componentOf } from './ui/styles.js';
|
|
28
28
|
import { AbovePrompt, areas, BelowPrompt, Dashboard, TurnEnd as TurnEndArea, Working } from './ui/areas.js';
|
|
29
|
-
import { drawWith, elementOf } from './ui/elements.js';
|
|
29
|
+
import { drawWith, elementOf, withLinks } from './ui/elements.js';
|
|
30
30
|
import { drawnParts } from './runtime/parts.js';
|
|
31
31
|
import { serveWidgets } from './runtime/widgets.js';
|
|
32
32
|
import { engineOf } from './runtime/engine.js';
|
|
33
33
|
import { pagesOf, servePages } from './runtime/pages.js';
|
|
34
|
-
import { inheriting, partMethods } from './runtime/ui.js';
|
|
34
|
+
import { inheriting, openLink, partMethods } from './runtime/ui.js';
|
|
35
35
|
const defaultColumns = 80;
|
|
36
36
|
const defaultRows = 24;
|
|
37
37
|
const presentation = { isFullscreen: false, columns: defaultColumns };
|
|
@@ -191,8 +191,13 @@ export function testMod(definition, options = {}) {
|
|
|
191
191
|
missedMarkdown.clear();
|
|
192
192
|
return draw();
|
|
193
193
|
};
|
|
194
|
-
const cmodClaude = { ...fake.claude, cmod: { call: async (input) => (input.to === name ? callMod(input.method, input.input) : fake.claude.cmod.call(input)) } };
|
|
195
194
|
const reportPart = (_id, message, error) => fake.claude.ui.log(`cmod: ${message}: ${messageOf(error)}`, { to: 'debug' });
|
|
195
|
+
const openFromCmod = (href, press) => void openLink(fake.claude, href, press.surface).catch((error) => reportPart('open-link', 'Could not open the link', error));
|
|
196
|
+
const cmodClaude = {
|
|
197
|
+
...fake.claude,
|
|
198
|
+
ui: { ...fake.claude.ui, resolve: (e) => withLinks(fake.claude.ui.resolve(e), e.surface, openFromCmod) },
|
|
199
|
+
cmod: { call: async (input) => (input.to === name ? callMod(input.method, input.input) : fake.claude.cmod.call(input)) },
|
|
200
|
+
};
|
|
196
201
|
const tellRefusedPress = (_mod, error) => fake.claude.ui.log(`cmod: ${name} did not take the press: ${messageOf(error)}`, { to: 'debug' });
|
|
197
202
|
const parts = drawnParts({ claude: cmodClaude, report: reportPart, press: (mod, input) => void pressPart(input).catch((error) => tellRefusedPress(mod, error)) });
|
|
198
203
|
const servedWidgets = async () => {
|
|
@@ -427,7 +432,8 @@ export function testMod(definition, options = {}) {
|
|
|
427
432
|
const drawn = (await callMod(partMethods.draw, { page: pageId, params: page.params, columns, isFocused: page.isFocused }));
|
|
428
433
|
await fake.settle();
|
|
429
434
|
const tree = drawn?.tree ?? null;
|
|
430
|
-
const
|
|
435
|
+
const table = withLinks(elements, 'terminal', openFromCmod);
|
|
436
|
+
const drawing = tree === null || drawn === null ? elements.Box({}) : await withOwnMarkdown(async () => drawWith(table, () => elementOf(tree, `${name}/${pageId}:`, (handler, args) => void modeling(pressPart({ draw: drawn.draw, handler, args }))), markdownIn(table, { surface: 'terminal', columns })));
|
|
431
437
|
checkKeys(drawing, cmodPluginName, 'Pane');
|
|
432
438
|
return { drawing, columns };
|
|
433
439
|
};
|
package/ui/areas.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { RenderElement } from 'claude-code';
|
|
2
1
|
import type { Mod, Turn } from '../mod.js';
|
|
3
2
|
export declare const AbovePrompt = "abovePrompt";
|
|
4
3
|
export declare const BelowPrompt = "belowPrompt";
|
|
@@ -23,7 +22,7 @@ export type WidgetInit<State extends object = Record<never, never>> = {
|
|
|
23
22
|
readonly side?: 'left' | 'right';
|
|
24
23
|
readonly size?: 'fit' | 'fill';
|
|
25
24
|
};
|
|
26
|
-
render(mod: Mod<State>, context: WidgetContext):
|
|
25
|
+
render(mod: Mod<State>, context: WidgetContext): JSX.Element | undefined;
|
|
27
26
|
};
|
|
28
27
|
export type Widget = {
|
|
29
28
|
readonly id: string;
|
package/ui/areas.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"areas.d.ts","sourceRoot":"","sources":["../src/ui/areas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"areas.d.ts","sourceRoot":"","sources":["../src/ui/areas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAE1C,eAAO,MAAM,WAAW,gBAAgB,CAAA;AACxC,eAAO,MAAM,WAAW,gBAAgB,CAAA;AACxC,eAAO,MAAM,OAAO,YAAY,CAAA;AAChC,eAAO,MAAM,OAAO,YAAY,CAAA;AAChC,eAAO,MAAM,SAAS,cAAc,CAAA;AAEpC,eAAO,MAAM,KAAK,4EAAmE,CAAA;AAErF,MAAM,MAAM,IAAI,GAAG,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,CAAA;AAEzC,MAAM,MAAM,aAAa,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,OAAO,C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