@trackunit/iris-app-webpack-plugin 0.0.36

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,16 @@
1
+ # Changelog
2
+
3
+ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
+
5
+ ### [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)
6
+
7
+ ### [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)
8
+
9
+ ### Dependency Updates
10
+
11
+ * `iris-app-api` updated to version `0.0.1`
12
+ ### [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)
13
+
14
+ ### Dependency Updates
15
+
16
+ * `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/package.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "@trackunit/iris-app-webpack-plugin",
3
+ "version": "0.0.36",
4
+ "license": "MIT",
5
+ "peerDependencies": {
6
+ "@trackunit/iris-app-api": "0.x",
7
+ "tslib": "^2.3.1"
8
+ },
9
+ "repository": "https://github.com/Trackunit/manager",
10
+ "main": "./src/index.js",
11
+ "typings": "./src/index.d.ts",
12
+ "dependencies": {}
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,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TrackunitIrisAppWebpackPlugin = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const fs = tslib_1.__importStar(require("fs"));
6
+ const path = tslib_1.__importStar(require("path"));
7
+ class TrackunitIrisAppWebpackPlugin {
8
+ constructor(options) {
9
+ this.options = options;
10
+ }
11
+ apply(compiler) {
12
+ const pluginName = TrackunitIrisAppWebpackPlugin.name;
13
+ // webpack module instance can be accessed from the compiler object,
14
+ // this ensures that correct version of the module is used
15
+ // (do not require/import the webpack or any symbols from it directly).
16
+ const { webpack } = compiler;
17
+ // Compilation object gives us reference to some useful constants.
18
+ const { Compilation } = webpack;
19
+ // RawSource is one of the "sources" classes that should be used
20
+ // to represent asset sources in compilation.
21
+ const { RawSource } = webpack.sources;
22
+ // Tapping to the "thisCompilation" hook in order to further tap
23
+ // to the compilation process on an earlier stage.
24
+ compiler.hooks.thisCompilation.tap(pluginName, (compilation) => {
25
+ // Tapping to the assets processing pipeline on a specific stage.
26
+ compilation.hooks.processAssets.tap({
27
+ name: pluginName,
28
+ // Using one of the later asset processing stages to ensure
29
+ // that all assets were already added to the compilation by other plugins.
30
+ stage: Compilation.PROCESS_ASSETS_STAGE_DERIVED,
31
+ }, (assets) => tslib_1.__awaiter(this, void 0, void 0, function* () {
32
+ // "assets" is an object that contains all assets
33
+ // in the compilation, the keys of the object are pathnames of the assets
34
+ // and the values are file sources.
35
+ var _a;
36
+ // Iterating over all the assets and
37
+ // generating content for our Markdown file.
38
+ if (!((_a = this.options) === null || _a === void 0 ? void 0 : _a.manifest)) {
39
+ throw Error("you must provide a app manifest");
40
+ }
41
+ const manifest = this.options.manifest;
42
+ const indexContents = fs.readFileSync(path.join(__dirname, "index.html"), "utf8");
43
+ const manifestJson = this.options.manifest;
44
+ manifestJson.extensions = this.options.manifest.extensions;
45
+ compilation.emitAsset("manifest.json", new RawSource(JSON.stringify(manifestJson, null, 2)));
46
+ const packageJson = fs.readFileSync(`${this.options.appDir}/package.json`, "utf8");
47
+ compilation.emitAsset("package.json", new RawSource(packageJson));
48
+ let html = indexContents.replace("{{validDomains}}", manifest.validDomains.join(" "));
49
+ html = html.replace("{{links}}", JSON.stringify(manifestJson.extensions.map(extension => {
50
+ return {
51
+ href: `?app=${manifestJson.moduleFederationName}&extension=${extension.id}`,
52
+ text: extension.id,
53
+ };
54
+ })));
55
+ // Adding new asset to the compilation, so it would be automatically
56
+ // generated by the webpack in the output directory.
57
+ compilation.emitAsset("index.html", new RawSource(html));
58
+ }));
59
+ });
60
+ }
61
+ }
62
+ exports.TrackunitIrisAppWebpackPlugin = TrackunitIrisAppWebpackPlugin;
63
+ //# 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":";;;;AACA,+CAAyB;AACzB,mDAA6B;AAS7B,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;gBAEhB,2DAA2D;gBAC3D,0EAA0E;gBAC1E,KAAK,EAAE,WAAW,CAAC,4BAA4B;aAChD,EACD,CAAM,MAAM,EAAC,EAAE;gBACb,iDAAiD;gBACjD,yEAAyE;gBACzE,mCAAmC;;gBAEnC,oCAAoC;gBACpC,4CAA4C;gBAC5C,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,QAAQ,CAAA,EAAE;oBAC3B,MAAM,KAAK,CAAC,iCAAiC,CAAC,CAAC;iBAChD;gBACD,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;gBACvC,MAAM,aAAa,GAAG,EAAE,CAAC,YAAY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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\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 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(\n \"{{links}}\",\n JSON.stringify(\n manifestJson.extensions.map(extension => {\n return {\n href: `?app=${manifestJson.moduleFederationName}&extension=${extension.id}`,\n text: extension.id,\n };\n })\n )\n );\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,17 @@
1
+ <html>
2
+ <head>
3
+ <script src="/remoteEntry.js"></script>
4
+ <script src="https://tiles.dev.iris.trackunit.com/tileloader.js"></script>
5
+ <meta http-equiv="Content-Security-Policy" content="default-src 'self' 'unsafe-inline' {{validDomains}};">
6
+ </head>
7
+ <body style="margin: 0px">
8
+ </body>
9
+ <script>
10
+ if(location.href.indexOf("?") === -1) {
11
+ const elem = document.createElement('span');
12
+ elem.innerHTML = '<b>Launch the manager in local mode for testing: <a href="https://dev.manager.trackunit.com/tiles-portal/main#runLocal">https://dev.manager.trackunit.com/tiles-portal/main#runLocal</a> </b>'
13
+ document.body.appendChild(elem);
14
+ document.body.style = "padding: 20px;"
15
+ }
16
+ </script>
17
+ </html>