@marimo-team/islands 0.21.2-dev56 → 0.21.2-dev58

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.
Files changed (45) hide show
  1. package/dist/{ConnectedDataExplorerComponent-D0GoOd_c.js → ConnectedDataExplorerComponent-DrWDbHRV.js} +1 -1
  2. package/dist/main.js +243 -16
  3. package/dist/{spec-Bfvf9Hre.js → spec-oVDndBz4.js} +25 -16
  4. package/package.json +1 -1
  5. package/src/__mocks__/requests.ts +1 -0
  6. package/src/core/cells/__tests__/apply-transaction.test.ts +279 -0
  7. package/src/core/cells/__tests__/cells.test.ts +6 -0
  8. package/src/core/cells/__tests__/document-changes.test.ts +575 -0
  9. package/src/core/cells/__tests__/document-roundtrip.test.ts +376 -0
  10. package/src/core/cells/cells.ts +28 -3
  11. package/src/core/cells/document-changes.ts +644 -0
  12. package/src/core/islands/bridge.ts +1 -0
  13. package/src/core/islands/main.ts +2 -0
  14. package/src/core/network/requests-lazy.ts +1 -0
  15. package/src/core/network/requests-network.ts +9 -0
  16. package/src/core/network/requests-static.ts +1 -0
  17. package/src/core/network/requests-toasting.tsx +1 -0
  18. package/src/core/network/types.ts +5 -0
  19. package/src/core/wasm/bridge.ts +1 -0
  20. package/src/core/websocket/useMarimoKernelConnection.tsx +19 -1
  21. package/src/css/app/fonts.css +6 -6
  22. package/src/fonts/Fira_Mono/FiraMono-Bold.woff2 +0 -0
  23. package/src/fonts/Fira_Mono/FiraMono-Medium.woff2 +0 -0
  24. package/src/fonts/Fira_Mono/FiraMono-Regular.woff2 +0 -0
  25. package/src/fonts/Lora/Lora-VariableFont_wght.woff2 +0 -0
  26. package/src/fonts/PT_Sans/PTSans-Bold.woff2 +0 -0
  27. package/src/fonts/PT_Sans/PTSans-Regular.woff2 +0 -0
  28. package/src/utils/createReducer.ts +26 -11
  29. package/src/fonts/Fira_Mono/FiraMono-Bold.ttf +0 -0
  30. package/src/fonts/Fira_Mono/FiraMono-Medium.ttf +0 -0
  31. package/src/fonts/Fira_Mono/FiraMono-Regular.ttf +0 -0
  32. package/src/fonts/Lora/Lora-Italic-VariableFont_wght.ttf +0 -0
  33. package/src/fonts/Lora/Lora-VariableFont_wght.ttf +0 -0
  34. package/src/fonts/Lora/static/Lora-Bold.ttf +0 -0
  35. package/src/fonts/Lora/static/Lora-BoldItalic.ttf +0 -0
  36. package/src/fonts/Lora/static/Lora-Italic.ttf +0 -0
  37. package/src/fonts/Lora/static/Lora-Medium.ttf +0 -0
  38. package/src/fonts/Lora/static/Lora-MediumItalic.ttf +0 -0
  39. package/src/fonts/Lora/static/Lora-Regular.ttf +0 -0
  40. package/src/fonts/Lora/static/Lora-SemiBold.ttf +0 -0
  41. package/src/fonts/Lora/static/Lora-SemiBoldItalic.ttf +0 -0
  42. package/src/fonts/PT_Sans/PTSans-Bold.ttf +0 -0
  43. package/src/fonts/PT_Sans/PTSans-BoldItalic.ttf +0 -0
  44. package/src/fonts/PT_Sans/PTSans-Italic.ttf +0 -0
  45. package/src/fonts/PT_Sans/PTSans-Regular.ttf +0 -0
