@edrlab/thorium-web 1.1.2 → 1.1.3

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.
Files changed (86) hide show
  1. package/README.md +2 -0
  2. package/dist/{StatefulReader-BjH7bkU1.d.mts → StatefulReader-lpxHxgKK.d.mts} +8 -6
  3. package/dist/{ThPreferencesAdapter-x_D4c7wI.d.mts → ThPreferencesAdapter-CcJgE3zC.d.mts} +78 -56
  4. package/dist/{actionsReducer-BKoeohBu.d.mts → actionsReducer-6UNIgifE.d.mts} +1 -1
  5. package/dist/{chunk-2JHEFF46.mjs → chunk-JDMFK3LV.mjs} +347 -47
  6. package/dist/chunk-JDMFK3LV.mjs.map +1 -0
  7. package/dist/{chunk-VETE7ULS.mjs → chunk-KKMH2EPS.mjs} +12 -4
  8. package/dist/chunk-KKMH2EPS.mjs.map +1 -0
  9. package/dist/{chunk-HE3WFPGE.mjs → chunk-KTZPAJ4S.mjs} +34 -19
  10. package/dist/chunk-KTZPAJ4S.mjs.map +1 -0
  11. package/dist/{chunk-EY4D4BZN.mjs → chunk-MW7LXDWC.mjs} +3 -3
  12. package/dist/{chunk-EY4D4BZN.mjs.map → chunk-MW7LXDWC.mjs.map} +1 -1
  13. package/dist/{chunk-IRA4ZKAX.mjs → chunk-VN44OJDD.mjs} +819 -43
  14. package/dist/chunk-VN44OJDD.mjs.map +1 -0
  15. package/dist/components/Epub/index.css +1 -0
  16. package/dist/components/Epub/index.css.map +1 -1
  17. package/dist/components/Epub/index.d.mts +8 -8
  18. package/dist/components/Epub/index.mjs +55 -18
  19. package/dist/components/Epub/index.mjs.map +1 -1
  20. package/dist/components/WebPub/index.css +1 -0
  21. package/dist/components/WebPub/index.css.map +1 -1
  22. package/dist/components/WebPub/index.d.mts +12 -12
  23. package/dist/components/WebPub/index.mjs +39 -16
  24. package/dist/components/WebPub/index.mjs.map +1 -1
  25. package/dist/core/Components/index.d.mts +2 -2
  26. package/dist/core/Helpers/index.d.mts +2 -2
  27. package/dist/core/Hooks/index.d.mts +4 -4
  28. package/dist/core/Hooks/index.mjs +1 -1
  29. package/dist/{enums-CBaXSsr9.d.mts → enums-Bhwwdfx5.d.mts} +1 -1
  30. package/dist/fonts/AccessibleDfA/AccessibleDfA-Bold.woff2 +0 -0
  31. package/dist/fonts/AccessibleDfA/AccessibleDfA-Italic.woff2 +0 -0
  32. package/dist/fonts/AccessibleDfA/AccessibleDfA-Regular.woff2 +0 -0
  33. package/dist/fonts/AccessibleDfA/LICENSE-AccessibleDfa +95 -0
  34. package/dist/fonts/AndroidPatch/sans-serif/GNU General Public License.txt +340 -0
  35. package/dist/fonts/AndroidPatch/sans-serif/NimbusSans-Bold.woff +0 -0
  36. package/dist/fonts/AndroidPatch/sans-serif/NimbusSans-BoldItalic.woff +0 -0
  37. package/dist/fonts/AndroidPatch/sans-serif/NimbusSans-Italic.woff +0 -0
  38. package/dist/fonts/AndroidPatch/sans-serif/NimbusSans.woff +0 -0
  39. package/dist/fonts/AndroidPatch/serif/GNU General Public License.txt +340 -0
  40. package/dist/fonts/AndroidPatch/serif/NimbusRoman-Bold.woff +0 -0
  41. package/dist/fonts/AndroidPatch/serif/NimbusRoman-BoldItalic.woff +0 -0
  42. package/dist/fonts/AndroidPatch/serif/NimbusRoman-Italic.woff +0 -0
  43. package/dist/fonts/AndroidPatch/serif/NimbusRoman.woff +0 -0
  44. package/dist/fonts/Luciole/Luciole-Bold.woff2 +0 -0
  45. package/dist/fonts/Luciole/Luciole-BoldItalic.woff2 +0 -0
  46. package/dist/fonts/Luciole/Luciole-Italic.woff2 +0 -0
  47. package/dist/fonts/Luciole/Luciole-Regular.woff2 +0 -0
  48. package/dist/fonts/Luciole/Read Me.txt +14 -0
  49. package/dist/fonts/OpenDyslexic/OpenDyslexic-Bold.otf +0 -0
  50. package/dist/fonts/OpenDyslexic/OpenDyslexic-BoldItalic.otf +0 -0
  51. package/dist/fonts/OpenDyslexic/OpenDyslexic-Italic.otf +0 -0
  52. package/dist/fonts/OpenDyslexic/OpenDyslexic-Regular.otf +0 -0
  53. package/dist/fonts/iAWriterDuo/README.md +13 -0
  54. package/dist/fonts/iAWriterDuo/iAWriterDuoS-Bold.woff2 +0 -0
  55. package/dist/fonts/iAWriterDuo/iAWriterDuoS-BoldItalic.woff2 +0 -0
  56. package/dist/fonts/iAWriterDuo/iAWriterDuoS-Italic.woff2 +0 -0
  57. package/dist/fonts/iAWriterDuo/iAWriterDuoS-Regular.woff2 +0 -0
  58. package/dist/i18n/index.mjs +2 -2
  59. package/dist/lib/index.d.mts +35 -18
  60. package/dist/lib/index.mjs +1 -1
  61. package/dist/locales/ar/thorium-shared.json +258 -2
  62. package/dist/locales/ar/thorium-web.json +59 -1
  63. package/dist/locales/da/thorium-shared.json +9 -3
  64. package/dist/locales/el/thorium-web.json +53 -1
  65. package/dist/locales/en/thorium-shared.json +30 -12
  66. package/dist/locales/et/thorium-shared.json +99 -7
  67. package/dist/locales/fi/thorium-shared.json +68 -15
  68. package/dist/locales/fr/thorium-shared.json +12 -6
  69. package/dist/locales/it/thorium-shared.json +82 -14
  70. package/dist/locales/lt/thorium-shared.json +80 -12
  71. package/dist/locales/pt-BR/thorium-shared.json +24 -12
  72. package/dist/locales/pt-PT/thorium-shared.json +24 -12
  73. package/dist/locales/sv/thorium-shared.json +24 -12
  74. package/dist/locales/tr/thorium-shared.json +24 -12
  75. package/dist/preferences/index.d.mts +104 -7
  76. package/dist/preferences/index.mjs +1 -1
  77. package/dist/{useBreakpoints-BtHd3571.d.mts → useBreakpoints-LTrHif3E.d.mts} +1 -1
  78. package/dist/{useEpubNavigator-DpvqVgNu.d.mts → useEpubNavigator-DQq5VlY0.d.mts} +2 -1
  79. package/dist/usePreferences-CM_Y2jpZ.d.mts +42 -0
  80. package/dist/{useWebPubNavigator-DBRj8KyC.d.mts → useWebPubNavigator-XFUVekhV.d.mts} +2 -1
  81. package/package.json +22 -20
  82. package/dist/chunk-2JHEFF46.mjs.map +0 -1
  83. package/dist/chunk-HE3WFPGE.mjs.map +0 -1
  84. package/dist/chunk-IRA4ZKAX.mjs.map +0 -1
  85. package/dist/chunk-VETE7ULS.mjs.map +0 -1
  86. package/dist/usePreferences-CRjFlZvF.d.mts +0 -16
