@innovastudio/contentbuilder 1.4.82 → 1.4.83

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@innovastudio/contentbuilder",
3
3
  "type": "module",
4
- "version": "1.4.82",
4
+ "version": "1.4.83",
5
5
  "description": "",
6
6
  "main": "public/contentbuilder/contentbuilder.esm.js",
7
7
  "files": [
@@ -55,6 +55,7 @@
55
55
  "cropperjs": "^1.5.12",
56
56
  "js-beautify": "^1.14.0",
57
57
  "moveable": "^0.30.0",
58
+ "opus-recorder": "^8.0.5",
58
59
  "rangy": "^1.3.0",
59
60
  "socket.io-client": "^4.7.1",
60
61
  "sortablejs": "^1.14.0",
@@ -1,5 +1,9 @@
1
1
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
2
2
 
3
+ function getDefaultExportFromCjs (x) {
4
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
5
+ }
6
+
3
7
  var rangyCore = {exports: {}};
4
8
 
5
9
  /**
@@ -77394,7 +77398,13 @@ class Lib {
77394
77398
  }
77395
77399
  }
77396
77400
 
77397
- // import RecordRTC from 'recordrtc';
77401
+ var recorder_min = {exports: {}};
77402
+
77403
+ (function (module, exports) {
77404
+ !function(e,t){module.exports=t();}("undefined"!=typeof self?self:commonjsGlobal,(function(){return function(e){var t={};function o(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,o),i.l=!0,i.exports}return o.m=e,o.c=t,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n});},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0});},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)o.d(n,i,function(t){return e[t]}.bind(null,i));return n},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=0)}([function(e,t,o){(function(t){function o(e,t){if(null==e)return {};var o,n,i=function(e,t){if(null==e)return {};var o,n,i={},r=Object.keys(e);for(n=0;n<r.length;n++)o=r[n],t.indexOf(o)>=0||(i[o]=e[o]);return i}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(n=0;n<r.length;n++)o=r[n],t.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(i[o]=e[o]);}return i}var n=t.AudioContext||t.webkitAudioContext,i=function e(){var t=this,o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!e.isRecordingSupported())throw new Error("Recording is not supported in this browser");this.state="inactive",this.config=Object.assign({bufferLength:4096,encoderApplication:2049,encoderFrameSize:20,encoderPath:"encoderWorker.min.js",encoderSampleRate:48e3,maxFramesPerPage:40,mediaTrackConstraints:!0,monitorGain:0,numberOfChannels:1,recordingGain:1,resampleQuality:3,streamPages:!1,wavBitDepth:16,sourceNode:{context:null}},o),this.encodedSamplePosition=0,this.initAudioContext(),this.initialize=this.initWorklet().then((function(){return t.initEncoder()}));};i.isRecordingSupported=function(){var e=t.navigator&&t.navigator.mediaDevices&&t.navigator.mediaDevices.getUserMedia;return n&&e&&t.WebAssembly},i.version="8.0.5",i.prototype.clearStream=function(){this.stream&&(this.stream.getTracks?this.stream.getTracks().forEach((function(e){return e.stop()})):this.stream.stop());},i.prototype.close=function(){return this.monitorGainNode.disconnect(),this.recordingGainNode.disconnect(),this.sourceNode&&this.sourceNode.disconnect(),this.clearStream(),this.encoder&&(this.encoderNode.disconnect(),this.encoder.postMessage({command:"close"})),this.config.sourceNode.context?Promise.resolve():this.audioContext.close()},i.prototype.encodeBuffers=function(e){if("recording"===this.state){for(var t=[],o=0;o<e.numberOfChannels;o++)t[o]=e.getChannelData(o);this.encoder.postMessage({command:"encode",buffers:t});}},i.prototype.initAudioContext=function(){this.audioContext=this.config.sourceNode.context?this.config.sourceNode.context:new n,this.monitorGainNode=this.audioContext.createGain(),this.setMonitorGain(this.config.monitorGain),this.recordingGainNode=this.audioContext.createGain(),this.setRecordingGain(this.config.recordingGain);},i.prototype.initEncoder=function(){var e=this;this.audioContext.audioWorklet?(this.encoderNode=new AudioWorkletNode(this.audioContext,"encoder-worklet",{numberOfOutputs:0}),this.encoder=this.encoderNode.port):(console.log("audioWorklet support not detected. Falling back to scriptProcessor"),this.encodeBuffers=function(){return delete e.encodeBuffers},this.encoderNode=this.audioContext.createScriptProcessor(this.config.bufferLength,this.config.numberOfChannels,this.config.numberOfChannels),this.encoderNode.onaudioprocess=function(t){var o=t.inputBuffer;return e.encodeBuffers(o)},this.encoderNode.connect(this.audioContext.destination),this.encoder=new t.Worker(this.config.encoderPath));},i.prototype.initSourceNode=function(){var e=this;return this.config.sourceNode.context?(this.sourceNode=this.config.sourceNode,Promise.resolve()):t.navigator.mediaDevices.getUserMedia({audio:this.config.mediaTrackConstraints}).then((function(t){e.stream=t,e.sourceNode=e.audioContext.createMediaStreamSource(t);}))},i.prototype.initWorker=function(){var e=this,t=(this.config.streamPages?this.streamPage:this.storePage).bind(this);return this.recordedPages=[],this.totalLength=0,new Promise((function(n){e.encoder.addEventListener("message",(function o(i){var r=i.data;switch(r.message){case"ready":n();break;case"page":e.encodedSamplePosition=r.samplePosition,t(r.page);break;case"done":e.encoder.removeEventListener("message",o),e.finish();}})),e.encoder.start&&e.encoder.start();var i=e.config,r=(i.sourceNode,o(i,["sourceNode"]));e.encoder.postMessage(Object.assign({command:"init",originalSampleRate:e.audioContext.sampleRate,wavSampleRate:e.audioContext.sampleRate},r));}))},i.prototype.initWorklet=function(){return this.audioContext.audioWorklet?this.audioContext.audioWorklet.addModule(this.config.encoderPath):Promise.resolve()},i.prototype.pause=function(e){var t=this;if("recording"===this.state)return this.state="paused",this.recordingGainNode.disconnect(),e&&this.config.streamPages?new Promise((function(e){t.encoder.addEventListener("message",(function o(n){"flushed"===n.data.message&&(t.encoder.removeEventListener("message",o),t.onpause(),e());})),t.encoder.start&&t.encoder.start(),t.encoder.postMessage({command:"flush"});})):(this.onpause(),Promise.resolve())},i.prototype.resume=function(){"paused"===this.state&&(this.state="recording",this.recordingGainNode.connect(this.encoderNode),this.onresume());},i.prototype.setRecordingGain=function(e){this.config.recordingGain=e,this.recordingGainNode&&this.audioContext&&this.recordingGainNode.gain.setTargetAtTime(e,this.audioContext.currentTime,.01);},i.prototype.setMonitorGain=function(e){this.config.monitorGain=e,this.monitorGainNode&&this.audioContext&&this.monitorGainNode.gain.setTargetAtTime(e,this.audioContext.currentTime,.01);},i.prototype.start=function(){var e=this;return "inactive"===this.state?(this.state="loading",this.encodedSamplePosition=0,this.audioContext.resume().then((function(){return e.initialize})).then((function(){return Promise.all([e.initSourceNode(),e.initWorker()])})).then((function(){e.state="recording",e.encoder.postMessage({command:"getHeaderPages"}),e.sourceNode.connect(e.monitorGainNode),e.sourceNode.connect(e.recordingGainNode),e.monitorGainNode.connect(e.audioContext.destination),e.recordingGainNode.connect(e.encoderNode),e.onstart();})).catch((function(t){throw e.state="inactive",t}))):Promise.resolve()},i.prototype.stop=function(){var e=this;return "paused"===this.state||"recording"===this.state?(this.state="inactive",this.recordingGainNode.connect(this.encoderNode),this.monitorGainNode.disconnect(),this.clearStream(),new Promise((function(t){e.encoder.addEventListener("message",(function o(n){"done"===n.data.message&&(e.encoder.removeEventListener("message",o),t());})),e.encoder.start&&e.encoder.start(),e.encoder.postMessage({command:"done"});}))):Promise.resolve()},i.prototype.storePage=function(e){this.recordedPages.push(e),this.totalLength+=e.length;},i.prototype.streamPage=function(e){this.ondataavailable(e);},i.prototype.finish=function(){if(!this.config.streamPages){var e=new Uint8Array(this.totalLength);this.recordedPages.reduce((function(t,o){return e.set(o,t),t+o.length}),0),this.ondataavailable(e);}this.onstop();},i.prototype.ondataavailable=function(){},i.prototype.onpause=function(){},i.prototype.onresume=function(){},i.prototype.onstart=function(){},i.prototype.onstop=function(){},e.exports=i;}).call(this,o(1));},function(e,t){var o;o=function(){return this}();try{o=o||new Function("return this")();}catch(e){"object"==typeof window&&(o=window);}e.exports=o;}])}));
77405
+ }(recorder_min));
77406
+
77407
+ var Recorder = /*@__PURE__*/getDefaultExportFromCjs(recorder_min.exports);
77398
77408
 
77399
77409
  const dom = new Dom();
77400
77410
  class Dictation {
@@ -77829,10 +77839,16 @@ class Dictation {
77829
77839
  // track.stop();
77830
77840
  // });
77831
77841
 
77832
- // Using mediaRecorder
77833
- if (this.mediaRecorder && this.mediaRecorder.state !== 'inactive') {
77834
- this.mediaRecorder.stop();
77835
- this.localStream.getTracks().forEach(track => track.stop()); // Stop the tracks to release the resources
77842
+ if (this.builder.useMediaRecorder) {
77843
+ // Using mediaRecorder
77844
+ if (this.mediaRecorder && this.mediaRecorder.state !== 'inactive') {
77845
+ this.mediaRecorder.stop();
77846
+ this.localStream.getTracks().forEach(track => track.stop()); // Stop the tracks to release the resources
77847
+ }
77848
+ } else {
77849
+ // Using Recorder
77850
+ if (this.recorder) this.recorder.stop();
77851
+ if (this.localStream) this.localStream.getTracks().forEach(track => track.stop()); // Stop the tracks to release the resources
77836
77852
  }
77837
77853
 
77838
77854
  if (this.websocket && this.websocket.readyState === WebSocket.OPEN) {
@@ -77882,30 +77898,46 @@ class Dictation {
77882
77898
  return;
77883
77899
  }
77884
77900
  const sampleRate = 16000;
77901
+ if (this.builder.useMediaRecorder) {
77902
+ // Using mediaRecorder
77903
+ navigator.mediaDevices.getUserMedia({
77904
+ audio: {
77905
+ sampleSize: 16,
77906
+ channelCount: 1,
77907
+ sampleRate: sampleRate
77908
+ }
77909
+ }).then(stream => {
77910
+ this.localStream = stream;
77911
+ this.mediaRecorder = new MediaRecorder(stream);
77912
+ this.mediaRecorder.addEventListener('dataavailable', event => {
77913
+ if (this.aborted) return;
77914
+
77915
+ // console.log(event.data);
77916
+ // if (event.data.size > 0) {
77917
+ // }
77918
+ this.websocket.send(event.data);
77919
+ });
77885
77920
 
77886
- // Using mediaRecorder
77887
- navigator.mediaDevices.getUserMedia({
77888
- audio: {
77889
- sampleSize: 16,
77890
- channelCount: 1,
77891
- sampleRate: sampleRate
77892
- }
77893
- }).then(stream => {
77894
- this.localStream = stream;
77895
- this.mediaRecorder = new MediaRecorder(stream);
77896
- this.mediaRecorder.addEventListener('dataavailable', event => {
77897
- if (this.aborted) return;
77898
-
77899
- // console.log(event.data);
77900
- // if (event.data.size > 0) {
77901
- // }
77902
- this.websocket.send(event.data);
77921
+ // this.mediaRecorder.start(1000);
77922
+ }).catch(error => {
77923
+ console.log(error);
77903
77924
  });
77904
-
77905
- // this.mediaRecorder.start(1000);
77906
- }).catch(error => {
77907
- console.log(error);
77908
- });
77925
+ } else {
77926
+ // Using Recorder
77927
+ this.recorder = new Recorder({
77928
+ encoderPath: 'https://cdnjs.cloudflare.com/ajax/libs/opus-recorder/8.0.5/encoderWorker.min.js',
77929
+ leaveStreamOpen: true,
77930
+ numberOfChannels: 1,
77931
+ // OPUS options
77932
+ encoderSampleRate: sampleRate,
77933
+ streamPages: true,
77934
+ maxBuffersPerPage: 1
77935
+ });
77936
+ this.recorder.ondataavailable = e => {
77937
+ if (this.aborted) return;
77938
+ this.websocket.send(e.buffer);
77939
+ };
77940
+ }
77909
77941
 
77910
77942
  /*
77911
77943
  // Using RecordRTC
@@ -77939,7 +77971,11 @@ class Dictation {
77939
77971
  if (message.event === 'can-open-mic') {
77940
77972
  //this.recorder.startRecording(); // Using RecordRTC
77941
77973
 
77942
- this.mediaRecorder.start(1000); // Using mediaRecorder
77974
+ if (this.builder.useMediaRecorder) {
77975
+ this.mediaRecorder.start(1000); // Using mediaRecorder
77976
+ } else {
77977
+ this.recorder.start(); // Using Recorder
77978
+ }
77943
77979
 
77944
77980
  // console.log('Start Dictation');
77945
77981
  this.aborted = false;
@@ -78782,6 +78818,7 @@ class ContentBuilder {
78782
78818
  commandPlaceholderText: '',
78783
78819
  enableShortCommands: true,
78784
78820
  speechRecognitionLang: 'en-US',
78821
+ useMediaRecorder: false,
78785
78822
  headlineList: ['We create simple and effective designs.', 'Ultimate Experiences With Story, Emotion, And Purpose.', 'Build Anything Beautifully', 'With Less Stuff and More Compassion', 'We\'re [CompanyName]. Full stack development with a spark of creativity.', 'Transforming your digital experience with [CompanyName]. Achieve your online goals with our customized solutions.', 'Revolutionizing web development with [CompanyName]. Unleash your digital potential with our high-performance solutions.', 'Creative and Inspiring'],
78786
78823
  shortCommandList: {
78787
78824
  undo: ['undo'],