@c8y/devkit 1019.0.3

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.
Files changed (196) hide show
  1. package/README.md +13 -0
  2. package/dist/builders.json +29 -0
  3. package/dist/index.d.ts +6 -0
  4. package/dist/index.js +11 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/options.d.ts +2 -0
  7. package/dist/options.js +6 -0
  8. package/dist/options.js.map +1 -0
  9. package/dist/src/builders/BuilderOptions.d.ts +90 -0
  10. package/dist/src/builders/BuilderOptions.js +3 -0
  11. package/dist/src/builders/BuilderOptions.js.map +1 -0
  12. package/dist/src/builders/browser/index.d.ts +2 -0
  13. package/dist/src/builders/browser/index.js +17 -0
  14. package/dist/src/builders/browser/index.js.map +1 -0
  15. package/dist/src/builders/browser/schema.json +606 -0
  16. package/dist/src/builders/compile-i18n/compile-i18n-builder.d.ts +5 -0
  17. package/dist/src/builders/compile-i18n/compile-i18n-builder.js +88 -0
  18. package/dist/src/builders/compile-i18n/compile-i18n-builder.js.map +1 -0
  19. package/dist/src/builders/compile-i18n/schema.json +24 -0
  20. package/dist/src/builders/create-schema.d.ts +1 -0
  21. package/dist/src/builders/create-schema.js +32 -0
  22. package/dist/src/builders/create-schema.js.map +1 -0
  23. package/dist/src/builders/deploy/Deploy.model.d.ts +30 -0
  24. package/dist/src/builders/deploy/Deploy.model.js +8 -0
  25. package/dist/src/builders/deploy/Deploy.model.js.map +1 -0
  26. package/dist/src/builders/deploy/app-as-zip-file.d.ts +8 -0
  27. package/dist/src/builders/deploy/app-as-zip-file.js +74 -0
  28. package/dist/src/builders/deploy/app-as-zip-file.js.map +1 -0
  29. package/dist/src/builders/deploy/build-and-zip-app.d.ts +10 -0
  30. package/dist/src/builders/deploy/build-and-zip-app.js +105 -0
  31. package/dist/src/builders/deploy/build-and-zip-app.js.map +1 -0
  32. package/dist/src/builders/deploy/deploy-builder.d.ts +5 -0
  33. package/dist/src/builders/deploy/deploy-builder.js +268 -0
  34. package/dist/src/builders/deploy/deploy-builder.js.map +1 -0
  35. package/dist/src/builders/deploy/helpers.d.ts +25 -0
  36. package/dist/src/builders/deploy/helpers.js +45 -0
  37. package/dist/src/builders/deploy/helpers.js.map +1 -0
  38. package/dist/src/builders/deploy/schema.json +42 -0
  39. package/dist/src/builders/dev-server/index.d.ts +2 -0
  40. package/dist/src/builders/dev-server/index.js +67 -0
  41. package/dist/src/builders/dev-server/index.js.map +1 -0
  42. package/dist/src/builders/dev-server/schema.json +120 -0
  43. package/dist/src/builders/extract-i18n/extract-i18n-builder.d.ts +5 -0
  44. package/dist/src/builders/extract-i18n/extract-i18n-builder.js +126 -0
  45. package/dist/src/builders/extract-i18n/extract-i18n-builder.js.map +1 -0
  46. package/dist/src/builders/extract-i18n/schema.json +30 -0
  47. package/dist/src/options.d.ts +82 -0
  48. package/dist/src/options.js +98 -0
  49. package/dist/src/options.js.map +1 -0
  50. package/dist/src/schematics/collection.json +9 -0
  51. package/dist/src/schematics/ng-add/configs/angular-json.d.ts +28 -0
  52. package/dist/src/schematics/ng-add/configs/angular-json.js +93 -0
  53. package/dist/src/schematics/ng-add/configs/angular-json.js.map +1 -0
  54. package/dist/src/schematics/ng-add/configs/app-module.d.ts +3 -0
  55. package/dist/src/schematics/ng-add/configs/app-module.js +13 -0
  56. package/dist/src/schematics/ng-add/configs/app-module.js.map +1 -0
  57. package/dist/src/schematics/ng-add/configs/app-routing.d.ts +2 -0
  58. package/dist/src/schematics/ng-add/configs/app-routing.js +16 -0
  59. package/dist/src/schematics/ng-add/configs/app-routing.js.map +1 -0
  60. package/dist/src/schematics/ng-add/configs/index-html.d.ts +2 -0
  61. package/dist/src/schematics/ng-add/configs/index-html.js +15 -0
  62. package/dist/src/schematics/ng-add/configs/index-html.js.map +1 -0
  63. package/dist/src/schematics/ng-add/configs/index.d.ts +2 -0
  64. package/dist/src/schematics/ng-add/configs/index.js +37 -0
  65. package/dist/src/schematics/ng-add/configs/index.js.map +1 -0
  66. package/dist/src/schematics/ng-add/configs/main.d.ts +2 -0
  67. package/dist/src/schematics/ng-add/configs/main.js +30 -0
  68. package/dist/src/schematics/ng-add/configs/main.js.map +1 -0
  69. package/dist/src/schematics/ng-add/configs/ng1.d.ts +3 -0
  70. package/dist/src/schematics/ng-add/configs/ng1.js +13 -0
  71. package/dist/src/schematics/ng-add/configs/ng1.js.map +1 -0
  72. package/dist/src/schematics/ng-add/configs/package-json.d.ts +17 -0
  73. package/dist/src/schematics/ng-add/configs/package-json.js +67 -0
  74. package/dist/src/schematics/ng-add/configs/package-json.js.map +1 -0
  75. package/dist/src/schematics/ng-add/configs/translation.d.ts +2 -0
  76. package/dist/src/schematics/ng-add/configs/translation.js +36 -0
  77. package/dist/src/schematics/ng-add/configs/translation.js.map +1 -0
  78. package/dist/src/schematics/ng-add/configs/tsconfig-app-json.d.ts +2 -0
  79. package/dist/src/schematics/ng-add/configs/tsconfig-app-json.js +21 -0
  80. package/dist/src/schematics/ng-add/configs/tsconfig-app-json.js.map +1 -0
  81. package/dist/src/schematics/ng-add/configs/tsconfig-json.d.ts +2 -0
  82. package/dist/src/schematics/ng-add/configs/tsconfig-json.js +19 -0
  83. package/dist/src/schematics/ng-add/configs/tsconfig-json.js.map +1 -0
  84. package/dist/src/schematics/ng-add/index.d.ts +4 -0
  85. package/dist/src/schematics/ng-add/index.js +93 -0
  86. package/dist/src/schematics/ng-add/index.js.map +1 -0
  87. package/dist/src/schematics/ng-add/model.d.ts +19 -0
  88. package/dist/src/schematics/ng-add/model.js +3 -0
  89. package/dist/src/schematics/ng-add/model.js.map +1 -0
  90. package/dist/src/schematics/ng-add/ng-add.json +18 -0
  91. package/dist/src/schematics/ng-add/utils.d.ts +13 -0
  92. package/dist/src/schematics/ng-add/utils.js +32 -0
  93. package/dist/src/schematics/ng-add/utils.js.map +1 -0
  94. package/dist/src/utils/locale-compiler.d.ts +48 -0
  95. package/dist/src/utils/locale-compiler.js +83 -0
  96. package/dist/src/utils/locale-compiler.js.map +1 -0
  97. package/dist/src/utils/locale-json-paths.d.ts +19 -0
  98. package/dist/src/utils/locale-json-paths.js +63 -0
  99. package/dist/src/utils/locale-json-paths.js.map +1 -0
  100. package/dist/src/utils/locale-utils.d.ts +24 -0
  101. package/dist/src/utils/locale-utils.js +104 -0
  102. package/dist/src/utils/locale-utils.js.map +1 -0
  103. package/dist/src/utils/package-config.d.ts +1 -0
  104. package/dist/src/utils/package-config.js +13 -0
  105. package/dist/src/utils/package-config.js.map +1 -0
  106. package/dist/src/webpack/ApplicationOptions.d.ts +344 -0
  107. package/dist/src/webpack/ApplicationOptions.js +3 -0
  108. package/dist/src/webpack/ApplicationOptions.js.map +1 -0
  109. package/dist/src/webpack/BuildDefaults.d.ts +10 -0
  110. package/dist/src/webpack/BuildDefaults.js +15 -0
  111. package/dist/src/webpack/BuildDefaults.js.map +1 -0
  112. package/dist/src/webpack/EnvironmentOptions.d.ts +132 -0
  113. package/dist/src/webpack/EnvironmentOptions.js +15 -0
  114. package/dist/src/webpack/EnvironmentOptions.js.map +1 -0
  115. package/dist/src/webpack/config/babel.d.ts +2 -0
  116. package/dist/src/webpack/config/babel.js +65 -0
  117. package/dist/src/webpack/config/babel.js.map +1 -0
  118. package/dist/src/webpack/config/base.d.ts +27 -0
  119. package/dist/src/webpack/config/base.js +125 -0
  120. package/dist/src/webpack/config/base.js.map +1 -0
  121. package/dist/src/webpack/config/development.d.ts +4 -0
  122. package/dist/src/webpack/config/development.js +37 -0
  123. package/dist/src/webpack/config/development.js.map +1 -0
  124. package/dist/src/webpack/config/extra.d.ts +3 -0
  125. package/dist/src/webpack/config/extra.js +24 -0
  126. package/dist/src/webpack/config/extra.js.map +1 -0
  127. package/dist/src/webpack/config/favicon.d.ts +2 -0
  128. package/dist/src/webpack/config/favicon.js +20 -0
  129. package/dist/src/webpack/config/favicon.js.map +1 -0
  130. package/dist/src/webpack/config/federation.d.ts +3 -0
  131. package/dist/src/webpack/config/federation.js +66 -0
  132. package/dist/src/webpack/config/federation.js.map +1 -0
  133. package/dist/src/webpack/config/legacy.d.ts +2 -0
  134. package/dist/src/webpack/config/legacy.js +72 -0
  135. package/dist/src/webpack/config/legacy.js.map +1 -0
  136. package/dist/src/webpack/config/plugin.d.ts +5 -0
  137. package/dist/src/webpack/config/plugin.js +89 -0
  138. package/dist/src/webpack/config/plugin.js.map +1 -0
  139. package/dist/src/webpack/config/production.d.ts +3 -0
  140. package/dist/src/webpack/config/production.js +30 -0
  141. package/dist/src/webpack/config/production.js.map +1 -0
  142. package/dist/src/webpack/config/styles.d.ts +3 -0
  143. package/dist/src/webpack/config/styles.js +54 -0
  144. package/dist/src/webpack/config/styles.js.map +1 -0
  145. package/dist/src/webpack/config/translation.d.ts +2 -0
  146. package/dist/src/webpack/config/translation.js +23 -0
  147. package/dist/src/webpack/config/translation.js.map +1 -0
  148. package/dist/src/webpack/loaders/loader-data.d.ts +1 -0
  149. package/dist/src/webpack/loaders/loader-data.js +53 -0
  150. package/dist/src/webpack/loaders/loader-data.js.map +1 -0
  151. package/dist/src/webpack/loaders/loader-less.d.ts +1 -0
  152. package/dist/src/webpack/loaders/loader-less.js +23 -0
  153. package/dist/src/webpack/loaders/loader-less.js.map +1 -0
  154. package/dist/src/webpack/loaders/loader-manifest.d.ts +1 -0
  155. package/dist/src/webpack/loaders/loader-manifest.js +88 -0
  156. package/dist/src/webpack/loaders/loader-manifest.js.map +1 -0
  157. package/dist/src/webpack/loaders/loader-ngtemplate.d.ts +1 -0
  158. package/dist/src/webpack/loaders/loader-ngtemplate.js +16 -0
  159. package/dist/src/webpack/loaders/loader-ngtemplate.js.map +1 -0
  160. package/dist/src/webpack/loaders/loader-pluginpath.d.ts +1 -0
  161. package/dist/src/webpack/loaders/loader-pluginpath.js +10 -0
  162. package/dist/src/webpack/loaders/loader-pluginpath.js.map +1 -0
  163. package/dist/src/webpack/loaders/loader-po.d.ts +3 -0
  164. package/dist/src/webpack/loaders/loader-po.js +9 -0
  165. package/dist/src/webpack/loaders/loader-po.js.map +1 -0
  166. package/dist/src/webpack/plugin/index-content.d.ts +2 -0
  167. package/dist/src/webpack/plugin/index-content.js +113 -0
  168. package/dist/src/webpack/plugin/index-content.js.map +1 -0
  169. package/dist/src/webpack/plugin/locales.d.ts +6 -0
  170. package/dist/src/webpack/plugin/locales.js +746 -0
  171. package/dist/src/webpack/plugin/locales.js.map +1 -0
  172. package/dist/src/webpack/plugin/plugin.d.ts +259 -0
  173. package/dist/src/webpack/plugin/plugin.js +286 -0
  174. package/dist/src/webpack/plugin/plugin.js.map +1 -0
  175. package/dist/src/webpack/plugin/translation-aggregation-plugin.d.ts +80 -0
  176. package/dist/src/webpack/plugin/translation-aggregation-plugin.js +152 -0
  177. package/dist/src/webpack/plugin/translation-aggregation-plugin.js.map +1 -0
  178. package/dist/src/webpack/plugin/translation-data-store.d.ts +27 -0
  179. package/dist/src/webpack/plugin/translation-data-store.js +37 -0
  180. package/dist/src/webpack/plugin/translation-data-store.js.map +1 -0
  181. package/dist/src/webpack/utils/federationUtils.d.ts +26 -0
  182. package/dist/src/webpack/utils/federationUtils.js +234 -0
  183. package/dist/src/webpack/utils/federationUtils.js.map +1 -0
  184. package/dist/src/webpack/utils/helpers.d.ts +45 -0
  185. package/dist/src/webpack/utils/helpers.js +137 -0
  186. package/dist/src/webpack/utils/helpers.js.map +1 -0
  187. package/dist/src/webpack/utils/index.d.ts +1 -0
  188. package/dist/src/webpack/utils/index.js +5 -0
  189. package/dist/src/webpack/utils/index.js.map +1 -0
  190. package/dist/src/webpack/utils/legacy-manifest-resolver.d.ts +4 -0
  191. package/dist/src/webpack/utils/legacy-manifest-resolver.js +27 -0
  192. package/dist/src/webpack/utils/legacy-manifest-resolver.js.map +1 -0
  193. package/dist/src/webpack/utils/proxy.d.ts +2 -0
  194. package/dist/src/webpack/utils/proxy.js +39 -0
  195. package/dist/src/webpack/utils/proxy.js.map +1 -0
  196. package/package.json +99 -0
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TranslationAggregationPlugin = void 0;
4
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
5
+ // @ts-ignore
6
+ const angular_gettext_tools_1 = require("angular-gettext-tools");
7
+ const pofile = require("pofile");
8
+ const webpack_1 = require("webpack");
9
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
10
+ // @ts-ignore
11
+ const webpack_sources_1 = require("webpack-sources");
12
+ const translation_data_store_1 = require("./translation-data-store");
13
+ const translationDataStoreInstance = translation_data_store_1.TranslationDataStore.instance;
14
+ const PLUGIN_NAME = 'TranslationAggregationPlugin';
15
+ /**
16
+ * TranslationAggregationPlugin is a Webpack plugin that processes .po files
17
+ * and extracts translation headers and items.
18
+ */
19
+ class TranslationAggregationPlugin {
20
+ constructor() {
21
+ /**
22
+ * `groupedPos` is an object that stores PO file objects indexed by their respective language keys.
23
+ * The key represents the language code (e.g., 'en', 'fr', 'de'), and the value is the parsed PO file
24
+ * content as a `pofile.PO` instance. This structure allows efficient access to the PO files for each
25
+ * language when generating translation assets.
26
+ */
27
+ this.groupedPos = {};
28
+ }
29
+ /**
30
+ * The `apply` method is called by Webpack when this plugin is used.
31
+ * @param compiler - The Webpack compiler instance.
32
+ */
33
+ apply(compiler) {
34
+ compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
35
+ compilation.hooks.finishModules.tapPromise(PLUGIN_NAME, async (_modules) => {
36
+ await this.handlePoFiles(compilation);
37
+ this.createTranslationAssets(compilation);
38
+ compiler.sharedData = this.groupedPos;
39
+ });
40
+ });
41
+ }
42
+ /**
43
+ * Creates translation assets based on the .po files and adds them to the compilation.
44
+ * The assets are generated in the format <language>.json and included in the production bundle.
45
+ *
46
+ * @param compilation - The Webpack compilation object.
47
+ */
48
+ createTranslationAssets(compilation) {
49
+ const { assets } = compilation;
50
+ // Iterate over the compiled translations for each language.
51
+ this.compile().forEach(({ language, json }) => {
52
+ // Add a new asset for the current language with the JSON content.
53
+ assets[`${language}.json`] = new webpack_sources_1.RawSource(json);
54
+ });
55
+ }
56
+ /**
57
+ * Compiles the grouped PO files into JSON format using `angular-gettext-tools`.
58
+ * @returns An array of objects containing the language code and the JSON representation of the translations.
59
+ */
60
+ compile() {
61
+ const grouped = this.groupedPos;
62
+ return Object.entries(grouped).map(([language, po]) => ({
63
+ language,
64
+ json: new angular_gettext_tools_1.Compiler({ format: 'json' }).convertPo([po.toString()])
65
+ }));
66
+ }
67
+ /**
68
+ * Processes the content of a PO file and updates the grouped PO data structure.
69
+ * @param {string} content - The PO file content.
70
+ * @param {string} srcPath - The source path of the PO file.
71
+ * @returns {pofile.PO} - The updated PO data structure.
72
+ */
73
+ processPoFile(content, srcPath) {
74
+ const po = pofile.parse(content);
75
+ const grouped = this.groupedPos;
76
+ translationDataStoreInstance.groupedPos = this.groupedPos;
77
+ const { Language } = po.headers;
78
+ if (Language && !grouped[Language]) {
79
+ grouped[Language] = new pofile();
80
+ }
81
+ if (Language) {
82
+ const finalPo = grouped[Language];
83
+ Object.assign(finalPo.headers, po.headers);
84
+ finalPo.items = this.getCombinedItems(finalPo.items, po.items, srcPath);
85
+ return finalPo;
86
+ }
87
+ throw new Error(`No language defined in po file header: ${srcPath}`);
88
+ }
89
+ /**
90
+ * Processes the PO files.
91
+ * @param {Compilation} compilation - Webpack compilation object.
92
+ */
93
+ async handlePoFiles(compilation) {
94
+ const poFileModules = this.getPoFileModules(compilation);
95
+ for (const poModule of poFileModules) {
96
+ if (poModule instanceof webpack_1.NormalModule) {
97
+ const poFilePath = poModule.resource;
98
+ const poFileContent = JSON.parse(poModule.originalSource()?.source());
99
+ if (poFileContent) {
100
+ this.processPoFile(poFileContent, poFilePath);
101
+ }
102
+ }
103
+ }
104
+ }
105
+ /**
106
+ * Returns an array of PO file modules.
107
+ * @param {Compilation} compilation - Webpack compilation object.
108
+ * @returns {Array<Module>} - Array of PO file modules.
109
+ */
110
+ getPoFileModules(compilation) {
111
+ return Array.from(compilation.modules).filter(module => module instanceof webpack_1.NormalModule && module.identifier().endsWith('.po'));
112
+ }
113
+ /**
114
+ * Combines two arrays of PO items, ignoring duplicates from the source array.
115
+ * @param destItems - The destination array of PO items.
116
+ * @param srcItems - The source array of PO items.
117
+ * @param srcPath - The path to the .po file.
118
+ * @returns An array of combined PO items.
119
+ */
120
+ getCombinedItems(destItems, srcItems, srcPath) {
121
+ const fromNodeModules = /node_modules\/@c8y/.test(srcPath);
122
+ if (fromNodeModules) {
123
+ return this.addUniqueAndIgnoreDuplicates(destItems, srcItems);
124
+ }
125
+ else {
126
+ return this.addUniqueAndOverwriteDuplicates(destItems, srcItems);
127
+ }
128
+ }
129
+ /**
130
+ * Adds unique items from the source array to the destination array, ignoring duplicates.
131
+ * @param destItems - The destination array of PO items.
132
+ * @param srcItems - The source array of PO items.
133
+ * @returns An array of combined PO items with duplicates ignored.
134
+ */
135
+ addUniqueAndIgnoreDuplicates(destItems, srcItems) {
136
+ const uniqueSrcItems = srcItems.filter(item => !destItems.some(({ msgid }) => msgid === item.msgid));
137
+ return [...destItems, ...uniqueSrcItems];
138
+ }
139
+ /**
140
+ * Adds unique items from the source array to the destination array, overwriting duplicates.
141
+ * @param destItems - The destination array of PO items.
142
+ * @param srcItems - The source array of PO items.
143
+ * @returns An array of combined PO items with duplicates overwritten.
144
+ */
145
+ addUniqueAndOverwriteDuplicates(destItems, srcItems) {
146
+ const uniqueDestItems = destItems.filter(item => !srcItems.some(({ msgid }) => msgid === item.msgid));
147
+ return [...uniqueDestItems, ...srcItems];
148
+ }
149
+ }
150
+ exports.TranslationAggregationPlugin = TranslationAggregationPlugin;
151
+ exports.default = TranslationAggregationPlugin;
152
+ //# sourceMappingURL=translation-aggregation-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translation-aggregation-plugin.js","sourceRoot":"","sources":["../../../../src/webpack/plugin/translation-aggregation-plugin.ts"],"names":[],"mappings":";;;AAAA,6DAA6D;AAC7D,aAAa;AACb,iEAAgF;AAChF,iCAAiC;AACjC,qCA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G,SAAS,CAAC,MAAM,CACtC,IAAI,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK,CAAC,CAC5D,CAAC;QACF,OAAO,CAAC,GAAG,eAAe,EAAE,GAAG,QAAQ,CAAC,CAAC;IAC3C,CAAC;CACF;AA5JD,oEA4JC;AAED,kBAAe,4BAA4B,CAAC"}
@@ -0,0 +1,27 @@
1
+ import * as pofile from 'pofile';
2
+ /**
3
+ * A class that stores and manages translation data shared between
4
+ * multiple webpack plugins.
5
+ */
6
+ export declare class TranslationDataStore {
7
+ private static _instance;
8
+ private _groupedPos;
9
+ /**
10
+ * Gets the instance of TranslationDataStore.
11
+ */
12
+ static get instance(): TranslationDataStore;
13
+ /**
14
+ * Gets the grouped PO files.
15
+ * @returns The grouped PO files as an object with language keys and PO file values.
16
+ */
17
+ get groupedPos(): {
18
+ [key: string]: pofile.PO;
19
+ };
20
+ /**
21
+ * Sets the grouped PO files.
22
+ * @param value - The new grouped PO files as an object with language keys and PO file values.
23
+ */
24
+ set groupedPos(value: {
25
+ [key: string]: pofile.PO;
26
+ });
27
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TranslationDataStore = void 0;
4
+ /**
5
+ * A class that stores and manages translation data shared between
6
+ * multiple webpack plugins.
7
+ */
8
+ class TranslationDataStore {
9
+ constructor() {
10
+ this._groupedPos = {};
11
+ }
12
+ /**
13
+ * Gets the instance of TranslationDataStore.
14
+ */
15
+ static get instance() {
16
+ if (!TranslationDataStore._instance) {
17
+ TranslationDataStore._instance = new TranslationDataStore();
18
+ }
19
+ return TranslationDataStore._instance;
20
+ }
21
+ /**
22
+ * Gets the grouped PO files.
23
+ * @returns The grouped PO files as an object with language keys and PO file values.
24
+ */
25
+ get groupedPos() {
26
+ return this._groupedPos;
27
+ }
28
+ /**
29
+ * Sets the grouped PO files.
30
+ * @param value - The new grouped PO files as an object with language keys and PO file values.
31
+ */
32
+ set groupedPos(value) {
33
+ this._groupedPos = value;
34
+ }
35
+ }
36
+ exports.TranslationDataStore = TranslationDataStore;
37
+ //# sourceMappingURL=translation-data-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translation-data-store.js","sourceRoot":"","sources":["../../../../src/webpack/plugin/translation-data-store.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACH,MAAa,oBAAoB;IAAjC;QAEU,gBAAW,GAAiC,EAAE,CAAC;IA2BzD,CAAC;IAzBC;;OAEG;IACH,MAAM,KAAK,QAAQ;QACjB,IAAI,CAAC,oBAAoB,CAAC,SAAS,EAAE;YACnC,oBAAoB,CAAC,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;SAC7D;QACD,OAAO,oBAAoB,CAAC,SAAS,CAAC;IACxC,CAAC;IAED;;;OAGG;IACH,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACH,IAAI,UAAU,CAAC,KAAmC;QAChD,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;IAC3B,CAAC;CACF;AA7BD,oDA6BC"}
@@ -0,0 +1,26 @@
1
+ import * as federationUtils from './federationUtils';
2
+ import { Configuration } from 'webpack';
3
+ import { C8yBrowserBuilderOptions } from '../../builders/BuilderOptions';
4
+ interface Dependency {
5
+ name: string;
6
+ version: string;
7
+ pkgJsonVersion: string;
8
+ path: string;
9
+ }
10
+ interface SimpleDependencyList {
11
+ [key: string]: string;
12
+ }
13
+ export declare function buildConfigForFederation(configuration: Configuration): Configuration;
14
+ export interface SharedDependencies {
15
+ [key: string]: {
16
+ requiredVersion: string;
17
+ singleton: boolean;
18
+ strictVersion: boolean;
19
+ version: string;
20
+ };
21
+ }
22
+ export declare function getSharedDependencies(buildOptions: C8yBrowserBuilderOptions): SharedDependencies;
23
+ export declare function getSharedDependenciesFromNames(names: string[]): federationUtils.SharedDependencies;
24
+ export declare function getSharedDependenciesMetaDataFromName(depKey: string, sharedDependenciesFromPackageJson?: SimpleDependencyList): Dependency | undefined;
25
+ export declare function getVersion(depKey: string, sharedDependenciesFromPackageJson?: SimpleDependencyList): any;
26
+ export {};
@@ -0,0 +1,234 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getVersion = exports.getSharedDependenciesMetaDataFromName = exports.getSharedDependenciesFromNames = exports.getSharedDependencies = exports.buildConfigForFederation = void 0;
4
+ const path = require("path");
5
+ const fs = require("fs-extra");
6
+ const lodash_1 = require("lodash");
7
+ // I know this looks wired, but it's for testing and seems to be an accepted approach:
8
+ // Base problem is: You cannot mock require calls in Jest.
9
+ // https://stackoverflow.com/questions/39755439/how-to-mock-imported-named-function-in-jest-when-module-is-unmocked/65243744#65243744
10
+ const federationUtils = require("./federationUtils");
11
+ const chalk = require("chalk");
12
+ function buildConfigForFederation(configuration) {
13
+ const { entry } = configuration;
14
+ /**
15
+ * Workaround: "Resolved Uncaught Error: Shared Module Unavailable for Eager Consumption".
16
+ * Angular includes @angular/compiler in the polyfills list, triggering a network request for the polyfills.js file.
17
+ * This file attempts to load the @angular/compiler module, which is not available at the moment.
18
+ */
19
+ if (entry?.polyfills) {
20
+ delete entry.polyfills;
21
+ }
22
+ return {
23
+ output: {
24
+ ...configuration.output,
25
+ publicPath: 'auto',
26
+ scriptType: 'text/javascript'
27
+ },
28
+ optimization: {
29
+ ...configuration.optimization,
30
+ runtimeChunk: false
31
+ }
32
+ };
33
+ }
34
+ exports.buildConfigForFederation = buildConfigForFederation;
35
+ const excludedSubDependencies = [];
36
+ const excludedDependenciesObj = {
37
+ 'libphonenumber-js': true,
38
+ 'zone.js': true,
39
+ three: true
40
+ };
41
+ const dontResolveVersion = {
42
+ rxjs: true
43
+ };
44
+ // Todo, check if still valid.
45
+ const snapshotRegexp = new RegExp(/-SNAPSHOT.0$/);
46
+ function getSharedDependencies(buildOptions) {
47
+ const rootPackageJsonPath = getRootPackageJsonPath(buildOptions);
48
+ const sharedDependenciesFromPackageJson = resolveDependencies(path.resolve(rootPackageJsonPath, 'package.json'));
49
+ const dependencies = Object.keys(sharedDependenciesFromPackageJson)
50
+ .map(key => getSharedDependenciesMetaDataFromName(key))
51
+ .filter(Boolean);
52
+ const dependenciesWithSubmodules = getDependenciesWithSubmodules(dependencies);
53
+ const flatDependenciesListWithSubmodules = transformDependenciesWithSubmodules(dependenciesWithSubmodules, buildOptions.buildTime?.federation === 'strict');
54
+ return flatDependenciesListWithSubmodules;
55
+ }
56
+ exports.getSharedDependencies = getSharedDependencies;
57
+ function getSharedDependenciesFromNames(names) {
58
+ const dependencies = names
59
+ .map(name => getSharedDependenciesMetaDataFromName(name))
60
+ .filter(Boolean);
61
+ const dependenciesWithSubmodules = getDependenciesWithSubmodules(dependencies);
62
+ const flatDependenciesListWithSubmodules = transformDependenciesWithSubmodules(dependenciesWithSubmodules, false);
63
+ return flatDependenciesListWithSubmodules;
64
+ }
65
+ exports.getSharedDependenciesFromNames = getSharedDependenciesFromNames;
66
+ function getSharedDependenciesMetaDataFromName(depKey, sharedDependenciesFromPackageJson) {
67
+ let version;
68
+ if (excludedDependenciesObj[depKey]) {
69
+ return undefined;
70
+ }
71
+ try {
72
+ version = federationUtils.getVersion(depKey, sharedDependenciesFromPackageJson);
73
+ }
74
+ catch (ex) {
75
+ console.warn(`${chalk.yellow('Warning')}: Dependency ${depKey} cannot be resolved for module federation sharing.`);
76
+ return undefined;
77
+ }
78
+ // remove -SNAPSHOT extension of c8y package versions to allow module federation with SNAPSHOT versions
79
+ if (depKey.startsWith('@c8y/') && snapshotRegexp.test(version)) {
80
+ version = version.replace(snapshotRegexp, '');
81
+ }
82
+ return {
83
+ name: depKey,
84
+ version,
85
+ pkgJsonVersion: sharedDependenciesFromPackageJson
86
+ ? sharedDependenciesFromPackageJson[depKey]
87
+ : version,
88
+ path: path.dirname(require.resolve(`${depKey}/package.json`))
89
+ };
90
+ }
91
+ exports.getSharedDependenciesMetaDataFromName = getSharedDependenciesMetaDataFromName;
92
+ function getVersion(depKey, sharedDependenciesFromPackageJson) {
93
+ if (sharedDependenciesFromPackageJson && dontResolveVersion[depKey]) {
94
+ return sharedDependenciesFromPackageJson[depKey];
95
+ }
96
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
97
+ return require(`${depKey}/package.json`).version;
98
+ }
99
+ exports.getVersion = getVersion;
100
+ function getRootPackageJsonPath(env) {
101
+ const cwd = /\.\m?[j|t]s$/.test(env.main) ? path.dirname(env.main) : env.main;
102
+ let pathToPackageJson = cwd;
103
+ while (!fs.existsSync(path.resolve(pathToPackageJson, 'package.json'))) {
104
+ pathToPackageJson = path.resolve(pathToPackageJson, '..');
105
+ if (pathToPackageJson === path.resolve('/')) {
106
+ throw new Error(`No package.json could be resolved from the main ${env.main}`);
107
+ }
108
+ }
109
+ return pathToPackageJson;
110
+ }
111
+ function resolveDependencies(filePath) {
112
+ const packageJson = fs.readJsonSync(filePath);
113
+ let dependencies = packageJson.dependencies;
114
+ // In our mono-repo the dependencies are in a folder one level up.
115
+ try {
116
+ const parentPath = path.join(filePath, '..', '..', 'package.json');
117
+ if (fileExist(parentPath)) {
118
+ const packageParentJson = fs.readJsonSync(parentPath);
119
+ if (packageParentJson.name === '@c8y/apps') {
120
+ dependencies = packageParentJson.dependencies;
121
+ }
122
+ }
123
+ }
124
+ catch (ex) {
125
+ dependencies = packageJson.dependencies;
126
+ }
127
+ // ngx-components sadly has atm it's own dependencies (should be shared dependencies)
128
+ // the following function resolves them to also share them in a module federation setup.
129
+ const ngxComponentsDependencies = resolveDependenciesFromNgxComponents() || {};
130
+ return { ...ngxComponentsDependencies, ...(dependencies || {}) };
131
+ }
132
+ function fileExist(filePath) {
133
+ return fs.existsSync(filePath);
134
+ }
135
+ function resolveDependenciesFromNgxComponents() {
136
+ const pathToNgxComponents = require.resolve('@c8y/ngx-components/package.json');
137
+ if (fileExist(pathToNgxComponents)) {
138
+ const packageJson = fs.readJsonSync(pathToNgxComponents);
139
+ return packageJson.dependencies;
140
+ }
141
+ return {};
142
+ }
143
+ function getDependenciesWithSubmodules(dependenciesWithResolvedPaths) {
144
+ return dependenciesWithResolvedPaths.map(resolvedDependency => {
145
+ const { path: depPath } = resolvedDependency;
146
+ let submodules = getRawSubmodules(depPath);
147
+ if (resolvedDependency.name.match('ngx-components')) {
148
+ // getC8ySubmoduleName transforms ngx-components submodules names into @c8y/ngx-components/... form.
149
+ submodules = submodules.map(submodule => getC8ySubmoduleName(submodule, 'ngx-components'));
150
+ }
151
+ if (submodules.length > 0) {
152
+ return { dependency: resolvedDependency, submodules };
153
+ }
154
+ return { dependency: resolvedDependency };
155
+ });
156
+ }
157
+ function transformDependenciesWithSubmodules(dependenciesWithSubmodules, strictVersion) {
158
+ return (0, lodash_1.reduce)(dependenciesWithSubmodules, (allDependenciesObj, currentVal) => {
159
+ const { dependency: { name, version, pkgJsonVersion }, submodules } = currentVal;
160
+ // Sometimes resolving errors could lead to the original version. To avoid issues, we remove the ^ or ~
161
+ const cleanVersion = cleanVersionPrefix(version);
162
+ const sharedDependencyDef = {
163
+ requiredVersion: getRequiredVersionPrefix(name, version, pkgJsonVersion) + cleanVersion,
164
+ singleton: true,
165
+ strictVersion,
166
+ version: cleanVersion
167
+ // eager: true TODO, check if needed.
168
+ };
169
+ allDependenciesObj[name] = sharedDependencyDef;
170
+ if (submodules) {
171
+ submodules.forEach(submodule => {
172
+ allDependenciesObj[submodule] = sharedDependencyDef;
173
+ });
174
+ }
175
+ return allDependenciesObj;
176
+ }, {});
177
+ }
178
+ function cleanVersionPrefix(version) {
179
+ return version.replace('^', '').replace('~', '');
180
+ }
181
+ function getRequiredVersionPrefix(dependency, version, originalVersion) {
182
+ if (originalVersion.startsWith('^') || originalVersion.startsWith('~')) {
183
+ return originalVersion[0];
184
+ }
185
+ if (dependency.startsWith('@c8y')) {
186
+ return '^';
187
+ }
188
+ return '~';
189
+ }
190
+ function getC8ySubmoduleName(submodule, submoduleName) {
191
+ const tokens = submodule.split('/');
192
+ const index = tokens.indexOf(submoduleName);
193
+ const ngxComponentsSubmodule = tokens.slice(index + 1, tokens.length).join('/');
194
+ return `@c8y/ngx-components/${ngxComponentsSubmodule}`;
195
+ }
196
+ function getRawSubmodules(depResolvedPath) {
197
+ return findSecondaries(depResolvedPath, excludedSubDependencies)
198
+ .filter(submodule => isDistFolderDependency(submodule))
199
+ .map(submodule => getSubmoduleNestedUpToFourLevelsDeep(submodule));
200
+ }
201
+ function isDistFolderDependency(submodule) {
202
+ return !submodule.match('/dist');
203
+ }
204
+ function getSubmoduleNestedUpToFourLevelsDeep(submodule) {
205
+ // i.e. cumulocity-ui/packages/ngx-components/binary-file-download
206
+ // TODO find better way of getting submodule name
207
+ const splitedSubmodulePath = submodule.split('/');
208
+ return (0, lodash_1.takeRight)(splitedSubmodulePath, 4).join('/');
209
+ }
210
+ /**
211
+ * Source:
212
+ * https://github.com/angular-architects/module-federation-plugin/blob/790d0e4a20c54b570267c036ddd20154556e959d/libs/mf/src/utils/share-utils.ts#L49
213
+ */
214
+ function findSecondaries(libPath, excludes) {
215
+ const acc = [];
216
+ _findSecondaries(libPath, excludes, acc);
217
+ return acc;
218
+ }
219
+ function _findSecondaries(libPath, excludes, acc) {
220
+ const files = fs.readdirSync(libPath);
221
+ const dirs = files
222
+ .map(f => path.join(libPath, f))
223
+ .filter(f => fs.lstatSync(f).isDirectory() && f !== 'node_modules');
224
+ const secondaries = dirs.filter(d => fs.existsSync(path.join(d, 'package.json')));
225
+ for (const s of secondaries) {
226
+ const secondaryLibName = s.replace(/\\/g, '/').replace(/^.*node_modules[/]/, '');
227
+ if (excludes.includes(secondaryLibName)) {
228
+ continue;
229
+ }
230
+ acc.push(secondaryLibName);
231
+ _findSecondaries(s, excludes, acc);
232
+ }
233
+ }
234
+ //# sourceMappingURL=federationUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"federationUtils.js","sourceRoot":"","sources":["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gB,CAAC,CAAC,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC;KACpC;AACH,CAAC"}
@@ -0,0 +1,45 @@
1
+ import { BuilderContext } from '@angular-devkit/architect';
2
+ import { Path } from '@angular-devkit/core';
3
+ import { Configuration } from 'webpack';
4
+ import { EnvironmentOptions } from '../EnvironmentOptions';
5
+ import { C8yBrowserBuilderOptions, C8yDevServerBuilderOptions } from '../../builders/BuilderOptions';
6
+ /**
7
+ * Reads the package.json file on the project context and returns the c8y.application properties.
8
+ * @param projectContext The current used project context.
9
+ * @returns The application options.
10
+ */
11
+ export declare function getOptionsFromContext(projectContext: BuilderContext): Promise<EnvironmentOptions>;
12
+ /**
13
+ * Returns the current project root path.
14
+ * @param projectContext The current project context
15
+ * @returns The current root path.
16
+ */
17
+ export declare function getProjectRootPath(projectContext: BuilderContext): Promise<Path>;
18
+ /**
19
+ * Merges the option elements.
20
+ * @param options The current browser builder options
21
+ * @param env The current environment options
22
+ * @returns A merged C8yBrowserBuilderOptions.
23
+ */
24
+ export declare function migrateDeprecatedBrowserBuildOptions(options: C8yBrowserBuilderOptions, env: EnvironmentOptions): C8yBrowserBuilderOptions;
25
+ /**
26
+ * Merges the option elements for a dev server
27
+ * @param options The current dev builder options
28
+ * @param env The current environment options
29
+ * @returns A merged C8yDevServerBuilderOptions.
30
+ */
31
+ export declare function migrateDeprecatedDevServerOptions(options: C8yDevServerBuilderOptions, env: EnvironmentOptions): C8yDevServerBuilderOptions;
32
+ /**
33
+ * This function tries to load cumulocity.config.ts, .cumulocityrc.ts or package.json from the given path
34
+ * and retrieve application options and version from it.
35
+ * @param {Path} path - The path to try to retrieve the configuration file.
36
+ * @returns {Promise<EnvironmentOptions>} The current environment options
37
+ */
38
+ export declare function getPackageOptions(path: Path): Promise<EnvironmentOptions>;
39
+ export declare function getFileFromPath(rootPath: Path, fileName: string): Promise<any>;
40
+ /**
41
+ * Returns a configuration object for handling images.
42
+ *
43
+ * @returns Object webpack configuration for images.
44
+ */
45
+ export declare function buildImagesConfig(): Configuration;