Documentation ¶
Index ¶
- Variables
- type Bundle
- func (b *Bundle) All() []*Source
- func (b *Bundle) ByExt(ext string) []*Source
- func (b *Bundle) Load(path string) (*Source, error)
- func (b *Bundle) MergedByExt(ext string) []byte
- func (b *Bundle) Reload() ([]*Change, error)
- func (b *Bundle) ReloadSource(prev *Source) (changed bool, next *Source, err error)
- func (b *Bundle) ServeFile(w http.ResponseWriter, r *http.Request)
- type Change
- type Errors
- type Server
- type Source
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrUnknownImport = errors.New("unknown import format")
Functions ¶
This section is empty.
Types ¶
type Bundle ¶
type Bundle struct { // Root is the filesystem used to load/reload sources Root http.FileSystem // Main is the root files that are used to find rest of the files Main []string // contains filtered or unexported fields }
Bundle is a collection of source files that can be bundled and/or reloaded
func NewBundle ¶
func NewBundle(root http.FileSystem, main ...string) *Bundle
NewBundle returns a empty bundle
func (*Bundle) MergedByExt ¶
MergedByExt bundles files together into bytes by ext
func (*Bundle) Reload ¶
Reload reloads the content from Root and returns the list of changes and all errors that occurred
func (*Bundle) ReloadSource ¶
ReloadSource reloads the base file and returns a new Source file in next. If file doesn't exist any more it will return nil as next
type Change ¶
type Change struct { Prev *Source `json:"prev"` // Prev is nil if file was added Next *Source `json:"next"` // Next is nil if file was deleted Deps bool `json:"deps"` // Deps is true if dependencies changed }
Change shows info about a source file change
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server implements a live reloading server for JS
type Source ¶
type Source struct { Path string `json:"path"` // absolute path for file Deps []string `json:"deps"` // list of absolute paths Ext string `json:"ext"` // file extension ModTime time.Time `json:"modified"` // last modified time ContentType string `json:"contentType"` // file content-type Content []byte `json:"-"` // original content on disk Processed []byte `json:"-"` // pre-processed content in some cases }
Source represents a single source file
func SortSources ¶
SortSources optimistically sorts items by dependencies in case of cycles those items will be unordered
Source Files ¶
Click to show internal directories.
Click to hide internal directories.