@rdlabo/ionic-angular-kit 22.0.0-beta.pr101.shae60a7d066900 → 22.0.0-beta.pr102.sha1c53fd4f57fa
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/README.md +26 -20
- package/docs/offline-realtime.md +116 -1
- package/docs/optional-features.md +23 -4
- package/docs/storage-overlays.md +21 -10
- package/fesm2022/rdlabo-ionic-angular-kit-app-update.mjs +108 -16
- package/fesm2022/rdlabo-ionic-angular-kit-app-update.mjs.map +1 -1
- package/fesm2022/rdlabo-ionic-angular-kit-offline.mjs +42 -7
- package/fesm2022/rdlabo-ionic-angular-kit-offline.mjs.map +1 -1
- package/fesm2022/rdlabo-ionic-angular-kit.mjs +19 -0
- package/fesm2022/rdlabo-ionic-angular-kit.mjs.map +1 -1
- package/package.json +1 -1
- package/types/rdlabo-ionic-angular-kit-app-update.d.ts +30 -9
- package/types/rdlabo-ionic-angular-kit-offline.d.ts +11 -0
- package/types/rdlabo-ionic-angular-kit.d.ts +7 -0
|
@@ -941,22 +941,36 @@ class OfflineReplicaTransientWriteError extends Error {
|
|
|
941
941
|
this.name = 'OfflineReplicaTransientWriteError';
|
|
942
942
|
}
|
|
943
943
|
}
|
|
944
|
-
function
|
|
945
|
-
if (error instanceof OfflineReplicaTransientWriteError)
|
|
946
|
-
return error;
|
|
944
|
+
function transientSqliteLockReason(error) {
|
|
947
945
|
const code = typeof error === 'object' && error !== null && typeof error.code === 'string'
|
|
948
946
|
? error.code.toUpperCase()
|
|
949
947
|
: '';
|
|
950
948
|
const message = error instanceof Error ? error.message : typeof error === 'string' ? error : '';
|
|
951
949
|
const normalizedMessage = message.toUpperCase();
|
|
952
950
|
if (code.includes('SQLITE_BUSY') || normalizedMessage.includes('SQLITE_BUSY')) {
|
|
953
|
-
return
|
|
951
|
+
return 'sqlite_busy';
|
|
954
952
|
}
|
|
955
953
|
if (code.includes('SQLITE_LOCKED') ||
|
|
956
954
|
normalizedMessage.includes('SQLITE_LOCKED') ||
|
|
957
955
|
message.includes('database is locked') ||
|
|
958
956
|
message.includes('database table is locked')) {
|
|
959
|
-
return
|
|
957
|
+
return 'sqlite_locked';
|
|
958
|
+
}
|
|
959
|
+
return null;
|
|
960
|
+
}
|
|
961
|
+
/** Returns whether SQLite reported a transient busy/locked condition in any supported error shape. */
|
|
962
|
+
function isTransientSqliteLockError(error) {
|
|
963
|
+
return error instanceof OfflineReplicaTransientWriteError
|
|
964
|
+
? error.reason === 'sqlite_busy' || error.reason === 'sqlite_locked'
|
|
965
|
+
: transientSqliteLockReason(error) !== null;
|
|
966
|
+
}
|
|
967
|
+
function normalizeOfflineReplicaTransientWriteError(error) {
|
|
968
|
+
if (error instanceof OfflineReplicaTransientWriteError)
|
|
969
|
+
return error;
|
|
970
|
+
const reason = transientSqliteLockReason(error);
|
|
971
|
+
if (reason) {
|
|
972
|
+
const message = error instanceof Error ? error.message : typeof error === 'string' ? error : '';
|
|
973
|
+
return new OfflineReplicaTransientWriteError(reason, message || (reason === 'sqlite_busy' ? 'SQLite is busy.' : 'SQLite database is locked.'), { cause: error });
|
|
960
974
|
}
|
|
961
975
|
return error;
|
|
962
976
|
}
|
|
@@ -5771,6 +5785,7 @@ async function createRandomOfflineEncryptionKey() {
|
|
|
5771
5785
|
return Array.from(bytes, (byte) => byte.toString(16).padStart(2, '0')).join('');
|
|
5772
5786
|
}
|
|
5773
5787
|
const settledSqliteOperation = async () => undefined;
|
|
5788
|
+
const COMMUNITY_SQLITE_OPEN_RETRY_DELAYS_MS = [50, 150, 300];
|
|
5774
5789
|
const communitySqliteDrivers = new WeakMap();
|
|
5775
5790
|
function sqliteErrorMessage(error) {
|
|
5776
5791
|
if (error instanceof Error)
|
|
@@ -5780,6 +5795,17 @@ function sqliteErrorMessage(error) {
|
|
|
5780
5795
|
}
|
|
5781
5796
|
return String(error);
|
|
5782
5797
|
}
|
|
5798
|
+
async function openCommunitySqliteDatabase(database) {
|
|
5799
|
+
for (const delayMs of COMMUNITY_SQLITE_OPEN_RETRY_DELAYS_MS) {
|
|
5800
|
+
const result = await database.open().then(() => ({ ok: true }), (error) => ({ ok: false, error }));
|
|
5801
|
+
if (result.ok)
|
|
5802
|
+
return;
|
|
5803
|
+
if (!isTransientSqliteLockError(result.error))
|
|
5804
|
+
throw result.error;
|
|
5805
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
5806
|
+
}
|
|
5807
|
+
await database.open();
|
|
5808
|
+
}
|
|
5783
5809
|
function normalizeCommunitySqliteDatabaseName(database) {
|
|
5784
5810
|
return database.endsWith('.db') ? database.slice(0, -3) : database;
|
|
5785
5811
|
}
|
|
@@ -5862,7 +5888,7 @@ function createCommunitySqliteDriver(connection, encrypted = COMMUNITY_SQLITE_EN
|
|
|
5862
5888
|
const opening = (async () => {
|
|
5863
5889
|
await ensureSecret(createEncryptionKey);
|
|
5864
5890
|
const value = await createReloadSafeCommunitySqliteDatabase(connection, databaseName, encrypted);
|
|
5865
|
-
await value
|
|
5891
|
+
await openCommunitySqliteDatabase(value);
|
|
5866
5892
|
databases.set(databaseKey, value);
|
|
5867
5893
|
return value;
|
|
5868
5894
|
})();
|
|
@@ -7189,7 +7215,16 @@ function assertSupportedOfflineMode(platform, mode) {
|
|
|
7189
7215
|
}
|
|
7190
7216
|
}
|
|
7191
7217
|
|
|
7192
|
-
/**
|
|
7218
|
+
/**
|
|
7219
|
+
* Experimental scoped local replica and outbox runtime for offline-capable Ionic applications.
|
|
7220
|
+
*
|
|
7221
|
+
* This entry point is not covered by the package's SemVer compatibility guarantee. Its public
|
|
7222
|
+
* APIs, persistence schema, and synchronization behavior may change incompatibly in a minor or
|
|
7223
|
+
* patch release before stabilization.
|
|
7224
|
+
*
|
|
7225
|
+
* @packageDocumentation
|
|
7226
|
+
* @experimental
|
|
7227
|
+
*/
|
|
7193
7228
|
|
|
7194
7229
|
/**
|
|
7195
7230
|
* Generated bundle index. Do not edit.
|