@wavemaker/angular-codegen 11.1.0-next.24309 → 11.1.0-next.24312

Sign up to get free protection for your applications and to get access to all the features.
@@ -74,8 +74,8 @@ const setMobileProjectType = (angularJson) => {
74
74
  const addMobileSpecificStyles = async (deployUrl) => {
75
75
  if (isDevBuild) {
76
76
  $("body").append(
77
- `<script> const WMStylesPath ="${deployUrl}/wm-android-styles.js" </script>`
78
- )
77
+ `<script type="text/javascript" defer="true" src="${deployUrl}/wm-android-styles.js"></script>`
78
+ );
79
79
  }
80
80
 
81
81
  if (isProdBuild) {
@@ -92,40 +92,23 @@ const addMobileSpecificStyles = async (deployUrl) => {
92
92
  }
93
93
  }
94
94
 
95
- const addScriptForWMStylesPath = () => {
96
- // Add print css on load
97
- $("body").append(`<script>
98
- (function () {
99
- if (typeof WMStylesPath !== "undefined") {
100
- let styleType = WMStylesPath.split(".").pop();
101
- let styleNode;
102
- if(styleType==="css"){
103
- styleNode = document.createElement("link");
104
- styleNode.type = "text/css";
105
- styleNode.rel = "stylesheet";
106
- styleNode.href = WMStylesPath;
107
- }
108
- else if(styleType==="js"){
109
- styleNode = document.createElement("script");
110
- styleNode.type = "text/javascript";
111
- styleNode.src = WMStylesPath;
112
- styleNode.defer = true;
113
- }
114
-
115
- styleNode && document
116
- .getElementsByTagName("head")[0]
117
- .appendChild(styleNode);
118
- }
119
- })()
120
- window.onload = function() {
121
- var printCssNode = document.createElement('link');
122
- printCssNode.type = 'text/css';
123
- printCssNode.rel = 'stylesheet';
124
- printCssNode.href = 'print.css';
125
- printCssNode.media = 'print';
126
- document.getElementsByTagName("head")[0].appendChild(printCssNode);
127
- }
128
- </script>`);
95
+ const addScriptForWMStylesPath = (wm_styles_path) => {
96
+ // wm_styles_path will not be present for mobile apps
97
+ if (wm_styles_path) {
98
+ let styleType = wm_styles_path.split(".").pop();
99
+ if(styleType==="css"){
100
+ $("head").append(
101
+ `<link rel="stylesheet" type="text/css" href="${wm_styles_path}"/>`
102
+ );
103
+ } else {
104
+ $("body").append(
105
+ `<script type="text/javascript" defer="true" src="${wm_styles_path}"></script>`
106
+ );
107
+ }
108
+ }
109
+ $("head").append(
110
+ `<link rel="stylesheet" type="text/css" media="print" href="print.css"/>`
111
+ );
129
112
  }
130
113
 
131
114
  /**
@@ -155,9 +138,9 @@ const SKIP_UPDATE = ['index.html', 'manifest.json'];
155
138
  /**
156
139
  * Checks if a file's name has been changed during the build process
157
140
  * and if changed, returns an updated file path.
158
- *
141
+ *
159
142
  * @param {string} deployUrl deployment url
160
- * @param {string} url an absolute url to check if its filename has changed
143
+ * @param {string} url an absolute url to check if its filename has changed
161
144
  * @param {object} updatedFileNames a map from old filenames to new filenames
162
145
  * @returns {string} an updated file path
163
146
  */
@@ -176,8 +159,8 @@ const getUpdatedFileName = (deployUrl, url, updatedFileNames) => {
176
159
  /**
177
160
  * Checks if a file's content has been changed during the build process
178
161
  * and if changed, returns a new hash to be updated in ngsw.json
179
- *
180
- * @param {string} url an absolute url to check if its filename has changed
162
+ *
163
+ * @param {string} url an absolute url to check if its filename has changed
181
164
  * @param {object} updatedFileHashes a map from filenames to file hashes
182
165
  * @returns {string} an updated file hash
183
166
  */
@@ -191,7 +174,7 @@ const getUpdatedFileHashes = (url, oldHash, updatedFileHashes) => {
191
174
 
192
175
  /**
193
176
  * Get the path of the icon without '/ng-bundle'
194
- *
177
+ *
195
178
  * @param {string} iconPath path with '/ng-bundle'
196
179
  * @returns {string} path of the icon without '/ng-bundle'
197
180
  */
@@ -202,7 +185,7 @@ const getIconPath = (iconPath) => {
202
185
 
203
186
  /**
204
187
  * Updates name, location and content of PWA related assets.
205
- *
188
+ *
206
189
  * @param {string} deployUrl deployment url
207
190
  * @param {object} updatedFileNames a map from old filenames to new filenames
208
191
  * @returns {void}
@@ -245,7 +228,7 @@ const updatePwaAssets = (deployUrl, updatedFileNames, updatedFileHashes) => {
245
228
 
246
229
  /**
247
230
  * Generated sha1 hash for the content supplied.
248
- *
231
+ *
249
232
  * @param {string} content the content to be hashed
250
233
  * @returns {string} the hash value
251
234
  */
@@ -289,26 +272,23 @@ const generateSha1 = (content) => {
289
272
  const serviceWorkerEnabled = build['configurations']['production']['serviceWorker'];
290
273
  const updatedFilenames = {}
291
274
  const updatedFileHashes = {}
275
+ let wm_styles_path;
292
276
 
293
277
  if (isMobileProject) {
294
278
  await addMobileSpecificStyles(deployUrl);
295
279
  } else {
296
280
  if (isDevBuild) {
297
- $("head").append(
298
- `<script> const WMStylesPath = "${deployUrl}/wm-styles.js" </script>`
299
- )
281
+ wm_styles_path = `${deployUrl}/wm-styles.js`;
300
282
  } else {
301
283
  const fileName = 'wm-styles';
302
284
  const hash = await generateHash(`${opPath}/${fileName}.css`);
303
285
  copyCssFiles(hash, updatedFilenames);
304
286
  const updatedFileName = `${fileName}.${hash}.css`
305
- $("head").append(
306
- `<script> const WMStylesPath = "${deployUrl}/${updatedFileName}" </script>`
307
- );
287
+ wm_styles_path = `${deployUrl}/${updatedFileName}`;
308
288
  }
309
289
  }
310
290
 
311
- addScriptForWMStylesPath();
291
+ addScriptForWMStylesPath(wm_styles_path);
312
292
  const htmlContent = $.html();
313
293
  await writeFile(`./dist/index.html`, htmlContent);
314
294
 
@@ -68,7 +68,7 @@
68
68
  "tslib": "^2.0.0",
69
69
  "x2js": "3.2.6",
70
70
  "zone.js": "~0.11.4",
71
- "@wavemaker/app-ng-runtime": "11.1.0-next.24309"
71
+ "@wavemaker/app-ng-runtime": "11.1.0-next.24312"
72
72
  },
73
73
  "devDependencies": {
74
74
  "@ampproject/rollup-plugin-closure-compiler": "0.8.5",