@marimo-team/islands 0.25.3-dev273 → 0.25.3-dev279

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 (143) hide show
  1. package/dist/{ConnectedDataExplorerComponent-eLHPh6uu.js → ConnectedDataExplorerComponent-CErm132k.js} +25 -26
  2. package/dist/{ErrorBoundary-DBh-wUT9.js → ErrorBoundary-DmTMuDPR.js} +43 -44
  3. package/dist/{abnfDiagram-VCTEODGH-hqd0IBtX.js → abnfDiagram-VCTEODGH-d-Qn2fwb.js} +2 -2
  4. package/dist/{any-language-editor-DnG26QXh.js → any-language-editor-6k6F12Z3.js} +3 -3
  5. package/dist/{architectureDiagram-5GKGNRK7-BzLAFcc0.js → architectureDiagram-5GKGNRK7-DxragHYv.js} +1 -1
  6. package/dist/{assertNever-DIU3JJbt.js → assertNever-B-YzWzbL.js} +14 -14
  7. package/dist/{button-0-RqY1DW.js → button-DZuNnIZO.js} +220 -223
  8. package/dist/{capabilities-B6yy_CBN.js → capabilities-D9FskwsK.js} +1 -1
  9. package/dist/{chat-ui-BWIkve2R.js → chat-ui-v1Fdh0NA.js} +332 -333
  10. package/dist/{check-gUSZbRsl.js → check-XFzZeH-y.js} +1 -1
  11. package/dist/{chunk-IMKFNOWR-DOeVvuyE.js → chunk-IMKFNOWR-C0x0feFg.js} +1 -1
  12. package/dist/{chunk-SHT3W25Y-DZoFI8wR.js → chunk-SHT3W25Y-D0ZdASqB.js} +1 -1
  13. package/dist/{chunk-SVP7TREG-CWu86PSW.js → chunk-SVP7TREG-BHjL96zx.js} +1 -1
  14. package/dist/{chunk-TICWLB2K-BrM0GoP3.js → chunk-TICWLB2K-CzcrwGfp.js} +1 -1
  15. package/dist/{classDiagram-ZZMXUADV-DYi4V2bB.js → classDiagram-ZZMXUADV-BTqFAZTP.js} +2 -2
  16. package/dist/{classDiagram-v2-VYDZK3BY-tN7FIk-m.js → classDiagram-v2-VYDZK3BY-EPXb0Elt.js} +2 -2
  17. package/dist/{code-visibility-M_dXDGp6.js → code-visibility-Dw4-TXN0.js} +20 -20
  18. package/dist/{common-DV0fvw_I.js → common-BXMFi4lr.js} +5399 -5397
  19. package/dist/{config-BsPruWMR.js → config-C8MFHQ2E.js} +23 -22
  20. package/dist/{copy-icon-C2I8sw4h.js → copy-icon-CtllOdmg.js} +3 -3
  21. package/dist/{createReducer-DdtT_7ji.js → createReducer-DRqwmaTc.js} +2 -2
  22. package/dist/{cynefinDiagram-5FMLGOSQ-D5nCnDc-.js → cynefinDiagram-5FMLGOSQ-CBSD344q.js} +1 -1
  23. package/dist/{dagre-GXQ25YYZ-BHkd7f_i.js → dagre-GXQ25YYZ-JItjh3Ge.js} +1 -1
  24. package/dist/{data-grid-overlay-editor-Cd1zGKBt.js → data-grid-overlay-editor-hZzwX7Ia.js} +1 -1
  25. package/dist/{diagram-S7CK7UJ4-D1ALppT2.js → diagram-S7CK7UJ4-CTD9xTVb.js} +1 -1
  26. package/dist/{diagram-UQ7AKVKN-DLv0b83L.js → diagram-UQ7AKVKN-DTfnFai8.js} +1 -1
  27. package/dist/{diagram-VX7I27RA-7XJ7J6qg.js → diagram-VX7I27RA-BcSnucV-.js} +1 -1
  28. package/dist/{diagram-Z3DM3KII-7M7zbHp_.js → diagram-Z3DM3KII-C2ATIE8A.js} +1 -1
  29. package/dist/{dialog-DzCj1qQv.js → dialog-CaYm5imE.js} +33 -33
  30. package/dist/{dropdown-menu-CdXE15an.js → dropdown-menu-Bb0bFOIk.js} +149 -149
  31. package/dist/{ebnfDiagram-PWID7BFC-DHH1qlmV.js → ebnfDiagram-PWID7BFC-B7B9JPxc.js} +2 -2
  32. package/dist/{erDiagram-RLTQ6QDP-fI_0dGef.js → erDiagram-RLTQ6QDP-v6hDno1O.js} +1 -1
  33. package/dist/{error-banner-DPc9eIw5.js → error-banner-CHCdHVFB.js} +44 -45
  34. package/dist/{error-entries-CxN-Nq3V.js → error-entries-C1S-Rmyt.js} +563 -554
  35. package/dist/{feedback-button-CE2gPi4-.js → feedback-button-6Ui2TDLR.js} +12 -12
  36. package/dist/{flowDiagram-HODETNUW-Brg9MA6i.js → flowDiagram-HODETNUW-aIFlAtOy.js} +2 -2
  37. package/dist/{formats-DbSvAPY-.js → formats-PzBQMUnr.js} +3 -3
  38. package/dist/{glide-data-editor-BycATbgF.js → glide-data-editor-PZNlrSDI.js} +14 -16
  39. package/dist/{glide-utils-BSw3SSHF.js → glide-utils-BSQr4d90.js} +51 -59
  40. package/dist/{globals-CW6OvnI5.js → globals-DX6FPZYq.js} +3 -3
  41. package/dist/{html-to-image-Bc2AvXHG.js → html-to-image-CqGUd58T.js} +14529 -14531
  42. package/dist/{infoDiagram-27XIBGKW-E9e403YT.js → infoDiagram-27XIBGKW-D6YHLeCP.js} +1 -1
  43. package/dist/{ishikawaDiagram-5VMMS53U-C-RlYDRo.js → ishikawaDiagram-5VMMS53U-D1ZvprOX.js} +1 -1
  44. package/dist/{kanban-definition-UXKFOSKX-CLFl_uqK.js → kanban-definition-UXKFOSKX-Bna_3BMr.js} +1 -1
  45. package/dist/{loader-BVEtQ4F3.js → loader-DZvtzQoD.js} +1 -1
  46. package/dist/main.js +7357 -7361
  47. package/dist/{mermaid-rd09e1JL.js → mermaid-A36unKXJ.js} +50 -50
  48. package/dist/{mindmap-definition-YA3MSWOX-BQ8TWtyB.js → mindmap-definition-YA3MSWOX-CyVCs__G.js} +1 -1
  49. package/dist/{number-overlay-editor-B_rR-LdM.js → number-overlay-editor-D0CsL3_R.js} +1 -1
  50. package/dist/{pegDiagram-XKGWAZYB-CN8UHFPi.js → pegDiagram-XKGWAZYB-9hNBD2wZ.js} +2 -2
  51. package/dist/{pencil-DcT8AE0h.js → pencil-DYUlSKxZ.js} +1 -1
  52. package/dist/{pieDiagram-E7YTZNPT-DGuJ0EBd.js → pieDiagram-E7YTZNPT-8tr-NYo7.js} +1 -1
  53. package/dist/{process-output-qecD7Dk8.js → process-output-DskX9jLa.js} +4 -4
  54. package/dist/{railroadDiagram-O6MQD6OU-BPDA8wy8.js → railroadDiagram-O6MQD6OU-Dzg1dyyp.js} +2 -2
  55. package/dist/{requirementDiagram-BXWQKSXE-ChzLGbGW.js → requirementDiagram-BXWQKSXE-B7sNqwGG.js} +1 -1
  56. package/dist/{reveal-component-CngVwOSy.js → reveal-component-D7xeI1QR.js} +1003 -1003
  57. package/dist/{select-OxgozOC8.js → select-DsoP1qe8.js} +290 -290
  58. package/dist/{sequenceDiagram-WJ2MYXX4-DFX-bE6O.js → sequenceDiagram-WJ2MYXX4-oP9shbaG.js} +1 -1
  59. package/dist/{spec-oJn0RhpQ.js → spec-BZMDxAu7.js} +4 -4
  60. package/dist/{stateDiagram-D77RDMKH-BR7cI3wK.js → stateDiagram-D77RDMKH-CjCv4ogv.js} +2 -2
  61. package/dist/{stateDiagram-v2-MP3YSRHH-oGqB5UDI.js → stateDiagram-v2-MP3YSRHH-BW9X162a.js} +2 -2
  62. package/dist/{static-state-CuV6Pc3a.js → static-state-D-Q-Ajaa.js} +8 -8
  63. package/dist/style.css +1 -1
  64. package/dist/{swimlanes-42K2YHIH-DwSZl1yC.js → swimlanes-42K2YHIH-Ckfs9Wrn.js} +1 -1
  65. package/dist/{swimlanesDiagram-VR7AAH4N-BHlcd-Ri.js → swimlanesDiagram-VR7AAH4N-DpTNG9YP.js} +2 -2
  66. package/dist/{swiper-component-Dvj-goaD.js → swiper-component-DQbK_ZWm.js} +7 -7
  67. package/dist/{timeline-definition-24CTP7MA-DMmP-G2O.js → timeline-definition-24CTP7MA-BXaBlV6U.js} +1 -1
  68. package/dist/{toast-DbBHmxmB.js → toast-BhjIy3Tq.js} +158 -158
  69. package/dist/{tooltip-BfcDQd2j.js → tooltip-DMMiOn2f.js} +64 -64
  70. package/dist/use-restore-focus-CosX7-gx.js +7568 -0
  71. package/dist/{useAsyncData-BYIAoMqn.js → useAsyncData-Ci4AvJff.js} +4 -4
  72. package/dist/{useDateFormatter-ButWkdcK.js → useDateFormatter-CPlava52.js} +2 -2
  73. package/dist/{useDeepCompareMemoize-Bz0c5GN6.js → useDeepCompareMemoize-NaaWoFlX.js} +1 -1
  74. package/dist/useEvent-BRH-aCqi.js +19 -0
  75. package/dist/{useIframeCapabilities-BIolGsF1.js → useIframeCapabilities-BXhDDoCG.js} +1 -1
  76. package/dist/{useLifecycle-JjxCC7Vu.js → useLifecycle-SniivYmC.js} +2 -2
  77. package/dist/{vega-component-rxIxAAh9.js → vega-component-DIxaDQNs.js} +40 -40
  78. package/dist/{vennDiagram-4TSXK5OY-Db8GtH1G.js → vennDiagram-4TSXK5OY-C-hQ4iNJ.js} +1 -1
  79. package/dist/{wardleyDiagram-VM6X3IG4-DmIiC3FU.js → wardleyDiagram-VM6X3IG4-C2MQ_Umv.js} +1 -1
  80. package/dist/{xychartDiagram-S5SC5T6Z-DS9OPrNq.js → xychartDiagram-S5SC5T6Z-BtTTBn7Q.js} +1 -1
  81. package/package.json +1 -1
  82. package/src/__mocks__/executions.ts +4 -2
  83. package/src/__mocks__/notebook.ts +0 -2
  84. package/src/__tests__/CellStatus.test.tsx +6 -6
  85. package/src/components/editor/__tests__/data-attributes.test.tsx +0 -2
  86. package/src/components/editor/__tests__/output-persistence.test.tsx +20 -5
  87. package/src/components/editor/cell/CellStatus.tsx +6 -5
  88. package/src/components/editor/cell/__tests__/useRunCells.test.tsx +169 -0
  89. package/src/components/editor/cell/collapse.tsx +3 -4
  90. package/src/components/editor/cell/useRunCells.ts +32 -3
  91. package/src/components/editor/errors/__tests__/send-error-report-button.test.tsx +2 -3
  92. package/src/components/editor/notebook-cell.tsx +23 -37
  93. package/src/components/editor/renderers/grid-layout/grid-layout.tsx +4 -10
  94. package/src/components/editor/renderers/slides-layout/__tests__/plugin.test.ts +0 -2
  95. package/src/components/editor/renderers/vertical-layout/vertical-layout.tsx +8 -5
  96. package/src/components/slides/minimap.tsx +3 -2
  97. package/src/components/slides/reveal-component.tsx +3 -2
  98. package/src/components/slides/slide-cell-view.tsx +8 -8
  99. package/src/core/cells/__tests__/__snapshots__/cells.test.ts.snap +0 -101
  100. package/src/core/cells/__tests__/actions.test.ts +0 -1
  101. package/src/core/cells/__tests__/cell.test.ts +81 -17
  102. package/src/core/cells/__tests__/cells.test.ts +0 -100
  103. package/src/core/cells/__tests__/document.test.ts +2 -8
  104. package/src/core/cells/__tests__/utils.test.ts +93 -24
  105. package/src/core/cells/actions.ts +0 -1
  106. package/src/core/cells/cell.ts +37 -14
  107. package/src/core/cells/cells.ts +10 -99
  108. package/src/core/cells/document.ts +2 -13
  109. package/src/core/cells/types.ts +0 -23
  110. package/src/core/cells/utils.ts +44 -17
  111. package/src/core/codemirror/cells/extensions.ts +0 -14
  112. package/src/core/errors/__tests__/error-entries.test.ts +40 -1
  113. package/src/core/errors/error-entries.ts +2 -3
  114. package/src/core/executions/__tests__/freshness.test.ts +420 -0
  115. package/src/core/executions/__tests__/hooks.test.tsx +106 -0
  116. package/src/core/executions/atoms.ts +22 -0
  117. package/src/core/executions/freshness.ts +164 -0
  118. package/src/core/executions/hooks.ts +17 -1
  119. package/src/core/executions/index.ts +3 -1
  120. package/src/core/islands/bootstrap.ts +0 -1
  121. package/src/core/islands/components/__tests__/web-components.test.tsx +63 -0
  122. package/src/core/islands/components/web-components.tsx +11 -0
  123. package/src/core/kernel/handlers.ts +0 -4
  124. package/src/core/session/useNotebookSession.tsx +2 -7
  125. package/src/css/globals.css +6 -2
  126. package/src/plugins/impl/DataEditorPlugin.tsx +0 -4
  127. package/src/plugins/impl/data-editor/__tests__/column-types.test.ts +5 -0
  128. package/src/plugins/impl/data-editor/__tests__/glide-data-editor.test.tsx +9 -5
  129. package/src/plugins/impl/data-editor/column-types.ts +3 -0
  130. package/src/plugins/impl/data-editor/glide-data-editor.tsx +6 -5
  131. package/src/plugins/impl/data-editor/glide-utils.ts +10 -32
  132. package/src/plugins/impl/data-editor/types.ts +0 -2
  133. package/src/stories/cell-status.stories.tsx +12 -14
  134. package/src/stories/cell.stories.tsx +44 -10
  135. package/src/stories/layout/vertical/one-column.stories.tsx +0 -10
  136. package/src/theme/__tests__/islands-theme.test.tsx +276 -0
  137. package/src/theme/namespace.tsx +4 -3
  138. package/src/theme/useTheme.ts +71 -41
  139. package/dist/schemas-CdscWNy_.js +0 -4747
  140. package/dist/use-restore-focus-CmflVLWJ.js +0 -1672
  141. package/dist/useTheme-DPLobSFs.js +0 -339
  142. package/dist/utils-EBklsC5R.js +0 -813
  143. package/src/components/editor/cell/__tests__/useRunCells.test.ts +0 -45
