accessibility-plugin-react 2.30.0 → 2.30.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/dist/index.d.mts CHANGED
@@ -1968,6 +1968,17 @@ declare function createOfflineMockTranslationAdapter(options?: {
1968
1968
  prefix?: string;
1969
1969
  supportedLanguages?: string[];
1970
1970
  }): TranslationAdapter;
1971
+ interface GoogleTranslateAdapterOptions {
1972
+ endpoint?: string;
1973
+ concurrency?: number;
1974
+ fallbackToOffline?: boolean;
1975
+ fetchImpl?: typeof fetch;
1976
+ }
1977
+ /**
1978
+ * Creates a client-side Google Translate adapter using the CORS-enabled
1979
+ * translate_a/single endpoint, with optional in-memory caching and offline fallback.
1980
+ */
1981
+ declare function createGoogleTranslateAdapter(options?: GoogleTranslateAdapterOptions): TranslationAdapter;
1971
1982
  /**
1972
1983
  * Coordinates end-to-end host content translation:
1973
1984
  * 1. Verifies user consent status (throws if unprompted, denied, or revoked).
@@ -1994,4 +2005,4 @@ interface TranslationControllerProps {
1994
2005
  }
1995
2006
  declare const TranslationController: react__default.FC<TranslationControllerProps>;
1996
2007
 
1997
- export { ALLOWED_PREFERENCE_KEYS, ALL_PROFILE_IDS, AccessibilityButton, type AccessibilityButtonProps, AccessibilityContext, type AccessibilityContextValue, type AccessibilityEventType, type AccessibilityFeatureEvent, AccessibilityList, type AccessibilityListProps, AccessibilityPlugin, type AccessibilityPluginProps, type AccessibilityPreferences, AccessibilityProfilesController, type AccessibilityState, AccessibleTooltipsController, type ActiveProfileState, type AppliedSmartContrast, type ApplyPageOptions, type ArticleContent, type BackdropResolution, type BaseAccessibilityEvent, BigCursorController, type BigCursorControllerProps, CONTRAST_MODES, CONTRAST_PALETTES, CONTRAST_PROTECTED_SELECTOR, ChoiceControl, type ChoiceControlProps, type ChoiceGroup, type ChoiceOption, ContrastController, type ContrastMode, ContrastModeController, type ContrastModeValue, type ContrastPalette, type CursorSizePreference, type CustomPreset, CustomPresetsController, DEFAULT_FEATURE_GROUP_MAP, DEFAULT_MENU_GROUPS, DEFAULT_PREFERENCES, DEFAULT_READING_MASK_HEIGHT, DEFAULT_SHORTCUTS, DIAGNOSTICS_DISCLAIMER, DYSLEXIA_FONT_STACK, type DataRetentionPolicy, type DiagnosticCategory, type DiagnosticIssue, type DiagnosticSeverity, type DiagnosticsConfig, DiagnosticsHarness, type DiagnosticsHarnessProps, type DiagnosticsReport, type DiagnosticsSummary, DictionaryController, type DictionaryControllerProps, type DictionaryEntry, type DictionaryLookupResult, type DictionaryProvider, type EffectScopeTarget, type EffectsSession, EmptyState, type EmptyStateProps, ErrorState, type ErrorStateProps, type EventTriggerSource, FONT_FAMILY_PRESETS, FONT_FAMILY_PROTECTED_SELECTOR, FeatureCard, type FeatureCardProps, type FeatureChangeEvent, type FeatureEventListener, FeatureGroup, type FeatureGroupProps, type FeatureLocaleLabels, FeatureMenu, type FeatureMenuGroupConfig, type FeatureMenuItemConfig, type FeatureMenuProps, type FeatureOptions, type FeatureRegistration, type FeatureResetEvent, type FeatureStatus, FocusHighlightController, FontFamilyController, type FontFamilyPreference, type FontFamilyPreset, FontSizeController, type FontSizeControllerProps, GrayscaleController, type GrayscaleControllerProps, HIGH_CONTRAST_TOKENS, type HeadingItem, HeadingsNavigatorController, HideDecorativeImagesController, HideImagesController, type HideImagesControllerProps, HideVideosController, HighlightFocusController, type ImportResult, InvertColorsController, KNOWN_FEATURE_IDS, KeyboardShortcutsController, type KeyboardShortcutsControllerProps, LEGIBLE_FONT_STACK, LINE_HEIGHT_RATIOS, LINE_HEIGHT_STEPS, LOCAL_DICTIONARY_EN, LOCAL_DICTIONARY_SI, LOCAL_DICTIONARY_TA, type LandmarkItem, LetterSpacingController, type LetterSpacingControllerProps, LineHeightController, type LineHeightControllerProps, LinkHighlightController, type LinkItem, type LocaleStrings, MAX_HOST_ELEMENTS, MAX_NODES_PER_TRANSLATION_BATCH, MAX_READING_MASK_HEIGHT, MAX_TEXT_LENGTH_PER_NODE, MIN_READING_MASK_HEIGHT, type MenuCustomizationConfig, type MenuValidationIssue, type MenuValidationResult, ModalDialog, type ModalDialogProps, type NormalizedMenuConfig, type NormalizedMenuGroup, type NormalizedMenuItem, PROFILE_DEFINITIONS, PageNavigatorController, type PageNavigatorControllerProps, PageStructureController, type PanelToggleEvent, ParagraphSpacingController, type ParagraphSpacingControllerProps, type PlacementChangeEvent, type PluginPosition, type PresetApplyEvent, PresetsBackupController, PresetsController, type PresetsControllerProps, type PresetsExportV1, type ProfileApplyEvent, ProfileController, type ProfileDefinition, type ProfilePresetId, ProfilePreviewCard, type ProfilePreviewCardProps, ProfilesController, type ProfilesControllerProps, READING_MASK_HEIGHT_PRESETS, READ_ALOUD_EXCLUDED_SELECTORS, RESERVED_BROWSER_SHORTCUTS, ReadAloudController, type ReadAloudControllerProps, type ReadAloudOptions, ReadAloudSession, type ReadAloudState, type ReaderMode, ReadingGuideController, type ReadingGuideControllerProps, ReadingMaskController, type ReadingMaskControllerProps, ReadingModeController, type ReadingModeControllerProps, ReduceMotionController, ResetController, type RgbColor, type RgbaColor, SMART_CONTRAST_DISCLAIMER, SaturationController, type SaturationControllerProps, type SaturationPreference, type ScriptSpacingConstraints, SearchCount, type SearchCountProps, SettingsImportExportController, type ShortcutDefinition, SkipToMainLink, type SkipToMainLinkProps, SmartContrastController, type SmartContrastLevel, type SmartContrastOptions, type SmartContrastReport, StepperControl, type StepperControlProps, type StorageMode, type SupportedLocale, TARGET_RATIOS, TEXT_ALIGN_BLOCK_SELECTOR, TEXT_SCALE_PROTECTED_SELECTOR, TEXT_SCALE_STEPS, TEXT_SPACING_EXCLUDED_SELECTOR, TRANSLATION_DISCLAIMER, TRANSLATION_ERROR_CODES, TextAlignController, type TextAlignPreference, TextScaleController, type TextScaleControllerProps, type TextScaleStep, ToggleControl, type ToggleControlProps, TooltipsController, type TooltipsControllerProps, type TranslatableNode, type TranslatedItem, type TranslationAdapter, type TranslationConsentRecord, type TranslationConsentStatus, TranslationController, type TranslationControllerProps, TranslationError, type TranslationErrorCode, type TranslationRequest, type TranslationResponse, type TranslationSession, type UnsupportedElementInfo, type UnsupportedReason, type UsePresetsResult, type UseProfilesResult, VOICE_COMMANDS, VOICE_NAVIGATION_DISCLAIMER, type ValidationResult, type VoiceCommandDefinition, type VoiceCommandId, type VoiceExecutionContext, VoiceNavigationController, type VoiceNavigationControllerProps, type VoiceNavigationOptions, type VoiceNavigationResult, type VoiceNavigationSession, type VoiceNavigationStatus, type WidgetPlacement, WordSpacingController, type WordSpacingControllerProps, applyCustomPresetToStore, applyPage, applyPageSession, applyProfileToStore, applySmartContrast, applyTranslations, calculateContrastRatio, calculateRelativeLuminance, checkBoundariesDiagnostics, checkCspDiagnostics, checkDomDiagnostics, checkHostCssDiagnostics, checkProviderDiagnostics, checkStorageDiagnostics, compositeRgba, countWords, createCustomPreset, createInitialPreferencesState, createOfflineMockTranslationAdapter, createVoiceNavigationSession, downloadJsonFile, emitFeatureEvent, enLocale, enableAccessibleTooltips, estimateReadingTime, evaluateSmartContrast, executeVoiceCommand, exportPresetsToJson, extractArticleContent, extractReadAloudText, extractTranslatableNodes, findArticleCandidate, findMainLandmark, getActiveSelectionText, getAuthoredDescription, getMenuConfigSignature, getProfileDefinition, getScriptSpacingConstraints, getSpeechVoices, hasFinePointer, isEligibleDecorativeImage, isEligibleForSmartContrast, isForcedColorsActive, isFormFieldOrEditable, isFunctionalOrMeaningfulImage, isLargeText, isProtectedFromContrast, isProtectedFromFontFamily, isProtectedFromTextAlign, isProtectedFromTextScale, isProtectedFromTextSpacing, isReducedMotionActive, isRtlLocale, isSensitiveElement, isSpeechRecognitionSupported, isSpeechSynthesisSupported, isValidCustomPreset, lookupLocalDictionary, lookupWord, mapFeaturesToProfileSettings, mapProfileSettingsToFeatures, matchVoiceCommand, navigateToElement, normalizeKeyCombo, normalizePreferenceValue, normalizePreferences, normalizeTranscript, nudgeReadingAid, parseColor, parseKeyboardEventToCombo, positionTooltip, preferencesReducer, recordProfileOverride, registerLocale, resolveActiveShortcut, resolveEffectScope, resolveEffectiveBackdrop, resolveEffectivePreferences, resolveLocaleStrings, revertProfileFromStore, runDiagnostics, sanitizeFeatureEvent, sanitizeLookupTerm, sanitizePreferences, sanitizeTranslationOutput, scanHeadings, scanLandmarks, scanLinks, siLocale, splitTextIntoChunks, subscribeFinePointer, subscribeForcedColors, subscribePageStructure, subscribeReducedMotion, subscribeSpeechVoices, taLocale, translateHostContent, useAccessibility, useDiagnostics, usePresets, useProfiles, validateAndParseImport, validateMenuConfig, validateShortcutRemap };
2008
+ export { ALLOWED_PREFERENCE_KEYS, ALL_PROFILE_IDS, AccessibilityButton, type AccessibilityButtonProps, AccessibilityContext, type AccessibilityContextValue, type AccessibilityEventType, type AccessibilityFeatureEvent, AccessibilityList, type AccessibilityListProps, AccessibilityPlugin, type AccessibilityPluginProps, type AccessibilityPreferences, AccessibilityProfilesController, type AccessibilityState, AccessibleTooltipsController, type ActiveProfileState, type AppliedSmartContrast, type ApplyPageOptions, type ArticleContent, type BackdropResolution, type BaseAccessibilityEvent, BigCursorController, type BigCursorControllerProps, CONTRAST_MODES, CONTRAST_PALETTES, CONTRAST_PROTECTED_SELECTOR, ChoiceControl, type ChoiceControlProps, type ChoiceGroup, type ChoiceOption, ContrastController, type ContrastMode, ContrastModeController, type ContrastModeValue, type ContrastPalette, type CursorSizePreference, type CustomPreset, CustomPresetsController, DEFAULT_FEATURE_GROUP_MAP, DEFAULT_MENU_GROUPS, DEFAULT_PREFERENCES, DEFAULT_READING_MASK_HEIGHT, DEFAULT_SHORTCUTS, DIAGNOSTICS_DISCLAIMER, DYSLEXIA_FONT_STACK, type DataRetentionPolicy, type DiagnosticCategory, type DiagnosticIssue, type DiagnosticSeverity, type DiagnosticsConfig, DiagnosticsHarness, type DiagnosticsHarnessProps, type DiagnosticsReport, type DiagnosticsSummary, DictionaryController, type DictionaryControllerProps, type DictionaryEntry, type DictionaryLookupResult, type DictionaryProvider, type EffectScopeTarget, type EffectsSession, EmptyState, type EmptyStateProps, ErrorState, type ErrorStateProps, type EventTriggerSource, FONT_FAMILY_PRESETS, FONT_FAMILY_PROTECTED_SELECTOR, FeatureCard, type FeatureCardProps, type FeatureChangeEvent, type FeatureEventListener, FeatureGroup, type FeatureGroupProps, type FeatureLocaleLabels, FeatureMenu, type FeatureMenuGroupConfig, type FeatureMenuItemConfig, type FeatureMenuProps, type FeatureOptions, type FeatureRegistration, type FeatureResetEvent, type FeatureStatus, FocusHighlightController, FontFamilyController, type FontFamilyPreference, type FontFamilyPreset, FontSizeController, type FontSizeControllerProps, type GoogleTranslateAdapterOptions, GrayscaleController, type GrayscaleControllerProps, HIGH_CONTRAST_TOKENS, type HeadingItem, HeadingsNavigatorController, HideDecorativeImagesController, HideImagesController, type HideImagesControllerProps, HideVideosController, HighlightFocusController, type ImportResult, InvertColorsController, KNOWN_FEATURE_IDS, KeyboardShortcutsController, type KeyboardShortcutsControllerProps, LEGIBLE_FONT_STACK, LINE_HEIGHT_RATIOS, LINE_HEIGHT_STEPS, LOCAL_DICTIONARY_EN, LOCAL_DICTIONARY_SI, LOCAL_DICTIONARY_TA, type LandmarkItem, LetterSpacingController, type LetterSpacingControllerProps, LineHeightController, type LineHeightControllerProps, LinkHighlightController, type LinkItem, type LocaleStrings, MAX_HOST_ELEMENTS, MAX_NODES_PER_TRANSLATION_BATCH, MAX_READING_MASK_HEIGHT, MAX_TEXT_LENGTH_PER_NODE, MIN_READING_MASK_HEIGHT, type MenuCustomizationConfig, type MenuValidationIssue, type MenuValidationResult, ModalDialog, type ModalDialogProps, type NormalizedMenuConfig, type NormalizedMenuGroup, type NormalizedMenuItem, PROFILE_DEFINITIONS, PageNavigatorController, type PageNavigatorControllerProps, PageStructureController, type PanelToggleEvent, ParagraphSpacingController, type ParagraphSpacingControllerProps, type PlacementChangeEvent, type PluginPosition, type PresetApplyEvent, PresetsBackupController, PresetsController, type PresetsControllerProps, type PresetsExportV1, type ProfileApplyEvent, ProfileController, type ProfileDefinition, type ProfilePresetId, ProfilePreviewCard, type ProfilePreviewCardProps, ProfilesController, type ProfilesControllerProps, READING_MASK_HEIGHT_PRESETS, READ_ALOUD_EXCLUDED_SELECTORS, RESERVED_BROWSER_SHORTCUTS, ReadAloudController, type ReadAloudControllerProps, type ReadAloudOptions, ReadAloudSession, type ReadAloudState, type ReaderMode, ReadingGuideController, type ReadingGuideControllerProps, ReadingMaskController, type ReadingMaskControllerProps, ReadingModeController, type ReadingModeControllerProps, ReduceMotionController, ResetController, type RgbColor, type RgbaColor, SMART_CONTRAST_DISCLAIMER, SaturationController, type SaturationControllerProps, type SaturationPreference, type ScriptSpacingConstraints, SearchCount, type SearchCountProps, SettingsImportExportController, type ShortcutDefinition, SkipToMainLink, type SkipToMainLinkProps, SmartContrastController, type SmartContrastLevel, type SmartContrastOptions, type SmartContrastReport, StepperControl, type StepperControlProps, type StorageMode, type SupportedLocale, TARGET_RATIOS, TEXT_ALIGN_BLOCK_SELECTOR, TEXT_SCALE_PROTECTED_SELECTOR, TEXT_SCALE_STEPS, TEXT_SPACING_EXCLUDED_SELECTOR, TRANSLATION_DISCLAIMER, TRANSLATION_ERROR_CODES, TextAlignController, type TextAlignPreference, TextScaleController, type TextScaleControllerProps, type TextScaleStep, ToggleControl, type ToggleControlProps, TooltipsController, type TooltipsControllerProps, type TranslatableNode, type TranslatedItem, type TranslationAdapter, type TranslationConsentRecord, type TranslationConsentStatus, TranslationController, type TranslationControllerProps, TranslationError, type TranslationErrorCode, type TranslationRequest, type TranslationResponse, type TranslationSession, type UnsupportedElementInfo, type UnsupportedReason, type UsePresetsResult, type UseProfilesResult, VOICE_COMMANDS, VOICE_NAVIGATION_DISCLAIMER, type ValidationResult, type VoiceCommandDefinition, type VoiceCommandId, type VoiceExecutionContext, VoiceNavigationController, type VoiceNavigationControllerProps, type VoiceNavigationOptions, type VoiceNavigationResult, type VoiceNavigationSession, type VoiceNavigationStatus, type WidgetPlacement, WordSpacingController, type WordSpacingControllerProps, applyCustomPresetToStore, applyPage, applyPageSession, applyProfileToStore, applySmartContrast, applyTranslations, calculateContrastRatio, calculateRelativeLuminance, checkBoundariesDiagnostics, checkCspDiagnostics, checkDomDiagnostics, checkHostCssDiagnostics, checkProviderDiagnostics, checkStorageDiagnostics, compositeRgba, countWords, createCustomPreset, createGoogleTranslateAdapter, createInitialPreferencesState, createOfflineMockTranslationAdapter, createVoiceNavigationSession, downloadJsonFile, emitFeatureEvent, enLocale, enableAccessibleTooltips, estimateReadingTime, evaluateSmartContrast, executeVoiceCommand, exportPresetsToJson, extractArticleContent, extractReadAloudText, extractTranslatableNodes, findArticleCandidate, findMainLandmark, getActiveSelectionText, getAuthoredDescription, getMenuConfigSignature, getProfileDefinition, getScriptSpacingConstraints, getSpeechVoices, hasFinePointer, isEligibleDecorativeImage, isEligibleForSmartContrast, isForcedColorsActive, isFormFieldOrEditable, isFunctionalOrMeaningfulImage, isLargeText, isProtectedFromContrast, isProtectedFromFontFamily, isProtectedFromTextAlign, isProtectedFromTextScale, isProtectedFromTextSpacing, isReducedMotionActive, isRtlLocale, isSensitiveElement, isSpeechRecognitionSupported, isSpeechSynthesisSupported, isValidCustomPreset, lookupLocalDictionary, lookupWord, mapFeaturesToProfileSettings, mapProfileSettingsToFeatures, matchVoiceCommand, navigateToElement, normalizeKeyCombo, normalizePreferenceValue, normalizePreferences, normalizeTranscript, nudgeReadingAid, parseColor, parseKeyboardEventToCombo, positionTooltip, preferencesReducer, recordProfileOverride, registerLocale, resolveActiveShortcut, resolveEffectScope, resolveEffectiveBackdrop, resolveEffectivePreferences, resolveLocaleStrings, revertProfileFromStore, runDiagnostics, sanitizeFeatureEvent, sanitizeLookupTerm, sanitizePreferences, sanitizeTranslationOutput, scanHeadings, scanLandmarks, scanLinks, siLocale, splitTextIntoChunks, subscribeFinePointer, subscribeForcedColors, subscribePageStructure, subscribeReducedMotion, subscribeSpeechVoices, taLocale, translateHostContent, useAccessibility, useDiagnostics, usePresets, useProfiles, validateAndParseImport, validateMenuConfig, validateShortcutRemap };
package/dist/index.d.ts CHANGED
@@ -1968,6 +1968,17 @@ declare function createOfflineMockTranslationAdapter(options?: {
1968
1968
  prefix?: string;
1969
1969
  supportedLanguages?: string[];
1970
1970
  }): TranslationAdapter;
1971
+ interface GoogleTranslateAdapterOptions {
1972
+ endpoint?: string;
1973
+ concurrency?: number;
1974
+ fallbackToOffline?: boolean;
1975
+ fetchImpl?: typeof fetch;
1976
+ }
1977
+ /**
1978
+ * Creates a client-side Google Translate adapter using the CORS-enabled
1979
+ * translate_a/single endpoint, with optional in-memory caching and offline fallback.
1980
+ */
1981
+ declare function createGoogleTranslateAdapter(options?: GoogleTranslateAdapterOptions): TranslationAdapter;
1971
1982
  /**
1972
1983
  * Coordinates end-to-end host content translation:
1973
1984
  * 1. Verifies user consent status (throws if unprompted, denied, or revoked).
@@ -1994,4 +2005,4 @@ interface TranslationControllerProps {
1994
2005
  }
1995
2006
  declare const TranslationController: react__default.FC<TranslationControllerProps>;
1996
2007
 
1997
- export { ALLOWED_PREFERENCE_KEYS, ALL_PROFILE_IDS, AccessibilityButton, type AccessibilityButtonProps, AccessibilityContext, type AccessibilityContextValue, type AccessibilityEventType, type AccessibilityFeatureEvent, AccessibilityList, type AccessibilityListProps, AccessibilityPlugin, type AccessibilityPluginProps, type AccessibilityPreferences, AccessibilityProfilesController, type AccessibilityState, AccessibleTooltipsController, type ActiveProfileState, type AppliedSmartContrast, type ApplyPageOptions, type ArticleContent, type BackdropResolution, type BaseAccessibilityEvent, BigCursorController, type BigCursorControllerProps, CONTRAST_MODES, CONTRAST_PALETTES, CONTRAST_PROTECTED_SELECTOR, ChoiceControl, type ChoiceControlProps, type ChoiceGroup, type ChoiceOption, ContrastController, type ContrastMode, ContrastModeController, type ContrastModeValue, type ContrastPalette, type CursorSizePreference, type CustomPreset, CustomPresetsController, DEFAULT_FEATURE_GROUP_MAP, DEFAULT_MENU_GROUPS, DEFAULT_PREFERENCES, DEFAULT_READING_MASK_HEIGHT, DEFAULT_SHORTCUTS, DIAGNOSTICS_DISCLAIMER, DYSLEXIA_FONT_STACK, type DataRetentionPolicy, type DiagnosticCategory, type DiagnosticIssue, type DiagnosticSeverity, type DiagnosticsConfig, DiagnosticsHarness, type DiagnosticsHarnessProps, type DiagnosticsReport, type DiagnosticsSummary, DictionaryController, type DictionaryControllerProps, type DictionaryEntry, type DictionaryLookupResult, type DictionaryProvider, type EffectScopeTarget, type EffectsSession, EmptyState, type EmptyStateProps, ErrorState, type ErrorStateProps, type EventTriggerSource, FONT_FAMILY_PRESETS, FONT_FAMILY_PROTECTED_SELECTOR, FeatureCard, type FeatureCardProps, type FeatureChangeEvent, type FeatureEventListener, FeatureGroup, type FeatureGroupProps, type FeatureLocaleLabels, FeatureMenu, type FeatureMenuGroupConfig, type FeatureMenuItemConfig, type FeatureMenuProps, type FeatureOptions, type FeatureRegistration, type FeatureResetEvent, type FeatureStatus, FocusHighlightController, FontFamilyController, type FontFamilyPreference, type FontFamilyPreset, FontSizeController, type FontSizeControllerProps, GrayscaleController, type GrayscaleControllerProps, HIGH_CONTRAST_TOKENS, type HeadingItem, HeadingsNavigatorController, HideDecorativeImagesController, HideImagesController, type HideImagesControllerProps, HideVideosController, HighlightFocusController, type ImportResult, InvertColorsController, KNOWN_FEATURE_IDS, KeyboardShortcutsController, type KeyboardShortcutsControllerProps, LEGIBLE_FONT_STACK, LINE_HEIGHT_RATIOS, LINE_HEIGHT_STEPS, LOCAL_DICTIONARY_EN, LOCAL_DICTIONARY_SI, LOCAL_DICTIONARY_TA, type LandmarkItem, LetterSpacingController, type LetterSpacingControllerProps, LineHeightController, type LineHeightControllerProps, LinkHighlightController, type LinkItem, type LocaleStrings, MAX_HOST_ELEMENTS, MAX_NODES_PER_TRANSLATION_BATCH, MAX_READING_MASK_HEIGHT, MAX_TEXT_LENGTH_PER_NODE, MIN_READING_MASK_HEIGHT, type MenuCustomizationConfig, type MenuValidationIssue, type MenuValidationResult, ModalDialog, type ModalDialogProps, type NormalizedMenuConfig, type NormalizedMenuGroup, type NormalizedMenuItem, PROFILE_DEFINITIONS, PageNavigatorController, type PageNavigatorControllerProps, PageStructureController, type PanelToggleEvent, ParagraphSpacingController, type ParagraphSpacingControllerProps, type PlacementChangeEvent, type PluginPosition, type PresetApplyEvent, PresetsBackupController, PresetsController, type PresetsControllerProps, type PresetsExportV1, type ProfileApplyEvent, ProfileController, type ProfileDefinition, type ProfilePresetId, ProfilePreviewCard, type ProfilePreviewCardProps, ProfilesController, type ProfilesControllerProps, READING_MASK_HEIGHT_PRESETS, READ_ALOUD_EXCLUDED_SELECTORS, RESERVED_BROWSER_SHORTCUTS, ReadAloudController, type ReadAloudControllerProps, type ReadAloudOptions, ReadAloudSession, type ReadAloudState, type ReaderMode, ReadingGuideController, type ReadingGuideControllerProps, ReadingMaskController, type ReadingMaskControllerProps, ReadingModeController, type ReadingModeControllerProps, ReduceMotionController, ResetController, type RgbColor, type RgbaColor, SMART_CONTRAST_DISCLAIMER, SaturationController, type SaturationControllerProps, type SaturationPreference, type ScriptSpacingConstraints, SearchCount, type SearchCountProps, SettingsImportExportController, type ShortcutDefinition, SkipToMainLink, type SkipToMainLinkProps, SmartContrastController, type SmartContrastLevel, type SmartContrastOptions, type SmartContrastReport, StepperControl, type StepperControlProps, type StorageMode, type SupportedLocale, TARGET_RATIOS, TEXT_ALIGN_BLOCK_SELECTOR, TEXT_SCALE_PROTECTED_SELECTOR, TEXT_SCALE_STEPS, TEXT_SPACING_EXCLUDED_SELECTOR, TRANSLATION_DISCLAIMER, TRANSLATION_ERROR_CODES, TextAlignController, type TextAlignPreference, TextScaleController, type TextScaleControllerProps, type TextScaleStep, ToggleControl, type ToggleControlProps, TooltipsController, type TooltipsControllerProps, type TranslatableNode, type TranslatedItem, type TranslationAdapter, type TranslationConsentRecord, type TranslationConsentStatus, TranslationController, type TranslationControllerProps, TranslationError, type TranslationErrorCode, type TranslationRequest, type TranslationResponse, type TranslationSession, type UnsupportedElementInfo, type UnsupportedReason, type UsePresetsResult, type UseProfilesResult, VOICE_COMMANDS, VOICE_NAVIGATION_DISCLAIMER, type ValidationResult, type VoiceCommandDefinition, type VoiceCommandId, type VoiceExecutionContext, VoiceNavigationController, type VoiceNavigationControllerProps, type VoiceNavigationOptions, type VoiceNavigationResult, type VoiceNavigationSession, type VoiceNavigationStatus, type WidgetPlacement, WordSpacingController, type WordSpacingControllerProps, applyCustomPresetToStore, applyPage, applyPageSession, applyProfileToStore, applySmartContrast, applyTranslations, calculateContrastRatio, calculateRelativeLuminance, checkBoundariesDiagnostics, checkCspDiagnostics, checkDomDiagnostics, checkHostCssDiagnostics, checkProviderDiagnostics, checkStorageDiagnostics, compositeRgba, countWords, createCustomPreset, createInitialPreferencesState, createOfflineMockTranslationAdapter, createVoiceNavigationSession, downloadJsonFile, emitFeatureEvent, enLocale, enableAccessibleTooltips, estimateReadingTime, evaluateSmartContrast, executeVoiceCommand, exportPresetsToJson, extractArticleContent, extractReadAloudText, extractTranslatableNodes, findArticleCandidate, findMainLandmark, getActiveSelectionText, getAuthoredDescription, getMenuConfigSignature, getProfileDefinition, getScriptSpacingConstraints, getSpeechVoices, hasFinePointer, isEligibleDecorativeImage, isEligibleForSmartContrast, isForcedColorsActive, isFormFieldOrEditable, isFunctionalOrMeaningfulImage, isLargeText, isProtectedFromContrast, isProtectedFromFontFamily, isProtectedFromTextAlign, isProtectedFromTextScale, isProtectedFromTextSpacing, isReducedMotionActive, isRtlLocale, isSensitiveElement, isSpeechRecognitionSupported, isSpeechSynthesisSupported, isValidCustomPreset, lookupLocalDictionary, lookupWord, mapFeaturesToProfileSettings, mapProfileSettingsToFeatures, matchVoiceCommand, navigateToElement, normalizeKeyCombo, normalizePreferenceValue, normalizePreferences, normalizeTranscript, nudgeReadingAid, parseColor, parseKeyboardEventToCombo, positionTooltip, preferencesReducer, recordProfileOverride, registerLocale, resolveActiveShortcut, resolveEffectScope, resolveEffectiveBackdrop, resolveEffectivePreferences, resolveLocaleStrings, revertProfileFromStore, runDiagnostics, sanitizeFeatureEvent, sanitizeLookupTerm, sanitizePreferences, sanitizeTranslationOutput, scanHeadings, scanLandmarks, scanLinks, siLocale, splitTextIntoChunks, subscribeFinePointer, subscribeForcedColors, subscribePageStructure, subscribeReducedMotion, subscribeSpeechVoices, taLocale, translateHostContent, useAccessibility, useDiagnostics, usePresets, useProfiles, validateAndParseImport, validateMenuConfig, validateShortcutRemap };
2008
+ export { ALLOWED_PREFERENCE_KEYS, ALL_PROFILE_IDS, AccessibilityButton, type AccessibilityButtonProps, AccessibilityContext, type AccessibilityContextValue, type AccessibilityEventType, type AccessibilityFeatureEvent, AccessibilityList, type AccessibilityListProps, AccessibilityPlugin, type AccessibilityPluginProps, type AccessibilityPreferences, AccessibilityProfilesController, type AccessibilityState, AccessibleTooltipsController, type ActiveProfileState, type AppliedSmartContrast, type ApplyPageOptions, type ArticleContent, type BackdropResolution, type BaseAccessibilityEvent, BigCursorController, type BigCursorControllerProps, CONTRAST_MODES, CONTRAST_PALETTES, CONTRAST_PROTECTED_SELECTOR, ChoiceControl, type ChoiceControlProps, type ChoiceGroup, type ChoiceOption, ContrastController, type ContrastMode, ContrastModeController, type ContrastModeValue, type ContrastPalette, type CursorSizePreference, type CustomPreset, CustomPresetsController, DEFAULT_FEATURE_GROUP_MAP, DEFAULT_MENU_GROUPS, DEFAULT_PREFERENCES, DEFAULT_READING_MASK_HEIGHT, DEFAULT_SHORTCUTS, DIAGNOSTICS_DISCLAIMER, DYSLEXIA_FONT_STACK, type DataRetentionPolicy, type DiagnosticCategory, type DiagnosticIssue, type DiagnosticSeverity, type DiagnosticsConfig, DiagnosticsHarness, type DiagnosticsHarnessProps, type DiagnosticsReport, type DiagnosticsSummary, DictionaryController, type DictionaryControllerProps, type DictionaryEntry, type DictionaryLookupResult, type DictionaryProvider, type EffectScopeTarget, type EffectsSession, EmptyState, type EmptyStateProps, ErrorState, type ErrorStateProps, type EventTriggerSource, FONT_FAMILY_PRESETS, FONT_FAMILY_PROTECTED_SELECTOR, FeatureCard, type FeatureCardProps, type FeatureChangeEvent, type FeatureEventListener, FeatureGroup, type FeatureGroupProps, type FeatureLocaleLabels, FeatureMenu, type FeatureMenuGroupConfig, type FeatureMenuItemConfig, type FeatureMenuProps, type FeatureOptions, type FeatureRegistration, type FeatureResetEvent, type FeatureStatus, FocusHighlightController, FontFamilyController, type FontFamilyPreference, type FontFamilyPreset, FontSizeController, type FontSizeControllerProps, type GoogleTranslateAdapterOptions, GrayscaleController, type GrayscaleControllerProps, HIGH_CONTRAST_TOKENS, type HeadingItem, HeadingsNavigatorController, HideDecorativeImagesController, HideImagesController, type HideImagesControllerProps, HideVideosController, HighlightFocusController, type ImportResult, InvertColorsController, KNOWN_FEATURE_IDS, KeyboardShortcutsController, type KeyboardShortcutsControllerProps, LEGIBLE_FONT_STACK, LINE_HEIGHT_RATIOS, LINE_HEIGHT_STEPS, LOCAL_DICTIONARY_EN, LOCAL_DICTIONARY_SI, LOCAL_DICTIONARY_TA, type LandmarkItem, LetterSpacingController, type LetterSpacingControllerProps, LineHeightController, type LineHeightControllerProps, LinkHighlightController, type LinkItem, type LocaleStrings, MAX_HOST_ELEMENTS, MAX_NODES_PER_TRANSLATION_BATCH, MAX_READING_MASK_HEIGHT, MAX_TEXT_LENGTH_PER_NODE, MIN_READING_MASK_HEIGHT, type MenuCustomizationConfig, type MenuValidationIssue, type MenuValidationResult, ModalDialog, type ModalDialogProps, type NormalizedMenuConfig, type NormalizedMenuGroup, type NormalizedMenuItem, PROFILE_DEFINITIONS, PageNavigatorController, type PageNavigatorControllerProps, PageStructureController, type PanelToggleEvent, ParagraphSpacingController, type ParagraphSpacingControllerProps, type PlacementChangeEvent, type PluginPosition, type PresetApplyEvent, PresetsBackupController, PresetsController, type PresetsControllerProps, type PresetsExportV1, type ProfileApplyEvent, ProfileController, type ProfileDefinition, type ProfilePresetId, ProfilePreviewCard, type ProfilePreviewCardProps, ProfilesController, type ProfilesControllerProps, READING_MASK_HEIGHT_PRESETS, READ_ALOUD_EXCLUDED_SELECTORS, RESERVED_BROWSER_SHORTCUTS, ReadAloudController, type ReadAloudControllerProps, type ReadAloudOptions, ReadAloudSession, type ReadAloudState, type ReaderMode, ReadingGuideController, type ReadingGuideControllerProps, ReadingMaskController, type ReadingMaskControllerProps, ReadingModeController, type ReadingModeControllerProps, ReduceMotionController, ResetController, type RgbColor, type RgbaColor, SMART_CONTRAST_DISCLAIMER, SaturationController, type SaturationControllerProps, type SaturationPreference, type ScriptSpacingConstraints, SearchCount, type SearchCountProps, SettingsImportExportController, type ShortcutDefinition, SkipToMainLink, type SkipToMainLinkProps, SmartContrastController, type SmartContrastLevel, type SmartContrastOptions, type SmartContrastReport, StepperControl, type StepperControlProps, type StorageMode, type SupportedLocale, TARGET_RATIOS, TEXT_ALIGN_BLOCK_SELECTOR, TEXT_SCALE_PROTECTED_SELECTOR, TEXT_SCALE_STEPS, TEXT_SPACING_EXCLUDED_SELECTOR, TRANSLATION_DISCLAIMER, TRANSLATION_ERROR_CODES, TextAlignController, type TextAlignPreference, TextScaleController, type TextScaleControllerProps, type TextScaleStep, ToggleControl, type ToggleControlProps, TooltipsController, type TooltipsControllerProps, type TranslatableNode, type TranslatedItem, type TranslationAdapter, type TranslationConsentRecord, type TranslationConsentStatus, TranslationController, type TranslationControllerProps, TranslationError, type TranslationErrorCode, type TranslationRequest, type TranslationResponse, type TranslationSession, type UnsupportedElementInfo, type UnsupportedReason, type UsePresetsResult, type UseProfilesResult, VOICE_COMMANDS, VOICE_NAVIGATION_DISCLAIMER, type ValidationResult, type VoiceCommandDefinition, type VoiceCommandId, type VoiceExecutionContext, VoiceNavigationController, type VoiceNavigationControllerProps, type VoiceNavigationOptions, type VoiceNavigationResult, type VoiceNavigationSession, type VoiceNavigationStatus, type WidgetPlacement, WordSpacingController, type WordSpacingControllerProps, applyCustomPresetToStore, applyPage, applyPageSession, applyProfileToStore, applySmartContrast, applyTranslations, calculateContrastRatio, calculateRelativeLuminance, checkBoundariesDiagnostics, checkCspDiagnostics, checkDomDiagnostics, checkHostCssDiagnostics, checkProviderDiagnostics, checkStorageDiagnostics, compositeRgba, countWords, createCustomPreset, createGoogleTranslateAdapter, createInitialPreferencesState, createOfflineMockTranslationAdapter, createVoiceNavigationSession, downloadJsonFile, emitFeatureEvent, enLocale, enableAccessibleTooltips, estimateReadingTime, evaluateSmartContrast, executeVoiceCommand, exportPresetsToJson, extractArticleContent, extractReadAloudText, extractTranslatableNodes, findArticleCandidate, findMainLandmark, getActiveSelectionText, getAuthoredDescription, getMenuConfigSignature, getProfileDefinition, getScriptSpacingConstraints, getSpeechVoices, hasFinePointer, isEligibleDecorativeImage, isEligibleForSmartContrast, isForcedColorsActive, isFormFieldOrEditable, isFunctionalOrMeaningfulImage, isLargeText, isProtectedFromContrast, isProtectedFromFontFamily, isProtectedFromTextAlign, isProtectedFromTextScale, isProtectedFromTextSpacing, isReducedMotionActive, isRtlLocale, isSensitiveElement, isSpeechRecognitionSupported, isSpeechSynthesisSupported, isValidCustomPreset, lookupLocalDictionary, lookupWord, mapFeaturesToProfileSettings, mapProfileSettingsToFeatures, matchVoiceCommand, navigateToElement, normalizeKeyCombo, normalizePreferenceValue, normalizePreferences, normalizeTranscript, nudgeReadingAid, parseColor, parseKeyboardEventToCombo, positionTooltip, preferencesReducer, recordProfileOverride, registerLocale, resolveActiveShortcut, resolveEffectScope, resolveEffectiveBackdrop, resolveEffectivePreferences, resolveLocaleStrings, revertProfileFromStore, runDiagnostics, sanitizeFeatureEvent, sanitizeLookupTerm, sanitizePreferences, sanitizeTranslationOutput, scanHeadings, scanLandmarks, scanLinks, siLocale, splitTextIntoChunks, subscribeFinePointer, subscribeForcedColors, subscribePageStructure, subscribeReducedMotion, subscribeSpeechVoices, taLocale, translateHostContent, useAccessibility, useDiagnostics, usePresets, useProfiles, validateAndParseImport, validateMenuConfig, validateShortcutRemap };
package/dist/index.js CHANGED
@@ -142,6 +142,7 @@ __export(index_exports, {
142
142
  compositeRgba: () => compositeRgba,
143
143
  countWords: () => countWords,
144
144
  createCustomPreset: () => createCustomPreset,
145
+ createGoogleTranslateAdapter: () => createGoogleTranslateAdapter,
145
146
  createInitialPreferencesState: () => createInitialPreferencesState,
146
147
  createOfflineMockTranslationAdapter: () => createOfflineMockTranslationAdapter,
147
148
  createVoiceNavigationSession: () => createVoiceNavigationSession,
@@ -1559,7 +1560,7 @@ function isFunctionalOrMeaningfulImage(el) {
1559
1560
  return true;
1560
1561
  }
1561
1562
  if (el.closest(
1562
- "[role='graphics-document'], [role='graphics-symbol'], [role='figure'], figure, [class*='chart' i], [id*='chart' i], [class*='graph' i], [id*='graph' i], [class*='diagram' i], [id*='diagram' i]"
1563
+ "[role='graphics-document'], [role='graphics-symbol'], [class*='chart' i], [id*='chart' i], [class*='graph' i], [id*='graph' i], [class*='diagram' i], [id*='diagram' i]"
1563
1564
  ) || el.matches(
1564
1565
  "[role='graphics-document'], [role='graphics-symbol'], [aria-roledescription*='chart' i]"
1565
1566
  )) {
@@ -1582,6 +1583,22 @@ function isFunctionalOrMeaningfulImage(el) {
1582
1583
  if (el.closest("[role='math'], math, [class*='math' i]")) {
1583
1584
  return true;
1584
1585
  }
1586
+ const hasExplicitDecorativeMarker = (node) => {
1587
+ if (node.hasAttribute("data-decorative") && node.getAttribute("data-decorative") !== "false") {
1588
+ return true;
1589
+ }
1590
+ if (node.classList.contains("decorative") || node.classList.contains("deco")) {
1591
+ return true;
1592
+ }
1593
+ const nodeRole = node.getAttribute("role");
1594
+ if (nodeRole === "presentation" || nodeRole === "none") {
1595
+ return true;
1596
+ }
1597
+ return node.getAttribute("aria-hidden") === "true";
1598
+ };
1599
+ if (hasExplicitDecorativeMarker(el) || el.parentElement?.matches("picture") && hasExplicitDecorativeMarker(el.parentElement)) {
1600
+ return false;
1601
+ }
1585
1602
  if (el.hasAttribute("alt")) {
1586
1603
  const alt = el.getAttribute("alt")?.trim();
1587
1604
  if (alt && alt.length > 0) return true;
@@ -1626,7 +1643,7 @@ function isEligibleDecorativeImage(el) {
1626
1643
  if (el.getAttribute("aria-hidden") === "true") {
1627
1644
  return true;
1628
1645
  }
1629
- if (el.hasAttribute("data-decorative") || el.classList.contains("decorative") || el.classList.contains("deco")) {
1646
+ if (el.hasAttribute("data-decorative") && el.getAttribute("data-decorative") !== "false" || el.classList.contains("decorative") || el.classList.contains("deco")) {
1630
1647
  return true;
1631
1648
  }
1632
1649
  if (el.matches("picture")) {
@@ -1662,6 +1679,15 @@ function resolveEffectScope(scope) {
1662
1679
  }
1663
1680
  return document.body ?? null;
1664
1681
  }
1682
+ function resolveActiveContrastPalette(values) {
1683
+ if (isForcedColorsActive()) {
1684
+ return { activePalette: null, fallbackColors: null };
1685
+ }
1686
+ const activeContrastKey = values.contrastMode && values.contrastMode !== "off" && values.contrastMode !== "original" ? String(values.contrastMode) : values.contrast !== void 0 && values.contrast !== 0 && values.contrast !== "0" && values.contrast !== "off" && values.contrast !== "original" ? String(values.contrast) : null;
1687
+ const activePalette = activeContrastKey ? CONTRAST_PALETTES[activeContrastKey] ?? null : null;
1688
+ const fallbackColors = !activePalette ? palette[String(values.contrast)] ?? null : null;
1689
+ return { activePalette, fallbackColors };
1690
+ }
1665
1691
  function applyToElements(elements, values, undo, styledElements, isFinePointer, set) {
1666
1692
  const targetElements = [];
1667
1693
  for (const el of elements) {
@@ -1821,8 +1847,7 @@ function applyToElements(elements, values, undo, styledElements, isFinePointer,
1821
1847
  }
1822
1848
  }
1823
1849
  }
1824
- const activeContrastKey = values.contrastMode && values.contrastMode !== "off" && values.contrastMode !== "original" ? String(values.contrastMode) : values.contrast !== void 0 && values.contrast !== 0 && values.contrast !== "0" && values.contrast !== "off" && values.contrast !== "original" ? String(values.contrast) : null;
1825
- const activePalette = activeContrastKey && !isForcedColorsActive() ? CONTRAST_PALETTES[activeContrastKey] : null;
1850
+ const { activePalette, fallbackColors } = resolveActiveContrastPalette(values);
1826
1851
  if (activePalette) {
1827
1852
  for (const el of targetElements) {
1828
1853
  if (isProtectedFromContrast(el)) continue;
@@ -1870,13 +1895,12 @@ function applyToElements(elements, values, undo, styledElements, isFinePointer,
1870
1895
  }
1871
1896
  }
1872
1897
  if (values.hideVideos && el.matches(
1873
- 'video, iframe[src*="youtube.com/embed/"], iframe[src*="youtube-nocookie.com/embed/"], iframe[src*="youtu.be/"], iframe[src*="player.vimeo.com/video/"], iframe[src*="player.twitch.tv/"], iframe[src*="dailymotion.com/embed/"], iframe[src*="loom.com/embed/"], iframe[src*="wistia."], iframe[data-src*="youtube"], iframe[data-src*="vimeo"], iframe[data-src*="twitch.tv"], iframe[data-src*="dailymotion"], iframe[data-src*="loom.com"]'
1898
+ 'video, [data-video], .video-placeholder, iframe[src*="youtube.com/embed/"], iframe[src*="youtube-nocookie.com/embed/"], iframe[src*="youtu.be/"], iframe[src*="player.vimeo.com/video/"], iframe[src*="player.twitch.tv/"], iframe[src*="dailymotion.com/embed/"], iframe[src*="loom.com/embed/"], iframe[src*="wistia."], iframe[data-src*="youtube"], iframe[data-src*="vimeo"], iframe[data-src*="twitch.tv"], iframe[data-src*="dailymotion"], iframe[data-src*="loom.com"]'
1874
1899
  ))
1875
1900
  set(el, "visibility", "hidden");
1876
- const colors = palette[String(values.contrast)];
1877
- if (colors && !activePalette && !isForcedColorsActive()) {
1878
- set(el, "color", colors[0]);
1879
- set(el, "background-color", colors[1]);
1901
+ if (fallbackColors) {
1902
+ set(el, "color", fallbackColors[0]);
1903
+ set(el, "background-color", fallbackColors[1]);
1880
1904
  }
1881
1905
  if (values.linkHighlight && el.matches("a[href]") && !el.closest("[data-arap-ui]")) {
1882
1906
  const isDisabled = el.getAttribute("aria-disabled") === "true" || el.hasAttribute("disabled") || el.classList.contains("disabled");
@@ -1887,12 +1911,12 @@ function applyToElements(elements, values, undo, styledElements, isFinePointer,
1887
1911
  set(el, "text-decoration-thickness", "2px");
1888
1912
  set(el, "text-underline-offset", "3px");
1889
1913
  } else {
1890
- const colors2 = palette[String(values.linkHighlight)] ?? [
1914
+ const colors = palette[String(values.linkHighlight)] ?? [
1891
1915
  "#111827",
1892
1916
  "#fef08a"
1893
1917
  ];
1894
- set(el, "color", colors2[0]);
1895
- set(el, "background-color", colors2[1]);
1918
+ set(el, "color", colors[0]);
1919
+ set(el, "background-color", colors[1]);
1896
1920
  set(el, "text-decoration", "underline");
1897
1921
  set(el, "text-decoration-thickness", "2px");
1898
1922
  set(el, "text-underline-offset", "3px");
@@ -1958,6 +1982,20 @@ function applyPageSession(values, optionsOrScope) {
1958
1982
  applyContainerFilter(targetRoot);
1959
1983
  }
1960
1984
  }
1985
+ const rootContrast = resolveActiveContrastPalette(values);
1986
+ if (targetRoot && !targetRoot.matches(EXCLUDED)) {
1987
+ if (rootContrast.activePalette) {
1988
+ set(targetRoot, "color", rootContrast.activePalette.text);
1989
+ set(
1990
+ targetRoot,
1991
+ "background-color",
1992
+ rootContrast.activePalette.background
1993
+ );
1994
+ } else if (rootContrast.fallbackColors) {
1995
+ set(targetRoot, "color", rootContrast.fallbackColors[0]);
1996
+ set(targetRoot, "background-color", rootContrast.fallbackColors[1]);
1997
+ }
1998
+ }
1961
1999
  const smartContrastVal = values.smartContrast;
1962
2000
  if ((smartContrastVal === true || smartContrastVal === "aa" || smartContrastVal === "aaa") && !isForcedColorsActive()) {
1963
2001
  const targetLevel = smartContrastVal === "aaa" ? "aaa" : "aa";
@@ -2331,7 +2369,9 @@ function useBuiltinEffects(values, onDisable, optionsOrScope) {
2331
2369
  hasRootAttributeChange = true;
2332
2370
  } else if ((values.hideImages || values.hideVideos) && record.target instanceof HTMLElement && !record.target.closest(
2333
2371
  "[data-arap-ui], [data-arap-diagnostics], .arap-root"
2334
- ) && record.target.matches("img, picture, video, iframe")) {
2372
+ ) && record.target.matches(
2373
+ "img, picture, video, [data-video], .video-placeholder, iframe"
2374
+ )) {
2335
2375
  added.push(record.target);
2336
2376
  }
2337
2377
  } else if (record.type === "childList") {
@@ -13259,6 +13299,177 @@ function createOfflineMockTranslationAdapter(options) {
13259
13299
  }
13260
13300
  };
13261
13301
  }
13302
+ var GOOGLE_TRANSLATE_DEFAULT_ENDPOINT = "https://translate.googleapis.com/translate_a/single";
13303
+ var GOOGLE_TRANSLATE_SUPPORTED_LANGUAGES = [
13304
+ "es",
13305
+ "fr",
13306
+ "de",
13307
+ "si",
13308
+ "ta",
13309
+ "ja",
13310
+ "zh",
13311
+ "ar",
13312
+ "hi",
13313
+ "pt",
13314
+ "ru",
13315
+ "ko",
13316
+ "it",
13317
+ "nl"
13318
+ ];
13319
+ var LETTER_OR_SCRIPT_PATTERN = /\p{L}/u;
13320
+ function parseGoogleTranslateResponse(data) {
13321
+ if (!Array.isArray(data) || !Array.isArray(data[0])) {
13322
+ return "";
13323
+ }
13324
+ const parts = [];
13325
+ for (const segment of data[0]) {
13326
+ if (Array.isArray(segment) && typeof segment[0] === "string") {
13327
+ parts.push(segment[0]);
13328
+ }
13329
+ }
13330
+ return parts.join("");
13331
+ }
13332
+ function createGoogleTranslateAdapter(options) {
13333
+ const endpoint = options?.endpoint ?? GOOGLE_TRANSLATE_DEFAULT_ENDPOINT;
13334
+ const concurrency = Math.max(1, options?.concurrency ?? 6);
13335
+ const fallbackToOffline = options?.fallbackToOffline ?? true;
13336
+ const resolvedFetch = options?.fetchImpl ?? (typeof fetch !== "undefined" ? fetch.bind(globalThis) : void 0);
13337
+ const cache = /* @__PURE__ */ new Map();
13338
+ return {
13339
+ id: "google-translate-adapter",
13340
+ name: "Google Translate",
13341
+ description: "Client-side machine translation powered by Google Translate with automatic offline fallback.",
13342
+ privacyPolicyUrl: "https://policies.google.com/privacy",
13343
+ dataRetention: "transient",
13344
+ dataResidency: "global",
13345
+ supportedTargetLanguages: GOOGLE_TRANSLATE_SUPPORTED_LANGUAGES,
13346
+ translate: async (request) => {
13347
+ if (request.signal?.aborted) {
13348
+ throw new TranslationError(
13349
+ TRANSLATION_ERROR_CODES.ABORTED,
13350
+ "Translation request was aborted."
13351
+ );
13352
+ }
13353
+ const sourceLang = (request.sourceLanguage || "auto").trim().toLowerCase();
13354
+ const baseTarget = request.targetLanguage.trim().toLowerCase().split("-")[0];
13355
+ const pendingKeys = [];
13356
+ const seenKeys = /* @__PURE__ */ new Set();
13357
+ for (const raw of request.texts) {
13358
+ const trimmed = raw.trim();
13359
+ if (!trimmed || !LETTER_OR_SCRIPT_PATTERN.test(trimmed)) {
13360
+ continue;
13361
+ }
13362
+ const cacheKey = `${sourceLang}:${baseTarget}:${trimmed}`;
13363
+ if (!cache.has(cacheKey) && !seenKeys.has(trimmed)) {
13364
+ seenKeys.add(trimmed);
13365
+ pendingKeys.push(trimmed);
13366
+ }
13367
+ }
13368
+ let cursor2 = 0;
13369
+ const translateSingle = async (textKey) => {
13370
+ if (request.signal?.aborted) {
13371
+ throw new TranslationError(
13372
+ TRANSLATION_ERROR_CODES.ABORTED,
13373
+ "Translation request was aborted."
13374
+ );
13375
+ }
13376
+ const cacheKey = `${sourceLang}:${baseTarget}:${textKey}`;
13377
+ if (!resolvedFetch) {
13378
+ if (!fallbackToOffline) {
13379
+ throw new TranslationError(
13380
+ TRANSLATION_ERROR_CODES.NETWORK_ERROR,
13381
+ "Fetch API is not available for Google Translate requests."
13382
+ );
13383
+ }
13384
+ cache.set(
13385
+ cacheKey,
13386
+ translateOfflineText(textKey, request.targetLanguage)
13387
+ );
13388
+ return;
13389
+ }
13390
+ const url = `${endpoint}?client=gtx&sl=${encodeURIComponent(
13391
+ sourceLang
13392
+ )}&tl=${encodeURIComponent(baseTarget)}&dt=t&q=${encodeURIComponent(
13393
+ textKey
13394
+ )}`;
13395
+ try {
13396
+ const response = await resolvedFetch(url, {
13397
+ method: "GET",
13398
+ signal: request.signal
13399
+ });
13400
+ if (!response.ok) {
13401
+ throw new Error(`HTTP ${response.status}`);
13402
+ }
13403
+ const json = await response.json();
13404
+ const parsed = sanitizeTranslationOutput(
13405
+ parseGoogleTranslateResponse(json)
13406
+ );
13407
+ cache.set(cacheKey, parsed || textKey);
13408
+ } catch (err) {
13409
+ const isAbort = request.signal?.aborted || err instanceof Error && err.name === "AbortError" || err instanceof TranslationError && err.code === TRANSLATION_ERROR_CODES.ABORTED;
13410
+ if (isAbort) {
13411
+ throw new TranslationError(
13412
+ TRANSLATION_ERROR_CODES.ABORTED,
13413
+ "Translation request was aborted.",
13414
+ err
13415
+ );
13416
+ }
13417
+ if (!fallbackToOffline) {
13418
+ const msg = err instanceof Error ? err.message : String(err);
13419
+ throw new TranslationError(
13420
+ TRANSLATION_ERROR_CODES.NETWORK_ERROR,
13421
+ `Google Translate request failed: ${msg}`,
13422
+ err
13423
+ );
13424
+ }
13425
+ cache.set(
13426
+ cacheKey,
13427
+ translateOfflineText(textKey, request.targetLanguage)
13428
+ );
13429
+ }
13430
+ };
13431
+ const workerCount = Math.min(concurrency, pendingKeys.length);
13432
+ if (workerCount > 0) {
13433
+ const workers = Array.from({ length: workerCount }, async () => {
13434
+ while (cursor2 < pendingKeys.length) {
13435
+ const nextIndex = cursor2;
13436
+ cursor2 += 1;
13437
+ const key = pendingKeys[nextIndex];
13438
+ if (key !== void 0) {
13439
+ await translateSingle(key);
13440
+ }
13441
+ }
13442
+ });
13443
+ await Promise.all(workers);
13444
+ }
13445
+ const translations = request.texts.map((raw) => {
13446
+ const trimmed = raw.trim();
13447
+ if (!trimmed || !LETTER_OR_SCRIPT_PATTERN.test(trimmed)) {
13448
+ return {
13449
+ original: raw,
13450
+ translated: raw,
13451
+ detectedSourceLanguage: request.sourceLanguage || "en"
13452
+ };
13453
+ }
13454
+ const leading = raw.match(/^\s*/)?.[0] ?? "";
13455
+ const trailing = raw.match(/\s*$/)?.[0] ?? "";
13456
+ const cacheKey = `${sourceLang}:${baseTarget}:${trimmed}`;
13457
+ const translatedCore = cache.get(cacheKey) ?? trimmed;
13458
+ return {
13459
+ original: raw,
13460
+ translated: `${leading}${translatedCore}${trailing}`,
13461
+ detectedSourceLanguage: request.sourceLanguage || "en"
13462
+ };
13463
+ });
13464
+ return {
13465
+ translations,
13466
+ providerId: "google-translate-adapter",
13467
+ timestamp: Date.now(),
13468
+ attribution: "Powered by Google Translate"
13469
+ };
13470
+ }
13471
+ };
13472
+ }
13262
13473
  async function translateHostContent(options) {
13263
13474
  const {
13264
13475
  rootElement = document.body,
@@ -13341,7 +13552,14 @@ var DEFAULT_TARGET_LANGUAGES = [
13341
13552
  { code: "si", label: "Sinhala (\u0DC3\u0DD2\u0D82\u0DC4\u0DBD)" },
13342
13553
  { code: "ta", label: "Tamil (\u0BA4\u0BAE\u0BBF\u0BB4\u0BCD)" },
13343
13554
  { code: "ja", label: "Japanese (\u65E5\u672C\u8A9E)" },
13344
- { code: "zh", label: "Chinese (\u4E2D\u6587)" }
13555
+ { code: "zh", label: "Chinese (\u4E2D\u6587)" },
13556
+ { code: "ar", label: "Arabic (\u0627\u0644\u0639\u0631\u0628\u064A\u0629)" },
13557
+ { code: "hi", label: "Hindi (\u0939\u093F\u0928\u094D\u0926\u0940)" },
13558
+ { code: "pt", label: "Portuguese (Portugu\xEAs)" },
13559
+ { code: "ru", label: "Russian (\u0420\u0443\u0441\u0441\u043A\u0438\u0439)" },
13560
+ { code: "ko", label: "Korean (\uD55C\uAD6D\uC5B4)" },
13561
+ { code: "it", label: "Italian (Italiano)" },
13562
+ { code: "nl", label: "Dutch (Nederlands)" }
13345
13563
  ];
13346
13564
  var TranslationController = ({
13347
13565
  className = "",
@@ -13352,7 +13570,7 @@ var TranslationController = ({
13352
13570
  }) => {
13353
13571
  const { value: isTranslationEnabled, setValue: setIsTranslationEnabled } = useAccessibility("translation", false);
13354
13572
  const [provider] = (0, import_react32.useState)(() => {
13355
- return customProvider || createOfflineMockTranslationAdapter();
13573
+ return customProvider || createGoogleTranslateAdapter();
13356
13574
  });
13357
13575
  const [targetLang, setTargetLang] = (0, import_react32.useState)(defaultTargetLanguage);
13358
13576
  const [consent, setConsent] = (0, import_react32.useState)({
@@ -14900,6 +15118,7 @@ function useDiagnostics(config = {}) {
14900
15118
  compositeRgba,
14901
15119
  countWords,
14902
15120
  createCustomPreset,
15121
+ createGoogleTranslateAdapter,
14903
15122
  createInitialPreferencesState,
14904
15123
  createOfflineMockTranslationAdapter,
14905
15124
  createVoiceNavigationSession,