You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 60bb699
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: projects/kit/docs/offline-realtime.md
+47Lines changed: 47 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -221,3 +221,50 @@ credential exchange is still pending.
221
221
Subclass `KitRealtimeConnection` to supply connection intent and `{ url, protocols }` targets. The kit owns foreground and network suspension, target-scoped reconnect, exponential backoff, ping/pong detection, self-echo annotation, and `reconnected$` resync signaling.
222
222
223
223
Use `kitRealtimeProtocols()` to carry authentication and the stable `KIT_REALTIME_CLIENT_ID` in WebSocket subprotocols instead of URL parameters. Offline-capable authenticated clients set `requireRemoteAccess: true`; sockets then remain closed in `none` and `local` modes.
224
+
225
+
## Disposable storage generations
226
+
227
+
`OfflineStorageLifecycle` is an explicit alternative to retaining incremental local data migrations.
228
+
It does not change the wire protocol and never resets storage in response to a generic error.
229
+
Products must opt in with `discardPendingCommands: true`: the entire configured replica, cursors,
230
+
local snapshots and unsent Outbox are disposable. Authentication and unrelated preferences remain
231
+
outside the cleanup targets. Repopulation requires connectivity.
232
+
233
+
Create one lifecycle instance for bootstrap and pass that same instance as `storageLifecycle` to
234
+
`provideOffline` / `provideRouteScopedOffline`. Await `prepare()` before constructing product
235
+
services that open the database. Kit also gates repository initialization through this instance.
236
+
`reload-required` is not permission to open the repository: render the product's reset/update UI,
237
+
call `requestRebuildAfterBootstrap(waitUntilReady, location)`, and resume only after a cold restart.
238
+
The `beforeCleanup` hook can acknowledge Live Update readiness before slow native file deletion.
239
+
Kit does not depend on the Live Update plugin or supply product messages/navigation.
240
+
241
+
The lightweight `@rdlabo/ionic-angular-kit/offline/storage-generation` entry point exports
242
+
`inspectOfflineStorageGeneration` for startup guards without eagerly loading the offline runtime.
243
+
Generation values and marker keys are product-owned. SeatKeep keeps its
244
+
`OFFLINE_SCHEMA_VERSION:schemaHash` identity; Winecode keeps generation `4` and its existing keys.
245
+
Matching markers are accepted without deleting data or forcing a migration-only reset. Local
246
+
schema changes must change the configured generation; they must not change `wireProtocol` unless
247
+
the server contract itself is incompatible. Retaining an explicit numeric generation requires the
248
+
product to bump it when its local storage shape changes.
249
+
250
+
Native targets list only databases compatible with the existing reset connection lifecycle;
251
+
`additionalCleanup` owns other databases/media files. A pending reset survives deletion failure,
252
+
completion-marker failure, and interrupted cleanup. Completion is recorded only after all cleanup
253
+
succeeds. Deferred mode can adopt a fresh installation without reloading when no target DB exists.
254
+
Existing manual reset and encryption-migration APIs remain available and retain their behavior.
255
+
256
+
Web targets require Web Locks (secure context). All cooperating runtimes use one origin-wide lock
257
+
for the existing `offline:` namespace: preparation and writes are exclusive, reads are shared.
258
+
The repository validates the generation and a reset revision within the lock. A stale runtime throws
259
+
`OfflineStorageGenerationChangedError` before touching rebuilt data, including after a manual reset
260
+
of the same generation. The product should reload that runtime. Absence of Web Locks fails before
261
+
any deletion; there is no unsafe per-tab fallback. Already shipped clients without this protocol
262
+
cannot be fenced by the new library; replacing/reloading old tabs is necessary during rollout.
263
+
264
+
Validation commands:
265
+
266
+
-`npm test -- --project kit --include='../offline/src/lib/offline-storage-lifecycle.spec.ts'`
267
+
-`npm run test:storage-lifecycle:browser` (headless Chromium, two pages of the same origin)
268
+
269
+
The browser test runs the actual lifecycle with Web Locks and a small localStorage adapter. Repository
270
+
integration tests separately cover the KitStorageService boundary and stale repository reads/writes.
0 commit comments