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

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