@pmate/bridge 0.1.6 → 0.1.7
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/package.json +4 -4
- package/src/index.ts +2 -0
- package/src/internal.ts +12 -0
- package/src/types.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pmate/bridge",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"files": [
|
|
5
5
|
"src",
|
|
6
6
|
"global.d.ts"
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@types/react": "
|
|
19
|
-
"react": "
|
|
18
|
+
"@types/react": "^19.2.7",
|
|
19
|
+
"react": "^19.1.1"
|
|
20
20
|
},
|
|
21
21
|
"main": "src/index.ts",
|
|
22
22
|
"exports": {
|
|
23
23
|
".": "./src/index.ts"
|
|
24
24
|
}
|
|
25
|
-
}
|
|
25
|
+
}
|
package/src/index.ts
CHANGED
package/src/internal.ts
CHANGED
|
@@ -47,6 +47,18 @@ export function readIsPmate() {
|
|
|
47
47
|
return hasWindow() && !!(window as PmateWindow).isPmate
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
function normalizedPlatform(info?: Pick<DeviceInfo, "platform"> | null) {
|
|
51
|
+
return info?.platform?.trim().toLowerCase() ?? ""
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function isAndroidDevice(info?: Pick<DeviceInfo, "platform"> | null) {
|
|
55
|
+
return normalizedPlatform(info) === "android"
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function isIOSDevice(info?: Pick<DeviceInfo, "platform"> | null) {
|
|
59
|
+
return normalizedPlatform(info) === "ios"
|
|
60
|
+
}
|
|
61
|
+
|
|
50
62
|
async function callBridge<T>(functionName: string, params?: unknown): Promise<T | undefined> {
|
|
51
63
|
try {
|
|
52
64
|
return await (window as PmateWindow).PmateBridge?.call<T>(functionName, params)
|