@floegence/floe-webapp-core 0.86.28 → 0.86.31

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.
@@ -1,13 +1,13 @@
1
1
  import { secureRandomUUID as w } from "../../../utils/secureRandom.js";
2
2
  import { renderMarkdownToHtml as k } from "../markdown/markdown.js";
3
- let n = null, l = !1, u = null;
4
- const c = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), m = 200;
3
+ let n = null, c = !1, u = null;
4
+ const l = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), m = 200;
5
5
  function h() {
6
6
  if (typeof Worker > "u") return null;
7
7
  try {
8
8
  return new Worker(new URL(
9
9
  /* @vite-ignore */
10
- "" + new URL("../../../assets/markdown.worker-D2sIOyGt.js", import.meta.url).href,
10
+ "" + new URL("../../../assets/markdown.worker-CcdiAiK-.js", import.meta.url).href,
11
11
  import.meta.url
12
12
  ), { type: "module" });
13
13
  } catch {
@@ -15,14 +15,14 @@ function h() {
15
15
  }
16
16
  }
17
17
  function W(r) {
18
- return n = r, l = !1, u = new Promise((t) => {
18
+ return n = r, c = !1, u = new Promise((t) => {
19
19
  n.onmessage = (e) => {
20
20
  if ("type" in e.data && e.data.type === "ready") {
21
- l = !0, t();
21
+ c = !0, t();
22
22
  return;
23
23
  }
24
- const { id: o, html: f, error: i } = e.data, s = c.get(o);
25
- s && (c.delete(o), i ? s.reject(new Error(i)) : s.resolve(f));
24
+ const { id: o, html: d, error: i } = e.data, s = l.get(o);
25
+ s && (l.delete(o), i ? s.reject(new Error(i)) : s.resolve(d));
26
26
  }, n.onerror = (e) => {
27
27
  console.error("Markdown worker error:", e);
28
28
  };
@@ -32,35 +32,35 @@ function g() {
32
32
  return !!n;
33
33
  }
34
34
  async function p() {
35
- return n ? l ? !0 : u ? (await u, !0) : !1 : !1;
35
+ return n ? c ? !0 : u ? (await u, !0) : !1 : !1;
36
36
  }
37
37
  function R(r) {
38
38
  const t = a.get(r);
39
39
  if (t) return t;
40
40
  const e = k(r);
41
- return d(r, e), e;
41
+ return f(r, e), e;
42
42
  }
43
43
  async function U(r) {
44
44
  const t = a.get(r);
45
45
  if (t) return t;
46
46
  if (!await p() || !n) {
47
47
  const o = k(r);
48
- return d(r, o), o;
48
+ return f(r, o), o;
49
49
  }
50
- return new Promise((o, f) => {
50
+ return new Promise((o, d) => {
51
51
  const i = w();
52
- c.set(i, {
52
+ l.set(i, {
53
53
  resolve: (s) => {
54
- d(r, s), o(s);
54
+ f(r, s), o(s);
55
55
  },
56
- reject: f
56
+ reject: d
57
57
  }), n.postMessage({ id: i, content: r });
58
58
  });
59
59
  }
60
60
  function v() {
61
- n && (n.terminate(), n = null), l = !1, u = null, c.clear(), a.clear();
61
+ n && (n.terminate(), n = null), c = !1, u = null, l.clear(), a.clear();
62
62
  }
63
- function d(r, t) {
63
+ function f(r, t) {
64
64
  if (a.size >= m) {
65
65
  const e = a.keys().next().value;
66
66
  e && a.delete(e);
@@ -1,12 +1,9 @@
1
- import { marked as c } from "../../../node_modules/.pnpm/marked@17.0.6/node_modules/marked/lib/marked.esm.js";
2
- c.setOptions({
3
- gfm: !0,
4
- breaks: !0
5
- });
6
- const t = new c.Renderer();
1
+ import { marked as n } from "../../../node_modules/.pnpm/marked@17.0.6/node_modules/marked/lib/marked.esm.js";
2
+ import { createMarkdownParser as l } from "./parser.js";
3
+ const a = l(), t = new n.Renderer();
7
4
  t.code = function(e) {
8
- const r = e.lang || "text", a = e.text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
9
- return `<pre class="chat-md-code-block" data-language="${r}"><code>${a}</code></pre>`;
5
+ const r = e.lang || "text", c = e.text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
6
+ return `<pre class="chat-md-code-block" data-language="${r}"><code>${c}</code></pre>`;
10
7
  };
11
8
  t.codespan = function(e) {
12
9
  return `<code class="chat-md-inline-code">${e.text}</code>`;
@@ -22,10 +19,10 @@ t.image = function(e) {
22
19
  t.blockquote = function(e) {
23
20
  return `<blockquote class="chat-md-blockquote">${e.text}</blockquote>`;
24
21
  };
25
- c.use({ renderer: t });
26
- function l(e) {
27
- return c.parse(e, { async: !1 });
22
+ a.use({ renderer: t });
23
+ function i(e) {
24
+ return a.parse(e, { async: !1 });
28
25
  }
29
26
  export {
30
- l as renderMarkdownToHtml
27
+ i as renderMarkdownToHtml
31
28
  };
@@ -0,0 +1,3 @@
1
+ import { Marked, type MarkedOptions } from 'marked';
2
+ /** Create an isolated GFM parser with CJK-aware emphasis boundaries. */
3
+ export declare function createMarkdownParser(options?: MarkedOptions): Marked;
@@ -0,0 +1,14 @@
1
+ import { Marked as a } from "../../../node_modules/.pnpm/marked@17.0.6/node_modules/marked/lib/marked.esm.js";
2
+ import i from "../../../node_modules/.pnpm/marked-cjk-friendly@0.1.2_marked@17.0.6/node_modules/marked-cjk-friendly/dist/index.js";
3
+ function u(r = {}) {
4
+ const t = i().tokenizer.emStrong;
5
+ return new a({ tokenizer: {
6
+ emStrong(n, o, s) {
7
+ const e = t.call(this, n, o, s);
8
+ return e && /^\s|\s$/u.test(e.text) ? !1 : e;
9
+ }
10
+ } }).setOptions({ gfm: !0, breaks: !0, ...r });
11
+ }
12
+ export {
13
+ u as createMarkdownParser
14
+ };
@@ -0,0 +1 @@
1
+ export { createMarkdownParser } from './components/chat/markdown/parser';
@@ -0,0 +1,4 @@
1
+ import { createMarkdownParser as a } from "./components/chat/markdown/parser.js";
2
+ export {
3
+ a as createMarkdownParser
4
+ };
@@ -0,0 +1,130 @@
1
+ const d = "\\u1100-\\u11ff\\u20a9\\u2329-\\u232a\\u2630-\\u2637\\u268a-\\u268f\\u2e80-\\u2e99\\u2e9b-\\u2ef3\\u2f00-\\u2fd5\\u2ff0-\\u303e\\u3041-\\u3096\\u3099-\\u30ff\\u3105-\\u312f\\u3131-\\u318e\\u3190-\\u31e5\\u31ef-\\u321e\\u3220-\\u3247\\u3250-\\ua48c\\ua490-\\ua4c6\\ua960-\\ua97c\\uac00-\\ud7a3\\ud7b0-\\ud7c6\\ud7cb-\\ud7fb\\uf900-\\ufaff\\ufe10-\\ufe19\\ufe30-\\ufe52\\ufe54-\\ufe66\\ufe68-\\ufe6b\\uff01-\\uffbe\\uffc2-\\uffc7\\uffca-\\uffcf\\uffd2-\\uffd7\\uffda-\\uffdc\\uffe0-\\uffe6\\uffe8-\\uffee\\u{16fe0}-\\u{16fe4}\\u{16ff0}-\\u{16ff6}\\u{17000}-\\u{18cda}\\u{18cff}-\\u{18d20}\\u{18d80}-\\u{18df2}\\u{18e00}-\\u{19191}\\u{191a0}-\\u{191d2}\\u{1aff0}-\\u{1aff3}\\u{1aff5}-\\u{1affb}\\u{1affd}-\\u{1affe}\\u{1b000}-\\u{1b128}\\u{1b132}\\u{1b150}-\\u{1b152}\\u{1b155}\\u{1b164}-\\u{1b168}\\u{1b170}-\\u{1b2fb}\\u{1d300}-\\u{1d356}\\u{1d360}-\\u{1d376}\\u{1f1ae}\\u{1f200}\\u{1f202}\\u{1f210}-\\u{1f219}\\u{1f21b}-\\u{1f22e}\\u{1f230}-\\u{1f231}\\u{1f237}\\u{1f23b}\\u{1f240}-\\u{1f248}\\u{1f260}-\\u{1f265}\\u{1f7da}\\u{20000}-\\u{3fffd}", k = new RegExp(`[${d}]`, "u"), I = new RegExp(`^((?![*_])[\\s\\p{P}\\p{S}${d}])`, "u");
2
+ function L(e, t, n) {
3
+ return new RegExp(`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)${e}(\\*+)(?=[\\s]|$)|${n}(\\*+)(?!\\*)(?=${t}|$)|(?!\\*)${t}(\\*+)(?=${n})|[\\s](\\*+)(?!\\*)(?=${e})|(?!\\*)${e}(\\*+)(?!\\*)(?=${e})|${n}(\\*+)(?=${n})`, "gu");
4
+ }
5
+ function G(e, t, n) {
6
+ return new RegExp(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)${e}(_+)(?=[\\s]|$)|${n}(_+)(?!_)(?=${t}|$)|(?!_)${t}(_+)(?=${n})|[\\s](_+)(?!_)(?=${e})|(?!_)${e}(_+)(?!_)(?=${e})`, "gu");
7
+ }
8
+ function N(e, t, n) {
9
+ return new RegExp(`^[^~]+(?=[^~])|(?!~)${e}(~~?)(?=[\\s]|$)|${n}(~~?)(?!~)(?=${t}|$)|(?!~)${t}(~~?)(?=${n})|[\\s](~~?)(?!~)(?=${e})|(?!~)${e}(~~?)(?!~)(?=${e})|${n}(~~?)(?=${n})`, "gu");
10
+ }
11
+ const E = `[\\p{P}\\p{S}${d}]`, w = `[\\s\\p{P}\\p{S}${d}]`, T = `[^\\s\\p{P}\\p{S}${d}]`, U = `(?![*_])[\\p{P}\\p{S}${d}]`, O = `(?![*_])[\\s\\p{P}\\p{S}${d}]`, z = `(?:[^\\s\\p{P}\\p{S}${d}]|[*_])`, F = `(?!~)[\\p{P}\\p{S}${d}]`, J = `(?!~)[\\s\\p{P}\\p{S}${d}]`, K = `(?:[^\\s\\p{P}\\p{S}${d}]|~)`, M = L(E, w, T), W = L(F, J, K), q = G(E, w, T), S = N(U, O, z);
12
+ function A(e, t, n) {
13
+ let f = I.test(e);
14
+ if (!f && e) {
15
+ const u = t.length - n.length;
16
+ if (u >= 1) {
17
+ let c = u - 1, a = t.charCodeAt(c);
18
+ if (a >= 65024 && a <= 65038 && c >= 1 && (c--, a = t.charCodeAt(c)), (a & 64512) === 56320 && c >= 1) {
19
+ const s = t.codePointAt(c - 1);
20
+ s !== void 0 && s > 65535 && (s >= 917760 && s <= 917999 ? f = !0 : f = k.test(String.fromCodePoint(s)));
21
+ } else f = k.test(String.fromCharCode(a));
22
+ }
23
+ }
24
+ return f;
25
+ }
26
+ function R(e, t) {
27
+ if (!(e[1] || e[2] || e[3] || e[4])) return !1;
28
+ const n = String.fromCodePoint(e[0].codePointAt(0)), f = e.index + e[0].length, u = f < t.length ? String.fromCodePoint(t.codePointAt(f)) : "";
29
+ return k.test(n) || k.test(u);
30
+ }
31
+ function P(e) {
32
+ return e.length >= 5;
33
+ }
34
+ function v(e) {
35
+ return !!(e[1] || e[2] || e[3] || e[4]);
36
+ }
37
+ function H(e) {
38
+ return P(e) ? !!e[4] : !!e[3];
39
+ }
40
+ function Q(e) {
41
+ return P(e) ? e[1] || e[3] || "" : e[1] || e[2] || "";
42
+ }
43
+ function V() {
44
+ return { tokenizer: {
45
+ emStrong(e, t, n = "") {
46
+ const { rules: f } = this, u = f.inline.emStrongLDelim.exec(e);
47
+ if (!u) return !1;
48
+ const c = P(u);
49
+ if (c && !v(u)) return;
50
+ if (H(u) && n.match(f.other.unicodeAlphaNumeric)) return !1;
51
+ const a = Q(u), s = A(n, t, e);
52
+ if (!a || !n || f.inline.punctuation.exec(n) || s || k.test(a)) {
53
+ const $ = [...u[0]].length - 1;
54
+ let r, o, g = $, i = 0;
55
+ const j = c && n === u[0][0], b = f.inline.emStrongRDelimAst.source.includes("(?!~)");
56
+ let m;
57
+ u[0][0] === "*" ? m = b ? W : M : m = q, m.lastIndex = 0;
58
+ const _ = t.slice(-1 * e.length + $);
59
+ let l;
60
+ for (; (l = m.exec(_)) != null; ) {
61
+ if (r = l[1] || l[2] || l[3] || l[4] || l[5] || l[6], !r) continue;
62
+ o = [...r].length;
63
+ const C = R(l, _), y = !!(l[3] || l[4]), h = !!(l[5] || l[6]);
64
+ if (y && !C) {
65
+ g += o;
66
+ continue;
67
+ }
68
+ if (h || C) {
69
+ if ($ % 3 && !(($ + o) % 3)) {
70
+ i += o;
71
+ continue;
72
+ }
73
+ if (j && h) break;
74
+ }
75
+ if (g -= o, g > 0) continue;
76
+ o = Math.min(o, o + g + i);
77
+ const B = l[0].codePointAt(0) > 65535 ? 2 : 1, x = e.slice(0, $ + l.index + B + o);
78
+ if (Math.min($, o) % 2) {
79
+ const D = x.slice(1, -1);
80
+ return {
81
+ type: "em",
82
+ raw: x,
83
+ text: D,
84
+ tokens: this.lexer.inlineTokens(D)
85
+ };
86
+ }
87
+ const p = x.slice(2, -2);
88
+ return {
89
+ type: "strong",
90
+ raw: x,
91
+ text: p,
92
+ tokens: this.lexer.inlineTokens(p)
93
+ };
94
+ }
95
+ }
96
+ },
97
+ del(e, t, n = "") {
98
+ const { rules: f } = this, u = f.inline.delLDelim.exec(e);
99
+ if (!u) return !1;
100
+ const c = u[1] || "", a = A(n, t, e);
101
+ if (!c || !n || f.inline.punctuation.exec(n) || a || k.test(c)) {
102
+ const s = [...u[0]].length - 1;
103
+ let $, r, o = s;
104
+ S.lastIndex = 0;
105
+ const g = t.slice(-1 * e.length + s);
106
+ let i;
107
+ for (; (i = S.exec(g)) != null; ) {
108
+ if ($ = i[1] || i[2] || i[3] || i[4] || i[5] || i[6], !$ || (r = [...$].length, r !== s)) continue;
109
+ const j = R(i, g);
110
+ if ((i[3] || i[4]) && !j) {
111
+ o += r;
112
+ continue;
113
+ }
114
+ if (o -= r, o > 0) continue;
115
+ r = Math.min(r, r + o);
116
+ const b = i[0].codePointAt(0) > 65535 ? 2 : 1, m = e.slice(0, s + i.index + b + r), _ = m.slice(s, -s);
117
+ return {
118
+ type: "del",
119
+ raw: m,
120
+ text: _,
121
+ tokens: this.lexer.inlineTokens(_)
122
+ };
123
+ }
124
+ }
125
+ }
126
+ } };
127
+ }
128
+ export {
129
+ V as default
130
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floegence/floe-webapp-core",
3
- "version": "0.86.28",
3
+ "version": "0.86.31",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -60,6 +60,10 @@
60
60
  "types": "./dist/chat.d.ts",
61
61
  "import": "./dist/chat.js"
62
62
  },
63
+ "./markdown": {
64
+ "types": "./dist/markdown.d.ts",
65
+ "import": "./dist/markdown.js"
66
+ },
63
67
  "./chat-media": {
64
68
  "types": "./dist/chat-media.d.ts",
65
69
  "import": "./dist/chat-media.js"
@@ -171,6 +175,7 @@
171
175
  "elkjs": "0.12.0",
172
176
  "libavoid-js": "0.5.0-beta.5",
173
177
  "marked": "^17.0.6",
178
+ "marked-cjk-friendly": "0.1.2",
174
179
  "mermaid": "^11.17.2",
175
180
  "monaco-editor": "^0.57.0",
176
181
  "pdfjs-dist": "6.3.289",