@@ -21,61 +21,92 @@ function themeFromQueryParam(): Theme | undefined {
21
21
  return THEMES.includes(value as Theme) ? (value as Theme) : undefined;
22
22
  }
23
23
 
24
- const themeAtom = atom((get) => {
25
- // If it is islands, try a few ways to infer if it is dark mode.
26
- if (isIslands()) {
27
- // If it has a dark mode class on the body, use dark mode.
28
- if (
29
- document.body.classList.contains("dark-mode") ||
30
- document.body.classList.contains("dark")
31
- ) {
32
- return "dark";
33
- }
24
+ function getHostElements() {
25
+ return [document.body, document.documentElement];
26
+ }
34
27
 
35
- // If it has data-theme=dark or data-mode=dark on the body, use dark mode.
36
- if (
37
- document.body.dataset.theme === "dark" ||
38
- document.body.dataset.mode === "dark" ||
39
- getVsCodeTheme() === "dark"
40
- ) {
41
- return "dark";
42
- }
28
+ function getColorSchemeMedia() {
29
+ return typeof window === "undefined"
30
+ ? undefined
31
+ : window.matchMedia?.("(prefers-color-scheme: dark)");
32
+ }
43
33
 
44
- // Check the computed style for color-scheme
45
- const computedStyle = window.getComputedStyle(document.body);
46
- const colorScheme = computedStyle.getPropertyValue("color-scheme").trim();
47
- if (colorScheme) {
48
- return colorScheme.includes("dark") ? "dark" : "light";
34
+ /** Body markers override HTML markers. CSS provides the fallback. */
35
+ function getHostTheme(
36
+ prefersDark = getColorSchemeMedia()?.matches,
37
+ ): ResolvedTheme {
38
+ const elements = getHostElements();
39
+ for (const element of elements) {
40
+ for (const theme of ["dark", "light"] as const) {
41
+ if (
42
+ element.classList.contains(theme) ||
43
+ element.classList.contains(`${theme}-mode`) ||
44
+ element.classList.contains(`${theme}-theme`) ||
45
+ element.dataset.theme === theme ||
46
+ element.dataset.mode === theme
47
+ ) {
48
+ return theme;
49
+ }
49
50
  }
51
+ }
52
+
53
+ const styles = elements.map((element) => window.getComputedStyle(element));
54
+ const colorScheme = styles[0].colorScheme.split(/\s+/);
55
+ if (colorScheme.includes("dark")) {
56
+ return !colorScheme.includes("light") || prefersDark ? "dark" : "light";
57
+ }
58
+ if (colorScheme.includes("light")) {
59
+ return "light";
60
+ }
50
61
 
51
- // Fallback: check for dark background color
52
- const bgColor = computedStyle.getPropertyValue("background-color");
53
- const rgb = bgColor.match(/\d+/g);
54
- if (rgb) {
55
- const [r, g, b] = rgb.map(Number);
56
- const brightness = (r * 299 + g * 587 + b * 114) / 1000;
57
- return brightness < 128 ? "dark" : "light";
62
+ // Transparent backgrounds do not indicate a dark host page.
63
+ for (const style of styles) {
64
+ const rgb = style.backgroundColor.match(/[\d.]+/g)?.map(Number);
65
+ if (rgb && (rgb.length === 3 || rgb[3] > 0)) {
66
+ const [r, g, b] = rgb;
67
+ return (r * 299 + g * 587 + b * 114) / 1000 < 128 ? "dark" : "light";
58
68
  }
69
+ }
59
70
 
60
- // We don't want to infer from the system theme,
61
- // since the island consumer may not support dark mode.
62
- return "light";
71
+ // A dark system preference does not imply a dark host.
72
+ return "light";
73
+ }
74
+
75
+ const hostThemeAtom = atom<ResolvedTheme | undefined>(undefined);
76
+ hostThemeAtom.onMount = (setTheme) => {
77
+ const media = getColorSchemeMedia();
78
+ const updateTheme = () => setTheme(getHostTheme(media?.matches));
79
+ const observer = new MutationObserver(updateTheme);
80
+ for (const element of getHostElements()) {
81
+ observer.observe(element, {
82
+ attributes: true,
83
+ attributeFilter: ["class", "data-theme", "data-mode", "style"],
84
+ });
63
85
  }
86
+ media?.addEventListener("change", updateTheme);
87
+ updateTheme();
88
+ return () => {
89
+ observer.disconnect();
90
+ media?.removeEventListener("change", updateTheme);
91
+ // A later mount must read the current host theme.
92
+ setTheme(undefined);
93
+ };
94
+ };
64
95
 
96
+ const themeAtom = atom((get) => {
97
+ if (isIslands()) {
98
+ return get(hostThemeAtom) ?? getHostTheme();
99
+ }
65
100
  return themeFromQueryParam() ?? get(resolvedMarimoConfigAtom).display.theme;
66
101
  });
67
102
 
68
103
  const prefersDarkModeAtom = atom(false);
69
104
 
70
105
  function setupThemeListener(): void {
71
- if (typeof window === "undefined") {
106
+ const media = getColorSchemeMedia();
107
+ if (!media) {
72
108
  return;
73
109
  }
74
- if (!window.matchMedia) {
75
- return;
76
- }
77
-
78
- const media = window.matchMedia("(prefers-color-scheme: dark)");
79
110
  store.set(prefersDarkModeAtom, media.matches);
80
111
  media.addEventListener("change", (e) => {
81
112
  store.set(prefersDarkModeAtom, e.matches);
@@ -126,8 +157,7 @@ export const resolvedThemeAtom = atom((get) => {
126
157
  });
127
158
 
128
159
  /**
129
- * React hook to get the theme of the app.
130
- * This is stored in the user config.
160
+ * Returns the resolved theme from VS Code, the Islands host, or notebook settings.
131
161
  */
132
162
  export function useTheme(): { theme: ResolvedTheme } {
133
163
  const theme = useAtomValue(resolvedThemeAtom, { store });