@wavemaker/react-codegen 11.14.1-rc.236

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 (339) hide show
  1. package/build-react-web.js +163 -0
  2. package/build-react-web.js.map +1 -0
  3. package/command.js +121 -0
  4. package/command.js.map +1 -0
  5. package/index.js +120 -0
  6. package/index.js.map +1 -0
  7. package/package-lock.json +6260 -0
  8. package/package.json +86 -0
  9. package/src/app.generator.js +955 -0
  10. package/src/app.generator.js.map +1 -0
  11. package/src/fomatter.js +20 -0
  12. package/src/fomatter.js.map +1 -0
  13. package/src/gen-app-override-css.js +308 -0
  14. package/src/gen-app-override-css.js.map +1 -0
  15. package/src/handlebar-helpers.js +59 -0
  16. package/src/handlebar-helpers.js.map +1 -0
  17. package/src/increment-builder.js +77 -0
  18. package/src/increment-builder.js.map +1 -0
  19. package/src/profiles/profile.js +24 -0
  20. package/src/profiles/profile.js.map +1 -0
  21. package/src/profiles/web-preview.profile.js +15 -0
  22. package/src/profiles/web-preview.profile.js.map +1 -0
  23. package/src/project.service.js +251 -0
  24. package/src/project.service.js.map +1 -0
  25. package/src/transpile/bind.ex.transformer.js +174 -0
  26. package/src/transpile/bind.ex.transformer.js.map +1 -0
  27. package/src/transpile/components/advanced/carousel-template.transformer.js +16 -0
  28. package/src/transpile/components/advanced/carousel-template.transformer.js.map +1 -0
  29. package/src/transpile/components/advanced/carousel.transformer.js +55 -0
  30. package/src/transpile/components/advanced/carousel.transformer.js.map +1 -0
  31. package/src/transpile/components/advanced/login.transformer.js +26 -0
  32. package/src/transpile/components/advanced/login.transformer.js.map +1 -0
  33. package/src/transpile/components/advanced/marquee.transformer.js +16 -0
  34. package/src/transpile/components/advanced/marquee.transformer.js.map +1 -0
  35. package/src/transpile/components/basic/anchor.transformer.js +13 -0
  36. package/src/transpile/components/basic/anchor.transformer.js.map +1 -0
  37. package/src/transpile/components/basic/audio.transformer.js +16 -0
  38. package/src/transpile/components/basic/audio.transformer.js.map +1 -0
  39. package/src/transpile/components/basic/html.transformer.js +15 -0
  40. package/src/transpile/components/basic/html.transformer.js.map +1 -0
  41. package/src/transpile/components/basic/icon.transformer.js +16 -0
  42. package/src/transpile/components/basic/icon.transformer.js.map +1 -0
  43. package/src/transpile/components/basic/iframe.transformer.js +16 -0
  44. package/src/transpile/components/basic/iframe.transformer.js.map +1 -0
  45. package/src/transpile/components/basic/label.transformer.js +16 -0
  46. package/src/transpile/components/basic/label.transformer.js.map +1 -0
  47. package/src/transpile/components/basic/message.transformer.js +16 -0
  48. package/src/transpile/components/basic/message.transformer.js.map +1 -0
  49. package/src/transpile/components/basic/picture.transformer.js +22 -0
  50. package/src/transpile/components/basic/picture.transformer.js.map +1 -0
  51. package/src/transpile/components/basic/progress-bar.transformer.js +18 -0
  52. package/src/transpile/components/basic/progress-bar.transformer.js.map +1 -0
  53. package/src/transpile/components/basic/progress-circle.transformer.js +16 -0
  54. package/src/transpile/components/basic/progress-circle.transformer.js.map +1 -0
  55. package/src/transpile/components/basic/richtexteditor.transformer.js +20 -0
  56. package/src/transpile/components/basic/richtexteditor.transformer.js.map +1 -0
  57. package/src/transpile/components/basic/search.transformer.js +70 -0
  58. package/src/transpile/components/basic/search.transformer.js.map +1 -0
  59. package/src/transpile/components/basic/spinner.transformer.js +16 -0
  60. package/src/transpile/components/basic/spinner.transformer.js.map +1 -0
  61. package/src/transpile/components/basic/tree.transformer.js +16 -0
  62. package/src/transpile/components/basic/tree.transformer.js.map +1 -0
  63. package/src/transpile/components/basic/video.transformer.js +16 -0
  64. package/src/transpile/components/basic/video.transformer.js.map +1 -0
  65. package/src/transpile/components/chart/chart.transformer.js +13 -0
  66. package/src/transpile/components/chart/chart.transformer.js.map +1 -0
  67. package/src/transpile/components/container/accordion-pane.transformer.js +32 -0
  68. package/src/transpile/components/container/accordion-pane.transformer.js.map +1 -0
  69. package/src/transpile/components/container/accordion.transformer.js +49 -0
  70. package/src/transpile/components/container/accordion.transformer.js.map +1 -0
  71. package/src/transpile/components/container/container.transformer.js +27 -0
  72. package/src/transpile/components/container/container.transformer.js.map +1 -0
  73. package/src/transpile/components/container/layout-grid/grid-column.transformer.js +16 -0
  74. package/src/transpile/components/container/layout-grid/grid-column.transformer.js.map +1 -0
  75. package/src/transpile/components/container/layout-grid/grid-row.transformer.js +16 -0
  76. package/src/transpile/components/container/layout-grid/grid-row.transformer.js.map +1 -0
  77. package/src/transpile/components/container/layout-grid/grid.transformer.js +16 -0
  78. package/src/transpile/components/container/layout-grid/grid.transformer.js.map +1 -0
  79. package/src/transpile/components/container/linear-layout/linear-layout-item.js +16 -0
  80. package/src/transpile/components/container/linear-layout/linear-layout-item.js.map +1 -0
  81. package/src/transpile/components/container/linear-layout/linear-layout.js +16 -0
  82. package/src/transpile/components/container/linear-layout/linear-layout.js.map +1 -0
  83. package/src/transpile/components/container/panel-footer.transformer.js +11 -0
  84. package/src/transpile/components/container/panel-footer.transformer.js.map +1 -0
  85. package/src/transpile/components/container/panel.transformer.js +27 -0
  86. package/src/transpile/components/container/panel.transformer.js.map +1 -0
  87. package/src/transpile/components/container/repeat-template.transformer.js +12 -0
  88. package/src/transpile/components/container/repeat-template.transformer.js.map +1 -0
  89. package/src/transpile/components/container/tabheader.transformer.js +13 -0
  90. package/src/transpile/components/container/tabheader.transformer.js.map +1 -0
  91. package/src/transpile/components/container/tabpane.transformer.js +23 -0
  92. package/src/transpile/components/container/tabpane.transformer.js.map +1 -0
  93. package/src/transpile/components/container/tabs.transformer.js +96 -0
  94. package/src/transpile/components/container/tabs.transformer.js.map +1 -0
  95. package/src/transpile/components/container/tile.transformer.js +16 -0
  96. package/src/transpile/components/container/tile.transformer.js.map +1 -0
  97. package/src/transpile/components/container/wizard.transformer.js +81 -0
  98. package/src/transpile/components/container/wizard.transformer.js.map +1 -0
  99. package/src/transpile/components/container/wizardaction.transformer.js +100 -0
  100. package/src/transpile/components/container/wizardaction.transformer.js.map +1 -0
  101. package/src/transpile/components/container/wizardstep.transformer.js +90 -0
  102. package/src/transpile/components/container/wizardstep.transformer.js.map +1 -0
  103. package/src/transpile/components/data/card/card-actions.transformer.js +13 -0
  104. package/src/transpile/components/data/card/card-actions.transformer.js.map +1 -0
  105. package/src/transpile/components/data/card/card-content.transformer.js +19 -0
  106. package/src/transpile/components/data/card/card-content.transformer.js.map +1 -0
  107. package/src/transpile/components/data/card/card-footer.transformer.js +13 -0
  108. package/src/transpile/components/data/card/card-footer.transformer.js.map +1 -0
  109. package/src/transpile/components/data/card/card.transformer.js +13 -0
  110. package/src/transpile/components/data/card/card.transformer.js.map +1 -0
  111. package/src/transpile/components/data/form/dynamic-fields.transformer.js +24 -0
  112. package/src/transpile/components/data/form/dynamic-fields.transformer.js.map +1 -0
  113. package/src/transpile/components/data/form/form-action.transformer.js +87 -0
  114. package/src/transpile/components/data/form/form-action.transformer.js.map +1 -0
  115. package/src/transpile/components/data/form/form-body.transformer.js +16 -0
  116. package/src/transpile/components/data/form/form-body.transformer.js.map +1 -0
  117. package/src/transpile/components/data/form/form-field.transformer.js +379 -0
  118. package/src/transpile/components/data/form/form-field.transformer.js.map +1 -0
  119. package/src/transpile/components/data/form/form-footer.transformer.js +16 -0
  120. package/src/transpile/components/data/form/form-footer.transformer.js.map +1 -0
  121. package/src/transpile/components/data/form/form.transformer.js +131 -0
  122. package/src/transpile/components/data/form/form.transformer.js.map +1 -0
  123. package/src/transpile/components/data/form/util.js +60 -0
  124. package/src/transpile/components/data/form/util.js.map +1 -0
  125. package/src/transpile/components/data/list/list-content.transformer.js +35 -0
  126. package/src/transpile/components/data/list/list-content.transformer.js.map +1 -0
  127. package/src/transpile/components/data/list/list-template-transformer.js +13 -0
  128. package/src/transpile/components/data/list/list-template-transformer.js.map +1 -0
  129. package/src/transpile/components/data/list/list-transformer.js +181 -0
  130. package/src/transpile/components/data/list/list-transformer.js.map +1 -0
  131. package/src/transpile/components/data/live-filter-field.transformer.js +352 -0
  132. package/src/transpile/components/data/live-filter-field.transformer.js.map +1 -0
  133. package/src/transpile/components/data/livefilter.transformer.js +141 -0
  134. package/src/transpile/components/data/livefilter.transformer.js.map +1 -0
  135. package/src/transpile/components/data/liveform.transformer.js +142 -0
  136. package/src/transpile/components/data/liveform.transformer.js.map +1 -0
  137. package/src/transpile/components/data/table/live-table.transformer.js +15 -0
  138. package/src/transpile/components/data/table/live-table.transformer.js.map +1 -0
  139. package/src/transpile/components/data/table/table-action.transformer.js +25 -0
  140. package/src/transpile/components/data/table/table-action.transformer.js.map +1 -0
  141. package/src/transpile/components/data/table/table-column.transformer.js +31 -0
  142. package/src/transpile/components/data/table/table-column.transformer.js.map +1 -0
  143. package/src/transpile/components/data/table/table-row-action.transformer.js +30 -0
  144. package/src/transpile/components/data/table/table-row-action.transformer.js.map +1 -0
  145. package/src/transpile/components/data/table/table-row.transformer.js +30 -0
  146. package/src/transpile/components/data/table/table-row.transformer.js.map +1 -0
  147. package/src/transpile/components/data/table/table.transformer.js +32 -0
  148. package/src/transpile/components/data/table/table.transformer.js.map +1 -0
  149. package/src/transpile/components/data/table/utils.js +54 -0
  150. package/src/transpile/components/data/table/utils.js.map +1 -0
  151. package/src/transpile/components/dialogs/alert-dialog.transformer.js +16 -0
  152. package/src/transpile/components/dialogs/alert-dialog.transformer.js.map +1 -0
  153. package/src/transpile/components/dialogs/confirm-dialog.transformer.js +16 -0
  154. package/src/transpile/components/dialogs/confirm-dialog.transformer.js.map +1 -0
  155. package/src/transpile/components/dialogs/dialog-actions.transformer.js +38 -0
  156. package/src/transpile/components/dialogs/dialog-actions.transformer.js.map +1 -0
  157. package/src/transpile/components/dialogs/dialog-body.transformer.js +13 -0
  158. package/src/transpile/components/dialogs/dialog-body.transformer.js.map +1 -0
  159. package/src/transpile/components/dialogs/dialog.transformer.js +37 -0
  160. package/src/transpile/components/dialogs/dialog.transformer.js.map +1 -0
  161. package/src/transpile/components/dialogs/iframe-dialog.transformer.js +16 -0
  162. package/src/transpile/components/dialogs/iframe-dialog.transformer.js.map +1 -0
  163. package/src/transpile/components/dialogs/login-dialog.transformer.js +45 -0
  164. package/src/transpile/components/dialogs/login-dialog.transformer.js.map +1 -0
  165. package/src/transpile/components/dialogs/page-dialog.transformer.js +16 -0
  166. package/src/transpile/components/dialogs/page-dialog.transformer.js.map +1 -0
  167. package/src/transpile/components/element/html-transformer.js +9 -0
  168. package/src/transpile/components/element/html-transformer.js.map +1 -0
  169. package/src/transpile/components/form/button-group.transformer.js +16 -0
  170. package/src/transpile/components/form/button-group.transformer.js.map +1 -0
  171. package/src/transpile/components/form/button.transformer.js +16 -0
  172. package/src/transpile/components/form/button.transformer.js.map +1 -0
  173. package/src/transpile/components/form/rating.transformer.js +19 -0
  174. package/src/transpile/components/form/rating.transformer.js.map +1 -0
  175. package/src/transpile/components/input/calendar.transformer.js +13 -0
  176. package/src/transpile/components/input/calendar.transformer.js.map +1 -0
  177. package/src/transpile/components/input/checkbox-set.transformer.js +29 -0
  178. package/src/transpile/components/input/checkbox-set.transformer.js.map +1 -0
  179. package/src/transpile/components/input/checkbox.transformer.js +19 -0
  180. package/src/transpile/components/input/checkbox.transformer.js.map +1 -0
  181. package/src/transpile/components/input/chips.transformer.js +21 -0
  182. package/src/transpile/components/input/chips.transformer.js.map +1 -0
  183. package/src/transpile/components/input/color-picker.transformer.js +18 -0
  184. package/src/transpile/components/input/color-picker.transformer.js.map +1 -0
  185. package/src/transpile/components/input/composite.transformer.js +16 -0
  186. package/src/transpile/components/input/composite.transformer.js.map +1 -0
  187. package/src/transpile/components/input/currency.transformer.js +21 -0
  188. package/src/transpile/components/input/currency.transformer.js.map +1 -0
  189. package/src/transpile/components/input/epoch/date.transformer.js +16 -0
  190. package/src/transpile/components/input/epoch/date.transformer.js.map +1 -0
  191. package/src/transpile/components/input/epoch/datetime.transformer.js +16 -0
  192. package/src/transpile/components/input/epoch/datetime.transformer.js.map +1 -0
  193. package/src/transpile/components/input/epoch/time.transformer.js +16 -0
  194. package/src/transpile/components/input/epoch/time.transformer.js.map +1 -0
  195. package/src/transpile/components/input/file-upload.transformer.js +32 -0
  196. package/src/transpile/components/input/file-upload.transformer.js.map +1 -0
  197. package/src/transpile/components/input/number.transformer.js +20 -0
  198. package/src/transpile/components/input/number.transformer.js.map +1 -0
  199. package/src/transpile/components/input/radio-set.transformer.js +25 -0
  200. package/src/transpile/components/input/radio-set.transformer.js.map +1 -0
  201. package/src/transpile/components/input/rating.transformer.js +20 -0
  202. package/src/transpile/components/input/rating.transformer.js.map +1 -0
  203. package/src/transpile/components/input/select.transformer.js +57 -0
  204. package/src/transpile/components/input/select.transformer.js.map +1 -0
  205. package/src/transpile/components/input/slider.transformer.js +28 -0
  206. package/src/transpile/components/input/slider.transformer.js.map +1 -0
  207. package/src/transpile/components/input/switch.transformer.js +21 -0
  208. package/src/transpile/components/input/switch.transformer.js.map +1 -0
  209. package/src/transpile/components/input/text.transformer.js +19 -0
  210. package/src/transpile/components/input/text.transformer.js.map +1 -0
  211. package/src/transpile/components/input/textarea.transformer.js +19 -0
  212. package/src/transpile/components/input/textarea.transformer.js.map +1 -0
  213. package/src/transpile/components/layout/footer.transformer.js +33 -0
  214. package/src/transpile/components/layout/footer.transformer.js.map +1 -0
  215. package/src/transpile/components/layout/header.transformer.js +33 -0
  216. package/src/transpile/components/layout/header.transformer.js.map +1 -0
  217. package/src/transpile/components/layout/leftnav.transformer.js +33 -0
  218. package/src/transpile/components/layout/leftnav.transformer.js.map +1 -0
  219. package/src/transpile/components/layout/rightnav.transformer.js +33 -0
  220. package/src/transpile/components/layout/rightnav.transformer.js.map +1 -0
  221. package/src/transpile/components/layout/topnav.transformer.js +37 -0
  222. package/src/transpile/components/layout/topnav.transformer.js.map +1 -0
  223. package/src/transpile/components/nav/nav-item.transformer.js +25 -0
  224. package/src/transpile/components/nav/nav-item.transformer.js.map +1 -0
  225. package/src/transpile/components/nav/nav.transformer.js +37 -0
  226. package/src/transpile/components/nav/nav.transformer.js.map +1 -0
  227. package/src/transpile/components/nav/navbar.transformer.js +37 -0
  228. package/src/transpile/components/nav/navbar.transformer.js.map +1 -0
  229. package/src/transpile/components/navigation/breadcrumb.transformer.js +16 -0
  230. package/src/transpile/components/navigation/breadcrumb.transformer.js.map +1 -0
  231. package/src/transpile/components/navigation/menu.transformer.js +41 -0
  232. package/src/transpile/components/navigation/menu.transformer.js.map +1 -0
  233. package/src/transpile/components/navigation/popover.transformer.js +29 -0
  234. package/src/transpile/components/navigation/popover.transformer.js.map +1 -0
  235. package/src/transpile/components/page/content.transformer.js +17 -0
  236. package/src/transpile/components/page/content.transformer.js.map +1 -0
  237. package/src/transpile/components/page/page-content.transformer.js +17 -0
  238. package/src/transpile/components/page/page-content.transformer.js.map +1 -0
  239. package/src/transpile/components/page/page.transformer.js +19 -0
  240. package/src/transpile/components/page/page.transformer.js.map +1 -0
  241. package/src/transpile/components/page/partial-container.transformer.js +86 -0
  242. package/src/transpile/components/page/partial-container.transformer.js.map +1 -0
  243. package/src/transpile/components/page/partial.transformer.js +19 -0
  244. package/src/transpile/components/page/partial.transformer.js.map +1 -0
  245. package/src/transpile/components/prefab/prefab-container.transformer.js +32 -0
  246. package/src/transpile/components/prefab/prefab-container.transformer.js.map +1 -0
  247. package/src/transpile/components/prefab/prefab.transformer.js +64 -0
  248. package/src/transpile/components/prefab/prefab.transformer.js.map +1 -0
  249. package/src/transpile/components/transform-register.js +238 -0
  250. package/src/transpile/components/transform-register.js.map +1 -0
  251. package/src/transpile/components/utils.js +171 -0
  252. package/src/transpile/components/utils.js.map +1 -0
  253. package/src/transpile/id-generator.js +87 -0
  254. package/src/transpile/id-generator.js.map +1 -0
  255. package/src/transpile/property/base-parser.js +13 -0
  256. package/src/transpile/property/base-parser.js.map +1 -0
  257. package/src/transpile/property/property-parser.js +264 -0
  258. package/src/transpile/property/property-parser.js.map +1 -0
  259. package/src/transpile/property/show-in-device.parser.js +17 -0
  260. package/src/transpile/property/show-in-device.parser.js.map +1 -0
  261. package/src/transpile/style/background-image.parser.js +20 -0
  262. package/src/transpile/style/background-image.parser.js.map +1 -0
  263. package/src/transpile/style/border-width.parser.js +20 -0
  264. package/src/transpile/style/border-width.parser.js.map +1 -0
  265. package/src/transpile/style/dimension-style.parser.js +57 -0
  266. package/src/transpile/style/dimension-style.parser.js.map +1 -0
  267. package/src/transpile/style/horizontal-align.parser.js +24 -0
  268. package/src/transpile/style/horizontal-align.parser.js.map +1 -0
  269. package/src/transpile/style/margin.parser.js +20 -0
  270. package/src/transpile/style/margin.parser.js.map +1 -0
  271. package/src/transpile/style/multi-dimension-style.parser.js +29 -0
  272. package/src/transpile/style/multi-dimension-style.parser.js.map +1 -0
  273. package/src/transpile/style/numeric-style.parser.js +18 -0
  274. package/src/transpile/style/numeric-style.parser.js.map +1 -0
  275. package/src/transpile/style/padding.parser.js +20 -0
  276. package/src/transpile/style/padding.parser.js.map +1 -0
  277. package/src/transpile/style/style.parser.js +15 -0
  278. package/src/transpile/style/style.parser.js.map +1 -0
  279. package/src/transpile/style.transformer.js +118 -0
  280. package/src/transpile/style.transformer.js.map +1 -0
  281. package/src/transpile/transpile.js +609 -0
  282. package/src/transpile/transpile.js.map +1 -0
  283. package/src/utils.js +418 -0
  284. package/src/utils.js.map +1 -0
  285. package/src/variables/variable.transformer.js +299 -0
  286. package/src/variables/variable.transformer.js.map +1 -0
  287. package/templates/.DS_Store +0 -0
  288. package/templates/app.style.template +3 -0
  289. package/templates/app.variables.template +1 -0
  290. package/templates/build-info/error.html +31 -0
  291. package/templates/build-info/index.html +94 -0
  292. package/templates/build-info/info.html +120 -0
  293. package/templates/component/app.libs.hbs +21 -0
  294. package/templates/component/app.script.hbs +9 -0
  295. package/templates/component/app.template.hbs +46 -0
  296. package/templates/component/component-old.hbs +29 -0
  297. package/templates/component/component.hbs +82 -0
  298. package/templates/component/component.props.template +1 -0
  299. package/templates/component/formatter.hbs +8 -0
  300. package/templates/component/page.hbs +13 -0
  301. package/templates/component/partial.hbs +73 -0
  302. package/templates/component/script.template +6 -0
  303. package/templates/component/style-def.template +18 -0
  304. package/templates/component/style.template +1 -0
  305. package/templates/entity-provider.template +21 -0
  306. package/templates/foundation/layout.tsx +30 -0
  307. package/templates/pages-config.template +12 -0
  308. package/templates/partial-config.template +58 -0
  309. package/templates/project/.DS_Store +0 -0
  310. package/templates/project/.env +1 -0
  311. package/templates/project/.gitignore +2 -0
  312. package/templates/project/.npmrc +5 -0
  313. package/templates/project/.prettierrc +8 -0
  314. package/templates/project/README.md +60 -0
  315. package/templates/project/app/client.layout.tsx +182 -0
  316. package/templates/project/app/components.css +121 -0
  317. package/templates/project/app/error.tsx +27 -0
  318. package/templates/project/app/globals.css +105 -0
  319. package/templates/project/app/layout.tsx +40 -0
  320. package/templates/project/app/loading.tsx +6 -0
  321. package/templates/project/app/page.tsx +3 -0
  322. package/templates/project/libs/appConfig.ts +14 -0
  323. package/templates/project/next-env.d.ts +5 -0
  324. package/templates/project/next.config.ts +17 -0
  325. package/templates/project/package-lock.json +5397 -0
  326. package/templates/project/package.json +31 -0
  327. package/templates/project/public/error-fallback.svg +89 -0
  328. package/templates/project/public/file.svg +1 -0
  329. package/templates/project/public/globe.svg +1 -0
  330. package/templates/project/public/next.svg +1 -0
  331. package/templates/project/public/vercel.svg +1 -0
  332. package/templates/project/public/window.svg +1 -0
  333. package/templates/project/scripts/app-custom-server.js +44 -0
  334. package/templates/project/scripts/getlibs.js +53 -0
  335. package/templates/project/tsconfig.json +35 -0
  336. package/templates/project/types/runtime-config.d.ts +9 -0
  337. package/templates/resource.resolver.template +20 -0
  338. package/templates/service.defs.template +3 -0
  339. package/templates/variables.template +233 -0
