@saolabs/client 1.0.0 → 1.0.2
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 +52 -195
- package/dist/index.d.ts +20 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -3
- package/dist/index.js.map +1 -1
- package/dist/plugins.d.ts +2 -2
- package/dist/plugins.js +2 -2
- package/dist/src/core/app/Application.d.ts +17 -15
- package/dist/src/core/app/Application.d.ts.map +1 -1
- package/dist/src/core/app/Application.js +41 -18
- package/dist/src/core/app/Application.js.map +1 -1
- package/dist/src/core/bootstrap/app.d.ts +1 -1
- package/dist/src/core/bootstrap/app.d.ts.map +1 -1
- package/dist/src/core/bootstrap/app.js +74 -4
- package/dist/src/core/bootstrap/app.js.map +1 -1
- package/dist/src/core/bootstrap/bundle.d.ts +41 -0
- package/dist/src/core/bootstrap/bundle.d.ts.map +1 -0
- package/dist/src/core/bootstrap/bundle.js +98 -0
- package/dist/src/core/bootstrap/bundle.js.map +1 -0
- package/dist/src/core/bootstrap/providers/ApiServiceProvider.d.ts +1 -1
- package/dist/src/core/bootstrap/providers/ApiServiceProvider.d.ts.map +1 -1
- package/dist/src/core/bootstrap/providers/ApiServiceProvider.js +3 -3
- package/dist/src/core/bootstrap/providers/ApiServiceProvider.js.map +1 -1
- package/dist/src/core/bootstrap/providers/CoreServiceProvider.d.ts +1 -1
- package/dist/src/core/bootstrap/providers/CoreServiceProvider.d.ts.map +1 -1
- package/dist/src/core/bootstrap/providers/CoreServiceProvider.js +11 -8
- package/dist/src/core/bootstrap/providers/CoreServiceProvider.js.map +1 -1
- package/dist/src/core/bootstrap/providers/HelperServiceProvider.d.ts +3 -1
- package/dist/src/core/bootstrap/providers/HelperServiceProvider.d.ts.map +1 -1
- package/dist/src/core/bootstrap/providers/HelperServiceProvider.js +8 -3
- package/dist/src/core/bootstrap/providers/HelperServiceProvider.js.map +1 -1
- package/dist/src/core/bootstrap/providers/RouteServiceProvider.d.ts +2 -1
- package/dist/src/core/bootstrap/providers/RouteServiceProvider.d.ts.map +1 -1
- package/dist/src/core/bootstrap/providers/RouteServiceProvider.js +14 -4
- package/dist/src/core/bootstrap/providers/RouteServiceProvider.js.map +1 -1
- package/dist/src/core/bootstrap/providers/ServiceProvider.d.ts +4 -4
- package/dist/src/core/bootstrap/providers/ServiceProvider.d.ts.map +1 -1
- package/dist/src/core/bootstrap/providers/ServiceProvider.js +5 -5
- package/dist/src/core/bootstrap/providers/ServiceProvider.js.map +1 -1
- package/dist/src/core/bootstrap/providers/ViewServiceProvider.d.ts +1 -1
- package/dist/src/core/bootstrap/providers/ViewServiceProvider.d.ts.map +1 -1
- package/dist/src/core/bootstrap/providers/ViewServiceProvider.js +3 -3
- package/dist/src/core/bootstrap/providers/ViewServiceProvider.js.map +1 -1
- package/dist/src/core/bootstrap/providers/default-providers.d.ts +1 -1
- package/dist/src/core/bootstrap/providers/default-providers.d.ts.map +1 -1
- package/dist/src/core/bootstrap/providers/default-providers.js +44 -11
- package/dist/src/core/bootstrap/providers/default-providers.js.map +1 -1
- package/dist/src/core/bootstrap/providers/index.d.ts +9 -9
- package/dist/src/core/bootstrap/providers/index.d.ts.map +1 -1
- package/dist/src/core/bootstrap/providers/index.js +8 -8
- package/dist/src/core/bootstrap/providers/index.js.map +1 -1
- package/dist/src/core/bootstrap/providers/provider-order.d.ts +1 -1
- package/dist/src/core/bootstrap/providers/provider-order.d.ts.map +1 -1
- package/dist/src/core/bootstrap/ssr.d.ts +47 -0
- package/dist/src/core/bootstrap/ssr.d.ts.map +1 -0
- package/dist/src/core/bootstrap/ssr.js +125 -0
- package/dist/src/core/bootstrap/ssr.js.map +1 -0
- package/dist/src/core/cache/ViewCache.d.ts +1 -1
- package/dist/src/core/cache/ViewCache.d.ts.map +1 -1
- package/dist/src/core/cache/index.d.ts +1 -1
- package/dist/src/core/cache/index.d.ts.map +1 -1
- package/dist/src/core/cache/index.js +1 -1
- package/dist/src/core/cache/index.js.map +1 -1
- package/dist/src/core/contracts/ApplicationInterface.d.ts +13 -11
- package/dist/src/core/contracts/ApplicationInterface.d.ts.map +1 -1
- package/dist/src/core/contracts/BlockInterface.d.ts +10 -10
- package/dist/src/core/contracts/BlockInterface.d.ts.map +1 -1
- package/dist/src/core/contracts/BundleInterface.d.ts +38 -0
- package/dist/src/core/contracts/BundleInterface.d.ts.map +1 -0
- package/dist/src/core/contracts/BundleInterface.js +2 -0
- package/dist/src/core/contracts/BundleInterface.js.map +1 -0
- package/dist/src/core/contracts/ComponentInterface.d.ts +7 -6
- package/dist/src/core/contracts/ComponentInterface.d.ts.map +1 -1
- package/dist/src/core/contracts/ElementInterface.d.ts +91 -27
- package/dist/src/core/contracts/ElementInterface.d.ts.map +1 -1
- package/dist/src/core/contracts/HeadServiceInterface.d.ts +37 -0
- package/dist/src/core/contracts/HeadServiceInterface.d.ts.map +1 -0
- package/dist/src/core/contracts/HeadServiceInterface.js +3 -0
- package/dist/src/core/contracts/HeadServiceInterface.js.map +1 -0
- package/dist/src/core/contracts/HelperInterface.d.ts +9 -1
- package/dist/src/core/contracts/HelperInterface.d.ts.map +1 -1
- package/dist/src/core/contracts/HttpServiceInterface.d.ts +3 -0
- package/dist/src/core/contracts/HttpServiceInterface.d.ts.map +1 -1
- package/dist/src/core/contracts/MarkerInterface.d.ts +29 -44
- package/dist/src/core/contracts/MarkerInterface.d.ts.map +1 -1
- package/dist/src/core/contracts/ReactiveInterface.d.ts +9 -9
- package/dist/src/core/contracts/ReactiveInterface.d.ts.map +1 -1
- package/dist/src/core/contracts/RouterInterface.d.ts +5 -2
- package/dist/src/core/contracts/RouterInterface.d.ts.map +1 -1
- package/dist/src/core/contracts/SectionInterface.d.ts +48 -0
- package/dist/src/core/contracts/SectionInterface.d.ts.map +1 -0
- package/dist/src/core/contracts/SectionInterface.js +2 -0
- package/dist/src/core/contracts/SectionInterface.js.map +1 -0
- package/dist/src/core/contracts/ServiceProviderInterface.d.ts +3 -3
- package/dist/src/core/contracts/ServiceProviderInterface.d.ts.map +1 -1
- package/dist/src/core/contracts/ViewControllerInterface.d.ts +116 -15
- package/dist/src/core/contracts/ViewControllerInterface.d.ts.map +1 -1
- package/dist/src/core/contracts/ViewInterface.d.ts +31 -5
- package/dist/src/core/contracts/ViewInterface.d.ts.map +1 -1
- package/dist/src/core/contracts/ViewManagerInterface.d.ts +47 -5
- package/dist/src/core/contracts/ViewManagerInterface.d.ts.map +1 -1
- package/dist/src/core/contracts/ViewStateInterface.d.ts +39 -2
- package/dist/src/core/contracts/ViewStateInterface.d.ts.map +1 -1
- package/dist/src/core/contracts/common.d.ts +3 -3
- package/dist/src/core/contracts/common.js +3 -3
- package/dist/src/core/contracts/utils.d.ts +19 -19
- package/dist/src/core/contracts/utils.d.ts.map +1 -1
- package/dist/src/core/contracts/views.d.ts +1 -22
- package/dist/src/core/contracts/views.d.ts.map +1 -1
- package/dist/src/core/devtools/hook.d.ts +66 -0
- package/dist/src/core/devtools/hook.d.ts.map +1 -0
- package/dist/src/core/devtools/hook.js +114 -0
- package/dist/src/core/devtools/hook.js.map +1 -0
- package/dist/src/core/devtools/index.d.ts +34 -0
- package/dist/src/core/devtools/index.d.ts.map +1 -0
- package/dist/src/core/devtools/index.js +33 -0
- package/dist/src/core/devtools/index.js.map +1 -0
- package/dist/src/core/devtools/inspector.d.ts +31 -0
- package/dist/src/core/devtools/inspector.d.ts.map +1 -0
- package/dist/src/core/devtools/inspector.js +249 -0
- package/dist/src/core/devtools/inspector.js.map +1 -0
- package/dist/src/core/elements/Block.d.ts +9 -7
- package/dist/src/core/elements/Block.d.ts.map +1 -1
- package/dist/src/core/elements/Block.js +33 -9
- package/dist/src/core/elements/Block.js.map +1 -1
- package/dist/src/core/elements/BlockOutlet.d.ts +19 -8
- package/dist/src/core/elements/BlockOutlet.d.ts.map +1 -1
- package/dist/src/core/elements/BlockOutlet.js +57 -13
- package/dist/src/core/elements/BlockOutlet.js.map +1 -1
- package/dist/src/core/elements/Component.d.ts +83 -11
- package/dist/src/core/elements/Component.d.ts.map +1 -1
- package/dist/src/core/elements/Component.js +334 -13
- package/dist/src/core/elements/Component.js.map +1 -1
- package/dist/src/core/elements/ForeachSlotCache.d.ts +95 -0
- package/dist/src/core/elements/ForeachSlotCache.d.ts.map +1 -0
- package/dist/src/core/elements/ForeachSlotCache.js +149 -0
- package/dist/src/core/elements/ForeachSlotCache.js.map +1 -0
- package/dist/src/core/elements/Fragment.d.ts +19 -13
- package/dist/src/core/elements/Fragment.d.ts.map +1 -1
- package/dist/src/core/elements/Fragment.js +43 -20
- package/dist/src/core/elements/Fragment.js.map +1 -1
- package/dist/src/core/elements/Html.d.ts +89 -12
- package/dist/src/core/elements/Html.d.ts.map +1 -1
- package/dist/src/core/elements/Html.js +707 -106
- package/dist/src/core/elements/Html.js.map +1 -1
- package/dist/src/core/elements/Output.d.ts +34 -10
- package/dist/src/core/elements/Output.d.ts.map +1 -1
- package/dist/src/core/elements/Output.js +141 -26
- package/dist/src/core/elements/Output.js.map +1 -1
- package/dist/src/core/elements/Reactive.d.ts +85 -14
- package/dist/src/core/elements/Reactive.d.ts.map +1 -1
- package/dist/src/core/elements/Reactive.js +315 -41
- package/dist/src/core/elements/Reactive.js.map +1 -1
- package/dist/src/core/elements/TextElement.d.ts +11 -7
- package/dist/src/core/elements/TextElement.d.ts.map +1 -1
- package/dist/src/core/elements/TextElement.js +18 -11
- package/dist/src/core/elements/TextElement.js.map +1 -1
- package/dist/src/core/elements/Wrapper.d.ts +24 -13
- package/dist/src/core/elements/Wrapper.d.ts.map +1 -1
- package/dist/src/core/elements/Wrapper.js +65 -8
- package/dist/src/core/elements/Wrapper.js.map +1 -1
- package/dist/src/core/elements/Yield.d.ts +10 -9
- package/dist/src/core/elements/Yield.d.ts.map +1 -1
- package/dist/src/core/elements/Yield.js +31 -19
- package/dist/src/core/elements/Yield.js.map +1 -1
- package/dist/src/core/elements/helpers.d.ts +7 -7
- package/dist/src/core/elements/helpers.d.ts.map +1 -1
- package/dist/src/core/elements/helpers.js +4 -4
- package/dist/src/core/elements/index.d.ts +12 -11
- package/dist/src/core/elements/index.d.ts.map +1 -1
- package/dist/src/core/elements/index.js +12 -11
- package/dist/src/core/elements/index.js.map +1 -1
- package/dist/src/core/elements/reconcileChildren.d.ts +7 -0
- package/dist/src/core/elements/reconcileChildren.d.ts.map +1 -0
- package/dist/src/core/elements/reconcileChildren.js +74 -0
- package/dist/src/core/elements/reconcileChildren.js.map +1 -0
- package/dist/src/core/hellpers/utils.d.ts +2 -2
- package/dist/src/core/hellpers/utils.js +4 -4
- package/dist/src/core/helpers/ApiClient.d.ts +58 -0
- package/dist/src/core/helpers/ApiClient.d.ts.map +1 -0
- package/dist/src/core/helpers/ApiClient.js +131 -0
- package/dist/src/core/helpers/ApiClient.js.map +1 -0
- package/dist/src/core/helpers/app.d.ts +3 -0
- package/dist/src/core/helpers/app.d.ts.map +1 -0
- package/dist/src/core/helpers/app.js +63 -0
- package/dist/src/core/helpers/app.js.map +1 -0
- package/dist/src/core/helpers/transition.d.ts +34 -0
- package/dist/src/core/helpers/transition.d.ts.map +1 -0
- package/dist/src/core/helpers/transition.js +118 -0
- package/dist/src/core/helpers/transition.js.map +1 -0
- package/dist/src/core/helpers/utils.d.ts +26 -0
- package/dist/src/core/helpers/utils.d.ts.map +1 -0
- package/dist/src/core/helpers/utils.js +96 -0
- package/dist/src/core/helpers/utils.js.map +1 -0
- package/dist/src/core/helpers/view.d.ts +39 -0
- package/dist/src/core/helpers/view.d.ts.map +1 -0
- package/dist/src/core/helpers/view.js +286 -0
- package/dist/src/core/helpers/view.js.map +1 -0
- package/dist/src/core/routers/Router.d.ts +108 -7
- package/dist/src/core/routers/Router.d.ts.map +1 -1
- package/dist/src/core/routers/Router.js +444 -68
- package/dist/src/core/routers/Router.js.map +1 -1
- package/dist/src/core/routers/index.d.ts +2 -2
- package/dist/src/core/routers/index.d.ts.map +1 -1
- package/dist/src/core/routers/index.js +1 -1
- package/dist/src/core/routers/index.js.map +1 -1
- package/dist/src/core/services/AssetManager.d.ts +112 -0
- package/dist/src/core/services/AssetManager.d.ts.map +1 -0
- package/dist/src/core/services/AssetManager.js +361 -0
- package/dist/src/core/services/AssetManager.js.map +1 -0
- package/dist/src/core/services/BlockManager.d.ts +73 -2
- package/dist/src/core/services/BlockManager.d.ts.map +1 -1
- package/dist/src/core/services/BlockManager.js +270 -48
- package/dist/src/core/services/BlockManager.js.map +1 -1
- package/dist/src/core/services/DomService.js +3 -3
- package/dist/src/core/services/DomService.js.map +1 -1
- package/dist/src/core/services/HeadService.d.ts +24 -0
- package/dist/src/core/services/HeadService.d.ts.map +1 -0
- package/dist/src/core/services/HeadService.js +120 -0
- package/dist/src/core/services/HeadService.js.map +1 -0
- package/dist/src/core/services/HelperService.d.ts +14 -3
- package/dist/src/core/services/HelperService.d.ts.map +1 -1
- package/dist/src/core/services/HelperService.js +32 -2
- package/dist/src/core/services/HelperService.js.map +1 -1
- package/dist/src/core/services/HttpService.d.ts +8 -0
- package/dist/src/core/services/HttpService.d.ts.map +1 -1
- package/dist/src/core/services/HttpService.js +121 -47
- package/dist/src/core/services/HttpService.js.map +1 -1
- package/dist/src/core/services/MarkerRegistry.d.ts +51 -8
- package/dist/src/core/services/MarkerRegistry.d.ts.map +1 -1
- package/dist/src/core/services/MarkerRegistry.js +135 -14
- package/dist/src/core/services/MarkerRegistry.js.map +1 -1
- package/dist/src/core/services/PageCache.d.ts +101 -0
- package/dist/src/core/services/PageCache.d.ts.map +1 -0
- package/dist/src/core/services/PageCache.js +184 -0
- package/dist/src/core/services/PageCache.js.map +1 -0
- package/dist/src/core/services/SectionManager.d.ts +100 -0
- package/dist/src/core/services/SectionManager.d.ts.map +1 -0
- package/dist/src/core/services/SectionManager.js +408 -0
- package/dist/src/core/services/SectionManager.js.map +1 -0
- package/dist/src/core/services/StorageService.js +1 -1
- package/dist/src/core/services/TranslationService.d.ts +21 -0
- package/dist/src/core/services/TranslationService.d.ts.map +1 -0
- package/dist/src/core/services/TranslationService.js +95 -0
- package/dist/src/core/services/TranslationService.js.map +1 -0
- package/dist/src/core/services/index.d.ts +11 -8
- package/dist/src/core/services/index.d.ts.map +1 -1
- package/dist/src/core/services/index.js +11 -8
- package/dist/src/core/services/index.js.map +1 -1
- package/dist/src/core/types/utils.d.ts +8 -8
- package/dist/src/core/types/utils.d.ts.map +1 -1
- package/dist/src/core/view/LoopContext.d.ts +21 -1
- package/dist/src/core/view/LoopContext.d.ts.map +1 -1
- package/dist/src/core/view/LoopContext.js +36 -0
- package/dist/src/core/view/LoopContext.js.map +1 -1
- package/dist/src/core/view/ResourceScope.d.ts +38 -0
- package/dist/src/core/view/ResourceScope.d.ts.map +1 -0
- package/dist/src/core/view/ResourceScope.js +167 -0
- package/dist/src/core/view/ResourceScope.js.map +1 -0
- package/dist/src/core/view/Section.d.ts +17 -32
- package/dist/src/core/view/Section.d.ts.map +1 -1
- package/dist/src/core/view/Section.js +14 -55
- package/dist/src/core/view/Section.js.map +1 -1
- package/dist/src/core/view/View.d.ts +43 -7
- package/dist/src/core/view/View.d.ts.map +1 -1
- package/dist/src/core/view/View.js +22 -4
- package/dist/src/core/view/View.js.map +1 -1
- package/dist/src/core/view/ViewController.d.ts +313 -40
- package/dist/src/core/view/ViewController.d.ts.map +1 -1
- package/dist/src/core/view/ViewController.js +1002 -147
- package/dist/src/core/view/ViewController.js.map +1 -1
- package/dist/src/core/view/ViewManager.d.ts +318 -27
- package/dist/src/core/view/ViewManager.d.ts.map +1 -1
- package/dist/src/core/view/ViewManager.js +1199 -258
- package/dist/src/core/view/ViewManager.js.map +1 -1
- package/dist/src/core/view/ViewState.d.ts +185 -6
- package/dist/src/core/view/ViewState.d.ts.map +1 -1
- package/dist/src/core/view/ViewState.js +851 -123
- package/dist/src/core/view/ViewState.js.map +1 -1
- package/dist/src/core/view/index.d.ts +5 -5
- package/dist/src/core/view/index.d.ts.map +1 -1
- package/dist/src/core/view/index.js +5 -5
- package/dist/src/core/view/index.js.map +1 -1
- package/dist/src/testing/index.d.ts +69 -0
- package/dist/src/testing/index.d.ts.map +1 -0
- package/dist/src/testing/index.js +140 -0
- package/dist/src/testing/index.js.map +1 -0
- package/index.ts +29 -5
- package/package.json +30 -21
- package/plugins.ts +2 -2
- package/src/core/app/Application.ts +58 -31
- package/src/core/bootstrap/app.ts +80 -6
- package/src/core/bootstrap/bundle.ts +101 -0
- package/src/core/bootstrap/providers/ApiServiceProvider.ts +4 -4
- package/src/core/bootstrap/providers/CoreServiceProvider.ts +14 -8
- package/src/core/bootstrap/providers/HelperServiceProvider.ts +8 -3
- package/src/core/bootstrap/providers/RouteServiceProvider.ts +15 -4
- package/src/core/bootstrap/providers/ServiceProvider.ts +8 -8
- package/src/core/bootstrap/providers/ViewServiceProvider.ts +3 -3
- package/src/core/bootstrap/providers/default-providers.ts +51 -16
- package/src/core/bootstrap/providers/index.ts +9 -9
- package/src/core/bootstrap/providers/provider-order.test.ts +16 -27
- package/src/core/bootstrap/providers/provider-order.ts +1 -1
- package/src/core/bootstrap/ssr.ts +136 -0
- package/src/core/cache/ViewCache.ts +1 -1
- package/src/core/cache/index.ts +1 -1
- package/src/core/contracts/ApplicationInterface.ts +13 -11
- package/src/core/contracts/BlockInterface.ts +18 -18
- package/src/core/contracts/BundleInterface.ts +40 -0
- package/src/core/contracts/ComponentInterface.ts +7 -6
- package/src/core/contracts/ElementInterface.ts +95 -27
- package/src/core/contracts/HeadServiceInterface.ts +41 -0
- package/src/core/contracts/HelperInterface.ts +9 -1
- package/src/core/contracts/HttpServiceInterface.ts +3 -0
- package/src/core/contracts/MarkerInterface.ts +22 -49
- package/src/core/contracts/ReactiveInterface.ts +9 -9
- package/src/core/contracts/RouterInterface.ts +5 -2
- package/src/core/contracts/SectionInterface.ts +49 -0
- package/src/core/contracts/ServiceProviderInterface.ts +3 -3
- package/src/core/contracts/ViewControllerInterface.ts +124 -16
- package/src/core/contracts/ViewInterface.ts +34 -5
- package/src/core/contracts/ViewManagerInterface.ts +40 -5
- package/src/core/contracts/ViewStateInterface.ts +39 -2
- package/src/core/contracts/common.ts +3 -3
- package/src/core/contracts/utils.ts +19 -19
- package/src/core/contracts/views.ts +2 -22
- package/src/core/devtools/hook.ts +142 -0
- package/src/core/devtools/index.ts +38 -0
- package/src/core/devtools/inspector.ts +270 -0
- package/src/core/elements/Block.ts +43 -21
- package/src/core/elements/BlockOutlet.ts +61 -21
- package/src/core/elements/Component.ts +352 -18
- package/src/core/elements/ElementManager.ts +9 -9
- package/src/core/elements/ForeachSlotCache.ts +170 -0
- package/src/core/elements/Fragment.ts +50 -32
- package/src/core/elements/Html.ts +696 -117
- package/src/core/elements/Output.ts +147 -30
- package/src/core/elements/Reactive.ts +329 -52
- package/src/core/elements/TextElement.ts +25 -16
- package/src/core/elements/Wrapper.ts +84 -18
- package/src/core/elements/Yield.ts +35 -24
- package/src/core/elements/helpers.ts +12 -12
- package/src/core/elements/index.ts +25 -24
- package/src/core/elements/reconcileChildren.ts +70 -0
- package/src/core/{hellpers → helpers}/ApiClient.ts +8 -1
- package/src/core/{hellpers → helpers}/app.ts +13 -2
- package/src/core/helpers/transition.ts +127 -0
- package/src/core/{hellpers → helpers}/utils.ts +4 -4
- package/src/core/helpers/view.ts +283 -0
- package/src/core/routers/Router.ts +458 -64
- package/src/core/routers/index.ts +2 -2
- package/src/core/services/AssetManager.ts +387 -0
- package/src/core/services/BlockManager.ts +272 -50
- package/src/core/services/DomService.ts +3 -3
- package/src/core/services/HeadService.ts +124 -0
- package/src/core/services/HelperService.ts +34 -4
- package/src/core/services/HttpService.ts +116 -55
- package/src/core/services/MarkerRegistry.ts +142 -16
- package/src/core/services/PageCache.ts +239 -0
- package/src/core/services/SectionManager.ts +387 -0
- package/src/core/services/StorageService.ts +1 -1
- package/src/core/services/TranslationService.ts +91 -0
- package/src/core/services/index.ts +11 -8
- package/src/core/types/utils.ts +8 -8
- package/src/core/view/LoopContext.ts +38 -1
- package/src/core/view/ResourceScope.ts +174 -0
- package/src/core/view/Section.ts +21 -68
- package/src/core/view/View.ts +57 -8
- package/src/core/view/ViewController.ts +1070 -186
- package/src/core/view/ViewManager.ts +1346 -272
- package/src/core/view/ViewState.ts +834 -116
- package/src/core/view/index.ts +5 -5
- package/src/testing/index.ts +184 -0
- package/dist/src/core/services/MarkerService.d.ts +0 -299
- package/dist/src/core/services/MarkerService.d.ts.map +0 -1
- package/dist/src/core/services/MarkerService.js +0 -723
- package/dist/src/core/services/MarkerService.js.map +0 -1
- package/src/core/services/MarkerService.ts +0 -923
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { InitMode, InitModes } from "../contracts/common";
|
|
2
|
-
import type { HtmlInterface, OutputInterface } from "../contracts/ElementInterface";
|
|
3
|
-
import type { ViewControllerInterface } from "../contracts/ViewControllerInterface";
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
1
|
+
import { InitMode, InitModes } from "../contracts/common.js";
|
|
2
|
+
import type { HtmlInterface, OutputInterface } from "../contracts/ElementInterface.js";
|
|
3
|
+
import type { ViewControllerInterface } from "../contracts/ViewControllerInterface.js";
|
|
4
|
+
import { generateUUID } from "../helpers/utils.js";
|
|
5
|
+
import markerRegistry from "../services/MarkerRegistry.js";
|
|
6
|
+
import type { SaoObjectType } from "../types/utils.js";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Output — reactive text output between comment markers.
|
|
@@ -14,7 +15,7 @@ import type { OneObjectType } from "../types/utils";
|
|
|
14
15
|
* Update: Khi stateKeys thay đổi → re-evaluate contentFactory → update textContent
|
|
15
16
|
*/
|
|
16
17
|
export class Output implements OutputInterface {
|
|
17
|
-
|
|
18
|
+
saoType: SaoObjectType = 'Output';
|
|
18
19
|
ctx: ViewControllerInterface;
|
|
19
20
|
parent: HtmlInterface | null;
|
|
20
21
|
openTag: Comment;
|
|
@@ -53,10 +54,54 @@ export class Output implements OutputInterface {
|
|
|
53
54
|
this.contentFactory = contentFactory;
|
|
54
55
|
this.isEscapeHTML = isEscapeHTML;
|
|
55
56
|
this.id = `${ctx.viewId}-${id ?? generateUUID(8)}`;
|
|
56
|
-
|
|
57
|
+
|
|
57
58
|
this.initMode = initMode;
|
|
58
|
-
|
|
59
|
-
this.
|
|
59
|
+
|
|
60
|
+
if (this.initMode === InitModes.HYDRATE) {
|
|
61
|
+
// ── SSR Hydration: tìm markers đã có trong DOM ──────────────────
|
|
62
|
+
// Blade emit: <!--o:{viewId}-{id}-s--> ... <!--o:{viewId}-{id}-e-->
|
|
63
|
+
// Nếu tìm thấy → claim, kèm text node giữa markers.
|
|
64
|
+
// Nếu không → tạo mới (partial hydration fallback).
|
|
65
|
+
const claimed = this.claimSSRMarkers();
|
|
66
|
+
if (claimed) {
|
|
67
|
+
this.openTag = claimed.open;
|
|
68
|
+
this.closeTag = claimed.close;
|
|
69
|
+
this.textNode = claimed.textNode;
|
|
70
|
+
} else {
|
|
71
|
+
this.openTag = markerRegistry.createMarkerStart('output', this.id);
|
|
72
|
+
this.closeTag = markerRegistry.createMarkerEnd('output', this.id);
|
|
73
|
+
}
|
|
74
|
+
} else {
|
|
75
|
+
// ── CSR: tạo markers mới ─────────────────────────────────────────
|
|
76
|
+
this.openTag = markerRegistry.createMarkerStart('output', this.id);
|
|
77
|
+
this.closeTag = markerRegistry.createMarkerEnd('output', this.id);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Tìm cặp comment markers và text node từ server-rendered HTML.
|
|
83
|
+
*
|
|
84
|
+
* Duyệt comment nodes trong parent element, tìm cặp khớp format chuẩn §5.1:
|
|
85
|
+
* open: `s:o:{this.id}-s`
|
|
86
|
+
* close: `s:o:{this.id}-e`
|
|
87
|
+
*
|
|
88
|
+
* Nếu có text node giữa 2 markers → claim luôn để không tạo thừa.
|
|
89
|
+
*/
|
|
90
|
+
private claimSSRMarkers(): { open: Comment; close: Comment; textNode: Text | null } | null {
|
|
91
|
+
const pair = markerRegistry.claim('output', this.id, this.parent?.element ?? null);
|
|
92
|
+
if (!pair) return null;
|
|
93
|
+
|
|
94
|
+
// Text node giữa 2 marker — claim luôn để không tạo thừa.
|
|
95
|
+
let textNode: Text | null = null;
|
|
96
|
+
let sibling = pair.open.nextSibling;
|
|
97
|
+
while (sibling && sibling !== pair.close) {
|
|
98
|
+
if (sibling.nodeType === Node.TEXT_NODE) {
|
|
99
|
+
textNode = sibling as Text;
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
sibling = sibling.nextSibling;
|
|
103
|
+
}
|
|
104
|
+
return { open: pair.open, close: pair.close, textNode };
|
|
60
105
|
}
|
|
61
106
|
|
|
62
107
|
setParentElement(parent: HtmlInterface | null): void {
|
|
@@ -74,23 +119,73 @@ export class Output implements OutputInterface {
|
|
|
74
119
|
}
|
|
75
120
|
}
|
|
76
121
|
|
|
122
|
+
/** Nodes của raw HTML mode ({!! !!}) — track để clear khi update */
|
|
123
|
+
private rawNodes: Node[] = [];
|
|
124
|
+
|
|
77
125
|
/**
|
|
78
|
-
* Render —
|
|
126
|
+
* Render — idempotent + position-aware (RUNTIME_CONTRACT.md §2):
|
|
127
|
+
* - Markers chưa nằm trong DOM → caller chưa đặt → tự append vào parent
|
|
128
|
+
* (đường mountElementList: thứ tự duyệt tuần tự nên vị trí đúng).
|
|
129
|
+
* - Markers ĐÃ nằm trong DOM (caller như Reactive đã chèn đúng chỗ)
|
|
130
|
+
* → chỉ render nội dung GIỮA markers. FIX(baseline#6).
|
|
79
131
|
*/
|
|
80
132
|
render(): void {
|
|
81
|
-
if (
|
|
133
|
+
if (this._isDestroyed) return;
|
|
134
|
+
|
|
135
|
+
// ── Hydrate mode: markers đã trong DOM, text node đã claim ──────
|
|
136
|
+
// Chỉ cần đảm bảo markers có mặt và text đồng bộ với state hiện tại.
|
|
137
|
+
// Không tạo thêm node, không clear — giữ nguyên DOM server-rendered.
|
|
138
|
+
if (this.initMode === InitModes.HYDRATE && this.openTag.parentNode && this.textNode) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
82
141
|
|
|
83
|
-
|
|
142
|
+
if (this.openTag.parentNode && this.textNode) {
|
|
143
|
+
this.update();
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
if (!this.openTag.parentNode) {
|
|
147
|
+
const parentEl = this.parent?.element;
|
|
148
|
+
if (!parentEl) return;
|
|
149
|
+
parentEl.appendChild(this.openTag);
|
|
150
|
+
parentEl.appendChild(this.closeTag);
|
|
151
|
+
}
|
|
84
152
|
|
|
85
|
-
|
|
86
|
-
parentEl.appendChild(this.openTag);
|
|
153
|
+
this.clearContent();
|
|
87
154
|
|
|
88
155
|
const rawText = String(this.contentFactory() ?? '');
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
156
|
+
if (this.isEscapeHTML) {
|
|
157
|
+
this.textNode = document.createTextNode(rawText);
|
|
158
|
+
this.insertBeforeClose(this.textNode);
|
|
159
|
+
} else {
|
|
160
|
+
this.renderRaw(rawText);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** Xoá toàn bộ nodes giữa open/close markers */
|
|
165
|
+
private clearContent(): void {
|
|
166
|
+
let current: Node | null = this.openTag.nextSibling;
|
|
167
|
+
while (current && current !== this.closeTag) {
|
|
168
|
+
const next: Node | null = current.nextSibling;
|
|
169
|
+
(current as ChildNode).remove();
|
|
170
|
+
current = next;
|
|
171
|
+
}
|
|
172
|
+
this.textNode = null;
|
|
173
|
+
this.rawNodes = [];
|
|
174
|
+
}
|
|
92
175
|
|
|
93
|
-
|
|
176
|
+
private insertBeforeClose(node: Node): void {
|
|
177
|
+
this.closeTag.parentNode?.insertBefore(node, this.closeTag);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** Parse HTML string → DOM nodes thật, chèn giữa markers */
|
|
181
|
+
private renderRaw(html: string): void {
|
|
182
|
+
if (!html) return;
|
|
183
|
+
const range = document.createRange();
|
|
184
|
+
const container = (this.closeTag.parentNode as HTMLElement) ?? document.body;
|
|
185
|
+
range.selectNodeContents(container);
|
|
186
|
+
const fragment = range.createContextualFragment(html);
|
|
187
|
+
this.rawNodes = Array.from(fragment.childNodes);
|
|
188
|
+
this.insertBeforeClose(fragment);
|
|
94
189
|
}
|
|
95
190
|
|
|
96
191
|
/**
|
|
@@ -123,33 +218,55 @@ export class Output implements OutputInterface {
|
|
|
123
218
|
}
|
|
124
219
|
|
|
125
220
|
/**
|
|
126
|
-
* Update — re-evaluate contentFactory
|
|
127
|
-
* O(1) — chỉ thay textContent
|
|
221
|
+
* Update — re-evaluate contentFactory.
|
|
222
|
+
* Escaped mode: O(1) — chỉ thay textContent.
|
|
223
|
+
* Raw mode: clear giữa markers → parse + chèn lại.
|
|
128
224
|
*/
|
|
129
225
|
private update(): void {
|
|
130
|
-
if (
|
|
226
|
+
if (this._isDestroyed) return;
|
|
131
227
|
|
|
132
228
|
const rawText = String(this.contentFactory() ?? '');
|
|
133
|
-
const displayText = this.isEscapeHTML ? escapeHTML(rawText) : rawText;
|
|
134
229
|
|
|
135
|
-
if (this.
|
|
136
|
-
this.textNode.textContent
|
|
230
|
+
if (this.isEscapeHTML && this.textNode) {
|
|
231
|
+
if (this.textNode.textContent !== rawText) {
|
|
232
|
+
this.textNode.textContent = rawText;
|
|
233
|
+
}
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// Raw mode hoặc textNode chưa tồn tại → render lại nội dung giữa markers
|
|
238
|
+
if (this.openTag.parentNode) {
|
|
239
|
+
this.clearContent();
|
|
240
|
+
if (this.isEscapeHTML) {
|
|
241
|
+
this.textNode = document.createTextNode(rawText);
|
|
242
|
+
this.insertBeforeClose(this.textNode);
|
|
243
|
+
} else {
|
|
244
|
+
this.renderRaw(rawText);
|
|
245
|
+
}
|
|
137
246
|
}
|
|
138
247
|
}
|
|
139
248
|
|
|
140
249
|
/**
|
|
141
250
|
* Destroy — cleanup everything.
|
|
142
251
|
*/
|
|
252
|
+
/** Registry guard — alias của _isDestroyed cho ViewController.aliveFromRegistry */
|
|
253
|
+
public get __destroyed__(): boolean { return this._isDestroyed; }
|
|
254
|
+
|
|
143
255
|
destroy(): void {
|
|
144
256
|
if (this._isDestroyed) return;
|
|
145
257
|
this._isDestroyed = true;
|
|
258
|
+
this.ctx.releaseElement?.(this);
|
|
146
259
|
this.stop();
|
|
147
260
|
|
|
148
|
-
// Remove text node
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
261
|
+
// Remove mọi nội dung giữa markers (text node hoặc raw nodes)
|
|
262
|
+
let current: Node | null = this.openTag.nextSibling;
|
|
263
|
+
while (current && current !== this.closeTag) {
|
|
264
|
+
const next: Node | null = current.nextSibling;
|
|
265
|
+
(current as ChildNode).remove();
|
|
266
|
+
current = next;
|
|
152
267
|
}
|
|
268
|
+
this.textNode = null;
|
|
269
|
+
this.rawNodes = [];
|
|
153
270
|
|
|
154
271
|
// Remove markers
|
|
155
272
|
this.openTag.remove();
|
|
@@ -160,8 +277,8 @@ export class Output implements OutputInterface {
|
|
|
160
277
|
|
|
161
278
|
// ─── OneElement markers ─────────────────────────────
|
|
162
279
|
|
|
163
|
-
get
|
|
164
|
-
set
|
|
280
|
+
get isSaoElement(): boolean { return true; }
|
|
281
|
+
set isSaoElement(_: boolean) {}
|
|
165
282
|
get isOneOutput(): boolean { return true; }
|
|
166
283
|
set isOneOutput(_: boolean) {}
|
|
167
284
|
}
|