@intlayer/config 1.0.0 → 1.0.1

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.
Files changed (99) hide show
  1. package/dist/cjs/client.cjs +17 -25
  2. package/dist/cjs/client.cjs.map +1 -1
  3. package/dist/cjs/client.d.ts +3 -16
  4. package/dist/cjs/configFile/buildConfigurationFields.cjs +30 -52
  5. package/dist/cjs/configFile/buildConfigurationFields.cjs.map +1 -1
  6. package/dist/cjs/configFile/buildConfigurationFields.d.ts +4 -7
  7. package/dist/cjs/configFile/getConfiguration.cjs +16 -29
  8. package/dist/cjs/configFile/getConfiguration.cjs.map +1 -1
  9. package/dist/cjs/configFile/getConfiguration.d.ts +5 -7
  10. package/dist/cjs/configFile/index.cjs +9 -21
  11. package/dist/cjs/configFile/index.d.ts +3 -6
  12. package/dist/cjs/configFile/loadConfigurationFile.cjs +18 -37
  13. package/dist/cjs/configFile/loadConfigurationFile.cjs.map +1 -1
  14. package/dist/cjs/configFile/loadConfigurationFile.d.ts +3 -5
  15. package/dist/cjs/configFile/searchConfigurationFile.cjs +8 -13
  16. package/dist/cjs/configFile/searchConfigurationFile.d.ts +3 -5
  17. package/dist/cjs/defaultValues/internationalization.cjs +11 -16
  18. package/dist/cjs/defaultValues/internationalization.cjs.map +1 -1
  19. package/dist/cjs/defaultValues/internationalization.d.ts +1 -1
  20. package/dist/cjs/defaultValues/middleware.cjs +13 -18
  21. package/dist/cjs/defaultValues/middleware.d.ts +1 -8
  22. package/dist/cjs/defaultValues/server.cjs +17 -22
  23. package/dist/cjs/defaultValues/server.d.ts +1 -12
  24. package/dist/cjs/envVariables/formatEnvVariable.cjs +11 -17
  25. package/dist/cjs/envVariables/getConfiguration.cjs +23 -49
  26. package/dist/cjs/envVariables/getConfiguration.cjs.map +1 -1
  27. package/dist/cjs/envVariables/getConfiguration.d.ts +3 -14
  28. package/dist/cjs/envVariables/index.cjs +17 -25
  29. package/dist/cjs/envVariables/index.d.ts +4 -10
  30. package/dist/cjs/envVariables/utils.cjs +8 -13
  31. package/dist/cjs/envVariables/utils.d.ts +5 -14
  32. package/dist/cjs/index.cjs +20 -28
  33. package/dist/cjs/index.cjs.map +1 -1
  34. package/dist/cjs/index.d.ts +5 -22
  35. package/dist/cjs/types/config.cjs +17 -0
  36. package/dist/cjs/types/config.cjs.map +1 -0
  37. package/dist/cjs/types/config.d.ts +75 -0
  38. package/dist/cjs/{defaultValues → types}/locales.cjs +8 -13
  39. package/dist/cjs/types/locales.cjs.map +1 -0
  40. package/dist/cjs/types/locales.d.ts +236 -0
  41. package/dist/esm/client.d.mts +3 -16
  42. package/dist/esm/client.mjs +5 -5
  43. package/dist/esm/client.mjs.map +1 -1
  44. package/dist/esm/configFile/buildConfigurationFields.d.mts +4 -7
  45. package/dist/esm/configFile/buildConfigurationFields.mjs +20 -25
  46. package/dist/esm/configFile/buildConfigurationFields.mjs.map +1 -1
  47. package/dist/esm/configFile/getConfiguration.d.mts +5 -7
  48. package/dist/esm/configFile/getConfiguration.mjs +9 -8
  49. package/dist/esm/configFile/getConfiguration.mjs.map +1 -1
  50. package/dist/esm/configFile/index.d.mts +3 -6
  51. package/dist/esm/configFile/index.mjs +2 -2
  52. package/dist/esm/configFile/loadConfigurationFile.d.mts +3 -5
  53. package/dist/esm/configFile/loadConfigurationFile.mjs +14 -24
  54. package/dist/esm/configFile/loadConfigurationFile.mjs.map +1 -1
  55. package/dist/esm/configFile/searchConfigurationFile.d.mts +3 -5
  56. package/dist/esm/configFile/searchConfigurationFile.mjs +4 -2
  57. package/dist/esm/defaultValues/internationalization.d.mts +1 -1
  58. package/dist/esm/defaultValues/internationalization.mjs +11 -4
  59. package/dist/esm/defaultValues/internationalization.mjs.map +1 -1
  60. package/dist/esm/defaultValues/middleware.d.mts +1 -8
  61. package/dist/esm/defaultValues/middleware.mjs +2 -2
  62. package/dist/esm/defaultValues/server.d.mts +1 -12
  63. package/dist/esm/defaultValues/server.mjs +2 -2
  64. package/dist/esm/envVariables/formatEnvVariable.mjs +7 -6
  65. package/dist/esm/envVariables/getConfiguration.d.mts +3 -14
  66. package/dist/esm/envVariables/getConfiguration.mjs +15 -9
  67. package/dist/esm/envVariables/getConfiguration.mjs.map +1 -1
  68. package/dist/esm/envVariables/index.d.mts +4 -10
  69. package/dist/esm/envVariables/index.mjs +5 -5
  70. package/dist/esm/envVariables/utils.d.mts +5 -14
  71. package/dist/esm/envVariables/utils.mjs +4 -2
  72. package/dist/esm/index.d.mts +5 -22
  73. package/dist/esm/index.mjs +6 -6
  74. package/dist/esm/index.mjs.map +1 -1
  75. package/dist/esm/types/config.d.mts +75 -0
  76. package/dist/esm/types/config.mjs +1 -0
  77. package/dist/esm/types/locales.d.mts +236 -0
  78. package/dist/esm/{defaultValues → types}/locales.mjs +4 -2
  79. package/dist/esm/types/locales.mjs.map +1 -0
  80. package/package.json +5 -8
  81. package/src/client.ts +3 -2
  82. package/src/configFile/buildConfigurationFields.ts +1 -1
  83. package/src/configFile/getConfiguration.ts +1 -1
  84. package/src/configFile/loadConfigurationFile.ts +1 -1
  85. package/src/defaultValues/internationalization.ts +1 -1
  86. package/src/envVariables/getConfiguration.ts +2 -2
  87. package/src/index.ts +3 -2
  88. package/src/types/{index.ts → config.ts} +1 -1
  89. package/src/{defaultValues → types}/locales.ts +6 -0
  90. package/dist/cjs/defaultValues/locales.cjs.map +0 -1
  91. package/dist/cjs/defaultValues/locales.d.ts +0 -234
  92. package/dist/cjs/types/index.cjs +0 -21
  93. package/dist/cjs/types/index.cjs.map +0 -1
  94. package/dist/cjs/types/index.d.ts +0 -89
  95. package/dist/esm/defaultValues/locales.d.mts +0 -234
  96. package/dist/esm/defaultValues/locales.mjs.map +0 -1
  97. package/dist/esm/types/index.d.mts +0 -89
  98. package/dist/esm/types/index.mjs +0 -1
  99. /package/dist/esm/types/{index.mjs.map → config.mjs.map} +0 -0
@@ -8,41 +8,33 @@ var __export = (target, all) => {
8
8
  __defProp(target, name, { get: all[name], enumerable: true });
9
9
  };
10
10
  var __copyProps = (to, from, except, desc) => {
11
- if ((from && typeof from === "object") || typeof from === "function") {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
12
  for (let key of __getOwnPropNames(from))
13
13
  if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, {
15
- get: () => from[key],
16
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
17
- });
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
15
  }
19
16
  return to;
20
17
  };
21
- var __toCommonJS = (mod) =>
22
- __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
19
  var client_exports = {};
24
20
  __export(client_exports, {
25
21
  Locales: () => import_locales.Locales,
26
22
  getConfiguration: () => import_getConfiguration.getConfiguration,
27
23
  intlayerConfiguration: () => import_getConfiguration.intlayerConfiguration,
28
- intlayerContentConfiguration: () =>
29
- import_getConfiguration.intlayerContentConfiguration,
30
- intlayerIntlConfiguration: () =>
31
- import_getConfiguration.intlayerIntlConfiguration,
32
- intlayerMiddlewareConfiguration: () =>
33
- import_getConfiguration.intlayerMiddlewareConfiguration,
24
+ intlayerContentConfiguration: () => import_getConfiguration.intlayerContentConfiguration,
25
+ intlayerIntlConfiguration: () => import_getConfiguration.intlayerIntlConfiguration,
26
+ intlayerMiddlewareConfiguration: () => import_getConfiguration.intlayerMiddlewareConfiguration
34
27
  });
35
28
  module.exports = __toCommonJS(client_exports);
36
- var import_locales = require("./defaultValues/locales.cjs");
37
- var import_getConfiguration = require("./envVariables/getConfiguration.cjs");
29
+ var import_locales = require('./types/locales.cjs');
30
+ var import_getConfiguration = require('./envVariables/getConfiguration.cjs');
38
31
  // Annotate the CommonJS export names for ESM import in node:
