@rdlabo/ionic-angular-kit 22.0.5 → 22.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/auth-http.md +21 -0
- package/docs/offline-realtime.md +47 -0
- package/fesm2022/rdlabo-ionic-angular-kit-offline-storage-generation.mjs +16 -0
- package/fesm2022/rdlabo-ionic-angular-kit-offline-storage-generation.mjs.map +1 -0
- package/fesm2022/rdlabo-ionic-angular-kit-offline.mjs +169 -10
- package/fesm2022/rdlabo-ionic-angular-kit-offline.mjs.map +1 -1
- package/fesm2022/rdlabo-ionic-angular-kit.mjs +11 -3
- package/fesm2022/rdlabo-ionic-angular-kit.mjs.map +1 -1
- package/package.json +5 -1
- package/types/rdlabo-ionic-angular-kit-offline-storage-generation.d.ts +23 -0
- package/types/rdlabo-ionic-angular-kit-offline.d.ts +149 -94
- package/types/rdlabo-ionic-angular-kit.d.ts +9 -3
package/docs/auth-http.md
CHANGED
|
@@ -93,3 +93,24 @@ export const appConfig: ApplicationConfig = {
|
|
|
93
93
|
Automatic retry is limited to `GET`, `HEAD`, `OPTIONS`, or requests carrying an `Idempotency-Key`. Ordinary writes are never retried automatically. Retries cover transient statuses `0`, `408`, `429`, `502`, `503`, and `504`, and honor `Retry-After`.
|
|
94
94
|
|
|
95
95
|
When offline support is enabled, register `offlineInterceptor` before `kitAuthInterceptor`. Local mode then prevents credential generation and network transport while allowing a matched read policy to serve the scoped replica.
|
|
96
|
+
|
|
97
|
+
### Request-owned error notifications
|
|
98
|
+
|
|
99
|
+
`onServerError` receives the server body message for HTTP 400, 409, 422, and 500.
|
|
100
|
+
For requests whose caller displays its own error UI, set the public boolean context token
|
|
101
|
+
`KIT_SKIP_ERROR_NOTIFICATIONS` (default `false`):
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
import { HttpContext } from '@angular/common/http';
|
|
105
|
+
import { KIT_SKIP_ERROR_NOTIFICATIONS } from '@rdlabo/ionic-angular-kit';
|
|
106
|
+
|
|
107
|
+
http.post('/applications', payload, {
|
|
108
|
+
context: new HttpContext().set(KIT_SKIP_ERROR_NOTIFICATIONS, true),
|
|
109
|
+
});
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
This suppresses only response-error notification hooks: `onUnauthorized`, `onForbidden`,
|
|
113
|
+
`onNetworkError`, `onRateLimited`, `onMaintenance`, `onServerBusy`, and `onServerError`.
|
|
114
|
+
The original error still rejects to the caller. It does not bypass authentication, stop
|
|
115
|
+
401 recovery/replay, change retry or offline-fallback behavior, prevent access revocation
|
|
116
|
+
(`onAuthAccessDenial`), or suppress auth-header failures (`onAuthError`).
|
package/docs/offline-realtime.md
CHANGED
|
@@ -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,0 +1,16 @@
|
|
|
1
|
+
/** Reads the generation and durable reset intent without opening or modifying any replica. */
|
|
2
|
+
async function inspectOfflineStorageGeneration(options) {
|
|
3
|
+
const generation = typeof options.generation === 'string' ? options.generation : await options.generation();
|
|
4
|
+
const [stored, marker] = await Promise.all([
|
|
5
|
+
options.markerStore.get({ key: options.generationKey }),
|
|
6
|
+
options.markerStore.get({ key: options.markerKey }),
|
|
7
|
+
]);
|
|
8
|
+
return { generation, matches: stored.value === generation, requested: marker.value === 'requested' };
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Generated bundle index. Do not edit.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export { inspectOfflineStorageGeneration };
|
|
16
|
+
//# sourceMappingURL=rdlabo-ionic-angular-kit-offline-storage-generation.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rdlabo-ionic-angular-kit-offline-storage-generation.mjs","sources":["../../../projects/kit/offline/storage-generation/src/public-api.ts","../../../projects/kit/offline/storage-generation/src/rdlabo-ionic-angular-kit-offline-storage-generation.ts"],"sourcesContent":["/** Lightweight storage marker inspection with no Angular, SQLite, or replica-runtime imports. @experimental */\n/** Persistent identity of an explicitly disposable local replica, independent of the wire protocol. */\nexport interface OfflineStorageGenerationOptions {\n markerStore: { get(options: { key: string }): Promise<{ value: string | null }> };\n generationKey: string;\n markerKey: string;\n generation: string | (() => Promise<string>);\n}\n\n/** Reads the generation and durable reset intent without opening or modifying any replica. */\nexport async function inspectOfflineStorageGeneration(\n options: OfflineStorageGenerationOptions,\n): Promise<{ generation: string; matches: boolean; requested: boolean }> {\n const generation = typeof options.generation === 'string' ? options.generation : await options.generation();\n const [stored, marker] = await Promise.all([\n options.markerStore.get({ key: options.generationKey }),\n options.markerStore.get({ key: options.markerKey }),\n ]);\n return { generation, matches: stored.value === generation, requested: marker.value === 'requested' };\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"AASA;AACO,eAAe,+BAA+B,CACnD,OAAwC,EAAA;IAExC,MAAM,UAAU,GAAG,OAAO,OAAO,CAAC,UAAU,KAAK,QAAQ,GAAG,OAAO,CAAC,UAAU,GAAG,MAAM,OAAO,CAAC,UAAU,EAAE;IAC3G,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;AACzC,QAAA,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC;AACvD,QAAA,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC;AACpD,KAAA,CAAC;AACF,IAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,CAAC,KAAK,KAAK,UAAU,EAAE,SAAS,EAAE,MAAM,CAAC,KAAK,KAAK,WAAW,EAAE;AACtG;;ACnBA;;AAEG;;;;"}
|
|
@@ -8,6 +8,8 @@ import { App } from '@capacitor/app';
|
|
|
8
8
|
import { Network } from '@capacitor/network';
|
|
9
9
|
import { firstValueFrom, timeout, map, catchError, of, defer, from, concatMap, EMPTY, throwError, materialize, connect, concat, ReplaySubject, filter, NEVER, race, take, Observable, dematerialize, tap } from 'rxjs';
|
|
10
10
|
import { Capacitor } from '@capacitor/core';
|
|
11
|
+
import { inspectOfflineStorageGeneration } from '@rdlabo/ionic-angular-kit/offline/storage-generation';
|
|
12
|
+
export * from '@rdlabo/ionic-angular-kit/offline/storage-generation';
|
|
11
13
|
|
|
12
14
|
const MAX_OFFLINE_NATURAL_KEY_TEXT_BYTES = 1024;
|
|
13
15
|
const IDENTIFIER_PATTERN = /^[a-z][a-z0-9_]*$/;
|
|
@@ -1041,7 +1043,7 @@ class IonicOfflineRepository {
|
|
|
1041
1043
|
#rowIndexBuild = null;
|
|
1042
1044
|
initialize() {
|
|
1043
1045
|
if (!this.#initialization) {
|
|
1044
|
-
this.#initialization = this.#migrate().catch((error) => {
|
|
1046
|
+
this.#initialization = this.#withStorageLifecycle('exclusive', () => this.#migrate()).catch((error) => {
|
|
1045
1047
|
this.#initialization = null;
|
|
1046
1048
|
throw error;
|
|
1047
1049
|
});
|
|
@@ -1206,7 +1208,7 @@ class IonicOfflineRepository {
|
|
|
1206
1208
|
await this.#writes;
|
|
1207
1209
|
this.#beginReaders();
|
|
1208
1210
|
const read = async () => operation();
|
|
1209
|
-
return read
|
|
1211
|
+
return this.#withStorageLifecycle('shared', read).finally(() => this.#endReaders());
|
|
1210
1212
|
}
|
|
1211
1213
|
#beginReaders() {
|
|
1212
1214
|
if (this.#activeReaders === 0) {
|
|
@@ -1444,7 +1446,8 @@ class IonicOfflineRepository {
|
|
|
1444
1446
|
});
|
|
1445
1447
|
throw error;
|
|
1446
1448
|
});
|
|
1447
|
-
|
|
1449
|
+
// Initialization already holds the lifecycle lock; Web Locks are not reentrant.
|
|
1450
|
+
}, false);
|
|
1448
1451
|
}
|
|
1449
1452
|
#toWebMigrationRow(row) {
|
|
1450
1453
|
return {
|
|
@@ -1631,11 +1634,14 @@ class IonicOfflineRepository {
|
|
|
1631
1634
|
const record = await this.#readRecord(key);
|
|
1632
1635
|
await this.#storage.set(key, mutate(record));
|
|
1633
1636
|
}
|
|
1634
|
-
#
|
|
1637
|
+
#withStorageLifecycle(mode, operation) {
|
|
1638
|
+
return this.#options.storageLifecycle ? this.#options.storageLifecycle.run(mode, operation) : operation();
|
|
1639
|
+
}
|
|
1640
|
+
#enqueueWrite(operation, guard = true) {
|
|
1635
1641
|
const write = this.#writes.then(async () => {
|
|
1636
1642
|
if (this.#activeReaders > 0)
|
|
1637
1643
|
await this.#readersIdle;
|
|
1638
|
-
return operation();
|
|
1644
|
+
return guard ? this.#withStorageLifecycle('exclusive', operation) : operation();
|
|
1639
1645
|
});
|
|
1640
1646
|
this.#writes = write.then(() => undefined, () => undefined);
|
|
1641
1647
|
return write;
|
|
@@ -5530,7 +5536,7 @@ async function recoverOfflineLocalReset(options) {
|
|
|
5530
5536
|
const marker = await options.markerStore.get({ key: options.markerKey });
|
|
5531
5537
|
if (marker.value !== OFFLINE_LOCAL_RESET_REQUESTED)
|
|
5532
5538
|
return false;
|
|
5533
|
-
await
|
|
5539
|
+
await clearOfflineLocalDatabases({
|
|
5534
5540
|
sqliteConnection: options.sqliteConnection,
|
|
5535
5541
|
databaseNames: options.kitCompatibleDatabaseNames,
|
|
5536
5542
|
databaseEncryption: options.databaseEncryption ?? COMMUNITY_SQLITE_ENCRYPTED,
|
|
@@ -5552,7 +5558,7 @@ async function migrateOfflineDatabaseEncryption(options) {
|
|
|
5552
5558
|
const marker = await options.markerStore.get({ key: options.markerKey });
|
|
5553
5559
|
if (marker.value === options.migrationVersion)
|
|
5554
5560
|
return false;
|
|
5555
|
-
await
|
|
5561
|
+
await clearOfflineLocalDatabases({
|
|
5556
5562
|
sqliteConnection: options.sqliteConnection,
|
|
5557
5563
|
databaseNames: options.kitCompatibleDatabaseNames,
|
|
5558
5564
|
databaseEncryption: options.sourceDatabaseEncryption,
|
|
@@ -5567,7 +5573,8 @@ async function migrateOfflineDatabaseEncryption(options) {
|
|
|
5567
5573
|
await options.markerStore.set({ key: options.markerKey, value: options.migrationVersion });
|
|
5568
5574
|
return true;
|
|
5569
5575
|
}
|
|
5570
|
-
|
|
5576
|
+
/** Deletes only explicitly configured databases and files; leaves markers and authentication untouched. */
|
|
5577
|
+
async function clearOfflineLocalDatabases(options) {
|
|
5571
5578
|
await options.sqliteConnection.checkConnectionsConsistency();
|
|
5572
5579
|
for (const databaseName of new Set(options.databaseNames)) {
|
|
5573
5580
|
const exists = await options.sqliteConnection.isDatabase(databaseName);
|
|
@@ -5609,6 +5616,154 @@ async function deleteAndCloseOfflineDatabase(sqliteConnection, databaseName, con
|
|
|
5609
5616
|
throw closing.error;
|
|
5610
5617
|
}
|
|
5611
5618
|
|
|
5619
|
+
/** A different runtime has rebuilt this storage. Reload before using the local replica again. */
|
|
5620
|
+
class OfflineStorageGenerationChangedError extends Error {
|
|
5621
|
+
constructor() {
|
|
5622
|
+
super('Offline storage changed in another runtime. Reload the application before using the local replica.');
|
|
5623
|
+
this.name = 'OfflineStorageGenerationChangedError';
|
|
5624
|
+
}
|
|
5625
|
+
}
|
|
5626
|
+
const nativeOperations = new WeakMap();
|
|
5627
|
+
/**
|
|
5628
|
+
* Opt-in lifecycle for disposable local replicas. Never infer a reset from a network, auth,
|
|
5629
|
+
* wire-protocol or generic storage error. Use one instance for preparation and repository access.
|
|
5630
|
+
*/
|
|
5631
|
+
class OfflineStorageLifecycle {
|
|
5632
|
+
#preparation = null;
|
|
5633
|
+
#generation = null;
|
|
5634
|
+
#revision = null;
|
|
5635
|
+
constructor(options) {
|
|
5636
|
+
this.options = options;
|
|
5637
|
+
if (options.discardPendingCommands !== true)
|
|
5638
|
+
throw new Error('Storage rebuild requires explicit permission to discard pending commands.');
|
|
5639
|
+
}
|
|
5640
|
+
/** Prepares storage once, before the repository is opened; failed attempts remain retryable. */
|
|
5641
|
+
prepare() {
|
|
5642
|
+
this.#preparation ??= this.#lock('exclusive', () => this.#prepare()).then((result) => {
|
|
5643
|
+
if (result === 'reload-required')
|
|
5644
|
+
this.#preparation = null;
|
|
5645
|
+
return result;
|
|
5646
|
+
}, (error) => {
|
|
5647
|
+
this.#preparation = null;
|
|
5648
|
+
throw error;
|
|
5649
|
+
});
|
|
5650
|
+
return this.#preparation;
|
|
5651
|
+
}
|
|
5652
|
+
/**
|
|
5653
|
+
* Holds the same Web Lock used for reset throughout one repository operation.
|
|
5654
|
+
* A stale runtime fails before it can read or write the newly rebuilt storage.
|
|
5655
|
+
*/
|
|
5656
|
+
async run(mode, operation) {
|
|
5657
|
+
if ((await this.prepare()) === 'reload-required')
|
|
5658
|
+
throw new Error('Offline storage requires a cold reload before opening.');
|
|
5659
|
+
return this.#lock(mode, async () => {
|
|
5660
|
+
const state = await inspectOfflineStorageGeneration({ ...this.options, generation: this.#generation });
|
|
5661
|
+
const revision = await this.options.markerStore.get({ key: this.#revisionKey });
|
|
5662
|
+
if (!state.matches || state.requested || state.generation !== this.#generation || revision.value !== this.#revision) {
|
|
5663
|
+
throw new OfflineStorageGenerationChangedError();
|
|
5664
|
+
}
|
|
5665
|
+
return operation();
|
|
5666
|
+
});
|
|
5667
|
+
}
|
|
5668
|
+
/** Waits for product readiness, rechecks the state, persists intent, then requests a cold reload. */
|
|
5669
|
+
async requestRebuildAfterBootstrap(waitUntilReady, reloadTarget) {
|
|
5670
|
+
const state = await inspectOfflineStorageGeneration(this.options);
|
|
5671
|
+
if (state.matches && !state.requested)
|
|
5672
|
+
return false;
|
|
5673
|
+
await waitUntilReady();
|
|
5674
|
+
const requested = await this.#lock('exclusive', async () => {
|
|
5675
|
+
const current = await inspectOfflineStorageGeneration(this.options);
|
|
5676
|
+
if (current.matches && !current.requested)
|
|
5677
|
+
return false;
|
|
5678
|
+
if (!current.requested)
|
|
5679
|
+
await this.options.markerStore.set({ key: this.options.markerKey, value: 'requested' });
|
|
5680
|
+
return true;
|
|
5681
|
+
});
|
|
5682
|
+
if (requested)
|
|
5683
|
+
reloadTarget.reload();
|
|
5684
|
+
return requested;
|
|
5685
|
+
}
|
|
5686
|
+
get #revisionKey() {
|
|
5687
|
+
return `${this.options.generationKey}:revision`;
|
|
5688
|
+
}
|
|
5689
|
+
async #prepare() {
|
|
5690
|
+
const options = this.options;
|
|
5691
|
+
const state = await inspectOfflineStorageGeneration(options);
|
|
5692
|
+
this.#generation = state.generation;
|
|
5693
|
+
if (state.matches && !state.requested) {
|
|
5694
|
+
this.#revision = (await options.markerStore.get({ key: this.#revisionKey })).value;
|
|
5695
|
+
return 'ready';
|
|
5696
|
+
}
|
|
5697
|
+
if (!state.requested && options.rebuild === 'after-reload') {
|
|
5698
|
+
if (await this.#hasStorage())
|
|
5699
|
+
return 'reload-required';
|
|
5700
|
+
// Database absence does not imply product-owned media is absent as well.
|
|
5701
|
+
const cleanup = options.target.kind === 'sqlite' ? options.target.additionalCleanup : undefined;
|
|
5702
|
+
if (cleanup) {
|
|
5703
|
+
await options.beforeCleanup?.();
|
|
5704
|
+
await options.markerStore.set({ key: options.markerKey, value: 'requested' });
|
|
5705
|
+
await cleanup();
|
|
5706
|
+
}
|
|
5707
|
+
await options.markerStore.set({ key: options.generationKey, value: state.generation });
|
|
5708
|
+
if (cleanup)
|
|
5709
|
+
await options.markerStore.remove({ key: options.markerKey });
|
|
5710
|
+
this.#revision = (await options.markerStore.get({ key: this.#revisionKey })).value;
|
|
5711
|
+
return 'ready';
|
|
5712
|
+
}
|
|
5713
|
+
await options.beforeCleanup?.();
|
|
5714
|
+
if (!state.requested)
|
|
5715
|
+
await options.markerStore.set({ key: options.markerKey, value: 'requested' });
|
|
5716
|
+
if (options.target.kind === 'sqlite') {
|
|
5717
|
+
await clearOfflineLocalDatabases(options.target);
|
|
5718
|
+
}
|
|
5719
|
+
else {
|
|
5720
|
+
const keys = (await options.target.storage.keys()).filter((key) => key.startsWith('offline:'));
|
|
5721
|
+
for (const key of keys)
|
|
5722
|
+
await options.target.storage.remove(key);
|
|
5723
|
+
}
|
|
5724
|
+
// Keep the reset intent until *all* completion writes succeed. A crash retries cleanup.
|
|
5725
|
+
const revision = options.target.kind === 'web' ? crypto.randomUUID() : null;
|
|
5726
|
+
if (revision !== null)
|
|
5727
|
+
await options.markerStore.set({ key: this.#revisionKey, value: revision });
|
|
5728
|
+
await options.markerStore.set({ key: options.generationKey, value: state.generation });
|
|
5729
|
+
await options.markerStore.remove({ key: options.markerKey });
|
|
5730
|
+
this.#revision = revision;
|
|
5731
|
+
return 'rebuilt';
|
|
5732
|
+
}
|
|
5733
|
+
async #hasStorage() {
|
|
5734
|
+
const target = this.options.target;
|
|
5735
|
+
if (target.kind === 'web')
|
|
5736
|
+
return (await target.storage.keys()).some((key) => key.startsWith('offline:'));
|
|
5737
|
+
await target.sqliteConnection.checkConnectionsConsistency();
|
|
5738
|
+
const databases = await Promise.all(target.databaseNames.map((name) => target.sqliteConnection.isDatabase(name)));
|
|
5739
|
+
return databases.some(({ result }) => result === true);
|
|
5740
|
+
}
|
|
5741
|
+
async #lock(mode, operation) {
|
|
5742
|
+
if (this.options.target.kind === 'sqlite') {
|
|
5743
|
+
let operations = nativeOperations.get(this.options.markerStore);
|
|
5744
|
+
if (!operations) {
|
|
5745
|
+
operations = new Map();
|
|
5746
|
+
nativeOperations.set(this.options.markerStore, operations);
|
|
5747
|
+
}
|
|
5748
|
+
const key = this.options.generationKey;
|
|
5749
|
+
const previous = operations.get(key);
|
|
5750
|
+
const result = previous ? previous.then(operation) : operation();
|
|
5751
|
+
const settled = result.then(() => undefined, () => undefined);
|
|
5752
|
+
operations.set(key, settled);
|
|
5753
|
+
void settled.then(() => {
|
|
5754
|
+
if (operations.get(key) === settled)
|
|
5755
|
+
operations.delete(key);
|
|
5756
|
+
});
|
|
5757
|
+
return result;
|
|
5758
|
+
}
|
|
5759
|
+
const locks = this.options.target.locks ?? globalThis.navigator?.locks;
|
|
5760
|
+
if (!locks)
|
|
5761
|
+
return Promise.reject(new Error('Web Locks are required to safely rebuild shared offline storage.'));
|
|
5762
|
+
// One origin-wide lock matches the existing shared `offline:` namespace, even across products.
|
|
5763
|
+
return await locks.request('kit:offline:storage', { mode }, operation);
|
|
5764
|
+
}
|
|
5765
|
+
}
|
|
5766
|
+
|
|
5612
5767
|
/**
|
|
5613
5768
|
* A successful HTTP response that violates the offline mutation protocol.
|
|
5614
5769
|
*
|
|
@@ -6093,7 +6248,9 @@ class SqliteOfflineRepository {
|
|
|
6093
6248
|
#atomicIdle = settledSqliteOperation();
|
|
6094
6249
|
#resolveAtomicIdle = null;
|
|
6095
6250
|
initialize() {
|
|
6096
|
-
this.#initialization ??= this.#
|
|
6251
|
+
this.#initialization ??= this.#options.storageLifecycle
|
|
6252
|
+
? this.#options.storageLifecycle.run('exclusive', () => this.#open())
|
|
6253
|
+
: this.#open();
|
|
6097
6254
|
return this.#initialization;
|
|
6098
6255
|
}
|
|
6099
6256
|
async getLastUserId() {
|
|
@@ -7227,6 +7384,7 @@ function offlineConfigurationProviders(options) {
|
|
|
7227
7384
|
createEncryptionKey: options.createEncryptionKey,
|
|
7228
7385
|
replicaSchema: options.replicaSchema,
|
|
7229
7386
|
wireProtocol: options.wireProtocol,
|
|
7387
|
+
storageLifecycle: options.storageLifecycle,
|
|
7230
7388
|
outboxLimits: options.outboxLimits,
|
|
7231
7389
|
mutationPersistence: options.mutationPersistence,
|
|
7232
7390
|
onStorageUnavailable: options.onStorageUnavailable,
|
|
@@ -7238,6 +7396,7 @@ function offlineConfigurationProviders(options) {
|
|
|
7238
7396
|
createEncryptionKey: options.createEncryptionKey,
|
|
7239
7397
|
replicaSchema: options.replicaSchema,
|
|
7240
7398
|
wireProtocol: options.wireProtocol,
|
|
7399
|
+
storageLifecycle: options.storageLifecycle,
|
|
7241
7400
|
outboxLimits: options.outboxLimits,
|
|
7242
7401
|
mutationPersistence: options.mutationPersistence,
|
|
7243
7402
|
onStorageUnavailable: options.onStorageUnavailable,
|
|
@@ -7307,5 +7466,5 @@ function assertSupportedOfflineMode(platform, mode) {
|
|
|
7307
7466
|
* Generated bundle index. Do not edit.
|
|
7308
7467
|
*/
|
|
7309
7468
|
|
|
7310
|
-
export { COMMUNITY_SQLITE, DEFAULT_OFFLINE_COMMAND_HOOKS, DEFAULT_OFFLINE_CONNECTION_VERIFICATION_TIMEOUT_MS, IonicOfflineRepository, OFFLINE_AGGREGATE_INTENT_PROJECTOR, OFFLINE_BYPASS, OFFLINE_COMMAND_EXECUTOR, OFFLINE_COMMAND_HOOKS, OFFLINE_IGNORE_TRANSPORT_FAILURE, OFFLINE_KIT_OPTIONS, OFFLINE_MUTATION_REQUEST_POLICIES, OFFLINE_REPLICA_PROJECTOR, OFFLINE_REPLICA_PULLER, OFFLINE_REPOSITORY, OFFLINE_REQUEST_POLICIES, OFFLINE_RESPONSE_COMPLETE_HEADER, OFFLINE_RESPONSE_HEADER, OFFLINE_RETRY_RANDOM, OFFLINE_SCHEMA_VERSION, OFFLINE_SYNC_CONTEXT, OfflineCommandInFlightError, OfflineCoordinatorService, OfflineImmediateCommandRejectedError, OfflineMutationPersistenceDisabledError, OfflineMutationPersistencePendingError, OfflineMutationPersistenceRequiresOnlineError, OfflineMutationPersistenceService, OfflineMutationPolicyConflictError, OfflineMutationProtocolError, OfflineMutationRequestPolicyRegistry, OfflineNetworkService, OfflineOutboxCapacityError, OfflinePayloadValidationError, OfflineReplicaMutationCoordinator, OfflineReplicaPullService, OfflineReplicaSchemaMismatchError, OfflineRequestFallbackService, OfflineRequestPolicyRegistry, OfflineRouteInitializerService, OfflineSessionService, OfflineStorageUnavailableError, OfflineSyncService, SqliteOfflineRepository, assertOfflineLocalId, assertOfflineReplicaGeneratedRemoteId, assertOfflineReplicaNaturalKeyBaseline, assertSupportedOfflineMode, booleanColumn, canonicalOfflineCommandIdentity, canonicalOfflinePrincipalId, canonicalOfflineRemoteIdentity, canonicalOfflineReplicaIdentity, canonicalOfflineReplicaRowKey, commandFootprintKeys, commandIdentityFromReplicaIdentity, commandIdentityMatchesReplicaRow, createCommunitySqliteDriver, createOfflineAuthBridge, createRandomOfflineEncryptionKey, datetime, decodeOfflineReplicaValues, defineOfflineReplicaSchema, defineReplicaEntity, encodeOfflineReplicaValues, generatedId, ignored, integer, isOfflineAggregateIntentConflict, isOfflineFallbackError, isOfflineStorageUnavailableError, json, localOnly, migrateOfflineDatabaseEncryption, naturalKey, normalizeOfflineNaturalKey, normalizeOfflineReplicaPullPage, nullable, offlineAggregateIntentMutations, offlineCommandLookupIdentity, offlineCommandTargetFromReplicaRow, offlineCommandWithBaseRevision, offlineGeneratedReplicaIdentity, offlineInterceptor, offlineNaturalKeyFromValues, offlineNaturalReplicaIdentity, offlineReadEmission, offlineReadSource, offlineReplicaRemoteIdentity, offlineRetryDelayMs, offlineSessionManifestAllows, parseOfflineCommandIdentity, parseOfflineMutationEnvelope, parseOfflinePrincipalId, projectOfflineReplicaValues, provideOffline, provideOfflineMutationRequestPolicy, provideOfflineRequestPolicy, provideRouteScopedOffline, real, recoverOfflineLocalReset, replicaAddressFromIdentity, requestOfflineLocalReset, requirePositiveOfflineInteger, selectOfflineRepository, serializeOfflineCommandIdentity, sha256OfflineReplicaSchema, shouldCommitOfflineCollection, supportsSynchronizedOfflineRepository, text };
|
|
7469
|
+
export { COMMUNITY_SQLITE, DEFAULT_OFFLINE_COMMAND_HOOKS, DEFAULT_OFFLINE_CONNECTION_VERIFICATION_TIMEOUT_MS, IonicOfflineRepository, OFFLINE_AGGREGATE_INTENT_PROJECTOR, OFFLINE_BYPASS, OFFLINE_COMMAND_EXECUTOR, OFFLINE_COMMAND_HOOKS, OFFLINE_IGNORE_TRANSPORT_FAILURE, OFFLINE_KIT_OPTIONS, OFFLINE_MUTATION_REQUEST_POLICIES, OFFLINE_REPLICA_PROJECTOR, OFFLINE_REPLICA_PULLER, OFFLINE_REPOSITORY, OFFLINE_REQUEST_POLICIES, OFFLINE_RESPONSE_COMPLETE_HEADER, OFFLINE_RESPONSE_HEADER, OFFLINE_RETRY_RANDOM, OFFLINE_SCHEMA_VERSION, OFFLINE_SYNC_CONTEXT, OfflineCommandInFlightError, OfflineCoordinatorService, OfflineImmediateCommandRejectedError, OfflineMutationPersistenceDisabledError, OfflineMutationPersistencePendingError, OfflineMutationPersistenceRequiresOnlineError, OfflineMutationPersistenceService, OfflineMutationPolicyConflictError, OfflineMutationProtocolError, OfflineMutationRequestPolicyRegistry, OfflineNetworkService, OfflineOutboxCapacityError, OfflinePayloadValidationError, OfflineReplicaMutationCoordinator, OfflineReplicaPullService, OfflineReplicaSchemaMismatchError, OfflineRequestFallbackService, OfflineRequestPolicyRegistry, OfflineRouteInitializerService, OfflineSessionService, OfflineStorageGenerationChangedError, OfflineStorageLifecycle, OfflineStorageUnavailableError, OfflineSyncService, SqliteOfflineRepository, assertOfflineLocalId, assertOfflineReplicaGeneratedRemoteId, assertOfflineReplicaNaturalKeyBaseline, assertSupportedOfflineMode, booleanColumn, canonicalOfflineCommandIdentity, canonicalOfflinePrincipalId, canonicalOfflineRemoteIdentity, canonicalOfflineReplicaIdentity, canonicalOfflineReplicaRowKey, clearOfflineLocalDatabases, commandFootprintKeys, commandIdentityFromReplicaIdentity, commandIdentityMatchesReplicaRow, createCommunitySqliteDriver, createOfflineAuthBridge, createRandomOfflineEncryptionKey, datetime, decodeOfflineReplicaValues, defineOfflineReplicaSchema, defineReplicaEntity, encodeOfflineReplicaValues, generatedId, ignored, integer, isOfflineAggregateIntentConflict, isOfflineFallbackError, isOfflineStorageUnavailableError, json, localOnly, migrateOfflineDatabaseEncryption, naturalKey, normalizeOfflineNaturalKey, normalizeOfflineReplicaPullPage, nullable, offlineAggregateIntentMutations, offlineCommandLookupIdentity, offlineCommandTargetFromReplicaRow, offlineCommandWithBaseRevision, offlineGeneratedReplicaIdentity, offlineInterceptor, offlineNaturalKeyFromValues, offlineNaturalReplicaIdentity, offlineReadEmission, offlineReadSource, offlineReplicaRemoteIdentity, offlineRetryDelayMs, offlineSessionManifestAllows, parseOfflineCommandIdentity, parseOfflineMutationEnvelope, parseOfflinePrincipalId, projectOfflineReplicaValues, provideOffline, provideOfflineMutationRequestPolicy, provideOfflineRequestPolicy, provideRouteScopedOffline, real, recoverOfflineLocalReset, replicaAddressFromIdentity, requestOfflineLocalReset, requirePositiveOfflineInteger, selectOfflineRepository, serializeOfflineCommandIdentity, sha256OfflineReplicaSchema, shouldCommitOfflineCollection, supportsSynchronizedOfflineRepository, text };
|
|
7311
7470
|
//# sourceMappingURL=rdlabo-ionic-angular-kit-offline.mjs.map
|