@burdenoff/fe-libs 2026.1115.7 → 2026.1115.9
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.
- package/dist/shared/assistant/i18nManifest.d.ts +6 -4
- package/dist/shared/assistant/i18nManifest.js +6 -4
- package/dist/shared/assistant/index.d.ts +1 -0
- package/dist/shared/assistant/ui/AssistantChatArea.js +1108 -1107
- package/dist/shared/assistant/ui/AssistantSpeechProvider.js +16 -6
- package/dist/shared/assistant/voice/phraseGate.js +2 -0
- package/dist/shared/assistant/voice/revealSpoken.d.ts +14 -0
- package/dist/shared/assistant/voice/revealSpoken.js +28 -0
- package/dist/shared/assistant/voice/speakableText.d.ts +27 -3
- package/dist/shared/assistant/voice/speakableText.js +149 -120
- package/dist/shared/assistant/voice/speechLabels.js +28 -16
- package/dist/shared/providers/shell/I18nProvider.d.ts +2 -1
- package/dist/shared/providers/shell/I18nProvider.js +42 -42
- package/dist/shared-assistant.js +396 -395
- package/package.json +1 -1
|
@@ -26,8 +26,10 @@ import { jsx as we } from "react/jsx-runtime";
|
|
|
26
26
|
// src/shared/assistant/ui/AssistantSpeechProvider.tsx
|
|
27
27
|
var Te = {
|
|
28
28
|
codeBlock: "",
|
|
29
|
+
codeBlockAgain: "",
|
|
29
30
|
image: "",
|
|
30
31
|
link: "",
|
|
32
|
+
linkTo: "",
|
|
31
33
|
largeTable: "",
|
|
32
34
|
truncated: "",
|
|
33
35
|
emailAt: "at",
|
|
@@ -111,10 +113,12 @@ var O = ({ children: s, visible: u = !0, engine: be }) => {
|
|
|
111
113
|
q,
|
|
112
114
|
N
|
|
113
115
|
]), nt = C(() => ({
|
|
114
|
-
codeBlock: D("speech.codeBlock", "
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
codeBlock: D("speech.codeBlock", "There’s a code example on screen"),
|
|
117
|
+
codeBlockAgain: D("speech.codeBlockAgain", "There’s another code example on screen"),
|
|
118
|
+
image: D("speech.image", "an image"),
|
|
119
|
+
link: D("speech.link", "a link"),
|
|
120
|
+
linkTo: D("speech.linkTo", "a link to {{site}}"),
|
|
121
|
+
largeTable: D("speech.largeTable", "There’s a table on screen with {{rows}} rows: {{headers}}"),
|
|
118
122
|
truncated: D("speech.truncated", "The rest of this message is not read aloud"),
|
|
119
123
|
nestedItem: D("speech.nestedItem", "Sub-item {{ordinal}}"),
|
|
120
124
|
emailAt: D("speech.emailAt", "at"),
|
|
@@ -299,7 +303,10 @@ var O = ({ children: s, visible: u = !0, engine: be }) => {
|
|
|
299
303
|
}, [ct]);
|
|
300
304
|
let Z = x((e, t, n, r) => {
|
|
301
305
|
if (!G) return;
|
|
302
|
-
let i = m(d(t, { labels: Te }), n ?? J), a = d(t, {
|
|
306
|
+
let i = m(d(t, { labels: Te }), n ?? J), a = d(t, {
|
|
307
|
+
labels: p(i, nt),
|
|
308
|
+
locale: i
|
|
309
|
+
});
|
|
303
310
|
a && ct(e, a, j, i, r?.auto === !0, r?.firstChunkMaxChars, r?.phraseStream);
|
|
304
311
|
}, [
|
|
305
312
|
G,
|
|
@@ -447,7 +454,10 @@ var O = ({ children: s, visible: u = !0, engine: be }) => {
|
|
|
447
454
|
if (!i.autoSpeakEnabled && !i.sessionSpeaking || !i.visible || !i.isSupported || r.channel === "voice" !== i.sessionSpeaking || fe(n) || Ge.current || t.getState().activeConversationId !== r.conversationId || dt.current !== r.conversationId) return;
|
|
448
455
|
let a = R.current;
|
|
449
456
|
if (a?.messageId === n && a.requestId === F.current) {
|
|
450
|
-
let t = d(e.type === "append" ? e.phrases.join(" ") : ve(r.text).text, {
|
|
457
|
+
let t = d(e.type === "append" ? e.phrases.join(" ") : ve(r.text).text, {
|
|
458
|
+
labels: p(a.locale, nt),
|
|
459
|
+
locale: a.locale
|
|
460
|
+
});
|
|
451
461
|
e.type === "append" ? a.playback.append(t) : a.playback.finish(t);
|
|
452
462
|
return;
|
|
453
463
|
}
|
|
@@ -2,8 +2,10 @@ import { MAX_SPEAKABLE_CHARS as e, toSpeakableText as t } from "./speakableText.
|
|
|
2
2
|
// src/shared/assistant/voice/phraseGate.ts
|
|
3
3
|
var n = /(?:\b(?:mr|mrs|ms|dr|prof|sr|jr|st|vs|etc|e\.g|i\.e)|\b[A-Z])\.$/i, r = /^(?:thinking|working|one moment|just a moment|sure|certainly|let me (?:check|think|look)|सोच रहा हूँ|சிந்திக்கிறேன்|أفكر|思考中)[\s.!…।॥。]*$/iu, i = /^\s*(?:\||[-*+]\s|\d+[.)]\s|[[{])/, a = {
|
|
4
4
|
codeBlock: "",
|
|
5
|
+
codeBlockAgain: "",
|
|
5
6
|
image: "",
|
|
6
7
|
link: "",
|
|
8
|
+
linkTo: "",
|
|
7
9
|
largeTable: "",
|
|
8
10
|
truncated: "",
|
|
9
11
|
emailAt: "",
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SpeakableLabels } from './speakableText';
|
|
2
|
+
/** One block of a reply: its text and where it ends in the reply. */
|
|
3
|
+
export interface MarkdownBlock {
|
|
4
|
+
text: string;
|
|
5
|
+
end: number;
|
|
6
|
+
}
|
|
7
|
+
/** The reply's blocks, split at blank lines but never inside a fenced code block. */
|
|
8
|
+
export declare function markdownBlocks(markdown: string): MarkdownBlock[];
|
|
9
|
+
/**
|
|
10
|
+
* The part of `markdown` to show once `spokenChars` characters of its speech text
|
|
11
|
+
* have been reached: every block the speech has got to, the one being spoken
|
|
12
|
+
* included, as the reply's own text. Nothing before the first word.
|
|
13
|
+
*/
|
|
14
|
+
export declare function revealSpokenMarkdown(markdown: string, spokenChars: number, labels?: Partial<SpeakableLabels>): string;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { toSpeakableText as e } from "./speakableText.js";
|
|
2
|
+
// src/shared/assistant/voice/revealSpoken.ts
|
|
3
|
+
var t = /^\s{0,3}(`{3,}|~{3,})/;
|
|
4
|
+
function n(e) {
|
|
5
|
+
let n = [], r = -1, i = 0, a = null, o = 0, s = () => {
|
|
6
|
+
r >= 0 && n.push({
|
|
7
|
+
text: e.slice(r, i),
|
|
8
|
+
end: i
|
|
9
|
+
}), r = -1;
|
|
10
|
+
};
|
|
11
|
+
for (let n of e.split("\n")) {
|
|
12
|
+
let e = o + n.length, c = t.exec(n);
|
|
13
|
+
a === null ? c ? (r < 0 && (r = o), a = c[1], i = e) : n.trim() ? (r < 0 && (r = o), i = e) : s() : (i = e, c && c[1][0] === a[0] && c[1].length >= a.length && (a = null)), o = e + 1;
|
|
14
|
+
}
|
|
15
|
+
return s(), n;
|
|
16
|
+
}
|
|
17
|
+
function r(t, r, i) {
|
|
18
|
+
if (r <= 0) return "";
|
|
19
|
+
let a = n(t), o = 0, s = 0;
|
|
20
|
+
for (let t of a) {
|
|
21
|
+
if (o >= r) break;
|
|
22
|
+
s = t.end;
|
|
23
|
+
let n = e(t.text, { labels: i }).length;
|
|
24
|
+
o += n > 0 ? n + 1 : 0;
|
|
25
|
+
}
|
|
26
|
+
return t.slice(0, s).trimEnd();
|
|
27
|
+
}
|
|
28
|
+
export { n as markdownBlocks, r as revealSpokenMarkdown };
|
|
@@ -23,13 +23,29 @@
|
|
|
23
23
|
* Every rule below uses a captured prefix or a lookahead instead.
|
|
24
24
|
*/
|
|
25
25
|
export interface SpeakableLabels {
|
|
26
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* Spoken in place of a reply's FIRST code block, which is unlistenable read
|
|
28
|
+
* out. ★ BOFF-14445: says what is there and where ("There's a code example on
|
|
29
|
+
* screen"), never a bare placeholder like "Code block".
|
|
30
|
+
*/
|
|
27
31
|
codeBlock: string;
|
|
32
|
+
/** Spoken in place of each further code block ("There's another code example on screen"). */
|
|
33
|
+
codeBlockAgain: string;
|
|
28
34
|
/** Spoken for an image with no alt text. */
|
|
29
35
|
image: string;
|
|
30
|
-
/** Spoken in place of a
|
|
36
|
+
/** Spoken in place of a link with no text and no readable site. */
|
|
31
37
|
link: string;
|
|
32
|
-
/**
|
|
38
|
+
/**
|
|
39
|
+
* Spoken in place of a bare URL: its site, never the path ("a link to
|
|
40
|
+
* example.com"). Nobody wants "h t t p s colon slash slash". Param: site.
|
|
41
|
+
*/
|
|
42
|
+
linkTo: string;
|
|
43
|
+
/**
|
|
44
|
+
* Spoken in place of a table too large to read: how big it is and what its
|
|
45
|
+
* columns are, so the person knows what to look at. Params: rows, columns,
|
|
46
|
+
* headers. Keep `{{headers}}` LAST: with no header text it is dropped together
|
|
47
|
+
* with the punctuation before it.
|
|
48
|
+
*/
|
|
33
49
|
largeTable: string;
|
|
34
50
|
/** Appended when a very long reply is cut short. */
|
|
35
51
|
truncated: string;
|
|
@@ -97,7 +113,15 @@ export interface SpeakableOptions {
|
|
|
97
113
|
labels?: Partial<SpeakableLabels>;
|
|
98
114
|
maxChars?: number;
|
|
99
115
|
maxSpokenTableRows?: number;
|
|
116
|
+
/** The reply's language (BCP-47), for joining a table's column names as a list. Default English. */
|
|
117
|
+
locale?: string;
|
|
100
118
|
}
|
|
119
|
+
/** At most this many column names are said for a table too large to read. */
|
|
120
|
+
export declare const MAX_SPOKEN_TABLE_HEADERS = 5;
|
|
121
|
+
/** "Name, Status and Owner", in the reply's language where the browser knows how. */
|
|
122
|
+
export declare function joinSpokenList(items: readonly string[], locale?: string): string;
|
|
123
|
+
/** "a link to example.com" for a URL; "a link" when it has no readable site. */
|
|
124
|
+
export declare function speakableLink(url: string, labels: Pick<SpeakableLabels, 'link' | 'linkTo'>): string;
|
|
101
125
|
/**
|
|
102
126
|
* Split a GFM table row into cells, honouring `\|` escapes.
|
|
103
127
|
*
|
|
@@ -1,22 +1,45 @@
|
|
|
1
1
|
// src/shared/assistant/voice/speakableText.ts
|
|
2
2
|
var e = {
|
|
3
|
-
codeBlock: "
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
codeBlock: "There’s a code example on screen",
|
|
4
|
+
codeBlockAgain: "There’s another code example on screen",
|
|
5
|
+
image: "an image",
|
|
6
|
+
link: "a link",
|
|
7
|
+
linkTo: "a link to {{site}}",
|
|
8
|
+
largeTable: "There’s a table on screen with {{rows}} rows: {{headers}}",
|
|
7
9
|
truncated: "The rest of this message is not read aloud",
|
|
8
10
|
nestedItem: "Sub-item {{ordinal}}",
|
|
9
11
|
emailAt: "at",
|
|
10
12
|
emailDot: "dot"
|
|
11
|
-
}, t = 3, n = 8e3, r = 180, i = 40, a = 110, o = 40, s =
|
|
12
|
-
function
|
|
13
|
+
}, t = 3, n = 8e3, r = 180, i = 40, a = 110, o = 40, s = 5;
|
|
14
|
+
function c(e, t = "en") {
|
|
15
|
+
let n = e.map((e) => e.trim()).filter(Boolean);
|
|
16
|
+
if (n.length < 2) return n.join("");
|
|
17
|
+
try {
|
|
18
|
+
if (typeof Intl < "u" && typeof Intl.ListFormat == "function") return new Intl.ListFormat(t, {
|
|
19
|
+
style: "long",
|
|
20
|
+
type: "conjunction"
|
|
21
|
+
}).format(n);
|
|
22
|
+
} catch {}
|
|
23
|
+
return n.join(", ");
|
|
24
|
+
}
|
|
25
|
+
function l(e, t) {
|
|
26
|
+
let n = "";
|
|
27
|
+
try {
|
|
28
|
+
n = new URL(e).hostname.replace(/^www\./i, "");
|
|
29
|
+
} catch {
|
|
30
|
+
n = "";
|
|
31
|
+
}
|
|
32
|
+
return n ? v(t.linkTo, { site: n }) : t.link;
|
|
33
|
+
}
|
|
34
|
+
var u = /^\s{0,3}(?:`{3,}|~{3,})/, d = /^\s{0,3}#{1,6}\s+(.*)$/, ee = /^\s{0,3}([-*_])(?:\s*\1){2,}\s*$/, f = /^\s{0,3}(?:>\s?)+/, p = /^(\s*)(?:[-*+]|(\d{1,9})[.)])\s+/, m = /^\[[ xX]\]\s*/, h = /[.!?…⋯:;。!?;.।॥۔؟؛]$/, g = /^\s{0,3}=+\s*$/, _ = /^(?: {4}|\t)/;
|
|
35
|
+
function v(e, t) {
|
|
13
36
|
return Object.entries(t).reduce((e, [t, n]) => e.replace(RegExp(`\\{\\{${t}\\}\\}`, "g"), String(n)), e);
|
|
14
37
|
}
|
|
15
|
-
function
|
|
38
|
+
function y(e) {
|
|
16
39
|
let t = e.trim();
|
|
17
40
|
return t.includes("|") && t.includes("-") && /^[\s:|-]+$/.test(t);
|
|
18
41
|
}
|
|
19
|
-
function
|
|
42
|
+
function b(e) {
|
|
20
43
|
let t = e.trim().replace(/^\|/, "").replace(/\|$/, ""), n = [], r = "";
|
|
21
44
|
for (let e = 0; e < t.length; e += 1) {
|
|
22
45
|
let i = t[e];
|
|
@@ -24,7 +47,7 @@ function v(e) {
|
|
|
24
47
|
}
|
|
25
48
|
return n.push(r), n.map((e) => e.trim());
|
|
26
49
|
}
|
|
27
|
-
var
|
|
50
|
+
var x = {
|
|
28
51
|
"&": " and ",
|
|
29
52
|
"<": " less than ",
|
|
30
53
|
">": " greater than ",
|
|
@@ -32,132 +55,138 @@ var y = {
|
|
|
32
55
|
"'": "'",
|
|
33
56
|
"'": "'",
|
|
34
57
|
" ": " "
|
|
35
|
-
},
|
|
36
|
-
function
|
|
58
|
+
}, S = "[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(?:\\.[A-Za-z0-9-]+)+", C = RegExp(`<(?:mailto:)?(${S})>`, "g"), w = RegExp(`\\bmailto:(${S})`, "g"), T = new RegExp(S, "g");
|
|
59
|
+
function E(e, t = "at", n = "dot") {
|
|
37
60
|
return e.replace(/@/g, ` ${t} `).replace(/\./g, ` ${n} `).replace(/\s+/g, " ").trim();
|
|
38
61
|
}
|
|
39
|
-
var
|
|
40
|
-
function
|
|
41
|
-
let n = e.replace(
|
|
42
|
-
n = n.replace(/!\[([^\]]*)\]\([^)]*\)/g, (e, n) => n.trim() || ` ${t.image} `), n = n.replace(/\[([^\]]*)\]\([^)]*\)/g, (e, n) => n.trim() || ` ${t.link} `), n = n.replace(/\[([^\]]*)\]\[[^\]]*\]/g, (e, n) => n.trim() || ` ${t.link} `), n = n.replace(/<https?:\/\/[^>\s]
|
|
43
|
-
|
|
44
|
-
|
|
62
|
+
var D = 57600, O = /[\ue121-\ue17e]/g, k = "", A = /\ue180/g, j = /[\ue100-\ue1ff]/g;
|
|
63
|
+
function M(e, t) {
|
|
64
|
+
let n = e.replace(j, "").replace(/\\[!-/:-@[-`{-~]|(`+)[^`]*?\1(?!`)/g, (e, t) => t ? e.replace(/\\/g, k) : e).replace(/\\([!-/:-@[-`{-~])/g, (e, t) => String.fromCharCode(D + t.charCodeAt(0)));
|
|
65
|
+
n = n.replace(/!\[([^\]]*)\]\([^)]*\)/g, (e, n) => n.trim() || ` ${t.image} `), n = n.replace(/\[([^\]]*)\]\([^)]*\)/g, (e, n) => n.trim() || ` ${t.link} `), n = n.replace(/\[([^\]]*)\]\[[^\]]*\]/g, (e, n) => n.trim() || ` ${t.link} `), n = n.replace(/<(https?:\/\/[^>\s]+)>/g, (e, n) => ` ${l(n, t)} `), n = n.replace(/\bhttps?:\/\/\S+/g, (e) => {
|
|
66
|
+
let n = e.replace(/[.,;:!?)\]]+$/, ""), r = e.slice(n.length).replace(/[)\]]/g, "");
|
|
67
|
+
return ` ${l(n, t)}${r} `;
|
|
68
|
+
}), n = n.replace(C, (e, n) => ` ${E(n, t.emailAt, t.emailDot)} `), n = n.replace(w, (e, n) => ` ${E(n, t.emailAt, t.emailDot)} `), n = n.replace(T, (e) => ` ${E(e, t.emailAt, t.emailDot)} `), n = n.replace(/`+([^`]*)`+/g, (e, t) => t), n = n.replace(/<\/?[a-zA-Z][^>]*>/g, " ");
|
|
69
|
+
for (let [e, t] of Object.entries(x)) n = n.split(e).join(t);
|
|
70
|
+
return n = n.replace(/(\*\*\*|___)(\S(?:[\s\S]*?\S)?)\1/g, "$2"), n = n.replace(/(\*\*|__)(\S(?:[\s\S]*?\S)?)\1/g, "$2"), n = n.replace(/~~(\S(?:[\s\S]*?\S)?)~~/g, "$1"), n = n.replace(/(^|[\s([{"'])\*(\S(?:[\s\S]*?\S)?)\*(?=$|[\s)\]}"'.,!?;:])/g, "$1$2"), n = n.replace(/(^|[\s([{"'])_(\S(?:[\s\S]*?\S)?)_(?=$|[\s)\]}"'.,!?;:])/g, "$1$2"), n = n.replace(/[\p{Extended_Pictographic}\uFE0F\u200D]/gu, " "), n = n.replace(/[•·▪▫◦‣⁃∙●○■□▶▸►➤➜→←↑↓⇒⇔★☆⭐✦✧✓✔✗✘✕✖]/gu, " "), n = n.replace(/(\d)?\s*[—–―]\s*(\d)?/g, (e, t, n) => t !== void 0 && n !== void 0 ? e : `${t ?? ""}, ${n ?? ""}`), n = n.replace(/\*{2,}/g, ""), n.replace(/\s+/g, " ").replace(/\s+([.,!?;:)\]}])/g, "$1").replace(/([([{])\s+/g, "$1").trim().replace(O, (e) => String.fromCharCode(e.charCodeAt(0) - D)).replace(A, "\\");
|
|
45
71
|
}
|
|
46
|
-
function
|
|
72
|
+
function N(e) {
|
|
47
73
|
let t = e.trim();
|
|
48
|
-
return t ?
|
|
74
|
+
return t ? h.test(t) ? t : `${t}.` : "";
|
|
49
75
|
}
|
|
50
|
-
function
|
|
76
|
+
function P(e, t, n) {
|
|
51
77
|
if (e.length <= t) return e;
|
|
52
78
|
let r = e.slice(0, t), i = Math.max(r.lastIndexOf(". "), r.lastIndexOf("\n")), a = r.lastIndexOf(" "), o = i > t * .5 ? i + 1 : a > 0 ? a : t;
|
|
53
79
|
return `${r.slice(0, o).trim()}\n${n}`;
|
|
54
80
|
}
|
|
55
|
-
function
|
|
81
|
+
function F(e) {
|
|
56
82
|
let t = 0;
|
|
57
83
|
for (let n of e) t += n === " " ? 4 : 1;
|
|
58
84
|
return t;
|
|
59
85
|
}
|
|
60
|
-
function
|
|
86
|
+
function I(e, t) {
|
|
61
87
|
let n = e[e.length - 1];
|
|
62
88
|
if (!n?.ordinal) return "";
|
|
63
89
|
if (e.length === 1) return `${n.ordinal}. `;
|
|
64
90
|
let r = e.map((e) => e.ordinal);
|
|
65
|
-
return r.every((e) => !!e) ? `${r.join(".")}. ` : `${
|
|
91
|
+
return r.every((e) => !!e) ? `${r.join(".")}. ` : `${v(t.nestedItem, { ordinal: n.ordinal })}. `;
|
|
66
92
|
}
|
|
67
|
-
function
|
|
93
|
+
function L(t, n = {}) {
|
|
68
94
|
let r = {
|
|
69
95
|
...e,
|
|
70
96
|
...n.labels
|
|
71
|
-
}, i = n.maxChars ?? 8e3, a = n.maxSpokenTableRows ?? 3;
|
|
97
|
+
}, i = n.maxChars ?? 8e3, a = n.maxSpokenTableRows ?? 3, o = n.locale ?? "en", s = 0;
|
|
72
98
|
if (!t) return "";
|
|
73
|
-
let
|
|
74
|
-
for (;
|
|
75
|
-
let e =
|
|
76
|
-
if (
|
|
77
|
-
for (
|
|
78
|
-
|
|
99
|
+
let l = t.replace(/\r\n?/g, "\n").split("\n"), h = [], x = [], S = 0;
|
|
100
|
+
for (; S < l.length;) {
|
|
101
|
+
let e = l[S].replace(f, ""), t = S === 0 || !l[S - 1].replace(f, "").trim();
|
|
102
|
+
if (u.test(e)) {
|
|
103
|
+
for (S += 1; S < l.length && !u.test(l[S].replace(f, ""));) S += 1;
|
|
104
|
+
S += 1, h.push(N(s++ === 0 ? r.codeBlock : r.codeBlockAgain));
|
|
79
105
|
continue;
|
|
80
106
|
}
|
|
81
|
-
if (t &&
|
|
82
|
-
for (
|
|
83
|
-
let e =
|
|
84
|
-
if (e.trim() &&
|
|
85
|
-
|
|
107
|
+
if (t && x.length === 0 && e.trim() && _.test(e)) {
|
|
108
|
+
for (S += 1; S < l.length;) {
|
|
109
|
+
let e = l[S].replace(f, "");
|
|
110
|
+
if (e.trim() && _.test(e)) {
|
|
111
|
+
S += 1;
|
|
86
112
|
continue;
|
|
87
113
|
}
|
|
88
114
|
if (e.trim()) break;
|
|
89
|
-
let t =
|
|
90
|
-
for (; t <
|
|
91
|
-
let n = t <
|
|
92
|
-
if (!n.trim() || !
|
|
93
|
-
|
|
115
|
+
let t = S;
|
|
116
|
+
for (; t < l.length && !l[t].replace(f, "").trim();) t += 1;
|
|
117
|
+
let n = t < l.length ? l[t].replace(f, "") : "";
|
|
118
|
+
if (!n.trim() || !_.test(n)) break;
|
|
119
|
+
S = t;
|
|
94
120
|
}
|
|
95
|
-
|
|
121
|
+
h.push(N(s++ === 0 ? r.codeBlock : r.codeBlockAgain));
|
|
96
122
|
continue;
|
|
97
123
|
}
|
|
98
|
-
if (
|
|
99
|
-
|
|
124
|
+
if (ee.test(e) || g.test(e)) {
|
|
125
|
+
S += 1;
|
|
100
126
|
continue;
|
|
101
127
|
}
|
|
102
|
-
let n =
|
|
103
|
-
if (e.includes("|") &&
|
|
104
|
-
|
|
105
|
-
let t =
|
|
106
|
-
|
|
128
|
+
let n = S + 1 < l.length ? l[S + 1].replace(f, "") : "";
|
|
129
|
+
if (e.includes("|") && y(n)) {
|
|
130
|
+
x.length = 0;
|
|
131
|
+
let t = b(e).map((e) => M(e, r));
|
|
132
|
+
S += 2;
|
|
107
133
|
let n = [];
|
|
108
|
-
for (;
|
|
109
|
-
let e =
|
|
134
|
+
for (; S < l.length;) {
|
|
135
|
+
let e = l[S].replace(f, "");
|
|
110
136
|
if (!e.includes("|") || !e.trim()) break;
|
|
111
|
-
n.push(
|
|
137
|
+
n.push(b(e).map((e) => M(e, r))), S += 1;
|
|
112
138
|
}
|
|
113
|
-
if (n.length > a)
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
139
|
+
if (n.length > a) {
|
|
140
|
+
let e = c(t.slice(0, 5), o), i = v(r.largeTable, {
|
|
141
|
+
rows: n.length,
|
|
142
|
+
columns: t.length,
|
|
143
|
+
headers: e
|
|
144
|
+
});
|
|
145
|
+
h.push(N(e ? i : i.replace(/[\s::،,]+$/u, "")));
|
|
146
|
+
} else for (let e of n) {
|
|
118
147
|
let n = e.map((e, n) => {
|
|
119
148
|
if (!e) return "";
|
|
120
149
|
let r = t[n];
|
|
121
150
|
return r ? `${r}: ${e}` : e;
|
|
122
151
|
}).filter(Boolean);
|
|
123
|
-
n.length &&
|
|
152
|
+
n.length && h.push(N(n.join(", ")));
|
|
124
153
|
}
|
|
125
154
|
continue;
|
|
126
155
|
}
|
|
127
|
-
if (
|
|
128
|
-
let i =
|
|
156
|
+
if (S += 1, !e.trim()) continue;
|
|
157
|
+
let i = d.exec(e);
|
|
129
158
|
if (i) {
|
|
130
|
-
|
|
131
|
-
let e =
|
|
132
|
-
e &&
|
|
159
|
+
x.length = 0;
|
|
160
|
+
let e = M(i[1].replace(/\s+#+\s*$/, ""), r);
|
|
161
|
+
e && h.push(N(e));
|
|
133
162
|
continue;
|
|
134
163
|
}
|
|
135
|
-
let
|
|
136
|
-
if (
|
|
137
|
-
|
|
138
|
-
let t =
|
|
139
|
-
for (;
|
|
140
|
-
|
|
164
|
+
let C = p.exec(e), w = e, T = "";
|
|
165
|
+
if (C) {
|
|
166
|
+
w = e.slice(C[0].length).replace(m, "");
|
|
167
|
+
let t = F(C[1]);
|
|
168
|
+
for (; x.length > 0 && x[x.length - 1].indent >= t;) x.pop();
|
|
169
|
+
x.push({
|
|
141
170
|
indent: t,
|
|
142
|
-
ordinal:
|
|
143
|
-
}),
|
|
144
|
-
} else /^\s/.test(e) || (
|
|
145
|
-
if (!
|
|
146
|
-
|
|
147
|
-
let t =
|
|
148
|
-
t &&
|
|
171
|
+
ordinal: C[2] ?? null
|
|
172
|
+
}), T = I(x, r);
|
|
173
|
+
} else /^\s/.test(e) || (x.length = 0);
|
|
174
|
+
if (!C && g.test(n)) {
|
|
175
|
+
x.length = 0, S += 1;
|
|
176
|
+
let t = M(e, r);
|
|
177
|
+
t && h.push(N(t));
|
|
149
178
|
continue;
|
|
150
179
|
}
|
|
151
|
-
let
|
|
152
|
-
|
|
180
|
+
let E = M(w, r);
|
|
181
|
+
E && h.push(N(`${T}${E}`));
|
|
153
182
|
}
|
|
154
|
-
return
|
|
183
|
+
return P(h.join("\n").replace(/\n{2,}/g, "\n").trim(), i, N(r.truncated));
|
|
155
184
|
}
|
|
156
|
-
var
|
|
185
|
+
var R = /* @__PURE__ */ new Set([
|
|
157
186
|
".",
|
|
158
187
|
"!",
|
|
159
188
|
"?"
|
|
160
|
-
]),
|
|
189
|
+
]), z = /* @__PURE__ */ new Set([
|
|
161
190
|
"。",
|
|
162
191
|
"!",
|
|
163
192
|
"?",
|
|
@@ -171,7 +200,7 @@ var I = /* @__PURE__ */ new Set([
|
|
|
171
200
|
"۔",
|
|
172
201
|
"؟",
|
|
173
202
|
"؛"
|
|
174
|
-
]),
|
|
203
|
+
]), B = /* @__PURE__ */ new Set([
|
|
175
204
|
"\"",
|
|
176
205
|
"'",
|
|
177
206
|
")",
|
|
@@ -186,25 +215,25 @@ var I = /* @__PURE__ */ new Set([
|
|
|
186
215
|
"』",
|
|
187
216
|
"】",
|
|
188
217
|
")"
|
|
189
|
-
]),
|
|
218
|
+
]), V = /* @__PURE__ */ new Set(/* @__PURE__ */ "i.e,e.g,etc,approx,vs,cf,viz,al,est,dept,fig,figs,ref,min,max,avg,qty,temp,mr,mrs,ms,dr,prof,sr,jr,st,inc,ltd,co,corp,univ,ca,kg,mg,gm,ha,cm,mm,km,ml,lb,oz,sq,hrs,wk,yr,mo,vol,pp".split(",")), H = /* @__PURE__ */ new Set([
|
|
190
219
|
"no",
|
|
191
220
|
"nos",
|
|
192
221
|
"p",
|
|
193
222
|
"ch",
|
|
194
223
|
"sec",
|
|
195
224
|
"art"
|
|
196
|
-
]),
|
|
197
|
-
function
|
|
198
|
-
for (let r = t; r < n; r += 1) if (
|
|
225
|
+
]), U = /^\d+(?:\.\d+)*$/, W = /^[A-Za-z]$/;
|
|
226
|
+
function G(e, t, n) {
|
|
227
|
+
for (let r = t; r < n; r += 1) if (z.has(e[r])) return !0;
|
|
199
228
|
if (n < e.length && !/\s/.test(e[n])) return !1;
|
|
200
229
|
if (e[t] !== ".") return !0;
|
|
201
230
|
let r = e.slice(0, t), i = /(\S+)$/.exec(r)?.[1] ?? "";
|
|
202
231
|
if (!i) return !0;
|
|
203
|
-
if (
|
|
232
|
+
if (U.test(i) && !r.slice(0, r.length - i.length).trim()) return !1;
|
|
204
233
|
let a = i.toLowerCase();
|
|
205
|
-
return
|
|
234
|
+
return W.test(i) || V.has(a) ? !1 : !H.has(a) || !/^\s*\d/.test(e.slice(n));
|
|
206
235
|
}
|
|
207
|
-
function
|
|
236
|
+
function K(e) {
|
|
208
237
|
let t = [];
|
|
209
238
|
for (let n of e.split("\n")) {
|
|
210
239
|
let e = n.trim();
|
|
@@ -212,14 +241,14 @@ function W(e) {
|
|
|
212
241
|
let r = 0, i = 0;
|
|
213
242
|
for (; i < e.length;) {
|
|
214
243
|
let n = e[i];
|
|
215
|
-
if (!
|
|
244
|
+
if (!R.has(n) && !z.has(n)) {
|
|
216
245
|
i += 1;
|
|
217
246
|
continue;
|
|
218
247
|
}
|
|
219
248
|
let a = i;
|
|
220
|
-
for (; a < e.length && (
|
|
221
|
-
for (; a < e.length &&
|
|
222
|
-
if (
|
|
249
|
+
for (; a < e.length && (R.has(e[a]) || z.has(e[a]));) a += 1;
|
|
250
|
+
for (; a < e.length && B.has(e[a]);) a += 1;
|
|
251
|
+
if (G(e, i, a)) {
|
|
223
252
|
let n = e.slice(r, a).trim();
|
|
224
253
|
n && t.push(n), r = a;
|
|
225
254
|
}
|
|
@@ -230,38 +259,38 @@ function W(e) {
|
|
|
230
259
|
}
|
|
231
260
|
return t;
|
|
232
261
|
}
|
|
233
|
-
var
|
|
234
|
-
function
|
|
235
|
-
return
|
|
262
|
+
var q = /[\u3040-\u30ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff\uff66-\uff9f]/, J = /[\u3000-\u303f\u3040-\u30ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff\uff01-\uff9f]/, Y = /[、,,;;::。!?!?]/, X = /[A-Za-z0-9][A-Za-z0-9._,:%/+-]*[A-Za-z0-9%]|[\s\S]/gu;
|
|
263
|
+
function Z(e) {
|
|
264
|
+
return q.test(e);
|
|
236
265
|
}
|
|
237
|
-
function
|
|
266
|
+
function Q(e, t) {
|
|
238
267
|
let n = `${e.slice(-1)}${t.slice(0, 1)}`;
|
|
239
|
-
return
|
|
268
|
+
return J.test(n) ? `${e}${t}` : `${e} ${t}`;
|
|
240
269
|
}
|
|
241
|
-
function
|
|
270
|
+
function $(e, t) {
|
|
242
271
|
let n = t.trim();
|
|
243
272
|
n && e.push(n);
|
|
244
273
|
}
|
|
245
|
-
function
|
|
274
|
+
function te(e, t) {
|
|
246
275
|
let n = [], r = "", i = -1;
|
|
247
|
-
for (let a of e.match(
|
|
276
|
+
for (let a of e.match(X) ?? []) {
|
|
248
277
|
if (r.length + a.length > t && r.trim()) {
|
|
249
278
|
if (i > 0 && i < r.length && i >= t * .4) {
|
|
250
|
-
|
|
279
|
+
$(n, r.slice(0, i));
|
|
251
280
|
let e = r.slice(i);
|
|
252
|
-
e.trim().length + a.length > t ? (
|
|
253
|
-
} else
|
|
281
|
+
e.trim().length + a.length > t ? ($(n, e), r = "") : r = e;
|
|
282
|
+
} else $(n, r), r = "";
|
|
254
283
|
i = -1;
|
|
255
284
|
}
|
|
256
285
|
if (a.length > t) {
|
|
257
|
-
|
|
286
|
+
$(n, r), r = "", i = -1;
|
|
258
287
|
for (let e = 0; e < a.length; e += t) n.push(a.slice(e, e + t));
|
|
259
|
-
} else r += a,
|
|
288
|
+
} else r += a, Y.test(a) && (i = r.length);
|
|
260
289
|
}
|
|
261
|
-
return
|
|
290
|
+
return $(n, r), n;
|
|
262
291
|
}
|
|
263
|
-
function
|
|
264
|
-
if (
|
|
292
|
+
function ne(e, t) {
|
|
293
|
+
if (Z(e)) return te(e, t);
|
|
265
294
|
let n = [], r = "";
|
|
266
295
|
for (let i of e.split(/\s+/)) if (i.length > t) {
|
|
267
296
|
r &&= (n.push(r), "");
|
|
@@ -269,36 +298,36 @@ function $(e, t) {
|
|
|
269
298
|
} else r ? r.length + 1 + i.length <= t ? r = `${r} ${i}` : (n.push(r), r = i) : r = i;
|
|
270
299
|
return r && n.push(r), n;
|
|
271
300
|
}
|
|
272
|
-
function
|
|
301
|
+
function re(e, t = 180, n = 40, r = {}) {
|
|
273
302
|
let i = Math.max(1, t), a = Math.max(1, Math.min(n, i)), o = [], s = "", c = i;
|
|
274
|
-
for (let t of
|
|
275
|
-
let e =
|
|
303
|
+
for (let t of K(e)) {
|
|
304
|
+
let e = Z(t) ? a : i;
|
|
276
305
|
if (t.length > e) {
|
|
277
|
-
s &&= (o.push(s), ""), o.push(
|
|
306
|
+
s &&= (o.push(s), ""), o.push(...ne(t, e)), c = i;
|
|
278
307
|
continue;
|
|
279
308
|
}
|
|
280
309
|
if (!s) {
|
|
281
310
|
s = t, c = e;
|
|
282
311
|
continue;
|
|
283
312
|
}
|
|
284
|
-
let n =
|
|
313
|
+
let n = Q(s, t), r = Math.min(c, e);
|
|
285
314
|
n.length <= r ? (s = n, c = r) : (o.push(s), s = t, c = e);
|
|
286
315
|
}
|
|
287
316
|
if (s && o.push(s), o.length > 1 && !r.packFirstChunk) {
|
|
288
|
-
let e =
|
|
317
|
+
let e = K(o[0]);
|
|
289
318
|
if (e.length > 1) {
|
|
290
319
|
let [t, ...n] = e;
|
|
291
|
-
o.splice(0, 1, t, n.reduce((e, t) =>
|
|
320
|
+
o.splice(0, 1, t, n.reduce((e, t) => Q(e, t)));
|
|
292
321
|
}
|
|
293
322
|
}
|
|
294
323
|
if (r.firstChunkMaxChars !== void 0 && o.length > 0) {
|
|
295
|
-
let [e, t] =
|
|
324
|
+
let [e, t] = ie(o[0], r.firstChunkMaxChars);
|
|
296
325
|
t && o.splice(0, 1, e, t);
|
|
297
326
|
}
|
|
298
327
|
return o;
|
|
299
328
|
}
|
|
300
|
-
function
|
|
301
|
-
if (e.length <= t ||
|
|
329
|
+
function ie(e, t) {
|
|
330
|
+
if (e.length <= t || Z(e)) return [e, null];
|
|
302
331
|
for (let n = Math.min(t, e.length - 1); n >= o; --n) {
|
|
303
332
|
let t = e[n - 1], r = e[n];
|
|
304
333
|
if (!("—–".includes(t) || ",;:".includes(t) && /\s/.test(r))) continue;
|
|
@@ -307,4 +336,4 @@ function te(e, t) {
|
|
|
307
336
|
}
|
|
308
337
|
return [e, null];
|
|
309
338
|
}
|
|
310
|
-
export { e as DEFAULT_SPEAKABLE_LABELS, n as MAX_SPEAKABLE_CHARS, t as MAX_SPOKEN_TABLE_ROWS, r as SPEECH_CHUNK_CHARS, i as SPEECH_CHUNK_CJK_CHARS, a as SPEECH_FIRST_CHUNK_MAX_CHARS,
|
|
339
|
+
export { e as DEFAULT_SPEAKABLE_LABELS, n as MAX_SPEAKABLE_CHARS, s as MAX_SPOKEN_TABLE_HEADERS, t as MAX_SPOKEN_TABLE_ROWS, r as SPEECH_CHUNK_CHARS, i as SPEECH_CHUNK_CJK_CHARS, a as SPEECH_FIRST_CHUNK_MAX_CHARS, re as chunkForSpeech, Z as containsCjk, c as joinSpokenList, E as speakableEmail, l as speakableLink, b as splitTableRow, L as toSpeakableText };
|