ssml-builder-js 2.13.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/dist/core.d.ts CHANGED
@@ -188,6 +188,45 @@ interface BuildPartialSsmlOptions extends SsmlPartialContext {
188
188
  declare function buildPartialSsml(text: string, context?: SsmlPartialContext): string;
189
189
  declare function buildPartialSsml(options: BuildPartialSsmlOptions): string;
190
190
 
191
+ interface SsmlTextNodeContext {
192
+ parentTag: string;
193
+ parentAttributes: Record<string, string>;
194
+ ancestorTags: string[];
195
+ path: string[];
196
+ }
197
+ interface SsmlSourceTextSegment {
198
+ text: string;
199
+ range: {
200
+ start: number;
201
+ end: number;
202
+ };
203
+ sourceNodePath: string[];
204
+ }
205
+ interface SsmlSourceMarker {
206
+ kind: "mark" | "bookmark";
207
+ name: string;
208
+ originalTextRange: {
209
+ start: number;
210
+ end: number;
211
+ };
212
+ sourceNodePath: string[];
213
+ }
214
+ interface SsmlSourceMap {
215
+ text: string;
216
+ segments: SsmlSourceTextSegment[];
217
+ markers: SsmlSourceMarker[];
218
+ }
219
+ interface MapSsmlTextNodesOptions {
220
+ /** Element names whose text should not be passed to the transform. */
221
+ skipTags?: readonly string[];
222
+ /** Decides whether an individual text node should be passed to the transform. */
223
+ filter?: (context: SsmlTextNodeContext) => boolean;
224
+ }
225
+ /** Returns decoded source text segments and marker locations with indexed SSML paths. */
226
+ declare function getSsmlSourceMap(ssml: string): SsmlSourceMap;
227
+ declare function extractSsmlText(ssml: string): string[];
228
+ declare function mapSsmlTextNodes(ssml: string, transform: (text: string, context: SsmlTextNodeContext) => string | Promise<string>, options?: MapSsmlTextNodesOptions): Promise<string>;
229
+
191
230
  interface SsmlTextRange {
192
231
  start: number;
193
232
  end: number;
@@ -204,6 +243,12 @@ interface SsmlChunk {
204
243
  inheritedContext: SsmlChunkContext;
205
244
  containedMarks: string[];
206
245
  hasBackgroundAudio: boolean;
246
+ /** Best-effort path to the first source element represented by this chunk. */
247
+ sourceNodePath?: string[];
248
+ /** Exact source segments represented by this chunk, used for event mapping. */
249
+ sourceTextSegments?: SsmlSourceTextSegment[];
250
+ /** Exact marker locations represented by this chunk, used for bookmark mapping. */
251
+ sourceMarkers?: SsmlSourceMarker[];
207
252
  }
208
253
  interface SplitSsmlOptions {
209
254
  maxLength?: number;
@@ -226,21 +271,6 @@ interface SsmlValidationError {
226
271
  }
227
272
  declare function validateSsml(xmlString: string): SsmlValidationError | null;
228
273
 
229
- interface SsmlTextNodeContext {
230
- parentTag: string;
231
- parentAttributes: Record<string, string>;
232
- ancestorTags: string[];
233
- path: string[];
234
- }
235
- interface MapSsmlTextNodesOptions {
236
- /** Element names whose text should not be passed to the transform. */
237
- skipTags?: readonly string[];
238
- /** Decides whether an individual text node should be passed to the transform. */
239
- filter?: (context: SsmlTextNodeContext) => boolean;
240
- }
241
- declare function extractSsmlText(ssml: string): string[];
242
- declare function mapSsmlTextNodes(ssml: string, transform: (text: string, context: SsmlTextNodeContext) => string | Promise<string>, options?: MapSsmlTextNodesOptions): Promise<string>;
243
-
244
274
  interface ExtractSsmlTranslatableTextOptions {
245
275
  /** Element names whose descendants are not translation targets. */
246
276
  skipTags?: readonly string[];
@@ -316,8 +346,17 @@ interface AzureValidationOptions {
316
346
  customVoiceDefinitions?: readonly AzureVoiceDefinition[];
317
347
  /** Host-side validation hook for URL-bearing SSML attributes. */
318
348
  urlValidator?: AzureUrlValidator;
349
+ /** Source path associated with a chunk being validated. */
350
+ sourceNodePath?: readonly string[];
319
351
  /** Alias for urlValidator retained for applications that use the longer name. */
320
352
  customUrlValidator?: AzureUrlValidator;
353
+ /** Controls deduplication, caching, cancellation, and concurrency for URL checks. */
354
+ urlValidation?: AzureUrlValidationRunnerOptions;
355
+ /** Flat aliases retained for callers that prefer not to nest URL runner options. */
356
+ urlValidatorConcurrency?: number;
357
+ urlValidatorTimeoutMs?: number;
358
+ urlValidatorSignal?: AbortSignal;
359
+ urlValidatorCache?: Map<string, AzureUrlValidationResult>;
321
360
  languageAliases?: Record<string, string | readonly string[]>;
322
361
  maxLength?: number;
323
362
  /** Maximum XML element nesting depth, counting `<speak>` as depth 1. */
@@ -344,7 +383,16 @@ type AzureUrlValidationResult = boolean | {
344
383
  type AzureUrlValidator = (url: string, context: {
345
384
  tag: string;
346
385
  attribute: string;
347
- }) => AzureUrlValidationResult | Promise<AzureUrlValidationResult>;
386
+ sourceNodePath?: readonly string[];
387
+ }, signal: AbortSignal) => AzureUrlValidationResult | Promise<AzureUrlValidationResult>;
388
+ interface AzureUrlValidationRunnerOptions {
389
+ concurrency?: number;
390
+ cache?: Map<string, AzureUrlValidationResult>;
391
+ signal?: AbortSignal;
392
+ timeoutMs?: number;
393
+ }
394
+ /** Wraps a URL validator with URL deduplication, bounded concurrency, caching, and cancellation. */
395
+ declare function createAzureUrlValidatorRunner(validator: AzureUrlValidator, options?: AzureUrlValidationRunnerOptions): AzureUrlValidator;
348
396
  type AzureLanguageNormalizationOptions = Pick<AzureValidationOptions, "languageAliases" | "normalizeLanguage">;
349
397
  /** @deprecated Use AzureValidationOptions instead. */
350
398
  type AzureSsmlValidationOptions = AzureValidationOptions;
@@ -376,4 +424,4 @@ declare function getAzureVoiceCatalogMetadata(): AzureVoiceCatalogMetadata;
376
424
  /** Alias for consumers that refer to the bundled catalog as the built-in catalog. */
377
425
  declare const getBuiltInVoiceCatalogMetadata: typeof getAzureVoiceCatalogMetadata;
378
426
 
379
- export { type AudioElement, type AzureDiagnosticCode, type AzureLanguageNormalizationOptions, type AzureSsmlValidationOptions, type AzureUrlValidationResult, type AzureUrlValidator, type AzureValidationOptions, type AzureVoiceCatalogMetadata, type AzureVoiceDefinition, type AzureVoiceMetadata, type BookmarkElement, type BreakElement, type BuildPartialSsmlOptions, type CustomElement, type EmphasisElement, type ExpressAsElement, type ExtractSsmlTranslatableTextOptions, type FromPlainTextToSsmlOptions, type LangElement, type LexiconElement, type MapSsmlTextNodesOptions, type MarkElement, type MsttsAudioDurationElement, type MsttsEmbeddingElement, type MsttsSilenceElement, type MsttsTtsEmbeddingElement, type MsttsVisemeElement, type MsttsVoiceConversionElement, type NamedElement, type ParagraphElement, type PhonemeElement, type ProsodyElement, type SayAsElement, type SentenceElement, type SplitSsmlOptions, type SsmlAttributeValue, type SsmlAttributes, type SsmlBackgroundAudioNode, type SsmlBreakElement, type SsmlChunk, type SsmlChunkContext, type SsmlDiagnostic, type SsmlDiagnosticSeverity, type SsmlDiagnosticSource, type SsmlDialogNode, type SsmlDocument, type SsmlElement, type SsmlElementBase, type SsmlEmbeddingNode, type SsmlExpressAsElement, type SsmlNode, type SsmlPartialContext, type SsmlPartialProsody, type SsmlPartialVoice, type SsmlPhonemeElement, type SsmlProsodyElement, type SsmlSayAsElement, type SsmlStructureIntegrityResult, type SsmlStructureMismatch, type SsmlText, type SsmlTextNodeContext, type SsmlTextRange, type SsmlTtsEmbeddingNode, type SsmlTurnNode, type SsmlValidationError, type SsmlVoiceConversionNode, type SsmlVoiceElement, type SubElement, type VoiceElement, type WordElement, areAzureLanguagesEquivalent, buildPartialSsml, buildSsml, extractSsmlText, extractSsmlTranslatableText, fromPlainTextToSsml, getAzureVoiceCatalogMetadata, getBuiltInVoiceCatalogMetadata, isValidAzureAudioDuration, mapSsmlTextNodes, normalizeAzureLanguage, parseSsml, splitSsmlDocument, validateAzureSsml, validateSsml, validateSsmlStructureIntegrity };
427
+ export { type AudioElement, type AzureDiagnosticCode, type AzureLanguageNormalizationOptions, type AzureSsmlValidationOptions, type AzureUrlValidationResult, type AzureUrlValidationRunnerOptions, type AzureUrlValidator, type AzureValidationOptions, type AzureVoiceCatalogMetadata, type AzureVoiceDefinition, type AzureVoiceMetadata, type BookmarkElement, type BreakElement, type BuildPartialSsmlOptions, type CustomElement, type EmphasisElement, type ExpressAsElement, type ExtractSsmlTranslatableTextOptions, type FromPlainTextToSsmlOptions, type LangElement, type LexiconElement, type MapSsmlTextNodesOptions, type MarkElement, type MsttsAudioDurationElement, type MsttsEmbeddingElement, type MsttsSilenceElement, type MsttsTtsEmbeddingElement, type MsttsVisemeElement, type MsttsVoiceConversionElement, type NamedElement, type ParagraphElement, type PhonemeElement, type ProsodyElement, type SayAsElement, type SentenceElement, type SplitSsmlOptions, type SsmlAttributeValue, type SsmlAttributes, type SsmlBackgroundAudioNode, type SsmlBreakElement, type SsmlChunk, type SsmlChunkContext, type SsmlDiagnostic, type SsmlDiagnosticSeverity, type SsmlDiagnosticSource, type SsmlDialogNode, type SsmlDocument, type SsmlElement, type SsmlElementBase, type SsmlEmbeddingNode, type SsmlExpressAsElement, type SsmlNode, type SsmlPartialContext, type SsmlPartialProsody, type SsmlPartialVoice, type SsmlPhonemeElement, type SsmlProsodyElement, type SsmlSayAsElement, type SsmlSourceMap, type SsmlSourceMarker, type SsmlSourceTextSegment, type SsmlStructureIntegrityResult, type SsmlStructureMismatch, type SsmlText, type SsmlTextNodeContext, type SsmlTextRange, type SsmlTtsEmbeddingNode, type SsmlTurnNode, type SsmlValidationError, type SsmlVoiceConversionNode, type SsmlVoiceElement, type SubElement, type VoiceElement, type WordElement, areAzureLanguagesEquivalent, buildPartialSsml, buildSsml, createAzureUrlValidatorRunner, extractSsmlText, extractSsmlTranslatableText, fromPlainTextToSsml, getAzureVoiceCatalogMetadata, getBuiltInVoiceCatalogMetadata, getSsmlSourceMap, isValidAzureAudioDuration, mapSsmlTextNodes, normalizeAzureLanguage, parseSsml, splitSsmlDocument, validateAzureSsml, validateSsml, validateSsmlStructureIntegrity };