@@ -2,7 +2,7 @@ import { a as __toCommonJS, n as __esmMin, r as __export, s as __toESM, t as __c
2
2
  import { t as require_react } from "./react-Bs6Z0kvn.js";
3
3
  import { t as require_compiler_runtime } from "./compiler-runtime-B_OLMU9S.js";
4
4
  import { l as createLucideIcon } from "./dist-C0Rnbr-_.js";
5
- import { A as useOnMount, F as $896ba0a80a8f4d36$export$85fd5fdf27bacc79, H as ListFilter, K as Calendar, M as Badge, N as createReducerAndAtoms, P as startCase_default, R as Type, U as Hash, V as SquareFunction, t as augmentSpecWithData, z as ToggleLeft } from "./spec-Bfvf9Hre.js";
5
+ import { A as useOnMount, F as $896ba0a80a8f4d36$export$85fd5fdf27bacc79, H as ListFilter, K as Calendar, M as Badge, N as createReducerAndAtoms, P as startCase_default, R as Type, U as Hash, V as SquareFunction, t as augmentSpecWithData, z as ToggleLeft } from "./spec-oVDndBz4.js";
6
6
  import { A as $a916eb452884faea$export$b7a616150fdb9f44, a as SelectGroup, c as SelectSeparator, i as SelectContent, l as SelectTrigger, o as SelectItem, r as Select, s as SelectLabel, t as Label, u as SelectValue } from "./label-BbpGrh4j.js";
7
7
  import { d as Objects, g as Logger, t as Button, y as cn } from "./button-BKkuUpZh.js";
8
8
  import "./Combination-BBPQRrDo.js";
package/dist/main.js CHANGED
@@ -23,7 +23,7 @@ import { t as require_compiler_runtime } from "./compiler-runtime-B_OLMU9S.js";
23
23
  import { n as Copy, r as toast, t as copyToClipboard } from "./copy-BjkXCUxP.js";
24
24
  import { _ as require_cjs$1, c as markdownLineEnding, d as SKIP, f as visitParents, g as s$2, h as h$1, l as longestStreak, m as webNamespaces, o as xn$1, p as convert$1, s as factorySpace, u as ok, __tla as __tla_0 } from "./chunk-5FQGJX7Z-BkzUmppO.js";
25
25
  import { a as Content$3, c as useSize, i as Arrow, l as createLucideIcon, o as Root2$6, r as Anchor, s as createPopperScope, t as Root$5 } from "./dist-C0Rnbr-_.js";
26
- import { A as useOnMount, B as Table$1, C as DEFAULT_COLOR_SCHEME, D as SCALE_TYPE_DESCRIPTIONS, E as EMPTY_VALUE$1, F as $896ba0a80a8f4d36$export$85fd5fdf27bacc79, G as ChartColumn, H as ListFilter, I as $fb18d541ea1ad717$export$ad991b66133851cf, K as Calendar, L as $5a387cc49350e6db$export$722debc0e56fea39, M as Badge, N as createReducerAndAtoms, O as TIME_UNIT_DESCRIPTIONS, P as startCase_default, R as Type, S as DEFAULT_AGGREGATION, T as DEFAULT_TIME_UNIT, U as Hash, V as SquareFunction, W as ChartPie, _ as AGGREGATION_TYPE_DESCRIPTIONS, a as AGGREGATION_FNS$1, b as COLOR_SCHEMES, c as COLOR_BY_FIELDS, d as NONE_VALUE, f as SELECTABLE_DATA_TYPES, g as TIME_UNITS, h as STRING_AGGREGATION_FNS, i as convertDataTypeToSelectable, j as useOnUnmount, k as escapeFieldName, l as COMBINED_TIME_UNITS, m as SORT_TYPES, n as createSpecWithoutData, o as BIN_AGGREGATION, p as SINGLE_TIME_UNITS, r as isFieldSet, s as CHART_TYPES, t as augmentSpecWithData, u as ChartType, v as AGGREGATION_TYPE_ICON, w as DEFAULT_MAX_BINS_FACET, x as COUNT_FIELD, y as CHART_TYPE_ICON, z as ToggleLeft } from "./spec-Bfvf9Hre.js";
26
+ import { A as useOnMount, B as Table$1, C as DEFAULT_COLOR_SCHEME, D as SCALE_TYPE_DESCRIPTIONS, E as EMPTY_VALUE$1, F as $896ba0a80a8f4d36$export$85fd5fdf27bacc79, G as ChartColumn, H as ListFilter, I as $fb18d541ea1ad717$export$ad991b66133851cf, K as Calendar, L as $5a387cc49350e6db$export$722debc0e56fea39, M as Badge, N as createReducerAndAtoms, O as TIME_UNIT_DESCRIPTIONS, P as startCase_default, R as Type, S as DEFAULT_AGGREGATION, T as DEFAULT_TIME_UNIT, U as Hash, V as SquareFunction, W as ChartPie, _ as AGGREGATION_TYPE_DESCRIPTIONS, a as AGGREGATION_FNS$1, b as COLOR_SCHEMES, c as COLOR_BY_FIELDS, d as NONE_VALUE, f as SELECTABLE_DATA_TYPES, g as TIME_UNITS, h as STRING_AGGREGATION_FNS, i as convertDataTypeToSelectable, j as useOnUnmount, k as escapeFieldName, l as COMBINED_TIME_UNITS, m as SORT_TYPES, n as createSpecWithoutData, o as BIN_AGGREGATION, p as SINGLE_TIME_UNITS, r as isFieldSet, s as CHART_TYPES, t as augmentSpecWithData, u as ChartType, v as AGGREGATION_TYPE_ICON, w as DEFAULT_MAX_BINS_FACET, x as COUNT_FIELD, y as CHART_TYPE_ICON, z as ToggleLeft } from "./spec-oVDndBz4.js";
27
27
  import { t as Check } from "./check-Diwc5emq.js";
28
28
  import { A as $a916eb452884faea$export$b7a616150fdb9f44, C as useDirection, D as assertNever, E as usePrevious$1, I as X, M as $18f2051aff69b9bf$export$43bb16f9c6d9e3f7, N as $18f2051aff69b9bf$export$a54013f0d02a8f82, O as logNever, P as $b5e257d569688ac6$export$535bd6ca7f90a273, R as ChevronDown, S as Trigger$5, T as clamp$2, _ as menuItemVariants, a as SelectGroup, b as menuSubTriggerVariants, c as SelectSeparator, d as NativeSelect, f as selectStyles, g as menuControlVariants, h as menuControlCheckVariants, i as SelectContent, j as $488c6ddbf4ef74c2$export$cc77c4ff7e8673c5, l as SelectTrigger, m as menuContentCommon, n as Primitive$1, o as SelectItem, p as MENU_ITEM_DISABLED, r as Select, s as SelectLabel, t as Label, u as SelectValue, v as menuLabelVariants, w as createCollection, x as Icon, y as menuSeparatorVariants } from "./label-BbpGrh4j.js";
29
29
  import { $ as $d2b4bc8c273e7be6$export$24d547caef80ccd1, $t as $c87311424ea30a05$export$a11b0059900ceec8, A as Portal$2, At as $fca6afa0e843324b$export$87b761675e8eaa10, B as Root$6, Bt as $ae1eeba8b9eafd08$export$5165eccb35aaadb5, C as Arrow2, Ct as $e5be200c675c3b3a$export$aca958c65c314e6c, D as Item2$2, Dt as $f7dceffc5ad7768b$export$4e328f61c538687f, E as Group$1, Et as $319e236875307eab$export$a9b970dcc4ae71a9, F as Sub, Ft as $9ab94262bd0047c7$export$420e68273165f4ec, G as $3985021b0ad6602f$export$f5b8910cec6cf069, Gt as $99facab73266f662$export$5add1d006293d136, H as ErrorBoundary, Ht as $458b0a5536c1a7cf$export$40bfa8c7b0832715, I as SubContent, It as $3ad3f6e1647bc98d$export$80f3e147d781571c, J as $d3e0e05bdfcf66bd$export$c24727297075ec6a, Jt as $df56164dff5785e2$export$4338b53315abf666, K as $a049562f99e7db0e$export$eb2fcfdbd7ba97d4, Kt as $e9faafb641e167db$export$90fc3a17d93f704c, L as SubTrigger, Lt as $507fabe10e71c6fb$export$630ff653c5ada6a9, M as RadioItem, Mt as $6db58dc88e78b024$export$2f817fcdc4b89ae0, N as Root3, Nt as $5b160d28a433310d$export$c17fa47878dc55b6, O as ItemIndicator, Ot as $701a24aa0da5b062$export$ea18c227d4417cc3, P as Separator, Pt as $6179b936705e76d3$export$ae780daf29e6d456, Q as $514c0188e459b4c0$export$9afb8bc826b033ea, Qt as $c87311424ea30a05$export$9ac100e40613ea10, R as createMenuScope, Rt as $f6c31cce2adf654f$export$45712eceda6fad21, S as Anchor2, St as $e5be200c675c3b3a$export$a763b9476acd3eb, T as Content2$3, Tt as $e5be200c675c3b3a$export$fc1a364ae1f3ff10, U as require_prop_types, Ut as $b4b717babfbb907b$export$4c063cf1350e6fed, V as createRovingFocusGroupScope, Vt as $9446cca9a3875146$export$7d15b64cf5a3a4c4, W as $3985021b0ad6602f$export$37fb8590cf2c088c, Wt as $b4b717babfbb907b$export$bebd5a1431fec25d, X as $ee014567cb39d3f0$export$ff05c3ac10437e03, Xt as $c87311424ea30a05$export$6446a186d09e379e, Y as $ee014567cb39d3f0$export$f551688fc98f2e09, Yt as $313b98861ee5dd6c$export$d6875122194c7b44, Z as $514c0188e459b4c0$export$5f1af8db9871e1d6, Zt as $c87311424ea30a05$export$78551043582a6a98, _ as DropdownMenuSeparator, _n as Plus, _t as capitalize_default, a as OnBlurredInput, an as $d4ee10de306f2510$export$b4f377a2b6254582, at as $64fa3d84918910a7$export$29f1550f4b0d4415, b as DropdownMenuSubTrigger, bn as ChevronRight, bt as $e93e671b31057976$export$b8473d3665f3a75a, c as prettyEngineeringNumber, cn as $f4e2df6bd15f8569$export$98658e8c59125e6a, ct as $64fa3d84918910a7$export$c245e6201fed2f75, d as DropdownMenu, dn as $ff5963eb1fccf552$export$e08e3b67e392101e, dt as $64fa3d84918910a7$export$ef03459518577ad4, en as $c87311424ea30a05$export$fedb369cb70207f1, et as $d2b4bc8c273e7be6$export$353f5b6fc5456de1, f as DropdownMenuContent, fn as $bdb11010cef70236$export$b4cc09c592e8fdb8, ft as $64fa3d84918910a7$export$fabf2dc03a41866e, g as DropdownMenuPortal, gn as Search, gt as useDebouncedCallback, h as DropdownMenuLabel, hn as Trash, ht as useDebounceControlledState, i as Input, in as $d4ee10de306f2510$export$4282f70798064fe0, it as $64fa3d84918910a7$export$2881499e37b75b9a, j as RadioGroup$2, jt as $fca6afa0e843324b$export$f12b703ca79dfbb1, k as Label$2, kt as $6c7bd7858deea686$export$cd11ab140839f11d, l as prettyNumber, ln as $431fbd86ca7dc216$export$b204af158042fbac, lt as $64fa3d84918910a7$export$c62b8e45d58ddad9, m as DropdownMenuItem, mn as $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c, mt as marked, n as DebouncedInput, nn as $65484d02dcb7eb3e$export$457c3d6518dd4c6f, nt as $01b77f81d0f07f68$export$b04be29aa201d4f5, o as NumberField, on as $d4ee10de306f2510$export$cd4e5573fbe2b576, ot as $64fa3d84918910a7$export$4d86445c2cf5e3, p as DropdownMenuGroup, pn as $bdb11010cef70236$export$f680877a34711e37, pt as useNonce, q as $a049562f99e7db0e$export$f9c6924e160136d1, qt as $8ae05eaa5c114e9c$export$7f54fc3180508a52, r as DebouncedNumberInput, rn as $3ef42575df84b30b$export$9d1611c77c2fe928, rt as $f39a9eba43920ace$export$b5d7cc18bb8d2b59, s as maxFractionalDigits, sn as $d4ee10de306f2510$export$e58f029f0fbfdb29, st as $64fa3d84918910a7$export$9d4c57ee4c6ffdd8, t as BulkEdit, tn as $7215afc6de606d6b$export$de79e2c695e052f3, tt as $01b77f81d0f07f68$export$75b6ee27786ba447, u as prettyScientificNumber, un as $431fbd86ca7dc216$export$f21a1ffae260145a, ut as $64fa3d84918910a7$export$df3a06d6289f983e, v as DropdownMenuSub, vn as Pencil, vt as $d2e8511e6f209edf$export$e908e06f4b8e3402, w as CheckboxItem, wt as $e5be200c675c3b3a$export$dad6ae84456c676a, x as DropdownMenuTrigger, xt as $e5be200c675c3b3a$export$75ee7c75d68f5b0e, y as DropdownMenuSubContent, yn as Circle, yt as $2baaea4c71418dea$export$294aa081a6c6f55d, z as Item$2, zt as _class_private_field_init } from "./types-CGc7peZV.js";
@@ -32731,6 +32731,228 @@ ${c.sqlString}
32731
32731
  let y = outputIsLoading(c), S = c === "running" && d !== null && f !== null && (d.timestamp ?? 0) > f;
32732
32732
  return y && !S ? true : v;
32733
32733
  }
