chayns-api 1.2.0-9 → 2.0.1-0

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.
@@ -8,16 +8,19 @@ var _react = _interopRequireWildcard(require("react"));
8
8
  var _constants = require("../constants");
9
9
  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); }
10
10
  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; }
11
- const withHydrationBoundary = (Component, initializer, useHydrationId) => {
11
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
12
+ const withHydrationBoundary = (Component, initializer, useHydrationId, useProps) => {
12
13
  return ({
13
14
  id: idProp,
14
- children
15
+ children,
16
+ ...rest
15
17
  }) => {
16
18
  let value;
17
19
  if (!globalThis.window) {
18
20
  value = (0, _react.useContext)(_constants.HydrationContext);
19
21
  }
20
22
  const id = useHydrationId ? useHydrationId() : idProp;
23
+ const props = useProps ? useProps(rest) : undefined;
21
24
  if (!id) {
22
25
  throw new Error('hydration boundary was not given a id which is required');
23
26
  }
@@ -33,7 +36,7 @@ const withHydrationBoundary = (Component, initializer, useHydrationId) => {
33
36
  initialValue = JSON.parse($elem.innerHTML);
34
37
  }
35
38
  }
36
- const s = initializer(initialValue, id);
39
+ const s = initializer(initialValue, id, props);
37
40
  if (!globalThis.window) {
38
41
  value[id] = s;
39
42
  }
@@ -46,9 +49,9 @@ const withHydrationBoundary = (Component, initializer, useHydrationId) => {
46
49
  $elem.remove();
47
50
  }
48
51
  }, []);
49
- return /*#__PURE__*/_react.default.createElement(Component, {
52
+ return /*#__PURE__*/_react.default.createElement(Component, _extends({}, rest, {
50
53
  value: store
51
- }, children);
54
+ }), children);
52
55
  };
53
56
  };
54
57
  var _default = exports.default = withHydrationBoundary;
@@ -22,7 +22,7 @@ const loadModule = (scope, module, url, preventSingleton = false) => {
22
22
  console.error(`[chayns-api] call registerRemote with force for scope ${scope}. url: ${url}`);
23
23
  }
24
24
  registerRemotes([{
25
- shareScope: 'chayns-api2',
25
+ shareScope: url.endsWith('v2.remoteEntry.js') ? 'chayns-api' : 'default',
26
26
  name: scope,
27
27
  entry: url,
28
28
  alias: scope
@@ -73,7 +73,6 @@ const loadComponent = (scope, module, url, skipCompatMode = false, preventSingle
73
73
  loadShareSync('react', {
74
74
  resolver: shareOptions => {
75
75
  resolve(shareOptions);
76
- console.log("shareOptions", shareOptions);
77
76
  return shareOptions[0];
78
77
  }
79
78
  });
@@ -85,12 +84,10 @@ const loadComponent = (scope, module, url, skipCompatMode = false, preventSingle
85
84
  return _semver.default.gt(version, hostVersion) && _semver.default.satisfies(version, requiredVersion) || scope === from.split('-').join('_');
86
85
  });
87
86
  if (!matchReactVersion || environment !== 'production' || process.env.NODE_ENV === 'development' || Module.default.version !== 2) {
88
- console.log("use compat mode for", scope, module);
89
87
  return {
90
88
  default: Module.default.CompatComponent
91
89
  };
92
90
  }
93
- console.log("use direct component for", scope, module);
94
91
  return {
95
92
  default: Module.default.Component
96
93
  };
package/dist/cjs/index.js CHANGED
@@ -190,6 +190,18 @@ Object.keys(_initModuleFederationSharing).forEach(function (key) {
190
190
  }
191
191
  });
192
192
  });
193
+ var _bindChaynsApi = require("./util/bindChaynsApi");
194
+ Object.keys(_bindChaynsApi).forEach(function (key) {
195
+ if (key === "default" || key === "__esModule") return;
196
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
197
+ if (key in exports && exports[key] === _bindChaynsApi[key]) return;
198
+ Object.defineProperty(exports, key, {
199
+ enumerable: true,
200
+ get: function () {
201
+ return _bindChaynsApi[key];
202
+ }
203
+ });
204
+ });
193
205
  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); }
