@wavemaker-ai/angular-app 1.0.0-rc.309

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 (66) hide show
  1. package/.npmrc +1 -0
  2. package/angular.json +274 -0
  3. package/build-scripts/build.js +53 -0
  4. package/build-scripts/index-html-transform-ng-serve.ts +20 -0
  5. package/build-scripts/index-html-transform.js +28 -0
  6. package/build-scripts/ngx-bootstrap-patch.mjs +287 -0
  7. package/build-scripts/optimize-css.gulpfile.js +101 -0
  8. package/build-scripts/post-build.js +217 -0
  9. package/build-scripts/update-version.js +25 -0
  10. package/dependencies/app.component.html +40 -0
  11. package/dependencies/custom-widgets-bundle.cjs.js +421 -0
  12. package/dependencies/expression-parser.cjs.js +33229 -0
  13. package/dependencies/pipe-provider.cjs.js +220499 -0
  14. package/dependencies/transpilation-web.cjs.js +107428 -0
  15. package/dependency-report.html +124 -0
  16. package/generate-dependency-report.js +240 -0
  17. package/npm-shrinkwrap.json +25599 -0
  18. package/package-lock.json +25599 -0
  19. package/package.json +131 -0
  20. package/proxy.conf.js +14 -0
  21. package/pwa-assets/icons/icon-128x128.png +0 -0
  22. package/pwa-assets/icons/icon-144x144.png +0 -0
  23. package/pwa-assets/icons/icon-152x152.png +0 -0
  24. package/pwa-assets/icons/icon-192x192.png +0 -0
  25. package/pwa-assets/icons/icon-384x384.png +0 -0
  26. package/pwa-assets/icons/icon-512x512.png +0 -0
  27. package/pwa-assets/icons/icon-72x72.png +0 -0
  28. package/pwa-assets/icons/icon-96x96.png +0 -0
  29. package/pwa-assets/manifest.json +59 -0
  30. package/pwa-assets/ngsw-config.json +30 -0
  31. package/pwa-assets/wmsw-worker.js +24 -0
  32. package/src/.browserslistrc +12 -0
  33. package/src/app/app.component.css +0 -0
  34. package/src/app/app.component.script.js +3 -0
  35. package/src/app/app.component.variables.ts +3 -0
  36. package/src/app/app.routes.ts +5 -0
  37. package/src/app/lazy-load-scripts.resolve.ts +13 -0
  38. package/src/app/prefabs/prefab-config.js +2 -0
  39. package/src/app/wm-project-properties.ts +3 -0
  40. package/src/app/wmProperties.js +13 -0
  41. package/src/assets/.gitkeep +0 -0
  42. package/src/assets/print.css +32 -0
  43. package/src/environments/environment.dev.ts +3 -0
  44. package/src/environments/environment.prod.ts +3 -0
  45. package/src/environments/environment.ts +16 -0
  46. package/src/framework/services/app-extension.service.ts +20 -0
  47. package/src/framework/services/app-js-provider.service.ts +15 -0
  48. package/src/framework/services/app-variables-provider.service.ts +15 -0
  49. package/src/framework/services/component-ref-provider.service.ts +70 -0
  50. package/src/framework/services/customwidget-config-provider.service.ts +13 -0
  51. package/src/framework/services/lazy-component-ref-provider.service.ts +79 -0
  52. package/src/framework/services/prefab-config-provider.service.ts +13 -0
  53. package/src/framework/util/lazy-module-routes.ts +4 -0
  54. package/src/framework/util/page-util.ts +7 -0
  55. package/src/index.html +17 -0
  56. package/src/main.ts +70 -0
  57. package/src/polyfills.ts +53 -0
  58. package/src/setup-jest.js +121 -0
  59. package/src/styles.css +1 -0
  60. package/src/tsconfig.app.json +17 -0
  61. package/src/tslint.json +17 -0
  62. package/src/typings.d.ts +27 -0
  63. package/src/wm-namespace.js +13 -0
  64. package/tsconfig.json +94 -0
  65. package/tsconfig.web-app.json +81 -0
  66. package/wm-custom-webpack.config.js +51 -0
