@miso.ai/client-sdk-core 1.10.2-beta.0 → 1.10.2-beta.2

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.
@@ -69,7 +69,7 @@ class Answer {
69
69
  } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
70
70
  // TODO: pass signal
71
71
  const response = await _this.get();
72
- return [response, response.finished];
72
+ return [response, response.finished, response.revision];
73
73
  };
74
74
  let _this$_options = this._options,
75
75
  {
@@ -27,6 +27,9 @@ class MisoClient extends _commons.Component {
27
27
  }
28
28
  window.MisoClient = MisoClient;
29
29
  }
30
+
31
+ // nop, will be replaced by DebugPlugin
32
+ static debug() {}
30
33
  constructor(options) {
31
34
  super('client', _root.root);
32
35
  this._config(options);
@@ -15,6 +15,12 @@ Object.defineProperty(exports, "InteractionsPlugin", {
15
15
  return _interactions.default;
16
16
  }
17
17
  });
18
+ Object.defineProperty(exports, "NativeFetchPlugin", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _nativeFetch.default;
22
+ }
23
+ });
18
24
  Object.defineProperty(exports, "PageInfoPlugin", {
19
25
  enumerable: true,
20
26
  get: function () {
@@ -31,4 +37,5 @@ var _user = _interopRequireDefault(require("./user.js"));
31
37
  var _pageInfo = _interopRequireDefault(require("./page-info.js"));
32
38
  var _autoEvents = _interopRequireDefault(require("./auto-events.js"));
33
39
  var _interactions = _interopRequireDefault(require("./interactions.js"));
40
+ var _nativeFetch = _interopRequireDefault(require("./native-fetch.js"));
34
41
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ const PLUGIN_ID = 'std:native-fetch';
8
+ function isNativeFunction(fn) {
9
+ return fn.toString().indexOf("[native code]") > -1;
10
+ }
11
+ let _fetchSource;
12
+ let _fetchError;
13
+ const fetchFn = (() => {
14
+ if (isNativeFunction(window.fetch)) {
15
+ _fetchSource = 'original';
16
+ return window.fetch;
17
+ }
18
+ try {
19
+ const iframe = document.createElement('iframe');
20
+ iframe.style.display = 'none';
21
+ document.head.appendChild(iframe); // in case body is not available yet
22
+ // don't remove the iframe to keep the fetch function alive
23
+ _fetchSource = 'borrowed';
24
+ return iframe.contentWindow.fetch;
25
+ } catch (e) {
26
+ _fetchError = e;
27
+ }
28
+ return undefined;
29
+ })();
30
+ class NativeFetchPlugin {
31
+ static get id() {
32
+ return PLUGIN_ID;
33
+ }
34
+ install(MisoClient, context) {
35
+ if (!fetchFn) {
36
+ MisoClient.debug(`<plugin:${PLUGIN_ID}>`, '[error]', `Failed to obtain native fetch: ${_fetchError.message}`);
37
+ return;
38
+ }
39
+ context.setCustomFetch(fetchFn);
40
+ MisoClient.debug(`<plugin:${PLUGIN_ID}>`, '[info]', `Using ${_fetchSource} native fetch`);
41
+ }
42
+ }
43
+ exports.default = NativeFetchPlugin;
@@ -4,4 +4,4 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _default = exports.default = '1.10.2-beta.0';
7
+ var _default = exports.default = '1.10.2-beta.2';
package/package.json CHANGED
@@ -29,7 +29,7 @@
29
29
  "url": "https://github.com/MisoAI/miso-client-js-sdk/issues"
30
30
  },
31
31
  "dependencies": {
32
- "@miso.ai/commons": "1.10.2-beta.0"
32
+ "@miso.ai/commons": "1.10.2-beta.2"
33
33
  },
34
- "version": "1.10.2-beta.0"
34
+ "version": "1.10.2-beta.2"
35
35
  }
package/src/api/ask.js CHANGED
@@ -56,7 +56,7 @@ class Answer {
56
56
  const fetch = async ({ signal } = {}) => {
57
57
  // TODO: pass signal
58
58
  const response = await this.get();
59
- return [response, response.finished];
59
+ return [response, response.finished, response.revision];
60
60
  };
61
61
  let { pollingInterval: interval, signal, stallTimeout = 120000, ...options } = this._options;
62
62
  const stac = new StallTimeoutAbortController(stallTimeout);
package/src/client.js CHANGED
@@ -20,6 +20,9 @@ class MisoClient extends Component {
20
20
  window.MisoClient = MisoClient;
21
21
  }
22
22
 
23
+ // nop, will be replaced by DebugPlugin
24
+ static debug() {}
25
+
23
26
  constructor(options) {
24
27
  super('client', root);
25
28
  this._config(options);
@@ -2,3 +2,4 @@ export { default as UserPlugin } from './user.js';
2
2
  export { default as PageInfoPlugin } from './page-info.js';
3
3
  export { default as AutoEventsPlugin } from './auto-events.js';
4
4
  export { default as InteractionsPlugin } from './interactions.js';
5
+ export { default as NativeFetchPlugin } from './native-fetch.js';
@@ -0,0 +1,43 @@
1
+ const PLUGIN_ID = 'std:native-fetch';
2
+
3
+ function isNativeFunction(fn) {
4
+ return fn.toString().indexOf("[native code]") > -1;
5
+ }
6
+
7
+ let _fetchSource;
8
+ let _fetchError;
9
+
10
+ const fetchFn = (() => {
11
+ if (isNativeFunction(window.fetch)) {
12
+ _fetchSource = 'original';
13
+ return window.fetch;
14
+ }
15
+ try {
16
+ const iframe = document.createElement('iframe');
17
+ iframe.style.display = 'none';
18
+ document.head.appendChild(iframe); // in case body is not available yet
19
+ // don't remove the iframe to keep the fetch function alive
20
+ _fetchSource = 'borrowed';
21
+ return iframe.contentWindow.fetch;
22
+ } catch (e) {
23
+ _fetchError = e;
24
+ }
25
+ return undefined;
26
+ })();
27
+
28
+ export default class NativeFetchPlugin {
29
+
30
+ static get id() {
31
+ return PLUGIN_ID;
32
+ }
33
+
34
+ install(MisoClient, context) {
35
+ if (!fetchFn) {
36
+ MisoClient.debug(`<plugin:${PLUGIN_ID}>`, '[error]', `Failed to obtain native fetch: ${_fetchError.message}`);
37
+ return;
38
+ }
39
+ context.setCustomFetch(fetchFn);
40
+ MisoClient.debug(`<plugin:${PLUGIN_ID}>`, '[info]', `Using ${_fetchSource} native fetch`);
41
+ }
42
+
43
+ }
package/src/version.js CHANGED
@@ -1 +1 @@
1
- export default '1.10.2-beta.0';
1
+ export default '1.10.2-beta.2';