@intlayer/webpack 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/cjs/index.cjs +16 -21
  2. package/dist/cjs/index.d.ts +6 -0
  3. package/dist/cjs/scripts/bundle.cjs +17 -20
  4. package/dist/cjs/scripts/bundle.d.ts +7 -0
  5. package/dist/cjs/scripts/index.cjs +11 -19
  6. package/dist/cjs/scripts/index.d.ts +3 -0
  7. package/dist/cjs/scripts/startServer.cjs +10 -18
  8. package/dist/cjs/scripts/startServer.d.ts +5 -0
  9. package/dist/cjs/transpiler/dictionary_to_main/createDictionaryList.cjs +14 -30
  10. package/dist/cjs/transpiler/dictionary_to_main/createDictionaryList.d.ts +6 -0
  11. package/dist/cjs/transpiler/dictionary_to_main/index.cjs +9 -21
  12. package/dist/cjs/transpiler/dictionary_to_main/index.d.ts +1 -0
  13. package/dist/cjs/transpiler/dictionary_to_type/createModuleAugmentation.cjs +37 -33
  14. package/dist/cjs/transpiler/dictionary_to_type/createModuleAugmentation.cjs.map +1 -1
  15. package/dist/cjs/transpiler/dictionary_to_type/createModuleAugmentation.d.ts +7 -0
  16. package/dist/cjs/transpiler/dictionary_to_type/createType.cjs +16 -28
  17. package/dist/cjs/transpiler/dictionary_to_type/createType.d.ts +42 -0
  18. package/dist/cjs/transpiler/dictionary_to_type/index.cjs +11 -27
  19. package/dist/cjs/transpiler/dictionary_to_type/index.d.ts +3 -0
  20. package/dist/cjs/transpiler/intlater_module_to_dictionary/extractNestedJSON.cjs +8 -13
  21. package/dist/cjs/transpiler/intlater_module_to_dictionary/extractNestedJSON.d.ts +44 -0
  22. package/dist/cjs/transpiler/intlater_module_to_dictionary/index.cjs +13 -33
  23. package/dist/cjs/transpiler/intlater_module_to_dictionary/index.d.ts +4 -0
  24. package/dist/cjs/transpiler/intlater_module_to_dictionary/processModule.cjs +11 -14
  25. package/dist/cjs/transpiler/intlater_module_to_dictionary/processModule.d.ts +8 -0
  26. package/dist/cjs/transpiler/intlater_module_to_dictionary/transpileBundledCode.cjs +14 -30
  27. package/dist/cjs/transpiler/intlater_module_to_dictionary/transpileBundledCode.d.ts +6 -0
  28. package/dist/cjs/utils.cjs +10 -18
  29. package/dist/cjs/utils.d.ts +4 -0
  30. package/dist/cjs/webpack-plugin.cjs +21 -40
  31. package/dist/cjs/webpack-plugin.d.ts +15 -0
  32. package/dist/cjs/webpack.config.cjs +34 -47
  33. package/dist/cjs/webpack.config.d.ts +7 -0
  34. package/dist/esm/index.d.mts +6 -9
  35. package/dist/esm/index.mjs +5 -5
  36. package/dist/esm/scripts/bundle.d.mts +2 -2
  37. package/dist/esm/scripts/bundle.mjs +13 -8
  38. package/dist/esm/scripts/index.d.mts +3 -3
  39. package/dist/esm/scripts/index.mjs +3 -3
  40. package/dist/esm/scripts/startServer.d.mts +1 -1
  41. package/dist/esm/scripts/startServer.mjs +5 -3
  42. package/dist/esm/transpiler/dictionary_to_main/createDictionaryList.mjs +7 -7
  43. package/dist/esm/transpiler/dictionary_to_main/index.d.mts +1 -1
  44. package/dist/esm/transpiler/dictionary_to_main/index.mjs +2 -2
  45. package/dist/esm/transpiler/dictionary_to_type/createModuleAugmentation.mjs +31 -12
  46. package/dist/esm/transpiler/dictionary_to_type/createModuleAugmentation.mjs.map +1 -1
  47. package/dist/esm/transpiler/dictionary_to_type/createType.d.mts +1 -1
  48. package/dist/esm/transpiler/dictionary_to_type/createType.mjs +14 -12
  49. package/dist/esm/transpiler/dictionary_to_type/index.d.mts +3 -10
  50. package/dist/esm/transpiler/dictionary_to_type/index.mjs +3 -3
  51. package/dist/esm/transpiler/intlater_module_to_dictionary/extractNestedJSON.d.mts +1 -1
  52. package/dist/esm/transpiler/intlater_module_to_dictionary/extractNestedJSON.mjs +4 -2
  53. package/dist/esm/transpiler/intlater_module_to_dictionary/index.d.mts +4 -4
  54. package/dist/esm/transpiler/intlater_module_to_dictionary/index.mjs +4 -4
  55. package/dist/esm/transpiler/intlater_module_to_dictionary/processModule.d.mts +2 -4
  56. package/dist/esm/transpiler/intlater_module_to_dictionary/processModule.mjs +7 -3
  57. package/dist/esm/transpiler/intlater_module_to_dictionary/transpileBundledCode.d.mts +1 -3
  58. package/dist/esm/transpiler/intlater_module_to_dictionary/transpileBundledCode.mjs +6 -4
  59. package/dist/esm/utils.mjs +6 -6
  60. package/dist/esm/webpack-plugin.d.mts +10 -10
  61. package/dist/esm/webpack-plugin.mjs +16 -20
  62. package/dist/esm/webpack.config.d.mts +2 -2
  63. package/dist/esm/webpack.config.mjs +29 -23
  64. package/package.json +7 -7
  65. package/src/transpiler/dictionary_to_type/createModuleAugmentation.ts +30 -5
