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