@ai-matrx/media 0.4.3 → 0.4.5

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/viewers.cjs CHANGED
@@ -47,7 +47,7 @@ __export(viewers_exports, {
47
47
  module.exports = __toCommonJS(viewers_exports);
48
48
 
49
49
  // src/viewers/media-file-viewer.tsx
50
- var import_react11 = require("react");
50
+ var import_react12 = require("react");
51
51
 
52
52
  // src/viewers/registry.ts
53
53
  var VIEWER_SLOT = /* @__PURE__ */ Symbol.for("ai-matrx.media.viewer-registry");
@@ -1433,6 +1433,9 @@ function HtmlSourceView({ source, maxBytes = 1024 * 1024 }) {
1433
1433
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("pre", { className: "h-full w-full overflow-auto bg-muted/10 p-4 font-mono text-xs leading-relaxed break-all whitespace-pre-wrap", children: text });
1434
1434
  }
1435
1435
 
1436
+ // src/viewers/svg-viewer.tsx
1437
+ var import_react11 = require("react");
1438
+
1436
1439
  // src/viewers/transparency-grid.ts
1437
1440
  var TRANSPARENCY_GRID_STYLE = {
1438
1441
  backgroundImage: "linear-gradient(45deg, rgb(0 0 0 / 0.08) 25%, transparent 25%), linear-gradient(-45deg, rgb(0 0 0 / 0.08) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, rgb(0 0 0 / 0.08) 75%), linear-gradient(-45deg, transparent 75%, rgb(0 0 0 / 0.08) 75%)",
@@ -1468,7 +1471,19 @@ function SvgViewer(props) {
1468
1471
  }
1469
1472
  function SvgRenderedView({ source, fileName }) {
1470
1473
  const fromClient = useMediaBlob(source.kind === "ref" ? source.ref : null);
1471
- const url = source.kind === "blob" ? source.url : fromClient.url;
1474
+ const [normalizedUrl, setNormalizedUrl] = (0, import_react11.useState)(null);
1475
+ (0, import_react11.useEffect)(() => {
1476
+ const blob = fromClient.blob;
1477
+ if (!blob || blob.type === "image/svg+xml") {
1478
+ setNormalizedUrl(null);
1479
+ return void 0;
1480
+ }
1481
+ const normalized = new Blob([blob], { type: "image/svg+xml" });
1482
+ const objectUrl = URL.createObjectURL(normalized);
1483
+ setNormalizedUrl(objectUrl);
1484
+ return () => URL.revokeObjectURL(objectUrl);
1485
+ }, [fromClient.blob]);
1486
+ const url = source.kind === "blob" ? source.url : normalizedUrl ?? fromClient.url;
1472
1487
  const loading = source.kind === "ref" && fromClient.loading;
1473
1488
  const error = source.kind === "ref" ? fromClient.error : null;
1474
1489
  if (error) {
@@ -1647,7 +1662,7 @@ function MediaFileViewer({
1647
1662
  }) {
1648
1663
  const kind = previewKind ?? getPreviewKind(props.fileName, props.mimeType ?? null);
1649
1664
  const viewer = getMediaViewer(kind) ?? BUILT_IN[kind];
1650
- if (viewer) return (0, import_react11.createElement)(viewer, props);
1665
+ if (viewer) return (0, import_react12.createElement)(viewer, props);
1651
1666
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(MediaViewerUnavailable, { ...props, kind });
1652
1667
  }
1653
1668
  //# sourceMappingURL=viewers.cjs.map