chayns-api 1.1.8 → 1.1.10
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/components/withCompatMode.js +1 -1
- package/dist/cjs/util/deviceHelper.js +3 -1
- package/dist/cjs/wrapper/AppWrapper.js +19 -0
- package/dist/cjs/wrapper/StaticChaynsApi.js +12 -1
- package/dist/esm/components/withCompatMode.js +1 -1
- package/dist/esm/util/deviceHelper.js +3 -1
- package/dist/esm/wrapper/AppWrapper.js +22 -2
- package/dist/esm/wrapper/StaticChaynsApi.js +11 -1
- package/dist/types/calls/index.d.ts +4 -1
- package/dist/types/types/IChaynsReact.d.ts +1 -0
- package/package.json +1 -1
|
@@ -55,7 +55,7 @@ const withCompatMode = Component => {
|
|
|
55
55
|
if (this.root) {
|
|
56
56
|
this.root.unmount();
|
|
57
57
|
} else {
|
|
58
|
-
_reactDom.default.render(
|
|
58
|
+
_reactDom.default.render(/*#__PURE__*/_react.default.createElement(_react.default.Fragment, null), this.ref.current);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
render() {
|
|
@@ -7,7 +7,7 @@ exports.getScreenSize = exports.getClientDeviceInfo = exports.default = void 0;
|
|
|
7
7
|
var _uaParserJs = require("ua-parser-js");
|
|
8
8
|
var _IChaynsReact = require("../types/IChaynsReact");
|
|
9
9
|
const getDeviceInfo = (userAgent, acceptHeader) => {
|
|
10
|
-
var _match$groups, _match$groups2, _customMatch$groups, _browser$version$spli, _browser$version, _uaParser$getOS, _uaParser$getOS2;
|
|
10
|
+
var _match$groups, _match$groups2, _customMatch$groups, _browser$version$spli, _browser$version, _uaParser$getOS, _uaParser$getOS2, _uaParser$getOS3;
|
|
11
11
|
const uaParser = new _uaParserJs.UAParser(userAgent);
|
|
12
12
|
let appName = _IChaynsReact.AppName.Unknown;
|
|
13
13
|
const match = /(?:my)?chayns\/(?<version>\d+).*(?<siteId>\d{5}-\d{5})/i.exec(userAgent);
|
|
@@ -47,7 +47,9 @@ const getDeviceInfo = (userAgent, acceptHeader) => {
|
|
|
47
47
|
};
|
|
48
48
|
result.imei = undefined; // TODO
|
|
49
49
|
result.engine = uaParser.getEngine();
|
|
50
|
+
// TODO: breaking change on next minor and use object with name and version
|
|
50
51
|
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;
|
|
52
|
+
result.osVersion = (_uaParser$getOS3 = uaParser.getOS()) === null || _uaParser$getOS3 === void 0 ? void 0 : _uaParser$getOS3.version;
|
|
51
53
|
if (typeof window !== 'undefined') {
|
|
52
54
|
result.screenSize = getScreenSize(window.innerWidth);
|
|
53
55
|
result.isTouch = getClientDeviceInfo().isTouch;
|
|
@@ -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,
|
|
@@ -5,10 +5,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _moduleWrapper = require("../components/moduleWrapper");
|
|
8
|
+
var _IChaynsReact = require("../types/IChaynsReact");
|
|
9
|
+
var _deviceHelper = _interopRequireDefault(require("../util/deviceHelper"));
|
|
10
|
+
var _AppWrapper = require("./AppWrapper");
|
|
8
11
|
var _FrameWrapper = require("./FrameWrapper");
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
13
|
class StaticChaynsApi {
|
|
10
14
|
constructor() {
|
|
11
|
-
|
|
15
|
+
var _deviceInfo$app$name, _deviceInfo$app;
|
|
16
|
+
let wrapper;
|
|
17
|
+
const deviceInfo = (0, _deviceHelper.default)(navigator.userAgent, '');
|
|
18
|
+
if ([_IChaynsReact.AppName.Chayns, _IChaynsReact.AppName.ChaynsLauncher, _IChaynsReact.AppName.Sidekick, _IChaynsReact.AppName.TobitChat].includes((_deviceInfo$app$name = (_deviceInfo$app = deviceInfo.app) === null || _deviceInfo$app === void 0 ? void 0 : _deviceInfo$app.name) !== null && _deviceInfo$app$name !== void 0 ? _deviceInfo$app$name : _IChaynsReact.AppName.Unknown) && window.self === window.top) {
|
|
19
|
+
wrapper = new _AppWrapper.AppWrapper();
|
|
20
|
+
} else {
|
|
21
|
+
wrapper = new _FrameWrapper.FrameWrapper();
|
|
22
|
+
}
|
|
12
23
|
_moduleWrapper.moduleWrapper.current = wrapper;
|
|
13
24
|
this._wrapper = wrapper;
|
|
14
25
|
this.ready = wrapper.init();
|
|
@@ -48,7 +48,7 @@ export const withCompatMode = Component => {
|
|
|
48
48
|
if (this.root) {
|
|
49
49
|
this.root.unmount();
|
|
50
50
|
} else {
|
|
51
|
-
ReactDOM.render(
|
|
51
|
+
ReactDOM.render(/*#__PURE__*/React.createElement(React.Fragment, null), this.ref.current);
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
render() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { UAParser } from 'ua-parser-js';
|
|
2
2
|
import { AppName, ScreenSize } from '../types/IChaynsReact';
|
|
3
3
|
const getDeviceInfo = (userAgent, acceptHeader) => {
|
|
4
|
-
var _match$groups, _match$groups2, _customMatch$groups, _browser$version$spli, _browser$version, _uaParser$getOS, _uaParser$getOS2;
|
|
4
|
+
var _match$groups, _match$groups2, _customMatch$groups, _browser$version$spli, _browser$version, _uaParser$getOS, _uaParser$getOS2, _uaParser$getOS3;
|
|
5
5
|
const uaParser = new UAParser(userAgent);
|
|
6
6
|
let appName = AppName.Unknown;
|
|
7
7
|
const match = /(?:my)?chayns\/(?<version>\d+).*(?<siteId>\d{5}-\d{5})/i.exec(userAgent);
|
|
@@ -41,7 +41,9 @@ const getDeviceInfo = (userAgent, acceptHeader) => {
|
|
|
41
41
|
};
|
|
42
42
|
result.imei = undefined; // TODO
|
|
43
43
|
result.engine = uaParser.getEngine();
|
|
44
|
+
// TODO: breaking change on next minor and use object with name and version
|
|
44
45
|
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;
|
|
46
|
+
result.osVersion = (_uaParser$getOS3 = uaParser.getOS()) === null || _uaParser$getOS3 === void 0 ? void 0 : _uaParser$getOS3.version;
|
|
45
47
|
if (typeof window !== 'undefined') {
|
|
46
48
|
result.screenSize = getScreenSize(window.innerWidth);
|
|
47
49
|
result.isTouch = getClientDeviceInfo().isTouch;
|
|
@@ -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
|
|
@@ -2,9 +2,13 @@ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object
|
|
|
2
2
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
3
3
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
4
4
|
import { moduleWrapper } from '../components/moduleWrapper';
|
|
5
|
+
import { AppName } from '../types/IChaynsReact';
|
|
6
|
+
import getDeviceInfo from '../util/deviceHelper';
|
|
7
|
+
import { AppWrapper } from './AppWrapper';
|
|
5
8
|
import { FrameWrapper } from './FrameWrapper';
|
|
6
9
|
class StaticChaynsApi {
|
|
7
10
|
constructor() {
|
|
11
|
+
var _deviceInfo$app$name, _deviceInfo$app;
|
|
8
12
|
_defineProperty(this, "getUser", () => this._wrapper.values.user);
|
|
9
13
|
_defineProperty(this, "getSite", () => this._wrapper.values.site);
|
|
10
14
|
_defineProperty(this, "getCurrentPage", () => this._wrapper.values.currentPage);
|
|
@@ -13,7 +17,13 @@ class StaticChaynsApi {
|
|
|
13
17
|
_defineProperty(this, "getParameters", () => this._wrapper.values.parameters);
|
|
14
18
|
_defineProperty(this, "getPages", () => this._wrapper.values.pages);
|
|
15
19
|
_defineProperty(this, "getEnvironment", () => this._wrapper.values.environment);
|
|
16
|
-
|
|
20
|
+
let wrapper;
|
|
21
|
+
const deviceInfo = getDeviceInfo(navigator.userAgent, '');
|
|
22
|
+
if ([AppName.Chayns, AppName.ChaynsLauncher, AppName.Sidekick, AppName.TobitChat].includes((_deviceInfo$app$name = (_deviceInfo$app = deviceInfo.app) === null || _deviceInfo$app === void 0 ? void 0 : _deviceInfo$app.name) !== null && _deviceInfo$app$name !== void 0 ? _deviceInfo$app$name : AppName.Unknown) && window.self === window.top) {
|
|
23
|
+
wrapper = new AppWrapper();
|
|
24
|
+
} else {
|
|
25
|
+
wrapper = new FrameWrapper();
|
|
26
|
+
}
|
|
17
27
|
moduleWrapper.current = wrapper;
|
|
18
28
|
this._wrapper = wrapper;
|
|
19
29
|
this.ready = wrapper.init();
|
|
@@ -217,7 +217,10 @@ export declare const getUser: () => import("../types/IChaynsReact").ChaynsApiUse
|
|
|
217
217
|
export declare const getSite: () => ChaynsApiSite;
|
|
218
218
|
export declare const getCurrentPage: () => {
|
|
219
219
|
id: number;
|
|
220
|
-
siteId: string;
|
|
220
|
+
siteId: string; /**
|
|
221
|
+
* Removes scroll listener.
|
|
222
|
+
* @category Event listener
|
|
223
|
+
*/
|
|
221
224
|
};
|
|
222
225
|
export declare const getDevice: () => ChaynsApiDevice;
|
|
223
226
|
export declare const getLanguage: () => {
|
|
@@ -185,6 +185,7 @@ export type ChaynsApiDevice = {
|
|
|
185
185
|
imei?: string;
|
|
186
186
|
accessToken?: string;
|
|
187
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;
|
|
188
|
+
osVersion?: string;
|
|
188
189
|
isTouch: boolean;
|
|
189
190
|
screenSize: ScreenSize;
|
|
190
191
|
};
|