Documentation ¶
Index ¶
- Constants
- func CreateComponentTree(path string) (*componentTree, error)
- type BrowserBuilder
- type Cache
- type CompiledResult
- type Component
- type ComponentTree
- type Layout
- type SSRBuilder
- type StaticAsset
- type SvelteBuildOutput
- type SvelteCompilerFunc
- type View
- type ViewManager
- func (v *ViewManager) AllViews() []*View
- func (v *ViewManager) Build() error
- func (v *ViewManager) GetStaticAsset(name string) (StaticAsset, bool)
- func (v *ViewManager) Render(_ context.Context, viewPath string, props interface{}) (string, error)
- func (v *ViewManager) StartWatch() error
- func (v *ViewManager) ViewByRelPath(path string) *View
Constants ¶
const ( CacheTypeSSR = iota CacheTypeBrowser )
Variables ¶
This section is empty.
Functions ¶
func CreateComponentTree ¶
CreateComponentTree creates a componentTree based on the absolute Path it performs a depth-first search through all subdirectories under the specified Path
Types ¶
type BrowserBuilder ¶
type BrowserBuilder struct {
// contains filtered or unexported fields
}
func NewBrowserBuilder ¶
func (*BrowserBuilder) BuildDev ¶
func (b *BrowserBuilder) BuildDev(allViews []*View) (map[string]StaticAsset, error)
BuildDev creates assets for embedding into the rendered view references to those assets are added to the View object for the entrypoint svelte file
type CompiledResult ¶
type Component ¶
type Component struct { Name string //Path is absolute Path string Layout *Layout // ParentTree represents the directory this component belongs in ParentTree *componentTree // contains filtered or unexported fields }
func (*Component) ApplicableLayouts ¶
ApplicableLayouts returns a flattened layout hierarchy of layouts applicable to this component. Layout index determines its proximity to the component in the hierarchy
func (*Component) RelativePath ¶
RelativePath returns the relative Path of the component to the views directory
type ComponentTree ¶
type Layout ¶
type Layout struct { Name string //Path is absolute Path string // nil if no parent layout exists ParentLayout *Layout // ParentTree represents the directory this layout belongs in ParentTree *componentTree // contains filtered or unexported fields }
func (*Layout) ApplicableLayouts ¶
func (*Layout) RelativePath ¶
RelativePath returns the relative Path of the layout to the views directory
type SSRBuilder ¶
type SSRBuilder struct {
// contains filtered or unexported fields
}
func NewSSRBuilder ¶
func (*SSRBuilder) DevBuild ¶
func (s *SSRBuilder) DevBuild(allViews []*View) (*CompiledResult, error)
type StaticAsset ¶
type SvelteBuildOutput ¶
type SvelteCompilerFunc ¶
type SvelteCompilerFunc func(string, []byte) (*SvelteBuildOutput, error)
type View ¶
type View struct { ComponentName string //UniqueName is the PascalCase of the Path relative to views directory UniqueName string //WrappedUniqueName prefixes the unique name with "__AviatorWrapped_" //i.e __AviatorWrapped{UniqueName} //This is used to disambiguate the layout wrapped component from the component itself WrappedUniqueName string Path string //RelPath is the relative Path from the project's views directory RelPath string //A view can represent either a Component or a Layout Component *Component Layout *Layout IsLayout bool //If the view is a svelte Component and starts with a capital letter, it will be //treated as an entrypoint for both SSR and Browser JS IsEntrypoint bool //ApplicableLayouts is a slice of Views that represent layouts that apply to this //view. Lower index means the layout is closer to this view in the ancestral hierarchy ApplicableLayoutViews []*View //the imports are generated during the browser build step and are injected into // the HTML at render time JSImports []string CSSImports []string // contains filtered or unexported fields }
View objects are passed to the go-template file responsible for creating the virtual __aviator_ssr.js file in the SSR Plugin A View object can represent both a Component or a Layout
type ViewManager ¶
func NewViewManager ¶
func (*ViewManager) Build ¶
func (v *ViewManager) Build() error
func (*ViewManager) GetStaticAsset ¶
func (v *ViewManager) GetStaticAsset(name string) (StaticAsset, bool)
func (*ViewManager) StartWatch ¶
func (v *ViewManager) StartWatch() error
StartWatch starts watching views directory for changes
func (*ViewManager) ViewByRelPath ¶
func (v *ViewManager) ViewByRelPath(path string) *View
ViewByRelPath returns a view by the relative Path