@ai-matrx/media 0.4.0 → 0.4.1

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
@@ -1,5 +1,8 @@
1
1
  "use client";
2
2
 
3
+ // src/viewers/media-file-viewer.tsx
4
+ import { createElement as createElement3 } from "react";
5
+
3
6
  // src/viewers/registry.ts
4
7
  var VIEWER_SLOT = /* @__PURE__ */ Symbol.for("ai-matrx.media.viewer-registry");
5
8
  var HIGHLIGHTER_SLOT = /* @__PURE__ */ Symbol.for("ai-matrx.media.code-highlighter");
@@ -42,7 +45,7 @@ function getMediaCodeHighlighter() {
42
45
  }
43
46
 
44
47
  // src/viewers/code-viewer.tsx
45
- import { useMemo as useMemo2, useState as useState4 } from "react";
48
+ import { createElement as createElement2, useMemo as useMemo2, useState as useState4 } from "react";
46
49
 
47
50
  // src/react/cn.ts
48
51
  import { twMerge } from "tailwind-merge";
@@ -642,7 +645,7 @@ function useViewerDisplayUrl(source) {
642
645
  }
643
646
 
644
647
  // src/viewers/code-viewer.tsx
645
- import { Fragment, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
648
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
646
649
  var EXT_TO_LANGUAGE = {
647
650
  js: "javascript",
648
651
  jsx: "jsx",
@@ -752,7 +755,15 @@ function CodeViewer({
752
755
  /* @__PURE__ */ jsx3(ViewerCopyButton, { text })
753
756
  ] })
754
757
  ] }),
755
- /* @__PURE__ */ jsx3("div", { className: "min-h-0 flex-1 overflow-auto", children: highlighter ? /* @__PURE__ */ jsx3(Fragment, { children: highlighter({ code: text, language }) }) : /* @__PURE__ */ jsxs3("pre", { className: "m-0 flex p-3 font-mono text-xs leading-5", children: [
758
+ /* @__PURE__ */ jsx3("div", { className: "min-h-0 flex-1 overflow-auto", children: highlighter ? (
759
+ // Mounted as an element, never called — a real highlighter reads the
760
+ // host's theme with a hook, and calling it would put that hook in
761
+ // THIS component's list (see the note in media-file-viewer.tsx).
762
+ createElement2(
763
+ highlighter,
764
+ { code: text, language }
765
+ )
766
+ ) : /* @__PURE__ */ jsxs3("pre", { className: "m-0 flex p-3 font-mono text-xs leading-5", children: [
756
767
  /* @__PURE__ */ jsx3(
757
768
  "code",
758
769
  {
@@ -1683,7 +1694,7 @@ function getPreviewKind(fileName, mimeType) {
1683
1694
  }
1684
1695
 
1685
1696
  // src/viewers/media-file-viewer.tsx
1686
- import { Fragment as Fragment2, jsx as jsx12 } from "react/jsx-runtime";
1697
+ import { jsx as jsx12 } from "react/jsx-runtime";
1687
1698
  var BUILT_IN = {
1688
1699
  text: TextViewer,
1689
1700
  code: CodeViewer,
@@ -1696,10 +1707,8 @@ function MediaFileViewer({
1696
1707
  ...props
1697
1708
  }) {
1698
1709
  const kind = previewKind ?? getPreviewKind(props.fileName, props.mimeType ?? null);
1699
- const registered = getMediaViewer(kind);
1700
- if (registered) return /* @__PURE__ */ jsx12(Fragment2, { children: registered(props) });
1701
- const builtIn = BUILT_IN[kind];
1702
- if (builtIn) return /* @__PURE__ */ jsx12(Fragment2, { children: builtIn(props) });
1710
+ const viewer = getMediaViewer(kind) ?? BUILT_IN[kind];
1711
+ if (viewer) return createElement3(viewer, props);
1703
1712
  return /* @__PURE__ */ jsx12(MediaViewerUnavailable, { ...props, kind });
1704
1713
  }
1705
1714
  export {