@trackunit/iris-app-webpack-plugin 0.0.1-alpha-afcc978985.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/CHANGELOG.md ADDED
@@ -0,0 +1,131 @@
1
+ # Changelog
2
+
3
+ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
+
5
+ ### [0.0.1-alpha-afcc978985.0](https://github.com/Trackunit/manager/compare/iris-app-webpack-plugin/0.0.60...iris-app-webpack-plugin/0.0.1-alpha-afcc978985.0) (2022-11-04)
6
+
7
+ ### [0.0.60](https://github.com/Trackunit/manager/compare/iris-app-webpack-plugin/0.0.59...iris-app-webpack-plugin/0.0.60) (2022-11-01)
8
+
9
+ ### Dependency Updates
10
+
11
+ * `iris-app-api` updated to version `0.0.1`
12
+ ### [0.0.59](https://github.com/Trackunit/manager/compare/iris-app-webpack-plugin/0.0.58...iris-app-webpack-plugin/0.0.59) (2022-10-28)
13
+
14
+ ### [0.0.58](https://github.com/Trackunit/manager/compare/iris-app-webpack-plugin/0.0.57...iris-app-webpack-plugin/0.0.58) (2022-10-27)
15
+
16
+ ### Dependency Updates
17
+
18
+ * `iris-app-api` updated to version `0.0.1`
19
+ ### [0.0.57](https://github.com/Trackunit/manager/compare/iris-app-webpack-plugin/0.0.56...iris-app-webpack-plugin/0.0.57) (2022-10-13)
20
+
21
+ ### Dependency Updates
22
+
23
+ * `iris-app-api` updated to version `0.0.1`
24
+ ### [0.0.56](https://github.com/Trackunit/manager/compare/iris-app-webpack-plugin/0.0.55...iris-app-webpack-plugin/0.0.56) (2022-10-06)
25
+
26
+ ### Dependency Updates
27
+
28
+ * `iris-app-api` updated to version `0.0.1`
29
+ ### [0.0.55](https://github.com/Trackunit/manager/compare/iris-app-webpack-plugin/0.0.54...iris-app-webpack-plugin/0.0.55) (2022-10-03)
30
+
31
+ ### Dependency Updates
32
+
33
+ * `iris-app-api` updated to version `0.0.1`
34
+ ### [0.0.54](https://github.com/Trackunit/manager/compare/iris-app-webpack-plugin/0.0.53...iris-app-webpack-plugin/0.0.54) (2022-09-26)
35
+
36
+ ### Dependency Updates
37
+
38
+ * `iris-app-api` updated to version `0.0.1`
39
+ ### [0.0.53](https://github.com/Trackunit/manager/compare/iris-app-webpack-plugin/0.0.52...iris-app-webpack-plugin/0.0.53) (2022-09-16)
40
+
41
+ ### Dependency Updates
42
+
43
+ * `iris-app-api` updated to version `0.0.1`
44
+ ### [0.0.52](https://github.com/Trackunit/manager/compare/iris-app-webpack-plugin/0.0.51...iris-app-webpack-plugin/0.0.52) (2022-09-15)
45
+
46
+ ### Dependency Updates
47
+
48
+ * `iris-app-api` updated to version `0.0.1`
49
+ ### [0.0.51](https://github.com/Trackunit/manager/compare/iris-app-webpack-plugin/0.0.50...iris-app-webpack-plugin/0.0.51) (2022-09-12)
50
+
51
+ ### Dependency Updates
52
+
53
+ * `iris-app-api` updated to version `0.0.1`
54
+ ### [0.0.50](https://github.com/Trackunit/manager/compare/iris-app-webpack-plugin/0.0.49...iris-app-webpack-plugin/0.0.50) (2022-09-12)
55
+
56
+ ### Dependency Updates
57
+
58
+ * `iris-app-api` updated to version `0.0.1`
59
+
60
+ ### Reverts
61
+
62
+ * Revert "ci: bump iris-app-webpack-plugin to 0.0.50-alpha-61732b8ce.0 [skip ci]" ([45108cf](https://github.com/Trackunit/manager/commit/45108cf83fb235f92842ce2daac907cc639e0625))
63
+
64
+ ### [0.0.49](https://github.com/Trackunit/manager/compare/iris-app-webpack-plugin/0.0.48...iris-app-webpack-plugin/0.0.49) (2022-09-02)
65
+
66
+ ### [0.0.48](https://github.com/Trackunit/manager/compare/iris-app-webpack-plugin/0.0.47...iris-app-webpack-plugin/0.0.48) (2022-08-30)
67
+
68
+ ### [0.0.47](https://github.com/Trackunit/manager/compare/iris-app-webpack-plugin/0.0.46...iris-app-webpack-plugin/0.0.47) (2022-08-25)
69
+
70
+ ### Dependency Updates
71
+
72
+ * `iris-app-api` updated to version `0.0.1`
73
+ ### [0.0.46](https://github.com/Trackunit/manager/compare/iris-app-webpack-plugin/0.0.45...iris-app-webpack-plugin/0.0.46) (2022-08-17)
74
+
75
+ ### Dependency Updates
76
+
77
+ * `iris-app-api` updated to version `0.0.1`
78
+ ### [0.0.45](https://github.com/Trackunit/manager/compare/iris-app-webpack-plugin/0.0.44...iris-app-webpack-plugin/0.0.45) (2022-08-12)
79
+
80
+ ### Dependency Updates
81
+
82
+ * `iris-app-api` updated to version `0.0.1`
83
+ ### [0.0.44](https://github.com/Trackunit/manager/compare/iris-app-webpack-plugin/0.0.43...iris-app-webpack-plugin/0.0.44) (2022-08-05)
84
+
85
+ ### Dependency Updates
86
+
87
+ * `iris-app-api` updated to version `0.0.1`
88
+ ### [0.0.43](https://github.com/Trackunit/manager/compare/iris-app-webpack-plugin/0.0.42...iris-app-webpack-plugin/0.0.43) (2022-07-29)
89
+
90
+ ### Dependency Updates
91
+
92
+ * `iris-app-api` updated to version `0.0.1`
93
+ ### [0.0.42](https://github.com/Trackunit/manager/compare/iris-app-webpack-plugin/0.0.41...iris-app-webpack-plugin/0.0.42) (2022-07-29)
94
+
95
+ ### Dependency Updates
96
+
97
+ * `iris-app-api` updated to version `0.0.1`
98
+ ### [0.0.41](https://github.com/Trackunit/manager/compare/iris-app-webpack-plugin/0.0.40...iris-app-webpack-plugin/0.0.41) (2022-07-25)
99
+
100
+ ### [0.0.40](https://github.com/Trackunit/manager/compare/iris-app-webpack-plugin/0.0.39...iris-app-webpack-plugin/0.0.40) (2022-07-05)
101
+
102
+ ### Dependency Updates
103
+
104
+ * `iris-app-api` updated to version `0.0.1`
105
+ ### [0.0.39](https://github.com/Trackunit/manager/compare/iris-app-webpack-plugin/0.0.38...iris-app-webpack-plugin/0.0.39) (2022-06-28)
106
+
107
+ ### Dependency Updates
108
+
109
+ * `iris-app-api` updated to version `0.0.1`
110
+ ### [0.0.38](https://github.com/Trackunit/manager/compare/iris-app-webpack-plugin/0.0.37...iris-app-webpack-plugin/0.0.38) (2022-06-27)
111
+
112
+ ### Dependency Updates
113
+
114
+ * `iris-app-api` updated to version `0.0.1`
115
+ ### [0.0.37](https://github.com/Trackunit/manager/compare/iris-app-webpack-plugin/0.0.36...iris-app-webpack-plugin/0.0.37) (2022-06-26)
116
+
117
+ ### Dependency Updates
118
+
119
+ * `iris-app-api` updated to version `0.0.1`
120
+ ### [0.0.36](https://github.com/Trackunit/manager/compare/iris-app-webpack-plugin/0.0.35...iris-app-webpack-plugin/0.0.36) (2022-06-23)
121
+
122
+ ### [0.0.35](https://github.com/Trackunit/manager/compare/iris-app-webpack-plugin/0.0.34...iris-app-webpack-plugin/0.0.35) (2022-06-23)
123
+
124
+ ### Dependency Updates
125
+
126
+ * `iris-app-api` updated to version `0.0.1`
127
+ ### [0.0.34](https://github.com/Trackunit/manager/compare/iris-app-webpack-plugin/0.0.33...iris-app-webpack-plugin/0.0.34) (2022-06-20)
128
+
129
+ ### Dependency Updates
130
+
131
+ * `iris-app-api` updated to version `0.0.1`
@@ -0,0 +1,5 @@
1
+ To build use:
2
+ yarn nx run iris-app-webpack-plugin:build
3
+
4
+ To publish use:
5
+ npm publish ./dist/libs/iris-app-sdk/iris-app-webpack-plugin/ --access public
package/README.md ADDED
@@ -0,0 +1,20 @@
1
+ > **⚠️ Beta**
2
+ >
3
+ > This is a beta version and subject to change without notice.
4
+
5
+ # Trackunit Iris App Webpack Plugin
6
+ The `@trackunit/iris-app-webpack-plugin` package contains a custom webpack plugin used for IrisAppSDK development.
7
+
8
+ Trackunit Iris App SDK are used by developers to integrate custom functionality into [the Trackunit Manager platform](https://www.trackunit.com/services/manager/).
9
+
10
+ For more info and a full guide on Iris App SDK Development, please visit our [Developer Hub](https://developers.trackunit.com/).
11
+
12
+ ## Getting started
13
+
14
+ Run through the easy getting started guide here: [Getting Started](https://developers.trackunit.com/docs/getting-started)
15
+
16
+ ## Trackunit
17
+ This package was developed by Trackunit ApS.
18
+ Trackunit is the leading SaaS-based IoT solution for the construction industry, offering an ecosystem of hardware, fleet management software & telematics.
19
+
20
+ ![The Trackunit logo](https://trackunit.com/wp-content/uploads/2022/03/top-logo.svg)
package/package.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "@trackunit/iris-app-webpack-plugin",
3
+ "version": "0.0.1-alpha-afcc978985.0",
4
+ "license": "SEE LICENSE IN LICENSE.txt",
5
+ "repository": "https://github.com/Trackunit/manager",
6
+ "main": "./src/index.js",
7
+ "types": "./src/index.d.ts",
8
+ "dependencies": {
9
+ "@trackunit/iris-app-api": "0.0.1-alpha-afcc978985.0",
10
+ "tslib": "^2.4.0"
11
+ },
12
+ "peerDependencies": {}
13
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { TrackunitIrisAppWebpackPlugin } from "./lib/TrackunitIrisAppWebpackPlugin";
package/src/index.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TrackunitIrisAppWebpackPlugin = void 0;
4
+ var TrackunitIrisAppWebpackPlugin_1 = require("./lib/TrackunitIrisAppWebpackPlugin");
5
+ Object.defineProperty(exports, "TrackunitIrisAppWebpackPlugin", { enumerable: true, get: function () { return TrackunitIrisAppWebpackPlugin_1.TrackunitIrisAppWebpackPlugin; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/iris-app-sdk/iris-app-webpack-plugin/src/index.ts"],"names":[],"mappings":";;;AAAA,qFAAoF;AAA3E,8IAAA,6BAA6B,OAAA","sourcesContent":["export { TrackunitIrisAppWebpackPlugin } from \"./lib/TrackunitIrisAppWebpackPlugin\";\n"]}
@@ -0,0 +1,13 @@
1
+ import { IrisAppManifest } from "@trackunit/iris-app-api";
2
+ import * as wp from "webpack";
3
+ interface ITrackunitIrisAppWebpackPluginOptions {
4
+ nxRootDir: string;
5
+ appDir: string;
6
+ manifest: IrisAppManifest;
7
+ }
8
+ export declare class TrackunitIrisAppWebpackPlugin {
9
+ private options;
10
+ constructor(options: ITrackunitIrisAppWebpackPluginOptions);
11
+ apply(compiler: wp.Compiler): void;
12
+ }
13
+ export {};
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TrackunitIrisAppWebpackPlugin = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const iris_app_api_1 = require("@trackunit/iris-app-api");
6
+ const fs = tslib_1.__importStar(require("fs"));
7
+ const path = tslib_1.__importStar(require("path"));
8
+ const isTranslationKey = (object) => {
9
+ return !!(object === null || object === void 0 ? void 0 : object.key);
10
+ };
11
+ class TrackunitIrisAppWebpackPlugin {
12
+ constructor(options) {
13
+ this.options = options;
14
+ }
15
+ apply(compiler) {
16
+ const pluginName = TrackunitIrisAppWebpackPlugin.name;
17
+ // webpack module instance can be accessed from the compiler object,
18
+ // this ensures that correct version of the module is used
19
+ // (do not require/import the webpack or any symbols from it directly).
20
+ const { webpack } = compiler;
21
+ // Compilation object gives us reference to some useful constants.
22
+ const { Compilation } = webpack;
23
+ // RawSource is one of the "sources" classes that should be used
24
+ // to represent asset sources in compilation.
25
+ const { RawSource } = webpack.sources;
26
+ // Tapping to the "thisCompilation" hook in order to further tap
27
+ // to the compilation process on an earlier stage.
28
+ compiler.hooks.thisCompilation.tap(pluginName, (compilation) => {
29
+ // Tapping to the assets processing pipeline on a specific stage.
30
+ compilation.hooks.processAssets.tap({
31
+ name: pluginName,
32
+ // Using one of the later asset processing stages to ensure
33
+ // that all assets were already added to the compilation by other plugins.
34
+ stage: Compilation.PROCESS_ASSETS_STAGE_DERIVED,
35
+ }, (assets) => tslib_1.__awaiter(this, void 0, void 0, function* () {
36
+ // "assets" is an object that contains all assets
37
+ // in the compilation, the keys of the object are pathnames of the assets
38
+ // and the values are file sources.
39
+ var _a, _b;
40
+ // Iterating over all the assets and
41
+ // generating content for our Markdown file.
42
+ if (!((_a = this.options) === null || _a === void 0 ? void 0 : _a.manifest)) {
43
+ throw Error("you must provide a app manifest");
44
+ }
45
+ const manifest = this.options.manifest;
46
+ const indexContents = fs.readFileSync(path.join(__dirname, "index.html"), "utf8");
47
+ const manifestJson = this.options.manifest;
48
+ manifestJson.extensions = this.options.manifest.extensions;
49
+ (_b = this.options.manifest.extensions) === null || _b === void 0 ? void 0 : _b.forEach(extension => {
50
+ var _a;
51
+ if (extension.menuItem && extension.menuItem.name) {
52
+ if (isTranslationKey(extension.menuItem.name)) {
53
+ const menuItemName = extension.menuItem.name;
54
+ const menuItemNameKey = menuItemName.key;
55
+ iris_app_api_1.translationKeys.forEach(langugageCode => {
56
+ const translationFilePath = path.join(extension.sourceRoot, "locales", langugageCode, "translation.json");
57
+ if (fs.existsSync(translationFilePath)) {
58
+ const translations = JSON.parse(fs.readFileSync(translationFilePath, "utf8"));
59
+ extension.menuItem.name[langugageCode] = translations[menuItemNameKey];
60
+ }
61
+ });
62
+ delete menuItemName.key;
63
+ }
64
+ if (extension.type === "REPORT_EXTENSION" && isTranslationKey((_a = extension.menuItem) === null || _a === void 0 ? void 0 : _a.description)) {
65
+ const description = extension.menuItem.description;
66
+ const menuItemDescriptionKey = description.key;
67
+ iris_app_api_1.translationKeys.forEach(langugageCode => {
68
+ const translationFilePath = path.join(extension.sourceRoot, "locales", langugageCode, "translation.json");
69
+ if (fs.existsSync(translationFilePath)) {
70
+ const translations = JSON.parse(fs.readFileSync(translationFilePath, "utf8"));
71
+ extension.menuItem.description[langugageCode] = translations[menuItemDescriptionKey];
72
+ }
73
+ });
74
+ delete description.key;
75
+ }
76
+ }
77
+ });
78
+ manifestJson.extensions = this.options.manifest.extensions;
79
+ compilation.emitAsset("manifest.json", new RawSource(JSON.stringify(manifestJson, null, 2)));
80
+ const packageJson = fs.readFileSync(`${this.options.appDir}/package.json`, "utf8");
81
+ compilation.emitAsset("package.json", new RawSource(packageJson));
82
+ let html = indexContents.replace("{{validDomains}}", manifest.validDomains.join(" "));
83
+ html = html.replace("{{scope}}", JSON.parse(packageJson).name);
84
+ // Adding new asset to the compilation, so it would be automatically
85
+ // generated by the webpack in the output directory.
86
+ compilation.emitAsset("index.html", new RawSource(html));
87
+ }));
88
+ });
89
+ }
90
+ }
91
+ exports.TrackunitIrisAppWebpackPlugin = TrackunitIrisAppWebpackPlugin;
92
+ //# sourceMappingURL=TrackunitIrisAppWebpackPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TrackunitIrisAppWebpackPlugin.js","sourceRoot":"","sources":["../../../../../../libs/iris-app-sdk/iris-app-webpack-plugin/src/lib/TrackunitIrisAppWebpackPlugin.ts"],"names":[],"mappings":";;;;AAAA,0DAAyG;AACzG,+CAAyB;AACzB,mDAA6B;AAS7B,MAAM,gBAAgB,GAAG,CAAC,MAA0D,EAA4B,EAAE;IAChH,OAAO,CAAC,CAAC,CAAC,MAA2B,aAA3B,MAAM,uBAAN,MAAM,CAAuB,GAAG,CAAA,CAAC;AAC7C,CAAC,CAAC;AAEF,MAAa,6BAA6B;IACxC,YAA2B,OAA8C;QAA9C,YAAO,GAAP,OAAO,CAAuC;IAAG,CAAC;IAEtE,KAAK,CAAC,QAAqB;QAChC,MAAM,UAAU,GAAG,6BAA6B,CAAC,IAAI,CAAC;QAEtD,oEAAoE;QACpE,0DAA0D;QAC1D,uEAAuE;QACvE,MAAM,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAC;QAE7B,kEAAkE;QAClE,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;QAEhC,gEAAgE;QAChE,6CAA6C;QAC7C,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;QAEtC,gEAAgE;QAChE,kDAAkD;QAClD,QAAQ,CAAC,KAAK,CAAC,eAAe,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,WAA2B,EAAE,EAAE;YAC7E,iEAAiE;YACjE,WAAW,CAAC,KAAK,CAAC,aAAa,CAAC,GAAG,CACjC;gBACE,IAAI,EAAE,UAAU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EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;gBAE7F,MAAM,WAAW,GAAG,EAAE,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,eAAe,EAAE,MAAM,CAAC,CAAC;gBACnF,WAAW,CAAC,SAAS,CAAC,cAAc,EAAE,IAAI,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC;gBAElE,IAAI,IAAI,GAAG,aAAa,CAAC,OAAO,CAAC,kBAAkB,EAAE,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;gBACtF,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC;gBAC/D,oEAAoE;gBACpE,oDAAoD;gBACpD,WAAW,CAAC,SAAS,CAAC,YAAY,EAAE,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;YAC3D,CAAC,CAAA,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAtGD,sEAsGC","sourcesContent":["import { IrisAppManifest, TranslationKey, translationKeys, Translations } from \"@trackunit/iris-app-api\";\nimport * as fs from \"fs\";\nimport * as path from \"path\";\nimport * as wp from \"webpack\";\n\ninterface ITrackunitIrisAppWebpackPluginOptions {\n nxRootDir: string;\n appDir: string;\n manifest: IrisAppManifest;\n}\n\nconst isTranslationKey = (object: string | Translations | TranslationKey | undefined): object is TranslationKey => {\n return !!(object as { key?: string })?.key;\n};\n\nexport class TrackunitIrisAppWebpackPlugin {\n public constructor(private options: ITrackunitIrisAppWebpackPluginOptions) {}\n\n public apply(compiler: wp.Compiler) {\n const pluginName = TrackunitIrisAppWebpackPlugin.name;\n\n // webpack module instance can be accessed from the compiler object,\n // this ensures that correct version of the module is used\n // (do not require/import the webpack or any symbols from it directly).\n const { webpack } = compiler;\n\n // Compilation object gives us reference to some useful constants.\n const { Compilation } = webpack;\n\n // RawSource is one of the \"sources\" classes that should be used\n // to represent asset sources in compilation.\n const { RawSource } = webpack.sources;\n\n // Tapping to the \"thisCompilation\" hook in order to further tap\n // to the compilation process on an earlier stage.\n compiler.hooks.thisCompilation.tap(pluginName, (compilation: wp.Compilation) => {\n // Tapping to the assets processing pipeline on a specific stage.\n compilation.hooks.processAssets.tap(\n {\n name: pluginName,\n\n // Using one of the later asset processing stages to ensure\n // that all assets were already added to the compilation by other plugins.\n stage: Compilation.PROCESS_ASSETS_STAGE_DERIVED,\n },\n async assets => {\n // \"assets\" is an object that contains all assets\n // in the compilation, the keys of the object are pathnames of the assets\n // and the values are file sources.\n\n // Iterating over all the assets and\n // generating content for our Markdown file.\n if (!this.options?.manifest) {\n throw Error(\"you must provide a app manifest\");\n }\n const manifest = this.options.manifest;\n const indexContents = fs.readFileSync(path.join(__dirname, \"index.html\"), \"utf8\");\n\n const manifestJson = this.options.manifest;\n manifestJson.extensions = this.options.manifest.extensions;\n\n this.options.manifest.extensions?.forEach(extension => {\n if (extension.menuItem && extension.menuItem.name) {\n if (isTranslationKey(extension.menuItem.name)) {\n const menuItemName = extension.menuItem.name;\n const menuItemNameKey = menuItemName.key;\n\n translationKeys.forEach(langugageCode => {\n const translationFilePath = path.join(\n extension.sourceRoot,\n \"locales\",\n langugageCode,\n \"translation.json\"\n );\n if (fs.existsSync(translationFilePath)) {\n const translations = JSON.parse(fs.readFileSync(translationFilePath, \"utf8\"));\n extension.menuItem.name[langugageCode] = translations[menuItemNameKey];\n }\n });\n delete (menuItemName as { key?: string }).key;\n }\n if (extension.type === \"REPORT_EXTENSION\" && isTranslationKey(extension.menuItem?.description)) {\n const description = extension.menuItem.description;\n const menuItemDescriptionKey = description.key;\n\n translationKeys.forEach(langugageCode => {\n const translationFilePath = path.join(\n extension.sourceRoot,\n \"locales\",\n langugageCode,\n \"translation.json\"\n );\n if (fs.existsSync(translationFilePath)) {\n const translations = JSON.parse(fs.readFileSync(translationFilePath, \"utf8\"));\n extension.menuItem.description[langugageCode] = translations[menuItemDescriptionKey];\n }\n });\n delete (description as { key?: string }).key;\n }\n }\n });\n\n manifestJson.extensions = this.options.manifest.extensions;\n compilation.emitAsset(\"manifest.json\", new RawSource(JSON.stringify(manifestJson, null, 2)));\n\n const packageJson = fs.readFileSync(`${this.options.appDir}/package.json`, \"utf8\");\n compilation.emitAsset(\"package.json\", new RawSource(packageJson));\n\n let html = indexContents.replace(\"{{validDomains}}\", manifest.validDomains.join(\" \"));\n html = html.replace(\"{{scope}}\", JSON.parse(packageJson).name);\n // Adding new asset to the compilation, so it would be automatically\n // generated by the webpack in the output directory.\n compilation.emitAsset(\"index.html\", new RawSource(html));\n }\n );\n });\n }\n}\n"]}
@@ -0,0 +1,14 @@
1
+ <html>
2
+ <head>
3
+ <script>
4
+ module = location.pathname.split('/')[1];
5
+ scope = "{{scope}}";
6
+ </script>
7
+ <base href="/"></base>
8
+ <script src="/remoteEntry.js"></script>
9
+ <script src="https://apps.dev.iris.trackunit.com/tileloader.js"></script>
10
+ <meta http-equiv="Content-Security-Policy" content="default-src 'self' 'unsafe-inline' {{validDomains}};">
11
+ </head>
12
+ <body style="margin: 0px">
13
+ </body>
14
+ </html>