@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,364 @@
|
|
|
1
|
+
import { ESK, InitMode, InitModes } from "../contracts/common";
|
|
2
|
+
import type { HtmlInterface, OneChildrenFactory, OneChildrenFactoryOutput, OneElementChildren, OneElementConfig } from "../contracts/ElementInterface";
|
|
3
|
+
import type { ViewControllerInterface } from "../contracts/ViewControllerInterface";
|
|
4
|
+
import type { ViewManagerInterface } from "../contracts/ViewManagerInterface";
|
|
5
|
+
import { hasData } from "../hellpers/utils";
|
|
6
|
+
import type { OneObjectType } from "../types/utils";
|
|
7
|
+
|
|
8
|
+
export class Html implements HtmlInterface {
|
|
9
|
+
oneType: OneObjectType = 'Html';
|
|
10
|
+
public element: HTMLElement;
|
|
11
|
+
public parent: HtmlInterface | null;
|
|
12
|
+
private tagName: string;
|
|
13
|
+
private config: OneElementConfig;
|
|
14
|
+
private ctx: ViewControllerInterface | ViewManagerInterface;
|
|
15
|
+
private children: OneElementChildren = [];
|
|
16
|
+
|
|
17
|
+
public domChildren: Node[] = []; // For compatibility with HtmlInterface; Html itself doesn't have a single root element
|
|
18
|
+
private childrenFactory: OneChildrenFactory | null = null;
|
|
19
|
+
private abortController: AbortController = new AbortController();
|
|
20
|
+
|
|
21
|
+
/** All state subscriptions for reactive bindings — cleanup on destroy */
|
|
22
|
+
private bindingUnsubscribes: (() => void)[] = [];
|
|
23
|
+
public initMode: InitMode = InitModes.CREATE;
|
|
24
|
+
|
|
25
|
+
constructor({
|
|
26
|
+
ctx,
|
|
27
|
+
id = null,
|
|
28
|
+
parentElement = null,
|
|
29
|
+
tagName = 'div',
|
|
30
|
+
element = null,
|
|
31
|
+
config = {},
|
|
32
|
+
childrenFactory = null,
|
|
33
|
+
initMode = InitModes.CREATE,
|
|
34
|
+
}: {
|
|
35
|
+
ctx: ViewControllerInterface | ViewManagerInterface,
|
|
36
|
+
id?: string | null,
|
|
37
|
+
parentElement?: HtmlInterface | null,
|
|
38
|
+
tagName?: string,
|
|
39
|
+
element?: HTMLElement | null,
|
|
40
|
+
config?: OneElementConfig,
|
|
41
|
+
childrenFactory?: OneChildrenFactory | null,
|
|
42
|
+
initMode?: InitMode;
|
|
43
|
+
}) {
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
this.ctx = ctx;
|
|
47
|
+
this.parent = parentElement;
|
|
48
|
+
this.config = config;
|
|
49
|
+
this.tagName = tagName;
|
|
50
|
+
this.initMode = initMode;
|
|
51
|
+
const shouldHydrate = config.hydrate && initMode === InitModes.HYDRATE;
|
|
52
|
+
|
|
53
|
+
const onlySync = (initMode === InitModes.HYDRATE && config.element instanceof HTMLElement) || element instanceof HTMLElement;
|
|
54
|
+
if (onlySync) {
|
|
55
|
+
this.element = element || config.element as HTMLElement;
|
|
56
|
+
this.tagName = this.element.tagName.toLowerCase();
|
|
57
|
+
} else if (shouldHydrate && config.selector) {
|
|
58
|
+
const found = document.querySelector(`${tagName}[${ESK.ID}="${id}"]`) as HTMLElement | null;
|
|
59
|
+
if (found instanceof HTMLElement) {
|
|
60
|
+
this.element = found;
|
|
61
|
+
this.tagName = found.tagName.toLowerCase();
|
|
62
|
+
} else {
|
|
63
|
+
this.element = document.createElement(tagName);
|
|
64
|
+
this.element.setAttribute(ESK.ID, id || '');
|
|
65
|
+
console.warn(`[Html] Selector "${config.selector}" not found, created new <${tagName}>.`);
|
|
66
|
+
}
|
|
67
|
+
} else {
|
|
68
|
+
this.element = document.createElement(this.tagName);
|
|
69
|
+
this.element.setAttribute(ESK.ID, id || '');
|
|
70
|
+
if (shouldHydrate) {
|
|
71
|
+
console.warn(`[Html] No selector for hydration, created new <${tagName}>.`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
this.childrenFactory = childrenFactory;
|
|
78
|
+
this.initialize();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
updateConfig(newConfig: Partial<OneElementConfig>): void {
|
|
82
|
+
if(hasData(newConfig)){
|
|
83
|
+
this.config = { ...this.config, ...newConfig };
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
private initialize() {
|
|
88
|
+
this.initializeAttributes();
|
|
89
|
+
this.initializeClasses();
|
|
90
|
+
this.initializeStyles();
|
|
91
|
+
this.initializeEvents();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
private initializeAttributes() {
|
|
97
|
+
if (this.config.attrs) {
|
|
98
|
+
for (const [attrName, attrConfig] of Object.entries(this.config.attrs)) {
|
|
99
|
+
if (attrConfig.type === 'value') {
|
|
100
|
+
this.element.setAttribute(attrName, attrConfig.value);
|
|
101
|
+
} else if (attrConfig.type === 'binding') {
|
|
102
|
+
const value = attrConfig.factory ? attrConfig.factory() : '';
|
|
103
|
+
if (value !== undefined && value !== null && value !== false) {
|
|
104
|
+
this.element.setAttribute(attrName, String(value));
|
|
105
|
+
} else {
|
|
106
|
+
this.element.removeAttribute(attrName);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Reactive binding for attributes
|
|
110
|
+
if (attrConfig.stateKeys?.length) {
|
|
111
|
+
const unsubscribe = this.ctx.states.__.subscribe(
|
|
112
|
+
attrConfig.stateKeys,
|
|
113
|
+
() => {
|
|
114
|
+
const newValue = attrConfig.factory ? attrConfig.factory() : '';
|
|
115
|
+
if (newValue !== undefined && newValue !== null && newValue !== false) {
|
|
116
|
+
this.element.setAttribute(attrName, String(newValue));
|
|
117
|
+
} else {
|
|
118
|
+
this.element.removeAttribute(attrName);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
);
|
|
122
|
+
this.bindingUnsubscribes.push(unsubscribe);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (this.config.props) {
|
|
128
|
+
for (const [propName, propConfig] of Object.entries(this.config.props)) {
|
|
129
|
+
if (propConfig.type === 'value') {
|
|
130
|
+
(this.element as any)[propName] = propConfig.value;
|
|
131
|
+
} else if (propConfig.type === 'binding') {
|
|
132
|
+
const value = propConfig.factory ? propConfig.factory() : '';
|
|
133
|
+
if (value !== undefined && value !== null && value !== false) {
|
|
134
|
+
(this.element as any)[propName] = value;
|
|
135
|
+
} else {
|
|
136
|
+
(this.element as any)[propName] = false;
|
|
137
|
+
delete (this.element as any)[propName];
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Reactive binding for properties
|
|
141
|
+
if (propConfig.stateKeys?.length) {
|
|
142
|
+
const unsubscribe = this.ctx.states.__.subscribe(
|
|
143
|
+
propConfig.stateKeys,
|
|
144
|
+
() => {
|
|
145
|
+
const newValue = propConfig.factory ? propConfig.factory() : '';
|
|
146
|
+
if (newValue !== undefined && newValue !== null && newValue !== false) {
|
|
147
|
+
(this.element as any)[propName] = newValue;
|
|
148
|
+
} else {
|
|
149
|
+
(this.element as any)[propName] = false;
|
|
150
|
+
delete (this.element as any)[propName];
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
this.bindingUnsubscribes.push(unsubscribe);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
private initializeClasses(): void {
|
|
162
|
+
if (!this.config.classes) return;
|
|
163
|
+
|
|
164
|
+
// New simplified format: classes: [{ type, value, factory?, stateKeys? }]
|
|
165
|
+
if (Array.isArray(this.config.classes)) {
|
|
166
|
+
for (const classConfig of this.config.classes) {
|
|
167
|
+
if (!classConfig || !classConfig.value) continue;
|
|
168
|
+
const className = classConfig.value;
|
|
169
|
+
|
|
170
|
+
if (classConfig.type === 'static') {
|
|
171
|
+
this.element.classList.add(className);
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (classConfig.type === 'binding') {
|
|
176
|
+
const initialValue = classConfig.factory ? classConfig.factory() : false;
|
|
177
|
+
this.element.classList.toggle(className, !!initialValue);
|
|
178
|
+
|
|
179
|
+
if (classConfig.stateKeys?.length) {
|
|
180
|
+
const unsubscribe = this.ctx.states.__.subscribe(
|
|
181
|
+
classConfig.stateKeys,
|
|
182
|
+
() => {
|
|
183
|
+
const newValue = classConfig.factory ? classConfig.factory() : false;
|
|
184
|
+
this.element.classList.toggle(className, !!newValue);
|
|
185
|
+
}
|
|
186
|
+
);
|
|
187
|
+
this.bindingUnsubscribes.push(unsubscribe);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
for (const [className, classConfig] of Object.entries(this.config.classes)) {
|
|
195
|
+
if (classConfig.type === 'static') {
|
|
196
|
+
if (classConfig.value) {
|
|
197
|
+
this.element.classList.add(className);
|
|
198
|
+
}
|
|
199
|
+
} else if (classConfig.type === 'binding') {
|
|
200
|
+
// Initial value
|
|
201
|
+
const initialValue = classConfig.factory ? classConfig.factory() : !!classConfig.value;
|
|
202
|
+
this.element.classList.toggle(className, !!initialValue);
|
|
203
|
+
|
|
204
|
+
// Subscribe for reactive updates
|
|
205
|
+
if (classConfig.stateKeys?.length) {
|
|
206
|
+
const unsubscribe = this.ctx.states.__.subscribe(
|
|
207
|
+
classConfig.stateKeys,
|
|
208
|
+
() => {
|
|
209
|
+
const newValue = classConfig.factory ? classConfig.factory() : false;
|
|
210
|
+
this.element.classList.toggle(className, !!newValue);
|
|
211
|
+
}
|
|
212
|
+
);
|
|
213
|
+
this.bindingUnsubscribes.push(unsubscribe);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
private initializeStyles(): void {
|
|
220
|
+
if (!this.config.styles) return;
|
|
221
|
+
|
|
222
|
+
for (const [prop, styleConfig] of Object.entries(this.config.styles)) {
|
|
223
|
+
if (styleConfig.type === 'value') {
|
|
224
|
+
this.element.style.setProperty(prop, styleConfig.value ?? '');
|
|
225
|
+
} else if (styleConfig.type === 'binding') {
|
|
226
|
+
// Initial value
|
|
227
|
+
const initialValue = styleConfig.factory ? styleConfig.factory() : (styleConfig.value ?? '');
|
|
228
|
+
this.element.style.setProperty(prop, initialValue);
|
|
229
|
+
|
|
230
|
+
// Subscribe for reactive updates
|
|
231
|
+
if (styleConfig.stateKeys?.length) {
|
|
232
|
+
const unsubscribe = this.ctx.states.__.subscribe(
|
|
233
|
+
styleConfig.stateKeys,
|
|
234
|
+
() => {
|
|
235
|
+
const newValue = styleConfig.factory ? styleConfig.factory() : '';
|
|
236
|
+
this.element.style.setProperty(prop, newValue);
|
|
237
|
+
}
|
|
238
|
+
);
|
|
239
|
+
this.bindingUnsubscribes.push(unsubscribe);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
private initializeEvents() {
|
|
246
|
+
if (this.config.events) {
|
|
247
|
+
for (const [eventName, handlers] of Object.entries(this.config.events)) {
|
|
248
|
+
this.ctx.addEventListener(this.element, eventName, handlers);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
setParentElement(parent: HtmlInterface | null): void {
|
|
254
|
+
this.parent = parent;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
setParent(parent: HtmlInterface | null): void {
|
|
258
|
+
this.parent = parent;
|
|
259
|
+
}
|
|
260
|
+
setChildrenFactory(factory: OneChildrenFactory): void {
|
|
261
|
+
this.childrenFactory = factory;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
isSingleElement(): boolean {
|
|
265
|
+
return ['input', 'img', 'br', 'hr', 'meta', 'link'].includes(this.tagName.toLowerCase());
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
render(): HTMLElement {
|
|
269
|
+
if (this.isSingleElement()) {
|
|
270
|
+
return this.element;
|
|
271
|
+
}
|
|
272
|
+
let children: OneChildrenFactoryOutput = [];
|
|
273
|
+
if (this.childrenFactory) {
|
|
274
|
+
// Compiled output uses (parentElement) => [...] — pass `this` as parentElement
|
|
275
|
+
children = this.childrenFactory(this);
|
|
276
|
+
}
|
|
277
|
+
if (children && children.length > 0) {
|
|
278
|
+
children.forEach(child => {
|
|
279
|
+
if (typeof child === 'string' || typeof child === 'number') {
|
|
280
|
+
const textNode = document.createTextNode(String(child));
|
|
281
|
+
this.element.appendChild(textNode);
|
|
282
|
+
this.children.push(textNode);
|
|
283
|
+
} else if (child && typeof child === 'object') {
|
|
284
|
+
if ('element' in child) {
|
|
285
|
+
// HtmlInterface, TextInterface
|
|
286
|
+
this.element.appendChild(child.element);
|
|
287
|
+
this.children.push(child);
|
|
288
|
+
child.render();
|
|
289
|
+
} else if ('openTag' in child && 'closeTag' in child) {
|
|
290
|
+
// Output, Reactive, Fragment, BlockOutlet — they self-append markers
|
|
291
|
+
if ('parent' in child) {
|
|
292
|
+
(child as any).parent = this;
|
|
293
|
+
}
|
|
294
|
+
if ('parentElement' in child) {
|
|
295
|
+
(child as any).parentElement = this;
|
|
296
|
+
}
|
|
297
|
+
this.children.push(child);
|
|
298
|
+
child.render();
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
return this.element;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/** Start reactive bindings + children (Phase 2 lifecycle) */
|
|
307
|
+
start(): void {
|
|
308
|
+
for (const child of this.children) {
|
|
309
|
+
if ('start' in child && typeof (child as any).start === 'function') {
|
|
310
|
+
(child as any).start();
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/** Stop reactive bindings + children */
|
|
316
|
+
stop(): void {
|
|
317
|
+
for (const child of this.children) {
|
|
318
|
+
if ('stop' in child && typeof (child as any).stop === 'function') {
|
|
319
|
+
(child as any).stop();
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
remove() {
|
|
325
|
+
this.element.remove();
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
destroy() {
|
|
329
|
+
// Abort all registered event listeners
|
|
330
|
+
this.abortController.abort();
|
|
331
|
+
this.abortController = new AbortController();
|
|
332
|
+
|
|
333
|
+
// Cleanup reactive binding subscriptions
|
|
334
|
+
for (const unsub of this.bindingUnsubscribes) {
|
|
335
|
+
unsub();
|
|
336
|
+
}
|
|
337
|
+
this.bindingUnsubscribes = [];
|
|
338
|
+
|
|
339
|
+
// Destroy children recursively
|
|
340
|
+
this.children.forEach(child => {
|
|
341
|
+
if ('destroy' in child && typeof child.destroy === 'function') {
|
|
342
|
+
child.destroy();
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
this.children = [];
|
|
346
|
+
if (this.element.children.length > 0) {
|
|
347
|
+
this.element.innerHTML = '';
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
get isOneElement(): boolean {
|
|
352
|
+
return true;
|
|
353
|
+
}
|
|
354
|
+
set isOneElement(value: boolean) {
|
|
355
|
+
// No-op setter to satisfy the Interface; this property is always true for Html elements
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
get isOneHtml(): boolean {
|
|
359
|
+
return true;
|
|
360
|
+
}
|
|
361
|
+
set isOneHtml(value: boolean) {
|
|
362
|
+
// No-op setter to satisfy the Interface; this property is always true for Html elements
|
|
363
|
+
}
|
|
364
|
+
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { InitMode, InitModes } from "../contracts/common";
|
|
2
|
+
import type { HtmlInterface, OutputInterface } from "../contracts/ElementInterface";
|
|
3
|
+
import type { ViewControllerInterface } from "../contracts/ViewControllerInterface";
|
|
4
|
+
import { escapeHTML, generateUUID } from "../hellpers/utils";
|
|
5
|
+
import type { OneObjectType } from "../types/utils";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Output — reactive text output between comment markers.
|
|
9
|
+
*
|
|
10
|
+
* Compiled từ: {{ $expression }} → output({ctx, parentElement, stateKeys, isEscapeHTML: true}, () => expression)
|
|
11
|
+
* Compiled từ: {!! $expression !!} → output({ctx, parentElement, stateKeys, isEscapeHTML: false}, () => expression)
|
|
12
|
+
*
|
|
13
|
+
* Render: Tạo Text node giữa <!--o:id-s--> và <!--o:id-e-->
|
|
14
|
+
* Update: Khi stateKeys thay đổi → re-evaluate contentFactory → update textContent
|
|
15
|
+
*/
|
|
16
|
+
export class Output implements OutputInterface {
|
|
17
|
+
oneType: OneObjectType = 'Output';
|
|
18
|
+
ctx: ViewControllerInterface;
|
|
19
|
+
parent: HtmlInterface | null;
|
|
20
|
+
openTag: Comment;
|
|
21
|
+
closeTag: Comment;
|
|
22
|
+
stateKeys: string[];
|
|
23
|
+
contentFactory: () => string;
|
|
24
|
+
isEscapeHTML: boolean;
|
|
25
|
+
domChildren: Node[] = []; // For compatibility with HtmlInterface; Output itself doesn't have a single root element
|
|
26
|
+
private textNode: Text | null = null;
|
|
27
|
+
private unsubscribe: (() => void) | null = null;
|
|
28
|
+
private _isStarted = false;
|
|
29
|
+
private _isDestroyed = false;
|
|
30
|
+
private id: string;
|
|
31
|
+
initMode: InitMode = InitModes.CREATE;
|
|
32
|
+
|
|
33
|
+
constructor({
|
|
34
|
+
ctx,
|
|
35
|
+
id = null,
|
|
36
|
+
parent = null,
|
|
37
|
+
stateKeys = [],
|
|
38
|
+
contentFactory = () => '',
|
|
39
|
+
isEscapeHTML = true,
|
|
40
|
+
initMode = InitModes.CREATE
|
|
41
|
+
}: {
|
|
42
|
+
ctx: ViewControllerInterface;
|
|
43
|
+
id?: string | null;
|
|
44
|
+
parent?: HtmlInterface | null;
|
|
45
|
+
stateKeys?: string[];
|
|
46
|
+
contentFactory?: () => string;
|
|
47
|
+
isEscapeHTML?: boolean;
|
|
48
|
+
initMode?: InitMode;
|
|
49
|
+
}) {
|
|
50
|
+
this.ctx = ctx;
|
|
51
|
+
this.parent = parent;
|
|
52
|
+
this.stateKeys = stateKeys;
|
|
53
|
+
this.contentFactory = contentFactory;
|
|
54
|
+
this.isEscapeHTML = isEscapeHTML;
|
|
55
|
+
this.id = `${ctx.viewId}-${id ?? generateUUID(8)}`;
|
|
56
|
+
|
|
57
|
+
this.initMode = initMode;
|
|
58
|
+
this.openTag = document.createComment(`o:${this.id}-s`);
|
|
59
|
+
this.closeTag = document.createComment(`o:${this.id}-e`);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
setParentElement(parent: HtmlInterface | null): void {
|
|
63
|
+
this.parent = parent;
|
|
64
|
+
}
|
|
65
|
+
setContentFactory(factory: () => string): void {
|
|
66
|
+
this.contentFactory = factory;
|
|
67
|
+
}
|
|
68
|
+
setStateKeys(stateKeys: string[]): void {
|
|
69
|
+
this.stateKeys = stateKeys;
|
|
70
|
+
// If already started, we need to resubscribe with new keys
|
|
71
|
+
if (this._isStarted) {
|
|
72
|
+
this.stop();
|
|
73
|
+
this.start();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Render — insert markers + initial text into parent element.
|
|
79
|
+
*/
|
|
80
|
+
render(): void {
|
|
81
|
+
if (!this.parent?.element || this._isDestroyed) return;
|
|
82
|
+
|
|
83
|
+
const parentEl = this.parent.element;
|
|
84
|
+
|
|
85
|
+
// Append markers + text node
|
|
86
|
+
parentEl.appendChild(this.openTag);
|
|
87
|
+
|
|
88
|
+
const rawText = String(this.contentFactory() ?? '');
|
|
89
|
+
const displayText = this.isEscapeHTML ? escapeHTML(rawText) : rawText;
|
|
90
|
+
this.textNode = document.createTextNode(displayText);
|
|
91
|
+
parentEl.appendChild(this.textNode);
|
|
92
|
+
|
|
93
|
+
parentEl.appendChild(this.closeTag);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Start — subscribe to state changes for reactive updates.
|
|
98
|
+
* Called during START phase of view lifecycle.
|
|
99
|
+
*/
|
|
100
|
+
start(): void {
|
|
101
|
+
if (this._isStarted || this._isDestroyed) return;
|
|
102
|
+
this._isStarted = true;
|
|
103
|
+
|
|
104
|
+
if (this.stateKeys.length > 0) {
|
|
105
|
+
this.unsubscribe = this.ctx.states.__.subscribe(
|
|
106
|
+
this.stateKeys,
|
|
107
|
+
() => this.update()
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Stop — unsubscribe from state changes.
|
|
114
|
+
*/
|
|
115
|
+
stop(): void {
|
|
116
|
+
if (!this._isStarted) return;
|
|
117
|
+
this._isStarted = false;
|
|
118
|
+
|
|
119
|
+
if (this.unsubscribe) {
|
|
120
|
+
this.unsubscribe();
|
|
121
|
+
this.unsubscribe = null;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Update — re-evaluate contentFactory and update text node in-place.
|
|
127
|
+
* O(1) — chỉ thay textContent, không tạo/xóa DOM nodes.
|
|
128
|
+
*/
|
|
129
|
+
private update(): void {
|
|
130
|
+
if (!this.textNode || this._isDestroyed) return;
|
|
131
|
+
|
|
132
|
+
const rawText = String(this.contentFactory() ?? '');
|
|
133
|
+
const displayText = this.isEscapeHTML ? escapeHTML(rawText) : rawText;
|
|
134
|
+
|
|
135
|
+
if (this.textNode.textContent !== displayText) {
|
|
136
|
+
this.textNode.textContent = displayText;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Destroy — cleanup everything.
|
|
142
|
+
*/
|
|
143
|
+
destroy(): void {
|
|
144
|
+
if (this._isDestroyed) return;
|
|
145
|
+
this._isDestroyed = true;
|
|
146
|
+
this.stop();
|
|
147
|
+
|
|
148
|
+
// Remove text node
|
|
149
|
+
if (this.textNode) {
|
|
150
|
+
this.textNode.remove();
|
|
151
|
+
this.textNode = null;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Remove markers
|
|
155
|
+
this.openTag.remove();
|
|
156
|
+
this.closeTag.remove();
|
|
157
|
+
|
|
158
|
+
this.parent = null;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// ─── OneElement markers ─────────────────────────────
|
|
162
|
+
|
|
163
|
+
get isOneElement(): boolean { return true; }
|
|
164
|
+
set isOneElement(_: boolean) {}
|
|
165
|
+
get isOneOutput(): boolean { return true; }
|
|
166
|
+
set isOneOutput(_: boolean) {}
|
|
167
|
+
}
|