@octostar/platform-api 0.5.11 → 0.5.13

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/index.d.ts CHANGED
@@ -9,4 +9,5 @@ export * from './lib/AIClientImpl';
9
9
  export * from './lib/Proxy';
10
10
  export * from './lib/userWorkspace';
11
11
  export * from './lib/ContextAPI';
12
+ export * from './lib/classInstanceToObject';
12
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,6BAA6B,CAAC"}
package/dist/index.js CHANGED
@@ -9,4 +9,5 @@ export * from './lib/AIClientImpl';
9
9
  export * from './lib/Proxy';
10
10
  export * from './lib/userWorkspace';
11
11
  export * from './lib/ContextAPI';
12
+ export * from './lib/classInstanceToObject';
12
13
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,6BAA6B,CAAC"}
@@ -1,21 +1,20 @@
1
1
  import { Context, ContextAPISetParams, ContextAPIStaticData, ContextListener } from '@octostar/platform-types';
2
- type ContextAPIContructorParams<ContextData extends Record<string, any>> = ContextAPIStaticData<ContextData> & {
3
- id?: string;
2
+ type ContextAPIConstructorParams<ContextData extends Record<string, any>> = ContextAPIStaticData<ContextData> & {
3
+ targetWindow?: Window;
4
4
  };
5
5
  export declare class ContextAPI<ContextData extends Record<string, any>> implements Context<ContextData> {
6
- readonly static_data: ContextAPIStaticData<ContextData>;
7
- private channel;
6
+ private contextData;
7
+ targetWindow: Window | undefined;
8
+ readonly id: string;
8
9
  private listeners;
9
- private id;
10
- constructor({ id, ...static_data }: ContextAPIContructorParams<ContextData>);
10
+ private postRobotEventId;
11
+ constructor({ targetWindow, contextData }: ContextAPIConstructorParams<ContextData>);
11
12
  get context(): ContextData;
12
13
  set context(context: ContextData);
13
- get channelId(): string | undefined;
14
- set channelId(channelId: string | undefined);
15
14
  getContext(): ContextData;
16
15
  setContext(context: ContextAPISetParams<ContextData>): void;
17
16
  notifyListeners(): void;
18
- syncContextToChannel(): void;
17
+ syncContextToChannel(): Promise<void>;
19
18
  subscribeToChanges(contextListener: ContextListener<ContextData>): string;
20
19
  subscribeToChanges(id: string, contextListener: ContextListener<ContextData>): string;
21
20
  unsubscribeFromChanges(id: string): void;
@@ -1 +1 @@
1
- {"version":3,"file":"ContextAPI.d.ts","sourceRoot":"","sources":["../../src/lib/ContextAPI.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,mBAAmB,EAAqB,oBAAoB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAGlI,KAAK,0BAA0B,CAAC,WAAW,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,oBAAoB,CAAC,WAAW,CAAC,GAAG;IAC7G,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,qBAAa,UAAU,CAAC,WAAW,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAE,YAAW,OAAO,CAAC,WAAW,CAAC;IAC9F,QAAQ,CAAC,WAAW,EAAE,oBAAoB,CAAC,WAAW,CAAC,CAAA;IAEvD,OAAO,CAAC,OAAO,CAA+B;IAE9C,OAAO,CAAC,SAAS,CAA+C;IAEhE,OAAO,CAAC,EAAE,CAAS;gBAEP,EAAE,EAAE,EAAE,GAAG,WAAW,EAAE,EAAE,0BAA0B,CAAC,WAAW,CAAC;IAO3E,IAAI,OAAO,IAIU,WAAW,CAF/B;IAED,IAAI,OAAO,CAAC,OAAO,EAAE,WAAW,EAK/B;IAED,IAAI,SAAS,IAIc,MAAM,GAAG,SAAS,CAF5C;IAEC,IAAI,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,EAe1C;IAEH,UAAU;IAIV,UAA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G,MAAM;IAEzE,kBAAkB,CAChB,EAAE,EAAE,MAAM,EACV,eAAe,EAAE,eAAe,CAAC,WAAW,CAAC,GAC5C,MAAM;IAqBT,sBAAsB,CAAC,EAAE,EAAE,MAAM;CAGlC"}
@@ -1,35 +1,26 @@
1
1
  import { v4 as uuidv4 } from 'uuid';
2
+ import postRobot from 'post-robot';
2
3
  export class ContextAPI {
3
- constructor({ id, ...static_data }) {
4
- this.static_data = static_data;
4
+ constructor({ targetWindow, contextData }) {
5
+ this.postRobotEventId = 'context-api-update';
6
+ this.contextData = contextData;
5
7
  this.listeners = {};
6
- this.id = id ?? uuidv4();
7
- this.channelId = static_data.channelId;
8
+ this.id = uuidv4();
9
+ this.targetWindow = targetWindow;
10
+ postRobot.on(this.postRobotEventId, (event) => {
11
+ if (event.data.from !== this.id) {
12
+ this.contextData = { ...this.contextData, ...event.data.contextData };
13
+ }
14
+ });
8
15
  }
9
16
  get context() {
10
- return this.static_data.context;
17
+ return this.contextData;
11
18
  }
12
19
  set context(context) {
13
- this.static_data.context = context;
20
+ this.contextData = context;
14
21
  this.notifyListeners();
15
22
  this.syncContextToChannel();
16
23
  }
17
- get channelId() {
18
- return this.static_data.channelId;
19
- }
20
- set channelId(channelId) {
21
- this.static_data.channelId = channelId;
22
- const contextChannelId = this.static_data.channelId && `ContextAPI-${this.static_data.channelId}`;
23
- if (!contextChannelId) {
24
- return;
25
- }
26
- this.channel = new BroadcastChannel(contextChannelId);
27
- this.channel.onmessage = (event) => {
28
- if (event.data.from !== this.id) {
29
- this.static_data.context = event.data.context;
30
- }
31
- };
32
- }
33
24
  getContext() {
34
25
  return this.context;
35
26
  }
@@ -40,11 +31,13 @@ export class ContextAPI {
40
31
  notifyListeners() {
41
32
  Object.values(this.listeners).forEach(listener => listener(this.context));
42
33
  }
43
- syncContextToChannel() {
44
- if (!this.channel) {
34
+ async syncContextToChannel() {
35
+ if (!this.targetWindow) {
45
36
  return;
46
37
  }
47
- this.channel.postMessage({
38
+ /** Try to exclude functions in the context */
39
+ // const context = classInstanceToObject(this.context);
40
+ await postRobot.send(this.targetWindow, this.postRobotEventId, {
48
41
  from: this.id,
49
42
  context: this.context,
50
43
  });
@@ -1 +1 @@
1
- {"version":3,"file":"ContextAPI.js","sourceRoot":"","sources":["../../src/lib/ContextAPI.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAMpC,MAAM,OAAO,UAAU;IASrB,YAAY,EAAE,EAAE,EAAE,GAAG,WAAW,EAA2C;QACzE,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,MAAM,EAAE,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,WAAW,CAAC,SAAS,CAAC;IACzC,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC;IAClC,CAAC;IAED,IAAI,OAAO,CAAC,OAAoB;QAC9B,IAAI,CAAC,WAAW,CAAC,OAAO,GAAG,OAAO,CAAC;QAEnC,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAC9B,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC;IACpC,CAAC;IAEC,IAAI,SAAS,CAAC,SAA6B;QACzC,IAAI,CAAC,WAAW,CAAC,SAAS,GAAG,SAAS,CAAC;QACvC,MAAM,gBAAgB,GAAG,IAAI,CAAC,WAAW,CAAC,SAAS,IAAI,cAAc,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,CAAC;QAClG,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACtB,OAAO;QACT,CAAC;QACD,IAAI,CAAC,OAAO,GAAG,IAAI,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;QAEtD,IAAI,CAAC,OAAO,C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AC5B,CAAC;CACF"}
@@ -0,0 +1,12 @@
1
+ export declare const classInstanceToObject: <T extends {
2
+ [key: string]: any;
3
+ }>(instance: T, options?: {
4
+ globals?: {
5
+ canCallAction?: (prams: {
6
+ method: string;
7
+ class: string;
8
+ }) => boolean;
9
+ };
10
+ methodWrappers?: { [K in keyof T]?: (fn: T[K], ...args: T[K] extends (...args: infer P) => any ? P : never) => T[K] extends (...args: any) => infer R ? R : never; };
11
+ }) => Record<string, any>;
12
+ //# sourceMappingURL=classInstanceToObject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"classInstanceToObject.d.ts","sourceRoot":"","sources":["../../src/lib/classInstanceToObject.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,qBAAqB,GAAI,CAAC,SAAS;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,EACpE,UAAU,CAAC,EACX,UAAU;IACR,OAAO,CAAC,EAAE;QACR,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE;YAAE,MAAM,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,KAAK,OAAO,CAAC;KACvE,CAAC;IACF,cAAc,CAAC,EAAE,GACd,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CACf,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EACR,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,KAAK,KACxD,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,GACxD,CAAC;CACH,KACA,MAAM,CAAC,MAAM,EAAE,GAAG,CAsCpB,CAAC"}
@@ -0,0 +1,48 @@
1
+ // Check if an object contains functions deeply
2
+ const containsDeepFunction = (obj) => {
3
+ if (obj === null || obj === undefined) {
4
+ return false;
5
+ }
6
+ if (typeof obj === 'function') {
7
+ return true;
8
+ }
9
+ if (typeof obj !== 'object') {
10
+ return false;
11
+ }
12
+ if (Array.isArray(obj)) {
13
+ return obj.some(item => containsDeepFunction(item));
14
+ }
15
+ return Object.values(obj).some(value => containsDeepFunction(value));
16
+ };
17
+ export const classInstanceToObject = (instance, options) => {
18
+ // Handle null or undefined
19
+ if (instance === null || instance === undefined) {
20
+ return instance;
21
+ }
22
+ // Handle primitive values
23
+ if (typeof instance !== 'object' || instance instanceof Date) {
24
+ return instance;
25
+ }
26
+ // Handle arrays
27
+ if (Array.isArray(instance)) {
28
+ return instance.map(item => classInstanceToObject(item, options));
29
+ }
30
+ // Handle objects
31
+ const obj = {};
32
+ // Get all own properties (data properties, not methods)
33
+ Object.keys(instance).forEach(key => {
34
+ const value = instance[key];
35
+ // Skip functions directly
36
+ if (typeof value === 'function') {
37
+ return;
38
+ }
39
+ // Skip properties that contain functions deeply
40
+ if (typeof value === 'object' && value !== null && containsDeepFunction(value)) {
41
+ return;
42
+ }
43
+ // Recursively convert nested objects
44
+ obj[key] = classInstanceToObject(value, options);
45
+ });
46
+ return obj;
47
+ };
48
+ //# sourceMappingURL=classInstanceToObject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"classInstanceToObject.js","sourceRoot":"","sources":["../../src/lib/classInstanceToObject.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,MAAM,oBAAoB,GAAG,CAAC,GAAQ,EAAW,EAAE;IACjD,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG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AED,qCAAqC;QACrC,GAAG,CAAC,GAAG,CAAC,GAAG,qBAAqB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
@@ -6684,7 +6684,7 @@ var forwardCallsToFutureObject = exports.forwardCallsToFutureObject = function f
6684
6684
  });
6685
6685
  };
6686
6686
 
6687
- },{"./constants":33,"./utils":44,"post-robot":5}],35:[function(require,module,exports){
6687
+ },{"./constants":33,"./utils":45,"post-robot":5}],35:[function(require,module,exports){
6688
6688
  "use strict";
6689
6689
 
6690
6690
  Object.defineProperty(exports, "__esModule", {
@@ -6811,8 +6811,19 @@ Object.keys(_ContextAPI).forEach(function (key) {
6811
6811
  }
6812
6812
  });
6813
6813
  });
6814
+ var _classInstanceToObject = require("./lib/classInstanceToObject");
6815
+ Object.keys(_classInstanceToObject).forEach(function (key) {
6816
+ if (key === "default" || key === "__esModule") return;
6817
+ if (key in exports && exports[key] === _classInstanceToObject[key]) return;
6818
+ Object.defineProperty(exports, key, {
6819
+ enumerable: true,
6820
+ get: function get() {
6821
+ return _classInstanceToObject[key];
6822
+ }
6823
+ });
6824
+ });
6814
6825
 
6815
- },{"./apis":22,"./components":32,"./constants":33,"./lib/AIClientImpl":36,"./lib/ContextAPI":38,"./lib/JWTProvider":39,"./lib/Proxy":40,"./lib/userWorkspace":41,"./permissions":42,"./types":43,"./utils":44}],36:[function(require,module,exports){
6826
+ },{"./apis":22,"./components":32,"./constants":33,"./lib/AIClientImpl":36,"./lib/ContextAPI":38,"./lib/JWTProvider":39,"./lib/Proxy":40,"./lib/classInstanceToObject":41,"./lib/userWorkspace":42,"./permissions":43,"./types":44,"./utils":45}],36:[function(require,module,exports){
6816
6827
  "use strict";
6817
6828
 
6818
6829
  Object.defineProperty(exports, "__esModule", {
@@ -7067,10 +7078,15 @@ Object.defineProperty(exports, "__esModule", {
7067
7078
  });
7068
7079
  exports.ContextAPI = void 0;
7069
7080
  var _uuid = require("uuid");
7070
- var _excluded = ["id"];
7081
+ var _postRobot = _interopRequireDefault(require("post-robot"));
7082
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
7071
7083
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
7072
- function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
7073
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
7084
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return r; }; var t, r = {}, e = Object.prototype, n = e.hasOwnProperty, o = "function" == typeof Symbol ? Symbol : {}, i = o.iterator || "@@iterator", a = o.asyncIterator || "@@asyncIterator", u = o.toStringTag || "@@toStringTag"; function c(t, r, e, n) { return Object.defineProperty(t, r, { value: e, enumerable: !n, configurable: !n, writable: !n }); } try { c({}, ""); } catch (t) { c = function c(t, r, e) { return t[r] = e; }; } function h(r, e, n, o) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype); return c(a, "_invoke", function (r, e, n) { var o = 1; return function (i, a) { if (3 === o) throw Error("Generator is already running"); if (4 === o) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var u = n.delegate; if (u) { var c = d(u, n); if (c) { if (c === f) continue; return c; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (1 === o) throw o = 4, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = 3; var h = s(r, e, n); if ("normal" === h.type) { if (o = n.done ? 4 : 2, h.arg === f) continue; return { value: h.arg, done: n.done }; } "throw" === h.type && (o = 4, n.method = "throw", n.arg = h.arg); } }; }(r, n, new Context(o || [])), !0), a; } function s(t, r, e) { try { return { type: "normal", arg: t.call(r, e) }; } catch (t) { return { type: "throw", arg: t }; } } r.wrap = h; var f = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var l = {}; c(l, i, function () { return this; }); var p = Object.getPrototypeOf, y = p && p(p(x([]))); y && y !== e && n.call(y, i) && (l = y); var v = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(l); function g(t) { ["next", "throw", "return"].forEach(function (r) { c(t, r, function (t) { return this._invoke(r, t); }); }); } function AsyncIterator(t, r) { function e(o, i, a, u) { var c = s(t[o], t, i); if ("throw" !== c.type) { var h = c.arg, f = h.value; return f && "object" == _typeof(f) && n.call(f, "__await") ? r.resolve(f.__await).then(function (t) { e("next", t, a, u); }, function (t) { e("throw", t, a, u); }) : r.resolve(f).then(function (t) { h.value = t, a(h); }, function (t) { return e("throw", t, a, u); }); } u(c.arg); } var o; c(this, "_invoke", function (t, n) { function i() { return new r(function (r, o) { e(t, n, r, o); }); } return o = o ? o.then(i, i) : i(); }, !0); } function d(r, e) { var n = e.method, o = r.i[n]; if (o === t) return e.delegate = null, "throw" === n && r.i["return"] && (e.method = "return", e.arg = t, d(r, e), "throw" === e.method) || "return" !== n && (e.method = "throw", e.arg = new TypeError("The iterator does not provide a '" + n + "' method")), f; var i = s(o, r.i, e.arg); if ("throw" === i.type) return e.method = "throw", e.arg = i.arg, e.delegate = null, f; var a = i.arg; return a ? a.done ? (e[r.r] = a.value, e.next = r.n, "return" !== e.method && (e.method = "next", e.arg = t), e.delegate = null, f) : a : (e.method = "throw", e.arg = new TypeError("iterator result is not an object"), e.delegate = null, f); } function w(t) { this.tryEntries.push(t); } function m(r) { var e = r[4] || {}; e.type = "normal", e.arg = t, r[4] = e; } function Context(t) { this.tryEntries = [[-1]], t.forEach(w, this), this.reset(!0); } function x(r) { if (null != r) { var e = r[i]; if (e) return e.call(r); if ("function" == typeof r.next) return r; if (!isNaN(r.length)) { var o = -1, a = function e() { for (; ++o < r.length;) if (n.call(r, o)) return e.value = r[o], e.done = !1, e; return e.value = t, e.done = !0, e; }; return a.next = a; } } throw new TypeError(_typeof(r) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, c(v, "constructor", GeneratorFunctionPrototype), c(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = c(GeneratorFunctionPrototype, u, "GeneratorFunction"), r.isGeneratorFunction = function (t) { var r = "function" == typeof t && t.constructor; return !!r && (r === GeneratorFunction || "GeneratorFunction" === (r.displayName || r.name)); }, r.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, c(t, u, "GeneratorFunction")), t.prototype = Object.create(v), t; }, r.awrap = function (t) { return { __await: t }; }, g(AsyncIterator.prototype), c(AsyncIterator.prototype, a, function () { return this; }), r.AsyncIterator = AsyncIterator, r.async = function (t, e, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(h(t, e, n, o), i); return r.isGeneratorFunction(e) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, g(v), c(v, u, "Generator"), c(v, i, function () { return this; }), c(v, "toString", function () { return "[object Generator]"; }), r.keys = function (t) { var r = Object(t), e = []; for (var n in r) e.unshift(n); return function t() { for (; e.length;) if ((n = e.pop()) in r) return t.value = n, t.done = !1, t; return t.done = !0, t; }; }, r.values = x, Context.prototype = { constructor: Context, reset: function reset(r) { if (this.prev = this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(m), !r) for (var e in this) "t" === e.charAt(0) && n.call(this, e) && !isNaN(+e.slice(1)) && (this[e] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0][4]; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(r) { if (this.done) throw r; var e = this; function n(t) { a.type = "throw", a.arg = r, e.next = t; } for (var o = e.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i[4], u = this.prev, c = i[1], h = i[2]; if (-1 === i[0]) return n("end"), !1; if (!c && !h) throw Error("try statement without catch or finally"); if (null != i[0] && i[0] <= u) { if (u < c) return this.method = "next", this.arg = t, n(c), !0; if (u < h) return n(h), !1; } } }, abrupt: function abrupt(t, r) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var n = this.tryEntries[e]; if (n[0] > -1 && n[0] <= this.prev && this.prev < n[2]) { var o = n; break; } } o && ("break" === t || "continue" === t) && o[0] <= r && r <= o[2] && (o = null); var i = o ? o[4] : {}; return i.type = t, i.arg = r, o ? (this.method = "next", this.next = o[2], f) : this.complete(i); }, complete: function complete(t, r) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && r && (this.next = r), f; }, finish: function finish(t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var e = this.tryEntries[r]; if (e[2] === t) return this.complete(e[4], e[3]), m(e), f; } }, "catch": function _catch(t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var e = this.tryEntries[r]; if (e[0] === t) { var n = e[4]; if ("throw" === n.type) { var o = n.arg; m(e); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(r, e, n) { return this.delegate = { i: x(r), r: e, n: n }, "next" === this.method && (this.arg = t), f; } }, r; }
7085
+ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
7086
+ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
7087
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
7088
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7089
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
7074
7090
  function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
7075
7091
  function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
7076
7092
  function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
@@ -7078,43 +7094,31 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
7078
7094
  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); }
7079
7095
  var ContextAPI = exports.ContextAPI = /*#__PURE__*/function () {
7080
7096
  function ContextAPI(_ref) {
7081
- var id = _ref.id,
7082
- static_data = _objectWithoutProperties(_ref, _excluded);
7097
+ var _this = this;
7098
+ var targetWindow = _ref.targetWindow,
7099
+ contextData = _ref.contextData;
7083
7100
  _classCallCheck(this, ContextAPI);
7084
- this.static_data = static_data;
7101
+ this.postRobotEventId = 'context-api-update';
7102
+ this.contextData = contextData;
7085
7103
  this.listeners = {};
7086
- this.id = id !== null && id !== void 0 ? id : (0, _uuid.v4)();
7087
- this.channelId = static_data.channelId;
7104
+ this.id = (0, _uuid.v4)();
7105
+ this.targetWindow = targetWindow;
7106
+ _postRobot["default"].on(this.postRobotEventId, function (event) {
7107
+ if (event.data.from !== _this.id) {
7108
+ _this.contextData = _objectSpread(_objectSpread({}, _this.contextData), event.data.contextData);
7109
+ }
7110
+ });
7088
7111
  }
7089
7112
  return _createClass(ContextAPI, [{
7090
7113
  key: "context",
7091
7114
  get: function get() {
7092
- return this.static_data.context;
7115
+ return this.contextData;
7093
7116
  },
7094
7117
  set: function set(context) {
7095
- this.static_data.context = context;
7118
+ this.contextData = context;
7096
7119
  this.notifyListeners();
7097
7120
  this.syncContextToChannel();
7098
7121
  }
7099
- }, {
7100
- key: "channelId",
7101
- get: function get() {
7102
- return this.static_data.channelId;
7103
- },
7104
- set: function set(channelId) {
7105
- var _this = this;
7106
- this.static_data.channelId = channelId;
7107
- var contextChannelId = this.static_data.channelId && "ContextAPI-".concat(this.static_data.channelId);
7108
- if (!contextChannelId) {
7109
- return;
7110
- }
7111
- this.channel = new BroadcastChannel(contextChannelId);
7112
- this.channel.onmessage = function (event) {
7113
- if (event.data.from !== _this.id) {
7114
- _this.static_data.context = event.data.context;
7115
- }
7116
- };
7117
- }
7118
7122
  }, {
7119
7123
  key: "getContext",
7120
7124
  value: function getContext() {
@@ -7135,15 +7139,33 @@ var ContextAPI = exports.ContextAPI = /*#__PURE__*/function () {
7135
7139
  }
7136
7140
  }, {
7137
7141
  key: "syncContextToChannel",
7138
- value: function syncContextToChannel() {
7139
- if (!this.channel) {
7140
- return;
7142
+ value: function () {
7143
+ var _syncContextToChannel = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
7144
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
7145
+ while (1) switch (_context.prev = _context.next) {
7146
+ case 0:
7147
+ if (this.targetWindow) {
7148
+ _context.next = 2;
7149
+ break;
7150
+ }
7151
+ return _context.abrupt("return");
7152
+ case 2:
7153
+ _context.next = 4;
7154
+ return _postRobot["default"].send(this.targetWindow, this.postRobotEventId, {
7155
+ from: this.id,
7156
+ context: this.context
7157
+ });
7158
+ case 4:
7159
+ case "end":
7160
+ return _context.stop();
7161
+ }
7162
+ }, _callee, this);
7163
+ }));
7164
+ function syncContextToChannel() {
7165
+ return _syncContextToChannel.apply(this, arguments);
7141
7166
  }
7142
- this.channel.postMessage({
7143
- from: this.id,
7144
- context: this.context
7145
- });
7146
- }
7167
+ return syncContextToChannel;
7168
+ }()
7147
7169
  }, {
7148
7170
  key: "subscribeToChanges",
7149
7171
  value: function subscribeToChanges(idOrContextListener, contextListenerOrNothing) {
@@ -7163,7 +7185,7 @@ var ContextAPI = exports.ContextAPI = /*#__PURE__*/function () {
7163
7185
  }]);
7164
7186
  }();
7165
7187
 
7166
- },{"uuid":6}],39:[function(require,module,exports){
7188
+ },{"post-robot":5,"uuid":6}],39:[function(require,module,exports){
7167
7189
  "use strict";
7168
7190
 
7169
7191
  Object.defineProperty(exports, "__esModule", {
@@ -7287,6 +7309,68 @@ var makeProxy = exports.makeProxy = function makeProxy(obj) {
7287
7309
  },{}],41:[function(require,module,exports){
7288
7310
  "use strict";
7289
7311
 
7312
+ Object.defineProperty(exports, "__esModule", {
7313
+ value: true
7314
+ });
7315
+ exports.classInstanceToObject = void 0;
7316
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
7317
+ // Check if an object contains functions deeply
7318
+ var containsDeepFunction = function containsDeepFunction(obj) {
7319
+ if (obj === null || obj === undefined) {
7320
+ return false;
7321
+ }
7322
+ if (typeof obj === 'function') {
7323
+ return true;
7324
+ }
7325
+ if (_typeof(obj) !== 'object') {
7326
+ return false;
7327
+ }
7328
+ if (Array.isArray(obj)) {
7329
+ return obj.some(function (item) {
7330
+ return containsDeepFunction(item);
7331
+ });
7332
+ }
7333
+ return Object.values(obj).some(function (value) {
7334
+ return containsDeepFunction(value);
7335
+ });
7336
+ };
7337
+ var classInstanceToObject = exports.classInstanceToObject = function classInstanceToObject(instance, options) {
7338
+ // Handle null or undefined
7339
+ if (instance === null || instance === undefined) {
7340
+ return instance;
7341
+ }
7342
+ // Handle primitive values
7343
+ if (_typeof(instance) !== 'object' || instance instanceof Date) {
7344
+ return instance;
7345
+ }
7346
+ // Handle arrays
7347
+ if (Array.isArray(instance)) {
7348
+ return instance.map(function (item) {
7349
+ return classInstanceToObject(item, options);
7350
+ });
7351
+ }
7352
+ // Handle objects
7353
+ var obj = {};
7354
+ // Get all own properties (data properties, not methods)
7355
+ Object.keys(instance).forEach(function (key) {
7356
+ var value = instance[key];
7357
+ // Skip functions directly
7358
+ if (typeof value === 'function') {
7359
+ return;
7360
+ }
7361
+ // Skip properties that contain functions deeply
7362
+ if (_typeof(value) === 'object' && value !== null && containsDeepFunction(value)) {
7363
+ return;
7364
+ }
7365
+ // Recursively convert nested objects
7366
+ obj[key] = classInstanceToObject(value, options);
7367
+ });
7368
+ return obj;
7369
+ };
7370
+
7371
+ },{}],42:[function(require,module,exports){
7372
+ "use strict";
7373
+
7290
7374
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
7291
7375
  Object.defineProperty(exports, "__esModule", {
7292
7376
  value: true
@@ -7337,7 +7421,7 @@ var getOrCreateUsersPrivateWorkspaceRecord = exports.getOrCreateUsersPrivateWork
7337
7421
  };
7338
7422
  }();
7339
7423
 
7340
- },{"uuid":6}],42:[function(require,module,exports){
7424
+ },{"uuid":6}],43:[function(require,module,exports){
7341
7425
  "use strict";
7342
7426
 
7343
7427
  Object.defineProperty(exports, "__esModule", {
@@ -7362,14 +7446,14 @@ var ONTOLOGY_PERMISSION_GROUP = exports.ONTOLOGY_PERMISSION_GROUP = 'octostar:on
7362
7446
  var ALL_PERMISSIONS = exports.ALL_PERMISSIONS = 'all';
7363
7447
  var ALL_PERMISSIONS_ARRAY = exports.ALL_PERMISSIONS_ARRAY = [ALL_PERMISSIONS];
7364
7448
 
7365
- },{}],43:[function(require,module,exports){
7449
+ },{}],44:[function(require,module,exports){
7366
7450
  "use strict";
7367
7451
 
7368
7452
  Object.defineProperty(exports, "__esModule", {
7369
7453
  value: true
7370
7454
  });
7371
7455
 
7372
- },{}],44:[function(require,module,exports){
7456
+ },{}],45:[function(require,module,exports){
7373
7457
  "use strict";
7374
7458
 
7375
7459
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@octostar/platform-api",
3
- "version": "0.5.11",
3
+ "version": "0.5.13",
4
4
  "description": "Provides access to the API exposed by Octostar platform to an application run in an iframe",
5
5
  "keywords": [
6
6
  "octostar",
@@ -38,10 +38,10 @@
38
38
  "rimraf": "^5.0.5",
39
39
  "tsup": "^8.4.0",
40
40
  "typescript": "^5.8.2",
41
- "@octostar/platform-types": "0.5.14"
41
+ "@octostar/platform-types": "0.5.16"
42
42
  },
43
43
  "peerDependencies": {
44
- "@octostar/platform-types": "^0.5.14"
44
+ "@octostar/platform-types": "^0.5.16"
45
45
  },
46
46
  "publishConfig": {
47
47
  "access": "public"