intor 2.2.1 → 2.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,7 @@
1
- import * as React7 from 'react';
1
+ import * as React6 from 'react';
2
2
  import { logry } from 'logry';
3
3
  import Keyv from 'keyv';
4
+ import merge from 'lodash.merge';
4
5
  import { Translator } from 'intor-translator';
5
6
  import { formatUrl } from 'next/dist/shared/lib/router/utils/format-url';
6
7
  import NextLink from 'next/link';
@@ -8,21 +9,21 @@ import { usePathname as usePathname$1, useRouter as useRouter$1, redirect as red
8
9
  import { cookies, headers } from 'next/headers';
9
10
 
10
11
  // src/adapters/next/contexts/intor-provider/intor-provider.tsx
11
- var ConfigContext = React7.createContext(void 0);
12
+ var ConfigContext = React6.createContext(void 0);
13
+
14
+ // src/adapters/next/contexts/config/provider.tsx
12
15
  function ConfigProvider({
13
16
  value: { config, pathname },
14
17
  children
15
18
  }) {
16
- const value = React7.useMemo(() => ({ config, pathname }), [config, pathname]);
17
- return /* @__PURE__ */ React7.createElement(ConfigContext.Provider, { value }, children);
19
+ const value = React6.useMemo(() => ({ config, pathname }), [config, pathname]);
20
+ return /* @__PURE__ */ React6.createElement(ConfigContext.Provider, { value }, children);
18
21
  }
19
22
  function useConfig() {
20
- const context = React7.useContext(ConfigContext);
23
+ const context = React6.useContext(ConfigContext);
21
24
  if (!context) throw new Error("useConfig must be used within ConfigProvider");
22
25
  return context;
23
26
  }
24
- var LocaleContext = React7.createContext(void 0);
25
- var MessagesContext = React7.createContext(void 0);
26
27
 
27
28
  // src/modules/config/constants/cache.constants.ts
28
29
  var DEFAULT_CACHE_OPTIONS = {
@@ -44,17 +45,18 @@ var DEFAULT_FORMATTER_CONFIG = {
44
45
  node: { meta: { compact: true }, lineBreaksAfter: 1 }
45
46
  };
46
47
  function getLogger({
47
- id,
48
+ id = "default",
48
49
  formatterConfig,
49
50
  preset,
50
51
  ...options
51
52
  }) {
52
53
  const pool = getGlobalLoggerPool();
53
54
  let logger = pool.get(id);
55
+ const useDefault = !formatterConfig && !preset;
54
56
  if (!logger) {
55
57
  logger = logry({
56
58
  id,
57
- formatterConfig: !formatterConfig && !preset ? DEFAULT_FORMATTER_CONFIG : formatterConfig,
59
+ formatterConfig: useDefault ? DEFAULT_FORMATTER_CONFIG : formatterConfig,
58
60
  preset,
59
61
  ...options
60
62
  });
@@ -66,28 +68,36 @@ function getLogger({
66
68
  }
67
69
  return logger;
68
70
  }
71
+
72
+ // src/modules/messages/shared/utils/is-valid-messages.ts
73
+ function isPlainObject(value) {
74
+ return typeof value === "object" && value !== null && !Array.isArray(value);
75
+ }
76
+ function isValidMessages(value) {
77
+ if (!isPlainObject(value)) return false;
78
+ const stack = [value];
79
+ while (stack.length > 0) {
80
+ const current = stack.pop();
81
+ for (const v of Object.values(current)) {
82
+ if (typeof v === "string") continue;
83
+ if (isPlainObject(v)) {
84
+ stack.push(v);
85
+ } else {
86
+ return false;
87
+ }
88
+ }
89
+ }
90
+ return true;
91
+ }
69
92
  function getGlobalMessagesPool() {
70
93
  if (!globalThis.__INTOR_MESSAGES_POOL__) {
71
94
  globalThis.__INTOR_MESSAGES_POOL__ = new Keyv();
72
95
  }
73
96
  return globalThis.__INTOR_MESSAGES_POOL__;
74
97
  }
75
-
76
- // src/shared/utils/merge-messages.ts
77
98
  var mergeMessages = (staticMessages = {}, loadedMessages = {}) => {
78
- const result = Object.keys(staticMessages).length > 0 ? { ...staticMessages } : {};
79
- for (const locale in loadedMessages) {
80
- const loaded = loadedMessages[locale];
81
- if (!result[locale]) {
82
- result[locale] = loaded;
83
- continue;
84
- }
85
- result[locale] = {
86
- ...result[locale],
87
- ...loaded
88
- };
89
- }
90
- return result;
99
+ if (!loadedMessages) return { ...staticMessages };
100
+ return merge({}, staticMessages, loadedMessages);
91
101
  };
92
102
 
93
103
  // src/shared/utils/normalize-cache-key.ts
@@ -119,6 +129,8 @@ var resolveNamespaces = ({
119
129
  }) => {
120
130
  const { loader } = config;
121
131
  const { routeNamespaces = {}, namespaces } = loader || {};
132
+ if (Object.keys(routeNamespaces).length === 0 && !namespaces)
133
+ return void 0;
122
134
  const standardizedPathname = standardizePathname({ config, pathname });
123
135
  const placeholderRemovedPathname = standardizedPathname.replace(
124
136
  `/${PREFIX_PLACEHOLDER}`,
@@ -274,23 +286,23 @@ var standardizePathname = ({
274
286
  return normalizePathname(standardizedPathname);
275
287
  };
276
288
 
277
- // src/modules/messages/load-api-messages/fetch-messages.ts
278
- var fetchMessages = async ({
279
- apiUrl,
280
- apiHeaders,
281
- locale,
289
+ // src/modules/messages/load-remote-messages/fetch-locale-messages/fetch-locale-messages.ts
290
+ var fetchLocaleMessages = async ({
291
+ remoteUrl,
292
+ remoteHeaders,
282
293
  searchParams,
283
- logger: loggerOptions = { id: "default" }
294
+ locale,
295
+ extraOptions: { loggerOptions } = {}
284
296
  }) => {
285
297
  const baseLogger = getLogger({ ...loggerOptions });
286
- const logger = baseLogger.child({ scope: "fetch-messages" });
298
+ const logger = baseLogger.child({ scope: "fetch-locale-messages" });
287
299
  try {
288
300
  const params = new URLSearchParams(searchParams);
289
301
  params.append("locale", locale);
290
- const url = `${apiUrl}?${params.toString()}`;
302
+ const url = `${remoteUrl}?${params.toString()}`;
291
303
  const headers2 = {
292
304
  "Content-Type": "application/json",
293
- ...apiHeaders
305
+ ...remoteHeaders
294
306
  };
295
307
  const response = await fetch(url, {
296
308
  method: "GET",
@@ -298,17 +310,17 @@ var fetchMessages = async ({
298
310
  cache: "no-store"
299
311
  });
300
312
  if (!response.ok) {
301
- throw new Error(`Fetch failed: ${locale} (${response.status})`);
313
+ throw new Error(`HTTP error ${response.status} ${response.statusText}`);
302
314
  }
303
315
  const data = await response.json();
304
- if (data == null || typeof data === "object" && Object.keys(data).length === 0) {
305
- throw new Error(`Invalid messages: ${locale}`);
316
+ if (!isValidMessages(data[locale])) {
317
+ throw new Error("JSON file does not match NamespaceMessages structure");
306
318
  }
307
319
  return data;
308
320
  } catch (error) {
309
- logger.warn(`Failed to fetch messages for locale "${locale}".`, {
321
+ logger.warn("Fetching locale messages failed.", {
310
322
  locale,
311
- apiUrl,
323
+ remoteUrl,
312
324
  searchParams: decodeURIComponent(searchParams.toString()),
313
325
  error
314
326
  });
@@ -316,30 +328,7 @@ var fetchMessages = async ({
316
328
  }
317
329
  };
318
330
 
319
- // src/modules/messages/load-api-messages/fetch-fallback-messages.ts
320
- var fetchFallbackMessages = async ({
321
- apiUrl,
322
- apiHeaders,
323
- searchParams,
324
- fallbackLocales,
325
- logger
326
- }) => {
327
- for (const fallbackLocale of fallbackLocales) {
328
- const result = await fetchMessages({
329
- apiUrl,
330
- searchParams,
331
- locale: fallbackLocale,
332
- apiHeaders,
333
- logger
334
- });
335
- if (result) {
336
- return { locale: fallbackLocale, messages: result };
337
- }
338
- }
339
- return;
340
- };
341
-
342
- // src/modules/messages/load-api-messages/utils/build-search-params.ts
331
+ // src/modules/messages/load-remote-messages/fetch-locale-messages/utils/build-search-params.ts
343
332
  var buildSearchParams = (params) => {
344
333
  const searchParams = new URLSearchParams();
345
334
  const appendParam = (key, value) => {
@@ -357,78 +346,72 @@ var buildSearchParams = (params) => {
357
346
  return searchParams;
358
347
  };
359
348
 
360
- // src/modules/messages/load-api-messages/load-api-messages.ts
361
- var loadApiMessages = async ({
362
- apiUrl,
363
- apiHeaders,
364
- basePath,
349
+ // src/modules/messages/load-remote-messages/load-remote-messages.ts
350
+ var loadRemoteMessages = async ({
351
+ pool = getGlobalMessagesPool(),
352
+ rootDir,
353
+ remoteUrl,
354
+ remoteHeaders,
365
355
  locale,
366
356
  fallbackLocales = [],
367
357
  namespaces = [],
368
- cache = DEFAULT_CACHE_OPTIONS,
369
- logger: loggerOptions = { id: "default" }
358
+ extraOptions: {
359
+ cacheOptions = DEFAULT_CACHE_OPTIONS,
360
+ loggerOptions = { id: "default" }
361
+ } = {}
370
362
  }) => {
371
363
  const baseLogger = getLogger({ ...loggerOptions });
372
- const logger = baseLogger.child({ scope: "load-api-messages" });
373
- if (!apiUrl) {
374
- logger.warn("No apiUrl provided. Skipping fetch.");
375
- return;
376
- }
377
- let pool;
378
- if (cache.enabled) {
379
- pool = getGlobalMessagesPool();
380
- }
364
+ const logger = baseLogger.child({ scope: "load-remote-messages" });
365
+ const start = performance.now();
366
+ logger.debug("Loading remote messages from api.", { remoteUrl });
381
367
  const key = normalizeCacheKey([
382
368
  loggerOptions.id,
383
- basePath,
369
+ "loaderType:remote",
370
+ rootDir,
384
371
  locale,
385
372
  (fallbackLocales ?? []).toSorted().join(","),
386
373
  (namespaces ?? []).toSorted().join(",")
387
374
  ]);
388
- if (cache.enabled && key) {
375
+ if (cacheOptions.enabled && key) {
389
376
  const cached = await pool?.get(key);
390
377
  if (cached) {
391
378
  logger.debug("Messages cache hit.", { key });
392
379
  return cached;
393
380
  }
394
381
  }
395
- const searchParams = buildSearchParams({ basePath, namespaces });
396
- const messages = await fetchMessages({
397
- apiUrl,
398
- apiHeaders,
399
- searchParams,
400
- locale,
401
- logger: loggerOptions
402
- });
403
- if (messages) {
404
- if (cache.enabled && key) {
405
- await pool?.set(key, messages, cache.ttl);
382
+ const searchParams = buildSearchParams({ rootDir, namespaces });
383
+ const candidateLocales = [locale, ...fallbackLocales || []];
384
+ let messages;
385
+ for (const candidateLocale of candidateLocales) {
386
+ try {
387
+ const result = await fetchLocaleMessages({
388
+ remoteUrl,
389
+ remoteHeaders,
390
+ searchParams,
391
+ locale: candidateLocale,
392
+ extraOptions: { loggerOptions }
393
+ });
394
+ if (result && Object.values(result[candidateLocale] || {}).length > 0) {
395
+ messages = result;
396
+ break;
397
+ }
398
+ } catch (error) {
399
+ logger.error("Failed to fetch locale messages.", {
400
+ locale: candidateLocale,
401
+ error
402
+ });
406
403
  }
407
- return messages;
408
404
  }
409
- const fallbackResult = await fetchFallbackMessages({
410
- apiUrl,
411
- apiHeaders,
412
- searchParams,
413
- fallbackLocales,
414
- logger: loggerOptions
415
- });
416
- if (fallbackResult) {
417
- logger.info("Fallback locale succeeded.", {
418
- usedLocale: fallbackResult.locale,
419
- apiUrl,
420
- searchParams: decodeURIComponent(searchParams.toString())
421
- });
422
- if (cache.enabled && key) {
423
- await pool?.set(key, fallbackResult.messages, cache.ttl);
424
- }
425
- return fallbackResult.messages;
405
+ if (cacheOptions.enabled && key && messages) {
406
+ await pool?.set(key, messages, cacheOptions.ttl);
426
407
  }
427
- logger.warn("Failed to fetch messages for all locales.", {
428
- locale,
429
- fallbackLocales
408
+ const end = performance.now();
409
+ const duration = Math.round(end - start);
410
+ logger.trace("Finished loading remote messages.", {
411
+ loadedLocale: messages ? Object.keys(messages)[0] : void 0,
412
+ duration: `${duration} ms`
430
413
  });
431
- return;
414
+ return messages;
432
415
  };
433
416
 
434
417
  // src/adapters/next/contexts/messages/utils/use-refetch-messages.ts
@@ -439,20 +422,25 @@ var useRefetchMessages = ({
439
422
  setIsLoadingMessages
440
423
  }) => {
441
424
  const { messages: staticMessages } = config;
442
- const namespaces = React7.useMemo(() => {
425
+ const namespaces = React6.useMemo(() => {
443
426
  if (!config.loader) return [];
444
427
  return resolveNamespaces({ config, pathname });
445
428
  }, [config, pathname]);
446
- const refetchMessages = React7.useCallback(
429
+ const refetchMessages = React6.useCallback(
447
430
  async (newLocale) => {
448
- if (config.loader?.type === "api") {
431
+ if (config.loader?.type === "remote") {
449
432
  setIsLoadingMessages(true);
450
- const loadedMessages = await loadApiMessages({
451
- ...config.loader,
433
+ const loadedMessages = await loadRemoteMessages({
434
+ rootDir: config.loader.rootDir,
435
+ remoteUrl: config.loader.remoteUrl,
436
+ remoteHeaders: config.loader.remoteHeaders,
452
437
  locale: newLocale,
453
438
  fallbackLocales: config.fallbackLocales[newLocale] || [],
454
439
  namespaces,
455
- logger: { id: config.id }
440
+ extraOptions: {
441
+ cacheOptions: config.cache,
442
+ loggerOptions: { id: config.id }
443
+ }
456
444
  });
457
445
  const messages = mergeMessages(staticMessages, loadedMessages);
458
446
  setLoadedMessages(messages);
@@ -471,6 +459,7 @@ var useRefetchMessages = ({
471
459
  );
472
460
  return { refetchMessages };
473
461
  };
462
+ var MessagesContext = React6.createContext(void 0);
474
463
 
475
464
  // src/adapters/next/contexts/messages/provider.tsx
476
465
  function MessagesProvider({
@@ -478,15 +467,15 @@ function MessagesProvider({
478
467
  children
479
468
  }) {
480
469
  const { config, pathname } = useConfig();
481
- const [loadedMessages, setLoadedMessages] = React7.useState(null);
482
- const [isLoadingMessages, setIsLoadingMessages] = React7.useState(false);
470
+ const [loadedMessages, setLoadedMessages] = React6.useState(null);
471
+ const [isLoadingMessages, setIsLoadingMessages] = React6.useState(false);
483
472
  const { refetchMessages } = useRefetchMessages({
484
473
  config,
485
474
  pathname,
486
475
  setLoadedMessages,
487
476
  setIsLoadingMessages
488
477
  });
489
- const value = React7.useMemo(
478
+ const value = React6.useMemo(
490
479
  () => ({
491
480
  messages: loadedMessages || messages,
492
481
  isLoading: isLoadingMessages,
@@ -496,10 +485,10 @@ function MessagesProvider({
496
485
  }),
497
486
  [loadedMessages, messages, isLoadingMessages, refetchMessages]
498
487
  );
499
- return /* @__PURE__ */ React7.createElement(MessagesContext.Provider, { value }, children);
488
+ return /* @__PURE__ */ React6.createElement(MessagesContext.Provider, { value }, children);
500
489
  }
501
490
  function useMessages() {
502
- const context = React7.useContext(MessagesContext);
491
+ const context = React6.useContext(MessagesContext);
503
492
  if (!context)
504
493
  throw new Error("useMessages must be used within a MessagesProvider");
505
494
  return context;
@@ -512,8 +501,8 @@ var useInitLazyLoad = ({
512
501
  }) => {
513
502
  const { refetchMessages } = useMessages();
514
503
  const lazyLoad = !!loaderOptions?.lazyLoad;
515
- const isFirstLoadedRef = React7.useRef(false);
516
- React7.useEffect(() => {
504
+ const isFirstLoadedRef = React6.useRef(false);
505
+ React6.useEffect(() => {
517
506
  if (lazyLoad && !isFirstLoadedRef.current) {
518
507
  void refetchMessages(currentLocale);
519
508
  isFirstLoadedRef.current = true;
@@ -559,7 +548,7 @@ var useInitLocaleCookie = ({
559
548
  config,
560
549
  locale
561
550
  }) => {
562
- React7.useEffect(() => {
551
+ React6.useEffect(() => {
563
552
  if (typeof document === "undefined") return;
564
553
  const { cookie, routing } = config;
565
554
  const { firstVisit } = routing;
@@ -571,6 +560,7 @@ var useInitLocaleCookie = ({
571
560
  setLocaleCookieBrowser({ cookie, locale });
572
561
  }, []);
573
562
  };
563
+ var LocaleContext = React6.createContext(void 0);
574
564
 
575
565
  // src/adapters/next/contexts/locale/utils/change-locale.ts
576
566
  var changeLocale = ({
@@ -584,15 +574,15 @@ var changeLocale = ({
584
574
  if (typeof document === "undefined") return;
585
575
  const loaderType = loaderOptions?.type;
586
576
  if (newLocale === currentLocale) return;
587
- if (loaderType === "import") {
577
+ if (loaderType === "local") {
588
578
  console.warn(
589
- `[Intor] You are using dynamic import 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.`
579
+ `[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.`
590
580
  );
591
581
  }
592
582
  setLocale(newLocale);
593
583
  setLocaleCookieBrowser({ cookie, locale: newLocale });
594
584
  document.documentElement.lang = newLocale;
595
- if (loaderType === "api" && refetchMessages) {
585
+ if (loaderType === "remote" && refetchMessages) {
596
586
  void refetchMessages(newLocale);
597
587
  }
598
588
  };
@@ -605,10 +595,10 @@ function LocaleProvider({
605
595
  const { config } = useConfig();
606
596
  const { refetchMessages } = useMessages();
607
597
  const { loader: loaderOptions, cookie } = config;
608
- const [currentLocale, setCurrentLocale] = React7.useState(initialLocale);
598
+ const [currentLocale, setCurrentLocale] = React6.useState(initialLocale);
609
599
  useInitLazyLoad({ loaderOptions, currentLocale });
610
600
  useInitLocaleCookie({ config, locale: initialLocale });
611
- const setLocale = React7.useCallback(
601
+ const setLocale = React6.useCallback(
612
602
  (newLocale) => {
613
603
  changeLocale({
614
604
  currentLocale,
@@ -621,43 +611,45 @@ function LocaleProvider({
621
611
  },
622
612
  [currentLocale, loaderOptions, cookie, refetchMessages]
623
613
  );
624
- const value = React7.useMemo(
614
+ const value = React6.useMemo(
625
615
  () => ({
626
616
  locale: currentLocale,
627
617
  setLocale
628
618
  }),
629
619
  [currentLocale, setLocale]
630
620
  );
631
- return /* @__PURE__ */ React7.createElement(LocaleContext.Provider, { value }, children);
621
+ return /* @__PURE__ */ React6.createElement(LocaleContext.Provider, { value }, children);
632
622
  }
633
623
  function useLocale() {
634
- const context = React7.useContext(LocaleContext);
624
+ const context = React6.useContext(LocaleContext);
635
625
  if (!context)
636
626
  throw new Error("useLocale must be used within a LocaleProvider");
637
627
  return context;
638
628
  }
639
- var TranslatorContext = React7.createContext(void 0);
640
- var TranslateHandlersContext = React7.createContext(void 0);
629
+ var TranslateHandlersContext = React6.createContext(void 0);
630
+
631
+ // src/adapters/next/contexts/translate-handlers/provider.tsx
641
632
  var TranslateHandlersProvider = ({
642
633
  children,
643
634
  handlers
644
635
  }) => {
645
636
  const value = handlers;
646
- return /* @__PURE__ */ React7.createElement(TranslateHandlersContext.Provider, { value }, children);
637
+ return /* @__PURE__ */ React6.createElement(TranslateHandlersContext.Provider, { value }, children);
647
638
  };
648
639
  function useTranslateHandlers() {
649
- const context = React7.useContext(TranslateHandlersContext);
640
+ const context = React6.useContext(TranslateHandlersContext);
650
641
  return context;
651
642
  }
652
643
  var useInitLoadingState = (config) => {
653
644
  const lazyLoad = !!config.loader?.lazyLoad;
654
- const [isCsr, setIsCsr] = React7.useState(false);
655
- React7.useEffect(() => {
645
+ const [isCsr, setIsCsr] = React6.useState(false);
646
+ React6.useEffect(() => {
656
647
  setIsCsr(true);
657
648
  }, []);
658
649
  const isBeforeCSRLoading = lazyLoad && !isCsr;
659
650
  return isBeforeCSRLoading;
660
651
  };
652
+ var TranslatorContext = React6.createContext(void 0);
661
653
 
662
654
  // src/adapters/next/contexts/translator/provider.tsx
663
655
  var EMPTY_OBJECT = Object.freeze({});
@@ -668,7 +660,7 @@ function TranslatorProvider({ children }) {
668
660
  const translatorHandlers = useTranslateHandlers();
669
661
  const { fallbackLocales, translator: translatorOptions } = config;
670
662
  const isBeforeCSRLoading = useInitLoadingState(config);
671
- const value = React7.useMemo(() => {
663
+ const value = React6.useMemo(() => {
672
664
  const translator = new Translator({
673
665
  messages: messages || EMPTY_OBJECT,
674
666
  locale,
@@ -689,10 +681,10 @@ function TranslatorProvider({ children }) {
689
681
  translatorOptions?.loadingMessage,
690
682
  translatorOptions?.placeholder
691
683
  ]);
692
- return /* @__PURE__ */ React7.createElement(TranslatorContext.Provider, { value }, children);
684
+ return /* @__PURE__ */ React6.createElement(TranslatorContext.Provider, { value }, children);
693
685
  }
694
686
  function useTranslator() {
695
- const context = React7.useContext(TranslatorContext);
687
+ const context = React6.useContext(TranslatorContext);
696
688
  if (!context)
697
689
  throw new Error(
698
690
  "useTranslator must be used within IntorTranslatorProvider"
@@ -705,7 +697,7 @@ var IntorProvider = ({
705
697
  value: { config, pathname, initialLocale, messages },
706
698
  children
707
699
  }) => {
708
- return /* @__PURE__ */ React7.createElement(ConfigProvider, { value: { config, pathname } }, /* @__PURE__ */ React7.createElement(MessagesProvider, { value: { messages } }, /* @__PURE__ */ React7.createElement(LocaleProvider, { value: { initialLocale } }, /* @__PURE__ */ React7.createElement(TranslatorProvider, null, children))));
700
+ return /* @__PURE__ */ React6.createElement(ConfigProvider, { value: { config, pathname } }, /* @__PURE__ */ React6.createElement(MessagesProvider, { value: { messages } }, /* @__PURE__ */ React6.createElement(LocaleProvider, { value: { initialLocale } }, /* @__PURE__ */ React6.createElement(TranslatorProvider, null, children))));
709
701
  };
710
702
 
711
703
  // src/adapters/next/hooks/use-translator/use-translator.ts
@@ -802,7 +794,7 @@ var shouldFullReload = ({
802
794
  }) => {
803
795
  const loader = config.loader;
804
796
  if (!loader || !loader.type) return false;
805
- if (loader.type === "api" && !loader.fullReload) return false;
797
+ if (loader.type === "remote" && !loader.fullReload) return false;
806
798
  const { maybeLocale, isLocalePrefixed } = extractPathname({
807
799
  config,
808
800
  pathname: targetPathname
@@ -864,7 +856,7 @@ var Link = ({
864
856
  onClick?.(e);
865
857
  switchLocale({ href: formatted, locale });
866
858
  };
867
- return /* @__PURE__ */ React7.createElement(NextLink, { href: resolvedHref, onClick: handleClick, ...props }, children);
859
+ return /* @__PURE__ */ React6.createElement(NextLink, { href: resolvedHref, onClick: handleClick, ...props }, children);
868
860
  };
869
861
  var useRouter = () => {
870
862
  const { push, replace, ...rest } = useRouter$1();
@@ -42,28 +42,28 @@ type RouteNamespaces = {
42
42
  [key: string]: string[];
43
43
  default: string[];
44
44
  };
45
- interface ApiHeaders {
45
+ interface RemoteHeaders {
46
46
  authorization?: string;
47
47
  "x-api-key"?: string;
48
48
  [key: string]: string | undefined;
49
49
  }
50
50
  type BaseLoaderOptions = {
51
- basePath?: string;
51
+ rootDir?: string;
52
52
  namespaces?: string[];
53
53
  routeNamespaces?: RouteNamespaces;
54
54
  concurrency?: number;
55
55
  lazyLoad?: boolean;
56
56
  };
57
- type ImportLoader = BaseLoaderOptions & {
58
- type: "import";
57
+ type LocalLoader = BaseLoaderOptions & {
58
+ type: "local";
59
59
  };
60
- type ApiLoader = BaseLoaderOptions & {
61
- type: "api";
62
- apiUrl: string;
63
- apiHeaders?: ApiHeaders;
60
+ type RemoteLoader = BaseLoaderOptions & {
61
+ type: "remote";
62
+ remoteUrl: string;
63
+ remoteHeaders?: RemoteHeaders;
64
64
  fullReload?: boolean;
65
65
  };
66
- type LoaderOptions = ImportLoader | ApiLoader;
66
+ type LoaderOptions = LocalLoader | RemoteLoader;
67
67
 
68
68
  type LoggerOptions = {
69
69
  level?: Level;
@@ -42,28 +42,28 @@ type RouteNamespaces = {
42
42
  [key: string]: string[];
43
43
  default: string[];
44
44
  };
45
- interface ApiHeaders {
45
+ interface RemoteHeaders {
46
46
  authorization?: string;
47
47
  "x-api-key"?: string;
48
48
  [key: string]: string | undefined;
49
49
  }
50
50
  type BaseLoaderOptions = {
51
- basePath?: string;
51
+ rootDir?: string;
52
52
  namespaces?: string[];
53
53
  routeNamespaces?: RouteNamespaces;
54
54
  concurrency?: number;
55
55
  lazyLoad?: boolean;
56
56
  };
57
- type ImportLoader = BaseLoaderOptions & {
58
- type: "import";
57
+ type LocalLoader = BaseLoaderOptions & {
58
+ type: "local";
59
59
  };
60
- type ApiLoader = BaseLoaderOptions & {
61
- type: "api";
62
- apiUrl: string;
63
- apiHeaders?: ApiHeaders;
60
+ type RemoteLoader = BaseLoaderOptions & {
61
+ type: "remote";
62
+ remoteUrl: string;
63
+ remoteHeaders?: RemoteHeaders;
64
64
  fullReload?: boolean;
65
65
  };
66
- type LoaderOptions = ImportLoader | ApiLoader;
66
+ type LoaderOptions = LocalLoader | RemoteLoader;
67
67
 
68
68
  type LoggerOptions = {
69
69
  level?: Level;