corewasm

package
v1.6.0-beta.11 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package corewasm owns the Gothic Framework STATIC CORE artifact: the prebuilt, type-agnostic RPC/registration hub compiled with the framework's pinned TinyGo fork. See wasm/core-runtime for the core's source and the rationale for a single static hub shared by every component on the page.

This package is the emission + versioning seam, mirroring gothiccore (which owns gothic-core.js). It embeds two artifacts and emits them to the project's public/ directory:

gothic-core.wasm       the prebuilt core module (from core.wasm, committed)
gothic-core-boot.js    a tiny loader that instantiates + runs the core once
                       per page, generated here so its content-hash tracks
                       the core wasm and the shared exec shim

The exec shim is NOT duplicated here — it is served from wasmexec (the same wasm_exec.js per-instance components use), avoiding the earlier 17,732 B duplicate download.

It is a leaf package (no internal deps) so BOTH the routes bootstrap layer and the wasm build layer can import it without a dependency cycle — same shape as gothiccore.

Regenerating the core artifacts (maintainers only)

The committed core.wasm is rebuilt ONLY when the core's source (wasm/core-runtime), one of its dependencies, or the pinned TinyGo version changes. Run:

go generate ./corewasm

The build needs the framework's pinned TinyGo fork on PATH as `tinygo`; set GOTHIC_TINYGO to point at a specific binary instead (the CLI caches one under ~/.cache/gothic-cli/tinygo/tinygo-<version>/<platform>/tinygo/bin/tinygo). The pinned version is the one cli/internal/build.tinyGoVersion names — building with a different one produces a different binary and therefore a different cache-buster.

The flags match what the CLI compiles per-instance components with, and they make the output byte-reproducible: two runs of the same source with the same toolchain emit an identical core.wasm. Everything downstream depends on that, because the ?v= cache-buster is a content hash of these bytes.

Commit the regenerated files. End users NEVER rebuild these — the CLI ships them prebuilt and only COPIES them into public/.

Index

Constants

View Source
const (
	WASMFileName = "gothic-core.wasm"
	BootFileName = "gothic-core-boot.js"
)

Emitted public basenames.

Variables

This section is empty.

Functions

func BootAssetPath

func BootAssetPath() string

BootAssetPath is the URL the layout references, including the content-hash cache-buster: /_gothic/gothic-core-boot.js?v=<bootHash>. Served from the framework embed via the /_gothic/ route (no longer copied into public/).

func BootJS

func BootJS() []byte

BootJS returns the generated boot loader bytes (gothic-core-boot.js). Served from /_gothic/.

func CoreHash

func CoreHash() string

CoreHash returns the content hash of the core wasm binary — the ?v= cache-buster the boot loader embeds when fetching it.

func CoreWASM

func CoreWASM() []byte

CoreWASM returns the prebuilt full-Go core module bytes (gothic-core.wasm). Exposed so the runtime-asset registry can serve it from the framework embed (via the /_gothic/ route) instead of copying it into the project's public/.

func Version

func Version() string

Version returns the boot loader's content hash — the ?v= cache-buster the layout <head> references. One hash covers all served artifacts.

func WASMAssetPath

func WASMAssetPath() string

WASMAssetPath is the core module URL, byte-identical to the one the boot loader fetches. The layout preloads it so the download starts while the HTML is still parsing instead of waiting for the boot loader itself to arrive; a preload whose URL diverged from the loader's would download the module twice, so both are built from the same coreHash.

func Write

func Write(publicDir string) error

Write emits the two static-core artifacts into publicDir (creating it if needed). Called at `gothic init` (to seed the files so the layout reference resolves on the first render) and on every build (so existing projects pick up a new core when the CLI is upgraded).

Emission is IDEMPOTENT and mtime-stable: each file is rewritten only when its content changed. The core is NEVER recompiled here — it is copied from the embedded, prebuilt artifact — so it is not part of the GenerateAll per-page rebuild set and a hot-reload cycle leaves both files' mtimes unchanged. The exec shim (wasm_exec.js) is served from the /_gothic/ embed and is no longer emitted here.

Types

This section is empty.

Jump to

Keyboard shortcuts

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