@dcloudio/vue-cli-plugin-uni 2.0.1-alpha-34520220408002 → 2.0.1-alpha-34620220415002
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": "@dcloudio/vue-cli-plugin-uni",
|
|
3
|
-
"version": "2.0.1-alpha-
|
|
3
|
+
"version": "2.0.1-alpha-34620220415002",
|
|
4
4
|
"description": "uni-app plugin for vue-cli 3",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"author": "fxy060608",
|
|
18
18
|
"license": "Apache-2.0",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@dcloudio/uni-stat": "^2.0.1-alpha-
|
|
20
|
+
"@dcloudio/uni-stat": "^2.0.1-alpha-34620220415002",
|
|
21
21
|
"buffer-json": "^2.0.0",
|
|
22
22
|
"clone-deep": "^4.0.1",
|
|
23
23
|
"copy-webpack-plugin": "^5.1.1",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"wrap-loader": "^0.2.0",
|
|
40
40
|
"xregexp": "4.0.0"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "c2c5b0345d72c1cfb51645719ce260a5c1d0d0f7"
|
|
43
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{initVueI18n as e}from"@dcloudio/uni-i18n";"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function n(e,t,n){return e(n={path:t,exports:{},require:function(e,t){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==t&&n.path)}},n.exports),n.exports}var s=n((function(e,t){var n;e.exports=(n=n||function(e,t){var n=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),s={},r=s.lib={},o=r.Base={extend:function(e){var t=n(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},i=r.WordArray=o.extend({init:function(e,n){e=this.words=e||[],this.sigBytes=n!=t?n:4*e.length},toString:function(e){return(e||c).stringify(this)},concat:function(e){var t=this.words,n=e.words,s=this.sigBytes,r=e.sigBytes;if(this.clamp(),s%4)for(var o=0;o<r;o++){var i=n[o>>>2]>>>24-o%4*8&255;t[s+o>>>2]|=i<<24-(s+o)%4*8}else for(o=0;o<r;o+=4)t[s+o>>>2]=n[o>>>2];return this.sigBytes+=r,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n,s=[],r=function(t){t=t;var n=987654321,s=4294967295;return function(){var r=((n=36969*(65535&n)+(n>>16)&s)<<16)+(t=18e3*(65535&t)+(t>>16)&s)&s;return r/=4294967296,(r+=.5)*(e.random()>.5?1:-1)}},o=0;o<t;o+=4){var a=r(4294967296*(n||e.random()));n=987654071*a(),s.push(4294967296*a()|0)}return new i.init(s,t)}}),a=s.enc={},c=a.Hex={stringify:function(e){for(var t=e.words,n=e.sigBytes,s=[],r=0;r<n;r++){var o=t[r>>>2]>>>24-r%4*8&255;s.push((o>>>4).toString(16)),s.push((15&o).toString(16))}return s.join("")},parse:function(e){for(var t=e.length,n=[],s=0;s<t;s+=2)n[s>>>3]|=parseInt(e.substr(s,2),16)<<24-s%8*4;return new i.init(n,t/2)}},u=a.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,s=[],r=0;r<n;r++){var o=t[r>>>2]>>>24-r%4*8&255;s.push(String.fromCharCode(o))}return s.join("")},parse:function(e){for(var t=e.length,n=[],s=0;s<t;s++)n[s>>>2]|=(255&e.charCodeAt(s))<<24-s%4*8;return new i.init(n,t)}},h=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},l=r.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new i.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=h.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,s=n.words,r=n.sigBytes,o=this.blockSize,a=r/(4*o),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*o,u=e.min(4*c,r);if(c){for(var h=0;h<c;h+=o)this._doProcessBlock(s,h);var l=s.splice(0,c);n.sigBytes-=u}return new i.init(l,u)},clone:function(){var e=o.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});r.Hasher=l.extend({cfg:o.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){l.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new d.HMAC.init(e,n).finalize(t)}}});var d=s.algo={};return s}(Math),n)})),r=(n((function(e,t){var n;e.exports=(n=s,function(e){var t=n,s=t.lib,r=s.WordArray,o=s.Hasher,i=t.algo,a=[];!function(){for(var t=0;t<64;t++)a[t]=4294967296*e.abs(e.sin(t+1))|0}();var c=i.MD5=o.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var n=0;n<16;n++){var s=t+n,r=e[s];e[s]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8)}var o=this._hash.words,i=e[t+0],c=e[t+1],f=e[t+2],p=e[t+3],g=e[t+4],m=e[t+5],y=e[t+6],_=e[t+7],w=e[t+8],k=e[t+9],S=e[t+10],v=e[t+11],T=e[t+12],A=e[t+13],P=e[t+14],I=e[t+15],b=o[0],E=o[1],O=o[2],C=o[3];b=u(b,E,O,C,i,7,a[0]),C=u(C,b,E,O,c,12,a[1]),O=u(O,C,b,E,f,17,a[2]),E=u(E,O,C,b,p,22,a[3]),b=u(b,E,O,C,g,7,a[4]),C=u(C,b,E,O,m,12,a[5]),O=u(O,C,b,E,y,17,a[6]),E=u(E,O,C,b,_,22,a[7]),b=u(b,E,O,C,w,7,a[8]),C=u(C,b,E,O,k,12,a[9]),O=u(O,C,b,E,S,17,a[10]),E=u(E,O,C,b,v,22,a[11]),b=u(b,E,O,C,T,7,a[12]),C=u(C,b,E,O,A,12,a[13]),O=u(O,C,b,E,P,17,a[14]),b=h(b,E=u(E,O,C,b,I,22,a[15]),O,C,c,5,a[16]),C=h(C,b,E,O,y,9,a[17]),O=h(O,C,b,E,v,14,a[18]),E=h(E,O,C,b,i,20,a[19]),b=h(b,E,O,C,m,5,a[20]),C=h(C,b,E,O,S,9,a[21]),O=h(O,C,b,E,I,14,a[22]),E=h(E,O,C,b,g,20,a[23]),b=h(b,E,O,C,k,5,a[24]),C=h(C,b,E,O,P,9,a[25]),O=h(O,C,b,E,p,14,a[26]),E=h(E,O,C,b,w,20,a[27]),b=h(b,E,O,C,A,5,a[28]),C=h(C,b,E,O,f,9,a[29]),O=h(O,C,b,E,_,14,a[30]),b=l(b,E=h(E,O,C,b,T,20,a[31]),O,C,m,4,a[32]),C=l(C,b,E,O,w,11,a[33]),O=l(O,C,b,E,v,16,a[34]),E=l(E,O,C,b,P,23,a[35]),b=l(b,E,O,C,c,4,a[36]),C=l(C,b,E,O,g,11,a[37]),O=l(O,C,b,E,_,16,a[38]),E=l(E,O,C,b,S,23,a[39]),b=l(b,E,O,C,A,4,a[40]),C=l(C,b,E,O,i,11,a[41]),O=l(O,C,b,E,p,16,a[42]),E=l(E,O,C,b,y,23,a[43]),b=l(b,E,O,C,k,4,a[44]),C=l(C,b,E,O,T,11,a[45]),O=l(O,C,b,E,I,16,a[46]),b=d(b,E=l(E,O,C,b,f,23,a[47]),O,C,i,6,a[48]),C=d(C,b,E,O,_,10,a[49]),O=d(O,C,b,E,P,15,a[50]),E=d(E,O,C,b,m,21,a[51]),b=d(b,E,O,C,T,6,a[52]),C=d(C,b,E,O,p,10,a[53]),O=d(O,C,b,E,S,15,a[54]),E=d(E,O,C,b,c,21,a[55]),b=d(b,E,O,C,w,6,a[56]),C=d(C,b,E,O,I,10,a[57]),O=d(O,C,b,E,y,15,a[58]),E=d(E,O,C,b,A,21,a[59]),b=d(b,E,O,C,g,6,a[60]),C=d(C,b,E,O,v,10,a[61]),O=d(O,C,b,E,f,15,a[62]),E=d(E,O,C,b,k,21,a[63]),o[0]=o[0]+b|0,o[1]=o[1]+E|0,o[2]=o[2]+O|0,o[3]=o[3]+C|0},_doFinalize:function(){var t=this._data,n=t.words,s=8*this._nDataBytes,r=8*t.sigBytes;n[r>>>5]|=128<<24-r%32;var o=e.floor(s/4294967296),i=s;n[15+(r+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),n[14+(r+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t.sigBytes=4*(n.length+1),this._process();for(var a=this._hash,c=a.words,u=0;u<4;u++){var h=c[u];c[u]=16711935&(h<<8|h>>>24)|4278255360&(h<<24|h>>>8)}return a},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,n,s,r,o,i){var a=e+(t&n|~t&s)+r+i;return(a<<o|a>>>32-o)+t}function h(e,t,n,s,r,o,i){var a=e+(t&s|n&~s)+r+i;return(a<<o|a>>>32-o)+t}function l(e,t,n,s,r,o,i){var a=e+(t^n^s)+r+i;return(a<<o|a>>>32-o)+t}function d(e,t,n,s,r,o,i){var a=e+(n^(t|~s))+r+i;return(a<<o|a>>>32-o)+t}t.MD5=o._createHelper(c),t.HmacMD5=o._createHmacHelper(c)}(Math),n.MD5)})),n((function(e,t){var n,r,o;e.exports=(r=(n=s).lib.Base,o=n.enc.Utf8,void(n.algo.HMAC=r.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=o.parse(t));var n=e.blockSize,s=4*n;t.sigBytes>s&&(t=e.finalize(t)),t.clamp();for(var r=this._oKey=t.clone(),i=this._iKey=t.clone(),a=r.words,c=i.words,u=0;u<n;u++)a[u]^=1549556828,c[u]^=909522486;r.sigBytes=i.sigBytes=s,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,n=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(n))}})))})),n((function(e,t){e.exports=s.HmacMD5})));function o(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function i(e){return"object"===o(e)}function a(e){return e&&"string"==typeof e?JSON.parse(e):e}const c="development"===process.env.NODE_ENV,u=process.env.VUE_APP_PLATFORM,h=a(process.env.UNICLOUD_DEBUG),l=a(process.env.UNI_CLOUD_PROVIDER),d=process.env.RUN_BY_HBUILDERX;let f="";try{{const e=require("uni-stat-config").default||require("uni-stat-config");f=e.appid}}catch(e){}let p={};function g(e,t={}){var n,s;return n=p,s=e,Object.prototype.hasOwnProperty.call(n,s)||(p[e]=t),p[e]}"app-plus"===u&&(p=uni._globalUniCloudObj?uni._globalUniCloudObj:uni._globalUniCloudObj={});const m=["invoke","success","fail","complete"],y=g("_globalUniCloudInterceptor");function _(e,t){y[e]||(y[e]={}),i(t)&&Object.keys(t).forEach((n=>{m.indexOf(n)>-1&&function(e,t,n){let s=y[e][t];s||(s=y[e][t]=[]),-1===s.indexOf(n)&&"function"==typeof n&&s.push(n)}(e,n,t[n])}))}function w(e,t){y[e]||(y[e]={}),i(t)?Object.keys(t).forEach((n=>{m.indexOf(n)>-1&&function(e,t,n){const s=y[e][t];if(!s)return;const r=s.indexOf(n);r>-1&&s.splice(r,1)}(e,n,t[n])})):delete y[e]}function k(e,t){return e&&0!==e.length?e.reduce(((e,n)=>e.then((()=>n(t)))),Promise.resolve()):Promise.resolve()}function S(e,t){return y[e]&&y[e][t]||[]}function v(e,t){return t?function(n){const s="callFunction"===t&&"DCloud-clientDB"===(n&&n.name);let r;r=this.isReady?Promise.resolve():this.initUniCloud,n=n||{};const o=r.then((()=>s?Promise.resolve():k(S(t,"invoke"),n))).then((()=>e.call(this,n))).then((e=>s?Promise.resolve(e):k(S(t,"success"),e).then((()=>k(S(t,"complete"),e))).then((()=>Promise.resolve(e)))),(e=>s?Promise.reject(e):k(S(t,"fail"),e).then((()=>k(S(t,"complete"),e))).then((()=>Promise.reject(e)))));if(!(n.success||n.fail||n.complete))return o;o.then((e=>{n.success&&n.success(e),n.complete&&n.complete(e)}),(e=>{n.fail&&n.fail(e),n.complete&&n.complete(e)}))}:function(t){if(!((t=t||{}).success||t.fail||t.complete))return e.call(this,t);e.call(this,t).then((e=>{t.success&&t.success(e),t.complete&&t.complete(e)}),(e=>{t.fail&&t.fail(e),t.complete&&t.complete(e)}))}}class T extends Error{constructor(e){super(e.message),this.errMsg=e.message||"",Object.defineProperties(this,{code:{get:()=>e.code},errCode:{get:()=>e.code},requestId:{get:()=>e.requestId},message:{get(){return this.errMsg},set(e){this.errMsg=e}}})}}let A;function P(){const e=uni.getLocale&&uni.getLocale()||"en";if(A)return{...A,LOCALE:e};const{deviceId:t,platform:n}=uni.getSystemInfoSync();return A={PLATFORM:u,OS:n,APPID:f,DEVICEID:t,CLIENT_SDK_VERSION:"1.0.23"},{...A,LOCALE:e}}var I={sign:function(e,t){let n="";return Object.keys(e).sort().forEach((function(t){e[t]&&(n=n+"&"+t+"="+e[t])})),n=n.slice(1),r(n,t).toString()},wrappedRequest:function(e,t){return new Promise(((n,s)=>{t(Object.assign(e,{complete(e){e||(e={}),c&&"h5"===u&&e.errMsg&&0===e.errMsg.indexOf("request:fail")&&console.warn("发布H5,需要在uniCloud后台操作,绑定安全域名,否则会因为跨域问题而无法访问。教程参考:https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5");const t=e.data&&e.data.header&&e.data.header["x-serverless-request-id"]||e.header&&e.header["request-id"];if(!e.statusCode||e.statusCode>=400)return s(new T({code:"SYS_ERR",message:e.errMsg||"request:fail",requestId:t}));const r=e.data;if(r.error)return s(new T({code:r.error.code,message:r.error.message,requestId:t}));r.result=r.data,r.requestId=t,delete r.data,n(r)}}))}))}};var b={request:e=>uni.request(e),uploadFile:e=>uni.uploadFile(e),setStorageSync:(e,t)=>uni.setStorageSync(e,t),getStorageSync:e=>uni.getStorageSync(e),removeStorageSync:e=>uni.removeStorageSync(e),clearStorageSync:()=>uni.clearStorageSync()},E={"uniCloud.init.paramRequired":"{param} required","uniCloud.uploadFile.fileError":"filePath should be instance of File"};const{t:O}=e({"zh-Hans":{"uniCloud.init.paramRequired":"缺少参数:{param}","uniCloud.uploadFile.fileError":"filePath应为File对象"},"zh-Hant":{"uniCloud.init.paramRequired":"缺少参数:{param}","uniCloud.uploadFile.fileError":"filePath应为File对象"},en:E,fr:{"uniCloud.init.paramRequired":"{param} required","uniCloud.uploadFile.fileError":"filePath should be instance of File"},es:{"uniCloud.init.paramRequired":"{param} required","uniCloud.uploadFile.fileError":"filePath should be instance of File"},ja:E},"zh-Hans");var C=class{constructor(e){["spaceId","clientSecret"].forEach((t=>{if(!Object.prototype.hasOwnProperty.call(e,t))throw new Error(O("uniCloud.init.paramRequired",{param:t}))})),this.config=Object.assign({},{endpoint:"https://api.bspapp.com"},e),this.config.provider="aliyun",this.config.requestUrl=this.config.endpoint+"/client",this.config.envType=this.config.envType||"public",this.config.accessTokenKey="access_token_"+this.config.spaceId,this.adapter=b,this._getAccessTokenPromise=null,this._getAccessTokenPromiseStatus=null}get hasAccessToken(){return!!this.accessToken}setAccessToken(e){this.accessToken=e}requestWrapped(e){return I.wrappedRequest(e,this.adapter.request)}requestAuth(e){return this.requestWrapped(e)}request(e,t){return Promise.resolve().then((()=>this.hasAccessToken?t?this.requestWrapped(e):this.requestWrapped(e).catch((t=>new Promise(((e,n)=>{!t||"GATEWAY_INVALID_TOKEN"!==t.code&&"InvalidParameter.InvalidToken"!==t.code?n(t):e()})).then((()=>this.getAccessToken())).then((()=>{const t=this.rebuildRequest(e);return this.request(t,!0)})))):this.getAccessToken().then((()=>{const t=this.rebuildRequest(e);return this.request(t,!0)}))))}rebuildRequest(e){const t=Object.assign({},e);return t.data.token=this.accessToken,t.header["x-basement-token"]=this.accessToken,t.header["x-serverless-sign"]=I.sign(t.data,this.config.clientSecret),t}setupRequest(e,t){const n=Object.assign({},e,{spaceId:this.config.spaceId,timestamp:Date.now()}),s={"Content-Type":"application/json"};return"auth"!==t&&(n.token=this.accessToken,s["x-basement-token"]=this.accessToken),s["x-serverless-sign"]=I.sign(n,this.config.clientSecret),{url:this.config.requestUrl,method:"POST",data:n,dataType:"json",header:s}}getAccessToken(){if("pending"===this._getAccessTokenPromiseStatus)return this._getAccessTokenPromise;this._getAccessTokenPromiseStatus="pending";return this._getAccessTokenPromise=this.requestAuth(this.setupRequest({method:"serverless.auth.user.anonymousAuthorize",params:"{}"},"auth")).then((e=>new Promise(((t,n)=>{e.result&&e.result.accessToken?(this.setAccessToken(e.result.accessToken),this._getAccessTokenPromiseStatus="fulfilled",t(this.accessToken)):(this._getAccessTokenPromiseStatus="rejected",n(new T({code:"AUTH_FAILED",message:"获取accessToken失败"})))}))),(e=>(this._getAccessTokenPromiseStatus="rejected",Promise.reject(e)))),this._getAccessTokenPromise}authorize(){this.getAccessToken()}callFunction(e){const t={method:"serverless.function.runtime.invoke",params:JSON.stringify({functionTarget:e.name,functionArgs:e.data||{}})};return this.request(this.setupRequest(t))}getOSSUploadOptionsFromPath(e){const t={method:"serverless.file.resource.generateProximalSign",params:JSON.stringify(e)};return this.request(this.setupRequest(t))}uploadFileToOSS({url:e,formData:t,name:n,filePath:s,fileType:r,onUploadProgress:o}){return new Promise(((i,a)=>{const c=this.adapter.uploadFile({url:e,formData:t,name:n,filePath:s,fileType:r,header:{"X-OSS-server-side-encrpytion":"AES256"},success(e){e&&e.statusCode<400?i(e):a(new T({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){a(new T({code:e.code||"UPLOAD_FAILED",message:e.message||e.errMsg||"文件上传失败"}))}});"function"==typeof o&&c&&"function"==typeof c.onProgressUpdate&&c.onProgressUpdate((e=>{o({loaded:e.totalBytesSent,total:e.totalBytesExpectedToSend})}))}))}reportOSSUpload(e){const t={method:"serverless.file.resource.report",params:JSON.stringify(e)};return this.request(this.setupRequest(t))}uploadFile({filePath:e,cloudPath:t,fileType:n="image",onUploadProgress:s,config:r}){if("string"!==o(t))throw new T({code:"INVALID_PARAM",message:"cloudPath必须为字符串类型"});if(!(t=t.trim()))throw new T({code:"CLOUDPATH_REQUIRED",message:"cloudPath不可为空"});if(/:\/\//.test(t))throw new T({code:"INVALID_PARAM",message:"cloudPath不合法"});const i=r&&r.envType||this.config.envType;let a,c;return this.getOSSUploadOptionsFromPath({env:i,filename:t}).then((t=>{const r=t.result;a=r.id,c="https://"+r.cdnDomain+"/"+r.ossPath;const o={url:"https://"+r.host,formData:{"Cache-Control":"max-age=2592000","Content-Disposition":"attachment",OSSAccessKeyId:r.accessKeyId,Signature:r.signature,host:r.host,id:a,key:r.ossPath,policy:r.policy,success_action_status:200},fileName:"file",name:"file",filePath:e,fileType:n};return this.uploadFileToOSS(Object.assign({},o,{onUploadProgress:s}))})).then((()=>this.reportOSSUpload({id:a}))).then((t=>new Promise(((n,s)=>{t.success?n({success:!0,filePath:e,fileID:c}):s(new T({code:"UPLOAD_FAILED",message:"文件上传失败"}))}))))}deleteFile({fileList:e}){const t={method:"serverless.file.resource.delete",params:JSON.stringify({id:e[0]})};return this.request(this.setupRequest(t))}getTempFileURL({fileList:e}={}){return new Promise(((t,n)=>{Array.isArray(e)&&0!==e.length||n(new T({code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"})),t({fileList:e.map((e=>({fileID:e,tempFileURL:e})))})}))}};var U={init(e){const t=new C(e),n={signInAnonymously:function(){return t.authorize()},getLoginState:function(){return Promise.resolve(!1)}};return t.auth=function(){return n},t.customAuth=t.auth,t}};const x="undefined"!=typeof location&&"http:"===location.protocol?"http:":"https:";var D;!function(e){e.local="local",e.none="none",e.session="session"}(D||(D={}));var q=function(){};const R=()=>{let e;if(!Promise){e=()=>{},e.promise={};const t=()=>{throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(e.promise,"then",{get:t}),Object.defineProperty(e.promise,"catch",{get:t}),e}const t=new Promise(((t,n)=>{e=(e,s)=>e?n(e):t(s)}));return e.promise=t,e};function F(e){return void 0===e}function L(e){return"[object Null]"===Object.prototype.toString.call(e)}var N;function $(e){const t=(n=e,"[object Array]"===Object.prototype.toString.call(n)?e:[e]);var n;for(const e of t){const{isMatch:t,genAdapter:n,runtime:s}=e;if(t())return{adapter:n(),runtime:s}}}!function(e){e.WEB="web",e.WX_MP="wx_mp"}(N||(N={}));const M={adapter:null,runtime:void 0},j=["anonymousUuidKey"];class B extends q{constructor(){super(),M.adapter.root.tcbObject||(M.adapter.root.tcbObject={})}setItem(e,t){M.adapter.root.tcbObject[e]=t}getItem(e){return M.adapter.root.tcbObject[e]}removeItem(e){delete M.adapter.root.tcbObject[e]}clear(){delete M.adapter.root.tcbObject}}function K(e,t){switch(e){case"local":return t.localStorage||new B;case"none":return new B;default:return t.sessionStorage||new B}}class H{constructor(e){if(!this._storage){this._persistence=M.adapter.primaryStorage||e.persistence,this._storage=K(this._persistence,M.adapter);const t=`access_token_${e.env}`,n=`access_token_expire_${e.env}`,s=`refresh_token_${e.env}`,r=`anonymous_uuid_${e.env}`,o=`login_type_${e.env}`,i=`user_info_${e.env}`;this.keys={accessTokenKey:t,accessTokenExpireKey:n,refreshTokenKey:s,anonymousUuidKey:r,loginTypeKey:o,userInfoKey:i}}}updatePersistence(e){if(e===this._persistence)return;const t="local"===this._persistence;this._persistence=e;const n=K(e,M.adapter);for(const e in this.keys){const s=this.keys[e];if(t&&j.includes(e))continue;const r=this._storage.getItem(s);F(r)||L(r)||(n.setItem(s,r),this._storage.removeItem(s))}this._storage=n}setStore(e,t,n){if(!this._storage)return;const s={version:n||"localCachev1",content:t},r=JSON.stringify(s);try{this._storage.setItem(e,r)}catch(e){throw e}}getStore(e,t){try{if(!this._storage)return}catch(e){return""}t=t||"localCachev1";const n=this._storage.getItem(e);if(!n)return"";if(n.indexOf(t)>=0){return JSON.parse(n).content}return""}removeStore(e){this._storage.removeItem(e)}}const W={},z={};function J(e){return W[e]}class V{constructor(e,t){this.data=t||null,this.name=e}}class Y extends V{constructor(e,t){super("error",{error:e,data:t}),this.error=e}}const X=new class{constructor(){this._listeners={}}on(e,t){return function(e,t,n){n[e]=n[e]||[],n[e].push(t)}(e,t,this._listeners),this}off(e,t){return function(e,t,n){if(n&&n[e]){const s=n[e].indexOf(t);-1!==s&&n[e].splice(s,1)}}(e,t,this._listeners),this}fire(e,t){if(e instanceof Y)return console.error(e.error),this;const n="string"==typeof e?new V(e,t||{}):e;const s=n.name;if(this._listens(s)){n.target=this;const e=this._listeners[s]?[...this._listeners[s]]:[];for(const t of e)t.call(this,n)}return this}_listens(e){return this._listeners[e]&&this._listeners[e].length>0}};function G(e,t){X.on(e,t)}function Q(e,t={}){X.fire(e,t)}function Z(e,t){X.off(e,t)}const ee="loginStateChanged",te="loginStateExpire",ne="loginTypeChanged",se="anonymousConverted",re="refreshAccessToken";var oe;!function(e){e.ANONYMOUS="ANONYMOUS",e.WECHAT="WECHAT",e.WECHAT_PUBLIC="WECHAT-PUBLIC",e.WECHAT_OPEN="WECHAT-OPEN",e.CUSTOM="CUSTOM",e.EMAIL="EMAIL",e.USERNAME="USERNAME",e.NULL="NULL"}(oe||(oe={}));const ie=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"],ae={"X-SDK-Version":"1.3.5"};function ce(e,t,n){const s=e[t];e[t]=function(t){const r={},o={};n.forEach((n=>{const{data:s,headers:i}=n.call(e,t);Object.assign(r,s),Object.assign(o,i)}));const i=t.data;return i&&(()=>{var e;if(e=i,"[object FormData]"!==Object.prototype.toString.call(e))t.data={...i,...r};else for(const e in r)i.append(e,r[e])})(),t.headers={...t.headers||{},...o},s.call(e,t)}}function ue(){const e=Math.random().toString(16).slice(2);return{data:{seqId:e},headers:{...ae,"x-seqid":e}}}class he{constructor(e={}){var t;this.config=e,this._reqClass=new M.adapter.reqClass({timeout:this.config.timeout,timeoutMsg:`请求在${this.config.timeout/1e3}s内未完成,已中断`,restrictedMethods:["post"]}),this._cache=J(this.config.env),this._localCache=(t=this.config.env,z[t]),ce(this._reqClass,"post",[ue]),ce(this._reqClass,"upload",[ue]),ce(this._reqClass,"download",[ue])}async post(e){return await this._reqClass.post(e)}async upload(e){return await this._reqClass.upload(e)}async download(e){return await this._reqClass.download(e)}async refreshAccessToken(){let e,t;this._refreshAccessTokenPromise||(this._refreshAccessTokenPromise=this._refreshAccessToken());try{e=await this._refreshAccessTokenPromise}catch(e){t=e}if(this._refreshAccessTokenPromise=null,this._shouldRefreshAccessTokenHook=null,t)throw t;return e}async _refreshAccessToken(){const{accessTokenKey:e,accessTokenExpireKey:t,refreshTokenKey:n,loginTypeKey:s,anonymousUuidKey:r}=this._cache.keys;this._cache.removeStore(e),this._cache.removeStore(t);let o=this._cache.getStore(n);if(!o)throw new Error("未登录CloudBase");const i={refresh_token:o},a=await this.request("auth.fetchAccessTokenWithRefreshToken",i);if(a.data.code){const{code:e}=a.data;if("SIGN_PARAM_INVALID"===e||"REFRESH_TOKEN_EXPIRED"===e||"INVALID_REFRESH_TOKEN"===e){if(this._cache.getStore(s)===oe.ANONYMOUS&&"INVALID_REFRESH_TOKEN"===e){const e=this._cache.getStore(r),t=this._cache.getStore(n),s=await this.send("auth.signInAnonymously",{anonymous_uuid:e,refresh_token:t});return this.setRefreshToken(s.refresh_token),this._refreshAccessToken()}Q(te),this._cache.removeStore(n)}throw new Error(`刷新access token失败:${a.data.code}`)}if(a.data.access_token)return Q(re),this._cache.setStore(e,a.data.access_token),this._cache.setStore(t,a.data.access_token_expire+Date.now()),{accessToken:a.data.access_token,accessTokenExpire:a.data.access_token_expire};a.data.refresh_token&&(this._cache.removeStore(n),this._cache.setStore(n,a.data.refresh_token),this._refreshAccessToken())}async getAccessToken(){const{accessTokenKey:e,accessTokenExpireKey:t,refreshTokenKey:n}=this._cache.keys;if(!this._cache.getStore(n))throw new Error("refresh token不存在,登录状态异常");let s=this._cache.getStore(e),r=this._cache.getStore(t),o=!0;return this._shouldRefreshAccessTokenHook&&!await this._shouldRefreshAccessTokenHook(s,r)&&(o=!1),(!s||!r||r<Date.now())&&o?this.refreshAccessToken():{accessToken:s,accessTokenExpire:r}}async request(e,t,n){const s=`x-tcb-trace_${this.config.env}`;let r="application/x-www-form-urlencoded";const o={action:e,env:this.config.env,dataVersion:"2019-08-16",...t};if(-1===ie.indexOf(e)){const{refreshTokenKey:e}=this._cache.keys;this._cache.getStore(e)&&(o.access_token=(await this.getAccessToken()).accessToken)}let i;if("storage.uploadFile"===e){i=new FormData;for(let e in i)i.hasOwnProperty(e)&&void 0!==i[e]&&i.append(e,o[e]);r="multipart/form-data"}else{r="application/json",i={};for(let e in o)void 0!==o[e]&&(i[e]=o[e])}let a={headers:{"content-type":r}};n&&n.onUploadProgress&&(a.onUploadProgress=n.onUploadProgress);const c=this._localCache.getStore(s);c&&(a.headers["X-TCB-Trace"]=c);const{parse:u,inQuery:h,search:l}=t;let d={env:this.config.env};u&&(d.parse=!0),h&&(d={...h,...d});let f=function(e,t,n={}){const s=/\?/.test(t);let r="";for(let e in n)""===r?!s&&(t+="?"):r+="&",r+=`${e}=${encodeURIComponent(n[e])}`;return/^http(s)?\:\/\//.test(t+=r)?t:`${e}${t}`}(x,"//tcb-api.tencentcloudapi.com/web",d);l&&(f+=l);const p=await this.post({url:f,data:i,...a}),g=p.header&&p.header["x-tcb-trace"];if(g&&this._localCache.setStore(s,g),200!==Number(p.status)&&200!==Number(p.statusCode)||!p.data)throw new Error("network request error");return p}async send(e,t={}){const n=await this.request(e,t,{onUploadProgress:t.onUploadProgress});if("ACCESS_TOKEN_EXPIRED"===n.data.code&&-1===ie.indexOf(e)){await this.refreshAccessToken();const n=await this.request(e,t,{onUploadProgress:t.onUploadProgress});if(n.data.code)throw new Error(`[${n.data.code}] ${n.data.message}`);return n.data}if(n.data.code)throw new Error(`[${n.data.code}] ${n.data.message}`);return n.data}setRefreshToken(e){const{accessTokenKey:t,accessTokenExpireKey:n,refreshTokenKey:s}=this._cache.keys;this._cache.removeStore(t),this._cache.removeStore(n),this._cache.setStore(s,e)}}const le={};function de(e){return le[e]}class fe{constructor(e){this.config=e,this._cache=J(e.env),this._request=de(e.env)}setRefreshToken(e){const{accessTokenKey:t,accessTokenExpireKey:n,refreshTokenKey:s}=this._cache.keys;this._cache.removeStore(t),this._cache.removeStore(n),this._cache.setStore(s,e)}setAccessToken(e,t){const{accessTokenKey:n,accessTokenExpireKey:s}=this._cache.keys;this._cache.setStore(n,e),this._cache.setStore(s,t)}async refreshUserInfo(){const{data:e}=await this._request.send("auth.getUserInfo",{});return this.setLocalUserInfo(e),e}setLocalUserInfo(e){const{userInfoKey:t}=this._cache.keys;this._cache.setStore(t,e)}}class pe{constructor(e){if(!e)throw new Error("envId is not defined");this._envId=e,this._cache=J(this._envId),this._request=de(this._envId),this.setUserInfo()}linkWithTicket(e){if("string"!=typeof e)throw new Error("ticket must be string");return this._request.send("auth.linkWithTicket",{ticket:e})}linkWithRedirect(e){e.signInWithRedirect()}updatePassword(e,t){return this._request.send("auth.updatePassword",{oldPassword:t,newPassword:e})}updateEmail(e){return this._request.send("auth.updateEmail",{newEmail:e})}updateUsername(e){if("string"!=typeof e)throw new Error("username must be a string");return this._request.send("auth.updateUsername",{username:e})}async getLinkedUidList(){const{data:e}=await this._request.send("auth.getLinkedUidList",{});let t=!1;const{users:n}=e;return n.forEach((e=>{e.wxOpenId&&e.wxPublicId&&(t=!0)})),{users:n,hasPrimaryUid:t}}setPrimaryUid(e){return this._request.send("auth.setPrimaryUid",{uid:e})}unlink(e){return this._request.send("auth.unlink",{platform:e})}async update(e){const{nickName:t,gender:n,avatarUrl:s,province:r,country:o,city:i}=e,{data:a}=await this._request.send("auth.updateUserInfo",{nickName:t,gender:n,avatarUrl:s,province:r,country:o,city:i});this.setLocalUserInfo(a)}async refresh(){const{data:e}=await this._request.send("auth.getUserInfo",{});return this.setLocalUserInfo(e),e}setUserInfo(){const{userInfoKey:e}=this._cache.keys,t=this._cache.getStore(e);["uid","loginType","openid","wxOpenId","wxPublicId","unionId","qqMiniOpenId","email","hasPassword","customUserId","nickName","gender","avatarUrl"].forEach((e=>{this[e]=t[e]})),this.location={country:t.country,province:t.province,city:t.city}}setLocalUserInfo(e){const{userInfoKey:t}=this._cache.keys;this._cache.setStore(t,e),this.setUserInfo()}}class ge{constructor(e){if(!e)throw new Error("envId is not defined");this._cache=J(e);const{refreshTokenKey:t,accessTokenKey:n,accessTokenExpireKey:s}=this._cache.keys,r=this._cache.getStore(t),o=this._cache.getStore(n),i=this._cache.getStore(s);this.credential={refreshToken:r,accessToken:o,accessTokenExpire:i},this.user=new pe(e)}get isAnonymousAuth(){return this.loginType===oe.ANONYMOUS}get isCustomAuth(){return this.loginType===oe.CUSTOM}get isWeixinAuth(){return this.loginType===oe.WECHAT||this.loginType===oe.WECHAT_OPEN||this.loginType===oe.WECHAT_PUBLIC}get loginType(){return this._cache.getStore(this._cache.keys.loginTypeKey)}}class me extends fe{async signIn(){this._cache.updatePersistence("local");const{anonymousUuidKey:e,refreshTokenKey:t}=this._cache.keys,n=this._cache.getStore(e)||void 0,s=this._cache.getStore(t)||void 0,r=await this._request.send("auth.signInAnonymously",{anonymous_uuid:n,refresh_token:s});if(r.uuid&&r.refresh_token){this._setAnonymousUUID(r.uuid),this.setRefreshToken(r.refresh_token),await this._request.refreshAccessToken(),Q(ee),Q(ne,{env:this.config.env,loginType:oe.ANONYMOUS,persistence:"local"});const e=new ge(this.config.env);return await e.user.refresh(),e}throw new Error("匿名登录失败")}async linkAndRetrieveDataWithTicket(e){const{anonymousUuidKey:t,refreshTokenKey:n}=this._cache.keys,s=this._cache.getStore(t),r=this._cache.getStore(n),o=await this._request.send("auth.linkAndRetrieveDataWithTicket",{anonymous_uuid:s,refresh_token:r,ticket:e});if(o.refresh_token)return this._clearAnonymousUUID(),this.setRefreshToken(o.refresh_token),await this._request.refreshAccessToken(),Q(se,{env:this.config.env}),Q(ne,{loginType:oe.CUSTOM,persistence:"local"}),{credential:{refreshToken:o.refresh_token}};throw new Error("匿名转化失败")}_setAnonymousUUID(e){const{anonymousUuidKey:t,loginTypeKey:n}=this._cache.keys;this._cache.removeStore(t),this._cache.setStore(t,e),this._cache.setStore(n,oe.ANONYMOUS)}_clearAnonymousUUID(){this._cache.removeStore(this._cache.keys.anonymousUuidKey)}}class ye extends fe{async signIn(e){if("string"!=typeof e)throw new Error("ticket must be a string");const{refreshTokenKey:t}=this._cache.keys,n=await this._request.send("auth.signInWithTicket",{ticket:e,refresh_token:this._cache.getStore(t)||""});if(n.refresh_token)return this.setRefreshToken(n.refresh_token),await this._request.refreshAccessToken(),Q(ee),Q(ne,{env:this.config.env,loginType:oe.CUSTOM,persistence:this.config.persistence}),await this.refreshUserInfo(),new ge(this.config.env);throw new Error("自定义登录失败")}}class _e extends fe{async signIn(e,t){if("string"!=typeof e)throw new Error("email must be a string");const{refreshTokenKey:n}=this._cache.keys,s=await this._request.send("auth.signIn",{loginType:"EMAIL",email:e,password:t,refresh_token:this._cache.getStore(n)||""}),{refresh_token:r,access_token:o,access_token_expire:i}=s;if(r)return this.setRefreshToken(r),o&&i?this.setAccessToken(o,i):await this._request.refreshAccessToken(),await this.refreshUserInfo(),Q(ee),Q(ne,{env:this.config.env,loginType:oe.EMAIL,persistence:this.config.persistence}),new ge(this.config.env);throw s.code?new Error(`邮箱登录失败: [${s.code}] ${s.message}`):new Error("邮箱登录失败")}async activate(e){return this._request.send("auth.activateEndUserMail",{token:e})}async resetPasswordWithToken(e,t){return this._request.send("auth.resetPasswordWithToken",{token:e,newPassword:t})}}class we extends fe{async signIn(e,t){if("string"!=typeof e)throw new Error("username must be a string");"string"!=typeof t&&(t="",console.warn("password is empty"));const{refreshTokenKey:n}=this._cache.keys,s=await this._request.send("auth.signIn",{loginType:oe.USERNAME,username:e,password:t,refresh_token:this._cache.getStore(n)||""}),{refresh_token:r,access_token_expire:o,access_token:i}=s;if(r)return this.setRefreshToken(r),i&&o?this.setAccessToken(i,o):await this._request.refreshAccessToken(),await this.refreshUserInfo(),Q(ee),Q(ne,{env:this.config.env,loginType:oe.USERNAME,persistence:this.config.persistence}),new ge(this.config.env);throw s.code?new Error(`用户名密码登录失败: [${s.code}] ${s.message}`):new Error("用户名密码登录失败")}}class ke{constructor(e){this.config=e,this._cache=J(e.env),this._request=de(e.env),this._onAnonymousConverted=this._onAnonymousConverted.bind(this),this._onLoginTypeChanged=this._onLoginTypeChanged.bind(this),G(ne,this._onLoginTypeChanged)}get currentUser(){const e=this.hasLoginState();return e&&e.user||null}get loginType(){return this._cache.getStore(this._cache.keys.loginTypeKey)}anonymousAuthProvider(){return new me(this.config)}customAuthProvider(){return new ye(this.config)}emailAuthProvider(){return new _e(this.config)}usernameAuthProvider(){return new we(this.config)}async signInAnonymously(){return new me(this.config).signIn()}async signInWithEmailAndPassword(e,t){return new _e(this.config).signIn(e,t)}signInWithUsernameAndPassword(e,t){return new we(this.config).signIn(e,t)}async linkAndRetrieveDataWithTicket(e){this._anonymousAuthProvider||(this._anonymousAuthProvider=new me(this.config)),G(se,this._onAnonymousConverted);return await this._anonymousAuthProvider.linkAndRetrieveDataWithTicket(e)}async signOut(){if(this.loginType===oe.ANONYMOUS)throw new Error("匿名用户不支持登出操作");const{refreshTokenKey:e,accessTokenKey:t,accessTokenExpireKey:n}=this._cache.keys,s=this._cache.getStore(e);if(!s)return;const r=await this._request.send("auth.logout",{refresh_token:s});return this._cache.removeStore(e),this._cache.removeStore(t),this._cache.removeStore(n),Q(ee),Q(ne,{env:this.config.env,loginType:oe.NULL,persistence:this.config.persistence}),r}async signUpWithEmailAndPassword(e,t){return this._request.send("auth.signUpWithEmailAndPassword",{email:e,password:t})}async sendPasswordResetEmail(e){return this._request.send("auth.sendPasswordResetEmail",{email:e})}onLoginStateChanged(e){G(ee,(()=>{const t=this.hasLoginState();e.call(this,t)}));const t=this.hasLoginState();e.call(this,t)}onLoginStateExpired(e){G(te,e.bind(this))}onAccessTokenRefreshed(e){G(re,e.bind(this))}onAnonymousConverted(e){G(se,e.bind(this))}onLoginTypeChanged(e){G(ne,(()=>{const t=this.hasLoginState();e.call(this,t)}))}async getAccessToken(){return{accessToken:(await this._request.getAccessToken()).accessToken,env:this.config.env}}hasLoginState(){const{refreshTokenKey:e}=this._cache.keys;return this._cache.getStore(e)?new ge(this.config.env):null}async isUsernameRegistered(e){if("string"!=typeof e)throw new Error("username must be a string");const{data:t}=await this._request.send("auth.isUsernameRegistered",{username:e});return t&&t.isRegistered}getLoginState(){return Promise.resolve(this.hasLoginState())}async signInWithTicket(e){return new ye(this.config).signIn(e)}shouldRefreshAccessToken(e){this._request._shouldRefreshAccessTokenHook=e.bind(this)}getUserInfo(){return this._request.send("auth.getUserInfo",{}).then((e=>e.code?e:{...e.data,requestId:e.seqId}))}getAuthHeader(){const{refreshTokenKey:e,accessTokenKey:t}=this._cache.keys,n=this._cache.getStore(e);return{"x-cloudbase-credentials":this._cache.getStore(t)+"/@@/"+n}}_onAnonymousConverted(e){const{env:t}=e.data;t===this.config.env&&this._cache.updatePersistence(this.config.persistence)}_onLoginTypeChanged(e){const{loginType:t,persistence:n,env:s}=e.data;s===this.config.env&&(this._cache.updatePersistence(n),this._cache.setStore(this._cache.keys.loginTypeKey,t))}}const Se=function(e,t){t=t||R();const n=de(this.config.env),{cloudPath:s,filePath:r,onUploadProgress:o,fileType:i="image"}=e;return n.send("storage.getUploadMetadata",{path:s}).then((e=>{const{data:{url:a,authorization:c,token:u,fileId:h,cosFileId:l},requestId:d}=e,f={key:s,signature:c,"x-cos-meta-fileid":l,success_action_status:"201","x-cos-security-token":u};n.upload({url:a,data:f,file:r,name:s,fileType:i,onUploadProgress:o}).then((e=>{201===e.statusCode?t(null,{fileID:h,requestId:d}):t(new Error(`STORAGE_REQUEST_FAIL: ${e.data}`))})).catch((e=>{t(e)}))})).catch((e=>{t(e)})),t.promise},ve=function(e,t){t=t||R();const n=de(this.config.env),{cloudPath:s}=e;return n.send("storage.getUploadMetadata",{path:s}).then((e=>{t(null,e)})).catch((e=>{t(e)})),t.promise},Te=function({fileList:e},t){if(t=t||R(),!e||!Array.isArray(e))return{code:"INVALID_PARAM",message:"fileList必须是非空的数组"};for(let t of e)if(!t||"string"!=typeof t)return{code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"};const n={fileid_list:e};return de(this.config.env).send("storage.batchDeleteFile",n).then((e=>{e.code?t(null,e):t(null,{fileList:e.data.delete_list,requestId:e.requestId})})).catch((e=>{t(e)})),t.promise},Ae=function({fileList:e},t){t=t||R(),e&&Array.isArray(e)||t(null,{code:"INVALID_PARAM",message:"fileList必须是非空的数组"});let n=[];for(let s of e)"object"==typeof s?(s.hasOwnProperty("fileID")&&s.hasOwnProperty("maxAge")||t(null,{code:"INVALID_PARAM",message:"fileList的元素必须是包含fileID和maxAge的对象"}),n.push({fileid:s.fileID,max_age:s.maxAge})):"string"==typeof s?n.push({fileid:s}):t(null,{code:"INVALID_PARAM",message:"fileList的元素必须是字符串"});const s={file_list:n};return de(this.config.env).send("storage.batchGetDownloadUrl",s).then((e=>{e.code?t(null,e):t(null,{fileList:e.data.download_list,requestId:e.requestId})})).catch((e=>{t(e)})),t.promise},Pe=async function({fileID:e},t){const n=(await Ae.call(this,{fileList:[{fileID:e,maxAge:600}]})).fileList[0];if("SUCCESS"!==n.code)return t?t(n):new Promise((e=>{e(n)}));const s=de(this.config.env);let r=n.download_url;if(r=encodeURI(r),!t)return s.download({url:r});t(await s.download({url:r}))},Ie=function({name:e,data:t,query:n,parse:s,search:r},o){const i=o||R();let a;try{a=t?JSON.stringify(t):""}catch(e){return Promise.reject(e)}if(!e)return Promise.reject(new Error("函数名不能为空"));const c={inQuery:n,parse:s,search:r,function_name:e,request_data:a};return de(this.config.env).send("functions.invokeFunction",c).then((e=>{if(e.code)i(null,e);else{let t=e.data.response_data;if(s)i(null,{result:t,requestId:e.requestId});else try{t=JSON.parse(e.data.response_data),i(null,{result:t,requestId:e.requestId})}catch(e){i(new Error("response data must be json"))}}return i.promise})).catch((e=>{i(e)})),i.promise},be={timeout:15e3,persistence:"session"},Ee={};class Oe{constructor(e){this.config=e||this.config,this.authObj=void 0}init(e){switch(M.adapter||(this.requestClient=new M.adapter.reqClass({timeout:e.timeout||5e3,timeoutMsg:`请求在${(e.timeout||5e3)/1e3}s内未完成,已中断`})),this.config={...be,...e},!0){case this.config.timeout>6e5:console.warn("timeout大于可配置上限[10分钟],已重置为上限数值"),this.config.timeout=6e5;break;case this.config.timeout<100:console.warn("timeout小于可配置下限[100ms],已重置为下限数值"),this.config.timeout=100}return new Oe(this.config)}auth({persistence:e}={}){if(this.authObj)return this.authObj;const t=e||M.adapter.primaryStorage||be.persistence;var n;return t!==this.config.persistence&&(this.config.persistence=t),function(e){const{env:t}=e;W[t]=new H(e),z[t]=new H({...e,persistence:"local"})}(this.config),n=this.config,le[n.env]=new he(n),this.authObj=new ke(this.config),this.authObj}on(e,t){return G.apply(this,[e,t])}off(e,t){return Z.apply(this,[e,t])}callFunction(e,t){return Ie.apply(this,[e,t])}deleteFile(e,t){return Te.apply(this,[e,t])}getTempFileURL(e,t){return Ae.apply(this,[e,t])}downloadFile(e,t){return Pe.apply(this,[e,t])}uploadFile(e,t){return Se.apply(this,[e,t])}getUploadMetadata(e,t){return ve.apply(this,[e,t])}registerExtension(e){Ee[e.name]=e}async invokeExtension(e,t){const n=Ee[e];if(!n)throw Error(`扩展${e} 必须先注册`);return await n.invoke(t,this)}useAdapters(e){const{adapter:t,runtime:n}=$(e)||{};t&&(M.adapter=t),n&&(M.runtime=n)}}var Ce=new Oe;function Ue(e,t,n){void 0===n&&(n={});var s=/\?/.test(t),r="";for(var o in n)""===r?!s&&(t+="?"):r+="&",r+=o+"="+encodeURIComponent(n[o]);return/^http(s)?:\/\//.test(t+=r)?t:""+e+t}class xe{post(e){const{url:t,data:n,headers:s}=e;return new Promise(((e,r)=>{b.request({url:Ue("https:",t),data:n,method:"POST",header:s,success(t){e(t)},fail(e){r(e)}})}))}upload(e){return new Promise(((t,n)=>{const{url:s,file:r,data:o,headers:i,fileType:a}=e,h=b.uploadFile({url:Ue("https:",s),name:"file",formData:Object.assign({},o),filePath:r,fileType:a,header:i,success(e){const n={statusCode:e.statusCode,data:e.data||{}};200===e.statusCode&&o.success_action_status&&(n.statusCode=parseInt(o.success_action_status,10)),t(n)},fail(e){c&&"mp-alipay"===u&&console.warn("支付宝小程序开发工具上传腾讯云时无法准确判断是否上传成功,请使用真机测试"),n(new Error(e.errMsg||"uploadFile:fail"))}});"function"==typeof e.onUploadProgress&&h&&"function"==typeof h.onProgressUpdate&&h.onProgressUpdate((t=>{e.onUploadProgress({loaded:t.totalBytesSent,total:t.totalBytesExpectedToSend})}))}))}}const De={setItem(e,t){b.setStorageSync(e,t)},getItem:e=>b.getStorageSync(e),removeItem(e){b.removeStorageSync(e)},clear(){b.clearStorageSync()}};var qe={genAdapter:function(){return{root:{},reqClass:xe,localStorage:De,primaryStorage:"local"}},isMatch:function(){return!0},runtime:"uni_app"};Ce.useAdapters(qe);const Re=Ce,Fe=Re.init;Re.init=function(e){e.env=e.spaceId;const t=Fe.call(this,e);t.config.provider="tencent",t.config.spaceId=e.spaceId;const n=t.auth;return t.auth=function(e){const t=n.call(this,e);return["linkAndRetrieveDataWithTicket","signInAnonymously","signOut","getAccessToken","getLoginState","signInWithTicket","getUserInfo"].forEach((e=>{t[e]=v(t[e]).bind(t)})),t},t.customAuth=t.auth,t};var Le=Re;function Ne(){return{token:b.getStorageSync("uni_id_token")||b.getStorageSync("uniIdToken"),tokenExpired:b.getStorageSync("uni_id_token_expired")}}function $e(){if(!c||"h5"!==u)return;uni.getStorageSync("__LAST_DCLOUD_APPID")!==f&&(uni.setStorageSync("__LAST_DCLOUD_APPID",f),console.warn("检测到当前项目与上次运行到此端口的项目不一致,自动清理uni-id保存的token信息(仅开发调试时生效)"),b.removeStorageSync("uni_id_token"),b.removeStorageSync("uniIdToken"),b.removeStorageSync("uni_id_token_expired"))}var Me=class extends C{getAccessToken(){return new Promise(((e,t)=>{const n="Anonymous_Access_token";this.setAccessToken(n),e(n)}))}setupRequest(e,t){const n=Object.assign({},e,{spaceId:this.config.spaceId,timestamp:Date.now()}),s={"Content-Type":"application/json"};"auth"!==t&&(n.token=this.accessToken,s["x-basement-token"]=this.accessToken),s["x-serverless-sign"]=I.sign(n,this.config.clientSecret);const r=P();s["x-client-info"]=JSON.stringify(r);const{token:o}=Ne();return s["x-client-token"]=o,{url:this.config.requestUrl,method:"POST",data:n,dataType:"json",header:JSON.parse(JSON.stringify(s))}}uploadFileToOSS({url:e,formData:t,name:n,filePath:s,fileType:r,onUploadProgress:o}){return new Promise(((i,a)=>{const c=this.adapter.uploadFile({url:e,formData:t,name:n,filePath:s,fileType:r,success(e){e&&e.statusCode<400?i(e):a(new T({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){a(new T({code:e.code||"UPLOAD_FAILED",message:e.message||e.errMsg||"文件上传失败"}))}});"function"==typeof o&&c&&"function"==typeof c.onProgressUpdate&&c.onProgressUpdate((e=>{o({loaded:e.totalBytesSent,total:e.totalBytesExpectedToSend})}))}))}uploadFile({filePath:e,cloudPath:t,fileType:n="image",onUploadProgress:s}){if(!t)throw new T({code:"CLOUDPATH_REQUIRED",message:"cloudPath不可为空"});let r;return this.getOSSUploadOptionsFromPath({cloudPath:t}).then((t=>{const{url:o,formData:i,name:a}=t.result;r=t.result.fileUrl;const c={url:o,formData:i,name:a,filePath:e,fileType:n};return this.uploadFileToOSS(Object.assign({},c,{onUploadProgress:s}))})).then((()=>this.reportOSSUpload({cloudPath:t}))).then((t=>new Promise(((n,s)=>{t.success?n({success:!0,filePath:e,fileID:r}):s(new T({code:"UPLOAD_FAILED",message:"文件上传失败"}))}))))}deleteFile({fileList:e}){const t={method:"serverless.file.resource.delete",params:JSON.stringify({fileList:e})};return this.request(this.setupRequest(t))}getTempFileURL({fileList:e}={}){const t={method:"serverless.file.resource.getTempFileURL",params:JSON.stringify({fileList:e})};return this.request(this.setupRequest(t))}};var je={init(e){const t=new Me(e),n={signInAnonymously:function(){return t.authorize()},getLoginState:function(){return Promise.resolve(!1)}};return t.auth=function(){return n},t.customAuth=t.auth,t}};function Be({data:e}){let t;t=P();const n=JSON.parse(JSON.stringify(e||{}));if(Object.assign(n,{clientInfo:t}),!n.uniIdToken){const{token:e}=Ne();e&&(n.uniIdToken=e)}return n}function Ke({name:e,data:t}){const{localAddress:n,localPort:s}=this,r={aliyun:"aliyun",tencent:"tcb"}[this.config.provider],o=this.config.spaceId,i=`http://${n}:${s}/system/check-function`,a=`http://${n}:${s}/cloudfunctions/${e}`;return new Promise(((t,n)=>{b.request({method:"POST",url:i,data:{name:e,platform:u,provider:r,spaceId:o},timeout:3e3,success(e){t(e)},fail(){t({data:{code:"NETWORK_ERROR",message:"连接本地调试服务失败,请检查客户端是否和主机在同一局域网下,自动切换为已部署的云函数。"}})}})})).then((({data:e}={})=>{const{code:t,message:n}=e||{};return{code:0===t?0:t||"SYS_ERR",message:n||"SYS_ERR"}})).then((({code:n,message:s})=>{if(0!==n){switch(n){case"MODULE_ENCRYPTED":console.error(`此云函数(${e})依赖加密公共模块不可本地调试,自动切换为云端已部署的云函数`);break;case"FUNCTION_ENCRYPTED":console.error(`此云函数(${e})已加密不可本地调试,自动切换为云端已部署的云函数`);break;case"ACTION_ENCRYPTED":console.error(s||"需要访问加密的uni-clientDB-action,自动切换为云端环境");break;case"NETWORK_ERROR":{const e="连接本地调试服务失败,请检查客户端是否和主机在同一局域网下";throw console.error(e),new Error(e)}case"SWITCH_TO_CLOUD":break;default:{const e=`检测本地调试服务出现错误:${s},请检查网络环境或重启客户端再试`;throw console.error(e),new Error(e)}}return this._originCallFunction({name:e,data:t})}return new Promise(((e,n)=>{const s=Be.call(this,{data:t});b.request({method:"POST",url:a,data:{provider:r,platform:u,param:s},success:({statusCode:t,data:s}={})=>!t||t>=400?n(new T({code:s.code||"SYS_ERR",message:s.message||"request:fail"})):e({result:s}),fail(e){n(new T({code:e.code||e.errCode||"SYS_ERR",message:e.message||e.errMsg||"request:fail"}))}})}))}))}const He=[{rule:/fc_function_not_found|FUNCTION_NOT_FOUND/,content:",云函数[{functionName}]在云端不存在,请检查此云函数名称是否正确以及该云函数是否已上传到服务空间",mode:"append"}];var We=/[\\^$.*+?()[\]{}|]/g,ze=RegExp(We.source);function Je(e,t,n){return e.replace(new RegExp((s=t)&&ze.test(s)?s.replace(We,"\\$&"):s,"g"),n);var s}function Ve({functionName:e,result:t,logPvd:n}){if(this.config.useDebugFunction&&t&&t.requestId){const s=JSON.stringify({spaceId:this.config.spaceId,functionName:e,requestId:t.requestId});console.log(`[${n}-request]${s}[/${n}-request]`)}}function Ye(e){const t=e.callFunction,n=function(n){const s=n.name;n.data=Be.call(e,{data:n.data});const r={aliyun:"aliyun",tencent:"tcb"}[this.config.provider];return t.call(this,n).then((e=>(Ve.call(this,{functionName:s,result:e,logPvd:r}),Promise.resolve(e))),(e=>(Ve.call(this,{functionName:s,result:e,logPvd:r}),e&&e.message&&(e.message=function({message:e="",extraInfo:t={},formatter:n=[]}={}){for(let s=0;s<n.length;s++){const{rule:r,content:o,mode:i}=n[s],a=e.match(r);if(!a)continue;let c=o;for(let e=1;e<a.length;e++)c=Je(c,`{$${e}}`,a[e]);for(const e in t)c=Je(c,`{${e}}`,t[e]);return"replace"===i?c:e+c}return e}({message:`[${n.name}]: ${e.message}`,formatter:He,extraInfo:{functionName:s}})),Promise.reject(e))))};e.callFunction=function(t){let s;return c&&e.debugInfo&&!e.debugInfo.forceRemote&&l?(e._originCallFunction||(e._originCallFunction=n),s=Ke.call(this,t)):s=n.call(this,t),Object.defineProperty(s,"result",{get:()=>(console.warn("当前返回结果为Promise类型,不可直接访问其result属性,详情请参考:https://uniapp.dcloud.net.cn/uniCloud/faq?id=promise"),{})}),s}}const Xe=Symbol("CLIENT_DB_INTERNAL");function Ge(e,t){return e.then="DoNotReturnProxyWithAFunctionNamedThen",e._internalType=Xe,e.__ob__=void 0,new Proxy(e,{get(e,n,s){if("_uniClient"===n)return null;if(n in e||"string"!=typeof n){const t=e[n];return"function"==typeof t?t.bind(e):t}return t.get(e,n,s)}})}function Qe(e){return{on:(t,n)=>{e[t]=e[t]||[],e[t].indexOf(n)>-1||e[t].push(n)},off:(t,n)=>{e[t]=e[t]||[];const s=e[t].indexOf(n);-1!==s&&e[t].splice(s,1)}}}const Ze=["db.Geo","db.command","command.aggregate"];function et(e,t){return Ze.indexOf(`${e}.${t}`)>-1}function tt(e){switch(o(e)){case"array":return e.map((e=>tt(e)));case"object":return e._internalType===Xe||Object.keys(e).forEach((t=>{e[t]=tt(e[t])})),e;case"regexp":return{$regexp:{source:e.source,flags:e.flags}};case"date":return{$date:e.toISOString()};default:return e}}class nt{constructor(e,t,n){this.content=e,this.prevStage=t||null,this.udb=null,this._database=n}toJSON(){let e=this;const t=[e.content];for(;e.prevStage;)e=e.prevStage,t.push(e.content);return{$db:t.reverse().map((e=>({$method:e.$method,$param:tt(e.$param)})))}}getAction(){const e=this.toJSON().$db.find((e=>"action"===e.$method));return e&&e.$param&&e.$param[0]}getCommand(){return{$db:this.toJSON().$db.filter((e=>"action"!==e.$method))}}get useAggregate(){let e=this,t=!1;for(;e.prevStage;){e=e.prevStage;const n=e.content.$method;if("aggregate"===n||"pipeline"===n){t=!0;break}}return t}get count(){if(!this.useAggregate)return function(){return this._send("count",Array.from(arguments))};const e=this;return function(){return st({$method:"count",$param:tt(Array.from(arguments))},e,this._database)}}get(){return this._send("get",Array.from(arguments))}add(){return this._send("add",Array.from(arguments))}remove(){return this._send("remove",Array.from(arguments))}update(){return this._send("update",Array.from(arguments))}end(){return this._send("end",Array.from(arguments))}set(){throw new Error("clientDB禁止使用set方法")}_send(e,t){const n=this.getAction(),s=this.getCommand();if(s.$db.push({$method:e,$param:tt(t)}),c){const e=s.$db.find((e=>"collection"===e.$method)),t=e&&e.$param;t&&1===t.length&&"string"==typeof e.$param[0]&&e.$param[0].indexOf(",")>-1&&console.warn("检测到使用JQL语法联表查询时,未使用getTemp先过滤主表数据,在主表数据量大的情况下可能会查询缓慢。\n- 如何优化请参考此文档:https://uniapp.dcloud.net.cn/uniCloud/jql?id=lookup-with-temp \n- 如果主表数据量很小请忽略此信息,项目发行时不会出现此提示。")}return this._database._callCloudFunction({action:n,command:s})}}function st(e,t,n){return Ge(new nt(e,t,n),{get(e,t){let s="db";return e&&e.content&&(s=e.content.$method),et(s,t)?st({$method:t},e,n):function(){return st({$method:t,$param:tt(Array.from(arguments))},e,n)}}})}function rt({path:e,method:t}){return class{constructor(){this.param=Array.from(arguments)}toJSON(){return{$newDb:[...e.map((e=>({$method:e}))),{$method:t,$param:this.param}]}}}}class ot extends class{constructor({uniClient:e={}}={}){this._uniClient=e,this._authCallBacks={},this._dbCallBacks={},e.isDefault&&(this._dbCallBacks=g("_globalUniCloudDatabaseCallback")),this.auth=Qe(this._authCallBacks),Object.assign(this,Qe(this._dbCallBacks)),this.env=Ge({},{get:(e,t)=>({$env:t})}),this.Geo=Ge({},{get:(e,t)=>rt({path:["Geo"],method:t})}),this.serverDate=rt({path:[],method:"serverDate"}),this.RegExp=rt({path:[],method:"RegExp"})}getCloudEnv(e){if("string"!=typeof e||!e.trim())throw new Error("getCloudEnv参数错误");return{$env:e.replace("$cloudEnv_","")}}_callback(e,t){const n=this._dbCallBacks;n[e]&&n[e].forEach((e=>{e(...t)}))}_callbackAuth(e,t){const n=this._authCallBacks;n[e]&&n[e].forEach((e=>{e(...t)}))}multiSend(){const e=Array.from(arguments),t=e.map((e=>{const t=e.getAction(),n=e.getCommand();if("getTemp"!==n.$db[n.$db.length-1].$method)throw new Error("multiSend只支持子命令内使用getTemp");return{action:t,command:n}}));return this._callCloudFunction({multiCommand:t,queryList:e})}}{_callCloudFunction({action:e,command:t,multiCommand:n,queryList:s}){function r(e,t){if(n&&s)for(let n=0;n<s.length;n++){const r=s[n];r.udb&&"function"==typeof r.udb.setResult&&(t?r.udb.setResult(t):r.udb.setResult(e.result.dataList[n]))}}const o=k(S("database","invoke")),i=this._uniClient;return o.then((()=>i.callFunction({name:"DCloud-clientDB",data:{action:e,command:t,multiCommand:n}}))).then((e=>{const{code:t,message:n,token:s,tokenExpired:o,systemInfo:i=[]}=e.result;if(i)for(let e=0;e<i.length;e++){const{level:t,message:n,detail:s}=i[e],r=console["app-plus"===u&&"warn"===t?"error":t]||console.log;let o="[System Info]"+n;s&&(o=`${o}\n详细信息:${s}`),r(o)}if(t){const s=new T({message:n,code:t,requestId:e.requestId});return this._callback("error",[s]),Promise.reject(s)}s&&o&&(!function({token:e,tokenExpired:t}={}){e&&b.setStorageSync("uni_id_token",e),t&&b.setStorageSync("uni_id_token_expired",t)}({token:s,tokenExpired:o}),this._callbackAuth("refreshToken",[{token:s,tokenExpired:o}]),this._callback("refreshToken",[{token:s,tokenExpired:o}]));const a=e.result.affectedDocs;return"number"==typeof a&&Object.defineProperty(e.result,"affectedDocs",{get:()=>(console.warn("affectedDocs不再推荐使用,请使用inserted/deleted/updated/data.length替代"),a)}),k(S("database","success"),e).then((()=>k(S("database","complete"),e))).then((()=>(r(e,null),Promise.resolve(e))))}),(e=>{const t=new T({code:e.code||"SYSTEM_ERROR",message:e.message,requestId:e.requestId});return this._callback("error",[t]),/fc_function_not_found|FUNCTION_NOT_FOUND/g.test(e.message)&&console.warn("clientDB未初始化,请在web控制台保存一次schema以开启clientDB"),k(S("database","fail"),e).then((()=>k(S("database","complete"),e))).then((()=>(r(null,e),Promise.reject(e))))}))}}function it(e){e.database=function(t){if(t&&Object.keys(t).length>0)return e.init(t).database();if(this._database)return this._database;const n=function(e,t={}){return Ge(new e(t),{get:(e,t)=>et("db",t)?st({$method:t},null,e):function(){return st({$method:t,$param:tt(Array.from(arguments))},null,e)}})}(ot,{uniClient:e});return this._database=n,n}}let at;const ct="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",ut=/^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;function ht(){const e=Ne().token||"",t=e.split(".");if(!e||3!==t.length)return{uid:null,role:[],permission:[],tokenExpired:0};let n;try{n=JSON.parse((s=t[1],decodeURIComponent(at(s).split("").map((function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)})).join(""))))}catch(e){throw new Error("获取当前用户信息出错,详细错误信息为:"+e.message)}var s;return n.tokenExpired=1e3*n.exp,delete n.exp,delete n.iat,n}at="function"!=typeof atob?function(e){if(e=String(e).replace(/[\t\n\f\r ]+/g,""),!ut.test(e))throw new Error("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");var t;e+="==".slice(2-(3&e.length));for(var n,s,r="",o=0;o<e.length;)t=ct.indexOf(e.charAt(o++))<<18|ct.indexOf(e.charAt(o++))<<12|(n=ct.indexOf(e.charAt(o++)))<<6|(s=ct.indexOf(e.charAt(o++))),r+=64===n?String.fromCharCode(t>>16&255):64===s?String.fromCharCode(t>>16&255,t>>8&255):String.fromCharCode(t>>16&255,t>>8&255,255&t);return r}:atob;var lt=t(n((function(e,t){Object.defineProperty(t,"__esModule",{value:!0});const n="chooseAndUploadFile:ok",s="chooseAndUploadFile:fail";function r(e,t){return e.tempFiles.forEach(((e,n)=>{e.name||(e.name=e.path.substring(e.path.lastIndexOf("/")+1)),t&&(e.fileType=t),e.cloudPath=Date.now()+"_"+n+e.name.substring(e.name.lastIndexOf("."))})),e.tempFilePaths||(e.tempFilePaths=e.tempFiles.map((e=>e.path))),e}function o(e,t,{onChooseFile:s,onUploadProgress:r}){return t.then((e=>{if(s){const t=s(e);if(void 0!==t)return Promise.resolve(t).then((t=>void 0===t?e:t))}return e})).then((t=>!1===t?{errMsg:n,tempFilePaths:[],tempFiles:[]}:function(e,t,s=5,r){(t=Object.assign({},t)).errMsg=n;const o=t.tempFiles,i=o.length;let a=0;return new Promise((n=>{for(;a<s;)c();function c(){const s=a++;if(s>=i)return void(!o.find((e=>!e.url&&!e.errMsg))&&n(t));const u=o[s];e.uploadFile({filePath:u.path,cloudPath:u.cloudPath,fileType:u.fileType,onUploadProgress(e){e.index=s,e.tempFile=u,e.tempFilePath=u.path,r&&r(e)}}).then((e=>{u.url=e.fileID,s<i&&c()})).catch((e=>{u.errMsg=e.errMsg||e.message,s<i&&c()}))}}))}(e,t,5,r)))}t.initChooseAndUploadFile=function(e){return function(t={type:"all"}){return"image"===t.type?o(e,function(e){const{count:t,sizeType:n,sourceType:o=["album","camera"],extension:i}=e;return new Promise(((e,a)=>{uni.chooseImage({count:t,sizeType:n,sourceType:o,extension:i,success(t){e(r(t,"image"))},fail(e){a({errMsg:e.errMsg.replace("chooseImage:fail",s)})}})}))}(t),t):"video"===t.type?o(e,function(e){const{camera:t,compressed:n,maxDuration:o,sourceType:i=["album","camera"],extension:a}=e;return new Promise(((e,c)=>{uni.chooseVideo({camera:t,compressed:n,maxDuration:o,sourceType:i,extension:a,success(t){const{tempFilePath:n,duration:s,size:o,height:i,width:a}=t;e(r({errMsg:"chooseVideo:ok",tempFilePaths:[n],tempFiles:[{name:t.tempFile&&t.tempFile.name||"",path:n,size:o,type:t.tempFile&&t.tempFile.type||"",width:a,height:i,duration:s,fileType:"video",cloudPath:""}]},"video"))},fail(e){c({errMsg:e.errMsg.replace("chooseVideo:fail",s)})}})}))}(t),t):o(e,function(e){const{count:t,extension:n}=e;return new Promise(((e,o)=>{let i=uni.chooseFile;if("undefined"!=typeof wx&&"function"==typeof wx.chooseMessageFile&&(i=wx.chooseMessageFile),"function"!=typeof i)return o({errMsg:s+" 请指定 type 类型,该平台仅支持选择 image 或 video。"});i({type:"all",count:t,extension:n,success(t){e(r(t))},fail(e){o({errMsg:e.errMsg.replace("chooseFile:fail",s)})}})}))}(t),t)}}})));const dt="manual";function ft(e){return{props:{localdata:{type:Array,default:()=>[]},options:{type:[Object,Array],default:()=>({})},spaceInfo:{type:Object,default:()=>({})},collection:{type:[String,Array],default:""},action:{type:String,default:""},field:{type:String,default:""},orderby:{type:String,default:""},where:{type:[String,Object],default:""},pageData:{type:String,default:"add"},pageCurrent:{type:Number,default:1},pageSize:{type:Number,default:20},getcount:{type:[Boolean,String],default:!1},gettree:{type:[Boolean,String],default:!1},gettreepath:{type:[Boolean,String],default:!1},startwith:{type:String,default:""},limitlevel:{type:Number,default:10},groupby:{type:String,default:""},groupField:{type:String,default:""},distinct:{type:[Boolean,String],default:!1},foreignKey:{type:String,default:""},loadtime:{type:String,default:"auto"},manual:{type:Boolean,default:!1}},data:()=>({mixinDatacomLoading:!1,mixinDatacomHasMore:!1,mixinDatacomResData:[],mixinDatacomErrorMessage:"",mixinDatacomPage:{}}),created(){this.mixinDatacomPage={current:this.pageCurrent,size:this.pageSize,count:0},this.$watch((()=>{var e=[];return["pageCurrent","pageSize","localdata","collection","action","field","orderby","where","getont","getcount","gettree","groupby","groupField","distinct"].forEach((t=>{e.push(this[t])})),e}),((e,t)=>{if(this.loadtime===dt)return;let n=!1;const s=[];for(let r=2;r<e.length;r++)e[r]!==t[r]&&(s.push(e[r]),n=!0);e[0]!==t[0]&&(this.mixinDatacomPage.current=this.pageCurrent),this.mixinDatacomPage.size=this.pageSize,this.onMixinDatacomPropsChange(n,s)}))},methods:{onMixinDatacomPropsChange(e,t){},mixinDatacomEasyGet({getone:e=!1,success:t,fail:n}={}){this.mixinDatacomLoading||(this.mixinDatacomLoading=!0,this.mixinDatacomErrorMessage="",this.mixinDatacomGet().then((n=>{this.mixinDatacomLoading=!1;const{data:s,count:r}=n.result;this.getcount&&(this.mixinDatacomPage.count=r),this.mixinDatacomHasMore=s.length<this.pageSize;const o=e?s.length?s[0]:void 0:s;this.mixinDatacomResData=o,t&&t(o)})).catch((e=>{this.mixinDatacomLoading=!1,this.mixinDatacomErrorMessage=e,n&&n(e)})))},mixinDatacomGet(t={}){let n=e.database(this.spaceInfo);const s=t.action||this.action;s&&(n=n.action(s));const r=t.collection||this.collection;n=Array.isArray(r)?n.collection(...r):n.collection(r);const o=t.where||this.where;o&&Object.keys(o).length&&(n=n.where(o));const i=t.field||this.field;i&&(n=n.field(i));const a=t.foreignKey||this.foreignKey;a&&(n=n.foreignKey(a));const c=t.groupby||this.groupby;c&&(n=n.groupBy(c));const u=t.groupField||this.groupField;u&&(n=n.groupField(u));!0===(void 0!==t.distinct?t.distinct:this.distinct)&&(n=n.distinct());const h=t.orderby||this.orderby;h&&(n=n.orderBy(h));const l=void 0!==t.pageCurrent?t.pageCurrent:this.mixinDatacomPage.current,d=void 0!==t.pageSize?t.pageSize:this.mixinDatacomPage.size,f=void 0!==t.getcount?t.getcount:this.getcount,p=void 0!==t.gettree?t.gettree:this.gettree,g=void 0!==t.gettreepath?t.gettreepath:this.gettreepath,m={getCount:f},y={limitLevel:void 0!==t.limitlevel?t.limitlevel:this.limitlevel,startWith:void 0!==t.startwith?t.startwith:this.startwith};return p&&(m.getTree=y),g&&(m.getTreePath=y),n=n.skip(d*(l-1)).limit(d).get(m),n}}}}function pt(e){e.getCurrentUserInfo=ht,e.chooseAndUploadFile=lt.initChooseAndUploadFile(e),Object.assign(e,{get mixinDatacom(){return ft(e)}}),e.importObject=function(e){return function(t){return new Proxy({},{get:(n,s)=>async function(...n){const r=await e.callFunction({name:t,data:{method:s,params:n}}),{errCode:o,errMsg:i}=r.result||{};if(o){const e=new T({code:o,message:i,requestId:r.requestId});throw e.detail=r.result,e}return r.result}})}}(e)}async function gt(e,t){const n=`http://${e}:${t}/system/ping`;try{const e=await(s={url:n,timeout:500},new Promise(((e,t)=>{b.request({...s,success(t){e(t)},fail(e){t(e)}})})));return!(!e.data||0!==e.data.code)}catch(e){return!1}var s}function mt(e){if(e.initUniCloudStatus&&"rejected"!==e.initUniCloudStatus)return;let t=Promise.resolve();var n;n=1,t=new Promise(((e,t)=>{setTimeout((()=>{e()}),n)})),e.isReady=!1,e.isDefault=!1;const s=e.auth();e.initUniCloudStatus="pending",e.initUniCloud=t.then((()=>s.getLoginState())).then((e=>e?Promise.resolve():s.signInAnonymously())).then((()=>{if(!c)return Promise.resolve();if(c&&e.debugInfo){const{address:t,servePort:n}=e.debugInfo;return async function(e,t){let n;for(let s=0;s<e.length;s++){const r=e[s];if(await gt(r,t)){n=r;break}}return{address:n,port:t}}(t,n)}})).then((({address:t,port:n}={})=>{if(!c)return Promise.resolve();if(t)e.localAddress=t,e.localPort=n;else if(e.debugInfo){const t=console["app-plus"===u?"error":"warn"];let n="";"remote"===e.debugInfo.initialLaunchType?(e.debugInfo.forceRemote=!0,n="当前客户端和HBuilderX不在同一局域网下(或其他网络原因无法连接HBuilderX),uniCloud本地调试服务不对当前客户端生效。\n- 如果不使用uniCloud本地调试服务,请直接忽略此信息。\n- 如需使用uniCloud本地调试服务,请将客户端与主机连接到同一局域网下并重新运行到客户端。\n- 如果在HBuilderX开启的状态下切换过网络环境,请重启HBuilderX后再试\n- 检查系统防火墙是否拦截了HBuilderX自带的nodejs"):n="无法连接uniCloud本地调试服务,请检查当前客户端是否与主机在同一局域网下。\n- 如需使用uniCloud本地调试服务,请将客户端与主机连接到同一局域网下并重新运行到客户端。\n- 如果在HBuilderX开启的状态下切换过网络环境,请重启HBuilderX后再试\n- 检查系统防火墙是否拦截了HBuilderX自带的nodejs","h5"===u&&(n+="\n- 部分浏览器开启节流模式之后访问本地地址受限,请检查是否启用了节流模式"),t(n)}})).then((()=>{$e(),e.isReady=!0,e.initUniCloudStatus="fulfilled"})).catch((t=>{console.error(t),e.initUniCloudStatus="rejected"}))}let yt=new class{init(e){let t={};const n=!1!==e.debugFunction&&c&&("h5"===u&&navigator.userAgent.indexOf("HBuilderX")>0||"app-plus"===u);switch(e.provider){case"tencent":t=Le.init(Object.assign(e,{useDebugFunction:n}));break;case"aliyun":t=U.init(Object.assign(e,{useDebugFunction:n}));break;case"private":t=je.init(Object.assign(e,{useDebugFunction:n}));break;default:throw new Error("未提供正确的provider参数")}const s=h;c&&s&&!s.code&&(t.debugInfo=s),mt(t),t.reInit=function(){mt(this)},Ye(t),function(e){const t=e.uploadFile;e.uploadFile=function(e){return t.call(this,e)}}(t),it(t),pt(t);return["callFunction","uploadFile","deleteFile","getTempFileURL","downloadFile","chooseAndUploadFile"].forEach((e=>{if(!t[e])return;const n=t[e];t[e]=function(){return t.reInit(),n.apply(t,Array.from(arguments))},t[e]=v(t[e],e).bind(t)})),t.init=this.init,t}};(()=>{{const e=l;let t={};if(1===e.length)t=e[0],yt=yt.init(t),yt.isDefault=!0;else{const t=["auth","callFunction","uploadFile","deleteFile","getTempFileURL","downloadFile","database","getCurrentUSerInfo","importObject"];let n;n=e&&e.length>0?"应用有多个服务空间,请通过uniCloud.init方法指定要使用的服务空间":d?"应用未关联服务空间,请在uniCloud目录右键关联服务空间":"uni-app cli项目内使用uniCloud需要使用HBuilderX的运行菜单运行项目,且需要在uniCloud目录关联服务空间",t.forEach((e=>{yt[e]=function(){return console.error(n),Promise.reject(new T({code:"SYS_ERR",message:n}))}}))}Object.assign(yt,{get mixinDatacom(){return ft(yt)}}),yt.addInterceptor=_,yt.removeInterceptor=w,c&&"h5"===u&&(window.uniCloud=yt)}})();var _t=yt;export{_t as default};
|
|
1
|
+
import{initVueI18n as e}from"@dcloudio/uni-i18n";"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function n(e,t,n){return e(n={path:t,exports:{},require:function(e,t){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==t&&n.path)}},n.exports),n.exports}var s=n((function(e,t){var n;e.exports=(n=n||function(e,t){var n=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),s={},r=s.lib={},o=r.Base={extend:function(e){var t=n(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},i=r.WordArray=o.extend({init:function(e,n){e=this.words=e||[],this.sigBytes=n!=t?n:4*e.length},toString:function(e){return(e||c).stringify(this)},concat:function(e){var t=this.words,n=e.words,s=this.sigBytes,r=e.sigBytes;if(this.clamp(),s%4)for(var o=0;o<r;o++){var i=n[o>>>2]>>>24-o%4*8&255;t[s+o>>>2]|=i<<24-(s+o)%4*8}else for(o=0;o<r;o+=4)t[s+o>>>2]=n[o>>>2];return this.sigBytes+=r,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n,s=[],r=function(t){t=t;var n=987654321,s=4294967295;return function(){var r=((n=36969*(65535&n)+(n>>16)&s)<<16)+(t=18e3*(65535&t)+(t>>16)&s)&s;return r/=4294967296,(r+=.5)*(e.random()>.5?1:-1)}},o=0;o<t;o+=4){var a=r(4294967296*(n||e.random()));n=987654071*a(),s.push(4294967296*a()|0)}return new i.init(s,t)}}),a=s.enc={},c=a.Hex={stringify:function(e){for(var t=e.words,n=e.sigBytes,s=[],r=0;r<n;r++){var o=t[r>>>2]>>>24-r%4*8&255;s.push((o>>>4).toString(16)),s.push((15&o).toString(16))}return s.join("")},parse:function(e){for(var t=e.length,n=[],s=0;s<t;s+=2)n[s>>>3]|=parseInt(e.substr(s,2),16)<<24-s%8*4;return new i.init(n,t/2)}},u=a.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,s=[],r=0;r<n;r++){var o=t[r>>>2]>>>24-r%4*8&255;s.push(String.fromCharCode(o))}return s.join("")},parse:function(e){for(var t=e.length,n=[],s=0;s<t;s++)n[s>>>2]|=(255&e.charCodeAt(s))<<24-s%4*8;return new i.init(n,t)}},h=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},l=r.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new i.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=h.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,s=n.words,r=n.sigBytes,o=this.blockSize,a=r/(4*o),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*o,u=e.min(4*c,r);if(c){for(var h=0;h<c;h+=o)this._doProcessBlock(s,h);var l=s.splice(0,c);n.sigBytes-=u}return new i.init(l,u)},clone:function(){var e=o.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});r.Hasher=l.extend({cfg:o.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){l.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new d.HMAC.init(e,n).finalize(t)}}});var d=s.algo={};return s}(Math),n)})),r=(n((function(e,t){var n;e.exports=(n=s,function(e){var t=n,s=t.lib,r=s.WordArray,o=s.Hasher,i=t.algo,a=[];!function(){for(var t=0;t<64;t++)a[t]=4294967296*e.abs(e.sin(t+1))|0}();var c=i.MD5=o.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var n=0;n<16;n++){var s=t+n,r=e[s];e[s]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8)}var o=this._hash.words,i=e[t+0],c=e[t+1],f=e[t+2],p=e[t+3],g=e[t+4],m=e[t+5],y=e[t+6],_=e[t+7],w=e[t+8],k=e[t+9],S=e[t+10],v=e[t+11],T=e[t+12],A=e[t+13],P=e[t+14],I=e[t+15],b=o[0],O=o[1],E=o[2],C=o[3];b=u(b,O,E,C,i,7,a[0]),C=u(C,b,O,E,c,12,a[1]),E=u(E,C,b,O,f,17,a[2]),O=u(O,E,C,b,p,22,a[3]),b=u(b,O,E,C,g,7,a[4]),C=u(C,b,O,E,m,12,a[5]),E=u(E,C,b,O,y,17,a[6]),O=u(O,E,C,b,_,22,a[7]),b=u(b,O,E,C,w,7,a[8]),C=u(C,b,O,E,k,12,a[9]),E=u(E,C,b,O,S,17,a[10]),O=u(O,E,C,b,v,22,a[11]),b=u(b,O,E,C,T,7,a[12]),C=u(C,b,O,E,A,12,a[13]),E=u(E,C,b,O,P,17,a[14]),b=h(b,O=u(O,E,C,b,I,22,a[15]),E,C,c,5,a[16]),C=h(C,b,O,E,y,9,a[17]),E=h(E,C,b,O,v,14,a[18]),O=h(O,E,C,b,i,20,a[19]),b=h(b,O,E,C,m,5,a[20]),C=h(C,b,O,E,S,9,a[21]),E=h(E,C,b,O,I,14,a[22]),O=h(O,E,C,b,g,20,a[23]),b=h(b,O,E,C,k,5,a[24]),C=h(C,b,O,E,P,9,a[25]),E=h(E,C,b,O,p,14,a[26]),O=h(O,E,C,b,w,20,a[27]),b=h(b,O,E,C,A,5,a[28]),C=h(C,b,O,E,f,9,a[29]),E=h(E,C,b,O,_,14,a[30]),b=l(b,O=h(O,E,C,b,T,20,a[31]),E,C,m,4,a[32]),C=l(C,b,O,E,w,11,a[33]),E=l(E,C,b,O,v,16,a[34]),O=l(O,E,C,b,P,23,a[35]),b=l(b,O,E,C,c,4,a[36]),C=l(C,b,O,E,g,11,a[37]),E=l(E,C,b,O,_,16,a[38]),O=l(O,E,C,b,S,23,a[39]),b=l(b,O,E,C,A,4,a[40]),C=l(C,b,O,E,i,11,a[41]),E=l(E,C,b,O,p,16,a[42]),O=l(O,E,C,b,y,23,a[43]),b=l(b,O,E,C,k,4,a[44]),C=l(C,b,O,E,T,11,a[45]),E=l(E,C,b,O,I,16,a[46]),b=d(b,O=l(O,E,C,b,f,23,a[47]),E,C,i,6,a[48]),C=d(C,b,O,E,_,10,a[49]),E=d(E,C,b,O,P,15,a[50]),O=d(O,E,C,b,m,21,a[51]),b=d(b,O,E,C,T,6,a[52]),C=d(C,b,O,E,p,10,a[53]),E=d(E,C,b,O,S,15,a[54]),O=d(O,E,C,b,c,21,a[55]),b=d(b,O,E,C,w,6,a[56]),C=d(C,b,O,E,I,10,a[57]),E=d(E,C,b,O,y,15,a[58]),O=d(O,E,C,b,A,21,a[59]),b=d(b,O,E,C,g,6,a[60]),C=d(C,b,O,E,v,10,a[61]),E=d(E,C,b,O,f,15,a[62]),O=d(O,E,C,b,k,21,a[63]),o[0]=o[0]+b|0,o[1]=o[1]+O|0,o[2]=o[2]+E|0,o[3]=o[3]+C|0},_doFinalize:function(){var t=this._data,n=t.words,s=8*this._nDataBytes,r=8*t.sigBytes;n[r>>>5]|=128<<24-r%32;var o=e.floor(s/4294967296),i=s;n[15+(r+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),n[14+(r+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t.sigBytes=4*(n.length+1),this._process();for(var a=this._hash,c=a.words,u=0;u<4;u++){var h=c[u];c[u]=16711935&(h<<8|h>>>24)|4278255360&(h<<24|h>>>8)}return a},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,n,s,r,o,i){var a=e+(t&n|~t&s)+r+i;return(a<<o|a>>>32-o)+t}function h(e,t,n,s,r,o,i){var a=e+(t&s|n&~s)+r+i;return(a<<o|a>>>32-o)+t}function l(e,t,n,s,r,o,i){var a=e+(t^n^s)+r+i;return(a<<o|a>>>32-o)+t}function d(e,t,n,s,r,o,i){var a=e+(n^(t|~s))+r+i;return(a<<o|a>>>32-o)+t}t.MD5=o._createHelper(c),t.HmacMD5=o._createHmacHelper(c)}(Math),n.MD5)})),n((function(e,t){var n,r,o;e.exports=(r=(n=s).lib.Base,o=n.enc.Utf8,void(n.algo.HMAC=r.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=o.parse(t));var n=e.blockSize,s=4*n;t.sigBytes>s&&(t=e.finalize(t)),t.clamp();for(var r=this._oKey=t.clone(),i=this._iKey=t.clone(),a=r.words,c=i.words,u=0;u<n;u++)a[u]^=1549556828,c[u]^=909522486;r.sigBytes=i.sigBytes=s,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,n=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(n))}})))})),n((function(e,t){e.exports=s.HmacMD5})));const o="FUNCTION",i="OBJECT",a="CLIENT_DB";function c(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function u(e){return"object"===c(e)}function h(e){return e&&"string"==typeof e?JSON.parse(e):e}const l="development"===process.env.NODE_ENV,d=process.env.VUE_APP_PLATFORM,f=h(process.env.UNICLOUD_DEBUG),p=h(process.env.UNI_CLOUD_PROVIDER),g=process.env.RUN_BY_HBUILDERX;let m="";try{{const e=require("uni-stat-config").default||require("uni-stat-config");m=e.appid}}catch(e){}let y={};function _(e,t={}){var n,s;return n=y,s=e,Object.prototype.hasOwnProperty.call(n,s)||(y[e]=t),y[e]}"app-plus"===d&&(y=uni._globalUniCloudObj?uni._globalUniCloudObj:uni._globalUniCloudObj={});const w=["invoke","success","fail","complete"],k=_("_globalUniCloudInterceptor");function S(e,t){k[e]||(k[e]={}),u(t)&&Object.keys(t).forEach((n=>{w.indexOf(n)>-1&&function(e,t,n){let s=k[e][t];s||(s=k[e][t]=[]),-1===s.indexOf(n)&&"function"==typeof n&&s.push(n)}(e,n,t[n])}))}function v(e,t){k[e]||(k[e]={}),u(t)?Object.keys(t).forEach((n=>{w.indexOf(n)>-1&&function(e,t,n){const s=k[e][t];if(!s)return;const r=s.indexOf(n);r>-1&&s.splice(r,1)}(e,n,t[n])})):delete k[e]}function T(e,t){return e&&0!==e.length?e.reduce(((e,n)=>e.then((()=>n(t)))),Promise.resolve()):Promise.resolve()}function A(e,t){return k[e]&&k[e][t]||[]}function P(e,t){return t?function(n){let s,r=!1;if("callFunction"===t){const e=n&&n.type||o;r=e!==o}s=this.isReady?Promise.resolve():this.initUniCloud,n=n||{};const i=s.then((()=>r?Promise.resolve():T(A(t,"invoke"),n))).then((()=>e.call(this,n))).then((e=>r?Promise.resolve(e):T(A(t,"success"),e).then((()=>T(A(t,"complete"),e))).then((()=>Promise.resolve(e)))),(e=>r?Promise.reject(e):T(A(t,"fail"),e).then((()=>T(A(t,"complete"),e))).then((()=>Promise.reject(e)))));if(!(n.success||n.fail||n.complete))return i;i.then((e=>{n.success&&n.success(e),n.complete&&n.complete(e)}),(e=>{n.fail&&n.fail(e),n.complete&&n.complete(e)}))}:function(t){if(!((t=t||{}).success||t.fail||t.complete))return e.call(this,t);e.call(this,t).then((e=>{t.success&&t.success(e),t.complete&&t.complete(e)}),(e=>{t.fail&&t.fail(e),t.complete&&t.complete(e)}))}}class I extends Error{constructor(e){super(e.message),this.errMsg=e.message||"",this.errCode=this.code=e.code,this.requestId=e.requestId,Object.defineProperties(this,{message:{get(){return this.errMsg},set(e){this.errMsg=e}}})}}let b;function O(){const e=uni.getLocale&&uni.getLocale()||"en";if(b)return{...b,LOCALE:e};const{deviceId:t,platform:n}=uni.getSystemInfoSync();return b={PLATFORM:d,OS:n,APPID:m,DEVICEID:t,CLIENT_SDK_VERSION:"1.0.24"},{...b,LOCALE:e}}var E={sign:function(e,t){let n="";return Object.keys(e).sort().forEach((function(t){e[t]&&(n=n+"&"+t+"="+e[t])})),n=n.slice(1),r(n,t).toString()},wrappedRequest:function(e,t){return new Promise(((n,s)=>{t(Object.assign(e,{complete(e){e||(e={}),l&&"h5"===d&&e.errMsg&&0===e.errMsg.indexOf("request:fail")&&console.warn("发布H5,需要在uniCloud后台操作,绑定安全域名,否则会因为跨域问题而无法访问。教程参考:https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5");const t=e.data&&e.data.header&&e.data.header["x-serverless-request-id"]||e.header&&e.header["request-id"];if(!e.statusCode||e.statusCode>=400)return s(new I({code:"SYS_ERR",message:e.errMsg||"request:fail",requestId:t}));const r=e.data;if(r.error)return s(new I({code:r.error.code,message:r.error.message,requestId:t}));r.result=r.data,r.requestId=t,delete r.data,n(r)}}))}))}};var C={request:e=>uni.request(e),uploadFile:e=>uni.uploadFile(e),setStorageSync:(e,t)=>uni.setStorageSync(e,t),getStorageSync:e=>uni.getStorageSync(e),removeStorageSync:e=>uni.removeStorageSync(e),clearStorageSync:()=>uni.clearStorageSync()},U={"uniCloud.init.paramRequired":"{param} required","uniCloud.uploadFile.fileError":"filePath should be instance of File"};const{t:x}=e({"zh-Hans":{"uniCloud.init.paramRequired":"缺少参数:{param}","uniCloud.uploadFile.fileError":"filePath应为File对象"},"zh-Hant":{"uniCloud.init.paramRequired":"缺少参数:{param}","uniCloud.uploadFile.fileError":"filePath应为File对象"},en:U,fr:{"uniCloud.init.paramRequired":"{param} required","uniCloud.uploadFile.fileError":"filePath should be instance of File"},es:{"uniCloud.init.paramRequired":"{param} required","uniCloud.uploadFile.fileError":"filePath should be instance of File"},ja:U},"zh-Hans");var D=class{constructor(e){["spaceId","clientSecret"].forEach((t=>{if(!Object.prototype.hasOwnProperty.call(e,t))throw new Error(x("uniCloud.init.paramRequired",{param:t}))})),this.config=Object.assign({},{endpoint:"https://api.bspapp.com"},e),this.config.provider="aliyun",this.config.requestUrl=this.config.endpoint+"/client",this.config.envType=this.config.envType||"public",this.config.accessTokenKey="access_token_"+this.config.spaceId,this.adapter=C,this._getAccessTokenPromise=null,this._getAccessTokenPromiseStatus=null}get hasAccessToken(){return!!this.accessToken}setAccessToken(e){this.accessToken=e}requestWrapped(e){return E.wrappedRequest(e,this.adapter.request)}requestAuth(e){return this.requestWrapped(e)}request(e,t){return Promise.resolve().then((()=>this.hasAccessToken?t?this.requestWrapped(e):this.requestWrapped(e).catch((t=>new Promise(((e,n)=>{!t||"GATEWAY_INVALID_TOKEN"!==t.code&&"InvalidParameter.InvalidToken"!==t.code?n(t):e()})).then((()=>this.getAccessToken())).then((()=>{const t=this.rebuildRequest(e);return this.request(t,!0)})))):this.getAccessToken().then((()=>{const t=this.rebuildRequest(e);return this.request(t,!0)}))))}rebuildRequest(e){const t=Object.assign({},e);return t.data.token=this.accessToken,t.header["x-basement-token"]=this.accessToken,t.header["x-serverless-sign"]=E.sign(t.data,this.config.clientSecret),t}setupRequest(e,t){const n=Object.assign({},e,{spaceId:this.config.spaceId,timestamp:Date.now()}),s={"Content-Type":"application/json"};return"auth"!==t&&(n.token=this.accessToken,s["x-basement-token"]=this.accessToken),s["x-serverless-sign"]=E.sign(n,this.config.clientSecret),{url:this.config.requestUrl,method:"POST",data:n,dataType:"json",header:s}}getAccessToken(){if("pending"===this._getAccessTokenPromiseStatus)return this._getAccessTokenPromise;this._getAccessTokenPromiseStatus="pending";return this._getAccessTokenPromise=this.requestAuth(this.setupRequest({method:"serverless.auth.user.anonymousAuthorize",params:"{}"},"auth")).then((e=>new Promise(((t,n)=>{e.result&&e.result.accessToken?(this.setAccessToken(e.result.accessToken),this._getAccessTokenPromiseStatus="fulfilled",t(this.accessToken)):(this._getAccessTokenPromiseStatus="rejected",n(new I({code:"AUTH_FAILED",message:"获取accessToken失败"})))}))),(e=>(this._getAccessTokenPromiseStatus="rejected",Promise.reject(e)))),this._getAccessTokenPromise}authorize(){this.getAccessToken()}callFunction(e){const t={method:"serverless.function.runtime.invoke",params:JSON.stringify({functionTarget:e.name,functionArgs:e.data||{}})};return this.request(this.setupRequest(t))}getOSSUploadOptionsFromPath(e){const t={method:"serverless.file.resource.generateProximalSign",params:JSON.stringify(e)};return this.request(this.setupRequest(t))}uploadFileToOSS({url:e,formData:t,name:n,filePath:s,fileType:r,onUploadProgress:o}){return new Promise(((i,a)=>{const c=this.adapter.uploadFile({url:e,formData:t,name:n,filePath:s,fileType:r,header:{"X-OSS-server-side-encrpytion":"AES256"},success(e){e&&e.statusCode<400?i(e):a(new I({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){a(new I({code:e.code||"UPLOAD_FAILED",message:e.message||e.errMsg||"文件上传失败"}))}});"function"==typeof o&&c&&"function"==typeof c.onProgressUpdate&&c.onProgressUpdate((e=>{o({loaded:e.totalBytesSent,total:e.totalBytesExpectedToSend})}))}))}reportOSSUpload(e){const t={method:"serverless.file.resource.report",params:JSON.stringify(e)};return this.request(this.setupRequest(t))}uploadFile({filePath:e,cloudPath:t,fileType:n="image",onUploadProgress:s,config:r}){if("string"!==c(t))throw new I({code:"INVALID_PARAM",message:"cloudPath必须为字符串类型"});if(!(t=t.trim()))throw new I({code:"CLOUDPATH_REQUIRED",message:"cloudPath不可为空"});if(/:\/\//.test(t))throw new I({code:"INVALID_PARAM",message:"cloudPath不合法"});const o=r&&r.envType||this.config.envType;let i,a;return this.getOSSUploadOptionsFromPath({env:o,filename:t}).then((t=>{const r=t.result;i=r.id,a="https://"+r.cdnDomain+"/"+r.ossPath;const o={url:"https://"+r.host,formData:{"Cache-Control":"max-age=2592000","Content-Disposition":"attachment",OSSAccessKeyId:r.accessKeyId,Signature:r.signature,host:r.host,id:i,key:r.ossPath,policy:r.policy,success_action_status:200},fileName:"file",name:"file",filePath:e,fileType:n};return this.uploadFileToOSS(Object.assign({},o,{onUploadProgress:s}))})).then((()=>this.reportOSSUpload({id:i}))).then((t=>new Promise(((n,s)=>{t.success?n({success:!0,filePath:e,fileID:a}):s(new I({code:"UPLOAD_FAILED",message:"文件上传失败"}))}))))}deleteFile({fileList:e}){const t={method:"serverless.file.resource.delete",params:JSON.stringify({id:e[0]})};return this.request(this.setupRequest(t))}getTempFileURL({fileList:e}={}){return new Promise(((t,n)=>{Array.isArray(e)&&0!==e.length||n(new I({code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"})),t({fileList:e.map((e=>({fileID:e,tempFileURL:e})))})}))}};var q={init(e){const t=new D(e),n={signInAnonymously:function(){return t.authorize()},getLoginState:function(){return Promise.resolve(!1)}};return t.auth=function(){return n},t.customAuth=t.auth,t}};const R="undefined"!=typeof location&&"http:"===location.protocol?"http:":"https:";var L;!function(e){e.local="local",e.none="none",e.session="session"}(L||(L={}));var F=function(){};const N=()=>{let e;if(!Promise){e=()=>{},e.promise={};const t=()=>{throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(e.promise,"then",{get:t}),Object.defineProperty(e.promise,"catch",{get:t}),e}const t=new Promise(((t,n)=>{e=(e,s)=>e?n(e):t(s)}));return e.promise=t,e};function $(e){return void 0===e}function j(e){return"[object Null]"===Object.prototype.toString.call(e)}var M;function B(e){const t=(n=e,"[object Array]"===Object.prototype.toString.call(n)?e:[e]);var n;for(const e of t){const{isMatch:t,genAdapter:n,runtime:s}=e;if(t())return{adapter:n(),runtime:s}}}!function(e){e.WEB="web",e.WX_MP="wx_mp"}(M||(M={}));const K={adapter:null,runtime:void 0},H=["anonymousUuidKey"];class W extends F{constructor(){super(),K.adapter.root.tcbObject||(K.adapter.root.tcbObject={})}setItem(e,t){K.adapter.root.tcbObject[e]=t}getItem(e){return K.adapter.root.tcbObject[e]}removeItem(e){delete K.adapter.root.tcbObject[e]}clear(){delete K.adapter.root.tcbObject}}function z(e,t){switch(e){case"local":return t.localStorage||new W;case"none":return new W;default:return t.sessionStorage||new W}}class J{constructor(e){if(!this._storage){this._persistence=K.adapter.primaryStorage||e.persistence,this._storage=z(this._persistence,K.adapter);const t=`access_token_${e.env}`,n=`access_token_expire_${e.env}`,s=`refresh_token_${e.env}`,r=`anonymous_uuid_${e.env}`,o=`login_type_${e.env}`,i=`user_info_${e.env}`;this.keys={accessTokenKey:t,accessTokenExpireKey:n,refreshTokenKey:s,anonymousUuidKey:r,loginTypeKey:o,userInfoKey:i}}}updatePersistence(e){if(e===this._persistence)return;const t="local"===this._persistence;this._persistence=e;const n=z(e,K.adapter);for(const e in this.keys){const s=this.keys[e];if(t&&H.includes(e))continue;const r=this._storage.getItem(s);$(r)||j(r)||(n.setItem(s,r),this._storage.removeItem(s))}this._storage=n}setStore(e,t,n){if(!this._storage)return;const s={version:n||"localCachev1",content:t},r=JSON.stringify(s);try{this._storage.setItem(e,r)}catch(e){throw e}}getStore(e,t){try{if(!this._storage)return}catch(e){return""}t=t||"localCachev1";const n=this._storage.getItem(e);if(!n)return"";if(n.indexOf(t)>=0){return JSON.parse(n).content}return""}removeStore(e){this._storage.removeItem(e)}}const V={},Y={};function X(e){return V[e]}class G{constructor(e,t){this.data=t||null,this.name=e}}class Q extends G{constructor(e,t){super("error",{error:e,data:t}),this.error=e}}const Z=new class{constructor(){this._listeners={}}on(e,t){return function(e,t,n){n[e]=n[e]||[],n[e].push(t)}(e,t,this._listeners),this}off(e,t){return function(e,t,n){if(n&&n[e]){const s=n[e].indexOf(t);-1!==s&&n[e].splice(s,1)}}(e,t,this._listeners),this}fire(e,t){if(e instanceof Q)return console.error(e.error),this;const n="string"==typeof e?new G(e,t||{}):e;const s=n.name;if(this._listens(s)){n.target=this;const e=this._listeners[s]?[...this._listeners[s]]:[];for(const t of e)t.call(this,n)}return this}_listens(e){return this._listeners[e]&&this._listeners[e].length>0}};function ee(e,t){Z.on(e,t)}function te(e,t={}){Z.fire(e,t)}function ne(e,t){Z.off(e,t)}const se="loginStateChanged",re="loginStateExpire",oe="loginTypeChanged",ie="anonymousConverted",ae="refreshAccessToken";var ce;!function(e){e.ANONYMOUS="ANONYMOUS",e.WECHAT="WECHAT",e.WECHAT_PUBLIC="WECHAT-PUBLIC",e.WECHAT_OPEN="WECHAT-OPEN",e.CUSTOM="CUSTOM",e.EMAIL="EMAIL",e.USERNAME="USERNAME",e.NULL="NULL"}(ce||(ce={}));const ue=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"],he={"X-SDK-Version":"1.3.5"};function le(e,t,n){const s=e[t];e[t]=function(t){const r={},o={};n.forEach((n=>{const{data:s,headers:i}=n.call(e,t);Object.assign(r,s),Object.assign(o,i)}));const i=t.data;return i&&(()=>{var e;if(e=i,"[object FormData]"!==Object.prototype.toString.call(e))t.data={...i,...r};else for(const e in r)i.append(e,r[e])})(),t.headers={...t.headers||{},...o},s.call(e,t)}}function de(){const e=Math.random().toString(16).slice(2);return{data:{seqId:e},headers:{...he,"x-seqid":e}}}class fe{constructor(e={}){var t;this.config=e,this._reqClass=new K.adapter.reqClass({timeout:this.config.timeout,timeoutMsg:`请求在${this.config.timeout/1e3}s内未完成,已中断`,restrictedMethods:["post"]}),this._cache=X(this.config.env),this._localCache=(t=this.config.env,Y[t]),le(this._reqClass,"post",[de]),le(this._reqClass,"upload",[de]),le(this._reqClass,"download",[de])}async post(e){return await this._reqClass.post(e)}async upload(e){return await this._reqClass.upload(e)}async download(e){return await this._reqClass.download(e)}async refreshAccessToken(){let e,t;this._refreshAccessTokenPromise||(this._refreshAccessTokenPromise=this._refreshAccessToken());try{e=await this._refreshAccessTokenPromise}catch(e){t=e}if(this._refreshAccessTokenPromise=null,this._shouldRefreshAccessTokenHook=null,t)throw t;return e}async _refreshAccessToken(){const{accessTokenKey:e,accessTokenExpireKey:t,refreshTokenKey:n,loginTypeKey:s,anonymousUuidKey:r}=this._cache.keys;this._cache.removeStore(e),this._cache.removeStore(t);let o=this._cache.getStore(n);if(!o)throw new Error("未登录CloudBase");const i={refresh_token:o},a=await this.request("auth.fetchAccessTokenWithRefreshToken",i);if(a.data.code){const{code:e}=a.data;if("SIGN_PARAM_INVALID"===e||"REFRESH_TOKEN_EXPIRED"===e||"INVALID_REFRESH_TOKEN"===e){if(this._cache.getStore(s)===ce.ANONYMOUS&&"INVALID_REFRESH_TOKEN"===e){const e=this._cache.getStore(r),t=this._cache.getStore(n),s=await this.send("auth.signInAnonymously",{anonymous_uuid:e,refresh_token:t});return this.setRefreshToken(s.refresh_token),this._refreshAccessToken()}te(re),this._cache.removeStore(n)}throw new Error(`刷新access token失败:${a.data.code}`)}if(a.data.access_token)return te(ae),this._cache.setStore(e,a.data.access_token),this._cache.setStore(t,a.data.access_token_expire+Date.now()),{accessToken:a.data.access_token,accessTokenExpire:a.data.access_token_expire};a.data.refresh_token&&(this._cache.removeStore(n),this._cache.setStore(n,a.data.refresh_token),this._refreshAccessToken())}async getAccessToken(){const{accessTokenKey:e,accessTokenExpireKey:t,refreshTokenKey:n}=this._cache.keys;if(!this._cache.getStore(n))throw new Error("refresh token不存在,登录状态异常");let s=this._cache.getStore(e),r=this._cache.getStore(t),o=!0;return this._shouldRefreshAccessTokenHook&&!await this._shouldRefreshAccessTokenHook(s,r)&&(o=!1),(!s||!r||r<Date.now())&&o?this.refreshAccessToken():{accessToken:s,accessTokenExpire:r}}async request(e,t,n){const s=`x-tcb-trace_${this.config.env}`;let r="application/x-www-form-urlencoded";const o={action:e,env:this.config.env,dataVersion:"2019-08-16",...t};if(-1===ue.indexOf(e)){const{refreshTokenKey:e}=this._cache.keys;this._cache.getStore(e)&&(o.access_token=(await this.getAccessToken()).accessToken)}let i;if("storage.uploadFile"===e){i=new FormData;for(let e in i)i.hasOwnProperty(e)&&void 0!==i[e]&&i.append(e,o[e]);r="multipart/form-data"}else{r="application/json",i={};for(let e in o)void 0!==o[e]&&(i[e]=o[e])}let a={headers:{"content-type":r}};n&&n.onUploadProgress&&(a.onUploadProgress=n.onUploadProgress);const c=this._localCache.getStore(s);c&&(a.headers["X-TCB-Trace"]=c);const{parse:u,inQuery:h,search:l}=t;let d={env:this.config.env};u&&(d.parse=!0),h&&(d={...h,...d});let f=function(e,t,n={}){const s=/\?/.test(t);let r="";for(let e in n)""===r?!s&&(t+="?"):r+="&",r+=`${e}=${encodeURIComponent(n[e])}`;return/^http(s)?\:\/\//.test(t+=r)?t:`${e}${t}`}(R,"//tcb-api.tencentcloudapi.com/web",d);l&&(f+=l);const p=await this.post({url:f,data:i,...a}),g=p.header&&p.header["x-tcb-trace"];if(g&&this._localCache.setStore(s,g),200!==Number(p.status)&&200!==Number(p.statusCode)||!p.data)throw new Error("network request error");return p}async send(e,t={}){const n=await this.request(e,t,{onUploadProgress:t.onUploadProgress});if("ACCESS_TOKEN_EXPIRED"===n.data.code&&-1===ue.indexOf(e)){await this.refreshAccessToken();const n=await this.request(e,t,{onUploadProgress:t.onUploadProgress});if(n.data.code)throw new Error(`[${n.data.code}] ${n.data.message}`);return n.data}if(n.data.code)throw new Error(`[${n.data.code}] ${n.data.message}`);return n.data}setRefreshToken(e){const{accessTokenKey:t,accessTokenExpireKey:n,refreshTokenKey:s}=this._cache.keys;this._cache.removeStore(t),this._cache.removeStore(n),this._cache.setStore(s,e)}}const pe={};function ge(e){return pe[e]}class me{constructor(e){this.config=e,this._cache=X(e.env),this._request=ge(e.env)}setRefreshToken(e){const{accessTokenKey:t,accessTokenExpireKey:n,refreshTokenKey:s}=this._cache.keys;this._cache.removeStore(t),this._cache.removeStore(n),this._cache.setStore(s,e)}setAccessToken(e,t){const{accessTokenKey:n,accessTokenExpireKey:s}=this._cache.keys;this._cache.setStore(n,e),this._cache.setStore(s,t)}async refreshUserInfo(){const{data:e}=await this._request.send("auth.getUserInfo",{});return this.setLocalUserInfo(e),e}setLocalUserInfo(e){const{userInfoKey:t}=this._cache.keys;this._cache.setStore(t,e)}}class ye{constructor(e){if(!e)throw new Error("envId is not defined");this._envId=e,this._cache=X(this._envId),this._request=ge(this._envId),this.setUserInfo()}linkWithTicket(e){if("string"!=typeof e)throw new Error("ticket must be string");return this._request.send("auth.linkWithTicket",{ticket:e})}linkWithRedirect(e){e.signInWithRedirect()}updatePassword(e,t){return this._request.send("auth.updatePassword",{oldPassword:t,newPassword:e})}updateEmail(e){return this._request.send("auth.updateEmail",{newEmail:e})}updateUsername(e){if("string"!=typeof e)throw new Error("username must be a string");return this._request.send("auth.updateUsername",{username:e})}async getLinkedUidList(){const{data:e}=await this._request.send("auth.getLinkedUidList",{});let t=!1;const{users:n}=e;return n.forEach((e=>{e.wxOpenId&&e.wxPublicId&&(t=!0)})),{users:n,hasPrimaryUid:t}}setPrimaryUid(e){return this._request.send("auth.setPrimaryUid",{uid:e})}unlink(e){return this._request.send("auth.unlink",{platform:e})}async update(e){const{nickName:t,gender:n,avatarUrl:s,province:r,country:o,city:i}=e,{data:a}=await this._request.send("auth.updateUserInfo",{nickName:t,gender:n,avatarUrl:s,province:r,country:o,city:i});this.setLocalUserInfo(a)}async refresh(){const{data:e}=await this._request.send("auth.getUserInfo",{});return this.setLocalUserInfo(e),e}setUserInfo(){const{userInfoKey:e}=this._cache.keys,t=this._cache.getStore(e);["uid","loginType","openid","wxOpenId","wxPublicId","unionId","qqMiniOpenId","email","hasPassword","customUserId","nickName","gender","avatarUrl"].forEach((e=>{this[e]=t[e]})),this.location={country:t.country,province:t.province,city:t.city}}setLocalUserInfo(e){const{userInfoKey:t}=this._cache.keys;this._cache.setStore(t,e),this.setUserInfo()}}class _e{constructor(e){if(!e)throw new Error("envId is not defined");this._cache=X(e);const{refreshTokenKey:t,accessTokenKey:n,accessTokenExpireKey:s}=this._cache.keys,r=this._cache.getStore(t),o=this._cache.getStore(n),i=this._cache.getStore(s);this.credential={refreshToken:r,accessToken:o,accessTokenExpire:i},this.user=new ye(e)}get isAnonymousAuth(){return this.loginType===ce.ANONYMOUS}get isCustomAuth(){return this.loginType===ce.CUSTOM}get isWeixinAuth(){return this.loginType===ce.WECHAT||this.loginType===ce.WECHAT_OPEN||this.loginType===ce.WECHAT_PUBLIC}get loginType(){return this._cache.getStore(this._cache.keys.loginTypeKey)}}class we extends me{async signIn(){this._cache.updatePersistence("local");const{anonymousUuidKey:e,refreshTokenKey:t}=this._cache.keys,n=this._cache.getStore(e)||void 0,s=this._cache.getStore(t)||void 0,r=await this._request.send("auth.signInAnonymously",{anonymous_uuid:n,refresh_token:s});if(r.uuid&&r.refresh_token){this._setAnonymousUUID(r.uuid),this.setRefreshToken(r.refresh_token),await this._request.refreshAccessToken(),te(se),te(oe,{env:this.config.env,loginType:ce.ANONYMOUS,persistence:"local"});const e=new _e(this.config.env);return await e.user.refresh(),e}throw new Error("匿名登录失败")}async linkAndRetrieveDataWithTicket(e){const{anonymousUuidKey:t,refreshTokenKey:n}=this._cache.keys,s=this._cache.getStore(t),r=this._cache.getStore(n),o=await this._request.send("auth.linkAndRetrieveDataWithTicket",{anonymous_uuid:s,refresh_token:r,ticket:e});if(o.refresh_token)return this._clearAnonymousUUID(),this.setRefreshToken(o.refresh_token),await this._request.refreshAccessToken(),te(ie,{env:this.config.env}),te(oe,{loginType:ce.CUSTOM,persistence:"local"}),{credential:{refreshToken:o.refresh_token}};throw new Error("匿名转化失败")}_setAnonymousUUID(e){const{anonymousUuidKey:t,loginTypeKey:n}=this._cache.keys;this._cache.removeStore(t),this._cache.setStore(t,e),this._cache.setStore(n,ce.ANONYMOUS)}_clearAnonymousUUID(){this._cache.removeStore(this._cache.keys.anonymousUuidKey)}}class ke extends me{async signIn(e){if("string"!=typeof e)throw new Error("ticket must be a string");const{refreshTokenKey:t}=this._cache.keys,n=await this._request.send("auth.signInWithTicket",{ticket:e,refresh_token:this._cache.getStore(t)||""});if(n.refresh_token)return this.setRefreshToken(n.refresh_token),await this._request.refreshAccessToken(),te(se),te(oe,{env:this.config.env,loginType:ce.CUSTOM,persistence:this.config.persistence}),await this.refreshUserInfo(),new _e(this.config.env);throw new Error("自定义登录失败")}}class Se extends me{async signIn(e,t){if("string"!=typeof e)throw new Error("email must be a string");const{refreshTokenKey:n}=this._cache.keys,s=await this._request.send("auth.signIn",{loginType:"EMAIL",email:e,password:t,refresh_token:this._cache.getStore(n)||""}),{refresh_token:r,access_token:o,access_token_expire:i}=s;if(r)return this.setRefreshToken(r),o&&i?this.setAccessToken(o,i):await this._request.refreshAccessToken(),await this.refreshUserInfo(),te(se),te(oe,{env:this.config.env,loginType:ce.EMAIL,persistence:this.config.persistence}),new _e(this.config.env);throw s.code?new Error(`邮箱登录失败: [${s.code}] ${s.message}`):new Error("邮箱登录失败")}async activate(e){return this._request.send("auth.activateEndUserMail",{token:e})}async resetPasswordWithToken(e,t){return this._request.send("auth.resetPasswordWithToken",{token:e,newPassword:t})}}class ve extends me{async signIn(e,t){if("string"!=typeof e)throw new Error("username must be a string");"string"!=typeof t&&(t="",console.warn("password is empty"));const{refreshTokenKey:n}=this._cache.keys,s=await this._request.send("auth.signIn",{loginType:ce.USERNAME,username:e,password:t,refresh_token:this._cache.getStore(n)||""}),{refresh_token:r,access_token_expire:o,access_token:i}=s;if(r)return this.setRefreshToken(r),i&&o?this.setAccessToken(i,o):await this._request.refreshAccessToken(),await this.refreshUserInfo(),te(se),te(oe,{env:this.config.env,loginType:ce.USERNAME,persistence:this.config.persistence}),new _e(this.config.env);throw s.code?new Error(`用户名密码登录失败: [${s.code}] ${s.message}`):new Error("用户名密码登录失败")}}class Te{constructor(e){this.config=e,this._cache=X(e.env),this._request=ge(e.env),this._onAnonymousConverted=this._onAnonymousConverted.bind(this),this._onLoginTypeChanged=this._onLoginTypeChanged.bind(this),ee(oe,this._onLoginTypeChanged)}get currentUser(){const e=this.hasLoginState();return e&&e.user||null}get loginType(){return this._cache.getStore(this._cache.keys.loginTypeKey)}anonymousAuthProvider(){return new we(this.config)}customAuthProvider(){return new ke(this.config)}emailAuthProvider(){return new Se(this.config)}usernameAuthProvider(){return new ve(this.config)}async signInAnonymously(){return new we(this.config).signIn()}async signInWithEmailAndPassword(e,t){return new Se(this.config).signIn(e,t)}signInWithUsernameAndPassword(e,t){return new ve(this.config).signIn(e,t)}async linkAndRetrieveDataWithTicket(e){this._anonymousAuthProvider||(this._anonymousAuthProvider=new we(this.config)),ee(ie,this._onAnonymousConverted);return await this._anonymousAuthProvider.linkAndRetrieveDataWithTicket(e)}async signOut(){if(this.loginType===ce.ANONYMOUS)throw new Error("匿名用户不支持登出操作");const{refreshTokenKey:e,accessTokenKey:t,accessTokenExpireKey:n}=this._cache.keys,s=this._cache.getStore(e);if(!s)return;const r=await this._request.send("auth.logout",{refresh_token:s});return this._cache.removeStore(e),this._cache.removeStore(t),this._cache.removeStore(n),te(se),te(oe,{env:this.config.env,loginType:ce.NULL,persistence:this.config.persistence}),r}async signUpWithEmailAndPassword(e,t){return this._request.send("auth.signUpWithEmailAndPassword",{email:e,password:t})}async sendPasswordResetEmail(e){return this._request.send("auth.sendPasswordResetEmail",{email:e})}onLoginStateChanged(e){ee(se,(()=>{const t=this.hasLoginState();e.call(this,t)}));const t=this.hasLoginState();e.call(this,t)}onLoginStateExpired(e){ee(re,e.bind(this))}onAccessTokenRefreshed(e){ee(ae,e.bind(this))}onAnonymousConverted(e){ee(ie,e.bind(this))}onLoginTypeChanged(e){ee(oe,(()=>{const t=this.hasLoginState();e.call(this,t)}))}async getAccessToken(){return{accessToken:(await this._request.getAccessToken()).accessToken,env:this.config.env}}hasLoginState(){const{refreshTokenKey:e}=this._cache.keys;return this._cache.getStore(e)?new _e(this.config.env):null}async isUsernameRegistered(e){if("string"!=typeof e)throw new Error("username must be a string");const{data:t}=await this._request.send("auth.isUsernameRegistered",{username:e});return t&&t.isRegistered}getLoginState(){return Promise.resolve(this.hasLoginState())}async signInWithTicket(e){return new ke(this.config).signIn(e)}shouldRefreshAccessToken(e){this._request._shouldRefreshAccessTokenHook=e.bind(this)}getUserInfo(){return this._request.send("auth.getUserInfo",{}).then((e=>e.code?e:{...e.data,requestId:e.seqId}))}getAuthHeader(){const{refreshTokenKey:e,accessTokenKey:t}=this._cache.keys,n=this._cache.getStore(e);return{"x-cloudbase-credentials":this._cache.getStore(t)+"/@@/"+n}}_onAnonymousConverted(e){const{env:t}=e.data;t===this.config.env&&this._cache.updatePersistence(this.config.persistence)}_onLoginTypeChanged(e){const{loginType:t,persistence:n,env:s}=e.data;s===this.config.env&&(this._cache.updatePersistence(n),this._cache.setStore(this._cache.keys.loginTypeKey,t))}}const Ae=function(e,t){t=t||N();const n=ge(this.config.env),{cloudPath:s,filePath:r,onUploadProgress:o,fileType:i="image"}=e;return n.send("storage.getUploadMetadata",{path:s}).then((e=>{const{data:{url:a,authorization:c,token:u,fileId:h,cosFileId:l},requestId:d}=e,f={key:s,signature:c,"x-cos-meta-fileid":l,success_action_status:"201","x-cos-security-token":u};n.upload({url:a,data:f,file:r,name:s,fileType:i,onUploadProgress:o}).then((e=>{201===e.statusCode?t(null,{fileID:h,requestId:d}):t(new Error(`STORAGE_REQUEST_FAIL: ${e.data}`))})).catch((e=>{t(e)}))})).catch((e=>{t(e)})),t.promise},Pe=function(e,t){t=t||N();const n=ge(this.config.env),{cloudPath:s}=e;return n.send("storage.getUploadMetadata",{path:s}).then((e=>{t(null,e)})).catch((e=>{t(e)})),t.promise},Ie=function({fileList:e},t){if(t=t||N(),!e||!Array.isArray(e))return{code:"INVALID_PARAM",message:"fileList必须是非空的数组"};for(let t of e)if(!t||"string"!=typeof t)return{code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"};const n={fileid_list:e};return ge(this.config.env).send("storage.batchDeleteFile",n).then((e=>{e.code?t(null,e):t(null,{fileList:e.data.delete_list,requestId:e.requestId})})).catch((e=>{t(e)})),t.promise},be=function({fileList:e},t){t=t||N(),e&&Array.isArray(e)||t(null,{code:"INVALID_PARAM",message:"fileList必须是非空的数组"});let n=[];for(let s of e)"object"==typeof s?(s.hasOwnProperty("fileID")&&s.hasOwnProperty("maxAge")||t(null,{code:"INVALID_PARAM",message:"fileList的元素必须是包含fileID和maxAge的对象"}),n.push({fileid:s.fileID,max_age:s.maxAge})):"string"==typeof s?n.push({fileid:s}):t(null,{code:"INVALID_PARAM",message:"fileList的元素必须是字符串"});const s={file_list:n};return ge(this.config.env).send("storage.batchGetDownloadUrl",s).then((e=>{e.code?t(null,e):t(null,{fileList:e.data.download_list,requestId:e.requestId})})).catch((e=>{t(e)})),t.promise},Oe=async function({fileID:e},t){const n=(await be.call(this,{fileList:[{fileID:e,maxAge:600}]})).fileList[0];if("SUCCESS"!==n.code)return t?t(n):new Promise((e=>{e(n)}));const s=ge(this.config.env);let r=n.download_url;if(r=encodeURI(r),!t)return s.download({url:r});t(await s.download({url:r}))},Ee=function({name:e,data:t,query:n,parse:s,search:r},o){const i=o||N();let a;try{a=t?JSON.stringify(t):""}catch(e){return Promise.reject(e)}if(!e)return Promise.reject(new Error("函数名不能为空"));const c={inQuery:n,parse:s,search:r,function_name:e,request_data:a};return ge(this.config.env).send("functions.invokeFunction",c).then((e=>{if(e.code)i(null,e);else{let t=e.data.response_data;if(s)i(null,{result:t,requestId:e.requestId});else try{t=JSON.parse(e.data.response_data),i(null,{result:t,requestId:e.requestId})}catch(e){i(new Error("response data must be json"))}}return i.promise})).catch((e=>{i(e)})),i.promise},Ce={timeout:15e3,persistence:"session"},Ue={};class xe{constructor(e){this.config=e||this.config,this.authObj=void 0}init(e){switch(K.adapter||(this.requestClient=new K.adapter.reqClass({timeout:e.timeout||5e3,timeoutMsg:`请求在${(e.timeout||5e3)/1e3}s内未完成,已中断`})),this.config={...Ce,...e},!0){case this.config.timeout>6e5:console.warn("timeout大于可配置上限[10分钟],已重置为上限数值"),this.config.timeout=6e5;break;case this.config.timeout<100:console.warn("timeout小于可配置下限[100ms],已重置为下限数值"),this.config.timeout=100}return new xe(this.config)}auth({persistence:e}={}){if(this.authObj)return this.authObj;const t=e||K.adapter.primaryStorage||Ce.persistence;var n;return t!==this.config.persistence&&(this.config.persistence=t),function(e){const{env:t}=e;V[t]=new J(e),Y[t]=new J({...e,persistence:"local"})}(this.config),n=this.config,pe[n.env]=new fe(n),this.authObj=new Te(this.config),this.authObj}on(e,t){return ee.apply(this,[e,t])}off(e,t){return ne.apply(this,[e,t])}callFunction(e,t){return Ee.apply(this,[e,t])}deleteFile(e,t){return Ie.apply(this,[e,t])}getTempFileURL(e,t){return be.apply(this,[e,t])}downloadFile(e,t){return Oe.apply(this,[e,t])}uploadFile(e,t){return Ae.apply(this,[e,t])}getUploadMetadata(e,t){return Pe.apply(this,[e,t])}registerExtension(e){Ue[e.name]=e}async invokeExtension(e,t){const n=Ue[e];if(!n)throw Error(`扩展${e} 必须先注册`);return await n.invoke(t,this)}useAdapters(e){const{adapter:t,runtime:n}=B(e)||{};t&&(K.adapter=t),n&&(K.runtime=n)}}var De=new xe;function qe(e,t,n){void 0===n&&(n={});var s=/\?/.test(t),r="";for(var o in n)""===r?!s&&(t+="?"):r+="&",r+=o+"="+encodeURIComponent(n[o]);return/^http(s)?:\/\//.test(t+=r)?t:""+e+t}class Re{post(e){const{url:t,data:n,headers:s}=e;return new Promise(((e,r)=>{C.request({url:qe("https:",t),data:n,method:"POST",header:s,success(t){e(t)},fail(e){r(e)}})}))}upload(e){return new Promise(((t,n)=>{const{url:s,file:r,data:o,headers:i,fileType:a}=e,c=C.uploadFile({url:qe("https:",s),name:"file",formData:Object.assign({},o),filePath:r,fileType:a,header:i,success(e){const n={statusCode:e.statusCode,data:e.data||{}};200===e.statusCode&&o.success_action_status&&(n.statusCode=parseInt(o.success_action_status,10)),t(n)},fail(e){l&&"mp-alipay"===d&&console.warn("支付宝小程序开发工具上传腾讯云时无法准确判断是否上传成功,请使用真机测试"),n(new Error(e.errMsg||"uploadFile:fail"))}});"function"==typeof e.onUploadProgress&&c&&"function"==typeof c.onProgressUpdate&&c.onProgressUpdate((t=>{e.onUploadProgress({loaded:t.totalBytesSent,total:t.totalBytesExpectedToSend})}))}))}}const Le={setItem(e,t){C.setStorageSync(e,t)},getItem:e=>C.getStorageSync(e),removeItem(e){C.removeStorageSync(e)},clear(){C.clearStorageSync()}};var Fe={genAdapter:function(){return{root:{},reqClass:Re,localStorage:Le,primaryStorage:"local"}},isMatch:function(){return!0},runtime:"uni_app"};De.useAdapters(Fe);const Ne=De,$e=Ne.init;Ne.init=function(e){e.env=e.spaceId;const t=$e.call(this,e);t.config.provider="tencent",t.config.spaceId=e.spaceId;const n=t.auth;return t.auth=function(e){const t=n.call(this,e);return["linkAndRetrieveDataWithTicket","signInAnonymously","signOut","getAccessToken","getLoginState","signInWithTicket","getUserInfo"].forEach((e=>{t[e]=P(t[e]).bind(t)})),t},t.customAuth=t.auth,t};var je=Ne;function Me(){return{token:C.getStorageSync("uni_id_token")||C.getStorageSync("uniIdToken"),tokenExpired:C.getStorageSync("uni_id_token_expired")}}function Be(){if(!l||"h5"!==d)return;uni.getStorageSync("__LAST_DCLOUD_APPID")!==m&&(uni.setStorageSync("__LAST_DCLOUD_APPID",m),console.warn("检测到当前项目与上次运行到此端口的项目不一致,自动清理uni-id保存的token信息(仅开发调试时生效)"),C.removeStorageSync("uni_id_token"),C.removeStorageSync("uniIdToken"),C.removeStorageSync("uni_id_token_expired"))}var Ke=class extends D{getAccessToken(){return new Promise(((e,t)=>{const n="Anonymous_Access_token";this.setAccessToken(n),e(n)}))}setupRequest(e,t){const n=Object.assign({},e,{spaceId:this.config.spaceId,timestamp:Date.now()}),s={"Content-Type":"application/json"};"auth"!==t&&(n.token=this.accessToken,s["x-basement-token"]=this.accessToken),s["x-serverless-sign"]=E.sign(n,this.config.clientSecret);const r=O();s["x-client-info"]=JSON.stringify(r);const{token:o}=Me();return s["x-client-token"]=o,{url:this.config.requestUrl,method:"POST",data:n,dataType:"json",header:JSON.parse(JSON.stringify(s))}}uploadFileToOSS({url:e,formData:t,name:n,filePath:s,fileType:r,onUploadProgress:o}){return new Promise(((i,a)=>{const c=this.adapter.uploadFile({url:e,formData:t,name:n,filePath:s,fileType:r,success(e){e&&e.statusCode<400?i(e):a(new I({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){a(new I({code:e.code||"UPLOAD_FAILED",message:e.message||e.errMsg||"文件上传失败"}))}});"function"==typeof o&&c&&"function"==typeof c.onProgressUpdate&&c.onProgressUpdate((e=>{o({loaded:e.totalBytesSent,total:e.totalBytesExpectedToSend})}))}))}uploadFile({filePath:e,cloudPath:t,fileType:n="image",onUploadProgress:s}){if(!t)throw new I({code:"CLOUDPATH_REQUIRED",message:"cloudPath不可为空"});let r;return this.getOSSUploadOptionsFromPath({cloudPath:t}).then((t=>{const{url:o,formData:i,name:a}=t.result;r=t.result.fileUrl;const c={url:o,formData:i,name:a,filePath:e,fileType:n};return this.uploadFileToOSS(Object.assign({},c,{onUploadProgress:s}))})).then((()=>this.reportOSSUpload({cloudPath:t}))).then((t=>new Promise(((n,s)=>{t.success?n({success:!0,filePath:e,fileID:r}):s(new I({code:"UPLOAD_FAILED",message:"文件上传失败"}))}))))}deleteFile({fileList:e}){const t={method:"serverless.file.resource.delete",params:JSON.stringify({fileList:e})};return this.request(this.setupRequest(t))}getTempFileURL({fileList:e}={}){const t={method:"serverless.file.resource.getTempFileURL",params:JSON.stringify({fileList:e})};return this.request(this.setupRequest(t))}};var He={init(e){const t=new Ke(e),n={signInAnonymously:function(){return t.authorize()},getLoginState:function(){return Promise.resolve(!1)}};return t.auth=function(){return n},t.customAuth=t.auth,t}};function We({data:e}){let t;t=O();const n=JSON.parse(JSON.stringify(e||{}));if(Object.assign(n,{clientInfo:t}),!n.uniIdToken){const{token:e}=Me();e&&(n.uniIdToken=e)}return n}function ze({name:e,data:t}){const{localAddress:n,localPort:s}=this,r={aliyun:"aliyun",tencent:"tcb"}[this.config.provider],o=this.config.spaceId,i=`http://${n}:${s}/system/check-function`,a=`http://${n}:${s}/cloudfunctions/${e}`;return new Promise(((t,n)=>{C.request({method:"POST",url:i,data:{name:e,platform:d,provider:r,spaceId:o},timeout:3e3,success(e){t(e)},fail(){t({data:{code:"NETWORK_ERROR",message:"连接本地调试服务失败,请检查客户端是否和主机在同一局域网下,自动切换为已部署的云函数。"}})}})})).then((({data:e}={})=>{const{code:t,message:n}=e||{};return{code:0===t?0:t||"SYS_ERR",message:n||"SYS_ERR"}})).then((({code:n,message:s})=>{if(0!==n){switch(n){case"MODULE_ENCRYPTED":console.error(`此云函数(${e})依赖加密公共模块不可本地调试,自动切换为云端已部署的云函数`);break;case"FUNCTION_ENCRYPTED":console.error(`此云函数(${e})已加密不可本地调试,自动切换为云端已部署的云函数`);break;case"ACTION_ENCRYPTED":console.error(s||"需要访问加密的uni-clientDB-action,自动切换为云端环境");break;case"NETWORK_ERROR":{const e="连接本地调试服务失败,请检查客户端是否和主机在同一局域网下";throw console.error(e),new Error(e)}case"SWITCH_TO_CLOUD":break;default:{const e=`检测本地调试服务出现错误:${s},请检查网络环境或重启客户端再试`;throw console.error(e),new Error(e)}}return this._originCallFunction({name:e,data:t})}return new Promise(((e,n)=>{const s=We.call(this,{data:t});C.request({method:"POST",url:a,data:{provider:r,platform:d,param:s},success:({statusCode:t,data:s}={})=>!t||t>=400?n(new I({code:s.code||"SYS_ERR",message:s.message||"request:fail"})):e({result:s}),fail(e){n(new I({code:e.code||e.errCode||"SYS_ERR",message:e.message||e.errMsg||"request:fail"}))}})}))}))}const Je=[{rule:/fc_function_not_found|FUNCTION_NOT_FOUND/,content:",云函数[{functionName}]在云端不存在,请检查此云函数名称是否正确以及该云函数是否已上传到服务空间",mode:"append"}];var Ve=/[\\^$.*+?()[\]{}|]/g,Ye=RegExp(Ve.source);function Xe(e,t,n){return e.replace(new RegExp((s=t)&&Ye.test(s)?s.replace(Ve,"\\$&"):s,"g"),n);var s}function Ge({functionName:e,result:t,logPvd:n}){if(this.config.useDebugFunction&&t&&t.requestId){const s=JSON.stringify({spaceId:this.config.spaceId,functionName:e,requestId:t.requestId});console.log(`[${n}-request]${s}[/${n}-request]`)}}function Qe(e){const t=e.callFunction,n=function(n){const s=n.name;n.data=We.call(e,{data:n.data});const r={aliyun:"aliyun",tencent:"tcb"}[this.config.provider];return t.call(this,n).then((e=>(Ge.call(this,{functionName:s,result:e,logPvd:r}),Promise.resolve(e))),(e=>(Ge.call(this,{functionName:s,result:e,logPvd:r}),e&&e.message&&(e.message=function({message:e="",extraInfo:t={},formatter:n=[]}={}){for(let s=0;s<n.length;s++){const{rule:r,content:o,mode:i}=n[s],a=e.match(r);if(!a)continue;let c=o;for(let e=1;e<a.length;e++)c=Xe(c,`{$${e}}`,a[e]);for(const e in t)c=Xe(c,`{${e}}`,t[e]);return"replace"===i?c:e+c}return e}({message:`[${n.name}]: ${e.message}`,formatter:Je,extraInfo:{functionName:s}})),Promise.reject(e))))};e.callFunction=function(t){let s;return l&&e.debugInfo&&!e.debugInfo.forceRemote&&p?(e._originCallFunction||(e._originCallFunction=n),s=ze.call(this,t)):s=n.call(this,t),Object.defineProperty(s,"result",{get:()=>(console.warn("当前返回结果为Promise类型,不可直接访问其result属性,详情请参考:https://uniapp.dcloud.net.cn/uniCloud/faq?id=promise"),{})}),s}}const Ze=Symbol("CLIENT_DB_INTERNAL");function et(e,t){return e.then="DoNotReturnProxyWithAFunctionNamedThen",e._internalType=Ze,e.__ob__=void 0,new Proxy(e,{get(e,n,s){if("_uniClient"===n)return null;if(n in e||"string"!=typeof n){const t=e[n];return"function"==typeof t?t.bind(e):t}return t.get(e,n,s)}})}function tt(e){return{on:(t,n)=>{e[t]=e[t]||[],e[t].indexOf(n)>-1||e[t].push(n)},off:(t,n)=>{e[t]=e[t]||[];const s=e[t].indexOf(n);-1!==s&&e[t].splice(s,1)}}}const nt=["db.Geo","db.command","command.aggregate"];function st(e,t){return nt.indexOf(`${e}.${t}`)>-1}function rt(e){switch(c(e)){case"array":return e.map((e=>rt(e)));case"object":return e._internalType===Ze||Object.keys(e).forEach((t=>{e[t]=rt(e[t])})),e;case"regexp":return{$regexp:{source:e.source,flags:e.flags}};case"date":return{$date:e.toISOString()};default:return e}}class ot{constructor(e,t,n){this.content=e,this.prevStage=t||null,this.udb=null,this._database=n}toJSON(){let e=this;const t=[e.content];for(;e.prevStage;)e=e.prevStage,t.push(e.content);return{$db:t.reverse().map((e=>({$method:e.$method,$param:rt(e.$param)})))}}getAction(){const e=this.toJSON().$db.find((e=>"action"===e.$method));return e&&e.$param&&e.$param[0]}getCommand(){return{$db:this.toJSON().$db.filter((e=>"action"!==e.$method))}}get useAggregate(){let e=this,t=!1;for(;e.prevStage;){e=e.prevStage;const n=e.content.$method;if("aggregate"===n||"pipeline"===n){t=!0;break}}return t}get count(){if(!this.useAggregate)return function(){return this._send("count",Array.from(arguments))};const e=this;return function(){return it({$method:"count",$param:rt(Array.from(arguments))},e,this._database)}}get(){return this._send("get",Array.from(arguments))}add(){return this._send("add",Array.from(arguments))}remove(){return this._send("remove",Array.from(arguments))}update(){return this._send("update",Array.from(arguments))}end(){return this._send("end",Array.from(arguments))}set(){throw new Error("clientDB禁止使用set方法")}_send(e,t){const n=this.getAction(),s=this.getCommand();if(s.$db.push({$method:e,$param:rt(t)}),l){const e=s.$db.find((e=>"collection"===e.$method)),t=e&&e.$param;t&&1===t.length&&"string"==typeof e.$param[0]&&e.$param[0].indexOf(",")>-1&&console.warn("检测到使用JQL语法联表查询时,未使用getTemp先过滤主表数据,在主表数据量大的情况下可能会查询缓慢。\n- 如何优化请参考此文档:https://uniapp.dcloud.net.cn/uniCloud/jql?id=lookup-with-temp \n- 如果主表数据量很小请忽略此信息,项目发行时不会出现此提示。")}return this._database._callCloudFunction({action:n,command:s})}}function it(e,t,n){return et(new ot(e,t,n),{get(e,t){let s="db";return e&&e.content&&(s=e.content.$method),st(s,t)?it({$method:t},e,n):function(){return it({$method:t,$param:rt(Array.from(arguments))},e,n)}}})}function at({path:e,method:t}){return class{constructor(){this.param=Array.from(arguments)}toJSON(){return{$newDb:[...e.map((e=>({$method:e}))),{$method:t,$param:this.param}]}}}}class ct extends class{constructor({uniClient:e={}}={}){this._uniClient=e,this._authCallBacks={},this._dbCallBacks={},e.isDefault&&(this._dbCallBacks=_("_globalUniCloudDatabaseCallback")),this.auth=tt(this._authCallBacks),Object.assign(this,tt(this._dbCallBacks)),this.env=et({},{get:(e,t)=>({$env:t})}),this.Geo=et({},{get:(e,t)=>at({path:["Geo"],method:t})}),this.serverDate=at({path:[],method:"serverDate"}),this.RegExp=at({path:[],method:"RegExp"})}getCloudEnv(e){if("string"!=typeof e||!e.trim())throw new Error("getCloudEnv参数错误");return{$env:e.replace("$cloudEnv_","")}}_callback(e,t){const n=this._dbCallBacks;n[e]&&n[e].forEach((e=>{e(...t)}))}_callbackAuth(e,t){const n=this._authCallBacks;n[e]&&n[e].forEach((e=>{e(...t)}))}multiSend(){const e=Array.from(arguments),t=e.map((e=>{const t=e.getAction(),n=e.getCommand();if("getTemp"!==n.$db[n.$db.length-1].$method)throw new Error("multiSend只支持子命令内使用getTemp");return{action:t,command:n}}));return this._callCloudFunction({multiCommand:t,queryList:e})}}{_callCloudFunction({action:e,command:t,multiCommand:n,queryList:s}){function r(e,t){if(n&&s)for(let n=0;n<s.length;n++){const r=s[n];r.udb&&"function"==typeof r.udb.setResult&&(t?r.udb.setResult(t):r.udb.setResult(e.result.dataList[n]))}}const o=T(A("database","invoke")),i=this._uniClient;return o.then((()=>i.callFunction({name:"DCloud-clientDB",type:a,data:{action:e,command:t,multiCommand:n}}))).then((e=>{const{code:t,message:n,token:s,tokenExpired:o,systemInfo:i=[]}=e.result;if(i)for(let e=0;e<i.length;e++){const{level:t,message:n,detail:s}=i[e],r=console["app-plus"===d&&"warn"===t?"error":t]||console.log;let o="[System Info]"+n;s&&(o=`${o}\n详细信息:${s}`),r(o)}if(t){const s=new I({message:n,code:t,requestId:e.requestId});return this._callback("error",[s]),Promise.reject(s)}s&&o&&(!function({token:e,tokenExpired:t}={}){e&&C.setStorageSync("uni_id_token",e),t&&C.setStorageSync("uni_id_token_expired",t)}({token:s,tokenExpired:o}),this._callbackAuth("refreshToken",[{token:s,tokenExpired:o}]),this._callback("refreshToken",[{token:s,tokenExpired:o}]));const a=e.result.affectedDocs;return"number"==typeof a&&Object.defineProperty(e.result,"affectedDocs",{get:()=>(console.warn("affectedDocs不再推荐使用,请使用inserted/deleted/updated/data.length替代"),a)}),T(A("database","success"),e).then((()=>T(A("database","complete"),e))).then((()=>(r(e,null),Promise.resolve(e))))}),(e=>{const t=new I({code:e.code||"SYSTEM_ERROR",message:e.message,requestId:e.requestId});return this._callback("error",[t]),/fc_function_not_found|FUNCTION_NOT_FOUND/g.test(e.message)&&console.warn("clientDB未初始化,请在web控制台保存一次schema以开启clientDB"),T(A("database","fail"),e).then((()=>T(A("database","complete"),e))).then((()=>(r(null,e),Promise.reject(e))))}))}}function ut(e){e.database=function(t){if(t&&Object.keys(t).length>0)return e.init(t).database();if(this._database)return this._database;const n=function(e,t={}){return et(new e(t),{get:(e,t)=>st("db",t)?it({$method:t},null,e):function(){return it({$method:t,$param:rt(Array.from(arguments))},null,e)}})}(ct,{uniClient:e});return this._database=n,n}}let ht;const lt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",dt=/^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;function ft(){const e=Me().token||"",t=e.split(".");if(!e||3!==t.length)return{uid:null,role:[],permission:[],tokenExpired:0};let n;try{n=JSON.parse((s=t[1],decodeURIComponent(ht(s).split("").map((function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)})).join(""))))}catch(e){throw new Error("获取当前用户信息出错,详细错误信息为:"+e.message)}var s;return n.tokenExpired=1e3*n.exp,delete n.exp,delete n.iat,n}ht="function"!=typeof atob?function(e){if(e=String(e).replace(/[\t\n\f\r ]+/g,""),!dt.test(e))throw new Error("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");var t;e+="==".slice(2-(3&e.length));for(var n,s,r="",o=0;o<e.length;)t=lt.indexOf(e.charAt(o++))<<18|lt.indexOf(e.charAt(o++))<<12|(n=lt.indexOf(e.charAt(o++)))<<6|(s=lt.indexOf(e.charAt(o++))),r+=64===n?String.fromCharCode(t>>16&255):64===s?String.fromCharCode(t>>16&255,t>>8&255):String.fromCharCode(t>>16&255,t>>8&255,255&t);return r}:atob;var pt=t(n((function(e,t){Object.defineProperty(t,"__esModule",{value:!0});const n="chooseAndUploadFile:ok",s="chooseAndUploadFile:fail";function r(e,t){return e.tempFiles.forEach(((e,n)=>{e.name||(e.name=e.path.substring(e.path.lastIndexOf("/")+1)),t&&(e.fileType=t),e.cloudPath=Date.now()+"_"+n+e.name.substring(e.name.lastIndexOf("."))})),e.tempFilePaths||(e.tempFilePaths=e.tempFiles.map((e=>e.path))),e}function o(e,t,{onChooseFile:s,onUploadProgress:r}){return t.then((e=>{if(s){const t=s(e);if(void 0!==t)return Promise.resolve(t).then((t=>void 0===t?e:t))}return e})).then((t=>!1===t?{errMsg:n,tempFilePaths:[],tempFiles:[]}:function(e,t,s=5,r){(t=Object.assign({},t)).errMsg=n;const o=t.tempFiles,i=o.length;let a=0;return new Promise((n=>{for(;a<s;)c();function c(){const s=a++;if(s>=i)return void(!o.find((e=>!e.url&&!e.errMsg))&&n(t));const u=o[s];e.uploadFile({filePath:u.path,cloudPath:u.cloudPath,fileType:u.fileType,onUploadProgress(e){e.index=s,e.tempFile=u,e.tempFilePath=u.path,r&&r(e)}}).then((e=>{u.url=e.fileID,s<i&&c()})).catch((e=>{u.errMsg=e.errMsg||e.message,s<i&&c()}))}}))}(e,t,5,r)))}t.initChooseAndUploadFile=function(e){return function(t={type:"all"}){return"image"===t.type?o(e,function(e){const{count:t,sizeType:n,sourceType:o=["album","camera"],extension:i}=e;return new Promise(((e,a)=>{uni.chooseImage({count:t,sizeType:n,sourceType:o,extension:i,success(t){e(r(t,"image"))},fail(e){a({errMsg:e.errMsg.replace("chooseImage:fail",s)})}})}))}(t),t):"video"===t.type?o(e,function(e){const{camera:t,compressed:n,maxDuration:o,sourceType:i=["album","camera"],extension:a}=e;return new Promise(((e,c)=>{uni.chooseVideo({camera:t,compressed:n,maxDuration:o,sourceType:i,extension:a,success(t){const{tempFilePath:n,duration:s,size:o,height:i,width:a}=t;e(r({errMsg:"chooseVideo:ok",tempFilePaths:[n],tempFiles:[{name:t.tempFile&&t.tempFile.name||"",path:n,size:o,type:t.tempFile&&t.tempFile.type||"",width:a,height:i,duration:s,fileType:"video",cloudPath:""}]},"video"))},fail(e){c({errMsg:e.errMsg.replace("chooseVideo:fail",s)})}})}))}(t),t):o(e,function(e){const{count:t,extension:n}=e;return new Promise(((e,o)=>{let i=uni.chooseFile;if("undefined"!=typeof wx&&"function"==typeof wx.chooseMessageFile&&(i=wx.chooseMessageFile),"function"!=typeof i)return o({errMsg:s+" 请指定 type 类型,该平台仅支持选择 image 或 video。"});i({type:"all",count:t,extension:n,success(t){e(r(t))},fail(e){o({errMsg:e.errMsg.replace("chooseFile:fail",s)})}})}))}(t),t)}}})));const gt="manual";function mt(e){return{props:{localdata:{type:Array,default:()=>[]},options:{type:[Object,Array],default:()=>({})},spaceInfo:{type:Object,default:()=>({})},collection:{type:[String,Array],default:""},action:{type:String,default:""},field:{type:String,default:""},orderby:{type:String,default:""},where:{type:[String,Object],default:""},pageData:{type:String,default:"add"},pageCurrent:{type:Number,default:1},pageSize:{type:Number,default:20},getcount:{type:[Boolean,String],default:!1},gettree:{type:[Boolean,String],default:!1},gettreepath:{type:[Boolean,String],default:!1},startwith:{type:String,default:""},limitlevel:{type:Number,default:10},groupby:{type:String,default:""},groupField:{type:String,default:""},distinct:{type:[Boolean,String],default:!1},foreignKey:{type:String,default:""},loadtime:{type:String,default:"auto"},manual:{type:Boolean,default:!1}},data:()=>({mixinDatacomLoading:!1,mixinDatacomHasMore:!1,mixinDatacomResData:[],mixinDatacomErrorMessage:"",mixinDatacomPage:{}}),created(){this.mixinDatacomPage={current:this.pageCurrent,size:this.pageSize,count:0},this.$watch((()=>{var e=[];return["pageCurrent","pageSize","localdata","collection","action","field","orderby","where","getont","getcount","gettree","groupby","groupField","distinct"].forEach((t=>{e.push(this[t])})),e}),((e,t)=>{if(this.loadtime===gt)return;let n=!1;const s=[];for(let r=2;r<e.length;r++)e[r]!==t[r]&&(s.push(e[r]),n=!0);e[0]!==t[0]&&(this.mixinDatacomPage.current=this.pageCurrent),this.mixinDatacomPage.size=this.pageSize,this.onMixinDatacomPropsChange(n,s)}))},methods:{onMixinDatacomPropsChange(e,t){},mixinDatacomEasyGet({getone:e=!1,success:t,fail:n}={}){this.mixinDatacomLoading||(this.mixinDatacomLoading=!0,this.mixinDatacomErrorMessage="",this.mixinDatacomGet().then((n=>{this.mixinDatacomLoading=!1;const{data:s,count:r}=n.result;this.getcount&&(this.mixinDatacomPage.count=r),this.mixinDatacomHasMore=s.length<this.pageSize;const o=e?s.length?s[0]:void 0:s;this.mixinDatacomResData=o,t&&t(o)})).catch((e=>{this.mixinDatacomLoading=!1,this.mixinDatacomErrorMessage=e,n&&n(e)})))},mixinDatacomGet(t={}){let n=e.database(this.spaceInfo);const s=t.action||this.action;s&&(n=n.action(s));const r=t.collection||this.collection;n=Array.isArray(r)?n.collection(...r):n.collection(r);const o=t.where||this.where;o&&Object.keys(o).length&&(n=n.where(o));const i=t.field||this.field;i&&(n=n.field(i));const a=t.foreignKey||this.foreignKey;a&&(n=n.foreignKey(a));const c=t.groupby||this.groupby;c&&(n=n.groupBy(c));const u=t.groupField||this.groupField;u&&(n=n.groupField(u));!0===(void 0!==t.distinct?t.distinct:this.distinct)&&(n=n.distinct());const h=t.orderby||this.orderby;h&&(n=n.orderBy(h));const l=void 0!==t.pageCurrent?t.pageCurrent:this.mixinDatacomPage.current,d=void 0!==t.pageSize?t.pageSize:this.mixinDatacomPage.size,f=void 0!==t.getcount?t.getcount:this.getcount,p=void 0!==t.gettree?t.gettree:this.gettree,g=void 0!==t.gettreepath?t.gettreepath:this.gettreepath,m={getCount:f},y={limitLevel:void 0!==t.limitlevel?t.limitlevel:this.limitlevel,startWith:void 0!==t.startwith?t.startwith:this.startwith};return p&&(m.getTree=y),g&&(m.getTreePath=y),n=n.skip(d*(l-1)).limit(d).get(m),n}}}}function yt(e){return function(t,n={}){n=function(e,t={}){return e.customUI=t.customUI||e.customUI,Object.assign(e.loadingOptions,t.loadingOptions),Object.assign(e.errorOptions,t.errorOptions),e}({customUI:!1,loadingOptions:{text:"加载中...",mask:!0},errorOptions:{type:"modal",retry:!1}},n);const{customUI:s,loadingOptions:r,errorOptions:o}=n,a=!s;return new Proxy({},{get:(n,s)=>async function n(...c){let u;a&&uni.showLoading({title:r.title,mask:r.mask});try{u=await e.callFunction({name:t,type:i,data:{method:s,params:c}})}catch(e){u={result:e}}const{errCode:h,errMsg:l}=u.result||{};if(a&&uni.hideLoading(),h){if(a)if("toast"===o.type)uni.showToast({title:l});else{if("modal"!==o.type)throw new Error(`Invalid errorOptions.type: ${o.type}`);{const{confirm:e}=await async function({title:e,content:t,showCancel:n,cancelText:s,confirmText:r}={}){return new Promise(((o,i)=>{uni.showModal({title:e,content:t,showCancel:n,cancelText:s,confirmText:r,success(e){o(e)},fail(){o({confirm:!1,cancel:!0})}})}))}({title:"提示",content:l,showCancel:o.retry,cancelText:"取消",confirmText:o.retry?"重试":"确定"});if(o.retry&&e)return n(...c)}}const e=new I({code:h,message:l,requestId:u.requestId});throw e.detail=u.result,e}return u.result}})}}async function _t(e,t){const n=`http://${e}:${t}/system/ping`;try{const e=await(s={url:n,timeout:500},new Promise(((e,t)=>{C.request({...s,success(t){e(t)},fail(e){t(e)}})})));return!(!e.data||0!==e.data.code)}catch(e){return!1}var s}function wt(e){if(e.initUniCloudStatus&&"rejected"!==e.initUniCloudStatus)return;let t=Promise.resolve();var n;n=1,t=new Promise(((e,t)=>{setTimeout((()=>{e()}),n)})),e.isReady=!1,e.isDefault=!1;const s=e.auth();e.initUniCloudStatus="pending",e.initUniCloud=t.then((()=>s.getLoginState())).then((e=>e?Promise.resolve():s.signInAnonymously())).then((()=>{if(!l)return Promise.resolve();if(l&&e.debugInfo){const{address:t,servePort:n}=e.debugInfo;return async function(e,t){let n;for(let s=0;s<e.length;s++){const r=e[s];if(await _t(r,t)){n=r;break}}return{address:n,port:t}}(t,n)}})).then((({address:t,port:n}={})=>{if(!l)return Promise.resolve();if(t)e.localAddress=t,e.localPort=n;else if(e.debugInfo){const t=console["app-plus"===d?"error":"warn"];let n="";"remote"===e.debugInfo.initialLaunchType?(e.debugInfo.forceRemote=!0,n="当前客户端和HBuilderX不在同一局域网下(或其他网络原因无法连接HBuilderX),uniCloud本地调试服务不对当前客户端生效。\n- 如果不使用uniCloud本地调试服务,请直接忽略此信息。\n- 如需使用uniCloud本地调试服务,请将客户端与主机连接到同一局域网下并重新运行到客户端。\n- 如果在HBuilderX开启的状态下切换过网络环境,请重启HBuilderX后再试\n- 检查系统防火墙是否拦截了HBuilderX自带的nodejs"):n="无法连接uniCloud本地调试服务,请检查当前客户端是否与主机在同一局域网下。\n- 如需使用uniCloud本地调试服务,请将客户端与主机连接到同一局域网下并重新运行到客户端。\n- 如果在HBuilderX开启的状态下切换过网络环境,请重启HBuilderX后再试\n- 检查系统防火墙是否拦截了HBuilderX自带的nodejs","h5"===d&&(n+="\n- 部分浏览器开启节流模式之后访问本地地址受限,请检查是否启用了节流模式"),t(n)}})).then((()=>{Be(),e.isReady=!0,e.initUniCloudStatus="fulfilled"})).catch((t=>{console.error(t),e.initUniCloudStatus="rejected"}))}let kt=new class{init(e){let t={};const n=!1!==e.debugFunction&&l&&("h5"===d&&navigator.userAgent.indexOf("HBuilderX")>0||"app-plus"===d);switch(e.provider){case"tencent":t=je.init(Object.assign(e,{useDebugFunction:n}));break;case"aliyun":t=q.init(Object.assign(e,{useDebugFunction:n}));break;case"private":t=He.init(Object.assign(e,{useDebugFunction:n}));break;default:throw new Error("未提供正确的provider参数")}const s=f;l&&s&&!s.code&&(t.debugInfo=s),wt(t),t.reInit=function(){wt(this)},Qe(t),function(e){const t=e.uploadFile;e.uploadFile=function(e){return t.call(this,e)}}(t),ut(t),function(e){e.getCurrentUserInfo=ft,e.chooseAndUploadFile=pt.initChooseAndUploadFile(e),Object.assign(e,{get mixinDatacom(){return mt(e)}}),e.importObject=yt(e)}(t);return["callFunction","uploadFile","deleteFile","getTempFileURL","downloadFile","chooseAndUploadFile"].forEach((e=>{if(!t[e])return;const n=t[e];t[e]=function(){return t.reInit(),n.apply(t,Array.from(arguments))},t[e]=P(t[e],e).bind(t)})),t.init=this.init,t}};(()=>{{const e=p;let t={};if(1===e.length)t=e[0],kt=kt.init(t),kt.isDefault=!0;else{const t=["auth","callFunction","uploadFile","deleteFile","getTempFileURL","downloadFile","database","getCurrentUSerInfo","importObject"];let n;n=e&&e.length>0?"应用有多个服务空间,请通过uniCloud.init方法指定要使用的服务空间":g?"应用未关联服务空间,请在uniCloud目录右键关联服务空间":"uni-app cli项目内使用uniCloud需要使用HBuilderX的运行菜单运行项目,且需要在uniCloud目录关联服务空间",t.forEach((e=>{kt[e]=function(){return console.error(n),Promise.reject(new I({code:"SYS_ERR",message:n}))}}))}Object.assign(kt,{get mixinDatacom(){return mt(kt)}}),kt.addInterceptor=S,kt.removeInterceptor=v,l&&"h5"===d&&(window.uniCloud=kt)}})();var St=kt;export{St as default};
|