@floegence/floe-webapp-core 0.86.48 → 0.86.50

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