@wavemaker/angular-codegen 11.0.1-next.139246 → 11.0.1-next.139250

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.
@@ -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,20 @@ 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
+ let styleType = wm_styles_path.split(".").pop();
97
+ if(styleType==="css"){
98
+ $("head").append(
99
+ `<link rel="stylesheet" type="text/css" href="${wm_styles_path}"/>`
100
+ );
101
+ } else {
102
+ $("body").append(
103
+ `<script type="text/javascript" defer="true" src="${wm_styles_path}"></script>`
104
+ );
105
+ }
106
+ $("head").append(
107
+ `<link rel="stylesheet" type="text/css" media="print" href="print.css"/>`
108
+ );
129
109
  }
130
110
 
131
111
  /**
@@ -155,9 +135,9 @@ const SKIP_UPDATE = ['index.html', 'manifest.json'];
155
135
  /**
156
136
  * Checks if a file's name has been changed during the build process
157
137
  * and if changed, returns an updated file path.
158
- *
138
+ *
159
139
  * @param {string} deployUrl deployment url
160
- * @param {string} url an absolute url to check if its filename has changed
140
+ * @param {string} url an absolute url to check if its filename has changed
161
141
  * @param {object} updatedFileNames a map from old filenames to new filenames
162
142
  * @returns {string} an updated file path
163
143
  */
