@rdlabo/ionic-angular-kit 21.2.0 → 21.3.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rdlabo/ionic-angular-kit",
3
- "version": "21.2.0",
3
+ "version": "21.3.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/rdlabo-team/ionic-angular-library.git"
@@ -13,6 +13,7 @@
13
13
  "@ionic/angular": "^8.0.0",
14
14
  "@ionic/storage-angular": "^4.0.0",
15
15
  "@capacitor/core": ">=6.0.0 <9.0.0",
16
+ "@capacitor/app": ">=6.0.0 <9.0.0",
16
17
  "@capawesome/capacitor-live-update": ">=6.0.0 <9.0.0",
17
18
  "@capacitor/haptics": ">=6.0.0 <9.0.0",
18
19
  "@capacitor/keyboard": ">=6.0.0 <9.0.0",
@@ -1279,6 +1279,104 @@ declare const provideKitHttp: (configFactory: () => KitHttpConfig) => Environmen
1279
1279
  */
1280
1280
  declare const kitAuthInterceptor: HttpInterceptorFn;
1281
1281
 
1282
+ /** One WebSocket endpoint and its ordered subprotocol list. */
1283
+ interface KitRealtimeSocketTarget {
1284
+ url: string;
1285
+ protocols: string[];
1286
+ }
1287
+ /** Realtime event shape required for self-echo identification. */
1288
+ interface KitRealtimeEvent {
1289
+ originId?: string;
1290
+ }
1291
+ /** An application event annotated with whether it originated from this client. */
1292
+ type KitClientRealtimeEvent<TEvent extends KitRealtimeEvent> = TEvent & {
1293
+ isSelf: boolean;
1294
+ };
1295
+ /** Timing and protocol options for {@link KitRealtimeConnection}. */
1296
+ interface KitRealtimeConnectionOptions {
1297
+ clientId?: string;
1298
+ ping?: string;
1299
+ pong?: string;
1300
+ maxBackoffMs?: number;
1301
+ openTimeoutMs?: number;
1302
+ pingIntervalMs?: number;
1303
+ livenessTimeoutMs?: number;
1304
+ }
1305
+ /** Stable per-tab/application-run ID shared by realtime connections and write headers. */
1306
+ declare const KIT_REALTIME_CLIENT_ID: `${string}-${string}-${string}-${string}-${string}`;
1307
+ /** Convert an HTTP(S) endpoint to its WebSocket equivalent. */
1308
+ declare function toKitWebSocketUrl(url: string): string;
1309
+ /** Build the standard application/auth/client WebSocket subprotocol list. */
1310
+ declare function kitRealtimeProtocols(protocol: string, options?: {
1311
+ clientId?: string;
1312
+ authToken?: string;
1313
+ authPrefix?: string;
1314
+ clientPrefix?: string;
1315
+ }): string[];
1316
+ /** Detect a half-open WebSocket when no pong or event arrives before the timeout. */
1317
+ declare class KitRealtimeLivenessWatchdog {
1318
+ #private;
1319
+ private readonly timeoutMs;
1320
+ private readonly onTimeout;
1321
+ constructor(timeoutMs: number, onTimeout: () => void);
1322
+ /** Restart the liveness deadline after receiving server activity. */
1323
+ reset(): void;
1324
+ /** Cancel the current liveness deadline. */
1325
+ clear(): void;
1326
+ }
1327
+ /**
1328
+ * Reconnecting Hibernation WebSocket client for Ionic/Capacitor applications.
1329
+ *
1330
+ * Subclasses provide connection intent and one or more targets. The base owns foreground/network
1331
+ * suspension, exponential backoff, open/liveness timeouts, runtime-friendly application pings,
1332
+ * all-target atomic reconnect, and a resync signal after connectivity is restored.
1333
+ */
1334
+ declare abstract class KitRealtimeConnection<TEvent extends KitRealtimeEvent> {
1335
+ #private;
1336
+ /** Client ID used to classify self echoes. */
1337
+ protected readonly listeners: PluginListenerHandle[];
1338
+ /** All parsed events received by this connection. */
1339
+ readonly events$: Observable<KitClientRealtimeEvent<TEvent>>;
1340
+ /** Emits once after every fully restored connection cycle, prompting consumers to resync via REST. */
1341
+ readonly reconnected$: Observable<void>;
1342
+ /** Override timing/protocol defaults in specialized clients or tests. */
1343
+ protected get realtimeOptions(): KitRealtimeConnectionOptions;
1344
+ /** Client ID used to classify self echoes. */
1345
+ get id(): string;
1346
+ /** Whether every configured socket is currently open. */
1347
+ get isStreamOpen(): boolean;
1348
+ /** Whether every configured socket has produced recent server activity. */
1349
+ get isStreamHealthy(): boolean;
1350
+ protected abstract get shouldConnect(): boolean;
1351
+ protected abstract buildSocketTargets(): Promise<KitRealtimeSocketTarget[]>;
1352
+ /** Hook used by authenticated clients to invalidate a token after handshake failure. */
1353
+ protected handleConnectionFailure(): Promise<void>;
1354
+ /** Parse a text WebSocket message into one or more domain events. */
1355
+ protected parseMessage(data: string): TEvent[];
1356
+ /** Factory seam for platform-specific WebSocket implementations and unit tests. */
1357
+ protected createWebSocket(url: string, protocols: string[]): WebSocket;
1358
+ /** Factory seam for Capacitor app-state listeners. */
1359
+ protected addAppStateListener(listener: (state: {
1360
+ isActive: boolean;
1361
+ }) => void): Promise<PluginListenerHandle>;
1362
+ /** Factory seam for Capacitor network-status listeners. */
1363
+ protected addNetworkStatusListener(listener: (status: {
1364
+ connected: boolean;
1365
+ }) => void): Promise<PluginListenerHandle>;
1366
+ /** Register foreground/network listeners exactly once, cleaning up handles that resolve after disconnect. */
1367
+ protected registerLifecycleListeners(): Promise<void>;
1368
+ /** Remove all lifecycle listeners, including listeners whose async registration has not completed yet. */
1369
+ protected removeLifecycleListeners(): void;
1370
+ /** Suspend sockets without changing the subclass connection intent. */
1371
+ protected suspend(): void;
1372
+ /** Reset resync and backoff history when the owning session ends. */
1373
+ protected resetConnectionState(): void;
1374
+ /** Open every current target, or schedule an atomic reconnect if any target fails. */
1375
+ protected open(): Promise<void>;
1376
+ static ɵfac: i0.ɵɵFactoryDeclaration<KitRealtimeConnection<any>, never>;
1377
+ static ɵprov: i0.ɵɵInjectableDeclaration<KitRealtimeConnection<any>>;
1378
+ }
1379
+
1282
1380
  /**
1283
1381
  * Trigger native haptic impact feedback.
1284
1382
  *
@@ -1477,5 +1575,5 @@ type ComponentPropsType<T> = {
1477
1575
  [K in keyof T]: InputSignal<T[K]> | InputSignalWithTransform<T[K], any>;
1478
1576
  };
1479
1577
 
1480
- export { KIT_AUTH_CONFIG, KIT_HTTP_CONFIG, KIT_LAST_AUTH_EMAIL_KEY, KIT_OVERLAY_CONFIG, KIT_THEME_STORAGE_KEY, KitAuthInputDirective, KitLoadingController, KitMaintenanceController, KitOverlayController, KitReloadAlertController, KitStorageService, arrayConcatById, disableHandler, isMaintenanceError, kitAuthInterceptor, kitChangeEventDisabled, kitClearStoragePreservingKeys, kitCreateDidEnter, kitForgetEmail, kitImpact, kitIsValidEmail, kitKeyboardInit, kitPresentAuthFailedAlert, kitPresentLanguageActionSheet, kitRecallEmail, kitRememberEmail, kitRequireAuthorizedGuard, kitRequireConfirmingGuard, kitRequiredUnauthorizedGuard, mountViewModel, objectEqual, provideKitAuth, provideKitHttp, provideKitOverlay };
1481
- export type { ComponentPropsType, KitAlertCloseOptions, KitAlertConfirmOptions, KitAuthConfig, KitAuthFailedAlertOptions, KitAuthInputMode, KitAuthRedirects, KitAuthState, KitClearableStore, KitEmailStore, KitHttpConfig, KitKeyboardAdjust, KitLabels, KitLanguageActionSheetOptions, KitLanguageOption, KitMaintenanceOptions, KitModalPresentOptions, KitOverlayConfig, KitReloadAlertOptions, ModalMetadata, ReactiveHost, ViewModelHost };
1578
+ export { KIT_AUTH_CONFIG, KIT_HTTP_CONFIG, KIT_LAST_AUTH_EMAIL_KEY, KIT_OVERLAY_CONFIG, KIT_REALTIME_CLIENT_ID, KIT_THEME_STORAGE_KEY, KitAuthInputDirective, KitLoadingController, KitMaintenanceController, KitOverlayController, KitRealtimeConnection, KitRealtimeLivenessWatchdog, KitReloadAlertController, KitStorageService, arrayConcatById, disableHandler, isMaintenanceError, kitAuthInterceptor, kitChangeEventDisabled, kitClearStoragePreservingKeys, kitCreateDidEnter, kitForgetEmail, kitImpact, kitIsValidEmail, kitKeyboardInit, kitPresentAuthFailedAlert, kitPresentLanguageActionSheet, kitRealtimeProtocols, kitRecallEmail, kitRememberEmail, kitRequireAuthorizedGuard, kitRequireConfirmingGuard, kitRequiredUnauthorizedGuard, mountViewModel, objectEqual, provideKitAuth, provideKitHttp, provideKitOverlay, toKitWebSocketUrl };
1579
+ export type { ComponentPropsType, KitAlertCloseOptions, KitAlertConfirmOptions, KitAuthConfig, KitAuthFailedAlertOptions, KitAuthInputMode, KitAuthRedirects, KitAuthState, KitClearableStore, KitClientRealtimeEvent, KitEmailStore, KitHttpConfig, KitKeyboardAdjust, KitLabels, KitLanguageActionSheetOptions, KitLanguageOption, KitMaintenanceOptions, KitModalPresentOptions, KitOverlayConfig, KitRealtimeConnectionOptions, KitRealtimeEvent, KitRealtimeSocketTarget, KitReloadAlertOptions, ModalMetadata, ReactiveHost, ViewModelHost };