@wavemaker/angular-codegen 11.0.1-next.139250 → 11.0.1-next.139254
Sign up to get free protection for your applications and to get access to all the features.
- angular-codegen/angular-app/package.json +1 -1
- angular-codegen/dependencies/expression-parser.cjs.js +26 -4
- angular-codegen/dependencies/pipe-provider.cjs.js +26 -4
- angular-codegen/dependencies/transpilation-mobile.cjs.js +26 -4
- angular-codegen/dependencies/transpilation-web.cjs.js +26 -4
- angular-codegen/package.json +1 -1
- angular-codegen/src/expr-parser-utils.js +1 -1
@@ -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.
|
71
|
+
"@wavemaker/app-ng-runtime": "11.0.1-next.139254"
|
72
72
|
},
|
73
73
|
"devDependencies": {
|
74
74
|
"@ampproject/rollup-plugin-closure-compiler": "0.8.5",
|
@@ -17619,9 +17619,15 @@ function $parseExpr(expr, defOnly) {
|
|
17619
17619
|
}
|
17620
17620
|
// fallback to generate function in runtime. This will break if CSP is enabled
|
17621
17621
|
if (!boundFn) {
|
17622
|
-
// If CSP enabled,
|
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
|
17623
17624
|
if (isCSPEnabled()) {
|
17624
|
-
boundFn =
|
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
|
+
};
|
17625
17631
|
}
|
17626
17632
|
else {
|
17627
17633
|
const parser = new Parser$1(new Lexer);
|
@@ -17672,6 +17678,23 @@ function $parseExpr(expr, defOnly) {
|
|
17672
17678
|
exprFnCache.set(expr, boundFn);
|
17673
17679
|
return boundFn;
|
17674
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
|
+
}
|
17675
17698
|
function $parseEvent(expr, defOnly) {
|
17676
17699
|
if (!isString(expr)) {
|
17677
17700
|
return noop;
|
@@ -17690,7 +17713,7 @@ function $parseEvent(expr, defOnly) {
|
|
17690
17713
|
// fallback to generate function in runtime. This will break if CSP is enabled
|
17691
17714
|
if (!fn) {
|
17692
17715
|
if (isCSPEnabled()) {
|
17693
|
-
fn =
|
17716
|
+
fn = simpleFunctionEvaluator.bind(undefined, expr);
|
17694
17717
|
}
|
17695
17718
|
else {
|
17696
17719
|
const parser = new Parser$1(new Lexer);
|
@@ -17714,7 +17737,6 @@ const getFnByExpr = (expr) => fnNameMap.get(expr);
|
|
17714
17737
|
const fnExecutor = (expr, exprType) => {
|
17715
17738
|
let fn = getFnByExpr(expr);
|
17716
17739
|
if (!fn) {
|
17717
|
-
console.warn("didn't find fn for the expr: ", expr, ". Falling back to runtime evaluation");
|
17718
17740
|
return;
|
17719
17741
|
}
|
17720
17742
|
const usedPipes = fn.usedPipes || [];
|
@@ -42703,9 +42703,15 @@ function $parseExpr(expr, defOnly) {
|
|
42703
42703
|
}
|
42704
42704
|
// fallback to generate function in runtime. This will break if CSP is enabled
|
42705
42705
|
if (!boundFn) {
|
42706
|
-
// If CSP enabled,
|
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
|
42707
42708
|
if (isCSPEnabled()) {
|
42708
|
-
boundFn =
|
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
|
+
};
|
42709
42715
|
}
|
42710
42716
|
else {
|
42711
42717
|
const parser = new Parser$1(new Lexer);
|
@@ -42756,6 +42762,23 @@ function $parseExpr(expr, defOnly) {
|
|
42756
42762
|
exprFnCache.set(expr, boundFn);
|
42757
42763
|
return boundFn;
|
42758
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
|
+
}
|
42759
42782
|
function $parseEvent(expr, defOnly) {
|
42760
42783
|
if (!isString$1(expr)) {
|
42761
42784
|
return noop$1$1;
|
@@ -42774,7 +42797,7 @@ function $parseEvent(expr, defOnly) {
|
|
42774
42797
|
// fallback to generate function in runtime. This will break if CSP is enabled
|
42775
42798
|
if (!fn) {
|
42776
42799
|
if (isCSPEnabled()) {
|
42777
|
-
fn =
|
42800
|
+
fn = simpleFunctionEvaluator.bind(undefined, expr);
|
42778
42801
|
}
|
42779
42802
|
else {
|
42780
42803
|
const parser = new Parser$1(new Lexer);
|
@@ -42794,7 +42817,6 @@ const getFnByExpr = (expr) => fnNameMap.get(expr);
|
|
42794
42817
|
const fnExecutor = (expr, exprType) => {
|
42795
42818
|
let fn = getFnByExpr(expr);
|
42796
42819
|
if (!fn) {
|
42797
|
-
console.warn("didn't find fn for the expr: ", expr, ". Falling back to runtime evaluation");
|
42798
42820
|
return;
|
42799
42821
|
}
|
42800
42822
|
const usedPipes = fn.usedPipes || [];
|
@@ -38691,9 +38691,15 @@ function $parseExpr(expr, defOnly) {
|
|
38691
38691
|
}
|
38692
38692
|
// fallback to generate function in runtime. This will break if CSP is enabled
|
38693
38693
|
if (!boundFn) {
|
38694
|
-
// If CSP enabled,
|
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
|
38695
38696
|
if (isCSPEnabled()) {
|
38696
|
-
boundFn =
|
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
|
+
};
|
38697
38703
|
}
|
38698
38704
|
else {
|
38699
38705
|
const parser = new Parser$1(new Lexer);
|
@@ -38744,6 +38750,23 @@ function $parseExpr(expr, defOnly) {
|
|
38744
38750
|
exprFnCache.set(expr, boundFn);
|
38745
38751
|
return boundFn;
|
38746
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
|
+
}
|
38747
38770
|
function $parseEvent(expr, defOnly) {
|
38748
38771
|
if (!isString$1(expr)) {
|
38749
38772
|
return noop$1$1;
|
@@ -38762,7 +38785,7 @@ function $parseEvent(expr, defOnly) {
|
|
38762
38785
|
// fallback to generate function in runtime. This will break if CSP is enabled
|
38763
38786
|
if (!fn) {
|
38764
38787
|
if (isCSPEnabled()) {
|
38765
|
-
fn =
|
38788
|
+
fn = simpleFunctionEvaluator.bind(undefined, expr);
|
38766
38789
|
}
|
38767
38790
|
else {
|
38768
38791
|
const parser = new Parser$1(new Lexer);
|
@@ -38782,7 +38805,6 @@ const getFnByExpr = (expr) => fnNameMap.get(expr);
|
|
38782
38805
|
const fnExecutor = (expr, exprType) => {
|
38783
38806
|
let fn = getFnByExpr(expr);
|
38784
38807
|
if (!fn) {
|
38785
|
-
console.warn("didn't find fn for the expr: ", expr, ". Falling back to runtime evaluation");
|
38786
38808
|
return;
|
38787
38809
|
}
|
38788
38810
|
const usedPipes = fn.usedPipes || [];
|
@@ -38691,9 +38691,15 @@ function $parseExpr(expr, defOnly) {
|
|
38691
38691
|
}
|
38692
38692
|
// fallback to generate function in runtime. This will break if CSP is enabled
|
38693
38693
|
if (!boundFn) {
|
38694
|
-
// If CSP enabled,
|
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
|
38695
38696
|
if (isCSPEnabled()) {
|
38696
|
-
boundFn =
|
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
|
+
};
|
38697
38703
|
}
|
38698
38704
|
else {
|
38699
38705
|
const parser = new Parser$1(new Lexer);
|
@@ -38744,6 +38750,23 @@ function $parseExpr(expr, defOnly) {
|
|
38744
38750
|
exprFnCache.set(expr, boundFn);
|
38745
38751
|
return boundFn;
|
38746
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
|
+
}
|
38747
38770
|
function $parseEvent(expr, defOnly) {
|
38748
38771
|
if (!isString$1(expr)) {
|
38749
38772
|
return noop$1$1;
|
@@ -38762,7 +38785,7 @@ function $parseEvent(expr, defOnly) {
|
|
38762
38785
|
// fallback to generate function in runtime. This will break if CSP is enabled
|
38763
38786
|
if (!fn) {
|
38764
38787
|
if (isCSPEnabled()) {
|
38765
|
-
fn =
|
38788
|
+
fn = simpleFunctionEvaluator.bind(undefined, expr);
|
38766
38789
|
}
|
38767
38790
|
else {
|
38768
38791
|
const parser = new Parser$1(new Lexer);
|
@@ -38782,7 +38805,6 @@ const getFnByExpr = (expr) => fnNameMap.get(expr);
|
|
38782
38805
|
const fnExecutor = (expr, exprType) => {
|
38783
38806
|
let fn = getFnByExpr(expr);
|
38784
38807
|
if (!fn) {
|
38785
|
-
console.warn("didn't find fn for the expr: ", expr, ". Falling back to runtime evaluation");
|
38786
38808
|
return;
|
38787
38809
|
}
|
38788
38810
|
const usedPipes = fn.usedPipes || [];
|
angular-codegen/package.json
CHANGED
@@ -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,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
|
+
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)=>{if(!e)return"";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,'\\"').replace(/\n/g,"\\n"));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};
|