@wavemaker/angular-codegen 11.0.1-next.139249 → 11.0.1-next.139253

Sign up to get free protection for your applications and to get access to all the features.
@@ -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.139249"
71
+ "@wavemaker/app-ng-runtime": "11.0.1-next.139253"
72
72
  },
73
73
  "devDependencies": {
74
74
  "@ampproject/rollup-plugin-closure-compiler": "0.8.5",
@@ -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,53 +17619,82 @@ 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, function def not found from the generated fn expressions for the page.
17623
+ // Handle bind expressions used internally inside WM components. e.g. wmAnchor used inside nav.comp.html
17624
+ if (isCSPEnabled()) {
17625
+ boundFn = function (ctx, locals) {
17626
+ // handle internal bindings for wm widgets used inside a component
17627
+ let _ctx = Object.assign({}, locals);
17628
+ Object.setPrototypeOf(_ctx, ctx);
17629
+ return _.get(_ctx, expr);
17630
+ };
17612
17631
  }
17613
17632
  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);
17633
+ const parser = new Parser$1(new Lexer);
17634
+ const ast = parser.parseBinding(expr, '', 0);
17635
+ if (ast.errors.length) {
17636
+ fn = noop;
17637
+ boundFn = fn;
17638
+ }
17639
+ else {
17640
+ const pipeNameVsIsPureMap = pipeProvider.getPipeNameVsIsPureMap();
17641
+ const astCompiler = new ASTCompiler(ast.ast, ExpressionType$1.Binding, pipeNameVsIsPureMap);
17642
+ fn = astCompiler.compile(defOnly);
17643
+ if (defOnly) {
17644
+ return fn;
17645
+ }
17646
+ if (fn.usedPipes.length) {
17647
+ const pipeArgs = [];
17648
+ let hasPurePipe = false;
17649
+ for (const [pipeName] of fn.usedPipes) {
17650
+ const pipeInfo = pipeProvider.meta(pipeName);
17651
+ let pipeInstance;
17652
+ if (!pipeInfo) {
17653
+ pipeInstance = nullPipe;
17636
17654
  }
17637
- if (pipeInfo.pure) {
17638
- purePipes.set(pipeName, pipeInstance);
17655
+ else {
17656
+ if (pipeInfo.pure) {
17657
+ hasPurePipe = true;
17658
+ pipeInstance = purePipes.get(pipeName);
17659
+ }
17660
+ if (!pipeInstance) {
17661
+ pipeInstance = pipeProvider.getInstance(pipeName);
17662
+ }
17663
+ if (pipeInfo.pure) {
17664
+ purePipes.set(pipeName, pipeInstance);
17665
+ }
17639
17666
  }
17667
+ pipeArgs.push(pipeInstance);
17640
17668
  }
17641
- pipeArgs.push(pipeInstance);
17669
+ pipeArgs.unshift(hasPurePipe ? new Map() : undefined);
17670
+ boundFn = fn.bind(undefined, ...pipeArgs);
17671
+ }
17672
+ else {
17673
+ boundFn = fn.bind(undefined, undefined);
17642
17674
  }
17643
- pipeArgs.unshift(hasPurePipe ? new Map() : undefined);
17644
- boundFn = fn.bind(undefined, ...pipeArgs);
17645
- }
17646
- else {
17647
- boundFn = fn.bind(undefined, undefined);
17648
17675
  }
17649
17676
  }
17650
17677
  }
17651
17678
  exprFnCache.set(expr, boundFn);
17652
17679
  return boundFn;
17653
17680
  }
