@marimo-team/islands 0.25.3-dev402 → 0.25.3-dev408

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/{ConnectedDataExplorerComponent-1DGGwl88.js → ConnectedDataExplorerComponent-DCW4bXq-.js} +1 -1
  2. package/dist/{ErrorBoundary-DfbzIKA3.js → ErrorBoundary-W6a-7ong.js} +1 -1
  3. package/dist/{chat-ui-r3PPIMn0.js → chat-ui-BGEXB6V4.js} +1354 -1320
  4. package/dist/{code-visibility-CXijswY7.js → code-visibility-0v5rL9iu.js} +1 -1
  5. package/dist/{common-Cm5ENbUw.js → common-B7sS0asw.js} +1 -1
  6. package/dist/{data-grid-overlay-editor-Dv0TkGKt.js → data-grid-overlay-editor-DtWpYC-j.js} +1 -1
  7. package/dist/{feedback-button-Xk-mOev4.js → feedback-button-KVSGwnVr.js} +2 -2
  8. package/dist/{glide-data-editor-DdxBDWAj.js → glide-data-editor-D0dykzDr.js} +3 -3
  9. package/dist/{globals-DR3VVkF6.js → globals-DOi11Nup.js} +1 -1
  10. package/dist/main.js +6160 -6141
  11. package/dist/{number-overlay-editor-Cc5gJryh.js → number-overlay-editor-DoR-BTMn.js} +1 -1
  12. package/dist/{process-output-39KkAXSF.js → process-output-BvCDoG-m.js} +14 -25
  13. package/dist/{reveal-component-Dm5K9KPi.js → reveal-component-Vu8VncD4.js} +2 -2
  14. package/dist/{spec-Ww0JjShW.js → spec-DV8oNpRR.js} +46 -49
  15. package/dist/{semaphore-8KhQouXt.js → useDeepCompareMemoize-C90a6_io.js} +15 -5
  16. package/dist/{vega-component-DQZhTzVQ.js → vega-component-ArEoBGzQ.js} +197 -198
  17. package/package.json +1 -1
  18. package/src/components/chat/__tests__/chat-utils.test.ts +48 -0
  19. package/src/components/chat/__tests__/message-queue.test.tsx +94 -1
  20. package/src/components/chat/__tests__/pending-chat-prompt.test.tsx +568 -0
  21. package/src/components/chat/__tests__/useFileState.test.tsx +176 -15
  22. package/src/components/chat/chat-components.tsx +3 -2
  23. package/src/components/chat/chat-panel.tsx +199 -74
  24. package/src/components/chat/chat-utils.ts +148 -34
  25. package/src/components/chat/user-message.tsx +15 -6
  26. package/src/components/data-table/charts/__tests__/altair-generator.test.ts +42 -27
  27. package/src/components/data-table/charts/chart-spec/altair-generator.ts +2 -6
  28. package/src/core/ai/__tests__/attachments.test.ts +153 -0
  29. package/src/core/ai/attachments.ts +80 -0
  30. package/src/utils/python-poet/poet.ts +12 -2
  31. package/dist/useDeepCompareMemoize-Bvrue1iy.js +0 -11
