@ai-matrx/rich-content 0.0.0 → 0.2.3

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 (248) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/LICENSE +1 -1
  3. package/README.md +58 -3
  4. package/dist/display/blocks/csv/CsvBlock.d.ts +10 -0
  5. package/dist/display/blocks/csv/CsvBlock.js +245 -0
  6. package/dist/display/blocks/table/parseMarkdownTable.d.ts +20 -0
  7. package/dist/display/blocks/table/parseMarkdownTable.js +35 -0
  8. package/dist/display/chat-markdown/citations/remarkMatrxCite.d.ts +33 -0
  9. package/dist/display/chat-markdown/citations/remarkMatrxCite.js +71 -0
  10. package/dist/display/chat-markdown/matrx-variables/remarkMatrxVariable.d.ts +29 -0
  11. package/dist/display/chat-markdown/matrx-variables/remarkMatrxVariable.js +71 -0
  12. package/dist/display/chat-markdown/page-break/remarkMatrxPageBreak.d.ts +55 -0
  13. package/dist/display/chat-markdown/page-break/remarkMatrxPageBreak.js +108 -0
  14. package/dist/display/chat-markdown/rehypeSafeRawHtml.d.ts +59 -0
  15. package/dist/display/chat-markdown/rehypeSafeRawHtml.js +140 -0
  16. package/dist/display/markdown-classification/processors/bock-processors/parse-markdown-table.d.ts +14 -0
  17. package/dist/display/markdown-classification/processors/bock-processors/parse-markdown-table.js +171 -0
  18. package/dist/display/markdown-classification/processors/types.d.ts +120 -0
  19. package/dist/display/markdown-classification/processors/types.js +10 -0
  20. package/dist/display/markdown-classification/processors/utils/client-blocks.d.ts +169 -0
  21. package/dist/display/markdown-classification/processors/utils/client-blocks.js +0 -0
  22. package/dist/display/markdown-classification/processors/utils/content-splitter-core.d.ts +223 -0
  23. package/dist/display/markdown-classification/processors/utils/content-splitter-core.js +1791 -0
  24. package/dist/display/markdown-classification/processors/utils/content-splitter-v2.d.ts +15 -0
  25. package/dist/display/markdown-classification/processors/utils/content-splitter-v2.js +19 -0
  26. package/dist/display/markdown-classification/processors/utils/expand-text-blocks.d.ts +9 -0
  27. package/dist/display/markdown-classification/processors/utils/expand-text-blocks.js +36 -0
  28. package/dist/display/markdown-classification/processors/utils/gfm-table-lines.d.ts +5 -0
  29. package/dist/display/markdown-classification/processors/utils/gfm-table-lines.js +40 -0
  30. package/dist/display/markdown-classification/processors/utils/gfm-table-vector-inputs.d.ts +16 -0
  31. package/dist/display/markdown-classification/processors/utils/gfm-table-vector-inputs.js +385 -0
  32. package/dist/display/markdown-classification/processors/utils/gfm-table-vectors.d.ts +43 -0
  33. package/dist/display/markdown-classification/processors/utils/gfm-table-vectors.js +33 -0
  34. package/dist/display/markdown-classification/processors/utils/table-data-parser.d.ts +9 -0
  35. package/dist/display/markdown-classification/processors/utils/table-data-parser.js +30 -0
  36. package/dist/display/markdown-classification/processors/utils/thinking-parser.d.ts +7 -0
  37. package/dist/display/markdown-classification/processors/utils/thinking-parser.js +70 -0
  38. package/dist/display/render-block.d.ts +23 -0
  39. package/dist/display/render-block.js +0 -0
  40. package/dist/display/themes.d.ts +1023 -0
  41. package/dist/display/themes.js +1105 -0
  42. package/dist/display/types.d.ts +32 -0
  43. package/dist/display/types.js +0 -0
  44. package/dist/host/ContentIrHostBoundary.d.ts +8 -0
  45. package/dist/host/ContentIrHostBoundary.js +15 -0
  46. package/dist/host/ErrorActions.d.ts +4 -0
  47. package/dist/host/ErrorActions.js +11 -0
  48. package/dist/host/NestedContent.d.ts +3 -0
  49. package/dist/host/NestedContent.js +12 -0
  50. package/dist/host/ResourcePeek.d.ts +6 -0
  51. package/dist/host/ResourcePeek.js +14 -0
  52. package/dist/host/component-registry.d.ts +2 -0
  53. package/dist/host/component-registry.js +25 -0
  54. package/dist/host/diagnostics.d.ts +2 -0
  55. package/dist/host/diagnostics.js +15 -0
  56. package/dist/host/index.d.ts +3 -0
  57. package/dist/host/index.js +18 -0
  58. package/dist/host/kind-incident.d.ts +3 -0
  59. package/dist/host/kind-incident.js +12 -0
  60. package/dist/host/kind-registry.d.ts +2 -0
  61. package/dist/host/kind-registry.js +35 -0
  62. package/dist/host/people.d.ts +3 -0
  63. package/dist/host/people.js +12 -0
  64. package/dist/host/registry.d.ts +27 -0
  65. package/dist/host/registry.js +55 -0
  66. package/dist/host/splitter-envelopes.d.ts +2 -0
  67. package/dist/host/splitter-envelopes.js +7 -0
  68. package/dist/host/tables.d.ts +6 -0
  69. package/dist/host/tables.js +8 -0
  70. package/dist/host/toast.d.ts +2 -0
  71. package/dist/host/toast.js +57 -0
  72. package/dist/host/types.d.ts +157 -0
  73. package/dist/host/types.js +0 -0
  74. package/dist/host/wikilinks.d.ts +15 -0
  75. package/dist/host/wikilinks.js +23 -0
  76. package/dist/kinds/host/route-env.d.ts +33 -0
  77. package/dist/kinds/host/route-env.js +16 -0
  78. package/dist/kinds/react/KindEscapedNotice.d.ts +14 -0
  79. package/dist/kinds/react/KindEscapedNotice.js +72 -0
  80. package/dist/kinds/react/ProvisionalKindBoundary.d.ts +19 -0
  81. package/dist/kinds/react/ProvisionalKindBoundary.js +17 -0
  82. package/dist/kinds/react/ensure-kind-renderable.d.ts +14 -0
  83. package/dist/kinds/react/ensure-kind-renderable.js +45 -0
  84. package/dist/kinds/react/kind-problems.d.ts +62 -0
  85. package/dist/kinds/react/kind-problems.js +134 -0
  86. package/dist/kinds/react/kind-route.d.ts +23 -0
  87. package/dist/kinds/react/kind-route.js +24 -0
  88. package/dist/kinds/react/loading/infer-loading-slug.d.ts +58 -0
  89. package/dist/kinds/react/loading/infer-loading-slug.js +100 -0
  90. package/dist/kinds/react/loading/kind-loading-components.d.ts +48 -0
  91. package/dist/kinds/react/loading/kind-loading-components.js +447 -0
  92. package/dist/kinds/react/loading/kind-loading-registry.d.ts +21 -0
  93. package/dist/kinds/react/loading/kind-loading-registry.js +62 -0
  94. package/dist/kinds/react/loading/kind-loading-slugs.d.ts +18 -0
  95. package/dist/kinds/react/loading/kind-loading-slugs.js +34 -0
  96. package/dist/kinds/react/loading/kind-loading.types.d.ts +79 -0
  97. package/dist/kinds/react/loading/kind-loading.types.js +31 -0
  98. package/dist/kinds/react/loading/resolve-loading-slug.d.ts +29 -0
  99. package/dist/kinds/react/loading/resolve-loading-slug.js +51 -0
  100. package/dist/kinds/react/partial-kind-route.d.ts +32 -0
  101. package/dist/kinds/react/partial-kind-route.js +27 -0
  102. package/dist/kinds/react/registry-versioned.d.ts +54 -0
  103. package/dist/kinds/react/registry-versioned.js +18 -0
  104. package/dist/kinds/react/route-at-version.d.ts +38 -0
  105. package/dist/kinds/react/route-at-version.js +78 -0
  106. package/dist/kinds/react/slot/KindSlot.d.ts +87 -0
  107. package/dist/kinds/react/slot/KindSlot.js +65 -0
  108. package/dist/kinds/react/use-registry-repaint.d.ts +6 -0
  109. package/dist/kinds/react/use-registry-repaint.js +36 -0
  110. package/dist/kinds/react/useIrNode.d.ts +9 -0
  111. package/dist/kinds/react/useIrNode.js +46 -0
  112. package/dist/kinds/react/useLiveJsonRegion.d.ts +15 -0
  113. package/dist/kinds/react/useLiveJsonRegion.js +84 -0
  114. package/dist/kinds/redux/render-block-envelope.d.ts +14 -0
  115. package/dist/kinds/redux/render-block-envelope.js +26 -0
  116. package/dist/kinds/registry/kind-correctors.d.ts +63 -0
  117. package/dist/kinds/registry/kind-correctors.js +94 -0
  118. package/dist/kinds/registry/legacy-quiz-envelope.d.ts +1 -0
  119. package/dist/kinds/registry/legacy-quiz-envelope.js +1 -0
  120. package/dist/kinds/registry/region-envelope-memo.d.ts +45 -0
  121. package/dist/kinds/registry/region-envelope-memo.js +94 -0
  122. package/dist/kinds/registry/registry-debug.d.ts +38 -0
  123. package/dist/kinds/registry/registry-debug.js +39 -0
  124. package/dist/markdown-core/MarkdownCore.d.ts +6 -0
  125. package/dist/markdown-core/MarkdownCore.js +32 -0
  126. package/dist/markdown-core/MarkdownCoreImpl.d.ts +3 -0
  127. package/dist/markdown-core/MarkdownCoreImpl.js +27 -0
  128. package/dist/markdown-core/MarkdownCoreServer.d.ts +4 -0
  129. package/dist/markdown-core/MarkdownCoreServer.js +26 -0
  130. package/dist/markdown-core/heading-anchors-context.d.ts +2 -0
  131. package/dist/markdown-core/heading-anchors-context.js +11 -0
  132. package/dist/markdown-core/heading-anchors-props.d.ts +2 -0
  133. package/dist/markdown-core/heading-anchors-props.js +6 -0
  134. package/dist/markdown-core/markdown-core-html.d.ts +3 -0
  135. package/dist/markdown-core/markdown-core-html.js +33 -0
  136. package/dist/markdown-core/markdown-core-presets.d.ts +22 -0
  137. package/dist/markdown-core/markdown-core-presets.js +118 -0
  138. package/dist/markdown-core/markdown-core-types.d.ts +43 -0
  139. package/dist/markdown-core/markdown-core-types.js +0 -0
  140. package/dist/markdown-core/math/vendor/micromark-math-math-flow.d.ts +15 -0
  141. package/dist/markdown-core/math/vendor/micromark-math-math-flow.js +143 -0
  142. package/dist/markdown-core/math/vendor/micromark-math-math-text.d.ts +24 -0
  143. package/dist/markdown-core/math/vendor/micromark-math-math-text.js +127 -0
  144. package/dist/markdown-core/math/vendor/micromark-math-syntax.d.ts +30 -0
  145. package/dist/markdown-core/math/vendor/micromark-math-syntax.js +15 -0
  146. package/dist/markdown-core/math/vendor/rehype-katex.d.ts +15 -0
  147. package/dist/markdown-core/math/vendor/rehype-katex.js +83 -0
  148. package/dist/markdown-core/math/vendor/remark-math.d.ts +9 -0
  149. package/dist/markdown-core/math/vendor/remark-math.js +20 -0
  150. package/dist/markdown-core/math-normalizer.d.ts +57 -0
  151. package/dist/markdown-core/math-normalizer.js +315 -0
  152. package/dist/markdown-core/plain-title.d.ts +2 -0
  153. package/dist/markdown-core/plain-title.js +1 -0
  154. package/dist/markdown-core/stream-heal.d.ts +2 -0
  155. package/dist/markdown-core/stream-heal.js +184 -0
  156. package/dist/markdown-core/streaming-context.d.ts +2 -0
  157. package/dist/markdown-core/streaming-context.js +11 -0
  158. package/dist/markdown-core/syntax/callout-types.d.ts +9 -0
  159. package/dist/markdown-core/syntax/callout-types.js +101 -0
  160. package/dist/markdown-core/syntax/containers.d.ts +17 -0
  161. package/dist/markdown-core/syntax/containers.js +353 -0
  162. package/dist/markdown-core/syntax/document-numbering.d.ts +52 -0
  163. package/dist/markdown-core/syntax/document-numbering.js +184 -0
  164. package/dist/markdown-core/syntax/elements/CalloutIcon.d.ts +3 -0
  165. package/dist/markdown-core/syntax/elements/CalloutIcon.js +41 -0
  166. package/dist/markdown-core/syntax/elements/CrossRef.d.ts +12 -0
  167. package/dist/markdown-core/syntax/elements/CrossRef.js +57 -0
  168. package/dist/markdown-core/syntax/elements/CsvFence.d.ts +4 -0
  169. package/dist/markdown-core/syntax/elements/CsvFence.js +18 -0
  170. package/dist/markdown-core/syntax/elements/DetailsElements.d.ts +12 -0
  171. package/dist/markdown-core/syntax/elements/DetailsElements.js +38 -0
  172. package/dist/markdown-core/syntax/elements/DocumentNumbering.d.ts +20 -0
  173. package/dist/markdown-core/syntax/elements/DocumentNumbering.js +37 -0
  174. package/dist/markdown-core/syntax/elements/DocumentPropertiesPanel.d.ts +4 -0
  175. package/dist/markdown-core/syntax/elements/DocumentPropertiesPanel.js +46 -0
  176. package/dist/markdown-core/syntax/elements/InDocAnchor.d.ts +11 -0
  177. package/dist/markdown-core/syntax/elements/InDocAnchor.js +87 -0
  178. package/dist/markdown-core/syntax/elements/MarkdownSourceEdit.d.ts +24 -0
  179. package/dist/markdown-core/syntax/elements/MarkdownSourceEdit.js +28 -0
  180. package/dist/markdown-core/syntax/elements/MatrxTabs.d.ts +10 -0
  181. package/dist/markdown-core/syntax/elements/MatrxTabs.js +59 -0
  182. package/dist/markdown-core/syntax/elements/MentionChip.d.ts +7 -0
  183. package/dist/markdown-core/syntax/elements/MentionChip.js +69 -0
  184. package/dist/markdown-core/syntax/elements/NestedBody.d.ts +3 -0
  185. package/dist/markdown-core/syntax/elements/NestedBody.js +13 -0
  186. package/dist/markdown-core/syntax/elements/TableOfContents.d.ts +5 -0
  187. package/dist/markdown-core/syntax/elements/TableOfContents.js +44 -0
  188. package/dist/markdown-core/syntax/elements/TaskCheckbox.d.ts +7 -0
  189. package/dist/markdown-core/syntax/elements/TaskCheckbox.js +63 -0
  190. package/dist/markdown-core/syntax/elements/WikiEmbed.d.ts +7 -0
  191. package/dist/markdown-core/syntax/elements/WikiEmbed.js +68 -0
  192. package/dist/markdown-core/syntax/elements/WikiLink.d.ts +10 -0
  193. package/dist/markdown-core/syntax/elements/WikiLink.js +114 -0
  194. package/dist/markdown-core/syntax/elements/core-syntax-elements.d.ts +22 -0
  195. package/dist/markdown-core/syntax/elements/core-syntax-elements.js +70 -0
  196. package/dist/markdown-core/syntax/elements/find-in-document.d.ts +3 -0
  197. package/dist/markdown-core/syntax/elements/find-in-document.js +20 -0
  198. package/dist/markdown-core/syntax/elements/wiki-target.d.ts +5 -0
  199. package/dist/markdown-core/syntax/elements/wiki-target.js +8 -0
  200. package/dist/markdown-core/syntax/frontmatter.d.ts +26 -0
  201. package/dist/markdown-core/syntax/frontmatter.js +72 -0
  202. package/dist/markdown-core/syntax/gfm-cell-pipes.d.ts +11 -0
  203. package/dist/markdown-core/syntax/gfm-cell-pipes.js +4 -0
  204. package/dist/markdown-core/syntax/inline-syntax.d.ts +26 -0
  205. package/dist/markdown-core/syntax/inline-syntax.js +163 -0
  206. package/dist/markdown-core/syntax/linear-scan.d.ts +46 -0
  207. package/dist/markdown-core/syntax/linear-scan.js +129 -0
  208. package/dist/markdown-core/syntax/mdast-helpers.d.ts +48 -0
  209. package/dist/markdown-core/syntax/mdast-helpers.js +48 -0
  210. package/dist/markdown-core/syntax/mentions.d.ts +2 -0
  211. package/dist/markdown-core/syntax/mentions.js +42 -0
  212. package/dist/markdown-core/syntax/names.d.ts +6 -0
  213. package/dist/markdown-core/syntax/names.js +18 -0
  214. package/dist/markdown-core/syntax/prepare-syntax-source.d.ts +1 -0
  215. package/dist/markdown-core/syntax/prepare-syntax-source.js +78 -0
  216. package/dist/markdown-core/syntax/rehype-matrx-syntax.d.ts +9 -0
  217. package/dist/markdown-core/syntax/rehype-matrx-syntax.js +180 -0
  218. package/dist/markdown-core/syntax/remark-inline-only.d.ts +23 -0
  219. package/dist/markdown-core/syntax/remark-inline-only.js +25 -0
  220. package/dist/markdown-core/syntax/remark-matrx-syntax.d.ts +7 -0
  221. package/dist/markdown-core/syntax/remark-matrx-syntax.js +351 -0
  222. package/dist/markdown-core/syntax/remark-table-code-pipes.d.ts +7 -0
  223. package/dist/markdown-core/syntax/remark-table-code-pipes.js +23 -0
  224. package/dist/markdown-core/syntax/stream-heal-syntax.d.ts +2 -0
  225. package/dist/markdown-core/syntax/stream-heal-syntax.js +108 -0
  226. package/dist/markdown-core/syntax/task-source.d.ts +10 -0
  227. package/dist/markdown-core/syntax/task-source.js +34 -0
  228. package/dist/markdown-core/syntax/useDocumentProperties.d.ts +3 -0
  229. package/dist/markdown-core/syntax/useDocumentProperties.js +8 -0
  230. package/dist/math-vendor-LICENSE-NOTICE.md +18 -0
  231. package/dist/styles.css +0 -0
  232. package/dist/utils/addressWithoutNavigating.d.ts +68 -0
  233. package/dist/utils/addressWithoutNavigating.js +60 -0
  234. package/dist/utils/client-lazy.d.ts +13 -0
  235. package/dist/utils/client-lazy.js +24 -0
  236. package/dist/utils/decision-options.d.ts +21 -0
  237. package/dist/utils/decision-options.js +32 -0
  238. package/dist/utils/gfm-lexer.d.ts +5 -0
  239. package/dist/utils/gfm-lexer.js +10 -0
  240. package/dist/utils/json.d.ts +63 -0
  241. package/dist/utils/json.js +22 -0
  242. package/dist/utils/plain-title.d.ts +25 -0
  243. package/dist/utils/plain-title.js +51 -0
  244. package/dist/utils/table-source.d.ts +62 -0
  245. package/dist/utils/table-source.js +191 -0
  246. package/dist/utils/youtube.d.ts +52 -0
  247. package/dist/utils/youtube.js +137 -0
  248. package/package.json +132 -5
