@wavemaker/angular-app 12.0.0-next.141221 → 12.0.0-next.47809

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/angular.json CHANGED
@@ -21,7 +21,7 @@
21
21
  "outputPath": "dist/ng-bundle",
22
22
  "index": {
23
23
  "input": "src/index.html",
24
- "output": "../index.html"
24
+ "output": "../../index.html"
25
25
  },
26
26
  "main": "src/main.ts",
27
27
  "polyfills": "src/polyfills.ts",
@@ -32,13 +32,13 @@
32
32
  "src/assets",
33
33
  {
34
34
  "glob": "**/*",
35
- "input": "libraries/locales/",
36
- "output": "/locales/"
35
+ "input": "libraries/locales/moment-timezone",
36
+ "output": "/locales/moment-timezone"
37
37
  },
38
38
  {
39
39
  "glob": "**/*",
40
- "input": "node_modules/@wavemaker/app-ng-runtime/locales/",
41
- "output": "/locales/"
40
+ "input": "node_modules/@wavemaker/app-ng-runtime/locales/moment-timezone",
41
+ "output": "/locales/moment-timezone"
42
42
  },
43
43
  {
44
44
  "glob": "**/*",
@@ -75,7 +75,6 @@
75
75
  }
76
76
  ],
77
77
  "scripts": [
78
- "./node_modules/x2js/x2js.js",
79
78
  "./node_modules/d3/dist/d3.min.js",
80
79
  "./node_modules/@wavemaker/nvd3/build/nv.d3.min.js",
81
80
  "./node_modules/jquery/dist/jquery.min.js",
@@ -94,9 +93,6 @@
94
93
  "./node_modules/@wavemaker/app-ng-runtime/scripts/datatable/datatable.js",
95
94
  "./node_modules/@wavemaker/app-ng-runtime/scripts/swipey/swipey.jquery.plugin.js",
96
95
  "./node_modules/@wavemaker/app-ng-runtime/scripts/jquery.ui.touch-punch/jquery.ui.touch-punch.min.js",
97
- "./node_modules/moment/min/moment.min.js",
98
- "./node_modules/moment-timezone/builds/moment-timezone.min.js",
99
- "./node_modules/fullcalendar/main.min.js",
100
96
  "./node_modules/summernote/dist/summernote-lite.min.js",
101
97
  "./node_modules/hammerjs/hammer.min.js",
102
98
  "./node_modules/iscroll/build/iscroll.js",
@@ -243,9 +239,6 @@
243
239
  "./node_modules/jquery-ui/ui/widgets/sortable.js",
244
240
  "./node_modules/jquery-ui/ui/widgets/droppable.js",
245
241
  "./libraries/scripts/datatable/datatable.js",
246
- "./node_modules/moment/min/moment.min.js",
247
- "./node_modules/moment-timezone/builds/moment-timezone.min.js",
248
- "./node_modules/fullcalendar/main.min.js",
249
242
  "./node_modules/summernote/dist/summernote-lite.min.js",
250
243
  "./node_modules/hammerjs/hammer.min.js",
251
244
  "./node_modules/iscroll/build/iscroll.js",
@@ -6,6 +6,7 @@ if (processArgs.findIndex(arg => arg.startsWith('--max-old-space-size')) !== -1)
6
6
  process.env.NODE_OPTIONS = processArgs.pop();
7
7
  console.log("Setting node options: ", process.env.NODE_OPTIONS);
8
8
  }
9
+
9
10
  const args = processArgs.slice(2);
10
11
  const ngBuildArgs = ['build', ...args];
11
12
  console.log("\x1b[33m", "Angular build params: ", ngBuildArgs);
@@ -6,94 +6,11 @@ const copyFile = util.promisify(fs.copyFile);
6
6
  const exec = util.promisify(require('child_process').exec);
7
7
  const cheerio = require(`cheerio`);
8
8
  const crypto = require(`crypto`);