39
- 0 &&
40
- (module.exports = {
41
- Locales,
42
- getConfiguration,
43
- intlayerConfiguration,
44
- intlayerContentConfiguration,
45
- intlayerIntlConfiguration,
46
- intlayerMiddlewareConfiguration,
47
- });
48
- //# sourceMappingURL=client.cjs.map
32
+ 0 && (module.exports = {
33
+ Locales,
34
+ getConfiguration,
35
+ intlayerConfiguration,
36
+ intlayerContentConfiguration,
37
+ intlayerIntlConfiguration,
38
+ intlayerMiddlewareConfiguration
39
+ });
40
+ //# sourceMappingURL=client.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/client.ts"],"sourcesContent":["export type {\n CustomIntlayerConfig,\n PatternsContentConfig as FixedIntlayerConfig,\n IntlayerConfig,\n BaseContentConfig as NotDerivedConfiguration,\n BaseDerivedConfig as BaseDirDerivedConfiguration,\n ResultDirDerivedConfig as ResultDirDerivedConfiguration,\n} from './types';\nexport { Locales } from './defaultValues/locales';\nexport {\n getConfiguration,\n intlayerConfiguration,\n intlayerContentConfiguration,\n intlayerIntlConfiguration,\n intlayerMiddlewareConfiguration,\n} from './envVariables/getConfiguration';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,qBAAwB;AACxB,8BAMO;","names":[]}
1
+ {"version":3,"sources":["../../src/client.ts"],"sourcesContent":["export type {\n CustomIntlayerConfig,\n PatternsContentConfig as FixedIntlayerConfig,\n IntlayerConfig,\n BaseContentConfig as NotDerivedConfiguration,\n BaseDerivedConfig as BaseDirDerivedConfiguration,\n ResultDirDerivedConfig as ResultDirDerivedConfiguration,\n} from './types/config';\nexport type { LocalesValues } from './types/locales';\nexport { Locales } from './types/locales';\nexport {\n getConfiguration,\n intlayerConfiguration,\n intlayerContentConfiguration,\n intlayerIntlConfiguration,\n intlayerMiddlewareConfiguration,\n} from './envVariables/getConfiguration';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,qBAAwB;AACxB,8BAMO;","names":[]}
@@ -1,16 +1,3 @@
1
- export {
2
- BaseDerivedConfig as BaseDirDerivedConfiguration,
3
- CustomIntlayerConfig,
4
- PatternsContentConfig as FixedIntlayerConfig,
5
- IntlayerConfig,
6
- BaseContentConfig as NotDerivedConfiguration,
7
- ResultDirDerivedConfig as ResultDirDerivedConfiguration,
8
- } from "./types/index.js";
9
- export { Locales } from "./defaultValues/locales.js";
10
- export {
11
- getConfiguration,
12
- intlayerConfiguration,
13
- intlayerContentConfiguration,
14
- intlayerIntlConfiguration,
15
- intlayerMiddlewareConfiguration,
16
- } from "./envVariables/getConfiguration.js";
1
+ export { BaseDerivedConfig as BaseDirDerivedConfiguration, CustomIntlayerConfig, PatternsContentConfig as FixedIntlayerConfig, IntlayerConfig, BaseContentConfig as NotDerivedConfiguration, ResultDirDerivedConfig as ResultDirDerivedConfiguration } from './types/config.js';
2
+ export { Locales, LocalesValues } from './types/locales.js';
3
+ export { getConfiguration, intlayerConfiguration, intlayerContentConfiguration, intlayerIntlConfiguration, intlayerMiddlewareConfiguration } from './envVariables/getConfiguration.js';
@@ -8,27 +8,23 @@ var __export = (target, all) => {
8
8
  __defProp(target, name, { get: all[name], enumerable: true });
9
9
  };
10
10
  var __copyProps = (to, from, except, desc) => {
11
- if ((from && typeof from === "object") || typeof from === "function") {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
12
  for (let key of __getOwnPropNames(from))
13
13
  if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, {
15
- get: () => from[key],
16
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
17
- });
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
15
  }
19
16
  return to;
20
17
  };
21
- var __toCommonJS = (mod) =>
22
- __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
19
  var buildConfigurationFields_exports = {};
24
20
  __export(buildConfigurationFields_exports, {
25
- buildConfigurationFields: () => buildConfigurationFields,
21
+ buildConfigurationFields: () => buildConfigurationFields
26
22
  });
27
23
  module.exports = __toCommonJS(buildConfigurationFields_exports);
28
24
  var import_path = require("path");
29
- var import_internationalization = require("../defaultValues/internationalization.cjs");
30
- var import_middleware = require("../defaultValues/middleware.cjs");
31
- var import_server = require("../defaultValues/server.cjs");
25
+ var import_internationalization = require('../defaultValues/internationalization.cjs');
26
+ var import_middleware = require('../defaultValues/middleware.cjs');
27
+ var import_server = require('../defaultValues/server.cjs');
32
28
  let storedConfiguration;
33
29
  const buildInternationalizationFields = (customConfiguration) => ({
34
30
  /**
@@ -37,9 +33,7 @@ const buildInternationalizationFields = (customConfiguration) => ({
37
33
  // Locales available in the application
38
34
  locales: customConfiguration?.locales ?? import_internationalization.LOCALES,
39
35
  // Default locale of the application for fallback
40
- defaultLocale:
41
- customConfiguration?.defaultLocale ??
42
- import_internationalization.DEFAULT_LOCALE,
36
+ defaultLocale: customConfiguration?.defaultLocale ?? import_internationalization.DEFAULT_LOCALE
43
37
  });
44
38
  const buildMiddlewareFields = (customConfiguration) => ({
45
39
  /**
@@ -50,15 +44,13 @@ const buildMiddlewareFields = (customConfiguration) => ({
50
44
  // Cookie name to get the locale
51
45
  cookieName: customConfiguration?.cookieName ?? import_middleware.COOKIE_NAME,
52
46
  // Prefix the default locale in the URL
53
- prefixDefault:
54
- customConfiguration?.prefixDefault ?? import_middleware.PREFIX_DEFAULT,
47
+ prefixDefault: customConfiguration?.prefixDefault ?? import_middleware.PREFIX_DEFAULT,
55
48
  // Base path
56
49
  basePath: customConfiguration?.basePath ?? import_middleware.BASE_PATH,
57
50
  // Set cookie on server
58
- serverSetCookie:
59
- customConfiguration?.serverSetCookie ?? import_middleware.SERVER_SET_COOKIE,
51
+ serverSetCookie: customConfiguration?.serverSetCookie ?? import_middleware.SERVER_SET_COOKIE,
60
52
  // No prefix
61
- noPrefix: customConfiguration?.noPrefix ?? import_middleware.NO_PREFIX,
53
+ noPrefix: customConfiguration?.noPrefix ?? import_middleware.NO_PREFIX
62
54
  });
63
55
  const buildContentFields = (customConfiguration) => {
64
56
  const notDerivedContentConfig = {
@@ -66,40 +58,27 @@ const buildContentFields = (customConfiguration) => {
66
58
  * Content configurations
67
59
  */
68
60
  // File extensions of content to look for
69
- fileExtensions:
70
- customConfiguration?.fileExtensions ?? import_server.FILE_EXTENSIONS,
61
+ fileExtensions: customConfiguration?.fileExtensions ?? import_server.FILE_EXTENSIONS,
71
62
  // Directory name of the project
72
63
  baseDir: customConfiguration?.baseDir ?? process.cwd(),
73
64
  // Directory name where the content is stored
74
- contentDirName:
75
- customConfiguration?.contentDirName ?? import_server.CONTENT_DIR_NAME,
65
+ contentDirName: customConfiguration?.contentDirName ?? import_server.CONTENT_DIR_NAME,
76
66
  // Result directory name
77
- resultDirName:
78
- customConfiguration?.resultDirName ?? import_server.RESULT_DIR_NAME,
67
+ resultDirName: customConfiguration?.resultDirName ?? import_server.RESULT_DIR_NAME,
79
68
  // Module augmentation directory name
80
- moduleAugmentationDirName:
81
- customConfiguration?.moduleAugmentationDirName ??
82
- import_server.MODULE_AUGMENTATION_DIR_NAME,
69
+ moduleAugmentationDirName: customConfiguration?.moduleAugmentationDirName ?? import_server.MODULE_AUGMENTATION_DIR_NAME,
83
70
  // Bundle directory name
84
- bundleDirName:
85
- customConfiguration?.bundleDirName ?? import_server.BUNDLE_DIR_NAME,
71
+ bundleDirName: customConfiguration?.bundleDirName ?? import_server.BUNDLE_DIR_NAME,
86
72
  // Bundle file extension
87
- bundleFileExtension:
88
- customConfiguration?.bundleFileExtension ??
89
- import_server.BUNDLE_FILE_EXTENSION,
73
+ bundleFileExtension: customConfiguration?.bundleFileExtension ?? import_server.BUNDLE_FILE_EXTENSION,
90
74
  // Dictionary directory name
91
- dictionariesDirName:
92
- customConfiguration?.dictionariesDirName ??
93
- import_server.DICTIONARIES_DIR_NAME,
75
+ dictionariesDirName: customConfiguration?.dictionariesDirName ?? import_server.DICTIONARIES_DIR_NAME,
94
76
  // Types directory name
95
- typeDirName:
96
- customConfiguration?.typeDirName ?? import_server.TYPES_DIR_NAME,
77
+ typeDirName: customConfiguration?.typeDirName ?? import_server.TYPES_DIR_NAME,
97
78
  // Main directory name
98
- mainDirName:
99
- customConfiguration?.mainDirName ?? import_server.MAIN_DIR_NAME,
79
+ mainDirName: customConfiguration?.mainDirName ?? import_server.MAIN_DIR_NAME,
100
80
  // Directories to exclude
101
- excludedPath:
102
- customConfiguration?.excludedPath ?? import_server.EXCLUDED_PATHS,
81
+ excludedPath: customConfiguration?.excludedPath ?? import_server.EXCLUDED_PATHS
103
82
  };
104
83
  const baseDirDerivedConfiguration = {
105
84
  // Directory where the content is stored
@@ -116,7 +95,7 @@ const buildContentFields = (customConfiguration) => {
116
95
  moduleAugmentationDir: (0, import_path.join)(
117
96
  notDerivedContentConfig.baseDir,
118
97
  notDerivedContentConfig.moduleAugmentationDirName
119
- ),
98
+ )
120
99
  };
121
100
  const resultDirDerivedConfiguration = {
122
101
  // Directory where the bundle will be stored
@@ -138,7 +117,7 @@ const buildContentFields = (customConfiguration) => {
138
117
  mainDir: (0, import_path.join)(
139
118
  baseDirDerivedConfiguration.resultDir,
140
119
  notDerivedContentConfig.mainDirName
141
- ),
120
+ )
142
121
  };
143
122
  const patternsConfiguration = {
144
123
  // Pattern of files to watch
@@ -150,13 +129,13 @@ const buildContentFields = (customConfiguration) => {
150
129
  (ext) => `${baseDirDerivedConfiguration.contentDir}/**/*${ext}`
151
130
  ),
152
131
  // Pattern of files to output
153
- outputFilesPatternWithPath: `${resultDirDerivedConfiguration.dictionariesDir}/**/*.json`,
132
+ outputFilesPatternWithPath: `${resultDirDerivedConfiguration.dictionariesDir}/**/*.json`
154
133
  };
155
134
  return {
156
135
  ...notDerivedContentConfig,
157
136
  ...baseDirDerivedConfiguration,
158
137
  ...resultDirDerivedConfiguration,
159
- ...patternsConfiguration,
138
+ ...patternsConfiguration
160
139
  };
161
140
  };
