@5minds/node-red-dashboard-2-processcube-audio-capture 0.1.8-develop-fd7f3c-mbq9beza → 0.1.8-develop-1bd22e-mdnreaeu
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@5minds/node-red-dashboard-2-processcube-audio-capture",
|
|
3
|
-
"version": "0.1.8-develop-
|
|
3
|
+
"version": "0.1.8-develop-1bd22e-mdnreaeu",
|
|
4
4
|
"description": "A node to capture audio and pass the audio data on in the flow",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node-red",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"widgets": {
|
|
66
66
|
"ui-audio-capture": {
|
|
67
67
|
"output": "ui-audio-capture.umd.js",
|
|
68
|
-
"component": "
|
|
68
|
+
"component": "UIAudioCapture"
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode("button[data-v-
|
|
2
|
-
(function(s,
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode("button[data-v-8b23056f]{padding:8px;border-style:solid;border-radius:4px}.ui-audio-capture[data-v-8b23056f]{display:flex;flex-direction:column;align-items:center;gap:10px;width:100%;padding:5px}")),document.head.appendChild(e)}}catch(d){console.error("vite-plugin-css-injected-by-js",d)}})();
|
|
2
|
+
(function(s,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],i):(s=typeof globalThis<"u"?globalThis:s||self,i(s["ui-audio-capture"]={},s.Vue))})(this,function(s,i){"use strict";const c=(e,t)=>{const d=e.__vccOpts||e;for(const[n,r]of t)d[n]=r;return d},u={name:"UIAudioCapture",inject:["$socket"],props:{id:{type:String,required:!0},props:{type:Object,default:()=>({})},state:{type:Object,default:()=>({enabled:!1,visible:!1})}},data(){return{isRecording:!1,mediaRecorder:null,audioCanBeSend:!1,audioChunks:[]}},mounted(){this.$socket.emit("widget-load",this.id)},unmounted(){var e;(e=this.$socket)==null||e.off("widget-load"+this.id)},computed:{start(){return this.props.start||"Start"},stop(){return this.props.stop||"Stop"},send(){return this.props.send||"Send"}},methods:{async toggleRecording(){this.isRecording?this.stopRecording():await this.startRecording()},async startRecording(){this.audioCanBeSend=!1;try{const e=await navigator.mediaDevices.getUserMedia({audio:!0});this.mediaRecorder=new MediaRecorder(e),this.mediaRecorder.ondataavailable=t=>{t.data.size>0&&this.audioChunks.push(t.data)},this.mediaRecorder.start(),this.isRecording=!0}catch(e){console.error("Error accessing microphone:",e)}},stopRecording(){this.audioCanBeSend=!0,this.mediaRecorder&&this.mediaRecorder.state!=="inactive"&&(this.mediaRecorder.stop(),this.mediaRecorder=null,this.isRecording=!1)},sendAudio(){this.audioCanBeSend=!1;const e=new Blob(this.audioChunks,{type:"audio/webm"}),t=new FileReader;t.onloadend=()=>{const d=t.result.split(",")[1];this.$socket.emit("handle-audio",this.id,{fileBase64:d,fileBlob:e,fileChunks:this.audioChunks}),this.audioChunks=[]},t.readAsDataURL(e)}}},l={class:"ui-audio-capture"};function p(e,t,d,n,r,o){return i.openBlock(),i.createElementBlock("div",l,[i.createElementVNode("button",{onClick:t[0]||(t[0]=(...a)=>o.toggleRecording&&o.toggleRecording(...a))},i.toDisplayString(r.isRecording?o.stop:o.start),1),r.audioCanBeSend?(i.openBlock(),i.createElementBlock("button",{key:0,onClick:t[1]||(t[1]=(...a)=>o.sendAudio&&o.sendAudio(...a))},i.toDisplayString(o.send),1)):i.createCommentVNode("",!0)])}const h=c(u,[["render",p],["__scopeId","data-v-8b23056f"]]);s.UIAudioCapture=h,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
<script>
|
|
9
9
|
export default {
|
|
10
|
-
name: '
|
|
10
|
+
name: 'UIAudioCapture',
|
|
11
11
|
inject: ['$socket'],
|
|
12
12
|
props: {
|
|
13
13
|
id: { type: String, required: true },
|
|
@@ -22,6 +22,12 @@ export default {
|
|
|
22
22
|
audioChunks: [],
|
|
23
23
|
};
|
|
24
24
|
},
|
|
25
|
+
mounted() {
|
|
26
|
+
this.$socket.emit('widget-load', this.id)
|
|
27
|
+
},
|
|
28
|
+
unmounted() {
|
|
29
|
+
this.$socket?.off('widget-load' + this.id)
|
|
30
|
+
},
|
|
25
31
|
computed: {
|
|
26
32
|
start() {
|
|
27
33
|
return this.props.start || 'Start';
|
package/ui/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* Exports of all of the components in this node */
|
|
2
|
-
export { default as
|
|
2
|
+
export { default as UIAudioCapture } from './components/UIAudioCapture.vue';
|
package/ui/main.js
CHANGED