@@ -1,8 +1,8 @@
1
1
  import { makeBreakpointsMap, isInteractiveElement, isKeyboardTriggered, isActiveElement, getBestMatchingProgressionFormat } from './chunk-VH22EPOM.mjs';
2
- import { useFullscreen, useEpubNavigator } from './chunk-VETE7ULS.mjs';
3
- import { useAppDispatch, setFullscreen, useAppSelector, setActionOpen, dockAction, setSettingsContainer, debounce, setColumnCount, setWebPubFontFamily, setFontFamily, setWebPubFontWeight, setFontWeight, setWebPubHyphens, setHyphens, setScroll, setWebPubLetterSpacing, setLetterSpacing, setWebPubLineHeight, setLineHeight, setWebPubParagraphIndent, setParagraphIndent, setWebPubParagraphSpacing, setParagraphSpacing, setWebPubWordSpacing, setWordSpacing, setWebPubSpacingPreset, setWebPubPublisherStyles, setSpacingPreset, setPublisherStyles, setWebPubTextAlign, setTextAlign, setWebPubTextNormalization, setTextNormalization, setTheme, setWebPubZoom, setFontSize, ThReduxPreferencesAdapter, setHovering, setImmersive, setOverflow, setUserNavigated, setTocEntry, collapseDockPanel, expandDockPanel, activateDockPanel, deactivateDockPanel, setDockPanelWidth } from './chunk-HE3WFPGE.mjs';
4
- import { usePreferences, prefixString, defaultSpacingSettingsSubpanel, defaultSpacingSettingsMain, defaultTextSettingsSubpanel, defaultTextSettingsMain, usePreferenceKeys, defaultFontFamilyOptions, buildThemeObject, defaultPreferences, ThPreferencesProvider } from './chunk-IRA4ZKAX.mjs';
5
- import { isIOSish, buildShortcut, metaKeys } from './chunk-5LUMM7FW.mjs';
2
+ import { useFullscreen, useEpubNavigator } from './chunk-KKMH2EPS.mjs';
3
+ import { useAppDispatch, setFullscreen, useAppSelector, setActionOpen, dockAction, setSettingsContainer, debounce, setColumnCount, setWebPubFontFamily, setFontFamily, setWebPubFontWeight, setFontWeight, setWebPubHyphens, setHyphens, setScroll, setWebPubLetterSpacing, setLetterSpacing, setWebPubLineHeight, setLineHeight, setWebPubParagraphIndent, setParagraphIndent, setWebPubParagraphSpacing, setParagraphSpacing, setWebPubWordSpacing, setWordSpacing, setWebPubSpacingPreset, setWebPubPublisherStyles, setSpacingPreset, setPublisherStyles, setWebPubTextAlign, setTextAlign, setWebPubTextNormalization, setTextNormalization, setTheme, setWebPubZoom, setFontSize, ThReduxPreferencesAdapter, setHovering, setImmersive, setOverflow, setUserNavigated, setTocEntry, collapseDockPanel, expandDockPanel, activateDockPanel, deactivateDockPanel, setDockPanelWidth } from './chunk-KTZPAJ4S.mjs';
4
+ import { usePreferences, prefixString, defaultSpacingSettingsSubpanel, defaultSpacingSettingsMain, defaultTextSettingsSubpanel, defaultTextSettingsMain, usePreferenceKeys, buildThemeObject, defaultPreferences, ThPreferencesProvider } from './chunk-VN44OJDD.mjs';
5
+ import { isIOSish, getPlatform, buildShortcut, metaKeys } from './chunk-5LUMM7FW.mjs';
6
6
  import { useI18n } from './chunk-IYAFKTPL.mjs';
