@intlayer/config 8.6.3 → 8.6.4

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 (60) hide show
  1. package/dist/cjs/built.browser.cjs +26 -1
  2. package/dist/cjs/built.browser.cjs.map +1 -1
  3. package/dist/cjs/built.cjs +26 -1
  4. package/dist/cjs/built.cjs.map +1 -1
  5. package/dist/cjs/client.cjs +2 -0
  6. package/dist/cjs/configFile/buildBrowserConfiguration.cjs +1 -10
  7. package/dist/cjs/configFile/buildBrowserConfiguration.cjs.map +1 -1
  8. package/dist/cjs/configFile/buildConfigurationFields.cjs +0 -1
  9. package/dist/cjs/configFile/buildConfigurationFields.cjs.map +1 -1
  10. package/dist/cjs/envVars/envVars.cjs +8 -8
  11. package/dist/cjs/envVars/envVars.cjs.map +1 -1
  12. package/dist/cjs/logger.cjs.map +1 -1
  13. package/dist/cjs/node.cjs +4 -0
  14. package/dist/cjs/utils/getStorageAttributes.cjs +13 -8
  15. package/dist/cjs/utils/getStorageAttributes.cjs.map +1 -1
  16. package/dist/cjs/utils/importMap.cjs +73 -0
  17. package/dist/cjs/utils/importMap.cjs.map +1 -0
  18. package/dist/cjs/utils/index.cjs +6 -0
  19. package/dist/cjs/utils/setIntlayerIdentifier.cjs +14 -0
  20. package/dist/cjs/utils/setIntlayerIdentifier.cjs.map +1 -0
  21. package/dist/esm/built.browser.mjs +13 -1
  22. package/dist/esm/built.browser.mjs.map +1 -1
  23. package/dist/esm/built.mjs +13 -1
  24. package/dist/esm/built.mjs.map +1 -1
  25. package/dist/esm/client.mjs +2 -1
  26. package/dist/esm/configFile/buildBrowserConfiguration.mjs +1 -8
  27. package/dist/esm/configFile/buildBrowserConfiguration.mjs.map +1 -1
  28. package/dist/esm/configFile/buildConfigurationFields.mjs +0 -1
  29. package/dist/esm/configFile/buildConfigurationFields.mjs.map +1 -1
  30. package/dist/esm/envVars/envVars.mjs +8 -8
  31. package/dist/esm/envVars/envVars.mjs.map +1 -1
  32. package/dist/esm/logger.mjs.map +1 -1
  33. package/dist/esm/node.mjs +2 -1
  34. package/dist/esm/utils/getStorageAttributes.mjs +13 -8
  35. package/dist/esm/utils/getStorageAttributes.mjs.map +1 -1
  36. package/dist/esm/utils/importMap.mjs +70 -0
  37. package/dist/esm/utils/importMap.mjs.map +1 -0
  38. package/dist/esm/utils/index.mjs +3 -1
  39. package/dist/esm/utils/setIntlayerIdentifier.mjs +12 -0
  40. package/dist/esm/utils/setIntlayerIdentifier.mjs.map +1 -0
  41. package/dist/types/built.browser.d.ts +15 -1
  42. package/dist/types/built.browser.d.ts.map +1 -1
  43. package/dist/types/built.d.ts +15 -1
  44. package/dist/types/built.d.ts.map +1 -1
  45. package/dist/types/client.d.ts +2 -1
  46. package/dist/types/configFile/buildBrowserConfiguration.d.ts +0 -1
  47. package/dist/types/configFile/buildBrowserConfiguration.d.ts.map +1 -1
  48. package/dist/types/configFile/configurationSchema.d.ts +2 -2
  49. package/dist/types/envVars/envVars.d.ts +1 -1
  50. package/dist/types/envVars/envVars.d.ts.map +1 -1
  51. package/dist/types/logger.d.ts +1 -1
  52. package/dist/types/logger.d.ts.map +1 -1
  53. package/dist/types/node.d.ts +2 -1
  54. package/dist/types/utils/getStorageAttributes.d.ts.map +1 -1
  55. package/dist/types/utils/importMap.d.ts +85 -0
  56. package/dist/types/utils/importMap.d.ts.map +1 -0
  57. package/dist/types/utils/index.d.ts +3 -1
  58. package/dist/types/utils/setIntlayerIdentifier.d.ts +15 -0
  59. package/dist/types/utils/setIntlayerIdentifier.d.ts.map +1 -0
  60. package/package.json +2 -2
@@ -1,3 +1,4 @@
1
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
1
2
 
2
3
  //#region src/built.browser.ts
3
4
  /**
@@ -15,7 +16,31 @@ const configuration = new Proxy({}, {
15
16
  return config != null && prop in config;
16
17
  }
17
18
  });
19
+ const internationalization = configuration.internationalization;
20
+ const dictionary = configuration.dictionary;
21
+ const routing = configuration.routing;
22
+ const content = configuration.content;
23
+ const system = configuration.system;
24
+ const editor = configuration.editor;
25
+ const log = configuration.log;
26
+ const ai = configuration.ai;
27
+ const build = configuration.build;
28
+ const compiler = configuration.compiler;
29
+ const schemas = configuration.schemas;
30
+ const plugins = configuration.plugins;
18
31
 
19
32
  //#endregion
20
- module.exports = configuration;
33
+ exports.ai = ai;
34
+ exports.build = build;
35
+ exports.compiler = compiler;
36
+ exports.content = content;
37
+ exports.default = configuration;
38
+ exports.dictionary = dictionary;
39
+ exports.editor = editor;
40
+ exports.internationalization = internationalization;
41
+ exports.log = log;
42
+ exports.plugins = plugins;
43
+ exports.routing = routing;
44
+ exports.schemas = schemas;
45
+ exports.system = system;
21
46
  //# sourceMappingURL=built.browser.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"built.browser.cjs","names":[],"sources":["../../src/built.browser.ts"],"sourcesContent":["/**\n * @intlayer/config/built — browser build\n *\n * In browser bundles this module is selected automatically via the `browser`\n * export condition in package.json (supported by Vite, webpack, Rollup, etc.).\n *\n * Configuration is resolved at *access time* (lazy) from `window.INTLAYER_CONFIG`\n * so that it works both when:\n *\n * - A build plugin (vite-intlayer / withIntlayer) injects the value via\n * bundler `define` (static replacement at build time), OR\n * - The application calls `installIntlayer(config)` at runtime before any\n * config field is first accessed.\n */\nimport type { IntlayerConfig } from '@intlayer/types/config';\n// This import brings in the `declare global { interface Window { INTLAYER_CONFIG } }` augmentation\nimport type {} from './configFile/buildBrowserConfiguration';\n\n/**\n * Proxy that reads each top-level key from `window.INTLAYER_CONFIG` lazily.\n * This avoids the module-evaluation timing issue: the proxy is safe to import\n * at the top of any file because the actual `window.INTLAYER_CONFIG` value is\n * only read when a property is first accessed.\n */\nconst configuration = new Proxy({} as IntlayerConfig, {\n get(_target, prop: string) {\n const config =\n typeof window !== 'undefined' ? window.INTLAYER_CONFIG : undefined;\n return (config as Record<string, unknown> | undefined)?.[prop];\n },\n has(_target, prop: string) {\n const config =\n typeof window !== 'undefined' ? window.INTLAYER_CONFIG : undefined;\n return config != null && prop in config;\n },\n});\n\nexport default configuration;\n"],"mappings":";;;;;;;;AAwBA,MAAM,gBAAgB,IAAI,MAAM,EAAE,EAAoB;CACpD,IAAI,SAAS,MAAc;AAGzB,UADE,OAAO,WAAW,cAAc,OAAO,kBAAkB,UACF;;CAE3D,IAAI,SAAS,MAAc;EACzB,MAAM,SACJ,OAAO,WAAW,cAAc,OAAO,kBAAkB;AAC3D,SAAO,UAAU,QAAQ,QAAQ;;CAEpC,CAAC"}
1
+ {"version":3,"file":"built.browser.cjs","names":[],"sources":["../../src/built.browser.ts"],"sourcesContent":["/**\n * @intlayer/config/built — browser build\n *\n * In browser bundles this module is selected automatically via the `browser`\n * export condition in package.json (supported by Vite, webpack, Rollup, etc.).\n *\n * Configuration is resolved at *access time* (lazy) from `window.INTLAYER_CONFIG`\n * so that it works both when:\n *\n * - A build plugin (vite-intlayer / withIntlayer) injects the value via\n * bundler `define` (static replacement at build time), OR\n * - The application calls `installIntlayer(config)` at runtime before any\n * config field is first accessed.\n */\nimport type { IntlayerConfig } from '@intlayer/types/config';\n// This import brings in the `declare global { interface Window { INTLAYER_CONFIG } }` augmentation\nimport type {} from './configFile/buildBrowserConfiguration';\n\n/**\n * Proxy that reads each top-level key from `window.INTLAYER_CONFIG` lazily.\n * This avoids the module-evaluation timing issue: the proxy is safe to import\n * at the top of any file because the actual `window.INTLAYER_CONFIG` value is\n * only read when a property is first accessed.\n */\nconst configuration = new Proxy({} as IntlayerConfig, {\n get(_target, prop: string) {\n const config =\n typeof window !== 'undefined' ? window.INTLAYER_CONFIG : undefined;\n return (config as Record<string, unknown> | undefined)?.[prop];\n },\n has(_target, prop: string) {\n const config =\n typeof window !== 'undefined' ? window.INTLAYER_CONFIG : undefined;\n return config != null && prop in config;\n },\n});\n\nexport const internationalization = configuration.internationalization;\nexport const dictionary = configuration.dictionary;\nexport const routing = configuration.routing;\nexport const content = configuration.content;\nexport const system = configuration.system;\nexport const editor = configuration.editor;\nexport const log = configuration.log;\nexport const ai = configuration.ai;\nexport const build = configuration.build;\nexport const compiler = configuration.compiler;\nexport const schemas = configuration.schemas;\nexport const plugins = configuration.plugins;\n\nexport default configuration;\n"],"mappings":";;;;;;;;;AAwBA,MAAM,gBAAgB,IAAI,MAAM,EAAE,EAAoB;CACpD,IAAI,SAAS,MAAc;AAGzB,UADE,OAAO,WAAW,cAAc,OAAO,kBAAkB,UACF;;CAE3D,IAAI,SAAS,MAAc;EACzB,MAAM,SACJ,OAAO,WAAW,cAAc,OAAO,kBAAkB;AAC3D,SAAO,UAAU,QAAQ,QAAQ;;CAEpC,CAAC;AAEF,MAAa,uBAAuB,cAAc;AAClD,MAAa,aAAa,cAAc;AACxC,MAAa,UAAU,cAAc;AACrC,MAAa,UAAU,cAAc;AACrC,MAAa,SAAS,cAAc;AACpC,MAAa,SAAS,cAAc;AACpC,MAAa,MAAM,cAAc;AACjC,MAAa,KAAK,cAAc;AAChC,MAAa,QAAQ,cAAc;AACnC,MAAa,WAAW,cAAc;AACtC,MAAa,UAAU,cAAc;AACrC,MAAa,UAAU,cAAc"}
@@ -1,8 +1,33 @@
1
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
1
2
  const require_configFile_getConfiguration = require('./configFile/getConfiguration.cjs');
2
3
 
3
4
  //#region src/built.ts
4
5
  const configuration = require_configFile_getConfiguration.getConfiguration();
6
+ const internationalization = configuration.internationalization;
7
+ const dictionary = configuration.dictionary;
8
+ const routing = configuration.routing;
9
+ const content = configuration.content;
10
+ const system = configuration.system;
11
+ const editor = configuration.editor;
12
+ const log = configuration.log;
13
+ const ai = configuration.ai;
14
+ const build = configuration.build;
15
+ const compiler = configuration.compiler;
16
+ const schemas = configuration.schemas;
17
+ const plugins = configuration.plugins;
5
18
 
6
19
  //#endregion
7
- module.exports = configuration;
20
+ exports.ai = ai;
21
+ exports.build = build;
22
+ exports.compiler = compiler;
23
+ exports.content = content;
24
+ exports.default = configuration;
25
+ exports.dictionary = dictionary;
26
+ exports.editor = editor;
27
+ exports.internationalization = internationalization;
28
+ exports.log = log;
29
+ exports.plugins = plugins;
30
+ exports.routing = routing;
31
+ exports.schemas = schemas;
32
+ exports.system = system;
8
33
  //# sourceMappingURL=built.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"built.cjs","names":["getConfiguration"],"sources":["../../src/built.ts"],"sourcesContent":["/**\n * @intlayer/config/built is a package that only returns the configuration file as a JSON object.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n */\n\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { getConfiguration } from './configFile/getConfiguration';\n\nconst configuration: IntlayerConfig = getConfiguration();\n\nexport default configuration;\n"],"mappings":";;;AAQA,MAAM,gBAAgCA,sDAAkB"}
1
+ {"version":3,"file":"built.cjs","names":["getConfiguration"],"sources":["../../src/built.ts"],"sourcesContent":["/**\n * @intlayer/config/built is a package that only returns the configuration file as a JSON object.\n * Using an external package allow to alias it in the bundle configuration (such as webpack).\n */\n\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { getConfiguration } from './configFile/getConfiguration';\n\nconst configuration: IntlayerConfig = getConfiguration();\n\nexport const internationalization = configuration.internationalization;\nexport const dictionary = configuration.dictionary;\nexport const routing = configuration.routing;\nexport const content = configuration.content;\nexport const system = configuration.system;\nexport const editor = configuration.editor;\nexport const log = configuration.log;\nexport const ai = configuration.ai;\nexport const build = configuration.build;\nexport const compiler = configuration.compiler;\nexport const schemas = configuration.schemas;\nexport const plugins = configuration.plugins;\n\nexport default configuration;\n"],"mappings":";;;;AAQA,MAAM,gBAAgCA,sDAAkB;AAExD,MAAa,uBAAuB,cAAc;AAClD,MAAa,aAAa,cAAc;AACxC,MAAa,UAAU,cAAc;AACrC,MAAa,UAAU,cAAc;AACrC,MAAa,SAAS,cAAc;AACpC,MAAa,SAAS,cAAc;AACpC,MAAa,MAAM,cAAc;AACjC,MAAa,KAAK,cAAc;AAChC,MAAa,QAAQ,cAAc;AACnC,MAAa,WAAW,cAAc;AACtC,MAAa,UAAU,cAAc;AACrC,MAAa,UAAU,cAAc"}
@@ -2,6 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_utils_normalizePath = require('./utils/normalizePath.cjs');
3
3
  const require_utils_extractErrorMessage = require('./utils/extractErrorMessage.cjs');
4
4
  const require_utils_logStack = require('./utils/logStack.cjs');
5
+ const require_utils_setIntlayerIdentifier = require('./utils/setIntlayerIdentifier.cjs');
5
6
  const require_utils_stringFormatter_camelCaseToKebabCase = require('./utils/stringFormatter/camelCaseToKebabCase.cjs');
6
7
  const require_utils_stringFormatter_camelCaseToSentence = require('./utils/stringFormatter/camelCaseToSentence.cjs');
7
8
  const require_utils_stringFormatter_kebabCaseToCamelCase = require('./utils/stringFormatter/kebabCaseToCamelCase.cjs');
@@ -20,4 +21,5 @@ exports.extractErrorMessage = require_utils_extractErrorMessage.extractErrorMess
20
21
  exports.kebabCaseToCamelCase = require_utils_stringFormatter_kebabCaseToCamelCase.kebabCaseToCamelCase;
21
22
  exports.logStack = require_utils_logStack.logStack;
22
23
  exports.normalizePath = require_utils_normalizePath.normalizePath;
24
+ exports.setIntlayerIdentifier = require_utils_setIntlayerIdentifier.setIntlayerIdentifier;
23
25
  exports.toLowerCamelCase = require_utils_stringFormatter_toLowerCamelCase.toLowerCamelCase;
@@ -1,12 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
2
  const require_defaultValues_routing = require('../defaultValues/routing.cjs');
4
3
  const require_utils_getStorageAttributes = require('../utils/getStorageAttributes.cjs');
5
4
  const require_defaultValues_editor = require('../defaultValues/editor.cjs');
6
5
  const require_defaultValues_internationalization = require('../defaultValues/internationalization.cjs');
7
6
  const require_defaultValues_log = require('../defaultValues/log.cjs');
8
- let _intlayer_types_package_json = require("@intlayer/types/package.json");
9
- _intlayer_types_package_json = require_runtime.__toESM(_intlayer_types_package_json);
10
7
 
11
8
  //#region src/configFile/buildBrowserConfiguration.ts
