@intlayer/chokidar 5.6.0 → 5.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dist/cjs/fetchDistantDictionaries.cjs +1 -1
  2. package/dist/cjs/fetchDistantDictionaries.cjs.map +1 -1
  3. package/dist/cjs/fetchDistantDictionaryKeys.cjs +1 -1
  4. package/dist/cjs/fetchDistantDictionaryKeys.cjs.map +1 -1
  5. package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs +2 -2
  6. package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs.map +1 -1
  7. package/dist/cjs/index.cjs +14 -2
  8. package/dist/cjs/index.cjs.map +1 -1
  9. package/dist/cjs/loadDictionaries/loadDictionaries.cjs +18 -5
  10. package/dist/cjs/loadDictionaries/loadDictionaries.cjs.map +1 -1
  11. package/dist/cjs/log.cjs +3 -3
  12. package/dist/cjs/log.cjs.map +1 -1
  13. package/dist/cjs/transpiler/declaration_file_to_dictionary/i18next_dictionary/buildI18nextDictionary.cjs +1 -1
  14. package/dist/cjs/transpiler/declaration_file_to_dictionary/i18next_dictionary/buildI18nextDictionary.cjs.map +1 -1
  15. package/dist/cjs/transpiler/dictionary_to_main/generateDictionaryListContent.cjs +2 -2
  16. package/dist/cjs/transpiler/dictionary_to_main/generateDictionaryListContent.cjs.map +1 -1
  17. package/dist/cjs/transpiler/dictionary_to_type/createModuleAugmentation.cjs +4 -3
  18. package/dist/cjs/transpiler/dictionary_to_type/createModuleAugmentation.cjs.map +1 -1
  19. package/dist/cjs/{utils.cjs → utils/getFileHash.cjs} +6 -22
  20. package/dist/cjs/utils/getFileHash.cjs.map +1 -0
  21. package/dist/cjs/utils/kebabCaseToCamelCase.cjs +39 -0
  22. package/dist/cjs/utils/kebabCaseToCamelCase.cjs.map +1 -0
  23. package/dist/cjs/utils/runOnce.cjs +58 -0
  24. package/dist/cjs/utils/runOnce.cjs.map +1 -0
  25. package/dist/cjs/utils/sortAlphabetically.cjs +29 -0
  26. package/dist/cjs/utils/sortAlphabetically.cjs.map +1 -0
  27. package/dist/esm/fetchDistantDictionaries.mjs +2 -2
  28. package/dist/esm/fetchDistantDictionaries.mjs.map +1 -1
  29. package/dist/esm/fetchDistantDictionaryKeys.mjs +1 -1
  30. package/dist/esm/fetchDistantDictionaryKeys.mjs.map +1 -1
  31. package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs +1 -1
  32. package/dist/esm/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.mjs.map +1 -1
  33. package/dist/esm/index.mjs +9 -1
  34. package/dist/esm/index.mjs.map +1 -1
  35. package/dist/esm/loadDictionaries/loadDictionaries.mjs +17 -4
  36. package/dist/esm/loadDictionaries/loadDictionaries.mjs.map +1 -1
  37. package/dist/esm/log.mjs +2 -2
  38. package/dist/esm/log.mjs.map +1 -1
  39. package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/buildI18nextDictionary.mjs +1 -1
  40. package/dist/esm/transpiler/declaration_file_to_dictionary/i18next_dictionary/buildI18nextDictionary.mjs.map +1 -1
  41. package/dist/esm/transpiler/dictionary_to_main/generateDictionaryListContent.mjs +1 -1
  42. package/dist/esm/transpiler/dictionary_to_main/generateDictionaryListContent.mjs.map +1 -1
  43. package/dist/esm/transpiler/dictionary_to_type/createModuleAugmentation.mjs +2 -1
  44. package/dist/esm/transpiler/dictionary_to_type/createModuleAugmentation.mjs.map +1 -1
  45. package/dist/esm/utils/getFileHash.mjs +9 -0
  46. package/dist/esm/utils/getFileHash.mjs.map +1 -0
  47. package/dist/esm/{utils.mjs → utils/kebabCaseToCamelCase.mjs} +2 -10
  48. package/dist/esm/utils/kebabCaseToCamelCase.mjs.map +1 -0
  49. package/dist/esm/utils/runOnce.mjs +34 -0
  50. package/dist/esm/utils/runOnce.mjs.map +1 -0
  51. package/dist/esm/utils/sortAlphabetically.mjs +5 -0
  52. package/dist/esm/utils/sortAlphabetically.mjs.map +1 -0
  53. package/dist/types/index.d.ts +5 -1
  54. package/dist/types/index.d.ts.map +1 -1
  55. package/dist/types/loadDictionaries/loadDictionaries.d.ts.map +1 -1
  56. package/dist/types/log.d.ts.map +1 -1
  57. package/dist/types/transpiler/declaration_file_to_dictionary/i18next_dictionary/buildI18nextDictionary.d.ts.map +1 -1
  58. package/dist/types/transpiler/dictionary_to_type/createModuleAugmentation.d.ts.map +1 -1
  59. package/dist/types/utils/getFileHash.d.ts +2 -0
  60. package/dist/types/utils/getFileHash.d.ts.map +1 -0
  61. package/dist/types/utils/kebabCaseToCamelCase.d.ts +2 -0
  62. package/dist/types/utils/kebabCaseToCamelCase.d.ts.map +1 -0
  63. package/dist/types/utils/runOnce.d.ts +24 -0
  64. package/dist/types/utils/runOnce.d.ts.map +1 -0
  65. package/dist/types/utils/sortAlphabetically.d.ts +2 -0
  66. package/dist/types/utils/sortAlphabetically.d.ts.map +1 -0
  67. package/package.json +13 -13
  68. package/dist/cjs/utils.cjs.map +0 -1
  69. package/dist/esm/utils.mjs.map +0 -1
  70. package/dist/types/utils.d.ts +0 -4
  71. package/dist/types/utils.d.ts.map +0 -1
