pwbrowser

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package pwbrowser is the browser runtime this framework ships, and where a document finds it.

It is a leaf because both transports serve the same bytes under the same URL, and they have to: a document naming the runtime is rendered by whichever half is running, and an application's own template names that URL once. Two runtimes each embedding their own copy would be two revisions of one asset, and a page rendered by one build would load a script the other does not serve.

What is not here is the serving. Reading a path and writing a response is a transport's work, so each supplies that over Lookup.

Index

Constants

View Source
const CacheControl = "public, max-age=31536000, immutable"

CacheControl is what an asset under a revision segment carries. The segment never serves different bytes, so this is genuinely immutable rather than merely long-lived.

View Source
const Prefix = "/_pw/"

Prefix is reserved for framework-owned browser assets. It is a fixed absolute path rather than a subtree of the configurable public mount, because these belong to the framework rather than to the application, and because the document shell has to be able to name one without reading configuration.

View Source
const RuntimeName = "popcornweb-runtime.js"

RuntimeName is the module a document loads.

Variables

This section is empty.

Functions

func Claims

func Claims(path string) bool

Claims reports whether path is inside the reserved namespace at all, which is what a transport uses to close it.

func ContentType

func ContentType(name string) string

ContentType picks a type from the name a module was registered under.

The set held nothing but JavaScript until the development launcher brought its mark along, and the name is the only thing to read it from: the bytes are held as strings, and sniffing them would be guessing at what the file name already states. The set is closed and this build wrote every name in it, so an unrecognised one is a module rather than something to refuse.

func Lookup

func Lookup(path string) (source, contentType string, ok bool)

Lookup answers what a request for path should be served, and whether this build claims it at all.

Only the modules of the current set are claimed. The prefix holds more than the script assets — a package asset lives here too — so claiming the whole namespace here would swallow every route that arrived after this one. A transport closes the namespace below all of them.

A stale revision is therefore not found rather than served from the current set, which is what makes the immutable caching sound.

func Publish

func Publish(extra map[string]string, extraImport string)

Publish adds the modules a build serves beyond the core, and the import line the core carries to reach them.

It exists for the development build mode, which adds a module and an import and must therefore land on a different revision — with no constant for anybody to bump, and no chance of a browser holding the release URL immutably and receiving development bytes under it.

A build that adds nothing calls nothing, which is every deployed build.

func Revision

func Revision() string

Revision digests the script set so a changed dependency changes every URL.

Deriving it from the bytes rather than from a release constant means an upgrade that changes the runtime cannot ship under a URL a browser already cached forever.

func RuntimeScriptURL

func RuntimeScriptURL() string

RuntimeScriptURL is the absolute path of the boundary runtime module. A document template names it through a declared external function rather than as a literal, so the template text survives an upgrade that moves the URL.

func RuntimeSource

func RuntimeSource() string

RuntimeSource is the core module's bytes, before whatever a build mode appends. It is exported for a test that reads what shipped rather than what a set was assembled into.

func ScriptURL

func ScriptURL(name string) string

ScriptURL is the absolute path of one module in the set. Modules share one revision segment so that imports between them stay ordinary relative specifiers and nothing has to rewrite them.

func Scripts

func Scripts() map[string]string

Scripts returns the module set this build serves, by file name.

It is a set rather than one file because the core loads its capabilities by dynamic import. Everything here is framework source: nothing is derived from application code, and nothing is written into the project.

Types

This section is empty.

Jump to

Keyboard shortcuts

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