chayns-api 1.2.0-0 → 1.2.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/chayns-api.js +2 -0
- package/dist/chayns-api.js.LICENSE.txt +51 -0
- package/dist/cjs/components/withCompatMode.js +8 -5
- package/dist/cjs/host/module/utils/loadComponent.js +35 -22
- package/dist/cjs/host/module/utils/useDynamicScript.js +4 -6
- package/dist/cjs/index.js +12 -0
- package/dist/cjs/types/IChaynsReact.js +13 -1
- package/dist/cjs/util/deviceHelper.js +23 -11
- package/dist/cjs/util/is.js +30 -0
- package/dist/cjs/wrapper/AppWrapper.js +33 -5
- package/dist/cjs/wrapper/StaticChaynsApi.js +12 -1
- package/dist/esm/components/withCompatMode.js +8 -5
- package/dist/esm/host/module/utils/loadComponent.js +33 -19
- package/dist/esm/index.js +1 -0
- package/dist/esm/types/IChaynsReact.js +12 -0
- package/dist/esm/util/deviceHelper.js +24 -11
- package/dist/esm/util/is.js +23 -0
- package/dist/esm/wrapper/AppWrapper.js +36 -7
- package/dist/esm/wrapper/StaticChaynsApi.js +11 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/types/IChaynsReact.d.ts +45 -5
- package/dist/types/util/deviceHelper.d.ts +3 -1
- package/dist/types/util/is.d.ts +5 -0
- package/package.json +4 -3
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/*
|
|
2
|
+
object-assign
|
|
3
|
+
(c) Sindre Sorhus
|
|
4
|
+
@license MIT
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @license React
|
|
9
|
+
* scheduler.production.min.js
|
|
10
|
+
*
|
|
11
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
12
|
+
*
|
|
13
|
+
* This source code is licensed under the MIT license found in the
|
|
14
|
+
* LICENSE file in the root directory of this source tree.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/** @license React v0.20.2
|
|
18
|
+
* scheduler.production.min.js
|
|
19
|
+
*
|
|
20
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
21
|
+
*
|
|
22
|
+
* This source code is licensed under the MIT license found in the
|
|
23
|
+
* LICENSE file in the root directory of this source tree.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/** @license React v17.0.2
|
|
27
|
+
* react-dom.production.min.js
|
|
28
|
+
*
|
|
29
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
30
|
+
*
|
|
31
|
+
* This source code is licensed under the MIT license found in the
|
|
32
|
+
* LICENSE file in the root directory of this source tree.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/** @license React v17.0.2
|
|
36
|
+
* react-jsx-runtime.production.min.js
|
|
37
|
+
*
|
|
38
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
39
|
+
*
|
|
40
|
+
* This source code is licensed under the MIT license found in the
|
|
41
|
+
* LICENSE file in the root directory of this source tree.
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
/** @license React v17.0.2
|
|
45
|
+
* react.production.min.js
|
|
46
|
+
*
|
|
47
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
48
|
+
*
|
|
49
|
+
* This source code is licensed under the MIT license found in the
|
|
50
|
+
* LICENSE file in the root directory of this source tree.
|
|
51
|
+
*/
|
|
@@ -45,11 +45,14 @@ const withCompatMode = Component => {
|
|
|
45
45
|
const component = /*#__PURE__*/_react.default.createElement(_ErrorBoundary.default, null, /*#__PURE__*/_react.default.createElement(Component, _extends({}, this.props, {
|
|
46
46
|
ref: innerRef
|
|
47
47
|
})));
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
clearTimeout(this.timeout);
|
|
49
|
+
this.timeout = setTimeout(() => {
|
|
50
|
+
if (this.root) {
|
|
51
|
+
this.root.render(component);
|
|
52
|
+
} else {
|
|
53
|
+
_reactDom.default.render(component, this.ref.current);
|
|
54
|
+
}
|
|
55
|
+
}, 0);
|
|
53
56
|
}
|
|
54
57
|
componentWillUnmount() {
|
|
55
58
|
if (this.root) {
|
|
@@ -7,35 +7,48 @@ exports.loadModule = exports.default = void 0;
|
|
|
7
7
|
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
8
8
|
var _semver = _interopRequireDefault(require("semver"));
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
|
-
var _runtime = require("@module-federation/runtime");
|
|
11
|
-
var _process$env$__PACKAG;
|
|
12
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
// forces single instance of module federation runtime
|
|
12
|
+
if (!globalThis.moduleFederationRuntime) {
|
|
13
|
+
var _process$env$__PACKAG;
|
|
14
|
+
globalThis.moduleFederationRuntime = require('@module-federation/runtime');
|
|
15
|
+
const {
|
|
16
|
+
init
|
|
17
|
+
} = globalThis.moduleFederationRuntime;
|
|
18
|
+
|
|
19
|
+
// init also should only be called once
|
|
20
|
+
init({
|
|
21
|
+
// will be set by chayns-toolkit via DefinePlugin
|
|
22
|
+
name: (_process$env$__PACKAG = process.env.__PACKAGE_NAME__) !== null && _process$env$__PACKAG !== void 0 ? _process$env$__PACKAG : '',
|
|
23
|
+
remotes: [],
|
|
24
|
+
shared: {
|
|
25
|
+
react: {
|
|
26
|
+
version: _react.default.version,
|
|
27
|
+
scope: 'default',
|
|
28
|
+
lib: () => _react.default
|
|
29
|
+
},
|
|
30
|
+
'react-dom': {
|
|
31
|
+
version: _reactDom.default.version,
|
|
32
|
+
scope: 'default',
|
|
33
|
+
lib: () => _reactDom.default
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
const {
|
|
39
|
+
loadRemote,
|
|
40
|
+
registerRemotes,
|
|
41
|
+
loadShareSync
|
|
42
|
+
} = globalThis.moduleFederationRuntime;
|
|
13
43
|
const registeredScopes = {};
|
|
14
44
|
const moduleMap = {};
|
|
15
45
|
const componentMap = {};
|
|
16
|
-
(0, _runtime.init)({
|
|
17
|
-
// will be set by chayns-toolkit via DefinePlugin
|
|
18
|
-
name: (_process$env$__PACKAG = process.env.__PACKAGE_NAME__) !== null && _process$env$__PACKAG !== void 0 ? _process$env$__PACKAG : '',
|
|
19
|
-
remotes: [],
|
|
20
|
-
shared: {
|
|
21
|
-
react: {
|
|
22
|
-
version: _react.default.version,
|
|
23
|
-
scope: 'default',
|
|
24
|
-
lib: () => _react.default
|
|
25
|
-
},
|
|
26
|
-
'react-dom': {
|
|
27
|
-
version: _reactDom.default.version,
|
|
28
|
-
scope: 'default',
|
|
29
|
-
lib: () => _reactDom.default
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
46
|
const loadModule = (scope, module, url, preventSingleton = false) => {
|
|
34
47
|
if (registeredScopes[scope] !== url || preventSingleton) {
|
|
35
48
|
if (scope in registeredScopes) {
|
|
36
49
|
console.error(`[chayns-api] call registerRemote with force for scope ${scope}. url: ${url}`);
|
|
37
50
|
}
|
|
38
|
-
|
|
51
|
+
registerRemotes([{
|
|
39
52
|
name: scope,
|
|
40
53
|
entry: url,
|
|
41
54
|
alias: scope
|
|
@@ -48,7 +61,7 @@ const loadModule = (scope, module, url, preventSingleton = false) => {
|
|
|
48
61
|
}
|
|
49
62
|
if (!(module in moduleMap[scope])) {
|
|
50
63
|
const path = `${scope}/${module.replace(/^\.\//, '')}`;
|
|
51
|
-
const promise =
|
|
64
|
+
const promise = loadRemote(path);
|
|
52
65
|
promise.catch(e => {
|
|
53
66
|
console.error("[chayns-api] Failed to load module", scope, url, e);
|
|
54
67
|
// causes registerRemote with force = true on next attempt to load the component which tries to load the component again
|
|
@@ -77,7 +90,7 @@ const loadComponent = (scope, module, url, skipCompatMode = false, preventSingle
|
|
|
77
90
|
environment
|
|
78
91
|
} = Module.default;
|
|
79
92
|
const shareScopes = await new Promise(resolve => {
|
|
80
|
-
|
|
93
|
+
loadShareSync('react', {
|
|
81
94
|
resolver: shareOptions => {
|
|
82
95
|
resolve(shareOptions);
|
|
83
96
|
return shareOptions[0];
|
|
@@ -7,10 +7,9 @@ exports.semaphore = exports.default = void 0;
|
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _semaphoreAsyncAwait = _interopRequireDefault(require("semaphore-async-await"));
|
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
function _getRequireWildcardCache(
|
|
11
|
-
function _interopRequireWildcard(
|
|
12
|
-
const semaphore = {};
|
|
13
|
-
exports.semaphore = semaphore;
|
|
10
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
11
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
12
|
+
const semaphore = exports.semaphore = {};
|
|
14
13
|
const useDynamicScript = args => {
|
|
15
14
|
const [ready, setReady] = _react.default.useState(false);
|
|
16
15
|
const [failed, setFailed] = _react.default.useState(false);
|
|
@@ -57,5 +56,4 @@ const useDynamicScript = args => {
|
|
|
57
56
|
failed
|
|
58
57
|
};
|
|
59
58
|
};
|
|
60
|
-
var _default = useDynamicScript;
|
|
61
|
-
exports.default = _default;
|
|
59
|
+
var _default = exports.default = useDynamicScript;
|
package/dist/cjs/index.js
CHANGED
|
@@ -148,6 +148,18 @@ Object.keys(_IChaynsReact).forEach(function (key) {
|
|
|
148
148
|
}
|
|
149
149
|
});
|
|
150
150
|
});
|
|
151
|
+
var _is = require("./util/is");
|
|
152
|
+
Object.keys(_is).forEach(function (key) {
|
|
153
|
+
if (key === "default" || key === "__esModule") return;
|
|
154
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
155
|
+
if (key in exports && exports[key] === _is[key]) return;
|
|
156
|
+
Object.defineProperty(exports, key, {
|
|
157
|
+
enumerable: true,
|
|
158
|
+
get: function () {
|
|
159
|
+
return _is[key];
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
});
|
|
151
163
|
var _constants = require("./constants");
|
|
152
164
|
Object.keys(_constants).forEach(function (key) {
|
|
153
165
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -3,13 +3,23 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.ToastType = exports.TappEvent = exports.SharingApp = exports.ScreenSize = exports.ScanQrCodeCodeType = exports.ScanQrCodeCameraTypes = exports.RuntimeEnviroment = exports.MediaType = exports.Language = exports.IconType = exports.Gender = exports.Font = exports.FloatingButtonPosition = exports.Environment = exports.DialogType = exports.DialogSelectType = exports.DialogInputType = exports.DialogIconType = exports.DialogButtonType = exports.DialogAnimation = exports.DeviceOs = exports.DateType = exports.ColorMode = exports.BrowserName = exports.AppName = exports.AccessMode = void 0;
|
|
6
|
+
exports.WeekDayType = exports.ToastType = exports.TappEvent = exports.SharingApp = exports.ScreenSize = exports.ScanQrCodeCodeType = exports.ScanQrCodeCameraTypes = exports.RuntimeEnviroment = exports.MediaType = exports.Language = exports.IconType = exports.Gender = exports.Font = exports.FloatingButtonPosition = exports.Environment = exports.DialogType = exports.DialogSelectType = exports.DialogInputType = exports.DialogIconType = exports.DialogButtonType = exports.DialogAnimation = exports.DeviceOs = exports.DateType = exports.ColorMode = exports.BrowserName = exports.AppName = exports.AccessMode = void 0;
|
|
7
7
|
let DateType = exports.DateType = /*#__PURE__*/function (DateType) {
|
|
8
8
|
DateType[DateType["DATE"] = 0] = "DATE";
|
|
9
9
|
DateType[DateType["TIME"] = 1] = "TIME";
|
|
10
10
|
DateType[DateType["DATE_TIME"] = 2] = "DATE_TIME";
|
|
11
11
|
return DateType;
|
|
12
12
|
}({});
|
|
13
|
+
let WeekDayType = exports.WeekDayType = /*#__PURE__*/function (WeekDayType) {
|
|
14
|
+
WeekDayType[WeekDayType["SUNDAY"] = 0] = "SUNDAY";
|
|
15
|
+
WeekDayType[WeekDayType["MONDAY"] = 1] = "MONDAY";
|
|
16
|
+
WeekDayType[WeekDayType["TUESDAY"] = 2] = "TUESDAY";
|
|
17
|
+
WeekDayType[WeekDayType["WEDNESDAY"] = 3] = "WEDNESDAY";
|
|
18
|
+
WeekDayType[WeekDayType["THURSDAY"] = 4] = "THURSDAY";
|
|
19
|
+
WeekDayType[WeekDayType["FRIDAY"] = 5] = "FRIDAY";
|
|
20
|
+
WeekDayType[WeekDayType["SATURDAY"] = 6] = "SATURDAY";
|
|
21
|
+
return WeekDayType;
|
|
22
|
+
}({});
|
|
13
23
|
let ToastType = exports.ToastType = /*#__PURE__*/function (ToastType) {
|
|
14
24
|
ToastType[ToastType["NEUTRAL"] = 1] = "NEUTRAL";
|
|
15
25
|
ToastType[ToastType["SUCCESS"] = 2] = "SUCCESS";
|
|
@@ -29,6 +39,7 @@ let DialogSelectType = exports.DialogSelectType = /*#__PURE__*/function (DialogS
|
|
|
29
39
|
DialogSelectType[DialogSelectType["DEFAULT"] = 0] = "DEFAULT";
|
|
30
40
|
DialogSelectType[DialogSelectType["ICON"] = 1] = "ICON";
|
|
31
41
|
DialogSelectType[DialogSelectType["IMAGE"] = 2] = "IMAGE";
|
|
42
|
+
DialogSelectType[DialogSelectType["SIMPLE"] = 3] = "SIMPLE";
|
|
32
43
|
return DialogSelectType;
|
|
33
44
|
}({});
|
|
34
45
|
let DialogButtonType = exports.DialogButtonType = /*#__PURE__*/function (DialogButtonType) {
|
|
@@ -210,6 +221,7 @@ let RuntimeEnviroment = exports.RuntimeEnviroment = /*#__PURE__*/function (Runti
|
|
|
210
221
|
RuntimeEnviroment[RuntimeEnviroment["ChaynsRuntime"] = 3] = "ChaynsRuntime";
|
|
211
222
|
RuntimeEnviroment[RuntimeEnviroment["IntercomPlugin"] = 4] = "IntercomPlugin";
|
|
212
223
|
RuntimeEnviroment[RuntimeEnviroment["PagemakerPlugin"] = 5] = "PagemakerPlugin";
|
|
224
|
+
RuntimeEnviroment[RuntimeEnviroment["Dialog"] = 6] = "Dialog";
|
|
213
225
|
return RuntimeEnviroment;
|
|
214
226
|
}({});
|
|
215
227
|
let DeviceOs = exports.DeviceOs = /*#__PURE__*/function (DeviceOs) {
|
|
@@ -4,13 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getScreenSize = exports.getClientDeviceInfo = exports.default = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _uaParserJs = require("ua-parser-js");
|
|
8
8
|
var _IChaynsReact = require("../types/IChaynsReact");
|
|
9
|
-
const getDeviceInfo = (userAgent, acceptHeader
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
const getDeviceInfo = (userAgent, acceptHeader, {
|
|
10
|
+
imei
|
|
11
|
+
} = {}) => {
|
|
12
|
+
var _match$groups, _match$groups2, _customMatch$groups, _browser$version$spli, _browser$version, _uaParser$getOS, _uaParser$getOS2, _uaParser$getOS3;
|
|
13
|
+
const uaParser = new _uaParserJs.UAParser(userAgent);
|
|
12
14
|
let appName = _IChaynsReact.AppName.Unknown;
|
|
13
15
|
const match = /(?:my)?chayns\/(?<version>\d+).*(?<siteId>\d{5}-\d{5})/i.exec(userAgent);
|
|
16
|
+
const customMatch = /\s(?<name>intercom|sidekick|team)\/(?<version>\d+)/i.exec(userAgent);
|
|
14
17
|
if (/\sintercom\/\d+/i.test(userAgent)) {
|
|
15
18
|
appName = _IChaynsReact.AppName.TobitChat;
|
|
16
19
|
} else if (/\ssidekick\/\d+/i.test(userAgent)) {
|
|
@@ -26,20 +29,29 @@ const getDeviceInfo = (userAgent, acceptHeader) => {
|
|
|
26
29
|
} else if (/dface|h96pp|h96max|jabiru|chaynsterminal|wayter|odroidn2p/i.test(userAgent)) {
|
|
27
30
|
appName = _IChaynsReact.AppName.ChaynsLauncher;
|
|
28
31
|
}
|
|
32
|
+
let appVersion = match !== null && match !== void 0 && match.groups ? Number.parseInt(match.groups.version, 10) : NaN;
|
|
33
|
+
if (customMatch !== null && customMatch !== void 0 && (_customMatch$groups = customMatch.groups) !== null && _customMatch$groups !== void 0 && _customMatch$groups.version) {
|
|
34
|
+
appVersion = Number.parseInt(customMatch.groups.version, 10);
|
|
35
|
+
}
|
|
29
36
|
const result = {};
|
|
37
|
+
const browser = uaParser.getBrowser();
|
|
30
38
|
result.browser = {
|
|
31
|
-
name:
|
|
32
|
-
version:
|
|
33
|
-
majorVersion: Number.parseInt((
|
|
39
|
+
name: browser === null || browser === void 0 ? void 0 : browser.name,
|
|
40
|
+
version: browser === null || browser === void 0 ? void 0 : browser.version,
|
|
41
|
+
majorVersion: Number.parseInt((_browser$version$spli = browser === null || browser === void 0 || (_browser$version = browser.version) === null || _browser$version === void 0 ? void 0 : _browser$version.split('.')[0]) !== null && _browser$version$spli !== void 0 ? _browser$version$spli : '0', 10) || 0,
|
|
34
42
|
isWebPSupported: acceptHeader.includes('image/webp')
|
|
35
43
|
};
|
|
36
44
|
result.app = {
|
|
37
45
|
name: appName,
|
|
38
|
-
version: match !== null && match !== void 0 && match.groups ? Number.parseInt(match.groups.version, 10) : NaN
|
|
46
|
+
version: match !== null && match !== void 0 && match.groups ? Number.parseInt(match.groups.version, 10) : NaN,
|
|
47
|
+
appVersion,
|
|
48
|
+
callVersion: match !== null && match !== void 0 && match.groups ? Number.parseInt(match.groups.version, 10) : NaN
|
|
39
49
|
};
|
|
40
|
-
result.imei =
|
|
41
|
-
result.
|
|
42
|
-
|
|
50
|
+
result.imei = imei;
|
|
51
|
+
result.engine = uaParser.getEngine();
|
|
52
|
+
// TODO: breaking change on next minor and use object with name and version
|
|
53
|
+
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;
|
|
54
|
+
result.osVersion = (_uaParser$getOS3 = uaParser.getOS()) === null || _uaParser$getOS3 === void 0 ? void 0 : _uaParser$getOS3.version;
|
|
43
55
|
if (typeof window !== 'undefined') {
|
|
44
56
|
result.screenSize = getScreenSize(window.innerWidth);
|
|
45
57
|
result.isTouch = getClientDeviceInfo().isTouch;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isAppCallSupported = exports.isApp = void 0;
|
|
7
|
+
var _calls = require("../calls");
|
|
8
|
+
var _IChaynsReact = require("../types/IChaynsReact");
|
|
9
|
+
const isApp = () => {
|
|
10
|
+
var _getDevice$app$name, _getDevice$app;
|
|
11
|
+
return ((_getDevice$app$name = (_getDevice$app = (0, _calls.getDevice)().app) === null || _getDevice$app === void 0 ? void 0 : _getDevice$app.name) !== null && _getDevice$app$name !== void 0 ? _getDevice$app$name : _IChaynsReact.AppName.Unknown) !== _IChaynsReact.AppName.Unknown;
|
|
12
|
+
};
|
|
13
|
+
exports.isApp = isApp;
|
|
14
|
+
const isAppCallSupported = ({
|
|
15
|
+
minAndroidVersion = 1,
|
|
16
|
+
minIOSVersion = 1
|
|
17
|
+
}) => {
|
|
18
|
+
var _device$app;
|
|
19
|
+
if (!isApp()) return false;
|
|
20
|
+
const device = (0, _calls.getDevice)();
|
|
21
|
+
if (!((_device$app = device.app) !== null && _device$app !== void 0 && _device$app.callVersion) || isNaN(device.app.callVersion)) return false;
|
|
22
|
+
if (device.os && ['iOS', 'Mac OS'].includes(device.os)) {
|
|
23
|
+
return device.app.callVersion >= minIOSVersion;
|
|
24
|
+
}
|
|
25
|
+
if (device.os === 'Android OS') {
|
|
26
|
+
return device.app.callVersion >= minAndroidVersion;
|
|
27
|
+
}
|
|
28
|
+
return false;
|
|
29
|
+
};
|
|
30
|
+
exports.isAppCallSupported = isAppCallSupported;
|
|
@@ -13,6 +13,7 @@ var _getUserInfo = _interopRequireDefault(require("../calls/getUserInfo"));
|
|
|
13
13
|
var _sendMessage = require("../calls/sendMessage");
|
|
14
14
|
var _apiListenerHelper = require("../helper/apiListenerHelper");
|
|
15
15
|
var _languages = require("../constants/languages");
|
|
16
|
+
var _is = require("../util/is");
|
|
16
17
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
17
18
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
18
19
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -67,7 +68,9 @@ class AppWrapper {
|
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
70
|
return {
|
|
70
|
-
device: (0, _deviceHelper.default)(navigator.userAgent, 'image/webp'
|
|
71
|
+
device: (0, _deviceHelper.default)(navigator.userAgent, 'image/webp', {
|
|
72
|
+
imei: Device.IMEI
|
|
73
|
+
}),
|
|
71
74
|
environment: {
|
|
72
75
|
buildEnvironment: _IChaynsReact.Environment.Production,
|
|
73
76
|
runtimeEnvironment: _IChaynsReact.RuntimeEnviroment.Unknown
|
|
@@ -417,6 +420,25 @@ class AppWrapper {
|
|
|
417
420
|
}
|
|
418
421
|
},
|
|
419
422
|
selectPage: async options => {
|
|
423
|
+
var _this$values, _this$values2;
|
|
424
|
+
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)) {
|
|
425
|
+
const url = new URL(`https://chayns.site/${options.siteId}`);
|
|
426
|
+
if (options.id) {
|
|
427
|
+
url.pathname += `/tapp/${options.id}`;
|
|
428
|
+
} else if (options.path) {
|
|
429
|
+
url.pathname += `/${options.path}`;
|
|
430
|
+
}
|
|
431
|
+
if (options.params) {
|
|
432
|
+
Object.entries(options.params).forEach(([k, v]) => {
|
|
433
|
+
url.searchParams.set(k, v);
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
void this.appCall(9, {
|
|
437
|
+
url: url.toString(),
|
|
438
|
+
checkForChaynsSite: true
|
|
439
|
+
});
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
420
442
|
void this.appCall(2, {
|
|
421
443
|
id: options.id,
|
|
422
444
|
showName: options.showName,
|
|
@@ -426,14 +448,16 @@ class AppWrapper {
|
|
|
426
448
|
awaitResult: false
|
|
427
449
|
});
|
|
428
450
|
},
|
|
429
|
-
scrollToY: async position => {
|
|
451
|
+
scrollToY: async (position, duration) => {
|
|
430
452
|
window.scrollTo({
|
|
431
|
-
top: position
|
|
453
|
+
top: position,
|
|
454
|
+
behavior: duration ? 'smooth' : 'auto'
|
|
432
455
|
});
|
|
433
456
|
},
|
|
434
457
|
scrollByY: (value, duration) => {
|
|
435
458
|
window.scrollBy({
|
|
436
|
-
top: value
|
|
459
|
+
top: value,
|
|
460
|
+
behavior: duration ? 'smooth' : 'auto'
|
|
437
461
|
});
|
|
438
462
|
},
|
|
439
463
|
sendMessageToGroup: async (groupId, message) => {
|
|
@@ -539,12 +563,16 @@ class AppWrapper {
|
|
|
539
563
|
},
|
|
540
564
|
openDialog: async (config, callback) => {
|
|
541
565
|
const currentDialogId = appWrapperDialogId++;
|
|
566
|
+
const isSupported = (0, _is.isAppCallSupported)({
|
|
567
|
+
minAndroidVersion: 7137,
|
|
568
|
+
minIOSVersion: 6934
|
|
569
|
+
});
|
|
542
570
|
this.appCall(184, {
|
|
543
571
|
dialogContent: {
|
|
544
572
|
apiVersion: 5,
|
|
545
573
|
config
|
|
546
574
|
},
|
|
547
|
-
externalDialogUrl: 'https://tapp.chayns-static.space/api/dialog-v2/v1/index.html'
|
|
575
|
+
externalDialogUrl: isSupported ? undefined : 'https://tapp.chayns-static.space/api/dialog-v2/v1/index.html'
|
|
548
576
|
}, {
|
|
549
577
|
awaitResult: true
|
|
550
578
|
}).then(result => {
|
|
@@ -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(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
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();
|
|
@@ -38,11 +38,14 @@ export const withCompatMode = Component => {
|
|
|
38
38
|
const component = /*#__PURE__*/React.createElement(ErrorBoundary, null, /*#__PURE__*/React.createElement(Component, _extends({}, this.props, {
|
|
39
39
|
ref: innerRef
|
|
40
40
|
})));
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
clearTimeout(this.timeout);
|
|
42
|
+
this.timeout = setTimeout(() => {
|
|
43
|
+
if (this.root) {
|
|
44
|
+
this.root.render(component);
|
|
45
|
+
} else {
|
|
46
|
+
ReactDOM.render(component, this.ref.current);
|
|
47
|
+
}
|
|
48
|
+
}, 0);
|
|
46
49
|
}
|
|
47
50
|
componentWillUnmount() {
|
|
48
51
|
if (this.root) {
|
|
@@ -1,28 +1,42 @@
|
|
|
1
|
-
var _process$env$__PACKAG;
|
|
2
1
|
import ReactDOM from 'react-dom';
|
|
3
2
|
import semver from 'semver';
|
|
4
3
|
import React from 'react';
|
|
5
|
-
|
|
4
|
+
|
|
5
|
+
// forces single instance of module federation runtime
|
|
6
|
+
if (!globalThis.moduleFederationRuntime) {
|
|
7
|
+
var _process$env$__PACKAG;
|
|
8
|
+
globalThis.moduleFederationRuntime = require('@module-federation/runtime');
|
|
9
|
+
const {
|
|
10
|
+
init
|
|
11
|
+
} = globalThis.moduleFederationRuntime;
|
|
12
|
+
|
|
13
|
+
// init also should only be called once
|
|
14
|
+
init({
|
|
15
|
+
// will be set by chayns-toolkit via DefinePlugin
|
|
16
|
+
name: (_process$env$__PACKAG = process.env.__PACKAGE_NAME__) !== null && _process$env$__PACKAG !== void 0 ? _process$env$__PACKAG : '',
|
|
17
|
+
remotes: [],
|
|
18
|
+
shared: {
|
|
19
|
+
react: {
|
|
20
|
+
version: React.version,
|
|
21
|
+
scope: 'default',
|
|
22
|
+
lib: () => React
|
|
23
|
+
},
|
|
24
|
+
'react-dom': {
|
|
25
|
+
version: ReactDOM.version,
|
|
26
|
+
scope: 'default',
|
|
27
|
+
lib: () => ReactDOM
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
const {
|
|
33
|
+
loadRemote,
|
|
34
|
+
registerRemotes,
|
|
35
|
+
loadShareSync
|
|
36
|
+
} = globalThis.moduleFederationRuntime;
|
|
6
37
|
const registeredScopes = {};
|
|
7
38
|
const moduleMap = {};
|
|
8
39
|
const componentMap = {};
|
|
9
|
-
init({
|
|
10
|
-
// will be set by chayns-toolkit via DefinePlugin
|
|
11
|
-
name: (_process$env$__PACKAG = process.env.__PACKAGE_NAME__) !== null && _process$env$__PACKAG !== void 0 ? _process$env$__PACKAG : '',
|
|
12
|
-
remotes: [],
|
|
13
|
-
shared: {
|
|
14
|
-
react: {
|
|
15
|
-
version: React.version,
|
|
16
|
-
scope: 'default',
|
|
17
|
-
lib: () => React
|
|
18
|
-
},
|
|
19
|
-
'react-dom': {
|
|
20
|
-
version: ReactDOM.version,
|
|
21
|
-
scope: 'default',
|
|
22
|
-
lib: () => ReactDOM
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
40
|
export const loadModule = function (scope, module, url) {
|
|
27
41
|
let preventSingleton = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
28
42
|
if (registeredScopes[scope] !== url || preventSingleton) {
|
package/dist/esm/index.js
CHANGED
|
@@ -7,6 +7,7 @@ export * from './calls';
|
|
|
7
7
|
export * from './hooks';
|
|
8
8
|
export * from './components/WaitUntil';
|
|
9
9
|
export * from './types/IChaynsReact';
|
|
10
|
+
export * from './util/is';
|
|
10
11
|
export * from './components/withCompatMode';
|
|
11
12
|
export * from './constants';
|
|
12
13
|
export { default as withHydrationBoundary } from './components/withHydrationBoundary';
|
|
@@ -4,6 +4,16 @@ export let DateType = /*#__PURE__*/function (DateType) {
|
|
|
4
4
|
DateType[DateType["DATE_TIME"] = 2] = "DATE_TIME";
|
|
5
5
|
return DateType;
|
|
6
6
|
}({});
|
|
7
|
+
export let WeekDayType = /*#__PURE__*/function (WeekDayType) {
|
|
8
|
+
WeekDayType[WeekDayType["SUNDAY"] = 0] = "SUNDAY";
|
|
9
|
+
WeekDayType[WeekDayType["MONDAY"] = 1] = "MONDAY";
|
|
10
|
+
WeekDayType[WeekDayType["TUESDAY"] = 2] = "TUESDAY";
|
|
11
|
+
WeekDayType[WeekDayType["WEDNESDAY"] = 3] = "WEDNESDAY";
|
|
12
|
+
WeekDayType[WeekDayType["THURSDAY"] = 4] = "THURSDAY";
|
|
13
|
+
WeekDayType[WeekDayType["FRIDAY"] = 5] = "FRIDAY";
|
|
14
|
+
WeekDayType[WeekDayType["SATURDAY"] = 6] = "SATURDAY";
|
|
15
|
+
return WeekDayType;
|
|
16
|
+
}({});
|
|
7
17
|
export let ToastType = /*#__PURE__*/function (ToastType) {
|
|
8
18
|
ToastType[ToastType["NEUTRAL"] = 1] = "NEUTRAL";
|
|
9
19
|
ToastType[ToastType["SUCCESS"] = 2] = "SUCCESS";
|
|
@@ -23,6 +33,7 @@ export let DialogSelectType = /*#__PURE__*/function (DialogSelectType) {
|
|
|
23
33
|
DialogSelectType[DialogSelectType["DEFAULT"] = 0] = "DEFAULT";
|
|
24
34
|
DialogSelectType[DialogSelectType["ICON"] = 1] = "ICON";
|
|
25
35
|
DialogSelectType[DialogSelectType["IMAGE"] = 2] = "IMAGE";
|
|
36
|
+
DialogSelectType[DialogSelectType["SIMPLE"] = 3] = "SIMPLE";
|
|
26
37
|
return DialogSelectType;
|
|
27
38
|
}({});
|
|
28
39
|
export let DialogButtonType = /*#__PURE__*/function (DialogButtonType) {
|
|
@@ -207,6 +218,7 @@ export let RuntimeEnviroment = /*#__PURE__*/function (RuntimeEnviroment) {
|
|
|
207
218
|
RuntimeEnviroment[RuntimeEnviroment["ChaynsRuntime"] = 3] = "ChaynsRuntime";
|
|
208
219
|
RuntimeEnviroment[RuntimeEnviroment["IntercomPlugin"] = 4] = "IntercomPlugin";
|
|
209
220
|
RuntimeEnviroment[RuntimeEnviroment["PagemakerPlugin"] = 5] = "PagemakerPlugin";
|
|
221
|
+
RuntimeEnviroment[RuntimeEnviroment["Dialog"] = 6] = "Dialog";
|
|
210
222
|
return RuntimeEnviroment;
|
|
211
223
|
}({});
|
|
212
224
|
export let DeviceOs = /*#__PURE__*/function (DeviceOs) {
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UAParser } from 'ua-parser-js';
|
|
2
2
|
import { AppName, ScreenSize } from '../types/IChaynsReact';
|
|
3
|
-
const getDeviceInfo = (userAgent, acceptHeader)
|
|
4
|
-
var _match$groups, _match$groups2,
|
|
5
|
-
|
|
3
|
+
const getDeviceInfo = function (userAgent, acceptHeader) {
|
|
4
|
+
var _match$groups, _match$groups2, _customMatch$groups, _browser$version$spli, _browser$version, _uaParser$getOS, _uaParser$getOS2, _uaParser$getOS3;
|
|
5
|
+
let {
|
|
6
|
+
imei
|
|
7
|
+
} = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
8
|
+
const uaParser = new UAParser(userAgent);
|
|
6
9
|
let appName = AppName.Unknown;
|
|
7
10
|
const match = /(?:my)?chayns\/(?<version>\d+).*(?<siteId>\d{5}-\d{5})/i.exec(userAgent);
|
|
11
|
+
const customMatch = /\s(?<name>intercom|sidekick|team)\/(?<version>\d+)/i.exec(userAgent);
|
|
8
12
|
if (/\sintercom\/\d+/i.test(userAgent)) {
|
|
9
13
|
appName = AppName.TobitChat;
|
|
10
14
|
} else if (/\ssidekick\/\d+/i.test(userAgent)) {
|
|
@@ -20,20 +24,29 @@ const getDeviceInfo = (userAgent, acceptHeader) => {
|
|
|
20
24
|
} else if (/dface|h96pp|h96max|jabiru|chaynsterminal|wayter|odroidn2p/i.test(userAgent)) {
|
|
21
25
|
appName = AppName.ChaynsLauncher;
|
|
22
26
|
}
|
|
27
|
+
let appVersion = match !== null && match !== void 0 && match.groups ? Number.parseInt(match.groups.version, 10) : NaN;
|
|
28
|
+
if (customMatch !== null && customMatch !== void 0 && (_customMatch$groups = customMatch.groups) !== null && _customMatch$groups !== void 0 && _customMatch$groups.version) {
|
|
29
|
+
appVersion = Number.parseInt(customMatch.groups.version, 10);
|
|
30
|
+
}
|
|
23
31
|
const result = {};
|
|
32
|
+
const browser = uaParser.getBrowser();
|
|
24
33
|
result.browser = {
|
|
25
|
-
name:
|
|
26
|
-
version:
|
|
27
|
-
majorVersion: Number.parseInt((
|
|
34
|
+
name: browser === null || browser === void 0 ? void 0 : browser.name,
|
|
35
|
+
version: browser === null || browser === void 0 ? void 0 : browser.version,
|
|
36
|
+
majorVersion: Number.parseInt((_browser$version$spli = browser === null || browser === void 0 || (_browser$version = browser.version) === null || _browser$version === void 0 ? void 0 : _browser$version.split('.')[0]) !== null && _browser$version$spli !== void 0 ? _browser$version$spli : '0', 10) || 0,
|
|
28
37
|
isWebPSupported: acceptHeader.includes('image/webp')
|
|
29
38
|
};
|
|
30
39
|
result.app = {
|
|
31
40
|
name: appName,
|
|
32
|
-
version: match !== null && match !== void 0 && match.groups ? Number.parseInt(match.groups.version, 10) : NaN
|
|
41
|
+
version: match !== null && match !== void 0 && match.groups ? Number.parseInt(match.groups.version, 10) : NaN,
|
|
42
|
+
appVersion,
|
|
43
|
+
callVersion: match !== null && match !== void 0 && match.groups ? Number.parseInt(match.groups.version, 10) : NaN
|
|
33
44
|
};
|
|
34
|
-
result.imei =
|
|
35
|
-
result.
|
|
36
|
-
|
|
45
|
+
result.imei = imei;
|
|
46
|
+
result.engine = uaParser.getEngine();
|
|
47
|
+
// TODO: breaking change on next minor and use object with name and version
|
|
48
|
+
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;
|
|
49
|
+
result.osVersion = (_uaParser$getOS3 = uaParser.getOS()) === null || _uaParser$getOS3 === void 0 ? void 0 : _uaParser$getOS3.version;
|
|
37
50
|
if (typeof window !== 'undefined') {
|
|
38
51
|
result.screenSize = getScreenSize(window.innerWidth);
|
|
39
52
|
result.isTouch = getClientDeviceInfo().isTouch;
|