@miso.ai/client-sdk-dev-tool 1.8.0-beta.0 → 1.8.0-beta.11

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/debug.js CHANGED
@@ -6,50 +6,25 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  const _excluded = ["groupName", "apiName", "url", "bulk"];
8
8
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
9
- const TAG = '%cMiso';
10
- const STYLE = 'color: #fff; background-color: #334cbb; padding: 2px 2px 1px 4px;';
11
9
  const ID = 'std:debug';
12
- const _log = function (path, name) {
13
- for (var _len = arguments.length, data = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
14
- data[_key - 2] = arguments[_key];
15
- }
16
- return console.log(TAG, STYLE, _path(path), _name(name), ...data);
17
- };
18
- function _logw(path, name, data) {
19
- if (data === undefined) {
20
- _log(path, name);
21
- } else if (Array.isArray(data)) {
22
- _log(path, name, ...data.map(_wrapObj));
23
- } else {
24
- _log(path, name, _wrapObj(data));
25
- }
26
- }
27
-
28
- // format path
29
- function _path(path) {
30
- return `<${typeof path === 'string' ? path : path.filter(v => v).join('/')}>`;
31
- }
32
-
33
- // format event name
34
- function _name(name) {
35
- return `[${name}]`;
36
- }
37
- function _wrapObj(value) {
38
- const type = typeof value;
39
- return type === 'function' || type === 'object' && !Array.isArray(value) ? [value] : value;
40
- }
41
10
  class DebugPlugin {
42
11
  constructor() {
43
- this._log = console.log.bind(console, TAG, STYLE);
12
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
13
+ this._options = options;
44
14
  }
45
15
  static get id() {
46
16
  return ID;
47
17
  }
48
-
49
- // TODO: config({ active })
50
-
51
18
  install(MisoClient) {
19
+ var _this = this;
52
20
  this._injectComponents(MisoClient);
21
+ MisoClient.debug = function () {
22
+ return _this._logr(...arguments);
23
+ };
24
+ }
25
+ config() {
26
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
27
+ this._options = Object.assign({}, this._options, options);
53
28
  }
54
29
  _injectComponents(component) {
55
30
  let treePath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
@@ -91,10 +66,10 @@ class DebugPlugin {
91
66
  }
92
67
  return;
93
68
  }
94
- _logw(path.join('.'), name, data);
69
+ this._logw(path.join('.'), name, data);
95
70
  }
96
71
  _handleCreateClient(eventName, data) {
97
- _logw('client', eventName, data);
72
+ this._logw('client', eventName, data);
98
73
  }
