@wavemaker/angular-codegen 12.0.0-next.45055 → 12.0.0-next.45058

Sign up to get free protection for your applications and to get access to all the features.
@@ -4975,6 +4975,45 @@ class AbstractJsEmitterVisitor extends AbstractEmitterVisitor {
4975
4975
  this.visitAllObjects(param => ctx.print(null, param.name), params, ctx, ',');
4976
4976
  }
4977
4977
  }
4978
+
4979
+ /**
4980
+ * @fileoverview
4981
+ * A module to facilitate use of a Trusted Types policy within the JIT
4982
+ * compiler. It lazily constructs the Trusted Types policy, providing helper
4983
+ * utilities for promoting strings to Trusted Types. When Trusted Types are not
4984
+ * available, strings are used as a fallback.
4985
+ * @security All use of this module is security-sensitive and should go through
4986
+ * security review.
4987
+ */
4988
+ /**
4989
+ * The Trusted Types policy, or null if Trusted Types are not
4990
+ * enabled/supported, or undefined if the policy has not been created yet.
4991
+ */
4992
+ let policy$2;
4993
+ /**
4994
+ * Returns the Trusted Types policy, or null if Trusted Types are not
4995
+ * enabled/supported. The first call to this function will create the policy.
4996
+ */
4997
+ function getPolicy$2() {
4998
+ if (policy$2 === undefined) {
4999
+ const trustedTypes = _global$1['trustedTypes'];
5000
+ policy$2 = null;
5001
+ if (trustedTypes) {
5002
+ try {
5003
+ policy$2 = trustedTypes.createPolicy('angular#unsafe-jit', {
5004
+ createScript: (s) => s,
5005
+ });
5006
+ }
5007
+ catch {
5008
+ // trustedTypes.createPolicy throws if called with a name that is
5009
+ // already registered, even in report-only mode. Until the API changes,
5010
+ // catch the error not to break the applications functionally. In such
5011
+ // cases, the code will fall back to using strings.
5012
+ }
5013
+ }
5014
+ }
5015
+ return policy$2;
5016
+ }
4978
5017
  /**
4979
5018
  * Unsafely promote a string to a TrustedScript, falling back to strings when
4980
5019
  * Trusted Types are not available.
@@ -4983,7 +5022,7 @@ class AbstractJsEmitterVisitor extends AbstractEmitterVisitor {
4983
5022
  * interpreted and executed as a script by a browser, e.g. when calling eval.
4984
5023
  */
4985
5024
  function trustedScriptFromString(script) {
4986
- return script;
5025
+ return getPolicy$2()?.createScript(script) || script;
4987
5026
  }
4988
5027
  /**
4989
5028
  * Unsafely call the Function constructor with the given string arguments.
@@ -49196,6 +49235,46 @@ const PRESERVE_HOST_CONTENT = new InjectionToken((typeof ngDevMode === 'undefine
49196
49235
  * is enabled.
49197
49236
  */
49198
49237
  const IS_I18N_HYDRATION_ENABLED = new InjectionToken((typeof ngDevMode === 'undefined' || !!ngDevMode ? 'IS_I18N_HYDRATION_ENABLED' : ''));
49238
+
49239
+ /**
49240
+ * @fileoverview
49241
+ * A module to facilitate use of a Trusted Types policy internally within
49242
+ * Angular. It lazily constructs the Trusted Types policy, providing helper
49243
+ * utilities for promoting strings to Trusted Types. When Trusted Types are not
49244
+ * available, strings are used as a fallback.
49245
+ * @security All use of this module is security-sensitive and should go through
49246
+ * security review.
49247
+ */
49248
+ /**
49249
+ * The Trusted Types policy, or null if Trusted Types are not
49250
+ * enabled/supported, or undefined if the policy has not been created yet.
49251
+ */
49252
+ let policy$1;
49253
+ /**
49254
+ * Returns the Trusted Types policy, or null if Trusted Types are not
49255
+ * enabled/supported. The first call to this function will create the policy.
49256
+ */
49257
+ function getPolicy$1() {
49258
+ if (policy$1 === undefined) {
49259
+ policy$1 = null;
49260
+ if (_global.trustedTypes) {
49261
+ try {
49262
+ policy$1 = _global.trustedTypes.createPolicy('angular', {
49263
+ createHTML: (s) => s,
49264
+ createScript: (s) => s,
49265
+ createScriptURL: (s) => s,
49266
+ });
49267
+ }
49268
+ catch {
49269
+ // trustedTypes.createPolicy throws if called with a name that is
49270
+ // already registered, even in report-only mode. Until the API changes,
49271
+ // catch the error not to break the applications functionally. In such
49272
+ // cases, the code will fall back to using strings.
49273
+ }
49274
+ }
49275
+ }
49276
+ return policy$1;
49277
+ }
49199
49278
  /**
49200
49279
  * Unsafely promote a string to a TrustedHTML, falling back to strings when
49201
49280
  * Trusted Types are not available.
@@ -49206,7 +49285,7 @@ const IS_I18N_HYDRATION_ENABLED = new InjectionToken((typeof ngDevMode === 'unde
49206
49285
  * element.innerHTML.
49207
49286
  */
49208
49287
  function trustedHTMLFromString(html) {
49209
- return html;
49288
+ return getPolicy$1()?.createHTML(html) || html;
49210
49289
  }
49211
49290
  /**
49212
49291
  * Unsafely promote a string to a TrustedScriptURL, falling back to strings
@@ -49218,7 +49297,49 @@ function trustedHTMLFromString(html) {
49218
49297
  * assigning to script.src.
49219
49298
  */
49220
49299
  function trustedScriptURLFromString(url) {
49221
- return url;
49300
+ return getPolicy$1()?.createScriptURL(url) || url;
49301
+ }
49302
+
49303
+ /**
49304
+ * @fileoverview
49305
+ * A module to facilitate use of a Trusted Types policy internally within
49306
+ * Angular specifically for bypassSecurityTrust* and custom sanitizers. It
49307
+ * lazily constructs the Trusted Types policy, providing helper utilities for
49308
+ * promoting strings to Trusted Types. When Trusted Types are not available,
49309
+ * strings are used as a fallback.
49310
+ * @security All use of this module is security-sensitive and should go through
49311
+ * security review.
49312
+ */
49313
+ /**
49314
+ * The Trusted Types policy, or null if Trusted Types are not
49315
+ * enabled/supported, or undefined if the policy has not been created yet.
49316
+ */
49317
+ let policy;
49318
+ /**
49319
+ * Returns the Trusted Types policy, or null if Trusted Types are not
49320
+ * enabled/supported. The first call to this function will create the policy.
49321
+ */
49322
+ function getPolicy() {
49323
+ if (policy === undefined) {
49324
+ policy = null;
49325
+ if (_global.trustedTypes) {
49326
+ try {
49327
+ policy = _global.trustedTypes
49328
+ .createPolicy('angular#unsafe-bypass', {
49329
+ createHTML: (s) => s,
49330
+ createScript: (s) => s,
49331
+ createScriptURL: (s) => s,
49332
+ });
49333
+ }
49334
+ catch {
49335
+ // trustedTypes.createPolicy throws if called with a name that is
49336
+ // already registered, even in report-only mode. Until the API changes,
49337
+ // catch the error not to break the applications functionally. In such
49338
+ // cases, the code will fall back to using strings.
49339
+ }
49340
+ }
49341
+ }
49342
+ return policy;
49222
49343
  }
49223
49344
  /**
49224
49345
  * Unsafely promote a string to a TrustedHTML, falling back to strings when
@@ -49229,7 +49350,7 @@ function trustedScriptURLFromString(url) {
49229
49350
  * bypassSecurityTrust* functions.
49230
49351
  */
49231
49352
  function trustedHTMLFromStringBypass(html) {
49232
- return html;
49353
+ return getPolicy()?.createHTML(html) || html;
49233
49354
  }
49234
49355
  /**
49235
49356
  * Unsafely promote a string to a TrustedScript, falling back to strings when
@@ -49240,7 +49361,7 @@ function trustedHTMLFromStringBypass(html) {
49240
49361
  * bypassSecurityTrust* functions.
49241
49362
  */
49242
49363
  function trustedScriptFromStringBypass(script) {
49243
- return script;
49364
+ return getPolicy()?.createScript(script) || script;
49244
49365
  }
49245
49366
  /**
49246
49367
  * Unsafely promote a string to a TrustedScriptURL, falling back to strings
@@ -49251,7 +49372,7 @@ function trustedScriptFromStringBypass(script) {
49251
49372
  * bypassSecurityTrust* functions.
49252
49373
  */
49253
49374
  function trustedScriptURLFromStringBypass(url) {
49254
- return url;
49375
+ return getPolicy()?.createScriptURL(url) || url;
49255
49376
  }
49256
49377
 
