@marimo-team/islands 0.25.1-dev27 → 0.25.1-dev28
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/{ErrorBoundary-D4ttmcVM.js → ErrorBoundary-CE6-1WC1.js} +1 -1
- package/dist/{code-visibility-BPU-HPcn.js → code-visibility--u2Q2Zfx.js} +1 -1
- package/dist/{common-BqBhuV4I.js → common-hHL7iKzA.js} +1 -1
- package/dist/{data-grid-overlay-editor-J_6pQ0_d.js → data-grid-overlay-editor-v7VZO5up.js} +1 -1
- package/dist/{feedback-button-BaxvkeuW.js → feedback-button-C3Ya1IXo.js} +2 -2
- package/dist/{glide-data-editor-CQLOtNIR.js → glide-data-editor-BKOLh2Tv.js} +3 -3
- package/dist/{globals-CNGEBL2Q.js → globals-DOJr_y24.js} +1 -1
- package/dist/main.js +6 -6
- package/dist/{number-overlay-editor-BdiJ3rzS.js → number-overlay-editor-DkEFJYK7.js} +1 -1
- package/dist/{reveal-component-Bphz8syB.js → reveal-component-rbEv9ppg.js} +2 -2
- package/package.json +1 -1
- package/src/__mocks__/common.ts +3 -3
- package/src/__tests__/CellStatus.test.tsx +1 -1
- package/src/__tests__/setup.ts +7 -7
- package/src/components/data-table/column-summary/chart-spec-model.tsx +4 -4
- package/src/components/dependency-graph/elements.ts +2 -2
- package/src/components/editor/ai/staged-cell-submission.ts +2 -2
- package/src/components/editor/ai/transport/chat-transport.tsx +1 -1
- package/src/components/editor/connections/database/as-code.ts +44 -44
- package/src/components/editor/connections/storage/as-code.ts +3 -3
- package/src/components/editor/file-tree/requesting-tree.tsx +16 -13
- package/src/components/editor/navigation/clipboard.ts +2 -2
- package/src/components/editor/output/ansi-reduce.ts +13 -13
- package/src/components/slides/__tests__/minimap-actions.test.tsx +7 -7
- package/src/components/slides/__tests__/minimap.test.ts +12 -12
- package/src/components/slides/__tests__/slide-scroll-hint.test.tsx +8 -8
- package/src/core/ai/context/__tests__/registry.test.ts +31 -28
- package/src/core/ai/context/providers/cell-output.ts +8 -8
- package/src/core/ai/context/providers/datasource.ts +10 -7
- package/src/core/ai/context/providers/error.ts +7 -7
- package/src/core/ai/context/providers/file.ts +8 -8
- package/src/core/ai/context/providers/tables.ts +7 -7
- package/src/core/ai/context/providers/variable.ts +7 -7
- package/src/core/ai/context/registry.ts +18 -18
- package/src/core/ai/ids/ids.ts +5 -5
- package/src/core/ai/model-registry.ts +12 -9
- package/src/core/ai/staged-cells.ts +6 -6
- package/src/core/ai/tools/base.ts +6 -6
- package/src/core/ai/tools/edit-notebook-tool.ts +6 -6
- package/src/core/ai/tools/registry.ts +4 -4
- package/src/core/ai/tools/run-cells-tool.ts +7 -7
- package/src/core/ai/tools/sample-tool.ts +6 -6
- package/src/core/codemirror/cells/debugger-decorations.ts +13 -7
- package/src/core/codemirror/cells/line-timing-decorations.ts +9 -9
- package/src/core/codemirror/cells/traceback-decorations.ts +7 -4
- package/src/core/codemirror/code-lens/extension.ts +13 -13
- package/src/core/codemirror/copilot/__tests__/language-server.test.ts +6 -6
- package/src/core/codemirror/copilot/__tests__/transport.test.ts +12 -12
- package/src/core/codemirror/copilot/language-server.ts +13 -13
- package/src/core/codemirror/copilot/transport.ts +1 -1
- package/src/core/codemirror/find-replace/search-highlight.ts +5 -5
- package/src/core/codemirror/go-to-definition/underline.ts +3 -3
- package/src/core/codemirror/keymaps/vim.ts +3 -3
- package/src/core/codemirror/language/languages/markdown.ts +8 -8
- package/src/core/codemirror/language/languages/python.ts +7 -7
- package/src/core/codemirror/language/languages/sql/completion-builder.ts +5 -5
- package/src/core/codemirror/language/languages/sql/completion-store.ts +4 -4
- package/src/core/codemirror/language/languages/sql/sql.ts +21 -21
- package/src/core/codemirror/lsp/__tests__/transports.test.ts +10 -10
- package/src/core/codemirror/lsp/federated-lsp.ts +29 -27
- package/src/core/codemirror/lsp/notebook-lsp.ts +21 -21
- package/src/core/codemirror/misc/__tests__/dnd.test.ts +10 -10
- package/src/core/codemirror/misc/__tests__/paste.test.ts +7 -4
- package/src/core/codemirror/reactive-references/extension.ts +3 -3
- package/src/core/codemirror/rtc/loro/awareness.ts +12 -12
- package/src/core/codemirror/rtc/loro/sync.ts +5 -5
- package/src/core/codemirror/vim/cursor-visibility.ts +3 -3
- package/src/core/dom/ui-element.ts +5 -5
- package/src/core/dom/uiregistry.ts +10 -10
- package/src/core/hotkeys/hotkeys.ts +9 -9
- package/src/core/islands/__tests__/bridge.test.ts +4 -4
- package/src/core/islands/__tests__/test-utils.tsx +4 -4
- package/src/core/islands/bridge.ts +85 -82
- package/src/core/islands/components/web-components.tsx +7 -7
- package/src/core/islands/worker/__tests__/controller.test.ts +1 -1
- package/src/core/islands/worker/controller.ts +6 -3
- package/src/core/islands/worker-factory.ts +2 -2
- package/src/core/kernel/RuntimeState.ts +4 -4
- package/src/core/lsp/__tests__/transport.test.ts +19 -19
- package/src/core/lsp/transport.ts +5 -5
- package/src/core/network/CachingRequestRegistry.ts +2 -2
- package/src/core/network/DeferredRequestRegistry.ts +4 -4
- package/src/core/runtime/runtime.ts +25 -20
- package/src/core/static/virtual-file-tracker.ts +5 -5
- package/src/core/wasm/__tests__/bridge.test.ts +2 -2
- package/src/core/wasm/bridge.ts +130 -126
- package/src/core/wasm/router.ts +5 -5
- package/src/core/wasm/store.ts +4 -4
- package/src/core/wasm/worker/bootstrap.ts +8 -5
- package/src/core/wasm/worker/message-buffer.ts +3 -3
- package/src/core/websocket/transports/__tests__/ws.test.ts +8 -8
- package/src/core/websocket/transports/basic.ts +15 -8
- package/src/core/websocket/transports/sse.ts +7 -7
- package/src/core/websocket/transports/transport.ts +3 -3
- package/src/core/websocket/transports/ws.ts +9 -7
- package/src/hooks/__tests__/useOverflowDetection.test.tsx +5 -5
- package/src/hooks/__tests__/useResizeObserver.test.tsx +12 -12
- package/src/plugins/core/registerReactComponent.tsx +5 -5
- package/src/plugins/core/sidebar-element.tsx +2 -2
- package/src/plugins/impl/ButtonPlugin.tsx +3 -3
- package/src/plugins/impl/CheckboxPlugin.tsx +3 -3
- package/src/plugins/impl/CodeEditorPlugin.tsx +3 -3
- package/src/plugins/impl/DatePickerPlugin.tsx +3 -3
- package/src/plugins/impl/DateRangePlugin.tsx +3 -3
- package/src/plugins/impl/DateTimePickerPlugin.tsx +3 -3
- package/src/plugins/impl/DictPlugin.tsx +3 -3
- package/src/plugins/impl/DropdownPlugin.tsx +3 -3
- package/src/plugins/impl/FileUploadPlugin.tsx +3 -3
- package/src/plugins/impl/MatrixPlugin.tsx +4 -4
- package/src/plugins/impl/MicrophonePlugin.tsx +3 -3
- package/src/plugins/impl/MultiselectPlugin.tsx +3 -3
- package/src/plugins/impl/NumberPlugin.tsx +3 -3
- package/src/plugins/impl/RadioPlugin.tsx +3 -3
- package/src/plugins/impl/RangeSliderPlugin.tsx +3 -3
- package/src/plugins/impl/RefreshPlugin.tsx +3 -3
- package/src/plugins/impl/SliderPlugin.tsx +3 -3
- package/src/plugins/impl/SwitchPlugin.tsx +3 -3
- package/src/plugins/impl/TabsPlugin.tsx +3 -3
- package/src/plugins/impl/TextAreaPlugin.tsx +3 -3
- package/src/plugins/impl/TextInputPlugin.tsx +3 -3
- package/src/plugins/impl/__tests__/MatrixPlugin.test.tsx +2 -2
- package/src/plugins/impl/anywidget/model.ts +10 -10
- package/src/plugins/impl/anywidget/registry.ts +12 -9
- package/src/plugins/impl/anywidget/runtime.ts +11 -9
- package/src/plugins/impl/anywidget/widget-binding.ts +6 -6
- package/src/plugins/impl/matplotlib/MatplotlibPlugin.tsx +3 -3
- package/src/plugins/impl/matplotlib/__tests__/matplotlib-renderer.test.ts +2 -2
- package/src/plugins/impl/matplotlib/matplotlib-renderer.ts +2 -2
- package/src/plugins/impl/mpl-interactive/mpl-websocket-shim.ts +10 -10
- package/src/plugins/impl/panel/utils.ts +5 -5
- package/src/plugins/impl/plotly/PlotlyPlugin.tsx +3 -3
- package/src/plugins/impl/vega/VegaPlugin.tsx +3 -3
- package/src/plugins/impl/vega/__tests__/use-vega-container-remeasure.test.ts +7 -7
- package/src/plugins/layout/AccordionPlugin.tsx +3 -3
- package/src/plugins/layout/CalloutPlugin.tsx +3 -3
- package/src/plugins/layout/ImageComparisonPlugin.tsx +5 -3
- package/src/plugins/layout/JsonOutputPlugin.tsx +3 -3
- package/src/plugins/layout/MimeRenderPlugin.tsx +3 -3
- package/src/plugins/layout/NavigationMenuPlugin.tsx +3 -3
- package/src/plugins/layout/OutlinePlugin.tsx +3 -3
- package/src/plugins/layout/ProgressPlugin.tsx +3 -3
- package/src/plugins/layout/RoutesPlugin.tsx +3 -3
- package/src/plugins/layout/StatPlugin.tsx +3 -3
- package/src/plugins/layout/TexPlugin.tsx +3 -3
- package/src/plugins/layout/carousel/CarouselPlugin.tsx +4 -4
- package/src/plugins/layout/mermaid/MermaidPlugin.tsx +3 -3
- package/src/utils/Deferred.ts +6 -6
- package/src/utils/async-capture-tracker.ts +10 -7
- package/src/utils/errors.ts +5 -5
- package/src/utils/id-tree.tsx +83 -80
- package/src/utils/lru.ts +1 -1
- package/src/utils/multi-map.ts +14 -12
- package/src/utils/paths.ts +6 -6
- package/src/utils/pluralize.ts +3 -3
- package/src/utils/progress.ts +6 -6
- package/src/utils/python-poet/poet.ts +14 -14
- package/src/utils/routes.ts +4 -2
- package/src/utils/semaphore.ts +6 -6
- package/src/utils/storage/storage.ts +6 -6
- package/src/utils/storage/typed.ts +16 -12
- package/src/utils/time.ts +9 -9
- package/src/utils/timed-cache.ts +4 -4
- package/src/utils/tracer.ts +9 -6
|
@@ -26,14 +26,14 @@ export const StorageLibraryDisplayNames: Record<StorageLibrary, string> = {
|
|
|
26
26
|
class SecretContainer {
|
|
27
27
|
private secrets: Record<string, string> = {};
|
|
28
28
|
|
|
29
|
-
get imports(): Set<string> {
|
|
29
|
+
public get imports(): Set<string> {
|
|
30
30
|
if (Object.keys(this.secrets).length === 0) {
|
|
31
31
|
return new Set<string>();
|
|
32
32
|
}
|
|
33
33
|
return new Set<string>(["import os"]);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
print(varName: string, value: string | undefined): string {
|
|
36
|
+
public print(varName: string, value: string | undefined): string {
|
|
37
37
|
if (value === undefined || value === "") {
|
|
38
38
|
return "";
|
|
39
39
|
}
|
|
@@ -46,7 +46,7 @@ class SecretContainer {
|
|
|
46
46
|
return `"${escapePythonString(value)}"`;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
formatSecrets(): string {
|
|
49
|
+
public formatSecrets(): string {
|
|
50
50
|
if (Object.keys(this.secrets).length === 0) {
|
|
51
51
|
return "";
|
|
52
52
|
}
|
|
@@ -55,7 +55,7 @@ export class RequestingTree {
|
|
|
55
55
|
renameFileOrFolder: EditRequests["sendRenameFileOrFolder"];
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
-
constructor(callbacks: {
|
|
58
|
+
public constructor(callbacks: {
|
|
59
59
|
getRoots: EditRequests["getFileRoots"];
|
|
60
60
|
listFiles: EditRequests["sendListFiles"];
|
|
61
61
|
createFileOrFolder: EditRequests["sendCreateFileOrFolder"];
|
|
@@ -71,7 +71,7 @@ export class RequestingTree {
|
|
|
71
71
|
private onChange: (data: FileTreeNode[]) => void = Functions.NOOP;
|
|
72
72
|
private path = new PathBuilder("/");
|
|
73
73
|
|
|
74
|
-
initialize = async (
|
|
74
|
+
public initialize = async (
|
|
75
75
|
onChange: (data: FileTreeNode[]) => void,
|
|
76
76
|
): Promise<void> => {
|
|
77
77
|
this.onChange = onChange;
|
|
@@ -102,7 +102,7 @@ export class RequestingTree {
|
|
|
102
102
|
this.emitChange();
|
|
103
103
|
};
|
|
104
104
|
|
|
105
|
-
expand(id: string): Promise<boolean> {
|
|
105
|
+
public expand(id: string): Promise<boolean> {
|
|
106
106
|
return this.requestDirectory(id);
|
|
107
107
|
}
|
|
108
108
|
|
|
@@ -149,11 +149,11 @@ export class RequestingTree {
|
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
getRoots(): readonly FileRoot[] {
|
|
152
|
+
public getRoots(): readonly FileRoot[] {
|
|
153
153
|
return this.roots;
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
-
async reveal(node: FileTreeNode): Promise<boolean> {
|
|
156
|
+
public async reveal(node: FileTreeNode): Promise<boolean> {
|
|
157
157
|
const relative = relativePath(node.path as FilePath, node.rootPath);
|
|
158
158
|
if (relative === null) {
|
|
159
159
|
return false;
|
|
@@ -190,7 +190,7 @@ export class RequestingTree {
|
|
|
190
190
|
return true;
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
-
async copy(id: string, newName: string): Promise<void> {
|
|
193
|
+
public async copy(id: string, newName: string): Promise<void> {
|
|
194
194
|
const node = this.getMutableNode(id);
|
|
195
195
|
if (!node) {
|
|
196
196
|
return;
|
|
@@ -206,7 +206,7 @@ export class RequestingTree {
|
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
-
async rename(id: string, name: string): Promise<void> {
|
|
209
|
+
public async rename(id: string, name: string): Promise<void> {
|
|
210
210
|
const node = this.getMutableNode(id);
|
|
211
211
|
if (!node) {
|
|
212
212
|
return;
|
|
@@ -222,7 +222,7 @@ export class RequestingTree {
|
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
224
|
|
|
225
|
-
async move(fromIds: string[], parentId: string | null): Promise<void> {
|
|
225
|
+
public async move(fromIds: string[], parentId: string | null): Promise<void> {
|
|
226
226
|
const targetParentId = parentId ?? this.getPrimaryRootId();
|
|
227
227
|
const parent = this.delegate.find(targetParentId);
|
|
228
228
|
if (!parent?.data.isDirectory) {
|
|
@@ -253,7 +253,7 @@ export class RequestingTree {
|
|
|
253
253
|
await this.refreshPaths([...refreshPaths]);
|
|
254
254
|
}
|
|
255
255
|
|
|
256
|
-
async createFile({
|
|
256
|
+
public async createFile({
|
|
257
257
|
name,
|
|
258
258
|
parentId,
|
|
259
259
|
type = "file",
|
|
@@ -278,7 +278,10 @@ export class RequestingTree {
|
|
|
278
278
|
}
|
|
279
279
|
}
|
|
280
280
|
|
|
281
|
-
async createFolder(
|
|
281
|
+
public async createFolder(
|
|
282
|
+
name: string,
|
|
283
|
+
parentId: string | null,
|
|
284
|
+
): Promise<void> {
|
|
282
285
|
const parent = this.getParentNode(parentId);
|
|
283
286
|
if (!parent) {
|
|
284
287
|
return;
|
|
@@ -295,7 +298,7 @@ export class RequestingTree {
|
|
|
295
298
|
}
|
|
296
299
|
}
|
|
297
300
|
|
|
298
|
-
async delete(id: string): Promise<void> {
|
|
301
|
+
public async delete(id: string): Promise<void> {
|
|
299
302
|
const node = this.getMutableNode(id);
|
|
300
303
|
if (!node) {
|
|
301
304
|
return;
|
|
@@ -309,7 +312,7 @@ export class RequestingTree {
|
|
|
309
312
|
}
|
|
310
313
|
}
|
|
311
314
|
|
|
312
|
-
refreshAll = async (ids: string[]): Promise<void> => {
|
|
315
|
+
public refreshAll = async (ids: string[]): Promise<void> => {
|
|
313
316
|
const paths = [
|
|
314
317
|
...this.roots.map((root) => root.path),
|
|
315
318
|
...ids
|
|
@@ -325,7 +328,7 @@ export class RequestingTree {
|
|
|
325
328
|
);
|
|
326
329
|
};
|
|
327
330
|
|
|
328
|
-
refreshPath = async (path: FilePath): Promise<void> => {
|
|
331
|
+
public refreshPath = async (path: FilePath): Promise<void> => {
|
|
329
332
|
await this.refreshPaths([path]);
|
|
330
333
|
};
|
|
331
334
|
|
|
@@ -257,7 +257,7 @@ const toastPasteFailed = () => {
|
|
|
257
257
|
class ClipboardItemBuilder {
|
|
258
258
|
private items: Record<string, string | Blob> = {};
|
|
259
259
|
|
|
260
|
-
add(mimeType: string, value: string | object) {
|
|
260
|
+
public add(mimeType: string, value: string | object) {
|
|
261
261
|
// Skip if the browser doesn't support the mime type
|
|
262
262
|
if (!ClipboardItem.supports(mimeType)) {
|
|
263
263
|
Logger.warn(`ClipboardItem does not support ${mimeType}`);
|
|
@@ -275,7 +275,7 @@ class ClipboardItemBuilder {
|
|
|
275
275
|
return this;
|
|
276
276
|
}
|
|
277
277
|
|
|
278
|
-
build() {
|
|
278
|
+
public build() {
|
|
279
279
|
return new ClipboardItem(this.items);
|
|
280
280
|
}
|
|
281
281
|
}
|
|
@@ -42,7 +42,7 @@ export class TerminalBuffer {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
/** Write a visible character at the current cursor position. */
|
|
45
|
-
writeChar(ch: string) {
|
|
45
|
+
public writeChar(ch: string) {
|
|
46
46
|
this.ensureLine(this.cursor.row);
|
|
47
47
|
const line = this.lines[this.cursor.row];
|
|
48
48
|
const padded = line.padEnd(this.cursor.col, " ");
|
|
@@ -52,7 +52,7 @@ export class TerminalBuffer {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
/** Write a string of visible characters at the current cursor position (optimized batch write). */
|
|
55
|
-
writeString(str: string) {
|
|
55
|
+
public writeString(str: string) {
|
|
56
56
|
if (str.length === 0) {
|
|
57
57
|
return;
|
|
58
58
|
}
|
|
@@ -67,7 +67,7 @@ export class TerminalBuffer {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
/** Handle simple control characters (\n, \r, \t, \b, \v). */
|
|
70
|
-
control(ch: string) {
|
|
70
|
+
public control(ch: string) {
|
|
71
71
|
switch (ch) {
|
|
72
72
|
case "\n":
|
|
73
73
|
this.cursor.row++;
|
|
@@ -95,7 +95,7 @@ export class TerminalBuffer {
|
|
|
95
95
|
* Supports cursor movement and line erasing.
|
|
96
96
|
* For other sequences (like color codes), preserve them by writing to the buffer.
|
|
97
97
|
*/
|
|
98
|
-
handleEscape(seq: string) {
|
|
98
|
+
public handleEscape(seq: string) {
|
|
99
99
|
const match = TerminalBuffer.ESCAPE_REGEX.exec(seq);
|
|
100
100
|
if (!match) {
|
|
101
101
|
// If it doesn't match the cursor movement pattern, it might be:
|
|
@@ -172,7 +172,7 @@ export class TerminalBuffer {
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
/** Return the final rendered buffer as a single string. */
|
|
175
|
-
render(): string {
|
|
175
|
+
public render(): string {
|
|
176
176
|
return this.lines.join("\n");
|
|
177
177
|
}
|
|
178
178
|
}
|
|
@@ -187,7 +187,7 @@ export class AnsiParser {
|
|
|
187
187
|
"gu",
|
|
188
188
|
);
|
|
189
189
|
|
|
190
|
-
parse(input: string): { type: "text" | "escape"; value: string }[] {
|
|
190
|
+
public parse(input: string): { type: "text" | "escape"; value: string }[] {
|
|
191
191
|
const tokens: { type: "text" | "escape"; value: string }[] = [];
|
|
192
192
|
let lastIndex = 0;
|
|
193
193
|
|
|
@@ -221,7 +221,7 @@ export class AnsiReducer {
|
|
|
221
221
|
* Process the entire input string (replaces any previous state).
|
|
222
222
|
* Use this for one-time processing or when starting fresh.
|
|
223
223
|
*/
|
|
224
|
-
reduce(input: string): string {
|
|
224
|
+
public reduce(input: string): string {
|
|
225
225
|
this.reset();
|
|
226
226
|
this.append(input);
|
|
227
227
|
return this.render();
|
|
@@ -231,7 +231,7 @@ export class AnsiReducer {
|
|
|
231
231
|
* Append new input to the existing buffer (for streaming/incremental updates).
|
|
232
232
|
* This is efficient for streaming scenarios - only processes the new chunk.
|
|
233
233
|
*/
|
|
234
|
-
append(input: string): void {
|
|
234
|
+
public append(input: string): void {
|
|
235
235
|
const tokens = this.parser.parse(input);
|
|
236
236
|
|
|
237
237
|
// Fast path: if only one text token (no ANSI codes), handle directly
|
|
@@ -260,14 +260,14 @@ export class AnsiReducer {
|
|
|
260
260
|
* Reset the buffer and cursor to initial state.
|
|
261
261
|
* Use this when you want to start processing fresh input.
|
|
262
262
|
*/
|
|
263
|
-
reset(): void {
|
|
263
|
+
public reset(): void {
|
|
264
264
|
this.buffer = new TerminalBuffer();
|
|
265
265
|
}
|
|
266
266
|
|
|
267
267
|
/**
|
|
268
268
|
* Get the current rendered output without processing new input.
|
|
269
269
|
*/
|
|
270
|
-
render(): string {
|
|
270
|
+
public render(): string {
|
|
271
271
|
return this.buffer.render();
|
|
272
272
|
}
|
|
273
273
|
|
|
@@ -375,7 +375,7 @@ export class StatefulOutputMessage implements OutputMessage {
|
|
|
375
375
|
return this._data;
|
|
376
376
|
}
|
|
377
377
|
|
|
378
|
-
static create(message: StringOutputMessage): StatefulOutputMessage {
|
|
378
|
+
public static create(message: StringOutputMessage): StatefulOutputMessage {
|
|
379
379
|
const ansiReducer = new AnsiReducer();
|
|
380
380
|
ansiReducer.append(message.data);
|
|
381
381
|
return new StatefulOutputMessage(
|
|
@@ -399,7 +399,7 @@ export class StatefulOutputMessage implements OutputMessage {
|
|
|
399
399
|
this._data = this.ansiReducer.render();
|
|
400
400
|
}
|
|
401
401
|
|
|
402
|
-
appendData(chunk: string): StatefulOutputMessage {
|
|
402
|
+
public appendData(chunk: string): StatefulOutputMessage {
|
|
403
403
|
this.ansiReducer.append(chunk);
|
|
404
404
|
return new StatefulOutputMessage(
|
|
405
405
|
this.mimetype,
|
|
@@ -409,7 +409,7 @@ export class StatefulOutputMessage implements OutputMessage {
|
|
|
409
409
|
);
|
|
410
410
|
}
|
|
411
411
|
|
|
412
|
-
toJSON(): StringOutputMessage {
|
|
412
|
+
public toJSON(): StringOutputMessage {
|
|
413
413
|
return {
|
|
414
414
|
mimetype: this.mimetype,
|
|
415
415
|
channel: this.channel,
|
|
@@ -46,21 +46,21 @@ beforeAll(() => {
|
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
48
|
global.IntersectionObserver ??= class {
|
|
49
|
-
observe() {
|
|
49
|
+
public observe() {
|
|
50
50
|
/* noop */
|
|
51
51
|
}
|
|
52
|
-
unobserve() {
|
|
52
|
+
public unobserve() {
|
|
53
53
|
/* noop */
|
|
54
54
|
}
|
|
55
|
-
disconnect() {
|
|
55
|
+
public disconnect() {
|
|
56
56
|
/* noop */
|
|
57
57
|
}
|
|
58
|
-
takeRecords() {
|
|
58
|
+
public takeRecords() {
|
|
59
59
|
return [];
|
|
60
60
|
}
|
|
61
|
-
root = null;
|
|
62
|
-
rootMargin = "";
|
|
63
|
-
thresholds = [];
|
|
61
|
+
public root = null;
|
|
62
|
+
public rootMargin = "";
|
|
63
|
+
public thresholds = [];
|
|
64
64
|
} as unknown as typeof IntersectionObserver;
|
|
65
65
|
});
|
|
66
66
|
|
|
@@ -42,28 +42,28 @@ describe("useVisibleCellIds", () => {
|
|
|
42
42
|
mutationObserveSpy = vi.fn();
|
|
43
43
|
|
|
44
44
|
global.IntersectionObserver = class MockIntersectionObserver {
|
|
45
|
-
constructor(
|
|
45
|
+
public constructor(
|
|
46
46
|
callback: IntersectionObserverCallback,
|
|
47
47
|
_options?: IntersectionObserverInit,
|
|
48
48
|
) {
|
|
49
49
|
intersectionCallback = callback;
|
|
50
50
|
}
|
|
51
|
-
observe = observeSpy;
|
|
52
|
-
unobserve = vi.fn();
|
|
53
|
-
disconnect = intersectionDisconnectSpy;
|
|
54
|
-
root = null;
|
|
55
|
-
rootMargin = "";
|
|
56
|
-
thresholds = [0];
|
|
57
|
-
takeRecords = vi.fn(() => []);
|
|
51
|
+
public observe = observeSpy;
|
|
52
|
+
public unobserve = vi.fn();
|
|
53
|
+
public disconnect = intersectionDisconnectSpy;
|
|
54
|
+
public root = null;
|
|
55
|
+
public rootMargin = "";
|
|
56
|
+
public thresholds = [0];
|
|
57
|
+
public takeRecords = vi.fn(() => []);
|
|
58
58
|
} as unknown as typeof IntersectionObserver;
|
|
59
59
|
|
|
60
60
|
global.MutationObserver = class MockMutationObserver {
|
|
61
|
-
constructor(callback: MutationCallback) {
|
|
61
|
+
public constructor(callback: MutationCallback) {
|
|
62
62
|
mutationCallback = callback;
|
|
63
63
|
}
|
|
64
|
-
observe = mutationObserveSpy;
|
|
65
|
-
disconnect = mutationDisconnectSpy;
|
|
66
|
-
takeRecords = vi.fn(() => []);
|
|
64
|
+
public observe = mutationObserveSpy;
|
|
65
|
+
public disconnect = mutationDisconnectSpy;
|
|
66
|
+
public takeRecords = vi.fn(() => []);
|
|
67
67
|
} as unknown as typeof MutationObserver;
|
|
68
68
|
});
|
|
69
69
|
|
|
@@ -76,12 +76,12 @@ describe("SlideScrollContainer", () => {
|
|
|
76
76
|
vi.stubGlobal(
|
|
77
77
|
"ResizeObserver",
|
|
78
78
|
class MockResizeObserver {
|
|
79
|
-
callback: ResizeObserverCallback;
|
|
80
|
-
observe = vi.fn();
|
|
81
|
-
unobserve = vi.fn();
|
|
82
|
-
disconnect = vi.fn();
|
|
79
|
+
public callback: ResizeObserverCallback;
|
|
80
|
+
public observe = vi.fn();
|
|
81
|
+
public unobserve = vi.fn();
|
|
82
|
+
public disconnect = vi.fn();
|
|
83
83
|
|
|
84
|
-
constructor(callback: ResizeObserverCallback) {
|
|
84
|
+
public constructor(callback: ResizeObserverCallback) {
|
|
85
85
|
this.callback = callback;
|
|
86
86
|
resizeObservers.push(this);
|
|
87
87
|
}
|
|
@@ -90,9 +90,9 @@ describe("SlideScrollContainer", () => {
|
|
|
90
90
|
vi.stubGlobal(
|
|
91
91
|
"MutationObserver",
|
|
92
92
|
class MockMutationObserver {
|
|
93
|
-
observe = vi.fn();
|
|
94
|
-
disconnect = vi.fn();
|
|
95
|
-
takeRecords = vi.fn(() => []);
|
|
93
|
+
public observe = vi.fn();
|
|
94
|
+
public disconnect = vi.fn();
|
|
95
|
+
public takeRecords = vi.fn(() => []);
|
|
96
96
|
},
|
|
97
97
|
);
|
|
98
98
|
});
|
|
@@ -44,9 +44,9 @@ const mockAttachment2: FileUIPart = {
|
|
|
44
44
|
|
|
45
45
|
// Concrete implementation of AIContextProvider for testing
|
|
46
46
|
class MockContextProvider extends AIContextProvider<MockContextItem> {
|
|
47
|
-
readonly title = "Mock Items";
|
|
48
|
-
readonly mentionPrefix = "@";
|
|
49
|
-
readonly contextType = "mock";
|
|
47
|
+
public readonly title = "Mock Items";
|
|
48
|
+
public readonly mentionPrefix = "@";
|
|
49
|
+
public readonly contextType = "mock";
|
|
50
50
|
|
|
51
51
|
private items: MockContextItem[] = [
|
|
52
52
|
{
|
|
@@ -72,57 +72,60 @@ class MockContextProvider extends AIContextProvider<MockContextItem> {
|
|
|
72
72
|
},
|
|
73
73
|
];
|
|
74
74
|
|
|
75
|
-
getItems(): MockContextItem[] {
|
|
75
|
+
public getItems(): MockContextItem[] {
|
|
76
76
|
return this.items;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
formatContext(item: MockContextItem): string {
|
|
79
|
+
public formatContext(item: MockContextItem): string {
|
|
80
80
|
return `Mock: ${item.name} (${item.data.value})`;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
formatCompletion(item: MockContextItem): Completion {
|
|
83
|
+
public formatCompletion(item: MockContextItem): Completion {
|
|
84
84
|
return this.createBasicCompletion(item);
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
// Method to add items for testing
|
|
88
|
-
addItem(item: MockContextItem): void {
|
|
88
|
+
public addItem(item: MockContextItem): void {
|
|
89
89
|
this.items.push(item);
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
// Method to clear items for testing
|
|
93
|
-
clearItems(): void {
|
|
93
|
+
public clearItems(): void {
|
|
94
94
|
this.items = [];
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
// Test provider that supports attachments
|
|
99
99
|
class AttachmentContextProvider extends AIContextProvider<MockContextItem> {
|
|
100
|
-
readonly title = "Attachment Items";
|
|
101
|
-
readonly mentionPrefix = "@";
|
|
102
|
-
readonly contextType = "attachment";
|
|
100
|
+
public readonly title = "Attachment Items";
|
|
101
|
+
public readonly mentionPrefix = "@";
|
|
102
|
+
public readonly contextType = "attachment";
|
|
103
103
|
|
|
104
104
|
private items: MockContextItem[];
|
|
105
105
|
private attachments: FileUIPart[];
|
|
106
106
|
|
|
107
|
-
constructor(
|
|
107
|
+
public constructor(
|
|
108
|
+
items: MockContextItem[] = [],
|
|
109
|
+
attachments: FileUIPart[] = [],
|
|
110
|
+
) {
|
|
108
111
|
super();
|
|
109
112
|
this.items = items;
|
|
110
113
|
this.attachments = attachments;
|
|
111
114
|
}
|
|
112
115
|
|
|
113
|
-
getItems(): MockContextItem[] {
|
|
116
|
+
public getItems(): MockContextItem[] {
|
|
114
117
|
return this.items;
|
|
115
118
|
}
|
|
116
119
|
|
|
117
|
-
formatContext(item: MockContextItem): string {
|
|
120
|
+
public formatContext(item: MockContextItem): string {
|
|
118
121
|
return `Attachment: ${item.name} (${item.data.value})`;
|
|
119
122
|
}
|
|
120
123
|
|
|
121
|
-
formatCompletion(item: MockContextItem): Completion {
|
|
124
|
+
public formatCompletion(item: MockContextItem): Completion {
|
|
122
125
|
return this.createBasicCompletion(item);
|
|
123
126
|
}
|
|
124
127
|
|
|
125
|
-
override async getAttachments(
|
|
128
|
+
public override async getAttachments(
|
|
126
129
|
items: MockContextItem[],
|
|
127
130
|
): Promise<FileUIPart[]> {
|
|
128
131
|
// Return attachments for items that need them
|
|
@@ -142,9 +145,9 @@ interface FileContextItem extends AIContextItem {
|
|
|
142
145
|
|
|
143
146
|
// Another mock provider with different prefix and type
|
|
144
147
|
class FileContextProvider extends AIContextProvider<FileContextItem> {
|
|
145
|
-
readonly title = "Files";
|
|
146
|
-
readonly mentionPrefix = "@";
|
|
147
|
-
readonly contextType = "file";
|
|
148
|
+
public readonly title = "Files";
|
|
149
|
+
public readonly mentionPrefix = "@";
|
|
150
|
+
public readonly contextType = "file";
|
|
148
151
|
|
|
149
152
|
private items: FileContextItem[] = [
|
|
150
153
|
{
|
|
@@ -163,26 +166,26 @@ class FileContextProvider extends AIContextProvider<FileContextItem> {
|
|
|
163
166
|
},
|
|
164
167
|
];
|
|
165
168
|
|
|
166
|
-
getItems(): FileContextItem[] {
|
|
169
|
+
public getItems(): FileContextItem[] {
|
|
167
170
|
return this.items;
|
|
168
171
|
}
|
|
169
172
|
|
|
170
|
-
formatCompletion(item: FileContextItem): Completion {
|
|
173
|
+
public formatCompletion(item: FileContextItem): Completion {
|
|
171
174
|
return this.createBasicCompletion(item);
|
|
172
175
|
}
|
|
173
176
|
|
|
174
|
-
formatContext(item: FileContextItem): string {
|
|
177
|
+
public formatContext(item: FileContextItem): string {
|
|
175
178
|
return `File: ${item.uri}\nDescription: ${item.description}`;
|
|
176
179
|
}
|
|
177
180
|
}
|
|
178
181
|
|
|
179
182
|
// Second mock provider with the same context type as MockContextProvider
|
|
180
183
|
class SecondaryMockProvider extends AIContextProvider<MockContextItem> {
|
|
181
|
-
readonly title = "Secondary Mock Items";
|
|
182
|
-
readonly mentionPrefix = "@";
|
|
183
|
-
readonly contextType = "mock";
|
|
184
|
+
public readonly title = "Secondary Mock Items";
|
|
185
|
+
public readonly mentionPrefix = "@";
|
|
186
|
+
public readonly contextType = "mock";
|
|
184
187
|
|
|
185
|
-
getItems(): MockContextItem[] {
|
|
188
|
+
public getItems(): MockContextItem[] {
|
|
186
189
|
return [
|
|
187
190
|
{
|
|
188
191
|
type: "mock",
|
|
@@ -194,11 +197,11 @@ class SecondaryMockProvider extends AIContextProvider<MockContextItem> {
|
|
|
194
197
|
];
|
|
195
198
|
}
|
|
196
199
|
|
|
197
|
-
formatContext(item: MockContextItem): string {
|
|
200
|
+
public formatContext(item: MockContextItem): string {
|
|
198
201
|
return `Secondary: ${item.name}`;
|
|
199
202
|
}
|
|
200
203
|
|
|
201
|
-
formatCompletion(item: MockContextItem): Completion {
|
|
204
|
+
public formatCompletion(item: MockContextItem): Completion {
|
|
202
205
|
return this.createBasicCompletion(item);
|
|
203
206
|
}
|
|
204
207
|
}
|
|
@@ -80,16 +80,16 @@ function isMediaMimetype(
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
export class CellOutputContextProvider extends AIContextProvider<CellOutputContextItem> {
|
|
83
|
-
readonly title = "Cell Outputs";
|
|
84
|
-
readonly mentionPrefix = "@";
|
|
85
|
-
readonly contextType = "cell-output";
|
|
83
|
+
public readonly title = "Cell Outputs";
|
|
84
|
+
public readonly mentionPrefix = "@";
|
|
85
|
+
public readonly contextType = "cell-output";
|
|
86
86
|
private store: JotaiStore;
|
|
87
|
-
constructor(store: JotaiStore) {
|
|
87
|
+
public constructor(store: JotaiStore) {
|
|
88
88
|
super();
|
|
89
89
|
this.store = store;
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
getItems(): CellOutputContextItem[] {
|
|
92
|
+
public getItems(): CellOutputContextItem[] {
|
|
93
93
|
const notebook = this.store.get(notebookAtom);
|
|
94
94
|
const items: CellOutputContextItem[] = [];
|
|
95
95
|
|
|
@@ -116,7 +116,7 @@ export class CellOutputContextProvider extends AIContextProvider<CellOutputConte
|
|
|
116
116
|
return items;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
formatCompletion(item: CellOutputContextItem): Completion {
|
|
119
|
+
public formatCompletion(item: CellOutputContextItem): Completion {
|
|
120
120
|
const { cellOutput: data, cellName, cellCode } = item.data;
|
|
121
121
|
|
|
122
122
|
return {
|
|
@@ -224,7 +224,7 @@ export class CellOutputContextProvider extends AIContextProvider<CellOutputConte
|
|
|
224
224
|
};
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
-
formatContext(item: CellOutputContextItem): string {
|
|
227
|
+
public formatContext(item: CellOutputContextItem): string {
|
|
228
228
|
const { cellOutput: data, cellName, cellId, cellCode } = item.data;
|
|
229
229
|
|
|
230
230
|
const contextData = {
|
|
@@ -253,7 +253,7 @@ export class CellOutputContextProvider extends AIContextProvider<CellOutputConte
|
|
|
253
253
|
}
|
|
254
254
|
|
|
255
255
|
/** Get attachments for cell output items that have shouldDownloadImage=true */
|
|
256
|
-
override async getAttachments(
|
|
256
|
+
public override async getAttachments(
|
|
257
257
|
items: CellOutputContextItem[],
|
|
258
258
|
): Promise<FileUIPart[]> {
|
|
259
259
|
const cellId = items[0].data.cellId;
|
|
@@ -46,13 +46,16 @@ export interface DatasourceContextItem extends AIContextItem {
|
|
|
46
46
|
const CONTEXT_TYPE = "datasource";
|
|
47
47
|
|
|
48
48
|
export class DatasourceContextProvider extends AIContextProvider<DatasourceContextItem> {
|
|
49
|
-
readonly title = "Datasource";
|
|
50
|
-
readonly mentionPrefix = "@";
|
|
51
|
-
readonly contextType = CONTEXT_TYPE;
|
|
49
|
+
public readonly title = "Datasource";
|
|
50
|
+
public readonly mentionPrefix = "@";
|
|
51
|
+
public readonly contextType = CONTEXT_TYPE;
|
|
52
52
|
private connectionsMap: ConnectionsMap;
|
|
53
53
|
private dataframes: DataTable[];
|
|
54
54
|
|
|
55
|
-
constructor(
|
|
55
|
+
public constructor(
|
|
56
|
+
connectionsMap: ConnectionsMap,
|
|
57
|
+
tablesMap: DatasetTablesMap,
|
|
58
|
+
) {
|
|
56
59
|
super();
|
|
57
60
|
this.connectionsMap = connectionsMap;
|
|
58
61
|
this.dataframes = [...tablesMap.values()].filter(
|
|
@@ -60,7 +63,7 @@ export class DatasourceContextProvider extends AIContextProvider<DatasourceConte
|
|
|
60
63
|
);
|
|
61
64
|
}
|
|
62
65
|
|
|
63
|
-
getItems(): DatasourceContextItem[] {
|
|
66
|
+
public getItems(): DatasourceContextItem[] {
|
|
64
67
|
return [...this.connectionsMap.values()]
|
|
65
68
|
.map((connection): DatasourceContextItem | null => {
|
|
66
69
|
let description = "Database schema.";
|
|
@@ -92,7 +95,7 @@ export class DatasourceContextProvider extends AIContextProvider<DatasourceConte
|
|
|
92
95
|
.filter(Boolean);
|
|
93
96
|
}
|
|
94
97
|
|
|
95
|
-
formatContext(item: DatasourceContextItem): string {
|
|
98
|
+
public formatContext(item: DatasourceContextItem): string {
|
|
96
99
|
const data = item.data;
|
|
97
100
|
// Remove certain fields that are not needed in the context
|
|
98
101
|
const { name, display_name, source, ...filteredDatasource } =
|
|
@@ -117,7 +120,7 @@ export class DatasourceContextProvider extends AIContextProvider<DatasourceConte
|
|
|
117
120
|
});
|
|
118
121
|
}
|
|
119
122
|
|
|
120
|
-
formatCompletion(item: DatasourceContextItem): Completion {
|
|
123
|
+
public formatCompletion(item: DatasourceContextItem): Completion {
|
|
121
124
|
const datasource = item.data;
|
|
122
125
|
|
|
123
126
|
const dataConnection = datasource.connection;
|
|
@@ -95,17 +95,17 @@ function errorContextName(entry: CellErrorEntry): string {
|
|
|
95
95
|
|
|
96
96
|
const errorsTxt = new PluralWord("error", "errors");
|
|
97
97
|
export class ErrorContextProvider extends AIContextProvider<ErrorContextItem> {
|
|
98
|
-
readonly title = "Errors";
|
|
99
|
-
readonly mentionPrefix = "@";
|
|
100
|
-
readonly contextType = "error";
|
|
98
|
+
public readonly title = "Errors";
|
|
99
|
+
public readonly mentionPrefix = "@";
|
|
100
|
+
public readonly contextType = "error";
|
|
101
101
|
private store: JotaiStore;
|
|
102
102
|
|
|
103
|
-
constructor(store: JotaiStore) {
|
|
103
|
+
public constructor(store: JotaiStore) {
|
|
104
104
|
super();
|
|
105
105
|
this.store = store;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
getItems(): ErrorContextItem[] {
|
|
108
|
+
public getItems(): ErrorContextItem[] {
|
|
109
109
|
const errors = getCellErrorEntries(this.store);
|
|
110
110
|
|
|
111
111
|
if (errors.length === 0) {
|
|
@@ -141,7 +141,7 @@ export class ErrorContextProvider extends AIContextProvider<ErrorContextItem> {
|
|
|
141
141
|
return items;
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
formatCompletion(item: ErrorContextItem): Completion {
|
|
144
|
+
public formatCompletion(item: ErrorContextItem): Completion {
|
|
145
145
|
if (item.data.type === "all-errors") {
|
|
146
146
|
const errorCount = item.data.errors.length;
|
|
147
147
|
return {
|
|
@@ -201,7 +201,7 @@ export class ErrorContextProvider extends AIContextProvider<ErrorContextItem> {
|
|
|
201
201
|
};
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
-
formatContext(item: ErrorContextItem): string {
|
|
204
|
+
public formatContext(item: ErrorContextItem): string {
|
|
205
205
|
const entries =
|
|
206
206
|
item.data.type === "all-errors" ? item.data.errors : [item.data.error];
|
|
207
207
|
|