162
141
  const buildConfigurationFields = (options, customConfiguration) => {
@@ -170,13 +149,12 @@ const buildConfigurationFields = (options, customConfiguration) => {
170
149
  storedConfiguration = {
171
150
  internationalization: internationalizationConfig,
172
151
  middleware: middlewareConfig,
173
- content: contentConfig,
152
+ content: contentConfig
174
153
  };
175
154
  return storedConfiguration;
176
155
  };
177
156
  // Annotate the CommonJS export names for ESM import in node:
178
- 0 &&
179
- (module.exports = {
180
- buildConfigurationFields,
181
- });
182
- //# sourceMappingURL=buildConfigurationFields.cjs.map
157
+ 0 && (module.exports = {
158
+ buildConfigurationFields
159
+ });
160
+ //# sourceMappingURL=buildConfigurationFields.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/configFile/buildConfigurationFields.ts"],"sourcesContent":["import { join } from 'path';\nimport { DEFAULT_LOCALE, LOCALES } from '../defaultValues/internationalization';\nimport {\n BASE_PATH,\n COOKIE_NAME,\n HEADER_NAME,\n NO_PREFIX,\n PREFIX_DEFAULT,\n SERVER_SET_COOKIE,\n} from '../defaultValues/middleware';\nimport {\n BUNDLE_DIR_NAME,\n CONTENT_DIR_NAME,\n DICTIONARIES_DIR_NAME,\n FILE_EXTENSIONS,\n RESULT_DIR_NAME,\n EXCLUDED_PATHS,\n BUNDLE_FILE_EXTENSION,\n TYPES_DIR_NAME,\n MAIN_DIR_NAME,\n MODULE_AUGMENTATION_DIR_NAME,\n} from '../defaultValues/server';\nimport type {\n BaseDerivedConfig,\n ContentConfig,\n CustomIntlayerConfig,\n PatternsContentConfig,\n InternationalizationConfig,\n IntlayerConfig,\n MiddlewareConfig,\n BaseContentConfig,\n ResultDirDerivedConfig,\n} from '../types';\nimport type { GetConfigurationOptions } from './getConfiguration';\n\nlet storedConfiguration: IntlayerConfig;\n\nconst buildInternationalizationFields = (\n customConfiguration?: Partial<InternationalizationConfig>\n): InternationalizationConfig => ({\n /**\n * Internationalization configuration\n */\n\n // Locales available in the application\n locales: customConfiguration?.locales ?? LOCALES,\n\n // Default locale of the application for fallback\n defaultLocale: customConfiguration?.defaultLocale ?? DEFAULT_LOCALE,\n});\n\nconst buildMiddlewareFields = (\n customConfiguration?: Partial<MiddlewareConfig>\n): MiddlewareConfig => ({\n /**\n * Middleware configuration\n */\n\n // Header name to get the locale\n headerName: customConfiguration?.headerName ?? HEADER_NAME,\n\n // Cookie name to get the locale\n cookieName: customConfiguration?.cookieName ?? COOKIE_NAME,\n\n // Prefix the default locale in the URL\n prefixDefault: customConfiguration?.prefixDefault ?? PREFIX_DEFAULT,\n\n // Base path\n basePath: customConfiguration?.basePath ?? BASE_PATH,\n\n // Set cookie on server\n serverSetCookie: customConfiguration?.serverSetCookie ?? SERVER_SET_COOKIE,\n\n // No prefix\n noPrefix: customConfiguration?.noPrefix ?? NO_PREFIX,\n});\n\nconst buildContentFields = (\n customConfiguration?: Partial<ContentConfig>\n): ContentConfig => {\n const notDerivedContentConfig: BaseContentConfig = {\n /**\n * Content configurations\n */\n\n // File extensions of content to look for\n fileExtensions: customConfiguration?.fileExtensions ?? FILE_EXTENSIONS,\n\n // Directory name of the project\n baseDir: customConfiguration?.baseDir ?? process.cwd(),\n\n // Directory name where the content is stored\n contentDirName: customConfiguration?.contentDirName ?? CONTENT_DIR_NAME,\n\n // Result directory name\n resultDirName: customConfiguration?.resultDirName ?? RESULT_DIR_NAME,\n\n // Module augmentation directory name\n moduleAugmentationDirName:\n customConfiguration?.moduleAugmentationDirName ??\n MODULE_AUGMENTATION_DIR_NAME,\n\n // Bundle directory name\n bundleDirName: customConfiguration?.bundleDirName ?? BUNDLE_DIR_NAME,\n\n // Bundle file extension\n bundleFileExtension:\n customConfiguration?.bundleFileExtension ?? BUNDLE_FILE_EXTENSION,\n\n // Dictionary directory name\n dictionariesDirName:\n customConfiguration?.dictionariesDirName ?? DICTIONARIES_DIR_NAME,\n\n // Types directory name\n typeDirName: customConfiguration?.typeDirName ?? TYPES_DIR_NAME,\n\n // Main directory name\n mainDirName: customConfiguration?.mainDirName ?? MAIN_DIR_NAME,\n\n // Directories to exclude\n excludedPath: customConfiguration?.excludedPath ?? EXCLUDED_PATHS,\n };\n\n const baseDirDerivedConfiguration: BaseDerivedConfig = {\n // Directory where the content is stored\n contentDir: join(\n notDerivedContentConfig.baseDir,\n notDerivedContentConfig.contentDirName\n ),\n\n // Directory where the result will be stored\n resultDir: join(\n notDerivedContentConfig.baseDir,\n notDerivedContentConfig.resultDirName\n ),\n\n // Directory where the module augmentation will be stored\n moduleAugmentationDir: join(\n notDerivedContentConfig.baseDir,\n notDerivedContentConfig.moduleAugmentationDirName\n ),\n };\n\n const resultDirDerivedConfiguration: ResultDirDerivedConfig = {\n // Directory where the bundle will be stored\n bundleDir: join(\n baseDirDerivedConfiguration.resultDir,\n notDerivedContentConfig.bundleDirName\n ),\n\n // Directory where the dictionaries will be stored\n dictionariesDir: join(\n baseDirDerivedConfiguration.resultDir,\n notDerivedContentConfig.dictionariesDirName\n ),\n\n // Directory where the types will be stored\n typesDir: join(\n baseDirDerivedConfiguration.resultDir,\n notDerivedContentConfig.typeDirName\n ),\n\n // Directory where the main files will be stored\n mainDir: join(\n baseDirDerivedConfiguration.resultDir,\n notDerivedContentConfig.mainDirName\n ),\n };\n\n const patternsConfiguration: PatternsContentConfig = {\n // Pattern of files to watch\n watchedFilesPattern: notDerivedContentConfig.fileExtensions.map(\n (ext) => `/**/*${ext}`\n ),\n\n // Pattern of files to watch including the relative path\n watchedFilesPatternWithPath: notDerivedContentConfig.fileExtensions.map(\n (ext) => `${baseDirDerivedConfiguration.contentDir}/**/*${ext}`\n ),\n\n // Pattern of files to output\n outputFilesPatternWithPath: `${resultDirDerivedConfiguration.dictionariesDir}/**/*.json`,\n };\n\n return {\n ...notDerivedContentConfig,\n ...baseDirDerivedConfiguration,\n ...resultDirDerivedConfiguration,\n ...patternsConfiguration,\n };\n};\n\nexport const buildConfigurationFields = (\n options: GetConfigurationOptions,\n customConfiguration?: CustomIntlayerConfig\n): IntlayerConfig => {\n const internationalizationConfig = buildInternationalizationFields(\n customConfiguration?.internationalization\n );\n\n const middlewareConfig = buildMiddlewareFields(\n customConfiguration?.middleware\n );\n\n const contentConfig = buildContentFields(customConfiguration?.content);\n\n storedConfiguration = {\n internationalization: internationalizationConfig,\n middleware: middlewareConfig,\n content: contentConfig,\n };\n\n return storedConfiguration;\n};\n"],"mappings":"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","names":[]}
1
+ {"version":3,"sources":["../../../src/configFile/buildConfigurationFields.ts"],"sourcesContent":["import { join } from 'path';\nimport { DEFAULT_LOCALE, LOCALES } from '../defaultValues/internationalization';\nimport {\n BASE_PATH,\n COOKIE_NAME,\n HEADER_NAME,\n NO_PREFIX,\n PREFIX_DEFAULT,\n SERVER_SET_COOKIE,\n} from '../defaultValues/middleware';\nimport {\n BUNDLE_DIR_NAME,\n CONTENT_DIR_NAME,\n DICTIONARIES_DIR_NAME,\n FILE_EXTENSIONS,\n RESULT_DIR_NAME,\n EXCLUDED_PATHS,\n BUNDLE_FILE_EXTENSION,\n TYPES_DIR_NAME,\n MAIN_DIR_NAME,\n MODULE_AUGMENTATION_DIR_NAME,\n} from '../defaultValues/server';\nimport type {\n BaseDerivedConfig,\n ContentConfig,\n CustomIntlayerConfig,\n PatternsContentConfig,\n InternationalizationConfig,\n IntlayerConfig,\n MiddlewareConfig,\n BaseContentConfig,\n ResultDirDerivedConfig,\n} from '../types/config';\nimport type { GetConfigurationOptions } from './getConfiguration';\n\nlet storedConfiguration: IntlayerConfig;\n\nconst buildInternationalizationFields = (\n customConfiguration?: Partial<InternationalizationConfig>\n): InternationalizationConfig => ({\n /**\n * Internationalization configuration\n */\n\n // Locales available in the application\n locales: customConfiguration?.locales ?? LOCALES,\n\n // Default locale of the application for fallback\n defaultLocale: customConfiguration?.defaultLocale ?? DEFAULT_LOCALE,\n});\n\nconst buildMiddlewareFields = (\n customConfiguration?: Partial<MiddlewareConfig>\n): MiddlewareConfig => ({\n /**\n * Middleware configuration\n */\n\n // Header name to get the locale\n headerName: customConfiguration?.headerName ?? HEADER_NAME,\n\n // Cookie name to get the locale\n cookieName: customConfiguration?.cookieName ?? COOKIE_NAME,\n\n // Prefix the default locale in the URL\n prefixDefault: customConfiguration?.prefixDefault ?? PREFIX_DEFAULT,\n\n // Base path\n basePath: customConfiguration?.basePath ?? BASE_PATH,\n\n // Set cookie on server\n serverSetCookie: customConfiguration?.serverSetCookie ?? SERVER_SET_COOKIE,\n\n // No prefix\n noPrefix: customConfiguration?.noPrefix ?? NO_PREFIX,\n});\n\nconst buildContentFields = (\n customConfiguration?: Partial<ContentConfig>\n): ContentConfig => {\n const notDerivedContentConfig: BaseContentConfig = {\n /**\n * Content configurations\n */\n\n // File extensions of content to look for\n fileExtensions: customConfiguration?.fileExtensions ?? FILE_EXTENSIONS,\n\n // Directory name of the project\n baseDir: customConfiguration?.baseDir ?? process.cwd(),\n\n // Directory name where the content is stored\n contentDirName: customConfiguration?.contentDirName ?? CONTENT_DIR_NAME,\n\n // Result directory name\n resultDirName: customConfiguration?.resultDirName ?? RESULT_DIR_NAME,\n\n // Module augmentation directory name\n moduleAugmentationDirName:\n customConfiguration?.moduleAugmentationDirName ??\n MODULE_AUGMENTATION_DIR_NAME,\n\n // Bundle directory name\n bundleDirName: customConfiguration?.bundleDirName ?? BUNDLE_DIR_NAME,\n\n // Bundle file extension\n bundleFileExtension:\n customConfiguration?.bundleFileExtension ?? BUNDLE_FILE_EXTENSION,\n\n // Dictionary directory name\n dictionariesDirName:\n customConfiguration?.dictionariesDirName ?? DICTIONARIES_DIR_NAME,\n\n // Types directory name\n typeDirName: customConfiguration?.typeDirName ?? TYPES_DIR_NAME,\n\n // Main directory name\n mainDirName: customConfiguration?.mainDirName ?? MAIN_DIR_NAME,\n\n // Directories to exclude\n excludedPath: customConfiguration?.excludedPath ?? EXCLUDED_PATHS,\n };\n\n const baseDirDerivedConfiguration: BaseDerivedConfig = {\n // Directory where the content is stored\n contentDir: join(\n notDerivedContentConfig.baseDir,\n notDerivedContentConfig.contentDirName\n ),\n\n // Directory where the result will be stored\n resultDir: join(\n notDerivedContentConfig.baseDir,\n notDerivedContentConfig.resultDirName\n ),\n\n // Directory where the module augmentation will be stored\n moduleAugmentationDir: join(\n notDerivedContentConfig.baseDir,\n notDerivedContentConfig.moduleAugmentationDirName\n ),\n };\n\n const resultDirDerivedConfiguration: ResultDirDerivedConfig = {\n // Directory where the bundle will be stored\n bundleDir: join(\n baseDirDerivedConfiguration.resultDir,\n notDerivedContentConfig.bundleDirName\n ),\n\n // Directory where the dictionaries will be stored\n dictionariesDir: join(\n baseDirDerivedConfiguration.resultDir,\n notDerivedContentConfig.dictionariesDirName\n ),\n\n // Directory where the types will be stored\n typesDir: join(\n baseDirDerivedConfiguration.resultDir,\n notDerivedContentConfig.typeDirName\n ),\n\n // Directory where the main files will be stored\n mainDir: join(\n baseDirDerivedConfiguration.resultDir,\n notDerivedContentConfig.mainDirName\n ),\n };\n\n const patternsConfiguration: PatternsContentConfig = {\n // Pattern of files to watch\n watchedFilesPattern: notDerivedContentConfig.fileExtensions.map(\n (ext) => `/**/*${ext}`\n ),\n\n // Pattern of files to watch including the relative path\n watchedFilesPatternWithPath: notDerivedContentConfig.fileExtensions.map(\n (ext) => `${baseDirDerivedConfiguration.contentDir}/**/*${ext}`\n ),\n\n // Pattern of files to output\n outputFilesPatternWithPath: `${resultDirDerivedConfiguration.dictionariesDir}/**/*.json`,\n };\n\n return {\n ...notDerivedContentConfig,\n ...baseDirDerivedConfiguration,\n ...resultDirDerivedConfiguration,\n ...patternsConfiguration,\n };\n};\n\nexport const buildConfigurationFields = (\n options: GetConfigurationOptions,\n customConfiguration?: CustomIntlayerConfig\n): IntlayerConfig => {\n const internationalizationConfig = buildInternationalizationFields(\n customConfiguration?.internationalization\n );\n\n const middlewareConfig = buildMiddlewareFields(\n customConfiguration?.middleware\n );\n\n const contentConfig = buildContentFields(customConfiguration?.content);\n\n storedConfiguration = {\n internationalization: internationalizationConfig,\n middleware: middlewareConfig,\n content: contentConfig,\n };\n\n return storedConfiguration;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqB;AACrB,kCAAwC;AACxC,wBAOO;AACP,oBAWO;AAcP,IAAI;AAEJ,MAAM,kCAAkC,CACtC,yBACgC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMhC,SAAS,qBAAqB,WAAW;AAAA;AAAA,EAGzC,eAAe,qBAAqB,iBAAiB;AACvD;AAEA,MAAM,wBAAwB,CAC5B,yBACsB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMtB,YAAY,qBAAqB,cAAc;AAAA;AAAA,EAG/C,YAAY,qBAAqB,cAAc;AAAA;AAAA,EAG/C,eAAe,qBAAqB,iBAAiB;AAAA;AAAA,EAGrD,UAAU,qBAAqB,YAAY;AAAA;AAAA,EAG3C,iBAAiB,qBAAqB,mBAAmB;AAAA;AAAA,EAGzD,UAAU,qBAAqB,YAAY;AAC7C;AAEA,MAAM,qBAAqB,CACzB,wBACkB;AAClB,QAAM,0BAA6C;AAAA;AAAA;AAAA;AAAA;AAAA,IAMjD,gBAAgB,qBAAqB,kBAAkB;AAAA;AAAA,IAGvD,SAAS,qBAAqB,WAAW,QAAQ,IAAI;AAAA;AAAA,IAGrD,gBAAgB,qBAAqB,kBAAkB;AAAA;AAAA,IAGvD,eAAe,qBAAqB,iBAAiB;AAAA;AAAA,IAGrD,2BACE,qBAAqB,6BACrB;AAAA;AAAA,IAGF,eAAe,qBAAqB,iBAAiB;AAAA;AAAA,IAGrD,qBACE,qBAAqB,uBAAuB;AAAA;AAAA,IAG9C,qBACE,qBAAqB,uBAAuB;AAAA;AAAA,IAG9C,aAAa,qBAAqB,eAAe;AAAA;AAAA,IAGjD,aAAa,qBAAqB,eAAe;AAAA;AAAA,IAGjD,cAAc,qBAAqB,gBAAgB;AAAA,EACrD;AAEA,QAAM,8BAAiD;AAAA;AAAA,IAErD,gBAAY;AAAA,MACV,wBAAwB;AAAA,MACxB,wBAAwB;AAAA,IAC1B;AAAA;AAAA,IAGA,eAAW;AAAA,MACT,wBAAwB;AAAA,MACxB,wBAAwB;AAAA,IAC1B;AAAA;AAAA,IAGA,2BAAuB;AAAA,MACrB,wBAAwB;AAAA,MACxB,wBAAwB;AAAA,IAC1B;AAAA,EACF;AAEA,QAAM,gCAAwD;AAAA;AAAA,IAE5D,eAAW;AAAA,MACT,4BAA4B;AAAA,MAC5B,wBAAwB;AAAA,IAC1B;AAAA;AAAA,IAGA,qBAAiB;AAAA,MACf,4BAA4B;AAAA,MAC5B,wBAAwB;AAAA,IAC1B;AAAA;AAAA,IAGA,cAAU;AAAA,MACR,4BAA4B;AAAA,MAC5B,wBAAwB;AAAA,IAC1B;AAAA;AAAA,IAGA,aAAS;AAAA,MACP,4BAA4B;AAAA,MAC5B,wBAAwB;AAAA,IAC1B;AAAA,EACF;AAEA,QAAM,wBAA+C;AAAA;AAAA,IAEnD,qBAAqB,wBAAwB,eAAe;AAAA,MAC1D,CAAC,QAAQ,QAAQ,GAAG;AAAA,IACtB;AAAA;AAAA,IAGA,6BAA6B,wBAAwB,eAAe;AAAA,MAClE,CAAC,QAAQ,GAAG,4BAA4B,UAAU,QAAQ,GAAG;AAAA,IAC/D;AAAA;AAAA,IAGA,4BAA4B,GAAG,8BAA8B,eAAe;AAAA,EAC9E;AAEA,SAAO;AAAA,IACL,GAAG;AAAA,IACH,GAAG;AAAA,IACH,GAAG;AAAA,IACH,GAAG;AAAA,EACL;AACF;AAEO,MAAM,2BAA2B,CACtC,SACA,wBACmB;AACnB,QAAM,6BAA6B;AAAA,IACjC,qBAAqB;AAAA,EACvB;AAEA,QAAM,mBAAmB;AAAA,IACvB,qBAAqB;AAAA,EACvB;AAEA,QAAM,gBAAgB,mBAAmB,qBAAqB,OAAO;AAErE,wBAAsB;AAAA,IACpB,sBAAsB;AAAA,IACtB,YAAY;AAAA,IACZ,SAAS;AAAA,EACX;AAEA,SAAO;AACT;","names":[]}
@@ -1,10 +1,7 @@
1
- import { CustomIntlayerConfig, IntlayerConfig } from "../types/index.js";
2
- import { GetConfigurationOptions } from "./getConfiguration.js";
3
- import "../defaultValues/locales.js";
1
+ import { CustomIntlayerConfig, IntlayerConfig } from '../types/config.js';
2
+ import { GetConfigurationOptions } from './getConfiguration.js';
3
+ import '../types/locales.js';
4
4
 
5
- declare const buildConfigurationFields: (
6
- options: GetConfigurationOptions,
7
- customConfiguration?: CustomIntlayerConfig
8
- ) => IntlayerConfig;
5
+ declare const buildConfigurationFields: (options: GetConfigurationOptions, customConfiguration?: CustomIntlayerConfig) => IntlayerConfig;
9
6
 
10
7
  export { buildConfigurationFields };
@@ -8,50 +8,41 @@ var __export = (target, all) => {
8
8
  __defProp(target, name, { get: all[name], enumerable: true });
9
9
  };
10
10
  var __copyProps = (to, from, except, desc) => {
11
- if ((from && typeof from === "object") || typeof from === "function") {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
12
  for (let key of __getOwnPropNames(from))
13
13
  if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, {
15
- get: () => from[key],
16
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
17
- });
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
15
  }
19
16
  return to;
20
17
  };
21
- var __toCommonJS = (mod) =>
22
- __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
19
  var getConfiguration_exports = {};
24
20
  __export(getConfiguration_exports, {
25
- getConfiguration: () => getConfiguration,
21
+ getConfiguration: () => getConfiguration
26
22
  });
27
23
  module.exports = __toCommonJS(getConfiguration_exports);
28
24
  var import_path = require("path");
29
- var import_buildConfigurationFields = require("./buildConfigurationFields.cjs");
30
- var import_loadConfigurationFile = require("./loadConfigurationFile.cjs");
31
- var import_searchConfigurationFile = require("./searchConfigurationFile.cjs");
25
+ var import_buildConfigurationFields = require('./buildConfigurationFields.cjs');
26
+ var import_loadConfigurationFile = require('./loadConfigurationFile.cjs');
27
+ var import_searchConfigurationFile = require('./searchConfigurationFile.cjs');
32
28
  let storedConfiguration;
33
29
  let storedConfigurationFilePath;
34
30
  let storedNumCustomConfiguration;
35
31
  const BASE_DIR_PATH = process.env.INTLAYER_BASE_DIR_PATH ?? process.cwd();
36
32
  const defaultOptions = {
37
33
  baseDir: BASE_DIR_PATH,
38
- verbose: false,
34
+ verbose: false
39
35
  };
40
36
  const getConfiguration = (options) => {
41
37
  const mergedOptions = { ...defaultOptions, ...options };
42
38
  const { baseDir, verbose } = mergedOptions;
43
39
  if (!storedConfiguration) {
44
- const { configurationFilePath, numCustomConfiguration } = (0,
45
- import_searchConfigurationFile.searchConfigurationFile)(baseDir);
40
+ const { configurationFilePath, numCustomConfiguration } = (0, import_searchConfigurationFile.searchConfigurationFile)(baseDir);
46
41
  let customConfiguration;
47
42
  if (configurationFilePath) {
48
- customConfiguration = (0,
49
- import_loadConfigurationFile.loadConfigurationFile)(
50
- configurationFilePath
51
- );
43
+ customConfiguration = (0, import_loadConfigurationFile.loadConfigurationFile)(configurationFilePath);
52
44
  }
53
- storedConfiguration = (0,
54
- import_buildConfigurationFields.buildConfigurationFields)(
45
+ storedConfiguration = (0, import_buildConfigurationFields.buildConfigurationFields)(
55
46
  mergedOptions,
56
47
  customConfiguration
57
48
  );
@@ -69,10 +60,7 @@ const logConfigFileResult = (numCustomConfiguration, configurationFilePath) => {
69
60
  if (numCustomConfiguration === 0) {
70
61
  console.info("Configuration file not found, using default configuration.");
71
62
  } else {
72
- const relativeOutputPath = (0, import_path.relative)(
73
- BASE_DIR_PATH,
74
- configurationFilePath
75
- );
63
+ const relativeOutputPath = (0, import_path.relative)(BASE_DIR_PATH, configurationFilePath);
76
64
  if (numCustomConfiguration === 1) {
77
65
  console.info(`Configuration file found: ${relativeOutputPath}.`);
78
66
  } else {
@@ -83,8 +71,7 @@ const logConfigFileResult = (numCustomConfiguration, configurationFilePath) => {
83
71
  }
84
72
  };
85
73
  // Annotate the CommonJS export names for ESM import in node:
86
- 0 &&
87
- (module.exports = {
88
- getConfiguration,
89
- });
90
- //# sourceMappingURL=getConfiguration.cjs.map
74
+ 0 && (module.exports = {
75
+ getConfiguration
76
+ });
77
+ //# sourceMappingURL=getConfiguration.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/configFile/getConfiguration.ts"],"sourcesContent":["import { relative } from 'path';\nimport type { CustomIntlayerConfig, IntlayerConfig } from '../types';\nimport { buildConfigurationFields } from './buildConfigurationFields';\nimport { loadConfigurationFile } from './loadConfigurationFile';\nimport { searchConfigurationFile } from './searchConfigurationFile';\n\nlet storedConfiguration: IntlayerConfig | undefined;\nlet storedConfigurationFilePath: string | undefined;\nlet storedNumCustomConfiguration: number | undefined;\n\nexport type GetConfigurationOptions = {\n baseDir: string;\n verbose: boolean;\n};\n\nconst BASE_DIR_PATH = process.env.INTLAYER_BASE_DIR_PATH ?? process.cwd();\nconst defaultOptions: GetConfigurationOptions = {\n baseDir: BASE_DIR_PATH,\n verbose: false,\n};\n\nexport const getConfiguration = (\n options?: Partial<GetConfigurationOptions>\n): IntlayerConfig => {\n const mergedOptions = { ...defaultOptions, ...options };\n const { baseDir, verbose } = mergedOptions;\n\n if (!storedConfiguration) {\n // Search for configuration files\n const { configurationFilePath, numCustomConfiguration } =\n searchConfigurationFile(baseDir);\n\n // Load the custom configuration\n let customConfiguration: CustomIntlayerConfig | undefined;\n if (configurationFilePath) {\n customConfiguration = loadConfigurationFile(configurationFilePath);\n }\n\n // Save the configuration to avoid reading the file again\n storedConfiguration = buildConfigurationFields(\n mergedOptions,\n customConfiguration\n );\n storedConfigurationFilePath = configurationFilePath;\n storedNumCustomConfiguration = numCustomConfiguration;\n }\n\n // Log warning if multiple configuration files are found\n if (verbose)\n logConfigFileResult(\n storedNumCustomConfiguration,\n storedConfigurationFilePath\n );\n\n return storedConfiguration;\n};\n\nconst logConfigFileResult = (\n numCustomConfiguration?: number,\n configurationFilePath?: string\n) => {\n if (numCustomConfiguration === 0) {\n console.info('Configuration file not found, using default configuration.');\n } else {\n const relativeOutputPath = relative(BASE_DIR_PATH, configurationFilePath!);\n\n if (numCustomConfiguration === 1) {\n console.info(`Configuration file found: ${relativeOutputPath}.`);\n } else {\n console.warn(\n `Multiple configuration files found, using ${relativeOutputPath}.`\n );\n }\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAyB;AAEzB,sCAAyC;AACzC,mCAAsC;AACtC,qCAAwC;AAExC,IAAI;AACJ,IAAI;AACJ,IAAI;AAOJ,MAAM,gBAAgB,QAAQ,IAAI,0BAA0B,QAAQ,IAAI;AACxE,MAAM,iBAA0C;AAAA,EAC9C,SAAS;AAAA,EACT,SAAS;AACX;AAEO,MAAM,mBAAmB,CAC9B,YACmB;AACnB,QAAM,gBAAgB,EAAE,GAAG,gBAAgB,GAAG,QAAQ;AACtD,QAAM,EAAE,SAAS,QAAQ,IAAI;AAE7B,MAAI,CAAC,qBAAqB;AAExB,UAAM,EAAE,uBAAuB,uBAAuB,QACpD,wDAAwB,OAAO;AAGjC,QAAI;AACJ,QAAI,uBAAuB;AACzB,gCAAsB,oDAAsB,qBAAqB;AAAA,IACnE;AAGA,8BAAsB;AAAA,MACpB;AAAA,MACA;AAAA,IACF;AACA,kCAA8B;AAC9B,mCAA+B;AAAA,EACjC;AAGA,MAAI;AACF;AAAA,MACE;AAAA,MACA;AAAA,IACF;AAEF,SAAO;AACT;AAEA,MAAM,sBAAsB,CAC1B,wBACA,0BACG;AACH,MAAI,2BAA2B,GAAG;AAChC,YAAQ,KAAK,4DAA4D;AAAA,EAC3E,OAAO;AACL,UAAM,yBAAqB,sBAAS,eAAe,qBAAsB;AAEzE,QAAI,2BAA2B,GAAG;AAChC,cAAQ,KAAK,6BAA6B,kBAAkB,GAAG;AAAA,IACjE,OAAO;AACL,cAAQ;AAAA,QACN,6CAA6C,kBAAkB;AAAA,MACjE;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/configFile/getConfiguration.ts"],"sourcesContent":["import { relative } from 'path';\nimport type { CustomIntlayerConfig, IntlayerConfig } from '../types/config';\nimport { buildConfigurationFields } from './buildConfigurationFields';\nimport { loadConfigurationFile } from './loadConfigurationFile';\nimport { searchConfigurationFile } from './searchConfigurationFile';\n\nlet storedConfiguration: IntlayerConfig | undefined;\nlet storedConfigurationFilePath: string | undefined;\nlet storedNumCustomConfiguration: number | undefined;\n\nexport type GetConfigurationOptions = {\n baseDir: string;\n verbose: boolean;\n};\n\nconst BASE_DIR_PATH = process.env.INTLAYER_BASE_DIR_PATH ?? process.cwd();\nconst defaultOptions: GetConfigurationOptions = {\n baseDir: BASE_DIR_PATH,\n verbose: false,\n};\n\nexport const getConfiguration = (\n options?: Partial<GetConfigurationOptions>\n): IntlayerConfig => {\n const mergedOptions = { ...defaultOptions, ...options };\n const { baseDir, verbose } = mergedOptions;\n\n if (!storedConfiguration) {\n // Search for configuration files\n const { configurationFilePath, numCustomConfiguration } =\n searchConfigurationFile(baseDir);\n\n // Load the custom configuration\n let customConfiguration: CustomIntlayerConfig | undefined;\n if (configurationFilePath) {\n customConfiguration = loadConfigurationFile(configurationFilePath);\n }\n\n // Save the configuration to avoid reading the file again\n storedConfiguration = buildConfigurationFields(\n mergedOptions,\n customConfiguration\n );\n storedConfigurationFilePath = configurationFilePath;\n storedNumCustomConfiguration = numCustomConfiguration;\n }\n\n // Log warning if multiple configuration files are found\n if (verbose)\n logConfigFileResult(\n storedNumCustomConfiguration,\n storedConfigurationFilePath\n );\n\n return storedConfiguration;\n};\n\nconst logConfigFileResult = (\n numCustomConfiguration?: number,\n configurationFilePath?: string\n) => {\n if (numCustomConfiguration === 0) {\n console.info('Configuration file not found, using default configuration.');\n } else {\n const relativeOutputPath = relative(BASE_DIR_PATH, configurationFilePath!);\n\n if (numCustomConfiguration === 1) {\n console.info(`Configuration file found: ${relativeOutputPath}.`);\n } else {\n console.warn(\n `Multiple configuration files found, using ${relativeOutputPath}.`\n );\n }\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAyB;AAEzB,sCAAyC;AACzC,mCAAsC;AACtC,qCAAwC;AAExC,IAAI;AACJ,IAAI;AACJ,IAAI;AAOJ,MAAM,gBAAgB,QAAQ,IAAI,0BAA0B,QAAQ,IAAI;AACxE,MAAM,iBAA0C;AAAA,EAC9C,SAAS;AAAA,EACT,SAAS;AACX;AAEO,MAAM,mBAAmB,CAC9B,YACmB;AACnB,QAAM,gBAAgB,EAAE,GAAG,gBAAgB,GAAG,QAAQ;AACtD,QAAM,EAAE,SAAS,QAAQ,IAAI;AAE7B,MAAI,CAAC,qBAAqB;AAExB,UAAM,EAAE,uBAAuB,uBAAuB,QACpD,wDAAwB,OAAO;AAGjC,QAAI;AACJ,QAAI,uBAAuB;AACzB,gCAAsB,oDAAsB,qBAAqB;AAAA,IACnE;AAGA,8BAAsB;AAAA,MACpB;AAAA,MACA;AAAA,IACF;AACA,kCAA8B;AAC9B,mCAA+B;AAAA,EACjC;AAGA,MAAI;AACF;AAAA,MACE;AAAA,MACA;AAAA,IACF;AAEF,SAAO;AACT;AAEA,MAAM,sBAAsB,CAC1B,wBACA,0BACG;AACH,MAAI,2BAA2B,GAAG;AAChC,YAAQ,KAAK,4DAA4D;AAAA,EAC3E,OAAO;AACL,UAAM,yBAAqB,sBAAS,eAAe,qBAAsB;AAEzE,QAAI,2BAA2B,GAAG;AAChC,cAAQ,KAAK,6BAA6B,kBAAkB,GAAG;AAAA,IACjE,OAAO;AACL,cAAQ;AAAA,QACN,6CAA6C,kBAAkB;AAAA,MACjE;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -1,12 +1,10 @@
1
- import { IntlayerConfig } from "../types/index.js";
2
- import "../defaultValues/locales.js";
1
+ import { IntlayerConfig } from '../types/config.js';
2
+ import '../types/locales.js';
3
3
 
4
4
  type GetConfigurationOptions = {
5
- baseDir: string;
6
- verbose: boolean;
5
+ baseDir: string;
6
+ verbose: boolean;
7
7
  };
8
- declare const getConfiguration: (
9
- options?: Partial<GetConfigurationOptions>
10
- ) => IntlayerConfig;
8
+ declare const getConfiguration: (options?: Partial<GetConfigurationOptions>) => IntlayerConfig;
11
9
 
12
10
  export { type GetConfigurationOptions, getConfiguration };
@@ -4,32 +4,20 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
6
  var __copyProps = (to, from, except, desc) => {
7
- if ((from && typeof from === "object") || typeof from === "function") {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
8
  for (let key of __getOwnPropNames(from))
9
9
  if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, {
11
- get: () => from[key],
12
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
13
- });
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
11
  }
15
12
  return to;
16
13
  };
17
- var __reExport = (target, mod, secondTarget) => (
18
- __copyProps(target, mod, "default"),
19
- secondTarget && __copyProps(secondTarget, mod, "default")
20
- );
21
- var __toCommonJS = (mod) =>
22
- __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
16
  var configFile_exports = {};
24
17
  module.exports = __toCommonJS(configFile_exports);
25
- __reExport(
26
- configFile_exports,
27
- require("./getConfiguration.cjs"),
28
- module.exports
29
- );
18
+ __reExport(configFile_exports, require('./getConfiguration.cjs'), module.exports);
30
19
  // Annotate the CommonJS export names for ESM import in node:
31
- 0 &&
32
- (module.exports = {
33
- ...require("./getConfiguration.cjs"),
34
- });
35
- //# sourceMappingURL=index.cjs.map
20
+ 0 && (module.exports = {
21
+ ...require('./getConfiguration.cjs')
22
+ });
23
+ //# sourceMappingURL=index.cjs.map
@@ -1,6 +1,3 @@
1
- export {
2
- GetConfigurationOptions,
3
- getConfiguration,
4
- } from "./getConfiguration.js";
5
- import "../types/index.js";
6
- import "../defaultValues/locales.js";
1
+ export { GetConfigurationOptions, getConfiguration } from './getConfiguration.js';
2
+ import '../types/config.js';
3
+ import '../types/locales.js';
@@ -8,21 +8,17 @@ var __export = (target, all) => {
8
8
  __defProp(target, name, { get: all[name], enumerable: true });
9
9
  };
10
10
  var __copyProps = (to, from, except, desc) => {
11
- if ((from && typeof from === "object") || typeof from === "function") {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
12
  for (let key of __getOwnPropNames(from))
13
13
  if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, {
15
- get: () => from[key],
16
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
17
- });
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
15
  }
19
16
  return to;
20
17
  };
21
- var __toCommonJS = (mod) =>
22
- __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
19
  var loadConfigurationFile_exports = {};
24
20
  __export(loadConfigurationFile_exports, {
25
- loadConfigurationFile: () => loadConfigurationFile,
21
+ loadConfigurationFile: () => loadConfigurationFile
26
22
  });
27
23
  module.exports = __toCommonJS(loadConfigurationFile_exports);
28
24
  var import_module = require("module");
@@ -32,15 +28,13 @@ const import_meta = {};
32
28
  const isESModule = typeof import_meta.url === "string";
33
29
  const sandboxContext = {
34
30
  exports: {
35
- default: {},
31
+ default: {}
36
32
  },
37
33
  module: {
38
- exports: {},
34
+ exports: {}
39
35
  },
40
36
  console,
41
- require: isESModule
42
- ? (0, import_module.createRequire)(import_meta.url)
43
- : require,
37
+ require: isESModule ? (0, import_module.createRequire)(import_meta.url) : require
44
38
  };
45
39
  const transformationOption = {
46
40
  loader: {
@@ -50,14 +44,14 @@ const transformationOption = {
50
44
  ".ts": "ts",
51
45
  ".tsx": "tsx",
52
46
  ".cjs": "js",
53
- ".json": "json",
47
+ ".json": "json"
54
48
  },
55
49
  format: "cjs",
56
50
  // Output format as commonjs
57
51
  target: "es2017",
58
52
  packages: "external",
59
53
  write: false,
60
- bundle: true,
54
+ bundle: true
61
55
  };
62
56
  const loadConfigurationFile = (configFilePath) => {
63
57
  let customConfiguration = void 0;
@@ -68,7 +62,7 @@ const loadConfigurationFile = (configFilePath) => {
68
62
  }
69
63
  const moduleResult = (0, import_esbuild.buildSync)({
70
64
  entryPoints: [configFilePath],
71
- ...transformationOption,
65
+ ...transformationOption
72
66
  });
73
67
  const moduleResultString = moduleResult.outputFiles?.[0].text;
74
68
  if (!moduleResultString) {
@@ -76,25 +70,13 @@ const loadConfigurationFile = (configFilePath) => {
76
70
  return void 0;
77
71
  }
78
72
  (0, import_vm.runInNewContext)(moduleResultString, sandboxContext);
79
- if (
80
- sandboxContext.exports.default &&
81
- Object.keys(sandboxContext.exports.default).length > 0
82
- ) {
73
+ if (sandboxContext.exports.default && Object.keys(sandboxContext.exports.default).length > 0) {
83
74
  customConfiguration = sandboxContext.exports.default;
84
- } else if (
85
- sandboxContext.module.exports.defaults &&
86
- Object.keys(sandboxContext.module.exports.defaults).length > 0
87
- ) {
75
+ } else if (sandboxContext.module.exports.defaults && Object.keys(sandboxContext.module.exports.defaults).length > 0) {
88
76
  customConfiguration = sandboxContext.module.exports.default;
89
- } else if (
90
- sandboxContext.module.exports.default &&
91
- Object.keys(sandboxContext.module.exports.default).length > 0
92
- ) {
77
+ } else if (sandboxContext.module.exports.default && Object.keys(sandboxContext.module.exports.default).length > 0) {
93
78
  customConfiguration = sandboxContext.module.exports.default;
94
- } else if (
95
- sandboxContext.module.exports &&
96
- Object.keys(sandboxContext.module.exports).length > 0
97
- ) {
79
+ } else if (sandboxContext.module.exports && Object.keys(sandboxContext.module.exports).length > 0) {
98
80
  customConfiguration = sandboxContext.module.exports;
99
81
  }
100
82
  return customConfiguration;
@@ -103,8 +85,7 @@ const loadConfigurationFile = (configFilePath) => {
103
85
  }
104
86
  };
105
87
  // Annotate the CommonJS export names for ESM import in node:
106
- 0 &&
107
- (module.exports = {
108
- loadConfigurationFile,
109
- });
110
- //# sourceMappingURL=loadConfigurationFile.cjs.map
88
+ 0 && (module.exports = {
89
+ loadConfigurationFile
90
+ });
91
+ //# sourceMappingURL=loadConfigurationFile.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/configFile/loadConfigurationFile.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-var-requires */\nimport { createRequire } from 'module';\nimport { type Context, runInNewContext } from 'vm';\nimport { type BuildOptions, buildSync, type BuildResult } from 'esbuild';\nimport type { CustomIntlayerConfig } from '../types';\n\nconst isESModule = typeof import.meta.url === 'string';\n\nconst sandboxContext: Context = {\n exports: {\n default: {},\n },\n module: {\n exports: {},\n },\n console,\n require: isESModule ? createRequire(import.meta.url) : require,\n};\n\nconst transformationOption: BuildOptions = {\n loader: {\n '.js': 'js',\n '.jsx': 'jsx',\n '.mjs': 'js',\n '.ts': 'ts',\n '.tsx': 'tsx',\n '.cjs': 'js',\n '.json': 'json',\n },\n format: 'cjs', // Output format as commonjs\n target: 'es2017',\n packages: 'external',\n write: false,\n bundle: true,\n};\n\nexport const loadConfigurationFile = (\n configFilePath: string\n): CustomIntlayerConfig | undefined => {\n let customConfiguration: CustomIntlayerConfig | undefined = undefined;\n\n const configFileExtension = configFilePath.split('.').pop() ?? '';\n\n try {\n if (configFileExtension === 'json') {\n // Assume JSON\n return require(configFilePath);\n }\n\n // Rest is JS, MJS or TS\n\n const moduleResult: BuildResult = buildSync({\n entryPoints: [configFilePath],\n\n ...transformationOption,\n });\n\n const moduleResultString = moduleResult.outputFiles?.[0].text;\n\n if (!moduleResultString) {\n console.error('Configuration file could not be loaded.');\n return undefined;\n }\n\n runInNewContext(moduleResultString, sandboxContext);\n\n if (\n sandboxContext.exports.default &&\n Object.keys(sandboxContext.exports.default).length > 0\n ) {\n // ES Module\n customConfiguration = sandboxContext.exports.default;\n } else if (\n sandboxContext.module.exports.defaults &&\n Object.keys(sandboxContext.module.exports.defaults).length > 0\n ) {\n // CommonJS\n customConfiguration = sandboxContext.module.exports.default;\n } else if (\n sandboxContext.module.exports.default &&\n Object.keys(sandboxContext.module.exports.default).length > 0\n ) {\n // ES Module\n customConfiguration = sandboxContext.module.exports.default;\n } else if (\n sandboxContext.module.exports &&\n Object.keys(sandboxContext.module.exports).length > 0\n ) {\n // Other\n customConfiguration = sandboxContext.module.exports;\n }\n\n return customConfiguration;\n } catch (error) {\n console.error('Error:', error);\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA8B;AAC9B,gBAA8C;AAC9C,qBAA+D;AAH/D;AAMA,MAAM,aAAa,OAAO,YAAY,QAAQ;AAE9C,MAAM,iBAA0B;AAAA,EAC9B,SAAS;AAAA,IACP,SAAS,CAAC;AAAA,EACZ;AAAA,EACA,QAAQ;AAAA,IACN,SAAS,CAAC;AAAA,EACZ;AAAA,EACA;AAAA,EACA,SAAS,iBAAa,6BAAc,YAAY,GAAG,IAAI;AACzD;AAEA,MAAM,uBAAqC;AAAA,EACzC,QAAQ;AAAA,IACN,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AAAA,EACA,QAAQ;AAAA;AAAA,EACR,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,OAAO;AAAA,EACP,QAAQ;AACV;AAEO,MAAM,wBAAwB,CACnC,mBACqC;AACrC,MAAI,sBAAwD;AAE5D,QAAM,sBAAsB,eAAe,MAAM,GAAG,EAAE,IAAI,KAAK;AAE/D,MAAI;AACF,QAAI,wBAAwB,QAAQ;AAElC,aAAO,QAAQ,cAAc;AAAA,IAC/B;AAIA,UAAM,mBAA4B,0BAAU;AAAA,MAC1C,aAAa,CAAC,cAAc;AAAA,MAE5B,GAAG;AAAA,IACL,CAAC;AAED,UAAM,qBAAqB,aAAa,cAAc,CAAC,EAAE;AAEzD,QAAI,CAAC,oBAAoB;AACvB,cAAQ,MAAM,yCAAyC;AACvD,aAAO;AAAA,IACT;AAEA,mCAAgB,oBAAoB,cAAc;AAElD,QACE,eAAe,QAAQ,WACvB,OAAO,KAAK,eAAe,QAAQ,OAAO,EAAE,SAAS,GACrD;AAEA,4BAAsB,eAAe,QAAQ;AAAA,IAC/C,WACE,eAAe,OAAO,QAAQ,YAC9B,OAAO,KAAK,eAAe,OAAO,QAAQ,QAAQ,EAAE,SAAS,GAC7D;AAEA,4BAAsB,eAAe,OAAO,QAAQ;AAAA,IACtD,WACE,eAAe,OAAO,QAAQ,WAC9B,OAAO,KAAK,eAAe,OAAO,QAAQ,OAAO,EAAE,SAAS,GAC5D;AAEA,4BAAsB,eAAe,OAAO,QAAQ;AAAA,IACtD,WACE,eAAe,OAAO,WACtB,OAAO,KAAK,eAAe,OAAO,OAAO,EAAE,SAAS,GACpD;AAEA,4BAAsB,eAAe,OAAO;AAAA,IAC9C;AAEA,WAAO;AAAA,EACT,SAAS,OAAO;AACd,YAAQ,MAAM,UAAU,KAAK;AAAA,EAC/B;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/configFile/loadConfigurationFile.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-var-requires */\nimport { createRequire } from 'module';\nimport { type Context, runInNewContext } from 'vm';\nimport { type BuildOptions, buildSync, type BuildResult } from 'esbuild';\nimport type { CustomIntlayerConfig } from '../types/config';\n\nconst isESModule = typeof import.meta.url === 'string';\n\nconst sandboxContext: Context = {\n exports: {\n default: {},\n },\n module: {\n exports: {},\n },\n console,\n require: isESModule ? createRequire(import.meta.url) : require,\n};\n\nconst transformationOption: BuildOptions = {\n loader: {\n '.js': 'js',\n '.jsx': 'jsx',\n '.mjs': 'js',\n '.ts': 'ts',\n '.tsx': 'tsx',\n '.cjs': 'js',\n '.json': 'json',\n },\n format: 'cjs', // Output format as commonjs\n target: 'es2017',\n packages: 'external',\n write: false,\n bundle: true,\n};\n\nexport const loadConfigurationFile = (\n configFilePath: string\n): CustomIntlayerConfig | undefined => {\n let customConfiguration: CustomIntlayerConfig | undefined = undefined;\n\n const configFileExtension = configFilePath.split('.').pop() ?? '';\n\n try {\n if (configFileExtension === 'json') {\n // Assume JSON\n return require(configFilePath);\n }\n\n // Rest is JS, MJS or TS\n\n const moduleResult: BuildResult = buildSync({\n entryPoints: [configFilePath],\n\n ...transformationOption,\n });\n\n const moduleResultString = moduleResult.outputFiles?.[0].text;\n\n if (!moduleResultString) {\n console.error('Configuration file could not be loaded.');\n return undefined;\n }\n\n runInNewContext(moduleResultString, sandboxContext);\n\n if (\n sandboxContext.exports.default &&\n Object.keys(sandboxContext.exports.default).length > 0\n ) {\n // ES Module\n customConfiguration = sandboxContext.exports.default;\n } else if (\n sandboxContext.module.exports.defaults &&\n Object.keys(sandboxContext.module.exports.defaults).length > 0\n ) {\n // CommonJS\n customConfiguration = sandboxContext.module.exports.default;\n } else if (\n sandboxContext.module.exports.default &&\n Object.keys(sandboxContext.module.exports.default).length > 0\n ) {\n // ES Module\n customConfiguration = sandboxContext.module.exports.default;\n } else if (\n sandboxContext.module.exports &&\n Object.keys(sandboxContext.module.exports).length > 0\n ) {\n // Other\n customConfiguration = sandboxContext.module.exports;\n }\n\n return customConfiguration;\n } catch (error) {\n console.error('Error:', error);\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA8B;AAC9B,gBAA8C;AAC9C,qBAA+D;AAH/D;AAMA,MAAM,aAAa,OAAO,YAAY,QAAQ;AAE9C,MAAM,iBAA0B;AAAA,EAC9B,SAAS;AAAA,IACP,SAAS,CAAC;AAAA,EACZ;AAAA,EACA,QAAQ;AAAA,IACN,SAAS,CAAC;AAAA,EACZ;AAAA,EACA;AAAA,EACA,SAAS,iBAAa,6BAAc,YAAY,GAAG,IAAI;AACzD;AAEA,MAAM,uBAAqC;AAAA,EACzC,QAAQ;AAAA,IACN,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AAAA,EACA,QAAQ;AAAA;AAAA,EACR,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,OAAO;AAAA,EACP,QAAQ;AACV;AAEO,MAAM,wBAAwB,CACnC,mBACqC;AACrC,MAAI,sBAAwD;AAE5D,QAAM,sBAAsB,eAAe,MAAM,GAAG,EAAE,IAAI,KAAK;AAE/D,MAAI;AACF,QAAI,wBAAwB,QAAQ;AAElC,aAAO,QAAQ,cAAc;AAAA,IAC/B;AAIA,UAAM,mBAA4B,0BAAU;AAAA,MAC1C,aAAa,CAAC,cAAc;AAAA,MAE5B,GAAG;AAAA,IACL,CAAC;AAED,UAAM,qBAAqB,aAAa,cAAc,CAAC,EAAE;AAEzD,QAAI,CAAC,oBAAoB;AACvB,cAAQ,MAAM,yCAAyC;AACvD,aAAO;AAAA,IACT;AAEA,mCAAgB,oBAAoB,cAAc;AAElD,QACE,eAAe,QAAQ,WACvB,OAAO,KAAK,eAAe,QAAQ,OAAO,EAAE,SAAS,GACrD;AAEA,4BAAsB,eAAe,QAAQ;AAAA,IAC/C,WACE,eAAe,OAAO,QAAQ,YAC9B,OAAO,KAAK,eAAe,OAAO,QAAQ,QAAQ,EAAE,SAAS,GAC7D;AAEA,4BAAsB,eAAe,OAAO,QAAQ;AAAA,IACtD,WACE,eAAe,OAAO,QAAQ,WAC9B,OAAO,KAAK,eAAe,OAAO,QAAQ,OAAO,EAAE,SAAS,GAC5D;AAEA,4BAAsB,eAAe,OAAO,QAAQ;AAAA,IACtD,WACE,eAAe,OAAO,WACtB,OAAO,KAAK,eAAe,OAAO,OAAO,EAAE,SAAS,GACpD;AAEA,4BAAsB,eAAe,OAAO;AAAA,IAC9C;AAEA,WAAO;AAAA,EACT,SAAS,OAAO;AACd,YAAQ,MAAM,UAAU,KAAK;AAAA,EAC/B;AACF;","names":[]}