@pyxis-llm/react 0.0.0-stage → 0.5.3
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/dist/AgentProfileEditor.d.ts +48 -0
- package/dist/AgentProfileEditor.d.ts.map +1 -0
- package/dist/AgentProfileEditor.js +122 -0
- package/dist/AgentProfileList.d.ts +17 -0
- package/dist/AgentProfileList.d.ts.map +1 -0
- package/dist/AgentProfileList.js +46 -0
- package/dist/AskCardAnswerChip.d.ts +8 -0
- package/dist/AskCardAnswerChip.d.ts.map +1 -0
- package/dist/AskCardAnswerChip.js +21 -0
- package/dist/AskCardView.d.ts +85 -0
- package/dist/AskCardView.d.ts.map +1 -0
- package/dist/AskCardView.js +158 -0
- package/dist/CatalogColumnBrowser.d.ts +33 -0
- package/dist/CatalogColumnBrowser.d.ts.map +1 -0
- package/dist/CatalogColumnBrowser.js +219 -0
- package/dist/CatalogModelPicker.d.ts +68 -0
- package/dist/CatalogModelPicker.d.ts.map +1 -0
- package/dist/CatalogModelPicker.js +119 -0
- package/dist/CatalogModelPickerMenuContent.d.ts +17 -0
- package/dist/CatalogModelPickerMenuContent.d.ts.map +1 -0
- package/dist/CatalogModelPickerMenuContent.js +103 -0
- package/dist/CatalogPickerMenuItem.d.ts +17 -0
- package/dist/CatalogPickerMenuItem.d.ts.map +1 -0
- package/dist/CatalogPickerMenuItem.js +15 -0
- package/dist/CatalogTreePickerOptions.d.ts +52 -0
- package/dist/CatalogTreePickerOptions.d.ts.map +1 -0
- package/dist/CatalogTreePickerOptions.js +248 -0
- package/dist/ChatMessage.d.ts +172 -0
- package/dist/ChatMessage.d.ts.map +1 -0
- package/dist/ChatMessage.js +295 -0
- package/dist/ChatPanel.d.ts +252 -0
- package/dist/ChatPanel.d.ts.map +1 -0
- package/dist/ChatPanel.js +247 -0
- package/dist/ChatTranscriptFind.d.ts +19 -0
- package/dist/ChatTranscriptFind.d.ts.map +1 -0
- package/dist/ChatTranscriptFind.js +224 -0
- package/dist/ChatTranscriptFindBar.d.ts +15 -0
- package/dist/ChatTranscriptFindBar.d.ts.map +1 -0
- package/dist/ChatTranscriptFindBar.js +22 -0
- package/dist/Composer.d.ts +43 -0
- package/dist/Composer.d.ts.map +1 -0
- package/dist/Composer.js +45 -0
- package/dist/ComposerAttachments.d.ts +101 -0
- package/dist/ComposerAttachments.d.ts.map +1 -0
- package/dist/ComposerAttachments.js +126 -0
- package/dist/DisplayCards.d.ts +18 -0
- package/dist/DisplayCards.d.ts.map +1 -0
- package/dist/DisplayCards.js +72 -0
- package/dist/ErrorBoundary.d.ts +27 -0
- package/dist/ErrorBoundary.d.ts.map +1 -0
- package/dist/ErrorBoundary.js +107 -0
- package/dist/ImageDisplayCard.d.ts +6 -0
- package/dist/ImageDisplayCard.d.ts.map +1 -0
- package/dist/ImageDisplayCard.js +57 -0
- package/dist/MarkdownCodeComponents.d.ts +23 -0
- package/dist/MarkdownCodeComponents.d.ts.map +1 -0
- package/dist/MarkdownCodeComponents.js +256 -0
- package/dist/MermaidDiagram.d.ts +18 -0
- package/dist/MermaidDiagram.d.ts.map +1 -0
- package/dist/MermaidDiagram.js +66 -0
- package/dist/MessageContentWithPastes.d.ts +14 -0
- package/dist/MessageContentWithPastes.d.ts.map +1 -0
- package/dist/MessageContentWithPastes.js +44 -0
- package/dist/PastePill.d.ts +16 -0
- package/dist/PastePill.d.ts.map +1 -0
- package/dist/PastePill.js +43 -0
- package/dist/ProviderAuthTerminal.d.ts +12 -0
- package/dist/ProviderAuthTerminal.d.ts.map +1 -0
- package/dist/ProviderAuthTerminal.js +50 -0
- package/dist/ProviderConnectForm.d.ts +62 -0
- package/dist/ProviderConnectForm.d.ts.map +1 -0
- package/dist/ProviderConnectForm.js +206 -0
- package/dist/ProviderList.d.ts +18 -0
- package/dist/ProviderList.d.ts.map +1 -0
- package/dist/ProviderList.js +67 -0
- package/dist/QueueStrip.d.ts +17 -0
- package/dist/QueueStrip.d.ts.map +1 -0
- package/dist/QueueStrip.js +60 -0
- package/dist/SettingsScreen.d.ts +10 -0
- package/dist/SettingsScreen.d.ts.map +1 -0
- package/dist/SettingsScreen.js +26 -0
- package/dist/StreamingMarkdown.d.ts +47 -0
- package/dist/StreamingMarkdown.d.ts.map +1 -0
- package/dist/StreamingMarkdown.js +103 -0
- package/dist/TurnTimer.d.ts +72 -0
- package/dist/TurnTimer.d.ts.map +1 -0
- package/dist/TurnTimer.js +114 -0
- package/dist/VegaChart.d.ts +36 -0
- package/dist/VegaChart.d.ts.map +1 -0
- package/dist/VegaChart.js +180 -0
- package/dist/browser.d.ts +7 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +18 -0
- package/dist/catalogColumnBrowserTree.d.ts +9 -0
- package/dist/catalogColumnBrowserTree.d.ts.map +1 -0
- package/dist/catalogColumnBrowserTree.js +48 -0
- package/dist/catalogPickerMenuStyles.d.ts +81 -0
- package/dist/catalogPickerMenuStyles.d.ts.map +1 -0
- package/dist/catalogPickerMenuStyles.js +130 -0
- package/dist/charts.d.ts +12 -0
- package/dist/charts.d.ts.map +1 -0
- package/dist/charts.js +45 -0
- package/dist/chatMessageScroll.d.ts +40 -0
- package/dist/chatMessageScroll.d.ts.map +1 -0
- package/dist/chatMessageScroll.js +62 -0
- package/dist/chatModelOptions.d.ts +28 -0
- package/dist/chatModelOptions.d.ts.map +1 -0
- package/dist/chatModelOptions.js +59 -0
- package/dist/chatTranscriptFindHighlights.d.ts +9 -0
- package/dist/chatTranscriptFindHighlights.d.ts.map +1 -0
- package/dist/chatTranscriptFindHighlights.js +88 -0
- package/dist/draftStore.d.ts +13 -0
- package/dist/draftStore.d.ts.map +1 -0
- package/dist/draftStore.js +38 -0
- package/dist/highlight.d.ts +4 -0
- package/dist/highlight.d.ts.map +1 -0
- package/dist/highlight.js +47 -0
- package/dist/index.d.ts +74 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +48 -0
- package/dist/keyboardShortcuts.d.ts +5 -0
- package/dist/keyboardShortcuts.d.ts.map +1 -0
- package/dist/keyboardShortcuts.js +19 -0
- package/dist/markdownClipboard.d.ts +22 -0
- package/dist/markdownClipboard.d.ts.map +1 -0
- package/dist/markdownClipboard.js +98 -0
- package/dist/markdownPlugins.d.ts +31 -0
- package/dist/markdownPlugins.d.ts.map +1 -0
- package/dist/markdownPlugins.js +32 -0
- package/dist/mermaid.d.ts +17 -0
- package/dist/mermaid.d.ts.map +1 -0
- package/dist/mermaid.js +11 -0
- package/dist/mermaidRuntime.d.ts +21 -0
- package/dist/mermaidRuntime.d.ts.map +1 -0
- package/dist/mermaidRuntime.js +140 -0
- package/dist/modelCatalogHelpers.d.ts +14 -0
- package/dist/modelCatalogHelpers.d.ts.map +1 -0
- package/dist/modelCatalogHelpers.js +65 -0
- package/dist/modelCatalogSource.d.ts +22 -0
- package/dist/modelCatalogSource.d.ts.map +1 -0
- package/dist/modelCatalogSource.js +26 -0
- package/dist/modelCatalogTree.d.ts +24 -0
- package/dist/modelCatalogTree.d.ts.map +1 -0
- package/dist/modelCatalogTree.js +77 -0
- package/dist/node.d.ts +9 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +13 -0
- package/dist/pasteFences.d.ts +20 -0
- package/dist/pasteFences.d.ts.map +1 -0
- package/dist/pasteFences.js +157 -0
- package/dist/pasteFormat.d.ts +5 -0
- package/dist/pasteFormat.d.ts.map +1 -0
- package/dist/pasteFormat.js +18 -0
- package/dist/plugins.d.ts +110 -0
- package/dist/plugins.d.ts.map +1 -0
- package/dist/plugins.js +98 -0
- package/dist/remarkAlerts.d.ts +12 -0
- package/dist/remarkAlerts.d.ts.map +1 -0
- package/dist/remarkAlerts.js +52 -0
- package/dist/sendMode.d.ts +69 -0
- package/dist/sendMode.d.ts.map +1 -0
- package/dist/sendMode.js +66 -0
- package/dist/useLlmdChatDriver.d.ts +367 -0
- package/dist/useLlmdChatDriver.d.ts.map +1 -0
- package/dist/useLlmdChatDriver.js +1739 -0
- package/dist/useLlmdModelCatalog.d.ts +23 -0
- package/dist/useLlmdModelCatalog.d.ts.map +1 -0
- package/dist/useLlmdModelCatalog.js +89 -0
- package/dist/useLlmdSessionModel.d.ts +34 -0
- package/dist/useLlmdSessionModel.d.ts.map +1 -0
- package/dist/useLlmdSessionModel.js +79 -0
- package/dist/useProviderAuthCommand.d.ts +26 -0
- package/dist/useProviderAuthCommand.d.ts.map +1 -0
- package/dist/useProviderAuthCommand.js +80 -0
- package/dist/vegaRuntime.d.ts +83 -0
- package/dist/vegaRuntime.d.ts.map +1 -0
- package/dist/vegaRuntime.js +314 -0
- package/dist/vendor/llmd-types/conversationEvents.d.ts +238 -0
- package/dist/vendor/llmd-types/conversationEvents.d.ts.map +1 -0
- package/dist/vendor/llmd-types/conversationEvents.js +98 -0
- package/dist/vendor/llmd-types/index.d.ts +4 -0
- package/dist/vendor/llmd-types/index.d.ts.map +1 -0
- package/dist/vendor/llmd-types/index.js +5 -0
- package/dist/vendor/llmd-types/messages.d.ts +67 -0
- package/dist/vendor/llmd-types/messages.d.ts.map +1 -0
- package/dist/vendor/llmd-types/messages.js +71 -0
- package/dist/vendor/llmd-types/sessionQueue.d.ts +54 -0
- package/dist/vendor/llmd-types/sessionQueue.d.ts.map +1 -0
- package/dist/vendor/llmd-types/sessionQueue.js +40 -0
- package/package.json +120 -4
- package/styles.css +389 -0
- package/README.md +0 -3
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 John Ewart <john@johnewart.net>
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
/** Picker menu text size — sm (14px) for comfortable readability. */
|
|
6
|
+
export const CATALOG_PICKER_MENU_FONT_SIZE = 'var(--mantine-font-size-sm)';
|
|
7
|
+
/** Horizontal inset for picker menu item divider lines (not full-width). */
|
|
8
|
+
export const CATALOG_PICKER_ITEM_DIVIDER_INSET = 10;
|
|
9
|
+
/** Finder-style selection fill for active parent rows and child panes. */
|
|
10
|
+
export const CATALOG_PICKER_ACTIVE_BACKGROUND = 'var(--mantine-primary-color-light)';
|
|
11
|
+
/** Text on active picker rows. */
|
|
12
|
+
export const CATALOG_PICKER_ACTIVE_COLOR = 'var(--mantine-primary-color-light-color)';
|
|
13
|
+
/** Fixed height for the column browser and filter-result lists. */
|
|
14
|
+
export const CATALOG_PICKER_BROWSER_HEIGHT = 280;
|
|
15
|
+
/** Single-column picker dropdown width. */
|
|
16
|
+
export const CATALOG_PICKER_DROPDOWN_SINGLE_COLUMN_WIDTH = 280;
|
|
17
|
+
/** Two-column picker dropdown width (double the single-column width). */
|
|
18
|
+
export const CATALOG_PICKER_DROPDOWN_TWO_COLUMN_WIDTH = CATALOG_PICKER_DROPDOWN_SINGLE_COLUMN_WIDTH * 2;
|
|
19
|
+
export function catalogPickerBrowserFrameStyle() {
|
|
20
|
+
return {
|
|
21
|
+
display: 'flex',
|
|
22
|
+
width: '100%',
|
|
23
|
+
height: CATALOG_PICKER_BROWSER_HEIGHT,
|
|
24
|
+
maxHeight: CATALOG_PICKER_BROWSER_HEIGHT,
|
|
25
|
+
overflow: 'hidden',
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export function catalogPickerColumnScrollStyle() {
|
|
29
|
+
return {
|
|
30
|
+
flex: 1,
|
|
31
|
+
minHeight: 0,
|
|
32
|
+
overflowY: 'auto',
|
|
33
|
+
overflowX: 'hidden',
|
|
34
|
+
WebkitOverflowScrolling: 'touch',
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export function catalogPickerSearchResultsScrollStyle() {
|
|
38
|
+
return {
|
|
39
|
+
maxHeight: CATALOG_PICKER_BROWSER_HEIGHT,
|
|
40
|
+
overflowY: 'auto',
|
|
41
|
+
overflowX: 'hidden',
|
|
42
|
+
WebkitOverflowScrolling: 'touch',
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/** Sticky footer row pinned to the bottom of a column browser pane (e.g. "Reload models"). */
|
|
46
|
+
export function catalogPickerColumnFooterStyle() {
|
|
47
|
+
return {
|
|
48
|
+
flexShrink: 0,
|
|
49
|
+
borderTop: '1px solid var(--mantine-color-default-border)',
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export function catalogPickerInsetDividerStyle() {
|
|
53
|
+
return {
|
|
54
|
+
height: 1,
|
|
55
|
+
marginLeft: CATALOG_PICKER_ITEM_DIVIDER_INSET,
|
|
56
|
+
marginRight: CATALOG_PICKER_ITEM_DIVIDER_INSET,
|
|
57
|
+
backgroundColor: 'var(--mantine-color-default-border)',
|
|
58
|
+
opacity: 0.45,
|
|
59
|
+
flexShrink: 0,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
export const catalogPickerMenuItemStyles = {
|
|
63
|
+
item: {
|
|
64
|
+
width: '100%',
|
|
65
|
+
paddingTop: 5,
|
|
66
|
+
paddingBottom: 5,
|
|
67
|
+
borderRadius: 0,
|
|
68
|
+
fontSize: CATALOG_PICKER_MENU_FONT_SIZE,
|
|
69
|
+
fontWeight: 500,
|
|
70
|
+
},
|
|
71
|
+
itemLabel: {
|
|
72
|
+
flex: 1,
|
|
73
|
+
minWidth: 0,
|
|
74
|
+
},
|
|
75
|
+
itemSection: {
|
|
76
|
+
marginInlineStart: 8,
|
|
77
|
+
flexShrink: 0,
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
export function catalogPickerMenuItemStylesForState(options) {
|
|
81
|
+
const active = options.selected || options.leafSelected;
|
|
82
|
+
return {
|
|
83
|
+
item: {
|
|
84
|
+
...catalogPickerMenuItemStyles.item,
|
|
85
|
+
...(active
|
|
86
|
+
? {
|
|
87
|
+
backgroundColor: CATALOG_PICKER_ACTIVE_BACKGROUND,
|
|
88
|
+
color: CATALOG_PICKER_ACTIVE_COLOR,
|
|
89
|
+
}
|
|
90
|
+
: {}),
|
|
91
|
+
},
|
|
92
|
+
itemLabel: catalogPickerMenuItemStyles.itemLabel,
|
|
93
|
+
itemSection: catalogPickerMenuItemStyles.itemSection,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
export function catalogPickerActiveColumnStyle() {
|
|
97
|
+
return {
|
|
98
|
+
backgroundColor: CATALOG_PICKER_ACTIVE_BACKGROUND,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export function catalogPickerActiveColumnHeaderStyle() {
|
|
102
|
+
return {
|
|
103
|
+
padding: '5px 10px 4px',
|
|
104
|
+
borderBottom: '1px solid var(--mantine-color-default-border)',
|
|
105
|
+
backgroundColor: CATALOG_PICKER_ACTIVE_BACKGROUND,
|
|
106
|
+
color: CATALOG_PICKER_ACTIVE_COLOR,
|
|
107
|
+
flexShrink: 0,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
export function catalogPickerMenuDropdownStyles(twoColumns = false) {
|
|
111
|
+
const width = twoColumns
|
|
112
|
+
? CATALOG_PICKER_DROPDOWN_TWO_COLUMN_WIDTH
|
|
113
|
+
: CATALOG_PICKER_DROPDOWN_SINGLE_COLUMN_WIDTH;
|
|
114
|
+
return {
|
|
115
|
+
dropdown: {
|
|
116
|
+
padding: 0,
|
|
117
|
+
overflow: 'hidden',
|
|
118
|
+
fontSize: CATALOG_PICKER_MENU_FONT_SIZE,
|
|
119
|
+
minWidth: width,
|
|
120
|
+
width,
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
/** Mantine Menu defaults that allow typing in the filter TextInput. */
|
|
125
|
+
export const catalogPickerMenuBehaviorProps = {
|
|
126
|
+
trapFocus: false,
|
|
127
|
+
};
|
|
128
|
+
export const catalogPickerMenuLabelStyle = {
|
|
129
|
+
fontSize: CATALOG_PICKER_MENU_FONT_SIZE,
|
|
130
|
+
};
|
package/dist/charts.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ChartBody } from '@pyxis-llm/core';
|
|
2
|
+
import { type DisplayCardRenderProps, type LlmdPlugin } from './plugins.js';
|
|
3
|
+
export type { VegaChartProps } from './VegaChart.js';
|
|
4
|
+
export { VegaChart, VegaLiteMarkdownCodeBlock, VegaMarkdownCodeBlock, VEGA_FONT_SCALES } from './VegaChart.js';
|
|
5
|
+
export type { RenderVegaOptions, RenderVegaResult, RenderVegaSvgOptions, RenderVegaSvgResult, VegaDataLoader, VegaMode } from './vegaRuntime.js';
|
|
6
|
+
export { VEGA_EXTERNAL_RESOURCE_ERROR, chartFontConfig, formatTooltip, resolveChartFont, prepareVegaSpec, renderVegaChart, renderVegaSvg, resetVegaRuntimeForTests, } from './vegaRuntime.js';
|
|
7
|
+
/** A `chart` display card: the spec rendered by VegaChart, which draws its own title and caption. */
|
|
8
|
+
export declare function ChartCardView({ card }: DisplayCardRenderProps<ChartBody>): import("react").FunctionComponentElement<import("./VegaChart.js").VegaChartProps>;
|
|
9
|
+
export declare const chartsPlugin: LlmdPlugin;
|
|
10
|
+
/** Registered on import; this undoes it. */
|
|
11
|
+
export declare const unregisterCharts: () => void;
|
|
12
|
+
//# sourceMappingURL=charts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"charts.d.ts","sourceRoot":"","sources":["../src/charts.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAoC,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACnF,OAAO,EAAsB,KAAK,sBAAsB,EAAE,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAGhG,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC/G,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjJ,OAAO,EACL,4BAA4B,EAC5B,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,aAAa,EACb,wBAAwB,GACzB,MAAM,kBAAkB,CAAC;AAE1B,qGAAqG;AACrG,wBAAgB,aAAa,CAAC,EAAE,IAAI,EAAE,EAAE,sBAAsB,CAAC,SAAS,CAAC,qFAGxE;AAED,eAAO,MAAM,YAAY,EAAE,UAU1B,CAAC;AAEF,4CAA4C;AAC5C,eAAO,MAAM,gBAAgB,YAAmC,CAAC"}
|
package/dist/charts.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 John Ewart <john@johnewart.net>
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* `@pyxis-llm/react/charts` — interactive Vega-Lite / Vega charts in chat:
|
|
7
|
+
* ```vega-lite (alias ```vegalite) and ```vega fences, and `chart` display
|
|
8
|
+
* cards (@pyxis-llm/core CHART_CARD_TYPE).
|
|
9
|
+
*
|
|
10
|
+
* import '@pyxis-llm/react/charts'; // that's all: it registers itself
|
|
11
|
+
*
|
|
12
|
+
* Importing this entry point registers `chartsPlugin` globally (see
|
|
13
|
+
* registerLlmdPlugin), so a host opts in by importing it. It is also
|
|
14
|
+
* exported, for a host that would rather scope it with LlmdPluginProvider —
|
|
15
|
+
* call `unregisterCharts()` first in that case.
|
|
16
|
+
*
|
|
17
|
+
* Requires the optional peers `vega`, `vega-lite` and `vega-embed`; they are
|
|
18
|
+
* loaded lazily, on the first chart, so importing this costs nothing until a
|
|
19
|
+
* chart appears. Specs are treated as untrusted: see vegaRuntime.ts for what
|
|
20
|
+
* is locked down.
|
|
21
|
+
*/
|
|
22
|
+
import { createElement, useMemo } from 'react';
|
|
23
|
+
import { CHART_CARD_TYPE, decodeChartBody } from '@pyxis-llm/core';
|
|
24
|
+
import { registerLlmdPlugin } from './plugins.js';
|
|
25
|
+
import { VegaChart, VegaLiteMarkdownCodeBlock, VegaMarkdownCodeBlock } from './VegaChart.js';
|
|
26
|
+
export { VegaChart, VegaLiteMarkdownCodeBlock, VegaMarkdownCodeBlock, VEGA_FONT_SCALES } from './VegaChart.js';
|
|
27
|
+
export { VEGA_EXTERNAL_RESOURCE_ERROR, chartFontConfig, formatTooltip, resolveChartFont, prepareVegaSpec, renderVegaChart, renderVegaSvg, resetVegaRuntimeForTests, } from './vegaRuntime.js';
|
|
28
|
+
/** A `chart` display card: the spec rendered by VegaChart, which draws its own title and caption. */
|
|
29
|
+
export function ChartCardView({ card }) {
|
|
30
|
+
const source = useMemo(() => JSON.stringify(card.body.spec), [card.body.spec]);
|
|
31
|
+
return createElement(VegaChart, { source, mode: card.body.format, title: card.title, caption: card.caption });
|
|
32
|
+
}
|
|
33
|
+
export const chartsPlugin = {
|
|
34
|
+
id: 'llmd.charts',
|
|
35
|
+
languages: {
|
|
36
|
+
'vega-lite': VegaLiteMarkdownCodeBlock,
|
|
37
|
+
vegalite: VegaLiteMarkdownCodeBlock,
|
|
38
|
+
vega: VegaMarkdownCodeBlock,
|
|
39
|
+
},
|
|
40
|
+
displayCards: {
|
|
41
|
+
[CHART_CARD_TYPE]: { decode: decodeChartBody, render: ChartCardView, ownsChrome: true },
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
/** Registered on import; this undoes it. */
|
|
45
|
+
export const unregisterCharts = registerLlmdPlugin(chartsPlugin);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DOM helpers for addressing a single message inside a scrolling transcript.
|
|
3
|
+
*
|
|
4
|
+
* `ChatMessage` stamps `data-message-id` on its root element, which makes
|
|
5
|
+
* `Message.id` the one stable address a host can point at — from a scroll
|
|
6
|
+
* request, a comment pin, a deep link. These helpers do the small amount of
|
|
7
|
+
* geometry that turns such an id into a scroll position, kept out of
|
|
8
|
+
* `ChatPanel` so they can be tested without rendering React.
|
|
9
|
+
*
|
|
10
|
+
* The centering arithmetic deliberately mirrors
|
|
11
|
+
* `scrollChatTranscriptMatchIntoView` (chatTranscriptFindHighlights.ts): assign
|
|
12
|
+
* `scrollTop` directly rather than call `scrollIntoView`, which is
|
|
13
|
+
* unimplemented in some test/embedded DOMs and, in a nested scroll container,
|
|
14
|
+
* tends to scroll ancestors too.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* How close to the bottom still counts as "parked at the bottom". Sub-pixel
|
|
18
|
+
* layout and fractional device pixel ratios mean an exact equality check
|
|
19
|
+
* reports "not at bottom" for a viewport the user considers fully scrolled.
|
|
20
|
+
*/
|
|
21
|
+
export declare const CHAT_PANEL_BOTTOM_THRESHOLD_PX = 32;
|
|
22
|
+
/**
|
|
23
|
+
* Finds the rendered root element for `messageId` within `viewport`.
|
|
24
|
+
*
|
|
25
|
+
* Scans the `data-message-id` attributes rather than using a
|
|
26
|
+
* `[data-message-id="…"]` selector: message ids come from the server and are
|
|
27
|
+
* not guaranteed to be selector-safe, and `CSS.escape` is absent in some
|
|
28
|
+
* embedded DOMs. Transcripts are small enough that the scan is irrelevant
|
|
29
|
+
* next to the layout work a scroll triggers anyway.
|
|
30
|
+
*/
|
|
31
|
+
export declare function findMessageElement(viewport: HTMLElement, messageId: string): HTMLElement | null;
|
|
32
|
+
/** Whether `viewport` is scrolled to (or within a hair of) its bottom. */
|
|
33
|
+
export declare function isPinnedToBottom(viewport: HTMLElement, thresholdPx?: number): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Scrolls `viewport` so `el` sits vertically centered, clamped to the
|
|
36
|
+
* scrollable range. A message taller than the viewport ends up with its top
|
|
37
|
+
* region visible, which is the useful part.
|
|
38
|
+
*/
|
|
39
|
+
export declare function centerMessageInViewport(viewport: HTMLElement, el: HTMLElement): void;
|
|
40
|
+
//# sourceMappingURL=chatMessageScroll.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chatMessageScroll.d.ts","sourceRoot":"","sources":["../src/chatMessageScroll.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;GAcG;AAEH;;;;GAIG;AACH,eAAO,MAAM,8BAA8B,KAAK,CAAC;AAEjD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,WAAW,EACrB,SAAS,EAAE,MAAM,GAChB,WAAW,GAAG,IAAI,CASpB;AAED,0EAA0E;AAC1E,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,WAAW,EACrB,WAAW,GAAE,MAAuC,GACnD,OAAO,CAIT;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,WAAW,EACrB,EAAE,EAAE,WAAW,GACd,IAAI,CAON"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 John Ewart <john@johnewart.net>
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* DOM helpers for addressing a single message inside a scrolling transcript.
|
|
7
|
+
*
|
|
8
|
+
* `ChatMessage` stamps `data-message-id` on its root element, which makes
|
|
9
|
+
* `Message.id` the one stable address a host can point at — from a scroll
|
|
10
|
+
* request, a comment pin, a deep link. These helpers do the small amount of
|
|
11
|
+
* geometry that turns such an id into a scroll position, kept out of
|
|
12
|
+
* `ChatPanel` so they can be tested without rendering React.
|
|
13
|
+
*
|
|
14
|
+
* The centering arithmetic deliberately mirrors
|
|
15
|
+
* `scrollChatTranscriptMatchIntoView` (chatTranscriptFindHighlights.ts): assign
|
|
16
|
+
* `scrollTop` directly rather than call `scrollIntoView`, which is
|
|
17
|
+
* unimplemented in some test/embedded DOMs and, in a nested scroll container,
|
|
18
|
+
* tends to scroll ancestors too.
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* How close to the bottom still counts as "parked at the bottom". Sub-pixel
|
|
22
|
+
* layout and fractional device pixel ratios mean an exact equality check
|
|
23
|
+
* reports "not at bottom" for a viewport the user considers fully scrolled.
|
|
24
|
+
*/
|
|
25
|
+
export const CHAT_PANEL_BOTTOM_THRESHOLD_PX = 32;
|
|
26
|
+
/**
|
|
27
|
+
* Finds the rendered root element for `messageId` within `viewport`.
|
|
28
|
+
*
|
|
29
|
+
* Scans the `data-message-id` attributes rather than using a
|
|
30
|
+
* `[data-message-id="…"]` selector: message ids come from the server and are
|
|
31
|
+
* not guaranteed to be selector-safe, and `CSS.escape` is absent in some
|
|
32
|
+
* embedded DOMs. Transcripts are small enough that the scan is irrelevant
|
|
33
|
+
* next to the layout work a scroll triggers anyway.
|
|
34
|
+
*/
|
|
35
|
+
export function findMessageElement(viewport, messageId) {
|
|
36
|
+
if (!messageId)
|
|
37
|
+
return null;
|
|
38
|
+
const candidates = Array.from(viewport.querySelectorAll('[data-message-id]'));
|
|
39
|
+
for (const el of candidates) {
|
|
40
|
+
if (el.getAttribute('data-message-id') === messageId)
|
|
41
|
+
return el;
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
/** Whether `viewport` is scrolled to (or within a hair of) its bottom. */
|
|
46
|
+
export function isPinnedToBottom(viewport, thresholdPx = CHAT_PANEL_BOTTOM_THRESHOLD_PX) {
|
|
47
|
+
const distance = viewport.scrollHeight - viewport.scrollTop - viewport.clientHeight;
|
|
48
|
+
return distance <= thresholdPx;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Scrolls `viewport` so `el` sits vertically centered, clamped to the
|
|
52
|
+
* scrollable range. A message taller than the viewport ends up with its top
|
|
53
|
+
* region visible, which is the useful part.
|
|
54
|
+
*/
|
|
55
|
+
export function centerMessageInViewport(viewport, el) {
|
|
56
|
+
const elRect = el.getBoundingClientRect();
|
|
57
|
+
const vpRect = viewport.getBoundingClientRect();
|
|
58
|
+
const relativeTop = elRect.top - vpRect.top + viewport.scrollTop;
|
|
59
|
+
const target = relativeTop - vpRect.height / 2 + elRect.height / 2;
|
|
60
|
+
const maxScroll = Math.max(0, viewport.scrollHeight - viewport.clientHeight);
|
|
61
|
+
viewport.scrollTop = Math.max(0, Math.min(target, maxScroll));
|
|
62
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type ChatModelOption = {
|
|
2
|
+
providerId: string;
|
|
3
|
+
providerName: string;
|
|
4
|
+
modelId: string;
|
|
5
|
+
modelName: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function encodeChatModelOptionValue(opt: ChatModelOption): string;
|
|
8
|
+
export declare function decodeChatModelOptionValue(value: string): {
|
|
9
|
+
providerId: string;
|
|
10
|
+
modelId: string;
|
|
11
|
+
} | null;
|
|
12
|
+
type ProviderRow = {
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
defaultModel?: string;
|
|
16
|
+
models?: {
|
|
17
|
+
id: string;
|
|
18
|
+
name: string;
|
|
19
|
+
}[];
|
|
20
|
+
useDefaultModelOnly?: boolean;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Flat list of picker rows for configured providers only, deduped by provider+model
|
|
24
|
+
* and skipping empty ids (avoids Mantine Combobox duplicate-value errors and malformed data).
|
|
25
|
+
*/
|
|
26
|
+
export declare function buildConfiguredModelOptions(configuredProviders: ProviderRow[]): ChatModelOption[];
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=chatModelOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chatModelOptions.d.ts","sourceRoot":"","sources":["../src/chatModelOptions.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,eAAe,GAAG;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,CAEvE;AAED,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,MAAM,GACZ;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAOhD;AAED,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACxC,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,CAAC;AAEF;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,mBAAmB,EAAE,WAAW,EAAE,GACjC,eAAe,EAAE,CAmCnB"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 John Ewart <john@johnewart.net>
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
/** Unit separator — not used in UUIDs or typical vendor model ids (unlike `:`). */
|
|
6
|
+
const MODEL_OPTION_VALUE_SEP = '';
|
|
7
|
+
export function encodeChatModelOptionValue(opt) {
|
|
8
|
+
return `${opt.providerId}${MODEL_OPTION_VALUE_SEP}${opt.modelId}`;
|
|
9
|
+
}
|
|
10
|
+
export function decodeChatModelOptionValue(value) {
|
|
11
|
+
const i = value.indexOf(MODEL_OPTION_VALUE_SEP);
|
|
12
|
+
if (i <= 0 || i >= value.length - 1)
|
|
13
|
+
return null;
|
|
14
|
+
return {
|
|
15
|
+
providerId: value.slice(0, i),
|
|
16
|
+
modelId: value.slice(i + MODEL_OPTION_VALUE_SEP.length),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Flat list of picker rows for configured providers only, deduped by provider+model
|
|
21
|
+
* and skipping empty ids (avoids Mantine Combobox duplicate-value errors and malformed data).
|
|
22
|
+
*/
|
|
23
|
+
export function buildConfiguredModelOptions(configuredProviders) {
|
|
24
|
+
const list = [];
|
|
25
|
+
const seen = new Set();
|
|
26
|
+
for (const p of configuredProviders) {
|
|
27
|
+
const models = p.models?.length
|
|
28
|
+
? p.models
|
|
29
|
+
: p.defaultModel?.trim()
|
|
30
|
+
? [{ id: p.defaultModel.trim(), name: p.defaultModel.trim() }]
|
|
31
|
+
: [];
|
|
32
|
+
// A provider reporting no models still gets one selectable row, but its
|
|
33
|
+
// model id must never be the PROVIDER id: the picker's choice is typically
|
|
34
|
+
// persisted downstream, and a provider id fails model lookups there.
|
|
35
|
+
// `default` is the sentinel meaning "whatever this provider is set to".
|
|
36
|
+
const modelList = models.length > 0
|
|
37
|
+
? models
|
|
38
|
+
: p.useDefaultModelOnly
|
|
39
|
+
? [{ id: 'default', name: 'Default' }]
|
|
40
|
+
: [{ id: 'default', name: p.name }];
|
|
41
|
+
for (const m of modelList) {
|
|
42
|
+
const pid = (p.id ?? '').trim();
|
|
43
|
+
const mid = (m.id ?? '').trim();
|
|
44
|
+
if (!pid || !mid)
|
|
45
|
+
continue;
|
|
46
|
+
const key = `${pid}\0${mid}`;
|
|
47
|
+
if (seen.has(key))
|
|
48
|
+
continue;
|
|
49
|
+
seen.add(key);
|
|
50
|
+
list.push({
|
|
51
|
+
providerId: pid,
|
|
52
|
+
providerName: (p.name ?? '').trim() || pid,
|
|
53
|
+
modelId: mid,
|
|
54
|
+
modelName: (m.name ?? '').trim() || mid,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return list;
|
|
59
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const CHAT_FIND_HIGHLIGHT_ALL = "chat-transcript-find";
|
|
2
|
+
export declare const CHAT_FIND_HIGHLIGHT_CURRENT = "chat-transcript-find-current";
|
|
3
|
+
/** Collect non-overlapping text match ranges under `root` (case-insensitive). */
|
|
4
|
+
export declare function collectChatTranscriptMatchRanges(root: HTMLElement, query: string): Range[];
|
|
5
|
+
export declare function supportsCssCustomHighlight(): boolean;
|
|
6
|
+
export declare function applyChatTranscriptFindHighlights(ranges: Range[], currentIndex: number, maxPainted?: number): void;
|
|
7
|
+
export declare function clearChatTranscriptFindHighlights(): void;
|
|
8
|
+
export declare function scrollChatTranscriptMatchIntoView(range: Range, viewport: HTMLElement): void;
|
|
9
|
+
//# sourceMappingURL=chatTranscriptFindHighlights.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chatTranscriptFindHighlights.d.ts","sourceRoot":"","sources":["../src/chatTranscriptFindHighlights.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,uBAAuB,yBAAyB,CAAC;AAC9D,eAAO,MAAM,2BAA2B,iCAAiC,CAAC;AAe1E,iFAAiF;AACjF,wBAAgB,gCAAgC,CAC9C,IAAI,EAAE,WAAW,EACjB,KAAK,EAAE,MAAM,GACZ,KAAK,EAAE,CA8BT;AAED,wBAAgB,0BAA0B,IAAI,OAAO,CAEpD;AAED,wBAAgB,iCAAiC,CAC/C,MAAM,EAAE,KAAK,EAAE,EACf,YAAY,EAAE,MAAM,EACpB,UAAU,SAAM,GACf,IAAI,CAiBN;AAED,wBAAgB,iCAAiC,IAAI,IAAI,CAIxD;AAED,wBAAgB,iCAAiC,CAC/C,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,WAAW,GACpB,IAAI,CAkBN"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 John Ewart <john@johnewart.net>
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
export const CHAT_FIND_HIGHLIGHT_ALL = 'chat-transcript-find';
|
|
6
|
+
export const CHAT_FIND_HIGHLIGHT_CURRENT = 'chat-transcript-find-current';
|
|
7
|
+
function nodeInFindScope(node, root) {
|
|
8
|
+
const parent = node.nodeType === Node.TEXT_NODE ? node.parentElement : node;
|
|
9
|
+
if (!parent || !root.contains(parent))
|
|
10
|
+
return false;
|
|
11
|
+
if (parent.closest('[data-chat-find-ignore]'))
|
|
12
|
+
return false;
|
|
13
|
+
if (parent.closest('.chat-transcript-find-bar'))
|
|
14
|
+
return false;
|
|
15
|
+
const tag = parent.tagName;
|
|
16
|
+
if (tag === 'SCRIPT' || tag === 'STYLE' || tag === 'TEXTAREA' || tag === 'INPUT') {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
/** Collect non-overlapping text match ranges under `root` (case-insensitive). */
|
|
22
|
+
export function collectChatTranscriptMatchRanges(root, query) {
|
|
23
|
+
const q = query.trim();
|
|
24
|
+
if (!q)
|
|
25
|
+
return [];
|
|
26
|
+
const lowerQ = q.toLowerCase();
|
|
27
|
+
const ranges = [];
|
|
28
|
+
const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, {
|
|
29
|
+
acceptNode(node) {
|
|
30
|
+
return nodeInFindScope(node, root)
|
|
31
|
+
? NodeFilter.FILTER_ACCEPT
|
|
32
|
+
: NodeFilter.FILTER_REJECT;
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
let node;
|
|
36
|
+
while ((node = walker.nextNode())) {
|
|
37
|
+
const text = node.textContent ?? '';
|
|
38
|
+
const lowerText = text.toLowerCase();
|
|
39
|
+
let start = 0;
|
|
40
|
+
while (start < lowerText.length) {
|
|
41
|
+
const idx = lowerText.indexOf(lowerQ, start);
|
|
42
|
+
if (idx === -1)
|
|
43
|
+
break;
|
|
44
|
+
const range = document.createRange();
|
|
45
|
+
range.setStart(node, idx);
|
|
46
|
+
range.setEnd(node, idx + q.length);
|
|
47
|
+
ranges.push(range);
|
|
48
|
+
start = idx + Math.max(1, q.length);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return ranges;
|
|
52
|
+
}
|
|
53
|
+
export function supportsCssCustomHighlight() {
|
|
54
|
+
return typeof CSS !== 'undefined' && 'highlights' in CSS;
|
|
55
|
+
}
|
|
56
|
+
export function applyChatTranscriptFindHighlights(ranges, currentIndex, maxPainted = 300) {
|
|
57
|
+
if (!supportsCssCustomHighlight())
|
|
58
|
+
return;
|
|
59
|
+
CSS.highlights.delete(CHAT_FIND_HIGHLIGHT_ALL);
|
|
60
|
+
CSS.highlights.delete(CHAT_FIND_HIGHLIGHT_CURRENT);
|
|
61
|
+
if (ranges.length === 0)
|
|
62
|
+
return;
|
|
63
|
+
const paintRanges = ranges.length > maxPainted ? ranges.slice(0, maxPainted) : ranges;
|
|
64
|
+
CSS.highlights.set(CHAT_FIND_HIGHLIGHT_ALL, new Highlight(...paintRanges));
|
|
65
|
+
if (currentIndex >= 0 && currentIndex < ranges.length) {
|
|
66
|
+
CSS.highlights.set(CHAT_FIND_HIGHLIGHT_CURRENT, new Highlight(ranges[currentIndex]));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
export function clearChatTranscriptFindHighlights() {
|
|
70
|
+
if (!supportsCssCustomHighlight())
|
|
71
|
+
return;
|
|
72
|
+
CSS.highlights.delete(CHAT_FIND_HIGHLIGHT_ALL);
|
|
73
|
+
CSS.highlights.delete(CHAT_FIND_HIGHLIGHT_CURRENT);
|
|
74
|
+
}
|
|
75
|
+
export function scrollChatTranscriptMatchIntoView(range, viewport) {
|
|
76
|
+
const rangeRect = range.getBoundingClientRect();
|
|
77
|
+
const vpRect = viewport.getBoundingClientRect();
|
|
78
|
+
if (rangeRect.height === 0 && rangeRect.width === 0) {
|
|
79
|
+
const el = range.startContainer.nodeType === Node.TEXT_NODE
|
|
80
|
+
? range.startContainer.parentElement
|
|
81
|
+
: range.startContainer;
|
|
82
|
+
el?.scrollIntoView({ block: 'center', behavior: 'auto' });
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const relativeTop = rangeRect.top - vpRect.top + viewport.scrollTop;
|
|
86
|
+
const targetScroll = relativeTop - vpRect.height / 2 + rangeRect.height / 2;
|
|
87
|
+
viewport.scrollTop = Math.max(0, Math.min(targetScroll, viewport.scrollHeight - viewport.clientHeight));
|
|
88
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Read side of the composer draft, as exposed on `LlmdChatDriver.draft`. */
|
|
2
|
+
export interface DraftStore {
|
|
3
|
+
get(): string;
|
|
4
|
+
subscribe(listener: () => void): () => void;
|
|
5
|
+
}
|
|
6
|
+
/** Internal: the driver's writable handle. */
|
|
7
|
+
export interface WritableDraftStore extends DraftStore {
|
|
8
|
+
set(next: string | ((current: string) => string)): void;
|
|
9
|
+
}
|
|
10
|
+
export declare function createDraftStore(): WritableDraftStore;
|
|
11
|
+
/** Current draft text; re-renders only the calling component on change. */
|
|
12
|
+
export declare function useDraft(store: DraftStore): string;
|
|
13
|
+
//# sourceMappingURL=draftStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"draftStore.d.ts","sourceRoot":"","sources":["../src/draftStore.ts"],"names":[],"mappings":"AAgBA,6EAA6E;AAC7E,MAAM,WAAW,UAAU;IACzB,GAAG,IAAI,MAAM,CAAC;IACd,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;CAC7C;AAED,8CAA8C;AAC9C,MAAM,WAAW,kBAAmB,SAAQ,UAAU;IACpD,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC,GAAG,IAAI,CAAC;CACzD;AAED,wBAAgB,gBAAgB,IAAI,kBAAkB,CAkBrD;AAED,2EAA2E;AAC3E,wBAAgB,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAElD"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 John Ewart <john@johnewart.net>
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* The composer draft as a subscribable store rather than React state.
|
|
7
|
+
*
|
|
8
|
+
* The chat driver is created by the HOST (the page that renders the chat), so
|
|
9
|
+
* if the draft were `useState` inside the driver every keystroke would
|
|
10
|
+
* re-render that whole page. Keeping it in a store means only the components
|
|
11
|
+
* that read it with {@link useDraft} re-render while typing.
|
|
12
|
+
*/
|
|
13
|
+
import { useSyncExternalStore } from 'react';
|
|
14
|
+
export function createDraftStore() {
|
|
15
|
+
let value = '';
|
|
16
|
+
const listeners = new Set();
|
|
17
|
+
return {
|
|
18
|
+
get: () => value,
|
|
19
|
+
subscribe(listener) {
|
|
20
|
+
listeners.add(listener);
|
|
21
|
+
return () => {
|
|
22
|
+
listeners.delete(listener);
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
set(next) {
|
|
26
|
+
const resolved = typeof next === 'function' ? next(value) : next;
|
|
27
|
+
if (resolved === value)
|
|
28
|
+
return;
|
|
29
|
+
value = resolved;
|
|
30
|
+
for (const l of [...listeners])
|
|
31
|
+
l();
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/** Current draft text; re-renders only the calling component on change. */
|
|
36
|
+
export function useDraft(store) {
|
|
37
|
+
return useSyncExternalStore(store.subscribe, store.get, store.get);
|
|
38
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { HighlightedCodeProps, LlmdPlugin } from './plugins.js';
|
|
2
|
+
export declare function PrismHighlightedCode({ code, language, customStyle, preTagProps }: HighlightedCodeProps): import("react").JSX.Element;
|
|
3
|
+
export declare const highlightPlugin: LlmdPlugin;
|
|
4
|
+
//# sourceMappingURL=highlight.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"highlight.d.ts","sourceRoot":"","sources":["../src/highlight.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAuBrE,wBAAgB,oBAAoB,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,EAAE,oBAAoB,+BAqBtG;AAED,eAAO,MAAM,eAAe,EAAE,UAAwE,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2026 John Ewart <john@johnewart.net>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* `@pyxis-llm/react/highlight` — Prism syntax highlighting for fenced code.
|
|
8
|
+
* Requires the optional peer `react-syntax-highlighter`.
|
|
9
|
+
*
|
|
10
|
+
* import { highlightPlugin } from '@pyxis-llm/react/highlight';
|
|
11
|
+
* registerLlmdPlugin(highlightPlugin); // or <LlmdPluginProvider plugins={[highlightPlugin]}>
|
|
12
|
+
*
|
|
13
|
+
* Not registered on import: a host may want its own highlighter instead.
|
|
14
|
+
*/
|
|
15
|
+
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
|
|
16
|
+
import oneDark from 'react-syntax-highlighter/dist/esm/styles/prism/one-dark';
|
|
17
|
+
/**
|
|
18
|
+
* Uses app CSS variables for code block background and base text, keeping
|
|
19
|
+
* Prism token colors from oneDark. Consumers must define `--app-code-bg`,
|
|
20
|
+
* `--app-code-text`, and `--mono-font` in their CSS.
|
|
21
|
+
*/
|
|
22
|
+
const codeBlockStyle = {
|
|
23
|
+
...oneDark,
|
|
24
|
+
'code[class*="language-"]': {
|
|
25
|
+
...oneDark['code[class*="language-"]'],
|
|
26
|
+
background: 'var(--app-code-bg)',
|
|
27
|
+
color: 'var(--app-code-text)',
|
|
28
|
+
fontFamily: 'var(--mono-font)',
|
|
29
|
+
},
|
|
30
|
+
'pre[class*="language-"]': {
|
|
31
|
+
...oneDark['pre[class*="language-"]'],
|
|
32
|
+
background: 'var(--app-code-bg)',
|
|
33
|
+
color: 'var(--app-code-text)',
|
|
34
|
+
fontFamily: 'var(--mono-font)',
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
export function PrismHighlightedCode({ code, language, customStyle, preTagProps }) {
|
|
38
|
+
return (_jsx(SyntaxHighlighter, { PreTag: "div", PreTagProps: preTagProps, language: language, style: codeBlockStyle, customStyle: customStyle, codeTagProps: {
|
|
39
|
+
style: {
|
|
40
|
+
fontFamily: 'var(--mono-font)',
|
|
41
|
+
whiteSpace: 'pre-wrap',
|
|
42
|
+
overflowWrap: 'anywhere',
|
|
43
|
+
wordBreak: 'break-word',
|
|
44
|
+
},
|
|
45
|
+
}, showLineNumbers: false, children: code }));
|
|
46
|
+
}
|
|
47
|
+
export const highlightPlugin = { id: 'llmd.highlight', highlighter: PrismHighlightedCode };
|