is-where 1.0.2 → 2.0.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.ts CHANGED
@@ -1,23 +1,28 @@
1
+ /**
2
+ * returns `true` if the current environment supports touch events
3
+ * @see https://stackoverflow.com/a/63666289/2697506
4
+ */
5
+ export declare function isTouchSupported(): boolean;
1
6
  /**
2
7
  * returns `true` if the current environment is Node
3
8
  */
4
- declare function isNode(): boolean;
9
+ export declare function isNode(): boolean;
5
10
  /**
6
11
  * returns `true` if the current environment is a browser
7
12
  */
8
- declare function isBrowser(): boolean;
13
+ export declare function isBrowser(): boolean;
9
14
  /**
10
15
  * returns `true` if the current environment is a Web Worker
11
16
  */
12
- declare function isWebWorker(): boolean;
17
+ export declare function isWebWorker(): boolean;
13
18
  /**
14
19
  * returns `true` if the current environment is JS DOM
15
20
  */
16
- declare function isJsDom(): boolean;
21
+ export declare function isJsDom(): boolean;
17
22
  /**
18
23
  * returns `true` if the current environment is Deno
19
24
  */
20
- declare function isDeno(): boolean;
25
+ export declare function isDeno(): boolean;
21
26
  /**
22
27
  * returns `true` if the current browser is based on WebKit
23
28
  *
@@ -30,7 +35,7 @@ declare function isDeno(): boolean;
30
35
  *
31
36
  * All mobile browsers on iOS & iPadOS use WebKit
32
37
  */
33
- declare function isWebKit(): boolean;
38
+ export declare function isWebKit(): boolean;
34
39
  /**
35
40
  * returns `true` if the current browser is Safari
36
41
  *
@@ -40,6 +45,4 @@ declare function isWebKit(): boolean;
40
45
  *
41
46
  * It does not include other browser on iOS & iPadOS
42
47
  */
