markstream-angular 2.0.19 → 2.0.20

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,69 +1,77 @@
1
1
  import f from "mermaid";
2
+ function u(n, e) {
3
+ var a, t;
4
+ const r = (a = (t = n.match(/^---[^\S\r\n]*(?:\r\n?|\n)[\s\S]*?(?:\r\n?|\n)---[^\S\r\n]*(?:\r\n?|\n)/)) === null || t === void 0 ? void 0 : t[0]) !== null && a !== void 0 ? a : "", i = n.slice(r.length);
5
+ return i.trimStart().startsWith("%%{") ? n : r + e + i;
6
+ }
2
7
  f.initialize({ startOnLoad: !1, securityLevel: "strict", flowchart: { htmlLabels: !1 } });
3
- function u(r, t) {
4
- const e = `%%{init: {"theme": "${t === "dark" ? "dark" : "default"}"}}%%
5
- `;
6
- return r.trimStart().startsWith("%%{") ? r : e + r;
8
+ function g(n, e) {
9
+ return u(n, `%%{init: {"theme": "${e === "dark" ? "dark" : "default"}"}}%%
10
+ `);
7
11
  }
8
- function g(r) {
9
- const t = /^(?:graph|flowchart|flowchart\s+tb|flowchart\s+lr|sequenceDiagram|gantt|classDiagram|stateDiagram(?:-v2)?|erDiagram|journey|pie|quadrantChart|timeline|xychart(?:-beta)?)\b/;
10
- for (let a = 0; a < r.length; a += 1) {
11
- const e = r[a].trim();
12
- if (!(!e || e.startsWith("%%")) && t.test(e))
13
- return a;
12
+ function p(n) {
13
+ const e = /^(?:graph|flowchart|flowchart\s+tb|flowchart\s+lr|sequenceDiagram|gantt|classDiagram|stateDiagram(?:-v2)?|erDiagram|journey|pie|quadrantChart|timeline|xychart(?:-beta)?)\b/;
14
+ let a = n[0]?.trimEnd() === "---";
15
+ for (let t = 0; t < n.length; t += 1) {
16
+ const r = n[t].trim();
17
+ if (a) {
18
+ t > 0 && n[t].trimEnd() === "---" && (a = !1);
19
+ continue;
20
+ }
21
+ if (!(!r || r.startsWith("%%")) && e.test(r))
22
+ return t;
14
23
  }
15
24
  return -1;
16
25
  }
17
- async function l(r, t) {
18
- const a = u(r, t), e = f;
19
- if (typeof e.parse == "function")
20
- return await e.parse(a), !0;
26
+ async function c(n, e) {
27
+ const a = g(n, e), t = f;
28
+ if (typeof t.parse == "function")
29
+ return await t.parse(a), !0;
21
30
  throw new Error("mermaid.parse not available in worker");
22
31
  }
23
- async function p(r, t) {
24
- const a = r.split(`
25
- `), e = g(a);
26
- if (e === -1)
32
+ async function y(n, e) {
33
+ const a = n.split(/\r\n?|\n/), t = p(a);
34
+ if (t === -1)
27
35
  return null;
28
- const n = a.slice(0, e + 1);
29
- await l(n.join(`
30
- `), t);
31
- let s = e + 1, o = a.length, c = e + 1, d = 0;
36
+ const r = a.slice(0, t + 1);
37
+ await c(r.join(`
38
+ `), e);
39
+ let i = t + 1, s = a.length, l = t + 1, d = 0;
32
40
  const m = 12;
33
- for (; s <= o && d < m; ) {
34
- const i = Math.floor((s + o) / 2), h = [...n, ...a.slice(e + 1, i)].join(`
41
+ for (; i <= s && d < m; ) {
42
+ const o = Math.floor((i + s) / 2), h = [...r, ...a.slice(t + 1, o)].join(`
35
43
  `);
36
44
  d += 1;
37
45
  try {
38
- await l(h, t), c = i, s = i + 1;
46
+ await c(h, e), l = o, i = o + 1;
39
47
  } catch {
40
- o = i - 1;
48
+ s = o - 1;
41
49
  }
42
50
  }
43
- return [...n, ...a.slice(e + 1, c)].join(`
51
+ return [...r, ...a.slice(t + 1, l)].join(`
44
52
  `);
45
53
  }
46
- self.onmessage = async (r) => {
47
- const t = r.data, a = (e) => self.postMessage(e);
54
+ self.onmessage = async (n) => {
55
+ const e = n.data, a = (t) => self.postMessage(t);
48
56
  try {
49
- if (t.action === "canParse") {
57
+ if (e.action === "canParse") {
50
58
  a({
51
- id: t.id,
59
+ id: e.id,
52
60
  ok: !0,
53
- result: await l(t.payload.code, t.payload.theme)
61
+ result: await c(e.payload.code, e.payload.theme)
54
62
  });
55
63
  return;
56
64
  }
57
- if (t.action === "findPrefix") {
65
+ if (e.action === "findPrefix") {
58
66
  a({
59
- id: t.id,
67
+ id: e.id,
60
68
  ok: !0,
61
- result: await p(t.payload.code, t.payload.theme)
69
+ result: await y(e.payload.code, e.payload.theme)
62
70
  });
63
71
  return;
64
72
  }
65
- a({ id: t.id, ok: !1, error: "Unknown action" });
66
- } catch (e) {
67
- a({ id: t.id, ok: !1, error: e?.message ?? String(e) });
73
+ a({ id: e.id, ok: !1, error: "Unknown action" });
74
+ } catch (t) {
75
+ a({ id: e.id, ok: !1, error: t?.message ?? String(t) });
68
76
  }
69
77
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "markstream-angular",
3
3
  "type": "module",
4
- "version": "2.0.19",
4
+ "version": "2.0.20",
5
5
  "description": "Angular 20+ standalone streaming Markdown renderer for AI chat, LLM token streams, SSE/WebSocket output, incomplete Markdown, Mermaid, KaTeX, stream-diffs powered code blocks, and safe Angular component rendering.",
6
6
  "author": "Simon He",
7
7
  "license": "MIT",
@@ -94,8 +94,8 @@
94
94
  },
95
95
  "dependencies": {
96
96
  "@floating-ui/dom": "^1.8.0",
97
- "markstream-core": "2.0.19",
98
- "stream-markdown-parser": "1.2.20"
97
+ "markstream-core": "2.0.20",
98
+ "stream-markdown-parser": "1.2.21"
99
99
  },
100
100
  "devDependencies": {
101
101
  "@angular/common": "^20.3.26",