@@ -0,0 +1,42 @@
1
+ import { ContentModule, Content } from '@intlayer/core';
2
+
3
+ /**
4
+ *
5
+ * This function generates a TypeScript type definition from a JSON object
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
+ * }
17
+ * };
18
+ *
19
+ * const result = generateTypeScriptType(input, 'RootObject');
20
+ * console.log(result);
21
+ *
22
+ * Output:
23
+ *
24
+ * type RootObject = {
25
+ * id: '1',
26
+ * name: string,
27
+ * address: {
28
+ * id: '2',
29
+ * street: string,
30
+ * city: string,
31
+ * },
32
+ * };
33
+ *
34
+ */
35
+ declare const generateTypeScriptType: (obj: ContentModule) => string;
36
+ declare const generateTypeScriptTypeContent: (obj: Content) => string;
37
+ /**
38
+ * This function generates a TypeScript type definition from a JSON object
39
+ */
40
+ declare const createTypes: (dictionariesPaths: string[]) => string[];
41
+
42
+ export { createTypes, generateTypeScriptType, generateTypeScriptTypeContent };
@@ -4,38 +4,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
6
  var __copyProps = (to, from, except, desc) => {
7
- if ((from && typeof from === "object") || typeof from === "function") {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
8
  for (let key of __getOwnPropNames(from))
9
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
- });
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
11
  }
15
12
  return to;
16
13
  };
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);
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);
23
16
  var dictionary_to_type_exports = {};
24
17
  module.exports = __toCommonJS(dictionary_to_type_exports);
25
- __reExport(
26
- dictionary_to_type_exports,
27
- require("./createModuleAugmentation.cjs"),
28
- module.exports
29
- );
30
- __reExport(
31
- dictionary_to_type_exports,
32
- require("./createType.cjs"),
33
- module.exports
34
- );
18
+ __reExport(dictionary_to_type_exports, require('./createModuleAugmentation.cjs'), module.exports);
19
+ __reExport(dictionary_to_type_exports, require('./createType.cjs'), module.exports);
35
20
  // Annotate the CommonJS export names for ESM import in node:
