@intlayer/webpack 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cjs/index.cjs +46 -0
  3. package/dist/cjs/index.cjs.map +1 -0
  4. package/dist/cjs/scripts/bundle.cjs +68 -0
  5. package/dist/cjs/scripts/bundle.cjs.map +1 -0
  6. package/dist/cjs/scripts/index.cjs +33 -0
  7. package/dist/cjs/scripts/index.cjs.map +1 -0
  8. package/dist/cjs/scripts/startServer.cjs +44 -0
  9. package/dist/cjs/scripts/startServer.cjs.map +1 -0
  10. package/dist/cjs/transpiler/dictionary_to_main/createDictionaryList.cjs +92 -0
  11. package/dist/cjs/transpiler/dictionary_to_main/createDictionaryList.cjs.map +1 -0
  12. package/dist/cjs/transpiler/dictionary_to_main/index.cjs +35 -0
  13. package/dist/cjs/transpiler/dictionary_to_main/index.cjs.map +1 -0
  14. package/dist/cjs/transpiler/dictionary_to_type/createModuleAugmentation.cjs +83 -0
  15. package/dist/cjs/transpiler/dictionary_to_type/createModuleAugmentation.cjs.map +1 -0
  16. package/dist/cjs/transpiler/dictionary_to_type/createType.cjs +122 -0
  17. package/dist/cjs/transpiler/dictionary_to_type/createType.cjs.map +1 -0
  18. package/dist/cjs/transpiler/dictionary_to_type/index.cjs +41 -0
  19. package/dist/cjs/transpiler/dictionary_to_type/index.cjs.map +1 -0
  20. package/dist/cjs/transpiler/intlater_module_to_dictionary/extractNestedJSON.cjs +50 -0
  21. package/dist/cjs/transpiler/intlater_module_to_dictionary/extractNestedJSON.cjs.map +1 -0
  22. package/dist/cjs/transpiler/intlater_module_to_dictionary/index.cjs +47 -0
  23. package/dist/cjs/transpiler/intlater_module_to_dictionary/index.cjs.map +1 -0
  24. package/dist/cjs/transpiler/intlater_module_to_dictionary/processModule.cjs +70 -0
  25. package/dist/cjs/transpiler/intlater_module_to_dictionary/processModule.cjs.map +1 -0
  26. package/dist/cjs/transpiler/intlater_module_to_dictionary/transpileBundledCode.cjs +112 -0
  27. package/dist/cjs/transpiler/intlater_module_to_dictionary/transpileBundledCode.cjs.map +1 -0
  28. package/dist/cjs/utils.cjs +53 -0
  29. package/dist/cjs/utils.cjs.map +1 -0
  30. package/dist/cjs/webpack-plugin.cjs +184 -0
  31. package/dist/cjs/webpack-plugin.cjs.map +1 -0
  32. package/dist/cjs/webpack.config.cjs +180 -0
  33. package/dist/cjs/webpack.config.cjs.map +1 -0
  34. package/dist/esm/index.d.mts +9 -0
  35. package/dist/esm/index.mjs +12 -0
  36. package/dist/esm/index.mjs.map +1 -0
  37. package/dist/esm/scripts/bundle.d.mts +7 -0
  38. package/dist/esm/scripts/bundle.mjs +35 -0
  39. package/dist/esm/scripts/bundle.mjs.map +1 -0
  40. package/dist/esm/scripts/index.d.mts +3 -0
  41. package/dist/esm/scripts/index.mjs +3 -0
  42. package/dist/esm/scripts/index.mjs.map +1 -0
  43. package/dist/esm/scripts/startServer.d.mts +5 -0
  44. package/dist/esm/scripts/startServer.mjs +10 -0
  45. package/dist/esm/scripts/startServer.mjs.map +1 -0
  46. package/dist/esm/transpiler/dictionary_to_main/createDictionaryList.d.mts +6 -0
  47. package/dist/esm/transpiler/dictionary_to_main/createDictionaryList.mjs +52 -0
  48. package/dist/esm/transpiler/dictionary_to_main/createDictionaryList.mjs.map +1 -0
  49. package/dist/esm/transpiler/dictionary_to_main/index.d.mts +1 -0
  50. package/dist/esm/transpiler/dictionary_to_main/index.mjs +2 -0
  51. package/dist/esm/transpiler/dictionary_to_main/index.mjs.map +1 -0
  52. package/dist/esm/transpiler/dictionary_to_type/createModuleAugmentation.d.mts +7 -0
  53. package/dist/esm/transpiler/dictionary_to_type/createModuleAugmentation.mjs +43 -0
  54. package/dist/esm/transpiler/dictionary_to_type/createModuleAugmentation.mjs.map +1 -0
  55. package/dist/esm/transpiler/dictionary_to_type/createType.d.mts +42 -0
  56. package/dist/esm/transpiler/dictionary_to_type/createType.mjs +84 -0
  57. package/dist/esm/transpiler/dictionary_to_type/createType.mjs.map +1 -0
  58. package/dist/esm/transpiler/dictionary_to_type/index.d.mts +10 -0
  59. package/dist/esm/transpiler/dictionary_to_type/index.mjs +3 -0
  60. package/dist/esm/transpiler/dictionary_to_type/index.mjs.map +1 -0
  61. package/dist/esm/transpiler/intlater_module_to_dictionary/extractNestedJSON.d.mts +44 -0
  62. package/dist/esm/transpiler/intlater_module_to_dictionary/extractNestedJSON.mjs +19 -0
  63. package/dist/esm/transpiler/intlater_module_to_dictionary/extractNestedJSON.mjs.map +1 -0
  64. package/dist/esm/transpiler/intlater_module_to_dictionary/index.d.mts +4 -0
  65. package/dist/esm/transpiler/intlater_module_to_dictionary/index.mjs +4 -0
  66. package/dist/esm/transpiler/intlater_module_to_dictionary/index.mjs.map +1 -0
  67. package/dist/esm/transpiler/intlater_module_to_dictionary/processModule.d.mts +10 -0
  68. package/dist/esm/transpiler/intlater_module_to_dictionary/processModule.mjs +39 -0
  69. package/dist/esm/transpiler/intlater_module_to_dictionary/processModule.mjs.map +1 -0
  70. package/dist/esm/transpiler/intlater_module_to_dictionary/transpileBundledCode.d.mts +8 -0
  71. package/dist/esm/transpiler/intlater_module_to_dictionary/transpileBundledCode.mjs +70 -0
  72. package/dist/esm/transpiler/intlater_module_to_dictionary/transpileBundledCode.mjs.map +1 -0
  73. package/dist/esm/utils.d.mts +4 -0
  74. package/dist/esm/utils.mjs +20 -0
  75. package/dist/esm/utils.mjs.map +1 -0
  76. package/dist/esm/webpack-plugin.d.mts +15 -0
  77. package/dist/esm/webpack-plugin.mjs +145 -0
  78. package/dist/esm/webpack-plugin.mjs.map +1 -0
  79. package/dist/esm/webpack.config.d.mts +7 -0
  80. package/dist/esm/webpack.config.mjs +136 -0
  81. package/dist/esm/webpack.config.mjs.map +1 -0
  82. package/package.json +97 -0
  83. package/src/index.ts +12 -0
  84. package/src/scripts/bundle.ts +44 -0
  85. package/src/scripts/index.ts +2 -0
  86. package/src/scripts/startServer.ts +14 -0
  87. package/src/transpiler/dictionary_to_main/createDictionaryList.ts +65 -0
  88. package/src/transpiler/dictionary_to_main/index.ts +1 -0
  89. package/src/transpiler/dictionary_to_type/createModuleAugmentation.ts +70 -0
  90. package/src/transpiler/dictionary_to_type/createType.ts +140 -0
  91. package/src/transpiler/dictionary_to_type/index.ts +2 -0
  92. package/src/transpiler/intlater_module_to_dictionary/extractNestedJSON.ts +60 -0
  93. package/src/transpiler/intlater_module_to_dictionary/index.ts +3 -0
  94. package/src/transpiler/intlater_module_to_dictionary/processModule.ts +69 -0
  95. package/src/transpiler/intlater_module_to_dictionary/transpileBundledCode.ts +107 -0
  96. package/src/utils.ts +26 -0
  97. package/src/webpack-plugin.ts +185 -0
  98. package/src/webpack.config.ts +149 -0
