Documentation
¶
Overview ¶
Package corewasm owns the Gothic Framework full-Go STATIC CORE artifact (Phase 16): the prebuilt, type-agnostic RPC/registration hub compiled with the standard Go toolchain (GOOS=js GOARCH=wasm) so it has the full standard library TinyGo lacks. See pkg/wasm/core-runtime for the core's source and the rationale for full-Go + static.
This package is the emission + versioning seam, mirroring pkg/helpers/gothiccore (which owns gothic-core.js). It embeds three artifacts and emits them to the project's public/ directory:
gothic-core.wasm the prebuilt core module (from core.wasm, committed)
gothic-core-exec.js the standard-Go wasm_exec shim, VERSION-MATCHED to the
Go toolchain that built 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 and exec hashes
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 + gothic-core-exec.js are rebuilt ONLY when the core's source (wasm/core-runtime) or the pinned Go toolchain changes. Run:
go generate ./corewasm
which runs the two directives below (build the wasm, copy the matching wasm_exec.js). Commit the regenerated files. End users NEVER rebuild these — the CLI ships them prebuilt and only COPIES them into public/.
Index ¶
Constants ¶
const ( WASMFileName = "gothic-core.wasm" ExecFileName = "gothic-core-exec.js" 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 / ExecHash return the content hashes of the two binary artifacts — the ?v= cache-busters the boot loader embeds when fetching them.
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 ExecJS ¶
func ExecJS() []byte
ExecJS returns the standard-Go wasm_exec shim bytes (gothic-core-exec.js), version-matched to the toolchain that built core.wasm. Served from /_gothic/.
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 three artifacts (see bootHash).
func Write ¶
Write emits the three 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 all three files' mtimes unchanged.
Types ¶
This section is empty.