36
- 0 &&
37
- (module.exports = {
38
- ...require("./createModuleAugmentation.cjs"),
39
- ...require("./createType.cjs"),
40
- });
41
- //# sourceMappingURL=index.cjs.map
21
+ 0 && (module.exports = {
22
+ ...require('./createModuleAugmentation.cjs'),
23
+ ...require('./createType.cjs')
24
+ });
25
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1,3 @@
1
+ export { createModuleAugmentation, getTypeName } from './createModuleAugmentation.js';
2
+ export { createTypes, generateTypeScriptType, generateTypeScriptTypeContent } from './createType.js';
3
+ import '@intlayer/core';
@@ -8,21 +8,17 @@ var __export = (target, all) => {
8
8
  __defProp(target, name, { get: all[name], enumerable: true });
9
9
  };
10
10
  var __copyProps = (to, from, except, desc) => {
11
- if ((from && typeof from === "object") || typeof from === "function") {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
12
  for (let key of __getOwnPropNames(from))
13
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
- });
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
15
  }
19
16
  return to;
20
17
  };
21
- var __toCommonJS = (mod) =>
22
- __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
19
  var extractNestedJSON_exports = {};
24
20
  __export(extractNestedJSON_exports, {
25
- extractObjectsWithId: () => extractObjectsWithId,
21
+ extractObjectsWithId: () => extractObjectsWithId
26
22
  });
27
23
  module.exports = __toCommonJS(extractNestedJSON_exports);
28
24
  const extractObjectsWithId = (input) => {
@@ -43,8 +39,7 @@ const extractObjectsWithId = (input) => {
43
39
  return results;
44
40
  };
45
41
  // Annotate the CommonJS export names for ESM import in node:
46
- 0 &&
47
- (module.exports = {
48
- extractObjectsWithId,
49
- });
50
- //# sourceMappingURL=extractNestedJSON.cjs.map
42
+ 0 && (module.exports = {
43
+ extractObjectsWithId
44
+ });
45
+ //# sourceMappingURL=extractNestedJSON.cjs.map
@@ -0,0 +1,44 @@
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 };
@@ -4,44 +4,24 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
6
  var __copyProps = (to, from, except, desc) => {
7
- if ((from && typeof from === "object") || typeof from === "function") {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
8
  for (let key of __getOwnPropNames(from))
9
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
- });
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
11
  }
15
12
  return to;
16
13
  };
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);
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);
23
16
  var intlater_module_to_dictionary_exports = {};
24
17
  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
- );
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);
40
21
  // 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
22
+ 0 && (module.exports = {
23
+ ...require('./extractNestedJSON.cjs'),
24
+ ...require('./processModule.cjs'),
25
+ ...require('./transpileBundledCode.cjs')
26
+ });
27
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1,4 @@
1
+ export { extractObjectsWithId } from './extractNestedJSON.js';
2
+ export { processModule } from './processModule.js';
3
+ export { transpileBundledCode } from './transpileBundledCode.js';
4
+ import '@intlayer/core';
@@ -8,21 +8,17 @@ var __export = (target, all) => {
8
8
  __defProp(target, name, { get: all[name], enumerable: true });
9
9
  };
10
10
  var __copyProps = (to, from, except, desc) => {
11
- if ((from && typeof from === "object") || typeof from === "function") {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
12
  for (let key of __getOwnPropNames(from))
13
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
- });
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
15
  }
19
16
  return to;
20
17
  };
21
- var __toCommonJS = (mod) =>
22
- __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
19
  var processModule_exports = {};
24
20
  __export(processModule_exports, {
25
- processModule: () => processModule,
21
+ processModule: () => processModule
26
22
  });
27
23
  module.exports = __toCommonJS(processModule_exports);
28
24
  var import_path = require("path");