17681
+ function simpleFunctionEvaluator(expr, ctx, locals) {
17682
+ let _ctx = Object.assign({}, locals);
17683
+ Object.setPrototypeOf(_ctx, ctx);
17684
+ let parts = expr.split('(');
17685
+ let fnName = parts[0];
17686
+ let computedFn = _.get(ctx, fnName);
17687
+ if (computedFn) {
17688
+ let args = parts[1].replace(')', '');
17689
+ args = args.split(',');
17690
+ let computedArgs = [];
17691
+ args.forEach((arg) => {
17692
+ arg = arg && arg.trim();
17693
+ computedArgs.push(_.get(_ctx, arg));
17694
+ });
17695
+ return computedFn.bind(_ctx)(...computedArgs);
17696
+ }
17697
+ }
17654
17698
  function $parseEvent(expr, defOnly) {
17655
17699
  if (!isString(expr)) {
17656
17700
  return noop;
@@ -17668,13 +17712,18 @@ function $parseEvent(expr, defOnly) {
17668
17712
  }
17669
17713
  // fallback to generate function in runtime. This will break if CSP is enabled
17670
17714
  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;
17715
+ if (isCSPEnabled()) {
17716
+ fn = simpleFunctionEvaluator.bind(undefined, expr);
17717
+ }
17718
+ else {
17719
+ const parser = new Parser$1(new Lexer);
17720
+ const ast = parser.parseAction(expr, '', 0);
17721
+ if (ast.errors.length) {
17722
+ return noop;
17723
+ }
17724
+ const astCompiler = new ASTCompiler(ast.ast, ExpressionType$1.Action);
17725
+ fn = astCompiler.compile(defOnly);
17675
17726
  }
17676
- const astCompiler = new ASTCompiler(ast.ast, ExpressionType$1.Action);
17677
- fn = astCompiler.compile(defOnly);
17678
17727
  }
17679
17728
  eventFnCache.set(expr, fn);
17680
17729
  return fn;
@@ -17688,7 +17737,6 @@ const getFnByExpr = (expr) => fnNameMap.get(expr);
17688
17737
  const fnExecutor = (expr, exprType) => {
17689
17738
  let fn = getFnByExpr(expr);
17690
17739
  if (!fn) {
17691
- console.warn("didn't find fn for the expr: ", expr, ". Falling back to runtime evaluation");
17692
17740
  return;
17693
17741
  }
17694
17742
  const usedPipes = fn.usedPipes || [];
@@ -17731,7 +17779,7 @@ const fnExecutor = (expr, exprType) => {
17731
17779
  }
17732
17780
  return fn;
17733
17781
  };
17734
- const ɵ11 = fnExecutor;
17782
+ const ɵ12 = fnExecutor;
17735
17783
  const getFnForBindExpr = (expr) => {
17736
17784
  return fnExecutor(expr, ExpressionType$1.Binding);
17737
17785
  };
@@ -17758,3 +17806,4 @@ exports.ɵ8 = ɵ8;
17758
17806
  exports.ɵ9 = ɵ9;
17759
17807
  exports.ɵ10 = ɵ10;
17760
17808
  exports.ɵ11 = ɵ11;
17809
+ 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,53 +42703,82 @@ 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, function def not found from the generated fn expressions for the page.
42707
+ // Handle bind expressions used internally inside WM components. e.g. wmAnchor used inside nav.comp.html
42708
+ if (isCSPEnabled()) {
42709
+ boundFn = function (ctx, locals) {
42710
+ // handle internal bindings for wm widgets used inside a component
42711
+ let _ctx = Object.assign({}, locals);
42712
+ Object.setPrototypeOf(_ctx, ctx);
42713
+ return _.get(_ctx, expr);
42714
+ };
42697
42715
  }
42698
42716
  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);