@@ -0,0 +1,101 @@
1
+ const gulp = require("gulp");
2
+ const filter = require("gulp-filter");
3
+ const purify = require("gulp-purify-css");
4
+ const gzip = require("gulp-gzip");
5
+ const brotli = require("gulp-brotli");
6
+ const rename = require("gulp-rename");
7
+ const clean = require("gulp-clean");
8
+ const { series, parallel } = require("gulp");
9
+
10
+ // #1 | Optimize CSS
11
+ gulp.task("css", () => {
12
+ return gulp
13
+ .src("../dist/ng-bundle/*")
14
+ .pipe(
15
+ filter([
16
+ "**/styles.*.css",
17
+ "**/wm-styles.css",
18
+ "!**/wm-styles.*.css",
19
+ "!**/*.br.*",
20
+ "!**/*.gzip.*"
21
+ ])
22
+ )
23
+ .pipe(
24
+ purify(["../dist/ng-bundle/*.js"], {
25
+ info: true,
26
+ minify: true,
27
+ rejected: true,
28
+ whitelist: []
29
+ })
30
+ )
31
+ .pipe(gulp.dest("../dist/test/"));
32
+ });
33
+ // # 2 | Genereate GZIP files
34
+ gulp.task("css-gzip", () => {
35
+ return gulp
36
+ .src("../dist/test/*")
37
+ .pipe(filter(["**/*.css", "!**/*.br.*", "!**/*.gzip.*"]))
38
+ .pipe(gzip({ append: false }))
39
+ .pipe(
40
+ rename(path => {
41
+ path.extname = ".gzip" + path.extname;
42
+ })
43
+ )
44
+ .pipe(gulp.dest("../dist/test/"));
45
+ });
46
+ // # 3 | Genereate BROTLI files
47
+ gulp.task("css-br", () => {
48
+ return gulp
49
+ .src("../dist/test/*")
50
+ .pipe(filter(["**/*.css", "!**/*.br.*", "!**/*.gzip.*"]))
51
+ .pipe(brotli.compress())
52
+ .pipe(
53
+ rename(path => {
54
+ path.extname =
55
+ ".br" +
56
+ path.basename.substring(
57
+ path.basename.lastIndexOf("."),
58
+ path.basename.length
59
+ );
60
+ path.basename = path.basename.substring(
61
+ 0,
62
+ path.basename.lastIndexOf(".")
63
+ );
64
+ })
65
+ )
66
+ .pipe(gulp.dest("../dist/test"));
67
+ });
68
+ // # 4 | Clear ng-build CSS
69
+ gulp.task("clear-ng-css", () => {
70
+ return gulp
71
+ .src("../dist/ng-bundle/*")
72
+ .pipe(filter(["**/styles*.css", "**/wm-styles*.css"]))
73
+ .pipe(clean({ force: true }));
74
+ });
75
+ // # 5 | Copy optimized CSS
76
+ gulp.task("copy-op-css", () => {
77
+ return gulp.src("../dist/test/*").pipe(gulp.dest("../dist/ng-bundle/"));
78
+ });
79
+ // #6 | Clear temp folder
80
+ gulp.task("clear-test", () => {
81
+ return gulp
82
+ .src("../dist/test/", { read: false })
83
+ .pipe(clean({ force: true }));
84
+ });
85
+
86
+ /*
87
+ ### Order of Tasks ###
88
+ * Add hash to the wm-styles.css
89
+ * Optimize the styles generated from ng build
90
+ * Create compressed files for optimized css
91
+ * Clear the angular build output css
92
+ * Copy the optimized css to ng-bundle folder
93
+ * Clear the temp folder
94
+ */
95
+ exports.default = series(
96
+ "css",
97
+ parallel("css-gzip", "css-br"),
98
+ "clear-ng-css",
99
+ "copy-op-css",
100
+ "clear-test"
101
+ );
@@ -0,0 +1,217 @@
1
+ const util = require(`util`);
2
+ const fs = require('fs-extra');
3
+ const readFile = util.promisify(fs.readFile);
4
+ const writeFile = util.promisify(fs.writeFile);
5
+ const copyFile = util.promisify(fs.copyFile);
6
+ const exec = util.promisify(require('child_process').exec);
7
+ const cheerio = require(`cheerio`);
8
+ const crypto = require(`crypto`);
9
+
10
+ let isProdBuild;
11
+ let isDevBuild;
12
+ let $;
13
+
14
+ const addScriptForWMStylesPath = (wm_styles_path) => {
15
+ // wm_styles_path will not be present for mobile apps
16
+ if (wm_styles_path) {
17
+ let styleType = wm_styles_path.split(".").pop();
18
+ if(styleType==="css"){
19
+ $("head").append(
20
+ `<link rel="stylesheet" type="text/css" href="${wm_styles_path}"/>`
21
+ );
22
+ } else {
23
+ $("body").append(
24
+ `<script type="text/javascript" defer="true" src="${wm_styles_path}"></script>`
25
+ );
26
+ }
27
+ }
28
+ }
29
+ const addPrintStylesPath = (print_styles_path) => {
30
+ $("head").append(
31
+ `<link rel="stylesheet" type="text/css" media="print" href="${print_styles_path}"/>`
32
+ );
33
+ }
34
+
35
+ /**
36
+ * Read the console arguments and prepare the key value pairs.
37
+ * @returns Object console arguments as key value pairs
38
+ */
39
+ const getArgs = (customArgs) => {
40
+ const args = {};
41
+ let arguments = customArgs || process.argv;
42
+ arguments.slice(2, process.argv.length)
43
+ .forEach(arg => {
44
+ if (arg.slice(0, 2) === '--') {
45
+ const longArg = arg.split('=');
46
+ const longArgFlag = longArg[0].slice(2, longArg[0].length);
47
+ const longArgValue = longArg.length > 2 ? longArg.slice(1, longArg.length).join('=') : longArg[1];
48
+ args[longArgFlag] = longArgValue;
49
+ }
50
+ });
51
+ return args;
52
+ }
53
+
54
+ const args = getArgs();
55
+
56
+ // Files that are moved out of ng-bundle and hence not to be updated.
57
+ const SKIP_UPDATE = ['index.html', 'manifest.json'];
58
+
59
+ /**
60
+ * Checks if a file's name has been changed during the build process
61
+ * and if changed, returns an updated file path.
62
+ *
63
+ * @param {string} deployUrl deployment url
64
+ * @param {string} url an absolute url to check if its filename has changed
65
+ * @param {object} updatedFileNames a map from old filenames to new filenames
66
+ * @returns {string} an updated file path
67
+ */
68
+ const getUpdatedFileName = (deployUrl, url, updatedFileNames) => {
69
+ const absUrl = url.substring(1); // remove leading '/'
70
+ if (SKIP_UPDATE.includes(absUrl)) {
71
+ return absUrl;
72
+ }
73
+
74
+ if (absUrl in updatedFileNames) {
75
+ return `${deployUrl}${updatedFileNames[absUrl]}` // add the leading '/' back
76
+ }
77
+ return `${deployUrl}${url}`;
78
+ }
79
+
80
+ /**
81
+ * Checks if a file's content has been changed during the build process
82
+ * and if changed, returns a new hash to be updated in ngsw.json
83
+ *
84
+ * @param {string} url an absolute url to check if its filename has changed
85
+ * @param {object} updatedFileHashes a map from filenames to file hashes
86
+ * @returns {string} an updated file hash
87
+ */
88
+ const getUpdatedFileHashes = (url, oldHash, updatedFileHashes) => {
89
+ const absUrl = url.substring(1); // remove leading '/'
90
+ if (absUrl in updatedFileHashes) {
91
+ return updatedFileHashes[absUrl];
92
+ }
93
+ return oldHash;
94
+ }
95
+
96
+ /**
97
+ * Get the path of the icon without '/ng-bundle'
98
+ *
99
+ * @param {string} iconPath path with '/ng-bundle'
100
+ * @returns {string} path of the icon without '/ng-bundle'
101
+ */
102
+ const getIconPath = (iconPath) => {
103
+ var index = iconPath.indexOf("/", iconPath.indexOf("/") + 1);
104
+ return iconPath.substring(index + 1);
105
+ }
106
+
107
+ /**
108
+ * Updates name, location and content of PWA related assets.
109
+ *
110
+ * @param {string} deployUrl deployment url
111
+ * @param {object} updatedFileNames a map from old filenames to new filenames
112
+ * @returns {void}
113
+ */
114
+ const updatePwaAssets = (deployUrl, updatedFileNames, updatedFileHashes) => {
115
+ const ngswPath = './dist/ngsw.json';
116
+ const manifestPath = './dist/manifest.json';
117
+ //this is always from server in case of pwa. Need to fix this to use cdnurl from runtime/build config
118
+ deployUrl = deployUrl === "_cdnUrl_" ? 'ng-bundle/' : deployUrl;
119
+
120
+ // copy service worker and its config to root directory
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);
125
+
126
+ // update the icons url in manifest.json
127
+ const manifest = JSON.parse(fs.readFileSync(manifestPath).toString());
128
+ const updatedManifest = {
129
+ ...manifest,
130
+ icons: manifest.icons.map(icon => ({ ...icon, src: `${deployUrl}${getIconPath(icon.src)}` })),
131
+ }
132
+ const manifestContent = JSON.stringify(updatedManifest, null, 4);
133
+ fs.writeFileSync(manifestPath, manifestContent);
134
+ updatedFileHashes['manifest.json'] = generateSha1(manifestContent);
135
+
136
+ // edit service worker config to include ./ng-bundle to the path of files to be cached
137
+ // also update the urls to files whose names are modified to include file hash (wm-styles)
138
+ const ngswData = JSON.parse(fs.readFileSync(ngswPath).toString());
139
+ ngswData.assetGroups = ngswData.assetGroups.map(group => ({
140
+ ...group,
141
+ urls: group.urls.map(url => getUpdatedFileName(deployUrl, url, updatedFileNames))
142
+ }));
143
+ ngswData.hashTable = Object.keys(ngswData.hashTable).reduce((prev, current) => ({
144
+ ...prev,
145
+ [getUpdatedFileName(deployUrl, current, updatedFileNames)]: getUpdatedFileHashes(current, ngswData.hashTable[current], updatedFileHashes),
146
+ }), {});
147
+
148
+ const ngswContent = JSON.stringify(ngswData, null, 4);
149
+ fs.writeFileSync(ngswPath, ngswContent);
150
+ }
151
+
152
+ /**
153
+ * Generated sha1 hash for the content supplied.
154
+ *
155
+ * @param {string} content the content to be hashed
156
+ * @returns {string} the hash value
157
+ */
158
+ const generateSha1 = (content) => {
159
+ const buffer = Buffer.from(content, 'utf8');
160
+ return crypto.createHash('sha1').update(buffer).digest("hex");
161
+ }
162
+
163
+ (async () => {
164
+ try {
165
+ const angularJson = require(`${process.cwd()}/angular.json`);
166
+ const build = angularJson['projects']['angular-app']['architect']['build'];
167
+ let deployUrl = args['deploy-url'] || build['configurations']['production']['deployUrl'];
168
+ global.randomHash = deployUrl.split('/')[1];
169
+ let outputPath = global.opPath = args['output-path'] || build['configurations']['production']['outputPath']
170
+ const contents = await readFile(`./dist/index.html`, `utf8`);
171
+ $ = cheerio.load(contents);
172
+ isProdBuild = fs.existsSync(`${process.cwd()}/${outputPath}/wm-styles.css`);
173
+ isDevBuild = fs.existsSync(`${process.cwd()}/${outputPath}/wm-styles.js`);
174
+
175
+ if (isProdBuild) {
176
+ const isOptimizeCss = $('meta[optimizecss]').length;
177
+ if (isOptimizeCss) {
178
+ console.log(`CSS Optimization Selected`);
179
+ const { stdout, stderr } = await exec(`npm run optimizecss`);
180
+ console.log(`Optimization Log | ${stdout}`);
181
+ console.error(`Optimization Error | ${stderr}`);
182
+ }
183
+ }
184
+ // if service worker is enabled the app is a PWA
185
+ const serviceWorkerEnabled = build['configurations']['production']['serviceWorker'];
186
+ const updatedFilenames = {}
187
+ const updatedFileHashes = {}
188
+ let wm_styles_path;
189
+
190
+ if (isDevBuild) {
191
+ wm_styles_path = `${deployUrl}wm-styles.js`;
192
+ } else {
193
+ const fileName = 'wm-styles';
194
+ const updatedFileName = `${fileName}.css`
195
+ wm_styles_path = `${deployUrl}${updatedFileName}`;
196
+ }
197
+
198
+ addScriptForWMStylesPath(wm_styles_path);
199
+ addPrintStylesPath(`${deployUrl}print.css`);
200
+
201
+ //this is required to download all the assets
202
+ $('head').append(`<meta name="deployUrl" content=${deployUrl} />`);
203
+ $('script[src$="services/application/wmProperties.js"]').remove();
204
+ $('link[href$="favicon.png"]').attr('href', `${deployUrl}favicon.png`);
205
+
206
+ const htmlContent = $.html();
207
+ await writeFile(`./dist/index.html`, htmlContent);
208
+
209
+ if (serviceWorkerEnabled) {
210
+ // re-generate hash for index.html since its been modified
211
+ updatedFileHashes['index.html'] = generateSha1(htmlContent);
212
+ updatePwaAssets(deployUrl, updatedFilenames, updatedFileHashes);
213
+ }
214
+ } catch (e) {
215
+ console.error(`Error in Post ng build Script | ${e}`);
216
+ }
217
+ })();
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+ const fs = require('fs');
3
+ const yargs = require('yargs');
4
+ const argv = yargs(process.argv).argv;
5
+ const { WM_NPM_SCOPE } = require('../src/wm-namespace.js');
6
+
7
+ /**
8
+ * Updates the @wavemaker-ai/app-ng-runtime dependency in the specified package.json file.
9
+ * @param {string} path - The path to the package.json file to update.
10
+ */
11
+
12
+ const updateNgRuntimePackage = (path) => {
13
+ if (fs.existsSync(path)) {
14
+ const packageJSON = require('../' + path);
15
+ packageJSON['dependencies'][`${WM_NPM_SCOPE}/app-ng-runtime`] = argv["publish-version"];
16
+ fs.writeFileSync(path, JSON.stringify(packageJSON, null, 4));
17
+ } else {
18
+ console.log('package.json not found at ' + path);
19
+ }
20
+ };
21
+ const init = () => {
22
+ updateNgRuntimePackage('../wavemaker-studio-runtime-integration/package.json');
23
+ };
24
+
25
+ init();
@@ -0,0 +1,40 @@
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
+ }
6
+ <router-outlet></router-outlet>
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
+ }
39
+ <!--Dummy container to create the component dynamically-->
40
+ <ng-container #dynamicComponent></ng-container>