@floegence/floe-webapp-core 0.86.48 → 0.86.49

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,38 +1,38 @@
1
- function V(O) {
2
- let L = 0, b = [], C = 0, I = !1, l = [], d = /* @__PURE__ */ Object.create(null), y = /* @__PURE__ */ Object.create(null), D = 1, o = 0, g, v, M = !1, S = 0, W = 0;
3
- const x = /* @__PURE__ */ new Map();
4
- function R(e) {
1
+ function X(k) {
2
+ let L = 0, b = [], C = 0, I = !1, l = [], p = /* @__PURE__ */ Object.create(null), v = /* @__PURE__ */ Object.create(null), R = 1, o = 0, g, O, S = !1, M = 0, W = 0;
3
+ const m = /* @__PURE__ */ new Map();
4
+ function U(e) {
5
5
  let t = 0, n = b.length;
6
6
  for (; t < n; ) {
7
7
  const s = t + n >>> 1;
8
8
  b[s].start <= e ? t = s + 1 : n = s;
9
9
  }
10
- const r = Math.max(0, t - 1);
11
- return b.slice(r).map((s, a) => a === 0 ? s.text.slice(e - s.start) : s.text).join("");
10
+ const i = Math.max(0, t - 1);
11
+ return b.slice(i).map((s, a) => a === 0 ? s.text.slice(e - s.start) : s.text).join("");
12
12
  }
13
13
  function F(e, t) {
14
14
  W += e.length;
15
- const n = new O.Lexer({ ...O.defaults });
15
+ const n = new k.Lexer({ ...k.defaults });
16
16
  return n.tokens.links = { ...t }, n.lex(e);
17
17
  }
18
- function m(e) {
19
- return { changes: e, links: d, sourceLength: C };
18
+ function w(e) {
19
+ return { changes: e, links: p, sourceLength: C };
20
20
  }
21
21
  function $(e) {
22
22
  return { id: e.id, start: e.start, token: structuredClone(e.token) };
23
23
  }
24
- function U(e) {
24
+ function q(e) {
25
25
  for (const t of e.token.raw.matchAll(/\[((?:\\[^\n]|[^\]\n\\])+)\]/g)) {
26
26
  const n = t[1].toLowerCase().replace(/\s+/g, " ");
27
27
  e.references.add(n);
28
- let r = x.get(n);
29
- r || x.set(n, r = /* @__PURE__ */ new Set()), r.add(e);
28
+ let i = m.get(n);
29
+ i || m.set(n, i = /* @__PURE__ */ new Set()), i.add(e);
30
30
  }
31
31
  }
32
- function q(e) {
32
+ function B(e) {
33
33
  for (const t of e.references) {
34
- const n = x.get(t);
35
- n?.delete(e), n?.size || x.delete(t);
34
+ const n = m.get(t);
35
+ n?.delete(e), n?.size || m.delete(t);
36
36
  }
37
37
  }
38
38
  function E(e, t) {
@@ -44,20 +44,31 @@ function V(O) {
44
44
  } else t.candidate && (n === t.mark && t.indent <= 3 ? t.count++ : n === " " && t.count === 0 && t.indent < 3 ? t.indent++ : (n !== " " && n !== " " || t.count === 0) && (t.candidate = !1));
45
45
  return t.candidate && t.count >= t.minimum;
46
46
  }
47
- function z(e, t = 0) {
47
+ function z(e) {
48
+ const t = k.defaults.extensions;
49
+ if (!t || !t.inline?.length) return !1;
50
+ const n = t.startInline ?? [];
51
+ if (n.length < t.inline.length) return !0;
52
+ const i = new k.Lexer({ ...k.defaults });
53
+ return n.some((s) => {
54
+ const a = s.call({ lexer: i }, e);
55
+ return typeof a == "number" && a >= 0;
56
+ });
57
+ }
58
+ function _(e, t = 0) {
48
59
  const n = e.tokens;
49
- let r = -1;
60
+ let i = -1;
50
61
  for (let f = t; f < n.length; f++) {
51
62
  const u = n[f];
52
- if (u.type === "text" && /[\\\x60*_[<~]/u.test(u.raw)) {
53
- r = f;
63
+ if (u.type === "text" && (/[\\\x60*_[<~]/u.test(u.raw) || z(u.raw))) {
64
+ i = f;
54
65
  break;
55
66
  }
56
67
  }
57
- let s = r >= 0 ? r : Math.max(t, n.length - 1);
68
+ let s = i >= 0 ? i : Math.max(t, n.length - 1);
58
69
  s > t && n[s]?.type === "text" && !/\s/u.test(n[s].raw) && n[s - 1]?.type === "link" && s--;
59
70
  const a = n[s];
60
- if (r < 0 && a?.type === "text" && a.raw === a.text) {
71
+ if (i < 0 && a?.type === "text" && a.raw === a.text) {
61
72
  const f = a.raw.lastIndexOf(" ");
62
73
  if (f > 0) {
63
74
  const u = a;
@@ -69,81 +80,82 @@ function V(O) {
69
80
  ), s++;
70
81
  }
71
82
  }
72
- const p = n.slice(s).map((f) => f.raw).join("");
73
- v = {
83
+ const d = n.slice(s).map((f) => f.raw).join("");
84
+ O = {
74
85
  from: s,
75
- source: p,
76
- unresolved: r >= 0,
77
- lastChar: p.slice(-1)
86
+ source: d,
87
+ unresolved: i >= 0,
88
+ extensionPending: z(d),
89
+ lastChar: d.slice(-1)
78
90
  };
79
91
  }
80
- function B() {
81
- g = void 0, v = void 0, M = !1;
92
+ function G() {
93
+ g = void 0, O = void 0, S = !1;
82
94
  const e = l.at(-1)?.token;
83
95
  if (e?.type === "paragraph") {
84
- z(e);
96
+ _(e);
85
97
  const a = e.raw.lastIndexOf(`
86
- `) + 1, p = e.raw.slice(a, a + 32);
87
- M = !e.raw.endsWith(`
88
- `) && !/^(?: {0,3}(?:[-+*_]+|[0-9]{1,9}[.)]?)[ \t]*$| {0,3}[[<\x60~#|=])/u.test(p);
98
+ `) + 1, d = e.raw.slice(a, a + 32);
99
+ S = !e.raw.endsWith(`
100
+ `) && !/^(?: {0,3}(?:[-+*_]+|[0-9]{1,9}[.)]?)[ \t]*$| {0,3}[[<\x60~#|=])/u.test(d);
89
101
  }
90
102
  if (e?.type !== "code") return;
91
103
  const t = /^(\x60{3,}|~{3,})[^\n]*\n/.exec(e.raw);
92
104
  if (!t) return;
93
- const n = t[1], r = e.raw.slice(t[0].length), s = {
105
+ const n = t[1], i = e.raw.slice(t[0].length), s = {
94
106
  mark: n[0],
95
107
  minimum: n.length,
96
108
  count: 0,
97
109
  indent: 0,
98
110
  candidate: !0,
99
- pendingNewline: r.endsWith(`
111
+ pendingNewline: i.endsWith(`
100
112
  `)
101
113
  };
102
- E(r, s) || (g = s);
114
+ E(i, s) || (g = s);
103
115
  }
104
- function _(e = !1) {
116
+ function N(e = !1) {
105
117
  const t = l[o]?.start ?? 0, n = l.splice(o);
106
- for (const i of n) q(i);
107
- const r = F(R(t), y), s = d;
108
- d = Object.freeze(
118
+ for (const r of n) B(r);
119
+ const i = F(U(t), v), s = p;
120
+ p = Object.freeze(
109
121
  Object.fromEntries(
110
- Object.entries(r.links).map(([i, c]) => [i, Object.freeze({ ...c })])
122
+ Object.entries(i.links).map(([r, c]) => [r, Object.freeze({ ...c })])
111
123
  )
112
124
  );
113
125
  const a = [];
114
- let p = t;
115
- for (let i = 0; i < r.length; i++) {
116
- const c = r[i], h = n[i], k = {
117
- id: h?.start === p ? h.id : D++,
118
- start: p,
126
+ let d = t;
127
+ for (let r = 0; r < i.length; r++) {
128
+ const c = i[r], h = n[r], x = {
129
+ id: h?.start === d ? h.id : R++,
130
+ start: d,
119
131
  token: c,
120
132
  references: /* @__PURE__ */ new Set()
121
133
  };
122
- l.push(k), U(k), i === r.length - 1 && c.type === "paragraph" && z(c), (!e || !h || JSON.stringify(h.token) !== JSON.stringify(c)) && a.push({ kind: "replace", block: $(k) }), p += c.raw.length;
134
+ l.push(x), q(x), r === i.length - 1 && c.type === "paragraph" && _(c), (!e || !h || JSON.stringify(h.token) !== JSON.stringify(c)) && a.push({ kind: "replace", block: $(x) }), d += c.raw.length;
123
135
  }
124
- const f = new Set(l.slice(o).map((i) => i.id));
125
- for (const i of n)
126
- f.has(i.id) || a.push({ kind: "remove", id: i.id });
136
+ const f = new Set(l.slice(o).map((r) => r.id));
137
+ for (const r of n)
138
+ f.has(r.id) || a.push({ kind: "remove", id: r.id });
127
139
  const u = /* @__PURE__ */ new Set();
128
- for (const i of /* @__PURE__ */ new Set([...Object.keys(s), ...Object.keys(d)]))
129
- if (!(s[i]?.href === d[i]?.href && s[i]?.title === d[i]?.title))
130
- for (const c of x.get(i) ?? [])
140
+ for (const r of /* @__PURE__ */ new Set([...Object.keys(s), ...Object.keys(p)]))
141
+ if (!(s[r]?.href === p[r]?.href && s[r]?.title === p[r]?.title))
142
+ for (const c of m.get(r) ?? [])
131
143
  c.start < t && u.add(c);
132
- for (const i of u) {
133
- const c = F(i.token.raw, d);
134
- c.length === 1 && (i.token = c[0], a.push({ kind: "replace", block: $(i) }));
144
+ for (const r of u) {
145
+ const c = F(r.token.raw, p);
146
+ c.length === 1 && (r.token = c[0], a.push({ kind: "replace", block: $(r) }));
135
147
  }
136
- const N = o;
148
+ const P = o;
137
149
  o = Math.max(0, l.length - 1), l[o]?.token.type === "space" ? o = Math.max(0, o - 1) : o > 0 && !l[o - 1].token.raw.endsWith(`
138
150
 
139
151
  `) && (l[o - 1]?.token.type !== "space" ? o-- : /\n[ \t]*\n/u.test(l[o - 1].token.raw) || (o = Math.max(0, o - 2)));
140
- const w = l.at(-1)?.token;
141
- o > 1 && l[o - 1]?.token.type === "space" && l[o - 2]?.token.type === "list" && (w?.type === "list" || w?.type === "paragraph" && /^ {0,3}(?:[0-9]{1,9}[.)]?|[-+*])[ \t]*$/u.test(w.raw)) && (o -= 2);
142
- for (let i = N; i < o; i++) {
143
- const c = l[i].token;
144
- c.type === "def" && !y[c.tag] && (y[c.tag] = { href: c.href, title: c.title });
152
+ const y = l.at(-1)?.token;
153
+ o > 1 && l[o - 1]?.token.type === "space" && l[o - 2]?.token.type === "list" && (y?.type === "list" || y?.type === "paragraph" && /^ {0,3}(?:[0-9]{1,9}[.)]?|[-+*])[ \t]*$/u.test(y.raw)) && (o -= 2);
154
+ for (let r = P; r < o; r++) {
155
+ const c = l[r].token;
156
+ c.type === "def" && !v[c.tag] && (v[c.tag] = { href: c.href, title: c.title });
145
157
  }
146
- return B(), m(a);
158
+ return G(), w(a);
147
159
  }
148
160
  function J(e) {
149
161
  const t = I && e.startsWith(`
@@ -151,9 +163,9 @@ function V(O) {
151
163
  return I = e.endsWith("\r"), (t ? e.slice(1) : e).replace(/\r\n?/g, `
152
164
  `);
153
165
  }
154
- function G(e) {
155
- if (!e) return m([]);
156
- if (C += e.length, e = J(e), !e) return m([]);
166
+ function H(e) {
167
+ if (!e) return w([]);
168
+ if (C += e.length, e = J(e), !e) return w([]);
157
169
  b.push({ start: L, text: e }), L += e.length;
158
170
  const t = l.at(-1), n = t?.token;
159
171
  if (t && o === l.length - 1 && n?.type === "code" && g && !e.includes("\r") && !E(e, g)) {
@@ -161,85 +173,86 @@ function V(O) {
161
173
  ` : "") + (e.endsWith(`
162
174
  `) ? e.slice(0, -1) : e);
163
175
  return g.pendingNewline = e.endsWith(`
164
- `), n.raw += e, n.text += s, m(s ? [{ kind: "append_text", id: t.id, text: s, code: !0 }] : []);
176
+ `), n.raw += e, n.text += s, w(s ? [{ kind: "append_text", id: t.id, text: s, code: !0 }] : []);
165
177
  }
166
- const r = n?.type === "paragraph" ? n : void 0;
167
- if (t && o === l.length - 1 && r && v && M && !/[\n\r]/u.test(e)) {
168
- const s = v, a = r.tokens.at(-1), p = a?.type === "text" && s.from === r.tokens.length - 1 && !/[\\\x60*_[\]<>~&:/.@;|="'()-]/u.test(e) && !/[\\\x60*_[\]<>~&:/.@;|="'()-]$/u.test(s.lastChar);
169
- if (r.raw += e, r.text += e, p) {
170
- const c = a, h = s.unresolved ? -1 : e.lastIndexOf(" "), k = h > 0 ? e.slice(0, h) : h === 0 ? "" : e, T = [], A = r.tokens.length - 1;
171
- if (k && (c.raw += k, c.text += k, T.push({
178
+ const i = n?.type === "paragraph" ? n : void 0;
179
+ if (t && o === l.length - 1 && i && O && S && !/[\n\r]/u.test(e)) {
180
+ const s = O, a = i.tokens.at(-1), d = a?.type === "text" && s.from === i.tokens.length - 1 && !z(e) && !s.extensionPending && !/[\\\x60*_[\]<>~&:/.@;|="'()-]/u.test(e) && !/[\\\x60*_[\]<>~&:/.@;|="'()-]$/u.test(s.lastChar);
181
+ if (i.raw += e, i.text += e, d) {
182
+ const c = a, h = s.unresolved ? -1 : e.lastIndexOf(" "), x = h > 0 ? e.slice(0, h) : h === 0 ? "" : e, T = [], A = i.tokens.length - 1;
183
+ if (x && (c.raw += x, c.text += x, T.push({
172
184
  kind: "append_text",
173
185
  id: t.id,
174
- text: k,
186
+ text: x,
175
187
  code: !1,
176
188
  inlineIndex: A
177
189
  })), h >= 0) {
178
- const j = e.slice(h), P = { type: "text", raw: j, text: j };
179
- r.tokens.push(P), T.push({
190
+ const j = e.slice(h), D = { type: "text", raw: j, text: j };
191
+ i.tokens.push(D), T.push({
180
192
  kind: "inline",
181
193
  id: t.id,
182
194
  from: A + 1,
183
195
  deleteCount: 0,
184
- tokens: [structuredClone(P)]
185
- }), v = {
196
+ tokens: [structuredClone(D)]
197
+ }), O = {
186
198
  from: A + 1,
187
199
  source: j,
188
200
  unresolved: !1,
201
+ extensionPending: !1,
189
202
  lastChar: j.slice(-1)
190
203
  };
191
204
  } else
192
205
  s.source += e, s.lastChar = e.slice(-1);
193
- return m(T);
206
+ return w(T);
194
207
  }
195
- const f = new O.Lexer({ ...O.defaults });
196
- f.tokens.links = d;
208
+ const f = new k.Lexer({ ...k.defaults });
209
+ f.tokens.links = p;
197
210
  const u = s.source + e;
198
211
  W += u.length;
199
- const N = f.inlineTokens(u), w = r.tokens.length - s.from;
200
- r.tokens.splice(s.from, w, ...N), z(r, s.from);
201
- const i = r.tokens.slice(s.from);
202
- return m([
212
+ const P = f.inlineTokens(u), y = i.tokens.length - s.from;
213
+ i.tokens.splice(s.from, y, ...P), _(i, s.from);
214
+ const r = i.tokens.slice(s.from);
215
+ return w([
203
216
  {
204
217
  kind: "inline",
205
218
  id: t.id,
206
219
  from: s.from,
207
- deleteCount: w,
208
- tokens: structuredClone(i)
220
+ deleteCount: y,
221
+ tokens: structuredClone(r)
209
222
  }
210
223
  ]);
211
224
  }
212
- return _();
225
+ return N();
213
226
  }
214
- function H(e = "") {
227
+ function K(e = "") {
215
228
  const t = l.map((s) => ({
216
229
  kind: "remove",
217
230
  id: s.id
218
231
  }));
219
232
  C = e.length, I = !1;
220
233
  const n = J(e);
221
- L = n.length, b = n ? [{ start: 0, text: n }] : [], l = [], d = /* @__PURE__ */ Object.create(null), y = /* @__PURE__ */ Object.create(null), x.clear(), o = 0, g = void 0, S++;
222
- const r = _();
223
- return { ...r, changes: [...t, ...r.changes] };
234
+ L = n.length, b = n ? [{ start: 0, text: n }] : [], l = [], p = /* @__PURE__ */ Object.create(null), v = /* @__PURE__ */ Object.create(null), m.clear(), o = 0, g = void 0, M++;
235
+ const i = N();
236
+ return { ...i, changes: [...t, ...i.changes] };
224
237
  }
225
- function K() {
238
+ function Q() {
226
239
  const e = l.map((t) => structuredClone(t.token));
227
- return e.links = { ...d }, e;
240
+ return e.links = { ...p }, e;
228
241
  }
229
- function Q() {
230
- return S++, o = 0, y = /* @__PURE__ */ Object.create(null), _(!0);
242
+ function V() {
243
+ return M++, o = 0, v = /* @__PURE__ */ Object.create(null), N(!0);
231
244
  }
232
245
  return {
233
- append: G,
234
- reset: H,
235
- finish: Q,
236
- snapshot: K,
246
+ append: H,
247
+ reset: K,
248
+ finish: V,
249
+ snapshot: Q,
237
250
  get sourceLength() {
238
251
  return C;
239
252
  },
240
- diagnostics: () => ({ fullParses: S, parsedCharacters: W, blocks: l.length })
253
+ diagnostics: () => ({ fullParses: M, parsedCharacters: W, blocks: l.length })
241
254
  };
242
255
  }
243
256
  export {
244
- V as createIncrementalMarkdownParser
257
+ X as createIncrementalMarkdownParser
245
258
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floegence/floe-webapp-core",
3
- "version": "0.86.48",
3
+ "version": "0.86.49",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",