From 0b2cd6df14547aa0c694e47e2174b2cb584a854d Mon Sep 17 00:00:00 2001 From: adnaan <758447+adnaan@users.noreply.github.com> Date: Sat, 18 Jul 2026 13:06:24 +0000 Subject: [PATCH] Sync from client@v0.18.2 --- content/client/index.md | 55 ++-------------------------------- content/contributing/client.md | 4 +-- 2 files changed, 4 insertions(+), 55 deletions(-) diff --git a/content/client/index.md b/content/client/index.md index f974208..408645b 100644 --- a/content/client/index.md +++ b/content/client/index.md @@ -2,8 +2,8 @@ title: "@livetemplate/client" source_repo: "https://github.com/livetemplate/client" source_path: "README.md" -source_ref: "v0.16.1" -source_commit: "80dd41be7f1e57ed9ff251d1250afbe864006bec" +source_ref: "v0.18.2" +source_commit: "2b45aee4a9e31e295b314ae07771e68bc1cb35f9" --- # @livetemplate/client @@ -240,57 +240,6 @@ This client library follows the LiveTemplate core library's major.minor version. Patch versions are independent and can be incremented for client-specific fixes. -### Let the server pick the version (recommended) - -There is **no runtime handshake** between server and client, so loading an -unpinned `@latest` bundle is unsafe: a client-only release can ship a wire-format -change to browsers still talking to an older server. To avoid hand-maintaining the -version, LiveTemplate seeds two template functions into every template that render -the CDN URL for the client bundle this server release is wire-compatible with: - -```html - - -``` - -The version moves only when you upgrade the server dependency -(`go get -u github.com/livetemplate/livetemplate`), keeping client and server in -lockstep. The functions resolve the exported `livetemplate.ClientVersion` / -`livetemplate.ClientScriptURL` / `livetemplate.ClientStyleURL` constants, so the -pinned version is single-sourced in Go. Every recipe in these docs uses this -pattern. - -### Self-hosting (offline, air-gapped, or CSP-strict) - -If your deployment cannot reach a public CDN — an offline network, or a -Content-Security-Policy that forbids third-party script origins — vendor the -bundle at the pinned version and serve it from your own origin instead: - -```bash -npm install @livetemplate/client@ # match livetemplate.ClientVersion -# or copy dist/livetemplate-client.browser.js + livetemplate.css into your assets -``` - -```go -mux.Handle("/assets/", http.StripPrefix("/assets/", http.FileServer(http.Dir("assets")))) -``` - -```html - - -``` - -Because the template functions merge into the template FuncMap by name, you can -also keep `{{lvtClientScriptURL}}` in your templates and repoint it at your -same-origin path with a `Funcs` override rather than editing every template: - -```go -tmpl.Funcs(template.FuncMap{ - "lvtClientScriptURL": func() string { return "/assets/livetemplate-client.browser.js" }, - "lvtClientStyleURL": func() string { return "/assets/livetemplate.css" }, -}) -``` - ## Contributing See [CONTRIBUTING.md](CONTRIBUTING.md) for development guidelines. diff --git a/content/contributing/client.md b/content/contributing/client.md index 3fa5c50..fb059eb 100644 --- a/content/contributing/client.md +++ b/content/contributing/client.md @@ -2,8 +2,8 @@ title: "Contributing to @livetemplate/client" source_repo: "https://github.com/livetemplate/client" source_path: "CONTRIBUTING.md" -source_ref: "v0.16.1" -source_commit: "80dd41be7f1e57ed9ff251d1250afbe864006bec" +source_ref: "v0.18.2" +source_commit: "2b45aee4a9e31e295b314ae07771e68bc1cb35f9" --- # Contributing to @livetemplate/client