@cloudsignal/pwa-sdk 1.0.0 → 1.1.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/dist/index.d.mts CHANGED
@@ -209,6 +209,14 @@ interface PWAConfig {
209
209
  heartbeat?: HeartbeatConfig;
210
210
  /** Custom logger function */
211
211
  logger?: LoggerFunction;
212
+ /** Wake lock configuration (v1.1.0) */
213
+ wakeLock?: WakeLockConfig$1;
214
+ /** Offline queue configuration (v1.1.0) */
215
+ offlineQueue?: OfflineQueueConfig$1;
216
+ /** iOS install banner configuration (v1.1.0) */
217
+ iosInstallBanner?: IOSInstallBannerConfig$1;
218
+ /** Notification analytics configuration (v1.1.0) */
219
+ notificationAnalytics?: NotificationAnalyticsConfig;
212
220
  }
213
221
  /**
214
222
  * Service worker configuration
@@ -236,6 +244,60 @@ interface HeartbeatConfig {
236
244
  /** Stop heartbeat when page is hidden */
237
245
  stopOnHidden?: boolean;
238
246
  }
247
+ /**
248
+ * Wake lock configuration to prevent screen sleep
249
+ */
250
+ interface WakeLockConfig$1 {
251
+ /** Enable wake lock feature */
252
+ enabled?: boolean;
253
+ /** Automatically request wake lock on init */
254
+ autoRequest?: boolean;
255
+ /** Automatically re-acquire on visibility change */
256
+ reacquireOnVisibility?: boolean;
257
+ }
258
+ /**
259
+ * Offline queue configuration for resilient request handling
260
+ */
261
+ interface OfflineQueueConfig$1 {
262
+ /** Enable offline request queuing */
263
+ enabled?: boolean;
264
+ /** Maximum requests in queue */
265
+ maxQueueSize?: number;
266
+ /** Time to live in hours for queued requests */
267
+ maxAgeTTLHours?: number;
268
+ /** Auto-process queue when coming online */
269
+ autoProcessOnOnline?: boolean;
270
+ }
271
+ /**
272
+ * iOS install banner configuration
273
+ */
274
+ interface IOSInstallBannerConfig$1 {
275
+ /** Enable iOS install banner */
276
+ enabled?: boolean;
277
+ /** Custom banner title */
278
+ title?: string;
279
+ /** Custom banner subtitle */
280
+ subtitle?: string;
281
+ /** App name to display */
282
+ appName?: string;
283
+ /** App icon URL */
284
+ iconUrl?: string;
285
+ /** Show on first visit */
286
+ showOnFirstVisit?: boolean;
287
+ /** Delay before showing (ms) */
288
+ showDelay?: number;
289
+ /** How many days before showing again after dismissal */
290
+ dismissRememberDays?: number;
291
+ }
292
+ /**
293
+ * Notification analytics configuration
294
+ */
295
+ interface NotificationAnalyticsConfig {
296
+ /** Enable analytics tracking */
297
+ enabled?: boolean;
298
+ /** Backend endpoint for analytics events */
299
+ endpoint?: string;
300
+ }
239
301
  /**
240
302
  * Logger function signature
241
303
  */
