asai-js-as 0.2.7 → 0.2.8

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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/index.js +1 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -14,7 +14,7 @@
14
14
 
15
15
  ```typescript
16
16
  // monorepo — webclient/src/App.vue
17
- import AsaiJsAs from './plugs/asai-js-as/AsaiJsAs.ts';
17
+ import AsaiJsAs from './plugs/asai-js-as/AsaiJsAs';
18
18
  // npm
19
19
  // import AsaiJsAs from '@estun/asai-js-as';
20
20
 
package/index.js CHANGED
@@ -1 +1 @@
1
- (()=>{"use strict";var e={995:function(e,t,i){var n=this&&this.__assign||function(){n=Object.assign||function(e){for(var t,i=1,n=arguments.length;i<n;i++){t=arguments[i];for(var o in t)if(Object.prototype.hasOwnProperty.call(t,o))e[o]=t[o]}return e};return n.apply(this,arguments)};var o=this&&this.__awaiter||function(e,t,i,n){function adopt(e){return e instanceof i?e:new i((function(t){t(e)}))}return new(i||(i=Promise))((function(i,o){function fulfilled(e){try{step(n.next(e))}catch(e){o(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){o(e)}}function step(e){e.done?i(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())}))};var s=this&&this.__generator||function(e,t){var i={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,o,s,r=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return r.next=verb(0),r["throw"]=verb(1),r["return"]=verb(2),typeof Symbol==="function"&&(r[Symbol.iterator]=function(){return this}),r;function verb(e){return function(t){return step([e,t])}}function step(a){if(n)throw new TypeError("Generator is already executing.");while(r&&(r=0,a[0]&&(i=0)),i)try{if(n=1,o&&(s=a[0]&2?o["return"]:a[0]?o["throw"]||((s=o["return"])&&s.call(o),0):o.next)&&!(s=s.call(o,a[1])).done)return s;if(o=0,s)a=[a[0]&2,s.value];switch(a[0]){case 0:case 1:s=a;break;case 4:i.label++;return{value:a[1],done:false};case 5:i.label++;o=a[1];a=[0];continue;case 7:a=i.ops.pop();i.trys.pop();continue;default:if(!(s=i.trys,s=s.length>0&&s[s.length-1])&&(a[0]===6||a[0]===2)){i=0;continue}if(a[0]===3&&(!s||a[1]>s[0]&&a[1]<s[3])){i.label=a[1];break}if(a[0]===6&&i.label<s[1]){i.label=s[1];s=a;break}if(s&&i.label<s[2]){i.label=s[2];i.ops.push(a);break}if(s[2])i.ops.pop();i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e];o=0}finally{n=s=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};Object.defineProperty(t,"__esModule",{value:true});t.AsaiApi=void 0;var r=i(992);var a=function(){function AsaiApi(e){if(e===void 0){e={}}this.interceptors={request:[],response:[]};this.defaultConfig={headers:{"Content-Type":"application/json"},cache:"reload",timeout:1e4};this.totalApi=0;this.baseURL=e.baseURL;this.ujt=e.ujt}AsaiApi.prototype.api=function(e){return o(this,arguments,void 0,(function(e,t){var i,o,a,l,u,d,c,f,v,p,h,w,g,y,m,b,A,k,_,j,W,h,M;var O=this;var S,$,P,R,C,D,E;if(t===void 0){t={}}return s(this,(function(s){switch(s.label){case 0:i=(P=($=(S=this.ujt)===null||S===void 0?void 0:S.$global)===null||$===void 0?void 0:$.sys)===null||P===void 0?void 0:P.onconsole;o=0;a=0;if(i){if(++this.totalApi>r.COUNTER_WRAP)this.totalApi=0;a=this.totalApi;o=Date.now()%r.LOG_TIME_MOD}l=new AbortController;u=setTimeout((function(){return l.abort()}),(R=t.timeout)!==null&&R!==void 0?R:this.defaultConfig.timeout);s.label=1;case 1:s.trys.push([1,6,,7]);d={url:this.baseURL+e};if(t.body instanceof FormData){d.opt=t}else{d.opt=n(n(n({},this.defaultConfig),t),{signal:l.signal,headers:n(n({},this.defaultConfig.headers),t.headers)})}if(o){(E=(D=(C=this.ujt)===null||C===void 0?void 0:C.$fn)===null||D===void 0?void 0:D.lo)===null||E===void 0?void 0:E.call(D,2,(t.method||"Req")+a,d)}c=Promise.resolve(d);f=function(e){c=c.then((function(t){return e(t)}))};for(v=0,p=this.interceptors.request;v<p.length;v++){h=p[v];f(h)}return[4,c];case 2:w=s.sent(),g=w.url,y=w.opt;return[4,fetch(g,y)];case 3:m=s.sent();clearTimeout(u);return[4,this._parseResponse(m)];case 4:b=s.sent();return[4,this._getRes(b,t)];case 5:A=s.sent();k=Promise.resolve(A);_=function(e){k=k.then((function(i){var n,s,l;if(o){(l=(s=(n=O.ujt)===null||n===void 0?void 0:n.$fn)===null||s===void 0?void 0:s.lo)===null||l===void 0?void 0:l.call(s,3,(t.method||"Res")+a+" "+(Date.now()%r.LOG_TIME_MOD-o)+"ms",i)}return e(i)}))};for(j=0,W=this.interceptors.response;j<W.length;j++){h=W[j];_(h)}return[2,k];case 6:M=s.sent();clearTimeout(u);throw this._handleError(M);case 7:return[2]}}))}))};AsaiApi.prototype.apiGet=function(e){return o(this,arguments,void 0,(function(e,t,i){var o,r;if(t===void 0){t={}}if(i===void 0){i={}}return s(this,(function(s){switch(s.label){case 0:o=e;if(!!(i===null||i===void 0?void 0:i.client))return[3,2];o=o.split("?")[0];return[4,this._getReqQuery(e,t,i)];case 1:r=s.sent();if(r)o+="?"+r;s.label=2;case 2:return[2,this.api(o,n(n({},i),{method:"GET"}))]}}))}))};AsaiApi.prototype.apiPost=function(e,t){return o(this,arguments,void 0,(function(e,t,i){var o,r,a;if(i===void 0){i={}}return s(this,(function(s){switch(s.label){case 0:o=e.split("?")[0];return[4,this._getReqQuery(e,null,i)];case 1:r=s.sent();if(r)o+="?"+r;return[4,this._getReqPost(t,i)];case 2:a=s.sent();return[2,this.api(o,n(n({},i),{method:"POST",body:t instanceof FormData?t:this._stringifyData(a,i.headers)}))]}}))}))};AsaiApi.prototype.apiUpload=function(e,t,i){var n=new FormData;n.append("file",t);return this.apiPost(e,n,i)};AsaiApi.prototype.apiDownload=function(e,t){return this.apiGet(e,null,{responseType:"blob"}).then((function(e){var i=URL.createObjectURL(e);var n=document.createElement("a");n.href=i;n.download=t;n.click();URL.revokeObjectURL(i)}))};AsaiApi.prototype._getReqQuery=function(e){return o(this,arguments,void 0,(function(e,t,i){var n,o,a,l,u,d;var c,f,v,p,h,w,g,y,m;if(t===void 0){t=null}if(i===void 0){i=null}return s(this,(function(s){switch(s.label){case 0:s.trys.push([0,3,,4]);n=e.startsWith("http")?e:r.URL_PARSE_BASE+e;o={};new URL(n).searchParams.forEach((function(e,t){o[t]=e}));if(t)o=Object.assign(o,t);a=new URLSearchParams(o).toString();l=(v=(f=(c=this.ujt)===null||c===void 0?void 0:c.$global)===null||f===void 0?void 0:f.code)===null||v===void 0?void 0:v.pri;if((i===null||i===void 0?void 0:i.mm)&&((w=(h=(p=this.ujt)===null||p===void 0?void 0:p.$fn)===null||h===void 0?void 0:h.AsCode)===null||w===void 0?void 0:w.asdecode)&&l&&a){a=this.ujt.$fn.AsCode.asencode(a,l);if(a)a="pm="+encodeURIComponent(a)}u=(m=(y=(g=this.ujt)===null||g===void 0?void 0:g.$global)===null||y===void 0?void 0:y.sys)===null||m===void 0?void 0:m.aesfns;if(!(a&&(u===null||u===void 0?void 0:u.toAES)&&(u.allaes||u&&(i===null||i===void 0?void 0:i.aes))))return[3,2];return[4,u.toAES(a)];case 1:a=s.sent();a="aes="+encodeURIComponent(JSON.stringify(a));s.label=2;case 2:return[2,a];case 3:d=s.sent();return[2,""];case 4:return[2]}}))}))};AsaiApi.prototype._getReqPost=function(e,t){return o(this,void 0,void 0,(function(){var i,n,o,r,a,l;return s(this,(function(s){if((t===null||t===void 0?void 0:t.mm)&&((o=(n=(i=this.ujt)===null||i===void 0?void 0:i.$fn)===null||n===void 0?void 0:n.AsCode)===null||o===void 0?void 0:o.asdecode)&&((l=(a=(r=this.ujt)===null||r===void 0?void 0:r.$global)===null||a===void 0?void 0:a.code)===null||l===void 0?void 0:l.pri)&&e){return[2,this.ujt.$fn.AsCode.asencode(typeof e==="string"?e:JSON.stringify(e),this.ujt.$global.code.pri)]}return[2,e]}))}))};AsaiApi.prototype._getRes=function(e,t){return o(this,void 0,void 0,(function(){var i,n,o,r,a,l;return s(this,(function(s){if(typeof e==="string"){if(e.startsWith("<!"))return[2,""];return[2,e]}if((t===null||t===void 0?void 0:t.mm)&&((o=(n=(i=this.ujt)===null||i===void 0?void 0:i.$fn)===null||n===void 0?void 0:n.AsCode)===null||o===void 0?void 0:o.asdecode)&&((l=(a=(r=this.ujt)===null||r===void 0?void 0:r.$global)===null||a===void 0?void 0:a.code)===null||l===void 0?void 0:l.pri)&&(e===null||e===void 0?void 0:e.data)&&typeof e.data==="string"){e.data=this.ujt.$fn.AsCode.asdecode(e.data,this.ujt.$global.code.pri);try{e.data=JSON.parse(e.data)}catch(e){}}return[2,e]}))}))};AsaiApi.prototype._parseResponse=function(e){var t=e.headers.get("content-type");if(t===null||t===void 0?void 0:t.includes("application/json"))return e.json();if(t===null||t===void 0?void 0:t.includes("text/"))return e.text();return e.blob()};AsaiApi.prototype._stringifyData=function(e,t){if(e instanceof FormData||typeof e==="string")return e;var i=t===null||t===void 0?void 0:t["Content-Type"];if(i==="application/json"||typeof e==="object"){return JSON.stringify(e)}return String(e)};AsaiApi.prototype._handleError=function(e){if((e===null||e===void 0?void 0:e.name)==="AbortError"){return{code:504,message:"Request Timeout"}}return{code:500,message:(e===null||e===void 0?void 0:e.message)||"Network Error"}};AsaiApi.prototype.ictReq=function(e){this.interceptors.request.push(e)};AsaiApi.prototype.ictRes=function(e){this.interceptors.response.push(e)};return AsaiApi}();t.AsaiApi=a},642:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:true});t.AsaiModel=AsaiModel;var n=i(995);function AsaiModel(e){if(e===void 0){e="./webmodel/"}var t=new n.AsaiApi({baseURL:e});function fetchPublic(e,i){if(i===void 0){i=""}return new Promise((function(n,o){t===null||t===void 0?void 0:t.apiGet(e,{},{client:1}).then((function(t){Promise.all(dfsFetch(t,e.substring(0,e.lastIndexOf("/")+1)+i)).then((function(){return n(t)})).catch(o)})).catch(o)}))}function dfsFetch(e,i){var n;var o=[];if((n=e===null||e===void 0?void 0:e.dir)===null||n===void 0?void 0:n.length){var _loop_1=function(n){var s=i+n;var r=s.lastIndexOf("/");o.push(t===null||t===void 0?void 0:t.apiGet(s,{},{client:1}).then((function(t){var i=s.substring(r+1);e[i.substring(0,i.indexOf("."))]=t;o.push(Promise.all(dfsFetch(t,s.substring(0,r+1))))})).catch((function(e){console.error("Error fetching resource:",e)})))};for(var s=0,r=e.dir;s<r.length;s++){var a=r[s];_loop_1(a)}}return o}return{fetchPublic:fetchPublic}}},821:(e,t)=>{Object.defineProperty(t,"__esModule",{value:true});t.AsaiWorker=void 0;var i=function(){function AsaiWorker(e,t){if(t===void 0){t=navigator.hardwareConcurrency||4}this.taskQueue=[];this.workers=new Set;this.taskMap=new Map;this.taskId=0;this.workerScript=e;this.maxWorkers=t}AsaiWorker.prototype.execute=function(e){var t=this;return new Promise((function(i,n){var o=t.taskId++;t.taskQueue.push({taskId:o,taskData:e});t.taskMap.set(o,{resolve:i,reject:n});t._processNext()}))};AsaiWorker.prototype.terminateAll=function(){this.workers.forEach((function(e){return e.terminate()}));this.workers.clear();this.taskQueue.length=0};AsaiWorker.prototype._createWorker=function(){var e=this;var t=new Worker(this.workerScript,{type:"module"});t.onmessage=function(i){var n=i.data,o=n.taskId,s=n.result,r=n.error;var a=e.taskMap.get(o);if(a){r?a.reject(r):a.resolve(s);e.taskMap.delete(o)}e.workers.delete(t);t.terminate();e._processNext()};t.onerror=function(i){console.error("Worker error:",i);e.workers.delete(t);e._createWorker()};this.workers.add(t);return t};AsaiWorker.prototype._processNext=function(){while(this.taskQueue.length>0&&this.workers.size<this.maxWorkers){var e=this.taskQueue.shift();var t=this._createWorker();t.postMessage({taskId:e.taskId,data:e.taskData})}};return AsaiWorker}();t.AsaiWorker=i},873:function(e,t,i){var n=this&&this.__assign||function(){n=Object.assign||function(e){for(var t,i=1,n=arguments.length;i<n;i++){t=arguments[i];for(var o in t)if(Object.prototype.hasOwnProperty.call(t,o))e[o]=t[o]}return e};return n.apply(this,arguments)};var o=this&&this.__awaiter||function(e,t,i,n){function adopt(e){return e instanceof i?e:new i((function(t){t(e)}))}return new(i||(i=Promise))((function(i,o){function fulfilled(e){try{step(n.next(e))}catch(e){o(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){o(e)}}function step(e){e.done?i(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())}))};var s=this&&this.__generator||function(e,t){var i={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,o,s,r=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return r.next=verb(0),r["throw"]=verb(1),r["return"]=verb(2),typeof Symbol==="function"&&(r[Symbol.iterator]=function(){return this}),r;function verb(e){return function(t){return step([e,t])}}function step(a){if(n)throw new TypeError("Generator is already executing.");while(r&&(r=0,a[0]&&(i=0)),i)try{if(n=1,o&&(s=a[0]&2?o["return"]:a[0]?o["throw"]||((s=o["return"])&&s.call(o),0):o.next)&&!(s=s.call(o,a[1])).done)return s;if(o=0,s)a=[a[0]&2,s.value];switch(a[0]){case 0:case 1:s=a;break;case 4:i.label++;return{value:a[1],done:false};case 5:i.label++;o=a[1];a=[0];continue;case 7:a=i.ops.pop();i.trys.pop();continue;default:if(!(s=i.trys,s=s.length>0&&s[s.length-1])&&(a[0]===6||a[0]===2)){i=0;continue}if(a[0]===3&&(!s||a[1]>s[0]&&a[1]<s[3])){i.label=a[1];break}if(a[0]===6&&i.label<s[1]){i.label=s[1];s=a;break}if(s&&i.label<s[2]){i.label=s[2];i.ops.push(a);break}if(s[2])i.ops.pop();i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e];o=0}finally{n=s=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};Object.defineProperty(t,"__esModule",{value:true});t.AsaiWs=void 0;var r=i(340);var a=i(992);var l=function(){function AsaiWs(e){if(e===void 0){e={}}var t=this;var i,n,o,s,r,a,l,u,d,c;this.reconnectAttempts=0;this.maxReconnectDelay=0;this.messageQueue=[];this.isSending=false;this.wstaskMap=new Map;this.workerState=false;this.totalWs=0;this.wsname=e.wsname;this.wsworker=e.wsworker;this.wssec=e.wssec;this.wsurl=e.wsurl;this.ujt=e.ujt;this.baseURL=e.baseURL;this.wsConfig=(o=(n=(i=this.ujt.$global.link)===null||i===void 0?void 0:i.ws)===null||n===void 0?void 0:n[this.wsname])===null||o===void 0?void 0:o.config;this.onConsole=!!((a=(r=(s=this.ujt)===null||s===void 0?void 0:s.$global)===null||r===void 0?void 0:r.sys)===null||a===void 0?void 0:a.onconsole);this.aesFns=(d=(u=(l=this.ujt)===null||l===void 0?void 0:l.$global)===null||u===void 0?void 0:u.sys)===null||d===void 0?void 0:d.aesfns;var f=(c=this.wsConfig)===null||c===void 0?void 0:c.tmdeltask;if(f){this.cleanupInterval=setInterval((function(){if(!t.wstaskMap.size)return;var e=Date.now();var i=f/2;for(var n=0,o=t.wstaskMap;n<o.length;n++){var s=o[n],r=s[0],a=s[1];if(!a.type&&a.timestamp&&e-a.timestamp>i){t.wstaskMap.delete(r)}}}),f)}}AsaiWs.prototype.Uuid=function(e,t,i){if(e===void 0){e=""}if(t===void 0){t=0}if(i===void 0){i=32}var n=[Date.now().toString(36).slice(-9),t.toString(36),e.slice(-3),crypto.getRandomValues(new Uint8Array(6)).reduce((function(e,t){return e+(t&15).toString(i)}),"")];return n.join("").slice(0,16)};AsaiWs.prototype.wsSend=function(e){var t=this;this._getSendMsg(e).then((function(e){return t.wsSendMsg(e)}))};AsaiWs.prototype.wsApi=function(e){var t=this;return new Promise((function(i){var o=0;if(t.onConsole){o=Date.now()%a.LOG_TIME_MOD}var s;try{if(e==="ping"){s="ping"}else if(e==="pong"){s="pong"}else if(!e){s={id:t.Uuid("ws")}}else if(typeof e==="object"){s=n({},e);if(!(s===null||s===void 0?void 0:s.id))s.id=t.Uuid("ws")}else{s=JSON.parse(e);if(!(s===null||s===void 0?void 0:s.id))s.id=t.Uuid("ws")}}catch(e){}t.wsWatchDo(s,(function(e){var n,s,r;if(o){var l=Date.now()%a.LOG_TIME_MOD-o;(r=(s=(n=t.ujt)===null||n===void 0?void 0:n.$fn)===null||s===void 0?void 0:s.lo)===null||r===void 0?void 0:r.call(s,5,"wsGet:"+l+"ms",e)}t._getOnMsg(e).then(i).catch((function(){return i(e)}))}))}))};AsaiWs.prototype.wsWatch=function(e,t){var i,n,o;if(this.onConsole)(o=(n=(i=this.ujt)===null||i===void 0?void 0:i.$fn)===null||n===void 0?void 0:n.lo)===null||o===void 0?void 0:o.call(n,3,"wsWatch",e);this.wsWatchDo(e,t)};AsaiWs.prototype.wsWatchDo=function(e,t){var i=this.getKeyByData(e);var o={};if(e!=="ping"&&e!=="pong"){o=typeof e==="object"&&(e===null||e===void 0?void 0:e.id)?{type:0,timestamp:Date.now()}:{type:1}}this.wstaskMap.set(i,n({callback:t},o));this.wsSend(e)};AsaiWs.prototype.wsWatchOff=function(e){var t,i,n;if(this.onConsole){(n=(i=(t=this.ujt)===null||t===void 0?void 0:t.$fn)===null||i===void 0?void 0:i.lo)===null||n===void 0?void 0:n.call(i,6,"wsWatchOff:"+this.wstaskMap.size,e)}if(!e.off)e.off=1;this.wsSend(e);var o=this.getKeyByData(e);if(this.wstaskMap.has(o)){this.wstaskMap.delete(o)}};AsaiWs.prototype.wsWatchWork=function(e){var t=this;var i=this.getKeyByData(e);var n=this.wstaskMap.get(i);if(!n)return;this._getOnMsg(e).then((function(e){var o,s,r;n.callback(e);if(!n.type){if(t.onConsole){(r=(s=(o=t.ujt)===null||o===void 0?void 0:o.$fn)===null||s===void 0?void 0:s.lo)===null||r===void 0?void 0:r.call(s,3,"wsDelete:"+t.wstaskMap.size,i)}t.wstaskMap.delete(i)}})).catch((function(){t.wstaskMap.delete(i)}))};AsaiWs.prototype.wsSendMsg=function(e){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:if(!(e==="ping"||e==="pong"))return[3,2];return[4,this.sendSingleMessage(e)];case 1:t.sent();return[2];case 2:this.messageQueue.push(e);if(this.isSending)return[2];this.isSending=true;t.label=3;case 3:t.trys.push([3,,7,8]);t.label=4;case 4:if(!(this.messageQueue.length>0))return[3,6];return[4,this.sendSingleMessage(this.messageQueue.shift())];case 5:t.sent();return[3,4];case 6:return[3,8];case 7:this.isSending=false;return[7];case 8:return[2]}}))}))};AsaiWs.prototype.sendSingleMessage=function(e){var t=this;return new Promise((function(i,n){t.init().then((function(){var o,s,r,a,l,u,d,c;if(t.wsworker){var f=(o=t.ujt.$fn.workers[t.wsname])===null||o===void 0?void 0:o.instance;if(typeof(f===null||f===void 0?void 0:f.postMessage)==="function"){f.postMessage({type:"send",data:e});i()}else{n()}return}var v=t.ujt.$fn.ws[t.wsname].socket;if((v===null||v===void 0?void 0:v.readyState)===WebSocket.OPEN){v.send(e);if((s=t.wsConfig)===null||s===void 0?void 0:s.resend){t.wsConfig.resend=0}i();return}if(((r=t.wsConfig)===null||r===void 0?void 0:r.resendmax)&&t.wsConfig.resend<=t.wsConfig.resendmax){t.wsSendMsg(e);t.wsConfig.resend++;i()}else{if(t.onConsole){(u=(l=(a=t.ujt)===null||a===void 0?void 0:a.$fn)===null||l===void 0?void 0:l.lo)===null||u===void 0?void 0:u.call(l,5,"Err",t.wsname,(d=t.wsConfig)===null||d===void 0?void 0:d.resend,(c=t.wsConfig)===null||c===void 0?void 0:c.resendmax)}n(new Error("Max send attempts reached"))}})).catch(n)}))};AsaiWs.prototype.getKeyByData=function(e){if(e==="ping"||e==="pong")return"pong";return(e===null||e===void 0?void 0:e.id)||(e===null||e===void 0?void 0:e.ty)};AsaiWs.prototype.newWorker=function(e,t){try{if(typeof Worker!=="undefined"&&e.id){if(!e.workers[e.id]){e.workers[e.id]={instance:new Worker(window.URL.createObjectURL(new Blob(["eval(".concat(e.fn.toString(),")(").concat(JSON.stringify(e.params),",this,'')")]))),callbacks:new Set};e.workers[e.id].instance.onmessage=function(t){e.workers[e.id].callbacks.forEach((function(e){e(t.data)}))}}e.workers[e.id].callbacks.add(t)}else{e.fn(e.params,"",t)}}catch(e){console.error("Worker creation error:",e)}};AsaiWs.prototype.initWsWorker=function(e,t){var i;this.newWorker({fn:function(e,t,i){var n,o;var s={};function deonmessage(e,t,i,n){var o,s;if(i===void 0){i={}}try{var r=JSON.parse(e);if(!n||!(r===null||r===void 0?void 0:r.ty)){t(r)}else{var a=r===null||r===void 0?void 0:r.ty;if(!i[a]){i[a]={s:e,v:r,t:1}}else if(i[a].s===e){if(i[a].t)i[a].t=0}else{i[a].s=e;i[a].v=r;if(!i[a].t)i[a].t=1}if((o=i[a])===null||o===void 0?void 0:o.t)t((s=i[a])===null||s===void 0?void 0:s.v)}}catch(i){t(e)}}function wsonmessage(t,i){if(t===null||t===void 0?void 0:t.data){if(t.data==="pong"){i(t.data)}else if(typeof t.data==="string"){deonmessage(t.data,i,s,e.de)}}}function wkclose(){a.close();a=null;t.postMessage("onclose");t.terminate()}var r=(o=(n=this.ujt)===null||n===void 0?void 0:n.$fn)===null||o===void 0?void 0:o.gettoken(0);var a=this.wssec&&r?new WebSocket(e.url,r):new WebSocket(e.url);a.onmessage=function(e){wsonmessage(e,t.postMessage)};a.onclose=function(){return t.postMessage("onclose")};a.onerror=function(){return t.postMessage("onerror")};a.onopen=function(){a.open=1;t.postMessage("onopen")};t.onmessage=function(e){var t,i,n;try{if(a===null||a===void 0?void 0:a.open){if(((t=e===null||e===void 0?void 0:e.data)===null||t===void 0?void 0:t.type)==="close")wkclose();else if(((i=e===null||e===void 0?void 0:e.data)===null||i===void 0?void 0:i.type)==="send"){a.send(((n=e===null||e===void 0?void 0:e.data)===null||n===void 0?void 0:n.data)||"")}}else{wkclose()}}catch(e){wkclose()}}},params:{url:e,de:(i=this.wsConfig)===null||i===void 0?void 0:i.de},id:this.wsname,workers:this.ujt.$fn.workers},(function(e){if(e&&e!=="null")t(e)}))};AsaiWs.prototype.init=function(){var e=this;var t;var i=this;var n={};var o=(t=this.wsConfig)===null||t===void 0?void 0:t.de;return new Promise((function(t,s){var a,l,u;try{if((a=e.ujt.$ws[e.wsname])===null||a===void 0?void 0:a.open){t(e.ujt)}else{if(!e.wsurl.startsWith("ws")){s({error:e.wsurl+" is not a WebSocket (WS) address!"})}else if(!("WebSocket"in window)){s({error:"WebSocket is null!"})}if(e.wsworker){if(e.workerState){setTimeout((function(){return t(e.ujt)}),3e3)}else{e.workerState=true;e.initWsWorker(e.wsurl,(function(i){if(i==="onclose")onclose();else if(i==="onerror")onerror();else if(i==="onopen"){onopen();t(e.ujt)}else onmessagedo(i)}))}}else{if(!e.ujt.$fn.ws[e.wsname]){e.ujt.$fn.ws[e.wsname]={}}var d=(u=(l=e.ujt)===null||l===void 0?void 0:l.$fn)===null||u===void 0?void 0:u.gettoken(0);e.ujt.$fn.ws[e.wsname].socket=e.wssec&&d?new WebSocket(e.wsurl,d):new WebSocket(e.wsurl);e.ujt.$fn.ws[e.wsname].socket.onmessage=onmessage;e.ujt.$fn.ws[e.wsname].socket.onclose=onclose;e.ujt.$fn.ws[e.wsname].socket.onerror=onerror;e.ujt.$fn.ws[e.wsname].socket.onopen=function(i){onopen(i);t(e.ujt)}}}}catch(e){onerror(e);s(e)}function onopen(e){if(e===void 0){e=null}if(!i.ujt.$ws[i.wsname])i.ujt.$ws[i.wsname]={};i.ujt.$ws[i.wsname].open=true}function onmessage(e){(0,r.deonmessage)(e.data,onmessagedo,n,o)}function onmessagedo(e){if(!i.wstaskMap.size)return;try{i.wsWatchWork(typeof e==="object"?e:JSON.parse(e))}catch(t){i.wsWatchWork(e)}}function onerror(e){var t,n,o,s,r;if(e===void 0){e=null}if((n=(t=i.ujt)===null||t===void 0?void 0:t.$ws)===null||n===void 0?void 0:n[i.wsname]){i.ujt.$ws[i.wsname].open=false;i.ujt.$global.stat[i.wsname]=0}(r=(s=(o=i.ujt)===null||o===void 0?void 0:o.$global)===null||s===void 0?void 0:s.msg)===null||r===void 0?void 0:r.fn({type:"err",con:i.ujt.$fn.lg("asai.hostmsg.error",i._wsDisplayName())||i._wsDisplayName()+" is error!"})}function onclose(e){if(e===void 0){e=null}if(i.ujt.$ws[i.wsname]){i.ujt.$ws[i.wsname].open=false;i.ujt.$global.stat[i.wsname]=0}if(i.ujt.$global.rlv){i.ujt.$global.pagebusy={log:i.wsname,close:1,v:i.ujt.$fn.lg("asai.hostmsg.closed",i._wsDisplayName())||i._wsDisplayName()+" is close!"}}scheduleReconnect()}function scheduleReconnect(){if(!i.maxReconnectDelay)return;var e=Math.min(1e3*Math.pow(2,i.reconnectAttempts),i.maxReconnectDelay);setTimeout((function(){return i.init()}),e);i.reconnectAttempts++}}))};AsaiWs.prototype._wsDisplayName=function(){var e,t,i,n;return((n=(i=(t=(e=this.ujt.$global.lang)===null||e===void 0?void 0:e.asai)===null||t===void 0?void 0:t.hostmsg)===null||i===void 0?void 0:i.wsname)===null||n===void 0?void 0:n[this.wsname])||this.wsname};AsaiWs.prototype._getSendMsg=function(e){var t=this;return new Promise((function(i){var o,s,r,l,u;try{if(t.onConsole){if(++t.totalWs>a.COUNTER_WRAP)t.totalWs=0;var d=(e===null||e===void 0?void 0:e.db)?n({},e):e;(r=(s=(o=t.ujt)===null||o===void 0?void 0:o.$fn)===null||s===void 0?void 0:s.lo)===null||r===void 0?void 0:r.call(s,4,"wsSend"+t.totalWs+":"+t.messageQueue.length,d)}if(typeof e!=="object"){i(e);return}if(((e===null||e===void 0?void 0:e.aes)||((l=t.aesFns)===null||l===void 0?void 0:l.allaes))&&(e===null||e===void 0?void 0:e.db)&&((u=t.aesFns)===null||u===void 0?void 0:u.toAES)){t.aesFns.toAES(e.db).then((function(t){e.db=t;i(JSON.stringify(e))})).catch((function(){return i(JSON.stringify(e))}))}else{i(JSON.stringify(e))}}catch(t){i(e)}}))};AsaiWs.prototype._getOnMsg=function(e){var t,i;if(((t=e===null||e===void 0?void 0:e.db)===null||t===void 0?void 0:t.aes)&&((i=this.aesFns)===null||i===void 0?void 0:i.fromAES)){return this.aesFns.fromAES(e.db).then((function(t){e.db=t;return e}))}return Promise.resolve(e)};return AsaiWs}();t.AsaiWs=l},992:(e,t)=>{Object.defineProperty(t,"__esModule",{value:true});t.URL_PARSE_BASE=t.COUNTER_WRAP=t.LOG_TIME_MOD=void 0;t.LOG_TIME_MOD=1e7;t.COUNTER_WRAP=1e4;t.URL_PARSE_BASE="ht"+"tp:"+"//as"+"ai.cc"},105:(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:true});t.deonmessage=t.AsaiModel=t.AsaiWs=t.AsaiApi=t.AsaiWorker=void 0;var n=i(821);Object.defineProperty(t,"AsaiWorker",{enumerable:true,get:function(){return n.AsaiWorker}});var o=i(995);Object.defineProperty(t,"AsaiApi",{enumerable:true,get:function(){return o.AsaiApi}});var s=i(873);Object.defineProperty(t,"AsaiWs",{enumerable:true,get:function(){return s.AsaiWs}});var r=i(642);Object.defineProperty(t,"AsaiModel",{enumerable:true,get:function(){return r.AsaiModel}});var a=i(340);Object.defineProperty(t,"deonmessage",{enumerable:true,get:function(){return a.deonmessage}})},340:(e,t)=>{Object.defineProperty(t,"__esModule",{value:true});t.deonmessage=deonmessage;function deonmessage(e,t,i,n){if(i===void 0){i={}}try{var o=JSON.parse(e);if(!n||!(o===null||o===void 0?void 0:o.ty)){t(o);return}var s=o.ty;var r=i[s];if(!r){r=i[s]={s:e,v:o,t:1}}else if(r.s===e){if(r.t)r.t=0}else{r.s=e;r.v=o;if(!r.t)r.t=1}if(r.t){t(r.v)}}catch(i){t(e)}}}};var t={};function __nccwpck_require__(i){var n=t[i];if(n!==undefined){return n.exports}var o=t[i]={exports:{}};var s=true;try{e[i].call(o.exports,o,o.exports,__nccwpck_require__);s=false}finally{if(s)delete t[i]}return o.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var i={};(()=>{var e=i;Object.defineProperty(e,"__esModule",{value:true});e.AsaiModel=e.AsaiWs=e.AsaiApi=e.AsaiWorker=void 0;var t=__nccwpck_require__(105);Object.defineProperty(e,"AsaiWorker",{enumerable:true,get:function(){return t.AsaiWorker}});Object.defineProperty(e,"AsaiApi",{enumerable:true,get:function(){return t.AsaiApi}});Object.defineProperty(e,"AsaiWs",{enumerable:true,get:function(){return t.AsaiWs}});Object.defineProperty(e,"AsaiModel",{enumerable:true,get:function(){return t.AsaiModel}});e["default"]={AsaiWorker:t.AsaiWorker,AsaiApi:t.AsaiApi,AsaiWs:t.AsaiWs,AsaiModel:t.AsaiModel}})();module.exports=i})();
1
+ (()=>{"use strict";var e={995:function(e,t,n){var i=this&&this.__assign||function(){i=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++){t=arguments[n];for(var o in t)if(Object.prototype.hasOwnProperty.call(t,o))e[o]=t[o]}return e};return i.apply(this,arguments)};var o=this&&this.__awaiter||function(e,t,n,i){function adopt(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,o){function fulfilled(e){try{step(i.next(e))}catch(e){o(e)}}function rejected(e){try{step(i["throw"](e))}catch(e){o(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((i=i.apply(e,t||[])).next())}))};var r=this&&this.__generator||function(e,t){var n={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},i,o,r,s=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return s.next=verb(0),s["throw"]=verb(1),s["return"]=verb(2),typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function verb(e){return function(t){return step([e,t])}}function step(a){if(i)throw new TypeError("Generator is already executing.");while(s&&(s=0,a[0]&&(n=0)),n)try{if(i=1,o&&(r=a[0]&2?o["return"]:a[0]?o["throw"]||((r=o["return"])&&r.call(o),0):o.next)&&!(r=r.call(o,a[1])).done)return r;if(o=0,r)a=[a[0]&2,r.value];switch(a[0]){case 0:case 1:r=a;break;case 4:n.label++;return{value:a[1],done:false};case 5:n.label++;o=a[1];a=[0];continue;case 7:a=n.ops.pop();n.trys.pop();continue;default:if(!(r=n.trys,r=r.length>0&&r[r.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!r||a[1]>r[0]&&a[1]<r[3])){n.label=a[1];break}if(a[0]===6&&n.label<r[1]){n.label=r[1];r=a;break}if(r&&n.label<r[2]){n.label=r[2];n.ops.push(a);break}if(r[2])n.ops.pop();n.trys.pop();continue}a=t.call(e,n)}catch(e){a=[6,e];o=0}finally{i=r=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};Object.defineProperty(t,"__esModule",{value:true});t.AsaiApi=void 0;var s=n(992);var a=function(){function AsaiApi(e){if(e===void 0){e={}}this.interceptors={request:[],response:[]};this.defaultConfig={headers:{"Content-Type":"application/json"},cache:"reload",timeout:1e4};this.totalApi=0;this.baseURL=e.baseURL;this.ujt=e.ujt}AsaiApi.prototype.api=function(e){return o(this,arguments,void 0,(function(e,t){var n,o,a,l,u,d,c,f,v,p,h,w,g,y,b,m,k,A,_,j,W,h,M;var O=this;var S,$,R,P,x,E,C;if(t===void 0){t={}}return r(this,(function(r){switch(r.label){case 0:n=(R=($=(S=this.ujt)===null||S===void 0?void 0:S.$global)===null||$===void 0?void 0:$.sys)===null||R===void 0?void 0:R.onconsole;o=0;a=0;if(n){if(++this.totalApi>s.COUNTER_WRAP)this.totalApi=0;a=this.totalApi;o=Date.now()%s.LOG_TIME_MOD}l=new AbortController;u=setTimeout((function(){return l.abort()}),(P=t.timeout)!==null&&P!==void 0?P:this.defaultConfig.timeout);r.label=1;case 1:r.trys.push([1,6,,7]);d={url:this.baseURL+e};if(t.body instanceof FormData){d.opt=t}else{d.opt=i(i(i({},this.defaultConfig),t),{signal:l.signal,headers:i(i({},this.defaultConfig.headers),t.headers)})}if(o){(C=(E=(x=this.ujt)===null||x===void 0?void 0:x.$fn)===null||E===void 0?void 0:E.lo)===null||C===void 0?void 0:C.call(E,2,(t.method||"Req")+a,d)}c=Promise.resolve(d);f=function(e){c=c.then((function(t){return e(t)}))};for(v=0,p=this.interceptors.request;v<p.length;v++){h=p[v];f(h)}return[4,c];case 2:w=r.sent(),g=w.url,y=w.opt;return[4,fetch(g,y)];case 3:b=r.sent();clearTimeout(u);return[4,this._parseResponse(b)];case 4:m=r.sent();return[4,this._getRes(m,t)];case 5:k=r.sent();A=Promise.resolve(k);_=function(e){A=A.then((function(n){var i,r,l;if(o){(l=(r=(i=O.ujt)===null||i===void 0?void 0:i.$fn)===null||r===void 0?void 0:r.lo)===null||l===void 0?void 0:l.call(r,3,(t.method||"Res")+a+" "+(Date.now()%s.LOG_TIME_MOD-o)+"ms",n)}return e(n)}))};for(j=0,W=this.interceptors.response;j<W.length;j++){h=W[j];_(h)}return[2,A];case 6:M=r.sent();clearTimeout(u);throw this._handleError(M);case 7:return[2]}}))}))};AsaiApi.prototype.apiGet=function(e){return o(this,arguments,void 0,(function(e,t,n){var o,s;if(t===void 0){t={}}if(n===void 0){n={}}return r(this,(function(r){switch(r.label){case 0:o=e;if(!!(n===null||n===void 0?void 0:n.client))return[3,2];o=o.split("?")[0];return[4,this._getReqQuery(e,t,n)];case 1:s=r.sent();if(s)o+="?"+s;r.label=2;case 2:return[2,this.api(o,i(i({},n),{method:"GET"}))]}}))}))};AsaiApi.prototype.apiPost=function(e,t){return o(this,arguments,void 0,(function(e,t,n){var o,s,a;if(n===void 0){n={}}return r(this,(function(r){switch(r.label){case 0:o=e.split("?")[0];return[4,this._getReqQuery(e,null,n)];case 1:s=r.sent();if(s)o+="?"+s;return[4,this._getReqPost(t,n)];case 2:a=r.sent();return[2,this.api(o,i(i({},n),{method:"POST",body:t instanceof FormData?t:this._stringifyData(a,n.headers)}))]}}))}))};AsaiApi.prototype.apiUpload=function(e,t,n){var i=new FormData;i.append("file",t);return this.apiPost(e,i,n)};AsaiApi.prototype.apiDownload=function(e,t){return this.apiGet(e,null,{responseType:"blob"}).then((function(e){var n=URL.createObjectURL(e);var i=document.createElement("a");i.href=n;i.download=t;i.click();URL.revokeObjectURL(n)}))};AsaiApi.prototype._getReqQuery=function(e){return o(this,arguments,void 0,(function(e,t,n){var i,o,a,l,u,d;var c,f,v,p,h,w,g,y,b;if(t===void 0){t=null}if(n===void 0){n=null}return r(this,(function(r){switch(r.label){case 0:r.trys.push([0,3,,4]);i=e.startsWith("http")?e:s.URL_PARSE_BASE+e;o={};new URL(i).searchParams.forEach((function(e,t){o[t]=e}));if(t)o=Object.assign(o,t);a=new URLSearchParams(o).toString();l=(v=(f=(c=this.ujt)===null||c===void 0?void 0:c.$global)===null||f===void 0?void 0:f.code)===null||v===void 0?void 0:v.pri;if((n===null||n===void 0?void 0:n.mm)&&((w=(h=(p=this.ujt)===null||p===void 0?void 0:p.$fn)===null||h===void 0?void 0:h.AsCode)===null||w===void 0?void 0:w.asdecode)&&l&&a){a=this.ujt.$fn.AsCode.asencode(a,l);if(a)a="pm="+encodeURIComponent(a)}u=(b=(y=(g=this.ujt)===null||g===void 0?void 0:g.$global)===null||y===void 0?void 0:y.sys)===null||b===void 0?void 0:b.aesfns;if(!(a&&(u===null||u===void 0?void 0:u.toAES)&&(u.allaes||u&&(n===null||n===void 0?void 0:n.aes))))return[3,2];return[4,u.toAES(a)];case 1:a=r.sent();a="aes="+encodeURIComponent(JSON.stringify(a));r.label=2;case 2:return[2,a];case 3:d=r.sent();return[2,""];case 4:return[2]}}))}))};AsaiApi.prototype._getReqPost=function(e,t){return o(this,void 0,void 0,(function(){var n,i,o,s,a,l;return r(this,(function(r){if((t===null||t===void 0?void 0:t.mm)&&((o=(i=(n=this.ujt)===null||n===void 0?void 0:n.$fn)===null||i===void 0?void 0:i.AsCode)===null||o===void 0?void 0:o.asdecode)&&((l=(a=(s=this.ujt)===null||s===void 0?void 0:s.$global)===null||a===void 0?void 0:a.code)===null||l===void 0?void 0:l.pri)&&e){return[2,this.ujt.$fn.AsCode.asencode(typeof e==="string"?e:JSON.stringify(e),this.ujt.$global.code.pri)]}return[2,e]}))}))};AsaiApi.prototype._getRes=function(e,t){return o(this,void 0,void 0,(function(){var n,i,o,s,a,l;return r(this,(function(r){if(typeof e==="string"){if(e.startsWith("<!"))return[2,""];return[2,e]}if((t===null||t===void 0?void 0:t.mm)&&((o=(i=(n=this.ujt)===null||n===void 0?void 0:n.$fn)===null||i===void 0?void 0:i.AsCode)===null||o===void 0?void 0:o.asdecode)&&((l=(a=(s=this.ujt)===null||s===void 0?void 0:s.$global)===null||a===void 0?void 0:a.code)===null||l===void 0?void 0:l.pri)&&(e===null||e===void 0?void 0:e.data)&&typeof e.data==="string"){e.data=this.ujt.$fn.AsCode.asdecode(e.data,this.ujt.$global.code.pri);try{e.data=JSON.parse(e.data)}catch(e){}}return[2,e]}))}))};AsaiApi.prototype._parseResponse=function(e){var t=e.headers.get("content-type");if(t===null||t===void 0?void 0:t.includes("application/json"))return e.json();if(t===null||t===void 0?void 0:t.includes("text/"))return e.text();return e.blob()};AsaiApi.prototype._stringifyData=function(e,t){if(e instanceof FormData||typeof e==="string")return e;var n=t===null||t===void 0?void 0:t["Content-Type"];if(n==="application/json"||typeof e==="object"){return JSON.stringify(e)}return String(e)};AsaiApi.prototype._handleError=function(e){if((e===null||e===void 0?void 0:e.name)==="AbortError"){return{code:504,message:"Request Timeout"}}return{code:500,message:(e===null||e===void 0?void 0:e.message)||"Network Error"}};AsaiApi.prototype.ictReq=function(e){this.interceptors.request.push(e)};AsaiApi.prototype.ictRes=function(e){this.interceptors.response.push(e)};return AsaiApi}();t.AsaiApi=a},642:function(e,t,n){var i=this&&this.__awaiter||function(e,t,n,i){function adopt(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,o){function fulfilled(e){try{step(i.next(e))}catch(e){o(e)}}function rejected(e){try{step(i["throw"](e))}catch(e){o(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((i=i.apply(e,t||[])).next())}))};var o=this&&this.__generator||function(e,t){var n={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},i,o,r,s=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return s.next=verb(0),s["throw"]=verb(1),s["return"]=verb(2),typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function verb(e){return function(t){return step([e,t])}}function step(a){if(i)throw new TypeError("Generator is already executing.");while(s&&(s=0,a[0]&&(n=0)),n)try{if(i=1,o&&(r=a[0]&2?o["return"]:a[0]?o["throw"]||((r=o["return"])&&r.call(o),0):o.next)&&!(r=r.call(o,a[1])).done)return r;if(o=0,r)a=[a[0]&2,r.value];switch(a[0]){case 0:case 1:r=a;break;case 4:n.label++;return{value:a[1],done:false};case 5:n.label++;o=a[1];a=[0];continue;case 7:a=n.ops.pop();n.trys.pop();continue;default:if(!(r=n.trys,r=r.length>0&&r[r.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!r||a[1]>r[0]&&a[1]<r[3])){n.label=a[1];break}if(a[0]===6&&n.label<r[1]){n.label=r[1];r=a;break}if(r&&n.label<r[2]){n.label=r[2];n.ops.push(a);break}if(r[2])n.ops.pop();n.trys.pop();continue}a=t.call(e,n)}catch(e){a=[6,e];o=0}finally{i=r=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};Object.defineProperty(t,"__esModule",{value:true});t.AsaiModel=AsaiModel;var r=n(995);function AsaiModel(e){if(e===void 0){e="./webmodel/"}var t=new r.AsaiApi({baseURL:e});function fetchPublic(e){return i(this,arguments,void 0,(function(e,n){var i;if(n===void 0){n=""}return o(this,(function(o){switch(o.label){case 0:return[4,t===null||t===void 0?void 0:t.apiGet(e,{},{client:1})];case 1:i=o.sent();return[4,dfsFetch(i,e.substring(0,e.lastIndexOf("/")+1)+n)];case 2:o.sent();return[2,i]}}))}))}function dfsFetch(e,n){return i(this,void 0,void 0,(function(){var r=this;var s;return o(this,(function(a){switch(a.label){case 0:if(!((s=e===null||e===void 0?void 0:e.dir)===null||s===void 0?void 0:s.length))return[2];return[4,Promise.all(e.dir.map((function(s){return i(r,void 0,void 0,(function(){var i,r,a,l,u;return o(this,(function(o){switch(o.label){case 0:i=n+s;r=i.lastIndexOf("/");o.label=1;case 1:o.trys.push([1,4,,5]);return[4,t===null||t===void 0?void 0:t.apiGet(i,{},{client:1})];case 2:a=o.sent();l=i.substring(r+1);e[l.substring(0,l.indexOf("."))]=a;return[4,dfsFetch(a,i.substring(0,r+1))];case 3:o.sent();return[3,5];case 4:u=o.sent();console.error("Error fetching resource:",u);return[3,5];case 5:return[2]}}))}))})))];case 1:a.sent();return[2]}}))}))}return{fetchPublic:fetchPublic}}},821:(e,t)=>{Object.defineProperty(t,"__esModule",{value:true});t.AsaiWorker=void 0;var n=function(){function AsaiWorker(e,t){if(t===void 0){t=navigator.hardwareConcurrency||4}this.taskQueue=[];this.workers=new Set;this.taskMap=new Map;this.taskId=0;this.workerScript=e;this.maxWorkers=t}AsaiWorker.prototype.execute=function(e){var t=this;return new Promise((function(n,i){var o=t.taskId++;t.taskQueue.push({taskId:o,taskData:e});t.taskMap.set(o,{resolve:n,reject:i});t._processNext()}))};AsaiWorker.prototype.terminateAll=function(){this.workers.forEach((function(e){return e.terminate()}));this.workers.clear();this.taskQueue.length=0;this.taskMap.forEach((function(e){return e.reject(new Error("Worker pool terminated"))}));this.taskMap.clear()};AsaiWorker.prototype._createWorker=function(e){var t=this;var n=new Worker(this.workerScript,{type:"module"});n._taskId=e;n.onmessage=function(e){var i=e.data,o=i.taskId,r=i.result,s=i.error;var a=t.taskMap.get(o);if(a){s?a.reject(s):a.resolve(r);t.taskMap.delete(o)}t.workers.delete(n);n.terminate();t._processNext()};n.onerror=function(e){console.error("Worker error:",e);var i=n._taskId;var o=t.taskMap.get(i);if(o){o.reject((e===null||e===void 0?void 0:e.message)||e);t.taskMap.delete(i)}t.workers.delete(n);n.terminate();t._processNext()};this.workers.add(n);return n};AsaiWorker.prototype._processNext=function(){while(this.taskQueue.length>0&&this.workers.size<this.maxWorkers){var e=this.taskQueue.shift();var t=this._createWorker(e.taskId);t.postMessage({taskId:e.taskId,data:e.taskData})}};return AsaiWorker}();t.AsaiWorker=n},873:function(e,t,n){var i=this&&this.__assign||function(){i=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++){t=arguments[n];for(var o in t)if(Object.prototype.hasOwnProperty.call(t,o))e[o]=t[o]}return e};return i.apply(this,arguments)};var o=this&&this.__awaiter||function(e,t,n,i){function adopt(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,o){function fulfilled(e){try{step(i.next(e))}catch(e){o(e)}}function rejected(e){try{step(i["throw"](e))}catch(e){o(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((i=i.apply(e,t||[])).next())}))};var r=this&&this.__generator||function(e,t){var n={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},i,o,r,s=Object.create((typeof Iterator==="function"?Iterator:Object).prototype);return s.next=verb(0),s["throw"]=verb(1),s["return"]=verb(2),typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function verb(e){return function(t){return step([e,t])}}function step(a){if(i)throw new TypeError("Generator is already executing.");while(s&&(s=0,a[0]&&(n=0)),n)try{if(i=1,o&&(r=a[0]&2?o["return"]:a[0]?o["throw"]||((r=o["return"])&&r.call(o),0):o.next)&&!(r=r.call(o,a[1])).done)return r;if(o=0,r)a=[a[0]&2,r.value];switch(a[0]){case 0:case 1:r=a;break;case 4:n.label++;return{value:a[1],done:false};case 5:n.label++;o=a[1];a=[0];continue;case 7:a=n.ops.pop();n.trys.pop();continue;default:if(!(r=n.trys,r=r.length>0&&r[r.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!r||a[1]>r[0]&&a[1]<r[3])){n.label=a[1];break}if(a[0]===6&&n.label<r[1]){n.label=r[1];r=a;break}if(r&&n.label<r[2]){n.label=r[2];n.ops.push(a);break}if(r[2])n.ops.pop();n.trys.pop();continue}a=t.call(e,n)}catch(e){a=[6,e];o=0}finally{i=r=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};Object.defineProperty(t,"__esModule",{value:true});t.AsaiWs=void 0;var s=n(340);var a=n(992);var l=function(){function AsaiWs(e){if(e===void 0){e={}}var t=this;var n,i,o,r,s,a,l,u,d,c;this.reconnectAttempts=0;this.maxReconnectDelay=0;this.messageQueue=[];this.isSending=false;this.wstaskMap=new Map;this.workerState=false;this.totalWs=0;this.wsname=e.wsname;this.wsworker=e.wsworker;this.wssec=e.wssec;this.wsurl=e.wsurl;this.ujt=e.ujt;this.baseURL=e.baseURL;this.wsConfig=(o=(i=(n=this.ujt.$global.link)===null||n===void 0?void 0:n.ws)===null||i===void 0?void 0:i[this.wsname])===null||o===void 0?void 0:o.config;this.onConsole=!!((a=(s=(r=this.ujt)===null||r===void 0?void 0:r.$global)===null||s===void 0?void 0:s.sys)===null||a===void 0?void 0:a.onconsole);this.aesFns=(d=(u=(l=this.ujt)===null||l===void 0?void 0:l.$global)===null||u===void 0?void 0:u.sys)===null||d===void 0?void 0:d.aesfns;var f=(c=this.wsConfig)===null||c===void 0?void 0:c.tmdeltask;if(f){this.cleanupInterval=setInterval((function(){if(!t.wstaskMap.size)return;var e=Date.now();var n=f/2;for(var i=0,o=t.wstaskMap;i<o.length;i++){var r=o[i],s=r[0],a=r[1];if(!a.type&&a.timestamp&&e-a.timestamp>n){t.wstaskMap.delete(s)}}}),f)}}AsaiWs.prototype.Uuid=function(e,t,n){if(e===void 0){e=""}if(t===void 0){t=0}if(n===void 0){n=32}var i=[Date.now().toString(36).slice(-9),t.toString(36),e.slice(-3),crypto.getRandomValues(new Uint8Array(6)).reduce((function(e,t){return e+(t&15).toString(n)}),"")];return i.join("").slice(0,16)};AsaiWs.prototype.wsSend=function(e){var t=this;this._getSendMsg(e).then((function(e){return t.wsSendMsg(e)}))};AsaiWs.prototype.wsApi=function(e){var t=this;return new Promise((function(n){var o=0;if(t.onConsole){o=Date.now()%a.LOG_TIME_MOD}var r;try{if(e==="ping"){r="ping"}else if(e==="pong"){r="pong"}else if(!e){r={id:t.Uuid("ws")}}else if(typeof e==="object"){r=i({},e);if(!(r===null||r===void 0?void 0:r.id))r.id=t.Uuid("ws")}else{r=JSON.parse(e);if(!(r===null||r===void 0?void 0:r.id))r.id=t.Uuid("ws")}}catch(e){}t.wsWatchDo(r,(function(e){var i,r,s;if(o){var l=Date.now()%a.LOG_TIME_MOD-o;(s=(r=(i=t.ujt)===null||i===void 0?void 0:i.$fn)===null||r===void 0?void 0:r.lo)===null||s===void 0?void 0:s.call(r,5,"wsGet:"+l+"ms",e)}t._getOnMsg(e).then(n).catch((function(){return n(e)}))}))}))};AsaiWs.prototype.wsWatch=function(e,t){var n,i,o;if(this.onConsole)(o=(i=(n=this.ujt)===null||n===void 0?void 0:n.$fn)===null||i===void 0?void 0:i.lo)===null||o===void 0?void 0:o.call(i,3,"wsWatch",e);this.wsWatchDo(e,t)};AsaiWs.prototype.wsWatchDo=function(e,t){var n=this.getKeyByData(e);var o={};if(e!=="ping"&&e!=="pong"){o=typeof e==="object"&&(e===null||e===void 0?void 0:e.id)?{type:0,timestamp:Date.now()}:{type:1}}this.wstaskMap.set(n,i({callback:t},o));this.wsSend(e)};AsaiWs.prototype.wsWatchOff=function(e){var t,n,i;if(this.onConsole){(i=(n=(t=this.ujt)===null||t===void 0?void 0:t.$fn)===null||n===void 0?void 0:n.lo)===null||i===void 0?void 0:i.call(n,6,"wsWatchOff:"+this.wstaskMap.size,e)}if(!e.off)e.off=1;this.wsSend(e);var o=this.getKeyByData(e);if(this.wstaskMap.has(o)){this.wstaskMap.delete(o)}};AsaiWs.prototype.wsWatchWork=function(e){var t=this;var n=this.getKeyByData(e);var i=this.wstaskMap.get(n);if(!i)return;this._getOnMsg(e).then((function(e){var o,r,s;i.callback(e);if(!i.type){if(t.onConsole){(s=(r=(o=t.ujt)===null||o===void 0?void 0:o.$fn)===null||r===void 0?void 0:r.lo)===null||s===void 0?void 0:s.call(r,3,"wsDelete:"+t.wstaskMap.size,n)}t.wstaskMap.delete(n)}})).catch((function(){t.wstaskMap.delete(n)}))};AsaiWs.prototype.wsSendMsg=function(e){return o(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:if(!(e==="ping"||e==="pong"))return[3,2];return[4,this.sendSingleMessage(e)];case 1:t.sent();return[2];case 2:this.messageQueue.push(e);if(this.isSending)return[2];this.isSending=true;t.label=3;case 3:t.trys.push([3,,7,8]);t.label=4;case 4:if(!(this.messageQueue.length>0))return[3,6];return[4,this.sendSingleMessage(this.messageQueue.shift())];case 5:t.sent();return[3,4];case 6:return[3,8];case 7:this.isSending=false;return[7];case 8:return[2]}}))}))};AsaiWs.prototype.sendSingleMessage=function(e){var t=this;return new Promise((function(n,i){t.init().then((function(){var o,r,s,a,l,u,d,c;if(t.wsworker){var f=(o=t.ujt.$fn.workers[t.wsname])===null||o===void 0?void 0:o.instance;if(typeof(f===null||f===void 0?void 0:f.postMessage)==="function"){f.postMessage({type:"send",data:e});n()}else{i()}return}var v=t.ujt.$fn.ws[t.wsname].socket;if((v===null||v===void 0?void 0:v.readyState)===WebSocket.OPEN){v.send(e);if((r=t.wsConfig)===null||r===void 0?void 0:r.resend){t.wsConfig.resend=0}n();return}if(((s=t.wsConfig)===null||s===void 0?void 0:s.resendmax)&&t.wsConfig.resend<=t.wsConfig.resendmax){t.wsSendMsg(e);t.wsConfig.resend++;n()}else{if(t.onConsole){(u=(l=(a=t.ujt)===null||a===void 0?void 0:a.$fn)===null||l===void 0?void 0:l.lo)===null||u===void 0?void 0:u.call(l,5,"Err",t.wsname,(d=t.wsConfig)===null||d===void 0?void 0:d.resend,(c=t.wsConfig)===null||c===void 0?void 0:c.resendmax)}i(new Error("Max send attempts reached"))}})).catch(i)}))};AsaiWs.prototype.getKeyByData=function(e){if(e==="ping"||e==="pong")return"pong";return(e===null||e===void 0?void 0:e.id)||(e===null||e===void 0?void 0:e.ty)};AsaiWs.prototype.newWorker=function(e,t){try{if(typeof Worker!=="undefined"&&e.id){if(!e.workers[e.id]){e.workers[e.id]={instance:new Worker(window.URL.createObjectURL(new Blob(["eval(".concat(e.fn.toString(),")(").concat(JSON.stringify(e.params),",this,'')")]))),callbacks:new Set};e.workers[e.id].instance.onmessage=function(t){e.workers[e.id].callbacks.forEach((function(e){e(t.data)}))}}e.workers[e.id].callbacks.add(t)}else{e.fn(e.params,"",t)}}catch(e){console.error("Worker creation error:",e)}};AsaiWs.prototype.initWsWorker=function(e,t){var n,i,o;this.newWorker({fn:function(e,t,n){var i={};function deonmessage(e,t,n,i){var o,r;if(n===void 0){n={}}try{var s=JSON.parse(e);if(!i||!(s===null||s===void 0?void 0:s.ty)){t(s)}else{var a=s===null||s===void 0?void 0:s.ty;if(!n[a]){n[a]={s:e,v:s,t:1}}else if(n[a].s===e){if(n[a].t)n[a].t=0}else{n[a].s=e;n[a].v=s;if(!n[a].t)n[a].t=1}if((o=n[a])===null||o===void 0?void 0:o.t)t((r=n[a])===null||r===void 0?void 0:r.v)}}catch(n){t(e)}}function wsonmessage(t,n){if(t===null||t===void 0?void 0:t.data){if(t.data==="pong"){n(t.data)}else if(typeof t.data==="string"){deonmessage(t.data,n,i,e.de)}}}function wkclose(){r.close();r=null;t.postMessage("onclose");t.terminate()}var o=e.usertoken;var r=e.wssec&&o?new WebSocket(e.url,o):new WebSocket(e.url);r.onmessage=function(e){wsonmessage(e,t.postMessage)};r.onclose=function(){return t.postMessage("onclose")};r.onerror=function(){return t.postMessage("onerror")};r.onopen=function(){r.open=1;t.postMessage("onopen")};t.onmessage=function(e){var t,n,i;try{if(r===null||r===void 0?void 0:r.open){if(((t=e===null||e===void 0?void 0:e.data)===null||t===void 0?void 0:t.type)==="close")wkclose();else if(((n=e===null||e===void 0?void 0:e.data)===null||n===void 0?void 0:n.type)==="send"){r.send(((i=e===null||e===void 0?void 0:e.data)===null||i===void 0?void 0:i.data)||"")}}else{wkclose()}}catch(e){wkclose()}}},params:{url:e,de:(n=this.wsConfig)===null||n===void 0?void 0:n.de,wssec:this.wssec,usertoken:(o=(i=this.ujt)===null||i===void 0?void 0:i.$fn)===null||o===void 0?void 0:o.gettoken(0)},id:this.wsname,workers:this.ujt.$fn.workers},(function(e){if(e&&e!=="null")t(e)}))};AsaiWs.prototype.init=function(){var e=this;var t;var n=this;var i={};var o=(t=this.wsConfig)===null||t===void 0?void 0:t.de;return new Promise((function(t,r){var a,l,u;try{if((a=e.ujt.$ws[e.wsname])===null||a===void 0?void 0:a.open){t(e.ujt)}else{if(!e.wsurl.startsWith("ws")){r({error:e.wsurl+" is not a WebSocket (WS) address!"})}else if(!("WebSocket"in window)){r({error:"WebSocket is null!"})}if(e.wsworker){if(e.workerState){setTimeout((function(){return t(e.ujt)}),3e3)}else{e.workerState=true;e.initWsWorker(e.wsurl,(function(n){if(n==="onclose")onclose();else if(n==="onerror")onerror();else if(n==="onopen"){onopen();t(e.ujt)}else onmessagedo(n)}))}}else{if(!e.ujt.$fn.ws[e.wsname]){e.ujt.$fn.ws[e.wsname]={}}var d=(u=(l=e.ujt)===null||l===void 0?void 0:l.$fn)===null||u===void 0?void 0:u.gettoken(0);e.ujt.$fn.ws[e.wsname].socket=e.wssec&&d?new WebSocket(e.wsurl,d):new WebSocket(e.wsurl);e.ujt.$fn.ws[e.wsname].socket.onmessage=onmessage;e.ujt.$fn.ws[e.wsname].socket.onclose=onclose;e.ujt.$fn.ws[e.wsname].socket.onerror=onerror;e.ujt.$fn.ws[e.wsname].socket.onopen=function(n){onopen(n);t(e.ujt)}}}}catch(e){onerror(e);r(e)}function onopen(e){if(e===void 0){e=null}if(!n.ujt.$ws[n.wsname])n.ujt.$ws[n.wsname]={};n.ujt.$ws[n.wsname].open=true;n.reconnectAttempts=0}function onmessage(e){(0,s.deonmessage)(e.data,onmessagedo,i,o)}function onmessagedo(e){if(!n.wstaskMap.size)return;try{n.wsWatchWork(typeof e==="object"?e:JSON.parse(e))}catch(t){n.wsWatchWork(e)}}function onerror(e){var t,i,o,r,s;if(e===void 0){e=null}if((i=(t=n.ujt)===null||t===void 0?void 0:t.$ws)===null||i===void 0?void 0:i[n.wsname]){n.ujt.$ws[n.wsname].open=false;n.ujt.$global.stat[n.wsname]=0}(s=(r=(o=n.ujt)===null||o===void 0?void 0:o.$global)===null||r===void 0?void 0:r.msg)===null||s===void 0?void 0:s.fn({type:"err",con:n.ujt.$fn.lg("asai.hostmsg.error",n._wsDisplayName())||n._wsDisplayName()+" is error!"})}function onclose(e){if(e===void 0){e=null}if(n.ujt.$ws[n.wsname]){n.ujt.$ws[n.wsname].open=false;n.ujt.$global.stat[n.wsname]=0}if(n.ujt.$global.rlv){n.ujt.$global.pagebusy={log:n.wsname,close:1,v:n.ujt.$fn.lg("asai.hostmsg.closed",n._wsDisplayName())||n._wsDisplayName()+" is close!"}}scheduleReconnect()}function scheduleReconnect(){if(!n.maxReconnectDelay)return;var e=Math.min(1e3*Math.pow(2,n.reconnectAttempts),n.maxReconnectDelay);setTimeout((function(){return n.init()}),e);n.reconnectAttempts++}}))};AsaiWs.prototype._wsDisplayName=function(){var e,t,n,i;return((i=(n=(t=(e=this.ujt.$global.lang)===null||e===void 0?void 0:e.asai)===null||t===void 0?void 0:t.hostmsg)===null||n===void 0?void 0:n.wsname)===null||i===void 0?void 0:i[this.wsname])||this.wsname};AsaiWs.prototype._getSendMsg=function(e){var t=this;return new Promise((function(n){var o,r,s,l,u;try{if(t.onConsole){if(++t.totalWs>a.COUNTER_WRAP)t.totalWs=0;var d=(e===null||e===void 0?void 0:e.db)?i({},e):e;(s=(r=(o=t.ujt)===null||o===void 0?void 0:o.$fn)===null||r===void 0?void 0:r.lo)===null||s===void 0?void 0:s.call(r,4,"wsSend"+t.totalWs+":"+t.messageQueue.length,d)}if(typeof e!=="object"){n(e);return}if(((e===null||e===void 0?void 0:e.aes)||((l=t.aesFns)===null||l===void 0?void 0:l.allaes))&&(e===null||e===void 0?void 0:e.db)&&((u=t.aesFns)===null||u===void 0?void 0:u.toAES)){t.aesFns.toAES(e.db).then((function(t){e.db=t;n(JSON.stringify(e))})).catch((function(){return n(JSON.stringify(e))}))}else{n(JSON.stringify(e))}}catch(t){n(e)}}))};AsaiWs.prototype._getOnMsg=function(e){var t,n;if(((t=e===null||e===void 0?void 0:e.db)===null||t===void 0?void 0:t.aes)&&((n=this.aesFns)===null||n===void 0?void 0:n.fromAES)){return this.aesFns.fromAES(e.db).then((function(t){e.db=t;return e}))}return Promise.resolve(e)};AsaiWs.prototype.destroy=function(){if(this.cleanupInterval){clearInterval(this.cleanupInterval);this.cleanupInterval=undefined}this.wstaskMap.clear();this.messageQueue.length=0};return AsaiWs}();t.AsaiWs=l},992:(e,t)=>{Object.defineProperty(t,"__esModule",{value:true});t.URL_PARSE_BASE=t.COUNTER_WRAP=t.LOG_TIME_MOD=void 0;t.LOG_TIME_MOD=1e7;t.COUNTER_WRAP=1e4;t.URL_PARSE_BASE="ht"+"tp:"+"//as"+"ai.cc"},105:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:true});t.deonmessage=t.AsaiModel=t.AsaiWs=t.AsaiApi=t.AsaiWorker=void 0;var i=n(821);Object.defineProperty(t,"AsaiWorker",{enumerable:true,get:function(){return i.AsaiWorker}});var o=n(995);Object.defineProperty(t,"AsaiApi",{enumerable:true,get:function(){return o.AsaiApi}});var r=n(873);Object.defineProperty(t,"AsaiWs",{enumerable:true,get:function(){return r.AsaiWs}});var s=n(642);Object.defineProperty(t,"AsaiModel",{enumerable:true,get:function(){return s.AsaiModel}});var a=n(340);Object.defineProperty(t,"deonmessage",{enumerable:true,get:function(){return a.deonmessage}})},340:(e,t)=>{Object.defineProperty(t,"__esModule",{value:true});t.deonmessage=deonmessage;function deonmessage(e,t,n,i){if(n===void 0){n={}}try{var o=JSON.parse(e);if(!i||!(o===null||o===void 0?void 0:o.ty)){t(o);return}var r=o.ty;var s=n[r];if(!s){s=n[r]={s:e,v:o,t:1}}else if(s.s===e){if(s.t)s.t=0}else{s.s=e;s.v=o;if(!s.t)s.t=1}if(s.t){t(s.v)}}catch(n){t(e)}}}};var t={};function __nccwpck_require__(n){var i=t[n];if(i!==undefined){return i.exports}var o=t[n]={exports:{}};var r=true;try{e[n].call(o.exports,o,o.exports,__nccwpck_require__);r=false}finally{if(r)delete t[n]}return o.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var n={};(()=>{var e=n;Object.defineProperty(e,"__esModule",{value:true});e.AsaiModel=e.AsaiWs=e.AsaiApi=e.AsaiWorker=void 0;var t=__nccwpck_require__(105);Object.defineProperty(e,"AsaiWorker",{enumerable:true,get:function(){return t.AsaiWorker}});Object.defineProperty(e,"AsaiApi",{enumerable:true,get:function(){return t.AsaiApi}});Object.defineProperty(e,"AsaiWs",{enumerable:true,get:function(){return t.AsaiWs}});Object.defineProperty(e,"AsaiModel",{enumerable:true,get:function(){return t.AsaiModel}});e["default"]={AsaiWorker:t.AsaiWorker,AsaiApi:t.AsaiApi,AsaiWs:t.AsaiWs,AsaiModel:t.AsaiModel}})();module.exports=n})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asai-js-as",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
4
4
  "description": "asai for you",
5
5
  "author": "Asai",
6
6
  "license": "ISC",