@wavemaker-ai/react-codegen 1.0.0-rc.647469

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.
Files changed (360) hide show
  1. package/build-react-web.js +149 -0
  2. package/build-react-web.js.map +1 -0
  3. package/command.js +101 -0
  4. package/command.js.map +1 -0
  5. package/index.js +122 -0
  6. package/index.js.map +1 -0
  7. package/package-lock.json +4353 -0
  8. package/package.json +86 -0
  9. package/src/app.generator.js +1272 -0
  10. package/src/app.generator.js.map +1 -0
  11. package/src/download-packages.js +193 -0
  12. package/src/download-packages.js.map +1 -0
  13. package/src/fomatter.js +20 -0
  14. package/src/fomatter.js.map +1 -0
  15. package/src/gen-app-override-css.js +379 -0
  16. package/src/gen-app-override-css.js.map +1 -0
  17. package/src/genappoverridecssold-file.js +311 -0
  18. package/src/genappoverridecssold-file.js.map +1 -0
  19. package/src/handlebar-helpers.js +399 -0
  20. package/src/handlebar-helpers.js.map +1 -0
  21. package/src/increment-builder.js +85 -0
  22. package/src/increment-builder.js.map +1 -0
  23. package/src/profiles/profile.js +24 -0
  24. package/src/profiles/profile.js.map +1 -0
  25. package/src/profiles/web-preview.profile.js +15 -0
  26. package/src/profiles/web-preview.profile.js.map +1 -0
  27. package/src/project.service.js +314 -0
  28. package/src/project.service.js.map +1 -0
  29. package/src/transpile/bind.ex.transformer.js +226 -0
  30. package/src/transpile/bind.ex.transformer.js.map +1 -0
  31. package/src/transpile/components/advanced/carousel-template.transformer.js +16 -0
  32. package/src/transpile/components/advanced/carousel-template.transformer.js.map +1 -0
  33. package/src/transpile/components/advanced/carousel.transformer.js +55 -0
  34. package/src/transpile/components/advanced/carousel.transformer.js.map +1 -0
  35. package/src/transpile/components/advanced/login.transformer.js +26 -0
  36. package/src/transpile/components/advanced/login.transformer.js.map +1 -0
  37. package/src/transpile/components/advanced/marquee.transformer.js +16 -0
  38. package/src/transpile/components/advanced/marquee.transformer.js.map +1 -0
  39. package/src/transpile/components/basic/anchor.transformer.js +13 -0
  40. package/src/transpile/components/basic/anchor.transformer.js.map +1 -0
  41. package/src/transpile/components/basic/audio.transformer.js +16 -0
  42. package/src/transpile/components/basic/audio.transformer.js.map +1 -0
  43. package/src/transpile/components/basic/html.transformer.js +15 -0
  44. package/src/transpile/components/basic/html.transformer.js.map +1 -0
  45. package/src/transpile/components/basic/icon.transformer.js +16 -0
  46. package/src/transpile/components/basic/icon.transformer.js.map +1 -0
  47. package/src/transpile/components/basic/iframe.transformer.js +16 -0
  48. package/src/transpile/components/basic/iframe.transformer.js.map +1 -0
  49. package/src/transpile/components/basic/label.transformer.js +16 -0
  50. package/src/transpile/components/basic/label.transformer.js.map +1 -0
  51. package/src/transpile/components/basic/message.transformer.js +16 -0
  52. package/src/transpile/components/basic/message.transformer.js.map +1 -0
  53. package/src/transpile/components/basic/picture.transformer.js +22 -0
  54. package/src/transpile/components/basic/picture.transformer.js.map +1 -0
  55. package/src/transpile/components/basic/progress-bar.transformer.js +18 -0
  56. package/src/transpile/components/basic/progress-bar.transformer.js.map +1 -0
  57. package/src/transpile/components/basic/progress-circle.transformer.js +16 -0
  58. package/src/transpile/components/basic/progress-circle.transformer.js.map +1 -0
  59. package/src/transpile/components/basic/richtexteditor.transformer.js +21 -0
  60. package/src/transpile/components/basic/richtexteditor.transformer.js.map +1 -0
  61. package/src/transpile/components/basic/search.transformer.js +68 -0
  62. package/src/transpile/components/basic/search.transformer.js.map +1 -0
  63. package/src/transpile/components/basic/spinner.transformer.js +16 -0
  64. package/src/transpile/components/basic/spinner.transformer.js.map +1 -0
  65. package/src/transpile/components/basic/tree.transformer.js +16 -0
  66. package/src/transpile/components/basic/tree.transformer.js.map +1 -0
  67. package/src/transpile/components/basic/video.transformer.js +16 -0
  68. package/src/transpile/components/basic/video.transformer.js.map +1 -0
  69. package/src/transpile/components/chart/chart.transformer.js +13 -0
  70. package/src/transpile/components/chart/chart.transformer.js.map +1 -0
  71. package/src/transpile/components/container/accordion-pane.transformer.js +34 -0
  72. package/src/transpile/components/container/accordion-pane.transformer.js.map +1 -0
  73. package/src/transpile/components/container/accordion.transformer.js +49 -0
  74. package/src/transpile/components/container/accordion.transformer.js.map +1 -0
  75. package/src/transpile/components/container/container.transformer.js +27 -0
  76. package/src/transpile/components/container/container.transformer.js.map +1 -0
  77. package/src/transpile/components/container/layout-grid/grid-column.transformer.js +16 -0
  78. package/src/transpile/components/container/layout-grid/grid-column.transformer.js.map +1 -0
  79. package/src/transpile/components/container/layout-grid/grid-row.transformer.js +16 -0
  80. package/src/transpile/components/container/layout-grid/grid-row.transformer.js.map +1 -0
  81. package/src/transpile/components/container/layout-grid/grid.transformer.js +16 -0
  82. package/src/transpile/components/container/layout-grid/grid.transformer.js.map +1 -0
  83. package/src/transpile/components/container/linear-layout/linear-layout-item.js +16 -0
  84. package/src/transpile/components/container/linear-layout/linear-layout-item.js.map +1 -0
  85. package/src/transpile/components/container/linear-layout/linear-layout.js +16 -0
  86. package/src/transpile/components/container/linear-layout/linear-layout.js.map +1 -0
  87. package/src/transpile/components/container/panel-content.transformer.js +16 -0
  88. package/src/transpile/components/container/panel-content.transformer.js.map +1 -0
  89. package/src/transpile/components/container/panel-footer.transformer.js +11 -0
  90. package/src/transpile/components/container/panel-footer.transformer.js.map +1 -0
  91. package/src/transpile/components/container/panel.transformer.js +26 -0
  92. package/src/transpile/components/container/panel.transformer.js.map +1 -0
  93. package/src/transpile/components/container/repeat-template.transformer.js +16 -0
  94. package/src/transpile/components/container/repeat-template.transformer.js.map +1 -0
  95. package/src/transpile/components/container/tabheader.transformer.js +13 -0
  96. package/src/transpile/components/container/tabheader.transformer.js.map +1 -0
  97. package/src/transpile/components/container/tabpane.transformer.js +38 -0
  98. package/src/transpile/components/container/tabpane.transformer.js.map +1 -0
  99. package/src/transpile/components/container/tabs.transformer.js +105 -0
  100. package/src/transpile/components/container/tabs.transformer.js.map +1 -0
  101. package/src/transpile/components/container/tile.transformer.js +16 -0
  102. package/src/transpile/components/container/tile.transformer.js.map +1 -0
  103. package/src/transpile/components/container/wizard.transformer.js +81 -0
  104. package/src/transpile/components/container/wizard.transformer.js.map +1 -0
  105. package/src/transpile/components/container/wizardaction.transformer.js +120 -0
  106. package/src/transpile/components/container/wizardaction.transformer.js.map +1 -0
  107. package/src/transpile/components/container/wizardstep.transformer.js +74 -0
  108. package/src/transpile/components/container/wizardstep.transformer.js.map +1 -0
  109. package/src/transpile/components/data/card/card-actions.transformer.js +13 -0
  110. package/src/transpile/components/data/card/card-actions.transformer.js.map +1 -0
  111. package/src/transpile/components/data/card/card-content.transformer.js +23 -0
  112. package/src/transpile/components/data/card/card-content.transformer.js.map +1 -0
  113. package/src/transpile/components/data/card/card-footer.transformer.js +13 -0
  114. package/src/transpile/components/data/card/card-footer.transformer.js.map +1 -0
  115. package/src/transpile/components/data/card/card.transformer.js +13 -0
  116. package/src/transpile/components/data/card/card.transformer.js.map +1 -0
  117. package/src/transpile/components/data/form/dynamic-fields.transformer.js +24 -0
  118. package/src/transpile/components/data/form/dynamic-fields.transformer.js.map +1 -0
  119. package/src/transpile/components/data/form/form-action.transformer.js +145 -0
  120. package/src/transpile/components/data/form/form-action.transformer.js.map +1 -0
  121. package/src/transpile/components/data/form/form-body.transformer.js +16 -0
  122. package/src/transpile/components/data/form/form-body.transformer.js.map +1 -0
  123. package/src/transpile/components/data/form/form-field.transformer.js +443 -0
  124. package/src/transpile/components/data/form/form-field.transformer.js.map +1 -0
  125. package/src/transpile/components/data/form/form-footer.transformer.js +16 -0
  126. package/src/transpile/components/data/form/form-footer.transformer.js.map +1 -0
  127. package/src/transpile/components/data/form/form.transformer.js +167 -0
  128. package/src/transpile/components/data/form/form.transformer.js.map +1 -0
  129. package/src/transpile/components/data/form/util.js +70 -0
  130. package/src/transpile/components/data/form/util.js.map +1 -0
  131. package/src/transpile/components/data/list/list-content.transformer.js +35 -0
  132. package/src/transpile/components/data/list/list-content.transformer.js.map +1 -0
  133. package/src/transpile/components/data/list/list-template-transformer.js +13 -0
  134. package/src/transpile/components/data/list/list-template-transformer.js.map +1 -0
  135. package/src/transpile/components/data/list/list-transformer.js +308 -0
  136. package/src/transpile/components/data/list/list-transformer.js.map +1 -0
  137. package/src/transpile/components/data/live-filter-field.transformer.js +437 -0
  138. package/src/transpile/components/data/live-filter-field.transformer.js.map +1 -0
  139. package/src/transpile/components/data/livefilter.transformer.js +141 -0
  140. package/src/transpile/components/data/livefilter.transformer.js.map +1 -0
  141. package/src/transpile/components/data/liveform.transformer.js +160 -0
  142. package/src/transpile/components/data/liveform.transformer.js.map +1 -0
  143. package/src/transpile/components/data/table/live-table.transformer.js +15 -0
  144. package/src/transpile/components/data/table/live-table.transformer.js.map +1 -0
  145. package/src/transpile/components/data/table/table-action.transformer.js +29 -0
  146. package/src/transpile/components/data/table/table-action.transformer.js.map +1 -0
  147. package/src/transpile/components/data/table/table-column.transformer.js +121 -0
  148. package/src/transpile/components/data/table/table-column.transformer.js.map +1 -0
  149. package/src/transpile/components/data/table/table-group.transformer.js +16 -0
  150. package/src/transpile/components/data/table/table-group.transformer.js.map +1 -0
  151. package/src/transpile/components/data/table/table-row-action.transformer.js +34 -0
  152. package/src/transpile/components/data/table/table-row-action.transformer.js.map +1 -0
  153. package/src/transpile/components/data/table/table-row.transformer.js +33 -0
  154. package/src/transpile/components/data/table/table-row.transformer.js.map +1 -0
  155. package/src/transpile/components/data/table/table.transformer.js +64 -0
  156. package/src/transpile/components/data/table/table.transformer.js.map +1 -0
  157. package/src/transpile/components/data/table/utils.js +89 -0
  158. package/src/transpile/components/data/table/utils.js.map +1 -0
  159. package/src/transpile/components/dialogs/alert-dialog.transformer.js +16 -0
  160. package/src/transpile/components/dialogs/alert-dialog.transformer.js.map +1 -0
  161. package/src/transpile/components/dialogs/confirm-dialog.transformer.js +16 -0
  162. package/src/transpile/components/dialogs/confirm-dialog.transformer.js.map +1 -0
  163. package/src/transpile/components/dialogs/dialog-actions.transformer.js +57 -0
  164. package/src/transpile/components/dialogs/dialog-actions.transformer.js.map +1 -0
  165. package/src/transpile/components/dialogs/dialog-body.transformer.js +13 -0
  166. package/src/transpile/components/dialogs/dialog-body.transformer.js.map +1 -0
  167. package/src/transpile/components/dialogs/dialog.transformer.js +26 -0
  168. package/src/transpile/components/dialogs/dialog.transformer.js.map +1 -0
  169. package/src/transpile/components/dialogs/iframe-dialog.transformer.js +16 -0
  170. package/src/transpile/components/dialogs/iframe-dialog.transformer.js.map +1 -0
  171. package/src/transpile/components/dialogs/login-dialog.transformer.js +45 -0
  172. package/src/transpile/components/dialogs/login-dialog.transformer.js.map +1 -0
  173. package/src/transpile/components/dialogs/page-dialog.transformer.js +16 -0
  174. package/src/transpile/components/dialogs/page-dialog.transformer.js.map +1 -0
  175. package/src/transpile/components/element/html-transformer.js +9 -0
  176. package/src/transpile/components/element/html-transformer.js.map +1 -0
  177. package/src/transpile/components/form/button-group.transformer.js +16 -0
  178. package/src/transpile/components/form/button-group.transformer.js.map +1 -0
  179. package/src/transpile/components/form/button.transformer.js +27 -0
  180. package/src/transpile/components/form/button.transformer.js.map +1 -0
  181. package/src/transpile/components/form/rating.transformer.js +19 -0
  182. package/src/transpile/components/form/rating.transformer.js.map +1 -0
  183. package/src/transpile/components/input/calendar.transformer.js +13 -0
  184. package/src/transpile/components/input/calendar.transformer.js.map +1 -0
  185. package/src/transpile/components/input/checkbox-set.transformer.js +29 -0
  186. package/src/transpile/components/input/checkbox-set.transformer.js.map +1 -0
  187. package/src/transpile/components/input/checkbox.transformer.js +47 -0
  188. package/src/transpile/components/input/checkbox.transformer.js.map +1 -0
  189. package/src/transpile/components/input/chips.transformer.js +22 -0
  190. package/src/transpile/components/input/chips.transformer.js.map +1 -0
  191. package/src/transpile/components/input/color-picker.transformer.js +19 -0
  192. package/src/transpile/components/input/color-picker.transformer.js.map +1 -0
  193. package/src/transpile/components/input/composite.transformer.js +16 -0
  194. package/src/transpile/components/input/composite.transformer.js.map +1 -0
  195. package/src/transpile/components/input/currency.transformer.js +21 -0
  196. package/src/transpile/components/input/currency.transformer.js.map +1 -0
  197. package/src/transpile/components/input/epoch/date.transformer.js +16 -0
  198. package/src/transpile/components/input/epoch/date.transformer.js.map +1 -0
  199. package/src/transpile/components/input/epoch/datetime.transformer.js +16 -0
  200. package/src/transpile/components/input/epoch/datetime.transformer.js.map +1 -0
  201. package/src/transpile/components/input/epoch/time.transformer.js +16 -0
  202. package/src/transpile/components/input/epoch/time.transformer.js.map +1 -0
  203. package/src/transpile/components/input/file-upload.transformer.js +32 -0
  204. package/src/transpile/components/input/file-upload.transformer.js.map +1 -0
  205. package/src/transpile/components/input/number.transformer.js +20 -0
  206. package/src/transpile/components/input/number.transformer.js.map +1 -0
  207. package/src/transpile/components/input/radio-set.transformer.js +25 -0
  208. package/src/transpile/components/input/radio-set.transformer.js.map +1 -0
  209. package/src/transpile/components/input/rating.transformer.js +20 -0
  210. package/src/transpile/components/input/rating.transformer.js.map +1 -0
  211. package/src/transpile/components/input/select.transformer.js +57 -0
  212. package/src/transpile/components/input/select.transformer.js.map +1 -0
  213. package/src/transpile/components/input/slider.transformer.js +28 -0
  214. package/src/transpile/components/input/slider.transformer.js.map +1 -0
  215. package/src/transpile/components/input/switch.transformer.js +21 -0
  216. package/src/transpile/components/input/switch.transformer.js.map +1 -0
  217. package/src/transpile/components/input/text.transformer.js +21 -0
  218. package/src/transpile/components/input/text.transformer.js.map +1 -0
  219. package/src/transpile/components/input/textarea.transformer.js +19 -0
  220. package/src/transpile/components/input/textarea.transformer.js.map +1 -0
  221. package/src/transpile/components/input/upload.transformer.js +19 -0
  222. package/src/transpile/components/input/upload.transformer.js.map +1 -0
  223. package/src/transpile/components/layout/footer.transformer.js +31 -0
  224. package/src/transpile/components/layout/footer.transformer.js.map +1 -0
  225. package/src/transpile/components/layout/header.transformer.js +31 -0
  226. package/src/transpile/components/layout/header.transformer.js.map +1 -0
  227. package/src/transpile/components/layout/leftnav.transformer.js +31 -0
  228. package/src/transpile/components/layout/leftnav.transformer.js.map +1 -0
  229. package/src/transpile/components/layout/rightnav.transformer.js +31 -0
  230. package/src/transpile/components/layout/rightnav.transformer.js.map +1 -0
  231. package/src/transpile/components/layout/topnav.transformer.js +35 -0
  232. package/src/transpile/components/layout/topnav.transformer.js.map +1 -0
  233. package/src/transpile/components/nav/nav-item.transformer.js +25 -0
  234. package/src/transpile/components/nav/nav-item.transformer.js.map +1 -0
  235. package/src/transpile/components/nav/nav.transformer.js +69 -0
  236. package/src/transpile/components/nav/nav.transformer.js.map +1 -0
  237. package/src/transpile/components/nav/navbar.transformer.js +121 -0
  238. package/src/transpile/components/nav/navbar.transformer.js.map +1 -0
  239. package/src/transpile/components/navigation/breadcrumb.transformer.js +16 -0
  240. package/src/transpile/components/navigation/breadcrumb.transformer.js.map +1 -0
  241. package/src/transpile/components/navigation/menu.transformer.js +36 -0
  242. package/src/transpile/components/navigation/menu.transformer.js.map +1 -0
  243. package/src/transpile/components/navigation/popover.transformer.js +29 -0
  244. package/src/transpile/components/navigation/popover.transformer.js.map +1 -0
  245. package/src/transpile/components/page/content.transformer.js +17 -0
  246. package/src/transpile/components/page/content.transformer.js.map +1 -0
  247. package/src/transpile/components/page/page-content.transformer.js +17 -0
  248. package/src/transpile/components/page/page-content.transformer.js.map +1 -0
  249. package/src/transpile/components/page/page.transformer.js +50 -0
  250. package/src/transpile/components/page/page.transformer.js.map +1 -0
  251. package/src/transpile/components/page/partial-container.transformer.js +95 -0
  252. package/src/transpile/components/page/partial-container.transformer.js.map +1 -0
  253. package/src/transpile/components/page/partial.transformer.js +19 -0
  254. package/src/transpile/components/page/partial.transformer.js.map +1 -0
  255. package/src/transpile/components/prefab/prefab-container.transformer.js +32 -0
  256. package/src/transpile/components/prefab/prefab-container.transformer.js.map +1 -0
  257. package/src/transpile/components/prefab/prefab.transformer.js +85 -0
  258. package/src/transpile/components/prefab/prefab.transformer.js.map +1 -0
  259. package/src/transpile/components/transform-register.js +247 -0
  260. package/src/transpile/components/transform-register.js.map +1 -0
  261. package/src/transpile/components/utils.js +371 -0
  262. package/src/transpile/components/utils.js.map +1 -0
  263. package/src/transpile/components/wmx-component/wmx-component.transformer.js +35 -0
  264. package/src/transpile/components/wmx-component/wmx-component.transformer.js.map +1 -0
  265. package/src/transpile/id-generator.js +87 -0
  266. package/src/transpile/id-generator.js.map +1 -0
  267. package/src/transpile/property/base-parser.js +13 -0
  268. package/src/transpile/property/base-parser.js.map +1 -0
  269. package/src/transpile/property/property-parser.js +276 -0
  270. package/src/transpile/property/property-parser.js.map +1 -0
  271. package/src/transpile/property/show-in-device.parser.js +17 -0
  272. package/src/transpile/property/show-in-device.parser.js.map +1 -0
  273. package/src/transpile/style/background-image.parser.js +20 -0
  274. package/src/transpile/style/background-image.parser.js.map +1 -0
  275. package/src/transpile/style/border-width.parser.js +20 -0
  276. package/src/transpile/style/border-width.parser.js.map +1 -0
  277. package/src/transpile/style/dimension-style.parser.js +70 -0
  278. package/src/transpile/style/dimension-style.parser.js.map +1 -0
  279. package/src/transpile/style/horizontal-align.parser.js +24 -0
  280. package/src/transpile/style/horizontal-align.parser.js.map +1 -0
  281. package/src/transpile/style/margin.parser.js +20 -0
  282. package/src/transpile/style/margin.parser.js.map +1 -0
  283. package/src/transpile/style/multi-dimension-style.parser.js +29 -0
  284. package/src/transpile/style/multi-dimension-style.parser.js.map +1 -0
  285. package/src/transpile/style/numeric-style.parser.js +18 -0
  286. package/src/transpile/style/numeric-style.parser.js.map +1 -0
  287. package/src/transpile/style/padding.parser.js +20 -0
  288. package/src/transpile/style/padding.parser.js.map +1 -0
  289. package/src/transpile/style/style.parser.js +15 -0
  290. package/src/transpile/style/style.parser.js.map +1 -0
  291. package/src/transpile/style.transformer.js +124 -0
  292. package/src/transpile/style.transformer.js.map +1 -0
  293. package/src/transpile/transpile.js +1057 -0
  294. package/src/transpile/transpile.js.map +1 -0
  295. package/src/transpile/widget-inline-style-constants.js +200 -0
  296. package/src/transpile/widget-inline-style-constants.js.map +1 -0
  297. package/src/transpile/widget-inline-style-processor.js +714 -0
  298. package/src/transpile/widget-inline-style-processor.js.map +1 -0
  299. package/src/types/index.js +6 -0
  300. package/src/types/index.js.map +1 -0
  301. package/src/utils/grouping-util.js +500 -0
  302. package/src/utils/grouping-util.js.map +1 -0
  303. package/src/utils.js +934 -0
  304. package/src/utils.js.map +1 -0
  305. package/src/variables/variable.transformer.js +675 -0
  306. package/src/variables/variable.transformer.js.map +1 -0
  307. package/src/wmx.generator.js +216 -0
  308. package/src/wmx.generator.js.map +1 -0
  309. package/templates/.DS_Store +0 -0
  310. package/templates/app.style.template +3 -0
  311. package/templates/app.variables.template +1 -0
  312. package/templates/component/app.libs.hbs +38 -0
  313. package/templates/component/app.script.hbs +8 -0
  314. package/templates/component/app.template.hbs +47 -0
  315. package/templates/component/component.hbs +92 -0
  316. package/templates/component/component.props.template +1 -0
  317. package/templates/component/formatter.hbs +8 -0
  318. package/templates/component/layout.hbs +32 -0
  319. package/templates/component/page.hbs +16 -0
  320. package/templates/component/partial.hbs +78 -0
  321. package/templates/component/script.template +6 -0
  322. package/templates/component/style-def.template +18 -0
  323. package/templates/component/style.template +1 -0
  324. package/templates/entity-provider.template +21 -0
  325. package/templates/foundation/layout.tsx +30 -0
  326. package/templates/pages-config.template +12 -0
  327. package/templates/partial-config.template +58 -0
  328. package/templates/project/.DS_Store +0 -0
  329. package/templates/project/.env +1 -0
  330. package/templates/project/.gitignore +2 -0
  331. package/templates/project/.prettierrc +8 -0
  332. package/templates/project/README.md +60 -0
  333. package/templates/project/app/autoLayout.css +133 -0
  334. package/templates/project/app/client.layout.tsx +193 -0
  335. package/templates/project/app/components.css +186 -0
  336. package/templates/project/app/error.tsx +27 -0
  337. package/templates/project/app/globals.css +157 -0
  338. package/templates/project/app/layout.tsx +40 -0
  339. package/templates/project/app/loading.tsx +6 -0
  340. package/templates/project/app/page.tsx +3 -0
  341. package/templates/project/app/widgetInlineStylesOverride.css +676 -0
  342. package/templates/project/hooks/usePageEvents.tsx +45 -0
  343. package/templates/project/libs/appConfig.ts +14 -0
  344. package/templates/project/next-env.d.ts +5 -0
  345. package/templates/project/next.config.ts +17 -0
  346. package/templates/project/package-lock.json +5397 -0
  347. package/templates/project/package.json +38 -0
  348. package/templates/project/public/error-fallback.svg +89 -0
  349. package/templates/project/public/file.svg +1 -0
  350. package/templates/project/public/globe.svg +1 -0
  351. package/templates/project/public/next.svg +1 -0
  352. package/templates/project/public/vercel.svg +1 -0
  353. package/templates/project/public/window.svg +1 -0
  354. package/templates/project/scripts/app-custom-server.js +44 -0
  355. package/templates/project/scripts/getlibs.js +53 -0
  356. package/templates/project/tsconfig.json +36 -0
  357. package/templates/project/types/runtime-config.d.ts +9 -0
  358. package/templates/resource.resolver.template +20 -0
  359. package/templates/service.defs.template +3 -0
  360. package/templates/variables.template +252 -0
