chayns-api 2.6.7 → 2.6.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/ChaynsProvider.js +6 -2
- package/dist/cjs/components/moduleWrapper.js +6 -1
- package/dist/cjs/hooks/context.js +3 -2
- package/dist/cjs/hooks/index.js +8 -1
- package/dist/cjs/hooks/useChaynsApiId.js +11 -0
- package/dist/cjs/index.js +9 -1
- package/dist/cjs/wrapper/FrameWrapper.js +1 -0
- package/dist/cjs/wrapper/ModuleFederationWrapper.js +1 -0
- package/dist/cjs/wrapper/SsrWrapper.js +1 -0
- package/dist/esm/components/ChaynsProvider.js +7 -3
- package/dist/esm/components/moduleWrapper.js +4 -0
- package/dist/esm/hooks/context.js +2 -1
- package/dist/esm/hooks/index.js +2 -1
- package/dist/esm/hooks/useChaynsApiId.js +4 -0
- package/dist/esm/index.js +2 -1
- package/dist/esm/wrapper/FrameWrapper.js +1 -0
- package/dist/esm/wrapper/ModuleFederationWrapper.js +1 -0
- package/dist/esm/wrapper/SsrWrapper.js +1 -0
- package/dist/types/components/ChaynsProvider.d.ts +1 -0
- package/dist/types/components/moduleWrapper.d.ts +3 -1
- package/dist/types/hooks/context.d.ts +1 -0
- package/dist/types/hooks/geoLocationListener.d.ts +1 -0
- package/dist/types/hooks/index.d.ts +1 -0
- package/dist/types/hooks/useChaynsApiId.d.ts +4 -0
- package/dist/types/index.d.ts +1 -0
- 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 +1 -0
- package/dist/types/wrapper/ModuleFederationWrapper.d.ts +1 -0
- package/dist/types/wrapper/SsrWrapper.d.ts +1 -0
- package/package.json +3 -2
|
@@ -39,10 +39,12 @@ const ChaynsProvider = ({
|
|
|
39
39
|
functions,
|
|
40
40
|
customFunctions,
|
|
41
41
|
renderedByServer,
|
|
42
|
-
isModule
|
|
42
|
+
isModule,
|
|
43
|
+
chaynsApiId
|
|
43
44
|
}) => {
|
|
44
|
-
var _customWrapper$curren, _customWrapper$curren2;
|
|
45
|
+
var _ref, _crypto, _customWrapper$curren, _customWrapper$curren2;
|
|
45
46
|
const customWrapper = (0, _react.useRef)(null);
|
|
47
|
+
const idRef = (0, _react.useRef)((_ref = chaynsApiId !== null && chaynsApiId !== void 0 ? chaynsApiId : (_crypto = crypto) === null || _crypto === void 0 ? void 0 : _crypto.randomUUID()) !== null && _ref !== void 0 ? _ref : Math.random().toString());
|
|
46
48
|
if (!customWrapper.current) {
|
|
47
49
|
if (isModule) {
|
|
48
50
|
if (data && functions) {
|
|
@@ -66,6 +68,8 @@ const ChaynsProvider = ({
|
|
|
66
68
|
}
|
|
67
69
|
}
|
|
68
70
|
_moduleWrapper.moduleWrapper.current = customWrapper.current;
|
|
71
|
+
_moduleWrapper.chaynsApis[idRef.current] = customWrapper.current.functions;
|
|
72
|
+
customWrapper.current.chaynsApiId = idRef.current;
|
|
69
73
|
}
|
|
70
74
|
const [isInitialized, setIsInitialized] = (0, _react.useState)(!!((_customWrapper$curren = customWrapper.current) !== null && _customWrapper$curren !== void 0 && _customWrapper$curren.values));
|
|
71
75
|
(0, _react.useEffect)(() => {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.removeModuleWrapper = exports.moduleWrapper = exports.addModuleWrapper = void 0;
|
|
6
|
+
exports.removeModuleWrapper = exports.moduleWrapper = exports.getChaynsApi = exports.chaynsApis = exports.addModuleWrapper = void 0;
|
|
7
7
|
const moduleWrapperStack = [];
|
|
8
8
|
let current = undefined;
|
|
9
9
|
const moduleWrapper = exports.moduleWrapper = {
|
|
@@ -17,6 +17,11 @@ const moduleWrapper = exports.moduleWrapper = {
|
|
|
17
17
|
current = chayns;
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
|
+
const chaynsApis = exports.chaynsApis = {};
|
|
21
|
+
const getChaynsApi = id => {
|
|
22
|
+
return chaynsApis[id];
|
|
23
|
+
};
|
|
24
|
+
exports.getChaynsApi = getChaynsApi;
|
|
20
25
|
const addModuleWrapper = chayns => {
|
|
21
26
|
moduleWrapperStack.push(chayns);
|
|
22
27
|
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.useValuesSelector = exports.useFunctionsSelector = exports.useCustomFunctionsSelector = void 0;
|
|
6
|
+
exports.useValuesSelector = exports.useFunctionsSelector = exports.useCustomFunctionsSelector = exports.useChaynsApiIdSelector = 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");
|
|
@@ -17,4 +17,5 @@ const createChaynsSelector = key => selector => {
|
|
|
17
17
|
};
|
|
18
18
|
const useValuesSelector = exports.useValuesSelector = createChaynsSelector('values');
|
|
19
19
|
const useFunctionsSelector = exports.useFunctionsSelector = createChaynsSelector('functions');
|
|
20
|
-
const useCustomFunctionsSelector = exports.useCustomFunctionsSelector = createChaynsSelector('customFunctions');
|
|
20
|
+
const useCustomFunctionsSelector = exports.useCustomFunctionsSelector = createChaynsSelector('customFunctions');
|
|
21
|
+
const useChaynsApiIdSelector = exports.useChaynsApiIdSelector = createChaynsSelector('chaynsApiId');
|
package/dist/cjs/hooks/index.js
CHANGED
|
@@ -15,6 +15,12 @@ Object.defineProperty(exports, "useAccessToken", {
|
|
|
15
15
|
return _useAccessToken.useAccessToken;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
+
Object.defineProperty(exports, "useChaynsApiId", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _useChaynsApiId.useChaynsApiId;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
18
24
|
Object.defineProperty(exports, "useCurrentPage", {
|
|
19
25
|
enumerable: true,
|
|
20
26
|
get: function () {
|
|
@@ -190,4 +196,5 @@ var _useCustomData = require("./useCustomData");
|
|
|
190
196
|
var _useDialogState = require("./useDialogState");
|
|
191
197
|
var _useCustomCallbackFunction = require("./useCustomCallbackFunction");
|
|
192
198
|
var _useCustomFunction = require("./useCustomFunction");
|
|
193
|
-
var _useStyleSettings = require("./useStyleSettings");
|
|
199
|
+
var _useStyleSettings = require("./useStyleSettings");
|
|
200
|
+
var _useChaynsApiId = require("./useChaynsApiId");
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useChaynsApiId = void 0;
|
|
7
|
+
var _context = require("./context");
|
|
8
|
+
const useChaynsApiId = () => {
|
|
9
|
+
return (0, _context.useChaynsApiIdSelector)(chaynsApiId => chaynsApiId);
|
|
10
|
+
};
|
|
11
|
+
exports.useChaynsApiId = useChaynsApiId;
|
package/dist/cjs/index.js
CHANGED
|
@@ -15,7 +15,8 @@ var _exportNames = {
|
|
|
15
15
|
loadComponent: true,
|
|
16
16
|
loadModule: true,
|
|
17
17
|
DialogHandler: true,
|
|
18
|
-
dialog: true
|
|
18
|
+
dialog: true,
|
|
19
|
+
getChaynsApi: true
|
|
19
20
|
};
|
|
20
21
|
Object.defineProperty(exports, "ChaynsHost", {
|
|
21
22
|
enumerable: true,
|
|
@@ -42,6 +43,12 @@ Object.defineProperty(exports, "StaticChaynsApi", {
|
|
|
42
43
|
}
|
|
43
44
|
});
|
|
44
45
|
exports.dialog = void 0;
|
|
46
|
+
Object.defineProperty(exports, "getChaynsApi", {
|
|
47
|
+
enumerable: true,
|
|
48
|
+
get: function () {
|
|
49
|
+
return _moduleWrapper.getChaynsApi;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
45
52
|
Object.defineProperty(exports, "getClientDeviceInfo", {
|
|
46
53
|
enumerable: true,
|
|
47
54
|
get: function () {
|
|
@@ -227,5 +234,6 @@ Object.keys(_collectCssChunks).forEach(function (key) {
|
|
|
227
234
|
}
|
|
228
235
|
});
|
|
229
236
|
});
|
|
237
|
+
var _moduleWrapper = require("./components/moduleWrapper");
|
|
230
238
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
231
239
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -12,6 +12,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
12
12
|
class ModuleFederationWrapper {
|
|
13
13
|
customFunctions = {};
|
|
14
14
|
listeners = [];
|
|
15
|
+
chaynsApiId = null;
|
|
15
16
|
constructor(values, functions, customFunctions) {
|
|
16
17
|
this.values = values;
|
|
17
18
|
this.functions = {};
|
|
@@ -8,7 +8,7 @@ import { FrameWrapper } from '../wrapper/FrameWrapper';
|
|
|
8
8
|
import { ModuleFederationWrapper } from '../wrapper/ModuleFederationWrapper';
|
|
9
9
|
import { SsrWrapper } from '../wrapper/SsrWrapper';
|
|
10
10
|
import { ChaynsContext } from './ChaynsContext';
|
|
11
|
-
import { addModuleWrapper, moduleWrapper, removeModuleWrapper } from './moduleWrapper';
|
|
11
|
+
import { addModuleWrapper, chaynsApis, moduleWrapper, removeModuleWrapper } from './moduleWrapper';
|
|
12
12
|
const isServer = typeof window === 'undefined';
|
|
13
13
|
const InitialDataProvider = React.memo(({
|
|
14
14
|
data,
|
|
@@ -31,10 +31,12 @@ const ChaynsProvider = ({
|
|
|
31
31
|
functions,
|
|
32
32
|
customFunctions,
|
|
33
33
|
renderedByServer,
|
|
34
|
-
isModule
|
|
34
|
+
isModule,
|
|
35
|
+
chaynsApiId
|
|
35
36
|
}) => {
|
|
36
|
-
var _customWrapper$curren, _customWrapper$curren2;
|
|
37
|
+
var _ref, _crypto, _customWrapper$curren, _customWrapper$curren2;
|
|
37
38
|
const customWrapper = useRef(null);
|
|
39
|
+
const idRef = useRef((_ref = chaynsApiId !== null && chaynsApiId !== void 0 ? chaynsApiId : (_crypto = crypto) === null || _crypto === void 0 ? void 0 : _crypto.randomUUID()) !== null && _ref !== void 0 ? _ref : Math.random().toString());
|
|
38
40
|
if (!customWrapper.current) {
|
|
39
41
|
if (isModule) {
|
|
40
42
|
if (data && functions) {
|
|
@@ -58,6 +60,8 @@ const ChaynsProvider = ({
|
|
|
58
60
|
}
|
|
59
61
|
}
|
|
60
62
|
moduleWrapper.current = customWrapper.current;
|
|
63
|
+
chaynsApis[idRef.current] = customWrapper.current.functions;
|
|
64
|
+
customWrapper.current.chaynsApiId = idRef.current;
|
|
61
65
|
}
|
|
62
66
|
const [isInitialized, setIsInitialized] = useState(!!((_customWrapper$curren = customWrapper.current) !== null && _customWrapper$curren !== void 0 && _customWrapper$curren.values));
|
|
63
67
|
useEffect(() => {
|
|
@@ -11,6 +11,10 @@ export const moduleWrapper = {
|
|
|
11
11
|
current = chayns;
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
|
+
export const chaynsApis = {};
|
|
15
|
+
export const getChaynsApi = id => {
|
|
16
|
+
return chaynsApis[id];
|
|
17
|
+
};
|
|
14
18
|
export const addModuleWrapper = chayns => {
|
|
15
19
|
moduleWrapperStack.push(chayns);
|
|
16
20
|
};
|
|
@@ -11,4 +11,5 @@ const createChaynsSelector = key => selector => {
|
|
|
11
11
|
};
|
|
12
12
|
export const useValuesSelector = createChaynsSelector('values');
|
|
13
13
|
export const useFunctionsSelector = createChaynsSelector('functions');
|
|
14
|
-
export const useCustomFunctionsSelector = createChaynsSelector('customFunctions');
|
|
14
|
+
export const useCustomFunctionsSelector = createChaynsSelector('customFunctions');
|
|
15
|
+
export const useChaynsApiIdSelector = createChaynsSelector('chaynsApiId');
|
package/dist/esm/hooks/index.js
CHANGED
|
@@ -17,4 +17,5 @@ export { useCustomData } from './useCustomData';
|
|
|
17
17
|
export { useDialogState, useDialogData } from './useDialogState';
|
|
18
18
|
export { useCustomCallbackFunction } from './useCustomCallbackFunction';
|
|
19
19
|
export { useCustomFunction } from './useCustomFunction';
|
|
20
|
-
export { useStyleSettings } from './useStyleSettings';
|
|
20
|
+
export { useStyleSettings } from './useStyleSettings';
|
|
21
|
+
export { useChaynsApiId } from './useChaynsApiId';
|
package/dist/esm/index.js
CHANGED
|
@@ -19,4 +19,5 @@ export * from './plugins';
|
|
|
19
19
|
export * from './util/initModuleFederationSharing';
|
|
20
20
|
export * from './util/bindChaynsApi';
|
|
21
21
|
export * from './util/appStorage';
|
|
22
|
-
export * from './util/collectCssChunks';
|
|
22
|
+
export * from './util/collectCssChunks';
|
|
23
|
+
export { getChaynsApi } from './components/moduleWrapper';
|
|
@@ -18,6 +18,7 @@ export class FrameWrapper {
|
|
|
18
18
|
this.resolve = res;
|
|
19
19
|
}));
|
|
20
20
|
_defineProperty(this, "values", null);
|
|
21
|
+
_defineProperty(this, "chaynsApiId", null);
|
|
21
22
|
_defineProperty(this, "listeners", []);
|
|
22
23
|
_defineProperty(this, "functions", {
|
|
23
24
|
addGeoLocationListener: async (value, callback) => {
|
|
@@ -9,6 +9,7 @@ export class ModuleFederationWrapper {
|
|
|
9
9
|
constructor(values, functions, customFunctions) {
|
|
10
10
|
_defineProperty(this, "customFunctions", {});
|
|
11
11
|
_defineProperty(this, "listeners", []);
|
|
12
|
+
_defineProperty(this, "chaynsApiId", null);
|
|
12
13
|
_defineProperty(this, "subscribe", listener => {
|
|
13
14
|
this.listeners.push(listener);
|
|
14
15
|
return () => {
|
|
@@ -4,6 +4,7 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
4
4
|
export class SsrWrapper {
|
|
5
5
|
constructor(values, functions, customFunctions) {
|
|
6
6
|
_defineProperty(this, "listeners", []);
|
|
7
|
+
_defineProperty(this, "chaynsApiId", null);
|
|
7
8
|
_defineProperty(this, "subscribe", listener => {
|
|
8
9
|
this.listeners.push(listener);
|
|
9
10
|
return () => {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { IChaynsReact } from '../types/IChaynsReact';
|
|
1
|
+
import { ChaynsReactFunctions, IChaynsReact } from '../types/IChaynsReact';
|
|
2
2
|
export declare const moduleWrapper: {
|
|
3
3
|
current: IChaynsReact;
|
|
4
4
|
};
|
|
5
|
+
export declare const chaynsApis: Record<string, ChaynsReactFunctions>;
|
|
6
|
+
export declare const getChaynsApi: (id: string) => ChaynsReactFunctions;
|
|
5
7
|
export declare const addModuleWrapper: (chayns: IChaynsReact) => void;
|
|
6
8
|
export declare const removeModuleWrapper: (chayns: IChaynsReact) => void;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export declare const useValuesSelector: <Result>(selector: (value: import("../types/IChaynsReact").ChaynsReactValues) => Result) => Result;
|
|
2
2
|
export declare const useFunctionsSelector: <Result>(selector: (value: import("../types/IChaynsReact").ChaynsReactFunctions) => Result) => Result;
|
|
3
3
|
export declare const useCustomFunctionsSelector: <Result>(selector: (value: import("../types/IChaynsReact").ChaynsReactCustomFunctions) => Result) => Result;
|
|
4
|
+
export declare const useChaynsApiIdSelector: <Result>(selector: (value: string) => Result) => Result;
|
|
@@ -5,6 +5,7 @@ import { GeoLocation } from '../types/IChaynsReact';
|
|
|
5
5
|
export declare const useGeoLocationListener: () => (value: {
|
|
6
6
|
timeout?: number;
|
|
7
7
|
silent?: boolean;
|
|
8
|
+
enableHighAccuracy?: boolean;
|
|
8
9
|
}, callback: (result: GeoLocation) => void) => () => void;
|
|
9
10
|
/**
|
|
10
11
|
* @category Hooks
|
|
@@ -18,3 +18,4 @@ export { useDialogState, useDialogData } from './useDialogState';
|
|
|
18
18
|
export { useCustomCallbackFunction } from './useCustomCallbackFunction';
|
|
19
19
|
export { useCustomFunction } from './useCustomFunction';
|
|
20
20
|
export { useStyleSettings } from './useStyleSettings';
|
|
21
|
+
export { useChaynsApiId } from './useChaynsApiId';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -336,6 +336,7 @@ export interface ChaynsReactValues {
|
|
|
336
336
|
isClosingRequested: boolean;
|
|
337
337
|
};
|
|
338
338
|
styleSettings?: ChaynsStyleSettings;
|
|
339
|
+
chaynsApiId: string;
|
|
339
340
|
}
|
|
340
341
|
export interface DialogResultFile {
|
|
341
342
|
blockDownload?: boolean;
|
|
@@ -356,6 +357,7 @@ export interface ChaynsReactFunctions {
|
|
|
356
357
|
addGeoLocationListener: (value: {
|
|
357
358
|
timeout?: number;
|
|
358
359
|
silent?: boolean;
|
|
360
|
+
enableHighAccuracy?: boolean;
|
|
359
361
|
}, callback: (geoLocation: GeoLocation) => void) => Promise<number>;
|
|
360
362
|
addScrollListener: (value: {
|
|
361
363
|
throttle?: number;
|
|
@@ -665,6 +667,7 @@ export interface IChaynsReact {
|
|
|
665
667
|
getInitialData: () => ChaynsReactValues;
|
|
666
668
|
subscribe: (listener: () => void) => () => void;
|
|
667
669
|
emitChange: () => void;
|
|
670
|
+
chaynsApiId: string;
|
|
668
671
|
}
|
|
669
672
|
export interface OpenUrl {
|
|
670
673
|
sameWindow?: boolean;
|
|
@@ -8,6 +8,7 @@ export declare class AppWrapper implements IChaynsReact {
|
|
|
8
8
|
loadStyleSettings(siteId: string): Promise<ChaynsStyleSettings | undefined>;
|
|
9
9
|
mapOldApiToNew(retVal: any): ChaynsReactValues;
|
|
10
10
|
constructor();
|
|
11
|
+
chaynsApiId: string;
|
|
11
12
|
notImplemented(call: string): void;
|
|
12
13
|
counter: number;
|
|
13
14
|
appCall(action: any, value?: unknown, { callback, awaitResult }?: {
|
|
@@ -4,6 +4,7 @@ export declare class ModuleFederationWrapper implements IChaynsReact {
|
|
|
4
4
|
functions: ChaynsReactFunctions;
|
|
5
5
|
customFunctions: IChaynsReact["customFunctions"];
|
|
6
6
|
listeners: (() => void)[];
|
|
7
|
+
chaynsApiId: string;
|
|
7
8
|
constructor(values: ChaynsReactValues, functions: ChaynsReactFunctions, customFunctions?: IChaynsReact["customFunctions"]);
|
|
8
9
|
init(): Promise<undefined>;
|
|
9
10
|
addDataListener(cb: DataChangeCallback): () => void;
|
|
@@ -5,6 +5,7 @@ export declare class SsrWrapper implements IChaynsReact {
|
|
|
5
5
|
functions: ChaynsReactFunctions;
|
|
6
6
|
customFunctions: IChaynsReact["customFunctions"];
|
|
7
7
|
listeners: (() => void)[];
|
|
8
|
+
chaynsApiId: string;
|
|
8
9
|
constructor(values: ChaynsReactValues, functions: ChaynsReactFunctions, customFunctions?: IChaynsReact["customFunctions"]);
|
|
9
10
|
init(): Promise<undefined>;
|
|
10
11
|
addDataListener(cb: DataChangeCallback): CleanupCallback;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chayns-api",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.9",
|
|
4
4
|
"description": "new chayns api",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -44,7 +44,8 @@
|
|
|
44
44
|
"prettier": {
|
|
45
45
|
"proseWrap": "always",
|
|
46
46
|
"singleQuote": true,
|
|
47
|
-
"tabWidth": 4
|
|
47
|
+
"tabWidth": 4,
|
|
48
|
+
"printWidth": 2000
|
|
48
49
|
},
|
|
49
50
|
"eslintConfig": {
|
|
50
51
|
"extends": "@chayns-toolkit"
|