@miso.ai/client-sdk-dev-tool 1.7.6 → 1.8.0-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/debug.js +64 -41
- package/dist/es/debug.js +63 -40
- package/package.json +2 -2
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
|
-
|
|
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._log(...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
|
|
95
|
+
this._log(...args);
|
|
121
96
|
}
|
|
122
97
|
_handlePluginsEvent(eventName, plugin) {
|
|
123
|
-
|
|
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,48 @@ class DebugPlugin {
|
|
|
132
112
|
}
|
|
133
113
|
return path.reverse();
|
|
134
114
|
}
|
|
115
|
+
_log(path, name) {
|
|
116
|
+
const options = this._options.console || {};
|
|
117
|
+
for (var _len = arguments.length, data = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
118
|
+
data[_key - 2] = arguments[_key];
|
|
119
|
+
}
|
|
120
|
+
console.log(_tag(options), _style(options), _path(path), _name(name), ...data);
|
|
121
|
+
}
|
|
122
|
+
_logw(path, name, data) {
|
|
123
|
+
if (data === undefined) {
|
|
124
|
+
this._log(path, name);
|
|
125
|
+
} else if (Array.isArray(data)) {
|
|
126
|
+
this._log(path, name, ...data.map(_wrapObj));
|
|
127
|
+
} else {
|
|
128
|
+
this._log(path, name, _wrapObj(data));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
exports.default = DebugPlugin;
|
|
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}]`;
|
|
135
155
|
}
|
|
136
|
-
|
|
156
|
+
function _wrapObj(value) {
|
|
157
|
+
const type = typeof value;
|
|
158
|
+
return type === 'function' || type === 'object' && !Array.isArray(value) ? [value] : value;
|
|
159
|
+
}
|
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
|
-
|
|
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._log(...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
|
|
89
|
+
this._log(...args);
|
|
115
90
|
}
|
|
116
91
|
_handlePluginsEvent(eventName, plugin) {
|
|
117
|
-
|
|
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,47 @@ export default class DebugPlugin {
|
|
|
126
106
|
}
|
|
127
107
|
return path.reverse();
|
|
128
108
|
}
|
|
109
|
+
_log(path, name) {
|
|
110
|
+
const options = this._options.console || {};
|
|
111
|
+
for (var _len = arguments.length, data = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
112
|
+
data[_key - 2] = arguments[_key];
|
|
113
|
+
}
|
|
114
|
+
console.log(_tag(options), _style(options), _path(path), _name(name), ...data);
|
|
115
|
+
}
|
|
116
|
+
_logw(path, name, data) {
|
|
117
|
+
if (data === undefined) {
|
|
118
|
+
this._log(path, name);
|
|
119
|
+
} else if (Array.isArray(data)) {
|
|
120
|
+
this._log(path, name, ...data.map(_wrapObj));
|
|
121
|
+
} else {
|
|
122
|
+
this._log(path, name, _wrapObj(data));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
function _tag() {
|
|
127
|
+
let {
|
|
128
|
+
text = 'Miso'
|
|
129
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
130
|
+
return `%c${text}`;
|
|
131
|
+
}
|
|
132
|
+
function _style() {
|
|
133
|
+
let {
|
|
134
|
+
color = '#fff',
|
|
135
|
+
background = '#334cbb'
|
|
136
|
+
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
137
|
+
return `color: ${color}; background-color: ${background}; padding: 2px 2px 1px 4px;`;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// format path
|
|
141
|
+
function _path(path) {
|
|
142
|
+
return `<${typeof path === 'string' ? path : path.filter(v => v).join('/')}>`;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// format event name
|
|
146
|
+
function _name(name) {
|
|
147
|
+
return `[${name}]`;
|
|
148
|
+
}
|
|
149
|
+
function _wrapObj(value) {
|
|
150
|
+
const type = typeof value;
|
|
151
|
+
return type === 'function' || type === 'object' && !Array.isArray(value) ? [value] : value;
|
|
129
152
|
}
|