@@ -0,0 +1,80 @@
1
+ /* Copyright 2026 Marimo. All rights reserved. */
2
+
3
+ import { AiModelId } from "./ids/ids";
4
+ import { getKnownModelMaps } from "./model-registry";
5
+
6
+ const IMAGE_TYPES = ["image/png", "image/jpeg", "image/gif", "image/webp"];
7
+ // oxlint-disable-next-line no-control-regex -- Binary detection deliberately matches control characters.
8
+ const BINARY_CONTROL_CHARACTERS = /[\x00-\x08\x0B\x0E-\x1F]/;
9
+ const TEXT_TYPES = [
10
+ "text/*",
11
+ "application/json",
12
+ "application/xml",
13
+ "application/toml",
14
+ "application/yaml",
15
+ "application/x-yaml",
16
+ ];
17
+
18
+ export function getAttachmentMediaType(mediaType: string): string {
19
+ const normalized = mediaType.split(";", 1)[0].trim().toLowerCase();
20
+ if (/^(image|audio|video)\//.test(normalized)) {
21
+ return normalized;
22
+ }
23
+ if (
24
+ isSupportedAttachmentType(normalized, TEXT_TYPES) ||
25
+ normalized.endsWith("+json") ||
26
+ normalized.endsWith("+xml")
27
+ ) {
28
+ return "text/plain";
29
+ }
30
+ return normalized;
31
+ }
32
+
33
+ export async function normalizeAttachment(file: File): Promise<File> {
34
+ let mediaType = getAttachmentMediaType(file.type);
35
+ if (
36
+ mediaType !== "text/plain" &&
37
+ !/^(image|audio|video)\//.test(mediaType) &&
38
+ mediaType !== "application/pdf"
39
+ ) {
40
+ const bytes = new Uint8Array(await file.arrayBuffer());
41
+ try {
42
+ const text = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
43
+ if (!BINARY_CONTROL_CHARACTERS.test(text)) {
44
+ mediaType = "text/plain";
45
+ }
46
+ } catch {
47
+ // Invalid UTF-8 stays binary instead of being decoded with replacement characters.
48
+ }
49
+ }
50
+ return mediaType === file.type
51
+ ? file
52
+ : new File([file], file.name, {
53
+ type: mediaType,
54
+ lastModified: file.lastModified,
55
+ });
56
+ }
57
+
58
+ export function getSupportedAttachmentTypes(model: string): readonly string[] {
59
+ const inputTypes = getKnownModelMaps().modelMap.get(
60
+ AiModelId.parse(model).id,
61
+ )?.input_types;
62
+ // Missing metadata must not prevent custom endpoints from accepting files.
63
+ const isUnknown = !inputTypes?.length;
64
+ return [
65
+ "text/*",
66
+ ...(isUnknown || inputTypes.includes("image") ? IMAGE_TYPES : []),
67
+ ...(isUnknown || inputTypes.includes("pdf") ? ["application/pdf"] : []),
68
+ ];
69
+ }
70
+
71
+ export function isSupportedAttachmentType(
72
+ mediaType: string,
73
+ supportedTypes: readonly string[],
74
+ ): boolean {
75
+ return supportedTypes.some((supported) =>
76
+ supported.endsWith("/*")
77
+ ? mediaType.startsWith(supported.slice(0, -1))
78
+ : mediaType === supported,
79
+ );
80
+ }
@@ -69,7 +69,17 @@ export class Literal implements PythonCode {
69
69
  return "None";
70
70
  }
71
71
  if (typeof this.value === "string") {
72
- return `'${this.value}'`;
72
+ // Escape sequences in JSON strings are also valid in Python. Requote with
73
+ // single quotes, and escape the line breaks that `str.splitlines()` splits
74
+ // on but `JSON.stringify` does not escape.
75
+ const escaped = JSON.stringify(this.value)
76
+ .slice(1, -1)
77
+ .replaceAll('\\"', '"')
78
+ .replaceAll("'", "\\'")
79
+ .replaceAll("\u0085", "\\x85")
80
+ .replaceAll("\u2028", "\\u2028")
81
+ .replaceAll("\u2029", "\\u2029");
82
+ return `'${escaped}'`;
73
83
  }
74
84
  if (typeof this.value === "boolean") {
75
85
  return this.value ? "True" : "False";
@@ -104,7 +114,7 @@ export class Literal implements PythonCode {
104
114
  if (code === "") {
105
115
  return "";
106
116
  }
107
- return `'${key}': ${code}`;
117
+ return `${new Literal(key).toCode()}: ${code}`;
108
118
  };
109
119
 
110
120
  const formattedEntries = entries
@@ -1,11 +0,0 @@
1
- import { a as e } from "./rolldown-runtime-BPCzCO3I.js";
2
- import { t } from "./react-Bgs_wQh3.js";
3
- import { jt as n } from "./use-restore-focus-CE9Sflmg.js";
4
- //#region src/hooks/useDeepCompareMemoize.ts
5
- var r = /* @__PURE__ */ e(t(), 1);
6
- function i(e) {
7
- let t = r.useRef(e);
8
- return n(e, t.current) || (t.current = e), t.current;
9
- }
10
- //#endregion
11
- export { i as t };