intor 2.2.8 → 2.2.10

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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  var formatUrl = require('next/dist/shared/lib/router/utils/format-url');
4
4
  var NextLink = require('next/link');
5
- var React6 = require('react');
5
+ var React10 = require('react');
6
6
  var navigation = require('next/navigation');
7
7
  var merge = require('lodash.merge');
8
8
  var jsxRuntime = require('react/jsx-runtime');
@@ -32,7 +32,7 @@ function _interopNamespace(e) {
32
32
  }
33
33
 
34
34
  var NextLink__default = /*#__PURE__*/_interopDefault(NextLink);
35
- var React6__namespace = /*#__PURE__*/_interopNamespace(React6);
35
+ var React10__namespace = /*#__PURE__*/_interopNamespace(React10);
36
36
  var merge__default = /*#__PURE__*/_interopDefault(merge);
37
37
  var Keyv__default = /*#__PURE__*/_interopDefault(Keyv);
38
38
 
@@ -281,20 +281,40 @@ var localizePathname = ({
281
281
  localePrefixedPathname
282
282
  };
283
283
  };
284
- var ConfigContext = React6__namespace.createContext(void 0);
284
+ var ConfigContext = React10__namespace.createContext(void 0);
285
285
  function ConfigProvider({
286
286
  value: { config, pathname },
287
287
  children
288
288
  }) {
289
- const value = React6__namespace.useMemo(() => ({ config, pathname }), [config, pathname]);
289
+ const value = React10__namespace.useMemo(() => ({ config, pathname }), [config, pathname]);
290
290
  return /* @__PURE__ */ jsxRuntime.jsx(ConfigContext.Provider, { value, children });
291
291
  }
292
292
  function useConfig() {
293
- const context = React6__namespace.useContext(ConfigContext);
293
+ const context = React10__namespace.useContext(ConfigContext);
294
294
  if (!context) throw new Error("useConfig must be used within ConfigProvider");
295
295
  return context;
296
296
  }
297
297
 
298
+ // src/client/react/contexts/load-import-messages.ts
299
+ async function loadImportMessages({
300
+ config,
301
+ locale,
302
+ importLoader,
303
+ setLoadedMessages,
304
+ setIsLoadingMessages
305
+ }) {
306
+ if (!importLoader) return;
307
+ try {
308
+ setIsLoadingMessages(true);
309
+ const importMessages = await importLoader(locale);
310
+ setLoadedMessages(mergeMessages(config.messages, importMessages));
311
+ } catch (error) {
312
+ console.error(`Failed to load messages for ${locale}`, error);
313
+ } finally {
314
+ setIsLoadingMessages(false);
315
+ }
316
+ }
317
+
298
318
  // src/config/constants/cache.constants.ts
