@dooboostore/simple-boot-frontis the browser-side runtime for DoobooStore applications.
It combines:
@dooboostore/simple-bootfor DI, routing, modules, and lifecycle@dooboostore/dom-renderfor component rendering and template bindings@dooboostore/core-webrouters for path/hash navigationroutingStartObservable,routingEndObservable) for integration points.SimFrontOption.npm init @dooboostore/simple-boot-front my-appcdmy-app
npm install
npm run devpnpm add @dooboostore/simple-boot-front reflect-metadataRoot import (recommended for normal library usage):
import{SimpleBootFront,SimFrontOption,UrlType,Component,Script,ComponentBase}from'@dooboostore/simple-boot-front';Bundle entry import (explicit bundle-style contract):
import*asSimpleBootFrontBundlefrom'@dooboostore/simple-boot-front/bundle-entry';constapp =newSimpleBootFrontBundle.SimpleBootFront(newSimpleBootFrontBundle.SimFrontOption(
{window,selector:'#app',urlType:SimpleBootFrontBundle.UrlType.path},
{rootRouter:IndexRouterComponent}
)
);import'reflect-metadata';import{Sim,Router}from'@dooboostore/simple-boot';import{Component,ComponentBase,ComponentRouterBase,SimpleBootFront,SimFrontOption,UrlType}from'@dooboostore/simple-boot-front';@Sim@Component({template:'<h1>Hello SimpleBootFront</h1>'})classHomePageextendsComponentBase{}@Sim@Router({path:'',route: {'/':HomePage} })@Component({template:'<main><dr-this value="${@this@.child}$"></dr-this></main>'})classIndexRouterComponentextendsComponentRouterBase{}constapp =newSimpleBootFront(newSimFrontOption(
{window,selector:'#app',urlType:UrlType.path},
{rootRouter:IndexRouterComponent}// 2nd arg: simple-boot InitOptionType)
);
app.run();SimpleBootFrontSimpleApplicationfrom@dooboostore/simple-boot).run(otherInstanceSim?, url?)bootstraps the app;goRouting(url)/routingRouterModule(url)navigate programmatically.routingObservable/routingStartObservable/routingEndObservable— observe routing transitions ({ triggerPoint, domRenderRouter, routerModule }).getSimstanceManager()exposes the underlying DI container.@dooboostore/simple-boot-http-server-ssr:saveDataHydration(key, data),getDataHydration(key),cutDataHydration(key)(read-and-remove),deleteDataHydration(key),clearDataHydration(),writeDataHydration()(serializes pending hydration data into a<script>tag).SimFrontOption/UrlTypenew SimFrontOption(config, initSimOption?):configsetswindow, rootselector(default#app), route strategy (urlType: UrlType.path | UrlType.hash, defaultpath), andusing;initSimOptionis simple-boot'sInitOptionType(rootRouter,advice,cache, ...).rootRouteris the top-level@Routercomponent.@Component(config)(alias:@component)selector(defaults to the lowercased class name),template,styles,using,proxy, andnoStrip(keep the host element instead of stripping it).@Componentwith no config).@Script(config?)(alias:@script)ScriptRunnable(implementsrun(...args)) under a name (defaults to the class name) so templates/other components can invoke it as a script function.ComponentBaseComponentBaseand implementsRouterAction.OnRoutingwith a default no-oponRouting.ComponentRouterBaseComponentRouterBase). ImplementscanActivate/onRoutingto swap in the routed child component, and exposesgetPathData<T>()for the current route's path data.ComponentSet@Componenttemplate/styles (extends dom-render'sComponentSet) — used internally when swapping routed components.OnInitedChild(onInitedChild(): void),OnFinish(onFinish(): void),onChangedRender(onChangedRender(): void) — implement on a component to hook into these lifecycle points.Core,CoreWeb,DomRender,SimpleBoot(namespaced re-exports of@dooboostore/core,@dooboostore/core-web,@dooboostore/dom-render,@dooboostore/simple-boot), so you don't need to add those as separate dependencies just to reach a type or utility.SimpleBootFrontextendsSimpleApplicationfrom@dooboostore/simple-boot.DomRenderinstance is created and stored in simstance storage.DomRenderRootObject.reflect-metadatamust be loaded before decorators are evaluated.import 'reflect-metadata'to your entry when importing from subpaths.SimFrontOption.selectordefaults to#app.urlType: UrlType.hash.The detailed API documentation, including all decorators and usage examples, is available on the documentation website.
This package is licensed under theMIT License.