@miso.ai/client-sdk-ui 1.10.1-beta.1 → 1.10.2-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/layout/text/typewriter/index.js +1 -1
- package/dist/cjs/layout/text/typewriter/utils.js +33 -0
- package/dist/cjs/version.js +1 -1
- package/package.json +2 -2
- package/src/layout/text/typewriter/index.js +2 -2
- package/src/layout/text/typewriter/utils.js +27 -0
- package/src/version.js +1 -1
|
@@ -88,7 +88,7 @@ class TypewriterLayout extends _progressive.default {
|
|
|
88
88
|
cursorClass,
|
|
89
89
|
getSource: index => this._getSource(index),
|
|
90
90
|
onCitationLink,
|
|
91
|
-
onDebug
|
|
91
|
+
onDebug: (0, _utils.normalizeOnDebug)(onDebug)
|
|
92
92
|
});
|
|
93
93
|
// capture citation link click if necessary
|
|
94
94
|
this._unsubscribes.push(this._view.proxyElement.on('click', e => this._onClick(e)));
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.containerElement = containerElement;
|
|
7
7
|
exports.cursorClassName = cursorClassName;
|
|
8
8
|
exports.fromSameSession = fromSameSession;
|
|
9
|
+
exports.normalizeOnDebug = normalizeOnDebug;
|
|
9
10
|
var _constants = require("../../../constants.js");
|
|
10
11
|
function containerElement(layout, element, _ref) {
|
|
11
12
|
let {
|
|
@@ -46,4 +47,36 @@ function cursorClassName(className) {
|
|
|
46
47
|
}
|
|
47
48
|
function fromSameSession(a, b) {
|
|
48
49
|
return a && b && a.session && b.session && a.session.uuid === b.session.uuid;
|
|
50
|
+
}
|
|
51
|
+
function normalizeOnDebug(fn) {
|
|
52
|
+
if (fn === true) {
|
|
53
|
+
return defaultOnDebug();
|
|
54
|
+
}
|
|
55
|
+
if (!fn) {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
if (typeof fn === 'function') {
|
|
59
|
+
return fn;
|
|
60
|
+
}
|
|
61
|
+
throw new Error('onDebug must be a function or a boolean');
|
|
62
|
+
}
|
|
63
|
+
function defaultOnDebug() {
|
|
64
|
+
let start = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : performance.now();
|
|
65
|
+
return function (_ref2) {
|
|
66
|
+
let {
|
|
67
|
+
summary,
|
|
68
|
+
timestamp,
|
|
69
|
+
elapsed,
|
|
70
|
+
ref,
|
|
71
|
+
operation,
|
|
72
|
+
conflict
|
|
73
|
+
} = _ref2;
|
|
74
|
+
MisoClient.debug('<progressive-markdown>', `[${formatTimeInSeconds(timestamp - start)}](${formatTimeInMilliseconds(elapsed[0])}, ${formatTimeInMilliseconds(elapsed[1])})`, summary, `${operation}`, ref, conflict);
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function formatTimeInSeconds(t) {
|
|
78
|
+
return `${Math.floor(t) / 1000}s`;
|
|
79
|
+
}
|
|
80
|
+
function formatTimeInMilliseconds(t) {
|
|
81
|
+
return `${Math.floor(t * 100) / 100}ms`;
|
|
49
82
|
}
|
package/dist/cjs/version.js
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@ import { trimObj, defineValues, Resolution, pacer } from '@miso.ai/commons';
|
|
|
2
2
|
import { LAYOUT_CATEGORY, STATUS } from '../../../constants.js';
|
|
3
3
|
import ProgressiveLayout from '../../progressive.js';
|
|
4
4
|
import PlaintextRenderer from './plaintext.js';
|
|
5
|
-
import { containerElement, cursorClassName, fromSameSession } from './utils.js';
|
|
5
|
+
import { containerElement, cursorClassName, fromSameSession, normalizeOnDebug } from './utils.js';
|
|
6
6
|
|
|
7
7
|
const TYPE = 'typewriter';
|
|
8
8
|
const DEFAULT_CLASSNAME = 'miso-typewriter';
|
|
@@ -80,7 +80,7 @@ export default class TypewriterLayout extends ProgressiveLayout {
|
|
|
80
80
|
cursorClass,
|
|
81
81
|
getSource: index => this._getSource(index),
|
|
82
82
|
onCitationLink,
|
|
83
|
-
onDebug,
|
|
83
|
+
onDebug: normalizeOnDebug(onDebug),
|
|
84
84
|
});
|
|
85
85
|
// capture citation link click if necessary
|
|
86
86
|
this._unsubscribes.push(this._view.proxyElement.on('click', (e) => this._onClick(e)));
|
|
@@ -32,3 +32,30 @@ export function cursorClassName(className) {
|
|
|
32
32
|
export function fromSameSession(a, b) {
|
|
33
33
|
return a && b && a.session && b.session && a.session.uuid === b.session.uuid;
|
|
34
34
|
}
|
|
35
|
+
|
|
36
|
+
export function normalizeOnDebug(fn) {
|
|
37
|
+
if (fn === true) {
|
|
38
|
+
return defaultOnDebug();
|
|
39
|
+
}
|
|
40
|
+
if (!fn) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
if (typeof fn === 'function') {
|
|
44
|
+
return fn;
|
|
45
|
+
}
|
|
46
|
+
throw new Error('onDebug must be a function or a boolean');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function defaultOnDebug(start = performance.now()) {
|
|
50
|
+
return function({ summary, timestamp, elapsed, ref, operation, conflict }) {
|
|
51
|
+
MisoClient.debug('<progressive-markdown>', `[${formatTimeInSeconds(timestamp - start)}](${formatTimeInMilliseconds(elapsed[0])}, ${formatTimeInMilliseconds(elapsed[1])})`, summary, `${operation}`, ref, conflict);
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function formatTimeInSeconds(t) {
|
|
56
|
+
return `${Math.floor(t) / 1000}s`;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function formatTimeInMilliseconds(t) {
|
|
60
|
+
return `${Math.floor(t * 100) / 100}ms`;
|
|
61
|
+
}
|
package/src/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '1.10.
|
|
1
|
+
export default '1.10.2-beta.0';
|