@@ -176,8 +156,8 @@ const getUpdatedFileName = (deployUrl, url, updatedFileNames) => {
176
156
  /**
177
157
  * Checks if a file's content has been changed during the build process
178
158
  * 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
159
+ *
160
+ * @param {string} url an absolute url to check if its filename has changed
181
161
  * @param {object} updatedFileHashes a map from filenames to file hashes
182
162
  * @returns {string} an updated file hash
183
163
  */
@@ -191,7 +171,7 @@ const getUpdatedFileHashes = (url, oldHash, updatedFileHashes) => {
191
171
 
192
172
  /**
193
173
  * Get the path of the icon without '/ng-bundle'
194
- *
174
+ *
195
175
  * @param {string} iconPath path with '/ng-bundle'
196
176
  * @returns {string} path of the icon without '/ng-bundle'
197
177
  */
@@ -202,7 +182,7 @@ const getIconPath = (iconPath) => {
202
182
 
203
183
  /**
204
184
  * Updates name, location and content of PWA related assets.
205
- *
185
+ *
206
186
  * @param {string} deployUrl deployment url
207
187
  * @param {object} updatedFileNames a map from old filenames to new filenames
208
188
  * @returns {void}
@@ -245,7 +225,7 @@ const updatePwaAssets = (deployUrl, updatedFileNames, updatedFileHashes) => {
245
225
 
246
226
  /**
247
227
  * Generated sha1 hash for the content supplied.
248
- *
228
+ *
249
229
  * @param {string} content the content to be hashed
250
230
  * @returns {string} the hash value
251
231
  */
@@ -291,26 +271,23 @@ const generateSha1 = (content) => {
291
271
  const serviceWorkerEnabled = build['configurations']['production']['serviceWorker'];
292
272
  const updatedFilenames = {}
293
273
  const updatedFileHashes = {}
274
+ let wm_styles_path;
294
275
 
295
276
  if (isMobileProject) {
296
277
  await addMobileSpecificStyles(deployUrl);
297
278
  } else {
298
279
  if (isDevBuild) {
299
- $("head").append(
300
- `<script> const WMStylesPath = "${deployUrl}/wm-styles.js" </script>`
301
- )
280
+ wm_styles_path = `${deployUrl}/wm-styles.js`;
302
281
  } else {
303
282
  const fileName = 'wm-styles';
304
283
  const hash = await generateHash(`${opPath}/${fileName}.css`);
305
284
  copyCssFiles(hash, updatedFilenames);
306
285
  const updatedFileName = `${fileName}.${hash}.css`
307
- $("head").append(
308
- `<script> const WMStylesPath = "${deployUrl}/${updatedFileName}" </script>`
309
- );
286
+ wm_styles_path = `${deployUrl}/${updatedFileName}`;
310
287
  }
311
288
  }
312
289
 
313
- addScriptForWMStylesPath();
290
+ addScriptForWMStylesPath(wm_styles_path);
314
291
  const htmlContent = $.html();
315
292
  await writeFile(`./dist/index.html`, htmlContent);
316
293
 
@@ -68,7 +68,7 @@
68
68
  "tslib": "^2.0.0",
69
69
  "x2js": "3.2.6",
70
70
  "zone.js": "~0.10.3",
71
- "@wavemaker/app-ng-runtime": "11.0.1-next.139246"
71
+ "@wavemaker/app-ng-runtime": "11.0.1-next.139250"
72
72
  },
73
73
  "devDependencies": {
74
74
  "@ampproject/rollup-plugin-closure-compiler": "0.8.5",
@@ -0,0 +1,22 @@
1
+ <ng-container *ngIf="startApp">
2
+ <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 wmAppExt></div>
19
+ <i id="wm-mobile-display"></i>
20
+ </ng-container>
21
+ <!--Dummy container to create the component dynamically-->
22
+ <ng-container #dynamicComponent></ng-container>
@@ -17570,6 +17570,21 @@ const nullPipe = () => {
17570
17570
  };
17571
17571
  };
17572
17572
  const ɵ10 = nullPipe;
17573
+ let _cspEnabled;
17574
+ const isCSPEnabled = () => {
17575
+ if (typeof _cspEnabled !== 'undefined') {
17576
+ return _cspEnabled;
17577
+ }
17578
+ try {
17579
+ new Function();
17580
+ _cspEnabled = false;
17581
+ }
17582
+ catch (e) {
17583
+ _cspEnabled = true;
17584
+ }
17585
+ return _cspEnabled;
17586
+ };
17587
+ const ɵ11 = isCSPEnabled;
17573
17588
  let pipeProvider;
17574
17589
  function setPipeProvider(_pipeProvider) {
17575
17590
  pipeProvider = _pipeProvider;
@@ -17604,47 +17619,53 @@ function $parseExpr(expr, defOnly) {
17604
17619
  }
17605
17620
  // fallback to generate function in runtime. This will break if CSP is enabled
17606
17621
  if (!boundFn) {
17607
- const parser = new Parser$1(new Lexer);
17608
- const ast = parser.parseBinding(expr, '', 0);
17609
- if (ast.errors.length) {
17610
- fn = noop;
17611
- boundFn = fn;
17622
+ // If CSP enabled, avoid multiple browser errors. [What do we say to death, NOT TODAY!]
17623
+ if (isCSPEnabled()) {
17624
+ boundFn = noop;
17612
17625
  }
17613
17626
  else {
17614
- const pipeNameVsIsPureMap = pipeProvider.getPipeNameVsIsPureMap();
17615
- const astCompiler = new ASTCompiler(ast.ast, ExpressionType$1.Binding, pipeNameVsIsPureMap);
17616
- fn = astCompiler.compile(defOnly);
17617
- if (defOnly) {
17618
- return fn;
17619
- }
17620
- if (fn.usedPipes.length) {
17621
- const pipeArgs = [];
17622
- let hasPurePipe = false;
17623
- for (const [pipeName] of fn.usedPipes) {
17624
- const pipeInfo = pipeProvider.meta(pipeName);
17625
- let pipeInstance;
17626
- if (!pipeInfo) {
17627
- pipeInstance = nullPipe;
17628
- }
17629
- else {
17630
- if (pipeInfo.pure) {
17631
- hasPurePipe = true;
17632
- pipeInstance = purePipes.get(pipeName);
17633
- }
17634
- if (!pipeInstance) {
17635
- pipeInstance = pipeProvider.getInstance(pipeName);
17627
+ const parser = new Parser$1(new Lexer);
17628
+ const ast = parser.parseBinding(expr, '', 0);
17629
+ if (ast.errors.length) {
17630
+ fn = noop;
17631
+ boundFn = fn;
17632
+ }
17633
+ else {
17634
+ const pipeNameVsIsPureMap = pipeProvider.getPipeNameVsIsPureMap();
17635
+ const astCompiler = new ASTCompiler(ast.ast, ExpressionType$1.Binding, pipeNameVsIsPureMap);
17636
+ fn = astCompiler.compile(defOnly);
17637
+ if (defOnly) {
17638
+ return fn;
17639
+ }
17640
+ if (fn.usedPipes.length) {
17641
+ const pipeArgs = [];
17642
+ let hasPurePipe = false;
17643
+ for (const [pipeName] of fn.usedPipes) {
17644
+ const pipeInfo = pipeProvider.meta(pipeName);
17645
+ let pipeInstance;
17646
+ if (!pipeInfo) {
17647
+ pipeInstance = nullPipe;
17636
17648
  }
17637
- if (pipeInfo.pure) {
17638
- purePipes.set(pipeName, pipeInstance);
17649
+ else {
17650
+ if (pipeInfo.pure) {
17651
+ hasPurePipe = true;
17652
+ pipeInstance = purePipes.get(pipeName);
17653
+ }
17654
+ if (!pipeInstance) {
17655
+ pipeInstance = pipeProvider.getInstance(pipeName);
17656
+ }
17657
+ if (pipeInfo.pure) {
17658
+ purePipes.set(pipeName, pipeInstance);
17659
+ }
17639
17660
  }
17661
+ pipeArgs.push(pipeInstance);
17640
17662
  }
17641
- pipeArgs.push(pipeInstance);
17663
+ pipeArgs.unshift(hasPurePipe ? new Map() : undefined);
17664
+ boundFn = fn.bind(undefined, ...pipeArgs);
17665
+ }
17666
+ else {
17667
+ boundFn = fn.bind(undefined, undefined);
17642
17668
  }
17643
- pipeArgs.unshift(hasPurePipe ? new Map() : undefined);
17644
- boundFn = fn.bind(undefined, ...pipeArgs);
17645
- }
17646
- else {
17647
- boundFn = fn.bind(undefined, undefined);
17648
17669
  }
17649
17670
  }
17650
17671
  }
@@ -17664,24 +17685,28 @@ function $parseEvent(expr, defOnly) {
17664
17685
  return fn;
17665
17686
  }
17666
17687
  if (!defOnly) {
17667
- fn = getFnForEventExpr(expr) || noop;
17688
+ fn = getFnForEventExpr(expr);
17668
17689
  }
17669
17690
  // fallback to generate function in runtime. This will break if CSP is enabled
17670
17691
  if (!fn) {
17671
- const parser = new Parser$1(new Lexer);
17672
- const ast = parser.parseAction(expr, '', 0);
17673
- if (ast.errors.length) {
17674
- return noop;
17692
+ if (isCSPEnabled()) {
17693
+ fn = noop;
17694
+ }
17695
+ else {
17696
+ const parser = new Parser$1(new Lexer);
17697
+ const ast = parser.parseAction(expr, '', 0);
17698
+ if (ast.errors.length) {
17699
+ return noop;
17700
+ }
17701
+ const astCompiler = new ASTCompiler(ast.ast, ExpressionType$1.Action);
17702
+ fn = astCompiler.compile(defOnly);
17675
17703
  }
17676
- const astCompiler = new ASTCompiler(ast.ast, ExpressionType$1.Action);
17677
- fn = astCompiler.compile(defOnly);
17678
17704
  }
17679
17705
  eventFnCache.set(expr, fn);
17680
17706
  return fn;
17681
17707
  }
17682
17708
  const fnNameMap = new Map();
17683
17709
  const registerFnByExpr = (expr, fn, usedPipes) => {
17684
- console.log('registering function for: ', expr);
17685
17710
  fn.usedPipes = usedPipes || [];
17686
17711
  fnNameMap.set(expr, fn);
17687
17712
  };
@@ -17689,8 +17714,8 @@ const getFnByExpr = (expr) => fnNameMap.get(expr);
17689
17714
  const fnExecutor = (expr, exprType) => {
17690
17715
  let fn = getFnByExpr(expr);
17691
17716
  if (!fn) {
17692
- console.warn('oops, didnt find fn for this expr', expr);
17693
- return function () { };
17717
+ console.warn("didn't find fn for the expr: ", expr, ". Falling back to runtime evaluation");
17718
+ return;
17694
17719
  }
17695
17720
  const usedPipes = fn.usedPipes || [];
17696
17721
  if (exprType === ExpressionType$1.Binding) {
@@ -17732,7 +17757,7 @@ const fnExecutor = (expr, exprType) => {
17732
17757
  }
17733
17758
  return fn;
17734
17759
  };
17735
- const ɵ11 = fnExecutor;
17760
+ const ɵ12 = fnExecutor;
17736
17761
  const getFnForBindExpr = (expr) => {
17737
17762
  return fnExecutor(expr, ExpressionType$1.Binding);
17738
17763
  };
@@ -17759,3 +17784,4 @@ exports.ɵ8 = ɵ8;
17759
17784
  exports.ɵ9 = ɵ9;
17760
17785
  exports.ɵ10 = ɵ10;
17761
17786
  exports.ɵ11 = ɵ11;
17787
+ exports.ɵ12 = ɵ12;
@@ -42658,6 +42658,20 @@ const nullPipe = () => {
42658
42658
  transform: noop$1$1
42659
42659
  };
42660
42660
  };
42661
+ let _cspEnabled;
42662
+ const isCSPEnabled = () => {
42663
+ if (typeof _cspEnabled !== 'undefined') {
42664
+ return _cspEnabled;
42665
+ }
42666
+ try {
42667
+ new Function();
42668
+ _cspEnabled = false;
42669
+ }
42670
+ catch (e) {
42671
+ _cspEnabled = true;
42672
+ }
42673
+ return _cspEnabled;
42674
+ };
42661
42675
  let pipeProvider;
42662
42676
  var ExpressionType$1;
42663
42677
  (function (ExpressionType$$1) {
@@ -42689,47 +42703,53 @@ function $parseExpr(expr, defOnly) {
42689
42703
  }
42690
42704
  // fallback to generate function in runtime. This will break if CSP is enabled
42691
42705
  if (!boundFn) {
42692
- const parser = new Parser$1(new Lexer);
42693
- const ast = parser.parseBinding(expr, '', 0);
42694
- if (ast.errors.length) {
42695
- fn = noop$1$1;
42696
- boundFn = fn;
42706
+ // If CSP enabled, avoid multiple browser errors. [What do we say to death, NOT TODAY!]
42707
+ if (isCSPEnabled()) {
42708
+ boundFn = noop$1$1;
42697
42709
  }
42698
42710
  else {
42699
- const pipeNameVsIsPureMap = pipeProvider.getPipeNameVsIsPureMap();
42700
- const astCompiler = new ASTCompiler(ast.ast, ExpressionType$1.Binding, pipeNameVsIsPureMap);
42701
- fn = astCompiler.compile(defOnly);
42702
- if (defOnly) {
42703
- return fn;
42704
- }
42705
- if (fn.usedPipes.length) {
42706
- const pipeArgs = [];
42707
- let hasPurePipe = false;
42708
- for (const [pipeName] of fn.usedPipes) {
42709
- const pipeInfo = pipeProvider.meta(pipeName);
42710
- let pipeInstance;
42711
- if (!pipeInfo) {
42712
- pipeInstance = nullPipe;
42713
- }
42714
- else {
42715
- if (pipeInfo.pure) {
42716
- hasPurePipe = true;
42717
- pipeInstance = purePipes.get(pipeName);
42718
- }
42719
- if (!pipeInstance) {
42720
- pipeInstance = pipeProvider.getInstance(pipeName);
42711
+ const parser = new Parser$1(new Lexer);
42712
+ const ast = parser.parseBinding(expr, '', 0);
42713
+ if (ast.errors.length) {
42714
+ fn = noop$1$1;
42715
+ boundFn = fn;
42716
+ }
42717
+ else {
42718
+ const pipeNameVsIsPureMap = pipeProvider.getPipeNameVsIsPureMap();
42719
+ const astCompiler = new ASTCompiler(ast.ast, ExpressionType$1.Binding, pipeNameVsIsPureMap);
42720
+ fn = astCompiler.compile(defOnly);
42721
+ if (defOnly) {
42722
+ return fn;
42723
+ }
42724
+ if (fn.usedPipes.length) {
42725
+ const pipeArgs = [];
42726
+ let hasPurePipe = false;
42727
+ for (const [pipeName] of fn.usedPipes) {
42728
+ const pipeInfo = pipeProvider.meta(pipeName);
42729
+ let pipeInstance;
42730
+ if (!pipeInfo) {
42731
+ pipeInstance = nullPipe;
42721
42732
  }
42722
- if (pipeInfo.pure) {
42723
- purePipes.set(pipeName, pipeInstance);
42733
+ else {
42734
+ if (pipeInfo.pure) {
42735
+ hasPurePipe = true;
42736
+ pipeInstance = purePipes.get(pipeName);
42737
+ }
42738
+ if (!pipeInstance) {
42739
+ pipeInstance = pipeProvider.getInstance(pipeName);
42740
+ }
42741
+ if (pipeInfo.pure) {
42742
+ purePipes.set(pipeName, pipeInstance);
42743
+ }
42724
42744
  }
42745
+ pipeArgs.push(pipeInstance);
42725
42746
  }
42726
- pipeArgs.push(pipeInstance);
42747
+ pipeArgs.unshift(hasPurePipe ? new Map() : undefined);
42748
+ boundFn = fn.bind(undefined, ...pipeArgs);
42749
+ }
42750
+ else {
42751
+ boundFn = fn.bind(undefined, undefined);
42727
42752
  }
42728
- pipeArgs.unshift(hasPurePipe ? new Map() : undefined);
42729
- boundFn = fn.bind(undefined, ...pipeArgs);
42730
- }
42731
- else {
42732
- boundFn = fn.bind(undefined, undefined);
42733
42753
  }
42734
42754
  }
42735
42755
  }
@@ -42749,17 +42769,22 @@ function $parseEvent(expr, defOnly) {
42749
42769
  return fn;
42750
42770
  }
42751
42771
  if (!defOnly) {
42752
- fn = getFnForEventExpr(expr) || noop$1$1;
42772
+ fn = getFnForEventExpr(expr);
42753
42773
  }
42754
42774
  // fallback to generate function in runtime. This will break if CSP is enabled
42755
42775
  if (!fn) {
42756
- const parser = new Parser$1(new Lexer);
42757
- const ast = parser.parseAction(expr, '', 0);
42758
- if (ast.errors.length) {
42759
- return noop$1$1;
42776
+ if (isCSPEnabled()) {
42777
+ fn = noop$1$1;
42778
+ }
42779
+ else {
42780
+ const parser = new Parser$1(new Lexer);
42781
+ const ast = parser.parseAction(expr, '', 0);
42782
+ if (ast.errors.length) {
42783
+ return noop$1$1;
42784
+ }
42785
+ const astCompiler = new ASTCompiler(ast.ast, ExpressionType$1.Action);
42786
+ fn = astCompiler.compile(defOnly);
42760
42787
  }
42761
- const astCompiler = new ASTCompiler(ast.ast, ExpressionType$1.Action);
42762
- fn = astCompiler.compile(defOnly);
42763
42788
  }
42764
42789
  eventFnCache.set(expr, fn);
42765
42790
  return fn;
@@ -42769,8 +42794,8 @@ const getFnByExpr = (expr) => fnNameMap.get(expr);
42769
42794
  const fnExecutor = (expr, exprType) => {
42770
42795
  let fn = getFnByExpr(expr);
42771
42796
  if (!fn) {
42772
- console.warn('oops, didnt find fn for this expr', expr);
42773
- return function () { };
42797
+ console.warn("didn't find fn for the expr: ", expr, ". Falling back to runtime evaluation");
42798
+ return;
42774
42799
  }
42775
42800
  const usedPipes = fn.usedPipes || [];
42776
42801
  if (exprType === ExpressionType$1.Binding) {
@@ -43657,10 +43682,26 @@ const loadScript = (url, loadViaScriptTag, cacheable = false) => __awaiter$1(voi
43657
43682
  return Promise.resolve();
43658
43683
  }
43659
43684
  if (loadViaScriptTag) {
43660
- return fetchContent('text', _url, false, text => {
43661
- const script = document.createElement('script');
43662
- script.textContent = text;
43663
- document.head.appendChild(script);
43685
+ return new Promise((resolve, reject) => {
43686
+ let script = document.createElement('script');
43687
+ script.type = 'text/javascript';
43688
+ script.src = _url;
43689
+ script.async = false;
43690
+ if (script.readyState) { //IE
43691
+ script.onreadystatechange = () => {
43692
+ if (script.readyState === "loaded" || script.readyState === "complete") {
43693
+ script.onreadystatechange = null;
43694
+ resolve(true);
43695
+ }
43696
+ };
43697
+ }
43698
+ else { //Other browsers
43699
+ script.onload = () => {
43700
+ resolve(true);
43701
+ };
43702
+ }
43703
+ script.onerror = (error) => reject(error);
43704
+ document.getElementsByTagName('head')[0].appendChild(script);
43664
43705
  });
43665
43706
  }
43666
43707
  else if (cacheable) {
@@ -43676,13 +43717,6 @@ const loadScript = (url, loadViaScriptTag, cacheable = false) => __awaiter$1(voi
43676
43717
  .done(response => response)
43677
43718
  .fail(reason => reason);
43678
43719
  }
43679
- // return fetch(_url)
43680
- // .then(response => response.text())
43681
- // .then(text => {
43682
- // const script = document.createElement('script');
43683
- // script.textContent = text;
43684
- // document.head.appendChild(script);
43685
- // });
43686
43720
  });
43687
43721
  const loadScripts = (urls = [], loadViaScriptTag = true) => __awaiter$1(void 0, void 0, void 0, function* () {
43688
43722
  for (const url of urls) {
@@ -43712,7 +43746,8 @@ const setSessionStorageItem = (key, value) => {
43712
43746
  * @param key string
43713
43747
  */
43714
43748
  const getSessionStorageItem = key => {
43715
- let item = window.sessionStorage.getItem(_WM_APP_PROJECT.id);
43749
+ // sanity check for this to work with ng-codegen
43750
+ let item = window && window.sessionStorage && window.sessionStorage.getItem(_WM_APP_PROJECT.id);
43716
43751
  if (item) {
43717
43752
  item = JSON.parse(item);
43718
43753
  return item[key];
@@ -38646,6 +38646,20 @@ const nullPipe = () => {
38646
38646
  transform: noop$1$1
38647
38647
  };
38648
38648
  };
38649
+ let _cspEnabled;
38650
+ const isCSPEnabled = () => {
38651
+ if (typeof _cspEnabled !== 'undefined') {
38652
+ return _cspEnabled;
38653
+ }
38654
+ try {
38655
+ new Function();
38656
+ _cspEnabled = false;
38657
+ }
38658
+ catch (e) {
38659
+ _cspEnabled = true;
38660
+ }
38661
+ return _cspEnabled;
38662
+ };
38649
38663
  let pipeProvider;
38650
38664
  var ExpressionType$1;
38651
38665
  (function (ExpressionType$$1) {
@@ -38677,47 +38691,53 @@ function $parseExpr(expr, defOnly) {
38677
38691
  }
38678
38692
  // fallback to generate function in runtime. This will break if CSP is enabled
38679
38693
  if (!boundFn) {
38680
- const parser = new Parser$1(new Lexer);
38681
- const ast = parser.parseBinding(expr, '', 0);
38682
- if (ast.errors.length) {
38683
- fn = noop$1$1;
38684
- boundFn = fn;
38694
+ // If CSP enabled, avoid multiple browser errors. [What do we say to death, NOT TODAY!]
38695
+ if (isCSPEnabled()) {
38696
+ boundFn = noop$1$1;
38685
38697
  }
38686
38698
  else {
38687
- const pipeNameVsIsPureMap = pipeProvider.getPipeNameVsIsPureMap();
38688
- const astCompiler = new ASTCompiler(ast.ast, ExpressionType$1.Binding, pipeNameVsIsPureMap);
38689
- fn = astCompiler.compile(defOnly);
38690
- if (defOnly) {
38691
- return fn;
38692
- }
38693
- if (fn.usedPipes.length) {
38694
- const pipeArgs = [];
38695
- let hasPurePipe = false;
38696
- for (const [pipeName] of fn.usedPipes) {
38697
- const pipeInfo = pipeProvider.meta(pipeName);
38698
- let pipeInstance;
38699
- if (!pipeInfo) {
38700
- pipeInstance = nullPipe;
38701
- }
38702
- else {
38703
- if (pipeInfo.pure) {
38704
- hasPurePipe = true;
38705
- pipeInstance = purePipes.get(pipeName);
38706
- }
38707
- if (!pipeInstance) {
38708
- pipeInstance = pipeProvider.getInstance(pipeName);
38699
+ const parser = new Parser$1(new Lexer);
38700
+ const ast = parser.parseBinding(expr, '', 0);
38701
+ if (ast.errors.length) {
38702
+ fn = noop$1$1;
38703
+ boundFn = fn;
38704
+ }
38705
+ else {
38706
+ const pipeNameVsIsPureMap = pipeProvider.getPipeNameVsIsPureMap();
38707
+ const astCompiler = new ASTCompiler(ast.ast, ExpressionType$1.Binding, pipeNameVsIsPureMap);
38708
+ fn = astCompiler.compile(defOnly);
38709
+ if (defOnly) {
38710
+ return fn;
38711
+ }
38712
+ if (fn.usedPipes.length) {
38713
+ const pipeArgs = [];
38714
+ let hasPurePipe = false;
38715
+ for (const [pipeName] of fn.usedPipes) {
38716
+ const pipeInfo = pipeProvider.meta(pipeName);
38717
+ let pipeInstance;
38718
+ if (!pipeInfo) {
38719
+ pipeInstance = nullPipe;
38709
38720
  }
38710
- if (pipeInfo.pure) {
38711
- purePipes.set(pipeName, pipeInstance);
38721
+ else {
38722
+ if (pipeInfo.pure) {
38723
+ hasPurePipe = true;
38724
+ pipeInstance = purePipes.get(pipeName);
38725
+ }
38726
+ if (!pipeInstance) {
38727
+ pipeInstance = pipeProvider.getInstance(pipeName);
38728
+ }
38729
+ if (pipeInfo.pure) {
38730
+ purePipes.set(pipeName, pipeInstance);
38731
+ }
38712
38732
  }
38733
+ pipeArgs.push(pipeInstance);
38713
38734
  }
38714
- pipeArgs.push(pipeInstance);
38735
+ pipeArgs.unshift(hasPurePipe ? new Map() : undefined);
38736
+ boundFn = fn.bind(undefined, ...pipeArgs);
38737
+ }
38738
+ else {
38739
+ boundFn = fn.bind(undefined, undefined);
38715
38740
  }
38716
- pipeArgs.unshift(hasPurePipe ? new Map() : undefined);
38717
- boundFn = fn.bind(undefined, ...pipeArgs);
38718
- }
38719
- else {
38720
- boundFn = fn.bind(undefined, undefined);
38721
38741
  }
38722
38742
  }
38723
38743
  }
@@ -38737,17 +38757,22 @@ function $parseEvent(expr, defOnly) {
38737
38757
  return fn;
38738
38758
  }
38739
38759
  if (!defOnly) {
38740
- fn = getFnForEventExpr(expr) || noop$1$1;
38760
+ fn = getFnForEventExpr(expr);
38741
38761
  }
38742
38762
  // fallback to generate function in runtime. This will break if CSP is enabled
38743
38763
  if (!fn) {
38744
- const parser = new Parser$1(new Lexer);
38745
- const ast = parser.parseAction(expr, '', 0);
38746
- if (ast.errors.length) {
38747
- return noop$1$1;
38764
+ if (isCSPEnabled()) {
38765
+ fn = noop$1$1;
38766
+ }
38767
+ else {
38768
+ const parser = new Parser$1(new Lexer);
38769
+ const ast = parser.parseAction(expr, '', 0);
38770
+ if (ast.errors.length) {
38771
+ return noop$1$1;
38772
+ }
38773
+ const astCompiler = new ASTCompiler(ast.ast, ExpressionType$1.Action);
38774
+ fn = astCompiler.compile(defOnly);
38748
38775
  }
38749
- const astCompiler = new ASTCompiler(ast.ast, ExpressionType$1.Action);
38750
- fn = astCompiler.compile(defOnly);
38751
38776
  }
38752
38777
  eventFnCache.set(expr, fn);
38753
38778
  return fn;
@@ -38757,8 +38782,8 @@ const getFnByExpr = (expr) => fnNameMap.get(expr);
38757
38782
  const fnExecutor = (expr, exprType) => {
38758
38783
  let fn = getFnByExpr(expr);
38759
38784
  if (!fn) {
38760
- console.warn('oops, didnt find fn for this expr', expr);
38761
- return function () { };
38785
+ console.warn("didn't find fn for the expr: ", expr, ". Falling back to runtime evaluation");
38786
+ return;
38762
38787
  }
38763
38788
  const usedPipes = fn.usedPipes || [];
38764
38789
  if (exprType === ExpressionType$1.Binding) {
@@ -39645,10 +39670,26 @@ const loadScript = (url, loadViaScriptTag, cacheable = false) => __awaiter$1(voi
39645
39670
  return Promise.resolve();
39646
39671
  }
39647
39672
  if (loadViaScriptTag) {
39648
- return fetchContent('text', _url, false, text => {
39649
- const script = document.createElement('script');
39650
- script.textContent = text;
39651
- document.head.appendChild(script);
39673
+ return new Promise((resolve, reject) => {
39674
+ let script = document.createElement('script');
39675
+ script.type = 'text/javascript';
39676
+ script.src = _url;
39677
+ script.async = false;
39678
+ if (script.readyState) { //IE
39679
+ script.onreadystatechange = () => {
39680
+ if (script.readyState === "loaded" || script.readyState === "complete") {
39681
+ script.onreadystatechange = null;
39682
+ resolve(true);
39683
+ }
39684
+ };
39685
+ }
39686
+ else { //Other browsers
39687
+ script.onload = () => {
39688
+ resolve(true);
39689
+ };
39690
+ }
39691
+ script.onerror = (error) => reject(error);
39692
+ document.getElementsByTagName('head')[0].appendChild(script);
39652
39693
  });
39653
39694
  }
39654
39695
  else if (cacheable) {
@@ -39664,13 +39705,6 @@ const loadScript = (url, loadViaScriptTag, cacheable = false) => __awaiter$1(voi
39664
39705
  .done(response => response)
39665
39706
  .fail(reason => reason);
39666
39707
  }
39667
- // return fetch(_url)
39668
- // .then(response => response.text())
39669
- // .then(text => {
39670
- // const script = document.createElement('script');
39671
- // script.textContent = text;
39672
- // document.head.appendChild(script);
39673
- // });
39674
39708
  });
39675
39709
  const loadScripts = (urls = [], loadViaScriptTag = true) => __awaiter$1(void 0, void 0, void 0, function* () {
39676
39710
  for (const url of urls) {
@@ -39700,7 +39734,8 @@ const setSessionStorageItem = (key, value) => {
39700
39734
  * @param key string
39701
39735
  */
39702
39736
  const getSessionStorageItem = key => {
39703
- let item = window.sessionStorage.getItem(_WM_APP_PROJECT.id);
39737
+ // sanity check for this to work with ng-codegen
39738
+ let item = window && window.sessionStorage && window.sessionStorage.getItem(_WM_APP_PROJECT.id);
39704
39739
  if (item) {
39705
39740
  item = JSON.parse(item);
39706
39741
  return item[key];
@@ -41919,7 +41954,7 @@ const setDimensionProp = (cssObj, key, nv) => {
41919
41954
  cssObj[cssKey] = nv;
41920
41955
  }
41921
41956
  };
41922
- const ɵ12 = setDimensionProp;
41957
+ const ɵ12$1 = setDimensionProp;
41923
41958
  const processDimensionAttributes = attrMap => {
41924
41959
  const attrKeys = Array.from(attrMap.keys());
41925
41960
  attrKeys.forEach((attrKey) => {
@@ -45073,7 +45108,7 @@ exports.ɵ0 = ɵ0$h;
45073
45108
  exports.ɵ1 = ɵ1$5;
45074
45109
  exports.ɵ10 = ɵ10$1;
45075
45110
  exports.ɵ11 = ɵ11$1;
45076
- exports.ɵ12 = ɵ12;
45111
+ exports.ɵ12 = ɵ12$1;
45077
45112
  exports.ɵ13 = ɵ13;
45078
45113
  exports.ɵ14 = ɵ14;
45079
45114
  exports.ɵ2 = ɵ2$4;
@@ -38646,6 +38646,20 @@ const nullPipe = () => {
38646
38646
  transform: noop$1$1
38647
38647
  };
38648
38648
  };
38649
+ let _cspEnabled;
38650
+ const isCSPEnabled = () => {
38651
+ if (typeof _cspEnabled !== 'undefined') {
38652
+ return _cspEnabled;
38653
+ }
38654
+ try {
38655
+ new Function();
38656
+ _cspEnabled = false;
38657
+ }
38658
+ catch (e) {
38659
+ _cspEnabled = true;
38660
+ }
38661
+ return _cspEnabled;
38662
+ };
38649
38663
  let pipeProvider;
38650
38664
  var ExpressionType$1;
38651
38665
  (function (ExpressionType$$1) {
@@ -38677,47 +38691,53 @@ function $parseExpr(expr, defOnly) {
38677
38691
  }
38678
38692
  // fallback to generate function in runtime. This will break if CSP is enabled
38679
38693
  if (!boundFn) {
38680
- const parser = new Parser$1(new Lexer);
38681
- const ast = parser.parseBinding(expr, '', 0);
38682
- if (ast.errors.length) {
38683
- fn = noop$1$1;
38684
- boundFn = fn;
38694
+ // If CSP enabled, avoid multiple browser errors. [What do we say to death, NOT TODAY!]
38695
+ if (isCSPEnabled()) {
38696
+ boundFn = noop$1$1;
38685
38697
  }
38686
38698
  else {
38687
- const pipeNameVsIsPureMap = pipeProvider.getPipeNameVsIsPureMap();
38688
- const astCompiler = new ASTCompiler(ast.ast, ExpressionType$1.Binding, pipeNameVsIsPureMap);
38689
- fn = astCompiler.compile(defOnly);
38690
- if (defOnly) {
38691
- return fn;
38692
- }
38693
- if (fn.usedPipes.length) {
38694
- const pipeArgs = [];
38695
- let hasPurePipe = false;
38696
- for (const [pipeName] of fn.usedPipes) {
38697
- const pipeInfo = pipeProvider.meta(pipeName);
38698
- let pipeInstance;
38699
- if (!pipeInfo) {
38700
- pipeInstance = nullPipe;
38701
- }
38702
- else {
38703
- if (pipeInfo.pure) {
38704
- hasPurePipe = true;
38705
- pipeInstance = purePipes.get(pipeName);
38706
- }
38707
- if (!pipeInstance) {
38708
- pipeInstance = pipeProvider.getInstance(pipeName);
38699
+ const parser = new Parser$1(new Lexer);
38700
+ const ast = parser.parseBinding(expr, '', 0);
38701
+ if (ast.errors.length) {
38702
+ fn = noop$1$1;
38703
+ boundFn = fn;
38704
+ }
38705
+ else {
38706
+ const pipeNameVsIsPureMap = pipeProvider.getPipeNameVsIsPureMap();
38707
+ const astCompiler = new ASTCompiler(ast.ast, ExpressionType$1.Binding, pipeNameVsIsPureMap);
38708
+ fn = astCompiler.compile(defOnly);
38709
+ if (defOnly) {
38710
+ return fn;
38711
+ }
38712
+ if (fn.usedPipes.length) {
38713
+ const pipeArgs = [];
38714
+ let hasPurePipe = false;
38715
+ for (const [pipeName] of fn.usedPipes) {
38716
+ const pipeInfo = pipeProvider.meta(pipeName);
38717
+ let pipeInstance;
38718
+ if (!pipeInfo) {
38719
+ pipeInstance = nullPipe;
38709
38720
  }
38710
- if (pipeInfo.pure) {
38711
- purePipes.set(pipeName, pipeInstance);
38721
+ else {
38722
+ if (pipeInfo.pure) {
38723
+ hasPurePipe = true;
38724
+ pipeInstance = purePipes.get(pipeName);
38725
+ }
38726
+ if (!pipeInstance) {
38727
+ pipeInstance = pipeProvider.getInstance(pipeName);
38728
+ }
38729
+ if (pipeInfo.pure) {
38730
+ purePipes.set(pipeName, pipeInstance);
38731
+ }
38712
38732
  }
38733
+ pipeArgs.push(pipeInstance);
38713
38734
  }
38714
- pipeArgs.push(pipeInstance);
38735
+ pipeArgs.unshift(hasPurePipe ? new Map() : undefined);
38736
+ boundFn = fn.bind(undefined, ...pipeArgs);
38737
+ }
38738
+ else {
38739
+ boundFn = fn.bind(undefined, undefined);
38715
38740
  }
38716
- pipeArgs.unshift(hasPurePipe ? new Map() : undefined);
38717
- boundFn = fn.bind(undefined, ...pipeArgs);
38718
- }
38719
- else {
38720
- boundFn = fn.bind(undefined, undefined);
38721
38741
  }
38722
38742
  }
38723
38743
  }
@@ -38737,17 +38757,22 @@ function $parseEvent(expr, defOnly) {
38737
38757
  return fn;
38738
38758
  }
38739
38759
  if (!defOnly) {
38740
- fn = getFnForEventExpr(expr) || noop$1$1;
38760
+ fn = getFnForEventExpr(expr);
38741
38761
  }
38742
38762
  // fallback to generate function in runtime. This will break if CSP is enabled
38743
38763
  if (!fn) {
38744
- const parser = new Parser$1(new Lexer);
38745
- const ast = parser.parseAction(expr, '', 0);
38746
- if (ast.errors.length) {
38747
- return noop$1$1;
38764
+ if (isCSPEnabled()) {
38765
+ fn = noop$1$1;
38766
+ }
38767
+ else {
38768
+ const parser = new Parser$1(new Lexer);
38769
+ const ast = parser.parseAction(expr, '', 0);
38770
+ if (ast.errors.length) {
38771
+ return noop$1$1;
38772
+ }
38773
+ const astCompiler = new ASTCompiler(ast.ast, ExpressionType$1.Action);
38774
+ fn = astCompiler.compile(defOnly);
38748
38775
  }
38749
- const astCompiler = new ASTCompiler(ast.ast, ExpressionType$1.Action);
38750
- fn = astCompiler.compile(defOnly);
38751
38776
  }
38752
38777
  eventFnCache.set(expr, fn);
38753
38778
  return fn;
@@ -38757,8 +38782,8 @@ const getFnByExpr = (expr) => fnNameMap.get(expr);
38757
38782
  const fnExecutor = (expr, exprType) => {
38758
38783
  let fn = getFnByExpr(expr);
38759
38784
  if (!fn) {
38760
- console.warn('oops, didnt find fn for this expr', expr);
38761
- return function () { };
38785
+ console.warn("didn't find fn for the expr: ", expr, ". Falling back to runtime evaluation");
38786
+ return;
38762
38787
  }
38763
38788
  const usedPipes = fn.usedPipes || [];
38764
38789
  if (exprType === ExpressionType$1.Binding) {
@@ -39645,10 +39670,26 @@ const loadScript = (url, loadViaScriptTag, cacheable = false) => __awaiter$1(voi
39645
39670
  return Promise.resolve();
39646
39671
  }
39647
39672
  if (loadViaScriptTag) {
39648
- return fetchContent('text', _url, false, text => {
39649
- const script = document.createElement('script');
39650
- script.textContent = text;
39651
- document.head.appendChild(script);
39673
+ return new Promise((resolve, reject) => {
39674
+ let script = document.createElement('script');
39675
+ script.type = 'text/javascript';
39676
+ script.src = _url;
39677
+ script.async = false;
39678
+ if (script.readyState) { //IE
39679
+ script.onreadystatechange = () => {
39680
+ if (script.readyState === "loaded" || script.readyState === "complete") {
39681
+ script.onreadystatechange = null;
39682
+ resolve(true);
39683
+ }
39684
+ };
39685
+ }
39686
+ else { //Other browsers
39687
+ script.onload = () => {
39688
+ resolve(true);
39689
+ };
39690
+ }
39691
+ script.onerror = (error) => reject(error);
39692
+ document.getElementsByTagName('head')[0].appendChild(script);
39652
39693
  });
39653
39694
  }
39654
39695
  else if (cacheable) {
@@ -39664,13 +39705,6 @@ const loadScript = (url, loadViaScriptTag, cacheable = false) => __awaiter$1(voi
39664
39705
  .done(response => response)
39665
39706
  .fail(reason => reason);
39666
39707
  }
39667
- // return fetch(_url)
39668
- // .then(response => response.text())
39669
- // .then(text => {
39670
- // const script = document.createElement('script');
39671
- // script.textContent = text;
39672
- // document.head.appendChild(script);
39673
- // });
39674
39708
  });
39675
39709
  const loadScripts = (urls = [], loadViaScriptTag = true) => __awaiter$1(void 0, void 0, void 0, function* () {
39676
39710
  for (const url of urls) {
@@ -39700,7 +39734,8 @@ const setSessionStorageItem = (key, value) => {
39700
39734
  * @param key string
39701
39735
  */
39702
39736
  const getSessionStorageItem = key => {
39703
- let item = window.sessionStorage.getItem(_WM_APP_PROJECT.id);
39737
+ // sanity check for this to work with ng-codegen
39738
+ let item = window && window.sessionStorage && window.sessionStorage.getItem(_WM_APP_PROJECT.id);
39704
39739
  if (item) {
39705
39740
  item = JSON.parse(item);
39706
39741
  return item[key];
@@ -41919,7 +41954,7 @@ const setDimensionProp = (cssObj, key, nv) => {
41919
41954
  cssObj[cssKey] = nv;
41920
41955
  }
41921
41956
  };
41922
- const ɵ12 = setDimensionProp;
41957
+ const ɵ12$1 = setDimensionProp;
41923
41958
  const processDimensionAttributes = attrMap => {
41924
41959
  const attrKeys = Array.from(attrMap.keys());
41925
41960
  attrKeys.forEach((attrKey) => {
@@ -45073,7 +45108,7 @@ exports.ɵ0 = ɵ0$h;
45073
45108
  exports.ɵ1 = ɵ1$5;
45074
45109
  exports.ɵ10 = ɵ10$1;
45075
45110
  exports.ɵ11 = ɵ11$1;
45076
- exports.ɵ12 = ɵ12;
45111
+ exports.ɵ12 = ɵ12$1;
45077
45112
  exports.ɵ13 = ɵ13;
45078
45113
  exports.ɵ14 = ɵ14;
45079
45114
  exports.ɵ2 = ɵ2$4;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wavemaker/angular-codegen",
3
- "version": "11.0.1-next.139246",
3
+ "version": "11.0.1-next.139250",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1 +1 @@
1
- const{getHandlebarTemplate:getHandlebarTemplate,safeString:safeString}=require("./handlebar-helpers"),cheerio=require("cheerio");let processedPageExpr=[];const isDisplayExpressionAttr=e=>{return["displayexpression","displaylabel","displayimagesrc","nodelabel","nodeicon","nodechildren","nodeid","itemid","itemlabel","itemicon","itemaction","itembadge","itemchildren","itemlink","itemtarget","userrole","isactive"].includes(e)},checkIsCustomPipeExpression=function(e){let r=e.match(/(custom(\s*:))/g);return r&&r.length},updateBindExpressionForDisplayexpression=e=>{let r,t,n,s,i,a,o,l,p,c="";for(checkIsCustomPipeExpression(e)&&(e+=": __1"),e=e.replace(/\$\[data\[\$i\]/g,"$[__1"),n=0;n<e.length;n++)if(r=e[n],t=e[n+1],"$"===r&&"["===t){for(a=1,p=!1,o=!1,s=n+2;s<e.length;s++)if(" "!==(i=e[s])&&(p||(o='"'===e[s]||"'"===e[s],p=!0),"["===i?a++:"]"===i&&a--,!a)){l=e.substring(n+2,s),c+=o?"__1["+l+"]":l;break}n=s}else c+=r;return c},updateArrTypeExpr=(e,r,t)=>{let n=/\[\$i\]/g;return isArrayTypeProperty(r,t)?e.substr(0,e.lastIndexOf("[$i]")).replace("[$i]","[0]"):e.replace(n,"[0]")},isArrayTypeProperty=(e,r)=>{const t=r?r.attribs:{};return["dataset","dataoptions","customcolors"].includes(e)||"datavalue"===e&&void 0!==t.wmcheckbox||"selecteditem"===e&&void 0!==t.wmtable||"selecteditem"===e&&void 0!==t.wmlist||"datavalue"===e&&t.wmselect&&t.multiple},getFnForExpr=(e,r)=>{let t=e.replace(/"/g,'\\"');if(processedPageExpr.includes(e))return"";processedPageExpr.push(e);let n=(r=r||{}).isEvent,s=r.widgetNode,i=r.prop,a="";const o=require("../dependencies/expression-parser.cjs");let l;n?l=o.$parseEvent(e,!0):(-1!==e.indexOf("[$i]")&&(e=updateArrTypeExpr(e,i,s)),l=o.$parseExpr(e,!0));const p=safeString(l.fnArgs),c=safeString(l.fnBody),d=l.pipes||[];return d.forEach((e,r)=>{a+="["+e.reduce((e,r)=>"'"+e+"','"+r+"'")+"]"+(r<d.length?",":"")}),a=safeString(a),t=safeString(t),getHandlebarTemplate("expr-vs-fn")({expr:t,fnArgs:p,fnBody:c,fnPipes:a})+","},generateVariableExpressions=e=>{let r="";e=JSON.parse(e);const t=["onBefore","onBeforeUpdate","onResult","onBeforeOpen","onOpen","onBeforeMessageSend","onMessageReceive","onProgress","onError","onBeforeDatasetReady","onCanUpdate","onClick","onHide","onOk","onCancel","onBeforeClose","onClose","onTimerFire","onSuccess","onOnline","onOffline"];for(const n in e){const s=e[n];(s.dataBinding||[]).forEach(e=>{if(e.value&&e.value.startsWith("bind:")){const t=e.value.replace("bind:","");r+=getFnForExpr(t)}}),t.forEach(e=>{s[e]&&(r+=getFnForExpr(s[e],{isEvent:!0}))})}return r},generateExtraWidgetBindings=(e,r)=>{let t="";switch(r){case"wmalertdialog":t+=getFnForExpr("oktext");break;case"wmconfirmdialog":t+=getFnForExpr("oktext"),t+=getFnForExpr("canceltext");break;case"wmtable":t+=e.attribs.rowngclass?getFnForExpr(e.attribs.rowngclass):"";break;case"wmtablecolumn":t+=e.attribs["col-ng-class"]?getFnForExpr(e.attribs["col-ng-class"]):""}return t},isActionTypeNode=e=>["wmtableaction","wmtablerowaction","wmformaction"].some(r=>void 0!==e.attribs[r]),generatePageExpressions=(e,r,t)=>{let n,s,i="";const a=cheerio.load(e);if(processedPageExpr.length=0,a("*").each((e,r)=>{for(let e in r.attribs)e.endsWith(".bind")?(s=e.replace(".bind",""),n=r.attribs[e],isDisplayExpressionAttr(s)&&(n=updateBindExpressionForDisplayexpression(n),console.log("++++++++displayexpressoin binding updated",n)),i+=getFnForExpr(n,{prop:s,widgetNode:r})):e.endsWith(".event")?(s=e.replace(".event",""),n=r.attribs[e],i+=getFnForExpr(n,{isEvent:!0})):"displayexpression"===e?(n=r.attribs[e],i+=getFnForExpr(n)):"action"===e&&isActionTypeNode(r)&&(n=r.attribs[e],console.warn("<<<<<<<<found action node",n),i+=getFnForExpr(n));["wmalertdialog","wmconfirmdialog","wmtable","wmtablecolumn"].forEach(e=>{void 0!==r.attribs[e]&&(i+=generateExtraWidgetBindings(r,e))})}),i+=generateVariableExpressions(r),t){const e=(t=JSON.parse(t.toString())).properties||{};Object.keys(e).forEach(r=>{let t=e[r];"string"==typeof t.value&&t.value.startsWith("bind:")&&(i+=getFnForExpr(t.value.replace("bind:","")))})}return i};module.exports={generatePageExpressions:generatePageExpressions,generateVariableExpressions:generateVariableExpressions};
1
+ const{getHandlebarTemplate:getHandlebarTemplate,safeString:safeString}=require("./handlebar-helpers"),cheerio=require("cheerio");let processedPageExpr=[];const isDisplayExpressionAttr=e=>{return["displayexpression","displaylabel","displayimagesrc","nodelabel","nodeicon","nodechildren","nodeid","itemid","itemlabel","itemicon","itemaction","itembadge","itemchildren","itemlink","itemtarget","userrole","isactive"].includes(e)},checkIsCustomPipeExpression=function(e){let r=e.match(/(custom(\s*:))/g);return r&&r.length},updateBindExpressionForDisplayexpression=e=>{let r,t,n,i,s,a,o,l,p,d="";for(checkIsCustomPipeExpression(e)&&(e+=": __1"),e=e.replace(/\$\[data\[\$i\]/g,"$[__1"),n=0;n<e.length;n++)if(r=e[n],t=e[n+1],"$"===r&&"["===t){for(a=1,p=!1,o=!1,i=n+2;i<e.length;i++)if(" "!==(s=e[i])&&(p||(o='"'===e[i]||"'"===e[i],p=!0),"["===s?a++:"]"===s&&a--,!a)){l=e.substring(n+2,i),d+=o?"__1["+l+"]":l;break}n=i}else d+=r;return d},updateArrTypeExpr=(e,r,t)=>{let n=/\[\$i\]/g;return isArrayTypeProperty(r,t)?e.substr(0,e.lastIndexOf("[$i]")).replace("[$i]","[0]"):e.replace(n,"[0]")},isArrayTypeProperty=(e,r)=>{const t=r?r.attribs:{};return["dataset","dataoptions","customcolors"].includes(e)||"datavalue"===e&&void 0!==t.wmcheckbox||"selecteditem"===e&&void 0!==t.wmtable||"selecteditem"===e&&void 0!==t.wmlist||"datavalue"===e&&t.wmselect&&t.multiple},getFnForExpr=(e,r)=>{let t=(r=r||{}).isEvent,n=r.widgetNode,i=r.prop;if(t||-1===e.indexOf("[$i]")||(e=updateArrTypeExpr(e,i,n)),processedPageExpr.includes(e))return"";processedPageExpr.push(e);let s,a="";const o=require("../dependencies/expression-parser.cjs");s=t?o.$parseEvent(e,!0):o.$parseExpr(e,!0);const l=safeString(s.fnArgs),p=safeString(s.fnBody),d=s.pipes||[];d.forEach((e,r)=>{a+="["+e.reduce((e,r)=>"'"+e+"','"+r+"'")+"]"+(r<d.length?",":"")}),a=safeString(a);const c=safeString(e.replace(/"/g,'\\"'));return getHandlebarTemplate("expr-vs-fn")({expr:c,fnArgs:l,fnBody:p,fnPipes:a})+","},getExprForBinding=e=>{let r="";return"string"==typeof e&&e.startsWith("bind:")&&(r=getFnForExpr(e.replace("bind:",""))),r},generateFilterExprBindings=e=>{let r="";return e.rules&&_.forEach(e.rules,(e,t)=>{e.rules?r+=generateFilterExprBindings(e):("between"===e.matchMode&&(r+=getExprForBinding(e.secondvalue)),r+=getExprForBinding(e.value))}),r},getCRUDVariableExpressions=e=>{let r=e.dataBinding||{},t="";for(let e in r){(r[e]||[]).forEach(e=>{t+=getExprForBinding(e.value)})}return t},generateVariableExpressions=e=>{let r="";e=JSON.parse(e);const t=["onBefore","onBeforeUpdate","onResult","onBeforeOpen","onOpen","onBeforeMessageSend","onMessageReceive","onProgress","onError","onBeforeDatasetReady","onCanUpdate","onClick","onHide","onOk","onCancel","onBeforeClose","onClose","onTimerFire","onSuccess","onOnline","onOffline"];for(const n in e){const i=e[n];if("wm.LiveVariable"===i.category&&"read"===i.operation)r+=generateFilterExprBindings(i.filterExpressions);else if("wm.CrudVariable"===i.category)r+=getCRUDVariableExpressions(i);else{(i.dataBinding||[]).forEach(e=>{r+=getExprForBinding(e.value)})}t.forEach(e=>{i[e]&&(r+=getFnForExpr(i[e],{isEvent:!0}))})}return r},generateExtraWidgetBindings=(e,r)=>{let t="";switch(r){case"wmalertdialog":t+=getFnForExpr("oktext");break;case"wmconfirmdialog":t+=getFnForExpr("oktext"),t+=getFnForExpr("canceltext");break;case"wmtable":t+=e.attribs.rowngclass?getFnForExpr(e.attribs.rowngclass):"";break;case"wmtablecolumn":t+=e.attribs["col-ng-class"]?getFnForExpr(e.attribs["col-ng-class"]):""}return t},isActionTypeNode=e=>["wmtableaction","wmtablerowaction","wmformaction"].some(r=>void 0!==e.attribs[r]),generatePageExpressions=(e,r,t)=>{let n,i,s="";const a=cheerio.load(e);if(processedPageExpr.length=0,a("*").each((e,r)=>{for(let e in r.attribs)e.endsWith(".bind")?(i=e.replace(".bind",""),n=r.attribs[e],isDisplayExpressionAttr(i)&&(n=updateBindExpressionForDisplayexpression(n),console.log("++++++++displayexpressoin binding updated",n)),s+=getFnForExpr(n,{prop:i,widgetNode:r})):e.endsWith(".event")?(i=e.replace(".event",""),n=r.attribs[e],s+=getFnForExpr(n,{isEvent:!0})):"displayexpression"===e?(n=r.attribs[e],s+=getFnForExpr(n)):"action"===e&&isActionTypeNode(r)&&(n=r.attribs[e],console.warn("<<<<<<<<found action node",n),s+=getFnForExpr(n));["wmalertdialog","wmconfirmdialog","wmtable","wmtablecolumn"].forEach(e=>{void 0!==r.attribs[e]&&(s+=generateExtraWidgetBindings(r,e))})}),s+=generateVariableExpressions(r),t){const e=(t=JSON.parse(t.toString())).properties||{};Object.keys(e).forEach(r=>{let t=e[r];"string"==typeof t.value&&t.value.startsWith("bind:")&&(s+=getFnForExpr(t.value.replace("bind:","")))})}return s};module.exports={generatePageExpressions:generatePageExpressions,generateVariableExpressions:generateVariableExpressions};
@@ -1 +1 @@
1
- const{getHandlebarTemplate:getHandlebarTemplate,safeString:safeString}=require("./handlebar-helpers"),{readFile:readFile,writeFile:writeFile,getAppVariablesFilePath:getAppVariablesFilePath,formatContents:formatContents}=require("./wm-utils"),{generateVariableExpressions:generateVariableExpressions}=require("./expr-parser-utils"),generateAppVariableExpressions=async(e,a)=>{const r=safeString(generateVariableExpressions(e)),t=getHandlebarTemplate("component-expressions")({expressions:r});await writeFile(`${a}/src/app/app.component.expressions.ts`,formatContents(t,"javascript"))},generateAppVariables=async(e,a)=>{const r=getHandlebarTemplate("component-variables");let t=await readFile(getAppVariablesFilePath(e),"utf8")||"{}";const s=r({variables:safeString(t)});await writeFile(`${a}/src/app/app.component.variables.ts`,s),await generateAppVariableExpressions(t,a)};module.exports={generateAppVariables:generateAppVariables};
1
+ const{getHandlebarTemplate:getHandlebarTemplate,safeString:safeString}=require("./handlebar-helpers"),{readFile:readFile,writeFile:writeFile,getAppVariablesFilePath:getAppVariablesFilePath,formatContents:formatContents,getCodegenPath:getCodegenPath}=require("./wm-utils"),{generatePageExpressions:generatePageExpressions}=require("./expr-parser-utils"),generateAppVariableExpressions=async(e,a)=>{const t=await readFile(`${getCodegenPath()}/dependencies/app.component.html`,"utf-8")||"",r=safeString(generatePageExpressions(t,e)),s=getHandlebarTemplate("component-expressions")({expressions:r});await writeFile(`${a}/src/app/app.component.expressions.ts`,formatContents(s,"javascript"))},generateAppVariables=async(e,a)=>{const t=getHandlebarTemplate("component-variables");let r=await readFile(getAppVariablesFilePath(e),"utf8")||"{}";const s=t({variables:safeString(r)});await writeFile(`${a}/src/app/app.component.variables.ts`,s),await generateAppVariableExpressions(r,a)};module.exports={generateAppVariables:generateAppVariables};