@vunk/plus 1.3.11 → 1.3.12
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/components/SharedSystems.mjs +3195 -0
- package/components/WebGLRenderer.mjs +3617 -0
- package/components/WebGPURenderer.mjs +2103 -0
- package/components/_commonjsHelpers.mjs +7 -0
- package/components/agent-chat-provider/src/types.d.ts +2 -1
- package/components/broadcasting-markdown/index.d.ts +2 -0
- package/components/broadcasting-markdown/index.mjs +238 -306
- package/components/broadcasting-markdown/src/const.d.ts +2 -7
- package/components/broadcasting-markdown/src/ctx.d.ts +28 -15
- package/components/broadcasting-markdown/src/howler-speech.vue.d.ts +24 -44
- package/components/broadcasting-markdown/src/index.vue.d.ts +31 -167
- package/components/broadcasting-markdown/src/paragraph.vue.d.ts +1 -14
- package/components/broadcasting-markdown/src/types.d.ts +10 -2
- package/components/broadcasting-markdown/src/use.d.ts +18 -0
- package/components/browserAll.mjs +3187 -0
- package/components/bubble-list/index.mjs +2 -1
- package/components/bubble-list/src/index.vue.d.ts +27 -161
- package/components/bubble-templates/src/index.vue.d.ts +27 -161
- package/components/bubble-templates/src/types.d.ts +6 -0
- package/components/chat-independent/index.mjs +3 -0
- package/components/chat-independent/src/index.vue.d.ts +27 -161
- package/components/colorToUniform.mjs +266 -0
- package/components/index2.mjs +21227 -0
- package/components/init.mjs +3779 -0
- package/components/pixi-frame/index.css +4 -0
- package/components/pixi-frame/index.d.ts +7 -0
- package/components/pixi-frame/index.mjs +6 -0
- package/components/pixi-frame/src/app.vue.d.ts +29 -0
- package/components/pixi-frame/src/core.vue.d.ts +122 -0
- package/components/pixi-frame/src/ctx.d.ts +40 -0
- package/components/pixi-frame/src/index.vue.d.ts +218 -0
- package/components/pixi-frame/src/types.d.ts +1 -0
- package/components/pixi-frame/src/use.d.ts +3 -0
- package/components/tables-v1/src/ctx.d.ts +1 -1
- package/components/tables-v1/src/el-ctx.d.ts +1 -1
- package/components/tables-v1-checkbox/src/ctx.d.ts +1 -1
- package/components/tables-v1-checkbox/src/index.vue.d.ts +1 -1
- package/components/webworkerAll.mjs +8 -0
- package/index.css +5 -4
- package/package.json +8 -4
- package/components/broadcasting-markdown/index.css +0 -3
- package/components/broadcasting-markdown/src/custom-speech.vue.d.ts +0 -117
- package/components/broadcasting-markdown/src/web-speech.vue.d.ts +0 -110
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { VkTypingMarkdown } from '@vunk/plus/components/typing-markdown';
|
|
2
2
|
import { setData } from '@vunk/core';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { useDeferred, useDataComputed } from '@vunk/core/composables';
|
|
4
|
+
import { defineComponent, createElementBlock, openBlock, createElementVNode, Fragment, createVNode, unref, withCtx, shallowRef, computed, watch, onBeforeUnmount, watchEffect, onMounted, nextTick, renderSlot, createCommentVNode, ref, resolveComponent, renderList, createBlock } from 'vue';
|
|
5
|
+
import { TickerStatus } from '@vunk/shared/enum';
|
|
6
6
|
import { noop } from '@vunk/shared/function';
|
|
7
|
+
import { ElIcon } from 'element-plus';
|
|
8
|
+
import { c as commonjsGlobal } from '../_commonjsHelpers.mjs';
|
|
7
9
|
import { Deferred } from '@vunk/shared/promise';
|
|
8
10
|
import { c as consola } from '../browser.mjs';
|
|
9
11
|
import { _ as _export_sfc } from '../_plugin-vue_export-helper.mjs';
|
|
@@ -22,14 +24,7 @@ var ParagraphStatus = /* @__PURE__ */ ((ParagraphStatus2) => {
|
|
|
22
24
|
ParagraphStatus2["rejected"] = "rejected";
|
|
23
25
|
return ParagraphStatus2;
|
|
24
26
|
})(ParagraphStatus || {});
|
|
25
|
-
|
|
26
|
-
Broadcast2["initial"] = "initial";
|
|
27
|
-
Broadcast2["playing"] = "playing";
|
|
28
|
-
Broadcast2["ended"] = "ended";
|
|
29
|
-
Broadcast2["paused"] = "paused";
|
|
30
|
-
Broadcast2["failed"] = "failed";
|
|
31
|
-
return Broadcast2;
|
|
32
|
-
})(Broadcast || {});
|
|
27
|
+
const Broadcast = TickerStatus;
|
|
33
28
|
|
|
34
29
|
const props = {
|
|
35
30
|
/**
|
|
@@ -67,13 +62,6 @@ const props = {
|
|
|
67
62
|
type: Array,
|
|
68
63
|
default: () => ["\n\n", "\n"]
|
|
69
64
|
},
|
|
70
|
-
/**
|
|
71
|
-
* @description 暂停的
|
|
72
|
-
*/
|
|
73
|
-
pause: {
|
|
74
|
-
type: Boolean,
|
|
75
|
-
default: false
|
|
76
|
-
},
|
|
77
65
|
/**
|
|
78
66
|
* @description 组件内会根据当前游标是否和 source 长度一致来判断,是否持续阅读, 当一致时,会关闭阅读状态。但若设置为 true,则会持续阅读, 这在动态接收数据时会有用
|
|
79
67
|
*/
|
|
@@ -81,19 +69,19 @@ const props = {
|
|
|
81
69
|
type: Boolean,
|
|
82
70
|
default: false
|
|
83
71
|
},
|
|
84
|
-
/**
|
|
85
|
-
* @description 是否使用 web speech api
|
|
86
|
-
*/
|
|
87
|
-
webSpeech: {
|
|
88
|
-
type: Boolean,
|
|
89
|
-
default: false
|
|
90
|
-
},
|
|
91
72
|
/**
|
|
92
73
|
* @description 是否使用自定义语音合成
|
|
93
74
|
*/
|
|
94
75
|
textToSpeech: {
|
|
95
76
|
type: Function,
|
|
96
77
|
default: void 0
|
|
78
|
+
},
|
|
79
|
+
/**
|
|
80
|
+
* @description 段落处理函数
|
|
81
|
+
*/
|
|
82
|
+
processing: {
|
|
83
|
+
type: Function,
|
|
84
|
+
default: noop
|
|
97
85
|
}
|
|
98
86
|
};
|
|
99
87
|
const emits = {
|
|
@@ -101,10 +89,94 @@ const emits = {
|
|
|
101
89
|
"interrupt": null,
|
|
102
90
|
"update:broadcasting": (_) => true,
|
|
103
91
|
"update:completed": (_) => true,
|
|
104
|
-
"update:error": (_) => true
|
|
92
|
+
"update:error": (_) => true,
|
|
93
|
+
"paragraphLoad": (_) => true
|
|
94
|
+
};
|
|
95
|
+
const paragraphProps = {
|
|
96
|
+
data: {
|
|
97
|
+
type: Object,
|
|
98
|
+
default: () => ({})
|
|
99
|
+
},
|
|
100
|
+
deferred: {
|
|
101
|
+
type: Object,
|
|
102
|
+
required: true
|
|
103
|
+
},
|
|
104
|
+
render: {
|
|
105
|
+
type: Function,
|
|
106
|
+
default: defaultRender
|
|
107
|
+
}
|
|
105
108
|
};
|
|
109
|
+
const paragraphEmits = {
|
|
110
|
+
setData: (e) => e,
|
|
111
|
+
load: (_) => true
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
var ctx = /*#__PURE__*/Object.freeze({
|
|
115
|
+
__proto__: null,
|
|
116
|
+
emits: emits,
|
|
117
|
+
paragraphEmits: paragraphEmits,
|
|
118
|
+
paragraphProps: paragraphProps,
|
|
119
|
+
props: props
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
/*! Element Plus Icons Vue v2.3.1 */
|
|
106
123
|
|
|
107
|
-
var
|
|
124
|
+
var close_bold_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
125
|
+
name: "CloseBold",
|
|
126
|
+
__name: "close-bold",
|
|
127
|
+
setup(__props) {
|
|
128
|
+
return (_ctx, _cache) => (openBlock(), createElementBlock("svg", {
|
|
129
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
130
|
+
viewBox: "0 0 1024 1024"
|
|
131
|
+
}, [
|
|
132
|
+
createElementVNode("path", {
|
|
133
|
+
fill: "currentColor",
|
|
134
|
+
d: "M195.2 195.2a64 64 0 0 1 90.496 0L512 421.504 738.304 195.2a64 64 0 0 1 90.496 90.496L602.496 512 828.8 738.304a64 64 0 0 1-90.496 90.496L512 602.496 285.696 828.8a64 64 0 0 1-90.496-90.496L421.504 512 195.2 285.696a64 64 0 0 1 0-90.496z"
|
|
135
|
+
})
|
|
136
|
+
]));
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
// src/components/close-bold.vue
|
|
141
|
+
var close_bold_default = close_bold_vue_vue_type_script_setup_true_lang_default;
|
|
142
|
+
|
|
143
|
+
var _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
144
|
+
__name: "speech-error",
|
|
145
|
+
setup(__props) {
|
|
146
|
+
return (_ctx, _cache) => {
|
|
147
|
+
return openBlock(), createElementBlock(
|
|
148
|
+
Fragment,
|
|
149
|
+
null,
|
|
150
|
+
[
|
|
151
|
+
createVNode(unref(ElIcon), {
|
|
152
|
+
color: "var(--el-color-danger)",
|
|
153
|
+
size: "1.5em",
|
|
154
|
+
style: {
|
|
155
|
+
verticalAlign: "text-bottom"
|
|
156
|
+
}
|
|
157
|
+
}, {
|
|
158
|
+
default: withCtx(() => [
|
|
159
|
+
createVNode(unref(close_bold_default))
|
|
160
|
+
]),
|
|
161
|
+
_: 1
|
|
162
|
+
/* STABLE */
|
|
163
|
+
}),
|
|
164
|
+
_cache[0] || (_cache[0] = createElementVNode(
|
|
165
|
+
"span",
|
|
166
|
+
{ style: {
|
|
167
|
+
color: "var(--el-color-danger)"
|
|
168
|
+
} },
|
|
169
|
+
" \u64AD\u62A5\u5931\u8D25 ",
|
|
170
|
+
-1
|
|
171
|
+
/* HOISTED */
|
|
172
|
+
))
|
|
173
|
+
],
|
|
174
|
+
64
|
|
175
|
+
/* STABLE_FRAGMENT */
|
|
176
|
+
);
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
});
|
|
108
180
|
|
|
109
181
|
var howler = {};
|
|
110
182
|
|
|
@@ -3345,188 +3417,137 @@ var howler = {};
|
|
|
3345
3417
|
})();
|
|
3346
3418
|
} (howler));
|
|
3347
3419
|
|
|
3348
|
-
/*! Element Plus Icons Vue v2.3.1 */
|
|
3349
|
-
|
|
3350
|
-
var close_bold_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
3351
|
-
name: "CloseBold",
|
|
3352
|
-
__name: "close-bold",
|
|
3353
|
-
setup(__props) {
|
|
3354
|
-
return (_ctx, _cache) => (openBlock(), createElementBlock("svg", {
|
|
3355
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
3356
|
-
viewBox: "0 0 1024 1024"
|
|
3357
|
-
}, [
|
|
3358
|
-
createElementVNode("path", {
|
|
3359
|
-
fill: "currentColor",
|
|
3360
|
-
d: "M195.2 195.2a64 64 0 0 1 90.496 0L512 421.504 738.304 195.2a64 64 0 0 1 90.496 90.496L602.496 512 828.8 738.304a64 64 0 0 1-90.496 90.496L512 602.496 285.696 828.8a64 64 0 0 1-90.496-90.496L421.504 512 195.2 285.696a64 64 0 0 1 0-90.496z"
|
|
3361
|
-
})
|
|
3362
|
-
]));
|
|
3363
|
-
}
|
|
3364
|
-
});
|
|
3365
|
-
|
|
3366
|
-
// src/components/close-bold.vue
|
|
3367
|
-
var close_bold_default = close_bold_vue_vue_type_script_setup_true_lang_default;
|
|
3368
|
-
|
|
3369
|
-
var _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
3370
|
-
__name: "speech-error",
|
|
3371
|
-
setup(__props) {
|
|
3372
|
-
return (_ctx, _cache) => {
|
|
3373
|
-
return openBlock(), createElementBlock(
|
|
3374
|
-
Fragment,
|
|
3375
|
-
null,
|
|
3376
|
-
[
|
|
3377
|
-
createVNode(unref(ElIcon), {
|
|
3378
|
-
color: "var(--el-color-danger)",
|
|
3379
|
-
size: "1.5em",
|
|
3380
|
-
style: {
|
|
3381
|
-
verticalAlign: "text-bottom"
|
|
3382
|
-
}
|
|
3383
|
-
}, {
|
|
3384
|
-
default: withCtx(() => [
|
|
3385
|
-
createVNode(unref(close_bold_default))
|
|
3386
|
-
]),
|
|
3387
|
-
_: 1
|
|
3388
|
-
/* STABLE */
|
|
3389
|
-
}),
|
|
3390
|
-
_cache[0] || (_cache[0] = createElementVNode(
|
|
3391
|
-
"span",
|
|
3392
|
-
{ style: {
|
|
3393
|
-
color: "var(--el-color-danger)"
|
|
3394
|
-
} },
|
|
3395
|
-
" \u64AD\u62A5\u5931\u8D25 ",
|
|
3396
|
-
-1
|
|
3397
|
-
/* HOISTED */
|
|
3398
|
-
))
|
|
3399
|
-
],
|
|
3400
|
-
64
|
|
3401
|
-
/* STABLE_FRAGMENT */
|
|
3402
|
-
);
|
|
3403
|
-
};
|
|
3404
|
-
}
|
|
3405
|
-
});
|
|
3406
|
-
|
|
3407
3420
|
const originalPlay = howler.Howl.prototype.play;
|
|
3408
|
-
howler.Howl.prototype.play = function
|
|
3421
|
+
howler.Howl.prototype.play = function(soundId) {
|
|
3409
3422
|
const WeixinJSBridge = window.WeixinJSBridge;
|
|
3410
3423
|
WeixinJSBridge && WeixinJSBridge.invoke("getNetworkType", {}, () => {
|
|
3411
3424
|
originalPlay.call(this, soundId);
|
|
3412
3425
|
}, false);
|
|
3413
3426
|
return originalPlay.call(this, soundId);
|
|
3414
3427
|
};
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3428
|
+
function useHowlerParagraph(props, emit) {
|
|
3429
|
+
const sound = shallowRef(null);
|
|
3430
|
+
const createSound = (url2) => {
|
|
3431
|
+
if (!url2)
|
|
3432
|
+
return null;
|
|
3433
|
+
if (sound.value) {
|
|
3434
|
+
sound.value.unload();
|
|
3435
|
+
}
|
|
3436
|
+
return new howler.Howl({
|
|
3437
|
+
src: [url2],
|
|
3438
|
+
format: ["mp3", "wav", "aac"],
|
|
3439
|
+
// 事件处理
|
|
3440
|
+
onplay: () => {
|
|
3441
|
+
emit("setData", {
|
|
3442
|
+
k: "broadcast",
|
|
3443
|
+
v: Broadcast.playing
|
|
3444
|
+
});
|
|
3445
|
+
},
|
|
3446
|
+
onpause: () => {
|
|
3447
|
+
emit("setData", {
|
|
3448
|
+
k: "broadcast",
|
|
3449
|
+
v: Broadcast.paused
|
|
3450
|
+
});
|
|
3451
|
+
},
|
|
3452
|
+
onend: () => {
|
|
3453
|
+
emit("setData", {
|
|
3454
|
+
k: "broadcast",
|
|
3455
|
+
v: Broadcast.stopped
|
|
3456
|
+
});
|
|
3457
|
+
setTimeout(() => {
|
|
3458
|
+
if (sound.value) {
|
|
3459
|
+
sound.value.unload();
|
|
3460
|
+
sound.value = null;
|
|
3461
|
+
}
|
|
3462
|
+
}, 400);
|
|
3463
|
+
props.deferred.resolve(true);
|
|
3464
|
+
},
|
|
3465
|
+
onstop: () => {
|
|
3466
|
+
emit("setData", {
|
|
3467
|
+
k: "broadcast",
|
|
3468
|
+
v: Broadcast.stopped
|
|
3469
|
+
});
|
|
3470
|
+
},
|
|
3471
|
+
onloaderror: (_, error) => {
|
|
3472
|
+
emit("setData", {
|
|
3473
|
+
k: "broadcast",
|
|
3474
|
+
v: Broadcast.failed
|
|
3475
|
+
});
|
|
3476
|
+
props.deferred.reject(error);
|
|
3477
|
+
},
|
|
3478
|
+
onplayerror: (_, error) => {
|
|
3479
|
+
emit("setData", {
|
|
3480
|
+
k: "broadcast",
|
|
3481
|
+
v: Broadcast.failed
|
|
3482
|
+
});
|
|
3483
|
+
props.deferred.reject(error);
|
|
3484
|
+
}
|
|
3485
|
+
});
|
|
3486
|
+
};
|
|
3487
|
+
const url = computed(() => props.data.url);
|
|
3488
|
+
const broadcast = computed(() => props.data.broadcast);
|
|
3489
|
+
watch(() => url.value, (newUrl) => {
|
|
3490
|
+
if (newUrl) {
|
|
3491
|
+
sound.value = createSound(newUrl);
|
|
3492
|
+
}
|
|
3493
|
+
}, { immediate: true });
|
|
3494
|
+
onBeforeUnmount(() => {
|
|
3495
|
+
if (sound.value) {
|
|
3496
|
+
sound.value.unload();
|
|
3497
|
+
sound.value = null;
|
|
3442
3498
|
}
|
|
3499
|
+
});
|
|
3500
|
+
watchEffect(() => {
|
|
3501
|
+
if (broadcast.value === Broadcast.play) {
|
|
3502
|
+
sound.value?.play();
|
|
3503
|
+
} else if (broadcast.value === Broadcast.pause) {
|
|
3504
|
+
sound.value?.pause();
|
|
3505
|
+
} else if (broadcast.value === Broadcast.stop) {
|
|
3506
|
+
sound.value?.stop();
|
|
3507
|
+
}
|
|
3508
|
+
});
|
|
3509
|
+
return {
|
|
3510
|
+
url,
|
|
3511
|
+
broadcast,
|
|
3512
|
+
sound
|
|
3513
|
+
};
|
|
3514
|
+
}
|
|
3515
|
+
|
|
3516
|
+
var _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
3517
|
+
components: {
|
|
3518
|
+
SpeechError: _sfc_main$3
|
|
3443
3519
|
},
|
|
3444
|
-
|
|
3520
|
+
props: paragraphProps,
|
|
3521
|
+
emits: paragraphEmits,
|
|
3522
|
+
setup(props, {
|
|
3523
|
+
emit
|
|
3524
|
+
}) {
|
|
3445
3525
|
const value = props.render(props.data.value);
|
|
3446
3526
|
const theData = computed(() => props.data);
|
|
3447
3527
|
if (!value.trim()) {
|
|
3448
3528
|
props.deferred.resolve(true);
|
|
3449
|
-
|
|
3529
|
+
emit("setData", {
|
|
3530
|
+
k: "broadcast",
|
|
3531
|
+
v: Broadcast.stopped
|
|
3532
|
+
});
|
|
3450
3533
|
return () => null;
|
|
3451
3534
|
}
|
|
3452
|
-
|
|
3453
|
-
const createSound = url => {
|
|
3454
|
-
if (!url) return null;
|
|
3455
|
-
if (sound.value) {
|
|
3456
|
-
sound.value.unload();
|
|
3457
|
-
}
|
|
3458
|
-
return new howler.Howl({
|
|
3459
|
-
src: [url],
|
|
3460
|
-
format: ["mp3", "wav", "aac"],
|
|
3461
|
-
// 事件处理
|
|
3462
|
-
onplay: () => {
|
|
3463
|
-
theData.value.broadcast = Broadcast.playing;
|
|
3464
|
-
},
|
|
3465
|
-
onpause: () => {
|
|
3466
|
-
theData.value.broadcast = Broadcast.paused;
|
|
3467
|
-
},
|
|
3468
|
-
onend: () => {
|
|
3469
|
-
theData.value.broadcast = Broadcast.ended;
|
|
3470
|
-
setTimeout(() => {
|
|
3471
|
-
if (sound.value) {
|
|
3472
|
-
sound.value.unload();
|
|
3473
|
-
sound.value = null;
|
|
3474
|
-
}
|
|
3475
|
-
}, 400);
|
|
3476
|
-
props.deferred.resolve(true);
|
|
3477
|
-
},
|
|
3478
|
-
onloaderror: (_, error) => {
|
|
3479
|
-
theData.value.broadcast = Broadcast.failed;
|
|
3480
|
-
props.deferred.reject(error || new Error("Failed to load audio"));
|
|
3481
|
-
},
|
|
3482
|
-
onplayerror: (_, error) => {
|
|
3483
|
-
theData.value.broadcast = Broadcast.failed;
|
|
3484
|
-
console.error("Failed to play audio", error);
|
|
3485
|
-
props.deferred.reject(error || new Error("Failed to play audio"));
|
|
3486
|
-
}
|
|
3487
|
-
});
|
|
3488
|
-
};
|
|
3489
|
-
watch(() => props.url, newUrl => {
|
|
3490
|
-
if (newUrl) {
|
|
3491
|
-
sound.value = createSound(newUrl);
|
|
3492
|
-
}
|
|
3493
|
-
}, {
|
|
3494
|
-
immediate: true
|
|
3495
|
-
});
|
|
3535
|
+
useHowlerParagraph(props, emit);
|
|
3496
3536
|
onMounted(() => {
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
if (theData.value.broadcast === Broadcast.failed || theData.value.broadcast === Broadcast.initial) {
|
|
3505
|
-
if (sound.value) {
|
|
3506
|
-
sound.value.play();
|
|
3507
|
-
}
|
|
3508
|
-
} else if (theData.value.broadcast === Broadcast.paused) {
|
|
3509
|
-
if (sound.value) {
|
|
3510
|
-
sound.value.play();
|
|
3511
|
-
}
|
|
3512
|
-
}
|
|
3513
|
-
}
|
|
3514
|
-
}
|
|
3515
|
-
}, {
|
|
3516
|
-
immediate: true
|
|
3537
|
+
emit("setData", {
|
|
3538
|
+
k: "broadcast",
|
|
3539
|
+
v: Broadcast.play
|
|
3540
|
+
});
|
|
3541
|
+
emit("load", {
|
|
3542
|
+
data: props.data,
|
|
3543
|
+
deferred: props.deferred
|
|
3517
3544
|
});
|
|
3518
3545
|
});
|
|
3519
|
-
|
|
3520
|
-
if (sound.value) {
|
|
3521
|
-
sound.value.unload();
|
|
3522
|
-
sound.value = null;
|
|
3523
|
-
}
|
|
3524
|
-
});
|
|
3525
|
-
return () => createVNode(Fragment, null, [theData.value.status === ParagraphStatus.rejected && createVNode(_sfc_main$4, null, null)]);
|
|
3546
|
+
return () => createVNode(Fragment, null, [theData.value.status === ParagraphStatus.rejected && createVNode(_sfc_main$3, null, null)]);
|
|
3526
3547
|
}
|
|
3527
3548
|
});
|
|
3528
3549
|
|
|
3529
|
-
var _sfc_main$
|
|
3550
|
+
var _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
3530
3551
|
__name: "paragraph",
|
|
3531
3552
|
props: {
|
|
3532
3553
|
enable: {
|
|
@@ -3537,10 +3558,6 @@ var _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
3537
3558
|
type: String,
|
|
3538
3559
|
default: ParagraphStatus.initial
|
|
3539
3560
|
},
|
|
3540
|
-
pause: {
|
|
3541
|
-
type: Boolean,
|
|
3542
|
-
default: false
|
|
3543
|
-
},
|
|
3544
3561
|
processing: {
|
|
3545
3562
|
type: Function,
|
|
3546
3563
|
default: noop
|
|
@@ -3603,106 +3620,19 @@ var _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
3603
3620
|
}
|
|
3604
3621
|
});
|
|
3605
3622
|
|
|
3606
|
-
var _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
3607
|
-
components: {
|
|
3608
|
-
SpeechError: _sfc_main$4
|
|
3609
|
-
},
|
|
3610
|
-
props: {
|
|
3611
|
-
voice: {
|
|
3612
|
-
type: null,
|
|
3613
|
-
required: false
|
|
3614
|
-
},
|
|
3615
|
-
data: {
|
|
3616
|
-
type: Object,
|
|
3617
|
-
default: () => ({})
|
|
3618
|
-
},
|
|
3619
|
-
deferred: {
|
|
3620
|
-
type: Object,
|
|
3621
|
-
required: true
|
|
3622
|
-
},
|
|
3623
|
-
pause: {
|
|
3624
|
-
type: Boolean,
|
|
3625
|
-
default: false
|
|
3626
|
-
},
|
|
3627
|
-
render: {
|
|
3628
|
-
type: Function,
|
|
3629
|
-
required: true
|
|
3630
|
-
}
|
|
3631
|
-
},
|
|
3632
|
-
setup(props) {
|
|
3633
|
-
const value = props.render(props.data.value);
|
|
3634
|
-
const theData = computed(() => props.data);
|
|
3635
|
-
if (!value.trim()) {
|
|
3636
|
-
props.deferred.resolve(true);
|
|
3637
|
-
theData.value.broadcast = Broadcast.ended;
|
|
3638
|
-
return () => null;
|
|
3639
|
-
}
|
|
3640
|
-
const utterThis = new SpeechSynthesisUtterance(value);
|
|
3641
|
-
utterThis.onend = function () {
|
|
3642
|
-
props.deferred.resolve(true);
|
|
3643
|
-
theData.value.broadcast = Broadcast.ended;
|
|
3644
|
-
};
|
|
3645
|
-
utterThis.onstart = function () {
|
|
3646
|
-
if (props.pause) return;
|
|
3647
|
-
theData.value.broadcast = Broadcast.playing;
|
|
3648
|
-
};
|
|
3649
|
-
utterThis.onerror = function (err) {
|
|
3650
|
-
props.deferred.reject(err);
|
|
3651
|
-
theData.value.broadcast = Broadcast.failed;
|
|
3652
|
-
window.speechSynthesis.cancel();
|
|
3653
|
-
};
|
|
3654
|
-
props.voice && (utterThis.voice = props.voice);
|
|
3655
|
-
watch(() => props.pause, v => {
|
|
3656
|
-
if (props.data.status === ParagraphStatus.pending) {
|
|
3657
|
-
if (v) {
|
|
3658
|
-
window.speechSynthesis.pause();
|
|
3659
|
-
if (theData.value.broadcast === Broadcast.playing) {
|
|
3660
|
-
theData.value.broadcast = Broadcast.paused;
|
|
3661
|
-
}
|
|
3662
|
-
} else {
|
|
3663
|
-
window.speechSynthesis.resume();
|
|
3664
|
-
if (theData.value.broadcast === Broadcast.failed || theData.value.broadcast === Broadcast.initial) {
|
|
3665
|
-
if (props.data.start === 0) {
|
|
3666
|
-
window.speechSynthesis.cancel();
|
|
3667
|
-
}
|
|
3668
|
-
console.log("start speaking");
|
|
3669
|
-
window.speechSynthesis.speak(utterThis);
|
|
3670
|
-
}
|
|
3671
|
-
if (theData.value.broadcast === Broadcast.paused) {
|
|
3672
|
-
theData.value.broadcast = Broadcast.playing;
|
|
3673
|
-
}
|
|
3674
|
-
}
|
|
3675
|
-
}
|
|
3676
|
-
}, {
|
|
3677
|
-
immediate: true
|
|
3678
|
-
});
|
|
3679
|
-
return () => theData.value.status === ParagraphStatus.rejected && createVNode(_sfc_main$4, null, null);
|
|
3680
|
-
}
|
|
3681
|
-
});
|
|
3682
|
-
|
|
3683
3623
|
var _sfc_main = defineComponent({
|
|
3684
3624
|
name: "VkBroadcastingMarkdown",
|
|
3685
3625
|
components: {
|
|
3686
|
-
ParagraphView: _sfc_main$
|
|
3626
|
+
ParagraphView: _sfc_main$1,
|
|
3687
3627
|
VkTypingMarkdown,
|
|
3688
|
-
|
|
3689
|
-
// CustomSpeechView,
|
|
3690
|
-
HowlerSpeechView: _sfc_main$3
|
|
3628
|
+
HowlerSpeechView: _sfc_main$2
|
|
3691
3629
|
},
|
|
3692
3630
|
props,
|
|
3693
3631
|
emits,
|
|
3694
3632
|
setup(props2, { emit, expose }) {
|
|
3695
|
-
const
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
});
|
|
3699
|
-
const handleSetData = (e) => {
|
|
3700
|
-
if (props2.data === void 0) {
|
|
3701
|
-
setData(_data.value, e);
|
|
3702
|
-
return;
|
|
3703
|
-
}
|
|
3704
|
-
emit("setData", e);
|
|
3705
|
-
};
|
|
3633
|
+
const [theData, handleSetData] = useDataComputed({
|
|
3634
|
+
default: []
|
|
3635
|
+
}, props2, emit);
|
|
3706
3636
|
const addParagraph = (paragraph) => {
|
|
3707
3637
|
const k = theData.value.length;
|
|
3708
3638
|
handleSetData({
|
|
@@ -3720,6 +3650,8 @@ var _sfc_main = defineComponent({
|
|
|
3720
3650
|
}
|
|
3721
3651
|
return props2.textToSpeech(`${value}`).then((url) => {
|
|
3722
3652
|
paragraph.url = url;
|
|
3653
|
+
}).then(async () => {
|
|
3654
|
+
await props2.processing?.(paragraph);
|
|
3723
3655
|
});
|
|
3724
3656
|
};
|
|
3725
3657
|
const currentIndex = ref(0);
|
|
@@ -3736,7 +3668,7 @@ var _sfc_main = defineComponent({
|
|
|
3736
3668
|
if (theData.value[0].broadcast === Broadcast.failed) {
|
|
3737
3669
|
return "";
|
|
3738
3670
|
}
|
|
3739
|
-
if (theData.value[0].broadcast === Broadcast.
|
|
3671
|
+
if (theData.value[0].broadcast === Broadcast.pending) {
|
|
3740
3672
|
return "......";
|
|
3741
3673
|
}
|
|
3742
3674
|
return theData.value.filter(
|
|
@@ -3782,7 +3714,7 @@ var _sfc_main = defineComponent({
|
|
|
3782
3714
|
end,
|
|
3783
3715
|
status: ParagraphStatus.initial,
|
|
3784
3716
|
value,
|
|
3785
|
-
broadcast: Broadcast.
|
|
3717
|
+
broadcast: Broadcast.pending
|
|
3786
3718
|
};
|
|
3787
3719
|
addParagraph(paragraph);
|
|
3788
3720
|
}
|
|
@@ -3816,20 +3748,25 @@ var _sfc_main = defineComponent({
|
|
|
3816
3748
|
end,
|
|
3817
3749
|
status: ParagraphStatus.initial,
|
|
3818
3750
|
value,
|
|
3819
|
-
broadcast: Broadcast.
|
|
3751
|
+
broadcast: Broadcast.pending
|
|
3820
3752
|
};
|
|
3821
3753
|
addParagraph(paragraph);
|
|
3822
3754
|
}
|
|
3823
3755
|
}
|
|
3824
3756
|
}
|
|
3825
3757
|
const isInterrupted = ref(false);
|
|
3826
|
-
const thePause = computed(() => {
|
|
3827
|
-
return isInterrupted.value || props2.pause;
|
|
3828
|
-
});
|
|
3829
3758
|
function interrupt() {
|
|
3830
3759
|
isInterrupted.value = true;
|
|
3760
|
+
theData.value.forEach((item) => {
|
|
3761
|
+
item.broadcast = Broadcast.stop;
|
|
3762
|
+
});
|
|
3831
3763
|
emit("interrupt");
|
|
3832
3764
|
}
|
|
3765
|
+
const isPaused = computed(() => {
|
|
3766
|
+
return theData.value.some(
|
|
3767
|
+
(item) => item.status === ParagraphStatus.pending && item.broadcast === Broadcast.paused
|
|
3768
|
+
);
|
|
3769
|
+
});
|
|
3833
3770
|
const isBroadcasting = computed(() => {
|
|
3834
3771
|
return theData.value.some(
|
|
3835
3772
|
(item) => item.broadcast === Broadcast.playing
|
|
@@ -3873,7 +3810,10 @@ var _sfc_main = defineComponent({
|
|
|
3873
3810
|
isPrevParagraphFulfilled,
|
|
3874
3811
|
isParagraphEnabled,
|
|
3875
3812
|
processingParagraph,
|
|
3876
|
-
|
|
3813
|
+
isInterrupted,
|
|
3814
|
+
setData,
|
|
3815
|
+
Broadcast,
|
|
3816
|
+
isPaused
|
|
3877
3817
|
};
|
|
3878
3818
|
}
|
|
3879
3819
|
});
|
|
@@ -3881,7 +3821,6 @@ var _sfc_main = defineComponent({
|
|
|
3881
3821
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
3882
3822
|
const _component_VkTypingMarkdown = resolveComponent("VkTypingMarkdown");
|
|
3883
3823
|
const _component_HowlerSpeechView = resolveComponent("HowlerSpeechView");
|
|
3884
|
-
const _component_WebSpeechView = resolveComponent("WebSpeechView");
|
|
3885
3824
|
const _component_ParagraphView = resolveComponent("ParagraphView");
|
|
3886
3825
|
return openBlock(), createElementBlock(
|
|
3887
3826
|
Fragment,
|
|
@@ -3890,8 +3829,8 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3890
3829
|
renderSlot(_ctx.$slots, "default", { paragraphs: _ctx.theData }, () => [
|
|
3891
3830
|
createVNode(_component_VkTypingMarkdown, {
|
|
3892
3831
|
source: _ctx.fulfilledTextValue,
|
|
3893
|
-
delay:
|
|
3894
|
-
pause: _ctx.
|
|
3832
|
+
delay: 120,
|
|
3833
|
+
pause: _ctx.isInterrupted || _ctx.isPaused
|
|
3895
3834
|
}, null, 8, ["source", "pause"])
|
|
3896
3835
|
]),
|
|
3897
3836
|
(openBlock(true), createElementBlock(
|
|
@@ -3912,18 +3851,11 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
3912
3851
|
}, () => [
|
|
3913
3852
|
createVNode(_component_HowlerSpeechView, {
|
|
3914
3853
|
render: _ctx.render,
|
|
3915
|
-
url: item.url,
|
|
3916
|
-
pause: _ctx.thePause,
|
|
3917
|
-
deferred,
|
|
3918
|
-
data: item
|
|
3919
|
-
}, null, 8, ["render", "url", "pause", "deferred", "data"]),
|
|
3920
|
-
_ctx.webSpeech ? (openBlock(), createBlock(_component_WebSpeechView, {
|
|
3921
|
-
key: 0,
|
|
3922
|
-
render: _ctx.render,
|
|
3923
|
-
pause: _ctx.thePause,
|
|
3924
3854
|
deferred,
|
|
3925
|
-
data: item
|
|
3926
|
-
|
|
3855
|
+
data: item,
|
|
3856
|
+
onSetData: ($event) => _ctx.setData(item, $event),
|
|
3857
|
+
onLoad: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("paragraphLoad", $event))
|
|
3858
|
+
}, null, 8, ["render", "deferred", "data", "onSetData"])
|
|
3927
3859
|
])
|
|
3928
3860
|
]),
|
|
3929
3861
|
_: 2
|
|
@@ -3948,4 +3880,4 @@ VkBroadcastingMarkdown.install = (app) => {
|
|
|
3948
3880
|
app.component(VkBroadcastingMarkdown.name || "VkBroadcastingMarkdown", VkBroadcastingMarkdown);
|
|
3949
3881
|
};
|
|
3950
3882
|
|
|
3951
|
-
export { Broadcast, ParagraphStatus, VkBroadcastingMarkdown, types as __VkBroadcastingMarkdown, VkBroadcastingMarkdown as default, defaultRender };
|
|
3883
|
+
export { Broadcast, ParagraphStatus, VkBroadcastingMarkdown, ctx as _VkBroadcastingMarkdownCtx, types as __VkBroadcastingMarkdown, VkBroadcastingMarkdown as default, defaultRender, useHowlerParagraph };
|