@wavemaker/angular-codegen 11.0.1-next.139247 → 11.0.1-next.139249
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.
- angular-codegen/angular-app/build-scripts/post-build.js +27 -50
- angular-codegen/angular-app/package.json +1 -1
- angular-codegen/dependencies/app.component.html +22 -0
- angular-codegen/dependencies/expression-parser.cjs.js +0 -1
- angular-codegen/package.json +1 -1
- angular-codegen/src/expr-parser-utils.js +1 -1
- angular-codegen/src/gen-app-variables.js +1 -1
@@ -74,8 +74,8 @@ const setMobileProjectType = (angularJson) => {
|
|
74
74
|
const addMobileSpecificStyles = async (deployUrl) => {
|
75
75
|
if (isDevBuild) {
|
76
76
|
$("body").append(
|
77
|
-
`<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
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
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
|
-
|
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
|
-
|
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.
|
71
|
+
"@wavemaker/app-ng-runtime": "11.0.1-next.139249"
|
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>
|
@@ -17681,7 +17681,6 @@ function $parseEvent(expr, defOnly) {
|
|
17681
17681
|
}
|
17682
17682
|
const fnNameMap = new Map();
|
17683
17683
|
const registerFnByExpr = (expr, fn, usedPipes) => {
|
17684
|
-
console.log('registering function for: ', expr);
|
17685
17684
|
fn.usedPipes = usedPipes || [];
|
17686
17685
|
fnNameMap.set(expr, fn);
|
17687
17686
|
};
|
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,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.
|
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 +1 @@
|
|
1
|
-
const{getHandlebarTemplate:getHandlebarTemplate,safeString:safeString}=require("./handlebar-helpers"),{readFile:readFile,writeFile:writeFile,getAppVariablesFilePath:getAppVariablesFilePath,formatContents:formatContents}=require("./wm-utils"),{
|
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};
|