calendar
All repositories: gitoria
29.6 KB
// Offline state and durable emits. The Client handle stays live across navigation;// seed, page and socket are always read from it, never copied into this feature.import { registerFeature } from 'hl:web'client = nullstatic register = () => { return registerFeature('offline', Offline) }replayingQ = null // the `q` of the queued entry whose frame is out and not acked (it cannot be taken back)store = nullunacked = {}replays = {} // 'k<i>' → what ends a replayed entry's wait when its socket closeslive = {} // q → true while a live emit's entry (written before its frame) waits for its ack: the replay leaves it aloneflushing = falseowner = '' // whose the kept copy is (settleWho): the last user logged inholding = false // an anonymous page over a user's copy: nothing is kept or laid over itheldBack = false // the server said a queued entry is for another user than the session'sneedsResync = false // a locally constructed destination needs full server values on reconnect (#377)flushAgain = false // an entry was queued while a round ran: the round goes over the queue once morequeueRetryTimer = null // a round that did not fully drain tries again after queueRetryWaitstatic replayAckTimeout = 20000static queueRetryWait = 3000// A DOCUMENT THAT STANDS IN FOR THIS URL (#124): the worker answered an unvisited param page// with a kept document of the same component, so the seed's parameters are another url's.// This url's are the truth: they go into the instance, and what they feed is derived again// here (what only the server can derive stays as that document had it, until a push).standIn() {if (client.page == null || client.seed.page == null) { return null }m = client.router.match(location.pathname)if (m == null || m.kind != 'component') { return null }mine = JSON.stringify(m.params)if (mine == JSON.stringify(client.seed.page.params)) { return null }for (k of m.params.keys()) { client.page.instance[k] = m.params[k] }client.seed.page.params = m.paramsclient.patch(client.page.chain, 'page', client.moved(&client.page, m.params.keys()), [])return null}// A kept route's identity reuses the component marker: an index in offline.pages,// or the key of a data-free page. true still means an ordinary server page.localRoute(String path) {if (holding) { return null }matched = client.router.match(path)if (matched == null || matched.kind != 'component') { return null }marker = matched.route.componentif (hlTypeName(marker) == 'Number') { return client.seed.offline.pages[marker] }return hlTypeName(marker) == 'String' ? marker : null}// No document request and no server construction. The page and its parents are// ordinary client constructions, with the destination's parameters and kept data.navigation(String path) {key = localRoute(path)if (key == null) { return null }matched = client.router.match(path)next = client.seednext.local = truenext.page = localMount(key, matched.params, [], 'page', path)levels = []let at = client.planOf(key).parentwhile (at != null && levels.length < 64) {levels.push(at)at = client.planOf(at).parent}let top = nulllet i = 0while (i < levels.length) {ch = []let n = levels.length - i - 1while (n > 0) { ch.push('^') n = n - 1 }level = localMount(levels[i], matched.params, ch, 'shell', path)if (top != null) { level.kids['^'] = top }top = leveli = i + 1}next.shell = topneedsResync = truereturn next}localMount(String key, Hybrid params, Hybrid chain, String root, String path) {bp = client.planOf(key)state = mountState(key, params, chain, root, path)if (bp.route == true) { state.route = client.currentRoute() }return { key = key params = params state = state kids = {} }}// Exact-address values win for parameter-fed members. Component-wide members// follow their freshest kept values. An unvisited address has client defaults;// server-only initializers are pinned to null until reconnect supplies them.mountState(String key, Hybrid params, Hybrid chain, String root, String path) {client.planOf(key)let state = {}list = client.derivationsOf(key)for (d of list) { if (d.srv == true) { state[d.name] = null } }if (store == null || holding) { return state }base = chain.length == 0 && root == 'page' ? key : (root == 'page' ? kidKey(chain, key) : shellKey(chain, key))fed = root == 'page' && chain.length > 0 ? null : fedBy(key, params)if (fed != null) { readState(base, fed, false, &state) }readState(base + '|' + path, fed, true, &state)// Match a fresh online page: client members run their initializers. Only// server-supplied data comes from the offline store, never another page's draft.for (d of list) {if (d.srv != true && d.name != 'session' && d.name != 'host' && d.name != 'headers') { delete state[d.name] }}return state}readState(String key, Hybrid fed, Boolean ofUrl, &state) {rec = done(objects('state', 'readonly').get(key))if (rec != null) {for (name of rec.members.keys()) {if (fed == null || fed.includes(name) == ofUrl) { state[name] = JSON.parse(rec.members[name].v) }}}return null}// ---- THE OFFLINE LAYER (COMPONENTS §10) --------------------------------------------// Live only in an app whose manifest declares `offline = [ … ]`: the seed then says// which pages it keeps, which emits it may queue, which worker to register, and the// server's clock at the render. Everything is in ONE IndexedDB database, `hl-offline`:// state `{ k, members }` under `<component>|<path>`: per member, the freshest value// this browser was told and the server time it was true at (`{ at, v }`,// v as JSON) — from the render, from a navigation, from every push// The shell (and each parent level, and the components composed into them) is kept the// same way under `@shell|<address>|<component>`, so its keys never meet a page's.// queue `{ id, event, payload, at, q }`, the id counting up, so the order the entries// are read in IS the order they were made; `q` is the emit's stable id, the// same on every try, which the server runs once. A queueable emit on an open socket is// written here BEFORE its frame goes out and leaves on its ack (sent / ack below)offlineBoot() {registerWorker()store = openStore()if (store == null) { return null }settleWho()if (keptPage()) {rehydrate()remember(client.seed.page.state.keys(), client.seed.offline.at)rehydrateShell()rememberShell()rehydrateKids()rememberKids()}client.syncQueued()// the network came back: reconnect now, not when the backoff says (the queue then// goes out at once)window.addEventListener('online', () => { client.reconnectNow() })return null}// WHOSE THE KEPT COPY IS (ticket #125). The seed says who the session is (an opaque value,// '' for nobody); the copy remembers its OWNER under `@who`: the last user who was logged// in. A session that expired, or a fresh anonymous one, owns nothing and changes nothing:// the owner's queue is HELD (not replayed, not dropped) and nothing is laid over or kept// for the anonymous page. The owner logging in again replays it; ANOTHER user logging in// forgets the owner's copy. The first user to log in adopts a copy that had no owner.settleWho() {rec = done(objects('state', 'readonly').get('@who'))owner = rec != null ? rec.who : ''w = client.seed.offline.whoholding = w == '' && owner != ''if (w == '' || owner == w) { return null }if (owner == '') {owner = wdone(objects('state', 'readwrite').put({ k = '@who'; who = w; }))return null}return forget(w)}// A FACE CHANGED WHOSE SESSION THIS IS (the ack says so): a log-out forgets the copy, a login// is settled like a page that arrived under that userwhoChanged(w) {client.dropKept()if (w == client.seed.offline.who) { return null }client.seed.offline.who = wif (w == '') { return forget('') }return settleWho()}// an explicit log-out: the owner's state, queue and documents all goforgetOffline() {client.dropKept()return forget('')}// the state, the queue and the worker's documents go; the copy is now `to`'s. The worker// keeps the page that stands again, fetched as this session sees it.forget(to) {if (store == null || client.seed == null || client.seed.offline == null) { return null }done(objects('state', 'readwrite').clear())done(objects('queue', 'readwrite').clear())done(objects('state', 'readwrite').put({ k = '@who'; who = to; }))owner = toholding = client.seed.offline.who == '' && to != ''sw = navigator.serviceWorkerif (sw != null && sw.controller != null) { sw.controller.postMessage({ t = 'forget'; path = location.pathname + location.search; }) }client.syncQueued()return null}// is the mounted page one the app keeps?keptPage() {return client.page != null && client.seed.offline != null && !holding && client.seed.offline.pages.includes(client.page.key)}// THE WORKER, registered once: a page it already controls has it, and the browser// itself checks the entry script for a new build at every navigationregisterWorker() {sw = navigator.serviceWorkerif (sw == null || sw.controller != null) { return null }r = window.__hlAttempt(() => { return sw.register(client.seed.offline.worker, { scope = '/' type = 'module' }) })if (!r.ok) { console.warn('framework: the offline worker could not be registered — ' + r.error) }return null}openStore() {if (window.indexedDB == null) { return null }// A BROWSER'S OPEN CAN STAY PENDING (a loaded Chrome: the request neither succeeds nor fails, W88/W99, Atlas G2):// boot awaits this store before it connects, so the page never finished hydrating. The open is given 3 s; after// that the page runs without its offline copy (store null, as when IndexedDB is missing) and a late success is closed.return new Promise((res, rej) => {let gaveUp = falsereq = indexedDB.open('hl-offline', 1)timer = setTimeout(() => { gaveUp = true res(null) }, 3000)req.onupgradeneeded = () => {db = req.resultdb.createObjectStore('state', { keyPath = 'k' })db.createObjectStore('queue', { keyPath = 'id' autoIncrement = true })}req.onsuccess = () => {if (gaveUp) { req.result.close() return null }clearTimeout(timer)res(req.result)}req.onerror = () => { clearTimeout(timer) res(null) }})}// one object store, in its own transactionobjects(name, mode) {return store.transaction(name, mode).objectStore(name)}// an IndexedDB request's result; null when it faileddone(req) {return new Promise((res, rej) => {req.onsuccess = () => { res(req.result) }req.onerror = () => { res(null) }})}// WHERE THIS PAGE'S STATE IS KEPT (ticket #123). A member that no route parameter feeds is// the component's: the same list at `/` and at `/notes/:id`, so it is kept ONCE, under the// component, and every url of it reads the freshest. A member a route parameter feeds — the// parameter itself, and every derivation that reads one, transitively — is that url's.stateKey() {return client.page.key + '|' + location.pathname + location.search}paramFed() {return fedBy(client.page.key, client.seed.page != null ? client.seed.page.params : null)}// the members of component `key` that its route parameters feed (the parameters, and everything derived from them)fedBy(key, params) {fed = ['route']if (params != null) {for (k of params.keys()) { fed.push(k) }}list = client.derivationsOf(key)let again = truewhile (again) {again = falsefor (d of list) {if (!fed.includes(d.name) && client.feedsFrom(d, fed)) {fed.push(d.name)again = true}}}return fed}// KEEP what the server said the named members of the page are, as of `at` (its// clock), the url's under the url and the others under the component.remember(names, at) {if (store == null || !keptPage()) { return null }fed = paramFed()byUrl = []byComponent = []for (n of names) {if (fed.includes(n)) { byUrl.push(n) } else { byComponent.push(n) }}keepMembers(stateKey(), byUrl, at)keepMembers(client.page.key, byComponent, at)return null}// A member already kept from a LATER moment is left as it is, so the order the answers// arrive in does not matter. Read and written in one transaction.keepMembers(k, names, at, chain = null, root = 'shell') {if (names.length == 0) { return null }os = objects('state', 'readwrite')let rec = done(os.get(k))if (rec == null) { rec = { k = k; members = {}; } }let changed = falsefor (n of names) {if (n != '__hlQueued' && n != '__hlQueue' && n != '__hlOnline' && n != '__hlReach') {was = rec.members[n]v = chain == null ? JSON.stringify(client.page.instance[n]) : client.shellValue(chain, n, root)if (v != null && (was == null || was.at <= at)) {rec.members[n] = { at = at; v = v; }changed = true}}}if (changed) { done(os.put(rec)) }return null}// AT BOOT, the kept values that are NEWER than this document are laid over it: a// document the worker served from its cache is as old as the visit that cached it,// and what a later push said is the fresher truth. A document the network just// rendered is newer than everything kept, and nothing is laid over it.rehydrate() {fed = paramFed()names = laidOver(done(objects('state', 'readonly').get(stateKey())), fed, true)for (n of laidOver(done(objects('state', 'readonly').get(client.page.key)), fed, false)) { names.push(n) }client.patch(client.page.chain, 'page', names, [])return null}// the members of one kept record that are the url's (`fed`) or not, and newer than the document// (`chain`: null for the page, else the address of the shell mount they are laid over)laidOver(rec, fed, ofUrl, chain = null, root = 'shell') {names = []if (rec == null) { return names }for (n of rec.members.keys()) {e = rec.members[n]if (e.at > client.seed.offline.at && fed.includes(n) == ofUrl) {if (chain == null) { client.page.instance[n] = JSON.parse(e.v) } else { client.shellLay(chain, n, e.v, root) }names.push(n)}}return names}// THE SHELL, ITS PARENT LEVELS AND THE COMPONENTS COMPOSED INTO THEM (#341) are kept by the// page's rules: per member, with the server's time, laid over a cached document at boot only// when newer. They stand at an address (`chain`: [] the shell, ['^'] the next level, …), under// `@shell|<address>|<component>` so no key is a page's. A level's members that a route parameter// feeds are that url's (as the page's are); a composed component's are always the url's, since// what a host binds into it may come from a parameter.shellKey(chain, key) {return '@shell|' + chain.join('/') + '|' + key}isLevel(chain) {for (c of chain) { if (c != '^') { return false } }return true}shellFed(chain, key) {if (!isLevel(chain)) { return null }return fedBy(key, client.routeParams()[key])}rehydrateShell() {for (m of client.shellMounts()) {fed = shellFed(m.chain, m.key)k = shellKey(m.chain, m.key)let names = []if (fed == null) {names = laidOver(done(objects('state', 'readonly').get(k + '|' + location.pathname + location.search)), [], false, m.chain)} else {names = laidOver(done(objects('state', 'readonly').get(k + '|' + location.pathname + location.search)), fed, true, m.chain)for (n of laidOver(done(objects('state', 'readonly').get(k)), fed, false, m.chain)) { names.push(n) }}client.patch(m.chain, 'shell', names, [])}return null}// what the render gave the shell mounts, kept as of the render's timerememberShell() {if (store == null || !keptPage()) { return null }for (m of client.shellMounts()) { rememberMount(m.chain, m.key, m.names, client.seed.offline.at) }return null}// THE COMPONENTS COMPOSED INTO THE PAGE (#343), at any depth, are kept by the same rules, with the// same walk (client.pageMounts is collectMounts from the page root): always per url, under// `@page|<address>|<component>`, so no key is a page's or a shell's. The page root's own members// are the page's (remember above).kidKey(chain, key) {return '@page|' + chain.join('/') + '|' + key}rehydrateKids() {for (m of client.pageMounts()) {names = laidOver(done(objects('state', 'readonly').get(kidKey(m.chain, m.key) + '|' + location.pathname + location.search)), [], false, m.chain, 'page')client.patch(m.chain, 'page', names, [])}return null}rememberKids() {if (store == null || !keptPage()) { return null }for (m of client.pageMounts()) { rememberMount(m.chain, m.key, m.names, client.seed.offline.at, 'page') }return null}// KEEP the named members of one mount of the shell (or, with root 'page', of the page's composed components), as of `at`rememberMount(chain, key, names, at, root = 'shell') {if (store == null || !keptPage()) { return null }fed = root == 'page' ? null : shellFed(chain, key)k = root == 'page' ? kidKey(chain, key) : shellKey(chain, key)url = k + '|' + location.pathname + location.searchif (fed == null) {keepMembers(url, names, at, chain, root)return null}byUrl = []byComponent = []for (n of names) {if (fed.includes(n)) { byUrl.push(n) } else { byComponent.push(n) }}keepMembers(url, byUrl, at, chain)keepMembers(k, byComponent, at, chain)return null}// AN EMIT THAT DID NOT REACH THE SERVER. A page the app keeps queues it; any other// says so. It answers null either way: nothing was answered.undelivered(event, payload, q) {if (store != null && client.seed.offline.queue.includes(event)) {enqueue(event, payload, q)return null}// (a navigation's own `page` emit is not reported: it falls back to loading the// document, which the worker answers)if (event != 'page') { console.warn('framework: ' + event + ' did not reach the server, and it is not an emit a page this app keeps offline may queue') }return null}// A FILE WAITS WITH ITS EMIT: IndexedDB keeps a File as it is, so the entry's `files`// holds them and each one's place in the payload names it, `{ __hlFile = n, name, type,// size }` (what a page shows of it in `__hlQueue`)enqueue(event, payload, q) {done(objects('queue', 'readwrite').add(entryOf(event, payload, q)))client.syncQueued()// (an entry added while a round runs is taken by that round's next pass)if (flushing) { flushAgain = true }// A LIVE EMIT CAN LAND HERE WITH ITS SOCKET STILL OPEN (crossing() above, when only// its UPLOAD dropped): nothing closed, so there is no "next open" to replay it on.// flush() is asked for right away — a no-op with no live socket, same as always.flush()return null}// the queue row of an emit, its files beside itentryOf(event, payload, q) {files = []kept = []for (a of payload) {if (client.isFile(a)) {kept.push(fileMark(a, files.length))files.push(a)} else if (client.isFileList(a)) {marks = []let j = 0while (j < a.length) {provider = client.uploadsReady()f = provider != null ? provider.fileAt(a, j) : (hlTypeName(a) == 'Hybrid' ? a[j] : a.item(j))marks.push(fileMark(f, files.length))files.push(f)j = j + 1}kept.push(marks)} else {kept.push(a)}}return { event = event; payload = JSON.stringify(kept); files = files; at = Date.now(); q = q; who = client.seed.offline.who; }}// WRITE BEFORE SEND (#339). A queueable emit about to go out on an open socket is in the queue// first, one transaction, committed before the frame is sent: a page killed while its socket is// open and silent (a stalled connection) still has the emit, and the next socket replays it.// It leaves the queue on its ack (ack below). The replay of it and the ack of it can meet (the// ack arrived, the page was killed before the delete): the entry then goes out again under the// same `q`, which the server has kept, and it answers the repeat without running it again.// While the emit is live the replay and the queue's readers leave it alone (`live`).// Answers 'sent' (the frame may go out), or 'queued' (the socket was lost while the entry was// written: it waits for the next one and nothing is sent now).sent(k, event, payload, q) {if (store == null) {unacked[k] = { event = event; payload = payload; q = q; id = null; }return 'sent'}live[q] = trueid = commitRow(entryOf(event, payload, q))if (id == null) {// (the write failed: the emit is kept in memory as before, and queued if the socket is lost)live[q] = nullif (client.socket == null || client.socket.readyState != 1) {enqueue(event, payload, q)return 'queued'}unacked[k] = { event = event; payload = payload; q = q; id = null; }return 'sent'}if (client.socket == null || client.socket.readyState != 1) {live[q] = nullclient.syncQueued()return 'queued'}unacked[k] = { event = event; payload = payload; q = q; id = id; }return 'sent'}// one row added in its own transaction; its id once the transaction has committed, null when it failedcommitRow(rec) {return new Promise((res, rej) => {let tx = nulllet req = nulllet made = window.__hlAttempt(() => {tx = store.transaction('queue', 'readwrite')req = tx.objectStore('queue').add(rec)return 1})if (!made.ok) { res(null) return null }tx.oncomplete = () => { res(req.result) }tx.onerror = () => { res(null) }tx.onabort = () => { res(null) }})}// whether entries made for this user wait in the queue, or a replay is under wayqueuedAhead() {if (flushing) { return true }let rows = done(objects('queue', 'readonly').getAll())if (rows == null) { return false }for (r of rows) { if (r.who == client.seed.offline.who && live[r.q] != true) { return true } }return false}fileMark(f, n) {return { __hlFile = n name = f.name != null ? f.name : '' type = f.type size = f.size }}isFileMark(a) {return hlTypeName(a) == 'Hybrid' && a.__hlFile != null}// A REPLAY GIVES A DROPPED UPLOAD MORE THAN ONE TRY (mission 2026-09-26): the socket// having just reopened says the network is back, so a stall here reads as congestion,// not as "offline" — unlike a live emit's `uploadFile` (uploadAll above), which still// gives up on the first drop, so an app that is genuinely offline queues at once// instead of waiting out a retry budget it does not need. `uploadFile` resumes from// what the server already has (`begun.have`), so asking it again is exactly a retry,// not a restart.uploadFileReplay(event, index, f, q) {provider = client.uploadsReady()if (provider == null) { return { error = 'files could not start because the upload module could not be loaded' dropped = true } }let up = provider.uploadFile(event, index, f, q)let misses = 0while (up.dropped == true) {misses = misses + 1if (misses > provider.uploadRetries) { return up }provider.uploadWait(misses)up = provider.uploadFile(event, index, f, q)}return up}// a queued entry's files, sent as the emit's own were (`uploadFile`, under its `q` and// their places): the payload with every mark replaced by `{ __hlUpload = id }`uploadKept(event, payload, files, q) {out = []for (a of payload) {if (isFileMark(a)) {up = uploadFileReplay(event, a.__hlFile, files[a.__hlFile], q)if (up.error != null) { return up }out.push({ __hlUpload = up.id })} else if (hlTypeName(a) == 'Hybrid' && a.length != null && a.length > 0 && isFileMark(a[0])) {ids = []for (m of a) {up = uploadFileReplay(event, m.__hlFile, files[m.__hlFile], q)if (up.error != null) { return up }ids.push({ __hlUpload = up.id })}out.push(ids)} else {out.push(a)}}return { payload = out }}// THE SOCKET CLOSED: every queueable emit it had not acked is queued, and a replay it// was carrying stops (its entry is still in the queue — it leaves only on its ack)unanswered() {for (k of unacked.keys()) {u = unacked[k]if (u != null) {unacked[k] = nullclient.inflight[k] = nullres = client.pending[k]client.pending[k] = null// (a live emit's entry is in the queue already: it is only let go of, and replayed on the next socket)if (u.id != null) { live[u.q] = null client.syncQueued() } else { enqueue(u.event, u.payload, u.q) }if (res != null) { res(null) }}}for (k of replays.keys()) {stop = replays[k]if (stop != null) {replays[k] = nullclient.pending[k] = nullstop()}}return null}// THE REPLAY, when a socket opens: every queued entry, oldest first, as an emit frame on// that socket; the next goes out when this one is acked, and an entry leaves the queue// only on its ack. A socket that closes midway stops it, and the next open resumes it.// A ROUND THAT DID NOT FINISH SCHEDULES ITS OWN NEXT TRY (mission 2026-09-26): a socket// that stays open the whole time never fires the "next open" above, so a step stuck// inside `replay()` — an upload, or the ack, whichever gave up — must not depend on one.// `replay()` itself is bounded (uploadCall's stall guard, and the ack wait's own below),// so `flushing` always clears; this is what makes a jam at any ONE step a delay, not a// stop.flush() {if (flushing || store == null) { return null }flushing = trueheldBack = falselet drained = truelet again = truewhile (again) {again = falseflushAgain = falselet rows = done(objects('queue', 'readonly').getAll())if (rows == null) { rows = [] }for (r of rows) {replayingQ = null// NEVER UNDER ANOTHER USER (#125): an entry waits for the user it was made for; one// from before users were kept (no user) cannot say whose it is, and is dropped unsentif (done(objects('queue', 'readonly').get(r.id)) == null) {// (taken back while this round ran)} else if (r.who == null) {done(objects('queue', 'readwrite').delete(r.id))client.syncQueued()} else if (r.who != client.seed.offline.who) {} else if (live[r.q] == true) {// (a live emit waiting for its ack: its frame is out already)} else if (flushing && replay(r)) {done(objects('queue', 'readwrite').delete(r.id))client.syncQueued()} else {flushing = falsedrained = false}}if (drained && flushAgain && flushing) { again = true }}flushing = falsereplayingQ = nullif (!drained && !heldBack) {if (queueRetryTimer != null) { clearTimeout(queueRetryTimer) }queueRetryTimer = setTimeout(() => { queueRetryTimer = null flush() }, queueRetryWait)}return null}// one entry on the socket; true when it was acked. ITS FILES GO UP FIRST, under the// entry's `q`: an upload a dropped connection cut short goes on where it stopped (and the// entry stays queued), one the server refuses drops the entry with the error, and one// whose emit the server already handled is not sent again. THE ACK ITSELF IS BOUNDED// too (`replayAckTimeout`): a socket the heartbeat has not yet caught, or never will for// this one, must not hold this promise — and `flush()` — open forever.replay(r) {let s = client.socketif (s == null || s.readyState != 1) { return false }let payload = JSON.parse(r.payload)if (r.files != null && r.files.length > 0) {let sent = uploadKept(r.event, payload, r.files, r.q)if (sent.dropped == true) { return false }if (sent.error != null) {console.error("framework: the queued emit '" + r.event + "' is dropped: the upload of " + sent.error)return true}payload = sent.payloads = client.socketif (s == null || s.readyState != 1) { return false }}client.nextId = client.nextId + 1i = client.nextIdf = { t = 'emit'; i = i; event = r.event; payload = payload; }if (r.q != null) { f.q = r.q replayingQ = r.q }if (r.who != null) { f.w = r.who }text = JSON.stringify(f)k = 'k' + ireturn new Promise((res, rej) => {let settled = falsegiveUp = setTimeout(() => {if (settled) { return null }settled = trueclient.pending[k] = nullreplays[k] = nullres(false)return null}, replayAckTimeout)client.pending[k] = (answer) => {if (settled) { return null }settled = trueclearTimeout(giveUp)res(!heldBack)return null}replays[k] = () => {if (settled) { return null }settled = trueclearTimeout(giveUp)res(false)return null}s.send(text)})}ready() { return store != null }queueable(event) { return client.seed.offline.queue.includes(event) }ack(k, held = false) {if (held) { heldBack = true }u = unacked[k]unacked[k] = nullreplays[k] = null// A LIVE EMIT'S ENTRY LEAVES ON ITS ACK (not waited for: the delete is asked for, and `live` holds// the replay off until it is done). An ack that says the entry is for another user's session keeps it.if (u != null && u.id != null) {if (held) { live[u.q] = null } else { dropRow(u.id, u.q) }}return null}dropRow(id, q) {let tx = nulllet r = window.__hlAttempt(() => {tx = store.transaction('queue', 'readwrite')tx.objectStore('queue').delete(id)return 1})if (!r.ok) { live[q] = null return null }tx.oncomplete = () => { live[q] = null }tx.onerror = () => { live[q] = null }tx.onabort = () => { live[q] = null }return null}ownerOf(w) {if (store != null && w != null) { whoChanged(w) }return null}arrived(path) {// Local defaults are never stamped as a new server observation.if (client.seed.local == true) { return null }if (store != null) { settleWho() }if (client.page != null && client.seed.offline.pages.includes(client.page.key)) {remember(client.seed.page.state.keys(), client.seed.offline.at)rememberShell()rememberKids()sw = navigator.serviceWorkerif (sw != null && sw.controller != null) { sw.controller.postMessage({ t = 'keep'; path = path; }) }}return null}rows() {if (store == null) { return [] }records = done(objects('queue', 'readonly').getAll())if (records == null) { return [] }out = []for (r of records) { if (live[r.q] != true) { out.push(r) } }return out}cancel(q) {if (store == null || q == replayingQ) { return false }for (r of rows()) {if (r.q == q) {done(objects('queue', 'readwrite').delete(r.id))client.syncQueued()return true}}return false}
Branches
Latest commits
- f9b8f918Merge branch 'calendar-vendor-day61' into mainAtlas
- 66341793|||PR Vendor Hybriel day61Atlas
- 36fc596bMerge branch 'vendor-day59' into mainAtlas
- b37cc1da|||PR Vendor Hybriel day59Atlas
- 05665102Merge branch 'vendor-day56' into mainAtlas
- 687296fb|||PR Vendor Hybriel day56Atlas
- a6166d4eMerge branch 'hl-standard-3' into mainAtlas
- 6d0eb3b0|||PR Calendar day add buttons only when signed in (Kunibert minor)Atlas
- add4b499|||PR Make calendar day actions keyboard accessibleAtlas
- 79e49b4dMerge branch 'hl-standard' into mainAtlas
- e9fec7bb|||PR HL-STANDARD clean-up: typed parameters, plain locals, by-reference cacheAtlas
- eff166a4Re-vendor complete Hybriel plugins and runtime to day44mre
- cef81394Wait for the DST fixture page instead of an unused socketmre
- 42434f47Check lazy-session cookies after login with a stored anonymous fixturemre
- 728e84e3Re-vendor complete Hybriel day41 plugin directoriesmre
- cbd7ff43Backup tar: --hard-dereference, so mpackdb sidecars are never stored as hard links (Tracker's finding)mre
- 59d1da0acalendar: plain declarations instead of needless let in 9 files (calendar#17): 49 declarations that are never reassigned; reassigned ones and the timer closure's p stay letmre
- f5415cf9calendar: the Style blocks in the language's nested form (calendar#16): rules named after the View's own elements with their children nested, pseudo-classes and @media nested, merged duplicate select rule; same CSS, shots identical in Chrome at 4 sizesmre
- edb7c947calendar: the sign-in callback keeps the session it finds and signs it in (same cookie, nothing signed out; ident#28); security gate 56+4 failing → 60 passedmre
- bf8cc0fcStyles move into their components: the shell's styles into main.hl, the events and the editors into the month view's Style block; styles.hl keeps only the theme inherit, the accent and the message line; .gitignore ignores a bin symlink too; tests/styles-shots.mjs for the before/after pixel comparemre