9
- const opPath = `${process.cwd()}/dist/ng-bundle`;
10
- const copyCssFiles = (hash, updatedFilenames) => {
11
- const filename = 'wm-styles.css';
12
- const updatedFilename = `wm-styles.${hash}.css`
13
- copyFile(`${opPath}/${filename}`, `${opPath}/${updatedFilename}`);
14
- updatedFilenames[filename] = updatedFilename;
15
- // copyFile(`${opPath}/wm-styles.br.css`,`${opPath}/wm-styles.${hash}.br.css`);
16
- // copyFile(`${opPath}/wm-styles.gzip.css`,`${opPath}/wm-styles.${hash}.gzip.css`);
17
- };
18
- const copyMobileCssFiles = (hash, fileName) => {
19
- // const name = filePath.split('.css')[0];
20
- copyFile(`${opPath}/${fileName}.css`, `${opPath}/${fileName}.${hash}.css`);
21
- // copyFile(`${opPath}/wm-styles.br.css`,`${opPath}/wm-styles.${hash}.br.css`);
22
- // copyFile(`${opPath}/wm-styles.gzip.css`,`${opPath}/wm-styles.${hash}.gzip.css`);
23
- };
24
- const generateHash = async (filepath) => {
25
- const cssContent = await readFile(filepath);
26
- let hash = crypto.createHash('md5');
27
- hash.update(cssContent);
28
- return hash.digest('hex');
29
- };
30
- const generateHashForScripts = (updatedFilenames) => {
31
- //from angular 12(IVY), scripts array in angular json, doesn't allow `@` symbol in the name/value
32
- //so removed `@` from wavemaker.com in the file name and adding it back in the post-build.js file
33
- const scriptsMap = {};
34
- return new Promise(resolve => {
35
- fs.readdir(opPath, (err, items) => {
36
- const promises = items.map(i => {
37
- const nohashIndex = i.indexOf('-NOHASH.js');
38
- if (nohashIndex > 0) {
39
- const key = i.substring(0, nohashIndex);
40
- return generateHash(`${opPath}/${i}`).then(hash => {
41
- const filename = `${key}-NOHASH.js`;
42
- const updatedFilename = `${key}.${hash}.js`
43
- scriptsMap[`${key}.js`] = updatedFilename;
44
- updatedFilenames[filename] = updatedFilename;
45
- return Promise.all([
46
- copyFile(`${opPath}/${filename}`, `${opPath}/${updatedFilename}`),
47
- // copyFile(`${opPath}/${key}-NOHASH.br.js`, `${opPath}/${key}.${hash}.br.js`),
48
- // copyFile(`${opPath}/${key}-NOHASH.gzip.js`, `${opPath}/${key}.${hash}.gzip.js`)
49
- ]);
50
- });
51
- }
52
- });
53
- Promise.all(promises).then(() => {
54
- return writeFile(`${opPath}/path_mapping.json`, JSON.stringify(scriptsMap, null, 2));
55
- }).then(resolve);
56
- });
57
- });
58
- };
59
- let isMobileProject = false;
9
+
60
10
  let isProdBuild;
61
11
  let isDevBuild;
62
12
  let $;
63
13
 
