chayns-api 2.2.0-beta.2 → 2.2.0-beta.4
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/context.js +4 -4
- package/dist/cjs/hooks/useParameters.js +1 -1
- package/dist/cjs/index.js +0 -11
- package/dist/cjs/types/IChaynsReact.js +6 -1
- package/dist/cjs/util/bindChaynsApi.js +3 -2
- package/dist/cjs/util/deviceHelper.js +1 -0
- package/dist/cjs/wrapper/AppWrapper.js +7 -3
- package/dist/esm/hooks/context.js +4 -4
- package/dist/esm/hooks/useParameters.js +1 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/types/IChaynsReact.js +5 -0
- package/dist/esm/util/bindChaynsApi.js +1 -1
- package/dist/esm/util/deviceHelper.js +2 -1
- package/dist/esm/wrapper/AppWrapper.js +7 -3
- package/dist/types/host/ChaynsHost.d.ts +12 -2
- package/dist/types/index.d.ts +0 -1
- package/dist/types/types/IChaynsReact.d.ts +7 -1
- package/package.json +9 -9
|
@@ -7,7 +7,7 @@ exports.useValuesSelector = exports.useFunctionsSelector = exports.useCustomFunc
|
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _shim = require("use-sync-external-store/shim");
|
|
9
9
|
var _ChaynsContext = require("../components/ChaynsContext");
|
|
10
|
-
const
|
|
10
|
+
const createChaynsSelector = key => selector => {
|
|
11
11
|
const store = (0, _react.useContext)(_ChaynsContext.ChaynsContext);
|
|
12
12
|
if (!store) {
|
|
13
13
|
throw new Error('Could not find chayns context. Did you forget to add ChaynsProvider?');
|
|
@@ -15,6 +15,6 @@ const useChaynsSelector = key => selector => {
|
|
|
15
15
|
const getSnapshot = () => selector(store[key]);
|
|
16
16
|
return (0, _shim.useSyncExternalStore)(store.subscribe, getSnapshot, getSnapshot);
|
|
17
17
|
};
|
|
18
|
-
const useValuesSelector = exports.useValuesSelector =
|
|
19
|
-
const useFunctionsSelector = exports.useFunctionsSelector =
|
|
20
|
-
const useCustomFunctionsSelector = exports.useCustomFunctionsSelector =
|
|
18
|
+
const useValuesSelector = exports.useValuesSelector = createChaynsSelector('values');
|
|
19
|
+
const useFunctionsSelector = exports.useFunctionsSelector = createChaynsSelector('functions');
|
|
20
|
+
const useCustomFunctionsSelector = exports.useCustomFunctionsSelector = createChaynsSelector('customFunctions');
|
|
@@ -5,5 +5,5 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.useParameters = void 0;
|
|
7
7
|
var _context = require("./context");
|
|
8
|
-
const useParameters = () => (0, _context.useValuesSelector)(v => v.parameters
|
|
8
|
+
const useParameters = () => (0, _context.useValuesSelector)(v => v.parameters);
|
|
9
9
|
exports.useParameters = useParameters;
|
package/dist/cjs/index.js
CHANGED
|
@@ -89,17 +89,6 @@ var _ChaynsProvider = _interopRequireDefault(require("./components/ChaynsProvide
|
|
|
89
89
|
var _deviceHelper = _interopRequireWildcard(require("./util/deviceHelper"));
|
|
90
90
|
var _ChaynsHost = _interopRequireDefault(require("./host/ChaynsHost"));
|
|
91
91
|
var _withCompatMode = require("./components/withCompatMode");
|
|
92
|
-
Object.keys(_withCompatMode).forEach(function (key) {
|
|
93
|
-
if (key === "default" || key === "__esModule") return;
|
|
94
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
95
|
-
if (key in exports && exports[key] === _withCompatMode[key]) return;
|
|
96
|
-
Object.defineProperty(exports, key, {
|
|
97
|
-
enumerable: true,
|
|
98
|
-
get: function () {
|
|
99
|
-
return _withCompatMode[key];
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
92
|
var _calls = require("./calls");
|
|
104
93
|
Object.keys(_calls).forEach(function (key) {
|
|
105
94
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.WeekDayType = exports.ToastType = exports.TappEvent = exports.SharingApp = exports.ScreenSize = exports.ScanQrCodeCodeType = exports.ScanQrCodeCameraTypes = exports.RuntimeEnviroment = exports.MediaType = exports.Language = exports.IconType = exports.IconStyle = exports.Gender = exports.Font = exports.FloatingButtonPosition = exports.FloatingButtonAnimation = 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.IconStyle = exports.Gender = exports.Font = exports.FloatingButtonPosition = exports.FloatingButtonAnimation = 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.AppFlavor = exports.AccessMode = void 0;
|
|
7
7
|
let DateType = exports.DateType = function (DateType) {
|
|
8
8
|
DateType[DateType["DATE"] = 0] = "DATE";
|
|
9
9
|
DateType[DateType["TIME"] = 1] = "TIME";
|
|
@@ -64,6 +64,11 @@ let ScreenSize = exports.ScreenSize = function (ScreenSize) {
|
|
|
64
64
|
ScreenSize[ScreenSize["XL"] = 4] = "XL";
|
|
65
65
|
return ScreenSize;
|
|
66
66
|
}({});
|
|
67
|
+
let AppFlavor = exports.AppFlavor = function (AppFlavor) {
|
|
68
|
+
AppFlavor["None"] = "none";
|
|
69
|
+
AppFlavor["Chayns"] = "chayns";
|
|
70
|
+
return AppFlavor;
|
|
71
|
+
}({});
|
|
67
72
|
let AccessMode = exports.AccessMode = function (AccessMode) {
|
|
68
73
|
AccessMode[AccessMode["public"] = 0] = "public";
|
|
69
74
|
AccessMode[AccessMode["protected"] = 1] = "protected";
|
|
@@ -4,9 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.bindChaynsApi = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _StaticChaynsApi = _interopRequireDefault(require("../wrapper/StaticChaynsApi"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
9
|
const bindChaynsApi = fun => (values, functions) => {
|
|
9
|
-
new
|
|
10
|
+
new _StaticChaynsApi.default(values, functions);
|
|
10
11
|
return fun;
|
|
11
12
|
};
|
|
12
13
|
exports.bindChaynsApi = bindChaynsApi;
|
|
@@ -45,6 +45,7 @@ const getDeviceInfo = (userAgent, acceptHeader, {
|
|
|
45
45
|
};
|
|
46
46
|
result.app = {
|
|
47
47
|
name: appName,
|
|
48
|
+
flavor: appName === _IChaynsReact.AppName.Unknown ? _IChaynsReact.AppFlavor.None : _IChaynsReact.AppFlavor.Chayns,
|
|
48
49
|
version: match !== null && match !== void 0 && match.groups ? Number.parseInt(match.groups.version, 10) : NaN,
|
|
49
50
|
appVersion,
|
|
50
51
|
callVersion: match !== null && match !== void 0 && match.groups ? Number.parseInt(match.groups.version, 10) : NaN
|
|
@@ -124,6 +124,7 @@ class AppWrapper {
|
|
|
124
124
|
gender: _IChaynsReact.Gender.Unknown,
|
|
125
125
|
userId: userId,
|
|
126
126
|
personId: AppUser.PersonID,
|
|
127
|
+
isAnonymous: AppUser.IsAnonymous,
|
|
127
128
|
uacGroups: []
|
|
128
129
|
},
|
|
129
130
|
customData: null,
|
|
@@ -624,9 +625,12 @@ class AppWrapper {
|
|
|
624
625
|
callback: ({
|
|
625
626
|
colorMode
|
|
626
627
|
}) => {
|
|
627
|
-
this.values
|
|
628
|
-
...this.values
|
|
629
|
-
|
|
628
|
+
this.values = {
|
|
629
|
+
...this.values,
|
|
630
|
+
site: {
|
|
631
|
+
...this.values.site,
|
|
632
|
+
colorMode
|
|
633
|
+
}
|
|
630
634
|
};
|
|
631
635
|
document.dispatchEvent(new CustomEvent('chayns_api_data', {
|
|
632
636
|
detail: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useContext } from 'react';
|
|
2
2
|
import { useSyncExternalStore } from 'use-sync-external-store/shim';
|
|
3
3
|
import { ChaynsContext } from '../components/ChaynsContext';
|
|
4
|
-
const
|
|
4
|
+
const createChaynsSelector = key => selector => {
|
|
5
5
|
const store = useContext(ChaynsContext);
|
|
6
6
|
if (!store) {
|
|
7
7
|
throw new Error('Could not find chayns context. Did you forget to add ChaynsProvider?');
|
|
@@ -9,6 +9,6 @@ const useChaynsSelector = key => selector => {
|
|
|
9
9
|
const getSnapshot = () => selector(store[key]);
|
|
10
10
|
return useSyncExternalStore(store.subscribe, getSnapshot, getSnapshot);
|
|
11
11
|
};
|
|
12
|
-
export const useValuesSelector =
|
|
13
|
-
export const useFunctionsSelector =
|
|
14
|
-
export const useCustomFunctionsSelector =
|
|
12
|
+
export const useValuesSelector = createChaynsSelector('values');
|
|
13
|
+
export const useFunctionsSelector = createChaynsSelector('functions');
|
|
14
|
+
export const useCustomFunctionsSelector = createChaynsSelector('customFunctions');
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { useValuesSelector } from './context';
|
|
2
|
-
export const useParameters = () => useValuesSelector(v => v.parameters
|
|
2
|
+
export const useParameters = () => useValuesSelector(v => v.parameters);
|
package/dist/esm/index.js
CHANGED
|
@@ -8,7 +8,6 @@ export * from './hooks';
|
|
|
8
8
|
export * from './components/WaitUntil';
|
|
9
9
|
export * from './types/IChaynsReact';
|
|
10
10
|
export * from './util/is';
|
|
11
|
-
export * from './components/withCompatMode';
|
|
12
11
|
export * from './constants';
|
|
13
12
|
export { default as withHydrationBoundary } from './components/withHydrationBoundary';
|
|
14
13
|
export { default as StaticChaynsApi } from './wrapper/StaticChaynsApi';
|
|
@@ -58,6 +58,11 @@ export let ScreenSize = function (ScreenSize) {
|
|
|
58
58
|
ScreenSize[ScreenSize["XL"] = 4] = "XL";
|
|
59
59
|
return ScreenSize;
|
|
60
60
|
}({});
|
|
61
|
+
export let AppFlavor = function (AppFlavor) {
|
|
62
|
+
AppFlavor["None"] = "none";
|
|
63
|
+
AppFlavor["Chayns"] = "chayns";
|
|
64
|
+
return AppFlavor;
|
|
65
|
+
}({});
|
|
61
66
|
export let AccessMode = function (AccessMode) {
|
|
62
67
|
AccessMode[AccessMode["public"] = 0] = "public";
|
|
63
68
|
AccessMode[AccessMode["protected"] = 1] = "protected";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UAParser } from 'ua-parser-js';
|
|
2
|
-
import { AppName, ScreenSize } from '../types/IChaynsReact';
|
|
2
|
+
import { AppFlavor, AppName, ScreenSize } from '../types/IChaynsReact';
|
|
3
3
|
const getDeviceInfo = function (userAgent, acceptHeader) {
|
|
4
4
|
var _match$groups, _match$groups2, _customMatch$groups, _browser$version$spli, _browser$version, _uaParser$getOS, _uaParser$getOS2, _uaParser$getOS3;
|
|
5
5
|
let {
|
|
@@ -40,6 +40,7 @@ const getDeviceInfo = function (userAgent, acceptHeader) {
|
|
|
40
40
|
};
|
|
41
41
|
result.app = {
|
|
42
42
|
name: appName,
|
|
43
|
+
flavor: appName === AppName.Unknown ? AppFlavor.None : AppFlavor.Chayns,
|
|
43
44
|
version: match !== null && match !== void 0 && match.groups ? Number.parseInt(match.groups.version, 10) : NaN,
|
|
44
45
|
appVersion,
|
|
45
46
|
callVersion: match !== null && match !== void 0 && match.groups ? Number.parseInt(match.groups.version, 10) : NaN
|
|
@@ -114,6 +114,7 @@ export class AppWrapper {
|
|
|
114
114
|
gender: Gender.Unknown,
|
|
115
115
|
userId: userId,
|
|
116
116
|
personId: AppUser.PersonID,
|
|
117
|
+
isAnonymous: AppUser.IsAnonymous,
|
|
117
118
|
uacGroups: []
|
|
118
119
|
},
|
|
119
120
|
customData: null,
|
|
@@ -635,9 +636,12 @@ export class AppWrapper {
|
|
|
635
636
|
let {
|
|
636
637
|
colorMode
|
|
637
638
|
} = _ref3;
|
|
638
|
-
this.values
|
|
639
|
-
...this.values
|
|
640
|
-
|
|
639
|
+
this.values = {
|
|
640
|
+
...this.values,
|
|
641
|
+
site: {
|
|
642
|
+
...this.values.site,
|
|
643
|
+
colorMode
|
|
644
|
+
}
|
|
641
645
|
};
|
|
642
646
|
document.dispatchEvent(new CustomEvent('chayns_api_data', {
|
|
643
647
|
detail: {
|
|
@@ -11,7 +11,7 @@ type ChaynsHostType = {
|
|
|
11
11
|
customFunctions?: IChaynsReact["customFunctions"];
|
|
12
12
|
src?: string;
|
|
13
13
|
iFrameRef?: React.MutableRefObject<HTMLIFrameElement | null> | undefined;
|
|
14
|
-
loadingComponent?:
|
|
14
|
+
loadingComponent?: React.ReactNode;
|
|
15
15
|
system?: TypeSystem;
|
|
16
16
|
pages: Page[];
|
|
17
17
|
isAdminModeActive: boolean;
|
|
@@ -26,6 +26,16 @@ type ChaynsHostType = {
|
|
|
26
26
|
preventStagingReplacement?: boolean;
|
|
27
27
|
dialog: ChaynsReactValues["dialog"];
|
|
28
28
|
styleSettings?: ChaynsReactValues["styleSettings"];
|
|
29
|
-
}
|
|
29
|
+
} & ({
|
|
30
|
+
type: `${'client' | 'server'}-iframe`;
|
|
31
|
+
src: string;
|
|
32
|
+
iFrameProps: {
|
|
33
|
+
[key: string]: unknown;
|
|
34
|
+
name: string;
|
|
35
|
+
};
|
|
36
|
+
} | {
|
|
37
|
+
type: `${'client' | 'server'}-module`;
|
|
38
|
+
system: TypeSystem;
|
|
39
|
+
});
|
|
30
40
|
declare const ChaynsHost: FC<ChaynsHostType>;
|
|
31
41
|
export default ChaynsHost;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -8,7 +8,6 @@ export * from './hooks';
|
|
|
8
8
|
export * from './components/WaitUntil';
|
|
9
9
|
export * from './types/IChaynsReact';
|
|
10
10
|
export * from './util/is';
|
|
11
|
-
export * from './components/withCompatMode';
|
|
12
11
|
export * from './constants';
|
|
13
12
|
export { default as withHydrationBoundary } from './components/withHydrationBoundary';
|
|
14
13
|
export { default as StaticChaynsApi } from './wrapper/StaticChaynsApi';
|
|
@@ -165,6 +165,7 @@ export type ChaynsApiUser = {
|
|
|
165
165
|
uacGroups?: UacGroup[];
|
|
166
166
|
userId?: number;
|
|
167
167
|
personId?: string;
|
|
168
|
+
isAnonymous?: boolean;
|
|
168
169
|
};
|
|
169
170
|
export type ChaynsApiSite = {
|
|
170
171
|
id: string;
|
|
@@ -236,6 +237,10 @@ export declare enum ScreenSize {
|
|
|
236
237
|
/** screen width larger than 1200px */
|
|
237
238
|
XL = 4
|
|
238
239
|
}
|
|
240
|
+
export declare enum AppFlavor {
|
|
241
|
+
None = "none",
|
|
242
|
+
Chayns = "chayns"
|
|
243
|
+
}
|
|
239
244
|
export type ChaynsApiDevice = {
|
|
240
245
|
app?: {
|
|
241
246
|
name: AppName;
|
|
@@ -246,6 +251,8 @@ export type ChaynsApiDevice = {
|
|
|
246
251
|
/** the version of the chayns call interface */
|
|
247
252
|
callVersion: number;
|
|
248
253
|
storePackageName?: string;
|
|
254
|
+
/** the flavor of the app, e. g. all chayns apps including chat app, sidekick, team */
|
|
255
|
+
flavor: AppFlavor;
|
|
249
256
|
};
|
|
250
257
|
browser?: {
|
|
251
258
|
name?: IBrowser["name"] | 'bot' | null;
|
|
@@ -435,7 +442,6 @@ export interface RefreshData {
|
|
|
435
442
|
user?: boolean;
|
|
436
443
|
chaynsProData?: boolean;
|
|
437
444
|
ignoreUacCache?: boolean;
|
|
438
|
-
styleSettings?: boolean;
|
|
439
445
|
chaynsInfo?: boolean;
|
|
440
446
|
}
|
|
441
447
|
export type IntercomMessage = {
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chayns-api",
|
|
3
|
-
"version": "2.2.0-beta.
|
|
3
|
+
"version": "2.2.0-beta.4",
|
|
4
4
|
"description": "new chayns api",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
7
7
|
"types": "dist/types/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
+
"types": "./dist/types/index.d.ts",
|
|
10
11
|
"require": "./dist/cjs/index.js",
|
|
11
|
-
"
|
|
12
|
-
"types": "./dist/types/index.d.ts"
|
|
12
|
+
"default": "./dist/esm/index.js"
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"keywords": [
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@babel/cli": "^7.26.4",
|
|
55
|
-
"@babel/core": "^7.26.
|
|
55
|
+
"@babel/core": "^7.26.9",
|
|
56
56
|
"@babel/preset-env": "^7.26.0",
|
|
57
57
|
"@babel/preset-react": "^7.26.3",
|
|
58
58
|
"@babel/preset-typescript": "^7.26.0",
|
|
@@ -60,16 +60,16 @@
|
|
|
60
60
|
"@rsbuild/plugin-umd": "^1.0.4",
|
|
61
61
|
"@types/htmlescape": "^1.1.3",
|
|
62
62
|
"@types/lodash.throttle": "^4.1.9",
|
|
63
|
-
"@types/prop-types": "^15.7.
|
|
64
|
-
"@types/react": "^18.
|
|
65
|
-
"@types/react-dom": "^18.
|
|
63
|
+
"@types/prop-types": "^15.7.14",
|
|
64
|
+
"@types/react": "^18.3.18",
|
|
65
|
+
"@types/react-dom": "^18.3.5",
|
|
66
66
|
"@types/ua-parser-js": "^0.7.39",
|
|
67
67
|
"@types/use-sync-external-store": "^0.0.6",
|
|
68
68
|
"@typescript-eslint/parser": "^7.6.0",
|
|
69
|
-
"chayns-toolkit": "^3.
|
|
69
|
+
"chayns-toolkit": "^3.2.0",
|
|
70
70
|
"concurrently": "^9.1.2",
|
|
71
71
|
"cross-env": "^7.0.3",
|
|
72
|
-
"prettier": "^3.
|
|
72
|
+
"prettier": "^3.5.1",
|
|
73
73
|
"prettier-plugin-packagejson": "^2.5.8",
|
|
74
74
|
"react": "^18.3.1",
|
|
75
75
|
"react-dom": "^18.3.1",
|