@@ -0,0 +1,50 @@
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, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
17
+ });
18
+ }
19
+ return to;
20
+ };
21
+ var __toCommonJS = (mod) =>
22
+ __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
+ var extractNestedJSON_exports = {};
24
+ __export(extractNestedJSON_exports, {
25
+ extractObjectsWithId: () => extractObjectsWithId,
26
+ });
27
+ module.exports = __toCommonJS(extractNestedJSON_exports);
28
+ const extractObjectsWithId = (input) => {
29
+ const search = (obj, results2) => {
30
+ if (obj && typeof obj === "object") {
31
+ if (Object.prototype.hasOwnProperty.call(obj, "id")) {
32
+ results2.push(obj);
33
+ }
34
+ for (const key of Object.keys(obj)) {
35
+ if (typeof obj[key] === "object") {
36
+ search(obj[key], results2);
37
+ }
38
+ }
39
+ }
40
+ };
41
+ const results = [];
42
+ search(input, results);
43
+ return results;
44
+ };
45
+ // Annotate the CommonJS export names for ESM import in node:
46
+ 0 &&
47
+ (module.exports = {
48
+ extractObjectsWithId,
49
+ });
50
+ //# sourceMappingURL=extractNestedJSON.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/transpiler/intlater_module_to_dictionary/extractNestedJSON.ts"],"sourcesContent":["import type { Content, ContentModule } from '@intlayer/core';\n\n/**\n *\n * This function extracts all nested objects with an 'id' field from the input object and returns them as an array\n *\n * Example:\n *\n * const input = {\n * id: '1',\n * name: 'John Doe',\n * address: {\n * id: '2',\n * street: '123 Main St',\n * city: 'Springfield',\n * state: 'IL'\n * },\n * };\n * const result = extractObjectsWithId(input);\n * console.log(result);\n *\n * Output:\n *\n * [{\n * id: '1',\n * name: 'John Doe',\n * address: {\n * id: '2',\n * street: '123 Main St',\n * city: 'Springfield',\n * state: 'IL'\n * }\n * },\n * {\n * id: '2',\n * street: '123 Main St',\n * city: 'Springfield',\n * state: 'IL'\n * }]\n *\n */\nexport const extractObjectsWithId = (input: ContentModule): ContentModule[] => {\n // Function to recursively search and extract nested objects with an 'id'\n const search = (obj: Content, results: ContentModule[]): void => {\n if (obj && typeof obj === 'object') {\n if (Object.prototype.hasOwnProperty.call(obj, 'id')) {\n results.push(obj as ContentModule);\n }\n for (const key of Object.keys(obj)) {\n if (typeof obj[key] === 'object') {\n search(obj[key] as Content, results);\n }\n }\n }\n };\n\n const results: ContentModule[] = [];\n search(input, results);\n return results;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAyCO,MAAM,uBAAuB,CAAC,UAA0C;AAE7E,QAAM,SAAS,CAAC,KAAcA,aAAmC;AAC/D,QAAI,OAAO,OAAO,QAAQ,UAAU;AAClC,UAAI,OAAO,UAAU,eAAe,KAAK,KAAK,IAAI,GAAG;AACnD,QAAAA,SAAQ,KAAK,GAAoB;AAAA,MACnC;AACA,iBAAW,OAAO,OAAO,KAAK,GAAG,GAAG;AAClC,YAAI,OAAO,IAAI,GAAG,MAAM,UAAU;AAChC,iBAAO,IAAI,GAAG,GAAcA,QAAO;AAAA,QACrC;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,UAA2B,CAAC;AAClC,SAAO,OAAO,OAAO;AACrB,SAAO;AACT;","names":["results"]}
@@ -0,0 +1,47 @@
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 __copyProps = (to, from, except, desc) => {
7
+ if ((from && typeof from === "object") || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, {
11
+ get: () => from[key],
12
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
13
+ });
14
+ }
15
+ return to;
16
+ };
17
+ var __reExport = (target, mod, secondTarget) => (
18
+ __copyProps(target, mod, "default"),
19
+ secondTarget && __copyProps(secondTarget, mod, "default")
20
+ );
21
+ var __toCommonJS = (mod) =>
22
+ __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
+ var intlater_module_to_dictionary_exports = {};
24
+ module.exports = __toCommonJS(intlater_module_to_dictionary_exports);
25
+ __reExport(
26
+ intlater_module_to_dictionary_exports,
27
+ require("./extractNestedJSON.cjs"),
28
+ module.exports
29
+ );
30
+ __reExport(
31
+ intlater_module_to_dictionary_exports,
32
+ require("./processModule.cjs"),
33
+ module.exports
34
+ );
35
+ __reExport(
36
+ intlater_module_to_dictionary_exports,
37
+ require("./transpileBundledCode.cjs"),
38
+ module.exports
39
+ );
40
+ // Annotate the CommonJS export names for ESM import in node:
41
+ 0 &&
42
+ (module.exports = {
43
+ ...require("./extractNestedJSON.cjs"),
44
+ ...require("./processModule.cjs"),
45
+ ...require("./transpileBundledCode.cjs"),
46
+ });
47
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/transpiler/intlater_module_to_dictionary/index.ts"],"sourcesContent":["export * from './extractNestedJSON';\nexport * from './processModule';\nexport * from './transpileBundledCode';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,kDAAc,gCAAd;AACA,kDAAc,4BADd;AAEA,kDAAc,mCAFd;","names":[]}
@@ -0,0 +1,70 @@
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, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
17
+ });
18
+ }
19
+ return to;
20
+ };
21
+ var __toCommonJS = (mod) =>
22
+ __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
+ var processModule_exports = {};
24
+ __export(processModule_exports, {
25
+ processModule: () => processModule,
26
+ });
27
+ module.exports = __toCommonJS(processModule_exports);
28
+ var import_path = require("path");
29
+ const loadModule = async (modulePath) => {
30
+ return (await import(modulePath)).default;
31
+ };
32
+ const processFunctionResults = async (entry) => {
33
+ if (entry && typeof entry === "object") {
34
+ const promises = [];
35
+ const result = {};
36
+ for (const key of Object.keys(entry)) {
37
+ const field = entry?.[key];
38
+ if (typeof field === "object") {
39
+ result[key] = await processFunctionResults(field);
40
+ }
41
+ if (typeof field === "function") {
42
+ const promise = (async () => {
43
+ const value = await field();
44
+ result[key] = value;
45
+ })();
46
+ promises.push(promise);
47
+ } else {
48
+ result[key] = field;
49
+ }
50
+ }
51
+ await Promise.all(promises);
52
+ return result;
53
+ }
54
+ return entry;
55
+ };
56
+ const processModule = async (file) => {
57
+ try {
58
+ const functionPath = (0, import_path.resolve)(file);
59
+ const entry = await loadModule(functionPath);
60
+ return await processFunctionResults(entry);
61
+ } catch (error) {
62
+ console.error("Error processing module:", error);
63
+ }
64
+ };
65
+ // Annotate the CommonJS export names for ESM import in node:
66
+ 0 &&
67
+ (module.exports = {
68
+ processModule,
69
+ });
70
+ //# sourceMappingURL=processModule.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/transpiler/intlater_module_to_dictionary/processModule.ts"],"sourcesContent":["import { resolve } from 'path';\nimport type {\n Content,\n ContentModule,\n FlatContent,\n FlatContentValue,\n} from '@intlayer/core';\n\n/**\n * Function to load the module file in a sandboxed environment\n */\nconst loadModule = async (modulePath: string): Promise<ContentModule> => {\n // @TODO: Sandbox the module to prevent malicious code execution\n\n return (await import(modulePath)).default;\n};\n\n/**\n * Function to replace function and async function fields with their results in the object\n */\nconst processFunctionResults = async (entry: Content): Promise<FlatContent> => {\n if (entry && typeof entry === 'object') {\n const promises: Promise<void>[] = [];\n const result: FlatContent = {};\n\n for (const key of Object.keys(entry)) {\n const field = entry?.[key];\n\n if (typeof field === 'object') {\n result[key] = (await processFunctionResults(\n field as Content\n )) as FlatContentValue;\n }\n\n if (typeof field === 'function') {\n // Wait for the function to resolve if it's an async function\n const promise = (async () => {\n // Execute the function and await the result if it's a Promise\n const value = await field();\n result[key] = value as FlatContentValue;\n })();\n promises.push(promise);\n } else {\n result[key] = field as FlatContentValue;\n }\n }\n\n // Wait for all async operations to complete\n await Promise.all(promises);\n\n return result;\n }\n\n return entry;\n};\n\n/**\n * Function to load, process the module and return the Intlayer ContentModule from the module file\n */\nexport const processModule = async (file: string) => {\n try {\n const functionPath = resolve(file);\n const entry = await loadModule(functionPath);\n\n return (await processFunctionResults(entry)) as ContentModule;\n } catch (error) {\n console.error('Error processing module:', error);\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwB;AAWxB,MAAM,aAAa,OAAO,eAA+C;AAGvE,UAAQ,MAAM,OAAO,aAAa;AACpC;AAKA,MAAM,yBAAyB,OAAO,UAAyC;AAC7E,MAAI,SAAS,OAAO,UAAU,UAAU;AACtC,UAAM,WAA4B,CAAC;AACnC,UAAM,SAAsB,CAAC;AAE7B,eAAW,OAAO,OAAO,KAAK,KAAK,GAAG;AACpC,YAAM,QAAQ,QAAQ,GAAG;AAEzB,UAAI,OAAO,UAAU,UAAU;AAC7B,eAAO,GAAG,IAAK,MAAM;AAAA,UACnB;AAAA,QACF;AAAA,MACF;AAEA,UAAI,OAAO,UAAU,YAAY;AAE/B,cAAM,WAAW,YAAY;AAE3B,gBAAM,QAAQ,MAAM,MAAM;AAC1B,iBAAO,GAAG,IAAI;AAAA,QAChB,GAAG;AACH,iBAAS,KAAK,OAAO;AAAA,MACvB,OAAO;AACL,eAAO,GAAG,IAAI;AAAA,MAChB;AAAA,IACF;AAGA,UAAM,QAAQ,IAAI,QAAQ;AAE1B,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAKO,MAAM,gBAAgB,OAAO,SAAiB;AACnD,MAAI;AACF,UAAM,mBAAe,qBAAQ,IAAI;AACjC,UAAM,QAAQ,MAAM,WAAW,YAAY;AAE3C,WAAQ,MAAM,uBAAuB,KAAK;AAAA,EAC5C,SAAS,OAAO;AACd,YAAQ,MAAM,4BAA4B,KAAK;AAAA,EACjD;AACF;","names":[]}
@@ -0,0 +1,112 @@
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, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
17
+ });
18
+ }
19
+ return to;
20
+ };
21
+ var __toCommonJS = (mod) =>
22
+ __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
+ var transpileBundledCode_exports = {};
24
+ __export(transpileBundledCode_exports, {
25
+ transpileBundledCode: () => transpileBundledCode,
26
+ });
27
+ module.exports = __toCommonJS(transpileBundledCode_exports);
28
+ var import_fs = require("fs");
29
+ var import_promises = require("fs/promises");
30
+ var import_path = require("path");
31
+ var import_config = require("@intlayer/config");
32
+ var import_extractNestedJSON = require("./extractNestedJSON.cjs");
33
+ var import_processModule = require("./processModule.cjs");
34
+ const { content } = (0, import_config.getConfiguration)();
35
+ const { dictionariesDir, bundleFileExtension } = content;
36
+ const loadBundledModule = async (bundledEntryPath) => {
37
+ const entryFilePath = (0, import_path.resolve)(bundledEntryPath);
38
+ const isEntryFilePathExist = (0, import_fs.existsSync)(entryFilePath);
39
+ if (!isEntryFilePathExist) {
40
+ console.error("Entry file not found. " + entryFilePath);
41
+ return;
42
+ }
43
+ const isEntryPathValid = entryFilePath.endsWith(bundleFileExtension);
44
+ if (!isEntryPathValid) {
45
+ return;
46
+ }
47
+ try {
48
+ delete require.cache[entryFilePath];
49
+ const entry = await import(entryFilePath);
50
+ let result;
51
+ if (entry.default) {
52
+ result = await (0, import_processModule.processModule)(entryFilePath);
53
+ } else {
54
+ result = entry;
55
+ }
56
+ return result;
57
+ } catch (err) {
58
+ console.error(`Error transpiling ${entryFilePath}:`, err);
59
+ }
60
+ };
61
+ const buildDictionary = async (dictionaries) => {
62
+ const resultDictionariesPaths = [];
63
+ for await (const content2 of dictionaries) {
64
+ const contentString = JSON.stringify(content2);
65
+ const id = content2.id;
66
+ const outputFileName = `${id}.json`;
67
+ const resultFilePath = (0, import_path.resolve)(
68
+ dictionariesDir,
69
+ outputFileName
70
+ );
71
+ await (0, import_promises.writeFile)(
72
+ resultFilePath,
73
+ contentString,
74
+ "utf8"
75
+ ).catch((err) => {
76
+ console.error(`Error creating ${outputFileName}:`, err);
77
+ });
78
+ resultDictionariesPaths.push(resultFilePath);
79
+ }
80
+ return resultDictionariesPaths;
81
+ };
82
+ const transpileBundledCode = async (bundledEntriesPaths) => {
83
+ const resultDictionariesPaths = [];
84
+ if (typeof bundledEntriesPaths === "string") {
85
+ bundledEntriesPaths = [bundledEntriesPaths];
86
+ }
87
+ const filteredBundledEntriesPaths = bundledEntriesPaths.filter(
88
+ // Filter js files;
89
+ (bundledEntryPath) => bundledEntryPath.endsWith(bundleFileExtension)
90
+ );
91
+ await (0, import_promises.mkdir)((0, import_path.resolve)(dictionariesDir), {
92
+ recursive: true,
93
+ });
94
+ for await (const bundledEntryPath of filteredBundledEntriesPaths) {
95
+ const result = await loadBundledModule(bundledEntryPath);
96
+ if (!result) {
97
+ continue;
98
+ }
99
+ const nestedContent = (0, import_extractNestedJSON.extractObjectsWithId)(
100
+ result
101
+ );
102
+ const dictionariesPaths = await buildDictionary(nestedContent);
103
+ resultDictionariesPaths.push(...dictionariesPaths);
104
+ }
105
+ return resultDictionariesPaths;
106
+ };
107
+ // Annotate the CommonJS export names for ESM import in node:
108
+ 0 &&
109
+ (module.exports = {
110
+ transpileBundledCode,
111
+ });
112
+ //# sourceMappingURL=transpileBundledCode.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/transpiler/intlater_module_to_dictionary/transpileBundledCode.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport { mkdir, writeFile } from 'fs/promises';\nimport { resolve } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport type { ContentModule } from '@intlayer/core';\nimport { extractObjectsWithId } from './extractNestedJSON';\nimport { processModule } from './processModule';\n\nconst { content } = getConfiguration();\nconst { dictionariesDir, bundleFileExtension } = content;\n\nconst loadBundledModule = async (bundledEntryPath: string) => {\n const entryFilePath = resolve(bundledEntryPath);\n\n const isEntryFilePathExist = existsSync(entryFilePath);\n\n if (!isEntryFilePathExist) {\n console.error('Entry file not found. ' + entryFilePath);\n return;\n }\n\n const isEntryPathValid = entryFilePath.endsWith(bundleFileExtension);\n\n if (!isEntryPathValid) {\n return;\n }\n\n try {\n // Remove the module from the cache\n delete require.cache[entryFilePath];\n\n // Require the module anew\n const entry = await import(entryFilePath);\n\n let result: ContentModule | undefined;\n\n if (entry.default) {\n // JS or TS file\n result = await processModule(entryFilePath);\n } else {\n // JSON file\n result = entry;\n }\n\n return result;\n } catch (err) {\n console.error(`Error transpiling ${entryFilePath}:`, err);\n }\n};\n\nconst buildDictionary = async (dictionaries: ContentModule[]) => {\n const resultDictionariesPaths: string[] = [];\n\n for await (const content of dictionaries) {\n const contentString = JSON.stringify(content);\n\n const id = content.id;\n const outputFileName = `${id}.json`;\n const resultFilePath = resolve(dictionariesDir, outputFileName);\n\n // Create the json file\n await writeFile(resultFilePath, contentString, 'utf8').catch((err) => {\n console.error(`Error creating ${outputFileName}:`, err);\n });\n\n resultDictionariesPaths.push(resultFilePath);\n }\n\n return resultDictionariesPaths;\n};\n\n/**\n * This function transpile the bundled code to to make dictionaries as JSON files\n */\nexport const transpileBundledCode = async (\n bundledEntriesPaths: string[] | string\n) => {\n const resultDictionariesPaths: string[] = [];\n\n if (typeof bundledEntriesPaths === 'string') {\n bundledEntriesPaths = [bundledEntriesPaths];\n }\n\n const filteredBundledEntriesPaths: string[] = bundledEntriesPaths.filter(\n // Filter js files;\n (bundledEntryPath) => bundledEntryPath.endsWith(bundleFileExtension)\n );\n\n // Create the dictionaries folder if it doesn't exist\n await mkdir(resolve(dictionariesDir), { recursive: true });\n\n for await (const bundledEntryPath of filteredBundledEntriesPaths) {\n const result = await loadBundledModule(bundledEntryPath);\n\n if (!result) {\n continue;\n }\n\n const nestedContent: ContentModule[] = extractObjectsWithId(result);\n\n const dictionariesPaths: string[] = await buildDictionary(nestedContent);\n\n resultDictionariesPaths.push(...dictionariesPaths);\n }\n\n return resultDictionariesPaths;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAA2B;AAC3B,sBAAiC;AACjC,kBAAwB;AACxB,oBAAiC;AAEjC,+BAAqC;AACrC,2BAA8B;AAE9B,MAAM,EAAE,QAAQ,QAAI,gCAAiB;AACrC,MAAM,EAAE,iBAAiB,oBAAoB,IAAI;AAEjD,MAAM,oBAAoB,OAAO,qBAA6B;AAC5D,QAAM,oBAAgB,qBAAQ,gBAAgB;AAE9C,QAAM,2BAAuB,sBAAW,aAAa;AAErD,MAAI,CAAC,sBAAsB;AACzB,YAAQ,MAAM,2BAA2B,aAAa;AACtD;AAAA,EACF;AAEA,QAAM,mBAAmB,cAAc,SAAS,mBAAmB;AAEnE,MAAI,CAAC,kBAAkB;AACrB;AAAA,EACF;AAEA,MAAI;AAEF,WAAO,QAAQ,MAAM,aAAa;AAGlC,UAAM,QAAQ,MAAM,OAAO;AAE3B,QAAI;AAEJ,QAAI,MAAM,SAAS;AAEjB,eAAS,UAAM,oCAAc,aAAa;AAAA,IAC5C,OAAO;AAEL,eAAS;AAAA,IACX;AAEA,WAAO;AAAA,EACT,SAAS,KAAK;AACZ,YAAQ,MAAM,qBAAqB,aAAa,KAAK,GAAG;AAAA,EAC1D;AACF;AAEA,MAAM,kBAAkB,OAAO,iBAAkC;AAC/D,QAAM,0BAAoC,CAAC;AAE3C,mBAAiBA,YAAW,cAAc;AACxC,UAAM,gBAAgB,KAAK,UAAUA,QAAO;AAE5C,UAAM,KAAKA,SAAQ;AACnB,UAAM,iBAAiB,GAAG,EAAE;AAC5B,UAAM,qBAAiB,qBAAQ,iBAAiB,cAAc;AAG9D,cAAM,2BAAU,gBAAgB,eAAe,MAAM,EAAE,MAAM,CAAC,QAAQ;AACpE,cAAQ,MAAM,kBAAkB,cAAc,KAAK,GAAG;AAAA,IACxD,CAAC;AAED,4BAAwB,KAAK,cAAc;AAAA,EAC7C;AAEA,SAAO;AACT;AAKO,MAAM,uBAAuB,OAClC,wBACG;AACH,QAAM,0BAAoC,CAAC;AAE3C,MAAI,OAAO,wBAAwB,UAAU;AAC3C,0BAAsB,CAAC,mBAAmB;AAAA,EAC5C;AAEA,QAAM,8BAAwC,oBAAoB;AAAA;AAAA,IAEhE,CAAC,qBAAqB,iBAAiB,SAAS,mBAAmB;AAAA,EACrE;AAGA,YAAM,2BAAM,qBAAQ,eAAe,GAAG,EAAE,WAAW,KAAK,CAAC;AAEzD,mBAAiB,oBAAoB,6BAA6B;AAChE,UAAM,SAAS,MAAM,kBAAkB,gBAAgB;AAEvD,QAAI,CAAC,QAAQ;AACX;AAAA,IACF;AAEA,UAAM,oBAAiC,+CAAqB,MAAM;AAElE,UAAM,oBAA8B,MAAM,gBAAgB,aAAa;AAEvE,4BAAwB,KAAK,GAAG,iBAAiB;AAAA,EACnD;AAEA,SAAO;AACT;","names":["content"]}
@@ -0,0 +1,53 @@
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, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
17
+ });
18
+ }
19
+ return to;
20
+ };
21
+ var __toCommonJS = (mod) =>
22
+ __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
+ var utils_exports = {};
24
+ __export(utils_exports, {
25
+ getFileHash: () => getFileHash,
26
+ transformToCamelCase: () => transformToCamelCase,
27
+ });
28
+ module.exports = __toCommonJS(utils_exports);
29
+ var import_crypto_js = require("crypto-js");
30
+ const getFileHash = (filePath) => {
31
+ const hash = (0, import_crypto_js.SHA3)(filePath);
32
+ return hash
33
+ .toString(import_crypto_js.enc.Base64)
34
+ .replace(/[^A-Z\d]/gi, "")
35
+ .substring(0, 20);
36
+ };
37
+ const transformToCamelCase = (string) => {
38
+ const words = string.split(/[\s\-_]+/);
39
+ const camelCasedWords = words.map((word, index) => {
40
+ if (index === 0) {
41
+ return word[0].toUpperCase() + word.slice(1);
42
+ }
43
+ return word.charAt(0).toUpperCase() + word.slice(1);
44
+ });
45
+ return camelCasedWords.join("");
46
+ };
47
+ // Annotate the CommonJS export names for ESM import in node:
48
+ 0 &&
49
+ (module.exports = {
50
+ getFileHash,
51
+ transformToCamelCase,
52
+ });
53
+ //# sourceMappingURL=utils.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils.ts"],"sourcesContent":["import { SHA3, enc } from 'crypto-js';\n\nexport const getFileHash = (filePath: string) => {\n const hash = SHA3(filePath);\n\n return hash\n .toString(enc.Base64)\n .replace(/[^A-Z\\d]/gi, '')\n .substring(0, 20);\n};\n\nexport const transformToCamelCase = (string: string): string => {\n // Split the string into words using a regex that finds spaces, hyphens, and underscores\n const words = string.split(/[\\s\\-_]+/);\n\n // Transform each word except the first to have its first letter uppercase\n const camelCasedWords = words.map((word, index) => {\n if (index === 0) {\n return word[0].toUpperCase() + word.slice(1);\n }\n return word.charAt(0).toUpperCase() + word.slice(1);\n });\n\n // Join the words back together\n return camelCasedWords.join('');\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAA0B;AAEnB,MAAM,cAAc,CAAC,aAAqB;AAC/C,QAAM,WAAO,uBAAK,QAAQ;AAE1B,SAAO,KACJ,SAAS,qBAAI,MAAM,EACnB,QAAQ,cAAc,EAAE,EACxB,UAAU,GAAG,EAAE;AACpB;AAEO,MAAM,uBAAuB,CAAC,WAA2B;AAE9D,QAAM,QAAQ,OAAO,MAAM,UAAU;AAGrC,QAAM,kBAAkB,MAAM,IAAI,CAAC,MAAM,UAAU;AACjD,QAAI,UAAU,GAAG;AACf,aAAO,KAAK,CAAC,EAAE,YAAY,IAAI,KAAK,MAAM,CAAC;AAAA,IAC7C;AACA,WAAO,KAAK,OAAO,CAAC,EAAE,YAAY,IAAI,KAAK,MAAM,CAAC;AAAA,EACpD,CAAC;AAGD,SAAO,gBAAgB,KAAK,EAAE;AAChC;","names":[]}
@@ -0,0 +1,184 @@
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, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
17
+ });
18
+ }
19
+ return to;
20
+ };
21
+ var __toCommonJS = (mod) =>
22
+ __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
+ var webpack_plugin_exports = {};
24
+ __export(webpack_plugin_exports, {
25
+ IntLayerPlugin: () => IntLayerPlugin,
26
+ });
27
+ module.exports = __toCommonJS(webpack_plugin_exports);
28
+ var import_path = require("path");
29
+ var import_config = require("@intlayer/config");
30
+ var import_glob = require("glob");
31
+ var import_webpack = require("webpack");
32
+ var import_createDictionaryList = require("./transpiler/dictionary_to_main/createDictionaryList.cjs");
33
+ var import_createModuleAugmentation = require("./transpiler/dictionary_to_type/createModuleAugmentation.cjs");
34
+ var import_createType = require("./transpiler/dictionary_to_type/createType.cjs");
35
+ var import_transpileBundledCode = require("./transpiler/intlater_module_to_dictionary/transpileBundledCode.cjs");
36
+ var import_utils = require("./utils.cjs");
37
+ const getRelativePath = (filePath) =>
38
+ (0, import_path.relative)(baseDir, filePath);
39
+ const getBundledFilePathFromIntlayerModule = (filePath) => {
40
+ const hash = (0, import_utils.getFileHash)(filePath);
41
+ return `${bundleDir}/${hash}${bundleFileExtension}`;
42
+ };
43
+ const { content } = (0, import_config.getConfiguration)();
44
+ const { bundleDir, baseDir, bundleFileExtension, watchedFilesPatternWithPath } =
45
+ content;
46
+ class IntLayerPlugin {
47
+ managedFiles;
48
+ updatedFiles;
49
+ addedFiles;
50
+ constructor() {
51
+ this.managedFiles = /* @__PURE__ */ new Set();
52
+ this.updatedFiles = /* @__PURE__ */ new Set();
53
+ this.addedFiles = /* @__PURE__ */ new Set();
54
+ }
55
+ // function to initialize the dictionaries
56
+ async initDictionaries() {
57
+ const outputFiles = [...this.managedFiles].map((file) =>
58
+ (0, import_path.resolve)(bundleDir, file)
59
+ );
60
+ const dictionaries =
61
+ (await (0, import_transpileBundledCode.transpileBundledCode)(
62
+ outputFiles
63
+ )) ?? [];
64
+ console.info(
65
+ `Dictionaries:
66
+ ${dictionaries.map(getRelativePath).join("\n")}`
67
+ );
68
+ console.info("Building TypeScript types...");
69
+ (0, import_createType.createTypes)(dictionaries);
70
+ console.info("Building type index...");
71
+ (0, import_createModuleAugmentation.createModuleAugmentation)();
72
+ console.info("Building main...");
73
+ (0, import_createDictionaryList.createDictionaryList)();
74
+ }
75
+ // function to process when intlayer module files content are changed
76
+ async processFilesChanges() {
77
+ const dictionaries =
78
+ (await (0, import_transpileBundledCode.transpileBundledCode)([
79
+ ...this.updatedFiles,
80
+ ])) ?? [];
81
+ console.info(
82
+ `Updated dictionaries:
83
+ ${dictionaries.map(getRelativePath).join("\n")}`
84
+ );
85
+ console.info("Updating TypeScript types...");
86
+ (0, import_createType.createTypes)(dictionaries);
87
+ this.updatedFiles.clear();
88
+ }
89
+ // function to process when new intlayer module is detected
90
+ async processNewFiles() {
91
+ const dictionaries =
92
+ (await (0, import_transpileBundledCode.transpileBundledCode)([
93
+ ...this.addedFiles,
94
+ ])) ?? [];
95
+ console.info(
96
+ `New dictionaries:
97
+ ${dictionaries.map(getRelativePath).join("\n")}`
98
+ );
99
+ console.info("Building TypeScript types...");
100
+ (0, import_createType.createTypes)(dictionaries);
101
+ console.info("Building type index...");
102
+ (0, import_createModuleAugmentation.createModuleAugmentation)();
103
+ console.info("Building main...");
104
+ (0, import_createDictionaryList.createDictionaryList)();
105
+ this.managedFiles = /* @__PURE__ */ new Set([
106
+ ...this.managedFiles,
107
+ ...this.addedFiles,
108
+ ]);
109
+ this.addedFiles.clear();
110
+ }
111
+ async detectFileAddedOrRemoved() {
112
+ const filesFound = [];
113
+ for (const pattern of watchedFilesPatternWithPath) {
114
+ (0, import_glob.sync)(pattern).map((file) => filesFound.push(file));
115
+ }
116
+ const newFiles = new Set(
117
+ filesFound.filter((x) => !this.managedFiles.has(x))
118
+ );
119
+ const removedFiles = new Set(
120
+ [...this.managedFiles].filter((x) => !filesFound.includes(x))
121
+ );
122
+ if (
123
+ // Check if there is new files
124
+ newFiles.size > 0
125
+ ) {
126
+ console.info("New files:", [...newFiles]);
127
+ this.addedFiles = newFiles;
128
+ await this.processNewFiles();
129
+ }
130
+ if (
131
+ // Check if there is removed files
132
+ removedFiles.size > 0
133
+ ) {
134
+ console.info("Removed files:", [...removedFiles]);
135
+ this.managedFiles = new Set(
136
+ [...this.managedFiles].filter((x) => !removedFiles.has(x))
137
+ );
138
+ }
139
+ if (this.updatedFiles.size > 0) {
140
+ await this.processFilesChanges();
141
+ }
142
+ }
143
+ apply(compiler) {
144
+ compiler.hooks.entryOption.tap("EntryOptionPlugin", (context, entry) => {
145
+ if (typeof entry === "function") {
146
+ new import_webpack.DynamicEntryPlugin(context, entry).apply(compiler);
147
+ }
148
+ return true;
149
+ });
150
+ compiler.hooks.afterEmit.tapAsync(
151
+ "IntLayerPlugin - Process dictionaries",
152
+ async (compilation, callback) => {
153
+ const currentEmitFiles = new Set(Object.keys(compilation.assets));
154
+ if (
155
+ // Check if this first load
156
+ !this.managedFiles.size
157
+ ) {
158
+ this.managedFiles = currentEmitFiles;
159
+ await this.initDictionaries();
160
+ }
161
+ await this.detectFileAddedOrRemoved();
162
+ callback();
163
+ }
164
+ );
165
+ compiler.hooks.watchRun.tap(
166
+ "IntLayerPlugin - Change detection",
167
+ (compilation) => {
168
+ if (compilation.modifiedFiles) {
169
+ const updatedFiles = Array.from(compilation.modifiedFiles);
170
+ const outputFileNames = updatedFiles.map(
171
+ getBundledFilePathFromIntlayerModule
172
+ );
173
+ this.updatedFiles = new Set(outputFileNames);
174
+ }
175
+ }
176
+ );
177
+ }
178
+ }
179
+ // Annotate the CommonJS export names for ESM import in node:
180
+ 0 &&
181
+ (module.exports = {
182
+ IntLayerPlugin,
183
+ });
184
+ //# sourceMappingURL=webpack-plugin.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/webpack-plugin.ts"],"sourcesContent":["import { relative, resolve } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport { sync } from 'glob';\nimport { DynamicEntryPlugin, type Compiler } from 'webpack';\nimport { createDictionaryList } from './transpiler/dictionary_to_main/createDictionaryList';\nimport { createModuleAugmentation } from './transpiler/dictionary_to_type/createModuleAugmentation';\nimport { createTypes } from './transpiler/dictionary_to_type/createType';\nimport { transpileBundledCode } from './transpiler/intlater_module_to_dictionary/transpileBundledCode';\nimport { getFileHash } from './utils';\n\nconst getRelativePath = (filePath: string) => relative(baseDir, filePath);\n\nconst getBundledFilePathFromIntlayerModule = (filePath: string): string => {\n const hash = getFileHash(filePath);\n\n return `${bundleDir}/${hash}${bundleFileExtension}`;\n};\n\nconst { content } = getConfiguration();\nconst { bundleDir, baseDir, bundleFileExtension, watchedFilesPatternWithPath } =\n content;\n\nexport class IntLayerPlugin {\n private managedFiles: Set<string>;\n private updatedFiles: Set<string>;\n private addedFiles: Set<string>;\n\n constructor() {\n this.managedFiles = new Set();\n this.updatedFiles = new Set();\n this.addedFiles = new Set();\n }\n\n // function to initialize the dictionaries\n public async initDictionaries() {\n const outputFiles = [...this.managedFiles].map((file) =>\n resolve(bundleDir, file)\n );\n\n const dictionaries = (await transpileBundledCode(outputFiles)) ?? [];\n\n console.info(\n `Dictionaries: \\n ${dictionaries.map(getRelativePath).join('\\n')}`\n );\n\n console.info('Building TypeScript types...');\n createTypes(dictionaries);\n\n console.info('Building type index...');\n createModuleAugmentation();\n\n console.info('Building main...');\n createDictionaryList();\n }\n\n // function to process when intlayer module files content are changed\n public async processFilesChanges() {\n const dictionaries =\n (await transpileBundledCode([...this.updatedFiles])) ?? [];\n\n console.info(\n `Updated dictionaries: \\n ${dictionaries.map(getRelativePath).join('\\n')}`\n );\n\n console.info('Updating TypeScript types...');\n createTypes(dictionaries);\n\n this.updatedFiles.clear();\n }\n\n // function to process when new intlayer module is detected\n public async processNewFiles() {\n const dictionaries =\n (await transpileBundledCode([...this.addedFiles])) ?? [];\n\n console.info(\n `New dictionaries: \\n ${dictionaries.map(getRelativePath).join('\\n')}`\n );\n\n console.info('Building TypeScript types...');\n createTypes(dictionaries);\n\n console.info('Building type index...');\n createModuleAugmentation();\n\n console.info('Building main...');\n createDictionaryList();\n\n this.managedFiles = new Set([...this.managedFiles, ...this.addedFiles]);\n this.addedFiles.clear();\n }\n\n public async detectFileAddedOrRemoved() {\n const filesFound: string[] = [];\n\n for (const pattern of watchedFilesPatternWithPath) {\n sync(pattern).map((file) => filesFound.push(file));\n }\n\n // Detect new files by comparing with files emitted in previous compilation\n const newFiles = new Set(\n filesFound.filter((x) => !this.managedFiles.has(x))\n );\n\n const removedFiles = new Set(\n [...this.managedFiles].filter((x) => !filesFound.includes(x))\n );\n\n if (\n // Check if there is new files\n newFiles.size > 0\n ) {\n console.info('New files:', [...newFiles]);\n\n this.addedFiles = newFiles;\n\n await this.processNewFiles();\n }\n\n if (\n // Check if there is removed files\n removedFiles.size > 0\n ) {\n console.info('Removed files:', [...removedFiles]);\n\n this.managedFiles = new Set(\n [...this.managedFiles].filter((x) => !removedFiles.has(x))\n );\n }\n\n // After the compilation, transpile the changed files if any\n if (this.updatedFiles.size > 0) {\n await this.processFilesChanges();\n }\n }\n\n apply(compiler: Compiler): void {\n compiler.hooks.entryOption.tap('EntryOptionPlugin', (context, entry) => {\n if (typeof entry === 'function') {\n // DynamicEntryPlugin is used to add entries at runtime when files are created, updated or deleted\n new DynamicEntryPlugin(context, entry).apply(compiler);\n }\n\n return true;\n });\n\n compiler.hooks.afterEmit.tapAsync(\n 'IntLayerPlugin - Process dictionaries',\n async (compilation, callback) => {\n // Get a set of files that will be emitted in this compilation\n const currentEmitFiles = new Set(Object.keys(compilation.assets));\n\n if (\n // Check if this first load\n !this.managedFiles.size\n ) {\n // Update previousEmitFiles for the next compilation\n this.managedFiles = currentEmitFiles;\n\n await this.initDictionaries();\n }\n\n await this.detectFileAddedOrRemoved();\n\n callback();\n }\n );\n\n // Detect modified files on watch mode\n compiler.hooks.watchRun.tap(\n 'IntLayerPlugin - Change detection',\n (compilation) => {\n if (compilation.modifiedFiles) {\n const updatedFiles = Array.from(compilation.modifiedFiles);\n\n const outputFileNames = updatedFiles.map(\n getBundledFilePathFromIntlayerModule\n );\n\n this.updatedFiles = new Set(outputFileNames);\n }\n }\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAkC;AAClC,oBAAiC;AACjC,kBA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