intor 2.2.10 → 2.2.11

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