is-where 1.0.2 → 2.0.1
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/README.md +4 -0
- package/dist/index.d.ts +12 -9
- package/dist/index.js +70 -16
- package/package.json +20 -67
- package/dist/cjs/index.cjs +0 -31
- package/dist/cjs/index.d.cts +0 -45
package/README.md
CHANGED
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
|
-
|
|
2
|
-
|
|
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
|
-
|
|
5
|
-
|
|
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
|
-
|
|
8
|
-
|
|
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
|
-
|
|
11
|
-
|
|
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
|
-
|
|
14
|
-
|
|
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
|
-
|
|
17
|
-
|
|
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
|
-
|
|
20
|
-
|
|
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,23 @@
|
|
|
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
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
4
|
+
"type": "module",
|
|
5
|
+
"version": "2.0.1",
|
|
6
|
+
"description": "JS environment check functions like `isWebkit() isSafari() isBrowser() isNode()` etc. A simple & small integration.",
|
|
10
7
|
"exports": {
|
|
11
|
-
".":
|
|
12
|
-
|
|
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
|
-
}
|
|
8
|
+
".": "./dist/index.js",
|
|
9
|
+
"./*": "./dist/*"
|
|
21
10
|
},
|
|
22
11
|
"files": [
|
|
23
12
|
"dist"
|
|
24
13
|
],
|
|
25
14
|
"engines": {
|
|
26
|
-
"node": ">=
|
|
15
|
+
"node": ">=18"
|
|
27
16
|
},
|
|
28
17
|
"scripts": {
|
|
29
18
|
"test": "vitest run",
|
|
30
|
-
"lint": "tsc --noEmit && eslint ./src
|
|
31
|
-
"build": "
|
|
19
|
+
"lint": "tsc --noEmit && eslint ./src",
|
|
20
|
+
"build": "del-cli dist && tsc",
|
|
32
21
|
"release": "npm run lint && del dist && npm run build && np"
|
|
33
22
|
},
|
|
34
23
|
"repository": {
|
|
@@ -68,57 +57,21 @@
|
|
|
68
57
|
},
|
|
69
58
|
"homepage": "https://github.com/mesqueeb/is-where#readme",
|
|
70
59
|
"devDependencies": {
|
|
71
|
-
"@
|
|
72
|
-
"@
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"eslint
|
|
76
|
-
"eslint-
|
|
77
|
-
"np": "^
|
|
78
|
-
"prettier": "^2.
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"vitest": "^0.31.0"
|
|
84
|
-
},
|
|
85
|
-
"ava": {
|
|
86
|
-
"extensions": {
|
|
87
|
-
"ts": "module"
|
|
88
|
-
},
|
|
89
|
-
"nodeArguments": [
|
|
90
|
-
"--loader=ts-node/esm"
|
|
91
|
-
]
|
|
60
|
+
"@cycraft/tsconfig": "^0.1.1",
|
|
61
|
+
"@eslint/js": "^9.1.1",
|
|
62
|
+
"@types/node": "^20.12.8",
|
|
63
|
+
"del-cli": "^5.1.0",
|
|
64
|
+
"eslint": "^8.57.0",
|
|
65
|
+
"eslint-config-prettier": "^9.1.0",
|
|
66
|
+
"np": "^10.0.5",
|
|
67
|
+
"prettier": "^3.2.5",
|
|
68
|
+
"prettier-plugin-jsdoc": "^1.3.0",
|
|
69
|
+
"typescript": "^5.4.5",
|
|
70
|
+
"typescript-eslint": "^7.8.0",
|
|
71
|
+
"vitest": "^1.5.3"
|
|
92
72
|
},
|
|
93
73
|
"np": {
|
|
94
74
|
"yarn": false,
|
|
95
75
|
"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
76
|
}
|
|
124
77
|
}
|
package/dist/cjs/index.cjs
DELETED
|
@@ -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;
|
package/dist/cjs/index.d.cts
DELETED
|
@@ -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 };
|