bundle

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 12 Imported by: 0

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

View Source
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

func Build

func Build(v Version, selected []string, minify bool) (js, css []byte, err error)

Build returns the JS and CSS bundles of the selected ids. web/site/bundle-size.ts builds the same bytes in the browser with the same esbuild version.

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 Nodes

func Nodes() []Node

Nodes returns every component sorted by name.

func (Node) Selectable

func (nd Node) Selectable() bool

Selectable reports whether a selection can name nd.

func (Node) ShortName

func (nd Node) ShortName() string

ShortName is the name without "neo-". The bundle builder page shows it, and ?components= and -components take it.

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.

func Select

func Select(values, absent []string) Selection

Select reads component names as the bundle builder page reads ?components=. A value holds comma-separated short names in any case, with or without "neo-". absent are the ids the version lacks.

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.

func Prepare

func Prepare(fsys fs.FS) (Version, error)

Prepare prepares the tree in fsys, which holds TreePaths.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL