intor 2.2.10 → 2.2.12

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,15 +666,16 @@ var changeLocale = ({
668
666
  }
669
667
  };
670
668
  function LocaleProvider({
671
- value: { initialLocale, importLoader },
669
+ value: { initialLocale, onLocaleChange },
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(
677
+ useInitLocaleCookie({ config, locale: initialLocale });
678
+ const setLocale = React6__namespace.useCallback(
680
679
  async (newLocale) => {
681
680
  changeLocale({
682
681
  currentLocale,
@@ -686,28 +685,11 @@ 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
- });
688
+ onLocaleChange?.(newLocale);
696
689
  },
697
- [
698
- currentLocale,
699
- loaderOptions,
700
- cookie,
701
- refetchMessages,
702
- importLoader,
703
- setLoadedMessages,
704
- setIsLoadingMessages
705
- ]
690
+ [currentLocale, loaderOptions, cookie, refetchMessages, onLocaleChange]
706
691
  );
707
- React10__namespace.useEffect(() => {
708
- void setLocale(initialLocale);
709
- }, []);
710
- const value = React10__namespace.useMemo(
692
+ const value = React6__namespace.useMemo(
711
693
  () => ({
712
694
  locale: currentLocale,
713
695
  setLocale
@@ -717,7 +699,7 @@ function LocaleProvider({
717
699
  return /* @__PURE__ */ jsxRuntime.jsx(LocaleContext.Provider, { value, children });
718
700
  }
719
701
  function useLocale() {
720
- const context = React10__namespace.useContext(LocaleContext);
702
+ const context = React6__namespace.useContext(LocaleContext);
721
703
  if (!context)
722
704
  throw new Error("useLocale must be used within a LocaleProvider");
723
705
  return context;
@@ -882,7 +864,7 @@ var redirect = async ({
882
864
  });
883
865
  navigation.redirect(localePrefixedPathname, type);
884
866
  };
885
- var TranslateHandlersContext = React10__namespace.createContext(void 0);
867
+ var TranslateHandlersContext = React6__namespace.createContext(void 0);
886
868
  var TranslateHandlersProvider = ({
887
869
  children,
888
870
  handlers
@@ -891,19 +873,19 @@ var TranslateHandlersProvider = ({
891
873
  return /* @__PURE__ */ jsxRuntime.jsx(TranslateHandlersContext.Provider, { value, children });
892
874
  };
893
875
  function useTranslateHandlers() {
894
- const context = React10__namespace.useContext(TranslateHandlersContext);
876
+ const context = React6__namespace.useContext(TranslateHandlersContext);
895
877
  return context;
896
878
  }
897
879
  var useInitLoadingState = (config) => {
898
880
  const lazyLoad = !!config.loader?.lazyLoad;
899
- const [isCsr, setIsCsr] = React10__namespace.useState(false);
900
- React10__namespace.useEffect(() => {
881
+ const [isCsr, setIsCsr] = React6__namespace.useState(false);
882
+ React6__namespace.useEffect(() => {
901
883
  setIsCsr(true);
902
884
  }, []);
903
885
  const isBeforeCSRLoading = lazyLoad && !isCsr;
904
886
  return isBeforeCSRLoading;
905
887
  };
906
- var TranslatorContext = React10__namespace.createContext(void 0);
888
+ var TranslatorContext = React6__namespace.createContext(void 0);
907
889
  var EMPTY_OBJECT = Object.freeze({});
908
890
  function TranslatorProvider({ children }) {
909
891
  const { config } = useConfig();
@@ -912,7 +894,7 @@ function TranslatorProvider({ children }) {
912
894
  const translatorHandlers = useTranslateHandlers();
913
895
  const { fallbackLocales, translator: translatorOptions } = config;
914
896
  const isBeforeCSRLoading = useInitLoadingState(config);
915
- const value = React10__namespace.useMemo(() => {
897
+ const value = React6__namespace.useMemo(() => {
916
898
  const translator = new intorTranslator.Translator({
917
899
  messages: messages || EMPTY_OBJECT,
918
900
  locale,
@@ -936,7 +918,7 @@ function TranslatorProvider({ children }) {
936
918
  return /* @__PURE__ */ jsxRuntime.jsx(TranslatorContext.Provider, { value, children });
937
919
  }
938
920
  function useTranslator() {
939
- const context = React10__namespace.useContext(TranslatorContext);
921
+ const context = React6__namespace.useContext(TranslatorContext);
940
922
  if (!context)
941
923
  throw new Error(
942
924
  "useTranslator must be used within IntorTranslatorProvider"
@@ -949,11 +931,11 @@ var IntorProvider = ({
949
931
  pathname = "",
950
932
  initialLocale,
951
933
  messages = config.messages,
952
- importLoader
934
+ onLocaleChange
953
935
  },
954
936
  children
955
937
  }) => {
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 }) }) }) });
938
+ return /* @__PURE__ */ jsxRuntime.jsx(ConfigProvider, { value: { config, pathname }, children: /* @__PURE__ */ jsxRuntime.jsx(MessagesProvider, { value: { messages }, children: /* @__PURE__ */ jsxRuntime.jsx(LocaleProvider, { value: { initialLocale, onLocaleChange }, children: /* @__PURE__ */ jsxRuntime.jsx(TranslatorProvider, { children }) }) }) });
957
939
  };
958
940
 
959
941
  // src/client/react/hooks/use-translator.ts
@@ -223,12 +223,12 @@ interface IntorProviderProps {
223
223
  initialLocale: Locale;
224
224
  pathname?: string;
225
225
  messages?: Readonly<LocaleMessages>;
226
- importLoader?: (locale: string) => Promise<LocaleMessages>;
226
+ onLocaleChange?: (newLocale: string) => Promise<void> | void;
227
227
  };
228
228
  children: React.ReactNode;
229
229
  }
230
230
 
231
- declare const IntorProvider: ({ value: { config, pathname, initialLocale, messages, importLoader, }, children, }: IntorProviderProps) => react_jsx_runtime.JSX.Element;
231
+ declare const IntorProvider: ({ value: { config, pathname, initialLocale, messages, onLocaleChange, }, children, }: IntorProviderProps) => react_jsx_runtime.JSX.Element;
232
232
 
233
233
  type TranslateHandlersProviderProps = {
234
234
  children: React.ReactNode;
@@ -223,12 +223,12 @@ interface IntorProviderProps {
223
223
  initialLocale: Locale;
224
224
  pathname?: string;
225
225
  messages?: Readonly<LocaleMessages>;
226
- importLoader?: (locale: string) => Promise<LocaleMessages>;
226
+ onLocaleChange?: (newLocale: string) => Promise<void> | void;
227
227
  };
228
228
  children: React.ReactNode;
229
229
  }
230
230
 
231
- declare const IntorProvider: ({ value: { config, pathname, initialLocale, messages, importLoader, }, children, }: IntorProviderProps) => react_jsx_runtime.JSX.Element;
231
+ declare const IntorProvider: ({ value: { config, pathname, initialLocale, messages, onLocaleChange, }, children, }: IntorProviderProps) => react_jsx_runtime.JSX.Element;
232
232
 
233
233
  type TranslateHandlersProviderProps = {
234
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 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,15 +639,16 @@ var changeLocale = ({
641
639
  }
642
640
  };
643
641
  function LocaleProvider({
644
- value: { initialLocale, importLoader },
642
+ value: { initialLocale, onLocaleChange },
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(
650
+ useInitLocaleCookie({ config, locale: initialLocale });
651
+ const setLocale = React6.useCallback(
653
652
  async (newLocale) => {
654
653
  changeLocale({
655
654
  currentLocale,
@@ -659,28 +658,11 @@ 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
- });
661
+ onLocaleChange?.(newLocale);
669
662
  },
670
- [
671
- currentLocale,
672
- loaderOptions,
673
- cookie,
674
- refetchMessages,
675
- importLoader,
676
- setLoadedMessages,
677
- setIsLoadingMessages
678
- ]
663
+ [currentLocale, loaderOptions, cookie, refetchMessages, onLocaleChange]
679
664
  );
680
- React10.useEffect(() => {
681
- void setLocale(initialLocale);
682
- }, []);
683
- const value = React10.useMemo(
665
+ const value = React6.useMemo(
684
666
  () => ({
685
667
  locale: currentLocale,
686
668
  setLocale
@@ -690,7 +672,7 @@ function LocaleProvider({
690
672
  return /* @__PURE__ */ jsx(LocaleContext.Provider, { value, children });
691
673
  }
692
674
  function useLocale() {
693
- const context = React10.useContext(LocaleContext);
675
+ const context = React6.useContext(LocaleContext);
694
676
  if (!context)
695
677
  throw new Error("useLocale must be used within a LocaleProvider");
696
678
  return context;
@@ -855,7 +837,7 @@ var redirect = async ({
855
837
  });
856
838
  redirect$1(localePrefixedPathname, type);
857
839
  };
858
- var TranslateHandlersContext = React10.createContext(void 0);
840
+ var TranslateHandlersContext = React6.createContext(void 0);
859
841
  var TranslateHandlersProvider = ({
860
842
  children,
861
843
  handlers
@@ -864,19 +846,19 @@ var TranslateHandlersProvider = ({
864
846
  return /* @__PURE__ */ jsx(TranslateHandlersContext.Provider, { value, children });
865
847
  };
866
848
  function useTranslateHandlers() {
867
- const context = React10.useContext(TranslateHandlersContext);
849
+ const context = React6.useContext(TranslateHandlersContext);
868
850
  return context;
869
851
  }
870
852
  var useInitLoadingState = (config) => {
871
853
  const lazyLoad = !!config.loader?.lazyLoad;
872
- const [isCsr, setIsCsr] = React10.useState(false);
873
- React10.useEffect(() => {
854
+ const [isCsr, setIsCsr] = React6.useState(false);
855
+ React6.useEffect(() => {
874
856
  setIsCsr(true);
875
857
  }, []);
876
858
  const isBeforeCSRLoading = lazyLoad && !isCsr;
877
859
  return isBeforeCSRLoading;
878
860
  };
879
- var TranslatorContext = React10.createContext(void 0);
861
+ var TranslatorContext = React6.createContext(void 0);
880
862
  var EMPTY_OBJECT = Object.freeze({});
881
863
  function TranslatorProvider({ children }) {
882
864
  const { config } = useConfig();
@@ -885,7 +867,7 @@ function TranslatorProvider({ children }) {
885
867
  const translatorHandlers = useTranslateHandlers();
886
868
  const { fallbackLocales, translator: translatorOptions } = config;
887
869
  const isBeforeCSRLoading = useInitLoadingState(config);
888
- const value = React10.useMemo(() => {
870
+ const value = React6.useMemo(() => {
889
871
  const translator = new Translator({
890
872
  messages: messages || EMPTY_OBJECT,
891
873
  locale,
@@ -909,7 +891,7 @@ function TranslatorProvider({ children }) {
909
891
  return /* @__PURE__ */ jsx(TranslatorContext.Provider, { value, children });
910
892
  }
911
893
  function useTranslator() {
912
- const context = React10.useContext(TranslatorContext);
894
+ const context = React6.useContext(TranslatorContext);
913
895
  if (!context)
914
896
  throw new Error(
915
897
  "useTranslator must be used within IntorTranslatorProvider"
@@ -922,11 +904,11 @@ var IntorProvider = ({
922
904
  pathname = "",
923
905
  initialLocale,
924
906
  messages = config.messages,
925
- importLoader
907
+ onLocaleChange
926
908
  },
927
909
  children
928
910
  }) => {
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 }) }) }) });
911
+ return /* @__PURE__ */ jsx(ConfigProvider, { value: { config, pathname }, children: /* @__PURE__ */ jsx(MessagesProvider, { value: { messages }, children: /* @__PURE__ */ jsx(LocaleProvider, { value: { initialLocale, onLocaleChange }, children: /* @__PURE__ */ jsx(TranslatorProvider, { children }) }) }) });
930
912
  };
931
913
 
932
914
  // src/client/react/hooks/use-translator.ts