@marimo-team/frontend 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/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
|
@@ -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
|
}
|
|
@@ -57,7 +57,7 @@ class MetaUnderlineVariablePlugin {
|
|
|
57
57
|
private hoveredRange: { from: number; to: number; position: number } | null;
|
|
58
58
|
private onClick: (view: EditorView) => void;
|
|
59
59
|
|
|
60
|
-
constructor(view: EditorView, onClick: (view: EditorView) => void) {
|
|
60
|
+
public constructor(view: EditorView, onClick: (view: EditorView) => void) {
|
|
61
61
|
this.view = view;
|
|
62
62
|
this.commandClickMode = false;
|
|
63
63
|
this.hoveredRange = null;
|
|
@@ -69,13 +69,13 @@ class MetaUnderlineVariablePlugin {
|
|
|
69
69
|
window.addEventListener("mouseleave", this.windowBlur);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
update(_update: ViewUpdate) {
|
|
72
|
+
public update(_update: ViewUpdate) {
|
|
73
73
|
// We cannot add any transactions here (e.g. clearing underlines),
|
|
74
74
|
// otherwise CM fails with
|
|
75
75
|
// "Calls to EditorView.update are not allowed while an update is in progress"
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
destroy() {
|
|
78
|
+
public destroy() {
|
|
79
79
|
window.removeEventListener("keydown", this.keydown);
|
|
80
80
|
window.removeEventListener("keyup", this.keyup);
|
|
81
81
|
window.removeEventListener("blur", this.windowBlur);
|
|
@@ -346,7 +346,7 @@ class CodeMirrorVimSync {
|
|
|
346
346
|
// noop
|
|
347
347
|
}
|
|
348
348
|
|
|
349
|
-
addInstance(instance: EditorView) {
|
|
349
|
+
public addInstance(instance: EditorView) {
|
|
350
350
|
this.instances.add(instance);
|
|
351
351
|
|
|
352
352
|
const cm = getCM(instance);
|
|
@@ -376,11 +376,11 @@ class CodeMirrorVimSync {
|
|
|
376
376
|
});
|
|
377
377
|
}
|
|
378
378
|
|
|
379
|
-
removeInstance(instance: EditorView) {
|
|
379
|
+
public removeInstance(instance: EditorView) {
|
|
380
380
|
this.instances.delete(instance);
|
|
381
381
|
}
|
|
382
382
|
|
|
383
|
-
broadcastModeChange(
|
|
383
|
+
public broadcastModeChange(
|
|
384
384
|
originInstance: EditorView,
|
|
385
385
|
mode: string,
|
|
386
386
|
subMode?: string,
|
|
@@ -41,23 +41,23 @@ export const MARKDOWN_INITIAL_HIDE_CODE = true;
|
|
|
41
41
|
export class MarkdownLanguageAdapter implements LanguageAdapter<MarkdownLanguageAdapterMetadata> {
|
|
42
42
|
private parser = new MarkdownParser();
|
|
43
43
|
|
|
44
|
-
readonly type = "markdown";
|
|
45
|
-
readonly defaultCode = this.parser.defaultCode;
|
|
46
|
-
readonly defaultMetadata: MarkdownLanguageAdapterMetadata =
|
|
44
|
+
public readonly type = "markdown";
|
|
45
|
+
public readonly defaultCode = this.parser.defaultCode;
|
|
46
|
+
public readonly defaultMetadata: MarkdownLanguageAdapterMetadata =
|
|
47
47
|
this.parser.defaultMetadata;
|
|
48
48
|
|
|
49
|
-
static fromMarkdown(markdown: string) {
|
|
49
|
+
public static fromMarkdown(markdown: string) {
|
|
50
50
|
return MarkdownParser.fromMarkdown(markdown);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
transformIn(
|
|
53
|
+
public transformIn(
|
|
54
54
|
pythonCode: string,
|
|
55
55
|
): [string, number, MarkdownLanguageAdapterMetadata] {
|
|
56
56
|
const result = this.parser.transformIn(pythonCode);
|
|
57
57
|
return [result.code, result.offset, result.metadata];
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
transformOut(
|
|
60
|
+
public transformOut(
|
|
61
61
|
code: string,
|
|
62
62
|
metadata: MarkdownLanguageAdapterMetadata,
|
|
63
63
|
): [string, number] {
|
|
@@ -65,11 +65,11 @@ export class MarkdownLanguageAdapter implements LanguageAdapter<MarkdownLanguage
|
|
|
65
65
|
return [result.code, result.offset];
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
isSupported(pythonCode: string): boolean {
|
|
68
|
+
public isSupported(pythonCode: string): boolean {
|
|
69
69
|
return this.parser.isSupported(pythonCode);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
getExtension(
|
|
72
|
+
public getExtension(
|
|
73
73
|
_cellId: CellId,
|
|
74
74
|
_completionConfig: CompletionConfig,
|
|
75
75
|
hotkeys: HotkeyProvider,
|
|
@@ -261,25 +261,25 @@ const pyrightClient = once((_: LSPConfig) => {
|
|
|
261
261
|
export class PythonLanguageAdapter implements LanguageAdapter<{}> {
|
|
262
262
|
private parser = new PythonParser();
|
|
263
263
|
|
|
264
|
-
readonly type = "python";
|
|
265
|
-
readonly defaultCode = this.parser.defaultCode;
|
|
266
|
-
readonly defaultMetadata = this.parser.defaultMetadata;
|
|
264
|
+
public readonly type = "python";
|
|
265
|
+
public readonly defaultCode = this.parser.defaultCode;
|
|
266
|
+
public readonly defaultMetadata = this.parser.defaultMetadata;
|
|
267
267
|
|
|
268
|
-
transformIn(code: string): [string, number, {}] {
|
|
268
|
+
public transformIn(code: string): [string, number, {}] {
|
|
269
269
|
const result = this.parser.transformIn(code);
|
|
270
270
|
return [result.code, result.offset, result.metadata];
|
|
271
271
|
}
|
|
272
272
|
|
|
273
|
-
transformOut(code: string, metadata: {}): [string, number] {
|
|
273
|
+
public transformOut(code: string, metadata: {}): [string, number] {
|
|
274
274
|
const result = this.parser.transformOut(code, metadata);
|
|
275
275
|
return [result.code, result.offset];
|
|
276
276
|
}
|
|
277
277
|
|
|
278
|
-
isSupported(code: string): boolean {
|
|
278
|
+
public isSupported(code: string): boolean {
|
|
279
279
|
return this.parser.isSupported(code);
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
-
getExtension(
|
|
282
|
+
public getExtension(
|
|
283
283
|
cellId: CellId,
|
|
284
284
|
completionConfig: CompletionConfig,
|
|
285
285
|
hotkeys: HotkeyProvider,
|
|
@@ -25,7 +25,7 @@ export class CompletionBuilder {
|
|
|
25
25
|
/**
|
|
26
26
|
* Add a table with its columns at the specified path
|
|
27
27
|
*/
|
|
28
|
-
addTable(path: string[], table: DataTable): this {
|
|
28
|
+
public addTable(path: string[], table: DataTable): this {
|
|
29
29
|
const tableNamespace: SQLNamespace = {
|
|
30
30
|
self: tableToCompletion({
|
|
31
31
|
table: table,
|
|
@@ -44,7 +44,7 @@ export class CompletionBuilder {
|
|
|
44
44
|
/**
|
|
45
45
|
* Add a schema at the specified path
|
|
46
46
|
*/
|
|
47
|
-
addSchema(path: string[], schema: DatabaseSchema): this {
|
|
47
|
+
public addSchema(path: string[], schema: DatabaseSchema): this {
|
|
48
48
|
const schemaObject: SQLNamespace = {
|
|
49
49
|
self: schemaToCompletion({
|
|
50
50
|
namespace: schema,
|
|
@@ -60,7 +60,7 @@ export class CompletionBuilder {
|
|
|
60
60
|
/**
|
|
61
61
|
* Add a database at the specified path
|
|
62
62
|
*/
|
|
63
|
-
addDatabase(path: string[], database: Database): this {
|
|
63
|
+
public addDatabase(path: string[], database: Database): this {
|
|
64
64
|
const databaseObject: SQLNamespace = {
|
|
65
65
|
self: databaseToCompletion({
|
|
66
66
|
namespace: database,
|
|
@@ -90,14 +90,14 @@ export class CompletionBuilder {
|
|
|
90
90
|
/**
|
|
91
91
|
* Build the final schema
|
|
92
92
|
*/
|
|
93
|
-
build(): SQLNamespace {
|
|
93
|
+
public build(): SQLNamespace {
|
|
94
94
|
return this.schema;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
/**
|
|
98
98
|
* Reset for reuse
|
|
99
99
|
*/
|
|
100
|
-
reset(): this {
|
|
100
|
+
public reset(): this {
|
|
101
101
|
this.schema = {};
|
|
102
102
|
return this;
|
|
103
103
|
}
|
|
@@ -28,7 +28,7 @@ const datasetTableCompletionsAtom = atom((get) => {
|
|
|
28
28
|
class SQLCompletionStore {
|
|
29
29
|
private cache: LRUCache<DataSourceConnection, CachedSchema>;
|
|
30
30
|
|
|
31
|
-
constructor() {
|
|
31
|
+
public constructor() {
|
|
32
32
|
this.cache = new LRUCache(10, {
|
|
33
33
|
create: (connection) => this.getConnectionSchema(connection),
|
|
34
34
|
});
|
|
@@ -121,7 +121,7 @@ class SQLCompletionStore {
|
|
|
121
121
|
* Returns the raw dialect of the connection passed from the backend,
|
|
122
122
|
* or null if the connection is not found
|
|
123
123
|
*/
|
|
124
|
-
getInternalDialect(connectionName: ConnectionName): string | null {
|
|
124
|
+
public getInternalDialect(connectionName: ConnectionName): string | null {
|
|
125
125
|
const connection = this.getConnection(connectionName);
|
|
126
126
|
if (!connection) {
|
|
127
127
|
return null;
|
|
@@ -133,7 +133,7 @@ class SQLCompletionStore {
|
|
|
133
133
|
* Get the inferred SQL dialect for a connection
|
|
134
134
|
* If the connection is not found, return the standard SQL dialect.
|
|
135
135
|
*/
|
|
136
|
-
getDialect(connectionName: ConnectionName): SQLDialect {
|
|
136
|
+
public getDialect(connectionName: ConnectionName): SQLDialect {
|
|
137
137
|
const connection = this.getConnection(connectionName);
|
|
138
138
|
if (!connection) {
|
|
139
139
|
return ModifiedStandardSQL;
|
|
@@ -141,7 +141,7 @@ class SQLCompletionStore {
|
|
|
141
141
|
return guessDialect(connection);
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
getCompletionSource(connectionName: ConnectionName): SQLConfig | null {
|
|
144
|
+
public getCompletionSource(connectionName: ConnectionName): SQLConfig | null {
|
|
145
145
|
const connection = this.getConnection(connectionName);
|
|
146
146
|
if (!connection) {
|
|
147
147
|
return null;
|
|
@@ -99,21 +99,21 @@ function getLatestEngine(): ConnectionName {
|
|
|
99
99
|
*/
|
|
100
100
|
export class SQLLanguageAdapter implements LanguageAdapter<SQLLanguageAdapterMetadata> {
|
|
101
101
|
private parser = new SQLParser();
|
|
102
|
-
readonly type = "sql";
|
|
103
|
-
sqlModeEnabled: boolean;
|
|
102
|
+
public readonly type = "sql";
|
|
103
|
+
public sqlModeEnabled: boolean;
|
|
104
104
|
|
|
105
|
-
constructor() {
|
|
105
|
+
public constructor() {
|
|
106
106
|
this.sqlModeEnabled = true;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
get defaultMetadata(): SQLLanguageAdapterMetadata {
|
|
109
|
+
public get defaultMetadata(): SQLLanguageAdapterMetadata {
|
|
110
110
|
return {
|
|
111
111
|
...this.parser.defaultMetadata,
|
|
112
112
|
engine: getLatestEngine() || DUCKDB_ENGINE,
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
get defaultCode(): string {
|
|
116
|
+
public get defaultCode(): string {
|
|
117
117
|
const engine = getLatestEngine();
|
|
118
118
|
if (engine && engine !== DUCKDB_ENGINE) {
|
|
119
119
|
return `_df = mo.sql(f"""SELECT * FROM """, engine=${engine})`;
|
|
@@ -121,9 +121,9 @@ export class SQLLanguageAdapter implements LanguageAdapter<SQLLanguageAdapterMet
|
|
|
121
121
|
return this.parser.defaultCode;
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
static fromQuery = (query: string) => SQLParser.fromQuery(query);
|
|
124
|
+
public static fromQuery = (query: string) => SQLParser.fromQuery(query);
|
|
125
125
|
|
|
126
|
-
transformIn(
|
|
126
|
+
public transformIn(
|
|
127
127
|
pythonCode: string,
|
|
128
128
|
): [
|
|
129
129
|
sqlQuery: string,
|
|
@@ -143,7 +143,7 @@ export class SQLLanguageAdapter implements LanguageAdapter<SQLLanguageAdapterMet
|
|
|
143
143
|
return [result.code, result.offset, metadata];
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
transformOut(
|
|
146
|
+
public transformOut(
|
|
147
147
|
code: string,
|
|
148
148
|
metadata: SQLLanguageAdapterMetadata,
|
|
149
149
|
): [string, number] {
|
|
@@ -151,11 +151,11 @@ export class SQLLanguageAdapter implements LanguageAdapter<SQLLanguageAdapterMet
|
|
|
151
151
|
return [result.code, result.offset];
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
isSupported(pythonCode: string): boolean {
|
|
154
|
+
public isSupported(pythonCode: string): boolean {
|
|
155
155
|
return this.parser.isSupported(pythonCode);
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
getExtension(
|
|
158
|
+
public getExtension(
|
|
159
159
|
_cellId: CellId,
|
|
160
160
|
_completionConfig: CompletionConfig,
|
|
161
161
|
_hotkeys: HotkeyProvider,
|
|
@@ -309,19 +309,19 @@ class DialectAwareQueryContextAnalyzer extends QueryContextAnalyzer {
|
|
|
309
309
|
private readonly analyzers = new Map<ParserDialects, QueryContextAnalyzer>();
|
|
310
310
|
private readonly analysisParser: NodeSqlParser;
|
|
311
311
|
|
|
312
|
-
constructor(analysisParser: NodeSqlParser) {
|
|
312
|
+
public constructor(analysisParser: NodeSqlParser) {
|
|
313
313
|
super(analysisParser);
|
|
314
314
|
this.analysisParser = analysisParser;
|
|
315
315
|
}
|
|
316
316
|
|
|
317
|
-
override getContext(
|
|
317
|
+
public override getContext(
|
|
318
318
|
sql: string,
|
|
319
319
|
opts: { state: EditorState },
|
|
320
320
|
): ReturnType<QueryContextAnalyzer["getContext"]> {
|
|
321
321
|
return this.getAnalyzer(opts.state).getContext(sql, opts);
|
|
322
322
|
}
|
|
323
323
|
|
|
324
|
-
override clearCache(): void {
|
|
324
|
+
public override clearCache(): void {
|
|
325
325
|
for (const analyzer of this.analyzers.values()) {
|
|
326
326
|
analyzer.clearCache();
|
|
327
327
|
}
|
|
@@ -342,25 +342,25 @@ class DialectAwareSqlStructureAnalyzer extends SqlStructureAnalyzer {
|
|
|
342
342
|
private readonly analyzers = new Map<ParserDialects, SqlStructureAnalyzer>();
|
|
343
343
|
private readonly analysisParser: NodeSqlParser;
|
|
344
344
|
|
|
345
|
-
constructor(analysisParser: NodeSqlParser) {
|
|
345
|
+
public constructor(analysisParser: NodeSqlParser) {
|
|
346
346
|
super(analysisParser);
|
|
347
347
|
this.analysisParser = analysisParser;
|
|
348
348
|
}
|
|
349
349
|
|
|
350
|
-
override analyzeDocument(
|
|
350
|
+
public override analyzeDocument(
|
|
351
351
|
state: EditorState,
|
|
352
352
|
): ReturnType<SqlStructureAnalyzer["analyzeDocument"]> {
|
|
353
353
|
return this.getAnalyzer(state).analyzeDocument(state);
|
|
354
354
|
}
|
|
355
355
|
|
|
356
|
-
override getStatementAtPosition(
|
|
356
|
+
public override getStatementAtPosition(
|
|
357
357
|
state: EditorState,
|
|
358
358
|
position: number,
|
|
359
359
|
): ReturnType<SqlStructureAnalyzer["getStatementAtPosition"]> {
|
|
360
360
|
return this.getAnalyzer(state).getStatementAtPosition(state, position);
|
|
361
361
|
}
|
|
362
362
|
|
|
363
|
-
override getStatementsInRange(
|
|
363
|
+
public override getStatementsInRange(
|
|
364
364
|
state: EditorState,
|
|
365
365
|
from: number,
|
|
366
366
|
to: number,
|
|
@@ -368,7 +368,7 @@ class DialectAwareSqlStructureAnalyzer extends SqlStructureAnalyzer {
|
|
|
368
368
|
return this.getAnalyzer(state).getStatementsInRange(state, from, to);
|
|
369
369
|
}
|
|
370
370
|
|
|
371
|
-
override clearCache(): void {
|
|
371
|
+
public override clearCache(): void {
|
|
372
372
|
for (const analyzer of this.analyzers.values()) {
|
|
373
373
|
analyzer.clearCache();
|
|
374
374
|
}
|
|
@@ -392,7 +392,7 @@ class CustomSqlParser extends NodeSqlParser {
|
|
|
392
392
|
private readonly VALIDATION_DELAY_MS = 300; // Wait 300ms after user stops typing
|
|
393
393
|
private isFocused = false; // Only validate if the editor is focused
|
|
394
394
|
|
|
395
|
-
setFocusState(focused: boolean) {
|
|
395
|
+
public setFocusState(focused: boolean) {
|
|
396
396
|
this.isFocused = focused;
|
|
397
397
|
}
|
|
398
398
|
|
|
@@ -446,7 +446,7 @@ class CustomSqlParser extends NodeSqlParser {
|
|
|
446
446
|
});
|
|
447
447
|
}
|
|
448
448
|
|
|
449
|
-
override async validateSql(
|
|
449
|
+
public override async validateSql(
|
|
450
450
|
sql: string,
|
|
451
451
|
opts: { state: EditorState },
|
|
452
452
|
): Promise<SqlParseError[]> {
|
|
@@ -470,7 +470,7 @@ class CustomSqlParser extends NodeSqlParser {
|
|
|
470
470
|
);
|
|
471
471
|
}
|
|
472
472
|
|
|
473
|
-
override async parse(
|
|
473
|
+
public override async parse(
|
|
474
474
|
sql: string,
|
|
475
475
|
opts: { state: EditorState },
|
|
476
476
|
): Promise<NodeSqlParserResult> {
|
|
@@ -17,38 +17,38 @@ vi.mock("../../../runtime/config", () => ({
|
|
|
17
17
|
|
|
18
18
|
/** Minimal stand-in for the browser WebSocket used by `WebSocketTransport`. */
|
|
19
19
|
class FakeWebSocket {
|
|
20
|
-
static readonly instances: FakeWebSocket[] = [];
|
|
21
|
-
static readonly OPEN = 1;
|
|
20
|
+
public static readonly instances: FakeWebSocket[] = [];
|
|
21
|
+
public static readonly OPEN = 1;
|
|
22
22
|
|
|
23
|
-
readyState = 0;
|
|
24
|
-
readonly url: string;
|
|
23
|
+
public readyState = 0;
|
|
24
|
+
public readonly url: string;
|
|
25
25
|
private readonly listeners = new Map<string, Set<(event: unknown) => void>>();
|
|
26
26
|
|
|
27
|
-
constructor(url: string) {
|
|
27
|
+
public constructor(url: string) {
|
|
28
28
|
this.url = url;
|
|
29
29
|
FakeWebSocket.instances.push(this);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
addEventListener(type: string, listener: (event: unknown) => void) {
|
|
32
|
+
public addEventListener(type: string, listener: (event: unknown) => void) {
|
|
33
33
|
const listeners = this.listeners.get(type) ?? new Set();
|
|
34
34
|
listeners.add(listener);
|
|
35
35
|
this.listeners.set(type, listeners);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
send() {
|
|
38
|
+
public send() {
|
|
39
39
|
// no-op
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
close() {
|
|
42
|
+
public close() {
|
|
43
43
|
this.readyState = 3;
|
|
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
|
-
receive(message: unknown) {
|
|
51
|
+
public receive(message: unknown) {
|
|
52
52
|
this.emit("message", { data: JSON.stringify(message) });
|
|
53
53
|
}
|
|
54
54
|
|