@@ -441,7 +503,7 @@ interface NotificationAction {
441
503
  /**
442
504
  * Event types emitted by the SDK
443
505
  */
444
- type PWAEvent = 'install:available' | 'install:accepted' | 'install:dismissed' | 'install:completed' | 'install:error' | 'push:registered' | 'push:unregistered' | 'push:updated' | 'push:error' | 'push:received' | 'push:clicked' | 'permission:granted' | 'permission:denied' | 'permission:prompt' | 'sw:registered' | 'sw:updated' | 'sw:error' | 'sw:activated' | 'config:loaded' | 'config:error' | 'heartbeat:started' | 'heartbeat:stopped' | 'heartbeat:sent' | 'heartbeat:error' | 'network:online' | 'network:offline' | 'state:changed';
506
+ type PWAEvent = 'install:available' | 'install:accepted' | 'install:dismissed' | 'install:completed' | 'install:error' | 'push:registered' | 'push:unregistered' | 'push:updated' | 'push:error' | 'push:received' | 'push:clicked' | 'permission:granted' | 'permission:denied' | 'permission:prompt' | 'sw:registered' | 'sw:updated' | 'sw:error' | 'sw:activated' | 'config:loaded' | 'config:error' | 'heartbeat:started' | 'heartbeat:stopped' | 'heartbeat:sent' | 'heartbeat:error' | 'heartbeat:intervalChanged' | 'heartbeat:pausedForBattery' | 'heartbeat:resumedFromBattery' | 'network:online' | 'network:offline' | 'state:changed' | 'wakeLock:acquired' | 'wakeLock:released' | 'wakeLock:error' | 'offlineQueue:queued' | 'offlineQueue:processed' | 'offlineQueue:flushed' | 'iosBanner:shown' | 'iosBanner:dismissed' | 'iosBanner:installClicked';
445
507
  /**
446
508
  * Event handler function
447
509
  */
@@ -517,6 +579,265 @@ interface NetworkEvent {
517
579
  connectionType?: string;
518
580
  }
519
581
 
582
+ /**
583
+ * CloudSignal PWA SDK Wake Lock Types
584
+ */
585
+ /**
586
+ * Wake lock configuration
587
+ */
588
+ interface WakeLockConfig {
589
+ /** Enable wake lock feature */
590
+ enabled?: boolean;
591
+ /** Automatically reacquire lock when page becomes visible */
592
+ autoReacquire?: boolean;
593
+ }
594
+ /**
595
+ * Wake lock state
596
+ */
597
+ interface WakeLockState {
598
+ /** Whether wake lock is currently active */
599
+ isActive: boolean;
600
+ /** Whether Wake Lock API is supported */
601
+ isSupported: boolean;
602
+ /** Type of wake lock (currently only 'screen' is supported) */
603
+ type?: 'screen';
604
+ /** Timestamp when lock was acquired */
605
+ acquiredAt?: number;
606
+ }
607
+ /**
608
+ * Wake lock acquired event data
609
+ */
610
+ interface WakeLockAcquiredEvent {
611
+ timestamp: number;
612
+ }
613
+ /**
614
+ * Wake lock released event data
615
+ */
616
+ interface WakeLockReleasedEvent {
617
+ timestamp: number;
618
+ reason: 'manual' | 'visibility' | 'system';
619
+ }
620
+ /**
621
+ * Wake lock error event data
622
+ */
623
+ interface WakeLockErrorEvent {
624
+ timestamp: number;
625
+ error: string;
626
+ errorName?: string;
627
+ }
628
+ /**
629
+ * iOS Install Banner configuration
630
+ */
631
+ interface IOSInstallBannerConfig {
632
+ /** Enable iOS install banner */
633
+ enabled?: boolean;
634
+ /** Title text */
635
+ title?: string;
636
+ /** Description text */
637
+ description?: string;
638
+ /** Button text */
639
+ buttonText?: string;
640
+ /** Close button text */
641
+ closeText?: string;
642
+ /** Icon URL (app icon) */
643
+ iconUrl?: string;
644
+ /** Custom CSS styles */
645
+ customStyles?: Partial<IOSInstallBannerStyles>;
646
+ /** Delay before showing banner (ms) */
647
+ showDelay?: number;
648
+ /** Remember dismissal for this many days */
649
+ dismissalDays?: number;
650
+ /** Position: 'top' | 'bottom' */
651
+ position?: 'top' | 'bottom';
652
+ }
653
+ /**
654
+ * iOS Install Banner styles
655
+ */
656
+ interface IOSInstallBannerStyles {
657
+ backgroundColor: string;
658
+ textColor: string;
659
+ buttonBackgroundColor: string;
660
+ buttonTextColor: string;
661
+ borderRadius: string;
662
+ boxShadow: string;
663
+ }
664
+ /**
665
+ * iOS Install Banner state
666
+ */
667
+ interface IOSInstallBannerState {
668
+ /** Whether banner is currently visible */
669
+ isVisible: boolean;
670
+ /** Whether banner was dismissed */
671
+ wasDismissed: boolean;
672
+ /** Whether device is iOS Safari (eligible for banner) */
673
+ isEligible: boolean;
674
+ /** Whether PWA is already installed */
675
+ isInstalled: boolean;
676
+ }
677
+ /**
678
+ * Notification analytics event
679
+ */
680
+ interface NotificationAnalyticsEvent {
681
+ /** Unique notification ID */
682
+ notificationId: string;
683
+ /** Event type */
684
+ eventType: 'displayed' | 'clicked' | 'dismissed';
685
+ /** Registration ID */
686
+ registrationId?: string;
687
+ /** Timestamp of event */
688
+ timestamp: number;
689
+ /** Action clicked (if notification had action buttons) */
690
+ action?: string;
691
+ /** Additional metadata */
692
+ metadata?: Record<string, any>;
693
+ }
694
+ /**
695
+ * Network connection info (from Network Information API)
696
+ */
697
+ interface NetworkConnectionInfo {
698
+ /** Effective connection type: '4g' | '3g' | '2g' | 'slow-2g' */
699
+ effectiveType?: '4g' | '3g' | '2g' | 'slow-2g';
700
+ /** Whether user has requested reduced data usage */
701
+ saveData?: boolean;
702
+ /** Estimated downlink speed in Mbps */
703
+ downlink?: number;
704
+ /** Estimated round-trip time in ms */
705
+ rtt?: number;
706
+ }
707
+ /**
708
+ * Battery info (from Battery Status API)
709
+ */
710
+ interface BatteryInfo {
711
+ /** Battery level (0-1) */
712
+ level: number;
713
+ /** Whether device is charging */
714
+ charging: boolean;
715
+ }
716
+ /**
717
+ * Adaptive heartbeat configuration
718
+ */
719
+ interface AdaptiveHeartbeatConfig {
720
+ /** Enable network-aware interval adjustment */
721
+ adaptToNetwork?: boolean;
722
+ /** Enable battery-aware pausing */
723
+ adaptToBattery?: boolean;
724
+ /** Battery threshold to pause heartbeat (0-1, default: 0.15) */
725
+ batteryPauseThreshold?: number;
726
+ /** Intervals by connection type */
727
+ intervals?: {
728
+ '4g'?: number;
729
+ '3g'?: number;
730
+ '2g'?: number;
731
+ 'slow-2g'?: number;
732
+ 'unknown'?: number;
733
+ };
734
+ }
735
+ /**
736
+ * iOS Install Banner options (for constructor)
737
+ */
738
+ interface IOSInstallBannerOptions$1 {
739
+ /** Title text */
740
+ title?: string;
741
+ /** Subtitle text */
742
+ subtitle?: string;
743
+ /** App name to display */
744
+ appName?: string;
745
+ /** App icon URL */
746
+ iconUrl?: string;
747
+ /** Delay before showing (ms) */
748
+ showDelay?: number;
749
+ /** Days to remember dismissal */
750
+ dismissRememberDays?: number;
751
+ /** Callback when banner is shown */
752
+ onShow?: () => void;
753
+ /** Callback when banner is dismissed */
754
+ onDismiss?: () => void;
755
+ /** Callback when install instructions are clicked */
756
+ onInstallClick?: () => void;
757
+ }
758
+
759
+ /**
760
+ * CloudSignal PWA SDK Offline Queue Types
761
+ */
762
+ /**
763
+ * Queued request for offline retry
764
+ */
765
+ interface QueuedRequest {
766
+ /** Unique request ID */
767
+ id?: number;
768
+ /** Request URL */
769
+ url: string;
770
+ /** HTTP method */
771
+ method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
772
+ /** Request headers */
773
+ headers?: Record<string, string>;
774
+ /** Request body (JSON stringified) */
775
+ body?: string;
776
+ /** When the request was queued */
777
+ queuedAt: number;
778
+ /** Number of retry attempts */
779
+ retryCount: number;
780
+ /** Maximum retry attempts */
781
+ maxRetries: number;
782
+ /** Request type for categorization */
783
+ requestType: QueuedRequestType;
784
+ /** Priority (higher = more important) */
785
+ priority: number;
786
+ /** Optional metadata */
787
+ metadata?: Record<string, any>;
788
+ }
789
+ /**
790
+ * Types of requests that can be queued
791
+ */
792
+ type QueuedRequestType = 'registration' | 'heartbeat' | 'analytics' | 'preferences' | 'unregister' | 'custom';
793
+ /**
794
+ * Offline queue configuration
795
+ */
796
+ interface OfflineQueueConfig {
797
+ /** Enable offline queue */
798
+ enabled?: boolean;
799
+ /** Maximum number of queued requests */
800
+ maxQueueSize?: number;
801
+ /** Maximum age of queued requests in ms (default: 24 hours) */
802
+ maxAge?: number;
803
+ /** Base retry delay in ms (default: 1000) */
804
+ baseRetryDelay?: number;
805
+ /** Maximum retry delay in ms (default: 60000) */
806
+ maxRetryDelay?: number;
807
+ /** Default max retries per request */
808
+ defaultMaxRetries?: number;
809
+ /** Process queue when online event fires */
810
+ processOnOnline?: boolean;
811
+ }
812
+ /**
813
+ * Result of processing a queued request
814
+ */
815
+ interface QueueProcessResult {
816
+ /** Request ID */
817
+ id: number;
818
+ /** Whether request succeeded */
819
+ success: boolean;
820
+ /** HTTP status code if request was made */
821
+ statusCode?: number;
822
+ /** Error message if failed */
823
+ error?: string;
824
+ /** Whether request should be retried */
825
+ shouldRetry: boolean;
826
+ }
827
+ /**
828
+ * Offline queue statistics
829
+ */
830
+ interface OfflineQueueStats {
831
+ /** Total requests in queue */
832
+ totalQueued: number;
833
+ /** Requests by type */
834
+ byType: Record<QueuedRequestType, number>;
835
+ /** Oldest request timestamp */
836
+ oldestRequest?: number;
837
+ /** Newest request timestamp */
838
+ newestRequest?: number;
839
+ }
840
+
520
841
  /**
521
842
  * CloudSignal PWA Client
522
843
  * Main class for PWA functionality including installation, push notifications, and device tracking
@@ -532,6 +853,9 @@ declare class CloudSignalPWA {
532
853
  private installationManager;
533
854
  private pushNotificationManager;
534
855
  private heartbeatManager;
856
+ private wakeLockManager;
857
+ private offlineQueueManager;
858
+ private iosInstallBanner;
535
859
  private eventHandlers;
536
860
  constructor(config: PWAConfig);
537
861
  /**
@@ -607,6 +931,65 @@ declare class CloudSignalPWA {
607
931
  * Stop heartbeat
608
932
  */
609
933
  stopHeartbeat(): void;
934
+ /**
935
+ * Get current heartbeat interval (may vary with network conditions)
936
+ */
937
+ getHeartbeatInterval(): number;
938
+ /**
939
+ * Get current network connection info
940
+ */
941
+ getNetworkInfo(): NetworkConnectionInfo;
942
+ /**
943
+ * Get battery info if available
944
+ */
945
+ getBatteryInfo(): Promise<BatteryInfo | null>;
946
+ /**
947
+ * Request screen wake lock to prevent sleep
948
+ */
949
+ requestWakeLock(): Promise<boolean>;
950
+ /**
951
+ * Release screen wake lock
952
+ */
953
+ releaseWakeLock(): void;
954
+ /**
955
+ * Get wake lock state
956
+ */
957
+ getWakeLockState(): WakeLockState;
958
+ /**
959
+ * Queue a request for later execution when offline
960
+ */
961
+ queueOfflineRequest(url: string, method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE', options?: {
962
+ body?: string;
963
+ headers?: Record<string, string>;
964
+ }): Promise<number | null>;
965
+ /**
966
+ * Process all queued requests
967
+ */
968
+ processOfflineQueue(): Promise<QueueProcessResult[]>;
969
+ /**
970
+ * Get offline queue statistics
971
+ */
972
+ getOfflineQueueStats(): Promise<OfflineQueueStats>;
973
+ /**
974
+ * Clear all queued requests
975
+ */
976
+ clearOfflineQueue(): Promise<void>;
977
+ /**
978
+ * Show iOS install banner manually
979
+ */
980
+ showIOSInstallBanner(): void;
981
+ /**
982
+ * Hide iOS install banner
983
+ */
984
+ hideIOSInstallBanner(): void;
985
+ /**
986
+ * Check if iOS install banner was previously dismissed
987
+ */
988
+ wasIOSBannerDismissed(): boolean;
989
+ /**
990
+ * Reset iOS banner dismissal state
991
+ */
992
+ resetIOSBannerDismissal(): void;
610
993
  /**
611
994
  * Clear app badge
612
995
  */
