@rdlabo/ionic-angular-kit 22.0.1-beta.pr105.sha55308d6acf67 → 22.0.2-beta.pr107.shabca274cf9d55
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 +20 -14
- package/docs/eslint.md +2 -2
- package/docs/forms.md +1 -1
- package/docs/optional-features.md +13 -1
- package/fesm2022/rdlabo-ionic-angular-kit-auth-firebase-apple.mjs +82 -0
- package/fesm2022/rdlabo-ionic-angular-kit-auth-firebase-apple.mjs.map +1 -0
- package/fesm2022/rdlabo-ionic-angular-kit-auth-firebase-facebook.mjs +69 -0
- package/fesm2022/rdlabo-ionic-angular-kit-auth-firebase-facebook.mjs.map +1 -0
- package/fesm2022/rdlabo-ionic-angular-kit-auth-firebase-google.mjs +15 -34
- package/fesm2022/rdlabo-ionic-angular-kit-auth-firebase-google.mjs.map +1 -1
- package/fesm2022/rdlabo-ionic-angular-kit-auth-firebase-internal.mjs +75 -0
- package/fesm2022/rdlabo-ionic-angular-kit-auth-firebase-internal.mjs.map +1 -0
- package/fesm2022/rdlabo-ionic-angular-kit-auth-firebase-social.mjs +9 -220
- package/fesm2022/rdlabo-ionic-angular-kit-auth-firebase-social.mjs.map +1 -1
- package/fesm2022/rdlabo-ionic-angular-kit-offline.mjs +175 -98
- package/fesm2022/rdlabo-ionic-angular-kit-offline.mjs.map +1 -1
- package/package.json +18 -6
- package/types/rdlabo-ionic-angular-kit-auth-firebase-apple.d.ts +33 -0
- package/types/rdlabo-ionic-angular-kit-auth-firebase-facebook.d.ts +29 -0
- package/types/rdlabo-ionic-angular-kit-auth-firebase-google.d.ts +10 -1
- package/types/rdlabo-ionic-angular-kit-auth-firebase-internal.d.ts +45 -0
- package/types/rdlabo-ionic-angular-kit-auth-firebase-social.d.ts +20 -102
- package/types/rdlabo-ionic-angular-kit-offline.d.ts +14 -1
|
@@ -2,12 +2,12 @@ import * as i0 from '@angular/core';
|
|
|
2
2
|
import { InjectionToken, inject, Injectable, signal, computed, ErrorHandler, effect, untracked, makeEnvironmentProviders, provideAppInitializer } from '@angular/core';
|
|
3
3
|
import { KitStorageService } from '@rdlabo/ionic-angular-kit';
|
|
4
4
|
import { toObservable } from '@angular/core/rxjs-interop';
|
|
5
|
-
import { map, distinctUntilChanged } from 'rxjs/operators';
|
|
5
|
+
import { map as map$1, distinctUntilChanged } from 'rxjs/operators';
|
|
6
|
+
import { HttpContextToken, HttpClient, HttpContext, HttpErrorResponse, HttpResponse } from '@angular/common/http';
|
|
6
7
|
import { App } from '@capacitor/app';
|
|
7
8
|
import { Network } from '@capacitor/network';
|
|
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';
|
|
8
10
|
import { Capacitor } from '@capacitor/core';
|
|
9
|
-
import { HttpErrorResponse, HttpContextToken, HttpResponse } from '@angular/common/http';
|
|
10
|
-
import { defer, from, map as map$1, concatMap, EMPTY, of, catchError, throwError, materialize, connect, concat, ReplaySubject, filter, NEVER, race, take, Observable, dematerialize, tap } from 'rxjs';
|
|
11
11
|
|
|
12
12
|
const MAX_OFFLINE_NATURAL_KEY_TEXT_BYTES = 1024;
|
|
13
13
|
const IDENTIFIER_PATTERN = /^[a-z][a-z0-9_]*$/;
|
|
@@ -941,7 +941,24 @@ class OfflineReplicaTransientWriteError extends Error {
|
|
|
941
941
|
this.name = 'OfflineReplicaTransientWriteError';
|
|
942
942
|
}
|
|
943
943
|
}
|
|
944
|
-
function transientSqliteLockReason(error) {
|
|
944
|
+
function transientSqliteLockReason(error, visited = new Set()) {
|
|
945
|
+
if (typeof error === 'object' && error !== null) {
|
|
946
|
+
if (visited.has(error))
|
|
947
|
+
return null;
|
|
948
|
+
visited.add(error);
|
|
949
|
+
}
|
|
950
|
+
if (error instanceof AggregateError) {
|
|
951
|
+
if (error.errors.length === 0)
|
|
952
|
+
return null;
|
|
953
|
+
let aggregateReason = null;
|
|
954
|
+
for (const nested of error.errors) {
|
|
955
|
+
const reason = transientSqliteLockReason(nested, new Set(visited));
|
|
956
|
+
if (!reason)
|
|
957
|
+
return null;
|
|
958
|
+
aggregateReason ??= reason;
|
|
959
|
+
}
|
|
960
|
+
return aggregateReason;
|
|
961
|
+
}
|
|
945
962
|
const code = typeof error === 'object' && error !== null && typeof error.code === 'string'
|
|
946
963
|
? error.code.toUpperCase()
|
|
947
964
|
: '';
|
|
@@ -956,6 +973,9 @@ function transientSqliteLockReason(error) {
|
|
|
956
973
|
message.includes('database table is locked')) {
|
|
957
974
|
return 'sqlite_locked';
|
|
958
975
|
}
|
|
976
|
+
if (error instanceof Error && error.cause !== undefined) {
|
|
977
|
+
return transientSqliteLockReason(error.cause, visited);
|
|
978
|
+
}
|
|
959
979
|
return null;
|
|
960
980
|
}
|
|
961
981
|
/** Returns whether SQLite reported a transient busy/locked condition in any supported error shape. */
|
|
@@ -2694,6 +2714,96 @@ function isPlainObject(value) {
|
|
|
2694
2714
|
return prototype === Object.prototype || prototype === null;
|
|
2695
2715
|
}
|
|
2696
2716
|
|
|
2717
|
+
/** outbox再送時にoffline interceptorだけを迂回する。認証・retryは維持する。 */
|
|
2718
|
+
const OFFLINE_BYPASS = new HttpContextToken(() => false);
|
|
2719
|
+
/** Lets a manual reachability probe apply its transport failure with its own observation-order guard. */
|
|
2720
|
+
const OFFLINE_IGNORE_TRANSPORT_FAILURE = new HttpContextToken(() => false);
|
|
2721
|
+
/** Header attached to synthetic local or optimistic responses. */
|
|
2722
|
+
const OFFLINE_RESPONSE_HEADER = 'X-Offline-Response';
|
|
2723
|
+
/** Header marking a local response as a complete collection snapshot. */
|
|
2724
|
+
const OFFLINE_RESPONSE_COMPLETE_HEADER = 'X-Offline-Response-Complete';
|
|
2725
|
+
/** Reads the source attached by the offline interceptor. */
|
|
2726
|
+
function offlineReadSource(response) {
|
|
2727
|
+
return response.headers.get(OFFLINE_RESPONSE_HEADER) === 'local' ? 'local' : 'remote';
|
|
2728
|
+
}
|
|
2729
|
+
/** Converts an HTTP response into the shared local-first read emission contract. */
|
|
2730
|
+
function offlineReadEmission(response, value) {
|
|
2731
|
+
const source = offlineReadSource(response);
|
|
2732
|
+
return {
|
|
2733
|
+
value,
|
|
2734
|
+
source,
|
|
2735
|
+
complete: source === 'remote' || response.headers.get(OFFLINE_RESPONSE_COMPLETE_HEADER) === 'true',
|
|
2736
|
+
};
|
|
2737
|
+
}
|
|
2738
|
+
/** Prevents an incomplete empty local collection from clearing usable UI state. */
|
|
2739
|
+
function shouldCommitOfflineCollection(emission) {
|
|
2740
|
+
return emission.source === 'remote' || emission.complete || emission.value.length > 0;
|
|
2741
|
+
}
|
|
2742
|
+
/** Multi-provider token containing product request policies. */
|
|
2743
|
+
const OFFLINE_REQUEST_POLICIES = new InjectionToken('OFFLINE_REQUEST_POLICIES', {
|
|
2744
|
+
factory: () => [],
|
|
2745
|
+
});
|
|
2746
|
+
/** Multi-provider token containing product mutation policies. */
|
|
2747
|
+
const OFFLINE_MUTATION_REQUEST_POLICIES = new InjectionToken('OFFLINE_MUTATION_REQUEST_POLICIES', { factory: () => [] });
|
|
2748
|
+
/** Registers one product request policy with the offline interceptor. */
|
|
2749
|
+
function provideOfflineRequestPolicy(policy) {
|
|
2750
|
+
return [policy, { provide: OFFLINE_REQUEST_POLICIES, useExisting: policy, multi: true }];
|
|
2751
|
+
}
|
|
2752
|
+
/** Registers one product mutation policy with the offline interceptor. */
|
|
2753
|
+
function provideOfflineMutationRequestPolicy(policy) {
|
|
2754
|
+
return [policy, { provide: OFFLINE_MUTATION_REQUEST_POLICIES, useExisting: policy, multi: true }];
|
|
2755
|
+
}
|
|
2756
|
+
/** Resolves the first product policy matching an HTTP request. */
|
|
2757
|
+
class OfflineRequestPolicyRegistry {
|
|
2758
|
+
#policies = inject(OFFLINE_REQUEST_POLICIES);
|
|
2759
|
+
resolve(request) {
|
|
2760
|
+
for (const policy of this.#policies) {
|
|
2761
|
+
const plan = policy.resolve(request);
|
|
2762
|
+
if (plan)
|
|
2763
|
+
return plan;
|
|
2764
|
+
}
|
|
2765
|
+
return null;
|
|
2766
|
+
}
|
|
2767
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: OfflineRequestPolicyRegistry, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2768
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: OfflineRequestPolicyRegistry, providedIn: 'root' }); }
|
|
2769
|
+
}
|
|
2770
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: OfflineRequestPolicyRegistry, decorators: [{
|
|
2771
|
+
type: Injectable,
|
|
2772
|
+
args: [{ providedIn: 'root' }]
|
|
2773
|
+
}] });
|
|
2774
|
+
/** Raised when more than one mutation policy claims the same request. */
|
|
2775
|
+
class OfflineMutationPolicyConflictError extends Error {
|
|
2776
|
+
constructor(request, matchCount) {
|
|
2777
|
+
super(`${matchCount} offline mutation policies matched ${request.method} ${request.urlWithParams}`);
|
|
2778
|
+
this.name = 'OfflineMutationPolicyConflictError';
|
|
2779
|
+
}
|
|
2780
|
+
}
|
|
2781
|
+
/** Resolves the only product mutation policy matching a write request. */
|
|
2782
|
+
class OfflineMutationRequestPolicyRegistry {
|
|
2783
|
+
#policies = inject(OFFLINE_MUTATION_REQUEST_POLICIES);
|
|
2784
|
+
resolve(request) {
|
|
2785
|
+
let matched = null;
|
|
2786
|
+
let matchCount = 0;
|
|
2787
|
+
for (const policy of this.#policies) {
|
|
2788
|
+
const plan = policy.resolve(request);
|
|
2789
|
+
if (!plan)
|
|
2790
|
+
continue;
|
|
2791
|
+
matched = plan;
|
|
2792
|
+
matchCount += 1;
|
|
2793
|
+
}
|
|
2794
|
+
if (matchCount > 1)
|
|
2795
|
+
throw new OfflineMutationPolicyConflictError(request, matchCount);
|
|
2796
|
+
return matched;
|
|
2797
|
+
}
|
|
2798
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: OfflineMutationRequestPolicyRegistry, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2799
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: OfflineMutationRequestPolicyRegistry, providedIn: 'root' }); }
|
|
2800
|
+
}
|
|
2801
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: OfflineMutationRequestPolicyRegistry, decorators: [{
|
|
2802
|
+
type: Injectable,
|
|
2803
|
+
args: [{ providedIn: 'root' }]
|
|
2804
|
+
}] });
|
|
2805
|
+
|
|
2806
|
+
const DEFAULT_OFFLINE_CONNECTION_VERIFICATION_TIMEOUT_MS = 8_000;
|
|
2697
2807
|
/** transport不能(status=0)だけをlocal replica fallback対象にし、HTTPエラーは隠さない。 */
|
|
2698
2808
|
function isOfflineFallbackError(error) {
|
|
2699
2809
|
return typeof error === 'object' && error !== null && error.status === 0;
|
|
@@ -2709,9 +2819,14 @@ class OfflineNetworkService {
|
|
|
2709
2819
|
...(ngDevMode ? [{ debugName: "#appActive" }] : /* istanbul ignore next */ []));
|
|
2710
2820
|
this.#lifecycleRevision = signal(0, /* @ts-ignore */
|
|
2711
2821
|
...(ngDevMode ? [{ debugName: "#lifecycleRevision" }] : /* istanbul ignore next */ []));
|
|
2822
|
+
this.#apiReachabilityRevision = 0;
|
|
2712
2823
|
this.#networkRevision = 0;
|
|
2713
2824
|
this.#listeners = [];
|
|
2714
2825
|
this.#initialized = false;
|
|
2826
|
+
this.#checkingConnection = signal(false, /* @ts-ignore */
|
|
2827
|
+
...(ngDevMode ? [{ debugName: "#checkingConnection" }] : /* istanbul ignore next */ []));
|
|
2828
|
+
this.#connectionVerification = null;
|
|
2829
|
+
this.#http = inject(HttpClient);
|
|
2715
2830
|
this.state = computed(() => {
|
|
2716
2831
|
if (this.#osConnected() === false || this.#apiReachable() === false)
|
|
2717
2832
|
return 'offline';
|
|
@@ -2726,14 +2841,20 @@ class OfflineNetworkService {
|
|
|
2726
2841
|
this.appActive = this.#appActive.asReadonly();
|
|
2727
2842
|
/** Changes on every foreground/background transition, even when connectivity is unchanged. */
|
|
2728
2843
|
this.lifecycleRevision = this.#lifecycleRevision.asReadonly();
|
|
2844
|
+
/** Whether an explicit remote API reachability check is running. */
|
|
2845
|
+
this.checkingConnection = this.#checkingConnection.asReadonly();
|
|
2729
2846
|
}
|
|
2730
2847
|
#osConnected;
|
|
2731
2848
|
#apiReachable;
|
|
2732
2849
|
#appActive;
|
|
2733
2850
|
#lifecycleRevision;
|
|
2851
|
+
#apiReachabilityRevision;
|
|
2734
2852
|
#networkRevision;
|
|
2735
2853
|
#listeners;
|
|
2736
2854
|
#initialized;
|
|
2855
|
+
#checkingConnection;
|
|
2856
|
+
#connectionVerification;
|
|
2857
|
+
#http;
|
|
2737
2858
|
async initialize() {
|
|
2738
2859
|
if (this.#initialized)
|
|
2739
2860
|
return;
|
|
@@ -2761,11 +2882,42 @@ class OfflineNetworkService {
|
|
|
2761
2882
|
this.#appActive.set(app.isActive);
|
|
2762
2883
|
}
|
|
2763
2884
|
markApiSuccess() {
|
|
2885
|
+
this.#apiReachabilityRevision += 1;
|
|
2764
2886
|
this.#apiReachable.set(true);
|
|
2765
2887
|
}
|
|
2766
2888
|
markApiFailure() {
|
|
2889
|
+
this.#apiReachabilityRevision += 1;
|
|
2767
2890
|
this.#apiReachable.set(false);
|
|
2768
2891
|
}
|
|
2892
|
+
/**
|
|
2893
|
+
* Runs one remote-only reachability check for this service instance and updates the observed API state.
|
|
2894
|
+
* While it is running, every caller shares that check; products should therefore use one stable health endpoint.
|
|
2895
|
+
*/
|
|
2896
|
+
verifyConnection(url, timeoutMs = DEFAULT_OFFLINE_CONNECTION_VERIFICATION_TIMEOUT_MS) {
|
|
2897
|
+
if (this.#connectionVerification)
|
|
2898
|
+
return this.#connectionVerification;
|
|
2899
|
+
const startingApiReachabilityRevision = this.#apiReachabilityRevision;
|
|
2900
|
+
this.#checkingConnection.set(true);
|
|
2901
|
+
const verification = firstValueFrom(this.#http
|
|
2902
|
+
.get(url, {
|
|
2903
|
+
context: new HttpContext().set(OFFLINE_BYPASS, true).set(OFFLINE_IGNORE_TRANSPORT_FAILURE, true),
|
|
2904
|
+
observe: 'response',
|
|
2905
|
+
})
|
|
2906
|
+
.pipe(timeout({ first: timeoutMs }), map(() => {
|
|
2907
|
+
this.markApiSuccess();
|
|
2908
|
+
return true;
|
|
2909
|
+
}), catchError((error) => {
|
|
2910
|
+
if (isOfflineFallbackError(error) && this.#apiReachabilityRevision === startingApiReachabilityRevision) {
|
|
2911
|
+
this.markApiFailure();
|
|
2912
|
+
}
|
|
2913
|
+
return of(false);
|
|
2914
|
+
}))).finally(() => {
|
|
2915
|
+
this.#checkingConnection.set(false);
|
|
2916
|
+
this.#connectionVerification = null;
|
|
2917
|
+
});
|
|
2918
|
+
this.#connectionVerification = verification;
|
|
2919
|
+
return verification;
|
|
2920
|
+
}
|
|
2769
2921
|
/** Factory seam for Capacitor app-state discovery and deterministic tests. */
|
|
2770
2922
|
getAppState() {
|
|
2771
2923
|
return App.getState();
|
|
@@ -5051,6 +5203,7 @@ class OfflineCoordinatorService {
|
|
|
5051
5203
|
this.isStorageReady = computed(() => this.#storageState().status === 'ready', /* @ts-ignore */
|
|
5052
5204
|
...(ngDevMode ? [{ debugName: "isStorageReady" }] : /* istanbul ignore next */ []));
|
|
5053
5205
|
this.networkState = this.#network.state;
|
|
5206
|
+
this.checkingConnection = this.#network.checkingConnection;
|
|
5054
5207
|
this.syncState = this.#sync.syncState;
|
|
5055
5208
|
this.pendingCommands = this.#sync.pendingCommands;
|
|
5056
5209
|
this.pendingCount = this.#sync.pendingCount;
|
|
@@ -5070,6 +5223,10 @@ class OfflineCoordinatorService {
|
|
|
5070
5223
|
#runtimeInitialization;
|
|
5071
5224
|
#transitionRevision;
|
|
5072
5225
|
#transitionTail;
|
|
5226
|
+
/** Immediately verifies remote API reachability without consulting the local replica. */
|
|
5227
|
+
verifyConnection(url, timeoutMs = DEFAULT_OFFLINE_CONNECTION_VERIFICATION_TIMEOUT_MS) {
|
|
5228
|
+
return this.#network.verifyConnection(url, timeoutMs);
|
|
5229
|
+
}
|
|
5073
5230
|
/** Opens local storage and restores its persisted session boundary without waiting for network discovery. */
|
|
5074
5231
|
initializeLocal() {
|
|
5075
5232
|
this.#localInitialization ??= this.#initializeLocal();
|
|
@@ -5251,7 +5408,7 @@ function createOfflineAuthBridge(options) {
|
|
|
5251
5408
|
const { exchange, currentAuthSubject, isUnavailableError, isIdentityCurrent, beforeRemoteResume, onRemoteResumed, resumeMode, retryDelayMs, } = options;
|
|
5252
5409
|
const defaultAvailability$ = options.availability
|
|
5253
5410
|
? undefined
|
|
5254
|
-
: toObservable(offline.networkState).pipe(map((state) => state !== 'offline'), distinctUntilChanged());
|
|
5411
|
+
: toObservable(offline.networkState).pipe(map$1((state) => state !== 'offline'), distinctUntilChanged());
|
|
5255
5412
|
const availability = options.availability ?? (() => defaultAvailability$);
|
|
5256
5413
|
const identityStillCurrent = (lease, identity) => lease.isCurrent() && currentAuthSubject() === identity.authSubject && (isIdentityCurrent?.(identity) ?? true);
|
|
5257
5414
|
const resolveRemoteAccess = async (phase, state, lease) => {
|
|
@@ -5354,6 +5511,7 @@ const COMMUNITY_SQLITE_VERSION = 1;
|
|
|
5354
5511
|
const COMMUNITY_SQLITE_READONLY = false;
|
|
5355
5512
|
|
|
5356
5513
|
const OFFLINE_LOCAL_RESET_REQUESTED = 'requested';
|
|
5514
|
+
const OFFLINE_LOCAL_RESET_RETRY_DELAYS_MS = [50, 150, 300];
|
|
5357
5515
|
/** Persists an explicit destructive reset request, then reloads into a cold bootstrap. */
|
|
5358
5516
|
async function requestOfflineLocalReset(options) {
|
|
5359
5517
|
await options.markerStore.set({ key: options.markerKey, value: OFFLINE_LOCAL_RESET_REQUESTED });
|
|
@@ -5431,6 +5589,12 @@ async function resolveOfflineDatabaseEncryption(sqliteConnection, databaseName,
|
|
|
5431
5589
|
return result.result === true;
|
|
5432
5590
|
}
|
|
5433
5591
|
async function settleOfflineResetOperation(operation) {
|
|
5592
|
+
for (const delayMs of OFFLINE_LOCAL_RESET_RETRY_DELAYS_MS) {
|
|
5593
|
+
const result = await new Promise((resolve) => resolve(operation())).then(() => ({ ok: true }), (error) => ({ ok: false, error }));
|
|
5594
|
+
if (result.ok || !isTransientSqliteLockError(result.error))
|
|
5595
|
+
return result;
|
|
5596
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
5597
|
+
}
|
|
5434
5598
|
return new Promise((resolve) => resolve(operation())).then(() => ({ ok: true }), (error) => ({ ok: false, error }));
|
|
5435
5599
|
}
|
|
5436
5600
|
async function deleteAndCloseOfflineDatabase(sqliteConnection, databaseName, connection) {
|
|
@@ -5518,98 +5682,11 @@ function parseOfflineMutationEnvelope(input, options) {
|
|
|
5518
5682
|
return { id, revision, values: values };
|
|
5519
5683
|
}
|
|
5520
5684
|
|
|
5521
|
-
/** outbox再送時にoffline interceptorだけを迂回する。認証・retryは維持する。 */
|
|
5522
|
-
const OFFLINE_BYPASS = new HttpContextToken(() => false);
|
|
5523
|
-
/** Header attached to synthetic local or optimistic responses. */
|
|
5524
|
-
const OFFLINE_RESPONSE_HEADER = 'X-Offline-Response';
|
|
5525
|
-
/** Header marking a local response as a complete collection snapshot. */
|
|
5526
|
-
const OFFLINE_RESPONSE_COMPLETE_HEADER = 'X-Offline-Response-Complete';
|
|
5527
|
-
/** Reads the source attached by the offline interceptor. */
|
|
5528
|
-
function offlineReadSource(response) {
|
|
5529
|
-
return response.headers.get(OFFLINE_RESPONSE_HEADER) === 'local' ? 'local' : 'remote';
|
|
5530
|
-
}
|
|
5531
|
-
/** Converts an HTTP response into the shared local-first read emission contract. */
|
|
5532
|
-
function offlineReadEmission(response, value) {
|
|
5533
|
-
const source = offlineReadSource(response);
|
|
5534
|
-
return {
|
|
5535
|
-
value,
|
|
5536
|
-
source,
|
|
5537
|
-
complete: source === 'remote' || response.headers.get(OFFLINE_RESPONSE_COMPLETE_HEADER) === 'true',
|
|
5538
|
-
};
|
|
5539
|
-
}
|
|
5540
|
-
/** Prevents an incomplete empty local collection from clearing usable UI state. */
|
|
5541
|
-
function shouldCommitOfflineCollection(emission) {
|
|
5542
|
-
return emission.source === 'remote' || emission.complete || emission.value.length > 0;
|
|
5543
|
-
}
|
|
5544
|
-
/** Multi-provider token containing product request policies. */
|
|
5545
|
-
const OFFLINE_REQUEST_POLICIES = new InjectionToken('OFFLINE_REQUEST_POLICIES', {
|
|
5546
|
-
factory: () => [],
|
|
5547
|
-
});
|
|
5548
|
-
/** Multi-provider token containing product mutation policies. */
|
|
5549
|
-
const OFFLINE_MUTATION_REQUEST_POLICIES = new InjectionToken('OFFLINE_MUTATION_REQUEST_POLICIES', { factory: () => [] });
|
|
5550
|
-
/** Registers one product request policy with the offline interceptor. */
|
|
5551
|
-
function provideOfflineRequestPolicy(policy) {
|
|
5552
|
-
return [policy, { provide: OFFLINE_REQUEST_POLICIES, useExisting: policy, multi: true }];
|
|
5553
|
-
}
|
|
5554
|
-
/** Registers one product mutation policy with the offline interceptor. */
|
|
5555
|
-
function provideOfflineMutationRequestPolicy(policy) {
|
|
5556
|
-
return [policy, { provide: OFFLINE_MUTATION_REQUEST_POLICIES, useExisting: policy, multi: true }];
|
|
5557
|
-
}
|
|
5558
|
-
/** Resolves the first product policy matching an HTTP request. */
|
|
5559
|
-
class OfflineRequestPolicyRegistry {
|
|
5560
|
-
#policies = inject(OFFLINE_REQUEST_POLICIES);
|
|
5561
|
-
resolve(request) {
|
|
5562
|
-
for (const policy of this.#policies) {
|
|
5563
|
-
const plan = policy.resolve(request);
|
|
5564
|
-
if (plan)
|
|
5565
|
-
return plan;
|
|
5566
|
-
}
|
|
5567
|
-
return null;
|
|
5568
|
-
}
|
|
5569
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: OfflineRequestPolicyRegistry, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
5570
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: OfflineRequestPolicyRegistry, providedIn: 'root' }); }
|
|
5571
|
-
}
|
|
5572
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: OfflineRequestPolicyRegistry, decorators: [{
|
|
5573
|
-
type: Injectable,
|
|
5574
|
-
args: [{ providedIn: 'root' }]
|
|
5575
|
-
}] });
|
|
5576
|
-
/** Raised when more than one mutation policy claims the same request. */
|
|
5577
|
-
class OfflineMutationPolicyConflictError extends Error {
|
|
5578
|
-
constructor(request, matchCount) {
|
|
5579
|
-
super(`${matchCount} offline mutation policies matched ${request.method} ${request.urlWithParams}`);
|
|
5580
|
-
this.name = 'OfflineMutationPolicyConflictError';
|
|
5581
|
-
}
|
|
5582
|
-
}
|
|
5583
|
-
/** Resolves the only product mutation policy matching a write request. */
|
|
5584
|
-
class OfflineMutationRequestPolicyRegistry {
|
|
5585
|
-
#policies = inject(OFFLINE_MUTATION_REQUEST_POLICIES);
|
|
5586
|
-
resolve(request) {
|
|
5587
|
-
let matched = null;
|
|
5588
|
-
let matchCount = 0;
|
|
5589
|
-
for (const policy of this.#policies) {
|
|
5590
|
-
const plan = policy.resolve(request);
|
|
5591
|
-
if (!plan)
|
|
5592
|
-
continue;
|
|
5593
|
-
matched = plan;
|
|
5594
|
-
matchCount += 1;
|
|
5595
|
-
}
|
|
5596
|
-
if (matchCount > 1)
|
|
5597
|
-
throw new OfflineMutationPolicyConflictError(request, matchCount);
|
|
5598
|
-
return matched;
|
|
5599
|
-
}
|
|
5600
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: OfflineMutationRequestPolicyRegistry, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
5601
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: OfflineMutationRequestPolicyRegistry, providedIn: 'root' }); }
|
|
5602
|
-
}
|
|
5603
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: OfflineMutationRequestPolicyRegistry, decorators: [{
|
|
5604
|
-
type: Injectable,
|
|
5605
|
-
args: [{ providedIn: 'root' }]
|
|
5606
|
-
}] });
|
|
5607
|
-
|
|
5608
5685
|
const LOCAL_FIRST_MUTATION_METHODS = new Set(['POST', 'PUT', 'PATCH', 'DELETE']);
|
|
5609
5686
|
/** Applies product read and local-first mutation policies while observing real API reachability. */
|
|
5610
5687
|
const offlineInterceptor = (request, next) => {
|
|
5611
5688
|
const network = inject(OfflineNetworkService);
|
|
5612
|
-
const transport = () => observeTransport(next(request), network);
|
|
5689
|
+
const transport = () => observeTransport(next(request), network, !request.context.get(OFFLINE_IGNORE_TRANSPORT_FAILURE));
|
|
5613
5690
|
if (request.context.get(OFFLINE_BYPASS))
|
|
5614
5691
|
return transport();
|
|
5615
5692
|
if (request.method === 'GET') {
|
|
@@ -5634,7 +5711,7 @@ const offlineInterceptor = (request, next) => {
|
|
|
5634
5711
|
return transport();
|
|
5635
5712
|
const plan = inject(OfflineMutationRequestPolicyRegistry).resolve(request);
|
|
5636
5713
|
if (plan) {
|
|
5637
|
-
return defer(() => from(plan.prepare())).pipe(map
|
|
5714
|
+
return defer(() => from(plan.prepare())).pipe(map((response) => response.clone({ headers: response.headers.set(OFFLINE_RESPONSE_HEADER, 'optimistic') })));
|
|
5638
5715
|
}
|
|
5639
5716
|
}
|
|
5640
5717
|
return transport();
|
|
@@ -5727,9 +5804,9 @@ function projectReadResponse(event, plan, replicaMutations) {
|
|
|
5727
5804
|
const projection = plan.serializeResponseProjection
|
|
5728
5805
|
? replicaMutations.runSerializedRead(() => plan.projectResponse(event, source))
|
|
5729
5806
|
: plan.projectResponse(event, source);
|
|
5730
|
-
return from(projection).pipe(map
|
|
5807
|
+
return from(projection).pipe(map((response) => source === 'local' ? response.clone({ headers: response.headers.set(OFFLINE_RESPONSE_HEADER, 'local') }) : response));
|
|
5731
5808
|
}
|
|
5732
|
-
function observeTransport(source, network) {
|
|
5809
|
+
function observeTransport(source, network, observeFailure) {
|
|
5733
5810
|
return source.pipe(tap({
|
|
5734
5811
|
next: (event) => {
|
|
5735
5812
|
if (!(event instanceof HttpResponse))
|
|
@@ -5741,7 +5818,7 @@ function observeTransport(source, network) {
|
|
|
5741
5818
|
network.markApiSuccess();
|
|
5742
5819
|
},
|
|
5743
5820
|
error: (error) => {
|
|
5744
|
-
if (isOfflineFallbackError(error))
|
|
5821
|
+
if (observeFailure && isOfflineFallbackError(error))
|
|
5745
5822
|
network.markApiFailure();
|
|
5746
5823
|
},
|
|
5747
5824
|
}));
|
|
@@ -7230,5 +7307,5 @@ function assertSupportedOfflineMode(platform, mode) {
|
|
|
7230
7307
|
* Generated bundle index. Do not edit.
|
|
7231
7308
|
*/
|
|
7232
7309
|
|
|
7233
|
-
export { COMMUNITY_SQLITE, DEFAULT_OFFLINE_COMMAND_HOOKS, IonicOfflineRepository, OFFLINE_AGGREGATE_INTENT_PROJECTOR, OFFLINE_BYPASS, OFFLINE_COMMAND_EXECUTOR, OFFLINE_COMMAND_HOOKS, 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 };
|
|
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 };
|
|
7234
7311
|
//# sourceMappingURL=rdlabo-ionic-angular-kit-offline.mjs.map
|