@@ -0,0 +1,1272 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ const fs_extra_1 = __importDefault(require("fs-extra"));
40
+ const path_1 = require("path");
41
+ const lodash_1 = require("lodash");
42
+ const execa_1 = __importDefault(require("execa"));
43
+ const path_2 = __importDefault(require("path"));
44
+ const semver_1 = __importDefault(require("semver"));
45
+ const transpile_1 = require("./transpile/transpile");
46
+ const grouping_util_1 = require("./utils/grouping-util");
47
+ const variable_transformer_1 = __importDefault(require("./variables/variable.transformer"));
48
+ const utils_1 = require("./utils");
49
+ const bind_ex_transformer_1 = __importDefault(require("./transpile/bind.ex.transformer"));
50
+ const profile_1 = __importDefault(require("./profiles/profile"));
51
+ const utils_2 = require("./utils");
52
+ const gen_app_override_css_1 = require("./gen-app-override-css");
53
+ const wmx_generator_1 = require("./wmx.generator");
54
+ const COMPONENT_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + "/../templates/component/component.hbs");
55
+ const COMPONENT_PAGE_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + "/../templates/component/page.hbs");
56
+ const PARTIAL_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + "/../templates/component/partial.hbs");
57
+ const COMPONENT_PROPS_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + "/../templates/component/component.props.template");
58
+ const SCRIPT_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + "/../templates/component/script.template");
59
+ const PAGE_CONFIG_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + "/../templates/pages-config.template");
60
+ const PARTIAL_CONFIG_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + "/../templates/partial-config.template");
61
+ const VARIABLE_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + "/../templates/variables.template");
62
+ const ENTITY_PROVIDER_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + "/../templates/entity-provider.template");
63
+ const APP_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + "/../templates/component/app.template.hbs");
64
+ const APP_SCRIPT_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + "/../templates/component/app.script.hbs");
65
+ const FORMATTERS_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + "/../templates/component/formatter.hbs");
66
+ const APP_LIBS_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + "/../templates/component/app.libs.hbs");
67
+ const LAYOUT_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + "/../templates/component/layout.hbs");
68
+ const ALL_GENERATED_FILES = "(src/**/*.js|App.js|app.style.js|bootstrap.js|app/**/*.js|wm-project-properties.ts)";
69
+ // REF: https://github.com/facebook/metro/blob/master/packages/metro-config/src/defaults/defaults.js#L14-L44
70
+ const ALLOWED_RESOURCE_EXT = [
71
+ // Image formats
72
+ "bmp",
73
+ "gif",
74
+ "jpg",
75
+ "jpeg",
76
+ "png",
77
+ "psd",
78
+ "svg",
79
+ "webp",
80
+ // Video formats
81
+ "m4v",
82
+ "mov",
83
+ "mp4",
84
+ "mpeg",
85
+ "mpg",
86
+ "webm",
87
+ // Audio formats
88
+ "aac",
89
+ "aiff",
90
+ "caf",
91
+ "m4a",
92
+ "mp3",
93
+ "wav",
94
+ // Document formats
95
+ "html",
96
+ "pdf",
97
+ "yaml",
98
+ "yml",
99
+ "json",
100
+ // Font formats
101
+ "otf",
102
+ "ttf",
103
+ // Archives (virtual files)
104
+ "zip",
105
+ "js",
106
+ ];
107
+ let deviceVariables = [];
108
+ let appVersion;
109
+ class AppGenerator {
110
+ constructor(projectPath, projectService, appUrl, prefabName = "", incBuilder, options, dynamicPrefabProps) {
111
+ this.projectPath = projectPath;
112
+ this.projectService = projectService;
113
+ this.appUrl = appUrl;
114
+ this.prefabName = prefabName;
115
+ this.incBuilder = incBuilder;
116
+ this.options = options;
117
+ this.dynamicPrefabProps = dynamicPrefabProps;
118
+ this.transpiledComponents = {
119
+ pages: {},
120
+ partials: {},
121
+ prefabs: {},
122
+ };
123
+ this.pageLayoutMap = {};
124
+ this.generatedRouteGroups = new Set();
125
+ this.layoutKeyToIdMap = new Map();
126
+ this.liveVariables = [];
127
+ this.isPrefabApp = false;
128
+ this.ResolvePrefabImports = {
129
+ SCRIPT_IMPORTS: [],
130
+ NPM_PACKAGES: [],
131
+ };
132
+ this.wmxComponents = [];
133
+ this.isWaveApp = false;
134
+ this.serviceDefsSource = "STATIC";
135
+ this.languageBundleSource = "STATIC";
136
+ this.autolayoutCssRules = new Set();
137
+ this.isTrue = (value) => {
138
+ return value === true || value === "true";
139
+ };
140
+ this.options = options;
141
+ this.isPrefabApp = !!prefabName;
142
+ this.dynamicPrefabProps = dynamicPrefabProps;
143
+ this.wmxGenerator = new wmx_generator_1.WmxGenerator(projectPath, projectService);
144
+ this.wmxComponents = this.wmxGenerator.getComponentNames();
145
+ }
146
+ prepareVariables(variableJSON, scope, imports) {
147
+ const variables = Object.values(variableJSON)
148
+ .map((v) => (0, variable_transformer_1.default)(v, scope, this.appUrl, imports))
149
+ .filter(v => !!v);
150
+ const item = VARIABLE_TEMPLATE({
151
+ scope: scope,
152
+ imports: imports,
153
+ addEntityProvider: !this.isPrefabApp && scope !== "App",
154
+ isPrefabApp: this.isPrefabApp,
155
+ prefabName: this.prefabName,
156
+ isPrefabScope: scope === "Prefab",
157
+ context: {
158
+ Variables: variables.filter(v => v.group === "variable"),
159
+ Actions: variables.filter(v => v.group === "action"),
160
+ },
161
+ });
162
+ return item;
163
+ }
164
+ isPartial(type) {
165
+ return (type === "PARTIAL" ||
166
+ type === "LEFTNAV" ||
167
+ type === "POPOVER" ||
168
+ type === "TEMPLATE" ||
169
+ type === "HEADER" ||
170
+ type === "FOOTER" ||
171
+ type === "TOPNAV" ||
172
+ type === "RIGHTNAV");
173
+ }
174
+ resolvePrefabDynamicProps(markup, dynamicPrefabProps) {
175
+ Object.entries(dynamicPrefabProps).forEach(([key, value]) => {
176
+ if (value.startsWith("fragment.") &&
177
+ (markup.includes(`fragment.${key}`) || markup.includes(`fragment?.${key}`))) {
178
+ value = (0, utils_2.addOptionalChaining)(value);
179
+ markup = markup.replace(new RegExp(`fragment\\??\\.${key}`, "g"), value);
180
+ }
181
+ });
182
+ return markup;
183
+ }
184
+ prettify(target = ALL_GENERATED_FILES) {
185
+ let prettierPath = null;
186
+ let d = __dirname;
187
+ while (d) {
188
+ prettierPath = d + path_1.sep + "node_modules" + path_1.sep + "prettier";
189
+ if (fs_extra_1.default.existsSync(prettierPath)) {
190
+ break;
191
+ }
192
+ const s = d.split(path_1.sep);
193
+ s.pop();
194
+ d = s.join(path_1.sep);
195
+ }
196
+ if (d) {
197
+ const targetPath = target === ALL_GENERATED_FILES
198
+ ? `${this.projectPath}/**/*.{ts,tsx,js,jsx,json,css,md}`
199
+ : `${this.projectPath}/${target}`;
200
+ return (0, execa_1.default)("node", [`${prettierPath}${path_1.sep}bin/prettier.cjs`, "--write", targetPath]);
201
+ }
202
+ console.warn("Prettier is not found");
203
+ return Promise.reject();
204
+ }
205
+ setDeviceVariables(variables) {
206
+ variables = Object.values(variables);
207
+ const filterOutput = variables.filter((v) => v.category === "wm.DeviceVariable");
208
+ deviceVariables = deviceVariables.concat(filterOutput);
209
+ }
210
+ generateAppVariables() {
211
+ if (this.incBuilder) {
212
+ console.log(`Generating App variables.`);
213
+ }
214
+ return this.projectService.getAppVariables().then(variables => {
215
+ this.setDeviceVariables(variables);
216
+ Object.keys(variables).map((key) => {
217
+ // @ts-ignore
218
+ if (variables[key]["category"] === "wm.LiveVariable") {
219
+ // @ts-ignore
220
+ this.liveVariables.push(variables[key]);
221
+ }
222
+ });
223
+ const output = this.prepareVariables(variables, "App", []);
224
+ (0, utils_1.writeFile)(`${this.projectPath}/app/app.variables.ts`, output);
225
+ // include _app.tsx file in root folder
226
+ this.generateAppConfig(variables);
227
+ // include _app.script.js file in root folder
228
+ this.generateAppScript();
229
+ });
230
+ }
231
+ async generateAppScript() {
232
+ const script = await this.projectService.getAppScript();
233
+ // Check if there are any default prefabs in the project
234
+ const prefabs = await this.projectService.getPrefabs();
235
+ const hasDefaultPrefabs = prefabs.some((prefab) => ["youtube", "googlemaps", "qrcode"].includes(prefab.toLowerCase()));
236
+ const appScript = APP_SCRIPT_TEMPLATE({
237
+ script: script,
238
+ hasDefaultPrefabs: hasDefaultPrefabs,
239
+ });
240
+ (0, utils_1.writeFile)(`${this.projectPath}/app/app.script.js`, appScript);
241
+ // Generate app.libs.js
242
+ const appLibs = APP_LIBS_TEMPLATE({
243
+ hasDefaultPrefabs: hasDefaultPrefabs,
244
+ });
245
+ (0, utils_1.writeFile)(`${this.projectPath}/app/app.libs.js`, appLibs);
246
+ }
247
+ async generateAppConfig(variables) {
248
+ // create _app file and populate data
249
+ const App = APP_TEMPLATE({
250
+ startUpVariables: Object.values(variables)
251
+ .filter((v) => v.startUpdate && v.category !== "wm.TimerAction")
252
+ .map((v) => v.name),
253
+ startUpActions: Object.values(variables)
254
+ .filter((v) => v.startUpdate && v.category === "wm.TimerAction")
255
+ .map((v) => v.name),
256
+ autoUpdateVariables: Object.values(variables)
257
+ .filter((v) => v.autoUpdate ||
258
+ ((v.category === "wm.Variable" || v.category === "wm.LiveVariable") &&
259
+ v.dataBinding &&
260
+ v.dataBinding.length))
261
+ .map((v) => v.name),
262
+ });
263
+ (0, utils_1.writeFile)(`${this.projectPath}/app/_app.tsx`, App);
264
+ }
265
+ getBasePath() {
266
+ var _a, _b;
267
+ // First check if appBasePath is provided via command line
268
+ if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.appBasePath) {
269
+ if (!((_b = this.options) === null || _b === void 0 ? void 0 : _b.isServerPath)) {
270
+ (0, utils_1.updateEnvFile)(this.projectPath, { NEXT_PUBLIC_BASE_PATH: this.options.appBasePath });
271
+ }
272
+ return this.options.appBasePath;
273
+ }
274
+ return "";
275
+ }
276
+ generatePageConfig(pageConfigs, isPartOfPrefab) {
277
+ pageConfigs = pageConfigs.filter((p) => p.type == "PAGE");
278
+ const output = PAGE_CONFIG_TEMPLATE({
279
+ pageConfigs: pageConfigs,
280
+ pageConfigsStr: JSON.stringify(pageConfigs),
281
+ lazyload: profile_1.default.lazyloadPages,
282
+ });
283
+ let path = isPartOfPrefab
284
+ ? `${this.projectPath}/pages-config.ts`
285
+ : `${this.projectPath}/app/pages-config.ts`;
286
+ (0, utils_1.writeFile)(path, output);
287
+ }
288
+ generatePartialConfig(pageConfigs, isPartOfPrefab) {
289
+ pageConfigs = pageConfigs.filter((p) => this.isPartial(p.type));
290
+ const output = PARTIAL_CONFIG_TEMPLATE({
291
+ pageConfigs: pageConfigs,
292
+ pageConfigsStr: JSON.stringify(pageConfigs),
293
+ lazyload: profile_1.default.lazyloadPartials,
294
+ });
295
+ let path = isPartOfPrefab
296
+ ? `${this.projectPath}/components/partial-config.ts`
297
+ : `${this.projectPath}/app/components/partial-config.ts`;
298
+ (0, utils_1.writeFile)(path, output);
299
+ }
300
+ extractRefsFromMarkup(markup) {
301
+ const refs = [];
302
+ const regex = /<\w+[^>]*\bname=["']([^"']+)["']/g; // Match any component with a `name` property
303
+ let match;
304
+ while ((match = regex.exec(markup)) !== null) {
305
+ refs.push(match[1]); // Extract the name
306
+ }
307
+ return refs;
308
+ }
309
+ generateComponent(info, type, name, isPartOfPrefab) {
310
+ var _a, _b, _c, _d;
311
+ if (this.incBuilder && !this.incBuilder.isFragmentModified(name)) {
312
+ return Promise.resolve();
313
+ }
314
+ if (this.incBuilder) {
315
+ console.log(`Generating ${name} component.`);
316
+ }
317
+ const lType = type.toLowerCase();
318
+ const typeLabel = (0, lodash_1.capitalize)(type);
319
+ let variables = {};
320
+ try {
321
+ variables = info.variables ? JSON.parse(info.variables) : {};
322
+ }
323
+ catch (_e) {
324
+ console.log(`Error parsing variables for ${name}, skipping variables.`);
325
+ variables = {};
326
+ }
327
+ Object.keys(variables).map(key => {
328
+ if (variables[key]["category"] === "wm.LiveVariable") {
329
+ this.liveVariables.push(variables[key]);
330
+ }
331
+ });
332
+ this.setDeviceVariables(variables);
333
+ // let dest = type === 'PREFAB' ? `${this.projectPath}/app/${name}` : `${this.projectPath}/app/${name}`;
334
+ let dest = "";
335
+ if (type === "PREFAB") {
336
+ dest = `${this.projectPath}/${name}`;
337
+ }
338
+ else if (type === "PAGE") {
339
+ const layoutId = (_a = this.pageLayoutMap) === null || _a === void 0 ? void 0 : _a[name];
340
+ const groupPrefix = layoutId ? `/(${layoutId})` : "";
341
+ dest = `${this.projectPath}/app/react-pages${groupPrefix}/${name}`;
342
+ }
343
+ else {
344
+ dest = isPartOfPrefab
345
+ ? `${this.projectPath}/components/${name}`
346
+ : `${this.projectPath}/app/components/${name}`;
347
+ }
348
+ try {
349
+ const output = this.prepareVariables(variables, typeLabel, []);
350
+ (0, utils_1.writeFile)(`${dest}/${name}.variables.ts`, output);
351
+ const transpiledOutput = (0, transpile_1.transpileMarkup)(info.markup, this.isPrefabApp, undefined, variables);
352
+ if (transpiledOutput.autolayoutCss) {
353
+ transpiledOutput.autolayoutCss.forEach(rule => this.autolayoutCssRules.add(rule));
354
+ }
355
+ let imports = (0, lodash_1.sortBy)((0, lodash_1.uniqBy)(transpiledOutput.imports, i => i.name + i.from), i => i.name);
356
+ const _markup = "\n" + transpiledOutput.markup;
357
+ const dynamicRefs = this.extractRefsFromMarkup(_markup);
358
+ const TEMPLATE_TYPE = this.isPartial(type) ? PARTIAL_TEMPLATE : COMPONENT_TEMPLATE;
359
+ if (this.dynamicPrefabProps && Object.keys(this.dynamicPrefabProps).length > 0) {
360
+ transpiledOutput.markup = this.resolvePrefabDynamicProps(transpiledOutput.markup, this.dynamicPrefabProps);
361
+ }
362
+ let effectiveMarkup = transpiledOutput.markup;
363
+ if (type === "PAGE") {
364
+ const hasLayout = (_b = this.pageLayoutMap) === null || _b === void 0 ? void 0 : _b[name];
365
+ if (hasLayout) {
366
+ effectiveMarkup = (0, grouping_util_1.extractInnerPageContent)(transpiledOutput.markup);
367
+ imports = (0, grouping_util_1.filterImportsByMarkup)(effectiveMarkup, imports);
368
+ }
369
+ }
370
+ const component = TEMPLATE_TYPE({
371
+ name: name,
372
+ componentName: (name.charAt(0).toUpperCase() + name.substring(1)).replace(/-/g, ""),
373
+ type: type,
374
+ lType: lType,
375
+ typeLabel: typeLabel,
376
+ prefabName: this.prefabName,
377
+ markup: "\n" + (0, utils_1.fixURLPath)(effectiveMarkup, this.getBasePath()),
378
+ components: transpiledOutput.components,
379
+ pageEvents: transpiledOutput.pageEvents,
380
+ startUpVariables: Object.values(variables)
381
+ .filter((v) => v.startUpdate && v.category !== "wm.TimerAction")
382
+ .map((v) => v.name),
383
+ startUpActions: Object.values(variables)
384
+ .filter((v) => v.startUpdate && v.category === "wm.TimerAction")
385
+ .map((v) => v.name),
386
+ autoUpdateVariables: Object.values(variables)
387
+ .filter((v) => v.autoUpdate ||
388
+ ((v.category === "wm.Variable" || v.category === "wm.LiveVariable") &&
389
+ v.dataBinding &&
390
+ v.dataBinding.length))
391
+ .map((v) => v.name),
392
+ eagerImports: imports.filter(i => !i.lazy),
393
+ lazyImports: imports.filter(i => i.lazy),
394
+ dynamicRefs,
395
+ });
396
+ if (type === "PAGE") {
397
+ const componentName = (name.charAt(0).toUpperCase() + name.substring(1)).replace(/-/g, "");
398
+ const pageTitleMatch = (_c = info.markup) === null || _c === void 0 ? void 0 : _c.match(/pagetitle=["']([^"']+)["']/i);
399
+ const rawPageTitle = (_d = pageTitleMatch === null || pageTitleMatch === void 0 ? void 0 : pageTitleMatch[1]) === null || _d === void 0 ? void 0 : _d.trim();
400
+ const isExpression = rawPageTitle && /^(bind:|{{)/.test(rawPageTitle);
401
+ const pageTitle = rawPageTitle && rawPageTitle.length > 0 && !isExpression ? rawPageTitle : componentName;
402
+ const componentPage = COMPONENT_PAGE_TEMPLATE({
403
+ name: name,
404
+ type: type,
405
+ lType: lType,
406
+ componentName: (name.charAt(0).toUpperCase() + name.substring(1)).replace(/-/g, ""),
407
+ pageTitle: pageTitle,
408
+ typeLabel: typeLabel,
409
+ dynamicPrefabProps: this.dynamicPrefabProps || {},
410
+ prefabName: this.prefabName,
411
+ markup: "\n" + (0, utils_1.fixURLPath)(effectiveMarkup, this.getBasePath()),
412
+ components: transpiledOutput.components,
413
+ startUpVariables: Object.values(variables)
414
+ .filter((v) => v.startUpdate && v.category !== "wm.TimerAction")
415
+ .map((v) => v.name),
416
+ startUpActions: Object.values(variables)
417
+ .filter((v) => v.startUpdate && v.category === "wm.TimerAction")
418
+ .map((v) => v.name),
419
+ autoUpdateVariables: Object.values(variables)
420
+ .filter((v) => v.autoUpdate ||
421
+ ((v.category === "wm.Variable" || v.category === "wm.LiveVariable") &&
422
+ v.dataBinding &&
423
+ v.dataBinding.length))
424
+ .map((v) => v.name),
425
+ eagerImports: imports.filter(i => !i.lazy),
426
+ lazyImports: imports.filter(i => i.lazy),
427
+ });
428
+ (0, utils_1.writeFile)(`${dest}/${name}.component.tsx`, component);
429
+ (0, utils_1.writeFile)(`${dest}/page.tsx`, componentPage);
430
+ }
431
+ else {
432
+ (0, utils_1.writeFile)(`${dest}/${name}.tsx`, component);
433
+ }
434
+ const script = SCRIPT_TEMPLATE({
435
+ typeLabel: typeLabel,
436
+ script: info.script,
437
+ });
438
+ (0, utils_1.writeFile)(`${dest}/${name}.script.js`, script);
439
+ const updatedCss = (0, utils_1.fixURLPathAndScope)(info.styles, this.getBasePath(), true);
440
+ (0, utils_1.writeFile)(`${dest}/${name}.css`, updatedCss);
441
+ return Promise.all(transpiledOutput.prefabs.map(p => this.generatePrefabComponent(p, false))).then(() => {
442
+ return Promise.all(transpiledOutput.wmxcomponents.map((c) => this.wmxGenerator.generate(c, false)));
443
+ });
444
+ }
445
+ catch (e) {
446
+ console.log(`failed to generate component ${dest}/${name}`);
447
+ throw e;
448
+ }
449
+ }
450
+ generatePrefabProps(name, projectPath) {
451
+ const dynamicProps = {};
452
+ return this.projectService.getPrefabInfo(name).then(info => {
453
+ const propConfig = {};
454
+ Object.keys(info.config.properties).map((k) => {
455
+ let value = info.config.properties[k].value;
456
+ const type = info.config.properties[k].type;
457
+ if (type === "number" || type == "integer") {
458
+ value = Number(value);
459
+ }
460
+ if (type === "boolean") {
461
+ value = Boolean(value);
462
+ }
463
+ if ((0, lodash_1.isString)(value) && value.startsWith("bind:")) {
464
+ let exStr = decodeURIComponent(value.substring(5));
465
+ dynamicProps[k] = `${(0, bind_ex_transformer_1.default)(exStr, "fragment", "attr")}`;
466
+ propConfig[k] = null;
467
+ }
468
+ else {
469
+ propConfig[k] = value === undefined ? null : value;
470
+ }
471
+ });
472
+ let propsStr = JSON.stringify(propConfig);
473
+ if (info.config.events) {
474
+ propsStr = propsStr.replace(/\}$/, "");
475
+ Object.keys(info.config.events).map((k) => {
476
+ propsStr += `${propsStr.length === 1 ? "" : ","} ${k} : () => {}`;
477
+ });
478
+ propsStr += "}";
479
+ }
480
+ const props = COMPONENT_PROPS_TEMPLATE({
481
+ props: propsStr,
482
+ });
483
+ (0, utils_1.writeFile)(`${projectPath}/app/prefabs/${name}/Main/Main.props.js`, props);
484
+ return dynamicProps;
485
+ });
486
+ }
487
+ generatePrefabComponent(name, overwrite = true) {
488
+ var _a;
489
+ if ((!overwrite && this.transpiledComponents.prefabs[name]) ||
490
+ (this.incBuilder && !((_a = this.incBuilder) === null || _a === void 0 ? void 0 : _a.isPrefabModified(name)))) {
491
+ return Promise.resolve();
492
+ }
493
+ if (this.incBuilder) {
494
+ console.log(`Generating ${name} prefab component.`);
495
+ }
496
+ const projectPath = this.isPrefabApp
497
+ ? this.projectPath.split("/app/prefabs/")[0]
498
+ : this.projectPath;
499
+ const appUrl = this.isPrefabApp ? this.appUrl.split("/app/prefabs/")[0] : this.appUrl;
500
+ this.transpiledComponents.prefabs[name] = true;
501
+ return this.generatePrefabProps(name, projectPath).then(dynamicPrefabProps => {
502
+ const prefabGenerator = new AppGenerator(`${projectPath}/app/prefabs/${name}`, this.projectService.getPrefabProjectService(name), `${appUrl}/app/prefabs/${name}`, name, undefined, undefined, dynamicPrefabProps);
503
+ return prefabGenerator
504
+ .generatePagesAndPartials(true)
505
+ .then(() => this.copyPrefabResources(projectPath, name))
506
+ .then(() => this.addPrefabLibsToLayout(prefabGenerator.projectPath, name));
507
+ });
508
+ }
509
+ addPrefabLibsToLayout(projectPath, prefabName) {
510
+ if (!projectPath || !prefabName)
511
+ return;
512
+ return this.projectService.getPrefabIndexHtml(prefabName).then(html => {
513
+ this.IncludeHtmlLibs(html);
514
+ return Promise.resolve({});
515
+ });
516
+ }
517
+ addIndexHtmlToLayout() {
518
+ if (this.isPrefabApp)
519
+ return Promise.resolve();
520
+ return this.projectService
521
+ .getIndexHtml()
522
+ .then(html => {
523
+ this.IncludeHtmlLibs(html);
524
+ return Promise.resolve({});
525
+ })
526
+ .catch(() => Promise.resolve({}));
527
+ }
528
+ copyPrefabResources(projectPath, prefabName) {
529
+ if (!projectPath || !prefabName)
530
+ return;
531
+ return this.projectService.getPrefabResources(prefabName).then(p => {
532
+ if (p) {
533
+ const dest = `${projectPath}/public/${prefabName}/resources`;
534
+ fs_extra_1.default.copySync(p, dest, {
535
+ filter: (src) => {
536
+ return !src.includes(path_2.default.sep + "i18n" + path_2.default.sep) && !src.endsWith(path_2.default.sep + "i18n");
537
+ },
538
+ });
539
+ }
540
+ this.resolvePrefabImports(prefabName).then(res => {
541
+ if (res.CSS_IMPORTS.length) {
542
+ // Filter imports to only include files that actually exist
543
+ const validImports = res.CSS_IMPORTS.filter((importPath) => {
544
+ const fullPath = path_2.default.resolve(projectPath, importPath);
545
+ const exists = fs_extra_1.default.existsSync(fullPath);
546
+ if (!exists) {
547
+ console.warn(`CSS import file not found: ${fullPath}, skipping import`);
548
+ }
549
+ return exists;
550
+ });
551
+ if (validImports.length > 0) {
552
+ const imports = validImports.map((i) => `import "${i}";`).join("\n");
553
+ const mainFilePath = `${projectPath}/app/prefabs/${prefabName}/Main/Main.tsx`;
554
+ if (fs_extra_1.default.existsSync(mainFilePath)) {
555
+ const mainContent = fs_extra_1.default.readFileSync(mainFilePath, "utf-8");
556
+ // Find the first line and insert imports after it
557
+ const lines = mainContent.split("\n");
558
+ const updatedContent = `${lines[0]}\n${imports}\n${lines.slice(1).join("\n")}`;
559
+ fs_extra_1.default.writeFileSync(mainFilePath, updatedContent);
560
+ }
561
+ }
562
+ }
563
+ });
564
+ return Promise.resolve({});
565
+ });
566
+ }
567
+ resolvePrefabImports(name) {
568
+ return this.projectService.getPrefabInfo(name).then(info => {
569
+ var _a;
570
+ const NPM_PACKAGES = [];
571
+ const CSS_IMPORTS = [];
572
+ info.config.resources.styles.forEach((item) => {
573
+ if (!item.endsWith("Main.css")) {
574
+ CSS_IMPORTS.push(`public/${name}${item}`);
575
+ }
576
+ }) || [];
577
+ const SCRIPT_IMPORTS = info.config.resources.scripts.map((item) => {
578
+ if (item.startsWith("npm://")) {
579
+ NPM_PACKAGES.push(item.replace("npm://", ""));
580
+ }
581
+ else if (item.startsWith("http")) {
582
+ return item;
583
+ }
584
+ else {
585
+ return `/${name}${item}`;
586
+ }
587
+ });
588
+ this.ResolvePrefabImports = {
589
+ SCRIPT_IMPORTS: [...(_a = this.ResolvePrefabImports) === null || _a === void 0 ? void 0 : _a.SCRIPT_IMPORTS, ...SCRIPT_IMPORTS],
590
+ NPM_PACKAGES: [...this.ResolvePrefabImports.NPM_PACKAGES, ...NPM_PACKAGES],
591
+ };
592
+ return Promise.resolve({
593
+ CSS_IMPORTS: CSS_IMPORTS || [],
594
+ });
595
+ });
596
+ }
597
+ generateAllPrefabComponents(overwrite) {
598
+ return this.projectService.getPrefabs().then(prefabs => {
599
+ return Promise.all(prefabs === null || prefabs === void 0 ? void 0 : prefabs.map(prefab => this.generatePrefabComponent(prefab, overwrite)));
600
+ });
601
+ }
602
+ generatePageComponent(name, overwrite = true, isPartOfPrefab) {
603
+ if (!overwrite && this.transpiledComponents.pages[name]) {
604
+ return Promise.resolve();
605
+ }
606
+ this.transpiledComponents.pages[name] = true;
607
+ return this.projectService.getPageInfo(name).then(info => {
608
+ if (!info) {
609
+ console.log(`Page ${name} not found, skipping.`);
610
+ return Promise.resolve();
611
+ }
612
+ return this.generateComponent(info, this.isPrefabApp ? "PREFAB" : "PAGE", name, isPartOfPrefab);
613
+ });
614
+ }
615
+ generatePartialComponent(name, overwrite = true, isPartOfPrefab) {
616
+ if (!overwrite && this.transpiledComponents.partials[name]) {
617
+ return Promise.resolve();
618
+ }
619
+ this.transpiledComponents.partials[name] = true;
620
+ return this.projectService.getPageInfo(name).then(info => {
621
+ if (!info) {
622
+ console.log(`Partial ${name} not found, skipping.`);
623
+ return Promise.resolve();
624
+ }
625
+ return this.generateComponent(info, "PARTIAL", name, isPartOfPrefab);
626
+ });
627
+ }
628
+ ensureRouteGroupLayout(layoutId, config = {}) {
629
+ if (!layoutId)
630
+ return;
631
+ if (this.generatedRouteGroups.has(layoutId))
632
+ return;
633
+ const groupDir = `${this.projectPath}/app/react-pages/(${layoutId})`;
634
+ const layoutFile = `${groupDir}/layout.tsx`;
635
+ const content = LAYOUT_TEMPLATE({
636
+ components: config.scaffoldMarkup,
637
+ eagerImports: config.eagerImports || [],
638
+ lazyImports: config.lazyImports || [],
639
+ });
640
+ (0, utils_1.writeFile)(layoutFile, content);
641
+ this.generatedRouteGroups.add(layoutId);
642
+ }
643
+ generateAppStyles() {
644
+ if (this.incBuilder) {
645
+ console.log(`Generating app.styles.css .`);
646
+ }
647
+ return this.projectService.getAppCss().then(response => {
648
+ const basePath = this.getBasePath();
649
+ const updatedCss = (0, utils_1.fixURLPath)(response, basePath, true);
650
+ (0, utils_1.writeFile)(`${this.projectPath}/app/app.css`, updatedCss);
651
+ });
652
+ }
653
+ generateAutoLayoutCSS() {
654
+ if (this.autolayoutCssRules.size === 0)
655
+ return;
656
+ const cssPath = `${this.projectPath}/app/autoLayout.css`;
657
+ fs_extra_1.default.appendFileSync(cssPath, "\n" + Array.from(this.autolayoutCssRules).join("\n\n") + "\n");
658
+ }
659
+ getAllResources(filter = (str) => true, dirPath = this.projectPath + "/assets/resources", pathPrefix = "resources", arrayOfFiles = []) {
660
+ if (fs_extra_1.default.existsSync(dirPath)) {
661
+ fs_extra_1.default.readdirSync(dirPath).forEach(file => {
662
+ if (fs_extra_1.default.statSync(dirPath + "/" + file).isDirectory()) {
663
+ arrayOfFiles = this.getAllResources(filter, dirPath + "/" + file, pathPrefix + "/" + file, arrayOfFiles);
664
+ }
665
+ else if (filter(dirPath + "/" + file)) {
666
+ const ext = (0, lodash_1.last)(file.split("."));
667
+ if (file.indexOf("@") < 0 && ALLOWED_RESOURCE_EXT.indexOf(ext || "") >= 0) {
668
+ arrayOfFiles.push(pathPrefix + "/" + file);
669
+ }
670
+ }
671
+ });
672
+ }
673
+ return arrayOfFiles;
674
+ }
675
+ copyi18nFiles() {
676
+ if (this.incBuilder) {
677
+ console.log(`Copying i18n files.`);
678
+ }
679
+ if (this.languageBundleSource !== "STATIC") {
680
+ return Promise.resolve({});
681
+ }
682
+ return this.projectService.geti18NFiles().then(p => {
683
+ if (p) {
684
+ fs_extra_1.default.copySync(p, this.projectPath + "/public/resources/i18n");
685
+ }
686
+ return Promise.resolve({});
687
+ });
688
+ }
689
+ copyServiceDefs() {
690
+ if (this.serviceDefsSource !== "STATIC") {
691
+ return Promise.resolve();
692
+ }
693
+ return this.projectService.getServiceDefsPath().then(serviceDefsPath => {
694
+ const targetDir = path_2.default.resolve(this.projectPath + "/public/services");
695
+ try {
696
+ // Copy regular service defs
697
+ if (fs_extra_1.default.existsSync(serviceDefsPath)) {
698
+ fs_extra_1.default.mkdirSync(targetDir, { recursive: true });
699
+ const sourceFile = path_2.default.join(serviceDefsPath, "app-servicedefs.json");
700
+ const targetFile = path_2.default.join(targetDir, "servicedefs.json");
701
+ if (fs_extra_1.default.existsSync(sourceFile)) {
702
+ fs_extra_1.default.copyFileSync(sourceFile, targetFile);
703
+ console.log("Service defs copied to servicedefs");
704
+ }
705
+ else {
706
+ console.warn(`Source file does not exist: ${sourceFile}`);
707
+ }
708
+ }
709
+ else {
710
+ console.warn(`Source directory does not exist: ${serviceDefsPath}`);
711
+ }
712
+ // Copy prefab service defs
713
+ const normalizedPath = serviceDefsPath.replace(/[/\\]$/, ""); // Remove trailing slash
714
+ const prefabSourceDir = normalizedPath.replace(/servicedefs$/, "prefabs");
715
+ if (fs_extra_1.default.existsSync(prefabSourceDir)) {
716
+ // Ensure target directory exists
717
+ fs_extra_1.default.mkdirSync(targetDir, { recursive: true });
718
+ // Read all prefab directories
719
+ const prefabDirs = fs_extra_1.default
720
+ .readdirSync(prefabSourceDir, { withFileTypes: true })
721
+ .filter((dirent) => dirent.isDirectory())
722
+ .map((dirent) => dirent.name);
723
+ let copiedCount = 0;
724
+ // Process each prefab directory
725
+ prefabDirs.forEach((prefabName) => {
726
+ const prefabSourcePath = path_2.default.join(prefabSourceDir, prefabName, "prefab-servicedefs.json");
727
+ const prefabTargetDir = path_2.default.join(targetDir, "prefabs", prefabName);
728
+ const prefabTargetPath = path_2.default.join(prefabTargetDir, "servicedefs.json");
729
+ // Check if prefab-servicedefs.json exists
730
+ if (fs_extra_1.default.existsSync(prefabSourcePath)) {
731
+ // Create target directory for this prefab
732
+ fs_extra_1.default.mkdirSync(prefabTargetDir, { recursive: true });
733
+ // Copy and rename the file
734
+ fs_extra_1.default.copyFileSync(prefabSourcePath, prefabTargetPath);
735
+ copiedCount++;
736
+ console.log(`Copied prefab service defs: ${prefabName} -> services/prefabs/${prefabName}/servicedefs.json`);
737
+ }
738
+ });
739
+ if (copiedCount > 0) {
740
+ console.log(`✅ Copied ${copiedCount} prefab service defs to servicedefs`);
741
+ }
742
+ }
743
+ }
744
+ catch (error) {
745
+ console.error("Error copying service defs:", error);
746
+ }
747
+ });
748
+ }
749
+ copyThemesFiles() {
750
+ return this.projectService
751
+ .getThemesFiles(this.isWaveApp)
752
+ .then(p => {
753
+ try {
754
+ if (p && this.isWaveApp) {
755
+ fs_extra_1.default.copySync(p, this.projectPath + "/public/design-tokens");
756
+ }
757
+ else if (p) {
758
+ fs_extra_1.default.copySync(p, this.projectPath + "/public/themes");
759
+ }
760
+ return Promise.resolve({});
761
+ }
762
+ catch (error) {
763
+ console.warn("Warning: Failed to copy theme files:", error);
764
+ return Promise.resolve({});
765
+ }
766
+ })
767
+ .catch(error => {
768
+ console.warn("Warning: Failed to get theme files:", error === null || error === void 0 ? void 0 : error.message);
769
+ return Promise.resolve({});
770
+ });
771
+ }
772
+ copyFavIcon() {
773
+ return this.projectService.getFavIcon().then(p => {
774
+ if (p && fs_extra_1.default.existsSync(p)) {
775
+ const dest = `${this.projectPath}/public/favicon.png`;
776
+ fs_extra_1.default.copySync(p, dest);
777
+ }
778
+ return Promise.resolve({});
779
+ });
780
+ }
781
+ async generateOverrideCSS(options) {
782
+ var _a;
783
+ // this.projectPath is the generated React app directory (e.g., temp/App)
784
+ // We need to pass the source project root from projectService
785
+ const sourceProjectPath = this.projectService.path;
786
+ // Get project root directory (parent of src/main/webapp or WEB-INF)
787
+ const projectRoot = sourceProjectPath.replace(/[\/\\](src[\/\\]main[\/\\]webapp|WEB-INF).*$/, "");
788
+ // this is only for local development, this block will not work in prod build
789
+ console.log("isLocal===>", options === null || options === void 0 ? void 0 : options.isLocal);
790
+ if (this.isTrue(options === null || options === void 0 ? void 0 : options.isLocal)) {
791
+ console.log("generateOverrideCss paths", "projectRoot===", projectRoot, "projectPath===", this.projectPath);
792
+ await (0, gen_app_override_css_1.generateOverrideCSS)({
793
+ runtimeUIVersion: ((_a = this.options) === null || _a === void 0 ? void 0 : _a.runtimeUIVersion) || "latest",
794
+ }, projectRoot, this.projectPath);
795
+ }
796
+ return Promise.resolve();
797
+ }
798
+ async generateFontConfig() {
799
+ if (this.incBuilder) {
800
+ console.log("Generating Font config.");
801
+ }
802
+ try {
803
+ const code = await this.projectService.getFontConfig();
804
+ await (0, utils_1.writeFile)(`${this.projectPath}/app/font.config.ts`, code);
805
+ this.IncludeScriptImports();
806
+ }
807
+ catch (e) {
808
+ console.log("Error generating font.config.js", e);
809
+ }
810
+ }
811
+ async IncludeHtmlLibs(html) {
812
+ try {
813
+ let layoutContent = fs_extra_1.default.readFileSync(`${this.projectPath}/app/layout.tsx`, "utf-8");
814
+ // optimization to keep the original “only write when we changed something” behavior.
815
+ let hasChanges = false;
816
+ // Extract script and link tags, passing layoutContent to avoid duplicates
817
+ const scriptsElements = (0, utils_1.extractScriptAndLinkTags)(html, layoutContent);
818
+ // Only update if there are new elements to add
819
+ if (scriptsElements && scriptsElements.trim()) {
820
+ hasChanges = true;
821
+ // Find the position of </head> and insert before it
822
+ // This preserves existing imports
823
+ const headCloseIndex = layoutContent.lastIndexOf("</head>");
824
+ if (headCloseIndex !== -1) {
825
+ const beforeHead = layoutContent.substring(0, headCloseIndex);
826
+ const afterHead = layoutContent.substring(headCloseIndex);
827
+ layoutContent = `${beforeHead}
828
+ ${scriptsElements}
829
+ ${afterHead}`;
830
+ }
831
+ else {
832
+ // Fallback to original method if </head> not found
833
+ layoutContent = layoutContent.replace(/\s*<\/head>/, `
834
+ ${scriptsElements}\n
835
+ </head>`);
836
+ }
837
+ }
838
+ // Splash screen support: extract interactive-container div (if present), convert to JSX, insert into body
839
+ const interactiveContainerHtml = (0, utils_1.extractInteractiveContainerDiv)(html);
840
+ if (interactiveContainerHtml && !layoutContent.includes("interactive-container")) {
841
+ hasChanges = true;
842
+ const interactiveContainerJsx = (0, utils_1.htmlToJsx)(interactiveContainerHtml);
843
+ const bodyOpenMatch = layoutContent.match(/(<body[^>]*>)/);
844
+ if ((bodyOpenMatch === null || bodyOpenMatch === void 0 ? void 0 : bodyOpenMatch.index) !== undefined) {
845
+ const insertIndex = bodyOpenMatch.index + bodyOpenMatch[1].length;
846
+ layoutContent =
847
+ layoutContent.slice(0, insertIndex) +
848
+ `\n ${interactiveContainerJsx}\n ` +
849
+ layoutContent.slice(insertIndex);
850
+ }
851
+ }
852
+ if (hasChanges) {
853
+ fs_extra_1.default.writeFileSync(`${this.projectPath}/app/layout.tsx`, layoutContent, "utf-8");
854
+ }
855
+ }
856
+ catch (e) {
857
+ console.log("Error in IncludePrefabsHtmlLibs:", e);
858
+ }
859
+ }
860
+ async IncludeScriptImports() {
861
+ try {
862
+ const layoutContent = fs_extra_1.default.readFileSync(`${this.projectPath}/app/layout.tsx`, "utf-8");
863
+ const fontConfig = await Promise.resolve(`${`${this.projectPath}/app/font.config.ts`}`).then(s => __importStar(require(s)));
864
+ const fonts = fontConfig.default.fonts;
865
+ if (!fonts || fonts.length === 0) {
866
+ return;
867
+ }
868
+ const scriptsElements = fonts
869
+ .map((file) => {
870
+ let links = "";
871
+ if (file === null || file === void 0 ? void 0 : file.csspath) {
872
+ links += `<link rel="stylesheet" href={\`\${configs.appConfig.basePath}${file.csspath}\`} />\n`;
873
+ }
874
+ if (file === null || file === void 0 ? void 0 : file.path) {
875
+ links += `<link rel="preload" href={\`\${configs.appConfig.basePath}${file.path}\`} />\n`;
876
+ }
877
+ return links;
878
+ })
879
+ .filter(Boolean)
880
+ .join("\n");
881
+ const updatedContent = layoutContent.replace(/\s*<\/head>/, `
882
+ ${scriptsElements}\n
883
+ </head>`);
884
+ fs_extra_1.default.writeFileSync(`${this.projectPath}/app/layout.tsx`, updatedContent, "utf-8");
885
+ }
886
+ catch (e) {
887
+ console.log("Error in IncludeScriptImports:", e);
888
+ }
889
+ }
890
+ async copyResource() {
891
+ return this.projectService.getResources().then(p => {
892
+ if (p) {
893
+ const dest = `${this.projectPath}${!this.isPrefabApp ? "/public" : ""}/resources`;
894
+ if (this.languageBundleSource !== "STATIC") {
895
+ fs_extra_1.default.copySync(p, dest, {
896
+ filter: (src) => {
897
+ return (!src.includes(path_2.default.sep + "i18n" + path_2.default.sep) && !src.endsWith(path_2.default.sep + "i18n"));
898
+ },
899
+ });
900
+ }
901
+ else {
902
+ fs_extra_1.default.copySync(p, dest);
903
+ }
904
+ }
905
+ return Promise.resolve({});
906
+ });
907
+ }
908
+ generatePagesAndPartials(isPartOfPrefab) {
909
+ let pageConfigs = null;
910
+ let securityConfigs = null;
911
+ return this.projectService
912
+ .getPageConfigs()
913
+ .then(_pageConfigs => {
914
+ pageConfigs = _pageConfigs;
915
+ return this.projectService.getSecurityConfig();
916
+ })
917
+ .then(_securityConfigs => {
918
+ securityConfigs = _securityConfigs;
919
+ pageConfigs = pageConfigs.map((p) => {
920
+ const matchingSecurity = securityConfigs.find((sec) => {
921
+ if (isPartOfPrefab) {
922
+ //search for prefab name since all pages inside the prefab we get main.tsx file
923
+ return sec.urlPattern.includes(`/prefabs/${this.prefabName}`);
924
+ }
925
+ else {
926
+ return sec.urlPattern.includes(`/pages/${p.name}`);
927
+ }
928
+ });
929
+ //Common page have always access to everyone
930
+ if (p.name === "Common" && !isPartOfPrefab) {
931
+ return Object.assign({}, p, {
932
+ allowedRoles: [],
933
+ permission: "PermitAll",
934
+ });
935
+ }
936
+ if (matchingSecurity) {
937
+ return Object.assign({}, p, {
938
+ allowedRoles: matchingSecurity.roles,
939
+ permission: matchingSecurity.permission,
940
+ });
941
+ }
942
+ return Object.assign({}, p, {
943
+ permission: "Authenticated",
944
+ });
945
+ });
946
+ // Build layout map and create route group layouts (auto-detect when layoutId absent)
947
+ this.pageLayoutMap = {};
948
+ const pageNames = (pageConfigs || [])
949
+ .filter((p) => p.type === "PAGE")
950
+ .map((p) => p.name);
951
+ return Promise.all(pageNames.map(n => this.projectService.getPageInfo(n))).then(pageInfos => {
952
+ // Pass 1: count pages per layout (only create layout when 2+ pages share it)
953
+ const layoutIdToPageCount = {};
954
+ const pageToLayoutId = {};
955
+ const layoutIdToScaffoldConfig = {};
956
+ pageInfos.forEach((info, idx) => {
957
+ const pageName = pageNames[idx];
958
+ const pageConfig = pageConfigs.find((p) => p.name === pageName);
959
+ if ((pageConfig === null || pageConfig === void 0 ? void 0 : pageConfig.type) !== "PAGE")
960
+ return;
961
+ const declaredLayoutId = pageConfig === null || pageConfig === void 0 ? void 0 : pageConfig.layoutId;
962
+ if (!(info === null || info === void 0 ? void 0 : info.markup))
963
+ return;
964
+ if (declaredLayoutId) {
965
+ pageToLayoutId[pageName] = declaredLayoutId;
966
+ layoutIdToPageCount[declaredLayoutId] =
967
+ (layoutIdToPageCount[declaredLayoutId] || 0) + 1;
968
+ return;
969
+ }
970
+ const layoutInfo = (0, grouping_util_1.detectLayoutInfoFromMarkup)(info.markup);
971
+ const key = (0, grouping_util_1.getLayoutKey)(layoutInfo);
972
+ if (key === "empty")
973
+ return;
974
+ if (!this.layoutKeyToIdMap.has(key)) {
975
+ const layoutId = `layout${this.layoutKeyToIdMap.size + 1}`;
976
+ this.layoutKeyToIdMap.set(key, { layoutId, config: layoutInfo });
977
+ }
978
+ const group = this.layoutKeyToIdMap.get(key);
979
+ pageToLayoutId[pageName] = group.layoutId;
980
+ layoutIdToPageCount[group.layoutId] = (layoutIdToPageCount[group.layoutId] || 0) + 1;
981
+ const transpiled = (0, transpile_1.transpileMarkup)(info.markup, this.isPrefabApp);
982
+ let scaffoldMarkup = (0, grouping_util_1.buildScaffoldMarkup)(transpiled.markup);
983
+ scaffoldMarkup = (0, grouping_util_1.stripNonLayoutRegionsFromScaffold)(scaffoldMarkup);
984
+ const layoutImports = (0, grouping_util_1.filterImportsForLayoutScaffold)(scaffoldMarkup, transpiled.imports || []);
985
+ layoutIdToScaffoldConfig[group.layoutId] = {
986
+ scaffoldMarkup,
987
+ eagerImports: layoutImports.filter((i) => !i.lazy),
988
+ lazyImports: layoutImports.filter((i) => i.lazy),
989
+ };
990
+ });
991
+ // Pass 2: only use layout for groups with 2+ pages; single-page layouts stay as plain pages
992
+ Object.entries(pageToLayoutId).forEach(([pageName, layoutId]) => {
993
+ const count = layoutIdToPageCount[layoutId] || 0;
994
+ if (count >= 2) {
995
+ this.pageLayoutMap[pageName] = layoutId;
996
+ const config = layoutIdToScaffoldConfig[layoutId];
997
+ this.ensureRouteGroupLayout(layoutId, config || {});
998
+ }
999
+ });
1000
+ // After grouping is prepared, create pages/partials
1001
+ const pageCreationPromises = pageConfigs.map(p => {
1002
+ if (p.type === "PAGE") {
1003
+ return this.generatePageComponent(p.name, isPartOfPrefab);
1004
+ }
1005
+ if (this.isPartial(p.type)) {
1006
+ return this.generatePartialComponent(p.name, true, isPartOfPrefab);
1007
+ }
1008
+ });
1009
+ return Promise.all(pageCreationPromises).then(() => undefined);
1010
+ });
1011
+ // page/partial generation handled in previous step
1012
+ return Promise.resolve();
1013
+ })
1014
+ .then(() => this.generatePageConfig(pageConfigs, isPartOfPrefab))
1015
+ .then(() => this.generatePartialConfig(pageConfigs, isPartOfPrefab));
1016
+ }
1017
+ generateEntityMetadata() {
1018
+ if (this.incBuilder) {
1019
+ console.log(`Generating Entity data.`);
1020
+ }
1021
+ const liveSources = {};
1022
+ this.liveVariables.forEach((lv) => {
1023
+ const liveSource = lv.liveSource;
1024
+ const entityName = lv.type;
1025
+ if (!liveSources[liveSource]) {
1026
+ liveSources[liveSource] = {};
1027
+ }
1028
+ const existing = liveSources[liveSource][entityName];
1029
+ const hasNewData = lv.propertiesMap != null || lv.relatedTables != null;
1030
+ const existingEmpty = !existing || (existing.propertiesMap == null && existing.relatedTables == null);
1031
+ if (!existing || (existingEmpty && hasNewData)) {
1032
+ liveSources[liveSource][entityName] = {
1033
+ propertiesMap: lv.propertiesMap,
1034
+ relatedTables: lv.relatedTables,
1035
+ };
1036
+ }
1037
+ });
1038
+ Object.keys(liveSources).forEach((liveSource) => {
1039
+ (0, utils_1.writeFile)(`${this.projectPath}/libs/metadata/entities/${liveSource}.json`, JSON.stringify(liveSources[liveSource], null, 4));
1040
+ });
1041
+ const output = ENTITY_PROVIDER_TEMPLATE({
1042
+ liveSources: Object.keys(liveSources),
1043
+ });
1044
+ (0, utils_1.writeFile)(`${this.projectPath}/libs/metadata/entities/entity-provider.js`, output);
1045
+ }
1046
+ async resolvePackage() {
1047
+ const { SCRIPT_IMPORTS, NPM_PACKAGES } = this.ResolvePrefabImports;
1048
+ if (SCRIPT_IMPORTS.length > 0) {
1049
+ const layoutPath = `${this.projectPath}/app/layout.tsx`;
1050
+ if (fs_extra_1.default.existsSync(layoutPath)) {
1051
+ const layoutContent = fs_extra_1.default.readFileSync(layoutPath, "utf-8");
1052
+ // Filter script imports to only include files that actually exist
1053
+ const validScriptImports = SCRIPT_IMPORTS.filter((script) => {
1054
+ // Skip HTTP URLs - they are external scripts
1055
+ if (script.startsWith("http")) {
1056
+ return true;
1057
+ }
1058
+ const fullPath = path_2.default.resolve(this.projectPath, `public/${script}`);
1059
+ const exists = fs_extra_1.default.existsSync(fullPath);
1060
+ if (!exists) {
1061
+ console.warn(`Script import file not found: ${fullPath}, skipping import`);
1062
+ }
1063
+ return exists;
1064
+ });
1065
+ if (validScriptImports.length > 0) {
1066
+ const scriptElements = [...new Set(validScriptImports)]
1067
+ .map(script => {
1068
+ // If script is a URL, use it as-is without prefix
1069
+ if (script.startsWith("http")) {
1070
+ return `<script src="${script}"></script>`;
1071
+ }
1072
+ // For local scripts, use JSX syntax and ensure proper path joining
1073
+ const cleanScript = script.startsWith("/") ? script.substring(1) : script;
1074
+ return `<script defer src={\`\${configs.appConfig.basePath}${cleanScript}\`}></script>`;
1075
+ })
1076
+ .join("\n");
1077
+ // Append new scripts before </head> instead of replacing
1078
+ const headCloseIndex = layoutContent.lastIndexOf("</head>");
1079
+ if (headCloseIndex !== -1) {
1080
+ const beforeHead = layoutContent.substring(0, headCloseIndex);
1081
+ const afterHead = layoutContent.substring(headCloseIndex);
1082
+ const updatedContent = `${beforeHead}
1083
+ ${scriptElements}
1084
+ ${afterHead}`;
1085
+ fs_extra_1.default.writeFileSync(layoutPath, updatedContent);
1086
+ }
1087
+ else {
1088
+ // Fallback to original method if </head> not found
1089
+ const updatedContent = layoutContent.replace(/\s*<\/head>/, `${scriptElements}\n </head>`);
1090
+ fs_extra_1.default.writeFileSync(layoutPath, updatedContent);
1091
+ }
1092
+ }
1093
+ }
1094
+ }
1095
+ if (NPM_PACKAGES.length) {
1096
+ let data = fs_extra_1.default.readFileSync(`${this.projectPath}/package.json`, "utf-8");
1097
+ const jsonData = JSON.parse(data);
1098
+ NPM_PACKAGES.forEach(script => {
1099
+ if (jsonData["dependencies"][script.match(/[\/]+(.*?)@\d/)[1]] &&
1100
+ semver_1.default.lt(jsonData["dependencies"][script.match(/[\/]+(.*?)@\d/)[1]], script.match(".*@(.*?)$")[1])) {
1101
+ console.log("adding new version " +
1102
+ script.match(".*@(.*?)$")[1] +
1103
+ "for script.match(/[\/]+(.*?)@\d/)![1] dependency");
1104
+ jsonData["dependencies"][script.match(/[\/]+(.*?)@\d/)[1]] =
1105
+ script.match(".*@(.*?)$")[1];
1106
+ }
1107
+ else {
1108
+ jsonData["dependencies"][script.match(/[\/]+(.*?)@\d/)[1]] =
1109
+ script.match(".*@(.*?)$")[1];
1110
+ }
1111
+ });
1112
+ fs_extra_1.default.writeFileSync(`${this.projectPath}/package.json`, JSON.stringify(jsonData, null, 4));
1113
+ }
1114
+ return Promise.resolve({});
1115
+ }
1116
+ async resolveProjectType() {
1117
+ this.isWaveApp = await this.projectService.getWmProjectType();
1118
+ if (!this.isWaveApp)
1119
+ return Promise.resolve({});
1120
+ // CSS override import is now handled in gen-app-override-css.ts after the file is generated
1121
+ // if it's waveApp replace the global.css file with foundation.css in the this.projectPath
1122
+ const globalCSSPath = path_2.default.resolve(this.projectPath, "app/globals.css");
1123
+ const layoutPath = path_2.default.resolve(this.projectPath, "app/layout.tsx");
1124
+ const WaveLayoutPath = path_2.default.resolve(__dirname, "../templates/foundation/layout.tsx");
1125
+ // Replace file import
1126
+ const cssContent = '@import "@wavemaker-ai/app-runtime-wm-build/wmapp/styles/foundation/foundation.css";\n';
1127
+ // Replace the first line of globals.css with cssContent
1128
+ let existingCss = fs_extra_1.default.existsSync(globalCSSPath)
1129
+ ? fs_extra_1.default.readFileSync(globalCSSPath, "utf-8").split("\n")
1130
+ : [];
1131
+ if (existingCss.length > 0) {
1132
+ existingCss[0] = cssContent.trim();
1133
+ }
1134
+ else {
1135
+ existingCss = [cssContent.trim()];
1136
+ }
1137
+ fs_extra_1.default.writeFileSync(globalCSSPath, existingCss.join("\n"), "utf-8");
1138
+ const lines = fs_extra_1.default.readFileSync(layoutPath, "utf-8").split("\n");
1139
+ // Remove the first line which is the import of global.css
1140
+ if (lines.length > 0 && lines[0].includes("globals.css")) {
1141
+ lines.splice(0, 1);
1142
+ }
1143
+ // Add the import of foundation.css after the first line
1144
+ lines.splice(0, 0, 'import "@wavemaker-ai/app-runtime-wm-build/wmapp/styles/foundation/foundation.css";');
1145
+ // Write the updated content back to layout
1146
+ fs_extra_1.default.writeFileSync(layoutPath, lines.join("\n"), "utf-8");
1147
+ // update layout
1148
+ let layoutContent = fs_extra_1.default.readFileSync(WaveLayoutPath, "utf-8");
1149
+ const isAppOverrideCssExist = await this.projectService
1150
+ .getThemesFiles(this.isWaveApp)
1151
+ .then(p => {
1152
+ if (p && fs_extra_1.default.existsSync(path_2.default.join(p, "app.override.css"))) {
1153
+ return true;
1154
+ }
1155
+ return false;
1156
+ });
1157
+ if (isAppOverrideCssExist) {
1158
+ const lines = layoutContent.split("\n");
1159
+ lines.splice(4, 0, 'import "public/design-tokens/app.override.css";');
1160
+ layoutContent = lines.join("\n");
1161
+ }
1162
+ fs_extra_1.default.writeFileSync(layoutPath, layoutContent, "utf-8");
1163
+ }
1164
+ async setSecurityConfig() {
1165
+ const securityConfig = await this.projectService.getAuthInfoFilePath();
1166
+ if (securityConfig && securityConfig.csrfConfig) {
1167
+ const envPath = `${this.projectPath}/.env`;
1168
+ (0, utils_1.updateEnvFile)(envPath, {
1169
+ NEXT_PUBLIC_XSRF_HEADER_NAME: securityConfig.csrfConfig.headerName,
1170
+ NEXT_PUBLIC_XSRF_COOKIE_NAME: securityConfig.csrfConfig.cookieName,
1171
+ });
1172
+ }
1173
+ return Promise.resolve();
1174
+ }
1175
+ generateFormatters() {
1176
+ if (this.incBuilder) {
1177
+ console.log(`Generating formatters.`);
1178
+ }
1179
+ return this.projectService.getFormatters().then(script => {
1180
+ const code = FORMATTERS_TEMPLATE({
1181
+ script: script,
1182
+ });
1183
+ return (0, utils_1.writeFile)(`${this.projectPath}/libs/extensions/formatters.js`, code);
1184
+ });
1185
+ }
1186
+ async resolvei18nAndServiceDefsSource() {
1187
+ const { i18nSource, serviceDefsSource } = await this.projectService.geti18nAndServiceDefsSource();
1188
+ this.languageBundleSource = i18nSource;
1189
+ this.serviceDefsSource = serviceDefsSource;
1190
+ return Promise.resolve();
1191
+ }
1192
+ async copyWmProjectProperties() {
1193
+ return this.projectService.getWmProjectPropertiesPath().then(sourceFile => {
1194
+ const targetDir = path_2.default.resolve(this.projectPath + "/public/services/application");
1195
+ const targetFile = path_2.default.join(targetDir, "wmProperties.js");
1196
+ // Ensure target directory exists before copying or writing
1197
+ fs_extra_1.default.mkdirSync(targetDir, { recursive: true });
1198
+ if (fs_extra_1.default.existsSync(sourceFile)) {
1199
+ fs_extra_1.default.copyFileSync(sourceFile, targetFile);
1200
+ console.log("Wm project properties copied to wmProperties.js");
1201
+ }
1202
+ else {
1203
+ fs_extra_1.default.writeFileSync(targetFile, "");
1204
+ console.log("Warning: Empty file created at wmProperties.js");
1205
+ }
1206
+ return Promise.resolve();
1207
+ });
1208
+ }
1209
+ generateApp(options) {
1210
+ this.incBuilder || fs_extra_1.default.copySync(__dirname + "/../templates/project", this.projectPath);
1211
+ return (this.generateOverrideCSS(options)
1212
+ .then(() => this.resolveProjectType())
1213
+ .then(() => this.setSecurityConfig())
1214
+ .then(() => this.generatePagesAndPartials())
1215
+ .then(() => this.generateAutoLayoutCSS())
1216
+ .then(() => this.addIndexHtmlToLayout())
1217
+ .then(() => this.resolvei18nAndServiceDefsSource())
1218
+ .then(() => this.copyServiceDefs())
1219
+ .then(() => this.copyWmProjectProperties())
1220
+ .then(() => this.incBuilder && this.generateAllPrefabComponents())
1221
+ .then(() => !this.incBuilder || this.incBuilder.isAppScriptModified())
1222
+ .then(() => !this.incBuilder || this.incBuilder.isAppStyleModified())
1223
+ .then((build) => (build && this.copyThemesFiles()))
1224
+ .then((build) => (build && this.copyFavIcon()))
1225
+ .then((build) => (build && this.copyResource()))
1226
+ .then((build) => (build && this.generateAppStyles()))
1227
+ .then(() => !this.incBuilder || this.incBuilder.isAppVariablesModified())
1228
+ .then((build) => (build && this.generateAppVariables()))
1229
+ .then(() => !this.incBuilder || this.incBuilder.isEntityModified())
1230
+ .then((build) => (build && this.generateEntityMetadata()))
1231
+ .then(() => !this.incBuilder || this.incBuilder.isFormatterModified())
1232
+ .then((build) => (build && this.generateFormatters()))
1233
+ .then(() => !this.incBuilder || this.incBuilder.isi18nModified())
1234
+ .then((build) => (build && this.copyi18nFiles()))
1235
+ .then(() => !this.incBuilder || this.incBuilder.isi18nModified())
1236
+ .then((build) => (build && this.resolvePackage()))
1237
+ .then(() => !this.incBuilder || this.incBuilder.isFontConfigModified())
1238
+ .then((build) => (build && this.generateFontConfig()))
1239
+ .then(() => {
1240
+ if (this.incBuilder) {
1241
+ const components = this.incBuilder.getWMXModifiedComponents();
1242
+ return Promise.all(components.map((c) => this.wmxGenerator.generate(c, true)));
1243
+ }
1244
+ })
1245
+ .then(() => !this.incBuilder)
1246
+ // .then(build => (build && this.prettify()) as any)
1247
+ .then(() => console.log("code generated at " + this.projectPath)));
1248
+ }
1249
+ generateFragment(name) {
1250
+ let pageConfigs = null;
1251
+ return (this.projectService
1252
+ .getPageConfigs()
1253
+ .then(_pageConfigs => {
1254
+ pageConfigs = _pageConfigs;
1255
+ const info = pageConfigs.find(config => config.name === name);
1256
+ if (info) {
1257
+ if (info.type === "PAGE") {
1258
+ return this.generatePageComponent(info.name);
1259
+ }
1260
+ if (this.isPartial(info.type)) {
1261
+ return this.generatePartialComponent(name);
1262
+ }
1263
+ }
1264
+ })
1265
+ .then(() => this.generatePageConfig(pageConfigs))
1266
+ .then(() => this.generatePartialConfig(pageConfigs))
1267
+ // .then(() => this.prettify(`**/${name}/**/*.js`))
1268
+ .then(() => console.log("code generated at " + this.projectPath)));
1269
+ }
1270
+ }
1271
+ exports.default = AppGenerator;
1272
+ //# sourceMappingURL=app.generator.js.map