@@ -651,6 +1034,10 @@ declare class CloudSignalPWA {
651
1034
  * Set up network status listeners
652
1035
  */
653
1036
  private setupNetworkListeners;
1037
+ /**
1038
+ * Configure notification analytics in service worker
1039
+ */
1040
+ private configureNotificationAnalytics;
654
1041
  /**
655
1042
  * Log message if debug is enabled
656
1043
  */
@@ -966,6 +1353,7 @@ declare class PushNotificationManager {
966
1353
 
967
1354
  /**
968
1355
  * HeartbeatManager - Online Status Tracking via Periodic Heartbeat
1356
+ * Now with network and battery awareness for optimal performance
969
1357
  */
970
1358
 
971
1359
  interface HeartbeatManagerOptions {
@@ -973,25 +1361,38 @@ interface HeartbeatManagerOptions {
973
1361
  organizationId: string;
974
1362
  organizationSecret: string;
975
1363
  config?: HeartbeatConfig;
1364
+ adaptiveConfig?: AdaptiveHeartbeatConfig;
976
1365
  debug?: boolean;
977
1366
  onHeartbeatSent?: () => void;
978
1367
  onHeartbeatError?: (error: Error) => void;
1368
+ onIntervalChanged?: (newInterval: number, reason: string) => void;
1369
+ onPausedForBattery?: () => void;
1370
+ onResumedFromBattery?: () => void;
979
1371
  }
980
1372
  /**
981
1373
  * HeartbeatManager sends periodic heartbeats to track online status
1374
+ * Now with adaptive intervals based on network quality and battery level
982
1375
  */
983
1376
  declare class HeartbeatManager {
984
1377
  private serviceUrl;
985
1378
  private organizationId;
986
1379
  private organizationSecret;
987
1380
  private config;
1381
+ private adaptiveConfig;
988
1382
  private debug;
989
1383
  private registrationId;
990
1384
  private intervalId;
991
1385
  private isRunning;
1386
+ private isPausedForBattery;
1387
+ private currentInterval;
992
1388
  private visibilityHandler;
1389
+ private connectionChangeHandler;
1390
+ private batteryManager;
993
1391
  private onHeartbeatSent?;
994
1392
  private onHeartbeatError?;
1393
+ private onIntervalChanged?;
1394
+ private onPausedForBattery?;
1395
+ private onResumedFromBattery?;
995
1396
  constructor(options: HeartbeatManagerOptions);
996
1397
  /**
997
1398
  * Set the registration ID for heartbeat requests
@@ -1017,6 +1418,38 @@ declare class HeartbeatManager {
1017
1418
  * Update heartbeat configuration
1018
1419
  */
1019
1420
  updateConfig(config: Partial<HeartbeatConfig>): void;
1421
+ /**
1422
+ * Get current network connection info
1423
+ */
1424
+ getNetworkInfo(): NetworkConnectionInfo;
1425
+ /**
1426
+ * Get current battery info (if available)
1427
+ */
1428
+ getBatteryInfo(): Promise<BatteryInfo | null>;
1429
+ /**
1430
+ * Get current heartbeat interval
1431
+ */
1432
+ getCurrentInterval(): number;
1433
+ /**
1434
+ * Check if heartbeat is paused due to low battery
1435
+ */
1436
+ isPausedDueToBattery(): boolean;
1437
+ /**
1438
+ * Start the heartbeat interval
1439
+ */
1440
+ private startInterval;
1441
+ /**
1442
+ * Update interval based on network conditions
1443
+ */
1444
+ private updateIntervalForNetwork;
1445
+ /**
1446
+ * Set up network change handler
1447
+ */
1448
+ private setupNetworkChangeHandler;
1449
+ /**
1450
+ * Set up battery monitoring
1451
+ */
1452
+ private setupBatteryMonitoring;
1020
1453
  /**
1021
1454
  * Set up visibility change handler
1022
1455
  */
@@ -1027,6 +1460,423 @@ declare class HeartbeatManager {
1027
1460
  private log;
1028
1461
  }
1029
1462
 
1463
+ /**
1464
+ * WakeLockManager - Screen Wake Lock API wrapper
1465
+ * Prevents device screen from dimming/locking when needed
1466
+ */
1467
+
1468
+ interface WakeLockManagerOptions {
1469
+ config?: WakeLockConfig;
1470
+ debug?: boolean;
1471
+ onAcquired?: (event: WakeLockAcquiredEvent) => void;
1472
+ onReleased?: (event: WakeLockReleasedEvent) => void;
1473
+ onError?: (event: WakeLockErrorEvent) => void;
1474
+ }
1475
+ /**
1476
+ * WakeLockManager provides a simple API for the Screen Wake Lock API
1477
+ * with automatic reacquisition when the page becomes visible again
1478
+ */
1479
+ declare class WakeLockManager {
1480
+ private wakeLock;
1481
+ private config;
1482
+ private debug;
1483
+ private visibilityHandler;
1484
+ private releaseHandler;
1485
+ private shouldReacquire;
1486
+ private onAcquired?;
1487
+ private onReleased?;
1488
+ private onError?;
1489
+ constructor(options?: WakeLockManagerOptions);
1490
+ /**
1491
+ * Check if Screen Wake Lock API is supported
1492
+ */
1493
+ isSupported(): boolean;
1494
+ /**
1495
+ * Get current wake lock state
1496
+ */
1497
+ getState(): WakeLockState;
1498
+ /**
1499
+ * Acquire a screen wake lock
1500
+ * Prevents the screen from dimming or locking
1501
+ */
1502
+ acquire(): Promise<boolean>;
1503
+ /**
1504
+ * Release the screen wake lock
1505
+ */
1506
+ release(): Promise<void>;
1507
+ /**
1508
+ * Toggle wake lock on/off
1509
+ */
1510
+ toggle(): Promise<boolean>;
1511
+ /**
1512
+ * Check if wake lock is currently active
1513
+ */
1514
+ isActive(): boolean;
1515
+ /**
1516
+ * Destroy the manager and release any held locks
1517
+ */
1518
+ destroy(): Promise<void>;
1519
+ /**
1520
+ * Handle wake lock release (from system)
1521
+ */
1522
+ private handleRelease;
1523
+ /**
1524
+ * Set up visibility change handler for auto-reacquire
1525
+ */
1526
+ private setupVisibilityHandler;
1527
+ /**
1528
+ * Remove visibility change handler
1529
+ */
1530
+ private removeVisibilityHandler;
1531
+ /**
1532
+ * Log message if debug is enabled
1533
+ */
1534
+ private log;
1535
+ }
1536
+
1537
+ /**
1538
+ * OfflineQueueManager - Queue and retry failed requests when offline
1539
+ * Uses IndexedDB for persistence across sessions
1540
+ */
1541
+
1542
+ interface OfflineQueueManagerOptions {
1543
+ config?: OfflineQueueConfig;
1544
+ debug?: boolean;
1545
+ onRequestQueued?: (request: QueuedRequest) => void;
1546
+ onRequestProcessed?: (result: QueueProcessResult) => void;
1547
+ onQueueEmpty?: () => void;
1548
+ onError?: (error: Error) => void;
1549
+ }
1550
+ /**
1551
+ * OfflineQueueManager handles queuing failed requests and retrying them
1552
+ * when the network connection is restored
1553
+ */
1554
+ declare class OfflineQueueManager {
1555
+ private db;
1556
+ private config;
1557
+ private debug;
1558
+ private isProcessing;
1559
+ private onlineHandler;
1560
+ private onRequestQueued?;
1561
+ private onRequestProcessed?;
1562
+ private onQueueEmpty?;
1563
+ private onError?;
1564
+ constructor(options?: OfflineQueueManagerOptions);
1565
+ /**
1566
+ * Initialize the offline queue manager
1567
+ */
1568
+ initialize(): Promise<void>;
1569
+ /**
1570
+ * Destroy the manager and clean up listeners
1571
+ */
1572
+ destroy(): void;
1573
+ /**
1574
+ * Add a request to the queue
1575
+ */
1576
+ queueRequest(url: string, method: QueuedRequest['method'], options?: {
1577
+ headers?: Record<string, string>;
1578
+ body?: string;
1579
+ requestType?: QueuedRequestType;
1580
+ priority?: number;
1581
+ maxRetries?: number;
1582
+ metadata?: Record<string, any>;
1583
+ }): Promise<number | null>;
1584
+ /**
1585
+ * Process all queued requests
1586
+ */
1587
+ processQueue(): Promise<QueueProcessResult[]>;
1588
+ /**
1589
+ * Process a single queued request
1590
+ */
1591
+ private processRequest;
1592
+ /**
1593
+ * Determine if a request should be retried based on status code
1594
+ */
1595
+ private shouldRetryStatus;
1596
+ /**
1597
+ * Update retry count and schedule next retry
1598
+ */
1599
+ private updateRetryCount;
1600
+ /**
1601
+ * Get queue statistics
1602
+ */
1603
+ getStats(): Promise<OfflineQueueStats>;
1604
+ /**
1605
+ * Clear all queued requests
1606
+ */
1607
+ clearQueue(): Promise<void>;
1608
+ /**
1609
+ * Check if queue has pending requests
1610
+ */
1611
+ hasPendingRequests(): Promise<boolean>;
1612
+ /**
1613
+ * Get number of queued requests
1614
+ */
1615
+ getQueueCount(): Promise<number>;
1616
+ private openDatabase;
1617
+ private addToStore;
1618
+ private removeFromStore;
1619
+ private getAllRequests;
1620
+ private removeOldestRequest;
1621
+ private cleanupOldRequests;
1622
+ private promisifyRequest;
1623
+ private delay;
1624
+ private log;
1625
+ }
1626
+
1627
+ /**
1628
+ * IOSInstallBanner Internationalization (i18n)
1629
+ * Language translations for iOS install instructions
1630
+ */
1631
+ /**
1632
+ * Supported language codes
1633
+ */
1634
+ type IOSBannerLanguage = 'en' | 'es' | 'fr' | 'de' | 'it' | 'pt' | 'nl' | 'ru' | 'zh' | 'ja' | 'ko' | 'ar' | 'he' | 'hi' | 'tr' | 'pl' | 'sv' | 'da' | 'no' | 'fi';
1635
+ /**
1636
+ * Language strings interface
1637
+ */
1638
+ interface IOSBannerStrings {
1639
+ title: string;
1640
+ description: string;
1641
+ buttonText: string;
1642
+ closeText: string;
1643
+ step1: string;
1644
+ step2: string;
1645
+ step3: string;
1646
+ shareIconHint: string;
1647
+ shareIconDescription: string;
1648
+ }
1649
+ /**
1650
+ * Built-in language translations (20 languages)
1651
+ */
1652
+ declare const IOS_BANNER_TRANSLATIONS: Record<IOSBannerLanguage, IOSBannerStrings>;
1653
+ /**
1654
+ * Detect browser language and map to supported language
1655
+ */
1656
+ declare function detectBrowserLanguage(): IOSBannerLanguage;
1657
+
1658
+ /**
1659
+ * IOSInstallBanner - Styled iOS Safari install instructions banner
1660
+ * Shows users how to add the PWA to their home screen on iOS
1661
+ * Supports 20 languages with auto-detection
1662
+ */
1663
+
1664
+ interface IOSInstallBannerOptions {
1665
+ config?: IOSInstallBannerConfig;
1666
+ /** Language code (e.g., 'en', 'es', 'fr') - auto-detected if not provided */
1667
+ language?: IOSBannerLanguage;
1668
+ /** Custom strings to override built-in translations */
1669
+ customStrings?: Partial<IOSBannerStrings>;
1670
+ debug?: boolean;
1671
+ onShow?: () => void;
1672
+ onDismiss?: () => void;
1673
+ onInstallClick?: () => void;
1674
+ }
1675
+ declare class IOSInstallBanner {
1676
+ private config;
1677
+ private styles;
1678
+ private strings;
1679
+ private language;
1680
+ private debug;
1681
+ private bannerElement;
1682
+ private overlayElement;
1683
+ private onShow?;
1684
+ private onDismiss?;
1685
+ private onInstallClick?;
1686
+ constructor(options?: IOSInstallBannerOptions);
1687
+ /**
1688
+ * Get current language
1689
+ */
1690
+ getLanguage(): IOSBannerLanguage;
1691
+ /**
1692
+ * Get current strings
1693
+ */
1694
+ getStrings(): IOSBannerStrings;
1695
+ /**
1696
+ * Set language and update strings
1697
+ */
1698
+ setLanguage(language: IOSBannerLanguage): void;
1699
+ /**
1700
+ * Get current banner state
1701
+ */
1702
+ getState(): IOSInstallBannerState;
1703
+ /**
1704
+ * Check if device is iOS Safari (eligible for banner)
1705
+ */
1706
+ isEligible(): boolean;
1707
+ /**
1708
+ * Check if PWA is already installed (running in standalone mode)
1709
+ */
1710
+ isInstalled(): boolean;
1711
+ /**
1712
+ * Check if banner was previously dismissed
1713
+ */
1714
+ wasDismissed(): boolean;
1715
+ /**
1716
+ * Show the install banner if eligible
1717
+ */
1718
+ show(): Promise<boolean>;
1719
+ /**
1720
+ * Hide the install banner
1721
+ */
1722
+ hide(): void;
1723
+ /**
1724
+ * Dismiss the banner and remember the dismissal
1725
+ */
1726
+ dismiss(): void;
1727
+ /**
1728
+ * Reset dismissal state (for testing or after significant time)
1729
+ */
1730
+ resetDismissal(): void;
1731
+ /**
1732
+ * Get iOS install steps (localized)
1733
+ */
1734
+ getInstallSteps(): string[];
1735
+ /**
1736
+ * Create and inject the banner element
1737
+ */
1738
+ private createBanner;
1739
+ /**
1740
+ * Log message if debug is enabled
1741
+ */
1742
+ private log;
1743
+ }
1744
+
1745
+ /**
1746
+ * NotificationPermissionPrompt - Soft prompt before native notification permission
1747
+ * Improves opt-in rates by explaining value before triggering browser prompt
1748
+ * Supports 20 languages with auto-detection
1749
+ */
1750
+
1751
+ /**
1752
+ * Notification prompt strings interface
1753
+ */
1754
+ interface NotificationPromptStrings {
1755
+ title: string;
1756
+ description: string;
1757
+ allowButton: string;
1758
+ laterButton: string;
1759
+ iosNote?: string;
1760
+ }
1761
+ /**
1762
+ * Built-in translations (20 languages)
1763
+ */
1764
+ declare const NOTIFICATION_PROMPT_TRANSLATIONS: Record<IOSBannerLanguage, NotificationPromptStrings>;
1765
+ /**
1766
+ * Prompt styles
1767
+ */
1768
+ interface NotificationPromptStyles {
1769
+ backgroundColor: string;
1770
+ textColor: string;
1771
+ primaryButtonBackground: string;
1772
+ primaryButtonText: string;
1773
+ secondaryButtonBackground: string;
1774
+ secondaryButtonText: string;
1775
+ borderRadius: string;
1776
+ boxShadow: string;
1777
+ }
1778
+ /**
1779
+ * Prompt configuration
1780
+ */
1781
+ interface NotificationPromptConfig {
1782
+ /** Enable the soft prompt */
1783
+ enabled?: boolean;
1784
+ /** Custom icon URL */
1785
+ iconUrl?: string;
1786
+ /** Show delay in ms */
1787
+ showDelay?: number;
1788
+ /** Days to remember dismissal */
1789
+ dismissalDays?: number;
1790
+ /** Position: 'top' | 'center' | 'bottom' */
1791
+ position?: 'top' | 'center' | 'bottom';
1792
+ /** Custom styles */
1793
+ customStyles?: Partial<NotificationPromptStyles>;
1794
+ /** Show iOS-specific note */
1795
+ showIOSNote?: boolean;
1796
+ }
1797
+ interface NotificationPromptOptions {
1798
+ config?: NotificationPromptConfig;
1799
+ /** Language code - auto-detected if not provided */
1800
+ language?: IOSBannerLanguage;
1801
+ /** Custom strings to override translations */
1802
+ customStrings?: Partial<NotificationPromptStrings>;
1803
+ debug?: boolean;
1804
+ /** Called when user clicks allow */
1805
+ onAllow?: () => void;
1806
+ /** Called when user clicks later */
1807
+ onLater?: () => void;
1808
+ /** Called when prompt is shown */
1809
+ onShow?: () => void;
1810
+ }
1811
+ /**
1812
+ * NotificationPermissionPrompt - Soft prompt before native browser permission
1813
+ */
1814
+ declare class NotificationPermissionPrompt {
1815
+ private config;
1816
+ private styles;
1817
+ private strings;
1818
+ private language;
1819
+ private debug;
1820
+ private promptElement;
1821
+ private overlayElement;
1822
+ private onAllow?;
1823
+ private onLater?;
1824
+ private onShow?;
1825
+ constructor(options?: NotificationPromptOptions);
1826
+ /**
1827
+ * Get current language
1828
+ */
1829
+ getLanguage(): IOSBannerLanguage;
1830
+ /**
1831
+ * Set language
1832
+ */
1833
+ setLanguage(language: IOSBannerLanguage): void;
1834
+ /**
1835
+ * Check if should show prompt
1836
+ */
1837
+ shouldShow(): boolean;
1838
+ /**
1839
+ * Check if previously dismissed
1840
+ */
1841
+ wasDismissed(): boolean;
1842
+ /**
1843
+ * Check if device is iOS
1844
+ */
1845
+ private isIOS;
1846
+ /**
1847
+ * Check if PWA is installed (standalone mode)
1848
+ */
1849
+ private isInstalled;
1850
+ /**
1851
+ * Show the soft prompt
1852
+ */
1853
+ show(): Promise<boolean>;
1854
+ /**
1855
+ * Hide the prompt
1856
+ */
1857
+ hide(): void;
1858
+ /**
1859
+ * Dismiss and remember
1860
+ */
1861
+ dismiss(): void;
1862
+ /**
1863
+ * Reset dismissal state
1864
+ */
1865
+ resetDismissal(): void;
1866
+ /**
1867
+ * Handle allow click - triggers native permission
1868
+ */
1869
+ handleAllow(): Promise<NotificationPermission>;
1870
+ /**
1871
+ * Create and inject the prompt element
1872
+ */
1873
+ private createPrompt;
1874
+ /**
1875
+ * Log message if debug is enabled
1876
+ */
1877
+ private log;
1878
+ }
1879
+
1030
1880
  /**
1031
1881
  * HMAC Authentication Utilities
1032
1882
  * Implements CloudSignal's HMAC signature scheme for API authentication
@@ -1189,9 +2039,11 @@ declare class IndexedDBStorage {
1189
2039
  * CloudSignal PWA SDK
1190
2040
  * Progressive Web App features with push notifications, installation management, and device tracking
1191
2041
  *
2042
+ * v1.1.0: Added WakeLock, OfflineQueue, iOS Install Banner, Network-aware Heartbeat, Notification Analytics
2043
+ *
1192
2044
  * @packageDocumentation
1193
2045
  */
1194
2046
 
1195
- declare const VERSION = "1.0.0";
2047
+ declare const VERSION = "1.1.0";
1196
2048
 
1197
- export { type BeforeInstallPromptEvent, CloudSignalPWA, type ConfigLoadedEvent, DeviceDetector, type DeviceInfo, type DisplayMode, type EventHandler, type HeartbeatConfig, type HeartbeatEvent, HeartbeatManager, IndexedDBStorage, type InitializeResult, type InstallAvailableEvent, type InstallResult, type InstallResultEvent, InstallationManager, type InstallationState, type LoggerFunction, type NetworkEvent, type NetworkInfo, type NotificationAction, type NotificationPayload, type NotificationPermissionState, type NotificationPreferences, type PWACapabilities, type PWAConfig, type PWAEvent, type PWAServiceConfig, type PWASupportLevel, type PermissionEvent, type PlatformInfo, type PushClickedEvent, PushNotificationManager, type PushReceivedEvent, type PushRegisteredEvent, type PushSubscriptionData, type RegisterOptions, type Registration, type RegistrationStatus, type RegistrationStatusResponse, type ScreenInfo, type ServiceWorkerConfig, type ServiceWorkerEvent, ServiceWorkerManager, VERSION, CloudSignalPWA as default, deviceDetector, generateAuthHeaders, generateBrowserFingerprint, generateHMACSignature, generateTrackingId, getRegistrationId, getStorageItem, isValidUUID, makeAuthenticatedRequest, removeRegistrationId, removeStorageItem, setRegistrationId, setStorageItem };
2049
+ export { type AdaptiveHeartbeatConfig, type BatteryInfo, type BeforeInstallPromptEvent, CloudSignalPWA, type ConfigLoadedEvent, DeviceDetector, type DeviceInfo, type DisplayMode, type EventHandler, type HeartbeatConfig, type HeartbeatEvent, HeartbeatManager, type IOSBannerLanguage, type IOSBannerStrings, IOSInstallBanner, type IOSInstallBannerConfig$1 as IOSInstallBannerConfig, type IOSInstallBannerOptions$1 as IOSInstallBannerOptions, IOS_BANNER_TRANSLATIONS, IndexedDBStorage, type InitializeResult, type InstallAvailableEvent, type InstallResult, type InstallResultEvent, InstallationManager, type InstallationState, type LoggerFunction, NOTIFICATION_PROMPT_TRANSLATIONS, type NetworkConnectionInfo, type NetworkEvent, type NetworkInfo, type NotificationAction, type NotificationAnalyticsConfig, type NotificationAnalyticsEvent, type NotificationPayload, NotificationPermissionPrompt, type NotificationPermissionState, type NotificationPreferences, type IOSBannerLanguage as NotificationPromptLanguage, type NotificationPromptStrings, type OfflineQueueConfig$1 as OfflineQueueConfig, OfflineQueueManager, type OfflineQueueStats, type PWACapabilities, type PWAConfig, type PWAEvent, type PWAServiceConfig, type PWASupportLevel, type PermissionEvent, type PlatformInfo, type PushClickedEvent, PushNotificationManager, type PushReceivedEvent, type PushRegisteredEvent, type PushSubscriptionData, type QueueProcessResult, type QueuedRequest, type RegisterOptions, type Registration, type RegistrationStatus, type RegistrationStatusResponse, type ScreenInfo, type ServiceWorkerConfig, type ServiceWorkerEvent, ServiceWorkerManager, VERSION, type WakeLockConfig$1 as WakeLockConfig, WakeLockManager, type WakeLockState, CloudSignalPWA as default, detectBrowserLanguage, deviceDetector, generateAuthHeaders, generateBrowserFingerprint, generateHMACSignature, generateTrackingId, getRegistrationId, getStorageItem, isValidUUID, makeAuthenticatedRequest, removeRegistrationId, removeStorageItem, setRegistrationId, setStorageItem };