@rdlabo/ionic-angular-kit 21.2.0-9 → 21.3.0

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-9",
3
+ "version": "21.3.0",
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,100 @@ 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
+ readonly id: string;
1338
+ protected readonly listeners: PluginListenerHandle[];
1339
+ /** All parsed events received by this connection. */
1340
+ readonly events$: Observable<KitClientRealtimeEvent<TEvent>>;
1341
+ /** Emits once after every fully restored connection cycle, prompting consumers to resync via REST. */
1342
+ readonly reconnected$: Observable<void>;
1343
+ protected constructor(options?: KitRealtimeConnectionOptions);
1344
+ /** Whether every configured socket is currently open. */
1345
+ get isStreamOpen(): boolean;
1346
+ /** Whether every configured socket has produced recent server activity. */
1347
+ get isStreamHealthy(): boolean;
1348
+ protected abstract get shouldConnect(): boolean;
1349
+ protected abstract buildSocketTargets(): Promise<KitRealtimeSocketTarget[]>;
1350
+ /** Hook used by authenticated clients to invalidate a token after handshake failure. */
1351
+ protected handleConnectionFailure(): Promise<void>;
1352
+ /** Parse a text WebSocket message into one or more domain events. */
1353
+ protected parseMessage(data: string): TEvent[];
1354
+ /** Factory seam for platform-specific WebSocket implementations and unit tests. */
1355
+ protected createWebSocket(url: string, protocols: string[]): WebSocket;
1356
+ /** Factory seam for Capacitor app-state listeners. */
1357
+ protected addAppStateListener(listener: (state: {
1358
+ isActive: boolean;
1359
+ }) => void): Promise<PluginListenerHandle>;
1360
+ /** Factory seam for Capacitor network-status listeners. */
1361
+ protected addNetworkStatusListener(listener: (status: {
1362
+ connected: boolean;
1363
+ }) => void): Promise<PluginListenerHandle>;
1364
+ /** Register foreground/network listeners exactly once, cleaning up handles that resolve after disconnect. */
1365
+ protected registerLifecycleListeners(): Promise<void>;
1366
+ /** Remove all lifecycle listeners, including listeners whose async registration has not completed yet. */
1367
+ protected removeLifecycleListeners(): void;
1368
+ /** Suspend sockets without changing the subclass connection intent. */
1369
+ protected suspend(): void;
1370
+ /** Reset resync and backoff history when the owning session ends. */
1371
+ protected resetConnectionState(): void;
1372
+ /** Open every current target, or schedule an atomic reconnect if any target fails. */
1373
+ protected open(): Promise<void>;
1374
+ }
1375
+
1282
1376
  /**
1283
1377
  * Trigger native haptic impact feedback.
1284
1378
  *
@@ -1455,12 +1549,20 @@ declare const kitCreateDidEnter: (el: ElementRef) => Observable<boolean>;
1455
1549
  * ViewModel から見えるようにする型。`vm` は循環参照になるため除外する。
1456
1550
  *
1457
1551
  * 注意: `new ViewModel(this)` の引数型に直接使うと、vm 依存 computed の推論と循環する。
1458
- * ViewModel 側は constructor(host: Component) で受け、フィールドを `ReactiveHost<Component>` に
1459
- * 絞り込むこと(呼び出し点では ReactiveHost を展開しない)。
1552
+ * ViewModelStore 側は constructor(host: Component) で受け、`mountViewModel()` により
1553
+ * `ViewModelHost<Component, Keys>` へ絞り込むこと(呼び出し点では mapped type を展開しない)。
1460
1554
  */
1461
1555
  type ReactiveHost<T> = Pick<T, {
1462
1556
  [K in Exclude<keyof T, 'vm'>]-?: T[K] extends Signal<unknown> ? K : T[K] extends OutputEmitterRef<any> ? K : never;
1463
1557
  }[Exclude<keyof T, 'vm'>]>;
1558
+ /**
1559
+ * ViewModel に公開する Component の Signal と、明示的に許可した非 Signal property。
1560
+ */
1561
+ type ViewModelHost<T, K extends keyof T = never> = ReactiveHost<T> & Pick<T, K>;
1562
+ /**
1563
+ * Component host を ViewModel 用に絞り込み、初回 render 後の mount hook を登録する。
1564
+ */
1565
+ declare function mountViewModel<T, K extends keyof T = never>(host: T, onMount?: () => void): ViewModelHost<T, K>;
1464
1566
  /**
1465
1567
  * Modal / page に渡す props オブジェクトを、Angular `input()` の InputSignal 形に写す型。
1466
1568
  * `implements ComponentPropsType<Props>` で component 側の input 宣言を揃える。
@@ -1469,5 +1571,5 @@ type ComponentPropsType<T> = {
1469
1571
  [K in keyof T]: InputSignal<T[K]> | InputSignalWithTransform<T[K], any>;
1470
1572
  };
1471
1573
 
1472
- 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, objectEqual, provideKitAuth, provideKitHttp, provideKitOverlay };
1473
- export type { ComponentPropsType, KitAlertCloseOptions, KitAlertConfirmOptions, KitAuthConfig, KitAuthFailedAlertOptions, KitAuthInputMode, KitAuthRedirects, KitAuthState, KitClearableStore, KitEmailStore, KitHttpConfig, KitKeyboardAdjust, KitLabels, KitLanguageActionSheetOptions, KitLanguageOption, KitMaintenanceOptions, KitModalPresentOptions, KitOverlayConfig, KitReloadAlertOptions, ModalMetadata, ReactiveHost };
1574
+ 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 };
1575
+ 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 };