32734
+ function getInitialAppMode() {
32735
+ let e = store.get(initialModeAtom);
32736
+ return assertExists(e, "internal-error: initial mode not found"), invariant(e !== "present", "internal-error: initial mode cannot be 'present'"), e;
32737
+ }
32738
+ const viewStateAtom = atom({
32739
+ mode: isIslands() ? "read" : "not-set",
32740
+ cellAnchor: null
32741
+ }), initialModeAtom = atom(void 0), kioskModeAtom = atom(false);
32742
+ function getCell(e, r) {
32743
+ if (!e) {
32744
+ Logger.warn("getCell: cellId is undefined");
32745
+ return;
32746
+ }
32747
+ let c = r.cellData[e];
32748
+ if (!c) {
32749
+ Logger.warn(`getCell: cell ${e} not found in state`);
32750
+ return;
32751
+ }
32752
+ return c;
32753
+ }
32754
+ function anchorOf(e, r) {
32755
+ let c = r.cellIds.inOrderIds, d = c.indexOf(e);
32756
+ if (d > 0) return {
32757
+ after: c[d - 1]
32758
+ };
32759
+ if (d === 0 && c.length > 1) return {
32760
+ before: c[1]
32761
+ };
32762
+ }
32763
+ function columnIndexMap(e) {
32764
+ let r = /* @__PURE__ */ new Map(), c = e.cellIds.getColumns();
32765
+ for (let [e2, d] of c.entries()) for (let c2 of d.inOrderIds) r.set(c2, e2);
32766
+ return r;
32767
+ }
32768
+ function newCellChanges(e, r) {
32769
+ let c = new Set(e.cellIds.inOrderIds), d = [];
32770
+ for (let e2 of r.cellIds.inOrderIds) if (!c.has(e2)) {
32771
+ let c2 = getCell(e2, r);
32772
+ c2 && d.push({
32773
+ type: "create-cell",
32774
+ cellId: c2.id,
32775
+ code: c2.code,
32776
+ name: c2.name,
32777
+ config: c2.config,
32778
+ ...anchorOf(c2.id, r)
32779
+ });
32780
+ }
32781
+ return d;
32782
+ }
32783
+ function deletedCellChanges(e, r) {
32784
+ let c = new Set(r.cellIds.inOrderIds), d = [];
32785
+ for (let r2 of e.cellIds.inOrderIds) c.has(r2) || d.push({
32786
+ type: "delete-cell",
32787
+ cellId: r2
32788
+ });
32789
+ return d;
32790
+ }
32791
+ function columnChanges(e, r) {
32792
+ let c = columnIndexMap(e), d = columnIndexMap(r), f = [];
32793
+ for (let [e2, r2] of d) c.get(e2) !== r2 && f.push({
32794
+ type: "set-config",
32795
+ cellId: e2,
32796
+ column: r2
32797
+ });
32798
+ return f.push({
32799
+ type: "reorder-cells",
32800
+ cellIds: r.cellIds.inOrderIds
32801
+ }), f;
32802
+ }
32803
+ function toDocumentChanges(e, r, c) {
32804
+ switch (c.type) {
32805
+ case "createNewCell":
32806
+ return newCellChanges(e, r);
32807
+ case "deleteCell":
32808
+ return [
32809
+ {
32810
+ type: "delete-cell",
32811
+ cellId: c.payload.cellId
32812
+ }
32813
+ ];
32814
+ case "moveCell":
32815
+ case "sendToTop":
32816
+ case "sendToBottom": {
32817
+ let { cellId: e2 } = c.payload;
32818
+ return [
32819
+ {
32820
+ type: "move-cell",
32821
+ cellId: e2,
32822
+ ...anchorOf(e2, r)
32823
+ }
32824
+ ];
32825
+ }
32826
+ case "dropCellOverCell":
32827
+ case "dropCellOverColumn":
32828
+ return columnChanges(e, r);
32829
+ case "updateCellCode": {
32830
+ let e2 = getCell(c.payload.cellId, r);
32831
+ return e2 ? [
32832
+ {
32833
+ type: "set-code",
32834
+ cellId: e2.id,
32835
+ code: e2.code
32836
+ }
32837
+ ] : [];
32838
+ }
32839
+ case "updateCellName": {
32840
+ let e2 = getCell(c.payload.cellId, r);
32841
+ return e2 ? [
32842
+ {
32843
+ type: "set-name",
32844
+ cellId: e2.id,
32845
+ name: e2.name
32846
+ }
32847
+ ] : [];
32848
+ }
32849
+ case "updateCellConfig": {
32850
+ let { cellId: e2, config: r2 } = c.payload;
32851
+ return [
32852
+ {
32853
+ type: "set-config",
32854
+ cellId: e2,
32855
+ ...r2.hide_code != null && {
32856
+ hideCode: r2.hide_code
32857
+ },
32858
+ ...r2.disabled != null && {
32859
+ disabled: r2.disabled
32860
+ },
32861
+ ...r2.column != null && {
32862
+ column: r2.column
32863
+ }
32864
+ }
32865
+ ];
32866
+ }
32867
+ case "dropOverNewColumn":
32868
+ case "moveColumn":
32869
+ case "addColumnBreakpoint":
32870
+ case "deleteColumn":
32871
+ case "mergeAllColumns":
32872
+ case "compactColumns":
32873
+ return columnChanges(e, r);
32874
+ case "addColumn":
32875
+ return [
32876
+ ...newCellChanges(e, r),
32877
+ ...columnChanges(e, r)
32878
+ ];
32879
+ case "undoDeleteCell": {
32880
+ let c2 = newCellChanges(e, r), d = columnChanges(e, r);
32881
+ return d.length > 1 ? [
32882
+ ...c2,
32883
+ ...d
32884
+ ] : c2;
32885
+ }
32886
+ case "splitCell": {
32887
+ let { cellId: d } = c.payload, f = getCell(d, r);
32888
+ return f ? [
32889
+ {
32890
+ type: "set-code",
32891
+ cellId: d,
32892
+ code: f.code
32893
+ },
32894
+ ...newCellChanges(e, r)
32895
+ ] : [];
32896
+ }
32897
+ case "undoSplitCell": {
32898
+ let { cellId: d } = c.payload, f = getCell(d, r);
32899
+ return f ? [
32900
+ {
32901
+ type: "set-code",
32902
+ cellId: d,
32903
+ code: f.code
32904
+ },
32905
+ ...deletedCellChanges(e, r)
32906
+ ] : [];
32907
+ }
32908
+ case "moveToNextCell":
32909
+ return newCellChanges(e, r);
32910
+ case "addSetupCellIfDoesntExist":
32911
+ return newCellChanges(e, r);
32912
+ case "focusCell":
32913
+ case "focusTopCell":
32914
+ case "focusBottomCell":
32915
+ case "scrollToTarget":
32916
+ case "showCellIfHidden":
32917
+ case "markTouched":
32918
+ case "markUntouched":
32919
+ return [];
32920
+ case "prepareForRun":
32921
+ case "handleCellMessage":
32922
+ case "setCellIds":
32923
+ case "setCellCodes":
32924
+ case "setCells":
32925
+ case "setStdinResponse":
32926
+ case "clearSerializedEditorState":
32927
+ case "clearCellOutput":
32928
+ case "clearCellConsoleOutput":
32929
+ case "clearAllCellOutputs":
32930
+ case "clearLogs":
32931
+ return [];
32932
+ case "foldAll":
32933
+ case "unfoldAll":
32934
+ case "collapseCell":
32935
+ case "expandCell":
32936
+ case "collapseAllCells":
32937
+ case "expandAllCells":
32938
+ return [];
32939
+ default:
32940
+ assertNever(c);
32941
+ }
32942
+ }
32943
+ var pendingChanges = [], flushChanges = debounce_default(() => {
32944
+ if (pendingChanges.length === 0) return;
32945
+ let e = pendingChanges;
32946
+ pendingChanges = [], getRequestClient().sendDocumentTransaction({
32947
+ changes: e
32948
+ });
32949
+ }, 400);
32950
+ function enqueue(e) {
32951
+ store.get(kioskModeAtom) || (pendingChanges.push(e), flushChanges());
32952
+ }
32953
+ function documentTransactionMiddleware(e, r, c) {
32954
+ for (let d of toDocumentChanges(e, r, c)) enqueue(d);
32955
+ }
32734
32956
  function addDays(e, r, c) {
32735
32957
  let d = toDate(e, c == null ? void 0 : c.in);
32736
32958
  return isNaN(r) ? constructFrom((c == null ? void 0 : c.in) || e, NaN) : (r && d.setDate(d.getDate() + r), d);
@@ -36262,7 +36484,7 @@ ${c.sqlString}
36262
36484
  ...e
36263
36485
  };
