@saolabs/client 1.0.0 → 1.1.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 +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 +25 -15
- package/dist/src/core/app/Application.d.ts.map +1 -1
- package/dist/src/core/app/Application.js +55 -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 +77 -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 +129 -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 +15 -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/helpers/ApiClient.d.ts.map +1 -0
- package/dist/src/core/{hellpers → helpers}/ApiClient.js +10 -1
- 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/{hellpers → helpers}/app.js +11 -1
- 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/{hellpers → helpers}/utils.d.ts +2 -2
- package/dist/src/core/helpers/utils.d.ts.map +1 -0
- package/dist/src/core/{hellpers → helpers}/utils.js +4 -4
- 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 +72 -31
- package/src/core/bootstrap/app.ts +84 -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 +141 -0
- package/src/core/cache/ViewCache.ts +1 -1
- package/src/core/cache/index.ts +1 -1
- package/src/core/contracts/ApplicationInterface.ts +15 -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/hellpers/ApiClient.d.ts.map +0 -1
- package/dist/src/core/hellpers/ApiClient.js.map +0 -1
- package/dist/src/core/hellpers/app.d.ts +0 -3
- package/dist/src/core/hellpers/app.d.ts.map +0 -1
- package/dist/src/core/hellpers/app.js.map +0 -1
- package/dist/src/core/hellpers/utils.d.ts.map +0 -1
- package/dist/src/core/hellpers/utils.js.map +0 -1
- 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
- /package/dist/src/core/{hellpers → helpers}/ApiClient.d.ts +0 -0
|
@@ -1,45 +1,80 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ViewInterface, ViewRenderFactory } from "./ViewInterface";
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import type { SaoObjectType } from "../types/utils.js";
|
|
2
|
+
import type { ViewInterface, ViewRenderFactory } from "./ViewInterface.js";
|
|
3
|
+
import type { ViewUserConfig } from "../view/View.js";
|
|
4
|
+
import type { ViewStateInterface } from "./ViewStateInterface.js";
|
|
5
|
+
import type {
|
|
6
|
+
HtmlInterface, FragmentInterface, SaoElementEventHandler, SaoElementChildren,
|
|
7
|
+
SaoChildrenFactory, SaoChildrenFactoryOutput, SaoChildrenSlotContent, WrapperInterface,
|
|
8
|
+
EventModifier
|
|
9
|
+
} from "./ElementInterface.js";
|
|
10
|
+
import type { ReactiveInterface } from "./ReactiveInterface.js";
|
|
11
|
+
import type { BlockInterface } from "./BlockInterface.js";
|
|
12
|
+
import type { LoopContextInterface } from "./LoopContextInterface.js";
|
|
13
|
+
import { SectionInterface } from "../contracts/SectionInterface.js";
|
|
14
|
+
import type { ForeachSlotCache } from "../elements/ForeachSlotCache.js";
|
|
15
|
+
import type { InitMode } from "./common.js";
|
|
16
|
+
import type { ResourceScope } from '../view/ResourceScope.js';
|
|
9
17
|
|
|
10
18
|
// ─── ViewController Interface ────────────────────────────────────
|
|
11
19
|
|
|
12
20
|
export type ViewType = 'view' | 'layout' | 'component' | 'template';
|
|
13
21
|
|
|
14
22
|
export interface ViewControllerInterface {
|
|
15
|
-
|
|
23
|
+
saoType: SaoObjectType;
|
|
16
24
|
view: ViewInterface;
|
|
17
25
|
viewId: string;
|
|
18
26
|
path: string;
|
|
19
27
|
viewType: ViewType;
|
|
20
28
|
states: ViewStateInterface;
|
|
29
|
+
readonly scope: ResourceScope;
|
|
30
|
+
afterDom(callback: () => void): () => void;
|
|
21
31
|
loopContext: LoopContextInterface | null;
|
|
22
32
|
/** Raw input data reference */
|
|
23
33
|
data: Record<string, any>;
|
|
24
34
|
/** Whether this view defines a super view (layout) */
|
|
25
35
|
hasSuperView: boolean;
|
|
36
|
+
|
|
37
|
+
/** Exact DOM listener references, used for element-level cleanup before destroy. */
|
|
38
|
+
elementEventHandlers: Map<HTMLElement, Map<string, EventListener[]>>;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Active ForeachSlotCache — set bởi Reactive.renderForeach() trước khi gọi factory.
|
|
42
|
+
* __foreach() dùng để quyết định reuse hay create elements.
|
|
43
|
+
* null = không có cache active (render bình thường).
|
|
44
|
+
*/
|
|
45
|
+
_currentForeachCache: ForeachSlotCache | null;
|
|
46
|
+
/** Element gọi trong destroy() để tự gỡ khỏi registry (no-op nếu key đã trỏ bản mới) */
|
|
47
|
+
releaseElement(el: object): void;
|
|
48
|
+
/** Compiler helper for raw interpolation inside HTML RCDATA. */
|
|
49
|
+
decodeTextContent(value: string): string;
|
|
26
50
|
/** Path to super view (layout) */
|
|
27
51
|
superViewPath: string | null;
|
|
28
52
|
|
|
29
53
|
/** Main element (Wrapper) for this view */
|
|
30
|
-
mainElement:
|
|
54
|
+
mainElement: WrapperInterface | null;
|
|
55
|
+
preloadElement: WrapperInterface | null;
|
|
31
56
|
|
|
32
57
|
sections: Map<string, SectionInterface>;
|
|
33
58
|
blocks: Map<string, BlockInterface>;
|
|
34
59
|
urlPath: string | null;
|
|
60
|
+
isActive: boolean;
|
|
61
|
+
childrenFactory: SaoChildrenFactory | null;
|
|
35
62
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
wrapper: (factory: OneChildrenFactory) => WrapperInterface;
|
|
63
|
+
wrapper: (factory: SaoChildrenFactory) => WrapperInterface;
|
|
39
64
|
|
|
40
|
-
|
|
65
|
+
removeEventListener(element: HTMLElement, event: string): void;
|
|
66
|
+
addEventListener(element: HTMLElement, event: string, handlers: SaoElementEventHandler, modifiers?: EventModifier[]): void;
|
|
41
67
|
/** Called by reactive system to schedule an update */
|
|
42
68
|
scheduleUpdate(reactive: ReactiveInterface): void;
|
|
69
|
+
/** Còn vùng reactive chờ re-render trong frame này không? */
|
|
70
|
+
hasPendingReactiveUpdate(): boolean;
|
|
71
|
+
/** Flush đồng bộ các reactive update đang chờ (sau mount/hydrate). */
|
|
72
|
+
flushReactiveUpdatesNow(): void;
|
|
73
|
+
/**
|
|
74
|
+
* Chế độ khởi tạo của view: 'create' (CSR) hoặc 'hydrate' (SSR).
|
|
75
|
+
* Truyền xuống mọi element con để chúng tạo mới hay claim DOM server.
|
|
76
|
+
*/
|
|
77
|
+
initMode: InitMode;
|
|
43
78
|
/** Lifecycle */
|
|
44
79
|
setup(config: Record<string, any>): void;
|
|
45
80
|
/** Commit initial data — set initial state values after render */
|
|
@@ -48,20 +83,36 @@ export interface ViewControllerInterface {
|
|
|
48
83
|
updateData(data: Record<string, any>): void;
|
|
49
84
|
/** Update single data item */
|
|
50
85
|
updateDataItem(key: string, value: any): void;
|
|
86
|
+
/** Mount — gắn instance vào real DOM (root!=null) + fire mounting/mounted + acquire asset */
|
|
87
|
+
mount(root?: HtmlInterface | null): void;
|
|
88
|
+
/** Unmount — gỡ instance khỏi real DOM + fire unmounting/unmounted + release asset */
|
|
89
|
+
unmount(): void;
|
|
51
90
|
/** Start reactive subscriptions */
|
|
52
91
|
start(): void;
|
|
53
92
|
/** Stop reactive subscriptions (for caching) */
|
|
54
93
|
stop(): void;
|
|
94
|
+
/** Pause — dirty-mode + buffer async, dùng khi vào PageCache (ROUTE_RENDER_FLOW §7) */
|
|
95
|
+
pause(): void;
|
|
96
|
+
/** Resume — flush dirty keys + apply buffered data, dùng khi restore từ PageCache */
|
|
97
|
+
resume(): void;
|
|
98
|
+
/** State machine: created → active ⇄ paused → destroyed */
|
|
99
|
+
readonly lifecycleState: string;
|
|
100
|
+
active(): void;
|
|
101
|
+
deactive(): void;
|
|
102
|
+
pushBlockAndSections(): void;
|
|
103
|
+
/** Materialize the lazy parent-owned slot only when ChildrenNode is rendered. */
|
|
104
|
+
__children(content: SaoChildrenSlotContent, parentElement: HtmlInterface | null): SaoChildrenFactoryOutput;
|
|
55
105
|
/** Loop directives */
|
|
56
|
-
__foreach<T>(list: T[] | Record<string, T>, callback: (item: T, key: string, index: number, loop: any) => any): any[];
|
|
106
|
+
__foreach<T>(list: T[] | Record<string, T>, callback: (item: T, key: string, index: number, loop: any, identity: number) => any, keyFn?: (item: T, index: number) => any, reconcile?: boolean, scopeId?: string): any[];
|
|
57
107
|
__for(loopType?: string, start?: number, end?: number, execute?: (loop: any) => any): any;
|
|
58
108
|
__while(execute: (loop: any) => any, maxIterations?: number): any;
|
|
59
109
|
/** App reference */
|
|
60
110
|
App: any;
|
|
61
111
|
setApp(app: any): void;
|
|
62
|
-
setUserDefinedConfig(config:
|
|
112
|
+
setUserDefinedConfig<T extends object>(config: ViewUserConfig<T>): void;
|
|
63
113
|
/** Set root element — the container this view renders into */
|
|
64
114
|
setRootElement(rootElement: HtmlInterface): void;
|
|
115
|
+
setParentElement(parentElement: HtmlInterface): void;
|
|
65
116
|
/** Render the view's element tree into rootElement */
|
|
66
117
|
render(): ViewInterface | FragmentInterface | null;
|
|
67
118
|
|
|
@@ -75,6 +126,13 @@ export interface ViewControllerInterface {
|
|
|
75
126
|
setIsSuperView(isSuper: boolean): void;
|
|
76
127
|
/** Set the parent layout's controller */
|
|
77
128
|
setSuperView(superView: ViewControllerInterface): void;
|
|
129
|
+
/** Nested view tree (@include): parent controller */
|
|
130
|
+
parent: ViewControllerInterface | null;
|
|
131
|
+
/** Nested view tree (@include): child controllers */
|
|
132
|
+
children: ViewControllerInterface[];
|
|
133
|
+
setParent(parent: ViewControllerInterface | null): void;
|
|
134
|
+
addChild(child: ViewControllerInterface): void;
|
|
135
|
+
removeChild(child: ViewControllerInterface): void;
|
|
78
136
|
/** Track the original page view's controller for block mounting */
|
|
79
137
|
originView: ViewControllerInterface | null;
|
|
80
138
|
/** Set the origin (page) controller reference */
|
|
@@ -88,6 +146,13 @@ export interface ViewControllerInterface {
|
|
|
88
146
|
/** Get config value with optional default */
|
|
89
147
|
getConfig(key?: string, defaultValue?: any): any;
|
|
90
148
|
getConfig(): ViewControllerConfig;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Đưa lỗi cho error boundary gần nhất (chính controller này hoặc tổ tiên
|
|
152
|
+
* qua `parent`). Trả `{ handled: true, fallback }` nếu có boundary xử lý;
|
|
153
|
+
* `{ handled: false }` → caller giữ nguyên hành vi cũ (bubble lên trên).
|
|
154
|
+
*/
|
|
155
|
+
handleError(err: unknown, info: ErrorInfo): { handled: boolean; fallback?: any };
|
|
91
156
|
}
|
|
92
157
|
|
|
93
158
|
// ─── View Config Types ───────────────────────────────────────────
|
|
@@ -130,6 +195,49 @@ export type ViewRuntimeConfig = {
|
|
|
130
195
|
updateVariableItemData?: (key: string, value: any) => void;
|
|
131
196
|
prerender?: ViewRenderFactory | null;
|
|
132
197
|
render?: ViewRenderFactory | null;
|
|
198
|
+
/**
|
|
199
|
+
* Error boundary. Trả children → dùng làm fallback cho vùng lỗi;
|
|
200
|
+
* trả void → chỉ ghi nhận, lỗi tiếp tục bubble lên boundary cha.
|
|
201
|
+
*/
|
|
202
|
+
onError?: ErrorBoundaryHandler;
|
|
133
203
|
[key: string]: any;
|
|
134
204
|
}
|
|
205
|
+
|
|
206
|
+
/** Giai đoạn phát sinh lỗi — giúp handler phân biệt lỗi render lần đầu với lỗi sau tương tác. */
|
|
207
|
+
export type ErrorPhase = 'render' | 'update' | 'async';
|
|
208
|
+
|
|
209
|
+
export type ErrorInfo = {
|
|
210
|
+
phase: ErrorPhase;
|
|
211
|
+
/** path của view NƠI lỗi xảy ra (có thể là view con, khác với view chứa boundary) */
|
|
212
|
+
path: string;
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
export type ErrorBoundaryHandler = (err: unknown, info: ErrorInfo) => any;
|
|
135
216
|
export type ViewControllerConfig = ViewConfig & ViewRuntimeConfig;
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* `this` bên trong các hàm config do compiler sinh — `commitConstructorData`,
|
|
220
|
+
* `updateVariableData`, `updateVariableItemData`.
|
|
221
|
+
*
|
|
222
|
+
* Chúng được gọi bằng `fn.call(makeConfigThis(), …)`, tức receiver KHÔNG phải
|
|
223
|
+
* object chứa chúng. TypeScript mặc định suy `this` = chính object literal đó,
|
|
224
|
+
* nên `this.config` không tồn tại theo kiểu và `tsc --strict` báo TS2339.
|
|
225
|
+
*
|
|
226
|
+
* Compiler emit `function(this: ViewConfigThis)` cho đầu ra `.ts`; đầu ra `.js`
|
|
227
|
+
* không có tham số này vì tham số `this` là cú pháp chỉ có ở TypeScript và bị
|
|
228
|
+
* xoá khi emit — nó không bao giờ là đối số thật.
|
|
229
|
+
*/
|
|
230
|
+
export interface ViewConfigThis {
|
|
231
|
+
/**
|
|
232
|
+
* Config runtime của chính view — nơi các hàm sinh ra gọi lẫn nhau.
|
|
233
|
+
*
|
|
234
|
+
* KHÔNG nullable, và `ViewController.runtimeConfig` cũng vậy: nó khởi tạo
|
|
235
|
+
* `{}` rồi chỉ bị `setup()` ghi đè bằng config thật. Cái CÓ THỂ vắng là
|
|
236
|
+
* từng hàm trong đó (`commitConstructorData`… đều optional) — mỗi lời gọi
|
|
237
|
+
* đã tự canh bằng `typeof fn === 'function'`.
|
|
238
|
+
*/
|
|
239
|
+
config: ViewRuntimeConfig;
|
|
240
|
+
data: Record<string, any>;
|
|
241
|
+
ctrl: ViewControllerInterface;
|
|
242
|
+
view: ViewInterface;
|
|
243
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { ViewControllerInterface, ViewType } from "./ViewControllerInterface";
|
|
3
|
-
import type { FragmentInterface } from "./ElementInterface";
|
|
1
|
+
import type { SaoObjectType } from "../types/utils.js";
|
|
2
|
+
import type { ViewControllerInterface, ViewType } from "./ViewControllerInterface.js";
|
|
3
|
+
import type { FragmentInterface } from "./ElementInterface.js";
|
|
4
4
|
|
|
5
5
|
// ─── View Interface ──────────────────────────────────────────────
|
|
6
6
|
|
|
7
7
|
export interface ViewInterface {
|
|
8
|
-
|
|
8
|
+
saoType: SaoObjectType;
|
|
9
9
|
__ctrl__: ViewControllerInterface;
|
|
10
10
|
path: string;
|
|
11
11
|
viewType: ViewType;
|
|
@@ -20,12 +20,41 @@ export type ViewRenderFactory = () => FragmentInterface | ViewInterface | null;
|
|
|
20
20
|
/** View class constructor signature */
|
|
21
21
|
export type ViewConstructor = new (path: string, viewType: 'view' | 'layout' | 'component', viewControllerClass?: any) => ViewInterface;
|
|
22
22
|
|
|
23
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* View lifecycle hooks — user có thể cài bất kỳ hook nào (mẫu examples/sao/app.sao).
|
|
25
|
+
* Mỗi transition có cặp before/after:
|
|
26
|
+
* mount → mounting / mounted (gắn vào real DOM)
|
|
27
|
+
* start → starting / started (subscribe reactive + attach events)
|
|
28
|
+
* pause → pausing / paused (vào PageCache — rời real DOM)
|
|
29
|
+
* resume → resuming / resumed (khôi phục từ PageCache)
|
|
30
|
+
* stop → stopping / stopped (deactivate reactive)
|
|
31
|
+
* unmount → unmounting / unmounted (gỡ khỏi real DOM)
|
|
32
|
+
* destroy → destroying / destroyed (cleanup toàn bộ)
|
|
33
|
+
*/
|
|
24
34
|
export interface ViewLifecycleHooks {
|
|
35
|
+
// ─── Cặp before/after (API chính) ───
|
|
36
|
+
mounting?(): void | Promise<void>;
|
|
37
|
+
mounted?(): void | Promise<void>;
|
|
38
|
+
starting?(): void | Promise<void>;
|
|
39
|
+
started?(): void | Promise<void>;
|
|
40
|
+
pausing?(): void | Promise<void>;
|
|
41
|
+
paused?(): void | Promise<void>;
|
|
42
|
+
resuming?(): void | Promise<void>;
|
|
43
|
+
resumed?(): void | Promise<void>;
|
|
44
|
+
stopping?(): void | Promise<void>;
|
|
45
|
+
stopped?(): void | Promise<void>;
|
|
46
|
+
unmounting?(): void | Promise<void>;
|
|
47
|
+
unmounted?(): void | Promise<void>;
|
|
48
|
+
destroying?(): void | Promise<void>;
|
|
49
|
+
destroyed?(): void | Promise<void>;
|
|
50
|
+
|
|
51
|
+
// ─── Legacy alias (giữ tương thích code/test cũ) ───
|
|
25
52
|
onInit?(): void | Promise<void>;
|
|
26
53
|
onMounted?(): void | Promise<void>;
|
|
27
54
|
onUpdated?(): void | Promise<void>;
|
|
28
55
|
onDestroy?(): void | Promise<void>;
|
|
29
56
|
onActivated?(): void | Promise<void>;
|
|
30
57
|
onDeactivated?(): void | Promise<void>;
|
|
58
|
+
onPause?(): void | Promise<void>;
|
|
59
|
+
onResume?(): void | Promise<void>;
|
|
31
60
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ViewInterface } from "./ViewInterface";
|
|
2
|
-
import type { ApplicationInterface } from "./ApplicationInterface";
|
|
3
|
-
import { RouterNavigationType } from "./RouterInterface";
|
|
1
|
+
import type { ViewInterface } from "./ViewInterface.js";
|
|
2
|
+
import type { ApplicationInterface } from "./ApplicationInterface.js";
|
|
3
|
+
import { RouterNavigationType } from "./RouterInterface.js";
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
// ─── ViewManager Interface ───────────────────────────────────────
|
|
@@ -25,13 +25,27 @@ export interface ViewManagerInterface {
|
|
|
25
25
|
/** Register a single view module */
|
|
26
26
|
registerView(name: string, loader: ((...args: any[]) => any) | (() => Promise<any>)): void;
|
|
27
27
|
/** Initialize with optional config */
|
|
28
|
-
init(config?: { container?: HTMLElement; registry?: Record<string, any> }): void;
|
|
28
|
+
init(config?: { container?: HTMLElement | string; registry?: Record<string, any>; systemData?: Record<string, any>; revision?: string; contextViews?: string; dataEndpoint?: string; fetchOptions?: Record<string, any> }): void;
|
|
29
|
+
/** Apply a newer server-authoritative view context. Returns true when changed. */
|
|
30
|
+
applyViewContext?(state: Record<string, any>): boolean;
|
|
31
|
+
/** A changed view namespace needs a full document load before it can be applied safely. */
|
|
32
|
+
requiresReloadForViewContext?(state: Record<string, any>): boolean;
|
|
33
|
+
/** Current server view-context fingerprint. */
|
|
34
|
+
getContextRevision?(): string | null;
|
|
29
35
|
/** Mount a view by name — main entry point */
|
|
30
36
|
mountView(name: string, data?: Record<string, any>, route?: any, navigationType?: RouterNavigationType ): any;
|
|
37
|
+
/**
|
|
38
|
+
* Hydrate a server-side rendered view.
|
|
39
|
+
* data PHẢI có __SSR_VIEW_ID__ — viewId mà Blade dùng để prefix element classes.
|
|
40
|
+
*/
|
|
41
|
+
hydrateView(name: string, data: Record<string, any> & { __SSR_VIEW_ID__: string }, route?: any): any;
|
|
42
|
+
/** Còn SSR boot chưa consume? (route đầu tiên nên hydrate thay vì mount) */
|
|
43
|
+
hasSSRBoot?(): boolean;
|
|
44
|
+
/** Lấy + consume viewId SSR cho view name (chỉ trả 1 lần, cho route đầu) */
|
|
45
|
+
consumeSSRViewId?(viewName: string): string | null;
|
|
31
46
|
/** Unmount all active views */
|
|
32
47
|
unmountAll(): void;
|
|
33
48
|
/** Unmount a specific view by path */
|
|
34
|
-
unmountView(path: string): void;
|
|
35
49
|
/** Get currently active page view */
|
|
36
50
|
getCurrentView(): ViewInterface | null;
|
|
37
51
|
/** Get current layout view */
|
|
@@ -40,6 +54,27 @@ export interface ViewManagerInterface {
|
|
|
40
54
|
getViewStack(): ViewInterface[];
|
|
41
55
|
/** Check if a view is mounted */
|
|
42
56
|
isViewMounted(path: string): boolean;
|
|
57
|
+
/** Invalidate async work of the navigation currently being rendered. */
|
|
58
|
+
cancelNavigation?(): void;
|
|
43
59
|
/** Full destroy */
|
|
44
60
|
destroy(): void;
|
|
61
|
+
/**
|
|
62
|
+
* generateViewId — tạo unique ID cho mỗi view instance.
|
|
63
|
+
* Compiled output gọi: App.View.generateViewId()
|
|
64
|
+
*/
|
|
65
|
+
generateViewId(): string;
|
|
66
|
+
/**
|
|
67
|
+
* exists — kiểm tra view đã đăng ký trong registry chưa.
|
|
68
|
+
* Dùng bởi @includeIf directive.
|
|
69
|
+
*/
|
|
70
|
+
exists(name: string): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* view — lấy view instance từ registry, có thể cache.
|
|
73
|
+
*/
|
|
74
|
+
/** Tạo View instance; hỗ trợ registry lazy (`() => import(...)`) — dùng cho view cấp route. */
|
|
75
|
+
view(name: string, data: Record<string, any>, cache: boolean): Promise<any>;
|
|
76
|
+
/** Bản đồng bộ cho `@include`/`@extends`; view lazy chưa preload → null. */
|
|
77
|
+
resolveViewSync(name: string, data: Record<string, any>, cache: boolean): any;
|
|
78
|
+
/** Nạp trước view lazy để dùng được đồng bộ sau đó. */
|
|
79
|
+
preloadView(name: string): Promise<boolean>;
|
|
45
80
|
}
|
|
@@ -13,16 +13,53 @@ export interface ViewStateInterface {
|
|
|
13
13
|
export interface StateManagerInterface {
|
|
14
14
|
/** Create reactive state — returns [value, setter, key] */
|
|
15
15
|
useState(value: any, key?: string | number): [any, (newValue: any) => void, string | number];
|
|
16
|
+
/**
|
|
17
|
+
* State dẫn xuất có memo hoá — chỉ tính lại khi `deps` đổi, và lazy
|
|
18
|
+
* (đánh dấu bẩn lúc dep đổi, tính lúc đọc). Đọc qua `getStateByKey(key)`
|
|
19
|
+
* hoặc `subscribe([key])` như state thường.
|
|
20
|
+
*/
|
|
21
|
+
computed<T>(key: string, fn: () => T, deps?: string[]): () => T;
|
|
16
22
|
/** Update state by key */
|
|
17
23
|
updateStateByKey(key: string | number, value: any): any;
|
|
18
24
|
/** Get state value by key (supports nested paths: 'user.name') */
|
|
19
25
|
getStateByKey(key: string | number): any;
|
|
26
|
+
getStateVersion(key: string): number;
|
|
20
27
|
/** Subscribe to state changes */
|
|
21
28
|
subscribe(key: string | number | string[] | Record<string, (value: any) => void>, callback?: (value: any) => void): () => void;
|
|
22
29
|
/** Unsubscribe */
|
|
23
30
|
unsubscribe(key: string | number | string[] | Record<string, (value: any) => void>, callback?: (value: any) => void): void;
|
|
24
|
-
/**
|
|
25
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Register shorthand — pre-declare a state slot, returns setter.
|
|
33
|
+
* Value is optional — compiler calls register(key) with 1 arg;
|
|
34
|
+
* initial value is set later via update$xxx() in commitConstructorData.
|
|
35
|
+
*/
|
|
36
|
+
register(key: string | number, value?: any): (newValue: any) => void;
|
|
37
|
+
/**
|
|
38
|
+
* Setter map — exposed for direct access by compiled views.
|
|
39
|
+
* e.g. __STATE__.__.setters.setCount = setCount;
|
|
40
|
+
*/
|
|
41
|
+
setters: Record<string | number, (value: any) => void>;
|
|
42
|
+
/**
|
|
43
|
+
* Flag — true while commitConstructorData is running, false after lockUpdateRealState().
|
|
44
|
+
* Compiler-generated update$xxx() checks this before calling updateStateByKey.
|
|
45
|
+
*/
|
|
46
|
+
readonly canUpdateStateByKey: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Lock — called at end of commitConstructorData() to prevent update$xxx from
|
|
49
|
+
* being accidentally triggered after initialization.
|
|
50
|
+
*/
|
|
51
|
+
lockUpdateRealState(): void;
|
|
52
|
+
/**
|
|
53
|
+
* Unlock — called before updateVariableData() to allow update$xxx again.
|
|
54
|
+
*/
|
|
55
|
+
unlockUpdateRealState(): void;
|
|
56
|
+
/**
|
|
57
|
+
* Flush đồng bộ pending state changes (huỷ RAF đang chờ nếu có).
|
|
58
|
+
* Dùng sau commitData()/mount để DOM phản ánh state ngay trong cùng tick.
|
|
59
|
+
*/
|
|
60
|
+
flushNow(): void;
|
|
61
|
+
/** Opt into expensive mutation diagnostics; disabled by default in browsers. */
|
|
62
|
+
setMutationDiagnostics(enabled: boolean): void;
|
|
26
63
|
/** Destroy — cleanup all listeners and states */
|
|
27
64
|
destroy(): void;
|
|
28
65
|
}
|
|
@@ -4,13 +4,13 @@ export enum InitModes {
|
|
|
4
4
|
HYDRATE = 'hydrate'
|
|
5
5
|
}
|
|
6
6
|
/**
|
|
7
|
-
* Common types and utilities for
|
|
8
|
-
* This file defines shared types and enums used across
|
|
7
|
+
* Common types and utilities for SaoView contracts
|
|
8
|
+
* This file defines shared types and enums used across SaoView's contracts, such as initialization modes and system keys for HTML elements.
|
|
9
9
|
*
|
|
10
10
|
* Key exports:
|
|
11
11
|
*/
|
|
12
12
|
/**
|
|
13
|
-
* System keys for HTML elements used by
|
|
13
|
+
* System keys for HTML elements used by SaoView.
|
|
14
14
|
* These keys are used to store metadata on HTML elements, such as IDs and view information.
|
|
15
15
|
* @name ESK (Element System Keys)
|
|
16
16
|
* @enum {string}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
// ─── Barrel Re-exports ───────────────────────────────────────────
|
|
2
2
|
// All interfaces and related types re-exported for backward compatibility
|
|
3
3
|
|
|
4
|
-
export type { LoopContextInterface } from "./LoopContextInterface";
|
|
5
|
-
export type { ViewStateInterface, StateManagerInterface, StateListener, MultiKeyStateListener, StateItem } from "./ViewStateInterface";
|
|
6
|
-
export type {
|
|
7
|
-
export type { ReactiveInterface, ReactiveRenderFn, ReactiveChildrenFactory, ReactiveConfig } from "./ReactiveInterface";
|
|
8
|
-
export type { BlockInterface, BlockOutletInterface, BlockManagerInterface, BlockRenderFactory } from "./BlockInterface";
|
|
9
|
-
export type { ViewControllerInterface, ViewType, ViewConfig, ViewRuntimeConfig } from "./ViewControllerInterface";
|
|
10
|
-
export type { ViewInterface, ViewRenderFactory, ViewConstructor, ViewLifecycleHooks } from "./ViewInterface";
|
|
11
|
-
export type { ComponentInterface } from "./ComponentInterface";
|
|
12
|
-
export type { ApplicationInterface, AppFactory, ServiceKey, ServiceFactory, ServiceBinding } from "./ApplicationInterface";
|
|
13
|
-
export type { ServiceProviderInterface } from "./ServiceProviderInterface";
|
|
14
|
-
export type { ViewCacheInterface } from "./ViewCacheInterface";
|
|
15
|
-
export type { ViewManagerInterface, ActiveViewInfo } from "./ViewManagerInterface";
|
|
16
|
-
export type { RouterInterface } from "./RouterInterface";
|
|
17
|
-
export type { HelperInterface, CollectionProxyInterface } from "./HelperInterface";
|
|
18
|
-
export type { EventServiceInterface, EventCallback } from "./EventServiceInterface";
|
|
19
|
-
export type { HttpServiceInterface, HttpRequestConfig, HttpResponse, HttpInterceptor } from "./HttpServiceInterface";
|
|
20
|
-
export type { StoreServiceInterface } from "./StoreServiceInterface";
|
|
21
|
-
export type { StorageServiceInterface, StorageEventCallback } from "./StorageServiceInterface";
|
|
22
|
-
export type { LoggerServiceInterface, LoggerConfig, LogEntry, LogLevel } from "./LoggerServiceInterface";
|
|
4
|
+
export type { LoopContextInterface } from "./LoopContextInterface.js";
|
|
5
|
+
export type { ViewStateInterface, StateManagerInterface, StateListener, MultiKeyStateListener, StateItem } from "./ViewStateInterface.js";
|
|
6
|
+
export type { SaoNodeInterface, HtmlInterface, TextInterface, OutputInterface, FragmentInterface, SaoElementConfig, HtmlElementConfig, SaoElementEventHandler, SaoElementChildren, SaoChildrenFactoryOutput, SaoChildrenFactory } from "./ElementInterface.js";
|
|
7
|
+
export type { ReactiveInterface, ReactiveRenderFn, ReactiveChildrenFactory, ReactiveConfig } from "./ReactiveInterface.js";
|
|
8
|
+
export type { BlockInterface, BlockOutletInterface, BlockManagerInterface, BlockRenderFactory } from "./BlockInterface.js";
|
|
9
|
+
export type { ViewControllerInterface, ViewType, ViewConfig, ViewRuntimeConfig } from "./ViewControllerInterface.js";
|
|
10
|
+
export type { ViewInterface, ViewRenderFactory, ViewConstructor, ViewLifecycleHooks } from "./ViewInterface.js";
|
|
11
|
+
export type { ComponentInterface } from "./ComponentInterface.js";
|
|
12
|
+
export type { ApplicationInterface, AppFactory, ServiceKey, ServiceFactory, ServiceBinding } from "./ApplicationInterface.js";
|
|
13
|
+
export type { ServiceProviderInterface } from "./ServiceProviderInterface.js";
|
|
14
|
+
export type { ViewCacheInterface } from "./ViewCacheInterface.js";
|
|
15
|
+
export type { ViewManagerInterface, ActiveViewInfo } from "./ViewManagerInterface.js";
|
|
16
|
+
export type { RouterInterface } from "./RouterInterface.js";
|
|
17
|
+
export type { HelperInterface, CollectionProxyInterface } from "./HelperInterface.js";
|
|
18
|
+
export type { EventServiceInterface, EventCallback } from "./EventServiceInterface.js";
|
|
19
|
+
export type { HttpServiceInterface, HttpRequestConfig, HttpResponse, HttpInterceptor } from "./HttpServiceInterface.js";
|
|
20
|
+
export type { StoreServiceInterface } from "./StoreServiceInterface.js";
|
|
21
|
+
export type { StorageServiceInterface, StorageEventCallback } from "./StorageServiceInterface.js";
|
|
22
|
+
export type { LoggerServiceInterface, LoggerConfig, LogEntry, LogLevel } from "./LoggerServiceInterface.js";
|
|
23
23
|
|
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
import { HtmlInterface,
|
|
2
|
-
import { ViewControllerInterface } from "./utils";
|
|
1
|
+
import { HtmlInterface, SaoElementChildren } from "./ElementInterface.js";
|
|
2
|
+
import { ViewControllerInterface } from "./utils.js";
|
|
3
3
|
|
|
4
|
-
export type SectionItemType = 'static' | 'dynamic' | 'async' | 'reactive';
|
|
5
|
-
export type SectionContentType = 'text' | 'html'
|
|
6
|
-
export type SectionContentRenderer = (parentElement?: HtmlInterface | null | undefined) => string | OneElementChildren;
|
|
7
|
-
export type SectionConstruvtorArgs = {
|
|
8
|
-
ctx?: ViewControllerInterface | null;
|
|
9
|
-
name: string;
|
|
10
|
-
type: SectionItemType;
|
|
11
|
-
contentType?: SectionContentType;
|
|
12
|
-
stateKeys?: string[];
|
|
13
|
-
renderFactory: SectionContentRenderer;
|
|
14
|
-
[key: string]: any;
|
|
15
|
-
}
|
|
16
|
-
export interface SectionInterface {
|
|
17
|
-
ctx? : ViewControllerInterface | null;
|
|
18
|
-
name: string;
|
|
19
|
-
type: SectionItemType;
|
|
20
|
-
contentType?: SectionContentType;
|
|
21
|
-
stateKeys?: string[];
|
|
22
|
-
renderFactory?: SectionContentRenderer;
|
|
23
|
-
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DevTools runtime hook (GAP-05).
|
|
3
|
+
*
|
|
4
|
+
* Nền tảng cho MỌI UI devtools (overlay in-page, browser extension sau này):
|
|
5
|
+
* runtime chỉ phát sự kiện + cho phép đọc snapshot, KHÔNG biết gì về UI.
|
|
6
|
+
*
|
|
7
|
+
* Thiết kế:
|
|
8
|
+
* - **Tắt mặc định, zero-cost.** `emit()` thoát ngay ở dòng đầu khi chưa bật.
|
|
9
|
+
* Không tạo object, không serialize — không được làm chậm production.
|
|
10
|
+
* - Bật bằng `App.devtools.enable()` hoặc đặt sẵn `window.__SAOLA_DEVTOOLS_HOOK__`
|
|
11
|
+
* TRƯỚC khi app boot (cách extension sẽ dùng: content script inject sớm).
|
|
12
|
+
* - Snapshot đọc từ ViewManager/ViewController, không giữ state riêng →
|
|
13
|
+
* không có nguồn sự thật thứ hai để lệch.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export type DevtoolsEventType =
|
|
17
|
+
| 'view:mounted' | 'view:destroyed'
|
|
18
|
+
| 'state:changed'
|
|
19
|
+
| 'error';
|
|
20
|
+
|
|
21
|
+
export interface DevtoolsEvent {
|
|
22
|
+
type: DevtoolsEventType;
|
|
23
|
+
/** ms từ lúc trang load — đủ để xếp thứ tự trên timeline */
|
|
24
|
+
at: number;
|
|
25
|
+
viewId?: string;
|
|
26
|
+
path?: string;
|
|
27
|
+
/** state:changed → key nào đổi; error → phase */
|
|
28
|
+
detail?: any;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface DevtoolsViewNode {
|
|
32
|
+
viewId: string;
|
|
33
|
+
path: string;
|
|
34
|
+
viewType: string;
|
|
35
|
+
lifecycleState: string;
|
|
36
|
+
/** Ảnh chụp state hiện tại (đã lọc giá trị không serialize được) */
|
|
37
|
+
state: Record<string, any>;
|
|
38
|
+
/** Số element đang giữ trong registry — dò rò rỉ */
|
|
39
|
+
elementCount: number;
|
|
40
|
+
children: DevtoolsViewNode[];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
type Listener = (e: DevtoolsEvent) => void;
|
|
44
|
+
|
|
45
|
+
const MAX_LOG = 200;
|
|
46
|
+
|
|
47
|
+
class DevtoolsHook {
|
|
48
|
+
private enabled = false;
|
|
49
|
+
private listeners: Listener[] = [];
|
|
50
|
+
/** Vòng đệm — devtools mở muộn vẫn xem được lịch sử gần đây */
|
|
51
|
+
private log: DevtoolsEvent[] = [];
|
|
52
|
+
/** ViewManager, gán lúc boot; dùng any để tránh vòng import */
|
|
53
|
+
private viewManager: any = null;
|
|
54
|
+
|
|
55
|
+
isEnabled(): boolean { return this.enabled; }
|
|
56
|
+
|
|
57
|
+
enable(): void { this.enabled = true; }
|
|
58
|
+
disable(): void { this.enabled = false; this.log = []; }
|
|
59
|
+
|
|
60
|
+
/** ViewManager tự đăng ký lúc init — hook không đi tìm global. */
|
|
61
|
+
attach(viewManager: any): void { this.viewManager = viewManager; }
|
|
62
|
+
|
|
63
|
+
subscribe(fn: Listener): () => void {
|
|
64
|
+
this.listeners.push(fn);
|
|
65
|
+
return () => { this.listeners = this.listeners.filter(l => l !== fn); };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Hot path — phải rẻ khi tắt. */
|
|
69
|
+
emit(type: DevtoolsEventType, data?: Omit<DevtoolsEvent, 'type' | 'at'>): void {
|
|
70
|
+
if (!this.enabled) return;
|
|
71
|
+
const event: DevtoolsEvent = { type, at: Math.round(performance.now()), ...data };
|
|
72
|
+
this.log.push(event);
|
|
73
|
+
if (this.log.length > MAX_LOG) this.log.shift();
|
|
74
|
+
for (const fn of this.listeners) {
|
|
75
|
+
try { fn(event); } catch (e) { console.error('[Devtools] listener error:', e); }
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
getLog(): DevtoolsEvent[] { return [...this.log]; }
|
|
80
|
+
clearLog(): void { this.log = []; }
|
|
81
|
+
|
|
82
|
+
/** Cây view đang mount: layout chain (ngoài → trong) rồi tới page. */
|
|
83
|
+
getViewTree(): DevtoolsViewNode[] {
|
|
84
|
+
const vm = this.viewManager;
|
|
85
|
+
if (!vm) return [];
|
|
86
|
+
const roots: any[] = [...(vm.getLayoutChain?.() ?? []), vm.getCurrentView?.()].filter(Boolean);
|
|
87
|
+
// Layout chain và page nối nhau theo thứ tự mount, không phải quan hệ
|
|
88
|
+
// parent/children (quan hệ đó chỉ dùng cho @include) → dựng phẳng ở
|
|
89
|
+
// gốc, rồi mỗi node mở rộng theo ctrl.children thật.
|
|
90
|
+
return roots.map(v => this.toNode(v.__ctrl__));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
private toNode(ctrl: any): DevtoolsViewNode {
|
|
94
|
+
return {
|
|
95
|
+
viewId: ctrl.viewId,
|
|
96
|
+
path: ctrl.path,
|
|
97
|
+
viewType: ctrl.viewType,
|
|
98
|
+
lifecycleState: ctrl.lifecycleState,
|
|
99
|
+
state: this.snapshotState(ctrl),
|
|
100
|
+
elementCount: ctrl.elements?.size ?? 0,
|
|
101
|
+
children: (ctrl.children ?? []).map((c: any) => this.toNode(c)),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Ảnh chụp state — mọi giá trị đi qua JSON round-trip để cắt tham chiếu
|
|
107
|
+
* DOM/hàm/vòng lặp: devtools không được giữ sống object của app, và
|
|
108
|
+
* không được nổ khi state chứa cấu trúc vòng.
|
|
109
|
+
*/
|
|
110
|
+
private snapshotState(ctrl: any): Record<string, any> {
|
|
111
|
+
const out: Record<string, any> = {};
|
|
112
|
+
const states = ctrl.states?.__?.states ?? {};
|
|
113
|
+
for (const key of Object.keys(states)) {
|
|
114
|
+
try {
|
|
115
|
+
const value = states[key]?.value; // computed: getter → tính lại ở đây
|
|
116
|
+
out[key] = value === undefined ? undefined : JSON.parse(JSON.stringify(value));
|
|
117
|
+
} catch {
|
|
118
|
+
out[key] = '[không serialize được]';
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return out;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export const devtools = new DevtoolsHook();
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Nếu môi trường đã cắm sẵn `window.__SAOLA_DEVTOOLS_HOOK__` trước khi app boot
|
|
129
|
+
* (browser extension làm vậy), tự bật và nối sự kiện sang đó.
|
|
130
|
+
*/
|
|
131
|
+
if (typeof window !== 'undefined') {
|
|
132
|
+
const external = (window as any).__SAOLA_DEVTOOLS_HOOK__;
|
|
133
|
+
if (external) {
|
|
134
|
+
devtools.enable();
|
|
135
|
+
devtools.subscribe((e) => { try { external.onEvent?.(e); } catch { /* của bên thứ 3 */ } });
|
|
136
|
+
external.getViewTree = () => devtools.getViewTree();
|
|
137
|
+
external.getLog = () => devtools.getLog();
|
|
138
|
+
}
|
|
139
|
+
(window as any).__SAOLA_DEVTOOLS__ = devtools;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export default devtools;
|