@intlayer/config 5.8.1 → 6.0.0-canary.0

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 (154) hide show
  1. package/dist/cjs/alias.cjs +101 -0
  2. package/dist/cjs/alias.cjs.map +1 -0
  3. package/dist/cjs/client.cjs +24 -2
  4. package/dist/cjs/client.cjs.map +1 -1
  5. package/dist/cjs/configFile/buildConfigurationFields.cjs +46 -4
  6. package/dist/cjs/configFile/buildConfigurationFields.cjs.map +1 -1
  7. package/dist/cjs/configFile/getConfiguration.cjs.map +1 -1
  8. package/dist/cjs/configFile/loadConfigurationFile.cjs.map +1 -1
  9. package/dist/cjs/defaultValues/content.cjs +9 -0
  10. package/dist/cjs/defaultValues/content.cjs.map +1 -1
  11. package/dist/cjs/defaultValues/editor.cjs +6 -3
  12. package/dist/cjs/defaultValues/editor.cjs.map +1 -1
  13. package/dist/cjs/defaultValues/log.cjs +2 -3
  14. package/dist/cjs/defaultValues/log.cjs.map +1 -1
  15. package/dist/cjs/getSandboxContext.cjs +1 -1
  16. package/dist/cjs/getSandboxContext.cjs.map +1 -1
  17. package/dist/cjs/index.cjs +30 -11
  18. package/dist/cjs/index.cjs.map +1 -1
  19. package/dist/cjs/loadEnvFile.cjs.map +1 -0
  20. package/dist/cjs/loadExternalFile.cjs.map +1 -1
  21. package/dist/cjs/logger.cjs +107 -4
  22. package/dist/cjs/logger.cjs.map +1 -1
  23. package/dist/cjs/types/config.cjs.map +1 -1
  24. package/dist/esm/alias.mjs +77 -0
  25. package/dist/esm/alias.mjs.map +1 -0
  26. package/dist/esm/client.mjs +26 -2
  27. package/dist/esm/client.mjs.map +1 -1
  28. package/dist/esm/configFile/buildConfigurationFields.mjs +50 -5
  29. package/dist/esm/configFile/buildConfigurationFields.mjs.map +1 -1
  30. package/dist/esm/configFile/getConfiguration.mjs.map +1 -1
  31. package/dist/esm/configFile/loadConfigurationFile.mjs.map +1 -1
  32. package/dist/esm/defaultValues/content.mjs +6 -0
  33. package/dist/esm/defaultValues/content.mjs.map +1 -1
  34. package/dist/esm/defaultValues/editor.mjs +4 -2
  35. package/dist/esm/defaultValues/editor.mjs.map +1 -1
  36. package/dist/esm/defaultValues/log.mjs +2 -3
  37. package/dist/esm/defaultValues/log.mjs.map +1 -1
  38. package/dist/esm/getSandboxContext.mjs +1 -3
  39. package/dist/esm/getSandboxContext.mjs.map +1 -1
  40. package/dist/esm/index.mjs +30 -12
  41. package/dist/esm/index.mjs.map +1 -1
  42. package/dist/esm/loadEnvFile.mjs.map +1 -0
  43. package/dist/esm/loadExternalFile.mjs.map +1 -1
  44. package/dist/esm/logger.mjs +95 -3
  45. package/dist/esm/logger.mjs.map +1 -1
  46. package/dist/types/alias.d.ts +15 -0
  47. package/dist/types/alias.d.ts.map +1 -0
  48. package/dist/types/client.d.ts +1 -1
  49. package/dist/types/client.d.ts.map +1 -1
  50. package/dist/types/configFile/buildConfigurationFields.d.ts.map +1 -1
  51. package/dist/types/configFile/getConfiguration.d.ts +3 -2
  52. package/dist/types/configFile/getConfiguration.d.ts.map +1 -1
  53. package/dist/types/configFile/loadConfigurationFile.d.ts +1 -1
  54. package/dist/types/configFile/loadConfigurationFile.d.ts.map +1 -1
  55. package/dist/types/defaultValues/content.d.ts +3 -0
  56. package/dist/types/defaultValues/content.d.ts.map +1 -1
  57. package/dist/types/defaultValues/editor.d.ts +2 -1
  58. package/dist/types/defaultValues/editor.d.ts.map +1 -1
  59. package/dist/types/defaultValues/log.d.ts +1 -1
  60. package/dist/types/defaultValues/log.d.ts.map +1 -1
  61. package/dist/types/getSandboxContext.d.ts +1 -1
  62. package/dist/types/getSandboxContext.d.ts.map +1 -1
  63. package/dist/types/index.d.ts +3 -2
  64. package/dist/types/index.d.ts.map +1 -1
  65. package/dist/types/loadEnvFile.d.ts.map +1 -0
  66. package/dist/types/loadExternalFile.d.ts +1 -1
  67. package/dist/types/loadExternalFile.d.ts.map +1 -1
  68. package/dist/types/logger.d.ts +43 -1
  69. package/dist/types/logger.d.ts.map +1 -1
  70. package/dist/types/types/config.d.ts +43 -7
  71. package/dist/types/types/config.d.ts.map +1 -1
  72. package/package.json +8 -7
  73. package/dist/cjs/envVariables/detectPlatform.cjs +0 -55
  74. package/dist/cjs/envVariables/detectPlatform.cjs.map +0 -1
  75. package/dist/cjs/envVariables/extractEnvVariable/index.cjs +0 -44
  76. package/dist/cjs/envVariables/extractEnvVariable/index.cjs.map +0 -1
  77. package/dist/cjs/envVariables/extractEnvVariable/next.cjs +0 -102
  78. package/dist/cjs/envVariables/extractEnvVariable/next.cjs.map +0 -1
  79. package/dist/cjs/envVariables/extractEnvVariable/react_app.cjs +0 -102
  80. package/dist/cjs/envVariables/extractEnvVariable/react_app.cjs.map +0 -1
  81. package/dist/cjs/envVariables/extractEnvVariable/types.cjs +0 -17
  82. package/dist/cjs/envVariables/extractEnvVariable/types.cjs.map +0 -1
  83. package/dist/cjs/envVariables/extractEnvVariable/undefined_platform.cjs +0 -102
  84. package/dist/cjs/envVariables/extractEnvVariable/undefined_platform.cjs.map +0 -1
  85. package/dist/cjs/envVariables/extractEnvVariable/vite.cjs +0 -111
  86. package/dist/cjs/envVariables/extractEnvVariable/vite.cjs.map +0 -1
  87. package/dist/cjs/envVariables/extractEnvVariable/vite_env.d.cjs +0 -18
  88. package/dist/cjs/envVariables/extractEnvVariable/vite_env.d.cjs.map +0 -1
  89. package/dist/cjs/envVariables/formatEnvVariable.cjs +0 -50
  90. package/dist/cjs/envVariables/formatEnvVariable.cjs.map +0 -1
  91. package/dist/cjs/envVariables/getConfiguration.cjs +0 -150
  92. package/dist/cjs/envVariables/getConfiguration.cjs.map +0 -1
  93. package/dist/cjs/envVariables/index.cjs +0 -40
  94. package/dist/cjs/envVariables/index.cjs.map +0 -1
  95. package/dist/cjs/envVariables/loadEnvFile.cjs.map +0 -1
  96. package/dist/cjs/envVariables/removeUndefinedValueObject.cjs +0 -38
  97. package/dist/cjs/envVariables/removeUndefinedValueObject.cjs.map +0 -1
  98. package/dist/cjs/envVariables/utils.cjs +0 -54
  99. package/dist/cjs/envVariables/utils.cjs.map +0 -1
  100. package/dist/esm/envVariables/detectPlatform.mjs +0 -29
  101. package/dist/esm/envVariables/detectPlatform.mjs.map +0 -1
  102. package/dist/esm/envVariables/extractEnvVariable/index.mjs +0 -20
  103. package/dist/esm/envVariables/extractEnvVariable/index.mjs.map +0 -1
  104. package/dist/esm/envVariables/extractEnvVariable/next.mjs +0 -78
  105. package/dist/esm/envVariables/extractEnvVariable/next.mjs.map +0 -1
  106. package/dist/esm/envVariables/extractEnvVariable/react_app.mjs +0 -78
  107. package/dist/esm/envVariables/extractEnvVariable/react_app.mjs.map +0 -1
  108. package/dist/esm/envVariables/extractEnvVariable/types.mjs +0 -1
  109. package/dist/esm/envVariables/extractEnvVariable/types.mjs.map +0 -1
  110. package/dist/esm/envVariables/extractEnvVariable/undefined_platform.mjs +0 -78
  111. package/dist/esm/envVariables/extractEnvVariable/undefined_platform.mjs.map +0 -1
  112. package/dist/esm/envVariables/extractEnvVariable/vite.mjs +0 -86
  113. package/dist/esm/envVariables/extractEnvVariable/vite.mjs.map +0 -1
  114. package/dist/esm/envVariables/extractEnvVariable/vite_env.d.mjs +0 -2
  115. package/dist/esm/envVariables/extractEnvVariable/vite_env.d.mjs.map +0 -1
  116. package/dist/esm/envVariables/formatEnvVariable.mjs +0 -26
  117. package/dist/esm/envVariables/formatEnvVariable.mjs.map +0 -1
  118. package/dist/esm/envVariables/getConfiguration.mjs +0 -128
  119. package/dist/esm/envVariables/getConfiguration.mjs.map +0 -1
  120. package/dist/esm/envVariables/index.mjs +0 -12
  121. package/dist/esm/envVariables/index.mjs.map +0 -1
  122. package/dist/esm/envVariables/loadEnvFile.mjs.map +0 -1
  123. package/dist/esm/envVariables/removeUndefinedValueObject.mjs +0 -14
  124. package/dist/esm/envVariables/removeUndefinedValueObject.mjs.map +0 -1
  125. package/dist/esm/envVariables/utils.mjs +0 -30
  126. package/dist/esm/envVariables/utils.mjs.map +0 -1
  127. package/dist/types/envVariables/detectPlatform.d.ts +0 -7
  128. package/dist/types/envVariables/detectPlatform.d.ts.map +0 -1
  129. package/dist/types/envVariables/extractEnvVariable/index.d.ts +0 -7
  130. package/dist/types/envVariables/extractEnvVariable/index.d.ts.map +0 -1
  131. package/dist/types/envVariables/extractEnvVariable/next.d.ts +0 -3
  132. package/dist/types/envVariables/extractEnvVariable/next.d.ts.map +0 -1
  133. package/dist/types/envVariables/extractEnvVariable/react_app.d.ts +0 -3
  134. package/dist/types/envVariables/extractEnvVariable/react_app.d.ts.map +0 -1
  135. package/dist/types/envVariables/extractEnvVariable/types.d.ts +0 -8
  136. package/dist/types/envVariables/extractEnvVariable/types.d.ts.map +0 -1
  137. package/dist/types/envVariables/extractEnvVariable/undefined_platform.d.ts +0 -3
  138. package/dist/types/envVariables/extractEnvVariable/undefined_platform.d.ts.map +0 -1
  139. package/dist/types/envVariables/extractEnvVariable/vite.d.ts +0 -3
  140. package/dist/types/envVariables/extractEnvVariable/vite.d.ts.map +0 -1
  141. package/dist/types/envVariables/formatEnvVariable.d.ts +0 -6
  142. package/dist/types/envVariables/formatEnvVariable.d.ts.map +0 -1
  143. package/dist/types/envVariables/getConfiguration.d.ts +0 -9
  144. package/dist/types/envVariables/getConfiguration.d.ts.map +0 -1
  145. package/dist/types/envVariables/index.d.ts +0 -5
  146. package/dist/types/envVariables/index.d.ts.map +0 -1
  147. package/dist/types/envVariables/loadEnvFile.d.ts.map +0 -1
  148. package/dist/types/envVariables/removeUndefinedValueObject.d.ts +0 -2
  149. package/dist/types/envVariables/removeUndefinedValueObject.d.ts.map +0 -1
  150. package/dist/types/envVariables/utils.d.ts +0 -7
  151. package/dist/types/envVariables/utils.d.ts.map +0 -1
  152. /package/dist/cjs/{envVariables/loadEnvFile.cjs → loadEnvFile.cjs} +0 -0
  153. /package/dist/esm/{envVariables/loadEnvFile.mjs → loadEnvFile.mjs} +0 -0
  154. /package/dist/types/{envVariables/loadEnvFile.d.ts → loadEnvFile.d.ts} +0 -0
