@cloudbase/js-sdk 3.5.5-beta.0 → 3.5.5-beta.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/ai/dist/index.esm.js +1 -1
- package/ai/dist/index.esm.js.map +1 -1
- package/ai/dist/index.js +1 -1
- package/ai/dist/index.js.map +1 -1
- 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/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/ai.js +1 -1
- package/miniprogram_dist/app.js +1 -1
- package/miniprogram_dist/index.js +1 -1
- package/package.json +1 -1
- package/types/package.json +1 -1
- package/utilities/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:()=>qt});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;function f(t){return"[object FormData]"===Object.prototype.toString.call(t)}function d(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 h(t,e){console.warn("[".concat(a(),"][").concat(t,"]:").concat(e))}function v(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 y,g,b=(y=function(t,e){return y=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])},y(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}y(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),m=function(){return m=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},m.apply(this,arguments)},w=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())}))},O=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])}}},A=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 b(e,t),e.prototype.get=function(t){return this.request(m(m({},t),{method:"get"}),this.restrictedMethods.includes("get"))},e.prototype.post=function(t){return this.request(m(m({},t),{method:"post"}),this.restrictedMethods.includes("post"))},e.prototype.put=function(t){return this.request(m(m({},t),{method:"put"}))},e.prototype.upload=function(t){var e=t.data,n=t.file,o=t.name,r=t.method,i=t.headers,a=void 0===i?{}:i,s={post:"post",put:"put"}[null==r?void 0:r.toLowerCase()]||"put",c=new FormData;return"post"===s?(Object.keys(e).forEach((function(t){c.append(t,e[t])})),c.append("key",o),c.append("file",n),this.request(m(m({},t),{data:c,method:s}),this.restrictedMethods.includes("upload"))):this.request(m(m({},t),{method:"put",headers:a,body:n}),this.restrictedMethods.includes("upload"))},e.prototype.download=function(t){return w(this,void 0,Promise,(function(){var e,n,o,r;return O(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.get(m(m({},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 w(this,void 0,Promise,(function(){var n,o,r,i,a,s,c,u,l,p,f,d,h,v=this;return O(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,m(m({},t),{signal:n.signal})).then((function(t){return w(v,void 0,void 0,(function(){var e,n,o;return O(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,h=t.body,v=t.onUploadProgress,y=d(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])})),v&&g.upload.addEventListener("progress",v),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=f(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):h||(u?JSON.stringify(u):void 0),p&&(g.withCredentials=!0),g.send(m)}))},e}(u.AbstractSDKRequest),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)};!function(t){t.WEB="web",t.WX_MP="wx_mp"}(g||(g={}));var E=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)}}(),P=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())}))},S=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])}}},_=function(t){function e(e){var n=t.call(this)||this;return n.root=e,e.tcbCacheObject||(e.tcbCacheObject={}),n}return E(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),C=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:(h(c.INVALID_PARAMS,"localStorage is not supported on current platform"),new _(e.root));case"none":return new _(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 h(c.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},t.prototype.setStoreAsync=function(t,e,n){return P(this,void 0,void 0,(function(){var o;return S(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:""}h(c.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},t.prototype.getStoreAsync=function(t,e){var n;return P(this,void 0,void 0,(function(){var o;return S(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):h(c.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},t.prototype.removeStoreAsync=function(t){return P(this,void 0,void 0,(function(){return S(this,(function(e){switch(e.label){case 0:return[4,this.storage.removeItem(t)];case 1:return e.sent(),[2]}}))}))},t}(),x=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)}}(),j=function(t,e){this.data=e||null,this.name=t},R=function(t){function e(e,n){var o=t.call(this,"error",{error:e,data:n})||this;return o.error=e,o}return x(e,t),e}(j),T=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 R)return console.error(t.error),this;var n="string"==typeof t?new j(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 T;var k=new T,N="lang_change";"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.indexOf("Firefox");const D=(t=>{var e={};return o.d(e,t),e})({default:()=>e.default});D.default;var L=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))},U=c,M={};function q(t,e){var n=e.name,o=e.namespace,r=e.entity,i=e.injectEvents,a=e.IIFE,s=void 0!==a&&a;if(M[n]||o&&t[o])throw new Error(JSON.stringify({code:U.INVALID_OPERATION,msg:"Duplicate component ".concat(n)}));if(s){if(!r||"function"!=typeof r)throw new Error(JSON.stringify({code:U.INVALID_PARAMS,msg:"IIFE component's entity must be a function"}));r.call(t)}if(M[n]=e,o?t.prototype[o]=r:W(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=L(L([],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 W(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]=W(t[r],e[r]))}return t}const V=(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 B=function(){return B=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},B.apply(this,arguments)},K={},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=C,J={},G={};function X(t){var e=t.env,n=t.platformInfo,o={userInfoKey:"".concat("user_info","_").concat(e)};J[e]=J[e]||new F(H(H({},t),{keys:o,platformInfo:n})),G[e]=G[e]||new F(H(H({},t),{keys:o,platformInfo:n,persistence:"local"}))}function Y(t){return G[t]}var Q=function(){return Q=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},Q.apply(this,arguments)},$="",z="@cloudbase/js-sdk";function Z(){return $}var tt,et=[],nt=["env","endPointKey","region"],ot="https:";function rt(t){return et.find((function(e){return nt.filter((function(e){return null!=t[e]})).every((function(n){return e[n]===t[n]}))}))}function it(t){var e,n;t.protocol&&!/:$/.test(t.protocol)&&(t.protocol="".concat(t.protocol,":"));var o,r=rt(t);r?(null!=t.baseUrl&&(r.baseUrl=t.baseUrl),null!=t.protocol&&(r.protocol=t.protocol)):et.push(Q(Q({},t),{protocol:null!==(e=t.protocol)&&void 0!==e?e:ot})),"CLOUD_API"===t.endPointKey&&(o=null!==(n=t.protocol)&&void 0!==n?n:ot,s=o)}function at(t,e,n){return rt({env:t,endPointKey:e,region:n})}function st(t,e){void 0===e&&(e="CLOUD_API");var n=at(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"}(tt||(tt={}));var 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)},ut=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())}))},lt=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])}}},pt=c,ft=f,dt=d,ht=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"];function vt(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&&(ft(a)?Object.keys(r).forEach((function(t){a.append(t,r[t])})):e.data=ct(ct({},a),r)),e.headers=ct(ct({},e.headers||{}),i),o.call(t,e)}}function yt(){var t=Math.random().toString(16).slice(2);return{data:{seqId:t},headers:{"X-SDK-Version":"@cloudbase/js-sdk/".concat(Z()),"x-seqid":t}}}var gt,bt,mt=function(){function t(t){var e=this;this.throwWhenRequestFail=!1,this.config=t;var n={timeout:this.config.timeout,timeoutMsg:"[@cloudbase/js-sdk] 请求在".concat(this.config.timeout/1e3,"s内未完成,已中断"),restrictedMethods:["post","put"],auth:t.auth};this.reqClass=new K.adapter.reqClass(n),this.throwWhenRequestFail=t.throw||!1,this.localCache=Y(this.config.env),"GATEWAY"!==this.config.endPointMode&&(vt(this.reqClass,"post",[yt]),vt(this.reqClass,"upload",[yt]),vt(this.reqClass,"download",[yt])),k.on(N,(function(t){var n;e.config.i18n=(null===(n=t.data)||void 0===n?void 0:n.i18n)||e.config.i18n}))}return t.prototype.getAccessToken=function(t){return void 0===t&&(t=null),ut(this,void 0,void 0,(function(){var e,n,o;return lt(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(Z()),t},t.prototype.post=function(t,e){return ut(this,void 0,Promise,(function(){return lt(this,(function(n){switch(n.label){case 0:return[4,this.reqClass.post(ct(ct({},t),{headers:ct(ct({},t.headers),this.getDefaultHeaders()),customReqOpts:e}))];case 1:return[2,n.sent()]}}))}))},t.prototype.upload=function(t){return ut(this,void 0,Promise,(function(){return lt(this,(function(e){switch(e.label){case 0:return[4,this.reqClass.upload(ct(ct({},t),{headers:ct(ct({},t.headers),this.getDefaultHeaders())}))];case 1:return[2,e.sent()]}}))}))},t.prototype.download=function(t){return ut(this,void 0,Promise,(function(){return lt(this,(function(e){switch(e.label){case 0:return[4,this.reqClass.download(ct(ct({},t),{headers:ct(ct({},t.headers),this.getDefaultHeaders())}))];case 1:return[2,e.sent()]}}))}))},t.prototype.getBaseEndPoint=function(t){return void 0===t&&(t="CLOUD_API"),st(this.config.env,t)},t.prototype.getOauthAccessTokenV2=function(t){return ut(this,void 0,Promise,(function(){var e,n;return lt(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 ut(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 lt(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=ct({action:t,dataVersion:"2020-01-10",env:this.config.env},e),-1!==ht.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:ct(ct({"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=ct(ct({},(null==n?void 0:n.defaultQuery)||{}),{env:this.config.env}),y&&(m.parse=!0),g&&(m=ct(ct({},g),m)),w=(null==n?void 0:n.endPointMode)||this.config.endPointMode||"CLOUD_API",O=at(this.config.env,w),A=O.baseUrl,I=O.protocol,"GATEWAY"===w&&/^((database)\.)|(auth\.wsWebSign)/.test(t)&&(E=at(this.config.env,"CLOUD_API"),A="".concat(E.baseUrl.match(/\/\/([^/?#]*)/)[0],"/web")),P=void 0,P=n.pathname?dt(I,"".concat(null===(r=st(this.config.env,w))||void 0===r?void 0:r.replace(/^https?:/,""),"/").concat(n.pathname),m):dt(I,A,m),b&&(P+=b),[4,this.post(ct({url:P,data:d},h),o)];case 3:if(S=x.sent(),(_=null===(i=S.header)||void 0===i?void 0:i["x-tcb-trace"])&&this.localCache.setStore(a,_),200!==Number(S.status)&&200!==Number(S.statusCode)||!S.data)throw new Error("network request error");return[2,S];case 4:C=x.sent();try{C.requestId=C.requestId||(null==n?void 0:n.headers["x-request-id"])||(null==n?void 0:n.headers["X-Request-Id"])||""}catch(t){}throw C;case 5:return[2]}}))}))},t.prototype.fetch=function(t){var e,n,o,r,i,a,s,c;return ut(this,void 0,Promise,(function(){var u,l,p,f,d,h,v,y,g=this;return lt(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 ut(g,void 0,void 0,(function(){var t,e,n,o;return lt(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=ct({headers:ct(ct(ct({"X-SDK-Version":"@cloudbase/js-sdk/".concat(Z())},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={}),ut(this,void 0,Promise,(function(){var r;return lt(this,(function(i){switch(i.label){case 0:return[4,this.request(t,e,ct(ct({},n),{onUploadProgress:e.onUploadProgress}),o)];case 1:if((r=i.sent()).data.code&&this.throwWhenRequestFail)throw new Error(JSON.stringify({code:pt.OPERATION_FAIL,msg:"[".concat(r.data.code,"] ").concat(r.data.message)}));return[2,r.data]}}))}))},t.prototype.gateWay=function(t,e){var n;return ut(this,void 0,void 0,(function(){var o,r,i,a,s,c,u,l,p,f,d,h,v,y,g,b,m,w,O;return lt(this,(function(A){switch(A.label){case 0:if(o=t.url,r=t.name,i=t.data,a=t.path,s=void 0===a?"":a,c=t.method,u=t.header,l=void 0===u?{}:u,!(r&&s||o))throw new Error(JSON.stringify({code:pt.INVALID_PARAMS,msg:"[gateWay] invalid function name or path or url"}));try{p=i?JSON.stringify(i):""}catch(t){throw new Error(JSON.stringify({code:pt.INVALID_PARAMS,msg:"[gateWay] invalid data"}))}if(I=(new Date).getTime(),E=(null===Date||void 0===Date?void 0:Date.now)&&1e3*Date.now()||0,f="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random();return I>0?(e=(I+e)%16|0,I=Math.floor(I/16)):(e=(E+e)%16|0,E=Math.floor(E/16)),("x"===t?e:7&e|8).toString(16)})),d=at(this.config.env,"GATEWAY"),h=d.baseUrl,v=d.protocol,y="".concat(v).concat(h).concat(o||"/".concat(s,"/").concat(r)),g=["GET","HEAD"].includes(null===(n=null==c?void 0:c.toUpperCase)||void 0===n?void 0:n.call(c)))try{b={};try{b=JSON.parse(i)}catch(t){b=i||{}}y="".concat(y).concat(y.includes("?")?"&":"?").concat(Object.keys(b).map((function(t){return"".concat(t,"=").concat(b[t])})).join("&"))}catch(t){}return[4,this.fetch(ct(ct({method:c||"POST",headers:ct({"Content-Type":"application/json; charset=utf-8","X-Request-Id":f},l)},g?{}:{body:p}),{url:y,customReqOpts:e}))];case 1:return m=A.sent(),w=[ct({requestId:f},m)],O={},[4,m.data];case 2:return[2,ct.apply(void 0,w.concat([(O.data=A.sent(),O)]))]}var I,E}))}))},t}(),wt={};!function(t){t.ZH="zh-CN",t.EN="en-US"}(bt||(bt={}));var Ot=((gt={})[bt.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"},gt),At=function(t,e){var n;return(null===(n=Ot[e])||void 0===n?void 0:n[t])||t},It=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))||bt.ZH;return null===(o=null==i?void 0:i.setItem)||void 0===o||o.call(i,r,a),new Proxy({t:function(t){return At(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 At(t,n)},null===(o=null==i?void 0:i.setItem)||void 0===o||o.call(i,r,n),k.fire(N,{i18n:t})),t[e]=n,!0}})},Et=function(){return Et=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},Et.apply(this,arguments)},Pt=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},St=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},_t=function(){return{adapter:I({},{type:"default",root:window,reqClass:A,wsClass:WebSocket,localStorage}),runtime:g.WEB}},Ct=c,xt="https://support.qq.com/products/148793",jt=h,Rt=function(t){return t.mode,t.customInfo,t.title,t.messages,function(t,e,n){}},Tt={timeout:15e3,persistence:"local"},kt=6e5,Nt={},Dt=function(){function t(t){this.cloudbaseConfig=t||this.cloudbaseConfig,this.authInstance=null,this.oauthInstance=null,this.version=Z()}return Object.defineProperty(t.prototype,"config",{get:function(){return this.cloudbaseConfig},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"platform",{get:function(){return K},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cache",{get:function(){return t=this.cloudbaseConfig.env,J[t];var t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCache",{get:function(){return Y(this.cloudbaseConfig.env)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"request",{get:function(){return t=this.cloudbaseConfig.env,wt[t];var t},enumerable:!1,configurable:!0}),t.prototype.init=function(e){var n,o,r;if(void 0===e&&(e={env:""}),e.endPointMode=e.endPointMode||"GATEWAY",K.adapter||this.useDefaultAdapter(),!(e=this.dealNodeAdapterConfig(e)).env)throw new Error(JSON.stringify({code:Ct.INVALID_PARAMS,msg:"env must not be specified"}));this.isInitialized(e);var i={timeout:e.timeout||15e3,timeoutMsg:"[".concat(z,"][REQUEST TIMEOUT] request had been abort since didn't finished within").concat(e.timeout/1e3,"s"),auth:e.auth};this.requestClient=new K.adapter.reqClass(i),this.cloudbaseConfig=Et(Et(Et({},Tt),e),{i18n:It(K,e)}),delete this.cloudbaseConfig.lang,this.cloudbaseConfig.timeout=this.formatTimeout(this.cloudbaseConfig.timeout);var a=this.cloudbaseConfig,s=a.env,c=a.persistence,u=a.debug,l=a.timeout,p=a.oauthClient,f=a.i18n;X({env:s,persistence:c,debug:u,platformInfo:this.platform}),function(t,e){it({env:t,region:e,baseUrl:"//".concat(t,".").concat(e||"ap-shanghai",".tcb-api.tencentcloudapi.com/web"),protocol:void 0,endPointKey:"CLOUD_API"})}(s,e.region||""),function(t,e,n){var o="//".concat(t,".api.tcloudbasegateway.com/v1");n&&(o="//".concat(t,".api.intl.tcloudbasegateway.com/v1")),it({endPointKey:"GATEWAY",env:t,baseUrl:o,protocol:e})}(s,ot,e.intl);var d=new t(this.cloudbaseConfig);return function(t){wt[t.env]=new mt(ct(ct({},t),{throw:!0}))}({env:s,region:e.region||"",timeout:l,oauthClient:p,_fromApp:d,i18n:f,endPointMode:e.endPointMode,auth:e.auth}),d.requestClient=this.requestClient,null===(n=null==this?void 0:this.fire)||void 0===n||n.call(this,"cloudbase_init",d),this.try2InitAuth(d),(null===(o=K.adapter)||void 0===o?void 0:o.nodeTool)&&(null===(r=K.adapter)||void 0===r||r.nodeTool(d,this.cloudbaseConfig)),d},t.prototype.updateConfig=function(t){var e=t.persistence,n=t.debug;this.cloudbaseConfig.persistence=e,this.cloudbaseConfig.debug=n,X({env:this.cloudbaseConfig.env,persistence:e,debug:n,platformInfo:this.platform})},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){Nt[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=Nt[t]))throw new Error(JSON.stringify({code:Ct.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:I({isMatch:a},s(e)),runtime:c}}}(t,e)||{},o=n.adapter,r=n.runtime;o&&(K.adapter=o),r&&(K.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:U.INVALID_OPERATION,msg:"target:".concat(o," is not exist")}));var r=t.prototype[o];if("function"!=typeof r)throw new Error(JSON.stringify({code:U.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,L([this],t,!1)),r.call.apply(r,L([this],t,!1))}}(t,e)},t.prototype.registerComponent=function(e){q(t,e)},t.prototype.registerVersion=function(t){!function(t){$=t}(t),this.version=t},t.prototype.registerSdkName=function(t){!function(t){z=t,function(t){i=t}(t)}(t)},t.prototype.isInitialized=function(t){return void 0===t&&(t=this.cloudbaseConfig),["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()}))&&jt(Ct.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){it({baseUrl:t,protocol:e,env:this.config.env,endPointKey:"CLOUD_API"})},t.prototype.registerEndPointWithKey=function(t){it({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);it({baseUrl:"".concat(o,"/web"),protocol:e,env:this.config.env,endPointKey:"CLOUD_API"}),it({baseUrl:"".concat(o,"/v1"),protocol:e,env:this.config.env,endPointKey:"GATEWAY"})},t.prototype.getEndPointWithKey=function(t){var e=at(this.config.env,t);return{BASE_URL:e.baseUrl,PROTOCOL:e.protocol}},t.prototype.parseCaptcha=function(t){return v(t)},t.prototype.useDefaultAdapter=function(){var t=_t.bind(this)(),e=t.adapter,n=t.runtime;K.adapter=e,K.runtime=n},t.prototype.formatTimeout=function(t){switch(!0){case t>kt:return jt(Ct.INVALID_PARAMS,"timeout is greater than maximum value[10min]"),kt;case t<100:return jt(Ct.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;if("undefined"!=typeof process&&void 0!=={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}&&(null===(e=K.adapter)||void 0===e?void 0:e.getSecretInfo)){var o=null===(n=K.adapter)||void 0===n?void 0:n.getSecretInfo(t);t.auth=Et(Et({},t.auth),{secretId:o.secretId,secretKey:o.secretKey,sessionToken:o.sessionToken,secretType:o.secretType}),t.env||(t.env=o.env),!t.accessKey&&o.accessKey&&(t.accessKey=o.accessKey)}return t},Pt([Rt({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(xt)]}),St("design:type",Function),St("design:paramtypes",[Object]),St("design:returntype",t)],t.prototype,"init",null),Pt([Rt({title:"调用扩展能力失败",messages:["请确认以下各项:"," 1 - 调用 invokeExtension() 的语法或参数是否正确"," 2 - 被调用的扩展能力是否已经安装并通过 registerExtension() 注册","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),St("design:type",Function),St("design:paramtypes",[String,Object]),St("design:returntype",Promise)],t.prototype,"invokeExtension",null),t}(),Lt=new Dt,Ut=void 0===V.WxRequest?null:(V.WxRequest.prototype.upload=function(t){var e=this,n=this;return new Promise((function(o){var r=t.url,i=t.file,a=t.data,s=t.headers,c=wx.getFileSystemManager(),u=wx.request({url:r,method:t.method,header:B({"content-type":" "},s),data:c.readFileSync(i),timeout:e._timeout,success:function(t){var e={statusCode:t.statusCode,data:t.data||{}};200===t.statusCode&&(null==a?void 0:a.success_action_status)&&(e.statusCode=parseInt(a.success_action_status,10)),o(e)},fail:function(t){o(t)},complete:function(t){if((null==t?void 0:t.errMsg)&&n._timeout&&-1!==n._restrictedMethods.indexOf("upload")&&"request:fail timeout"===t.errMsg){console.warn(n._timeoutMsg);try{u.abort()}catch(t){}}}})}))},V.default.genAdapter=function(t){return{root:{globalThis:{}},reqClass:V.WxRequest,wsClass:V.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,V.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",B(B({},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:V.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:""}}},V.default);Ut&&Lt.useAdapters(Ut);const Mt=Lt;Mt.registerVersion("3.5.4");try{window.cloudbase=Mt}catch(t){}const qt=Mt;var Wt=r.Z;export{Wt 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:()=>Wt});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;function f(t){return"[object FormData]"===Object.prototype.toString.call(t)}function d(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 h(t,e){console.warn("[".concat(a(),"][").concat(t,"]:").concat(e))}function v(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 y,g,b=(y=function(t,e){return y=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])},y(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}y(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),m=function(){return m=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},m.apply(this,arguments)},w=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())}))},O=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])}}},A=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 b(e,t),e.prototype.get=function(t){return this.request(m(m({},t),{method:"get"}),this.restrictedMethods.includes("get"))},e.prototype.post=function(t){return this.request(m(m({},t),{method:"post"}),this.restrictedMethods.includes("post"))},e.prototype.put=function(t){return this.request(m(m({},t),{method:"put"}))},e.prototype.upload=function(t){var e=t.data,n=t.file,o=t.name,r=t.method,i=t.headers,a=void 0===i?{}:i,s={post:"post",put:"put"}[null==r?void 0:r.toLowerCase()]||"put",c=new FormData;return"post"===s?(Object.keys(e).forEach((function(t){c.append(t,e[t])})),c.append("key",o),c.append("file",n),this.request(m(m({},t),{data:c,method:s}),this.restrictedMethods.includes("upload"))):this.request(m(m({},t),{method:"put",headers:a,body:n}),this.restrictedMethods.includes("upload"))},e.prototype.download=function(t){return w(this,void 0,Promise,(function(){var e,n,o,r;return O(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.get(m(m({},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 w(this,void 0,Promise,(function(){var n,o,r,i,a,s,c,u,l,p,f,d,h,v=this;return O(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,m(m({},t),{signal:n.signal})).then((function(t){return w(v,void 0,void 0,(function(){var e,n,o;return O(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,h=t.body,v=t.onUploadProgress,y=d(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])})),v&&g.upload.addEventListener("progress",v),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=f(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):h||(u?JSON.stringify(u):void 0),p&&(g.withCredentials=!0),g.send(m)}))},e}(u.AbstractSDKRequest),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)};!function(t){t.WEB="web",t.WX_MP="wx_mp"}(g||(g={}));var E=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)}}(),P=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())}))},S=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])}}},_=function(t){function e(e){var n=t.call(this)||this;return n.root=e,e.tcbCacheObject||(e.tcbCacheObject={}),n}return E(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),C=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:(h(c.INVALID_PARAMS,"localStorage is not supported on current platform"),new _(e.root));case"none":return new _(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 h(c.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},t.prototype.setStoreAsync=function(t,e,n){return P(this,void 0,void 0,(function(){var o;return S(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:""}h(c.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},t.prototype.getStoreAsync=function(t,e){var n;return P(this,void 0,void 0,(function(){var o;return S(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):h(c.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},t.prototype.removeStoreAsync=function(t){return P(this,void 0,void 0,(function(){return S(this,(function(e){switch(e.label){case 0:return[4,this.storage.removeItem(t)];case 1:return e.sent(),[2]}}))}))},t}(),x=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)}}(),j=function(t,e){this.data=e||null,this.name=t},R=function(t){function e(e,n){var o=t.call(this,"error",{error:e,data:n})||this;return o.error=e,o}return x(e,t),e}(j),T=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 R)return console.error(t.error),this;var n="string"==typeof t?new j(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 T;var k=new T,N="lang_change";"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.indexOf("Firefox");const D=(t=>{var e={};return o.d(e,t),e})({default:()=>e.default});D.default;var L=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))},U=c,M={};function q(t,e){var n=e.name,o=e.namespace,r=e.entity,i=e.injectEvents,a=e.IIFE,s=void 0!==a&&a;if(M[n]||o&&t[o])throw new Error(JSON.stringify({code:U.INVALID_OPERATION,msg:"Duplicate component ".concat(n)}));if(s){if(!r||"function"!=typeof r)throw new Error(JSON.stringify({code:U.INVALID_PARAMS,msg:"IIFE component's entity must be a function"}));r.call(t)}if(M[n]=e,o?t.prototype[o]=r:W(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=L(L([],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 W(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]=W(t[r],e[r]))}return t}const V=(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 B=function(){return B=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},B.apply(this,arguments)},K={},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=C,J={},G={};function X(t){var e=t.env,n=t.platformInfo,o={userInfoKey:"".concat("user_info","_").concat(e)};J[e]=J[e]||new F(H(H({},t),{keys:o,platformInfo:n})),G[e]=G[e]||new F(H(H({},t),{keys:o,platformInfo:n,persistence:"local"}))}function Y(t){return G[t]}var Q=function(){return Q=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},Q.apply(this,arguments)},$="",z="@cloudbase/js-sdk";function Z(){return $}var tt,et=[],nt=["env","endPointKey","region"],ot="https:";function rt(t){return et.find((function(e){return nt.filter((function(e){return null!=t[e]})).every((function(n){return e[n]===t[n]}))}))}function it(t){var e,n;t.protocol&&!/:$/.test(t.protocol)&&(t.protocol="".concat(t.protocol,":"));var o,r=rt(t);r?(null!=t.baseUrl&&(r.baseUrl=t.baseUrl),null!=t.protocol&&(r.protocol=t.protocol)):et.push(Q(Q({},t),{protocol:null!==(e=t.protocol)&&void 0!==e?e:ot})),"CLOUD_API"===t.endPointKey&&(o=null!==(n=t.protocol)&&void 0!==n?n:ot,s=o)}function at(t,e,n){return rt({env:t,endPointKey:e,region:n})}function st(t,e){void 0===e&&(e="CLOUD_API");var n=at(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"}(tt||(tt={}));var 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)},ut=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())}))},lt=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])}}},pt=c,ft=f,dt=d,ht=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"];function vt(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&&(ft(a)?Object.keys(r).forEach((function(t){a.append(t,r[t])})):e.data=ct(ct({},a),r)),e.headers=ct(ct({},e.headers||{}),i),o.call(t,e)}}function yt(){var t=Math.random().toString(16).slice(2);return{data:{seqId:t},headers:{"X-SDK-Version":"@cloudbase/js-sdk/".concat(Z()),"x-seqid":t}}}var gt,bt,mt=function(){function t(t){var e=this;this.throwWhenRequestFail=!1,this.config=t;var n={timeout:this.config.timeout,timeoutMsg:"[@cloudbase/js-sdk] 请求在".concat(this.config.timeout/1e3,"s内未完成,已中断"),restrictedMethods:["post","put"],auth:t.auth};this.reqClass=new K.adapter.reqClass(n),this.throwWhenRequestFail=t.throw||!1,this.localCache=Y(this.config.env),"GATEWAY"!==this.config.endPointMode&&(vt(this.reqClass,"post",[yt]),vt(this.reqClass,"upload",[yt]),vt(this.reqClass,"download",[yt])),k.on(N,(function(t){var n;e.config.i18n=(null===(n=t.data)||void 0===n?void 0:n.i18n)||e.config.i18n}))}return t.prototype.getAccessToken=function(t){return void 0===t&&(t=null),ut(this,void 0,void 0,(function(){var e,n,o;return lt(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(Z()),t},t.prototype.post=function(t,e){return ut(this,void 0,Promise,(function(){return lt(this,(function(n){switch(n.label){case 0:return[4,this.reqClass.post(ct(ct({},t),{headers:ct(ct({},t.headers),this.getDefaultHeaders()),customReqOpts:e}))];case 1:return[2,n.sent()]}}))}))},t.prototype.upload=function(t){return ut(this,void 0,Promise,(function(){return lt(this,(function(e){switch(e.label){case 0:return[4,this.reqClass.upload(ct(ct({},t),{headers:ct(ct({},t.headers),this.getDefaultHeaders())}))];case 1:return[2,e.sent()]}}))}))},t.prototype.download=function(t){return ut(this,void 0,Promise,(function(){return lt(this,(function(e){switch(e.label){case 0:return[4,this.reqClass.download(ct(ct({},t),{headers:ct(ct({},t.headers),this.getDefaultHeaders())}))];case 1:return[2,e.sent()]}}))}))},t.prototype.getBaseEndPoint=function(t){return void 0===t&&(t="CLOUD_API"),st(this.config.env,t)},t.prototype.getOauthAccessTokenV2=function(t){return ut(this,void 0,Promise,(function(){var e,n;return lt(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 ut(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 lt(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=ct({action:t,dataVersion:"2020-01-10",env:this.config.env},e),-1!==ht.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:ct(ct({"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=ct(ct({},(null==n?void 0:n.defaultQuery)||{}),{env:this.config.env}),y&&(m.parse=!0),g&&(m=ct(ct({},g),m)),w=(null==n?void 0:n.endPointMode)||this.config.endPointMode||"CLOUD_API",O=at(this.config.env,w),A=O.baseUrl,I=O.protocol,"GATEWAY"===w&&/^((database)\.)|(auth\.wsWebSign)/.test(t)&&(E=at(this.config.env,"CLOUD_API"),A="".concat(E.baseUrl.match(/\/\/([^/?#]*)/)[0],"/web")),P=void 0,P=n.pathname?dt(I,"".concat(null===(r=st(this.config.env,w))||void 0===r?void 0:r.replace(/^https?:/,""),"/").concat(n.pathname),m):dt(I,A,m),b&&(P+=b),[4,this.post(ct({url:P,data:d},h),o)];case 3:if(S=x.sent(),(_=null===(i=S.header)||void 0===i?void 0:i["x-tcb-trace"])&&this.localCache.setStore(a,_),200!==Number(S.status)&&200!==Number(S.statusCode)||!S.data)throw new Error("network request error");return[2,S];case 4:C=x.sent();try{C.requestId=C.requestId||(null==n?void 0:n.headers["x-request-id"])||(null==n?void 0:n.headers["X-Request-Id"])||""}catch(t){}throw C;case 5:return[2]}}))}))},t.prototype.fetch=function(t){var e,n,o,r,i,a,s,c;return ut(this,void 0,Promise,(function(){var u,l,p,f,d,h,v,y,g=this;return lt(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 ut(g,void 0,void 0,(function(){var t,e,n,o;return lt(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=ct({headers:ct(ct(ct({"X-SDK-Version":"@cloudbase/js-sdk/".concat(Z())},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={}),ut(this,void 0,Promise,(function(){var r;return lt(this,(function(i){switch(i.label){case 0:return[4,this.request(t,e,ct(ct({},n),{onUploadProgress:e.onUploadProgress}),o)];case 1:if((r=i.sent()).data.code&&this.throwWhenRequestFail)throw new Error(JSON.stringify({code:pt.OPERATION_FAIL,msg:"[".concat(r.data.code,"] ").concat(r.data.message)}));return[2,r.data]}}))}))},t.prototype.gateWay=function(t,e){var n;return ut(this,void 0,void 0,(function(){var o,r,i,a,s,c,u,l,p,f,d,h,v,y,g,b,m,w,O;return lt(this,(function(A){switch(A.label){case 0:if(o=t.url,r=t.name,i=t.data,a=t.path,s=void 0===a?"":a,c=t.method,u=t.header,l=void 0===u?{}:u,!(r&&s||o))throw new Error(JSON.stringify({code:pt.INVALID_PARAMS,msg:"[gateWay] invalid function name or path or url"}));try{p=i?JSON.stringify(i):""}catch(t){throw new Error(JSON.stringify({code:pt.INVALID_PARAMS,msg:"[gateWay] invalid data"}))}if(I=(new Date).getTime(),E=(null===Date||void 0===Date?void 0:Date.now)&&1e3*Date.now()||0,f="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random();return I>0?(e=(I+e)%16|0,I=Math.floor(I/16)):(e=(E+e)%16|0,E=Math.floor(E/16)),("x"===t?e:7&e|8).toString(16)})),d=at(this.config.env,"GATEWAY"),h=d.baseUrl,v=d.protocol,y="".concat(v).concat(h).concat(o||"/".concat(s,"/").concat(r)),g=["GET","HEAD"].includes(null===(n=null==c?void 0:c.toUpperCase)||void 0===n?void 0:n.call(c)))try{b={};try{b=JSON.parse(i)}catch(t){b=i||{}}y="".concat(y).concat(y.includes("?")?"&":"?").concat(Object.keys(b).map((function(t){return"".concat(t,"=").concat(b[t])})).join("&"))}catch(t){}return[4,this.fetch(ct(ct({method:c||"POST",headers:ct({"Content-Type":"application/json; charset=utf-8","X-Request-Id":f},l)},g?{}:{body:p}),{url:y,customReqOpts:e}))];case 1:return m=A.sent(),w=[ct({requestId:f},m)],O={},[4,m.data];case 2:return[2,ct.apply(void 0,w.concat([(O.data=A.sent(),O)]))]}var I,E}))}))},t}(),wt={};!function(t){t.ZH="zh-CN",t.EN="en-US"}(bt||(bt={}));var Ot=((gt={})[bt.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"},gt),At=function(t,e){var n;return(null===(n=Ot[e])||void 0===n?void 0:n[t])||t},It=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))||bt.ZH;return null===(o=null==i?void 0:i.setItem)||void 0===o||o.call(i,r,a),new Proxy({t:function(t){return At(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 At(t,n)},null===(o=null==i?void 0:i.setItem)||void 0===o||o.call(i,r,n),k.fire(N,{i18n:t})),t[e]=n,!0}})},Et=function(){return Et=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},Et.apply(this,arguments)},Pt=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},St=function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},_t=function(){return{adapter:I({},{type:"default",root:window,reqClass:A,wsClass:WebSocket,localStorage}),runtime:g.WEB}},Ct=c,xt="https://support.qq.com/products/148793",jt=h,Rt=function(t){return t.mode,t.customInfo,t.title,t.messages,function(t,e,n){}},Tt={timeout:15e3,persistence:"local"},kt=6e5,Nt={},Dt=function(){function t(t){this.cloudbaseConfig=t||this.cloudbaseConfig,this.authInstance=null,this.oauthInstance=null,this.version=Z()}return Object.defineProperty(t.prototype,"config",{get:function(){return this.cloudbaseConfig},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"platform",{get:function(){return K},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cache",{get:function(){return t=this.cloudbaseConfig.env,J[t];var t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"localCache",{get:function(){return Y(this.cloudbaseConfig.env)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"request",{get:function(){return t=this.cloudbaseConfig.env,wt[t];var t},enumerable:!1,configurable:!0}),t.prototype.init=function(e){var n,o,r;if(void 0===e&&(e={env:""}),e.endPointMode=e.endPointMode||"GATEWAY",K.adapter||this.useDefaultAdapter(),!(e=this.dealNodeAdapterConfig(e)).env)throw new Error(JSON.stringify({code:Ct.INVALID_PARAMS,msg:"env must not be specified"}));this.isInitialized(e);var i={timeout:e.timeout||15e3,timeoutMsg:"[".concat(z,"][REQUEST TIMEOUT] request had been abort since didn't finished within").concat(e.timeout/1e3,"s"),auth:e.auth};this.requestClient=new K.adapter.reqClass(i),this.cloudbaseConfig=Et(Et(Et({},Tt),e),{i18n:It(K,e)}),delete this.cloudbaseConfig.lang,this.cloudbaseConfig.timeout=this.formatTimeout(this.cloudbaseConfig.timeout);var a=this.cloudbaseConfig,s=a.env,c=a.persistence,u=a.debug,l=a.timeout,p=a.oauthClient,f=a.i18n;X({env:s,persistence:c,debug:u,platformInfo:this.platform}),function(t,e){it({env:t,region:e,baseUrl:"//".concat(t,".").concat(e||"ap-shanghai",".tcb-api.tencentcloudapi.com/web"),protocol:void 0,endPointKey:"CLOUD_API"})}(s,e.region||""),function(t,e,n){var o="//".concat(t,".api.tcloudbasegateway.com/v1");n&&(o="//".concat(t,".api.intl.tcloudbasegateway.com/v1")),it({endPointKey:"GATEWAY",env:t,baseUrl:o,protocol:e})}(s,ot,e.intl);var d=new t(this.cloudbaseConfig);return function(t){wt[t.env]=new mt(ct(ct({},t),{throw:!0}))}({env:s,region:e.region||"",timeout:l,oauthClient:p,_fromApp:d,i18n:f,endPointMode:e.endPointMode,auth:e.auth}),d.requestClient=this.requestClient,null===(n=null==this?void 0:this.fire)||void 0===n||n.call(this,"cloudbase_init",d),this.try2InitAuth(d),(null===(o=K.adapter)||void 0===o?void 0:o.nodeTool)&&(null===(r=K.adapter)||void 0===r||r.nodeTool(d,this.cloudbaseConfig)),d},t.prototype.updateConfig=function(t){var e=t.persistence,n=t.debug;this.cloudbaseConfig.persistence=e,this.cloudbaseConfig.debug=n,X({env:this.cloudbaseConfig.env,persistence:e,debug:n,platformInfo:this.platform})},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){Nt[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=Nt[t]))throw new Error(JSON.stringify({code:Ct.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:I({isMatch:a},s(e)),runtime:c}}}(t,e)||{},o=n.adapter,r=n.runtime;o&&(K.adapter=o),r&&(K.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:U.INVALID_OPERATION,msg:"target:".concat(o," is not exist")}));var r=t.prototype[o];if("function"!=typeof r)throw new Error(JSON.stringify({code:U.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,L([this],t,!1)),r.call.apply(r,L([this],t,!1))}}(t,e)},t.prototype.registerComponent=function(e){q(t,e)},t.prototype.registerVersion=function(t){!function(t){$=t}(t),this.version=t},t.prototype.registerSdkName=function(t){!function(t){z=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()}))&&jt(Ct.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){it({baseUrl:t,protocol:e,env:this.config.env,endPointKey:"CLOUD_API"})},t.prototype.registerEndPointWithKey=function(t){it({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);it({baseUrl:"".concat(o,"/web"),protocol:e,env:this.config.env,endPointKey:"CLOUD_API"}),it({baseUrl:"".concat(o,"/v1"),protocol:e,env:this.config.env,endPointKey:"GATEWAY"})},t.prototype.getEndPointWithKey=function(t){var e=at(this.config.env,t);return{BASE_URL:e.baseUrl,PROTOCOL:e.protocol}},t.prototype.parseCaptcha=function(t){return v(t)},t.prototype.useDefaultAdapter=function(){var t=_t.bind(this)(),e=t.adapter,n=t.runtime;K.adapter=e,K.runtime=n},t.prototype.formatTimeout=function(t){switch(!0){case t>kt:return jt(Ct.INVALID_PARAMS,"timeout is greater than maximum value[10min]"),kt;case t<100:return jt(Ct.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;if("undefined"!=typeof process&&void 0!=={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}&&(null===(e=K.adapter)||void 0===e?void 0:e.getSecretInfo)){var o=null===(n=K.adapter)||void 0===n?void 0:n.getSecretInfo(t);t.auth=Et(Et({},t.auth),{secretId:o.secretId,secretKey:o.secretKey,sessionToken:o.sessionToken,secretType:o.secretType}),t.env&&"symbol"!=typeof t.env||(t.env=o.env),!t.accessKey&&o.accessKey&&(t.accessKey=o.accessKey)}return t},Pt([Rt({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(xt)]}),St("design:type",Function),St("design:paramtypes",[Object]),St("design:returntype",t)],t.prototype,"init",null),Pt([Rt({title:"调用扩展能力失败",messages:["请确认以下各项:"," 1 - 调用 invokeExtension() 的语法或参数是否正确"," 2 - 被调用的扩展能力是否已经安装并通过 registerExtension() 注册","如果问题依然存在,建议到官方问答社区提问或寻找帮助:".concat(xt)]}),St("design:type",Function),St("design:paramtypes",[String,Object]),St("design:returntype",Promise)],t.prototype,"invokeExtension",null),t}(),Lt=new Dt,Ut=void 0===V.WxRequest?null:(V.WxRequest.prototype.upload=function(t){var e=this,n=this;return new Promise((function(o){var r=t.url,i=t.file,a=t.data,s=t.headers,c=wx.getFileSystemManager(),u=wx.request({url:r,method:t.method,header:B({"content-type":" "},s),data:c.readFileSync(i),timeout:e._timeout,success:function(t){var e={statusCode:t.statusCode,data:t.data||{}};200===t.statusCode&&(null==a?void 0:a.success_action_status)&&(e.statusCode=parseInt(a.success_action_status,10)),o(e)},fail:function(t){o(t)},complete:function(t){if((null==t?void 0:t.errMsg)&&n._timeout&&-1!==n._restrictedMethods.indexOf("upload")&&"request:fail timeout"===t.errMsg){console.warn(n._timeoutMsg);try{u.abort()}catch(t){}}}})}))},V.default.genAdapter=function(t){return{root:{globalThis:{}},reqClass:V.WxRequest,wsClass:V.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,V.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",B(B({},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:V.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:""}}},V.default);Ut&&Lt.useAdapters(Ut);const Mt=Lt,qt=JSON.parse('{"i8":"3.5.5-beta.1"}');Mt.registerVersion(qt.i8);try{window.cloudbase=Mt}catch(t){}const Wt=Mt;var Vt=r.Z;export{Vt as default};
|
|
2
2
|
//# sourceMappingURL=index.esm.js.map
|