@@ -40,7 +40,7 @@ const fetchDistantDictionaries = async (options) => {
40
40
  const appLogger = (0, import_config.getAppLogger)(config);
41
41
  try {
42
42
  const { clientId, clientSecret } = config.editor;
43
- const authAPI = (0, import_api.getAuthAPI)(void 0, config);
43
+ const authAPI = (0, import_api.getOAuthAPI)(config);
44
44
  const dictionaryAPI = (0, import_api.getDictionaryAPI)(void 0, config);
45
45
  if (!clientId || !clientSecret) {
46
46
  throw new Error(
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/fetchDistantDictionaries.ts"],"sourcesContent":["import { getAuthAPI, getDictionaryAPI } from '@intlayer/api';\n// @ts-ignore @intlayer/backend is not build yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport { getAppLogger, getConfiguration } from '@intlayer/config';\nimport pLimit from 'p-limit';\nimport { logger } from './log';\n\ntype FetchDistantDictionariesOptions = {\n dictionaryKeys: string[];\n newDictionariesPath?: string;\n logPrefix?: string;\n};\n\n/**\n * Fetch distant dictionaries and update the logger with their statuses.\n */\nexport const fetchDistantDictionaries = async (\n options: FetchDistantDictionariesOptions\n): Promise<DictionaryAPI[]> => {\n const config = getConfiguration();\n const appLogger = getAppLogger(config);\n try {\n const { clientId, clientSecret } = config.editor;\n const authAPI = getAuthAPI(undefined, config);\n const dictionaryAPI = getDictionaryAPI(undefined, config);\n\n if (!clientId || !clientSecret) {\n throw new Error(\n 'Missing OAuth2 client ID or client secret. To get access token go to https://intlayer.org/dashboard/project.'\n );\n }\n\n const oAuth2TokenResult = await authAPI.getOAuth2AccessToken();\n\n const oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;\n\n const distantDictionariesKeys = options.dictionaryKeys;\n\n // Process dictionaries in parallel with a concurrency limit\n const limit = pLimit(5); // Limit the number of concurrent requests\n\n const processDictionary = async (\n dictionaryKey: string\n ): Promise<DictionaryAPI | undefined> => {\n logger.updateStatus([\n {\n dictionaryKey,\n type: 'distant',\n status: { status: 'fetching' },\n },\n ]);\n\n try {\n // Fetch the dictionary\n const getDictionaryResult = await dictionaryAPI.getDictionary(\n dictionaryKey,\n undefined,\n {\n ...(oAuth2AccessToken && {\n headers: {\n Authorization: `Bearer ${oAuth2AccessToken}`,\n },\n }),\n }\n );\n\n const distantDictionary = getDictionaryResult.data;\n\n if (!distantDictionary) {\n throw new Error(`Dictionary ${dictionaryKey} not found on remote`);\n }\n\n logger.updateStatus([\n { dictionaryKey, type: 'distant', status: { status: 'imported' } },\n ]);\n\n return distantDictionary;\n } catch (error) {\n logger.updateStatus([\n {\n dictionaryKey,\n type: 'distant',\n status: {\n status: 'error',\n error: error as Error,\n errorMessage: `${options?.logPrefix ?? ''}Error fetching dictionary ${dictionaryKey}: ${error}`,\n },\n },\n ]);\n return undefined;\n }\n };\n\n const fetchPromises = distantDictionariesKeys.map((dictionaryKey) =>\n limit(async () => await processDictionary(dictionaryKey))\n );\n\n const result = await Promise.all(fetchPromises);\n\n // Output any error messages\n const statuses = logger.getStatuses();\n for (const statusObj of statuses) {\n const currentState = statusObj.state.find((s) => s.type === 'distant');\n if (currentState && currentState.errorMessage) {\n appLogger(currentState.errorMessage, { level: 'error' });\n }\n }\n\n // Remove undefined values\n const filteredResult = result.filter(\n (dict): dict is DictionaryAPI => dict !== undefined\n );\n\n return filteredResult;\n } catch (error) {\n appLogger(error, { level: 'error' });\n return [];\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAA6C;AAG7C,oBAA+C;AAC/C,qBAAmB;AACnB,iBAAuB;AAWhB,MAAM,2BAA2B,OACtC,YAC6B;AAC7B,QAAM,aAAS,gCAAiB;AAChC,QAAM,gBAAY,4BAAa,MAAM;AACrC,MAAI;AACF,UAAM,EAAE,UAAU,aAAa,IAAI,OAAO;AAC1C,UAAM,cAAU,uBAAW,QAAW,MAAM;AAC5C,UAAM,oBAAgB,6BAAiB,QAAW,MAAM;AAExD,QAAI,CAAC,YAAY,CAAC,cAAc;AAC9B,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,UAAM,oBAAoB,MAAM,QAAQ,qBAAqB;AAE7D,UAAM,oBAAoB,kBAAkB,MAAM;AAElD,UAAM,0BAA0B,QAAQ;AAGxC,UAAM,YAAQ,eAAAA,SAAO,CAAC;AAEtB,UAAM,oBAAoB,OACxB,kBACuC;AACvC,wBAAO,aAAa;AAAA,QAClB;AAAA,UACE;AAAA,UACA,MAAM;AAAA,UACN,QAAQ,EAAE,QAAQ,WAAW;AAAA,QAC/B;AAAA,MACF,CAAC;AAED,UAAI;AAEF,cAAM,sBAAsB,MAAM,cAAc;AAAA,UAC9C;AAAA,UACA;AAAA,UACA;AAAA,YACE,GAAI,qBAAqB;AAAA,cACvB,SAAS;AAAA,gBACP,eAAe,UAAU,iBAAiB;AAAA,cAC5C;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAEA,cAAM,oBAAoB,oBAAoB;AAE9C,YAAI,CAAC,mBAAmB;AACtB,gBAAM,IAAI,MAAM,cAAc,aAAa,sBAAsB;AAAA,QACnE;AAEA,0BAAO,aAAa;AAAA,UAClB,EAAE,eAAe,MAAM,WAAW,QAAQ,EAAE,QAAQ,WAAW,EAAE;AAAA,QACnE,CAAC;AAED,eAAO;AAAA,MACT,SAAS,OAAO;AACd,0BAAO,aAAa;AAAA,UAClB;AAAA,YACE;AAAA,YACA,MAAM;AAAA,YACN,QAAQ;AAAA,cACN,QAAQ;AAAA,cACR;AAAA,cACA,cAAc,GAAG,SAAS,aAAa,EAAE,6BAA6B,aAAa,KAAK,KAAK;AAAA,YAC/F;AAAA,UACF;AAAA,QACF,CAAC;AACD,eAAO;AAAA,MACT;AAAA,IACF;AAEA,UAAM,gBAAgB,wBAAwB;AAAA,MAAI,CAAC,kBACjD,MAAM,YAAY,MAAM,kBAAkB,aAAa,CAAC;AAAA,IAC1D;AAEA,UAAM,SAAS,MAAM,QAAQ,IAAI,aAAa;AAG9C,UAAM,WAAW,kBAAO,YAAY;AACpC,eAAW,aAAa,UAAU;AAChC,YAAM,eAAe,UAAU,MAAM,KAAK,CAAC,MAAM,EAAE,SAAS,SAAS;AACrE,UAAI,gBAAgB,aAAa,cAAc;AAC7C,kBAAU,aAAa,cAAc,EAAE,OAAO,QAAQ,CAAC;AAAA,MACzD;AAAA,IACF;AAGA,UAAM,iBAAiB,OAAO;AAAA,MAC5B,CAAC,SAAgC,SAAS;AAAA,IAC5C;AAEA,WAAO;AAAA,EACT,SAAS,OAAO;AACd,cAAU,OAAO,EAAE,OAAO,QAAQ,CAAC;AACnC,WAAO,CAAC;AAAA,EACV;AACF;","names":["pLimit"]}
1
+ {"version":3,"sources":["../../src/fetchDistantDictionaries.ts"],"sourcesContent":["import { getDictionaryAPI, getOAuthAPI } from '@intlayer/api';\n// @ts-ignore @intlayer/backend is not build yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport { getAppLogger, getConfiguration } from '@intlayer/config';\nimport pLimit from 'p-limit';\nimport { logger } from './log';\n\ntype FetchDistantDictionariesOptions = {\n dictionaryKeys: string[];\n newDictionariesPath?: string;\n logPrefix?: string;\n};\n\n/**\n * Fetch distant dictionaries and update the logger with their statuses.\n */\nexport const fetchDistantDictionaries = async (\n options: FetchDistantDictionariesOptions\n): Promise<DictionaryAPI[]> => {\n const config = getConfiguration();\n const appLogger = getAppLogger(config);\n try {\n const { clientId, clientSecret } = config.editor;\n const authAPI = getOAuthAPI(config);\n const dictionaryAPI = getDictionaryAPI(undefined, config);\n\n if (!clientId || !clientSecret) {\n throw new Error(\n 'Missing OAuth2 client ID or client secret. To get access token go to https://intlayer.org/dashboard/project.'\n );\n }\n\n const oAuth2TokenResult = await authAPI.getOAuth2AccessToken();\n\n const oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;\n\n const distantDictionariesKeys = options.dictionaryKeys;\n\n // Process dictionaries in parallel with a concurrency limit\n const limit = pLimit(5); // Limit the number of concurrent requests\n\n const processDictionary = async (\n dictionaryKey: string\n ): Promise<DictionaryAPI | undefined> => {\n logger.updateStatus([\n {\n dictionaryKey,\n type: 'distant',\n status: { status: 'fetching' },\n },\n ]);\n\n try {\n // Fetch the dictionary\n const getDictionaryResult = await dictionaryAPI.getDictionary(\n dictionaryKey,\n undefined,\n {\n ...(oAuth2AccessToken && {\n headers: {\n Authorization: `Bearer ${oAuth2AccessToken}`,\n },\n }),\n }\n );\n\n const distantDictionary = getDictionaryResult.data;\n\n if (!distantDictionary) {\n throw new Error(`Dictionary ${dictionaryKey} not found on remote`);\n }\n\n logger.updateStatus([\n { dictionaryKey, type: 'distant', status: { status: 'imported' } },\n ]);\n\n return distantDictionary;\n } catch (error) {\n logger.updateStatus([\n {\n dictionaryKey,\n type: 'distant',\n status: {\n status: 'error',\n error: error as Error,\n errorMessage: `${options?.logPrefix ?? ''}Error fetching dictionary ${dictionaryKey}: ${error}`,\n },\n },\n ]);\n return undefined;\n }\n };\n\n const fetchPromises = distantDictionariesKeys.map((dictionaryKey) =>\n limit(async () => await processDictionary(dictionaryKey))\n );\n\n const result = await Promise.all(fetchPromises);\n\n // Output any error messages\n const statuses = logger.getStatuses();\n for (const statusObj of statuses) {\n const currentState = statusObj.state.find((s) => s.type === 'distant');\n if (currentState && currentState.errorMessage) {\n appLogger(currentState.errorMessage, { level: 'error' });\n }\n }\n\n // Remove undefined values\n const filteredResult = result.filter(\n (dict): dict is DictionaryAPI => dict !== undefined\n );\n\n return filteredResult;\n } catch (error) {\n appLogger(error, { level: 'error' });\n return [];\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAA8C;AAG9C,oBAA+C;AAC/C,qBAAmB;AACnB,iBAAuB;AAWhB,MAAM,2BAA2B,OACtC,YAC6B;AAC7B,QAAM,aAAS,gCAAiB;AAChC,QAAM,gBAAY,4BAAa,MAAM;AACrC,MAAI;AACF,UAAM,EAAE,UAAU,aAAa,IAAI,OAAO;AAC1C,UAAM,cAAU,wBAAY,MAAM;AAClC,UAAM,oBAAgB,6BAAiB,QAAW,MAAM;AAExD,QAAI,CAAC,YAAY,CAAC,cAAc;AAC9B,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAEA,UAAM,oBAAoB,MAAM,QAAQ,qBAAqB;AAE7D,UAAM,oBAAoB,kBAAkB,MAAM;AAElD,UAAM,0BAA0B,QAAQ;AAGxC,UAAM,YAAQ,eAAAA,SAAO,CAAC;AAEtB,UAAM,oBAAoB,OACxB,kBACuC;AACvC,wBAAO,aAAa;AAAA,QAClB;AAAA,UACE;AAAA,UACA,MAAM;AAAA,UACN,QAAQ,EAAE,QAAQ,WAAW;AAAA,QAC/B;AAAA,MACF,CAAC;AAED,UAAI;AAEF,cAAM,sBAAsB,MAAM,cAAc;AAAA,UAC9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31,7 @@ const fetchDistantDictionaryKeys = async (configuration = (0, import_config.getC
31
31
  );
32
32
  }
33
33
  const intlayerAPI = (0, import_api.getIntlayerAPI)(void 0, configuration);
34
- const oAuth2TokenResult = await intlayerAPI.auth.getOAuth2AccessToken();
34
+ const oAuth2TokenResult = await intlayerAPI.oAuth.getOAuth2AccessToken();
35
35
  const oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;
36
36
  const getDictionariesKeysResult = await intlayerAPI.dictionary.getDictionariesKeys({
37
37
  ...oAuth2AccessToken && {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/fetchDistantDictionaryKeys.ts"],"sourcesContent":["import { getIntlayerAPI } from '@intlayer/api';\nimport { getConfiguration, type IntlayerConfig } from '@intlayer/config';\n\nexport const fetchDistantDictionaryKeys = async (\n configuration: IntlayerConfig = getConfiguration()\n): Promise<string[]> => {\n const { clientId, clientSecret } = configuration.editor;\n\n if (!clientId || !clientSecret) {\n throw new Error(\n 'Missing OAuth2 client ID or client secret. To get access token go to https://intlayer.org/dashboard/project.'\n );\n }\n\n const intlayerAPI = getIntlayerAPI(undefined, configuration);\n\n const oAuth2TokenResult = await intlayerAPI.auth.getOAuth2AccessToken();\n\n const oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;\n\n // Get the list of dictionary keys\n const getDictionariesKeysResult =\n await intlayerAPI.dictionary.getDictionariesKeys({\n ...(oAuth2AccessToken && {\n headers: {\n Authorization: `Bearer ${oAuth2AccessToken}`,\n },\n }),\n });\n\n if (!getDictionariesKeysResult.data) {\n throw new Error('No distant dictionaries found');\n }\n\n const distantDictionariesKeys: string[] = getDictionariesKeysResult.data;\n\n // Apply any filtering if needed\n return distantDictionariesKeys;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAA+B;AAC/B,oBAAsD;AAE/C,MAAM,6BAA6B,OACxC,oBAAgC,gCAAiB,MAC3B;AACtB,QAAM,EAAE,UAAU,aAAa,IAAI,cAAc;AAEjD,MAAI,CAAC,YAAY,CAAC,cAAc;AAC9B,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,kBAAc,2BAAe,QAAW,aAAa;AAE3D,QAAM,oBAAoB,MAAM,YAAY,KAAK,qBAAqB;AAEtE,QAAM,oBAAoB,kBAAkB,MAAM;AAGlD,QAAM,4BACJ,MAAM,YAAY,WAAW,oBAAoB;AAAA,IAC/C,GAAI,qBAAqB;AAAA,MACvB,SAAS;AAAA,QACP,eAAe,UAAU,iBAAiB;AAAA,MAC5C;AAAA,IACF;AAAA,EACF,CAAC;AAEH,MAAI,CAAC,0BAA0B,MAAM;AACnC,UAAM,IAAI,MAAM,+BAA+B;AAAA,EACjD;AAEA,QAAM,0BAAoC,0BAA0B;AAGpE,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/fetchDistantDictionaryKeys.ts"],"sourcesContent":["import { getIntlayerAPI } from '@intlayer/api';\nimport { getConfiguration, type IntlayerConfig } from '@intlayer/config';\n\nexport const fetchDistantDictionaryKeys = async (\n configuration: IntlayerConfig = getConfiguration()\n): Promise<string[]> => {\n const { clientId, clientSecret } = configuration.editor;\n\n if (!clientId || !clientSecret) {\n throw new Error(\n 'Missing OAuth2 client ID or client secret. To get access token go to https://intlayer.org/dashboard/project.'\n );\n }\n\n const intlayerAPI = getIntlayerAPI(undefined, configuration);\n\n const oAuth2TokenResult = await intlayerAPI.oAuth.getOAuth2AccessToken();\n\n const oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;\n\n // Get the list of dictionary keys\n const getDictionariesKeysResult =\n await intlayerAPI.dictionary.getDictionariesKeys({\n ...(oAuth2AccessToken && {\n headers: {\n Authorization: `Bearer ${oAuth2AccessToken}`,\n },\n }),\n });\n\n if (!getDictionariesKeysResult.data) {\n throw new Error('No distant dictionaries found');\n }\n\n const distantDictionariesKeys: string[] = getDictionariesKeysResult.data;\n\n // Apply any filtering if needed\n return distantDictionariesKeys;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAA+B;AAC/B,oBAAsD;AAE/C,MAAM,6BAA6B,OACxC,oBAAgC,gCAAiB,MAC3B;AACtB,QAAM,EAAE,UAAU,aAAa,IAAI,cAAc;AAEjD,MAAI,CAAC,YAAY,CAAC,cAAc;AAC9B,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,kBAAc,2BAAe,QAAW,aAAa;AAE3D,QAAM,oBAAoB,MAAM,YAAY,MAAM,qBAAqB;AAEvE,QAAM,oBAAoB,kBAAkB,MAAM;AAGlD,QAAM,4BACJ,MAAM,YAAY,WAAW,oBAAoB;AAAA,IAC/C,GAAI,qBAAqB;AAAA,MACvB,SAAS;AAAA,QACP,eAAe,UAAU,iBAAiB;AAAA,MAC5C;AAAA,IACF;AAAA,EACF,CAAC;AAEH,MAAI,CAAC,0BAA0B,MAAM;AACnC,UAAM,IAAI,MAAM,+BAA+B;AAAA,EACjD;AAEA,QAAM,0BAAoC,0BAA0B;AAGpE,SAAO;AACT;","names":[]}
@@ -24,7 +24,7 @@ module.exports = __toCommonJS(getContentDeclarationFileTemplate_exports);
24
24
  var import_promises = require("fs/promises");
25
25
  var import_path = require("path");
26
26
  var import_url = require("url");
27
- var import_utils = require('../utils.cjs');
27
+ var import_kebabCaseToCamelCase = require('../utils/kebabCaseToCamelCase.cjs');
28
28
  const import_meta = {};
29
29
  const getContentDeclarationFileTemplate = async (key, format, fileParams = {}) => {
30
30
  const dirname = __dirname ?? (0, import_url.fileURLToPath)(import_meta.url);
@@ -35,7 +35,7 @@ const getContentDeclarationFileTemplate = async (key, format, fileParams = {}) =
35
35
  fileTemplate = "./cjsTemplate.md";
36
36
  }
37
37
  const fileContent = await (0, import_promises.readFile)((0, import_path.join)(dirname, fileTemplate), "utf-8");
38
- const camelCaseKey = (0, import_utils.kebabCaseToCamelCase)(key);
38
+ const camelCaseKey = (0, import_kebabCaseToCamelCase.kebabCaseToCamelCase)(key);
39
39
  const nonCapitalizedCamelCaseKey = camelCaseKey.charAt(0).toLowerCase() + camelCaseKey.slice(1);
40
40
  const fileParmsString = Object.entries(fileParams).filter(([, value]) => value !== void 0).map(([key2, value]) => {
41
41
  if (typeof value === "object") {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.ts"],"sourcesContent":["import { readFile } from 'fs/promises';\nimport { join } from 'path';\nimport { fileURLToPath } from 'url';\nimport { kebabCaseToCamelCase } from '../utils';\n\nexport const getContentDeclarationFileTemplate = async (\n key: string,\n format: 'ts' | 'cjs' | 'esm',\n fileParams: Record<string, any> = {}\n) => {\n const dirname = __dirname ?? fileURLToPath(import.meta.url);\n\n let fileTemplate = './esmTemplate.md';\n\n if (format === 'ts') {\n fileTemplate = './tsTemplate.md';\n } else if (format === 'cjs') {\n fileTemplate = './cjsTemplate.md';\n }\n\n const fileContent = await readFile(join(dirname, fileTemplate), 'utf-8');\n const camelCaseKey = kebabCaseToCamelCase(key);\n const nonCapitalizedCamelCaseKey =\n camelCaseKey.charAt(0).toLowerCase() + camelCaseKey.slice(1);\n\n const fileParmsString = Object.entries(fileParams)\n .filter(([, value]) => value !== undefined)\n .map(([key, value]) => {\n if (typeof value === 'object') {\n return `\\n${key}: ${JSON.stringify(value)},`;\n }\n\n if (typeof value === 'boolean' || typeof value === 'number') {\n return `\\n${key}: ${value},`;\n }\n\n if (typeof value === 'string') {\n return `\\n${key}: '${value}',`;\n }\n\n return `\\n${key}: ${value},`;\n })\n .join('');\n\n return fileContent\n .replace('{{key}}', key)\n .replaceAll('{{name}}', nonCapitalizedCamelCaseKey)\n .replace('{{fileParams}}', fileParmsString);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAyB;AACzB,kBAAqB;AACrB,iBAA8B;AAC9B,mBAAqC;AAHrC;AAKO,MAAM,oCAAoC,OAC/C,KACA,QACA,aAAkC,CAAC,MAChC;AACH,QAAM,UAAU,iBAAa,0BAAc,YAAY,GAAG;AAE1D,MAAI,eAAe;AAEnB,MAAI,WAAW,MAAM;AACnB,mBAAe;AAAA,EACjB,WAAW,WAAW,OAAO;AAC3B,mBAAe;AAAA,EACjB;AAEA,QAAM,cAAc,UAAM,8BAAS,kBAAK,SAAS,YAAY,GAAG,OAAO;AACvE,QAAM,mBAAe,mCAAqB,GAAG;AAC7C,QAAM,6BACJ,aAAa,OAAO,CAAC,EAAE,YAAY,IAAI,aAAa,MAAM,CAAC;AAE7D,QAAM,kBAAkB,OAAO,QAAQ,UAAU,EAC9C,OAAO,CAAC,CAAC,EAAE,KAAK,MAAM,UAAU,MAAS,EACzC,IAAI,CAAC,CAACA,MAAK,KAAK,MAAM;AACrB,QAAI,OAAO,UAAU,UAAU;AAC7B,aAAO;AAAA,EAAKA,IAAG,KAAK,KAAK,UAAU,KAAK,CAAC;AAAA,IAC3C;AAEA,QAAI,OAAO,UAAU,aAAa,OAAO,UAAU,UAAU;AAC3D,aAAO;AAAA,EAAKA,IAAG,KAAK,KAAK;AAAA,IAC3B;AAEA,QAAI,OAAO,UAAU,UAAU;AAC7B,aAAO;AAAA,EAAKA,IAAG,MAAM,KAAK;AAAA,IAC5B;AAEA,WAAO;AAAA,EAAKA,IAAG,KAAK,KAAK;AAAA,EAC3B,CAAC,EACA,KAAK,EAAE;AAEV,SAAO,YACJ,QAAQ,WAAW,GAAG,EACtB,WAAW,YAAY,0BAA0B,EACjD,QAAQ,kBAAkB,eAAe;AAC9C;","names":["key"]}
1
+ {"version":3,"sources":["../../../src/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.ts"],"sourcesContent":["import { readFile } from 'fs/promises';\nimport { join } from 'path';\nimport { fileURLToPath } from 'url';\nimport { kebabCaseToCamelCase } from '../utils/kebabCaseToCamelCase';\n\nexport const getContentDeclarationFileTemplate = async (\n key: string,\n format: 'ts' | 'cjs' | 'esm',\n fileParams: Record<string, any> = {}\n) => {\n const dirname = __dirname ?? fileURLToPath(import.meta.url);\n\n let fileTemplate = './esmTemplate.md';\n\n if (format === 'ts') {\n fileTemplate = './tsTemplate.md';\n } else if (format === 'cjs') {\n fileTemplate = './cjsTemplate.md';\n }\n\n const fileContent = await readFile(join(dirname, fileTemplate), 'utf-8');\n const camelCaseKey = kebabCaseToCamelCase(key);\n const nonCapitalizedCamelCaseKey =\n camelCaseKey.charAt(0).toLowerCase() + camelCaseKey.slice(1);\n\n const fileParmsString = Object.entries(fileParams)\n .filter(([, value]) => value !== undefined)\n .map(([key, value]) => {\n if (typeof value === 'object') {\n return `\\n${key}: ${JSON.stringify(value)},`;\n }\n\n if (typeof value === 'boolean' || typeof value === 'number') {\n return `\\n${key}: ${value},`;\n }\n\n if (typeof value === 'string') {\n return `\\n${key}: '${value}',`;\n }\n\n return `\\n${key}: ${value},`;\n })\n .join('');\n\n return fileContent\n .replace('{{key}}', key)\n .replaceAll('{{name}}', nonCapitalizedCamelCaseKey)\n .replace('{{fileParams}}', fileParmsString);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAyB;AACzB,kBAAqB;AACrB,iBAA8B;AAC9B,kCAAqC;AAHrC;AAKO,MAAM,oCAAoC,OAC/C,KACA,QACA,aAAkC,CAAC,MAChC;AACH,QAAM,UAAU,iBAAa,0BAAc,YAAY,GAAG;AAE1D,MAAI,eAAe;AAEnB,MAAI,WAAW,MAAM;AACnB,mBAAe;AAAA,EACjB,WAAW,WAAW,OAAO;AAC3B,mBAAe;AAAA,EACjB;AAEA,QAAM,cAAc,UAAM,8BAAS,kBAAK,SAAS,YAAY,GAAG,OAAO;AACvE,QAAM,mBAAe,kDAAqB,GAAG;AAC7C,QAAM,6BACJ,aAAa,OAAO,CAAC,EAAE,YAAY,IAAI,aAAa,MAAM,CAAC;AAE7D,QAAM,kBAAkB,OAAO,QAAQ,UAAU,EAC9C,OAAO,CAAC,CAAC,EAAE,KAAK,MAAM,UAAU,MAAS,EACzC,IAAI,CAAC,CAACA,MAAK,KAAK,MAAM;AACrB,QAAI,OAAO,UAAU,UAAU;AAC7B,aAAO;AAAA,EAAKA,IAAG,KAAK,KAAK,UAAU,KAAK,CAAC;AAAA,IAC3C;AAEA,QAAI,OAAO,UAAU,aAAa,OAAO,UAAU,UAAU;AAC3D,aAAO;AAAA,EAAKA,IAAG,KAAK,KAAK;AAAA,IAC3B;AAEA,QAAI,OAAO,UAAU,UAAU;AAC7B,aAAO;AAAA,EAAKA,IAAG,MAAM,KAAK;AAAA,IAC5B;AAEA,WAAO;AAAA,EAAKA,IAAG,KAAK,KAAK;AAAA,EAC3B,CAAC,EACA,KAAK,EAAE;AAEV,SAAO,YACJ,QAAQ,WAAW,GAAG,EACtB,WAAW,YAAY,0BAA0B,EACjD,QAAQ,kBAAkB,eAAe;AAC9C;","names":["key"]}
@@ -29,10 +29,11 @@ __export(index_exports, {
29
29
  generateDictionaryListContent: () => import_dictionary_to_main.generateDictionaryListContent,
30
30
  getBuiltDictionariesPath: () => import_getBuiltDictionariesPath.getBuiltDictionariesPath,
31
31
  getBuiltUnmergedDictionariesPath: () => import_getBuiltUnmergedDictionariesPath.getBuiltUnmergedDictionariesPath,
32
- getFileHash: () => import_utils.getFileHash,
32
+ getFileHash: () => import_getFileHash.getFileHash,
33
33
  getFilteredLocalesContent: () => import_getFilteredLocalesContent.getFilteredLocalesContent,
34
34
  handleAdditionalContentDeclarationFile: () => import_watcher.handleAdditionalContentDeclarationFile,
35
35
  handleContentDeclarationFileChange: () => import_watcher.handleContentDeclarationFileChange,
36
+ kebabCaseToCamelCase: () => import_kebabCaseToCamelCase.kebabCaseToCamelCase,
36
37
  listDictionaries: () => import_listDictionariesPath.listDictionaries,
37
38
  listGitFiles: () => import_listGitFiles.listGitFiles,
38
39
  listGitLines: () => import_listGitFiles.listGitLines,
@@ -44,6 +45,9 @@ __export(index_exports, {
44
45
  prepareIntlayer: () => import_prepareIntlayer.prepareIntlayer,
45
46
  processPerLocaleDictionary: () => import_processPerLocaleDictionary.processPerLocaleDictionary,
46
47
  reduceDictionaryContent: () => import_reduceDictionaryContent.reduceDictionaryContent,
48
+ resolveObjectPromises: () => import_resolveObjectPromises.resolveObjectPromises,
49
+ runOnce: () => import_runOnce.runOnce,
50
+ sortAlphabetically: () => import_sortAlphabetically.sortAlphabetically,
47
51
  watch: () => import_watcher.watch,
48
52
  writeContentDeclaration: () => import_writeContentDeclaration.writeContentDeclaration
49
53
  });
@@ -67,7 +71,11 @@ var import_reduceDictionaryContent = require('./reduceDictionaryContent/reduceDi
67
71
  var import_declaration_file_to_dictionary = require('./transpiler/declaration_file_to_dictionary/index.cjs');
68
72
  var import_dictionary_to_main = require('./transpiler/dictionary_to_main/index.cjs');
69
73
  var import_createModuleAugmentation = require('./transpiler/dictionary_to_type/createModuleAugmentation.cjs');
70
- var import_utils = require('./utils.cjs');
74
+ var import_getFileHash = require('./utils/getFileHash.cjs');
75
+ var import_kebabCaseToCamelCase = require('./utils/kebabCaseToCamelCase.cjs');
76
+ var import_resolveObjectPromises = require('./utils/resolveObjectPromises.cjs');
77
+ var import_runOnce = require('./utils/runOnce.cjs');
78
+ var import_sortAlphabetically = require('./utils/sortAlphabetically.cjs');
71
79
  var import_writeContentDeclaration = require('./writeContentDeclaration/index.cjs');
72
80
  // Annotate the CommonJS export names for ESM import in node:
73
81
  0 && (module.exports = {
@@ -86,6 +94,7 @@ var import_writeContentDeclaration = require('./writeContentDeclaration/index.cj
86
94
  getFilteredLocalesContent,
87
95
  handleAdditionalContentDeclarationFile,
88
96
  handleContentDeclarationFileChange,
97
+ kebabCaseToCamelCase,
89
98
  listDictionaries,
90
99
  listGitFiles,
91
100
  listGitLines,
@@ -97,6 +106,9 @@ var import_writeContentDeclaration = require('./writeContentDeclaration/index.cj
97
106
  prepareIntlayer,
98
107
  processPerLocaleDictionary,
99
108
  reduceDictionaryContent,
109
+ resolveObjectPromises,
110
+ runOnce,
111
+ sortAlphabetically,
100
112
  watch,
101
113
  writeContentDeclaration
102
114
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { checkDictionaryChanges } from './checkDictionaryChanges';\nexport {\n buildAndWatchIntlayer,\n handleAdditionalContentDeclarationFile,\n handleContentDeclarationFileChange,\n watch,\n} from './chokidar/watcher';\nexport { cleanOutputDir } from './cleanOutputDir';\nexport { fetchDistantDictionaries } from './fetchDistantDictionaries';\nexport { fetchDistantDictionaryKeys } from './fetchDistantDictionaryKeys';\nexport { getBuiltDictionariesPath } from './getBuiltDictionariesPath';\nexport { getBuiltUnmergedDictionariesPath } from './getBuiltUnmergedDictionariesPath';\nexport { getFilteredLocalesContent } from './getFilteredLocalesContent';\nexport { listDictionaries } from './listDictionariesPath';\nexport {\n listGitFiles,\n listGitLines,\n type DiffMode,\n type ListGitFilesOptions,\n type ListGitLinesOptions,\n} from './listGitFiles';\nexport {\n loadDictionaries,\n loadDistantDictionaries,\n loadLocalDictionaries,\n} from './loadDictionaries/index';\nexport { mergeDictionaries } from './mergeDictionaries';\nexport { prepareContentDeclaration } from './prepareContentDeclaration';\nexport { prepareIntlayer } from './prepareIntlayer';\nexport { processPerLocaleDictionary } from './processPerLocaleDictionary';\nexport { reduceDictionaryContent } from './reduceDictionaryContent/reduceDictionaryContent';\nexport { buildDictionary } from './transpiler/declaration_file_to_dictionary/index';\nexport {\n createDictionaryEntryPoint,\n generateDictionaryListContent,\n} from './transpiler/dictionary_to_main';\nexport { createModuleAugmentation } from './transpiler/dictionary_to_type/createModuleAugmentation';\nexport { getFileHash } from './utils';\nexport {\n writeContentDeclaration,\n type DictionaryStatus,\n} from './writeContentDeclaration';\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;AAAA;AAAA;AAAA;AAAA,oCAAuC;AACvC,qBAKO;AACP,4BAA+B;AAC/B,sCAAyC;AACzC,wCAA2C;AAC3C,sCAAyC;AACzC,8CAAiD;AACjD,uCAA0C;AAC1C,kCAAiC;AACjC,0BAMO;AACP,8BAIO;AACP,+BAAkC;AAClC,uCAA0C;AAC1C,6BAAgC;AAChC,wCAA2C;AAC3C,qCAAwC;AACxC,4CAAgC;AAChC,gCAGO;AACP,sCAAyC;AACzC,mBAA4B;AAC5B,qCAGO;","names":[]}
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { checkDictionaryChanges } from './checkDictionaryChanges';\nexport {\n buildAndWatchIntlayer,\n handleAdditionalContentDeclarationFile,\n handleContentDeclarationFileChange,\n watch,\n} from './chokidar/watcher';\nexport { cleanOutputDir } from './cleanOutputDir';\nexport { fetchDistantDictionaries } from './fetchDistantDictionaries';\nexport { fetchDistantDictionaryKeys } from './fetchDistantDictionaryKeys';\nexport { getBuiltDictionariesPath } from './getBuiltDictionariesPath';\nexport { getBuiltUnmergedDictionariesPath } from './getBuiltUnmergedDictionariesPath';\nexport { getFilteredLocalesContent } from './getFilteredLocalesContent';\nexport { listDictionaries } from './listDictionariesPath';\nexport {\n listGitFiles,\n listGitLines,\n type DiffMode,\n type ListGitFilesOptions,\n type ListGitLinesOptions,\n} from './listGitFiles';\nexport {\n loadDictionaries,\n loadDistantDictionaries,\n loadLocalDictionaries,\n} from './loadDictionaries/index';\nexport { mergeDictionaries } from './mergeDictionaries';\nexport { prepareContentDeclaration } from './prepareContentDeclaration';\nexport { prepareIntlayer } from './prepareIntlayer';\nexport { processPerLocaleDictionary } from './processPerLocaleDictionary';\nexport { reduceDictionaryContent } from './reduceDictionaryContent/reduceDictionaryContent';\nexport { buildDictionary } from './transpiler/declaration_file_to_dictionary/index';\nexport {\n createDictionaryEntryPoint,\n generateDictionaryListContent,\n} from './transpiler/dictionary_to_main';\nexport { createModuleAugmentation } from './transpiler/dictionary_to_type/createModuleAugmentation';\nexport { getFileHash } from './utils/getFileHash';\nexport { kebabCaseToCamelCase } from './utils/kebabCaseToCamelCase';\nexport { resolveObjectPromises } from './utils/resolveObjectPromises';\nexport { runOnce } from './utils/runOnce';\nexport { sortAlphabetically } from './utils/sortAlphabetically';\nexport {\n writeContentDeclaration,\n type DictionaryStatus,\n} from './writeContentDeclaration';\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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oCAAuC;AACvC,qBAKO;AACP,4BAA+B;AAC/B,sCAAyC;AACzC,wCAA2C;AAC3C,sCAAyC;AACzC,8CAAiD;AACjD,uCAA0C;AAC1C,kCAAiC;AACjC,0BAMO;AACP,8BAIO;AACP,+BAAkC;AAClC,uCAA0C;AAC1C,6BAAgC;AAChC,wCAA2C;AAC3C,qCAAwC;AACxC,4CAAgC;AAChC,gCAGO;AACP,sCAAyC;AACzC,yBAA4B;AAC5B,kCAAqC;AACrC,mCAAsC;AACtC,qBAAwB;AACxB,gCAAmC;AACnC,qCAGO;","names":[]}
@@ -24,7 +24,7 @@ module.exports = __toCommonJS(loadDictionaries_exports);
24
24
  var import_config = require("@intlayer/config");
25
25
  var import_fetchDistantDictionaryKeys = require('../fetchDistantDictionaryKeys.cjs');
26
26
  var import_log = require('../log.cjs');
27
- var import_utils = require('../utils.cjs');
27
+ var import_sortAlphabetically = require('../utils/sortAlphabetically.cjs');
28
28
  var import_loadContentDeclaration = require('./loadContentDeclaration.cjs');
29
29
  var import_loadDistantDictionaries = require('./loadDistantDictionaries.cjs');
30
30
  const loadDictionaries = async (contentDeclarationsPaths, configuration = (0, import_config.getConfiguration)(), projectRequire = import_config.ESMxCJSRequire) => {
@@ -37,10 +37,23 @@ const loadDictionaries = async (contentDeclarationsPaths, configuration = (0, im
37
37
  files,
38
38
  projectRequire
39
39
  );
40
- const localDictionaryKeys = localDictionaries.map((dict) => dict.key).filter(Boolean);
40
+ const filteredLocalDictionaries = localDictionaries.filter((dict) => {
41
+ const hasKey = Boolean(dict.key);
42
+ const hasContent = Boolean(dict.content);
43
+ if (!hasContent) {
44
+ console.error(
45
+ "Content declaration has no exported content",
46
+ dict.filePath
47
+ );
48
+ } else if (!hasKey) {
49
+ console.error("Content declaration has no key", dict.filePath);
50
+ }
51
+ return hasKey && hasContent;
52
+ });
53
+ const localDictionaryKeys = filteredLocalDictionaries.map((dict) => dict.key).filter(Boolean);
41
54
  import_log.logger.init(localDictionaryKeys, []);
42
55
  import_log.logger.updateStatus(
43
- localDictionaries.map((dict) => ({
56
+ filteredLocalDictionaries.map((dict) => ({
44
57
  dictionaryKey: dict.key,
45
58
  type: "local",
46
59
  status: { status: "built" }
@@ -51,7 +64,7 @@ const loadDictionaries = async (contentDeclarationsPaths, configuration = (0, im
51
64
  if (editor.clientId && editor.clientSecret) {
52
65
  try {
53
66
  distantDictionaryKeys = await (0, import_fetchDistantDictionaryKeys.fetchDistantDictionaryKeys)();
54
- const orderedDistantDictionaryKeys = distantDictionaryKeys.sort(import_utils.sortAlphabetically);
67
+ const orderedDistantDictionaryKeys = distantDictionaryKeys.sort(import_sortAlphabetically.sortAlphabetically);
55
68
  import_log.logger.addDictionaryKeys("distant", orderedDistantDictionaryKeys);
56
69
  distantDictionaries = await (0, import_loadDistantDictionaries.loadDistantDictionaries)({
57
70
  dictionaryKeys: orderedDistantDictionaryKeys
@@ -63,7 +76,7 @@ const loadDictionaries = async (contentDeclarationsPaths, configuration = (0, im
63
76
  }
64
77
  }
65
78
  import_log.logger.stop();
66
- return [...localDictionaries, ...distantDictionaries];
79
+ return [...filteredLocalDictionaries, ...distantDictionaries];
67
80
  } catch (error) {
68
81
  import_log.logger.stop();
69
82
  throw error;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"sourcesContent":["// @ts-ignore @intlayer/backend is not build yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport {\n ESMxCJSRequire,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { fetchDistantDictionaryKeys } from '../fetchDistantDictionaryKeys';\nimport { logger } from '../log';\nimport { sortAlphabetically } from '../utils';\nimport { loadContentDeclarations } from './loadContentDeclaration';\nimport { loadDistantDictionaries } from './loadDistantDictionaries';\n\nexport const loadDictionaries = async (\n contentDeclarationsPaths: string[] | string,\n configuration = getConfiguration(),\n projectRequire = ESMxCJSRequire\n): Promise<Dictionary[]> => {\n try {\n const appLogger = getAppLogger(configuration);\n const { editor } = configuration;\n\n appLogger('Dictionaries:', { isVerbose: true });\n\n const files = Array.isArray(contentDeclarationsPaths)\n ? contentDeclarationsPaths\n : [contentDeclarationsPaths];\n\n const localDictionaries: Dictionary[] = await loadContentDeclarations(\n files,\n projectRequire\n );\n const localDictionaryKeys = localDictionaries\n .map((dict) => dict.key)\n .filter(Boolean); // Remove empty or undefined keys\n\n // Initialize the logger with both local and distant dictionaries\n logger.init(localDictionaryKeys, []);\n\n // Update logger statuses for local dictionaries\n logger.updateStatus(\n localDictionaries.map((dict) => ({\n dictionaryKey: dict.key,\n type: 'local',\n status: { status: 'built' },\n }))\n );\n\n let distantDictionaries: DictionaryAPI[] = [];\n let distantDictionaryKeys: string[] = [];\n\n if (editor.clientId && editor.clientSecret) {\n try {\n // Fetch distant dictionary keys\n distantDictionaryKeys = await fetchDistantDictionaryKeys();\n\n const orderedDistantDictionaryKeys =\n distantDictionaryKeys.sort(sortAlphabetically);\n\n // Add distant dictionaries to the logger\n logger.addDictionaryKeys('distant', orderedDistantDictionaryKeys);\n\n // Fetch distant dictionaries\n distantDictionaries = await loadDistantDictionaries({\n dictionaryKeys: orderedDistantDictionaryKeys,\n });\n } catch (_error) {\n appLogger('Error during fetching distant dictionaries', {\n level: 'error',\n });\n }\n }\n\n // Ensure the logger is stopped\n logger.stop();\n\n return [...localDictionaries, ...distantDictionaries];\n } catch (error) {\n // Ensure the logger is stopped\n logger.stop();\n\n throw error; // Re-throw the error after logging\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAIO;AAEP,wCAA2C;AAC3C,iBAAuB;AACvB,mBAAmC;AACnC,oCAAwC;AACxC,qCAAwC;AAEjC,MAAM,mBAAmB,OAC9B,0BACA,oBAAgB,gCAAiB,GACjC,iBAAiB,iCACS;AAC1B,MAAI;AACF,UAAM,gBAAY,4BAAa,aAAa;AAC5C,UAAM,EAAE,OAAO,IAAI;AAEnB,cAAU,iBAAiB,EAAE,WAAW,KAAK,CAAC;AAE9C,UAAM,QAAQ,MAAM,QAAQ,wBAAwB,IAChD,2BACA,CAAC,wBAAwB;AAE7B,UAAM,oBAAkC,UAAM;AAAA,MAC5C;AAAA,MACA;AAAA,IACF;AACA,UAAM,sBAAsB,kBACzB,IAAI,CAAC,SAAS,KAAK,GAAG,EACtB,OAAO,OAAO;AAGjB,sBAAO,KAAK,qBAAqB,CAAC,CAAC;AAGnC,sBAAO;AAAA,MACL,kBAAkB,IAAI,CAAC,UAAU;AAAA,QAC/B,eAAe,KAAK;AAAA,QACpB,MAAM;AAAA,QACN,QAAQ,EAAE,QAAQ,QAAQ;AAAA,MAC5B,EAAE;AAAA,IACJ;AAEA,QAAI,sBAAuC,CAAC;AAC5C,QAAI,wBAAkC,CAAC;AAEvC,QAAI,OAAO,YAAY,OAAO,cAAc;AAC1C,UAAI;AAEF,gCAAwB,UAAM,8DAA2B;AAEzD,cAAM,+BACJ,sBAAsB,KAAK,+BAAkB;AAG/C,0BAAO,kBAAkB,WAAW,4BAA4B;AAGhE,8BAAsB,UAAM,wDAAwB;AAAA,UAClD,gBAAgB;AAAA,QAClB,CAAC;AAAA,MACH,SAAS,QAAQ;AACf,kBAAU,8CAA8C;AAAA,UACtD,OAAO;AAAA,QACT,CAAC;AAAA,MACH;AAAA,IACF;AAGA,sBAAO,KAAK;AAEZ,WAAO,CAAC,GAAG,mBAAmB,GAAG,mBAAmB;AAAA,EACtD,SAAS,OAAO;AAEd,sBAAO,KAAK;AAEZ,UAAM;AAAA,EACR;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"sourcesContent":["// @ts-ignore @intlayer/backend is not build yet\nimport type { DictionaryAPI } from '@intlayer/backend';\nimport {\n ESMxCJSRequire,\n getAppLogger,\n getConfiguration,\n} from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { fetchDistantDictionaryKeys } from '../fetchDistantDictionaryKeys';\nimport { logger } from '../log';\nimport { sortAlphabetically } from '../utils/sortAlphabetically';\nimport { loadContentDeclarations } from './loadContentDeclaration';\nimport { loadDistantDictionaries } from './loadDistantDictionaries';\n\nexport const loadDictionaries = async (\n contentDeclarationsPaths: string[] | string,\n configuration = getConfiguration(),\n projectRequire = ESMxCJSRequire\n): Promise<Dictionary[]> => {\n try {\n const appLogger = getAppLogger(configuration);\n const { editor } = configuration;\n\n appLogger('Dictionaries:', { isVerbose: true });\n\n const files = Array.isArray(contentDeclarationsPaths)\n ? contentDeclarationsPaths\n : [contentDeclarationsPaths];\n\n const localDictionaries: Dictionary[] = await loadContentDeclarations(\n files,\n projectRequire\n );\n\n const filteredLocalDictionaries = localDictionaries.filter((dict) => {\n const hasKey = Boolean(dict.key);\n const hasContent = Boolean(dict.content);\n\n if (!hasContent) {\n console.error(\n 'Content declaration has no exported content',\n dict.filePath\n );\n } else if (!hasKey) {\n console.error('Content declaration has no key', dict.filePath);\n }\n\n return hasKey && hasContent;\n });\n\n const localDictionaryKeys = filteredLocalDictionaries\n .map((dict) => dict.key)\n .filter(Boolean); // Remove empty or undefined keys\n\n // Initialize the logger with both local and distant dictionaries\n logger.init(localDictionaryKeys, []);\n\n // Update logger statuses for local dictionaries\n logger.updateStatus(\n filteredLocalDictionaries.map((dict) => ({\n dictionaryKey: dict.key,\n type: 'local',\n status: { status: 'built' },\n }))\n );\n\n let distantDictionaries: DictionaryAPI[] = [];\n let distantDictionaryKeys: string[] = [];\n\n if (editor.clientId && editor.clientSecret) {\n try {\n // Fetch distant dictionary keys\n distantDictionaryKeys = await fetchDistantDictionaryKeys();\n\n const orderedDistantDictionaryKeys =\n distantDictionaryKeys.sort(sortAlphabetically);\n\n // Add distant dictionaries to the logger\n logger.addDictionaryKeys('distant', orderedDistantDictionaryKeys);\n\n // Fetch distant dictionaries\n distantDictionaries = await loadDistantDictionaries({\n dictionaryKeys: orderedDistantDictionaryKeys,\n });\n } catch (_error) {\n appLogger('Error during fetching distant dictionaries', {\n level: 'error',\n });\n }\n }\n\n // Ensure the logger is stopped\n logger.stop();\n\n return [...filteredLocalDictionaries, ...distantDictionaries];\n } catch (error) {\n // Ensure the logger is stopped\n logger.stop();\n\n throw error; // Re-throw the error after logging\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAIO;AAEP,wCAA2C;AAC3C,iBAAuB;AACvB,gCAAmC;AACnC,oCAAwC;AACxC,qCAAwC;AAEjC,MAAM,mBAAmB,OAC9B,0BACA,oBAAgB,gCAAiB,GACjC,iBAAiB,iCACS;AAC1B,MAAI;AACF,UAAM,gBAAY,4BAAa,aAAa;AAC5C,UAAM,EAAE,OAAO,IAAI;AAEnB,cAAU,iBAAiB,EAAE,WAAW,KAAK,CAAC;AAE9C,UAAM,QAAQ,MAAM,QAAQ,wBAAwB,IAChD,2BACA,CAAC,wBAAwB;AAE7B,UAAM,oBAAkC,UAAM;AAAA,MAC5C;AAAA,MACA;AAAA,IACF;AAEA,UAAM,4BAA4B,kBAAkB,OAAO,CAAC,SAAS;AACnE,YAAM,SAAS,QAAQ,KAAK,GAAG;AAC/B,YAAM,aAAa,QAAQ,KAAK,OAAO;AAEvC,UAAI,CAAC,YAAY;AACf,gBAAQ;AAAA,UACN;AAAA,UACA,KAAK;AAAA,QACP;AAAA,MACF,WAAW,CAAC,QAAQ;AAClB,gBAAQ,MAAM,kCAAkC,KAAK,QAAQ;AAAA,MAC/D;AAEA,aAAO,UAAU;AAAA,IACnB,CAAC;AAED,UAAM,sBAAsB,0BACzB,IAAI,CAAC,SAAS,KAAK,GAAG,EACtB,OAAO,OAAO;AAGjB,sBAAO,KAAK,qBAAqB,CAAC,CAAC;AAGnC,sBAAO;AAAA,MACL,0BAA0B,IAAI,CAAC,UAAU;AAAA,QACvC,eAAe,KAAK;AAAA,QACpB,MAAM;AAAA,QACN,QAAQ,EAAE,QAAQ,QAAQ;AAAA,MAC5B,EAAE;AAAA,IACJ;AAEA,QAAI,sBAAuC,CAAC;AAC5C,QAAI,wBAAkC,CAAC;AAEvC,QAAI,OAAO,YAAY,OAAO,cAAc;AAC1C,UAAI;AAEF,gCAAwB,UAAM,8DAA2B;AAEzD,cAAM,+BACJ,sBAAsB,KAAK,4CAAkB;AAG/C,0BAAO,kBAAkB,WAAW,4BAA4B;AAGhE,8BAAsB,UAAM,wDAAwB;AAAA,UAClD,gBAAgB;AAAA,QAClB,CAAC;AAAA,MACH,SAAS,QAAQ;AACf,kBAAU,8CAA8C;AAAA,UACtD,OAAO;AAAA,QACT,CAAC;AAAA,MACH;AAAA,IACF;AAGA,sBAAO,KAAK;AAEZ,WAAO,CAAC,GAAG,2BAA2B,GAAG,mBAAmB;AAAA,EAC9D,SAAS,OAAO;AAEd,sBAAO,KAAK;AAEZ,UAAM;AAAA,EACR;AACF;","names":[]}
package/dist/cjs/log.cjs CHANGED
@@ -31,9 +31,9 @@ __export(log_exports, {
31
31
  logger: () => logger
32
32
  });
33
33
  module.exports = __toCommonJS(log_exports);
34
- var import_readline = __toESM(require("readline"));
35
34
  var import_config = require("@intlayer/config");
36
- var import_utils = require('./utils.cjs');
35
+ var import_readline = __toESM(require("readline"));
36
+ var import_sortAlphabetically = require('./utils/sortAlphabetically.cjs');
37
37
  const LINE_DETECTOR = "\u200B\u200B\u200B";
38
38
  const SPINNER_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
39
39
  const RESET = "\x1B[0m";
@@ -67,7 +67,7 @@ class Logger {
67
67
  const allKeys = Array.from(
68
68
  new Set(
69
69
  [...localDictionariesKeys, ...distantDictionariesKeys].sort(
70
- import_utils.sortAlphabetically
70
+ import_sortAlphabetically.sortAlphabetically
71
71
  )
72
72
  )
73
73
  );
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/log.ts"],"sourcesContent":["import readline from 'readline';\nimport { type IntlayerConfig, getConfiguration } from '@intlayer/config';\nimport { sortAlphabetically } from './utils';\n\nexport type State = {\n type: 'local' | 'distant';\n status: 'pending' | 'fetching' | 'fetched' | 'error' | 'imported' | 'built';\n icon?: string;\n error?: Error;\n errorMessage?: string;\n spinnerFrameIndex?: number;\n};\n\nexport type DictionariesStatus = {\n dictionaryKey: string;\n state: State[];\n};\n\nconst LINE_DETECTOR = '\\u200B\\u200B\\u200B'; // Three zero-width spaces\nconst SPINNER_FRAMES = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];\n\n// ANSI color codes\nconst RESET = '\\x1b[0m';\nconst GREEN = '\\x1b[32m';\nconst RED = '\\x1b[31m';\nconst BLUE = '\\x1b[34m';\nconst GREY = '\\x1b[90m';\nconst GREY_DARK = '\\x1b[90m';\n\nclass Logger {\n private dictionariesStatuses: DictionariesStatus[] = [];\n private spinnerTimer: NodeJS.Timeout | null = null;\n private maxDictionaryKeyLength: number = 0;\n private previousLineCount: number = 0;\n private lineDifCounter: number = 0;\n private originalStdoutWrite:\n | ((\n chunk: string | Uint8Array, // `chunk` can be either a string or a Uint8Array\n encoding?: BufferEncoding, // `encoding` is optional and should be a BufferEncoding\n callback?: (err?: Error | null) => void // `callback` is optional and a function\n ) => boolean)\n | null = null;\n private extraLines: number = 0;\n private isUpdating: boolean = false;\n private config?: IntlayerConfig;\n\n // Singleton instance\n private static instance: Logger;\n\n private constructor() {}\n\n public static getInstance(): Logger {\n if (!Logger.instance) {\n Logger.instance = new Logger();\n }\n return Logger.instance;\n }\n\n public init(\n localDictionariesKeys: string[],\n distantDictionariesKeys: string[],\n configuration: IntlayerConfig = getConfiguration()\n ) {\n this.config = configuration;\n\n const allKeys = Array.from(\n new Set(\n [...localDictionariesKeys, ...distantDictionariesKeys].sort(\n sortAlphabetically\n )\n )\n );\n\n this.maxDictionaryKeyLength = allKeys.reduce(\n (max, key) => (key.length > max ? key.length : max),\n 0\n );\n\n this.dictionariesStatuses = allKeys.map((dictionaryKey) => {\n const states: State[] = [];\n\n if (localDictionariesKeys.includes(dictionaryKey)) {\n states.push({\n type: 'local',\n status: 'pending',\n spinnerFrameIndex: 0,\n });\n }\n if (distantDictionariesKeys.includes(dictionaryKey)) {\n states.push({\n type: 'distant',\n status: 'pending',\n spinnerFrameIndex: 0,\n });\n }\n\n return {\n dictionaryKey,\n state: states,\n };\n });\n\n // Start spinner timer\n this.startSpinner();\n\n // Update all status lines (this will output the initial statuses)\n this.updateAllStatusLines();\n }\n\n // New method to add dictionary keys after initialization\n public addDictionaryKeys(\n type: 'local' | 'distant',\n dictionaryKeys: string[]\n ) {\n for (const dictionaryKey of dictionaryKeys) {\n // Update maxDictionaryKeyLength if the new key is longer\n if (dictionaryKey.length > this.maxDictionaryKeyLength) {\n this.maxDictionaryKeyLength = dictionaryKey.length;\n }\n\n let statusObj = this.dictionariesStatuses.find(\n (ds) => ds.dictionaryKey === dictionaryKey\n );\n\n if (!statusObj) {\n // If the dictionaryKey doesn't exist yet, create a new DictionariesStatus\n\n statusObj = {\n dictionaryKey,\n state: [],\n };\n this.dictionariesStatuses.push(statusObj);\n\n const newState: State = {\n type,\n status: 'pending',\n spinnerFrameIndex: 0,\n };\n statusObj.state.push(newState);\n } else {\n const existingState = statusObj.state.find((s) => s.type === type);\n if (!existingState) {\n // Add new state for the type\n\n const newState: State = {\n type,\n status: 'pending',\n spinnerFrameIndex: 0,\n };\n statusObj.state.push(newState);\n }\n }\n }\n\n // Call updateAllStatusLines() to refresh the output\n this.updateAllStatusLines();\n }\n\n private startSpinner() {\n if (!this.spinnerTimer) {\n this.spinnerTimer = setInterval(() => {\n this.updateAllStatusLines();\n }, 100); // Update every 100ms\n }\n }\n\n private stopSpinner() {\n if (this.spinnerTimer) {\n clearInterval(this.spinnerTimer);\n this.spinnerTimer = null;\n }\n }\n\n // Method to update the terminal output\n private updateOutput(content: string) {\n if (this.config?.log.mode !== 'verbose') return;\n\n // Monkey-patch process.stdout.write to keep track of extra lines\n if (!this.originalStdoutWrite) {\n this.originalStdoutWrite = process.stdout.write.bind(process.stdout);\n this.extraLines = 0;\n\n const write = (\n chunk: string | Uint8Array, // `chunk` can be either a string or a Uint8Array\n encoding?: BufferEncoding, // `encoding` is optional and should be a BufferEncoding\n callback?: (err?: Error | null) => void // `callback` is optional and a function\n ) => {\n const str = typeof chunk === 'string' ? chunk : chunk.toString();\n const newLines = (str.match(/\\n/g) ?? []).length;\n\n // If the write is not initiated by Logger's updateOutput method\n if (!this.isUpdating) {\n this.extraLines += newLines;\n }\n\n return this.originalStdoutWrite!(chunk, encoding, callback);\n };\n\n process.stdout.write = write as typeof process.stdout.write;\n }\n\n // Set a flag to indicate that updateOutput is running\n this.isUpdating = true;\n\n // Adjust lineDifCounter if LINE_DETECTOR is not the first line\n const contentLines = content.split('\\n');\n const indexOfLineDetector = contentLines.indexOf(LINE_DETECTOR.trim());\n\n if (indexOfLineDetector > 0) {\n // LINE_DETECTOR is not at the first line\n this.lineDifCounter = indexOfLineDetector;\n } else {\n this.lineDifCounter = 0;\n }\n\n // Calculate total lines to move up\n const totalLinesToMoveUp =\n this.previousLineCount + this.lineDifCounter + this.extraLines;\n\n // Move cursor up by totalLinesToMoveUp\n readline.moveCursor(process.stdout, 0, -totalLinesToMoveUp);\n\n // Clear all lines downwards\n readline.clearScreenDown(process.stdout);\n\n // Write the updated content\n contentLines.forEach((line) => {\n process.stdout.write(`${line}\\x1b[K\\n`);\n });\n\n // Update previousLineCount\n this.previousLineCount = contentLines.length;\n\n // Reset extraLines counter and updating flag\n this.extraLines = 0;\n this.isUpdating = false;\n }\n\n public stop() {\n this.stopSpinner();\n }\n\n public updateStatus(\n dictionaries: {\n dictionaryKey: string;\n type: 'local' | 'distant';\n status: Partial<State>;\n }[]\n ) {\n for (const { dictionaryKey, type, status } of dictionaries) {\n const statusObj = this.dictionariesStatuses.find(\n (ds) => ds.dictionaryKey === dictionaryKey\n );\n if (statusObj) {\n const state = statusObj.state.find((s) => s.type === type);\n if (state) {\n // Update existing state\n Object.assign(state, status);\n } else {\n // If the state for this type doesn't exist yet, add it\n if (status.status === undefined) {\n status.status = 'pending'; // Provide default status\n }\n const newState: State = {\n type,\n status: status.status,\n icon: status.icon ?? '',\n error: status.error,\n errorMessage: status.errorMessage,\n spinnerFrameIndex: status.spinnerFrameIndex ?? 0,\n };\n statusObj.state.push(newState);\n }\n } else {\n // If the status object doesn't exist, create it\n const newState: State = {\n type,\n status: status.status ?? 'pending',\n icon: status.icon ?? '',\n error: status.error,\n errorMessage: status.errorMessage,\n spinnerFrameIndex: status.spinnerFrameIndex ?? 0,\n };\n this.dictionariesStatuses.push({\n dictionaryKey,\n state: [newState],\n });\n }\n }\n\n // Update the display after status change\n this.updateAllStatusLines();\n }\n\n private getStatusIcon(status: string): string {\n const statusIcons: Record<string, string> = {\n pending: '⏲',\n fetching: '', // Spinner handled separately\n built: '✔',\n imported: '✔',\n error: '✖',\n };\n return statusIcons[status] ?? '';\n }\n\n private getStatusLine(statusObj: DictionariesStatus): string {\n const keyPadding =\n this.maxDictionaryKeyLength - statusObj.dictionaryKey.length;\n const paddedKey = `${statusObj.dictionaryKey}${' '.repeat(keyPadding)}`;\n\n const states = statusObj.state.map((state) => {\n let colorStart = '';\n let colorEnd = '';\n let icon = this.getStatusIcon(state.status);\n if (state.status === 'fetching') {\n // Use spinner frame\n icon = SPINNER_FRAMES[state.spinnerFrameIndex! % SPINNER_FRAMES.length];\n colorStart = BLUE;\n colorEnd = RESET;\n } else if (state.status === 'error') {\n colorStart = RED;\n colorEnd = RESET;\n } else if (state.status === 'imported' || state.status === 'built') {\n colorStart = GREEN;\n colorEnd = RESET;\n } else {\n colorStart = GREY;\n colorEnd = RESET;\n }\n\n // Format the status block\n const statusBlock = `${GREY_DARK}[${state.type}: ${colorStart}${icon} ${state.status}${GREY_DARK}]${colorEnd}`;\n\n return `${colorStart}${statusBlock}${colorEnd}`;\n });\n\n return `${this.config?.log.prefix}- ${paddedKey} ${states.join(' ')}`;\n }\n\n // Replace logUpdate calls with your custom methods\n private updateAllStatusLines() {\n const terminalHeight = process.stdout.rows;\n const maxVisibleLines = terminalHeight - 1;\n\n const lines = this.dictionariesStatuses.map((statusObj) => {\n statusObj.state.forEach((state) => {\n if (state.status === 'fetching') {\n // Update spinner frame\n state.spinnerFrameIndex =\n (state.spinnerFrameIndex! + 1) % SPINNER_FRAMES.length;\n }\n });\n return this.getStatusLine(statusObj);\n });\n\n let content;\n\n if (lines.length > maxVisibleLines) {\n const visibleLines = lines.slice(0, maxVisibleLines - 5);\n const summary = `${this.config?.log.prefix}... and ${lines.length - visibleLines.length} more`;\n content = LINE_DETECTOR + visibleLines.join('\\n') + '\\n' + summary;\n } else {\n content = lines.join('\\n');\n }\n\n this.updateOutput(content);\n }\n\n public getStatuses() {\n return this.dictionariesStatuses;\n }\n}\n\nexport const logger = Logger.getInstance();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAqB;AACrB,oBAAsD;AACtD,mBAAmC;AAgBnC,MAAM,gBAAgB;AACtB,MAAM,iBAAiB,CAAC,UAAK,UAAK,UAAK,UAAK,UAAK,UAAK,UAAK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Config, getConfiguration } from '@intlayer/config';\nimport readline from 'readline';\nimport { sortAlphabetically } from './utils/sortAlphabetically';\n\nexport type State = {\n type: 'local' | 'distant';\n status: 'pending' | 'fetching' | 'fetched' | 'error' | 'imported' | 'built';\n icon?: string;\n error?: Error;\n errorMessage?: string;\n spinnerFrameIndex?: number;\n};\n\nexport type DictionariesStatus = {\n dictionaryKey: string;\n state: State[];\n};\n\nconst LINE_DETECTOR = '\\u200B\\u200B\\u200B'; // Three zero-width spaces\nconst SPINNER_FRAMES = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];\n\n// ANSI color codes\nconst RESET = '\\x1b[0m';\nconst GREEN = '\\x1b[32m';\nconst RED = '\\x1b[31m';\nconst BLUE = '\\x1b[34m';\nconst GREY = '\\x1b[90m';\nconst GREY_DARK = '\\x1b[90m';\n\nclass Logger {\n private dictionariesStatuses: DictionariesStatus[] = [];\n private spinnerTimer: NodeJS.Timeout | null = null;\n private maxDictionaryKeyLength: number = 0;\n private previousLineCount: number = 0;\n private lineDifCounter: number = 0;\n private originalStdoutWrite:\n | ((\n chunk: string | Uint8Array, // `chunk` can be either a string or a Uint8Array\n encoding?: BufferEncoding, // `encoding` is optional and should be a BufferEncoding\n callback?: (err?: Error | null) => void // `callback` is optional and a function\n ) => boolean)\n | null = null;\n private extraLines: number = 0;\n private isUpdating: boolean = false;\n private config?: IntlayerConfig;\n\n // Singleton instance\n private static instance: Logger;\n\n private constructor() {}\n\n public static getInstance(): Logger {\n if (!Logger.instance) {\n Logger.instance = new Logger();\n }\n return Logger.instance;\n }\n\n public init(\n localDictionariesKeys: string[],\n distantDictionariesKeys: string[],\n configuration: IntlayerConfig = getConfiguration()\n ) {\n this.config = configuration;\n\n const allKeys = Array.from(\n new Set(\n [...localDictionariesKeys, ...distantDictionariesKeys].sort(\n sortAlphabetically\n )\n )\n );\n\n this.maxDictionaryKeyLength = allKeys.reduce(\n (max, key) => (key.length > max ? key.length : max),\n 0\n );\n\n this.dictionariesStatuses = allKeys.map((dictionaryKey) => {\n const states: State[] = [];\n\n if (localDictionariesKeys.includes(dictionaryKey)) {\n states.push({\n type: 'local',\n status: 'pending',\n spinnerFrameIndex: 0,\n });\n }\n if (distantDictionariesKeys.includes(dictionaryKey)) {\n states.push({\n type: 'distant',\n status: 'pending',\n spinnerFrameIndex: 0,\n });\n }\n\n return {\n dictionaryKey,\n state: states,\n };\n });\n\n // Start spinner timer\n this.startSpinner();\n\n // Update all status lines (this will output the initial statuses)\n this.updateAllStatusLines();\n }\n\n // New method to add dictionary keys after initialization\n public addDictionaryKeys(\n type: 'local' | 'distant',\n dictionaryKeys: string[]\n ) {\n for (const dictionaryKey of dictionaryKeys) {\n // Update maxDictionaryKeyLength if the new key is longer\n if (dictionaryKey.length > this.maxDictionaryKeyLength) {\n this.maxDictionaryKeyLength = dictionaryKey.length;\n }\n\n let statusObj = this.dictionariesStatuses.find(\n (ds) => ds.dictionaryKey === dictionaryKey\n );\n\n if (!statusObj) {\n // If the dictionaryKey doesn't exist yet, create a new DictionariesStatus\n\n statusObj = {\n dictionaryKey,\n state: [],\n };\n this.dictionariesStatuses.push(statusObj);\n\n const newState: State = {\n type,\n status: 'pending',\n spinnerFrameIndex: 0,\n };\n statusObj.state.push(newState);\n } else {\n const existingState = statusObj.state.find((s) => s.type === type);\n if (!existingState) {\n // Add new state for the type\n\n const newState: State = {\n type,\n status: 'pending',\n spinnerFrameIndex: 0,\n };\n statusObj.state.push(newState);\n }\n }\n }\n\n // Call updateAllStatusLines() to refresh the output\n this.updateAllStatusLines();\n }\n\n private startSpinner() {\n if (!this.spinnerTimer) {\n this.spinnerTimer = setInterval(() => {\n this.updateAllStatusLines();\n }, 100); // Update every 100ms\n }\n }\n\n private stopSpinner() {\n if (this.spinnerTimer) {\n clearInterval(this.spinnerTimer);\n this.spinnerTimer = null;\n }\n }\n\n // Method to update the terminal output\n private updateOutput(content: string) {\n if (this.config?.log.mode !== 'verbose') return;\n\n // Monkey-patch process.stdout.write to keep track of extra lines\n if (!this.originalStdoutWrite) {\n this.originalStdoutWrite = process.stdout.write.bind(process.stdout);\n this.extraLines = 0;\n\n const write = (\n chunk: string | Uint8Array, // `chunk` can be either a string or a Uint8Array\n encoding?: BufferEncoding, // `encoding` is optional and should be a BufferEncoding\n callback?: (err?: Error | null) => void // `callback` is optional and a function\n ) => {\n const str = typeof chunk === 'string' ? chunk : chunk.toString();\n const newLines = (str.match(/\\n/g) ?? []).length;\n\n // If the write is not initiated by Logger's updateOutput method\n if (!this.isUpdating) {\n this.extraLines += newLines;\n }\n\n return this.originalStdoutWrite!(chunk, encoding, callback);\n };\n\n process.stdout.write = write as typeof process.stdout.write;\n }\n\n // Set a flag to indicate that updateOutput is running\n this.isUpdating = true;\n\n // Adjust lineDifCounter if LINE_DETECTOR is not the first line\n const contentLines = content.split('\\n');\n const indexOfLineDetector = contentLines.indexOf(LINE_DETECTOR.trim());\n\n if (indexOfLineDetector > 0) {\n // LINE_DETECTOR is not at the first line\n this.lineDifCounter = indexOfLineDetector;\n } else {\n this.lineDifCounter = 0;\n }\n\n // Calculate total lines to move up\n const totalLinesToMoveUp =\n this.previousLineCount + this.lineDifCounter + this.extraLines;\n\n // Move cursor up by totalLinesToMoveUp\n readline.moveCursor(process.stdout, 0, -totalLinesToMoveUp);\n\n // Clear all lines downwards\n readline.clearScreenDown(process.stdout);\n\n // Write the updated content\n contentLines.forEach((line) => {\n process.stdout.write(`${line}\\x1b[K\\n`);\n });\n\n // Update previousLineCount\n this.previousLineCount = contentLines.length;\n\n // Reset extraLines counter and updating flag\n this.extraLines = 0;\n this.isUpdating = false;\n }\n\n public stop() {\n this.stopSpinner();\n }\n\n public updateStatus(\n dictionaries: {\n dictionaryKey: string;\n type: 'local' | 'distant';\n status: Partial<State>;\n }[]\n ) {\n for (const { dictionaryKey, type, status } of dictionaries) {\n const statusObj = this.dictionariesStatuses.find(\n (ds) => ds.dictionaryKey === dictionaryKey\n );\n if (statusObj) {\n const state = statusObj.state.find((s) => s.type === type);\n if (state) {\n // Update existing state\n Object.assign(state, status);\n } else {\n // If the state for this type doesn't exist yet, add it\n if (status.status === undefined) {\n status.status = 'pending'; // Provide default status\n }\n const newState: State = {\n type,\n status: status.status,\n icon: status.icon ?? '',\n error: status.error,\n errorMessage: status.errorMessage,\n spinnerFrameIndex: status.spinnerFrameIndex ?? 0,\n };\n statusObj.state.push(newState);\n }\n } else {\n // If the status object doesn't exist, create it\n const newState: State = {\n type,\n status: status.status ?? 'pending',\n icon: status.icon ?? '',\n error: status.error,\n errorMessage: status.errorMessage,\n spinnerFrameIndex: status.spinnerFrameIndex ?? 0,\n };\n this.dictionariesStatuses.push({\n dictionaryKey,\n state: [newState],\n });\n }\n }\n\n // Update the display after status change\n this.updateAllStatusLines();\n }\n\n private getStatusIcon(status: string): string {\n const statusIcons: Record<string, string> = {\n pending: '⏲',\n fetching: '', // Spinner handled separately\n built: '✔',\n imported: '✔',\n error: '✖',\n };\n return statusIcons[status] ?? '';\n }\n\n private getStatusLine(statusObj: DictionariesStatus): string {\n const keyPadding =\n this.maxDictionaryKeyLength - statusObj.dictionaryKey.length;\n const paddedKey = `${statusObj.dictionaryKey}${' '.repeat(keyPadding)}`;\n\n const states = statusObj.state.map((state) => {\n let colorStart = '';\n let colorEnd = '';\n let icon = this.getStatusIcon(state.status);\n if (state.status === 'fetching') {\n // Use spinner frame\n icon = SPINNER_FRAMES[state.spinnerFrameIndex! % SPINNER_FRAMES.length];\n colorStart = BLUE;\n colorEnd = RESET;\n } else if (state.status === 'error') {\n colorStart = RED;\n colorEnd = RESET;\n } else if (state.status === 'imported' || state.status === 'built') {\n colorStart = GREEN;\n colorEnd = RESET;\n } else {\n colorStart = GREY;\n colorEnd = RESET;\n }\n\n // Format the status block\n const statusBlock = `${GREY_DARK}[${state.type}: ${colorStart}${icon} ${state.status}${GREY_DARK}]${colorEnd}`;\n\n return `${colorStart}${statusBlock}${colorEnd}`;\n });\n\n return `${this.config?.log.prefix}- ${paddedKey} ${states.join(' ')}`;\n }\n\n // Replace logUpdate calls with your custom methods\n private updateAllStatusLines() {\n const terminalHeight = process.stdout.rows;\n const maxVisibleLines = terminalHeight - 1;\n\n const lines = this.dictionariesStatuses.map((statusObj) => {\n statusObj.state.forEach((state) => {\n if (state.status === 'fetching') {\n // Update spinner frame\n state.spinnerFrameIndex =\n (state.spinnerFrameIndex! + 1) % SPINNER_FRAMES.length;\n }\n });\n return this.getStatusLine(statusObj);\n });\n\n let content;\n\n if (lines.length > maxVisibleLines) {\n const visibleLines = lines.slice(0, maxVisibleLines - 5);\n const summary = `${this.config?.log.prefix}... and ${lines.length - visibleLines.length} more`;\n content = LINE_DETECTOR + visibleLines.join('\\n') + '\\n' + summary;\n } else {\n content = lines.join('\\n');\n }\n\n this.updateOutput(content);\n }\n\n public getStatuses() {\n return this.dictionariesStatuses;\n }\n}\n\nexport const logger = Logger.getInstance();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAsD;AACtD,sBAAqB;AACrB,gCAAmC;AAgBnC,MAAM,gBAAgB;AACtB,MAAM,iBAAiB,CAAC,UAAK,UAAK,UAAK,UAAK,UAAK,UAAK,UAAK,UAAK,UAAK,QAAG;AAGxE,MAAM,QAAQ;AACd,MAAM,QAAQ;AACd,MAAM,MAAM;AACZ,MAAM,OAAO;AACb,MAAM,OAAO;AACb,MAAM,YAAY;AAElB,MAAM,OAAO;AAAA,EACH,uBAA6C,CAAC;AAAA,EAC9C,eAAsC;AAAA,EACtC,yBAAiC;AAAA,EACjC,oBAA4B;AAAA,EAC5B,iBAAyB;AAAA,EACzB,sBAMG;AAAA,EACH,aAAqB;AAAA,EACrB,aAAsB;AAAA,EACtB;AAAA;AAAA,EAGR,OAAe;AAAA,EAEP,cAAc;AAAA,EAAC;AAAA,EAEvB,OAAc,cAAsB;AAClC,QAAI,CAAC,OAAO,UAAU;AACpB,aAAO,WAAW,IAAI,OAA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,UAAM,iBAAiB,QAAQ,OAAO;AACtC,UAAM,kBAAkB,iBAAiB;AAEzC,UAAM,QAAQ,KAAK,qBAAqB,IAAI,CAAC,cAAc;AACzD,gBAAU,MAAM,QAAQ,CAAC,UAAU;AACjC,YAAI,MAAM,WAAW,YAAY;AAE/B,gBAAM,qBACH,MAAM,oBAAqB,KAAK,eAAe;AAAA,QACpD;AAAA,MACF,CAAC;AACD,aAAO,KAAK,cAAc,SAAS;AAAA,IACrC,CAAC;AAED,QAAI;AAEJ,QAAI,MAAM,SAAS,iBAAiB;AAClC,YAAM,eAAe,MAAM,MAAM,GAAG,kBAAkB,CAAC;AACvD,YAAM,UAAU,GAAG,KAAK,QAAQ,IAAI,MAAM,WAAW,MAAM,SAAS,aAAa,MAAM;AACvF,gBAAU,gBAAgB,aAAa,KAAK,IAAI,IAAI,OAAO;AAAA,IAC7D,OAAO;AACL,gBAAU,MAAM,KAAK,IAAI;AAAA,IAC3B;AAEA,SAAK,aAAa,OAAO;AAAA,EAC3B;AAAA,EAEO,cAAc;AACnB,WAAO,KAAK;AAAA,EACd;AACF;AAEO,MAAM,SAAS,OAAO,YAAY;","names":["readline"]}
@@ -21,9 +21,9 @@ __export(buildI18nextDictionary_exports, {
21
21
  buildI18nDictionary: () => buildI18nDictionary
22
22
  });
23
23
  module.exports = __toCommonJS(buildI18nextDictionary_exports);
24
+ var import_config = require("@intlayer/config");
24
25
  var import_convertContentDeclarationInto18nDictionaries = require('./convertContentDeclarationInto18nDictionaries.cjs');
25
26
  var import_writeDictionary = require('./writeDictionary.cjs');
26
- var import_config = require("@intlayer/config");
27
27
  const buildI18nDictionary = async (contentDeclarations, configuration = (0, import_config.getConfiguration)()) => {
28
28
  const dictionariesDeclaration = contentDeclarations.reduce((acc, dictionary) => {
29
29
  const { key, content } = dictionary;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18next_dictionary/buildI18nextDictionary.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/core';\nimport { createI18nextDictionaries } from './convertContentDeclarationInto18nDictionaries';\nimport {\n writeDictionary,\n type DictionariesDeclaration,\n} from './writeDictionary';\nimport { getConfiguration } from '@intlayer/config';\n\n/**\n * This function transpile content declaration to i18n dictionaries\n */\nexport const buildI18nDictionary = async (\n contentDeclarations: Dictionary[],\n configuration = getConfiguration()\n) => {\n // Create dictionaries for each nested content and format them\n const dictionariesDeclaration: DictionariesDeclaration =\n contentDeclarations.reduce((acc, dictionary) => {\n const { key, content } = dictionary;\n const i18Content = createI18nextDictionaries(content, configuration);\n\n return {\n ...acc,\n [key]: i18Content,\n };\n }, {});\n\n // Write the dictionaries to the file system\n const dictionariesPaths: string[] = await writeDictionary(\n dictionariesDeclaration,\n configuration\n );\n\n return dictionariesPaths;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,0DAA0C;AAC1C,6BAGO;AACP,oBAAiC;AAK1B,MAAM,sBAAsB,OACjC,qBACA,oBAAgB,gCAAiB,MAC9B;AAEH,QAAM,0BACJ,oBAAoB,OAAO,CAAC,KAAK,eAAe;AAC9C,UAAM,EAAE,KAAK,QAAQ,IAAI;AACzB,UAAM,iBAAa,+EAA0B,SAAS,aAAa;AAEnE,WAAO;AAAA,MACL,GAAG;AAAA,MACH,CAAC,GAAG,GAAG;AAAA,IACT;AAAA,EACF,GAAG,CAAC,CAAC;AAGP,QAAM,oBAA8B,UAAM;AAAA,IACxC;AAAA,IACA;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/i18next_dictionary/buildI18nextDictionary.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { createI18nextDictionaries } from './convertContentDeclarationInto18nDictionaries';\nimport {\n writeDictionary,\n type DictionariesDeclaration,\n} from './writeDictionary';\n\n/**\n * This function transpile content declaration to i18n dictionaries\n */\nexport const buildI18nDictionary = async (\n contentDeclarations: Dictionary[],\n configuration = getConfiguration()\n) => {\n // Create dictionaries for each nested content and format them\n const dictionariesDeclaration: DictionariesDeclaration =\n contentDeclarations.reduce((acc, dictionary) => {\n const { key, content } = dictionary;\n const i18Content = createI18nextDictionaries(content, configuration);\n\n return {\n ...acc,\n [key]: i18Content,\n };\n }, {});\n\n // Write the dictionaries to the file system\n const dictionariesPaths: string[] = await writeDictionary(\n dictionariesDeclaration,\n configuration\n );\n\n return dictionariesPaths;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AAEjC,0DAA0C;AAC1C,6BAGO;AAKA,MAAM,sBAAsB,OACjC,qBACA,oBAAgB,gCAAiB,MAC9B;AAEH,QAAM,0BACJ,oBAAoB,OAAO,CAAC,KAAK,eAAe;AAC9C,UAAM,EAAE,KAAK,QAAQ,IAAI;AACzB,UAAM,iBAAa,+EAA0B,SAAS,aAAa;AAEnE,WAAO;AAAA,MACL,GAAG;AAAA,MACH,CAAC,GAAG,GAAG;AAAA,IACT;AAAA,EACF,GAAG,CAAC,CAAC;AAGP,QAAM,oBAA8B,UAAM;AAAA,IACxC;AAAA,IACA;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
@@ -23,7 +23,7 @@ __export(generateDictionaryListContent_exports, {
23
23
  module.exports = __toCommonJS(generateDictionaryListContent_exports);
24
24
  var import_config = require("@intlayer/config");
25
25
  var import_path = require("path");
26
- var import_utils = require('../../utils.cjs');
26
+ var import_getFileHash = require('../../utils/getFileHash.cjs');
27
27
  const generateDictionaryListContent = (dictionaries, format = "esm", configuration = (0, import_config.getConfiguration)()) => {
28
28
  const { mainDir } = configuration.content;
29
29
  let content = "";
@@ -31,7 +31,7 @@ const generateDictionaryListContent = (dictionaries, format = "esm", configurati
31
31
  relativePath: (0, import_config.normalizePath)((0, import_path.relative)(mainDir, dictionaryPath)),
32
32
  id: (0, import_path.basename)(dictionaryPath, (0, import_path.extname)(dictionaryPath)),
33
33
  // Get the base name as the dictionary id
34
- hash: `_${(0, import_utils.getFileHash)(dictionaryPath)}`
34
+ hash: `_${(0, import_getFileHash.getFileHash)(dictionaryPath)}`
35
35
  // Get the hash of the dictionary to avoid conflicts
36
36
  }));
37
37
  dictionariesRef.forEach((dictionary) => {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/transpiler/dictionary_to_main/generateDictionaryListContent.ts"],"sourcesContent":["import { getConfiguration, normalizePath } from '@intlayer/config';\nimport { basename, extname, relative } from 'path';\nimport { getFileHash } from '../../utils';\n\n/**\n * This function generates the content of the dictionary list file\n */\nexport const generateDictionaryListContent = (\n dictionaries: string[],\n format: 'cjs' | 'esm' = 'esm',\n configuration = getConfiguration()\n): string => {\n const { mainDir } = configuration.content;\n\n let content = '';\n\n const dictionariesRef = dictionaries.map((dictionaryPath) => ({\n relativePath: normalizePath(relative(mainDir, dictionaryPath)),\n id: basename(dictionaryPath, extname(dictionaryPath)), // Get the base name as the dictionary id\n hash: `_${getFileHash(dictionaryPath)}`, // Get the hash of the dictionary to avoid conflicts\n }));\n\n // Import all dictionaries\n dictionariesRef.forEach((dictionary) => {\n if (format === 'esm')\n content += `import ${dictionary.hash} from '${dictionary.relativePath}' with { type: 'json' };\\n`;\n if (format === 'cjs')\n content += `const ${dictionary.hash} = require('${dictionary.relativePath}');\\n`;\n });\n\n content += '\\n';\n\n // Format Dictionary Map\n const formattedDictionaryMap: string = dictionariesRef\n .map((dictionary) => ` \"${dictionary.id}\": ${dictionary.hash}`)\n .join(',\\n');\n\n if (format === 'esm')\n content += `export default {\\n${formattedDictionaryMap}\\n};\\n`;\n if (format === 'cjs')\n content += `module.exports = {\\n${formattedDictionaryMap}\\n};\\n`;\n\n return content;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAgD;AAChD,kBAA4C;AAC5C,mBAA4B;AAKrB,MAAM,gCAAgC,CAC3C,cACA,SAAwB,OACxB,oBAAgB,gCAAiB,MACtB;AACX,QAAM,EAAE,QAAQ,IAAI,cAAc;AAElC,MAAI,UAAU;AAEd,QAAM,kBAAkB,aAAa,IAAI,CAAC,oBAAoB;AAAA,IAC5D,kBAAc,iCAAc,sBAAS,SAAS,cAAc,CAAC;AAAA,IAC7D,QAAI,sBAAS,oBAAgB,qBAAQ,cAAc,CAAC;AAAA;AAAA,IACpD,MAAM,QAAI,0BAAY,cAAc,CAAC;AAAA;AAAA,EACvC,EAAE;AAGF,kBAAgB,QAAQ,CAAC,eAAe;AACtC,QAAI,WAAW;AACb,iBAAW,UAAU,WAAW,IAAI,UAAU,WAAW,YAAY;AAAA;AACvE,QAAI,WAAW;AACb,iBAAW,SAAS,WAAW,IAAI,eAAe,WAAW,YAAY;AAAA;AAAA,EAC7E,CAAC;AAED,aAAW;AAGX,QAAM,yBAAiC,gBACpC,IAAI,CAAC,eAAe,MAAM,WAAW,EAAE,MAAM,WAAW,IAAI,EAAE,EAC9D,KAAK,KAAK;AAEb,MAAI,WAAW;AACb,eAAW;AAAA,EAAqB,sBAAsB;AAAA;AAAA;AACxD,MAAI,WAAW;AACb,eAAW;AAAA,EAAuB,sBAAsB;AAAA;AAAA;AAE1D,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../../src/transpiler/dictionary_to_main/generateDictionaryListContent.ts"],"sourcesContent":["import { getConfiguration, normalizePath } from '@intlayer/config';\nimport { basename, extname, relative } from 'path';\nimport { getFileHash } from '../../utils/getFileHash';\n\n/**\n * This function generates the content of the dictionary list file\n */\nexport const generateDictionaryListContent = (\n dictionaries: string[],\n format: 'cjs' | 'esm' = 'esm',\n configuration = getConfiguration()\n): string => {\n const { mainDir } = configuration.content;\n\n let content = '';\n\n const dictionariesRef = dictionaries.map((dictionaryPath) => ({\n relativePath: normalizePath(relative(mainDir, dictionaryPath)),\n id: basename(dictionaryPath, extname(dictionaryPath)), // Get the base name as the dictionary id\n hash: `_${getFileHash(dictionaryPath)}`, // Get the hash of the dictionary to avoid conflicts\n }));\n\n // Import all dictionaries\n dictionariesRef.forEach((dictionary) => {\n if (format === 'esm')\n content += `import ${dictionary.hash} from '${dictionary.relativePath}' with { type: 'json' };\\n`;\n if (format === 'cjs')\n content += `const ${dictionary.hash} = require('${dictionary.relativePath}');\\n`;\n });\n\n content += '\\n';\n\n // Format Dictionary Map\n const formattedDictionaryMap: string = dictionariesRef\n .map((dictionary) => ` \"${dictionary.id}\": ${dictionary.hash}`)\n .join(',\\n');\n\n if (format === 'esm')\n content += `export default {\\n${formattedDictionaryMap}\\n};\\n`;\n if (format === 'cjs')\n content += `module.exports = {\\n${formattedDictionaryMap}\\n};\\n`;\n\n return content;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAgD;AAChD,kBAA4C;AAC5C,yBAA4B;AAKrB,MAAM,gCAAgC,CAC3C,cACA,SAAwB,OACxB,oBAAgB,gCAAiB,MACtB;AACX,QAAM,EAAE,QAAQ,IAAI,cAAc;AAElC,MAAI,UAAU;AAEd,QAAM,kBAAkB,aAAa,IAAI,CAAC,oBAAoB;AAAA,IAC5D,kBAAc,iCAAc,sBAAS,SAAS,cAAc,CAAC;AAAA,IAC7D,QAAI,sBAAS,oBAAgB,qBAAQ,cAAc,CAAC;AAAA;AAAA,IACpD,MAAM,QAAI,gCAAY,cAAc,CAAC;AAAA;AAAA,EACvC,EAAE;AAGF,kBAAgB,QAAQ,CAAC,eAAe;AACtC,QAAI,WAAW;AACb,iBAAW,UAAU,WAAW,IAAI,UAAU,WAAW,YAAY;AAAA;AACvE,QAAI,WAAW;AACb,iBAAW,SAAS,WAAW,IAAI,eAAe,WAAW,YAAY;AAAA;AAAA,EAC7E,CAAC;AAED,aAAW;AAGX,QAAM,yBAAiC,gBACpC,IAAI,CAAC,eAAe,MAAM,WAAW,EAAE,MAAM,WAAW,IAAI,EAAE,EAC9D,KAAK,KAAK;AAEb,MAAI,WAAW;AACb,eAAW;AAAA,EAAqB,sBAAsB;AAAA;AAAA;AACxD,MAAI,WAAW;AACb,eAAW;AAAA,EAAuB,sBAAsB;AAAA;AAAA;AAE1D,SAAO;AACT;","names":[]}
@@ -36,8 +36,9 @@ var import_config = require("@intlayer/config");
36
36
  var import_fast_glob = __toESM(require("fast-glob"));
37
37
  var import_fs = require("fs");
38
38
  var import_path = require("path");
39
- var import_utils = require('../../utils.cjs');
40
- const getTypeName = (key) => `${(0, import_utils.kebabCaseToCamelCase)(key)}Content`;
39
+ var import_getFileHash = require('../../utils/getFileHash.cjs');
40
+ var import_kebabCaseToCamelCase = require('../../utils/kebabCaseToCamelCase.cjs');
41
+ const getTypeName = (key) => `${(0, import_kebabCaseToCamelCase.kebabCaseToCamelCase)(key)}Content`;
41
42
  const formatLocales = (locales) => locales.map((locale) => {
42
43
  for (const key in import_config.Locales) {
43
44
  if (import_config.Locales[key] === locale) {
@@ -54,7 +55,7 @@ const generateTypeIndexContent = (typeFiles, configuration = (0, import_config.g
54
55
  relativePath: `./${(0, import_path.relative)(moduleAugmentationDir, dictionaryPath)}`,
55
56
  id: (0, import_path.basename)(dictionaryPath, (0, import_path.extname)(dictionaryPath)),
56
57
  // Get the base name as the dictionary id (without the extension)
57
- hash: `_${(0, import_utils.getFileHash)(dictionaryPath)}`
58
+ hash: `_${(0, import_getFileHash.getFileHash)(dictionaryPath)}`
58
59
  // Get the hash of the dictionary to avoid conflicts
59
60
  }));
60
61
  dictionariesRef.forEach((dictionary) => {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/transpiler/dictionary_to_type/createModuleAugmentation.ts"],"sourcesContent":["import { Locales, getConfiguration, normalizePath } from '@intlayer/config';\nimport fg from 'fast-glob';\nimport { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { basename, extname, join, relative } from 'path';\nimport { getFileHash, kebabCaseToCamelCase } from '../../utils';\n\nexport const getTypeName = (key: string): string =>\n `${kebabCaseToCamelCase(key)}Content`;\n\nconst formatLocales = (locales: Locales[]): string =>\n locales\n .map((locale) => {\n for (const key in Locales) {\n if (Locales[key as keyof typeof Locales] === locale) {\n return `Locales.${key}`;\n }\n }\n })\n .join(' | ');\n\n/**\n * This function generates the content of the module augmentation file\n */\nconst generateTypeIndexContent = (\n typeFiles: string[],\n configuration = getConfiguration()\n): string => {\n const { content, internationalization } = configuration;\n const { moduleAugmentationDir } = content;\n const { locales, requiredLocales, strictMode } = internationalization;\n\n let fileContent =\n \"/* eslint-disable */\\nimport { Locales } from 'intlayer';\\n\";\n\n const dictionariesRef = typeFiles.map((dictionaryPath) => ({\n relativePath: `./${relative(moduleAugmentationDir, dictionaryPath)}`,\n id: basename(dictionaryPath, extname(dictionaryPath)), // Get the base name as the dictionary id (without the extension)\n hash: `_${getFileHash(dictionaryPath)}`, // Get the hash of the dictionary to avoid conflicts\n }));\n\n // Import all dictionaries\n dictionariesRef.forEach((dictionary) => {\n fileContent += `import ${dictionary.hash} from '${dictionary.relativePath}';\\n`;\n });\n\n fileContent += '\\n';\n\n // Format Dictionary Map\n const formattedDictionaryMap: string = dictionariesRef\n .map((dictionary) => ` \"${dictionary.id}\": typeof ${dictionary.hash};`)\n .join('\\n');\n\n const requiredLocalesValues =\n requiredLocales.length > 0\n ? requiredLocales.filter((locale) =>\n locales.map((locale) => String(locale)).includes(String(locale))\n )\n : locales;\n\n const formattedLocales = formatLocales(locales);\n const formattedRequiredLocales = formatLocales(requiredLocalesValues);\n\n const strictModeRecord =\n strictMode === 'strict'\n ? `interface IConfigLocales<Content> extends Record<DeclaredLocales, Content> {}`\n : strictMode === 'inclusive'\n ? `interface IConfigLocales<Content> extends Record<ExtractedLocales, Content>, Partial<Record<ExcludedLocales, Content>> {}`\n : `interface IConfigLocales<Content> extends Partial<Record<Locales, Content>> {}`;\n\n /**\n * Write the module augmentation to extend the intlayer module with the dictionaries types\n * Will suggest the type resulting of the dictionaries\n *\n * declare module 'intlayer' {\n * interface IntlayerDictionaryTypesConnector = {\n * dictionaries: {\n * id: DictionaryType;\n * }\n * }\n *\n * type ConfigLocales = Locales.ENGLISH | Locales.FRENCH | Locales.SPANISH;\n * type ExtractedLocales = Extract<Locales, ConfigLocales>;\n *\n * interface IConfigLocales<Content> extends Record<ExtractedLocales, Content>, Partial<Record<ExcludedLocales, Content>> {}\n *\n *\n * }\n * See https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation\n */\n fileContent += `declare module 'intlayer' {\\n`;\n fileContent += ` interface IntlayerDictionaryTypesConnector {\\n${formattedDictionaryMap}\\n }\\n\\n`;\n fileContent += ` type DeclaredLocales = ${formattedLocales};\\n`;\n fileContent += ` type RequiredLocales = ${formattedRequiredLocales};\\n`;\n fileContent += ` type ExtractedLocales = Extract<Locales, RequiredLocales>;\\n`;\n fileContent += ` type ExcludedLocales = Exclude<Locales, RequiredLocales>;\\n`;\n fileContent += ` ${strictModeRecord}\\n`;\n fileContent += `}`;\n\n return fileContent;\n};\n\n/**\n * This function generates a index file merging all the types\n */\nexport const createModuleAugmentation = (\n configuration = getConfiguration()\n) => {\n const { moduleAugmentationDir, typesDir } = configuration.content;\n\n // Create main directory if it doesn't exist\n if (!existsSync(moduleAugmentationDir)) {\n mkdirSync(moduleAugmentationDir, { recursive: true });\n }\n\n const dictionariesTypesDefinitions: string[] = fg.sync(\n normalizePath(`${typesDir}/*.ts`),\n {\n ignore: ['**/*.d.ts'],\n }\n );\n // Create the dictionary list file\n\n const tsContent = generateTypeIndexContent(dictionariesTypesDefinitions);\n writeFileSync(join(moduleAugmentationDir, 'intlayer.d.ts'), tsContent);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAyD;AACzD,uBAAe;AACf,gBAAqD;AACrD,kBAAkD;AAClD,mBAAkD;AAE3C,MAAM,cAAc,CAAC,QAC1B,OAAG,mCAAqB,GAAG,CAAC;AAE9B,MAAM,gBAAgB,CAAC,YACrB,QACG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A;AACnE,iBAAe;AAAA;AACf,iBAAe;AAAA;AACf,iBAAe,KAAK,gBAAgB;AAAA;AACpC,iBAAe;AAEf,SAAO;AACT;AAKO,MAAM,2BAA2B,CACtC,oBAAgB,gCAAiB,MAC9B;AACH,QAAM,EAAE,uBAAuB,SAAS,IAAI,cAAc;AAG1D,MAAI,KAAC,sBAAW,qBAAqB,GAAG;AACtC,6BAAU,uBAAuB,EAAE,WAAW,KAAK,CAAC;AAAA,EACtD;AAEA,QAAM,+BAAyC,iBAAAC,QAAG;AAAA,QAChD,6BAAc,GAAG,QAAQ,OAAO;AAAA,IAChC;AAAA,MACE,QAAQ,CAAC,WAAW;AAAA,IACtB;AAAA,EACF;AAGA,QAAM,YAAY,yBAAyB,4BAA4B;AACvE,mCAAc,kBAAK,uBAAuB,eAAe,GAAG,SAAS;AACvE;","names":["locale","fg"]}
1
+ {"version":3,"sources":["../../../../src/transpiler/dictionary_to_type/createModuleAugmentation.ts"],"sourcesContent":["import { Locales, getConfiguration, normalizePath } from '@intlayer/config';\nimport fg from 'fast-glob';\nimport { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { basename, extname, join, relative } from 'path';\nimport { getFileHash } from '../../utils/getFileHash';\nimport { kebabCaseToCamelCase } from '../../utils/kebabCaseToCamelCase';\n\nexport const getTypeName = (key: string): string =>\n `${kebabCaseToCamelCase(key)}Content`;\n\nconst formatLocales = (locales: Locales[]): string =>\n locales\n .map((locale) => {\n for (const key in Locales) {\n if (Locales[key as keyof typeof Locales] === locale) {\n return `Locales.${key}`;\n }\n }\n })\n .join(' | ');\n\n/**\n * This function generates the content of the module augmentation file\n */\nconst generateTypeIndexContent = (\n typeFiles: string[],\n configuration = getConfiguration()\n): string => {\n const { content, internationalization } = configuration;\n const { moduleAugmentationDir } = content;\n const { locales, requiredLocales, strictMode } = internationalization;\n\n let fileContent =\n \"/* eslint-disable */\\nimport { Locales } from 'intlayer';\\n\";\n\n const dictionariesRef = typeFiles.map((dictionaryPath) => ({\n relativePath: `./${relative(moduleAugmentationDir, dictionaryPath)}`,\n id: basename(dictionaryPath, extname(dictionaryPath)), // Get the base name as the dictionary id (without the extension)\n hash: `_${getFileHash(dictionaryPath)}`, // Get the hash of the dictionary to avoid conflicts\n }));\n\n // Import all dictionaries\n dictionariesRef.forEach((dictionary) => {\n fileContent += `import ${dictionary.hash} from '${dictionary.relativePath}';\\n`;\n });\n\n fileContent += '\\n';\n\n // Format Dictionary Map\n const formattedDictionaryMap: string = dictionariesRef\n .map((dictionary) => ` \"${dictionary.id}\": typeof ${dictionary.hash};`)\n .join('\\n');\n\n const requiredLocalesValues =\n requiredLocales.length > 0\n ? requiredLocales.filter((locale) =>\n locales.map((locale) => String(locale)).includes(String(locale))\n )\n : locales;\n\n const formattedLocales = formatLocales(locales);\n const formattedRequiredLocales = formatLocales(requiredLocalesValues);\n\n const strictModeRecord =\n strictMode === 'strict'\n ? `interface IConfigLocales<Content> extends Record<DeclaredLocales, Content> {}`\n : strictMode === 'inclusive'\n ? `interface IConfigLocales<Content> extends Record<ExtractedLocales, Content>, Partial<Record<ExcludedLocales, Content>> {}`\n : `interface IConfigLocales<Content> extends Partial<Record<Locales, Content>> {}`;\n\n /**\n * Write the module augmentation to extend the intlayer module with the dictionaries types\n * Will suggest the type resulting of the dictionaries\n *\n * declare module 'intlayer' {\n * interface IntlayerDictionaryTypesConnector = {\n * dictionaries: {\n * id: DictionaryType;\n * }\n * }\n *\n * type ConfigLocales = Locales.ENGLISH | Locales.FRENCH | Locales.SPANISH;\n * type ExtractedLocales = Extract<Locales, ConfigLocales>;\n *\n * interface IConfigLocales<Content> extends Record<ExtractedLocales, Content>, Partial<Record<ExcludedLocales, Content>> {}\n *\n *\n * }\n * See https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation\n */\n fileContent += `declare module 'intlayer' {\\n`;\n fileContent += ` interface IntlayerDictionaryTypesConnector {\\n${formattedDictionaryMap}\\n }\\n\\n`;\n fileContent += ` type DeclaredLocales = ${formattedLocales};\\n`;\n fileContent += ` type RequiredLocales = ${formattedRequiredLocales};\\n`;\n fileContent += ` type ExtractedLocales = Extract<Locales, RequiredLocales>;\\n`;\n fileContent += ` type ExcludedLocales = Exclude<Locales, RequiredLocales>;\\n`;\n fileContent += ` ${strictModeRecord}\\n`;\n fileContent += `}`;\n\n return fileContent;\n};\n\n/**\n * This function generates a index file merging all the types\n */\nexport const createModuleAugmentation = (\n configuration = getConfiguration()\n) => {\n const { moduleAugmentationDir, typesDir } = configuration.content;\n\n // Create main directory if it doesn't exist\n if (!existsSync(moduleAugmentationDir)) {\n mkdirSync(moduleAugmentationDir, { recursive: true });\n }\n\n const dictionariesTypesDefinitions: string[] = fg.sync(\n normalizePath(`${typesDir}/*.ts`),\n {\n ignore: ['**/*.d.ts'],\n }\n );\n // Create the dictionary list file\n\n const tsContent = generateTypeIndexContent(dictionariesTypesDefinitions);\n writeFileSync(join(moduleAugmentationDir, 'intlayer.d.ts'), tsContent);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAyD;AACzD,uBAAe;AACf,gBAAqD;AACrD,kBAAkD;AAClD,yBAA4B;AAC5B,kCAAqC;AAE9B,MAAM,cAAc,CAAC,QAC1B,OAAG,kDAAqB,GAAG,CAAC;AAE9B,MAAM,gBAAgB,CAAC,YACrB,QACG,IAAI,CAAC,WAAW;AACf,aAAW,OAAO,uBAAS;AACzB,QAAI,sBAAQ,GAA2B,MAAM,QAAQ;AACnD,aAAO,WAAW,GAAG;AAAA,IACvB;AAAA,EACF;AACF,CAAC,EACA,KAAK,KAAK;AAKf,MAAM,2BAA2B,CAC/B,WACA,oBAAgB,gCAAiB,MACtB;AACX,QAAM,EAAE,SAAS,qBAAqB,IAAI;AAC1C,QAAM,EAAE,sBAAsB,IAAI;AAClC,QAAM,EAAE,SAAS,iBAAiB,WAAW,IAAI;AAEjD,MAAI,cACF;AAEF,QAAM,kBAAkB,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AAAA,IAChC;AAAA,MACE,QAAQ,CAAC,WAAW;AAAA,IACtB;AAAA,EACF;AAGA,QAAM,YAAY,yBAAyB,4BAA4B;AACvE,mCAAc,kBAAK,uBAAuB,eAAe,GAAG,SAAS;AACvE;","names":["locale","fg"]}
@@ -26,34 +26,18 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var utils_exports = {};
30
- __export(utils_exports, {
31
- getFileHash: () => getFileHash,
32
- kebabCaseToCamelCase: () => kebabCaseToCamelCase,
33
- sortAlphabetically: () => sortAlphabetically
29
+ var getFileHash_exports = {};
30
+ __export(getFileHash_exports, {
31
+ getFileHash: () => getFileHash
34
32
  });
35
- module.exports = __toCommonJS(utils_exports);
33
+ module.exports = __toCommonJS(getFileHash_exports);
36
34
  var import_crypto_js = __toESM(require("crypto-js"));
37
35
  const getFileHash = (filePath) => {
38
36
  const hash = import_crypto_js.default.SHA3(filePath);
39
37
  return hash.toString(import_crypto_js.default.enc.Base64).replace(/[^A-Z\d]/gi, "").substring(0, 20);
40
38
  };
41
- const kebabCaseToCamelCase = (name) => {
42
- return name.split(/[^a-zA-Z0-9]+/).filter(Boolean).map((word) => {
43
- const lowerWord = word.toLowerCase();
44
- let capitalized = lowerWord.charAt(0).toUpperCase() + lowerWord.slice(1);
45
- capitalized = capitalized.replace(
46
- /(\d)([a-z])/g,
47
- (_, number, char) => number + char.toUpperCase()
48
- );
49
- return capitalized;
50
- }).join("");
51
- };
52
- const sortAlphabetically = (a, b) => a.localeCompare(b);
53
39
  // Annotate the CommonJS export names for ESM import in node:
54
40
  0 && (module.exports = {
55
- getFileHash,
56
- kebabCaseToCamelCase,
57
- sortAlphabetically
41
+ getFileHash
58
42
  });
59
- //# sourceMappingURL=utils.cjs.map
43
+ //# sourceMappingURL=getFileHash.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/getFileHash.ts"],"sourcesContent":["import crypto from 'crypto-js';\n\nexport const getFileHash = (filePath: string) => {\n const hash = crypto.SHA3(filePath);\n\n return hash\n .toString(crypto.enc.Base64)\n .replace(/[^A-Z\\d]/gi, '')\n .substring(0, 20);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAmB;AAEZ,MAAM,cAAc,CAAC,aAAqB;AAC/C,QAAM,OAAO,iBAAAA,QAAO,KAAK,QAAQ;AAEjC,SAAO,KACJ,SAAS,iBAAAA,QAAO,IAAI,MAAM,EAC1B,QAAQ,cAAc,EAAE,EACxB,UAAU,GAAG,EAAE;AACpB;","names":["crypto"]}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var kebabCaseToCamelCase_exports = {};
20
+ __export(kebabCaseToCamelCase_exports, {
21
+ kebabCaseToCamelCase: () => kebabCaseToCamelCase
22
+ });
23
+ module.exports = __toCommonJS(kebabCaseToCamelCase_exports);
24
+ const kebabCaseToCamelCase = (name) => {
25
+ return name.split(/[^a-zA-Z0-9]+/).filter(Boolean).map((word) => {
26
+ const lowerWord = word.toLowerCase();
27
+ let capitalized = lowerWord.charAt(0).toUpperCase() + lowerWord.slice(1);
28
+ capitalized = capitalized.replace(
29
+ /(\d)([a-z])/g,
30
+ (_, number, char) => number + char.toUpperCase()
31
+ );
32
+ return capitalized;
33
+ }).join("");
34
+ };
35
+ // Annotate the CommonJS export names for ESM import in node:
36
+ 0 && (module.exports = {
37
+ kebabCaseToCamelCase
38
+ });
39
+ //# sourceMappingURL=kebabCaseToCamelCase.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/kebabCaseToCamelCase.ts"],"sourcesContent":["export const kebabCaseToCamelCase = (name: string): string => {\n return name\n .split(/[^a-zA-Z0-9]+/) // Split on any non-alphanumeric character\n .filter(Boolean) // Remove any empty strings\n .map((word) => {\n // Convert the entire word to lowercase first\n const lowerWord = word.toLowerCase();\n\n // Capitalize the first character\n let capitalized = lowerWord.charAt(0).toUpperCase() + lowerWord.slice(1);\n\n // Capitalize any letter that follows a number\n capitalized = capitalized.replace(\n /(\\d)([a-z])/g,\n (_, number, char) => number + char.toUpperCase()\n );\n\n return capitalized;\n })\n .join(''); // Concatenate all parts into a single string\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,uBAAuB,CAAC,SAAyB;AAC5D,SAAO,KACJ,MAAM,eAAe,EACrB,OAAO,OAAO,EACd,IAAI,CAAC,SAAS;AAEb,UAAM,YAAY,KAAK,YAAY;AAGnC,QAAI,cAAc,UAAU,OAAO,CAAC,EAAE,YAAY,IAAI,UAAU,MAAM,CAAC;AAGvE,kBAAc,YAAY;AAAA,MACxB;AAAA,MACA,CAAC,GAAG,QAAQ,SAAS,SAAS,KAAK,YAAY;AAAA,IACjD;AAEA,WAAO;AAAA,EACT,CAAC,EACA,KAAK,EAAE;AACZ;","names":[]}