12
9
  /**
@@ -115,11 +112,6 @@ const buildBrowserConfiguration = (customConfig) => {
115
112
  log: {
116
113
  mode,
117
114
  prefix
118
- },
119
- metadata: {
120
- name: "Intlayer",
121
- version: _intlayer_types_package_json.default.version,
122
- doc: "https://intlayer.org/docs"
123
115
  }
124
116
  };
125
117
  };
@@ -160,8 +152,7 @@ const extractBrowserConfiguration = (config) => ({
160
152
  log: {
161
153
  mode: config.log.mode,
162
154
  prefix: config.log.prefix
163
- },
164
- metadata: config.metadata
155
+ }
165
156
  });
166
157
 
167
158
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"buildBrowserConfiguration.cjs","names":["LOCALES","REQUIRED_LOCALES","DEFAULT_LOCALE","STORAGE","getStorageAttributes","PREFIX","packageJson"],"sources":["../../../src/configFile/buildBrowserConfiguration.ts"],"sourcesContent":["import type {\n CustomIntlayerConfig,\n CustomRoutingConfig,\n EditorConfig,\n InternationalizationConfig,\n IntlayerConfig,\n LogConfig,\n LogFunctions,\n RoutingConfig,\n} from '@intlayer/types/config';\nimport packageJson from '@intlayer/types/package.json' with { type: 'json' };\nimport {\n APPLICATION_URL,\n BACKEND_URL,\n CMS_URL,\n DICTIONARY_PRIORITY_STRATEGY,\n EDITOR_URL,\n IS_ENABLED,\n LIVE_SYNC,\n LIVE_SYNC_PORT,\n PORT,\n} from '../defaultValues/editor';\nimport {\n DEFAULT_LOCALE,\n LOCALES,\n REQUIRED_LOCALES,\n STRICT_MODE,\n} from '../defaultValues/internationalization';\nimport { MODE, PREFIX } from '../defaultValues/log';\nimport { BASE_PATH, ROUTING_MODE, STORAGE } from '../defaultValues/routing';\nimport { getStorageAttributes } from '../utils/getStorageAttributes';\n\n// ---------------------------------------------------------------------------\n// Type\n// ---------------------------------------------------------------------------\n\n/**\n * Browser-safe subset of {@link IntlayerConfig}.\n *\n * Excludes server-only fields (`system`, `content`, `build`, `compiler`,\n * `dictionary`, `ai`) and sensitive editor credentials (`clientId`,\n * `clientSecret`) that must never be shipped to the browser.\n */\nexport type BrowserIntlayerConfig = {\n internationalization: Pick<\n InternationalizationConfig,\n 'locales' | 'defaultLocale'\n >;\n routing: RoutingConfig;\n editor: Omit<EditorConfig, 'clientId' | 'clientSecret'>;\n log: Pick<LogConfig, 'mode' | 'prefix'>;\n metadata: IntlayerConfig['metadata'];\n};\n\ndeclare global {\n interface Window {\n /** Browser-safe Intlayer configuration injected by a build plugin or `installIntlayer`. */\n INTLAYER_CONFIG?: BrowserIntlayerConfig;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Shared field builders (browser-safe — no Node.js APIs)\n//\n// These functions are re-used by both `buildBrowserConfiguration` (browser)\n// and `buildConfigurationFields` (server) to avoid duplication.\n// ---------------------------------------------------------------------------\n\n/**\n * Build the internationalization section of the Intlayer configuration.\n *\n * @param customConfiguration - Partial user-supplied internationalization config.\n * @returns A fully-defaulted {@link InternationalizationConfig}.\n */\nexport const buildInternationalizationFields = (\n customConfiguration?: Partial<InternationalizationConfig>\n): InternationalizationConfig => ({\n /**\n * Locales available in the application\n *\n * Default: ['en']\n *\n */\n locales: customConfiguration?.locales ?? LOCALES,\n\n /**\n * Locales required by TypeScript to ensure strong implementations of internationalized content using typescript.\n *\n * Default: []\n *\n * If empty, all locales are required in `strict` mode.\n *\n * Ensure required locales are also defined in the `locales` field.\n */\n requiredLocales:\n customConfiguration?.requiredLocales ??\n customConfiguration?.locales ??\n REQUIRED_LOCALES,\n\n /**\n * Ensure strong implementations of internationalized content using typescript.\n * - If set to \"strict\", the translation `t` function will require each declared locales to be defined. If one locale is missing, or if a locale is not declared in your config, it will throw an error.\n * - If set to \"inclusive\", the translation `t` function will require each declared locales to be defined. If one locale is missing, it will throw a warning. But will accept if a locale is not declared in your config, but exist.\n * - If set to \"loose\", the translation `t` function will accept any existing locale.\n *\n * Default: \"inclusive\"\n */\n strictMode: customConfiguration?.strictMode ?? STRICT_MODE,\n\n /**\n * Default locale of the application for fallback\n *\n * Default: 'en'\n */\n defaultLocale: customConfiguration?.defaultLocale ?? DEFAULT_LOCALE,\n});\n\n/**\n * Build the routing section of the Intlayer configuration.\n *\n * @param customConfiguration - Partial user-supplied routing config.\n * @returns A fully-defaulted {@link RoutingConfig}.\n */\nexport const buildRoutingFields = (\n customConfiguration?: Partial<CustomRoutingConfig>\n): RoutingConfig => {\n const storage = customConfiguration?.storage ?? STORAGE;\n\n return {\n /**\n * URL routing mode for locale handling\n *\n * Controls how locales are represented in application URLs:\n * - 'prefix-no-default': Prefix all locales except the default locale (default)\n * - en → /dashboard\n * - fr → /fr/dashboard\n *\n * - 'prefix-all': Prefix all locales including the default locale\n * - en → /en/dashboard\n * - fr → /fr/dashboard\n *\n * - 'search-params': Use search parameters for locale handling\n * - en → /dashboard?locale=en\n * - fr → /fr/dashboard?locale=fr\n *\n * - 'no-prefix': No locale prefixing in URLs\n * - en → /dashboard\n * - fr → /dashboard\n *\n * Default: 'prefix-no-default'\n */\n mode: customConfiguration?.mode ?? ROUTING_MODE,\n\n /**\n * Configuration for storing the locale in the client (localStorage or sessionStorage)\n *\n * If false, the locale will not be stored by the middleware.\n * If true, the locale storage will consider all default values. (cookie and header)\n *\n * Default: ['cookie', 'header']\n *\n */\n storage: getStorageAttributes(storage),\n\n /**\n * Base path of the application URL\n *\n * Default: ''\n *\n * Example:\n * - If the application is hosted at https://example.com/my-app\n * - The base path is '/my-app'\n * - The URL will be https://example.com/my-app/en\n * - If the base path is not set, the URL will be https://example.com/en\n */\n basePath: customConfiguration?.basePath ?? BASE_PATH,\n\n /**\n * Custom URL rewriting rules that override the default routing mode for specific paths.\n * Allows you to define locale-specific paths that differ from the standard routing behavior.\n * Supports dynamic route parameters using `[param]` syntax.\n *\n * Default: undefined\n *\n * Example:\n * ```typescript\n * rewrite: {\n * \"/about\": {\n * en: \"/about\",\n * fr: \"/a-propos\",\n * },\n * \"/product/[slug]\": {\n * en: \"/product/[slug]\",\n * fr: \"/produit/[slug]\",\n * },\n * }\n * ```\n *\n * Note:\n * - The rewrite rules take precedence over the default `mode` behavior.\n * - If a path matches a rewrite rule, the localized path from the rewrite configuration will be used.\n * - Dynamic route parameters are supported using bracket notation (e.g., `[slug]`, `[id]`).\n * - Works with both Next.js and Vite applications.\n */\n rewrite: customConfiguration?.rewrite,\n };\n};\n\n/**\n * Build the editor section of the Intlayer configuration.\n *\n * Returns the **full** {@link EditorConfig} including sensitive fields\n * (`clientId`, `clientSecret`). The browser-safe {@link BrowserIntlayerConfig}\n * omits those fields when exposing config to the client.\n *\n * @param customConfiguration - Partial user-supplied editor config.\n * @returns A fully-defaulted {@link EditorConfig}.\n */\nexport const buildEditorFields = (\n customConfiguration?: Partial<EditorConfig>\n): EditorConfig => {\n const liveSyncPort = customConfiguration?.liveSyncPort ?? LIVE_SYNC_PORT;\n return {\n /**\n * URL of the application. Used to restrict the origin of the editor for security reasons.\n *\n * > '*' means that the editor is accessible from any origin\n *\n * Default: '*'\n */\n applicationURL: customConfiguration?.applicationURL || APPLICATION_URL,\n\n /**\n * URL of the editor server. Used to restrict the origin of the editor for security reasons.\n *\n * > '*' means that the editor is accessible from any origin\n *\n * Default: '*'\n */\n editorURL: customConfiguration?.editorURL || EDITOR_URL,\n\n /**\n * URL of the CMS server. Used to restrict the origin of the editor for security reasons.\n */\n cmsURL: customConfiguration?.cmsURL || CMS_URL,\n\n /**\n * URL of the editor server\n *\n * Default: 'https://back.intlayer.org'\n */\n backendURL: customConfiguration?.backendURL || BACKEND_URL,\n\n /** Port of the editor server\n *\n * Default: 8000\n */\n port: customConfiguration?.port ?? PORT,\n\n /**\n * Indicates if the application interact with the visual editor\n *\n * Default: false;\n *\n * If true, the editor will be able to interact with the application.\n * If false, the editor will not be able to interact with the application.\n * In any case, the editor can only be enabled by the visual editor.\n * Disabling the editor for specific environments is a way to enforce the security.\n *\n * Usage:\n * ```js\n * {\n * // Other configurations\n * editor: {\n * enabled: process.env.NODE_ENV !== 'production',\n * }\n * };\n * ```\n */\n enabled: customConfiguration?.enabled ?? IS_ENABLED,\n\n /**\n * clientId and clientSecret allow the intlayer packages to authenticate with the backend using oAuth2 authentication.\n * An access token is use to authenticate the user related to the project.\n * To get an access token, go to https://app.intlayer.org/project and create an account.\n *\n * Default: undefined\n *\n * > Important: The clientId and clientSecret should be kept secret and not shared publicly. Please ensure to keep them in a secure location, such as environment variables.\n */\n clientId: customConfiguration?.clientId ?? undefined,\n\n /**\n * clientId and clientSecret allow the intlayer packages to authenticate with the backend using oAuth2 authentication.\n * An access token is use to authenticate the user related to the project.\n * To get an access token, go to https://app.intlayer.org/project and create an account.\n *\n * Default: undefined\n *\n * > Important: The clientId and clientSecret should be kept secret and not shared publicly. Please ensure to keep them in a secure location, such as environment variables.\n */\n clientSecret: customConfiguration?.clientSecret ?? undefined,\n\n /**\n * Strategy for prioritizing dictionaries. If a dictionary is both present online and locally, the content will be merge.\n * However, is a field is defined in both dictionary, this setting determines which fields takes the priority over the other.\n *\n * Default: 'local_first'\n *\n * The strategy for prioritizing dictionaries. It can be either 'local_first' or 'distant_first'.\n * - 'local_first': The first dictionary found in the locale is used.\n * - 'distant_first': The first dictionary found in the distant locales is used.\n */\n dictionaryPriorityStrategy:\n customConfiguration?.dictionaryPriorityStrategy ??\n DICTIONARY_PRIORITY_STRATEGY,\n\n /**\n * Indicates if the application should hot reload the locale configurations when a change is detected.\n * For example, when a new dictionary is added or updated, the application will update the content tu display in the page.\n *\n * The hot reload is only available for clients of the `enterprise` plan.\n *\n * Default: false\n */\n liveSync: customConfiguration?.liveSync ?? LIVE_SYNC,\n\n /**\n * Port of the live sync server\n *\n * Default: 4000\n */\n liveSyncPort,\n\n /**\n * URL of the live sync server in case of remote live sync server\n *\n * Default: `http://localhost:${LIVE_SYNC_PORT}`\n */\n liveSyncURL:\n customConfiguration?.liveSyncURL ?? `http://localhost:${liveSyncPort}`,\n };\n};\n\n/**\n * Build the log section of the Intlayer configuration.\n *\n * @param customConfiguration - Partial user-supplied log config.\n * @param logFunctions - Optional custom log function overrides (server-only).\n * @returns A fully-defaulted {@link LogConfig}.\n */\nexport const buildLogFields = (\n customConfiguration?: Partial<LogConfig>,\n logFunctions?: LogFunctions\n): LogConfig => ({\n /**\n * Indicates if the logger is enabled\n *\n * Default: 'prefix-no-default'\n *\n * If 'default', the logger is enabled and can be used.\n * If 'verbose', the logger will be enabled and can be used, but will log more information.\n * If 'disabled', the logger is disabled and cannot be used.\n */\n mode: customConfiguration?.mode ?? MODE,\n\n /**\n * Prefix of the logger\n *\n * Default: '[intlayer]'\n *\n * The prefix of the logger.\n */\n prefix: customConfiguration?.prefix ?? PREFIX,\n\n /**\n * Functions to log\n */\n error: logFunctions?.error,\n log: logFunctions?.log,\n info: logFunctions?.info,\n warn: logFunctions?.warn,\n});\n\n// ---------------------------------------------------------------------------\n// Browser configuration builders\n// ---------------------------------------------------------------------------\n\n/**\n * Build a browser-safe {@link BrowserIntlayerConfig} from a raw user config.\n *\n * Applies defaults for every field and strips all server-only or sensitive\n * information (`system`, `content`, `build`, `compiler`, `dictionary`, `ai`,\n * `editor.clientId`, `editor.clientSecret`).\n *\n * This is the browser counterpart of `buildConfigurationFields`. It is safe\n * to call in browser environments because it has no Node.js dependencies.\n *\n * @param customConfig - Optional partial user-supplied Intlayer config.\n * @returns A browser-safe configuration object ready for `window.INTLAYER_CONFIG`.\n *\n * @example\n * ```ts\n * import { buildBrowserConfiguration } from '@intlayer/config/client';\n *\n * window.INTLAYER_CONFIG = buildBrowserConfiguration({\n * internationalization: { locales: ['en', 'fr'], defaultLocale: 'en' },\n * });\n * ```\n */\nexport const buildBrowserConfiguration = (\n customConfig?: CustomIntlayerConfig\n): BrowserIntlayerConfig => {\n const { locales, defaultLocale } = buildInternationalizationFields(\n customConfig?.internationalization\n );\n const routing = buildRoutingFields(customConfig?.routing);\n const {\n clientId: _clientId,\n clientSecret: _clientSecret,\n ...editorPublic\n } = buildEditorFields(customConfig?.editor);\n const { mode, prefix } = buildLogFields(customConfig?.log);\n\n return {\n internationalization: { locales, defaultLocale },\n routing,\n editor: editorPublic,\n log: { mode, prefix },\n metadata: {\n name: 'Intlayer',\n version: packageJson.version,\n doc: 'https://intlayer.org/docs',\n },\n };\n};\n\n/**\n * Extract a {@link BrowserIntlayerConfig} from an already-built full\n * {@link IntlayerConfig}.\n *\n * Used by build plugins (`vite-intlayer`, `withIntlayer`) which already hold\n * the full server-side config and need to inject the browser-safe subset at\n * compile time via a bundler `define`.\n *\n * @param config - A fully-built server-side Intlayer configuration.\n * @returns The browser-safe subset of that configuration.\n */\nexport const extractBrowserConfiguration = (\n config: IntlayerConfig\n): BrowserIntlayerConfig => ({\n internationalization: {\n locales: config.internationalization.locales,\n defaultLocale: config.internationalization.defaultLocale,\n },\n routing: {\n mode: config.routing.mode,\n storage: config.routing.storage,\n basePath: config.routing.basePath,\n rewrite: config.routing.rewrite,\n },\n editor: {\n applicationURL: config.editor.applicationURL,\n editorURL: config.editor.editorURL,\n cmsURL: config.editor.cmsURL,\n backendURL: config.editor.backendURL,\n port: config.editor.port,\n enabled: config.editor.enabled,\n dictionaryPriorityStrategy: config.editor.dictionaryPriorityStrategy,\n liveSync: config.editor.liveSync,\n liveSyncPort: config.editor.liveSyncPort,\n liveSyncURL: config.editor.liveSyncURL,\n },\n log: {\n mode: config.log.mode,\n prefix: config.log.prefix,\n },\n metadata: config.metadata,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;AA0EA,MAAa,mCACX,yBACgC;CAOhC,SAAS,qBAAqB,WAAWA;CAWzC,iBACE,qBAAqB,mBACrB,qBAAqB,WACrBC;CAUF,YAAY,qBAAqB;CAOjC,eAAe,qBAAqB,iBAAiBC;CACtD;;;;;;;AAQD,MAAa,sBACX,wBACkB;CAClB,MAAM,UAAU,qBAAqB,WAAWC;AAEhD,QAAO;EAuBL,MAAM,qBAAqB;EAW3B,SAASC,wDAAqB,QAAQ;EAatC,UAAU,qBAAqB;EA6B/B,SAAS,q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AO;EAC9B,WAAW,OAAO,OAAO;EACzB,QAAQ,OAAO,OAAO;EACtB,YAAY,OAAO,OAAO;EAC1B,MAAM,OAAO,OAAO;EACpB,SAAS,OAAO,OAAO;EACvB,4BAA4B,OAAO,OAAO;EAC1C,UAAU,OAAO,OAAO;EACxB,cAAc,OAAO,OAAO;EAC5B,aAAa,OAAO,OAAO;EAC5B;CACD,KAAK;EACH,MAAM,OAAO,IAAI;EACjB,QAAQ,OAAO,IAAI;EACpB;CACD,UAAU,OAAO;CAClB"}
1
+ {"version":3,"file":"buildBrowserConfiguration.cjs","names":["LOCALES","REQUIRED_LOCALES","DEFAULT_LOCALE","STORAGE","getStorageAttributes","PREFIX"],"sources":["../../../src/configFile/buildBrowserConfiguration.ts"],"sourcesContent":["import type {\n CustomIntlayerConfig,\n CustomRoutingConfig,\n EditorConfig,\n InternationalizationConfig,\n IntlayerConfig,\n LogConfig,\n LogFunctions,\n RoutingConfig,\n} from '@intlayer/types/config';\nimport {\n APPLICATION_URL,\n BACKEND_URL,\n CMS_URL,\n DICTIONARY_PRIORITY_STRATEGY,\n EDITOR_URL,\n IS_ENABLED,\n LIVE_SYNC,\n LIVE_SYNC_PORT,\n PORT,\n} from '../defaultValues/editor';\nimport {\n DEFAULT_LOCALE,\n LOCALES,\n REQUIRED_LOCALES,\n STRICT_MODE,\n} from '../defaultValues/internationalization';\nimport { MODE, PREFIX } from '../defaultValues/log';\nimport { BASE_PATH, ROUTING_MODE, STORAGE } from '../defaultValues/routing';\nimport { getStorageAttributes } from '../utils/getStorageAttributes';\n\n// ---------------------------------------------------------------------------\n// Type\n// ---------------------------------------------------------------------------\n\n/**\n * Browser-safe subset of {@link IntlayerConfig}.\n *\n * Excludes server-only fields (`system`, `content`, `build`, `compiler`,\n * `dictionary`, `ai`) and sensitive editor credentials (`clientId`,\n * `clientSecret`) that must never be shipped to the browser.\n */\nexport type BrowserIntlayerConfig = {\n internationalization: Pick<\n InternationalizationConfig,\n 'locales' | 'defaultLocale'\n >;\n routing: RoutingConfig;\n editor: Omit<EditorConfig, 'clientId' | 'clientSecret'>;\n log: Pick<LogConfig, 'mode' | 'prefix'>;\n};\n\ndeclare global {\n interface Window {\n /** Browser-safe Intlayer configuration injected by a build plugin or `installIntlayer`. */\n INTLAYER_CONFIG?: BrowserIntlayerConfig;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Shared field builders (browser-safe — no Node.js APIs)\n//\n// These functions are re-used by both `buildBrowserConfiguration` (browser)\n// and `buildConfigurationFields` (server) to avoid duplication.\n// ---------------------------------------------------------------------------\n\n/**\n * Build the internationalization section of the Intlayer configuration.\n *\n * @param customConfiguration - Partial user-supplied internationalization config.\n * @returns A fully-defaulted {@link InternationalizationConfig}.\n */\nexport const buildInternationalizationFields = (\n customConfiguration?: Partial<InternationalizationConfig>\n): InternationalizationConfig => ({\n /**\n * Locales available in the application\n *\n * Default: ['en']\n *\n */\n locales: customConfiguration?.locales ?? LOCALES,\n\n /**\n * Locales required by TypeScript to ensure strong implementations of internationalized content using typescript.\n *\n * Default: []\n *\n * If empty, all locales are required in `strict` mode.\n *\n * Ensure required locales are also defined in the `locales` field.\n */\n requiredLocales:\n customConfiguration?.requiredLocales ??\n customConfiguration?.locales ??\n REQUIRED_LOCALES,\n\n /**\n * Ensure strong implementations of internationalized content using typescript.\n * - If set to \"strict\", the translation `t` function will require each declared locales to be defined. If one locale is missing, or if a locale is not declared in your config, it will throw an error.\n * - If set to \"inclusive\", the translation `t` function will require each declared locales to be defined. If one locale is missing, it will throw a warning. But will accept if a locale is not declared in your config, but exist.\n * - If set to \"loose\", the translation `t` function will accept any existing locale.\n *\n * Default: \"inclusive\"\n */\n strictMode: customConfiguration?.strictMode ?? STRICT_MODE,\n\n /**\n * Default locale of the application for fallback\n *\n * Default: 'en'\n */\n defaultLocale: customConfiguration?.defaultLocale ?? DEFAULT_LOCALE,\n});\n\n/**\n * Build the routing section of the Intlayer configuration.\n *\n * @param customConfiguration - Partial user-supplied routing config.\n * @returns A fully-defaulted {@link RoutingConfig}.\n */\nexport const buildRoutingFields = (\n customConfiguration?: Partial<CustomRoutingConfig>\n): RoutingConfig => {\n const storage = customConfiguration?.storage ?? STORAGE;\n\n return {\n /**\n * URL routing mode for locale handling\n *\n * Controls how locales are represented in application URLs:\n * - 'prefix-no-default': Prefix all locales except the default locale (default)\n * - en → /dashboard\n * - fr → /fr/dashboard\n *\n * - 'prefix-all': Prefix all locales including the default locale\n * - en → /en/dashboard\n * - fr → /fr/dashboard\n *\n * - 'search-params': Use search parameters for locale handling\n * - en → /dashboard?locale=en\n * - fr → /fr/dashboard?locale=fr\n *\n * - 'no-prefix': No locale prefixing in URLs\n * - en → /dashboard\n * - fr → /dashboard\n *\n * Default: 'prefix-no-default'\n */\n mode: customConfiguration?.mode ?? ROUTING_MODE,\n\n /**\n * Configuration for storing the locale in the client (localStorage or sessionStorage)\n *\n * If false, the locale will not be stored by the middleware.\n * If true, the locale storage will consider all default values. (cookie and header)\n *\n * Default: ['cookie', 'header']\n *\n */\n storage: getStorageAttributes(storage),\n\n /**\n * Base path of the application URL\n *\n * Default: ''\n *\n * Example:\n * - If the application is hosted at https://example.com/my-app\n * - The base path is '/my-app'\n * - The URL will be https://example.com/my-app/en\n * - If the base path is not set, the URL will be https://example.com/en\n */\n basePath: customConfiguration?.basePath ?? BASE_PATH,\n\n /**\n * Custom URL rewriting rules that override the default routing mode for specific paths.\n * Allows you to define locale-specific paths that differ from the standard routing behavior.\n * Supports dynamic route parameters using `[param]` syntax.\n *\n * Default: undefined\n *\n * Example:\n * ```typescript\n * rewrite: {\n * \"/about\": {\n * en: \"/about\",\n * fr: \"/a-propos\",\n * },\n * \"/product/[slug]\": {\n * en: \"/product/[slug]\",\n * fr: \"/produit/[slug]\",\n * },\n * }\n * ```\n *\n * Note:\n * - The rewrite rules take precedence over the default `mode` behavior.\n * - If a path matches a rewrite rule, the localized path from the rewrite configuration will be used.\n * - Dynamic route parameters are supported using bracket notation (e.g., `[slug]`, `[id]`).\n * - Works with both Next.js and Vite applications.\n */\n rewrite: customConfiguration?.rewrite,\n };\n};\n\n/**\n * Build the editor section of the Intlayer configuration.\n *\n * Returns the **full** {@link EditorConfig} including sensitive fields\n * (`clientId`, `clientSecret`). The browser-safe {@link BrowserIntlayerConfig}\n * omits those fields when exposing config to the client.\n *\n * @param customConfiguration - Partial user-supplied editor config.\n * @returns A fully-defaulted {@link EditorConfig}.\n */\nexport const buildEditorFields = (\n customConfiguration?: Partial<EditorConfig>\n): EditorConfig => {\n const liveSyncPort = customConfiguration?.liveSyncPort ?? LIVE_SYNC_PORT;\n return {\n /**\n * URL of the application. Used to restrict the origin of the editor for security reasons.\n *\n * > '*' means that the editor is accessible from any origin\n *\n * Default: '*'\n */\n applicationURL: customConfiguration?.applicationURL || APPLICATION_URL,\n\n /**\n * URL of the editor server. Used to restrict the origin of the editor for security reasons.\n *\n * > '*' means that the editor is accessible from any origin\n *\n * Default: '*'\n */\n editorURL: customConfiguration?.editorURL || EDITOR_URL,\n\n /**\n * URL of the CMS server. Used to restrict the origin of the editor for security reasons.\n */\n cmsURL: customConfiguration?.cmsURL || CMS_URL,\n\n /**\n * URL of the editor server\n *\n * Default: 'https://back.intlayer.org'\n */\n backendURL: customConfiguration?.backendURL || BACKEND_URL,\n\n /** Port of the editor server\n *\n * Default: 8000\n */\n port: customConfiguration?.port ?? PORT,\n\n /**\n * Indicates if the application interact with the visual editor\n *\n * Default: false;\n *\n * If true, the editor will be able to interact with the application.\n * If false, the editor will not be able to interact with the application.\n * In any case, the editor can only be enabled by the visual editor.\n * Disabling the editor for specific environments is a way to enforce the security.\n *\n * Usage:\n * ```js\n * {\n * // Other configurations\n * editor: {\n * enabled: process.env.NODE_ENV !== 'production',\n * }\n * };\n * ```\n */\n enabled: customConfiguration?.enabled ?? IS_ENABLED,\n\n /**\n * clientId and clientSecret allow the intlayer packages to authenticate with the backend using oAuth2 authentication.\n * An access token is use to authenticate the user related to the project.\n * To get an access token, go to https://app.intlayer.org/project and create an account.\n *\n * Default: undefined\n *\n * > Important: The clientId and clientSecret should be kept secret and not shared publicly. Please ensure to keep them in a secure location, such as environment variables.\n */\n clientId: customConfiguration?.clientId ?? undefined,\n\n /**\n * clientId and clientSecret allow the intlayer packages to authenticate with the backend using oAuth2 authentication.\n * An access token is use to authenticate the user related to the project.\n * To get an access token, go to https://app.intlayer.org/project and create an account.\n *\n * Default: undefined\n *\n * > Important: The clientId and clientSecret should be kept secret and not shared publicly. Please ensure to keep them in a secure location, such as environment variables.\n */\n clientSecret: customConfiguration?.clientSecret ?? undefined,\n\n /**\n * Strategy for prioritizing dictionaries. If a dictionary is both present online and locally, the content will be merge.\n * However, is a field is defined in both dictionary, this setting determines which fields takes the priority over the other.\n *\n * Default: 'local_first'\n *\n * The strategy for prioritizing dictionaries. It can be either 'local_first' or 'distant_first'.\n * - 'local_first': The first dictionary found in the locale is used.\n * - 'distant_first': The first dictionary found in the distant locales is used.\n */\n dictionaryPriorityStrategy:\n customConfiguration?.dictionaryPriorityStrategy ??\n DICTIONARY_PRIORITY_STRATEGY,\n\n /**\n * Indicates if the application should hot reload the locale configurations when a change is detected.\n * For example, when a new dictionary is added or updated, the application will update the content tu display in the page.\n *\n * The hot reload is only available for clients of the `enterprise` plan.\n *\n * Default: false\n */\n liveSync: customConfiguration?.liveSync ?? LIVE_SYNC,\n\n /**\n * Port of the live sync server\n *\n * Default: 4000\n */\n liveSyncPort,\n\n /**\n * URL of the live sync server in case of remote live sync server\n *\n * Default: `http://localhost:${LIVE_SYNC_PORT}`\n */\n liveSyncURL:\n customConfiguration?.liveSyncURL ?? `http://localhost:${liveSyncPort}`,\n };\n};\n\n/**\n * Build the log section of the Intlayer configuration.\n *\n * @param customConfiguration - Partial user-supplied log config.\n * @param logFunctions - Optional custom log function overrides (server-only).\n * @returns A fully-defaulted {@link LogConfig}.\n */\nexport const buildLogFields = (\n customConfiguration?: Partial<LogConfig>,\n logFunctions?: LogFunctions\n): LogConfig => ({\n /**\n * Indicates if the logger is enabled\n *\n * Default: 'prefix-no-default'\n *\n * If 'default', the logger is enabled and can be used.\n * If 'verbose', the logger will be enabled and can be used, but will log more information.\n * If 'disabled', the logger is disabled and cannot be used.\n */\n mode: customConfiguration?.mode ?? MODE,\n\n /**\n * Prefix of the logger\n *\n * Default: '[intlayer]'\n *\n * The prefix of the logger.\n */\n prefix: customConfiguration?.prefix ?? PREFIX,\n\n /**\n * Functions to log\n */\n error: logFunctions?.error,\n log: logFunctions?.log,\n info: logFunctions?.info,\n warn: logFunctions?.warn,\n});\n\n// ---------------------------------------------------------------------------\n// Browser configuration builders\n// ---------------------------------------------------------------------------\n\n/**\n * Build a browser-safe {@link BrowserIntlayerConfig} from a raw user config.\n *\n * Applies defaults for every field and strips all server-only or sensitive\n * information (`system`, `content`, `build`, `compiler`, `dictionary`, `ai`,\n * `editor.clientId`, `editor.clientSecret`).\n *\n * This is the browser counterpart of `buildConfigurationFields`. It is safe\n * to call in browser environments because it has no Node.js dependencies.\n *\n * @param customConfig - Optional partial user-supplied Intlayer config.\n * @returns A browser-safe configuration object ready for `window.INTLAYER_CONFIG`.\n *\n * @example\n * ```ts\n * import { buildBrowserConfiguration } from '@intlayer/config/client';\n *\n * window.INTLAYER_CONFIG = buildBrowserConfiguration({\n * internationalization: { locales: ['en', 'fr'], defaultLocale: 'en' },\n * });\n * ```\n */\nexport const buildBrowserConfiguration = (\n customConfig?: CustomIntlayerConfig\n): BrowserIntlayerConfig => {\n const { locales, defaultLocale } = buildInternationalizationFields(\n customConfig?.internationalization\n );\n const routing = buildRoutingFields(customConfig?.routing);\n const {\n clientId: _clientId,\n clientSecret: _clientSecret,\n ...editorPublic\n } = buildEditorFields(customConfig?.editor);\n const { mode, prefix } = buildLogFields(customConfig?.log);\n\n return {\n internationalization: { locales, defaultLocale },\n routing,\n editor: editorPublic,\n log: { mode, prefix },\n };\n};\n\n/**\n * Extract a {@link BrowserIntlayerConfig} from an already-built full\n * {@link IntlayerConfig}.\n *\n * Used by build plugins (`vite-intlayer`, `withIntlayer`) which already hold\n * the full server-side config and need to inject the browser-safe subset at\n * compile time via a bundler `define`.\n *\n * @param config - A fully-built server-side Intlayer configuration.\n * @returns The browser-safe subset of that configuration.\n */\nexport const extractBrowserConfiguration = (\n config: IntlayerConfig\n): BrowserIntlayerConfig => ({\n internationalization: {\n locales: config.internationalization.locales,\n defaultLocale: config.internationalization.defaultLocale,\n },\n routing: {\n mode: config.routing.mode,\n storage: config.routing.storage,\n basePath: config.routing.basePath,\n rewrite: config.routing.rewrite,\n },\n editor: {\n applicationURL: config.editor.applicationURL,\n editorURL: config.editor.editorURL,\n cmsURL: config.editor.cmsURL,\n backendURL: config.editor.backendURL,\n port: config.editor.port,\n enabled: config.editor.enabled,\n dictionaryPriorityStrategy: config.editor.dictionaryPriorityStrategy,\n liveSync: config.editor.liveSync,\n liveSyncPort: config.editor.liveSyncPort,\n liveSyncURL: config.editor.liveSyncURL,\n },\n log: {\n mode: config.log.mode,\n prefix: config.log.prefix,\n },\n});\n"],"mappings":";;;;;;;;;;;;;;AAwEA,MAAa,mCACX,yBACgC;CAOhC,SAAS,qBAAqB,WAAWA;CAWzC,iBACE,qBAAqB,mBACrB,qBAAqB,WACrBC;CAUF,YAAY,qBAAqB;CAOjC,eAAe,qBAAqB,iBAAiBC;CACtD;;;;;;;AAQD,MAAa,sBACX,wBACkB;CAClB,MAAM,UAAU,qBAAqB,WAAWC;AAEhD,QAAO;EAuBL,MAAM,qBAAqB;EAW3B,SAASC,wDAAqB,QAAQ;EAatC,UAAU,qBAAqB;EA6B/B,SAAS,qBAAqB;EAC/B;;;;;;;;;;;;AAaH,MAAa,qBACX,wBACiB;CACjB,MAAM,eAAe,qBAAqB;AAC1C,QAAO;EAQL,gBAAgB,qBAAqB;EASrC,WAAW,qBAAqB;EAKhC,QAAQ,qBAAqB;EAO7B,YAAY,qBAAqB;EAMjC,MAAM,qBAAqB;EAsB3B,SAAS,qBAAqB;EAW9B,UAAU,qBAAqB,YAAY;EAW3C,cAAc,qBA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 const buildConfigurationFields = (customConfiguration, baseDir, logFunctions) =>
199
199
  const contentConfig = buildContentFields(systemConfig, customConfiguration?.content);
200
200
  storedConfiguration = {
201
201
  routing: browserConfig.routing,
202
- metadata: browserConfig.metadata,
203
202
  internationalization: internationalizationConfig,
204
203
  editor: editorConfig,
205
204
  log: logConfig,
@@ -1 +1 @@
1
- {"version":3,"file":"buildConfigurationFields.cjs","names":["getProjectRequire","FILE_EXTENSIONS","CONTENT_DIR","CODE_DIR","EXCLUDED_PATHS","TRAVERSE_PATTERN","OUTPUT_FORMAT","intlayerConfigSchema","buildBrowserConfiguration","buildInternationalizationFields","buildEditorFields","buildLogFields"],"sources":["../../../src/configFile/buildConfigurationFields.ts"],"sourcesContent":["import { statSync } from 'node:fs';\nimport { dirname, isAbsolute, join } from 'node:path';\nimport type {\n AiConfig,\n BuildConfig,\n CompilerConfig,\n ContentConfig,\n CustomIntlayerConfig,\n DictionaryConfig,\n IntlayerConfig,\n LogFunctions,\n SystemConfig,\n} from '@intlayer/types/config';\nimport {\n BUILD_MODE,\n CACHE,\n OUTPUT_FORMAT,\n TRAVERSE_PATTERN,\n TYPE_CHECKING,\n} from '../defaultValues/build';\nimport {\n COMPILER_DICTIONARY_KEY_PREFIX,\n COMPILER_ENABLED,\n COMPILER_NO_METADATA,\n COMPILER_SAVE_COMPONENTS,\n} from '../defaultValues/compiler';\nimport {\n CODE_DIR,\n CONTENT_DIR,\n EXCLUDED_PATHS,\n FILE_EXTENSIONS,\n WATCH,\n} from '../defaultValues/content';\nimport {\n CONTENT_AUTO_TRANSFORMATION,\n FILL,\n IMPORT_MODE,\n LOCATION,\n} from '../defaultValues/dictionary';\nimport {\n CACHE_DIR,\n CONFIG_DIR,\n DICTIONARIES_DIR,\n DYNAMIC_DICTIONARIES_DIR,\n FETCH_DICTIONARIES_DIR,\n MAIN_DIR,\n MODULE_AUGMENTATION_DIR,\n REMOTE_DICTIONARIES_DIR,\n TEMP_DIR,\n TYPES_DIR,\n UNMERGED_DICTIONARIES_DIR,\n} from '../defaultValues/system';\nimport { getProjectRequire } from '../utils';\nimport {\n buildBrowserConfiguration,\n buildEditorFields,\n buildInternationalizationFields,\n buildLogFields,\n} from './buildBrowserConfiguration';\nimport { intlayerConfigSchema } from './configurationSchema';\n\nexport {\n type BrowserIntlayerConfig,\n buildBrowserConfiguration,\n buildEditorFields,\n buildInternationalizationFields,\n buildLogFields,\n buildRoutingFields,\n extractBrowserConfiguration,\n} from './buildBrowserConfiguration';\n\nlet storedConfiguration: IntlayerConfig;\n\n// ---------------------------------------------------------------------------\n// Server-only field builders (Node.js — not browser-safe)\n// ---------------------------------------------------------------------------\n\n/**\n * Build the `system` section of the Intlayer configuration.\n *\n * Resolves all directory paths (dictionaries, types, cache, …) relative to\n * the project base directory, using Node.js `require.resolve` where available\n * and falling back to `path.join` otherwise.\n *\n * @param baseDir - Project root directory. Defaults to `process.cwd()`.\n * @param customConfiguration - Partial user-supplied system config.\n * @returns A fully-resolved {@link SystemConfig}.\n */\nconst buildSystemFields = (\n baseDir?: string,\n customConfiguration?: Partial<SystemConfig>\n): SystemConfig => {\n const projectBaseDir = baseDir ?? process.cwd();\n\n const optionalJoinBaseDir = (pathInput: string) => {\n let absolutePath: string;\n\n try {\n const requireFunction = getProjectRequire(projectBaseDir);\n absolutePath = requireFunction.resolve(pathInput, {\n paths: [projectBaseDir],\n });\n } catch {\n absolutePath = isAbsolute(pathInput)\n ? pathInput\n : join(projectBaseDir, pathInput);\n }\n\n try {\n const stats = statSync(absolutePath);\n if (stats.isFile()) {\n return dirname(absolutePath);\n }\n } catch {\n if (/\\.[a-z0-9]+$/i.test(absolutePath)) {\n return dirname(absolutePath);\n }\n }\n\n return absolutePath;\n };\n\n const dictionariesDir = optionalJoinBaseDir(\n customConfiguration?.dictionariesDir ?? DICTIONARIES_DIR\n );\n\n return {\n baseDir: projectBaseDir,\n moduleAugmentationDir: optionalJoinBaseDir(\n customConfiguration?.moduleAugmentationDir ?? MODULE_AUGMENTATION_DIR\n ),\n unmergedDictionariesDir: optionalJoinBaseDir(\n customConfiguration?.unmergedDictionariesDir ?? UNMERGED_DICTIONARIES_DIR\n ),\n remoteDictionariesDir: optionalJoinBaseDir(\n customConfiguration?.remoteDictionariesDir ?? REMOTE_DICTIONARIES_DIR\n ),\n dictionariesDir,\n dynamicDictionariesDir: optionalJoinBaseDir(\n customConfiguration?.dynamicDictionariesDir ?? DYNAMIC_DICTIONARIES_DIR\n ),\n fetchDictionariesDir: optionalJoinBaseDir(\n customConfiguration?.fetchDictionariesDir ?? FETCH_DICTIONARIES_DIR\n ),\n typesDir: optionalJoinBaseDir(customConfiguration?.typesDir ?? TYPES_DIR),\n mainDir: optionalJoinBaseDir(customConfiguration?.mainDir ?? MAIN_DIR),\n configDir: optionalJoinBaseDir(\n customConfiguration?.configDir ?? CONFIG_DIR\n ),\n cacheDir: optionalJoinBaseDir(customConfiguration?.cacheDir ?? CACHE_DIR),\n tempDir: optionalJoinBaseDir(customConfiguration?.tempDir ?? TEMP_DIR),\n };\n};\n\n/**\n * Build the `content` section of the Intlayer configuration.\n *\n * Resolves content and code directories relative to the project base using\n * `require.resolve`, falling back to `path.join`.\n *\n * @param systemConfig - Already-built system configuration (provides `baseDir`).\n * @param customConfiguration - Partial user-supplied content config.\n * @returns A fully-resolved {@link ContentConfig}.\n */\nconst buildContentFields = (\n systemConfig: SystemConfig,\n customConfiguration?: Partial<ContentConfig>\n): ContentConfig => {\n const fileExtensions = customConfiguration?.fileExtensions ?? FILE_EXTENSIONS;\n\n const optionalJoinBaseDir = (pathInput: string) => {\n let absolutePath: string;\n\n try {\n const requireFunction = getProjectRequire(systemConfig.baseDir);\n absolutePath = requireFunction.resolve(pathInput, {\n paths: [systemConfig.baseDir],\n });\n } catch {\n try {\n absolutePath = require.resolve(pathInput, {\n paths: [systemConfig.baseDir],\n });\n } catch {\n absolutePath = isAbsolute(pathInput)\n ? pathInput\n : join(systemConfig.baseDir, pathInput);\n }\n }\n\n try {\n const stats = statSync(absolutePath);\n if (stats.isFile()) {\n return dirname(absolutePath);\n }\n } catch {\n if (/\\.[a-z0-9]+$/i.test(absolutePath)) {\n return dirname(absolutePath);\n }\n }\n\n return absolutePath;\n };\n\n const contentDir = (customConfiguration?.contentDir ?? CONTENT_DIR).map(\n optionalJoinBaseDir\n );\n const codeDir = (customConfiguration?.codeDir ?? CODE_DIR).map(\n optionalJoinBaseDir\n );\n\n return {\n fileExtensions,\n contentDir,\n codeDir,\n excludedPath: customConfiguration?.excludedPath ?? EXCLUDED_PATHS,\n watch: customConfiguration?.watch ?? WATCH,\n formatCommand: customConfiguration?.formatCommand,\n };\n};\n\n/**\n * Build the `ai` section of the Intlayer configuration.\n *\n * @param customConfiguration - Partial user-supplied AI config.\n * @returns A fully-defaulted {@link AiConfig}.\n */\nconst buildAiFields = (customConfiguration?: Partial<AiConfig>): AiConfig => ({\n /**\n * AI configuration\n */\n provider: customConfiguration?.provider,\n\n /**\n * API key\n */\n apiKey: customConfiguration?.apiKey,\n\n /**\n * API model\n */\n model: customConfiguration?.model,\n\n /**\n * Temperature\n */\n temperature: customConfiguration?.temperature,\n\n /**\n * Application context\n *\n * Default: undefined\n *\n * The application context.\n *\n * Example: `'My application context'`\n *\n * Note: Can be used to provide additional context about the application to the AI model. You can add more rules (e.g. \"You should not transform urls\").\n */\n applicationContext: customConfiguration?.applicationContext,\n\n /**\n * Base URL for the AI API\n *\n * Default: undefined\n *\n * The base URL for the AI API.\n *\n * Example: `'http://localhost:5000'`\n *\n * Note: Can be used to point to a local, or custom AI API endpoint.\n */\n baseURL: customConfiguration?.baseURL,\n\n /**\n * Data serialization\n *\n * Options:\n * - \"json\": The industry standard. Highly reliable and structured, but consumes more tokens.\n * - \"toon\": An optimized format designed to reduce token consumption (cost-effective). However, it may slightly increase the risk of output inconsistency compared to standard JSON\n *\n * Default: `\"json\"`\n */\n dataSerialization: customConfiguration?.dataSerialization,\n});\n\n/**\n * Build the `build` section of the Intlayer configuration.\n *\n * @param customConfiguration - Partial user-supplied build config.\n * @returns A fully-defaulted {@link BuildConfig}.\n */\nconst buildBuildFields = (\n customConfiguration?: Partial<BuildConfig>\n): BuildConfig => ({\n /**\n * Indicates the mode of the build\n *\n * Default: 'auto'\n *\n * If 'auto', the build will be enabled automatically when the application is built.\n * If 'manual', the build will be set only when the build command is executed.\n *\n * Can be used to disable dictionaries build, for instance when execution on Node.js environment should be avoided.\n */\n mode: customConfiguration?.mode ?? BUILD_MODE,\n\n /**\n * Indicates if the build should be optimized\n *\n * Default: process.env.NODE_ENV === 'production'\n *\n * If true, the build will be optimized.\n * If false, the build will not be optimized.\n *\n * Intlayer will replace all calls of dictionaries to optimize chunking. That way the final bundle will import only the dictionaries that are used.\n * All imports will stay as static import to avoid async processing when loading the dictionaries.\n *\n * Note:\n * - Intlayer will replace all call of `useIntlayer` with the defined mode by the `importMode` option.\n * - Intlayer will replace all call of `getIntlayer` with `getDictionary`.\n * - This option relies on the `@intlayer/babel` and `@intlayer/swc` plugins.\n * - In most cases, \"dynamic\" will be used for React applications, \"async\" for Vue.js applications.\n * - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.\n */\n optimize: customConfiguration?.optimize,\n\n /**\n * Indicates the mode of import to use for the dictionaries.\n *\n * Available modes:\n * - \"static\": The dictionaries are imported statically.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionary`.\n * - \"dynamic\": The dictionaries are imported dynamically in a synchronous component using the suspense API.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.\n * - \"live\": The dictionaries are imported dynamically using the live sync API.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.\n * Live mode will use the live sync API to fetch the dictionaries. If the API call fails, the dictionaries will be imported dynamically as \"dynamic\" mode.\n *\n * Default: \"static\"\n *\n * By default, when a dictionary is loaded, it imports content for all locales as it's imported statically.\n *\n * Note:\n * - Dynamic imports rely on Suspense and may slightly impact rendering performance.\n * - If disabled all locales will be loaded at once, even if they are not used.\n * - This option relies on the `@intlayer/babel` and `@intlayer/swc` plugins.\n * - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.\n * - This option will be ignored if `optimize` is disabled.\n * - This option will not impact the `getIntlayer`, `getDictionary`, `useDictionary`, `useDictionaryAsync` and `useDictionaryDynamic` functions. You can still use them to refine you code on manual optimization.\n * - The \"live\" allows to sync the dictionaries to the live sync server.\n *\n * @deprecated Use `dictionary.importMode` instead.\n */\n importMode: customConfiguration?.importMode,\n\n /**\n * Pattern to traverse the code to optimize.\n *\n * Allows to avoid to traverse the code that is not relevant to the optimization.\n * Improve build performance.\n *\n * Default: ['**\\/*.{js,ts,mjs,cjs,jsx,tsx}', '!**\\/node_modules/**']\n *\n * Example: `['src/**\\/*.{ts,tsx}', '../ui-library/**\\/*.{ts,tsx}']`\n *\n * Note:\n * - This option will be ignored if `optimize` is disabled.\n * - Use glob pattern.\n */\n traversePattern: customConfiguration?.traversePattern ?? TRAVERSE_PATTERN,\n\n /**\n * Output format of the dictionaries\n *\n * Can be set on large projects to improve build performance.\n *\n * Default: ['cjs', 'esm']\n *\n * The output format of the dictionaries. It can be either 'cjs' or 'esm'.\n * - 'cjs': The dictionaries are outputted as CommonJS modules.\n * - 'esm': The dictionaries are outputted as ES modules.\n */\n outputFormat: customConfiguration?.outputFormat ?? OUTPUT_FORMAT,\n\n /**\n * Cache\n */\n cache: customConfiguration?.cache ?? CACHE,\n\n /**\n * Require function\n */\n require: customConfiguration?.require,\n\n /**\n * Indicates if the build should check TypeScript types\n *\n * Default: `false`\n *\n * If true, the build will check TypeScript types and log errors.\n * Note: This can slow down the build.\n */\n checkTypes: customConfiguration?.checkTypes ?? TYPE_CHECKING,\n});\n\n/**\n * Build the `compiler` section of the Intlayer configuration.\n *\n * @param customConfiguration - Partial user-supplied compiler config.\n * @returns A fully-defaulted {@link CompilerConfig}.\n */\nconst buildCompilerFields = (\n customConfiguration?: Partial<CompilerConfig>\n): CompilerConfig => ({\n /**\n * Indicates if the compiler should be enabled\n */\n enabled: customConfiguration?.enabled ?? COMPILER_ENABLED,\n\n /**\n * Prefix for the extracted dictionary keys\n */\n dictionaryKeyPrefix:\n customConfiguration?.dictionaryKeyPrefix ?? COMPILER_DICTIONARY_KEY_PREFIX,\n\n /**\n * Pattern to traverse the code to optimize.\n *\n * @deprecated use `build.traversePattern` instead\n */\n transformPattern: customConfiguration?.transformPattern,\n\n /**\n * Pattern to exclude from the optimization.\n *\n * @deprecated use `build.traversePattern` instead\n */\n excludePattern: customConfiguration?.excludePattern,\n\n /**\n * Defines the output files path. Replaces `outputDir`.\n *\n * - `./` paths are resolved relative to the component directory.\n * - `/` paths are resolved relative to the project root (`baseDir`).\n *\n * - Including the `{{locale}}` variable in the path will trigger the generation of separate dictionaries per locale.\n *\n * @example:\n * ```ts\n * {\n * // Create Multilingual .content.ts files close to the component\n * output: ({ fileName, extension }) => `./${fileName}${extension}`,\n *\n * // output: './{{fileName}}{{extension}}', // Equivalent using template string\n * }\n * ```\n *\n * ```ts\n * {\n * // Create centralize per-locale JSON at the root of the project\n * output: ({ key, locale }) => `/locales/${locale}/${key}.content.json`,\n *\n * // output: '/locales/{{locale}}/{{key}}.content.json', // Equivalent using template string\n * }\n * ```\n *\n * ```ts\n * {\n * // Create per-locale JSON files with locale-specific output paths\n * output: {\n * en: ({ fileName, locale }) => `${fileName}.${locale}.content.json`,\n * fr: '{{fileName}}.{{locale}}.content.json',\n * es: false, // skip this locale\n * },\n * }\n * ```\n *\n * Variable list:\n * - `fileName`: The name of the file.\n * - `key`: The key of the content.\n * - `locale`: The locale of the content.\n * - `extension`: The extension of the file.\n * - `componentFileName`: The name of the component file.\n * - `componentExtension`: The extension of the component file.\n * - `format`: The format of the dictionary.\n * - `componentFormat`: The format of the component dictionary.\n * - `componentDirPath`: The directory path of the component.\n */\n output: customConfiguration?.output,\n\n /**\n * Indicates if the metadata should be saved in the file.\n *\n * If true, the compiler will not save the metadata of the dictionaries.\n *\n * If `true`:\n *\n * ```json\n * {\n * \"key\": \"value\"\n * }\n * ```\n *\n * If `false`:\n *\n * ```json\n * {\n * \"key\": \"value\",\n * \"content\": {\n * \"key\": \"value\"\n * }\n * }\n * ```\n *\n * Default: `false`\n *\n * Note: Useful if used with loadJSON plugin\n */\n noMetadata: customConfiguration?.noMetadata ?? COMPILER_NO_METADATA,\n\n /**\n * Indicates if the components should be saved after being transformed.\n */\n saveComponents:\n customConfiguration?.saveComponents ?? COMPILER_SAVE_COMPONENTS,\n});\n\n/**\n * Build the `dictionary` section of the Intlayer configuration.\n *\n * @param customConfiguration - Partial user-supplied dictionary config.\n * @returns A fully-defaulted {@link DictionaryConfig}.\n */\nconst buildDictionaryFields = (\n customConfiguration?: Partial<DictionaryConfig>\n): DictionaryConfig => {\n const contentAutoTransformation =\n customConfiguration?.contentAutoTransformation ??\n CONTENT_AUTO_TRANSFORMATION;\n\n return {\n /**\n * Indicate how the dictionary should be filled using AI.\n *\n * Default: `true`\n *\n * - If `true`, will consider the `compiler.output` field.\n * - If `false`, will skip the fill process.\n *\n * - `./` paths are resolved relative to the component directory.\n * - `/` paths are resolved relative to the project root (`baseDir`).\n *\n * - If includes `{{locale}}` variable in the path, will trigger the generation of separate dictionaries per locale.\n *\n * Example:\n * ```ts\n * {\n * // Create Multilingual .content.ts files close to the component\n * fill: ({ fileName, extension }) => `./${fileName}${extension}`,\n *\n * // fill: './{{fileName}}{{extension}}', // Equivalent using template string\n * }\n * ```\n *\n * ```ts\n * {\n * // Create centralize per-locale JSON at the root of the project\n * fill: ({ key, locale }) => `/locales/${locale}/${key}.content.json`,\n *\n * // fill: '/locales/{{locale}}/{{key}}.content.json', // Equivalent using template string\n * }\n * ```\n *\n * ```ts\n * {\n * // Create custom output based on the locale\n * fill: {\n * en: ({ key }) => `/locales/en/${key}.content.json`,\n * fr: '/locales/fr/{{key}}.content.json',\n * es: false,\n * de: true,\n * },\n * }\n * ```\n *\n *\n * Variable list:\n * - `fileName`: The name of the file.\n * - `key`: The key of the content.\n * - `locale`: The locale of the content.\n * - `extension`: The extension of the file.\n * - `componentFileName`: The name of the component file.\n * - `componentExtension`: The extension of the component file.\n * - `format`: The format of the dictionary.\n * - `componentFormat`: The format of the component dictionary.\n * - `componentDirPath`: The directory path of the component.\n */\n fill: customConfiguration?.fill ?? FILL,\n\n /**\n * Indicates if the content of the dictionary should be automatically transformed.\n *\n * Default: `false`\n */\n contentAutoTransformation:\n typeof contentAutoTransformation === 'object'\n ? {\n markdown: contentAutoTransformation.markdown ?? false,\n html: contentAutoTransformation.html ?? false,\n insertion: contentAutoTransformation.insertion ?? false,\n }\n : contentAutoTransformation,\n\n /**\n * The location of the dictionary.\n *\n * Default: `\"local\"`\n */\n location: customConfiguration?.location ?? LOCATION,\n\n /**\n * Transform the dictionary in a per-locale dictionary.\n * Each field declared in a per-locale dictionary will be transformed in a translation node.\n * If missing, the dictionary will be treated as a multilingual dictionary.\n */\n locale: customConfiguration?.locale,\n\n /**\n * The title of the dictionary.\n */\n title: customConfiguration?.title,\n\n /**\n * The description of the dictionary.\n */\n description: customConfiguration?.description,\n\n /**\n * Tags to categorize the dictionaries.\n */\n tags: customConfiguration?.tags,\n\n /**\n * The priority of the dictionary.\n */\n priority: customConfiguration?.priority,\n\n /**\n * Indicates the mode of import to use for the dictionary.\n *\n * Available modes:\n * - \"static\": The dictionaries are imported statically.\n * - \"dynamic\": The dictionaries are imported dynamically in a synchronous component using the suspense API.\n * - \"live\": The dictionaries are imported dynamically using the live sync API.\n *\n * Default: `\"static\"`\n */\n importMode: customConfiguration?.importMode ?? IMPORT_MODE,\n };\n};\n\n// ---------------------------------------------------------------------------\n// Main export\n// ---------------------------------------------------------------------------\n\n/**\n * Build the complete Intlayer configuration by merging user-supplied values\n * with defaults.\n *\n * Internally this function:\n * 1. Calls {@link buildBrowserConfiguration} to produce the browser-safe\n * subset (internationalization, routing, editor public fields, log, metadata).\n * 2. Extends the result with full server-side fields:\n * - `internationalization` — adds `requiredLocales` and `strictMode`.\n * - `editor` — adds `clientId` and `clientSecret`.\n * - `log` — adds custom log functions.\n * - `system`, `content`, `ai`, `build`, `compiler`, `dictionary`.\n *\n * @param customConfiguration - Optional user-supplied configuration object.\n * @param baseDir - Project root directory. Defaults to `process.cwd()`.\n * @param logFunctions - Optional custom logging functions.\n * @returns A fully-built {@link IntlayerConfig}.\n */\nexport const buildConfigurationFields = (\n customConfiguration?: CustomIntlayerConfig,\n baseDir?: string,\n logFunctions?: LogFunctions\n): IntlayerConfig => {\n if (customConfiguration) {\n const result = intlayerConfigSchema.safeParse(customConfiguration);\n if (!result.success) {\n const logError = logFunctions?.error ?? console.error;\n for (const issue of result.error.issues) {\n logError(`${issue.path.join('.')}: ${issue.message}`);\n }\n }\n }\n\n // build browser-safe config (shared defaults, no Node.js deps)\n const browserConfig = buildBrowserConfiguration(customConfiguration);\n\n // extend shared fields with server-only additions\n const internationalizationConfig = buildInternationalizationFields(\n customConfiguration?.internationalization\n );\n\n const editorConfig = buildEditorFields(customConfiguration?.editor);\n\n const logConfig = buildLogFields(customConfiguration?.log, logFunctions);\n\n // build server-only fields\n const systemConfig = buildSystemFields(baseDir, customConfiguration?.system);\n\n const contentConfig = buildContentFields(\n systemConfig,\n customConfiguration?.content\n );\n\n storedConfiguration = {\n // Shared browser fields\n routing: browserConfig.routing,\n metadata: browserConfig.metadata,\n // Full (extended) shared fields\n internationalization: internationalizationConfig,\n editor: editorConfig,\n log: logConfig,\n // Server-only fields\n system: systemConfig,\n content: contentConfig,\n ai: buildAiFields(customConfiguration?.ai),\n build: buildBuildFields(customConfiguration?.build),\n compiler: buildCompilerFields(customConfiguration?.compiler),\n dictionary: buildDictionaryFields(customConfiguration?.dictionary),\n plugins: customConfiguration?.plugins,\n schemas: customConfiguration?.schemas,\n } as IntlayerConfig;\n\n return storedConfiguration;\n};\n"],"mappings":";;;;;;;;;;;;;;AAuEA,IAAI;;;;;;;;;;;;AAiBJ,MAAM,qBACJ,SACA,wBACiB;CACjB,MAAM,iBA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EAK3B,UAAU,qBAAqB;EAY/B,YAAY,qBAAqB;EAClC;;;;;;;;;;;;;;;;;;;;AAyBH,MAAa,4BACX,qBACA,SACA,iBACmB;AACnB,KAAI,qBAAqB;EACvB,MAAM,SAASC,4DAAqB,UAAU,oBAAoB;AAClE,MAAI,CAAC,OAAO,SAAS;GACnB,MAAM,WAAW,cAAc,SAAS,QAAQ;AAChD,QAAK,MAAM,SAAS,OAAO,MAAM,OAC/B,UAAS,GAAG,MAAM,KAAK,KAAK,IAAI,CAAC,IAAI,MAAM,UAAU;;;CAM3D,MAAM,gBAAgBC,uEAA0B,oBAAoB;CAGpE,MAAM,6BAA6BC,6EACjC,qBAAqB,qBACtB;CAED,MAAM,eAAeC,+DAAkB,qBAAqB,OAAO;CAEnE,MAAM,YAAYC,4DAAe,qBAAqB,KAAK,aAAa;CAGxE,MAAM,eAAe,kBAAkB,SAAS,qBAAqB,OAAO;CAE5E,MAAM,gBAAgB,mBACpB,cACA,qBAAqB,QACtB;AAED,uBAAsB;EAEpB,SAAS,cAAc;EACvB,UAAU,cAAc;EAExB,sBAAsB;EACtB,QAAQ;EACR,KAAK;EAEL,QAAQ;EACR,SAAS;EACT,IAAI,cAAc,qBAAqB,GAAG;EAC1C,OAAO,iBAAiB,qBAAqB,MAAM;EACnD,UAAU,oBAAoB,qBAAqB,SAAS;EAC5D,YAAY,sBAAsB,qBAAqB,WAAW;EAClE,SAAS,qBAAqB;EAC9B,SAAS,qBAAqB;EAC/B;AAED,QAAO"}
1
+ {"version":3,"file":"buildConfigurationFields.cjs","names":["getProjectRequire","FILE_EXTENSIONS","CONTENT_DIR","CODE_DIR","EXCLUDED_PATHS","TRAVERSE_PATTERN","OUTPUT_FORMAT","intlayerConfigSchema","buildBrowserConfiguration","buildInternationalizationFields","buildEditorFields","buildLogFields"],"sources":["../../../src/configFile/buildConfigurationFields.ts"],"sourcesContent":["import { statSync } from 'node:fs';\nimport { dirname, isAbsolute, join } from 'node:path';\nimport type {\n AiConfig,\n BuildConfig,\n CompilerConfig,\n ContentConfig,\n CustomIntlayerConfig,\n DictionaryConfig,\n IntlayerConfig,\n LogFunctions,\n SystemConfig,\n} from '@intlayer/types/config';\nimport {\n BUILD_MODE,\n CACHE,\n OUTPUT_FORMAT,\n TRAVERSE_PATTERN,\n TYPE_CHECKING,\n} from '../defaultValues/build';\nimport {\n COMPILER_DICTIONARY_KEY_PREFIX,\n COMPILER_ENABLED,\n COMPILER_NO_METADATA,\n COMPILER_SAVE_COMPONENTS,\n} from '../defaultValues/compiler';\nimport {\n CODE_DIR,\n CONTENT_DIR,\n EXCLUDED_PATHS,\n FILE_EXTENSIONS,\n WATCH,\n} from '../defaultValues/content';\nimport {\n CONTENT_AUTO_TRANSFORMATION,\n FILL,\n IMPORT_MODE,\n LOCATION,\n} from '../defaultValues/dictionary';\nimport {\n CACHE_DIR,\n CONFIG_DIR,\n DICTIONARIES_DIR,\n DYNAMIC_DICTIONARIES_DIR,\n FETCH_DICTIONARIES_DIR,\n MAIN_DIR,\n MODULE_AUGMENTATION_DIR,\n REMOTE_DICTIONARIES_DIR,\n TEMP_DIR,\n TYPES_DIR,\n UNMERGED_DICTIONARIES_DIR,\n} from '../defaultValues/system';\nimport { getProjectRequire } from '../utils';\nimport {\n buildBrowserConfiguration,\n buildEditorFields,\n buildInternationalizationFields,\n buildLogFields,\n} from './buildBrowserConfiguration';\nimport { intlayerConfigSchema } from './configurationSchema';\n\nexport {\n type BrowserIntlayerConfig,\n buildBrowserConfiguration,\n buildEditorFields,\n buildInternationalizationFields,\n buildLogFields,\n buildRoutingFields,\n extractBrowserConfiguration,\n} from './buildBrowserConfiguration';\n\nlet storedConfiguration: IntlayerConfig;\n\n// ---------------------------------------------------------------------------\n// Server-only field builders (Node.js — not browser-safe)\n// ---------------------------------------------------------------------------\n\n/**\n * Build the `system` section of the Intlayer configuration.\n *\n * Resolves all directory paths (dictionaries, types, cache, …) relative to\n * the project base directory, using Node.js `require.resolve` where available\n * and falling back to `path.join` otherwise.\n *\n * @param baseDir - Project root directory. Defaults to `process.cwd()`.\n * @param customConfiguration - Partial user-supplied system config.\n * @returns A fully-resolved {@link SystemConfig}.\n */\nconst buildSystemFields = (\n baseDir?: string,\n customConfiguration?: Partial<SystemConfig>\n): SystemConfig => {\n const projectBaseDir = baseDir ?? process.cwd();\n\n const optionalJoinBaseDir = (pathInput: string) => {\n let absolutePath: string;\n\n try {\n const requireFunction = getProjectRequire(projectBaseDir);\n absolutePath = requireFunction.resolve(pathInput, {\n paths: [projectBaseDir],\n });\n } catch {\n absolutePath = isAbsolute(pathInput)\n ? pathInput\n : join(projectBaseDir, pathInput);\n }\n\n try {\n const stats = statSync(absolutePath);\n if (stats.isFile()) {\n return dirname(absolutePath);\n }\n } catch {\n if (/\\.[a-z0-9]+$/i.test(absolutePath)) {\n return dirname(absolutePath);\n }\n }\n\n return absolutePath;\n };\n\n const dictionariesDir = optionalJoinBaseDir(\n customConfiguration?.dictionariesDir ?? DICTIONARIES_DIR\n );\n\n return {\n baseDir: projectBaseDir,\n moduleAugmentationDir: optionalJoinBaseDir(\n customConfiguration?.moduleAugmentationDir ?? MODULE_AUGMENTATION_DIR\n ),\n unmergedDictionariesDir: optionalJoinBaseDir(\n customConfiguration?.unmergedDictionariesDir ?? UNMERGED_DICTIONARIES_DIR\n ),\n remoteDictionariesDir: optionalJoinBaseDir(\n customConfiguration?.remoteDictionariesDir ?? REMOTE_DICTIONARIES_DIR\n ),\n dictionariesDir,\n dynamicDictionariesDir: optionalJoinBaseDir(\n customConfiguration?.dynamicDictionariesDir ?? DYNAMIC_DICTIONARIES_DIR\n ),\n fetchDictionariesDir: optionalJoinBaseDir(\n customConfiguration?.fetchDictionariesDir ?? FETCH_DICTIONARIES_DIR\n ),\n typesDir: optionalJoinBaseDir(customConfiguration?.typesDir ?? TYPES_DIR),\n mainDir: optionalJoinBaseDir(customConfiguration?.mainDir ?? MAIN_DIR),\n configDir: optionalJoinBaseDir(\n customConfiguration?.configDir ?? CONFIG_DIR\n ),\n cacheDir: optionalJoinBaseDir(customConfiguration?.cacheDir ?? CACHE_DIR),\n tempDir: optionalJoinBaseDir(customConfiguration?.tempDir ?? TEMP_DIR),\n };\n};\n\n/**\n * Build the `content` section of the Intlayer configuration.\n *\n * Resolves content and code directories relative to the project base using\n * `require.resolve`, falling back to `path.join`.\n *\n * @param systemConfig - Already-built system configuration (provides `baseDir`).\n * @param customConfiguration - Partial user-supplied content config.\n * @returns A fully-resolved {@link ContentConfig}.\n */\nconst buildContentFields = (\n systemConfig: SystemConfig,\n customConfiguration?: Partial<ContentConfig>\n): ContentConfig => {\n const fileExtensions = customConfiguration?.fileExtensions ?? FILE_EXTENSIONS;\n\n const optionalJoinBaseDir = (pathInput: string) => {\n let absolutePath: string;\n\n try {\n const requireFunction = getProjectRequire(systemConfig.baseDir);\n absolutePath = requireFunction.resolve(pathInput, {\n paths: [systemConfig.baseDir],\n });\n } catch {\n try {\n absolutePath = require.resolve(pathInput, {\n paths: [systemConfig.baseDir],\n });\n } catch {\n absolutePath = isAbsolute(pathInput)\n ? pathInput\n : join(systemConfig.baseDir, pathInput);\n }\n }\n\n try {\n const stats = statSync(absolutePath);\n if (stats.isFile()) {\n return dirname(absolutePath);\n }\n } catch {\n if (/\\.[a-z0-9]+$/i.test(absolutePath)) {\n return dirname(absolutePath);\n }\n }\n\n return absolutePath;\n };\n\n const contentDir = (customConfiguration?.contentDir ?? CONTENT_DIR).map(\n optionalJoinBaseDir\n );\n const codeDir = (customConfiguration?.codeDir ?? CODE_DIR).map(\n optionalJoinBaseDir\n );\n\n return {\n fileExtensions,\n contentDir,\n codeDir,\n excludedPath: customConfiguration?.excludedPath ?? EXCLUDED_PATHS,\n watch: customConfiguration?.watch ?? WATCH,\n formatCommand: customConfiguration?.formatCommand,\n };\n};\n\n/**\n * Build the `ai` section of the Intlayer configuration.\n *\n * @param customConfiguration - Partial user-supplied AI config.\n * @returns A fully-defaulted {@link AiConfig}.\n */\nconst buildAiFields = (customConfiguration?: Partial<AiConfig>): AiConfig => ({\n /**\n * AI configuration\n */\n provider: customConfiguration?.provider,\n\n /**\n * API key\n */\n apiKey: customConfiguration?.apiKey,\n\n /**\n * API model\n */\n model: customConfiguration?.model,\n\n /**\n * Temperature\n */\n temperature: customConfiguration?.temperature,\n\n /**\n * Application context\n *\n * Default: undefined\n *\n * The application context.\n *\n * Example: `'My application context'`\n *\n * Note: Can be used to provide additional context about the application to the AI model. You can add more rules (e.g. \"You should not transform urls\").\n */\n applicationContext: customConfiguration?.applicationContext,\n\n /**\n * Base URL for the AI API\n *\n * Default: undefined\n *\n * The base URL for the AI API.\n *\n * Example: `'http://localhost:5000'`\n *\n * Note: Can be used to point to a local, or custom AI API endpoint.\n */\n baseURL: customConfiguration?.baseURL,\n\n /**\n * Data serialization\n *\n * Options:\n * - \"json\": The industry standard. Highly reliable and structured, but consumes more tokens.\n * - \"toon\": An optimized format designed to reduce token consumption (cost-effective). However, it may slightly increase the risk of output inconsistency compared to standard JSON\n *\n * Default: `\"json\"`\n */\n dataSerialization: customConfiguration?.dataSerialization,\n});\n\n/**\n * Build the `build` section of the Intlayer configuration.\n *\n * @param customConfiguration - Partial user-supplied build config.\n * @returns A fully-defaulted {@link BuildConfig}.\n */\nconst buildBuildFields = (\n customConfiguration?: Partial<BuildConfig>\n): BuildConfig => ({\n /**\n * Indicates the mode of the build\n *\n * Default: 'auto'\n *\n * If 'auto', the build will be enabled automatically when the application is built.\n * If 'manual', the build will be set only when the build command is executed.\n *\n * Can be used to disable dictionaries build, for instance when execution on Node.js environment should be avoided.\n */\n mode: customConfiguration?.mode ?? BUILD_MODE,\n\n /**\n * Indicates if the build should be optimized\n *\n * Default: process.env.NODE_ENV === 'production'\n *\n * If true, the build will be optimized.\n * If false, the build will not be optimized.\n *\n * Intlayer will replace all calls of dictionaries to optimize chunking. That way the final bundle will import only the dictionaries that are used.\n * All imports will stay as static import to avoid async processing when loading the dictionaries.\n *\n * Note:\n * - Intlayer will replace all call of `useIntlayer` with the defined mode by the `importMode` option.\n * - Intlayer will replace all call of `getIntlayer` with `getDictionary`.\n * - This option relies on the `@intlayer/babel` and `@intlayer/swc` plugins.\n * - In most cases, \"dynamic\" will be used for React applications, \"async\" for Vue.js applications.\n * - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.\n */\n optimize: customConfiguration?.optimize,\n\n /**\n * Indicates the mode of import to use for the dictionaries.\n *\n * Available modes:\n * - \"static\": The dictionaries are imported statically.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionary`.\n * - \"dynamic\": The dictionaries are imported dynamically in a synchronous component using the suspense API.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.\n * - \"live\": The dictionaries are imported dynamically using the live sync API.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.\n * Live mode will use the live sync API to fetch the dictionaries. If the API call fails, the dictionaries will be imported dynamically as \"dynamic\" mode.\n *\n * Default: \"static\"\n *\n * By default, when a dictionary is loaded, it imports content for all locales as it's imported statically.\n *\n * Note:\n * - Dynamic imports rely on Suspense and may slightly impact rendering performance.\n * - If disabled all locales will be loaded at once, even if they are not used.\n * - This option relies on the `@intlayer/babel` and `@intlayer/swc` plugins.\n * - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.\n * - This option will be ignored if `optimize` is disabled.\n * - This option will not impact the `getIntlayer`, `getDictionary`, `useDictionary`, `useDictionaryAsync` and `useDictionaryDynamic` functions. You can still use them to refine you code on manual optimization.\n * - The \"live\" allows to sync the dictionaries to the live sync server.\n *\n * @deprecated Use `dictionary.importMode` instead.\n */\n importMode: customConfiguration?.importMode,\n\n /**\n * Pattern to traverse the code to optimize.\n *\n * Allows to avoid to traverse the code that is not relevant to the optimization.\n * Improve build performance.\n *\n * Default: ['**\\/*.{js,ts,mjs,cjs,jsx,tsx}', '!**\\/node_modules/**']\n *\n * Example: `['src/**\\/*.{ts,tsx}', '../ui-library/**\\/*.{ts,tsx}']`\n *\n * Note:\n * - This option will be ignored if `optimize` is disabled.\n * - Use glob pattern.\n */\n traversePattern: customConfiguration?.traversePattern ?? TRAVERSE_PATTERN,\n\n /**\n * Output format of the dictionaries\n *\n * Can be set on large projects to improve build performance.\n *\n * Default: ['cjs', 'esm']\n *\n * The output format of the dictionaries. It can be either 'cjs' or 'esm'.\n * - 'cjs': The dictionaries are outputted as CommonJS modules.\n * - 'esm': The dictionaries are outputted as ES modules.\n */\n outputFormat: customConfiguration?.outputFormat ?? OUTPUT_FORMAT,\n\n /**\n * Cache\n */\n cache: customConfiguration?.cache ?? CACHE,\n\n /**\n * Require function\n */\n require: customConfiguration?.require,\n\n /**\n * Indicates if the build should check TypeScript types\n *\n * Default: `false`\n *\n * If true, the build will check TypeScript types and log errors.\n * Note: This can slow down the build.\n */\n checkTypes: customConfiguration?.checkTypes ?? TYPE_CHECKING,\n});\n\n/**\n * Build the `compiler` section of the Intlayer configuration.\n *\n * @param customConfiguration - Partial user-supplied compiler config.\n * @returns A fully-defaulted {@link CompilerConfig}.\n */\nconst buildCompilerFields = (\n customConfiguration?: Partial<CompilerConfig>\n): CompilerConfig => ({\n /**\n * Indicates if the compiler should be enabled\n */\n enabled: customConfiguration?.enabled ?? COMPILER_ENABLED,\n\n /**\n * Prefix for the extracted dictionary keys\n */\n dictionaryKeyPrefix:\n customConfiguration?.dictionaryKeyPrefix ?? COMPILER_DICTIONARY_KEY_PREFIX,\n\n /**\n * Pattern to traverse the code to optimize.\n *\n * @deprecated use `build.traversePattern` instead\n */\n transformPattern: customConfiguration?.transformPattern,\n\n /**\n * Pattern to exclude from the optimization.\n *\n * @deprecated use `build.traversePattern` instead\n */\n excludePattern: customConfiguration?.excludePattern,\n\n /**\n * Defines the output files path. Replaces `outputDir`.\n *\n * - `./` paths are resolved relative to the component directory.\n * - `/` paths are resolved relative to the project root (`baseDir`).\n *\n * - Including the `{{locale}}` variable in the path will trigger the generation of separate dictionaries per locale.\n *\n * @example:\n * ```ts\n * {\n * // Create Multilingual .content.ts files close to the component\n * output: ({ fileName, extension }) => `./${fileName}${extension}`,\n *\n * // output: './{{fileName}}{{extension}}', // Equivalent using template string\n * }\n * ```\n *\n * ```ts\n * {\n * // Create centralize per-locale JSON at the root of the project\n * output: ({ key, locale }) => `/locales/${locale}/${key}.content.json`,\n *\n * // output: '/locales/{{locale}}/{{key}}.content.json', // Equivalent using template string\n * }\n * ```\n *\n * ```ts\n * {\n * // Create per-locale JSON files with locale-specific output paths\n * output: {\n * en: ({ fileName, locale }) => `${fileName}.${locale}.content.json`,\n * fr: '{{fileName}}.{{locale}}.content.json',\n * es: false, // skip this locale\n * },\n * }\n * ```\n *\n * Variable list:\n * - `fileName`: The name of the file.\n * - `key`: The key of the content.\n * - `locale`: The locale of the content.\n * - `extension`: The extension of the file.\n * - `componentFileName`: The name of the component file.\n * - `componentExtension`: The extension of the component file.\n * - `format`: The format of the dictionary.\n * - `componentFormat`: The format of the component dictionary.\n * - `componentDirPath`: The directory path of the component.\n */\n output: customConfiguration?.output,\n\n /**\n * Indicates if the metadata should be saved in the file.\n *\n * If true, the compiler will not save the metadata of the dictionaries.\n *\n * If `true`:\n *\n * ```json\n * {\n * \"key\": \"value\"\n * }\n * ```\n *\n * If `false`:\n *\n * ```json\n * {\n * \"key\": \"value\",\n * \"content\": {\n * \"key\": \"value\"\n * }\n * }\n * ```\n *\n * Default: `false`\n *\n * Note: Useful if used with loadJSON plugin\n */\n noMetadata: customConfiguration?.noMetadata ?? COMPILER_NO_METADATA,\n\n /**\n * Indicates if the components should be saved after being transformed.\n */\n saveComponents:\n customConfiguration?.saveComponents ?? COMPILER_SAVE_COMPONENTS,\n});\n\n/**\n * Build the `dictionary` section of the Intlayer configuration.\n *\n * @param customConfiguration - Partial user-supplied dictionary config.\n * @returns A fully-defaulted {@link DictionaryConfig}.\n */\nconst buildDictionaryFields = (\n customConfiguration?: Partial<DictionaryConfig>\n): DictionaryConfig => {\n const contentAutoTransformation =\n customConfiguration?.contentAutoTransformation ??\n CONTENT_AUTO_TRANSFORMATION;\n\n return {\n /**\n * Indicate how the dictionary should be filled using AI.\n *\n * Default: `true`\n *\n * - If `true`, will consider the `compiler.output` field.\n * - If `false`, will skip the fill process.\n *\n * - `./` paths are resolved relative to the component directory.\n * - `/` paths are resolved relative to the project root (`baseDir`).\n *\n * - If includes `{{locale}}` variable in the path, will trigger the generation of separate dictionaries per locale.\n *\n * Example:\n * ```ts\n * {\n * // Create Multilingual .content.ts files close to the component\n * fill: ({ fileName, extension }) => `./${fileName}${extension}`,\n *\n * // fill: './{{fileName}}{{extension}}', // Equivalent using template string\n * }\n * ```\n *\n * ```ts\n * {\n * // Create centralize per-locale JSON at the root of the project\n * fill: ({ key, locale }) => `/locales/${locale}/${key}.content.json`,\n *\n * // fill: '/locales/{{locale}}/{{key}}.content.json', // Equivalent using template string\n * }\n * ```\n *\n * ```ts\n * {\n * // Create custom output based on the locale\n * fill: {\n * en: ({ key }) => `/locales/en/${key}.content.json`,\n * fr: '/locales/fr/{{key}}.content.json',\n * es: false,\n * de: true,\n * },\n * }\n * ```\n *\n *\n * Variable list:\n * - `fileName`: The name of the file.\n * - `key`: The key of the content.\n * - `locale`: The locale of the content.\n * - `extension`: The extension of the file.\n * - `componentFileName`: The name of the component file.\n * - `componentExtension`: The extension of the component file.\n * - `format`: The format of the dictionary.\n * - `componentFormat`: The format of the component dictionary.\n * - `componentDirPath`: The directory path of the component.\n */\n fill: customConfiguration?.fill ?? FILL,\n\n /**\n * Indicates if the content of the dictionary should be automatically transformed.\n *\n * Default: `false`\n */\n contentAutoTransformation:\n typeof contentAutoTransformation === 'object'\n ? {\n markdown: contentAutoTransformation.markdown ?? false,\n html: contentAutoTransformation.html ?? false,\n insertion: contentAutoTransformation.insertion ?? false,\n }\n : contentAutoTransformation,\n\n /**\n * The location of the dictionary.\n *\n * Default: `\"local\"`\n */\n location: customConfiguration?.location ?? LOCATION,\n\n /**\n * Transform the dictionary in a per-locale dictionary.\n * Each field declared in a per-locale dictionary will be transformed in a translation node.\n * If missing, the dictionary will be treated as a multilingual dictionary.\n */\n locale: customConfiguration?.locale,\n\n /**\n * The title of the dictionary.\n */\n title: customConfiguration?.title,\n\n /**\n * The description of the dictionary.\n */\n description: customConfiguration?.description,\n\n /**\n * Tags to categorize the dictionaries.\n */\n tags: customConfiguration?.tags,\n\n /**\n * The priority of the dictionary.\n */\n priority: customConfiguration?.priority,\n\n /**\n * Indicates the mode of import to use for the dictionary.\n *\n * Available modes:\n * - \"static\": The dictionaries are imported statically.\n * - \"dynamic\": The dictionaries are imported dynamically in a synchronous component using the suspense API.\n * - \"live\": The dictionaries are imported dynamically using the live sync API.\n *\n * Default: `\"static\"`\n */\n importMode: customConfiguration?.importMode ?? IMPORT_MODE,\n };\n};\n\n// ---------------------------------------------------------------------------\n// Main export\n// ---------------------------------------------------------------------------\n\n/**\n * Build the complete Intlayer configuration by merging user-supplied values\n * with defaults.\n *\n * Internally this function:\n * 1. Calls {@link buildBrowserConfiguration} to produce the browser-safe\n * subset (internationalization, routing, editor public fields, log, metadata).\n * 2. Extends the result with full server-side fields:\n * - `internationalization` — adds `requiredLocales` and `strictMode`.\n * - `editor` — adds `clientId` and `clientSecret`.\n * - `log` — adds custom log functions.\n * - `system`, `content`, `ai`, `build`, `compiler`, `dictionary`.\n *\n * @param customConfiguration - Optional user-supplied configuration object.\n * @param baseDir - Project root directory. Defaults to `process.cwd()`.\n * @param logFunctions - Optional custom logging functions.\n * @returns A fully-built {@link IntlayerConfig}.\n */\nexport const buildConfigurationFields = (\n customConfiguration?: CustomIntlayerConfig,\n baseDir?: string,\n logFunctions?: LogFunctions\n): IntlayerConfig => {\n if (customConfiguration) {\n const result = intlayerConfigSchema.safeParse(customConfiguration);\n\n if (!result.success) {\n const logError = logFunctions?.error ?? console.error;\n\n for (const issue of result.error.issues) {\n logError(`${issue.path.join('.')}: ${issue.message}`);\n }\n }\n }\n\n // build browser-safe config (shared defaults, no Node.js deps)\n const browserConfig = buildBrowserConfiguration(customConfiguration);\n\n // extend shared fields with server-only additions\n const internationalizationConfig = buildInternationalizationFields(\n customConfiguration?.internationalization\n );\n\n const editorConfig = buildEditorFields(customConfiguration?.editor);\n\n const logConfig = buildLogFields(customConfiguration?.log, logFunctions);\n\n // build server-only fields\n const systemConfig = buildSystemFields(baseDir, customConfiguration?.system);\n\n const contentConfig = buildContentFields(\n systemConfig,\n customConfiguration?.content\n );\n\n storedConfiguration = {\n // Shared browser fields\n routing: browserConfig.routing,\n // Full (extended) shared fields\n internationalization: internationalizationConfig,\n editor: editorConfig,\n log: logConfig,\n // Server-only fields\n system: systemConfig,\n content: contentConfig,\n ai: buildAiFields(customConfiguration?.ai),\n build: buildBuildFields(customConfiguration?.build),\n compiler: buildCompilerFields(customConfiguration?.compiler),\n dictionary: buildDictionaryFields(customConfiguration?.dictionary),\n plugins: customConfiguration?.plugins,\n schemas: customConfiguration?.schemas,\n } as IntlayerConfig;\n\n return storedConfiguration;\n};\n"],"mappings":";;;;;;;;;;;;;;AAuEA,IAAI;;;;;;;;;;;;AAiBJ,MAAM,qBACJ,SACA,wBACiB;CACjB,MAAM,iBAAiB,WAAW,QAAQ,KAAK;CAE/C,MAAM,uBAAuB,cAAsB;EACjD,IAAI;AAEJ,MAAI;AAEF,kBADwBA,+CAAkB,eAAe,CAC1B,QAAQ,WAAW,EAChD,OAAO,CAAC,eAAe,EACxB,CAAC;UACI;AACN,4CAA0B,UAAU,GAChC,gCACK,gBAAgB,UAAU;;AAGrC,MAAI;AAEF,6BADuB,aAAa,CAC1B,QAAQ,CAChB,+BAAe,aAAa;UAExB;AACN,OAAI,gBAAgB,KAAK,aAAa,CACpC,+BAAe,aAAa;;AAIhC,SAAO;;CAGT,MAAM,kBAAkB,oBACtB,qBAAqB,0CACtB;AAED,QAAO;EACL,SAAS;EACT,uBAAuB,oBACrB,qBAAqB,2CACtB;EACD,yBAAyB,oBACvB,qBAAqB,2DACtB;EACD,uBAAuB,oBACrB,qBAAqB,uDACtB;EACD;EAC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AAe,kBAAkB,SAAS,qBAAqB,OAAO;CAE5E,MAAM,gBAAgB,mBACpB,cACA,qBAAqB,QACtB;AAED,uBAAsB;EAEpB,SAAS,cAAc;EAEvB,sBAAsB;EACtB,QAAQ;EACR,KAAK;EAEL,QAAQ;EACR,SAAS;EACT,IAAI,cAAc,qBAAqB,GAAG;EAC1C,OAAO,iBAAiB,qBAAqB,MAAM;EACnD,UAAU,oBAAoB,qBAAqB,SAAS;EAC5D,YAAY,sBAAsB,qBAAqB,WAAW;EAClE,SAAS,qBAAqB;EAC9B,SAAS,qBAAqB;EAC/B;AAED,QAAO"}
@@ -28,16 +28,16 @@ const formatNodeTypeToEnvVar = (nodeTypes, addProcessEnv = false) => nodeTypes.r
28
28
  * getConfigEnvVars(config, true)
29
29
  * // { 'process.env.INTLAYER_ROUTING_MODE': '"prefix-no-default"', ... }
30
30
  */
31
- const getConfigEnvVars = (config, addProcessEnv = false) => {
31
+ const getConfigEnvVars = (config, addProcessEnv = false, wrapValue = (value) => value) => {
32
32
  const prefix = addProcessEnv ? "process.env." : "";
33
33
  const { routing, editor } = config;
34
- const envVars = { [`${prefix}INTLAYER_ROUTING_MODE`]: JSON.stringify(routing.mode) };
35
- if (!routing.rewrite) envVars[`${prefix}INTLAYER_ROUTING_REWRITE_RULES`] = "\"false\"";
36
- if (routing.storage.cookies.length === 0) envVars[`${prefix}INTLAYER_ROUTING_STORAGE_COOKIES`] = "\"false\"";
37
- if (routing.storage.localStorage.length === 0) envVars[`${prefix}INTLAYER_ROUTING_STORAGE_LOCALSTORAGE`] = "\"false\"";
38
- if (routing.storage.sessionStorage.length === 0) envVars[`${prefix}INTLAYER_ROUTING_STORAGE_SESSIONSTORAGE`] = "\"false\"";
39
- if (routing.storage.headers.length === 0) envVars[`${prefix}INTLAYER_ROUTING_STORAGE_HEADERS`] = "\"false\"";
40
- if (editor?.enabled === false) envVars[`${prefix}INTLAYER_EDITOR_ENABLED`] = "\"false\"";
34
+ const envVars = { [`${prefix}INTLAYER_ROUTING_MODE`]: wrapValue(routing.mode) };
35
+ if (!routing.rewrite) envVars[`${prefix}INTLAYER_ROUTING_REWRITE_RULES`] = wrapValue("false");
36
+ if (!routing.storage.cookies || routing.storage.cookies.length === 0) envVars[`${prefix}INTLAYER_ROUTING_STORAGE_COOKIES`] = wrapValue("false");
37
+ if (!routing.storage.localStorage || routing.storage.localStorage.length === 0) envVars[`${prefix}INTLAYER_ROUTING_STORAGE_LOCALSTORAGE`] = wrapValue("false");
38
+ if (!routing.storage.sessionStorage || routing.storage.sessionStorage.length === 0) envVars[`${prefix}INTLAYER_ROUTING_STORAGE_SESSIONSTORAGE`] = wrapValue("false");
39
+ if (!routing.storage.headers || routing.storage.headers.length === 0) envVars[`${prefix}INTLAYER_ROUTING_STORAGE_HEADERS`] = wrapValue("false");
40
+ if (editor?.enabled === false) envVars[`${prefix}INTLAYER_EDITOR_ENABLED`] = wrapValue("false");
41
41
  return envVars;
42
42
  };
43
43
 
@@ -1 +1 @@
1
- {"version":3,"file":"envVars.cjs","names":[],"sources":["../../../src/envVars/envVars.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types/config';\n\n/**\n * Converts a list of unused NodeType keys into env-var definitions.\n * Set to `\"false\"` so bundlers can eliminate the corresponding plugin code.\n *\n * @example\n * formatNodeTypeToEnvVar(['enumeration'])\n * // { 'INTLAYER_NODE_TYPE_ENUMERATION': '\"false\"' }\n *\n * formatNodeTypeToEnvVar(['enumeration'], true)\n * // { 'process.env.INTLAYER_NODE_TYPE_ENUMERATION': '\"false\"' }\n */\nexport const formatNodeTypeToEnvVar = (\n nodeTypes: string[],\n addProcessEnv: boolean = false\n): Record<string, string> =>\n nodeTypes.reduce(\n (acc, nodeType) => {\n acc[\n addProcessEnv\n ? `process.env.INTLAYER_NODE_TYPE_${nodeType.toUpperCase()}`\n : `INTLAYER_NODE_TYPE_${nodeType.toUpperCase()}`\n ] = '\"false\"';\n return acc;\n },\n {} as Record<string, string>\n );\n\n/**\n * Returns env-var definitions for the full Intlayer config to be injected at\n * build time. Allows bundlers to dead-code-eliminate unused routing modes,\n * rewrite logic, storage mechanisms, and editor code.\n *\n * @example\n * getConfigEnvVars(config)\n * // { INTLAYER_ROUTING_MODE: '\"prefix-no-default\"', INTLAYER_ROUTING_REWRITE_RULES: '\"false\"', ... }\n *\n * getConfigEnvVars(config, true)\n * // { 'process.env.INTLAYER_ROUTING_MODE': '\"prefix-no-default\"', ... }\n */\nexport const getConfigEnvVars = (\n config: IntlayerConfig,\n addProcessEnv: boolean = false\n): Record<string, string> => {\n const prefix = addProcessEnv ? 'process.env.' : '';\n const { routing, editor } = config;\n\n const envVars: Record<string, string> = {\n [`${prefix}INTLAYER_ROUTING_MODE`]: JSON.stringify(routing.mode),\n };\n\n if (!routing.rewrite) {\n envVars[`${prefix}INTLAYER_ROUTING_REWRITE_RULES`] = '\"false\"';\n }\n\n if (routing.storage.cookies.length === 0) {\n envVars[`${prefix}INTLAYER_ROUTING_STORAGE_COOKIES`] = '\"false\"';\n }\n\n if (routing.storage.localStorage.length === 0) {\n envVars[`${prefix}INTLAYER_ROUTING_STORAGE_LOCALSTORAGE`] = '\"false\"';\n }\n\n if (routing.storage.sessionStorage.length === 0) {\n envVars[`${prefix}INTLAYER_ROUTING_STORAGE_SESSIONSTORAGE`] = '\"false\"';\n }\n\n if (routing.storage.headers.length === 0) {\n envVars[`${prefix}INTLAYER_ROUTING_STORAGE_HEADERS`] = '\"false\"';\n }\n\n if (editor?.enabled === false) {\n envVars[`${prefix}INTLAYER_EDITOR_ENABLED`] = '\"false\"';\n }\n\n return envVars;\n};\n"],"mappings":";;;;;;;;;;;;;;AAaA,MAAa,0BACX,WACA,gBAAyB,UAEzB,UAAU,QACP,KAAK,aAAa;AACjB,KACE,gBACI,kCAAkC,SAAS,aAAa,KACxD,sBAAsB,SAAS,aAAa,MAC9C;AACJ,QAAO;GAET,EAAE,CACH;;;;;;;;;;;;;AAcH,MAAa,oBACX,QACA,gBAAyB,UACE;CAC3B,MAAM,SAAS,gBAAgB,iBAAiB;CAChD,MAAM,EAAE,SAAS,WAAW;CAE5B,MAAM,UAAkC,GACrC,GAAG,OAAO,yBAAyB,KAAK,UAAU,QAAQ,KAAK,EACjE;AAED,KAAI,CAAC,QAAQ,QACX,SAAQ,GAAG,OAAO,mCAAmC;AAGvD,KAAI,QAAQ,QAAQ,QAAQ,WAAW,EACrC,SAAQ,GAAG,OAAO,qCAAqC;AAGzD,KAAI,QAAQ,QAAQ,aAAa,WAAW,EAC1C,SAAQ,GAAG,OAAO,0CAA0C;AAG9D,KAAI,QAAQ,QAAQ,eAAe,WAAW,EAC5C,SAAQ,GAAG,OAAO,4CAA4C;AAGhE,KAAI,QAAQ,QAAQ,QAAQ,WAAW,EACrC,SAAQ,GAAG,OAAO,qCAAqC;AAGzD,KAAI,QAAQ,YAAY,MACtB,SAAQ,GAAG,OAAO,4BAA4B;AAGhD,QAAO"}
1
+ {"version":3,"file":"envVars.cjs","names":[],"sources":["../../../src/envVars/envVars.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types/config';\n\n/**\n * Converts a list of unused NodeType keys into env-var definitions.\n * Set to `\"false\"` so bundlers can eliminate the corresponding plugin code.\n *\n * @example\n * formatNodeTypeToEnvVar(['enumeration'])\n * // { 'INTLAYER_NODE_TYPE_ENUMERATION': '\"false\"' }\n *\n * formatNodeTypeToEnvVar(['enumeration'], true)\n * // { 'process.env.INTLAYER_NODE_TYPE_ENUMERATION': '\"false\"' }\n */\nexport const formatNodeTypeToEnvVar = (\n nodeTypes: string[],\n addProcessEnv: boolean = false\n): Record<string, string> =>\n nodeTypes.reduce(\n (acc, nodeType) => {\n acc[\n addProcessEnv\n ? `process.env.INTLAYER_NODE_TYPE_${nodeType.toUpperCase()}`\n : `INTLAYER_NODE_TYPE_${nodeType.toUpperCase()}`\n ] = '\"false\"';\n return acc;\n },\n {} as Record<string, string>\n );\n\n/**\n * Returns env-var definitions for the full Intlayer config to be injected at\n * build time. Allows bundlers to dead-code-eliminate unused routing modes,\n * rewrite logic, storage mechanisms, and editor code.\n *\n * @example\n * getConfigEnvVars(config)\n * // { INTLAYER_ROUTING_MODE: '\"prefix-no-default\"', INTLAYER_ROUTING_REWRITE_RULES: '\"false\"', ... }\n *\n * getConfigEnvVars(config, true)\n * // { 'process.env.INTLAYER_ROUTING_MODE': '\"prefix-no-default\"', ... }\n */\nexport const getConfigEnvVars = (\n config: IntlayerConfig,\n addProcessEnv: boolean = false,\n wrapValue: (value: string) => string = (value) => value\n): Record<string, string> => {\n const prefix = addProcessEnv ? 'process.env.' : '';\n const { routing, editor } = config;\n\n const envVars: Record<string, string> = {\n [`${prefix}INTLAYER_ROUTING_MODE`]: wrapValue(routing.mode),\n };\n\n if (!routing.rewrite) {\n envVars[`${prefix}INTLAYER_ROUTING_REWRITE_RULES`] = wrapValue('false');\n }\n\n if (!routing.storage.cookies || routing.storage.cookies.length === 0) {\n envVars[`${prefix}INTLAYER_ROUTING_STORAGE_COOKIES`] = wrapValue('false');\n }\n\n if (\n !routing.storage.localStorage ||\n routing.storage.localStorage.length === 0\n ) {\n envVars[`${prefix}INTLAYER_ROUTING_STORAGE_LOCALSTORAGE`] =\n wrapValue('false');\n }\n\n if (\n !routing.storage.sessionStorage ||\n routing.storage.sessionStorage.length === 0\n ) {\n envVars[`${prefix}INTLAYER_ROUTING_STORAGE_SESSIONSTORAGE`] =\n wrapValue('false');\n }\n\n if (!routing.storage.headers || routing.storage.headers.length === 0) {\n envVars[`${prefix}INTLAYER_ROUTING_STORAGE_HEADERS`] = wrapValue('false');\n }\n\n if (editor?.enabled === false) {\n envVars[`${prefix}INTLAYER_EDITOR_ENABLED`] = wrapValue('false');\n }\n\n return envVars;\n};\n"],"mappings":";;;;;;;;;;;;;;AAaA,MAAa,0BACX,WACA,gBAAyB,UAEzB,UAAU,QACP,KAAK,aAAa;AACjB,KACE,gBACI,kCAAkC,SAAS,aAAa,KACxD,sBAAsB,SAAS,aAAa,MAC9C;AACJ,QAAO;GAET,EAAE,CACH;;;;;;;;;;;;;AAcH,MAAa,oBACX,QACA,gBAAyB,OACzB,aAAwC,UAAU,UACvB;CAC3B,MAAM,SAAS,gBAAgB,iBAAiB;CAChD,MAAM,EAAE,SAAS,WAAW;CAE5B,MAAM,UAAkC,GACrC,GAAG,OAAO,yBAAyB,UAAU,QAAQ,KAAK,EAC5D;AAED,KAAI,CAAC,QAAQ,QACX,SAAQ,GAAG,OAAO,mCAAmC,UAAU,QAAQ;AAGzE,KAAI,CAAC,QAAQ,QAAQ,WAAW,QAAQ,QAAQ,QAAQ,WAAW,EACjE,SAAQ,GAAG,OAAO,qCAAqC,UAAU,QAAQ;AAG3E,KACE,CAAC,QAAQ,QAAQ,gBACjB,QAAQ,QAAQ,aAAa,WAAW,EAExC,SAAQ,GAAG,OAAO,0CAChB,UAAU,QAAQ;AAGtB,KACE,CAAC,QAAQ,QAAQ,kBACjB,QAAQ,QAAQ,eAAe,WAAW,EAE1C,SAAQ,GAAG,OAAO,4CAChB,UAAU,QAAQ;AAGtB,KAAI,CAAC,QAAQ,QAAQ,WAAW,QAAQ,QAAQ,QAAQ,WAAW,EACjE,SAAQ,GAAG,OAAO,qCAAqC,UAAU,QAAQ;AAG3E,KAAI,QAAQ,YAAY,MACtB,SAAQ,GAAG,OAAO,4BAA4B,UAAU,QAAQ;AAGlE,QAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"logger.cjs","names":["RESET","GREEN","BEIGE","GREY","BLUE","RED"],"sources":["../../src/logger.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type {\n CustomIntlayerConfig,\n IntlayerConfig,\n} from '@intlayer/types/config';\nimport type * as ANSIColorsTypes from './colors';\nimport { BEIGE, BLUE, GREEN, GREY, RED, RESET } from './colors';\n\nexport type ANSIColorsType =\n (typeof ANSIColorsTypes)[keyof typeof ANSIColorsTypes];\n\nexport type Details = {\n isVerbose?: boolean;\n level?: 'info' | 'warn' | 'error' | 'debug';\n config?: CustomIntlayerConfig['log'];\n};\n\nexport type Logger = (content: any, details?: Details) => void;\n\nlet loggerPrefix: string | undefined;\n\nexport const setPrefix = (prefix: string | undefined) => {\n loggerPrefix = prefix;\n};\n\nexport const getPrefix = (configPrefix?: string): string | undefined => {\n if (typeof loggerPrefix !== 'undefined') {\n return loggerPrefix;\n }\n\n return configPrefix;\n};\n\nexport const logger: Logger = (content, details) => {\n const config = details?.config ?? {};\n const mode = config.mode ?? 'default';\n\n if (mode === 'disabled' || (details?.isVerbose && mode !== 'verbose')) return;\n\n const prefix = getPrefix(config.prefix);\n const flatContent = prefix ? [prefix, ...[content].flat()] : [content].flat();\n const level = details?.level ?? 'info';\n\n const logMethod =\n config[level] ?? console[level] ?? config.log ?? console.log;\n\n logMethod(...flatContent);\n};\n\nexport const spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];\n\n/**\n * The appLogger function takes the logger and merges it with the configuration from the intlayer config file.\n * It allows overriding the default configuration by passing a config object in the details parameter.\n * The configuration is merged with the default configuration from the intlayer config file.\n */\nexport const getAppLogger =\n (configuration?: IntlayerConfig, globalDetails?: Details) =>\n (content: any, details?: Details) =>\n logger(content, {\n ...(details ?? {}),\n config: {\n ...configuration?.log,\n ...globalDetails?.config,\n ...(details?.config ?? {}),\n },\n });\n\nexport const colorize = (\n string: string,\n color?: ANSIColorsType,\n reset?: boolean | ANSIColorsType\n): string =>\n color\n ? `${color}${string}${reset ? (typeof reset === 'boolean' ? RESET : reset) : RESET}`\n : string;\n\nexport const colorizeLocales = (\n locales: Locale | Locale[],\n color: ANSIColorsType = GREEN,\n reset: boolean | ANSIColorsType = RESET\n) =>\n [locales]\n .flat()\n .map((locale) => colorize(locale, color, reset))\n .join(`, `);\n\nexport const colorizeKey = (\n keyPath: string | string[],\n color: ANSIColorsType = BEIGE,\n reset: boolean | ANSIColorsType = RESET\n) =>\n [keyPath]\n .flat()\n .map((key) => colorize(key, color, reset))\n .join(`, `);\n\nexport const colorizePath = (\n path: string | string[],\n color: ANSIColorsType = GREY,\n reset: boolean | ANSIColorsType = RESET\n) =>\n [path]\n .flat()\n .map((path) => colorize(path, color, reset))\n .join(`, `);\n\nexport const colorizeNumber = (\n number: number | string,\n options: Partial<Record<Intl.LDMLPluralRule, ANSIColorsType>> = {\n zero: BLUE,\n one: BLUE,\n two: BLUE,\n few: BLUE,\n many: BLUE,\n other: BLUE,\n }\n): string => {\n if (number === 0 || number === '0') {\n const color = options.zero ?? GREEN;\n return colorize(number.toString(), color);\n }\n\n // Kept inside the function. Top-level instantiation of classes/APIs\n // is treated as a side-effect and prevents tree-shaking if the function is unused.\n const rule = new Intl.PluralRules('en').select(Number(number));\n const color = options[rule];\n return colorize(number.toString(), color);\n};\n\nexport const removeColor = (text: string) =>\n // biome-ignore lint/suspicious/noControlCharactersInRegex: we need to remove the color codes\n text.replace(/\\x1b\\[[0-9;]*m/g, '');\n\nconst getLength = (length: number | number[] | string | string[]): number => {\n let value: number = 0;\n if (typeof length === 'number') {\n value = length;\n }\n if (typeof length === 'string') {\n value = length.length;\n }\n if (\n Array.isArray(length) &&\n length.every((locale) => typeof locale === 'string')\n ) {\n value = Math.max(...length.map((str) => str.length));\n }\n if (\n Array.isArray(length) &&\n length.every((locale) => typeof locale === 'number')\n ) {\n value = Math.max(...length);\n }\n return Math.max(value, 0);\n};\n\nconst defaultColonOptions = {\n colSize: 0,\n minSize: 0,\n maxSize: Infinity,\n pad: 'right',\n padChar: '0',\n};\n\n/**\n * Create a string of spaces of a given length.\n *\n * @param colSize - The length of the string to create.\n * @returns A string of spaces.\n */\nexport const colon = (\n text: string | string[],\n options?: {\n colSize?: number | number[] | string | string[];\n minSize?: number;\n maxSize?: number;\n pad?: 'left' | 'right';\n padChar?: string;\n }\n): string =>\n [text]\n .flat()\n .map((text) => {\n const { colSize, minSize, maxSize, pad } = {\n ...defaultColonOptions,\n ...(options ?? {}),\n };\n\n const length = getLength(colSize);\n const spacesLength = Math.max(\n minSize!,\n Math.min(maxSize!, length - removeColor(text).length)\n );\n\n if (pad === 'left') {\n return `${' '.repeat(spacesLength)}${text}`;\n }\n\n return `${text}${' '.repeat(spacesLength)}`;\n })\n .join('');\n\nexport const x = colorize('✗', RED);\nexport const v = colorize('✓', GREEN);\nexport const clock = colorize('⏲', BLUE);\n"],"mappings":";;;;AAmBA,IAAI;AAEJ,MAAa,aAAa,WAA+B;AACvD,gBAAe;;AAGjB,MAAa,aAAa,iBAA8C;AACtE,KAAI,OAAO,iBAAiB,YAC1B,QAAO;AAGT,QAAO;;AAGT,MAAa,UAAkB,SAAS,YAAY;CAClD,MAAM,SAAS,SAAS,UAAU,EAAE;CACpC,MAAM,OAAO,OAAO,QAAQ;AAE5B,KAAI,SAAS,cAAe,SAAS,aAAa,SAAS,UAAY;CAEvE,MAAM,SAAS,UAAU,OAAO,OAAO;CACvC,MAAM,cAAc,SAAS,CAAC,QAAQ,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM;CAC7E,MAAM,QAAQ,SAAS,SAAS;AAKhC,EAFE,OAAO,UAAU,QAAQ,UAAU,OAAO,OAAO,QAAQ,KAEjD,GAAG,YAAY;;AAG3B,MAAa,gBAAgB;CAAC;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAK;CAAI;;;;;;AAO/E,MAAa,gBACV,eAAgC,mBAChC,SAAc,YACb,OAAO,SAAS;CACd,GAAI,WAAW,EAAE;CACjB,QAAQ;EACN,GAAG,eAAe;EAClB,GAAG,eAAe;EAClB,GAAI,SAAS,UAAU,EAAE;EAC1B;CACF,CAAC;AAEN,MAAa,YACX,QACA,OACA,UAEA,QACI,GAAG,QAAQ,SAAS,QAAS,OAAO,UAAU,YAAYA,uBAAQ,QAASA,yBAC3E;AAEN,MAAa,mBACX,SACA,QAAwBC,sBACxB,QAAkCD,yBAElC,CAAC,QAAQ,CACN,MAAM,CACN,KAAK,WAAW,SAAS,QAAQ,O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QD,MAAa,SACX,MACA,YAQA,CAAC,KAAK,CACH,MAAM,CACN,KAAK,SAAS;CACb,MAAM,EAAE,SAAS,SAAS,SAAS,QAAQ;EACzC,GAAG;EACH,GAAI,WAAW,EAAE;EAClB;CAED,MAAM,SAAS,UAAU,QAAQ;CACjC,MAAM,eAAe,KAAK,IACxB,SACA,KAAK,IAAI,SAAU,SAAS,YAAY,KAAK,CAAC,OAAO,CACtD;AAED,KAAI,QAAQ,OACV,QAAO,GAAG,IAAI,OAAO,aAAa,GAAG;AAGvC,QAAO,GAAG,OAAO,IAAI,OAAO,aAAa;EACzC,CACD,KAAK,GAAG;AAEb,MAAa,IAAI,SAAS,KAAKC,mBAAI;AACnC,MAAa,IAAI,SAAS,KAAKJ,qBAAM;AACrC,MAAa,QAAQ,SAAS,KAAKG,oBAAK"}
1
+ {"version":3,"file":"logger.cjs","names":["RESET","GREEN","BEIGE","GREY","BLUE","RED"],"sources":["../../src/logger.ts"],"sourcesContent":["import type { Locale } from '@intlayer/types/allLocales';\nimport type {\n CustomIntlayerConfig,\n IntlayerConfig,\n} from '@intlayer/types/config';\nimport type * as ANSIColorsTypes from './colors';\nimport { BEIGE, BLUE, GREEN, GREY, RED, RESET } from './colors';\n\nexport type ANSIColorsType =\n (typeof ANSIColorsTypes)[keyof typeof ANSIColorsTypes];\n\nexport type Details = {\n isVerbose?: boolean;\n level?: 'info' | 'warn' | 'error' | 'debug';\n config?: CustomIntlayerConfig['log'];\n};\n\nexport type Logger = (content: any, details?: Details) => void;\n\nlet loggerPrefix: string | undefined;\n\nexport const setPrefix = (prefix: string | undefined) => {\n loggerPrefix = prefix;\n};\n\nexport const getPrefix = (configPrefix?: string): string | undefined => {\n if (typeof loggerPrefix !== 'undefined') {\n return loggerPrefix;\n }\n\n return configPrefix;\n};\n\nexport const logger: Logger = (content, details) => {\n const config = details?.config ?? {};\n const mode = config.mode ?? 'default';\n\n if (mode === 'disabled' || (details?.isVerbose && mode !== 'verbose')) return;\n\n const prefix = getPrefix(config.prefix);\n const flatContent = prefix ? [prefix, ...[content].flat()] : [content].flat();\n const level = details?.level ?? 'info';\n\n const logMethod =\n config[level] ?? console[level] ?? config.log ?? console.log;\n\n logMethod(...flatContent);\n};\n\nexport const spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];\n\n/**\n * The appLogger function takes the logger and merges it with the configuration from the intlayer config file.\n * It allows overriding the default configuration by passing a config object in the details parameter.\n * The configuration is merged with the default configuration from the intlayer config file.\n */\nexport const getAppLogger =\n (configuration?: Pick<IntlayerConfig, 'log'>, globalDetails?: Details) =>\n (content: any, details?: Details) =>\n logger(content, {\n ...(details ?? {}),\n config: {\n ...configuration?.log,\n ...globalDetails?.config,\n ...(details?.config ?? {}),\n },\n });\n\nexport const colorize = (\n string: string,\n color?: ANSIColorsType,\n reset?: boolean | ANSIColorsType\n): string =>\n color\n ? `${color}${string}${reset ? (typeof reset === 'boolean' ? RESET : reset) : RESET}`\n : string;\n\nexport const colorizeLocales = (\n locales: Locale | Locale[],\n color: ANSIColorsType = GREEN,\n reset: boolean | ANSIColorsType = RESET\n) =>\n [locales]\n .flat()\n .map((locale) => colorize(locale, color, reset))\n .join(`, `);\n\nexport const colorizeKey = (\n keyPath: string | string[],\n color: ANSIColorsType = BEIGE,\n reset: boolean | ANSIColorsType = RESET\n) =>\n [keyPath]\n .flat()\n .map((key) => colorize(key, color, reset))\n .join(`, `);\n\nexport const colorizePath = (\n path: string | string[],\n color: ANSIColorsType = GREY,\n reset: boolean | ANSIColorsType = RESET\n) =>\n [path]\n .flat()\n .map((path) => colorize(path, color, reset))\n .join(`, `);\n\nexport const colorizeNumber = (\n number: number | string,\n options: Partial<Record<Intl.LDMLPluralRule, ANSIColorsType>> = {\n zero: BLUE,\n one: BLUE,\n two: BLUE,\n few: BLUE,\n many: BLUE,\n other: BLUE,\n }\n): string => {\n if (number === 0 || number === '0') {\n const color = options.zero ?? GREEN;\n return colorize(number.toString(), color);\n }\n\n // Kept inside the function. Top-level instantiation of classes/APIs\n // is treated as a side-effect and prevents tree-shaking if the function is unused.\n const rule = new Intl.PluralRules('en').select(Number(number));\n const color = options[rule];\n return colorize(number.toString(), color);\n};\n\nexport const removeColor = (text: string) =>\n // biome-ignore lint/suspicious/noControlCharactersInRegex: we need to remove the color codes\n text.replace(/\\x1b\\[[0-9;]*m/g, '');\n\nconst getLength = (length: number | number[] | string | string[]): number => {\n let value: number = 0;\n if (typeof length === 'number') {\n value = length;\n }\n if (typeof length === 'string') {\n value = length.length;\n }\n if (\n Array.isArray(length) &&\n length.every((locale) => typeof locale === 'string')\n ) {\n value = Math.max(...length.map((str) => str.length));\n }\n if (\n Array.isArray(length) &&\n length.every((locale) => typeof locale === 'number')\n ) {\n value = Math.max(...length);\n }\n return Math.max(value, 0);\n};\n\nconst defaultColonOptions = {\n colSize: 0,\n minSize: 0,\n maxSize: Infinity,\n pad: 'right',\n padChar: '0',\n};\n\n/**\n * Create a string of spaces of a given length.\n *\n * @param colSize - The length of the string to create.\n * @returns A string of spaces.\n */\nexport const colon = (\n text: string | string[],\n options?: {\n colSize?: number | number[] | string | string[];\n minSize?: number;\n maxSize?: number;\n pad?: 'left' | 'right';\n padChar?: string;\n }\n): string =>\n [text]\n .flat()\n .map((text) => {\n const { colSize, minSize, maxSize, pad } = {\n ...defaultColonOptions,\n ...(options ?? {}),\n };\n\n const length = getLength(colSize);\n const spacesLength = Math.max(\n minSize!,\n Math.min(maxSize!, length - removeColor(text).length)\n );\n\n if (pad === 'left') {\n return `${' '.repeat(spacesLength)}${text}`;\n }\n\n return `${text}${' '.repeat(spacesLength)}`;\n })\n .join('');\n\nexport const x = colorize('✗', RED);\nexport const v = colorize('✓', GREEN);\nexport const clock = colorize('⏲', BLUE);\n"],"mappings":";;;;AAmBA,IAAI;AAEJ,MAAa,aAAa,WAA+B;AACvD,gBAAe;;AAGjB,MAAa,aAAa,iBAA8C;AACtE,KAAI,OAAO,iBAAiB,YAC1B,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AAGvC,QAAO,GAAG,OAAO,IAAI,OAAO,aAAa;EACzC,CACD,KAAK,GAAG;AAEb,MAAa,IAAI,SAAS,KAAKC,mBAAI;AACnC,MAAa,IAAI,SAAS,KAAKJ,qBAAM;AACrC,MAAa,QAAQ,SAAS,KAAKG,oBAAK"}
package/dist/cjs/node.cjs CHANGED
@@ -1,4 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_utils_importMap = require('./utils/importMap.cjs');
2
3
  const require_configFile_buildBrowserConfiguration = require('./configFile/buildBrowserConfiguration.cjs');
3
4
  const require_configFile_configurationSchema = require('./configFile/configurationSchema.cjs');
4
5
  const require_configFile_buildConfigurationFields = require('./configFile/buildConfigurationFields.cjs');
@@ -22,6 +23,9 @@ exports.editorSchema = require_configFile_configurationSchema.editorSchema;
22
23
  exports.extractBrowserConfiguration = require_configFile_buildBrowserConfiguration.extractBrowserConfiguration;
23
24
  exports.getConfiguration = require_configFile_getConfiguration.getConfiguration;
24
25
  exports.getConfigurationAndFilePath = require_configFile_getConfiguration.getConfigurationAndFilePath;
26
+ exports.getImportMap = require_utils_importMap.getImportMap;
27
+ exports.getImportMapContent = require_utils_importMap.getImportMapContent;
28
+ exports.getImportMapScript = require_utils_importMap.getImportMapScript;
25
29
  exports.internationalizationSchema = require_configFile_configurationSchema.internationalizationSchema;
26
30
  exports.intlayerConfigSchema = require_configFile_configurationSchema.intlayerConfigSchema;
27
31
  exports.logSchema = require_configFile_configurationSchema.logSchema;
@@ -53,10 +53,10 @@ const processStorageEntry = (entry) => {
53
53
  };
54
54
  };
55
55
  const mergeStorageAttributes = (accumulated, partial) => ({
56
- cookies: [...accumulated.cookies, ...partial.cookies ?? []],
57
- localStorage: [...accumulated.localStorage, ...partial.localStorage ?? []],
58
- sessionStorage: [...accumulated.sessionStorage, ...partial.sessionStorage ?? []],
59
- headers: [...accumulated.headers, ...partial.headers ?? []]
56
+ cookies: [...accumulated.cookies ?? [], ...partial.cookies ?? []],
57
+ localStorage: [...accumulated.localStorage ?? [], ...partial.localStorage ?? []],
58
+ sessionStorage: [...accumulated.sessionStorage ?? [], ...partial.sessionStorage ?? []],
59
+ headers: [...accumulated.headers ?? [], ...partial.headers ?? []]
60
60
  });
61
61
  /**
62
62
  * Extracts and normalizes storage configuration into separate arrays for each storage type.
@@ -72,11 +72,16 @@ const getStorageAttributes = (options) => {
72
72
  sessionStorage: [],
73
73
  headers: []
74
74
  };
75
- if (options === false || options === void 0) return emptyResult;
76
- if (Array.isArray(options)) return options.reduce((acc, entry) => {
75
+ if (options === false || options === void 0) return {};
76
+ const result = Array.isArray(options) ? options.reduce((acc, entry) => {
77
77
  return mergeStorageAttributes(acc, processStorageEntry(entry));
78
- }, emptyResult);
79
- return mergeStorageAttributes(emptyResult, processStorageEntry(options));
78
+ }, emptyResult) : mergeStorageAttributes(emptyResult, processStorageEntry(options));
79
+ const cleanedResult = {};
80
+ if (result.cookies && result.cookies.length > 0) cleanedResult.cookies = result.cookies;
81
+ if (result.localStorage && result.localStorage.length > 0) cleanedResult.localStorage = result.localStorage;
82
+ if (result.sessionStorage && result.sessionStorage.length > 0) cleanedResult.sessionStorage = result.sessionStorage;
83
+ if (result.headers && result.headers.length > 0) cleanedResult.headers = result.headers;
84
+ return cleanedResult;
80
85
  };
81
86
 
82
87
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"getStorageAttributes.cjs","names":[],"sources":["../../../src/utils/getStorageAttributes.ts"],"sourcesContent":["import type {\n CookiesAttributes,\n ProcessedStorageAttributes,\n RoutingStorageInput,\n StorageAttributes,\n} from '@intlayer/types/config';\nimport {\n COOKIE_NAME,\n HEADER_NAME,\n LOCALE_STORAGE_NAME,\n} from '../defaultValues/routing';\n\n// ============================================================================\n// Types\n// ============================================================================\n\ntype CookieEntry = {\n name: string;\n attributes: Omit<CookiesAttributes, 'type' | 'name'>;\n};\n\ntype WebStorageEntry = {\n name: string;\n};\n\ntype HeaderEntry = {\n name: string;\n};\n\ntype StorageEntry =\n | 'cookie'\n | 'localStorage'\n | 'sessionStorage'\n | 'header'\n | CookiesAttributes\n | StorageAttributes;\n\n// ============================================================================\n// Helper Functions\n// ============================================================================\n\nconst createCookieEntry = (\n options?: Partial<CookiesAttributes>\n): CookieEntry => {\n const { name, path, expires, domain, secure, sameSite, httpOnly } =\n options ?? {};\n return {\n name: name ?? COOKIE_NAME,\n attributes: { path, expires, domain, secure, sameSite, httpOnly },\n };\n};\n\nconst createWebStorageEntry = (\n options?: Partial<StorageAttributes>\n): WebStorageEntry => ({\n name: options?.name ?? LOCALE_STORAGE_NAME,\n});\n\nconst createHeaderEntry = (\n options?: Partial<StorageAttributes>\n): HeaderEntry => ({\n name: options?.name ?? HEADER_NAME,\n});\n\nconst isCookieEntry = (entry: unknown): boolean => {\n if (typeof entry !== 'object' || entry === null) return false;\n const e = entry as Record<string, unknown>;\n return (\n e['type'] === 'cookie' ||\n 'sameSite' in e ||\n 'httpOnly' in e ||\n 'secure' in e\n );\n};\n\nconst isStorageType = (\n value: string\n): value is 'cookie' | 'localStorage' | 'sessionStorage' | 'header' =>\n value === 'cookie' ||\n value === 'localStorage' ||\n value === 'sessionStorage' ||\n value === 'header';\n\n// ============================================================================\n// Main Function\n// ============================================================================\n\nconst processStorageEntry = (\n entry: StorageEntry\n): Partial<ProcessedStorageAttributes> => {\n if (typeof entry === 'string') {\n if (!isStorageType(entry)) {\n return { cookies: [], localStorage: [], sessionStorage: [], headers: [] };\n }\n if (entry === 'cookie') return { cookies: [createCookieEntry()] };\n if (entry === 'localStorage')\n return { localStorage: [createWebStorageEntry()] };\n if (entry === 'sessionStorage')\n return { sessionStorage: [createWebStorageEntry()] };\n if (entry === 'header') return { headers: [createHeaderEntry()] };\n }\n\n if (typeof entry === 'object' && entry !== null) {\n const typedEntry = entry as CookiesAttributes | StorageAttributes;\n\n if (isCookieEntry(typedEntry)) {\n return { cookies: [createCookieEntry(typedEntry as CookiesAttributes)] };\n }\n if ('type' in typedEntry && typedEntry.type === 'localStorage') {\n return {\n localStorage: [createWebStorageEntry(typedEntry as StorageAttributes)],\n };\n }\n if ('type' in typedEntry && typedEntry.type === 'sessionStorage') {\n return {\n sessionStorage: [\n createWebStorageEntry(typedEntry as StorageAttributes),\n ],\n };\n }\n if ('type' in typedEntry && typedEntry.type === 'header') {\n return { headers: [createHeaderEntry(typedEntry as StorageAttributes)] };\n }\n // Default to localStorage for ambiguous objects\n return {\n localStorage: [\n createWebStorageEntry(typedEntry as Omit<StorageAttributes, 'type'>),\n ],\n };\n }\n\n return { cookies: [], localStorage: [], sessionStorage: [], headers: [] };\n};\n\nconst mergeStorageAttributes = (\n accumulated: ProcessedStorageAttributes,\n partial: Partial<ProcessedStorageAttributes>\n): ProcessedStorageAttributes => ({\n cookies: [...accumulated.cookies, ...(partial.cookies ?? [])],\n localStorage: [...accumulated.localStorage, ...(partial.localStorage ?? [])],\n sessionStorage: [\n ...accumulated.sessionStorage,\n ...(partial.sessionStorage ?? []),\n ],\n headers: [...accumulated.headers, ...(partial.headers ?? [])],\n});\n\n/**\n * Extracts and normalizes storage configuration into separate arrays for each storage type.\n * Called at config-build time so the result is pre-computed and stored in the config.\n *\n * @param options - The storage configuration from IntlayerConfig\n * @returns An object containing arrays for cookies, localStorage, sessionStorage and headers\n */\nexport const getStorageAttributes = (\n options: RoutingStorageInput\n): ProcessedStorageAttributes => {\n const emptyResult: ProcessedStorageAttributes = {\n cookies: [],\n localStorage: [],\n sessionStorage: [],\n headers: [],\n };\n\n if (options === false || options === undefined) return emptyResult;\n\n if (Array.isArray(options)) {\n return options.reduce<ProcessedStorageAttributes>((acc, entry) => {\n const partial = processStorageEntry(entry);\n return mergeStorageAttributes(acc, partial);\n }, emptyResult);\n }\n\n return mergeStorageAttributes(emptyResult, processStorageEntry(options));\n};\n"],"mappings":";;;;AAyCA,MAAM,qBACJ,YACgB;CAChB,MAAM,EAAE,MAAM,MAAM,SAAS,QAAQ,QAAQ,UAAU,aACrD,WAAW,EAAE;AACf,Q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C,QAAO,EAAE,SAAS,CAAC,kBAAkB,WAAgC,CAAC,EAAE;AAG1E,SAAO,EACL,cAAc,CACZ,sBAAsB,WAA8C,CACrE,EACF;;AAGH,QAAO;EAAE,SAAS,EAAE;EAAE,cAAc,EAAE;EAAE,gBAAgB,EAAE;EAAE,SAAS,EAAE;EAAE;;AAG3E,MAAM,0BACJ,aACA,aACgC;CAChC,SAAS,CAAC,GAAG,YAAY,SAAS,GAAI,QAAQ,WAAW,EAAE,CAAE;CAC7D,cAAc,CAAC,GAAG,YAAY,cAAc,GAAI,QAAQ,gBAAgB,EAAE,CAAE;CAC5E,gBAAgB,CACd,GAAG,YAAY,gBACf,GAAI,QAAQ,kBAAkB,EAAE,CACjC;CACD,SAAS,CAAC,GAAG,YAAY,SAAS,GAAI,QAAQ,WAAW,EAAE,CAAE;CAC9D;;;;;;;;AASD,MAAa,wBACX,YAC+B;CAC/B,MAAM,cAA0C;EAC9C,SAAS,EAAE;EACX,cAAc,EAAE;EAChB,gBAAgB,EAAE;EAClB,SAAS,EAAE;EACZ;AAED,KAAI,YAAY,SAAS,YAAY,OAAW,QAAO;AAEvD,KAAI,MAAM,QAAQ,QAAQ,CACxB,QAAO,QAAQ,QAAoC,KAAK,UAAU;AAEhE,SAAO,uBAAuB,KADd,oBAAoB,MAAM,CACC;IAC1C,YAAY;AAGjB,QAAO,uBAAuB,aAAa,oBAAoB,QAAQ,CAAC"}
1
+ {"version":3,"file":"getStorageAttributes.cjs","names":[],"sources":["../../../src/utils/getStorageAttributes.ts"],"sourcesContent":["import type {\n CookiesAttributes,\n ProcessedStorageAttributes,\n RoutingStorageInput,\n StorageAttributes,\n} from '@intlayer/types/config';\nimport {\n COOKIE_NAME,\n HEADER_NAME,\n LOCALE_STORAGE_NAME,\n} from '../defaultValues/routing';\n\n// ============================================================================\n// Types\n// ============================================================================\n\ntype CookieEntry = {\n name: string;\n attributes: Omit<CookiesAttributes, 'type' | 'name'>;\n};\n\ntype WebStorageEntry = {\n name: string;\n};\n\ntype HeaderEntry = {\n name: string;\n};\n\ntype StorageEntry =\n | 'cookie'\n | 'localStorage'\n | 'sessionStorage'\n | 'header'\n | CookiesAttributes\n | StorageAttributes;\n\n// ============================================================================\n// Helper Functions\n// ============================================================================\n\nconst createCookieEntry = (\n options?: Partial<CookiesAttributes>\n): CookieEntry => {\n const { name, path, expires, domain, secure, sameSite, httpOnly } =\n options ?? {};\n return {\n name: name ?? COOKIE_NAME,\n attributes: { path, expires, domain, secure, sameSite, httpOnly },\n };\n};\n\nconst createWebStorageEntry = (\n options?: Partial<StorageAttributes>\n): WebStorageEntry => ({\n name: options?.name ?? LOCALE_STORAGE_NAME,\n});\n\nconst createHeaderEntry = (\n options?: Partial<StorageAttributes>\n): HeaderEntry => ({\n name: options?.name ?? HEADER_NAME,\n});\n\nconst isCookieEntry = (entry: unknown): boolean => {\n if (typeof entry !== 'object' || entry === null) return false;\n const e = entry as Record<string, unknown>;\n return (\n e['type'] === 'cookie' ||\n 'sameSite' in e ||\n 'httpOnly' in e ||\n 'secure' in e\n );\n};\n\nconst isStorageType = (\n value: string\n): value is 'cookie' | 'localStorage' | 'sessionStorage' | 'header' =>\n value === 'cookie' ||\n value === 'localStorage' ||\n value === 'sessionStorage' ||\n value === 'header';\n\n// ============================================================================\n// Main Function\n// ============================================================================\n\nconst processStorageEntry = (\n entry: StorageEntry\n): Partial<ProcessedStorageAttributes> => {\n if (typeof entry === 'string') {\n if (!isStorageType(entry)) {\n return { cookies: [], localStorage: [], sessionStorage: [], headers: [] };\n }\n if (entry === 'cookie') return { cookies: [createCookieEntry()] };\n if (entry === 'localStorage')\n return { localStorage: [createWebStorageEntry()] };\n if (entry === 'sessionStorage')\n return { sessionStorage: [createWebStorageEntry()] };\n if (entry === 'header') return { headers: [createHeaderEntry()] };\n }\n\n if (typeof entry === 'object' && entry !== null) {\n const typedEntry = entry as CookiesAttributes | StorageAttributes;\n\n if (isCookieEntry(typedEntry)) {\n return { cookies: [createCookieEntry(typedEntry as CookiesAttributes)] };\n }\n if ('type' in typedEntry && typedEntry.type === 'localStorage') {\n return {\n localStorage: [createWebStorageEntry(typedEntry as StorageAttributes)],\n };\n }\n if ('type' in typedEntry && typedEntry.type === 'sessionStorage') {\n return {\n sessionStorage: [\n createWebStorageEntry(typedEntry as StorageAttributes),\n ],\n };\n }\n if ('type' in typedEntry && typedEntry.type === 'header') {\n return { headers: [createHeaderEntry(typedEntry as StorageAttributes)] };\n }\n // Default to localStorage for ambiguous objects\n return {\n localStorage: [\n createWebStorageEntry(typedEntry as Omit<StorageAttributes, 'type'>),\n ],\n };\n }\n\n return { cookies: [], localStorage: [], sessionStorage: [], headers: [] };\n};\n\nconst mergeStorageAttributes = (\n accumulated: ProcessedStorageAttributes,\n partial: Partial<ProcessedStorageAttributes>\n): ProcessedStorageAttributes => ({\n cookies: [...(accumulated.cookies ?? []), ...(partial.cookies ?? [])],\n localStorage: [\n ...(accumulated.localStorage ?? []),\n ...(partial.localStorage ?? []),\n ],\n sessionStorage: [\n ...(accumulated.sessionStorage ?? []),\n ...(partial.sessionStorage ?? []),\n ],\n headers: [...(accumulated.headers ?? []), ...(partial.headers ?? [])],\n});\n\n/**\n * Extracts and normalizes storage configuration into separate arrays for each storage type.\n * Called at config-build time so the result is pre-computed and stored in the config.\n *\n * @param options - The storage configuration from IntlayerConfig\n * @returns An object containing arrays for cookies, localStorage, sessionStorage and headers\n */\nexport const getStorageAttributes = (\n options: RoutingStorageInput\n): ProcessedStorageAttributes => {\n const emptyResult: ProcessedStorageAttributes = {\n cookies: [],\n localStorage: [],\n sessionStorage: [],\n headers: [],\n };\n\n if (options === false || options === undefined) return {};\n\n const result = Array.isArray(options)\n ? options.reduce<ProcessedStorageAttributes>((acc, entry) => {\n const partial = processStorageEntry(entry);\n return mergeStorageAttributes(acc, partial);\n }, emptyResult)\n : mergeStorageAttributes(emptyResult, processStorageEntry(options));\n\n // Remove empty arrays\n const cleanedResult: ProcessedStorageAttributes = {};\n\n if (result.cookies && result.cookies.length > 0) {\n cleanedResult.cookies = result.cookies;\n }\n\n if (result.localStorage && result.localStorage.length > 0) {\n cleanedResult.localStorage = result.localStorage;\n }\n\n if (result.sessionStorage && result.sessionStorage.length > 0) {\n cleanedResult.sessionStorage = result.sessionStorage;\n }\n\n if (result.headers && result.headers.length > 0) {\n cleanedResult.headers = result.headers;\n }\n\n return cleanedResult;\n};\n"],"mappings":";;;;AAyCA,MAAM,qBACJ,YACgB;CAChB,MAAM,EAAE,MAAM,MAAM,SAAS,QAAQ,QAAQ,UAAU,aACrD,WAAW,EAAE;AACf,QAAO;EACL,MAAM;EACN,YAAY;GAAE;GAAM;GAAS;GAAQ;GAAQ;GAAU;GAAU;EAClE;;AAGH,MAAM,yBACJ,aACqB,EACrB,MAAM,SAAS,2BAChB;AAED,MAAM,qBACJ,aACiB,EACjB,MAAM,SAAS,6BAChB;AAED,MAAM,iBAAiB,UAA4B;AACjD,KAAI,OAAO,UAAU,YAAY,UAAU,KAAM,QAAO;CACxD,MAAM,IAAI;AACV,QACE,EAAE,YAAY,YACd,cAAc,KACd,cAAc,KACd,YAAY;;AAIhB,MAAM,iBACJ,UAEA,UAAU,YACV,UAAU,kBACV,UAAU,oBACV,UAAU;AAMZ,MAAM,uBACJ,UACwC;AACxC,KAAI,OAAO,UAAU,UAAU;AAC7B,MAAI,CAAC,cAAc,MAAM,CACvB,QAAO;GAAE,SAAS,EAAE;GAAE,cAAc,EAAE;GAAE,gBAAgB,EAAE;GAAE,SAAS,EAAE;GAAE;AAE3E,MAAI,UAAU,SAAU,QAAO,EAAE,SAAS,CAAC,mBAAmB,CAAC,EAAE;AACjE,MAAI,UAAU,eACZ,QAAO,EAAE,cAAc,CAAC,uBAAuB,CAAC,EAAE;AACpD,MAAI,UAAU,iBACZ,QAAO,EAAE,gBAAgB,CAAC,uBAAuB,CAAC,EAAE;AACtD,MAAI,UAAU,SAAU,QAAO,EAAE,SAAS,CAAC,mBAAmB,CAAC,EAAE;;AAGnE,KAAI,OAAO,UAA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