chayns-api 3.2.0-beta.0 → 3.2.0-beta.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/cjs/calls/index.js +3 -1
- package/dist/cjs/wrapper/AppWrapper.js +14 -0
- package/dist/cjs/wrapper/FrameWrapper.js +4 -0
- package/dist/cjs/wrapper/normalizeFunctions.js +24 -4
- package/dist/esm/calls/index.js +1 -0
- package/dist/esm/wrapper/AppWrapper.js +14 -0
- package/dist/esm/wrapper/FrameWrapper.js +4 -0
- package/dist/esm/wrapper/StaticChaynsApi.js +1 -0
- package/dist/esm/wrapper/normalizeFunctions.js +24 -4
- package/dist/types/calls/index.d.ts +6 -0
- package/dist/types/types/IChaynsReact.d.ts +1 -0
- package/dist/types/wrapper/StaticChaynsApi.d.ts +1 -0
- package/package.json +1 -1
package/dist/cjs/calls/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.vibrate = exports.user = exports.storageSetItem = exports.storageRemoveItem = exports.storageGetItem = exports.site = exports.setWaitCursor = exports.setTempDesignSettings = exports.setScanQrCode = exports.setRefreshScrollEnabled = exports.setOverlay = exports.setHeight = exports.setFloatingButton = exports.setDisplayTimeout = exports.setCustomCookie = exports.setAdminMode = exports.sendMessageToUser = exports.sendMessageToPage = exports.sendMessageToGroup = exports.selectPage = exports.scrollToY = exports.scrollByY = exports.removeWindowMetricsListener = exports.removeVisibilityChangeListener = exports.removeToolbarChangeListener = exports.removeScrollListener = exports.removeGeoLocationListener = exports.removeAppleSafeAreaListener = exports.removeAccessTokenChangeListener = exports.refreshData = exports.refreshAccessToken = exports.redirect = exports.parameters = exports.pages = exports.openVideo = exports.openUrl = exports.openMedia = exports.openImage = exports.navigateBack = exports.logout = exports.login = exports.language = exports.invokePaymentCall = exports.invokeDialogCall = exports.invokeCall = exports.getWindowMetrics = exports.getUserInfo = exports.getUser = exports.getStyleSettings = exports.getSite = exports.getScrollPosition = exports.getParameters = exports.getPages = exports.getLanguage = exports.getGeoLocation = exports.getEnvironment = exports.getDialogData = exports.getDevice = exports.getCustomFunction = exports.getCustomCookie = exports.getCurrentPage = exports.getChaynsHistoryLayer = exports.getAvailableSharingServices = exports.getAccessToken = exports.environment = exports.device = exports.customCallbackFunction = exports.createDialog = exports.addWindowMetricsListener = exports.addVisibilityChangeListener = exports.addToolbarChangeListener = exports.addScrollListener = exports.addGeoLocationListener = exports.addAppleSafeAreaListener = exports.addAnonymousAccount = exports.addAccessTokenChangeListener = void 0;
|
|
6
|
+
exports.vibrate = exports.user = exports.storageSetItem = exports.storageRemoveItem = exports.storageGetItem = exports.site = exports.setWaitCursor = exports.setTempDesignSettings = exports.setScanQrCode = exports.setRefreshScrollEnabled = exports.setOverlay = exports.setHeight = exports.setFloatingButton = exports.setDisplayTimeout = exports.setCustomCookie = exports.setAdminMode = exports.sendMessageToUser = exports.sendMessageToPage = exports.sendMessageToGroup = exports.selectPage = exports.scrollToY = exports.scrollByY = exports.removeWindowMetricsListener = exports.removeVisibilityChangeListener = exports.removeToolbarChangeListener = exports.removeScrollListener = exports.removeGeoLocationListener = exports.removeAppleSafeAreaListener = exports.removeAccessTokenChangeListener = exports.refreshData = exports.refreshAccessToken = exports.redirect = exports.parameters = exports.pages = exports.openVideo = exports.openUrl = exports.openMedia = exports.openImage = exports.navigateBack = exports.logout = exports.login = exports.language = exports.invokePaymentCall = exports.invokeDialogCall = exports.invokeCall = exports.getWindowMetrics = exports.getUserInfo = exports.getUser = exports.getStyleSettings = exports.getSite = exports.getScrollPosition = exports.getSafeArea = exports.getParameters = exports.getPages = exports.getLanguage = exports.getGeoLocation = exports.getEnvironment = exports.getDialogData = exports.getDevice = exports.getCustomFunction = exports.getCustomCookie = exports.getCurrentPage = exports.getChaynsHistoryLayer = exports.getAvailableSharingServices = exports.getAccessToken = exports.environment = exports.device = exports.customCallbackFunction = exports.createDialog = exports.addWindowMetricsListener = exports.addVisibilityChangeListener = exports.addToolbarChangeListener = exports.addScrollListener = exports.addGeoLocationListener = exports.addAppleSafeAreaListener = exports.addAnonymousAccount = exports.addAccessTokenChangeListener = void 0;
|
|
7
7
|
var _moduleWrapper = require("../components/moduleWrapper");
|
|
8
8
|
var _HistoryLayerContext = require("../contexts/HistoryLayerContext");
|
|
9
9
|
const addGeoLocationListener = (...args) => _moduleWrapper.moduleWrapper.current.functions.addGeoLocationListener(...args);
|
|
@@ -36,6 +36,8 @@ const getScrollPosition = (...args) => _moduleWrapper.moduleWrapper.current.func
|
|
|
36
36
|
exports.getScrollPosition = getScrollPosition;
|
|
37
37
|
const getWindowMetrics = (...args) => _moduleWrapper.moduleWrapper.current.functions.getWindowMetrics(...args);
|
|
38
38
|
exports.getWindowMetrics = getWindowMetrics;
|
|
39
|
+
const getSafeArea = (...args) => _moduleWrapper.moduleWrapper.current.functions.getAppleSafeArea(...args);
|
|
40
|
+
exports.getSafeArea = getSafeArea;
|
|
39
41
|
const invokeCall = (...args) => _moduleWrapper.moduleWrapper.current.functions.invokeCall(...args);
|
|
40
42
|
exports.invokeCall = invokeCall;
|
|
41
43
|
const invokePaymentCall = (...args) => _moduleWrapper.moduleWrapper.current.functions.invokePaymentCall(...args);
|
|
@@ -354,6 +354,20 @@ class AppWrapper {
|
|
|
354
354
|
pageWidth: window.innerWidth,
|
|
355
355
|
topBarHeight: 0
|
|
356
356
|
}),
|
|
357
|
+
getAppleSafeArea: async () => {
|
|
358
|
+
var _v$top, _v$left, _v$bottom, _v$right;
|
|
359
|
+
if (this.latestAppleSafeArea) {
|
|
360
|
+
return this.latestAppleSafeArea;
|
|
361
|
+
}
|
|
362
|
+
const v = await this.appCall(300, {});
|
|
363
|
+
this.latestAppleSafeArea = {
|
|
364
|
+
top: (_v$top = v === null || v === void 0 ? void 0 : v.top) !== null && _v$top !== void 0 ? _v$top : 0,
|
|
365
|
+
left: (_v$left = v === null || v === void 0 ? void 0 : v.left) !== null && _v$left !== void 0 ? _v$left : 0,
|
|
366
|
+
bottom: (_v$bottom = v === null || v === void 0 ? void 0 : v.bottom) !== null && _v$bottom !== void 0 ? _v$bottom : 0,
|
|
367
|
+
right: (_v$right = v === null || v === void 0 ? void 0 : v.right) !== null && _v$right !== void 0 ? _v$right : 0
|
|
368
|
+
};
|
|
369
|
+
return this.latestAppleSafeArea;
|
|
370
|
+
},
|
|
357
371
|
invokeCall: async (value, callback) => {
|
|
358
372
|
return this.appCall(value.action, value.value, {
|
|
359
373
|
callback
|
|
@@ -91,6 +91,10 @@ class FrameWrapper {
|
|
|
91
91
|
if (!this.initialized) await this.ready;
|
|
92
92
|
return this.exposedFunctions.getWindowMetrics();
|
|
93
93
|
},
|
|
94
|
+
getAppleSafeArea: async () => {
|
|
95
|
+
if (!this.initialized) await this.ready;
|
|
96
|
+
return this.exposedFunctions.getAppleSafeArea();
|
|
97
|
+
},
|
|
94
98
|
invokeCall: async (value, callback) => {
|
|
95
99
|
if (!this.initialized) await this.ready;
|
|
96
100
|
return this.exposedFunctions.invokeCall(value, callback && comlink.proxy(result => callback(result)));
|
|
@@ -47,22 +47,42 @@ const createAppleSafeAreaFunctions = functions => {
|
|
|
47
47
|
}
|
|
48
48
|
return Promise.resolve();
|
|
49
49
|
};
|
|
50
|
+
const baseGetSafeArea = runtimeFunctions.getAppleSafeArea;
|
|
51
|
+
const getAppleSafeArea = async () => {
|
|
52
|
+
if (hasLatestValue && latestValue) {
|
|
53
|
+
return latestValue;
|
|
54
|
+
}
|
|
55
|
+
if (baseGetSafeArea) {
|
|
56
|
+
const result = await baseGetSafeArea();
|
|
57
|
+
dispatch(result);
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
const fallback = {
|
|
61
|
+
top: 0,
|
|
62
|
+
left: 0,
|
|
63
|
+
bottom: 0,
|
|
64
|
+
right: 0
|
|
65
|
+
};
|
|
66
|
+
return fallback;
|
|
67
|
+
};
|
|
50
68
|
return {
|
|
51
69
|
addAppleSafeAreaListener,
|
|
52
|
-
removeAppleSafeAreaListener
|
|
70
|
+
removeAppleSafeAreaListener,
|
|
71
|
+
getAppleSafeArea
|
|
53
72
|
};
|
|
54
73
|
};
|
|
55
74
|
const normalizeFunctions = functions => {
|
|
56
|
-
var _runtimeFunctions$add2, _runtimeFunctions$rem2;
|
|
75
|
+
var _runtimeFunctions$add2, _runtimeFunctions$rem2, _runtimeFunctions$get;
|
|
57
76
|
const runtimeFunctions = functions;
|
|
58
|
-
if (runtimeFunctions.addAppleSafeAreaListener && runtimeFunctions.removeAppleSafeAreaListener) {
|
|
77
|
+
if (runtimeFunctions.addAppleSafeAreaListener && runtimeFunctions.removeAppleSafeAreaListener && runtimeFunctions.getAppleSafeArea) {
|
|
59
78
|
return functions;
|
|
60
79
|
}
|
|
61
80
|
const safeAreaFunctions = createAppleSafeAreaFunctions(functions);
|
|
62
81
|
return {
|
|
63
82
|
...functions,
|
|
64
83
|
addAppleSafeAreaListener: (_runtimeFunctions$add2 = runtimeFunctions.addAppleSafeAreaListener) !== null && _runtimeFunctions$add2 !== void 0 ? _runtimeFunctions$add2 : safeAreaFunctions.addAppleSafeAreaListener,
|
|
65
|
-
removeAppleSafeAreaListener: (_runtimeFunctions$rem2 = runtimeFunctions.removeAppleSafeAreaListener) !== null && _runtimeFunctions$rem2 !== void 0 ? _runtimeFunctions$rem2 : safeAreaFunctions.removeAppleSafeAreaListener
|
|
84
|
+
removeAppleSafeAreaListener: (_runtimeFunctions$rem2 = runtimeFunctions.removeAppleSafeAreaListener) !== null && _runtimeFunctions$rem2 !== void 0 ? _runtimeFunctions$rem2 : safeAreaFunctions.removeAppleSafeAreaListener,
|
|
85
|
+
getAppleSafeArea: (_runtimeFunctions$get = runtimeFunctions.getAppleSafeArea) !== null && _runtimeFunctions$get !== void 0 ? _runtimeFunctions$get : safeAreaFunctions.getAppleSafeArea
|
|
66
86
|
};
|
|
67
87
|
};
|
|
68
88
|
exports.normalizeFunctions = normalizeFunctions;
|
package/dist/esm/calls/index.js
CHANGED
|
@@ -15,6 +15,7 @@ export const getGeoLocation = (...args) => moduleWrapper.current.functions.getGe
|
|
|
15
15
|
export const getUserInfo = (...args) => moduleWrapper.current.functions.getUserInfo(...args);
|
|
16
16
|
export const getScrollPosition = (...args) => moduleWrapper.current.functions.getScrollPosition(...args);
|
|
17
17
|
export const getWindowMetrics = (...args) => moduleWrapper.current.functions.getWindowMetrics(...args);
|
|
18
|
+
export const getSafeArea = (...args) => moduleWrapper.current.functions.getAppleSafeArea(...args);
|
|
18
19
|
export const invokeCall = (...args) => moduleWrapper.current.functions.invokeCall(...args);
|
|
19
20
|
export const invokePaymentCall = (...args) => moduleWrapper.current.functions.invokePaymentCall(...args);
|
|
20
21
|
export const invokeDialogCall = (...args) => moduleWrapper.current.functions.invokeDialogCall(...args);
|
|
@@ -317,6 +317,20 @@ export class AppWrapper {
|
|
|
317
317
|
pageWidth: window.innerWidth,
|
|
318
318
|
topBarHeight: 0
|
|
319
319
|
}),
|
|
320
|
+
getAppleSafeArea: async () => {
|
|
321
|
+
var _v$top, _v$left, _v$bottom, _v$right;
|
|
322
|
+
if (this.latestAppleSafeArea) {
|
|
323
|
+
return this.latestAppleSafeArea;
|
|
324
|
+
}
|
|
325
|
+
const v = await this.appCall(300, {});
|
|
326
|
+
this.latestAppleSafeArea = {
|
|
327
|
+
top: (_v$top = v === null || v === void 0 ? void 0 : v.top) !== null && _v$top !== void 0 ? _v$top : 0,
|
|
328
|
+
left: (_v$left = v === null || v === void 0 ? void 0 : v.left) !== null && _v$left !== void 0 ? _v$left : 0,
|
|
329
|
+
bottom: (_v$bottom = v === null || v === void 0 ? void 0 : v.bottom) !== null && _v$bottom !== void 0 ? _v$bottom : 0,
|
|
330
|
+
right: (_v$right = v === null || v === void 0 ? void 0 : v.right) !== null && _v$right !== void 0 ? _v$right : 0
|
|
331
|
+
};
|
|
332
|
+
return this.latestAppleSafeArea;
|
|
333
|
+
},
|
|
320
334
|
invokeCall: async (value, callback) => {
|
|
321
335
|
return this.appCall(value.action, value.value, {
|
|
322
336
|
callback
|
|
@@ -87,6 +87,10 @@ export class FrameWrapper {
|
|
|
87
87
|
if (!this.initialized) await this.ready;
|
|
88
88
|
return this.exposedFunctions.getWindowMetrics();
|
|
89
89
|
},
|
|
90
|
+
getAppleSafeArea: async () => {
|
|
91
|
+
if (!this.initialized) await this.ready;
|
|
92
|
+
return this.exposedFunctions.getAppleSafeArea();
|
|
93
|
+
},
|
|
90
94
|
invokeCall: async (value, callback) => {
|
|
91
95
|
if (!this.initialized) await this.ready;
|
|
92
96
|
return this.exposedFunctions.invokeCall(value, callback && comlink.proxy(result => callback(result)));
|
|
@@ -24,6 +24,7 @@ class StaticChaynsApi {
|
|
|
24
24
|
_defineProperty(this, "getUserInfo", void 0);
|
|
25
25
|
_defineProperty(this, "getScrollPosition", void 0);
|
|
26
26
|
_defineProperty(this, "getWindowMetrics", void 0);
|
|
27
|
+
_defineProperty(this, "getAppleSafeArea", void 0);
|
|
27
28
|
_defineProperty(this, "invokeCall", void 0);
|
|
28
29
|
_defineProperty(this, "invokePaymentCall", void 0);
|
|
29
30
|
_defineProperty(this, "invokeDialogCall", void 0);
|
|
@@ -41,21 +41,41 @@ const createAppleSafeAreaFunctions = functions => {
|
|
|
41
41
|
}
|
|
42
42
|
return Promise.resolve();
|
|
43
43
|
};
|
|
44
|
+
const baseGetSafeArea = runtimeFunctions.getAppleSafeArea;
|
|
45
|
+
const getAppleSafeArea = async () => {
|
|
46
|
+
if (hasLatestValue && latestValue) {
|
|
47
|
+
return latestValue;
|
|
48
|
+
}
|
|
49
|
+
if (baseGetSafeArea) {
|
|
50
|
+
const result = await baseGetSafeArea();
|
|
51
|
+
dispatch(result);
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
const fallback = {
|
|
55
|
+
top: 0,
|
|
56
|
+
left: 0,
|
|
57
|
+
bottom: 0,
|
|
58
|
+
right: 0
|
|
59
|
+
};
|
|
60
|
+
return fallback;
|
|
61
|
+
};
|
|
44
62
|
return {
|
|
45
63
|
addAppleSafeAreaListener,
|
|
46
|
-
removeAppleSafeAreaListener
|
|
64
|
+
removeAppleSafeAreaListener,
|
|
65
|
+
getAppleSafeArea
|
|
47
66
|
};
|
|
48
67
|
};
|
|
49
68
|
export const normalizeFunctions = functions => {
|
|
50
|
-
var _runtimeFunctions$add2, _runtimeFunctions$rem2;
|
|
69
|
+
var _runtimeFunctions$add2, _runtimeFunctions$rem2, _runtimeFunctions$get;
|
|
51
70
|
const runtimeFunctions = functions;
|
|
52
|
-
if (runtimeFunctions.addAppleSafeAreaListener && runtimeFunctions.removeAppleSafeAreaListener) {
|
|
71
|
+
if (runtimeFunctions.addAppleSafeAreaListener && runtimeFunctions.removeAppleSafeAreaListener && runtimeFunctions.getAppleSafeArea) {
|
|
53
72
|
return functions;
|
|
54
73
|
}
|
|
55
74
|
const safeAreaFunctions = createAppleSafeAreaFunctions(functions);
|
|
56
75
|
return {
|
|
57
76
|
...functions,
|
|
58
77
|
addAppleSafeAreaListener: (_runtimeFunctions$add2 = runtimeFunctions.addAppleSafeAreaListener) !== null && _runtimeFunctions$add2 !== void 0 ? _runtimeFunctions$add2 : safeAreaFunctions.addAppleSafeAreaListener,
|
|
59
|
-
removeAppleSafeAreaListener: (_runtimeFunctions$rem2 = runtimeFunctions.removeAppleSafeAreaListener) !== null && _runtimeFunctions$rem2 !== void 0 ? _runtimeFunctions$rem2 : safeAreaFunctions.removeAppleSafeAreaListener
|
|
78
|
+
removeAppleSafeAreaListener: (_runtimeFunctions$rem2 = runtimeFunctions.removeAppleSafeAreaListener) !== null && _runtimeFunctions$rem2 !== void 0 ? _runtimeFunctions$rem2 : safeAreaFunctions.removeAppleSafeAreaListener,
|
|
79
|
+
getAppleSafeArea: (_runtimeFunctions$get = runtimeFunctions.getAppleSafeArea) !== null && _runtimeFunctions$get !== void 0 ? _runtimeFunctions$get : safeAreaFunctions.getAppleSafeArea
|
|
60
80
|
};
|
|
61
81
|
};
|
|
@@ -67,6 +67,12 @@ export declare const getScrollPosition: (...args: Parameters<ChaynsReactFunction
|
|
|
67
67
|
* Returns the window metrics.
|
|
68
68
|
*/
|
|
69
69
|
export declare const getWindowMetrics: (...args: Parameters<ChaynsReactFunctions["getWindowMetrics"]>) => Promise<import("../types/IChaynsReact").WindowMetricsListenerResult>;
|
|
70
|
+
/**
|
|
71
|
+
* Returns the current safe area insets on iOS. Can be used outside of a React context
|
|
72
|
+
* (e.g. inside a redux action, thunk or service), as long as the ChaynsProvider has been
|
|
73
|
+
* mounted once.
|
|
74
|
+
*/
|
|
75
|
+
export declare const getSafeArea: (...args: Parameters<ChaynsReactFunctions["getAppleSafeArea"]>) => Promise<import("../types/IChaynsReact").AppleSafeArea>;
|
|
70
76
|
/** @internal */
|
|
71
77
|
export declare const invokeCall: (...args: Parameters<ChaynsReactFunctions["invokeCall"]>) => Promise<any>;
|
|
72
78
|
/** @internal */
|
|
@@ -390,6 +390,7 @@ export interface ChaynsReactFunctions {
|
|
|
390
390
|
getUserInfo: (value: UserInfoQuery) => Promise<UserInfo | null>;
|
|
391
391
|
getScrollPosition: () => Promise<ScrollListenerResult>;
|
|
392
392
|
getWindowMetrics: () => Promise<WindowMetricsListenerResult>;
|
|
393
|
+
getAppleSafeArea: () => Promise<AppleSafeArea>;
|
|
393
394
|
invokeCall: (value: InvokeCall, callback?: (result: any) => void) => Promise<any>;
|
|
394
395
|
invokePaymentCall: <T>(value: InvokeCall, callback?: (result: T) => void) => Promise<T>;
|
|
395
396
|
invokeDialogCall: (value: InvokeCall, callback?: (result: any) => void) => Promise<any>;
|
|
@@ -14,6 +14,7 @@ declare class StaticChaynsApi implements ChaynsReactFunctions {
|
|
|
14
14
|
getUserInfo: ChaynsReactFunctions['getUserInfo'];
|
|
15
15
|
getScrollPosition: ChaynsReactFunctions['getScrollPosition'];
|
|
16
16
|
getWindowMetrics: ChaynsReactFunctions['getWindowMetrics'];
|
|
17
|
+
getAppleSafeArea: ChaynsReactFunctions['getAppleSafeArea'];
|
|
17
18
|
invokeCall: ChaynsReactFunctions['invokeCall'];
|
|
18
19
|
invokePaymentCall: ChaynsReactFunctions['invokePaymentCall'];
|
|
19
20
|
invokeDialogCall: ChaynsReactFunctions['invokeDialogCall'];
|