chayns-api 2.1.6 → 2.1.8
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/calls/index.js +3 -1
- package/dist/cjs/components/ChaynsProvider.js +9 -2
- package/dist/cjs/hooks/context.js +11 -2
- package/dist/cjs/hooks/index.js +8 -1
- package/dist/cjs/hooks/useCustomFunction.js +9 -0
- package/dist/cjs/host/ChaynsHost.js +3 -0
- package/dist/cjs/host/iframe/HostIframe.js +10 -0
- package/dist/cjs/host/module/ModuleHost.js +2 -0
- package/dist/cjs/wrapper/AppWrapper.js +1 -0
- package/dist/cjs/wrapper/FrameWrapper.js +21 -0
- package/dist/cjs/wrapper/ModuleFederationWrapper.js +5 -1
- package/dist/cjs/wrapper/SsrWrapper.js +2 -1
- package/dist/cjs/wrapper/StaticChaynsApi.js +1 -0
- package/dist/esm/calls/index.js +1 -0
- package/dist/esm/components/ChaynsProvider.js +9 -2
- package/dist/esm/hooks/context.js +8 -0
- package/dist/esm/hooks/index.js +2 -1
- package/dist/esm/hooks/useCustomFunction.js +2 -0
- package/dist/esm/host/ChaynsHost.js +3 -0
- package/dist/esm/host/iframe/HostIframe.js +10 -0
- package/dist/esm/host/module/ModuleHost.js +2 -0
- package/dist/esm/wrapper/AppWrapper.js +1 -0
- package/dist/esm/wrapper/FrameWrapper.js +31 -0
- package/dist/esm/wrapper/ModuleFederationWrapper.js +5 -1
- package/dist/esm/wrapper/SsrWrapper.js +2 -1
- package/dist/esm/wrapper/StaticChaynsApi.js +1 -0
- package/dist/types/calls/index.d.ts +7 -1
- package/dist/types/components/ChaynsProvider.d.ts +2 -1
- package/dist/types/hooks/context.d.ts +1 -0
- package/dist/types/hooks/index.d.ts +1 -0
- package/dist/types/hooks/useCustomCallbackFunction.d.ts +2 -1
- package/dist/types/hooks/useCustomFunction.d.ts +6 -0
- package/dist/types/host/ChaynsHost.d.ts +2 -1
- package/dist/types/host/iframe/HostIframe.d.ts +2 -1
- package/dist/types/host/module/ModuleHost.d.ts +2 -1
- package/dist/types/types/IChaynsReact.d.ts +3 -0
- package/dist/types/wrapper/AppWrapper.d.ts +1 -0
- package/dist/types/wrapper/FrameWrapper.d.ts +3 -0
- package/dist/types/wrapper/ModuleFederationWrapper.d.ts +2 -1
- package/dist/types/wrapper/SsrWrapper.d.ts +2 -1
- package/dist/types/wrapper/StaticChaynsApi.d.ts +2 -0
- package/package.json +1 -1
package/dist/cjs/calls/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.vibrate = exports.user = exports.storageSetItem = exports.storageRemoveItem = exports.storageGetItem = exports.site = exports.setWaitCursor = exports.setTempDesignSettings = exports.setScanQrCode = exports.setRefreshScrollEnabled = exports.setOverlay = exports.setHeight = exports.setFloatingButton = exports.setDisplayTimeout = exports.setAdminMode = exports.sendMessageToUser = exports.sendMessageToPage = exports.sendMessageToGroup = exports.selectPage = exports.scrollToY = exports.scrollByY = exports.removeWindowMetricsListener = exports.removeVisibilityChangeListener = exports.removeToolbarChangeListener = exports.removeScrollListener = exports.removeGeoLocationListener = exports.refreshData = exports.refreshAccessToken = exports.parameters = exports.pages = exports.openVideo = exports.openUrl = exports.openMedia = exports.openImage = exports.navigateBack = exports.logout = exports.login = exports.language = exports.invokeDialogCall = exports.invokeCall = exports.getWindowMetrics = exports.getUserInfo = exports.getUser = exports.getSite = exports.getScrollPosition = exports.getParameters = exports.getPages = exports.getLanguage = exports.getGeoLocation = exports.getEnvironment = exports.getDevice = exports.getCurrentPage = exports.getAvailableSharingServices = exports.getAccessToken = exports.environment = exports.device = exports.customCallbackFunction = exports.createDialog = exports.addWindowMetricsListener = exports.addVisibilityChangeListener = exports.addToolbarChangeListener = exports.addScrollListener = exports.addGeoLocationListener = exports.addAnonymousAccount = void 0;
|
|
6
|
+
exports.vibrate = exports.user = exports.storageSetItem = exports.storageRemoveItem = exports.storageGetItem = exports.site = exports.setWaitCursor = exports.setTempDesignSettings = exports.setScanQrCode = exports.setRefreshScrollEnabled = exports.setOverlay = exports.setHeight = exports.setFloatingButton = exports.setDisplayTimeout = exports.setAdminMode = exports.sendMessageToUser = exports.sendMessageToPage = exports.sendMessageToGroup = exports.selectPage = exports.scrollToY = exports.scrollByY = exports.removeWindowMetricsListener = exports.removeVisibilityChangeListener = exports.removeToolbarChangeListener = exports.removeScrollListener = exports.removeGeoLocationListener = exports.refreshData = exports.refreshAccessToken = exports.parameters = exports.pages = exports.openVideo = exports.openUrl = exports.openMedia = exports.openImage = exports.navigateBack = exports.logout = exports.login = exports.language = exports.invokeDialogCall = exports.invokeCall = exports.getWindowMetrics = exports.getUserInfo = exports.getUser = exports.getSite = exports.getScrollPosition = exports.getParameters = exports.getPages = exports.getLanguage = exports.getGeoLocation = exports.getEnvironment = exports.getDevice = exports.getCustomFunction = exports.getCurrentPage = exports.getAvailableSharingServices = exports.getAccessToken = exports.environment = exports.device = exports.customCallbackFunction = exports.createDialog = exports.addWindowMetricsListener = exports.addVisibilityChangeListener = exports.addToolbarChangeListener = exports.addScrollListener = exports.addGeoLocationListener = exports.addAnonymousAccount = void 0;
|
|
7
7
|
var _moduleWrapper = require("../components/moduleWrapper");
|
|
8
8
|
const addGeoLocationListener = (...args) => _moduleWrapper.moduleWrapper.current.functions.addGeoLocationListener(...args);
|
|
9
9
|
exports.addGeoLocationListener = addGeoLocationListener;
|
|
@@ -119,6 +119,8 @@ const getPages = () => _moduleWrapper.moduleWrapper.current.values.pages;
|
|
|
119
119
|
exports.getPages = getPages;
|
|
120
120
|
const getEnvironment = () => _moduleWrapper.moduleWrapper.current.values.environment;
|
|
121
121
|
exports.getEnvironment = getEnvironment;
|
|
122
|
+
const getCustomFunction = key => _moduleWrapper.moduleWrapper.current.customFunctions[key];
|
|
123
|
+
exports.getCustomFunction = getCustomFunction;
|
|
122
124
|
const user = exports.user = new Proxy({}, {
|
|
123
125
|
get: (target, prop) => {
|
|
124
126
|
var _moduleWrapper$curren;
|
|
@@ -37,6 +37,7 @@ const ChaynsProvider = ({
|
|
|
37
37
|
children,
|
|
38
38
|
data,
|
|
39
39
|
functions,
|
|
40
|
+
customFunctions,
|
|
40
41
|
renderedByServer,
|
|
41
42
|
isModule
|
|
42
43
|
}) => {
|
|
@@ -45,13 +46,13 @@ const ChaynsProvider = ({
|
|
|
45
46
|
if (!customWrapper.current) {
|
|
46
47
|
if (isModule) {
|
|
47
48
|
if (data && functions) {
|
|
48
|
-
customWrapper.current = new _ModuleFederationWrapper.ModuleFederationWrapper(data, functions);
|
|
49
|
+
customWrapper.current = new _ModuleFederationWrapper.ModuleFederationWrapper(data, functions, customFunctions);
|
|
49
50
|
} else {
|
|
50
51
|
console.warn('ModuleFederationWrapper requires data and functions');
|
|
51
52
|
}
|
|
52
53
|
} else if (isServer) {
|
|
53
54
|
if (data && functions) {
|
|
54
|
-
customWrapper.current = new _SsrWrapper.SsrWrapper(data, functions);
|
|
55
|
+
customWrapper.current = new _SsrWrapper.SsrWrapper(data, functions, customFunctions);
|
|
55
56
|
} else {
|
|
56
57
|
console.warn('SsrWrapper requires data and functions');
|
|
57
58
|
}
|
|
@@ -89,6 +90,12 @@ const ChaynsProvider = ({
|
|
|
89
90
|
}
|
|
90
91
|
}
|
|
91
92
|
}, [data, isModule]);
|
|
93
|
+
(0, _react.useEffect)(() => {
|
|
94
|
+
if (isModule && customFunctions) {
|
|
95
|
+
customWrapper.current.customFunctions = customFunctions;
|
|
96
|
+
customWrapper.current.emitChange();
|
|
97
|
+
}
|
|
98
|
+
}, [customFunctions, isModule]);
|
|
92
99
|
return _react.default.createElement(_react.default.Fragment, null, isInitialized && _react.default.createElement(_ChaynsContext.ChaynsContext.Provider, {
|
|
93
100
|
value: customWrapper.current
|
|
94
101
|
}, children), _react.default.createElement(InitialDataProvider, {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.useValuesSelector = exports.useFunctionsSelector = void 0;
|
|
6
|
+
exports.useValuesSelector = exports.useFunctionsSelector = exports.useCustomFunctionsSelector = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _shim = require("use-sync-external-store/shim");
|
|
9
9
|
var _ChaynsContext = require("../components/ChaynsContext");
|
|
@@ -24,4 +24,13 @@ const useFunctionsSelector = selector => {
|
|
|
24
24
|
const getSnapshot = () => selector(store.functions);
|
|
25
25
|
return (0, _shim.useSyncExternalStore)(store.subscribe, getSnapshot, getSnapshot);
|
|
26
26
|
};
|
|
27
|
-
exports.useFunctionsSelector = useFunctionsSelector;
|
|
27
|
+
exports.useFunctionsSelector = useFunctionsSelector;
|
|
28
|
+
const useCustomFunctionsSelector = selector => {
|
|
29
|
+
const store = (0, _react.useContext)(_ChaynsContext.ChaynsContext);
|
|
30
|
+
if (!store) {
|
|
31
|
+
throw new Error('Could not find chayns context. Did you forget to add ChaynsProvider?');
|
|
32
|
+
}
|
|
33
|
+
const getSnapshot = () => selector(store.customFunctions);
|
|
34
|
+
return (0, _shim.useSyncExternalStore)(store.subscribe, getSnapshot, getSnapshot);
|
|
35
|
+
};
|
|
36
|
+
exports.useCustomFunctionsSelector = useCustomFunctionsSelector;
|
package/dist/cjs/hooks/index.js
CHANGED
|
@@ -33,6 +33,12 @@ Object.defineProperty(exports, "useCustomData", {
|
|
|
33
33
|
return _useCustomData.useCustomData;
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
|
+
Object.defineProperty(exports, "useCustomFunction", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _useCustomFunction.useCustomFunction;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
36
42
|
Object.defineProperty(exports, "useDevice", {
|
|
37
43
|
enumerable: true,
|
|
38
44
|
get: function () {
|
|
@@ -176,4 +182,5 @@ var _useFunctions = require("./useFunctions");
|
|
|
176
182
|
var _useCurrentPage = require("./useCurrentPage");
|
|
177
183
|
var _useCustomData = require("./useCustomData");
|
|
178
184
|
var _useDialogState = require("./useDialogState");
|
|
179
|
-
var _useCustomCallbackFunction = require("./useCustomCallbackFunction");
|
|
185
|
+
var _useCustomCallbackFunction = require("./useCustomCallbackFunction");
|
|
186
|
+
var _useCustomFunction = require("./useCustomFunction");
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useCustomFunction = void 0;
|
|
7
|
+
var _context = require("./context");
|
|
8
|
+
const useCustomFunction = key => (0, _context.useCustomFunctionsSelector)(customFunctions => customFunctions[key]);
|
|
9
|
+
exports.useCustomFunction = useCustomFunction;
|
|
@@ -14,6 +14,7 @@ const ChaynsHost = ({
|
|
|
14
14
|
type,
|
|
15
15
|
iFrameProps,
|
|
16
16
|
functions,
|
|
17
|
+
customFunctions,
|
|
17
18
|
src,
|
|
18
19
|
iFrameRef = undefined,
|
|
19
20
|
loadingComponent = undefined,
|
|
@@ -58,6 +59,7 @@ const ChaynsHost = ({
|
|
|
58
59
|
device: device,
|
|
59
60
|
currentPage: currentPage,
|
|
60
61
|
functions: functions,
|
|
62
|
+
customFunctions: customFunctions,
|
|
61
63
|
src: src,
|
|
62
64
|
postForm: type === 'server-iframe',
|
|
63
65
|
language: language,
|
|
@@ -79,6 +81,7 @@ const ChaynsHost = ({
|
|
|
79
81
|
currentPage: currentPage,
|
|
80
82
|
children: loadingComponent,
|
|
81
83
|
functions: functions,
|
|
84
|
+
customFunctions: customFunctions,
|
|
82
85
|
language: language,
|
|
83
86
|
parameters: parameters,
|
|
84
87
|
customData: customData,
|
|
@@ -24,6 +24,7 @@ const HostIframe = ({
|
|
|
24
24
|
user,
|
|
25
25
|
currentPage,
|
|
26
26
|
functions,
|
|
27
|
+
customFunctions,
|
|
27
28
|
device,
|
|
28
29
|
language,
|
|
29
30
|
parameters,
|
|
@@ -35,6 +36,8 @@ const HostIframe = ({
|
|
|
35
36
|
const eventTarget = (0, _react.useRef)();
|
|
36
37
|
const ref = (0, _react.useRef)();
|
|
37
38
|
const currentDataRef = (0, _react.useRef)();
|
|
39
|
+
const customFunctionsRef = (0, _react.useRef)();
|
|
40
|
+
customFunctionsRef.current = customFunctions;
|
|
38
41
|
if (!eventTarget.current) {
|
|
39
42
|
eventTarget.current = global.document ? document.createElement('div') : undefined;
|
|
40
43
|
}
|
|
@@ -79,6 +82,13 @@ const HostIframe = ({
|
|
|
79
82
|
...functions,
|
|
80
83
|
setHeight
|
|
81
84
|
},
|
|
85
|
+
customFunctions: new Proxy(customFunctionsRef, {
|
|
86
|
+
get: (target, p) => {
|
|
87
|
+
var _target$current;
|
|
88
|
+
return (_target$current = target.current) === null || _target$current === void 0 ? void 0 : _target$current[p];
|
|
89
|
+
}
|
|
90
|
+
}),
|
|
91
|
+
_customFunctionNames: Object.keys(customFunctions !== null && customFunctions !== void 0 ? customFunctions : {}),
|
|
82
92
|
addDataListener: cb => {
|
|
83
93
|
if (eventTarget.current) eventTarget.current.addEventListener('data_update', e => e.detail && cb(e.detail));
|
|
84
94
|
},
|
|
@@ -24,6 +24,7 @@ const ModuleHost = ({
|
|
|
24
24
|
system,
|
|
25
25
|
children = null,
|
|
26
26
|
functions,
|
|
27
|
+
customFunctions,
|
|
27
28
|
pages,
|
|
28
29
|
isAdminModeActive,
|
|
29
30
|
site,
|
|
@@ -66,6 +67,7 @@ const ModuleHost = ({
|
|
|
66
67
|
},
|
|
67
68
|
data: initialData,
|
|
68
69
|
functions: functions,
|
|
70
|
+
customFunctions: customFunctions,
|
|
69
71
|
fallback: children,
|
|
70
72
|
isModule: true
|
|
71
73
|
}));
|
|
@@ -17,6 +17,8 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
17
17
|
class FrameWrapper {
|
|
18
18
|
resolve = null;
|
|
19
19
|
exposedFunctions = null;
|
|
20
|
+
exposedCustomFunctions = {};
|
|
21
|
+
exposedCustomFunctionNames = [];
|
|
20
22
|
resizeListener = null;
|
|
21
23
|
ready = new Promise(res => {
|
|
22
24
|
this.resolve = res;
|
|
@@ -298,6 +300,18 @@ class FrameWrapper {
|
|
|
298
300
|
return this.exposedFunctions.addAnonymousAccount();
|
|
299
301
|
}
|
|
300
302
|
};
|
|
303
|
+
customFunctions = new Proxy({}, {
|
|
304
|
+
get: (target, p) => {
|
|
305
|
+
if (p in target) {
|
|
306
|
+
return target[p];
|
|
307
|
+
}
|
|
308
|
+
return target[p] = async (...args) => {
|
|
309
|
+
if (!this.initialized) await this.ready;
|
|
310
|
+
const wrappedArgs = args.map(v => typeof v === 'function' ? comlink.proxy(v) : v);
|
|
311
|
+
return this.exposedCustomFunctions[p](...wrappedArgs);
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
});
|
|
301
315
|
initialized = false;
|
|
302
316
|
constructor() {
|
|
303
317
|
const initialDataTag = document.querySelector('#__CHAYNS_DATA__');
|
|
@@ -306,6 +320,7 @@ class FrameWrapper {
|
|
|
306
320
|
}
|
|
307
321
|
}
|
|
308
322
|
async init() {
|
|
323
|
+
var _await$exposed$_custo;
|
|
309
324
|
if (this.initialized) return;
|
|
310
325
|
const exposed = comlink.wrap(comlink.windowEndpoint(window.parent))[window.name];
|
|
311
326
|
const dataListener = () => exposed.addDataListener(comlink.proxy(({
|
|
@@ -333,6 +348,12 @@ class FrameWrapper {
|
|
|
333
348
|
if (hostReadyCallback) window.removeEventListener('message', hostReadyCallback);
|
|
334
349
|
this.values = await exposed.getInitialData();
|
|
335
350
|
this.exposedFunctions = exposed.functions;
|
|
351
|
+
this.exposedCustomFunctions = exposed.customFunctions;
|
|
352
|
+
this.exposedCustomFunctionNames = (_await$exposed$_custo = await exposed._customFunctionNames) !== null && _await$exposed$_custo !== void 0 ? _await$exposed$_custo : [];
|
|
353
|
+
this.customFunctions = this.exposedCustomFunctionNames.reduce((p, e) => {
|
|
354
|
+
p[e] = (...args) => this.exposedCustomFunctions[e](...args.map(a => typeof a === 'function' ? comlink.proxy(a) : a));
|
|
355
|
+
return p;
|
|
356
|
+
}, {});
|
|
336
357
|
this.initialized = true;
|
|
337
358
|
this.resolve(null);
|
|
338
359
|
(0, _heightHelper.setTappHeight)(this.functions.setHeight);
|
|
@@ -11,8 +11,9 @@ var _getUserInfo = _interopRequireDefault(require("../calls/getUserInfo"));
|
|
|
11
11
|
var _sendMessage = require("../calls/sendMessage");
|
|
12
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
13
|
class ModuleFederationWrapper {
|
|
14
|
+
customFunctions = {};
|
|
14
15
|
listeners = [];
|
|
15
|
-
constructor(values, functions) {
|
|
16
|
+
constructor(values, functions, customFunctions) {
|
|
16
17
|
this.values = values;
|
|
17
18
|
this.functions = {};
|
|
18
19
|
this.functions.addVisibilityChangeListener = async callback => (0, _visibilityChangeListener.addVisibilityChangeListener)(callback);
|
|
@@ -24,6 +25,9 @@ class ModuleFederationWrapper {
|
|
|
24
25
|
Object.entries(functions).forEach(([k, fn]) => {
|
|
25
26
|
this.functions[k] = async (...args) => fn(...args);
|
|
26
27
|
});
|
|
28
|
+
if (customFunctions) {
|
|
29
|
+
this.customFunctions = customFunctions;
|
|
30
|
+
}
|
|
27
31
|
this.functions.createDialog = config => {
|
|
28
32
|
return new _DialogHandler.default(config, functions.openDialog, functions.closeDialog, functions.dispatchEventToDialogClient, functions.addDialogClientEventListener);
|
|
29
33
|
};
|
|
@@ -6,10 +6,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.SsrWrapper = void 0;
|
|
7
7
|
class SsrWrapper {
|
|
8
8
|
listeners = [];
|
|
9
|
-
constructor(values, functions) {
|
|
9
|
+
constructor(values, functions, customFunctions) {
|
|
10
10
|
this.initialData = values;
|
|
11
11
|
this.values = values;
|
|
12
12
|
this.functions = functions;
|
|
13
|
+
this.customFunctions = customFunctions !== null && customFunctions !== void 0 ? customFunctions : {};
|
|
13
14
|
}
|
|
14
15
|
async init() {
|
|
15
16
|
return undefined;
|
|
@@ -39,5 +39,6 @@ class StaticChaynsApi {
|
|
|
39
39
|
getParameters = () => this._wrapper.values.parameters;
|
|
40
40
|
getPages = () => this._wrapper.values.pages;
|
|
41
41
|
getEnvironment = () => this._wrapper.values.environment;
|
|
42
|
+
getCustomFunction = key => this._wrapper.customFunctions[key];
|
|
42
43
|
}
|
|
43
44
|
var _default = exports.default = StaticChaynsApi;
|
package/dist/esm/calls/index.js
CHANGED
|
@@ -150,6 +150,7 @@ export const getLanguage = () => moduleWrapper.current.values.language;
|
|
|
150
150
|
export const getParameters = () => moduleWrapper.current.values.parameters;
|
|
151
151
|
export const getPages = () => moduleWrapper.current.values.pages;
|
|
152
152
|
export const getEnvironment = () => moduleWrapper.current.values.environment;
|
|
153
|
+
export const getCustomFunction = key => moduleWrapper.current.customFunctions[key];
|
|
153
154
|
export const user = new Proxy({}, {
|
|
154
155
|
get: (target, prop) => {
|
|
155
156
|
var _moduleWrapper$curren;
|
|
@@ -31,6 +31,7 @@ const ChaynsProvider = _ref2 => {
|
|
|
31
31
|
children,
|
|
32
32
|
data,
|
|
33
33
|
functions,
|
|
34
|
+
customFunctions,
|
|
34
35
|
renderedByServer,
|
|
35
36
|
isModule
|
|
36
37
|
} = _ref2;
|
|
@@ -38,13 +39,13 @@ const ChaynsProvider = _ref2 => {
|
|
|
38
39
|
if (!customWrapper.current) {
|
|
39
40
|
if (isModule) {
|
|
40
41
|
if (data && functions) {
|
|
41
|
-
customWrapper.current = new ModuleFederationWrapper(data, functions);
|
|
42
|
+
customWrapper.current = new ModuleFederationWrapper(data, functions, customFunctions);
|
|
42
43
|
} else {
|
|
43
44
|
console.warn('ModuleFederationWrapper requires data and functions');
|
|
44
45
|
}
|
|
45
46
|
} else if (isServer) {
|
|
46
47
|
if (data && functions) {
|
|
47
|
-
customWrapper.current = new SsrWrapper(data, functions);
|
|
48
|
+
customWrapper.current = new SsrWrapper(data, functions, customFunctions);
|
|
48
49
|
} else {
|
|
49
50
|
console.warn('SsrWrapper requires data and functions');
|
|
50
51
|
}
|
|
@@ -83,6 +84,12 @@ const ChaynsProvider = _ref2 => {
|
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
86
|
}, [data, isModule]);
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
if (isModule && customFunctions) {
|
|
89
|
+
customWrapper.current.customFunctions = customFunctions;
|
|
90
|
+
customWrapper.current.emitChange();
|
|
91
|
+
}
|
|
92
|
+
}, [customFunctions, isModule]);
|
|
86
93
|
return React.createElement(React.Fragment, null, isInitialized && React.createElement(ChaynsContext.Provider, {
|
|
87
94
|
value: customWrapper.current
|
|
88
95
|
}, children), React.createElement(InitialDataProvider, {
|
|
@@ -16,4 +16,12 @@ export const useFunctionsSelector = selector => {
|
|
|
16
16
|
}
|
|
17
17
|
const getSnapshot = () => selector(store.functions);
|
|
18
18
|
return useSyncExternalStore(store.subscribe, getSnapshot, getSnapshot);
|
|
19
|
+
};
|
|
20
|
+
export const useCustomFunctionsSelector = selector => {
|
|
21
|
+
const store = useContext(ChaynsContext);
|
|
22
|
+
if (!store) {
|
|
23
|
+
throw new Error('Could not find chayns context. Did you forget to add ChaynsProvider?');
|
|
24
|
+
}
|
|
25
|
+
const getSnapshot = () => selector(store.customFunctions);
|
|
26
|
+
return useSyncExternalStore(store.subscribe, getSnapshot, getSnapshot);
|
|
19
27
|
};
|
package/dist/esm/hooks/index.js
CHANGED
|
@@ -15,4 +15,5 @@ export { useFunctions } from './useFunctions';
|
|
|
15
15
|
export { useCurrentPage } from './useCurrentPage';
|
|
16
16
|
export { useCustomData } from './useCustomData';
|
|
17
17
|
export { useDialogState, useDialogData } from './useDialogState';
|
|
18
|
-
export { useCustomCallbackFunction } from './useCustomCallbackFunction';
|
|
18
|
+
export { useCustomCallbackFunction } from './useCustomCallbackFunction';
|
|
19
|
+
export { useCustomFunction } from './useCustomFunction';
|
|
@@ -6,6 +6,7 @@ const ChaynsHost = _ref => {
|
|
|
6
6
|
type,
|
|
7
7
|
iFrameProps,
|
|
8
8
|
functions,
|
|
9
|
+
customFunctions,
|
|
9
10
|
src,
|
|
10
11
|
iFrameRef = undefined,
|
|
11
12
|
loadingComponent = undefined,
|
|
@@ -50,6 +51,7 @@ const ChaynsHost = _ref => {
|
|
|
50
51
|
device: device,
|
|
51
52
|
currentPage: currentPage,
|
|
52
53
|
functions: functions,
|
|
54
|
+
customFunctions: customFunctions,
|
|
53
55
|
src: src,
|
|
54
56
|
postForm: type === 'server-iframe',
|
|
55
57
|
language: language,
|
|
@@ -71,6 +73,7 @@ const ChaynsHost = _ref => {
|
|
|
71
73
|
currentPage: currentPage,
|
|
72
74
|
children: loadingComponent,
|
|
73
75
|
functions: functions,
|
|
76
|
+
customFunctions: customFunctions,
|
|
74
77
|
language: language,
|
|
75
78
|
parameters: parameters,
|
|
76
79
|
customData: customData,
|
|
@@ -16,6 +16,7 @@ const HostIframe = _ref => {
|
|
|
16
16
|
user,
|
|
17
17
|
currentPage,
|
|
18
18
|
functions,
|
|
19
|
+
customFunctions,
|
|
19
20
|
device,
|
|
20
21
|
language,
|
|
21
22
|
parameters,
|
|
@@ -27,6 +28,8 @@ const HostIframe = _ref => {
|
|
|
27
28
|
const eventTarget = useRef();
|
|
28
29
|
const ref = useRef();
|
|
29
30
|
const currentDataRef = useRef();
|
|
31
|
+
const customFunctionsRef = useRef();
|
|
32
|
+
customFunctionsRef.current = customFunctions;
|
|
30
33
|
if (!eventTarget.current) {
|
|
31
34
|
eventTarget.current = global.document ? document.createElement('div') : undefined;
|
|
32
35
|
}
|
|
@@ -71,6 +74,13 @@ const HostIframe = _ref => {
|
|
|
71
74
|
...functions,
|
|
72
75
|
setHeight
|
|
73
76
|
},
|
|
77
|
+
customFunctions: new Proxy(customFunctionsRef, {
|
|
78
|
+
get: (target, p) => {
|
|
79
|
+
var _target$current;
|
|
80
|
+
return (_target$current = target.current) === null || _target$current === void 0 ? void 0 : _target$current[p];
|
|
81
|
+
}
|
|
82
|
+
}),
|
|
83
|
+
_customFunctionNames: Object.keys(customFunctions !== null && customFunctions !== void 0 ? customFunctions : {}),
|
|
74
84
|
addDataListener: cb => {
|
|
75
85
|
if (eventTarget.current) eventTarget.current.addEventListener('data_update', e => e.detail && cb(e.detail));
|
|
76
86
|
},
|
|
@@ -17,6 +17,7 @@ const ModuleHost = _ref2 => {
|
|
|
17
17
|
system,
|
|
18
18
|
children = null,
|
|
19
19
|
functions,
|
|
20
|
+
customFunctions,
|
|
20
21
|
pages,
|
|
21
22
|
isAdminModeActive,
|
|
22
23
|
site,
|
|
@@ -59,6 +60,7 @@ const ModuleHost = _ref2 => {
|
|
|
59
60
|
},
|
|
60
61
|
data: initialData,
|
|
61
62
|
functions: functions,
|
|
63
|
+
customFunctions: customFunctions,
|
|
62
64
|
fallback: children,
|
|
63
65
|
isModule: true
|
|
64
66
|
}));
|
|
@@ -125,6 +125,7 @@ export class AppWrapper {
|
|
|
125
125
|
_defineProperty(this, "values", null);
|
|
126
126
|
_defineProperty(this, "accessToken", '');
|
|
127
127
|
_defineProperty(this, "listeners", []);
|
|
128
|
+
_defineProperty(this, "customFunctions", {});
|
|
128
129
|
_defineProperty(this, "counter", 0);
|
|
129
130
|
_defineProperty(this, "functions", {
|
|
130
131
|
getAccessToken: async () => ({
|
|
@@ -10,8 +10,11 @@ import { sendMessageToGroup, sendMessageToPage, sendMessageToUser } from '../cal
|
|
|
10
10
|
import { setTappHeight } from '../util/heightHelper';
|
|
11
11
|
export class FrameWrapper {
|
|
12
12
|
constructor() {
|
|
13
|
+
var _this = this;
|
|
13
14
|
_defineProperty(this, "resolve", null);
|
|
14
15
|
_defineProperty(this, "exposedFunctions", null);
|
|
16
|
+
_defineProperty(this, "exposedCustomFunctions", {});
|
|
17
|
+
_defineProperty(this, "exposedCustomFunctionNames", []);
|
|
15
18
|
_defineProperty(this, "resizeListener", null);
|
|
16
19
|
_defineProperty(this, "ready", new Promise(res => {
|
|
17
20
|
this.resolve = res;
|
|
@@ -293,6 +296,21 @@ export class FrameWrapper {
|
|
|
293
296
|
return this.exposedFunctions.addAnonymousAccount();
|
|
294
297
|
}
|
|
295
298
|
});
|
|
299
|
+
_defineProperty(this, "customFunctions", new Proxy({}, {
|
|
300
|
+
get: (target, p) => {
|
|
301
|
+
if (p in target) {
|
|
302
|
+
return target[p];
|
|
303
|
+
}
|
|
304
|
+
return target[p] = async function () {
|
|
305
|
+
if (!_this.initialized) await _this.ready;
|
|
306
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
307
|
+
args[_key] = arguments[_key];
|
|
308
|
+
}
|
|
309
|
+
const wrappedArgs = args.map(v => typeof v === 'function' ? comlink.proxy(v) : v);
|
|
310
|
+
return _this.exposedCustomFunctions[p](...wrappedArgs);
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
}));
|
|
296
314
|
_defineProperty(this, "initialized", false);
|
|
297
315
|
_defineProperty(this, "subscribe", listener => {
|
|
298
316
|
this.listeners.push(listener);
|
|
@@ -309,6 +327,8 @@ export class FrameWrapper {
|
|
|
309
327
|
}
|
|
310
328
|
}
|
|
311
329
|
async init() {
|
|
330
|
+
var _await$exposed$_custo,
|
|
331
|
+
_this2 = this;
|
|
312
332
|
if (this.initialized) return;
|
|
313
333
|
const exposed = comlink.wrap(comlink.windowEndpoint(window.parent))[window.name];
|
|
314
334
|
const dataListener = () => exposed.addDataListener(comlink.proxy(_ref => {
|
|
@@ -337,6 +357,17 @@ export class FrameWrapper {
|
|
|
337
357
|
if (hostReadyCallback) window.removeEventListener('message', hostReadyCallback);
|
|
338
358
|
this.values = await exposed.getInitialData();
|
|
339
359
|
this.exposedFunctions = exposed.functions;
|
|
360
|
+
this.exposedCustomFunctions = exposed.customFunctions;
|
|
361
|
+
this.exposedCustomFunctionNames = (_await$exposed$_custo = await exposed._customFunctionNames) !== null && _await$exposed$_custo !== void 0 ? _await$exposed$_custo : [];
|
|
362
|
+
this.customFunctions = this.exposedCustomFunctionNames.reduce((p, e) => {
|
|
363
|
+
p[e] = function () {
|
|
364
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
365
|
+
args[_key2] = arguments[_key2];
|
|
366
|
+
}
|
|
367
|
+
return _this2.exposedCustomFunctions[e](...args.map(a => typeof a === 'function' ? comlink.proxy(a) : a));
|
|
368
|
+
};
|
|
369
|
+
return p;
|
|
370
|
+
}, {});
|
|
340
371
|
this.initialized = true;
|
|
341
372
|
this.resolve(null);
|
|
342
373
|
setTappHeight(this.functions.setHeight);
|
|
@@ -7,7 +7,8 @@ import { addApiListener, dispatchApiEvent, removeApiListener } from '../helper/a
|
|
|
7
7
|
import getUserInfo from '../calls/getUserInfo';
|
|
8
8
|
import { sendMessageToGroup, sendMessageToPage, sendMessageToUser } from '../calls/sendMessage';
|
|
9
9
|
export class ModuleFederationWrapper {
|
|
10
|
-
constructor(values, functions) {
|
|
10
|
+
constructor(values, functions, customFunctions) {
|
|
11
|
+
_defineProperty(this, "customFunctions", {});
|
|
11
12
|
_defineProperty(this, "listeners", []);
|
|
12
13
|
_defineProperty(this, "subscribe", listener => {
|
|
13
14
|
this.listeners.push(listener);
|
|
@@ -32,6 +33,9 @@ export class ModuleFederationWrapper {
|
|
|
32
33
|
return fn(...arguments);
|
|
33
34
|
};
|
|
34
35
|
});
|
|
36
|
+
if (customFunctions) {
|
|
37
|
+
this.customFunctions = customFunctions;
|
|
38
|
+
}
|
|
35
39
|
this.functions.createDialog = config => {
|
|
36
40
|
return new DialogHandler(config, functions.openDialog, functions.closeDialog, functions.dispatchEventToDialogClient, functions.addDialogClientEventListener);
|
|
37
41
|
};
|
|
@@ -2,7 +2,7 @@ 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
|
export class SsrWrapper {
|
|
5
|
-
constructor(values, functions) {
|
|
5
|
+
constructor(values, functions, customFunctions) {
|
|
6
6
|
_defineProperty(this, "listeners", []);
|
|
7
7
|
_defineProperty(this, "subscribe", listener => {
|
|
8
8
|
this.listeners.push(listener);
|
|
@@ -16,6 +16,7 @@ export class SsrWrapper {
|
|
|
16
16
|
this.initialData = values;
|
|
17
17
|
this.values = values;
|
|
18
18
|
this.functions = functions;
|
|
19
|
+
this.customFunctions = customFunctions !== null && customFunctions !== void 0 ? customFunctions : {};
|
|
19
20
|
}
|
|
20
21
|
async init() {
|
|
21
22
|
return undefined;
|
|
@@ -18,6 +18,7 @@ class StaticChaynsApi {
|
|
|
18
18
|
_defineProperty(this, "getParameters", () => this._wrapper.values.parameters);
|
|
19
19
|
_defineProperty(this, "getPages", () => this._wrapper.values.pages);
|
|
20
20
|
_defineProperty(this, "getEnvironment", () => this._wrapper.values.environment);
|
|
21
|
+
_defineProperty(this, "getCustomFunction", key => this._wrapper.customFunctions[key]);
|
|
21
22
|
let wrapper;
|
|
22
23
|
const deviceInfo = getDeviceInfo(navigator.userAgent, '');
|
|
23
24
|
if (values && functions) {
|
|
@@ -29,7 +29,8 @@ export declare const addToolbarChangeListener: (callback: (result: import("../ty
|
|
|
29
29
|
* @category Event listener
|
|
30
30
|
*/
|
|
31
31
|
export declare const addWindowMetricsListener: (callback: (result: import("../types/IChaynsReact").WindowMetricsListenerResult) => void) => Promise<number>; /**
|
|
32
|
-
* Allows a custom callback function to be defined
|
|
32
|
+
* Allows a custom callback function to be defined. Prefer usage via useCustomCallbackFunction when possible
|
|
33
|
+
* @deprecated Use customFunction/useCustomFunction-interface instead if possible
|
|
33
34
|
*/
|
|
34
35
|
export declare const customCallbackFunction: (type: string, data: unknown) => Promise<unknown>;
|
|
35
36
|
/**
|
|
@@ -235,6 +236,11 @@ export declare const getEnvironment: () => {
|
|
|
235
236
|
buildEnvironment: import("../types/IChaynsReact").Environment;
|
|
236
237
|
runtimeEnvironment: string | import("../types/IChaynsReact").RuntimeEnviroment;
|
|
237
238
|
};
|
|
239
|
+
/**
|
|
240
|
+
* Returns the customFunction. Prefer usage via useCustomFunction when possible
|
|
241
|
+
* @param key functionName
|
|
242
|
+
*/
|
|
243
|
+
export declare const getCustomFunction: <A extends any[], T>(key: string) => (...args: A) => Promise<T>;
|
|
238
244
|
export declare const user: UserInfo;
|
|
239
245
|
export declare const site: ChaynsApiSite;
|
|
240
246
|
export declare const device: ChaynsApiDevice;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
|
-
import { ChaynsReactFunctions, ChaynsReactValues } from '../types/IChaynsReact';
|
|
2
|
+
import { ChaynsReactFunctions, ChaynsReactValues, IChaynsReact } from '../types/IChaynsReact';
|
|
3
3
|
type ChaynsProviderProps = {
|
|
4
4
|
data?: ChaynsReactValues;
|
|
5
5
|
functions?: ChaynsReactFunctions;
|
|
6
|
+
customFunctions?: IChaynsReact["customFunctions"];
|
|
6
7
|
renderedByServer?: boolean;
|
|
7
8
|
isModule?: boolean;
|
|
8
9
|
children?: ReactNode;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { IChaynsReact } from '../types/IChaynsReact';
|
|
2
2
|
export declare const useValuesSelector: <Result>(selector: (value: IChaynsReact["values"]) => Result) => Result;
|
|
3
3
|
export declare const useFunctionsSelector: <Result>(selector: (value: IChaynsReact["functions"]) => Result) => Result;
|
|
4
|
+
export declare const useCustomFunctionsSelector: <Result>(selector: (value: IChaynsReact["customFunctions"]) => Result) => Result;
|
|
@@ -16,3 +16,4 @@ export { useCurrentPage } from './useCurrentPage';
|
|
|
16
16
|
export { useCustomData } from './useCustomData';
|
|
17
17
|
export { useDialogState, useDialogData } from './useDialogState';
|
|
18
18
|
export { useCustomCallbackFunction } from './useCustomCallbackFunction';
|
|
19
|
+
export { useCustomFunction } from './useCustomFunction';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @category Hooks
|
|
3
2
|
* Returns customCallbackFunction
|
|
3
|
+
* @category Hooks
|
|
4
|
+
* @deprecated Use customFunction/useCustomFunction-interface instead if possible
|
|
4
5
|
*/
|
|
5
6
|
export declare const useCustomCallbackFunction: () => (type: string, data: unknown) => Promise<unknown>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
2
|
import { TypeSystem } from './module/ModuleHost';
|
|
3
|
-
import { ChaynsApiDevice, ChaynsApiSite, ChaynsApiUser, ChaynsReactFunctions, ChaynsReactValues, Page } from '../types/IChaynsReact';
|
|
3
|
+
import { ChaynsApiDevice, ChaynsApiSite, ChaynsApiUser, ChaynsReactFunctions, ChaynsReactValues, IChaynsReact, Page } from '../types/IChaynsReact';
|
|
4
4
|
type ChaynsHostType = {
|
|
5
5
|
type: string;
|
|
6
6
|
iFrameProps?: {
|
|
@@ -8,6 +8,7 @@ type ChaynsHostType = {
|
|
|
8
8
|
name: string;
|
|
9
9
|
};
|
|
10
10
|
functions: ChaynsReactFunctions;
|
|
11
|
+
customFunctions?: IChaynsReact["customFunctions"];
|
|
11
12
|
src?: string;
|
|
12
13
|
iFrameRef?: React.MutableRefObject<HTMLIFrameElement | null> | undefined;
|
|
13
14
|
loadingComponent?: JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
|
-
import { ChaynsApiDevice, ChaynsApiSite, ChaynsApiUser, ChaynsReactFunctions, ChaynsReactValues, Page } from '../../types/IChaynsReact';
|
|
2
|
+
import { ChaynsApiDevice, ChaynsApiSite, ChaynsApiUser, ChaynsReactFunctions, ChaynsReactValues, IChaynsReact, Page } from '../../types/IChaynsReact';
|
|
3
3
|
type HostIframeProps = {
|
|
4
4
|
iFrameProps: {
|
|
5
5
|
[key: string]: unknown;
|
|
@@ -14,6 +14,7 @@ type HostIframeProps = {
|
|
|
14
14
|
user: ChaynsApiUser | undefined;
|
|
15
15
|
currentPage: ChaynsReactValues["currentPage"];
|
|
16
16
|
functions: ChaynsReactFunctions;
|
|
17
|
+
customFunctions?: IChaynsReact["customFunctions"];
|
|
17
18
|
device: ChaynsApiDevice;
|
|
18
19
|
language: ChaynsReactValues["language"];
|
|
19
20
|
parameters: ChaynsReactValues["parameters"];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FC, ReactNode } from 'react';
|
|
2
|
-
import { ChaynsApiDevice, ChaynsApiSite, ChaynsApiUser, ChaynsReactFunctions, ChaynsReactValues, Page } from '../../types/IChaynsReact';
|
|
2
|
+
import { ChaynsApiDevice, ChaynsApiSite, ChaynsApiUser, ChaynsReactFunctions, ChaynsReactValues, IChaynsReact, Page } from '../../types/IChaynsReact';
|
|
3
3
|
export type TypeSystem = {
|
|
4
4
|
scope: string;
|
|
5
5
|
url: string;
|
|
@@ -10,6 +10,7 @@ export type TypeSystem = {
|
|
|
10
10
|
type ModulePropTypes = {
|
|
11
11
|
system: TypeSystem;
|
|
12
12
|
functions: ChaynsReactFunctions;
|
|
13
|
+
customFunctions?: IChaynsReact["customFunctions"];
|
|
13
14
|
pages: Page[];
|
|
14
15
|
isAdminModeActive: boolean;
|
|
15
16
|
site: ChaynsApiSite;
|
|
@@ -553,6 +553,9 @@ interface DesignSettingsUpdateItem {
|
|
|
553
553
|
export interface IChaynsReact {
|
|
554
554
|
values: ChaynsReactValues;
|
|
555
555
|
functions: ChaynsReactFunctions;
|
|
556
|
+
customFunctions: {
|
|
557
|
+
[key: string]: <A extends Array<any>, O>(...args: A) => Promise<O>;
|
|
558
|
+
};
|
|
556
559
|
addDataListener: (cb: DataChangeCallback) => CleanupCallback;
|
|
557
560
|
getSSRData: () => ChaynsReactValues | null;
|
|
558
561
|
init: () => Promise<void>;
|
|
@@ -2,11 +2,14 @@ import { ChaynsReactFunctions, ChaynsReactValues, DataChangeCallback, IChaynsRea
|
|
|
2
2
|
export declare class FrameWrapper implements IChaynsReact {
|
|
3
3
|
private resolve;
|
|
4
4
|
private exposedFunctions;
|
|
5
|
+
private exposedCustomFunctions;
|
|
6
|
+
private exposedCustomFunctionNames;
|
|
5
7
|
private resizeListener;
|
|
6
8
|
ready: Promise<unknown>;
|
|
7
9
|
values: ChaynsReactValues;
|
|
8
10
|
listeners: (() => void)[];
|
|
9
11
|
functions: ChaynsReactFunctions;
|
|
12
|
+
customFunctions: {};
|
|
10
13
|
initialized: boolean;
|
|
11
14
|
constructor();
|
|
12
15
|
init(): Promise<void>;
|
|
@@ -2,8 +2,9 @@ import { ChaynsReactFunctions, ChaynsReactValues, DataChangeCallback, IChaynsRea
|
|
|
2
2
|
export declare class ModuleFederationWrapper implements IChaynsReact {
|
|
3
3
|
values: ChaynsReactValues;
|
|
4
4
|
functions: ChaynsReactFunctions;
|
|
5
|
+
customFunctions: IChaynsReact["customFunctions"];
|
|
5
6
|
listeners: (() => void)[];
|
|
6
|
-
constructor(values: ChaynsReactValues, functions: ChaynsReactFunctions);
|
|
7
|
+
constructor(values: ChaynsReactValues, functions: ChaynsReactFunctions, customFunctions?: IChaynsReact["customFunctions"]);
|
|
7
8
|
init(): Promise<undefined>;
|
|
8
9
|
addDataListener(cb: DataChangeCallback): () => void;
|
|
9
10
|
subscribe: (listener: () => void) => () => void;
|
|
@@ -3,8 +3,9 @@ export declare class SsrWrapper implements IChaynsReact {
|
|
|
3
3
|
private readonly initialData;
|
|
4
4
|
values: ChaynsReactValues;
|
|
5
5
|
functions: ChaynsReactFunctions;
|
|
6
|
+
customFunctions: IChaynsReact["customFunctions"];
|
|
6
7
|
listeners: (() => void)[];
|
|
7
|
-
constructor(values: ChaynsReactValues, functions: ChaynsReactFunctions);
|
|
8
|
+
constructor(values: ChaynsReactValues, functions: ChaynsReactFunctions, customFunctions?: IChaynsReact["customFunctions"]);
|
|
8
9
|
init(): Promise<undefined>;
|
|
9
10
|
addDataListener(cb: DataChangeCallback): CleanupCallback;
|
|
10
11
|
subscribe: (listener: () => void) => () => void;
|
|
@@ -3,6 +3,7 @@ declare class StaticChaynsApi {
|
|
|
3
3
|
ready: Promise<void>;
|
|
4
4
|
addDataListener: (cb: DataChangeCallback) => () => void;
|
|
5
5
|
private _wrapper;
|
|
6
|
+
private customFunctions;
|
|
6
7
|
constructor(values: any, functions: any);
|
|
7
8
|
getUser: () => any;
|
|
8
9
|
getSite: () => any;
|
|
@@ -12,5 +13,6 @@ declare class StaticChaynsApi {
|
|
|
12
13
|
getParameters: () => any;
|
|
13
14
|
getPages: () => any;
|
|
14
15
|
getEnvironment: () => any;
|
|
16
|
+
getCustomFunction: (key: string) => any;
|
|
15
17
|
}
|
|
16
18
|
export default StaticChaynsApi;
|