@micromag/screen-conversation 0.3.401 → 0.3.403
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/es/index.js +8 -10
- package/lib/index.js +8 -10
- package/package.json +13 -13
package/es/index.js
CHANGED
|
@@ -385,7 +385,7 @@ var ConversationScreen = function ConversationScreen(_ref) {
|
|
|
385
385
|
}, [conversationState, setConversationState]);
|
|
386
386
|
|
|
387
387
|
// sequence timings
|
|
388
|
-
var defaultHesitationDelay =
|
|
388
|
+
var defaultHesitationDelay = 1500;
|
|
389
389
|
var imageReadDelay = 5000; // 5 seconds
|
|
390
390
|
var millisecondsPerWord = 60 * 1000 / readingSpeed;
|
|
391
391
|
var filteredMessages = (messages || []).filter(function (m) {
|
|
@@ -394,9 +394,11 @@ var ConversationScreen = function ConversationScreen(_ref) {
|
|
|
394
394
|
var timings = filteredMessages.map(function (messageParams, messageI) {
|
|
395
395
|
var _ref3 = messageParams || {},
|
|
396
396
|
_ref3$timing = _ref3.timing,
|
|
397
|
-
timing = _ref3$timing === void 0 ? null : _ref3$timing
|
|
398
|
-
_ref3.message
|
|
399
|
-
|
|
397
|
+
timing = _ref3$timing === void 0 ? null : _ref3$timing,
|
|
398
|
+
_ref3$message = _ref3.message,
|
|
399
|
+
message = _ref3$message === void 0 ? null : _ref3$message,
|
|
400
|
+
image = _ref3.image,
|
|
401
|
+
audio = _ref3.audio;
|
|
400
402
|
if (timing !== null) {
|
|
401
403
|
return timing;
|
|
402
404
|
}
|
|
@@ -409,16 +411,12 @@ var ConversationScreen = function ConversationScreen(_ref) {
|
|
|
409
411
|
return audio.metadata.duration;
|
|
410
412
|
}
|
|
411
413
|
|
|
412
|
-
// the trick here is to estimate "how long it take to read the previous message"
|
|
413
|
-
// instead of "how long does it take to write this message".
|
|
414
|
-
var previous = filteredMessages[messageI - 1];
|
|
415
|
-
|
|
416
414
|
// counting words: only keep whitespaces and alphanumeric characters, then split of whitespaces
|
|
417
|
-
var wordCount =
|
|
415
|
+
var wordCount = message ? message.replace(/[^\w\d\s]/g, '').trim().split(/\s/g).length : 0;
|
|
418
416
|
var finalTimeMs = wordCount * millisecondsPerWord;
|
|
419
417
|
|
|
420
418
|
// if the message includes an image, add some more time to "read" it
|
|
421
|
-
if (
|
|
419
|
+
if (image) {
|
|
422
420
|
finalTimeMs += imageReadDelay;
|
|
423
421
|
}
|
|
424
422
|
return finalTimeMs;
|
package/lib/index.js
CHANGED
|
@@ -409,7 +409,7 @@ var ConversationScreen = function ConversationScreen(_ref) {
|
|
|
409
409
|
}, [conversationState, setConversationState]);
|
|
410
410
|
|
|
411
411
|
// sequence timings
|
|
412
|
-
var defaultHesitationDelay =
|
|
412
|
+
var defaultHesitationDelay = 1500;
|
|
413
413
|
var imageReadDelay = 5000; // 5 seconds
|
|
414
414
|
var millisecondsPerWord = 60 * 1000 / readingSpeed;
|
|
415
415
|
var filteredMessages = (messages || []).filter(function (m) {
|
|
@@ -418,9 +418,11 @@ var ConversationScreen = function ConversationScreen(_ref) {
|
|
|
418
418
|
var timings = filteredMessages.map(function (messageParams, messageI) {
|
|
419
419
|
var _ref3 = messageParams || {},
|
|
420
420
|
_ref3$timing = _ref3.timing,
|
|
421
|
-
timing = _ref3$timing === void 0 ? null : _ref3$timing
|
|
422
|
-
_ref3.message
|
|
423
|
-
|
|
421
|
+
timing = _ref3$timing === void 0 ? null : _ref3$timing,
|
|
422
|
+
_ref3$message = _ref3.message,
|
|
423
|
+
message = _ref3$message === void 0 ? null : _ref3$message,
|
|
424
|
+
image = _ref3.image,
|
|
425
|
+
audio = _ref3.audio;
|
|
424
426
|
if (timing !== null) {
|
|
425
427
|
return timing;
|
|
426
428
|
}
|
|
@@ -433,16 +435,12 @@ var ConversationScreen = function ConversationScreen(_ref) {
|
|
|
433
435
|
return audio.metadata.duration;
|
|
434
436
|
}
|
|
435
437
|
|
|
436
|
-
// the trick here is to estimate "how long it take to read the previous message"
|
|
437
|
-
// instead of "how long does it take to write this message".
|
|
438
|
-
var previous = filteredMessages[messageI - 1];
|
|
439
|
-
|
|
440
438
|
// counting words: only keep whitespaces and alphanumeric characters, then split of whitespaces
|
|
441
|
-
var wordCount =
|
|
439
|
+
var wordCount = message ? message.replace(/[^\w\d\s]/g, '').trim().split(/\s/g).length : 0;
|
|
442
440
|
var finalTimeMs = wordCount * millisecondsPerWord;
|
|
443
441
|
|
|
444
442
|
// if the message includes an image, add some more time to "read" it
|
|
445
|
-
if (
|
|
443
|
+
if (image) {
|
|
446
444
|
finalTimeMs += imageReadDelay;
|
|
447
445
|
}
|
|
448
446
|
return finalTimeMs;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/screen-conversation",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.403",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
@@ -50,17 +50,17 @@
|
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@babel/runtime": "^7.13.10",
|
|
53
|
-
"@micromag/core": "^0.3.
|
|
54
|
-
"@micromag/element-background": "^0.3.
|
|
55
|
-
"@micromag/element-container": "^0.3.
|
|
56
|
-
"@micromag/element-footer": "^0.3.
|
|
57
|
-
"@micromag/element-header": "^0.3.
|
|
58
|
-
"@micromag/element-heading": "^0.3.
|
|
59
|
-
"@micromag/element-layout": "^0.3.
|
|
60
|
-
"@micromag/element-scroll": "^0.3.
|
|
61
|
-
"@micromag/element-text": "^0.3.
|
|
62
|
-
"@micromag/element-visual": "^0.3.
|
|
63
|
-
"@micromag/transforms": "^0.3.
|
|
53
|
+
"@micromag/core": "^0.3.403",
|
|
54
|
+
"@micromag/element-background": "^0.3.403",
|
|
55
|
+
"@micromag/element-container": "^0.3.403",
|
|
56
|
+
"@micromag/element-footer": "^0.3.403",
|
|
57
|
+
"@micromag/element-header": "^0.3.403",
|
|
58
|
+
"@micromag/element-heading": "^0.3.403",
|
|
59
|
+
"@micromag/element-layout": "^0.3.403",
|
|
60
|
+
"@micromag/element-scroll": "^0.3.403",
|
|
61
|
+
"@micromag/element-text": "^0.3.403",
|
|
62
|
+
"@micromag/element-visual": "^0.3.403",
|
|
63
|
+
"@micromag/transforms": "^0.3.403",
|
|
64
64
|
"classnames": "^2.2.6",
|
|
65
65
|
"lodash": "^4.17.21",
|
|
66
66
|
"prop-types": "^15.7.2",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"access": "public",
|
|
72
72
|
"registry": "https://registry.npmjs.org/"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "3179202a6bd721978ed10d9282b904045770189b"
|
|
75
75
|
}
|