99
74
  _handleApiEvent(eventName, _ref2) {
100
75
  let {
@@ -117,13 +92,18 @@ class DebugPlugin {
117
92
  args.push([Object.assign({}, data, {
118
93
  url
119
94
  })]);
120
- _log.apply(undefined, args);
95
+ this._log(...args);
121
96
  }
122
97
  _handlePluginsEvent(eventName, plugin) {
123
- _log('plugins', eventName, `${plugin.id || '(anonymous)'}`, [plugin]);
98
+ let data = [];
99
+ if (Array.isArray(plugin)) {
100
+ data = plugin.slice(1);
101
+ plugin = plugin[0];
102
+ }
103
+ this._log('plugins', eventName, `${plugin.id || '(anonymous)'}`, [plugin, ...data]);
124
104
  }
125
105
  _handlePluginSpecificEvent(pluginId, path, name, data) {
126
- _logw([pluginId, path.join('.')], name, data);
106
+ this._logw([pluginId, path.join('.')], name, data);
127
107
  }
128
108
  _getPath(component) {
129
109
  const path = [];
@@ -132,5 +112,55 @@ class DebugPlugin {
132
112
  }
133
113
  return path.reverse();
134
114
  }
115
+ _logr() {
116
+ const options = this._options.console || {};
117
+ for (var _len = arguments.length, data = new Array(_len), _key = 0; _key < _len; _key++) {
118
+ data[_key] = arguments[_key];
119
+ }
120
+ console.log(_tag(options), _style(options), ...data);
121
+ }
122
+ _log(path, name) {
123
+ const options = this._options.console || {};
124
+ for (var _len2 = arguments.length, data = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
125
+ data[_key2 - 2] = arguments[_key2];
126
+ }
127
+ console.log(_tag(options), _style(options), _path(path), _name(name), ...data);
128
+ }
129
+ _logw(path, name, data) {
130
+ if (data === undefined) {
131
+ this._log(path, name);
132
+ } else if (Array.isArray(data)) {
133
+ this._log(path, name, ...data.map(_wrapObj));
134
+ } else {
135
+ this._log(path, name, _wrapObj(data));
136
+ }
137
+ }
135
138
  }
136
- exports.default = DebugPlugin;
139
+ exports.default = DebugPlugin;
140
+ function _tag() {
141
+ let {
142
+ text = 'Miso'
143
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
144
+ return `%c${text}`;
145
+ }
146
+ function _style() {
147
+ let {
148
+ color = '#fff',
149
+ background = '#334cbb'
150
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
151
+ return `color: ${color}; background-color: ${background}; padding: 2px 2px 1px 4px;`;
152
+ }
153
+
154
+ // format path
155
+ function _path(path) {
156
+ return `<${typeof path === 'string' ? path : path.filter(v => v).join('/')}>`;
157
+ }
158
+
159
+ // format event name
160
+ function _name(name) {
161
+ return `[${name}]`;
162
+ }
163
+ function _wrapObj(value) {
164
+ const type = typeof value;
165
+ return type === 'function' || type === 'object' && !Array.isArray(value) ? [value] : value;
166
+ }
package/dist/es/debug.js CHANGED
@@ -1,49 +1,24 @@
1
1
  const _excluded = ["groupName", "apiName", "url", "bulk"];
2
2
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
3
- const TAG = '%cMiso';
4
- const STYLE = 'color: #fff; background-color: #334cbb; padding: 2px 2px 1px 4px;';
5
3
  const ID = 'std:debug';
6
- const _log = function (path, name) {
7
- for (var _len = arguments.length, data = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
8
- data[_key - 2] = arguments[_key];
9
- }
10
- return console.log(TAG, STYLE, _path(path), _name(name), ...data);
11
- };
12
- function _logw(path, name, data) {
13
- if (data === undefined) {
14
- _log(path, name);
15
- } else if (Array.isArray(data)) {
16
- _log(path, name, ...data.map(_wrapObj));
17
- } else {
18
- _log(path, name, _wrapObj(data));
19
- }
20
- }
21
-
22
- // format path
23
- function _path(path) {
24
- return `<${typeof path === 'string' ? path : path.filter(v => v).join('/')}>`;
25
- }
26
-
27
- // format event name
28
- function _name(name) {
29
- return `[${name}]`;
30
- }
31
- function _wrapObj(value) {
32
- const type = typeof value;
33
- return type === 'function' || type === 'object' && !Array.isArray(value) ? [value] : value;
34
- }
35
4
  export default class DebugPlugin {
36
5
  constructor() {
37
- this._log = console.log.bind(console, TAG, STYLE);
6
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
7
+ this._options = options;
38
8
  }
39
9
  static get id() {
40
10
  return ID;
41
11
  }
42
-
43
- // TODO: config({ active })
44
-
45
12
  install(MisoClient) {
13
+ var _this = this;
46
14
  this._injectComponents(MisoClient);
15
+ MisoClient.debug = function () {
16
+ return _this._logr(...arguments);
17
+ };
18
+ }
19
+ config() {
20
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
21
+ this._options = Object.assign({}, this._options, options);
47
22
  }
48
23
  _injectComponents(component) {
49
24
  let treePath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
@@ -85,10 +60,10 @@ export default class DebugPlugin {
85
60
  }
86
61
  return;
87
62
  }
88
- _logw(path.join('.'), name, data);
63
+ this._logw(path.join('.'), name, data);
89
64
  }
90
65
  _handleCreateClient(eventName, data) {
91
- _logw('client', eventName, data);
66
+ this._logw('client', eventName, data);
92
67
  }
93
68
  _handleApiEvent(eventName, _ref2) {
94
69
  let {
@@ -111,13 +86,18 @@ export default class DebugPlugin {
111
86
  args.push([Object.assign({}, data, {
112
87
  url
113
88
  })]);
114
- _log.apply(undefined, args);
89
+ this._log(...args);
115
90
  }
116
91
  _handlePluginsEvent(eventName, plugin) {
117
- _log('plugins', eventName, `${plugin.id || '(anonymous)'}`, [plugin]);
92
+ let data = [];
93
+ if (Array.isArray(plugin)) {
94
+ data = plugin.slice(1);
95
+ plugin = plugin[0];
96
+ }
97
+ this._log('plugins', eventName, `${plugin.id || '(anonymous)'}`, [plugin, ...data]);
118
98
  }
119
99
  _handlePluginSpecificEvent(pluginId, path, name, data) {
120
- _logw([pluginId, path.join('.')], name, data);
100
+ this._logw([pluginId, path.join('.')], name, data);
121
101
  }
122
102
  _getPath(component) {
123
103
  const path = [];
@@ -126,4 +106,54 @@ export default class DebugPlugin {
126
106
  }
127
107
  return path.reverse();
128
108
  }
109
+ _logr() {
110
+ const options = this._options.console || {};
111
+ for (var _len = arguments.length, data = new Array(_len), _key = 0; _key < _len; _key++) {
112
+ data[_key] = arguments[_key];
113
+ }
114
+ console.log(_tag(options), _style(options), ...data);
115
+ }
116
+ _log(path, name) {
117
+ const options = this._options.console || {};
118
+ for (var _len2 = arguments.length, data = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
119
+ data[_key2 - 2] = arguments[_key2];
120
+ }
121
+ console.log(_tag(options), _style(options), _path(path), _name(name), ...data);
122
+ }
123
+ _logw(path, name, data) {
124
+ if (data === undefined) {
125
+ this._log(path, name);
126
+ } else if (Array.isArray(data)) {
127
+ this._log(path, name, ...data.map(_wrapObj));
128
+ } else {
129
+ this._log(path, name, _wrapObj(data));
130
+ }
131
+ }
132
+ }
133
+ function _tag() {
134
+ let {
135
+ text = 'Miso'
136
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
137
+ return `%c${text}`;
138
+ }
139
+ function _style() {
140
+ let {
141
+ color = '#fff',
142
+ background = '#334cbb'
143
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
144
+ return `color: ${color}; background-color: ${background}; padding: 2px 2px 1px 4px;`;
145
+ }
146
+
147
+ // format path
148
+ function _path(path) {
149
+ return `<${typeof path === 'string' ? path : path.filter(v => v).join('/')}>`;
150
+ }
151
+
152
+ // format event name
153
+ function _name(name) {
154
+ return `[${name}]`;
155
+ }
156
+ function _wrapObj(value) {
157
+ const type = typeof value;
158
+ return type === 'function' || type === 'object' && !Array.isArray(value) ? [value] : value;
129
159
  }
package/package.json CHANGED
@@ -26,7 +26,7 @@
26
26
  "url": "https://github.com/MisoAI/miso-client-js-sdk/issues"
27
27
  },
28
28
  "dependencies": {
29
- "@miso.ai/commons": "1.8.0-beta.0"
29
+ "@miso.ai/commons": "1.8.0-beta.11"
30
30
  },
31
- "version": "1.8.0-beta.0"
31
+ "version": "1.8.0-beta.11"
32
32
  }