@marimo-team/islands 0.19.10-dev25 → 0.19.10-dev30

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/main.js CHANGED
@@ -73304,7 +73304,7 @@ Image URL: ${r.imageUrl}`)), contextToXml({
73304
73304
  return Logger.warn("Failed to get version from mount config"), null;
73305
73305
  }
73306
73306
  }
73307
- const marimoVersionAtom = atom(getVersionFromMountConfig() || "0.19.10-dev25"), showCodeInRunModeAtom = atom(true);
73307
+ const marimoVersionAtom = atom(getVersionFromMountConfig() || "0.19.10-dev30"), showCodeInRunModeAtom = atom(true);
73308
73308
  atom(null);
73309
73309
  var import_compiler_runtime$88 = require_compiler_runtime();
73310
73310
  function useKeydownOnElement(e, r) {
@@ -102162,7 +102162,7 @@ ${c}
102162
102162
  }), r[12] = y, r[13] = z, r[14] = G) : G = r[14], G;
102163
102163
  };
102164
102164
  var import_compiler_runtime$1 = require_compiler_runtime(), VerticalLayoutRenderer = (e) => {
102165
- let r = (0, import_compiler_runtime$1.c)(34), { cells: c, appConfig: d, mode: f } = e, { invisible: _ } = useDelayVisibility(c.length, f), v = useAtomValue(kioskModeAtom), y = useAtomValue(kernelStateAtom), [S] = useResolvedMarimoConfig(), w = useAtomValue(showCodeInRunModeAtom), E;
102165
+ let r = (0, import_compiler_runtime$1.c)(37), { cells: c, appConfig: d, mode: f } = e, { invisible: _ } = useDelayVisibility(c.length, f), v = useAtomValue(kioskModeAtom), y = useAtomValue(kernelStateAtom), [S] = useResolvedMarimoConfig(), w = useAtomValue(showCodeInRunModeAtom), E;
102166
102166
  r[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (E = new URLSearchParams(window.location.search), r[0] = E) : E = r[0];
102167
102167
  let O = E, M;
102168
102168
  r[1] !== v || r[2] !== w ? (M = () => {
@@ -102227,32 +102227,33 @@ ${c}
102227
102227
  }) : (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
102228
102228
  children: c.map(LY)
102229
102229
  }), r[14] = d.width, r[15] = c, r[16] = _, r[17] = y, r[18] = LY, r[19] = RY) : RY = r[19];
102230
- let zY = RY, BY;
102231
- r[20] !== q || r[21] !== zY || r[22] !== I ? (BY = I && q ? (0, import_jsx_runtime.jsxs)("div", {
102232
- className: "flex flex-col gap-5",
102233
- children: [
102234
- " ",
102235
- zY()
102236
- ]
102237
- }) : zY(), r[20] = q, r[21] = zY, r[22] = I, r[23] = BY) : BY = r[23];
102238
- let VY;
102239
- r[24] !== q || r[25] !== f || r[26] !== I ? (VY = f === "read" && (0, import_jsx_runtime.jsx)(ActionButtons, {
102230
+ let zY = RY, BY = I && q && "gap-5", VY;
102231
+ r[20] === BY ? VY = r[21] : (VY = cn("flex flex-col", BY), r[20] = BY, r[21] = VY);
102232
+ let HY;
102233
+ r[22] === zY ? HY = r[23] : (HY = zY(), r[22] = zY, r[23] = HY);
102234
+ let UY;
102235
+ r[24] !== VY || r[25] !== HY ? (UY = (0, import_jsx_runtime.jsx)("div", {
102236
+ className: VY,
102237
+ children: HY
102238
+ }), r[24] = VY, r[25] = HY, r[26] = UY) : UY = r[26];
102239
+ let WY;
102240
+ r[27] !== q || r[28] !== f || r[29] !== I ? (WY = f === "read" && (0, import_jsx_runtime.jsx)(ActionButtons, {
102240
102241
  canShowCode: q,
102241
102242
  showCode: I,
102242
102243
  onToggleShowCode: () => z(_temp2$1)
102243
- }), r[24] = q, r[25] = f, r[26] = I, r[27] = VY) : VY = r[27];
102244
- let HY;
102245
- r[28] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (HY = (0, import_jsx_runtime.jsx)(FloatingOutline, {}), r[28] = HY) : HY = r[28];
102246
- let UY;
102247
- return r[29] !== d || r[30] !== _ || r[31] !== BY || r[32] !== VY ? (UY = (0, import_jsx_runtime.jsxs)(VerticalLayoutWrapper, {
102244
+ }), r[27] = q, r[28] = f, r[29] = I, r[30] = WY) : WY = r[30];
102245
+ let GY;
102246
+ r[31] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (GY = (0, import_jsx_runtime.jsx)(FloatingOutline, {}), r[31] = GY) : GY = r[31];
102247
+ let KY;
102248
+ return r[32] !== d || r[33] !== _ || r[34] !== WY || r[35] !== UY ? (KY = (0, import_jsx_runtime.jsxs)(VerticalLayoutWrapper, {
102248
102249
  invisible: _,
102249
102250
  appConfig: d,
102250
102251
  children: [
102251
- BY,
102252
- VY,
102253
- HY
102252
+ UY,
102253
+ WY,
102254
+ GY
102254
102255
  ]
102255
- }), r[29] = d, r[30] = _, r[31] = BY, r[32] = VY, r[33] = UY) : UY = r[33], UY;
102256
+ }), r[32] = d, r[33] = _, r[34] = WY, r[35] = UY, r[36] = KY) : KY = r[36], KY;
102256
102257
  }, ActionButtons = (e) => {
102257
102258
  let r = (0, import_compiler_runtime$1.c)(26), { canShowCode: c, showCode: d, onToggleShowCode: f } = e, { readCode: _ } = useRequestClient(), v = _temp3, y = _temp4, S;
102258
102259
  r[0] === _ ? S = r[1] : (S = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marimo-team/islands",
3
- "version": "0.19.10-dev25",
3
+ "version": "0.19.10-dev30",
4
4
  "main": "dist/main.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -58,6 +58,7 @@ export const DependencyGraphTree: React.FC<PropsWithChildren<Props>> = ({
58
58
  cellAtoms,
59
59
  variables,
60
60
  settings.hidePureMarkdown,
61
+ settings.hideReusableFunctions,
61
62
  );
62
63
  elements = layoutElements({
63
64
  nodes: elements.nodes,
@@ -94,9 +95,17 @@ export const DependencyGraphTree: React.FC<PropsWithChildren<Props>> = ({
94
95
  cellAtoms,
95
96
  variables,
96
97
  settings.hidePureMarkdown,
98
+ settings.hideReusableFunctions,
97
99
  ),
98
100
  );
99
- }, [cellIds, variables, cellAtoms, syncChanges, settings.hidePureMarkdown]);
101
+ }, [
102
+ cellIds,
103
+ variables,
104
+ cellAtoms,
105
+ syncChanges,
106
+ settings.hidePureMarkdown,
107
+ settings.hideReusableFunctions,
108
+ ]);
100
109
 
101
110
  const [selection, setSelection] = useState<GraphSelection>();
102
111
  useFitToViewOnDimensionChange();
@@ -24,6 +24,7 @@ interface Props {
24
24
  const graphViewAtom = atom<LayoutDirection>("TB");
25
25
  const graphViewSettings = atom<GraphSettings>({
26
26
  hidePureMarkdown: true,
27
+ hideReusableFunctions: false,
27
28
  });
28
29
 
29
30
  export const DependencyGraph: React.FC<Props> = (props) => {
@@ -2,6 +2,7 @@
2
2
 
3
3
  import type { Atom } from "jotai";
4
4
  import { type Edge, MarkerType, type Node, type NodeProps } from "reactflow";
5
+ import { getNotebook } from "@/core/cells/cells";
5
6
  import type { CellId } from "@/core/cells/ids";
6
7
  import type { CellData } from "@/core/cells/types";
7
8
  import { store } from "@/core/state/jotai";
@@ -29,6 +30,7 @@ interface ElementsBuilder {
29
30
  cellAtoms: Atom<CellData>[],
30
31
  variables: Variables,
31
32
  hidePureMarkdown: boolean,
33
+ hideReusableFunctions: boolean,
32
34
  ) => { nodes: Node<NodeData>[]; edges: Edge[] };
33
35
  }
34
36
 
@@ -76,6 +78,7 @@ export class VerticalElementsBuilder implements ElementsBuilder {
76
78
  cellAtoms: Atom<CellData>[],
77
79
  variables: Variables,
78
80
  _hidePureMarkdown: boolean,
81
+ _hideReusableFunctions: boolean,
79
82
  ) {
80
83
  let prevY = 0;
81
84
  const nodes: Node<NodeData>[] = [];
@@ -143,6 +146,7 @@ export class TreeElementsBuilder implements ElementsBuilder {
143
146
  cellAtoms: Atom<CellData>[],
144
147
  variables: Variables,
145
148
  hidePureMarkdown: boolean,
149
+ hideReusableFunctions: boolean,
146
150
  ) {
147
151
  const nodes: Node<NodeData>[] = [];
148
152
  const edges: Edge[] = [];
@@ -171,18 +175,25 @@ export class TreeElementsBuilder implements ElementsBuilder {
171
175
  }
172
176
  }
173
177
 
174
- for (const [cellId, cellAtom] of Arrays.zip(cellIds, cellAtoms)) {
175
- // Show every cell
176
- if (!hidePureMarkdown) {
177
- nodes.push(this.createNode(cellId, cellAtom));
178
- }
178
+ const cellRuntime = getNotebook().cellRuntime;
179
179
 
180
+ for (const [cellId, cellAtom] of Arrays.zip(cellIds, cellAtoms)) {
181
+ const code = store.get(cellAtom).code.trim();
180
182
  const hasEdge = nodesWithEdges.has(cellId);
181
- const isMarkdown = store.get(cellAtom).code.trim().startsWith("mo.md");
182
- // Show only cells with edges or non-markdown cells
183
- if (hasEdge || !isMarkdown) {
184
- nodes.push(this.createNode(cellId, cellAtom));
183
+ const isMarkdown = code.startsWith("mo.md");
184
+ const runtime = cellRuntime[cellId];
185
+ const isReusable = runtime?.serialization?.toLowerCase() === "valid";
186
+
187
+ // Apply filters
188
+ if (hidePureMarkdown && isMarkdown && !hasEdge) {
189
+ continue;
190
+ }
191
+ if (hideReusableFunctions && isReusable && !hasEdge) {
192
+ continue;
185
193
  }
194
+
195
+ // Show every cell that wasn't filtered out
196
+ nodes.push(this.createNode(cellId, cellAtom));
186
197
  }
187
198
 
188
199
  return { nodes, edges };
@@ -43,7 +43,8 @@ export const GraphToolbar: React.FC<Props> = memo(
43
43
  onSettingsChange({ ...settings, [key]: value });
44
44
  };
45
45
 
46
- const checkboxId = useId();
46
+ const markdownCheckboxId = useId();
47
+ const functionsCheckboxId = useId();
47
48
 
48
49
  const settingsButton = (
49
50
  <Popover>
@@ -54,16 +55,31 @@ export const GraphToolbar: React.FC<Props> = memo(
54
55
  </PopoverTrigger>
55
56
  <PopoverContent className="w-auto p-2 text-muted-foreground">
56
57
  <div className="font-semibold pb-4">Settings</div>
57
- <div className="flex items-center gap-2">
58
- <Checkbox
59
- data-testid="hide-pure-markdown-checkbox"
60
- id={checkboxId}
61
- checked={settings.hidePureMarkdown}
62
- onCheckedChange={(checked) =>
63
- handleSettingChange("hidePureMarkdown", Boolean(checked))
64
- }
65
- />
66
- <Label htmlFor={checkboxId}>Hide pure markdown</Label>
58
+ <div className="flex flex-col gap-2">
59
+ <div className="flex items-center gap-2">
60
+ <Checkbox
61
+ data-testid="hide-pure-markdown-checkbox"
62
+ id={markdownCheckboxId}
63
+ checked={settings.hidePureMarkdown}
64
+ onCheckedChange={(checked) =>
65
+ handleSettingChange("hidePureMarkdown", Boolean(checked))
66
+ }
67
+ />
68
+ <Label htmlFor={markdownCheckboxId}>Hide pure markdown</Label>
69
+ </div>
70
+ <div className="flex items-center gap-2">
71
+ <Checkbox
72
+ data-testid="hide-reusable-functions-checkbox"
73
+ id={functionsCheckboxId}
74
+ checked={settings.hideReusableFunctions}
75
+ onCheckedChange={(checked) =>
76
+ handleSettingChange("hideReusableFunctions", Boolean(checked))
77
+ }
78
+ />
79
+ <Label htmlFor={functionsCheckboxId}>
80
+ Hide reusable functions
81
+ </Label>
82
+ </div>
67
83
  </div>
68
84
  </PopoverContent>
69
85
  </Popover>
@@ -17,4 +17,5 @@ export type GraphSelection =
17
17
 
18
18
  export interface GraphSettings {
19
19
  hidePureMarkdown: boolean;
20
+ hideReusableFunctions: boolean;
20
21
  }
@@ -96,10 +96,10 @@ export const PackageAlert: React.FC = () => {
96
96
 
97
97
  if (isMissingPackageAlert(packageAlert)) {
98
98
  return (
99
- <div className="flex flex-col gap-4 mb-5 fixed top-5 left-12 min-w-[400px] z-200 opacity-95 max-w-[600px]">
99
+ <div className="flex flex-col gap-4 mb-5 fixed top-5 left-12 min-w-[400px] z-200 opacity-95 max-w-[600px] pointer-events-none">
100
100
  <Banner
101
101
  kind="danger"
102
- className="flex flex-col rounded py-3 px-5 animate-in slide-in-from-left overflow-auto max-h-[80vh] scrollbar-thin"
102
+ className="flex flex-col rounded py-3 px-5 animate-in slide-in-from-left overflow-auto max-h-[80vh] scrollbar-thin pointer-events-auto"
103
103
  >
104
104
  <div className="flex justify-between">
105
105
  <span className="font-bold text-lg flex items-center mb-2">
@@ -207,10 +207,10 @@ export const PackageAlert: React.FC = () => {
207
207
  }
208
208
 
209
209
  return (
210
- <div className="flex flex-col gap-4 mb-5 fixed top-5 left-12 min-w-[400px] z-200 opacity-95 max-w-[600px] ">
210
+ <div className="flex flex-col gap-4 mb-5 fixed top-5 left-12 min-w-[400px] z-200 opacity-95 max-w-[600px] pointer-events-none">
211
211
  <Banner
212
212
  kind={status === "failed" ? "danger" : "info"}
213
- className="flex flex-col rounded pt-3 pb-4 px-5 overflow-auto max-h-[80vh] scrollbar-thin"
213
+ className="flex flex-col rounded pt-3 pb-4 px-5 overflow-auto max-h-[80vh] scrollbar-thin pointer-events-auto"
214
214
  >
215
215
  <div className="flex justify-between">
216
216
  <span className="font-bold text-lg flex items-center mb-2">
@@ -172,11 +172,9 @@ const VerticalLayoutRenderer: React.FC<VerticalLayoutProps> = ({
172
172
  // spacing is handled elsewhere
173
173
  return (
174
174
  <VerticalLayoutWrapper invisible={invisible} appConfig={appConfig}>
175
- {showCode && canShowCode ? (
176
- <div className="flex flex-col gap-5"> {renderCells()}</div>
177
- ) : (
178
- renderCells()
179
- )}
175
+ <div className={cn("flex flex-col", showCode && canShowCode && "gap-5")}>
176
+ {renderCells()}
177
+ </div>
180
178
  {mode === "read" && (
181
179
  <ActionButtons
182
180
  canShowCode={canShowCode}