@marimo-team/islands 0.23.3-dev3 → 0.23.3-dev33

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 (31) hide show
  1. package/dist/{chat-ui-CTt4WX0V.js → chat-ui-BLFhPclV.js} +2 -2
  2. package/dist/{html-to-image-BdsDysfl.js → html-to-image-XYwXqg2E.js} +2107 -2107
  3. package/dist/main.js +1134 -1116
  4. package/dist/{process-output-COL2Pf5I.js → process-output-BDVjDpbu.js} +1 -1
  5. package/dist/{reveal-component-Cd5Y35Ny.js → reveal-component-DaX8Aj0s.js} +2 -2
  6. package/dist/{slide-BEerfanN.js → slide-C1t_W7WX.js} +571 -467
  7. package/package.json +2 -2
  8. package/src/components/editor/file-tree/__tests__/requesting-tree.test.ts +84 -2
  9. package/src/components/editor/file-tree/file-explorer.tsx +142 -203
  10. package/src/components/editor/file-tree/file-name-input.tsx +41 -0
  11. package/src/components/editor/file-tree/file-operations.tsx +266 -0
  12. package/src/components/editor/file-tree/renderers.tsx +1 -1
  13. package/src/components/editor/file-tree/requesting-tree.tsx +68 -49
  14. package/src/components/editor/output/JsonOutput.tsx +157 -4
  15. package/src/components/editor/output/__tests__/JsonOutput-mimetype.test.tsx +80 -0
  16. package/src/components/editor/output/__tests__/json-output.test.ts +147 -2
  17. package/src/components/home/state.ts +13 -1
  18. package/src/components/pages/home-page.tsx +116 -10
  19. package/src/core/islands/__tests__/bridge.test.ts +116 -5
  20. package/src/core/islands/bridge.ts +5 -1
  21. package/src/core/network/requests-network.ts +0 -3
  22. package/src/core/static/export-context.ts +43 -0
  23. package/src/plugins/core/__test__/trusted-url.test.ts +130 -18
  24. package/src/plugins/core/trusted-url.ts +23 -10
  25. package/src/plugins/impl/anywidget/__tests__/widget-binding.test.ts +29 -1
  26. package/src/plugins/impl/mpl-interactive/__tests__/MplInteractivePlugin.test.tsx +34 -0
  27. package/src/plugins/impl/panel/__tests__/PanelPlugin.test.ts +35 -2
  28. package/src/utils/__tests__/path.test.ts +20 -0
  29. package/src/utils/pathUtils.test.ts +141 -1
  30. package/src/utils/pathUtils.ts +46 -0
  31. package/src/utils/paths.ts +9 -1
@@ -1,5 +1,7 @@
1
1
  /* Copyright 2026 Marimo. All rights reserved. */
2
2
 
3
+ import { type FilePath, Paths, PathBuilder } from "./paths";
4
+
3
5
  /**
4
6
  * Get the protocol and parent directories of a path.
5
7
  */
@@ -74,3 +76,47 @@ export function fileSplit(path: string): [name: string, extension: string] {
74
76
  const extension = lastDotIndex > 0 ? path.slice(lastDotIndex) : "";
75
77
  return [name, extension];
76
78
  }
79
+
80
+ /**
81
+ * Build the "_copy" filename used for duplicate operations.
82
+ * e.g. `foo.py` → `foo_copy.py`, `README` → `README_copy`.
83
+ */
84
+ export function makeDuplicateName(name: string): string {
85
+ const [base, extension] = fileSplit(name);
86
+ return `${base}_copy${extension}`;
87
+ }
88
+
89
+ /**
90
+ * Return `path` as an absolute path, joining against `root` when it's
91
+ * workspace-relative. `root`'s delimiter determines the join style so
92
+ * Windows and POSIX paths both behave correctly.
93
+ */
94
+ export function toAbsolutePath(path: string, root: string): FilePath {
95
+ if (Paths.isAbsolute(path)) {
96
+ return path as FilePath;
97
+ }
98
+ return PathBuilder.guessDeliminator(root).join(root, path as FilePath);
99
+ }
100
+
101
+ /**
102
+ * Resolve absolute current/new paths for a rename- or copy-style operation.
103
+ * Given a node's current `path` (absolute or workspace-relative) and a
104
+ * desired new `name` (basename only), returns the absolute source and the
105
+ * absolute destination, keeping the file in the same parent directory.
106
+ */
107
+ export function resolvePaths({
108
+ path,
109
+ name,
110
+ root,
111
+ }: {
112
+ path: string;
113
+ name: string;
114
+ root: string;
115
+ }): { path: FilePath; newPath: FilePath } {
116
+ const absPath = toAbsolutePath(path, root);
117
+ // When `root` is empty (callers with already-absolute paths), fall back to
118
+ // the resolved absolute path so we don't default to the Windows delimiter.
119
+ const pathBuilder = PathBuilder.guessDeliminator(root || absPath);
120
+ const newPath = pathBuilder.join(pathBuilder.dirname(absPath), name);
121
+ return { path: absPath, newPath };
122
+ }
@@ -4,10 +4,18 @@ import type { TypedString } from "./typed";
4
4
 
5
5
  export type FilePath = TypedString<"FilePath">;
6
6
 
7
+ // Windows drive-letter prefix like `C:\`, `d:/`, `Z:\`.
8
+ const WINDOWS_DRIVE_PREFIX = /^[A-Za-z]:[/\\]/;
9
+ // URI scheme prefix like `s3://`, `gs://`, `http://`, `file://`.
10
+ const URI_SCHEME_PREFIX = /^[A-Za-z][\dA-Za-z+.-]*:\/\//;
11
+
7
12
  export const Paths = {
8
13
  isAbsolute: (path: string): boolean => {
9
14
  return (
10
- path.startsWith("/") || path.startsWith("\\") || path.startsWith("C:\\")
15
+ path.startsWith("/") ||
16
+ path.startsWith("\\") ||
17
+ WINDOWS_DRIVE_PREFIX.test(path) ||
18
+ URI_SCHEME_PREFIX.test(path)
11
19
  );
12
20
  },
13
21
  dirname: (path: string) => {