chayns-api 1.1.6 → 1.1.9
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/host/module/ModuleHost.js +5 -2
- package/dist/cjs/util/deviceHelper.js +1 -1
- package/dist/cjs/wrapper/AppWrapper.js +19 -0
- package/dist/esm/host/module/ModuleHost.js +5 -2
- package/dist/esm/util/deviceHelper.js +1 -1
- package/dist/esm/wrapper/AppWrapper.js +22 -2
- package/dist/types/types/IChaynsReact.d.ts +2 -1
- package/package.json +1 -1
|
@@ -25,13 +25,16 @@ const System = ({
|
|
|
25
25
|
});
|
|
26
26
|
const Component = (0, _react.useMemo)(() => {
|
|
27
27
|
// maybe return waitcursor instead
|
|
28
|
-
if (
|
|
28
|
+
if (failed) {
|
|
29
|
+
throw new Error('failed to load component');
|
|
30
|
+
}
|
|
31
|
+
if (!system || !ready) {
|
|
29
32
|
return null;
|
|
30
33
|
}
|
|
31
34
|
return /*#__PURE__*/_react.default.lazy((0, _loadComponent.default)(system.scope, system.module, system.url, undefined, system.preventSingleton));
|
|
32
35
|
|
|
33
36
|
/* eslint-disable react-hooks/exhaustive-deps */
|
|
34
|
-
}, [system === null || system === void 0 ? void 0 : system.scope, ready, system === null || system === void 0 ? void 0 : system.url]);
|
|
37
|
+
}, [system === null || system === void 0 ? void 0 : system.scope, ready, failed, system === null || system === void 0 ? void 0 : system.url]);
|
|
35
38
|
return Component ? /*#__PURE__*/_react.default.createElement(_react.default.Suspense, {
|
|
36
39
|
fallback: fallback || ''
|
|
37
40
|
}, /*#__PURE__*/_react.default.createElement(Component, props)) : fallback;
|
|
@@ -46,7 +46,7 @@ const getDeviceInfo = (userAgent, acceptHeader) => {
|
|
|
46
46
|
callVersion: match !== null && match !== void 0 && match.groups ? Number.parseInt(match.groups.version, 10) : NaN
|
|
47
47
|
};
|
|
48
48
|
result.imei = undefined; // TODO
|
|
49
|
-
result.
|
|
49
|
+
result.engine = uaParser.getEngine();
|
|
50
50
|
result.os = ((_uaParser$getOS = uaParser.getOS()) === null || _uaParser$getOS === void 0 ? void 0 : _uaParser$getOS.name) === 'Android' ? 'Android OS' : (_uaParser$getOS2 = uaParser.getOS()) === null || _uaParser$getOS2 === void 0 ? void 0 : _uaParser$getOS2.name;
|
|
51
51
|
if (typeof window !== 'undefined') {
|
|
52
52
|
result.screenSize = getScreenSize(window.innerWidth);
|
|
@@ -418,6 +418,25 @@ class AppWrapper {
|
|
|
418
418
|
}
|
|
419
419
|
},
|
|
420
420
|
selectPage: async options => {
|
|
421
|
+
var _this$values, _this$values2;
|
|
422
|
+
if ((_this$values = this.values) !== null && _this$values !== void 0 && (_this$values = _this$values.site) !== null && _this$values !== void 0 && _this$values.id && options.siteId && options.siteId !== ((_this$values2 = this.values) === null || _this$values2 === void 0 || (_this$values2 = _this$values2.site) === null || _this$values2 === void 0 ? void 0 : _this$values2.id)) {
|
|
423
|
+
const url = new URL(`https://chayns.site/${options.siteId}`);
|
|
424
|
+
if (options.id) {
|
|
425
|
+
url.pathname += `/tapp/${options.id}`;
|
|
426
|
+
} else if (options.path) {
|
|
427
|
+
url.pathname += `/${options.path}`;
|
|
428
|
+
}
|
|
429
|
+
if (options.params) {
|
|
430
|
+
Object.entries(options.params).forEach(([k, v]) => {
|
|
431
|
+
url.searchParams.set(k, v);
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
void this.appCall(9, {
|
|
435
|
+
url: url.toString(),
|
|
436
|
+
checkForChaynsSite: true
|
|
437
|
+
});
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
421
440
|
void this.appCall(2, {
|
|
422
441
|
id: options.id,
|
|
423
442
|
showName: options.showName,
|
|
@@ -17,13 +17,16 @@ const System = _ref => {
|
|
|
17
17
|
});
|
|
18
18
|
const Component = useMemo(() => {
|
|
19
19
|
// maybe return waitcursor instead
|
|
20
|
-
if (
|
|
20
|
+
if (failed) {
|
|
21
|
+
throw new Error('failed to load component');
|
|
22
|
+
}
|
|
23
|
+
if (!system || !ready) {
|
|
21
24
|
return null;
|
|
22
25
|
}
|
|
23
26
|
return /*#__PURE__*/React.lazy(loadComponent(system.scope, system.module, system.url, undefined, system.preventSingleton));
|
|
24
27
|
|
|
25
28
|
/* eslint-disable react-hooks/exhaustive-deps */
|
|
26
|
-
}, [system === null || system === void 0 ? void 0 : system.scope, ready, system === null || system === void 0 ? void 0 : system.url]);
|
|
29
|
+
}, [system === null || system === void 0 ? void 0 : system.scope, ready, failed, system === null || system === void 0 ? void 0 : system.url]);
|
|
27
30
|
return Component ? /*#__PURE__*/React.createElement(React.Suspense, {
|
|
28
31
|
fallback: fallback || ''
|
|
29
32
|
}, /*#__PURE__*/React.createElement(Component, props)) : fallback;
|
|
@@ -40,7 +40,7 @@ const getDeviceInfo = (userAgent, acceptHeader) => {
|
|
|
40
40
|
callVersion: match !== null && match !== void 0 && match.groups ? Number.parseInt(match.groups.version, 10) : NaN
|
|
41
41
|
};
|
|
42
42
|
result.imei = undefined; // TODO
|
|
43
|
-
result.
|
|
43
|
+
result.engine = uaParser.getEngine();
|
|
44
44
|
result.os = ((_uaParser$getOS = uaParser.getOS()) === null || _uaParser$getOS === void 0 ? void 0 : _uaParser$getOS.name) === 'Android' ? 'Android OS' : (_uaParser$getOS2 = uaParser.getOS()) === null || _uaParser$getOS2 === void 0 ? void 0 : _uaParser$getOS2.name;
|
|
45
45
|
if (typeof window !== 'undefined') {
|
|
46
46
|
result.screenSize = getScreenSize(window.innerWidth);
|
|
@@ -381,6 +381,26 @@ export class AppWrapper {
|
|
|
381
381
|
}
|
|
382
382
|
},
|
|
383
383
|
selectPage: async options => {
|
|
384
|
+
var _this$values, _this$values2;
|
|
385
|
+
if ((_this$values = this.values) !== null && _this$values !== void 0 && (_this$values = _this$values.site) !== null && _this$values !== void 0 && _this$values.id && options.siteId && options.siteId !== ((_this$values2 = this.values) === null || _this$values2 === void 0 || (_this$values2 = _this$values2.site) === null || _this$values2 === void 0 ? void 0 : _this$values2.id)) {
|
|
386
|
+
const url = new URL(`https://chayns.site/${options.siteId}`);
|
|
387
|
+
if (options.id) {
|
|
388
|
+
url.pathname += `/tapp/${options.id}`;
|
|
389
|
+
} else if (options.path) {
|
|
390
|
+
url.pathname += `/${options.path}`;
|
|
391
|
+
}
|
|
392
|
+
if (options.params) {
|
|
393
|
+
Object.entries(options.params).forEach(_ref2 => {
|
|
394
|
+
let [k, v] = _ref2;
|
|
395
|
+
url.searchParams.set(k, v);
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
void this.appCall(9, {
|
|
399
|
+
url: url.toString(),
|
|
400
|
+
checkForChaynsSite: true
|
|
401
|
+
});
|
|
402
|
+
return;
|
|
403
|
+
}
|
|
384
404
|
void this.appCall(2, {
|
|
385
405
|
id: options.id,
|
|
386
406
|
showName: options.showName,
|
|
@@ -593,10 +613,10 @@ export class AppWrapper {
|
|
|
593
613
|
this.appCall(254, {
|
|
594
614
|
enabled: true
|
|
595
615
|
}, {
|
|
596
|
-
callback:
|
|
616
|
+
callback: _ref3 => {
|
|
597
617
|
let {
|
|
598
618
|
colorMode
|
|
599
|
-
} =
|
|
619
|
+
} = _ref3;
|
|
600
620
|
this.values.site = {
|
|
601
621
|
...this.values.site,
|
|
602
622
|
colorMode
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IBrowser } from 'ua-parser-js';
|
|
1
|
+
import { IBrowser, IEngine } from 'ua-parser-js';
|
|
2
2
|
import DialogHandler from '../handler/DialogHandler';
|
|
3
3
|
import { DialogButtonOld, SelectDialogItem } from './dialog';
|
|
4
4
|
export type DialogButton = {
|
|
@@ -181,6 +181,7 @@ export type ChaynsApiDevice = {
|
|
|
181
181
|
majorVersion: number;
|
|
182
182
|
isWebPSupported: boolean;
|
|
183
183
|
};
|
|
184
|
+
engine?: IEngine;
|
|
184
185
|
imei?: string;
|
|
185
186
|
accessToken?: string;
|
|
186
187
|
os?: 'AIX' | 'Amiga OS' | 'Android OS' | 'Arch' | 'Bada' | 'BeOS' | 'BlackBerry' | 'CentOS' | 'Chromium OS' | 'Contiki' | 'Fedora' | 'Firefox OS' | 'FreeBSD' | 'Debian' | 'DragonFly' | 'Gentoo' | 'GNU' | 'Haiku' | 'Hurd' | 'iOS' | 'Joli' | 'Linpus' | 'Linux' | 'Mac OS' | 'Mageia' | 'Mandriva' | 'MeeGo' | 'Minix' | 'Mint' | 'Morph OS' | 'NetBSD' | 'Nintendo' | 'OpenBSD' | 'OpenVMS' | 'OS/2' | 'Palm' | 'PCLinuxOS' | 'Plan9' | 'Playstation' | 'QNX' | 'RedHat' | 'RIM Tablet OS' | 'RISC OS' | 'Sailfish' | 'Series40' | 'Slackware' | 'Solaris' | 'SUSE' | 'Symbian' | 'Tizen' | 'Ubuntu' | 'UNIX' | 'VectorLinux' | 'WebOS' | 'Windows' | 'Windows Phone' | 'Windows Mobile' | 'Zenwalk' | null;
|