@@ -18,26 +18,36 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var index_exports = {};
20
20
  __export(index_exports, {
21
+ ANSIColors: () => import_logger.ANSIColors,
21
22
  ESMxCJSRequire: () => import_ESMxCJSHelpers.ESMxCJSRequire,
22
23
  Locales: () => import_locales.Locales,
23
- formatEnvVariable: () => import_envVariables.formatEnvVariable,
24
+ clock: () => import_logger.clock,
25
+ colon: () => import_logger.colon,
26
+ colorize: () => import_logger.colorize,
27
+ colorizeKey: () => import_logger.colorizeKey,
28
+ colorizeLocales: () => import_logger.colorizeLocales,
29
+ colorizeNumber: () => import_logger.colorizeNumber,
30
+ colorizePath: () => import_logger.colorizePath,
31
+ getAlias: () => import_alias.getAlias,
24
32
  getAppLogger: () => import_logger.getAppLogger,
25
- getClientConfiguration: () => import_envVariables.getConfiguration,
26
33
  getConfiguration: () => import_getConfiguration.getConfiguration,
27
- getEnvFilePath: () => import_envVariables.getEnvFilePath,
28
- getPlatform: () => import_envVariables.getPlatform,
34
+ getEnvFilePath: () => import_loadEnvFile.getEnvFilePath,
29
35
  getSandBoxContext: () => import_getSandboxContext.getSandBoxContext,
30
36
  isESModule: () => import_ESMxCJSHelpers.isESModule,
31
- loadEnvFile: () => import_envVariables.loadEnvFile,
37
+ loadEnvFile: () => import_loadEnvFile.loadEnvFile,
32
38
  loadExternalFile: () => import_loadExternalFile.loadExternalFile,
33
39
  logger: () => import_logger.logger,
34
40
  normalizePath: () => import_normalizePath.normalizePath,
35
- retryManager: () => import_retryManager.retryManager
41
+ retryManager: () => import_retryManager.retryManager,
42
+ spinnerFrames: () => import_logger.spinnerFrames,
43
+ v: () => import_logger.v,
44
+ x: () => import_logger.x
36
45
  });
37
46
  module.exports = __toCommonJS(index_exports);
47
+ var import_alias = require('./alias.cjs');
38
48
  var import_getConfiguration = require('./configFile/getConfiguration.cjs');
39
- var import_envVariables = require('./envVariables/index.cjs');
40
49
  var import_getSandboxContext = require('./getSandboxContext.cjs');
50
+ var import_loadEnvFile = require('./loadEnvFile.cjs');
41
51
  var import_loadExternalFile = require('./loadExternalFile.cjs');
42
52
  var import_logger = require('./logger.cjs');
43
53
  var import_retryManager = require('./retryManager.cjs');
@@ -46,20 +56,29 @@ var import_ESMxCJSHelpers = require('./utils/ESMxCJSHelpers.cjs');
46
56
  var import_normalizePath = require('./utils/normalizePath.cjs');
47
57
  // Annotate the CommonJS export names for ESM import in node:
48
58
  0 && (module.exports = {
59
+ ANSIColors,
49
60
  ESMxCJSRequire,
50
61
  Locales,
51
- formatEnvVariable,
62
+ clock,
63
+ colon,
64
+ colorize,
65
+ colorizeKey,
66
+ colorizeLocales,
67
+ colorizeNumber,
68
+ colorizePath,
69
+ getAlias,
52
70
  getAppLogger,
53
- getClientConfiguration,
54
71
  getConfiguration,
55
72
  getEnvFilePath,
56
- getPlatform,
57
73
  getSandBoxContext,
58
74
  isESModule,
59
75
  loadEnvFile,
60
76
  loadExternalFile,
61
77
  logger,
62
78
  normalizePath,
63
- retryManager
79
+ retryManager,
80
+ spinnerFrames,
81
+ v,
82
+ x
64
83
  });
