@cloudbase/js-sdk 3.10.1 → 3.10.2
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/app/dist/index.esm.js +1 -1
- package/app/dist/index.esm.js.map +1 -1
- package/app/dist/index.js +1 -1
- package/app/dist/index.js.map +1 -1
- package/app/dist/index.node.esm.js +1 -1
- package/app/dist/index.node.esm.js.map +1 -1
- package/app/dist/index.node.js +1 -1
- package/app/dist/index.node.js.map +1 -1
- package/app/dist/libs/adapter-node/request.d.ts +1 -0
- package/app/dist/libs/request.d.ts +1 -0
- package/database/dist/index.esm.js +1 -1
- package/database/dist/index.esm.js.map +1 -1
- package/database/dist/index.js +1 -1
- package/database/dist/index.js.map +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.node.cjs.js +1 -1
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.esm.js +1 -1
- package/dist/index.node.esm.js.map +1 -1
- package/miniprogram_dist/app/index.js +1 -1
- package/miniprogram_dist/database/index.js +1 -1
- package/miniprogram_dist/index.js +1 -1
- package/package.json +2 -2
package/app/dist/index.esm.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import*as t from"@cloudbase/adapter-interface";import*as e from"jwt-decode";import*as n from"@cloudbase/adapter-wx_mp";var o={d:(t,e)=>{for(var n in e)o.o(e,n)&&!o.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},r={};o.d(r,{Z:()=>Vt});var i="@cloudbase/js-sdk";function a(){return i}var s="https:",c={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"};const u=(l={AbstractSDKRequest:()=>t.AbstractSDKRequest,AbstractStorage:()=>t.AbstractStorage,StorageType:()=>t.StorageType},p={},o.d(p,l),p);var l,p,f,d,h=(f=function(t,e){return f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},f(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}f(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});function v(t){return"[object FormData]"===Object.prototype.toString.call(t)}function y(t,e,n){void 0===n&&(n={});var o=/\?/.test(e),r="";return Object.keys(n).forEach(function(t){""===r?!o&&(e+="?"):r+="&",r+="".concat(t,"=").concat(encodeURIComponent(n[t]))}),/^http(s)?:\/\//.test(e+=r)?e:"".concat(t).concat(e)}function g(t,e){console.warn("[".concat(a(),"][").concat(t,"]:").concat(e))}function b(t){var e={},n=t.match(/^(data:.*?)(\?[^#\s]*)?$/);if(n){t=n[1];var o=n[2];o&&(e=function(t){t=t.replace(/^\?/,"");var e={};return t.split("&").forEach(function(t){var n=t.split("="),o=n[0],r=n[1];o=decodeURIComponent(o),r=decodeURIComponent(r),o&&(e[o]?Array.isArray(e[o])?e[o].push(r):e[o]=[e[o],r]:e[o]=r)}),e}(o))}var r=e.token,i=function(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(t);r<o.length;r++)e.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(n[o[r]]=t[o[r]])}return n}(e,["token"]);return/^data:/.test(t)&&!r?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(t)}:r?{state:i.state,token:r,captchaData:t}:{error:"unimplemented",error_description:"need to impl captcha data"}}d=Error,h(function(t){var e=d.call(this,t.msg||t.message||"")||this;return e.code=t.code||"",e.requestId=t.requestId||"",Object.defineProperty(e,"message",{value:t.msg||t.message||"",enumerable:!0,writable:!0,configurable:!0}),e},d);var m,w=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function o(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),O=function(){return O=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},O.apply(this,arguments)},A=function(t,e,n,o){return new(n||(n=Promise))(function(r,i){function a(t){try{c(o.next(t))}catch(t){i(t)}}function s(t){try{c(o.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}c((o=o.apply(t,e||[])).next())})},I=function(t,e){var n,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,o&&(r=2&s[0]?o.return:s[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,s[1])).done)return r;switch(o=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,o=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){a.label=s[1];break}if(6===s[0]&&a.label<r[1]){a.label=r[1],r=s;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(s);break}r[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],o=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},E=function(t){function e(e){var n=t.call(this)||this,o=e.timeout,r=e.timeoutMsg,i=e.restrictedMethods;return n.timeout=o||0,n.timeoutMsg=r||"请求超时",n.restrictedMethods=i||["get","post","upload","download"],n}return w(e,t),e.prototype.get=function(t){return this.request(O(O({},t),{method:"get"}),this.restrictedMethods.includes("get"))},e.prototype.post=function(t){return this.request(O(O({},t),{method:"post"}),this.restrictedMethods.includes("post"))},e.prototype.put=function(t){return this.request(O(O({},t),{method:"put"}))},e.prototype.upload=function(t){var e=t,n=e.data,o=e.file,r=e.fileContent,i=e.name,a=e.method,s=e.headers,c=void 0===s?{}:s,u=null!=o?o:r,l={post:"post",put:"put"}[null==a?void 0:a.toLowerCase()]||"put",p=new FormData;return"post"===l?(Object.keys(n).forEach(function(t){p.append(t,n[t])}),p.append("key",i),p.append("file",u instanceof Blob?u:new Blob([u])),this.request(O(O({},t),{data:p,method:l}),this.restrictedMethods.includes("upload"))):this.request(O(O({},t),{method:"put",headers:c,body:u}),this.restrictedMethods.includes("upload"))},e.prototype.download=function(t){return A(this,void 0,Promise,function(){var e,n,o,r;return I(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.get(O(O({},t),{headers:{},responseType:"blob"}))];case 1:return e=i.sent().data,n=window.URL.createObjectURL(new Blob([e])),o=decodeURIComponent(new URL(t.url).pathname.split("/").pop()||""),(r=document.createElement("a")).href=n,r.setAttribute("download",o),r.style.display="none",document.body.appendChild(r),r.click(),window.URL.revokeObjectURL(n),document.body.removeChild(r),[3,3];case 2:return i.sent(),[3,3];case 3:return[2,new Promise(function(e){e({statusCode:200,tempFilePath:t.url})})]}})})},e.prototype.fetch=function(t){var e;return A(this,void 0,Promise,function(){var n,o,r,i,a,s,c,u,l,p,f,d,h,v=this;return I(this,function(y){switch(y.label){case 0:return n=new AbortController,o=t.url,r=t.enableAbort,i=void 0!==r&&r,a=t.stream,s=void 0!==a&&a,c=t.signal,u=t.timeout,l=t.shouldThrowOnError,p=void 0===l||l,f=null!=u?u:this.timeout,c&&(c.aborted&&n.abort(),c.addEventListener("abort",function(){return n.abort()})),d=null,i&&f&&(d=setTimeout(function(){console.warn(v.timeoutMsg),n.abort(new Error(v.timeoutMsg))},f)),[4,fetch(o,O(O({},t),{signal:n.signal})).then(function(t){return A(v,void 0,void 0,function(){var e,n,o;return I(this,function(r){switch(r.label){case 0:return clearTimeout(d),p?t.ok?(e=t,[3,3]):[3,1]:[3,4];case 1:return o=(n=Promise).reject,[4,t.json()];case 2:e=o.apply(n,[r.sent()]),r.label=3;case 3:return[2,e];case 4:return[2,t]}})})}).catch(function(t){return clearTimeout(d),Promise.reject(t)})];case 1:return h=y.sent(),[2,{data:s?h.body:(null===(e=h.headers.get("content-type"))||void 0===e?void 0:e.includes("application/json"))?h.json():h.text(),statusCode:h.status,header:h.headers,response:h}]}})})},e.prototype.request=function(t,e){var n=this;void 0===e&&(e=!1);var o=String(t.method).toLowerCase()||"get";return new Promise(function(r){var i=t.url,a=t.headers,c=void 0===a?{}:a,u=t.data,l=t.responseType,p=t.withCredentials,f=t.body,d=t.onUploadProgress,h=y(s,i,"get"===o?u:{}),g=new XMLHttpRequest;g.open(o,h),l&&(g.responseType=l);var b,m,w=t.signal;w&&(w.aborted?g.abort():w.addEventListener("abort",function(){return g.abort()},{once:!0})),Object.keys(c).forEach(function(t){g.setRequestHeader(t,c[t])}),d&&g.upload.addEventListener("progress",d),g.onreadystatechange=function(){var t={};if(4===g.readyState){var e=g.getAllResponseHeaders().trim().split(/[\r\n]+/),n={};e.forEach(function(t){var e=t.split(": "),o=e.shift().toLowerCase(),r=e.join(": ");n[o]=r}),t.header=n,t.statusCode=g.status;try{t.data="blob"===l?g.response:JSON.parse(g.responseText)}catch(e){t.data="blob"===l?g.response:g.responseText}clearTimeout(b),r(t)}},e&&n.timeout&&(b=setTimeout(function(){console.warn(n.timeoutMsg),g.abort()},n.timeout)),m=v(u)?u:"application/x-www-form-urlencoded"===c["content-type"]?function(t){void 0===t&&(t={});var e=[];return Object.keys(t).forEach(function(n){e.push("".concat(n,"=").concat(encodeURIComponent(t[n])))}),e.join("&")}(u):f||(u?JSON.stringify(u):void 0),p&&(g.withCredentials=!0),g.send(m)})},e}(u.AbstractSDKRequest),P=function(){return P=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},P.apply(this,arguments)};!function(t){t.WEB="web",t.WX_MP="wx_mp"}(m||(m={}));var S=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function o(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),C=function(t,e,n,o){return new(n||(n=Promise))(function(r,i){function a(t){try{c(o.next(t))}catch(t){i(t)}}function s(t){try{c(o.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}c((o=o.apply(t,e||[])).next())})},_=function(t,e){var n,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,o&&(r=2&s[0]?o.return:s[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,s[1])).done)return r;switch(o=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,o=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){a.label=s[1];break}if(6===s[0]&&a.label<r[1]){a.label=r[1],r=s;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(s);break}r[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],o=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},x=function(t){function e(e){var n=t.call(this)||this;return n.root=e,e.tcbCacheObject||(e.tcbCacheObject={}),n}return S(e,t),e.prototype.setItem=function(t,e){this.root.tcbCacheObject[t]=e},e.prototype.getItem=function(t){return this.root.tcbCacheObject[t]},e.prototype.removeItem=function(t){delete this.root.tcbCacheObject[t]},e.prototype.clear=function(){delete this.root.tcbCacheObject},e}(u.AbstractStorage),j=function(){function t(t){this.keys={};var e=t.persistence,n=t.platformInfo,o=void 0===n?{}:n,r=t.keys,i=void 0===r?{}:r;this.platformInfo=o,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||e,this.storage=function(t,e){switch(t){case"local":default:return e.localStorage?e.localStorage:(g(c.INVALID_PARAMS,"localStorage is not supported on current platform"),new x(e.root));case"none":return new x(e.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}return Object.defineProperty(t.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),t.prototype.setStore=function(t,e,n){if("async"!==this.mode){if(this.storage)try{var o={version:n||"localCachev1",content:e};this.storage.setItem(t,JSON.stringify(o))}catch(t){throw new Error(JSON.stringify({code:c.OPERATION_FAIL,msg:"[".concat(a(),"][").concat(c.OPERATION_FAIL,"]setStore failed"),info:t}))}}else g(c.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},t.prototype.setStoreAsync=function(t,e,n){return C(this,void 0,void 0,function(){var o;return _(this,function(r){switch(r.label){case 0:if(!this.storage)return[2];r.label=1;case 1:return r.trys.push([1,3,,4]),o={version:n||"localCachev1",content:e},[4,this.storage.setItem(t,JSON.stringify(o))];case 2:return r.sent(),[3,4];case 3:return r.sent(),[2];case 4:return[2]}})})},t.prototype.getStore=function(t,e){var n;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(n={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===n?void 0:n.tcb_token))return{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token;if(!this.storage)return""}catch(t){return""}e=e||"localCachev1";var o=this.storage.getItem(t);return o&&o.indexOf(e)>=0?JSON.parse(o).content:""}g(c.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},t.prototype.getStoreAsync=function(t,e){var n;return C(this,void 0,void 0,function(){var o;return _(this,function(r){switch(r.label){case 0:try{if("undefined"!=typeof process&&(null===(n={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===n?void 0:n.tcb_token))return[2,{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token];if(!this.storage)return[2,""]}catch(t){return[2,""]}return e=e||"localCachev1",[4,this.storage.getItem(t)];case 1:return(o=r.sent())&&o.indexOf(e)>=0?[2,JSON.parse(o).content]:[2,""]}})})},t.prototype.removeStore=function(t){"async"!==this.mode?this.storage.removeItem(t):g(c.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},t.prototype.removeStoreAsync=function(t){return C(this,void 0,void 0,function(){return _(this,function(e){switch(e.label){case 0:return[4,this.storage.removeItem(t)];case 1:return e.sent(),[2]}})})},t}(),T=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function o(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),R=function(t,e){this.data=e||null,this.name=t},k=function(t){function e(e,n){var o=t.call(this,"error",{error:e,data:n})||this;return o.error=e,o}return T(e,t),e}(R),N=function(){function t(){this.listeners={}}return t.prototype.on=function(t,e){return function(t,e,n){n[t]=n[t]||[],n[t].push(e)}(t,e,this.listeners),this},t.prototype.off=function(t,e){return function(t,e,n){if(null==n?void 0:n[t]){var o=n[t].indexOf(e);-1!==o&&n[t].splice(o,1)}}(t,e,this.listeners),this},t.prototype.fire=function(t,e){if(t instanceof k)return console.error(t.error),this;var n="string"==typeof t?new R(t,e||{}):t,o=n.name;if(this.listens(o)){n.target=this;for(var r=0,i=this.listeners[o]?function(t,e,n){if(n||2===arguments.length)for(var o,r=0,i=e.length;r<i;r++)!o&&r in e||(o||(o=Array.prototype.slice.call(e,0,r)),o[r]=e[r]);return t.concat(o||Array.prototype.slice.call(e))}([],this.listeners[o],!0):[];r<i.length;r++)i[r].call(this,n)}return this},t.prototype.listens=function(t){return this.listeners[t]&&this.listeners[t].length>0},t}();new N;var D=new N,L="lang_change";"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.indexOf("Firefox");const U=(t=>{var e={};return o.d(e,t),e})({default:()=>e.default});U.default;var q=function(t,e,n){if(n||2===arguments.length)for(var o,r=0,i=e.length;r<i;r++)!o&&r in e||(o||(o=Array.prototype.slice.call(e,0,r)),o[r]=e[r]);return t.concat(o||Array.prototype.slice.call(e))},M=c,W={};function K(t,e){var n=e.name,o=e.namespace,r=e.entity,i=e.injectEvents,a=e.IIFE,s=void 0!==a&&a;if(W[n]||o&&t[o])throw new Error(JSON.stringify({code:M.INVALID_OPERATION,msg:"Duplicate component ".concat(n)}));if(s){if(!r||"function"!=typeof r)throw new Error(JSON.stringify({code:M.INVALID_PARAMS,msg:"IIFE component's entity must be a function"}));r.call(t)}if(W[n]=e,o?t.prototype[o]=r:V(t.prototype,r),i){var c=i.bus,u=i.events;if(!c||!u||0===u.length)return;var l=t.prototype.fire||function(){};t.prototype.events||(t.prototype.events={}),(t.prototype.events||{})[n]?t.prototype.events[n].events=q(q([],t.prototype.events[n].events,!0),u,!0):t.prototype.events[n]={bus:c,events:u},t.prototype.fire=function(t,e){l(t,e);for(var n=0,o=Object.keys(this.events);n<o.length;n++){var r=o[n],i=this.events[r],a=i.bus;if(i.events.includes(t)){a.fire(t,e);break}}}}}function V(t,e){if(!(e instanceof Object))return e;switch(e.constructor){case Date:return new Date(e.getTime());case Object:void 0===t&&(t={});break;case Array:t=[];break;default:return e}for(var n=0,o=Object.keys(e);n<o.length;n++){var r=o[n];Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=V(t[r],e[r]))}return t}const B=(t=>{var e={};return o.d(e,t),e})({WxMpWebSocket:()=>n.WxMpWebSocket,WxRequest:()=>n.WxRequest,default:()=>n.default,parseQueryString:()=>n.parseQueryString,wxMpStorage:()=>n.wxMpStorage});var H=function(){return H=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},H.apply(this,arguments)},F={},J=function(){return J=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},J.apply(this,arguments)},G=j,X={},Y={};function Q(t){var e=t.env,n=t.platformInfo,o={userInfoKey:"".concat("user_info","_").concat(e)};X[e]=X[e]||new G(J(J({},t),{keys:o,platformInfo:n})),Y[e]=Y[e]||new G(J(J({},t),{keys:o,platformInfo:n,persistence:"local"}))}function $(t){return Y[t]}var z=function(){return z=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},z.apply(this,arguments)},Z="",tt="@cloudbase/js-sdk";function et(){return Z}var nt,ot=[],rt=["env","endPointKey","region"],it="https:";function at(t){return ot.find(function(e){return rt.filter(function(e){return null!=t[e]}).every(function(n){return e[n]===t[n]})})}function st(t){var e,n;t.protocol&&!/:$/.test(t.protocol)&&(t.protocol="".concat(t.protocol,":"));var o,r=at(t);r?(null!=t.baseUrl&&(r.baseUrl=t.baseUrl),null!=t.protocol&&(r.protocol=t.protocol)):ot.push(z(z({},t),{protocol:null!==(e=t.protocol)&&void 0!==e?e:it})),"CLOUD_API"===t.endPointKey&&(o=null!==(n=t.protocol)&&void 0!==n?n:it,s=o)}function ct(t,e,n){return at({env:t,endPointKey:e,region:n})}function ut(t,e){void 0===e&&(e="CLOUD_API");var n=ct(t,e||"CLOUD_API"),o=n.protocol,r=n.baseUrl;return"".concat(o).concat(r).match(/(http(s)?:)?\/\/([^/?#]*)/)[0]}!function(t){t.NULL="NULL",t.ANONYMOUS="ANONYMOUS",t.WECHAT="WECHAT",t.WECHAT_PUBLIC="WECHAT-PUBLIC",t.WECHAT_OPEN="WECHAT-OPEN",t.CUSTOM="CUSTOM",t.EMAIL="EMAIL",t.USERNAME="USERNAME",t.PHONE="PHONE"}(nt||(nt={}));var lt=function(){return lt=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},lt.apply(this,arguments)},pt=function(t,e,n,o){return new(n||(n=Promise))(function(r,i){function a(t){try{c(o.next(t))}catch(t){i(t)}}function s(t){try{c(o.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}c((o=o.apply(t,e||[])).next())})},ft=function(t,e){var n,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,o&&(r=2&s[0]?o.return:s[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,s[1])).done)return r;switch(o=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,o=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){a.label=s[1];break}if(6===s[0]&&a.label<r[1]){a.label=r[1],r=s;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(s);break}r[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],o=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},dt=c,ht=v,vt=y,yt=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"];function gt(t,e,n){var o=t[e];t[e]=function(e){var r={},i={};n.forEach(function(n){var o=n.call(t,e),a=o.data,s=o.headers;Object.assign(r,a),Object.assign(i,s)});var a=e.data;return a&&(ht(a)?Object.keys(r).forEach(function(t){a.append(t,r[t])}):e.data=lt(lt({},a),r)),e.headers=lt(lt({},e.headers||{}),i),o.call(t,e)}}function bt(){var t=Math.random().toString(16).slice(2);return{data:{seqId:t},headers:{"X-SDK-Version":"@cloudbase/js-sdk/".concat(et()),"x-seqid":t}}}var mt,wt,Ot=function(){function t(t){var e=this;this.config=t;var n={env:this.config.env,region:this.config.region,accessKey:this.config.accessKey,context:this.config.context,auth:this.config.auth,timeout:this.config.timeout,timeoutMsg:"[@cloudbase/js-sdk] 请求在".concat(this.config.timeout/1e3,"s内未完成,已中断"),restrictedMethods:["post","put"]};this.reqClass=new F.adapter.reqClass(n),this.localCache=$(this.config.env),"GATEWAY"!==this.config.endPointMode&&(gt(this.reqClass,"post",[bt]),gt(this.reqClass,"upload",[bt]),gt(this.reqClass,"download",[bt])),D.on(L,function(t){var n;e.config.i18n=(null===(n=t.data)||void 0===n?void 0:n.i18n)||e.config.i18n})}return Object.defineProperty(t.prototype,"throwWhenRequestFail",{get:function(){var t,e,n,o,r=null===(n=null===(e=null===(t=this.config)||void 0===t?void 0:t._fromApp)||void 0===e?void 0:e.config)||void 0===n?void 0:n.throw;return"boolean"==typeof r?r:!1!==(null===(o=this.config)||void 0===o?void 0:o.throw)},enumerable:!1,configurable:!0}),t.prototype.getAccessToken=function(t){return void 0===t&&(t=null),pt(this,void 0,void 0,function(){var e,n,o;return ft(this,function(r){switch(r.label){case 0:if(null!=t)return[2,t];if(!(e=this.config._fromApp).oauthInstance)throw new Error("you can't request without auth");return n=e.oauthInstance,o=n.oauth2client,[4,this.getOauthAccessTokenV2(o)];case 1:return[2,r.sent().accessToken]}})})},t.prototype.getDefaultHeaders=function(){var t,e,n;return(t={})[null===(e=this.config.i18n)||void 0===e?void 0:e.LANG_HEADER_KEY]=null===(n=this.config.i18n)||void 0===n?void 0:n.lang,t["X-SDK-Version"]="@cloudbase/js-sdk/".concat(et()),t},t.prototype.post=function(t,e){return pt(this,void 0,Promise,function(){return ft(this,function(n){switch(n.label){case 0:return[4,this.reqClass.post(lt(lt({},t),{headers:lt(lt({},t.headers),this.getDefaultHeaders()),customReqOpts:e}))];case 1:return[2,n.sent()]}})})},t.prototype.upload=function(t){var e;return pt(this,void 0,Promise,function(){var n,o,r;return ft(this,function(i){switch(i.label){case 0:return o=null!==(e=(n=t).file)&&void 0!==e?e:n.fileContent,delete(r=lt(lt({},n),{file:o,headers:lt(lt({},n.headers),this.getDefaultHeaders())})).fileContent,[4,this.reqClass.upload(r)];case 1:return[2,i.sent()]}})})},t.prototype.download=function(t){return pt(this,void 0,Promise,function(){return ft(this,function(e){switch(e.label){case 0:return[4,this.reqClass.download(lt(lt({},t),{headers:lt(lt({},t.headers),this.getDefaultHeaders())}))];case 1:return[2,e.sent()]}})})},t.prototype.getUploadByteLength=function(t){var e,n;return null===(n=(e=this.reqClass).getUploadByteLength)||void 0===n?void 0:n.call(e,t)},t.prototype.getBaseEndPoint=function(t){return void 0===t&&(t="CLOUD_API"),ut(this.config.env,t)},t.prototype.getOauthAccessTokenV2=function(t){return pt(this,void 0,Promise,function(){var e,n;return ft(this,function(o){switch(o.label){case 0:return[4,t.getAccessToken()];case 1:return e=o.sent(),[4,t.getCredentials()];case 2:return n=o.sent(),[2,{accessToken:e,accessTokenExpire:new Date(n.expires_at).getTime()}]}})})},t.prototype.request=function(t,e,n,o){var r,i;return pt(this,void 0,Promise,function(){var a,s,c,u,l,p,f,d,h,v,y,g,b,m,w,O,A,I,E,P,S,C,_;return ft(this,function(x){switch(x.label){case 0:if(x.trys.push([0,4,,5]),a="x-tcb-trace_".concat(this.config.env),s="application/x-www-form-urlencoded",c=lt({action:t,dataVersion:"2020-01-10",env:this.config.env},e),-1!==yt.indexOf(t))return[3,2];if(!(u=this.config._fromApp).oauthInstance)throw new Error("you can't request without auth");return l=u.oauthInstance,p=l.oauth2client,f=c,[4,this.getOauthAccessTokenV2(p)];case 1:f.access_token=x.sent().accessToken,x.label=2;case 2:return"storage.uploadFile"===t?(d=new FormData,Object.keys(d).forEach(function(t){Object.prototype.hasOwnProperty.call(d,t)&&void 0!==d[t]&&d.append(t,c[t])}),s="multipart/form-data"):(s="application/json;charset=UTF-8",d={},Object.keys(c).forEach(function(t){void 0!==c[t]&&(d[t]=c[t])})),h={headers:lt(lt({"content-type":s},this.getDefaultHeaders()),null==n?void 0:n.headers)},(null==n?void 0:n.onUploadProgress)&&(h.onUploadProgress=n.onUploadProgress),this.config.region&&(h.headers["X-TCB-Region"]=this.config.region),(v=this.localCache.getStore(a))&&(h.headers["X-TCB-Trace"]=v),y=void 0!==(null==n?void 0:n.parse)?n.parse:e.parse,g=void 0!==(null==n?void 0:n.inQuery)?n.inQuery:e.inQuery,b=void 0!==(null==n?void 0:n.search)?n.search:e.search,m=lt(lt({},(null==n?void 0:n.defaultQuery)||{}),{env:this.config.env}),y&&(m.parse=!0),g&&(m=lt(lt({},g),m)),w=(null==n?void 0:n.endPointMode)||this.config.endPointMode||"CLOUD_API",O=ct(this.config.env,w),A=O.baseUrl,I=O.protocol,"GATEWAY"===w&&/^((database)\.)|(auth\.wsWebSign)/.test(t)&&(E=ct(this.config.env,"CLOUD_API"),A="".concat(E.baseUrl.match(/\/\/([^/?#]*)/)[0],"/web")),P=void 0,P=n.pathname?vt(I,"".concat(null===(r=ut(this.config.env,w))||void 0===r?void 0:r.replace(/^https?:/,""),"/").concat(n.pathname),m):vt(I,A,m),b&&(P+=b),[4,this.post(lt({url:P,data:d},h),o)];case 3:if(S=x.sent(),(C=null===(i=S.header)||void 0===i?void 0:i["x-tcb-trace"])&&this.localCache.setStore(a,C),200!==Number(S.status)&&200!==Number(S.statusCode)||!S.data)throw new Error("network request error");return[2,S];case 4:_=x.sent();try{_.requestId=_.requestId||(null==n?void 0:n.headers["x-request-id"])||(null==n?void 0:n.headers["X-Request-Id"])||""}catch(t){}throw _;case 5:return[2]}})})},t.prototype.fetch=function(t){var e,n,o,r,i,a,s,c;return pt(this,void 0,Promise,function(){var u,l,p,f,d,h,v,y,g=this;return ft(this,function(b){switch(b.label){case 0:u=t.token,l=t.headers,p=void 0===l?{}:l,f=t.withCredentials,d=void 0===f||f,h=function(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(t);r<o.length;r++)e.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(n[o[r]]=t[o[r]])}return n}(t,["token","headers","withCredentials"]),v=function(){return pt(g,void 0,void 0,function(){var t,e,n,o;return ft(this,function(r){switch(r.label){case 0:if(t={},!d)return[3,4];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.getAccessToken(u)];case 2:return(e=r.sent())&&(t.Authorization="Bearer ".concat(e)),[3,4];case 3:if(n=r.sent(),"undefined"==typeof process||null==process.versions||null==process.versions.node)throw n;return[3,4];case 4:return o=lt({headers:lt(lt(lt({"X-SDK-Version":"@cloudbase/js-sdk/".concat(et())},t),this.getDefaultHeaders()),p),withCredentials:d},h),[2,this.reqClass.fetch(o)]}})})},b.label=1;case 1:return b.trys.push([1,3,,6]),[4,v()];case 2:return[2,b.sent()];case 3:y=b.sent();try{y.requestId=y.requestId||p["x-request-id"]||p["X-Request-Id"]||""}catch(t){}if("ACCESS_TOKEN_EXPIRED"!==(null==y?void 0:y.code))return[3,5];if("function"!=typeof(null===(r=null===(o=null===(n=null===(e=this.config)||void 0===e?void 0:e._fromApp)||void 0===n?void 0:n.oauthInstance)||void 0===o?void 0:o.authApi)||void 0===r?void 0:r.refreshTokenForce))throw y;return[4,null===(c=null===(s=null===(a=null===(i=this.config)||void 0===i?void 0:i._fromApp)||void 0===a?void 0:a.oauthInstance)||void 0===s?void 0:s.authApi)||void 0===c?void 0:c.refreshTokenForce()];case 4:return b.sent(),[2,v()];case 5:throw y;case 6:return[2]}})})},t.prototype.send=function(t,e,n,o){return void 0===e&&(e={}),void 0===n&&(n={}),pt(this,void 0,Promise,function(){var r;return ft(this,function(i){switch(i.label){case 0:return[4,this.request(t,e,lt(lt({},n),{onUploadProgress:e.onUploadProgress}),o)];case 1:if((r=i.sent()).data.code&&this.throwWhenRequestFail)throw new Error(JSON.stringify({code:dt.OPERATION_FAIL,msg:"[".concat(r.data.code,"] ").concat(r.data.message)}));return[2,r.data]}})})},t.prototype.gateWay=function(t,e){var n,o;return pt(this,void 0,void 0,function(){var r,i,a,s,c,u,l,p,f,d,h,v,y,g,b,m,w,O,A;return ft(this,function(I){switch(I.label){case 0:if(r=t.url,i=t.name,a=t.data,s=t.path,c=void 0===s?"":s,u=t.method,l=t.header,p=void 0===l?{}:l,!(i&&c||r))throw new Error(JSON.stringify({code:dt.INVALID_PARAMS,msg:"[gateWay] invalid function name or path or url"}));try{f=a?JSON.stringify(a):""}catch(t){throw new Error(JSON.stringify({code:dt.INVALID_PARAMS,msg:"[gateWay] invalid data"}))}if(E=(new Date).getTime(),P=(null===Date||void 0===Date?void 0:Date.now)&&1e3*Date.now()||0,d="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random();return E>0?(e=(E+e)%16|0,E=Math.floor(E/16)):(e=(P+e)%16|0,P=Math.floor(P/16)),("x"===t?e:7&e|8).toString(16)}),h=ct(this.config.env,"GATEWAY"),v=h.baseUrl,y=h.protocol,g="".concat(y).concat(v).concat(r||"/".concat(c,"/").concat(i)),b=["GET","HEAD"].includes(null===(n=null==u?void 0:u.toUpperCase)||void 0===n?void 0:n.call(u)))try{m={};try{m=JSON.parse(a)}catch(t){m=a||{}}g="".concat(g).concat(g.includes("?")?"&":"?").concat(Object.keys(m).map(function(t){return"".concat(t,"=").concat(m[t])}).join("&"))}catch(t){}return[4,this.fetch(lt(lt({method:u||"POST",headers:lt({"Content-Type":"application/json; charset=utf-8","X-Request-Id":d},p)},b?{}:{body:f}),{url:g,customReqOpts:e,shouldThrowOnError:null!==(o=t.shouldThrowOnError)&&void 0!==o?o:this.throwWhenRequestFail}))];case 1:return w=I.sent(),O=[lt({requestId:d},w)],A={},[4,w.data];case 2:return[2,lt.apply(void 0,O.concat([(A.data=I.sent(),A)]))]}var E,P})})},t}(),At={};!function(t){t.ZH="zh-CN",t.EN="en-US"}(wt||(wt={}));var It=((mt={})[wt.EN]={"请检查调用方式,或前往云开发 AI+ 首页查看文档":"Please check the calling method or visit the AI+ homepage to view the documentation","AI+ 请求出错,错误码":"AI+ request error, error code",错误信息:"error message",未实现:"not implemented","小程序不支持 wasm 加载":"wasm loading is not supported in mini programs","小程序不支持动态 js 加载":"dynamic js loading is not supported in mini programs",请求超时:"request timeout","缺少 privatelink sdk 地址":"missing privatelink sdk address"},mt),Et=function(t,e){var n;return(null===(n=It[e])||void 0===n?void 0:n[t])||t},Pt=function(t,e){var n,o,r=function(t){return"lang_".concat(t.clientId||t.env)}(e),i=(t.adapter||{}).localStorage,a=e.lang||(null===(n=null==i?void 0:i.getItem)||void 0===n?void 0:n.call(i,r))||wt.ZH;return null===(o=null==i?void 0:i.setItem)||void 0===o||o.call(i,r,a),new Proxy({t:function(t){return Et(t,a)},LANG_HEADER_KEY:"Accept-Language",lang:a},{get:function(t,e){var n;return"lang"===e&&(null===(n=null==i?void 0:i.getItem)||void 0===n?void 0:n.call(i,r))||t[e]},set:function(t,e,n){var o;return"lang"===e&&n!==t[e]&&(t[e]=n,t.t=function(t){return Et(t,n)},null===(o=null==i?void 0:i.setItem)||void 0===o||o.call(i,r,n),D.fire(L,{i18n:t})),t[e]=n,!0}})},St=new Set,Ct=function(){return Ct=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},Ct.apply(this,arguments)},_t=function(t,e,n,o){var r,i=arguments.length,a=i<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,o);else for(var s=t.length-1;s>=0;s--)(r=t[s])&&(a=(i<3?r(a):i>3?r(e,n,a):r(e,n))||a);return i>3&&a&&Object.defineProperty(e,n,a),a},xt=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},jt=function(){return{adapter:P({},{type:"default",root:window,reqClass:E,wsClass:WebSocket,localStorage}),runtime:m.WEB}},Tt=c,Rt="https://support.qq.com/products/148793",kt=g,Nt=function(t){return t.mode,t.customInfo,t.title,t.messages,function(t,e,n){}},Dt={persistence:"local"},Lt=6e5,Ut={},qt=function(){function t(t){this.cloudbaseConfig=t||this.cloudbaseConfig,this.authInstance=null,this.oauthInstance=null,this.requestInstance=null,this.version=et()}return Object.defineProperty(t.prototype,"config",{get:function(){return this.cloudbaseConfig},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"platform",{get:function(){return F},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cache",{get:function(){return t=this.cloudbaseConfig.env,X[t];var t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCache",{get:function(){return $(this.cloudbaseConfig.env)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"request",{get:function(){return this.requestInstance||(t=this.cloudbaseConfig.env,At[t]);var t},enumerable:!1,configurable:!0}),t.prototype.init=function(e){var n,o,r,i,a;if(void 0===e&&(e={env:""}),e.endPointMode=e.endPointMode||"GATEWAY",F.adapter||this.useDefaultAdapter(),(e=this.dealNodeAdapterConfig(e)).throw=null===(o=null!==(n=e.throw)&&void 0!==n?n:e.throwOnCode)||void 0===o||o,delete e.throwOnCode,!e.env)throw new Error(JSON.stringify({code:Tt.INVALID_PARAMS,msg:"env must not be specified"}));this.isInitialized(e);var s=this.isNodeEnv()?void 0:15e3,c=e.timeout||s,u={env:e.env,region:e.region,accessKey:e.accessKey,context:e.context,auth:e.auth,timeout:c,timeoutMsg:c?"[".concat(tt,"][REQUEST TIMEOUT] request had been abort since didn't finished within").concat(c/1e3,"s"):void 0};this.requestClient=new F.adapter.reqClass(u),this.cloudbaseConfig=Ct(Ct(Ct({},Dt),e),{timeout:c,i18n:Pt(F,e)}),function(t){t&&"object"==typeof t&&St.add(t)}(this.cloudbaseConfig),delete this.cloudbaseConfig.lang,this.cloudbaseConfig.timeout=this.formatTimeout(this.cloudbaseConfig.timeout);var l=this.cloudbaseConfig,p=l.env,f=l.persistence,d=l.debug,h=l.timeout,v=l.oauthClient,y=l.i18n;Q({env:p,persistence:f,debug:d,platformInfo:this.platform}),function(t,e){st({env:t,region:e,baseUrl:"//".concat(t,".").concat(e||"ap-shanghai",".tcb-api.tencentcloudapi.com/web"),protocol:void 0,endPointKey:"CLOUD_API"})}(p,e.region||""),function(t,e,n){var o="//".concat(t,".api.tcloudbasegateway.com/v1");n&&(o="//".concat(t,".api.intl.tcloudbasegateway.com/v1")),st({endPointKey:"GATEWAY",env:t,baseUrl:o,protocol:e})}(p,it,e.intl);var g=new t(this.cloudbaseConfig);return g.requestInstance=function(t){var e=new Ot(lt(lt({},t),{throw:t.throw}));return At[t.env]=e,e}({env:p,region:e.region||"",timeout:h,oauthClient:v,_fromApp:g,i18n:y,endPointMode:e.endPointMode,auth:e.auth,context:e.context,accessKey:e.accessKey,throw:e.throw}),g.requestClient=this.requestClient,null===(r=null==this?void 0:this.fire)||void 0===r||r.call(this,"cloudbase_init",g),this.try2InitAuth(g),(null===(i=F.adapter)||void 0===i?void 0:i.nodeTool)&&(null===(a=F.adapter)||void 0===a||a.nodeTool(g,this.cloudbaseConfig)),g},t.prototype.updateConfig=function(t){var e=t.persistence,n=t.debug;this.cloudbaseConfig.persistence=e,this.cloudbaseConfig.debug=n,Q({env:this.cloudbaseConfig.env,persistence:e,debug:n,platformInfo:this.platform})},t.prototype.setThrowOnCode=function(t){this.cloudbaseConfig.throw=t},t.prototype.updateLang=function(t){var e;t&&t!==(null===(e=this.cloudbaseConfig.i18n)||void 0===e?void 0:e.lang)&&(this.cloudbaseConfig.i18n.lang=t)},t.prototype.registerExtension=function(t){Ut[t.name]=t},t.prototype.invokeExtension=function(t,e){return n=this,o=void 0,i=function(){var n;return function(t,e){var n,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,o&&(r=2&s[0]?o.return:s[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,s[1])).done)return r;switch(o=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,o=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){a.label=s[1];break}if(6===s[0]&&a.label<r[1]){a.label=r[1],r=s;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(s);break}r[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],o=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}(this,function(o){switch(o.label){case 0:if(!(n=Ut[t]))throw new Error(JSON.stringify({code:Tt.INVALID_PARAMS,msg:"extension:".concat(t," must be registered before invoke")}));return[4,n.invoke(e,this)];case 1:return[2,o.sent()]}})},new((r=void 0)||(r=Promise))(function(t,e){function a(t){try{c(i.next(t))}catch(t){e(t)}}function s(t){try{c(i.throw(t))}catch(t){e(t)}}function c(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r(function(t){t(n)})).then(a,s)}c((i=i.apply(n,o||[])).next())});var n,o,r,i},t.prototype.useAdapters=function(t,e){var n=function(t,e){for(var n,o=0,r=(n=t,"[object Array]"===Object.prototype.toString.call(n)?t:[t]);o<r.length;o++){var i=r[o],a=i.isMatch,s=i.genAdapter,c=i.runtime;if(a())return{adapter:P({isMatch:a},s(e)),runtime:c}}}(t,e)||{},o=n.adapter,r=n.runtime;o&&(F.adapter=o),r&&(F.runtime=r)},t.prototype.registerHook=function(e){!function(t,e){var n=e.entity,o=e.target;if(Object.prototype.hasOwnProperty.call(t,o))throw new Error(JSON.stringify({code:M.INVALID_OPERATION,msg:"target:".concat(o," is not exist")}));var r=t.prototype[o];if("function"!=typeof r)throw new Error(JSON.stringify({code:M.INVALID_OPERATION,msg:"target:".concat(o," is not a function which is the only type supports hook")}));t.prototype[o]=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return n.call.apply(n,q([this],t,!1)),r.call.apply(r,q([this],t,!1))}}(t,e)},t.prototype.registerComponent=function(e){K(t,e)},t.prototype.registerVersion=function(t){!function(t){Z=t}(t),this.version=t},t.prototype.registerSdkName=function(t){!function(t){tt=t,function(t){i=t}(t)}(t)},t.prototype.isInitialized=function(t){return void 0===t&&(t=this.cloudbaseConfig),"string"==typeof t.env&&["your-env-id","your-envid","your_env_id","xxx-yyy","xxxx-yyy","envId","env-id","your-environment-id","REPLACE_ME"].some(function(e){return t.env.toLowerCase()===e.toLowerCase()})&&kt(Tt.INVALID_PARAMS,'[CloudBase] 检测到环境 ID "'.concat(t.env,'" 可能是占位符,请替换为真实的环境 ID。\n')+" 获取方式:登录腾讯云开发平台 → 环境管理 → 环境设置 → 环境 ID\n 建议通过环境变量配置:process.env.CLOUDBASE_ENV 或 import.meta.env.VITE_CLOUDBASE_ENV"),!!(null==t?void 0:t.env)},t.prototype.registerEndPoint=function(t,e){st({baseUrl:t,protocol:e,env:this.config.env,endPointKey:"CLOUD_API"})},t.prototype.registerEndPointWithKey=function(t){st({env:this.config.env,endPointKey:t.key,baseUrl:t.url,protocol:t.protocol})},t.prototype.registerHost=function(t,e){void 0===e&&(e="http");var n=t.replace(/^(https?:)?\/\//,""),o="//".concat(n);st({baseUrl:"".concat(o,"/web"),protocol:e,env:this.config.env,endPointKey:"CLOUD_API"}),st({baseUrl:"".concat(o,"/v1"),protocol:e,env:this.config.env,endPointKey:"GATEWAY"})},t.prototype.getEndPointWithKey=function(t){var e=ct(this.config.env,t);return{BASE_URL:e.baseUrl,PROTOCOL:e.protocol}},t.prototype.parseCaptcha=function(t){return b(t)},t.prototype.useDefaultAdapter=function(){var t=jt.bind(this)(),e=t.adapter,n=t.runtime;F.adapter=e,F.runtime=n},t.prototype.isNodeEnv=function(){var t;return"undefined"!=typeof process&&!!(null===(t=F.adapter)||void 0===t?void 0:t.getSecretInfo)},t.prototype.formatTimeout=function(t){if(null==t)return t;switch(!0){case t>Lt:return kt(Tt.INVALID_PARAMS,"timeout is greater than maximum value[10min]"),Lt;case t<100:return kt(Tt.INVALID_PARAMS,"timeout is less than maximum value[100ms]"),100;default:return t}},t.prototype.try2InitAuth=function(t){try{t.auth()}catch(t){console.log("try2InitAuth error:",t)}},t.prototype.dealNodeAdapterConfig=function(t){var e,n,o,r,i;if(this.isNodeEnv()){var a=null===(e=F.adapter)||void 0===e?void 0:e.getSecretInfo(t);t.env&&"symbol"!=typeof t.env||(t.env=a.env),a.credentials&&(t.auth=Ct(Ct({},t.auth),{credentials:a.credentials}));var s=t,c=s.secretId||(null===(n=t.auth)||void 0===n?void 0:n.secretId),u=s.secretKey||(null===(o=t.auth)||void 0===o?void 0:o.secretKey);if(c&&u){var l=s.sessionToken||(null===(r=t.auth)||void 0===r?void 0:r.sessionToken)||"";t.auth=Ct(Ct({},t.auth),{secretId:c,secretKey:u,sessionToken:l,secretType:(null===(i=t.auth)||void 0===i?void 0:i.secretType)||(l?"SESSION_SECRET":"SECRET")})}}return t},_t([Nt({mode:"sync",title:"Cloudbase 初始化失败",messages:["请确认以下各项:"," 1 - 调用 cloudbase.init() 的语法或参数是否正确"," 2 - 如果是非浏览器环境,是否配置了安全应用来源(https://docs.cloudbase.net/api-reference/webv3/adapter#%E7%AC%AC-2-%E6%AD%A5%E9%85%8D%E7%BD%AE%E5%AE%89%E5%85%A8%E5%BA%94%E7%94%A8%E6%9D%A5%E6%BA%90)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Rt)]}),xt("design:type",Function),xt("design:paramtypes",[Object]),xt("design:returntype",t)],t.prototype,"init",null),_t([Nt({title:"调用扩展能力失败",messages:["请确认以下各项:"," 1 - 调用 invokeExtension() 的语法或参数是否正确"," 2 - 被调用的扩展能力是否已经安装并通过 registerExtension() 注册","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Rt)]}),xt("design:type",Function),xt("design:paramtypes",[String,Object]),xt("design:returntype",Promise)],t.prototype,"invokeExtension",null),t}(),Mt=new qt,Wt=void 0===B.WxRequest?null:(B.default.genAdapter=function(t){return{root:{globalThis:{}},reqClass:B.WxRequest,wsClass:B.WxMpWebSocket,captchaOptions:{openURIWithCallback:function(e){var n=t.EventBus,o={},r=e;console.log("openURIWithCallback",e);var i=e.match(/^(data:.*?)(\?[^#\s]*)?$/);if(i){r=i[1],console.log("openURIWithCallback url",r);var a=i[2];a&&(o=(0,B.parseQueryString)(a))}console.log("openURIWithCallback queryObj",o);var s=o.token,c=function(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(t);r<o.length;r++)e.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(n[o[r]]=t[o[r]])}return n}(o,["token"]);return/^data:/.test(r)&&!s?Promise.reject({error:"invalid_argument",error_description:"invalie captcha data: ".concat(e)}):s?new Promise(function(t){console.log("wait for captcha..."),n.$emit("CAPTCHA_DATA_CHANGE",H(H({},c),{token:s,url:r})),n.$once("RESOLVE_CAPTCHA_DATA",function(e){t(e)})}):Promise.reject({error:"unimplemented",error_description:"need to impl captcha data"})}},localStorage:B.wxMpStorage,primaryStorage:u.StorageType.local,getAppSign:function(){var t=wx.getAccountInfoSync();return"undefined"!=typeof App||"undefined"!=typeof getApp||wx.onAppHide||wx.offAppHide||wx.onAppShow||wx.offAppShow?t&&t.miniProgram?t.miniProgram.appId:"":t&&t.plugin?t.plugin.appId:""}}},B.default);Wt&&Mt.useAdapters(Wt);const Kt=Mt;Kt.registerVersion("3.10.1");try{window.cloudbase=Kt}catch(t){}const Vt=Kt;var Bt=r.Z;export{Bt as default};
|
|
1
|
+
import*as t from"@cloudbase/adapter-interface";import*as e from"jwt-decode";import*as n from"@cloudbase/adapter-wx_mp";var o={d:(t,e)=>{for(var n in e)o.o(e,n)&&!o.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},r={};o.d(r,{Z:()=>Ht});var i="@cloudbase/js-sdk";function a(){return i}var s="https:",c={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"};const u=(l={AbstractSDKRequest:()=>t.AbstractSDKRequest,AbstractStorage:()=>t.AbstractStorage,StorageType:()=>t.StorageType},p={},o.d(p,l),p);var l,p,f,d=(f=function(t,e){return f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},f(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}f(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});function h(t){return"[object FormData]"===Object.prototype.toString.call(t)}function v(t,e,n){void 0===n&&(n={});var o=/\?/.test(e),r="";return Object.keys(n).forEach(function(t){""===r?!o&&(e+="?"):r+="&",r+="".concat(t,"=").concat(encodeURIComponent(n[t]))}),/^http(s)?:\/\//.test(e+=r)?e:"".concat(t).concat(e)}function y(t,e){console.warn("[".concat(a(),"][").concat(t,"]:").concat(e))}var g=function(t){function e(e){var n=t.call(this,e.msg||e.message||"")||this;return n.code=e.code||"",n.requestId=e.requestId||"",Object.defineProperty(n,"message",{value:e.msg||e.message||"",enumerable:!0,writable:!0,configurable:!0}),n}return d(e,t),e}(Error),b=function(t){return new g(t)};function m(t,e){return(e||b)(t)}function w(t){var e={},n=t.match(/^(data:.*?)(\?[^#\s]*)?$/);if(n){t=n[1];var o=n[2];o&&(e=function(t){t=t.replace(/^\?/,"");var e={};return t.split("&").forEach(function(t){var n=t.split("="),o=n[0],r=n[1];o=decodeURIComponent(o),r=decodeURIComponent(r),o&&(e[o]?Array.isArray(e[o])?e[o].push(r):e[o]=[e[o],r]:e[o]=r)}),e}(o))}var r=e.token,i=function(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(t);r<o.length;r++)e.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(n[o[r]]=t[o[r]])}return n}(e,["token"]);return/^data:/.test(t)&&!r?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(t)}:r?{state:i.state,token:r,captchaData:t}:{error:"unimplemented",error_description:"need to impl captcha data"}}var O,A=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function o(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),I=function(){return I=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},I.apply(this,arguments)},E=function(t,e,n,o){return new(n||(n=Promise))(function(r,i){function a(t){try{c(o.next(t))}catch(t){i(t)}}function s(t){try{c(o.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}c((o=o.apply(t,e||[])).next())})},P=function(t,e){var n,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,o&&(r=2&s[0]?o.return:s[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,s[1])).done)return r;switch(o=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,o=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){a.label=s[1];break}if(6===s[0]&&a.label<r[1]){a.label=r[1],r=s;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(s);break}r[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],o=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},C=function(t){function e(e){var n=t.call(this)||this,o=e.timeout,r=e.timeoutMsg,i=e.restrictedMethods;return n.timeout=o||0,n.timeoutMsg=r||"请求超时",n.restrictedMethods=i||["get","post","upload","download"],n}return A(e,t),e.prototype.get=function(t){return this.request(I(I({},t),{method:"get"}),this.restrictedMethods.includes("get"))},e.prototype.post=function(t){return this.request(I(I({},t),{method:"post"}),this.restrictedMethods.includes("post"))},e.prototype.put=function(t){return this.request(I(I({},t),{method:"put"}))},e.prototype.upload=function(t){var e=t,n=e.data,o=e.file,r=e.fileContent,i=e.name,a=e.method,s=e.headers,c=void 0===s?{}:s,u=null!=o?o:r,l={post:"post",put:"put"}[null==a?void 0:a.toLowerCase()]||"put",p=new FormData;return"post"===l?(Object.keys(n).forEach(function(t){p.append(t,n[t])}),p.append("key",i),p.append("file",u instanceof Blob?u:new Blob([u])),this.request(I(I({},t),{data:p,method:l}),this.restrictedMethods.includes("upload"))):this.request(I(I({},t),{method:"put",headers:c,body:u}),this.restrictedMethods.includes("upload"))},e.prototype.download=function(t){return E(this,void 0,Promise,function(){var e,n,o,r;return P(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.get(I(I({},t),{headers:{},responseType:"blob"}))];case 1:return e=i.sent().data,n=window.URL.createObjectURL(new Blob([e])),o=decodeURIComponent(new URL(t.url).pathname.split("/").pop()||""),(r=document.createElement("a")).href=n,r.setAttribute("download",o),r.style.display="none",document.body.appendChild(r),r.click(),window.URL.revokeObjectURL(n),document.body.removeChild(r),[3,3];case 2:return i.sent(),[3,3];case 3:return[2,new Promise(function(e){e({statusCode:200,tempFilePath:t.url})})]}})})},e.prototype.fetch=function(t){var e;return E(this,void 0,Promise,function(){var n,o,r,i,a,s,c,u,l,p,f,d,h,v=this;return P(this,function(y){switch(y.label){case 0:return n=new AbortController,o=t.url,r=t.enableAbort,i=void 0!==r&&r,a=t.stream,s=void 0!==a&&a,c=t.signal,u=t.timeout,l=t.shouldThrowOnError,p=void 0===l||l,f=null!=u?u:this.timeout,c&&(c.aborted&&n.abort(),c.addEventListener("abort",function(){return n.abort()})),d=null,i&&f&&(d=setTimeout(function(){console.warn(v.timeoutMsg),n.abort(new Error(v.timeoutMsg))},f)),[4,fetch(o,I(I({},t),{signal:n.signal})).then(function(t){return E(v,void 0,void 0,function(){var e,n,o;return P(this,function(r){switch(r.label){case 0:return clearTimeout(d),p?t.ok?(e=t,[3,3]):[3,1]:[3,4];case 1:return o=(n=Promise).reject,[4,t.json()];case 2:e=o.apply(n,[r.sent()]),r.label=3;case 3:return[2,e];case 4:return[2,t]}})})}).catch(function(t){return clearTimeout(d),Promise.reject(t)})];case 1:return h=y.sent(),[2,{data:s?h.body:(null===(e=h.headers.get("content-type"))||void 0===e?void 0:e.includes("application/json"))?h.json():h.text(),statusCode:h.status,header:h.headers,response:h}]}})})},e.prototype.request=function(t,e){var n=this;void 0===e&&(e=!1);var o=String(t.method).toLowerCase()||"get";return new Promise(function(r){var i=t.url,a=t.headers,c=void 0===a?{}:a,u=t.data,l=t.responseType,p=t.withCredentials,f=t.body,d=t.onUploadProgress,y=v(s,i,"get"===o?u:{}),g=new XMLHttpRequest;g.open(o,y),l&&(g.responseType=l);var b,m,w=t.signal;w&&(w.aborted?g.abort():w.addEventListener("abort",function(){return g.abort()},{once:!0})),Object.keys(c).forEach(function(t){g.setRequestHeader(t,c[t])}),d&&g.upload.addEventListener("progress",d),g.onreadystatechange=function(){var t={};if(4===g.readyState){var e=g.getAllResponseHeaders().trim().split(/[\r\n]+/),n={};e.forEach(function(t){var e=t.split(": "),o=e.shift().toLowerCase(),r=e.join(": ");n[o]=r}),t.header=n,t.statusCode=g.status;try{t.data="blob"===l?g.response:JSON.parse(g.responseText)}catch(e){t.data="blob"===l?g.response:g.responseText}clearTimeout(b),r(t)}},e&&n.timeout&&(b=setTimeout(function(){console.warn(n.timeoutMsg),g.abort()},n.timeout)),m=h(u)?u:"application/x-www-form-urlencoded"===c["content-type"]?function(t){void 0===t&&(t={});var e=[];return Object.keys(t).forEach(function(n){e.push("".concat(n,"=").concat(encodeURIComponent(t[n])))}),e.join("&")}(u):f||(u?JSON.stringify(u):void 0),p&&(g.withCredentials=!0),g.send(m)})},e}(u.AbstractSDKRequest),S=function(){return S=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},S.apply(this,arguments)};!function(t){t.WEB="web",t.WX_MP="wx_mp"}(O||(O={}));var _=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function o(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),x=function(t,e,n,o){return new(n||(n=Promise))(function(r,i){function a(t){try{c(o.next(t))}catch(t){i(t)}}function s(t){try{c(o.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}c((o=o.apply(t,e||[])).next())})},j=function(t,e){var n,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,o&&(r=2&s[0]?o.return:s[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,s[1])).done)return r;switch(o=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,o=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){a.label=s[1];break}if(6===s[0]&&a.label<r[1]){a.label=r[1],r=s;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(s);break}r[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],o=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},T=function(t){function e(e){var n=t.call(this)||this;return n.root=e,e.tcbCacheObject||(e.tcbCacheObject={}),n}return _(e,t),e.prototype.setItem=function(t,e){this.root.tcbCacheObject[t]=e},e.prototype.getItem=function(t){return this.root.tcbCacheObject[t]},e.prototype.removeItem=function(t){delete this.root.tcbCacheObject[t]},e.prototype.clear=function(){delete this.root.tcbCacheObject},e}(u.AbstractStorage),k=function(){function t(t){this.keys={};var e=t.persistence,n=t.platformInfo,o=void 0===n?{}:n,r=t.keys,i=void 0===r?{}:r;this.platformInfo=o,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||e,this.storage=function(t,e){switch(t){case"local":default:return e.localStorage?e.localStorage:(y(c.INVALID_PARAMS,"localStorage is not supported on current platform"),new T(e.root));case"none":return new T(e.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}return Object.defineProperty(t.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),t.prototype.setStore=function(t,e,n){if("async"!==this.mode){if(this.storage)try{var o={version:n||"localCachev1",content:e};this.storage.setItem(t,JSON.stringify(o))}catch(t){throw new Error(JSON.stringify({code:c.OPERATION_FAIL,msg:"[".concat(a(),"][").concat(c.OPERATION_FAIL,"]setStore failed"),info:t}))}}else y(c.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},t.prototype.setStoreAsync=function(t,e,n){return x(this,void 0,void 0,function(){var o;return j(this,function(r){switch(r.label){case 0:if(!this.storage)return[2];r.label=1;case 1:return r.trys.push([1,3,,4]),o={version:n||"localCachev1",content:e},[4,this.storage.setItem(t,JSON.stringify(o))];case 2:return r.sent(),[3,4];case 3:return r.sent(),[2];case 4:return[2]}})})},t.prototype.getStore=function(t,e){var n;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(n={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===n?void 0:n.tcb_token))return{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token;if(!this.storage)return""}catch(t){return""}e=e||"localCachev1";var o=this.storage.getItem(t);return o&&o.indexOf(e)>=0?JSON.parse(o).content:""}y(c.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},t.prototype.getStoreAsync=function(t,e){var n;return x(this,void 0,void 0,function(){var o;return j(this,function(r){switch(r.label){case 0:try{if("undefined"!=typeof process&&(null===(n={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===n?void 0:n.tcb_token))return[2,{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token];if(!this.storage)return[2,""]}catch(t){return[2,""]}return e=e||"localCachev1",[4,this.storage.getItem(t)];case 1:return(o=r.sent())&&o.indexOf(e)>=0?[2,JSON.parse(o).content]:[2,""]}})})},t.prototype.removeStore=function(t){"async"!==this.mode?this.storage.removeItem(t):y(c.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},t.prototype.removeStoreAsync=function(t){return x(this,void 0,void 0,function(){return j(this,function(e){switch(e.label){case 0:return[4,this.storage.removeItem(t)];case 1:return e.sent(),[2]}})})},t}(),R=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function o(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),N=function(t,e){this.data=e||null,this.name=t},D=function(t){function e(e,n){var o=t.call(this,"error",{error:e,data:n})||this;return o.error=e,o}return R(e,t),e}(N),L=function(){function t(){this.listeners={}}return t.prototype.on=function(t,e){return function(t,e,n){n[t]=n[t]||[],n[t].push(e)}(t,e,this.listeners),this},t.prototype.off=function(t,e){return function(t,e,n){if(null==n?void 0:n[t]){var o=n[t].indexOf(e);-1!==o&&n[t].splice(o,1)}}(t,e,this.listeners),this},t.prototype.fire=function(t,e){if(t instanceof D)return console.error(t.error),this;var n="string"==typeof t?new N(t,e||{}):t,o=n.name;if(this.listens(o)){n.target=this;for(var r=0,i=this.listeners[o]?function(t,e,n){if(n||2===arguments.length)for(var o,r=0,i=e.length;r<i;r++)!o&&r in e||(o||(o=Array.prototype.slice.call(e,0,r)),o[r]=e[r]);return t.concat(o||Array.prototype.slice.call(e))}([],this.listeners[o],!0):[];r<i.length;r++)i[r].call(this,n)}return this},t.prototype.listens=function(t){return this.listeners[t]&&this.listeners[t].length>0},t}();new L;var U=new L,q="lang_change";"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.indexOf("Firefox");const M=(t=>{var e={};return o.d(e,t),e})({default:()=>e.default});M.default;var W=function(t,e,n){if(n||2===arguments.length)for(var o,r=0,i=e.length;r<i;r++)!o&&r in e||(o||(o=Array.prototype.slice.call(e,0,r)),o[r]=e[r]);return t.concat(o||Array.prototype.slice.call(e))},K=c,V={};function B(t,e){var n=e.name,o=e.namespace,r=e.entity,i=e.injectEvents,a=e.IIFE,s=void 0!==a&&a;if(V[n]||o&&t[o])throw new Error(JSON.stringify({code:K.INVALID_OPERATION,msg:"Duplicate component ".concat(n)}));if(s){if(!r||"function"!=typeof r)throw new Error(JSON.stringify({code:K.INVALID_PARAMS,msg:"IIFE component's entity must be a function"}));r.call(t)}if(V[n]=e,o?t.prototype[o]=r:H(t.prototype,r),i){var c=i.bus,u=i.events;if(!c||!u||0===u.length)return;var l=t.prototype.fire||function(){};t.prototype.events||(t.prototype.events={}),(t.prototype.events||{})[n]?t.prototype.events[n].events=W(W([],t.prototype.events[n].events,!0),u,!0):t.prototype.events[n]={bus:c,events:u},t.prototype.fire=function(t,e){l(t,e);for(var n=0,o=Object.keys(this.events);n<o.length;n++){var r=o[n],i=this.events[r],a=i.bus;if(i.events.includes(t)){a.fire(t,e);break}}}}}function H(t,e){if(!(e instanceof Object))return e;switch(e.constructor){case Date:return new Date(e.getTime());case Object:void 0===t&&(t={});break;case Array:t=[];break;default:return e}for(var n=0,o=Object.keys(e);n<o.length;n++){var r=o[n];Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=H(t[r],e[r]))}return t}const F=(t=>{var e={};return o.d(e,t),e})({WxMpWebSocket:()=>n.WxMpWebSocket,WxRequest:()=>n.WxRequest,default:()=>n.default,parseQueryString:()=>n.parseQueryString,wxMpStorage:()=>n.wxMpStorage});var J=function(){return J=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},J.apply(this,arguments)},G={},X=function(){return X=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},X.apply(this,arguments)},Y=k,Q={},$={};function z(t){var e=t.env,n=t.platformInfo,o={userInfoKey:"".concat("user_info","_").concat(e)};Q[e]=Q[e]||new Y(X(X({},t),{keys:o,platformInfo:n})),$[e]=$[e]||new Y(X(X({},t),{keys:o,platformInfo:n,persistence:"local"}))}function Z(t){return $[t]}var tt=function(){return tt=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},tt.apply(this,arguments)},et="",nt="@cloudbase/js-sdk";function ot(){return et}var rt,it=[],at=["env","endPointKey","region"],st="https:";function ct(t){return it.find(function(e){return at.filter(function(e){return null!=t[e]}).every(function(n){return e[n]===t[n]})})}function ut(t){var e,n;t.protocol&&!/:$/.test(t.protocol)&&(t.protocol="".concat(t.protocol,":"));var o,r=ct(t);r?(null!=t.baseUrl&&(r.baseUrl=t.baseUrl),null!=t.protocol&&(r.protocol=t.protocol)):it.push(tt(tt({},t),{protocol:null!==(e=t.protocol)&&void 0!==e?e:st})),"CLOUD_API"===t.endPointKey&&(o=null!==(n=t.protocol)&&void 0!==n?n:st,s=o)}function lt(t,e,n){return ct({env:t,endPointKey:e,region:n})}function pt(t,e){void 0===e&&(e="CLOUD_API");var n=lt(t,e||"CLOUD_API"),o=n.protocol,r=n.baseUrl;return"".concat(o).concat(r).match(/(http(s)?:)?\/\/([^/?#]*)/)[0]}!function(t){t.NULL="NULL",t.ANONYMOUS="ANONYMOUS",t.WECHAT="WECHAT",t.WECHAT_PUBLIC="WECHAT-PUBLIC",t.WECHAT_OPEN="WECHAT-OPEN",t.CUSTOM="CUSTOM",t.EMAIL="EMAIL",t.USERNAME="USERNAME",t.PHONE="PHONE"}(rt||(rt={}));var ft=function(){return ft=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},ft.apply(this,arguments)},dt=function(t,e,n,o){return new(n||(n=Promise))(function(r,i){function a(t){try{c(o.next(t))}catch(t){i(t)}}function s(t){try{c(o.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}c((o=o.apply(t,e||[])).next())})},ht=function(t,e){var n,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,o&&(r=2&s[0]?o.return:s[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,s[1])).done)return r;switch(o=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,o=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){a.label=s[1];break}if(6===s[0]&&a.label<r[1]){a.label=r[1],r=s;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(s);break}r[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],o=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}},vt=c,yt=h,gt=v,bt=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"];function mt(t,e,n){var o=t[e];t[e]=function(e){var r={},i={};n.forEach(function(n){var o=n.call(t,e),a=o.data,s=o.headers;Object.assign(r,a),Object.assign(i,s)});var a=e.data;return a&&(yt(a)?Object.keys(r).forEach(function(t){a.append(t,r[t])}):e.data=ft(ft({},a),r)),e.headers=ft(ft({},e.headers||{}),i),o.call(t,e)}}function wt(){var t=Math.random().toString(16).slice(2);return{data:{seqId:t},headers:{"X-SDK-Version":"@cloudbase/js-sdk/".concat(ot()),"x-seqid":t}}}var Ot,At,It=function(){function t(t){var e=this;this.config=t;var n={env:this.config.env,region:this.config.region,accessKey:this.config.accessKey,context:this.config.context,auth:this.config.auth,timeout:this.config.timeout,timeoutMsg:"[@cloudbase/js-sdk] 请求在".concat(this.config.timeout/1e3,"s内未完成,已中断"),restrictedMethods:["post","put"]};this.reqClass=new G.adapter.reqClass(n),this.localCache=Z(this.config.env),"GATEWAY"!==this.config.endPointMode&&(mt(this.reqClass,"post",[wt]),mt(this.reqClass,"upload",[wt]),mt(this.reqClass,"download",[wt])),U.on(q,function(t){var n;e.config.i18n=(null===(n=t.data)||void 0===n?void 0:n.i18n)||e.config.i18n})}return Object.defineProperty(t.prototype,"throwWhenRequestFail",{get:function(){var t,e,n,o,r=null===(n=null===(e=null===(t=this.config)||void 0===t?void 0:t._fromApp)||void 0===e?void 0:e.config)||void 0===n?void 0:n.throw;return"boolean"==typeof r?r:!1!==(null===(o=this.config)||void 0===o?void 0:o.throw)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"errorFactory",{get:function(){var t,e,n,o=this.config;return null!==(t=null==o?void 0:o.errorFactory)&&void 0!==t?t:null===(n=null===(e=null==o?void 0:o._fromApp)||void 0===e?void 0:e.config)||void 0===n?void 0:n.errorFactory},enumerable:!1,configurable:!0}),t.prototype.getAccessToken=function(t){return void 0===t&&(t=null),dt(this,void 0,void 0,function(){var e,n,o;return ht(this,function(r){switch(r.label){case 0:if(null!=t)return[2,t];if(!(e=this.config._fromApp).oauthInstance)throw new Error("you can't request without auth");return n=e.oauthInstance,o=n.oauth2client,[4,this.getOauthAccessTokenV2(o)];case 1:return[2,r.sent().accessToken]}})})},t.prototype.getDefaultHeaders=function(){var t,e,n;return(t={})[null===(e=this.config.i18n)||void 0===e?void 0:e.LANG_HEADER_KEY]=null===(n=this.config.i18n)||void 0===n?void 0:n.lang,t["X-SDK-Version"]="@cloudbase/js-sdk/".concat(ot()),t},t.prototype.post=function(t,e){return dt(this,void 0,Promise,function(){return ht(this,function(n){switch(n.label){case 0:return[4,this.reqClass.post(ft(ft({},t),{headers:ft(ft({},t.headers),this.getDefaultHeaders()),customReqOpts:e}))];case 1:return[2,n.sent()]}})})},t.prototype.upload=function(t){var e;return dt(this,void 0,Promise,function(){var n,o,r;return ht(this,function(i){switch(i.label){case 0:return o=null!==(e=(n=t).file)&&void 0!==e?e:n.fileContent,delete(r=ft(ft({},n),{file:o,headers:ft(ft({},n.headers),this.getDefaultHeaders())})).fileContent,[4,this.reqClass.upload(r)];case 1:return[2,i.sent()]}})})},t.prototype.download=function(t){return dt(this,void 0,Promise,function(){return ht(this,function(e){switch(e.label){case 0:return[4,this.reqClass.download(ft(ft({},t),{headers:ft(ft({},t.headers),this.getDefaultHeaders())}))];case 1:return[2,e.sent()]}})})},t.prototype.getUploadByteLength=function(t){var e,n;return null===(n=(e=this.reqClass).getUploadByteLength)||void 0===n?void 0:n.call(e,t)},t.prototype.getBaseEndPoint=function(t){return void 0===t&&(t="CLOUD_API"),pt(this.config.env,t)},t.prototype.getOauthAccessTokenV2=function(t){return dt(this,void 0,Promise,function(){var e,n;return ht(this,function(o){switch(o.label){case 0:return[4,t.getAccessToken()];case 1:return e=o.sent(),[4,t.getCredentials()];case 2:return n=o.sent(),[2,{accessToken:e,accessTokenExpire:new Date(n.expires_at).getTime()}]}})})},t.prototype.request=function(t,e,n,o){var r,i;return dt(this,void 0,Promise,function(){var a,s,c,u,l,p,f,d,h,v,y,g,b,m,w,O,A,I,E,P,C,S,_;return ht(this,function(x){switch(x.label){case 0:if(x.trys.push([0,4,,5]),a="x-tcb-trace_".concat(this.config.env),s="application/x-www-form-urlencoded",c=ft({action:t,dataVersion:"2020-01-10",env:this.config.env},e),-1!==bt.indexOf(t))return[3,2];if(!(u=this.config._fromApp).oauthInstance)throw new Error("you can't request without auth");return l=u.oauthInstance,p=l.oauth2client,f=c,[4,this.getOauthAccessTokenV2(p)];case 1:f.access_token=x.sent().accessToken,x.label=2;case 2:return"storage.uploadFile"===t?(d=new FormData,Object.keys(d).forEach(function(t){Object.prototype.hasOwnProperty.call(d,t)&&void 0!==d[t]&&d.append(t,c[t])}),s="multipart/form-data"):(s="application/json;charset=UTF-8",d={},Object.keys(c).forEach(function(t){void 0!==c[t]&&(d[t]=c[t])})),h={headers:ft(ft({"content-type":s},this.getDefaultHeaders()),null==n?void 0:n.headers)},(null==n?void 0:n.onUploadProgress)&&(h.onUploadProgress=n.onUploadProgress),this.config.region&&(h.headers["X-TCB-Region"]=this.config.region),(v=this.localCache.getStore(a))&&(h.headers["X-TCB-Trace"]=v),y=void 0!==(null==n?void 0:n.parse)?n.parse:e.parse,g=void 0!==(null==n?void 0:n.inQuery)?n.inQuery:e.inQuery,b=void 0!==(null==n?void 0:n.search)?n.search:e.search,m=ft(ft({},(null==n?void 0:n.defaultQuery)||{}),{env:this.config.env}),y&&(m.parse=!0),g&&(m=ft(ft({},g),m)),w=(null==n?void 0:n.endPointMode)||this.config.endPointMode||"CLOUD_API",O=lt(this.config.env,w),A=O.baseUrl,I=O.protocol,"GATEWAY"===w&&/^((database)\.)|(auth\.wsWebSign)/.test(t)&&(E=lt(this.config.env,"CLOUD_API"),A="".concat(E.baseUrl.match(/\/\/([^/?#]*)/)[0],"/web")),P=void 0,P=n.pathname?gt(I,"".concat(null===(r=pt(this.config.env,w))||void 0===r?void 0:r.replace(/^https?:/,""),"/").concat(n.pathname),m):gt(I,A,m),b&&(P+=b),[4,this.post(ft({url:P,data:d},h),o)];case 3:if(C=x.sent(),(S=null===(i=C.header)||void 0===i?void 0:i["x-tcb-trace"])&&this.localCache.setStore(a,S),200!==Number(C.status)&&200!==Number(C.statusCode)||!C.data)throw new Error("network request error");return[2,C];case 4:_=x.sent();try{_.requestId=_.requestId||(null==n?void 0:n.headers["x-request-id"])||(null==n?void 0:n.headers["X-Request-Id"])||""}catch(t){}throw _;case 5:return[2]}})})},t.prototype.fetch=function(t){var e,n,o,r,i,a,s,c;return dt(this,void 0,Promise,function(){var u,l,p,f,d,h,v,y,g=this;return ht(this,function(b){switch(b.label){case 0:u=t.token,l=t.headers,p=void 0===l?{}:l,f=t.withCredentials,d=void 0===f||f,h=function(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(t);r<o.length;r++)e.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(n[o[r]]=t[o[r]])}return n}(t,["token","headers","withCredentials"]),v=function(){return dt(g,void 0,void 0,function(){var t,e,n,o;return ht(this,function(r){switch(r.label){case 0:if(t={},!d)return[3,4];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.getAccessToken(u)];case 2:return(e=r.sent())&&(t.Authorization="Bearer ".concat(e)),[3,4];case 3:if(n=r.sent(),"undefined"==typeof process||null==process.versions||null==process.versions.node)throw n;return[3,4];case 4:return o=ft({headers:ft(ft(ft({"X-SDK-Version":"@cloudbase/js-sdk/".concat(ot())},t),this.getDefaultHeaders()),p),withCredentials:d},h),[2,this.reqClass.fetch(o)]}})})},b.label=1;case 1:return b.trys.push([1,3,,6]),[4,v()];case 2:return[2,b.sent()];case 3:y=b.sent();try{y.requestId=y.requestId||p["x-request-id"]||p["X-Request-Id"]||""}catch(t){}if("ACCESS_TOKEN_EXPIRED"!==(null==y?void 0:y.code))return[3,5];if("function"!=typeof(null===(r=null===(o=null===(n=null===(e=this.config)||void 0===e?void 0:e._fromApp)||void 0===n?void 0:n.oauthInstance)||void 0===o?void 0:o.authApi)||void 0===r?void 0:r.refreshTokenForce))throw y;return[4,null===(c=null===(s=null===(a=null===(i=this.config)||void 0===i?void 0:i._fromApp)||void 0===a?void 0:a.oauthInstance)||void 0===s?void 0:s.authApi)||void 0===c?void 0:c.refreshTokenForce()];case 4:return b.sent(),[2,v()];case 5:throw y;case 6:return[2]}})})},t.prototype.send=function(t,e,n,o){return void 0===e&&(e={}),void 0===n&&(n={}),dt(this,void 0,Promise,function(){var r;return ht(this,function(i){switch(i.label){case 0:return[4,this.request(t,e,ft(ft({},n),{onUploadProgress:e.onUploadProgress}),o)];case 1:if((r=i.sent()).data.code&&this.throwWhenRequestFail)throw m({code:r.data.code,msg:r.data.message||"",requestId:r.requestId},this.errorFactory);return[2,r.data]}})})},t.prototype.gateWay=function(t,e){var n,o;return dt(this,void 0,void 0,function(){var r,i,a,s,c,u,l,p,f,d,h,v,y,g,b,w,O,A,I;return ht(this,function(E){switch(E.label){case 0:if(r=t.url,i=t.name,a=t.data,s=t.path,c=void 0===s?"":s,u=t.method,l=t.header,p=void 0===l?{}:l,!(i&&c||r))throw m({code:vt.INVALID_PARAMS,msg:"[gateWay] invalid function name or path or url"},this.errorFactory);try{f=a?JSON.stringify(a):""}catch(t){throw m({code:vt.INVALID_PARAMS,msg:"[gateWay] invalid data"},this.errorFactory)}if(P=(new Date).getTime(),C=(null===Date||void 0===Date?void 0:Date.now)&&1e3*Date.now()||0,d="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random();return P>0?(e=(P+e)%16|0,P=Math.floor(P/16)):(e=(C+e)%16|0,C=Math.floor(C/16)),("x"===t?e:7&e|8).toString(16)}),h=lt(this.config.env,"GATEWAY"),v=h.baseUrl,y=h.protocol,g="".concat(y).concat(v).concat(r||"/".concat(c,"/").concat(i)),b=["GET","HEAD"].includes(null===(n=null==u?void 0:u.toUpperCase)||void 0===n?void 0:n.call(u)))try{w={};try{w=JSON.parse(a)}catch(t){w=a||{}}g="".concat(g).concat(g.includes("?")?"&":"?").concat(Object.keys(w).map(function(t){return"".concat(t,"=").concat(w[t])}).join("&"))}catch(t){}return[4,this.fetch(ft(ft({method:u||"POST",headers:ft({"Content-Type":"application/json; charset=utf-8","X-Request-Id":d},p)},b?{}:{body:f}),{url:g,customReqOpts:e,shouldThrowOnError:null!==(o=t.shouldThrowOnError)&&void 0!==o?o:this.throwWhenRequestFail}))];case 1:return O=E.sent(),A=[ft({requestId:d},O)],I={},[4,O.data];case 2:return[2,ft.apply(void 0,A.concat([(I.data=E.sent(),I)]))]}var P,C})})},t}(),Et={};!function(t){t.ZH="zh-CN",t.EN="en-US"}(At||(At={}));var Pt=((Ot={})[At.EN]={"请检查调用方式,或前往云开发 AI+ 首页查看文档":"Please check the calling method or visit the AI+ homepage to view the documentation","AI+ 请求出错,错误码":"AI+ request error, error code",错误信息:"error message",未实现:"not implemented","小程序不支持 wasm 加载":"wasm loading is not supported in mini programs","小程序不支持动态 js 加载":"dynamic js loading is not supported in mini programs",请求超时:"request timeout","缺少 privatelink sdk 地址":"missing privatelink sdk address"},Ot),Ct=function(t,e){var n;return(null===(n=Pt[e])||void 0===n?void 0:n[t])||t},St=function(t,e){var n,o,r=function(t){return"lang_".concat(t.clientId||t.env)}(e),i=(t.adapter||{}).localStorage,a=e.lang||(null===(n=null==i?void 0:i.getItem)||void 0===n?void 0:n.call(i,r))||At.ZH;return null===(o=null==i?void 0:i.setItem)||void 0===o||o.call(i,r,a),new Proxy({t:function(t){return Ct(t,a)},LANG_HEADER_KEY:"Accept-Language",lang:a},{get:function(t,e){var n;return"lang"===e&&(null===(n=null==i?void 0:i.getItem)||void 0===n?void 0:n.call(i,r))||t[e]},set:function(t,e,n){var o;return"lang"===e&&n!==t[e]&&(t[e]=n,t.t=function(t){return Ct(t,n)},null===(o=null==i?void 0:i.setItem)||void 0===o||o.call(i,r,n),U.fire(q,{i18n:t})),t[e]=n,!0}})},_t=new Set,xt=function(){return xt=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},xt.apply(this,arguments)},jt=function(t,e,n,o){var r,i=arguments.length,a=i<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,o);else for(var s=t.length-1;s>=0;s--)(r=t[s])&&(a=(i<3?r(a):i>3?r(e,n,a):r(e,n))||a);return i>3&&a&&Object.defineProperty(e,n,a),a},Tt=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},kt=function(){return{adapter:S({},{type:"default",root:window,reqClass:C,wsClass:WebSocket,localStorage}),runtime:O.WEB}},Rt=c,Nt="https://support.qq.com/products/148793",Dt=y,Lt=function(t){return t.mode,t.customInfo,t.title,t.messages,function(t,e,n){}},Ut={persistence:"local"},qt=6e5,Mt={},Wt=function(){function t(t){this.cloudbaseConfig=t||this.cloudbaseConfig,this.authInstance=null,this.oauthInstance=null,this.requestInstance=null,this.version=ot()}return Object.defineProperty(t.prototype,"config",{get:function(){return this.cloudbaseConfig},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"platform",{get:function(){return G},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cache",{get:function(){return t=this.cloudbaseConfig.env,Q[t];var t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCache",{get:function(){return Z(this.cloudbaseConfig.env)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"request",{get:function(){return this.requestInstance||(t=this.cloudbaseConfig.env,Et[t]);var t},enumerable:!1,configurable:!0}),t.prototype.init=function(e){var n,o,r,i,a;if(void 0===e&&(e={env:""}),e.endPointMode=e.endPointMode||"GATEWAY",G.adapter||this.useDefaultAdapter(),(e=this.dealNodeAdapterConfig(e)).throw=null===(o=null!==(n=e.throw)&&void 0!==n?n:e.throwOnCode)||void 0===o||o,delete e.throwOnCode,!e.env)throw new Error(JSON.stringify({code:Rt.INVALID_PARAMS,msg:"env must not be specified"}));this.isInitialized(e);var s=this.isNodeEnv()?void 0:15e3,c=e.timeout||s,u={env:e.env,region:e.region,accessKey:e.accessKey,context:e.context,auth:e.auth,timeout:c,timeoutMsg:c?"[".concat(nt,"][REQUEST TIMEOUT] request had been abort since didn't finished within").concat(c/1e3,"s"):void 0};this.requestClient=new G.adapter.reqClass(u),this.cloudbaseConfig=xt(xt(xt({},Ut),e),{timeout:c,i18n:St(G,e)}),function(t){t&&"object"==typeof t&&_t.add(t)}(this.cloudbaseConfig),delete this.cloudbaseConfig.lang,this.cloudbaseConfig.timeout=this.formatTimeout(this.cloudbaseConfig.timeout);var l=this.cloudbaseConfig,p=l.env,f=l.persistence,d=l.debug,h=l.timeout,v=l.oauthClient,y=l.i18n;z({env:p,persistence:f,debug:d,platformInfo:this.platform}),function(t,e){ut({env:t,region:e,baseUrl:"//".concat(t,".").concat(e||"ap-shanghai",".tcb-api.tencentcloudapi.com/web"),protocol:void 0,endPointKey:"CLOUD_API"})}(p,e.region||""),function(t,e,n){var o="//".concat(t,".api.tcloudbasegateway.com/v1");n&&(o="//".concat(t,".api.intl.tcloudbasegateway.com/v1")),ut({endPointKey:"GATEWAY",env:t,baseUrl:o,protocol:e})}(p,st,e.intl);var g=new t(this.cloudbaseConfig);return g.requestInstance=function(t){var e=new It(ft(ft({},t),{throw:t.throw}));return Et[t.env]=e,e}({env:p,region:e.region||"",timeout:h,oauthClient:v,_fromApp:g,i18n:y,endPointMode:e.endPointMode,auth:e.auth,context:e.context,accessKey:e.accessKey,throw:e.throw}),g.requestClient=this.requestClient,null===(r=null==this?void 0:this.fire)||void 0===r||r.call(this,"cloudbase_init",g),this.try2InitAuth(g),(null===(i=G.adapter)||void 0===i?void 0:i.nodeTool)&&(null===(a=G.adapter)||void 0===a||a.nodeTool(g,this.cloudbaseConfig)),g},t.prototype.updateConfig=function(t){var e=t.persistence,n=t.debug;this.cloudbaseConfig.persistence=e,this.cloudbaseConfig.debug=n,z({env:this.cloudbaseConfig.env,persistence:e,debug:n,platformInfo:this.platform})},t.prototype.setThrowOnCode=function(t){this.cloudbaseConfig.throw=t},t.prototype.updateLang=function(t){var e;t&&t!==(null===(e=this.cloudbaseConfig.i18n)||void 0===e?void 0:e.lang)&&(this.cloudbaseConfig.i18n.lang=t)},t.prototype.registerExtension=function(t){Mt[t.name]=t},t.prototype.invokeExtension=function(t,e){return n=this,o=void 0,i=function(){var n;return function(t,e){var n,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,o&&(r=2&s[0]?o.return:s[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,s[1])).done)return r;switch(o=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,o=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((r=(r=a.trys).length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){a.label=s[1];break}if(6===s[0]&&a.label<r[1]){a.label=r[1],r=s;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(s);break}r[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],o=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}(this,function(o){switch(o.label){case 0:if(!(n=Mt[t]))throw new Error(JSON.stringify({code:Rt.INVALID_PARAMS,msg:"extension:".concat(t," must be registered before invoke")}));return[4,n.invoke(e,this)];case 1:return[2,o.sent()]}})},new((r=void 0)||(r=Promise))(function(t,e){function a(t){try{c(i.next(t))}catch(t){e(t)}}function s(t){try{c(i.throw(t))}catch(t){e(t)}}function c(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r(function(t){t(n)})).then(a,s)}c((i=i.apply(n,o||[])).next())});var n,o,r,i},t.prototype.useAdapters=function(t,e){var n=function(t,e){for(var n,o=0,r=(n=t,"[object Array]"===Object.prototype.toString.call(n)?t:[t]);o<r.length;o++){var i=r[o],a=i.isMatch,s=i.genAdapter,c=i.runtime;if(a())return{adapter:S({isMatch:a},s(e)),runtime:c}}}(t,e)||{},o=n.adapter,r=n.runtime;o&&(G.adapter=o),r&&(G.runtime=r)},t.prototype.registerHook=function(e){!function(t,e){var n=e.entity,o=e.target;if(Object.prototype.hasOwnProperty.call(t,o))throw new Error(JSON.stringify({code:K.INVALID_OPERATION,msg:"target:".concat(o," is not exist")}));var r=t.prototype[o];if("function"!=typeof r)throw new Error(JSON.stringify({code:K.INVALID_OPERATION,msg:"target:".concat(o," is not a function which is the only type supports hook")}));t.prototype[o]=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return n.call.apply(n,W([this],t,!1)),r.call.apply(r,W([this],t,!1))}}(t,e)},t.prototype.registerComponent=function(e){B(t,e)},t.prototype.registerVersion=function(t){!function(t){et=t}(t),this.version=t},t.prototype.registerSdkName=function(t){!function(t){nt=t,function(t){i=t}(t)}(t)},t.prototype.isInitialized=function(t){return void 0===t&&(t=this.cloudbaseConfig),"string"==typeof t.env&&["your-env-id","your-envid","your_env_id","xxx-yyy","xxxx-yyy","envId","env-id","your-environment-id","REPLACE_ME"].some(function(e){return t.env.toLowerCase()===e.toLowerCase()})&&Dt(Rt.INVALID_PARAMS,'[CloudBase] 检测到环境 ID "'.concat(t.env,'" 可能是占位符,请替换为真实的环境 ID。\n')+" 获取方式:登录腾讯云开发平台 → 环境管理 → 环境设置 → 环境 ID\n 建议通过环境变量配置:process.env.CLOUDBASE_ENV 或 import.meta.env.VITE_CLOUDBASE_ENV"),!!(null==t?void 0:t.env)},t.prototype.registerEndPoint=function(t,e){ut({baseUrl:t,protocol:e,env:this.config.env,endPointKey:"CLOUD_API"})},t.prototype.registerEndPointWithKey=function(t){ut({env:this.config.env,endPointKey:t.key,baseUrl:t.url,protocol:t.protocol})},t.prototype.registerHost=function(t,e){void 0===e&&(e="http");var n=t.replace(/^(https?:)?\/\//,""),o="//".concat(n);ut({baseUrl:"".concat(o,"/web"),protocol:e,env:this.config.env,endPointKey:"CLOUD_API"}),ut({baseUrl:"".concat(o,"/v1"),protocol:e,env:this.config.env,endPointKey:"GATEWAY"})},t.prototype.getEndPointWithKey=function(t){var e=lt(this.config.env,t);return{BASE_URL:e.baseUrl,PROTOCOL:e.protocol}},t.prototype.parseCaptcha=function(t){return w(t)},t.prototype.useDefaultAdapter=function(){var t=kt.bind(this)(),e=t.adapter,n=t.runtime;G.adapter=e,G.runtime=n},t.prototype.isNodeEnv=function(){var t;return"undefined"!=typeof process&&!!(null===(t=G.adapter)||void 0===t?void 0:t.getSecretInfo)},t.prototype.formatTimeout=function(t){if(null==t)return t;switch(!0){case t>qt:return Dt(Rt.INVALID_PARAMS,"timeout is greater than maximum value[10min]"),qt;case t<100:return Dt(Rt.INVALID_PARAMS,"timeout is less than maximum value[100ms]"),100;default:return t}},t.prototype.try2InitAuth=function(t){try{t.auth()}catch(t){console.log("try2InitAuth error:",t)}},t.prototype.dealNodeAdapterConfig=function(t){var e,n,o,r,i;if(this.isNodeEnv()){var a=null===(e=G.adapter)||void 0===e?void 0:e.getSecretInfo(t);t.env&&"symbol"!=typeof t.env||(t.env=a.env),a.credentials&&(t.auth=xt(xt({},t.auth),{credentials:a.credentials}));var s=t,c=s.secretId||(null===(n=t.auth)||void 0===n?void 0:n.secretId),u=s.secretKey||(null===(o=t.auth)||void 0===o?void 0:o.secretKey);if(c&&u){var l=s.sessionToken||(null===(r=t.auth)||void 0===r?void 0:r.sessionToken)||"";t.auth=xt(xt({},t.auth),{secretId:c,secretKey:u,sessionToken:l,secretType:(null===(i=t.auth)||void 0===i?void 0:i.secretType)||(l?"SESSION_SECRET":"SECRET")})}}return t},jt([Lt({mode:"sync",title:"Cloudbase 初始化失败",messages:["请确认以下各项:"," 1 - 调用 cloudbase.init() 的语法或参数是否正确"," 2 - 如果是非浏览器环境,是否配置了安全应用来源(https://docs.cloudbase.net/api-reference/webv3/adapter#%E7%AC%AC-2-%E6%AD%A5%E9%85%8D%E7%BD%AE%E5%AE%89%E5%85%A8%E5%BA%94%E7%94%A8%E6%9D%A5%E6%BA%90)","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Nt)]}),Tt("design:type",Function),Tt("design:paramtypes",[Object]),Tt("design:returntype",t)],t.prototype,"init",null),jt([Lt({title:"调用扩展能力失败",messages:["请确认以下各项:"," 1 - 调用 invokeExtension() 的语法或参数是否正确"," 2 - 被调用的扩展能力是否已经安装并通过 registerExtension() 注册","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(Nt)]}),Tt("design:type",Function),Tt("design:paramtypes",[String,Object]),Tt("design:returntype",Promise)],t.prototype,"invokeExtension",null),t}(),Kt=new Wt,Vt=void 0===F.WxRequest?null:(F.default.genAdapter=function(t){return{root:{globalThis:{}},reqClass:F.WxRequest,wsClass:F.WxMpWebSocket,captchaOptions:{openURIWithCallback:function(e){var n=t.EventBus,o={},r=e;console.log("openURIWithCallback",e);var i=e.match(/^(data:.*?)(\?[^#\s]*)?$/);if(i){r=i[1],console.log("openURIWithCallback url",r);var a=i[2];a&&(o=(0,F.parseQueryString)(a))}console.log("openURIWithCallback queryObj",o);var s=o.token,c=function(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(t);r<o.length;r++)e.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(t,o[r])&&(n[o[r]]=t[o[r]])}return n}(o,["token"]);return/^data:/.test(r)&&!s?Promise.reject({error:"invalid_argument",error_description:"invalie captcha data: ".concat(e)}):s?new Promise(function(t){console.log("wait for captcha..."),n.$emit("CAPTCHA_DATA_CHANGE",J(J({},c),{token:s,url:r})),n.$once("RESOLVE_CAPTCHA_DATA",function(e){t(e)})}):Promise.reject({error:"unimplemented",error_description:"need to impl captcha data"})}},localStorage:F.wxMpStorage,primaryStorage:u.StorageType.local,getAppSign:function(){var t=wx.getAccountInfoSync();return"undefined"!=typeof App||"undefined"!=typeof getApp||wx.onAppHide||wx.offAppHide||wx.onAppShow||wx.offAppShow?t&&t.miniProgram?t.miniProgram.appId:"":t&&t.plugin?t.plugin.appId:""}}},F.default);Vt&&Kt.useAdapters(Vt);const Bt=Kt;Bt.registerVersion("3.10.2");try{window.cloudbase=Bt}catch(t){}const Ht=Bt;var Ft=r.Z;export{Ft as default};
|
|
2
2
|
//# sourceMappingURL=index.esm.js.map
|