@marimo-team/islands 0.22.5-dev18 → 0.22.5-dev21

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marimo-team/islands",
3
- "version": "0.22.5-dev18",
3
+ "version": "0.22.5-dev21",
4
4
  "main": "dist/main.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -25,6 +25,7 @@ import type { NotebookDocumentTransactionRequest } from "../network/types";
25
25
  import { store } from "../state/jotai";
26
26
  import type { CellActions, NotebookState } from "./cells";
27
27
  import type { CellId } from "./ids";
28
+ import { SCRATCH_CELL_ID } from "./ids";
28
29
  import type { CellData } from "./types";
29
30
 
30
31
  export type DocumentChange =
@@ -572,10 +573,21 @@ const flushChanges = debounce(() => {
572
573
  void getRequestClient().sendDocumentTransaction({ changes });
573
574
  }, 400);
574
575
 
576
+ function isScratchChange(change: DocumentChange): boolean {
577
+ if ("cellId" in change && change.cellId === SCRATCH_CELL_ID) {
578
+ return true;
579
+ }
580
+ return false;
581
+ }
582
+
575
583
  function enqueue(change: DocumentChange) {
576
584
  if (store.get(kioskModeAtom)) {
577
585
  return;
578
586
  }
587
+ // The scratchpad cell is local-only — don't sync it to the document.
588
+ if (isScratchChange(change)) {
589
+ return;
590
+ }
579
591
  pendingChanges.push(change);
580
592
  flushChanges();
581
593
  }
@@ -16,6 +16,22 @@ export const filenameAtom = atom<string | null>(getFilenameFromDOM());
16
16
  */
17
17
  export const cwdAtom = atom<string | null>(null);
18
18
 
19
+ /**
20
+ * LSP workspace information from the backend.
21
+ * Contains the project root and the document's file URI.
22
+ */
23
+ export interface LspWorkspace {
24
+ rootUri: string;
25
+ documentUri: string;
26
+ }
27
+
28
+ /**
29
+ * Atom for storing the LSP workspace information.
30
+ * This is populated during active notebook sessions
31
+ * and null for other pages.
32
+ */
33
+ export const lspWorkspaceAtom = atom<LspWorkspace | null>(null);
34
+
19
35
  /**
20
36
  * Set for static notebooks.
21
37
  */
package/src/mount.tsx CHANGED
@@ -36,7 +36,12 @@ import {
36
36
  DEFAULT_RUNTIME_CONFIG,
37
37
  runtimeConfigAtom,
38
38
  } from "./core/runtime/config";
39
- import { codeAtom, cwdAtom, filenameAtom } from "./core/saving/file-state";
39
+ import {
40
+ codeAtom,
41
+ cwdAtom,
42
+ filenameAtom,
43
+ lspWorkspaceAtom,
44
+ } from "./core/saving/file-state";
40
45
  import { store } from "./core/state/jotai";
41
46
  import { patchFetch, patchVegaLoader } from "./core/static/files";
42
47
  import {
@@ -150,6 +155,16 @@ const mountOptionsSchema = z.object({
150
155
  * absolute working directory of the notebook
151
156
  */
152
157
  cwd: z.string().nullish().default(null),
158
+ /**
159
+ * LSP workspace information
160
+ */
161
+ lspWorkspace: z
162
+ .object({
163
+ rootUri: z.string(),
164
+ documentUri: z.string(),
165
+ })
166
+ .nullish()
167
+ .default(null),
153
168
  /**
154
169
  * notebook code
155
170
  */
@@ -287,6 +302,7 @@ function initStore(options: unknown) {
287
302
  // Files
288
303
  store.set(filenameAtom, parsedOptions.data.filename);
289
304
  store.set(cwdAtom, parsedOptions.data.cwd ?? null);
305
+ store.set(lspWorkspaceAtom, parsedOptions.data.lspWorkspace);
290
306
  store.set(codeAtom, parsedOptions.data.code);
291
307
  store.set(initialModeAtom, mode);
292
308