intor 1.0.35 → 1.0.36

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,36 +1,19 @@
1
1
  'use strict';
2
2
 
3
- var logry = require('logry');
3
+ var edge = require('logry/edge');
4
4
 
5
- var __defProp = Object.defineProperty;
6
- var __defProps = Object.defineProperties;
7
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
8
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
- var __hasOwnProp = Object.prototype.hasOwnProperty;
10
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
- var __spreadValues = (a, b) => {
13
- for (var prop in b || (b = {}))
14
- if (__hasOwnProp.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- if (__getOwnPropSymbols)
17
- for (var prop of __getOwnPropSymbols(b)) {
18
- if (__propIsEnum.call(b, prop))
19
- __defNormalProp(a, prop, b[prop]);
20
- }
21
- return a;
22
- };
23
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
5
+ // src/modules/intor-config/initialize-logger.ts
24
6
  var initializeLogger = ({
25
7
  id,
26
8
  scope,
27
9
  loggerOptions
28
10
  }) => {
29
- const logger = logry.logry(__spreadValues({
11
+ const logger = edge.logry({
30
12
  id,
31
- level: loggerOptions == null ? void 0 : loggerOptions.level,
32
- scope
33
- }, loggerOptions));
13
+ level: loggerOptions?.level,
14
+ scope,
15
+ ...loggerOptions
16
+ });
34
17
  return logger;
35
18
  };
36
19
 
@@ -50,7 +33,10 @@ var DEFAULT_COOKIE_OPTIONS = {
50
33
 
51
34
  // src/modules/intor-config/resolvers/resolve-cookie-options.ts
52
35
  var resolveCookieOptions = (cookie = {}) => {
53
- return __spreadValues(__spreadValues({}, DEFAULT_COOKIE_OPTIONS), cookie);
36
+ return {
37
+ ...DEFAULT_COOKIE_OPTIONS,
38
+ ...cookie
39
+ };
54
40
  };
55
41
 
56
42
  // src/modules/intor-config/resolvers/resolve-fallback-locales.ts
@@ -96,7 +82,7 @@ var DEFAULT_PREFIX_PLACEHOLDER = "{{locale}}";
96
82
 
97
83
  // src/modules/intor-config/resolvers/resolve-prefix-placeholder.ts
98
84
  var resolvePrefixPlaceholder = (input) => {
99
- return (input == null ? void 0 : input.replace(/\//g, "")) || DEFAULT_PREFIX_PLACEHOLDER;
85
+ return input?.replace(/\//g, "") || DEFAULT_PREFIX_PLACEHOLDER;
100
86
  };
101
87
 
102
88
  // src/modules/intor-config/constants/routing-options-constants.ts
@@ -145,10 +131,15 @@ var normalizePathname = (rawPathname, options = {}) => {
145
131
 
146
132
  // src/modules/intor-config/resolvers/resolve-routing-options.ts
147
133
  var resolveRoutingOptions = (routing = {}) => {
148
- return __spreadProps(__spreadValues(__spreadValues({}, DEFAULT_ROUTING_OPTIONS), routing), {
149
- firstVisit: __spreadValues(__spreadValues({}, DEFAULT_ROUTING_OPTIONS.firstVisit), routing.firstVisit || {}),
150
- basePath: normalizePathname((routing == null ? void 0 : routing.basePath) || "")
151
- });
134
+ return {
135
+ ...DEFAULT_ROUTING_OPTIONS,
136
+ ...routing,
137
+ firstVisit: {
138
+ ...DEFAULT_ROUTING_OPTIONS.firstVisit,
139
+ ...routing.firstVisit || {}
140
+ },
141
+ basePath: normalizePathname(routing?.basePath || "")
142
+ };
152
143
  };
153
144
 
154
145
  // src/modules/intor-error/intor-error.ts
@@ -176,7 +167,7 @@ var validateDefaultLocale = ({
176
167
  message: `The defaultLocale is undefined`
177
168
  });
178
169
  }
179
- if (!(supportedLocales == null ? void 0 : supportedLocales.includes(defaultLocale))) {
170
+ if (!supportedLocales?.includes(defaultLocale)) {
180
171
  throw new IntorError({
181
172
  id,
182
173
  code: "INTOR_UNSUPPORTED_DEFAULT_LOCALE" /* UNSUPPORTED_DEFAULT_LOCALE */,
@@ -1,4 +1,4 @@
1
- import { Level, NormalizerConfig, FormatterConfig, LoggerPreset } from 'logry';
1
+ import { Level, NormalizerConfig, FormatterConfig, LoggerPreset } from 'logry/edge';
2
2
  import { Locale, LocaleNamespaceMessages, FallbackLocalesMap } from 'intor-translator';
3
3
 
4
4
  type InitCookieOptions = {
@@ -1,4 +1,4 @@
1
- import { Level, NormalizerConfig, FormatterConfig, LoggerPreset } from 'logry';
1
+ import { Level, NormalizerConfig, FormatterConfig, LoggerPreset } from 'logry/edge';
2
2
  import { Locale, LocaleNamespaceMessages, FallbackLocalesMap } from 'intor-translator';
3
3
 
4
4
  type InitCookieOptions = {
@@ -1,34 +1,17 @@
1
- import { logry } from 'logry';
1
+ import { logry } from 'logry/edge';
2
2
 
3
- var __defProp = Object.defineProperty;
4
- var __defProps = Object.defineProperties;
5
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
- var __spreadValues = (a, b) => {
11
- for (var prop in b || (b = {}))
12
- if (__hasOwnProp.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- if (__getOwnPropSymbols)
15
- for (var prop of __getOwnPropSymbols(b)) {
16
- if (__propIsEnum.call(b, prop))
17
- __defNormalProp(a, prop, b[prop]);
18
- }
19
- return a;
20
- };
21
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
3
+ // src/modules/intor-config/initialize-logger.ts
22
4
  var initializeLogger = ({
23
5
  id,
24
6
  scope,
25
7
  loggerOptions
26
8
  }) => {
27
- const logger = logry(__spreadValues({
9
+ const logger = logry({
28
10
  id,
29
- level: loggerOptions == null ? void 0 : loggerOptions.level,
30
- scope
31
- }, loggerOptions));
11
+ level: loggerOptions?.level,
12
+ scope,
13
+ ...loggerOptions
14
+ });
32
15
  return logger;
33
16
  };
34
17
 
@@ -48,7 +31,10 @@ var DEFAULT_COOKIE_OPTIONS = {
48
31
 
49
32
  // src/modules/intor-config/resolvers/resolve-cookie-options.ts
50
33
  var resolveCookieOptions = (cookie = {}) => {
51
- return __spreadValues(__spreadValues({}, DEFAULT_COOKIE_OPTIONS), cookie);
34
+ return {
35
+ ...DEFAULT_COOKIE_OPTIONS,
36
+ ...cookie
37
+ };
52
38
  };
53
39
 
54
40
  // src/modules/intor-config/resolvers/resolve-fallback-locales.ts
@@ -94,7 +80,7 @@ var DEFAULT_PREFIX_PLACEHOLDER = "{{locale}}";
94
80
 
95
81
  // src/modules/intor-config/resolvers/resolve-prefix-placeholder.ts
96
82
  var resolvePrefixPlaceholder = (input) => {
97
- return (input == null ? void 0 : input.replace(/\//g, "")) || DEFAULT_PREFIX_PLACEHOLDER;
83
+ return input?.replace(/\//g, "") || DEFAULT_PREFIX_PLACEHOLDER;
98
84
  };
99
85
 
100
86
  // src/modules/intor-config/constants/routing-options-constants.ts
@@ -143,10 +129,15 @@ var normalizePathname = (rawPathname, options = {}) => {
143
129
 
144
130
  // src/modules/intor-config/resolvers/resolve-routing-options.ts
145
131
  var resolveRoutingOptions = (routing = {}) => {
146
- return __spreadProps(__spreadValues(__spreadValues({}, DEFAULT_ROUTING_OPTIONS), routing), {
147
- firstVisit: __spreadValues(__spreadValues({}, DEFAULT_ROUTING_OPTIONS.firstVisit), routing.firstVisit || {}),
148
- basePath: normalizePathname((routing == null ? void 0 : routing.basePath) || "")
149
- });
132
+ return {
133
+ ...DEFAULT_ROUTING_OPTIONS,
134
+ ...routing,
135
+ firstVisit: {
136
+ ...DEFAULT_ROUTING_OPTIONS.firstVisit,
137
+ ...routing.firstVisit || {}
138
+ },
139
+ basePath: normalizePathname(routing?.basePath || "")
140
+ };
150
141
  };
151
142
 
152
143
  // src/modules/intor-error/intor-error.ts
@@ -174,7 +165,7 @@ var validateDefaultLocale = ({
174
165
  message: `The defaultLocale is undefined`
175
166
  });
176
167
  }
177
- if (!(supportedLocales == null ? void 0 : supportedLocales.includes(defaultLocale))) {
168
+ if (!supportedLocales?.includes(defaultLocale)) {
178
169
  throw new IntorError({
179
170
  id,
180
171
  code: "INTOR_UNSUPPORTED_DEFAULT_LOCALE" /* UNSUPPORTED_DEFAULT_LOCALE */,
package/dist/index.cjs CHANGED
@@ -14,25 +14,7 @@ var path__default = /*#__PURE__*/_interopDefault(path);
14
14
  var pLimit__default = /*#__PURE__*/_interopDefault(pLimit);
15
15
  var fs__default = /*#__PURE__*/_interopDefault(fs);
16
16
 
17
- var __defProp = Object.defineProperty;
18
- var __defProps = Object.defineProperties;
19
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
20
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
21
- var __hasOwnProp = Object.prototype.hasOwnProperty;
22
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
23
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
24
- var __spreadValues = (a, b) => {
25
- for (var prop in b || (b = {}))
26
- if (__hasOwnProp.call(b, prop))
27
- __defNormalProp(a, prop, b[prop]);
28
- if (__getOwnPropSymbols)
29
- for (var prop of __getOwnPropSymbols(b)) {
30
- if (__propIsEnum.call(b, prop))
31
- __defNormalProp(a, prop, b[prop]);
32
- }
33
- return a;
34
- };
35
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
17
+ // src/modules/intor/intor.ts
36
18
 
37
19
  // src/modules/intor-error/intor-error.ts
38
20
  var IntorError = class extends Error {
@@ -64,10 +46,9 @@ var DEFAULT_PATHNAME_HEADER_NAME = "x-intor-pathname";
64
46
  var normalizeLocale = (locale = "", supportedLocales = []) => {
65
47
  if (!locale || supportedLocales.length === 0) return void 0;
66
48
  const toCanonical = (input) => {
67
- var _a;
68
49
  try {
69
- return (_a = Intl.getCanonicalLocales(input)[0]) == null ? void 0 : _a.toLowerCase();
70
- } catch (e) {
50
+ return Intl.getCanonicalLocales(input)[0]?.toLowerCase();
51
+ } catch {
71
52
  return void 0;
72
53
  }
73
54
  };
@@ -95,19 +76,18 @@ var normalizeLocale = (locale = "", supportedLocales = []) => {
95
76
 
96
77
  // src/shared/utils/locale/resolve-preferred-locale.ts
97
78
  var resolvePreferredLocale = (acceptLanguageHeader, supportedLocales) => {
98
- var _a;
99
79
  if (!acceptLanguageHeader || !supportedLocales || supportedLocales.length === 0) {
100
80
  return;
101
81
  }
102
82
  const supportedLocalesSet = new Set(supportedLocales);
103
- const preferred = (_a = acceptLanguageHeader.split(",").map((part) => {
83
+ const preferred = acceptLanguageHeader.split(",").map((part) => {
104
84
  const [lang, qValue] = part.split(";");
105
85
  const q = qValue ? parseFloat(qValue.split("=")[1]) : 1;
106
86
  if (isNaN(q)) {
107
87
  return { lang: lang.trim(), q: 0 };
108
88
  }
109
89
  return { lang: lang.trim(), q };
110
- }).sort((a, b) => b.q - a.q).find(({ lang }) => supportedLocalesSet.has(lang))) == null ? void 0 : _a.lang;
90
+ }).sort((a, b) => b.q - a.q).find(({ lang }) => supportedLocalesSet.has(lang))?.lang;
111
91
  return preferred;
112
92
  };
113
93
 
@@ -115,14 +95,13 @@ var resolvePreferredLocale = (acceptLanguageHeader, supportedLocales) => {
115
95
  var nextClientRuntime = async ({
116
96
  config
117
97
  }) => {
118
- var _a;
119
98
  const cookiesStore = await headers.cookies();
120
99
  const headersStore = await headers.headers();
121
100
  const logger = logry.logry({ id: config.id, scope: "nextClientRuntime" });
122
101
  const { defaultLocale, supportedLocales = [], cookie, routing } = config;
123
102
  let locale;
124
103
  if (!cookie.disabled) {
125
- const localeFromCookie = (_a = cookiesStore.get(cookie.name)) == null ? void 0 : _a.value;
104
+ const localeFromCookie = cookiesStore.get(cookie.name)?.value;
126
105
  locale = normalizeLocale(localeFromCookie, supportedLocales);
127
106
  if (locale) {
128
107
  logger.debug("Get locale from cookie:", { locale });
@@ -147,14 +126,13 @@ var nextServerRuntime = async ({
147
126
  config,
148
127
  request
149
128
  }) => {
150
- var _a;
151
129
  const cookiesStore = await headers.cookies();
152
130
  const headersStore = await headers.headers();
153
131
  const logger = logry.logry({ id: config.id, scope: "nextServerRuntime" });
154
132
  const { defaultLocale, supportedLocales = [], cookie, routing } = config;
155
133
  let locale;
156
134
  if (!cookie.disabled) {
157
- const localeFromCookie = (_a = cookiesStore.get(cookie.name)) == null ? void 0 : _a.value;
135
+ const localeFromCookie = cookiesStore.get(cookie.name)?.value;
158
136
  locale = normalizeLocale(localeFromCookie, supportedLocales);
159
137
  if (locale) {
160
138
  logger.debug("Get locale from cookie:", { locale });
@@ -180,16 +158,16 @@ var nextServerRuntime = async ({
180
158
  }
181
159
  }
182
160
  if (!cookie.disabled && cookie.autoSetCookie) {
183
- cookiesStore.set(__spreadProps(__spreadValues({
161
+ cookiesStore.set({
184
162
  name: cookie.name,
185
- value: locale || defaultLocale
186
- }, cookie.domain ? { domain: cookie.domain } : {}), {
163
+ value: locale || defaultLocale,
164
+ ...cookie.domain ? { domain: cookie.domain } : {},
187
165
  path: cookie.path,
188
166
  maxAge: cookie.maxAge,
189
167
  httpOnly: cookie.httpOnly,
190
168
  secure: cookie.secure,
191
169
  sameSite: cookie.sameSite
192
- }));
170
+ });
193
171
  logger.debug("Set locale to cookie:", {
194
172
  cookie: { name: cookie.name, value: locale || defaultLocale }
195
173
  });
@@ -232,24 +210,24 @@ var parseMessageFile = async (filePath, loggerId) => {
232
210
  const logger = logry.logry({ id: loggerId, scope: "parseMessageFile" });
233
211
  const trimmedPath = filePath.trim();
234
212
  if (!trimmedPath) {
235
- logger == null ? void 0 : logger.warn("Invalid file path provided.", { filePath: trimmedPath });
213
+ logger?.warn("Invalid file path provided.", { filePath: trimmedPath });
236
214
  return null;
237
215
  }
238
216
  if (trimmedPath.length > MAX_PATH_LENGTH) {
239
- logger == null ? void 0 : logger.warn("Invalid file path provided.", { filePath: trimmedPath });
217
+ logger?.warn("Invalid file path provided.", { filePath: trimmedPath });
240
218
  return null;
241
219
  }
242
220
  const fileName = path__default.default.basename(trimmedPath);
243
221
  if (!fileName.toLowerCase().endsWith(".json")) {
244
- logger == null ? void 0 : logger.debug(`Skipped non-JSON file.`, { filePath: trimmedPath });
222
+ logger?.debug(`Skipped non-JSON file.`, { filePath: trimmedPath });
245
223
  return null;
246
224
  }
247
225
  try {
248
226
  const { content } = await readMessageRecordFile(trimmedPath);
249
- logger == null ? void 0 : logger.debug(`Loaded a file.`, { filePath: trimmedPath });
227
+ logger?.debug(`Loaded a file.`, { filePath: trimmedPath });
250
228
  return content;
251
229
  } catch (error) {
252
- logger == null ? void 0 : logger.warn(`Failed to load file.`, { filePath: trimmedPath, error });
230
+ logger?.warn(`Failed to load file.`, { filePath: trimmedPath, error });
253
231
  return null;
254
232
  }
255
233
  };
@@ -285,12 +263,10 @@ var loadNamespaceGroup = async ({
285
263
  limit,
286
264
  loggerId
287
265
  }) => {
288
- var _a;
289
266
  const logger = logry.logry({ id: loggerId, scope: "loadNamespaceGroup" });
290
267
  const { isAtRoot, filePaths } = namespaceGroupValue;
291
268
  if (filePaths.length === 0) {
292
- (_a = logger == null ? void 0 : logger.debug) == null ? void 0 : _a.call(
293
- logger,
269
+ logger?.debug?.(
294
270
  `Skipped merging [${locale}][${namespace}] because filePaths is empty`
295
271
  );
296
272
  return;
@@ -304,10 +280,10 @@ var loadNamespaceGroup = async ({
304
280
  if (!messages[locale]) {
305
281
  messages[locale] = {};
306
282
  }
307
- const finalContent = isAtRoot ? base : __spreadValues(__spreadValues({}, base), sub);
283
+ const finalContent = isAtRoot ? base : { ...base, ...sub };
308
284
  messages[locale][namespace] = finalContent;
309
285
  if (!isAtRoot && Object.keys(finalContent).length > 0) {
310
- logger == null ? void 0 : logger.debug(
286
+ logger?.debug(
311
287
  `Merged ${locale}/${namespace} from ${filePaths.length} file(s)`,
312
288
  { namespace }
313
289
  );
@@ -553,7 +529,7 @@ var loadLocalMessages = async ({
553
529
  path: { basePath, resolvedBasePath },
554
530
  locale,
555
531
  fallbackLocales,
556
- namespaces: namespaces && namespaces.length > 0 ? { count: namespaces == null ? void 0 : namespaces.length, list: [...namespaces] } : "All",
532
+ namespaces: namespaces && namespaces.length > 0 ? { count: namespaces?.length, list: [...namespaces] } : "All",
557
533
  concurrency
558
534
  });
559
535
  const validNamespaces = await loadLocaleWithFallback({
@@ -567,7 +543,7 @@ var loadLocalMessages = async ({
567
543
  });
568
544
  const end = perf_hooks.performance.now();
569
545
  const duration = Math.round(end - start);
570
- if (validNamespaces && (validNamespaces == null ? void 0 : validNamespaces.length) > 0) {
546
+ if (validNamespaces && validNamespaces?.length > 0) {
571
547
  logger.info("Finished loading local messages.", {
572
548
  locale,
573
549
  namespaces: validNamespaces,
@@ -585,7 +561,7 @@ var loadLocalMessages = async ({
585
561
 
586
562
  // src/modules/intor-messages-loader/create-local-messages-loader/create-local-messages-loader.ts
587
563
  var createLocalMessagesLoader = (basePath) => {
588
- return (options) => loadLocalMessages(__spreadValues({ basePath }, options));
564
+ return (options) => loadLocalMessages({ basePath, ...options });
589
565
  };
590
566
 
591
567
  // src/modules/intor-messages-loader/fetch-api-messages/build-search-params.ts
@@ -634,7 +610,7 @@ var fetcher = async ({
634
610
  );
635
611
  }
636
612
  return data;
637
- } catch (e) {
613
+ } catch {
638
614
  logger.warn(`Failed to fetch messages for locale "${locale}".`, {
639
615
  locale,
640
616
  apiUrl,
@@ -714,7 +690,6 @@ var extractPathname = ({
714
690
  config,
715
691
  pathname: rawPathname
716
692
  }) => {
717
- var _a;
718
693
  const { routing, defaultLocale } = config;
719
694
  const { basePath, prefix } = routing;
720
695
  const normalizedPathname = normalizePathname(rawPathname);
@@ -726,7 +701,7 @@ var extractPathname = ({
726
701
  }
727
702
  const pathParts = prefixedPathname.split("/").filter(Boolean);
728
703
  const maybeLocale = pathParts[0] || "";
729
- const isLocalePrefixed = (_a = config.supportedLocales) == null ? void 0 : _a.includes(maybeLocale);
704
+ const isLocalePrefixed = config.supportedLocales?.includes(maybeLocale);
730
705
  let unprefixedPathname = prefixedPathname;
731
706
  if (prefix === "all") {
732
707
  if (isLocalePrefixed) {
@@ -767,7 +742,6 @@ var resolveNamespaces = ({
767
742
  config,
768
743
  pathname
769
744
  }) => {
770
- var _a, _b, _c, _d;
771
745
  const { loaderOptions, prefixPlaceHolder } = config;
772
746
  const {
773
747
  routeNamespaces = {},
@@ -782,8 +756,8 @@ var resolveNamespaces = ({
782
756
  `/${prefixPlaceHolder}`,
783
757
  ""
784
758
  );
785
- const defaultNamespaces = (_a = routeNamespaces.default) != null ? _a : [];
786
- const exactMatchNamespaces = (_b = routeNamespaces[standardizedPathname]) != null ? _b : routeNamespaces[placeholderRemovedPathname];
759
+ const defaultNamespaces = routeNamespaces.default ?? [];
760
+ const exactMatchNamespaces = routeNamespaces[standardizedPathname] ?? routeNamespaces[placeholderRemovedPathname];
787
761
  if (exactMatchNamespaces) {
788
762
  return [...defaultNamespaces, ...exactMatchNamespaces];
789
763
  }
@@ -801,7 +775,7 @@ var resolveNamespaces = ({
801
775
  }
802
776
  }
803
777
  }
804
- const matchedNamespaces = (_d = (_c = bestNamespaces != null ? bestNamespaces : routeNamespaces["/*"]) != null ? _c : fallbackNamespaces) != null ? _d : [];
778
+ const matchedNamespaces = bestNamespaces ?? routeNamespaces["/*"] ?? fallbackNamespaces ?? [];
805
779
  if (matchedNamespaces.length > 0) {
806
780
  return [...defaultNamespaces, ...matchedNamespaces];
807
781
  } else {
@@ -828,19 +802,21 @@ var intorMessagesLoader = async ({
828
802
  });
829
803
  if (loaderOptions.type === "import") {
830
804
  const loadLocalMessages2 = createLocalMessagesLoader(loaderOptions.basePath);
831
- dynamicMessages = await loadLocalMessages2(__spreadProps(__spreadValues({}, loaderOptions), {
805
+ dynamicMessages = await loadLocalMessages2({
806
+ ...loaderOptions,
832
807
  locale,
833
808
  fallbackLocales,
834
809
  namespaces,
835
810
  loggerId: config.id
836
- }));
811
+ });
837
812
  } else if (loaderOptions.type === "api") {
838
- dynamicMessages = await fetchApiMessages(__spreadProps(__spreadValues({}, loaderOptions), {
813
+ dynamicMessages = await fetchApiMessages({
814
+ ...loaderOptions,
839
815
  locale,
840
816
  fallbackLocales,
841
817
  namespaces,
842
818
  loggerId: config.id
843
- }));
819
+ });
844
820
  } else {
845
821
  logger.error("Unknown loader type.", {
846
822
  type: loaderOptions.type
@@ -877,14 +853,17 @@ var shouldLoadDynamicMessages = (loaderOptions, adapter) => {
877
853
 
878
854
  // src/shared/utils/merge-static-and-dynamic-messages.ts
879
855
  var mergeStaticAndDynamicMessages = (staticMessages = {}, dynamicMessages = {}) => {
880
- const result = Object.keys(staticMessages).length ? __spreadValues({}, staticMessages) : {};
856
+ const result = Object.keys(staticMessages).length ? { ...staticMessages } : {};
881
857
  for (const locale in dynamicMessages) {
882
858
  const dynamic = dynamicMessages[locale];
883
859
  if (!result[locale]) {
884
860
  result[locale] = dynamic;
885
861
  continue;
886
862
  }
887
- result[locale] = __spreadValues(__spreadValues({}, result[locale]), dynamic);
863
+ result[locale] = {
864
+ ...result[locale],
865
+ ...dynamic
866
+ };
888
867
  }
889
868
  return result;
890
869
  };
@@ -924,12 +903,13 @@ var intorRuntime = async ({
924
903
  staticMessages: {
925
904
  fromConfig: !!staticMessages
926
905
  },
927
- dynamicMessages: __spreadValues({
928
- fromLoader: !!dynamicMessages
929
- }, loaderOptions ? {
930
- loaderType: loaderOptions.type,
931
- lazyLoad: !!loaderOptions.lazyLoad
932
- } : null),
906
+ dynamicMessages: {
907
+ fromLoader: !!dynamicMessages,
908
+ ...loaderOptions ? {
909
+ loaderType: loaderOptions.type,
910
+ lazyLoad: !!loaderOptions.lazyLoad
911
+ } : null
912
+ },
933
913
  mergedMessages: messages
934
914
  });
935
915
  return {
@@ -969,14 +949,13 @@ var intor = async ({
969
949
  };
970
950
  var createIntor = (config, translateHandlers) => {
971
951
  return async (request) => {
972
- var _a, _b;
973
952
  const { initialLocale, messages } = await intor({ config, request });
974
953
  const translator = new intorTranslator.Translator({
975
954
  locale: initialLocale,
976
955
  messages,
977
956
  fallbackLocales: config.fallbackLocales,
978
- loadingMessage: (_a = config.translator) == null ? void 0 : _a.loadingMessage,
979
- placeholder: (_b = config.translator) == null ? void 0 : _b.placeholder,
957
+ loadingMessage: config.translator?.loadingMessage,
958
+ placeholder: config.translator?.placeholder,
980
959
  handlers: translateHandlers
981
960
  });
982
961
  return translator;