@intlayer/webpack 1.0.1 → 1.2.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 (117) hide show
  1. package/dist/cjs/{scripts/startServer.cjs → getEntries.cjs} +19 -14
  2. package/dist/cjs/getEntries.cjs.map +1 -0
  3. package/dist/cjs/getEntries.d.ts +5 -0
  4. package/dist/cjs/index.cjs +0 -7
  5. package/dist/cjs/index.cjs.map +1 -1
  6. package/dist/cjs/index.d.ts +0 -2
  7. package/dist/cjs/utils.cjs +26 -17
  8. package/dist/cjs/utils.cjs.map +1 -1
  9. package/dist/cjs/utils.d.ts +5 -2
  10. package/dist/cjs/webpack-plugin.cjs +4 -134
  11. package/dist/cjs/webpack-plugin.cjs.map +1 -1
  12. package/dist/cjs/webpack-plugin.d.ts +1 -11
  13. package/dist/cjs/webpack.config.cjs +28 -25
  14. package/dist/cjs/webpack.config.cjs.map +1 -1
  15. package/dist/esm/getEntries.d.mts +5 -0
  16. package/dist/esm/getEntries.mjs +17 -0
  17. package/dist/esm/getEntries.mjs.map +1 -0
  18. package/dist/esm/index.d.mts +0 -2
  19. package/dist/esm/index.mjs +0 -4
  20. package/dist/esm/index.mjs.map +1 -1
  21. package/dist/esm/utils.d.mts +5 -2
  22. package/dist/esm/utils.mjs +13 -15
  23. package/dist/esm/utils.mjs.map +1 -1
  24. package/dist/esm/webpack-plugin.d.mts +1 -11
  25. package/dist/esm/webpack-plugin.mjs +4 -134
  26. package/dist/esm/webpack-plugin.mjs.map +1 -1
  27. package/dist/esm/webpack.config.mjs +29 -26
  28. package/dist/esm/webpack.config.mjs.map +1 -1
  29. package/package.json +11 -15
  30. package/src/getEntries.ts +19 -0
  31. package/src/index.ts +2 -12
  32. package/src/utils.ts +19 -19
  33. package/src/webpack-plugin.ts +5 -180
  34. package/src/webpack.config.ts +32 -28
  35. package/dist/cjs/scripts/bundle.cjs +0 -65
  36. package/dist/cjs/scripts/bundle.cjs.map +0 -1
  37. package/dist/cjs/scripts/bundle.d.ts +0 -7
  38. package/dist/cjs/scripts/index.cjs +0 -25
  39. package/dist/cjs/scripts/index.cjs.map +0 -1
  40. package/dist/cjs/scripts/index.d.ts +0 -3
  41. package/dist/cjs/scripts/startServer.cjs.map +0 -1
  42. package/dist/cjs/scripts/startServer.d.ts +0 -5
  43. package/dist/cjs/transpiler/dictionary_to_main/createDictionaryList.cjs +0 -76
  44. package/dist/cjs/transpiler/dictionary_to_main/createDictionaryList.cjs.map +0 -1
  45. package/dist/cjs/transpiler/dictionary_to_main/createDictionaryList.d.ts +0 -6
  46. package/dist/cjs/transpiler/dictionary_to_main/index.cjs +0 -23
  47. package/dist/cjs/transpiler/dictionary_to_main/index.cjs.map +0 -1
  48. package/dist/cjs/transpiler/dictionary_to_main/index.d.ts +0 -1
  49. package/dist/cjs/transpiler/dictionary_to_type/createModuleAugmentation.cjs +0 -87
  50. package/dist/cjs/transpiler/dictionary_to_type/createModuleAugmentation.cjs.map +0 -1
  51. package/dist/cjs/transpiler/dictionary_to_type/createModuleAugmentation.d.ts +0 -7
  52. package/dist/cjs/transpiler/dictionary_to_type/createType.cjs +0 -110
  53. package/dist/cjs/transpiler/dictionary_to_type/createType.cjs.map +0 -1
  54. package/dist/cjs/transpiler/dictionary_to_type/createType.d.ts +0 -42
  55. package/dist/cjs/transpiler/dictionary_to_type/index.cjs +0 -25
  56. package/dist/cjs/transpiler/dictionary_to_type/index.cjs.map +0 -1
  57. package/dist/cjs/transpiler/dictionary_to_type/index.d.ts +0 -3
  58. package/dist/cjs/transpiler/intlater_module_to_dictionary/extractNestedJSON.cjs +0 -45
  59. package/dist/cjs/transpiler/intlater_module_to_dictionary/extractNestedJSON.cjs.map +0 -1
  60. package/dist/cjs/transpiler/intlater_module_to_dictionary/extractNestedJSON.d.ts +0 -44
  61. package/dist/cjs/transpiler/intlater_module_to_dictionary/index.cjs +0 -27
  62. package/dist/cjs/transpiler/intlater_module_to_dictionary/index.cjs.map +0 -1
  63. package/dist/cjs/transpiler/intlater_module_to_dictionary/index.d.ts +0 -4
  64. package/dist/cjs/transpiler/intlater_module_to_dictionary/processModule.cjs +0 -67
  65. package/dist/cjs/transpiler/intlater_module_to_dictionary/processModule.cjs.map +0 -1
  66. package/dist/cjs/transpiler/intlater_module_to_dictionary/processModule.d.ts +0 -8
  67. package/dist/cjs/transpiler/intlater_module_to_dictionary/transpileBundledCode.cjs +0 -96
  68. package/dist/cjs/transpiler/intlater_module_to_dictionary/transpileBundledCode.cjs.map +0 -1
  69. package/dist/cjs/transpiler/intlater_module_to_dictionary/transpileBundledCode.d.ts +0 -6
  70. package/dist/esm/scripts/bundle.d.mts +0 -7
  71. package/dist/esm/scripts/bundle.mjs +0 -40
  72. package/dist/esm/scripts/bundle.mjs.map +0 -1
  73. package/dist/esm/scripts/index.d.mts +0 -3
  74. package/dist/esm/scripts/index.mjs +0 -3
  75. package/dist/esm/scripts/index.mjs.map +0 -1
  76. package/dist/esm/scripts/startServer.d.mts +0 -5
  77. package/dist/esm/scripts/startServer.mjs +0 -12
  78. package/dist/esm/scripts/startServer.mjs.map +0 -1
  79. package/dist/esm/transpiler/dictionary_to_main/createDictionaryList.d.mts +0 -6
  80. package/dist/esm/transpiler/dictionary_to_main/createDictionaryList.mjs +0 -52
  81. package/dist/esm/transpiler/dictionary_to_main/createDictionaryList.mjs.map +0 -1
  82. package/dist/esm/transpiler/dictionary_to_main/index.d.mts +0 -1
  83. package/dist/esm/transpiler/dictionary_to_main/index.mjs +0 -2
  84. package/dist/esm/transpiler/dictionary_to_main/index.mjs.map +0 -1
  85. package/dist/esm/transpiler/dictionary_to_type/createModuleAugmentation.d.mts +0 -7
  86. package/dist/esm/transpiler/dictionary_to_type/createModuleAugmentation.mjs +0 -62
  87. package/dist/esm/transpiler/dictionary_to_type/createModuleAugmentation.mjs.map +0 -1
  88. package/dist/esm/transpiler/dictionary_to_type/createType.d.mts +0 -42
  89. package/dist/esm/transpiler/dictionary_to_type/createType.mjs +0 -86
  90. package/dist/esm/transpiler/dictionary_to_type/createType.mjs.map +0 -1
  91. package/dist/esm/transpiler/dictionary_to_type/index.d.mts +0 -3
  92. package/dist/esm/transpiler/dictionary_to_type/index.mjs +0 -3
  93. package/dist/esm/transpiler/dictionary_to_type/index.mjs.map +0 -1
  94. package/dist/esm/transpiler/intlater_module_to_dictionary/extractNestedJSON.d.mts +0 -44
  95. package/dist/esm/transpiler/intlater_module_to_dictionary/extractNestedJSON.mjs +0 -21
  96. package/dist/esm/transpiler/intlater_module_to_dictionary/extractNestedJSON.mjs.map +0 -1
  97. package/dist/esm/transpiler/intlater_module_to_dictionary/index.d.mts +0 -4
  98. package/dist/esm/transpiler/intlater_module_to_dictionary/index.mjs +0 -4
  99. package/dist/esm/transpiler/intlater_module_to_dictionary/index.mjs.map +0 -1
  100. package/dist/esm/transpiler/intlater_module_to_dictionary/processModule.d.mts +0 -8
  101. package/dist/esm/transpiler/intlater_module_to_dictionary/processModule.mjs +0 -43
  102. package/dist/esm/transpiler/intlater_module_to_dictionary/processModule.mjs.map +0 -1
  103. package/dist/esm/transpiler/intlater_module_to_dictionary/transpileBundledCode.d.mts +0 -6
  104. package/dist/esm/transpiler/intlater_module_to_dictionary/transpileBundledCode.mjs +0 -72
  105. package/dist/esm/transpiler/intlater_module_to_dictionary/transpileBundledCode.mjs.map +0 -1
  106. package/src/scripts/bundle.ts +0 -44
  107. package/src/scripts/index.ts +0 -2
  108. package/src/scripts/startServer.ts +0 -14
  109. package/src/transpiler/dictionary_to_main/createDictionaryList.ts +0 -65
  110. package/src/transpiler/dictionary_to_main/index.ts +0 -1
  111. package/src/transpiler/dictionary_to_type/createModuleAugmentation.ts +0 -95
  112. package/src/transpiler/dictionary_to_type/createType.ts +0 -140
  113. package/src/transpiler/dictionary_to_type/index.ts +0 -2
  114. package/src/transpiler/intlater_module_to_dictionary/extractNestedJSON.ts +0 -60
  115. package/src/transpiler/intlater_module_to_dictionary/index.ts +0 -3
  116. package/src/transpiler/intlater_module_to_dictionary/processModule.ts +0 -69
  117. package/src/transpiler/intlater_module_to_dictionary/transpileBundledCode.ts +0 -107