194
206
  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; }
195
207
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -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.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.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;
7
7
  let DateType = exports.DateType = /*#__PURE__*/function (DateType) {
8
8
  DateType[DateType["DATE"] = 0] = "DATE";
9
9
  DateType[DateType["TIME"] = 1] = "TIME";
@@ -164,6 +164,12 @@ let FloatingButtonPosition = exports.FloatingButtonPosition = /*#__PURE__*/funct
164
164
  FloatingButtonPosition[FloatingButtonPosition["Left"] = 2] = "Left";
165
165
  return FloatingButtonPosition;
166
166
  }({});
167
+ let FloatingButtonAnimation = exports.FloatingButtonAnimation = /*#__PURE__*/function (FloatingButtonAnimation) {
168
+ FloatingButtonAnimation["None"] = "none";
169
+ FloatingButtonAnimation["FadeIn"] = "fade-in";
170
+ FloatingButtonAnimation["Pulse"] = "pulse";
171
+ return FloatingButtonAnimation;
172
+ }({});
167
173
  let SharingApp = exports.SharingApp = /*#__PURE__*/function (SharingApp) {
168
174
  SharingApp[SharingApp["Mail"] = 0] = "Mail";
169
175
  SharingApp[SharingApp["WhatsApp"] = 1] = "WhatsApp";
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.bindChaynsApi = void 0;
7
+ var _index = require("../index");
8
+ const bindChaynsApi = fun => (values, functions) => {
9
+ new _index.StaticChaynsApi(values, functions);
10
+ return fun;
11
+ };
12
+ exports.bindChaynsApi = bindChaynsApi;
@@ -7,38 +7,38 @@ exports.initModuleFederationSharing = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _reactDom = _interopRequireDefault(require("react-dom"));
9
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
- const initModuleFederationSharing = () => {
10
+ const initModuleFederationSharing = ({
11
+ name
12
+ }) => {
11
13
  // forces single instance of module federation runtime
12
- if (!globalThis.moduleFederationRuntime) {
13
- var _process$env$__PACKAG;
14
- globalThis.moduleFederationRuntime = require('@module-federation/enhanced/runtime');
15
- globalThis.moduleFederationScopes = {
16
- registeredScopes: {},
17
- moduleMap: {},
18
- componentMap: {}
19
- };
20
- const {
21
- init
22
- } = globalThis.moduleFederationRuntime;
23
-
24
- // init also should only be called once
25
- init({
26
- // will be set by chayns-toolkit via DefinePlugin
27
- name: (_process$env$__PACKAG = process.env.__PACKAGE_NAME__) !== null && _process$env$__PACKAG !== void 0 ? _process$env$__PACKAG : '',
28
- remotes: [],
29
- shared: {
30
- react: {
31
- version: _react.default.version,
32
- scope: 'chayns-api2',
33
- lib: () => _react.default
34
- },
35
- 'react-dom': {
36
- version: _reactDom.default.version,
37
- scope: 'chayns-api2',
38
- lib: () => _reactDom.default
39
- }
40
- }
41
- });
14
+ if (globalThis.moduleFederationRuntime) {
15
+ return;
42
16
  }
17
+ globalThis.moduleFederationRuntime = require('@module-federation/enhanced/runtime');
18
+ globalThis.moduleFederationScopes = {
19
+ registeredScopes: {},
20
+ moduleMap: {},
21
+ componentMap: {}
22
+ };
23
+ const {
24
+ init
25
+ } = globalThis.moduleFederationRuntime;
26
+ init({
27
+ name: name !== null && name !== void 0 ? name : '',
28
+ remotes: [],
29
+ shared: {
30
+ react: {
31
+ version: _react.default.version,
32
+ scope: 'chayns-api',
33
+ lib: () => _react.default
34
+ },
35
+ 'react-dom': {
36
+ version: _react.default.version,
37
+ // intended, because react dom.version is not identical to package json react version (hash in version)
38
+ scope: 'chayns-api',
39
+ lib: () => _reactDom.default
40
+ }
41
+ }
42
+ });
43
43
  };
44
44
  exports.initModuleFederationSharing = initModuleFederationSharing;
@@ -9,13 +9,16 @@ var _IChaynsReact = require("../types/IChaynsReact");
9
9
  var _deviceHelper = _interopRequireDefault(require("../util/deviceHelper"));
10
10
  var _AppWrapper = require("./AppWrapper");
11
11
  var _FrameWrapper = require("./FrameWrapper");
12
+ var _ModuleFederationWrapper = require("./ModuleFederationWrapper");
12
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
14
  class StaticChaynsApi {
14
- constructor() {
15
+ constructor(values, functions) {
15
16
  var _deviceInfo$app$name, _deviceInfo$app;
16
17
  let wrapper;
17
18
  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
+ if (values && functions) {
20
+ wrapper = new _ModuleFederationWrapper.ModuleFederationWrapper(values, functions);
21
+ } else 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
22
  wrapper = new _AppWrapper.AppWrapper();
20
23
  } else {
21
24
  wrapper = new _FrameWrapper.FrameWrapper();
@@ -1,16 +1,19 @@
1
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
1
2
  import React, { useContext, useEffect, useState } from 'react';
2
3
  import { HydrationContext } from '../constants';
3
- const withHydrationBoundary = (Component, initializer, useHydrationId) => {
4
+ const withHydrationBoundary = (Component, initializer, useHydrationId, useProps) => {
4
5
  return _ref => {
5
6
  let {
6
7
  id: idProp,
7
- children
8
+ children,
9
+ ...rest
8
10
  } = _ref;
9
11
  let value;
10
12
  if (!globalThis.window) {
11
13
  value = useContext(HydrationContext);
12
14
  }
13
15
  const id = useHydrationId ? useHydrationId() : idProp;
16
+ const props = useProps ? useProps(rest) : undefined;
14
17
  if (!id) {
15
18
  throw new Error('hydration boundary was not given a id which is required');
16
19
  }
@@ -26,7 +29,7 @@ const withHydrationBoundary = (Component, initializer, useHydrationId) => {
26
29
  initialValue = JSON.parse($elem.innerHTML);
27
30
  }
28
31
  }
29
- const s = initializer(initialValue, id);
32
+ const s = initializer(initialValue, id, props);
30
33
  if (!globalThis.window) {
31
34
  value[id] = s;
32
35
  }
@@ -39,9 +42,9 @@ const withHydrationBoundary = (Component, initializer, useHydrationId) => {
39
42
  $elem.remove();
40
43
  }
41
44
  }, []);
42
- return /*#__PURE__*/React.createElement(Component, {
45
+ return /*#__PURE__*/React.createElement(Component, _extends({}, rest, {
43
46
  value: store
44
- }, children);
47
+ }), children);
45
48
  };
46
49
  };
47
50
  export default withHydrationBoundary;
@@ -16,7 +16,7 @@ export const loadModule = function (scope, module, url) {
16
16
  console.error(`[chayns-api] call registerRemote with force for scope ${scope}. url: ${url}`);
17
17
  }
18
18
  registerRemotes([{
19
- shareScope: 'chayns-api2',
19
+ shareScope: url.endsWith('v2.remoteEntry.js') ? 'chayns-api' : 'default',
20
20
  name: scope,
21
21
  entry: url,
22
22
  alias: scope
@@ -68,7 +68,6 @@ const loadComponent = function (scope, module, url) {
68
68
  loadShareSync('react', {
69
69
  resolver: shareOptions => {
70
70
  resolve(shareOptions);
71
- console.log("shareOptions", shareOptions);
72
71
  return shareOptions[0];
73
72
  }
74
73
  });
@@ -81,12 +80,10 @@ const loadComponent = function (scope, module, url) {
81
80
  return semver.gt(version, hostVersion) && semver.satisfies(version, requiredVersion) || scope === from.split('-').join('_');
82
81
  });
83
82
  if (!matchReactVersion || environment !== 'production' || process.env.NODE_ENV === 'development' || Module.default.version !== 2) {
84
- console.log("use compat mode for", scope, module);
85
83
  return {
86
84
  default: Module.default.CompatComponent
87
85
  };
88
86
  }
89
- console.log("use direct component for", scope, module);
90
87
  return {
91
88
  default: Module.default.Component
92
89
  };
package/dist/esm/index.js CHANGED
@@ -17,4 +17,5 @@ export { default as DialogHandler } from './handler/DialogHandler';
17
17
  import * as _dialog from './calls/dialogs/index';
18
18
  export { _dialog as dialog };
19
19
  export * from './types/IChaynsReact';
20
- export * from './util/initModuleFederationSharing';
20
+ export * from './util/initModuleFederationSharing';
21
+ export * from './util/bindChaynsApi';
@@ -161,6 +161,12 @@ export let FloatingButtonPosition = /*#__PURE__*/function (FloatingButtonPositio
161
161
  FloatingButtonPosition[FloatingButtonPosition["Left"] = 2] = "Left";
162
162
  return FloatingButtonPosition;
163
163
  }({});
164
+ export let FloatingButtonAnimation = /*#__PURE__*/function (FloatingButtonAnimation) {
165
+ FloatingButtonAnimation["None"] = "none";
166
+ FloatingButtonAnimation["FadeIn"] = "fade-in";
167
+ FloatingButtonAnimation["Pulse"] = "pulse";
168
+ return FloatingButtonAnimation;
169
+ }({});
164
170
  export let SharingApp = /*#__PURE__*/function (SharingApp) {
165
171
  SharingApp[SharingApp["Mail"] = 0] = "Mail";
166
172
  SharingApp[SharingApp["WhatsApp"] = 1] = "WhatsApp";
@@ -0,0 +1,5 @@
1
+ import { StaticChaynsApi } from "../index";
2
+ export const bindChaynsApi = fun => (values, functions) => {
3
+ new StaticChaynsApi(values, functions);
4
+ return fun;
5
+ };
@@ -1,36 +1,37 @@
1
1
  import React from 'react';
2
2
  import ReactDOM from 'react-dom';
3
- export const initModuleFederationSharing = () => {
3
+ export const initModuleFederationSharing = _ref => {
4
+ let {
5
+ name
6
+ } = _ref;
4
7
  // forces single instance of module federation runtime
5
- if (!globalThis.moduleFederationRuntime) {
6
- var _process$env$__PACKAG;
7
- globalThis.moduleFederationRuntime = require('@module-federation/enhanced/runtime');
8
- globalThis.moduleFederationScopes = {
9
- registeredScopes: {},
10
- moduleMap: {},
11
- componentMap: {}
12
- };
13
- const {
14
- init
15
- } = globalThis.moduleFederationRuntime;
16
-
17
- // init also should only be called once
18
- init({
19
- // will be set by chayns-toolkit via DefinePlugin
20
- name: (_process$env$__PACKAG = process.env.__PACKAGE_NAME__) !== null && _process$env$__PACKAG !== void 0 ? _process$env$__PACKAG : '',
21
- remotes: [],
22
- shared: {
23
- react: {
24
- version: React.version,
25
- scope: 'chayns-api2',
26
- lib: () => React
27
- },
28
- 'react-dom': {
29
- version: ReactDOM.version,
30
- scope: 'chayns-api2',
31
- lib: () => ReactDOM
32
- }
33
- }
34
- });
8
+ if (globalThis.moduleFederationRuntime) {
9
+ return;
35
10
  }
11
+ globalThis.moduleFederationRuntime = require('@module-federation/enhanced/runtime');
12
+ globalThis.moduleFederationScopes = {
13
+ registeredScopes: {},
14
+ moduleMap: {},
15
+ componentMap: {}
16
+ };
17
+ const {
18
+ init
19
+ } = globalThis.moduleFederationRuntime;
20
+ init({
21
+ name: name !== null && name !== void 0 ? name : '',
22
+ remotes: [],
23
+ shared: {
24
+ react: {
25
+ version: React.version,
26
+ scope: 'chayns-api',
27
+ lib: () => React
28
+ },
29
+ 'react-dom': {
30
+ version: React.version,
31
+ // intended, because react dom.version is not identical to package json react version (hash in version)
32
+ scope: 'chayns-api',
33
+ lib: () => ReactDOM
34
+ }
35
+ }
36
+ });
36
37
  };
@@ -6,8 +6,9 @@ import { AppName } from '../types/IChaynsReact';
6
6
  import getDeviceInfo from '../util/deviceHelper';
7
7
  import { AppWrapper } from './AppWrapper';
8
8
  import { FrameWrapper } from './FrameWrapper';
9
+ import { ModuleFederationWrapper } from "./ModuleFederationWrapper";
9
10
  class StaticChaynsApi {
10
- constructor() {
11
+ constructor(values, functions) {
11
12
  var _deviceInfo$app$name, _deviceInfo$app;
12
13
  _defineProperty(this, "getUser", () => this._wrapper.values.user);
13
14
  _defineProperty(this, "getSite", () => this._wrapper.values.site);
@@ -19,7 +20,9 @@ class StaticChaynsApi {
19
20
  _defineProperty(this, "getEnvironment", () => this._wrapper.values.environment);
20
21
  let wrapper;
21
22
  const deviceInfo = getDeviceInfo(navigator.userAgent, '');
22
- if ([AppName.Chayns, AppName.ChaynsLauncher, AppName.Sidekick, AppName.TobitChat].includes((_deviceInfo$app$name = (_deviceInfo$app = deviceInfo.app) === null || _deviceInfo$app === void 0 ? void 0 : _deviceInfo$app.name) !== null && _deviceInfo$app$name !== void 0 ? _deviceInfo$app$name : AppName.Unknown) && window.self === window.top) {
23
+ if (values && functions) {
24
+ wrapper = new ModuleFederationWrapper(values, functions);
25
+ } else if ([AppName.Chayns, AppName.ChaynsLauncher, AppName.Sidekick, AppName.TobitChat].includes((_deviceInfo$app$name = (_deviceInfo$app = deviceInfo.app) === null || _deviceInfo$app === void 0 ? void 0 : _deviceInfo$app.name) !== null && _deviceInfo$app$name !== void 0 ? _deviceInfo$app$name : AppName.Unknown) && window.self === window.top) {
23
26
  wrapper = new AppWrapper();
24
27
  } else {
25
28
  wrapper = new FrameWrapper();
@@ -221,6 +221,9 @@ export declare const getCurrentPage: () => {
221
221
  };
222
222
  export declare const getDevice: () => ChaynsApiDevice;
223
223
  export declare const getLanguage: () => {
224
+ /**
225
+ * Select other page on chayns site.
226
+ */
224
227
  site: import("../types/IChaynsReact").Language;
225
228
  translation: import("../types/IChaynsReact").Language | null;
226
229
  device: import("../types/IChaynsReact").Language;
@@ -233,12 +236,17 @@ export declare const getParameters: () => {
233
236
  export declare const getPages: () => import("../types/IChaynsReact").Page[];
234
237
  export declare const getEnvironment: () => {
235
238
  buildEnvironment: import("../types/IChaynsReact").Environment;
236
- runtimeEnvironment: string | import("../types/IChaynsReact").RuntimeEnviroment;
239
+ runtimeEnvironment: string | import("../types/IChaynsReact").RuntimeEnviroment; /**
240
+ * Scrolls to specific position.
241
+ */
237
242
  };
238
243
  export declare const user: UserInfo;
239
244
  export declare const site: ChaynsApiSite;
240
245
  export declare const device: ChaynsApiDevice;
241
246
  export declare const language: {
247
+ /**
248
+ * Select other page on chayns site.
249
+ */
242
250
  site: import("../types/IChaynsReact").Language;
243
251
  translation: import("../types/IChaynsReact").Language | null;
244
252
  device: import("../types/IChaynsReact").Language;
@@ -251,5 +259,7 @@ export declare const parameters: {
251
259
  export declare const pages: import("../types/IChaynsReact").Page[];
252
260
  export declare const environment: {
253
261
  buildEnvironment: import("../types/IChaynsReact").Environment;
254
- runtimeEnvironment: string | import("../types/IChaynsReact").RuntimeEnviroment;
262
+ runtimeEnvironment: string | import("../types/IChaynsReact").RuntimeEnviroment; /**
263
+ * Scrolls to specific position.
264
+ */
255
265
  };
@@ -8,10 +8,10 @@ type HydrationComponent = React.FC<{
8
8
  value: StoreLikeValue;
9
9
  children?: React.ReactNode;
10
10
  }>;
11
- type Initializer = (initialValue: object | undefined, id: string) => StoreLikeValue;
11
+ type Initializer = (initialValue: object | undefined, id: string, props: any) => StoreLikeValue;
12
12
  type HydrationBoundary = React.FC<{
13
13
  id?: string;
14
14
  children?: React.ReactNode;
15
15
  }>;
16
- declare const withHydrationBoundary: (Component: HydrationComponent, initializer: Initializer, useHydrationId: undefined | (() => string)) => HydrationBoundary;
16
+ declare const withHydrationBoundary: (Component: HydrationComponent, initializer: Initializer, useHydrationId: undefined | (() => string), useProps: ((props: any) => any) | undefined) => HydrationBoundary;
17
17
  export default withHydrationBoundary;
@@ -17,3 +17,4 @@ export { default as DialogHandler } from './handler/DialogHandler';
17
17
  export * as dialog from './calls/dialogs/index';
18
18
  export * from './types/IChaynsReact';
19
19
  export * from './util/initModuleFederationSharing';
20
+ export * from './util/bindChaynsApi';
@@ -30,8 +30,8 @@ export interface DialogDate {
30
30
  disabledWeekDayIntervals?: {
31
31
  weekDay: WeekDayType;
32
32
  interval?: {
33
- start: Date;
34
- end: Date;
33
+ start: string;
34
+ end: string;
35
35
  };
36
36
  }[];
37
37
  }
@@ -619,22 +619,28 @@ export declare enum FloatingButtonPosition {
619
619
  Center = 1,
620
620
  Left = 2
621
621
  }
622
+ export declare enum FloatingButtonAnimation {
623
+ None = "none",
624
+ FadeIn = "fade-in",
625
+ Pulse = "pulse"
626
+ }
622
627
  export interface FloatingButton {
623
628
  isEnabled: boolean;
624
- position: FloatingButtonPosition;
625
- zIndex: number;
626
- badge: string;
627
- textSize: number;
628
- color: string;
629
- colorText: string;
630
- icon: string;
631
- text: string;
632
- rotateIcon: boolean;
633
- items: {
629
+ position?: FloatingButtonPosition;
630
+ zIndex?: number;
631
+ badge?: string;
632
+ textSize?: number;
633
+ color?: string;
634
+ colorText?: string;
635
+ icon?: string;
636
+ text?: string;
637
+ rotateIcon?: boolean;
638
+ items?: {
634
639
  onClick?: () => Promise<void>;
635
640
  text: string;
636
641
  icon: string;
637
642
  }[];
643
+ animation?: FloatingButtonAnimation;
638
644
  }
639
645
  export declare enum SharingApp {
640
646
  Mail = 0,
@@ -0,0 +1 @@
1
+ export declare const bindChaynsApi: (fun: any) => (values: any, functions: any) => any;
@@ -1 +1,3 @@
1
- export declare const initModuleFederationSharing: () => void;
1
+ export declare const initModuleFederationSharing: ({ name }: {
2
+ name: any;
3
+ }) => void;
@@ -3,7 +3,7 @@ declare class StaticChaynsApi {
3
3
  ready: Promise<void>;
4
4
  addDataListener: (cb: DataChangeCallback) => () => void;
5
5
  private _wrapper;
6
- constructor();
6
+ constructor(values: any, functions: any);
7
7
  getUser: () => any;
8
8
  getSite: () => any;
9
9
  getCurrentPage: () => any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chayns-api",
3
- "version": "1.2.0-9",
3
+ "version": "2.0.1-0",
4
4
  "description": "new chayns api",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -63,7 +63,7 @@
63
63
  "@babel/preset-react": "^7.24.1",
64
64
  "@babel/preset-typescript": "^7.24.1",
65
65
  "@chayns-toolkit/eslint-config": "^2.0.0",
66
- "@testing-library/react": "^12.1.2",
66
+ "@testing-library/react": "^16.0.1",
67
67
  "@types/htmlescape": "^1.1.3",
68
68
  "@types/lodash.throttle": "^4.1.9",
69
69
  "@types/prop-types": "^15.7.12",
@@ -1,59 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.semaphore = exports.default = void 0;
7
- var _react = _interopRequireWildcard(require("react"));
8
- var _semaphoreAsyncAwait = _interopRequireDefault(require("semaphore-async-await"));
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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 = {};
13
- const useDynamicScript = args => {
14
- const [ready, setReady] = _react.default.useState(false);
15
- const [failed, setFailed] = _react.default.useState(false);
16
- (0, _react.useEffect)(() => {
17
- if (!args.url) {
18
- return undefined;
19
- }
20
- const element = document.createElement('script');
21
- element.src = args.url;
22
- element.type = 'text/javascript';
23
- element.async = true;
24
- setReady(false);
25
- setFailed(false);
26
- if (!(args.scope in semaphore)) {
27
- semaphore[args.scope] = new _semaphoreAsyncAwait.default(1);
28
- }
29
- (async () => {
30
- await semaphore[args.scope].acquire();
31
- element.onload = () => {
32
- setReady(true);
33
- const listKey = args.scope + "_list";
34
- if (!window[listKey]) window[listKey] = [];
35
- window[listKey].push({
36
- url: args.url,
37
- container: window[args.scope]
38
- });
39
- window[args.scope] = null;
40
- };
41
- element.onerror = () => {
42
- setReady(false);
43
- setFailed(true);
44
- };
45
- document.head.appendChild(element);
46
- })();
47
- return () => {
48
- semaphore[args.scope].release();
49
- if (document.head.contains(element)) {
50
- document.head.removeChild(element);
51
- }
52
- };
53
- }, [args.url]);
54
- return {
55
- ready,
56
- failed
57
- };
58
- };
59
- var _default = exports.default = useDynamicScript;
@@ -1,50 +0,0 @@
1
- import React, { useEffect } from 'react';
2
- import Semaphore from 'semaphore-async-await';
3
- export const semaphore = {};
4
- const useDynamicScript = args => {
5
- const [ready, setReady] = React.useState(false);
6
- const [failed, setFailed] = React.useState(false);
7
- useEffect(() => {
8
- if (!args.url) {
9
- return undefined;
10
- }
11
- const element = document.createElement('script');
12
- element.src = args.url;
13
- element.type = 'text/javascript';
14
- element.async = true;
15
- setReady(false);
16
- setFailed(false);
17
- if (!(args.scope in semaphore)) {
18
- semaphore[args.scope] = new Semaphore(1);
19
- }
20
- (async () => {
21
- await semaphore[args.scope].acquire();
22
- element.onload = () => {
23
- setReady(true);
24
- const listKey = args.scope + "_list";
25
- if (!window[listKey]) window[listKey] = [];
26
- window[listKey].push({
27
- url: args.url,
28
- container: window[args.scope]
29
- });
30
- window[args.scope] = null;
31
- };
32
- element.onerror = () => {
33
- setReady(false);
34
- setFailed(true);
35
- };
36
- document.head.appendChild(element);
37
- })();
38
- return () => {
39
- semaphore[args.scope].release();
40
- if (document.head.contains(element)) {
41
- document.head.removeChild(element);
42
- }
43
- };
44
- }, [args.url]);
45
- return {
46
- ready,
47
- failed
48
- };
49
- };
50
- export default useDynamicScript;
@@ -1,9 +0,0 @@
1
- export declare const semaphore: {};
2
- declare const useDynamicScript: (args: {
3
- url: string | undefined;
4
- scope: string | undefined;
5
- }) => {
6
- ready: boolean;
7
- failed: boolean;
8
- };
9
- export default useDynamicScript;