@@ -36,7 +32,9 @@ const processFunctionResults = async (entry) => {
36
32
  for (const key of Object.keys(entry)) {
37
33
  const field = entry?.[key];
38
34
  if (typeof field === "object") {
39
- result[key] = await processFunctionResults(field);
35
+ result[key] = await processFunctionResults(
36
+ field
37
+ );
40
38
  }
41
39
  if (typeof field === "function") {
42
40
  const promise = (async () => {
@@ -63,8 +61,7 @@ const processModule = async (file) => {
63
61
  }
64
62
  };
65
63
  // Annotate the CommonJS export names for ESM import in node:
66
- 0 &&
67
- (module.exports = {
68
- processModule,
69
- });
70
- //# sourceMappingURL=processModule.cjs.map
64
+ 0 && (module.exports = {
65
+ processModule
66
+ });
67
+ //# sourceMappingURL=processModule.cjs.map
@@ -0,0 +1,8 @@
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 };
@@ -8,29 +8,25 @@ var __export = (target, all) => {
8
8
  __defProp(target, name, { get: all[name], enumerable: true });
9
9
  };
10
10
  var __copyProps = (to, from, except, desc) => {
11
- if ((from && typeof from === "object") || typeof from === "function") {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
12
  for (let key of __getOwnPropNames(from))
13
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
- });
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
15
  }
19
16
  return to;
20
17
  };
21
- var __toCommonJS = (mod) =>
22
- __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
19
  var transpileBundledCode_exports = {};
24
20
  __export(transpileBundledCode_exports, {
25
- transpileBundledCode: () => transpileBundledCode,
21
+ transpileBundledCode: () => transpileBundledCode
26
22
  });
27
23
  module.exports = __toCommonJS(transpileBundledCode_exports);
28
24
  var import_fs = require("fs");
29
25
  var import_promises = require("fs/promises");
30
26
  var import_path = require("path");
31
27
  var import_config = require("@intlayer/config");
32
- var import_extractNestedJSON = require("./extractNestedJSON.cjs");
33
- var import_processModule = require("./processModule.cjs");
28
+ var import_extractNestedJSON = require('./extractNestedJSON.cjs');
29
+ var import_processModule = require('./processModule.cjs');
34
30
  const { content } = (0, import_config.getConfiguration)();
35
31
  const { dictionariesDir, bundleFileExtension } = content;
36
32
  const loadBundledModule = async (bundledEntryPath) => {
@@ -64,15 +60,8 @@ const buildDictionary = async (dictionaries) => {
64
60
  const contentString = JSON.stringify(content2);
65
61
  const id = content2.id;
66
62
  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) => {
63
+ const resultFilePath = (0, import_path.resolve)(dictionariesDir, outputFileName);
64
+ await (0, import_promises.writeFile)(resultFilePath, contentString, "utf8").catch((err) => {
76
65
  console.error(`Error creating ${outputFileName}:`, err);
77
66
  });
78
67
  resultDictionariesPaths.push(resultFilePath);
@@ -88,25 +77,20 @@ const transpileBundledCode = async (bundledEntriesPaths) => {
88
77
  // Filter js files;
89
78
  (bundledEntryPath) => bundledEntryPath.endsWith(bundleFileExtension)
90
79
  );
91
- await (0, import_promises.mkdir)((0, import_path.resolve)(dictionariesDir), {
92
- recursive: true,
93
- });
80
+ await (0, import_promises.mkdir)((0, import_path.resolve)(dictionariesDir), { recursive: true });
94
81
  for await (const bundledEntryPath of filteredBundledEntriesPaths) {
95
82
  const result = await loadBundledModule(bundledEntryPath);
96
83
  if (!result) {
97
84
  continue;
98
85
  }
99
- const nestedContent = (0, import_extractNestedJSON.extractObjectsWithId)(
100
- result
101
- );
86
+ const nestedContent = (0, import_extractNestedJSON.extractObjectsWithId)(result);
102
87
  const dictionariesPaths = await buildDictionary(nestedContent);
103
88
  resultDictionariesPaths.push(...dictionariesPaths);
104
89
  }
105
90
  return resultDictionariesPaths;
106
91
  };
107
92
  // Annotate the CommonJS export names for ESM import in node:
108
- 0 &&
109
- (module.exports = {
110
- transpileBundledCode,
111
- });
112
- //# sourceMappingURL=transpileBundledCode.cjs.map
93
+ 0 && (module.exports = {
94
+ transpileBundledCode
95
+ });
96
+ //# sourceMappingURL=transpileBundledCode.cjs.map
@@ -0,0 +1,6 @@
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 };
@@ -8,31 +8,24 @@ var __export = (target, all) => {
8
8
  __defProp(target, name, { get: all[name], enumerable: true });
9
9
  };
10
10
  var __copyProps = (to, from, except, desc) => {
11
- if ((from && typeof from === "object") || typeof from === "function") {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
12
  for (let key of __getOwnPropNames(from))
13
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
- });
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
15
  }
