chayns-api 1.2.0-16 → 1.2.0-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.
@@ -21,7 +21,6 @@ const loadModule = (scope, module, url, preventSingleton = false) => {
21
21
  if (scope in registeredScopes) {
22
22
  console.error(`[chayns-api] call registerRemote with force for scope ${scope}. url: ${url}`);
23
23
  }
24
- console.log("load module", scope, module, url);
25
24
  registerRemotes([{
26
25
  shareScope: url.endsWith('v2.remoteEntry.js') ? 'chayns-api' : 'default',
27
26
  name: scope,
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 }; }
@@ -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(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();
@@ -15,7 +15,6 @@ export const loadModule = function (scope, module, url) {
15
15
  if (scope in registeredScopes) {
16
16
  console.error(`[chayns-api] call registerRemote with force for scope ${scope}. url: ${url}`);
17
17
  }
18
- console.log("load module", scope, module, url);
19
18
  registerRemotes([{
20
19
  shareScope: url.endsWith('v2.remoteEntry.js') ? 'chayns-api' : 'default',
21
20
  name: scope,
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';
@@ -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();
@@ -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';
@@ -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.2.0-16",
3
+ "version": "1.2.0-18",
4
4
  "description": "new chayns api",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",