@wukazis/euphony 0.1.45
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/LICENSE +201 -0
- package/NOTICE +13 -0
- package/README.md +266 -0
- package/bin/euphony.js +4 -0
- package/dist/apple-touch-icon.png +0 -0
- package/dist/assets/harmony-render-5ErAOXX9.js +3285 -0
- package/dist/assets/local-data-worker-CHLGzNeW.js +2 -0
- package/dist/assets/main-CmldcHcT.js +4047 -0
- package/dist/examples/euphony-convo-100.jsonl +8 -0
- package/dist/examples/simple-harmony-convos.jsonl +8 -0
- package/dist/favicon-48x48.png +0 -0
- package/dist/favicon.ico +0 -0
- package/dist/favicon.svg +3 -0
- package/dist/global.css +38 -0
- package/dist/index.html +22 -0
- package/dist/web-app-manifest-192x192.png +0 -0
- package/dist/web-app-manifest-512x512.png +0 -0
- package/lib/chunks/conversation.js +612 -0
- package/lib/chunks/css/codex.js +1 -0
- package/lib/chunks/css/confirm-dialog.js +1 -0
- package/lib/chunks/css/conversation.js +1 -0
- package/lib/chunks/css/floating-toolbar.js +1 -0
- package/lib/chunks/css/input-dialog.js +1 -0
- package/lib/chunks/css/json-viewer.js +1 -0
- package/lib/chunks/css/menu.js +1 -0
- package/lib/chunks/css/message-code.js +1 -0
- package/lib/chunks/css/message-developer-content.js +1 -0
- package/lib/chunks/css/message-editor-popover.js +1 -0
- package/lib/chunks/css/message-hidden.js +1 -0
- package/lib/chunks/css/message-system-content.js +1 -0
- package/lib/chunks/css/message-text.js +1 -0
- package/lib/chunks/css/message-unsupported.js +1 -0
- package/lib/chunks/css/pagination.js +1 -0
- package/lib/chunks/css/preference-window.js +1 -0
- package/lib/chunks/css/search-window.js +1 -0
- package/lib/chunks/css/toast.js +1 -0
- package/lib/chunks/css/token-window.js +1 -0
- package/lib/chunks/css-inline.js +1 -0
- package/lib/chunks/dompurify.js +1 -0
- package/lib/chunks/harmony-types.js +1 -0
- package/lib/chunks/icon-cross.js +1 -0
- package/lib/chunks/icon-play.js +1 -0
- package/lib/chunks/marked.js +1 -0
- package/lib/chunks/prismjs.js +1 -0
- package/lib/chunks/shoelace.js +1131 -0
- package/lib/chunks/third-party.js +1 -0
- package/lib/chunks/utils.js +16 -0
- package/lib/components/app/app.d.ts +192 -0
- package/lib/components/app/local-data-worker.d.ts +35 -0
- package/lib/components/app/request-worker.d.ts +45 -0
- package/lib/components/app/url-manager.d.ts +25 -0
- package/lib/components/codex/codex.d.ts +50 -0
- package/lib/components/codex/codex.js +36 -0
- package/lib/components/confirm-dialog/confirm-dialog.d.ts +42 -0
- package/lib/components/confirm-dialog/confirm-dialog.js +41 -0
- package/lib/components/conversation/conversation.d.ts +259 -0
- package/lib/components/conversation/conversation.js +1 -0
- package/lib/components/floating-toolbar/floating-toolbar.d.ts +47 -0
- package/lib/components/floating-toolbar/floating-toolbar.js +32 -0
- package/lib/components/input-dialog/input-dialog.d.ts +43 -0
- package/lib/components/input-dialog/input-dialog.js +51 -0
- package/lib/components/json-viewer/json-viewer.d.ts +33 -0
- package/lib/components/json-viewer/json-viewer.js +8 -0
- package/lib/components/menu/menu.d.ts +38 -0
- package/lib/components/menu/menu.js +9 -0
- package/lib/components/message-code/message-code.d.ts +20 -0
- package/lib/components/message-code/message-code.js +10 -0
- package/lib/components/message-developer-content/message-developer-content.d.ts +45 -0
- package/lib/components/message-developer-content/message-developer-content.js +72 -0
- package/lib/components/message-editor-popover/message-editor-popover.d.ts +36 -0
- package/lib/components/message-editor-popover/message-editor-popover.js +85 -0
- package/lib/components/message-hidden/message-hidden.d.ts +38 -0
- package/lib/components/message-hidden/message-hidden.js +10 -0
- package/lib/components/message-system-content/message-system-content.d.ts +52 -0
- package/lib/components/message-system-content/message-system-content.js +74 -0
- package/lib/components/message-text/message-text.d.ts +36 -0
- package/lib/components/message-text/message-text.js +14 -0
- package/lib/components/message-unsupported/message-unsupported.d.ts +19 -0
- package/lib/components/message-unsupported/message-unsupported.js +26 -0
- package/lib/components/pagination/pagination.d.ts +29 -0
- package/lib/components/pagination/pagination.js +35 -0
- package/lib/components/preference-window/preference-window.d.ts +107 -0
- package/lib/components/preference-window/preference-window.js +319 -0
- package/lib/components/search-window/search-window.d.ts +44 -0
- package/lib/components/search-window/search-window.js +71 -0
- package/lib/components/toast/toast.d.ts +34 -0
- package/lib/components/toast/toast.js +77 -0
- package/lib/components/token-window/token-window.d.ts +96 -0
- package/lib/components/token-window/token-window.js +1 -0
- package/lib/config/config.d.ts +273 -0
- package/lib/euphony.d.ts +11 -0
- package/lib/euphony.js +1 -0
- package/lib/types/common-types.d.ts +176 -0
- package/lib/types/harmony-types.d.ts +72 -0
- package/lib/utils/api-manager.d.ts +42 -0
- package/lib/utils/codex-session.d.ts +7 -0
- package/lib/utils/dompurify-configs.d.ts +2 -0
- package/lib/utils/harmony-render.d.ts +4 -0
- package/lib/utils/marked-katex-extension.d.ts +22 -0
- package/lib/utils/patch-preview.d.ts +2 -0
- package/lib/utils/utils.d.ts +80 -0
- package/package.json +84 -0
- package/server-dist/node-main.js +1273 -0
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { LitElement, PropertyValues, TemplateResult } from 'lit';
|
|
2
|
+
import { TranslatableConversation } from '../../types/common-types';
|
|
3
|
+
import { Conversation, Message, Role } from '../../types/harmony-types';
|
|
4
|
+
import { EuphonyFloatingToolbar, FloatingToolbarButton } from '../floating-toolbar/floating-toolbar';
|
|
5
|
+
import { EuphonyTokenWindow } from '../token-window/token-window';
|
|
6
|
+
import { MessageEditorUserSetData } from '../message-editor-popover/message-editor-popover';
|
|
7
|
+
import { FocusModeSettings, MessageLabelSettings } from '../preference-window/preference-window';
|
|
8
|
+
type CustomMessageLabel = [number | string, string] | [number | string, string, string] | [number | string, string, string, string];
|
|
9
|
+
/**
|
|
10
|
+
* Conversation element.
|
|
11
|
+
*/
|
|
12
|
+
export declare class EuphonyConversation extends LitElement {
|
|
13
|
+
conversationString: string;
|
|
14
|
+
conversationData: TranslatableConversation | null;
|
|
15
|
+
/**
|
|
16
|
+
* The URL for the sharing button. If it's null, the copy URL button will be
|
|
17
|
+
* hidden.
|
|
18
|
+
*/
|
|
19
|
+
sharingURL: string | null;
|
|
20
|
+
/**
|
|
21
|
+
* Optional URL to the current json/jsonl file (if any). This is used to
|
|
22
|
+
* resolve some relative paths in the asset pointers in the conversation. For
|
|
23
|
+
* example, `aquifer://foo` will be resolved to `dataFileURL/../assets/foo`.
|
|
24
|
+
* We won't resolve relative paths if `dataFileURL` is not provided.
|
|
25
|
+
*/
|
|
26
|
+
dataFileURL: string | null;
|
|
27
|
+
/**
|
|
28
|
+
* This overrides the JSON content when user clicks copy JSON or download
|
|
29
|
+
* JSON. It should never be set unless the content you want users to copy is
|
|
30
|
+
* different form the Conversation data itself (e.g., we use it for
|
|
31
|
+
* Comparison).
|
|
32
|
+
*/
|
|
33
|
+
overrideSharingJSONString: string | null;
|
|
34
|
+
shouldRenderMarkdown: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* We use DOMPurify to sanitize the markdown rendered HTML before displaying
|
|
37
|
+
* it. This property is used to pass DOMPurify's allowed tags. If this is not
|
|
38
|
+
* provided, we use the default allowed tags defined in dompurify-configs.ts
|
|
39
|
+
*/
|
|
40
|
+
markdownAllowedTags: string[] | null;
|
|
41
|
+
/**
|
|
42
|
+
* We use DOMPurify to sanitize the markdown rendered HTML before displaying
|
|
43
|
+
* it. This property is used to pass DOMPurify's allowed attributes. If this
|
|
44
|
+
* is not provided, we use the default allowed attributes defined in
|
|
45
|
+
* dompurify-configs.ts
|
|
46
|
+
*/
|
|
47
|
+
markdownAllowedAttributes: string[] | null;
|
|
48
|
+
/**
|
|
49
|
+
* The label shown before the conversation ID.
|
|
50
|
+
*/
|
|
51
|
+
conversationLabel: string;
|
|
52
|
+
conversation: TranslatableConversation | null;
|
|
53
|
+
isEditable: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Focus mode settings.
|
|
56
|
+
* Each of the three properties is an independent filter. If it is empty, we
|
|
57
|
+
* do not apply any filter.
|
|
58
|
+
*/
|
|
59
|
+
focusModeAuthor: string[];
|
|
60
|
+
focusModeRecipient: string[];
|
|
61
|
+
focusModeContentType: string[];
|
|
62
|
+
focusModeExemptedMessageIndexes: Set<number>;
|
|
63
|
+
deletedMessageIndexes: Set<number>;
|
|
64
|
+
insertMessageMenuIndex: number | null;
|
|
65
|
+
showMessageEditorPopover: boolean;
|
|
66
|
+
editorFocusedMessage: Message | null;
|
|
67
|
+
editorFocusedMessageIndex: number | null;
|
|
68
|
+
isConvoMarkedForDeletion: boolean;
|
|
69
|
+
hasMessageSharingURLEventListener: boolean;
|
|
70
|
+
hasTranslationEventListener: boolean;
|
|
71
|
+
isShowingTranslation: boolean;
|
|
72
|
+
isTranslating: boolean;
|
|
73
|
+
translationProgress: string;
|
|
74
|
+
translationSourceLanguage: string | null;
|
|
75
|
+
/**
|
|
76
|
+
* Custom labels. They will be shown on the header bar. Each item is a string
|
|
77
|
+
* array with at most four items.
|
|
78
|
+
* 1. ['value'] -> 'value'
|
|
79
|
+
* 2. ['key', 'value'] -> 'key: value'
|
|
80
|
+
* 3. ['key', 'value', 'tooltip text'] -> 'key: value' + tooltip text
|
|
81
|
+
* 4. ['key', 'value', 'tooltip text', 'color'] -> 'key: value' + tooltip text
|
|
82
|
+
* + text color
|
|
83
|
+
*/
|
|
84
|
+
customLabels: string[][];
|
|
85
|
+
/**
|
|
86
|
+
* Custom message labels. They will be shown below the author icon. Each item
|
|
87
|
+
* is a string array with at most four items. The first two items are
|
|
88
|
+
* required, and the last two items are optional.
|
|
89
|
+
* 1. [message index / 'message id', 'tooltip text']
|
|
90
|
+
* 2. [message index / 'message id', 'tooltip text', 'color']
|
|
91
|
+
* 3. [message index / 'message id', 'tooltip text', 'color', 'icon text']
|
|
92
|
+
*/
|
|
93
|
+
customMessageLabels: CustomMessageLabel[];
|
|
94
|
+
private effectiveCustomLabels;
|
|
95
|
+
private effectiveCustomMessageLabels;
|
|
96
|
+
private updateEffectiveCustomLabels;
|
|
97
|
+
/**
|
|
98
|
+
* Custom share buttons. They will be shown on in the floating bar when hover
|
|
99
|
+
* over the share button. Each item is a string array with 3 items.
|
|
100
|
+
* You can leave the svg string empty if you want to use the default icon.
|
|
101
|
+
* ['name', 'url', 'svg string']
|
|
102
|
+
*/
|
|
103
|
+
customShareButtons: string[][];
|
|
104
|
+
baseTime: number | null;
|
|
105
|
+
popperTooltip: HTMLElement | undefined;
|
|
106
|
+
messageMetadataOverlay: HTMLElement | undefined;
|
|
107
|
+
isResizingMessageMetadata: boolean;
|
|
108
|
+
shareFloatingToolbar: EuphonyFloatingToolbar | undefined | null;
|
|
109
|
+
showShareFloatingToolbar: boolean;
|
|
110
|
+
shareFloatingToolbarButtons: FloatingToolbarButton[];
|
|
111
|
+
cleanupShareFloatingToolbarAutoUpdate: () => void;
|
|
112
|
+
shareFloatingToolbarRepositionAdded: boolean;
|
|
113
|
+
cleanupMessageEditorPopoverAutoUpdate: () => void;
|
|
114
|
+
messageEditorPopoverRepositionAdded: boolean;
|
|
115
|
+
cleanupInsertMessageMenuAutoUpdate: () => void;
|
|
116
|
+
insertMessageMenuRepositionAdded: boolean;
|
|
117
|
+
hasInsertMessageMenuOutsideClickListener: boolean;
|
|
118
|
+
hasMessageEditorPopoverOutsideClickListener: boolean;
|
|
119
|
+
tokenWindowComponent: EuphonyTokenWindow | undefined;
|
|
120
|
+
isShowingMetadata: boolean;
|
|
121
|
+
mouseoverMessage: Message | null;
|
|
122
|
+
mouseoverMessageIndex: number | null;
|
|
123
|
+
isShowingMessageMetadata: boolean;
|
|
124
|
+
conversationMaxWidth: number | null;
|
|
125
|
+
conversationMinWidth: number | null;
|
|
126
|
+
disableMarkdownButton: boolean;
|
|
127
|
+
disableTranslationButton: boolean;
|
|
128
|
+
disableShareButton: boolean;
|
|
129
|
+
disableMetadataButton: boolean;
|
|
130
|
+
disableEditingModeSaveButton: boolean;
|
|
131
|
+
disableConversationIDCopyButton: boolean;
|
|
132
|
+
isShowingPreferenceWindow: boolean;
|
|
133
|
+
euphonyStyleConfig: Record<string, string>;
|
|
134
|
+
disableMessageMetadata: boolean;
|
|
135
|
+
disableConversationName: boolean;
|
|
136
|
+
disablePreferenceButton: boolean;
|
|
137
|
+
disableTokenWindow: boolean;
|
|
138
|
+
theme: 'auto' | 'light' | 'dark';
|
|
139
|
+
isDarkTheme: boolean;
|
|
140
|
+
toolbarTooltipDebouncer: number | null;
|
|
141
|
+
shareFloatingToolbarDebouncer: number | null;
|
|
142
|
+
shareFloatingToolbarDisappearDebouncer: number | null;
|
|
143
|
+
metadataDisappearDebouncer: number | null;
|
|
144
|
+
metadataAppearDebouncer: number | null;
|
|
145
|
+
constructor();
|
|
146
|
+
addEventListener(type: keyof HTMLElementEventMap | 'translation-requested' | 'translation-completed' | 'conversation-metadata-button-toggled' | 'markdown-button-toggled' | 'editing-save-button-clicked' | 'fetch-message-sharing-url' | 'refresh-renderer-list-requested' | 'harmony-render-requested', listener: EventListener, options?: AddEventListenerOptions): void;
|
|
147
|
+
/**
|
|
148
|
+
* This method is called when the DOM is added for the first time
|
|
149
|
+
*/
|
|
150
|
+
firstUpdated(): void;
|
|
151
|
+
/**
|
|
152
|
+
* This method is called before new DOM is updated and rendered
|
|
153
|
+
* @param changedProperties Property that has been changed
|
|
154
|
+
*/
|
|
155
|
+
willUpdate(changedProperties: PropertyValues<this>): void;
|
|
156
|
+
updated(changedProperties: PropertyValues<this>): void;
|
|
157
|
+
initData(): Promise<void>;
|
|
158
|
+
refreshBaseTime(): void;
|
|
159
|
+
resetComponent(): void;
|
|
160
|
+
/**
|
|
161
|
+
* Return the edited conversation data after filtering deleted messages.
|
|
162
|
+
* This is the single source of truth for all editor-mode exports.
|
|
163
|
+
*/
|
|
164
|
+
getEditedConversationData(): Conversation | null;
|
|
165
|
+
/**
|
|
166
|
+
* Serialize the current conversation to a JSON string. It will ignore the
|
|
167
|
+
* deleted messages.
|
|
168
|
+
*/
|
|
169
|
+
serializeConversation(indent?: number | null): string;
|
|
170
|
+
updateShareFloatingToolbarPosition(shareButton: HTMLElement, floatingToolbar: HTMLElement): void;
|
|
171
|
+
updateInsertMessageMenuPosition(addButton: HTMLElement, insertMessageMenu: HTMLElement): void;
|
|
172
|
+
updateMessageEditorPopoverPosition(editButton: HTMLElement, messageEditorPopover: HTMLElement): void;
|
|
173
|
+
/**
|
|
174
|
+
* In editor mode, conversations with zero messages need a temporary deleted
|
|
175
|
+
* placeholder so the existing per-message add controls still have an anchor.
|
|
176
|
+
* The placeholder stays filtered out of all exports unless the user restores
|
|
177
|
+
* or inserts real content.
|
|
178
|
+
*/
|
|
179
|
+
bootstrapEmptyConversationForEditorMode(): void;
|
|
180
|
+
getMessageByIndex: (messageIndex: number) => HTMLElement | null | undefined;
|
|
181
|
+
translationButtonClicked(): Promise<void>;
|
|
182
|
+
/**
|
|
183
|
+
* MouseEnter Event handler for all the buttons in the toolbar
|
|
184
|
+
* @param e Mouse event
|
|
185
|
+
*/
|
|
186
|
+
toolButtonMouseEnter(e: MouseEvent, type: 'markdown' | 'translate' | 'share' | 'metadata' | 'delete' | 'add' | 'edit' | 'reorder-up' | 'reorder-down' | 'custom-label' | 'preference' | 'message-share', maybeTooltipText?: string): void;
|
|
187
|
+
/**
|
|
188
|
+
* MouseLeave Event handler for all the buttons in the toolbar
|
|
189
|
+
* @param e Mouse event
|
|
190
|
+
*/
|
|
191
|
+
toolButtonMouseLeave(useTransition?: boolean): void;
|
|
192
|
+
shareButtonMouseEnter(): void;
|
|
193
|
+
shareButtonMouseLeave(): void;
|
|
194
|
+
shareFloatingToolbarButtonClicked(e: CustomEvent<string>): Promise<void>;
|
|
195
|
+
metadataButtonClicked(): void;
|
|
196
|
+
markdownButtonClicked(): void;
|
|
197
|
+
/**
|
|
198
|
+
* Send the current conversation string to the parent
|
|
199
|
+
*/
|
|
200
|
+
editingSaveButtonClicked(): void;
|
|
201
|
+
private swapDeletedMessageIndexes;
|
|
202
|
+
private shiftDeletedIndexesAfterInsert;
|
|
203
|
+
reorderUpButtonClicked(messageIndex: number): void;
|
|
204
|
+
reorderDownButtonClicked(messageIndex: number): void;
|
|
205
|
+
createEmptyMessageForContentType(referenceMessage: Message | undefined, contentType: 'text' | 'system' | 'developer'): Message;
|
|
206
|
+
insertMessageAfterIndex(messageIndex: number, contentType: 'text' | 'system' | 'developer'): Promise<void>;
|
|
207
|
+
closeInsertMessageMenu(): void;
|
|
208
|
+
insertMessageMenuWindowPointerDown: (e: Event) => void;
|
|
209
|
+
messageEditorAddMessageButtonClicked(messageIndex: number): void;
|
|
210
|
+
closeMessageEditorPopover(): void;
|
|
211
|
+
messageEditorEditButtonClicked(messageIndex: number): void;
|
|
212
|
+
messageEditorPopoverSaveButtonClicked(e: CustomEvent<MessageEditorUserSetData>): void;
|
|
213
|
+
messageEditorPopoverCancelButtonClicked(): void;
|
|
214
|
+
messageEditorPopoverWindowPointerDown: (e: Event) => void;
|
|
215
|
+
focusEditableFieldsForMessage(messageIndex: number): void;
|
|
216
|
+
preferenceButtonClicked(): void;
|
|
217
|
+
messageInfoMouseEnter(e: MouseEvent, message: Message, messageIndex: number): void;
|
|
218
|
+
messageInfoMouseLeave(): void;
|
|
219
|
+
metadataOverlayMouseEnter(): void;
|
|
220
|
+
metadataOverlayMouseLeave(): void;
|
|
221
|
+
metadataOverlayShareButtonClicked(e: MouseEvent, messageIndex: number): void;
|
|
222
|
+
/**
|
|
223
|
+
* Prevent mouse leave when user drag the overlay to resize it
|
|
224
|
+
* Note this handler is not called on Safari. For some reason, Safari doesn't
|
|
225
|
+
* fire mousedown event when user clicks the resize handle. It doesn't fire it
|
|
226
|
+
* on window or document as well when user clicks the resize handle :(
|
|
227
|
+
* WebKit but: https://bugs.webkit.org/show_bug.cgi?id=280956
|
|
228
|
+
* @param e Mouse event
|
|
229
|
+
*/
|
|
230
|
+
metadataMouseDown: () => void;
|
|
231
|
+
loadKatexScript(): HTMLScriptElement | undefined;
|
|
232
|
+
preferenceWindowMaxMessageHeightChanged(e: CustomEvent<string>): void;
|
|
233
|
+
preferenceWindowFocusModeSettingsChanged(e: CustomEvent<FocusModeSettings>): void;
|
|
234
|
+
preferenceWindowMessageLabelChanged(e: CustomEvent<MessageLabelSettings>): void;
|
|
235
|
+
allChildrenUpdateComplete(): Promise<void>;
|
|
236
|
+
relativeTimestampFormatter(creationTime: number): string;
|
|
237
|
+
absoluteTimestampFormatter(creationTime: number): string;
|
|
238
|
+
getAuthorIcon(role: Role): TemplateResult<1>;
|
|
239
|
+
/**
|
|
240
|
+
* Check if the message is hidden by focus mode settings.
|
|
241
|
+
* @param message Message to check
|
|
242
|
+
* @returns True if the message is hidden, false otherwise
|
|
243
|
+
*/
|
|
244
|
+
isMessageHiddenByFocusMode(message: Message, messageIndex: number): boolean;
|
|
245
|
+
getMessageContentTemplate(message: Message, i: number): TemplateResult<1>;
|
|
246
|
+
renderTextWithWordBreaks(text: string): TemplateResult[];
|
|
247
|
+
getMessageMetadataInfo(message: Message): TemplateResult<1>;
|
|
248
|
+
render(): TemplateResult<1>;
|
|
249
|
+
static styles: import('lit').CSSResult[];
|
|
250
|
+
expandBlockContents(): void;
|
|
251
|
+
collapseBlockContents(): void;
|
|
252
|
+
}
|
|
253
|
+
declare global {
|
|
254
|
+
interface HTMLElementTagNameMap {
|
|
255
|
+
'euphony-conversation': EuphonyConversation;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
export declare const parseConversationJSONString: (conversationString: string) => Conversation | null;
|
|
259
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../../chunks/third-party.js";import"../../chunks/harmony-types.js";import"../../chunks/utils.js";import"../preference-window/preference-window.js";import"../../chunks/shoelace.js";import"../floating-toolbar/floating-toolbar.js";import"../json-viewer/json-viewer.js";import"../message-code/message-code.js";import"../message-developer-content/message-developer-content.js";import"../message-editor-popover/message-editor-popover.js";import"../message-hidden/message-hidden.js";import"../message-system-content/message-system-content.js";import"../message-text/message-text.js";import"../message-unsupported/message-unsupported.js";import{E as e,p as s}from"../../chunks/conversation.js";import"../../chunks/css/conversation.js";export{e as EuphonyConversation,s as parseConversationJSONString};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { LitElement, PropertyValues } from 'lit';
|
|
2
|
+
export interface FloatingToolbarButton {
|
|
3
|
+
name: string;
|
|
4
|
+
tooltip: string;
|
|
5
|
+
svgIcon: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Floating toolbar element.
|
|
9
|
+
*/
|
|
10
|
+
export declare class EuphonyFloatingToolbar extends LitElement {
|
|
11
|
+
buttons: FloatingToolbarButton[];
|
|
12
|
+
disappearTimeout: number | null;
|
|
13
|
+
popperTooltip: HTMLElement | undefined;
|
|
14
|
+
lastAnchor: HTMLElement | null;
|
|
15
|
+
toolbarTooltipDebouncer: number | null;
|
|
16
|
+
constructor();
|
|
17
|
+
/**
|
|
18
|
+
* This method is called when the DOM is added for the first time
|
|
19
|
+
*/
|
|
20
|
+
firstUpdated(): void;
|
|
21
|
+
/**
|
|
22
|
+
* This method is called before new DOM is updated and rendered
|
|
23
|
+
* @param changedProperties Property that has been changed
|
|
24
|
+
*/
|
|
25
|
+
willUpdate(changedProperties: PropertyValues<this>): void;
|
|
26
|
+
initData(): Promise<void>;
|
|
27
|
+
updateCurrentTooltip(tooltip: string): void;
|
|
28
|
+
/**
|
|
29
|
+
* MouseEnter Event handler for all the buttons in the toolbar
|
|
30
|
+
* @param e Mouse event
|
|
31
|
+
*/
|
|
32
|
+
toolButtonMouseEnter(e: MouseEvent, name: string): void;
|
|
33
|
+
/**
|
|
34
|
+
* MouseLeave Event handler for all the buttons in the toolbar
|
|
35
|
+
* @param e Mouse event
|
|
36
|
+
*/
|
|
37
|
+
toolButtonMouseLeave(useTransition?: boolean): void;
|
|
38
|
+
toolbarMouseEnter(): void;
|
|
39
|
+
toolbarMouseLeave(): void;
|
|
40
|
+
render(): import('lit').TemplateResult<1>;
|
|
41
|
+
static styles: import('lit').CSSResult[];
|
|
42
|
+
}
|
|
43
|
+
declare global {
|
|
44
|
+
interface HTMLElementTagNameMap {
|
|
45
|
+
'euphony-floating-toolbar': EuphonyFloatingToolbar;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import{v as o,i as t,n as e,e as i,a as s,b as p,x as r,w as n}from"../../chunks/third-party.js";import{u as l}from"../../chunks/utils.js";import{c as a}from"../../chunks/css/floating-toolbar.js";var u=Object.defineProperty,c=Object.getOwnPropertyDescriptor,h=(o,t,e,i)=>{for(var s,p=i>1?void 0:i?c(t,e):t,r=o.length-1;r>=0;r--)(s=o[r])&&(p=(i?s(t,e,p):s(p))||p);return i&&p&&u(t,e,p),p};const d=5;let b=class extends s{constructor(){super(),this.buttons=[],this.disappearTimeout=null,this.lastAnchor=null,this.toolbarTooltipDebouncer=null}firstUpdated(){}willUpdate(o){}async initData(){}updateCurrentTooltip(o){if(!this.popperTooltip)return void console.error("Popper tooltip not initialized.");if(!this.lastAnchor)return void console.warn("Last anchor not initialized.");const t=this.lastAnchor;this.popperTooltip.querySelector(".popper-label").textContent=o,l(this.popperTooltip,t,"top",!0,5)}toolButtonMouseEnter(o,t){if(o.stopPropagation(),o.preventDefault(),!this.popperTooltip)return void console.error("Popper tooltip not initialized.");const e=o.currentTarget;this.lastAnchor=e,this.toolbarTooltipDebouncer&&clearTimeout(this.toolbarTooltipDebouncer),this.toolbarTooltipDebouncer=window.setTimeout(()=>{const o=this.popperTooltip.querySelector(".popper-label");let i="Button";const s=this.buttons.find(o=>o.name===t);s?(i=s.tooltip,o.textContent=i,l(this.popperTooltip,e,"top",!0,5),this.popperTooltip.classList.remove("hidden")):console.error(`Button ${t} not found.`)},500)}toolButtonMouseLeave(o=!0){this.popperTooltip?(this.toolbarTooltipDebouncer&&(clearTimeout(this.toolbarTooltipDebouncer),this.toolbarTooltipDebouncer=null),o?this.popperTooltip.classList.add("hidden"):(this.popperTooltip.classList.add("no-transition"),this.popperTooltip.classList.add("hidden"),setTimeout(()=>{this.popperTooltip.classList.remove("no-transition")},150))):console.error("popperTooltip are not initialized yet.")}toolbarMouseEnter(){null!==this.disappearTimeout&&(clearTimeout(this.disappearTimeout),this.disappearTimeout=null)}toolbarMouseLeave(){const o=new Event("mouseleave",{bubbles:!0,composed:!0});this.dispatchEvent(o)}render(){const o=p`
|
|
2
|
+
<div
|
|
3
|
+
id="popper-tooltip"
|
|
4
|
+
class="popper-tooltip hidden"
|
|
5
|
+
role="tooltip"
|
|
6
|
+
@click=${o=>{o.stopPropagation()}}
|
|
7
|
+
>
|
|
8
|
+
<div class="popper-content">
|
|
9
|
+
<span class="popper-label">Hello</span>
|
|
10
|
+
</div>
|
|
11
|
+
<div class="popper-arrow"></div>
|
|
12
|
+
</div>
|
|
13
|
+
`;let t=p``;for(const o of this.buttons)t=p`${t}
|
|
14
|
+
<button
|
|
15
|
+
class="icon svg-icon ${o.name}-button"
|
|
16
|
+
@mouseenter=${t=>{this.toolButtonMouseEnter(t,o.name)}}
|
|
17
|
+
@mouseleave=${()=>{this.toolButtonMouseLeave()}}
|
|
18
|
+
@click=${t=>{const e=new CustomEvent("button-clicked",{bubbles:!0,composed:!0,detail:o.name});this.dispatchEvent(e)}}
|
|
19
|
+
>
|
|
20
|
+
${r(o.svgIcon)}
|
|
21
|
+
</button> `;return p`
|
|
22
|
+
${o}
|
|
23
|
+
<div
|
|
24
|
+
class="floating-toolbar"
|
|
25
|
+
@mouseenter=${()=>{this.toolbarMouseEnter()}}
|
|
26
|
+
@mouseleave=${()=>{this.toolbarMouseLeave()}}
|
|
27
|
+
>
|
|
28
|
+
${t}
|
|
29
|
+
</div>
|
|
30
|
+
`}};b.styles=[t`
|
|
31
|
+
${o(a)}
|
|
32
|
+
`],h([e({attribute:!1})],b.prototype,"buttons",2),h([e({})],b.prototype,"disappearTimeout",2),h([i("#popper-tooltip")],b.prototype,"popperTooltip",2),b=h([n("euphony-floating-toolbar")],b);export{b as EuphonyFloatingToolbar};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { LitElement, PropertyValues } from 'lit';
|
|
2
|
+
export interface DialogInfo {
|
|
3
|
+
header: string;
|
|
4
|
+
message: string;
|
|
5
|
+
yesButtonText: string;
|
|
6
|
+
errorMessage?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Confirm dialog element.
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
export declare class NightjarInputDialog extends LitElement {
|
|
13
|
+
dialogElement: HTMLDialogElement | undefined;
|
|
14
|
+
header: string;
|
|
15
|
+
message: string;
|
|
16
|
+
yesButtonText: string;
|
|
17
|
+
errorMessage: string;
|
|
18
|
+
isError: boolean;
|
|
19
|
+
isLoading: boolean;
|
|
20
|
+
inputStorageKey: string;
|
|
21
|
+
confirmAction: (input: string) => void;
|
|
22
|
+
cancelAction: () => void;
|
|
23
|
+
inputValidate: (input: string) => Promise<boolean> | boolean;
|
|
24
|
+
constructor();
|
|
25
|
+
firstUpdated(): void;
|
|
26
|
+
/**
|
|
27
|
+
* This method is called before new DOM is updated and rendered
|
|
28
|
+
* @param changedProperties Property that has been changed
|
|
29
|
+
*/
|
|
30
|
+
willUpdate(changedProperties: PropertyValues<this>): void;
|
|
31
|
+
initData: () => Promise<void>;
|
|
32
|
+
show(dialogInfo: DialogInfo, confirmAction: (input: string) => void, cancelAction?: () => void, inputValidate?: (input: string) => Promise<boolean> | boolean): void;
|
|
33
|
+
dialogClicked(e: MouseEvent): void;
|
|
34
|
+
cancelClicked(e: MouseEvent): void;
|
|
35
|
+
confirmClicked(e: MouseEvent): Promise<void>;
|
|
36
|
+
render(): import('lit').TemplateResult<1>;
|
|
37
|
+
static styles: import('lit').CSSResult[];
|
|
38
|
+
}
|
|
39
|
+
declare global {
|
|
40
|
+
interface HTMLElementTagNameMap {
|
|
41
|
+
'nightjar-input-dialog': NightjarInputDialog;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import{v as e,i as t,e as i,r as s,a,b as o,w as n}from"../../chunks/third-party.js";import{c as r}from"../../chunks/css/input-dialog.js";var l=Object.defineProperty,d=Object.getOwnPropertyDescriptor,c=(e,t,i,s)=>{for(var a,o=s>1?void 0:s?d(t,i):t,n=e.length-1;n>=0;n--)(a=e[n])&&(o=(s?a(t,i,o):a(o))||o);return s&&o&&l(t,i,o),o};let h=class extends a{constructor(){super(),this.header="Delete Item",this.message="Are you sure you want to delete this item? This action cannot be undone.",this.yesButtonText="Delete",this.errorMessage="Invalid input, please try again.",this.isError=!1,this.isLoading=!1,this.inputStorageKey="deletion",this.initData=async()=>{},this.confirmAction=e=>{},this.cancelAction=()=>{},this.inputValidate=()=>!0}firstUpdated(){window.setTimeout(()=>{},1e3)}willUpdate(e){}show(e,t,i,s){this.header=e.header,this.message=e.message,this.yesButtonText=e.yesButtonText,this.confirmAction=t,this.errorMessage=e.errorMessage||this.errorMessage,this.cancelAction=void 0===i?()=>{}:i,this.inputValidate=void 0===s?()=>!0:s,this.dialogElement&&this.dialogElement.showModal()}dialogClicked(e){e.target===this.dialogElement&&this.dialogElement.close()}cancelClicked(e){e.stopPropagation(),this.dialogElement&&(this.dialogElement.close(),this.cancelAction())}async confirmClicked(e){if(e.stopPropagation(),this.dialogElement){const e=this.dialogElement.querySelector("#input-element");this.isLoading=!0,this.isError=!1;const t=e?.value||"";await this.inputValidate(t)?(this.isLoading=!1,this.confirmAction(t),this.dialogElement.close()):(this.isLoading=!1,this.isError=!0)}}render(){return o`
|
|
2
|
+
<dialog
|
|
3
|
+
class="input-dialog"
|
|
4
|
+
@click=${e=>{this.dialogClicked(e)}}
|
|
5
|
+
>
|
|
6
|
+
<div class="header">
|
|
7
|
+
<div class="header-name">${this.header}</div>
|
|
8
|
+
</div>
|
|
9
|
+
|
|
10
|
+
<div class="content">
|
|
11
|
+
<div class="message">${this.message}</div>
|
|
12
|
+
|
|
13
|
+
<div class="input-container">
|
|
14
|
+
<sl-input
|
|
15
|
+
id="input-element"
|
|
16
|
+
size="medium"
|
|
17
|
+
placeholder="OpenAI API Key"
|
|
18
|
+
clearable
|
|
19
|
+
spellcheck="false"
|
|
20
|
+
>
|
|
21
|
+
</sl-input>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
<div class="footer-container">
|
|
26
|
+
<div class="message validating-message" ?is-hidden=${!this.isLoading}>
|
|
27
|
+
Validating...
|
|
28
|
+
</div>
|
|
29
|
+
<div class="message error-message" ?is-hidden=${!this.isError}>
|
|
30
|
+
${this.errorMessage}
|
|
31
|
+
</div>
|
|
32
|
+
|
|
33
|
+
<div class="button-block">
|
|
34
|
+
<button
|
|
35
|
+
class="cancel-button"
|
|
36
|
+
@click=${e=>{this.cancelClicked(e)}}
|
|
37
|
+
>
|
|
38
|
+
Cancel
|
|
39
|
+
</button>
|
|
40
|
+
<button
|
|
41
|
+
class="confirm-button"
|
|
42
|
+
@click=${e=>{this.confirmClicked(e)}}
|
|
43
|
+
>
|
|
44
|
+
${this.yesButtonText}
|
|
45
|
+
</button>
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
</dialog>
|
|
49
|
+
`}};h.styles=[t`
|
|
50
|
+
${e(r)}
|
|
51
|
+
`],c([i("dialog")],h.prototype,"dialogElement",2),c([s()],h.prototype,"header",2),c([s()],h.prototype,"message",2),c([s()],h.prototype,"yesButtonText",2),c([s()],h.prototype,"errorMessage",2),c([s()],h.prototype,"isError",2),c([s()],h.prototype,"isLoading",2),h=c([n("nightjar-input-dialog")],h);export{h as NightjarInputDialog};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { LitElement, PropertyValues } from 'lit';
|
|
2
|
+
type JSONValue = string | number | boolean | null | JSONObject | JSONArray;
|
|
3
|
+
interface JSONObject {
|
|
4
|
+
[key: string]: JSONValue;
|
|
5
|
+
}
|
|
6
|
+
type JSONArray = JSONValue[];
|
|
7
|
+
/**
|
|
8
|
+
* Json viewer element.
|
|
9
|
+
*/
|
|
10
|
+
export declare class EuphonyJsonViewer extends LitElement {
|
|
11
|
+
data: JSONValue;
|
|
12
|
+
isDarkTheme: boolean;
|
|
13
|
+
constructor();
|
|
14
|
+
/**
|
|
15
|
+
* This method is called when the DOM is added for the first time
|
|
16
|
+
*/
|
|
17
|
+
firstUpdated(): void;
|
|
18
|
+
/**
|
|
19
|
+
* This method is called before new DOM is updated and rendered
|
|
20
|
+
* @param changedProperties Property that has been changed
|
|
21
|
+
*/
|
|
22
|
+
willUpdate(changedProperties: PropertyValues<this>): void;
|
|
23
|
+
initData(): Promise<void>;
|
|
24
|
+
getHighlightedCode(code: string, language: string): import('lit').TemplateResult<1>;
|
|
25
|
+
render(): import('lit').TemplateResult<1>;
|
|
26
|
+
static styles: import('lit').CSSResult[];
|
|
27
|
+
}
|
|
28
|
+
declare global {
|
|
29
|
+
interface HTMLElementTagNameMap {
|
|
30
|
+
'euphony-json-viewer': EuphonyJsonViewer;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{v as e,i as s,n as t,a as r,b as i,x as a,w as n}from"../../chunks/third-party.js";import{p as o}from"../../chunks/prismjs.js";import{p as h}from"../../chunks/css-inline.js";import{c as p}from"../../chunks/css/json-viewer.js";var d=Object.defineProperty,c=Object.getOwnPropertyDescriptor,l=(e,s,t,r)=>{for(var i,a=r>1?void 0:r?c(s,t):s,n=e.length-1;n>=0;n--)(i=e[n])&&(a=(r?i(s,t,a):i(a))||a);return r&&a&&d(s,t,a),a};let u=class extends r{constructor(){super(),this.data=null,this.isDarkTheme=!1}firstUpdated(){}willUpdate(e){}async initData(){}getHighlightedCode(e,s){if(!(s in o.languages))return i`${e}`;const t=o.languages[s],r=o.highlight(e,t,s);return i`${a(r)}`}render(){return i`
|
|
2
|
+
<div class="json-viewer" ?is-dark-theme=${this.isDarkTheme}>
|
|
3
|
+
<pre class="message-pre"><code>${this.getHighlightedCode(JSON.stringify(this.data,null,2),"json")}</code></pre>
|
|
4
|
+
</div>
|
|
5
|
+
`}};u.styles=[s`
|
|
6
|
+
${e(p)}
|
|
7
|
+
${e(h)}
|
|
8
|
+
`],l([t({attribute:!1})],u.prototype,"data",2),l([t({type:Boolean,attribute:"is-dark-theme"})],u.prototype,"isDarkTheme",2),u=l([n("euphony-json-viewer")],u);export{u as EuphonyJsonViewer};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { LitElement, PropertyValues } from 'lit';
|
|
2
|
+
interface MenuItem {
|
|
3
|
+
name: string;
|
|
4
|
+
icon?: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Menu element.
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
export declare class NightjarMenu extends LitElement {
|
|
11
|
+
menuItems: MenuItem[];
|
|
12
|
+
isHidden: boolean;
|
|
13
|
+
timer: null | number;
|
|
14
|
+
constructor();
|
|
15
|
+
/**
|
|
16
|
+
* This method is called before new DOM is updated and rendered
|
|
17
|
+
* @param changedProperties Property that has been changed
|
|
18
|
+
*/
|
|
19
|
+
willUpdate(changedProperties: PropertyValues<this>): void;
|
|
20
|
+
initData(): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Show the toast message
|
|
23
|
+
*/
|
|
24
|
+
show(): void;
|
|
25
|
+
/**
|
|
26
|
+
* Hide the toast message
|
|
27
|
+
*/
|
|
28
|
+
hide(): void;
|
|
29
|
+
menuItemClicked(e: MouseEvent, menuItemName: string): void;
|
|
30
|
+
render(): import('lit').TemplateResult<1>;
|
|
31
|
+
static styles: import('lit').CSSResult[];
|
|
32
|
+
}
|
|
33
|
+
declare global {
|
|
34
|
+
interface HTMLElementTagNameMap {
|
|
35
|
+
'nightjar-menu': NightjarMenu;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{v as t,i as e,n as s,r as i,a as n,b as o,x as r,w as a}from"../../chunks/third-party.js";import{c as u}from"../../chunks/css/menu.js";var d=Object.defineProperty,c=Object.getOwnPropertyDescriptor,m=(t,e,s,i)=>{for(var n,o=i>1?void 0:i?c(e,s):e,r=t.length-1;r>=0;r--)(n=t[r])&&(o=(i?n(e,s,o):n(o))||o);return i&&o&&d(e,s,o),o};let h=class extends n{constructor(){super(),this.menuItems=[],this.isHidden=!0,this.timer=null}willUpdate(t){}async initData(){}show(){this.isHidden&&(this.isHidden=!1)}hide(){if(this.isHidden)return;if(null===this.shadowRoot)throw Error("Shadow root is null");const t=this.shadowRoot.querySelector(".menu");if(!t)throw Error("Menu element not found");t.animate({opacity:[1,0]},{duration:200,easing:"ease-in-out"}).onfinish=()=>{this.isHidden=!0}}menuItemClicked(t,e){t.stopPropagation(),t.preventDefault();const s=new CustomEvent("menu-item-clicked",{bubbles:!0,composed:!0,detail:e});this.dispatchEvent(s)}render(){let t=o``;for(const[e,s]of this.menuItems.entries()){const e=s.name,i=s.icon;t=o`${t}<button
|
|
2
|
+
class="menu-item"
|
|
3
|
+
@click=${t=>{this.menuItemClicked(t,e)}}
|
|
4
|
+
>
|
|
5
|
+
<span class="svg-icon">${r(i)}</span>
|
|
6
|
+
${e}
|
|
7
|
+
</button>`}return o` <div class="menu">${t}</div> `}};h.styles=[e`
|
|
8
|
+
${t(u)}
|
|
9
|
+
`],m([s({type:Array,attribute:!1})],h.prototype,"menuItems",2),m([i()],h.prototype,"isHidden",2),h=m([a("nightjar-menu")],h);export{h as NightjarMenu};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { LitElement, PropertyValues } from 'lit';
|
|
2
|
+
import { Message } from '../../types/harmony-types';
|
|
3
|
+
/**
|
|
4
|
+
* Message code element.
|
|
5
|
+
*/
|
|
6
|
+
export declare class EuphonyMessageCode extends LitElement {
|
|
7
|
+
message: Message | null;
|
|
8
|
+
constructor();
|
|
9
|
+
firstUpdated(): void;
|
|
10
|
+
willUpdate(changedProperties: PropertyValues<this>): void;
|
|
11
|
+
initData(): Promise<void>;
|
|
12
|
+
getHighlightedCode(code: string, language?: string | null): import('lit').TemplateResult<1>;
|
|
13
|
+
render(): import('lit').TemplateResult<1>;
|
|
14
|
+
static styles: import('lit').CSSResult[];
|
|
15
|
+
}
|
|
16
|
+
declare global {
|
|
17
|
+
interface HTMLElementTagNameMap {
|
|
18
|
+
'euphony-message-code': EuphonyMessageCode;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import{b as e,v as t,i as s,n,a as r,x as a,w as i}from"../../chunks/third-party.js";import{p as c}from"../../chunks/prismjs.js";import{g as o,a as p}from"../../chunks/harmony-types.js";import{p as h}from"../../chunks/css-inline.js";import{c as g}from"../../chunks/css/message-code.js";function l(e){const t=e.replace(/\r\n/g,"\n").trim();return/^```[^\n]*\n([\s\S]*?)\n```$/.exec(t)?.[1]??e}function u(e){const t=l(e).replace(/\r\n/g,"\n"),s=t.split("\n"),n=s.findIndex(e=>"*** Begin Patch"===e||"@@"===e||e.startsWith("@@ "));return n>=0?s.slice(n).join("\n"):t}function d(e){const t=u(e).trim();return!(!t.startsWith("*** Begin Patch")||!t.includes("*** End Patch"))||t.startsWith("@@")}function m(e){return e.startsWith("+")&&!e.startsWith("+++")?"patch-line-add":e.startsWith("-")&&!e.startsWith("---")?"patch-line-delete":"patch-line"}function f(t){if(!d(t))return null;const s=u(t).replace(/\r\n/g,"\n").split("\n");return e`<pre class="message-pre patch-pre"><code>${s.map(t=>e`<div class=${m(t)}><span class="patch-text">${t}</span></div>`)}</code></pre>`}var $=Object.defineProperty,y=Object.getOwnPropertyDescriptor,j=(e,t,s,n)=>{for(var r,a=n>1?void 0:n?y(t,s):t,i=e.length-1;i>=0;i--)(r=e[i])&&(a=(n?r(t,s,a):r(a))||a);return n&&a&&$(t,s,a),a};let v=class extends r{constructor(){super(),this.message=null}firstUpdated(){}willUpdate(e){if(e.has("message")&&this.message){const e=o(this.message.content);if("code"!==e)throw new Error(`Invalid message type, expect code, but got: ${e}`)}}async initData(){}getHighlightedCode(t,s){if(!s)return e`${t}`;if(!(s in c.languages))return e`${t}`;const n=c.languages[s],r=c.highlight(t,n,s);return e`${a(r)}`}render(){if(!this.message)return e``;const t=p(this.message.content),s=f(t.text);return e`
|
|
2
|
+
<div class="message-content">
|
|
3
|
+
${s??e`
|
|
4
|
+
<pre class="message-pre"><code>${this.getHighlightedCode(t.text,t.language)}</code></pre>
|
|
5
|
+
`}
|
|
6
|
+
</div>
|
|
7
|
+
`}};v.styles=[s`
|
|
8
|
+
${t(g)}
|
|
9
|
+
${t(h)}
|
|
10
|
+
`],j([n({attribute:!1})],v.prototype,"message",2),v=j([i("euphony-message-code")],v);export{v as EuphonyMessageCode};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { LitElement, PropertyValues, TemplateResult } from 'lit';
|
|
2
|
+
import { BlockContent } from '../../types/common-types';
|
|
3
|
+
import { Message } from '../../types/harmony-types';
|
|
4
|
+
interface EditMetadata {
|
|
5
|
+
location: 'instruction' | 'tool_namespace_name' | 'tool_namespace_description';
|
|
6
|
+
index: number | string;
|
|
7
|
+
}
|
|
8
|
+
export interface DeveloperContentEditPayload extends EditMetadata {
|
|
9
|
+
newContent: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Message developer content element.
|
|
13
|
+
*/
|
|
14
|
+
export declare class EuphonyMessageDeveloperContent extends LitElement {
|
|
15
|
+
message: Message | null;
|
|
16
|
+
shouldRenderMarkdown: boolean;
|
|
17
|
+
markdownAllowedTags: string[] | null;
|
|
18
|
+
markdownAllowedAttributes: string[] | null;
|
|
19
|
+
isEditable: boolean;
|
|
20
|
+
blockContents: BlockContent[];
|
|
21
|
+
constructor();
|
|
22
|
+
/**
|
|
23
|
+
* This method is called when the DOM is added for the first time
|
|
24
|
+
*/
|
|
25
|
+
firstUpdated(): void;
|
|
26
|
+
/**
|
|
27
|
+
* This method is called before new DOM is updated and rendered
|
|
28
|
+
* @param changedProperties Property that has been changed
|
|
29
|
+
*/
|
|
30
|
+
willUpdate(changedProperties: PropertyValues<this>): void;
|
|
31
|
+
initData(): Promise<void>;
|
|
32
|
+
messageTextChanged(e: InputEvent, editMetadata: EditMetadata): void;
|
|
33
|
+
resetBlockContents(): void;
|
|
34
|
+
getHighlightedCode(code: string, language: string): TemplateResult<1>;
|
|
35
|
+
getEditableTemplate: (content: string, editMetadata: EditMetadata) => TemplateResult<1>;
|
|
36
|
+
renderNamespaceTable(namespaceKey: string, name: string, description: string, isEditable: boolean): TemplateResult<1>;
|
|
37
|
+
render(): TemplateResult<1>;
|
|
38
|
+
static styles: import('lit').CSSResult[];
|
|
39
|
+
}
|
|
40
|
+
declare global {
|
|
41
|
+
interface HTMLElementTagNameMap {
|
|
42
|
+
'euphony-message-developer-content': EuphonyMessageDeveloperContent;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export {};
|