49257
49378
  class SafeValueImpl {
@@ -87039,6 +87160,14 @@ const REGEX = {
87039
87160
  const NUMBER_TYPES = ['int', DataType.INTEGER, DataType.FLOAT, DataType.DOUBLE, DataType.LONG, DataType.SHORT, DataType.BYTE, DataType.BIG_INTEGER, DataType.BIG_DECIMAL];
87040
87161
  const now = new Date();
87041
87162
  const CURRENT_DATE = 'CURRENT_DATE';
87163
+ const getNavClass = (suffix) => {
87164
+ const APP_NAV_CLASS_PREFIX = 'app-nav-';
87165
+ return APP_NAV_CLASS_PREFIX + suffix;
87166
+ };
87167
+ const getSheetPositionClass = (suffix) => {
87168
+ const SHEET_POSITION_CLASS_PREFIX = 'sheet-position-';
87169
+ return SHEET_POSITION_CLASS_PREFIX + suffix;
87170
+ };
87042
87171
  const isDefined = v => 'undefined' !== typeof v;
87043
87172
  const isObject = v => null !== v && 'object' === typeof v;
87044
87173
  const toBoolean = (val, identity) => ((val && val !== 'false') ? true : (identity ? val === identity : false));
@@ -88486,9 +88615,11 @@ var Utils = /*#__PURE__*/Object.freeze({
88486
88615
  getFormattedDate: getFormattedDate,
88487
88616
  getMomentLocaleObject: getMomentLocaleObject,
88488
88617
  getNativeDateObject: getNativeDateObject,
88618
+ getNavClass: getNavClass,
88489
88619
  getResourceURL: getResourceURL,
88490
88620
  getRouteNameFromLink: getRouteNameFromLink,
88491
88621
  getSessionStorageItem: getSessionStorageItem,
88622
+ getSheetPositionClass: getSheetPositionClass,
88492
88623
  getUrlParams: getUrlParams,
88493
88624
  getValidDateObject: getValidDateObject,
88494
88625
  getValidJSON: getValidJSON,
@@ -4975,6 +4975,45 @@ class AbstractJsEmitterVisitor extends AbstractEmitterVisitor {
4975
4975
  this.visitAllObjects(param => ctx.print(null, param.name), params, ctx, ',');
4976
4976
  }
4977
4977
  }
4978
+
4979
+ /**
4980
+ * @fileoverview
4981
+ * A module to facilitate use of a Trusted Types policy within the JIT
4982
+ * compiler. It lazily constructs the Trusted Types policy, providing helper
4983
+ * utilities for promoting strings to Trusted Types. When Trusted Types are not
4984
+ * available, strings are used as a fallback.
4985
+ * @security All use of this module is security-sensitive and should go through
4986
+ * security review.
4987
+ */
4988
+ /**
4989
+ * The Trusted Types policy, or null if Trusted Types are not
4990
+ * enabled/supported, or undefined if the policy has not been created yet.
4991
+ */
4992
+ let policy$2;
4993
+ /**
4994
+ * Returns the Trusted Types policy, or null if Trusted Types are not
4995
+ * enabled/supported. The first call to this function will create the policy.
4996
+ */
4997
+ function getPolicy$2() {
4998
+ if (policy$2 === undefined) {
4999
+ const trustedTypes = _global$1['trustedTypes'];
5000
+ policy$2 = null;
5001
+ if (trustedTypes) {
5002
+ try {
5003
+ policy$2 = trustedTypes.createPolicy('angular#unsafe-jit', {
5004
+ createScript: (s) => s,
5005
+ });
5006
+ }
5007
+ catch {
5008
+ // trustedTypes.createPolicy throws if called with a name that is
5009
+ // already registered, even in report-only mode. Until the API changes,
5010
+ // catch the error not to break the applications functionally. In such
5011
+ // cases, the code will fall back to using strings.
5012
+ }
5013
+ }
5014
+ }
5015
+ return policy$2;
5016
+ }
4978
5017
  /**
4979
5018
  * Unsafely promote a string to a TrustedScript, falling back to strings when
4980
5019
  * Trusted Types are not available.
@@ -4983,7 +5022,7 @@ class AbstractJsEmitterVisitor extends AbstractEmitterVisitor {
4983
5022
  * interpreted and executed as a script by a browser, e.g. when calling eval.
4984
5023
  */
4985
5024
  function trustedScriptFromString(script) {
4986
- return script;
5025
+ return getPolicy$2()?.createScript(script) || script;
4987
5026
  }
4988
5027
  /**
4989
5028
  * Unsafely call the Function constructor with the given string arguments.
@@ -60387,6 +60426,46 @@ const PRESERVE_HOST_CONTENT = new InjectionToken((typeof ngDevMode === 'undefine
60387
60426
  * is enabled.
60388
60427
  */
60389
60428
  const IS_I18N_HYDRATION_ENABLED = new InjectionToken((typeof ngDevMode === 'undefined' || !!ngDevMode ? 'IS_I18N_HYDRATION_ENABLED' : ''));
60429
+
60430
+ /**
60431
+ * @fileoverview
60432
+ * A module to facilitate use of a Trusted Types policy internally within
60433
+ * Angular. It lazily constructs the Trusted Types policy, providing helper
60434
+ * utilities for promoting strings to Trusted Types. When Trusted Types are not
60435
+ * available, strings are used as a fallback.
60436
+ * @security All use of this module is security-sensitive and should go through
60437
+ * security review.
60438
+ */
60439
+ /**
60440
+ * The Trusted Types policy, or null if Trusted Types are not
60441
+ * enabled/supported, or undefined if the policy has not been created yet.
60442
+ */
60443
+ let policy$1;
60444
+ /**
60445
+ * Returns the Trusted Types policy, or null if Trusted Types are not
60446
+ * enabled/supported. The first call to this function will create the policy.
60447
+ */
60448
+ function getPolicy$1() {
60449
+ if (policy$1 === undefined) {
60450
+ policy$1 = null;
60451
+ if (_global.trustedTypes) {
60452
+ try {
60453
+ policy$1 = _global.trustedTypes.createPolicy('angular', {
60454
+ createHTML: (s) => s,
60455
+ createScript: (s) => s,
60456
+ createScriptURL: (s) => s,
60457
+ });
60458
+ }
60459
+ catch {
60460
+ // trustedTypes.createPolicy throws if called with a name that is
60461
+ // already registered, even in report-only mode. Until the API changes,
60462
+ // catch the error not to break the applications functionally. In such
60463
+ // cases, the code will fall back to using strings.
60464
+ }
60465
+ }
60466
+ }
60467
+ return policy$1;
60468
+ }
60390
60469
  /**
60391
60470
  * Unsafely promote a string to a TrustedHTML, falling back to strings when
60392
60471
  * Trusted Types are not available.
@@ -60397,7 +60476,7 @@ const IS_I18N_HYDRATION_ENABLED = new InjectionToken((typeof ngDevMode === 'unde
60397
60476
  * element.innerHTML.
60398
60477
  */
60399
60478
  function trustedHTMLFromString(html) {
60400
- return html;
60479
+ return getPolicy$1()?.createHTML(html) || html;
60401
60480
  }
60402
60481
  /**
60403
60482
  * Unsafely promote a string to a TrustedScriptURL, falling back to strings
@@ -60409,7 +60488,49 @@ function trustedHTMLFromString(html) {
60409
60488
  * assigning to script.src.
60410
60489
  */
60411
60490
  function trustedScriptURLFromString(url) {
60412
- return url;
60491
+ return getPolicy$1()?.createScriptURL(url) || url;
60492
+ }
60493
+
60494
+ /**
60495
+ * @fileoverview
60496
+ * A module to facilitate use of a Trusted Types policy internally within
60497
+ * Angular specifically for bypassSecurityTrust* and custom sanitizers. It
60498
+ * lazily constructs the Trusted Types policy, providing helper utilities for
60499
+ * promoting strings to Trusted Types. When Trusted Types are not available,
60500
+ * strings are used as a fallback.
60501
+ * @security All use of this module is security-sensitive and should go through
60502
+ * security review.
60503
+ */
60504
+ /**
60505
+ * The Trusted Types policy, or null if Trusted Types are not
60506
+ * enabled/supported, or undefined if the policy has not been created yet.
60507
+ */
60508
+ let policy;
60509
+ /**
60510
+ * Returns the Trusted Types policy, or null if Trusted Types are not
60511
+ * enabled/supported. The first call to this function will create the policy.
60512
+ */
60513
+ function getPolicy() {
60514
+ if (policy === undefined) {
60515
+ policy = null;
60516
+ if (_global.trustedTypes) {
60517
+ try {
60518
+ policy = _global.trustedTypes
60519
+ .createPolicy('angular#unsafe-bypass', {
60520
+ createHTML: (s) => s,
60521
+ createScript: (s) => s,
60522
+ createScriptURL: (s) => s,
60523
+ });
60524
+ }
60525
+ catch {
60526
+ // trustedTypes.createPolicy throws if called with a name that is
60527
+ // already registered, even in report-only mode. Until the API changes,
60528
+ // catch the error not to break the applications functionally. In such
60529
+ // cases, the code will fall back to using strings.
60530
+ }
60531
+ }
60532
+ }
60533
+ return policy;
60413
60534
  }
60414
60535
  /**
60415
60536
  * Unsafely promote a string to a TrustedHTML, falling back to strings when
@@ -60420,7 +60541,7 @@ function trustedScriptURLFromString(url) {
60420
60541
  * bypassSecurityTrust* functions.
60421
60542
  */
60422
60543
  function trustedHTMLFromStringBypass(html) {
60423
- return html;
60544
+ return getPolicy()?.createHTML(html) || html;
60424
60545
  }
60425
60546
  /**
60426
60547
  * Unsafely promote a string to a TrustedScript, falling back to strings when
@@ -60431,7 +60552,7 @@ function trustedHTMLFromStringBypass(html) {
60431
60552
  * bypassSecurityTrust* functions.
60432
60553
  */
60433
60554
  function trustedScriptFromStringBypass(script) {
60434
- return script;
60555
+ return getPolicy()?.createScript(script) || script;
60435
60556
  }
60436
60557
  /**
60437
60558
  * Unsafely promote a string to a TrustedScriptURL, falling back to strings
@@ -60442,7 +60563,7 @@ function trustedScriptFromStringBypass(script) {
60442
60563
  * bypassSecurityTrust* functions.
60443
60564
  */
60444
60565
  function trustedScriptURLFromStringBypass(url) {
60445
- return url;
60566
+ return getPolicy()?.createScriptURL(url) || url;
60446
60567
  }
60447
60568
 
60448
60569
  class SafeValueImpl {
@@ -98230,6 +98351,14 @@ const REGEX = {
98230
98351
  const NUMBER_TYPES = ['int', DataType.INTEGER, DataType.FLOAT, DataType.DOUBLE, DataType.LONG, DataType.SHORT, DataType.BYTE, DataType.BIG_INTEGER, DataType.BIG_DECIMAL];
98231
98352
  const now = new Date();
98232
98353
  const CURRENT_DATE = 'CURRENT_DATE';
98354
+ const getNavClass = (suffix) => {
98355
+ const APP_NAV_CLASS_PREFIX = 'app-nav-';
98356
+ return APP_NAV_CLASS_PREFIX + suffix;
98357
+ };
98358
+ const getSheetPositionClass = (suffix) => {
98359
+ const SHEET_POSITION_CLASS_PREFIX = 'sheet-position-';
98360
+ return SHEET_POSITION_CLASS_PREFIX + suffix;
98361
+ };
98233
98362
  const isDefined = v => 'undefined' !== typeof v;
98234
98363
  const isObject = v => null !== v && 'object' === typeof v;
98235
98364
  const toBoolean = (val, identity) => ((val && val !== 'false') ? true : (identity ? val === identity : false));
@@ -99677,9 +99806,11 @@ var Utils = /*#__PURE__*/Object.freeze({
99677
99806
  getFormattedDate: getFormattedDate,
99678
99807
  getMomentLocaleObject: getMomentLocaleObject,
99679
99808
  getNativeDateObject: getNativeDateObject,
99809
+ getNavClass: getNavClass,
99680
99810
  getResourceURL: getResourceURL,
99681
99811
  getRouteNameFromLink: getRouteNameFromLink,
99682
99812
  getSessionStorageItem: getSessionStorageItem,
99813
+ getSheetPositionClass: getSheetPositionClass,
99683
99814
  getUrlParams: getUrlParams,
99684
99815
  getValidDateObject: getValidDateObject,
99685
99816
  getValidJSON: getValidJSON,
@@ -9,7 +9,7 @@
9
9
  "version": "1.0.0",
10
10
  "license": "ISC",
11
11
  "dependencies": {
12
- "cheerio": "^1.0.0-rc.2",
12
+ "cheerio": "1.0.0-rc.12",
13
13
  "decode-uri-component": "^0.2.0",
14
14
  "express": "^4.16.4",
15
15
  "fast-xml-parser": "^3.19.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wavemaker/angular-codegen",
3
- "version": "12.0.0-next.45055",
3
+ "version": "12.0.0-next.45058",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -11,7 +11,7 @@
11
11
  "author": "",
12
12
  "license": "ISC",
13
13
  "dependencies": {
14
- "cheerio": "^1.0.0-rc.2",
14
+ "cheerio": "1.0.0-rc.12",
15
15
  "decode-uri-component": "^0.2.0",
16
16
  "express": "^4.16.4",
17
17
  "fast-xml-parser": "^3.19.0",
@@ -1 +1 @@
1
- global._WM_APP_PROPERTIES={},global._WM_PACKAGE_PATH="./libraries",global.$=require("jquery"),global._=require("lodash");const cheerio=require("cheerio"),{deleteResource:deleteResource,getIndexHtmlPath:getIndexHtmlPath,getPagesDirPath:getPagesDirPath,readFile:readFile,searchFileByName:searchFileByName,writeFile:writeFile,readFileSync:readFileSync}=require("./wm-utils"),{createAppSkeleton:createApp}=require("./gen-app-skeleton"),{generateAppModule:generateAppModule,generateCodeGenModule:generateCodeGenModule}=require("./gen-app-codegen-module"),{generatePrefabConfigFile:generatePrefabConfigFile}=require("./gen-prefabs"),{generateAppRoutes:generateAppRoutes}=require("./gen-app-routes"),{generateAppJS:generateAppJS}=require("./gen-app-js"),{generateAppVariables:generateAppVariables}=require("./gen-app-variables"),{getWmProjectProperties:getWmProjectProperties,getThemesConfigProperties:getThemesConfigProperties,getSecurityConfig:getSecurityConfig,getLayoutsConfig:getLayoutsConfig,getPagesConfig:getPagesConfig,getPrefabConfigsUsedInApp:getPrefabConfigsUsedInApp,getPrefabPartialsConfig:getPrefabPartialsConfig}=require("./project-meta"),{generateTSConfig:generateTSConfig}=require("./gen-tsconfig"),{generateComponents:generateComponents,generatePagePartialComponent:generatePagePartialComponent}=require("./gen-components"),{generateWmProjectProperties:generateWmProjectProperties}=require("./gen-wm-project-properties"),{generateIndexHtml:generateIndexHtml}=require("./gen-index-html"),{updateAngularJSON:updateAngularJSON}=require("./update-angular-json"),{generatePwaFiles:generatePwaFiles}=require("./gen-pwa-files"),{generateLazyModuleRoutes:generateLazyModuleRoutes}=require("./gen-lazy-module-routes"),{createIntermediateAppSkeleton:createIntermediateAppSkeleton,generateLayoutsAndPages:generateLayoutsAndPages}=require("./gen-layouts"),getMarkupFiles=async e=>{const a=[];return searchFileByName(e+"/src/app",/\.html$/,e=>{a.push(e)}),a},isDynamicComponentUsedInMarkup=async e=>{const a=await readFile(e,"utf8");return cheerio.load(a)("form[wmForm][metadata],form[wmForm][metadata\\.bind],div[wmTable]:not(:has(*))").length>0},isDynamicComponentUsedInApp=async e=>{const a=await getMarkupFiles(e);return(await Promise.all(a.map(e=>isDynamicComponentUsedInMarkup(e)))).find(e=>e)},cleanPackageJSON=async(e,a)=>{const t=`${e}/package.json`;let r=readFileSync(t,!0);["@ampproject/rollup-plugin-closure-compiler","rollup","rollup-plugin-alias","rollup-plugin-commonjs","rollup-plugin-includepaths","rollup-plugin-multi-entry","rollup-plugin-node-resolve"].forEach(e=>{delete r.devDependencies[e]}),a||delete r.dependencies["@angular/service-worker"],await writeFile(t,JSON.stringify(r,null,4))},generateIntermediateApp=async(e,a)=>{console.time("create-intermediate-app"),await createIntermediateAppSkeleton(e,a),await generateLayoutsAndPages(a),console.timeEnd("create-intermediate-app")},generateSources=async(e,a,t,r,n,o)=>{console.time("generate app-sources"),await Promise.all([deleteResource(`${a}/src/app/layouts`),deleteResource(`${a}/src/app/pages`),deleteResource(`${a}/src/app/partials`),deleteResource(`${a}/src/app/prefabs`)]);const i=readFileSync(`${a}/angular.json`);global._WM_PACKAGE_PATH=i.includes("./node_modules/@wavemaker/app-ng-runtime/")?"./node_modules/@wavemaker/app-ng-runtime":"./libraries";const g=await getWmProjectProperties(e),p=await getThemesConfigProperties(e),s=await getSecurityConfig(e);let l;o&&(l=await getLayoutsConfig(e));const u=await getPagesConfig(e),c=await getPrefabConfigsUsedInApp(g,e);let d={};for(const a of c.keys())d[a]=await getPrefabPartialsConfig(e,a);await Promise.all([generateIndexHtml(e,a,g,t,r),generateWmProjectProperties(g,a),generateAppRoutes(e,g,l,u,s,a,o),generateLazyModuleRoutes(u,c,d,a),generatePrefabConfigFile(c,a),generateCodeGenModule(g,u,c,s,a),generateTSConfig(g,a),generateAppJS(e,a),generateAppVariables(e,a,n),generateComponents(e,g,l,u,s,c,a,d,n,o)]);const m=await isDynamicComponentUsedInApp(a),P={aot:!m,buildOptimizer:!m};await generateAppModule(g,a,m,r),await updateAngularJSON(e,a,g,p,u,c,t,P,d,r),await cleanPackageJSON(a,r),r&&await generatePwaFiles(e,a,g),console.timeEnd("generate app-sources")},createAppSkeleton=async(e,a,t)=>{console.time("create-angular-app"),await createApp(e,a,t),console.timeEnd("create-angular-app")},generatePage=async(e,a,t,r)=>{console.time("generate page",t);const n=getPagesDirPath(e),o=await getWmProjectProperties(e),i=await getPagesConfig(e),g=_.find(i,{name:t}),p="PAGE"===g.type?"pages":"partials";await deleteResource(`${a}/src/app/${p}/${t}`),await generatePagePartialComponent(n,o,g.name,g.type,a,void 0,void 0,r),console.timeEnd("generate page",t)};module.exports={generateIntermediateApp:generateIntermediateApp,generateSources:generateSources,createAppSkeleton:createAppSkeleton,generatePage:generatePage};
1
+ global._WM_APP_PROPERTIES={},global._WM_PACKAGE_PATH="./libraries",global.$=require("jquery"),global._=require("lodash");const cheerio=require("cheerio"),{deleteResource:deleteResource,getIndexHtmlPath:getIndexHtmlPath,getPagesDirPath:getPagesDirPath,readFile:readFile,searchFileByName:searchFileByName,writeFile:writeFile,readFileSync:readFileSync}=require("./wm-utils"),{createAppSkeleton:createApp}=require("./gen-app-skeleton"),{generateAppModule:generateAppModule,generateCodeGenModule:generateCodeGenModule}=require("./gen-app-codegen-module"),{generatePrefabConfigFile:generatePrefabConfigFile}=require("./gen-prefabs"),{generateAppRoutes:generateAppRoutes}=require("./gen-app-routes"),{generateAppJS:generateAppJS}=require("./gen-app-js"),{generateAppVariables:generateAppVariables}=require("./gen-app-variables"),{getWmProjectProperties:getWmProjectProperties,getThemesConfigProperties:getThemesConfigProperties,getSecurityConfig:getSecurityConfig,getLayoutsConfig:getLayoutsConfig,getPagesConfig:getPagesConfig,getPrefabConfigsUsedInApp:getPrefabConfigsUsedInApp,getPrefabPartialsConfig:getPrefabPartialsConfig}=require("./project-meta"),{generateTSConfig:generateTSConfig}=require("./gen-tsconfig"),{generateComponents:generateComponents,generatePagePartialComponent:generatePagePartialComponent}=require("./gen-components"),{generateWmProjectProperties:generateWmProjectProperties}=require("./gen-wm-project-properties"),{generateIndexHtml:generateIndexHtml}=require("./gen-index-html"),{updateAngularJSON:updateAngularJSON}=require("./update-angular-json"),{generatePwaFiles:generatePwaFiles}=require("./gen-pwa-files"),{generateLazyModuleRoutes:generateLazyModuleRoutes}=require("./gen-lazy-module-routes"),{createIntermediateAppSkeleton:createIntermediateAppSkeleton,generateLayoutsAndPages:generateLayoutsAndPages}=require("./gen-layouts"),getMarkupFiles=async e=>{const a=[];return searchFileByName(e+"/src/app",/\.html$/,e=>{a.push(e)}),a},isDynamicComponentUsedInMarkup=async e=>{const a=await readFile(e,"utf8");return cheerio.load(a)("form[wmForm][metadata],form[wmForm][metadata\\.bind],div[wmTable]:not(:has(*))").length>0},isDynamicComponentUsedInApp=async e=>{const a=await getMarkupFiles(e);return(await Promise.all(a.map(e=>isDynamicComponentUsedInMarkup(e)))).find(e=>e)},cleanPackageJSON=async(e,a)=>{const t=`${e}/package.json`;let r=readFileSync(t,!0);["@ampproject/rollup-plugin-closure-compiler","rollup","rollup-plugin-alias","rollup-plugin-commonjs","rollup-plugin-includepaths","rollup-plugin-multi-entry","rollup-plugin-node-resolve"].forEach(e=>{delete r.devDependencies[e]}),a||delete r.dependencies["@angular/service-worker"],await writeFile(t,JSON.stringify(r,null,4))},generateIntermediateApp=async(e,a)=>{console.time("create-intermediate-app"),await createIntermediateAppSkeleton(e,a),await generateLayoutsAndPages(a),console.timeEnd("create-intermediate-app")},generateSources=async(e,a,t,r,n,o)=>{console.time("generate app-sources"),await Promise.all([deleteResource(`${a}/src/app/layouts`),deleteResource(`${a}/src/app/pages`),deleteResource(`${a}/src/app/partials`),deleteResource(`${a}/src/app/prefabs`),deleteResource(`${a}/src/app/customwidgets`)]);const i=readFileSync(`${a}/angular.json`);global._WM_PACKAGE_PATH=i.includes("./node_modules/@wavemaker/app-ng-runtime/")?"./node_modules/@wavemaker/app-ng-runtime":"./libraries";const g=await getWmProjectProperties(e),p=await getThemesConfigProperties(e),s=await getSecurityConfig(e);let l;o&&(l=await getLayoutsConfig(e));const u=await getPagesConfig(e),c=await getPrefabConfigsUsedInApp(g,e);let d={};for(const a of c.keys())d[a]=await getPrefabPartialsConfig(e,a);await Promise.all([generateIndexHtml(e,a,g,t,r),generateWmProjectProperties(g,a),generateAppRoutes(e,g,l,u,s,a,o),generateLazyModuleRoutes(u,c,d,a),generatePrefabConfigFile(c,a),generateCodeGenModule(g,u,c,s,a),generateTSConfig(g,a),generateAppJS(e,a),generateAppVariables(e,a,n),generateComponents(e,g,l,u,s,c,a,d,n,o)]);const m=await isDynamicComponentUsedInApp(a),P={aot:!m,buildOptimizer:!m};await generateAppModule(g,a,m,r),await updateAngularJSON(e,a,g,p,u,c,t,P,d,r),await cleanPackageJSON(a,r),r&&await generatePwaFiles(e,a,g),console.timeEnd("generate app-sources")},createAppSkeleton=async(e,a,t)=>{console.time("create-angular-app"),await createApp(e,a,t),console.timeEnd("create-angular-app")},generatePage=async(e,a,t,r)=>{console.time("generate page",t);const n=getPagesDirPath(e),o=await getWmProjectProperties(e),i=await getPagesConfig(e),g=_.find(i,{name:t}),p="PAGE"===g.type?"pages":"partials";await deleteResource(`${a}/src/app/${p}/${t}`),await generatePagePartialComponent(n,o,g.name,g.type,a,void 0,void 0,r),console.timeEnd("generate page",t)};module.exports={generateIntermediateApp:generateIntermediateApp,generateSources:generateSources,createAppSkeleton:createAppSkeleton,generatePage:generatePage};
@@ -1 +1 @@
1
- const{createDir:createDir,writeFile:writeFile,isPrefabProject:isPrefabProject,getLayoutsDirPath:getLayoutsDirPath,getPagesDirPath:getPagesDirPath,formatContents:formatContents,getComponentName:getComponentName,getComponentModuleName:getComponentModuleName,getPrefabPagesDirPath:getPrefabPagesDirPath}=require("./wm-utils"),fs=require("fs"),cheerio=require("cheerio"),{getPageContents:getPageContents}=require("./pages-util"),{getHandlebarTemplate:getHandlebarTemplate,safeString:safeString}=require("./handlebar-helpers"),writeComponentHtmlFile=async(e,t,a)=>{const n=`${a}/${e}.component.html`;await writeFile(n,t.string)},writeComponentCssFile=async(e,t,a)=>{const n=`${a}/${e}.component.css`;await writeFile(n,t.string)},writeComponentVariablesFile=async(e,t,a,n)=>{let r=getHandlebarTemplate(e)({variables:a});await writeFile(`${n}/${t}.component.variables.ts`,formatContents(r))},writeComponentJsFile=async(e,t,a,n)=>{const r=getHandlebarTemplate(e)({jsContent:a});await writeFile(`${n}/${t}.component.script.js`,formatContents(r,"javascript"))},writeComponentExpressionsFile=async(e,t,a,n)=>{const r=getHandlebarTemplate(e)({expressions:a});await writeFile(`${n}/${t}.component.expressions.ts`,formatContents(r,"javascript"))},writeComponentTsFile=async(e,t,a,n,r,o)=>{let i=getHandlebarTemplate(e)({name:t,prefabName:a,componentName:getComponentName(t),enableSpa:r,layoutPages:safeString(JSON.stringify(o))});await writeFile(`${n}/${t}.component.ts`,i)},writePagePartialModuleTsFile=async(e,t,a,n,r,o,i=!1,s,m,p)=>{let l=getHandlebarTemplate(e)({name:t,componentName:getComponentName(t),moduleName:getComponentModuleName(t),requiredPartials:n,requiredPrefabs:r,requiredWMComponents:o,hasCustomElement:i,insidePrefab:!!s,pagesConfig:m,securityConfig:p});await writeFile(`${a}/${t}.module.ts`,l)},writePrefabModuleTsFile=async(e,t,a,n=!1,r)=>{let o=getHandlebarTemplate("prefab-module-ts")({name:e,componentName:getComponentName(e),moduleName:getComponentModuleName(e),requiredPartials:r,requiredWMComponents:a,hasCustomElement:n});await writeFile(`${t}/${e}.module.ts`,o)},generateComponent=async(e,t,a,n,r,o,i,s,m)=>{await createDir(e,{recursive:!0});const{markup:p,styles:l,variables:g,script:c,expressions:P}=n,f=[writeComponentHtmlFile(t,safeString(p),e),writeComponentTsFile(r,t,a,e,s,m),writeComponentExpressionsFile("component-expressions",t,safeString(P),e)];return i||f.concat([writeComponentCssFile(t,safeString(l),e),writeComponentVariablesFile("component-variables",t,safeString(g),e),writeComponentJsFile(o,t,safeString(c),e)]),Promise.all(f)},findRequiredPartials=e=>{const t={};return e("[partialContainer]").map((t,a)=>e(a).attr("content")).toArray().map(e=>({type:"PARTIAL",name:e.trim()})).filter(e=>!t[e.name]&&(t[e.name]=!0))},findRequiredPrefabs=e=>{const t={};return e("[wmPrefab]").map((t,a)=>e(a).attr("prefabname")).toArray().map(e=>({type:"PREFAB",name:e.trim()})).filter(e=>!t[e.name]&&(t[e.name]=!0))},generatePagePartialComponent=async(e,t,a,n,r,o,i,s,m,p,l)=>{let g,c,P,f,u;if("PAGE"===n?(f=`${r}/src/app/pages/${a}`,g="page-component-ts",c="page-component-script",P="page-module-ts"):"LAYOUT"===n?(f=`${r}/src/app/layouts/${a}`,g="layout-component-ts",P="layout-module-ts",u=p.filter(e=>"PAGE"===e.type&&e.layout===a).map(e=>e.name)):(f=o?`${r}/partials/${a}`:`${r}/src/app/partials/${a}`,g="partial-component-ts",c="partial-component-script",P="partial-module-ts"),fs.existsSync(`${f}/${a}.component.ts`))return;let C=`${e}/${a}`;o&&(C=`${getPrefabPagesDirPath(i,o)}/${a}`);const d=await getPageContents(t,C,`${a}`,a,n,void 0,s);try{const e=cheerio.load(d.markup),C=findRequiredPartials(e),w=findRequiredPrefabs(e);for(const e of C){const a=getPagesDirPath(i);await generatePagePartialComponent(a,t,e.name,e.type,r,o,i,s,m)}await generateComponent(f,a,void 0,d,g,c,"LAYOUT"===n,m,u),await writePagePartialModuleTsFile(P,a,f,C,w,d.requiredWMComponents,d.hasCustomElement,o,p,l)}catch(e){throw console.log("failed in "+a),e}},generateComponents=async(e,t,a,n,r,o,i,s,m,p)=>{const l=getPagesDirPath(e);for(const a of o.keys()){const n="__self__"===a?`${l}/Main`:`${getPrefabPagesDirPath(e,a)}/Main`,r=await getPageContents(t,n,"Main",a,"PREFAB",o.get(a),m),c=`${i}/src/app/prefabs/${a}`,P=cheerio.load(r.markup),f=findRequiredPartials(P);await generateComponent(c,a,a,r,"prefab-component-ts","prefab-component-script",!1,p);const u=s[a];for(var g=0;g<u.length;g++)await generatePagePartialComponent(l,t,u[g].name,u[g].type,c,a,e,m,p);await writePrefabModuleTsFile(a,c,r.requiredWMComponents,r.hasCustomElement,f)}if(!isPrefabProject(t)){if(p){const o=getLayoutsDirPath(e);for(let s of a)await generateLayoutComponent(o,t,s.name,s.type,i,s.prefabName,e,m,p,n,r)}for(let a of n)await generatePagePartialComponent(l,t,a.name,a.type,i,a.prefabName,e,m,p)}},generateLayoutComponent=async(e,t,a,n,r,o,i,s,m,p,l)=>{await generatePagePartialComponent(e,t,a,n,r,o,i,s,m,p,l)};module.exports={generateComponents:generateComponents,generatePagePartialComponent:generatePagePartialComponent};
1
+ const{createDir:createDir,writeFile:writeFile,isPrefabProject:isPrefabProject,getLayoutsDirPath:getLayoutsDirPath,getPagesDirPath:getPagesDirPath,formatContents:formatContents,getComponentName:getComponentName,getComponentModuleName:getComponentModuleName,getPrefabPagesDirPath:getPrefabPagesDirPath}=require("./wm-utils"),fs=require("fs"),cheerio=require("cheerio"),{getPageContents:getPageContents,getCustomWidgetPageContents:getCustomWidgetPageContents}=require("./pages-util"),{getHandlebarTemplate:getHandlebarTemplate,safeString:safeString}=require("./handlebar-helpers"),{generateCustomWidgetConfigFile:generateCustomWidgetConfigFile}=require("./gen-customwidget-config"),writeComponentHtmlFile=async(e,t,a)=>{const n=`${a}/${e}.component.html`;await writeFile(n,t.string)},writeComponentCssFile=async(e,t,a)=>{const n=`${a}/${e}.component.css`;await writeFile(n,t.string)},writeComponentVariablesFile=async(e,t,a,n)=>{let o=getHandlebarTemplate(e)({variables:a});await writeFile(`${n}/${t}.component.variables.ts`,formatContents(o))},writeComponentConfigFile=async(e,t,a,n)=>{let o=getHandlebarTemplate(e)({config:a});await writeFile(`${n}/${t}.component.config.ts`,formatContents(o))},writeComponentJsFile=async(e,t,a,n)=>{const o=getHandlebarTemplate(e)({jsContent:a});await writeFile(`${n}/${t}.component.script.js`,formatContents(o,"javascript"))},writeComponentExpressionsFile=async(e,t,a,n)=>{const o=getHandlebarTemplate(e)({expressions:a});await writeFile(`${n}/${t}.component.expressions.ts`,formatContents(o,"javascript"))},writeComponentTsFile=async(e,t,a,n,o,r,i=[])=>{let s=getHandlebarTemplate(e)({name:t,prefabName:a,componentName:getComponentName(t),enableSpa:o,layoutPages:safeString(JSON.stringify(r)),requiredWMComponents:i});await writeFile(`${n}/${t}.component.ts`,s)},writePagePartialModuleTsFile=async(e,t,a,n,o,r,i=!1,s,m,p,g)=>{let l=getHandlebarTemplate(e)({name:t,componentName:getComponentName(t),moduleName:getComponentModuleName(t),requiredPartials:n,requiredPrefabs:o,requiredWMComponents:r,hasCustomElement:i,insidePrefab:!!s,pagesConfig:m,securityConfig:p,requireCustomComponents:g});await writeFile(`${a}/${t}.module.ts`,l)},writePrefabModuleTsFile=async(e,t,a,n=!1,o)=>{let r=getHandlebarTemplate("prefab-module-ts")({name:e,componentName:getComponentName(e),moduleName:getComponentModuleName(e),requiredPartials:o,requiredWMComponents:a,hasCustomElement:n});await writeFile(`${t}/${e}.module.ts`,r)},generateComponent=async(e,t,a,n,o,r,i,s,m,p=!1)=>{await createDir(e,{recursive:!0});const{markup:g,styles:l,variables:c,script:u,expressions:d}=n,C=[writeComponentHtmlFile(t,safeString(g),e),writeComponentTsFile(o,t,a,e,s,m,n.requiredWMComponents)];return p||writeComponentExpressionsFile("component-expressions",t,safeString(d),e),i||C.concat([writeComponentCssFile(t,safeString(l),e),writeComponentVariablesFile("component-variables",t,safeString(c),e),writeComponentJsFile(r,t,safeString(u),e)]),Promise.all(C)},findRequiredPartials=e=>{const t={};return e("[partialContainer]").map((t,a)=>e(a).attr("content")).toArray().map(e=>({type:"PARTIAL",name:e.trim()})).filter(e=>!t[e.name]&&(t[e.name]=!0))},findRequiredPrefabs=e=>{const t={};return e("[wmPrefab]").map((t,a)=>e(a).attr("prefabname")).toArray().map(e=>({type:"PREFAB",name:e.trim()})).filter(e=>!t[e.name]&&(t[e.name]=!0))},findRequiredCustomWidgets=e=>{const t={};return e("[customWidgetContainer]").map((t,a)=>e(a).attr("widgetname")).toArray().map(e=>({type:"CUSTOMWIDGET",name:e.trim()})).filter(e=>!t[e.name]&&(t[e.name]=!0))},generateCustomWidgetsComponent=async(e,t,a,n)=>{let o,r,i,s;{if(s=`${t}/src/app/customwidgets/${e}`,o="customwidget-component-ts",r="customwidget-component-script",i="customwidget-module-ts",fs.existsSync(`${s}/${e}.component.ts`))return;const a="angular-app/libraries/scripts/custom-widgets-m3/src",m=await getCustomWidgetPageContents(a,e);n.set(e,m.config);try{const t=cheerio.load(m.markup);findRequiredPartials(t),findRequiredPrefabs(t);await generateComponent(s,e,void 0,m,"customwidget-component-ts","customwidget-component-script",!1,void 0,void 0,!0)}catch(e){throw console.log("failed in "+pageName),e}}};convertHTMLStructure=(e=>{return e.replace(/<div\s+wmWidgetContainer\s+customWidgetContainer\s+#wm_custom_widget\d+="wmWidgetContainer"\s+widgetname="([^"]+)"\s+name="([^"]+)"\s*(.*?)\s*\/?>\s*<\/div>/g,(e,t,a,n)=>{let o;return`<${o=`app-custom-${t.replace("_","-")}`} wmWidgetContainer #wm_custom_widget${a.match(/\d+/)[0]}="wmWidgetContainer" widgetname="${t}" name="${a}" ${n}></${o}>`})});const generatePagePartialComponent=async(e,t,a,n,o,r,i,s,m,p,g,l)=>{let c,u,d,C,f;if("PAGE"===n?(C=`${o}/src/app/pages/${a}`,c="page-component-ts",u="page-component-script",d="page-module-ts"):"LAYOUT"===n?(C=`${o}/src/app/layouts/${a}`,c="layout-component-ts",d="layout-module-ts",f=p.filter(e=>"PAGE"===e.type&&e.layout===a).map(e=>e.name)):(C=r?`${o}/partials/${a}`:`${o}/src/app/partials/${a}`,c="partial-component-ts",u="partial-component-script",d="partial-module-ts"),fs.existsSync(`${C}/${a}.component.ts`))return;let w=`${e}/${a}`;r&&(w=`${getPrefabPagesDirPath(i,r)}/${a}`);const P=await getPageContents(t,w,`${a}`,a,n,void 0,s),$=new Map;try{const e=cheerio.load(P.markup),l=findRequiredPartials(e),w=findRequiredPrefabs(e),y=findRequiredCustomWidgets(e);for(const e of l){const a=getPagesDirPath(i);await generatePagePartialComponent(a,t,e.name,e.type,o,r,i,s,m)}for(const e of y)await generateCustomWidgetsComponent(e.name,o,0,$);y.length&&await generateCustomWidgetConfigFile($,o),P.markup=convertHTMLStructure(P.markup),await generateComponent(C,a,void 0,P,c,u,"LAYOUT"===n,m,f),await writePagePartialModuleTsFile(d,a,C,l,w,P.requiredWMComponents,P.hasCustomElement,r,p,g,y)}catch(e){throw console.log("failed in "+a),e}},generateComponents=async(e,t,a,n,o,r,i,s,m,p)=>{const g=getPagesDirPath(e);for(const a of r.keys()){const n="__self__"===a?`${g}/Main`:`${getPrefabPagesDirPath(e,a)}/Main`,o=await getPageContents(t,n,"Main",a,"PREFAB",r.get(a),m),c=`${i}/src/app/prefabs/${a}`,u=cheerio.load(o.markup),d=findRequiredPartials(u);await generateComponent(c,a,a,o,"prefab-component-ts","prefab-component-script",!1,p);const C=s[a];for(var l=0;l<C.length;l++)await generatePagePartialComponent(g,t,C[l].name,C[l].type,c,a,e,m,p);await writePrefabModuleTsFile(a,c,o.requiredWMComponents,o.hasCustomElement,d)}if(!isPrefabProject(t)){if(p){const r=getLayoutsDirPath(e);for(let s of a)await generateLayoutComponent(r,t,s.name,s.type,i,s.prefabName,e,m,p,n,o)}for(let a of n)await generatePagePartialComponent(g,t,a.name,a.type,i,a.prefabName,e,m,p)}},generateLayoutComponent=async(e,t,a,n,o,r,i,s,m,p,g)=>{await generatePagePartialComponent(e,t,a,n,o,r,i,s,m,p,g)};module.exports={generateComponents:generateComponents,generatePagePartialComponent:generatePagePartialComponent};
@@ -0,0 +1 @@
1
+ const{createDir:createDir,writeFile:writeFile}=require("./wm-utils"),{getHandlebarTemplate:getHandlebarTemplate}=require("./handlebar-helpers"),generateCustomWidgetConfigFile=async(e={},t)=>{await createDir(`${t}/src/app/customwidgets`,{recursive:!0});const i=getHandlebarTemplate("customwidget-config")({customWidgetConfigMap:e});await writeFile(`${t}/src/app/customwidgets/customwidget-config.ts`,i)};module.exports={generateCustomWidgetConfigFile:generateCustomWidgetConfigFile};
@@ -1 +1 @@
1
- const Handlebars=require("handlebars"),fs=require("fs"),{getComponentName:getComponentName,isPrefabProject:isPrefabProject,getComponentModuleName:getComponentModuleName,getCodegenPath:getCodegenPath}=require("./wm-utils"),getPageRouteInfo=(e,t,n)=>{let a,r;if(null!==e){a="[(route) => inject(AuthGuard).canActivate(route)]";for(const n of e)if(n.urlPattern.startsWith("/pages/")){n.urlPattern.split("/")[2]===t&&("Role"===n.permission?(a="[(route) => inject(RoleGuard).canActivate(route)]",n.roles&&(r=JSON.stringify(n.roles))):"PermitAll"===n.permission&&(a=void 0))}}return`{\n path: '${t}',\n pathMatch: 'full',\n loadChildren: () => import('${n?"../..":"."}/pages/${t}/${t}.module').then(m => m.${getComponentModuleName(t)}),\n ${a?`canActivate: ${a},`:""}\n data : {\n ${r?`allowedRoles: ${r},`:""}\n pageName: '${t}'\n }\n }`},getLayoutRouteInfo=e=>`{\n path: "",\n resolve: appDependenciesResolve,\n loadChildren: () => import("./layouts/${e}/${e}.module").then(m => m.${getComponentModuleName(e)}),\n data : { \n layoutName: '${e}' \n }\n }`;Handlebars.registerHelper("PageComponentsImportStmts",(e,t)=>{if(isPrefabProject(e))return"";const n=t.filter(e=>"PAGE"===e.type).map(e=>`import { ${getComponentName(e.name)} } from './pages/${e.name}/${e.name}.component';`).join("\n");return safeString(n)}),Handlebars.registerHelper("WMComponentsImportStmts",(e=[])=>{const t=e.map(e=>`import { ${e.name} as ${e.as||"WM_"+e.name} } from '${e.from}';`).join("\n");return safeString(t)}),Handlebars.registerHelper("PartialModuleImportStmts",e=>{const t=e.filter(e=>"PARTIAL"===e.type).map(e=>`import { ${getComponentModuleName(e.name)} as Partial${getComponentModuleName(e.name)}} from '../../partials/${e.name}/${e.name}.module';`).join("\n");return safeString(t)}),Handlebars.registerHelper("PrefabPartialModuleImportStmts",e=>{const t=e.filter(e=>"PARTIAL"===e.type).map(e=>`import { ${getComponentModuleName(e.name)} as Partial${getComponentModuleName(e.name)}} from './partials/${e.name}/${e.name}.module';`).join("\n");return safeString(t)}),Handlebars.registerHelper("PartialModuleStmts",e=>{const t=e.filter(e=>"PARTIAL"===e.type).map(e=>"Partial"+getComponentModuleName(e.name)).join(",\n\t");return safeString(t)}),Handlebars.registerHelper("PrefabModuleImportStmts",e=>{const t=e.filter(e=>"PREFAB"===e.type).map(e=>`import { ${getComponentModuleName(e.name)} as Prefab${getComponentModuleName(e.name)} } from '../../prefabs/${e.name}/${e.name}.module';`).join("\n");return safeString(t)}),Handlebars.registerHelper("PrefabModuleStmts",e=>{const t=e.filter(e=>"PREFAB"===e.type).map(e=>"Prefab"+getComponentModuleName(e.name)).join(",\n\t");return safeString(t)}),Handlebars.registerHelper("WMComponentModuleStmts",e=>{const t=e.map(e=>`${e.as||"WM_"+e.name}${e.forRoot?".forRoot()":""}`).join(",\n\t");return safeString(t)}),Handlebars.registerHelper("PartialComponentsImportStmts",e=>{const t=e.filter(e=>"PAGE"!==e.type).map(e=>`import { ${getComponentName(e.name)} } from './partials/${e.name}/${e.name}.component';`).join("\n");return safeString(t)}),Handlebars.registerHelper("PrefabComponentsImportStmts",e=>{const t=[];for(const[n]of e.entries())t.push(`import { MainComponent as ${n}Component } from './prefabs/${n}/Main/Main.component';`);return safeString(t.join("\n"))}),Handlebars.registerHelper("RegisterComponents",(e,t,n)=>{let a=[];for(const[e]of n.entries())a.push(`ComponentRefProviderService.registerComponentRef('${e}', ComponentType.PREFAB, ${e}Component, null);`);return safeString(a.join("\n"))}),Handlebars.registerHelper("ComponentDeclarations",(e,t,n)=>{let a=[];for(const[e]of n.entries())a.push(`${e}Component`);return safeString(a.join(",\n\t"))}),Handlebars.registerHelper("RegisterPrefabConfig",e=>{const t=[];for(const[n,a]of e.entries())t.push(`registerPrefabConfig('${n}', ${a})`);return safeString(t.join("\n"))}),Handlebars.registerHelper("DefineHomePage",e=>isPrefabProject(e)?"prefab-preview":e.homePage),Handlebars.registerHelper("ImportPrefabPreviewComponent",e=>isPrefabProject(e)?safeString('import { PrefabPreviewComponent } from "@wm/runtime/base";'):""),Handlebars.registerHelper("DefineLayoutRoutes",(e,t,n,a)=>{const r=n.filter(t=>t.layout===e&&"PAGE"===t.type).map(e=>getPageRouteInfo(a,e.name,!0));let o="";return r.length&&(o=`\n children: [\n ${r.join(",\n")}\n ]`),safeString(`[\n {\n path: '',\n component: ${t},\n ${o}\n\n }\n ]`)}),Handlebars.registerHelper("DefineAppRoutes",(e,t,n,a,r)=>{let o="";if(isPrefabProject(e))o="{\n path: 'prefab-preview',\n resolve: appDependenciesResolve,\n component: PrefabPreviewComponent\n }";else if(r){o=`${t.map(e=>getLayoutRouteInfo(e.name)).join(",\n")}`}else{o=`{\n path: '',\n resolve: appDependenciesResolve,\n children: [\n ${n.filter(e=>"PAGE"===e.type).map(e=>getPageRouteInfo(a,e.name,!1)).join(",\n")}\n ]\n }`}return safeString(`[\n {\n path: '',\n pathMatch: 'full',\n component: EmptyPageComponent,\n resolve: appDependenciesResolve\n },\n ${o},\n {\n path: "**",\n canActivate: [(route) => inject(PageNotFoundGuard).canActivate(route)],\n component: EmptyPageComponent\n }\n ]`)}),Handlebars.registerHelper("DefinePrefabModules",e=>`{ ${e} }`),Handlebars.registerHelper("DefinePartialModules",e=>`{ ${e} }`),Handlebars.registerHelper("DefinePrefabPartialModules",e=>`{ ${e} }`);const templates=new Map,initTemplates=()=>{const e=getCodegenPath()+"/templates/";templates.set("app-module-ts",Handlebars.compile(fs.readFileSync(e+"app.module.ts.hbs","utf-8"))),templates.set("app-codegen-module",Handlebars.compile(fs.readFileSync(e+"app-codegen.module.ts.hbs","utf-8"))),templates.set("app-prefabs-module",Handlebars.compile(fs.readFileSync(e+"app-prefabs.module.ts.hbs","utf-8"))),templates.set("prefab-config",Handlebars.compile(fs.readFileSync(e+"prefab/prefab-config.ts.hbs","utf-8"))),templates.set("app-routes",Handlebars.compile(fs.readFileSync(e+"app-routes.ts.hbs","utf-8"))),templates.set("lazy-module-routes",Handlebars.compile(fs.readFileSync(e+"lazy-module-routes.ts.hbs","utf-8"))),templates.set("wm-project-properties",Handlebars.compile(fs.readFileSync(e+"wm-project-properties.ts.hbs","utf-8"))),templates.set("component-variables",Handlebars.compile(fs.readFileSync(e+"component.variables.ts.hbs","utf-8"))),templates.set("component-expressions",Handlebars.compile(fs.readFileSync(e+"component.expressions.ts.hbs","utf-8"))),templates.set("app-component-script",Handlebars.compile(fs.readFileSync(e+"app.component.script.js.hbs","utf-8"))),templates.set("layout-component-ts",Handlebars.compile(fs.readFileSync(e+"layout/layout.component.ts.hbs","utf-8"))),templates.set("layout-module-ts",Handlebars.compile(fs.readFileSync(e+"layout/layout.module.ts.hbs","utf-8"))),templates.set("page-component-ts",Handlebars.compile(fs.readFileSync(e+"page/page.component.ts.hbs","utf-8"))),templates.set("page-component-script",Handlebars.compile(fs.readFileSync(e+"page/page.component.script.js.hbs","utf-8"))),templates.set("page-module-ts",Handlebars.compile(fs.readFileSync(e+"page/page.module.ts.hbs","utf-8"))),templates.set("partial-component-ts",Handlebars.compile(fs.readFileSync(e+"partial/partial.component.ts.hbs","utf-8"))),templates.set("partial-component-script",Handlebars.compile(fs.readFileSync(e+"partial/partial.component.script.js.hbs","utf-8"))),templates.set("partial-module-ts",Handlebars.compile(fs.readFileSync(e+"partial/partial.module.ts.hbs","utf-8"))),templates.set("prefab-component-ts",Handlebars.compile(fs.readFileSync(e+"prefab/prefab.component.ts.hbs","utf-8"))),templates.set("prefab-module-ts",Handlebars.compile(fs.readFileSync(e+"prefab/prefab.module.ts.hbs","utf-8"))),templates.set("prefab-component-script",Handlebars.compile(fs.readFileSync(e+"prefab/prefab.component.script.js.hbs","utf-8"))),templates.set("expr-vs-fn",Handlebars.compile(fs.readFileSync(e+"expr-vs-fn.hbs","utf-8")))},getHandlebarTemplate=e=>templates.get(e),safeString=e=>new Handlebars.SafeString(e);module.exports={getHandlebarTemplate:getHandlebarTemplate,safeString:safeString,initTemplates:initTemplates};
1
+ const Handlebars=require("handlebars"),fs=require("fs"),{getComponentName:getComponentName,isPrefabProject:isPrefabProject,getComponentModuleName:getComponentModuleName,getCodegenPath:getCodegenPath}=require("./wm-utils"),getPageRouteInfo=(e,t,n)=>{let a,r;if(null!==e){a="[(route) => inject(AuthGuard).canActivate(route)]";for(const n of e)if(n.urlPattern.startsWith("/pages/")){n.urlPattern.split("/")[2]===t&&("Role"===n.permission?(a="[(route) => inject(RoleGuard).canActivate(route)]",n.roles&&(r=JSON.stringify(n.roles))):"PermitAll"===n.permission&&(a=void 0))}}return`{\n path: '${t}',\n pathMatch: 'full',\n loadChildren: () => import('${n?"../..":"."}/pages/${t}/${t}.module').then(m => m.${getComponentModuleName(t)}),\n ${a?`canActivate: ${a},`:""}\n data : {\n ${r?`allowedRoles: ${r},`:""}\n pageName: '${t}'\n }\n }`},getLayoutRouteInfo=e=>`{\n path: "",\n resolve: appDependenciesResolve,\n loadChildren: () => import("./layouts/${e}/${e}.module").then(m => m.${getComponentModuleName(e)}),\n data : { \n layoutName: '${e}' \n }\n }`;Handlebars.registerHelper("PageComponentsImportStmts",(e,t)=>{if(isPrefabProject(e))return"";const n=t.filter(e=>"PAGE"===e.type).map(e=>`import { ${getComponentName(e.name)} } from './pages/${e.name}/${e.name}.component';`).join("\n");return safeString(n)}),Handlebars.registerHelper("WMComponentsImportStmts",(e=[])=>{const t=e.map(e=>`import { ${e.name} as ${e.as||"WM_"+e.name} } from '${e.from}';`).join("\n");return safeString(t)}),Handlebars.registerHelper("WMCustomComponentsImportStmts",(e=[])=>{const t=e.map(e=>`import { ${getComponentName(e.name)} } from '../../customwidgets/${e.name}/${e.name}.component';`).join("\n");return safeString(t)}),Handlebars.registerHelper("PartialModuleImportStmts",e=>{const t=e.filter(e=>"PARTIAL"===e.type).map(e=>`import { ${getComponentModuleName(e.name)} as Partial${getComponentModuleName(e.name)}} from '../../partials/${e.name}/${e.name}.module';`).join("\n");return safeString(t)}),Handlebars.registerHelper("PrefabPartialModuleImportStmts",e=>{const t=e.filter(e=>"PARTIAL"===e.type).map(e=>`import { ${getComponentModuleName(e.name)} as Partial${getComponentModuleName(e.name)}} from './partials/${e.name}/${e.name}.module';`).join("\n");return safeString(t)}),Handlebars.registerHelper("PartialModuleStmts",e=>{const t=e.filter(e=>"PARTIAL"===e.type).map(e=>"Partial"+getComponentModuleName(e.name)).join(",\n\t");return safeString(t)}),Handlebars.registerHelper("PrefabModuleImportStmts",e=>{const t=e.filter(e=>"PREFAB"===e.type).map(e=>`import { ${getComponentModuleName(e.name)} as Prefab${getComponentModuleName(e.name)} } from '../../prefabs/${e.name}/${e.name}.module';`).join("\n");return safeString(t)}),Handlebars.registerHelper("PrefabModuleStmts",e=>{const t=e.filter(e=>"PREFAB"===e.type).map(e=>"Prefab"+getComponentModuleName(e.name)).join(",\n\t");return safeString(t)}),Handlebars.registerHelper("WMComponentModuleStmts",e=>{const t=e.map(e=>`${e.as||"WM_"+e.name}${e.forRoot?".forRoot()":""}`).join(",\n\t");return safeString(t)}),Handlebars.registerHelper("WMCustomComponentStmts",e=>{const t=e.map(e=>`${getComponentName(e.name)}`).join(",\n\t");return safeString(t)}),Handlebars.registerHelper("PartialComponentsImportStmts",e=>{const t=e.filter(e=>"PAGE"!==e.type).map(e=>`import { ${getComponentName(e.name)} } from './partials/${e.name}/${e.name}.component';`).join("\n");return safeString(t)}),Handlebars.registerHelper("PrefabComponentsImportStmts",e=>{const t=[];for(const[n]of e.entries())t.push(`import { MainComponent as ${n}Component } from './prefabs/${n}/Main/Main.component';`);return safeString(t.join("\n"))}),Handlebars.registerHelper("RegisterComponents",(e,t,n)=>{let a=[];for(const[e]of n.entries())a.push(`ComponentRefProviderService.registerComponentRef('${e}', ComponentType.PREFAB, ${e}Component, null);`);return safeString(a.join("\n"))}),Handlebars.registerHelper("ComponentDeclarations",(e,t,n)=>{let a=[];for(const[e]of n.entries())a.push(`${e}Component`);return safeString(a.join(",\n\t"))}),Handlebars.registerHelper("RegisterPrefabConfig",e=>{const t=[];for(const[n,a]of e.entries())t.push(`registerPrefabConfig('${n}', ${a})`);return safeString(t.join("\n"))}),Handlebars.registerHelper("registerCustomWidgetConfig",e=>{const t=[];for(const[n,a]of e.entries())t.push(`registerCustomWidgetConfig('${n}', ${a})`);return safeString(t.join("\n"))}),Handlebars.registerHelper("DefineHomePage",e=>isPrefabProject(e)?"prefab-preview":e.homePage),Handlebars.registerHelper("ImportPrefabPreviewComponent",e=>isPrefabProject(e)?safeString('import { PrefabPreviewComponent } from "@wm/runtime/base";'):""),Handlebars.registerHelper("DefineLayoutRoutes",(e,t,n,a)=>{const r=n.filter(t=>t.layout===e&&"PAGE"===t.type).map(e=>getPageRouteInfo(a,e.name,!0));let o="";return r.length&&(o=`\n children: [\n ${r.join(",\n")}\n ]`),safeString(`[\n {\n path: '',\n component: ${t},\n ${o}\n\n }\n ]`)}),Handlebars.registerHelper("DefineAppRoutes",(e,t,n,a,r)=>{let o="";if(isPrefabProject(e))o="{\n path: 'prefab-preview',\n resolve: appDependenciesResolve,\n component: PrefabPreviewComponent\n }";else if(r){o=`${t.map(e=>getLayoutRouteInfo(e.name)).join(",\n")}`}else{o=`{\n path: '',\n resolve: appDependenciesResolve,\n children: [\n ${n.filter(e=>"PAGE"===e.type).map(e=>getPageRouteInfo(a,e.name,!1)).join(",\n")}\n ]\n }`}return safeString(`[\n {\n path: '',\n pathMatch: 'full',\n component: EmptyPageComponent,\n resolve: appDependenciesResolve\n },\n ${o},\n {\n path: "**",\n canActivate: [(route) => inject(PageNotFoundGuard).canActivate(route)],\n component: EmptyPageComponent\n }\n ]`)}),Handlebars.registerHelper("DefinePrefabModules",e=>`{ ${e} }`),Handlebars.registerHelper("DefinePartialModules",e=>`{ ${e} }`),Handlebars.registerHelper("DefinePrefabPartialModules",e=>`{ ${e} }`);const templates=new Map,initTemplates=()=>{const e=getCodegenPath()+"/templates/";templates.set("app-module-ts",Handlebars.compile(fs.readFileSync(e+"app.module.ts.hbs","utf-8"))),templates.set("app-codegen-module",Handlebars.compile(fs.readFileSync(e+"app-codegen.module.ts.hbs","utf-8"))),templates.set("app-prefabs-module",Handlebars.compile(fs.readFileSync(e+"app-prefabs.module.ts.hbs","utf-8"))),templates.set("prefab-config",Handlebars.compile(fs.readFileSync(e+"prefab/prefab-config.ts.hbs","utf-8"))),templates.set("customwidget-config",Handlebars.compile(fs.readFileSync(e+"customwidget/customwidget-config.ts.hbs","utf-8"))),templates.set("app-routes",Handlebars.compile(fs.readFileSync(e+"app-routes.ts.hbs","utf-8"))),templates.set("lazy-module-routes",Handlebars.compile(fs.readFileSync(e+"lazy-module-routes.ts.hbs","utf-8"))),templates.set("wm-project-properties",Handlebars.compile(fs.readFileSync(e+"wm-project-properties.ts.hbs","utf-8"))),templates.set("component-variables",Handlebars.compile(fs.readFileSync(e+"component.variables.ts.hbs","utf-8"))),templates.set("component-expressions",Handlebars.compile(fs.readFileSync(e+"component.expressions.ts.hbs","utf-8"))),templates.set("app-component-script",Handlebars.compile(fs.readFileSync(e+"app.component.script.js.hbs","utf-8"))),templates.set("layout-component-ts",Handlebars.compile(fs.readFileSync(e+"layout/layout.component.ts.hbs","utf-8"))),templates.set("layout-module-ts",Handlebars.compile(fs.readFileSync(e+"layout/layout.module.ts.hbs","utf-8"))),templates.set("page-component-ts",Handlebars.compile(fs.readFileSync(e+"page/page.component.ts.hbs","utf-8"))),templates.set("page-component-script",Handlebars.compile(fs.readFileSync(e+"page/page.component.script.js.hbs","utf-8"))),templates.set("page-module-ts",Handlebars.compile(fs.readFileSync(e+"page/page.module.ts.hbs","utf-8"))),templates.set("partial-component-ts",Handlebars.compile(fs.readFileSync(e+"partial/partial.component.ts.hbs","utf-8"))),templates.set("partial-component-script",Handlebars.compile(fs.readFileSync(e+"partial/partial.component.script.js.hbs","utf-8"))),templates.set("partial-module-ts",Handlebars.compile(fs.readFileSync(e+"partial/partial.module.ts.hbs","utf-8"))),templates.set("customwidget-component-ts",Handlebars.compile(fs.readFileSync(e+"customwidget/customwidget.component.ts.hbs","utf-8"))),templates.set("customwidget-component-script",Handlebars.compile(fs.readFileSync(e+"customwidget/customwidget.component.script.js.hbs","utf-8"))),templates.set("prefab-component-ts",Handlebars.compile(fs.readFileSync(e+"prefab/prefab.component.ts.hbs","utf-8"))),templates.set("prefab-module-ts",Handlebars.compile(fs.readFileSync(e+"prefab/prefab.module.ts.hbs","utf-8"))),templates.set("prefab-component-script",Handlebars.compile(fs.readFileSync(e+"prefab/prefab.component.script.js.hbs","utf-8"))),templates.set("expr-vs-fn",Handlebars.compile(fs.readFileSync(e+"expr-vs-fn.hbs","utf-8")))},getHandlebarTemplate=e=>templates.get(e),safeString=e=>new Handlebars.SafeString(e);module.exports={getHandlebarTemplate:getHandlebarTemplate,safeString:safeString,initTemplates:initTemplates};
@@ -1 +1 @@
1
- global.$=require("jquery"),global._=require("lodash"),global._WM_APP_PROPERTIES={};const cheerio=require("cheerio"),{generatePageExpressions:generatePageExpressions}=require("./expr-parser-utils"),{readFile:readFile,isMobileProject:isMobileProject}=require("./wm-utils"),nodePolyfill=require("node-window-polyfill").register(!1),getRequiredScripts=e=>{const r={wmCalendar:["./node_modules/fullcalendar/main.min.js"],wmChart:["./node_modules/d3/dist/d3.min.js","./node_modules/@wavemaker/nvd3/build/nv.d3.min.js"],wmChips:["./node_modules/jquery-ui/ui/widgets/sortable.js"],wmList:["./node_modules/jquery-ui/ui/widgets/droppable.js","./node_modules/jquery-ui/ui/widgets/sortable.js"],wmRichtexteditor:["./node_modules/summernote/dist/summernote-lite.min.js"],wmTable:[global._WM_PACKAGE_PATH+"/scripts/datatable/datatable.js","./node_modules/jquery-ui/ui/widgets/resizable.js"]};let t=[];return _.each(r,(r,i)=>{e("["+i+"]").length>0&&(t=t.concat(r))}),t=t.map(e=>e.replace(/^(\.\/)/,"").replace(/\//g,"-").replace(/@/g,"")),_.uniq(t)},includesCustomElement=e=>{return cheerio.load(e)('[html-custom-element="true"]').length},getPageContents=async(e,r,t,i,s,o,l)=>{try{const a=`${r}/${t}`,n=await readFile(`${a}.html`,"utf8");let u,d,m,p="{}";"LAYOUT"!==s&&(u=await readFile(`${a}.js`,"utf8"),d=await readFile(`${a}.css`,"utf8"),p=await readFile(`${a}.variables.json`,"utf8")),global._WM_APP_PROPERTIES=e,window=window||{},window._WM_APP_PROPERTIES=e;const c=(m=isMobileProject(e)?require("../dependencies/transpilation-mobile.cjs"):require("../dependencies/transpilation-web.cjs")).transpile(n),g=cheerio.load(c.markup),w=getRequiredScripts(g);return w.length>0&&(c.markup=c.markup.replace(">",` scripts-to-load="${w.join(",")}">`)),{markup:c.markup,script:u,styles:m.scopeComponentStyles(i,s,d),variables:p,expressions:l?generatePageExpressions(c.markup,p,o):"",requiredWMComponents:c.requiredWMComponents.filter(r=>!r.platformType||r.platformType===e.platformType),hasCustomElement:includesCustomElement(n)}}catch(e){throw console.error(`error occurred in transpilation of ${t}`,e),e}};module.exports={getPageContents:getPageContents};
1
+ global.$=require("jquery"),global._=require("lodash"),global._WM_APP_PROPERTIES={};const cheerio=require("cheerio"),{generatePageExpressions:generatePageExpressions}=require("./expr-parser-utils"),{readFile:readFile,isMobileProject:isMobileProject}=require("./wm-utils"),{config:config}=require("yargs"),nodePolyfill=require("node-window-polyfill").register(!1),getRequiredScripts=e=>{const t={wmCalendar:["./node_modules/fullcalendar/main.min.js"],wmChart:["./node_modules/d3/dist/d3.min.js","./node_modules/@wavemaker/nvd3/build/nv.d3.min.js"],wmChips:["./node_modules/jquery-ui/ui/widgets/sortable.js"],wmList:["./node_modules/jquery-ui/ui/widgets/droppable.js","./node_modules/jquery-ui/ui/widgets/sortable.js"],wmRichtexteditor:["./node_modules/summernote/dist/summernote-lite.min.js"],wmTable:[global._WM_PACKAGE_PATH+"/scripts/datatable/datatable.js","./node_modules/jquery-ui/ui/widgets/resizable.js"]};let o=[];return _.each(t,(t,r)=>{e("["+r+"]").length>0&&(o=o.concat(t))}),o=o.map(e=>e.replace(/^(\.\/)/,"").replace(/\//g,"-").replace(/@/g,"")),_.uniq(o)},includesCustomElement=e=>{return cheerio.load(e)('[html-custom-element="true"]').length},_decodeURIComponent=e=>decodeURIComponent(e.replace(/\+/g," ")),getCustomWidgetPageContents=async(e,t)=>{try{const o=`${e}/${t}`;let r,n="{}";script=await readFile(`${o}/page.min.js`,"utf8"),code=script.toString();const s=code.indexOf("{"),i=code.lastIndexOf("}")+1;jsonString=code.substring(s,i);let l=jsonString.split(",").map(e=>{const t=e.replaceAll("{","").replaceAll("}","").trim();if(t.length){const[e,o]=t.split(":");return`"${e.trim().replaceAll('"',"")}": "${o.trim().replaceAll('"',"")}"`}});const a=`{${(l=l.filter(e=>e)).join(",")}}`;jsonObject=JSON.parse(a),r=_decodeURIComponent(jsonObject.styles),n=_decodeURIComponent(jsonObject.variables),markup=_decodeURIComponent(jsonObject.markup),script=_decodeURIComponent(jsonObject.script),configJson=_decodeURIComponent(jsonObject.config);let d=require("../dependencies/transpilation-web.cjs");const c=d.transpile(markup);return{markup:c.markup,script:script,styles:d.scopeComponentStyles(t,"WIDGET",r),variables:n,requiredWMComponents:c.requiredWMComponents.filter(e=>!e.platformType||"APPLICATION"===e.platformType),config:configJson}}catch(e){throw console.error(`error occurred in transpilation of ${t}`,e),e}},getPageContents=async(e,t,o,r,n,s,i)=>{try{const l=`${t}/${o}`,a=await readFile(`${l}.html`,"utf8");let d,c,p,u="{}";"LAYOUT"!==n&&(d=await readFile(`${l}.js`,"utf8"),c=await readFile(`${l}.css`,"utf8"),u=await readFile(`${l}.variables.json`,"utf8")),global._WM_APP_PROPERTIES=e,window=window||{},window._WM_APP_PROPERTIES=e;const m=(p=isMobileProject(e)?require("../dependencies/transpilation-mobile.cjs"):require("../dependencies/transpilation-web.cjs")).transpile(a),g=cheerio.load(m.markup),j=getRequiredScripts(g);return j.length>0&&(m.markup=m.markup.replace(">",` scripts-to-load="${j.join(",")}">`)),{markup:m.markup,script:d,styles:p.scopeComponentStyles(r,n,c),variables:u,expressions:i?generatePageExpressions(m.markup,u,s):"",requiredWMComponents:m.requiredWMComponents.filter(t=>!t.platformType||t.platformType===e.platformType),hasCustomElement:includesCustomElement(a)}}catch(e){throw console.error(`error occurred in transpilation of ${o}`,e),e}};module.exports={getPageContents:getPageContents,getCustomWidgetPageContents:getCustomWidgetPageContents};
@@ -95,13 +95,14 @@ import { MobileNavbarModule as MobileMobileNavbarModule } from '@wm/mobile/compo
95
95
  import { TabBarModule as MobileTabBarModule } from '@wm/mobile/components/page/tab-bar';
96
96
  {{/if}}
97
97
  {{/if}}
98
- import { CoreModule, PartialRefProvider } from '@wm/core';
98
+ import { CoreModule, PartialRefProvider, CustomWidgetRefProvider } from '@wm/core';
99
99
  import {
100
100
  AppComponent,
101
101
  AppJSProvider,
102
102
  AppVariablesProvider,
103
103
  ComponentRefProvider,
104
104
  PrefabConfigProvider,
105
+ CustomwidgetConfigProvider,
105
106
  WmNgRouteReuseStrategy,
106
107
  CanDeactivateNgPageGuard,
107
108
  REQUIRED_MODULES_FOR_DYNAMIC_COMPONENTS,
@@ -119,6 +120,7 @@ import { PrefabConfigProviderService } from '../framework/services/prefab-config
119
120
  import { AppCodeGenModule, xsrfHeaderName } from './app-codegen.module';
120
121
  import { LazyLoadScriptsResolve } from './lazy-load-scripts.resolve';
121
122
  import { initPrefabConfig } from './prefabs/prefab-config';
123
+ import { CustomwidgetConfigProviderService } from '../framework/services/customwidget-config-provider.service';
122
124
 
123
125
  {{#if isPwa}}
124
126
  import { ServiceWorkerModule } from '@angular/service-worker';
@@ -281,7 +283,9 @@ export const isPrefabInitialized = initPrefabConfig();
281
283
  {provide: AppExtensionProvider,useClass:AppExtensionProviderService},
282
284
  {provide: ComponentRefProvider, useClass: ComponentRefProviderService},
283
285
  {provide: PartialRefProvider, useClass: ComponentRefProviderService},
286
+ {provide: CustomWidgetRefProvider, useClass: ComponentRefProviderService},
284
287
  {provide: PrefabConfigProvider, useClass: PrefabConfigProviderService},
288
+ {provide: CustomwidgetConfigProvider, useClass: CustomwidgetConfigProviderService},
285
289
  {provide: RouteReuseStrategy, useClass: WmNgRouteReuseStrategy},
286
290
  CanDeactivateNgPageGuard,
287
291
  LazyLoadScriptsResolve,
@@ -0,0 +1 @@
1
+ export const config = {{config}};
@@ -0,0 +1,6 @@
1
+ import { registerCustomWidgetConfig } from '../../framework/util/page-util';
2
+
3
+ export const initCustomWidgetConfig = () => {
4
+ {{registerCustomWidgetConfig customWidgetConfigMap}}
5
+ return true;
6
+ };
@@ -0,0 +1,3 @@
1
+ export const initScript = (Widget, App, Utils) => {
2
+ {{ jsContent }}
3
+ }