@miso.ai/client-sdk-core 1.10.2-beta.1 → 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.
- package/dist/cjs/api/ask.js +1 -1
- package/dist/cjs/client.js +3 -0
- package/dist/cjs/plugin/index.js +7 -0
- package/dist/cjs/plugin/native-fetch.js +43 -0
- package/dist/cjs/version.js +1 -1
- package/package.json +2 -2
- package/src/api/ask.js +1 -1
- package/src/client.js +3 -0
- package/src/plugin/index.js +1 -0
- package/src/plugin/native-fetch.js +43 -0
- package/src/version.js +1 -1
package/dist/cjs/api/ask.js
CHANGED
|
@@ -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
|
{
|
package/dist/cjs/client.js
CHANGED
package/dist/cjs/plugin/index.js
CHANGED
|
@@ -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;
|
package/dist/cjs/version.js
CHANGED
package/package.json
CHANGED
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
package/src/plugin/index.js
CHANGED
|
@@ -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.
|
|
1
|
+
export default '1.10.2-beta.2';
|