@@ -0,0 +1,32 @@
1
+ import { DisplayTheme } from "./themes.js";
2
+ export interface MarkdownTableData {
3
+ headers: string[];
4
+ rows: string[][];
5
+ originalContent?: string;
6
+ }
7
+ export interface MarkdownTableProps {
8
+ data: MarkdownTableData;
9
+ className?: string;
10
+ fontSize?: number;
11
+ theme?: DisplayTheme;
12
+ onSave?: (data: MarkdownTableData) => void;
13
+ }
14
+ export interface SectionItem {
15
+ name: string;
16
+ }
17
+ export interface MarkdownTable {
18
+ title: string;
19
+ data: MarkdownTableData;
20
+ }
21
+ export interface Section {
22
+ title: string;
23
+ intro: string;
24
+ items: SectionItem[];
25
+ tables: MarkdownTable[];
26
+ outro: string;
27
+ }
28
+ export interface ParsedContent {
29
+ intro: string;
30
+ sections: Section[];
31
+ outro: string;
32
+ }
File without changes
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The content-IR render host for content-ir-react, from `configureRichContent({ contentIrHost })`.
3
+ * A bare host renders children without a host provider (announced).
4
+ */
5
+ import type { ReactNode } from "react";
6
+ export declare function ContentIrHostBoundary({ children }: {
7
+ children: ReactNode;
8
+ }): import("react").JSX.Element;
@@ -0,0 +1,15 @@
1
+ "use client";
2
+ import { Fragment, jsx } from "react/jsx-runtime";
3
+ import { ContentIrRenderProvider } from "@ai-matrx/content-ir-react";
4
+ import { announceBareHost, hostCapability } from "./registry.js";
5
+ function ContentIrHostBoundary({ children }) {
6
+ const host = hostCapability("contentIrHost");
7
+ if (!host) {
8
+ announceBareHost("contentIrHost", "kinds render without the host's render seams");
9
+ return /* @__PURE__ */ jsx(Fragment, { children });
10
+ }
11
+ return /* @__PURE__ */ jsx(ContentIrRenderProvider, { host, children });
12
+ }
13
+ export {
14
+ ContentIrHostBoundary
15
+ };
@@ -0,0 +1,4 @@
1
+ export declare function ErrorAlchemyMenu({ error }: {
2
+ error: unknown;
3
+ }): import("react").JSX.Element | null;
4
+ export { ErrorAlchemyMenu as ErrorActions };
@@ -0,0 +1,11 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { hostCapability } from "./registry.js";
4
+ function ErrorAlchemyMenu({ error }) {
5
+ const Actions = hostCapability("ErrorActions");
6
+ return Actions ? /* @__PURE__ */ jsx(Actions, { error }) : null;
7
+ }
8
+ export {
9
+ ErrorAlchemyMenu as ErrorActions,
10
+ ErrorAlchemyMenu
11
+ };
@@ -0,0 +1,3 @@
1
+ export declare function NestedRichContent({ source }: {
2
+ source: string;
3
+ }): import("react").JSX.Element;
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { announceBareHost, BARE_HOST_ATTR, hostCapability } from "./registry.js";
4
+ function NestedRichContent({ source }) {
5
+ const Nested = hostCapability("NestedContent");
6
+ if (Nested) return /* @__PURE__ */ jsx(Nested, { source });
7
+ announceBareHost("NestedContent", "nested content shows as plain text");
8
+ return /* @__PURE__ */ jsx("div", { ...BARE_HOST_ATTR, className: "whitespace-pre-wrap", children: source });
9
+ }
10
+ export {
11
+ NestedRichContent
12
+ };
@@ -0,0 +1,6 @@
1
+ export declare function ResourcePeekHost(props: {
2
+ kind: string;
3
+ id: string;
4
+ onClose: () => void;
5
+ }): import("react").JSX.Element | null;
6
+ export declare function hasResourcePeek(): boolean;
@@ -0,0 +1,14 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { hostCapability } from "./registry.js";
4
+ function ResourcePeekHost(props) {
5
+ const Peek = hostCapability("ResourcePeek");
6
+ return Peek ? /* @__PURE__ */ jsx(Peek, { ...props }) : null;
7
+ }
8
+ function hasResourcePeek() {
9
+ return Boolean(hostCapability("ResourcePeek"));
10
+ }
11
+ export {
12
+ ResourcePeekHost,
13
+ hasResourcePeek
14
+ };
@@ -0,0 +1,2 @@
1
+ import type { RichContentComponentRegistry } from "./types.js";
2
+ export declare const componentRegistry: RichContentComponentRegistry;
@@ -0,0 +1,25 @@
1
+ import { ComponentResolver } from "@ai-matrx/content-ir-react";
2
+ import { announceBareHost, hostCapability } from "./registry.js";
3
+ const EMPTY_KEY = /* @__PURE__ */ Symbol.for("ai-matrx.rich-content.empty-component-resolver");
4
+ function empty() {
5
+ const g = globalThis;
6
+ return g[EMPTY_KEY] ??= Object.assign(new ComponentResolver({}), {
7
+ wasRefused: () => false,
8
+ debugSnapshot: () => ({ host: "bare" })
9
+ });
10
+ }
11
+ function current() {
12
+ const r = hostCapability("componentRegistry");
13
+ if (!r) announceBareHost("componentRegistry", "no kind components resolve beyond the compiled floor");
14
+ return r ?? empty();
15
+ }
16
+ const componentRegistry = new Proxy({}, {
17
+ get(_t, key) {
18
+ const r = current();
19
+ const v = r[key];
20
+ return typeof v === "function" ? v.bind(r) : v;
21
+ }
22
+ });
23
+ export {
24
+ componentRegistry
25
+ };
@@ -0,0 +1,2 @@
1
+ import type { RichContentErrorReport } from "./types.js";
2
+ export declare function captureError(report: RichContentErrorReport): void;
@@ -0,0 +1,15 @@
1
+ import { hostCapability } from "./registry.js";
2
+ function captureError(report) {
3
+ const sink = hostCapability("captureError");
4
+ if (sink) {
5
+ try {
6
+ sink(report);
7
+ return;
8
+ } catch {
9
+ }
10
+ }
11
+ console.error(`[rich-content:${report.source}] ${report.message}`, report);
12
+ }
13
+ export {
14
+ captureError
15
+ };
@@ -0,0 +1,3 @@
1
+ /** `@ai-matrx/rich-content/host` — configure the engine once at the app root. */
2
+ export { configureRichContent, resetRichContentHost, hostCapability, subscribeRichContentHost, richContentHostVersion, announceBareHost, BARE_HOST_ATTR, } from "./registry.js";
3
+ export type { RichContentHost, RichContentToast, RichContentErrorReport, RichContentWikilinks, RichContentPerson, RichContentSplitterEnvelopes, WikiResolution, } from "./types.js";
@@ -0,0 +1,18 @@
1
+ import {
2
+ configureRichContent,
3
+ resetRichContentHost,
4
+ hostCapability,
5
+ subscribeRichContentHost,
6
+ richContentHostVersion,
7
+ announceBareHost,
8
+ BARE_HOST_ATTR
9
+ } from "./registry.js";
10
+ export {
11
+ BARE_HOST_ATTR,
12
+ announceBareHost,
13
+ configureRichContent,
14
+ hostCapability,
15
+ resetRichContentHost,
16
+ richContentHostVersion,
17
+ subscribeRichContentHost
18
+ };
@@ -0,0 +1,3 @@
1
+ import type { RichContentKindIncident } from "./types.js";
2
+ export type KindComponentIncidentInput = RichContentKindIncident;
3
+ export declare function reportKindComponentIncident(input: RichContentKindIncident): void;
@@ -0,0 +1,12 @@
1
+ import { hostCapability } from "./registry.js";
2
+ function reportKindComponentIncident(input) {
3
+ const report = hostCapability("reportKindComponentIncident");
4
+ if (report) {
5
+ report(input);
6
+ return;
7
+ }
8
+ console.warn(`[rich-content] kind component incident (${input.errorType}) for "${input.kind}": ${input.message}`);
9
+ }
10
+ export {
11
+ reportKindComponentIncident
12
+ };
@@ -0,0 +1,2 @@
1
+ import type { RichContentKindRegistry } from "./types.js";
2
+ export declare const kindRegistry: RichContentKindRegistry;
@@ -0,0 +1,35 @@
1
+ import { announceBareHost, hostCapability } from "./registry.js";
2
+ const noop = () => {
3
+ };
4
+ const EMPTY = {
5
+ getDefinition: () => void 0,
6
+ getSchema: () => void 0,
7
+ getEmittedJsonSchema: () => void 0,
8
+ getDeclaredLoadingComponent: () => null,
9
+ isKnownKind: () => false,
10
+ isRenderableKind: () => false,
11
+ listDefinitions: () => [],
12
+ getKindVersion: () => 0,
13
+ subscribeKind: () => noop,
14
+ getVersion: () => 0,
15
+ subscribeVersion: () => noop,
16
+ ensureWarm: () => Promise.resolve(),
17
+ requestSchema: noop,
18
+ onSchemaArrived: () => noop,
19
+ resolver: () => ({ get: () => void 0 })
20
+ };
21
+ function current() {
22
+ const r = hostCapability("kindRegistry");
23
+ if (!r) announceBareHost("kindRegistry", "no kinds are known (kind JSON renders through the generic structured floor)");
24
+ return r ?? EMPTY;
25
+ }
26
+ const kindRegistry = new Proxy({}, {
27
+ get(_t, key) {
28
+ const r = current();
29
+ const v = r[key];
30
+ return typeof v === "function" ? v.bind(r) : v;
31
+ }
32
+ });
33
+ export {
34
+ kindRegistry
35
+ };
@@ -0,0 +1,3 @@
1
+ import type { RichContentPerson } from "./types.js";
2
+ export declare function resolveVisiblePerson(id: string): Promise<RichContentPerson | null>;
3
+ export type VisiblePerson = RichContentPerson;
@@ -0,0 +1,12 @@
1
+ import { announceBareHost, hostCapability } from "./registry.js";
2
+ async function resolveVisiblePerson(id) {
3
+ const resolve = hostCapability("resolvePerson");
4
+ if (!resolve) {
5
+ announceBareHost("resolvePerson", "@mentions stay unresolved");
6
+ return null;
7
+ }
8
+ return resolve(id);
9
+ }
10
+ export {
11
+ resolveVisiblePerson
12
+ };
@@ -0,0 +1,27 @@
1
+ /**
2
+ * THE HOST of @ai-matrx/rich-content — one object, configured once at the app root.
3
+ *
4
+ * The engine renders without any host: every capability below has an honest default that
5
+ * announces itself (a console line once per capability, and `data-rich-content-host="bare"`
6
+ * on the elements it degrades). A host fills in only what it has — identity, sinks,
7
+ * navigation, its own windows and records.
8
+ *
9
+ * State lives on `globalThis` under a `Symbol.for` key: a dual-loader graph (Next.js server +
10
+ * client, Jest module registries) splits module state, and a second empty host would silently
11
+ * downgrade every surface it rendered.
12
+ */
13
+ import type { RichContentHost } from "./types.js";
14
+ /** Register (or extend) the host. Later calls merge over earlier ones, capability by capability. */
15
+ export declare function configureRichContent(partial: Partial<RichContentHost>): void;
16
+ /** Test seam: forget every registration. */
17
+ export declare function resetRichContentHost(): void;
18
+ /** The registered capability, or undefined (callers apply their own documented default). */
19
+ export declare function hostCapability<K extends keyof RichContentHost>(key: K): RichContentHost[K] | undefined;
20
+ export declare function subscribeRichContentHost(listener: () => void): () => void;
21
+ export declare function richContentHostVersion(): number;
22
+ /** Announce ONCE that a capability fell back to its default (never silently). */
23
+ export declare function announceBareHost(capability: string, degraded: string): void;
24
+ /** The DOM marker every degraded element carries. */
25
+ export declare const BARE_HOST_ATTR: {
26
+ readonly "data-rich-content-host": "bare";
27
+ };
@@ -0,0 +1,55 @@
1
+ const HOST_KEY = /* @__PURE__ */ Symbol.for("ai-matrx.rich-content.host");
2
+ const ANNOUNCED_KEY = /* @__PURE__ */ Symbol.for("ai-matrx.rich-content.host.announced");
3
+ function store() {
4
+ const g = globalThis;
5
+ let s = g[HOST_KEY];
6
+ if (!s) {
7
+ s = { host: {}, version: 0, listeners: /* @__PURE__ */ new Set() };
8
+ g[HOST_KEY] = s;
9
+ }
10
+ return s;
11
+ }
12
+ function configureRichContent(partial) {
13
+ const s = store();
14
+ s.host = { ...s.host, ...partial };
15
+ s.version += 1;
16
+ for (const l of s.listeners) l();
17
+ }
18
+ function resetRichContentHost() {
19
+ const s = store();
20
+ s.host = {};
21
+ s.version += 1;
22
+ for (const l of s.listeners) l();
23
+ }
24
+ function hostCapability(key) {
25
+ return store().host[key];
26
+ }
27
+ function subscribeRichContentHost(listener) {
28
+ const s = store();
29
+ s.listeners.add(listener);
30
+ return () => s.listeners.delete(listener);
31
+ }
32
+ function richContentHostVersion() {
33
+ return store().version;
34
+ }
35
+ function announceBareHost(capability, degraded) {
36
+ const g = globalThis;
37
+ let seen = g[ANNOUNCED_KEY];
38
+ if (!seen) {
39
+ seen = /* @__PURE__ */ new Set();
40
+ g[ANNOUNCED_KEY] = seen;
41
+ }
42
+ if (seen.has(capability)) return;
43
+ seen.add(capability);
44
+ console.warn(`[@ai-matrx/rich-content] The host registered no "${capability}", so ${degraded}.`);
45
+ }
46
+ const BARE_HOST_ATTR = { "data-rich-content-host": "bare" };
47
+ export {
48
+ BARE_HOST_ATTR,
49
+ announceBareHost,
50
+ configureRichContent,
51
+ hostCapability,
52
+ resetRichContentHost,
53
+ richContentHostVersion,
54
+ subscribeRichContentHost
55
+ };
@@ -0,0 +1,2 @@
1
+ import type { RichContentSplitterEnvelopes } from "./types.js";
2
+ export declare function hostSplitterEnvelopes(): RichContentSplitterEnvelopes | undefined;
@@ -0,0 +1,7 @@
1
+ import { hostCapability } from "./registry.js";
2
+ function hostSplitterEnvelopes() {
3
+ return hostCapability("splitterEnvelopes");
4
+ }
5
+ export {
6
+ hostSplitterEnvelopes
7
+ };
@@ -0,0 +1,6 @@
1
+ export declare function useOpenSaveToTable(): ((options: {
2
+ grid: {
3
+ headers: string[];
4
+ rows: string[][];
5
+ };
6
+ }) => unknown) | null;
@@ -0,0 +1,8 @@
1
+ import { hostCapability } from "./registry.js";
2
+ const none = () => null;
3
+ function useOpenSaveToTable() {
4
+ return (hostCapability("useOpenSaveToTable") ?? none)();
5
+ }
6
+ export {
7
+ useOpenSaveToTable
8
+ };
@@ -0,0 +1,2 @@
1
+ import type { RichContentToast } from "./types.js";
2
+ export declare const toast: RichContentToast;
@@ -0,0 +1,57 @@
1
+ import { announceBareHost, hostCapability } from "./registry.js";
2
+ function text(message) {
3
+ return typeof message === "string" ? message : typeof message === "function" ? "[toast]" : String(message);
4
+ }
5
+ const consoleToast = Object.assign(
6
+ (message) => {
7
+ announceBareHost("toast", "notices go to the console");
8
+ console.info(`[rich-content] ${text(message)}`);
9
+ return Date.now();
10
+ },
11
+ {
12
+ success: (m) => {
13
+ announceBareHost("toast", "notices go to the console");
14
+ console.info(`[rich-content] \u2713 ${text(m)}`);
15
+ return Date.now();
16
+ },
17
+ error: (m) => {
18
+ announceBareHost("toast", "notices go to the console");
19
+ console.error(`[rich-content] ${text(m)}`);
20
+ return Date.now();
21
+ },
22
+ info: (m) => {
23
+ announceBareHost("toast", "notices go to the console");
24
+ console.info(`[rich-content] ${text(m)}`);
25
+ return Date.now();
26
+ },
27
+ warning: (m) => {
28
+ announceBareHost("toast", "notices go to the console");
29
+ console.warn(`[rich-content] ${text(m)}`);
30
+ return Date.now();
31
+ },
32
+ loading: (m) => {
33
+ announceBareHost("toast", "notices go to the console");
34
+ console.info(`[rich-content] \u2026 ${text(m)}`);
35
+ return Date.now();
36
+ },
37
+ dismiss: () => {
38
+ }
39
+ }
40
+ );
41
+ function current() {
42
+ return hostCapability("toast") ?? consoleToast;
43
+ }
44
+ const toast = Object.assign(
45
+ ((message, data) => current()(message, data)),
46
+ {
47
+ success: ((m, d) => current().success(m, d)),
48
+ error: ((m, d) => current().error(m, d)),
49
+ info: ((m, d) => current().info(m, d)),
50
+ warning: ((m, d) => current().warning(m, d)),
51
+ loading: ((m, d) => current().loading(m, d)),
52
+ dismiss: ((id) => current().dismiss(id))
53
+ }
54
+ );
55
+ export {
56
+ toast
57
+ };
@@ -0,0 +1,157 @@
1
+ /**
2
+ * Every capability the engine may ask of its host. All optional: each has a documented default
3
+ * in the module that reads it. Add a capability here, never an import of the app.
4
+ */
5
+ import type { ComponentType, ReactNode } from "react";
6
+ import type { KindDefinition, KindSchema } from "@ai-matrx/content-ir";
7
+ import type { ComponentResolver, ContentIrHost } from "@ai-matrx/content-ir-react";
8
+ /** The host's kind registry (matrx-frontend: features/content-ir/registry/kind-registry `kindRegistry`). */
9
+ export interface RichContentKindRegistry {
10
+ getDefinition(kind: string): KindDefinition | undefined;
11
+ getSchema(kind: string): KindSchema | undefined;
12
+ getEmittedJsonSchema(kind: string): unknown;
13
+ getDeclaredLoadingComponent(kind: string): string | null;
14
+ isKnownKind(kind: string): boolean;
15
+ isRenderableKind(kind: string): boolean;
16
+ listDefinitions(): KindDefinition[];
17
+ getKindVersion(kind: string): number;
18
+ subscribeKind(kind: string, listener: () => void): () => void;
19
+ getVersion(): number;
20
+ subscribeVersion(listener: () => void): () => void;
21
+ ensureWarm(): Promise<void>;
22
+ requestSchema(kind: string): void;
23
+ onSchemaArrived(listener: (kind: string, schema: KindSchema | null) => void): () => void;
24
+ resolver(): {
25
+ get(kind: string): KindSchema | undefined;
26
+ request?(kind: string): void;
27
+ };
28
+ }
29
+ /** The host's component registry: content-ir-react's resolver plus its refusal + debug reads. */
30
+ export type RichContentComponentRegistry = ComponentResolver & {
31
+ wasRefused(kind: string): boolean;
32
+ debugSnapshot(kind: string | null): Record<string, unknown>;
33
+ };
34
+ /** One kind-component render incident (matrx-frontend files it to `log_kind_component_incident`). */
35
+ export interface RichContentKindIncident {
36
+ kind: string;
37
+ errorType: string;
38
+ message: string;
39
+ platform?: string;
40
+ role?: string;
41
+ componentKey?: string | null;
42
+ componentUpdatedAt?: string | null;
43
+ stack?: string | null;
44
+ data?: unknown;
45
+ }
46
+ /** The structural toast the host passes in (matrx-frontend: `lib/toast` `toast`). */
47
+ export interface RichContentToast {
48
+ (message: ReactNode, data?: Record<string, unknown>): string | number;
49
+ success(message: ReactNode, data?: Record<string, unknown>): string | number;
50
+ error(message: ReactNode, data?: Record<string, unknown>): string | number;
51
+ info(message: ReactNode, data?: Record<string, unknown>): string | number;
52
+ warning(message: ReactNode, data?: Record<string, unknown>): string | number;
53
+ loading(message: ReactNode, data?: Record<string, unknown>): string | number;
54
+ dismiss(id?: string | number): void;
55
+ }
56
+ /** An error report (shape of matrx-frontend's Error Inspector `captureError` input). */
57
+ export interface RichContentErrorReport {
58
+ source: string;
59
+ message: string;
60
+ [field: string]: unknown;
61
+ }
62
+ /** A wikilink target resolved against the host's records. */
63
+ export type WikiResolution = {
64
+ status: "found";
65
+ token: string;
66
+ id: string;
67
+ title: string;
68
+ href: string | null;
69
+ typeLabel: string;
70
+ } | {
71
+ status: "missing";
72
+ title: string;
73
+ } | {
74
+ status: "unavailable";
75
+ title: string;
76
+ message: string;
77
+ };
78
+ /** The host's records behind `[[wikilinks]]` and `![[embeds]]`. */
79
+ export interface RichContentWikilinks {
80
+ resolve(target: string): Promise<WikiResolution>;
81
+ /** Create the missing page named `title` in the host's active organization. */
82
+ create(title: string): Promise<{
83
+ ok: true;
84
+ href: string | null;
85
+ } | {
86
+ ok: false;
87
+ error: string;
88
+ }>;
89
+ /** The markdown body of a found record, for an embed on its own line. */
90
+ loadBody(token: string, id: string): Promise<{
91
+ body: string;
92
+ } | {
93
+ error: string;
94
+ }>;
95
+ }
96
+ /** A person visible to the viewer, for an `@mention`. */
97
+ export interface RichContentPerson {
98
+ userId: string;
99
+ name: string;
100
+ role?: string | null;
101
+ [field: string]: unknown;
102
+ }
103
+ /** The splitter's content-IR envelope hooks (matrx-frontend binds its kind registry). */
104
+ export interface RichContentSplitterEnvelopes {
105
+ withIrEnvelope(source: string, metadata: Record<string, unknown> | undefined): Record<string, unknown> | undefined;
106
+ fenceRegion(language: string, regionText: string): unknown;
107
+ xmlRegion(tag: string, regionText: string): unknown;
108
+ }
109
+ export interface RichContentHost {
110
+ /** User-visible notices. Default: the console (announced). */
111
+ toast: RichContentToast;
112
+ /** The Error Inspector sink. Default: `console.error`. */
113
+ captureError: (report: RichContentErrorReport) => void;
114
+ /** An error notice with the host's error actions. Default: the message in a bordered box. */
115
+ ErrorNotice: ComponentType<{
116
+ error: unknown;
117
+ title?: string;
118
+ className?: string;
119
+ children?: ReactNode;
120
+ [prop: string]: unknown;
121
+ }>;
122
+ /** Extra actions beside an error message (matrx-frontend: the Alchemy error menu). Default: none — the message itself always shows. */
123
+ ErrorActions: ComponentType<{
124
+ error: unknown;
125
+ }>;
126
+ /** Renders nested markdown at the `standard` level, one depth deeper. Default: the source as plain text. */
127
+ NestedContent: ComponentType<{
128
+ source: string;
129
+ }>;
130
+ /** `[[wikilinks]]` against the host's records. Default: every link reads "unavailable". */
131
+ wikilinks: RichContentWikilinks;
132
+ /** `@mentions` of people. Default: the label as written, unresolved. */
133
+ resolvePerson: (id: string) => Promise<RichContentPerson | null>;
134
+ /** The host's record peek for a person or resource. Default: none (the chip is not clickable). */
135
+ ResourcePeek: ComponentType<{
136
+ kind: string;
137
+ id: string;
138
+ onClose: () => void;
139
+ }>;
140
+ /** The splitter's kind-envelope hooks. Default: no envelopes (regions carry no `metadata.__ir`). */
141
+ splitterEnvelopes: RichContentSplitterEnvelopes;
142
+ /** A hook returning the host's "save these rows as a table" opener, or null. Default: no opener (the button is absent). */
143
+ useOpenSaveToTable: () => ((options: {
144
+ grid: {
145
+ headers: string[];
146
+ rows: string[][];
147
+ };
148
+ }) => unknown) | null;
149
+ /** The kind registry. Default: no kinds known (kind JSON renders through the generic structured floor). */
150
+ kindRegistry: RichContentKindRegistry;
151
+ /** The (kind, platform, role) component resolver. Default: a resolver with no rows. */
152
+ componentRegistry: RichContentComponentRegistry;
153
+ /** The content-IR render host (seams + registries) for content-ir-react. Default: none — kinds render without host seams. */
154
+ contentIrHost: ContentIrHost;
155
+ /** Files a kind-component render incident. Default: the console. */
156
+ reportKindComponentIncident: (incident: RichContentKindIncident) => void;
157
+ }
File without changes
@@ -0,0 +1,15 @@
1
+ import type { WikiResolution } from "./types.js";
2
+ export declare function resolveWikiTarget(target: string): Promise<WikiResolution>;
3
+ export declare function createWikiPage(title: string): Promise<{
4
+ ok: true;
5
+ href: string | null;
6
+ } | {
7
+ ok: false;
8
+ error: string;
9
+ }>;
10
+ export declare function loadWikiBody(token: string, id: string): Promise<{
11
+ body: string;
12
+ } | {
13
+ error: string;
14
+ }>;
15
+ export type { WikiResolution };
@@ -0,0 +1,23 @@
1
+ import { announceBareHost, hostCapability } from "./registry.js";
2
+ const BARE = "This document is not connected to any records.";
3
+ function resolveWikiTarget(target) {
4
+ const w = hostCapability("wikilinks");
5
+ if (!w) {
6
+ announceBareHost("wikilinks", "every [[link]] reads unavailable");
7
+ return Promise.resolve({ status: "unavailable", title: target, message: BARE });
8
+ }
9
+ return w.resolve(target);
10
+ }
11
+ function createWikiPage(title) {
12
+ const w = hostCapability("wikilinks");
13
+ return w ? w.create(title) : Promise.resolve({ ok: false, error: BARE });
14
+ }
15
+ function loadWikiBody(token, id) {
16
+ const w = hostCapability("wikilinks");
17
+ return w ? w.loadBody(token, id) : Promise.resolve({ error: BARE });
18
+ }
19
+ export {
20
+ createWikiPage,
21
+ loadWikiBody,
22
+ resolveWikiTarget
23
+ };