Documentation
¶
Overview ¶
Package bundle builds a Morpheus bundle of chosen components. It holds the component graph, the source tree preparation and the build, which the morpheus command, internal/cmd/gen and the bundle builder page share.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var TreePaths = []string{
"web/lib", "web/package.json", "min/bundle.js", "min/theme-*.css",
"internal/site/static/morpheus.css",
}
TreePaths are the parts of a source tree a Version is prepared from, as git pathspecs.
Functions ¶
Types ¶
type Entry ¶
type Entry struct {
ID string `json:"id"`
Name string `json:"name"`
Bound bool `json:"bound"`
// JS is the module's file name in bundle-src/, or "" for none.
JS string `json:"js"`
// Owners, for a bound node, are the ids whose selection ships it.
Owners []string `json:"owners,omitempty"`
}
Entry is a graph node in a Manifest.
type Manifest ¶
type Manifest struct {
Banner string `json:"banner"`
Esbuild string `json:"esbuild"`
CSS []Sheet `json:"css"`
Entries []Entry `json:"entries"`
// Themes are the file names in bundle-themes/, such as theme-default.css.
Themes []string `json:"themes"`
}
Manifest is a version's bundle-manifest.json. CSS is in morpheus.css import order.
type Node ¶
type Node struct {
// ID is the manifest entry id and the landing graph's element id,
// such as graph-neo-select.
ID string
Name string
// DependsOn are the ids of the direct dependencies.
DependsOn []string
Disabled bool
Bound bool
// Requires are the selectable transitive dependencies, which selecting
// the node adds.
Requires []string
// RequiredBy are the selectable transitive dependents.
// They lock the node's toggle, or own a bound node.
RequiredBy []string
}
Node is one component of the graph.
func (Node) Selectable ¶
Selectable reports whether a selection can name nd.
type Selection ¶
type Selection struct {
// IDs are the named components and their requirements, in [Nodes] order.
// [Build] takes them.
IDs []string
// Named are the ids of the named components, in [Nodes] order.
Named []string
// Unknown are the names that match no selectable component.
Unknown []string
// Missing are the short names of the named components a version lacks.
Missing []string
}
Selection is what a list of component names selects.
type Sheet ¶
type Sheet struct {
// File is the name in bundle-css/.
File string `json:"file"`
// Nodes are the ids that need the sheet; empty for a base sheet,
// which always ships.
Nodes []string `json:"nodes,omitempty"`
// contains filtered or unexported fields
}
Sheet is one stylesheet morpheus.css imports.
type Version ¶
type Version struct {
Manifest Manifest
// Absent are the selectable ids the tree lacks.
Absent []string
// Files are bundle-src/, bundle-css/ and bundle-themes/
// by slash-separated path.
Files map[string][]byte
}
Version is a source tree prepared for building with the current graph (Nodes). internal/cmd/gen writes it to static/bundle/<version>/, which the bundle builder page builds from:
- bundle-src/: the kit's TypeScript, flattened ([flatten]), with the stylesheets it imports as text and index.ts.
- bundle-css/: the stylesheets morpheus.css imports.
- bundle-themes/: the min/theme-*.css files that load no other file.
- bundle-manifest.json: the Manifest.