42717
+ const parser = new Parser$1(new Lexer);
42718
+ const ast = parser.parseBinding(expr, '', 0);
42719
+ if (ast.errors.length) {
42720
+ fn = noop$1$1;
42721
+ boundFn = fn;
42722
+ }
42723
+ else {
42724
+ const pipeNameVsIsPureMap = pipeProvider.getPipeNameVsIsPureMap();
42725
+ const astCompiler = new ASTCompiler(ast.ast, ExpressionType$1.Binding, pipeNameVsIsPureMap);
42726
+ fn = astCompiler.compile(defOnly);
42727
+ if (defOnly) {
42728
+ return fn;
42729
+ }
42730
+ if (fn.usedPipes.length) {
42731
+ const pipeArgs = [];
42732
+ let hasPurePipe = false;
42733
+ for (const [pipeName] of fn.usedPipes) {
42734
+ const pipeInfo = pipeProvider.meta(pipeName);
42735
+ let pipeInstance;
42736
+ if (!pipeInfo) {
42737
+ pipeInstance = nullPipe;
42721
42738
  }
42722
- if (pipeInfo.pure) {
42723
- purePipes.set(pipeName, pipeInstance);
42739
+ else {
42740
+ if (pipeInfo.pure) {
42741
+ hasPurePipe = true;
42742
+ pipeInstance = purePipes.get(pipeName);
42743
+ }
42744
+ if (!pipeInstance) {
42745
+ pipeInstance = pipeProvider.getInstance(pipeName);
42746
+ }
42747
+ if (pipeInfo.pure) {
42748
+ purePipes.set(pipeName, pipeInstance);
42749
+ }
42724
42750
  }
42751
+ pipeArgs.push(pipeInstance);
42725
42752
  }
42726
- pipeArgs.push(pipeInstance);
42753
+ pipeArgs.unshift(hasPurePipe ? new Map() : undefined);
42754
+ boundFn = fn.bind(undefined, ...pipeArgs);
42755
+ }
42756
+ else {
42757
+ boundFn = fn.bind(undefined, undefined);
42727
42758
  }
42728
- pipeArgs.unshift(hasPurePipe ? new Map() : undefined);
42729
- boundFn = fn.bind(undefined, ...pipeArgs);
42730
- }
42731
- else {
42732
- boundFn = fn.bind(undefined, undefined);
42733
42759
  }
42734
42760
  }
42735
42761
  }
42736
42762
  exprFnCache.set(expr, boundFn);
42737
42763
  return boundFn;
42738
42764
  }
