The package holds the scripts that a local web page of the kit runs: htmx, its extension for Server-Sent Events, and idiomorph, which swaps a fragment by changing only what changed. They are the files their projects publish, byte for byte, under the Zero-Clause BSD licence. A test holds each to its checksum.
vendor, err := assets.New(htmx.Files(), "/htmx/", assets.Options{})
if err != nil {
fmt.Println(err)
return
}
mux := http.NewServeMux()
mux.Handle("GET /htmx/", vendor)
target := vendor.URL(htmx.Script)
fmt.Println(strings.HasPrefix(target, "/htmx/"), strings.HasSuffix(target, "/htmx.min.js"))
w := httptest.NewRecorder()
mux.ServeHTTP(w, httptest.NewRequest(http.MethodGet, target, nil))
fmt.Println(w.Code, w.Header().Get("Content-Type"))
fmt.Println(htmx.Config)true true
200 text/javascript; charset=utf-8
{"allowEval":false,"allowScriptTags":false,"includeIndicatorStyles":false,"selfRequestsOnly":true,"historyCacheSize":0,"historyRestoreAsHxRequest":false}localweb/htmx/example_test.go. CI runs it and checks its output.Serve them with assets, and put htmx.Config into
the page, so that htmx keeps to the Content-Security-Policy of
localweb.Headers.
| Name | What it is |
|---|---|
htmx.Files | the scripts, as an fs.FS |
htmx.Config | the htmx-config of the page; it restores history as a page (decision 41) |
htmx.ScriptVersion, htmx.SSEVersion, htmx.MorphVersion | the versions of the scripts |
A new version of a script comes in a minor release of the kit.