@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.js CHANGED
@@ -1391,6 +1391,9 @@ function HtmlSourceView({ source, maxBytes = 1024 * 1024 }) {
1391
1391
  return /* @__PURE__ */ jsx8("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 });
1392
1392
  }
1393
1393
 
1394
+ // src/viewers/svg-viewer.tsx
1395
+ import { useEffect as useEffect6, useState as useState8 } from "react";
1396
+
1394
1397
  // src/viewers/transparency-grid.ts
1395
1398
  var TRANSPARENCY_GRID_STYLE = {
1396
1399
  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%)",
@@ -1426,7 +1429,19 @@ function SvgViewer(props) {
1426
1429
  }
1427
1430
  function SvgRenderedView({ source, fileName }) {
1428
1431
  const fromClient = useMediaBlob(source.kind === "ref" ? source.ref : null);
1429
- const url = source.kind === "blob" ? source.url : fromClient.url;
1432
+ const [normalizedUrl, setNormalizedUrl] = useState8(null);
1433
+ useEffect6(() => {
1434
+ const blob = fromClient.blob;
1435
+ if (!blob || blob.type === "image/svg+xml") {
1436
+ setNormalizedUrl(null);
1437
+ return void 0;
1438
+ }
1439
+ const normalized = new Blob([blob], { type: "image/svg+xml" });
1440
+ const objectUrl = URL.createObjectURL(normalized);
1441
+ setNormalizedUrl(objectUrl);
1442
+ return () => URL.revokeObjectURL(objectUrl);
1443
+ }, [fromClient.blob]);
1444
+ const url = source.kind === "blob" ? source.url : normalizedUrl ?? fromClient.url;
1430
1445
  const loading = source.kind === "ref" && fromClient.loading;
1431
1446
  const error = source.kind === "ref" ? fromClient.error : null;
1432
1447
  if (error) {