ssml-builder-js 2.14.0 → 2.15.0
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/README.md +6 -4
- package/dist/{chunk-UZSCXPC5.mjs → chunk-BDY2Q2JL.mjs} +2 -2
- package/dist/{chunk-AQ55MOPU.mjs → chunk-FXUM45ZY.mjs} +305 -173
- package/dist/chunk-FXUM45ZY.mjs.map +1 -0
- package/dist/{chunk-QFIBPCO4.mjs → chunk-WXFLUCLR.mjs} +164 -17
- package/dist/chunk-WXFLUCLR.mjs.map +1 -0
- package/dist/core.d.mts +48 -17
- package/dist/core.d.ts +48 -17
- package/dist/core.js +303 -170
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +3 -1
- package/dist/elements.js +38 -16
- package/dist/elements.js.map +1 -1
- package/dist/elements.mjs +2 -2
- package/dist/{index.d-CUXRwSw0.d.mts → index.d-8BvkB9gz.d.mts} +22 -2
- package/dist/{index.d-CUXRwSw0.d.ts → index.d-8BvkB9gz.d.ts} +22 -2
- package/dist/index.d.mts +114 -18
- package/dist/index.d.ts +114 -18
- package/dist/index.js +1783 -1281
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +307 -86
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +11 -2
- package/dist/react.d.ts +11 -2
- package/dist/react.js +115 -28
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +79 -14
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-AQ55MOPU.mjs.map +0 -1
- package/dist/chunk-QFIBPCO4.mjs.map +0 -1
- /package/dist/{chunk-UZSCXPC5.mjs.map → chunk-BDY2Q2JL.mjs.map} +0 -0
package/dist/core.mjs
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
fromPlainTextToSsml,
|
|
9
9
|
getAzureVoiceCatalogMetadata,
|
|
10
10
|
getBuiltInVoiceCatalogMetadata,
|
|
11
|
+
getSsmlSourceMap,
|
|
11
12
|
isValidAzureAudioDuration,
|
|
12
13
|
mapSsmlTextNodes,
|
|
13
14
|
normalizeAzureLanguage,
|
|
@@ -16,7 +17,7 @@ import {
|
|
|
16
17
|
validateAzureSsml,
|
|
17
18
|
validateSsml,
|
|
18
19
|
validateSsmlStructureIntegrity
|
|
19
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-FXUM45ZY.mjs";
|
|
20
21
|
import "./chunk-6S5ODO6A.mjs";
|
|
21
22
|
export {
|
|
22
23
|
areAzureLanguagesEquivalent,
|
|
@@ -28,6 +29,7 @@ export {
|
|
|
28
29
|
fromPlainTextToSsml,
|
|
29
30
|
getAzureVoiceCatalogMetadata,
|
|
30
31
|
getBuiltInVoiceCatalogMetadata,
|
|
32
|
+
getSsmlSourceMap,
|
|
31
33
|
isValidAzureAudioDuration,
|
|
32
34
|
mapSsmlTextNodes,
|
|
33
35
|
normalizeAzureLanguage,
|
package/dist/elements.js
CHANGED
|
@@ -1024,34 +1024,51 @@ function createAzureUrlValidatorRunner(validator, options = {}) {
|
|
|
1024
1024
|
const inFlight = /* @__PURE__ */ new Map();
|
|
1025
1025
|
const waiters = [];
|
|
1026
1026
|
let active = 0;
|
|
1027
|
-
const
|
|
1027
|
+
const configuredSignal = options.signal ?? new AbortController().signal;
|
|
1028
|
+
const acquire = async (signal) => {
|
|
1029
|
+
if (signal.aborted) throw new Error("URL validation was aborted.");
|
|
1028
1030
|
if (active < concurrency) {
|
|
1029
1031
|
active += 1;
|
|
1030
1032
|
return;
|
|
1031
1033
|
}
|
|
1032
|
-
await new Promise((resolve) =>
|
|
1034
|
+
await new Promise((resolve, reject) => {
|
|
1035
|
+
let waiter;
|
|
1036
|
+
const abortHandler = () => {
|
|
1037
|
+
const index = waiters.indexOf(waiter);
|
|
1038
|
+
if (index >= 0) waiters.splice(index, 1);
|
|
1039
|
+
signal.removeEventListener("abort", abortHandler);
|
|
1040
|
+
reject(new Error("URL validation was aborted."));
|
|
1041
|
+
};
|
|
1042
|
+
signal.addEventListener("abort", abortHandler, { once: true });
|
|
1043
|
+
waiter = () => {
|
|
1044
|
+
signal.removeEventListener("abort", abortHandler);
|
|
1045
|
+
resolve();
|
|
1046
|
+
};
|
|
1047
|
+
waiters.push(waiter);
|
|
1048
|
+
});
|
|
1033
1049
|
active += 1;
|
|
1034
1050
|
};
|
|
1035
1051
|
const release = () => {
|
|
1036
1052
|
active -= 1;
|
|
1037
1053
|
waiters.shift()?.();
|
|
1038
1054
|
};
|
|
1039
|
-
const check = async (url, context) => {
|
|
1040
|
-
if (
|
|
1041
|
-
const
|
|
1055
|
+
const check = async (url, context, signal = configuredSignal) => {
|
|
1056
|
+
if (signal.aborted) throw new Error("URL validation was aborted.");
|
|
1057
|
+
const key = `${context.tag}:${context.attribute}:${url}`;
|
|
1058
|
+
const cached = cache.get(key);
|
|
1042
1059
|
if (cached !== void 0) return cached;
|
|
1043
|
-
const existing = inFlight.get(
|
|
1060
|
+
const existing = inFlight.get(key);
|
|
1044
1061
|
if (existing) return existing;
|
|
1045
1062
|
const promise = (async () => {
|
|
1046
|
-
await acquire();
|
|
1063
|
+
await acquire(signal);
|
|
1047
1064
|
try {
|
|
1048
|
-
if (
|
|
1049
|
-
const validation = Promise.resolve(validator(url, context));
|
|
1065
|
+
if (signal.aborted) throw new Error("URL validation was aborted.");
|
|
1066
|
+
const validation = Promise.resolve(validator(url, context, signal));
|
|
1050
1067
|
let timer;
|
|
1051
1068
|
let abortHandler;
|
|
1052
1069
|
const cancellation = new Promise((_resolve, reject) => {
|
|
1053
1070
|
abortHandler = () => reject(new Error("URL validation was aborted."));
|
|
1054
|
-
|
|
1071
|
+
signal.addEventListener("abort", abortHandler, { once: true });
|
|
1055
1072
|
if (options.timeoutMs !== void 0 && options.timeoutMs > 0) {
|
|
1056
1073
|
timer = setTimeout(
|
|
1057
1074
|
() => reject(new Error(`URL validation timed out after ${options.timeoutMs} ms.`)),
|
|
@@ -1061,24 +1078,24 @@ function createAzureUrlValidatorRunner(validator, options = {}) {
|
|
|
1061
1078
|
});
|
|
1062
1079
|
try {
|
|
1063
1080
|
const result = await (timer || abortHandler ? Promise.race([validation, cancellation]) : validation);
|
|
1064
|
-
cache.set(
|
|
1081
|
+
cache.set(key, result);
|
|
1065
1082
|
return result;
|
|
1066
1083
|
} finally {
|
|
1067
1084
|
if (timer) clearTimeout(timer);
|
|
1068
|
-
if (abortHandler)
|
|
1085
|
+
if (abortHandler) signal.removeEventListener("abort", abortHandler);
|
|
1069
1086
|
}
|
|
1070
1087
|
} finally {
|
|
1071
1088
|
release();
|
|
1072
1089
|
}
|
|
1073
1090
|
})();
|
|
1074
|
-
inFlight.set(
|
|
1091
|
+
inFlight.set(key, promise);
|
|
1075
1092
|
try {
|
|
1076
1093
|
return await promise;
|
|
1077
1094
|
} finally {
|
|
1078
|
-
inFlight.delete(
|
|
1095
|
+
inFlight.delete(key);
|
|
1079
1096
|
}
|
|
1080
1097
|
};
|
|
1081
|
-
return (url, context) => check(url, context);
|
|
1098
|
+
return (url, context, signal) => check(url, context, signal ?? configuredSignal);
|
|
1082
1099
|
}
|
|
1083
1100
|
var ALLOWED_BREAK_STRENGTHS = /* @__PURE__ */ new Set(["none", "x-weak", "weak", "medium", "strong", "x-strong"]);
|
|
1084
1101
|
var ALLOWED_SAY_AS = /* @__PURE__ */ new Set([
|
|
@@ -1724,6 +1741,7 @@ function validateAzureSsml(ssml, options = {}) {
|
|
|
1724
1741
|
...options.urlValidatorSignal ? { signal: options.urlValidatorSignal } : {},
|
|
1725
1742
|
...options.urlValidatorCache ? { cache: options.urlValidatorCache } : {}
|
|
1726
1743
|
});
|
|
1744
|
+
const validationSignal = options.urlValidatorSignal ?? options.urlValidation?.signal ?? new AbortController().signal;
|
|
1727
1745
|
let tokens;
|
|
1728
1746
|
try {
|
|
1729
1747
|
tokens = tokenizeElements(ssml);
|
|
@@ -1733,7 +1751,11 @@ function validateAzureSsml(ssml, options = {}) {
|
|
|
1733
1751
|
const checks = tokens.flatMap(
|
|
1734
1752
|
(token) => urlAttributes(token).map(async ({ attribute, value }) => {
|
|
1735
1753
|
try {
|
|
1736
|
-
const result = await boundedValidator(
|
|
1754
|
+
const result = await boundedValidator(
|
|
1755
|
+
value,
|
|
1756
|
+
{ tag: token.name, attribute, ...options.sourceNodePath ? { sourceNodePath: options.sourceNodePath } : {} },
|
|
1757
|
+
validationSignal
|
|
1758
|
+
);
|
|
1737
1759
|
const valid = typeof result === "boolean" ? result : result.valid;
|
|
1738
1760
|
if (!valid) {
|
|
1739
1761
|
const reason = typeof result === "boolean" ? void 0 : result.reason;
|