@marimo-team/islands 0.25.1-dev26 → 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-pWWhtr0s.js → ErrorBoundary-CE6-1WC1.js} +1 -1
- package/dist/{code-visibility-Ba_KMLhg.js → code-visibility--u2Q2Zfx.js} +1 -1
- package/dist/{common-Cqwp2VSj.js → common-hHL7iKzA.js} +1 -1
- package/dist/{data-grid-overlay-editor-CpH8-A59.js → data-grid-overlay-editor-v7VZO5up.js} +1 -1
- package/dist/{feedback-button-CJxD9fy8.js → feedback-button-C3Ya1IXo.js} +2 -2
- package/dist/{glide-data-editor-cm-NQofk.js → glide-data-editor-BKOLh2Tv.js} +3 -3
- package/dist/{globals-BquX8N9R.js → globals-DOJr_y24.js} +1 -1
- package/dist/main.js +6 -6
- package/dist/{number-overlay-editor-3AkAzj7F.js → number-overlay-editor-DkEFJYK7.js} +1 -1
- package/dist/{reveal-component-rC5k5pu3.js → reveal-component-rbEv9ppg.js} +2 -2
- package/dist/style.css +1 -1
- 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/app-config/ai-config.tsx +2 -0
- package/src/components/chat/chat-panel.tsx +19 -8
- 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/actions/__tests__/pair-with-agent.test.tsx +107 -0
- package/src/components/editor/actions/pair-with-agent.tsx +119 -0
- package/src/components/editor/actions/useNotebookActions.tsx +2 -1
- package/src/components/editor/ai/add-cell-with-ai.tsx +2 -0
- 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
|
@@ -305,11 +305,11 @@ class StagedCellReconciler {
|
|
|
305
305
|
private readonly actions: StagedCellReconcilerActions;
|
|
306
306
|
private marimoImportCellId: CellId | null = null;
|
|
307
307
|
|
|
308
|
-
constructor(actions: StagedCellReconcilerActions) {
|
|
308
|
+
public constructor(actions: StagedCellReconcilerActions) {
|
|
309
309
|
this.actions = actions;
|
|
310
310
|
}
|
|
311
311
|
|
|
312
|
-
reconcile(completionCells: GeneratedCell[]) {
|
|
312
|
+
public reconcile(completionCells: GeneratedCell[]) {
|
|
313
313
|
for (const [idx, cell] of completionCells.entries()) {
|
|
314
314
|
if (idx < this.createdCells.length) {
|
|
315
315
|
const existingCell = this.createdCells[idx];
|
|
@@ -336,7 +336,7 @@ class StagedCellReconciler {
|
|
|
336
336
|
this.syncMarimoImport(completionCells);
|
|
337
337
|
}
|
|
338
338
|
|
|
339
|
-
discard(stagedCells: StagedAICells) {
|
|
339
|
+
public discard(stagedCells: StagedAICells) {
|
|
340
340
|
for (const { cellId } of this.createdCells.toReversed()) {
|
|
341
341
|
if (stagedCells.has(cellId)) {
|
|
342
342
|
this.actions.deleteStagedCell(cellId);
|
|
@@ -350,17 +350,17 @@ class StagedCellReconciler {
|
|
|
350
350
|
this.marimoImportCellId = null;
|
|
351
351
|
}
|
|
352
352
|
|
|
353
|
-
accept() {
|
|
353
|
+
public accept() {
|
|
354
354
|
for (const cellId of this.stagedCellIds()) {
|
|
355
355
|
this.actions.removeStagedCell(cellId);
|
|
356
356
|
}
|
|
357
357
|
}
|
|
358
358
|
|
|
359
|
-
hasStagedCells(stagedCells: StagedAICells) {
|
|
359
|
+
public hasStagedCells(stagedCells: StagedAICells) {
|
|
360
360
|
return this.stagedCellIds().some((cellId) => stagedCells.has(cellId));
|
|
361
361
|
}
|
|
362
362
|
|
|
363
|
-
stagedCellIds() {
|
|
363
|
+
public stagedCellIds() {
|
|
364
364
|
const cellIds = this.createdCells.map(({ cellId }) => cellId);
|
|
365
365
|
if (this.marimoImportCellId) {
|
|
366
366
|
cellIds.push(this.marimoImportCellId);
|
|
@@ -26,12 +26,12 @@ export type StatusValue = "success" | "error" | "warning";
|
|
|
26
26
|
* );
|
|
27
27
|
*/
|
|
28
28
|
export class ToolExecutionError extends Error {
|
|
29
|
-
readonly code: string;
|
|
30
|
-
readonly isRetryable: boolean;
|
|
31
|
-
readonly suggestedFix?: string;
|
|
32
|
-
readonly meta?: Record<string, unknown>;
|
|
29
|
+
public readonly code: string;
|
|
30
|
+
public readonly isRetryable: boolean;
|
|
31
|
+
public readonly suggestedFix?: string;
|
|
32
|
+
public readonly meta?: Record<string, unknown>;
|
|
33
33
|
|
|
34
|
-
constructor(
|
|
34
|
+
public constructor(
|
|
35
35
|
message: string,
|
|
36
36
|
code = "TOOL_ERROR",
|
|
37
37
|
isRetryable = false,
|
|
@@ -46,7 +46,7 @@ export class ToolExecutionError extends Error {
|
|
|
46
46
|
this.meta = meta;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
toStructuredString(): string {
|
|
49
|
+
public toStructuredString(): string {
|
|
50
50
|
const stringError = JSON.stringify({
|
|
51
51
|
message: this.message,
|
|
52
52
|
code: this.code,
|
|
@@ -76,13 +76,13 @@ export class EditNotebookTool implements AiTool<
|
|
|
76
76
|
EditNotebookInput,
|
|
77
77
|
ToolOutputBase
|
|
78
78
|
> {
|
|
79
|
-
readonly name = "edit_notebook_tool";
|
|
80
|
-
readonly description = description;
|
|
81
|
-
readonly schema = editNotebookSchema;
|
|
82
|
-
readonly outputSchema = toolOutputBaseSchema;
|
|
83
|
-
readonly mode: CopilotMode[] = ["agent"];
|
|
79
|
+
public readonly name = "edit_notebook_tool";
|
|
80
|
+
public readonly description = description;
|
|
81
|
+
public readonly schema = editNotebookSchema;
|
|
82
|
+
public readonly outputSchema = toolOutputBaseSchema;
|
|
83
|
+
public readonly mode: CopilotMode[] = ["agent"];
|
|
84
84
|
|
|
85
|
-
handler = async (
|
|
85
|
+
public handler = async (
|
|
86
86
|
{ edit }: EditNotebookInput,
|
|
87
87
|
toolContext: ToolNotebookContext,
|
|
88
88
|
): Promise<ToolOutputBase> => {
|
|
@@ -36,11 +36,11 @@ export class FrontendToolRegistry {
|
|
|
36
36
|
/** All registered tools */
|
|
37
37
|
private tools = new Map<string, StoredTool>();
|
|
38
38
|
|
|
39
|
-
constructor(tools: StoredTool[] = []) {
|
|
39
|
+
public constructor(tools: StoredTool[] = []) {
|
|
40
40
|
this.tools = new Map(tools.map((tool) => [tool.name, tool]));
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
has(toolName: string) {
|
|
43
|
+
public has(toolName: string) {
|
|
44
44
|
return this.tools.has(toolName);
|
|
45
45
|
}
|
|
46
46
|
|
|
@@ -52,7 +52,7 @@ export class FrontendToolRegistry {
|
|
|
52
52
|
return tool;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
async invoke<TName extends string>({
|
|
55
|
+
public async invoke<TName extends string>({
|
|
56
56
|
toolName,
|
|
57
57
|
rawArgs,
|
|
58
58
|
toolContext,
|
|
@@ -127,7 +127,7 @@ export class FrontendToolRegistry {
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
@Memoize()
|
|
130
|
-
getToolSchemas(mode: CopilotMode): FrontendToolDefinition[] {
|
|
130
|
+
public getToolSchemas(mode: CopilotMode): FrontendToolDefinition[] {
|
|
131
131
|
const tools = [...this.tools.values()].filter((tool) =>
|
|
132
132
|
tool.mode.includes(mode),
|
|
133
133
|
);
|
|
@@ -54,10 +54,10 @@ export class RunStaleCellsTool implements AiTool<
|
|
|
54
54
|
EmptyToolInput,
|
|
55
55
|
RunStaleCellsOutput
|
|
56
56
|
> {
|
|
57
|
-
readonly name = "run_stale_cells_tool";
|
|
58
|
-
readonly description = description;
|
|
59
|
-
readonly schema = z.object({});
|
|
60
|
-
readonly outputSchema = toolOutputBaseSchema.extend({
|
|
57
|
+
public readonly name = "run_stale_cells_tool";
|
|
58
|
+
public readonly description = description;
|
|
59
|
+
public readonly schema = z.object({});
|
|
60
|
+
public readonly outputSchema = toolOutputBaseSchema.extend({
|
|
61
61
|
cellsToOutput: z
|
|
62
62
|
.record(
|
|
63
63
|
z.string(),
|
|
@@ -72,15 +72,15 @@ export class RunStaleCellsTool implements AiTool<
|
|
|
72
72
|
)
|
|
73
73
|
.optional(),
|
|
74
74
|
}) satisfies z.ZodType<RunStaleCellsOutput>;
|
|
75
|
-
readonly mode: CopilotMode[] = ["agent"];
|
|
75
|
+
public readonly mode: CopilotMode[] = ["agent"];
|
|
76
76
|
|
|
77
77
|
private readonly postExecutionDelay: number;
|
|
78
78
|
|
|
79
|
-
constructor(opts?: { postExecutionDelay?: number }) {
|
|
79
|
+
public constructor(opts?: { postExecutionDelay?: number }) {
|
|
80
80
|
this.postExecutionDelay = opts?.postExecutionDelay ?? POST_EXECUTION_DELAY;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
handler = async (
|
|
83
|
+
public handler = async (
|
|
84
84
|
_args: EmptyToolInput,
|
|
85
85
|
toolContext: ToolNotebookContext,
|
|
86
86
|
): Promise<RunStaleCellsOutput> => {
|
|
@@ -36,18 +36,18 @@ interface Output extends ToolOutputBase {
|
|
|
36
36
|
|
|
37
37
|
/** A sample frontend tool that demonstrates real tool output structure */
|
|
38
38
|
export class TestFrontendTool implements AiTool<Input, Output> {
|
|
39
|
-
readonly name = "test_frontend_tool";
|
|
40
|
-
readonly description = description;
|
|
41
|
-
readonly schema = z.object({ name: z.string() });
|
|
42
|
-
readonly outputSchema = toolOutputBaseSchema.extend({
|
|
39
|
+
public readonly name = "test_frontend_tool";
|
|
40
|
+
public readonly description = description;
|
|
41
|
+
public readonly schema = z.object({ name: z.string() });
|
|
42
|
+
public readonly outputSchema = toolOutputBaseSchema.extend({
|
|
43
43
|
data: z.object({
|
|
44
44
|
greeting: z.string(),
|
|
45
45
|
timestamp: z.string(),
|
|
46
46
|
}),
|
|
47
47
|
});
|
|
48
|
-
readonly mode: CopilotMode[] = ["ask"];
|
|
48
|
+
public readonly mode: CopilotMode[] = ["ask"];
|
|
49
49
|
|
|
50
|
-
async handler({ name }: Input): Promise<Output> {
|
|
50
|
+
public async handler({ name }: Input): Promise<Output> {
|
|
51
51
|
// Example: Validate input and throw ToolExecutionError on invalid data
|
|
52
52
|
if (!name.trim()) {
|
|
53
53
|
throw new ToolExecutionError(
|
|
@@ -48,9 +48,12 @@ function createLineDecoration(
|
|
|
48
48
|
|
|
49
49
|
class CurrentLineHighlighter implements PluginValue {
|
|
50
50
|
private unsubscribe: () => void;
|
|
51
|
-
decorations: DecorationSet;
|
|
51
|
+
public decorations: DecorationSet;
|
|
52
52
|
|
|
53
|
-
constructor(
|
|
53
|
+
public constructor(
|
|
54
|
+
view: EditorView,
|
|
55
|
+
lineObservable: Observable<number | null>,
|
|
56
|
+
) {
|
|
54
57
|
this.decorations = createLineDecoration(view.state, lineObservable.get());
|
|
55
58
|
this.unsubscribe = lineObservable.sub((line) => {
|
|
56
59
|
this.decorations = createLineDecoration(view.state, line);
|
|
@@ -59,11 +62,11 @@ class CurrentLineHighlighter implements PluginValue {
|
|
|
59
62
|
});
|
|
60
63
|
}
|
|
61
64
|
|
|
62
|
-
update(update: ViewUpdate) {
|
|
65
|
+
public update(update: ViewUpdate) {
|
|
63
66
|
this.decorations = this.decorations.map(update.changes);
|
|
64
67
|
}
|
|
65
68
|
|
|
66
|
-
destroy() {
|
|
69
|
+
public destroy() {
|
|
67
70
|
this.unsubscribe();
|
|
68
71
|
}
|
|
69
72
|
}
|
|
@@ -88,7 +91,7 @@ export function debuggerLineHighlighter(
|
|
|
88
91
|
// --- Breakpoint gutter ------------------------------------------------------
|
|
89
92
|
|
|
90
93
|
class BreakpointMarker extends GutterMarker {
|
|
91
|
-
override toDOM() {
|
|
94
|
+
public override toDOM() {
|
|
92
95
|
const dot = document.createElement("div");
|
|
93
96
|
dot.className = "cm-breakpoint-marker";
|
|
94
97
|
return dot;
|
|
@@ -130,7 +133,10 @@ function buildBreakpointMarkers(state: EditorState): RangeSet<GutterMarker> {
|
|
|
130
133
|
class BreakpointSync implements PluginValue {
|
|
131
134
|
private unsubscribe: () => void;
|
|
132
135
|
|
|
133
|
-
constructor(
|
|
136
|
+
public constructor(
|
|
137
|
+
view: EditorView,
|
|
138
|
+
observable: Observable<ReadonlySet<number>>,
|
|
139
|
+
) {
|
|
134
140
|
const apply = (lines: ReadonlySet<number>) => {
|
|
135
141
|
view.dispatch({ effects: setBreakpointLines.of(lines) });
|
|
136
142
|
};
|
|
@@ -144,7 +150,7 @@ class BreakpointSync implements PluginValue {
|
|
|
144
150
|
this.unsubscribe = observable.sub(apply);
|
|
145
151
|
}
|
|
146
152
|
|
|
147
|
-
destroy() {
|
|
153
|
+
public destroy() {
|
|
148
154
|
this.unsubscribe();
|
|
149
155
|
}
|
|
150
156
|
}
|
|
@@ -42,16 +42,16 @@ class LineTimerWidget extends WidgetType {
|
|
|
42
42
|
|
|
43
43
|
private readonly startedAtMs: number;
|
|
44
44
|
|
|
45
|
-
constructor(startedAtMs: number) {
|
|
45
|
+
public constructor(startedAtMs: number) {
|
|
46
46
|
super();
|
|
47
47
|
this.startedAtMs = startedAtMs;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
override eq(other: LineTimerWidget): boolean {
|
|
50
|
+
public override eq(other: LineTimerWidget): boolean {
|
|
51
51
|
return other.startedAtMs === this.startedAtMs;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
override toDOM(): HTMLElement {
|
|
54
|
+
public override toDOM(): HTMLElement {
|
|
55
55
|
const el = document.createElement("span");
|
|
56
56
|
el.className = "cm-line-timer";
|
|
57
57
|
el.setAttribute("aria-hidden", "true");
|
|
@@ -68,7 +68,7 @@ class LineTimerWidget extends WidgetType {
|
|
|
68
68
|
return el;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
override destroy(dom: HTMLElement): void {
|
|
71
|
+
public override destroy(dom: HTMLElement): void {
|
|
72
72
|
const interval = LineTimerWidget.intervals.get(dom);
|
|
73
73
|
if (interval !== undefined) {
|
|
74
74
|
window.clearInterval(interval);
|
|
@@ -76,7 +76,7 @@ class LineTimerWidget extends WidgetType {
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
override ignoreEvent(): boolean {
|
|
79
|
+
public override ignoreEvent(): boolean {
|
|
80
80
|
return true;
|
|
81
81
|
}
|
|
82
82
|
}
|
|
@@ -112,9 +112,9 @@ function createTimingDecorations(
|
|
|
112
112
|
|
|
113
113
|
class ActiveLineTimer implements PluginValue {
|
|
114
114
|
private unsubscribe: () => void;
|
|
115
|
-
decorations: DecorationSet;
|
|
115
|
+
public decorations: DecorationSet;
|
|
116
116
|
|
|
117
|
-
constructor(
|
|
117
|
+
public constructor(
|
|
118
118
|
view: EditorView,
|
|
119
119
|
infoObservable: Observable<ActiveLineInfo | null>,
|
|
120
120
|
) {
|
|
@@ -129,11 +129,11 @@ class ActiveLineTimer implements PluginValue {
|
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
update(update: ViewUpdate) {
|
|
132
|
+
public update(update: ViewUpdate) {
|
|
133
133
|
this.decorations = this.decorations.map(update.changes);
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
destroy() {
|
|
136
|
+
public destroy() {
|
|
137
137
|
this.unsubscribe();
|
|
138
138
|
}
|
|
139
139
|
}
|
|
@@ -91,9 +91,12 @@ function unfoldErrorLines(view: EditorView, errors: TracebackInfos) {
|
|
|
91
91
|
*/
|
|
92
92
|
class ErrorHighlighter implements PluginValue {
|
|
93
93
|
private unsubscribe: () => void;
|
|
94
|
-
decorations: DecorationSet;
|
|
94
|
+
public decorations: DecorationSet;
|
|
95
95
|
|
|
96
|
-
constructor(
|
|
96
|
+
public constructor(
|
|
97
|
+
view: EditorView,
|
|
98
|
+
errorsObservable: Observable<TracebackInfos>,
|
|
99
|
+
) {
|
|
97
100
|
const errors = errorsObservable.get();
|
|
98
101
|
this.decorations = createErrorDecorations(view.state, errors);
|
|
99
102
|
unfoldErrorLines(view, errors);
|
|
@@ -113,11 +116,11 @@ class ErrorHighlighter implements PluginValue {
|
|
|
113
116
|
});
|
|
114
117
|
}
|
|
115
118
|
|
|
116
|
-
update(update: ViewUpdate) {
|
|
119
|
+
public update(update: ViewUpdate) {
|
|
117
120
|
this.decorations = this.decorations.map(update.changes);
|
|
118
121
|
}
|
|
119
122
|
|
|
120
|
-
destroy() {
|
|
123
|
+
public destroy() {
|
|
121
124
|
this.unsubscribe();
|
|
122
125
|
}
|
|
123
126
|
}
|
|
@@ -56,12 +56,12 @@ class LensHoverController {
|
|
|
56
56
|
private showTimer: number | undefined;
|
|
57
57
|
private hideTimer: number | undefined;
|
|
58
58
|
|
|
59
|
-
constructor(view: EditorView) {
|
|
59
|
+
public constructor(view: EditorView) {
|
|
60
60
|
this.view = view;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
/** Pointer entered a lens icon */
|
|
64
|
-
enterLens(spec: CodeLensSpec, icon: HTMLElement): void {
|
|
64
|
+
public enterLens(spec: CodeLensSpec, icon: HTMLElement): void {
|
|
65
65
|
this.clearTimers();
|
|
66
66
|
dismissEditorHoverTooltips(this.view, icon);
|
|
67
67
|
const hovered = this.view.state.field(codeLensHoverField, false);
|
|
@@ -76,7 +76,7 @@ class LensHoverController {
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
/** Pointer left a lens icon or the popover */
|
|
79
|
-
leave(): void {
|
|
79
|
+
public leave(): void {
|
|
80
80
|
this.clearTimers();
|
|
81
81
|
this.hideTimer = window.setTimeout(() => {
|
|
82
82
|
this.hideTimer = undefined;
|
|
@@ -85,19 +85,19 @@ class LensHoverController {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
/** Pointer entered the popover */
|
|
88
|
-
enterPopover(): void {
|
|
88
|
+
public enterPopover(): void {
|
|
89
89
|
window.clearTimeout(this.hideTimer);
|
|
90
90
|
this.hideTimer = undefined;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
hide(): void {
|
|
93
|
+
public hide(): void {
|
|
94
94
|
this.clearTimers();
|
|
95
95
|
if (this.view.state.field(codeLensHoverField, false)) {
|
|
96
96
|
this.view.dispatch({ effects: setHoveredLens.of(null) });
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
destroy(): void {
|
|
100
|
+
public destroy(): void {
|
|
101
101
|
this.clearTimers();
|
|
102
102
|
}
|
|
103
103
|
|
|
@@ -135,18 +135,18 @@ function dismissEditorHoverTooltips(
|
|
|
135
135
|
class CodeLensWidget extends WidgetType {
|
|
136
136
|
private readonly spec: CodeLensSpec;
|
|
137
137
|
|
|
138
|
-
constructor(spec: CodeLensSpec) {
|
|
138
|
+
public constructor(spec: CodeLensSpec) {
|
|
139
139
|
super();
|
|
140
140
|
this.spec = spec;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
override eq(other: CodeLensWidget): boolean {
|
|
143
|
+
public override eq(other: CodeLensWidget): boolean {
|
|
144
144
|
// `pos` is captured by the DOM hover/click handlers, so a reused widget
|
|
145
145
|
// whose anchor moved must not be treated as equal
|
|
146
146
|
return specEquals(this.spec, other.spec);
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
override toDOM(view: EditorView): HTMLElement {
|
|
149
|
+
public override toDOM(view: EditorView): HTMLElement {
|
|
150
150
|
const { spec } = this;
|
|
151
151
|
const element = document.createElement("span");
|
|
152
152
|
element.className = "mo-code-lens";
|
|
@@ -188,7 +188,7 @@ class CodeLensWidget extends WidgetType {
|
|
|
188
188
|
return element;
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
-
override ignoreEvent(): boolean {
|
|
191
|
+
public override ignoreEvent(): boolean {
|
|
192
192
|
// The widget handles its own events
|
|
193
193
|
return true;
|
|
194
194
|
}
|
|
@@ -281,7 +281,7 @@ class CodeLensPlugin {
|
|
|
281
281
|
private readonly debounceMs = 300;
|
|
282
282
|
private readonly scheduleUpdate: DebouncedFunc<() => void>;
|
|
283
283
|
|
|
284
|
-
constructor(view: EditorView, cellId: CellId, includeCache: boolean) {
|
|
284
|
+
public constructor(view: EditorView, cellId: CellId, includeCache: boolean) {
|
|
285
285
|
this.view = view;
|
|
286
286
|
this.cellId = cellId;
|
|
287
287
|
this.includeCache = includeCache;
|
|
@@ -297,7 +297,7 @@ class CodeLensPlugin {
|
|
|
297
297
|
this.scheduleUpdate();
|
|
298
298
|
}
|
|
299
299
|
|
|
300
|
-
update(update: ViewUpdate) {
|
|
300
|
+
public update(update: ViewUpdate) {
|
|
301
301
|
// Recompute on edits, and when the cell's language changes (e.g. Python ->
|
|
302
302
|
// SQL) so stale Python-only icons are cleared even if the text is unchanged
|
|
303
303
|
const adapterChanged =
|
|
@@ -308,7 +308,7 @@ class CodeLensPlugin {
|
|
|
308
308
|
}
|
|
309
309
|
}
|
|
310
310
|
|
|
311
|
-
destroy() {
|
|
311
|
+
public destroy() {
|
|
312
312
|
this.scheduleUpdate.cancel();
|
|
313
313
|
for (const unsubscribe of this.unsubscribes) {
|
|
314
314
|
unsubscribe();
|
|
@@ -22,11 +22,11 @@ vi.mock("../state", async (importOriginal) => {
|
|
|
22
22
|
|
|
23
23
|
class MockTransport implements Transport {
|
|
24
24
|
private readonly handlers = new Set<(message: JSONRPCMessage) => void>();
|
|
25
|
-
readonly sent: JSONRPCMessage[] = [];
|
|
25
|
+
public readonly sent: JSONRPCMessage[] = [];
|
|
26
26
|
|
|
27
|
-
connect = vi.fn().mockResolvedValue(undefined);
|
|
28
|
-
close = vi.fn();
|
|
29
|
-
send = vi.fn((message: JSONRPCMessage) => {
|
|
27
|
+
public connect = vi.fn().mockResolvedValue(undefined);
|
|
28
|
+
public close = vi.fn();
|
|
29
|
+
public send = vi.fn((message: JSONRPCMessage) => {
|
|
30
30
|
this.sent.push(message);
|
|
31
31
|
if (isRequest(message) && message.method === "initialize") {
|
|
32
32
|
queueMicrotask(() => {
|
|
@@ -39,14 +39,14 @@ class MockTransport implements Transport {
|
|
|
39
39
|
}
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
-
onMessage(handler: (message: JSONRPCMessage) => void): () => void {
|
|
42
|
+
public onMessage(handler: (message: JSONRPCMessage) => void): () => void {
|
|
43
43
|
this.handlers.add(handler);
|
|
44
44
|
return () => {
|
|
45
45
|
this.handlers.delete(handler);
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
emit(message: JSONRPCMessage) {
|
|
49
|
+
public emit(message: JSONRPCMessage) {
|
|
50
50
|
for (const handler of this.handlers) {
|
|
51
51
|
handler(message);
|
|
52
52
|
}
|
|
@@ -8,24 +8,24 @@ vi.mock("@/utils/Logger", () => ({
|
|
|
8
8
|
}));
|
|
9
9
|
|
|
10
10
|
class FakeWebSocket {
|
|
11
|
-
static readonly OPEN = 1;
|
|
12
|
-
static readonly CLOSED = 3;
|
|
13
|
-
static readonly instances: FakeWebSocket[] = [];
|
|
11
|
+
public static readonly OPEN = 1;
|
|
12
|
+
public static readonly CLOSED = 3;
|
|
13
|
+
public static readonly instances: FakeWebSocket[] = [];
|
|
14
14
|
|
|
15
|
-
readonly sent: string[] = [];
|
|
16
|
-
readyState = 0;
|
|
17
|
-
readonly url: string;
|
|
15
|
+
public readonly sent: string[] = [];
|
|
16
|
+
public readyState = 0;
|
|
17
|
+
public readonly url: string;
|
|
18
18
|
private readonly listeners = new Map<
|
|
19
19
|
string,
|
|
20
20
|
Set<(event: Record<string, never>) => void>
|
|
21
21
|
>();
|
|
22
22
|
|
|
23
|
-
constructor(url: string) {
|
|
23
|
+
public constructor(url: string) {
|
|
24
24
|
this.url = url;
|
|
25
25
|
FakeWebSocket.instances.push(this);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
addEventListener(
|
|
28
|
+
public addEventListener(
|
|
29
29
|
type: string,
|
|
30
30
|
listener: (event: Record<string, never>) => void,
|
|
31
31
|
) {
|
|
@@ -34,21 +34,21 @@ class FakeWebSocket {
|
|
|
34
34
|
this.listeners.set(type, listeners);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
send(frame: string) {
|
|
37
|
+
public send(frame: string) {
|
|
38
38
|
this.sent.push(frame);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
close() {
|
|
41
|
+
public close() {
|
|
42
42
|
this.readyState = FakeWebSocket.CLOSED;
|
|
43
43
|
this.emit("close");
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
open() {
|
|
46
|
+
public open() {
|
|
47
47
|
this.readyState = FakeWebSocket.OPEN;
|
|
48
48
|
this.emit("open");
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
fail() {
|
|
51
|
+
public fail() {
|
|
52
52
|
this.emit("error");
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -117,7 +117,7 @@ export class CopilotLanguageServerClient extends LanguageServerClient {
|
|
|
117
117
|
private lastOpenedDocument: DidOpenTextDocumentParams | undefined;
|
|
118
118
|
private copilotSettings: Record<string, unknown> = {};
|
|
119
119
|
|
|
120
|
-
constructor(
|
|
120
|
+
public constructor(
|
|
121
121
|
options: ConstructorParameters<typeof LanguageServerClient>[0] & {
|
|
122
122
|
copilotSettings?: Record<string, unknown>;
|
|
123
123
|
},
|
|
@@ -140,7 +140,7 @@ export class CopilotLanguageServerClient extends LanguageServerClient {
|
|
|
140
140
|
* Re-run the LSP initialize handshake and send configuration.
|
|
141
141
|
* Called by the transport's onReconnect callback after reconnecting.
|
|
142
142
|
*/
|
|
143
|
-
async reInitialize(): Promise<void> {
|
|
143
|
+
public async reInitialize(): Promise<void> {
|
|
144
144
|
logger.log("#reInitialize: Re-initializing LSP connection");
|
|
145
145
|
this.initializePromise = this.initialize();
|
|
146
146
|
await this.initializePromise;
|
|
@@ -186,7 +186,7 @@ export class CopilotLanguageServerClient extends LanguageServerClient {
|
|
|
186
186
|
return this.notify(method, params);
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
-
override getInitializationOptions() {
|
|
189
|
+
public override getInitializationOptions() {
|
|
190
190
|
const info = {
|
|
191
191
|
name: "marimo",
|
|
192
192
|
version: "0.1.0",
|
|
@@ -208,7 +208,7 @@ export class CopilotLanguageServerClient extends LanguageServerClient {
|
|
|
208
208
|
return !isCopilotEnabled();
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
-
override async textDocumentDidOpen(
|
|
211
|
+
public override async textDocumentDidOpen(
|
|
212
212
|
params: DidOpenTextDocumentParams,
|
|
213
213
|
): Promise<boolean> {
|
|
214
214
|
if (this.isDisabled()) {
|
|
@@ -223,7 +223,7 @@ export class CopilotLanguageServerClient extends LanguageServerClient {
|
|
|
223
223
|
return super.textDocumentDidOpen(params);
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
-
override async textDocumentDidClose(
|
|
226
|
+
public override async textDocumentDidClose(
|
|
227
227
|
params: DidCloseTextDocumentParams,
|
|
228
228
|
): Promise<void> {
|
|
229
229
|
if (this.openDocumentCount === 0) {
|
|
@@ -233,14 +233,14 @@ export class CopilotLanguageServerClient extends LanguageServerClient {
|
|
|
233
233
|
return super.textDocumentDidClose(params);
|
|
234
234
|
}
|
|
235
235
|
|
|
236
|
-
override async textDocumentCompletion(
|
|
236
|
+
public override async textDocumentCompletion(
|
|
237
237
|
params: CompletionParams,
|
|
238
238
|
): Promise<CompletionList | CompletionItem[]> {
|
|
239
239
|
// Not used in Copilot
|
|
240
240
|
return [];
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
-
override async textDocumentDidChange(
|
|
243
|
+
public override async textDocumentDidChange(
|
|
244
244
|
params: DidChangeTextDocumentParams,
|
|
245
245
|
): Promise<void> {
|
|
246
246
|
if (this.isDisabled()) {
|
|
@@ -304,17 +304,17 @@ export class CopilotLanguageServerClient extends LanguageServerClient {
|
|
|
304
304
|
});
|
|
305
305
|
}
|
|
306
306
|
|
|
307
|
-
override textDocumentHover(params: HoverParams): Promise<Hover> {
|
|
307
|
+
public override textDocumentHover(params: HoverParams): Promise<Hover> {
|
|
308
308
|
// Not used in Copilot
|
|
309
309
|
return Promise.resolve({ contents: [] });
|
|
310
310
|
}
|
|
311
311
|
|
|
312
312
|
// AUTH
|
|
313
|
-
signOut() {
|
|
313
|
+
public signOut() {
|
|
314
314
|
return this._request("signOut", {});
|
|
315
315
|
}
|
|
316
316
|
|
|
317
|
-
async signInInitiate() {
|
|
317
|
+
public async signInInitiate() {
|
|
318
318
|
logger.log("#signInInitiate: Starting sign-in flow");
|
|
319
319
|
try {
|
|
320
320
|
const result = await this._request("signIn", {});
|
|
@@ -326,7 +326,7 @@ export class CopilotLanguageServerClient extends LanguageServerClient {
|
|
|
326
326
|
}
|
|
327
327
|
}
|
|
328
328
|
|
|
329
|
-
async signInConfirm(params: GitHubCopilotSignInConfirmParams) {
|
|
329
|
+
public async signInConfirm(params: GitHubCopilotSignInConfirmParams) {
|
|
330
330
|
logger.log("#signInConfirm: Confirming sign-in");
|
|
331
331
|
try {
|
|
332
332
|
const result = await this._request("signInConfirm", params);
|
|
@@ -338,7 +338,7 @@ export class CopilotLanguageServerClient extends LanguageServerClient {
|
|
|
338
338
|
}
|
|
339
339
|
}
|
|
340
340
|
|
|
341
|
-
async signedIn() {
|
|
341
|
+
public async signedIn() {
|
|
342
342
|
try {
|
|
343
343
|
const { status } = await this._request("checkStatus", {});
|
|
344
344
|
logger.log("#checkStatus: Status check completed", { status });
|
|
@@ -375,7 +375,7 @@ export class CopilotLanguageServerClient extends LanguageServerClient {
|
|
|
375
375
|
200,
|
|
376
376
|
);
|
|
377
377
|
|
|
378
|
-
async getCompletion(
|
|
378
|
+
public async getCompletion(
|
|
379
379
|
params: InlineCompletionParams,
|
|
380
380
|
): Promise<InlineCompletionList | InlineCompletionItem[] | null> {
|
|
381
381
|
if (this.isDisabled()) {
|
|
@@ -38,7 +38,7 @@ export interface LazyWebsocketTransportOptions {
|
|
|
38
38
|
* Copilot-specific readiness checks, retries, and user-facing errors.
|
|
39
39
|
*/
|
|
40
40
|
export class LazyWebsocketTransport extends ReconnectingWebSocketTransport {
|
|
41
|
-
constructor(options: LazyWebsocketTransportOptions) {
|
|
41
|
+
public constructor(options: LazyWebsocketTransportOptions) {
|
|
42
42
|
super({
|
|
43
43
|
getWsUrl: options.getWsUrl,
|
|
44
44
|
waitForConnection: options.waitForReady,
|
|
@@ -90,15 +90,15 @@ const HighlightMargin = 250;
|
|
|
90
90
|
|
|
91
91
|
export const searchHighlighter = ViewPlugin.fromClass(
|
|
92
92
|
class {
|
|
93
|
-
decorations: DecorationSet;
|
|
94
|
-
readonly view: EditorView;
|
|
93
|
+
public decorations: DecorationSet;
|
|
94
|
+
public readonly view: EditorView;
|
|
95
95
|
|
|
96
|
-
constructor(view: EditorView) {
|
|
96
|
+
public constructor(view: EditorView) {
|
|
97
97
|
this.view = view;
|
|
98
98
|
this.decorations = this.highlight(view.state.field(searchState));
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
update(update: ViewUpdate) {
|
|
101
|
+
public update(update: ViewUpdate) {
|
|
102
102
|
const state = update.state.field(searchState);
|
|
103
103
|
if (
|
|
104
104
|
state !== update.startState.field(searchState) ||
|
|
@@ -110,7 +110,7 @@ export const searchHighlighter = ViewPlugin.fromClass(
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
highlight(query: QueryType) {
|
|
113
|
+
public highlight(query: QueryType) {
|
|
114
114
|
if (!query.spec.valid) {
|
|
115
115
|
return Decoration.none;
|
|
116
116
|
}
|