On this page
Where the editor's front end comes from: its own embedded shell, module and stylesheet, plus a tinymoon asset tree the caller names rather than discovers.
#internal/blog/editor/assets
#internal/blog/editor/assets
Package assets decides where the editor's front-end comes from, declared rather than discovered.
Two asset trees are served: tinymoon's (the framework chrome plus the editor tier the authoring surface is built on) and the editor's own (the shell page, its module, its stylesheet). Both ship inside this package -- the editor's as its own files, tinymoon's through the framework module this build compiles in.
The caller still states which tinymoon it wants, because a checkout is routinely ahead of the released framework. There are two answers and the caller picks one before anything binds a port:
- a path, from --tinymoon-assets -- a checkout's assets directory; - nothing, meaning the framework tree this build embeds.
Neither is a fallback for the other. Either way the resolved tree is checked for every file the shell loads, including the editor tier, and a tree missing any of them is refused with all the missing names. That refusal exists because the alternative is a shell that loads, renders its chrome, and never mounts an editor -- a failure that looks like a bug in the app rather than a missing dependency.
#TinymoonEditorTier
var TinymoonEditorTier = []string{TinymoonEditorTier is the three files that make up tinymoon's editor tier. They were newer than any released tinymoon when the authoring app was written, which is why the --tinymoon-assets path exists.
#TinymoonRequired
var TinymoonRequired = []string{TinymoonRequired is every tinymoon file the editor shell names DIRECTLY -- the stylesheets its page links, in the framework's own load order, and the modules its app imports by name.
Not the transitive module graph: those imports resolve inside the served tree at load time, and enumerating them here would be a copy of tinymoon's internals that goes stale on its next refactor. The editor tier is the one exception: js/completion.js is reached only through js/editor.js, and it is named anyway because the tier's presence is the thing being checked. A test keeps this list and the shell's own references in step in both directions.
#Error
type Error structError reports that the front-end assets cannot be served, and the message says why.
It is the Go counterpart of the Python surface's AssetsError, and the one error type a caller needs to recognize with errors.As to render an assets refusal as one line instead of an unexpected internal failure.
#Tinymoon
type Tinymoon structTinymoon is a resolved tinymoon asset tree, ready to be served.
#UI
func UI() fs.FSUI returns the editor's own front-end: the shell page, its module and its stylesheet, addressed as "index.html", "app.js" and "app.css".
#ResolveTinymoon
func ResolveTinymoon(explicit string) (Tinymoon, error)ResolveTinymoon resolves tinymoon's asset tree, or refuses.
An explicit path names a tinymoon checkout's assets directory; empty means the framework tree this build embeds. The resolved tree is then checked for every file in [TinymoonRequired], and a tree missing any of them is refused naming all of them.
#Error.Error
func (e *Error) Error() string { return e.Message }Error returns the diagnostic.