|
|
|
var e=function(){return(e=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function t(e,t){void 0===t&&(t=!1);var n=function(){var e=new Int8Array(1);window.crypto.getRandomValues(e);var t=new Uint8Array(Math.max(16,Math.abs(e[0])));return window.crypto.getRandomValues(t),t.join("")}();return Object.defineProperty(window,n,{value:function(r){return t&&Reflect.deleteProperty(window,n),null==e?void 0:e(r)},writable:!1,configurable:!0}),n}function n(n,r){return void 0===r&&(r={}),function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{l(r.next(e))}catch(e){i(e)}}function c(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}l((r=r.apply(e,t||[])).next())}))}(this,void 0,void 0,(function(){return function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}(this,(function(o){return[2,new Promise((function(o,i){var a=t((function(e){o(e),Reflect.deleteProperty(window,c)}),!0),c=t((function(e){i(e),Reflect.deleteProperty(window,a)}),!0);window.rpc.notify(n,e({__invokeKey:__TAURI_INVOKE_KEY__,callback:a,error:c},r))}))]}))}))}Object.freeze({__proto__:null,transformCallback:t,invoke:n,convertFileSrc:function(e){return navigator.userAgent.includes("Windows")?"https://asset.localhost/"+e:"asset://"+e}});class r{constructor(e,t){this.id=e,this.listeners=t}static async connect(e,o){const i=[];return n("plugin:websocket|connect",{url:e,callbackFunction:t((e=>{i.forEach((t=>t(e)))})),options:o}).then((e=>new r(e,i)))}addListener(e){this.listeners.push(e)}send(e){let t;if("string"==typeof e)t={type:"Text",data:e};else if("object"==typeof e&&"type"in e)t=e;else{if(!Array.isArray(e))throw new Error("invalid `message` type, expected a `{ type: string, data: any }` object, a string or a numeric array");t={type:"Binary",data:e}}return n("plugin:websocket|send",{id:this.id,message:t})}disconnect(){return this.send({type:"Close",data:{code:1e3,reason:"Disconnected by client"}})}}export{r as default};
|
|
|
|
var e=function(){return(e=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function t(e,t){void 0===t&&(t=!1);var n=window.crypto.getRandomValues(new Uint32Array(1))[0],r="_".concat(n);return Object.defineProperty(window,r,{value:function(n){return t&&Reflect.deleteProperty(window,r),null==e?void 0:e(n)},writable:!1,configurable:!0}),n}function n(n,r){return void 0===r&&(r={}),function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{l(r.next(e))}catch(e){i(e)}}function c(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}l((r=r.apply(e,t||[])).next())}))}(this,void 0,void 0,(function(){return function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}(this,(function(o){return[2,new Promise((function(o,i){var a=t((function(e){o(e),Reflect.deleteProperty(window,c)}),!0),c=t((function(e){i(e),Reflect.deleteProperty(window,a)}),!0);window.__TAURI_IPC__(e({cmd:n,callback:a,error:c},r))}))]}))}))}Object.freeze({__proto__:null,transformCallback:t,invoke:n,convertFileSrc:function(e){return navigator.userAgent.includes("Windows")?"https://asset.localhost/".concat(e):"asset://".concat(e)}});class r{constructor(e,t){this.id=e,this.listeners=t}static async connect(e,o){const i=[];return n("plugin:websocket|connect",{url:e,callbackFunction:t((e=>{i.forEach((t=>t(e)))})),options:o}).then((e=>new r(e,i)))}addListener(e){this.listeners.push(e)}send(e){let t;if("string"==typeof e)t={type:"Text",data:e};else if("object"==typeof e&&"type"in e)t=e;else{if(!Array.isArray(e))throw new Error("invalid `message` type, expected a `{ type: string, data: any }` object, a string or a numeric array");t={type:"Binary",data:e}}return n("plugin:websocket|send",{id:this.id,message:t})}disconnect(){return this.send({type:"Close",data:{code:1e3,reason:"Disconnected by client"}})}}export{r as default};
|