@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,723 @@
|
|
|
1
|
+
import { app } from "../hellpers/app";
|
|
2
|
+
import { generateUUID } from "../hellpers/utils";
|
|
3
|
+
import { MarkerRegistry } from "./MarkerRegistry";
|
|
4
|
+
/**
|
|
5
|
+
* OneMarker Model - Represents a custom marker element
|
|
6
|
+
* Supports both:
|
|
7
|
+
* - Generic markup: <tag>...</tag> or <!--tag-->...<!--/tag-->
|
|
8
|
+
* - Registry tags: <!--o:r:id-->...<!--/o:r:id-->
|
|
9
|
+
*/
|
|
10
|
+
export class MarkerModel {
|
|
11
|
+
constructor(data) {
|
|
12
|
+
this.__fullName = data.name;
|
|
13
|
+
this.__tagName = data.name.split(':')[1] || data.name;
|
|
14
|
+
this.__registryID = data.registryID;
|
|
15
|
+
this.__openTag = data.openTag;
|
|
16
|
+
this.__closeTag = data.closeTag;
|
|
17
|
+
this.__attributes = data.attributes;
|
|
18
|
+
this.__nodes = data.children || [];
|
|
19
|
+
this.__definedAttributes = [];
|
|
20
|
+
this.__defineAttributes(Object.keys(data.attributes));
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Update model data
|
|
24
|
+
*/
|
|
25
|
+
__update(data) {
|
|
26
|
+
this.__fullName = data.name;
|
|
27
|
+
this.__tagName = data.name.split(':')[1] || data.name;
|
|
28
|
+
this.__registryID = data.registryID;
|
|
29
|
+
this.__openTag = data.openTag;
|
|
30
|
+
this.__closeTag = data.closeTag;
|
|
31
|
+
this.__attributes = data.attributes;
|
|
32
|
+
this.__nodes = data.children || [];
|
|
33
|
+
this.__defineAttributes(Object.keys(data.attributes));
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Define dynamic property accessors for attributes
|
|
38
|
+
* @private
|
|
39
|
+
*/
|
|
40
|
+
__defineAttributes(attributeKeys) {
|
|
41
|
+
attributeKeys.forEach(key => this.__defineAttribute(key));
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Define single attribute accessor
|
|
46
|
+
* @private
|
|
47
|
+
*/
|
|
48
|
+
__defineAttribute(name) {
|
|
49
|
+
if (this.__definedAttributes.includes(name)) {
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
this.__definedAttributes.push(name);
|
|
53
|
+
Object.defineProperty(this, name, {
|
|
54
|
+
get: () => this.__attributes[name],
|
|
55
|
+
set: (value) => {
|
|
56
|
+
this.__attributes[name] = value;
|
|
57
|
+
},
|
|
58
|
+
enumerable: true,
|
|
59
|
+
configurable: true,
|
|
60
|
+
});
|
|
61
|
+
return this;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Get tag name (without namespace)
|
|
65
|
+
*/
|
|
66
|
+
get tagName() {
|
|
67
|
+
return this.__tagName;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Get full name (with namespace)
|
|
71
|
+
*/
|
|
72
|
+
get fullName() {
|
|
73
|
+
return this.__fullName;
|
|
74
|
+
}
|
|
75
|
+
get registryID() {
|
|
76
|
+
return this.__registryID;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Get open tag node
|
|
80
|
+
*/
|
|
81
|
+
get openTag() {
|
|
82
|
+
return this.__openTag;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Get close tag node
|
|
86
|
+
*/
|
|
87
|
+
get closeTag() {
|
|
88
|
+
return this.__closeTag;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Get all attributes
|
|
92
|
+
*/
|
|
93
|
+
get attributes() {
|
|
94
|
+
return this.__attributes;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Get nodes between open and close tags
|
|
98
|
+
*/
|
|
99
|
+
get nodes() {
|
|
100
|
+
return this.__nodes;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Get system prefix (registry tags only)
|
|
104
|
+
*/
|
|
105
|
+
get systemPrefix() {
|
|
106
|
+
return this.__systemPrefix;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Get tag (registry tags only)
|
|
110
|
+
*/
|
|
111
|
+
get tag() {
|
|
112
|
+
return this.__tag;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Get ID (registry tags only)
|
|
116
|
+
*/
|
|
117
|
+
get id() {
|
|
118
|
+
return this.__id;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Get full key (registry tags only)
|
|
122
|
+
*/
|
|
123
|
+
get key() {
|
|
124
|
+
return this.__key;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Get full data (registry tags only)
|
|
128
|
+
*/
|
|
129
|
+
get data() {
|
|
130
|
+
if (!this.__systemPrefix)
|
|
131
|
+
return undefined;
|
|
132
|
+
return {
|
|
133
|
+
systemPrefix: this.__systemPrefix,
|
|
134
|
+
tag: this.__tag,
|
|
135
|
+
id: this.__id,
|
|
136
|
+
key: this.__key,
|
|
137
|
+
attributes: this.__attributes,
|
|
138
|
+
nodes: this.__nodes
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Get outer HTML including open/close tags and content
|
|
143
|
+
*/
|
|
144
|
+
get outerHTML() {
|
|
145
|
+
let html = '';
|
|
146
|
+
html += this.__getNodeHTML(this.__openTag);
|
|
147
|
+
let currentNode = this.__openTag.nextSibling;
|
|
148
|
+
while (currentNode && currentNode !== this.__closeTag) {
|
|
149
|
+
html += this.__getNodeHTML(currentNode);
|
|
150
|
+
currentNode = currentNode.nextSibling;
|
|
151
|
+
}
|
|
152
|
+
html += this.__getNodeHTML(this.__closeTag);
|
|
153
|
+
return html;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Get inner HTML (content only, without open/close tags)
|
|
157
|
+
*/
|
|
158
|
+
get innerHTML() {
|
|
159
|
+
let html = '';
|
|
160
|
+
let currentNode = this.__openTag.nextSibling;
|
|
161
|
+
while (currentNode && currentNode !== this.__closeTag) {
|
|
162
|
+
html += this.__getNodeHTML(currentNode);
|
|
163
|
+
currentNode = currentNode.nextSibling;
|
|
164
|
+
}
|
|
165
|
+
return html;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Get HTML representation of a node
|
|
169
|
+
* @private
|
|
170
|
+
*/
|
|
171
|
+
__getNodeHTML(node) {
|
|
172
|
+
if (!node)
|
|
173
|
+
return '';
|
|
174
|
+
switch (node.nodeType) {
|
|
175
|
+
case Node.COMMENT_NODE:
|
|
176
|
+
return `<!--${node.nodeValue}-->`;
|
|
177
|
+
case Node.TEXT_NODE:
|
|
178
|
+
return node.textContent || '';
|
|
179
|
+
case Node.ELEMENT_NODE:
|
|
180
|
+
return node.outerHTML || '';
|
|
181
|
+
default:
|
|
182
|
+
return node.textContent || '';
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Get attribute value
|
|
187
|
+
*/
|
|
188
|
+
getAttribute(name) {
|
|
189
|
+
return this.__attributes[name];
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Set attribute value
|
|
193
|
+
*/
|
|
194
|
+
setAttribute(name, value) {
|
|
195
|
+
this.__defineAttribute(name);
|
|
196
|
+
this.__attributes[name] = value;
|
|
197
|
+
return this;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Check if model matches query attributes
|
|
201
|
+
* @private
|
|
202
|
+
*/
|
|
203
|
+
__match(attributes) {
|
|
204
|
+
for (const [key, value] of Object.entries(attributes)) {
|
|
205
|
+
if (key === 'tagName') {
|
|
206
|
+
if (this.__tagName !== value)
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
else if (key === 'openTag') {
|
|
210
|
+
if (this.__openTag !== value)
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
else if (key === 'closeTag') {
|
|
214
|
+
if (this.__closeTag !== value)
|
|
215
|
+
return false;
|
|
216
|
+
}
|
|
217
|
+
else if (key === 'attributes' || key === 'nodes') {
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
else if (this.__attributes[key] !== value) {
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return true;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Check if model matches given attributes (for registry tag filtering)
|
|
228
|
+
*/
|
|
229
|
+
matchesAttributes(attributes) {
|
|
230
|
+
if (!attributes || Object.keys(attributes).length === 0) {
|
|
231
|
+
return true;
|
|
232
|
+
}
|
|
233
|
+
for (const [key, value] of Object.entries(attributes)) {
|
|
234
|
+
if (this.__attributes?.[key] !== value) {
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return true;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Set attributes from registry
|
|
242
|
+
*/
|
|
243
|
+
setAttributes(attributes) {
|
|
244
|
+
Object.assign(this.__attributes, attributes);
|
|
245
|
+
this.__defineAttributes(Object.keys(attributes));
|
|
246
|
+
return this;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Scan and update nodes between open/close tags
|
|
250
|
+
*/
|
|
251
|
+
__scan() {
|
|
252
|
+
const nodes = [];
|
|
253
|
+
let currentNode = this.__openTag.nextSibling;
|
|
254
|
+
while (currentNode && currentNode !== this.__closeTag) {
|
|
255
|
+
nodes.push(currentNode);
|
|
256
|
+
currentNode = currentNode.nextSibling;
|
|
257
|
+
}
|
|
258
|
+
this.__nodes = nodes;
|
|
259
|
+
return this.__nodes;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Sync with DOM (re-query and update)
|
|
263
|
+
*/
|
|
264
|
+
__sync() {
|
|
265
|
+
// Placeholder for sync logic
|
|
266
|
+
// In V1, this uses oms.find() which requires OneMarkerService
|
|
267
|
+
return false;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Update nodes array
|
|
271
|
+
*/
|
|
272
|
+
updateNodes(nodes) {
|
|
273
|
+
this.__nodes = nodes;
|
|
274
|
+
return this;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Replace content between open and close tags
|
|
278
|
+
*/
|
|
279
|
+
replaceContent(content) {
|
|
280
|
+
// Remove existing nodes
|
|
281
|
+
this.__nodes.forEach(node => {
|
|
282
|
+
if (node.parentNode) {
|
|
283
|
+
node.parentNode.removeChild(node);
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
this.__nodes = [];
|
|
287
|
+
// Insert new content
|
|
288
|
+
const closeTag = this.__closeTag;
|
|
289
|
+
if (typeof content === 'string') {
|
|
290
|
+
const temp = document.createElement('div');
|
|
291
|
+
temp.innerHTML = content;
|
|
292
|
+
const fragment = document.createDocumentFragment();
|
|
293
|
+
Array.from(temp.childNodes).forEach(node => fragment.appendChild(node));
|
|
294
|
+
if (closeTag.parentNode) {
|
|
295
|
+
closeTag.parentNode.insertBefore(fragment, closeTag);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
else if (content instanceof Node) {
|
|
299
|
+
if (closeTag.parentNode) {
|
|
300
|
+
closeTag.parentNode.insertBefore(content, closeTag);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
else if (Array.isArray(content)) {
|
|
304
|
+
const fragment = document.createDocumentFragment();
|
|
305
|
+
content.forEach(node => fragment.appendChild(node));
|
|
306
|
+
if (closeTag.parentNode) {
|
|
307
|
+
closeTag.parentNode.insertBefore(fragment, closeTag);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
// Rescan nodes
|
|
311
|
+
this.__scan();
|
|
312
|
+
return this;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Remove element and its content from DOM
|
|
316
|
+
*/
|
|
317
|
+
remove() {
|
|
318
|
+
// Remove all nodes
|
|
319
|
+
this.__nodes.forEach(node => {
|
|
320
|
+
if (node.parentNode) {
|
|
321
|
+
node.parentNode.removeChild(node);
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
// Remove open and close tags
|
|
325
|
+
if (this.__openTag.parentNode) {
|
|
326
|
+
this.__openTag.parentNode.removeChild(this.__openTag);
|
|
327
|
+
}
|
|
328
|
+
if (this.__closeTag.parentNode) {
|
|
329
|
+
this.__closeTag.parentNode.removeChild(this.__closeTag);
|
|
330
|
+
}
|
|
331
|
+
this.__nodes = [];
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* OneMarkerCollection - Collection of OneMarkerModel instances
|
|
336
|
+
* Provides array-like operations with type safety
|
|
337
|
+
*/
|
|
338
|
+
export class MarkerCollection {
|
|
339
|
+
constructor(elements = []) {
|
|
340
|
+
this.__models = elements.map(element => (element instanceof MarkerModel) ? element : new MarkerModel(element));
|
|
341
|
+
}
|
|
342
|
+
get models() {
|
|
343
|
+
return this.__models;
|
|
344
|
+
}
|
|
345
|
+
get length() {
|
|
346
|
+
return this.__models.length;
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Get the first model in the collection
|
|
350
|
+
*/
|
|
351
|
+
get first() {
|
|
352
|
+
return this.__models[0];
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Get the last model in the collection
|
|
356
|
+
*/
|
|
357
|
+
get last() {
|
|
358
|
+
return this.__models[this.__models.length - 1];
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Get the model at the given index
|
|
362
|
+
*/
|
|
363
|
+
get(index) {
|
|
364
|
+
return this.__models[index];
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Set the model at the given index
|
|
368
|
+
*/
|
|
369
|
+
set(index, model) {
|
|
370
|
+
this.__models[index] = model;
|
|
371
|
+
return this;
|
|
372
|
+
}
|
|
373
|
+
push(model) {
|
|
374
|
+
if (!(model instanceof MarkerModel)) {
|
|
375
|
+
model = new MarkerModel(model);
|
|
376
|
+
}
|
|
377
|
+
this.__models.push(model);
|
|
378
|
+
return this;
|
|
379
|
+
}
|
|
380
|
+
pop() {
|
|
381
|
+
return this.__models.pop();
|
|
382
|
+
}
|
|
383
|
+
shift() {
|
|
384
|
+
return this.__models.shift();
|
|
385
|
+
}
|
|
386
|
+
unshift(model) {
|
|
387
|
+
if (!(model instanceof MarkerModel)) {
|
|
388
|
+
model = new MarkerModel(model);
|
|
389
|
+
}
|
|
390
|
+
this.__models.unshift(model);
|
|
391
|
+
return this;
|
|
392
|
+
}
|
|
393
|
+
splice(start, deleteCount, ...items) {
|
|
394
|
+
return this.__models.splice(start, deleteCount, ...items);
|
|
395
|
+
}
|
|
396
|
+
slice(start, end) {
|
|
397
|
+
return this.__models.slice(start, end);
|
|
398
|
+
}
|
|
399
|
+
concat(models) {
|
|
400
|
+
const otherModels = (models instanceof MarkerCollection) ? models.__models : models;
|
|
401
|
+
return new MarkerCollection(this.__models.concat(otherModels));
|
|
402
|
+
}
|
|
403
|
+
reverse() {
|
|
404
|
+
return new MarkerCollection([...this.__models].reverse());
|
|
405
|
+
}
|
|
406
|
+
map(callback) {
|
|
407
|
+
return this.__models.map(callback);
|
|
408
|
+
}
|
|
409
|
+
filter(callback) {
|
|
410
|
+
return this.__models.filter(callback);
|
|
411
|
+
}
|
|
412
|
+
reduce(callback, initialValue) {
|
|
413
|
+
return this.__models.reduce(callback, initialValue);
|
|
414
|
+
}
|
|
415
|
+
forEach(callback) {
|
|
416
|
+
this.__models.forEach(callback);
|
|
417
|
+
}
|
|
418
|
+
some(callback) {
|
|
419
|
+
return this.__models.some(callback);
|
|
420
|
+
}
|
|
421
|
+
every(callback) {
|
|
422
|
+
return this.__models.every(callback);
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Query the collection by attributes
|
|
426
|
+
*/
|
|
427
|
+
query(attributes = {}) {
|
|
428
|
+
return this.__models.filter(model => model.__match(attributes));
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Find first model matching attributes
|
|
432
|
+
*/
|
|
433
|
+
find(attributes = {}) {
|
|
434
|
+
return this.query(attributes)[0] || null;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Marker Service - Manages custom markup elements
|
|
439
|
+
* Supports both HydrationMarker (comments)
|
|
440
|
+
*/
|
|
441
|
+
export class MarkerService {
|
|
442
|
+
constructor(rootElement) {
|
|
443
|
+
this.prefix = 'o';
|
|
444
|
+
this.delimiter = ':';
|
|
445
|
+
this.closeTagSuffix = '/';
|
|
446
|
+
this.markerRegistry = MarkerRegistry;
|
|
447
|
+
this.rootElement = (rootElement instanceof Element) ? rootElement : document.body;
|
|
448
|
+
this.walker = document.createTreeWalker(this.rootElement, NodeFilter.SHOW_COMMENT, null);
|
|
449
|
+
}
|
|
450
|
+
refreshWalker() {
|
|
451
|
+
this.walker = document.createTreeWalker(this.rootElement, NodeFilter.SHOW_COMMENT, null);
|
|
452
|
+
return this;
|
|
453
|
+
}
|
|
454
|
+
addRegistry(tag, id, attributes = {}) {
|
|
455
|
+
return this.markerRegistry.register(tag, id, attributes);
|
|
456
|
+
}
|
|
457
|
+
resolveTagName(tagShortcut) {
|
|
458
|
+
return this.markerRegistry.fullTag(tagShortcut);
|
|
459
|
+
}
|
|
460
|
+
getShortcut(tagName) {
|
|
461
|
+
return this.markerRegistry.shortcut(tagName);
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Check if registryIDOrAttributes is a registryID (string) or attributes (object)
|
|
465
|
+
*/
|
|
466
|
+
parseRegistryIDOrAttributes(value) {
|
|
467
|
+
if (typeof value === 'string') {
|
|
468
|
+
return { registryID: value };
|
|
469
|
+
}
|
|
470
|
+
if (typeof value === 'object' && value !== null) {
|
|
471
|
+
const registryID = typeof value['registryID'] === 'string' ? value['registryID'] : undefined;
|
|
472
|
+
if (registryID) {
|
|
473
|
+
delete value['registryID'];
|
|
474
|
+
}
|
|
475
|
+
return { registryID, attributes: value };
|
|
476
|
+
}
|
|
477
|
+
return {};
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Get attributes from MarkerRegistry if registryID provided
|
|
481
|
+
*/
|
|
482
|
+
getAttributesFromRegistry(tagName, registryID) {
|
|
483
|
+
const record = this.markerRegistry.getByTagAndId(tagName, registryID);
|
|
484
|
+
return record?.attributes || {};
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Check if attributes match filter
|
|
488
|
+
*/
|
|
489
|
+
attributesMatch(tagAttributes, filter) {
|
|
490
|
+
if (!filter)
|
|
491
|
+
return true;
|
|
492
|
+
for (const [key, value] of Object.entries(filter)) {
|
|
493
|
+
if (value !== undefined && tagAttributes[key] !== value) {
|
|
494
|
+
return false;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
return true;
|
|
498
|
+
}
|
|
499
|
+
createMarker(tag, id, attributes = {}) {
|
|
500
|
+
const name = this.markerRegistry.fullTag(tag);
|
|
501
|
+
const registryID = id ?? generateUUID();
|
|
502
|
+
const key = this.markerRegistry.register(tag, registryID, attributes);
|
|
503
|
+
const openTag = this.markerRegistry.createMarkerStart(tag, registryID);
|
|
504
|
+
const closeTag = this.markerRegistry.createMarkerEnd(tag, registryID);
|
|
505
|
+
// Register in MarkerRegistry
|
|
506
|
+
return new MarkerModel({
|
|
507
|
+
name,
|
|
508
|
+
tagName: (this.prefix ? this.prefix + this.delimiter : '') + tag,
|
|
509
|
+
registryID,
|
|
510
|
+
openTag,
|
|
511
|
+
closeTag,
|
|
512
|
+
attributes,
|
|
513
|
+
children: []
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
createOpenMarker(tag, id) {
|
|
517
|
+
return this.markerRegistry.createMarkerStart(tag, id);
|
|
518
|
+
}
|
|
519
|
+
createCloseMarker(tag, id) {
|
|
520
|
+
return this.markerRegistry.createMarkerEnd(tag, id);
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* Query hydration markers in HTML comments
|
|
524
|
+
* Works with format: <!--prefix:shortcutTag:registryID-->
|
|
525
|
+
*
|
|
526
|
+
* @param tagOrShortcut - Tag name or shortcut (r, v, c, etc.)
|
|
527
|
+
* @param where - Registry ID (string) or attributes filter (object)
|
|
528
|
+
* @returns Array of matched markers
|
|
529
|
+
*
|
|
530
|
+
* @example
|
|
531
|
+
* query("r", "1234") // Find o:r:1234
|
|
532
|
+
* query("reactive", "1234") // Find o:r:1234 (resolved from shortcut)
|
|
533
|
+
* query("r", { userId: "123" }) // Find o:r:* with userId="123"
|
|
534
|
+
*/
|
|
535
|
+
query(tagOrShortcut, where, useCache = true) {
|
|
536
|
+
const { registryID, attributes: attributeFilter } = this.parseRegistryIDOrAttributes(where);
|
|
537
|
+
const results = [];
|
|
538
|
+
if (!(useCache === true)) {
|
|
539
|
+
this.refreshWalker();
|
|
540
|
+
}
|
|
541
|
+
const walker = this.walker;
|
|
542
|
+
const commentNodes = [];
|
|
543
|
+
let comment;
|
|
544
|
+
while ((comment = walker.nextNode())) {
|
|
545
|
+
commentNodes.push(comment);
|
|
546
|
+
}
|
|
547
|
+
const tagShortcut = this.markerRegistry.shortcut(tagOrShortcut);
|
|
548
|
+
const stack = [];
|
|
549
|
+
// Process comments with stack-based matching
|
|
550
|
+
for (let i = 0; i < commentNodes.length; i++) {
|
|
551
|
+
const commentText = commentNodes[i].nodeValue?.trim() || '';
|
|
552
|
+
// Check if open tag: prefix:shortcut:registryID
|
|
553
|
+
const openMatch = commentText.match(new RegExp(`^${this.prefix}${this.delimiter}([^${this.delimiter}/]+)${this.delimiter}(.+)$`));
|
|
554
|
+
if (openMatch) {
|
|
555
|
+
const shortcut = openMatch[1];
|
|
556
|
+
const id = openMatch[2];
|
|
557
|
+
// Check if matches requested tag and registryID
|
|
558
|
+
if (shortcut === tagShortcut) {
|
|
559
|
+
if (registryID && id !== registryID) {
|
|
560
|
+
continue; // Skip if specific registryID requested
|
|
561
|
+
}
|
|
562
|
+
const attrs = this.getAttributesFromRegistry(tagOrShortcut, id);
|
|
563
|
+
if (!this.attributesMatch(attrs, attributeFilter)) {
|
|
564
|
+
continue; // Skip if attributes don't match
|
|
565
|
+
}
|
|
566
|
+
stack.push({
|
|
567
|
+
index: i,
|
|
568
|
+
shortcut,
|
|
569
|
+
registryID: id,
|
|
570
|
+
attributes: attrs
|
|
571
|
+
});
|
|
572
|
+
}
|
|
573
|
+
continue;
|
|
574
|
+
}
|
|
575
|
+
// Check if close tag: /prefix:shortcut:registryID
|
|
576
|
+
const closeMatch = commentText.match(new RegExp(`^${this.closeTagSuffix}${this.prefix}${this.delimiter}([^${this.delimiter}/]+)${this.delimiter}(.+)$`));
|
|
577
|
+
if (closeMatch) {
|
|
578
|
+
const shortcut = closeMatch[1];
|
|
579
|
+
const id = closeMatch[2];
|
|
580
|
+
// Find matching open tag in stack (LIFO)
|
|
581
|
+
let foundIndex = -1;
|
|
582
|
+
for (let s = stack.length - 1; s >= 0; s--) {
|
|
583
|
+
if (stack[s].shortcut === shortcut && stack[s].registryID === id) {
|
|
584
|
+
foundIndex = s;
|
|
585
|
+
break;
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
if (foundIndex !== -1) {
|
|
589
|
+
const openTag = stack[foundIndex];
|
|
590
|
+
// Get children between open and close
|
|
591
|
+
let currentNode = commentNodes[openTag.index].nextSibling;
|
|
592
|
+
const children = [];
|
|
593
|
+
while (currentNode && currentNode !== commentNodes[i]) {
|
|
594
|
+
children.push(currentNode);
|
|
595
|
+
currentNode = currentNode.nextSibling;
|
|
596
|
+
}
|
|
597
|
+
const fullTagName = this.resolveTagName(openTag.shortcut);
|
|
598
|
+
results.push({
|
|
599
|
+
name: fullTagName,
|
|
600
|
+
tagName: openTag.shortcut,
|
|
601
|
+
registryID: openTag.registryID,
|
|
602
|
+
attributes: openTag.attributes,
|
|
603
|
+
openTag: commentNodes[openTag.index],
|
|
604
|
+
closeTag: commentNodes[i],
|
|
605
|
+
children
|
|
606
|
+
});
|
|
607
|
+
stack.splice(foundIndex, 1);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
return results;
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* Find multiple hydration markers by tag and optional ID/attributes
|
|
615
|
+
* Flexible API supporting multiple query styles
|
|
616
|
+
*
|
|
617
|
+
* @param tagOrShortcut - Tag name or shortcut (r, v, c, etc.)
|
|
618
|
+
* @param registryIDOrAttributes - Optional registry ID (string) or attributes filter (object)
|
|
619
|
+
* @returns Array of all matched markers
|
|
620
|
+
*
|
|
621
|
+
* @example
|
|
622
|
+
* find("r") // All o:r:*
|
|
623
|
+
* find("reactive") // All o:r:* (resolved from shortcut)
|
|
624
|
+
* find("r", "1234") // All o:r:1234 (usually one)
|
|
625
|
+
* find("r", { userId: "123" }) // All o:r:* with userId="123"
|
|
626
|
+
*/
|
|
627
|
+
find(tagOrShortcut, where, useCache = true) {
|
|
628
|
+
return this.collect(this.query(tagOrShortcut, where, useCache));
|
|
629
|
+
}
|
|
630
|
+
getResults(tagOrShortcut, where, index, length, useCache = true) {
|
|
631
|
+
const startIndex = (typeof index === 'number' && index !== null) ? index : 0;
|
|
632
|
+
const takeLength = (typeof length === 'number' && length !== null && length > 0) ? length : 0;
|
|
633
|
+
const allResults = this.query(tagOrShortcut, where, useCache);
|
|
634
|
+
// Handle positive index
|
|
635
|
+
if (startIndex >= 0) {
|
|
636
|
+
const sliced = allResults.slice(startIndex);
|
|
637
|
+
if (takeLength > 0) {
|
|
638
|
+
return sliced.slice(0, takeLength);
|
|
639
|
+
}
|
|
640
|
+
return sliced;
|
|
641
|
+
}
|
|
642
|
+
// Handle negative index
|
|
643
|
+
const sliced = allResults.slice(startIndex);
|
|
644
|
+
if (takeLength > 0) {
|
|
645
|
+
return sliced.slice(0, takeLength);
|
|
646
|
+
}
|
|
647
|
+
return sliced;
|
|
648
|
+
}
|
|
649
|
+
/**
|
|
650
|
+
* Get hydration markers with index and length support
|
|
651
|
+
*
|
|
652
|
+
* @param tagOrShortcut - Tag name or shortcut
|
|
653
|
+
* @param where - Registry ID or attributes filter
|
|
654
|
+
* @param index - Start position (default 0): >= 0 positive, < 0 negative from end
|
|
655
|
+
* @param length - Number to return (default 0 = all): > 0 returns exactly that many
|
|
656
|
+
* @returns Array of matched markers
|
|
657
|
+
*
|
|
658
|
+
* @example
|
|
659
|
+
* get("r", "1234") // All o:r:1234
|
|
660
|
+
* get("r", "1234", 1) // From index 1
|
|
661
|
+
* get("r", "1234", 0, 2) // First 2 items
|
|
662
|
+
* get("r", {}, -1) // Last item
|
|
663
|
+
*/
|
|
664
|
+
get(tagOrShortcut, where, index, length, useCache = true) {
|
|
665
|
+
const results = this.getResults(tagOrShortcut, where, index, length, useCache);
|
|
666
|
+
return this.collect(results);
|
|
667
|
+
}
|
|
668
|
+
/**
|
|
669
|
+
* Get first matching hydration marker
|
|
670
|
+
*
|
|
671
|
+
* @param tagOrShortcut - Tag name or shortcut
|
|
672
|
+
* @param where - Registry ID or attributes filter
|
|
673
|
+
* @returns First matched marker or null
|
|
674
|
+
*/
|
|
675
|
+
first(tagOrShortcut, where, useCache = true) {
|
|
676
|
+
const results = this.getResults(tagOrShortcut, where, 0, 1, useCache);
|
|
677
|
+
return results.length > 0 ? this.toModel(results[0]) : null;
|
|
678
|
+
}
|
|
679
|
+
/**
|
|
680
|
+
* Get last matching hydration marker
|
|
681
|
+
*
|
|
682
|
+
* @param tagOrShortcut - Tag name or shortcut
|
|
683
|
+
* @param where - Registry ID or attributes filter
|
|
684
|
+
* @returns Last matched marker or null
|
|
685
|
+
*/
|
|
686
|
+
last(tagOrShortcut, where, useCache = true) {
|
|
687
|
+
const results = this.getResults(tagOrShortcut, where, -1, 1, useCache);
|
|
688
|
+
return results.length > 0 ? this.toModel(results[0]) : null;
|
|
689
|
+
}
|
|
690
|
+
/**
|
|
691
|
+
* Get exactly one matching hydration marker
|
|
692
|
+
* Throws error if not found or multiple matches found
|
|
693
|
+
*
|
|
694
|
+
* @param tagOrShortcut - Tag name or shortcut
|
|
695
|
+
* @param where - Registry ID or attributes filter
|
|
696
|
+
* @param index - Start position (default 0)
|
|
697
|
+
* @returns Exactly one matched marker
|
|
698
|
+
* @throws Error if no match or multiple matches
|
|
699
|
+
*/
|
|
700
|
+
once(tagOrShortcut, where, index, useCache = true) {
|
|
701
|
+
const startIndex = (typeof index === 'number' && index !== null) ? index : 0;
|
|
702
|
+
const results = this.getResults(tagOrShortcut, where, startIndex, 1, useCache);
|
|
703
|
+
if (!results || results.length === 0) {
|
|
704
|
+
return null; // Or throw new Error(`HydrationMarker: No marker found for "${tagOrShortcut}" with specified criteria`);
|
|
705
|
+
}
|
|
706
|
+
return this.toModel(results[0]);
|
|
707
|
+
}
|
|
708
|
+
/**
|
|
709
|
+
* Create MarkerCollection from query results
|
|
710
|
+
*/
|
|
711
|
+
collect(models) {
|
|
712
|
+
return new MarkerCollection(models);
|
|
713
|
+
}
|
|
714
|
+
/**
|
|
715
|
+
* Convert raw tag to MarkerModel
|
|
716
|
+
*/
|
|
717
|
+
toModel(tag) {
|
|
718
|
+
return new MarkerModel(tag);
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
MarkerService.class = 'HydrationMarker';
|
|
722
|
+
export const OneMarker = app(MarkerService);
|
|
723
|
+
//# sourceMappingURL=MarkerService.js.map
|