@duskmoon-dev/components 0.6.2 → 0.6.4

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.
@@ -38,7 +38,7 @@ var __chunks = (base, ids, nodes, entry) => {
38
38
  __chunkSeen ||= {};
39
39
  __preload(ids[entry], 1);
40
40
  };
41
- __chunks(import.meta.url,["actqdgcw","rd10x4gc","kg46s2vk"],[["./index.js",2],["../../../chunk-rd10x4gc.js",2],["../../../chunk-kg46s2vk.js"]],0);
41
+ __chunks(import.meta.url,["43jyfyzy","rd10x4gc","kg46s2vk"],[["./index.js",2],["../../../chunk-rd10x4gc.js",2],["../../../chunk-kg46s2vk.js"]],0);
42
42
 
43
43
  // src/components/chat/rich/RichChatComposer.tsx
44
44
  import { Component, Suspense, forwardRef as forwardRef5, lazy } from "react";
@@ -601,6 +601,7 @@ var ComposerShell = forwardRef(({
601
601
  composerId,
602
602
  compact = false,
603
603
  addMenu,
604
+ context,
604
605
  entries,
605
606
  renderAttachment,
606
607
  removeAttachment,
@@ -815,7 +816,7 @@ var ComposerShell = forwardRef(({
815
816
  return /* @__PURE__ */ jsxs3("div", {
816
817
  ...props,
817
818
  ref,
818
- className: cn("chat-composer", className),
819
+ className: cn("chat-composer", compact && "chat-composer-compact", className),
819
820
  style: compact ? {
820
821
  ...props.style,
821
822
  anchorName: props.style?.anchorName && props.style.anchorName !== "none" ? `${props.style.anchorName}, ${completionAnchor}` : completionAnchor
@@ -844,6 +845,7 @@ var ComposerShell = forwardRef(({
844
845
  }
845
846
  },
846
847
  children: [
848
+ context,
847
849
  entries.length > 0 ? /* @__PURE__ */ jsx3("ul", {
848
850
  role: "list",
849
851
  className: cn("chat-composer-attachments", thumbnails && "chat-composer-thumbnails"),
@@ -2992,6 +2994,7 @@ var SemanticComposer = forwardRef4(({
2992
2994
  allowAttachmentOnly = false,
2993
2995
  compact = false,
2994
2996
  addMenu,
2997
+ context: composerContext,
2995
2998
  onStop,
2996
2999
  label = "Message",
2997
3000
  attachLabel = "Attach files",
@@ -3190,6 +3193,7 @@ var SemanticComposer = forwardRef4(({
3190
3193
  composerId: id,
3191
3194
  compact,
3192
3195
  addMenu,
3196
+ context: composerContext,
3193
3197
  entries: (attachmentsCurrent ? attachments.entries : []).map((entry) => ({
3194
3198
  id: entry.entryId,
3195
3199
  name: entry.metadata.name,
@@ -6,6 +6,73 @@ import ReactMarkdown from "react-markdown";
6
6
  import remarkBreaks from "remark-breaks";
7
7
  import remarkGfm from "remark-gfm";
8
8
 
9
+ // src/components/markdown/remarkCjkAutolink.ts
10
+ var CJK_BOUNDARY = /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\u3000-\u303F\u30FB\uFF00-\uFFEF]/u;
11
+ var BARE_URL = /(?:https?:\/\/|www\.)[\p{L}\p{N}_-]/iu;
12
+ var LEADING_BARE_URL = new RegExp(`^${BARE_URL.source}`, "iu");
13
+ var TRAILING_PUNCTUATION = /[?!.,:;*_~'"]$/;
14
+ function isLiteralAutolink(node) {
15
+ const [child] = node.children ?? [];
16
+ return node.children?.length === 1 && child.type === "text" && child.value !== undefined && node.position?.start.offset !== undefined && child.position?.start.offset === node.position.start.offset && LEADING_BARE_URL.test(child.value);
17
+ }
18
+ function trimTrailing(url) {
19
+ let end = url;
20
+ for (;; ) {
21
+ if (TRAILING_PUNCTUATION.test(end)) {
22
+ end = end.slice(0, -1);
23
+ } else if (end.endsWith(")") && end.split(")").length > end.split("(").length) {
24
+ end = end.slice(0, -1);
25
+ } else {
26
+ return end;
27
+ }
28
+ }
29
+ }
30
+ function linkNode(text) {
31
+ return {
32
+ type: "link",
33
+ url: /^www\./i.test(text) ? `http://${text}` : text,
34
+ children: [{ type: "text", value: text }]
35
+ };
36
+ }
37
+ function splitBareUrl(value) {
38
+ const boundary = value.search(CJK_BOUNDARY);
39
+ if (boundary === -1)
40
+ return [linkNode(value)];
41
+ const url = trimTrailing(value.slice(0, boundary));
42
+ const nodes = [
43
+ LEADING_BARE_URL.test(url) ? linkNode(url) : { type: "text", value: url }
44
+ ];
45
+ const rest = value.slice(url.length);
46
+ const next = rest.search(BARE_URL);
47
+ if (next === -1) {
48
+ nodes.push({ type: "text", value: rest });
49
+ } else {
50
+ if (next > 0)
51
+ nodes.push({ type: "text", value: rest.slice(0, next) });
52
+ nodes.push(...splitBareUrl(rest.slice(next)));
53
+ }
54
+ return nodes;
55
+ }
56
+ function visit(parent) {
57
+ const children = parent.children;
58
+ if (!children)
59
+ return;
60
+ for (let index = 0;index < children.length; index++) {
61
+ const node = children[index];
62
+ const text = node.children?.[0]?.value;
63
+ if (node.type === "link" && text !== undefined && isLiteralAutolink(node) && CJK_BOUNDARY.test(text)) {
64
+ const replacement = splitBareUrl(text);
65
+ children.splice(index, 1, ...replacement);
66
+ index += replacement.length - 1;
67
+ } else {
68
+ visit(node);
69
+ }
70
+ }
71
+ }
72
+ function remarkCjkAutolink() {
73
+ return (tree) => visit(tree);
74
+ }
75
+
9
76
  // ../../node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs
10
77
  function r(e) {
11
78
  var t, f, n = "";
@@ -159,7 +226,7 @@ var Markdown = forwardRef(function Markdown({
159
226
  })
160
227
  }) : null,
161
228
  /* @__PURE__ */ jsx(ReactMarkdown, {
162
- remarkPlugins: breaks ? [remarkGfm, remarkBreaks] : [remarkGfm],
229
+ remarkPlugins: breaks ? [remarkGfm, remarkCjkAutolink, remarkBreaks] : [remarkGfm, remarkCjkAutolink],
163
230
  components,
164
231
  children: source.body
165
232
  })
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Ends GFM literal autolinks (bare `https://…` / `www.…` URLs) at CJK text.
3
+ *
4
+ * GFM only stops a literal URL at whitespace, `<` or trailing ASCII
5
+ * punctuation, so `https://example.com,告诉我` links the Chinese text too.
6
+ * This transform runs after `remark-gfm` and cuts each literal autolink before
7
+ * the first CJK ideograph, kana, Hangul, CJK symbol/punctuation or full-width
8
+ * form. Non-ASCII path text is therefore not kept (`https://a.com/路径` links
9
+ * `https://a.com/`); percent-encoded paths, `<url>` autolinks and
10
+ * `[text](url)` links are untouched.
11
+ */
12
+ interface MdNode {
13
+ type: string;
14
+ value?: string;
15
+ url?: string;
16
+ children?: MdNode[];
17
+ position?: {
18
+ start: {
19
+ offset?: number;
20
+ };
21
+ };
22
+ }
23
+ export declare function remarkCjkAutolink(): (tree: MdNode) => void;
24
+ export {};
@@ -1 +1 @@
1
- export declare const version = "0.6.2";
1
+ export declare const version = "0.6.4";