65
84
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export {\n getConfiguration,\n type GetConfigurationOptions,\n} from './configFile/getConfiguration';\nexport {\n formatEnvVariable,\n getConfiguration as getClientConfiguration,\n getEnvFilePath,\n getPlatform,\n loadEnvFile,\n} from './envVariables/index';\nexport { getSandBoxContext } from './getSandboxContext';\nexport { loadExternalFile } from './loadExternalFile';\nexport { getAppLogger, logger, type Logger } from './logger';\nexport { retryManager } from './retryManager';\nexport type {\n BaseContentConfig,\n BaseDerivedConfig,\n ContentConfig,\n CustomIntlayerConfig,\n InternationalizationConfig,\n IntlayerConfig,\n LogConfig,\n MiddlewareConfig,\n PatternsContentConfig,\n ResultDirDerivedConfig,\n ServerSetCookieRule,\n StrictMode,\n} from './types/config';\nexport { Locales } from './types/locales';\nexport type { LocalesValues } from './types/locales';\nexport { ESMxCJSRequire, isESModule } from './utils/ESMxCJSHelpers';\nexport { normalizePath } from './utils/normalizePath';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BAGO;AACP,0BAMO;AACP,+BAAkC;AAClC,8BAAiC;AACjC,oBAAkD;AAClD,0BAA6B;AAe7B,qBAAwB;AAExB,4BAA2C;AAC3C,2BAA8B;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { getAlias } from './alias';\nexport {\n getConfiguration,\n type GetConfigurationOptions,\n} from './configFile/getConfiguration';\nexport { getSandBoxContext } from './getSandboxContext';\nexport { getEnvFilePath, loadEnvFile } from './loadEnvFile';\nexport { loadExternalFile } from './loadExternalFile';\nexport {\n ANSIColors,\n clock,\n colon,\n colorize,\n colorizeKey,\n colorizeLocales,\n colorizeNumber,\n colorizePath,\n getAppLogger,\n logger,\n spinnerFrames,\n v,\n x,\n type Logger,\n} from './logger';\nexport { retryManager } from './retryManager';\nexport type {\n BaseContentConfig,\n BaseDerivedConfig,\n ContentConfig,\n CustomIntlayerConfig,\n InternationalizationConfig,\n IntlayerConfig,\n LogConfig,\n MiddlewareConfig,\n PatternsContentConfig,\n ResultDirDerivedConfig,\n ServerSetCookieRule,\n StrictMode,\n} from './types/config';\nexport { Locales } from './types/locales';\nexport type { LocalesValues } from './types/locales';\nexport { ESMxCJSRequire, isESModule } from './utils/ESMxCJSHelpers';\nexport { normalizePath } from './utils/normalizePath';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAyB;AACzB,8BAGO;AACP,+BAAkC;AAClC,yBAA4C;AAC5C,8BAAiC;AACjC,oBAeO;AACP,0BAA6B;AAe7B,qBAAwB;AAExB,4BAA2C;AAC3C,2BAA8B;","names":[]}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/loadEnvFile.ts"],"sourcesContent":["import dotenv from 'dotenv';\nimport { existsSync } from 'fs';\n\nconst DEFAULT_ENV = process.env.NODE_ENV ?? 'development';\n\nexport type LoadEnvFileOptions = {\n env?: string;\n envFile?: string;\n};\n\nexport const getEnvFilePath = (\n env: string = process.env.NODE_ENV ?? 'development',\n envFile?: string\n): string | undefined => {\n const envFiles = envFile\n ? [envFile]\n : [`.env.${env}.local`, `.env.${env}`, '.env.local', '.env'];\n\n return envFiles.find(existsSync); // Returns the first existing env file\n};\n\nexport const loadEnvFile = (options?: Partial<LoadEnvFileOptions>) => {\n const env = options?.env ?? DEFAULT_ENV;\n\n const envFiles = options?.envFile\n ? [options.envFile]\n : [`.env.${env}.local`, `.env.${env}`, '.env.local', '.env'];\n\n const result = {};\n\n dotenv.config({\n path: envFiles,\n processEnv: result,\n });\n\n return result; // Return the parsed env object\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAmB;AACnB,gBAA2B;AAE3B,MAAM,cAAc,QAAQ,IAAI,YAAY;AAOrC,MAAM,iBAAiB,CAC5B,MAAc,QAAQ,IAAI,YAAY,eACtC,YACuB;AACvB,QAAM,WAAW,UACb,CAAC,OAAO,IACR,CAAC,QAAQ,GAAG,UAAU,QAAQ,GAAG,IAAI,cAAc,MAAM;AAE7D,SAAO,SAAS,KAAK,oBAAU;AACjC;AAEO,MAAM,cAAc,CAAC,YAA0C;AACpE,QAAM,MAAM,SAAS,OAAO;AAE5B,QAAM,WAAW,SAAS,UACtB,CAAC,QAAQ,OAAO,IAChB,CAAC,QAAQ,GAAG,UAAU,QAAQ,GAAG,IAAI,cAAc,MAAM;AAE7D,QAAM,SAAS,CAAC;AAEhB,gBAAAA,QAAO,OAAO;AAAA,IACZ,MAAM;AAAA,IACN,YAAY;AAAA,EACd,CAAC;AAED,SAAO;AACT;","names":["dotenv"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/loadExternalFile.ts"],"sourcesContent":["import { buildSync, type BuildOptions, type BuildResult } from 'esbuild';\nimport { dirname } from 'path';\nimport { runInNewContext } from 'vm';\nimport { LoadEnvFileOptions } from './envVariables/loadEnvFile';\nimport { getSandBoxContext } from './getSandboxContext';\nimport { logger } from './logger';\nimport { ESMxCJSRequire } from './utils/ESMxCJSHelpers';\n\nconst getTransformationOptions = (filePath: string): BuildOptions => ({\n loader: {\n '.js': 'js',\n '.jsx': 'jsx',\n '.mjs': 'js',\n '.ts': 'ts',\n '.tsx': 'tsx',\n '.cjs': 'js',\n '.json': 'json',\n '.md': 'text',\n '.mdx': 'text',\n },\n format: 'cjs', // Output format as commonjs\n target: 'es2017',\n packages: 'external',\n write: false,\n bundle: true,\n banner: {\n js: [\n `globalThis.intlayer_file_path = ${JSON.stringify(filePath)};`,\n `globalThis.intlayer_file_dir = ${JSON.stringify(dirname(filePath))};`,\n ].join('\\n'),\n },\n});\n\n/**\n * Load the content declaration from the given path\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadExternalFile = (\n filePath: string,\n envVarOptions?: LoadEnvFileOptions,\n projectRequire = ESMxCJSRequire\n): any | undefined => {\n let fileContent: any | undefined = undefined;\n\n const fileExtension = filePath.split('.').pop() ?? '';\n\n try {\n if (fileExtension === 'json') {\n // Remove cache to force reloading\n delete ESMxCJSRequire.cache[ESMxCJSRequire.resolve(filePath)];\n // Assume JSON\n return ESMxCJSRequire(filePath);\n }\n\n // Rest is JS, MJS or TS\n\n const moduleResult: BuildResult = buildSync({\n entryPoints: [filePath],\n ...getTransformationOptions(filePath),\n });\n\n const moduleResultString = moduleResult.outputFiles?.[0].text;\n\n if (!moduleResultString) {\n logger('File could not be loaded.', { level: 'error' });\n return undefined;\n }\n\n const sandboxContext = getSandBoxContext(envVarOptions, projectRequire);\n\n runInNewContext(moduleResultString, sandboxContext);\n\n if (\n sandboxContext.exports.default &&\n Object.keys(sandboxContext.exports.default).length > 0\n ) {\n // ES Module\n fileContent = sandboxContext.exports.default;\n } else if (\n sandboxContext.module.exports.defaults &&\n Object.keys(sandboxContext.module.exports.defaults).length > 0\n ) {\n // CommonJS\n fileContent = sandboxContext.module.exports.default;\n } else if (\n sandboxContext.module.exports.default &&\n Object.keys(sandboxContext.module.exports.default).length > 0\n ) {\n // ES Module\n fileContent = sandboxContext.module.exports.default;\n } else if (\n sandboxContext.module.exports &&\n Object.keys(sandboxContext.module.exports).length > 0\n ) {\n // Other\n fileContent = sandboxContext.module.exports;\n }\n\n if (typeof fileContent === 'undefined') {\n logger(`File file could not be loaded. Path : ${filePath}`);\n return undefined;\n }\n\n return fileContent;\n } catch (error) {\n logger(\n `Error: ${error} ${JSON.stringify((error as Error).stack, null, 2)}`,\n {\n level: 'error',\n }\n );\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA+D;AAC/D,kBAAwB;AACxB,gBAAgC;AAEhC,+BAAkC;AAClC,oBAAuB;AACvB,4BAA+B;AAE/B,MAAM,2BAA2B,CAAC,cAAoC;AAAA,EACpE,QAAQ;AAAA,IACN,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,OAAO;AAAA,IACP,QAAQ;AAAA,EACV;AAAA,EACA,QAAQ;AAAA;AAAA,EACR,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,QAAQ;AAAA,IACN,IAAI;AAAA,MACF,mCAAmC,KAAK,UAAU,QAAQ,CAAC;AAAA,MAC3D,kCAAkC,KAAK,cAAU,qBAAQ,QAAQ,CAAC,CAAC;AAAA,IACrE,EAAE,KAAK,IAAI;AAAA,EACb;AACF;AAOO,MAAM,mBAAmB,CAC9B,UACA,eACA,iBAAiB,yCACG;AACpB,MAAI,cAA+B;AAEnC,QAAM,gBAAgB,SAAS,MAAM,GAAG,EAAE,IAAI,KAAK;AAEnD,MAAI;AACF,QAAI,kBAAkB,QAAQ;AAE5B,aAAO,qCAAe,MAAM,qCAAe,QAAQ,QAAQ,CAAC;AAE5D,iBAAO,sCAAe,QAAQ;AAAA,IAChC;AAIA,UAAM,mBAA4B,0BAAU;AAAA,MAC1C,aAAa,CAAC,QAAQ;AAAA,MACtB,GAAG,yBAAyB,QAAQ;AAAA,IACtC,CAAC;AAED,UAAM,qBAAqB,aAAa,cAAc,CAAC,EAAE;AAEzD,QAAI,CAAC,oBAAoB;AACvB,gCAAO,6BAA6B,EAAE,OAAO,QAAQ,CAAC;AACtD,aAAO;AAAA,IACT;AAEA,UAAM,qBAAiB,4CAAkB,eAAe,cAAc;AAEtE,mCAAgB,oBAAoB,cAAc;AAElD,QACE,eAAe,QAAQ,WACvB,OAAO,KAAK,eAAe,QAAQ,OAAO,EAAE,SAAS,GACrD;AAEA,oBAAc,eAAe,QAAQ;AAAA,IACvC,WACE,eAAe,OAAO,QAAQ,YAC9B,OAAO,KAAK,eAAe,OAAO,QAAQ,QAAQ,EAAE,SAAS,GAC7D;AAEA,oBAAc,eAAe,OAAO,QAAQ;AAAA,IAC9C,WACE,eAAe,OAAO,QAAQ,WAC9B,OAAO,KAAK,eAAe,OAAO,QAAQ,OAAO,EAAE,SAAS,GAC5D;AAEA,oBAAc,eAAe,OAAO,QAAQ;AAAA,IAC9C,WACE,eAAe,OAAO,WACtB,OAAO,KAAK,eAAe,OAAO,OAAO,EAAE,SAAS,GACpD;AAEA,oBAAc,eAAe,OAAO;AAAA,IACtC;AAEA,QAAI,OAAO,gBAAgB,aAAa;AACtC,gCAAO,yCAAyC,QAAQ,EAAE;AAC1D,aAAO;AAAA,IACT;AAEA,WAAO;AAAA,EACT,SAAS,OAAO;AACd;AAAA,MACE,UAAU,KAAK,IAAI,KAAK,UAAW,MAAgB,OAAO,MAAM,CAAC,CAAC;AAAA,MAClE;AAAA,QACE,OAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/loadExternalFile.ts"],"sourcesContent":["import { buildSync, type BuildOptions, type BuildResult } from 'esbuild';\nimport { dirname } from 'path';\nimport { runInNewContext } from 'vm';\nimport { getSandBoxContext } from './getSandboxContext';\nimport { LoadEnvFileOptions } from './loadEnvFile';\nimport { logger } from './logger';\nimport { ESMxCJSRequire } from './utils/ESMxCJSHelpers';\n\nconst getTransformationOptions = (filePath: string): BuildOptions => ({\n loader: {\n '.js': 'js',\n '.jsx': 'jsx',\n '.mjs': 'js',\n '.ts': 'ts',\n '.tsx': 'tsx',\n '.cjs': 'js',\n '.json': 'json',\n '.md': 'text',\n '.mdx': 'text',\n },\n format: 'cjs', // Output format as commonjs\n target: 'es2017',\n packages: 'external',\n write: false,\n bundle: true,\n banner: {\n js: [\n `globalThis.intlayer_file_path = ${JSON.stringify(filePath)};`,\n `globalThis.intlayer_file_dir = ${JSON.stringify(dirname(filePath))};`,\n ].join('\\n'),\n },\n});\n\n/**\n * Load the content declaration from the given path\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nexport const loadExternalFile = (\n filePath: string,\n envVarOptions?: LoadEnvFileOptions,\n projectRequire = ESMxCJSRequire\n): any | undefined => {\n let fileContent: any | undefined = undefined;\n\n const fileExtension = filePath.split('.').pop() ?? '';\n\n try {\n if (fileExtension === 'json') {\n // Remove cache to force reloading\n delete ESMxCJSRequire.cache[ESMxCJSRequire.resolve(filePath)];\n // Assume JSON\n return ESMxCJSRequire(filePath);\n }\n\n // Rest is JS, MJS or TS\n\n const moduleResult: BuildResult = buildSync({\n entryPoints: [filePath],\n ...getTransformationOptions(filePath),\n });\n\n const moduleResultString = moduleResult.outputFiles?.[0].text;\n\n if (!moduleResultString) {\n logger('File could not be loaded.', { level: 'error' });\n return undefined;\n }\n\n const sandboxContext = getSandBoxContext(envVarOptions, projectRequire);\n\n runInNewContext(moduleResultString, sandboxContext);\n\n if (\n sandboxContext.exports.default &&\n Object.keys(sandboxContext.exports.default).length > 0\n ) {\n // ES Module\n fileContent = sandboxContext.exports.default;\n } else if (\n sandboxContext.module.exports.defaults &&\n Object.keys(sandboxContext.module.exports.defaults).length > 0\n ) {\n // CommonJS\n fileContent = sandboxContext.module.exports.default;\n } else if (\n sandboxContext.module.exports.default &&\n Object.keys(sandboxContext.module.exports.default).length > 0\n ) {\n // ES Module\n fileContent = sandboxContext.module.exports.default;\n } else if (\n sandboxContext.module.exports &&\n Object.keys(sandboxContext.module.exports).length > 0\n ) {\n // Other\n fileContent = sandboxContext.module.exports;\n }\n\n if (typeof fileContent === 'undefined') {\n logger(`File file could not be loaded. Path : ${filePath}`);\n return undefined;\n }\n\n return fileContent;\n } catch (error) {\n logger(\n `Error: ${error} ${JSON.stringify((error as Error).stack, null, 2)}`,\n {\n level: 'error',\n }\n );\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA+D;AAC/D,kBAAwB;AACxB,gBAAgC;AAChC,+BAAkC;AAElC,oBAAuB;AACvB,4BAA+B;AAE/B,MAAM,2BAA2B,CAAC,cAAoC;AAAA,EACpE,QAAQ;AAAA,IACN,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,OAAO;AAAA,IACP,QAAQ;AAAA,EACV;AAAA,EACA,QAAQ;AAAA;AAAA,EACR,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,QAAQ;AAAA,IACN,IAAI;AAAA,MACF,mCAAmC,KAAK,UAAU,QAAQ,CAAC;AAAA,MAC3D,kCAAkC,KAAK,cAAU,qBAAQ,QAAQ,CAAC,CAAC;AAAA,IACrE,EAAE,KAAK,IAAI;AAAA,EACb;AACF;AAOO,MAAM,mBAAmB,CAC9B,UACA,eACA,iBAAiB,yCACG;AACpB,MAAI,cAA+B;AAEnC,QAAM,gBAAgB,SAAS,MAAM,GAAG,EAAE,IAAI,KAAK;AAEnD,MAAI;AACF,QAAI,kBAAkB,QAAQ;AAE5B,aAAO,qCAAe,MAAM,qCAAe,QAAQ,QAAQ,CAAC;AAE5D,iBAAO,sCAAe,QAAQ;AAAA,IAChC;AAIA,UAAM,mBAA4B,0BAAU;AAAA,MAC1C,aAAa,CAAC,QAAQ;AAAA,MACtB,GAAG,yBAAyB,QAAQ;AAAA,IACtC,CAAC;AAED,UAAM,qBAAqB,aAAa,cAAc,CAAC,EAAE;AAEzD,QAAI,CAAC,oBAAoB;AACvB,gCAAO,6BAA6B,EAAE,OAAO,QAAQ,CAAC;AACtD,aAAO;AAAA,IACT;AAEA,UAAM,qBAAiB,4CAAkB,eAAe,cAAc;AAEtE,mCAAgB,oBAAoB,cAAc;AAElD,QACE,eAAe,QAAQ,WACvB,OAAO,KAAK,eAAe,QAAQ,OAAO,EAAE,SAAS,GACrD;AAEA,oBAAc,eAAe,QAAQ;AAAA,IACvC,WACE,eAAe,OAAO,QAAQ,YAC9B,OAAO,KAAK,eAAe,OAAO,QAAQ,QAAQ,EAAE,SAAS,GAC7D;AAEA,oBAAc,eAAe,OAAO,QAAQ;AAAA,IAC9C,WACE,eAAe,OAAO,QAAQ,WAC9B,OAAO,KAAK,eAAe,OAAO,QAAQ,OAAO,EAAE,SAAS,GAC5D;AAEA,oBAAc,eAAe,OAAO,QAAQ;AAAA,IAC9C,WACE,eAAe,OAAO,WACtB,OAAO,KAAK,eAAe,OAAO,OAAO,EAAE,SAAS,GACpD;AAEA,oBAAc,eAAe,OAAO;AAAA,IACtC;AAEA,QAAI,OAAO,gBAAgB,aAAa;AACtC,gCAAO,yCAAyC,QAAQ,EAAE;AAC1D,aAAO;AAAA,IACT;AAEA,WAAO;AAAA,EACT,SAAS,OAAO;AACd;AAAA,MACE,UAAU,KAAK,IAAI,KAAK,UAAW,MAAgB,OAAO,MAAM,CAAC,CAAC;AAAA,MAClE;AAAA,QACE,OAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -18,8 +18,19 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var logger_exports = {};
20
20
  __export(logger_exports, {
21
+ ANSIColors: () => ANSIColors,
22
+ clock: () => clock,
23
+ colon: () => colon,
24
+ colorize: () => colorize,
25
+ colorizeKey: () => colorizeKey,
26
+ colorizeLocales: () => colorizeLocales,
27
+ colorizeNumber: () => colorizeNumber,
28
+ colorizePath: () => colorizePath,
21
29
  getAppLogger: () => getAppLogger,
22
- logger: () => logger
30
+ logger: () => logger,
31
+ spinnerFrames: () => spinnerFrames,
32
+ v: () => v,
33
+ x: () => x
23
34
  });
24
35
  module.exports = __toCommonJS(logger_exports);
25
36
  const logger = (content, details = {
@@ -46,13 +57,105 @@ const logger = (content, details = {
46
57
  }
47
58
  console.log(...flatContent);
48
59
  };
49
- const getAppLogger = (configuration) => (content, details) => logger(content, {
60
+ var ANSIColors = /* @__PURE__ */ ((ANSIColors2) => {
61
+ ANSIColors2["RESET"] = "\x1B[0m";
62
+ ANSIColors2["GREY"] = "\x1B[90m";
63
+ ANSIColors2["GREY_DARK"] = "\x1B[38;5;239m";
64
+ ANSIColors2["BLUE"] = "\x1B[34m";
65
+ ANSIColors2["RED"] = "\x1B[31m";
66
+ ANSIColors2["GREEN"] = "\x1B[32m";
67
+ ANSIColors2["YELLOW"] = "\x1B[33m";
68
+ ANSIColors2["MAGENTA"] = "\x1B[35m";
69
+ ANSIColors2["BEIGE"] = "\x1B[38;5;3m";
70
+ ANSIColors2["CYAN"] = "\x1B[36m";
71
+ ANSIColors2["WHITE"] = "\x1B[37m";
72
+ return ANSIColors2;
73
+ })(ANSIColors || {});
74
+ const spinnerFrames = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
75
+ const getAppLogger = (configuration, globalDetails) => (content, details) => logger(content, {
50
76
  ...details ?? {},
51
- config: { ...configuration?.log, ...details?.config ?? {} }
77
+ config: {
78
+ ...configuration?.log,
79
+ ...globalDetails?.config,
80
+ ...details?.config ?? {}
81
+ }
52
82
  });
83
+ const colorize = (s, color) => color ? `${color}${s}${"\x1B[0m" /* RESET */}` : s;
84
+ const colorizeLocales = (locales, color = "\x1B[32m" /* GREEN */) => [locales].flat().map((locale) => colorize(locale, color)).join(`, `);
85
+ const colorizeKey = (keyPath, color = "\x1B[38;5;3m" /* BEIGE */) => [keyPath].flat().map((key) => colorize(key, color)).join(`, `);
86
+ const colorizePath = (path, color = "\x1B[90m" /* GREY */) => [path].flat().map((p) => colorize(p, color)).join(`, `);
87
+ const colorizeNumber = (number, options = {
88
+ zero: "\x1B[34m" /* BLUE */,
89
+ one: "\x1B[34m" /* BLUE */,
90
+ two: "\x1B[34m" /* BLUE */,
91
+ few: "\x1B[34m" /* BLUE */,
92
+ many: "\x1B[34m" /* BLUE */,
93
+ other: "\x1B[34m" /* BLUE */
94
+ }) => {
95
+ if (number === 0) {
96
+ const color2 = options.zero ?? "\x1B[32m" /* GREEN */;
97
+ return colorize(number.toString(), color2);
98
+ }
99
+ const rule = new Intl.PluralRules("en").select(number);
100
+ const color = options[rule];
101
+ return colorize(number.toString(), color);
102
+ };
103
+ const removeColor = (text) => text.replace(/\x1b\[[0-9;]*m/g, "");
104
+ const getLength = (length) => {
105
+ let value = 0;
106
+ if (typeof length === "number") {
107
+ value = length;
108
+ }
109
+ if (typeof length === "string") {
110
+ value = length.length;
111
+ }
112
+ if (Array.isArray(length) && length.every((l) => typeof l === "string")) {
113
+ value = Math.max(...length.map((str) => str.length));
114
+ }
115
+ if (Array.isArray(length) && length.every((l) => typeof l === "number")) {
116
+ value = Math.max(...length);
117
+ }
118
+ return Math.max(value, 0);
119
+ };
120
+ const defaultColonOptions = {
121
+ colSize: 0,
122
+ minSize: 0,
123
+ maxSize: Infinity,
124
+ pad: "right",
125
+ padChar: "0"
126
+ };
127
+ const colon = (text, options) => [text].flat().map((text2) => {
128
+ const { colSize, minSize, maxSize, pad, padChar } = {
129
+ ...defaultColonOptions,
130
+ ...options ?? {}
131
+ };
132
+ const length = getLength(colSize);
133
+ const spacesLength = Math.max(
134
+ minSize,
135
+ Math.min(maxSize, length - removeColor(text2).length)
136
+ );
137
+ if (pad === "left") {
138
+ return `${" ".repeat(spacesLength)}${text2}`;
139
+ }
140
+ return `${text2}${" ".repeat(spacesLength)}`;
141
+ }).join("");
142
+ const x = colorize("\u2717", "\x1B[31m" /* RED */);
143
+ const v = colorize("\u2713", "\x1B[32m" /* GREEN */);
144
+ const clock = colorize("\u23F2", "\x1B[34m" /* BLUE */);
53
145
  // Annotate the CommonJS export names for ESM import in node:
54
146
  0 && (module.exports = {
147
+ ANSIColors,
148
+ clock,
149
+ colon,
150
+ colorize,
151
+ colorizeKey,
152
+ colorizeLocales,
153
+ colorizeNumber,
154
+ colorizePath,
55
155
  getAppLogger,
56
- logger
156
+ logger,
157
+ spinnerFrames,
158
+ v,
159
+ x
57
160
  });
58
161
  //# sourceMappingURL=logger.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/logger.ts"],"sourcesContent":["import type { CustomIntlayerConfig } from './types/config';\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\nexport const logger: Logger = (\n content,\n details = {\n isVerbose: false,\n level: undefined,\n config: { mode: 'default', prefix: '' },\n }\n) => {\n const mode = details.config?.mode ?? 'default';\n const prefix = Boolean(details.config?.prefix)\n ? details.config?.prefix\n : undefined;\n\n if (mode === 'disabled') return;\n\n if (details.isVerbose && mode !== 'verbose') return;\n\n const flatContent = prefix ? [prefix, ...[content].flat()] : [content].flat();\n\n if (details.level === 'debug') {\n return console.debug(...flatContent);\n }\n\n if (details.level === 'info') {\n return console.info(...flatContent);\n }\n\n if (details.level === 'warn') {\n return console.warn(...flatContent);\n }\n\n if (details.level === 'error') {\n return console.error(...flatContent);\n }\n\n console.log(...flatContent);\n};\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?: CustomIntlayerConfig) => (content: any, details?: Details) =>\n logger(content, {\n ...(details ?? {}),\n config: { ...configuration?.log, ...(details?.config ?? {}) },\n });\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUO,MAAM,SAAiB,CAC5B,SACA,UAAU;AAAA,EACR,WAAW;AAAA,EACX,OAAO;AAAA,EACP,QAAQ,EAAE,MAAM,WAAW,QAAQ,GAAG;AACxC,MACG;AACH,QAAM,OAAO,QAAQ,QAAQ,QAAQ;AACrC,QAAM,SAAS,QAAQ,QAAQ,QAAQ,MAAM,IACzC,QAAQ,QAAQ,SAChB;AAEJ,MAAI,SAAS,WAAY;AAEzB,MAAI,QAAQ,aAAa,SAAS,UAAW;AAE7C,QAAM,cAAc,SAAS,CAAC,QAAQ,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK;AAE5E,MAAI,QAAQ,UAAU,SAAS;AAC7B,WAAO,QAAQ,MAAM,GAAG,WAAW;AAAA,EACrC;AAEA,MAAI,QAAQ,UAAU,QAAQ;AAC5B,WAAO,QAAQ,KAAK,GAAG,WAAW;AAAA,EACpC;AAEA,MAAI,QAAQ,UAAU,QAAQ;AAC5B,WAAO,QAAQ,KAAK,GAAG,WAAW;AAAA,EACpC;AAEA,MAAI,QAAQ,UAAU,SAAS;AAC7B,WAAO,QAAQ,MAAM,GAAG,WAAW;AAAA,EACrC;AAEA,UAAQ,IAAI,GAAG,WAAW;AAC5B;AAOO,MAAM,eACX,CAAC,kBAAyC,CAAC,SAAc,YACvD,OAAO,SAAS;AAAA,EACd,GAAI,WAAW,CAAC;AAAA,EAChB,QAAQ,EAAE,GAAG,eAAe,KAAK,GAAI,SAAS,UAAU,CAAC,EAAG;AAC9D,CAAC;","names":[]}
1
+ {"version":3,"sources":["../../src/logger.ts"],"sourcesContent":["import type { CustomIntlayerConfig } from './types/config';\nimport { Locales } from './types/locales';\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\nexport const logger: Logger = (\n content,\n details = {\n isVerbose: false,\n level: undefined,\n config: { mode: 'default', prefix: '' },\n }\n) => {\n const mode = details.config?.mode ?? 'default';\n const prefix = Boolean(details.config?.prefix)\n ? details.config?.prefix\n : undefined;\n\n if (mode === 'disabled') return;\n\n if (details.isVerbose && mode !== 'verbose') return;\n\n const flatContent = prefix ? [prefix, ...[content].flat()] : [content].flat();\n\n if (details.level === 'debug') {\n return console.debug(...flatContent);\n }\n\n if (details.level === 'info') {\n return console.info(...flatContent);\n }\n\n if (details.level === 'warn') {\n return console.warn(...flatContent);\n }\n\n if (details.level === 'error') {\n return console.error(...flatContent);\n }\n\n console.log(...flatContent);\n};\n\nexport enum ANSIColors {\n RESET = '\\x1b[0m',\n GREY = '\\x1b[90m',\n GREY_DARK = '\\x1b[38;5;239m',\n BLUE = '\\x1b[34m',\n RED = '\\x1b[31m',\n GREEN = '\\x1b[32m',\n YELLOW = '\\x1b[33m',\n MAGENTA = '\\x1b[35m',\n BEIGE = '\\x1b[38;5;3m',\n CYAN = '\\x1b[36m',\n WHITE = '\\x1b[37m',\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?: CustomIntlayerConfig, 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 = (s: string, color?: ANSIColors): string =>\n color ? `${color}${s}${ANSIColors.RESET}` : s;\n\nexport const colorizeLocales = (\n locales: Locales | Locales[],\n color = ANSIColors.GREEN\n) =>\n [locales]\n .flat()\n .map((locale) => colorize(locale, color))\n .join(`, `);\n\nexport const colorizeKey = (\n keyPath: string | string[],\n color = ANSIColors.BEIGE\n) =>\n [keyPath]\n .flat()\n .map((key) => colorize(key, color))\n .join(`, `);\n\nexport const colorizePath = (\n path: string | string[],\n color = ANSIColors.GREY\n) =>\n [path]\n .flat()\n .map((p) => colorize(p, color))\n .join(`, `);\n\n/**\n * Colorize numeric value using Intl.NumberFormat and optional ANSI colors.\n *\n * Examples:\n * colorizeNumber(2, [{ pluralRule: 'one' , color: ANSIColors.GREEN}, { pluralRule: 'other' , color: ANSIColors.RED}]) // \"'\\x1b[31m2\\x1b[0m\"\n */\nexport const colorizeNumber = (\n number: number,\n options: Partial<Record<Intl.LDMLPluralRule, ANSIColors>> = {\n zero: ANSIColors.BLUE,\n one: ANSIColors.BLUE,\n two: ANSIColors.BLUE,\n few: ANSIColors.BLUE,\n many: ANSIColors.BLUE,\n other: ANSIColors.BLUE,\n }\n): string => {\n if (number === 0) {\n const color = options.zero ?? ANSIColors.GREEN;\n return colorize(number.toString(), color);\n }\n\n const rule = new Intl.PluralRules('en').select(number);\n const color = options[rule];\n return colorize(number.toString(), color);\n};\n\nconst removeColor = (text: string) => 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 (Array.isArray(length) && length.every((l) => typeof l === 'string')) {\n value = Math.max(...length.map((str) => str.length));\n }\n if (Array.isArray(length) && length.every((l) => typeof l === 'number')) {\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, padChar } = {\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('✗', ANSIColors.RED);\nexport const v = colorize('✓', ANSIColors.GREEN);\nexport const clock = colorize('⏲', ANSIColors.BLUE);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWO,MAAM,SAAiB,CAC5B,SACA,UAAU;AAAA,EACR,WAAW;AAAA,EACX,OAAO;AAAA,EACP,QAAQ,EAAE,MAAM,WAAW,QAAQ,GAAG;AACxC,MACG;AACH,QAAM,OAAO,QAAQ,QAAQ,QAAQ;AACrC,QAAM,SAAS,QAAQ,QAAQ,QAAQ,MAAM,IACzC,QAAQ,QAAQ,SAChB;AAEJ,MAAI,SAAS,WAAY;AAEzB,MAAI,QAAQ,aAAa,SAAS,UAAW;AAE7C,QAAM,cAAc,SAAS,CAAC,QAAQ,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK;AAE5E,MAAI,QAAQ,UAAU,SAAS;AAC7B,WAAO,QAAQ,MAAM,GAAG,WAAW;AAAA,EACrC;AAEA,MAAI,QAAQ,UAAU,QAAQ;AAC5B,WAAO,QAAQ,KAAK,GAAG,WAAW;AAAA,EACpC;AAEA,MAAI,QAAQ,UAAU,QAAQ;AAC5B,WAAO,QAAQ,KAAK,GAAG,WAAW;AAAA,EACpC;AAEA,MAAI,QAAQ,UAAU,SAAS;AAC7B,WAAO,QAAQ,MAAM,GAAG,WAAW;AAAA,EACrC;AAEA,UAAQ,IAAI,GAAG,WAAW;AAC5B;AAEO,IAAK,aAAL,kBAAKA,gBAAL;AACL,EAAAA,YAAA,WAAQ;AACR,EAAAA,YAAA,UAAO;AACP,EAAAA,YAAA,eAAY;AACZ,EAAAA,YAAA,UAAO;AACP,EAAAA,YAAA,SAAM;AACN,EAAAA,YAAA,WAAQ;AACR,EAAAA,YAAA,YAAS;AACT,EAAAA,YAAA,aAAU;AACV,EAAAA,YAAA,WAAQ;AACR,EAAAA,YAAA,UAAO;AACP,EAAAA,YAAA,WAAQ;AAXE,SAAAA;AAAA,GAAA;AAcL,MAAM,gBAAgB,CAAC,UAAK,UAAK,UAAK,UAAK,UAAK,UAAK,UAAK,UAAK,UAAK,QAAG;AAOvE,MAAM,eACX,CAAC,eAAsC,kBACvC,CAAC,SAAc,YACb,OAAO,SAAS;AAAA,EACd,GAAI,WAAW,CAAC;AAAA,EAChB,QAAQ;AAAA,IACN,GAAG,eAAe;AAAA,IAClB,GAAG,eAAe;AAAA,IAClB,GAAI,SAAS,UAAU,CAAC;AAAA,EAC1B;AACF,CAAC;AAEE,MAAM,WAAW,CAAC,GAAW,UAClC,QAAQ,GAAG,KAAK,GAAG,CAAC,GAAG,qBAAgB,KAAK;AAEvC,MAAM,kBAAkB,CAC7B,SACA,QAAQ,2BAER,CAAC,OAAO,EACL,KAAK,EACL,IAAI,CAAC,WAAW,SAAS,QAAQ,KAAK,CAAC,EACvC,KAAK,IAAI;AAEP,MAAM,cAAc,CACzB,SACA,QAAQ,+BAER,CAAC,OAAO,EACL,KAAK,EACL,IAAI,CAAC,QAAQ,SAAS,KAAK,KAAK,CAAC,EACjC,KAAK,IAAI;AAEP,MAAM,eAAe,CAC1B,MACA,QAAQ,0BAER,CAAC,IAAI,EACF,KAAK,EACL,IAAI,CAAC,MAAM,SAAS,GAAG,KAAK,CAAC,EAC7B,KAAK,IAAI;AAQP,MAAM,iBAAiB,CAC5B,QACA,UAA4D;AAAA,EAC1D,MAAM;AAAA,EACN,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,MAAM;AAAA,EACN,OAAO;AACT,MACW;AACX,MAAI,WAAW,GAAG;AAChB,UAAMC,SAAQ,QAAQ,QAAQ;AAC9B,WAAO,SAAS,OAAO,SAAS,GAAGA,MAAK;AAAA,EAC1C;AAEA,QAAM,OAAO,IAAI,KAAK,YAAY,IAAI,EAAE,OAAO,MAAM;AACrD,QAAM,QAAQ,QAAQ,IAAI;AAC1B,SAAO,SAAS,OAAO,SAAS,GAAG,KAAK;AAC1C;AAEA,MAAM,cAAc,CAAC,SAAiB,KAAK,QAAQ,mBAAmB,EAAE;AAExE,MAAM,YAAY,CAAC,WAA0D;AAC3E,MAAI,QAAgB;AACpB,MAAI,OAAO,WAAW,UAAU;AAC9B,YAAQ;AAAA,EACV;AACA,MAAI,OAAO,WAAW,UAAU;AAC9B,YAAQ,OAAO;AAAA,EACjB;AACA,MAAI,MAAM,QAAQ,MAAM,KAAK,OAAO,MAAM,CAAC,MAAM,OAAO,MAAM,QAAQ,GAAG;AACvE,YAAQ,KAAK,IAAI,GAAG,OAAO,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC;AAAA,EACrD;AACA,MAAI,MAAM,QAAQ,MAAM,KAAK,OAAO,MAAM,CAAC,MAAM,OAAO,MAAM,QAAQ,GAAG;AACvE,YAAQ,KAAK,IAAI,GAAG,MAAM;AAAA,EAC5B;AACA,SAAO,KAAK,IAAI,OAAO,CAAC;AAC1B;AAEA,MAAM,sBAAsB;AAAA,EAC1B,SAAS;AAAA,EACT,SAAS;AAAA,EACT,SAAS;AAAA,EACT,KAAK;AAAA,EACL,SAAS;AACX;AAQO,MAAM,QAAQ,CACnB,MACA,YAQA,CAAC,IAAI,EACF,KAAK,EACL,IAAI,CAACC,UAAS;AACb,QAAM,EAAE,SAAS,SAAS,SAAS,KAAK,QAAQ,IAAI;AAAA,IAClD,GAAG;AAAA,IACH,GAAI,WAAW,CAAC;AAAA,EAClB;AAEA,QAAM,SAAS,UAAU,OAAO;AAChC,QAAM,eAAe,KAAK;AAAA,IACxB;AAAA,IACA,KAAK,IAAI,SAAU,SAAS,YAAYA,KAAI,EAAE,MAAM;AAAA,EACtD;AAEA,MAAI,QAAQ,QAAQ;AAClB,WAAO,GAAG,IAAI,OAAO,YAAY,CAAC,GAAGA,KAAI;AAAA,EAC3C;AAEA,SAAO,GAAGA,KAAI,GAAG,IAAI,OAAO,YAAY,CAAC;AAC3C,CAAC,EACA,KAAK,EAAE;AAEL,MAAM,IAAI,SAAS,UAAK,oBAAc;AACtC,MAAM,IAAI,SAAS,UAAK,sBAAgB;AACxC,MAAM,QAAQ,SAAS,UAAK,qBAAe;","names":["ANSIColors","color","text"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/types/config.ts"],"sourcesContent":["import type { Locales } from './locales';\n\nexport type StrictMode = 'strict' | 'inclusive' | 'loose';\n\n/**\n * Configuration for internationalization settings\n */\nexport type InternationalizationConfig = {\n /**\n * Locales available in the application\n *\n * Default: [Locales.ENGLISH]\n *\n * You can define a list of available locales to support in the application.\n */\n 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: 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: StrictMode;\n\n /**\n * Default locale of the application for fallback\n *\n * Default: Locales.ENGLISH\n *\n * Used to specify a fallback locale in case no other locale is set.\n */\n defaultLocale: Locales;\n};\n\nexport type ServerSetCookieRule = 'always' | 'never';\n\n/**\n * Configuration for middleware behaviors\n */\nexport type MiddlewareConfig = {\n /**\n * Header name to get the locale from the request\n *\n * Default: 'x-intlayer-locale'\n *\n * The HTTP header key used to determine the current locale.\n */\n headerName: string;\n\n /**\n * Cookie name to store the locale information\n *\n * Default: 'INTLAYER_LOCALE'\n *\n * The cookie key where the locale information is stored.\n */\n cookieName: string;\n\n /**\n * Prefix default prefix the default locale to the path as other locales.\n *\n * Example with prefixDefault = true and defaultLocale = 'en':\n * path = /en/dashboard or /fr/dashboard\n *\n * Example with prefixDefault = false and defaultLocale = 'en':\n * path = /dashboard or /fr/dashboard\n *\n *\n * Default: false\n */\n prefixDefault: boolean;\n\n /**\n * Base path for application URLs\n *\n * Default: ''\n *\n * Defines the base path where the application is accessible from.\n */\n basePath: string;\n\n /**\n * Strategy for setting the locale cookie on the server\n *\n * Default: 'always'\n *\n * This setting controls when the server sets the locale cookie. It can either set the cookie on every request or never set it.\n */\n serverSetCookie: ServerSetCookieRule;\n\n /**\n * Indicates if no prefix should be used in the URL for locale\n *\n * Default: false\n *\n * If true, no locale-based prefix is used in the URL.\n */\n noPrefix: boolean;\n\n /**\n * Controls whether locale detection occurs during Next.js prefetch requests\n * - true: Detect and apply locale during prefetch\n * - false: Use default locale during prefetch (recommended)\n *\n * This setting affects how Next.js handles locale prefetching:\n *\n * Example scenario:\n * - User's browser language is 'fr'\n * - Current page is /fr/about\n * - Link prefetches /about\n *\n * With `detectLocaleOnPrefetchNoPrefix:true`\n * - Prefetch detects 'fr' locale from browser\n * - Redirects prefetch to /fr/about\n *\n * With `detectLocaleOnPrefetchNoPrefix:false` (default)\n * - Prefetch uses default locale\n * - Redirects prefetch to /en/about (assuming 'en' is default)\n *\n * When to use true:\n * - Your app uses non-localized internal links (e.g. <a href=\"/about\">)\n * - You want consistent locale detection behavior between regular and prefetch requests\n *\n * When to use false (default):\n * - Your app uses locale-prefixed links (e.g. <a href=\"/fr/about\">)\n * - You want to optimize prefetching performance\n * - You want to avoid potential redirect loops\n *\n * Default: false\n */\n detectLocaleOnPrefetchNoPrefix: boolean;\n};\n\n/**\n * Configuration for intlayer editor\n */\nexport type EditorConfig = {\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: string;\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: 'http://localhost:8000'\n */\n editorURL: string;\n\n /**\n * URL of the CMS server. Used to restrict the origin of the editor for security reasons.\n *\n * Default: 'https://intlayer.org'\n */\n cmsURL: string;\n\n /**\n * URL of the backend\n *\n * Default: 'https://back.intlayer.org'\n *\n * The URL of the backend server.\n */\n backendURL: string;\n\n /**\n * Indicates if the application interact with the visual editor\n *\n * Default: true;\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 */\n enabled: boolean;\n\n /** Port of the editor server\n *\n * Default: 8000\n */\n port: number;\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://intlayer.org/dashboard/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?: string;\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://intlayer.org/dashboard/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?: string;\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: 'local_first' | 'distant_first';\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 hotReload: boolean;\n};\n\nexport type AiConfig = {\n /**\n * Provider\n *\n * The provider to use for the AI features of Intlayer.\n *\n * Available providers:\n * - 'openai'\n * - 'anthropic'\n * - 'mistral'\n * - 'deepseek'\n * - 'gemini'\n *\n * Default: 'openai'\n */\n provider?: string;\n\n /**\n * API model\n *\n * The model to use for the AI features of Intlayer.\n *\n * Example: 'gpt-4o-2024-11-20'\n *\n */\n model?: string;\n\n /**\n * temperature\n *\n * The temperature to use for the AI features of Intlayer.\n * The temperature controls the randomness of the AI's responses.\n * A higher temperature will make the AI more creative and less predictable.\n *\n * Example: 0.1\n */\n temperature?: number;\n\n /**\n * API key\n *\n * Use your own OpenAI API key to use the AI features of Intlayer.\n * If you don't have an OpenAI API key, you can get one for free at https://openai.com/api/.\n *\n */\n apiKey?: string;\n\n /**\n * Application context\n *\n * The context of the application to use for the AI features of Intlayer.\n *\n * Example: 'This is a website for a company that sells products online.'\n */\n applicationContext?: string;\n};\n\nexport type BuildConfig = {\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 * - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.\n */\n optimize: boolean;\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 * - \"async\": The dictionaries are imported dynamically in an asynchronous component.\n * In that case, Intlayer will replace all calls to `useIntlayer` with `await useDictionaryAsync`.\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 desabled 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 * - In most cases, \"dynamic\" will be used for React applications, \"async\" for Vue.js applications.\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 */\n importMode: 'static' | 'dynamic' | 'async';\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,mjx,cjx}', '!**\\/node_modules/**']\n *\n * Example: `['src/**\\/*.{ts,tsx}', '../ui-library/**\\/*.{ts,tsx}', '!**\\/node_modules/**']`\n *\n * Note:\n * - This option will be ignored if `optimize` is disabled.\n * - Use glob pattern.\n */\n traversePattern: string[];\n};\n\n/**\n * Custom configuration that can be provided to override default settings\n */\nexport type CustomIntlayerConfig = {\n /**\n * Custom internationalization configuration\n */\n internationalization?: Partial<InternationalizationConfig>;\n\n /**\n * Custom middleware configuration\n */\n middleware?: Partial<MiddlewareConfig>;\n\n /**\n * Custom content configuration\n */\n content?: Partial<ContentConfig>;\n\n /**\n * Custom editor configuration\n */\n editor?: Partial<EditorConfig>;\n\n /**\n * Custom middleware configuration\n */\n log?: Partial<LogConfig>;\n\n /**\n * Custom AI configuration\n */\n ai?: Partial<AiConfig>;\n\n /**\n * Custom build configuration\n */\n build?: Partial<BuildConfig>;\n};\n\n/**\n * Combined configuration for internationalization, middleware, and content\n */\nexport type IntlayerConfig = {\n /**\n * Internationalization configuration\n */\n internationalization: InternationalizationConfig;\n\n /**\n * Middleware configuration\n */\n middleware: MiddlewareConfig;\n\n /**\n * Content configuration\n */\n content: ContentConfig;\n\n /**\n * Intlayer editor configuration\n */\n editor: EditorConfig;\n\n /**\n * Logger configuration\n */\n log: LogConfig;\n\n /**\n * AI configuration\n */\n ai?: Partial<AiConfig>;\n\n /**\n * Build configuration\n */\n build: BuildConfig;\n};\n\n/**\n * Base configuration for content handling\n */\nexport type BaseContentConfig = {\n /**\n * File extensions of content to look for\n *\n * Default: ['.content.ts', '.content.js', '.content.cjs', '.content.mjs', '.content.json', '.content.tsx', '.content.jsx']\n *\n * List of file extensions to scan for content.\n */\n fileExtensions: string[];\n\n /**\n * Absolute path of the project's base directory\n *\n * Default: process.cwd()\n *\n * The root directory of the project, typically used for resolving other paths.\n */\n baseDir: string;\n\n /**\n * Directories to be excluded from content processing\n *\n * Default: ['node_modules', '.intlayer']\n *\n * A list of directories to exclude from content processing.\n */\n excludedPath: string[];\n\n /**\n * Indicates if Intlayer should watch for changes in the content declaration files in the app to rebuild the related dictionaries.\n *\n * Default: process.env.NODE_ENV === 'development'\n */\n watch: boolean;\n};\n\nexport type DictionaryOutput = 'intlayer' | 'i18next' | 'react-intl';\n\n/**\n * Configuration derived based on the base content configuration\n */\nexport type BaseDerivedConfig = {\n /**\n * Directory where the content is stored, relative to the base directory\n *\n * Default: ['.']\n *\n * Derived content directory based on the base configuration.\n */\n contentDir: string[];\n\n /**\n * Directory where the results are stored, relative to the base directory\n *\n * Default: .intlayer/dictionary\n *\n * Derived results directory based on the base configuration.\n */\n dictionariesDir: string;\n\n /**\n * Directory for module augmentation, relative to the base directory\n *\n * Default: .intlayer/types\n *\n * Defines the derived path for module augmentation.\n */\n moduleAugmentationDir: string;\n\n /**\n * Type of dictionary to use as an output\n *\n * Default: ['intlayer']\n *\n * The type of dictionary to use as an output. It can be either 'intlayer' or 'i18next'.\n *\n * Note:\n * - 'i18next' is not yet ensure a 1:1 mapping with the i18next library.\n * - Removing 'intlayer' will break the compatibility with react-intlayer or next-intlayer\n *\n */\n dictionaryOutput: DictionaryOutput[];\n};\n\n/**\n * Configuration derived based on the result directory\n */\nexport type ResultDirDerivedConfig = {\n /**\n * Directory where unmerged dictionaries are stored, relative to the result directory\n *\n * Default: .intlayer/unmerged_dictionary\n *\n * Specifies the derived path for unmerged dictionaries relative to the result directory.\n */\n unmergedDictionariesDir: string;\n\n /**\n * Directory where final dictionaries are stored, relative to the result directory\n *\n * Default: .intlayer/dictionary\n *\n * Specifies the derived path for dictionaries relative to the result directory.\n */\n dictionariesDir: string;\n\n /**\n * Directory where dynamic dictionaries are stored, relative to the result directory\n *\n * Default: .intlayer/dynamic_dictionary\n *\n * Specifies the derived path for dynamic dictionaries relative to the result directory.\n */\n dynamicDictionariesDir: string;\n\n /**\n * Directory where dictionaries are stored, relative to the result directory\n *\n * Default: i18next_resources\n *\n * Specifies the derived path for dictionaries relative to the result directory.\n *\n * Note:\n * - Ensure the i18n dictionaries output includes i18next to build the dictionaries for i18next\n */\n i18nextResourcesDir: string;\n\n /**\n * Directory where dictionaries are stored, relative to the result directory\n *\n * Default: intl_messages\n *\n * Specifies the derived path for dictionaries relative to the result directory.\n *\n * Note:\n * - Ensure the dictionaries output includes 'react-intl' to build the dictionaries for react-intl\n */\n reactIntlMessagesDir: string;\n\n /**\n * Directory where dictionary types are stored, relative to the result directory\n *\n * Default: .intlayer/types\n *\n * Specifies the derived path for dictionary types relative to the result directory.\n */\n typesDir: string;\n\n /**\n * Directory where the main files are stored, relative to the result directory\n *\n * Default: .intlayer/main\n *\n * Specifies the derived path for the main files relative to the result directory.\n */\n mainDir: string;\n\n /**\n * Directory where the configuration files are stored, relative to the result directory\n *\n * Default: .intlayer/config\n *\n * Specifies the derived path for the configuration files relative to the result directory.\n */\n configDir: string;\n};\n\n/**\n * Configuration for content patterns\n */\nexport type PatternsContentConfig = {\n /**\n * Patterns of files to watch for changes\n *\n * Default: ['/**\\/*.content.ts', '/**\\/*.content.js', '/**\\/*.content.json', '/**\\/*.content.cjs', '/**\\/*.content.mjs', '/**\\/*.content.tsx', '/**\\/*.content.jsx']\n *\n * Defines file patterns for content to watch for changes.\n */\n watchedFilesPattern: string[];\n\n /**\n * Patterns of files to watch for changes including the relative path\n *\n * Default: ['src/**\\/*.content.ts', 'src/**\\/*.content.js', 'src/**\\/*.content.json', 'src/**\\/*.content.cjs', 'src/**\\/*.content.mjs', 'src/**\\/*.content.tsx', 'src/**\\/*.content.jsx']\n *\n * Specifies the file patterns for content to watch, including relative paths.\n */\n watchedFilesPatternWithPath: string[];\n\n /**\n * Pattern for output files including the relative path\n *\n * Default: '{{dictionariesDir}}/**\\/*.json'\n *\n * Defines the pattern for output files, including the relative path.\n */\n outputFilesPatternWithPath: string;\n};\n\n// @TODO: Implement exclusion of non configurable fields, to not allow them to be set in the config\n/**\n * General configuration derived from the config file\n */\nexport type ContentConfig = BaseContentConfig &\n BaseDerivedConfig &\n ResultDirDerivedConfig &\n PatternsContentConfig;\n\nexport type LogConfig = {\n /**\n * Indicates if the logger is enabled\n *\n * Default: true\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: 'default' | 'verbose' | 'disabled';\n\n /**\n * Prefix of the logger\n *\n * Default: '[intlayer]'\n *\n * The prefix of the logger.\n */\n prefix: string;\n};\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../../src/types/config.ts"],"sourcesContent":["import type { Locales } from './locales';\n\nexport type StrictMode = 'strict' | 'inclusive' | 'loose';\n\n/**\n * Configuration for internationalization settings\n */\nexport type InternationalizationConfig = {\n /**\n * Locales available in the application\n *\n * Default: [Locales.ENGLISH]\n *\n * You can define a list of available locales to support in the application.\n */\n 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: 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: StrictMode;\n\n /**\n * Default locale of the application for fallback\n *\n * Default: Locales.ENGLISH\n *\n * Used to specify a fallback locale in case no other locale is set.\n */\n defaultLocale: Locales;\n};\n\nexport type ServerSetCookieRule = 'always' | 'never';\n\n/**\n * Configuration for middleware behaviors\n */\nexport type MiddlewareConfig = {\n /**\n * Header name to get the locale from the request\n *\n * Default: 'x-intlayer-locale'\n *\n * The HTTP header key used to determine the current locale.\n */\n headerName: string;\n\n /**\n * Cookie name to store the locale information\n *\n * Default: 'INTLAYER_LOCALE'\n *\n * The cookie key where the locale information is stored.\n */\n cookieName: string;\n\n /**\n * Prefix default prefix the default locale to the path as other locales.\n *\n * Example with prefixDefault = true and defaultLocale = 'en':\n * path = /en/dashboard or /fr/dashboard\n *\n * Example with prefixDefault = false and defaultLocale = 'en':\n * path = /dashboard or /fr/dashboard\n *\n *\n * Default: false\n */\n prefixDefault: boolean;\n\n /**\n * Base path for application URLs\n *\n * Default: ''\n *\n * Defines the base path where the application is accessible from.\n */\n basePath: string;\n\n /**\n * Strategy for setting the locale cookie on the server\n *\n * Default: 'always'\n *\n * This setting controls when the server sets the locale cookie. It can either set the cookie on every request or never set it.\n */\n serverSetCookie: ServerSetCookieRule;\n\n /**\n * Indicates if no prefix should be used in the URL for locale\n *\n * Default: false\n *\n * If true, no locale-based prefix is used in the URL.\n */\n noPrefix: boolean;\n\n /**\n * Controls whether locale detection occurs during Next.js prefetch requests\n * - true: Detect and apply locale during prefetch\n * - false: Use default locale during prefetch (recommended)\n *\n * This setting affects how Next.js handles locale prefetching:\n *\n * Example scenario:\n * - User's browser language is 'fr'\n * - Current page is /fr/about\n * - Link prefetches /about\n *\n * With `detectLocaleOnPrefetchNoPrefix:true`\n * - Prefetch detects 'fr' locale from browser\n * - Redirects prefetch to /fr/about\n *\n * With `detectLocaleOnPrefetchNoPrefix:false` (default)\n * - Prefetch uses default locale\n * - Redirects prefetch to /en/about (assuming 'en' is default)\n *\n * When to use true:\n * - Your app uses non-localized internal links (e.g. <a href=\"/about\">)\n * - You want consistent locale detection behavior between regular and prefetch requests\n *\n * When to use false (default):\n * - Your app uses locale-prefixed links (e.g. <a href=\"/fr/about\">)\n * - You want to optimize prefetching performance\n * - You want to avoid potential redirect loops\n *\n * Default: false\n */\n detectLocaleOnPrefetchNoPrefix: boolean;\n};\n\n/**\n * Configuration for intlayer editor\n */\nexport type EditorConfig = {\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: string;\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: 'http://localhost:8000'\n */\n editorURL: string;\n\n /**\n * URL of the CMS server. Used to restrict the origin of the editor for security reasons.\n *\n * Default: 'https://intlayer.org'\n */\n cmsURL: string;\n\n /**\n * URL of the backend\n *\n * Default: 'https://back.intlayer.org'\n *\n * The URL of the backend server.\n */\n backendURL: string;\n\n /**\n * Indicates if the application interact with the visual editor\n *\n * Default: true;\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 */\n enabled: boolean;\n\n /** Port of the editor server\n *\n * Default: 8000\n */\n port: number;\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://intlayer.org/dashboard/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?: string;\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://intlayer.org/dashboard/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?: string;\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: 'local_first' | 'distant_first';\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 * Default: true\n */\n liveSync: boolean;\n\n /**\n * Port of the live sync server\n *\n * Default: 4000\n */\n liveSyncPort: number;\n\n /**\n * URL of the live sync server in case of remote live sync server\n *\n * Default: `http://localhost:${liveSyncPort}`\n */\n liveSyncURL: string;\n};\n\nexport type AiConfig = {\n /**\n * Provider\n *\n * The provider to use for the AI features of Intlayer.\n *\n * Available providers:\n * - 'openai'\n * - 'anthropic'\n * - 'mistral'\n * - 'deepseek'\n * - 'gemini'\n *\n * Default: 'openai'\n */\n provider?: string;\n\n /**\n * API model\n *\n * The model to use for the AI features of Intlayer.\n *\n * Example: 'gpt-4o-2024-11-20'\n *\n */\n model?: string;\n\n /**\n * temperature\n *\n * The temperature to use for the AI features of Intlayer.\n * The temperature controls the randomness of the AI's responses.\n * A higher temperature will make the AI more creative and less predictable.\n *\n * Example: 0.1\n */\n temperature?: number;\n\n /**\n * API key\n *\n * Use your own OpenAI API key to use the AI features of Intlayer.\n * If you don't have an OpenAI API key, you can get one for free at https://openai.com/api/.\n *\n */\n apiKey?: string;\n\n /**\n * Application context\n *\n * The context of the application to use for the AI features of Intlayer.\n *\n * Example: 'This is a website for a company that sells products online.'\n */\n applicationContext?: string;\n};\n\nexport type BuildConfig = {\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 * - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.\n */\n optimize: boolean;\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 desabled 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 importMode: 'static' | 'dynamic' | 'live';\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,mjx,cjx}', '!**\\/node_modules/**']\n *\n * Example: `['src/**\\/*.{ts,tsx}', '../ui-library/**\\/*.{ts,tsx}', '!**\\/node_modules/**']`\n *\n * Note:\n * - This option will be ignored if `optimize` is disabled.\n * - Use glob pattern.\n */\n traversePattern: string[];\n};\n\n/**\n * Custom configuration that can be provided to override default settings\n */\nexport type CustomIntlayerConfig = {\n /**\n * Custom internationalization configuration\n */\n internationalization?: Partial<InternationalizationConfig>;\n\n /**\n * Custom middleware configuration\n */\n middleware?: Partial<MiddlewareConfig>;\n\n /**\n * Custom content configuration\n */\n content?: Partial<ContentConfig>;\n\n /**\n * Custom editor configuration\n */\n editor?: Partial<EditorConfig>;\n\n /**\n * Custom middleware configuration\n */\n log?: Partial<LogConfig>;\n\n /**\n * Custom AI configuration\n */\n ai?: Partial<AiConfig>;\n\n /**\n * Custom build configuration\n */\n build?: Partial<BuildConfig>;\n};\n\n/**\n * Combined configuration for internationalization, middleware, and content\n */\nexport type IntlayerConfig = {\n /**\n * Internationalization configuration\n */\n internationalization: InternationalizationConfig;\n\n /**\n * Middleware configuration\n */\n middleware: MiddlewareConfig;\n\n /**\n * Content configuration\n */\n content: ContentConfig;\n\n /**\n * Intlayer editor configuration\n */\n editor: EditorConfig;\n\n /**\n * Logger configuration\n */\n log: LogConfig;\n\n /**\n * AI configuration\n */\n ai?: Partial<AiConfig>;\n\n /**\n * Build configuration\n */\n build: BuildConfig;\n};\n\n/**\n * Base configuration for content handling\n */\nexport type BaseContentConfig = {\n /**\n * File extensions of content to look for\n *\n * Default: ['.content.ts', '.content.js', '.content.cjs', '.content.mjs', '.content.json', '.content.tsx', '.content.jsx']\n *\n * List of file extensions to scan for content.\n */\n fileExtensions: string[];\n\n /**\n * Absolute path of the project's base directory\n *\n * Default: process.cwd()\n *\n * The root directory of the project, typically used for resolving other paths.\n */\n baseDir: string;\n\n /**\n * Directories to be excluded from content processing\n *\n * Default: ['node_modules', '.intlayer']\n *\n * A list of directories to exclude from content processing.\n */\n excludedPath: string[];\n\n /**\n * Indicates if Intlayer should watch for changes in the content declaration files in the app to rebuild the related dictionaries.\n *\n * Default: process.env.NODE_ENV === 'development'\n */\n watch: boolean;\n\n /**\n * Indicate how the content should be automatically filled using AI.\n *\n * Default: undefined\n *\n */\n autoFill?: boolean | string | { [key in Locales]?: string };\n};\n\nexport type DictionaryOutput = 'intlayer' | 'i18next' | 'react-intl';\n\n/**\n * Configuration derived based on the base content configuration\n */\nexport type BaseDerivedConfig = {\n /**\n * Directory where the content is stored, relative to the base directory\n *\n * Default: ['.']\n *\n * Derived content directory based on the base configuration.\n */\n contentDir: string[];\n\n /**\n * Directory where the results are stored, relative to the base directory\n *\n * Default: .intlayer/dictionary\n *\n * Derived results directory based on the base configuration.\n */\n dictionariesDir: string;\n\n /**\n * Directory for module augmentation, relative to the base directory\n *\n * Default: .intlayer/types\n *\n * Defines the derived path for module augmentation.\n */\n moduleAugmentationDir: string;\n\n /**\n * Type of dictionary to use as an output\n *\n * Default: ['intlayer']\n *\n * The type of dictionary to use as an output. It can be either 'intlayer' or 'i18next'.\n *\n * Note:\n * - 'i18next' is not yet ensure a 1:1 mapping with the i18next library.\n * - Removing 'intlayer' will break the compatibility with react-intlayer or next-intlayer\n *\n */\n dictionaryOutput: DictionaryOutput[];\n};\n\n/**\n * Configuration derived based on the result directory\n */\nexport type ResultDirDerivedConfig = {\n /**\n * Directory where unmerged dictionaries are stored, relative to the result directory\n *\n * Default: .intlayer/unmerged_dictionary\n *\n * Specifies the derived path for unmerged dictionaries relative to the result directory.\n */\n unmergedDictionariesDir: string;\n\n /**\n * Directory where remote dictionaries are stored, relative to the result directory\n *\n * Default: .intlayer/remote_dictionary\n *\n * Specifies the derived path for remote dictionaries relative to the result directory.\n */\n remoteDictionariesDir: string;\n\n /**\n * Directory where final dictionaries are stored, relative to the result directory\n *\n * Default: .intlayer/dictionary\n *\n * Specifies the derived path for dictionaries relative to the result directory.\n */\n dictionariesDir: string;\n\n /**\n * Directory where dynamic dictionaries are stored, relative to the result directory\n *\n * Default: .intlayer/dynamic_dictionary\n *\n * Specifies the derived path for dynamic dictionaries relative to the result directory.\n */\n dynamicDictionariesDir: string;\n\n /**\n * Directory where fetch dictionaries are stored, relative to the result directory\n *\n * Default: .intlayer/fetch_dictionary\n *\n * Specifies the derived path for fetch dictionaries relative to the result directory.\n */\n fetchDictionariesDir: string;\n\n /**\n * Directory where dictionaries are stored, relative to the result directory\n *\n * Default: i18next_resources\n *\n * Specifies the derived path for dictionaries relative to the result directory.\n *\n * Note:\n * - Ensure the i18n dictionaries output includes i18next to build the dictionaries for i18next\n */\n i18nextResourcesDir: string;\n\n /**\n * Directory where dictionaries are stored, relative to the result directory\n *\n * Default: intl_messages\n *\n * Specifies the derived path for dictionaries relative to the result directory.\n *\n * Note:\n * - Ensure the dictionaries output includes 'react-intl' to build the dictionaries for react-intl\n */\n reactIntlMessagesDir: string;\n\n /**\n * Directory where dictionary types are stored, relative to the result directory\n *\n * Default: .intlayer/types\n *\n * Specifies the derived path for dictionary types relative to the result directory.\n */\n typesDir: string;\n\n /**\n * Directory where the main files are stored, relative to the result directory\n *\n * Default: .intlayer/main\n *\n * Specifies the derived path for the main files relative to the result directory.\n */\n mainDir: string;\n\n /**\n * Directory where the configuration files are stored, relative to the result directory\n *\n * Default: .intlayer/config\n *\n * Specifies the derived path for the configuration files relative to the result directory.\n */\n configDir: string;\n};\n\n/**\n * Configuration for content patterns\n */\nexport type PatternsContentConfig = {\n /**\n * Patterns of files to watch for changes\n *\n * Default: ['/**\\/*.content.ts', '/**\\/*.content.js', '/**\\/*.content.json', '/**\\/*.content.cjs', '/**\\/*.content.mjs', '/**\\/*.content.tsx', '/**\\/*.content.jsx']\n *\n * Defines file patterns for content to watch for changes.\n */\n watchedFilesPattern: string[];\n\n /**\n * Patterns of files to watch for changes including the relative path\n *\n * Default: ['src/**\\/*.content.ts', 'src/**\\/*.content.js', 'src/**\\/*.content.json', 'src/**\\/*.content.cjs', 'src/**\\/*.content.mjs', 'src/**\\/*.content.tsx', 'src/**\\/*.content.jsx']\n *\n * Specifies the file patterns for content to watch, including relative paths.\n */\n watchedFilesPatternWithPath: string[];\n\n /**\n * Pattern for output files including the relative path\n *\n * Default: '{{dictionariesDir}}/**\\/*.json'\n *\n * Defines the pattern for output files, including the relative path.\n */\n outputFilesPatternWithPath: string;\n};\n\n// @TODO: Implement exclusion of non configurable fields, to not allow them to be set in the config\n/**\n * General configuration derived from the config file\n */\nexport type ContentConfig = BaseContentConfig &\n BaseDerivedConfig &\n ResultDirDerivedConfig &\n PatternsContentConfig;\n\nexport type LogConfig = {\n /**\n * Indicates if the logger is enabled\n *\n * Default: true\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: 'default' | 'verbose' | 'disabled';\n\n /**\n * Prefix of the logger\n *\n * Default: '[intlayer]'\n *\n * The prefix of the logger.\n */\n prefix: string;\n};\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -0,0 +1,77 @@
1
+ import { join, relative } from "path";
2
+ import { getConfiguration } from "./configFile/getConfiguration.mjs";
3
+ import { normalizePath } from "./utils/normalizePath.mjs";
4
+ const getAlias = ({
5
+ configuration = getConfiguration(),
6
+ format = "esm",
7
+ formatter = (value) => value
8
+ } = {}) => {
9
+ const extension = format === "cjs" ? "cjs" : "mjs";
10
+ const { mainDir, configDir, baseDir } = configuration.content;
11
+ const dictionariesPath = join(mainDir, `dictionaries.${extension}`);
12
+ const relativeDictionariesPath = relative(baseDir, dictionariesPath);
13
+ const normalizedDictionariesPath = formatter(
14
+ normalizePath(relativeDictionariesPath)
15
+ );
16
+ const unmergedDictionariesPath = join(
17
+ mainDir,
18
+ `unmerged_dictionaries.${extension}`
19
+ );
20
+ const relativeUnmergedDictionariesPath = relative(
21
+ baseDir,
22
+ unmergedDictionariesPath
23
+ );
24
+ const normalizedUnmergedDictionariesPath = formatter(
25
+ normalizePath(relativeUnmergedDictionariesPath)
26
+ );
27
+ const remoteDictionariesPath = join(
28
+ mainDir,
29
+ `remote_dictionaries.${extension}`
30
+ );
31
+ const relativeRemoteDictionariesPath = relative(
32
+ baseDir,
33
+ remoteDictionariesPath
34
+ );
35
+ const normalizedRemoteDictionariesPath = formatter(
36
+ normalizePath(relativeRemoteDictionariesPath)
37
+ );
38
+ const dynamicDictionariesPath = join(
39
+ mainDir,
40
+ `dynamic_dictionaries.${extension}`
41
+ );
42
+ const relativeDynamicDictionariesPath = relative(
43
+ baseDir,
44
+ dynamicDictionariesPath
45
+ );
46
+ const normalizedDynamicDictionariesPath = formatter(
47
+ normalizePath(relativeDynamicDictionariesPath)
48
+ );
49
+ const fetchDictionariesPath = join(
50
+ mainDir,
51
+ `fetch_dictionaries.${extension}`
52
+ );
53
+ const relativeFetchDictionariesPath = relative(
54
+ baseDir,
55
+ fetchDictionariesPath
56
+ );
57
+ const normalizedFetchDictionariesPath = formatter(
58
+ normalizePath(relativeFetchDictionariesPath)
59
+ );
60
+ const configurationPath = join(configDir, `configuration.json`);
61
+ const relativeConfigurationPath = relative(baseDir, configurationPath);
62
+ const normalizedConfigurationPath = formatter(
63
+ normalizePath(relativeConfigurationPath)
64
+ );
65
+ return {
66
+ "@intlayer/dictionaries-entry": normalizedDictionariesPath,
67
+ "@intlayer/unmerged-dictionaries-entry": normalizedUnmergedDictionariesPath,
68
+ "@intlayer/remote-dictionaries-entry": normalizedRemoteDictionariesPath,
69
+ "@intlayer/dynamic-dictionaries-entry": normalizedDynamicDictionariesPath,
70
+ "@intlayer/fetch-dictionaries-entry": normalizedFetchDictionariesPath,
71
+ "@intlayer/config/built": normalizedConfigurationPath
72
+ };
73
+ };
74
+ export {
75
+ getAlias
76
+ };
77
+ //# sourceMappingURL=alias.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/alias.ts"],"sourcesContent":["import { join, relative } from 'path';\nimport { getConfiguration } from './configFile/getConfiguration';\nimport { IntlayerConfig } from './types/config';\nimport { normalizePath } from './utils/normalizePath';\n\nexport type GetAliasOptions = {\n configuration?: IntlayerConfig;\n format?: 'esm' | 'cjs';\n formatter?: (value: string) => string;\n};\n\nexport const getAlias = ({\n configuration = getConfiguration(),\n format = 'esm',\n formatter = (value: string) => value,\n}: GetAliasOptions = {}) => {\n const extension = format === 'cjs' ? 'cjs' : 'mjs';\n const { mainDir, configDir, baseDir } = configuration.content;\n\n /**\n * Dictionaries\n */\n const dictionariesPath = join(mainDir, `dictionaries.${extension}`);\n const relativeDictionariesPath = relative(baseDir, dictionariesPath);\n const normalizedDictionariesPath = formatter(\n normalizePath(relativeDictionariesPath)\n );\n\n /**\n * Unmerged dictionaries\n */\n const unmergedDictionariesPath = join(\n mainDir,\n `unmerged_dictionaries.${extension}`\n );\n const relativeUnmergedDictionariesPath = relative(\n baseDir,\n unmergedDictionariesPath\n );\n const normalizedUnmergedDictionariesPath = formatter(\n normalizePath(relativeUnmergedDictionariesPath)\n );\n\n /**\n * Remote dictionaries\n */\n const remoteDictionariesPath = join(\n mainDir,\n `remote_dictionaries.${extension}`\n );\n const relativeRemoteDictionariesPath = relative(\n baseDir,\n remoteDictionariesPath\n );\n const normalizedRemoteDictionariesPath = formatter(\n normalizePath(relativeRemoteDictionariesPath)\n );\n\n /**\n * Dynamic dictionaries\n */\n const dynamicDictionariesPath = join(\n mainDir,\n `dynamic_dictionaries.${extension}`\n );\n const relativeDynamicDictionariesPath = relative(\n baseDir,\n dynamicDictionariesPath\n );\n const normalizedDynamicDictionariesPath = formatter(\n normalizePath(relativeDynamicDictionariesPath)\n );\n\n /**\n * Fetch dictionaries\n */\n const fetchDictionariesPath = join(\n mainDir,\n `fetch_dictionaries.${extension}`\n );\n const relativeFetchDictionariesPath = relative(\n baseDir,\n fetchDictionariesPath\n );\n const normalizedFetchDictionariesPath = formatter(\n normalizePath(relativeFetchDictionariesPath)\n );\n\n /**\n * Configuration\n */\n const configurationPath = join(configDir, `configuration.json`);\n const relativeConfigurationPath = relative(baseDir, configurationPath);\n const normalizedConfigurationPath = formatter(\n normalizePath(relativeConfigurationPath)\n );\n\n return {\n '@intlayer/dictionaries-entry': normalizedDictionariesPath,\n '@intlayer/unmerged-dictionaries-entry': normalizedUnmergedDictionariesPath,\n '@intlayer/remote-dictionaries-entry': normalizedRemoteDictionariesPath,\n '@intlayer/dynamic-dictionaries-entry': normalizedDynamicDictionariesPath,\n '@intlayer/fetch-dictionaries-entry': normalizedFetchDictionariesPath,\n '@intlayer/config/built': normalizedConfigurationPath,\n };\n};\n"],"mappings":"AAAA,SAAS,MAAM,gBAAgB;AAC/B,SAAS,wBAAwB;AAEjC,SAAS,qBAAqB;AAQvB,MAAM,WAAW,CAAC;AAAA,EACvB,gBAAgB,iBAAiB;AAAA,EACjC,SAAS;AAAA,EACT,YAAY,CAAC,UAAkB;AACjC,IAAqB,CAAC,MAAM;AAC1B,QAAM,YAAY,WAAW,QAAQ,QAAQ;AAC7C,QAAM,EAAE,SAAS,WAAW,QAAQ,IAAI,cAAc;AAKtD,QAAM,mBAAmB,KAAK,SAAS,gBAAgB,SAAS,EAAE;AAClE,QAAM,2BAA2B,SAAS,SAAS,gBAAgB;AACnE,QAAM,6BAA6B;AAAA,IACjC,cAAc,wBAAwB;AAAA,EACxC;AAKA,QAAM,2BAA2B;AAAA,IAC/B;AAAA,IACA,yBAAyB,SAAS;AAAA,EACpC;AACA,QAAM,mCAAmC;AAAA,IACvC;AAAA,IACA;AAAA,EACF;AACA,QAAM,qCAAqC;AAAA,IACzC,cAAc,gCAAgC;AAAA,EAChD;AAKA,QAAM,yBAAyB;AAAA,IAC7B;AAAA,IACA,uBAAuB,SAAS;AAAA,EAClC;AACA,QAAM,iCAAiC;AAAA,IACrC;AAAA,IACA;AAAA,EACF;AACA,QAAM,mCAAmC;AAAA,IACvC,cAAc,8BAA8B;AAAA,EAC9C;AAKA,QAAM,0BAA0B;AAAA,IAC9B;AAAA,IACA,wBAAwB,SAAS;AAAA,EACnC;AACA,QAAM,kCAAkC;AAAA,IACtC;AAAA,IACA;AAAA,EACF;AACA,QAAM,oCAAoC;AAAA,IACxC,cAAc,+BAA+B;AAAA,EAC/C;AAKA,QAAM,wBAAwB;AAAA,IAC5B;AAAA,IACA,sBAAsB,SAAS;AAAA,EACjC;AACA,QAAM,gCAAgC;AAAA,IACpC;AAAA,IACA;AAAA,EACF;AACA,QAAM,kCAAkC;AAAA,IACtC,cAAc,6BAA6B;AAAA,EAC7C;AAKA,QAAM,oBAAoB,KAAK,WAAW,oBAAoB;AAC9D,QAAM,4BAA4B,SAAS,SAAS,iBAAiB;AACrE,QAAM,8BAA8B;AAAA,IAClC,cAAc,yBAAyB;AAAA,EACzC;AAEA,SAAO;AAAA,IACL,gCAAgC;AAAA,IAChC,yCAAyC;AAAA,IACzC,uCAAuC;AAAA,IACvC,wCAAwC;AAAA,IACxC,sCAAsC;AAAA,IACtC,0BAA0B;AAAA,EAC5B;AACF;","names":[]}
@@ -1,7 +1,31 @@
1
- import { logger } from "./logger.mjs";
1
+ import {
2
+ ANSIColors,
3
+ clock,
4
+ colon,
5
+ colorizeKey,
6
+ colorizeLocales,
7
+ colorizeNumber,
8
+ colorizePath,
9
+ getAppLogger,
10
+ logger,
11
+ spinnerFrames,
12
+ v,
13
+ x
14
+ } from "./logger.mjs";
2
15
  import { Locales } from "./types/locales.mjs";
3
16
  export {
17
+ ANSIColors,
4
18
  Locales,
5
- logger
19
+ clock,
20
+ colon,
21
+ colorizeKey,
22
+ colorizeLocales,
23
+ colorizeNumber,
24
+ colorizePath,
25
+ getAppLogger,
26
+ logger,
27
+ spinnerFrames,
28
+ v,
29
+ x
6
30
  };
7
31
  //# sourceMappingURL=client.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/client.ts"],"sourcesContent":["export { logger } from './logger';\nexport type {\n BaseContentConfig,\n BaseDerivedConfig,\n CustomIntlayerConfig,\n IntlayerConfig,\n PatternsContentConfig,\n ResultDirDerivedConfig,\n} from './types/config';\nexport { Locales } from './types/locales';\nexport type { LocalesValues } from './types/locales';\n"],"mappings":"AAAA,SAAS,cAAc;AASvB,SAAS,eAAe;","names":[]}
1
+ {"version":3,"sources":["../../src/client.ts"],"sourcesContent":["export {\n ANSIColors,\n clock,\n colon,\n colorizeKey,\n colorizeLocales,\n colorizeNumber,\n colorizePath,\n getAppLogger,\n logger,\n spinnerFrames,\n v,\n x,\n} from './logger';\nexport type {\n BaseContentConfig,\n BaseDerivedConfig,\n CustomIntlayerConfig,\n IntlayerConfig,\n PatternsContentConfig,\n ResultDirDerivedConfig,\n} from './types/config';\nexport { Locales } from './types/locales';\nexport type { LocalesValues } from './types/locales';\n"],"mappings":"AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AASP,SAAS,eAAe;","names":[]}
@@ -11,11 +11,13 @@ import {
11
11
  DICTIONARY_OUTPUT,
12
12
  DYNAMIC_DICTIONARIES_DIR,
13
13
  EXCLUDED_PATHS,
14
+ FETCH_DICTIONARIES_DIR,
14
15
  FILE_EXTENSIONS,
15
16
  I18NEXT_DICTIONARIES_DIR,
16
17
  MAIN_DIR,
17
18
  MODULE_AUGMENTATION_DIR,
18
19
  REACT_INTL_MESSAGES_DIR,
20
+ REMOTE_DICTIONARIES_DIR,
19
21
  TYPES_DIR,
20
22
  UNMERGED_DICTIONARIES_DIR,
21
23
  WATCH
@@ -26,8 +28,9 @@ import {
26
28
  CMS_URL,
27
29
  DICTIONARY_PRIORITY_STRATEGY,
28
30
  EDITOR_URL,
29
- HOT_RELOAD,
30
31
  IS_ENABLED,
32
+ LIVE_SYNC,
33
+ LIVE_SYNC_PORT,
31
34
  PORT
32
35
  } from "../defaultValues/editor.mjs";
33
36
  import {
@@ -215,7 +218,13 @@ const buildContentFields = (customConfiguration, baseDir) => {
215
218
  *
216
219
  * Default: process.env.NODE_ENV === 'development'
217
220
  */
218
- watch: customConfiguration?.watch ?? WATCH
221
+ watch: customConfiguration?.watch ?? WATCH,
222
+ /**
223
+ * Indicate how the content should be automatically filled using AI.
224
+ *
225
+ * Default: undefined
226
+ */
227
+ autoFill: customConfiguration?.autoFill ?? void 0
219
228
  };
220
229
  const baseDirDerivedConfiguration = {
221
230
  /**
@@ -295,6 +304,17 @@ const buildContentFields = (customConfiguration, baseDir) => {
295
304
  notDerivedContentConfig.baseDir,
296
305
  customConfiguration?.unmergedDictionariesDir ?? UNMERGED_DICTIONARIES_DIR
297
306
  ),
307
+ /**
308
+ * Directory where the remote dictionaries will be stored
309
+ *
310
+ * Relative to the result directory
311
+ *
312
+ * Default: '.intlayer/remote_dictionary'
313
+ */
314
+ remoteDictionariesDir: join(
315
+ notDerivedContentConfig.baseDir,
316
+ customConfiguration?.remoteDictionariesDir ?? REMOTE_DICTIONARIES_DIR
317
+ ),
298
318
  /**
299
319
  * Directory where the final dictionaries will be stored
300
320
  *
@@ -325,6 +345,17 @@ const buildContentFields = (customConfiguration, baseDir) => {
325
345
  notDerivedContentConfig.baseDir,
326
346
  customConfiguration?.dynamicDictionariesDir ?? DYNAMIC_DICTIONARIES_DIR
327
347
  ),
348
+ /**
349
+ * Directory where the fetch dictionaries will be stored
350
+ *
351
+ * Relative to the result directory
352
+ *
353
+ * Default: .intlayer/fetch_dictionary
354
+ */
355
+ fetchDictionariesDir: join(
356
+ notDerivedContentConfig.baseDir,
357
+ customConfiguration?.fetchDictionariesDir ?? FETCH_DICTIONARIES_DIR
358
+ ),
328
359
  /**
329
360
  * Directory where the 18n dictionaries will be stored
330
361
  *
@@ -535,7 +566,19 @@ const buildEditorFields = (customConfiguration) => ({
535
566
  *
536
567
  * Default: false
537
568
  */
538
- hotReload: customConfiguration?.hotReload ?? HOT_RELOAD
569
+ liveSync: customConfiguration?.liveSync ?? LIVE_SYNC,
570
+ /**
571
+ * Port of the live sync server
572
+ *
573
+ * Default: 4000
574
+ */
575
+ liveSyncPort: customConfiguration?.liveSyncPort ?? LIVE_SYNC_PORT,
576
+ /**
577
+ * URL of the live sync server in case of remote live sync server
578
+ *
579
+ * Default: `http://localhost:${LIVE_SYNC_PORT}`
580
+ */
581
+ liveSyncURL: customConfiguration?.liveSyncURL ?? `http://localhost:${customConfiguration?.liveSyncPort ?? LIVE_SYNC_PORT}`
539
582
  });
540
583
  const buildLogFields = (customConfiguration) => ({
541
584
  /**
@@ -607,8 +650,9 @@ const buildBuildFields = (customConfiguration) => ({
607
650
  * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionary`.
608
651
  * - "dynamic": The dictionaries are imported dynamically in a synchronous component using the suspense API.
609
652
  * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.
610
- * - "async": The dictionaries are imported dynamically in an asynchronous component.
611
- * In that case, Intlayer will replace all calls to `useIntlayer` with `await useDictionaryAsync`.
653
+ * - "live": The dictionaries are imported dynamically using the live sync API.
654
+ * In that case, Intlayer will replace all calls to `useIntlayer` with `useDictionaryDynamic`.
655
+ * 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.
612
656
  *
613
657
  * Default: "static"
614
658
  *
@@ -621,6 +665,7 @@ const buildBuildFields = (customConfiguration) => ({
621
665
  * - Ensure all keys are declared statically in the `useIntlayer` calls. e.g. `useIntlayer('navbar')`.
622
666
  * - This option will be ignored if `optimize` is disabled.
623
667
  * - 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.
668
+ * - The "live" allows to sync the dictionaries to the live sync server.
624
669
  */
625
670
  importMode: customConfiguration?.importMode ?? IMPORT_MODE,
626
671
  /**