@ai-matrx/messaging 0.3.0 → 0.4.0
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/CHANGELOG.md +36 -0
- package/README.md +5 -0
- package/dist/index.cjs +16 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +16 -5
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +44 -7
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +28 -5
- package/dist/react.d.ts +28 -5
- package/dist/react.js +44 -7
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
package/dist/react.cjs
CHANGED
|
@@ -316,21 +316,32 @@ function splitText(content) {
|
|
|
316
316
|
if (start > cursor) {
|
|
317
317
|
segments.push({ type: "text", value: content.slice(cursor, start) });
|
|
318
318
|
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
319
|
+
const body = match[1] ?? "";
|
|
320
|
+
const references = parseFenceBody(body);
|
|
321
|
+
if (references.length === 0) {
|
|
322
|
+
segments.push({ type: "fence", body });
|
|
323
|
+
} else {
|
|
324
|
+
references.forEach((reference) => {
|
|
325
|
+
segments.push({ type: "reference", reference });
|
|
326
|
+
});
|
|
327
|
+
}
|
|
322
328
|
cursor = start + match[0].length;
|
|
323
329
|
}
|
|
324
330
|
if (cursor < content.length) {
|
|
325
331
|
segments.push({ type: "text", value: content.slice(cursor) });
|
|
326
332
|
}
|
|
327
333
|
return segments.filter(
|
|
328
|
-
(segment) => segment.type
|
|
334
|
+
(segment) => segment.type !== "text" || segment.value.trim().length > 0
|
|
329
335
|
);
|
|
330
336
|
}
|
|
331
337
|
function summarizeText(content, maxLength = 140) {
|
|
332
338
|
const parts = splitText(content).map(
|
|
333
|
-
(segment) => segment.type === "text" ? segment.value : segment.reference.label
|
|
339
|
+
(segment) => segment.type === "text" ? segment.value : segment.type === "reference" ? segment.reference.label : (
|
|
340
|
+
// A fence we cannot read still SAYS something. Collapsing it to
|
|
341
|
+
// nothing is how a reference-only message becomes an inbox row that
|
|
342
|
+
// reads "No messages yet" — a screen telling a lie.
|
|
343
|
+
"Reference"
|
|
344
|
+
)
|
|
334
345
|
);
|
|
335
346
|
const flattened = parts.join(" ").replace(/\s+/g, " ").trim();
|
|
336
347
|
if (flattened.length <= maxLength) return flattened;
|
|
@@ -1886,6 +1897,7 @@ function MessagingRuntime(props) {
|
|
|
1886
1897
|
return map;
|
|
1887
1898
|
}, [renderers]);
|
|
1888
1899
|
const renderReference = props.renderReference ?? null;
|
|
1900
|
+
const renderFence = props.renderFence ?? null;
|
|
1889
1901
|
const wrapMessage = props.wrapMessage ?? null;
|
|
1890
1902
|
const wrapConversationRow = props.wrapConversationRow ?? null;
|
|
1891
1903
|
const host = (0, import_react.useMemo)(() => {
|
|
@@ -1898,10 +1910,20 @@ function MessagingRuntime(props) {
|
|
|
1898
1910
|
openReference: referenceRef.current ?? null,
|
|
1899
1911
|
actionRenderers: rendererMap,
|
|
1900
1912
|
renderReference,
|
|
1913
|
+
renderFence,
|
|
1901
1914
|
wrapMessage,
|
|
1902
1915
|
wrapConversationRow
|
|
1903
1916
|
};
|
|
1904
|
-
}, [
|
|
1917
|
+
}, [
|
|
1918
|
+
engine,
|
|
1919
|
+
actionRegistry,
|
|
1920
|
+
ai,
|
|
1921
|
+
rendererMap,
|
|
1922
|
+
renderReference,
|
|
1923
|
+
renderFence,
|
|
1924
|
+
wrapMessage,
|
|
1925
|
+
wrapConversationRow
|
|
1926
|
+
]);
|
|
1905
1927
|
const MessagingContext = messagingContext();
|
|
1906
1928
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MessagingContext.Provider, { value: host, children });
|
|
1907
1929
|
}
|
|
@@ -2492,6 +2514,20 @@ function DeliveryTick(props) {
|
|
|
2492
2514
|
return null;
|
|
2493
2515
|
}
|
|
2494
2516
|
}
|
|
2517
|
+
function UnreadableReference() {
|
|
2518
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
2519
|
+
"span",
|
|
2520
|
+
{
|
|
2521
|
+
className: "mx-msg__reference mx-msg__reference--inert",
|
|
2522
|
+
title: "This message names something in a reference format this app has not wired. Pass renderFence to <MessagingProvider> to render it.",
|
|
2523
|
+
children: [
|
|
2524
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(LinkIcon, {}),
|
|
2525
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "mx-msg__reference-type", children: "reference" }),
|
|
2526
|
+
"Reference"
|
|
2527
|
+
]
|
|
2528
|
+
}
|
|
2529
|
+
);
|
|
2530
|
+
}
|
|
2495
2531
|
function ReferenceCard(props) {
|
|
2496
2532
|
const { reference, onOpen } = props;
|
|
2497
2533
|
const href = reference.href;
|
|
@@ -2856,6 +2892,7 @@ function MessageBubble(props) {
|
|
|
2856
2892
|
const { message, isMine } = props;
|
|
2857
2893
|
const host = useMessagingHost();
|
|
2858
2894
|
const HostReference = host?.renderReference ?? null;
|
|
2895
|
+
const HostFence = host?.renderFence ?? null;
|
|
2859
2896
|
const MessageChrome = host?.wrapMessage ?? null;
|
|
2860
2897
|
if (message.deletedAt !== null) {
|
|
2861
2898
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "mx-msg__bubble mx-msg__bubble--deleted", children: "Message deleted" });
|
|
@@ -2870,7 +2907,7 @@ function MessageBubble(props) {
|
|
|
2870
2907
|
const bubble = /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
2871
2908
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: classes, children: [
|
|
2872
2909
|
splitText(message.content).map(
|
|
2873
|
-
(segment, index) => segment.type === "text" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: segment.value }, index) : HostReference !== null ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2910
|
+
(segment, index) => segment.type === "text" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: segment.value }, index) : segment.type === "fence" ? HostFence !== null ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(HostFence, { body: segment.body }, `fence:${index}`) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(UnreadableReference, {}, `fence:${index}`) : HostReference !== null ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
2874
2911
|
HostReference,
|
|
2875
2912
|
{
|
|
2876
2913
|
reference: segment.reference
|