@@ -0,0 +1,955 @@
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 variable_transformer_1 = __importDefault(require("./variables/variable.transformer"));
47
+ const utils_1 = require("./utils");
48
+ const bind_ex_transformer_1 = __importDefault(require("./transpile/bind.ex.transformer"));
49
+ const profile_1 = __importDefault(require("./profiles/profile"));
50
+ const utils_2 = require("./utils");
51
+ const gen_app_override_css_1 = require("./gen-app-override-css");
52
+ const COMPONENT_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + "/../templates/component/component.hbs");
53
+ const COMPONENT_PAGE_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + "/../templates/component/page.hbs");
54
+ const PARTIAL_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + "/../templates/component/partial.hbs");
55
+ const COMPONENT_PROPS_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + "/../templates/component/component.props.template");
56
+ const SCRIPT_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + "/../templates/component/script.template");
57
+ const PAGE_CONFIG_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + "/../templates/pages-config.template");
58
+ const PARTIAL_CONFIG_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + "/../templates/partial-config.template");
59
+ const VARIABLE_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + "/../templates/variables.template");
60
+ const ENTITY_PROVIDER_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + "/../templates/entity-provider.template");
61
+ const APP_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + "/../templates/component/app.template.hbs");
62
+ const APP_SCRIPT_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + "/../templates/component/app.script.hbs");
63
+ const FORMATTERS_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + "/../templates/component/formatter.hbs");
64
+ const APP_LIBS_TEMPLATE = (0, utils_1.loadTemplate)(__dirname + "/../templates/component/app.libs.hbs");
65
+ const ALL_GENERATED_FILES = "(src/**/*.js|App.js|app.style.js|bootstrap.js|app/**/*.js|wm-project-properties.ts)";
66
+ // REF: https://github.com/facebook/metro/blob/master/packages/metro-config/src/defaults/defaults.js#L14-L44
67
+ const ALLOWED_RESOURCE_EXT = [
68
+ // Image formats
69
+ "bmp",
70
+ "gif",
71
+ "jpg",
72
+ "jpeg",
73
+ "png",
74
+ "psd",
75
+ "svg",
76
+ "webp",
77
+ // Video formats
78
+ "m4v",
79
+ "mov",
80
+ "mp4",
81
+ "mpeg",
82
+ "mpg",
83
+ "webm",
84
+ // Audio formats
85
+ "aac",
86
+ "aiff",
87
+ "caf",
88
+ "m4a",
89
+ "mp3",
90
+ "wav",
91
+ // Document formats
92
+ "html",
93
+ "pdf",
94
+ "yaml",
95
+ "yml",
96
+ "json",
97
+ // Font formats
98
+ "otf",
99
+ "ttf",
100
+ // Archives (virtual files)
101
+ "zip",
102
+ "js",
103
+ ];
104
+ let deviceVariables = [];
105
+ let appVersion;
106
+ class AppGenerator {
107
+ constructor(projectPath, projectService, appUrl, prefabName = "", incBuilder, options, dynamicPrefabProps) {
108
+ this.projectPath = projectPath;
109
+ this.projectService = projectService;
110
+ this.appUrl = appUrl;
111
+ this.prefabName = prefabName;
112
+ this.incBuilder = incBuilder;
113
+ this.options = options;
114
+ this.dynamicPrefabProps = dynamicPrefabProps;
115
+ this.transpiledComponents = {
116
+ pages: {},
117
+ partials: {},
118
+ prefabs: {},
119
+ };
120
+ this.liveVariables = [];
121
+ this.isPrefabApp = false;
122
+ this.ResolvePrefabImports = {
123
+ SCRIPT_IMPORTS: [],
124
+ NPM_PACKAGES: [],
125
+ };
126
+ this.isWaveApp = false;
127
+ this.options = options;
128
+ this.isPrefabApp = !!prefabName;
129
+ this.dynamicPrefabProps = dynamicPrefabProps;
130
+ }
131
+ prepareVariables(variableJSON, scope, imports) {
132
+ const variables = Object.values(variableJSON)
133
+ .map((v) => (0, variable_transformer_1.default)(v, scope, this.appUrl, imports))
134
+ .filter(v => !!v);
135
+ const item = VARIABLE_TEMPLATE({
136
+ scope: scope,
137
+ imports: imports,
138
+ addEntityProvider: !this.isPrefabApp && scope !== "App",
139
+ isPrefabApp: this.isPrefabApp,
140
+ prefabName: this.prefabName,
141
+ context: {
142
+ Variables: variables.filter(v => v.group === "variable"),
143
+ Actions: variables.filter(v => v.group === "action"),
144
+ },
145
+ });
146
+ return item;
147
+ }
148
+ isPartial(type) {
149
+ return (type === "PARTIAL" ||
150
+ type === "LEFTNAV" ||
151
+ type === "POPOVER" ||
152
+ type === "TEMPLATE" ||
153
+ type === "HEADER" ||
154
+ type === "FOOTER" ||
155
+ type === "TOPNAV" ||
156
+ type === "RIGHTNAV");
157
+ }
158
+ resolvePrefabDynamicProps(markup, dynamicPrefabProps) {
159
+ Object.entries(dynamicPrefabProps).forEach(([key, value]) => {
160
+ if (value.startsWith("fragment.") &&
161
+ (markup.includes(`fragment.${key}`) || markup.includes(`fragment?.${key}`))) {
162
+ value = (0, utils_2.addOptionalChaining)(value);
163
+ markup = markup.replace(new RegExp(`fragment\\??\\.${key}`, "g"), value);
164
+ }
165
+ });
166
+ return markup;
167
+ }
168
+ prettify(target = ALL_GENERATED_FILES) {
169
+ let prettierPath = null;
170
+ let d = __dirname;
171
+ while (d) {
172
+ prettierPath = d + path_1.sep + "node_modules" + path_1.sep + "prettier";
173
+ if (fs_extra_1.default.existsSync(prettierPath)) {
174
+ break;
175
+ }
176
+ const s = d.split(path_1.sep);
177
+ s.pop();
178
+ d = s.join(path_1.sep);
179
+ }
180
+ if (d) {
181
+ const targetPath = target === ALL_GENERATED_FILES
182
+ ? `${this.projectPath}/**/*.{ts,tsx,js,jsx,json,css,md}`
183
+ : `${this.projectPath}/${target}`;
184
+ return (0, execa_1.default)("node", [`${prettierPath}${path_1.sep}bin/prettier.cjs`, "--write", targetPath]);
185
+ }
186
+ console.warn("Prettier is not found");
187
+ return Promise.reject();
188
+ }
189
+ setDeviceVariables(variables) {
190
+ variables = Object.values(variables);
191
+ const filterOutput = variables.filter((v) => v.category === "wm.DeviceVariable");
192
+ deviceVariables = deviceVariables.concat(filterOutput);
193
+ }
194
+ generateAppVariables() {
195
+ if (this.incBuilder) {
196
+ console.log(`Generating App variables.`);
197
+ }
198
+ return this.projectService.getAppVariables().then(variables => {
199
+ this.setDeviceVariables(variables);
200
+ Object.keys(variables).map((key) => {
201
+ // @ts-ignore
202
+ if (variables[key]["category"] === "wm.LiveVariable") {
203
+ // @ts-ignore
204
+ this.liveVariables.push(variables[key]);
205
+ }
206
+ });
207
+ const output = this.prepareVariables(variables, "App", []);
208
+ (0, utils_1.writeFile)(`${this.projectPath}/app/app.variables.ts`, output);
209
+ // include _app.tsx file in root folder
210
+ this.generateAppConfig(variables);
211
+ // include _app.script.js file in root folder
212
+ this.generateAppScript();
213
+ });
214
+ }
215
+ async generateAppScript() {
216
+ const script = await this.projectService.getAppScript();
217
+ // Check if there are any default prefabs in the project
218
+ const prefabs = await this.projectService.getPrefabs();
219
+ const hasDefaultPrefabs = prefabs.some((prefab) => ["youtube", "googlemaps", "qrcode"].includes(prefab.toLowerCase()));
220
+ const appScript = APP_SCRIPT_TEMPLATE({
221
+ script: script,
222
+ hasDefaultPrefabs: hasDefaultPrefabs,
223
+ });
224
+ (0, utils_1.writeFile)(`${this.projectPath}/app/app.script.js`, appScript);
225
+ // Generate app.libs.js if there are default prefabs
226
+ if (hasDefaultPrefabs) {
227
+ const appLibs = APP_LIBS_TEMPLATE({
228
+ hasDefaultPrefabs: hasDefaultPrefabs,
229
+ });
230
+ (0, utils_1.writeFile)(`${this.projectPath}/app/app.libs.js`, appLibs);
231
+ }
232
+ }
233
+ async generateAppConfig(variables) {
234
+ // create _app file and populate data
235
+ const App = APP_TEMPLATE({
236
+ startUpVariables: Object.values(variables)
237
+ .filter((v) => v.startUpdate && v.category !== "wm.TimerVariable")
238
+ .map((v) => v.name),
239
+ startUpActions: Object.values(variables)
240
+ .filter((v) => v.startUpdate && v.category === "wm.TimerVariable")
241
+ .map((v) => v.name),
242
+ autoUpdateVariables: Object.values(variables)
243
+ .filter((v) => v.autoUpdate ||
244
+ ((v.category === "wm.Variable" || v.category === "wm.LiveVariable") &&
245
+ v.dataBinding &&
246
+ v.dataBinding.length))
247
+ .map((v) => v.name),
248
+ });
249
+ (0, utils_1.writeFile)(`${this.projectPath}/app/_app.tsx`, App);
250
+ }
251
+ getBasePath() {
252
+ var _a, _b;
253
+ // First check if appBasePath is provided via command line
254
+ if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.appBasePath) {
255
+ if (!((_b = this.options) === null || _b === void 0 ? void 0 : _b.isServerPath)) {
256
+ (0, utils_1.updateEnvFile)(this.projectPath, { NEXT_PUBLIC_BASE_PATH: this.options.appBasePath });
257
+ }
258
+ return this.options.appBasePath;
259
+ }
260
+ return "";
261
+ }
262
+ generatePageConfig(pageConfigs, isPartOfPrefab) {
263
+ pageConfigs = pageConfigs.filter((p) => p.type == "PAGE");
264
+ const output = PAGE_CONFIG_TEMPLATE({
265
+ pageConfigs: pageConfigs,
266
+ pageConfigsStr: JSON.stringify(pageConfigs),
267
+ lazyload: profile_1.default.lazyloadPages,
268
+ });
269
+ let path = isPartOfPrefab
270
+ ? `${this.projectPath}/pages-config.ts`
271
+ : `${this.projectPath}/app/pages-config.ts`;
272
+ (0, utils_1.writeFile)(path, output);
273
+ }
274
+ generatePartialConfig(pageConfigs, isPartOfPrefab) {
275
+ pageConfigs = pageConfigs.filter((p) => this.isPartial(p.type));
276
+ const output = PARTIAL_CONFIG_TEMPLATE({
277
+ pageConfigs: pageConfigs,
278
+ pageConfigsStr: JSON.stringify(pageConfigs),
279
+ lazyload: profile_1.default.lazyloadPartials,
280
+ });
281
+ let path = isPartOfPrefab
282
+ ? `${this.projectPath}/components/partial-config.ts`
283
+ : `${this.projectPath}/app/components/partial-config.ts`;
284
+ (0, utils_1.writeFile)(path, output);
285
+ }
286
+ extractRefsFromMarkup(markup) {
287
+ const refs = [];
288
+ const regex = /<\w+[^>]*\bname=["']([^"']+)["']/g; // Match any component with a `name` property
289
+ let match;
290
+ while ((match = regex.exec(markup)) !== null) {
291
+ refs.push(match[1]); // Extract the name
292
+ }
293
+ return refs;
294
+ }
295
+ generateComponent(info, type, name, isPartOfPrefab) {
296
+ if (this.incBuilder && !this.incBuilder.isFragmentModified(name)) {
297
+ return Promise.resolve();
298
+ }
299
+ if (this.incBuilder) {
300
+ console.log(`Generating ${name} component.`);
301
+ }
302
+ const lType = type.toLowerCase();
303
+ const typeLabel = (0, lodash_1.capitalize)(type);
304
+ let variables = {};
305
+ try {
306
+ variables = info.variables ? JSON.parse(info.variables) : {};
307
+ }
308
+ catch (_a) {
309
+ console.log(`Error parsing variables for ${name}, skipping variables.`);
310
+ variables = {};
311
+ }
312
+ Object.keys(variables).map(key => {
313
+ if (variables[key]["category"] === "wm.LiveVariable") {
314
+ this.liveVariables.push(variables[key]);
315
+ }
316
+ });
317
+ this.setDeviceVariables(variables);
318
+ // let dest = type === 'PREFAB' ? `${this.projectPath}/app/${name}` : `${this.projectPath}/app/${name}`;
319
+ let dest = "";
320
+ if (type === "PREFAB") {
321
+ dest = `${this.projectPath}/${name}`;
322
+ }
323
+ else if (type === "PAGE") {
324
+ dest = `${this.projectPath}/app/react-pages/${name}`;
325
+ }
326
+ else {
327
+ dest = isPartOfPrefab
328
+ ? `${this.projectPath}/components/${name}`
329
+ : `${this.projectPath}/app/components/${name}`;
330
+ }
331
+ try {
332
+ const output = this.prepareVariables(variables, typeLabel, []);
333
+ (0, utils_1.writeFile)(`${dest}/${name}.variables.ts`, output);
334
+ const transpiledOutput = (0, transpile_1.transpileMarkup)(info.markup, this.isPrefabApp);
335
+ const imports = (0, lodash_1.sortBy)((0, lodash_1.uniqBy)(transpiledOutput.imports, i => i.name + i.from), i => i.name);
336
+ const _markup = "\n" + transpiledOutput.markup;
337
+ const dynamicRefs = this.extractRefsFromMarkup(_markup);
338
+ const TEMPLATE_TYPE = this.isPartial(type) ? PARTIAL_TEMPLATE : COMPONENT_TEMPLATE;
339
+ if (this.dynamicPrefabProps && Object.keys(this.dynamicPrefabProps).length > 0) {
340
+ transpiledOutput.markup = this.resolvePrefabDynamicProps(transpiledOutput.markup, this.dynamicPrefabProps);
341
+ }
342
+ const component = TEMPLATE_TYPE({
343
+ name: name,
344
+ componentName: name.charAt(0).toUpperCase() + name.substring(1),
345
+ type: type,
346
+ lType: lType,
347
+ typeLabel: typeLabel,
348
+ prefabName: this.prefabName,
349
+ markup: "\n" + (0, utils_1.fixURLPath)(transpiledOutput.markup, this.getBasePath()),
350
+ components: transpiledOutput.components,
351
+ startUpVariables: Object.values(variables)
352
+ .filter((v) => v.startUpdate && v.category !== "wm.TimerVariable")
353
+ .map((v) => v.name),
354
+ startUpActions: Object.values(variables)
355
+ .filter((v) => v.startUpdate && v.category === "wm.TimerVariable")
356
+ .map((v) => v.name),
357
+ autoUpdateVariables: Object.values(variables)
358
+ .filter((v) => v.autoUpdate ||
359
+ ((v.category === "wm.Variable" || v.category === "wm.LiveVariable") &&
360
+ v.dataBinding &&
361
+ v.dataBinding.length))
362
+ .map((v) => v.name),
363
+ eagerImports: imports.filter(i => !i.lazy),
364
+ lazyImports: imports.filter(i => i.lazy),
365
+ dynamicRefs,
366
+ });
367
+ if (type === "PAGE") {
368
+ const componentPage = COMPONENT_PAGE_TEMPLATE({
369
+ name: name,
370
+ type: type,
371
+ lType: lType,
372
+ componentName: name.charAt(0).toUpperCase() + name.substring(1),
373
+ typeLabel: typeLabel,
374
+ dynamicPrefabProps: this.dynamicPrefabProps || {},
375
+ prefabName: this.prefabName,
376
+ markup: "\n" + (0, utils_1.fixURLPath)(transpiledOutput.markup, this.getBasePath()),
377
+ components: transpiledOutput.components,
378
+ startUpVariables: Object.values(variables)
379
+ .filter((v) => v.startUpdate && v.category !== "wm.TimerVariable")
380
+ .map((v) => v.name),
381
+ startUpActions: Object.values(variables)
382
+ .filter((v) => v.startUpdate && v.category === "wm.TimerVariable")
383
+ .map((v) => v.name),
384
+ autoUpdateVariables: Object.values(variables)
385
+ .filter((v) => v.autoUpdate ||
386
+ ((v.category === "wm.Variable" || v.category === "wm.LiveVariable") &&
387
+ v.dataBinding &&
388
+ v.dataBinding.length))
389
+ .map((v) => v.name),
390
+ eagerImports: imports.filter(i => !i.lazy),
391
+ lazyImports: imports.filter(i => i.lazy),
392
+ });
393
+ (0, utils_1.writeFile)(`${dest}/${name}.component.tsx`, component);
394
+ (0, utils_1.writeFile)(`${dest}/page.tsx`, componentPage);
395
+ }
396
+ else {
397
+ (0, utils_1.writeFile)(`${dest}/${name}.tsx`, component);
398
+ }
399
+ const script = SCRIPT_TEMPLATE({
400
+ typeLabel: typeLabel,
401
+ script: info.script,
402
+ });
403
+ (0, utils_1.writeFile)(`${dest}/${name}.script.js`, script);
404
+ const updatedCss = (0, utils_1.fixURLPathAndScope)(info.styles, this.getBasePath(), true);
405
+ (0, utils_1.writeFile)(`${dest}/${name}.css`, updatedCss);
406
+ return Promise.all(transpiledOutput.prefabs.map(p => this.generatePrefabComponent(p, false)));
407
+ }
408
+ catch (e) {
409
+ console.log(`failed to generate component ${dest}/${name}`);
410
+ throw e;
411
+ }
412
+ }
413
+ generatePrefabProps(name, projectPath) {
414
+ const dynamicProps = {};
415
+ return this.projectService.getPrefabInfo(name).then(info => {
416
+ const propConfig = {};
417
+ Object.keys(info.config.properties).map((k) => {
418
+ let value = info.config.properties[k].value;
419
+ const type = info.config.properties[k].type;
420
+ if (type === "number") {
421
+ value = Number(value);
422
+ }
423
+ if (type === "boolean") {
424
+ value = Boolean(value);
425
+ }
426
+ if ((0, lodash_1.isString)(value) && value.startsWith("bind:")) {
427
+ let exStr = decodeURIComponent(value.substring(5));
428
+ dynamicProps[k] = `${(0, bind_ex_transformer_1.default)(exStr, "fragment", "attr")}`;
429
+ propConfig[k] = null;
430
+ }
431
+ else {
432
+ propConfig[k] = value === undefined ? null : value;
433
+ }
434
+ });
435
+ let propsStr = JSON.stringify(propConfig);
436
+ if (info.config.events) {
437
+ propsStr = propsStr.replace(/\}$/, "");
438
+ Object.keys(info.config.events).map((k) => {
439
+ propsStr += `${propsStr.length === 1 ? "" : ","} ${k} : () => {}`;
440
+ });
441
+ propsStr += "}";
442
+ }
443
+ const props = COMPONENT_PROPS_TEMPLATE({
444
+ props: propsStr,
445
+ });
446
+ (0, utils_1.writeFile)(`${projectPath}/app/prefabs/${name}/Main/Main.props.js`, props);
447
+ return dynamicProps;
448
+ });
449
+ }
450
+ generatePrefabComponent(name, overwrite = true) {
451
+ var _a;
452
+ if ((!overwrite && this.transpiledComponents.prefabs[name]) ||
453
+ (this.incBuilder && !((_a = this.incBuilder) === null || _a === void 0 ? void 0 : _a.isPrefabModified(name)))) {
454
+ return Promise.resolve();
455
+ }
456
+ if (this.incBuilder) {
457
+ console.log(`Generating ${name} prefab component.`);
458
+ }
459
+ const projectPath = this.isPrefabApp
460
+ ? this.projectPath.split("/app/prefabs/")[0]
461
+ : this.projectPath;
462
+ const appUrl = this.isPrefabApp ? this.appUrl.split("/app/prefabs/")[0] : this.appUrl;
463
+ this.transpiledComponents.prefabs[name] = true;
464
+ return this.generatePrefabProps(name, projectPath).then(dynamicPrefabProps => {
465
+ const prefabGenerator = new AppGenerator(`${projectPath}/app/prefabs/${name}`, this.projectService.getPrefabProjectService(name), `${appUrl}/app/prefabs/${name}`, name, undefined, undefined, dynamicPrefabProps);
466
+ return prefabGenerator
467
+ .generatePagesAndPartials(true)
468
+ .then(() => this.copyPrefabResources(projectPath, name));
469
+ });
470
+ }
471
+ copyPrefabResources(projectPath, prefabName) {
472
+ if (!projectPath || !prefabName)
473
+ return;
474
+ return this.projectService.getPrefabResources(prefabName).then(p => {
475
+ if (p) {
476
+ const dest = `${projectPath}/public/${prefabName}/resources`;
477
+ fs_extra_1.default.copySync(p, dest);
478
+ }
479
+ this.resolvePrefabImports(prefabName).then(res => {
480
+ if (res.CSS_IMPORTS.length) {
481
+ // Filter imports to only include files that actually exist
482
+ const validImports = res.CSS_IMPORTS.filter((importPath) => {
483
+ const fullPath = path_2.default.resolve(projectPath, importPath);
484
+ const exists = fs_extra_1.default.existsSync(fullPath);
485
+ if (!exists) {
486
+ console.warn(`CSS import file not found: ${fullPath}, skipping import`);
487
+ }
488
+ return exists;
489
+ });
490
+ if (validImports.length > 0) {
491
+ const imports = validImports.map((i) => `import "${i}";`).join("\n");
492
+ const mainFilePath = `${projectPath}/app/prefabs/${prefabName}/Main/Main.tsx`;
493
+ if (fs_extra_1.default.existsSync(mainFilePath)) {
494
+ const mainContent = fs_extra_1.default.readFileSync(mainFilePath, "utf-8");
495
+ // Find the first line and insert imports after it
496
+ const lines = mainContent.split("\n");
497
+ const updatedContent = `${lines[0]}\n${imports}\n${lines.slice(1).join("\n")}`;
498
+ fs_extra_1.default.writeFileSync(mainFilePath, updatedContent);
499
+ }
500
+ }
501
+ }
502
+ });
503
+ return Promise.resolve({});
504
+ });
505
+ }
506
+ resolvePrefabImports(name) {
507
+ return this.projectService.getPrefabInfo(name).then(info => {
508
+ var _a;
509
+ const NPM_PACKAGES = [];
510
+ const CSS_IMPORTS = [];
511
+ info.config.resources.styles.forEach((item) => {
512
+ if (!item.endsWith("Main.css")) {
513
+ CSS_IMPORTS.push(`public/${name}${item}`);
514
+ }
515
+ }) || [];
516
+ const SCRIPT_IMPORTS = info.config.resources.scripts.map((item) => {
517
+ if (item.startsWith("npm://")) {
518
+ NPM_PACKAGES.push(item.replace("npm://", ""));
519
+ }
520
+ else if (item.startsWith("http")) {
521
+ return item;
522
+ }
523
+ else {
524
+ return `/${name}${item}`;
525
+ }
526
+ });
527
+ this.ResolvePrefabImports = {
528
+ SCRIPT_IMPORTS: [...(_a = this.ResolvePrefabImports) === null || _a === void 0 ? void 0 : _a.SCRIPT_IMPORTS, ...SCRIPT_IMPORTS],
529
+ NPM_PACKAGES: [...this.ResolvePrefabImports.NPM_PACKAGES, ...NPM_PACKAGES],
530
+ };
531
+ return Promise.resolve({
532
+ CSS_IMPORTS: CSS_IMPORTS || [],
533
+ });
534
+ });
535
+ }
536
+ generateAllPrefabComponents(overwrite) {
537
+ return this.projectService.getPrefabs().then(prefabs => {
538
+ return Promise.all(prefabs === null || prefabs === void 0 ? void 0 : prefabs.map(prefab => this.generatePrefabComponent(prefab, overwrite)));
539
+ });
540
+ }
541
+ generatePageComponent(name, overwrite = true, isPartOfPrefab) {
542
+ if (!overwrite && this.transpiledComponents.pages[name]) {
543
+ return Promise.resolve();
544
+ }
545
+ this.transpiledComponents.pages[name] = true;
546
+ return this.projectService.getPageInfo(name).then(info => {
547
+ if (!info) {
548
+ console.log(`Page ${name} not found, skipping.`);
549
+ return Promise.resolve();
550
+ }
551
+ return this.generateComponent(info, this.isPrefabApp ? "PREFAB" : "PAGE", name, isPartOfPrefab);
552
+ });
553
+ }
554
+ generatePartialComponent(name, overwrite = true, isPartOfPrefab) {
555
+ if (!overwrite && this.transpiledComponents.partials[name]) {
556
+ return Promise.resolve();
557
+ }
558
+ this.transpiledComponents.partials[name] = true;
559
+ return this.projectService.getPageInfo(name).then(info => {
560
+ if (!info) {
561
+ console.log(`Partial ${name} not found, skipping.`);
562
+ return Promise.resolve();
563
+ }
564
+ return this.generateComponent(info, "PARTIAL", name, isPartOfPrefab);
565
+ });
566
+ }
567
+ generateAppStyles() {
568
+ if (this.incBuilder) {
569
+ console.log(`Generating app.styles.css .`);
570
+ }
571
+ return this.projectService.getAppCss().then(response => {
572
+ const basePath = this.getBasePath();
573
+ const updatedCss = (0, utils_1.fixURLPath)(response, basePath, true);
574
+ (0, utils_1.writeFile)(`${this.projectPath}/app/app.css`, updatedCss);
575
+ });
576
+ }
577
+ getAllResources(filter = (str) => true, dirPath = this.projectPath + "/assets/resources", pathPrefix = "resources", arrayOfFiles = []) {
578
+ if (fs_extra_1.default.existsSync(dirPath)) {
579
+ fs_extra_1.default.readdirSync(dirPath).forEach(file => {
580
+ if (fs_extra_1.default.statSync(dirPath + "/" + file).isDirectory()) {
581
+ arrayOfFiles = this.getAllResources(filter, dirPath + "/" + file, pathPrefix + "/" + file, arrayOfFiles);
582
+ }
583
+ else if (filter(dirPath + "/" + file)) {
584
+ const ext = (0, lodash_1.last)(file.split("."));
585
+ if (file.indexOf("@") < 0 && ALLOWED_RESOURCE_EXT.indexOf(ext || "") >= 0) {
586
+ arrayOfFiles.push(pathPrefix + "/" + file);
587
+ }
588
+ }
589
+ });
590
+ }
591
+ return arrayOfFiles;
592
+ }
593
+ copyi18nFiles() {
594
+ if (profile_1.default.useLocalMetadata) {
595
+ if (this.incBuilder) {
596
+ console.log(`Copying i18n files.`);
597
+ }
598
+ return this.projectService.geti18NFiles().then(p => {
599
+ if (p) {
600
+ fs_extra_1.default.copySync(p, this.projectPath + "/public/resources/i18n");
601
+ }
602
+ });
603
+ }
604
+ return Promise.resolve();
605
+ }
606
+ copyThemesFiles() {
607
+ return this.projectService
608
+ .getThemesFiles()
609
+ .then(p => {
610
+ try {
611
+ if (p && this.isWaveApp) {
612
+ fs_extra_1.default.copySync(p, this.projectPath + "/public/design-tokens");
613
+ }
614
+ else if (p) {
615
+ fs_extra_1.default.copySync(p, this.projectPath + "/public/themes");
616
+ }
617
+ return Promise.resolve({});
618
+ }
619
+ catch (error) {
620
+ console.warn("Warning: Failed to copy theme files:", error);
621
+ return Promise.resolve({});
622
+ }
623
+ })
624
+ .catch(error => {
625
+ console.warn("Warning: Failed to get theme files:", error === null || error === void 0 ? void 0 : error.message);
626
+ return Promise.resolve({});
627
+ });
628
+ }
629
+ copyFavIcon() {
630
+ return this.projectService.getFavIcon().then(p => {
631
+ if (p && fs_extra_1.default.existsSync(p)) {
632
+ const dest = `${this.projectPath}/public/favicon.png`;
633
+ fs_extra_1.default.copySync(p, dest);
634
+ }
635
+ return Promise.resolve({});
636
+ });
637
+ }
638
+ async generateOverrideCSS() {
639
+ var _a;
640
+ // this.projectPath is the generated React app directory (e.g., temp/App)
641
+ // We need to pass the source project root from projectService
642
+ const sourceProjectPath = this.projectService.path;
643
+ // Get project root directory (parent of src/main/webapp or WEB-INF)
644
+ const projectRoot = sourceProjectPath.replace(/[\/\\](src[\/\\]main[\/\\]webapp|WEB-INF).*$/, "");
645
+ await (0, gen_app_override_css_1.generateOverrideCSS)(((_a = this.options) === null || _a === void 0 ? void 0 : _a.runtimeUIVersion) || "latest", projectRoot, this.projectPath);
646
+ return Promise.resolve();
647
+ }
648
+ async generateFontConfig() {
649
+ if (this.incBuilder) {
650
+ console.log("Generating Font config.");
651
+ }
652
+ try {
653
+ const code = await this.projectService.getFontConfig();
654
+ await (0, utils_1.writeFile)(`${this.projectPath}/app/font.config.ts`, code);
655
+ this.IncludeScriptImports();
656
+ }
657
+ catch (e) {
658
+ console.log("Error generating font.config.js", e);
659
+ }
660
+ }
661
+ async IncludeScriptImports() {
662
+ try {
663
+ const layoutContent = fs_extra_1.default.readFileSync(`${this.projectPath}/app/layout.tsx`, "utf-8");
664
+ const fontConfig = await Promise.resolve(`${`${this.projectPath}/app/font.config.ts`}`).then(s => __importStar(require(s)));
665
+ const fonts = fontConfig.default.fonts;
666
+ if (!fonts || fonts.length === 0) {
667
+ return;
668
+ }
669
+ const scriptsElements = fonts
670
+ .map((file) => {
671
+ let links = "";
672
+ if (file === null || file === void 0 ? void 0 : file.csspath) {
673
+ links += `<link rel="stylesheet" href={\`\${configs.appConfig.basePath}${file.csspath}\`} />\n`;
674
+ }
675
+ if (file === null || file === void 0 ? void 0 : file.path) {
676
+ links += `<link rel="preload" href={\`\${configs.appConfig.basePath}${file.path}\`} />\n`;
677
+ }
678
+ return links;
679
+ })
680
+ .filter(Boolean)
681
+ .join("\n");
682
+ const updatedContent = layoutContent.replace(/\s*<\/head>/, `
683
+ ${scriptsElements}\n
684
+ </head>`);
685
+ fs_extra_1.default.writeFileSync(`${this.projectPath}/app/layout.tsx`, updatedContent, "utf-8");
686
+ }
687
+ catch (e) {
688
+ console.log("Error in IncludeScriptImports:", e);
689
+ }
690
+ }
691
+ copyResource() {
692
+ return this.projectService.getResources().then(p => {
693
+ if (p) {
694
+ const dest = `${this.projectPath}${!this.isPrefabApp ? "/public" : ""}/resources`;
695
+ fs_extra_1.default.copySync(p, dest);
696
+ }
697
+ return Promise.resolve({});
698
+ });
699
+ }
700
+ generatePagesAndPartials(isPartOfPrefab) {
701
+ let pageConfigs = null;
702
+ let securityConfigs = null;
703
+ return this.projectService
704
+ .getPageConfigs()
705
+ .then(_pageConfigs => {
706
+ pageConfigs = _pageConfigs;
707
+ return this.projectService.getSecurityConfig();
708
+ })
709
+ .then(_securityConfigs => {
710
+ securityConfigs = _securityConfigs;
711
+ pageConfigs = pageConfigs.map((p) => {
712
+ const matchingSecurity = securityConfigs.find((sec) => {
713
+ if (isPartOfPrefab) {
714
+ //search for prefab name since all pages inside the prefab we get main.tsx file
715
+ return sec.urlPattern.includes(`/prefabs/${this.prefabName}`);
716
+ }
717
+ else {
718
+ return sec.urlPattern.includes(`/pages/${p.name}`);
719
+ }
720
+ });
721
+ //Common page have always access to everyone
722
+ if (p.name === "Common" && !isPartOfPrefab) {
723
+ return Object.assign({}, p, {
724
+ allowedRoles: [],
725
+ permission: "PermitAll",
726
+ });
727
+ }
728
+ if (matchingSecurity) {
729
+ return Object.assign({}, p, {
730
+ allowedRoles: matchingSecurity.roles,
731
+ permission: matchingSecurity.permission,
732
+ });
733
+ }
734
+ return Object.assign({}, p, {
735
+ permission: "Authenticated",
736
+ });
737
+ });
738
+ const pageCreationPromises = pageConfigs.map(p => {
739
+ if (p.type === "PAGE") {
740
+ return this.generatePageComponent(p.name, isPartOfPrefab);
741
+ }
742
+ if (this.isPartial(p.type)) {
743
+ return this.generatePartialComponent(p.name, true, isPartOfPrefab);
744
+ }
745
+ });
746
+ return Promise.all(pageCreationPromises);
747
+ })
748
+ .then(() => this.generatePageConfig(pageConfigs, isPartOfPrefab))
749
+ .then(() => this.generatePartialConfig(pageConfigs, isPartOfPrefab));
750
+ }
751
+ generateEntityMetadata() {
752
+ if (this.incBuilder) {
753
+ console.log(`Generating Entity data.`);
754
+ }
755
+ const liveSources = {};
756
+ this.liveVariables.forEach((lv) => {
757
+ const liveSource = lv.liveSource;
758
+ const entityName = lv.type;
759
+ if (!liveSources[liveSource]) {
760
+ liveSources[liveSource] = {};
761
+ }
762
+ if (!liveSources[liveSource][entityName]) {
763
+ liveSources[liveSource][entityName] = {
764
+ propertiesMap: lv.propertiesMap,
765
+ relatedTables: lv.relatedTables,
766
+ };
767
+ }
768
+ });
769
+ Object.keys(liveSources).forEach((liveSource) => {
770
+ (0, utils_1.writeFile)(`${this.projectPath}/libs/metadata/entities/${liveSource}.json`, JSON.stringify(liveSources[liveSource], null, 4));
771
+ });
772
+ const output = ENTITY_PROVIDER_TEMPLATE({
773
+ liveSources: Object.keys(liveSources),
774
+ });
775
+ (0, utils_1.writeFile)(`${this.projectPath}/libs/metadata/entities/entity-provider.js`, output);
776
+ }
777
+ resolvePackage() {
778
+ const { SCRIPT_IMPORTS, NPM_PACKAGES } = this.ResolvePrefabImports;
779
+ if (SCRIPT_IMPORTS.length > 0) {
780
+ const layoutPath = `${this.projectPath}/app/layout.tsx`;
781
+ if (fs_extra_1.default.existsSync(layoutPath)) {
782
+ const layoutContent = fs_extra_1.default.readFileSync(layoutPath, "utf-8");
783
+ // Filter script imports to only include files that actually exist
784
+ const validScriptImports = SCRIPT_IMPORTS.filter((script) => {
785
+ // Skip HTTP URLs - they are external scripts
786
+ if (script.startsWith("http")) {
787
+ return true;
788
+ }
789
+ const fullPath = path_2.default.resolve(this.projectPath, `public/${script}`);
790
+ const exists = fs_extra_1.default.existsSync(fullPath);
791
+ if (!exists) {
792
+ console.warn(`Script import file not found: ${fullPath}, skipping import`);
793
+ }
794
+ return exists;
795
+ });
796
+ if (validScriptImports.length > 0) {
797
+ const scriptElements = [...new Set(validScriptImports)]
798
+ .map(script => {
799
+ // If script is a URL, use it as-is without prefix
800
+ if (script.startsWith("http")) {
801
+ return `<script src="${script}"></script>`;
802
+ }
803
+ // For local scripts, use JSX syntax and ensure proper path joining
804
+ const cleanScript = script.startsWith("/") ? script.substring(1) : script;
805
+ return `<script defer src={\`\${configs.appConfig.basePath}${cleanScript}\`}></script>`;
806
+ })
807
+ .join("\n");
808
+ const updatedContent = layoutContent.replace(/\s*<\/head>/, `${scriptElements}\n </head>`);
809
+ fs_extra_1.default.writeFileSync(layoutPath, updatedContent);
810
+ }
811
+ }
812
+ }
813
+ if (NPM_PACKAGES.length) {
814
+ let data = fs_extra_1.default.readFileSync(`${this.projectPath}/package.json`, "utf-8");
815
+ const jsonData = JSON.parse(data);
816
+ NPM_PACKAGES.forEach(script => {
817
+ if (jsonData["dependencies"][script.match(/[\/]+(.*?)@\d/)[1]] &&
818
+ semver_1.default.lt(jsonData["dependencies"][script.match(/[\/]+(.*?)@\d/)[1]], script.match(".*@(.*?)$")[1])) {
819
+ console.log("adding new version " +
820
+ script.match(".*@(.*?)$")[1] +
821
+ "for script.match(/[\/]+(.*?)@\d/)![1] dependency");
822
+ jsonData["dependencies"][script.match(/[\/]+(.*?)@\d/)[1]] =
823
+ script.match(".*@(.*?)$")[1];
824
+ }
825
+ else {
826
+ jsonData["dependencies"][script.match(/[\/]+(.*?)@\d/)[1]] =
827
+ script.match(".*@(.*?)$")[1];
828
+ }
829
+ });
830
+ fs_extra_1.default.writeFileSync(`${this.projectPath}/package.json`, JSON.stringify(jsonData, null, 4));
831
+ }
832
+ return Promise.resolve({});
833
+ }
834
+ async resolveProjectType() {
835
+ this.isWaveApp = await this.projectService.getWmProjectType();
836
+ if (!this.isWaveApp)
837
+ return Promise.resolve({});
838
+ // CSS override import is now handled in gen-app-override-css.ts after the file is generated
839
+ // if it's waveApp replace the global.css file with foundation.css in the this.projectPath
840
+ const globalCSSPath = path_2.default.resolve(this.projectPath, "app/globals.css");
841
+ const layoutPath = path_2.default.resolve(this.projectPath, "app/layout.tsx");
842
+ const WaveLayoutPath = path_2.default.resolve(__dirname, "../templates/foundation/layout.tsx");
843
+ // Replace file import
844
+ const cssContent = '@import "@wavemaker/app-runtime-wm-build/wmapp/styles/foundation/foundation.css";\n';
845
+ // Replace the first line of globals.css with cssContent
846
+ let existingCss = fs_extra_1.default.existsSync(globalCSSPath)
847
+ ? fs_extra_1.default.readFileSync(globalCSSPath, "utf-8").split("\n")
848
+ : [];
849
+ if (existingCss.length > 0) {
850
+ existingCss[0] = cssContent.trim();
851
+ }
852
+ else {
853
+ existingCss = [cssContent.trim()];
854
+ }
855
+ fs_extra_1.default.writeFileSync(globalCSSPath, existingCss.join("\n"), "utf-8");
856
+ const lines = fs_extra_1.default.readFileSync(layoutPath, "utf-8").split("\n");
857
+ // Remove the first line which is the import of global.css
858
+ if (lines.length > 0 && lines[0].includes("globals.css")) {
859
+ lines.splice(0, 1);
860
+ }
861
+ // Add the import of foundation.css after the first line
862
+ lines.splice(0, 0, 'import "@wavemaker/app-runtime-wm-build/wmapp/styles/foundation/foundation.css";');
863
+ // Write the updated content back to layout
864
+ fs_extra_1.default.writeFileSync(layoutPath, lines.join("\n"), "utf-8");
865
+ // update layout
866
+ let layoutContent = fs_extra_1.default.readFileSync(WaveLayoutPath, "utf-8");
867
+ // check app.override.css file is present or not
868
+ const isAppOverrideCssExist = await this.projectService.getThemesFiles().then(p => {
869
+ if (p && fs_extra_1.default.existsSync(path_2.default.join(p, "app.override.css"))) {
870
+ return true;
871
+ }
872
+ return false;
873
+ });
874
+ if (isAppOverrideCssExist) {
875
+ const lines = layoutContent.split("\n");
876
+ lines.splice(4, 0, 'import "public/design-tokens/app.override.css";');
877
+ layoutContent = lines.join("\n");
878
+ }
879
+ fs_extra_1.default.writeFileSync(layoutPath, layoutContent, "utf-8");
880
+ }
881
+ async setSecurityConfig() {
882
+ const securityConfig = await this.projectService.getAuthInfoFilePath();
883
+ if (securityConfig && securityConfig.csrfConfig) {
884
+ const envPath = `${this.projectPath}/.env`;
885
+ (0, utils_1.updateEnvFile)(envPath, {
886
+ NEXT_PUBLIC_XSRF_HEADER_NAME: securityConfig.csrfConfig.headerName,
887
+ NEXT_PUBLIC_XSRF_COOKIE_NAME: securityConfig.csrfConfig.cookieName,
888
+ });
889
+ }
890
+ return Promise.resolve();
891
+ }
892
+ generateFormatters() {
893
+ if (this.incBuilder) {
894
+ console.log(`Generating formatters.`);
895
+ }
896
+ return this.projectService.getFormatters().then(script => {
897
+ const code = FORMATTERS_TEMPLATE({
898
+ script: script,
899
+ });
900
+ return (0, utils_1.writeFile)(`${this.projectPath}/libs/extensions/formatters.js`, code);
901
+ });
902
+ }
903
+ generateApp() {
904
+ this.incBuilder || fs_extra_1.default.copySync(__dirname + "/../templates/project", this.projectPath);
905
+ return (this.resolveProjectType()
906
+ .then(() => this.setSecurityConfig())
907
+ .then(() => this.generatePagesAndPartials())
908
+ .then(() => this.incBuilder && this.generateAllPrefabComponents())
909
+ .then(() => !this.incBuilder || this.incBuilder.isAppScriptModified())
910
+ .then(() => !this.incBuilder || this.incBuilder.isAppStyleModified())
911
+ .then((build) => (build && this.copyThemesFiles()))
912
+ .then((build) => (build && this.copyFavIcon()))
913
+ .then((build) => (build && this.copyResource()))
914
+ .then((build) => (build && this.generateAppStyles()))
915
+ .then(() => !this.incBuilder || this.incBuilder.isAppVariablesModified())
916
+ .then((build) => (build && this.generateAppVariables()))
917
+ .then(() => !this.incBuilder || this.incBuilder.isEntityModified())
918
+ .then((build) => (build && this.generateEntityMetadata()))
919
+ .then(() => !this.incBuilder || this.incBuilder.isFormatterModified())
920
+ .then((build) => (build && this.generateFormatters()))
921
+ .then(() => !this.incBuilder || this.incBuilder.isi18nModified())
922
+ .then((build) => (build && this.copyi18nFiles()))
923
+ .then(() => !this.incBuilder || this.incBuilder.isi18nModified())
924
+ .then((build) => (build && this.resolvePackage()))
925
+ .then(() => !this.incBuilder || this.incBuilder.isFontConfigModified())
926
+ .then((build) => (build && this.generateFontConfig()))
927
+ .then(() => this.generateOverrideCSS())
928
+ .then(() => !this.incBuilder)
929
+ // .then(build => (build && this.prettify()) as any)
930
+ .then(() => console.log("code generated at " + this.projectPath)));
931
+ }
932
+ generateFragment(name) {
933
+ let pageConfigs = null;
934
+ return (this.projectService
935
+ .getPageConfigs()
936
+ .then(_pageConfigs => {
937
+ pageConfigs = _pageConfigs;
938
+ const info = pageConfigs.find(config => config.name === name);
939
+ if (info) {
940
+ if (info.type === "PAGE") {
941
+ return this.generatePageComponent(info.name);
942
+ }
943
+ if (this.isPartial(info.type)) {
944
+ return this.generatePartialComponent(name);
945
+ }
946
+ }
947
+ })
948
+ .then(() => this.generatePageConfig(pageConfigs))
949
+ .then(() => this.generatePartialConfig(pageConfigs))
950
+ // .then(() => this.prettify(`**/${name}/**/*.js`))
951
+ .then(() => console.log("code generated at " + this.projectPath)));
952
+ }
953
+ }
954
+ exports.default = AppGenerator;
955
+ //# sourceMappingURL=app.generator.js.map