@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,268 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StorageService — localStorage wrapper with TTL, events, import/export.
|
|
3
|
+
*
|
|
4
|
+
* Features:
|
|
5
|
+
* - get/set/remove/clear with TTL (seconds)
|
|
6
|
+
* - Event system: on('set', fn), on('set:key', fn), on('remove', fn)
|
|
7
|
+
* - Backup/restore, import/export (JSON)
|
|
8
|
+
* - Auto-cleans expired items on access
|
|
9
|
+
*
|
|
10
|
+
* Register via DI:
|
|
11
|
+
* app.singleton('storage', () => new StorageService('myapp'));
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
// ─── Types ──────────────────────────────────────────────────────
|
|
15
|
+
|
|
16
|
+
interface StoredItem {
|
|
17
|
+
value: any;
|
|
18
|
+
timestamp: number;
|
|
19
|
+
ttl?: number; // milliseconds
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type StorageEventCallback = (data?: any) => void;
|
|
23
|
+
|
|
24
|
+
// ─── StorageService ─────────────────────────────────────────────
|
|
25
|
+
|
|
26
|
+
export class StorageService {
|
|
27
|
+
|
|
28
|
+
static instances: Map<string, StorageService> = new Map();
|
|
29
|
+
|
|
30
|
+
static getInstance(key: string = 'default'): StorageService {
|
|
31
|
+
if (!StorageService.instances.has(key)) {
|
|
32
|
+
StorageService.instances.set(key, new StorageService(key));
|
|
33
|
+
}
|
|
34
|
+
return StorageService.instances.get(key)!;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static instance(key: string = 'default'): StorageService {
|
|
38
|
+
return StorageService.getInstance(key);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
static removeInstance(key: string = 'default'): void {
|
|
42
|
+
StorageService.instances.delete(key);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
private storageKey: string;
|
|
46
|
+
private data: Record<string, StoredItem> = {};
|
|
47
|
+
private listeners = new Map<string, StorageEventCallback[]>();
|
|
48
|
+
private supported: boolean;
|
|
49
|
+
|
|
50
|
+
constructor(storageKey: string = 'oneview_storage') {
|
|
51
|
+
this.storageKey = storageKey;
|
|
52
|
+
this.supported = typeof localStorage !== 'undefined';
|
|
53
|
+
if (this.supported) this.load();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// ─── CRUD ───────────────────────────────────────────────────
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Set value with optional TTL (in seconds).
|
|
60
|
+
* Supports bulk set: set({ key1: val1, key2: val2 })
|
|
61
|
+
*/
|
|
62
|
+
set(key: string | Record<string, any>, value?: any, ttl?: number | null): boolean {
|
|
63
|
+
if (!this.supported) return false;
|
|
64
|
+
|
|
65
|
+
if (typeof key === 'object' && key !== null) {
|
|
66
|
+
let ok = true;
|
|
67
|
+
for (const [k, v] of Object.entries(key)) {
|
|
68
|
+
if (!this.set(k, v, ttl)) ok = false;
|
|
69
|
+
}
|
|
70
|
+
return ok;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const oldValue = this.data[key]?.value;
|
|
74
|
+
const item: StoredItem = { value, timestamp: Date.now() };
|
|
75
|
+
if (ttl != null && ttl > 0) item.ttl = ttl * 1000;
|
|
76
|
+
|
|
77
|
+
this.data[key] = item;
|
|
78
|
+
|
|
79
|
+
try {
|
|
80
|
+
this.save();
|
|
81
|
+
this.emit(`set:${key}`, { key, value, oldValue, ttl });
|
|
82
|
+
this.emit('set', { key, value, oldValue, ttl });
|
|
83
|
+
return true;
|
|
84
|
+
} catch (e) {
|
|
85
|
+
this.data[key] = { value: oldValue, timestamp: Date.now() };
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Get value (null if expired or missing) */
|
|
91
|
+
get<T = any>(key: string, defaultValue: T | null = null): T | null {
|
|
92
|
+
if (!this.supported) return defaultValue;
|
|
93
|
+
const item = this.data[key];
|
|
94
|
+
if (!item) return defaultValue;
|
|
95
|
+
|
|
96
|
+
if (this.isExpired(item)) {
|
|
97
|
+
this.remove(key);
|
|
98
|
+
return defaultValue;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return (item.value ?? defaultValue) as T;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Check if key exists and not expired */
|
|
105
|
+
has(key: string): boolean {
|
|
106
|
+
const item = this.data[key];
|
|
107
|
+
if (!item) return false;
|
|
108
|
+
if (this.isExpired(item)) { this.remove(key); return false; }
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** Remove key */
|
|
113
|
+
remove(key: string): boolean {
|
|
114
|
+
if (!this.supported || !(key in this.data)) return false;
|
|
115
|
+
const oldValue = this.data[key]?.value;
|
|
116
|
+
delete this.data[key];
|
|
117
|
+
|
|
118
|
+
try {
|
|
119
|
+
this.save();
|
|
120
|
+
this.emit(`remove:${key}`, { key, oldValue });
|
|
121
|
+
this.emit('remove', { key, oldValue });
|
|
122
|
+
return true;
|
|
123
|
+
} catch {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Clear all storage data */
|
|
129
|
+
clear(): void {
|
|
130
|
+
const oldData = { ...this.data };
|
|
131
|
+
this.data = {};
|
|
132
|
+
this.save();
|
|
133
|
+
this.emit('clear', { oldData });
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// ─── Query ──────────────────────────────────────────────────
|
|
137
|
+
|
|
138
|
+
/** Get all non-expired values as plain object */
|
|
139
|
+
getAll(): Record<string, any> {
|
|
140
|
+
this.cleanExpired();
|
|
141
|
+
const result: Record<string, any> = {};
|
|
142
|
+
for (const [k, item] of Object.entries(this.data)) {
|
|
143
|
+
result[k] = item.value;
|
|
144
|
+
}
|
|
145
|
+
return result;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** All non-expired keys */
|
|
149
|
+
getAllKeys(): string[] {
|
|
150
|
+
this.cleanExpired();
|
|
151
|
+
return Object.keys(this.data);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** Number of stored items */
|
|
155
|
+
size(): number {
|
|
156
|
+
this.cleanExpired();
|
|
157
|
+
return Object.keys(this.data).length;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
isEmpty(): boolean {
|
|
161
|
+
return this.size() === 0;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// ─── Import / Export / Backup ───────────────────────────────
|
|
165
|
+
|
|
166
|
+
/** Export all data as JSON string */
|
|
167
|
+
export(): string {
|
|
168
|
+
return JSON.stringify(this.getAll(), null, 2);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** Import data from JSON string */
|
|
172
|
+
import(json: string): boolean {
|
|
173
|
+
try {
|
|
174
|
+
const parsed = JSON.parse(json);
|
|
175
|
+
for (const [k, v] of Object.entries(parsed)) {
|
|
176
|
+
this.data[k] = { value: v, timestamp: Date.now() };
|
|
177
|
+
}
|
|
178
|
+
this.save();
|
|
179
|
+
this.emit('import', { data: parsed });
|
|
180
|
+
return true;
|
|
181
|
+
} catch {
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** Create backup snapshot */
|
|
187
|
+
backup(): { timestamp: number; key: string; data: Record<string, any> } {
|
|
188
|
+
return { timestamp: Date.now(), key: this.storageKey, data: this.getAll() };
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** Restore from backup */
|
|
192
|
+
restore(backup: { data: Record<string, any> }): boolean {
|
|
193
|
+
if (!backup?.data) return false;
|
|
194
|
+
this.data = {};
|
|
195
|
+
for (const [k, v] of Object.entries(backup.data)) {
|
|
196
|
+
this.data[k] = { value: v, timestamp: Date.now() };
|
|
197
|
+
}
|
|
198
|
+
this.save();
|
|
199
|
+
this.emit('restore', { data: backup.data });
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// ─── Event System ───────────────────────────────────────────
|
|
204
|
+
|
|
205
|
+
/** Subscribe to storage events. Returns unsubscribe function. */
|
|
206
|
+
on(event: string, callback: StorageEventCallback): () => void {
|
|
207
|
+
if (!this.listeners.has(event)) this.listeners.set(event, []);
|
|
208
|
+
this.listeners.get(event)!.push(callback);
|
|
209
|
+
return () => this.off(event, callback);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** Unsubscribe from event */
|
|
213
|
+
off(event: string, callback: StorageEventCallback): void {
|
|
214
|
+
const list = this.listeners.get(event);
|
|
215
|
+
if (!list) return;
|
|
216
|
+
const filtered = list.filter((cb) => cb !== callback);
|
|
217
|
+
filtered.length > 0 ? this.listeners.set(event, filtered) : this.listeners.delete(event);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// ─── Lifecycle ──────────────────────────────────────────────
|
|
221
|
+
|
|
222
|
+
destroy(): void {
|
|
223
|
+
this.listeners.clear();
|
|
224
|
+
this.data = {};
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// ─── Private ────────────────────────────────────────────────
|
|
228
|
+
|
|
229
|
+
private isExpired(item: StoredItem): boolean {
|
|
230
|
+
if (!item.ttl) return false;
|
|
231
|
+
return Date.now() > item.timestamp + item.ttl;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
private cleanExpired(): void {
|
|
235
|
+
for (const key of Object.keys(this.data)) {
|
|
236
|
+
if (this.isExpired(this.data[key])) {
|
|
237
|
+
delete this.data[key];
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
this.save();
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
private load(): void {
|
|
244
|
+
try {
|
|
245
|
+
const raw = localStorage.getItem(this.storageKey);
|
|
246
|
+
if (raw) this.data = JSON.parse(raw);
|
|
247
|
+
} catch {
|
|
248
|
+
this.data = {};
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
private save(): void {
|
|
253
|
+
if (!this.supported) return;
|
|
254
|
+
try {
|
|
255
|
+
localStorage.setItem(this.storageKey, JSON.stringify(this.data));
|
|
256
|
+
} catch (e) {
|
|
257
|
+
console.error('[StorageService] Failed to save:', e);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
private emit(event: string, data?: any): void {
|
|
262
|
+
const cbs = this.listeners.get(event);
|
|
263
|
+
if (!cbs) return;
|
|
264
|
+
for (const cb of cbs) {
|
|
265
|
+
try { cb(data); } catch (e) { console.error(`[StorageService] Event listener error (${event}):`, e); }
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* StoreService — In-memory reactive key-value store.
|
|
3
|
+
*
|
|
4
|
+
* Features:
|
|
5
|
+
* - get/set/has/remove with TTL (minutes)
|
|
6
|
+
* - Subscribe to single or multiple keys (batched via microtask)
|
|
7
|
+
* - Expiration callbacks (onExpire)
|
|
8
|
+
* - Lazy expiration on access + periodic batch cleanup
|
|
9
|
+
* - Dynamic property access: store.user === store.get('user')
|
|
10
|
+
*
|
|
11
|
+
* Register via DI:
|
|
12
|
+
* app.singleton('store', StoreService);
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
// ─── Types ──────────────────────────────────────────────────────
|
|
16
|
+
|
|
17
|
+
interface TTLInfo {
|
|
18
|
+
ttl: number; // minutes
|
|
19
|
+
createdAt: number;
|
|
20
|
+
expiresAt: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface MultiKeyListener {
|
|
24
|
+
keys: Set<string>;
|
|
25
|
+
callback: (values: Record<string, any>) => void;
|
|
26
|
+
called: boolean;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// ─── StoreService ───────────────────────────────────────────────
|
|
30
|
+
|
|
31
|
+
export class StoreService {
|
|
32
|
+
static instances: Map<string, StoreService> = new Map();
|
|
33
|
+
|
|
34
|
+
static getInstance(key: string = 'default'): StoreService {
|
|
35
|
+
if (!StoreService.instances.has(key)) {
|
|
36
|
+
StoreService.instances.set(key, new StoreService());
|
|
37
|
+
}
|
|
38
|
+
return StoreService.instances.get(key)!;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
static instance(key: string = 'default'): StoreService {
|
|
42
|
+
return StoreService.getInstance(key);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static removeInstance(key: string = 'default'): void {
|
|
46
|
+
StoreService.instances.delete(key);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private data: Record<string, any> = {};
|
|
50
|
+
private ttlMap = new Map<string, TTLInfo>();
|
|
51
|
+
private listeners = new Map<string, Array<(value: any) => void>>();
|
|
52
|
+
private multiListeners: MultiKeyListener[] = [];
|
|
53
|
+
private expirationListeners = new Map<string, Array<(value: any) => void>>();
|
|
54
|
+
private changedKeys = new Set<string>();
|
|
55
|
+
private pendingFlush = false;
|
|
56
|
+
private cleanupTimer: ReturnType<typeof setInterval> | null = null;
|
|
57
|
+
|
|
58
|
+
/** Protected method names — cannot be used as data keys */
|
|
59
|
+
private static RESERVED = new Set([
|
|
60
|
+
'get', 'set', 'has', 'remove', 'clear', 'subscribe',
|
|
61
|
+
'unsubscribe', 'onExpire', 'keys', 'values', 'entries',
|
|
62
|
+
'destroy',
|
|
63
|
+
]);
|
|
64
|
+
|
|
65
|
+
[key: string]: any;
|
|
66
|
+
|
|
67
|
+
constructor(cleanupIntervalMs: number = 60_000) {
|
|
68
|
+
if (cleanupIntervalMs > 0) {
|
|
69
|
+
this.cleanupTimer = setInterval(() => this.cleanExpired(), cleanupIntervalMs);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// ─── CRUD ───────────────────────────────────────────────────
|
|
74
|
+
|
|
75
|
+
/** Set value with optional TTL (in minutes) */
|
|
76
|
+
set<T = any>(key: string, value: T, ttl: number | null = null): void {
|
|
77
|
+
if (StoreService.RESERVED.has(key)) return;
|
|
78
|
+
|
|
79
|
+
this.data[key] = value;
|
|
80
|
+
|
|
81
|
+
if (ttl !== null && ttl > 0) {
|
|
82
|
+
const ms = ttl * 60_000;
|
|
83
|
+
this.ttlMap.set(key, { ttl, createdAt: Date.now(), expiresAt: Date.now() + ms });
|
|
84
|
+
} else {
|
|
85
|
+
this.ttlMap.delete(key);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Dynamic property
|
|
89
|
+
if (!Object.getOwnPropertyDescriptor(this, key)?.get) {
|
|
90
|
+
Object.defineProperty(this, key, {
|
|
91
|
+
get: () => this.get(key),
|
|
92
|
+
set: (v) => this.set(key, v, ttl),
|
|
93
|
+
enumerable: true,
|
|
94
|
+
configurable: true,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
this.queueChange(key);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** Get value (returns null if expired or missing) */
|
|
102
|
+
get<T = any>(key: string): T | null {
|
|
103
|
+
if (this.isExpired(key)) {
|
|
104
|
+
this.expire(key);
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
return (this.data[key] as T) ?? null;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Check if key exists and is not expired */
|
|
111
|
+
has(key: string): boolean {
|
|
112
|
+
if (this.isExpired(key)) {
|
|
113
|
+
this.expire(key);
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
return key in this.data;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Remove key, returns removed value or null */
|
|
120
|
+
remove(key: string): any {
|
|
121
|
+
if (!(key in this.data)) return null;
|
|
122
|
+
const value = this.data[key];
|
|
123
|
+
|
|
124
|
+
delete this.data[key];
|
|
125
|
+
this.ttlMap.delete(key);
|
|
126
|
+
this.listeners.delete(key);
|
|
127
|
+
this.expirationListeners.delete(key);
|
|
128
|
+
this.removeDynamicProp(key);
|
|
129
|
+
this.queueChange(key);
|
|
130
|
+
|
|
131
|
+
return value;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** Clear all data, listeners, TTLs */
|
|
135
|
+
clear(): void {
|
|
136
|
+
const keys = Object.keys(this.data);
|
|
137
|
+
this.data = {};
|
|
138
|
+
this.ttlMap.clear();
|
|
139
|
+
this.listeners.clear();
|
|
140
|
+
this.multiListeners = [];
|
|
141
|
+
this.expirationListeners.clear();
|
|
142
|
+
this.changedKeys.clear();
|
|
143
|
+
this.pendingFlush = false;
|
|
144
|
+
keys.forEach((k) => this.removeDynamicProp(k));
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// ─── Subscriptions ──────────────────────────────────────────
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Subscribe to key changes. Returns unsubscribe function.
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* store.subscribe('user', (value) => { ... });
|
|
154
|
+
* store.subscribe(['user', 'token'], (values) => { ... });
|
|
155
|
+
*/
|
|
156
|
+
subscribe(
|
|
157
|
+
key: string | string[],
|
|
158
|
+
callback: (value: any) => void,
|
|
159
|
+
): () => void {
|
|
160
|
+
if (Array.isArray(key)) {
|
|
161
|
+
const listener: MultiKeyListener = {
|
|
162
|
+
keys: new Set(key),
|
|
163
|
+
callback: callback as any,
|
|
164
|
+
called: false,
|
|
165
|
+
};
|
|
166
|
+
this.multiListeners.push(listener);
|
|
167
|
+
return () => {
|
|
168
|
+
const idx = this.multiListeners.indexOf(listener);
|
|
169
|
+
if (idx !== -1) this.multiListeners.splice(idx, 1);
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (!this.listeners.has(key)) this.listeners.set(key, []);
|
|
174
|
+
this.listeners.get(key)!.push(callback);
|
|
175
|
+
return () => this.unsubscribe(key, callback);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** Unsubscribe specific callback from key */
|
|
179
|
+
unsubscribe(key: string, callback: (value: any) => void): void {
|
|
180
|
+
const list = this.listeners.get(key);
|
|
181
|
+
if (!list) return;
|
|
182
|
+
const filtered = list.filter((cb) => cb !== callback);
|
|
183
|
+
filtered.length > 0 ? this.listeners.set(key, filtered) : this.listeners.delete(key);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** Subscribe to TTL expiration of a key */
|
|
187
|
+
onExpire(key: string, callback: (value: any) => void): () => void {
|
|
188
|
+
if (!this.expirationListeners.has(key)) this.expirationListeners.set(key, []);
|
|
189
|
+
this.expirationListeners.get(key)!.push(callback);
|
|
190
|
+
return () => {
|
|
191
|
+
const list = this.expirationListeners.get(key);
|
|
192
|
+
if (list) {
|
|
193
|
+
const filtered = list.filter((cb) => cb !== callback);
|
|
194
|
+
filtered.length > 0
|
|
195
|
+
? this.expirationListeners.set(key, filtered)
|
|
196
|
+
: this.expirationListeners.delete(key);
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// ─── TTL Utilities ──────────────────────────────────────────
|
|
202
|
+
|
|
203
|
+
/** Get TTL info for a key */
|
|
204
|
+
getTTL(key: string): { ttl: number; createdAt: number; expiresAt: number; remaining: number; expired: boolean } | null {
|
|
205
|
+
const info = this.ttlMap.get(key);
|
|
206
|
+
if (!info) return null;
|
|
207
|
+
const remaining = Math.max(0, info.expiresAt - Date.now());
|
|
208
|
+
return { ttl: info.ttl, createdAt: info.createdAt, expiresAt: info.expiresAt, remaining, expired: remaining <= 0 };
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** Refresh TTL (reset timer). Pass null to use existing TTL. */
|
|
212
|
+
refreshTTL(key: string, ttl?: number | null): void {
|
|
213
|
+
if (!(key in this.data)) return;
|
|
214
|
+
const finalTTL = (ttl != null && ttl > 0) ? ttl : this.ttlMap.get(key)?.ttl ?? null;
|
|
215
|
+
if (finalTTL != null && finalTTL > 0) {
|
|
216
|
+
const ms = finalTTL * 60_000;
|
|
217
|
+
this.ttlMap.set(key, { ttl: finalTTL, createdAt: Date.now(), expiresAt: Date.now() + ms });
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** Remove TTL from key (key lives forever) */
|
|
222
|
+
removeTTL(key: string): void {
|
|
223
|
+
this.ttlMap.delete(key);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// ─── Iteration ──────────────────────────────────────────────
|
|
227
|
+
|
|
228
|
+
/** All non-expired keys */
|
|
229
|
+
keys(): string[] {
|
|
230
|
+
this.cleanExpired();
|
|
231
|
+
return Object.keys(this.data);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/** All non-expired values */
|
|
235
|
+
values<T = any>(): T[] {
|
|
236
|
+
return this.keys().map((k) => this.get<T>(k)!);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/** All non-expired entries */
|
|
240
|
+
entries<T = any>(): Array<[string, T]> {
|
|
241
|
+
return this.keys().map((k) => [k, this.get<T>(k)!]);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// ─── Lifecycle ──────────────────────────────────────────────
|
|
245
|
+
|
|
246
|
+
/** Destroy — clear all + stop cleanup timer */
|
|
247
|
+
destroy(): void {
|
|
248
|
+
if (this.cleanupTimer) {
|
|
249
|
+
clearInterval(this.cleanupTimer);
|
|
250
|
+
this.cleanupTimer = null;
|
|
251
|
+
}
|
|
252
|
+
this.clear();
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// ─── Private ────────────────────────────────────────────────
|
|
256
|
+
|
|
257
|
+
private isExpired(key: string): boolean {
|
|
258
|
+
const info = this.ttlMap.get(key);
|
|
259
|
+
return info ? Date.now() > info.expiresAt : false;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
private expire(key: string): void {
|
|
263
|
+
if (!(key in this.data)) return;
|
|
264
|
+
const value = this.data[key];
|
|
265
|
+
|
|
266
|
+
// Notify expiration listeners
|
|
267
|
+
const cbs = this.expirationListeners.get(key);
|
|
268
|
+
if (cbs) {
|
|
269
|
+
for (const cb of cbs) {
|
|
270
|
+
try { cb(value); } catch (e) { console.error(`[StoreService] Expiration listener error for "${key}":`, e); }
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
delete this.data[key];
|
|
275
|
+
this.ttlMap.delete(key);
|
|
276
|
+
this.listeners.delete(key);
|
|
277
|
+
this.expirationListeners.delete(key);
|
|
278
|
+
this.removeDynamicProp(key);
|
|
279
|
+
this.queueChange(key);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
private cleanExpired(): number {
|
|
283
|
+
let count = 0;
|
|
284
|
+
for (const [key, info] of this.ttlMap) {
|
|
285
|
+
if (Date.now() > info.expiresAt) {
|
|
286
|
+
this.expire(key);
|
|
287
|
+
count++;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
return count;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
private queueChange(key: string): void {
|
|
294
|
+
this.changedKeys.add(key);
|
|
295
|
+
if (!this.pendingFlush) {
|
|
296
|
+
this.pendingFlush = true;
|
|
297
|
+
Promise.resolve().then(() => this.flush());
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
private flush(): void {
|
|
302
|
+
const keys = [...this.changedKeys];
|
|
303
|
+
this.changedKeys.clear();
|
|
304
|
+
this.pendingFlush = false;
|
|
305
|
+
this.multiListeners.forEach((l) => (l.called = false));
|
|
306
|
+
|
|
307
|
+
for (const key of keys) {
|
|
308
|
+
const value = this.get(key);
|
|
309
|
+
|
|
310
|
+
// Single-key listeners
|
|
311
|
+
const cbs = this.listeners.get(key);
|
|
312
|
+
if (cbs) {
|
|
313
|
+
for (const cb of cbs) {
|
|
314
|
+
try { cb(value); } catch (e) { console.error(`[StoreService] Listener error for "${key}":`, e); }
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// Multi-key listeners
|
|
319
|
+
for (const listener of this.multiListeners) {
|
|
320
|
+
if (listener.keys.has(key) && !listener.called) {
|
|
321
|
+
listener.called = true;
|
|
322
|
+
const values: Record<string, any> = {};
|
|
323
|
+
for (const k of listener.keys) {
|
|
324
|
+
if (keys.includes(k)) values[k] = this.get(k);
|
|
325
|
+
}
|
|
326
|
+
try { listener.callback(values); } catch (e) { console.error('[StoreService] Multi-key listener error:', e); }
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
private removeDynamicProp(key: string): void {
|
|
333
|
+
try {
|
|
334
|
+
const desc = Object.getOwnPropertyDescriptor(this, key);
|
|
335
|
+
if (desc?.configurable) delete (this as any)[key];
|
|
336
|
+
} catch { /* noop */ }
|
|
337
|
+
}
|
|
338
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./BlockManager";
|
|
2
|
+
export * from "./EventService";
|
|
3
|
+
export * from "./LoggerService";
|
|
4
|
+
export * from './HelperService';
|
|
5
|
+
export * from './HttpService';
|
|
6
|
+
export * from './MarkerRegistry';
|
|
7
|
+
export * from "./StoreService";
|
|
8
|
+
export * from "./StorageService";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export type OneObjectType = 'Application' | 'App' | 'ServiceProvider' | 'Html' | 'Reactive' | 'TextElement' | 'Fragment' | 'Wrapper' | 'Block' | 'BlockOutlet' | 'Output' | 'ViewController' | 'View' | 'Service' | 'Router' | 'App' | 'Component' | 'Unknown' | 'Yield' | '' | null; // Extendable for custom types
|
|
2
|
+
export enum OOTEnum {
|
|
3
|
+
APPLICATION = 'Application',
|
|
4
|
+
HTML = 'Html',
|
|
5
|
+
REACTIVE = 'Reactive',
|
|
6
|
+
TEXT_ELEMENT = 'TextElement',
|
|
7
|
+
FRAGMENT = 'Fragment',
|
|
8
|
+
WRAPPER = 'Wrapper',
|
|
9
|
+
BLOCK = 'Block',
|
|
10
|
+
BLOCK_OUTLET = 'BlockOutlet',
|
|
11
|
+
OUTPUT = 'Output',
|
|
12
|
+
VIEW_CONTROLLER = 'ViewController',
|
|
13
|
+
VIEW = 'View',
|
|
14
|
+
SERVICE = 'Service',
|
|
15
|
+
ROUTER = 'Router',
|
|
16
|
+
APP = 'App',
|
|
17
|
+
SERVICE_PROVIDER = 'ServiceProvider',
|
|
18
|
+
COMPONENT = 'Component',
|
|
19
|
+
UNKNOWN = 'Unknown',
|
|
20
|
+
YIELD = 'Yield'
|
|
21
|
+
}
|
|
22
|
+
// ─── Re-exports from contracts (backward compatibility) ─────────
|
|
23
|
+
|
|
24
|
+
export type { OneElementConfig, HtmlElementConfig, OneElementEventHandler, OneElementChildren, OneChildrenFactoryOutput, OneChildrenFactory } from "../contracts/ElementInterface";
|
|
25
|
+
export type { ReactiveRenderFn, ReactiveChildrenFactory, ReactiveConfig } from "../contracts/ReactiveInterface";
|
|
26
|
+
export type { BlockRenderFactory } from "../contracts/BlockInterface";
|
|
27
|
+
export type { ViewRenderFactory, ViewConstructor, ViewLifecycleHooks } from "../contracts/ViewInterface";
|
|
28
|
+
export type { StateListener, MultiKeyStateListener, StateItem } from "../contracts/ViewStateInterface";
|
|
29
|
+
export type { ServiceKey, ServiceFactory, ServiceBinding } from "../contracts/ApplicationInterface";
|
|
30
|
+
export type { ViewConfig, ViewRuntimeConfig } from "../contracts/ViewControllerInterface";
|