@osovitny/anatoly 3.19.19 → 3.19.20

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,33 @@ 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
3450
  this.isDesktopScreen = false;
3450
- //Private Streams
3451
+ // Reactive update stream
3451
3452
  this._updated = new BehaviorSubject(null);
3452
- //Public Streams
3453
3453
  this.updated$ = this._updated.asObservable();
3454
+ // Cached lowercase UserAgent string
3455
+ this.userAgent = navigator.userAgent.toLowerCase();
3454
3456
  this.init();
3455
3457
  }
3456
3458
  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
- }
3459
+ // Listen to Angular CDK breakpoints for screen size changes
3460
+ this.breakpointObserver
3461
+ .observe([Breakpoints.Handset, Breakpoints.Tablet, Breakpoints.Web])
3462
+ .subscribe(result => {
3463
+ const breakpoints = result.breakpoints;
3464
+ this.isMobileScreen = breakpoints[Breakpoints.Handset] || false;
3465
+ this.isTabletScreen = breakpoints[Breakpoints.Tablet] || false;
3466
+ this.isDesktopScreen = breakpoints[Breakpoints.Web] || false;
3470
3467
  this.fireUpdated();
3471
3468
  });
3472
3469
  }
3473
3470
  fireUpdated() {
3474
3471
  this._updated.next(null);
3475
3472
  }
3473
+ // Checks if the app is running inside an iframe
3476
3474
  isIframe() {
3477
3475
  return window !== window.parent && !window.opener;
3478
3476
  }
@@ -3480,62 +3478,53 @@ class BrowserService {
3480
3478
  return this.platform.TRIDENT;
3481
3479
  }
3482
3480
  isMobile() {
3483
- if (!this.platform || !this.platform.isBrowser) {
3481
+ if (!this.platform?.isBrowser)
3484
3482
  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);
3483
+ const mobileRegex = new RegExp("(android.+mobile)|" + // Android phones
3484
+ "iphone|ipod|" + // Apple phones
3485
+ "blackberry|" + // Modern BlackBerry
3486
+ "mobile safari|" + // Safari in mobile mode
3487
+ "sm-[a-z0-9]+|" + // Samsung Galaxy phones (SM-G series)
3488
+ "pixel [0-9a-z]+|" + // Google Pixel phones
3489
+ "redmi|mi [0-9a-z]+|poco|" + // Xiaomi/Redmi/Poco
3490
+ "oneplus|oppo|vivo|realme|" + // Other Android phones
3491
+ "huawei|honor|" + // Huawei/Honor
3492
+ "motorola|moto|" + // Motorola
3493
+ "nokia|infinix|tecno", // Other brands
3494
+ "i");
3495
+ return mobileRegex.test(this.userAgent) && this.isMobileScreen;
3503
3496
  }
3504
3497
  isTablet() {
3505
- if (!this.platform || !this.platform.isBrowser) {
3498
+ if (!this.platform?.isBrowser)
3506
3499
  return false;
3507
- }
3508
- /*
3509
- const tabletRegex = new RegExp(
3510
- "ipad|" +
3511
- "android(?!.*mobile)|" +
3500
+ const tabletRegex = new RegExp("ipad|" + // Apple iPads
3501
+ "android(?!.*mobile)|" + // Android tablets (exclude phones)
3512
3502
  "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;
3503
+ "nexus 7|nexus 10|" + // Google Nexus tablets
3504
+ "fire|kf[a-z0-9]+|" + // Amazon Fire tablets
3505
+ "sm-t|sm-x|gt-p|sch-i|xoom|tf101|" + // Samsung Galaxy Tab tablets
3506
+ "tab(?!let)|" + // Match "tab" but not "tablet"
3507
+ "tangor|tangorpro|" + // Google Pixel Tablet
3508
+ "pad\\s?[0-9]*|23043rp34g|" + // Xiaomi Pad
3509
+ "tb[0-9a-z\\-]+|" + // Lenovo Tab
3510
+ "mrx-al09|" + // Huawei MatePad Pro
3511
+ "x926b", // Galaxy Tab S10 Ultra
3512
+ "i");
3513
+ return tabletRegex.test(this.userAgent) && this.isTabletScreen;
3530
3514
  }
3531
3515
  isMobileOrTablet() {
3532
3516
  return this.isMobile() || this.isTablet();
3533
3517
  }
3518
+ isDesktopMacOS() {
3519
+ // Check macOS desktop user agent (Macintosh or Mac OS X)
3520
+ const isMac = /macintosh|mac os x/i.test(this.userAgent);
3521
+ // Exclude iPhone and iPad (iOS devices)
3522
+ const isIPhone = /iphone/i.test(this.userAgent);
3523
+ const isIPad = /ipad/i.test(this.userAgent);
3524
+ return isMac && !isIPhone && !isIPad;
3525
+ }
3534
3526
  isDesktop() {
3535
- if (this.isDesktopMacOS()) {
3536
- return true;
3537
- }
3538
- return !this.isMobileOrTablet();
3527
+ return this.isDesktopMacOS() || (!this.isMobileOrTablet() && this.isDesktopScreen);
3539
3528
  }
3540
3529
  static { this.ɵfac = function BrowserService_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || BrowserService)(i0.ɵɵinject(i1$5.Platform), i0.ɵɵinject(i2.BreakpointObserver)); }; }
3541
3530
  static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: BrowserService, factory: BrowserService.ɵfac, providedIn: 'root' }); }