@@ -1,25 +0,0 @@
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, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
- var dictionary_to_type_exports = {};
17
- module.exports = __toCommonJS(dictionary_to_type_exports);
18
- __reExport(dictionary_to_type_exports, require('./createModuleAugmentation.cjs'), module.exports);
19
- __reExport(dictionary_to_type_exports, require('./createType.cjs'), module.exports);
20
- // Annotate the CommonJS export names for ESM import in node:
21
- 0 && (module.exports = {
22
- ...require('./createModuleAugmentation.cjs'),
23
- ...require('./createType.cjs')
24
- });
25
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/transpiler/dictionary_to_type/index.ts"],"sourcesContent":["export * from './createModuleAugmentation';\nexport * from './createType';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,uCAAc,uCAAd;AACA,uCAAc,yBADd;","names":[]}
@@ -1,3 +0,0 @@
1
- export { createModuleAugmentation, getTypeName } from './createModuleAugmentation.js';
2
- export { createTypes, generateTypeScriptType, generateTypeScriptTypeContent } from './createType.js';
3
- import '@intlayer/core';
@@ -1,45 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var extractNestedJSON_exports = {};
20
- __export(extractNestedJSON_exports, {
21
- extractObjectsWithId: () => extractObjectsWithId
22
- });
23
- module.exports = __toCommonJS(extractNestedJSON_exports);
24
- const extractObjectsWithId = (input) => {
25
- const search = (obj, results2) => {
26
- if (obj && typeof obj === "object") {
27
- if (Object.prototype.hasOwnProperty.call(obj, "id")) {
28
- results2.push(obj);
29
- }
30
- for (const key of Object.keys(obj)) {
31
- if (typeof obj[key] === "object") {
32
- search(obj[key], results2);
33
- }
34
- }
35
- }
36
- };
37
- const results = [];
38
- search(input, results);
39
- return results;
40
- };
41
- // Annotate the CommonJS export names for ESM import in node:
42
- 0 && (module.exports = {
43
- extractObjectsWithId
44
- });
45
- //# sourceMappingURL=extractNestedJSON.cjs.map
@@ -1 +0,0 @@
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"]}
@@ -1,44 +0,0 @@
1
- import { ContentModule } from '@intlayer/core';
2
-
3
- /**
4
- *
5
- * This function extracts all nested objects with an 'id' field from the input object and returns them as an array
6
- *
7
- * Example:
8
- *
9
- * const input = {
10
- * id: '1',
11
- * name: 'John Doe',
12
- * address: {
13
- * id: '2',
14
- * street: '123 Main St',
15
- * city: 'Springfield',
16
- * state: 'IL'
17
- * },
18
- * };
19
- * const result = extractObjectsWithId(input);
20
- * console.log(result);
21
- *
22
- * Output:
23
- *
24
- * [{
25
- * id: '1',
26
- * name: 'John Doe',
27
- * address: {
28
- * id: '2',
29
- * street: '123 Main St',
30
- * city: 'Springfield',
31
- * state: 'IL'
32
- * }
33
- * },
34
- * {
35
- * id: '2',
36
- * street: '123 Main St',
37
- * city: 'Springfield',
38
- * state: 'IL'
39
- * }]
40
- *
41
- */
42
- declare const extractObjectsWithId: (input: ContentModule) => ContentModule[];
43
-
44
- export { extractObjectsWithId };
@@ -1,27 +0,0 @@
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, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
- var intlater_module_to_dictionary_exports = {};
17
- module.exports = __toCommonJS(intlater_module_to_dictionary_exports);
18
- __reExport(intlater_module_to_dictionary_exports, require('./extractNestedJSON.cjs'), module.exports);
19
- __reExport(intlater_module_to_dictionary_exports, require('./processModule.cjs'), module.exports);
20
- __reExport(intlater_module_to_dictionary_exports, require('./transpileBundledCode.cjs'), module.exports);
21
- // Annotate the CommonJS export names for ESM import in node:
22
- 0 && (module.exports = {
23
- ...require('./extractNestedJSON.cjs'),
24
- ...require('./processModule.cjs'),
25
- ...require('./transpileBundledCode.cjs')
26
- });
27
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
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":[]}
@@ -1,4 +0,0 @@
1
- export { extractObjectsWithId } from './extractNestedJSON.js';
2
- export { processModule } from './processModule.js';
3
- export { transpileBundledCode } from './transpileBundledCode.js';
4
- import '@intlayer/core';
@@ -1,67 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var processModule_exports = {};
20
- __export(processModule_exports, {
21
- processModule: () => processModule
22
- });
23
- module.exports = __toCommonJS(processModule_exports);
24
- var import_path = require("path");
25
- const loadModule = async (modulePath) => {
26
- return (await import(modulePath)).default;
27
- };
28
- const processFunctionResults = async (entry) => {
29
- if (entry && typeof entry === "object") {
30
- const promises = [];
31
- const result = {};
32
- for (const key of Object.keys(entry)) {
33
- const field = entry?.[key];
34
- if (typeof field === "object") {
35
- result[key] = await processFunctionResults(
36
- field
37
- );
38
- }
39
- if (typeof field === "function") {
40
- const promise = (async () => {
41
- const value = await field();
42
- result[key] = value;
43
- })();
44
- promises.push(promise);
45
- } else {
46
- result[key] = field;
47
- }
48
- }
49
- await Promise.all(promises);
50
- return result;
51
- }
52
- return entry;
53
- };
54
- const processModule = async (file) => {
55
- try {
56
- const functionPath = (0, import_path.resolve)(file);
57
- const entry = await loadModule(functionPath);
58
- return await processFunctionResults(entry);
59
- } catch (error) {
60
- console.error("Error processing module:", error);
61
- }
62
- };
63
- // Annotate the CommonJS export names for ESM import in node:
64
- 0 && (module.exports = {
65
- processModule
66
- });
67
- //# sourceMappingURL=processModule.cjs.map
@@ -1 +0,0 @@
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":[]}
@@ -1,8 +0,0 @@
1
- import { ContentModule } from '@intlayer/core';
2
-
3
- /**
4
- * Function to load, process the module and return the Intlayer ContentModule from the module file
5
- */
6
- declare const processModule: (file: string) => Promise<ContentModule | undefined>;
7
-
8
- export { processModule };
@@ -1,96 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var transpileBundledCode_exports = {};
20
- __export(transpileBundledCode_exports, {
21
- transpileBundledCode: () => transpileBundledCode
22
- });
23
- module.exports = __toCommonJS(transpileBundledCode_exports);
24
- var import_fs = require("fs");
25
- var import_promises = require("fs/promises");
26
- var import_path = require("path");
27
- var import_config = require("@intlayer/config");
28
- var import_extractNestedJSON = require('./extractNestedJSON.cjs');
29
- var import_processModule = require('./processModule.cjs');
30
- const { content } = (0, import_config.getConfiguration)();
31
- const { dictionariesDir, bundleFileExtension } = content;
32
- const loadBundledModule = async (bundledEntryPath) => {
33
- const entryFilePath = (0, import_path.resolve)(bundledEntryPath);
34
- const isEntryFilePathExist = (0, import_fs.existsSync)(entryFilePath);
35
- if (!isEntryFilePathExist) {
36
- console.error("Entry file not found. " + entryFilePath);
37
- return;
38
- }
39
- const isEntryPathValid = entryFilePath.endsWith(bundleFileExtension);
40
- if (!isEntryPathValid) {
41
- return;
42
- }
43
- try {
44
- delete require.cache[entryFilePath];
45
- const entry = await import(entryFilePath);
46
- let result;
47
- if (entry.default) {
48
- result = await (0, import_processModule.processModule)(entryFilePath);
49
- } else {
50
- result = entry;
51
- }
52
- return result;
53
- } catch (err) {
54
- console.error(`Error transpiling ${entryFilePath}:`, err);
55
- }
56
- };
57
- const buildDictionary = async (dictionaries) => {
58
- const resultDictionariesPaths = [];
59
- for await (const content2 of dictionaries) {
60
- const contentString = JSON.stringify(content2);
61
- const id = content2.id;
62
- const outputFileName = `${id}.json`;
63
- const resultFilePath = (0, import_path.resolve)(dictionariesDir, outputFileName);
64
- await (0, import_promises.writeFile)(resultFilePath, contentString, "utf8").catch((err) => {
65
- console.error(`Error creating ${outputFileName}:`, err);
66
- });
67
- resultDictionariesPaths.push(resultFilePath);
68
- }
69
- return resultDictionariesPaths;
70
- };
71
- const transpileBundledCode = async (bundledEntriesPaths) => {
72
- const resultDictionariesPaths = [];
73
- if (typeof bundledEntriesPaths === "string") {
74
- bundledEntriesPaths = [bundledEntriesPaths];
75
- }
76
- const filteredBundledEntriesPaths = bundledEntriesPaths.filter(
77
- // Filter js files;
78
- (bundledEntryPath) => bundledEntryPath.endsWith(bundleFileExtension)
79
- );
80
- await (0, import_promises.mkdir)((0, import_path.resolve)(dictionariesDir), { recursive: true });
81
- for await (const bundledEntryPath of filteredBundledEntriesPaths) {
82
- const result = await loadBundledModule(bundledEntryPath);
83
- if (!result) {
84
- continue;
85
- }
86
- const nestedContent = (0, import_extractNestedJSON.extractObjectsWithId)(result);
87
- const dictionariesPaths = await buildDictionary(nestedContent);
88
- resultDictionariesPaths.push(...dictionariesPaths);
89
- }
90
- return resultDictionariesPaths;
91
- };
92
- // Annotate the CommonJS export names for ESM import in node:
93
- 0 && (module.exports = {
94
- transpileBundledCode
95
- });
96
- //# sourceMappingURL=transpileBundledCode.cjs.map
@@ -1 +0,0 @@
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"]}
@@ -1,6 +0,0 @@
1
- /**
2
- * This function transpile the bundled code to to make dictionaries as JSON files
3
- */
4
- declare const transpileBundledCode: (bundledEntriesPaths: string[] | string) => Promise<string[]>;
5
-
6
- export { transpileBundledCode };
@@ -1,7 +0,0 @@
1
- import * as webpack from 'webpack';
2
- import { Compiler } from 'webpack';
3
-
4
- declare const bundle: (compiler: Compiler) => void;
5
- declare const watch: (compiler: Compiler) => webpack.Watching;
6
-
7
- export { bundle, watch };
@@ -1,40 +0,0 @@
1
- const bundle = (compiler) => (
2
- // Run the compiler
3
- compiler.run((err, stats) => {
4
- if (err) {
5
- console.error("Webpack compilation error:", err);
6
- return;
7
- }
8
- console.info("Webpack compilation successful.");
9
- if (stats)
10
- console.info(
11
- stats.toString({
12
- // Add options here to customize the stats output
13
- colors: true
14
- })
15
- );
16
- })
17
- );
18
- const watch = (compiler) => (
19
- // Run the compiler
20
- compiler.watch({}, (err, stats) => {
21
- if (err) {
22
- console.error("Webpack compilation error:", err);
23
- return;
24
- }
25
- console.info("Webpack compilation successful.");
26
- if (stats)
27
- console.info(
28
- stats.toString({
29
- // Add options here to customize the stats output
30
- colors: true
31
- })
32
- );
33
- console.info("Watch IntLayer content...");
34
- })
35
- );
36
- export {
37
- bundle,
38
- watch
39
- };
40
- //# sourceMappingURL=bundle.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/scripts/bundle.ts"],"sourcesContent":["import type { Compiler } from 'webpack';\n\nexport const bundle = (compiler: Compiler) =>\n // Run the compiler\n compiler.run((err, stats) => {\n // Handle errors and webpack compilation stats\n if (err) {\n console.error('Webpack compilation error:', err);\n return;\n }\n\n console.info('Webpack compilation successful.');\n\n if (stats)\n console.info(\n stats.toString({\n // Add options here to customize the stats output\n colors: true,\n })\n );\n });\n\nexport const watch = (compiler: Compiler) =>\n // Run the compiler\n compiler.watch({}, (err, stats) => {\n // Handle errors and webpack compilation stats\n if (err) {\n console.error('Webpack compilation error:', err);\n return;\n }\n\n console.info('Webpack compilation successful.');\n\n if (stats)\n console.info(\n stats.toString({\n // Add options here to customize the stats output\n colors: true,\n })\n );\n\n // After successful compilation, start the server\n console.info('Watch IntLayer content...');\n });\n"],"mappings":"AAEO,MAAM,SAAS,CAAC;AAAA;AAAA,EAErB,SAAS,IAAI,CAAC,KAAK,UAAU;AAE3B,QAAI,KAAK;AACP,cAAQ,MAAM,8BAA8B,GAAG;AAC/C;AAAA,IACF;AAEA,YAAQ,KAAK,iCAAiC;AAE9C,QAAI;AACF,cAAQ;AAAA,QACN,MAAM,SAAS;AAAA;AAAA,UAEb,QAAQ;AAAA,QACV,CAAC;AAAA,MACH;AAAA,EACJ,CAAC;AAAA;AAEI,MAAM,QAAQ,CAAC;AAAA;AAAA,EAEpB,SAAS,MAAM,CAAC,GAAG,CAAC,KAAK,UAAU;AAEjC,QAAI,KAAK;AACP,cAAQ,MAAM,8BAA8B,GAAG;AAC/C;AAAA,IACF;AAEA,YAAQ,KAAK,iCAAiC;AAE9C,QAAI;AACF,cAAQ;AAAA,QACN,MAAM,SAAS;AAAA;AAAA,UAEb,QAAQ;AAAA,QACV,CAAC;AAAA,MACH;AAGF,YAAQ,KAAK,2BAA2B;AAAA,EAC1C,CAAC;AAAA;","names":[]}
@@ -1,3 +0,0 @@
1
- export { startServer } from './startServer.mjs';
2
- export { bundle, watch } from './bundle.mjs';
3
- import 'webpack';
@@ -1,3 +0,0 @@
1
- export * from './startServer.mjs';
2
- export * from './bundle.mjs';
3
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/scripts/index.ts"],"sourcesContent":["export * from './startServer';\nexport * from './bundle';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;","names":[]}
@@ -1,5 +0,0 @@
1
- import { Compiler } from 'webpack';
2
-
3
- declare const startServer: (compiler: Compiler) => void;
4
-
5
- export { startServer };
@@ -1,12 +0,0 @@
1
- import { devServerConfig } from '../webpack.config.mjs';
2
- const WebpackDevServer = require("webpack-dev-server");
3
- const startServer = (compiler) => {
4
- const devServer = new WebpackDevServer(devServerConfig, compiler);
5
- devServer.startCallback(() => {
6
- console.info("Webpack Dev Server is running...");
7
- });
8
- };
9
- export {
10
- startServer
11
- };
12
- //# sourceMappingURL=startServer.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/scripts/startServer.ts"],"sourcesContent":["import type { Compiler } from 'webpack';\nimport { devServerConfig } from '../webpack.config';\n\nconst WebpackDevServer = require('webpack-dev-server');\n\nexport const startServer = (compiler: Compiler) => {\n // Create a new instance of webpack-dev-server\n const devServer = new WebpackDevServer(devServerConfig, compiler);\n\n // Start the server\n devServer.startCallback(() => {\n console.info('Webpack Dev Server is running...');\n });\n};\n"],"mappings":"AACA,SAAS,uBAAuB;AAEhC,MAAM,mBAAmB,QAAQ,oBAAoB;AAE9C,MAAM,cAAc,CAAC,aAAuB;AAEjD,QAAM,YAAY,IAAI,iBAAiB,iBAAiB,QAAQ;AAGhE,YAAU,cAAc,MAAM;AAC5B,YAAQ,KAAK,kCAAkC;AAAA,EACjD,CAAC;AACH;","names":[]}
@@ -1,6 +0,0 @@
1
- /**
2
- * This function generates a list of dictionaries in the main directory
3
- */
4
- declare const createDictionaryList: () => void;
5
-
6
- export { createDictionaryList };
@@ -1,52 +0,0 @@
1
- import { existsSync, mkdirSync, writeFileSync } from "fs";
2
- import { basename, extname, relative, resolve } from "path";
3
- import { getConfiguration } from "@intlayer/config";
4
- import { sync } from "glob";
5
- import { getFileHash } from '../../utils.mjs';
6
- const { content } = getConfiguration();
7
- const { dictionariesDir, mainDir } = content;
8
- const generateDictionaryListContent = (dictionaries, format = "esm") => {
9
- let content2 = "";
10
- const dictionariesRef = dictionaries.map((dictionaryPath) => ({
11
- relativePath: relative(mainDir, dictionaryPath),
12
- id: basename(dictionaryPath, extname(dictionaryPath)),
13
- // Get the base name as the dictionary id
14
- hash: `_${getFileHash(dictionaryPath)}`
15
- // Get the hash of the dictionary to avoid conflicts
16
- }));
17
- dictionariesRef.forEach((dictionary) => {
18
- if (format === "esm")
19
- content2 += `import ${dictionary.hash} from '${dictionary.relativePath}';
20
- `;
21
- if (format === "cjs")
22
- content2 += `const ${dictionary.hash} = require('${dictionary.relativePath}');
23
- `;
24
- });
25
- content2 += "\n";
26
- const formattedDictionaryMap = dictionariesRef.map((dictionary) => `"${dictionary.id}": ${dictionary.hash}`).join(",\n");
27
- if (format === "esm")
28
- content2 += `export default {
29
- ${formattedDictionaryMap}
30
- };
31
- `;
32
- if (format === "cjs")
33
- content2 += `module.exports = {
34
- ${formattedDictionaryMap}
35
- };
36
- `;
37
- return content2;
38
- };
39
- const createDictionaryList = () => {
40
- if (!existsSync(mainDir)) {
41
- mkdirSync(mainDir, { recursive: true });
42
- }
43
- const dictionaries = sync(`${dictionariesDir}/**/*.json`);
44
- const cjsContent = generateDictionaryListContent(dictionaries, "cjs");
45
- writeFileSync(resolve(mainDir, "dictionaries.cjs"), cjsContent);
46
- const esmContent = generateDictionaryListContent(dictionaries, "esm");
47
- writeFileSync(resolve(mainDir, "dictionaries.mjs"), esmContent);
48
- };
49
- export {
50
- createDictionaryList
51
- };
52
- //# sourceMappingURL=createDictionaryList.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/transpiler/dictionary_to_main/createDictionaryList.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { basename, extname, relative, resolve } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport { sync } from 'glob';\nimport { getFileHash } from '../../utils';\n\nconst { content } = getConfiguration();\nconst { dictionariesDir, mainDir } = content;\n\n/**\n * This function generates the content of the dictionary list file\n */\nconst generateDictionaryListContent = (\n dictionaries: string[],\n format: 'cjs' | 'esm' = 'esm'\n): string => {\n let content = '';\n\n const dictionariesRef = dictionaries.map((dictionaryPath) => ({\n relativePath: relative(mainDir, dictionaryPath),\n id: basename(dictionaryPath, extname(dictionaryPath)), // Get the base name as the dictionary id\n hash: `_${getFileHash(dictionaryPath)}`, // Get the hash of the dictionary to avoid conflicts\n }));\n\n // Import all dictionaries\n dictionariesRef.forEach((dictionary) => {\n if (format === 'esm')\n content += `import ${dictionary.hash} from '${dictionary.relativePath}';\\n`;\n if (format === 'cjs')\n content += `const ${dictionary.hash} = require('${dictionary.relativePath}');\\n`;\n });\n\n content += '\\n';\n\n // Format Dictionary Map\n const formattedDictionaryMap: string = dictionariesRef\n .map((dictionary) => `\"${dictionary.id}\": ${dictionary.hash}`)\n .join(',\\n');\n\n if (format === 'esm')\n content += `export default {\\n${formattedDictionaryMap}\\n};\\n`;\n if (format === 'cjs')\n content += `module.exports = {\\n${formattedDictionaryMap}\\n};\\n`;\n\n return content;\n};\n\n/**\n * This function generates a list of dictionaries in the main directory\n */\nexport const createDictionaryList = () => {\n // Create main directory if it doesn't exist\n if (!existsSync(mainDir)) {\n mkdirSync(mainDir, { recursive: true });\n }\n\n const dictionaries: string[] = sync(`${dictionariesDir}/**/*.json`);\n\n // Create the dictionary list file\n const cjsContent = generateDictionaryListContent(dictionaries, 'cjs');\n writeFileSync(resolve(mainDir, 'dictionaries.cjs'), cjsContent);\n\n const esmContent = generateDictionaryListContent(dictionaries, 'esm');\n writeFileSync(resolve(mainDir, 'dictionaries.mjs'), esmContent);\n};\n"],"mappings":"AAAA,SAAS,YAAY,WAAW,qBAAqB;AACrD,SAAS,UAAU,SAAS,UAAU,eAAe;AACrD,SAAS,wBAAwB;AACjC,SAAS,YAAY;AACrB,SAAS,mBAAmB;AAE5B,MAAM,EAAE,QAAQ,IAAI,iBAAiB;AACrC,MAAM,EAAE,iBAAiB,QAAQ,IAAI;AAKrC,MAAM,gCAAgC,CACpC,cACA,SAAwB,UACb;AACX,MAAIA,WAAU;AAEd,QAAM,kBAAkB,aAAa,IAAI,CAAC,oBAAoB;AAAA,IAC5D,cAAc,SAAS,SAAS,cAAc;AAAA,IAC9C,IAAI,SAAS,gBAAgB,QAAQ,cAAc,CAAC;AAAA;AAAA,IACpD,MAAM,IAAI,YAAY,cAAc,CAAC;AAAA;AAAA,EACvC,EAAE;AAGF,kBAAgB,QAAQ,CAAC,eAAe;AACtC,QAAI,WAAW;AACb,MAAAA,YAAW,UAAU,WAAW,IAAI,UAAU,WAAW,YAAY;AAAA;AACvE,QAAI,WAAW;AACb,MAAAA,YAAW,SAAS,WAAW,IAAI,eAAe,WAAW,YAAY;AAAA;AAAA,EAC7E,CAAC;AAED,EAAAA,YAAW;AAGX,QAAM,yBAAiC,gBACpC,IAAI,CAAC,eAAe,IAAI,WAAW,EAAE,MAAM,WAAW,IAAI,EAAE,EAC5D,KAAK,KAAK;AAEb,MAAI,WAAW;AACb,IAAAA,YAAW;AAAA,EAAqB,sBAAsB;AAAA;AAAA;AACxD,MAAI,WAAW;AACb,IAAAA,YAAW;AAAA,EAAuB,sBAAsB;AAAA;AAAA;AAE1D,SAAOA;AACT;AAKO,MAAM,uBAAuB,MAAM;AAExC,MAAI,CAAC,WAAW,OAAO,GAAG;AACxB,cAAU,SAAS,EAAE,WAAW,KAAK,CAAC;AAAA,EACxC;AAEA,QAAM,eAAyB,KAAK,GAAG,eAAe,YAAY;AAGlE,QAAM,aAAa,8BAA8B,cAAc,KAAK;AACpE,gBAAc,QAAQ,SAAS,kBAAkB,GAAG,UAAU;AAE9D,QAAM,aAAa,8BAA8B,cAAc,KAAK;AACpE,gBAAc,QAAQ,SAAS,kBAAkB,GAAG,UAAU;AAChE;","names":["content"]}
@@ -1 +0,0 @@
1
- export { createDictionaryList } from './createDictionaryList.mjs';
@@ -1,2 +0,0 @@
1
- export * from './createDictionaryList.mjs';
2
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/transpiler/dictionary_to_main/index.ts"],"sourcesContent":["export * from './createDictionaryList';\n"],"mappings":"AAAA,cAAc;","names":[]}
@@ -1,7 +0,0 @@
1
- declare const getTypeName: (id: string) => string;
2
- /**
3
- * This function generates a index file merging all the types
4
- */
5
- declare const createModuleAugmentation: () => void;
6
-
7
- export { createModuleAugmentation, getTypeName };
@@ -1,62 +0,0 @@
1
- import { existsSync, mkdirSync, writeFileSync } from "fs";
2
- import { basename, join, relative } from "path";
3
- import { Locales, getConfiguration } from "@intlayer/config";
4
- import { sync } from "glob";
5
- import { getFileHash, transformToCamelCase } from '../../utils.mjs';
6
- const { content, internationalization } = getConfiguration();
7
- const { typesDir, moduleAugmentationDir } = content;
8
- const { locales } = internationalization;
9
- const getTypeName = (id) => transformToCamelCase(`${id}Content`);
10
- const generateTypeIndexContent = (typeFiles) => {
11
- let content2 = "/* eslint-disable */\nimport 'intlayer';\nimport { Locales } from '@intlayer/config'\n";
12
- const dictionariesRef = typeFiles.map((dictionaryPath) => ({
13
- relativePath: relative(moduleAugmentationDir, dictionaryPath),
14
- id: basename(dictionaryPath, ".d.ts"),
15
- // Get the base name as the dictionary id
16
- hash: `_${getFileHash(dictionaryPath)}`
17
- // Get the hash of the dictionary to avoid conflicts
18
- }));
19
- dictionariesRef.forEach((dictionary) => {
20
- const typeName = getTypeName(dictionary.id);
21
- content2 += `import type { ${typeName} as ${dictionary.hash} } from '${dictionary.relativePath}';
22
- `;
23
- });
24
- content2 += "\n";
25
- const formattedDictionaryMap = dictionariesRef.map((dictionary) => ` "${dictionary.id}": ${dictionary.hash};`).join("\n");
26
- const formatLocales = locales.map((locale) => {
27
- for (const key in Locales) {
28
- if (Locales[key] === locale) {
29
- return ` ${key} = '${locale}'`;
30
- }
31
- }
32
- }).join(",\n");
33
- content2 += `declare module 'intlayer' {
34
- `;
35
- content2 += ` interface IntlayerDictionaryTypesConnector {
36
- ${formattedDictionaryMap}
37
- }
38
-
39
- `;
40
- content2 += ` enum ConfigLocales {
41
- ${formatLocales}
42
- };
43
-
44
- `;
45
- content2 += ` interface IConfigLocales<Content> extends Record<ConfigLocales, Content> {}
46
- `;
47
- content2 += `};`;
48
- return content2;
49
- };
50
- const createModuleAugmentation = () => {
51
- if (!existsSync(moduleAugmentationDir)) {
52
- mkdirSync(moduleAugmentationDir, { recursive: true });
53
- }
54
- const dictionaries = sync(`${typesDir}/**/*.d.ts`);
55
- const tsContent = generateTypeIndexContent(dictionaries);
56
- writeFileSync(join(moduleAugmentationDir, "intlayer.d.ts"), tsContent);
57
- };
58
- export {
59
- createModuleAugmentation,
60
- getTypeName
61
- };
62
- //# sourceMappingURL=createModuleAugmentation.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/transpiler/dictionary_to_type/createModuleAugmentation.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { basename, join, relative } from 'path';\nimport { Locales, getConfiguration } from '@intlayer/config';\nimport { sync } from 'glob';\nimport { getFileHash, transformToCamelCase } from '../../utils';\n\nconst { content, internationalization } = getConfiguration();\nconst { typesDir, moduleAugmentationDir } = content;\nconst { locales } = internationalization;\n\nexport const getTypeName = (id: string): string =>\n transformToCamelCase(`${id}Content`);\n\n/**\n * This function generates the content of the module augmentation file\n */\nconst generateTypeIndexContent = (typeFiles: string[]): string => {\n let content =\n \"/* eslint-disable */\\nimport 'intlayer';\\nimport { Locales } from '@intlayer/config'\\n\";\n\n const dictionariesRef = typeFiles.map((dictionaryPath) => ({\n relativePath: relative(moduleAugmentationDir, dictionaryPath),\n id: basename(dictionaryPath, '.d.ts'), // Get the base name as the dictionary id\n hash: `_${getFileHash(dictionaryPath)}`, // Get the hash of the dictionary to avoid conflicts\n }));\n\n // Import all dictionaries\n dictionariesRef.forEach((dictionary) => {\n const typeName = getTypeName(dictionary.id);\n content += `import type { ${typeName} as ${dictionary.hash} } from '${dictionary.relativePath}';\\n`;\n });\n\n content += '\\n';\n\n // Format Dictionary Map\n const formattedDictionaryMap: string = dictionariesRef\n .map((dictionary) => ` \"${dictionary.id}\": ${dictionary.hash};`)\n .join('\\n');\n\n const formatLocales = locales\n .map((locale) => {\n for (const key in Locales) {\n if (Locales[key as keyof typeof Locales] === locale) {\n return ` ${key} = '${locale}'`;\n }\n }\n })\n .join(',\\n');\n\n /**\n * Write the module augmentation to extend the intlayer module with the dictionaries types\n * Will suggest the type resulting of the dictionaries\n *\n * declare module 'intlayer' {\n * interface IntlayerDictionaryTypesConnector = {\n * dictionaries: {\n * id: DictionaryType;\n * }\n * }\n *\n * enum ConfigLocales {\n * ENGLISH = 'en',\n * FRENCH = 'fr',\n * SPANISH = 'es',\n * }\n *\n * interface IConfigLocales<Content> extends Record<ConfigLocales, Content> {}\n *\n * }\n * See https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation\n */\n content += `declare module 'intlayer' {\\n`;\n content += ` interface IntlayerDictionaryTypesConnector {\\n${formattedDictionaryMap}\\n }\\n\\n`;\n content += ` enum ConfigLocales {\\n${formatLocales}\\n };\\n\\n`;\n content += ` interface IConfigLocales<Content> extends Record<ConfigLocales, Content> {}\\n`;\n content += `};`;\n\n return content;\n};\n\n/**\n * This function generates a index file merging all the types\n */\nexport const createModuleAugmentation = () => {\n // Create main directory if it doesn't exist\n if (!existsSync(moduleAugmentationDir)) {\n mkdirSync(moduleAugmentationDir, { recursive: true });\n }\n\n const dictionaries: string[] = sync(`${typesDir}/**/*.d.ts`);\n // Create the dictionary list file\n\n const tsContent = generateTypeIndexContent(dictionaries);\n writeFileSync(join(moduleAugmentationDir, 'intlayer.d.ts'), tsContent);\n};\n"],"mappings":"AAAA,SAAS,YAAY,WAAW,qBAAqB;AACrD,SAAS,UAAU,MAAM,gBAAgB;AACzC,SAAS,SAAS,wBAAwB;AAC1C,SAAS,YAAY;AACrB,SAAS,aAAa,4BAA4B;AAElD,MAAM,EAAE,SAAS,qBAAqB,IAAI,iBAAiB;AAC3D,MAAM,EAAE,UAAU,sBAAsB,IAAI;AAC5C,MAAM,EAAE,QAAQ,IAAI;AAEb,MAAM,cAAc,CAAC,OAC1B,qBAAqB,GAAG,EAAE,SAAS;AAKrC,MAAM,2BAA2B,CAAC,cAAgC;AAChE,MAAIA,WACF;AAEF,QAAM,kBAAkB,UAAU,IAAI,CAAC,oBAAoB;AAAA,IACzD,cAAc,SAAS,uBAAuB,cAAc;AAAA,IAC5D,IAAI,SAAS,gBAAgB,OAAO;AAAA;AAAA,IACpC,MAAM,IAAI,YAAY,cAAc,CAAC;AAAA;AAAA,EACvC,EAAE;AAGF,kBAAgB,QAAQ,CAAC,eAAe;AACtC,UAAM,WAAW,YAAY,WAAW,EAAE;AAC1C,IAAAA,YAAW,iBAAiB,QAAQ,OAAO,WAAW,IAAI,YAAY,WAAW,YAAY;AAAA;AAAA,EAC/F,CAAC;AAED,EAAAA,YAAW;AAGX,QAAM,yBAAiC,gBACpC,IAAI,CAAC,eAAe,QAAQ,WAAW,EAAE,MAAM,WAAW,IAAI,GAAG,EACjE,KAAK,IAAI;AAEZ,QAAM,gBAAgB,QACnB,IAAI,CAAC,WAAW;AACf,eAAW,OAAO,SAAS;AACzB,UAAI,QAAQ,GAA2B,MAAM,QAAQ;AACnD,eAAO,OAAO,GAAG,OAAO,MAAM;AAAA,MAChC;AAAA,IACF;AAAA,EACF,CAAC,EACA,KAAK,KAAK;AAwBb,EAAAA,YAAW;AAAA;AACX,EAAAA,YAAW;AAAA,EAAmD,sBAAsB;AAAA;AAAA;AAAA;AACpF,EAAAA,YAAW;AAAA,EAA2B,aAAa;AAAA;AAAA;AAAA;AACnD,EAAAA,YAAW;AAAA;AACX,EAAAA,YAAW;AAEX,SAAOA;AACT;AAKO,MAAM,2BAA2B,MAAM;AAE5C,MAAI,CAAC,WAAW,qBAAqB,GAAG;AACtC,cAAU,uBAAuB,EAAE,WAAW,KAAK,CAAC;AAAA,EACtD;AAEA,QAAM,eAAyB,KAAK,GAAG,QAAQ,YAAY;AAG3D,QAAM,YAAY,yBAAyB,YAAY;AACvD,gBAAc,KAAK,uBAAuB,eAAe,GAAG,SAAS;AACvE;","names":["content"]}