64
- const setMobileProjectType = (angularJson) => {
65
- let styles = angularJson['projects']['angular-app']['architect']['build']['options']['styles'];
66
- const androidStyles = styles.find((style) => {
67
- let isObject = typeof (style) === 'object';
68
- if (isObject) {
69
- return style.bundleName === 'wm-android-styles';
70
- }
71
- return false;
72
- });
73
- isMobileProject = androidStyles ? true : false;
74
- return isMobileProject;
75
- }
76
- const addMobileSpecificStyles = async (deployUrl) => {
77
- if (isDevBuild) {
78
- $("body").append(
79
- `<script type="text/javascript" defer="true" src="${deployUrl}wm-android-styles.js"></script>`
80
- );
81
- }
82
-
83
- if (isProdBuild) {
84
- let hash = await generateHash(`${opPath}/wm-android-styles.css`);
85
- copyMobileCssFiles(hash, 'wm-android-styles');
86
- $("head").append(
87
- `<link rel="stylesheet" theme="wmtheme" href="${deployUrl}wm-android-styles.${hash}.css" >`
88
- );
89
- hash = await generateHash(`${opPath}/wm-ios-styles.css`);
90
- copyMobileCssFiles(hash, 'wm-ios-styles');
91
- $("head").append(
92
- `<link rel="stylesheet" theme="wmtheme" href="${deployUrl}wm-ios-styles.${hash}.css" >`
93
- );
94
- }
95
- }
96
-
97
14
  const addScriptForWMStylesPath = (wm_styles_path) => {
98
15
  // wm_styles_path will not be present for mobile apps
99
16
  if (wm_styles_path) {
@@ -201,10 +118,10 @@ const updatePwaAssets = (deployUrl, updatedFileNames, updatedFileHashes) => {
201
118
  deployUrl = deployUrl === "_cdnUrl_" ? 'ng-bundle/' : deployUrl;
202
119
 
203
120
  // copy service worker and its config to root directory
204
- fs.copyFileSync('./dist/ng-bundle/ngsw-worker.js', './dist/ngsw-worker.js');
205
- fs.copyFileSync('./dist/ng-bundle/wmsw-worker.js', './dist/wmsw-worker.js');
206
- fs.copyFileSync('./dist/ng-bundle/ngsw.json', ngswPath);
207
- fs.copyFileSync('./dist/ng-bundle/manifest.json', manifestPath);
121
+ fs.copyFileSync(`./dist/ng-bundle/${global.randomHash}/ngsw-worker.js`, './dist/ngsw-worker.js');
122
+ fs.copyFileSync(`./dist/ng-bundle/${global.randomHash}/wmsw-worker.js`, './dist/wmsw-worker.js');
123
+ fs.copyFileSync(`./dist/ng-bundle/${global.randomHash}/ngsw.json`, ngswPath);
124
+ fs.copyFileSync(`./dist/ng-bundle/${global.randomHash}/manifest.json`, manifestPath);
208
125
 
209
126
  // update the icons url in manifest.json
210
127
  const manifest = JSON.parse(fs.readFileSync(manifestPath).toString());
@@ -248,17 +165,12 @@ const generateSha1 = (content) => {
248
165
  const angularJson = require(`${process.cwd()}/angular.json`);
249
166
  const build = angularJson['projects']['angular-app']['architect']['build'];
250
167
  let deployUrl = args['deploy-url'] || build['options']['deployUrl'];
251
-
168
+ global.randomHash = deployUrl.split('/')[1];
169
+ let outputPath = global.opPath = args['output-path'] || build['options']['outputPath']
252
170
  const contents = await readFile(`./dist/index.html`, `utf8`);
253
171
  $ = cheerio.load(contents);
254
- setMobileProjectType(angularJson);
255
- if (!isMobileProject) {
256
- isProdBuild = fs.existsSync(`${process.cwd()}/dist/ng-bundle/wm-styles.css`);
257
- isDevBuild = fs.existsSync(`${process.cwd()}/dist/ng-bundle/wm-styles.js`);
258
- } else {
259
- isDevBuild = fs.existsSync(`${process.cwd()}/dist/ng-bundle/wm-android-styles.js`);
260
- isProdBuild = fs.existsSync(`${process.cwd()}/dist/ng-bundle/wm-android-styles.css`);
261
- }
172
+ isProdBuild = fs.existsSync(`${process.cwd()}/${outputPath}/wm-styles.css`);
173
+ isDevBuild = fs.existsSync(`${process.cwd()}/${outputPath}/wm-styles.js`);
262
174
 
263
175
  if (isProdBuild) {
264
176
  const isOptimizeCss = $('meta[optimizecss]').length;
@@ -275,18 +187,12 @@ const generateSha1 = (content) => {
275
187
  const updatedFileHashes = {}
276
188
  let wm_styles_path;
277
189
 
278
- if (isMobileProject) {
279
- await addMobileSpecificStyles(deployUrl);
190
+ if (isDevBuild) {
191
+ wm_styles_path = `${deployUrl}wm-styles.js`;
280
192
  } else {
281
- if (isDevBuild) {
282
- wm_styles_path = `${deployUrl}wm-styles.js`;
283
- } else {
284
- const fileName = 'wm-styles';
285
- const hash = await generateHash(`${opPath}/${fileName}.css`);
286
- copyCssFiles(hash, updatedFilenames);
287
- const updatedFileName = `${fileName}.${hash}.css`
288
- wm_styles_path = `${deployUrl}${updatedFileName}`;
289
- }
193
+ const fileName = 'wm-styles';
194
+ const updatedFileName = `${fileName}.css`
195
+ wm_styles_path = `${deployUrl}${updatedFileName}`;
290
196
  }
291
197
 
292
198
  addScriptForWMStylesPath(wm_styles_path);
@@ -295,13 +201,11 @@ const generateSha1 = (content) => {
295
201
  //this is required to download all the assets
296
202
  $('head').append(`<meta name="deployUrl" content=${deployUrl} />`);
297
203
  $('script[src$="services/application/wmProperties.js"]').remove();
298
- $('link[href$="favicon.png"]').attr('href', './ng-bundle/favicon.png');
204
+ $('link[href$="favicon.png"]').attr('href', `${deployUrl}favicon.png`);
299
205
 
300
206
  const htmlContent = $.html();
301
207
  await writeFile(`./dist/index.html`, htmlContent);
302
208
 
303
- await generateHashForScripts(updatedFilenames);
304
-
305
209
  if (serviceWorkerEnabled) {
306
210
  // re-generate hash for index.html since its been modified
307
211
  updatedFileHashes['index.html'] = generateSha1(htmlContent);
@@ -1,28 +1,40 @@
1
- <ng-container *ngIf="startApp">
1
+ @if (startApp) {
2
+ @if(enableSkipToMainContent) {
3
+ <div id="app-focus-start" tabindex="-1"></div>
4
+ <a href="javascript:void(0);" class="skip" (click)="skipToAppContent($event)">{{appLocale.LABEL_SKIP_TO_MAIN_CONTENT || 'Skip to main content'}}</a>
5
+ }
2
6
  <router-outlet></router-outlet>
3
- <div wmContainer partialContainer content="Common" hidden class="ng-hide" *ngIf="isApplicationType"></div>
4
- <app-spinner name="globalspinner" classname="global-spinner" role="alert" aria-live="assertive" [attr.aria-label]="spinner.arialabel || 'Loading'" [show]="spinner.show" [spinnermessages]="spinner.messages"></app-spinner>
5
- <div wmDialog name="oAuthLoginDialog" title="Application is requesting you to sign in with"
6
- close.event="closeOAuthDialog()">
7
- <ng-template #dialogBody>
8
- <ul class="list-items">
9
- <li class="list-item" *ngFor="let provider of providersConfig">
10
- <button class="btn" (click)="provider.invoke()">{{provider.name}}</button>
11
- </li>
12
- </ul>
13
- </ng-template>
14
- </div>
15
- <div wmConfirmDialog name="_app-confirm-dialog" title.bind="title" message.bind="message" oktext.bind="oktext"
16
- canceltext.bind="canceltext" closable="false" iconclass.bind="iconclass"
17
- escape.event="onEscape()" ok.event="onOk()" cancel.event="onCancel()" close.event="onClose()" opened.event="onOpen()"></div>
18
- <div *ngIf="!isApplicationType" wmConfirmDialog name="PrefabConfirmDialog" title.bind="title" message.bind="text" oktext.bind="okButtonText"
19
- canceltext.bind="cancelButtonText" closable="false" iconclass.bind="iconclass"
20
- escape.event="onEscape()" ok.event="onOk()" cancel.event="onCancel()" close.event="onClose()" opened.event="onOpen()"></div>
21
- <div *ngIf="!isApplicationType" wmAlertDialog name="PrefabAlertDialog" title.bind="title" message.bind="text" oktext.bind="okButtonText"
22
- canceltext.bind="cancelButtonText" closable="false" iconclass.bind="iconclass"
23
- escape.event="onEscape()" ok.event="onOk()" cancel.event="onCancel()" close.event="onClose()" opened.event="onOpen()"></div>
24
- <div wmAppExt></div>
25
- <i id="wm-mobile-display"></i>
26
- </ng-container>
7
+ @if (isApplicationType) {
8
+ <div wmContainer partialContainer content="Common" hidden class="ng-hide"></div>
9
+ }
10
+ <app-spinner name="globalspinner" classname="global-spinner" role="alert" aria-live="assertive" [attr.aria-label]="spinner.arialabel || 'Loading'" [show]="spinner.show" [spinnermessages]="spinner.messages"></app-spinner>
11
+ <div wmDialog name="oAuthLoginDialog" title="Application is requesting you to sign in with"
12
+ close.event="closeOAuthDialog()">
13
+ <ng-template #dialogBody>
14
+ <ul class="list-items">
15
+ @for (provider of providersConfig; track provider) {
16
+ <li class="list-item">
17
+ <button class="btn" (click)="provider.invoke()">{{provider.name}}</button>
18
+ </li>
19
+ }
20
+ </ul>
21
+ </ng-template>
22
+ </div>
23
+ <div wmConfirmDialog name="_app-confirm-dialog" title.bind="title" message.bind="message" oktext.bind="oktext"
24
+ canceltext.bind="canceltext" closable="false" iconclass.bind="iconclass"
25
+ escape.event="onEscape()" ok.event="onOk()" cancel.event="onCancel()" close.event="onClose()" opened.event="onOpen()"></div>
26
+ @if (!isApplicationType) {
27
+ <div wmConfirmDialog name="PrefabConfirmDialog" title.bind="title" message.bind="text" oktext.bind="okButtonText"
28
+ canceltext.bind="cancelButtonText" closable="false" iconclass.bind="iconclass"
29
+ escape.event="onEscape()" ok.event="onOk()" cancel.event="onCancel()" close.event="onClose()" opened.event="onOpen()"></div>
30
+ }
31
+ @if (!isApplicationType) {
32
+ <div wmAlertDialog name="PrefabAlertDialog" title.bind="title" message.bind="text" oktext.bind="okButtonText"
33
+ canceltext.bind="cancelButtonText" closable="false" iconclass.bind="iconclass"
34
+ escape.event="onEscape()" ok.event="onOk()" cancel.event="onCancel()" close.event="onClose()" opened.event="onOpen()"></div>
35
+ }
36
+ <div wmAppExt></div>
37
+ <i id="wm-mobile-display"></i>
38
+ }
27
39
  <!--Dummy container to create the component dynamically-->
28
40
  <ng-container #dynamicComponent></ng-container>