提交 05a38735 编写于 作者: fxy060608's avatar fxy060608

Merge branch 'dev' of https://github.com/dcloudio/uni-app into alpha

......@@ -30,7 +30,7 @@ module.exports = {
}
if (PLATFORMS.indexOf(scriptOptions.env.UNI_PLATFORM) === -1) {
console.error(`UNI_PLATFORM 支持下平台 ${JSON.stringify(PLATFORMS)}`)
console.error(`UNI_PLATFORM 支持下平台 ${JSON.stringify(PLATFORMS)}`)
process.exit(0)
}
......@@ -41,4 +41,4 @@ module.exports = {
return scriptOptions
}
}
}
......@@ -36,7 +36,11 @@ const uniPath = process.env.UNI_USING_V8
? '../packages/uni-app-plus-nvue-v8/dist/index.js'
: '../packages/uni-app-plus-nvue/dist/index.js'
const provide = {}
const uniCloudPath = require.resolve('@dcloudio/vue-cli-plugin-uni/packages/uni-cloud/dist/index.js')
const provide = {
'uniCloud': [uniCloudPath, 'default']
}
if (process.env.UNI_USING_V3 || process.env.UNI_USING_NATIVE) {
provide['uni.getCurrentSubNVue'] = [path.resolve(__dirname,
......@@ -68,7 +72,8 @@ const plugins = [
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify(process.env.NODE_ENV),
'VUE_APP_PLATFORM': JSON.stringify(process.env.UNI_PLATFORM)
'VUE_APP_PLATFORM': JSON.stringify(process.env.UNI_PLATFORM),
'UNI_CLOUD_PROVIDER': process.env.UNI_CLOUD_PROVIDER
}
}),
new webpack.BannerPlugin({
......
......@@ -64,6 +64,9 @@ function getWebpackConfig (api, args, options) {
})
} else {
modifyConfig(webpackConfig, config => {
if (!config.optimization) {
config.optimization = {}
}
config.optimization.namedModules = false
})
}
......@@ -77,11 +80,11 @@ function getWebpackConfigs (api, args, options) {
const pluginOptions = (options.pluginOptions || (options.pluginOptions = {}))
pluginOptions['uni-app-plus'] = {
service: true
}
}
options.publicPath = '/'
const serviceWebpackConfig = getWebpackConfig(api, args, options)
delete pluginOptions['uni-app-plus']['service']
pluginOptions['uni-app-plus']['view'] = true
pluginOptions['uni-app-plus']['view'] = true
options.publicPath = './'
const viewWebpackConfig = getWebpackConfig(api, args, options)
return [serviceWebpackConfig, viewWebpackConfig]
......
......@@ -24,6 +24,7 @@ const {
const runtimePath = '@dcloudio/uni-mp-weixin/dist/mp.js'
const wxsPath = '@dcloudio/uni-mp-weixin/dist/wxs.js'
const uniCloudPath = path.resolve(__dirname, '../../packages/uni-cloud/dist/index.js')
function getProvides (isAppService) {
if (isAppService) {
......@@ -35,7 +36,8 @@ function getProvides (isAppService) {
'Component': [runtimePath, 'Component'],
'Behavior': [runtimePath, 'Behavior'],
'getDate': [wxsPath, 'getDate'],
'getRegExp': [wxsPath, 'getRegExp']
'getRegExp': [wxsPath, 'getRegExp'],
'uniCloud': [uniCloudPath, 'default']
}
}
return { // app-view
......
......@@ -94,7 +94,8 @@ module.exports = function chainWebpack (platformOptions, vueOptions, api) {
webpackConfig
.plugin('uni-define')
.use(require.resolve('webpack/lib/DefinePlugin'), [{
'process.env.UNI_ENV': JSON.stringify(process.env.UNI_PLATFORM)
'process.env.UNI_ENV': JSON.stringify(process.env.UNI_PLATFORM),
'process.env.UNI_CLOUD_PROVIDER': process.env.UNI_CLOUD_PROVIDER
}])
if (runByHBuilderX) { // 由 HBuilderX 运行时,移除进度,错误
......
......@@ -3,6 +3,30 @@ const path = require('path')
const mkdirp = require('mkdirp')
const loaderUtils = require('loader-utils')
process.env.UNI_CLOUD_PROVIDER = JSON.stringify({})
if (process.env.UNI_CLOUD_SPACES) {
try {
const spaces = JSON.parse(process.env.UNI_CLOUD_SPACES)
if (Array.isArray(spaces) && spaces.length === 1) {
const space = spaces[0]
if (space.clientSecret) {
process.env.UNI_CLOUD_PROVIDER = JSON.stringify({
provider: 'aliyun',
spaceId: space.name,
clientSecret: space.clientSecret,
endpoint: space.apiEndpoint
})
} else {
process.env.UNI_CLOUD_PROVIDER = JSON.stringify({
provider: 'tencent',
spaceId: space.name
})
}
}
} catch (e) {}
}
if (process.env.UNI_PLATFORM === 'mp-360') {
process.env.UNI_PLATFORM = 'h5'
process.env.UNI_SUB_PLATFORM = 'mp-360'
......
......@@ -30,9 +30,11 @@ const {
const runtimePath = '@dcloudio/uni-mp-weixin/dist/mp.js'
const wxsPath = '@dcloudio/uni-mp-weixin/dist/wxs.js'
const uniCloudPath = path.resolve(__dirname, '../../packages/uni-cloud/dist/index.js')
function getProvides () {
return {
'uniCloud': [uniCloudPath, 'default'],
'wx.nextTick': [runtimePath, 'nextTick'],
'Page': [runtimePath, 'Page'],
'Component': [runtimePath, 'Component'],
......@@ -103,7 +105,7 @@ module.exports = {
`import 'uni-pages';import 'uni-${process.env.UNI_PLATFORM}';`
const qihooCode = process.env.UNI_SUB_PLATFORM === 'mp-360'
? `
? `
import 'uni-touch-emulator';
import qh from 'uni-qh';
global.qh = qh;
......@@ -117,7 +119,7 @@ global.onAppShow = function(){};
alias: {
'vue-router': resolve('packages/h5-vue-router'),
'uni-h5': require.resolve('@dcloudio/uni-h5'),
'uni-qh': path.resolve(__dirname, 'qh-api.js'),
'uni-qh': path.resolve(__dirname, 'qh-api.js'),
'uni-touch-emulator': path.resolve(__dirname, 'touch-emulator.js')
}
},
......
......@@ -27,8 +27,10 @@ function createUniMPPlugin () {
function getProvides () {
const uniPath = require.resolve('@dcloudio/uni-' + process.env.UNI_PLATFORM)
const uniCloudPath = path.resolve(__dirname, '../packages/uni-cloud/dist/index.js')
const provides = {
'uni': [uniPath, 'default']
'uni': [uniPath, 'default'],
'uniCloud': [uniCloudPath, 'default']
}
if (process.env.UNI_USING_COMPONENTS) {
......
var e="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){return e(t={exports:{}},t.exports),t.exports}var r=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}}(),r={},o=r.lib={},i=o.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)}},s=o.WordArray=i.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||c).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes,o=e.sigBytes;if(this.clamp(),r%4)for(var i=0;i<o;i++){var s=n[i>>>2]>>>24-i%4*8&255;t[r+i>>>2]|=s<<24-(r+i)%4*8}else for(i=0;i<o;i+=4)t[r+i>>>2]=n[i>>>2];return this.sigBytes+=o,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=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n,r=[],o=function(t){t=t;var n=987654321,r=4294967295;return function(){var o=((n=36969*(65535&n)+(n>>16)&r)<<16)+(t=18e3*(65535&t)+(t>>16)&r)&r;return o/=4294967296,(o+=.5)*(e.random()>.5?1:-1)}},i=0;i<t;i+=4){var a=o(4294967296*(n||e.random()));n=987654071*a(),r.push(4294967296*a()|0)}return new s.init(r,t)}}),a=r.enc={},c=a.Hex={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],o=0;o<n;o++){var i=t[o>>>2]>>>24-o%4*8&255;r.push((i>>>4).toString(16)),r.push((15&i).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r+=2)n[r>>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new s.init(n,t/2)}},u=a.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],o=0;o<n;o++){var i=t[o>>>2]>>>24-o%4*8&255;r.push(String.fromCharCode(i))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r++)n[r>>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new s.init(n,t)}},l=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)))}},f=o.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,o=n.sigBytes,i=this.blockSize,a=o/(4*i),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*i,u=e.min(4*c,o);if(c){for(var l=0;l<c;l+=i)this._doProcessBlock(r,l);var f=r.splice(0,c);n.sigBytes-=u}return new s.init(f,u)},clone:function(){var e=i.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),p=(o.Hasher=f.extend({cfg:i.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){f.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 p.HMAC.init(e,n).finalize(t)}}}),r.algo={});return r}(Math),n)})),o=(n((function(e,t){var n;e.exports=(n=r,function(e){var t=n,r=t.lib,o=r.WordArray,i=r.Hasher,s=t.algo,a=[];!function(){for(var t=0;t<64;t++)a[t]=4294967296*e.abs(e.sin(t+1))|0}();var c=s.MD5=i.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var n=0;n<16;n++){var r=t+n,o=e[r];e[r]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8)}var i=this._hash.words,s=e[t+0],c=e[t+1],h=e[t+2],d=e[t+3],y=e[t+4],v=e[t+5],_=e[t+6],g=e[t+7],m=e[t+8],w=e[t+9],b=e[t+10],E=e[t+11],S=e[t+12],T=e[t+13],k=e[t+14],O=e[t+15],A=i[0],P=i[1],N=i[2],I=i[3];A=u(A,P,N,I,s,7,a[0]),I=u(I,A,P,N,c,12,a[1]),N=u(N,I,A,P,h,17,a[2]),P=u(P,N,I,A,d,22,a[3]),A=u(A,P,N,I,y,7,a[4]),I=u(I,A,P,N,v,12,a[5]),N=u(N,I,A,P,_,17,a[6]),P=u(P,N,I,A,g,22,a[7]),A=u(A,P,N,I,m,7,a[8]),I=u(I,A,P,N,w,12,a[9]),N=u(N,I,A,P,b,17,a[10]),P=u(P,N,I,A,E,22,a[11]),A=u(A,P,N,I,S,7,a[12]),I=u(I,A,P,N,T,12,a[13]),N=u(N,I,A,P,k,17,a[14]),A=l(A,P=u(P,N,I,A,O,22,a[15]),N,I,c,5,a[16]),I=l(I,A,P,N,_,9,a[17]),N=l(N,I,A,P,E,14,a[18]),P=l(P,N,I,A,s,20,a[19]),A=l(A,P,N,I,v,5,a[20]),I=l(I,A,P,N,b,9,a[21]),N=l(N,I,A,P,O,14,a[22]),P=l(P,N,I,A,y,20,a[23]),A=l(A,P,N,I,w,5,a[24]),I=l(I,A,P,N,k,9,a[25]),N=l(N,I,A,P,d,14,a[26]),P=l(P,N,I,A,m,20,a[27]),A=l(A,P,N,I,T,5,a[28]),I=l(I,A,P,N,h,9,a[29]),N=l(N,I,A,P,g,14,a[30]),A=f(A,P=l(P,N,I,A,S,20,a[31]),N,I,v,4,a[32]),I=f(I,A,P,N,m,11,a[33]),N=f(N,I,A,P,E,16,a[34]),P=f(P,N,I,A,k,23,a[35]),A=f(A,P,N,I,c,4,a[36]),I=f(I,A,P,N,y,11,a[37]),N=f(N,I,A,P,g,16,a[38]),P=f(P,N,I,A,b,23,a[39]),A=f(A,P,N,I,T,4,a[40]),I=f(I,A,P,N,s,11,a[41]),N=f(N,I,A,P,d,16,a[42]),P=f(P,N,I,A,_,23,a[43]),A=f(A,P,N,I,w,4,a[44]),I=f(I,A,P,N,S,11,a[45]),N=f(N,I,A,P,O,16,a[46]),A=p(A,P=f(P,N,I,A,h,23,a[47]),N,I,s,6,a[48]),I=p(I,A,P,N,g,10,a[49]),N=p(N,I,A,P,k,15,a[50]),P=p(P,N,I,A,v,21,a[51]),A=p(A,P,N,I,S,6,a[52]),I=p(I,A,P,N,d,10,a[53]),N=p(N,I,A,P,b,15,a[54]),P=p(P,N,I,A,c,21,a[55]),A=p(A,P,N,I,m,6,a[56]),I=p(I,A,P,N,O,10,a[57]),N=p(N,I,A,P,_,15,a[58]),P=p(P,N,I,A,T,21,a[59]),A=p(A,P,N,I,y,6,a[60]),I=p(I,A,P,N,E,10,a[61]),N=p(N,I,A,P,h,15,a[62]),P=p(P,N,I,A,w,21,a[63]),i[0]=i[0]+A|0,i[1]=i[1]+P|0,i[2]=i[2]+N|0,i[3]=i[3]+I|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;n[o>>>5]|=128<<24-o%32;var i=e.floor(r/4294967296),s=r;n[15+(o+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),n[14+(o+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),t.sigBytes=4*(n.length+1),this._process();for(var a=this._hash,c=a.words,u=0;u<4;u++){var l=c[u];c[u]=16711935&(l<<8|l>>>24)|4278255360&(l<<24|l>>>8)}return a},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,n,r,o,i,s){var a=e+(t&n|~t&r)+o+s;return(a<<i|a>>>32-i)+t}function l(e,t,n,r,o,i,s){var a=e+(t&r|n&~r)+o+s;return(a<<i|a>>>32-i)+t}function f(e,t,n,r,o,i,s){var a=e+(t^n^r)+o+s;return(a<<i|a>>>32-i)+t}function p(e,t,n,r,o,i,s){var a=e+(n^(t|~r))+o+s;return(a<<i|a>>>32-i)+t}t.MD5=i._createHelper(c),t.HmacMD5=i._createHmacHelper(c)}(Math),n.MD5)})),n((function(e,t){var n,o,i;e.exports=(o=(n=r).lib.Base,i=n.enc.Utf8,void(n.algo.HMAC=o.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=i.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),s=this._iKey=t.clone(),a=o.words,c=s.words,u=0;u<n;u++)a[u]^=1549556828,c[u]^=909522486;o.sigBytes=s.sigBytes=r,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=r.HmacMD5})));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),o(n,t).toString()},wrappedRequest:function(e){return new Promise((t,n)=>{uni.request(Object.assign(e,{complete(e){e||(e={}),(!e.statusCode||e.statusCode>=400)&&n(e.data||{error:{code:"Request Error",message:"请求出错"},success:!1});const r=e.data;r.error&&n(r),r.result=r.data,delete r.data,t(r)}}))})}};const s={jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",mp3:"audio/mpeg",mp4:"video/mp4",ogg:"audio/ogg",webm:"video/webm"};function a(e){return s[e]}class c{constructor(e){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.env,this.setAccessToken(uni.getStorageSync(this.config.accessTokenKey)||"")}get hasAccessToken(){return!!this.accessToken}setAccessToken(e){uni.setStorageSync(this.config.accessTokenKey,e),this.accessToken=e}requestAuth(e){return i.wrappedRequest(e)}request(e,t){return this.hasAccessToken?t?i.wrappedRequest(e):i.wrappedRequest(e).catch(t=>new Promise((e,n)=>{t&&t.error&&("GATEWAY_INVALID_TOKEN"===t.error.code||"InvalidParameter.InvalidToken"===t.error.code)?e():n(t)}).then(()=>{return 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.env,timestamp:Date.now()}),r={"Content-Type":"application/json"};return"auth"!==t&&(n.token=this.accessToken,r["x-basement-token"]=this.accessToken),r["x-serverless-sign"]=i.sign(n,this.config.clientSecret),{url:this.config.requestUrl,method:"POST",data:n,dataType:"json",header:r}}getAccessToken(){return 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),t(this.accessToken)):n(new Error("获取accessToken失败"))}))}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,fileName:n,name:r,filePath:o,fileType:i,contentType:s}){return new Promise((s,a)=>{uni.uploadFile({url:e,formData:t,fileName:n,name:r,filePath:o,fileType:i,header:{"X-OSS-server-side-encrpytion":"AES256"},success(e){e&&e.statusCode<400?s(e):a(new Error("Upload Fail"))},fail(e){a(e)}})})}reportOSSUpload(e){const t={method:"serverless.file.resource.report",params:JSON.stringify(e)};return this.request(this.setupRequest(t))}uploadFile({filePath:e,config:t}){const n=t&&t.envType||this.config.envType;let r,o,i,c,u,l=e.split("/").pop();return(r="h5"===process.env.VUE_APP_PLATFORM?new Promise((t,n)=>{var r=new XMLHttpRequest;r.open("GET",e,!0),r.responseType="blob",r.onload=function(){(o=function(e){let t;return Object.keys(s).forEach(n=>{s[n]===e&&(t=n)}),t}(this.response.type))||n(new Error("Unsupported File Type")),l+="."+o,t()},r.send()}):a(o=e.split(".").pop())?Promise.resolve():Promise.reject(new Error("Unsupported File Type"))).then(()=>this.getOSSUploadOptionsFromPath({env:n,filename:l})).then(t=>{const n=t.result;i=a(o),c=n.id,u="https://"+n.host+"/"+n.ossPath;const r={url:"https://"+n.host,formData:{"Cache-Control":"max-age=2592000","Content-Disposition":"attachment",OSSAccessKeyId:n.accessKeyId,Signature:n.signature,host:n.host,id:c,key:n.ossPath,policy:n.policy,success_action_status:200},fileName:"file",name:"file",filePath:e,fileType:"image",contentType:i};return this.uploadFileToOSS(r)}).then(()=>this.reportOSSUpload({id:c,contentType:i})).then(t=>new Promise((n,r)=>{t.success?n({success:!0,filePath:e,fileUrl:u}):r(new Error("Upload Fail"))}))}deleteFile({url:e}){const t={method:"serverless.file.resource.delete",params:JSON.stringify({id:e})};return this.request(this.setupRequest(t))}}const u=require("uni-stat-config").default||require("uni-stat-config"),l="__DC_STAT_UUID",f="__DC_UUID_VALUE",p="https://ide.dcloud.net.cn/serverless/function/invoke";function h(){return{"app-plus":"n",h5:"h5","mp-weixin":"wx","mp-alipay":"ali","mp-baidu":"bd","mp-toutiao":"tt","mp-qq":"qq"}[process.env.VUE_APP_PLATFORM]}function d(e){return 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)}).catch(e=>{t.fail&&t.fail(e),t.complete&&t.complete(e)})}}const y=uni.getSystemInfoSync(),v={platform:process.env.VUE_APP_PLATFORM,os:y.platform},_={ak:u.appid,p:"android"===y.platform?"a":"i",ut:h(),uuid:function(){let e="";if("n"===h()){try{e=plus.runtime.getDCloudId()}catch(t){e=""}return e}try{e=uni.getStorageSync(l)}catch(t){e=f}if(!e){e=Date.now()+""+Math.floor(1e7*Math.random());try{uni.setStorageSync(l,e)}catch(e){uni.setStorageSync(l,f)}}return e}()},g={init(e){const t=new c(e);t.authorize();return["callFunction","uploadFile","deleteFile"].forEach(e=>{t[e]=d(t[e]).bind(t)}),t}};var m;!function(e){e.local="local",e.none="none",e.session="session"}(m||(m={}));var w=function(){},b=function(){};function E(e,t,n){void 0===n&&(n={});var r=/\?/.test(t),o="";for(var i in n)""===o?!r&&(t+="?"):o+="&",o+=i+"="+encodeURIComponent(n[i]);return/^http(s)?\:\/\//.test(t+=o)?t:""+e+t}var S,T=Object.freeze({__proto__:null,get StorageType(){return m},AbstractSDKRequest:w,AbstractStorage:b,formatUrl:E}),k=(S=function(e,t){return(S=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}S(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),O=function(){return(O=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},A=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},P=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}};var N=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return k(t,e),t.prototype.post=function(e){var t=e.url,n=e.data,r=e.headers;return new Promise((function(e,o){wx.request({url:E("https:",t),data:n,method:"POST",header:r,success:function(t){e(t)},fail:function(e){o(e)}})}))},t.prototype.upload=function(e){var t=this;return new Promise((function(n){return A(t,void 0,void 0,(function(){var t,r,o,i;return P(this,(function(s){return t=e.url,r=e.file,o=e.data,i=e.headers,wx.uploadFile({url:E("https:",t),filePath:r,name:"file",formData:O(O({},o),{file:r}),header:i,success:function(e){var t={statusCode:e.statusCode,data:e.data||{}};200===e.statusCode&&o.success_action_status&&(t.statusCode=parseInt(o.success_action_status,10)),n(t)},fail:function(e){n(e)}}),[2]}))}))}))},t.prototype.download=function(e){var t=e.url,n=e.headers;return new Promise((function(e,r){wx.downloadFile({url:E("https:",t),header:n,success:function(t){200===t.statusCode&&t.tempFilePath?e({statusCode:200,tempFilePath:t.tempFilePath}):e(t)},fail:function(e){r(e)}})}))},t}(w),I={setItem:function(e,t){wx.setStorageSync(e,t)},getItem:function(e){return wx.getStorageSync(e)},removeItem:function(e){wx.removeStorageSync(e)},clear:function(){wx.clearStorageSync()}},x=function(e,t){void 0===t&&(t={});var n=wx.connectSocket(O({url:e},t));return{set onopen(e){n.onOpen(e)},set onmessage(e){n.onMessage(e)},set onclose(e){n.onClose(e)},set onerror(e){n.onError(e)},send:function(e){return n.send({data:e})},close:function(e,t){return n.close({code:e,reason:t})},get readyState(){return n.readyState},CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3}};var C={genAdapter:function(){return{root:{},reqClass:N,wsClass:x,localStorage:I,primaryStorage:m.local}},isMatch:function(){if("undefined"==typeof wx)return!1;if("undefined"==typeof App)return!1;if("undefined"==typeof Page)return!1;if("function"!=typeof getApp)return!1;if(!wx.onAppHide)return!1;if(!wx.offAppHide)return!1;if(!wx.onAppShow)return!1;if(!wx.offAppShow)return!1;if(!wx.getSystemInfoSync)return!1;if(!wx.getStorageSync)return!1;if(!wx.setStorageSync)return!1;if(!wx.connectSocket)return!1;if(!wx.request)return!1;try{if(!wx.getSystemInfoSync())return!1;if("qq"===wx.getSystemInfoSync().AppPlatform)return!1}catch(e){return!1}return!0},runtime:"wx_mp"},R=n((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.getQuery=function(e,t){if("undefined"==typeof window)return!1;var n=t||window.location.search,r=new RegExp("(^|&)"+e+"=([^&]*)(&|$)"),o=n.substr(n.indexOf("?")+1).match(r);return null!=o?o[2]:""},t.getHash=function(e){var t=window.location.hash.match(new RegExp("[#?&/]"+e+"=([^&#]*)"));return t?t[1]:""},t.removeParam=function(e,t){var n=t.split("?")[0],r=[],o=-1!==t.indexOf("?")?t.split("?")[1]:"";if(""!==o){for(var i=(r=o.split("&")).length-1;i>=0;i-=1)r[i].split("=")[0]===e&&r.splice(i,1);n=n+"?"+r.join("&")}return n},t.createPromiseCallback=function(){var e;if(!Promise){(e=function(){}).promise={};var t=function(){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}var n=new Promise((function(t,n){e=function(e,r){return e?n(e):t(r)}}));return e.promise=n,e},t.getWeixinCode=function(){return t.getQuery("code")||t.getHash("code")},t.getMiniAppCode=function(){return new Promise((function(e,t){wx.login({success:function(t){e(t.code)},fail:function(e){t(e)}})}))},t.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},t.isString=function(e){return"string"==typeof e},t.isUndefined=function(e){return void 0===e},t.isInstanceOf=function(e,t){return e instanceof t},t.isFormData=function(e){return"[object FormData]"===Object.prototype.toString.call(e)},t.genSeqId=function(){return Math.random().toString(16).slice(2)},t.getArgNames=function(e){var t=e.toString();return t.slice(t.indexOf("(")+1,t.indexOf(")")).match(/([^\s,]+)/g)},t.formatUrl=function(e,t,n){void 0===n&&(n={});var r=/\?/.test(t),o="";for(var i in n)""===o?!r&&(t+="?"):o+="&",o+=i+"="+encodeURIComponent(n[i]);return/^http(s)?\:\/\//.test(t+=o)?t:""+e+t}}));t(R);R.getQuery,R.getHash,R.removeParam,R.createPromiseCallback,R.getWeixinCode,R.getMiniAppCode,R.isArray,R.isString,R.isUndefined,R.isInstanceOf,R.isFormData,R.genSeqId,R.getArgNames,R.formatUrl;var j,U="dist/index.js",q="./dist/index.d.ts",L={build:"npm run tsc && webpack",tsc:"tsc -p tsconfig.json","tsc:w":"tsc -p tsconfig.json -w",test:"jest --verbose false -i",e2e:'NODE_ENV=e2e webpack && jest --config="./jest.e2e.config.js" --verbose false -i "e2e"',start:"webpack-dev-server --hot --open",eslint:'eslint "./**/*.js" "./**/*.ts"',"eslint-fix":'eslint --fix "./**/*.js" "./**/*.ts"',test_web:"npm run tsc && webpack-dev-server --devtool eval-source-map --progress --colors --hot --inline --content-base ./dist --host jimmytest-088bef.tcb.qcloud.la --port 80 --disableHostCheck true --mode development --config webpack.test.js"},K={type:"git",url:"https://github.com/TencentCloudBase/tcb-js-sdk"},D=["tcb","js-sdk"],M={"@cloudbase/adapter-interface":"^0.2.0","@cloudbase/adapter-wx_mp":"^0.2.1","@cloudbase/database":"^0.9.8"},F={"@babel/core":"^7.6.2","@babel/plugin-proposal-class-properties":"^7.5.5","@babel/plugin-proposal-object-rest-spread":"^7.6.2","@babel/plugin-transform-runtime":"^7.6.2","@babel/preset-env":"^7.6.2","@babel/preset-typescript":"^7.6.0","@babel/runtime":"^7.6.2","@types/jest":"^23.1.4","@types/node":"^10.14.4","@types/superagent":"^4.1.4",axios:"^0.19.0","babel-eslint":"^10.0.1","babel-loader":"^8.0.6","babel-polyfill":"^6.26.0",eslint:"^5.16.0","eslint-config-alloy":"^1.4.2","eslint-config-prettier":"^4.1.0","eslint-plugin-prettier":"^3.0.1","eslint-plugin-typescript":"^1.0.0-rc.3",express:"^4.17.1",husky:"^3.1.0",jest:"^24.7.1","jest-puppeteer":"^4.3.0","lint-staged":"^9.5.0","power-assert":"^1.6.1",puppeteer:"^1.20.0","serve-static":"^1.14.1","ts-jest":"^23.10.4","ts-loader":"^6.2.1",typescript:"^3.4.3","typescript-eslint-parser":"^22.0.0",webpack:"^4.41.3","webpack-bundle-analyzer":"^3.4.1","webpack-cli":"^3.3.0","webpack-dev-server":"^3.3.1","webpack-merge":"^4.2.2","webpack-visualizer-plugin":"^0.1.11"},G={hooks:{"pre-commit":"lint-staged"}},H={name:"tcb-js-sdk",version:"1.3.5",description:"js sdk for tcb",main:U,types:q,scripts:L,repository:K,keywords:D,author:"jimmyjzhang",license:"ISC",dependencies:M,devDependencies:F,husky:G,"lint-staged":{"*.{js,ts}":["eslint --fix","git add"]}},Y=(j=Object.freeze({__proto__:null,name:"tcb-js-sdk",version:"1.3.5",description:"js sdk for tcb",main:U,types:q,scripts:L,repository:K,keywords:D,author:"jimmyjzhang",license:"ISC",dependencies:M,devDependencies:F,husky:G,default:H}))&&j.default||j,V=n((function(t,n){var r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t};Object.defineProperty(n,"__esModule",{value:!0});var o=r(Y);n.SDK_VERISON=o.version,n.ACCESS_TOKEN="access_token",n.ACCESS_TOKEN_Expire="access_token_expire",n.REFRESH_TOKEN="refresh_token",n.ANONYMOUS_UUID="anonymous_uuid",n.LOGIN_TYPE_KEY="login_type",n.protocol="undefined"!=typeof location&&"http:"===location.protocol?"http:":"https:",n.BASE_URL="e2e"===process.env.NODE_ENV&&"pre"===process.env.END_POINT?"//tcb-pre.tencentcloudapi.com/web":"//tcb-api.tencentcloudapi.com/web"}));t(V);V.SDK_VERISON,V.ACCESS_TOKEN,V.ACCESS_TOKEN_Expire,V.REFRESH_TOKEN,V.ANONYMOUS_UUID,V.LOGIN_TYPE_KEY,V.protocol,V.BASE_URL;var B=n((function(t,n){var r=e&&e.__extends||function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),o=e&&e.__assign||function(){return(o=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},i=e&&e.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},s=e&&e.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}};Object.defineProperty(n,"__esModule",{value:!0});var a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.get=function(e){return this._request(o(o({},e),{method:"get"}))},t.prototype.post=function(e){return this._request(o(o({},e),{method:"post"}))},t.prototype.upload=function(e){var t=e.data,n=e.file,r=e.name,i=new FormData;for(var s in t)i.append(s,t[s]);return i.append("key",r),i.append("file",n),this._request(o(o({},e),{data:i,method:"post"}))},t.prototype.download=function(e){return i(this,void 0,void 0,(function(){var t,n;return s(this,(function(r){return t=decodeURIComponent(new URL(e.url).pathname.split("/").pop()||""),(n=document.createElement("a")).href=e.url,n.setAttribute("download",t),n.setAttribute("target","_blank"),document.body.appendChild(n),n.click(),[2,new Promise((function(t){t({statusCode:200,tempFilePath:e.url})}))]}))}))},t.prototype._request=function(e){var t=String(e.method).toLowerCase()||"get";return new Promise((function(n){var r=e.url,o=e.headers,i=void 0===o?{}:o,s=e.data,a=e.responseType,c=R.formatUrl(V.protocol,r,"get"===t?s:{}),u=new XMLHttpRequest;for(var l in u.open(t,c),a&&(u.responseType=a),i)u.setRequestHeader(l,i[l]);u.onreadystatechange=function(){if(4===u.readyState){var e={statusCode:u.status};try{e.data=JSON.parse(u.responseText)}catch(e){}n(e)}},u.send("post"===t&&R.isFormData(s)?s:JSON.stringify(s||{}))}))},t}(T.AbstractSDKRequest);n.WebRequest=a,n.genAdapter=function(){return{root:window,reqClass:a,wsClass:WebSocket,localStorage:localStorage,sessionStorage:sessionStorage}}}));t(B);B.WebRequest,B.genAdapter;var W=n((function(t,n){var r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t};Object.defineProperty(n,"__esModule",{value:!0});var o,i=r(B);!function(e){e.WEB="web",e.WX_MP="wx_mp"}(o=n.RUNTIME||(n.RUNTIME={})),n.useAdapters=function(e){for(var t=0,n=R.isArray(e)?e:[e];t<n.length;t++){var r=n[t],o=r.isMatch,i=r.genAdapter,s=r.runtime;if(o())return{adapter:i(),runtime:s}}},n.useDefaultAdapter=function(){return{adapter:i.genAdapter(),runtime:o.WEB}},n.Adapter={adapter:null,runtime:void 0}}));t(W);W.RUNTIME,W.useAdapters,W.useDefaultAdapter,W.Adapter;var z=n((function(t,n){var r=e&&e.__extends||function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(n,"__esModule",{value:!0});var o=function(){function e(e){switch(W.Adapter.adapter.primaryStorage||e){case"local":this.storageClass=W.Adapter.adapter.localStorage||new i;break;case"none":this.storageClass=new i;break;default:this.storageClass=W.Adapter.adapter.sessionStorage||new i}}return e.prototype.setStore=function(e,t,n){try{if(!this.storageClass)return}catch(e){return}var r,o={};o.version=n||"localCachev1",o.content=t,r=JSON.stringify(o);try{this.storageClass.setItem(e,r)}catch(e){return}},e.prototype.getStore=function(e,t){try{if(process&&process.env&&process.env.tcb_token)return process.env.tcb_token;if(!this.storageClass)return}catch(e){return""}t=t||"localCachev1";var n=this.storageClass.getItem(e);return n&&n.indexOf(t)>=0?JSON.parse(n).content:""},e.prototype.removeStore=function(e){this.storageClass.removeItem(e)},e}();n.Cache=o;var i=function(e){function t(){var t=e.call(this)||this;return W.Adapter.adapter.root.tcbObject||(W.Adapter.adapter.root.tcbObject={}),t}return r(t,e),t.prototype.setItem=function(e,t){W.Adapter.adapter.root.tcbObject[e]=t},t.prototype.getItem=function(e){return W.Adapter.adapter.root.tcbObject[e]},t.prototype.removeItem=function(e){delete W.Adapter.adapter.root.tcbObject[e]},t.prototype.clear=function(){delete W.Adapter.adapter.root.tcbObject},t}(T.AbstractStorage)}));t(z);z.Cache;var J=n((function(t,n){var r=e&&e.__extends||function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),o=e&&e.__spreadArrays||function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var i=arguments[t],s=0,a=i.length;s<a;s++,o++)r[o]=i[s];return r};Object.defineProperty(n,"__esModule",{value:!0});var i=function(e,t){this.data=t||null,this.name=e};n.IEvent=i;var s=function(e){function t(t,n){var r=e.call(this,"error",{error:t,data:n})||this;return r.error=t,r}return r(t,e),t}(i);n.IErrorEvent=s;var a=function(){function e(){this._listeners={}}return e.prototype.on=function(e,t){return function(e,t,n){n[e]=n[e]||[],n[e].push(t)}(e,t,this._listeners),this},e.prototype.off=function(e,t){return function(e,t,n){if(n&&n[e]){var r=n[e].indexOf(t);-1!==r&&n[e].splice(r,1)}}(e,t,this._listeners),this},e.prototype.fire=function(e,t){if(R.isInstanceOf(e,s))return console.error(e.error),this;var n=R.isString(e)?new i(e,t||{}):e,r=n.name;if(this._listens(r)){n.target=this;for(var a=0,c=this._listeners[r]?o(this._listeners[r]):[];a<c.length;a++){c[a].call(this,n)}}return this},e.prototype._listens=function(e){return this._listeners[e]&&this._listeners[e].length>0},e}();n.IEventEmitter=a;var c=new a;n.addEventListener=function(e,t){c.on(e,t)},n.activateEvent=function(e,t){void 0===t&&(t={}),c.fire(e,t)},n.removeEventListener=function(e,t){c.off(e,t)},n.EVENTS={LOGIN_STATE_CHANGED:"loginStateChanged",LOGIN_STATE_EXPIRE:"loginStateExpire",LOGIN_TYPE_CHANGE:"loginTypeChanged",ANONYMOUS_CONVERTED:"anonymousConverted",REFRESH_ACCESS_TOKEN:"refreshAccessToken"}}));t(J);J.IEvent,J.IErrorEvent,J.IEventEmitter,J.addEventListener,J.activateEvent,J.removeEventListener,J.EVENTS;var X=n((function(t,n){var r=e&&e.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},o=e&&e.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},i=e&&e.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}};Object.defineProperty(n,"__esModule",{value:!0});var s=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously"],a={"X-SDK-Version":V.SDK_VERISON};function c(e,t,n){var o=e[t];e[t]=function(t){var i={},s={};n.forEach((function(n){var r=n.call(e,t),o=r.data,a=r.headers;Object.assign(i,o),Object.assign(s,a)}));var a=t.data;return a&&function(){if(R.isFormData(a))for(var e in i)a.append(e,i[e]);else t.data=r(r({},a),i)}(),t.headers=r(r({},t.headers||{}),s),o.call(e,t)}}function u(){var e=R.genSeqId();return{data:{seqId:e},headers:r(r({},a),{"x-seqid":e})}}var l=function(){function e(e){void 0===e&&(e={}),this.config=e,this.cache=new z.Cache(e.persistence),this.accessTokenKey=V.ACCESS_TOKEN+"_"+e.env,this.accessTokenExpireKey=V.ACCESS_TOKEN_Expire+"_"+e.env,this.refreshTokenKey=V.REFRESH_TOKEN+"_"+e.env,this.anonymousUuidKey=V.ANONYMOUS_UUID+"_"+e.env,this.loginTypeKey=V.LOGIN_TYPE_KEY+"_"+e.env,this._reqClass=new W.Adapter.adapter.reqClass,c(this._reqClass,"post",[u]),c(this._reqClass,"upload",[u]),c(this._reqClass,"download",[u])}return e.prototype.post=function(e){return o(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this._reqClass.post(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.upload=function(e){return o(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this._reqClass.upload(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.download=function(e){return o(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this._reqClass.download(e)];case 1:return[2,t.sent()]}}))}))},e.prototype.refreshAccessToken=function(){return o(this,void 0,void 0,(function(){var e,t,n;return i(this,(function(r){switch(r.label){case 0:this._refreshAccessTokenPromise||(this._refreshAccessTokenPromise=this._refreshAccessToken()),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this._refreshAccessTokenPromise];case 2:return e=r.sent(),[3,4];case 3:return n=r.sent(),t=n,[3,4];case 4:if(this._refreshAccessTokenPromise=null,this._shouldRefreshAccessTokenHook=null,t)throw t;return[2,e]}}))}))},e.prototype._refreshAccessToken=function(){return o(this,void 0,void 0,(function(){var e,t,n,r;return i(this,(function(o){switch(o.label){case 0:if(this.cache.removeStore(this.accessTokenKey),this.cache.removeStore(this.accessTokenExpireKey),!(e=this.cache.getStore(this.refreshTokenKey)))throw new Error("[tcb-js-sdk] 未登录CloudBase");return t={refresh_token:e},this.cache.getStore(this.loginTypeKey)===$.LOGINTYPE.ANONYMOUS&&(t.anonymous_uuid=this.cache.getStore(this.anonymousUuidKey)),[4,this.request("auth.getJwt",t)];case 1:if((n=o.sent()).data.code)throw"SIGN_PARAM_INVALID"!==(r=n.data.code)&&"REFRESH_TOKEN_EXPIRED"!==r&&"INVALID_REFRESH_TOKEN"!==r||(J.activateEvent(J.EVENTS.LOGIN_STATE_EXPIRE),this.cache.removeStore(this.refreshTokenKey)),new Error("[tcb-js-sdk] 刷新access token失败:"+n.data.code);return n.data.access_token?(J.activateEvent(J.EVENTS.REFRESH_ACCESS_TOKEN),this.cache.setStore(this.accessTokenKey,n.data.access_token),this.cache.setStore(this.accessTokenExpireKey,n.data.access_token_expire+Date.now()),J.activateEvent(J.EVENTS.LOGIN_TYPE_CHANGE,n.data.login_type),[2,{accessToken:n.data.access_token,accessTokenExpire:n.data.access_token_expire}]):(n.data.refresh_token&&(this.cache.removeStore(this.refreshTokenKey),this.cache.setStore(this.refreshTokenKey,n.data.refresh_token),this._refreshAccessToken()),[2])}}))}))},e.prototype.getAccessToken=function(){return o(this,void 0,void 0,(function(){var e,t,n,r;return i(this,(function(o){switch(o.label){case 0:return e=this.cache.getStore(this.accessTokenKey),t=this.cache.getStore(this.accessTokenExpireKey),n=!0,(r=this._shouldRefreshAccessTokenHook)?[4,this._shouldRefreshAccessTokenHook(e,t)]:[3,2];case 1:r=!o.sent(),o.label=2;case 2:return r&&(n=!1),(!e||!t||t<Date.now())&&n?[2,this.refreshAccessToken()]:[2,{accessToken:e,accessTokenExpire:t}]}}))}))},e.prototype.request=function(e,t,n){return o(this,void 0,void 0,(function(){var o,a,c,u,l,f,p,h,d,y,v,_;return i(this,(function(i){switch(i.label){case 0:return o="application/x-www-form-urlencoded",a=r({action:e,env:this.config.env,dataVersion:"2019-08-16"},t),-1!==s.indexOf(e)?[3,2]:(c=a,[4,this.getAccessToken()]);case 1:c.access_token=i.sent().accessToken,i.label=2;case 2:if("storage.uploadFile"===e){for(l in u=new FormData)u.hasOwnProperty(l)&&void 0!==u[l]&&u.append(l,a[l]);o="multipart/form-data"}else o="application/json;charset=UTF-8",u=a;return f={headers:{"content-type":o}},n&&n.onUploadProgress&&(f.onUploadProgress=n.onUploadProgress),p=t.parse,h=t.query,d=t.search,y={env:this.config.env},p&&(y.parse=!0),h&&(y=r(r({},h),y)),v=R.formatUrl(V.protocol,V.BASE_URL,y),d&&(v+=d),[4,this.post(r({url:v,data:u},f))];case 3:if(_=i.sent(),200!==Number(_.status)&&200!==Number(_.statusCode)||!_.data)throw new Error("network request error");return[2,_]}}))}))},e.prototype.send=function(e,t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:return n=setTimeout((function(){console.warn("Database operation is longer than 3s. Please check query performance and your network environment.")}),3e3),[4,this.request(e,t,{onUploadProgress:t.onUploadProgress})];case 1:return r=i.sent(),clearTimeout(n),"ACCESS_TOKEN_EXPIRED"!==r.data.code||-1!==s.indexOf(e)?[3,4]:[4,this.refreshAccessToken()];case 2:return i.sent(),[4,this.request(e,t,{onUploadProgress:t.onUploadProgress})];case 3:if((o=i.sent()).data.code)throw new Error("["+o.data.code+"] "+o.data.message);return[2,o.data];case 4:if(r.data.code)throw new Error("["+r.data.code+"] "+r.data.message);return[2,r.data]}}))}))},e}();n.Request=l}));t(X);X.Request;var $=n((function(t,n){var r,o=e&&e.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},i=e&&e.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}};Object.defineProperty(n,"__esModule",{value:!0}),function(e){e.ANONYMOUS="ANONYMOUS",e.WECHAT="WECHAT",e.CUSTOM="CUSTOM",e.NULL="NULL"}(r=n.LOGINTYPE||(n.LOGINTYPE={}));var s=function(){function e(e){this._loginType=r.NULL,this.config=e,this.onLoginTypeChanged=this.onLoginTypeChanged.bind(this),J.addEventListener(J.EVENTS.LOGIN_TYPE_CHANGE,this.onLoginTypeChanged)}return e.prototype.init=function(){this.httpRequest=new X.Request(this.config),this.cache=new z.Cache(this.config.persistence),this.accessTokenKey=V.ACCESS_TOKEN+"_"+this.config.env,this.accessTokenExpireKey=V.ACCESS_TOKEN_Expire+"_"+this.config.env,this.refreshTokenKey=V.REFRESH_TOKEN+"_"+this.config.env,this.loginTypeKey=V.LOGIN_TYPE_KEY+"_"+this.config.env},e.prototype.onLoginTypeChanged=function(e){this._loginType=e.data,this.cache.setStore(this.loginTypeKey,this._loginType)},Object.defineProperty(e.prototype,"loginType",{get:function(){return this._loginType},enumerable:!0,configurable:!0}),e.prototype.setRefreshToken=function(e){this.cache.removeStore(this.accessTokenKey),this.cache.removeStore(this.accessTokenExpireKey),this.cache.setStore(this.refreshTokenKey,e)},e.prototype.getRefreshTokenByWXCode=function(e,t,n){return o(this,void 0,void 0,(function(){var r;return i(this,(function(o){return"auth.getJwt",r=W.Adapter.runtime===W.RUNTIME.WX_MP?"1":"0",[2,this.httpRequest.send("auth.getJwt",{appid:e,loginType:t,code:n,hybridMiniapp:r}).then((function(e){if(e.code)throw new Error("[tcb-js-sdk] 微信登录失败: "+e.code);if(e.refresh_token)return{refreshToken:e.refresh_token,accessToken:e.access_token,accessTokenExpire:e.access_token_expire};throw new Error("[tcb-js-sdk] getJwt未返回refreshToken")}))]}))}))},e}();n.default=s}));t($);$.LOGINTYPE;var Q=n((function(t,n){var r=e&&e.__extends||function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),o=e&&e.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},i=e&&e.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},s=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t};Object.defineProperty(n,"__esModule",{value:!0});var a,c,u=s(R),l=s($);!function(e){e.snsapi_base="snsapi_base",e.snsapi_userinfo="snsapi_userinfo",e.snsapi_login="snsapi_login"}(a||(a={})),function(e){e.redirect="redirect",e.prompt="prompt"}(c||(c={}));var f={},p=function(e){function t(t,n,r,o,i){var s=e.call(this,t)||this;return s.config=t,s.appid=n,s.scope=W.Adapter.runtime===W.RUNTIME.WX_MP?"snsapi_base":r,s.state=i||"weixin",s.loginMode=o||"redirect",s}return r(t,e),t.prototype.signIn=function(){return o(this,void 0,void 0,(function(){var e,t,n;return i(this,(function(r){switch(r.label){case 0:f[this.config.env]||(f[this.config.env]=this._signIn()),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,f[this.config.env]];case 2:return e=r.sent(),[3,4];case 3:return n=r.sent(),t=n,[3,4];case 4:if(f[this.config.env]=null,t)throw t;return[2,e]}}))}))},t.prototype._signIn=function(){return o(this,void 0,void 0,(function(){var e,t,n,r,o,s;return i(this,(function(i){switch(i.label){case 0:if(e=this.cache.getStore(this.accessTokenKey),t=this.cache.getStore(this.accessTokenExpireKey),e){if(t&&t>Date.now())return[2,{credential:{accessToken:e,refreshToken:this.cache.getStore(this.refreshTokenKey)}}];this.cache.removeStore(this.accessTokenKey),this.cache.removeStore(this.accessTokenExpireKey)}if(!1===Object.values(a).includes(a[this.scope]))throw new Error("错误的scope类型");return W.Adapter.runtime!==W.RUNTIME.WX_MP?[3,2]:[4,u.getMiniAppCode()];case 1:return n=i.sent(),[3,4];case 2:return[4,u.getWeixinCode()];case 3:if(!(n=i.sent()))return[2,this.redirect()];i.label=4;case 4:return r=function(e){switch(e){case a.snsapi_login:return"WECHAT-OPEN";default:return"WECHAT-PUBLIC"}}(this.scope),[4,this.getRefreshTokenByWXCode(this.appid,r,n)];case 5:return o=i.sent(),s=o.refreshToken,this.cache.setStore(this.refreshTokenKey,s),o.accessToken&&this.cache.setStore(this.accessTokenKey,o.accessToken),o.accessTokenExpire&&this.cache.setStore(this.accessTokenExpireKey,o.accessTokenExpire+Date.now()),J.activateEvent(J.EVENTS.LOGIN_STATE_CHANGED),J.activateEvent(J.EVENTS.LOGIN_TYPE_CHANGE,l.LOGINTYPE.WECHAT),[2,{credential:{refreshToken:s}}]}}))}))},t.prototype.redirect=function(){var e=u.removeParam("code",location.href);e=u.removeParam("state",e),e=encodeURIComponent(e);var t="//open.weixin.qq.com/connect/oauth2/authorize";"snsapi_login"===this.scope&&(t="//open.weixin.qq.com/connect/qrconnect"),"redirect"===c[this.loginMode]&&(location.href=t+"?appid="+this.appid+"&redirect_uri="+e+"&response_type=code&scope="+this.scope+"&state="+this.state+"#wechat_redirect")},t}(l.default);n.default=p}));t(Q);var Z=n((function(t,n){var r=e&&e.__extends||function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),o=e&&e.__assign||function(){return(o=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},i=e&&e.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},s=e&&e.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},a=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t};Object.defineProperty(n,"__esModule",{value:!0});var c=a($),u=function(e){function t(t){var n=e.call(this,o(o({},t),{persistence:"local"}))||this;return n._anonymousUuidKey=V.ANONYMOUS_UUID+"_"+n.config.env,n._loginTypeKey=V.LOGIN_TYPE_KEY+"_"+n.config.env,n}return r(t,e),t.prototype.init=function(){e.prototype.init.call(this)},t.prototype.signIn=function(){return i(this,void 0,void 0,(function(){var e,t,n;return s(this,(function(r){switch(r.label){case 0:return e=this.cache.getStore(this._anonymousUuidKey)||void 0,t=this.cache.getStore(this.refreshTokenKey)||void 0,[4,this.httpRequest.send("auth.signInAnonymously",{anonymous_uuid:e,refresh_token:t})];case 1:return(n=r.sent()).uuid&&n.refresh_token?(this._setAnonymousUUID(n.uuid),this.setRefreshToken(n.refresh_token),[4,this.httpRequest.refreshAccessToken()]):[3,3];case 2:return r.sent(),J.activateEvent(J.EVENTS.LOGIN_STATE_CHANGED),J.activateEvent(J.EVENTS.LOGIN_TYPE_CHANGE,c.LOGINTYPE.ANONYMOUS),[2,{credential:{refreshToken:n.refresh_token}}];case 3:throw new Error("[tcb-js-sdk] 匿名登录失败")}}))}))},t.prototype.linkAndRetrieveDataWithTicket=function(e){return i(this,void 0,void 0,(function(){var t,n,r;return s(this,(function(o){switch(o.label){case 0:return t=this.cache.getStore(this._anonymousUuidKey),n=this.cache.getStore(this.refreshTokenKey),[4,this.httpRequest.send("auth.linkAndRetrieveDataWithTicket",{anonymous_uuid:t,refresh_token:n,ticket:e})];case 1:return(r=o.sent()).refresh_token?(this._clearAnonymousUUID(),this.setRefreshToken(r.refresh_token),[4,this.httpRequest.refreshAccessToken()]):[3,3];case 2:return o.sent(),J.activateEvent(J.EVENTS.ANONYMOUS_CONVERTED,{refresh_token:r.refresh_token}),J.activateEvent(J.EVENTS.LOGIN_TYPE_CHANGE,c.LOGINTYPE.CUSTOM),[2,{credential:{refreshToken:r.refresh_token}}];case 3:throw new Error("[tcb-js-sdk] 匿名转化失败")}}))}))},t.prototype.getAllStore=function(){var e={};return e[this.refreshTokenKey]=this.cache.getStore(this.refreshTokenKey)||"",e[this._loginTypeKey]=this.cache.getStore(this._loginTypeKey)||"",e[this.accessTokenKey]=this.cache.getStore(this.accessTokenKey)||"",e[this.accessTokenExpireKey]=this.cache.getStore(this.accessTokenExpireKey)||"",e},t.prototype._setAnonymousUUID=function(e){this.cache.removeStore(this._anonymousUuidKey),this.cache.setStore(this._anonymousUuidKey,e),this.cache.setStore(this._loginTypeKey,c.LOGINTYPE.ANONYMOUS)},t.prototype._clearAnonymousUUID=function(){this.cache.removeStore(this._anonymousUuidKey)},t}(c.default);n.AnonymousAuthProvider=u}));t(Z);Z.AnonymousAuthProvider;var ee=n((function(t,n){var r=e&&e.__extends||function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),o=e&&e.__assign||function(){return(o=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},i=e&&e.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},s=e&&e.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},a=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},c=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t};Object.defineProperty(n,"__esModule",{value:!0});var u=a(Q),l=c($),f=function(e){function t(t){var n=e.call(this,t)||this;return n.config=t,n}return r(t,e),t.prototype.init=function(){e.prototype.init.call(this),this.customAuthProvider=new l.default(this.config),this.customAuthProvider.init()},t.prototype.weixinAuthProvider=function(e){var t=e.appid,n=e.scope,r=e.loginMode,o=e.state,i=new u.default(this.config,t,n,r,o);return i.init(),i},t.prototype.signInAnonymously=function(){return i(this,void 0,void 0,(function(){var e=this;return s(this,(function(t){switch(t.label){case 0:return this._anonymousAuthProvider||(this._anonymousAuthProvider=new Z.AnonymousAuthProvider(this.config),this._anonymousAuthProvider.init()),J.addEventListener(J.EVENTS.LOGIN_TYPE_CHANGE,(function(t){if(t&&t.data===l.LOGINTYPE.ANONYMOUS){var n=e._anonymousAuthProvider.getAllStore();for(var r in n)n[r]&&e.httpRequest.cache.setStore(r,n[r])}})),[4,this._anonymousAuthProvider.signIn()];case 1:return[2,t.sent()]}}))}))},t.prototype.linkAndRetrieveDataWithTicket=function(e){return i(this,void 0,void 0,(function(){var t=this;return s(this,(function(n){switch(n.label){case 0:return this._anonymousAuthProvider||(this._anonymousAuthProvider=new Z.AnonymousAuthProvider(this.config),this._anonymousAuthProvider.init()),J.addEventListener(J.EVENTS.ANONYMOUS_CONVERTED,(function(e){var n=e.data.refresh_token;n&&t.httpRequest.cache.setStore(t.refreshTokenKey,n)})),[4,this._anonymousAuthProvider.linkAndRetrieveDataWithTicket(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.signOut=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,o,i,a;return s(this,(function(s){switch(s.label){case 0:if(this.loginType===l.LOGINTYPE.ANONYMOUS)throw new Error("[tcb-js-sdk] 匿名用户不支持登出操作");return e=this.httpRequest,t=e.cache,n=e.refreshTokenKey,r=e.accessTokenKey,o=e.accessTokenExpireKey,"auth.logout",(i=t.getStore(n))?[4,this.httpRequest.send("auth.logout",{refresh_token:i})]:[2];case 1:return a=s.sent(),t.removeStore(n),t.removeStore(r),t.removeStore(o),J.activateEvent(J.EVENTS.LOGIN_STATE_CHANGED),J.activateEvent(J.EVENTS.LOGIN_TYPE_CHANGE,l.LOGINTYPE.NULL),[2,a]}}))}))},t.prototype.getAccessToken=function(){return i(this,void 0,void 0,(function(){var e;return s(this,(function(t){switch(t.label){case 0:return e={},[4,this.httpRequest.getAccessToken()];case 1:return[2,(e.accessToken=t.sent().accessToken,e.env=this.config.env,e)]}}))}))},t.prototype.onLoginStateExpire=function(e){J.addEventListener("loginStateExpire",e)},t.prototype.getLoginState=function(){return i(this,void 0,void 0,(function(){var e,t,n,r,o;return s(this,(function(i){switch(i.label){case 0:if(e=this.httpRequest,t=e.cache,n=e.refreshTokenKey,r=e.accessTokenKey,!(o=t.getStore(n)))return[3,5];i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.httpRequest.refreshAccessToken()];case 2:return i.sent(),[3,4];case 3:return i.sent(),[2,null];case 4:return[2,{isAnonymous:this.loginType===l.LOGINTYPE.ANONYMOUS,credential:{refreshToken:o,accessToken:t.getStore(r)}}];case 5:return[2,null]}}))}))},t.prototype.signInWithTicket=function(e){return i(this,void 0,void 0,(function(){var t,n,r,o;return s(this,(function(i){switch(i.label){case 0:if("string"!=typeof e)throw new Error("ticket must be a string");return t=this.httpRequest,n=t.cache,r=t.refreshTokenKey,[4,this.httpRequest.send("auth.signInWithTicket",{ticket:e,refresh_token:n.getStore(r)||""})];case 1:return(o=i.sent()).refresh_token?(this.customAuthProvider.setRefreshToken(o.refresh_token),[4,this.httpRequest.refreshAccessToken()]):[3,3];case 2:return i.sent(),J.activateEvent(J.EVENTS.LOGIN_STATE_CHANGED),J.activateEvent(J.EVENTS.LOGIN_TYPE_CHANGE,l.LOGINTYPE.CUSTOM),[2,{credential:{refreshToken:o.refresh_token}}];case 3:throw new Error("[tcb-js-sdk] 自定义登录失败")}}))}))},t.prototype.shouldRefreshAccessToken=function(e){this.httpRequest._shouldRefreshAccessTokenHook=e.bind(this)},t.prototype.getUserInfo=function(){return this.httpRequest.send("auth.getUserInfo",{}).then((function(e){return e.code?e:o(o({},e.data),{requestId:e.seqId})}))},t}(l.default);n.default=f}));t(ee);var te=n((function(t,n){var r=e&&e.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},o=e&&e.__generator||function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}};Object.defineProperty(n,"__esModule",{value:!0}),n.uploadFile=function(e,t){t=t||R.createPromiseCallback();var n=new X.Request(this.config),r=e.cloudPath,o=e.filePath,i=e.onUploadProgress;return n.send("storage.getUploadMetadata",{path:r}).then((function(e){var s=e.data,a=s.url,c=s.authorization,u=s.token,l=s.fileId,f=s.cosFileId,p=e.requestId,h={key:r,signature:c,"x-cos-meta-fileid":f,success_action_status:"201","x-cos-security-token":u};n.upload({url:a,data:h,file:o,name:r,onUploadProgress:i}).then((function(e){201===e.statusCode?t(null,{fileID:l,requestId:p}):t(new Error("STORAGE_REQUEST_FAIL: "+e.data))})).catch((function(e){t(e)}))})).catch((function(e){t(e)})),t.promise},n.deleteFile=function(e,t){var n=e.fileList;if(t=t||R.createPromiseCallback(),!n||!Array.isArray(n))return{code:"INVALID_PARAM",message:"fileList必须是非空的数组"};for(var r=0,o=n;r<o.length;r++){var i=o[r];if(!i||"string"!=typeof i)return{code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"}}var s={fileid_list:n};return new X.Request(this.config).send("storage.batchDeleteFile",s).then((function(e){e.code?t(null,e):t(null,{fileList:e.data.delete_list,requestId:e.requestId})})).catch((function(e){t(e)})),t.promise},n.getTempFileURL=function(e,t){var n=e.fileList;t=t||R.createPromiseCallback(),n&&Array.isArray(n)||t(null,{code:"INVALID_PARAM",message:"fileList必须是非空的数组"});for(var r=[],o=0,i=n;o<i.length;o++){var s=i[o];"object"==typeof s?(s.hasOwnProperty("fileID")&&s.hasOwnProperty("maxAge")||t(null,{code:"INVALID_PARAM",message:"fileList的元素必须是包含fileID和maxAge的对象"}),r.push({fileid:s.fileID,max_age:s.maxAge})):"string"==typeof s?r.push({fileid:s}):t(null,{code:"INVALID_PARAM",message:"fileList的元素必须是字符串"})}var a={file_list:r};return new X.Request(this.config).send("storage.batchGetDownloadUrl",a).then((function(e){e.code?t(null,e):t(null,{fileList:e.data.download_list,requestId:e.requestId})})).catch((function(e){t(e)})),t.promise},n.downloadFile=function(e,t){var i=e.fileID;return r(this,void 0,void 0,(function(){var e,r,s,a,c;return o(this,(function(o){switch(o.label){case 0:return[4,n.getTempFileURL.call(this,{fileList:[{fileID:i,maxAge:600}]})];case 1:return e=o.sent(),"SUCCESS"!==(r=e.fileList[0]).code?[2,t?t(r):new Promise((function(e){e(r)}))]:(s=r.download_url,s=encodeURI(s),a=new X.Request(this.config),t?[4,a.download({url:s})]:[3,3]);case 2:return c=o.sent(),t(c),[3,4];case 3:return[2,a.download({url:s})];case 4:return[2]}}))}))}}));t(te);te.uploadFile,te.deleteFile,te.getTempFileURL,te.downloadFile;var ne=n((function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.callFunction=function(e,t){var n,r=e.name,o=e.data,i=e.query,s=e.parse,a=e.search,c=t||R.createPromiseCallback();try{n=o?JSON.stringify(o):""}catch(e){return Promise.reject(e)}if(!r)return Promise.reject(new Error("函数名不能为空"));var u={query:i,parse:s,search:a,function_name:r,request_data:n};return new X.Request(this.config).send("functions.invokeFunction",u).then((function(e){if(e.code)c(null,e);else{var t=e.data.response_data;if(s)c(null,{result:t,requestId:e.requestId});else try{t=JSON.parse(e.data.response_data),c(null,{result:t,requestId:e.requestId})}catch(e){c(new Error("response data must be json"))}}return c.promise})).catch((function(e){c(e)})),c.promise}}));t(ne);ne.callFunction;var re=t(n((function(t){var n=e&&e.__assign||function(){return(n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},r=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},o=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t},i=r(C),s=r(ee),a=o(te),c=o(ne),u={timeout:15e3},l=new(function(){function e(e){var t=this;this.config=e||this.config,this.authObj=void 0,J.addEventListener(J.EVENTS.LOGIN_TYPE_CHANGE,(function(e){e.data===$.LOGINTYPE.ANONYMOUS&&(t.config.persistence="local")}))}return e.prototype.init=function(t){return this.config=n(n({},u),t),W.Adapter.adapter||this._useDefaultAdapter(),new e(this.config)},e.prototype.auth=function(e){var t=(void 0===e?{}:e).persistence;return this.authObj?this.authObj:(this.config=n(n({},this.config),{persistence:t||W.Adapter.adapter.primaryStorage||"session"}),this.authObj=new s.default(this.config),this.authObj.init(),this.authObj)},e.prototype.on=function(e,t){return J.addEventListener.apply(this,[e,t])},e.prototype.off=function(e,t){return J.removeEventListener.apply(this,[e,t])},e.prototype.callFunction=function(e,t){return c.callFunction.apply(this,[e,t])},e.prototype.deleteFile=function(e,t){return a.deleteFile.apply(this,[e,t])},e.prototype.getTempFileURL=function(e,t){return a.getTempFileURL.apply(this,[e,t])},e.prototype.downloadFile=function(e,t){return a.downloadFile.apply(this,[e,t])},e.prototype.uploadFile=function(e,t){return a.uploadFile.apply(this,[e,t])},e.prototype.useAdapters=function(e){var t=W.useAdapters(e)||{},n=t.adapter,r=t.runtime;n&&(W.Adapter.adapter=n),r&&(W.Adapter.runtime=r)},e.prototype._useDefaultAdapter=function(){var e=W.useDefaultAdapter(),t=e.adapter,n=e.runtime;W.Adapter.adapter=t,W.Adapter.runtime=n},e}());l.useAdapters(i.default);try{window.tcb=l}catch(e){}t.exports=l}))),oe=function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),ie=function(){return(ie=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};var se=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return oe(t,e),t.prototype.post=function(e){var t=e.url,n=e.data,r=e.headers;return new Promise((function(e,o){uni.request({url:E("https:",t),data:n,method:"POST",header:r,success:function(t){e(t)},fail:function(e){o(e)}})}))},t.prototype.upload=function(e){return new Promise((function(t){var n=e.url,r=e.file,o=e.data,i=e.headers;uni.uploadFile({url:E("https:",n),name:"file",formData:Object.assign({},o,{file:r}),filePath:r,header:i,success:function(e){var 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:function(e){t(e)}})}))},t.prototype.download=function(e){var t=e.url,n=e.headers;return new Promise((function(e,r){uni.downloadFile({url:E("https:",t),header:n,success:function(t){200===t.statusCode&&t.tempFilePath?e({statusCode:200,tempFilePath:t.tempFilePath}):e(t)},fail:function(e){r(e)}})}))},t}(w),ae={setItem:function(e,t){uni.setStorageSync(e,t)},getItem:function(e){return uni.getStorageSync(e)},removeItem:function(e){uni.removeStorageSync(e)},clear:function(){uni.clearStorageSync()}},ce=function(e,t){void 0===t&&(t={});var n=uni.connectSocket(ie({url:e},t));return{set onopen(e){n.onOpen(e)},set onmessage(e){n.onMessage(e)},set onclose(e){n.onClose(e)},set onerror(e){n.onError(e)},send:function(e){return n.send({data:e})},close:function(e,t){return n.close({code:e,reason:t})},get readyState(){return n.readyState},CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3}};var ue={genAdapter:function(){return{root:{},reqClass:se,wsClass:ce,localStorage:ae,primaryStorage:m.local}},isMatch:function(){return"undefined"!=typeof uni&&!!uni.request},runtime:"uni_app"};re.useAdapters(ue);const le=re,fe=le.init;function pe(e){const t=JSON.parse(JSON.stringify(e||{})),n=t.name,r=this.config.env,o=Object.assign({},_,{fn:n,sid:r});return Object.assign(t.data,{clientInfo:v,uniCloudClientInfoCopy:o}),t}function he(e){const t=pe.call(this,e);console.log(this);const n={tencent:"tcb",aliyun:"aliyun"}[this.config.provider],r=_.appid,o=this.config.env,i=t.data,s=t.name;return new Promise((e,t)=>{uni.request({url:p,data:{provider:n,appid:r,spaceId:o,functionName:s,run_params:i},header:{token:process.env.USER_TOKEN},complete(n){n||(n={});const r=n.body;r||t(new Error(`[FUNCTIONS_EXECUTE_FAIL] Request Fail: [${s}]`)),console.log(`[uniCloud]${r.log}[/uniCloud]`),0===r.invokeResult&&"0"===r.invokeResult||t(new Error(r.errorMsg));const o=r.requestId;let i={};try{i=JSON.parse(r.result)}catch(e){i=r.result}e({requestId:o,result:i})}})})}le.init=function(e){const t=fe.call(this,e);t.config.provider="tencent";const n=t.auth;t.auth=function(e){const t=n.call(this,e);return["linkAndRetrieveDataWithTicket","signInAnonymously","signOut","getAccessToken","getLoginState","signInWithTicket","getUserInfo"].forEach(e=>{t[e]=d(t[e]).bind(t)}),t};if(["callFunction","uploadFile","deleteFile","getTempFileURL","downloadFile"].forEach(e=>{t[e]=d(t[e]).bind(t)}),!1!==e.autoSignIn){const e=t.auth();e.getLoginState().then(t=>{t||e.signInAnonymously()})}return t};const de={init(e){let t={};switch(e.provider){case"tencent":t=le.init(e);break;case"aliyun":t=g.init(e);break;default:throw new Error("未提供正确的provider参数")}if(!1!==e.debugFunction&&"development"===process.env.NODE_ENV&&("app-plus"===process.env.VUE_APP_PLATFORM||"h5"===process.env.VUE_APP_PLATFORM)&&process.env.USER_TOKEN)t.callFunction=function(e){d(he).call(this,e)};else{const e=t.callFunction;t.callFunction=function(t){const n=pe.call(this,t);return e.call(this,n)}}return t.init=this.init,t}};let ye=de;if(process.env.UNI_CLOUD_PROVIDER)try{ye=de.init(JSON.parse(process.env.UNI_CLOUD_PROVIDER))}catch(e){}var ve=ye;export default ve;
......@@ -24,7 +24,7 @@ function getTabBarPages (appJson) {
}
function isTabBarPage (pathName, tabBarPages) {
return tabBarPages && tabBarPages.find(item => item.pagePath === pathName)
return Array.isArray(tabBarPages) && tabBarPages.find(item => item.pagePath === pathName)
}
function parseEntryPagePath (appJson, manifestJson) {
......@@ -89,7 +89,7 @@ module.exports = function (appJson, manifestJson, {
path: entryPagePath + '.js' + (appJson.entryPageQuery || '')
}
const tabBar = manifestJson.plus.tabBar
if (isTabBarPage(entryPagePath, tabBar.list)) {
if (tabBar && isTabBarPage(entryPagePath, tabBar.list)) {
tabBar.child = ['lauchwebview']
}
} else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册