19
16
  return to;
20
17
  };
21
- var __toCommonJS = (mod) =>
22
- __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
19
  var utils_exports = {};
24
20
  __export(utils_exports, {
25
21
  getFileHash: () => getFileHash,
26
- transformToCamelCase: () => transformToCamelCase,
22
+ transformToCamelCase: () => transformToCamelCase
27
23
  });
28
24
  module.exports = __toCommonJS(utils_exports);
29
25
  var import_crypto_js = require("crypto-js");
30
26
  const getFileHash = (filePath) => {
31
27
  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);
28
+ return hash.toString(import_crypto_js.enc.Base64).replace(/[^A-Z\d]/gi, "").substring(0, 20);
36
29
  };
37
30
  const transformToCamelCase = (string) => {
38
31
  const words = string.split(/[\s\-_]+/);
@@ -45,9 +38,8 @@ const transformToCamelCase = (string) => {
45
38
  return camelCasedWords.join("");
46
39
  };
47
40
  // 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
41
+ 0 && (module.exports = {
42
+ getFileHash,
43
+ transformToCamelCase
44
+ });
45
+ //# sourceMappingURL=utils.cjs.map
@@ -0,0 +1,4 @@
1
+ declare const getFileHash: (filePath: string) => string;
2
+ declare const transformToCamelCase: (string: string) => string;
3
+
4
+ export { getFileHash, transformToCamelCase };
@@ -8,41 +8,35 @@ var __export = (target, all) => {
8
8
  __defProp(target, name, { get: all[name], enumerable: true });
9
9
  };
10
10
  var __copyProps = (to, from, except, desc) => {
11
- if ((from && typeof from === "object") || typeof from === "function") {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
12
  for (let key of __getOwnPropNames(from))
13
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
- });
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
15
  }
19
16
  return to;
20
17
  };
21
- var __toCommonJS = (mod) =>
22
- __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
19
  var webpack_plugin_exports = {};
24
20
  __export(webpack_plugin_exports, {
25
- IntLayerPlugin: () => IntLayerPlugin,
21
+ IntLayerPlugin: () => IntLayerPlugin
26
22
  });
27
23
  module.exports = __toCommonJS(webpack_plugin_exports);
28
24
  var import_path = require("path");
29
25
  var import_config = require("@intlayer/config");
30
26
  var import_glob = require("glob");
31
27
  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);
28
+ var import_createDictionaryList = require('./transpiler/dictionary_to_main/createDictionaryList.cjs');
29
+ var import_createModuleAugmentation = require('./transpiler/dictionary_to_type/createModuleAugmentation.cjs');
30
+ var import_createType = require('./transpiler/dictionary_to_type/createType.cjs');
31
+ var import_transpileBundledCode = require('./transpiler/intlater_module_to_dictionary/transpileBundledCode.cjs');
32
+ var import_utils = require('./utils.cjs');
33
+ const getRelativePath = (filePath) => (0, import_path.relative)(baseDir, filePath);
39
34
  const getBundledFilePathFromIntlayerModule = (filePath) => {
40
35
  const hash = (0, import_utils.getFileHash)(filePath);
41
36
  return `${bundleDir}/${hash}${bundleFileExtension}`;
42
37
  };
43
38
  const { content } = (0, import_config.getConfiguration)();
