@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
package/package.json
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@saolabs/client",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Saola Client - Modern TypeScript Framework for Laravel. Reactive SPAs with TypeScript-first approach.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"require": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./plugins": {
|
|
14
|
+
"types": "./dist/plugins.d.ts",
|
|
15
|
+
"import": "./dist/plugins.js",
|
|
16
|
+
"require": "./dist/plugins.js"
|
|
17
|
+
},
|
|
18
|
+
"./core": {
|
|
19
|
+
"types": "./dist/core/index.d.ts",
|
|
20
|
+
"import": "./dist/core/index.js",
|
|
21
|
+
"require": "./dist/core/index.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"src",
|
|
27
|
+
"index.ts",
|
|
28
|
+
"plugins.ts"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "tsc",
|
|
32
|
+
"dev": "tsc --watch",
|
|
33
|
+
"clean": "rm -rf dist",
|
|
34
|
+
"prepublishOnly": "npm run clean && npm run build",
|
|
35
|
+
"publish-dry-run": "npm publish --dry-run",
|
|
36
|
+
"test": "echo \"No tests specified yet\""
|
|
37
|
+
},
|
|
38
|
+
"keywords": [
|
|
39
|
+
"typescript",
|
|
40
|
+
"framework",
|
|
41
|
+
"laravel",
|
|
42
|
+
"spa",
|
|
43
|
+
"reactive",
|
|
44
|
+
"frontend"
|
|
45
|
+
],
|
|
46
|
+
"author": "Saola Labs",
|
|
47
|
+
"license": "MIT",
|
|
48
|
+
"repository": {
|
|
49
|
+
"type": "git",
|
|
50
|
+
"url": "git+https://github.com/saolabs/saola-client.git"
|
|
51
|
+
},
|
|
52
|
+
"bugs": {
|
|
53
|
+
"url": "https://github.com/saolabs/saola-client/issues"
|
|
54
|
+
},
|
|
55
|
+
"homepage": "https://github.com/saolabs/saola-client#readme",
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"typescript": "^5.0.0",
|
|
58
|
+
"@types/node": "^20.0.0"
|
|
59
|
+
},
|
|
60
|
+
"engines": {
|
|
61
|
+
"node": ">=16.0.0"
|
|
62
|
+
},
|
|
63
|
+
"directories": {
|
|
64
|
+
"doc": "docs"
|
|
65
|
+
},
|
|
66
|
+
"dependencies": {
|
|
67
|
+
"undici-types": "^6.21.0"
|
|
68
|
+
},
|
|
69
|
+
"type": "commonjs"
|
|
70
|
+
}
|
package/plugins.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OneView Plugins
|
|
3
|
+
* Extension system for OneView framework
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export interface PluginOptions {
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface Plugin {
|
|
11
|
+
name: string;
|
|
12
|
+
install(options?: PluginOptions): void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
class PluginManager {
|
|
16
|
+
private plugins: Map<string, Plugin> = new Map();
|
|
17
|
+
private installed: Set<string> = new Set();
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Register a plugin
|
|
21
|
+
*/
|
|
22
|
+
register(plugin: Plugin): this {
|
|
23
|
+
if (this.plugins.has(plugin.name)) {
|
|
24
|
+
console.warn(`Plugin "${plugin.name}" is already registered`);
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
this.plugins.set(plugin.name, plugin);
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Install a registered plugin
|
|
33
|
+
*/
|
|
34
|
+
install(name: string, options?: PluginOptions): this {
|
|
35
|
+
const plugin = this.plugins.get(name);
|
|
36
|
+
if (!plugin) {
|
|
37
|
+
throw new Error(`Plugin "${name}" is not registered`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (this.installed.has(name)) {
|
|
41
|
+
console.warn(`Plugin "${name}" is already installed`);
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
plugin.install(options);
|
|
46
|
+
this.installed.add(name);
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Check if a plugin is installed
|
|
52
|
+
*/
|
|
53
|
+
isInstalled(name: string): boolean {
|
|
54
|
+
return this.installed.has(name);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Get all registered plugins
|
|
59
|
+
*/
|
|
60
|
+
getPlugins(): Plugin[] {
|
|
61
|
+
return Array.from(this.plugins.values());
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export const pluginManager = new PluginManager();
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Create a plugin
|
|
69
|
+
*/
|
|
70
|
+
export function createPlugin(name: string, install: (options?: PluginOptions) => void): Plugin {
|
|
71
|
+
return {
|
|
72
|
+
name,
|
|
73
|
+
install
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export default pluginManager;
|
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Application — DI Container + App Lifecycle.
|
|
3
|
+
*
|
|
4
|
+
* Tương tự Laravel Service Container:
|
|
5
|
+
* - bind / singleton / instance → đăng ký service
|
|
6
|
+
* - make / resolve → lấy service
|
|
7
|
+
* - alias → tên tắt
|
|
8
|
+
* - register / boot → service providers
|
|
9
|
+
*
|
|
10
|
+
* Khác với core Application (hardcode services), bản này hoàn toàn DI-driven:
|
|
11
|
+
* mọi service (Router, ViewManager, Store...) đều được đăng ký qua providers.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* const app = new Application();
|
|
15
|
+
*
|
|
16
|
+
* // Đăng ký trực tiếp
|
|
17
|
+
* app.singleton('markerRegistry', MarkerRegistry);
|
|
18
|
+
* app.instance('config', { debug: true });
|
|
19
|
+
*
|
|
20
|
+
* // Đăng ký qua provider
|
|
21
|
+
* app.register({
|
|
22
|
+
* register(app) { app.singleton('router', () => new Router(app)); },
|
|
23
|
+
* boot(app) { app.make('router').start(); }
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* app.boot();
|
|
27
|
+
* const router = app.make('router');
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
import type { ApplicationInterface, ServiceKey, ServiceFactory, ServiceBinding } from '../contracts/ApplicationInterface';
|
|
31
|
+
import type { ServiceProviderInterface } from '../contracts/ServiceProviderInterface';
|
|
32
|
+
import type { ViewManagerInterface, RouterInterface } from '../contracts/utils';
|
|
33
|
+
import type { HelperInterface } from '../contracts/HelperInterface';
|
|
34
|
+
import type { EventServiceInterface } from '../contracts/EventServiceInterface';
|
|
35
|
+
import type { HttpServiceInterface } from '../contracts/HttpServiceInterface';
|
|
36
|
+
import type { StoreServiceInterface } from '../contracts/StoreServiceInterface';
|
|
37
|
+
import type { StorageServiceInterface } from '../contracts/StorageServiceInterface';
|
|
38
|
+
import type { LoggerServiceInterface } from '../contracts/LoggerServiceInterface';
|
|
39
|
+
import { APIClientInterface } from '../contracts/ApiInterface';
|
|
40
|
+
import { OneObjectType, OOTEnum } from '../types/utils';
|
|
41
|
+
|
|
42
|
+
// ─── Application ────────────────────────────────────────────────
|
|
43
|
+
|
|
44
|
+
export class Application implements ApplicationInterface {
|
|
45
|
+
readonly oneType: OneObjectType = OOTEnum.APPLICATION;
|
|
46
|
+
// Service properties — set during bootstrap via App.set()
|
|
47
|
+
declare isInitialized: boolean;
|
|
48
|
+
declare isStarted: boolean;
|
|
49
|
+
declare View: ViewManagerInterface;
|
|
50
|
+
declare Router: RouterInterface;
|
|
51
|
+
declare Helper: HelperInterface;
|
|
52
|
+
declare Events: EventServiceInterface;
|
|
53
|
+
declare Http: HttpServiceInterface;
|
|
54
|
+
declare API: APIClientInterface;
|
|
55
|
+
declare Store: StoreServiceInterface;
|
|
56
|
+
declare Storage: StorageServiceInterface;
|
|
57
|
+
declare Logger: LoggerServiceInterface;
|
|
58
|
+
|
|
59
|
+
/** Factory bindings — mỗi lần make() gọi factory tạo instance mới */
|
|
60
|
+
private bindings = new Map<ServiceKey, ServiceFactory<any>>();
|
|
61
|
+
|
|
62
|
+
/** Singleton instances — tạo một lần, reuse */
|
|
63
|
+
private singletons = new Map<ServiceKey, any>();
|
|
64
|
+
|
|
65
|
+
/** Aliases — tên tắt trỏ về key gốc */
|
|
66
|
+
private aliases = new Map<string | symbol, ServiceKey>();
|
|
67
|
+
|
|
68
|
+
/** Service providers đã đăng ký */
|
|
69
|
+
private providers: ServiceProviderInterface[] = [];
|
|
70
|
+
|
|
71
|
+
/** Đã boot chưa */
|
|
72
|
+
private booted = false;
|
|
73
|
+
|
|
74
|
+
private ownProperties: string[] = [
|
|
75
|
+
'bindings',
|
|
76
|
+
'singletons',
|
|
77
|
+
'aliases',
|
|
78
|
+
'providers',
|
|
79
|
+
'booted',
|
|
80
|
+
'ownProperties',
|
|
81
|
+
'transient',
|
|
82
|
+
'bind',
|
|
83
|
+
'singleton',
|
|
84
|
+
'instance',
|
|
85
|
+
'alias',
|
|
86
|
+
'make',
|
|
87
|
+
'resolve',
|
|
88
|
+
'has',
|
|
89
|
+
'bound',
|
|
90
|
+
'register',
|
|
91
|
+
'boot',
|
|
92
|
+
'isBooted',
|
|
93
|
+
'flush',
|
|
94
|
+
'destroy',
|
|
95
|
+
'getBindings',
|
|
96
|
+
'getSingletons',
|
|
97
|
+
'__store',
|
|
98
|
+
]; // Để track dynamic properties nếu cần
|
|
99
|
+
|
|
100
|
+
__store: Map<string, { isOverridable: boolean, value: any }> = new Map(); // Store cho dynamic properties nếu cần
|
|
101
|
+
|
|
102
|
+
[key: string]: any; // Cho phép dynamic properties nếu cần
|
|
103
|
+
|
|
104
|
+
constructor() { }
|
|
105
|
+
|
|
106
|
+
// ─── Transient (factory — instance mới mỗi lần) ───────────
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Đăng ký transient service.
|
|
110
|
+
* Mỗi lần make() trả về instance mới (không cache).
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* app.transient('request', (app) => new Request(app.make('config')));
|
|
114
|
+
* app.transient(Database, Database); // class shorthand
|
|
115
|
+
*/
|
|
116
|
+
transient<T>(key: ServiceKey<T>, value: ServiceBinding<T>): this {
|
|
117
|
+
this.bindings.set(key, (app) => {
|
|
118
|
+
if (typeof value === 'function' && value.prototype) {
|
|
119
|
+
return new (value as new (...args: any[]) => T)();
|
|
120
|
+
}
|
|
121
|
+
return (value as ServiceFactory<T>)(app);
|
|
122
|
+
});
|
|
123
|
+
return this;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
bind<T>(key: ServiceKey<T>, value: ServiceBinding<T>): this {
|
|
127
|
+
return this.transient(key, value);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// ─── Singleton (instance duy nhất) ──────────────────────────
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Đăng ký singleton — tạo một lần, reuse mãi mãi.
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* app.singleton('store', StoreService); // class
|
|
137
|
+
* app.singleton('config', (app) => loadConfig()); // factory
|
|
138
|
+
* app.singleton(StoreService); // class, tự tạo
|
|
139
|
+
* app.singleton('store', existingInstance); // instance sẵn
|
|
140
|
+
*/
|
|
141
|
+
singleton<T>(key: ServiceKey<T>, value?: ServiceBinding<T> | T): this {
|
|
142
|
+
// singleton(MyClass) — không có value, key là class
|
|
143
|
+
if (value === undefined) {
|
|
144
|
+
if (typeof key === 'function') {
|
|
145
|
+
this.singletons.set(key, new (key as new (...args: any[]) => T)());
|
|
146
|
+
return this;
|
|
147
|
+
}
|
|
148
|
+
throw new Error(`[Application] Singleton requires a value for key: ${String(key)}`);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// value là instance sẵn (object, không phải function)
|
|
152
|
+
if (value !== null && typeof value === 'object') {
|
|
153
|
+
this.singletons.set(key, value);
|
|
154
|
+
return this;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// value là class hoặc factory — lazy init
|
|
158
|
+
this.bindings.set(key, (app) => {
|
|
159
|
+
if (!this.singletons.has(key)) {
|
|
160
|
+
const isClass = typeof value === 'function' && (value as any).prototype;
|
|
161
|
+
const instance = isClass
|
|
162
|
+
? new (value as new (...args: any[]) => T)()
|
|
163
|
+
: (value as ServiceFactory<T>)(app);
|
|
164
|
+
this.singletons.set(key, instance);
|
|
165
|
+
}
|
|
166
|
+
return this.singletons.get(key);
|
|
167
|
+
});
|
|
168
|
+
return this;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// ─── Instance (đăng ký instance sẵn) ────────────────────────
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Đăng ký instance đã tạo sẵn.
|
|
175
|
+
* Shortcut cho singleton khi đã có instance.
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* app.instance('config', { debug: true, api_url: '/api' });
|
|
179
|
+
*/
|
|
180
|
+
instance<T>(key: ServiceKey<T>, value: T): this {
|
|
181
|
+
this.singletons.set(key, value);
|
|
182
|
+
return this;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// ─── Alias ──────────────────────────────────────────────────
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Tạo tên tắt cho service.
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* app.singleton('email.service', EmailService);
|
|
192
|
+
* app.alias('mailer', 'email.service');
|
|
193
|
+
* app.make('mailer') === app.make('email.service') // true
|
|
194
|
+
*/
|
|
195
|
+
alias(alias: string | symbol, key: ServiceKey): this {
|
|
196
|
+
this.aliases.set(alias, key);
|
|
197
|
+
return this;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// ─── Resolve ────────────────────────────────────────────────
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Lấy service instance. Shortcut cho resolve().
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* const router = app.make<Router>('router');
|
|
207
|
+
*/
|
|
208
|
+
make<T>(key: ServiceKey<T>, defaultValue?: T): T {
|
|
209
|
+
return this.resolve(key, defaultValue);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Resolve service instance.
|
|
214
|
+
*
|
|
215
|
+
* Thứ tự tìm:
|
|
216
|
+
* 1. Alias → resolve key gốc
|
|
217
|
+
* 2. Singleton đã tạo → reuse
|
|
218
|
+
* 3. Binding (factory) → gọi factory
|
|
219
|
+
* 4. Key là class → auto-instantiate + cache
|
|
220
|
+
* 5. defaultValue → trả về
|
|
221
|
+
* 6. Throw error
|
|
222
|
+
*/
|
|
223
|
+
resolve<T>(key: ServiceKey<T>, defaultValue?: T): T {
|
|
224
|
+
// 1. Resolve alias
|
|
225
|
+
let resolved: ServiceKey<T> = key;
|
|
226
|
+
if ((typeof key === 'string' || typeof key === 'symbol') && this.aliases.has(key)) {
|
|
227
|
+
resolved = this.aliases.get(key)! as ServiceKey<T>;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// 2. Singleton đã có
|
|
231
|
+
if (this.singletons.has(resolved)) {
|
|
232
|
+
return this.singletons.get(resolved);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// 3. Binding factory
|
|
236
|
+
const factory = this.bindings.get(resolved);
|
|
237
|
+
if (factory) {
|
|
238
|
+
return factory(this);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// 4. Auto-instantiate class
|
|
242
|
+
if (typeof resolved === 'function') {
|
|
243
|
+
if (resolved.prototype) {
|
|
244
|
+
const inst = new (resolved as new (...args: any[]) => T)();
|
|
245
|
+
this.singletons.set(resolved, inst);
|
|
246
|
+
return inst;
|
|
247
|
+
}
|
|
248
|
+
return (resolved as Function)(this);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// 5. Default value
|
|
252
|
+
if (defaultValue !== undefined) {
|
|
253
|
+
return defaultValue;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// 6. Not found
|
|
257
|
+
throw new Error(`[Application] Cannot resolve: ${String(key)}`);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// ─── Query ──────────────────────────────────────────────────
|
|
261
|
+
|
|
262
|
+
/** Kiểm tra service đã đăng ký chưa */
|
|
263
|
+
has(key: ServiceKey): boolean {
|
|
264
|
+
const aliased = (typeof key === 'string' || typeof key === 'symbol') && this.aliases.has(key);
|
|
265
|
+
return this.bindings.has(key) || this.singletons.has(key) || aliased
|
|
266
|
+
|| (typeof key === 'string' && this.__store.has(key));
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/** Alias cho has() */
|
|
270
|
+
bound(key: ServiceKey): boolean {
|
|
271
|
+
return this.has(key);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// ─── Service Providers ──────────────────────────────────────
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Đăng ký service provider.
|
|
278
|
+
* register() được gọi ngay, boot() gọi khi app.boot().
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
* app.register({
|
|
282
|
+
* register(app) { app.singleton('db', Database); },
|
|
283
|
+
* boot(app) { app.make('db').connect(); }
|
|
284
|
+
* });
|
|
285
|
+
*/
|
|
286
|
+
register(provider: ServiceProviderInterface): this {
|
|
287
|
+
this.providers.push(provider);
|
|
288
|
+
if (typeof (provider as any).initApplication === 'function') {
|
|
289
|
+
(provider as any).initApplication();
|
|
290
|
+
}
|
|
291
|
+
provider.register();
|
|
292
|
+
return this;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Boot tất cả providers.
|
|
297
|
+
* Gọi boot() của mỗi provider theo thứ tự đăng ký.
|
|
298
|
+
* Chỉ chạy một lần.
|
|
299
|
+
*/
|
|
300
|
+
boot(): void {
|
|
301
|
+
if (this.booted) return;
|
|
302
|
+
|
|
303
|
+
for (const provider of this.providers) {
|
|
304
|
+
if (typeof provider.boot === 'function') {
|
|
305
|
+
provider.boot();
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
this.booted = true;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/** Đã boot chưa */
|
|
313
|
+
get isBooted(): boolean {
|
|
314
|
+
return this.booted;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// ─── Cleanup ────────────────────────────────────────────────
|
|
318
|
+
|
|
319
|
+
/** Xóa toàn bộ bindings, singletons, aliases, __store. Reset container. */
|
|
320
|
+
flush(): void {
|
|
321
|
+
this.bindings.clear();
|
|
322
|
+
this.singletons.clear();
|
|
323
|
+
this.aliases.clear();
|
|
324
|
+
this.__store.clear();
|
|
325
|
+
this.providers = [];
|
|
326
|
+
this.booted = false;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/** Destroy app — flush + cleanup */
|
|
330
|
+
destroy(): void {
|
|
331
|
+
this.flush();
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// ─── Introspection (debug) ──────────────────────────────────
|
|
335
|
+
|
|
336
|
+
getBindings(): Map<ServiceKey, ServiceFactory<any>> {
|
|
337
|
+
return this.bindings;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
getSingletons(): Map<ServiceKey, any> {
|
|
341
|
+
return this.singletons;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
set<T = any>(name: string, value: T, isOne: boolean = false): void {
|
|
346
|
+
if (this.ownProperties.includes(name)) {
|
|
347
|
+
return; // Không cho ghi đè lên thuộc tính có sẵn
|
|
348
|
+
}
|
|
349
|
+
if (this.__store.has(name) && this.__store.get(name)?.isOverridable === false) {
|
|
350
|
+
return; // Không cho ghi đè lên thuộc tính không thể override
|
|
351
|
+
}
|
|
352
|
+
this.__store.set(name, { value, isOverridable: !isOne });
|
|
353
|
+
this.singletons.set(name, value); // Sync → DI container
|
|
354
|
+
Object.defineProperty(this, name, {
|
|
355
|
+
get: () => this.__store.get(name)?.value,
|
|
356
|
+
set: (newValue) => {
|
|
357
|
+
if (this.__store.has(name) && this.__store.get(name)?.isOverridable === false) {
|
|
358
|
+
return; // Không cho ghi đè nếu isOverridable là false
|
|
359
|
+
}
|
|
360
|
+
this.__store.set(name, { value: newValue, isOverridable: !isOne });
|
|
361
|
+
this.singletons.set(name, newValue); // Sync → DI container
|
|
362
|
+
},
|
|
363
|
+
configurable: isOne ? false : true,
|
|
364
|
+
enumerable: false,
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
get<T = any>(name: string): T {
|
|
369
|
+
if (this.ownProperties.includes(name)) {
|
|
370
|
+
return (this as any)[name]; // Trả về thuộc tính có sẵn
|
|
371
|
+
}
|
|
372
|
+
// Check __store first (registered via set())
|
|
373
|
+
if (this.__store.has(name)) {
|
|
374
|
+
return this.__store.get(name)?.value;
|
|
375
|
+
}
|
|
376
|
+
// Fall back to DI container (registered via singleton/instance/bind)
|
|
377
|
+
if (this.singletons.has(name) || this.bindings.has(name) || this.aliases.has(name)) {
|
|
378
|
+
return this.resolve(name);
|
|
379
|
+
}
|
|
380
|
+
return undefined as T;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
setMethod(name: string, method: Function, isOne: boolean = false): void {
|
|
384
|
+
if (this.ownProperties.includes(name)) {
|
|
385
|
+
return; // Không cho ghi đè lên thuộc tính có sẵn
|
|
386
|
+
}
|
|
387
|
+
if (this.__store.has(name) && this.__store.get(name)?.isOverridable === false) {
|
|
388
|
+
return; // Không cho ghi đè lên thuộc tính không thể override
|
|
389
|
+
}
|
|
390
|
+
this.__store.set(name, { value: method, isOverridable: !isOne });
|
|
391
|
+
(this as any)[name] = (...args: any[]) => {
|
|
392
|
+
const fn = this.get(name);
|
|
393
|
+
if (typeof fn === 'function') {
|
|
394
|
+
if (typeof fn.bind === 'function') {
|
|
395
|
+
return fn.bind(this)(...args);
|
|
396
|
+
}
|
|
397
|
+
return fn.apply(this, args);
|
|
398
|
+
}
|
|
399
|
+
throw new Error(`[Application] Method ${name} is not a function`);
|
|
400
|
+
};
|
|
401
|
+
if (isOne) {
|
|
402
|
+
Object.defineProperty(this, name, {
|
|
403
|
+
configurable: false,
|
|
404
|
+
writable: false,
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
// ─── Singleton App Instance ─────────────────────────────────────
|
|
410
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ApplicationInterface } from "../contracts/ApplicationInterface";
|
|
2
|
+
import { app } from "../hellpers/app";
|
|
3
|
+
import { Router } from "../routers";
|
|
4
|
+
import { buildDefaultProviders, resolveProviderOrder } from "./providers";
|
|
5
|
+
|
|
6
|
+
const App: ApplicationInterface = app<ApplicationInterface>();
|
|
7
|
+
|
|
8
|
+
// ⚠️ Flags PHẢI dùng isOne=false để có thể cập nhật sau init/start
|
|
9
|
+
App.set<boolean>('isInitialized', false);
|
|
10
|
+
App.set<boolean>('isStarted', false);
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Khởi tạo app — đăng ký + boot tất cả providers theo dependency order.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* App.init({
|
|
17
|
+
* view: { container: '#app', registry: {...} },
|
|
18
|
+
* router: { mode: 'history', routes: [...] },
|
|
19
|
+
* api: { endpoint: '/api' },
|
|
20
|
+
* providers: [{ name: 'analytics', dependsOn: ['core'], register(app) {...} }]
|
|
21
|
+
* });
|
|
22
|
+
*/
|
|
23
|
+
App.setMethod('init', function (config: Record<string, any> = {}) {
|
|
24
|
+
if (App.isInitialized) {
|
|
25
|
+
console.warn('[Bootstrap] App already initialized.');
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const providers = resolveProviderOrder(buildDefaultProviders(config));
|
|
30
|
+
for (const provider of providers) {
|
|
31
|
+
App.register(provider);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
App.boot();
|
|
35
|
+
App.isInitialized = true;
|
|
36
|
+
}, true);
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Start app — init nếu chưa, rồi start Router.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* App.start(); // init với config mặc định
|
|
43
|
+
* App.start({ view: { container: '#app' } }); // init với config tùy chỉnh
|
|
44
|
+
*/
|
|
45
|
+
App.setMethod('start', function (config?: Record<string, any>) {
|
|
46
|
+
if (App.isStarted) {
|
|
47
|
+
console.warn('[Bootstrap] App already started.');
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (!App.isInitialized) {
|
|
51
|
+
App.init(config || {});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
App.get<Router>('Router').start();
|
|
55
|
+
App.isStarted = true;
|
|
56
|
+
}, true);
|
|
57
|
+
|
|
58
|
+
export default App;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { APIClientInterface } from "../../contracts/ApiInterface";
|
|
2
|
+
import { ApiClient } from "../../hellpers/ApiClient";
|
|
3
|
+
import { PROVIDER_NAMES } from "./provider-order";
|
|
4
|
+
import { ServiceProvider } from "./ServiceProvider";
|
|
5
|
+
|
|
6
|
+
export class ApiServiceProvider extends ServiceProvider {
|
|
7
|
+
readonly name = PROVIDER_NAMES.API;
|
|
8
|
+
readonly dependsOn = [PROVIDER_NAMES.CORE];
|
|
9
|
+
static config: Record<string, any> = {};
|
|
10
|
+
|
|
11
|
+
register(): void {
|
|
12
|
+
this.app.set<APIClientInterface>("API", new ApiClient(), true);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
boot(): void {
|
|
16
|
+
this.app.get<APIClientInterface>("API").init(ApiServiceProvider.config);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { app } from "../../hellpers/app";
|
|
2
|
+
import { EventService } from "../../services/EventService";
|
|
3
|
+
import { HttpService } from "../../services/HttpService";
|
|
4
|
+
import { MarkerService } from "../../services/MarkerService";
|
|
5
|
+
import { StoreService } from "../../services/StoreService";
|
|
6
|
+
import { PROVIDER_NAMES } from "./provider-order";
|
|
7
|
+
import { ServiceProvider } from "./ServiceProvider";
|
|
8
|
+
|
|
9
|
+
export class CoreServiceProvider extends ServiceProvider {
|
|
10
|
+
readonly name = PROVIDER_NAMES.CORE;
|
|
11
|
+
|
|
12
|
+
register(): void {
|
|
13
|
+
this.app.set<MarkerService>("Marker", app<MarkerService>(MarkerService), true);
|
|
14
|
+
this.app.set<StoreService>("Store", StoreService.instance(), true);
|
|
15
|
+
this.app.set<StoreService>("Storage", StoreService.instance(), true);
|
|
16
|
+
this.app.set<EventService>("Event", EventService.instance(), true);
|
|
17
|
+
this.app.set<HttpService>("Http", HttpService.instance(), true);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { HelperService } from "../../services/HelperService";
|
|
2
|
+
import { PROVIDER_NAMES } from "./provider-order";
|
|
3
|
+
import { ServiceProvider } from "./ServiceProvider";
|
|
4
|
+
|
|
5
|
+
export class HelperServiceProvider extends ServiceProvider {
|
|
6
|
+
readonly name = PROVIDER_NAMES.HELPER;
|
|
7
|
+
readonly dependsOn = [PROVIDER_NAMES.CORE, PROVIDER_NAMES.ROUTER, PROVIDER_NAMES.VIEW];
|
|
8
|
+
|
|
9
|
+
register(): void {
|
|
10
|
+
this.app.set<HelperService>("Helper", new HelperService(this.app), true);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Router } from "../../routers";
|
|
2
|
+
import { PROVIDER_NAMES } from "./provider-order";
|
|
3
|
+
import { ServiceProvider } from "./ServiceProvider";
|
|
4
|
+
|
|
5
|
+
export class RouteServiceProvider extends ServiceProvider {
|
|
6
|
+
readonly name = PROVIDER_NAMES.ROUTER;
|
|
7
|
+
readonly dependsOn = [PROVIDER_NAMES.VIEW];
|
|
8
|
+
static config: Record<string, any> = {};
|
|
9
|
+
|
|
10
|
+
register(): void {
|
|
11
|
+
this.app.set<Router>("Router", new Router(this.app), true);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
boot(): void {
|
|
15
|
+
this.app.get<Router>("Router").init(RouteServiceProvider.config);
|
|
16
|
+
}
|
|
17
|
+
}
|