@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.
- package/dist/cjs/index.cjs +16 -21
- package/dist/cjs/index.d.ts +6 -0
- package/dist/cjs/scripts/bundle.cjs +17 -20
- package/dist/cjs/scripts/bundle.d.ts +7 -0
- package/dist/cjs/scripts/index.cjs +11 -19
- package/dist/cjs/scripts/index.d.ts +3 -0
- package/dist/cjs/scripts/startServer.cjs +10 -18
- package/dist/cjs/scripts/startServer.d.ts +5 -0
- package/dist/cjs/transpiler/dictionary_to_main/createDictionaryList.cjs +14 -30
- package/dist/cjs/transpiler/dictionary_to_main/createDictionaryList.d.ts +6 -0
- package/dist/cjs/transpiler/dictionary_to_main/index.cjs +9 -21
- package/dist/cjs/transpiler/dictionary_to_main/index.d.ts +1 -0
- package/dist/cjs/transpiler/dictionary_to_type/createModuleAugmentation.cjs +37 -33
- package/dist/cjs/transpiler/dictionary_to_type/createModuleAugmentation.cjs.map +1 -1
- package/dist/cjs/transpiler/dictionary_to_type/createModuleAugmentation.d.ts +7 -0
- package/dist/cjs/transpiler/dictionary_to_type/createType.cjs +16 -28
- package/dist/cjs/transpiler/dictionary_to_type/createType.d.ts +42 -0
- package/dist/cjs/transpiler/dictionary_to_type/index.cjs +11 -27
- package/dist/cjs/transpiler/dictionary_to_type/index.d.ts +3 -0
- package/dist/cjs/transpiler/intlater_module_to_dictionary/extractNestedJSON.cjs +8 -13
- package/dist/cjs/transpiler/intlater_module_to_dictionary/extractNestedJSON.d.ts +44 -0
- package/dist/cjs/transpiler/intlater_module_to_dictionary/index.cjs +13 -33
- package/dist/cjs/transpiler/intlater_module_to_dictionary/index.d.ts +4 -0
- package/dist/cjs/transpiler/intlater_module_to_dictionary/processModule.cjs +11 -14
- package/dist/cjs/transpiler/intlater_module_to_dictionary/processModule.d.ts +8 -0
- package/dist/cjs/transpiler/intlater_module_to_dictionary/transpileBundledCode.cjs +14 -30
- package/dist/cjs/transpiler/intlater_module_to_dictionary/transpileBundledCode.d.ts +6 -0
- package/dist/cjs/utils.cjs +10 -18
- package/dist/cjs/utils.d.ts +4 -0
- package/dist/cjs/webpack-plugin.cjs +21 -40
- package/dist/cjs/webpack-plugin.d.ts +15 -0
- package/dist/cjs/webpack.config.cjs +34 -47
- package/dist/cjs/webpack.config.d.ts +7 -0
- package/dist/esm/index.d.mts +6 -9
- package/dist/esm/index.mjs +5 -5
- package/dist/esm/scripts/bundle.d.mts +2 -2
- package/dist/esm/scripts/bundle.mjs +13 -8
- package/dist/esm/scripts/index.d.mts +3 -3
- package/dist/esm/scripts/index.mjs +3 -3
- package/dist/esm/scripts/startServer.d.mts +1 -1
- package/dist/esm/scripts/startServer.mjs +5 -3
- package/dist/esm/transpiler/dictionary_to_main/createDictionaryList.mjs +7 -7
- package/dist/esm/transpiler/dictionary_to_main/index.d.mts +1 -1
- package/dist/esm/transpiler/dictionary_to_main/index.mjs +2 -2
- package/dist/esm/transpiler/dictionary_to_type/createModuleAugmentation.mjs +31 -12
- package/dist/esm/transpiler/dictionary_to_type/createModuleAugmentation.mjs.map +1 -1
- package/dist/esm/transpiler/dictionary_to_type/createType.d.mts +1 -1
- package/dist/esm/transpiler/dictionary_to_type/createType.mjs +14 -12
- package/dist/esm/transpiler/dictionary_to_type/index.d.mts +3 -10
- package/dist/esm/transpiler/dictionary_to_type/index.mjs +3 -3
- package/dist/esm/transpiler/intlater_module_to_dictionary/extractNestedJSON.d.mts +1 -1
- package/dist/esm/transpiler/intlater_module_to_dictionary/extractNestedJSON.mjs +4 -2
- package/dist/esm/transpiler/intlater_module_to_dictionary/index.d.mts +4 -4
- package/dist/esm/transpiler/intlater_module_to_dictionary/index.mjs +4 -4
- package/dist/esm/transpiler/intlater_module_to_dictionary/processModule.d.mts +2 -4
- package/dist/esm/transpiler/intlater_module_to_dictionary/processModule.mjs +7 -3
- package/dist/esm/transpiler/intlater_module_to_dictionary/transpileBundledCode.d.mts +1 -3
- package/dist/esm/transpiler/intlater_module_to_dictionary/transpileBundledCode.mjs +6 -4
- package/dist/esm/utils.mjs +6 -6
- package/dist/esm/webpack-plugin.d.mts +10 -10
- package/dist/esm/webpack-plugin.mjs +16 -20
- package/dist/esm/webpack.config.d.mts +2 -2
- package/dist/esm/webpack.config.mjs +29 -23
- package/package.json +7 -7
- 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 (
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
//# sourceMappingURL=index.cjs.map
|
|
21
|
+
0 && (module.exports = {
|
|
22
|
+
...require('./createModuleAugmentation.cjs'),
|
|
23
|
+
...require('./createType.cjs')
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -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 (
|
|
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
|
-
|
|
48
|
-
|
|
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 (
|
|
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
|
-
|
|
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
|
-
|
|
27
|
-
|
|
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
|
-
(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
|
@@ -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 (
|
|
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(
|
|
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
|
-
|
|
68
|
-
|
|
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 (
|
|
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(
|
|
33
|
-
var import_processModule = require(
|
|
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
|
-
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
//# sourceMappingURL=transpileBundledCode.cjs.map
|
|
93
|
+
0 && (module.exports = {
|
|
94
|
+
transpileBundledCode
|
|
95
|
+
});
|
|
96
|
+
//# sourceMappingURL=transpileBundledCode.cjs.map
|
package/dist/cjs/utils.cjs
CHANGED
|
@@ -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 (
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
//# sourceMappingURL=utils.cjs.map
|
|
41
|
+
0 && (module.exports = {
|
|
42
|
+
getFileHash,
|
|
43
|
+
transformToCamelCase
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=utils.cjs.map
|
|
@@ -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 (
|
|
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(
|
|
33
|
-
var import_createModuleAugmentation = require(
|
|
34
|
-
var import_createType = require(
|
|
35
|
-
var import_transpileBundledCode = require(
|
|
36
|
-
var import_utils = require(
|
|
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(
|
|
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
|
-
|
|
182
|
-
|
|
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 };
|