@miso.ai/client-sdk-core 1.8.2 → 1.9.0-beta.0
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/client.js +4 -2
- package/dist/cjs/index.js +9 -1
- package/dist/cjs/plugin/plugin-root.js +1 -1
- package/dist/cjs/root.js +9 -1
- package/dist/cjs/version.js +1 -1
- package/package.json +2 -2
- package/src/client.js +3 -2
- package/src/index.js +1 -0
- package/src/plugin/plugin-root.js +1 -1
- package/src/root.js +11 -2
- package/src/version.js +1 -1
package/dist/cjs/client.js
CHANGED
|
@@ -12,6 +12,9 @@ var helpers = _interopRequireWildcard(require("./utils"));
|
|
|
12
12
|
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); }
|
|
13
13
|
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 && Object.prototype.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; }
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
const {
|
|
16
|
+
currentScript
|
|
17
|
+
} = document;
|
|
15
18
|
class MisoClient extends _commons.Component {
|
|
16
19
|
static attach() {
|
|
17
20
|
(window.MisoClients || (window.MisoClients = [])).push(MisoClient);
|
|
@@ -56,8 +59,7 @@ class MisoClient extends _commons.Component {
|
|
|
56
59
|
return (0, _commons.trimObj)(options);
|
|
57
60
|
}
|
|
58
61
|
_readConfigFromScriptUrl() {
|
|
59
|
-
const
|
|
60
|
-
const url = me.src || me.href; // might be <link> as well
|
|
62
|
+
const url = currentScript.src || currentScript.href; // might be <link> as well
|
|
61
63
|
const params = new URL(new Request(url).url).searchParams;
|
|
62
64
|
return (0, _commons.trimObj)({
|
|
63
65
|
apiKey: params.get('api_key') || undefined
|
package/dist/cjs/index.js
CHANGED
|
@@ -5,7 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
var _exportNames = {
|
|
7
7
|
version: true,
|
|
8
|
-
MisoClient: true
|
|
8
|
+
MisoClient: true,
|
|
9
|
+
setCmdDone: true
|
|
9
10
|
};
|
|
10
11
|
Object.defineProperty(exports, "MisoClient", {
|
|
11
12
|
enumerable: true,
|
|
@@ -13,6 +14,12 @@ Object.defineProperty(exports, "MisoClient", {
|
|
|
13
14
|
return _client.default;
|
|
14
15
|
}
|
|
15
16
|
});
|
|
17
|
+
Object.defineProperty(exports, "setCmdDone", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () {
|
|
20
|
+
return _root.setCmdDone;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
16
23
|
Object.defineProperty(exports, "version", {
|
|
17
24
|
enumerable: true,
|
|
18
25
|
get: function () {
|
|
@@ -33,4 +40,5 @@ Object.keys(_index).forEach(function (key) {
|
|
|
33
40
|
}
|
|
34
41
|
});
|
|
35
42
|
});
|
|
43
|
+
var _root = require("./root.js");
|
|
36
44
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -196,7 +196,7 @@ class PluginRoot extends _commons.Registry {
|
|
|
196
196
|
const {
|
|
197
197
|
version
|
|
198
198
|
} = this._root;
|
|
199
|
-
const request = version === 'dev' ? `plugin:${id}@dev:${MisoClient.uuid}` : `plugin:${id}@${version}`;
|
|
199
|
+
const request = version === 'dev' ? `plugin:${id}@dev:${this.MisoClient.uuid}` : `plugin:${id}@${version}`;
|
|
200
200
|
|
|
201
201
|
// check if such script already exists
|
|
202
202
|
if (!document.querySelector(`script[data-request="${request}"]`)) {
|
package/dist/cjs/root.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.init = init;
|
|
7
7
|
exports.register = register;
|
|
8
8
|
exports.root = void 0;
|
|
9
|
+
exports.setCmdDone = setCmdDone;
|
|
9
10
|
var _commons = require("@miso.ai/commons");
|
|
10
11
|
var _version = _interopRequireDefault(require("./version.js"));
|
|
11
12
|
var _pluginRoot = _interopRequireDefault(require("./plugin/plugin-root.js"));
|
|
@@ -24,6 +25,7 @@ class Root extends _commons.Component {
|
|
|
24
25
|
this._customFetch = undefined;
|
|
25
26
|
this._customSendBeacon = undefined;
|
|
26
27
|
this.version = _version.default || 'dev';
|
|
28
|
+
this._cmdRes = new _commons.Resolution();
|
|
27
29
|
}
|
|
28
30
|
get instances() {
|
|
29
31
|
return [...this._clients]; // write protection
|
|
@@ -32,16 +34,22 @@ class Root extends _commons.Component {
|
|
|
32
34
|
async any() {
|
|
33
35
|
return this._clients[0] || this._any || (this._any = (await this._events.once('create')).data);
|
|
34
36
|
}
|
|
37
|
+
get cmdDone() {
|
|
38
|
+
return this._cmdRes.promise;
|
|
39
|
+
}
|
|
35
40
|
}
|
|
36
41
|
const root = exports.root = new Root();
|
|
37
42
|
function init(MisoClient) {
|
|
38
43
|
const pluginRoot = root._pluginRoot;
|
|
39
44
|
root.MisoClient = pluginRoot.MisoClient = MisoClient;
|
|
40
|
-
(0, _commons.delegateGetters)(MisoClient, root, ['version', 'instances', 'any', 'meta', 'on', 'once']);
|
|
45
|
+
(0, _commons.delegateGetters)(MisoClient, root, ['version', 'instances', 'any', 'meta', 'on', 'once', 'cmdDone']);
|
|
41
46
|
(0, _commons.delegateGetters)(MisoClient, pluginRoot, ['plugins']);
|
|
42
47
|
return MisoClient;
|
|
43
48
|
}
|
|
44
49
|
function register(client) {
|
|
45
50
|
root._clients.push(client);
|
|
46
51
|
root._events.emit('create', client);
|
|
52
|
+
}
|
|
53
|
+
function setCmdDone() {
|
|
54
|
+
root._cmdRes.resolve();
|
|
47
55
|
}
|
package/dist/cjs/version.js
CHANGED
package/package.json
CHANGED
package/src/client.js
CHANGED
|
@@ -4,6 +4,8 @@ import { Api } from './api/index.js';
|
|
|
4
4
|
import Context from './context';
|
|
5
5
|
import * as helpers from './utils';
|
|
6
6
|
|
|
7
|
+
const { currentScript } = document;
|
|
8
|
+
|
|
7
9
|
class MisoClient extends Component {
|
|
8
10
|
|
|
9
11
|
static attach() {
|
|
@@ -58,8 +60,7 @@ class MisoClient extends Component {
|
|
|
58
60
|
}
|
|
59
61
|
|
|
60
62
|
_readConfigFromScriptUrl() {
|
|
61
|
-
const
|
|
62
|
-
const url = me.src || me.href; // might be <link> as well
|
|
63
|
+
const url = currentScript.src || currentScript.href; // might be <link> as well
|
|
63
64
|
const params = new URL(new Request(url).url).searchParams;
|
|
64
65
|
return trimObj({
|
|
65
66
|
apiKey: params.get('api_key') || undefined,
|
package/src/index.js
CHANGED
|
@@ -203,7 +203,7 @@ export default class PluginRoot extends Registry {
|
|
|
203
203
|
|
|
204
204
|
async _registerStdRemotely(id) {
|
|
205
205
|
const { version } = this._root;
|
|
206
|
-
const request = version === 'dev' ? `plugin:${id}@dev:${MisoClient.uuid}` : `plugin:${id}@${version}`;
|
|
206
|
+
const request = version === 'dev' ? `plugin:${id}@dev:${this.MisoClient.uuid}` : `plugin:${id}@${version}`;
|
|
207
207
|
|
|
208
208
|
// check if such script already exists
|
|
209
209
|
if (!document.querySelector(`script[data-request="${request}"]`)) {
|
package/src/root.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { delegateGetters, Component } from '@miso.ai/commons';
|
|
1
|
+
import { delegateGetters, Component, Resolution } from '@miso.ai/commons';
|
|
2
2
|
import version from './version.js';
|
|
3
3
|
import PluginRoot from './plugin/plugin-root.js';
|
|
4
4
|
|
|
@@ -17,6 +17,7 @@ class Root extends Component {
|
|
|
17
17
|
this._customFetch = undefined;
|
|
18
18
|
this._customSendBeacon = undefined;
|
|
19
19
|
this.version = version || 'dev';
|
|
20
|
+
this._cmdRes = new Resolution();
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
get instances() {
|
|
@@ -27,6 +28,10 @@ class Root extends Component {
|
|
|
27
28
|
return this._clients[0] || this._any || (this._any = (await this._events.once('create')).data);
|
|
28
29
|
}
|
|
29
30
|
|
|
31
|
+
get cmdDone() {
|
|
32
|
+
return this._cmdRes.promise;
|
|
33
|
+
}
|
|
34
|
+
|
|
30
35
|
}
|
|
31
36
|
|
|
32
37
|
export const root = new Root();
|
|
@@ -34,7 +39,7 @@ export const root = new Root();
|
|
|
34
39
|
export function init(MisoClient) {
|
|
35
40
|
const pluginRoot = root._pluginRoot;
|
|
36
41
|
root.MisoClient = pluginRoot.MisoClient = MisoClient;
|
|
37
|
-
delegateGetters(MisoClient, root, ['version', 'instances', 'any', 'meta', 'on', 'once']);
|
|
42
|
+
delegateGetters(MisoClient, root, ['version', 'instances', 'any', 'meta', 'on', 'once', 'cmdDone']);
|
|
38
43
|
delegateGetters(MisoClient, pluginRoot, ['plugins']);
|
|
39
44
|
return MisoClient;
|
|
40
45
|
}
|
|
@@ -43,3 +48,7 @@ export function register(client) {
|
|
|
43
48
|
root._clients.push(client);
|
|
44
49
|
root._events.emit('create', client);
|
|
45
50
|
}
|
|
51
|
+
|
|
52
|
+
export function setCmdDone() {
|
|
53
|
+
root._cmdRes.resolve();
|
|
54
|
+
}
|
package/src/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '1.
|
|
1
|
+
export default '1.9.0-beta.0';
|