@trackunit/iris-app-webpack-plugin 0.0.128 → 0.0.130

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 CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [0.0.130](https://github.com/Trackunit/manager/compare/iris-app-webpack-plugin/0.0.129...iris-app-webpack-plugin/0.0.130) (2023-09-21)
6
+
7
+ ### Dependency Updates
8
+
9
+ * `iris-app-api` updated to version `0.0.129`
10
+ ## [0.0.129](https://github.com/Trackunit/manager/compare/iris-app-webpack-plugin/0.0.128...iris-app-webpack-plugin/0.0.129) (2023-09-19)
11
+
12
+ ### Dependency Updates
13
+
14
+ * `iris-app-api` updated to version `0.0.128`
5
15
  ## [0.0.128](https://github.com/Trackunit/manager/compare/iris-app-webpack-plugin/0.0.127...iris-app-webpack-plugin/0.0.128) (2023-09-13)
6
16
 
7
17
  ### Dependency Updates
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/iris-app-webpack-plugin",
3
- "version": "0.0.128",
3
+ "version": "0.0.130",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "repository": "https://github.com/Trackunit/manager",
6
6
  "engines": {
@@ -8,8 +8,8 @@
8
8
  },
9
9
  "dependencies": {
10
10
  "csp-header": "^5.1.0",
11
- "@trackunit/iris-app-api": "0.0.115",
12
- "tslib": "1.10.0"
11
+ "@trackunit/iris-app-api": "0.0.117",
12
+ "tslib": "2.4.1"
13
13
  },
14
14
  "main": "./src/index.js",
15
15
  "type": "commonjs"
@@ -63,7 +63,7 @@ class TrackunitIrisAppWebpackPlugin {
63
63
  const manifestJson = this.options.manifest;
64
64
  manifestJson.extensions = this.options.manifest.extensions;
65
65
  (_b = this.options.manifest.extensions) === null || _b === void 0 ? void 0 : _b.forEach(extension => {
66
- var _a;
66
+ var _a, _b, _c;
67
67
  const translationKey = (extension.type !== "IRIS_APP_SETTINGS_EXTENSION" &&
68
68
  extension.type !== "WIDGET_EXTENSION" &&
69
69
  extension.menuItem &&
@@ -99,6 +99,32 @@ class TrackunitIrisAppWebpackPlugin {
99
99
  delete description.key;
100
100
  }
101
101
  }
102
+ if (extension.type === "ASSET_HOME_EXTENSION" || extension.type === "FLEET_EXTENSION") {
103
+ if ((_b = extension.conditions) === null || _b === void 0 ? void 0 : _b.brand) {
104
+ if (Array.isArray(extension.conditions.brand)) {
105
+ extension.conditions.brand.map(brand => {
106
+ if (typeof brand !== "string") {
107
+ brand.pattern = brand.pattern.toString();
108
+ }
109
+ });
110
+ }
111
+ else if (typeof extension.conditions.brand !== "string") {
112
+ extension.conditions.brand.pattern = extension.conditions.brand.pattern.toString();
113
+ }
114
+ }
115
+ if ((_c = extension.conditions) === null || _c === void 0 ? void 0 : _c.model) {
116
+ if (Array.isArray(extension.conditions.model)) {
117
+ extension.conditions.model.map(model => {
118
+ if (typeof model !== "string") {
119
+ model.pattern = model.pattern.toString();
120
+ }
121
+ });
122
+ }
123
+ else if (typeof extension.conditions.model !== "string") {
124
+ extension.conditions.model.pattern = extension.conditions.model.pattern.toString();
125
+ }
126
+ }
127
+ }
102
128
  });
103
129
  manifestJson.extensions = this.options.manifest.extensions;
104
130
  compilation.emitAsset("manifest.json", new RawSource(JSON.stringify(manifestJson, null, 2)));
@@ -1 +1 @@
1
- {"version":3,"file":"TrackunitIrisAppWebpackPlugin.js","sourceRoot":"","sources":["../../../../../../libs/iris-app-sdk/iris-app-webpack-plugin/src/lib/TrackunitIrisAppWebpackPlugin.ts"],"names":[],"mappings":";;;;AAAA,0DAAuH;AACvH,2CAAoC;AACpC,+CAAyB;AACzB,mDAA6B;AAS7B,MAAM,gBAAgB,GAAG,CAAC,MAA0D,EAA4B,EAAE;IAChH,OAAO,CAAC,CAAC,CAAC,MAA2B,aAA3B,MAAM,uBAAN,MAAM,CAAuB,GAAG,CAAA,CAA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BAAM,EAAC,IAAA,8BAAe,EAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC;gBAE3D,IAAI,IAAI,GAAG,aAAa,CAAC,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC;gBACxD,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;AA9HD,sEA8HC","sourcesContent":["import { irisAppCspInput, IrisAppManifest, languageKeys, TranslationKey, Translations } from \"@trackunit/iris-app-api\";\nimport { getCSP } from \"csp-header\";\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\n/**\n * Webpack plugin that generates a manifest.json file\n */\nexport class TrackunitIrisAppWebpackPlugin {\n /**\n * @param options - Plugin options\n */\n public constructor(private options: ITrackunitIrisAppWebpackPluginOptions) {}\n\n /**\n Webpack plugin for generating a Markdown file from app manifest and index HTML file.\n *\n @class\n @public\n @param {object} options - Plugin options object\n @param {string} options.appDir - Directory path where the app resides\n @param {object} options.manifest - Object containing the app's manifest\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 const translationKey =\n (extension.type !== \"IRIS_APP_SETTINGS_EXTENSION\" &&\n extension.type !== \"WIDGET_EXTENSION\" &&\n extension.menuItem &&\n extension.menuItem.name) ||\n (extension.type === \"WIDGET_EXTENSION\" && extension.header && extension.header.name);\n if (translationKey) {\n if (isTranslationKey(translationKey)) {\n const menuItemName = translationKey;\n const menuItemNameKey = menuItemName.key;\n\n languageKeys.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 //@ts-ignore - suppressImplicitAnyIndexErrors\n // Here we substitute the translation key with the actual translation\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 languageKeys.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 //@ts-ignore - suppressImplicitAnyIndexErrors\n // Here we substitute the translation key with the actual translation\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 const csp = getCSP(irisAppCspInput(manifest.validDomains));\n\n let html = indexContents.replace(\"{{cspContent}}\", csp);\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"]}
1
+ {"version":3,"file":"TrackunitIrisAppWebpackPlugin.js","sourceRoot":"","sources":["../../../../../../libs/iris-app-sdk/iris-app-webpack-plugin/src/lib/TrackunitIrisAppWebpackPlugin.ts"],"names":[],"mappings":";;;;AAAA,0DAAuH;AACvH,2CAAoC;AACpC,+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;;GAEG;AACH,MAAa,6BAA6B;IACxC;;OAEG;IACH,YAA2B,OAA8C;QAA9C,YAAO,GAAP,OAAO,CAAuC;IAAG,CAAC;IAE7E;;;;;;;;OAQG;IACI,KAAK,CAAC,QAAqB;QAChC,M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,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;AAtJD,sEAsJC","sourcesContent":["import { irisAppCspInput, IrisAppManifest, languageKeys, TranslationKey, Translations } from \"@trackunit/iris-app-api\";\nimport { getCSP } from \"csp-header\";\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\n/**\n * Webpack plugin that generates a manifest.json file\n */\nexport class TrackunitIrisAppWebpackPlugin {\n /**\n * @param options - Plugin options\n */\n public constructor(private options: ITrackunitIrisAppWebpackPluginOptions) {}\n\n /**\n Webpack plugin for generating a Markdown file from app manifest and index HTML file.\n *\n @class\n @public\n @param {object} options - Plugin options object\n @param {string} options.appDir - Directory path where the app resides\n @param {object} options.manifest - Object containing the app's manifest\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 const translationKey =\n (extension.type !== \"IRIS_APP_SETTINGS_EXTENSION\" &&\n extension.type !== \"WIDGET_EXTENSION\" &&\n extension.menuItem &&\n extension.menuItem.name) ||\n (extension.type === \"WIDGET_EXTENSION\" && extension.header && extension.header.name);\n if (translationKey) {\n if (isTranslationKey(translationKey)) {\n const menuItemName = translationKey;\n const menuItemNameKey = menuItemName.key;\n\n languageKeys.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 //@ts-ignore - suppressImplicitAnyIndexErrors\n // Here we substitute the translation key with the actual translation\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 languageKeys.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 //@ts-ignore - suppressImplicitAnyIndexErrors\n // Here we substitute the translation key with the actual translation\n extension.menuItem.description[langugageCode] = translations[menuItemDescriptionKey];\n }\n });\n delete (description as { key?: string }).key;\n }\n }\n if (extension.type === \"ASSET_HOME_EXTENSION\" || extension.type === \"FLEET_EXTENSION\") {\n if (extension.conditions?.brand) {\n if (Array.isArray(extension.conditions.brand)) {\n extension.conditions.brand.map(brand => {\n if (typeof brand !== \"string\") {\n brand.pattern = brand.pattern.toString();\n }\n });\n } else if (typeof extension.conditions.brand !== \"string\") {\n extension.conditions.brand.pattern = extension.conditions.brand.pattern.toString();\n }\n }\n if (extension.conditions?.model) {\n if (Array.isArray(extension.conditions.model)) {\n extension.conditions.model.map(model => {\n if (typeof model !== \"string\") {\n model.pattern = model.pattern.toString();\n }\n });\n } else if (typeof extension.conditions.model !== \"string\") {\n extension.conditions.model.pattern = extension.conditions.model.pattern.toString();\n }\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 const csp = getCSP(irisAppCspInput(manifest.validDomains));\n\n let html = indexContents.replace(\"{{cspContent}}\", csp);\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"]}