@readium/speech 0.7.0 → 0.7.1
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/build/index.js
CHANGED
|
@@ -428,7 +428,7 @@ const ii = ["veryLow", "low", "normal", "high", "veryHigh"], si = ["android", "a
|
|
|
428
428
|
...t,
|
|
429
429
|
quality: t.quality?.filter((e) => ii.includes(e)),
|
|
430
430
|
localizedName: t.localizedName && si.includes(t.localizedName) ? t.localizedName : void 0
|
|
431
|
-
}),
|
|
431
|
+
}), Oe = {
|
|
432
432
|
cmn: "cmn",
|
|
433
433
|
"cmn-CN": "cmn-CN",
|
|
434
434
|
"cmn-TW": "cmn-TW",
|
|
@@ -447,7 +447,7 @@ const ii = ["veryLow", "low", "normal", "high", "veryHigh"], si = ["android", "a
|
|
|
447
447
|
const [n, r] = e.split("-");
|
|
448
448
|
e = `${n.toLowerCase()}-${r.toUpperCase()}`;
|
|
449
449
|
}
|
|
450
|
-
return
|
|
450
|
+
return Oe[e] || e;
|
|
451
451
|
}, Rt = async (t) => {
|
|
452
452
|
if (!t) return [];
|
|
453
453
|
try {
|
|
@@ -478,8 +478,8 @@ const ii = ["veryLow", "low", "normal", "high", "veryHigh"], si = ["android", "a
|
|
|
478
478
|
const e = D(t), n = j[e];
|
|
479
479
|
if (n?.testUtterance)
|
|
480
480
|
return n.testUtterance;
|
|
481
|
-
if (e in
|
|
482
|
-
const i =
|
|
481
|
+
if (e in Oe) {
|
|
482
|
+
const i = Oe[e];
|
|
483
483
|
if (i && j[i]?.testUtterance)
|
|
484
484
|
return j[i].testUtterance;
|
|
485
485
|
}
|
|
@@ -488,14 +488,14 @@ const ii = ["veryLow", "low", "normal", "high", "veryHigh"], si = ["android", "a
|
|
|
488
488
|
} catch (e) {
|
|
489
489
|
return console.error(`Error in getTestUtterance for ${t}:`, e), "";
|
|
490
490
|
}
|
|
491
|
-
},
|
|
491
|
+
}, Ge = (t) => {
|
|
492
492
|
if (!t) return "";
|
|
493
493
|
try {
|
|
494
494
|
const e = D(t), n = j[e];
|
|
495
495
|
if (n?.defaultRegion)
|
|
496
496
|
return `${e}-${n.defaultRegion}`;
|
|
497
|
-
if (e in
|
|
498
|
-
const i =
|
|
497
|
+
if (e in Oe) {
|
|
498
|
+
const i = Oe[e];
|
|
499
499
|
if (i) {
|
|
500
500
|
const s = j[i];
|
|
501
501
|
if (s?.defaultRegion)
|
|
@@ -530,7 +530,7 @@ const ii = ["veryLow", "low", "normal", "high", "veryHigh"], si = ["android", "a
|
|
|
530
530
|
return g - f;
|
|
531
531
|
});
|
|
532
532
|
if (l.length === 0) {
|
|
533
|
-
const d =
|
|
533
|
+
const d = Ge(i), [, u] = U(d);
|
|
534
534
|
u && l.push(u);
|
|
535
535
|
}
|
|
536
536
|
return {
|
|
@@ -539,7 +539,7 @@ const ii = ["veryLow", "low", "normal", "high", "veryHigh"], si = ["android", "a
|
|
|
539
539
|
};
|
|
540
540
|
});
|
|
541
541
|
};
|
|
542
|
-
async function
|
|
542
|
+
async function $e(t) {
|
|
543
543
|
const e = /* @__PURE__ */ new Map();
|
|
544
544
|
for (const r of t) {
|
|
545
545
|
if (r.source !== "json") continue;
|
|
@@ -1095,7 +1095,7 @@ class k {
|
|
|
1095
1095
|
async sortVoicesByQuality(e) {
|
|
1096
1096
|
const n = e || this.voices;
|
|
1097
1097
|
if (!n?.length) return [];
|
|
1098
|
-
const r = await
|
|
1098
|
+
const r = await $e(n);
|
|
1099
1099
|
return [...n].sort((i, s) => k.sortByQuality(i, s, r));
|
|
1100
1100
|
}
|
|
1101
1101
|
/**
|
|
@@ -1113,7 +1113,7 @@ class k {
|
|
|
1113
1113
|
* Sort regions by default then alphabetically, sort voices by quality
|
|
1114
1114
|
*/
|
|
1115
1115
|
static async sortByDefaultRegion(e, n) {
|
|
1116
|
-
const r = await
|
|
1116
|
+
const r = await $e(e), i = Ge(n);
|
|
1117
1117
|
e.sort((s, o) => {
|
|
1118
1118
|
const [, a] = k.extractLangRegionFromBCP47(s.language), [, c] = k.extractLangRegionFromBCP47(o.language), l = i && a === i.split("-")[1], d = i && c === i.split("-")[1];
|
|
1119
1119
|
return l && !d ? -1 : !l && d ? 1 : k.sortByQuality(s, o, r, n);
|
|
@@ -1123,13 +1123,13 @@ class k {
|
|
|
1123
1123
|
* Sort voices alphabetically by language, then region, then quality
|
|
1124
1124
|
*/
|
|
1125
1125
|
static async sortAlphabetically(e) {
|
|
1126
|
-
const n = await
|
|
1126
|
+
const n = await $e(e);
|
|
1127
1127
|
e.sort((r, i) => {
|
|
1128
1128
|
const [s] = k.extractLangRegionFromBCP47(r.language), [o] = k.extractLangRegionFromBCP47(i.language), a = k.getLanguageDisplayName(s).toLowerCase(), c = k.getLanguageDisplayName(o).toLowerCase(), l = a.localeCompare(c);
|
|
1129
1129
|
if (l !== 0)
|
|
1130
1130
|
return l;
|
|
1131
1131
|
if (s === o) {
|
|
1132
|
-
const d =
|
|
1132
|
+
const d = Ge(s), [, u] = k.extractLangRegionFromBCP47(r.language), [, g] = k.extractLangRegionFromBCP47(i.language), f = d && u === d.split("-")[1], y = d && g === d.split("-")[1];
|
|
1133
1133
|
if (f && !y) return -1;
|
|
1134
1134
|
if (!f && y) return 1;
|
|
1135
1135
|
if (u && g) {
|
|
@@ -1166,7 +1166,7 @@ class k {
|
|
|
1166
1166
|
* Sort languages by region preference, then voices by quality
|
|
1167
1167
|
*/
|
|
1168
1168
|
static async sortByPreferredRegion(e, n) {
|
|
1169
|
-
const r = await
|
|
1169
|
+
const r = await $e(e);
|
|
1170
1170
|
e.sort((i, s) => {
|
|
1171
1171
|
const [, o] = k.extractLangRegionFromBCP47(i.language), [, a] = k.extractLangRegionFromBCP47(s.language), c = o && n.regions.includes(o), l = a && n.regions.includes(a);
|
|
1172
1172
|
if (c && l) {
|
|
@@ -1175,7 +1175,7 @@ class k {
|
|
|
1175
1175
|
}
|
|
1176
1176
|
if (c) return -1;
|
|
1177
1177
|
if (l) return 1;
|
|
1178
|
-
const d =
|
|
1178
|
+
const d = Ge(n.baseLang), [, u] = k.extractLangRegionFromBCP47(d), g = o === u, f = a === u;
|
|
1179
1179
|
if (g && !f) return -1;
|
|
1180
1180
|
if (!g && f) return 1;
|
|
1181
1181
|
if (o && a) {
|
|
@@ -1608,9 +1608,9 @@ function Rs(t) {
|
|
|
1608
1608
|
function Ns(t) {
|
|
1609
1609
|
return t != null && Rs(t.length) && !fr(t);
|
|
1610
1610
|
}
|
|
1611
|
-
var
|
|
1611
|
+
var Te = Kt(Object, "create");
|
|
1612
1612
|
function Is() {
|
|
1613
|
-
this.__data__ =
|
|
1613
|
+
this.__data__ = Te ? Te(null) : {}, this.size = 0;
|
|
1614
1614
|
}
|
|
1615
1615
|
function Ls(t) {
|
|
1616
1616
|
var e = this.has(t) && delete this.__data__[t];
|
|
@@ -1619,7 +1619,7 @@ function Ls(t) {
|
|
|
1619
1619
|
var Ps = "__lodash_hash_undefined__", qs = Object.prototype, $s = qs.hasOwnProperty;
|
|
1620
1620
|
function Ds(t) {
|
|
1621
1621
|
var e = this.__data__;
|
|
1622
|
-
if (
|
|
1622
|
+
if (Te) {
|
|
1623
1623
|
var n = e[t];
|
|
1624
1624
|
return n === Ps ? void 0 : n;
|
|
1625
1625
|
}
|
|
@@ -1628,12 +1628,12 @@ function Ds(t) {
|
|
|
1628
1628
|
var _s = Object.prototype, Bs = _s.hasOwnProperty;
|
|
1629
1629
|
function Us(t) {
|
|
1630
1630
|
var e = this.__data__;
|
|
1631
|
-
return
|
|
1631
|
+
return Te ? e[t] !== void 0 : Bs.call(e, t);
|
|
1632
1632
|
}
|
|
1633
1633
|
var zs = "__lodash_hash_undefined__";
|
|
1634
1634
|
function js(t, e) {
|
|
1635
1635
|
var n = this.__data__;
|
|
1636
|
-
return this.size += this.has(t) ? 0 : 1, n[t] =
|
|
1636
|
+
return this.size += this.has(t) ? 0 : 1, n[t] = Te && e === void 0 ? zs : e, this;
|
|
1637
1637
|
}
|
|
1638
1638
|
function Q(t) {
|
|
1639
1639
|
var e = -1, n = t == null ? 0 : t.length;
|
|
@@ -2142,7 +2142,7 @@ function Ln(t, e) {
|
|
|
2142
2142
|
if (typeof t == "string") return t.trim() ? [t] : [];
|
|
2143
2143
|
throw new TypeError(`string-strip-html/stripHtml(): [THROW_ID_05] ${e} must be array containing zero or more strings or something falsey. Currently it's equal to: ${t}, that a type of ${typeof t}.`);
|
|
2144
2144
|
}
|
|
2145
|
-
function
|
|
2145
|
+
function De(t, e, n, r) {
|
|
2146
2146
|
for (let i = e, s = t.length; i < s; i++) {
|
|
2147
2147
|
if (t.startsWith(n, i)) return !0;
|
|
2148
2148
|
if (t.startsWith(r, i)) return !1;
|
|
@@ -2150,7 +2150,7 @@ function $e(t, e, n, r) {
|
|
|
2150
2150
|
return !1;
|
|
2151
2151
|
}
|
|
2152
2152
|
function Pn(t, e, n) {
|
|
2153
|
-
return t?.quotes, t?.quotes?.value &&
|
|
2153
|
+
return t?.quotes, t?.quotes?.value && De(e, n + 1, t.quotes.value, ">"), t?.quotes?.next, De(e, t?.quotes?.next - 1, t?.quotes?.value, ">"), !t?.quotes || !De(e, n + 1, t.quotes.value, ">") && t?.quotes?.next !== -1 && De(e, t?.quotes?.next - 1, t?.quotes?.value, ">");
|
|
2154
2154
|
}
|
|
2155
2155
|
function io(t, e) {
|
|
2156
2156
|
return (e.match(new RegExp(t, "g")) || []).length;
|
|
@@ -2241,9 +2241,9 @@ ${JSON.stringify(e, null, 4)}`);
|
|
|
2241
2241
|
});
|
|
2242
2242
|
let O = new to({ limitToBeAddedWhitespace: !0, limitLinebreaksCount: 2 });
|
|
2243
2243
|
if (!b.skipHtmlDecoding) for (; t !== Tn(t, { scope: "strict" }); ) t = Tn(t, { scope: "strict" });
|
|
2244
|
-
let J = !1, H = !1,
|
|
2244
|
+
let J = !1, H = !1, qe = 0, cn = 0, $ = t.length, ei = Math.floor($ / 2);
|
|
2245
2245
|
for (let h = 0; h < $; h++) {
|
|
2246
|
-
if (b.reportProgressFunc && ($ > 1e3 && $ < 2e3 ? h === ei && b.reportProgressFunc(Math.floor((b.reportProgressFuncTo - b.reportProgressFuncFrom) / 2)) : $ >= 2e3 && (
|
|
2246
|
+
if (b.reportProgressFunc && ($ > 1e3 && $ < 2e3 ? h === ei && b.reportProgressFunc(Math.floor((b.reportProgressFuncTo - b.reportProgressFuncFrom) / 2)) : $ >= 2e3 && (qe = b.reportProgressFuncFrom + Math.floor(h / $ * (b.reportProgressFuncTo - b.reportProgressFuncFrom)), qe !== cn && (cn = qe, b.reportProgressFunc(qe)))), Object.keys(a).length > 1 && a.lastClosingBracketAt && a.lastClosingBracketAt < h && t[h] !== " " && w === null && (w = h), !J && t[h] === "%" && t[h - 1] === "{" && t.includes("%}", h + 1)) {
|
|
2247
2247
|
u = null;
|
|
2248
2248
|
let v = t.indexOf("%}", h) - 1;
|
|
2249
2249
|
if (v > h) {
|
|
@@ -2834,7 +2834,7 @@ const wo = /* @__PURE__ */ new Set(["wav", "flac"]), So = {
|
|
|
2834
2834
|
function xo(t, e, n) {
|
|
2835
2835
|
return wo.has(t) || !e || !n ? void 0 : n.saveData === !0 || /2g/.test(n.effectiveType ?? "") ? So[t] : void 0;
|
|
2836
2836
|
}
|
|
2837
|
-
function Er(t) {
|
|
2837
|
+
function Er(t, e) {
|
|
2838
2838
|
return {
|
|
2839
2839
|
source: "server",
|
|
2840
2840
|
label: t.name,
|
|
@@ -2846,7 +2846,7 @@ function Er(t) {
|
|
|
2846
2846
|
quality: t.quality,
|
|
2847
2847
|
provider: t.provider,
|
|
2848
2848
|
identifier: t.identifier,
|
|
2849
|
-
controls:
|
|
2849
|
+
controls: e
|
|
2850
2850
|
};
|
|
2851
2851
|
}
|
|
2852
2852
|
class Qe extends Error {
|
|
@@ -2858,7 +2858,7 @@ class Qe extends Error {
|
|
|
2858
2858
|
super(e), this.name = "SpeechServerError", this.status = n.status, this.type = n.type, this.title = n.title, this.instance = n.instance;
|
|
2859
2859
|
}
|
|
2860
2860
|
}
|
|
2861
|
-
async function
|
|
2861
|
+
async function Ae(t) {
|
|
2862
2862
|
if ((t.headers.get("content-type") ?? "").includes("application/problem+json"))
|
|
2863
2863
|
try {
|
|
2864
2864
|
const n = await t.json();
|
|
@@ -2882,7 +2882,7 @@ function Eo(t) {
|
|
|
2882
2882
|
function Ao(t) {
|
|
2883
2883
|
return Math.max(0.25, Math.min(4, t));
|
|
2884
2884
|
}
|
|
2885
|
-
function
|
|
2885
|
+
function _e(t) {
|
|
2886
2886
|
return t?.plain ?? t?.ssml ?? void 0;
|
|
2887
2887
|
}
|
|
2888
2888
|
function _n(t) {
|
|
@@ -2947,7 +2947,7 @@ class Oo {
|
|
|
2947
2947
|
return -1;
|
|
2948
2948
|
let n = 0;
|
|
2949
2949
|
for (let r = 0; r < this.currentUtterances.length; r++)
|
|
2950
|
-
if (n += (
|
|
2950
|
+
if (n += (_e(this.currentUtterances[r]) ?? "").length, n >= e)
|
|
2951
2951
|
return r;
|
|
2952
2952
|
return this.currentUtterances.length - 1;
|
|
2953
2953
|
}
|
|
@@ -2978,11 +2978,11 @@ class Oo {
|
|
|
2978
2978
|
async getAvailableVoices() {
|
|
2979
2979
|
if (this.voices.length > 0)
|
|
2980
2980
|
return this.voices;
|
|
2981
|
-
const e = await this.fetchImpl(this.endpoints.voices);
|
|
2981
|
+
const [e, n] = await Promise.all([this.fetchImpl(this.endpoints.voices), this.getServiceInfo()]);
|
|
2982
2982
|
if (!e.ok)
|
|
2983
|
-
throw await
|
|
2984
|
-
const
|
|
2985
|
-
return this.voices =
|
|
2983
|
+
throw await Ae(e);
|
|
2984
|
+
const r = await e.json(), i = new Map(n.providers.map((s) => [s.id, s.controls]));
|
|
2985
|
+
return this.voices = r.map((s) => Er(s, i.get(s.provider))), this.voices;
|
|
2986
2986
|
}
|
|
2987
2987
|
// Cached after the first successful fetch; a failed fetch isn't cached, so the next
|
|
2988
2988
|
// synthesize() call retries rather than being stuck on a transient network error.
|
|
@@ -2994,7 +2994,7 @@ class Oo {
|
|
|
2994
2994
|
async fetchServiceInfo() {
|
|
2995
2995
|
const e = await this.fetchImpl(this.endpoints.service);
|
|
2996
2996
|
if (!e.ok)
|
|
2997
|
-
throw await
|
|
2997
|
+
throw await Ae(e);
|
|
2998
2998
|
return e.json();
|
|
2999
2999
|
}
|
|
3000
3000
|
setSpeakInContentLanguage(e) {
|
|
@@ -3070,7 +3070,7 @@ class Oo {
|
|
|
3070
3070
|
this.prefetchCache.clear();
|
|
3071
3071
|
}
|
|
3072
3072
|
async synthesizeStream(e) {
|
|
3073
|
-
const n = this.currentUtterances[e], r = !n.plain && !!n.ssml, i = this.speakInContentLanguage ? n.language : void 0, s =
|
|
3073
|
+
const n = this.currentUtterances[e], r = !n.plain && !!n.ssml, i = this.speakInContentLanguage ? n.language : void 0, s = _e(n) ?? "", o = _e(this.currentUtterances[e - 1]), a = _e(this.currentUtterances[e + 1]), c = await this.getServiceInfo(), l = vo(c.output, this.formatOptions, this.canPlayType), d = navigator.connection, u = xo(l, this.formatOptions.adaptBitrateToNetwork ?? !1, d);
|
|
3074
3074
|
if (s.length <= c.limits.maxTextLength)
|
|
3075
3075
|
return [this.synthesizeChunk(n, s, 0, r, i, o, a, l, u)];
|
|
3076
3076
|
if (this.overLengthText === "error")
|
|
@@ -3109,7 +3109,7 @@ class Oo {
|
|
|
3109
3109
|
})
|
|
3110
3110
|
});
|
|
3111
3111
|
if (!d.ok)
|
|
3112
|
-
throw await
|
|
3112
|
+
throw await Ae(d);
|
|
3113
3113
|
const u = await d.json(), g = Eo(u.audio);
|
|
3114
3114
|
let f;
|
|
3115
3115
|
try {
|
|
@@ -3288,11 +3288,16 @@ class fc {
|
|
|
3288
3288
|
async getVoices() {
|
|
3289
3289
|
if (this.voices.length > 0)
|
|
3290
3290
|
return this.voices;
|
|
3291
|
-
const e = await
|
|
3291
|
+
const [e, n] = await Promise.all([
|
|
3292
|
+
this.fetchImpl(this.options.endpoints.voices),
|
|
3293
|
+
this.fetchImpl(this.options.endpoints.service)
|
|
3294
|
+
]);
|
|
3292
3295
|
if (!e.ok)
|
|
3293
|
-
throw await
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
+
throw await Ae(e);
|
|
3297
|
+
if (!n.ok)
|
|
3298
|
+
throw await Ae(n);
|
|
3299
|
+
const r = await e.json(), i = await n.json(), s = new Map(i.providers.map((o) => [o.id, o.controls]));
|
|
3300
|
+
return this.voices = r.map((o) => Er(o, s.get(o.provider))), this.voices;
|
|
3296
3301
|
}
|
|
3297
3302
|
async createEngine(e) {
|
|
3298
3303
|
const n = new Oo(this.options);
|
|
@@ -3331,7 +3336,7 @@ function Lo(t) {
|
|
|
3331
3336
|
function wt(t) {
|
|
3332
3337
|
return isNaN(t) ? void 0 : t;
|
|
3333
3338
|
}
|
|
3334
|
-
function
|
|
3339
|
+
function Be(t) {
|
|
3335
3340
|
return t.otherLocations?.get("cssSelector");
|
|
3336
3341
|
}
|
|
3337
3342
|
let xe = class Ar {
|
|
@@ -3531,7 +3536,7 @@ function Ir(t, ...e) {
|
|
|
3531
3536
|
if (n !== void 0) throw new RangeError("Offset exceeds text length");
|
|
3532
3537
|
return i;
|
|
3533
3538
|
}
|
|
3534
|
-
let
|
|
3539
|
+
let Ue = class re {
|
|
3535
3540
|
constructor(e, n) {
|
|
3536
3541
|
if (n < 0) throw new Error("Offset is invalid");
|
|
3537
3542
|
this.element = e, this.offset = n;
|
|
@@ -3597,11 +3602,11 @@ let Be = class re {
|
|
|
3597
3602
|
return r.setStart(e.node, e.offset), r.setEnd(n.node, n.offset), r;
|
|
3598
3603
|
}
|
|
3599
3604
|
static fromRange(e) {
|
|
3600
|
-
const n =
|
|
3605
|
+
const n = Ue.fromPoint(e.startContainer, e.startOffset), r = Ue.fromPoint(e.endContainer, e.endOffset);
|
|
3601
3606
|
return new Ce(n, r);
|
|
3602
3607
|
}
|
|
3603
3608
|
static fromOffsets(e, n, r) {
|
|
3604
|
-
return new Ce(new
|
|
3609
|
+
return new Ce(new Ue(e, n), new Ue(e, r));
|
|
3605
3610
|
}
|
|
3606
3611
|
static trimmedRange(e) {
|
|
3607
3612
|
return Bo(Ce.fromRange(e).toRange());
|
|
@@ -3656,7 +3661,7 @@ function Vo(t, e) {
|
|
|
3656
3661
|
const n = e.locations, r = e.text;
|
|
3657
3662
|
if (r && r.highlight) {
|
|
3658
3663
|
let i;
|
|
3659
|
-
n &&
|
|
3664
|
+
n && Be(n) && (i = t.querySelector(Be(n))), i || (i = t.body);
|
|
3660
3665
|
const s = new zo(i, r.highlight, { prefix: r.before, suffix: r.after });
|
|
3661
3666
|
try {
|
|
3662
3667
|
return s.toRange();
|
|
@@ -3666,7 +3671,7 @@ function Vo(t, e) {
|
|
|
3666
3671
|
}
|
|
3667
3672
|
if (n) {
|
|
3668
3673
|
let i = null;
|
|
3669
|
-
if (!i &&
|
|
3674
|
+
if (!i && Be(n) && (i = t.querySelector(Be(n))), !i && n.fragments) {
|
|
3670
3675
|
for (const s of n.fragments) if (i = t.getElementById(s), i) break;
|
|
3671
3676
|
}
|
|
3672
3677
|
if (i) {
|
|
@@ -3702,7 +3707,7 @@ function Fo(t, e) {
|
|
|
3702
3707
|
}
|
|
3703
3708
|
return r;
|
|
3704
3709
|
}
|
|
3705
|
-
function
|
|
3710
|
+
function ze(t, e, n = !1, r = 0) {
|
|
3706
3711
|
let i;
|
|
3707
3712
|
if (Array.isArray(t)) i = t;
|
|
3708
3713
|
else {
|
|
@@ -3804,26 +3809,26 @@ function qr(t, e, n) {
|
|
|
3804
3809
|
function q(t, e, n) {
|
|
3805
3810
|
return Math.abs(t - e) <= n;
|
|
3806
3811
|
}
|
|
3807
|
-
let
|
|
3812
|
+
let je = null, xt = null, ke = 0;
|
|
3808
3813
|
const ie = { r: 255, g: 255, b: 255, a: 1 }, ee = /* @__PURE__ */ new Map(), Ko = () => {
|
|
3809
|
-
if (!
|
|
3814
|
+
if (!je) if (typeof OffscreenCanvas < "u") je = new OffscreenCanvas(5, 5), xt = je.getContext("2d", { willReadFrequently: !0, desynchronized: !0 });
|
|
3810
3815
|
else {
|
|
3811
3816
|
const t = document.createElement("canvas");
|
|
3812
|
-
t.width = 5, t.height = 5,
|
|
3817
|
+
t.width = 5, t.height = 5, je = t, xt = t.getContext("2d", { willReadFrequently: !0, desynchronized: !0 });
|
|
3813
3818
|
}
|
|
3814
3819
|
return xt;
|
|
3815
3820
|
}, Jo = (t) => {
|
|
3816
3821
|
if (!t) return !0;
|
|
3817
3822
|
const e = t.trim().toLowerCase();
|
|
3818
3823
|
return e.startsWith("var(") || ["transparent", "currentcolor", "inherit", "initial", "revert", "unset", "revert-layer"].includes(e) ? !0 : ["linear-gradient", "radial-gradient", "conic-gradient", "repeating-linear-gradient", "repeating-radial-gradient", "repeating-conic-gradient"].some((n) => e.includes(n));
|
|
3819
|
-
},
|
|
3824
|
+
}, Ve = (t, e) => {
|
|
3820
3825
|
console.warn(`[Decorator] Could not parse color: "${t}". ${e} Falling back to ${JSON.stringify(ie)} to compute contrast. Please use a CSS color value that can be computed to RGB(A).`);
|
|
3821
3826
|
}, X = (t, e = null) => {
|
|
3822
3827
|
const n = e ? `${t}|${e}` : t, r = ee.get(n);
|
|
3823
3828
|
if (r !== void 0) return r ?? ie;
|
|
3824
|
-
if (Jo(t)) return
|
|
3829
|
+
if (Jo(t)) return Ve(t, "Unsupported color format or special value."), ee.set(n, null), ie;
|
|
3825
3830
|
const i = Ko();
|
|
3826
|
-
if (!i) return
|
|
3831
|
+
if (!i) return Ve(t, "Could not get canvas context."), ee.set(n, null), ie;
|
|
3827
3832
|
try {
|
|
3828
3833
|
ke === 0 && i.clearRect(0, 0, 5, 5);
|
|
3829
3834
|
const s = ke % 5, o = Math.floor(ke / 5);
|
|
@@ -3831,11 +3836,11 @@ const ie = { r: 255, g: 255, b: 255, a: 1 }, ee = /* @__PURE__ */ new Map(), Ko
|
|
|
3831
3836
|
const a = i.getImageData(s, o, 1, 1);
|
|
3832
3837
|
ke = (ke + 1) % 25;
|
|
3833
3838
|
const [c, l, d, u] = a.data;
|
|
3834
|
-
if (u === 0) return
|
|
3839
|
+
if (u === 0) return Ve(t, "Fully transparent color."), ee.set(n, null), ie;
|
|
3835
3840
|
const g = { r: c, g: l, b: d, a: u / 255 };
|
|
3836
3841
|
return ee.set(n, g), g;
|
|
3837
3842
|
} catch (s) {
|
|
3838
|
-
return
|
|
3843
|
+
return Ve(t, `Error: ${s instanceof Error ? s.message : String(s)}`), ee.set(n, null), ie;
|
|
3839
3844
|
}
|
|
3840
3845
|
}, kt = (t) => {
|
|
3841
3846
|
const e = t / 255;
|
|
@@ -3981,7 +3986,7 @@ class cl {
|
|
|
3981
3986
|
o !== A.TextColor && (o === A.Outline || o === A.Template || o === A.Mask || a !== void 0 && a !== "boxes" || c !== void 0 && c !== "wrap" || l) && this.notTextFlag?.set(n, !0);
|
|
3982
3987
|
}
|
|
3983
3988
|
const s = { decoration: e, id: n, range: r, hitRects: [], clickableElements: void 0, container: void 0 };
|
|
3984
|
-
this.items.push(s), this.layout(s), s.hitRects = this.clientRectsToDocCoords(
|
|
3989
|
+
this.items.push(s), this.layout(s), s.hitRects = this.clientRectsToDocCoords(ze(s.range, !1, !1, (s.decoration.style.expand ?? 0) + this.hitGap())), this.renderLayout([s]);
|
|
3985
3990
|
}
|
|
3986
3991
|
remove(e) {
|
|
3987
3992
|
const n = this.items.findIndex((s) => s.decoration.id === e);
|
|
@@ -4072,7 +4077,7 @@ class cl {
|
|
|
4072
4077
|
this.wnd.cancelAnimationFrame(this.currentRender), this.clearContainer(), this.wnd.document.fonts.ready.then(() => {
|
|
4073
4078
|
this.currentRender = this.wnd.requestAnimationFrame(() => {
|
|
4074
4079
|
this.items.forEach((e) => {
|
|
4075
|
-
this.layout(e), e.hitRects = this.clientRectsToDocCoords(
|
|
4080
|
+
this.layout(e), e.hitRects = this.clientRectsToDocCoords(ze(e.range, !1, !1, (e.decoration.style.expand ?? 0) + this.hitGap()));
|
|
4076
4081
|
}), this.renderLayout(this.items), this.updateSharedMask();
|
|
4077
4082
|
});
|
|
4078
4083
|
});
|
|
@@ -4234,7 +4239,7 @@ class cl {
|
|
|
4234
4239
|
o(u, g, a, l), n.append(u);
|
|
4235
4240
|
} else {
|
|
4236
4241
|
const u = c.type, g = u === A.Underline || u === A.Strikethrough, f = u === A.Strikethrough, y = g ? Fo(e.range, ["rt", "rp"]) : e.range;
|
|
4237
|
-
let p =
|
|
4242
|
+
let p = ze(y, !0, r.isVertical, g ? 0 : s);
|
|
4238
4243
|
p = p.sort((m, w) => r.isVertical ? (r.isVertLR ? 1 : -1) * (m.left - w.left) : m.top - w.top);
|
|
4239
4244
|
for (let m of p) {
|
|
4240
4245
|
const w = d.cloneNode(!0);
|
|
@@ -4275,7 +4280,7 @@ class cl {
|
|
|
4275
4280
|
}
|
|
4276
4281
|
const n = Se(this.wnd), r = 1 / this.effectiveZoom(), i = this.wnd.document.documentElement, s = i.scrollWidth, o = i.scrollHeight, a = [];
|
|
4277
4282
|
for (const g of e) {
|
|
4278
|
-
const f = g.decoration.style, y = f.layout ?? "boxes", p = f.width ?? "wrap", m = f.expand ?? 0, w = g.range.getBoundingClientRect(), E = y === "bounds" ? [m ? { left: w.left - m, top: w.top - m, right: w.right + m, bottom: w.bottom + m, width: w.width + m * 2, height: w.height + m * 2 } : w] :
|
|
4283
|
+
const f = g.decoration.style, y = f.layout ?? "boxes", p = f.width ?? "wrap", m = f.expand ?? 0, w = g.range.getBoundingClientRect(), E = y === "bounds" ? [m ? { left: w.left - m, top: w.top - m, right: w.right + m, bottom: w.bottom + m, width: w.width + m * 2, height: w.height + m * 2 } : w] : ze(g.range, !1, !1, m);
|
|
4279
4284
|
for (const C of E) {
|
|
4280
4285
|
let N;
|
|
4281
4286
|
switch (p) {
|
|
@@ -4701,7 +4706,7 @@ function F(t, e) {
|
|
|
4701
4706
|
const n = Math.min(...e), r = Math.max(...e);
|
|
4702
4707
|
return t >= n && t <= r ? t : void 0;
|
|
4703
4708
|
}
|
|
4704
|
-
function
|
|
4709
|
+
function Re(t) {
|
|
4705
4710
|
return t == null || Array.isArray(t) && t.every((e) => typeof e == "string") ? t : void 0;
|
|
4706
4711
|
}
|
|
4707
4712
|
class kl {
|
|
@@ -4717,10 +4722,10 @@ class kl {
|
|
|
4717
4722
|
pitch;
|
|
4718
4723
|
volume;
|
|
4719
4724
|
constructor(e = {}) {
|
|
4720
|
-
this.format = V(e.format, tn) ?? "plain", this.inlineContextualization = rn(e.inlineContextualization) ?? !1, this.verbosity = V(e.verbosity, Yt) ?? "few", this.skip =
|
|
4725
|
+
this.format = V(e.format, tn) ?? "plain", this.inlineContextualization = rn(e.inlineContextualization) ?? !1, this.verbosity = V(e.verbosity, Yt) ?? "few", this.skip = Re(e.skip) ?? [], this.contextualize = Re(e.contextualize) ?? [], this.language = V(e.language, en) ?? "block-level", this.pauseDuration = F(e.pauseDuration, Ye.range) ?? 300, this.autoPause = V(e.autoPause, nn) ?? "none", this.rate = F(e.rate, et.range) ?? 1, this.pitch = F(e.pitch, tt.range) ?? 1, this.volume = F(e.volume, nt.range) ?? 1;
|
|
4721
4726
|
}
|
|
4722
4727
|
}
|
|
4723
|
-
class
|
|
4728
|
+
class Ne {
|
|
4724
4729
|
format;
|
|
4725
4730
|
inlineContextualization;
|
|
4726
4731
|
verbosity;
|
|
@@ -4733,13 +4738,13 @@ class Re {
|
|
|
4733
4738
|
pitch;
|
|
4734
4739
|
volume;
|
|
4735
4740
|
constructor(e = {}) {
|
|
4736
|
-
this.format = V(e.format, tn), this.inlineContextualization = rn(e.inlineContextualization), this.verbosity = V(e.verbosity, Yt), this.skip =
|
|
4741
|
+
this.format = V(e.format, tn), this.inlineContextualization = rn(e.inlineContextualization), this.verbosity = V(e.verbosity, Yt), this.skip = Re(e.skip), this.contextualize = Re(e.contextualize), this.language = V(e.language, en), this.pauseDuration = F(e.pauseDuration, Ye.range), this.autoPause = V(e.autoPause, nn), this.rate = F(e.rate, et.range), this.pitch = F(e.pitch, tt.range), this.volume = F(e.volume, nt.range);
|
|
4737
4742
|
}
|
|
4738
4743
|
merging(e) {
|
|
4739
4744
|
const n = { ...this };
|
|
4740
4745
|
for (const r of Object.keys(e))
|
|
4741
4746
|
e[r] !== void 0 && (n[r] = e[r]);
|
|
4742
|
-
return new
|
|
4747
|
+
return new Ne(n);
|
|
4743
4748
|
}
|
|
4744
4749
|
}
|
|
4745
4750
|
class ct {
|
|
@@ -4771,7 +4776,7 @@ class ct {
|
|
|
4771
4776
|
this._value = null, this._onChange(this._value);
|
|
4772
4777
|
}
|
|
4773
4778
|
}
|
|
4774
|
-
class
|
|
4779
|
+
class Fe extends ct {
|
|
4775
4780
|
_supportedValues;
|
|
4776
4781
|
constructor({
|
|
4777
4782
|
initialValue: e = null,
|
|
@@ -4806,7 +4811,7 @@ class Cl extends ct {
|
|
|
4806
4811
|
}
|
|
4807
4812
|
class Xn extends ct {
|
|
4808
4813
|
set value(e) {
|
|
4809
|
-
if (e != null &&
|
|
4814
|
+
if (e != null && Re(e) === void 0)
|
|
4810
4815
|
throw new Error(`Value '${String(e)}' is not an array of strings.`);
|
|
4811
4816
|
this._value = e, this._onChange(this._value);
|
|
4812
4817
|
}
|
|
@@ -4814,7 +4819,7 @@ class Xn extends ct {
|
|
|
4814
4819
|
return this._value;
|
|
4815
4820
|
}
|
|
4816
4821
|
}
|
|
4817
|
-
class
|
|
4822
|
+
class He extends ct {
|
|
4818
4823
|
_supportedRange;
|
|
4819
4824
|
_step;
|
|
4820
4825
|
_decimals;
|
|
@@ -4866,12 +4871,12 @@ class Zn {
|
|
|
4866
4871
|
// once explicitly passed to submitPreferences() — discarding the editor
|
|
4867
4872
|
// without submitting must leave the navigator untouched.
|
|
4868
4873
|
constructor(e, n) {
|
|
4869
|
-
this.preferences = new
|
|
4874
|
+
this.preferences = new Ne({ ...e }), this.settings = n;
|
|
4870
4875
|
}
|
|
4871
4876
|
// Explicit `null`s, not `undefined` — merging() skips `undefined` fields,
|
|
4872
4877
|
// so only `null` actually clears them once submitted.
|
|
4873
4878
|
clear() {
|
|
4874
|
-
this.preferences = new
|
|
4879
|
+
this.preferences = new Ne({
|
|
4875
4880
|
format: null,
|
|
4876
4881
|
inlineContextualization: null,
|
|
4877
4882
|
verbosity: null,
|
|
@@ -4889,7 +4894,7 @@ class Zn {
|
|
|
4889
4894
|
this.preferences[e] = n;
|
|
4890
4895
|
}
|
|
4891
4896
|
get format() {
|
|
4892
|
-
return new
|
|
4897
|
+
return new Fe({
|
|
4893
4898
|
initialValue: this.preferences.format,
|
|
4894
4899
|
effectiveValue: this.settings.format,
|
|
4895
4900
|
isEffective: this.preferences.format != null,
|
|
@@ -4906,7 +4911,7 @@ class Zn {
|
|
|
4906
4911
|
});
|
|
4907
4912
|
}
|
|
4908
4913
|
get verbosity() {
|
|
4909
|
-
return new
|
|
4914
|
+
return new Fe({
|
|
4910
4915
|
initialValue: this.preferences.verbosity,
|
|
4911
4916
|
effectiveValue: this.settings.verbosity,
|
|
4912
4917
|
isEffective: this.preferences.verbosity != null,
|
|
@@ -4931,7 +4936,7 @@ class Zn {
|
|
|
4931
4936
|
});
|
|
4932
4937
|
}
|
|
4933
4938
|
get language() {
|
|
4934
|
-
return new
|
|
4939
|
+
return new Fe({
|
|
4935
4940
|
initialValue: this.preferences.language,
|
|
4936
4941
|
effectiveValue: this.settings.language,
|
|
4937
4942
|
isEffective: this.preferences.language != null,
|
|
@@ -4940,7 +4945,7 @@ class Zn {
|
|
|
4940
4945
|
});
|
|
4941
4946
|
}
|
|
4942
4947
|
get pauseDuration() {
|
|
4943
|
-
return new
|
|
4948
|
+
return new He({
|
|
4944
4949
|
initialValue: this.preferences.pauseDuration,
|
|
4945
4950
|
effectiveValue: this.settings.pauseDuration,
|
|
4946
4951
|
isEffective: this.preferences.pauseDuration != null,
|
|
@@ -4950,7 +4955,7 @@ class Zn {
|
|
|
4950
4955
|
});
|
|
4951
4956
|
}
|
|
4952
4957
|
get autoPause() {
|
|
4953
|
-
return new
|
|
4958
|
+
return new Fe({
|
|
4954
4959
|
initialValue: this.preferences.autoPause,
|
|
4955
4960
|
effectiveValue: this.settings.autoPause,
|
|
4956
4961
|
isEffective: this.preferences.autoPause != null,
|
|
@@ -4959,7 +4964,7 @@ class Zn {
|
|
|
4959
4964
|
});
|
|
4960
4965
|
}
|
|
4961
4966
|
get rate() {
|
|
4962
|
-
return new
|
|
4967
|
+
return new He({
|
|
4963
4968
|
initialValue: this.preferences.rate,
|
|
4964
4969
|
effectiveValue: this.settings.rate,
|
|
4965
4970
|
isEffective: this.preferences.rate != null,
|
|
@@ -4969,7 +4974,7 @@ class Zn {
|
|
|
4969
4974
|
});
|
|
4970
4975
|
}
|
|
4971
4976
|
get pitch() {
|
|
4972
|
-
return new
|
|
4977
|
+
return new He({
|
|
4973
4978
|
initialValue: this.preferences.pitch,
|
|
4974
4979
|
effectiveValue: this.settings.pitch,
|
|
4975
4980
|
isEffective: this.preferences.pitch != null,
|
|
@@ -4979,7 +4984,7 @@ class Zn {
|
|
|
4979
4984
|
});
|
|
4980
4985
|
}
|
|
4981
4986
|
get volume() {
|
|
4982
|
-
return new
|
|
4987
|
+
return new He({
|
|
4983
4988
|
initialValue: this.preferences.volume,
|
|
4984
4989
|
effectiveValue: this.settings.volume,
|
|
4985
4990
|
isEffective: this.preferences.volume != null,
|
|
@@ -5131,11 +5136,11 @@ class Yn {
|
|
|
5131
5136
|
this.format = e.format ?? n.format, this.inlineContextualization = e.inlineContextualization ?? n.inlineContextualization, this.verbosity = e.verbosity ?? n.verbosity, this.verbosity === "custom" ? (this.skip = e.skip ?? n.skip, this.contextualize = e.contextualize ?? n.contextualize) : (this.skip = [...Al[this.verbosity]], this.contextualize = [...Ol[this.verbosity]]), this.language = e.language ?? n.language, this.pauseDuration = e.pauseDuration ?? n.pauseDuration, this.autoPause = e.autoPause ?? n.autoPause, this.rate = e.rate ?? n.rate, this.pitch = e.pitch ?? n.pitch, this.volume = e.volume ?? n.volume;
|
|
5132
5137
|
}
|
|
5133
5138
|
}
|
|
5134
|
-
function
|
|
5139
|
+
function Pe(t) {
|
|
5135
5140
|
return t.plain === "" && t.ssml === "" && t.language === "";
|
|
5136
5141
|
}
|
|
5137
5142
|
function Tl(t) {
|
|
5138
|
-
if (!t ||
|
|
5143
|
+
if (!t || Pe(t)) return;
|
|
5139
5144
|
if (t.ssml === "" && t.language === "") return t.plain;
|
|
5140
5145
|
const e = { language: t.language };
|
|
5141
5146
|
return t.plain !== "" && (e.plain = t.plain), t.ssml !== "" && (e.ssml = t.ssml), e;
|
|
@@ -5149,7 +5154,7 @@ const rt = (t) => t.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, "
|
|
|
5149
5154
|
function Il(t) {
|
|
5150
5155
|
return Nl.test(t);
|
|
5151
5156
|
}
|
|
5152
|
-
function
|
|
5157
|
+
function Ie(t, e) {
|
|
5153
5158
|
let n = "", r = !1, i = !1;
|
|
5154
5159
|
for (const s of t)
|
|
5155
5160
|
if (Il(s))
|
|
@@ -5407,7 +5412,7 @@ const Sc = [
|
|
|
5407
5412
|
"summary",
|
|
5408
5413
|
"tip"
|
|
5409
5414
|
], Hl = new Set(Fl);
|
|
5410
|
-
function
|
|
5415
|
+
function Le(t, e) {
|
|
5411
5416
|
return typeof t == "function" ? t(e) : t;
|
|
5412
5417
|
}
|
|
5413
5418
|
function le(t, e) {
|
|
@@ -5426,10 +5431,10 @@ function tr(t, e, n, r, i, s, o) {
|
|
|
5426
5431
|
if (a !== void 0) {
|
|
5427
5432
|
if (it(a)) {
|
|
5428
5433
|
const c = s === "before" ? a.start : a.end;
|
|
5429
|
-
ce(t, e, n, [le(
|
|
5434
|
+
ce(t, e, n, [le(Le(c, o), r.format)]);
|
|
5430
5435
|
return;
|
|
5431
5436
|
}
|
|
5432
|
-
s === "before" && ce(t, e, n, [le(
|
|
5437
|
+
s === "before" && ce(t, e, n, [le(Le(a, o), r.format)]);
|
|
5433
5438
|
}
|
|
5434
5439
|
}
|
|
5435
5440
|
function nr(t, e) {
|
|
@@ -5457,7 +5462,7 @@ function Ml(t, e) {
|
|
|
5457
5462
|
if (!e.contextualize.has("pagebreak")) return r;
|
|
5458
5463
|
const i = e.announcements.pagebreak;
|
|
5459
5464
|
if (i === void 0) return r;
|
|
5460
|
-
const s = le(
|
|
5465
|
+
const s = le(Le(it(i) ? i.start : i), e.format);
|
|
5461
5466
|
if (r.length === 0) return [s];
|
|
5462
5467
|
const o = an([s, ...r], e.format);
|
|
5463
5468
|
return o ? (o.plain !== void 0 && (o.plain += "."), o.ssml !== void 0 && (o.ssml += "."), [o]) : [s, ...r];
|
|
@@ -5511,9 +5516,9 @@ function Xr(t, e, n, r, i) {
|
|
|
5511
5516
|
const p = r.contextualize.has("footnote") ? r.announcements.footnote : void 0, m = [], w = [];
|
|
5512
5517
|
if (p !== void 0) {
|
|
5513
5518
|
const C = it(p) ? p.start : p;
|
|
5514
|
-
m.push(le(
|
|
5519
|
+
m.push(le(Le(C), r.format)), w.push(u);
|
|
5515
5520
|
}
|
|
5516
|
-
m.push(...f), w.push(...y), p !== void 0 && it(p) && (m.push(le(
|
|
5521
|
+
m.push(...f), w.push(...y), p !== void 0 && it(p) && (m.push(le(Le(p.end), r.format)), w.push(u));
|
|
5517
5522
|
const E = p !== void 0 && m.length > 1 ? an(m, r.format) : void 0;
|
|
5518
5523
|
Jr(e, n, r, u, m, w, E);
|
|
5519
5524
|
} else
|
|
@@ -5598,7 +5603,7 @@ class kc {
|
|
|
5598
5603
|
// Index to speak() on the next play() when autoPause has stopped playback between utterances.
|
|
5599
5604
|
pendingAutoPauseIndex = null;
|
|
5600
5605
|
constructor(e, n = {}) {
|
|
5601
|
-
this.engine = e, this._defaults = new kl(n.defaults), this._preferences = new
|
|
5606
|
+
this.engine = e, this._defaults = new kl(n.defaults), this._preferences = new Ne(n.preferences), this._settings = new Yn(this._preferences, this._defaults), this.setupEngineListeners(), this.applyEngineParameters(), this.initializeEngine();
|
|
5602
5607
|
}
|
|
5603
5608
|
// Unlike pauseDuration/autoPause (read live off settings), the engine owns rate/pitch/volume and must be pushed.
|
|
5604
5609
|
applyEngineParameters() {
|
|
@@ -6039,7 +6044,7 @@ function Ft(t) {
|
|
|
6039
6044
|
return n(t), e;
|
|
6040
6045
|
}
|
|
6041
6046
|
function We(t) {
|
|
6042
|
-
return
|
|
6047
|
+
return Ie(Ft(t), !0).trim();
|
|
6043
6048
|
}
|
|
6044
6049
|
function Xl(t) {
|
|
6045
6050
|
if (ir(t))
|
|
@@ -6054,7 +6059,7 @@ function Xl(t) {
|
|
|
6054
6059
|
const g = d.getAttribute("aria-label");
|
|
6055
6060
|
c += g || Ft(d), u < a.length - 1 && (c += " ");
|
|
6056
6061
|
});
|
|
6057
|
-
const l =
|
|
6062
|
+
const l = Ie(c, !0).trim();
|
|
6058
6063
|
if (l !== "")
|
|
6059
6064
|
return [{ language: "", plain: l }, !0];
|
|
6060
6065
|
}
|
|
@@ -6066,7 +6071,7 @@ function Xl(t) {
|
|
|
6066
6071
|
if (r) {
|
|
6067
6072
|
const o = [...new Set(r.split(/\s+/).filter(Boolean))].map((a) => t.ownerDocument.getElementById(a)).filter((a) => a !== null);
|
|
6068
6073
|
if (o.length > 0) {
|
|
6069
|
-
const a = o.map((l) => Ft(l)).join(" "), c =
|
|
6074
|
+
const a = o.map((l) => Ft(l)).join(" "), c = Ie(a, !0).trim();
|
|
6070
6075
|
if (c !== "")
|
|
6071
6076
|
return [{ language: "", plain: c }, !0];
|
|
6072
6077
|
}
|
|
@@ -6114,15 +6119,15 @@ const ec = /* @__PURE__ */ new Set([
|
|
|
6114
6119
|
"rtc"
|
|
6115
6120
|
]);
|
|
6116
6121
|
function Ht(t) {
|
|
6117
|
-
return !t.audioref && !t.imgref && !t.textref && !t.videoref && (!t.text ||
|
|
6122
|
+
return !t.audioref && !t.imgref && !t.textref && !t.videoref && (!t.text || Pe(t.text)) && !(t.children && t.children.length > 0) && !t.description;
|
|
6118
6123
|
}
|
|
6119
6124
|
function tc(t) {
|
|
6120
|
-
return !t.audioref && !t.imgref && !t.textref && !t.videoref && (!t.text ||
|
|
6125
|
+
return !t.audioref && !t.imgref && !t.textref && !t.videoref && (!t.text || Pe(t.text)) && !!(t.children && t.children.length > 0) && !(t.role && t.role.length > 0) && !t.id;
|
|
6121
6126
|
}
|
|
6122
6127
|
function nc(t) {
|
|
6123
6128
|
return !(t.role && t.role.length > 0) && !t.id;
|
|
6124
6129
|
}
|
|
6125
|
-
class
|
|
6130
|
+
class Me {
|
|
6126
6131
|
el;
|
|
6127
6132
|
object = {};
|
|
6128
6133
|
children = [];
|
|
@@ -6139,7 +6144,7 @@ class He {
|
|
|
6139
6144
|
n.push(i);
|
|
6140
6145
|
}
|
|
6141
6146
|
}
|
|
6142
|
-
if (n.length > 0 && (e.children = n), (!e.text ||
|
|
6147
|
+
if (n.length > 0 && (e.children = n), (!e.text || Pe(e.text)) && e.children?.length === 1) {
|
|
6143
6148
|
const r = e.children[0];
|
|
6144
6149
|
nc(r) && (r.text && (e.text = r.text), r.textref && (e.textref = r.textref), r.imgref && (e.imgref = r.imgref), r.audioref && (e.audioref = r.audioref), r.videoref && (e.videoref = r.videoref), e.children = r.children);
|
|
6145
6150
|
}
|
|
@@ -6257,7 +6262,7 @@ class on {
|
|
|
6257
6262
|
idAlloc = { claimed: /* @__PURE__ */ new Set(), counters: /* @__PURE__ */ new Map() };
|
|
6258
6263
|
noterefDepth = 0;
|
|
6259
6264
|
allowNode = null;
|
|
6260
|
-
root = new
|
|
6265
|
+
root = new Me();
|
|
6261
6266
|
current = this.root;
|
|
6262
6267
|
segments = [];
|
|
6263
6268
|
textAcc = "";
|
|
@@ -6313,7 +6318,7 @@ class on {
|
|
|
6313
6318
|
return !e.children || e.children.length === 0 ? Ht(e) ? [] : [Mt(e)] : e.children.map(Mt);
|
|
6314
6319
|
}
|
|
6315
6320
|
descend(e) {
|
|
6316
|
-
const n = new
|
|
6321
|
+
const n = new Me();
|
|
6317
6322
|
n.el = e, n.noText = this.current.noText, this.current.children.push(n), this.current = n;
|
|
6318
6323
|
}
|
|
6319
6324
|
appendChild(e) {
|
|
@@ -6382,11 +6387,11 @@ class on {
|
|
|
6382
6387
|
if (this.current.noText) return;
|
|
6383
6388
|
const n = e.nodeValue ?? "";
|
|
6384
6389
|
if (/^\s*$/.test(n)) {
|
|
6385
|
-
(this.textAcc.length > 0 || this.segments.length > 0) && (this.textAcc +=
|
|
6390
|
+
(this.textAcc.length > 0 || this.segments.length > 0) && (this.textAcc += Ie(n, this.flowEndsWithSpace), this.updateFlowSpace());
|
|
6386
6391
|
return;
|
|
6387
6392
|
}
|
|
6388
6393
|
const r = this.textContext(e);
|
|
6389
|
-
Rl(r, this.currentCtx) || (this.closeSegment(), this.currentCtx = r), this.textAcc +=
|
|
6394
|
+
Rl(r, this.currentCtx) || (this.closeSegment(), this.currentCtx = r), this.textAcc += Ie(n, this.flowEndsWithSpace), this.updateFlowSpace();
|
|
6390
6395
|
}
|
|
6391
6396
|
textContext(e) {
|
|
6392
6397
|
const n = { lang: sr(e.parentElement), tag: "" };
|
|
@@ -6410,7 +6415,7 @@ class on {
|
|
|
6410
6415
|
}
|
|
6411
6416
|
placeholder(e, n, r, i) {
|
|
6412
6417
|
if (Ht(r)) return;
|
|
6413
|
-
const s = new
|
|
6418
|
+
const s = new Me();
|
|
6414
6419
|
if (s.el = e, s.object = r, this.current.noText) {
|
|
6415
6420
|
this.appendChild(s);
|
|
6416
6421
|
return;
|
|
@@ -6425,7 +6430,7 @@ class on {
|
|
|
6425
6430
|
pagebreak(e, n, r) {
|
|
6426
6431
|
const i = { role: r }, s = (e.getAttribute("title") ?? "").trim();
|
|
6427
6432
|
s ? i.text = { plain: s, ssml: "", language: "" } : n && (i.text = { plain: n.plain ?? "", ssml: n.ssml ?? "", language: n.language });
|
|
6428
|
-
const o = !!(i.text && !
|
|
6433
|
+
const o = !!(i.text && !Pe(i.text)), a = !this.xmlParsed && (ic(e) || o && e.firstChild !== null);
|
|
6429
6434
|
if (!o && !a) {
|
|
6430
6435
|
const l = We(e);
|
|
6431
6436
|
l && (i.text = { plain: l, ssml: "", language: "" });
|
|
@@ -6556,7 +6561,7 @@ class on {
|
|
|
6556
6561
|
} else m.kind === "break" ? p += "<break/>" : m.kind === "placeholder" && (p += `<readium:${m.tag} id="${At(m.child.object.id)}" />`);
|
|
6557
6562
|
f.ssml = p;
|
|
6558
6563
|
}
|
|
6559
|
-
const y = new
|
|
6564
|
+
const y = new Me();
|
|
6560
6565
|
y.object = { text: f };
|
|
6561
6566
|
for (const p of n)
|
|
6562
6567
|
y.children.push(p);
|
|
@@ -6582,17 +6587,17 @@ export {
|
|
|
6582
6587
|
pl as DirectCommsChannel,
|
|
6583
6588
|
ml as DirectCommsFrame,
|
|
6584
6589
|
yl as DirectCommsHost,
|
|
6585
|
-
|
|
6590
|
+
Fe as EnumPreference,
|
|
6586
6591
|
Ze as Locator,
|
|
6587
6592
|
W as LocatorLocations,
|
|
6588
6593
|
lt as LocatorText,
|
|
6589
6594
|
ct as Preference,
|
|
6590
|
-
|
|
6595
|
+
He as RangePreference,
|
|
6591
6596
|
xl as ReadiumSpeechDecorationController,
|
|
6592
6597
|
kc as ReadiumSpeechNavigator,
|
|
6593
6598
|
wc as ReadiumSpeechProviderRegistry,
|
|
6594
6599
|
kl as SpeechDefaults,
|
|
6595
|
-
|
|
6600
|
+
Ne as SpeechPreferences,
|
|
6596
6601
|
Zn as SpeechPreferencesEditor,
|
|
6597
6602
|
Oo as SpeechServerEngine,
|
|
6598
6603
|
fc as SpeechServerEngineProvider,
|
|
@@ -6603,7 +6608,7 @@ export {
|
|
|
6603
6608
|
gc as WebSpeechEngineProvider,
|
|
6604
6609
|
k as WebSpeechVoiceManager,
|
|
6605
6610
|
Fl as blockLevelRoles,
|
|
6606
|
-
|
|
6611
|
+
Oe as chineseVariantMap,
|
|
6607
6612
|
ho as chunkPlainText,
|
|
6608
6613
|
fo as chunkSsmlText,
|
|
6609
6614
|
Ol as contextualizedAtVerbosity,
|
|
@@ -6622,5 +6627,5 @@ export {
|
|
|
6622
6627
|
Al as skippableAtVerbosity,
|
|
6623
6628
|
Sc as skippableRoles,
|
|
6624
6629
|
dl as supportsDecorationStyle,
|
|
6625
|
-
|
|
6630
|
+
Ae as toSpeechServerError
|
|
6626
6631
|
};
|