299
319
  var DEFAULT_CACHE_OPTIONS = {
300
320
  enabled: process.env.NODE_ENV === "production",
@@ -503,11 +523,11 @@ var useRefetchMessages = ({
503
523
  setIsLoadingMessages
504
524
  }) => {
505
525
  const { messages: staticMessages } = config;
506
- const namespaces = React6__namespace.useMemo(() => {
526
+ const namespaces = React10__namespace.useMemo(() => {
507
527
  if (!config.loader) return [];
508
528
  return resolveNamespaces({ config, pathname });
509
529
  }, [config, pathname]);
510
- const refetchMessages = React6__namespace.useCallback(
530
+ const refetchMessages = React10__namespace.useCallback(
511
531
  async (newLocale) => {
512
532
  if (config.loader?.type === "remote") {
513
533
  setIsLoadingMessages(true);
@@ -540,21 +560,21 @@ var useRefetchMessages = ({
540
560
  );
541
561
  return { refetchMessages };
542
562
  };
543
- var MessagesContext = React6__namespace.createContext(void 0);
563
+ var MessagesContext = React10__namespace.createContext(void 0);
544
564
  function MessagesProvider({
545
565
  value: { messages = {} },
546
566
  children
547
567
  }) {
548
568
  const { config, pathname } = useConfig();
549
- const [loadedMessages, setLoadedMessages] = React6__namespace.useState(null);
550
- const [isLoadingMessages, setIsLoadingMessages] = React6__namespace.useState(false);
569
+ const [loadedMessages, setLoadedMessages] = React10__namespace.useState(null);
570
+ const [isLoadingMessages, setIsLoadingMessages] = React10__namespace.useState(false);
551
571
  const { refetchMessages } = useRefetchMessages({
552
572
  config,
553
573
  pathname,
554
574
  setLoadedMessages,
555
575
  setIsLoadingMessages
556
576
  });
557
- const value = React6__namespace.useMemo(
577
+ const value = React10__namespace.useMemo(
558
578
  () => ({
559
579
  messages: loadedMessages || messages,
560
580
  isLoading: isLoadingMessages,
@@ -567,7 +587,7 @@ function MessagesProvider({
567
587
  return /* @__PURE__ */ jsxRuntime.jsx(MessagesContext.Provider, { value, children });
568
588
  }
569
589
  function useMessages() {
570
- const context = React6__namespace.useContext(MessagesContext);
590
+ const context = React10__namespace.useContext(MessagesContext);
571
591
  if (!context)
572
592
  throw new Error("useMessages must be used within a MessagesProvider");
573
593
  return context;
@@ -580,14 +600,15 @@ var useInitLazyLoad = ({
580
600
  }) => {
581
601
  const { refetchMessages } = useMessages();
582
602
  const lazyLoad = !!loaderOptions?.lazyLoad;
583
- const isFirstLoadedRef = React6__namespace.useRef(false);
584
- React6__namespace.useEffect(() => {
603
+ const isFirstLoadedRef = React10__namespace.useRef(false);
604
+ React10__namespace.useEffect(() => {
585
605
  if (lazyLoad && !isFirstLoadedRef.current) {
586
606
  void refetchMessages(currentLocale);
587
607
  isFirstLoadedRef.current = true;
588
608
  }
589
609
  }, [lazyLoad, currentLocale, refetchMessages, isFirstLoadedRef]);
590
610
  };
611
+ var LocaleContext = React10__namespace.createContext(void 0);
591
612
 
592
613
  // src/shared/utils/client/build-cookie-string.ts
593
614
  var buildCookieString = (cookie, locale) => {
@@ -622,25 +643,6 @@ var setLocaleCookieBrowser = ({
622
643
  document.cookie = cookieString;
623
644
  };
624
645
 
625
- // src/client/react/contexts/locale/utils/use-init-locale-cookie.ts
626
- var useInitLocaleCookie = ({
627
- config,
628
- locale
629
- }) => {
630
- React6__namespace.useEffect(() => {
631
- if (typeof document === "undefined") return;
632
- const { cookie, routing } = config;
633
- const { firstVisit } = routing;
634
- const cookies2 = document.cookie.split(";").map((c) => c.trim());
635
- const isCookieExists = cookies2.some((c) => c.startsWith(`${cookie.name}=`));
636
- if (isCookieExists) return;
637
- if (!firstVisit.redirect) return;
638
- if (cookie.disabled || !cookie.autoSetCookie) return;
639
- setLocaleCookieBrowser({ cookie, locale });
640
- }, []);
641
- };
642
- var LocaleContext = React6__namespace.createContext(void 0);
643
-
644
646
  // src/client/react/contexts/locale/utils/change-locale.ts
645
647
  var changeLocale = ({
646
648
  currentLocale,
@@ -666,17 +668,16 @@ var changeLocale = ({
666
668
  }
667
669
  };
668
670
  function LocaleProvider({
669
- value: { initialLocale },
671
+ value: { initialLocale, importLoader },
670
672
  children
671
673
  }) {
672
674
  const { config } = useConfig();
673
- const { refetchMessages } = useMessages();
675
+ const { refetchMessages, setLoadedMessages, setIsLoadingMessages } = useMessages();
674
676
  const { loader: loaderOptions, cookie } = config;
675
- const [currentLocale, setCurrentLocale] = React6__namespace.useState(initialLocale);
677
+ const [currentLocale, setCurrentLocale] = React10__namespace.useState(initialLocale);
676
678
  useInitLazyLoad({ loaderOptions, currentLocale });
677
- useInitLocaleCookie({ config, locale: initialLocale });
678
- const setLocale = React6__namespace.useCallback(
679
- (newLocale) => {
679
+ const setLocale = React10__namespace.useCallback(
680
+ async (newLocale) => {
680
681
  changeLocale({
681
682
  currentLocale,
682
683
  newLocale,
@@ -685,10 +686,28 @@ function LocaleProvider({
685
686
  setLocale: setCurrentLocale,
686
687
  refetchMessages
687
688
  });
689
+ await loadImportMessages({
690
+ config,
691
+ locale: newLocale,
692
+ importLoader,
693
+ setLoadedMessages,
694
+ setIsLoadingMessages
695
+ });
688
696
  },
689
- [currentLocale, loaderOptions, cookie, refetchMessages]
697
+ [
698
+ currentLocale,
699
+ loaderOptions,
700
+ cookie,
701
+ refetchMessages,
702
+ importLoader,
703
+ setLoadedMessages,
704
+ setIsLoadingMessages
705
+ ]
690
706
  );
691
- const value = React6__namespace.useMemo(
707
+ React10__namespace.useEffect(() => {
708
+ void setLocale(initialLocale);
709
+ }, []);
710
+ const value = React10__namespace.useMemo(
692
711
  () => ({
693
712
  locale: currentLocale,
694
713
  setLocale
@@ -698,7 +717,7 @@ function LocaleProvider({
698
717
  return /* @__PURE__ */ jsxRuntime.jsx(LocaleContext.Provider, { value, children });
699
718
  }
700
719
  function useLocale() {
701
- const context = React6__namespace.useContext(LocaleContext);
720
+ const context = React10__namespace.useContext(LocaleContext);
702
721
  if (!context)
703
722
  throw new Error("useLocale must be used within a LocaleProvider");
704
723
  return context;
@@ -863,7 +882,7 @@ var redirect = async ({
863
882
  });
864
883
  navigation.redirect(localePrefixedPathname, type);
865
884
  };
866
- var TranslateHandlersContext = React6__namespace.createContext(void 0);
885
+ var TranslateHandlersContext = React10__namespace.createContext(void 0);
867
886
  var TranslateHandlersProvider = ({
868
887
  children,
869
888
  handlers
@@ -872,19 +891,19 @@ var TranslateHandlersProvider = ({
872
891
  return /* @__PURE__ */ jsxRuntime.jsx(TranslateHandlersContext.Provider, { value, children });
873
892
  };
874
893
  function useTranslateHandlers() {
875
- const context = React6__namespace.useContext(TranslateHandlersContext);
894
+ const context = React10__namespace.useContext(TranslateHandlersContext);
876
895
  return context;
877
896
  }
878
897
  var useInitLoadingState = (config) => {
879
898
  const lazyLoad = !!config.loader?.lazyLoad;
880
- const [isCsr, setIsCsr] = React6__namespace.useState(false);
881
- React6__namespace.useEffect(() => {
899
+ const [isCsr, setIsCsr] = React10__namespace.useState(false);
900
+ React10__namespace.useEffect(() => {
882
901
  setIsCsr(true);
883
902
  }, []);
884
903
  const isBeforeCSRLoading = lazyLoad && !isCsr;
885
904
  return isBeforeCSRLoading;
886
905
  };
887
- var TranslatorContext = React6__namespace.createContext(void 0);
906
+ var TranslatorContext = React10__namespace.createContext(void 0);
888
907
  var EMPTY_OBJECT = Object.freeze({});
889
908
  function TranslatorProvider({ children }) {
890
909
  const { config } = useConfig();
@@ -893,7 +912,7 @@ function TranslatorProvider({ children }) {
893
912
  const translatorHandlers = useTranslateHandlers();
894
913
  const { fallbackLocales, translator: translatorOptions } = config;
895
914
  const isBeforeCSRLoading = useInitLoadingState(config);
896
- const value = React6__namespace.useMemo(() => {
915
+ const value = React10__namespace.useMemo(() => {
897
916
  const translator = new intorTranslator.Translator({
898
917
  messages: messages || EMPTY_OBJECT,
899
918
  locale,
@@ -917,7 +936,7 @@ function TranslatorProvider({ children }) {
917
936
  return /* @__PURE__ */ jsxRuntime.jsx(TranslatorContext.Provider, { value, children });
918
937
  }
919
938
  function useTranslator() {
920
- const context = React6__namespace.useContext(TranslatorContext);
939
+ const context = React10__namespace.useContext(TranslatorContext);
921
940
  if (!context)
922
941
  throw new Error(
923
942
  "useTranslator must be used within IntorTranslatorProvider"
@@ -925,10 +944,16 @@ function useTranslator() {
925
944
  return context;
926
945
  }
927
946
  var IntorProvider = ({
928
- value: { config, pathname = "", initialLocale, messages = config.messages },
947
+ value: {
948
+ config,
949
+ pathname = "",
950
+ initialLocale,
951
+ messages = config.messages,
952
+ importLoader
953
+ },
929
954
  children
930
955
  }) => {
931
- return /* @__PURE__ */ jsxRuntime.jsx(ConfigProvider, { value: { config, pathname }, children: /* @__PURE__ */ jsxRuntime.jsx(MessagesProvider, { value: { messages }, children: /* @__PURE__ */ jsxRuntime.jsx(LocaleProvider, { value: { initialLocale }, children: /* @__PURE__ */ jsxRuntime.jsx(TranslatorProvider, { children }) }) }) });
956
+ return /* @__PURE__ */ jsxRuntime.jsx(ConfigProvider, { value: { config, pathname }, children: /* @__PURE__ */ jsxRuntime.jsx(MessagesProvider, { value: { messages }, children: /* @__PURE__ */ jsxRuntime.jsx(LocaleProvider, { value: { initialLocale, importLoader }, children: /* @__PURE__ */ jsxRuntime.jsx(TranslatorProvider, { children }) }) }) });
932
957
  };
933
958
 
934
959
  // src/client/react/hooks/use-translator.ts
@@ -223,11 +223,12 @@ interface IntorProviderProps {
223
223
  initialLocale: Locale;
224
224
  pathname?: string;
225
225
  messages?: Readonly<LocaleMessages>;
226
+ importLoader?: (locale: string) => Promise<LocaleMessages>;
226
227
  };
227
228
  children: React.ReactNode;
228
229
  }
229
230
 
230
- declare const IntorProvider: ({ value: { config, pathname, initialLocale, messages }, children, }: IntorProviderProps) => react_jsx_runtime.JSX.Element;
231
+ declare const IntorProvider: ({ value: { config, pathname, initialLocale, messages, importLoader, }, children, }: IntorProviderProps) => react_jsx_runtime.JSX.Element;
231
232
 
232
233
  type TranslateHandlersProviderProps = {
233
234
  children: React.ReactNode;
@@ -223,11 +223,12 @@ interface IntorProviderProps {
223
223
  initialLocale: Locale;
224
224
  pathname?: string;
225
225
  messages?: Readonly<LocaleMessages>;
226
+ importLoader?: (locale: string) => Promise<LocaleMessages>;
226
227
  };
227
228
  children: React.ReactNode;
228
229
  }
229
230
 
230
- declare const IntorProvider: ({ value: { config, pathname, initialLocale, messages }, children, }: IntorProviderProps) => react_jsx_runtime.JSX.Element;
231
+ declare const IntorProvider: ({ value: { config, pathname, initialLocale, messages, importLoader, }, children, }: IntorProviderProps) => react_jsx_runtime.JSX.Element;
231
232
 
232
233
  type TranslateHandlersProviderProps = {
233
234
  children: React.ReactNode;
@@ -1,6 +1,6 @@
1
1
  import { formatUrl } from 'next/dist/shared/lib/router/utils/format-url';
2
2
  import NextLink from 'next/link';
3
- import * as React6 from 'react';
3
+ import * as React10 from 'react';
4
4
  import { usePathname as usePathname$1, useRouter as useRouter$1, redirect as redirect$1 } from 'next/navigation';
5
5
  import merge from 'lodash.merge';
6
6
  import { jsx } from 'react/jsx-runtime';
@@ -254,20 +254,40 @@ var localizePathname = ({
254
254
  localePrefixedPathname
255
255
  };
256
256
  };
257
- var ConfigContext = React6.createContext(void 0);
257
+ var ConfigContext = React10.createContext(void 0);
258
258
  function ConfigProvider({
259
259
  value: { config, pathname },
260
260
  children
261
261
  }) {
262
- const value = React6.useMemo(() => ({ config, pathname }), [config, pathname]);
262
+ const value = React10.useMemo(() => ({ config, pathname }), [config, pathname]);
263
263
  return /* @__PURE__ */ jsx(ConfigContext.Provider, { value, children });
264
264
  }
265
265
  function useConfig() {
266
- const context = React6.useContext(ConfigContext);
266
+ const context = React10.useContext(ConfigContext);
267
267
  if (!context) throw new Error("useConfig must be used within ConfigProvider");
268
268
  return context;
269
269
  }
270
270
 
271
+ // src/client/react/contexts/load-import-messages.ts
272
+ async function loadImportMessages({
273
+ config,
274
+ locale,
275
+ importLoader,
276
+ setLoadedMessages,
277
+ setIsLoadingMessages
278
+ }) {
279
+ if (!importLoader) return;
280
+ try {
281
+ setIsLoadingMessages(true);
282
+ const importMessages = await importLoader(locale);
283
+ setLoadedMessages(mergeMessages(config.messages, importMessages));
284
+ } catch (error) {
285
+ console.error(`Failed to load messages for ${locale}`, error);
286
+ } finally {
287
+ setIsLoadingMessages(false);
288
+ }
289
+ }
290
+
271
291
  // src/config/constants/cache.constants.ts
272
292
  var DEFAULT_CACHE_OPTIONS = {
273
293
  enabled: process.env.NODE_ENV === "production",
@@ -476,11 +496,11 @@ var useRefetchMessages = ({
476
496
  setIsLoadingMessages
477
497
  }) => {
478
498
  const { messages: staticMessages } = config;
479
- const namespaces = React6.useMemo(() => {
499
+ const namespaces = React10.useMemo(() => {
480
500
  if (!config.loader) return [];
481
501
  return resolveNamespaces({ config, pathname });
482
502
  }, [config, pathname]);
483
- const refetchMessages = React6.useCallback(
503
+ const refetchMessages = React10.useCallback(
484
504
  async (newLocale) => {
485
505
  if (config.loader?.type === "remote") {
486
506
  setIsLoadingMessages(true);
@@ -513,21 +533,21 @@ var useRefetchMessages = ({
513
533
  );
514
534
  return { refetchMessages };
515
535
  };
516
- var MessagesContext = React6.createContext(void 0);
536
+ var MessagesContext = React10.createContext(void 0);
517
537
  function MessagesProvider({
518
538
  value: { messages = {} },
519
539
  children
520
540
  }) {
521
541
  const { config, pathname } = useConfig();
522
- const [loadedMessages, setLoadedMessages] = React6.useState(null);
523
- const [isLoadingMessages, setIsLoadingMessages] = React6.useState(false);
542
+ const [loadedMessages, setLoadedMessages] = React10.useState(null);
543
+ const [isLoadingMessages, setIsLoadingMessages] = React10.useState(false);
524
544
  const { refetchMessages } = useRefetchMessages({
525
545
  config,
526
546
  pathname,
527
547
  setLoadedMessages,
528
548
  setIsLoadingMessages
529
549
  });
530
- const value = React6.useMemo(
550
+ const value = React10.useMemo(
531
551
  () => ({
532
552
  messages: loadedMessages || messages,
533
553
  isLoading: isLoadingMessages,
@@ -540,7 +560,7 @@ function MessagesProvider({
540
560
  return /* @__PURE__ */ jsx(MessagesContext.Provider, { value, children });
541
561
  }
542
562
  function useMessages() {
543
- const context = React6.useContext(MessagesContext);
563
+ const context = React10.useContext(MessagesContext);
544
564
  if (!context)
545
565
  throw new Error("useMessages must be used within a MessagesProvider");
546
566
  return context;
@@ -553,14 +573,15 @@ var useInitLazyLoad = ({
553
573
  }) => {
554
574
  const { refetchMessages } = useMessages();
555
575
  const lazyLoad = !!loaderOptions?.lazyLoad;
556
- const isFirstLoadedRef = React6.useRef(false);
557
- React6.useEffect(() => {
576
+ const isFirstLoadedRef = React10.useRef(false);
577
+ React10.useEffect(() => {
558
578
  if (lazyLoad && !isFirstLoadedRef.current) {
559
579
  void refetchMessages(currentLocale);
560
580
  isFirstLoadedRef.current = true;
561
581
  }
562
582
  }, [lazyLoad, currentLocale, refetchMessages, isFirstLoadedRef]);
563
583
  };
584
+ var LocaleContext = React10.createContext(void 0);
564
585
 
565
586
  // src/shared/utils/client/build-cookie-string.ts
566
587
  var buildCookieString = (cookie, locale) => {
@@ -595,25 +616,6 @@ var setLocaleCookieBrowser = ({
595
616
  document.cookie = cookieString;
596
617
  };
597
618
 
598
- // src/client/react/contexts/locale/utils/use-init-locale-cookie.ts
599
- var useInitLocaleCookie = ({
600
- config,
601
- locale
602
- }) => {
603
- React6.useEffect(() => {
604
- if (typeof document === "undefined") return;
605
- const { cookie, routing } = config;
606
- const { firstVisit } = routing;
607
- const cookies2 = document.cookie.split(";").map((c) => c.trim());
608
- const isCookieExists = cookies2.some((c) => c.startsWith(`${cookie.name}=`));
609
- if (isCookieExists) return;
610
- if (!firstVisit.redirect) return;
611
- if (cookie.disabled || !cookie.autoSetCookie) return;
612
- setLocaleCookieBrowser({ cookie, locale });
613
- }, []);
614
- };
615
- var LocaleContext = React6.createContext(void 0);
616
-
617
619
  // src/client/react/contexts/locale/utils/change-locale.ts
618
620
  var changeLocale = ({
619
621
  currentLocale,
@@ -639,17 +641,16 @@ var changeLocale = ({
639
641
  }
640
642
  };
641
643
  function LocaleProvider({
642
- value: { initialLocale },
644
+ value: { initialLocale, importLoader },
643
645
  children
644
646
  }) {
645
647
  const { config } = useConfig();
646
- const { refetchMessages } = useMessages();
648
+ const { refetchMessages, setLoadedMessages, setIsLoadingMessages } = useMessages();
647
649
  const { loader: loaderOptions, cookie } = config;
648
- const [currentLocale, setCurrentLocale] = React6.useState(initialLocale);
650
+ const [currentLocale, setCurrentLocale] = React10.useState(initialLocale);
649
651
  useInitLazyLoad({ loaderOptions, currentLocale });
650
- useInitLocaleCookie({ config, locale: initialLocale });
651
- const setLocale = React6.useCallback(
652
- (newLocale) => {
652
+ const setLocale = React10.useCallback(
653
+ async (newLocale) => {
653
654
  changeLocale({
654
655
  currentLocale,
655
656
  newLocale,
@@ -658,10 +659,28 @@ function LocaleProvider({
658
659
  setLocale: setCurrentLocale,
659
660
  refetchMessages
660
661
  });
662
+ await loadImportMessages({
663
+ config,
664
+ locale: newLocale,
665
+ importLoader,
666
+ setLoadedMessages,
667
+ setIsLoadingMessages
668
+ });
661
669
  },
662
- [currentLocale, loaderOptions, cookie, refetchMessages]
670
+ [
671
+ currentLocale,
672
+ loaderOptions,
673
+ cookie,
674
+ refetchMessages,
675
+ importLoader,
676
+ setLoadedMessages,
677
+ setIsLoadingMessages
678
+ ]
663
679
  );
664
- const value = React6.useMemo(
680
+ React10.useEffect(() => {
681
+ void setLocale(initialLocale);
682
+ }, []);
683
+ const value = React10.useMemo(
665
684
  () => ({
666
685
  locale: currentLocale,
667
686
  setLocale
@@ -671,7 +690,7 @@ function LocaleProvider({
671
690
  return /* @__PURE__ */ jsx(LocaleContext.Provider, { value, children });
672
691
  }
673
692
  function useLocale() {
674
- const context = React6.useContext(LocaleContext);
693
+ const context = React10.useContext(LocaleContext);
675
694
  if (!context)
676
695
  throw new Error("useLocale must be used within a LocaleProvider");
677
696
  return context;
@@ -836,7 +855,7 @@ var redirect = async ({
836
855
  });
837
856
  redirect$1(localePrefixedPathname, type);
838
857
  };
839
- var TranslateHandlersContext = React6.createContext(void 0);
858
+ var TranslateHandlersContext = React10.createContext(void 0);
840
859
  var TranslateHandlersProvider = ({
841
860
  children,
842
861
  handlers
@@ -845,19 +864,19 @@ var TranslateHandlersProvider = ({
845
864
  return /* @__PURE__ */ jsx(TranslateHandlersContext.Provider, { value, children });
846
865
  };
847
866
  function useTranslateHandlers() {
848
- const context = React6.useContext(TranslateHandlersContext);
867
+ const context = React10.useContext(TranslateHandlersContext);
849
868
  return context;
850
869
  }
851
870
  var useInitLoadingState = (config) => {
852
871
  const lazyLoad = !!config.loader?.lazyLoad;
853
- const [isCsr, setIsCsr] = React6.useState(false);
854
- React6.useEffect(() => {
872
+ const [isCsr, setIsCsr] = React10.useState(false);
873
+ React10.useEffect(() => {
855
874
  setIsCsr(true);
856
875
  }, []);
857
876
  const isBeforeCSRLoading = lazyLoad && !isCsr;
858
877
  return isBeforeCSRLoading;
859
878
  };
860
- var TranslatorContext = React6.createContext(void 0);
879
+ var TranslatorContext = React10.createContext(void 0);
861
880
  var EMPTY_OBJECT = Object.freeze({});
862
881
  function TranslatorProvider({ children }) {
863
882
  const { config } = useConfig();
@@ -866,7 +885,7 @@ function TranslatorProvider({ children }) {
866
885
  const translatorHandlers = useTranslateHandlers();
867
886
  const { fallbackLocales, translator: translatorOptions } = config;
868
887
  const isBeforeCSRLoading = useInitLoadingState(config);
869
- const value = React6.useMemo(() => {
888
+ const value = React10.useMemo(() => {
870
889
  const translator = new Translator({
871
890
  messages: messages || EMPTY_OBJECT,
872
891
  locale,
@@ -890,7 +909,7 @@ function TranslatorProvider({ children }) {
890
909
  return /* @__PURE__ */ jsx(TranslatorContext.Provider, { value, children });
891
910
  }
892
911
  function useTranslator() {
893
- const context = React6.useContext(TranslatorContext);
912
+ const context = React10.useContext(TranslatorContext);
894
913
  if (!context)
895
914
  throw new Error(
896
915
  "useTranslator must be used within IntorTranslatorProvider"
@@ -898,10 +917,16 @@ function useTranslator() {
898
917
  return context;
899
918
  }
900
919
  var IntorProvider = ({
901
- value: { config, pathname = "", initialLocale, messages = config.messages },
920
+ value: {
921
+ config,
922
+ pathname = "",
923
+ initialLocale,
924
+ messages = config.messages,
925
+ importLoader
926
+ },
902
927
  children
903
928
  }) => {
904
- return /* @__PURE__ */ jsx(ConfigProvider, { value: { config, pathname }, children: /* @__PURE__ */ jsx(MessagesProvider, { value: { messages }, children: /* @__PURE__ */ jsx(LocaleProvider, { value: { initialLocale }, children: /* @__PURE__ */ jsx(TranslatorProvider, { children }) }) }) });
929
+ return /* @__PURE__ */ jsx(ConfigProvider, { value: { config, pathname }, children: /* @__PURE__ */ jsx(MessagesProvider, { value: { messages }, children: /* @__PURE__ */ jsx(LocaleProvider, { value: { initialLocale, importLoader }, children: /* @__PURE__ */ jsx(TranslatorProvider, { children }) }) }) });
905
930
  };
906
931
 
907
932
  // src/client/react/hooks/use-translator.ts