intor 2.2.12 → 2.2.13

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.
@@ -17,7 +17,7 @@ var resolveCacheOptions = (cache) => {
17
17
 
18
18
  // src/config/constants/cookie.constants.ts
19
19
  var DEFAULT_COOKIE_OPTIONS = {
20
- disabled: false,
20
+ enabled: true,
21
21
  autoSetCookie: true,
22
22
  name: "intor.i18n.locale",
23
23
  domain: null,
@@ -2,8 +2,8 @@ import { Level, NormalizerConfig, FormatterConfig, LoggerPreset } from 'logry/ed
2
2
  import { Locale, LocaleMessages, FallbackLocalesMap } from 'intor-translator';
3
3
 
4
4
  type CookieRawOptions = {
5
- /** Completely disable cookie usage (no read, no write, no lookup by name) - default: false */
6
- disabled?: boolean;
5
+ /** Enable cookie usage (read/write) - default: true */
6
+ enabled?: boolean;
7
7
  /** Allow the system to automatically set cookies - default: true */
8
8
  autoSetCookie?: boolean;
9
9
  /** default: "intor.i18n.locale" */
@@ -51,7 +51,6 @@ type BaseLoaderOptions = {
51
51
  namespaces?: string[];
52
52
  routeNamespaces?: RouteNamespaces;
53
53
  concurrency?: number;
54
- lazyLoad?: boolean;
55
54
  };
56
55
  type LocalLoader = BaseLoaderOptions & {
57
56
  type: "local";
@@ -88,6 +87,7 @@ type RoutingRawOptions = {
88
87
  type RoutingResolvedOptions = Required<RoutingRawOptions>;
89
88
 
90
89
  type CacheRawOptions = {
90
+ /** default: process.env.NODE_ENV === "production" */
91
91
  enabled?: boolean;
92
92
  /** default: 60\*60\*1000 (1 hour) */
93
93
  ttl?: number;
@@ -2,8 +2,8 @@ import { Level, NormalizerConfig, FormatterConfig, LoggerPreset } from 'logry/ed
2
2
  import { Locale, LocaleMessages, FallbackLocalesMap } from 'intor-translator';
3
3
 
4
4
  type CookieRawOptions = {
5
- /** Completely disable cookie usage (no read, no write, no lookup by name) - default: false */
6
- disabled?: boolean;
5
+ /** Enable cookie usage (read/write) - default: true */
6
+ enabled?: boolean;
7
7
  /** Allow the system to automatically set cookies - default: true */
8
8
  autoSetCookie?: boolean;
9
9
  /** default: "intor.i18n.locale" */
@@ -51,7 +51,6 @@ type BaseLoaderOptions = {
51
51
  namespaces?: string[];
52
52
  routeNamespaces?: RouteNamespaces;
53
53
  concurrency?: number;
54
- lazyLoad?: boolean;
55
54
  };
56
55
  type LocalLoader = BaseLoaderOptions & {
57
56
  type: "local";
@@ -88,6 +87,7 @@ type RoutingRawOptions = {
88
87
  type RoutingResolvedOptions = Required<RoutingRawOptions>;
89
88
 
90
89
  type CacheRawOptions = {
90
+ /** default: process.env.NODE_ENV === "production" */
91
91
  enabled?: boolean;
92
92
  /** default: 60\*60\*1000 (1 hour) */
93
93
  ttl?: number;
@@ -15,7 +15,7 @@ var resolveCacheOptions = (cache) => {
15
15
 
16
16
  // src/config/constants/cookie.constants.ts
17
17
  var DEFAULT_COOKIE_OPTIONS = {
18
- disabled: false,
18
+ enabled: true,
19
19
  autoSetCookie: true,
20
20
  name: "intor.i18n.locale",
21
21
  domain: null,
package/dist/index.d.cts CHANGED
@@ -14,8 +14,8 @@ type RawCacheKey = string | boolean | Array<string | number | boolean | undefine
14
14
  declare const normalizeCacheKey: (key?: RawCacheKey, delimiter?: string) => string | null;
15
15
 
16
16
  type CookieRawOptions = {
17
- /** Completely disable cookie usage (no read, no write, no lookup by name) - default: false */
18
- disabled?: boolean;
17
+ /** Enable cookie usage (read/write) - default: true */
18
+ enabled?: boolean;
19
19
  /** Allow the system to automatically set cookies - default: true */
20
20
  autoSetCookie?: boolean;
21
21
  /** default: "intor.i18n.locale" */
@@ -63,7 +63,6 @@ type BaseLoaderOptions = {
63
63
  namespaces?: string[];
64
64
  routeNamespaces?: RouteNamespaces;
65
65
  concurrency?: number;
66
- lazyLoad?: boolean;
67
66
  };
68
67
  type LocalLoader = BaseLoaderOptions & {
69
68
  type: "local";
@@ -100,6 +99,7 @@ type RoutingRawOptions = {
100
99
  type RoutingResolvedOptions = Required<RoutingRawOptions>;
101
100
 
102
101
  type CacheRawOptions = {
102
+ /** default: process.env.NODE_ENV === "production" */
103
103
  enabled?: boolean;
104
104
  /** default: 60\*60\*1000 (1 hour) */
105
105
  ttl?: number;
package/dist/index.d.ts CHANGED
@@ -14,8 +14,8 @@ type RawCacheKey = string | boolean | Array<string | number | boolean | undefine
14
14
  declare const normalizeCacheKey: (key?: RawCacheKey, delimiter?: string) => string | null;
15
15
 
16
16
  type CookieRawOptions = {
17
- /** Completely disable cookie usage (no read, no write, no lookup by name) - default: false */
18
- disabled?: boolean;
17
+ /** Enable cookie usage (read/write) - default: true */
18
+ enabled?: boolean;
19
19
  /** Allow the system to automatically set cookies - default: true */
20
20
  autoSetCookie?: boolean;
21
21
  /** default: "intor.i18n.locale" */
@@ -63,7 +63,6 @@ type BaseLoaderOptions = {
63
63
  namespaces?: string[];
64
64
  routeNamespaces?: RouteNamespaces;
65
65
  concurrency?: number;
66
- lazyLoad?: boolean;
67
66
  };
68
67
  type LocalLoader = BaseLoaderOptions & {
69
68
  type: "local";
@@ -100,6 +99,7 @@ type RoutingRawOptions = {
100
99
  type RoutingResolvedOptions = Required<RoutingRawOptions>;
101
100
 
102
101
  type CacheRawOptions = {
102
+ /** default: process.env.NODE_ENV === "production" */
103
103
  enabled?: boolean;
104
104
  /** default: 60\*60\*1000 (1 hour) */
105
105
  ttl?: number;
@@ -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 React7 = 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 React7__namespace = /*#__PURE__*/_interopNamespace(React7);
36
36
  var merge__default = /*#__PURE__*/_interopDefault(merge);
37
37
  var Keyv__default = /*#__PURE__*/_interopDefault(Keyv);
38
38
 
@@ -281,20 +281,71 @@ var localizePathname = ({
281
281
  localePrefixedPathname
282
282
  };
283
283
  };
284
- var ConfigContext = React6__namespace.createContext(void 0);
284
+ var ConfigContext = React7__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 = React7__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 = React7__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/shared/utils/client/build-cookie-string.ts
299
+ var buildCookieString = (cookie, locale) => {
300
+ const parts = [`${cookie.name}=${encodeURIComponent(locale)}`];
301
+ if (cookie.maxAge) {
302
+ const expires = new Date(Date.now() + cookie.maxAge * 1e3).toUTCString();
303
+ parts.push(`expires=${expires}`, `max-age=${cookie.maxAge}`);
304
+ }
305
+ parts.push(`path=${cookie.path ?? "/"}`);
306
+ if (cookie.domain) {
307
+ parts.push(`domain=${cookie.domain}`);
308
+ }
309
+ if (cookie.sameSite) {
310
+ parts.push(
311
+ `SameSite=${cookie.sameSite[0].toUpperCase()}${cookie.sameSite.slice(1).toLowerCase()}`
312
+ );
313
+ }
314
+ if (cookie.secure !== false) {
315
+ parts.push(`Secure`);
316
+ }
317
+ return parts.join("; ");
318
+ };
319
+
320
+ // src/shared/utils/client/set-locale-cookie-browser.ts
321
+ var setLocaleCookieBrowser = ({
322
+ cookie,
323
+ locale
324
+ }) => {
325
+ if (typeof document === "undefined") return;
326
+ if (!cookie.enabled || !cookie.autoSetCookie) return;
327
+ const cookieString = buildCookieString(cookie, locale);
328
+ document.cookie = cookieString;
329
+ };
330
+
331
+ // src/client/react/contexts/locale/utils/use-init-locale-cookie.ts
332
+ var useInitLocaleCookie = ({
333
+ config,
334
+ locale
335
+ }) => {
336
+ React7__namespace.useEffect(() => {
337
+ if (typeof document === "undefined") return;
338
+ const { cookie, routing } = config;
339
+ const { firstVisit } = routing;
340
+ const cookies2 = document.cookie.split(";").map((c) => c.trim());
341
+ const isCookieExists = cookies2.some((c) => c.startsWith(`${cookie.name}=`));
342
+ if (isCookieExists) return;
343
+ if (!firstVisit.redirect) return;
344
+ if (!cookie.enabled || !cookie.autoSetCookie) return;
345
+ setLocaleCookieBrowser({ cookie, locale });
346
+ }, []);
347
+ };
348
+
298
349
  // src/config/constants/cache.constants.ts
299
350
  var DEFAULT_CACHE_OPTIONS = {
300
351
  enabled: process.env.NODE_ENV === "production",
@@ -502,19 +553,19 @@ var useRefetchMessages = ({
502
553
  setLoadedMessages,
503
554
  setIsLoadingMessages
504
555
  }) => {
505
- const { messages: staticMessages } = config;
506
- const namespaces = React6__namespace.useMemo(() => {
507
- if (!config.loader) return [];
556
+ const { messages: staticMessages, loader } = config;
557
+ const namespaces = React7__namespace.useMemo(() => {
558
+ if (!loader) return [];
508
559
  return resolveNamespaces({ config, pathname });
509
560
  }, [config, pathname]);
510
- const refetchMessages = React6__namespace.useCallback(
561
+ const refetchMessages = React7__namespace.useCallback(
511
562
  async (newLocale) => {
512
- if (config.loader?.type === "remote") {
563
+ if (loader?.type === "remote") {
513
564
  setIsLoadingMessages(true);
514
565
  const loadedMessages = await loadRemoteMessages({
515
- rootDir: config.loader.rootDir,
516
- remoteUrl: config.loader.remoteUrl,
517
- remoteHeaders: config.loader.remoteHeaders,
566
+ rootDir: loader.rootDir,
567
+ remoteUrl: loader.remoteUrl,
568
+ remoteHeaders: loader.remoteHeaders,
518
569
  locale: newLocale,
519
570
  fallbackLocales: config.fallbackLocales[newLocale] || [],
520
571
  namespaces,
@@ -529,8 +580,9 @@ var useRefetchMessages = ({
529
580
  }
530
581
  },
531
582
  [
532
- config.loader,
583
+ loader,
533
584
  config.fallbackLocales,
585
+ config.cache,
534
586
  config.id,
535
587
  setIsLoadingMessages,
536
588
  namespaces,
@@ -540,21 +592,21 @@ var useRefetchMessages = ({
540
592
  );
541
593
  return { refetchMessages };
542
594
  };
543
- var MessagesContext = React6__namespace.createContext(void 0);
595
+ var MessagesContext = React7__namespace.createContext(void 0);
544
596
  function MessagesProvider({
545
597
  value: { messages = {} },
546
598
  children
547
599
  }) {
548
600
  const { config, pathname } = useConfig();
549
- const [loadedMessages, setLoadedMessages] = React6__namespace.useState(null);
550
- const [isLoadingMessages, setIsLoadingMessages] = React6__namespace.useState(false);
601
+ const [loadedMessages, setLoadedMessages] = React7__namespace.useState(null);
602
+ const [isLoadingMessages, setIsLoadingMessages] = React7__namespace.useState(false);
551
603
  const { refetchMessages } = useRefetchMessages({
552
604
  config,
553
605
  pathname,
554
606
  setLoadedMessages,
555
607
  setIsLoadingMessages
556
608
  });
557
- const value = React6__namespace.useMemo(
609
+ const value = React7__namespace.useMemo(
558
610
  () => ({
559
611
  messages: loadedMessages || messages,
560
612
  isLoading: isLoadingMessages,
@@ -567,101 +619,34 @@ function MessagesProvider({
567
619
  return /* @__PURE__ */ jsxRuntime.jsx(MessagesContext.Provider, { value, children });
568
620
  }
569
621
  function useMessages() {
570
- const context = React6__namespace.useContext(MessagesContext);
622
+ const context = React7__namespace.useContext(MessagesContext);
571
623
  if (!context)
572
624
  throw new Error("useMessages must be used within a MessagesProvider");
573
625
  return context;
574
626
  }
575
-
576
- // src/client/react/contexts/locale/utils/use-init-lazy-load.ts
577
- var useInitLazyLoad = ({
578
- loaderOptions,
579
- currentLocale
580
- }) => {
581
- const { refetchMessages } = useMessages();
582
- const lazyLoad = !!loaderOptions?.lazyLoad;
583
- const isFirstLoadedRef = React6__namespace.useRef(false);
584
- React6__namespace.useEffect(() => {
585
- if (lazyLoad && !isFirstLoadedRef.current) {
586
- void refetchMessages(currentLocale);
587
- isFirstLoadedRef.current = true;
588
- }
589
- }, [lazyLoad, currentLocale, refetchMessages, isFirstLoadedRef]);
590
- };
591
-
592
- // src/shared/utils/client/build-cookie-string.ts
593
- var buildCookieString = (cookie, locale) => {
594
- const parts = [`${cookie.name}=${encodeURIComponent(locale)}`];
595
- if (cookie.maxAge) {
596
- const expires = new Date(Date.now() + cookie.maxAge * 1e3).toUTCString();
597
- parts.push(`expires=${expires}`, `max-age=${cookie.maxAge}`);
598
- }
599
- parts.push(`path=${cookie.path ?? "/"}`);
600
- if (cookie.domain) {
601
- parts.push(`domain=${cookie.domain}`);
602
- }
603
- if (cookie.sameSite) {
604
- parts.push(
605
- `SameSite=${cookie.sameSite[0].toUpperCase()}${cookie.sameSite.slice(1).toLowerCase()}`
606
- );
607
- }
608
- if (cookie.secure !== false) {
609
- parts.push(`Secure`);
610
- }
611
- return parts.join("; ");
612
- };
613
-
614
- // src/shared/utils/client/set-locale-cookie-browser.ts
615
- var setLocaleCookieBrowser = ({
616
- cookie,
617
- locale
618
- }) => {
619
- if (globalThis.window === void 0) return;
620
- if (cookie.disabled || !cookie.autoSetCookie) return;
621
- const cookieString = buildCookieString(cookie, locale);
622
- document.cookie = cookieString;
623
- };
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);
627
+ var LocaleContext = React7__namespace.createContext(void 0);
643
628
 
644
629
  // src/client/react/contexts/locale/utils/change-locale.ts
645
630
  var changeLocale = ({
646
631
  currentLocale,
647
632
  newLocale,
648
- loaderOptions,
633
+ loader,
649
634
  cookie,
650
635
  setLocale,
651
636
  refetchMessages
652
637
  }) => {
653
638
  if (typeof document === "undefined") return;
654
- const loaderType = loaderOptions?.type;
639
+ const { type } = loader || {};
655
640
  if (newLocale === currentLocale) return;
656
- if (loaderType === "local") {
641
+ if (type === "local") {
657
642
  console.warn(
658
- `[Intor] You are using dynamic local to switch languages. Please make sure to use the wrapped <Link> component to trigger a page reload, ensuring that the translation data is dynamically updated.`
643
+ `[Intor] You are using "loader type: local" to switch languages. Please make sure to use the wrapped <Link> component to trigger a page reload, ensuring that the translation data is dynamically updated.`
659
644
  );
660
645
  }
661
646
  setLocale(newLocale);
662
647
  setLocaleCookieBrowser({ cookie, locale: newLocale });
663
648
  document.documentElement.lang = newLocale;
664
- if (loaderType === "remote" && refetchMessages) {
649
+ if (type === "remote" && refetchMessages) {
665
650
  void refetchMessages(newLocale);
666
651
  }
667
652
  };
@@ -671,25 +656,24 @@ function LocaleProvider({
671
656
  }) {
672
657
  const { config } = useConfig();
673
658
  const { refetchMessages } = useMessages();
674
- const { loader: loaderOptions, cookie } = config;
675
- const [currentLocale, setCurrentLocale] = React6__namespace.useState(initialLocale);
676
- useInitLazyLoad({ loaderOptions, currentLocale });
659
+ const { loader, cookie } = config;
660
+ const [currentLocale, setCurrentLocale] = React7__namespace.useState(initialLocale);
677
661
  useInitLocaleCookie({ config, locale: initialLocale });
678
- const setLocale = React6__namespace.useCallback(
662
+ const setLocale = React7__namespace.useCallback(
679
663
  async (newLocale) => {
680
664
  changeLocale({
681
665
  currentLocale,
682
666
  newLocale,
683
- loaderOptions,
667
+ loader,
684
668
  cookie,
685
669
  setLocale: setCurrentLocale,
686
670
  refetchMessages
687
671
  });
688
672
  onLocaleChange?.(newLocale);
689
673
  },
690
- [currentLocale, loaderOptions, cookie, refetchMessages, onLocaleChange]
674
+ [currentLocale, loader, cookie, refetchMessages, onLocaleChange]
691
675
  );
692
- const value = React6__namespace.useMemo(
676
+ const value = React7__namespace.useMemo(
693
677
  () => ({
694
678
  locale: currentLocale,
695
679
  setLocale
@@ -699,7 +683,7 @@ function LocaleProvider({
699
683
  return /* @__PURE__ */ jsxRuntime.jsx(LocaleContext.Provider, { value, children });
700
684
  }
701
685
  function useLocale() {
702
- const context = React6__namespace.useContext(LocaleContext);
686
+ const context = React7__namespace.useContext(LocaleContext);
703
687
  if (!context)
704
688
  throw new Error("useLocale must be used within a LocaleProvider");
705
689
  return context;
@@ -822,7 +806,7 @@ var getI18nContext = async (config) => {
822
806
  const headersStore = await headers.headers();
823
807
  const { defaultLocale, supportedLocales = [], cookie, routing } = config;
824
808
  let locale;
825
- if (!cookie.disabled) {
809
+ if (cookie.enabled) {
826
810
  const localeFromCookie = cookiesStore.get(cookie.name)?.value;
827
811
  locale = normalizeLocale(localeFromCookie, supportedLocales);
828
812
  if (locale) {
@@ -864,61 +848,51 @@ var redirect = async ({
864
848
  });
865
849
  navigation.redirect(localePrefixedPathname, type);
866
850
  };
867
- var TranslateHandlersContext = React6__namespace.createContext(void 0);
851
+ var TranslateHandlersContext = React7__namespace.createContext(void 0);
868
852
  var TranslateHandlersProvider = ({
869
- children,
870
- handlers
853
+ handlers,
854
+ children
871
855
  }) => {
872
- const value = handlers;
873
- return /* @__PURE__ */ jsxRuntime.jsx(TranslateHandlersContext.Provider, { value, children });
856
+ return /* @__PURE__ */ jsxRuntime.jsx(TranslateHandlersContext.Provider, { value: { handlers }, children });
874
857
  };
875
858
  function useTranslateHandlers() {
876
- const context = React6__namespace.useContext(TranslateHandlersContext);
859
+ const context = React7__namespace.useContext(TranslateHandlersContext);
877
860
  return context;
878
861
  }
879
- var useInitLoadingState = (config) => {
880
- const lazyLoad = !!config.loader?.lazyLoad;
881
- const [isCsr, setIsCsr] = React6__namespace.useState(false);
882
- React6__namespace.useEffect(() => {
883
- setIsCsr(true);
884
- }, []);
885
- const isBeforeCSRLoading = lazyLoad && !isCsr;
886
- return isBeforeCSRLoading;
887
- };
888
- var TranslatorContext = React6__namespace.createContext(void 0);
889
- var EMPTY_OBJECT = Object.freeze({});
890
- function TranslatorProvider({ children }) {
862
+ var TranslatorContext = React7__namespace.createContext(void 0);
863
+ function TranslatorProvider({
864
+ value: { isLoading: externalIsLoading },
865
+ children
866
+ }) {
891
867
  const { config } = useConfig();
892
- const { messages, isLoading } = useMessages();
868
+ const { messages, isLoading: internalIsLoading } = useMessages();
893
869
  const { locale } = useLocale();
894
- const translatorHandlers = useTranslateHandlers();
870
+ const { handlers } = useTranslateHandlers();
895
871
  const { fallbackLocales, translator: translatorOptions } = config;
896
- const isBeforeCSRLoading = useInitLoadingState(config);
897
- const value = React6__namespace.useMemo(() => {
898
- const translator = new intorTranslator.Translator({
899
- messages: messages || EMPTY_OBJECT,
872
+ const isLoading = Boolean(externalIsLoading ?? internalIsLoading);
873
+ const translator = React7__namespace.useMemo(() => {
874
+ return new intorTranslator.Translator({
875
+ messages,
900
876
  locale,
877
+ isLoading,
901
878
  fallbackLocales,
902
879
  loadingMessage: translatorOptions?.loadingMessage,
903
880
  placeholder: translatorOptions?.placeholder,
904
- handlers: translatorHandlers
881
+ handlers
905
882
  });
906
- translator.setLoading(isBeforeCSRLoading || isLoading);
907
- return { translator };
908
883
  }, [
909
- fallbackLocales,
910
- isBeforeCSRLoading,
911
- isLoading,
912
- locale,
913
884
  messages,
914
- translatorHandlers,
885
+ locale,
886
+ isLoading,
887
+ fallbackLocales,
888
+ handlers,
915
889
  translatorOptions?.loadingMessage,
916
890
  translatorOptions?.placeholder
917
891
  ]);
918
- return /* @__PURE__ */ jsxRuntime.jsx(TranslatorContext.Provider, { value, children });
892
+ return /* @__PURE__ */ jsxRuntime.jsx(TranslatorContext.Provider, { value: { translator }, children });
919
893
  }
920
894
  function useTranslator() {
921
- const context = React6__namespace.useContext(TranslatorContext);
895
+ const context = React7__namespace.useContext(TranslatorContext);
922
896
  if (!context)
923
897
  throw new Error(
924
898
  "useTranslator must be used within IntorTranslatorProvider"
@@ -931,11 +905,12 @@ var IntorProvider = ({
931
905
  pathname = "",
932
906
  initialLocale,
933
907
  messages = config.messages,
934
- onLocaleChange
908
+ onLocaleChange,
909
+ isLoading
935
910
  },
936
911
  children
937
912
  }) => {
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 }) }) }) });
913
+ 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, { value: { isLoading }, children }) }) }) });
939
914
  };
940
915
 
941
916
  // src/client/react/hooks/use-translator.ts
@@ -88,8 +88,8 @@ declare const useRouter: () => {
88
88
  };
89
89
 
90
90
  type CookieRawOptions = {
91
- /** Completely disable cookie usage (no read, no write, no lookup by name) - default: false */
92
- disabled?: boolean;
91
+ /** Enable cookie usage (read/write) - default: true */
92
+ enabled?: boolean;
93
93
  /** Allow the system to automatically set cookies - default: true */
94
94
  autoSetCookie?: boolean;
95
95
  /** default: "intor.i18n.locale" */
@@ -137,7 +137,6 @@ type BaseLoaderOptions = {
137
137
  namespaces?: string[];
138
138
  routeNamespaces?: RouteNamespaces;
139
139
  concurrency?: number;
140
- lazyLoad?: boolean;
141
140
  };
142
141
  type LocalLoader = BaseLoaderOptions & {
143
142
  type: "local";
@@ -174,6 +173,7 @@ type RoutingRawOptions = {
174
173
  type RoutingResolvedOptions = Required<RoutingRawOptions>;
175
174
 
176
175
  type CacheRawOptions = {
176
+ /** default: process.env.NODE_ENV === "production" */
177
177
  enabled?: boolean;
178
178
  /** default: 60\*60\*1000 (1 hour) */
179
179
  ttl?: number;
@@ -224,18 +224,19 @@ interface IntorProviderProps {
224
224
  pathname?: string;
225
225
  messages?: Readonly<LocaleMessages>;
226
226
  onLocaleChange?: (newLocale: string) => Promise<void> | void;
227
+ isLoading?: boolean;
227
228
  };
228
229
  children: React.ReactNode;
229
230
  }
230
231
 
231
- declare const IntorProvider: ({ value: { config, pathname, initialLocale, messages, onLocaleChange, }, children, }: IntorProviderProps) => react_jsx_runtime.JSX.Element;
232
+ declare const IntorProvider: ({ value: { config, pathname, initialLocale, messages, onLocaleChange, isLoading, }, children, }: IntorProviderProps) => react_jsx_runtime.JSX.Element;
232
233
 
233
234
  type TranslateHandlersProviderProps = {
234
- children: React.ReactNode;
235
235
  handlers: TranslateHandlers;
236
+ children: React.ReactNode;
236
237
  };
237
238
 
238
- declare const TranslateHandlersProvider: ({ children, handlers, }: TranslateHandlersProviderProps) => react_jsx_runtime.JSX.Element;
239
+ declare const TranslateHandlersProvider: ({ handlers, children, }: TranslateHandlersProviderProps) => react_jsx_runtime.JSX.Element;
239
240
 
240
241
  /** Base properties shared by all translator instances. */
241
242
  interface TranslatorBaseProps<M = unknown> {
@@ -88,8 +88,8 @@ declare const useRouter: () => {
88
88
  };
89
89
 
90
90
  type CookieRawOptions = {
91
- /** Completely disable cookie usage (no read, no write, no lookup by name) - default: false */
92
- disabled?: boolean;
91
+ /** Enable cookie usage (read/write) - default: true */
92
+ enabled?: boolean;
93
93
  /** Allow the system to automatically set cookies - default: true */
94
94
  autoSetCookie?: boolean;
95
95
  /** default: "intor.i18n.locale" */
@@ -137,7 +137,6 @@ type BaseLoaderOptions = {
137
137
  namespaces?: string[];
138
138
  routeNamespaces?: RouteNamespaces;
139
139
  concurrency?: number;
140
- lazyLoad?: boolean;
141
140
  };
142
141
  type LocalLoader = BaseLoaderOptions & {
143
142
  type: "local";
@@ -174,6 +173,7 @@ type RoutingRawOptions = {
174
173
  type RoutingResolvedOptions = Required<RoutingRawOptions>;
175
174
 
176
175
  type CacheRawOptions = {
176
+ /** default: process.env.NODE_ENV === "production" */
177
177
  enabled?: boolean;
178
178
  /** default: 60\*60\*1000 (1 hour) */
179
179
  ttl?: number;
@@ -224,18 +224,19 @@ interface IntorProviderProps {
224
224
  pathname?: string;
225
225
  messages?: Readonly<LocaleMessages>;
226
226
  onLocaleChange?: (newLocale: string) => Promise<void> | void;
227
+ isLoading?: boolean;
227
228
  };
228
229
  children: React.ReactNode;
229
230
  }
230
231
 
231
- declare const IntorProvider: ({ value: { config, pathname, initialLocale, messages, onLocaleChange, }, children, }: IntorProviderProps) => react_jsx_runtime.JSX.Element;
232
+ declare const IntorProvider: ({ value: { config, pathname, initialLocale, messages, onLocaleChange, isLoading, }, children, }: IntorProviderProps) => react_jsx_runtime.JSX.Element;
232
233
 
233
234
  type TranslateHandlersProviderProps = {
234
- children: React.ReactNode;
235
235
  handlers: TranslateHandlers;
236
+ children: React.ReactNode;
236
237
  };
237
238
 
238
- declare const TranslateHandlersProvider: ({ children, handlers, }: TranslateHandlersProviderProps) => react_jsx_runtime.JSX.Element;
239
+ declare const TranslateHandlersProvider: ({ handlers, children, }: TranslateHandlersProviderProps) => react_jsx_runtime.JSX.Element;
239
240
 
240
241
  /** Base properties shared by all translator instances. */
241
242
  interface TranslatorBaseProps<M = unknown> {