@pallasoft/ps-utilities 2.13.0 → 2.14.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.
@@ -0,0 +1,6 @@
1
+ export declare const DeviceConfig: {
2
+ ios: RegExp;
3
+ macintosh: RegExp;
4
+ mobile: RegExp;
5
+ touchPointsForTablet: number;
6
+ };
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DeviceConfig = void 0;
4
+ exports.DeviceConfig = {
5
+ ios: /iPhone|iPad|iPod/i,
6
+ macintosh: /Macintosh/i,
7
+ mobile: /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|Tablet|Silk|Kindle/i,
8
+ touchPointsForTablet: 1,
9
+ };
@@ -0,0 +1,5 @@
1
+ import type { DeviceData } from '../models/device-data';
2
+ export declare class DeviceService {
3
+ static fromUserAgent(userAgent: string, maxTouchPoints: number): DeviceData;
4
+ static current(): DeviceData;
5
+ }
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DeviceService = void 0;
4
+ var device_config_1 = require("./constants/device-config");
5
+ var DeviceService = /** @class */ (function () {
6
+ function DeviceService() {
7
+ }
8
+ DeviceService.fromUserAgent = function (userAgent, maxTouchPoints) {
9
+ var isIPadOS = device_config_1.DeviceConfig.macintosh.test(userAgent) && maxTouchPoints > device_config_1.DeviceConfig.touchPointsForTablet;
10
+ return {
11
+ isIOS: device_config_1.DeviceConfig.ios.test(userAgent) || isIPadOS,
12
+ isMobile: device_config_1.DeviceConfig.mobile.test(userAgent) || isIPadOS,
13
+ };
14
+ };
15
+ DeviceService.current = function () {
16
+ if (typeof navigator === 'undefined')
17
+ return { isIOS: false, isMobile: false };
18
+ return DeviceService.fromUserAgent(navigator.userAgent, navigator.maxTouchPoints);
19
+ };
20
+ return DeviceService;
21
+ }());
22
+ exports.DeviceService = DeviceService;
@@ -1,2 +1,3 @@
1
1
  export * from './debounce-service';
2
+ export * from './device-service';
2
3
  export * from './http-service';
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./debounce-service"), exports);
18
+ __exportStar(require("./device-service"), exports);
18
19
  __exportStar(require("./http-service"), exports);
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ import * as CommonNamespace from './common';
3
3
  export declare const Common: typeof CommonNamespace;
4
4
  export declare const Client: typeof ClientNamespace;
5
5
  export { AmountDirection } from './common/constants/amount-direction';
6
+ export type { DeviceData } from './models/device-data';
6
7
  export type { EmailPreviewInput } from './models/email-preview-input';
7
8
  export type { SignedTokenHeader } from './models/signed-token-header';
8
9
  export type { SignedTokenKeyPair } from './models/signed-token-key-pair';
@@ -0,0 +1,4 @@
1
+ export interface DeviceData {
2
+ isIOS: boolean;
3
+ isMobile: boolean;
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pallasoft/ps-utilities",
3
- "version": "2.13.0",
3
+ "version": "2.14.0",
4
4
  "private": false,
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",