@necto/platform 1.5.0 → 1.5.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/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +35 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +12 -4
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var i=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var w=(t,o)=>{for(var r in o)i(t,r,{get:o[r],enumerable:!0})},c=(t,o,r,a)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of u(o))!p.call(t,n)&&n!==r&&i(t,n,{get:()=>o[n],enumerable:!(a=l(o,n))||a.enumerable});return t};var g=t=>c(i({},"__esModule",{value:!0}),t);var b={};w(b,{isAndroid:()=>v,isCtrlKeyPressed:()=>P,isIOS:()=>y,isIPad:()=>f,isIPhone:()=>d,isMac:()=>e});module.exports=g(b);function m(t){return typeof window<"u"&&window.navigator!=null?t.test(window.navigator.platform):!1}var e=()=>m(/^Mac/i);function x(t){return typeof window>"u"||window.navigator==null?!1:window.navigator.userAgentData?.brands.some(o=>t.test(o.brand))||t.test(window.navigator.userAgent)}var v=()=>x(/Android/i);function s(t){return typeof window<"u"&&window.navigator!=null?t.test(window.navigator.platform):!1}var d=()=>s(/^iPhone/i),f=()=>s(/^iPad/i)||e()&&navigator.maxTouchPoints>1,y=()=>d()||f();function P(t){return e()?t.metaKey??!1:t.ctrlKey??!1}0&&(module.exports={isAndroid,isCtrlKeyPressed,isIOS,isIPad,isIPhone,isMac});
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/isMac.ts","../src/isAndroid.ts","../src/isIOS.ts","../src/isCtrlKeyPressed.ts"],"sourcesContent":["/**\n * Copyright (c) Corinvo, LLC. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\n// WARNING: This code is not recommended for use.\n// It contains significant issues and may lead to unexpected behavior.\n// Please avoid using or referencing this implementation.\n\nexport * from './isMac';\nexport * from './isAndroid';\nexport * from './isIOS';\nexport * from './isCtrlKeyPressed';\n","/**\n * Copyright (c) Corinvo, LLC. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\n// WARNING: This code is not recommended for use.\n// It contains significant issues and may lead to unexpected behavior.\n// Please avoid using or referencing this implementation.\n\nfunction testPlatform(re: RegExp) {\n return typeof window !== 'undefined' && window.navigator != null\n ? //@ts-ignore\n re.test(window.navigator.platform)\n : false;\n}\n\nexport const isMac = () => testPlatform(/^Mac/i);\n","// WARNING: This code is not recommended for use.\n// It contains significant issues and may lead to unexpected behavior.\n// Please avoid using or referencing this implementation.\n\nfunction testUserAgent(re: RegExp) {\n if (typeof window === 'undefined' || window.navigator == null) {\n return false;\n }\n return (\n //@ts-ignore\n window.navigator.userAgentData?.brands.some(\n (brand: { brand: string; version: string }) => re.test(brand.brand)\n ) || re.test(window.navigator.userAgent)\n );\n}\n\nexport const isAndroid = () => testUserAgent(/Android/i);\n","// WARNING: This code is not recommended for use.\n// It contains significant issues and may lead to unexpected behavior.\n// Please avoid using or referencing this implementation.\n\nimport { isMac } from './isMac';\n\nfunction testPlatform(re: RegExp) {\n return typeof window !== 'undefined' && window.navigator != null\n ? //@ts-ignore\n re.test(window.navigator.platform)\n : false;\n}\n\nexport const isIPhone = () => {\n return testPlatform(/^iPhone/i);\n};\n\nexport const isIPad = () => {\n return (\n testPlatform(/^iPad/i) ||\n // iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support.\n (isMac() && navigator.maxTouchPoints > 1)\n );\n};\n\nexport const isIOS = () => {\n return isIPhone() || isIPad();\n};\n","/**\n * Copyright (c) Corinvo, LLC. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { isMac } from './isMac';\n\n/**\n * Checks if the Ctrl key (or Cmd on Mac) is pressed.\n * On Mac, the Cmd key is used instead of Ctrl for most shortcuts.\n *\n * @param event - The keyboard or mouse event to check.\n * @returns True if Ctrl (or Cmd on Mac) is pressed.\n */\nexport function isCtrlKeyPressed(event: {\n ctrlKey?: boolean;\n metaKey?: boolean;\n}): boolean {\n return isMac() ? (event.metaKey ?? false) : (event.ctrlKey ?? false);\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,eAAAE,EAAA,qBAAAC,EAAA,UAAAC,EAAA,WAAAC,EAAA,aAAAC,EAAA,UAAAC,IAAA,eAAAC,EAAAR,GCYA,SAASS,EAAaC,EAAY,CAChC,OAAO,OAAO,OAAW,KAAe,OAAO,WAAa,KAExDA,EAAG,KAAK,OAAO,UAAU,QAAQ,EACjC,EACN,CAEO,IAAMC,EAAQ,IAAMF,EAAa,OAAO,ECf/C,SAASG,EAAcC,EAAY,CACjC,OAAI,OAAO,OAAW,KAAe,OAAO,WAAa,KAChD,GAIP,OAAO,UAAU,eAAe,OAAO,KACpCC,GAA8CD,EAAG,KAAKC,EAAM,KAAK,CACpE,GAAKD,EAAG,KAAK,OAAO,UAAU,SAAS,CAE3C,CAEO,IAAME,EAAY,IAAMH,EAAc,UAAU,ECVvD,SAASI,EAAaC,EAAY,CAChC,OAAO,OAAO,OAAW,KAAe,OAAO,WAAa,KAExDA,EAAG,KAAK,OAAO,UAAU,QAAQ,EACjC,EACN,CAEO,IAAMC,EAAW,IACfF,EAAa,UAAU,EAGnBG,EAAS,IAElBH,EAAa,QAAQ,GAEpBI,EAAM,GAAK,UAAU,eAAiB,EAI9BC,EAAQ,IACZH,EAAS,GAAKC,EAAO,ECTvB,SAASG,EAAiBC,EAGrB,CACV,OAAOC,EAAM,EAAKD,EAAM,SAAW,GAAUA,EAAM,SAAW,EAChE","names":["index_exports","__export","isAndroid","isCtrlKeyPressed","isIOS","isIPad","isIPhone","isMac","__toCommonJS","testPlatform","re","isMac","testUserAgent","re","brand","isAndroid","testPlatform","re","isIPhone","isIPad","isMac","isIOS","isCtrlKeyPressed","event","isMac"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
declare const isMac: () => boolean;
|
|
9
|
+
|
|
10
|
+
declare const isAndroid: () => any;
|
|
11
|
+
|
|
12
|
+
declare const isIPhone: () => boolean;
|
|
13
|
+
declare const isIPad: () => boolean;
|
|
14
|
+
declare const isIOS: () => boolean;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Copyright (c) Corinvo, LLC. and affiliates.
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the MIT license found in the
|
|
20
|
+
* LICENSE file in the root directory of this source tree.
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Checks if the Ctrl key (or Cmd on Mac) is pressed.
|
|
25
|
+
* On Mac, the Cmd key is used instead of Ctrl for most shortcuts.
|
|
26
|
+
*
|
|
27
|
+
* @param event - The keyboard or mouse event to check.
|
|
28
|
+
* @returns True if Ctrl (or Cmd on Mac) is pressed.
|
|
29
|
+
*/
|
|
30
|
+
declare function isCtrlKeyPressed(event: {
|
|
31
|
+
ctrlKey?: boolean;
|
|
32
|
+
metaKey?: boolean;
|
|
33
|
+
}): boolean;
|
|
34
|
+
|
|
35
|
+
export { isAndroid, isCtrlKeyPressed, isIOS, isIPad, isIPhone, isMac };
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
function r(t){return typeof window<"u"&&window.navigator!=null?t.test(window.navigator.platform):!1}var o=()=>r(/^Mac/i);function i(t){return typeof window>"u"||window.navigator==null?!1:window.navigator.userAgentData?.brands.some(e=>t.test(e.brand))||t.test(window.navigator.userAgent)}var f=()=>i(/Android/i);function n(t){return typeof window<"u"&&window.navigator!=null?t.test(window.navigator.platform):!1}var a=()=>n(/^iPhone/i),s=()=>n(/^iPad/i)||o()&&navigator.maxTouchPoints>1,p=()=>a()||s();function g(t){return o()?t.metaKey??!1:t.ctrlKey??!1}export{f as isAndroid,g as isCtrlKeyPressed,p as isIOS,s as isIPad,a as isIPhone,o as isMac};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/
|
|
1
|
+
{"version":3,"sources":["../src/isMac.ts","../src/isAndroid.ts","../src/isIOS.ts","../src/isCtrlKeyPressed.ts"],"sourcesContent":["/**\n * Copyright (c) Corinvo, LLC. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\n// WARNING: This code is not recommended for use.\n// It contains significant issues and may lead to unexpected behavior.\n// Please avoid using or referencing this implementation.\n\nfunction testPlatform(re: RegExp) {\n return typeof window !== 'undefined' && window.navigator != null\n ? //@ts-ignore\n re.test(window.navigator.platform)\n : false;\n}\n\nexport const isMac = () => testPlatform(/^Mac/i);\n","// WARNING: This code is not recommended for use.\n// It contains significant issues and may lead to unexpected behavior.\n// Please avoid using or referencing this implementation.\n\nfunction testUserAgent(re: RegExp) {\n if (typeof window === 'undefined' || window.navigator == null) {\n return false;\n }\n return (\n //@ts-ignore\n window.navigator.userAgentData?.brands.some(\n (brand: { brand: string; version: string }) => re.test(brand.brand)\n ) || re.test(window.navigator.userAgent)\n );\n}\n\nexport const isAndroid = () => testUserAgent(/Android/i);\n","// WARNING: This code is not recommended for use.\n// It contains significant issues and may lead to unexpected behavior.\n// Please avoid using or referencing this implementation.\n\nimport { isMac } from './isMac';\n\nfunction testPlatform(re: RegExp) {\n return typeof window !== 'undefined' && window.navigator != null\n ? //@ts-ignore\n re.test(window.navigator.platform)\n : false;\n}\n\nexport const isIPhone = () => {\n return testPlatform(/^iPhone/i);\n};\n\nexport const isIPad = () => {\n return (\n testPlatform(/^iPad/i) ||\n // iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support.\n (isMac() && navigator.maxTouchPoints > 1)\n );\n};\n\nexport const isIOS = () => {\n return isIPhone() || isIPad();\n};\n","/**\n * Copyright (c) Corinvo, LLC. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { isMac } from './isMac';\n\n/**\n * Checks if the Ctrl key (or Cmd on Mac) is pressed.\n * On Mac, the Cmd key is used instead of Ctrl for most shortcuts.\n *\n * @param event - The keyboard or mouse event to check.\n * @returns True if Ctrl (or Cmd on Mac) is pressed.\n */\nexport function isCtrlKeyPressed(event: {\n ctrlKey?: boolean;\n metaKey?: boolean;\n}): boolean {\n return isMac() ? (event.metaKey ?? false) : (event.ctrlKey ?? false);\n}\n"],"mappings":"AAYA,SAASA,EAAaC,EAAY,CAChC,OAAO,OAAO,OAAW,KAAe,OAAO,WAAa,KAExDA,EAAG,KAAK,OAAO,UAAU,QAAQ,EACjC,EACN,CAEO,IAAMC,EAAQ,IAAMF,EAAa,OAAO,ECf/C,SAASG,EAAcC,EAAY,CACjC,OAAI,OAAO,OAAW,KAAe,OAAO,WAAa,KAChD,GAIP,OAAO,UAAU,eAAe,OAAO,KACpCC,GAA8CD,EAAG,KAAKC,EAAM,KAAK,CACpE,GAAKD,EAAG,KAAK,OAAO,UAAU,SAAS,CAE3C,CAEO,IAAME,EAAY,IAAMH,EAAc,UAAU,ECVvD,SAASI,EAAaC,EAAY,CAChC,OAAO,OAAO,OAAW,KAAe,OAAO,WAAa,KAExDA,EAAG,KAAK,OAAO,UAAU,QAAQ,EACjC,EACN,CAEO,IAAMC,EAAW,IACfF,EAAa,UAAU,EAGnBG,EAAS,IAElBH,EAAa,QAAQ,GAEpBI,EAAM,GAAK,UAAU,eAAiB,EAI9BC,EAAQ,IACZH,EAAS,GAAKC,EAAO,ECTvB,SAASG,EAAiBC,EAGrB,CACV,OAAOC,EAAM,EAAKD,EAAM,SAAW,GAAUA,EAAM,SAAW,EAChE","names":["testPlatform","re","isMac","testUserAgent","re","brand","isAndroid","testPlatform","re","isIPhone","isIPad","isMac","isIOS","isCtrlKeyPressed","event","isMac"]}
|
package/package.json
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@necto/platform",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "Necto's library for detecting platforms, devices, other device related information.",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
7
7
|
"README.md"
|
|
8
8
|
],
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
9
|
+
"type": "module",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"main": "./dist/index.cjs",
|
|
12
|
+
"module": "./dist/index.js",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js",
|
|
17
|
+
"require": "./dist/index.cjs"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
12
20
|
"author": "Corinvo OSS Team",
|
|
13
21
|
"license": "MIT",
|
|
14
22
|
"devDependencies": {
|