7
7
  import { ThMenuItem, ThActionButton, ThMenu, ThCollapsibleActionsBar, ThPopover, ThContainerHeader, ThNavigationButton, ThContainerBody, ThBottomSheet, ThCloseButton, ThModal, ThDockedPanel, ThTypedComponentRenderer, useActions, ThForm, ThFormNumberField, ThSettingsWrapper, ThFormSearchField, ThRadioGroup, ThDropdown, ThSwitch, ThNumberField, ThSlider, ThInteractiveOverlay, ThHeader, ThFooter, ThLink, ThLibrary, ThHome, ThBackArrow, ThRunningHead, ThPagination, ThProgression } from './chunk-GZDYMUV7.mjs';
8
8
  import { usePrevious } from './chunk-YZ73DHRU.mjs';
@@ -2488,35 +2488,49 @@ var StatefulDropdown = ({
2488
2488
  }
2489
2489
  );
2490
2490
  };
2491
- var fontFamilyLabelMap = {
2492
- publisher: "direct",
2493
- oldStyle: "descriptive",
2494
- modern: "descriptive",
2495
- sans: "direct",
2496
- humanist: "descriptive",
2497
- monospace: "direct"
2498
- };
2499
2491
  var StatefulFontFamily = ({ standalone = true }) => {
2492
+ const { getFontMetadata, getFontsList } = usePreferences();
2500
2493
  const { t } = useI18n();
2501
- const getFontFamilyLabel = useCallback((property) => {
2502
- const config = fontFamilyLabelMap[property];
2503
- const labelPath = `reader.preferences.fontFamily.${property}`;
2504
- if (config === "direct") {
2505
- return t(labelPath);
2506
- } else {
2507
- return t(`${labelPath}.${config}`);
2494
+ const getFontFamilyLabel = useCallback((font) => {
2495
+ if (font.label) {
2496
+ if (typeof font.label === "string") {
2497
+ return t(font.label, { defaultValue: font.label || font.name });
2498
+ } else if (typeof font.label === "object" && "key" in font.label) {
2499
+ return t(font.label.key, {
2500
+ defaultValue: font.label.fallback || font.name
2501
+ });
2502
+ }
2508
2503
  }
2504
+ return font.name;
2509
2505
  }, [t]);
2510
2506
  const profile = useAppSelector((state) => state.reader.profile);
2511
2507
  const isWebPub = profile === "webPub";
2512
- const fontFamily = useAppSelector((state) => isWebPub ? state.webPubSettings.fontFamily : state.settings.fontFamily) ?? "publisher";
2513
- const fontFamilyOptions = useRef(
2514
- Object.entries(defaultFontFamilyOptions).map(([property, stack]) => ({
2515
- id: property,
2516
- label: getFontFamilyLabel(property),
2517
- value: stack
2518
- }))
2519
- );
2508
+ const fontLanguage = useAppSelector((state) => state.publication.fontLanguage) || "default";
2509
+ const fontPreferences = getFontsList({ language: fontLanguage });
2510
+ const fontFamily = useAppSelector((state) => {
2511
+ const fontSettings = isWebPub ? state.webPubSettings.fontFamily : state.settings.fontFamily;
2512
+ return fontSettings[fontLanguage] ?? "publisher";
2513
+ });
2514
+ const availableFontIds = /* @__PURE__ */ new Set([
2515
+ "publisher",
2516
+ ...Object.keys(fontPreferences)
2517
+ ]);
2518
+ const currentFontFamily = availableFontIds.has(fontFamily) ? fontFamily : "publisher";
2519
+ const fontFamilyOptions = useRef([
2520
+ {
2521
+ id: "publisher",
2522
+ label: t("reader.preferences.fontFamily.publisher"),
2523
+ value: null
2524
+ },
2525
+ ...Object.entries(fontPreferences).map(([id, font]) => {
2526
+ const metadata = getFontMetadata(id);
2527
+ return {
2528
+ id,
2529
+ label: getFontFamilyLabel(font),
2530
+ value: metadata.fontStack || metadata.fontFamily
2531
+ };
2532
+ })
2533
+ ]);
2520
2534
  const dispatch = useAppDispatch();
2521
2535
  const { getSetting, submitPreferences } = useNavigator();
2522
2536
  const updatePreference = useCallback(async (key) => {
@@ -2525,20 +2539,34 @@ var StatefulFontFamily = ({ standalone = true }) => {
2525
2539
  if (selectedOption) {
2526
2540
  await submitPreferences({ fontFamily: selectedOption.value });
2527
2541
  const currentSetting = getSetting("fontFamily");
2528
- const selectedOptionId = Object.keys(defaultFontFamilyOptions).find((key2) => defaultFontFamilyOptions[key2] === currentSetting);
2529
- if (isWebPub) {
2530
- dispatch(setWebPubFontFamily(selectedOptionId || defaultFontFamilyOptions.publisher));
2531
- } else {
2532
- dispatch(setFontFamily(selectedOptionId || defaultFontFamilyOptions.publisher));
2542
+ if (currentSetting === null) {
2543
+ if (isWebPub) {
2544
+ dispatch(setWebPubFontFamily({ key: fontLanguage, value: "publisher" }));
2545
+ } else {
2546
+ dispatch(setFontFamily({ key: fontLanguage, value: "publisher" }));
2547
+ }
2548
+ return;
2549
+ }
2550
+ const entry = Object.entries(fontPreferences).find(([id]) => {
2551
+ const metadata = getFontMetadata(id);
2552
+ return metadata.fontStack === currentSetting || metadata.fontFamily === currentSetting;
2553
+ });
2554
+ if (entry) {
2555
+ const [selectedOptionId] = entry;
2556
+ if (isWebPub) {
2557
+ dispatch(setWebPubFontFamily({ key: fontLanguage, value: selectedOptionId }));
2558
+ } else {
2559
+ dispatch(setFontFamily({ key: fontLanguage, value: selectedOptionId }));
2560
+ }
2533
2561
  }
2534
2562
  }
2535
- }, [isWebPub, fontFamily, submitPreferences, getSetting, dispatch]);
2563
+ }, [isWebPub, fontLanguage, fontFamily, submitPreferences, getSetting, fontPreferences, getFontMetadata, dispatch]);
2536
2564
  return /* @__PURE__ */ jsx(
2537
2565
  StatefulDropdown,
2538
2566
  {
2539
2567
  standalone,
2540
2568
  label: t("reader.preferences.fontFamily.title"),
2541
- selectedKey: fontFamily,
2569
+ selectedKey: currentFontFamily,
2542
2570
  onSelectionChange: async (key) => await updatePreference(key),
2543
2571
  compounds: {
2544
2572
  listbox: /* @__PURE__ */ jsx(
@@ -2844,6 +2872,55 @@ var StatefulSlider = ({
2844
2872
  }
2845
2873
  ) });
2846
2874
  };
2875
+ function useSettingsComponentStatus(options) {
2876
+ const { settingsKey, publicationType, componentType, additionalCondition = true } = options;
2877
+ const { spacingSettingsComponentsMap, textSettingsComponentsMap, settingsComponentsMap } = usePlugins();
2878
+ const { preferences } = usePreferences();
2879
+ return useMemo(() => {
2880
+ const isComponentRegistered = !!(settingsComponentsMap?.[settingsKey] || spacingSettingsComponentsMap?.[settingsKey] || textSettingsComponentsMap?.[settingsKey]);
2881
+ let isInOrder = false;
2882
+ switch (publicationType) {
2883
+ case "reflow":
2884
+ isInOrder = preferences.settings?.reflowOrder?.includes(settingsKey) || false;
2885
+ break;
2886
+ case "fxl":
2887
+ isInOrder = preferences.settings?.fxlOrder?.includes(settingsKey) || false;
2888
+ break;
2889
+ case "webpub":
2890
+ isInOrder = preferences.settings?.webPubOrder?.includes(settingsKey) || false;
2891
+ break;
2892
+ }
2893
+ let isInMainPanel = false;
2894
+ let isInSubPanel = false;
2895
+ if (componentType === "text") {
2896
+ isInMainPanel = preferences.settings?.text?.main?.includes(settingsKey) || false;
2897
+ isInSubPanel = preferences.settings?.text?.subPanel?.includes(settingsKey) || false;
2898
+ } else if (componentType === "spacing") {
2899
+ isInMainPanel = preferences.settings?.spacing?.main?.includes(settingsKey) || false;
2900
+ isInSubPanel = preferences.settings?.spacing?.subPanel?.includes(settingsKey) || false;
2901
+ }
2902
+ const isDisplayed = isInOrder || (isInMainPanel || isInSubPanel) && additionalCondition;
2903
+ const isComponentUsed = isComponentRegistered && isDisplayed;
2904
+ return {
2905
+ isComponentRegistered,
2906
+ isInMainPanel,
2907
+ isInSubPanel,
2908
+ isDisplayed,
2909
+ isComponentUsed
2910
+ };
2911
+ }, [
2912
+ settingsKey,
2913
+ publicationType,
2914
+ componentType,
2915
+ additionalCondition,
2916
+ preferences,
2917
+ spacingSettingsComponentsMap,
2918
+ textSettingsComponentsMap,
2919
+ settingsComponentsMap
2920
+ ]);
2921
+ }
2922
+
2923
+ // src/components/Settings/Spacing/hooks/useSpacingPresets.ts
2847
2924
  var useSpacingPresets = () => {
2848
2925
  const readerProfile = useAppSelector((state) => state.reader.profile);
2849
2926
  const isWebPub = readerProfile === "webPub";
@@ -2856,20 +2933,18 @@ var useSpacingPresets = () => {
2856
2933
  custom: {},
2857
2934
  baseline: {}
2858
2935
  };
2859
- const { spacingSettingsComponentsMap } = usePlugins();
2860
2936
  const { reflowSpacingPresetKeys, fxlSpacingPresetKeys, webPubSpacingPresetKeys } = usePreferenceKeys();
2861
2937
  const { preferences } = usePreferences();
2862
2938
  const dispatch = useAppDispatch();
2863
2939
  const spacingKeys = useMemo(() => {
2864
2940
  return isWebPub ? webPubSpacingPresetKeys : isFXL ? fxlSpacingPresetKeys : reflowSpacingPresetKeys;
2865
2941
  }, [isWebPub, isFXL, webPubSpacingPresetKeys, fxlSpacingPresetKeys, reflowSpacingPresetKeys]);
2866
- const isComponentRegistered = !!spacingSettingsComponentsMap?.["spacingPresets" /* spacingPresets */];
2867
- const mainDisplayOrder = preferences.settings?.spacing?.main || defaultSpacingSettingsMain;
2868
- const subPanelDisplayOrder = preferences.settings?.spacing?.subPanel || defaultSpacingSettingsSubpanel;
2869
- const isInMainPanel = mainDisplayOrder.includes("spacingPresets" /* spacingPresets */);
2870
- const isInSubPanel = subPanelDisplayOrder.includes("spacingPresets" /* spacingPresets */);
2871
- const isDisplayed = (isInMainPanel || isInSubPanel) && spacingKeys.length > 0;
2872
- const shouldApplyPresets = isComponentRegistered && isDisplayed;
2942
+ const { isComponentUsed: shouldApplyPresets } = useSettingsComponentStatus({
2943
+ settingsKey: "spacingPresets" /* spacingPresets */,
2944
+ publicationType: isWebPub ? "webpub" : isFXL ? "fxl" : "reflow",
2945
+ componentType: "spacing",
2946
+ additionalCondition: spacingKeys.length > 0
2947
+ });
2873
2948
  const {
2874
2949
  letterSpacing,
2875
2950
  lineHeight,
@@ -3874,7 +3949,7 @@ var createDefaultPlugin = () => {
3874
3949
  id: "core",
3875
3950
  name: "Core Components",
3876
3951
  description: "Default components for Thorium Web Epub StatefulReader",
3877
- version: "1.1.2",
3952
+ version: "1.1.3",
3878
3953
  components: {
3879
3954
  actions: {
3880
3955
  ["fullscreen" /* fullscreen */]: {
@@ -4703,7 +4778,7 @@ var StatefulReaderProgression = ({
4703
4778
  break;
4704
4779
  case "positionsLeft" /* positionsLeft */:
4705
4780
  if (positionsLeft !== void 0) {
4706
- text = t(`reader.progression.positionsLeftInChapter`, {
4781
+ text = t(`reader.progression.positionsLeftInChapter.descriptive`, {
4707
4782
  count: positionsLeft
4708
4783
  });
4709
4784
  }
@@ -4930,6 +5005,231 @@ var StatefulReaderFooter = ({
4930
5005
  ] });
4931
5006
  };
4932
5007
 
5008
+ // src/core/Hooks/fonts/androidPatchCss.ts
5009
+ var getAndroidPatchCss = () => {
5010
+ if (typeof window === "undefined") {
5011
+ return "";
5012
+ }
5013
+ const origin = window.location.origin;
5014
+ return `/* Readium CSS
5015
+ Android Fonts Patch module
5016
+
5017
+ A stylesheet aligning Android generic serif and sans-serif fonts on other platforms
5018
+
5019
+ Repo: https://github.com/readium/css */
5020
+
5021
+ /* Android resolves sans-serif to Roboto, and serif to Droid Serif
5022
+ This created issues for FXL EPUBs relying on Times (New Roman),
5023
+ Helvetica or Arial while not embedding the font files in the package.
5024
+
5025
+ See https://github.com/readium/css/issues/149
5026
+
5027
+ Unfortunately it is no possible to target generic family using @font-face,
5028
+ we have to target specific font-family names e.g. Times, Arial, etc.
5029
+
5030
+ This stylesheet/patch should be loaded only for this case i.e.
5031
+ a Fixed-Layout EPUB with text but no embedded font on an Android device.
5032
+ The logic for checking these conditions are up to implementers.
5033
+ */
5034
+
5035
+ /* Serif (Times + Times New Roman) */
5036
+
5037
+ @font-face {
5038
+ font-family: Times;
5039
+ src: url("${new URL("/fonts/AndroidPatch/serif/NimbusRoman.woff", origin).toString()}") format("woff");
5040
+ font-weight: normal;
5041
+ font-style: normal;
5042
+ }
5043
+
5044
+ @font-face {
5045
+ font-family: "Times New Roman";
5046
+ src: url("${new URL("/fonts/AndroidPatch/serif/NimbusRoman.woff", origin).toString()}") format("woff");
5047
+ font-weight: normal;
5048
+ font-style: normal;
5049
+ }
5050
+
5051
+ @font-face {
5052
+ font-family: Times;
5053
+ src: url("${new URL("/fonts/AndroidPatch/serif/NimbusRoman-Italic.woff", origin).toString()}") format("woff");
5054
+ font-weight: normal;
5055
+ font-style: italic;
5056
+ }
5057
+
5058
+ @font-face {
5059
+ font-family: "Times New Roman";
5060
+ src: url("${new URL("/fonts/AndroidPatch/serif/NimbusRoman-Italic.woff", origin).toString()}") format("woff");
5061
+ font-weight: normal;
5062
+ font-style: italic;
5063
+ }
5064
+
5065
+ @font-face {
5066
+ font-family: Times;
5067
+ src: url("${new URL("/fonts/AndroidPatch/serif/NimbusRoman-Bold.woff", origin).toString()}") format("woff");
5068
+ font-weight: bold;
5069
+ font-style: normal;
5070
+ }
5071
+
5072
+ @font-face {
5073
+ font-family: "Times New Roman";
5074
+ src: url("${new URL("/fonts/AndroidPatch/serif/NimbusRoman-Bold.woff", origin).toString()}") format("woff");
5075
+ font-weight: bold;
5076
+ font-style: normal;
5077
+ }
5078
+
5079
+ @font-face {
5080
+ font-family: Times;
5081
+ src: url("${new URL("/fonts/AndroidPatch/serif/NimbusRoman-BoldItalic.woff", origin).toString()}") format("woff");
5082
+ font-weight: bold;
5083
+ font-style: italic;
5084
+ }
5085
+
5086
+ @font-face {
5087
+ font-family: "Times New Roman";
5088
+ src: url("${new URL("/fonts/AndroidPatch/serif/NimbusRoman-BoldItalic.woff", origin).toString()}") format("woff");
5089
+ font-weight: bold;
5090
+ font-style: italic;
5091
+ }
5092
+
5093
+ /* Sans-serif (Helvetica + Arial) */
5094
+
5095
+ @font-face {
5096
+ font-family: Helvetica;
5097
+ src: url("${new URL("/fonts/AndroidPatch/sans-serif/NimbusSans.woff", origin).toString()}") format("woff");
5098
+ font-weight: normal;
5099
+ font-style: normal;
5100
+ }
5101
+
5102
+ @font-face {
5103
+ font-family: Arial;
5104
+ src: url("${new URL("/fonts/AndroidPatch/sans-serif/NimbusSans.woff", origin).toString()}") format("woff");
5105
+ font-weight: normal;
5106
+ font-style: normal;
5107
+ }
5108
+
5109
+ @font-face {
5110
+ font-family: Helvetica;
5111
+ src: url("${new URL("/fonts/AndroidPatch/sans-serif/NimbusSans-Italic.woff", origin).toString()}") format("woff");
5112
+ font-weight: normal;
5113
+ font-style: italic;
5114
+ }
5115
+
5116
+ @font-face {
5117
+ font-family: Arial;
5118
+ src: url("${new URL("/fonts/AndroidPatch/sans-serif/NimbusSans-Italic.woff", origin).toString()}") format("woff");
5119
+ font-weight: normal;
5120
+ font-style: italic;
5121
+ }
5122
+
5123
+ @font-face {
5124
+ font-family: Helvetica;
5125
+ src: url("${new URL("/fonts/AndroidPatch/sans-serif/NimbusSans-Bold.woff", origin).toString()}") format("woff");
5126
+ font-weight: bold;
5127
+ font-style: normal;
5128
+ }
5129
+
5130
+ @font-face {
5131
+ font-family: Arial;
5132
+ src: url("${new URL("/fonts/AndroidPatch/sans-serif/NimbusSans-Bold.woff", origin).toString()}") format("woff");
5133
+ font-weight: bold;
5134
+ font-style: normal;
5135
+ }
5136
+
5137
+ @font-face {
5138
+ font-family: Helvetica;
5139
+ src: url("${new URL("/fonts/AndroidPatch/sans-serif/NimbusSans-BoldItalic.woff", origin).toString()}") format("woff");
5140
+ font-weight: bold;
5141
+ font-style: italic;
5142
+ }
5143
+
5144
+ @font-face {
5145
+ font-family: Arial;
5146
+ src: url("${new URL("/fonts/AndroidPatch/sans-serif/NimbusSans-BoldItalic.woff", origin).toString()}") format("woff");
5147
+ font-weight: bold;
5148
+ font-style: italic;
5149
+ }`;
5150
+ };
5151
+
5152
+ // src/core/Hooks/fonts/useFonts.ts
5153
+ var useFonts = (fontResources) => {
5154
+ const injectedElementsRef = useRef({
5155
+ prepend: [],
5156
+ append: []
5157
+ });
5158
+ const createLinkElement = useCallback((resource) => {
5159
+ const link = document.createElement("link");
5160
+ if ("attributes" in resource && resource.attributes) {
5161
+ Object.entries(resource.attributes).forEach(([key, value]) => {
5162
+ link.setAttribute(key, value);
5163
+ });
5164
+ }
5165
+ link.rel = resource.rel;
5166
+ link.as = resource.as;
5167
+ if ("url" in resource) {
5168
+ link.href = resource.url;
5169
+ } else if ("blob" in resource && resource.blob) {
5170
+ link.href = URL.createObjectURL(resource.blob);
5171
+ }
5172
+ return link;
5173
+ }, []);
5174
+ const removeInjectedElements = useCallback(() => {
5175
+ const { prepend, append } = injectedElementsRef.current;
5176
+ [...prepend, ...append].forEach((element) => {
5177
+ if (element.parentNode) {
5178
+ element.parentNode.removeChild(element);
5179
+ }
5180
+ if (element instanceof HTMLLinkElement && element.href.startsWith("blob:")) {
5181
+ URL.revokeObjectURL(element.href);
5182
+ }
5183
+ });
5184
+ injectedElementsRef.current = {
5185
+ prepend: [],
5186
+ append: []
5187
+ };
5188
+ }, []);
5189
+ const injectFontResources = useCallback((resources) => {
5190
+ if (typeof document === "undefined") return;
5191
+ removeInjectedElements();
5192
+ if (!resources) return;
5193
+ const { prepend, append } = resources;
5194
+ const injectedElements = injectedElementsRef.current;
5195
+ prepend.forEach((resource) => {
5196
+ const element = createLinkElement(resource);
5197
+ document.head.insertBefore(element, document.head.firstChild);
5198
+ injectedElements.prepend.push(element);
5199
+ });
5200
+ append.forEach((resource) => {
5201
+ const element = createLinkElement(resource);
5202
+ document.head.appendChild(element);
5203
+ injectedElements.append.push(element);
5204
+ });
5205
+ }, [createLinkElement, removeInjectedElements]);
5206
+ const getAndroidFXLPatch = useCallback(() => {
5207
+ const platform = getPlatform();
5208
+ const isAndroid = platform === "android";
5209
+ if (!isAndroid) {
5210
+ return null;
5211
+ }
5212
+ const cssContent = getAndroidPatchCss();
5213
+ const blob = new Blob([cssContent], { type: "text/css" });
5214
+ return {
5215
+ as: "link",
5216
+ rel: "stylesheet",
5217
+ blob
5218
+ };
5219
+ }, []);
5220
+ useEffect(() => {
5221
+ injectFontResources(fontResources || null);
5222
+ return () => {
5223
+ removeInjectedElements();
5224
+ };
5225
+ }, [fontResources, injectFontResources, removeInjectedElements]);
5226
+ return {
5227
+ injectFontResources,
5228
+ removeFontResources: removeInjectedElements,
5229
+ getAndroidFXLPatch
5230
+ };
5231
+ };
5232
+
4933
5233
  // src/helpers/peripherals.ts
4934
5234
  var Peripherals = class {
4935
5235
  observers = ["keydown"];
@@ -5063,6 +5363,6 @@ function getReaderClassNames(options) {
5063
5363
  );
5064
5364
  }
5065
5365
 
5066
- export { NavigatorProvider, Peripherals, StatefulActionIcon, StatefulBottomSheet, StatefulCollapsibleActionsBar, StatefulColumns, StatefulDockedSheet, StatefulDockingWrapper, StatefulDropdown, StatefulFontFamily, StatefulFullScreenSheet, StatefulFullscreenTrigger, StatefulGroupWrapper, StatefulHyphens, StatefulJumpToPositionContainer, StatefulJumpToPositionTrigger, StatefulLayout, StatefulLetterSpacing, StatefulLineHeight, StatefulNumberField, StatefulOverflowMenu, StatefulOverflowMenuItem, StatefulParagraphIndent, StatefulParagraphSpacing, StatefulPopoverSheet, StatefulPreferencesProvider, StatefulPublisherStyles, StatefulRadioGroup, StatefulReaderFooter, StatefulReaderHeader, StatefulSettingsContainer, StatefulSettingsTrigger, StatefulSheetWrapper, StatefulSlider, StatefulSpacingGroup, StatefulSpacingGroupContainer, StatefulSpacingPresets, StatefulSwitch, StatefulTextAlign, StatefulTextGroup, StatefulTextGroupContainer, StatefulTextNormalize, StatefulTheme, StatefulTocContainer, StatefulTocTrigger, StatefulWordSpacing, StatefulZoom, ThPluginProvider, ThPluginRegistry, UnstableStatefulFontWeight, createDefaultPlugin, getReaderClassNames, thorium_web_button_default, thorium_web_reader_app_default, useDocking, useGridNavigation, useGridTemplate, useLineHeight, useNavigator, usePublication, useReaderTransitions, useSpacingPresets };
5067
- //# sourceMappingURL=chunk-2JHEFF46.mjs.map
5068
- //# sourceMappingURL=chunk-2JHEFF46.mjs.map
5366
+ export { NavigatorProvider, Peripherals, StatefulActionIcon, StatefulBottomSheet, StatefulCollapsibleActionsBar, StatefulColumns, StatefulDockedSheet, StatefulDockingWrapper, StatefulDropdown, StatefulFontFamily, StatefulFullScreenSheet, StatefulFullscreenTrigger, StatefulGroupWrapper, StatefulHyphens, StatefulJumpToPositionContainer, StatefulJumpToPositionTrigger, StatefulLayout, StatefulLetterSpacing, StatefulLineHeight, StatefulNumberField, StatefulOverflowMenu, StatefulOverflowMenuItem, StatefulParagraphIndent, StatefulParagraphSpacing, StatefulPopoverSheet, StatefulPreferencesProvider, StatefulPublisherStyles, StatefulRadioGroup, StatefulReaderFooter, StatefulReaderHeader, StatefulSettingsContainer, StatefulSettingsTrigger, StatefulSheetWrapper, StatefulSlider, StatefulSpacingGroup, StatefulSpacingGroupContainer, StatefulSpacingPresets, StatefulSwitch, StatefulTextAlign, StatefulTextGroup, StatefulTextGroupContainer, StatefulTextNormalize, StatefulTheme, StatefulTocContainer, StatefulTocTrigger, StatefulWordSpacing, StatefulZoom, ThPluginProvider, ThPluginRegistry, UnstableStatefulFontWeight, createDefaultPlugin, getReaderClassNames, thorium_web_button_default, thorium_web_reader_app_default, useDocking, useFonts, useGridNavigation, useGridTemplate, useLineHeight, useNavigator, usePublication, useReaderTransitions, useSettingsComponentStatus, useSpacingPresets };
5367
+ //# sourceMappingURL=chunk-JDMFK3LV.mjs.map
5368
+ //# sourceMappingURL=chunk-JDMFK3LV.mjs.map