chayns-api 1.1.17 → 1.1.18

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/index.js CHANGED
@@ -143,6 +143,18 @@ var _StaticChaynsApi = _interopRequireDefault(require("./wrapper/StaticChaynsApi
143
143
  var _DialogHandler = _interopRequireDefault(require("./handler/DialogHandler"));
144
144
  var _dialog = _interopRequireWildcard(require("./calls/dialogs/index"));
145
145
  exports.dialog = _dialog;
146
+ var _bindChaynsApi = require("./util/bindChaynsApi");
147
+ Object.keys(_bindChaynsApi).forEach(function (key) {
148
+ if (key === "default" || key === "__esModule") return;
149
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
150
+ if (key in exports && exports[key] === _bindChaynsApi[key]) return;
151
+ Object.defineProperty(exports, key, {
152
+ enumerable: true,
153
+ get: function () {
154
+ return _bindChaynsApi[key];
155
+ }
156
+ });
157
+ });
146
158
  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); }
147
159
  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; }
148
160
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -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;
@@ -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(e) { return e && e.__esModule ? e : { default: e }; }
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();
package/dist/esm/index.js CHANGED
@@ -17,4 +17,5 @@ export * from './types/IChaynsReact';
17
17
  export default {
18
18
  buildEnv: process.env.BUILD_ENV,
19
19
  appVersion: process.env.VERSION
20
- };
20
+ };
21
+ export * from './util/bindChaynsApi';
@@ -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
+ };
@@ -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();
@@ -18,3 +18,4 @@ declare const _default: {
18
18
  appVersion: string | undefined;
19
19
  };
20
20
  export default _default;
21
+ export * from './util/bindChaynsApi';
@@ -0,0 +1 @@
1
+ export declare const bindChaynsApi: (fun: any) => (values: any, functions: any) => any;
@@ -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.1.17",
3
+ "version": "1.1.18",
4
4
  "description": "new chayns api",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",