@saolabs/client 1.0.0
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/README.md +221 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -0
- package/dist/plugins.d.ts +38 -0
- package/dist/plugins.d.ts.map +1 -0
- package/dist/plugins.js +61 -0
- package/dist/plugins.js.map +1 -0
- package/dist/src/core/app/Application.d.ts +159 -0
- package/dist/src/core/app/Application.d.ts.map +1 -0
- package/dist/src/core/app/Application.js +338 -0
- package/dist/src/core/app/Application.js.map +1 -0
- package/dist/src/core/bootstrap/app.d.ts +4 -0
- package/dist/src/core/bootstrap/app.d.ts.map +1 -0
- package/dist/src/core/bootstrap/app.js +49 -0
- package/dist/src/core/bootstrap/app.js.map +1 -0
- package/dist/src/core/bootstrap/providers/ApiServiceProvider.d.ts +9 -0
- package/dist/src/core/bootstrap/providers/ApiServiceProvider.d.ts.map +1 -0
- package/dist/src/core/bootstrap/providers/ApiServiceProvider.js +18 -0
- package/dist/src/core/bootstrap/providers/ApiServiceProvider.js.map +1 -0
- package/dist/src/core/bootstrap/providers/CoreServiceProvider.d.ts +6 -0
- package/dist/src/core/bootstrap/providers/CoreServiceProvider.d.ts.map +1 -0
- package/dist/src/core/bootstrap/providers/CoreServiceProvider.js +21 -0
- package/dist/src/core/bootstrap/providers/CoreServiceProvider.js.map +1 -0
- package/dist/src/core/bootstrap/providers/HelperServiceProvider.d.ts +7 -0
- package/dist/src/core/bootstrap/providers/HelperServiceProvider.d.ts.map +1 -0
- package/dist/src/core/bootstrap/providers/HelperServiceProvider.js +14 -0
- package/dist/src/core/bootstrap/providers/HelperServiceProvider.js.map +1 -0
- package/dist/src/core/bootstrap/providers/RouteServiceProvider.d.ts +9 -0
- package/dist/src/core/bootstrap/providers/RouteServiceProvider.d.ts.map +1 -0
- package/dist/src/core/bootstrap/providers/RouteServiceProvider.js +18 -0
- package/dist/src/core/bootstrap/providers/RouteServiceProvider.js.map +1 -0
- package/dist/src/core/bootstrap/providers/ServiceProvider.d.ts +38 -0
- package/dist/src/core/bootstrap/providers/ServiceProvider.d.ts.map +1 -0
- package/dist/src/core/bootstrap/providers/ServiceProvider.js +41 -0
- package/dist/src/core/bootstrap/providers/ServiceProvider.js.map +1 -0
- package/dist/src/core/bootstrap/providers/ViewServiceProvider.d.ts +9 -0
- package/dist/src/core/bootstrap/providers/ViewServiceProvider.d.ts.map +1 -0
- package/dist/src/core/bootstrap/providers/ViewServiceProvider.js +18 -0
- package/dist/src/core/bootstrap/providers/ViewServiceProvider.js.map +1 -0
- package/dist/src/core/bootstrap/providers/default-providers.d.ts +14 -0
- package/dist/src/core/bootstrap/providers/default-providers.d.ts.map +1 -0
- package/dist/src/core/bootstrap/providers/default-providers.js +79 -0
- package/dist/src/core/bootstrap/providers/default-providers.js.map +1 -0
- package/dist/src/core/bootstrap/providers/index.d.ts +10 -0
- package/dist/src/core/bootstrap/providers/index.d.ts.map +1 -0
- package/dist/src/core/bootstrap/providers/index.js +9 -0
- package/dist/src/core/bootstrap/providers/index.js.map +1 -0
- package/dist/src/core/bootstrap/providers/provider-order.d.ts +19 -0
- package/dist/src/core/bootstrap/providers/provider-order.d.ts.map +1 -0
- package/dist/src/core/bootstrap/providers/provider-order.js +51 -0
- package/dist/src/core/bootstrap/providers/provider-order.js.map +1 -0
- package/dist/src/core/cache/ViewCache.d.ts +46 -0
- package/dist/src/core/cache/ViewCache.d.ts.map +1 -0
- package/dist/src/core/cache/ViewCache.js +85 -0
- package/dist/src/core/cache/ViewCache.js.map +1 -0
- package/dist/src/core/cache/index.d.ts +2 -0
- package/dist/src/core/cache/index.d.ts.map +1 -0
- package/dist/src/core/cache/index.js +2 -0
- package/dist/src/core/cache/index.js.map +1 -0
- package/dist/src/core/contracts/ApiInterface.d.ts +11 -0
- package/dist/src/core/contracts/ApiInterface.d.ts.map +1 -0
- package/dist/src/core/contracts/ApiInterface.js +2 -0
- package/dist/src/core/contracts/ApiInterface.js.map +1 -0
- package/dist/src/core/contracts/ApplicationInterface.d.ts +66 -0
- package/dist/src/core/contracts/ApplicationInterface.d.ts.map +1 -0
- package/dist/src/core/contracts/ApplicationInterface.js +3 -0
- package/dist/src/core/contracts/ApplicationInterface.js.map +1 -0
- package/dist/src/core/contracts/BlockInterface.d.ts +67 -0
- package/dist/src/core/contracts/BlockInterface.d.ts.map +1 -0
- package/dist/src/core/contracts/BlockInterface.js +2 -0
- package/dist/src/core/contracts/BlockInterface.js.map +1 -0
- package/dist/src/core/contracts/ComponentInterface.d.ts +24 -0
- package/dist/src/core/contracts/ComponentInterface.d.ts.map +1 -0
- package/dist/src/core/contracts/ComponentInterface.js +2 -0
- package/dist/src/core/contracts/ComponentInterface.js.map +1 -0
- package/dist/src/core/contracts/ElementInterface.d.ts +117 -0
- package/dist/src/core/contracts/ElementInterface.d.ts.map +1 -0
- package/dist/src/core/contracts/ElementInterface.js +2 -0
- package/dist/src/core/contracts/ElementInterface.js.map +1 -0
- package/dist/src/core/contracts/EventServiceInterface.d.ts +37 -0
- package/dist/src/core/contracts/EventServiceInterface.d.ts.map +1 -0
- package/dist/src/core/contracts/EventServiceInterface.js +3 -0
- package/dist/src/core/contracts/EventServiceInterface.js.map +1 -0
- package/dist/src/core/contracts/HelperInterface.d.ts +231 -0
- package/dist/src/core/contracts/HelperInterface.d.ts.map +1 -0
- package/dist/src/core/contracts/HelperInterface.js +3 -0
- package/dist/src/core/contracts/HelperInterface.js.map +1 -0
- package/dist/src/core/contracts/HttpServiceInterface.d.ts +38 -0
- package/dist/src/core/contracts/HttpServiceInterface.d.ts.map +1 -0
- package/dist/src/core/contracts/HttpServiceInterface.js +3 -0
- package/dist/src/core/contracts/HttpServiceInterface.js.map +1 -0
- package/dist/src/core/contracts/LoggerServiceInterface.d.ts +37 -0
- package/dist/src/core/contracts/LoggerServiceInterface.d.ts.map +1 -0
- package/dist/src/core/contracts/LoggerServiceInterface.js +3 -0
- package/dist/src/core/contracts/LoggerServiceInterface.js.map +1 -0
- package/dist/src/core/contracts/LoopContextInterface.d.ts +14 -0
- package/dist/src/core/contracts/LoopContextInterface.d.ts.map +1 -0
- package/dist/src/core/contracts/LoopContextInterface.js +3 -0
- package/dist/src/core/contracts/LoopContextInterface.js.map +1 -0
- package/dist/src/core/contracts/MarkerInterface.d.ts +55 -0
- package/dist/src/core/contracts/MarkerInterface.d.ts.map +1 -0
- package/dist/src/core/contracts/MarkerInterface.js +2 -0
- package/dist/src/core/contracts/MarkerInterface.js.map +1 -0
- package/dist/src/core/contracts/ReactiveInterface.d.ts +38 -0
- package/dist/src/core/contracts/ReactiveInterface.d.ts.map +1 -0
- package/dist/src/core/contracts/ReactiveInterface.js +2 -0
- package/dist/src/core/contracts/ReactiveInterface.js.map +1 -0
- package/dist/src/core/contracts/RouterInterface.d.ts +58 -0
- package/dist/src/core/contracts/RouterInterface.d.ts.map +1 -0
- package/dist/src/core/contracts/RouterInterface.js +2 -0
- package/dist/src/core/contracts/RouterInterface.js.map +1 -0
- package/dist/src/core/contracts/ServiceProviderInterface.d.ts +12 -0
- package/dist/src/core/contracts/ServiceProviderInterface.d.ts.map +1 -0
- package/dist/src/core/contracts/ServiceProviderInterface.js +2 -0
- package/dist/src/core/contracts/ServiceProviderInterface.js.map +1 -0
- package/dist/src/core/contracts/StorageServiceInterface.d.ts +43 -0
- package/dist/src/core/contracts/StorageServiceInterface.d.ts.map +1 -0
- package/dist/src/core/contracts/StorageServiceInterface.js +3 -0
- package/dist/src/core/contracts/StorageServiceInterface.js.map +1 -0
- package/dist/src/core/contracts/StoreServiceInterface.d.ts +45 -0
- package/dist/src/core/contracts/StoreServiceInterface.d.ts.map +1 -0
- package/dist/src/core/contracts/StoreServiceInterface.js +3 -0
- package/dist/src/core/contracts/StoreServiceInterface.js.map +1 -0
- package/dist/src/core/contracts/ViewCacheInterface.d.ts +13 -0
- package/dist/src/core/contracts/ViewCacheInterface.d.ts.map +1 -0
- package/dist/src/core/contracts/ViewCacheInterface.js +3 -0
- package/dist/src/core/contracts/ViewCacheInterface.js.map +1 -0
- package/dist/src/core/contracts/ViewControllerInterface.d.ts +115 -0
- package/dist/src/core/contracts/ViewControllerInterface.d.ts.map +1 -0
- package/dist/src/core/contracts/ViewControllerInterface.js +2 -0
- package/dist/src/core/contracts/ViewControllerInterface.js.map +1 -0
- package/dist/src/core/contracts/ViewInterface.d.ts +24 -0
- package/dist/src/core/contracts/ViewInterface.d.ts.map +1 -0
- package/dist/src/core/contracts/ViewInterface.js +2 -0
- package/dist/src/core/contracts/ViewInterface.js.map +1 -0
- package/dist/src/core/contracts/ViewManagerInterface.d.ts +44 -0
- package/dist/src/core/contracts/ViewManagerInterface.d.ts.map +1 -0
- package/dist/src/core/contracts/ViewManagerInterface.js +2 -0
- package/dist/src/core/contracts/ViewManagerInterface.js.map +1 -0
- package/dist/src/core/contracts/ViewStateInterface.d.ts +40 -0
- package/dist/src/core/contracts/ViewStateInterface.d.ts.map +1 -0
- package/dist/src/core/contracts/ViewStateInterface.js +3 -0
- package/dist/src/core/contracts/ViewStateInterface.js.map +1 -0
- package/dist/src/core/contracts/common.d.ts +28 -0
- package/dist/src/core/contracts/common.d.ts.map +1 -0
- package/dist/src/core/contracts/common.js +29 -0
- package/dist/src/core/contracts/common.js.map +1 -0
- package/dist/src/core/contracts/utils.d.ts +20 -0
- package/dist/src/core/contracts/utils.d.ts.map +1 -0
- package/dist/src/core/contracts/utils.js +4 -0
- package/dist/src/core/contracts/utils.js.map +1 -0
- package/dist/src/core/contracts/views.d.ts +23 -0
- package/dist/src/core/contracts/views.d.ts.map +1 -0
- package/dist/src/core/contracts/views.js +2 -0
- package/dist/src/core/contracts/views.js.map +1 -0
- package/dist/src/core/elements/Block.d.ts +58 -0
- package/dist/src/core/elements/Block.d.ts.map +1 -0
- package/dist/src/core/elements/Block.js +77 -0
- package/dist/src/core/elements/Block.js.map +1 -0
- package/dist/src/core/elements/BlockOutlet.d.ts +34 -0
- package/dist/src/core/elements/BlockOutlet.d.ts.map +1 -0
- package/dist/src/core/elements/BlockOutlet.js +59 -0
- package/dist/src/core/elements/BlockOutlet.js.map +1 -0
- package/dist/src/core/elements/Component.d.ts +62 -0
- package/dist/src/core/elements/Component.d.ts.map +1 -0
- package/dist/src/core/elements/Component.js +72 -0
- package/dist/src/core/elements/Component.js.map +1 -0
- package/dist/src/core/elements/ElementManager.d.ts +23 -0
- package/dist/src/core/elements/ElementManager.d.ts.map +1 -0
- package/dist/src/core/elements/ElementManager.js +33 -0
- package/dist/src/core/elements/ElementManager.js.map +1 -0
- package/dist/src/core/elements/Fragment.d.ts +51 -0
- package/dist/src/core/elements/Fragment.d.ts.map +1 -0
- package/dist/src/core/elements/Fragment.js +133 -0
- package/dist/src/core/elements/Fragment.js.map +1 -0
- package/dist/src/core/elements/Html.d.ts +52 -0
- package/dist/src/core/elements/Html.d.ts.map +1 -0
- package/dist/src/core/elements/Html.js +299 -0
- package/dist/src/core/elements/Html.js.map +1 -0
- package/dist/src/core/elements/Output.d.ts +69 -0
- package/dist/src/core/elements/Output.d.ts.map +1 -0
- package/dist/src/core/elements/Output.js +121 -0
- package/dist/src/core/elements/Output.js.map +1 -0
- package/dist/src/core/elements/Reactive.d.ts +77 -0
- package/dist/src/core/elements/Reactive.d.ts.map +1 -0
- package/dist/src/core/elements/Reactive.js +199 -0
- package/dist/src/core/elements/Reactive.js.map +1 -0
- package/dist/src/core/elements/TextElement.d.ts +46 -0
- package/dist/src/core/elements/TextElement.d.ts.map +1 -0
- package/dist/src/core/elements/TextElement.js +94 -0
- package/dist/src/core/elements/TextElement.js.map +1 -0
- package/dist/src/core/elements/Wrapper.d.ts +50 -0
- package/dist/src/core/elements/Wrapper.d.ts.map +1 -0
- package/dist/src/core/elements/Wrapper.js +96 -0
- package/dist/src/core/elements/Wrapper.js.map +1 -0
- package/dist/src/core/elements/Yield.d.ts +34 -0
- package/dist/src/core/elements/Yield.d.ts.map +1 -0
- package/dist/src/core/elements/Yield.js +56 -0
- package/dist/src/core/elements/Yield.js.map +1 -0
- package/dist/src/core/elements/helpers.d.ts +8 -0
- package/dist/src/core/elements/helpers.d.ts.map +1 -0
- package/dist/src/core/elements/helpers.js +40 -0
- package/dist/src/core/elements/helpers.js.map +1 -0
- package/dist/src/core/elements/index.d.ts +12 -0
- package/dist/src/core/elements/index.d.ts.map +1 -0
- package/dist/src/core/elements/index.js +12 -0
- package/dist/src/core/elements/index.js.map +1 -0
- package/dist/src/core/hellpers/ApiClient.d.ts +58 -0
- package/dist/src/core/hellpers/ApiClient.d.ts.map +1 -0
- package/dist/src/core/hellpers/ApiClient.js +122 -0
- package/dist/src/core/hellpers/ApiClient.js.map +1 -0
- package/dist/src/core/hellpers/app.d.ts +3 -0
- package/dist/src/core/hellpers/app.d.ts.map +1 -0
- package/dist/src/core/hellpers/app.js +53 -0
- package/dist/src/core/hellpers/app.js.map +1 -0
- package/dist/src/core/hellpers/utils.d.ts +26 -0
- package/dist/src/core/hellpers/utils.d.ts.map +1 -0
- package/dist/src/core/hellpers/utils.js +96 -0
- package/dist/src/core/hellpers/utils.js.map +1 -0
- package/dist/src/core/routers/Router.d.ts +212 -0
- package/dist/src/core/routers/Router.d.ts.map +1 -0
- package/dist/src/core/routers/Router.js +623 -0
- package/dist/src/core/routers/Router.js.map +1 -0
- package/dist/src/core/routers/index.d.ts +3 -0
- package/dist/src/core/routers/index.d.ts.map +1 -0
- package/dist/src/core/routers/index.js +2 -0
- package/dist/src/core/routers/index.js.map +1 -0
- package/dist/src/core/services/BlockManager.d.ts +63 -0
- package/dist/src/core/services/BlockManager.d.ts.map +1 -0
- package/dist/src/core/services/BlockManager.js +191 -0
- package/dist/src/core/services/BlockManager.js.map +1 -0
- package/dist/src/core/services/DomService.d.ts +9 -0
- package/dist/src/core/services/DomService.d.ts.map +1 -0
- package/dist/src/core/services/DomService.js +18 -0
- package/dist/src/core/services/DomService.js.map +1 -0
- package/dist/src/core/services/EventService.d.ts +58 -0
- package/dist/src/core/services/EventService.d.ts.map +1 -0
- package/dist/src/core/services/EventService.js +212 -0
- package/dist/src/core/services/EventService.js.map +1 -0
- package/dist/src/core/services/HelperService.d.ts +443 -0
- package/dist/src/core/services/HelperService.d.ts.map +1 -0
- package/dist/src/core/services/HelperService.js +1650 -0
- package/dist/src/core/services/HelperService.js.map +1 -0
- package/dist/src/core/services/HttpService.d.ts +63 -0
- package/dist/src/core/services/HttpService.d.ts.map +1 -0
- package/dist/src/core/services/HttpService.js +182 -0
- package/dist/src/core/services/HttpService.js.map +1 -0
- package/dist/src/core/services/LoggerService.d.ts +56 -0
- package/dist/src/core/services/LoggerService.d.ts.map +1 -0
- package/dist/src/core/services/LoggerService.js +94 -0
- package/dist/src/core/services/LoggerService.js.map +1 -0
- package/dist/src/core/services/MarkerRegistry.d.ts +94 -0
- package/dist/src/core/services/MarkerRegistry.d.ts.map +1 -0
- package/dist/src/core/services/MarkerRegistry.js +199 -0
- package/dist/src/core/services/MarkerRegistry.js.map +1 -0
- package/dist/src/core/services/MarkerService.d.ts +299 -0
- package/dist/src/core/services/MarkerService.d.ts.map +1 -0
- package/dist/src/core/services/MarkerService.js +723 -0
- package/dist/src/core/services/MarkerService.js.map +1 -0
- package/dist/src/core/services/StorageService.d.ts +69 -0
- package/dist/src/core/services/StorageService.d.ts.map +1 -0
- package/dist/src/core/services/StorageService.js +243 -0
- package/dist/src/core/services/StorageService.js.map +1 -0
- package/dist/src/core/services/StoreService.d.ts +80 -0
- package/dist/src/core/services/StoreService.d.ts.map +1 -0
- package/dist/src/core/services/StoreService.js +301 -0
- package/dist/src/core/services/StoreService.js.map +1 -0
- package/dist/src/core/services/index.d.ts +9 -0
- package/dist/src/core/services/index.d.ts.map +1 -0
- package/dist/src/core/services/index.js +9 -0
- package/dist/src/core/services/index.js.map +1 -0
- package/dist/src/core/types/utils.d.ts +29 -0
- package/dist/src/core/types/utils.d.ts.map +1 -0
- package/dist/src/core/types/utils.js +22 -0
- package/dist/src/core/types/utils.js.map +1 -0
- package/dist/src/core/view/LoopContext.d.ts +38 -0
- package/dist/src/core/view/LoopContext.d.ts.map +1 -0
- package/dist/src/core/view/LoopContext.js +100 -0
- package/dist/src/core/view/LoopContext.js.map +1 -0
- package/dist/src/core/view/Section.d.ts +41 -0
- package/dist/src/core/view/Section.d.ts.map +1 -0
- package/dist/src/core/view/Section.js +67 -0
- package/dist/src/core/view/Section.js.map +1 -0
- package/dist/src/core/view/View.d.ts +63 -0
- package/dist/src/core/view/View.d.ts.map +1 -0
- package/dist/src/core/view/View.js +85 -0
- package/dist/src/core/view/View.js.map +1 -0
- package/dist/src/core/view/ViewController.d.ts +277 -0
- package/dist/src/core/view/ViewController.d.ts.map +1 -0
- package/dist/src/core/view/ViewController.js +862 -0
- package/dist/src/core/view/ViewController.js.map +1 -0
- package/dist/src/core/view/ViewManager.d.ts +141 -0
- package/dist/src/core/view/ViewManager.d.ts.map +1 -0
- package/dist/src/core/view/ViewManager.js +565 -0
- package/dist/src/core/view/ViewManager.js.map +1 -0
- package/dist/src/core/view/ViewState.d.ts +117 -0
- package/dist/src/core/view/ViewState.d.ts.map +1 -0
- package/dist/src/core/view/ViewState.js +410 -0
- package/dist/src/core/view/ViewState.js.map +1 -0
- package/dist/src/core/view/index.d.ts +6 -0
- package/dist/src/core/view/index.d.ts.map +1 -0
- package/dist/src/core/view/index.js +6 -0
- package/dist/src/core/view/index.js.map +1 -0
- package/index.ts +62 -0
- package/package.json +70 -0
- package/plugins.ts +77 -0
- package/src/core/app/Application.ts +410 -0
- package/src/core/bootstrap/app.ts +58 -0
- package/src/core/bootstrap/providers/ApiServiceProvider.ts +18 -0
- package/src/core/bootstrap/providers/CoreServiceProvider.ts +19 -0
- package/src/core/bootstrap/providers/HelperServiceProvider.ts +12 -0
- package/src/core/bootstrap/providers/RouteServiceProvider.ts +17 -0
- package/src/core/bootstrap/providers/ServiceProvider.ts +51 -0
- package/src/core/bootstrap/providers/ViewServiceProvider.ts +17 -0
- package/src/core/bootstrap/providers/default-providers.ts +94 -0
- package/src/core/bootstrap/providers/index.ts +9 -0
- package/src/core/bootstrap/providers/provider-order.test.ts +67 -0
- package/src/core/bootstrap/providers/provider-order.ts +66 -0
- package/src/core/cache/ViewCache.ts +102 -0
- package/src/core/cache/index.ts +1 -0
- package/src/core/contracts/ApiInterface.ts +11 -0
- package/src/core/contracts/ApplicationInterface.ts +79 -0
- package/src/core/contracts/BlockInterface.ts +76 -0
- package/src/core/contracts/ComponentInterface.ts +26 -0
- package/src/core/contracts/ElementInterface.ts +140 -0
- package/src/core/contracts/EventServiceInterface.ts +47 -0
- package/src/core/contracts/HelperInterface.ts +256 -0
- package/src/core/contracts/HttpServiceInterface.ts +51 -0
- package/src/core/contracts/LoggerServiceInterface.ts +48 -0
- package/src/core/contracts/LoopContextInterface.ts +15 -0
- package/src/core/contracts/MarkerInterface.ts +77 -0
- package/src/core/contracts/ReactiveInterface.ts +45 -0
- package/src/core/contracts/RouterInterface.ts +65 -0
- package/src/core/contracts/ServiceProviderInterface.ts +12 -0
- package/src/core/contracts/StorageServiceInterface.ts +48 -0
- package/src/core/contracts/StoreServiceInterface.ts +50 -0
- package/src/core/contracts/ViewCacheInterface.ts +14 -0
- package/src/core/contracts/ViewControllerInterface.ts +135 -0
- package/src/core/contracts/ViewInterface.ts +31 -0
- package/src/core/contracts/ViewManagerInterface.ts +45 -0
- package/src/core/contracts/ViewStateInterface.ts +47 -0
- package/src/core/contracts/common.ts +27 -0
- package/src/core/contracts/utils.ts +23 -0
- package/src/core/contracts/views.ts +23 -0
- package/src/core/elements/Block.ts +113 -0
- package/src/core/elements/BlockOutlet.ts +83 -0
- package/src/core/elements/Component.ts +114 -0
- package/src/core/elements/ElementManager.ts +48 -0
- package/src/core/elements/Fragment.ts +168 -0
- package/src/core/elements/Html.ts +364 -0
- package/src/core/elements/Output.ts +167 -0
- package/src/core/elements/Reactive.ts +253 -0
- package/src/core/elements/TextElement.ts +110 -0
- package/src/core/elements/Wrapper.ts +131 -0
- package/src/core/elements/Yield.ts +70 -0
- package/src/core/elements/helpers.ts +56 -0
- package/src/core/elements/index.ts +26 -0
- package/src/core/hellpers/ApiClient.ts +145 -0
- package/src/core/hellpers/app.ts +57 -0
- package/src/core/hellpers/utils.ts +109 -0
- package/src/core/routers/Router.ts +765 -0
- package/src/core/routers/index.ts +2 -0
- package/src/core/services/BlockManager.ts +210 -0
- package/src/core/services/DomService.ts +26 -0
- package/src/core/services/EventService.ts +266 -0
- package/src/core/services/HelperService.ts +1653 -0
- package/src/core/services/HttpService.ts +235 -0
- package/src/core/services/LoggerService.ts +139 -0
- package/src/core/services/MarkerRegistry.ts +239 -0
- package/src/core/services/MarkerService.ts +923 -0
- package/src/core/services/StorageService.ts +268 -0
- package/src/core/services/StoreService.ts +338 -0
- package/src/core/services/index.ts +8 -0
- package/src/core/types/utils.ts +30 -0
- package/src/core/view/LoopContext.ts +109 -0
- package/src/core/view/Section.ts +86 -0
- package/src/core/view/View.ts +109 -0
- package/src/core/view/ViewController.ts +1002 -0
- package/src/core/view/ViewManager.ts +700 -0
- package/src/core/view/ViewState.ts +453 -0
- package/src/core/view/index.ts +5 -0
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { InitMode, InitModes } from "../contracts/common";
|
|
2
|
+
import type { HtmlInterface, OneChildrenFactoryOutput, OneElementChildren } from "../contracts/ElementInterface";
|
|
3
|
+
import type { ReactiveInterface, ReactiveChildrenFactory, ReactiveRenderFn } from "../contracts/ReactiveInterface";
|
|
4
|
+
import type { ViewControllerInterface } from "../contracts/ViewControllerInterface";
|
|
5
|
+
import { generateUUID } from "../hellpers/utils";
|
|
6
|
+
import markerRegistry from "../services/MarkerRegistry";
|
|
7
|
+
import type { OneObjectType } from "../types/utils";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Reactive — a region in the DOM bounded by comment markers that
|
|
11
|
+
* can re-render its content when reactive dependencies change.
|
|
12
|
+
*
|
|
13
|
+
* Use cases:
|
|
14
|
+
* - o-if / o-show conditional rendering
|
|
15
|
+
* - o-for list rendering
|
|
16
|
+
* - @useBlock(name) slot mounting
|
|
17
|
+
* - Any expression binding that affects DOM structure
|
|
18
|
+
*
|
|
19
|
+
* The open/close comment markers stay in place; only the content
|
|
20
|
+
* between them is replaced on re-render. This avoids the need to
|
|
21
|
+
* scan/diff the entire DOM tree.
|
|
22
|
+
*/
|
|
23
|
+
export class Reactive implements ReactiveInterface {
|
|
24
|
+
static class = 'Reactive';
|
|
25
|
+
oneType: OneObjectType = 'Reactive';
|
|
26
|
+
public id: string; // Unique ID for debugging and marker registry
|
|
27
|
+
public type: string; // Custom type for different reactive behaviors (e.g. 'if', 'list')
|
|
28
|
+
public openTag: Comment;
|
|
29
|
+
public closeTag: Comment;
|
|
30
|
+
public parentElement: HtmlInterface | null;
|
|
31
|
+
public parentReactive: ReactiveInterface | null;
|
|
32
|
+
public parent: HtmlInterface | null = null; // Alias for parentReactive to satisfy OneNodeInterface
|
|
33
|
+
|
|
34
|
+
public ctx: ViewControllerInterface;
|
|
35
|
+
public childrenFactory: ReactiveChildrenFactory;
|
|
36
|
+
public children: OneElementChildren = [];
|
|
37
|
+
private mounted: boolean = false;
|
|
38
|
+
public stateKeys: string[];
|
|
39
|
+
public unsubscribe: () => void = () => {};
|
|
40
|
+
private _isStarted = false;
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
domChildren: Node[] = []; // For compatibility with HtmlInterface; Reactive itself doesn't have a single root element
|
|
45
|
+
initMode: InitMode = InitModes.CREATE;
|
|
46
|
+
constructor({
|
|
47
|
+
type = 'reactive',
|
|
48
|
+
id = null,
|
|
49
|
+
ctx,
|
|
50
|
+
parentElement = null,
|
|
51
|
+
parentReactive = null,
|
|
52
|
+
stateKeys = [],
|
|
53
|
+
childrenFactory = () => [],
|
|
54
|
+
initMode = InitModes.CREATE,
|
|
55
|
+
}: {
|
|
56
|
+
id?: string | null;
|
|
57
|
+
type?: string;
|
|
58
|
+
ctx: ViewControllerInterface;
|
|
59
|
+
parentElement?: HtmlInterface | null;
|
|
60
|
+
parentReactive?: ReactiveInterface | null;
|
|
61
|
+
stateKeys?: string[];
|
|
62
|
+
childrenFactory: ReactiveChildrenFactory;
|
|
63
|
+
initMode?: InitMode;
|
|
64
|
+
}) {
|
|
65
|
+
this.ctx = ctx;
|
|
66
|
+
this.parentElement = parentElement;
|
|
67
|
+
this.parentReactive = parentReactive;
|
|
68
|
+
this.id = `${ctx.viewId}-${id || generateUUID(5)}`;
|
|
69
|
+
this.type = type;
|
|
70
|
+
this.childrenFactory = childrenFactory;
|
|
71
|
+
this.stateKeys = stateKeys;
|
|
72
|
+
this.initMode = initMode;
|
|
73
|
+
markerRegistry.register('reactive', this.id, {
|
|
74
|
+
type: this.type,
|
|
75
|
+
stateKeys: this.stateKeys,
|
|
76
|
+
viewID: this.ctx.viewId,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
this.openTag = markerRegistry.createMarkerStart('reactive', this.id);
|
|
80
|
+
this.closeTag = markerRegistry.createMarkerEnd('reactive', this.id);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
setParentElement(parent: HtmlInterface | null): void {
|
|
84
|
+
this.parentElement = parent;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
setChildrenFactory(factory: ReactiveChildrenFactory): void {
|
|
88
|
+
this.childrenFactory = factory;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
setStateKeys(stateKeys: string[]): void {
|
|
92
|
+
this.stateKeys = stateKeys;
|
|
93
|
+
// If already started, we need to resubscribe with new keys
|
|
94
|
+
if (this._isStarted) {
|
|
95
|
+
this.stop();
|
|
96
|
+
this.start();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Mount markers into parent and render content */
|
|
101
|
+
render(): void {
|
|
102
|
+
const target = this.getInsertionTarget();
|
|
103
|
+
if (!target) return;
|
|
104
|
+
|
|
105
|
+
if (!this.mounted) {
|
|
106
|
+
// First render: place markers
|
|
107
|
+
if (this.parentReactive) {
|
|
108
|
+
// Insert before the parent's close marker
|
|
109
|
+
target.insertBefore(this.openTag, this.parentReactive.closeTag);
|
|
110
|
+
target.insertBefore(this.closeTag, this.parentReactive.closeTag);
|
|
111
|
+
} else {
|
|
112
|
+
target.appendChild(this.openTag);
|
|
113
|
+
target.appendChild(this.closeTag);
|
|
114
|
+
}
|
|
115
|
+
this.mounted = true;
|
|
116
|
+
} else {
|
|
117
|
+
// Re-render: clear existing content between markers
|
|
118
|
+
this.clearContent();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Produce children
|
|
122
|
+
const output: OneChildrenFactoryOutput = this.childrenFactory(this, this.parentElement);
|
|
123
|
+
|
|
124
|
+
// Insert children between markers
|
|
125
|
+
for (const child of output) {
|
|
126
|
+
if (typeof child === 'string' || typeof child === 'number') {
|
|
127
|
+
const textNode = document.createTextNode(String(child));
|
|
128
|
+
this.insertBeforeClose(textNode);
|
|
129
|
+
this.children.push(textNode);
|
|
130
|
+
} else if (child && typeof child === 'object') {
|
|
131
|
+
if ('element' in child) {
|
|
132
|
+
// HtmlInterface, TextInterface, FragmentInterface
|
|
133
|
+
this.insertBeforeClose(child.element);
|
|
134
|
+
this.children.push(child);
|
|
135
|
+
child.render();
|
|
136
|
+
} else if ('openTag' in child) {
|
|
137
|
+
// Nested Reactive
|
|
138
|
+
this.children.push(child);
|
|
139
|
+
child.render();
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Schedule a re-render through the ViewController */
|
|
146
|
+
update(): void {
|
|
147
|
+
this.ctx.scheduleUpdate(this);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** Clear all DOM nodes between the open and close markers */
|
|
151
|
+
private clearContent(): void {
|
|
152
|
+
// Destroy managed children first
|
|
153
|
+
for (const child of this.children) {
|
|
154
|
+
if (child && typeof child === 'object' && 'destroy' in child) {
|
|
155
|
+
child.destroy();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
this.children = [];
|
|
159
|
+
|
|
160
|
+
// Remove DOM nodes between markers
|
|
161
|
+
let current = this.openTag.nextSibling;
|
|
162
|
+
while (current && current !== this.closeTag) {
|
|
163
|
+
const next = current.nextSibling;
|
|
164
|
+
current.remove();
|
|
165
|
+
current = next;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** Insert a node just before the close marker */
|
|
170
|
+
private insertBeforeClose(node: Node): void {
|
|
171
|
+
this.closeTag.parentNode?.insertBefore(node, this.closeTag);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** Determine the actual DOM element to insert into */
|
|
175
|
+
private getInsertionTarget(): HTMLElement | null {
|
|
176
|
+
if (this.parentElement) {
|
|
177
|
+
return this.parentElement.element;
|
|
178
|
+
}
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** Start — subscribe to stateKeys and recursively start children.
|
|
183
|
+
* Called during START phase of view lifecycle. */
|
|
184
|
+
start(): void {
|
|
185
|
+
if (this._isStarted) return;
|
|
186
|
+
this._isStarted = true;
|
|
187
|
+
|
|
188
|
+
// Subscribe to state changes → schedule re-render
|
|
189
|
+
if (this.stateKeys.length > 0) {
|
|
190
|
+
this.unsubscribe = this.ctx.states.__.subscribe(
|
|
191
|
+
this.stateKeys,
|
|
192
|
+
() => this.update()
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// Recursively start children
|
|
197
|
+
for (const child of this.children) {
|
|
198
|
+
if (child && typeof child === 'object' && 'start' in child && typeof (child as any).start === 'function') {
|
|
199
|
+
(child as any).start();
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/** Stop — unsubscribe and recursively stop children. */
|
|
205
|
+
stop(): void {
|
|
206
|
+
if (!this._isStarted) return;
|
|
207
|
+
this._isStarted = false;
|
|
208
|
+
|
|
209
|
+
if (this.unsubscribe) {
|
|
210
|
+
this.unsubscribe();
|
|
211
|
+
this.unsubscribe = () => {};
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// Recursively stop children
|
|
215
|
+
for (const child of this.children) {
|
|
216
|
+
if (child && typeof child === 'object' && 'stop' in child && typeof (child as any).stop === 'function') {
|
|
217
|
+
(child as any).stop();
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/** Remove content but keep markers (for hide/show scenarios) */
|
|
223
|
+
hide(): void {
|
|
224
|
+
this.clearContent();
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/** Re-render content (for show after hide) */
|
|
228
|
+
show(): void {
|
|
229
|
+
this.render();
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
destroy(): void {
|
|
233
|
+
this.clearContent();
|
|
234
|
+
this.openTag.remove();
|
|
235
|
+
this.closeTag.remove();
|
|
236
|
+
this.mounted = false;
|
|
237
|
+
this.parentElement = null;
|
|
238
|
+
this.parentReactive = null;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
get isOneReactive(): boolean {
|
|
242
|
+
return true;
|
|
243
|
+
}
|
|
244
|
+
set isOneReactive(value: boolean) {
|
|
245
|
+
// No-op setter to satisfy the Interface; this property is always true for Reactive elements
|
|
246
|
+
}
|
|
247
|
+
set isOneElement(value: boolean) {
|
|
248
|
+
// No-op setter to satisfy the Interface; Reactive is a type of OneElement
|
|
249
|
+
}
|
|
250
|
+
get isOneElement(): boolean {
|
|
251
|
+
return true;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { HtmlInterface, TextInterface } from "../contracts/ElementInterface";
|
|
2
|
+
import type { ViewControllerInterface } from "../contracts/ViewControllerInterface";
|
|
3
|
+
import { escapeHTML } from "../hellpers/utils";
|
|
4
|
+
import { OneObjectType } from "../types/utils";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* TextElement — wraps a DOM Text node.
|
|
8
|
+
*
|
|
9
|
+
* Supports reactive text updates without re-creating the node.
|
|
10
|
+
* When `update(newText)` is called, only the textContent changes —
|
|
11
|
+
* no DOM removal/insertion needed.
|
|
12
|
+
*/
|
|
13
|
+
export class TextElement implements TextInterface {
|
|
14
|
+
oneType: OneObjectType = 'TextElement';
|
|
15
|
+
public element: Text;
|
|
16
|
+
public parent: HtmlInterface | null;
|
|
17
|
+
private ctx: ViewControllerInterface;
|
|
18
|
+
private statekeys: string[] = [];
|
|
19
|
+
private unsubscribe: (() => void) | null = null;
|
|
20
|
+
protected generateText: () => string = () => this._text;
|
|
21
|
+
public _text: string = '';
|
|
22
|
+
public shouldEscapeHTML: boolean = true; // Whether to escape HTML in text content
|
|
23
|
+
|
|
24
|
+
public isStarted: boolean = false;
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
domChildren: Node[] = []; // For compatibility with HtmlInterface; Text itself doesn't have a single root element
|
|
28
|
+
constructor({ ctx, parent = null, stateKeys = [], generateText = () => '', isEscapeHTML = true }: { ctx: ViewControllerInterface, parent?: HtmlInterface | null, stateKeys?: string[], generateText?: () => string, isEscapeHTML?: boolean }) {
|
|
29
|
+
this.ctx = ctx;
|
|
30
|
+
this.generateText = generateText;
|
|
31
|
+
this.parent = parent;
|
|
32
|
+
this.statekeys = stateKeys;
|
|
33
|
+
this.shouldEscapeHTML = isEscapeHTML;
|
|
34
|
+
this._text = this.generateText();
|
|
35
|
+
if (this.shouldEscapeHTML) {
|
|
36
|
+
this._text = escapeHTML(this._text);
|
|
37
|
+
}
|
|
38
|
+
this.element = document.createTextNode(this._text);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Start reactive text updates */
|
|
42
|
+
start(): void {
|
|
43
|
+
if (this.isStarted) return;
|
|
44
|
+
this.isStarted = true;
|
|
45
|
+
if (this.statekeys.length > 0) {
|
|
46
|
+
this.unsubscribe = this.ctx.states.__.subscribe(this.statekeys, (newText: string) => {
|
|
47
|
+
this.update(this.generateText());
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
stop(): void {
|
|
52
|
+
if (!this.isStarted) return;
|
|
53
|
+
this.isStarted = false;
|
|
54
|
+
if (this.unsubscribe) {
|
|
55
|
+
this.unsubscribe();
|
|
56
|
+
this.unsubscribe = null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
setParentElement(parent: HtmlInterface | null): void {
|
|
60
|
+
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Update text content in-place */
|
|
64
|
+
update(newText: string): void {
|
|
65
|
+
if (this._text !== newText) {
|
|
66
|
+
this._text = newText;
|
|
67
|
+
this.element.textContent = this.shouldEscapeHTML ? escapeHTML(newText) : newText;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
render(): void {
|
|
72
|
+
if (this.parent && this.parent.element) {
|
|
73
|
+
this.parent.element.appendChild(this.element);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
remove(): void {
|
|
78
|
+
this.element.remove();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
destroy(): void {
|
|
82
|
+
if (this.unsubscribe) {
|
|
83
|
+
this.unsubscribe();
|
|
84
|
+
this.unsubscribe = null;
|
|
85
|
+
}
|
|
86
|
+
this.element.remove();
|
|
87
|
+
this.parent = null;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
get text(): string {
|
|
91
|
+
return this._text;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
set text(newText: string) {
|
|
95
|
+
this.update(newText);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
get isOneElement(): boolean {
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
set isOneElement(value: boolean) {
|
|
102
|
+
// No-op setter to satisfy the Interface; this property is always true for Text elements
|
|
103
|
+
}
|
|
104
|
+
get isOneText(): boolean {
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
set isOneText(value: boolean) {
|
|
108
|
+
// No-op setter to satisfy the Interface; this property is always true for Text elements
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { InitMode, InitModes } from "../contracts/common";
|
|
2
|
+
import type { FragmentInterface, HtmlInterface, OneChildrenFactory, OneChildrenFactoryOutput, OneElementChildren, WrapperInterface } from "../contracts/ElementInterface";
|
|
3
|
+
import type { ViewControllerInterface } from "../contracts/ViewControllerInterface";
|
|
4
|
+
import { generateUUID } from "../hellpers/utils";
|
|
5
|
+
import type { OneObjectType } from "../types/utils";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Wrapper — renders multiple root nodes into a parent without a wrapping tag.
|
|
9
|
+
*
|
|
10
|
+
* Use case: when a ViewController's render() returns multiple sibling elements
|
|
11
|
+
* (e.g. `<h1>` + `<p>` + `<div>`) without a single root wrapper.
|
|
12
|
+
*
|
|
13
|
+
* Wrapper uses open/close Comment markers to track its region in the DOM,
|
|
14
|
+
* similar to Reactive but without the reactivity overhead.
|
|
15
|
+
*/
|
|
16
|
+
export class Wrapper implements WrapperInterface {
|
|
17
|
+
oneType: OneObjectType = 'Wrapper';
|
|
18
|
+
public parent: HtmlInterface | null;
|
|
19
|
+
public nodes: Node[] = [];
|
|
20
|
+
/** Tracked child element wrappers (Html, Output, Reactive, TextElement, etc.) */
|
|
21
|
+
public children: OneElementChildren = [];
|
|
22
|
+
private ctx: ViewControllerInterface;
|
|
23
|
+
private childrenFactory: OneChildrenFactory;
|
|
24
|
+
public openTag: Comment;
|
|
25
|
+
public closeTag: Comment;
|
|
26
|
+
public id: string; // Unique ID for debugging and marker registry
|
|
27
|
+
public initMode: InitMode = InitModes.CREATE;
|
|
28
|
+
|
|
29
|
+
domChildren: Node[] = []; // For compatibility with HtmlInterface; Wrapper itself doesn't have a single root element
|
|
30
|
+
|
|
31
|
+
constructor({
|
|
32
|
+
ctx,
|
|
33
|
+
initMode = InitModes.CREATE,
|
|
34
|
+
parentElement = null,
|
|
35
|
+
childrenFactory
|
|
36
|
+
}: {
|
|
37
|
+
ctx: ViewControllerInterface,
|
|
38
|
+
initMode?: InitMode,
|
|
39
|
+
parentElement?: HtmlInterface | null,
|
|
40
|
+
childrenFactory: OneChildrenFactory
|
|
41
|
+
}) {
|
|
42
|
+
this.ctx = ctx;
|
|
43
|
+
this.parent = parentElement;
|
|
44
|
+
this.childrenFactory = childrenFactory;
|
|
45
|
+
this.id = ctx.viewId;
|
|
46
|
+
this.initMode = initMode;
|
|
47
|
+
|
|
48
|
+
this.openTag = document.createComment('wrapper-start');
|
|
49
|
+
this.closeTag = document.createComment('wrapper-end');
|
|
50
|
+
|
|
51
|
+
}
|
|
52
|
+
setParentElement(parent: HtmlInterface | null): void {
|
|
53
|
+
this.parent = parent;
|
|
54
|
+
}
|
|
55
|
+
render(): void {
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
setChildrenFactory(factory: OneChildrenFactory): void {
|
|
60
|
+
this.childrenFactory = factory;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Hydrate lifecycle — reattach event listeners or perform other setup */
|
|
64
|
+
|
|
65
|
+
hydrate(): void {
|
|
66
|
+
for (const child of this.children) {
|
|
67
|
+
if ('hydrate' in child && typeof (child as any).hydrate === 'function') {
|
|
68
|
+
(child as any).hydrate();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Start lifecycle — recursively activate children's reactive subscriptions */
|
|
74
|
+
start(): void {
|
|
75
|
+
for (const child of this.children) {
|
|
76
|
+
if ('start' in child && typeof (child as any).start === 'function') {
|
|
77
|
+
(child as any).start();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Stop lifecycle — recursively deactivate children's reactive subscriptions */
|
|
83
|
+
stop(): void {
|
|
84
|
+
for (const child of this.children) {
|
|
85
|
+
if ('stop' in child && typeof (child as any).stop === 'function') {
|
|
86
|
+
(child as any).stop();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Remove all nodes between markers from the DOM */
|
|
92
|
+
clear(): void {
|
|
93
|
+
// Destroy managed children first
|
|
94
|
+
for (const child of this.children) {
|
|
95
|
+
if ('destroy' in child && typeof child.destroy === 'function') {
|
|
96
|
+
child.destroy();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
this.children = [];
|
|
100
|
+
|
|
101
|
+
// Remove remaining DOM nodes between markers
|
|
102
|
+
let current = this.openTag.nextSibling;
|
|
103
|
+
while (current && current !== this.closeTag) {
|
|
104
|
+
const next = current.nextSibling;
|
|
105
|
+
current.remove();
|
|
106
|
+
current = next;
|
|
107
|
+
}
|
|
108
|
+
this.nodes = [];
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
destroy(): void {
|
|
112
|
+
this.clear();
|
|
113
|
+
this.openTag.remove();
|
|
114
|
+
this.closeTag.remove();
|
|
115
|
+
this.parent = null;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
get isOneElement(): boolean {
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
set isOneElement(value: boolean) {
|
|
122
|
+
// No-op setter to satisfy the Interface; this property is always true for Fragment elements
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
get isOneFragment(): boolean {
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
set isOneFragment(value: boolean) {
|
|
129
|
+
// No-op setter to satisfy the Interface; this property is always true for Fragment elements
|
|
130
|
+
}
|
|
131
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { InitMode, InitModes } from "../contracts/common";
|
|
2
|
+
import { HtmlInterface, OneChildrenFactoryOutput, YieldInterface } from "../contracts/ElementInterface";
|
|
3
|
+
import { ViewControllerInterface } from "../contracts/ViewControllerInterface";
|
|
4
|
+
import { generateUUID } from "../hellpers/utils";
|
|
5
|
+
import { MarkerModel, OneMarker } from "../services/MarkerService";
|
|
6
|
+
import { OneObjectType } from "../types/utils";
|
|
7
|
+
|
|
8
|
+
export class YieldElement implements YieldInterface{
|
|
9
|
+
oneType: OneObjectType = "Yield";
|
|
10
|
+
ctx: ViewControllerInterface;
|
|
11
|
+
name: string
|
|
12
|
+
id: string;
|
|
13
|
+
contentFactory: () => OneChildrenFactoryOutput = () => [];
|
|
14
|
+
openTag!: Comment;
|
|
15
|
+
closeTag!: Comment;
|
|
16
|
+
initMode: InitMode = InitModes.CREATE
|
|
17
|
+
domChildren: Node[] = [];
|
|
18
|
+
parent: HtmlInterface | null = null;
|
|
19
|
+
defaultValue: string = '';
|
|
20
|
+
constructor({ctx, name = '', initMode = InitModes.CREATE, id = null, defaultValue = ''} : {ctx: ViewControllerInterface, name: string, initMode?: InitMode, id?: string | null, defaultValue?: string}) {
|
|
21
|
+
this.ctx = ctx;
|
|
22
|
+
this.name = name;
|
|
23
|
+
this.initMode = initMode;
|
|
24
|
+
this.id = id && id.length > 0 ? id : generateUUID();
|
|
25
|
+
this.defaultValue = defaultValue;
|
|
26
|
+
|
|
27
|
+
const yeildMarker: MarkerModel | null = (this.initMode === InitModes.HYDRATE) ? OneMarker.first('yield', this.id) : null;
|
|
28
|
+
if(yeildMarker){
|
|
29
|
+
this.openTag = yeildMarker.openTag;
|
|
30
|
+
this.closeTag = yeildMarker.closeTag;
|
|
31
|
+
this.domChildren = yeildMarker.nodes.map((el: Node) => el);
|
|
32
|
+
} else {
|
|
33
|
+
this.createMarkers();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
private createMarkers(){
|
|
38
|
+
const key = OneMarker.addRegistry('yield', this.id, {name: this.name});
|
|
39
|
+
this.openTag = OneMarker.createOpenMarker('yield', this.id);
|
|
40
|
+
this.closeTag = OneMarker.createCloseMarker('yield', this.id);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
setParentElement(parent: HtmlInterface | null): void {
|
|
44
|
+
this.parent = parent;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
setContentFactory(factory: () => OneChildrenFactoryOutput): void {
|
|
48
|
+
this.contentFactory = factory;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
render(): void {
|
|
52
|
+
if (!this.parent?.element) return;
|
|
53
|
+
|
|
54
|
+
const parentEl = this.parent.element;
|
|
55
|
+
parentEl.appendChild(this.openTag);
|
|
56
|
+
parentEl.appendChild(this.closeTag);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
destroy(): void {
|
|
60
|
+
this.openTag?.remove();
|
|
61
|
+
this.closeTag?.remove();
|
|
62
|
+
this.domChildren = [];
|
|
63
|
+
this.parent = null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
get isOneElement(): boolean { return true; }
|
|
67
|
+
set isOneElement(_: boolean) {}
|
|
68
|
+
get isOneYield(): boolean { return true; }
|
|
69
|
+
set isOneYield(_: boolean) {}
|
|
70
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { BlockInterface, BlockOutletInterface } from "../contracts/BlockInterface";
|
|
2
|
+
import { FragmentInterface, HtmlInterface, OutputInterface, OneChildrenFactoryOutput, OneElementChildren } from "../contracts/ElementInterface";
|
|
3
|
+
import { ReactiveInterface } from "../contracts/ReactiveInterface";
|
|
4
|
+
import { ViewControllerInterface } from "../contracts/ViewControllerInterface";
|
|
5
|
+
import { OneObjectType } from "../types/utils";
|
|
6
|
+
|
|
7
|
+
export function getOneObjectType(instance: any): OneObjectType | null {
|
|
8
|
+
if (instance && typeof instance === 'object' && 'oneType' in instance) {
|
|
9
|
+
return instance.oneType;
|
|
10
|
+
}
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function parseElementChildren(
|
|
15
|
+
oneElement: HtmlInterface | ReactiveInterface | BlockOutletInterface | OutputInterface | FragmentInterface | ViewControllerInterface,
|
|
16
|
+
parentElement: HTMLElement,
|
|
17
|
+
children: OneChildrenFactoryOutput
|
|
18
|
+
): OneElementChildren {
|
|
19
|
+
const parsedChildren: OneElementChildren = [];
|
|
20
|
+
|
|
21
|
+
if(!children || !Array.isArray(children)) {
|
|
22
|
+
console.warn('Children factory returned invalid output (not an array):', children);
|
|
23
|
+
return parsedChildren;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
children.forEach(child => {
|
|
27
|
+
if (typeof child === 'string' || typeof child === 'number') {
|
|
28
|
+
const textNode = document.createTextNode(String(child));
|
|
29
|
+
parsedChildren.push(textNode);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if(child instanceof Node) {
|
|
33
|
+
// Direct DOM node (e.g. from a third-party library) — append as-is
|
|
34
|
+
parsedChildren.push(child);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (!child || typeof child !== 'object' || child === null) {
|
|
38
|
+
// Skip invalid child types (null, undefined, non-objects, non-DOM nodes)
|
|
39
|
+
console.warn('Skipping invalid child:', child);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
let childType: OneObjectType = getOneObjectType(child);
|
|
43
|
+
if(!childType) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
switch (childType) {
|
|
47
|
+
case 'Html':
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
return parsedChildren;
|
|
56
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { BlockOutletInterface, BlockRenderFactory } from "../contracts/BlockInterface";
|
|
2
|
+
import type { HtmlInterface, HtmlElementConfig, OneChildrenFactory } from "../contracts/ElementInterface";
|
|
3
|
+
import type { ReactiveChildrenFactory } from "../contracts/ReactiveInterface";
|
|
4
|
+
import type { ViewControllerInterface } from "../contracts/ViewControllerInterface";
|
|
5
|
+
import { ViewController } from "../view";
|
|
6
|
+
import { Block } from "./Block";
|
|
7
|
+
import BlockManager from "../services/BlockManager";
|
|
8
|
+
import { BlockOutlet } from "./BlockOutlet";
|
|
9
|
+
import { Fragment } from "./Fragment";
|
|
10
|
+
import { Html } from "./Html";
|
|
11
|
+
import { Output } from "./Output";
|
|
12
|
+
import { Reactive } from "./Reactive";
|
|
13
|
+
import { TextElement } from "./TextElement";
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
export * from "./Block";
|
|
17
|
+
export * from "./BlockOutlet";
|
|
18
|
+
export * from './Component';
|
|
19
|
+
export * from "./ElementManager";
|
|
20
|
+
export * from "./Fragment";
|
|
21
|
+
export * from "./helpers";
|
|
22
|
+
export * from "./Html";
|
|
23
|
+
export * from "./Output";
|
|
24
|
+
export * from './Reactive';
|
|
25
|
+
export * from "./TextElement";
|
|
26
|
+
export * from "./Yield";
|