@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
package/src/utils.js ADDED
@@ -0,0 +1,934 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.copyRecursiveSync = exports.extractScriptAndLinkTags = exports.extractInteractiveContainerDiv = exports.htmlToJsx = exports.convertStyleStringToObject = exports.OVERRIDE_TOKENS_PATH = exports.APP_OVERRIDE_CSS_PATH = exports.DESIGN_TOKENS_DIR_NAME = exports.executeSyncCmd = exports.htmlElements = exports.updateEnvFile = exports.fixURLPathAndScope = exports.scopeCssUnderWmApp = exports.modifyExpression = exports.convertHyphenatedPropsToBracketNotation = exports.transformAppLocale = exports.fixURLPath = exports.addOptionalChaining = exports.addOptionalChainingToPropertyPath = exports.readAndReplaceFileContent = exports.findNodeModules = exports.readdir = exports.writeFile = exports.loadTemplate = void 0;
7
+ exports.isJSExpression = isJSExpression;
8
+ const fs_extra_1 = __importDefault(require("fs-extra"));
9
+ const handlebars_1 = __importDefault(require("handlebars"));
10
+ const node_html_parser_1 = require("node-html-parser");
11
+ const profile_1 = __importDefault(require("./profiles/profile"));
12
+ const parser_1 = require("@babel/parser");
13
+ function isValid(expr) {
14
+ try {
15
+ (0, parser_1.parse)(expr, { sourceType: "module", plugins: ["optionalChaining"] });
16
+ return true;
17
+ }
18
+ catch (_a) {
19
+ return false;
20
+ }
21
+ }
22
+ function isJSExpression(expr) {
23
+ try {
24
+ (0, parser_1.parseExpression)(expr, { sourceType: "module", plugins: ["optionalChaining"] });
25
+ return true;
26
+ }
27
+ catch (_a) {
28
+ return false;
29
+ }
30
+ }
31
+ const loadTemplate = (templatePath) => {
32
+ const template = fs_extra_1.default.readFileSync(templatePath, "utf8");
33
+ const fn = handlebars_1.default.compile(template);
34
+ return (data) => fn({ profile: profile_1.default, ...data });
35
+ };
36
+ exports.loadTemplate = loadTemplate;
37
+ const writeFile = (path, content) => {
38
+ const parent = path.substring(0, path.lastIndexOf("/"));
39
+ if (!fs_extra_1.default.existsSync(parent)) {
40
+ fs_extra_1.default.mkdirpSync(parent);
41
+ }
42
+ if (profile_1.default.targetPlatform === "native" && (path.endsWith("js") || path.endsWith("jsx"))) {
43
+ content = content.replace(/debugger/gi, "//debugger");
44
+ }
45
+ fs_extra_1.default.writeFileSync(path, content);
46
+ };
47
+ exports.writeFile = writeFile;
48
+ const readdir = (path, opts = { recursive: false }, callback = (f) => ({})) => {
49
+ fs_extra_1.default.readdirSync(path).forEach(name => {
50
+ const child = `${path}/${name}`;
51
+ if (fs_extra_1.default.statSync(child).isDirectory() && opts.recursive) {
52
+ (0, exports.readdir)(child, opts, callback);
53
+ }
54
+ else {
55
+ callback(child);
56
+ }
57
+ });
58
+ };
59
+ exports.readdir = readdir;
60
+ const findNodeModules = (path) => {
61
+ if (fs_extra_1.default.existsSync(`${path}/node_modules`)) {
62
+ return `${path}/node_modules`;
63
+ }
64
+ else {
65
+ const splits = path.split("/");
66
+ splits.pop();
67
+ if (splits.length) {
68
+ return (0, exports.findNodeModules)(splits.join("/"));
69
+ }
70
+ }
71
+ return "";
72
+ };
73
+ exports.findNodeModules = findNodeModules;
74
+ const readAndReplaceFileContent = async function (path, writeFn) {
75
+ if (!fs_extra_1.default.existsSync(path)) {
76
+ return Promise.resolve();
77
+ }
78
+ const content = fs_extra_1.default.readFileSync(path, "utf-8");
79
+ return Promise.resolve()
80
+ .then(() => {
81
+ return writeFn && writeFn(content);
82
+ })
83
+ .then(modifiedContent => {
84
+ if (modifiedContent !== undefined && modifiedContent !== null) {
85
+ fs_extra_1.default.writeFileSync(path, modifiedContent);
86
+ return modifiedContent;
87
+ }
88
+ return content;
89
+ });
90
+ };
91
+ exports.readAndReplaceFileContent = readAndReplaceFileContent;
92
+ const addOptionalChainingToPropertyPath = (propertyPath) => {
93
+ var _a;
94
+ // Split the path into meaningful parts while preserving structure
95
+ const parts = [];
96
+ let current = "";
97
+ let i = 0;
98
+ // Handle the first part specially (no optional chaining at the start)
99
+ while (i < propertyPath.length && propertyPath[i] !== "." && propertyPath[i] !== "[") {
100
+ current += propertyPath[i];
101
+ i++;
102
+ }
103
+ if (current) {
104
+ parts.push({ type: "prop", content: current });
105
+ current = "";
106
+ }
107
+ while (i < propertyPath.length) {
108
+ if (propertyPath[i] === ".") {
109
+ i++; // Skip the dot
110
+ current = "";
111
+ while (i < propertyPath.length && propertyPath[i] !== "." && propertyPath[i] !== "[") {
112
+ current += propertyPath[i];
113
+ i++;
114
+ }
115
+ if (current) {
116
+ parts.push({ type: "prop", content: `.${current}` });
117
+ current = "";
118
+ }
119
+ }
120
+ else if (propertyPath[i] === "[") {
121
+ i++; // Skip the opening bracket
122
+ let bracketContent = "";
123
+ let nestedBracketLevel = 0;
124
+ // Handle nested brackets properly
125
+ while (i < propertyPath.length) {
126
+ if (propertyPath[i] === "[") {
127
+ nestedBracketLevel++;
128
+ bracketContent += propertyPath[i];
129
+ }
130
+ else if (propertyPath[i] === "]") {
131
+ if (nestedBracketLevel === 0) {
132
+ break; // Found the matching closing bracket
133
+ }
134
+ nestedBracketLevel--;
135
+ bracketContent += propertyPath[i];
136
+ }
137
+ else {
138
+ bracketContent += propertyPath[i];
139
+ }
140
+ i++;
141
+ }
142
+ if (i < propertyPath.length) {
143
+ parts.push({ type: "bracket", content: bracketContent });
144
+ i++; // Skip the closing bracket
145
+ }
146
+ }
147
+ else {
148
+ i++; // Skip any unexpected characters
149
+ }
150
+ }
151
+ // Helper to process only property paths within bracket content, preserving bracket structure
152
+ const processBracketContent = (content) => {
153
+ const trimmed = content.trim();
154
+ // Skip if it's a string literal or numeric index
155
+ if (trimmed.startsWith("'") || trimmed.startsWith('"'))
156
+ return content;
157
+ if (/^\d+$/.test(trimmed))
158
+ return content;
159
+ // If it contains nested brackets, process property paths within them
160
+ if (trimmed.includes("[")) {
161
+ // Find property paths (identifier.identifier) and process only those parts
162
+ // Example: "data[Widgets.form.value]" -> "data[Widgets?.form?.value]"
163
+ // Example: "items[0]" -> "items[0]" (no change)
164
+ // Use regex to find and replace property paths, preserving bracket structure
165
+ const propertyPathRegex = /([a-zA-Z_$][a-zA-Z0-9_$]*\.[a-zA-Z_$][a-zA-Z0-9_$]*(?:\.[a-zA-Z_$][a-zA-Z0-9_$]*)*)/g;
166
+ return trimmed.replace(propertyPathRegex, match => {
167
+ // Process only the property path part (the part with dots)
168
+ return (0, exports.addOptionalChainingToPropertyPath)(match);
169
+ });
170
+ }
171
+ // Check if it's a property path (contains dots after identifier)
172
+ if (/^[a-zA-Z_$][a-zA-Z0-9_$]*\.[a-zA-Z_$]/.test(trimmed)) {
173
+ return (0, exports.addOptionalChainingToPropertyPath)(content);
174
+ }
175
+ // Simple identifier or other - leave as is
176
+ return content;
177
+ };
178
+ // Add optional chaining
179
+ let result = ((_a = parts[0]) === null || _a === void 0 ? void 0 : _a.content) || "";
180
+ for (let j = 1; j < parts.length; j++) {
181
+ const part = parts[j];
182
+ if (part.type === "bracket") {
183
+ // Process bracket content - only property paths get optional chaining
184
+ const processedContent = processBracketContent(part.content);
185
+ result += `?.[${processedContent}]`;
186
+ }
187
+ else if (part.content.startsWith(".")) {
188
+ result += `?${part.content}`;
189
+ }
190
+ }
191
+ return result;
192
+ };
193
+ exports.addOptionalChainingToPropertyPath = addOptionalChainingToPropertyPath;
194
+ const addOptionalChaining = (bindPath, options = {}) => {
195
+ const { targetPattern, addFallback = false, fallbackValue = '""', detectFunctionCalls = false, } = options;
196
+ // Helper to find balanced parentheses
197
+ const findBalancedParens = (str, start) => {
198
+ let depth = 0;
199
+ for (let i = start; i < str.length; i++) {
200
+ if (str[i] === "(")
201
+ depth++;
202
+ else if (str[i] === ")") {
203
+ depth--;
204
+ if (depth === 0)
205
+ return i;
206
+ }
207
+ }
208
+ return -1;
209
+ };
210
+ // Step 1: Extract and protect string literals
211
+ const stringLiterals = [];
212
+ let protectedExpression = bindPath.replace(/"[^"]*"|'[^']*'/g, match => {
213
+ const placeholder = `__STRING_${stringLiterals.length}__`;
214
+ stringLiterals.push(match);
215
+ return placeholder;
216
+ });
217
+ // Step 1.5: Extract and protect function arguments (including arrow functions)
218
+ // This prevents processing property paths inside function arguments
219
+ const functionArgs = [];
220
+ let argProtectedExpression = protectedExpression;
221
+ // Find all function calls and protect their arguments
222
+ let funcArgIndex = 0;
223
+ let i = 0;
224
+ while (i < argProtectedExpression.length) {
225
+ if (argProtectedExpression[i] === "(") {
226
+ const parenStart = i;
227
+ const parenEnd = findBalancedParens(argProtectedExpression, i);
228
+ if (parenEnd !== -1) {
229
+ const argsContent = argProtectedExpression.substring(parenStart + 1, parenEnd);
230
+ // Only protect if there's actual content (not empty parentheses)
231
+ if (argsContent.trim()) {
232
+ const placeholder = `__FUNCARG_${funcArgIndex}__`;
233
+ functionArgs.push(argsContent);
234
+ argProtectedExpression =
235
+ argProtectedExpression.substring(0, parenStart + 1) +
236
+ placeholder +
237
+ argProtectedExpression.substring(parenEnd);
238
+ funcArgIndex++;
239
+ i = parenStart + placeholder.length + 1;
240
+ continue;
241
+ }
242
+ }
243
+ }
244
+ i++;
245
+ }
246
+ // Step 2: Process property access patterns, handling function calls
247
+ // Use default pattern if not provided
248
+ const defaultPattern = /[a-zA-Z_$][a-zA-Z0-9_$]*(?:\.[a-zA-Z_$][a-zA-Z0-9_$]*|\[[^\]]+\])*/g;
249
+ const pattern = targetPattern || defaultPattern;
250
+ let result = argProtectedExpression;
251
+ const matches = [];
252
+ // Collect all matches
253
+ pattern.lastIndex = 0;
254
+ let match;
255
+ while ((match = pattern.exec(argProtectedExpression)) !== null) {
256
+ matches.push({
257
+ start: match.index,
258
+ end: match.index + match[0].length,
259
+ text: match[0],
260
+ });
261
+ }
262
+ // Process matches in reverse order to maintain indices
263
+ for (let i = matches.length - 1; i >= 0; i--) {
264
+ const m = matches[i];
265
+ let processed = (0, exports.addOptionalChainingToPropertyPath)(m.text);
266
+ // Check if there's a function call immediately after this match
267
+ const afterMatch = argProtectedExpression.substring(m.end);
268
+ const funcCallMatch = afterMatch.match(/^\s*\(/);
269
+ if (funcCallMatch) {
270
+ // Find the closing parenthesis
271
+ const parenEnd = findBalancedParens(argProtectedExpression, m.end + funcCallMatch[0].length - 1);
272
+ if (parenEnd !== -1) {
273
+ const funcCall = argProtectedExpression.substring(m.end, parenEnd + 1);
274
+ processed += funcCall;
275
+ // Check if there's property access after the function call
276
+ const afterFunc = argProtectedExpression.substring(parenEnd + 1);
277
+ const propAccessMatch = afterFunc.match(/^\s*\.([a-zA-Z_$][a-zA-Z0-9_$]*)/);
278
+ if (propAccessMatch) {
279
+ processed += `?.${propAccessMatch[1]}`;
280
+ // Update the match end to include the function call and property
281
+ matches[i].end = parenEnd + 1 + propAccessMatch[0].length;
282
+ }
283
+ else {
284
+ matches[i].end = parenEnd + 1;
285
+ }
286
+ }
287
+ }
288
+ // Replace in result
289
+ result = result.substring(0, m.start) + processed + result.substring(m.end);
290
+ }
291
+ // Step 3: Add optional chaining after closing parentheses/brackets that are followed by property access
292
+ // This handles cases like:
293
+ // - obj.method().prop
294
+ // - (expr | pipe)[0].url
295
+ // - (expr)[0].url
296
+ result = result.replace(/(\))\s*\.([a-zA-Z_$][a-zA-Z0-9_$]*)/g, "$1?.$2");
297
+ result = result.replace(/(\))\s*\[/g, "$1?.[");
298
+ result = result.replace(/(\])\s*\.([a-zA-Z_$][a-zA-Z0-9_$]*)/g, "$1?.$2");
299
+ result = result.replace(/(\])\s*\[/g, "$1?.[");
300
+ // Step 4: Restore function arguments and process property paths in them
301
+ functionArgs.forEach((arg, index) => {
302
+ let processedArg = arg;
303
+ // Process arrow function bodies (parts after =>)
304
+ const arrowMatch = arg.match(/^([^=]*)=>\s*(.+)$/);
305
+ if (arrowMatch) {
306
+ const [, params, body] = arrowMatch;
307
+ // Process property paths in the arrow function body
308
+ const processedBody = (0, exports.addOptionalChaining)(body);
309
+ processedArg = `${params}=> ${processedBody}`;
310
+ }
311
+ else {
312
+ // Not an arrow function - recursively process with addOptionalChaining
313
+ // This handles nested brackets properly
314
+ processedArg = (0, exports.addOptionalChaining)(arg);
315
+ }
316
+ result = result.replace(`__FUNCARG_${index}__`, processedArg);
317
+ });
318
+ // Step 5: Restore string literals
319
+ stringLiterals.forEach((literal, index) => {
320
+ result = result.replace(`__STRING_${index}__`, literal);
321
+ });
322
+ // Step 6: Add fallback handling if requested
323
+ if (addFallback) {
324
+ if (detectFunctionCalls) {
325
+ const hasFunctionCall = /\([^)]*\)\s*$/.test(result);
326
+ if (!hasFunctionCall) {
327
+ result = `(${result} || ${fallbackValue})`;
328
+ }
329
+ }
330
+ else {
331
+ result = `(${result} || ${fallbackValue})`;
332
+ }
333
+ }
334
+ return result;
335
+ };
336
+ exports.addOptionalChaining = addOptionalChaining;
337
+ const fixURLPath = (file_content, basePath, isAppCss) => {
338
+ // Fix resources URLs
339
+ let updatedContent = file_content.replace(/url\((['"]?)resources/g, `url($1${basePath || ""}/resources`);
340
+ // Fix font URLs and other URLs that need leading slash
341
+ // This regex matches url() with single or double quotes that don't start with /, http, or data:
342
+ if (isAppCss) {
343
+ updatedContent = updatedContent.replace(/url\((['"])(?!\/|http|data:)([^'"]+)\1\)/g, (match, quote, url) => {
344
+ // Add leading slash if the URL doesn't already have one
345
+ // Check if URL already starts with / (absolute path)
346
+ const fixedUrl = url.startsWith("/") ? url : `/${url}`;
347
+ return `url(${quote}${fixedUrl}${quote})`;
348
+ });
349
+ }
350
+ return updatedContent;
351
+ };
352
+ exports.fixURLPath = fixURLPath;
353
+ const transformAppLocale = (exp) => {
354
+ if (exp.startsWith("fragment?.Prefab") || exp.startsWith("fragment.Prefab")) {
355
+ exp = exp.replace("fragment?.Prefab", "fragment");
356
+ exp = exp.replace("fragment.Prefab", "fragment");
357
+ }
358
+ // Updated regex to capture the optional 'fragment.' prefix
359
+ const appLocaleRegex = /(fragment\.)?appLocale(?:\.messages)?(?:\[(['"])([^'"]+)\2\]|\.([a-zA-Z0-9_]+))/g;
360
+ // We use a replacer function with .replace() to have full control over the output.
361
+ // This function is called for every match found by the regex.
362
+ const replacer = (fullMatch, fragmentPrefix, quoteType, keyFromBrackets, keyFromDot) => {
363
+ // The key will either be from the bracket capture group or the dot capture group.
364
+ const key = keyFromBrackets || keyFromDot;
365
+ if (key) {
366
+ // If there's a fragment prefix, include it in the formatMessage call
367
+ if (fragmentPrefix) {
368
+ return `formatMessage(fragment, '${key}')`;
369
+ }
370
+ else {
371
+ return `formatMessage('${key}')`;
372
+ }
373
+ }
374
+ // Fallback to return the original match if key extraction fails (unlikely)
375
+ return fullMatch;
376
+ };
377
+ // Apply the transformation
378
+ const expression = exp.replace(appLocaleRegex, replacer);
379
+ return expression;
380
+ };
381
+ exports.transformAppLocale = transformAppLocale;
382
+ /**
383
+ * Converts property paths with hyphens to bracket notation for valid JavaScript.
384
+ * e.g. Actions.goToPage_test-page.invoke() -> Actions["goToPage_test-page"].invoke()
385
+ * Hyphens in identifiers are invalid in JS (parsed as subtraction), so we use bracket notation.
386
+ */
387
+ const convertHyphenatedPropsToBracketNotation = (expr) => {
388
+ if (!expr || typeof expr !== "string")
389
+ return expr;
390
+ // Match .identifier where identifier contains hyphen (e.g. .goToPage_test-page, .my-var)
391
+ return expr.replace(/\.([a-zA-Z_$][a-zA-Z0-9_$]*-[a-zA-Z_$][a-zA-Z0-9_$\-]*)/g, (_, propName) => {
392
+ return `["${propName}"]`;
393
+ });
394
+ };
395
+ exports.convertHyphenatedPropsToBracketNotation = convertHyphenatedPropsToBracketNotation;
396
+ const modifyExpression = (exp) => {
397
+ if (exp.startsWith('"http') || exp.startsWith('"/') || exp.startsWith("{")) {
398
+ return exp;
399
+ }
400
+ if (!isValid(exp))
401
+ return `""`;
402
+ if (exp.includes("appLocale")) {
403
+ const transformedExp = (0, exports.transformAppLocale)(exp);
404
+ return (0, exports.addOptionalChaining)(transformedExp);
405
+ }
406
+ else {
407
+ return (0, exports.addOptionalChaining)(exp);
408
+ }
409
+ };
410
+ exports.modifyExpression = modifyExpression;
411
+ const scopeCssUnderWmApp = (cssContent) => {
412
+ if (!cssContent || cssContent.trim() === "") {
413
+ return cssContent;
414
+ }
415
+ // Split CSS into rules while preserving structure
416
+ const rules = [];
417
+ let currentRule = "";
418
+ let inComment = false;
419
+ let inString = false;
420
+ let stringChar = "";
421
+ let braceLevel = 0;
422
+ for (let i = 0; i < cssContent.length; i++) {
423
+ const char = cssContent[i];
424
+ const nextChar = cssContent[i + 1];
425
+ // Handle comments
426
+ if (!inString && char === "/" && nextChar === "*") {
427
+ inComment = true;
428
+ currentRule += char;
429
+ continue;
430
+ }
431
+ if (inComment && char === "*" && nextChar === "/") {
432
+ inComment = false;
433
+ currentRule += char;
434
+ continue;
435
+ }
436
+ if (inComment) {
437
+ currentRule += char;
438
+ continue;
439
+ }
440
+ // Handle strings
441
+ if (!inString && (char === '"' || char === "'")) {
442
+ inString = true;
443
+ stringChar = char;
444
+ currentRule += char;
445
+ continue;
446
+ }
447
+ if (inString && char === stringChar && cssContent[i - 1] !== "\\") {
448
+ inString = false;
449
+ stringChar = "";
450
+ currentRule += char;
451
+ continue;
452
+ }
453
+ if (inString) {
454
+ currentRule += char;
455
+ continue;
456
+ }
457
+ // Handle braces to track rule boundaries
458
+ if (char === "{") {
459
+ braceLevel++;
460
+ currentRule += char;
461
+ }
462
+ else if (char === "}") {
463
+ braceLevel--;
464
+ currentRule += char;
465
+ // If we're back to level 0, we've completed a rule
466
+ if (braceLevel === 0) {
467
+ rules.push(currentRule.trim());
468
+ currentRule = "";
469
+ }
470
+ }
471
+ else {
472
+ currentRule += char;
473
+ }
474
+ }
475
+ // Add any remaining content
476
+ if (currentRule.trim()) {
477
+ rules.push(currentRule.trim());
478
+ }
479
+ // Process each rule
480
+ const processedRules = rules.map(rule => {
481
+ // Skip empty rules or comments
482
+ if (!rule ||
483
+ rule.startsWith("/*") ||
484
+ rule.startsWith("@import") ||
485
+ rule.startsWith("@charset")) {
486
+ return rule;
487
+ }
488
+ // Handle at-rules like @media, @keyframes, etc.
489
+ if (rule.startsWith("@")) {
490
+ return rule;
491
+ }
492
+ // Find the opening brace to separate selector from declarations
493
+ const openBraceIndex = rule.indexOf("{");
494
+ if (openBraceIndex === -1) {
495
+ return rule;
496
+ }
497
+ const selector = rule.substring(0, openBraceIndex).trim();
498
+ const declarations = rule.substring(openBraceIndex);
499
+ // Skip if already scoped under .wm-app .app-page
500
+ if (selector.includes(".wm-app .app-page") ||
501
+ selector.startsWith(".wm-app .app-page") ||
502
+ selector.includes(".wm-app") ||
503
+ selector.startsWith(".wm-app")) {
504
+ return rule;
505
+ }
506
+ // Split multiple selectors (comma-separated)
507
+ const selectors = selector.split(",").map(s => s.trim());
508
+ // Scope each selector under .wm-app .app-page
509
+ const scopedSelectors = selectors.map(sel => {
510
+ if (!sel)
511
+ return sel;
512
+ // Handle pseudo-selectors like :root, :before, :after
513
+ if (sel.startsWith(":")) {
514
+ return sel;
515
+ }
516
+ // Handle html, body tags - wrap them
517
+ if (sel === "html" || sel === "body" || sel.startsWith("html ") || sel.startsWith("body ")) {
518
+ return `.wm-app .app-page ${sel}`;
519
+ }
520
+ // For all other selectors, wrap them under .wm-app .app-page
521
+ return `.wm-app .app-page ${sel}`;
522
+ });
523
+ return `${scopedSelectors.join(", ")} ${declarations}`;
524
+ });
525
+ return processedRules.join("\n");
526
+ };
527
+ exports.scopeCssUnderWmApp = scopeCssUnderWmApp;
528
+ const fixURLPathAndScope = (file_content, basePath, isAppCss) => {
529
+ const urlFixed = (0, exports.fixURLPath)(file_content, basePath, isAppCss);
530
+ return (0, exports.scopeCssUnderWmApp)(urlFixed);
531
+ };
532
+ exports.fixURLPathAndScope = fixURLPathAndScope;
533
+ const updateEnvFile = (envFilePath, updates) => {
534
+ let content = "";
535
+ if (fs_extra_1.default.existsSync(envFilePath)) {
536
+ content = fs_extra_1.default.readFileSync(envFilePath, "utf-8");
537
+ }
538
+ // Replace or add each env variable
539
+ for (const [key, value] of Object.entries(updates)) {
540
+ const regex = new RegExp(`^${key}=.*$`, "m");
541
+ const line = `${key}="${value}"`;
542
+ if (regex.test(content)) {
543
+ content = content.replace(regex, line);
544
+ }
545
+ else {
546
+ content += content ? `\n${line}` : line;
547
+ }
548
+ }
549
+ fs_extra_1.default.writeFileSync(envFilePath, content);
550
+ };
551
+ exports.updateEnvFile = updateEnvFile;
552
+ exports.htmlElements = [
553
+ "header",
554
+ "footer",
555
+ "main",
556
+ "section",
557
+ "article",
558
+ "aside",
559
+ "nav",
560
+ "div",
561
+ "span",
562
+ "p",
563
+ "a",
564
+ "img",
565
+ "button",
566
+ "input",
567
+ "textarea",
568
+ "select",
569
+ "option",
570
+ "label",
571
+ "form",
572
+ "table",
573
+ "tbody",
574
+ "tr",
575
+ "td",
576
+ "th",
577
+ "ul",
578
+ "li",
579
+ "ol",
580
+ "h1",
581
+ "h2",
582
+ "h3",
583
+ "h4",
584
+ "h5",
585
+ "h6",
586
+ "iframe",
587
+ ];
588
+ /**
589
+ * Execute a system command synchronously
590
+ * @param cmd Command to execute
591
+ * @param errorCallback Callback to handle errors
592
+ * @param msg Optional message to log before execution
593
+ * @returns Result of the command
594
+ */
595
+ const executeSyncCmd = (cmd, errorCallback, msg) => {
596
+ const { execSync } = require("child_process");
597
+ try {
598
+ console.log(msg ? msg + " Current running cmd: " + cmd : "Running command: " + cmd);
599
+ return execSync(cmd, { stdio: "inherit" });
600
+ }
601
+ catch (err) {
602
+ if (errorCallback) {
603
+ errorCallback(err);
604
+ }
605
+ console.log((msg ? msg : "") + " FAILED command: " + cmd, err);
606
+ return process.exit(err.code || err.pid);
607
+ }
608
+ };
609
+ exports.executeSyncCmd = executeSyncCmd;
610
+ exports.DESIGN_TOKENS_DIR_NAME = "design-tokens";
611
+ exports.APP_OVERRIDE_CSS_PATH = `${exports.DESIGN_TOKENS_DIR_NAME}/app.override.css`;
612
+ exports.OVERRIDE_TOKENS_PATH = `${exports.DESIGN_TOKENS_DIR_NAME}/overrides`;
613
+ /**
614
+ * Extracts URLs from existing script and link tags in a layout file
615
+ * @param layoutContent The layout file content
616
+ * @returns Set of URLs that already exist in the layout
617
+ */
618
+ const getExistingImportUrls = (layoutContent) => {
619
+ const existingUrls = new Set();
620
+ try {
621
+ const parsed = (0, node_html_parser_1.parse)(layoutContent);
622
+ const traverseNodes = (node) => {
623
+ var _a;
624
+ if (node.nodeType === node_html_parser_1.NodeType.ELEMENT_NODE) {
625
+ const tagName = (_a = node.tagName) === null || _a === void 0 ? void 0 : _a.toLowerCase();
626
+ if (tagName === "script" || tagName === "link") {
627
+ const url = node.getAttribute("src") || node.getAttribute("href") || "";
628
+ if (url) {
629
+ existingUrls.add(url);
630
+ }
631
+ }
632
+ if (node.childNodes) {
633
+ node.childNodes.forEach((child) => {
634
+ traverseNodes(child);
635
+ });
636
+ }
637
+ }
638
+ };
639
+ parsed.childNodes.forEach((node) => {
640
+ traverseNodes(node);
641
+ });
642
+ }
643
+ catch (error) {
644
+ // If parsing fails, return empty set
645
+ }
646
+ return existingUrls;
647
+ };
648
+ /**
649
+ * HTML attribute names that need to be converted for JSX compatibility
650
+ */
651
+ const HTML_TO_JSX_ATTR_MAP = {
652
+ class: "className",
653
+ for: "htmlFor",
654
+ tabindex: "tabIndex",
655
+ readonly: "readOnly",
656
+ autofocus: "autoFocus",
657
+ autoplay: "autoPlay",
658
+ crossorigin: "crossOrigin",
659
+ maxlength: "maxLength",
660
+ minlength: "minLength",
661
+ spellcheck: "spellCheck",
662
+ };
663
+ /**
664
+ * Void elements that must be self-closing in JSX
665
+ */
666
+ const VOID_ELEMENTS = new Set([
667
+ "area",
668
+ "base",
669
+ "br",
670
+ "col",
671
+ "embed",
672
+ "hr",
673
+ "img",
674
+ "input",
675
+ "link",
676
+ "meta",
677
+ "param",
678
+ "source",
679
+ "track",
680
+ "wbr",
681
+ ]);
682
+ /**
683
+ * Converts CSS style string to React style object format
684
+ * Example: "color:#ffffff; font-size:14px" -> {color:"#ffffff",fontSize:"14px"}
685
+ */
686
+ const convertStyleStringToObject = (styleString) => {
687
+ if (!styleString || styleString.trim() === "") {
688
+ return "{}";
689
+ }
690
+ const styleObject = {};
691
+ styleString.split(";").forEach(rule => {
692
+ const colonIndex = rule.indexOf(":");
693
+ if (colonIndex > 0) {
694
+ const property = rule.substring(0, colonIndex).trim();
695
+ const value = rule.substring(colonIndex + 1).trim();
696
+ if (property && value) {
697
+ const camelCaseProperty = property.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
698
+ styleObject[camelCaseProperty] = value;
699
+ }
700
+ }
701
+ });
702
+ return JSON.stringify(styleObject);
703
+ };
704
+ exports.convertStyleStringToObject = convertStyleStringToObject;
705
+ /**
706
+ * Converts HTML string to JSX-compatible format (class->className, style->style object, etc.)
707
+ * @param htmlString The HTML string to convert
708
+ * @returns JSX-compatible string
709
+ */
710
+ const htmlToJsx = (htmlString) => {
711
+ if (!htmlString || typeof htmlString !== "string") {
712
+ return "";
713
+ }
714
+ try {
715
+ const parsed = (0, node_html_parser_1.parse)(htmlString);
716
+ const nodeToJsx = (node) => {
717
+ var _a, _b;
718
+ if (node.nodeType === node_html_parser_1.NodeType.TEXT_NODE) {
719
+ return node.text || "";
720
+ }
721
+ if (node.nodeType !== node_html_parser_1.NodeType.ELEMENT_NODE) {
722
+ return "";
723
+ }
724
+ const tagName = ((_a = node.tagName) === null || _a === void 0 ? void 0 : _a.toLowerCase()) || "div";
725
+ const isVoid = VOID_ELEMENTS.has(tagName);
726
+ const attrs = [];
727
+ const attributes = node.attributes || node.attrs || {};
728
+ if (Object.keys(attributes).length > 0) {
729
+ for (const [attr, value] of Object.entries(attributes)) {
730
+ if (value == null || value === "")
731
+ continue;
732
+ const attrLower = attr.toLowerCase();
733
+ if (attrLower === "class") {
734
+ attrs.push(`className="${value}"`);
735
+ }
736
+ else if (attrLower === "style") {
737
+ attrs.push(`style={${(0, exports.convertStyleStringToObject)(value)}}`);
738
+ }
739
+ else {
740
+ const jsxAttr = HTML_TO_JSX_ATTR_MAP[attrLower] || attr;
741
+ attrs.push(`${jsxAttr}="${value}"`);
742
+ }
743
+ }
744
+ }
745
+ const attrsStr = attrs.length ? " " + attrs.join(" ") : "";
746
+ if (isVoid) {
747
+ return `<${tagName}${attrsStr} />`;
748
+ }
749
+ let children = "";
750
+ if ((_b = node.childNodes) === null || _b === void 0 ? void 0 : _b.length) {
751
+ children = node.childNodes.map((child) => nodeToJsx(child)).join("");
752
+ }
753
+ return `<${tagName}${attrsStr}>${children}</${tagName}>`;
754
+ };
755
+ return parsed.childNodes.map((node) => nodeToJsx(node)).join("");
756
+ }
757
+ catch (error) {
758
+ console.error("Error converting HTML to JSX:", error);
759
+ return "";
760
+ }
761
+ };
762
+ exports.htmlToJsx = htmlToJsx;
763
+ /**
764
+ * Extracts the interactive-container div from HTML (with full structure including children)
765
+ * @param htmlString The HTML string to parse
766
+ * @returns The outerHTML of the interactive-container div, or empty string if not found
767
+ */
768
+ const extractInteractiveContainerDiv = (htmlString) => {
769
+ if (!htmlString || typeof htmlString !== "string") {
770
+ return "";
771
+ }
772
+ try {
773
+ const parsed = (0, node_html_parser_1.parse)(htmlString);
774
+ const findInteractiveContainer = (node) => {
775
+ var _a;
776
+ if (node.nodeType === node_html_parser_1.NodeType.ELEMENT_NODE) {
777
+ const tagName = (_a = node.tagName) === null || _a === void 0 ? void 0 : _a.toLowerCase();
778
+ if (tagName === "div") {
779
+ const className = node.getAttribute("class") || "";
780
+ if (className.split(/\s+/).includes("interactive-container")) {
781
+ return node;
782
+ }
783
+ }
784
+ if (node.childNodes) {
785
+ for (const child of node.childNodes) {
786
+ const found = findInteractiveContainer(child);
787
+ if (found)
788
+ return found;
789
+ }
790
+ }
791
+ }
792
+ return null;
793
+ };
794
+ for (const node of parsed.childNodes) {
795
+ const div = findInteractiveContainer(node);
796
+ if (div) {
797
+ return div.outerHTML;
798
+ }
799
+ }
800
+ }
801
+ catch (error) {
802
+ console.error("Error extracting interactive-container div:", error);
803
+ }
804
+ return "";
805
+ };
806
+ exports.extractInteractiveContainerDiv = extractInteractiveContainerDiv;
807
+ function getInlineScriptBody(node) {
808
+ const tc = node.textContent;
809
+ if (typeof tc === "string" && tc.trim().length > 0) {
810
+ return tc;
811
+ }
812
+ const raw = node.rawText;
813
+ if (typeof raw === "string" && raw.trim().length > 0) {
814
+ return raw;
815
+ }
816
+ return "";
817
+ }
818
+ /**
819
+ * Extracts only <script> and <link> tags from an HTML string that:
820
+ * - Have CDN paths (http:// or https:// URLs)
821
+ * - Are NOT from jQuery or Angular libraries
822
+ * - Are NOT already present in the layout file
823
+ * - Plus inline `<script>` blocks (no `src`) as JSX `dangerouslySetInnerHTML`, except JSON-LD / importmap / speculationrules types; skips if layout already contains the same payload.
824
+ * @param htmlString The HTML string to parse
825
+ * @param layoutContent Optional layout file content to check for existing imports
826
+ * @returns A string containing only the extracted <script> and <link> tags
827
+ */
828
+ const extractScriptAndLinkTags = (htmlString, layoutContent) => {
829
+ if (!htmlString || typeof htmlString !== "string") {
830
+ return "";
831
+ }
832
+ try {
833
+ const parsed = (0, node_html_parser_1.parse)(htmlString);
834
+ const extractedTags = [];
835
+ // Get existing URLs from layout if provided
836
+ const existingUrls = layoutContent ? getExistingImportUrls(layoutContent) : new Set();
837
+ // Patterns to identify jQuery and Angular libraries
838
+ const jqueryPatterns = [/jquery/i, /\bjq\b/i, /jquery-ui/i, /jquery\.min/i];
839
+ const angularPatterns = [/angular/i, /ng-/i, /angularjs/i, /@angular/i];
840
+ // Function to check if a URL is from jQuery or Angular
841
+ const isJQueryOrAngular = (url) => {
842
+ if (!url)
843
+ return false;
844
+ const lowerUrl = url.toLowerCase();
845
+ return (jqueryPatterns.some(pattern => pattern.test(lowerUrl)) ||
846
+ angularPatterns.some(pattern => pattern.test(lowerUrl)));
847
+ };
848
+ // Function to check if a URL is a CDN path (http:// or https://)
849
+ const isCdnPath = (url) => {
850
+ if (!url)
851
+ return false;
852
+ return url.startsWith("http://") || url.startsWith("https://");
853
+ };
854
+ // Function to recursively traverse nodes
855
+ const traverseNodes = (node) => {
856
+ var _a;
857
+ if (node.nodeType === node_html_parser_1.NodeType.ELEMENT_NODE) {
858
+ const tagName = (_a = node.tagName) === null || _a === void 0 ? void 0 : _a.toLowerCase();
859
+ // Extract script and link tags
860
+ if (tagName === "script" || tagName === "link") {
861
+ // Get the URL from src (for script) or href (for link)
862
+ const url = node.getAttribute("src") || node.getAttribute("href") || "";
863
+ // It's a CDN path (http:// or https://)
864
+ if (isCdnPath(url) && !isJQueryOrAngular(url) && !existingUrls.has(url)) {
865
+ // Convert to JSX-compatible format (self-closing for link tags only)
866
+ let jsxTag = node.outerHTML;
867
+ // For link tags, ensure they are self-closing for JSX compatibility
868
+ if (tagName === "link") {
869
+ // Remove any closing tag </link>
870
+ jsxTag = jsxTag.replace(/\s*<\/link>/gi, "");
871
+ // If it doesn't end with />, make it self-closing
872
+ if (!jsxTag.trim().endsWith("/>")) {
873
+ // Replace the closing > with />
874
+ jsxTag = jsxTag.replace(/>\s*$/, " />");
875
+ }
876
+ }
877
+ extractedTags.push(jsxTag);
878
+ }
879
+ else if (tagName === "script") {
880
+ const src = node.getAttribute("src") || "";
881
+ const typeAttr = (node.getAttribute("type") || "").toLowerCase();
882
+ const inner = getInlineScriptBody(node).trim();
883
+ if (!src &&
884
+ inner &&
885
+ !/json/.test(typeAttr) &&
886
+ typeAttr !== "importmap" &&
887
+ typeAttr !== "speculationrules") {
888
+ const payload = JSON.stringify(inner);
889
+ if (!layoutContent || !layoutContent.includes(payload)) {
890
+ extractedTags.push(` <script
891
+ dangerouslySetInnerHTML={{
892
+ __html: \`${inner}\`,
893
+ }}
894
+ />`);
895
+ }
896
+ }
897
+ }
898
+ }
899
+ // Recursively process child nodes
900
+ if (node.childNodes) {
901
+ node.childNodes.forEach((child) => {
902
+ traverseNodes(child);
903
+ });
904
+ }
905
+ }
906
+ };
907
+ // Traverse all nodes in the parsed HTML
908
+ parsed.childNodes.forEach((node) => {
909
+ traverseNodes(node);
910
+ });
911
+ return extractedTags.join("\n");
912
+ }
913
+ catch (error) {
914
+ console.error("Error extracting script and link tags:", error);
915
+ return "";
916
+ }
917
+ };
918
+ exports.extractScriptAndLinkTags = extractScriptAndLinkTags;
919
+ const copyRecursiveSync = (src, dest) => {
920
+ let exists = fs_extra_1.default.existsSync(src), stats = exists && fs_extra_1.default.statSync(src), isDirectory = exists && stats && stats.isDirectory();
921
+ if (isDirectory) {
922
+ if (!fs_extra_1.default.existsSync(dest)) {
923
+ fs_extra_1.default.mkdirSync(dest, { recursive: true });
924
+ }
925
+ fs_extra_1.default.readdirSync(src).forEach(function (childItemName) {
926
+ (0, exports.copyRecursiveSync)(src + "/" + childItemName, dest + "/" + childItemName);
927
+ });
928
+ }
929
+ else {
930
+ fs_extra_1.default.copyFileSync(src, dest);
931
+ }
932
+ };
933
+ exports.copyRecursiveSync = copyRecursiveSync;
934
+ //# sourceMappingURL=utils.js.map