@miso.ai/client-sdk-dev-tool 1.13.0 → 1.13.1-beta.1

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/lorem.js CHANGED
@@ -4,18 +4,30 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ var _commons = require("@miso.ai/commons");
8
+ var _lorem = require("@miso.ai/lorem");
7
9
  var _api = _interopRequireDefault(require("@miso.ai/doggoganger/src/api.js"));
8
10
  var _fetch = _interopRequireDefault(require("@miso.ai/doggoganger/src/fetch.js"));
11
+ const _excluded = ["seed"];
9
12
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
+ 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; }
10
14
  const PLUGIN_ID = 'std:lorem';
11
15
  class LoremPlugin {
12
16
  static get id() {
13
17
  return PLUGIN_ID;
14
18
  }
15
19
  constructor() {
20
+ this._lorem = (0, _lorem.lorem)();
16
21
  this._api = (0, _api.default)();
17
22
  }
18
- config(options = {}) {
23
+ config(_ref = {}) {
24
+ let {
25
+ seed
26
+ } = _ref,
27
+ options = _objectWithoutPropertiesLoose(_ref, _excluded);
28
+ this._lorem = (0, _lorem.lorem)({
29
+ seed
30
+ });
19
31
  this._api = (0, _api.default)(options);
20
32
  }
21
33
  get api() {
@@ -29,7 +41,9 @@ class LoremPlugin {
29
41
  MisoClient.lorem = new Lorem(this);
30
42
  setCustomFetch(this._fetch.bind(this));
31
43
  setCustomSendBeacon(this._sendBeacon.bind(this));
32
- interceptDummyLinkClick();
44
+ if (_commons.isInBrowser) {
45
+ interceptDummyLinkClick();
46
+ }
33
47
  }
34
48
  _bypassApiKeyCheck(MisoClient) {
35
49
  const _normalizeOptions = MisoClient.prototype._normalizeOptions;
@@ -43,7 +57,10 @@ class LoremPlugin {
43
57
  };
44
58
  }
45
59
  _fetch(url, options) {
46
- return (0, _fetch.default)(this._api, url, options);
60
+ const seed = this._lorem.prng.seed();
61
+ return (0, _fetch.default)(this._api, url, Object.assign({
62
+ seed
63
+ }, options));
47
64
  }
48
65
  _sendBeacon(/*url, data*/
49
66
  ) {
@@ -59,6 +76,10 @@ class Lorem {
59
76
  return this._plugin.api;
60
77
  }
61
78
  }
79
+
80
+ /**
81
+ * [browser only]
82
+ */
62
83
  function interceptDummyLinkClick() {
63
84
  document.addEventListener('click', e => {
64
85
  if (e.isDefaultPrevented) {
package/package.json CHANGED
@@ -30,8 +30,9 @@
30
30
  "url": "https://github.com/MisoAI/miso-client-js-sdk/issues"
31
31
  },
32
32
  "dependencies": {
33
- "@miso.ai/commons": "1.13.0",
34
- "@miso.ai/doggoganger": "^0.10.0-beta.0"
33
+ "@miso.ai/commons": "1.13.1-beta.1",
34
+ "@miso.ai/doggoganger": "^0.10.0-beta.0",
35
+ "@miso.ai/lorem": "^0.10.0-beta.0"
35
36
  },
36
- "version": "1.13.0"
37
+ "version": "1.13.1-beta.1"
37
38
  }
package/src/lorem.js CHANGED
@@ -1,3 +1,5 @@
1
+ import { isInBrowser } from '@miso.ai/commons';
2
+ import { lorem } from '@miso.ai/lorem';
1
3
  import buildApi from '@miso.ai/doggoganger/src/api.js';
2
4
  import fetch from '@miso.ai/doggoganger/src/fetch.js';
3
5
 
@@ -10,10 +12,12 @@ export default class LoremPlugin {
10
12
  }
11
13
 
12
14
  constructor() {
15
+ this._lorem = lorem();
13
16
  this._api = buildApi();
14
17
  }
15
18
 
16
- config(options = {}) {
19
+ config({ seed, ...options } = {}) {
20
+ this._lorem = lorem({ seed });
17
21
  this._api = buildApi(options);
18
22
  }
19
23
 
@@ -26,7 +30,9 @@ export default class LoremPlugin {
26
30
  MisoClient.lorem = new Lorem(this);
27
31
  setCustomFetch(this._fetch.bind(this));
28
32
  setCustomSendBeacon(this._sendBeacon.bind(this));
29
- interceptDummyLinkClick();
33
+ if (isInBrowser) {
34
+ interceptDummyLinkClick();
35
+ }
30
36
  }
31
37
 
32
38
  _bypassApiKeyCheck(MisoClient) {
@@ -40,7 +46,8 @@ export default class LoremPlugin {
40
46
  }
41
47
 
42
48
  _fetch(url, options) {
43
- return fetch(this._api, url, options);
49
+ const seed = this._lorem.prng.seed();
50
+ return fetch(this._api, url, { seed, ...options });
44
51
  }
45
52
 
46
53
  _sendBeacon(/*url, data*/) {
@@ -61,6 +68,9 @@ class Lorem {
61
68
 
62
69
  }
63
70
 
71
+ /**
72
+ * [browser only]
73
+ */
64
74
  function interceptDummyLinkClick() {
65
75
  document.addEventListener('click', (e) => {
66
76
  if (e.isDefaultPrevented) {