@intlayer/chokidar 5.2.9 → 5.3.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.
@@ -109,7 +109,7 @@ const watch = (options) => {
109
109
  const buildAndWatchIntlayer = async (options) => {
110
110
  const configuration = options?.configuration ?? (0, import_config.getConfiguration)();
111
111
  await (0, import_prepareIntlayer.prepareIntlayer)(configuration);
112
- if (configuration.content.watch) {
112
+ if (configuration.content.watch | options.persistent) {
113
113
  watch({ ...options, configuration });
114
114
  }
115
115
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/chokidar/watcher.ts"],"sourcesContent":["import { relative } from 'path';\nimport {\n type IntlayerConfig,\n appLogger,\n getConfiguration,\n} from '@intlayer/config';\n/** @ts-ignore remove error Module '\"chokidar\"' has no exported member 'ChokidarOptions' */\nimport { type ChokidarOptions, watch as chokidarWatch } from 'chokidar';\nimport { getDictionariesPath } from '../getDictionariesPath';\nimport { loadLocalDictionaries } from '../loadDictionaries/loadLocalDictionaries';\nimport { buildDictionary } from '../transpiler/declaration_file_to_dictionary/index';\nimport { createDictionaryEntryPoint } from '../transpiler/dictionary_to_main/createDictionaryEntryPoint';\nimport {\n createTypes,\n createModuleAugmentation,\n} from '../transpiler/dictionary_to_type/index';\nimport { prepareIntlayer } from '../prepareIntlayer';\n\nexport const handleAdditionalContentDeclarationFile = async (\n filePath: string,\n configuration?: IntlayerConfig\n) => {\n const { content } =\n configuration ??\n getConfiguration({\n verbose: true,\n });\n\n // Process the file with the functionToRun\n appLogger(\n `Additional file detected: ${relative(content.baseDir, filePath)}`,\n {\n isVerbose: true,\n }\n );\n\n const localeDictionaries = await loadLocalDictionaries(filePath);\n\n const dictionariesPaths = await buildDictionary(localeDictionaries);\n\n createTypes(dictionariesPaths);\n\n createDictionaryEntryPoint();\n\n appLogger('Dictionaries built', {\n isVerbose: true,\n });\n\n createModuleAugmentation();\n\n appLogger('Module augmentation built', {\n isVerbose: true,\n });\n};\n\nexport const handleContentDeclarationFileChange = async (\n filePath: string,\n configuration?: IntlayerConfig\n) => {\n const { content } =\n configuration ??\n getConfiguration({\n verbose: true,\n });\n\n // Process the file with the functionToRun\n appLogger(`Change detected: ${relative(content.baseDir, filePath)}`, {\n isVerbose: true,\n });\n\n const localeDictionaries = await loadLocalDictionaries(filePath);\n const updatedDictionariesPaths = await buildDictionary(localeDictionaries);\n const allDictionariesPaths: string[] = getDictionariesPath();\n\n createTypes(updatedDictionariesPaths);\n appLogger('TypeScript types built', {\n isVerbose: true,\n });\n\n if (\n updatedDictionariesPaths.some((updatedDictionaryPath) =>\n allDictionariesPaths.includes(updatedDictionaryPath)\n )\n ) {\n createDictionaryEntryPoint();\n\n appLogger('Dictionary list built', {\n isVerbose: true,\n });\n\n createModuleAugmentation();\n\n appLogger('Module augmentation built', {\n isVerbose: true,\n });\n }\n};\n\ntype WatchOptions = ChokidarOptions & {\n configuration?: IntlayerConfig;\n};\n\n// Initialize chokidar watcher (non-persistent)\nexport const watch = (options?: WatchOptions) => {\n const configuration =\n options?.configuration ??\n getConfiguration({\n verbose: true,\n });\n\n const { watch: isWatchMode, watchedFilesPatternWithPath } =\n configuration.content;\n\n /** @ts-ignore remove error Expected 0-1 arguments, but got 2. */\n return chokidarWatch(watchedFilesPatternWithPath, {\n persistent: isWatchMode, // Make the watcher persistent\n ignoreInitial: true, // Process existing files\n ...options,\n })\n .on(\n 'add',\n async (filePath) =>\n await handleAdditionalContentDeclarationFile(filePath, configuration)\n )\n .on(\n 'change',\n async (filePath) =>\n await handleContentDeclarationFileChange(filePath, configuration)\n )\n .on('error', (error) =>\n appLogger('Watcher error: ' + error, {\n level: 'error',\n })\n );\n};\n\nexport const buildAndWatchIntlayer = async (options?: WatchOptions) => {\n const configuration = options?.configuration ?? getConfiguration();\n\n await prepareIntlayer(configuration);\n\n if (configuration.content.watch) {\n // Start watching (assuming watch is also async)\n watch({ ...options, configuration });\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;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B;AAEzB,iCAAU,6BAA6B;AAAA,MACrC,WAAW;AAAA,IACb,CAAC;AAAA,EACH;AACF;AAOO,MAAM,QAAQ,CAAC,YAA2B;AAC/C,QAAM,gBACJ,SAAS,qBACT,gCAAiB;AAAA,IACf,SAAS;AAAA,EACX,CAAC;AAEH,QAAM,EAAE,OAAO,aAAa,4BAA4B,IACtD,cAAc;AAGhB,aAAO,gBAAAA,OAAc,6BAA6B;AAAA,IAChD,YAAY;AAAA;AAAA,IACZ,eAAe;AAAA;AAAA,IACf,GAAG;AAAA,EACL,CAAC,EACE;AAAA,IACC;AAAA,IACA,OAAO,aACL,MAAM,uCAAuC,UAAU,aAAa;AAAA,EACxE,EACC;AAAA,IACC;AAAA,IACA,OAAO,aACL,MAAM,mCAAmC,UAAU,aAAa;AAAA,EACpE,EACC;AAAA,IAAG;AAAA,IAAS,CAAC,cACZ,yBAAU,oBAAoB,OAAO;AAAA,MACnC,OAAO;AAAA,IACT,CAAC;AAAA,EACH;AACJ;AAEO,MAAM,wBAAwB,OAAO,YAA2B;AACrE,QAAM,gBAAgB,SAAS,qBAAiB,gCAAiB;AAEjE,YAAM,wCAAgB,aAAa;AAEnC,MAAI,cAAc,QAAQ,OAAO;AAE/B,UAAM,EAAE,GAAG,SAAS,cAAc,CAAC;AAAA,EACrC;AACF;","names":["chokidarWatch"]}
1
+ {"version":3,"sources":["../../../src/chokidar/watcher.ts"],"sourcesContent":["import { relative } from 'path';\nimport {\n type IntlayerConfig,\n appLogger,\n getConfiguration,\n} from '@intlayer/config';\n/** @ts-ignore remove error Module '\"chokidar\"' has no exported member 'ChokidarOptions' */\nimport { type ChokidarOptions, watch as chokidarWatch } from 'chokidar';\nimport { getDictionariesPath } from '../getDictionariesPath';\nimport { loadLocalDictionaries } from '../loadDictionaries/loadLocalDictionaries';\nimport { buildDictionary } from '../transpiler/declaration_file_to_dictionary/index';\nimport { createDictionaryEntryPoint } from '../transpiler/dictionary_to_main/createDictionaryEntryPoint';\nimport {\n createTypes,\n createModuleAugmentation,\n} from '../transpiler/dictionary_to_type/index';\nimport { prepareIntlayer } from '../prepareIntlayer';\n\nexport const handleAdditionalContentDeclarationFile = async (\n filePath: string,\n configuration?: IntlayerConfig\n) => {\n const { content } =\n configuration ??\n getConfiguration({\n verbose: true,\n });\n\n // Process the file with the functionToRun\n appLogger(\n `Additional file detected: ${relative(content.baseDir, filePath)}`,\n {\n isVerbose: true,\n }\n );\n\n const localeDictionaries = await loadLocalDictionaries(filePath);\n\n const dictionariesPaths = await buildDictionary(localeDictionaries);\n\n createTypes(dictionariesPaths);\n\n createDictionaryEntryPoint();\n\n appLogger('Dictionaries built', {\n isVerbose: true,\n });\n\n createModuleAugmentation();\n\n appLogger('Module augmentation built', {\n isVerbose: true,\n });\n};\n\nexport const handleContentDeclarationFileChange = async (\n filePath: string,\n configuration?: IntlayerConfig\n) => {\n const { content } =\n configuration ??\n getConfiguration({\n verbose: true,\n });\n\n // Process the file with the functionToRun\n appLogger(`Change detected: ${relative(content.baseDir, filePath)}`, {\n isVerbose: true,\n });\n\n const localeDictionaries = await loadLocalDictionaries(filePath);\n const updatedDictionariesPaths = await buildDictionary(localeDictionaries);\n const allDictionariesPaths: string[] = getDictionariesPath();\n\n createTypes(updatedDictionariesPaths);\n appLogger('TypeScript types built', {\n isVerbose: true,\n });\n\n if (\n updatedDictionariesPaths.some((updatedDictionaryPath) =>\n allDictionariesPaths.includes(updatedDictionaryPath)\n )\n ) {\n createDictionaryEntryPoint();\n\n appLogger('Dictionary list built', {\n isVerbose: true,\n });\n\n createModuleAugmentation();\n\n appLogger('Module augmentation built', {\n isVerbose: true,\n });\n }\n};\n\ntype WatchOptions = ChokidarOptions & {\n configuration?: IntlayerConfig;\n};\n\n// Initialize chokidar watcher (non-persistent)\nexport const watch = (options?: WatchOptions) => {\n const configuration =\n options?.configuration ??\n getConfiguration({\n verbose: true,\n });\n\n const { watch: isWatchMode, watchedFilesPatternWithPath } =\n configuration.content;\n\n /** @ts-ignore remove error Expected 0-1 arguments, but got 2. */\n return chokidarWatch(watchedFilesPatternWithPath, {\n persistent: isWatchMode, // Make the watcher persistent\n ignoreInitial: true, // Process existing files\n ...options,\n })\n .on(\n 'add',\n async (filePath) =>\n await handleAdditionalContentDeclarationFile(filePath, configuration)\n )\n .on(\n 'change',\n async (filePath) =>\n await handleContentDeclarationFileChange(filePath, configuration)\n )\n .on('error', (error) =>\n appLogger('Watcher error: ' + error, {\n level: 'error',\n })\n );\n};\n\nexport const buildAndWatchIntlayer = async (options?: WatchOptions) => {\n const configuration = options?.configuration ?? getConfiguration();\n\n await prepareIntlayer(configuration);\n\n if (configuration.content.watch | options.persistent) {\n // Start watching (assuming watch is also async)\n watch({ ...options, configuration });\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAyB;AACzB,oBAIO;AAEP,sBAA6D;AAC7D,iCAAoC;AACpC,mCAAsC;AACtC,4CAAgC;AAChC,wCAA2C;AAC3C,gCAGO;AACP,6BAAgC;AAEzB,MAAM,yCAAyC,OACpD,UACA,kBACG;AACH,QAAM,EAAE,QAAQ,IACd,qBACA,gCAAiB;AAAA,IACf,SAAS;AAAA,EACX,CAAC;AAGH;AAAA,IACE,iCAA6B,sBAAS,QAAQ,SAAS,QAAQ,CAAC;AAAA,IAChE;AAAA,MACE,WAAW;AAAA,IACb;AAAA,EACF;AAEA,QAAM,qBAAqB,UAAM,oDAAsB,QAAQ;AAE/D,QAAM,oBAAoB,UAAM,uDAAgB,kBAAkB;AAElE,6CAAY,iBAAiB;AAE7B,oEAA2B;AAE3B,+BAAU,sBAAsB;AAAA,IAC9B,WAAW;AAAA,EACb,CAAC;AAED,0DAAyB;AAEzB,+BAAU,6BAA6B;AAAA,IACrC,WAAW;AAAA,EACb,CAAC;AACH;AAEO,MAAM,qCAAqC,OAChD,UACA,kBACG;AACH,QAAM,EAAE,QAAQ,IACd,qBACA,gCAAiB;AAAA,IAC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AQ,QAAQ,YAAY;AAEpD,UAAM,EAAE,GAAG,SAAS,cAAc,CAAC;AAAA,EACrC;AACF;","names":["chokidarWatch"]}
@@ -21,66 +21,11 @@ __export(loadContentDeclaration_exports, {
21
21
  loadContentDeclarations: () => loadContentDeclarations
22
22
  });
23
23
  module.exports = __toCommonJS(loadContentDeclaration_exports);
24
- var import_vm = require("vm");
25
24
  var import_config = require("@intlayer/config");
26
- var import_esbuild = require("esbuild");
27
25
  var import_processContentDeclaration = require('../transpiler/declaration_file_to_dictionary/intlayer_dictionary/processContentDeclaration.cjs');
28
- const transformationOption = {
29
- loader: {
30
- ".js": "js",
31
- ".jsx": "jsx",
32
- ".mjs": "js",
33
- ".ts": "ts",
34
- ".tsx": "tsx",
35
- ".cjs": "js",
36
- ".json": "json"
37
- },
38
- format: "cjs",
39
- // Output format as commonjs
40
- target: "es2017",
41
- packages: "external",
42
- write: false,
43
- bundle: true
44
- };
45
- const loadContentDeclaration = (contentDeclarationFilePath) => {
46
- let contentDeclaration = void 0;
47
- const fileExtension = contentDeclarationFilePath.split(".").pop() ?? "";
48
- try {
49
- if (fileExtension === "json") {
50
- return (0, import_config.ESMxCJSRequire)(contentDeclarationFilePath);
51
- }
52
- const moduleResult = (0, import_esbuild.buildSync)({
53
- entryPoints: [contentDeclarationFilePath],
54
- ...transformationOption
55
- });
56
- const moduleResultString = moduleResult.outputFiles?.[0].text;
57
- if (!moduleResultString) {
58
- console.error("Configuration file could not be loaded.");
59
- return void 0;
60
- }
61
- const sandboxContext = (0, import_config.getSandBoxContext)();
62
- (0, import_vm.runInNewContext)(moduleResultString, sandboxContext);
63
- if (sandboxContext.exports.default && Object.keys(sandboxContext.exports.default).length > 0) {
64
- contentDeclaration = sandboxContext.exports.default;
65
- } else if (sandboxContext.module.exports.defaults && Object.keys(sandboxContext.module.exports.defaults).length > 0) {
66
- contentDeclaration = sandboxContext.module.exports.default;
67
- } else if (sandboxContext.module.exports.default && Object.keys(sandboxContext.module.exports.default).length > 0) {
68
- contentDeclaration = sandboxContext.module.exports.default;
69
- } else if (sandboxContext.module.exports && Object.keys(sandboxContext.module.exports).length > 0) {
70
- contentDeclaration = sandboxContext.module.exports;
71
- }
72
- if (typeof contentDeclaration === "undefined") {
73
- console.error("Configuration file could not be loaded.");
74
- return void 0;
75
- }
76
- return contentDeclaration;
77
- } catch (error) {
78
- console.error("Error:", error);
79
- }
80
- };
81
26
  const loadContentDeclarations = async (contentDeclarationFilePath) => {
82
27
  const contentDeclarations = contentDeclarationFilePath.map((path) => ({
83
- ...loadContentDeclaration(path),
28
+ ...(0, import_config.loadExternalFile)(path),
84
29
  filePath: path
85
30
  }));
86
31
  const resultDictionariesPaths = [];
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/loadDictionaries/loadContentDeclaration.ts"],"sourcesContent":["import { runInNewContext } from 'vm';\nimport { ESMxCJSRequire, getSandBoxContext } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { type BuildOptions, buildSync, type BuildResult } from 'esbuild';\nimport { processContentDeclaration } from '../transpiler/declaration_file_to_dictionary/intlayer_dictionary/processContentDeclaration';\n\nconst transformationOption: BuildOptions = {\n loader: {\n '.js': 'js',\n '.jsx': 'jsx',\n '.mjs': 'js',\n '.ts': 'ts',\n '.tsx': 'tsx',\n '.cjs': 'js',\n '.json': 'json',\n },\n format: 'cjs', // Output format as commonjs\n target: 'es2017',\n packages: 'external',\n write: false,\n bundle: true,\n};\n\n/**\n * Load the content declaration from the given path\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nconst loadContentDeclaration = (\n contentDeclarationFilePath: string\n): Dictionary | undefined => {\n let contentDeclaration: Dictionary | undefined = undefined;\n\n const fileExtension = contentDeclarationFilePath.split('.').pop() ?? '';\n\n try {\n if (fileExtension === 'json') {\n // Assume JSON\n return ESMxCJSRequire(contentDeclarationFilePath);\n }\n\n // Rest is JS, MJS or TS\n\n const moduleResult: BuildResult = buildSync({\n entryPoints: [contentDeclarationFilePath],\n\n ...transformationOption,\n });\n\n const moduleResultString = moduleResult.outputFiles?.[0].text;\n\n if (!moduleResultString) {\n console.error('Configuration file could not be loaded.');\n return undefined;\n }\n\n const sandboxContext = getSandBoxContext();\n\n runInNewContext(moduleResultString, sandboxContext);\n\n if (\n sandboxContext.exports.default &&\n Object.keys(sandboxContext.exports.default).length > 0\n ) {\n // ES Module\n contentDeclaration = sandboxContext.exports.default;\n } else if (\n sandboxContext.module.exports.defaults &&\n Object.keys(sandboxContext.module.exports.defaults).length > 0\n ) {\n // CommonJS\n contentDeclaration = sandboxContext.module.exports.default;\n } else if (\n sandboxContext.module.exports.default &&\n Object.keys(sandboxContext.module.exports.default).length > 0\n ) {\n // ES Module\n contentDeclaration = sandboxContext.module.exports.default;\n } else if (\n sandboxContext.module.exports &&\n Object.keys(sandboxContext.module.exports).length > 0\n ) {\n // Other\n contentDeclaration = sandboxContext.module.exports;\n }\n\n if (typeof contentDeclaration === 'undefined') {\n console.error('Configuration file could not be loaded.');\n return undefined;\n }\n\n return contentDeclaration;\n } catch (error) {\n console.error('Error:', error);\n }\n};\n\nexport const loadContentDeclarations = async (\n contentDeclarationFilePath: string[]\n): Promise<Dictionary[]> => {\n const contentDeclarations = contentDeclarationFilePath.map((path) => ({\n ...loadContentDeclaration(path),\n filePath: path,\n }));\n const resultDictionariesPaths: Dictionary[] = [];\n\n for await (const contentDeclaration of contentDeclarations) {\n if (!contentDeclaration) {\n continue;\n }\n\n const processedContentDeclaration = await processContentDeclaration(\n contentDeclaration as Dictionary\n );\n\n if (!processedContentDeclaration) {\n continue;\n }\n\n resultDictionariesPaths.push(processedContentDeclaration);\n }\n\n return resultDictionariesPaths;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAgC;AAChC,oBAAkD;AAElD,qBAA+D;AAC/D,uCAA0C;AAE1C,MAAM,uBAAqC;AAAA,EACzC,QAAQ;AAAA,IACN,OAAO;AAAA,IACP,QAAQ;AA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ACvD,aAAO;AAAA,IACT;AAEA,WAAO;AAAA,EACT,SAAS,OAAO;AACd,YAAQ,MAAM,UAAU,KAAK;AAAA,EAC/B;AACF;AAEO,MAAM,0BAA0B,OACrC,+BAC0B;AAC1B,QAAM,sBAAsB,2BAA2B,IAAI,CAAC,UAAU;AAAA,IACpE,GAAG,uBAAuB,IAAI;AAAA,IAC9B,UAAU;AAAA,EACZ,EAAE;AACF,QAAM,0BAAwC,CAAC;AAE/C,mBAAiB,sBAAsB,qBAAqB;AAC1D,QAAI,CAAC,oBAAoB;AACvB;AAAA,IACF;AAEA,UAAM,8BAA8B,UAAM;AAAA,MACxC;AAAA,IACF;AAEA,QAAI,CAAC,6BAA6B;AAChC;AAAA,IACF;AAEA,4BAAwB,KAAK,2BAA2B;AAAA,EAC1D;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../src/loadDictionaries/loadContentDeclaration.ts"],"sourcesContent":["import { loadExternalFile } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { processContentDeclaration } from '../transpiler/declaration_file_to_dictionary/intlayer_dictionary/processContentDeclaration';\n\nexport const loadContentDeclarations = async (\n contentDeclarationFilePath: string[]\n): Promise<Dictionary[]> => {\n const contentDeclarations = contentDeclarationFilePath.map((path) => ({\n ...loadExternalFile(path),\n filePath: path,\n }));\n const resultDictionariesPaths: Dictionary[] = [];\n\n for await (const contentDeclaration of contentDeclarations) {\n if (!contentDeclaration) {\n continue;\n }\n\n const processedContentDeclaration = await processContentDeclaration(\n contentDeclaration as Dictionary\n );\n\n if (!processedContentDeclaration) {\n continue;\n }\n\n resultDictionariesPaths.push(processedContentDeclaration);\n }\n\n return resultDictionariesPaths;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAiC;AAEjC,uCAA0C;AAEnC,MAAM,0BAA0B,OACrC,+BAC0B;AAC1B,QAAM,sBAAsB,2BAA2B,IAAI,CAAC,UAAU;AAAA,IACpE,OAAG,gCAAiB,IAAI;AAAA,IACxB,UAAU;AAAA,EACZ,EAAE;AACF,QAAM,0BAAwC,CAAC;AAE/C,mBAAiB,sBAAsB,qBAAqB;AAC1D,QAAI,CAAC,oBAAoB;AACvB;AAAA,IACF;AAEA,UAAM,8BAA8B,UAAM;AAAA,MACxC;AAAA,IACF;AAEA,QAAI,CAAC,6BAA6B;AAChC;AAAA,IACF;AAEA,4BAAwB,KAAK,2BAA2B;AAAA,EAC1D;AAEA,SAAO;AACT;","names":[]}
@@ -18,23 +18,23 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var processContentDeclaration_exports = {};
20
20
  __export(processContentDeclaration_exports, {
21
- processContentDeclaration: () => processContentDeclaration
21
+ processContentDeclaration: () => processContentDeclaration,
22
+ resolveContentPromises: () => resolveContentPromises
22
23
  });
23
24
  module.exports = __toCommonJS(processContentDeclaration_exports);
24
25
  var import_client = require("@intlayer/config/client");
25
- const awaitFunction = async (fn) => {
26
- if (fn && typeof fn.then === "function") {
27
- await fn;
26
+ const resolveContentPromises = async (entry) => {
27
+ if (entry && typeof entry.then === "function") {
28
+ const awaited = await entry;
29
+ return resolveContentPromises(awaited);
28
30
  }
29
- };
30
- const processFunctionResults = async (entry) => {
31
31
  if (typeof entry === "function") {
32
- const result = await awaitFunction(entry());
33
- return await processFunctionResults(result);
32
+ const result = entry();
33
+ return resolveContentPromises(result);
34
34
  }
35
35
  if (Array.isArray(entry)) {
36
36
  return Promise.all(
37
- entry.map(async (item) => await processFunctionResults(item))
37
+ entry.map(async (item) => resolveContentPromises(item))
38
38
  );
39
39
  }
40
40
  if (entry && typeof entry === "object") {
@@ -42,7 +42,7 @@ const processFunctionResults = async (entry) => {
42
42
  const keys = Object.keys(entry);
43
43
  await Promise.all(
44
44
  keys.map(async (key) => {
45
- result[key] = await processFunctionResults(entry[key]);
45
+ result[key] = await resolveContentPromises(entry[key]);
46
46
  })
47
47
  );
48
48
  return result;
@@ -51,7 +51,7 @@ const processFunctionResults = async (entry) => {
51
51
  };
52
52
  const processContentDeclaration = async (contentDeclaration) => {
53
53
  try {
54
- const content = await processFunctionResults(
54
+ const content = await resolveContentPromises(
55
55
  contentDeclaration.content
56
56
  );
57
57
  return {
@@ -66,6 +66,7 @@ const processContentDeclaration = async (contentDeclaration) => {
66
66
  };
67
67
  // Annotate the CommonJS export names for ESM import in node:
68
68
  0 && (module.exports = {
69
- processContentDeclaration
69
+ processContentDeclaration,
70
+ resolveContentPromises
70
71
  });
71
72
  //# sourceMappingURL=processContentDeclaration.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/intlayer_dictionary/processContentDeclaration.ts"],"sourcesContent":["import { logger } from '@intlayer/config/client';\nimport type { Dictionary } from '@intlayer/core';\n\n/**\n * Helper that awaits either a synchronous or asynchronous value.\n */\nconst awaitFunction = async (fn: any) => {\n // Check if result is a Promise (Thenable)\n\n if (fn && typeof fn.then === 'function') {\n // It's a Promise, so wait for it to resolve\n await fn;\n }\n // If not a Promise, it will just execute without awaiting\n};\n\n/**\n * A more \"unified\" approach where each type (function, array, object, primitive)\n * is handled inside the main recursive body.\n */\nconst processFunctionResults = async <T = unknown>(entry: any): Promise<T> => {\n // If entry is a function, invoke it and process the result\n if (typeof entry === 'function') {\n const result = await awaitFunction(entry());\n // Recursively process the result in case it contains nested arrays/objects/functions\n return await processFunctionResults(result);\n }\n\n // If entry is an array, recursively process each item\n if (Array.isArray(entry)) {\n return Promise.all(\n entry.map(async (item) => await processFunctionResults(item))\n ) as unknown as T;\n }\n\n // If entry is an object, recursively process each property\n if (entry && typeof entry === 'object') {\n const result: Record<string, any> = {};\n // Use Promise.all to handle any async resolution for the properties\n const keys = Object.keys(entry);\n await Promise.all(\n keys.map(async (key) => {\n result[key] = await processFunctionResults(entry[key]);\n })\n );\n return result as T;\n }\n\n // Otherwise, it's a primitive value—just return as is\n return entry as T;\n};\n\n/**\n * Function to load, process the module and return the Intlayer Dictionary from the module file\n */\nexport const processContentDeclaration = async (\n contentDeclaration: Dictionary\n): Promise<Dictionary | undefined> => {\n try {\n const content = (await processFunctionResults(\n contentDeclaration.content\n )) as Dictionary['content'];\n\n return {\n ...contentDeclaration,\n content,\n } as Dictionary;\n } catch (error) {\n logger(error, {\n level: 'error',\n });\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAuB;AAMvB,MAAM,gBAAgB,OAAO,OAAY;AAGvC,MAAI,MAAM,OAAO,GAAG,SAAS,YAAY;AAEvC,UAAM;AAAA,EACR;AAEF;AAMA,MAAM,yBAAyB,OAAoB,UAA2B;AAE5E,MAAI,OAAO,UAAU,YAAY;AAC/B,UAAM,SAAS,MAAM,cAAc,MAAM,CAAC;AAE1C,WAAO,MAAM,uBAAuB,MAAM;AAAA,EAC5C;AAGA,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,QAAQ;AAAA,MACb,MAAM,IAAI,OAAO,SAAS,MAAM,uBAAuB,IAAI,CAAC;AAAA,IAC9D;AAAA,EACF;AAGA,MAAI,SAAS,OAAO,UAAU,UAAU;AACtC,UAAM,SAA8B,CAAC;AAErC,UAAM,OAAO,OAAO,KAAK,KAAK;AAC9B,UAAM,QAAQ;AAAA,MACZ,KAAK,IAAI,OAAO,QAAQ;AACtB,eAAO,GAAG,IAAI,MAAM,uBAAuB,MAAM,GAAG,CAAC;AAAA,MACvD,CAAC;AAAA,IACH;AACA,WAAO;AAAA,EACT;AAGA,SAAO;AACT;AAKO,MAAM,4BAA4B,OACvC,uBACoC;AACpC,MAAI;AACF,UAAM,UAAW,MAAM;AAAA,MACrB,mBAAmB;AAAA,IACrB;AAEA,WAAO;AAAA,MACL,GAAG;AAAA,MACH;AAAA,IACF;AAAA,EACF,SAAS,OAAO;AACd,8BAAO,OAAO;AAAA,MACZ,OAAO;AAAA,IACT,CAAC;AAAA,EACH;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/intlayer_dictionary/processContentDeclaration.ts"],"sourcesContent":["import { logger } from '@intlayer/config/client';\nimport type { Dictionary } from '@intlayer/core';\n\n/**\n * A more \"unified\" approach where each type (function, array, object, primitive)\n * is handled inside the main recursive body.\n */\nexport const resolveContentPromises = async <T = unknown>(\n entry: any\n): Promise<T> => {\n // Check if entry is a Promise (Thenable)\n if (entry && typeof entry.then === 'function') {\n const awaited = await entry;\n return resolveContentPromises(awaited);\n }\n\n // If entry is a function, invoke it and process the result\n if (typeof entry === 'function') {\n const result = entry();\n return resolveContentPromises(result);\n }\n\n if (Array.isArray(entry)) {\n return Promise.all(\n entry.map(async (item) => resolveContentPromises(item))\n ) as unknown as T;\n }\n\n if (entry && typeof entry === 'object') {\n const result: Record<string, any> = {};\n const keys = Object.keys(entry);\n await Promise.all(\n keys.map(async (key) => {\n result[key] = await resolveContentPromises(entry[key]);\n })\n );\n return result as T;\n }\n\n return entry as T;\n};\n\n/**\n * Function to load, process the module and return the Intlayer Dictionary from the module file\n */\nexport const processContentDeclaration = async (\n contentDeclaration: Dictionary\n): Promise<Dictionary | undefined> => {\n try {\n const content = (await resolveContentPromises(\n contentDeclaration.content\n )) as Dictionary['content'];\n\n return {\n ...contentDeclaration,\n content,\n } as Dictionary;\n } catch (error) {\n logger(error, {\n level: 'error',\n });\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAuB;AAOhB,MAAM,yBAAyB,OACpC,UACe;AAEf,MAAI,SAAS,OAAO,MAAM,SAAS,YAAY;AAC7C,UAAM,UAAU,MAAM;AACtB,WAAO,uBAAuB,OAAO;AAAA,EACvC;AAGA,MAAI,OAAO,UAAU,YAAY;AAC/B,UAAM,SAAS,MAAM;AACrB,WAAO,uBAAuB,MAAM;AAAA,EACtC;AAEA,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,QAAQ;AAAA,MACb,MAAM,IAAI,OAAO,SAAS,uBAAuB,IAAI,CAAC;AAAA,IACxD;AAAA,EACF;AAEA,MAAI,SAAS,OAAO,UAAU,UAAU;AACtC,UAAM,SAA8B,CAAC;AACrC,UAAM,OAAO,OAAO,KAAK,KAAK;AAC9B,UAAM,QAAQ;AAAA,MACZ,KAAK,IAAI,OAAO,QAAQ;AACtB,eAAO,GAAG,IAAI,MAAM,uBAAuB,MAAM,GAAG,CAAC;AAAA,MACvD,CAAC;AAAA,IACH;AACA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAKO,MAAM,4BAA4B,OACvC,uBACoC;AACpC,MAAI;AACF,UAAM,UAAW,MAAM;AAAA,MACrB,mBAAmB;AAAA,IACrB;AAEA,WAAO;AAAA,MACL,GAAG;AAAA,MACH;AAAA,IACF;AAAA,EACF,SAAS,OAAO;AACd,8BAAO,OAAO;AAAA,MACZ,OAAO;AAAA,IACT,CAAC;AAAA,EACH;AACF;","names":[]}
@@ -89,7 +89,7 @@ const watch = (options) => {
89
89
  const buildAndWatchIntlayer = async (options) => {
90
90
  const configuration = options?.configuration ?? getConfiguration();
91
91
  await prepareIntlayer(configuration);
92
- if (configuration.content.watch) {
92
+ if (configuration.content.watch | options.persistent) {
93
93
  watch({ ...options, configuration });
94
94
  }
95
95
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/chokidar/watcher.ts"],"sourcesContent":["import { relative } from 'path';\nimport {\n type IntlayerConfig,\n appLogger,\n getConfiguration,\n} from '@intlayer/config';\n/** @ts-ignore remove error Module '\"chokidar\"' has no exported member 'ChokidarOptions' */\nimport { type ChokidarOptions, watch as chokidarWatch } from 'chokidar';\nimport { getDictionariesPath } from '../getDictionariesPath';\nimport { loadLocalDictionaries } from '../loadDictionaries/loadLocalDictionaries';\nimport { buildDictionary } from '../transpiler/declaration_file_to_dictionary/index';\nimport { createDictionaryEntryPoint } from '../transpiler/dictionary_to_main/createDictionaryEntryPoint';\nimport {\n createTypes,\n createModuleAugmentation,\n} from '../transpiler/dictionary_to_type/index';\nimport { prepareIntlayer } from '../prepareIntlayer';\n\nexport const handleAdditionalContentDeclarationFile = async (\n filePath: string,\n configuration?: IntlayerConfig\n) => {\n const { content } =\n configuration ??\n getConfiguration({\n verbose: true,\n });\n\n // Process the file with the functionToRun\n appLogger(\n `Additional file detected: ${relative(content.baseDir, filePath)}`,\n {\n isVerbose: true,\n }\n );\n\n const localeDictionaries = await loadLocalDictionaries(filePath);\n\n const dictionariesPaths = await buildDictionary(localeDictionaries);\n\n createTypes(dictionariesPaths);\n\n createDictionaryEntryPoint();\n\n appLogger('Dictionaries built', {\n isVerbose: true,\n });\n\n createModuleAugmentation();\n\n appLogger('Module augmentation built', {\n isVerbose: true,\n });\n};\n\nexport const handleContentDeclarationFileChange = async (\n filePath: string,\n configuration?: IntlayerConfig\n) => {\n const { content } =\n configuration ??\n getConfiguration({\n verbose: true,\n });\n\n // Process the file with the functionToRun\n appLogger(`Change detected: ${relative(content.baseDir, filePath)}`, {\n isVerbose: true,\n });\n\n const localeDictionaries = await loadLocalDictionaries(filePath);\n const updatedDictionariesPaths = await buildDictionary(localeDictionaries);\n const allDictionariesPaths: string[] = getDictionariesPath();\n\n createTypes(updatedDictionariesPaths);\n appLogger('TypeScript types built', {\n isVerbose: true,\n });\n\n if (\n updatedDictionariesPaths.some((updatedDictionaryPath) =>\n allDictionariesPaths.includes(updatedDictionaryPath)\n )\n ) {\n createDictionaryEntryPoint();\n\n appLogger('Dictionary list built', {\n isVerbose: true,\n });\n\n createModuleAugmentation();\n\n appLogger('Module augmentation built', {\n isVerbose: true,\n });\n }\n};\n\ntype WatchOptions = ChokidarOptions & {\n configuration?: IntlayerConfig;\n};\n\n// Initialize chokidar watcher (non-persistent)\nexport const watch = (options?: WatchOptions) => {\n const configuration =\n options?.configuration ??\n getConfiguration({\n verbose: true,\n });\n\n const { watch: isWatchMode, watchedFilesPatternWithPath } =\n configuration.content;\n\n /** @ts-ignore remove error Expected 0-1 arguments, but got 2. */\n return chokidarWatch(watchedFilesPatternWithPath, {\n persistent: isWatchMode, // Make the watcher persistent\n ignoreInitial: true, // Process existing files\n ...options,\n })\n .on(\n 'add',\n async (filePath) =>\n await handleAdditionalContentDeclarationFile(filePath, configuration)\n )\n .on(\n 'change',\n async (filePath) =>\n await handleContentDeclarationFileChange(filePath, configuration)\n )\n .on('error', (error) =>\n appLogger('Watcher error: ' + error, {\n level: 'error',\n })\n );\n};\n\nexport const buildAndWatchIntlayer = async (options?: WatchOptions) => {\n const configuration = options?.configuration ?? getConfiguration();\n\n await prepareIntlayer(configuration);\n\n if (configuration.content.watch) {\n // Start watching (assuming watch is also async)\n watch({ ...options, configuration });\n }\n};\n"],"mappings":"AAAA,SAAS,gBAAgB;AACzB;AAAA,EAEE;AAAA,EACA;AAAA,OACK;AAEP,SAA+B,SAAS,qBAAqB;AAC7D,SAAS,2BAA2B;AACpC,SAAS,6BAA6B;AACtC,SAAS,uBAAuB;AAChC,SAAS,kCAAkC;AAC3C;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,uBAAuB;AAEzB,MAAM,yCAAyC,OACpD,UACA,kBACG;AACH,QAAM,EAAE,QAAQ,IACd,iBACA,iBAAiB;AAAA,IACf,SAAS;AAAA,EACX,CAAC;AAGH;AAAA,IACE,6BAA6B,SAAS,QAAQ,SAAS,QAAQ,CAAC;AAAA,IAChE;AAAA,MACE,WAAW;AAAA,IACb;AAAA,EACF;AAEA,QAAM,qBAAqB,MAAM,sBAAsB,QAAQ;AAE/D,QAAM,oBAAoB,MAAM,gBAAgB,kBAAkB;AAElE,cAAY,iBAAiB;AAE7B,6BAA2B;AAE3B,YAAU,sBAAsB;AAAA,IAC9B,WAAW;AAAA,EACb,CAAC;AAED,2BAAyB;AAEzB,YAAU,6BAA6B;AAAA,IACrC,WAAW;AAAA,EACb,CAAC;AACH;AAEO,MAAM,qCAAqC,OAChD,UACA,kBAC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B,aAAa;AAEnC,MAAI,cAAc,QAAQ,OAAO;AAE/B,UAAM,EAAE,GAAG,SAAS,cAAc,CAAC;AAAA,EACrC;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/chokidar/watcher.ts"],"sourcesContent":["import { relative } from 'path';\nimport {\n type IntlayerConfig,\n appLogger,\n getConfiguration,\n} from '@intlayer/config';\n/** @ts-ignore remove error Module '\"chokidar\"' has no exported member 'ChokidarOptions' */\nimport { type ChokidarOptions, watch as chokidarWatch } from 'chokidar';\nimport { getDictionariesPath } from '../getDictionariesPath';\nimport { loadLocalDictionaries } from '../loadDictionaries/loadLocalDictionaries';\nimport { buildDictionary } from '../transpiler/declaration_file_to_dictionary/index';\nimport { createDictionaryEntryPoint } from '../transpiler/dictionary_to_main/createDictionaryEntryPoint';\nimport {\n createTypes,\n createModuleAugmentation,\n} from '../transpiler/dictionary_to_type/index';\nimport { prepareIntlayer } from '../prepareIntlayer';\n\nexport const handleAdditionalContentDeclarationFile = async (\n filePath: string,\n configuration?: IntlayerConfig\n) => {\n const { content } =\n configuration ??\n getConfiguration({\n verbose: true,\n });\n\n // Process the file with the functionToRun\n appLogger(\n `Additional file detected: ${relative(content.baseDir, filePath)}`,\n {\n isVerbose: true,\n }\n );\n\n const localeDictionaries = await loadLocalDictionaries(filePath);\n\n const dictionariesPaths = await buildDictionary(localeDictionaries);\n\n createTypes(dictionariesPaths);\n\n createDictionaryEntryPoint();\n\n appLogger('Dictionaries built', {\n isVerbose: true,\n });\n\n createModuleAugmentation();\n\n appLogger('Module augmentation built', {\n isVerbose: true,\n });\n};\n\nexport const handleContentDeclarationFileChange = async (\n filePath: string,\n configuration?: IntlayerConfig\n) => {\n const { content } =\n configuration ??\n getConfiguration({\n verbose: true,\n });\n\n // Process the file with the functionToRun\n appLogger(`Change detected: ${relative(content.baseDir, filePath)}`, {\n isVerbose: true,\n });\n\n const localeDictionaries = await loadLocalDictionaries(filePath);\n const updatedDictionariesPaths = await buildDictionary(localeDictionaries);\n const allDictionariesPaths: string[] = getDictionariesPath();\n\n createTypes(updatedDictionariesPaths);\n appLogger('TypeScript types built', {\n isVerbose: true,\n });\n\n if (\n updatedDictionariesPaths.some((updatedDictionaryPath) =>\n allDictionariesPaths.includes(updatedDictionaryPath)\n )\n ) {\n createDictionaryEntryPoint();\n\n appLogger('Dictionary list built', {\n isVerbose: true,\n });\n\n createModuleAugmentation();\n\n appLogger('Module augmentation built', {\n isVerbose: true,\n });\n }\n};\n\ntype WatchOptions = ChokidarOptions & {\n configuration?: IntlayerConfig;\n};\n\n// Initialize chokidar watcher (non-persistent)\nexport const watch = (options?: WatchOptions) => {\n const configuration =\n options?.configuration ??\n getConfiguration({\n verbose: true,\n });\n\n const { watch: isWatchMode, watchedFilesPatternWithPath } =\n configuration.content;\n\n /** @ts-ignore remove error Expected 0-1 arguments, but got 2. */\n return chokidarWatch(watchedFilesPatternWithPath, {\n persistent: isWatchMode, // Make the watcher persistent\n ignoreInitial: true, // Process existing files\n ...options,\n })\n .on(\n 'add',\n async (filePath) =>\n await handleAdditionalContentDeclarationFile(filePath, configuration)\n )\n .on(\n 'change',\n async (filePath) =>\n await handleContentDeclarationFileChange(filePath, configuration)\n )\n .on('error', (error) =>\n appLogger('Watcher error: ' + error, {\n level: 'error',\n })\n );\n};\n\nexport const buildAndWatchIntlayer = async (options?: WatchOptions) => {\n const configuration = options?.configuration ?? getConfiguration();\n\n await prepareIntlayer(configuration);\n\n if (configuration.content.watch | options.persistent) {\n // Start watching (assuming watch is also async)\n watch({ ...options, configuration });\n }\n};\n"],"mappings":"AAAA,SAAS,gBAAgB;AACzB;AAAA,EAEE;AAAA,EACA;AAAA,OACK;AAEP,SAA+B,SAAS,qBAAqB;AAC7D,SAAS,2BAA2B;AACpC,SAAS,6BAA6B;AACtC,SAAS,uBAAuB;AAChC,SAAS,kCAAkC;AAC3C;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,uBAAuB;AAEzB,MAAM,yCAAyC,OACpD,UACA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IACtD,cAAc;AAGhB,SAAO,cAAc,6BAA6B;AAAA,IAChD,YAAY;AAAA;AAAA,IACZ,eAAe;AAAA;AAAA,IACf,GAAG;AAAA,EACL,CAAC,EACE;AAAA,IACC;AAAA,IACA,OAAO,aACL,MAAM,uCAAuC,UAAU,aAAa;AAAA,EACxE,EACC;AAAA,IACC;AAAA,IACA,OAAO,aACL,MAAM,mCAAmC,UAAU,aAAa;AAAA,EACpE,EACC;AAAA,IAAG;AAAA,IAAS,CAAC,UACZ,UAAU,oBAAoB,OAAO;AAAA,MACnC,OAAO;AAAA,IACT,CAAC;AAAA,EACH;AACJ;AAEO,MAAM,wBAAwB,OAAO,YAA2B;AACrE,QAAM,gBAAgB,SAAS,iBAAiB,iBAAiB;AAEjE,QAAM,gBAAgB,aAAa;AAEnC,MAAI,cAAc,QAAQ,QAAQ,QAAQ,YAAY;AAEpD,UAAM,EAAE,GAAG,SAAS,cAAc,CAAC;AAAA,EACrC;AACF;","names":[]}
@@ -1,63 +1,8 @@
1
- import { runInNewContext } from "vm";
2
- import { ESMxCJSRequire, getSandBoxContext } from "@intlayer/config";
3
- import { buildSync } from "esbuild";
1
+ import { loadExternalFile } from "@intlayer/config";
4
2
  import { processContentDeclaration } from "../transpiler/declaration_file_to_dictionary/intlayer_dictionary/processContentDeclaration.mjs";
5
- const transformationOption = {
6
- loader: {
7
- ".js": "js",
8
- ".jsx": "jsx",
9
- ".mjs": "js",
10
- ".ts": "ts",
11
- ".tsx": "tsx",
12
- ".cjs": "js",
13
- ".json": "json"
14
- },
15
- format: "cjs",
16
- // Output format as commonjs
17
- target: "es2017",
18
- packages: "external",
19
- write: false,
20
- bundle: true
21
- };
22
- const loadContentDeclaration = (contentDeclarationFilePath) => {
23
- let contentDeclaration = void 0;
24
- const fileExtension = contentDeclarationFilePath.split(".").pop() ?? "";
25
- try {
26
- if (fileExtension === "json") {
27
- return ESMxCJSRequire(contentDeclarationFilePath);
28
- }
29
- const moduleResult = buildSync({
30
- entryPoints: [contentDeclarationFilePath],
31
- ...transformationOption
32
- });
33
- const moduleResultString = moduleResult.outputFiles?.[0].text;
34
- if (!moduleResultString) {
35
- console.error("Configuration file could not be loaded.");
36
- return void 0;
37
- }
38
- const sandboxContext = getSandBoxContext();
39
- runInNewContext(moduleResultString, sandboxContext);
40
- if (sandboxContext.exports.default && Object.keys(sandboxContext.exports.default).length > 0) {
41
- contentDeclaration = sandboxContext.exports.default;
42
- } else if (sandboxContext.module.exports.defaults && Object.keys(sandboxContext.module.exports.defaults).length > 0) {
43
- contentDeclaration = sandboxContext.module.exports.default;
44
- } else if (sandboxContext.module.exports.default && Object.keys(sandboxContext.module.exports.default).length > 0) {
45
- contentDeclaration = sandboxContext.module.exports.default;
46
- } else if (sandboxContext.module.exports && Object.keys(sandboxContext.module.exports).length > 0) {
47
- contentDeclaration = sandboxContext.module.exports;
48
- }
49
- if (typeof contentDeclaration === "undefined") {
50
- console.error("Configuration file could not be loaded.");
51
- return void 0;
52
- }
53
- return contentDeclaration;
54
- } catch (error) {
55
- console.error("Error:", error);
56
- }
57
- };
58
3
  const loadContentDeclarations = async (contentDeclarationFilePath) => {
59
4
  const contentDeclarations = contentDeclarationFilePath.map((path) => ({
60
- ...loadContentDeclaration(path),
5
+ ...loadExternalFile(path),
61
6
  filePath: path
62
7
  }));
63
8
  const resultDictionariesPaths = [];
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/loadDictionaries/loadContentDeclaration.ts"],"sourcesContent":["import { runInNewContext } from 'vm';\nimport { ESMxCJSRequire, getSandBoxContext } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { type BuildOptions, buildSync, type BuildResult } from 'esbuild';\nimport { processContentDeclaration } from '../transpiler/declaration_file_to_dictionary/intlayer_dictionary/processContentDeclaration';\n\nconst transformationOption: BuildOptions = {\n loader: {\n '.js': 'js',\n '.jsx': 'jsx',\n '.mjs': 'js',\n '.ts': 'ts',\n '.tsx': 'tsx',\n '.cjs': 'js',\n '.json': 'json',\n },\n format: 'cjs', // Output format as commonjs\n target: 'es2017',\n packages: 'external',\n write: false,\n bundle: true,\n};\n\n/**\n * Load the content declaration from the given path\n *\n * Accepts JSON, JS, MJS and TS files as configuration\n */\nconst loadContentDeclaration = (\n contentDeclarationFilePath: string\n): Dictionary | undefined => {\n let contentDeclaration: Dictionary | undefined = undefined;\n\n const fileExtension = contentDeclarationFilePath.split('.').pop() ?? '';\n\n try {\n if (fileExtension === 'json') {\n // Assume JSON\n return ESMxCJSRequire(contentDeclarationFilePath);\n }\n\n // Rest is JS, MJS or TS\n\n const moduleResult: BuildResult = buildSync({\n entryPoints: [contentDeclarationFilePath],\n\n ...transformationOption,\n });\n\n const moduleResultString = moduleResult.outputFiles?.[0].text;\n\n if (!moduleResultString) {\n console.error('Configuration file could not be loaded.');\n return undefined;\n }\n\n const sandboxContext = getSandBoxContext();\n\n runInNewContext(moduleResultString, sandboxContext);\n\n if (\n sandboxContext.exports.default &&\n Object.keys(sandboxContext.exports.default).length > 0\n ) {\n // ES Module\n contentDeclaration = sandboxContext.exports.default;\n } else if (\n sandboxContext.module.exports.defaults &&\n Object.keys(sandboxContext.module.exports.defaults).length > 0\n ) {\n // CommonJS\n contentDeclaration = sandboxContext.module.exports.default;\n } else if (\n sandboxContext.module.exports.default &&\n Object.keys(sandboxContext.module.exports.default).length > 0\n ) {\n // ES Module\n contentDeclaration = sandboxContext.module.exports.default;\n } else if (\n sandboxContext.module.exports &&\n Object.keys(sandboxContext.module.exports).length > 0\n ) {\n // Other\n contentDeclaration = sandboxContext.module.exports;\n }\n\n if (typeof contentDeclaration === 'undefined') {\n console.error('Configuration file could not be loaded.');\n return undefined;\n }\n\n return contentDeclaration;\n } catch (error) {\n console.error('Error:', error);\n }\n};\n\nexport const loadContentDeclarations = async (\n contentDeclarationFilePath: string[]\n): Promise<Dictionary[]> => {\n const contentDeclarations = contentDeclarationFilePath.map((path) => ({\n ...loadContentDeclaration(path),\n filePath: path,\n }));\n const resultDictionariesPaths: Dictionary[] = [];\n\n for await (const contentDeclaration of contentDeclarations) {\n if (!contentDeclaration) {\n continue;\n }\n\n const processedContentDeclaration = await processContentDeclaration(\n contentDeclaration as Dictionary\n );\n\n if (!processedContentDeclaration) {\n continue;\n }\n\n resultDictionariesPaths.push(processedContentDeclaration);\n }\n\n return resultDictionariesPaths;\n};\n"],"mappings":"AAAA,SAAS,uBAAuB;AAChC,SAAS,gBAAgB,yBAAyB;AAElD,SAA4B,iBAAmC;AAC/D,SAAS,iCAAiC;AAE1C,MAAM,uBAAqC;AAAA,EACzC,QAAQ;AAAA,IACN,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AAAA,EACA,QAAQ;AAAA;AAAA,EACR,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,OAAO;AAAA,EACP,QAAQ;AACV;AAOA,MAAM,yBAAyB,CAC7B,+BAC2B;AAC3B,MAAI,qBAA6C;AAEjD,QAAM,gBAAgB,2BAA2B,MAAM,GAAG,EAAE,IAAI,KAAK;AAErE,MAAI;AACF,QAAI,kBAAkB,QAAQ;AAE5B,aAAO,eAAe,0BAA0B;AAAA,IAClD;AAIA,UAAM,eAA4B,UAAU;AAAA,MAC1C,aAAa,CAAC,0BAA0B;AAAA,MAExC,GAAG;AAAA,IACL,CAAC;AAED,UAAM,qBAAqB,aAAa,cAAc,CAAC,EAAE;AAEzD,QAAI,CAAC,oBAAoB;AACvB,cAAQ,MAAM,yCAAyC;AACvD,aAAO;AAAA,IACT;AAEA,UAAM,iBAAiB,kBAAkB;AAEzC,oBAAgB,oBAAoB,cAAc;AAElD,QACE,eAAe,QAAQ,WACvB,OAAO,KAAK,eAAe,QAAQ,OAAO,EAAE,SAAS,GACrD;AAEA,2BAAqB,eAAe,QAAQ;AAAA,IAC9C,WACE,eAAe,OAAO,QAAQ,YAC9B,OAAO,KAAK,eAAe,OAAO,QAAQ,QAAQ,EAAE,SAAS,GAC7D;AAEA,2BAAqB,eAAe,OAAO,QAAQ;AAAA,IACrD,WACE,eAAe,OAAO,QAAQ,WAC9B,OAAO,KAAK,eAAe,OAAO,QAAQ,OAAO,EAAE,SAAS,GAC5D;AAEA,2BAAqB,eAAe,OAAO,QAAQ;AAAA,IACrD,WACE,eAAe,OAAO,WACtB,OAAO,KAAK,eAAe,OAAO,OAAO,EAAE,SAAS,GACpD;AAEA,2BAAqB,eAAe,OAAO;AAAA,IAC7C;AAEA,QAAI,OAAO,uBAAuB,aAAa;AAC7C,cAAQ,MAAM,yCAAyC;AACvD,aAAO;AAAA,IACT;AAEA,WAAO;AAAA,EACT,SAAS,OAAO;AACd,YAAQ,MAAM,UAAU,KAAK;AAAA,EAC/B;AACF;AAEO,MAAM,0BAA0B,OACrC,+BAC0B;AAC1B,QAAM,sBAAsB,2BAA2B,IAAI,CAAC,UAAU;AAAA,IACpE,GAAG,uBAAuB,IAAI;AAAA,IAC9B,UAAU;AAAA,EACZ,EAAE;AACF,QAAM,0BAAwC,CAAC;AAE/C,mBAAiB,sBAAsB,qBAAqB;AAC1D,QAAI,CAAC,oBAAoB;AACvB;AAAA,IACF;AAEA,UAAM,8BAA8B,MAAM;AAAA,MACxC;AAAA,IACF;AAEA,QAAI,CAAC,6BAA6B;AAChC;AAAA,IACF;AAEA,4BAAwB,KAAK,2BAA2B;AAAA,EAC1D;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../../src/loadDictionaries/loadContentDeclaration.ts"],"sourcesContent":["import { loadExternalFile } from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { processContentDeclaration } from '../transpiler/declaration_file_to_dictionary/intlayer_dictionary/processContentDeclaration';\n\nexport const loadContentDeclarations = async (\n contentDeclarationFilePath: string[]\n): Promise<Dictionary[]> => {\n const contentDeclarations = contentDeclarationFilePath.map((path) => ({\n ...loadExternalFile(path),\n filePath: path,\n }));\n const resultDictionariesPaths: Dictionary[] = [];\n\n for await (const contentDeclaration of contentDeclarations) {\n if (!contentDeclaration) {\n continue;\n }\n\n const processedContentDeclaration = await processContentDeclaration(\n contentDeclaration as Dictionary\n );\n\n if (!processedContentDeclaration) {\n continue;\n }\n\n resultDictionariesPaths.push(processedContentDeclaration);\n }\n\n return resultDictionariesPaths;\n};\n"],"mappings":"AAAA,SAAS,wBAAwB;AAEjC,SAAS,iCAAiC;AAEnC,MAAM,0BAA0B,OACrC,+BAC0B;AAC1B,QAAM,sBAAsB,2BAA2B,IAAI,CAAC,UAAU;AAAA,IACpE,GAAG,iBAAiB,IAAI;AAAA,IACxB,UAAU;AAAA,EACZ,EAAE;AACF,QAAM,0BAAwC,CAAC;AAE/C,mBAAiB,sBAAsB,qBAAqB;AAC1D,QAAI,CAAC,oBAAoB;AACvB;AAAA,IACF;AAEA,UAAM,8BAA8B,MAAM;AAAA,MACxC;AAAA,IACF;AAEA,QAAI,CAAC,6BAA6B;AAChC;AAAA,IACF;AAEA,4BAAwB,KAAK,2BAA2B;AAAA,EAC1D;AAEA,SAAO;AACT;","names":[]}
@@ -1,17 +1,16 @@
1
1
  import { logger } from "@intlayer/config/client";
2
- const awaitFunction = async (fn) => {
3
- if (fn && typeof fn.then === "function") {
4
- await fn;
2
+ const resolveContentPromises = async (entry) => {
3
+ if (entry && typeof entry.then === "function") {
4
+ const awaited = await entry;
5
+ return resolveContentPromises(awaited);
5
6
  }
6
- };
7
- const processFunctionResults = async (entry) => {
8
7
  if (typeof entry === "function") {
9
- const result = await awaitFunction(entry());
10
- return await processFunctionResults(result);
8
+ const result = entry();
9
+ return resolveContentPromises(result);
11
10
  }
12
11
  if (Array.isArray(entry)) {
13
12
  return Promise.all(
14
- entry.map(async (item) => await processFunctionResults(item))
13
+ entry.map(async (item) => resolveContentPromises(item))
15
14
  );
16
15
  }
17
16
  if (entry && typeof entry === "object") {
@@ -19,7 +18,7 @@ const processFunctionResults = async (entry) => {
19
18
  const keys = Object.keys(entry);
20
19
  await Promise.all(
21
20
  keys.map(async (key) => {
22
- result[key] = await processFunctionResults(entry[key]);
21
+ result[key] = await resolveContentPromises(entry[key]);
23
22
  })
24
23
  );
25
24
  return result;
@@ -28,7 +27,7 @@ const processFunctionResults = async (entry) => {
28
27
  };
29
28
  const processContentDeclaration = async (contentDeclaration) => {
30
29
  try {
31
- const content = await processFunctionResults(
30
+ const content = await resolveContentPromises(
32
31
  contentDeclaration.content
33
32
  );
34
33
  return {
@@ -42,6 +41,7 @@ const processContentDeclaration = async (contentDeclaration) => {
42
41
  }
43
42
  };
44
43
  export {
45
- processContentDeclaration
44
+ processContentDeclaration,
45
+ resolveContentPromises
46
46
  };
47
47
  //# sourceMappingURL=processContentDeclaration.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/intlayer_dictionary/processContentDeclaration.ts"],"sourcesContent":["import { logger } from '@intlayer/config/client';\nimport type { Dictionary } from '@intlayer/core';\n\n/**\n * Helper that awaits either a synchronous or asynchronous value.\n */\nconst awaitFunction = async (fn: any) => {\n // Check if result is a Promise (Thenable)\n\n if (fn && typeof fn.then === 'function') {\n // It's a Promise, so wait for it to resolve\n await fn;\n }\n // If not a Promise, it will just execute without awaiting\n};\n\n/**\n * A more \"unified\" approach where each type (function, array, object, primitive)\n * is handled inside the main recursive body.\n */\nconst processFunctionResults = async <T = unknown>(entry: any): Promise<T> => {\n // If entry is a function, invoke it and process the result\n if (typeof entry === 'function') {\n const result = await awaitFunction(entry());\n // Recursively process the result in case it contains nested arrays/objects/functions\n return await processFunctionResults(result);\n }\n\n // If entry is an array, recursively process each item\n if (Array.isArray(entry)) {\n return Promise.all(\n entry.map(async (item) => await processFunctionResults(item))\n ) as unknown as T;\n }\n\n // If entry is an object, recursively process each property\n if (entry && typeof entry === 'object') {\n const result: Record<string, any> = {};\n // Use Promise.all to handle any async resolution for the properties\n const keys = Object.keys(entry);\n await Promise.all(\n keys.map(async (key) => {\n result[key] = await processFunctionResults(entry[key]);\n })\n );\n return result as T;\n }\n\n // Otherwise, it's a primitive value—just return as is\n return entry as T;\n};\n\n/**\n * Function to load, process the module and return the Intlayer Dictionary from the module file\n */\nexport const processContentDeclaration = async (\n contentDeclaration: Dictionary\n): Promise<Dictionary | undefined> => {\n try {\n const content = (await processFunctionResults(\n contentDeclaration.content\n )) as Dictionary['content'];\n\n return {\n ...contentDeclaration,\n content,\n } as Dictionary;\n } catch (error) {\n logger(error, {\n level: 'error',\n });\n }\n};\n"],"mappings":"AAAA,SAAS,cAAc;AAMvB,MAAM,gBAAgB,OAAO,OAAY;AAGvC,MAAI,MAAM,OAAO,GAAG,SAAS,YAAY;AAEvC,UAAM;AAAA,EACR;AAEF;AAMA,MAAM,yBAAyB,OAAoB,UAA2B;AAE5E,MAAI,OAAO,UAAU,YAAY;AAC/B,UAAM,SAAS,MAAM,cAAc,MAAM,CAAC;AAE1C,WAAO,MAAM,uBAAuB,MAAM;AAAA,EAC5C;AAGA,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,QAAQ;AAAA,MACb,MAAM,IAAI,OAAO,SAAS,MAAM,uBAAuB,IAAI,CAAC;AAAA,IAC9D;AAAA,EACF;AAGA,MAAI,SAAS,OAAO,UAAU,UAAU;AACtC,UAAM,SAA8B,CAAC;AAErC,UAAM,OAAO,OAAO,KAAK,KAAK;AAC9B,UAAM,QAAQ;AAAA,MACZ,KAAK,IAAI,OAAO,QAAQ;AACtB,eAAO,GAAG,IAAI,MAAM,uBAAuB,MAAM,GAAG,CAAC;AAAA,MACvD,CAAC;AAAA,IACH;AACA,WAAO;AAAA,EACT;AAGA,SAAO;AACT;AAKO,MAAM,4BAA4B,OACvC,uBACoC;AACpC,MAAI;AACF,UAAM,UAAW,MAAM;AAAA,MACrB,mBAAmB;AAAA,IACrB;AAEA,WAAO;AAAA,MACL,GAAG;AAAA,MACH;AAAA,IACF;AAAA,EACF,SAAS,OAAO;AACd,WAAO,OAAO;AAAA,MACZ,OAAO;AAAA,IACT,CAAC;AAAA,EACH;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../../../src/transpiler/declaration_file_to_dictionary/intlayer_dictionary/processContentDeclaration.ts"],"sourcesContent":["import { logger } from '@intlayer/config/client';\nimport type { Dictionary } from '@intlayer/core';\n\n/**\n * A more \"unified\" approach where each type (function, array, object, primitive)\n * is handled inside the main recursive body.\n */\nexport const resolveContentPromises = async <T = unknown>(\n entry: any\n): Promise<T> => {\n // Check if entry is a Promise (Thenable)\n if (entry && typeof entry.then === 'function') {\n const awaited = await entry;\n return resolveContentPromises(awaited);\n }\n\n // If entry is a function, invoke it and process the result\n if (typeof entry === 'function') {\n const result = entry();\n return resolveContentPromises(result);\n }\n\n if (Array.isArray(entry)) {\n return Promise.all(\n entry.map(async (item) => resolveContentPromises(item))\n ) as unknown as T;\n }\n\n if (entry && typeof entry === 'object') {\n const result: Record<string, any> = {};\n const keys = Object.keys(entry);\n await Promise.all(\n keys.map(async (key) => {\n result[key] = await resolveContentPromises(entry[key]);\n })\n );\n return result as T;\n }\n\n return entry as T;\n};\n\n/**\n * Function to load, process the module and return the Intlayer Dictionary from the module file\n */\nexport const processContentDeclaration = async (\n contentDeclaration: Dictionary\n): Promise<Dictionary | undefined> => {\n try {\n const content = (await resolveContentPromises(\n contentDeclaration.content\n )) as Dictionary['content'];\n\n return {\n ...contentDeclaration,\n content,\n } as Dictionary;\n } catch (error) {\n logger(error, {\n level: 'error',\n });\n }\n};\n"],"mappings":"AAAA,SAAS,cAAc;AAOhB,MAAM,yBAAyB,OACpC,UACe;AAEf,MAAI,SAAS,OAAO,MAAM,SAAS,YAAY;AAC7C,UAAM,UAAU,MAAM;AACtB,WAAO,uBAAuB,OAAO;AAAA,EACvC;AAGA,MAAI,OAAO,UAAU,YAAY;AAC/B,UAAM,SAAS,MAAM;AACrB,WAAO,uBAAuB,MAAM;AAAA,EACtC;AAEA,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,QAAQ;AAAA,MACb,MAAM,IAAI,OAAO,SAAS,uBAAuB,IAAI,CAAC;AAAA,IACxD;AAAA,EACF;AAEA,MAAI,SAAS,OAAO,UAAU,UAAU;AACtC,UAAM,SAA8B,CAAC;AACrC,UAAM,OAAO,OAAO,KAAK,KAAK;AAC9B,UAAM,QAAQ;AAAA,MACZ,KAAK,IAAI,OAAO,QAAQ;AACtB,eAAO,GAAG,IAAI,MAAM,uBAAuB,MAAM,GAAG,CAAC;AAAA,MACvD,CAAC;AAAA,IACH;AACA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAKO,MAAM,4BAA4B,OACvC,uBACoC;AACpC,MAAI;AACF,UAAM,UAAW,MAAM;AAAA,MACrB,mBAAmB;AAAA,IACrB;AAEA,WAAO;AAAA,MACL,GAAG;AAAA,MACH;AAAA,IACF;AAAA,EACF,SAAS,OAAO;AACd,WAAO,OAAO;AAAA,MACZ,OAAO;AAAA,IACT,CAAC;AAAA,EACH;AACF;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"loadContentDeclaration.d.ts","sourceRoot":"","sources":["../../../src/loadDictionaries/loadContentDeclaration.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AA+FjD,eAAO,MAAM,uBAAuB,GAClC,4BAA4B,MAAM,EAAE,KACnC,OAAO,CAAC,UAAU,EAAE,CAwBtB,CAAC"}
1
+ {"version":3,"file":"loadContentDeclaration.d.ts","sourceRoot":"","sources":["../../../src/loadDictionaries/loadContentDeclaration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGjD,eAAO,MAAM,uBAAuB,GAClC,4BAA4B,MAAM,EAAE,KACnC,OAAO,CAAC,UAAU,EAAE,CAwBtB,CAAC"}
@@ -1,4 +1,9 @@
1
1
  import type { Dictionary } from '@intlayer/core';
2
+ /**
3
+ * A more "unified" approach where each type (function, array, object, primitive)
4
+ * is handled inside the main recursive body.
5
+ */
6
+ export declare const resolveContentPromises: <T = unknown>(entry: any) => Promise<T>;
2
7
  /**
3
8
  * Function to load, process the module and return the Intlayer Dictionary from the module file
4
9
  */
@@ -1 +1 @@
1
- {"version":3,"file":"processContentDeclaration.d.ts","sourceRoot":"","sources":["../../../../../src/transpiler/declaration_file_to_dictionary/intlayer_dictionary/processContentDeclaration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAmDjD;;GAEG;AACH,eAAO,MAAM,yBAAyB,GACpC,oBAAoB,UAAU,KAC7B,OAAO,CAAC,UAAU,GAAG,SAAS,CAehC,CAAC"}
1
+ {"version":3,"file":"processContentDeclaration.d.ts","sourceRoot":"","sources":["../../../../../src/transpiler/declaration_file_to_dictionary/intlayer_dictionary/processContentDeclaration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD;;;GAGG;AACH,eAAO,MAAM,sBAAsB,GAAU,CAAC,GAAG,OAAO,EACtD,OAAO,GAAG,KACT,OAAO,CAAC,CAAC,CA+BX,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,yBAAyB,GACpC,oBAAoB,UAAU,KAC7B,OAAO,CAAC,UAAU,GAAG,SAAS,CAehC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/chokidar",
3
- "version": "5.2.9",
3
+ "version": "5.3.1",
4
4
  "private": false,
5
5
  "description": "Uses chokidar to scan and build Intlayer declaration files into dictionaries based on Intlayer configuration.",
6
6
  "keywords": [
@@ -33,6 +33,7 @@
33
33
  "url": "https://github.com/aymericzip"
34
34
  }
35
35
  ],
36
+ "sideEffects": false,
36
37
  "exports": {
37
38
  ".": {
38
39
  "types": "./dist/types/index.d.ts",
@@ -59,13 +60,12 @@
59
60
  "chokidar": "^3.6.0",
60
61
  "crypto-js": "^4.2.0",
61
62
  "deepmerge": "^4.3.1",
62
- "esbuild": "^0.24.2",
63
63
  "fast-glob": "^3.3.3",
64
64
  "p-limit": "^3.1.0",
65
- "@intlayer/api": "5.2.9",
66
- "@intlayer/core": "5.2.9",
67
- "@intlayer/config": "5.2.9",
68
- "intlayer": "5.2.9"
65
+ "@intlayer/config": "5.3.1",
66
+ "@intlayer/api": "5.3.1",
67
+ "@intlayer/core": "5.3.1",
68
+ "intlayer": "5.3.1"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@changesets/cli": "2.27.12",
@@ -79,8 +79,8 @@
79
79
  "tsc-alias": "^1.8.10",
80
80
  "tsup": "^8.3.5",
81
81
  "typescript": "^5.7.3",
82
+ "@intlayer/backend": "5.3.1",
82
83
  "@utils/eslint-config": "1.0.4",
83
- "@intlayer/backend": "5.2.9",
84
84
  "@utils/ts-config": "1.0.4",
85
85
  "@utils/ts-config-types": "1.0.4",
86
86
  "@utils/tsup-config": "1.0.4"
@@ -88,10 +88,10 @@
88
88
  "peerDependencies": {
89
89
  "fast-glob": "^3.3.3",
90
90
  "react": ">=16.0.0",
91
- "@intlayer/config": "5.2.9",
92
- "@intlayer/api": "5.2.9",
93
- "@intlayer/core": "5.2.9",
94
- "intlayer": "5.2.9"
91
+ "@intlayer/core": "5.3.1",
92
+ "intlayer": "5.3.1",
93
+ "@intlayer/api": "5.3.1",
94
+ "@intlayer/config": "5.3.1"
95
95
  },
96
96
  "engines": {
97
97
  "node": ">=14.18"