@trackunit/iris-app-webpack-plugin 0.0.120-alpha-ea50faef71.0 → 0.0.120

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,8 +2,11 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
- ## [0.0.120-alpha-ea50faef71.0](https://github.com/Trackunit/manager/compare/iris-app-webpack-plugin/0.0.119...iris-app-webpack-plugin/0.0.120-alpha-ea50faef71.0) (2023-08-14)
5
+ ## [0.0.120](https://github.com/Trackunit/manager/compare/iris-app-webpack-plugin/0.0.119...iris-app-webpack-plugin/0.0.120) (2023-08-23)
6
6
 
7
+ ### Dependency Updates
8
+
9
+ * `iris-app-api` updated to version `0.0.107`
7
10
  ## [0.0.119](https://github.com/Trackunit/manager/compare/iris-app-webpack-plugin/0.0.118...iris-app-webpack-plugin/0.0.119) (2023-08-01)
8
11
 
9
12
  ### Dependency Updates
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/iris-app-webpack-plugin",
3
- "version": "0.0.120-alpha-ea50faef71.0",
3
+ "version": "0.0.120",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "repository": "https://github.com/Trackunit/manager",
6
6
  "engines": {
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "dependencies": {
10
10
  "csp-header": "^5.1.0",
11
- "@trackunit/iris-app-api": "0.0.107-alpha-ea50faef71.0",
11
+ "@trackunit/iris-app-api": "0.0.107",
12
12
  "tslib": "1.10.0"
13
13
  },
14
14
  "main": "./src/index.js",
@@ -19,9 +19,9 @@ export declare class TrackunitIrisAppWebpackPlugin {
19
19
  *
20
20
  @class
21
21
  @public
22
- @param {Object} options - Plugin options object
22
+ @param {object} options - Plugin options object
23
23
  @param {string} options.appDir - Directory path where the app resides
24
- @param {Object} options.manifest - Object containing the app's manifest
24
+ @param {object} options.manifest - Object containing the app's manifest
25
25
  */
26
26
  apply(compiler: wp.Compiler): void;
27
27
  }
@@ -24,9 +24,9 @@ class TrackunitIrisAppWebpackPlugin {
24
24
  *
25
25
  @class
26
26
  @public
27
- @param {Object} options - Plugin options object
27
+ @param {object} options - Plugin options object
28
28
  @param {string} options.appDir - Directory path where the app resides
29
- @param {Object} options.manifest - Object containing the app's manifest
29
+ @param {object} options.manifest - Object containing the app's manifest
30
30
  */
31
31
  apply(compiler) {
32
32
  const pluginName = TrackunitIrisAppWebpackPlugin.name;
@@ -64,9 +64,14 @@ class TrackunitIrisAppWebpackPlugin {
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
66
  var _a;
67
- if (extension.type !== "IRIS_APP_SETTINGS_EXTENSION" && extension.menuItem && extension.menuItem.name) {
68
- if (isTranslationKey(extension.menuItem.name)) {
69
- const menuItemName = extension.menuItem.name;
67
+ const translationKey = (extension.type !== "IRIS_APP_SETTINGS_EXTENSION" &&
68
+ extension.type !== "WIDGET_EXTENSION" &&
69
+ extension.menuItem &&
70
+ extension.menuItem.name) ||
71
+ (extension.type === "WIDGET_EXTENSION" && extension.header && extension.header.name);
72
+ if (translationKey) {
73
+ if (isTranslationKey(translationKey)) {
74
+ const menuItemName = translationKey;
70
75
  const menuItemNameKey = menuItemName.key;
71
76
  iris_app_api_1.languageKeys.forEach(langugageCode => {
72
77
  const translationFilePath = path.join(extension.sourceRoot, "locales", langugageCode, "translation.json");
@@ -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;IA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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;AAxHD,sEAwHC","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 if (extension.type !== \"IRIS_APP_SETTINGS_EXTENSION\" && extension.menuItem && extension.menuItem.name) {\n if (isTranslationKey(extension.menuItem.name)) {\n const menuItemName = extension.menuItem.name;\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,MAAM,UAAU,GAAG,6BAA6B,CAAC,IAAI,CAAC;QAEtD,oEAAoE;QACpE,0DAA0D;QAC1D,uEAAuE;QACvE,MAAM,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAC;QAE7B,kEAAkE;QAClE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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"]}