@osovitny/anatoly 3.19.19 → 3.19.21

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.
@@ -3444,35 +3444,31 @@ class BrowserService {
3444
3444
  constructor(platform, breakpointObserver) {
3445
3445
  this.platform = platform;
3446
3446
  this.breakpointObserver = breakpointObserver;
3447
+ // Breakpoint status flags
3447
3448
  this.isMobileScreen = false;
3448
3449
  this.isTabletScreen = false;
3449
- this.isDesktopScreen = false;
3450
- //Private Streams
3450
+ // Reactive update stream
3451
3451
  this._updated = new BehaviorSubject(null);
3452
- //Public Streams
3453
3452
  this.updated$ = this._updated.asObservable();
3453
+ // Cached lowercase UserAgent string
3454
+ this.userAgent = navigator.userAgent.toLowerCase();
3454
3455
  this.init();
3455
3456
  }
3456
3457
  init() {
3457
- this.breakpointObserver.observe([Breakpoints.Handset, Breakpoints.Tablet, Breakpoints.Web]).subscribe(result => {
3458
- this.isMobileScreen = false;
3459
- this.isTabletScreen = false;
3460
- this.isDesktopScreen = false;
3461
- if (this.breakpointObserver.isMatched(Breakpoints.Handset)) {
3462
- this.isMobileScreen = true;
3463
- }
3464
- else if (this.breakpointObserver.isMatched(Breakpoints.Tablet)) {
3465
- this.isTabletScreen = true;
3466
- }
3467
- else {
3468
- this.isDesktopScreen = true;
3469
- }
3458
+ // Listen to Angular CDK breakpoints for screen size changes
3459
+ this.breakpointObserver
3460
+ .observe([Breakpoints.Handset, Breakpoints.Tablet, Breakpoints.Web])
3461
+ .subscribe(result => {
3462
+ const breakpoints = result.breakpoints;
3463
+ this.isMobileScreen = breakpoints[Breakpoints.Handset] || false;
3464
+ this.isTabletScreen = breakpoints[Breakpoints.Tablet] || false;
3470
3465
  this.fireUpdated();
3471
3466
  });
3472
3467
  }
3473
3468
  fireUpdated() {
3474
3469
  this._updated.next(null);
3475
3470
  }
3471
+ // Checks if the app is running inside an iframe
3476
3472
  isIframe() {
3477
3473
  return window !== window.parent && !window.opener;
3478
3474
  }
@@ -3480,57 +3476,51 @@ class BrowserService {
3480
3476
  return this.platform.TRIDENT;
3481
3477
  }
3482
3478
  isMobile() {
3483
- if (!this.platform || !this.platform.isBrowser) {
3479
+ if (!this.platform?.isBrowser)
3484
3480
  return false;
3485
- }
3486
- /*
3487
- const mobileRegex = new RegExp(
3488
- "(android|bb\\d+|meego).+mobile|" +
3489
- "avantgo|bada\\/|blackberry|blazer|compal|elaine|fennec|hiptop|" +
3490
- "iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|" +
3491
- "mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|" +
3492
- "p(ixi|re)\\/|plucker|pocket|psp|series(4|6)0|symbian|treo|" +
3493
- "up\\.(browser|link)|vodafone|wap|windows ce|xda|xiino|" +
3494
- "nokia|samsung|htc|motorola|sonyericsson|iemobile",
3495
- "i"
3496
- );
3497
- const isMobileUserAgent = mobileRegex.test(userAgent);
3498
- */
3499
- const userAgent = navigator.userAgent || navigator.vendor;
3500
- const isIPad = /ipad/i.test(userAgent);
3501
- return (this.platform.ANDROID && this.isMobileScreen) ||
3502
- (this.platform.IOS && !isIPad && this.isMobileScreen);
3481
+ const mobileRegex = new RegExp("(android.+mobile)|" + // Android phones
3482
+ "iphone|ipod|" + // Apple phones
3483
+ "blackberry|" + // Modern BlackBerry
3484
+ "mobile safari|" + // Safari in mobile mode
3485
+ "sm-[a-z0-9]+|" + // Samsung Galaxy phones (SM-G series)
3486
+ "pixel [0-9a-z]+|" + // Google Pixel phones
3487
+ "redmi|mi [0-9a-z]+|poco|" + // Xiaomi/Redmi/Poco
3488
+ "oneplus|oppo|vivo|realme|" + // Other Android phones
3489
+ "huawei|honor|" + // Huawei/Honor
3490
+ "motorola|moto|" + // Motorola
3491
+ "nokia|infinix|tecno", // Other brands
3492
+ "i");
3493
+ return mobileRegex.test(this.userAgent) && this.isMobileScreen;
3503
3494
  }
3504
3495
  isTablet() {
3505
- if (!this.platform || !this.platform.isBrowser) {
3496
+ if (!this.platform?.isBrowser)
3506
3497
  return false;
3507
- }
3508
- /*
3509
- const tabletRegex = new RegExp(
3510
- "ipad|" +
3511
- "android(?!.*mobile)|" +
3498
+ const tabletRegex = new RegExp("ipad|" + // Apple iPads
3499
+ "android(?!.*mobile)|" + // Android tablets (exclude phones)
3512
3500
  "tablet|kindle|playbook|silk|" +
3513
- "nexus 7|nexus 10|" +
3514
- "fire|sm-t|tab|gt-p|sch-i|xoom|tf101|" +
3515
- "kftt|kfot|kfjw|kfsowi|a500|rim\\w",
3516
- "i"
3517
- );
3518
- const isTabletUserAgent = tabletRegex.test(userAgent);
3519
- */
3520
- const userAgent = navigator.userAgent || navigator.vendor;
3521
- const isIPad = /ipad/i.test(userAgent);
3522
- return (this.platform.ANDROID && this.isTabletScreen) ||
3523
- (this.platform.IOS && isIPad && this.isTabletScreen);
3524
- }
3525
- isDesktopMacOS() {
3526
- const userAgent = navigator.userAgent || navigator.vendor;
3527
- const isMac = /macintosh|mac os x/i.test(userAgent);
3528
- const isIPad = /ipad/i.test(userAgent);
3529
- return isMac && !isIPad;
3501
+ "nexus 7|nexus 10|" + // Google Nexus tablets
3502
+ "fire|kf[a-z0-9]+|" + // Amazon Fire tablets
3503
+ "sm-t|sm-x|gt-p|sch-i|xoom|tf101|" + // Samsung Galaxy Tab tablets
3504
+ "tab(?!let)|" + // Match "tab" but not "tablet"
3505
+ "tangor|tangorpro|" + // Google Pixel Tablet
3506
+ "pad\\s?[0-9]*|23043rp34g|" + // Xiaomi Pad
3507
+ "tb[0-9a-z\\-]+|" + // Lenovo Tab
3508
+ "mrx-al09|" + // Huawei MatePad Pro
3509
+ "x926b", // Galaxy Tab S10 Ultra
3510
+ "i");
3511
+ return tabletRegex.test(this.userAgent) && this.isTabletScreen;
3530
3512
  }
3531
3513
  isMobileOrTablet() {
3532
3514
  return this.isMobile() || this.isTablet();
3533
3515
  }
3516
+ isDesktopMacOS() {
3517
+ // Check macOS desktop user agent (Macintosh or Mac OS X)
3518
+ const isMac = /macintosh|mac os x/i.test(this.userAgent);
3519
+ // Exclude iPhone and iPad (iOS devices)
3520
+ const isIPhone = /iphone/i.test(this.userAgent);
3521
+ const isIPad = /ipad/i.test(this.userAgent);
3522
+ return isMac && !isIPhone && !isIPad;
3523
+ }
3534
3524
  isDesktop() {
3535
3525
  if (this.isDesktopMacOS()) {
3536
3526
  return true;