42765
+ function simpleFunctionEvaluator(expr, ctx, locals) {
42766
+ let _ctx = Object.assign({}, locals);
42767
+ Object.setPrototypeOf(_ctx, ctx);
42768
+ let parts = expr.split('(');
42769
+ let fnName = parts[0];
42770
+ let computedFn = _.get(ctx, fnName);
42771
+ if (computedFn) {
42772
+ let args = parts[1].replace(')', '');
42773
+ args = args.split(',');
42774
+ let computedArgs = [];
42775
+ args.forEach((arg) => {
42776
+ arg = arg && arg.trim();
42777
+ computedArgs.push(_.get(_ctx, arg));
42778
+ });
42779
+ return computedFn.bind(_ctx)(...computedArgs);
42780
+ }
42781
+ }
42739
42782
  function $parseEvent(expr, defOnly) {
42740
42783
  if (!isString$1(expr)) {
42741
42784
  return noop$1$1;
@@ -42753,13 +42796,18 @@ function $parseEvent(expr, defOnly) {
42753
42796
  }
42754
42797
  // fallback to generate function in runtime. This will break if CSP is enabled
42755
42798
  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;
42799
+ if (isCSPEnabled()) {
42800
+ fn = simpleFunctionEvaluator.bind(undefined, expr);
42801
+ }
42802
+ else {
42803
+ const parser = new Parser$1(new Lexer);
42804
+ const ast = parser.parseAction(expr, '', 0);
42805
+ if (ast.errors.length) {
42806
+ return noop$1$1;
42807
+ }
42808
+ const astCompiler = new ASTCompiler(ast.ast, ExpressionType$1.Action);
42809
+ fn = astCompiler.compile(defOnly);
42760
42810
  }
42761
- const astCompiler = new ASTCompiler(ast.ast, ExpressionType$1.Action);
42762
- fn = astCompiler.compile(defOnly);
42763
42811
  }
42764
42812
  eventFnCache.set(expr, fn);
42765
42813
  return fn;
@@ -42769,7 +42817,6 @@ const getFnByExpr = (expr) => fnNameMap.get(expr);
42769
42817
  const fnExecutor = (expr, exprType) => {
42770
42818
  let fn = getFnByExpr(expr);
42771
42819
  if (!fn) {
42772
- console.warn("didn't find fn for the expr: ", expr, ". Falling back to runtime evaluation");
42773
42820
  return;
42774
42821
  }
42775
42822
  const usedPipes = fn.usedPipes || [];
@@ -43657,10 +43704,26 @@ const loadScript = (url, loadViaScriptTag, cacheable = false) => __awaiter$1(voi
43657
43704
  return Promise.resolve();
43658
43705
  }
43659
43706
  if (loadViaScriptTag) {
43660
- return fetchContent('text', _url, false, text => {
43661
- const script = document.createElement('script');
43662
- script.textContent = text;
43663
- document.head.appendChild(script);
43707
+ return new Promise((resolve, reject) => {
43708
+ let script = document.createElement('script');
43709
+ script.type = 'text/javascript';
43710
+ script.src = _url;
43711
+ script.async = false;
43712
+ if (script.readyState) { //IE
43713
+ script.onreadystatechange = () => {
43714
+ if (script.readyState === "loaded" || script.readyState === "complete") {
43715
+ script.onreadystatechange = null;
43716
+ resolve(true);
43717
+ }
43718
+ };
43719
+ }
43720
+ else { //Other browsers
43721
+ script.onload = () => {
43722
+ resolve(true);
43723
+ };
43724
+ }
43725
+ script.onerror = (error) => reject(error);
43726
+ document.getElementsByTagName('head')[0].appendChild(script);
43664
43727
  });
43665
43728
  }
43666
43729
  else if (cacheable) {
@@ -43676,13 +43739,6 @@ const loadScript = (url, loadViaScriptTag, cacheable = false) => __awaiter$1(voi
43676
43739
  .done(response => response)
43677
43740
  .fail(reason => reason);
43678
43741
  }
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
43742
  });
43687
43743
  const loadScripts = (urls = [], loadViaScriptTag = true) => __awaiter$1(void 0, void 0, void 0, function* () {
43688
43744
  for (const url of urls) {
@@ -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,53 +38691,82 @@ 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, function def not found from the generated fn expressions for the page.
38695
+ // Handle bind expressions used internally inside WM components. e.g. wmAnchor used inside nav.comp.html
38696
+ if (isCSPEnabled()) {
38697
+ boundFn = function (ctx, locals) {
38698
+ // handle internal bindings for wm widgets used inside a component
38699
+ let _ctx = Object.assign({}, locals);
38700
+ Object.setPrototypeOf(_ctx, ctx);
38701
+ return _.get(_ctx, expr);
38702
+ };
38685
38703
  }
38686
38704
  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);
38705
+ const parser = new Parser$1(new Lexer);
38706
+ const ast = parser.parseBinding(expr, '', 0);
38707
+ if (ast.errors.length) {
38708
+ fn = noop$1$1;
38709
+ boundFn = fn;
38710
+ }
38711
+ else {
38712
+ const pipeNameVsIsPureMap = pipeProvider.getPipeNameVsIsPureMap();
38713
+ const astCompiler = new ASTCompiler(ast.ast, ExpressionType$1.Binding, pipeNameVsIsPureMap);
38714
+ fn = astCompiler.compile(defOnly);
38715
+ if (defOnly) {
38716
+ return fn;
38717
+ }
38718
+ if (fn.usedPipes.length) {
38719
+ const pipeArgs = [];
38720
+ let hasPurePipe = false;
38721
+ for (const [pipeName] of fn.usedPipes) {
38722
+ const pipeInfo = pipeProvider.meta(pipeName);
38723
+ let pipeInstance;
38724
+ if (!pipeInfo) {
38725
+ pipeInstance = nullPipe;
38709
38726
  }
38710
- if (pipeInfo.pure) {
38711
- purePipes.set(pipeName, pipeInstance);
38727
+ else {
38728
+ if (pipeInfo.pure) {
38729
+ hasPurePipe = true;
38730
+ pipeInstance = purePipes.get(pipeName);
38731
+ }
38732
+ if (!pipeInstance) {
38733
+ pipeInstance = pipeProvider.getInstance(pipeName);
38734
+ }
38735
+ if (pipeInfo.pure) {
38736
+ purePipes.set(pipeName, pipeInstance);
38737
+ }
38712
38738
  }
38739
+ pipeArgs.push(pipeInstance);
38713
38740
  }
38714
- pipeArgs.push(pipeInstance);
38741
+ pipeArgs.unshift(hasPurePipe ? new Map() : undefined);
38742
+ boundFn = fn.bind(undefined, ...pipeArgs);
38743
+ }
38744
+ else {
38745
+ boundFn = fn.bind(undefined, undefined);
38715
38746
  }
38716
- pipeArgs.unshift(hasPurePipe ? new Map() : undefined);
38717
- boundFn = fn.bind(undefined, ...pipeArgs);
38718
- }
38719
- else {
38720
- boundFn = fn.bind(undefined, undefined);
38721
38747
  }
38722
38748
  }
38723
38749
  }
38724
38750
  exprFnCache.set(expr, boundFn);
38725
38751
  return boundFn;
38726
38752
  }
38753
+ function simpleFunctionEvaluator(expr, ctx, locals) {
38754
+ let _ctx = Object.assign({}, locals);
38755
+ Object.setPrototypeOf(_ctx, ctx);
38756
+ let parts = expr.split('(');
38757
+ let fnName = parts[0];
38758
+ let computedFn = _.get(ctx, fnName);
38759
+ if (computedFn) {
38760
+ let args = parts[1].replace(')', '');
38761
+ args = args.split(',');
38762
+ let computedArgs = [];
38763
+ args.forEach((arg) => {
38764
+ arg = arg && arg.trim();
38765
+ computedArgs.push(_.get(_ctx, arg));
38766
+ });
38767
+ return computedFn.bind(_ctx)(...computedArgs);
38768
+ }
38769
+ }
38727
38770
  function $parseEvent(expr, defOnly) {
38728
38771
  if (!isString$1(expr)) {
38729
38772
  return noop$1$1;
@@ -38741,13 +38784,18 @@ function $parseEvent(expr, defOnly) {
38741
38784
  }
38742
38785
  // fallback to generate function in runtime. This will break if CSP is enabled
38743
38786
  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;
38787
+ if (isCSPEnabled()) {
38788
+ fn = simpleFunctionEvaluator.bind(undefined, expr);
38789
+ }
38790
+ else {
38791
+ const parser = new Parser$1(new Lexer);
38792
+ const ast = parser.parseAction(expr, '', 0);
38793
+ if (ast.errors.length) {
38794
+ return noop$1$1;
38795
+ }
38796
+ const astCompiler = new ASTCompiler(ast.ast, ExpressionType$1.Action);
38797
+ fn = astCompiler.compile(defOnly);
38748
38798
  }
38749
- const astCompiler = new ASTCompiler(ast.ast, ExpressionType$1.Action);
38750
- fn = astCompiler.compile(defOnly);
38751
38799
  }
38752
38800
  eventFnCache.set(expr, fn);
38753
38801
  return fn;
@@ -38757,7 +38805,6 @@ const getFnByExpr = (expr) => fnNameMap.get(expr);
38757
38805
  const fnExecutor = (expr, exprType) => {
38758
38806
  let fn = getFnByExpr(expr);
38759
38807
  if (!fn) {
38760
- console.warn("didn't find fn for the expr: ", expr, ". Falling back to runtime evaluation");
38761
38808
  return;
38762
38809
  }
38763
38810
  const usedPipes = fn.usedPipes || [];
@@ -39645,10 +39692,26 @@ const loadScript = (url, loadViaScriptTag, cacheable = false) => __awaiter$1(voi
39645
39692
  return Promise.resolve();
39646
39693
  }
39647
39694
  if (loadViaScriptTag) {
39648
- return fetchContent('text', _url, false, text => {
39649
- const script = document.createElement('script');
39650
- script.textContent = text;
39651
- document.head.appendChild(script);
39695
+ return new Promise((resolve, reject) => {
39696
+ let script = document.createElement('script');
39697
+ script.type = 'text/javascript';
39698
+ script.src = _url;
39699
+ script.async = false;
39700
+ if (script.readyState) { //IE
39701
+ script.onreadystatechange = () => {
39702
+ if (script.readyState === "loaded" || script.readyState === "complete") {
39703
+ script.onreadystatechange = null;
39704
+ resolve(true);
39705
+ }
39706
+ };
39707
+ }
39708
+ else { //Other browsers
39709
+ script.onload = () => {
39710
+ resolve(true);
39711
+ };
39712
+ }
39713
+ script.onerror = (error) => reject(error);
39714
+ document.getElementsByTagName('head')[0].appendChild(script);
39652
39715
  });
39653
39716
  }
39654
39717
  else if (cacheable) {
@@ -39664,13 +39727,6 @@ const loadScript = (url, loadViaScriptTag, cacheable = false) => __awaiter$1(voi
39664
39727
  .done(response => response)
39665
39728
  .fail(reason => reason);
39666
39729
  }
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
39730
  });
39675
39731
  const loadScripts = (urls = [], loadViaScriptTag = true) => __awaiter$1(void 0, void 0, void 0, function* () {
39676
39732
  for (const url of urls) {
@@ -41920,7 +41976,7 @@ const setDimensionProp = (cssObj, key, nv) => {
41920
41976
  cssObj[cssKey] = nv;
41921
41977
  }
41922
41978
  };
41923
- const ɵ12 = setDimensionProp;
41979
+ const ɵ12$1 = setDimensionProp;
41924
41980
  const processDimensionAttributes = attrMap => {
41925
41981
  const attrKeys = Array.from(attrMap.keys());
41926
41982
  attrKeys.forEach((attrKey) => {
@@ -45074,7 +45130,7 @@ exports.ɵ0 = ɵ0$h;
45074
45130
  exports.ɵ1 = ɵ1$5;
45075
45131
  exports.ɵ10 = ɵ10$1;
45076
45132
  exports.ɵ11 = ɵ11$1;
45077
- exports.ɵ12 = ɵ12;
45133
+ exports.ɵ12 = ɵ12$1;
45078
45134
  exports.ɵ13 = ɵ13;
45079
45135
  exports.ɵ14 = ɵ14;
45080
45136
  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,53 +38691,82 @@ 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, function def not found from the generated fn expressions for the page.
38695
+ // Handle bind expressions used internally inside WM components. e.g. wmAnchor used inside nav.comp.html
38696
+ if (isCSPEnabled()) {
38697
+ boundFn = function (ctx, locals) {
38698
+ // handle internal bindings for wm widgets used inside a component
38699
+ let _ctx = Object.assign({}, locals);
38700
+ Object.setPrototypeOf(_ctx, ctx);
38701
+ return _.get(_ctx, expr);
38702
+ };
38685
38703
  }
38686
38704
  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);
38705
+ const parser = new Parser$1(new Lexer);
38706
+ const ast = parser.parseBinding(expr, '', 0);
38707
+ if (ast.errors.length) {
38708
+ fn = noop$1$1;
38709
+ boundFn = fn;
38710
+ }
38711
+ else {
38712
+ const pipeNameVsIsPureMap = pipeProvider.getPipeNameVsIsPureMap();
38713
+ const astCompiler = new ASTCompiler(ast.ast, ExpressionType$1.Binding, pipeNameVsIsPureMap);
38714
+ fn = astCompiler.compile(defOnly);
38715
+ if (defOnly) {
38716
+ return fn;
38717
+ }
38718
+ if (fn.usedPipes.length) {
38719
+ const pipeArgs = [];
38720
+ let hasPurePipe = false;
38721
+ for (const [pipeName] of fn.usedPipes) {
38722
+ const pipeInfo = pipeProvider.meta(pipeName);
38723
+ let pipeInstance;
38724
+ if (!pipeInfo) {
38725
+ pipeInstance = nullPipe;
38709
38726
  }
38710
- if (pipeInfo.pure) {
38711
- purePipes.set(pipeName, pipeInstance);
38727
+ else {
38728
+ if (pipeInfo.pure) {
38729
+ hasPurePipe = true;
38730
+ pipeInstance = purePipes.get(pipeName);
38731
+ }
38732
+ if (!pipeInstance) {
38733
+ pipeInstance = pipeProvider.getInstance(pipeName);
38734
+ }
38735
+ if (pipeInfo.pure) {
38736
+ purePipes.set(pipeName, pipeInstance);
38737
+ }
38712
38738
  }
38739
+ pipeArgs.push(pipeInstance);
38713
38740
  }
38714
- pipeArgs.push(pipeInstance);
38741
+ pipeArgs.unshift(hasPurePipe ? new Map() : undefined);
38742
+ boundFn = fn.bind(undefined, ...pipeArgs);
38743
+ }
38744
+ else {
38745
+ boundFn = fn.bind(undefined, undefined);
38715
38746
  }
38716
- pipeArgs.unshift(hasPurePipe ? new Map() : undefined);
38717
- boundFn = fn.bind(undefined, ...pipeArgs);
38718
- }
38719
- else {
38720
- boundFn = fn.bind(undefined, undefined);
38721
38747
  }
38722
38748
  }
38723
38749
  }
38724
38750
  exprFnCache.set(expr, boundFn);
38725
38751
  return boundFn;
38726
38752
  }
38753
+ function simpleFunctionEvaluator(expr, ctx, locals) {
38754
+ let _ctx = Object.assign({}, locals);
38755
+ Object.setPrototypeOf(_ctx, ctx);
38756
+ let parts = expr.split('(');
38757
+ let fnName = parts[0];
38758
+ let computedFn = _.get(ctx, fnName);
38759
+ if (computedFn) {
38760
+ let args = parts[1].replace(')', '');
38761
+ args = args.split(',');
38762
+ let computedArgs = [];
38763
+ args.forEach((arg) => {
38764
+ arg = arg && arg.trim();
38765
+ computedArgs.push(_.get(_ctx, arg));
38766
+ });
38767
+ return computedFn.bind(_ctx)(...computedArgs);
38768
+ }
38769
+ }
38727
38770
  function $parseEvent(expr, defOnly) {
38728
38771
  if (!isString$1(expr)) {
38729
38772
  return noop$1$1;
@@ -38741,13 +38784,18 @@ function $parseEvent(expr, defOnly) {
38741
38784
  }
38742
38785
  // fallback to generate function in runtime. This will break if CSP is enabled
38743
38786
  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;
38787
+ if (isCSPEnabled()) {
38788
+ fn = simpleFunctionEvaluator.bind(undefined, expr);
38789
+ }
38790
+ else {
38791
+ const parser = new Parser$1(new Lexer);
38792
+ const ast = parser.parseAction(expr, '', 0);
38793
+ if (ast.errors.length) {
38794
+ return noop$1$1;
38795
+ }
38796
+ const astCompiler = new ASTCompiler(ast.ast, ExpressionType$1.Action);
38797
+ fn = astCompiler.compile(defOnly);
38748
38798
  }
38749
- const astCompiler = new ASTCompiler(ast.ast, ExpressionType$1.Action);
38750
- fn = astCompiler.compile(defOnly);
38751
38799
  }
38752
38800
  eventFnCache.set(expr, fn);
38753
38801
  return fn;
@@ -38757,7 +38805,6 @@ const getFnByExpr = (expr) => fnNameMap.get(expr);
38757
38805
  const fnExecutor = (expr, exprType) => {
38758
38806
  let fn = getFnByExpr(expr);
38759
38807
  if (!fn) {
38760
- console.warn("didn't find fn for the expr: ", expr, ". Falling back to runtime evaluation");
38761
38808
  return;
38762
38809
  }
38763
38810
  const usedPipes = fn.usedPipes || [];
@@ -39645,10 +39692,26 @@ const loadScript = (url, loadViaScriptTag, cacheable = false) => __awaiter$1(voi
39645
39692
  return Promise.resolve();
39646
39693
  }
39647
39694
  if (loadViaScriptTag) {
39648
- return fetchContent('text', _url, false, text => {
39649
- const script = document.createElement('script');
39650
- script.textContent = text;
39651
- document.head.appendChild(script);
39695
+ return new Promise((resolve, reject) => {
39696
+ let script = document.createElement('script');
39697
+ script.type = 'text/javascript';
39698
+ script.src = _url;
39699
+ script.async = false;
39700
+ if (script.readyState) { //IE
39701
+ script.onreadystatechange = () => {
39702
+ if (script.readyState === "loaded" || script.readyState === "complete") {
39703
+ script.onreadystatechange = null;
39704
+ resolve(true);
39705
+ }
39706
+ };
39707
+ }
39708
+ else { //Other browsers
39709
+ script.onload = () => {
39710
+ resolve(true);
39711
+ };
39712
+ }
39713
+ script.onerror = (error) => reject(error);
39714
+ document.getElementsByTagName('head')[0].appendChild(script);
39652
39715
  });
39653
39716
  }
39654
39717
  else if (cacheable) {
@@ -39664,13 +39727,6 @@ const loadScript = (url, loadViaScriptTag, cacheable = false) => __awaiter$1(voi
39664
39727
  .done(response => response)
39665
39728
  .fail(reason => reason);
39666
39729
  }
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
39730
  });
39675
39731
  const loadScripts = (urls = [], loadViaScriptTag = true) => __awaiter$1(void 0, void 0, void 0, function* () {
39676
39732
  for (const url of urls) {
@@ -41920,7 +41976,7 @@ const setDimensionProp = (cssObj, key, nv) => {
41920
41976
  cssObj[cssKey] = nv;
41921
41977
  }
41922
41978
  };
41923
- const ɵ12 = setDimensionProp;
41979
+ const ɵ12$1 = setDimensionProp;
41924
41980
  const processDimensionAttributes = attrMap => {
41925
41981
  const attrKeys = Array.from(attrMap.keys());
41926
41982
  attrKeys.forEach((attrKey) => {
@@ -45074,7 +45130,7 @@ exports.ɵ0 = ɵ0$h;
45074
45130
  exports.ɵ1 = ɵ1$5;
45075
45131
  exports.ɵ10 = ɵ10$1;
45076
45132
  exports.ɵ11 = ɵ11$1;
45077
- exports.ɵ12 = ɵ12;
45133
+ exports.ɵ12 = ɵ12$1;
45078
45134
  exports.ɵ13 = ɵ13;
45079
45135
  exports.ɵ14 = ɵ14;
45080
45136
  exports.ɵ2 = ɵ2$4;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wavemaker/angular-codegen",
3
- "version": "11.0.1-next.139249",
3
+ "version": "11.0.1-next.139253",
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=(r=r||{}).isEvent,n=r.widgetNode,s=r.prop;if(t||-1===e.indexOf("[$i]")||(e=updateArrTypeExpr(e,s,n)),processedPageExpr.includes(e))return"";processedPageExpr.push(e);let i,a="";const o=require("../dependencies/expression-parser.cjs");i=t?o.$parseEvent(e,!0):o.$parseExpr(e,!0);const l=safeString(i.fnArgs),p=safeString(i.fnBody),c=i.pipes||[];c.forEach((e,r)=>{a+="["+e.reduce((e,r)=>"'"+e+"','"+r+"'")+"]"+(r<c.length?",":"")}),a=safeString(a);const d=safeString(e.replace(/"/g,'\\"'));return getHandlebarTemplate("expr-vs-fn")({expr:d,fnArgs:l,fnBody:p,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&&"string"==typeof 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};