@btsd/aitu-bridge 0.3.2 → 0.3.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/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +1 -1
- package/dist/index.modern.js.map +1 -1
- package/dist/index.module.js +1 -1
- package/dist/index.module.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/index.ts +21 -0
- package/src/version.ts +1 -1
package/src/index.ts
CHANGED
|
@@ -146,6 +146,7 @@ export interface AituBridge {
|
|
|
146
146
|
setCustomBackArrowMode: (enabled: boolean) => Promise<ResponseType>;
|
|
147
147
|
getCustomBackArrowMode: () => Promise<boolean>;
|
|
148
148
|
setCustomBackArrowVisible: (visible: boolean) => Promise<ResponseType>;
|
|
149
|
+
openPayment: (transactionId: string) => Promise<ResponseType>;
|
|
149
150
|
setCustomBackArrowOnClickHandler: (handler: BackArrowClickHandlerType) => void;
|
|
150
151
|
}
|
|
151
152
|
|
|
@@ -172,6 +173,7 @@ const setHeaderMenuItemClickHandlerMethod = 'setHeaderMenuItemClickHandler';
|
|
|
172
173
|
const setCustomBackArrowModeMethod = 'setCustomBackArrowMode';
|
|
173
174
|
const getCustomBackArrowModeMethod = 'getCustomBackArrowMode';
|
|
174
175
|
const setCustomBackArrowVisibleMethod = 'setCustomBackArrowVisible';
|
|
176
|
+
const openPaymentMethod = 'openPayment'
|
|
175
177
|
const setCustomBackArrowOnClickHandlerMethod = 'setCustomBackArrowOnClickHandler';
|
|
176
178
|
|
|
177
179
|
const android = typeof window !== 'undefined' && (window as any).AndroidBridge;
|
|
@@ -187,6 +189,10 @@ const buildBridge = (): AituBridge => {
|
|
|
187
189
|
})
|
|
188
190
|
|
|
189
191
|
window.addEventListener('message', (e) => {
|
|
192
|
+
if(typeof e.data !== 'string') {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
|
|
190
196
|
const message = JSON.parse(e.data)
|
|
191
197
|
|
|
192
198
|
if (message && message['method']) {
|
|
@@ -600,6 +606,19 @@ const buildBridge = (): AituBridge => {
|
|
|
600
606
|
}
|
|
601
607
|
}
|
|
602
608
|
|
|
609
|
+
const openPayment = (reqId, transactionId: string) => {
|
|
610
|
+
const isAndroid = android && android[openPaymentMethod];
|
|
611
|
+
const isIos = ios && ios[openPaymentMethod];
|
|
612
|
+
|
|
613
|
+
if (isAndroid) {
|
|
614
|
+
android[openPaymentMethod](reqId, transactionId);
|
|
615
|
+
} else if (isIos) {
|
|
616
|
+
ios[openPaymentMethod].postMessage({ reqId, transactionId });
|
|
617
|
+
} else {
|
|
618
|
+
console.log('--openPayment-isUnknown');
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
|
|
603
622
|
|
|
604
623
|
const invokePromise = promisifyInvoke(invoke, sub);
|
|
605
624
|
const storagePromise = promisifyStorage(storage, sub);
|
|
@@ -621,6 +640,7 @@ const buildBridge = (): AituBridge => {
|
|
|
621
640
|
const setCustomBackArrowModePromise = promisifyMethod(setCustomBackArrowMode, setCustomBackArrowModeMethod, sub);
|
|
622
641
|
const getCustomBackArrowModePromise = promisifyMethod(getCustomBackArrowMode, getCustomBackArrowModeMethod, sub);
|
|
623
642
|
const setCustomBackArrowVisiblePromise = promisifyMethod(setCustomBackArrowVisible, setCustomBackArrowVisibleMethod, sub);
|
|
643
|
+
const openPaymentPromise = promisifyMethod(openPayment, openPaymentMethod, sub);
|
|
624
644
|
|
|
625
645
|
return {
|
|
626
646
|
version: String(LIB_VERSION),
|
|
@@ -658,6 +678,7 @@ const buildBridge = (): AituBridge => {
|
|
|
658
678
|
setCustomBackArrowMode: setCustomBackArrowModePromise,
|
|
659
679
|
getCustomBackArrowMode: getCustomBackArrowModePromise,
|
|
660
680
|
setCustomBackArrowVisible: setCustomBackArrowVisiblePromise,
|
|
681
|
+
openPayment: openPaymentPromise,
|
|
661
682
|
setCustomBackArrowOnClickHandler,
|
|
662
683
|
}
|
|
663
684
|
}
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const LIB_VERSION = "0.3.
|
|
1
|
+
export const LIB_VERSION = "0.3.4";
|