chayns-api 1.0.0 → 1.0.2
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/hooks/index.js +6 -0
- package/dist/cjs/hooks/usePages.js +22 -2
- package/dist/cjs/hooks/useUser.js +0 -1
- package/dist/cjs/host/ChaynsHost.js +2 -0
- package/dist/cjs/types/IChaynsReact.js +27 -1
- package/dist/cjs/util/deviceHelper.js +3 -5
- package/dist/cjs/wrapper/AppWrapper.js +260 -76
- package/dist/esm/hooks/index.js +1 -1
- package/dist/esm/hooks/usePages.js +20 -0
- package/dist/esm/hooks/useUser.js +0 -1
- package/dist/esm/host/ChaynsHost.js +2 -0
- package/dist/esm/types/IChaynsReact.js +23 -0
- package/dist/esm/util/deviceHelper.js +3 -5
- package/dist/esm/wrapper/AppWrapper.js +260 -78
- package/dist/types/calls/index.d.ts +0 -6
- package/dist/types/hooks/index.d.ts +1 -1
- package/dist/types/hooks/usePages.d.ts +4 -0
- package/dist/types/host/ChaynsHost.d.ts +1 -0
- package/dist/types/types/IChaynsReact.d.ts +41 -10
- package/dist/types/util/deviceHelper.d.ts +2 -2
- package/dist/types/wrapper/AppWrapper.d.ts +6 -4
- package/package.json +1 -1
package/dist/cjs/hooks/index.js
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
Object.defineProperty(exports, "getPage", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _usePages.getPage;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
6
12
|
Object.defineProperty(exports, "useAccessToken", {
|
|
7
13
|
enumerable: true,
|
|
8
14
|
get: function () {
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.usePages = exports.usePage = void 0;
|
|
6
|
+
exports.usePages = exports.usePage = exports.getPage = void 0;
|
|
7
7
|
var _useContextSelector = require("use-context-selector");
|
|
8
8
|
var _ChaynsContext = require("../components/ChaynsContext");
|
|
9
|
+
var _ChaynsProvider = require("../components/ChaynsProvider");
|
|
9
10
|
/**
|
|
10
11
|
* @category Hooks
|
|
11
12
|
*/
|
|
@@ -35,4 +36,23 @@ const usePage = ({
|
|
|
35
36
|
}
|
|
36
37
|
return null;
|
|
37
38
|
};
|
|
38
|
-
exports.usePage = usePage;
|
|
39
|
+
exports.usePage = usePage;
|
|
40
|
+
const getPage = ({
|
|
41
|
+
id,
|
|
42
|
+
siteId
|
|
43
|
+
} = {
|
|
44
|
+
id: null,
|
|
45
|
+
siteId: null
|
|
46
|
+
}) => {
|
|
47
|
+
var _pages$find3;
|
|
48
|
+
const {
|
|
49
|
+
pages,
|
|
50
|
+
currentPage
|
|
51
|
+
} = _ChaynsProvider.moduleWrapper.current.values;
|
|
52
|
+
if (id) {
|
|
53
|
+
var _pages$find2;
|
|
54
|
+
return (_pages$find2 = pages.find(x => x.id === id && (!siteId || x.siteId === siteId))) !== null && _pages$find2 !== void 0 ? _pages$find2 : null;
|
|
55
|
+
}
|
|
56
|
+
return (_pages$find3 = pages.find(x => x.id === currentPage.id && x.siteId === currentPage.siteId || !x.siteId)) !== null && _pages$find3 !== void 0 ? _pages$find3 : null;
|
|
57
|
+
};
|
|
58
|
+
exports.getPage = getPage;
|
|
@@ -9,6 +9,5 @@ var _ChaynsContext = require("../components/ChaynsContext");
|
|
|
9
9
|
/**
|
|
10
10
|
* @category Hooks
|
|
11
11
|
*/
|
|
12
|
-
// @ts-ignore
|
|
13
12
|
const useUser = () => (0, _useContextSelector.useContextSelector)(_ChaynsContext.ChaynsContext, v => (v === null || v === void 0 ? void 0 : v.user) || {});
|
|
14
13
|
exports.useUser = useUser;
|
|
@@ -14,6 +14,7 @@ const ChaynsHost = ({
|
|
|
14
14
|
functions,
|
|
15
15
|
src,
|
|
16
16
|
iFrameRef = undefined,
|
|
17
|
+
loadingComponent = undefined,
|
|
17
18
|
children = undefined,
|
|
18
19
|
system,
|
|
19
20
|
// shallow data
|
|
@@ -55,6 +56,7 @@ const ChaynsHost = ({
|
|
|
55
56
|
user: user,
|
|
56
57
|
device: device,
|
|
57
58
|
currentPage: currentPage,
|
|
59
|
+
children: loadingComponent,
|
|
58
60
|
functions: functions,
|
|
59
61
|
language: language,
|
|
60
62
|
parameters: parameters,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.SharingApp = exports.ScreenSize = exports.RuntimeEnviroment = exports.Language = exports.IconType = exports.Gender = exports.Font = exports.FloatingButtonPosition = exports.Environment = exports.DeviceOs = exports.ColorMode = exports.BrowserName = exports.AppName = exports.AccessMode = void 0;
|
|
6
|
+
exports.TappEvent = exports.SharingApp = exports.ScreenSize = exports.ScanQrCodeCodeType = exports.ScanQrCodeCameraTypes = exports.RuntimeEnviroment = exports.Language = exports.IconType = exports.Gender = exports.Font = exports.FloatingButtonPosition = exports.Environment = exports.DeviceOs = exports.ColorMode = exports.BrowserName = exports.AppName = exports.AccessMode = void 0;
|
|
7
7
|
let ScreenSize;
|
|
8
8
|
exports.ScreenSize = ScreenSize;
|
|
9
9
|
(function (ScreenSize) {
|
|
@@ -20,6 +20,20 @@ exports.AccessMode = AccessMode;
|
|
|
20
20
|
AccessMode[AccessMode["protected"] = 1] = "protected";
|
|
21
21
|
AccessMode[AccessMode["private"] = 2] = "private";
|
|
22
22
|
})(AccessMode || (exports.AccessMode = AccessMode = {}));
|
|
23
|
+
let ScanQrCodeCodeType;
|
|
24
|
+
exports.ScanQrCodeCodeType = ScanQrCodeCodeType;
|
|
25
|
+
(function (ScanQrCodeCodeType) {
|
|
26
|
+
ScanQrCodeCodeType[ScanQrCodeCodeType["QR"] = 0] = "QR";
|
|
27
|
+
ScanQrCodeCodeType[ScanQrCodeCodeType["BARCODE"] = 0] = "BARCODE";
|
|
28
|
+
ScanQrCodeCodeType[ScanQrCodeCodeType["ALL"] = 2] = "ALL";
|
|
29
|
+
})(ScanQrCodeCodeType || (exports.ScanQrCodeCodeType = ScanQrCodeCodeType = {}));
|
|
30
|
+
let ScanQrCodeCameraTypes;
|
|
31
|
+
exports.ScanQrCodeCameraTypes = ScanQrCodeCameraTypes;
|
|
32
|
+
(function (ScanQrCodeCameraTypes) {
|
|
33
|
+
ScanQrCodeCameraTypes[ScanQrCodeCameraTypes["AUTO"] = 0] = "AUTO";
|
|
34
|
+
ScanQrCodeCameraTypes[ScanQrCodeCameraTypes["BACK"] = 1] = "BACK";
|
|
35
|
+
ScanQrCodeCameraTypes[ScanQrCodeCameraTypes["FRONT"] = 2] = "FRONT";
|
|
36
|
+
})(ScanQrCodeCameraTypes || (exports.ScanQrCodeCameraTypes = ScanQrCodeCameraTypes = {}));
|
|
23
37
|
var IOSFeedbackVibration;
|
|
24
38
|
(function (IOSFeedbackVibration) {
|
|
25
39
|
IOSFeedbackVibration[IOSFeedbackVibration["Unknown"] = 0] = "Unknown";
|
|
@@ -92,8 +106,11 @@ var DesignSettingsUpdateTappViewModes;
|
|
|
92
106
|
})(DesignSettingsUpdateTappViewModes || (DesignSettingsUpdateTappViewModes = {}));
|
|
93
107
|
var LoginState;
|
|
94
108
|
(function (LoginState) {
|
|
109
|
+
LoginState[LoginState["FACEBOOK"] = 0] = "FACEBOOK";
|
|
110
|
+
LoginState[LoginState["T_WEB"] = 1] = "T_WEB";
|
|
95
111
|
LoginState[LoginState["LoginFailed"] = 2] = "LoginFailed";
|
|
96
112
|
LoginState[LoginState["AlreadyLoggedIn"] = 3] = "AlreadyLoggedIn";
|
|
113
|
+
LoginState[LoginState["SUCCESS"] = 4] = "SUCCESS";
|
|
97
114
|
})(LoginState || (LoginState = {}));
|
|
98
115
|
let FloatingButtonPosition;
|
|
99
116
|
exports.FloatingButtonPosition = FloatingButtonPosition;
|
|
@@ -112,6 +129,15 @@ exports.SharingApp = SharingApp;
|
|
|
112
129
|
SharingApp[SharingApp["GooglePlus"] = 4] = "GooglePlus";
|
|
113
130
|
SharingApp[SharingApp["Twitter"] = 5] = "Twitter";
|
|
114
131
|
})(SharingApp || (exports.SharingApp = SharingApp = {}));
|
|
132
|
+
let TappEvent;
|
|
133
|
+
exports.TappEvent = TappEvent;
|
|
134
|
+
(function (TappEvent) {
|
|
135
|
+
TappEvent[TappEvent["OnShow"] = 0] = "OnShow";
|
|
136
|
+
TappEvent[TappEvent["OnHide"] = 1] = "OnHide";
|
|
137
|
+
TappEvent[TappEvent["OnRefresh"] = 2] = "OnRefresh";
|
|
138
|
+
TappEvent[TappEvent["OnOpenCcScanner"] = 3] = "OnOpenCcScanner";
|
|
139
|
+
TappEvent[TappEvent["OnCloseCcScanner"] = 4] = "OnCloseCcScanner";
|
|
140
|
+
})(TappEvent || (exports.TappEvent = TappEvent = {}));
|
|
115
141
|
let IconType;
|
|
116
142
|
exports.IconType = IconType;
|
|
117
143
|
(function (IconType) {
|
|
@@ -45,11 +45,9 @@ const getDeviceInfo = (userAgent, acceptHeader) => {
|
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
// Infos that are only available on client or iframe side
|
|
48
|
-
const getClientDeviceInfo = () => {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
};
|
|
52
|
-
};
|
|
48
|
+
const getClientDeviceInfo = () => ({
|
|
49
|
+
isTouch: navigator.maxTouchPoints > 0 && window.matchMedia('(pointer: coarse)')
|
|
50
|
+
});
|
|
53
51
|
exports.getClientDeviceInfo = getClientDeviceInfo;
|
|
54
52
|
const getScreenSize = width => {
|
|
55
53
|
let value;
|
|
@@ -6,16 +6,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.AppWrapper = void 0;
|
|
7
7
|
var _IChaynsReact = require("../types/IChaynsReact");
|
|
8
8
|
var _appCall = _interopRequireDefault(require("../util/appCall"));
|
|
9
|
-
var _deviceHelper =
|
|
9
|
+
var _deviceHelper = _interopRequireWildcard(require("../util/deviceHelper"));
|
|
10
10
|
var _visibilityChangeListener = require("../calls/visibilityChangeListener");
|
|
11
11
|
var _getUserInfo = _interopRequireDefault(require("../calls/getUserInfo"));
|
|
12
|
+
var _sendMessage = require("../calls/sendMessage");
|
|
13
|
+
var _apiListenerHelper = require("../helper/apiListenerHelper");
|
|
14
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
12
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
/* eslint-disable */
|
|
18
|
+
// @ts-nocheck
|
|
19
|
+
|
|
13
20
|
class AppWrapper {
|
|
14
21
|
values = null;
|
|
15
22
|
accessToken = "";
|
|
16
|
-
mapOldApiToNew({
|
|
17
|
-
retVal
|
|
18
|
-
}) {
|
|
23
|
+
mapOldApiToNew(retVal) {
|
|
19
24
|
var _window, _window2, _AppInfo$TappSelected;
|
|
20
25
|
const {
|
|
21
26
|
AppInfo,
|
|
@@ -90,20 +95,44 @@ class AppWrapper {
|
|
|
90
95
|
};
|
|
91
96
|
}
|
|
92
97
|
constructor() {}
|
|
98
|
+
notImplemented(call) {
|
|
99
|
+
console.warn(`call ${call} not implement in app`);
|
|
100
|
+
}
|
|
93
101
|
counter = 0;
|
|
94
|
-
appCall(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
102
|
+
appCall(action, value = {}, {
|
|
103
|
+
callback,
|
|
104
|
+
awaitResult = true
|
|
105
|
+
} = {}) {
|
|
106
|
+
if (!awaitResult) {
|
|
107
|
+
(0, _appCall.default)({
|
|
108
|
+
action,
|
|
109
|
+
value
|
|
110
|
+
});
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
return new Promise(resolve => {
|
|
114
|
+
const callbackName = `chaynsApiV5Callback_${this.counter++}`;
|
|
115
|
+
window[callbackName] = v => {
|
|
116
|
+
var _v$retVal2;
|
|
117
|
+
if (callback) {
|
|
118
|
+
var _v$retVal;
|
|
119
|
+
callback((_v$retVal = v === null || v === void 0 ? void 0 : v.retVal) !== null && _v$retVal !== void 0 ? _v$retVal : v);
|
|
120
|
+
} else {
|
|
121
|
+
delete window[callbackName];
|
|
122
|
+
}
|
|
123
|
+
resolve((_v$retVal2 = v === null || v === void 0 ? void 0 : v.retVal) !== null && _v$retVal2 !== void 0 ? _v$retVal2 : v);
|
|
124
|
+
};
|
|
125
|
+
value.callback = "window." + callbackName;
|
|
126
|
+
(0, _appCall.default)({
|
|
127
|
+
action,
|
|
128
|
+
value
|
|
129
|
+
});
|
|
130
|
+
});
|
|
98
131
|
}
|
|
99
|
-
|
|
100
|
-
// @ts-ignore
|
|
101
132
|
functions = {
|
|
102
|
-
getAccessToken: async
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
};
|
|
106
|
-
},
|
|
133
|
+
getAccessToken: async () => ({
|
|
134
|
+
accessToken: this.accessToken
|
|
135
|
+
}),
|
|
107
136
|
// addGeoLocationListener: async (value , callback) => {
|
|
108
137
|
// return invokeAppCall({
|
|
109
138
|
// 'action': 14,
|
|
@@ -116,7 +145,22 @@ class AppWrapper {
|
|
|
116
145
|
// addScrollListener: async (value, callback) => {
|
|
117
146
|
//
|
|
118
147
|
// },
|
|
119
|
-
|
|
148
|
+
addVisibilityChangeListener: async callback => {
|
|
149
|
+
const {
|
|
150
|
+
id,
|
|
151
|
+
shouldInitialize
|
|
152
|
+
} = (0, _apiListenerHelper.addApiListener)('windowMetricsListener', callback);
|
|
153
|
+
this.appCall(60, {}, {
|
|
154
|
+
callback: v => {
|
|
155
|
+
console.log("v", v);
|
|
156
|
+
(0, _apiListenerHelper.dispatchApiEvent)("windowMetricsListener", {
|
|
157
|
+
isVisible: v.tappEvent === _IChaynsReact.TappEvent.OnShow,
|
|
158
|
+
tappEvent: v.tappEvent
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
return id;
|
|
163
|
+
},
|
|
120
164
|
// addWindowMetricsListener: async (callback) => {
|
|
121
165
|
// const { id, shouldInitialize } = addApiListener('windowMetricsListener', callback);
|
|
122
166
|
//
|
|
@@ -131,19 +175,49 @@ class AppWrapper {
|
|
|
131
175
|
// }
|
|
132
176
|
// return id;
|
|
133
177
|
// },
|
|
134
|
-
customCallbackFunction: async (
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
178
|
+
customCallbackFunction: async () => {
|
|
179
|
+
this.notImplemented("customCallbackFunction");
|
|
180
|
+
},
|
|
181
|
+
getAvailableSharingServices: async () => {
|
|
182
|
+
const res = await this.appCall(79);
|
|
183
|
+
return {
|
|
184
|
+
availableSharingApps: res.availableSharingApps,
|
|
185
|
+
availableAndroidApps: res.availableAndroidApps
|
|
186
|
+
};
|
|
187
|
+
},
|
|
188
|
+
getGeoLocation: async () => {
|
|
189
|
+
const res = await this.appCall(14);
|
|
190
|
+
return {
|
|
191
|
+
latitude: res.latitude,
|
|
192
|
+
longitude: res.longitude,
|
|
193
|
+
speed: res.speed,
|
|
194
|
+
code: res.code,
|
|
195
|
+
isAccurate: res.isAccurate
|
|
196
|
+
};
|
|
197
|
+
},
|
|
139
198
|
getUserInfo: async query => {
|
|
140
199
|
return (0, _getUserInfo.default)(this, query);
|
|
141
200
|
},
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
201
|
+
getScrollPosition: async () => {
|
|
202
|
+
return {
|
|
203
|
+
scrollX: window.scrollX,
|
|
204
|
+
scrollY: window.scrollY
|
|
205
|
+
};
|
|
206
|
+
},
|
|
207
|
+
getWindowMetrics: async () => ({
|
|
208
|
+
bottomBarHeight: 0,
|
|
209
|
+
windowHeight: window.innerHeight,
|
|
210
|
+
offsetTop: 0,
|
|
211
|
+
pageHeight: window.innerHeight,
|
|
212
|
+
pageSize: (0, _deviceHelper.getScreenSize)(window.innerWidth),
|
|
213
|
+
pageWidth: window.innerWidth,
|
|
214
|
+
topBarHeight: 0
|
|
215
|
+
}),
|
|
216
|
+
invokeCall: async (value, callback) => {
|
|
217
|
+
return this.appCall(value.action, value.value, {
|
|
218
|
+
callback
|
|
219
|
+
});
|
|
220
|
+
},
|
|
147
221
|
invokeDialogCall: async (value, callback) => {
|
|
148
222
|
const callbackName = `chaynsApiV5Callback_${this.counter++}`;
|
|
149
223
|
window[callbackName] = ({
|
|
@@ -161,70 +235,180 @@ class AppWrapper {
|
|
|
161
235
|
};
|
|
162
236
|
(0, _appCall.default)(callObj);
|
|
163
237
|
},
|
|
164
|
-
|
|
238
|
+
login: async (value, callback, closeCallback) => {
|
|
239
|
+
const res = await this.appCall({}, callback);
|
|
240
|
+
return {
|
|
241
|
+
loginState: res === null || res === void 0 ? void 0 : res.loginState
|
|
242
|
+
};
|
|
243
|
+
},
|
|
244
|
+
logout: async () => {
|
|
245
|
+
this.appCall(56, undefined, {
|
|
246
|
+
awaitResult: false
|
|
247
|
+
});
|
|
248
|
+
},
|
|
249
|
+
navigateBack: async () => {
|
|
250
|
+
this.appCall(20, undefined, {
|
|
251
|
+
awaitResult: false
|
|
252
|
+
});
|
|
253
|
+
},
|
|
254
|
+
openImage: async value => {
|
|
255
|
+
this.appCall(4, {
|
|
256
|
+
items: value.items.map(x => ({
|
|
257
|
+
url: x.url,
|
|
258
|
+
title: x.title,
|
|
259
|
+
description: x.description,
|
|
260
|
+
preventCache: x.preventCache
|
|
261
|
+
})),
|
|
262
|
+
startIndex: value.startIndex
|
|
263
|
+
}, {
|
|
264
|
+
awaitResult: false
|
|
265
|
+
});
|
|
266
|
+
},
|
|
267
|
+
// openUrl: async (value) => {
|
|
268
|
+
//
|
|
269
|
+
// },
|
|
270
|
+
openVideo: async value => {
|
|
271
|
+
this.appCall(15, {
|
|
272
|
+
url: value.url
|
|
273
|
+
}, {
|
|
274
|
+
awaitResult: false
|
|
275
|
+
});
|
|
276
|
+
},
|
|
277
|
+
refreshAccessToken: async () => {
|
|
278
|
+
this.appCall(55, undefined, {
|
|
279
|
+
awaitResult: false
|
|
280
|
+
});
|
|
281
|
+
},
|
|
282
|
+
refreshData: async value => {
|
|
283
|
+
this.notImplemented("refreshData");
|
|
284
|
+
},
|
|
285
|
+
// removeGeoLocationListener: async (id) => {
|
|
286
|
+
// },
|
|
287
|
+
// removeScrollListener: async (id) => {
|
|
165
288
|
// },
|
|
166
|
-
logout: async () => {},
|
|
167
|
-
navigateBack: async () => {},
|
|
168
|
-
openImage: async value => {},
|
|
169
|
-
openUrl: async value => {},
|
|
170
|
-
openVideo: async value => {},
|
|
171
|
-
refreshAccessToken: async () => {},
|
|
172
|
-
refreshData: async value => {},
|
|
173
|
-
removeGeoLocationListener: async id => {},
|
|
174
|
-
removeScrollListener: async id => {},
|
|
175
289
|
removeVisibilityChangeListener(number) {
|
|
176
290
|
(0, _visibilityChangeListener.removeVisibilityChangeListener)(number);
|
|
177
291
|
return Promise.resolve();
|
|
178
292
|
},
|
|
179
|
-
removeWindowMetricsListener: async id => {
|
|
180
|
-
|
|
181
|
-
scrollToY: async (position, duration) => {},
|
|
182
|
-
// sendMessageToGroup: async (groupId, message) => {
|
|
183
|
-
// },
|
|
184
|
-
// sendMessageToPage: async (message) => {
|
|
185
|
-
// },
|
|
186
|
-
// sendMessageToUser: async (userId, message) => {
|
|
187
|
-
// },
|
|
188
|
-
setAdminMode: async enabled => {},
|
|
189
|
-
// setDisplayTimeout: async (value) => {
|
|
293
|
+
// removeWindowMetricsListener: async (id) => {
|
|
294
|
+
//
|
|
190
295
|
// },
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
296
|
+
selectPage: async options => {
|
|
297
|
+
void this.appCall(2, {
|
|
298
|
+
id: options.id,
|
|
299
|
+
showName: options.showName,
|
|
300
|
+
position: options.position,
|
|
301
|
+
params: options.params
|
|
302
|
+
}, {
|
|
303
|
+
awaitResult: false
|
|
304
|
+
});
|
|
305
|
+
},
|
|
306
|
+
scrollToY: async position => {
|
|
307
|
+
window.scrollTo({
|
|
308
|
+
top: position
|
|
309
|
+
});
|
|
310
|
+
},
|
|
311
|
+
sendMessageToGroup: async (groupId, message) => {
|
|
312
|
+
return (0, _sendMessage.sendMessageToGroup)(this, message, groupId);
|
|
313
|
+
},
|
|
314
|
+
sendMessageToPage: async message => {
|
|
315
|
+
return (0, _sendMessage.sendMessageToPage)(this, message);
|
|
316
|
+
},
|
|
317
|
+
sendMessageToUser: async (userId, message) => {
|
|
318
|
+
return (0, _sendMessage.sendMessageToUser)(this, message, userId);
|
|
319
|
+
},
|
|
320
|
+
setAdminMode: async () => {
|
|
321
|
+
this.notImplemented("setAdminMode");
|
|
322
|
+
},
|
|
323
|
+
setDisplayTimeout: async enabled => {
|
|
324
|
+
this.appCall(94, {
|
|
325
|
+
enabled
|
|
326
|
+
}, {
|
|
327
|
+
awaitResult: false
|
|
328
|
+
});
|
|
329
|
+
return {
|
|
330
|
+
isEnabled: enabled
|
|
331
|
+
};
|
|
332
|
+
},
|
|
333
|
+
setFloatingButton: async (value, callback) => {
|
|
334
|
+
void (await this.appCall(72, {
|
|
335
|
+
text: value.text,
|
|
336
|
+
textSize: value.textSize,
|
|
337
|
+
badge: value.badge,
|
|
338
|
+
color: value.color,
|
|
339
|
+
colorText: value.colorText,
|
|
340
|
+
icon: value.icon,
|
|
341
|
+
enabled: value.isEnabled,
|
|
342
|
+
position: value.position
|
|
343
|
+
}, callback));
|
|
344
|
+
},
|
|
345
|
+
setHeight: async () => {
|
|
346
|
+
this.notImplemented("setOverlay");
|
|
347
|
+
},
|
|
348
|
+
setOverlay: async () => {
|
|
349
|
+
this.notImplemented("setOverlay");
|
|
350
|
+
},
|
|
194
351
|
setRefreshScrollEnabled: async isEnabled => {
|
|
195
|
-
(0,
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}
|
|
352
|
+
this.appCall(0, {
|
|
353
|
+
enabled: isEnabled
|
|
354
|
+
}, {
|
|
355
|
+
awaitResult: false
|
|
200
356
|
});
|
|
201
357
|
return {
|
|
202
358
|
isEnabled
|
|
203
359
|
};
|
|
204
360
|
},
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
361
|
+
setScanQrCode: async value => {
|
|
362
|
+
return await this.appCall(34, value);
|
|
363
|
+
},
|
|
364
|
+
setTempDesignSettings: async () => {
|
|
365
|
+
this.notImplemented("setTempDesignSettings");
|
|
366
|
+
},
|
|
367
|
+
setWaitCursor: async value => {
|
|
368
|
+
void this.appCall(1, {
|
|
369
|
+
enabled: value.isEnabled,
|
|
370
|
+
text: value.text,
|
|
371
|
+
timeout: value.timeout,
|
|
372
|
+
progress: value.progress,
|
|
373
|
+
progressText: value.progressText,
|
|
374
|
+
disappearTimeout: value.disappearTimeout
|
|
375
|
+
}, {
|
|
376
|
+
awaitResult: false
|
|
377
|
+
});
|
|
378
|
+
},
|
|
379
|
+
storageGetItem: async (key, accessMode) => {
|
|
380
|
+
const result = await this.appCall(74, {
|
|
381
|
+
key,
|
|
382
|
+
accessMode
|
|
383
|
+
});
|
|
384
|
+
return result === null || result === void 0 ? void 0 : result.object;
|
|
385
|
+
},
|
|
386
|
+
storageRemoveItem: async (key, accessMode) => {
|
|
387
|
+
this.appCall(73, {
|
|
388
|
+
key,
|
|
389
|
+
accessMode
|
|
390
|
+
}, {
|
|
391
|
+
awaitResult: false
|
|
392
|
+
});
|
|
393
|
+
},
|
|
394
|
+
storageSetItem: async (key, value, accessMode, tappIds) => {
|
|
395
|
+
this.appCall(73, {
|
|
396
|
+
key,
|
|
397
|
+
object: value,
|
|
398
|
+
accessMode,
|
|
399
|
+
tappIDs: tappIds
|
|
400
|
+
}, {
|
|
401
|
+
awaitResult: false
|
|
402
|
+
});
|
|
403
|
+
},
|
|
404
|
+
vibrate: async value => {
|
|
405
|
+
void this.appCall(19, value, {
|
|
406
|
+
awaitResult: false
|
|
407
|
+
});
|
|
408
|
+
}
|
|
213
409
|
};
|
|
214
410
|
async init() {
|
|
215
|
-
|
|
216
|
-
// @ts-ignore
|
|
217
|
-
window.globalDataCallback = data => {
|
|
218
|
-
this.values = this.mapOldApiToNew(data);
|
|
219
|
-
resolve(data);
|
|
220
|
-
};
|
|
221
|
-
(0, _appCall.default)({
|
|
222
|
-
action: 18,
|
|
223
|
-
value: {
|
|
224
|
-
callback: 'window.globalDataCallback'
|
|
225
|
-
}
|
|
226
|
-
});
|
|
227
|
-
});
|
|
411
|
+
this.values = this.mapOldApiToNew(await this.appCall(18));
|
|
228
412
|
return undefined;
|
|
229
413
|
}
|
|
230
414
|
getSSRData() {
|
package/dist/esm/hooks/index.js
CHANGED
|
@@ -7,7 +7,7 @@ export { useWindowMetrics, useWindowMetricsListener } from './windowMetricsListe
|
|
|
7
7
|
export { useDevice } from './useDevice';
|
|
8
8
|
export { useSite } from './useSite';
|
|
9
9
|
export { useParameters } from './useParameters';
|
|
10
|
-
export { usePages, usePage } from './usePages';
|
|
10
|
+
export { usePages, usePage, getPage } from './usePages';
|
|
11
11
|
export { useEnvironment } from './useEnvironment';
|
|
12
12
|
export { useLanguage } from './useLanguage';
|
|
13
13
|
export { useValues } from './useValues';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useContextSelector } from 'use-context-selector';
|
|
2
2
|
import { ChaynsContext } from '../components/ChaynsContext';
|
|
3
|
+
import { moduleWrapper } from "../components/ChaynsProvider";
|
|
3
4
|
/**
|
|
4
5
|
* @category Hooks
|
|
5
6
|
*/
|
|
@@ -29,4 +30,23 @@ export const usePage = _ref => {
|
|
|
29
30
|
return (_pages$find = pages.find(x => x.id === id && (!siteId || x.siteId === siteId))) !== null && _pages$find !== void 0 ? _pages$find : null;
|
|
30
31
|
}
|
|
31
32
|
return null;
|
|
33
|
+
};
|
|
34
|
+
export const getPage = function () {
|
|
35
|
+
var _pages$find3;
|
|
36
|
+
let {
|
|
37
|
+
id,
|
|
38
|
+
siteId
|
|
39
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
40
|
+
id: null,
|
|
41
|
+
siteId: null
|
|
42
|
+
};
|
|
43
|
+
const {
|
|
44
|
+
pages,
|
|
45
|
+
currentPage
|
|
46
|
+
} = moduleWrapper.current.values;
|
|
47
|
+
if (id) {
|
|
48
|
+
var _pages$find2;
|
|
49
|
+
return (_pages$find2 = pages.find(x => x.id === id && (!siteId || x.siteId === siteId))) !== null && _pages$find2 !== void 0 ? _pages$find2 : null;
|
|
50
|
+
}
|
|
51
|
+
return (_pages$find3 = pages.find(x => x.id === currentPage.id && x.siteId === currentPage.siteId || !x.siteId)) !== null && _pages$find3 !== void 0 ? _pages$find3 : null;
|
|
32
52
|
};
|
|
@@ -8,6 +8,7 @@ const ChaynsHost = _ref => {
|
|
|
8
8
|
functions,
|
|
9
9
|
src,
|
|
10
10
|
iFrameRef = undefined,
|
|
11
|
+
loadingComponent = undefined,
|
|
11
12
|
children = undefined,
|
|
12
13
|
system,
|
|
13
14
|
// shallow data
|
|
@@ -49,6 +50,7 @@ const ChaynsHost = _ref => {
|
|
|
49
50
|
user: user,
|
|
50
51
|
device: device,
|
|
51
52
|
currentPage: currentPage,
|
|
53
|
+
children: loadingComponent,
|
|
52
54
|
functions: functions,
|
|
53
55
|
language: language,
|
|
54
56
|
parameters: parameters,
|
|
@@ -12,6 +12,18 @@ export let AccessMode;
|
|
|
12
12
|
AccessMode[AccessMode["protected"] = 1] = "protected";
|
|
13
13
|
AccessMode[AccessMode["private"] = 2] = "private";
|
|
14
14
|
})(AccessMode || (AccessMode = {}));
|
|
15
|
+
export let ScanQrCodeCodeType;
|
|
16
|
+
(function (ScanQrCodeCodeType) {
|
|
17
|
+
ScanQrCodeCodeType[ScanQrCodeCodeType["QR"] = 0] = "QR";
|
|
18
|
+
ScanQrCodeCodeType[ScanQrCodeCodeType["BARCODE"] = 0] = "BARCODE";
|
|
19
|
+
ScanQrCodeCodeType[ScanQrCodeCodeType["ALL"] = 2] = "ALL";
|
|
20
|
+
})(ScanQrCodeCodeType || (ScanQrCodeCodeType = {}));
|
|
21
|
+
export let ScanQrCodeCameraTypes;
|
|
22
|
+
(function (ScanQrCodeCameraTypes) {
|
|
23
|
+
ScanQrCodeCameraTypes[ScanQrCodeCameraTypes["AUTO"] = 0] = "AUTO";
|
|
24
|
+
ScanQrCodeCameraTypes[ScanQrCodeCameraTypes["BACK"] = 1] = "BACK";
|
|
25
|
+
ScanQrCodeCameraTypes[ScanQrCodeCameraTypes["FRONT"] = 2] = "FRONT";
|
|
26
|
+
})(ScanQrCodeCameraTypes || (ScanQrCodeCameraTypes = {}));
|
|
15
27
|
var IOSFeedbackVibration;
|
|
16
28
|
(function (IOSFeedbackVibration) {
|
|
17
29
|
IOSFeedbackVibration[IOSFeedbackVibration["Unknown"] = 0] = "Unknown";
|
|
@@ -84,8 +96,11 @@ var DesignSettingsUpdateTappViewModes;
|
|
|
84
96
|
})(DesignSettingsUpdateTappViewModes || (DesignSettingsUpdateTappViewModes = {}));
|
|
85
97
|
var LoginState;
|
|
86
98
|
(function (LoginState) {
|
|
99
|
+
LoginState[LoginState["FACEBOOK"] = 0] = "FACEBOOK";
|
|
100
|
+
LoginState[LoginState["T_WEB"] = 1] = "T_WEB";
|
|
87
101
|
LoginState[LoginState["LoginFailed"] = 2] = "LoginFailed";
|
|
88
102
|
LoginState[LoginState["AlreadyLoggedIn"] = 3] = "AlreadyLoggedIn";
|
|
103
|
+
LoginState[LoginState["SUCCESS"] = 4] = "SUCCESS";
|
|
89
104
|
})(LoginState || (LoginState = {}));
|
|
90
105
|
export let FloatingButtonPosition;
|
|
91
106
|
(function (FloatingButtonPosition) {
|
|
@@ -102,6 +117,14 @@ export let SharingApp;
|
|
|
102
117
|
SharingApp[SharingApp["GooglePlus"] = 4] = "GooglePlus";
|
|
103
118
|
SharingApp[SharingApp["Twitter"] = 5] = "Twitter";
|
|
104
119
|
})(SharingApp || (SharingApp = {}));
|
|
120
|
+
export let TappEvent;
|
|
121
|
+
(function (TappEvent) {
|
|
122
|
+
TappEvent[TappEvent["OnShow"] = 0] = "OnShow";
|
|
123
|
+
TappEvent[TappEvent["OnHide"] = 1] = "OnHide";
|
|
124
|
+
TappEvent[TappEvent["OnRefresh"] = 2] = "OnRefresh";
|
|
125
|
+
TappEvent[TappEvent["OnOpenCcScanner"] = 3] = "OnOpenCcScanner";
|
|
126
|
+
TappEvent[TappEvent["OnCloseCcScanner"] = 4] = "OnCloseCcScanner";
|
|
127
|
+
})(TappEvent || (TappEvent = {}));
|
|
105
128
|
export let IconType;
|
|
106
129
|
(function (IconType) {
|
|
107
130
|
IconType[IconType["Font"] = 0] = "Font";
|
|
@@ -39,11 +39,9 @@ const getDeviceInfo = (userAgent, acceptHeader) => {
|
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
// Infos that are only available on client or iframe side
|
|
42
|
-
export const getClientDeviceInfo = () => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
};
|
|
46
|
-
};
|
|
42
|
+
export const getClientDeviceInfo = () => ({
|
|
43
|
+
isTouch: navigator.maxTouchPoints > 0 && window.matchMedia('(pointer: coarse)')
|
|
44
|
+
});
|
|
47
45
|
export const getScreenSize = width => {
|
|
48
46
|
let value;
|
|
49
47
|
if (width > 1200) {
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
-
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
|
|
5
|
+
import { Environment, Font, Gender, IconType, RuntimeEnviroment, TappEvent } from '../types/IChaynsReact';
|
|
3
6
|
import invokeAppCall from "../util/appCall";
|
|
4
|
-
import getDeviceInfo from "../util/deviceHelper";
|
|
7
|
+
import getDeviceInfo, { getScreenSize } from "../util/deviceHelper";
|
|
5
8
|
import { removeVisibilityChangeListener } from "../calls/visibilityChangeListener";
|
|
6
9
|
import getUserInfo from "../calls/getUserInfo";
|
|
10
|
+
import { sendMessageToGroup, sendMessageToPage, sendMessageToUser } from "../calls/sendMessage";
|
|
11
|
+
import { addApiListener, dispatchApiEvent } from "../helper/apiListenerHelper";
|
|
7
12
|
export class AppWrapper {
|
|
8
|
-
mapOldApiToNew(
|
|
13
|
+
mapOldApiToNew(retVal) {
|
|
9
14
|
var _window, _window2, _AppInfo$TappSelected;
|
|
10
|
-
let {
|
|
11
|
-
retVal
|
|
12
|
-
} = _ref;
|
|
13
15
|
const {
|
|
14
16
|
AppInfo,
|
|
15
17
|
AppUser
|
|
@@ -87,11 +89,9 @@ export class AppWrapper {
|
|
|
87
89
|
_defineProperty(this, "accessToken", "");
|
|
88
90
|
_defineProperty(this, "counter", 0);
|
|
89
91
|
_defineProperty(this, "functions", {
|
|
90
|
-
getAccessToken: async
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
};
|
|
94
|
-
},
|
|
92
|
+
getAccessToken: async () => ({
|
|
93
|
+
accessToken: this.accessToken
|
|
94
|
+
}),
|
|
95
95
|
// addGeoLocationListener: async (value , callback) => {
|
|
96
96
|
// return invokeAppCall({
|
|
97
97
|
// 'action': 14,
|
|
@@ -104,7 +104,22 @@ export class AppWrapper {
|
|
|
104
104
|
// addScrollListener: async (value, callback) => {
|
|
105
105
|
//
|
|
106
106
|
// },
|
|
107
|
-
|
|
107
|
+
addVisibilityChangeListener: async callback => {
|
|
108
|
+
const {
|
|
109
|
+
id,
|
|
110
|
+
shouldInitialize
|
|
111
|
+
} = addApiListener('windowMetricsListener', callback);
|
|
112
|
+
this.appCall(60, {}, {
|
|
113
|
+
callback: v => {
|
|
114
|
+
console.log("v", v);
|
|
115
|
+
dispatchApiEvent("windowMetricsListener", {
|
|
116
|
+
isVisible: v.tappEvent === TappEvent.OnShow,
|
|
117
|
+
tappEvent: v.tappEvent
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
return id;
|
|
122
|
+
},
|
|
108
123
|
// addWindowMetricsListener: async (callback) => {
|
|
109
124
|
// const { id, shouldInitialize } = addApiListener('windowMetricsListener', callback);
|
|
110
125
|
//
|
|
@@ -119,25 +134,55 @@ export class AppWrapper {
|
|
|
119
134
|
// }
|
|
120
135
|
// return id;
|
|
121
136
|
// },
|
|
122
|
-
customCallbackFunction: async (
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
137
|
+
customCallbackFunction: async () => {
|
|
138
|
+
this.notImplemented("customCallbackFunction");
|
|
139
|
+
},
|
|
140
|
+
getAvailableSharingServices: async () => {
|
|
141
|
+
const res = await this.appCall(79);
|
|
142
|
+
return {
|
|
143
|
+
availableSharingApps: res.availableSharingApps,
|
|
144
|
+
availableAndroidApps: res.availableAndroidApps
|
|
145
|
+
};
|
|
146
|
+
},
|
|
147
|
+
getGeoLocation: async () => {
|
|
148
|
+
const res = await this.appCall(14);
|
|
149
|
+
return {
|
|
150
|
+
latitude: res.latitude,
|
|
151
|
+
longitude: res.longitude,
|
|
152
|
+
speed: res.speed,
|
|
153
|
+
code: res.code,
|
|
154
|
+
isAccurate: res.isAccurate
|
|
155
|
+
};
|
|
156
|
+
},
|
|
127
157
|
getUserInfo: async query => {
|
|
128
158
|
return getUserInfo(this, query);
|
|
129
159
|
},
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
160
|
+
getScrollPosition: async () => {
|
|
161
|
+
return {
|
|
162
|
+
scrollX: window.scrollX,
|
|
163
|
+
scrollY: window.scrollY
|
|
164
|
+
};
|
|
165
|
+
},
|
|
166
|
+
getWindowMetrics: async () => ({
|
|
167
|
+
bottomBarHeight: 0,
|
|
168
|
+
windowHeight: window.innerHeight,
|
|
169
|
+
offsetTop: 0,
|
|
170
|
+
pageHeight: window.innerHeight,
|
|
171
|
+
pageSize: getScreenSize(window.innerWidth),
|
|
172
|
+
pageWidth: window.innerWidth,
|
|
173
|
+
topBarHeight: 0
|
|
174
|
+
}),
|
|
175
|
+
invokeCall: async (value, callback) => {
|
|
176
|
+
return this.appCall(value.action, value.value, {
|
|
177
|
+
callback
|
|
178
|
+
});
|
|
179
|
+
},
|
|
135
180
|
invokeDialogCall: async (value, callback) => {
|
|
136
181
|
const callbackName = `chaynsApiV5Callback_${this.counter++}`;
|
|
137
|
-
window[callbackName] =
|
|
182
|
+
window[callbackName] = _ref => {
|
|
138
183
|
let {
|
|
139
184
|
retVal
|
|
140
|
-
} =
|
|
185
|
+
} = _ref;
|
|
141
186
|
callback === null || callback === void 0 ? void 0 : callback(retVal);
|
|
142
187
|
delete window[callbackName];
|
|
143
188
|
};
|
|
@@ -150,79 +195,216 @@ export class AppWrapper {
|
|
|
150
195
|
};
|
|
151
196
|
invokeAppCall(callObj);
|
|
152
197
|
},
|
|
153
|
-
|
|
198
|
+
login: async (value, callback, closeCallback) => {
|
|
199
|
+
const res = await this.appCall({}, callback);
|
|
200
|
+
return {
|
|
201
|
+
loginState: res === null || res === void 0 ? void 0 : res.loginState
|
|
202
|
+
};
|
|
203
|
+
},
|
|
204
|
+
logout: async () => {
|
|
205
|
+
this.appCall(56, undefined, {
|
|
206
|
+
awaitResult: false
|
|
207
|
+
});
|
|
208
|
+
},
|
|
209
|
+
navigateBack: async () => {
|
|
210
|
+
this.appCall(20, undefined, {
|
|
211
|
+
awaitResult: false
|
|
212
|
+
});
|
|
213
|
+
},
|
|
214
|
+
openImage: async value => {
|
|
215
|
+
this.appCall(4, {
|
|
216
|
+
items: value.items.map(x => ({
|
|
217
|
+
url: x.url,
|
|
218
|
+
title: x.title,
|
|
219
|
+
description: x.description,
|
|
220
|
+
preventCache: x.preventCache
|
|
221
|
+
})),
|
|
222
|
+
startIndex: value.startIndex
|
|
223
|
+
}, {
|
|
224
|
+
awaitResult: false
|
|
225
|
+
});
|
|
226
|
+
},
|
|
227
|
+
// openUrl: async (value) => {
|
|
228
|
+
//
|
|
229
|
+
// },
|
|
230
|
+
openVideo: async value => {
|
|
231
|
+
this.appCall(15, {
|
|
232
|
+
url: value.url
|
|
233
|
+
}, {
|
|
234
|
+
awaitResult: false
|
|
235
|
+
});
|
|
236
|
+
},
|
|
237
|
+
refreshAccessToken: async () => {
|
|
238
|
+
this.appCall(55, undefined, {
|
|
239
|
+
awaitResult: false
|
|
240
|
+
});
|
|
241
|
+
},
|
|
242
|
+
refreshData: async value => {
|
|
243
|
+
this.notImplemented("refreshData");
|
|
244
|
+
},
|
|
245
|
+
// removeGeoLocationListener: async (id) => {
|
|
246
|
+
// },
|
|
247
|
+
// removeScrollListener: async (id) => {
|
|
154
248
|
// },
|
|
155
|
-
logout: async () => {},
|
|
156
|
-
navigateBack: async () => {},
|
|
157
|
-
openImage: async value => {},
|
|
158
|
-
openUrl: async value => {},
|
|
159
|
-
openVideo: async value => {},
|
|
160
|
-
refreshAccessToken: async () => {},
|
|
161
|
-
refreshData: async value => {},
|
|
162
|
-
removeGeoLocationListener: async id => {},
|
|
163
|
-
removeScrollListener: async id => {},
|
|
164
249
|
removeVisibilityChangeListener(number) {
|
|
165
250
|
removeVisibilityChangeListener(number);
|
|
166
251
|
return Promise.resolve();
|
|
167
252
|
},
|
|
168
|
-
removeWindowMetricsListener: async id => {
|
|
169
|
-
|
|
170
|
-
scrollToY: async (position, duration) => {},
|
|
171
|
-
// sendMessageToGroup: async (groupId, message) => {
|
|
172
|
-
// },
|
|
173
|
-
// sendMessageToPage: async (message) => {
|
|
174
|
-
// },
|
|
175
|
-
// sendMessageToUser: async (userId, message) => {
|
|
176
|
-
// },
|
|
177
|
-
setAdminMode: async enabled => {},
|
|
178
|
-
// setDisplayTimeout: async (value) => {
|
|
253
|
+
// removeWindowMetricsListener: async (id) => {
|
|
254
|
+
//
|
|
179
255
|
// },
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
256
|
+
selectPage: async options => {
|
|
257
|
+
void this.appCall(2, {
|
|
258
|
+
id: options.id,
|
|
259
|
+
showName: options.showName,
|
|
260
|
+
position: options.position,
|
|
261
|
+
params: options.params
|
|
262
|
+
}, {
|
|
263
|
+
awaitResult: false
|
|
264
|
+
});
|
|
265
|
+
},
|
|
266
|
+
scrollToY: async position => {
|
|
267
|
+
window.scrollTo({
|
|
268
|
+
top: position
|
|
269
|
+
});
|
|
270
|
+
},
|
|
271
|
+
sendMessageToGroup: async (groupId, message) => {
|
|
272
|
+
return sendMessageToGroup(this, message, groupId);
|
|
273
|
+
},
|
|
274
|
+
sendMessageToPage: async message => {
|
|
275
|
+
return sendMessageToPage(this, message);
|
|
276
|
+
},
|
|
277
|
+
sendMessageToUser: async (userId, message) => {
|
|
278
|
+
return sendMessageToUser(this, message, userId);
|
|
279
|
+
},
|
|
280
|
+
setAdminMode: async () => {
|
|
281
|
+
this.notImplemented("setAdminMode");
|
|
282
|
+
},
|
|
283
|
+
setDisplayTimeout: async enabled => {
|
|
284
|
+
this.appCall(94, {
|
|
285
|
+
enabled
|
|
286
|
+
}, {
|
|
287
|
+
awaitResult: false
|
|
288
|
+
});
|
|
289
|
+
return {
|
|
290
|
+
isEnabled: enabled
|
|
291
|
+
};
|
|
292
|
+
},
|
|
293
|
+
setFloatingButton: async (value, callback) => {
|
|
294
|
+
void (await this.appCall(72, {
|
|
295
|
+
text: value.text,
|
|
296
|
+
textSize: value.textSize,
|
|
297
|
+
badge: value.badge,
|
|
298
|
+
color: value.color,
|
|
299
|
+
colorText: value.colorText,
|
|
300
|
+
icon: value.icon,
|
|
301
|
+
enabled: value.isEnabled,
|
|
302
|
+
position: value.position
|
|
303
|
+
}, callback));
|
|
304
|
+
},
|
|
305
|
+
setHeight: async () => {
|
|
306
|
+
this.notImplemented("setOverlay");
|
|
307
|
+
},
|
|
308
|
+
setOverlay: async () => {
|
|
309
|
+
this.notImplemented("setOverlay");
|
|
310
|
+
},
|
|
183
311
|
setRefreshScrollEnabled: async isEnabled => {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}
|
|
312
|
+
this.appCall(0, {
|
|
313
|
+
enabled: isEnabled
|
|
314
|
+
}, {
|
|
315
|
+
awaitResult: false
|
|
189
316
|
});
|
|
190
317
|
return {
|
|
191
318
|
isEnabled
|
|
192
319
|
};
|
|
193
320
|
},
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
321
|
+
setScanQrCode: async value => {
|
|
322
|
+
return await this.appCall(34, value);
|
|
323
|
+
},
|
|
324
|
+
setTempDesignSettings: async () => {
|
|
325
|
+
this.notImplemented("setTempDesignSettings");
|
|
326
|
+
},
|
|
327
|
+
setWaitCursor: async value => {
|
|
328
|
+
void this.appCall(1, {
|
|
329
|
+
enabled: value.isEnabled,
|
|
330
|
+
text: value.text,
|
|
331
|
+
timeout: value.timeout,
|
|
332
|
+
progress: value.progress,
|
|
333
|
+
progressText: value.progressText,
|
|
334
|
+
disappearTimeout: value.disappearTimeout
|
|
335
|
+
}, {
|
|
336
|
+
awaitResult: false
|
|
337
|
+
});
|
|
338
|
+
},
|
|
339
|
+
storageGetItem: async (key, accessMode) => {
|
|
340
|
+
const result = await this.appCall(74, {
|
|
341
|
+
key,
|
|
342
|
+
accessMode
|
|
343
|
+
});
|
|
344
|
+
return result === null || result === void 0 ? void 0 : result.object;
|
|
345
|
+
},
|
|
346
|
+
storageRemoveItem: async (key, accessMode) => {
|
|
347
|
+
this.appCall(73, {
|
|
348
|
+
key,
|
|
349
|
+
accessMode
|
|
350
|
+
}, {
|
|
351
|
+
awaitResult: false
|
|
352
|
+
});
|
|
353
|
+
},
|
|
354
|
+
storageSetItem: async (key, value, accessMode, tappIds) => {
|
|
355
|
+
this.appCall(73, {
|
|
356
|
+
key,
|
|
357
|
+
object: value,
|
|
358
|
+
accessMode,
|
|
359
|
+
tappIDs: tappIds
|
|
360
|
+
}, {
|
|
361
|
+
awaitResult: false
|
|
362
|
+
});
|
|
363
|
+
},
|
|
364
|
+
vibrate: async value => {
|
|
365
|
+
void this.appCall(19, value, {
|
|
366
|
+
awaitResult: false
|
|
367
|
+
});
|
|
368
|
+
}
|
|
202
369
|
});
|
|
203
370
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
call.value.callback = `window.chaynsApiV5Callback_` + this.counter++;
|
|
207
|
-
invokeAppCall(call);
|
|
371
|
+
notImplemented(call) {
|
|
372
|
+
console.warn(`call ${call} not implement in app`);
|
|
208
373
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
this.values = this.mapOldApiToNew(data);
|
|
217
|
-
resolve(data);
|
|
218
|
-
};
|
|
374
|
+
appCall(action) {
|
|
375
|
+
let value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
376
|
+
let {
|
|
377
|
+
callback,
|
|
378
|
+
awaitResult = true
|
|
379
|
+
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
380
|
+
if (!awaitResult) {
|
|
219
381
|
invokeAppCall({
|
|
220
|
-
action
|
|
221
|
-
value
|
|
222
|
-
|
|
382
|
+
action,
|
|
383
|
+
value
|
|
384
|
+
});
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
return new Promise(resolve => {
|
|
388
|
+
const callbackName = `chaynsApiV5Callback_${this.counter++}`;
|
|
389
|
+
window[callbackName] = v => {
|
|
390
|
+
var _v$retVal2;
|
|
391
|
+
if (callback) {
|
|
392
|
+
var _v$retVal;
|
|
393
|
+
callback((_v$retVal = v === null || v === void 0 ? void 0 : v.retVal) !== null && _v$retVal !== void 0 ? _v$retVal : v);
|
|
394
|
+
} else {
|
|
395
|
+
delete window[callbackName];
|
|
223
396
|
}
|
|
397
|
+
resolve((_v$retVal2 = v === null || v === void 0 ? void 0 : v.retVal) !== null && _v$retVal2 !== void 0 ? _v$retVal2 : v);
|
|
398
|
+
};
|
|
399
|
+
value.callback = "window." + callbackName;
|
|
400
|
+
invokeAppCall({
|
|
401
|
+
action,
|
|
402
|
+
value
|
|
224
403
|
});
|
|
225
404
|
});
|
|
405
|
+
}
|
|
406
|
+
async init() {
|
|
407
|
+
this.values = this.mapOldApiToNew(await this.appCall(18));
|
|
226
408
|
return undefined;
|
|
227
409
|
}
|
|
228
410
|
getSSRData() {
|
|
@@ -193,9 +193,6 @@ export declare const getDevice: () => ChaynsApiDevice;
|
|
|
193
193
|
export declare const getLanguage: () => {
|
|
194
194
|
site: import("../types/IChaynsReact").Language;
|
|
195
195
|
translation: import("../types/IChaynsReact").Language | null;
|
|
196
|
-
/**
|
|
197
|
-
* This method returns a list of installed share/social media apps.
|
|
198
|
-
*/
|
|
199
196
|
device: import("../types/IChaynsReact").Language;
|
|
200
197
|
active: import("../types/IChaynsReact").Language;
|
|
201
198
|
};
|
|
@@ -214,9 +211,6 @@ export declare const device: ChaynsApiDevice;
|
|
|
214
211
|
export declare const language: {
|
|
215
212
|
site: import("../types/IChaynsReact").Language;
|
|
216
213
|
translation: import("../types/IChaynsReact").Language | null;
|
|
217
|
-
/**
|
|
218
|
-
* This method returns a list of installed share/social media apps.
|
|
219
|
-
*/
|
|
220
214
|
device: import("../types/IChaynsReact").Language;
|
|
221
215
|
active: import("../types/IChaynsReact").Language;
|
|
222
216
|
};
|
|
@@ -7,7 +7,7 @@ export { useWindowMetrics, useWindowMetricsListener } from './windowMetricsListe
|
|
|
7
7
|
export { useDevice } from './useDevice';
|
|
8
8
|
export { useSite } from './useSite';
|
|
9
9
|
export { useParameters } from './useParameters';
|
|
10
|
-
export { usePages, usePage } from './usePages';
|
|
10
|
+
export { usePages, usePage, getPage } from './usePages';
|
|
11
11
|
export { useEnvironment } from './useEnvironment';
|
|
12
12
|
export { useLanguage } from './useLanguage';
|
|
13
13
|
export { useValues } from './useValues';
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Browser, OperatingSystem } from 'detect-browser';
|
|
2
2
|
import { DialogButton, SelectDialogItem } from "./dialog";
|
|
3
3
|
export type ChaynsApiUser = {
|
|
4
|
-
firstName
|
|
5
|
-
lastName
|
|
6
|
-
gender
|
|
7
|
-
uacGroups
|
|
8
|
-
userId
|
|
9
|
-
personId
|
|
4
|
+
firstName?: string;
|
|
5
|
+
lastName?: string;
|
|
6
|
+
gender?: Gender;
|
|
7
|
+
uacGroups?: UacGroup[];
|
|
8
|
+
userId?: number;
|
|
9
|
+
personId?: string;
|
|
10
10
|
};
|
|
11
11
|
export type ChaynsApiSite = {
|
|
12
12
|
id: string;
|
|
@@ -171,10 +171,29 @@ export type IntercomMessage = {
|
|
|
171
171
|
text: string;
|
|
172
172
|
images?: string[];
|
|
173
173
|
};
|
|
174
|
+
export declare enum ScanQrCodeCodeType {
|
|
175
|
+
QR = 0,
|
|
176
|
+
BARCODE = 0,
|
|
177
|
+
ALL = 2
|
|
178
|
+
}
|
|
179
|
+
export declare enum ScanQrCodeCameraTypes {
|
|
180
|
+
AUTO = 0,
|
|
181
|
+
BACK = 1,
|
|
182
|
+
FRONT = 2
|
|
183
|
+
}
|
|
174
184
|
export type ScanQrCodeRequest = {
|
|
175
|
-
cancel
|
|
185
|
+
cancel?: boolean;
|
|
176
186
|
timeout?: number;
|
|
177
|
-
cameraType
|
|
187
|
+
cameraType?: ScanQrCodeCameraTypes;
|
|
188
|
+
dialogTitle?: string;
|
|
189
|
+
dialogSubtitle?: string;
|
|
190
|
+
enableFlashToggle?: boolean;
|
|
191
|
+
enableCameraSwitch?: boolean;
|
|
192
|
+
ccAnimation?: boolean;
|
|
193
|
+
geoLocation?: boolean;
|
|
194
|
+
showInput?: boolean;
|
|
195
|
+
codeType?: ScanQrCodeCodeType;
|
|
196
|
+
codeFormats?: 4 | 5;
|
|
178
197
|
};
|
|
179
198
|
export type ScanQrCodeResult = {
|
|
180
199
|
qrCode: string;
|
|
@@ -349,8 +368,11 @@ export interface OpenVideo {
|
|
|
349
368
|
url: string;
|
|
350
369
|
}
|
|
351
370
|
declare enum LoginState {
|
|
371
|
+
FACEBOOK = 0,
|
|
372
|
+
T_WEB = 1,
|
|
352
373
|
LoginFailed = 2,
|
|
353
|
-
AlreadyLoggedIn = 3
|
|
374
|
+
AlreadyLoggedIn = 3,
|
|
375
|
+
SUCCESS = 4
|
|
354
376
|
}
|
|
355
377
|
export interface LoginResult {
|
|
356
378
|
loginState: LoginState;
|
|
@@ -360,7 +382,7 @@ export interface Login {
|
|
|
360
382
|
}
|
|
361
383
|
export interface InvokeCall {
|
|
362
384
|
action: number;
|
|
363
|
-
value
|
|
385
|
+
value?: object;
|
|
364
386
|
}
|
|
365
387
|
export interface WaitCursor {
|
|
366
388
|
isEnabled: boolean;
|
|
@@ -368,6 +390,7 @@ export interface WaitCursor {
|
|
|
368
390
|
timeout?: number;
|
|
369
391
|
progress?: number;
|
|
370
392
|
progressText?: string;
|
|
393
|
+
disappearTimeout?: number;
|
|
371
394
|
}
|
|
372
395
|
export declare enum FloatingButtonPosition {
|
|
373
396
|
Right = 0,
|
|
@@ -443,8 +466,16 @@ export interface WindowMetricsListenerResult {
|
|
|
443
466
|
pageWidth: number;
|
|
444
467
|
pageSize: ScreenSize;
|
|
445
468
|
}
|
|
469
|
+
export declare enum TappEvent {
|
|
470
|
+
OnShow = 0,
|
|
471
|
+
OnHide = 1,
|
|
472
|
+
OnRefresh = 2,
|
|
473
|
+
OnOpenCcScanner = 3,
|
|
474
|
+
OnCloseCcScanner = 4
|
|
475
|
+
}
|
|
446
476
|
export interface VisibilityChangeListenerResult {
|
|
447
477
|
isVisible: boolean;
|
|
478
|
+
tappEvent: TappEvent;
|
|
448
479
|
}
|
|
449
480
|
export interface ScrollListenerResult {
|
|
450
481
|
scrollX: number | null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ChaynsApiDevice } from '../types/IChaynsReact';
|
|
1
|
+
import { ChaynsApiDevice, ScreenSize } from '../types/IChaynsReact';
|
|
2
2
|
declare const getDeviceInfo: (userAgent: string, acceptHeader: string) => ChaynsApiDevice;
|
|
3
3
|
export declare const getClientDeviceInfo: () => {
|
|
4
4
|
isTouch: false | MediaQueryList;
|
|
5
5
|
};
|
|
6
|
-
export declare const getScreenSize: (width: any) =>
|
|
6
|
+
export declare const getScreenSize: (width: any) => ScreenSize;
|
|
7
7
|
export default getDeviceInfo;
|
|
@@ -2,12 +2,14 @@ import { ChaynsReactFunctions, ChaynsReactValues, CleanupCallback, DataChangeCal
|
|
|
2
2
|
export declare class AppWrapper implements IChaynsReact {
|
|
3
3
|
values: ChaynsReactValues;
|
|
4
4
|
accessToken: string;
|
|
5
|
-
mapOldApiToNew(
|
|
6
|
-
retVal: any;
|
|
7
|
-
}): ChaynsReactValues;
|
|
5
|
+
mapOldApiToNew(retVal: any): ChaynsReactValues;
|
|
8
6
|
constructor();
|
|
7
|
+
notImplemented(call: string): void;
|
|
9
8
|
counter: number;
|
|
10
|
-
appCall(
|
|
9
|
+
appCall(action: any, value?: unknown, { callback, awaitResult }?: {
|
|
10
|
+
callback: any;
|
|
11
|
+
awaitResult?: boolean | undefined;
|
|
12
|
+
}): Promise<unknown> | undefined;
|
|
11
13
|
functions: ChaynsReactFunctions;
|
|
12
14
|
init(): Promise<undefined>;
|
|
13
15
|
getSSRData(): null;
|