All notable changes to live_slice are recorded in this file. The format is based on
Keep a Changelog, and versions follow
Semantic Versioning: before 1.0, a minor version may break the API.
Releases are published on Hex and tagged in git (v0.2.1); the library is
not published on npm.
Unreleased
0.2.1 - 2026-12-04
Changed
- The service worker fetches the
pagesit precaches at install without following redirects. While nobody is signed in, a page that redirects to the sign-in page is skipped without requesting the sign-in page: one request less at install, and that page's answer no longer replaces the session cookie of the page that is open (a LiveView could reload the page once after it). A redirect that itself writes the session, such as one that stores the page to return to after signing in, still sets its cookie. The install report still lists the page, as{url, kind: "page", essential: false, status: null, error: "redirected"}:statusis null, since a redirect that is not followed hides its status (it used to be the status of the page the redirect led to, usually 200). Static files and theofflinePagestill follow redirects.
Fixed
- A page skipped at install only because the server redirected it no longer causes the warning "the service worker ... installed without ... (redirected)", in the worker or in the page: on a first visit to an app that requires signing in, the worker installs on the sign-in page, where every listed page redirects. Any other skipped file still causes it, and the warning names only those.
0.2.0 - 2026-12-03
Deploy the Elixir and the JavaScript sides together. The guide Upgrading from 0.1.0 to 0.2.0 explains each breaking change in more detail.
Breaking changes
Deploying
- New wire formats: entry operations (
opsinlive_slice:patch, sent byput_entries/5and the other entry functions) and binary columns of types:int16and:uint16. A tab still running the 0.1.0 bundle drops anopspatch without an error and fails a chunk with such a column (unknown column type 8or9). Migration: keep thephx-track-staticattribute on the root layout's script and stylesheet tags, so an old tab reloads when it reconnects; without it, send the new operations and column types only once the new bundle is deployed.
Store and actions
- Failed pushes are kept by default: a server action that got no reply after
maxAttemptspushes stays applied and pending as failed (keepFailedistrueby default) instead of being rolled back with"push_failed", and holds back the later calls that may concern its record untilretry(id)ordiscard(id). When the store sets nokeepFailedand has noonFailedlistener, this is reported once per store and page withconsole.warn. A tab still running 0.1.0 rejects a call another tab kept as failed when its queue reaches it. Migration:keepFailed: falserestores the old behaviour exactly; otherwise offer retry and discard fromonFailedandpending().
Collaborative keys
LiveSlice.CRDT.delete/2returns{:ok, generation}instead of:ok; the errors are unchanged. Migration: match{:ok, _generation}where code matched:ok.- Local changes are batched: the changes made within
batchMs(50 ms by default) go out as one push. Each change is still written to the local copy at once. Migration:batchMs: 0pushes the changes of each task at once, as before. - New status
"waiting": connected, but the LiveView'scrdt_document/2does not name the binding's document yet; the binding syncs once the LiveView names it. Migration: handle the new value where code switches onstatus. - The status key (
statusKey) holdsunsentnext tostatusandwritable. Migration: code that compares the whole value sees one more field. - Before each
sync1, the binding pushes the store's mirrored keys whose debounce is still running, on the same connection, so the LiveView has applied them when thesync1arrives. Migration: none, unless the server relied on the debounce delay. LiveSlice.CRDT's:rate_limitis one window per key and LiveView, whatever document the key syncs: async1to another document no longer starts a fresh window, and background deliveries (deliver1included) count in it. Migration: raise:rate_limitif keys that switch documents often reach it.
Persistence and tabs
- Persisted keys are shared live between tabs (
persist.share,trueby default): after each write, the other tabs show the values at once, without writing them back. Migration:persist: { share: false }restores the old behaviour;persist: { share: ["key"] }shares only the keys listed. - The persisted record of a store gains
seq, a stamp per key (stamps) and, once cleared,epoch.removeStore(name, { clearPersisted: true })replaces the record with a marker ({cleared: id}) instead of deleting it. A tab still running 0.1.0 reads the marker as an invalid record, removes it and writes its own state again, as after a delete. Migration: none in application code.
Service worker and offline
- A precache file that is not a script, stylesheet or WebAssembly (
.js,.mjs,.css,.wasm) no longer fails the install: it is skipped and reported. Migration:essential: ["/"]in the worker's options makes every file essential again. - The manifest of
LiveSlice.ServiceWorkerlists only the names thatPlug.Staticwith the same filters serves: digested names that:onlydoes not serve are left out and logged withLogger.warning, naming the:only_matchingentry that would serve them.only: [](oronly_matching: []) now lists everything, asPlug.Staticserves everything with it. Migration: give the plug the same:onlyand:only_matchingfilters asPlug.Static. - The offline mount reports each hook present in the page and not mounted offline with
console.warn, once per name (never LiveView's ownPhoenix.hooks). Migration: name a hook that rightly needs the server inexcludeto silence it.
Only for code that followed the untagged main after 0.1.0
These concern features added after 0.1.0 that changed again before this release; code written against 0.1.0 is not affected.
- Connection state: a store with no bridge mounted and none expected on the page is
"detached"instead of"connecting". Migration:status === "detached" ? "connecting" : statuswhere an interface showed"connecting". - Coalesced patches: the first patch after a quiet time no longer goes out alone at once; it goes out at the
end of its callback with every patch of the store that callback makes. Migration: a callback that navigates
calls
LiveSlice.flush_patches(socket)first. Patches ahandle_action/4makes go out before its reply,invalidate/4sends the held patches of its store first, and a patch made with a LiveComponent's socket is pushed at once. - A held key goes out with the key the patch gave (an atom or a string) instead of a string, as a patch pushed at once does. Migration: server tests assert the keys they patched.
If-None-Matchgoes only to URLs of the page's origin;createLiveSliceHook({ conditional })opts other origins in. A 304 to a request without it is an error.retry(id)sends at once after a push that timed out, and the bridge sends queued calls again after settlements and retries.patch/4and the entry functions raiseArgumentErrorfor an unknown option; a connected LiveView that renders a bridge sending the actions of aLiveSlice.Actionsmodule it does not attach raises at its first render;send_json/3raises for a:versionthat is not a non-empty string, an integer, aDateTime,NaiveDateTimeorDate.send_json/3hashes versions with a comma, a quote, a space or non-ASCII characters into the tag (W/"h<hash>"); weak comparison andIf-None-Match: *are honoured.- Install reports in
live_slice:metacarryrank(the install order),offlinePageis null when the offline page was not kept, and a reset (unregisterServiceWorker({clearCaches: true})) deletes the reports. - The persistent chunk cache keys an entry with a per-chunk version by the version's type too: such entries cached before are fetched again once.
- The persisted record's
seqand stamps count from the current time in milliseconds rather than from 1. - A collaborative binding marks stored updates as acknowledged each time the server acknowledges changes, so
after a reload
unsentandunsentSinceleave out what was acknowledged before.LiveSlice.CRDT.MemoryPersistence.save/4is available again.
Added
Store and actions
- Failed pushes:
retry(id)sends a failed call again with the samemeta.idandmeta.base, anddiscard(id)rolls it back and settles it as"discarded";onFailedandonRetrylisteners;pending()marksfailed: trueand, on the calls it holds back,blocked: true. The failed state is persisted with the queue and announced to the other tabs. cancel(id)takes back a queued call that was never pushed: it is rolled back and its promise rejects with"cancelled". It returnsfalseonce the call was pushed.- Conflicts that wait for a person:
onConflict: "park"(or a resolver that returns"park", or a promise of{ args }ornull) parks the call;resolveConflict(id, "mine" | "theirs", { args })resolves it, andpending()lists it withparked: { reason, state }. Parked calls are persisted and shared between tabs. - The confirmed state is public:
getConfirmedState(),getConfirmed(key)andsubscribeConfirmed(selector, listener, { equals });reducersfold a key the server writes into the confirmed state in the same write. - The promise of a server action carries
id(its mutation id) andqueued(resolvestruewhen the call waits for a connection);onQueued(listener);pending()entries carryat, the time the call was made. - Transport API for transports of their own:
exhausted(id),pushFailed(id, reason),markQueued(id),setConnection(status)andnoteServerData(at?).
Bridge and connection
- Connection state per store:
store.connection("connected","connecting","reconnecting","offline"or"detached"),store.serverAt(when the page last received server data for the store),onConnection(listener), andconnectionKeys: { status, serverAt }to write both into store keys. flushMirror(store, key)pushes mirrored keys at once instead of when their debounce elapses.- Conditional fetches: the bridge sends the
ETagof an invalidate response back asIf-None-Matchand keeps the value on a304 Not Modified;createLiveSliceHook({ conditional })allows it for other origins.LiveSlice.send_json/3answers such fetches with a weakETag, from a hash of the JSON or fromversion:. defineInvalidation(store, key, { params, debounce })adds query parameters from the store's state to the server's invalidate URL and fetches again when they change.LiveSlice.Actions:use LiveSlice.Actions, store: ..., actions: [...]defines a store's server actions once; attached withon_mountand rendered with<LiveSlice.bridge module={...} />, it lets every page send the store's queue. A bridge logs a warning when server actions are queued and no bridge of the page sends them.
Server patches
- Entry functions change entries inside one key:
put_entries/5,merge_entries/5,delete_entries/5,append_items/5andprepend_items/5(withlimit:). They apply to the confirmed value of the key. - Coalescing:
coalesce: [quiet: ..., max_wait: ..., keep: [...]]onuse LiveSlice, orcoalesce:per call (onpatch/4and the entry functions, also in a LiveView that does notuse LiveSlice), holds a LiveView's patches and sends them merged, without timers in the application.keepnames keys whose every value must reach the client.LiveSlice.flush_patches(socket)(orflush_patches(socket, store)) sends what waits.
Collaborative keys
- Following the store:
docmay be a function of the store's state that returns the document's name, ornullfor none;binding.name,binding.loadedandonLoad({ name })tell which document is open and when its local copy has loaded. The LiveView sendsresynconce itscrdt_document/2names the document. - Unsent changes:
binding.unsent,binding.unsentSinceandunsentin the status key, kept across a reload. - Background delivery of offline changes to documents no binding has open:
listUnsentDocuments(),deliverUnsentDocuments({...})anddropUnsentDocument(name, ...)inlive_slice/crdt. The LiveView accepts a delivery through theaccept_crdt_delivery/3callback; the server refuses by default. LiveSlice.CRDT.delete/3takesmeta:(who deleted, why), which every client gets inonResetasmeta;delete(doc_name, opts)deletes on the default server. Persistences may implementsave/5, which stores the metadata, and return it fromload/2.carryOver(off by default) oncreateCollaborativeKeyanddeliverUnsentDocuments: after a delete, the changes the server never acknowledged are put onto the new generation, once across tabs, reloads and background deliveries.onResetreportscarried,carriedValueandnotCarried(why nothing was carried).
Persistence and tabs
persist.sharetakestrue,falseor a list of the keys to share between tabs.removeStore(name, { clearPersisted: true })is announced to the other tabs, which stop writing the record, put their persisted keys back to the store's initial values and callstore.onCleared(listener).
Service worker and offline
essentialin the worker's options: patterns of the precache URLs that fail the install.- Install reports: the worker posts
{type: "live_slice:install", version, ok, failures}to every page of the origin and records it inlive_slice:meta, each failure naming its URL; theonInstallFailedoption ofregisterServiceWorkeris called with them. offlineReadiness({ pages })inlive_slice/offlinereads the caches to tell whether this device opens the page offline now, and if not, why.:only_matchingfilter ofLiveSlice.ServiceWorker, asPlug.Static's.createOfflineMount({ mountAll: true, exclude: [...] })mounts every object hook offline except the ones named.
Chunk loader and columns
- Per-chunk versions:
chunkVersionsKey(orchunkVersionsandloader.setChunkVersions); the chunk's version is the third argument ofurl(chunk, version, chunkVersion), and only chunks whose version changed are fetched again. LiveSlice.Columnscolumn types:int16and:uint16, decoded asInt16ArrayandUint16Array.
Testing helpers
live_slice/testing, for application tests in Node:FakeLiveView,deferred,nextTurn,jsonResponse,createReferenceServer(Y)(the collaborative key protocol asLiveSlice.CRDTspeaks it),createFakeIndexedDB()andcreateFakeTabs({ storage }), whoseopenTab()gives a second tab its own store registry. Nothing else in live_slice imports it.
Changed
- Every listener event about a call (
onPending,onQueued,onFailed,onRetry,onConflict,onRejected,onSettled) and the context of anonConflictresolver carryat, the time the call was made; it is absent only for an entry stored by an older version. A test that compares whole events sees one more field. onResetof a collaborative key also receivesmeta,value,unsent,carried,carriedValueandnotCarried(false,nulland"off"withoutcarryOver).- Document storages:
loadandsetGenerationmay resolve withcarry,setGenerationpassesdecidewhat is stored as a second argument, and its change may holdcarryandappend(seecrdt_storage.js). Custom storages that ignore them keep working, with the limits listed below. - Tabs also post
{type: "attempted", id, attempts}for each push of the sending tab; older tabs ignore it. LiveSlice.Columnschecks each distinct string of a dictionary column for UTF-8 once, not each record, which makes dictionary columns faster to build.
Fixed
- A store no longer writes its persisted record when only keys that are not persisted changed before it finished hydrating; it used to write its whole persisted state, unchanged.
- With tab coordination, a tab that took over the queue and adopted a resubmitted call before it heard of the resubmission no longer rejects the original call as a conflict: the resubmission takes its place and its caller.
Known limitations
- Coalesced patches that still wait when the LiveView ends are not sent, including on
push_navigate/2andredirect/2: callLiveSlice.flush_patches(socket)before navigating. A key patched twice while held reaches the client with its last value only, unless it is named inkeep. - A tab still running an older bundle after a deploy cannot apply
opspatches or decode:int16/:uint16columns; it relies onphx-track-staticto reload (see Breaking changes). - With tab coordination, the tab that sends the queue also moves the
baseof calls it adopted from other tabs when an earlier call is confirmed, judging from its own confirmed state rather than the state of the tab that made the call. - A bridge inside a nested LiveView (
live_render) reached by live navigation comes with that LiveView's join patch, after the parent's hooks mounted, so those hooks can read"detached"before the store turns"connecting". - Carry-over of unsent changes: the carried content is written again at the end of each root, so content
others added since the delete may land before or after it; deletions are not carried and a text loses its
formatting. A function that refuses holds only for its own tab: another tab whose function accepts carries
what it holds. A tab without a local storage (
persistence: null) carries only the changes it made itself. With a custom storage that does not passdecidewhat it holds, only the tab that switches the copy carries and a tab reports only what it carried itself; with one that ignorescarryandappend, the carried changes are stored after the switch, so a reload in between loses them. A background delivery that finds the copy switched by a tab that recorded no carry-over reportsnotCarried: "unknown"and carries nothing. deliverUnsentDocumentsruns only when the application calls it, for example fromonConnection.- Known limits lists the library's other limits.
0.1.0 - 2026-12-01
No tag was made for 0.1.0; this changelog takes it as the state of main at commit 75e5f14, before the
changes listed under 0.2.0.
Added
- A synchronous client-side store for LiveView hooks (
createStore,ensureStore,removeStore), a bridge hook (LiveSliceHook) and theLiveSliceElixir module: mirrored keys,patch/3,invalidate/4and DOM bindings. - Optimistic server actions handled by
handle_action/4, with rollback, version conflicts (base,record,onConflictresolvers) and an offline queue persisted in IndexedDB and shared between tabs. - Persisted keys (
persist) with versions and migrations. - Collaborative keys (
live_slice/crdtandLiveSlice.CRDTon the optionaly_exdependency), with document generations and server deletes. live_slice/data: a chunk loader, a persistent chunk cache and theLiveSlice.Columnsbinary codec.live_slice/maplibre: a MapLibre GL JS binding (bindMap).live_slice/swandlive_slice/offlinewithLiveSlice.ServiceWorker: a service worker and an offline mount for an offline cold start.