@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,235 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HttpService — Fetch-based HTTP client.
|
|
3
|
+
*
|
|
4
|
+
* Features:
|
|
5
|
+
* - Base URL, default headers, timeout
|
|
6
|
+
* - Request/response/error interceptors (chainable)
|
|
7
|
+
* - Auto-cancel duplicate in-flight requests (same method + URL)
|
|
8
|
+
* - Convenience: get, post, put, patch, delete
|
|
9
|
+
*
|
|
10
|
+
* Register via DI:
|
|
11
|
+
* app.singleton('http', () => {
|
|
12
|
+
* const http = new HttpService();
|
|
13
|
+
* http.setBaseUrl('/api');
|
|
14
|
+
* return http;
|
|
15
|
+
* });
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
// ─── Types ──────────────────────────────────────────────────────
|
|
19
|
+
|
|
20
|
+
export interface HttpRequestConfig extends RequestInit {
|
|
21
|
+
headers?: Record<string, string>;
|
|
22
|
+
timeout?: number;
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface HttpResponse<T = any> {
|
|
27
|
+
status: boolean;
|
|
28
|
+
statusCode: number;
|
|
29
|
+
data: T;
|
|
30
|
+
headers: Headers;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface HttpInterceptor {
|
|
34
|
+
request?: (config: HttpRequestConfig) => HttpRequestConfig | Promise<HttpRequestConfig>;
|
|
35
|
+
response?: <T = any>(response: HttpResponse<T>) => HttpResponse<T> | Promise<HttpResponse<T>>;
|
|
36
|
+
error?: (error: Error) => Error | Promise<Error>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// ─── HttpService ────────────────────────────────────────────────
|
|
40
|
+
|
|
41
|
+
export class HttpService {
|
|
42
|
+
private static instances: Map<string, HttpService> = new Map();
|
|
43
|
+
static getInstance(key: string = 'default'): HttpService {
|
|
44
|
+
if (!HttpService.instances.has(key)) {
|
|
45
|
+
HttpService.instances.set(key, new HttpService());
|
|
46
|
+
}
|
|
47
|
+
return HttpService.instances.get(key)!;
|
|
48
|
+
}
|
|
49
|
+
static instance(key: string = 'default'): HttpService {
|
|
50
|
+
return HttpService.getInstance(key);
|
|
51
|
+
}
|
|
52
|
+
static removeInstance(key: string = 'default'): void {
|
|
53
|
+
HttpService.instances.delete(key);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
private baseUrl: string = '';
|
|
57
|
+
private timeout: number = 10000;
|
|
58
|
+
private defaultHeaders: Record<string, string> = {};
|
|
59
|
+
private interceptors: HttpInterceptor[] = [];
|
|
60
|
+
private pending = new Map<string, AbortController>();
|
|
61
|
+
|
|
62
|
+
// ─── Config ─────────────────────────────────────────────────
|
|
63
|
+
|
|
64
|
+
setBaseUrl(url: string): this {
|
|
65
|
+
this.baseUrl = url.endsWith('/') ? url.slice(0, -1) : url;
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
setTimeout(ms: number): this {
|
|
70
|
+
this.timeout = ms;
|
|
71
|
+
return this;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
setDefaultHeaders(headers: Record<string, string>): this {
|
|
75
|
+
Object.assign(this.defaultHeaders, headers);
|
|
76
|
+
return this;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
setHeader(name: string, value: string): this {
|
|
80
|
+
this.defaultHeaders[name] = value;
|
|
81
|
+
return this;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
removeHeader(name: string): this {
|
|
85
|
+
delete this.defaultHeaders[name];
|
|
86
|
+
return this;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Add interceptor. Returns unregister function. */
|
|
90
|
+
addInterceptor(interceptor: HttpInterceptor): () => void {
|
|
91
|
+
this.interceptors.push(interceptor);
|
|
92
|
+
return () => {
|
|
93
|
+
const idx = this.interceptors.indexOf(interceptor);
|
|
94
|
+
if (idx !== -1) this.interceptors.splice(idx, 1);
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// ─── Core Request ───────────────────────────────────────────
|
|
99
|
+
|
|
100
|
+
async request<T = any>(
|
|
101
|
+
method: string,
|
|
102
|
+
url: string,
|
|
103
|
+
data: any = null,
|
|
104
|
+
options: HttpRequestConfig = {},
|
|
105
|
+
): Promise<HttpResponse<T>> {
|
|
106
|
+
// Build full URL
|
|
107
|
+
let fullUrl = url.startsWith('http') ? url : `${this.baseUrl}${url}`;
|
|
108
|
+
|
|
109
|
+
// Cancel duplicate in-flight request
|
|
110
|
+
const requestKey = `${method.toUpperCase()}:${fullUrl}`;
|
|
111
|
+
this.pending.get(requestKey)?.abort();
|
|
112
|
+
|
|
113
|
+
const controller = new AbortController();
|
|
114
|
+
this.pending.set(requestKey, controller);
|
|
115
|
+
|
|
116
|
+
// Build config
|
|
117
|
+
let config: HttpRequestConfig = {
|
|
118
|
+
method: method.toUpperCase(),
|
|
119
|
+
headers: { ...this.defaultHeaders, ...options.headers },
|
|
120
|
+
signal: options.signal ?? controller.signal,
|
|
121
|
+
...options,
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// Apply request interceptors
|
|
125
|
+
for (const i of this.interceptors) {
|
|
126
|
+
if (i.request) config = await i.request(config);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Body for POST/PUT/PATCH
|
|
130
|
+
if (data && ['POST', 'PUT', 'PATCH'].includes(config.method!)) {
|
|
131
|
+
const ct = (config.headers as Record<string, string>)?.['Content-Type'];
|
|
132
|
+
if (data instanceof FormData) {
|
|
133
|
+
config.body = data;
|
|
134
|
+
delete (config.headers as Record<string, string>)['Content-Type'];
|
|
135
|
+
} else if (ct === 'application/json' || !ct) {
|
|
136
|
+
(config.headers as Record<string, string>)['Content-Type'] = 'application/json';
|
|
137
|
+
config.body = JSON.stringify(data);
|
|
138
|
+
} else {
|
|
139
|
+
config.body = data;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Query params for GET
|
|
144
|
+
if (data && config.method === 'GET' && typeof data === 'object') {
|
|
145
|
+
const urlObj = new URL(fullUrl, window.location.origin);
|
|
146
|
+
for (const [key, value] of Object.entries(data)) {
|
|
147
|
+
urlObj.searchParams.append(key, String(value));
|
|
148
|
+
}
|
|
149
|
+
fullUrl = urlObj.toString();
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
try {
|
|
153
|
+
const timeoutId = setTimeout(() => controller.abort(), options.timeout ?? this.timeout);
|
|
154
|
+
const raw = await fetch(fullUrl, config);
|
|
155
|
+
clearTimeout(timeoutId);
|
|
156
|
+
|
|
157
|
+
const responseData = await raw.json().catch(() => ({}));
|
|
158
|
+
|
|
159
|
+
let response: HttpResponse<T> = {
|
|
160
|
+
status: raw.ok,
|
|
161
|
+
statusCode: raw.status,
|
|
162
|
+
data: responseData,
|
|
163
|
+
headers: raw.headers,
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
// Apply response interceptors
|
|
167
|
+
for (const i of this.interceptors) {
|
|
168
|
+
if (i.response) response = await i.response(response);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
this.pending.delete(requestKey);
|
|
172
|
+
|
|
173
|
+
if (!raw.ok) {
|
|
174
|
+
throw Object.assign(new Error(`HTTP ${raw.status} ${raw.statusText}`), { response });
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return response;
|
|
178
|
+
} catch (err) {
|
|
179
|
+
this.pending.delete(requestKey);
|
|
180
|
+
|
|
181
|
+
let error = err as Error;
|
|
182
|
+
for (const i of this.interceptors) {
|
|
183
|
+
if (i.error) error = await i.error(error);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
if (error.name === 'AbortError') {
|
|
187
|
+
throw new Error('Request cancelled');
|
|
188
|
+
}
|
|
189
|
+
throw error;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// ─── Convenience ────────────────────────────────────────────
|
|
194
|
+
|
|
195
|
+
get<T = any>(url: string, params?: any, options?: HttpRequestConfig) {
|
|
196
|
+
return this.request<T>('GET', url, params, options);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
post<T = any>(url: string, data?: any, options?: HttpRequestConfig) {
|
|
200
|
+
return this.request<T>('POST', url, data, options);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
put<T = any>(url: string, data?: any, options?: HttpRequestConfig) {
|
|
204
|
+
return this.request<T>('PUT', url, data, options);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
patch<T = any>(url: string, data?: any, options?: HttpRequestConfig) {
|
|
208
|
+
return this.request<T>('PATCH', url, data, options);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
delete<T = any>(url: string, options?: HttpRequestConfig) {
|
|
212
|
+
return this.request<T>('DELETE', url, null, options);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// ─── Cancellation ───────────────────────────────────────────
|
|
216
|
+
|
|
217
|
+
/** Cancel all pending requests */
|
|
218
|
+
cancelAll(): void {
|
|
219
|
+
this.pending.forEach((c) => c.abort());
|
|
220
|
+
this.pending.clear();
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/** Cancel a specific pending request */
|
|
224
|
+
cancel(url: string, method: string = 'GET'): void {
|
|
225
|
+
const key = `${method.toUpperCase()}:${url}`;
|
|
226
|
+
this.pending.get(key)?.abort();
|
|
227
|
+
this.pending.delete(key);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/** Destroy — cancel all + clear interceptors */
|
|
231
|
+
destroy(): void {
|
|
232
|
+
this.cancelAll();
|
|
233
|
+
this.interceptors = [];
|
|
234
|
+
}
|
|
235
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LoggerService — Configurable console logger with log history.
|
|
3
|
+
*
|
|
4
|
+
* Features:
|
|
5
|
+
* - Log levels: debug < info < warn < error
|
|
6
|
+
* - Enable/disable toggle
|
|
7
|
+
* - Stored log history (for debug tools, remote reporting)
|
|
8
|
+
* - Prefix formatting
|
|
9
|
+
*
|
|
10
|
+
* Register via DI:
|
|
11
|
+
* app.singleton('logger', () => new LoggerService({ level: 'info', enabled: true }));
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
// ─── Types ──────────────────────────────────────────────────────
|
|
15
|
+
|
|
16
|
+
export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent';
|
|
17
|
+
|
|
18
|
+
export interface LoggerConfig {
|
|
19
|
+
/** Minimum log level to output (default: 'info') */
|
|
20
|
+
level?: LogLevel;
|
|
21
|
+
/** Enable/disable console output (default: true) */
|
|
22
|
+
enabled?: boolean;
|
|
23
|
+
/** Prefix for all log messages (default: '') */
|
|
24
|
+
prefix?: string;
|
|
25
|
+
/** Max history entries (0 = unlimited, default: 500) */
|
|
26
|
+
maxHistory?: number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface LogEntry {
|
|
30
|
+
level: LogLevel;
|
|
31
|
+
timestamp: number;
|
|
32
|
+
args: any[];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// ─── Log Level Priority ─────────────────────────────────────────
|
|
36
|
+
|
|
37
|
+
const LEVEL_PRIORITY: Record<LogLevel, number> = {
|
|
38
|
+
debug: 0,
|
|
39
|
+
info: 1,
|
|
40
|
+
warn: 2,
|
|
41
|
+
error: 3,
|
|
42
|
+
silent: 4,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// ─── LoggerService ──────────────────────────────────────────────
|
|
46
|
+
|
|
47
|
+
export class LoggerService {
|
|
48
|
+
private config: Required<LoggerConfig>;
|
|
49
|
+
private history: LogEntry[] = [];
|
|
50
|
+
|
|
51
|
+
constructor(config: LoggerConfig = {}) {
|
|
52
|
+
this.config = {
|
|
53
|
+
level: config.level ?? 'info',
|
|
54
|
+
enabled: config.enabled ?? true,
|
|
55
|
+
prefix: config.prefix ?? '',
|
|
56
|
+
maxHistory: config.maxHistory ?? 500,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// ─── Config ─────────────────────────────────────────────────
|
|
61
|
+
|
|
62
|
+
setConfig(config: Partial<LoggerConfig>): void {
|
|
63
|
+
Object.assign(this.config, config);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
getConfig(): Readonly<Required<LoggerConfig>> {
|
|
67
|
+
return this.config;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
enable(): void { this.config.enabled = true; }
|
|
71
|
+
disable(): void { this.config.enabled = false; }
|
|
72
|
+
|
|
73
|
+
setLevel(level: LogLevel): void { this.config.level = level; }
|
|
74
|
+
setPrefix(prefix: string): void { this.config.prefix = prefix; }
|
|
75
|
+
|
|
76
|
+
// ─── Log Methods ────────────────────────────────────────────
|
|
77
|
+
|
|
78
|
+
debug(...args: any[]): void { this.write('debug', args); }
|
|
79
|
+
info(...args: any[]): void { this.write('info', args); }
|
|
80
|
+
log(...args: any[]): void { this.write('info', args); }
|
|
81
|
+
warn(...args: any[]): void { this.write('warn', args); }
|
|
82
|
+
error(...args: any[]): void { this.write('error', args); }
|
|
83
|
+
|
|
84
|
+
// ─── History ────────────────────────────────────────────────
|
|
85
|
+
|
|
86
|
+
/** Get all stored log entries */
|
|
87
|
+
getHistory(): readonly LogEntry[] {
|
|
88
|
+
return this.history;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Get history filtered by level */
|
|
92
|
+
getHistoryByLevel(level: LogLevel): LogEntry[] {
|
|
93
|
+
return this.history.filter((e) => e.level === level);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Clear log history */
|
|
97
|
+
clearHistory(): void {
|
|
98
|
+
this.history = [];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// ─── Lifecycle ──────────────────────────────────────────────
|
|
102
|
+
|
|
103
|
+
destroy(): void {
|
|
104
|
+
this.history = [];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// ─── Private ────────────────────────────────────────────────
|
|
108
|
+
|
|
109
|
+
private write(level: LogLevel, args: any[]): void {
|
|
110
|
+
// Always store in history
|
|
111
|
+
this.addToHistory(level, args);
|
|
112
|
+
|
|
113
|
+
// Check if should output to console
|
|
114
|
+
if (!this.config.enabled) return;
|
|
115
|
+
if (LEVEL_PRIORITY[level] < LEVEL_PRIORITY[this.config.level]) return;
|
|
116
|
+
|
|
117
|
+
const prefix = this.config.prefix ? `[${this.config.prefix}]` : '';
|
|
118
|
+
const method = level === 'debug' ? 'debug' : level === 'info' ? 'log' : level;
|
|
119
|
+
|
|
120
|
+
if (prefix) {
|
|
121
|
+
(console as any)[method](prefix, ...args);
|
|
122
|
+
} else {
|
|
123
|
+
(console as any)[method](...args);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
private addToHistory(level: LogLevel, args: any[]): void {
|
|
128
|
+
this.history.push({ level, timestamp: Date.now(), args });
|
|
129
|
+
|
|
130
|
+
// Trim if over max
|
|
131
|
+
if (this.config.maxHistory > 0 && this.history.length > this.config.maxHistory) {
|
|
132
|
+
this.history = this.history.slice(-this.config.maxHistory);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
export const logger = new LoggerService();
|
|
139
|
+
export default logger;
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MarkerRegistry — singleton service that manages DOM comment marker metadata.
|
|
3
|
+
*
|
|
4
|
+
* In the new element-based system, Reactive/Block/Fragment all use
|
|
5
|
+
* comment nodes (<!--reactive-start-->, <!--block:content-end-->) as markers.
|
|
6
|
+
*
|
|
7
|
+
* MarkerRegistry provides:
|
|
8
|
+
* 1. Tag shortcuts: 'reactive' → 'r', 'block' → 'b', etc.
|
|
9
|
+
* → Keeps DOM comments short: <!--r:abc123--> instead of <!--reactive:abc123-->
|
|
10
|
+
* 2. Registry records: maps marker IDs to metadata (tag type, attributes, owner viewId, etc.)
|
|
11
|
+
* → Enables lookup: given a comment node, find what element/view it belongs to
|
|
12
|
+
* 3. Query API: find records by tag, by viewId, by custom attributes
|
|
13
|
+
*
|
|
14
|
+
* Used by:
|
|
15
|
+
* - Reactive, Block, Fragment — to register their markers on creation
|
|
16
|
+
* - ViewController — to query/manage markers for its view
|
|
17
|
+
* - Compiler — to know tag shortcut mappings for generated code
|
|
18
|
+
* - DevTools (future) — to inspect/debug the element tree via markers
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { MarkerRegistryRecord } from "../contracts/MarkerInterface";
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
export class MarkerRegistryService {
|
|
25
|
+
static class: string = 'MarkerRegistryService';
|
|
26
|
+
/** Tag name → short abbreviation (for compact DOM comments) */
|
|
27
|
+
private shortcuts: Record<string, string> = {
|
|
28
|
+
view: 'v',
|
|
29
|
+
component: 'c',
|
|
30
|
+
layout: 'l',
|
|
31
|
+
template: 't',
|
|
32
|
+
block: 'b',
|
|
33
|
+
reactive: 'r',
|
|
34
|
+
section: 's',
|
|
35
|
+
fragment: 'frg',
|
|
36
|
+
blockoutlet: 'bo',
|
|
37
|
+
for: 'fo',
|
|
38
|
+
forin: 'fi',
|
|
39
|
+
foreach: 'fe',
|
|
40
|
+
while: 'wh',
|
|
41
|
+
if: 'if',
|
|
42
|
+
switch: 'sw',
|
|
43
|
+
include: 'inc',
|
|
44
|
+
echo: 'e',
|
|
45
|
+
echoescaped: 'ee',
|
|
46
|
+
yield: 'y',
|
|
47
|
+
slot: 'st',
|
|
48
|
+
useblock: 'ub',
|
|
49
|
+
extend: 'ex',
|
|
50
|
+
style: 'sty',
|
|
51
|
+
script: 'sc',
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/** Reverse lookup: shortcut → full tag name */
|
|
55
|
+
private reverseShortcuts: Record<string, string> = {};
|
|
56
|
+
|
|
57
|
+
/** All registered marker records, keyed by composite key (e.g. 'r:abc123') */
|
|
58
|
+
private records: Map<string, MarkerRegistryRecord> = new Map();
|
|
59
|
+
|
|
60
|
+
/** Delimiter between tag shortcut and ID in keys */
|
|
61
|
+
private delimiter: string = ':';
|
|
62
|
+
|
|
63
|
+
/** Auto-increment counter for generating unique IDs */
|
|
64
|
+
private counter: number = 0;
|
|
65
|
+
|
|
66
|
+
constructor() {
|
|
67
|
+
this.buildReverseShortcuts();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// ─── Tag Shortcuts ──────────────────────────────────────────
|
|
71
|
+
|
|
72
|
+
/** Get short abbreviation for a tag name */
|
|
73
|
+
shortcut(tag: string): string {
|
|
74
|
+
return this.shortcuts[tag] ?? tag;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Get full tag name from a shortcut */
|
|
78
|
+
fullTag(shortcut: string): string {
|
|
79
|
+
return this.reverseShortcuts[shortcut] ?? shortcut;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Register a custom tag shortcut */
|
|
83
|
+
registerShortcut(tag: string, short: string): void {
|
|
84
|
+
this.shortcuts[tag] = short;
|
|
85
|
+
this.reverseShortcuts[short] = tag;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// ─── Record Management ──────────────────────────────────────
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Register a marker record.
|
|
92
|
+
*
|
|
93
|
+
* @param tag Full tag name (e.g. 'reactive', 'block')
|
|
94
|
+
* @param id Optional specific ID. Auto-generated if omitted.
|
|
95
|
+
* @param attributes Optional metadata.
|
|
96
|
+
* @returns The composite key (e.g. 'r:m0')
|
|
97
|
+
*/
|
|
98
|
+
register(tag: string, id?: string, attributes: Record<string, any> = {}): string {
|
|
99
|
+
const resolvedId = id ?? this.generateId();
|
|
100
|
+
const key = this.makeKey(tag, resolvedId);
|
|
101
|
+
|
|
102
|
+
const existing = this.records.get(key);
|
|
103
|
+
if (existing) {
|
|
104
|
+
existing.attributes = { ...existing.attributes, ...attributes };
|
|
105
|
+
return key;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
this.records.set(key, {
|
|
109
|
+
tag,
|
|
110
|
+
registryID: resolvedId,
|
|
111
|
+
attributes,
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
return key;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** Register + create the opening Comment node */
|
|
118
|
+
createMarkerStart(tag: string, id?: string): Comment {
|
|
119
|
+
return document.createComment(this.openComment(tag, id ?? ''));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
createMarkerEnd(tag: string, id?: string): Comment {
|
|
123
|
+
return document.createComment(this.closeComment(tag, id));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
/** Get a record by composite key (e.g. 'r:abc123') */
|
|
128
|
+
get(key: string): MarkerRegistryRecord | null {
|
|
129
|
+
return this.records.get(key) ?? null;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** Get a record by tag + id */
|
|
133
|
+
getByTagAndId(tag: string, id: string): MarkerRegistryRecord | null {
|
|
134
|
+
return this.records.get(this.makeKey(tag, id)) ?? null;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** Check if a record exists */
|
|
138
|
+
has(key: string): boolean {
|
|
139
|
+
return this.records.has(key);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** Remove a record */
|
|
143
|
+
remove(key: string): boolean {
|
|
144
|
+
return this.records.delete(key);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** Get all records for a specific tag type */
|
|
148
|
+
getByTag(tag: string): MarkerRegistryRecord[] {
|
|
149
|
+
const short = this.shortcut(tag);
|
|
150
|
+
const results: MarkerRegistryRecord[] = [];
|
|
151
|
+
for (const [key, record] of this.records) {
|
|
152
|
+
if (key.startsWith(short + this.delimiter) || record.tag === tag) {
|
|
153
|
+
results.push(record);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return results;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** Get all records */
|
|
160
|
+
all(): Map<string, MarkerRegistryRecord> {
|
|
161
|
+
return this.records;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** Clear all records */
|
|
165
|
+
clear(): void {
|
|
166
|
+
this.records.clear();
|
|
167
|
+
this.counter = 0;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** Total number of registered markers */
|
|
171
|
+
get size(): number {
|
|
172
|
+
return this.records.size;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// ─── Comment Node Helpers ───────────────────────────────────
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Create a comment string for a marker (open).
|
|
179
|
+
* e.g. 'r:abc123' for <!--r:abc123-->
|
|
180
|
+
*/
|
|
181
|
+
openComment(tag: string, id?: string): string {
|
|
182
|
+
return `${this.shortcut(tag)}${id ? this.delimiter + id : ''}`;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Create a comment string for a closing marker.
|
|
187
|
+
* e.g. '/r:abc123' for <!--/r:abc123-->
|
|
188
|
+
*/
|
|
189
|
+
closeComment(tag: string, id?: string): string {
|
|
190
|
+
return `/${this.shortcut(tag)}${id ? this.delimiter + id : ''}`;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Parse a comment node's text to extract tag and id.
|
|
195
|
+
* ' r:abc123 ' → { tag: 'reactive', id: 'abc123', isClose: false }
|
|
196
|
+
* ' /r:abc123 ' → { tag: 'reactive', id: 'abc123', isClose: true }
|
|
197
|
+
*/
|
|
198
|
+
parseComment(text: string): { tag: string; id: string; isClose: boolean } | null {
|
|
199
|
+
const trimmed = text.trim();
|
|
200
|
+
if (!trimmed) return null;
|
|
201
|
+
|
|
202
|
+
const isClose = trimmed.startsWith('/');
|
|
203
|
+
const content = isClose ? trimmed.slice(1) : trimmed;
|
|
204
|
+
const delimIdx = content.indexOf(this.delimiter);
|
|
205
|
+
|
|
206
|
+
if (delimIdx === -1) return null;
|
|
207
|
+
|
|
208
|
+
const shortTag = content.slice(0, delimIdx);
|
|
209
|
+
const id = content.slice(delimIdx + 1);
|
|
210
|
+
|
|
211
|
+
return {
|
|
212
|
+
tag: this.fullTag(shortTag),
|
|
213
|
+
id,
|
|
214
|
+
isClose,
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// ─── Private ────────────────────────────────────────────────
|
|
219
|
+
|
|
220
|
+
private makeKey(tag: string, id?: string): string {
|
|
221
|
+
return `${this.shortcut(tag)}${id ? this.delimiter + id : ''}`;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
private generateId(): string {
|
|
225
|
+
return `m${(this.counter++).toString(36)}`;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
private buildReverseShortcuts(): void {
|
|
229
|
+
this.reverseShortcuts = {};
|
|
230
|
+
for (const [tag, short] of Object.entries(this.shortcuts)) {
|
|
231
|
+
this.reverseShortcuts[short] = tag;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// ─── Singleton ──────────────────────────────────────────────────
|
|
237
|
+
|
|
238
|
+
export const MarkerRegistry = new MarkerRegistryService();
|
|
239
|
+
export default MarkerRegistry;
|