44
- const { bundleDir, baseDir, bundleFileExtension, watchedFilesPatternWithPath } =
45
- content;
39
+ const { bundleDir, baseDir, bundleFileExtension, watchedFilesPatternWithPath } = content;
46
40
  class IntLayerPlugin {
47
41
  managedFiles;
48
42
  updatedFiles;
@@ -54,13 +48,10 @@ class IntLayerPlugin {
54
48
  }
55
49
  // function to initialize the dictionaries
56
50
  async initDictionaries() {
57
- const outputFiles = [...this.managedFiles].map((file) =>
58
- (0, import_path.resolve)(bundleDir, file)
51
+ const outputFiles = [...this.managedFiles].map(
52
+ (file) => (0, import_path.resolve)(bundleDir, file)
59
53
  );
60
- const dictionaries =
61
- (await (0, import_transpileBundledCode.transpileBundledCode)(
62
- outputFiles
63
- )) ?? [];
54
+ const dictionaries = await (0, import_transpileBundledCode.transpileBundledCode)(outputFiles) ?? [];
64
55
  console.info(
65
56
  `Dictionaries:
66
57
  ${dictionaries.map(getRelativePath).join("\n")}`
@@ -74,10 +65,7 @@ class IntLayerPlugin {
74
65
  }
75
66
  // function to process when intlayer module files content are changed
76
67
  async processFilesChanges() {
77
- const dictionaries =
78
- (await (0, import_transpileBundledCode.transpileBundledCode)([
79
- ...this.updatedFiles,
80
- ])) ?? [];
68
+ const dictionaries = await (0, import_transpileBundledCode.transpileBundledCode)([...this.updatedFiles]) ?? [];
81
69
  console.info(
82
70
  `Updated dictionaries:
83
71
  ${dictionaries.map(getRelativePath).join("\n")}`
@@ -88,10 +76,7 @@ class IntLayerPlugin {
88
76
  }
89
77
  // function to process when new intlayer module is detected
90
78
  async processNewFiles() {
91
- const dictionaries =
92
- (await (0, import_transpileBundledCode.transpileBundledCode)([
93
- ...this.addedFiles,
94
- ])) ?? [];
79
+ const dictionaries = await (0, import_transpileBundledCode.transpileBundledCode)([...this.addedFiles]) ?? [];
95
80
  console.info(
96
81
  `New dictionaries:
97
82
  ${dictionaries.map(getRelativePath).join("\n")}`
@@ -102,10 +87,7 @@ class IntLayerPlugin {
102
87
  (0, import_createModuleAugmentation.createModuleAugmentation)();
103
88
  console.info("Building main...");
104
89
  (0, import_createDictionaryList.createDictionaryList)();
105
- this.managedFiles = /* @__PURE__ */ new Set([
106
- ...this.managedFiles,
107
- ...this.addedFiles,
108
- ]);
90
+ this.managedFiles = /* @__PURE__ */ new Set([...this.managedFiles, ...this.addedFiles]);
109
91
  this.addedFiles.clear();
110
92
  }
111
93
  async detectFileAddedOrRemoved() {
@@ -177,8 +159,7 @@ class IntLayerPlugin {
177
159
  }
178
160
  }
179
161
  // Annotate the CommonJS export names for ESM import in node:
180
- 0 &&
181
- (module.exports = {
182
- IntLayerPlugin,
183
- });
184
- //# sourceMappingURL=webpack-plugin.cjs.map
162
+ 0 && (module.exports = {
163
+ IntLayerPlugin
164
+ });
165
+ //# sourceMappingURL=webpack-plugin.cjs.map
@@ -0,0 +1,15 @@
1
+ import { Compiler } from 'webpack';
2
+
3
+ declare class IntLayerPlugin {
4
+ private managedFiles;
5
+ private updatedFiles;
6
+ private addedFiles;
7
+ constructor();
8
+ initDictionaries(): Promise<void>;
9
+ processFilesChanges(): Promise<void>;
10
+ processNewFiles(): Promise<void>;
11
+ detectFileAddedOrRemoved(): Promise<void>;
12
+ apply(compiler: Compiler): void;
13
+ }
14
+
15
+ export { IntLayerPlugin };