36264
36486
  }
36265
- require_compiler_runtime();
36487
+ var import_compiler_runtime$153 = require_compiler_runtime();
36266
36488
  function withScratchCell(e) {
36267
36489
  let r = {
36268
36490
  column: 0,
@@ -36300,7 +36522,7 @@ ${c.sqlString}
36300
36522
  untouchedNewCells: /* @__PURE__ */ new Set()
36301
36523
  });
36302
36524
  }
36303
- var { reducer, createActions, useActions: useActions$1, valueAtom: notebookAtom } = createReducerAndAtoms(initialNotebookState, {
36525
+ var { reducer, addMiddleware, createActions, useActions: useActions$1, valueAtom: notebookAtom } = createReducerAndAtoms(initialNotebookState, {
36304
36526
  createNewCell: (e, r) => {
36305
36527
  var _a3;
36306
36528
  let { cellId: c, before: d, code: f, lastCodeRun: _ = null, lastExecutionTime: v = null, autoFocus: y = true, skipIfCodeExists: S = false, hideCode: w = false } = r, E, O;
@@ -36642,7 +36864,15 @@ ${c.sqlString}
36642
36864
  cellId: c,
36643
36865
  cellReducer: (e2) => transitionCell(e2, r)
36644
36866
  });
36645
- return {
36867
+ return r.status === "queued" && (d = updateCellData({
36868
+ state: d,
36869
+ cellId: c,
36870
+ cellReducer: (e2) => ({
36871
+ ...e2,
36872
+ lastCodeRun: e2.code.trim(),
36873
+ edited: false
36874
+ })
36875
+ })), {
36646
36876
  ...d,
36647
36877
  cellLogs: [
36648
36878
  ...d.cellLogs,
@@ -37079,6 +37309,7 @@ ${c.sqlString}
37079
37309
  };
37080
37310
  }
37081
37311
  });
37312
+ addMiddleware(documentTransactionMiddleware);
37082
37313
  function isCellCodeHidden(e, r) {
37083
37314
  return !!e.cellData[r].config.hide_code && !e.untouchedNewCells.has(r);
37084
37315
  }
@@ -37159,8 +37390,9 @@ ${c.sqlString}
37159
37390
  let { cellHandles: r } = store.get(notebookAtom);
37160
37391
  return (_a3 = r[e].current) == null ? void 0 : _a3.editorView;
37161
37392
  };
37162
- function useCellActions() {
37163
- return useActions$1();
37393
+ function useCellActions(e) {
37394
+ let r = (0, import_compiler_runtime$153.c)(2), c;
37395
+ return r[0] === e ? c = r[1] : (c = e === void 0 ? {} : e, r[0] = e, r[1] = c), useActions$1(c);
37164
37396
  }
37165
37397
  async function requestOutputDocumentation(e) {
37166
37398
  let r = getCells().inOrderIds.at(0);
@@ -37195,14 +37427,6 @@ ${c.sqlString}
37195
37427
  };
37196
37428
  require_compiler_runtime();
37197
37429
  const hasRunAnyCellAtom = atom(false);
37198
- function getInitialAppMode() {
37199
- let e = store.get(initialModeAtom);
37200
- return assertExists(e, "internal-error: initial mode not found"), invariant(e !== "present", "internal-error: initial mode cannot be 'present'"), e;
37201
- }
37202
- const viewStateAtom = atom({
37203
- mode: isIslands() ? "read" : "not-set",
37204
- cellAnchor: null
37205
- }), initialModeAtom = atom(void 0), kioskModeAtom = atom(false);
37206
37430
  var sanitizeHtmlAtom = atom((e) => {
37207
37431
  let r = e(hasRunAnyCellAtom), c = e(autoInstantiateAtom);
37208
37432
  if (r || c) return false;
@@ -70883,7 +71107,7 @@ Image URL: ${r.imageUrl}`)), contextToXml({
70883
71107
  return Logger.warn("Failed to get version from mount config"), null;
70884
71108
  }
70885
71109
  }
70886
- const marimoVersionAtom = atom(getVersionFromMountConfig() || "0.21.2-dev56"), showCodeInRunModeAtom = atom(true);
71110
+ const marimoVersionAtom = atom(getVersionFromMountConfig() || "0.21.2-dev58"), showCodeInRunModeAtom = atom(true);
70887
71111
  atom(null);
70888
71112
  var import_compiler_runtime$89 = require_compiler_runtime();
70889
71113
  function useKeydownOnElement(e, r) {
@@ -82550,7 +82774,7 @@ ${c}
82550
82774
  fullWidth: y,
82551
82775
  children: G
82552
82776
  }), r[19] = y, r[20] = S, r[21] = c, r[22] = G, r[23] = q) : q = r[23], q;
82553
- }, LazyDataExplorerComponent = import_react.lazy(() => import("./ConnectedDataExplorerComponent-D0GoOd_c.js"));
82777
+ }, LazyDataExplorerComponent = import_react.lazy(() => import("./ConnectedDataExplorerComponent-DrWDbHRV.js"));
82554
82778
  const DataExplorerPlugin = createPlugin("marimo-data-explorer").withData(object$1({
82555
82779
  label: string().nullish(),
82556
82780
  data: string()
@@ -101802,6 +102026,7 @@ ${r}
101802
102026
  __publicField(this, "saveCellConfig", throwNotImplemented);
101803
102027
  __publicField(this, "sendRestart", throwNotImplemented);
101804
102028
  __publicField(this, "syncCellIds", throwNotImplemented);
102029
+ __publicField(this, "sendDocumentTransaction", throwNotImplemented);
101805
102030
  __publicField(this, "readCode", throwNotImplemented);
101806
102031
  __publicField(this, "readSnippets", throwNotImplemented);
101807
102032
  __publicField(this, "previewDatasetColumn", throwNotImplemented);
@@ -101996,6 +102221,8 @@ ${r}
101996
102221
  return;
101997
102222
  case "kernel-startup-error":
101998
102223
  return;
102224
+ case "notebook-document-transaction":
102225
+ return;
101999
102226
  case "model-lifecycle":
102000
102227
  handleWidgetMessage(MODEL_MANAGER, c.data);
102001
102228
  return;
@@ -700,32 +700,41 @@ function createReducer(a, P) {
700
700
  };
701
701
  }
702
702
  function createReducerAndAtoms(a, P, F) {
703
- let { reducer: I, createActions: L } = createReducer(a, P), R = (a2, P2) => {
703
+ let I = [...F ?? []], L = (a2) => {
704
+ I.push(a2);
705
+ }, { reducer: R, createActions: z } = createReducer(a, P), B = (a2, P2) => {
704
706
  try {
705
- let L2 = I(a2, P2);
706
- if (F) for (let I2 of F) try {
707
- I2(a2, L2, P2);
707
+ let F2 = R(a2, P2);
708
+ for (let L2 of I) try {
709
+ L2(a2, F2, P2);
708
710
  } catch (a3) {
709
711
  Logger.error(`Error in middleware for action ${P2.type}:`, a3);
710
712
  }
711
- return L2;
713
+ return F2;
712
714
  } catch (F2) {
713
715
  return Logger.error(`Error in reducer for action ${P2.type}:`, F2), a2;
714
716
  }
715
- }, z = atom(a()), B = /* @__PURE__ */ new WeakMap();
716
- function H() {
717
- let a2 = (0, import_compiler_runtime$1.c)(2), P2 = useSetAtom(z);
718
- B.has(P2) || B.set(P2, L((a3) => {
719
- P2((P3) => R(P3, a3));
717
+ }, H = atom(a()), U = /* @__PURE__ */ new WeakMap();
718
+ function W(a2) {
719
+ let P2 = (0, import_compiler_runtime$1.c)(4), F2 = a2 === void 0 ? {} : a2, I2 = useSetAtom(H);
720
+ if (F2.skipMiddleware === true) {
721
+ let a3;
722
+ return P2[0] === I2 ? a3 = P2[1] : (a3 = z((a4) => {
723
+ I2((P3) => R(P3, a4));
724
+ }), P2[0] = I2, P2[1] = a3), a3;
725
+ }
726
+ U.has(I2) || U.set(I2, z((a3) => {
727
+ I2((P3) => B(P3, a3));
720
728
  }));
721
- let F2;
722
- return a2[0] === P2 ? F2 = a2[1] : (F2 = B.get(P2), a2[0] = P2, a2[1] = F2), F2;
729
+ let L2;
730
+ return P2[2] === I2 ? L2 = P2[3] : (L2 = U.get(I2), P2[2] = I2, P2[3] = L2), L2;
723
731
  }
724
732
  return {
725
- reducer: R,
726
- createActions: L,
727
- valueAtom: z,
728
- useActions: H
733
+ reducer: B,
734
+ addMiddleware: L,
735
+ createActions: z,
736
+ valueAtom: H,
737
+ useActions: W
729
738
  };
730
739
  }
731
740
  var import_compiler_runtime = require_compiler_runtime(), import_jsx_runtime = /* @__PURE__ */ __toESM(require_jsx_runtime(), 1), badgeVariants = cva("inline-flex items-center border rounded-full px-2 py-0.5 text-xs font-semibold transition-colors focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marimo-team/islands",
3
- "version": "0.21.2-dev56",
3
+ "version": "0.21.2-dev58",
4
4
  "main": "dist/main.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -18,6 +18,7 @@ export const MockRequestClient = {
18
18
  sendRename: vi.fn().mockResolvedValue({}),
19
19
  sendRestart: vi.fn().mockResolvedValue({}),
20
20
  syncCellIds: vi.fn().mockResolvedValue({}),
21
+ sendDocumentTransaction: vi.fn().mockResolvedValue({}),
21
22
  sendSave: vi.fn().mockResolvedValue({}),
22
23
  sendCopy: vi.fn().mockResolvedValue({}),
23
24
  sendStdin: vi.fn().mockResolvedValue({}),