@intlayer/webpack 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/cjs/index.cjs +46 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/scripts/bundle.cjs +68 -0
- package/dist/cjs/scripts/bundle.cjs.map +1 -0
- package/dist/cjs/scripts/index.cjs +33 -0
- package/dist/cjs/scripts/index.cjs.map +1 -0
- package/dist/cjs/scripts/startServer.cjs +44 -0
- package/dist/cjs/scripts/startServer.cjs.map +1 -0
- package/dist/cjs/transpiler/dictionary_to_main/createDictionaryList.cjs +92 -0
- package/dist/cjs/transpiler/dictionary_to_main/createDictionaryList.cjs.map +1 -0
- package/dist/cjs/transpiler/dictionary_to_main/index.cjs +35 -0
- package/dist/cjs/transpiler/dictionary_to_main/index.cjs.map +1 -0
- package/dist/cjs/transpiler/dictionary_to_type/createModuleAugmentation.cjs +83 -0
- package/dist/cjs/transpiler/dictionary_to_type/createModuleAugmentation.cjs.map +1 -0
- package/dist/cjs/transpiler/dictionary_to_type/createType.cjs +122 -0
- package/dist/cjs/transpiler/dictionary_to_type/createType.cjs.map +1 -0
- package/dist/cjs/transpiler/dictionary_to_type/index.cjs +41 -0
- package/dist/cjs/transpiler/dictionary_to_type/index.cjs.map +1 -0
- package/dist/cjs/transpiler/intlater_module_to_dictionary/extractNestedJSON.cjs +50 -0
- package/dist/cjs/transpiler/intlater_module_to_dictionary/extractNestedJSON.cjs.map +1 -0
- package/dist/cjs/transpiler/intlater_module_to_dictionary/index.cjs +47 -0
- package/dist/cjs/transpiler/intlater_module_to_dictionary/index.cjs.map +1 -0
- package/dist/cjs/transpiler/intlater_module_to_dictionary/processModule.cjs +70 -0
- package/dist/cjs/transpiler/intlater_module_to_dictionary/processModule.cjs.map +1 -0
- package/dist/cjs/transpiler/intlater_module_to_dictionary/transpileBundledCode.cjs +112 -0
- package/dist/cjs/transpiler/intlater_module_to_dictionary/transpileBundledCode.cjs.map +1 -0
- package/dist/cjs/utils.cjs +53 -0
- package/dist/cjs/utils.cjs.map +1 -0
- package/dist/cjs/webpack-plugin.cjs +184 -0
- package/dist/cjs/webpack-plugin.cjs.map +1 -0
- package/dist/cjs/webpack.config.cjs +180 -0
- package/dist/cjs/webpack.config.cjs.map +1 -0
- package/dist/esm/index.d.mts +9 -0
- package/dist/esm/index.mjs +12 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/scripts/bundle.d.mts +7 -0
- package/dist/esm/scripts/bundle.mjs +35 -0
- package/dist/esm/scripts/bundle.mjs.map +1 -0
- package/dist/esm/scripts/index.d.mts +3 -0
- package/dist/esm/scripts/index.mjs +3 -0
- package/dist/esm/scripts/index.mjs.map +1 -0
- package/dist/esm/scripts/startServer.d.mts +5 -0
- package/dist/esm/scripts/startServer.mjs +10 -0
- package/dist/esm/scripts/startServer.mjs.map +1 -0
- package/dist/esm/transpiler/dictionary_to_main/createDictionaryList.d.mts +6 -0
- package/dist/esm/transpiler/dictionary_to_main/createDictionaryList.mjs +52 -0
- package/dist/esm/transpiler/dictionary_to_main/createDictionaryList.mjs.map +1 -0
- package/dist/esm/transpiler/dictionary_to_main/index.d.mts +1 -0
- package/dist/esm/transpiler/dictionary_to_main/index.mjs +2 -0
- package/dist/esm/transpiler/dictionary_to_main/index.mjs.map +1 -0
- package/dist/esm/transpiler/dictionary_to_type/createModuleAugmentation.d.mts +7 -0
- package/dist/esm/transpiler/dictionary_to_type/createModuleAugmentation.mjs +43 -0
- package/dist/esm/transpiler/dictionary_to_type/createModuleAugmentation.mjs.map +1 -0
- package/dist/esm/transpiler/dictionary_to_type/createType.d.mts +42 -0
- package/dist/esm/transpiler/dictionary_to_type/createType.mjs +84 -0
- package/dist/esm/transpiler/dictionary_to_type/createType.mjs.map +1 -0
- package/dist/esm/transpiler/dictionary_to_type/index.d.mts +10 -0
- package/dist/esm/transpiler/dictionary_to_type/index.mjs +3 -0
- package/dist/esm/transpiler/dictionary_to_type/index.mjs.map +1 -0
- package/dist/esm/transpiler/intlater_module_to_dictionary/extractNestedJSON.d.mts +44 -0
- package/dist/esm/transpiler/intlater_module_to_dictionary/extractNestedJSON.mjs +19 -0
- package/dist/esm/transpiler/intlater_module_to_dictionary/extractNestedJSON.mjs.map +1 -0
- package/dist/esm/transpiler/intlater_module_to_dictionary/index.d.mts +4 -0
- package/dist/esm/transpiler/intlater_module_to_dictionary/index.mjs +4 -0
- package/dist/esm/transpiler/intlater_module_to_dictionary/index.mjs.map +1 -0
- package/dist/esm/transpiler/intlater_module_to_dictionary/processModule.d.mts +10 -0
- package/dist/esm/transpiler/intlater_module_to_dictionary/processModule.mjs +39 -0
- package/dist/esm/transpiler/intlater_module_to_dictionary/processModule.mjs.map +1 -0
- package/dist/esm/transpiler/intlater_module_to_dictionary/transpileBundledCode.d.mts +8 -0
- package/dist/esm/transpiler/intlater_module_to_dictionary/transpileBundledCode.mjs +70 -0
- package/dist/esm/transpiler/intlater_module_to_dictionary/transpileBundledCode.mjs.map +1 -0
- package/dist/esm/utils.d.mts +4 -0
- package/dist/esm/utils.mjs +20 -0
- package/dist/esm/utils.mjs.map +1 -0
- package/dist/esm/webpack-plugin.d.mts +15 -0
- package/dist/esm/webpack-plugin.mjs +145 -0
- package/dist/esm/webpack-plugin.mjs.map +1 -0
- package/dist/esm/webpack.config.d.mts +7 -0
- package/dist/esm/webpack.config.mjs +136 -0
- package/dist/esm/webpack.config.mjs.map +1 -0
- package/package.json +97 -0
- package/src/index.ts +12 -0
- package/src/scripts/bundle.ts +44 -0
- package/src/scripts/index.ts +2 -0
- package/src/scripts/startServer.ts +14 -0
- package/src/transpiler/dictionary_to_main/createDictionaryList.ts +65 -0
- package/src/transpiler/dictionary_to_main/index.ts +1 -0
- package/src/transpiler/dictionary_to_type/createModuleAugmentation.ts +70 -0
- package/src/transpiler/dictionary_to_type/createType.ts +140 -0
- package/src/transpiler/dictionary_to_type/index.ts +2 -0
- package/src/transpiler/intlater_module_to_dictionary/extractNestedJSON.ts +60 -0
- package/src/transpiler/intlater_module_to_dictionary/index.ts +3 -0
- package/src/transpiler/intlater_module_to_dictionary/processModule.ts +69 -0
- package/src/transpiler/intlater_module_to_dictionary/transpileBundledCode.ts +107 -0
- package/src/utils.ts +26 -0
- package/src/webpack-plugin.ts +185 -0
- package/src/webpack.config.ts +149 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020-2021 Sébastien Vanvelthem
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if ((from && typeof from === "object") || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toCommonJS = (mod) =>
|
|
22
|
+
__copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
+
var src_exports = {};
|
|
24
|
+
__export(src_exports, {
|
|
25
|
+
IntLayerPlugin: () => import_webpack_plugin.IntLayerPlugin,
|
|
26
|
+
bundle: () => import_scripts.bundle,
|
|
27
|
+
devServerConfig: () => import_webpack.devServerConfig,
|
|
28
|
+
startServer: () => import_scripts.startServer,
|
|
29
|
+
watch: () => import_scripts.watch,
|
|
30
|
+
webpackConfig: () => import_webpack.webpackConfig,
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(src_exports);
|
|
33
|
+
var import_scripts = require("./scripts/index.cjs");
|
|
34
|
+
var import_webpack_plugin = require("./webpack-plugin.cjs");
|
|
35
|
+
var import_webpack = require("./webpack.config.cjs");
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 &&
|
|
38
|
+
(module.exports = {
|
|
39
|
+
IntLayerPlugin,
|
|
40
|
+
bundle,
|
|
41
|
+
devServerConfig,
|
|
42
|
+
startServer,
|
|
43
|
+
watch,
|
|
44
|
+
webpackConfig,
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import { bundle, startServer, watch } from './scripts/index';\nimport { IntLayerPlugin } from './webpack-plugin';\nimport { devServerConfig, webpackConfig } from './webpack.config';\n\nexport {\n bundle,\n watch,\n startServer,\n devServerConfig,\n webpackConfig,\n IntLayerPlugin,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA2C;AAC3C,4BAA+B;AAC/B,qBAA+C;","names":[]}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if ((from && typeof from === "object") || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toCommonJS = (mod) =>
|
|
22
|
+
__copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
+
var bundle_exports = {};
|
|
24
|
+
__export(bundle_exports, {
|
|
25
|
+
bundle: () => bundle,
|
|
26
|
+
watch: () => watch,
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(bundle_exports);
|
|
29
|
+
const bundle = (compiler) =>
|
|
30
|
+
// Run the compiler
|
|
31
|
+
compiler.run((err, stats) => {
|
|
32
|
+
if (err) {
|
|
33
|
+
console.error("Webpack compilation error:", err);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
console.info("Webpack compilation successful.");
|
|
37
|
+
if (stats)
|
|
38
|
+
console.info(
|
|
39
|
+
stats.toString({
|
|
40
|
+
// Add options here to customize the stats output
|
|
41
|
+
colors: true,
|
|
42
|
+
})
|
|
43
|
+
);
|
|
44
|
+
});
|
|
45
|
+
const watch = (compiler) =>
|
|
46
|
+
// Run the compiler
|
|
47
|
+
compiler.watch({}, (err, stats) => {
|
|
48
|
+
if (err) {
|
|
49
|
+
console.error("Webpack compilation error:", err);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
console.info("Webpack compilation successful.");
|
|
53
|
+
if (stats)
|
|
54
|
+
console.info(
|
|
55
|
+
stats.toString({
|
|
56
|
+
// Add options here to customize the stats output
|
|
57
|
+
colors: true,
|
|
58
|
+
})
|
|
59
|
+
);
|
|
60
|
+
console.info("Watch IntLayer content...");
|
|
61
|
+
});
|
|
62
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
63
|
+
0 &&
|
|
64
|
+
(module.exports = {
|
|
65
|
+
bundle,
|
|
66
|
+
watch,
|
|
67
|
+
});
|
|
68
|
+
//# sourceMappingURL=bundle.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if ((from && typeof from === "object") || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, {
|
|
11
|
+
get: () => from[key],
|
|
12
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __reExport = (target, mod, secondTarget) => (
|
|
18
|
+
__copyProps(target, mod, "default"),
|
|
19
|
+
secondTarget && __copyProps(secondTarget, mod, "default")
|
|
20
|
+
);
|
|
21
|
+
var __toCommonJS = (mod) =>
|
|
22
|
+
__copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
+
var scripts_exports = {};
|
|
24
|
+
module.exports = __toCommonJS(scripts_exports);
|
|
25
|
+
__reExport(scripts_exports, require("./startServer.cjs"), module.exports);
|
|
26
|
+
__reExport(scripts_exports, require("./bundle.cjs"), module.exports);
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 &&
|
|
29
|
+
(module.exports = {
|
|
30
|
+
...require("./startServer.cjs"),
|
|
31
|
+
...require("./bundle.cjs"),
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/scripts/index.ts"],"sourcesContent":["export * from './startServer';\nexport * from './bundle';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,4BAAc,0BAAd;AACA,4BAAc,qBADd;","names":[]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if ((from && typeof from === "object") || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toCommonJS = (mod) =>
|
|
22
|
+
__copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
+
var startServer_exports = {};
|
|
24
|
+
__export(startServer_exports, {
|
|
25
|
+
startServer: () => startServer,
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(startServer_exports);
|
|
28
|
+
var import_webpack = require("../webpack.config.cjs");
|
|
29
|
+
const WebpackDevServer = require("webpack-dev-server");
|
|
30
|
+
const startServer = (compiler) => {
|
|
31
|
+
const devServer = new WebpackDevServer(
|
|
32
|
+
import_webpack.devServerConfig,
|
|
33
|
+
compiler
|
|
34
|
+
);
|
|
35
|
+
devServer.startCallback(() => {
|
|
36
|
+
console.info("Webpack Dev Server is running...");
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
+
0 &&
|
|
41
|
+
(module.exports = {
|
|
42
|
+
startServer,
|
|
43
|
+
});
|
|
44
|
+
//# sourceMappingURL=startServer.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,qBAAgC;AAEhC,MAAM,mBAAmB,QAAQ,oBAAoB;AAE9C,MAAM,cAAc,CAAC,aAAuB;AAEjD,QAAM,YAAY,IAAI,iBAAiB,gCAAiB,QAAQ;AAGhE,YAAU,cAAc,MAAM;AAC5B,YAAQ,KAAK,kCAAkC;AAAA,EACjD,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if ((from && typeof from === "object") || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toCommonJS = (mod) =>
|
|
22
|
+
__copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
+
var createDictionaryList_exports = {};
|
|
24
|
+
__export(createDictionaryList_exports, {
|
|
25
|
+
createDictionaryList: () => createDictionaryList,
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(createDictionaryList_exports);
|
|
28
|
+
var import_fs = require("fs");
|
|
29
|
+
var import_path = require("path");
|
|
30
|
+
var import_config = require("@intlayer/config");
|
|
31
|
+
var import_glob = require("glob");
|
|
32
|
+
var import_utils = require("../../utils.cjs");
|
|
33
|
+
const { content } = (0, import_config.getConfiguration)();
|
|
34
|
+
const { dictionariesDir, mainDir } = content;
|
|
35
|
+
const generateDictionaryListContent = (dictionaries, format = "esm") => {
|
|
36
|
+
let content2 = "";
|
|
37
|
+
const dictionariesRef = dictionaries.map((dictionaryPath) => ({
|
|
38
|
+
relativePath: (0, import_path.relative)(mainDir, dictionaryPath),
|
|
39
|
+
id: (0, import_path.basename)(
|
|
40
|
+
dictionaryPath,
|
|
41
|
+
(0, import_path.extname)(dictionaryPath)
|
|
42
|
+
),
|
|
43
|
+
// Get the base name as the dictionary id
|
|
44
|
+
hash: `_${(0, import_utils.getFileHash)(dictionaryPath)}`,
|
|
45
|
+
// Get the hash of the dictionary to avoid conflicts
|
|
46
|
+
}));
|
|
47
|
+
dictionariesRef.forEach((dictionary) => {
|
|
48
|
+
if (format === "esm")
|
|
49
|
+
content2 += `import ${dictionary.hash} from '${dictionary.relativePath}';
|
|
50
|
+
`;
|
|
51
|
+
if (format === "cjs")
|
|
52
|
+
content2 += `const ${dictionary.hash} = require('${dictionary.relativePath}');
|
|
53
|
+
`;
|
|
54
|
+
});
|
|
55
|
+
content2 += "\n";
|
|
56
|
+
const formattedDictionaryMap = dictionariesRef
|
|
57
|
+
.map((dictionary) => `"${dictionary.id}": ${dictionary.hash}`)
|
|
58
|
+
.join(",\n");
|
|
59
|
+
if (format === "esm")
|
|
60
|
+
content2 += `export default {
|
|
61
|
+
${formattedDictionaryMap}
|
|
62
|
+
};
|
|
63
|
+
`;
|
|
64
|
+
if (format === "cjs")
|
|
65
|
+
content2 += `module.exports = {
|
|
66
|
+
${formattedDictionaryMap}
|
|
67
|
+
};
|
|
68
|
+
`;
|
|
69
|
+
return content2;
|
|
70
|
+
};
|
|
71
|
+
const createDictionaryList = () => {
|
|
72
|
+
if (!(0, import_fs.existsSync)(mainDir)) {
|
|
73
|
+
(0, import_fs.mkdirSync)(mainDir, { recursive: true });
|
|
74
|
+
}
|
|
75
|
+
const dictionaries = (0, import_glob.sync)(`${dictionariesDir}/**/*.json`);
|
|
76
|
+
const cjsContent = generateDictionaryListContent(dictionaries, "cjs");
|
|
77
|
+
(0, import_fs.writeFileSync)(
|
|
78
|
+
(0, import_path.resolve)(mainDir, "dictionaries.cjs"),
|
|
79
|
+
cjsContent
|
|
80
|
+
);
|
|
81
|
+
const esmContent = generateDictionaryListContent(dictionaries, "esm");
|
|
82
|
+
(0, import_fs.writeFileSync)(
|
|
83
|
+
(0, import_path.resolve)(mainDir, "dictionaries.mjs"),
|
|
84
|
+
esmContent
|
|
85
|
+
);
|
|
86
|
+
};
|
|
87
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
88
|
+
0 &&
|
|
89
|
+
(module.exports = {
|
|
90
|
+
createDictionaryList,
|
|
91
|
+
});
|
|
92
|
+
//# sourceMappingURL=createDictionaryList.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
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;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAqD;AACrD,kBAAqD;AACrD,oBAAiC;AACjC,kBAAqB;AACrB,mBAA4B;AAE5B,MAAM,EAAE,QAAQ,QAAI,gCAAiB;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,kBAAc,sBAAS,SAAS,cAAc;AAAA,IAC9C,QAAI,sBAAS,oBAAgB,qBAAQ,cAAc,CAAC;AAAA;AAAA,IACpD,MAAM,QAAI,0BAAY,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,KAAC,sBAAW,OAAO,GAAG;AACxB,6BAAU,SAAS,EAAE,WAAW,KAAK,CAAC;AAAA,EACxC;AAEA,QAAM,mBAAyB,kBAAK,GAAG,eAAe,YAAY;AAGlE,QAAM,aAAa,8BAA8B,cAAc,KAAK;AACpE,mCAAc,qBAAQ,SAAS,kBAAkB,GAAG,UAAU;AAE9D,QAAM,aAAa,8BAA8B,cAAc,KAAK;AACpE,mCAAc,qBAAQ,SAAS,kBAAkB,GAAG,UAAU;AAChE;","names":["content"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if ((from && typeof from === "object") || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, {
|
|
11
|
+
get: () => from[key],
|
|
12
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __reExport = (target, mod, secondTarget) => (
|
|
18
|
+
__copyProps(target, mod, "default"),
|
|
19
|
+
secondTarget && __copyProps(secondTarget, mod, "default")
|
|
20
|
+
);
|
|
21
|
+
var __toCommonJS = (mod) =>
|
|
22
|
+
__copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
+
var dictionary_to_main_exports = {};
|
|
24
|
+
module.exports = __toCommonJS(dictionary_to_main_exports);
|
|
25
|
+
__reExport(
|
|
26
|
+
dictionary_to_main_exports,
|
|
27
|
+
require("./createDictionaryList.cjs"),
|
|
28
|
+
module.exports
|
|
29
|
+
);
|
|
30
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
+
0 &&
|
|
32
|
+
(module.exports = {
|
|
33
|
+
...require("./createDictionaryList.cjs"),
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_main/index.ts"],"sourcesContent":["export * from './createDictionaryList';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,uCAAc,mCAAd;","names":[]}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if ((from && typeof from === "object") || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toCommonJS = (mod) =>
|
|
22
|
+
__copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
+
var createModuleAugmentation_exports = {};
|
|
24
|
+
__export(createModuleAugmentation_exports, {
|
|
25
|
+
createModuleAugmentation: () => createModuleAugmentation,
|
|
26
|
+
getTypeName: () => getTypeName,
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(createModuleAugmentation_exports);
|
|
29
|
+
var import_fs = require("fs");
|
|
30
|
+
var import_path = require("path");
|
|
31
|
+
var import_config = require("@intlayer/config");
|
|
32
|
+
var import_glob = require("glob");
|
|
33
|
+
var import_utils = require("../../utils.cjs");
|
|
34
|
+
const { content } = (0, import_config.getConfiguration)();
|
|
35
|
+
const { typesDir, moduleAugmentationDir } = content;
|
|
36
|
+
const getTypeName = (id) =>
|
|
37
|
+
(0, import_utils.transformToCamelCase)(`${id}Content`);
|
|
38
|
+
const generateTypeIndexContent = (typeFiles) => {
|
|
39
|
+
let content2 = "import 'intlayer';\n\n";
|
|
40
|
+
const dictionariesRef = typeFiles.map((dictionaryPath) => ({
|
|
41
|
+
relativePath: (0, import_path.relative)(
|
|
42
|
+
moduleAugmentationDir,
|
|
43
|
+
dictionaryPath
|
|
44
|
+
),
|
|
45
|
+
id: (0, import_path.basename)(dictionaryPath, ".d.ts"),
|
|
46
|
+
// Get the base name as the dictionary id
|
|
47
|
+
hash: `_${(0, import_utils.getFileHash)(dictionaryPath)}`,
|
|
48
|
+
// Get the hash of the dictionary to avoid conflicts
|
|
49
|
+
}));
|
|
50
|
+
dictionariesRef.forEach((dictionary) => {
|
|
51
|
+
const typeName = getTypeName(dictionary.id);
|
|
52
|
+
content2 += `import type { ${typeName} as ${dictionary.hash} } from '${dictionary.relativePath}';
|
|
53
|
+
`;
|
|
54
|
+
});
|
|
55
|
+
content2 += "\n";
|
|
56
|
+
const formattedDictionaryMap = dictionariesRef
|
|
57
|
+
.map((dictionary) => ` "${dictionary.id}": ${dictionary.hash};`)
|
|
58
|
+
.join("\n");
|
|
59
|
+
content2 += `declare module 'intlayer' {
|
|
60
|
+
interface IntlayerDictionaryTypesConnector {
|
|
61
|
+
${formattedDictionaryMap}
|
|
62
|
+
};
|
|
63
|
+
};`;
|
|
64
|
+
return content2;
|
|
65
|
+
};
|
|
66
|
+
const createModuleAugmentation = () => {
|
|
67
|
+
if (!(0, import_fs.existsSync)(moduleAugmentationDir)) {
|
|
68
|
+
(0, import_fs.mkdirSync)(moduleAugmentationDir, { recursive: true });
|
|
69
|
+
}
|
|
70
|
+
const dictionaries = (0, import_glob.sync)(`${typesDir}/**/*.d.ts`);
|
|
71
|
+
const tsContent = generateTypeIndexContent(dictionaries);
|
|
72
|
+
(0, import_fs.writeFileSync)(
|
|
73
|
+
(0, import_path.join)(moduleAugmentationDir, "intlayer.d.ts"),
|
|
74
|
+
tsContent
|
|
75
|
+
);
|
|
76
|
+
};
|
|
77
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
78
|
+
0 &&
|
|
79
|
+
(module.exports = {
|
|
80
|
+
createModuleAugmentation,
|
|
81
|
+
getTypeName,
|
|
82
|
+
});
|
|
83
|
+
//# sourceMappingURL=createModuleAugmentation.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
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 { getConfiguration } from '@intlayer/config';\nimport { sync } from 'glob';\nimport { getFileHash, transformToCamelCase } from '../../utils';\n\nconst { content } = getConfiguration();\nconst { typesDir, moduleAugmentationDir } = content;\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 = \"import 'intlayer';\\n\\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 /**\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 * See https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation\n */\n content += `declare module 'intlayer' {\\n interface IntlayerDictionaryTypesConnector {\\n${formattedDictionaryMap}\\n };\\n};`;\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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAqD;AACrD,kBAAyC;AACzC,oBAAiC;AACjC,kBAAqB;AACrB,mBAAkD;AAElD,MAAM,EAAE,QAAQ,QAAI,gCAAiB;AACrC,MAAM,EAAE,UAAU,sBAAsB,IAAI;AAErC,MAAM,cAAc,CAAC,WAC1B,mCAAqB,GAAG,EAAE,SAAS;AAKrC,MAAM,2BAA2B,CAAC,cAAgC;AAChE,MAAIA,WAAU;AAEd,QAAM,kBAAkB,UAAU,IAAI,CAAC,oBAAoB;AAAA,IACzD,kBAAc,sBAAS,uBAAuB,cAAc;AAAA,IAC5D,QAAI,sBAAS,gBAAgB,OAAO;AAAA;AAAA,IACpC,MAAM,QAAI,0BAAY,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,EAAAA,YAAW;AAAA;AAAA,EAAgF,sBAAsB;AAAA;AAAA;AAEjH,SAAOA;AACT;AAKO,MAAM,2BAA2B,MAAM;AAE5C,MAAI,KAAC,sBAAW,qBAAqB,GAAG;AACtC,6BAAU,uBAAuB,EAAE,WAAW,KAAK,CAAC;AAAA,EACtD;AAEA,QAAM,mBAAyB,kBAAK,GAAG,QAAQ,YAAY;AAG3D,QAAM,YAAY,yBAAyB,YAAY;AACvD,mCAAc,kBAAK,uBAAuB,eAAe,GAAG,SAAS;AACvE;","names":["content"]}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if ((from && typeof from === "object") || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toCommonJS = (mod) =>
|
|
22
|
+
__copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
+
var createType_exports = {};
|
|
24
|
+
__export(createType_exports, {
|
|
25
|
+
createTypes: () => createTypes,
|
|
26
|
+
generateTypeScriptType: () => generateTypeScriptType,
|
|
27
|
+
generateTypeScriptTypeContent: () => generateTypeScriptTypeContent,
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(createType_exports);
|
|
30
|
+
var import_fs = require("fs");
|
|
31
|
+
var import_path = require("path");
|
|
32
|
+
var import_config = require("@intlayer/config");
|
|
33
|
+
var import_core = require("@intlayer/core");
|
|
34
|
+
var import_createModuleAugmentation = require("./createModuleAugmentation.cjs");
|
|
35
|
+
const { content, internationalization } = (0, import_config.getConfiguration)();
|
|
36
|
+
const { typesDir } = content;
|
|
37
|
+
const generateTypeScriptType = (obj) => {
|
|
38
|
+
let typeDefinition = ``;
|
|
39
|
+
const typeName = (0, import_createModuleAugmentation.getTypeName)(obj.id);
|
|
40
|
+
typeDefinition += `export type ${typeName} = {
|
|
41
|
+
`;
|
|
42
|
+
typeDefinition += generateTypeScriptTypeContent(obj);
|
|
43
|
+
typeDefinition += "};\n\n";
|
|
44
|
+
return typeDefinition;
|
|
45
|
+
};
|
|
46
|
+
const generateTypeScriptTypeContent = (obj) => {
|
|
47
|
+
let typeDefinition = ``;
|
|
48
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
49
|
+
const nodeType = value.nodeType;
|
|
50
|
+
if (
|
|
51
|
+
// Check if the value is a typed node
|
|
52
|
+
typeof value === "object" &&
|
|
53
|
+
nodeType === import_core.NodeType.Translation
|
|
54
|
+
) {
|
|
55
|
+
const tsType = typeof value[internationalization.defaultLocale];
|
|
56
|
+
typeDefinition += ` ${key}: ${tsType},
|
|
57
|
+
`;
|
|
58
|
+
} else if (
|
|
59
|
+
// Check if the value is a typed node
|
|
60
|
+
typeof value === "object" &&
|
|
61
|
+
nodeType === import_core.NodeType.Enumeration
|
|
62
|
+
) {
|
|
63
|
+
const tsType = typeof value[internationalization.defaultLocale];
|
|
64
|
+
typeDefinition += ` ${key}: (quantity: number) => ${tsType},
|
|
65
|
+
`;
|
|
66
|
+
} else if (
|
|
67
|
+
// Check if the value is a nested object
|
|
68
|
+
typeof value === "object" &&
|
|
69
|
+
!Array.isArray(value)
|
|
70
|
+
) {
|
|
71
|
+
const nestedType = generateTypeScriptTypeContent(value);
|
|
72
|
+
typeDefinition += ` ${key}: {${nestedType}},
|
|
73
|
+
`;
|
|
74
|
+
} else if (
|
|
75
|
+
// Check if the value is an array
|
|
76
|
+
Array.isArray(value)
|
|
77
|
+
) {
|
|
78
|
+
const arrayType = typeof value[0];
|
|
79
|
+
typeDefinition += ` ${key}: ${arrayType}[],
|
|
80
|
+
`;
|
|
81
|
+
} else if (
|
|
82
|
+
// Check if the value is an 'id'
|
|
83
|
+
typeof value === "string" &&
|
|
84
|
+
key === "id"
|
|
85
|
+
) {
|
|
86
|
+
const tsType = `"${value}"`;
|
|
87
|
+
typeDefinition += ` ${key}: ${tsType},
|
|
88
|
+
`;
|
|
89
|
+
} else {
|
|
90
|
+
const tsType = typeof value;
|
|
91
|
+
typeDefinition += ` ${key}: ${tsType},
|
|
92
|
+
`;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return typeDefinition;
|
|
96
|
+
};
|
|
97
|
+
const createTypes = (dictionariesPaths) => {
|
|
98
|
+
const resultTypesPaths = [];
|
|
99
|
+
if (!(0, import_fs.existsSync)(typesDir)) {
|
|
100
|
+
(0, import_fs.mkdirSync)(typesDir, { recursive: true });
|
|
101
|
+
}
|
|
102
|
+
for (const dictionaryPath of dictionariesPaths) {
|
|
103
|
+
const contentModule = require(dictionaryPath);
|
|
104
|
+
const dictionaryName = contentModule.id;
|
|
105
|
+
const typeDefinition = generateTypeScriptType(contentModule);
|
|
106
|
+
const outputPath = (0, import_path.resolve)(
|
|
107
|
+
typesDir,
|
|
108
|
+
`${dictionaryName}.d.ts`
|
|
109
|
+
);
|
|
110
|
+
(0, import_fs.writeFileSync)(outputPath, typeDefinition);
|
|
111
|
+
resultTypesPaths.push(outputPath);
|
|
112
|
+
}
|
|
113
|
+
return resultTypesPaths;
|
|
114
|
+
};
|
|
115
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
116
|
+
0 &&
|
|
117
|
+
(module.exports = {
|
|
118
|
+
createTypes,
|
|
119
|
+
generateTypeScriptType,
|
|
120
|
+
generateTypeScriptTypeContent,
|
|
121
|
+
});
|
|
122
|
+
//# sourceMappingURL=createType.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/transpiler/dictionary_to_type/createType.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'fs';\nimport { resolve } from 'path';\nimport { getConfiguration } from '@intlayer/config';\nimport {\n NodeType,\n type Content,\n type ContentModule,\n type TypedNode,\n} from '@intlayer/core';\nimport { getTypeName } from './createModuleAugmentation';\n\nconst { content, internationalization } = getConfiguration();\nconst { typesDir } = content;\n\n/**\n *\n * This function generates a TypeScript type definition from a JSON object\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 * }\n * };\n *\n * const result = generateTypeScriptType(input, 'RootObject');\n * console.log(result);\n *\n * Output:\n *\n * type RootObject = {\n * id: '1',\n * name: string,\n * address: {\n * id: '2',\n * street: string,\n * city: string,\n * },\n * };\n *\n */\nexport const generateTypeScriptType = (obj: ContentModule): string => {\n let typeDefinition = ``;\n\n const typeName = getTypeName(obj.id);\n\n typeDefinition += `export type ${typeName} = {\\n`;\n typeDefinition += generateTypeScriptTypeContent(obj);\n typeDefinition += '};\\n\\n';\n\n return typeDefinition;\n};\n\nexport const generateTypeScriptTypeContent = (obj: Content): string => {\n let typeDefinition = ``;\n\n for (const [key, value] of Object.entries(obj)) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const nodeType: NodeType | undefined = (value as TypedNode).nodeType;\n\n if (\n // Check if the value is a typed node\n typeof value === 'object' &&\n nodeType === NodeType.Translation\n ) {\n const tsType =\n typeof value[internationalization.defaultLocale as keyof typeof value];\n typeDefinition += ` ${key}: ${tsType},\\n`;\n } else if (\n // Check if the value is a typed node\n typeof value === 'object' &&\n nodeType === NodeType.Enumeration\n ) {\n const tsType =\n typeof value[internationalization.defaultLocale as keyof typeof value];\n\n typeDefinition += ` ${key}: (quantity: number) => ${tsType},\\n`;\n } else if (\n // Check if the value is a nested object\n typeof value === 'object' &&\n !Array.isArray(value)\n ) {\n // Nested object, recurse\n const nestedType = generateTypeScriptTypeContent(value as Content);\n typeDefinition += ` ${key}: {${nestedType}},\\n`;\n } else if (\n // Check if the value is an array\n Array.isArray(value)\n ) {\n // Array handling (simplified, assumes non-empty arrays with uniform type)\n const arrayType = typeof value[0];\n typeDefinition += ` ${key}: ${arrayType}[],\\n`;\n } else if (\n // Check if the value is an 'id'\n typeof value === 'string' &&\n key === 'id'\n ) {\n // Special handling for 'id' field\n const tsType = `\"${value}\"`;\n typeDefinition += ` ${key}: ${tsType},\\n`;\n } else {\n // Primitive type\n const tsType = typeof value;\n typeDefinition += ` ${key}: ${tsType},\\n`;\n }\n }\n\n return typeDefinition;\n};\n\n/**\n * This function generates a TypeScript type definition from a JSON object\n */\nexport const createTypes = (dictionariesPaths: string[]): string[] => {\n const resultTypesPaths: string[] = [];\n\n // Create type folders if they don't exist\n if (!existsSync(typesDir)) {\n mkdirSync(typesDir, { recursive: true });\n }\n\n for (const dictionaryPath of dictionariesPaths) {\n const contentModule: ContentModule = require(dictionaryPath);\n const dictionaryName: string = contentModule.id;\n const typeDefinition: string = generateTypeScriptType(contentModule);\n\n const outputPath = resolve(typesDir, `${dictionaryName}.d.ts`);\n\n writeFileSync(outputPath, typeDefinition);\n\n resultTypesPaths.push(outputPath);\n }\n\n return resultTypesPaths;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAqD;AACrD,kBAAwB;AACxB,oBAAiC;AACjC,kBAKO;AACP,sCAA4B;AAE5B,MAAM,EAAE,SAAS,qBAAqB,QAAI,gCAAiB;AAC3D,MAAM,EAAE,SAAS,IAAI;AAkCd,MAAM,yBAAyB,CAAC,QAA+B;AACpE,MAAI,iBAAiB;AAErB,QAAM,eAAW,6CAAY,IAAI,EAAE;AAEnC,oBAAkB,eAAe,QAAQ;AAAA;AACzC,oBAAkB,8BAA8B,GAAG;AACnD,oBAAkB;AAElB,SAAO;AACT;AAEO,MAAM,gCAAgC,CAAC,QAAyB;AACrE,MAAI,iBAAiB;AAErB,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,GAAG,GAAG;AAE9C,UAAM,WAAkC,MAAoB;AAE5D;AAAA;AAAA,MAEE,OAAO,UAAU,YACjB,aAAa,qBAAS;AAAA,MACtB;AACA,YAAM,SACJ,OAAO,MAAM,qBAAqB,aAAmC;AACvE,wBAAkB,KAAK,GAAG,KAAK,MAAM;AAAA;AAAA,IACvC;AAAA;AAAA,MAEE,OAAO,UAAU,YACjB,aAAa,qBAAS;AAAA,MACtB;AACA,YAAM,SACJ,OAAO,MAAM,qBAAqB,aAAmC;AAEvE,wBAAkB,KAAK,GAAG,2BAA2B,MAAM;AAAA;AAAA,IAC7D;AAAA;AAAA,MAEE,OAAO,UAAU,YACjB,CAAC,MAAM,QAAQ,KAAK;AAAA,MACpB;AAEA,YAAM,aAAa,8BAA8B,KAAgB;AACjE,wBAAkB,KAAK,GAAG,MAAM,UAAU;AAAA;AAAA,IAC5C;AAAA;AAAA,MAEE,MAAM,QAAQ,KAAK;AAAA,MACnB;AAEA,YAAM,YAAY,OAAO,MAAM,CAAC;AAChC,wBAAkB,KAAK,GAAG,KAAK,SAAS;AAAA;AAAA,IAC1C;AAAA;AAAA,MAEE,OAAO,UAAU,YACjB,QAAQ;AAAA,MACR;AAEA,YAAM,SAAS,IAAI,KAAK;AACxB,wBAAkB,KAAK,GAAG,KAAK,MAAM;AAAA;AAAA,IACvC,OAAO;AAEL,YAAM,SAAS,OAAO;AACtB,wBAAkB,KAAK,GAAG,KAAK,MAAM;AAAA;AAAA,IACvC;AAAA,EACF;AAEA,SAAO;AACT;AAKO,MAAM,cAAc,CAAC,sBAA0C;AACpE,QAAM,mBAA6B,CAAC;AAGpC,MAAI,KAAC,sBAAW,QAAQ,GAAG;AACzB,6BAAU,UAAU,EAAE,WAAW,KAAK,CAAC;AAAA,EACzC;AAEA,aAAW,kBAAkB,mBAAmB;AAC9C,UAAM,gBAA+B,QAAQ,cAAc;AAC3D,UAAM,iBAAyB,cAAc;AAC7C,UAAM,iBAAyB,uBAAuB,aAAa;AAEnE,UAAM,iBAAa,qBAAQ,UAAU,GAAG,cAAc,OAAO;AAE7D,iCAAc,YAAY,cAAc;AAExC,qBAAiB,KAAK,UAAU;AAAA,EAClC;AAEA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if ((from && typeof from === "object") || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, {
|
|
11
|
+
get: () => from[key],
|
|
12
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __reExport = (target, mod, secondTarget) => (
|
|
18
|
+
__copyProps(target, mod, "default"),
|
|
19
|
+
secondTarget && __copyProps(secondTarget, mod, "default")
|
|
20
|
+
);
|
|
21
|
+
var __toCommonJS = (mod) =>
|
|
22
|
+
__copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
+
var dictionary_to_type_exports = {};
|
|
24
|
+
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
|
+
);
|
|
35
|
+
// 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
|
|
@@ -0,0 +1 @@
|
|
|
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":[]}
|