@microbt/environment 1.2.3 → 1.2.4
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/esm/hybrid.d.ts +1 -1
- package/dist/esm/hybrid.js +27 -46
- package/package.json +1 -1
package/dist/esm/hybrid.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare function bridgeCall(method: string, params: Record<string, string>, callback: (resp: string) => void): void;
|
|
2
|
-
export declare function bridgeBootstrap():
|
|
2
|
+
export declare function bridgeBootstrap(): void;
|
|
3
3
|
export declare function inSuperAcme(): boolean;
|
|
4
4
|
export declare function superAcmeVersion(): {
|
|
5
5
|
version: string;
|
package/dist/esm/hybrid.js
CHANGED
|
@@ -40,55 +40,36 @@ function bridgeCall(method, params, callback) {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
function bridgeBootstrap() {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
Logger.error("bootstrap:", error);
|
|
49
|
-
reject(error);
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
if (window.SuperAcme && typeof window.SuperAcme.call === "function") {
|
|
53
|
-
Logger.debug("bootstrap: SuperAcme bridge is ready");
|
|
54
|
-
callback();
|
|
55
|
-
resolve();
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
if (Array.isArray(window.WKWVJBCallbacks)) {
|
|
59
|
-
Logger.debug("bootstrap: Adding callback to existing WKWVJBCallbacks queue");
|
|
60
|
-
window.WKWVJBCallbacks.push(() => {
|
|
61
|
-
callback();
|
|
62
|
-
resolve();
|
|
63
|
-
});
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
Logger.debug("bootstrap: Initializing WKWVJBCallbacks");
|
|
67
|
-
window.WKWVJBCallbacks = [
|
|
68
|
-
() => {
|
|
69
|
-
callback();
|
|
70
|
-
resolve();
|
|
71
|
-
}
|
|
72
|
-
];
|
|
73
|
-
if (((_c = (_b = (_a = window.webkit) == null ? void 0 : _a.messageHandlers) == null ? void 0 : _b.iOS_Native_InjectJavascript) == null ? void 0 : _c.postMessage) && typeof window.webkit.messageHandlers.iOS_Native_InjectJavascript.postMessage === "function") {
|
|
74
|
-
window.webkit.messageHandlers.iOS_Native_InjectJavascript.postMessage(null);
|
|
75
|
-
} else {
|
|
76
|
-
const error = new Error("iOS bridge postMessage method not available or not a function");
|
|
77
|
-
Logger.warn(error.message);
|
|
78
|
-
reject(error);
|
|
79
|
-
}
|
|
43
|
+
function bootstrap(callback) {
|
|
44
|
+
var _a, _b, _c;
|
|
45
|
+
if (!callback || typeof callback !== "function") {
|
|
46
|
+
Logger.error("bootstrap: Invalid callback provided");
|
|
47
|
+
return;
|
|
80
48
|
}
|
|
81
|
-
if (
|
|
82
|
-
bootstrap
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
49
|
+
if (window.SuperAcme && typeof window.SuperAcme.call === "function") {
|
|
50
|
+
Logger.debug("bootstrap: SuperAcme bridge is ready");
|
|
51
|
+
return callback();
|
|
52
|
+
}
|
|
53
|
+
if (Array.isArray(window.WKWVJBCallbacks)) {
|
|
54
|
+
Logger.debug("bootstrap: Adding callback to existing WKWVJBCallbacks queue");
|
|
55
|
+
return window.WKWVJBCallbacks.push(callback);
|
|
56
|
+
}
|
|
57
|
+
Logger.debug("bootstrap: Initializing WKWVJBCallbacks");
|
|
58
|
+
window.WKWVJBCallbacks = [callback];
|
|
59
|
+
if (((_c = (_b = (_a = window.webkit) == null ? void 0 : _a.messageHandlers) == null ? void 0 : _b.iOS_Native_InjectJavascript) == null ? void 0 : _c.postMessage) && typeof window.webkit.messageHandlers.iOS_Native_InjectJavascript.postMessage === "function") {
|
|
60
|
+
window.webkit.messageHandlers.iOS_Native_InjectJavascript.postMessage(null);
|
|
88
61
|
} else {
|
|
89
|
-
|
|
62
|
+
Logger.warn("iOS bridge postMessage method not available or not a function");
|
|
90
63
|
}
|
|
91
|
-
}
|
|
64
|
+
}
|
|
65
|
+
if (iOSWebview) {
|
|
66
|
+
bootstrap(() => {
|
|
67
|
+
const ready = new CustomEvent("WebViewJavascriptBridgeReady", {
|
|
68
|
+
detail: { platform: "ios" }
|
|
69
|
+
});
|
|
70
|
+
document.dispatchEvent(ready);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
92
73
|
}
|
|
93
74
|
function inSuperAcme() {
|
|
94
75
|
return navigator.userAgent.toLowerCase().includes("superacme");
|