43
- declare function isSafari(): boolean;
44
-
45
- export { isBrowser, isDeno, isJsDom, isNode, isSafari, isWebKit, isWebWorker };
48
+ export declare function isSafari(): boolean;
package/dist/index.js CHANGED
@@ -1,23 +1,77 @@
1
- function isNode() {
2
- return typeof process !== "undefined" && process.versions != null && process.versions.node != null;
1
+ /**
2
+ * returns `true` if the current environment supports touch events
3
+ * @see https://stackoverflow.com/a/63666289/2697506
4
+ */
5
+ export function isTouchSupported() {
6
+ return isBrowser() && matchMedia('(hover: none)').matches;
3
7
  }
4
- function isBrowser() {
5
- return typeof window !== "undefined" && typeof window.document !== "undefined";
8
+ /**
9
+ * returns `true` if the current environment is Node
10
+ */
11
+ export function isNode() {
12
+ return typeof process !== 'undefined' && process.versions != null && process.versions.node != null;
6
13
  }
7
- function isWebWorker() {
8
- return typeof self === "object" && self.constructor && self.constructor.name === "DedicatedWorkerGlobalScope";
14
+ /**
15
+ * returns `true` if the current environment is a browser
16
+ */
17
+ export function isBrowser() {
18
+ return typeof window !== 'undefined' && typeof window.document !== 'undefined';
9
19
  }
10
- function isJsDom() {
11
- return typeof window !== "undefined" && window.name === "nodejs" || typeof navigator !== "undefined" && (navigator.userAgent.includes("Node.js") || navigator.userAgent.includes("jsdom"));
20
+ /**
21
+ * returns `true` if the current environment is a Web Worker
22
+ */
23
+ export function isWebWorker() {
24
+ return (typeof self === 'object' &&
25
+ self.constructor &&
26
+ self.constructor.name === 'DedicatedWorkerGlobalScope');
12
27
  }
13
- function isDeno() {
14
- return typeof Deno !== "undefined" && typeof Deno.core !== "undefined";
28
+ /**
29
+ * returns `true` if the current environment is JS DOM
30
+ */
31
+ export function isJsDom() {
32
+ return ((typeof window !== 'undefined' && window.name === 'nodejs') ||
33
+ (typeof navigator !== 'undefined' &&
34
+ (navigator.userAgent.includes('Node.js') || navigator.userAgent.includes('jsdom'))));
15
35
  }
16
- function isWebKit() {
17
- return isBrowser() && !!navigator.vendor && navigator.vendor.indexOf("Apple") !== -1 && !!navigator.userAgent;
36
+ /**
37
+ * returns `true` if the current environment is Deno
38
+ */
39
+ export function isDeno() {
40
+ // @ts-expect-error Deno types not found
41
+ return typeof Deno !== 'undefined' && typeof Deno.core !== 'undefined';
18
42
  }
19
- function isSafari() {
20
- return isBrowser() && !!navigator.vendor && navigator.vendor.indexOf("Apple") !== -1 && !!navigator.userAgent && navigator.userAgent.indexOf("CriOS") == -1 && navigator.userAgent.indexOf("FxiOS") == -1;
43
+ /**
44
+ * returns `true` if the current browser is based on WebKit
45
+ *
46
+ * This includes:
47
+ * - Safari on macOS
48
+ * - Safari on iOS & iPadOS
49
+ * - Google Chrome on iOS & iPadOS
50
+ * - Firefox on iOS & iPadOS
51
+ * - ... on iOS & iPadOS
52
+ *
53
+ * All mobile browsers on iOS & iPadOS use WebKit
54
+ */
55
+ export function isWebKit() {
56
+ return (isBrowser() &&
57
+ !!navigator.vendor &&
58
+ navigator.vendor.indexOf('Apple') !== -1 &&
59
+ !!navigator.userAgent);
60
+ }
61
+ /**
62
+ * returns `true` if the current browser is Safari
63
+ *
64
+ * This includes:
65
+ * - Safari on macOS
66
+ * - Safari on iOS & iPadOS
67
+ *
68
+ * It does not include other browser on iOS & iPadOS
69
+ */
70
+ export function isSafari() {
71
+ return (isBrowser() &&
72
+ !!navigator.vendor &&
73
+ navigator.vendor.indexOf('Apple') !== -1 &&
74
+ !!navigator.userAgent &&
75
+ navigator.userAgent.indexOf('CriOS') == -1 &&
76
+ navigator.userAgent.indexOf('FxiOS') == -1);
21
77
  }
22
-
23
- export { isBrowser, isDeno, isJsDom, isNode, isSafari, isWebKit, isWebWorker };
package/package.json CHANGED
@@ -1,34 +1,20 @@
1
1
  {
2
2
  "name": "is-where",
3
- "version": "1.0.2",
4
- "description": "JS environment check functions like `isWebkit() isSafari() isBrowser() isNode()` etc. A simple & small integration.",
5
- "type": "module",
6
3
  "sideEffects": false,
7
- "types": "./dist/index.d.ts",
8
- "module": "./dist/index.js",
9
- "main": "./dist/index.js",
10
- "exports": {
11
- ".": {
12
- "require": {
13
- "types": "./dist/cjs/index.d.cts",
14
- "default": "./dist/cjs/index.cjs"
15
- },
16
- "import": {
17
- "types": "./dist/index.d.ts",
18
- "default": "./dist/index.js"
19
- }
20
- }
21
- },
4
+ "type": "module",
5
+ "version": "2.0.0",
6
+ "description": "JS environment check functions like `isWebkit() isSafari() isBrowser() isNode()` etc. A simple & small integration.",
7
+ "exports": "./index.js",
22
8
  "files": [
23
9
  "dist"
24
10
  ],
25
11
  "engines": {
26
- "node": ">=14"
12
+ "node": ">=18"
27
13
  },
28
14
  "scripts": {
29
15
  "test": "vitest run",
30
- "lint": "tsc --noEmit && eslint ./src --ext .ts",
31
- "build": "rollup -c ./rollup.config.js",
16
+ "lint": "tsc --noEmit && eslint ./src",
17
+ "build": "del-cli dist && tsc",
32
18
  "release": "npm run lint && del dist && npm run build && np"
33
19
  },
34
20
  "repository": {
@@ -68,57 +54,20 @@
68
54
  },
69
55
  "homepage": "https://github.com/mesqueeb/is-where#readme",
70
56
  "devDependencies": {
71
- "@typescript-eslint/eslint-plugin": "^5.59.2",
72
- "@typescript-eslint/parser": "^5.59.2",
73
- "del-cli": "^5.0.0",
74
- "eslint": "^8.40.0",
75
- "eslint-config-prettier": "^8.8.0",
76
- "eslint-plugin-tree-shaking": "^1.10.0",
77
- "np": "^7.7.0",
78
- "prettier": "^2.8.8",
79
- "rollup": "^3.23.0",
80
- "rollup-plugin-dts": "^5.3.0",
81
- "rollup-plugin-esbuild": "^5.0.0",
82
- "typescript": "^4.9.5",
83
- "vitest": "^0.31.0"
84
- },
85
- "ava": {
86
- "extensions": {
87
- "ts": "module"
88
- },
89
- "nodeArguments": [
90
- "--loader=ts-node/esm"
91
- ]
57
+ "@cycraft/tsconfig": "^0.1.1",
58
+ "@eslint/js": "^9.1.1",
59
+ "@types/node": "^20.12.8",
60
+ "del-cli": "^5.1.0",
61
+ "eslint": "^8.57.0",
62
+ "eslint-config-prettier": "^9.1.0",
63
+ "np": "^10.0.5",
64
+ "prettier": "^3.2.5",
65
+ "typescript": "^5.4.5",
66
+ "typescript-eslint": "^7.8.0",
67
+ "vitest": "^1.5.3"
92
68
  },
93
69
  "np": {
94
70
  "yarn": false,
95
71
  "branch": "production"
96
- },
97
- "eslintConfig": {
98
- "ignorePatterns": [
99
- "node_modules",
100
- "dist",
101
- "scripts",
102
- "test"
103
- ],
104
- "root": true,
105
- "parser": "@typescript-eslint/parser",
106
- "plugins": [
107
- "@typescript-eslint",
108
- "tree-shaking"
109
- ],
110
- "extends": [
111
- "eslint:recommended",
112
- "plugin:@typescript-eslint/eslint-recommended",
113
- "plugin:@typescript-eslint/recommended",
114
- "prettier"
115
- ],
116
- "rules": {
117
- "@typescript-eslint/no-empty-function": "off",
118
- "@typescript-eslint/no-explicit-any": "off",
119
- "@typescript-eslint/ban-ts-ignore": "off",
120
- "tree-shaking/no-side-effects-in-initialization": "error",
121
- "@typescript-eslint/ban-ts-comment": "off"
122
- }
123
72
  }
124
73
  }
@@ -1,31 +0,0 @@
1
- 'use strict';
2
-
3
- function isNode() {
4
- return typeof process !== "undefined" && process.versions != null && process.versions.node != null;
5
- }
6
- function isBrowser() {
7
- return typeof window !== "undefined" && typeof window.document !== "undefined";
8
- }
9
- function isWebWorker() {
10
- return typeof self === "object" && self.constructor && self.constructor.name === "DedicatedWorkerGlobalScope";
11
- }
12
- function isJsDom() {
13
- return typeof window !== "undefined" && window.name === "nodejs" || typeof navigator !== "undefined" && (navigator.userAgent.includes("Node.js") || navigator.userAgent.includes("jsdom"));
14
- }
15
- function isDeno() {
16
- return typeof Deno !== "undefined" && typeof Deno.core !== "undefined";
17
- }
18
- function isWebKit() {
19
- return isBrowser() && !!navigator.vendor && navigator.vendor.indexOf("Apple") !== -1 && !!navigator.userAgent;
20
- }
21
- function isSafari() {
22
- return isBrowser() && !!navigator.vendor && navigator.vendor.indexOf("Apple") !== -1 && !!navigator.userAgent && navigator.userAgent.indexOf("CriOS") == -1 && navigator.userAgent.indexOf("FxiOS") == -1;
23
- }
24
-
25
- exports.isBrowser = isBrowser;
26
- exports.isDeno = isDeno;
27
- exports.isJsDom = isJsDom;
28
- exports.isNode = isNode;
29
- exports.isSafari = isSafari;
30
- exports.isWebKit = isWebKit;
31
- exports.isWebWorker = isWebWorker;
@@ -1,45 +0,0 @@
1
- /**
2
- * returns `true` if the current environment is Node
3
- */
4
- declare function isNode(): boolean;
5
- /**
6
- * returns `true` if the current environment is a browser
7
- */
8
- declare function isBrowser(): boolean;
9
- /**
10
- * returns `true` if the current environment is a Web Worker
11
- */
12
- declare function isWebWorker(): boolean;
13
- /**
14
- * returns `true` if the current environment is JS DOM
15
- */
16
- declare function isJsDom(): boolean;
17
- /**
18
- * returns `true` if the current environment is Deno
19
- */
20
- declare function isDeno(): boolean;
21
- /**
22
- * returns `true` if the current browser is based on WebKit
23
- *
24
- * This includes:
25
- * - Safari on macOS
26
- * - Safari on iOS & iPadOS
27
- * - Google Chrome on iOS & iPadOS
28
- * - Firefox on iOS & iPadOS
29
- * - ... on iOS & iPadOS
30
- *
31
- * All mobile browsers on iOS & iPadOS use WebKit
32
- */
33
- declare function isWebKit(): boolean;
34
- /**
35
- * returns `true` if the current browser is Safari
36
- *
37
- * This includes:
38
- * - Safari on macOS
39
- * - Safari on iOS & iPadOS
40
- *
41
- * It does not include other browser on iOS & iPadOS
42
- */
43
- declare function isSafari(): boolean;
44
-
45
- export { isBrowser, isDeno, isJsDom, isNode, isSafari, isWebKit, isWebWorker };