@scalar/helpers 0.4.0 → 0.4.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/CHANGELOG.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-mac-os.d.ts","sourceRoot":"","sources":["../../src/general/is-mac-os.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"is-mac-os.d.ts","sourceRoot":"","sources":["../../src/general/is-mac-os.ts"],"names":[],"mappings":"AAkBA,eAAO,MAAM,OAAO,eAanB,CAAA"}
|
|
@@ -1,9 +1,20 @@
|
|
|
1
|
+
const getUserAgentDataPlatform = (nav) => {
|
|
2
|
+
const userAgentData = Reflect.get(nav, "userAgentData");
|
|
3
|
+
if (!userAgentData || typeof userAgentData !== "object") {
|
|
4
|
+
return void 0;
|
|
5
|
+
}
|
|
6
|
+
if (!("platform" in userAgentData) || typeof userAgentData.platform !== "string") {
|
|
7
|
+
return void 0;
|
|
8
|
+
}
|
|
9
|
+
return userAgentData.platform;
|
|
10
|
+
};
|
|
1
11
|
const isMacOS = () => {
|
|
2
12
|
if (typeof navigator === "undefined") {
|
|
3
13
|
return false;
|
|
4
14
|
}
|
|
5
|
-
|
|
6
|
-
|
|
15
|
+
const userAgentDataPlatform = getUserAgentDataPlatform(navigator);
|
|
16
|
+
if (userAgentDataPlatform) {
|
|
17
|
+
return userAgentDataPlatform.toLowerCase().includes("mac");
|
|
7
18
|
}
|
|
8
19
|
return /Mac/.test(navigator.userAgent);
|
|
9
20
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/general/is-mac-os.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Checks whether the user is on macOS\n * Uses the modern navigator.userAgentData API with a fallback to navigator.userAgent\n */\
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/**\n * Checks whether the user is on macOS\n * Uses the modern navigator.userAgentData API with a fallback to navigator.userAgent\n */\nconst getUserAgentDataPlatform = (nav: Navigator): string | undefined => {\n const userAgentData: unknown = Reflect.get(nav, 'userAgentData')\n\n if (!userAgentData || typeof userAgentData !== 'object') {\n return undefined\n }\n\n if (!('platform' in userAgentData) || typeof userAgentData.platform !== 'string') {\n return undefined\n }\n\n return userAgentData.platform\n}\n\nexport const isMacOS = () => {\n if (typeof navigator === 'undefined') {\n return false\n }\n\n // Modern approach using navigator.userAgentData\n const userAgentDataPlatform = getUserAgentDataPlatform(navigator)\n if (userAgentDataPlatform) {\n return userAgentDataPlatform.toLowerCase().includes('mac')\n }\n\n // Fallback to userAgent\n return /Mac/.test(navigator.userAgent)\n}\n"],
|
|
5
|
+
"mappings": "AAIA,MAAM,2BAA2B,CAAC,QAAuC;AACvE,QAAM,gBAAyB,QAAQ,IAAI,KAAK,eAAe;AAE/D,MAAI,CAAC,iBAAiB,OAAO,kBAAkB,UAAU;AACvD,WAAO;AAAA,EACT;AAEA,MAAI,EAAE,cAAc,kBAAkB,OAAO,cAAc,aAAa,UAAU;AAChF,WAAO;AAAA,EACT;AAEA,SAAO,cAAc;AACvB;AAEO,MAAM,UAAU,MAAM;AAC3B,MAAI,OAAO,cAAc,aAAa;AACpC,WAAO;AAAA,EACT;AAGA,QAAM,wBAAwB,yBAAyB,SAAS;AAChE,MAAI,uBAAuB;AACzB,WAAO,sBAAsB,YAAY,EAAE,SAAS,KAAK;AAAA,EAC3D;AAGA,SAAO,MAAM,KAAK,UAAU,SAAS;AACvC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|