diff --git a/.editorconfig b/.editorconfig index d0d3054abae254775fd5c772f0c82ab370b11040..8da7b4b0dc1def84a8139b0caeb138150e4e2c54 100644 --- a/.editorconfig +++ b/.editorconfig @@ -7,11 +7,11 @@ root = true charset = utf-8 indent_style = space indent_size = 2 -end_of_line = lf +end_of_line = crlf insert_final_newline = true trim_trailing_whitespace = true # md files [*.md] insert_final_newline = false -trim_trailing_whitespace = false \ No newline at end of file +trim_trailing_whitespace = false diff --git a/.eslintignore b/.eslintignore index 33e9646869202319d7b33aec1cd1d10d13fe68a8..c51ed8fb31773d51f7a770c0c76f06c62de69cde 100644 --- a/.eslintignore +++ b/.eslintignore @@ -39,4 +39,5 @@ uni-polyfill.js packages/uni-cli-shared/components/ad-fullscreen-video.vue packages/uni-cli-shared/components/ad-interactive.vue packages/uni-cli-shared/components/ad-interstitial.vue -packages/uni-cli-shared/components/ad-rewarded-video.vue +packages/uni-cli-shared/components/ad-rewarded-video.vue +packages/uni-cli-shared/lib/uni_modules/uni_modules.js diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 26d8e69a1eaef5454985990a8c37e82260a95ced..e1ab5218db9104dd9522d46e12c4b6217ecda774 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -46,6 +46,8 @@ * build:编译脚本 * lib:其他编译依赖 + * apis.js 参与编译的接口列表 + * modules.json 摇树优化接口类别划分 * dist:其他编译后的文件 * docs:~~文档目录~~ ,现已迁移 * examples:~~示例目录~~,现已迁移 @@ -97,6 +99,8 @@ * assets:静态资源 * core:运行时公共部分 * helpers + * i18n:国际化资源文件 + * protocol:App、H5 平台接口通用校验 * runtime * service:逻辑层(App、H5) * api:uni 接口实现(App、H5 平台公共部分) diff --git a/.gitignore b/.gitignore index 83c062940cdde775767686824e44aa43259fe60e..345b6512c2e3e162b51b25bf2f861e1a11972ef9 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ unpackage/ package-lock.json !packages/vue-cli-plugin-uni/packages/**/* tests/package.json +*.DS_Store diff --git a/README.md b/README.md index 9fc79cb4139119c71bdcf0607204b95326249398..ac60047618b456b6a4f8cc93eeab5ef3f788f5b4 100644 --- a/README.md +++ b/README.md @@ -20,10 +20,10 @@ ## 扫码体验 -开发一次,编译到11个平台。依次扫描11个二维码,亲自体验最全面的跨平台效果! +开发一次,编译到14个平台。依次扫描14个二维码,亲自体验最全面的跨平台效果!
- +
*注: 某些平台不能提交简单demo,补充了一些其他功能。* diff --git a/build/manifest.js b/build/manifest.js index e60c7693628a61aea731456a9c08497184d8a9b0..d757622b43aaa5823f74efe9523e4b6628b2af22 100644 --- a/build/manifest.js +++ b/build/manifest.js @@ -46,7 +46,14 @@ const DEPS = { ['/core/view/components/swiper-item/index.vue', 'SwiperItem'], ['/core/view/components/movable-area/index.vue', 'MovableArea'], ['/core/view/components/movable-view/index.vue', 'MovableView'], - ['/platforms/h5/components/system-routes/preview-image/index.vue', 'PreviewImage'] + [ + '/platforms/h5/components/app/popup/preview-image/index.vue', + 'PreviewImage' + ], + [ + '/platforms/h5/components/app/popup/mixins/preview-image.js', + 'PreviewImageMixin' + ] ], showToast: TOAST_DEPS, hideToast: TOAST_DEPS, diff --git a/lib/apis.js b/lib/apis.js index 867e7e3ad47a6ebfc7cd078fc9528ae99ff414b1..34bd0e0a84fbe118ed3b53c139d40733a82fc155 100644 --- a/lib/apis.js +++ b/lib/apis.js @@ -46,7 +46,13 @@ const location = [ 'getLocation', 'chooseLocation', 'openLocation', - 'createMapContext' + 'createMapContext', + 'onLocationChange', + 'onLocationChangeError', + 'startLocationUpdate', + 'stopLocationUpdate', + 'offLocationChange', + 'offLocationChangeError' ] const media = [ diff --git a/lib/modules.json b/lib/modules.json index 2386842b81dc019e735e8e810b727f86995fc9ca..ab21d5f5f2cdb5648c4b066476e87c9c87744553 100644 --- a/lib/modules.json +++ b/lib/modules.json @@ -48,7 +48,13 @@ "apiList": { "uni.getLocation": true, "uni.openLocation": true, - "uni.chooseLocation": true + "uni.chooseLocation": true, + "uni.onLocationChange": true, + "uni.onLocationChangeError": true, + "uni.startLocationUpdate": true, + "uni.stopLocationUpdate": true, + "uni.offLocationChange": true, + "uni.offLocationChangeError": true } }, { "name": "media", @@ -225,7 +231,7 @@ "apiList": { "uni.createRewardedVideoAd": true, "uni.createFullScreenVideoAd": true, - "uni.'createInterstitialAd'": true, + "uni.'createInterstitialAd'": true, "uni.'createInteractiveAd'": true } }] diff --git a/package.json b/package.json index 6e098f2b2cc109f15fcb579fe7f9a3b8b9a9e7fd..e3eb922440f06dc9d3b2dc398174c3e7c8431471 100644 --- a/package.json +++ b/package.json @@ -116,6 +116,7 @@ "my": true, "swan": true, "tt": true, + "ks": true, "qh": true, "qa": true, "xhs": true, diff --git a/packages/uni-app-plus/template/common/__uniapppicker.js b/packages/uni-app-plus/template/common/__uniapppicker.js index ac4e48c0d0107330959a7657b752588189cd2907..29c7a016e0136583da537c4558c6e8d6ebdcff9e 100644 --- a/packages/uni-app-plus/template/common/__uniapppicker.js +++ b/packages/uni-app-plus/template/common/__uniapppicker.js @@ -1 +1 @@ -!function(e){var t={};function n(a){if(t[a])return t[a].exports;var r=t[a]={i:a,l:!1,exports:{}};return e[a].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,a){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(n.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(a,r,function(t){return e[t]}.bind(null,r));return a},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=44)}([function(e,t){e.exports={}},function(e,t,n){"use strict";function a(e,t,n,a,r,i,o,s,u,c){var l,f="function"==typeof e?e.options:e;if(u){f.components||(f.components={});var d=Object.prototype.hasOwnProperty;for(var p in u)d.call(u,p)&&!d.call(f.components,p)&&(f.components[p]=u[p])}if(c&&((c.beforeCreate||(c.beforeCreate=[])).unshift((function(){this[c.__module]=this})),(f.mixins||(f.mixins=[])).push(c)),t&&(f.render=t,f.staticRenderFns=n,f._compiled=!0),a&&(f.functional=!0),i&&(f._scopeId="data-v-"+i),o?(l=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),r&&r.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(o)},f._ssrRegister=l):r&&(l=s?function(){r.call(this,this.$root.$options.shadowRoot)}:r),l)if(f.functional){f._injectStyles=l;var h=f.render;f.render=function(e,t){return l.call(t),h(e,t)}}else{var v=f.beforeCreate;f.beforeCreate=v?[].concat(v,l):[l]}return{exports:e,options:f}}n.d(t,"a",(function(){return a}))},function(e,t,n){"use strict";var a;Object.defineProperty(t,"__esModule",{value:!0}),t.weexPlus=t.default=void 0,a="function"==typeof getUni?getUni:function(){var e=function(e){return"function"==typeof e},t=function(e){return e.then((function(e){return[null,e]})).catch((function(e){return[e]}))},n=/^\$|^on|^create|Sync$|Manager$|^pause/,a=["os","getCurrentSubNVue","getSubNVueById","stopRecord","stopVoice","stopBackgroundAudio","stopPullDownRefresh","hideKeyboard","hideToast","hideLoading","showNavigationBarLoading","hideNavigationBarLoading","canIUse","navigateBack","closeSocket","pageScrollTo","drawCanvas"],i=function(e){return(!n.test(e)||"createBLEConnection"===e)&&!~a.indexOf(e)},o=function(n){return function(){for(var a=arguments.length,r=Array(a>1?a-1:0),i=1;i0&&void 0!==arguments[0]?arguments[0]:{};return e(o.success)||e(o.fail)||e(o.complete)?n.apply(void 0,[o].concat(r)):t(new Promise((function(e,t){n.apply(void 0,[Object.assign({},o,{success:e,fail:t})].concat(r)),Promise.prototype.finally=function(e){var t=this.constructor;return this.then((function(n){return t.resolve(e()).then((function(){return n}))}),(function(n){return t.resolve(e()).then((function(){throw n}))}))}})))}},s=[],u=void 0;function c(e){s.forEach((function(t){return t({origin:u,data:e})}))}var l=r.webview.currentWebview().id,f=new BroadcastChannel("UNI-APP-SUBNVUE");function d(e){var t=r.webview.getWebviewById(e);return t&&!t.$processed&&function(e){e.$processed=!0;var t=r.webview.currentWebview().id===e.id,n="uniNView"===e.__uniapp_origin_type&&e.__uniapp_origin_id,a=e.id;if(e.postMessage=function(e){n?f.postMessage({data:e,to:t?n:a}):_({type:"UniAppSubNVue",data:e})},e.onMessage=function(e){s.push(e)},e.__uniapp_mask_id){u=e.__uniapp_host;var i=e.__uniapp_mask,o=r.webview.getWebviewById(e.__uniapp_mask_id);o=o.parent()||o;var c=e.show,l=e.hide,d=e.close,p=function(){o.setStyle({mask:i})},h=function(){o.setStyle({mask:"none"})};e.show=function(){p();for(var t=arguments.length,n=Array(t),a=0;a1&&void 0!==arguments[1]?arguments[1]:"GET",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"application/x-www-form-urlencoded";return"object"===(void 0===e?"undefined":L(e))?"POST"===t.toUpperCase()&&"application/json"===n.toLowerCase()?JSON.stringify(e):Object.keys(e).map((function(t){return encodeURIComponent(t)+"="+encodeURIComponent(e[t])})).join("&"):e},D=weex.requireModule("plusstorage"),$=weex.requireModule("clipboard"),B=function(){if("function"==typeof getUniEmitter)return getUniEmitter;var e={$on:function(){console.warn("uni.$on failed")},$off:function(){console.warn("uni.$off failed")},$once:function(){console.warn("uni.$once failed")},$emit:function(){console.warn("uni.$emit failed")}};return function(){return e}}();function R(e,t,n){return e[t].apply(e,n)}var U=Object.freeze({loadFontFace:function(t){var n=t.family,a=t.source,r=(t.desc,t.success),i=(t.fail,t.complete);I.addRule("fontFace",{fontFamily:n,src:a.replace(/"/g,"'")});var o={errMsg:"loadFontFace:ok",status:"loaded"};e(r)&&r(o),e(i)&&i(o)},ready:V,request:function(t){var n=t.url,a=t.data,r=t.header,i=t.method,o=void 0===i?"GET":i,s=t.dataType,u=void 0===s?"json":s,c=(t.responseType,t.success),l=t.fail,f=t.complete,d=!1,p=!1,h={};if(r)for(var v in r)p||"content-type"!==v.toLowerCase()?h[v]=r[v]:(p=!0,h["Content-Type"]=r[v]);return"GET"===o&&a&&(n=n+(~n.indexOf("?")?"&"===n.substr(-1)||"?"===n.substr(-1)?"":"&":"?")+P(a)),j.fetch({url:n,method:o,headers:h,type:"json"===u?"json":"text",body:"GET"!==o?P(a,o,h["Content-Type"]):""},(function(t){var n=t.status,a=(t.ok,t.statusText,t.data),r=t.headers,i={};!n||-1===n||d?(i.errMsg="request:fail",e(l)&&l(i)):(i.data=a,i.statusCode=n,i.header=r,e(c)&&c(i)),e(f)&&f(i)})),{abort:function(){d=!0}}},getStorage:function(t){var n=t.key,a=(t.data,t.success),r=t.fail,i=t.complete;D.getItem(n+"__TYPE",(function(t){if("success"===t.result){var o=t.data;D.getItem(n,(function(t){if("success"===t.result){var n=t.data;o&&n?("String"!==o&&(n=JSON.parse(n)),e(a)&&a({errMsg:"getStorage:ok",data:n})):(t.errMsg="setStorage:fail",e(r)&&r(t))}else t.errMsg="setStorage:fail",e(r)&&r(t);e(i)&&i(t)}))}else t.errMsg="setStorage:fail",e(r)&&r(t),e(i)&&i(t)}))},setStorage:function(t){var n=t.key,a=t.data,r=t.success,i=t.fail,o=t.complete,s="String";"object"===(void 0===a?"undefined":L(a))&&(s="Object",a=JSON.stringify(a)),D.setItem(n,a,(function(t){"success"===t.result?D.setItem(n+"__TYPE",s,(function(t){"success"===t.result?e(r)&&r({errMsg:"setStorage:ok"}):(t.errMsg="setStorage:fail",e(i)&&i(t))})):(t.errMsg="setStorage:fail",e(i)&&i(t)),e(o)&&o(t)}))},removeStorage:function(t){var n=t.key,a=(t.data,t.success),r=t.fail,i=t.complete;D.removeItem(n,(function(t){"success"===t.result?e(a)&&a({errMsg:"removeStorage:ok"}):(t.errMsg="removeStorage:fail",e(r)&&r(t)),e(i)&&i(t)})),D.removeItem(n+"__TYPE")},clearStorage:function(e){e.key,e.data,e.success,e.fail,e.complete},getClipboardData:function(t){var n=t.success,a=(t.fail,t.complete);$.getString((function(t){var r={errMsg:"getClipboardData:ok",data:t.data};e(n)&&n(r),e(a)&&a(r)}))},setClipboardData:function(t){var n=t.data,a=t.success,r=(t.fail,t.complete),i={errMsg:"setClipboardData:ok"};$.setString(n),e(a)&&a(i),e(r)&&r(i)},onSubNVueMessage:c,getSubNVueById:d,getCurrentSubNVue:function(){return d(r.webview.currentWebview().id)},$on:function(){return R(B(),"$on",[].concat(Array.prototype.slice.call(arguments)))},$off:function(){return R(B(),"$off",[].concat(Array.prototype.slice.call(arguments)))},$once:function(){return R(B(),"$once",[].concat(Array.prototype.slice.call(arguments)))},$emit:function(){return R(B(),"$emit",[].concat(Array.prototype.slice.call(arguments)))}}),z={os:{nvue:!0}},F={};return"undefined"!=typeof Proxy?F=new Proxy({},{get:function(e,t){if("os"===t)return{nvue:!0};if("postMessage"===t)return _;if("requireNativePlugin"===t)return x;if("onNavigationBarButtonTap"===t)return k;if("onNavigationBarSearchInputChanged"===t)return M;if("onNavigationBarSearchInputConfirmed"===t)return E;if("onNavigationBarSearchInputClicked"===t)return C;var n=U[t];return n||(n=b(t)),i(t)?o(n):n}}):(Object.keys(z).forEach((function(e){F[e]=z[e]})),F.postMessage=_,F.requireNativePlugin=x,F.onNavigationBarButtonTap=k,F.onNavigationBarSearchInputChanged=M,F.onNavigationBarSearchInputConfirmed=E,F.onNavigationBarSearchInputClicked=C,Object.keys({uploadFile:!0,downloadFile:!0,chooseImage:!0,previewImage:!0,getImageInfo:!0,saveImageToPhotosAlbum:!0,chooseVideo:!0,saveVideoToPhotosAlbum:!0,saveFile:!0,getSavedFileList:!0,getSavedFileInfo:!0,removeSavedFile:!0,openDocument:!0,setStorage:!0,getStorage:!0,getStorageInfo:!0,removeStorage:!0,clearStorage:!0,getLocation:!0,chooseLocation:!0,openLocation:!0,getSystemInfo:!0,getNetworkType:!0,makePhoneCall:!0,scanCode:!0,setScreenBrightness:!0,getScreenBrightness:!0,setKeepScreenOn:!0,vibrateLong:!0,vibrateShort:!0,addPhoneContact:!0,showToast:!0,showLoading:!0,hideToast:!0,hideLoading:!0,showModal:!0,showActionSheet:!0,setNavigationBarTitle:!0,setNavigationBarColor:!0,navigateTo:!0,redirectTo:!0,reLaunch:!0,switchTab:!0,navigateBack:!0,getProvider:!0,login:!0,getUserInfo:!0,share:!0,requestPayment:!0,subscribePush:!0,unsubscribePush:!0,onPush:!0,offPush:!0}).forEach((function(e){var t=U[e];t||(t=b(e)),i(e)?F[e]=o(t):F[e]=t}))),F};var r=new WeexPlus(weex);t.weexPlus=r;var i=a(weex,r,BroadcastChannel);t.default=i},function(e,t,n){Vue.prototype.__$appStyle__={},Vue.prototype.__merge_style&&Vue.prototype.__merge_style(n(4).default,Vue.prototype.__$appStyle__)},function(e,t,n){"use strict";n.r(t);var a=n(0),r=n.n(a);for(var i in a)"default"!==i&&function(e){n.d(t,e,(function(){return a[e]}))}(i);t.default=r.a},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n={onLoad:function(){this.initMessage()},methods:{initMessage:function(){var t=this,n=e.webview.currentWebview().extras||{},a=n.from,r=(n.callback,n.runtime),i=n.data,o=void 0===i?{}:i,s=n.useGlobalEvent;this.__from=a,this.__runtime=r,this.__page=e.webview.currentWebview().id,this.__useGlobalEvent=s,this.data=JSON.parse(JSON.stringify(o)),e.key.addEventListener("backbutton",(function(){"function"==typeof t.onClose?t.onClose():e.webview.currentWebview().close("auto")}));var u=this,c=function(e){var t=e.data&&e.data.__message;t&&u.__onMessageCallback&&u.__onMessageCallback(t.data)};this.__useGlobalEvent?weex.requireModule("globalEvent").addEventListener("plusMessage",c):new BroadcastChannel(this.__page).onmessage=c},postMessage:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],a=JSON.parse(JSON.stringify({__message:{__page:this.__page,data:t,keep:n}})),r=this.__from;if("v8"===this.__runtime)if(this.__useGlobalEvent)e.webview.postMessageToUniNView(a,r);else{var i=new BroadcastChannel(r);i.postMessage(a)}else{var o=e.webview.getWebviewById(r);o&&o.evalJS("__plusMessage&&__plusMessage(".concat(JSON.stringify({data:a}),")"))}},onMessage:function(e){this.__onMessageCallback=e}}};t.default=n}).call(this,n(2).weexPlus)},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n={data:function(){return{locale:"en",fallbackLocale:"en",localization:{en:{done:"OK",cancel:"Cancel"},zh:{done:"完成",cancel:"取消"},"zh-hans":{},"zh-hant":{},messages:{}}}},onLoad:function(){this.initLocale()},created:function(){this.initLocale()},methods:{initLocale:function(){if(!this.__initLocale){this.__initLocale=!0;var t=(e.webview.currentWebview().extras||{}).data||{};if(t.messages&&(this.localization.messages=t.messages),t.locale)this.locale=t.locale.toLowerCase();else{var n=e.os.language.toLowerCase().split("/")[0].replace("_","-").split("-"),a=n[1];a&&(n[1]={chs:"hans",cn:"hans",sg:"hans",cht:"hant",tw:"hant",hk:"hant",mo:"hant"}[a]||a),n.length=n.length>2?2:n.length,this.locale=n.join("-")}}},localize:function(e){var t=this.locale,n=t.split("-")[0],a=this.fallbackLocale,r=this.localization;function i(e){return r[e]||{}}return i("messages")[e]||i(t)[e]||i(n)[e]||i(a)[e]||e}}};t.default=n}).call(this,n(2).weexPlus)},,,,function(e,t,n){"use strict";var a=n(31),r=n(21),i=n(1);var o=Object(i.a)(r.default,a.b,a.c,!1,null,null,"ff831df6",!1,a.a,void 0);(function(e){this.options.style||(this.options.style={}),Vue.prototype.__merge_style&&Vue.prototype.__$appStyle__&&Vue.prototype.__merge_style(Vue.prototype.__$appStyle__,this.options.style),Vue.prototype.__merge_style?Vue.prototype.__merge_style(n(40).default,this.options.style):Object.assign(this.options.style,n(40).default)}).call(o),t.default=o.exports},,,,,,,,,,,function(e,t,n){"use strict";var a=n(22),r=n.n(a);t.default=r.a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var a=r(n(45));function r(e){return e&&e.__esModule?e:{default:e}}var i={mixins:[r(n(5)).default],components:{picker:a.default},data:function(){return{range:[],rangeKey:"",value:0,mode:"selector",fields:"day",start:"",end:"",disabled:!1,visible:!1}},onLoad:function(){var e=this;null===this.data?this.postMessage({event:"created"},!0):this.showPicker(this.data),this.onMessage((function(t){e.showPicker(t)}))},onReady:function(){var e=this;this.$nextTick((function(){e.visible=!0}))},methods:{showPicker:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.column;for(var n in e)"column"!==n&&("number"==typeof t?this.$set(this.$data[n],t,e[n]):this.$data[n]=e[n])},close:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=n.value,r=void 0===a?-1:a;this.visible=!1,setTimeout((function(){t.postMessage({event:e,value:r})}),210)},onClose:function(){this.close("cancel")},columnchange:function(e){var t=e.column,n=e.value;Array.isArray(this.value)&&this.$set(this.value,t,n),this.postMessage({event:"columnchange",column:t,value:n},!0)}}};t.default=i},function(e,t,n){"use strict";n.r(t);var a=n(24),r=n.n(a);for(var i in a)"default"!==i&&function(e){n.d(t,e,(function(){return a[e]}))}(i);t.default=r.a},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var a=n(46),r=o(n(6)),i=o(n(47));function o(e){return e&&e.__esModule?e:{default:e}}function s(e){return function(e){if(Array.isArray(e))return u(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return u(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return u(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=new Array(t);nn(i)&&this._cloneArray(a,i)}e.forEach((function(e,n){e!==t.oldValueArray[n]&&(t.oldValueArray[n]=e,t.mode===d.MULTISELECTOR&&t.$emit("columnchange",{column:n,value:e}))}))},visible:function(e){var t=this;e?setTimeout((function(){f.transition(t.$refs.picker,{styles:{transform:"translateY(0)"},duration:200})}),20):f.transition(this.$refs.picker,{styles:{transform:"translateY(".concat(283+this.safeAreaInsets.bottom,"px)")},duration:200})}},created:function(){this._createTime(),this._createDate(),this._setValueSync(),e.webview.currentWebview().picker=this},methods:{getTexts:function(e,t){var n=this,a=this.textMaxLength;return e.map((function(e){var r=String("object"==typeof e?e[n.rangeKey]||"":n._l10nItem(e,t));if(a>0&&r.length>a)for(var i=0,o=0,s=0;s127||94===u?1:.65)<=a-1&&(o=s),i>=a)return s===r.length-1?r:r.substr(0,o+1)+"…"}return r||" "})).join("\n")},_createTime:function(){var e=[],t=[];e.splice(0,e.length);for(var n=0;n<24;n++)e.push((n<10?"0":"")+n);t.splice(0,t.length);for(var a=0;a<60;a++)t.push((a<10?"0":"")+a);this.timeArray.push(e,t)},_createDate:function(){for(var e=[],t=(new Date).getFullYear(),n=t-61,a=t+61;n<=a;n++)e.push(String(n));for(var r=[],i=1;i<=12;i++)r.push((i<10?"0":"")+i);for(var o=[],s=1;s<=31;s++)o.push((s<10?"0":"")+s);this.dateArray.push(e,r,o)},_getTimeValue:function(e){return 60*e[0]+e[1]},_getDateValue:function(e){return 31*e[0]*12+31*(e[1]||0)+(e[2]||0)},_cloneArray:function(e,t){for(var n=0;no?0:i)}break;case d.TIME:case d.DATE:this.valueSync=String(e);break;default:var s=Number(e);this.valueSync=s<0?0:s}},_setValueArray:function(){var e,t=this.valueSync;switch(this.mode){case d.MULTISELECTOR:e=s(t);break;case d.TIME:e=this._getDateValueArray(t,(0,a.formatDateTime)({mode:d.TIME}));break;case d.DATE:e=this._getDateValueArray(t,(0,a.formatDateTime)({mode:d.DATE}));break;default:e=[t]}this.oldValueArray=s(e),this.valueArray=s(e)},_getValue:function(){var e=this,t=this.valueArray;switch(this.mode){case d.SELECTOR:return t[0];case d.MULTISELECTOR:return t.map((function(e){return e}));case d.TIME:return this.valueArray.map((function(t,n){return e.timeArray[n][t]})).join(":");case d.DATE:return this.valueArray.map((function(t,n){return e.dateArray[n][t]})).join("-")}},_getDateValueArray:function(e,t){var n=this.mode===d.DATE?"-":":",a=this.mode===d.DATE?this.dateArray:this.timeArray,r=3;switch(this.fields){case p.YEAR:r=1;break;case p.MONTH:r=2}for(var i=String(e).split(n),o=[],s=0;s=0&&(o=t?this._getDateValueArray(t):o.map((function(){return 0}))),o},_change:function(){this.$emit("change",{value:this._getValue()})},_cancel:function(){this.$emit("cancel")},_pickerViewChange:function(e){this.valueArray=this._l10nColumn(e.detail.value,!0)},_l10nColumn:function(e,t){if(this.mode===d.DATE){var n=this.locale;if(!n.startsWith("zh"))switch(this.fields){case p.YEAR:return e;case p.MONTH:return[e[1],e[0]];default:switch(n){case"es":case"fr":return[e[2],e[1],e[0]];default:return t?[e[2],e[0],e[1]]:[e[1],e[2],e[0]]}}}return e},_l10nItem:function(e,t){if(this.mode===d.DATE){var n=this.locale;if(n.startsWith("zh")){return e+["年","月","日"][t]}if(this.fields!==p.YEAR&&t===(this.fields===p.MONTH||"es"!==n&&"fr"!==n?0:1)){var a;switch(n){case"es":a=["enero","febrero","marzo","abril","mayo","junio","​​julio","agosto","septiembre","octubre","noviembre","diciembre"];break;case"fr":a=["janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre"];break;default:a=["January","February","March","April","May","June","July","August","September","October","November","December"]}return a[Number(e)-1]}}return e}}};t.default=h}).call(this,n(2).weexPlus)},function(e,t){e.exports={content:{position:"absolute",top:0,left:0,bottom:0,right:0},"uni-mask":{position:"absolute",top:0,left:0,bottom:0,right:0,backgroundColor:"rgba(0,0,0,0.4)",opacity:0,transitionProperty:"opacity",transitionDuration:200,transitionTimingFunction:"linear"},"@TRANSITION":{"uni-mask":{property:"opacity",duration:200,timingFunction:"linear"}},"uni-mask-android":{backgroundColor:"rgba(0,0,0,0.6)"},"uni-mask-visible":{opacity:1},"uni-picker":{position:"absolute",left:0,bottom:0,right:0,backgroundColor:"#ffffff",color:"#000000",flexDirection:"column",transform:"translateY(295px)"},"uni-picker-header":{height:"45",borderBottomWidth:0,backgroundColor:"#E6E6E6",fontSize:"20"},"uni-picker-action":{position:"absolute",textAlign:"center",top:0,height:"45",paddingTop:0,paddingRight:"14",paddingBottom:0,paddingLeft:"14",fontSize:"17",lineHeight:"45"},"uni-picker-action-cancel":{left:0,color:"#888888"},"uni-picker-action-confirm":{right:0,color:"#007aff"},"uni-picker-content":{flex:1},"uni-picker-item":{lineHeight:"34",textAlign:"center",color:"#000000"}}},function(e,t){e.exports={page:{flex:1}}},,,,,function(e,t,n){"use strict";var a=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("scroll-view",{staticStyle:{flexDirection:"column"},attrs:{scrollY:!0,enableBackToTop:!0,bubble:"true"}},[n("view",{staticClass:["page"]},[n("picker",{attrs:{range:e.range,rangeKey:e.rangeKey,value:e.value,mode:e.mode,fields:e.fields,start:e.start,end:e.end,disabled:e.disabled,visible:e.visible},on:{change:function(t){e.close("change",t)},cancel:function(t){e.close("cancel",t)},columnchange:e.columnchange}})],1)])},r=[];n.d(t,"b",(function(){return a})),n.d(t,"c",(function(){return r})),n.d(t,"a",(function(){}))},,,function(e,t,n){"use strict";var a=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:["content"]},[n("div",{ref:"mask",staticClass:["uni-mask"],class:{"uni-mask-visible":e.visible,"uni-mask-android":e.android},on:{click:e._cancel}}),n("div",{ref:"picker",staticClass:["uni-picker"],class:{"uni-picker-visible":e.visible},style:"padding-bottom:"+e.safeAreaInsets.bottom+"px;height:"+(e.height+e.safeAreaInsets.bottom)+"px;"},[n("div",{staticClass:["uni-picker-header"]},[n("u-text",{staticClass:["uni-picker-action","uni-picker-action-cancel"],style:"left:"+e.safeAreaInsets.left+"px",on:{click:e._cancel}},[e._v(e._s(e.localize("cancel")))]),n("u-text",{staticClass:["uni-picker-action","uni-picker-action-confirm"],style:"right:"+e.safeAreaInsets.right+"px",on:{click:e._change}},[e._v(e._s(e.localize("done")))])]),e.visible?n("picker-view",{staticClass:["uni-picker-content"],style:"margin-left:"+e.safeAreaInsets.left+"px",attrs:{height:"216",indicatorStyle:"height: 34px;border-color:#C8C9C9;border-top-width:0.5px;border-bottom-width:0.5px;",value:e._l10nColumn(e.valueArray)},on:{change:e._pickerViewChange}},e._l(e._l10nColumn(e.rangeArray),(function(t,a){return n("picker-view-column",{key:a,attrs:{length:t.length}},[n("u-text",{staticClass:["uni-picker-item"],style:{fontSize:e.fontSize+"px"}},[e._v(e._s(e.getTexts(t,a)))])])})),1):e._e()],1)])},r=[];n.d(t,"b",(function(){return a})),n.d(t,"c",(function(){return r})),n.d(t,"a",(function(){}))},,,,,function(e,t,n){"use strict";n.r(t);var a=n(25),r=n.n(a);for(var i in a)"default"!==i&&function(e){n.d(t,e,(function(){return a[e]}))}(i);t.default=r.a},function(e,t,n){"use strict";n.r(t);var a=n(26),r=n.n(a);for(var i in a)"default"!==i&&function(e){n.d(t,e,(function(){return a[e]}))}(i);t.default=r.a},,,,function(e,t,n){"use strict";n.r(t);n(3);var a=n(10);a.default.mpType="page",a.default.route="template/__uniapppicker",a.default.el="#root",new Vue(a.default)},function(e,t,n){"use strict";n.r(t);var a=n(34),r=n(23);for(var i in r)"default"!==i&&function(e){n.d(t,e,(function(){return r[e]}))}(i);var o=n(1);var s=Object(o.a)(r.default,a.b,a.c,!1,null,null,"980cd0c2",!1,a.a,void 0);(function(e){this.options.style||(this.options.style={}),Vue.prototype.__merge_style&&Vue.prototype.__$appStyle__&&Vue.prototype.__merge_style(Vue.prototype.__$appStyle__,this.options.style),Vue.prototype.__merge_style?Vue.prototype.__merge_style(n(39).default,this.options.style):Object.assign(this.options.style,n(39).default)}).call(s),t.default=s.exports},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.formatDateTime=function(e){var t=e.date,n=void 0===t?new Date:t,r=e.mode;return"time"===(void 0===r?"date":r)?a(n.getHours())+":"+a(n.getMinutes()):n.getFullYear()+"-"+a(n.getMonth()+1)+"-"+a(n.getDate())};var a=function(e){return e>9?e:"0"+e}},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n={data:function(){return{safeAreaInsets:{left:0,right:0,top:0,bottom:0}}},onLoad:function(){this.initSafeAreaInsets()},created:function(){this.initSafeAreaInsets()},methods:{initSafeAreaInsets:function(){var t=this;if(!this.__initSafeAreaInsets){this.__initSafeAreaInsets=!0;var n=e.webview.currentWebview();n.addEventListener("resize",(function(){setTimeout((function(){t.updateSafeAreaInsets(n)}),20)})),this.updateSafeAreaInsets(n)}},updateSafeAreaInsets:function(e){var t=e.getSafeAreaInsets(),n=this.safeAreaInsets;Object.keys(n).forEach((function(e){n[e]=t[e]}))}}};t.default=n}).call(this,n(2).weexPlus)}]); \ No newline at end of file +!function(e){var t={};function n(a){if(t[a])return t[a].exports;var r=t[a]={i:a,l:!1,exports:{}};return e[a].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,a){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(n.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(a,r,function(t){return e[t]}.bind(null,r));return a},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=44)}([function(e,t){e.exports={}},function(e,t,n){"use strict";function a(e,t,n,a,r,i,o,s,u,c){var l,f="function"==typeof e?e.options:e;if(u){f.components||(f.components={});var d=Object.prototype.hasOwnProperty;for(var p in u)d.call(u,p)&&!d.call(f.components,p)&&(f.components[p]=u[p])}if(c&&((c.beforeCreate||(c.beforeCreate=[])).unshift((function(){this[c.__module]=this})),(f.mixins||(f.mixins=[])).push(c)),t&&(f.render=t,f.staticRenderFns=n,f._compiled=!0),a&&(f.functional=!0),i&&(f._scopeId="data-v-"+i),o?(l=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),r&&r.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(o)},f._ssrRegister=l):r&&(l=s?function(){r.call(this,this.$root.$options.shadowRoot)}:r),l)if(f.functional){f._injectStyles=l;var h=f.render;f.render=function(e,t){return l.call(t),h(e,t)}}else{var v=f.beforeCreate;f.beforeCreate=v?[].concat(v,l):[l]}return{exports:e,options:f}}n.d(t,"a",(function(){return a}))},function(e,t,n){"use strict";var a;Object.defineProperty(t,"__esModule",{value:!0}),t.weexPlus=t.default=void 0,a="function"==typeof getUni?getUni:function(){var e=function(e){return"function"==typeof e},t=function(e){return e.then((function(e){return[null,e]})).catch((function(e){return[e]}))},n=/^\$|^on|^create|Sync$|Manager$|^pause/,a=["os","getCurrentSubNVue","getSubNVueById","stopRecord","stopVoice","stopBackgroundAudio","stopPullDownRefresh","hideKeyboard","hideToast","hideLoading","showNavigationBarLoading","hideNavigationBarLoading","canIUse","navigateBack","closeSocket","pageScrollTo","drawCanvas"],i=function(e){return(!n.test(e)||"createBLEConnection"===e)&&!~a.indexOf(e)},o=function(n){return function(){for(var a=arguments.length,r=Array(a>1?a-1:0),i=1;i0&&void 0!==arguments[0]?arguments[0]:{};return e(o.success)||e(o.fail)||e(o.complete)?n.apply(void 0,[o].concat(r)):t(new Promise((function(e,t){n.apply(void 0,[Object.assign({},o,{success:e,fail:t})].concat(r)),Promise.prototype.finally=function(e){var t=this.constructor;return this.then((function(n){return t.resolve(e()).then((function(){return n}))}),(function(n){return t.resolve(e()).then((function(){throw n}))}))}})))}},s=[],u=void 0;function c(e){s.forEach((function(t){return t({origin:u,data:e})}))}var l=r.webview.currentWebview().id,f=new BroadcastChannel("UNI-APP-SUBNVUE");function d(e){var t=r.webview.getWebviewById(e);return t&&!t.$processed&&function(e){e.$processed=!0;var t=r.webview.currentWebview().id===e.id,n="uniNView"===e.__uniapp_origin_type&&e.__uniapp_origin_id,a=e.id;if(e.postMessage=function(e){n?f.postMessage({data:e,to:t?n:a}):_({type:"UniAppSubNVue",data:e})},e.onMessage=function(e){s.push(e)},e.__uniapp_mask_id){u=e.__uniapp_host;var i=e.__uniapp_mask,o=r.webview.getWebviewById(e.__uniapp_mask_id);o=o.parent()||o;var c=e.show,l=e.hide,d=e.close,p=function(){o.setStyle({mask:i})},h=function(){o.setStyle({mask:"none"})};e.show=function(){p();for(var t=arguments.length,n=Array(t),a=0;a1&&void 0!==arguments[1]?arguments[1]:"GET",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"application/x-www-form-urlencoded";return"object"===(void 0===e?"undefined":L(e))?"POST"===t.toUpperCase()&&"application/json"===n.toLowerCase()?JSON.stringify(e):Object.keys(e).map((function(t){return encodeURIComponent(t)+"="+encodeURIComponent(e[t])})).join("&"):e},P=weex.requireModule("plusstorage"),$=weex.requireModule("clipboard"),B=function(){if("function"==typeof getUniEmitter)return getUniEmitter;var e={$on:function(){console.warn("uni.$on failed")},$off:function(){console.warn("uni.$off failed")},$once:function(){console.warn("uni.$once failed")},$emit:function(){console.warn("uni.$emit failed")}};return function(){return e}}();function R(e,t,n){return e[t].apply(e,n)}var U=Object.freeze({loadFontFace:function(t){var n=t.family,a=t.source,r=(t.desc,t.success),i=(t.fail,t.complete);I.addRule("fontFace",{fontFamily:n,src:a.replace(/"/g,"'")});var o={errMsg:"loadFontFace:ok",status:"loaded"};e(r)&&r(o),e(i)&&i(o)},ready:V,request:function(t){var n=t.url,a=t.data,r=t.header,i=t.method,o=void 0===i?"GET":i,s=t.dataType,u=void 0===s?"json":s,c=(t.responseType,t.success),l=t.fail,f=t.complete,d=!1,p=!1,h={};if(r)for(var v in r)p||"content-type"!==v.toLowerCase()?h[v]=r[v]:(p=!0,h["Content-Type"]=r[v]);return"GET"===o&&a&&(n=n+(~n.indexOf("?")?"&"===n.substr(-1)||"?"===n.substr(-1)?"":"&":"?")+D(a)),j.fetch({url:n,method:o,headers:h,type:"json"===u?"json":"text",body:"GET"!==o?D(a,o,h["Content-Type"]):""},(function(t){var n=t.status,a=(t.ok,t.statusText,t.data),r=t.headers,i={};!n||-1===n||d?(i.errMsg="request:fail",e(l)&&l(i)):(i.data=a,i.statusCode=n,i.header=r,e(c)&&c(i)),e(f)&&f(i)})),{abort:function(){d=!0}}},getStorage:function(t){var n=t.key,a=(t.data,t.success),r=t.fail,i=t.complete;P.getItem(n+"__TYPE",(function(t){if("success"===t.result){var o=t.data;P.getItem(n,(function(t){if("success"===t.result){var n=t.data;o&&n?("String"!==o&&(n=JSON.parse(n)),e(a)&&a({errMsg:"getStorage:ok",data:n})):(t.errMsg="setStorage:fail",e(r)&&r(t))}else t.errMsg="setStorage:fail",e(r)&&r(t);e(i)&&i(t)}))}else t.errMsg="setStorage:fail",e(r)&&r(t),e(i)&&i(t)}))},setStorage:function(t){var n=t.key,a=t.data,r=t.success,i=t.fail,o=t.complete,s="String";"object"===(void 0===a?"undefined":L(a))&&(s="Object",a=JSON.stringify(a)),P.setItem(n,a,(function(t){"success"===t.result?P.setItem(n+"__TYPE",s,(function(t){"success"===t.result?e(r)&&r({errMsg:"setStorage:ok"}):(t.errMsg="setStorage:fail",e(i)&&i(t))})):(t.errMsg="setStorage:fail",e(i)&&i(t)),e(o)&&o(t)}))},removeStorage:function(t){var n=t.key,a=(t.data,t.success),r=t.fail,i=t.complete;P.removeItem(n,(function(t){"success"===t.result?e(a)&&a({errMsg:"removeStorage:ok"}):(t.errMsg="removeStorage:fail",e(r)&&r(t)),e(i)&&i(t)})),P.removeItem(n+"__TYPE")},clearStorage:function(e){e.key,e.data,e.success,e.fail,e.complete},getClipboardData:function(t){var n=t.success,a=(t.fail,t.complete);$.getString((function(t){var r={errMsg:"getClipboardData:ok",data:t.data};e(n)&&n(r),e(a)&&a(r)}))},setClipboardData:function(t){var n=t.data,a=t.success,r=(t.fail,t.complete),i={errMsg:"setClipboardData:ok"};$.setString(n),e(a)&&a(i),e(r)&&r(i)},onSubNVueMessage:c,getSubNVueById:d,getCurrentSubNVue:function(){return d(r.webview.currentWebview().id)},$on:function(){return R(B(),"$on",[].concat(Array.prototype.slice.call(arguments)))},$off:function(){return R(B(),"$off",[].concat(Array.prototype.slice.call(arguments)))},$once:function(){return R(B(),"$once",[].concat(Array.prototype.slice.call(arguments)))},$emit:function(){return R(B(),"$emit",[].concat(Array.prototype.slice.call(arguments)))}}),z={os:{nvue:!0}},F={};return"undefined"!=typeof Proxy?F=new Proxy({},{get:function(e,t){if("os"===t)return{nvue:!0};if("postMessage"===t)return _;if("requireNativePlugin"===t)return x;if("onNavigationBarButtonTap"===t)return k;if("onNavigationBarSearchInputChanged"===t)return M;if("onNavigationBarSearchInputConfirmed"===t)return E;if("onNavigationBarSearchInputClicked"===t)return C;var n=U[t];return n||(n=b(t)),i(t)?o(n):n}}):(Object.keys(z).forEach((function(e){F[e]=z[e]})),F.postMessage=_,F.requireNativePlugin=x,F.onNavigationBarButtonTap=k,F.onNavigationBarSearchInputChanged=M,F.onNavigationBarSearchInputConfirmed=E,F.onNavigationBarSearchInputClicked=C,Object.keys({uploadFile:!0,downloadFile:!0,chooseImage:!0,previewImage:!0,getImageInfo:!0,saveImageToPhotosAlbum:!0,chooseVideo:!0,saveVideoToPhotosAlbum:!0,saveFile:!0,getSavedFileList:!0,getSavedFileInfo:!0,removeSavedFile:!0,openDocument:!0,setStorage:!0,getStorage:!0,getStorageInfo:!0,removeStorage:!0,clearStorage:!0,getLocation:!0,chooseLocation:!0,openLocation:!0,getSystemInfo:!0,getNetworkType:!0,makePhoneCall:!0,scanCode:!0,setScreenBrightness:!0,getScreenBrightness:!0,setKeepScreenOn:!0,vibrateLong:!0,vibrateShort:!0,addPhoneContact:!0,showToast:!0,showLoading:!0,hideToast:!0,hideLoading:!0,showModal:!0,showActionSheet:!0,setNavigationBarTitle:!0,setNavigationBarColor:!0,navigateTo:!0,redirectTo:!0,reLaunch:!0,switchTab:!0,navigateBack:!0,getProvider:!0,login:!0,getUserInfo:!0,share:!0,requestPayment:!0,subscribePush:!0,unsubscribePush:!0,onPush:!0,offPush:!0}).forEach((function(e){var t=U[e];t||(t=b(e)),i(e)?F[e]=o(t):F[e]=t}))),F};var r=new WeexPlus(weex);t.weexPlus=r;var i=a(weex,r,BroadcastChannel);t.default=i},function(e,t,n){Vue.prototype.__$appStyle__={},Vue.prototype.__merge_style&&Vue.prototype.__merge_style(n(4).default,Vue.prototype.__$appStyle__)},function(e,t,n){"use strict";n.r(t);var a=n(0),r=n.n(a);for(var i in a)"default"!==i&&function(e){n.d(t,e,(function(){return a[e]}))}(i);t.default=r.a},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n={onLoad:function(){this.initMessage()},methods:{initMessage:function(){var t=this,n=e.webview.currentWebview().extras||{},a=n.from,r=(n.callback,n.runtime),i=n.data,o=void 0===i?{}:i,s=n.useGlobalEvent;this.__from=a,this.__runtime=r,this.__page=e.webview.currentWebview().id,this.__useGlobalEvent=s,this.data=JSON.parse(JSON.stringify(o)),e.key.addEventListener("backbutton",(function(){"function"==typeof t.onClose?t.onClose():e.webview.currentWebview().close("auto")}));var u=this,c=function(e){var t=e.data&&e.data.__message;t&&u.__onMessageCallback&&u.__onMessageCallback(t.data)};this.__useGlobalEvent?weex.requireModule("globalEvent").addEventListener("plusMessage",c):new BroadcastChannel(this.__page).onmessage=c},postMessage:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],a=JSON.parse(JSON.stringify({__message:{__page:this.__page,data:t,keep:n}})),r=this.__from;if("v8"===this.__runtime)if(this.__useGlobalEvent)e.webview.postMessageToUniNView(a,r);else{var i=new BroadcastChannel(r);i.postMessage(a)}else{var o=e.webview.getWebviewById(r);o&&o.evalJS("__plusMessage&&__plusMessage(".concat(JSON.stringify({data:a}),")"))}},onMessage:function(e){this.__onMessageCallback=e}}};t.default=n}).call(this,n(2).weexPlus)},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n={data:function(){return{locale:"en",fallbackLocale:"en",localization:{en:{done:"OK",cancel:"Cancel"},zh:{done:"完成",cancel:"取消"},"zh-hans":{},"zh-hant":{},messages:{}},localizationTemplate:{}}},onLoad:function(){this.initLocale()},created:function(){this.initLocale()},methods:{initLocale:function(){if(!this.__initLocale){this.__initLocale=!0;var t=(e.webview.currentWebview().extras||{}).data||{};if(t.messages&&(this.localization.messages=t.messages),t.locale)this.locale=t.locale.toLowerCase();else{var n=e.os.language.toLowerCase().split("/")[0].replace("_","-").split("-"),a=n[1];a&&(n[1]={chs:"hans",cn:"hans",sg:"hans",cht:"hant",tw:"hant",hk:"hant",mo:"hant"}[a]||a),n.length=n.length>2?2:n.length,this.locale=n.join("-")}}},localize:function(e){var t=this,n=this.locale,a=n.split("-")[0],r=this.fallbackLocale,i=function(e){return Object.assign({},t.localization[e],(t.localizationTemplate||{})[e])};return i("messages")[e]||i(n)[e]||i(a)[e]||i(r)[e]||e}}};t.default=n}).call(this,n(2).weexPlus)},,,,function(e,t,n){"use strict";var a=n(31),r=n(21),i=n(1);var o=Object(i.a)(r.default,a.b,a.c,!1,null,null,"9abad300",!1,a.a,void 0);(function(e){this.options.style||(this.options.style={}),Vue.prototype.__merge_style&&Vue.prototype.__$appStyle__&&Vue.prototype.__merge_style(Vue.prototype.__$appStyle__,this.options.style),Vue.prototype.__merge_style?Vue.prototype.__merge_style(n(40).default,this.options.style):Object.assign(this.options.style,n(40).default)}).call(o),t.default=o.exports},,,,,,,,,,,function(e,t,n){"use strict";var a=n(22),r=n.n(a);t.default=r.a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var a=r(n(45));function r(e){return e&&e.__esModule?e:{default:e}}var i={mixins:[r(n(5)).default],components:{picker:a.default},data:function(){return{range:[],rangeKey:"",value:0,mode:"selector",fields:"day",start:"",end:"",disabled:!1,visible:!1}},onLoad:function(){var e=this;null===this.data?this.postMessage({event:"created"},!0):this.showPicker(this.data),this.onMessage((function(t){e.showPicker(t)}))},onReady:function(){var e=this;this.$nextTick((function(){e.visible=!0}))},methods:{showPicker:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.column;for(var n in e)"column"!==n&&("number"==typeof t?this.$set(this.$data[n],t,e[n]):this.$data[n]=e[n])},close:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=n.value,r=void 0===a?-1:a;this.visible=!1,setTimeout((function(){t.postMessage({event:e,value:r})}),210)},onClose:function(){this.close("cancel")},columnchange:function(e){var t=e.column,n=e.value;this.$set(this.value,t,n),this.postMessage({event:"columnchange",column:t,value:n},!0)}}};t.default=i},function(e,t,n){"use strict";n.r(t);var a=n(24),r=n.n(a);for(var i in a)"default"!==i&&function(e){n.d(t,e,(function(){return a[e]}))}(i);t.default=r.a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var a=n(46),r=o(n(6)),i=o(n(47));function o(e){return e&&e.__esModule?e:{default:e}}function s(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);tn(i)&&this._cloneArray(a,i)}e.forEach((function(e,n){e!==t.oldValueArray[n]&&(t.oldValueArray[n]=e,t.mode===f.MULTISELECTOR&&t.$emit("columnchange",{column:n,value:e}))}))},visible:function(e){var t=this;e?setTimeout((function(){l.transition(t.$refs.picker,{styles:{transform:"translateY(0)"},duration:200})}),20):l.transition(this.$refs.picker,{styles:{transform:"translateY(".concat(283+this.safeAreaInsets.bottom,"px)")},duration:200})}},created:function(){this._createTime(),this._createDate(),this._setValueSync()},methods:{getTexts:function(e,t){var n=this,a=this.textMaxLength;return e.map((function(e){var r=String("object"==typeof e?e[n.rangeKey]||"":n._l10nItem(e,t));if(a>0&&r.length>a)for(var i=0,o=0,s=0;s127||94===u?1:.65)<=a-1&&(o=s),i>=a)return s===r.length-1?r:r.substr(0,o+1)+"…"}return r||" "})).join("\n")},_createTime:function(){var e=[],t=[];e.splice(0,e.length);for(var n=0;n<24;n++)e.push((n<10?"0":"")+n);t.splice(0,t.length);for(var a=0;a<60;a++)t.push((a<10?"0":"")+a);this.timeArray.push(e,t)},_createDate:function(){for(var e=[],t=function(e){var t=(new Date).getFullYear(),n=t-61,a=t+61;if(e.start){var r=new Date(e.start).getFullYear();!isNaN(r)&&ra&&(a=i)}return{start:n,end:a}}(this),n=t.start,a=t.end;n<=a;n++)e.push(String(n));for(var r=[],i=1;i<=12;i++)r.push((i<10?"0":"")+i);for(var o=[],s=1;s<=31;s++)o.push((s<10?"0":"")+s);this.dateArray.push(e,r,o)},_getTimeValue:function(e){return 60*e[0]+e[1]},_getDateValue:function(e){return 31*e[0]*12+31*(e[1]||0)+(e[2]||0)},_cloneArray:function(e,t){for(var n=0;no?0:i)}break;case f.TIME:case f.DATE:this.valueSync=String(e);break;default:var s=Number(e);this.valueSync=s<0?0:s}},_setValueArray:function(){var e,t=this.valueSync;switch(this.mode){case f.MULTISELECTOR:e=s(t);break;case f.TIME:e=this._getDateValueArray(t,(0,a.formatDateTime)({mode:f.TIME}));break;case f.DATE:e=this._getDateValueArray(t,(0,a.formatDateTime)({mode:f.DATE}));break;default:e=[t]}this.oldValueArray=s(e),this.valueArray=s(e)},_getValue:function(){var e=this,t=this.valueArray;switch(this.mode){case f.SELECTOR:return t[0];case f.MULTISELECTOR:return t.map((function(e){return e}));case f.TIME:return this.valueArray.map((function(t,n){return e.timeArray[n][t]})).join(":");case f.DATE:return this.valueArray.map((function(t,n){return e.dateArray[n][t]})).join("-")}},_getDateValueArray:function(e,t){var n=this.mode===f.DATE?"-":":",a=this.mode===f.DATE?this.dateArray:this.timeArray,r=3;switch(this.fields){case d.YEAR:r=1;break;case d.MONTH:r=2}for(var i=String(e).split(n),o=[],s=0;s=0&&(o=t?this._getDateValueArray(t):o.map((function(){return 0}))),o},_change:function(){this.$emit("change",{value:this._getValue()})},_cancel:function(){this.$emit("cancel")},_pickerViewChange:function(e){this.valueArray=this._l10nColumn(e.detail.value,!0)},_l10nColumn:function(e,t){if(this.mode===f.DATE){var n=this.locale;if(!n.startsWith("zh"))switch(this.fields){case d.YEAR:return e;case d.MONTH:return[e[1],e[0]];default:switch(n){case"es":case"fr":return[e[2],e[1],e[0]];default:return t?[e[2],e[0],e[1]]:[e[1],e[2],e[0]]}}}return e},_l10nItem:function(e,t){if(this.mode===f.DATE){var n=this.locale;if(n.startsWith("zh")){return e+["年","月","日"][t]}if(this.fields!==d.YEAR&&t===(this.fields===d.MONTH||"es"!==n&&"fr"!==n?0:1)){var a;switch(n){case"es":a=["enero","febrero","marzo","abril","mayo","junio","​​julio","agosto","septiembre","octubre","noviembre","diciembre"];break;case"fr":a=["janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre"];break;default:a=["January","February","March","April","May","June","July","August","September","October","November","December"]}return a[Number(e)-1]}}return e}}};t.default=p},function(e,t){e.exports={content:{position:"absolute",top:0,left:0,bottom:0,right:0},"uni-mask":{position:"absolute",top:0,left:0,bottom:0,right:0,backgroundColor:"rgba(0,0,0,0.4)",opacity:0,transitionProperty:"opacity",transitionDuration:200,transitionTimingFunction:"linear"},"@TRANSITION":{"uni-mask":{property:"opacity",duration:200,timingFunction:"linear"}},"uni-mask-android":{backgroundColor:"rgba(0,0,0,0.6)"},"uni-mask-visible":{opacity:1},"uni-picker":{position:"absolute",left:0,bottom:0,right:0,backgroundColor:"#ffffff",color:"#000000",flexDirection:"column",transform:"translateY(295px)"},"uni-picker-header":{height:"45",borderBottomWidth:0,backgroundColor:"#E6E6E6",fontSize:"20"},"uni-picker-action":{position:"absolute",textAlign:"center",top:0,height:"45",paddingTop:0,paddingRight:"14",paddingBottom:0,paddingLeft:"14",fontSize:"17",lineHeight:"45"},"uni-picker-action-cancel":{left:0,color:"#888888"},"uni-picker-action-confirm":{right:0,color:"#007aff"},"uni-picker-content":{flex:1},"uni-picker-item":{lineHeight:"34",textAlign:"center",color:"#000000"}}},function(e,t){e.exports={page:{flex:1}}},,,,,function(e,t,n){"use strict";var a=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("scroll-view",{staticStyle:{flexDirection:"column"},attrs:{scrollY:!0,enableBackToTop:!0,bubble:"true"}},[n("view",{staticClass:["page"]},[n("picker",{attrs:{range:e.range,rangeKey:e.rangeKey,value:e.value,mode:e.mode,fields:e.fields,start:e.start,end:e.end,disabled:e.disabled,visible:e.visible},on:{change:function(t){e.close("change",t)},cancel:function(t){e.close("cancel",t)},columnchange:e.columnchange}})],1)])},r=[];n.d(t,"b",(function(){return a})),n.d(t,"c",(function(){return r})),n.d(t,"a",(function(){}))},,,function(e,t,n){"use strict";var a=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:["content"]},[n("div",{ref:"mask",staticClass:["uni-mask"],class:{"uni-mask-visible":e.visible,"uni-mask-android":e.android},on:{click:e._cancel}}),n("div",{ref:"picker",staticClass:["uni-picker"],class:{"uni-picker-visible":e.visible},style:"padding-bottom:"+e.safeAreaInsets.bottom+"px;height:"+(e.height+e.safeAreaInsets.bottom)+"px;"},[n("div",{staticClass:["uni-picker-header"]},[n("u-text",{staticClass:["uni-picker-action","uni-picker-action-cancel"],style:"left:"+e.safeAreaInsets.left+"px",on:{click:e._cancel}},[e._v(e._s(e.localize("cancel")))]),n("u-text",{staticClass:["uni-picker-action","uni-picker-action-confirm"],style:"right:"+e.safeAreaInsets.right+"px",on:{click:e._change}},[e._v(e._s(e.localize("done")))])]),e.visible?n("picker-view",{staticClass:["uni-picker-content"],style:"margin-left:"+e.safeAreaInsets.left+"px",attrs:{height:"216",indicatorStyle:"height: 34px;border-color:#C8C9C9;border-top-width:0.5px;border-bottom-width:0.5px;",value:e._l10nColumn(e.valueArray)},on:{change:e._pickerViewChange}},e._l(e._l10nColumn(e.rangeArray),(function(t,a){return n("picker-view-column",{key:a,attrs:{length:t.length}},[n("u-text",{staticClass:["uni-picker-item"],style:{fontSize:e.fontSize+"px"}},[e._v(e._s(e.getTexts(t,a)))])])})),1):e._e()],1)])},r=[];n.d(t,"b",(function(){return a})),n.d(t,"c",(function(){return r})),n.d(t,"a",(function(){}))},,,,,function(e,t,n){"use strict";n.r(t);var a=n(25),r=n.n(a);for(var i in a)"default"!==i&&function(e){n.d(t,e,(function(){return a[e]}))}(i);t.default=r.a},function(e,t,n){"use strict";n.r(t);var a=n(26),r=n.n(a);for(var i in a)"default"!==i&&function(e){n.d(t,e,(function(){return a[e]}))}(i);t.default=r.a},,,,function(e,t,n){"use strict";n.r(t);n(3);var a=n(10);a.default.mpType="page",a.default.route="template/__uniapppicker",a.default.el="#root",new Vue(a.default)},function(e,t,n){"use strict";n.r(t);var a=n(34),r=n(23);for(var i in r)"default"!==i&&function(e){n.d(t,e,(function(){return r[e]}))}(i);var o=n(1);var s=Object(o.a)(r.default,a.b,a.c,!1,null,null,"1f8b5a47",!1,a.a,void 0);(function(e){this.options.style||(this.options.style={}),Vue.prototype.__merge_style&&Vue.prototype.__$appStyle__&&Vue.prototype.__merge_style(Vue.prototype.__$appStyle__,this.options.style),Vue.prototype.__merge_style?Vue.prototype.__merge_style(n(39).default,this.options.style):Object.assign(this.options.style,n(39).default)}).call(s),t.default=s.exports},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.formatDateTime=function(e){var t=e.date,n=void 0===t?new Date:t,r=e.mode;return"time"===(void 0===r?"date":r)?a(n.getHours())+":"+a(n.getMinutes()):n.getFullYear()+"-"+a(n.getMonth()+1)+"-"+a(n.getDate())};var a=function(e){return e>9?e:"0"+e}},function(e,t,n){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n={data:function(){return{safeAreaInsets:{left:0,right:0,top:0,bottom:0}}},onLoad:function(){this.initSafeAreaInsets()},created:function(){this.initSafeAreaInsets()},methods:{initSafeAreaInsets:function(){var t=this;if(!this.__initSafeAreaInsets){this.__initSafeAreaInsets=!0;var n=e.webview.currentWebview();n.addEventListener("resize",(function(){setTimeout((function(){t.updateSafeAreaInsets(n)}),20)})),this.updateSafeAreaInsets(n)}},updateSafeAreaInsets:function(e){var t=e.getSafeAreaInsets(),n=this.safeAreaInsets;Object.keys(n).forEach((function(e){n[e]=t[e]}))}}};t.default=n}).call(this,n(2).weexPlus)}]); \ No newline at end of file diff --git a/packages/uni-app/.npmignore b/packages/uni-app/.npmignore new file mode 100644 index 0000000000000000000000000000000000000000..be20f8185792fd93ae7241db775b56c3a6adcce8 --- /dev/null +++ b/packages/uni-app/.npmignore @@ -0,0 +1,3 @@ +src +yarn.lock +tsconfig.json \ No newline at end of file diff --git a/packages/uni-app/LICENSE b/packages/uni-app/LICENSE new file mode 100755 index 0000000000000000000000000000000000000000..7a4a3ea2424c09fbe48d455aed1eaa94d9124835 --- /dev/null +++ b/packages/uni-app/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/packages/uni-app/dist/index.d.ts b/packages/uni-app/dist/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e127a80794259fd25dc27f7b02c5d95a769d52a5 --- /dev/null +++ b/packages/uni-app/dist/index.d.ts @@ -0,0 +1,30 @@ +/// +/// +/// +/// +import { ComponentInternalInstance } from '@vue/composition-api'; +export declare const onShow: (callback: ((options?: App.LaunchShowOption) => void) | (() => void), target?: ComponentInternalInstance | null) => Function; +export declare const onHide: (callback: (() => void) | (() => void), target?: ComponentInternalInstance | null) => Function; +export declare const onLaunch: (callback: (options?: App.LaunchShowOption) => void, target?: ComponentInternalInstance | null) => Function; +export declare const onError: (callback: (error: string) => void, target?: ComponentInternalInstance | null) => Function; +export declare const onPageNotFound: (callback: (options: App.PageNotFoundOption) => void, target?: ComponentInternalInstance | null) => Function; +export declare const onUnhandledRejection: (callback: (options: UniApp.OnUnhandledRejectionCallbackResult) => void, target?: ComponentInternalInstance | null) => Function; +export declare const onThemeChange: (callback: (options: UniApp.OnThemeChangeCallbackResult) => void, target?: ComponentInternalInstance | null) => Function; +export declare const onUniNViewMessage: (callback: (options: AnyObject) => void, target?: ComponentInternalInstance | null) => Function; +export declare const onInit: (callback: (query?: AnyObject) => void, target?: ComponentInternalInstance | null) => Function; +export declare const onLoad: (callback: (query?: AnyObject) => void, target?: ComponentInternalInstance | null) => Function; +export declare const onReady: (callback: () => void, target?: ComponentInternalInstance | null) => Function; +export declare const onUnload: (callback: () => void, target?: ComponentInternalInstance | null) => Function; +export declare const onPullDownRefresh: (callback: () => void, target?: ComponentInternalInstance | null) => Function; +export declare const onReachBottom: (callback: () => void, target?: ComponentInternalInstance | null) => Function; +export declare const onShareAppMessage: (callback: (options: Page.ShareAppMessageOption) => Page.CustomShareContent, target?: ComponentInternalInstance | null) => Function; +export declare const onShareTimeline: (callback: () => Page.ShareTimelineContent, target?: ComponentInternalInstance | null) => Function; +export declare const onAddToFavorites: (callback: (options: Page.AddToFavoritesOption) => Page.CustomFavoritesContent, target?: ComponentInternalInstance | null) => Function; +export declare const onPageScroll: (callback: (options: Page.PageScrollOption) => void, target?: ComponentInternalInstance | null) => Function; +export declare const onResize: (callback: (options: Page.PageScrollOption) => void, target?: ComponentInternalInstance | null) => Function; +export declare const onTabItemTap: (callback: (options: Page.TabItemTapOption) => void, target?: ComponentInternalInstance | null) => Function; +export declare const onNavigationBarButtonTap: (callback: (options: Page.NavigationBarButtonTapOption) => void, target?: ComponentInternalInstance | null) => Function; +export declare const onBackPress: (callback: (options: Page.BackPressOption) => any, target?: ComponentInternalInstance | null) => Function; +export declare const onNavigationBarSearchInputChanged: (callback: (event: Page.NavigationBarSearchInputEvent) => void, target?: ComponentInternalInstance | null) => Function; +export declare const onNavigationBarSearchInputConfirmed: (callback: (event: Page.NavigationBarSearchInputEvent) => void, target?: ComponentInternalInstance | null) => Function; +export declare const onNavigationBarSearchInputClicked: (callback: () => void, target?: ComponentInternalInstance | null) => Function; diff --git a/packages/uni-app/dist/index.js b/packages/uni-app/dist/index.js new file mode 100644 index 0000000000000000000000000000000000000000..c55ca2c2db3114b0c8db9cd4ec2ee299bd89527e --- /dev/null +++ b/packages/uni-app/dist/index.js @@ -0,0 +1,45 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.onNavigationBarSearchInputClicked = exports.onNavigationBarSearchInputConfirmed = exports.onNavigationBarSearchInputChanged = exports.onBackPress = exports.onNavigationBarButtonTap = exports.onTabItemTap = exports.onResize = exports.onPageScroll = exports.onAddToFavorites = exports.onShareTimeline = exports.onShareAppMessage = exports.onReachBottom = exports.onPullDownRefresh = exports.onUnload = exports.onReady = exports.onLoad = exports.onInit = exports.onUniNViewMessage = exports.onThemeChange = exports.onUnhandledRejection = exports.onPageNotFound = exports.onError = exports.onLaunch = exports.onHide = exports.onShow = void 0; +var composition_api_1 = require("@vue/composition-api"); +var mp = require("./mp"); +var lifecycles = []; +var createLifeCycle = function (lifecycle) { + lifecycles.push(lifecycle); + var fn = (0, composition_api_1.createLifeCycle)(lifecycle); + return function (callback, target) { + return fn(callback, target); + }; +}; +if (typeof plus === 'object') { +} +else if (typeof window === 'object' && 'document' in window) { +} +else { + mp.init(lifecycles); +} +exports.onShow = createLifeCycle('onShow'); +exports.onHide = createLifeCycle('onHide'); +exports.onLaunch = createLifeCycle('onLaunch'); +exports.onError = createLifeCycle('onError'); +exports.onPageNotFound = createLifeCycle('onPageNotFound'); +exports.onUnhandledRejection = createLifeCycle('onUnhandledRejection'); +exports.onThemeChange = createLifeCycle('onThemeChange'); +exports.onUniNViewMessage = createLifeCycle('onUniNViewMessage'); +exports.onInit = createLifeCycle('onInit'); +exports.onLoad = createLifeCycle('onLoad'); +exports.onReady = createLifeCycle('onReady'); +exports.onUnload = createLifeCycle('onUnload'); +exports.onPullDownRefresh = createLifeCycle('onPullDownRefresh'); +exports.onReachBottom = createLifeCycle('onReachBottom'); +exports.onShareAppMessage = createLifeCycle('onShareAppMessage'); +exports.onShareTimeline = createLifeCycle('onShareTimeline'); +exports.onAddToFavorites = createLifeCycle('onAddToFavorites'); +exports.onPageScroll = createLifeCycle('onPageScroll'); +exports.onResize = createLifeCycle('onResize'); +exports.onTabItemTap = createLifeCycle('onTabItemTap'); +exports.onNavigationBarButtonTap = createLifeCycle('onNavigationBarButtonTap'); +exports.onBackPress = createLifeCycle('onBackPress'); +exports.onNavigationBarSearchInputChanged = createLifeCycle('onNavigationBarSearchInputChanged'); +exports.onNavigationBarSearchInputConfirmed = createLifeCycle('onNavigationBarSearchInputConfirmed'); +exports.onNavigationBarSearchInputClicked = createLifeCycle('onNavigationBarSearchInputClicked'); diff --git a/packages/uni-app/dist/mp.d.ts b/packages/uni-app/dist/mp.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ce303b215717ea1be9e84218648b53525ed46e2a --- /dev/null +++ b/packages/uni-app/dist/mp.d.ts @@ -0,0 +1 @@ +export declare function init(lifecycles: string[]): void; diff --git a/packages/uni-app/dist/mp.js b/packages/uni-app/dist/mp.js new file mode 100644 index 0000000000000000000000000000000000000000..50801a33152af20444d8fe5299160cbd2565f30a --- /dev/null +++ b/packages/uni-app/dist/mp.js @@ -0,0 +1,55 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.init = void 0; +var vue_1 = require("vue"); +function updateLifeCycle(lifecycles, setupLifecycles, fn) { + if (fn) { + if (fn.lifecycles) { + fn.lifecycles.forEach(function (item) { + if (!setupLifecycles.includes(item)) { + setupLifecycles.push(item); + } + }); + } + else { + var fnString_1 = fn.toString(); + lifecycles.forEach(function (item) { + if (!setupLifecycles.includes(item) && (new RegExp("\\b(".concat(item, ")\\b"))).test(fnString_1)) { + setupLifecycles.push(item); + } + }); + } + } +} +function init(lifecycles) { + var setup = vue_1.default.config.optionMergeStrategies.setup; + var extend = vue_1.default.extend; + vue_1.default.extend = function () { + var extendedVue = extend.apply(this, arguments); + var newOptions = extendedVue.options; + var setup = newOptions.setup; + if (setup && setup.lifecycles) { + setup.lifecycles.forEach(function (item) { + newOptions[item] = newOptions[item] || [function noop() { }]; + }); + } + return extendedVue; + }; + Object.defineProperty(vue_1.default.config.optionMergeStrategies, 'setup', { + set: function (fn) { + setup = fn; + }, + get: function () { + return function (to, from) { + if (typeof setup === 'function') { + var newSetup = setup.apply(this, arguments); + newSetup.lifecycles = newSetup.lifecycles || []; + updateLifeCycle(lifecycles, newSetup.lifecycles, from); + updateLifeCycle(lifecycles, newSetup.lifecycles, to); + return newSetup; + } + }; + } + }); +} +exports.init = init; diff --git a/packages/uni-app/package.json b/packages/uni-app/package.json new file mode 100644 index 0000000000000000000000000000000000000000..40f0c13604413ae68e082a249811fdf2ca33d500 --- /dev/null +++ b/packages/uni-app/package.json @@ -0,0 +1,25 @@ +{ + "name": "@dcloudio/uni-app", + "version": "2.0.0-32920211029001", + "description": "uni-app composition-api", + "main": "dist/index.js", + "repository": { + "type": "git", + "url": "git+https://github.com/dcloudio/uni-app.git", + "directory": "packages/uni-app" + }, + "scripts": { + "build": "tsc -p . " + }, + "peerDependencies": { + "@dcloudio/types": "^3.0.15", + "@vue/composition-api": "^1.7.0" + }, + "author": "fxy060608", + "license": "Apache-2.0", + "gitHead": "9e2d0f8e244724fcd64880316c57d837d1778cf8", + "devDependencies": { + "@dcloudio/types": "^3.0.15", + "typescript": "^4.8.3" + } +} diff --git a/packages/uni-app/src/index.ts b/packages/uni-app/src/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..c9728175a83dff2c62f5131aaf237d4e8c06a5b9 --- /dev/null +++ b/packages/uni-app/src/index.ts @@ -0,0 +1,48 @@ +/// +import { createLifeCycle as createLifeCycleBase, ComponentInternalInstance } from '@vue/composition-api' +import * as mp from './mp' + +const lifecycles: string[] = [] + +const createLifeCycle = (lifecycle: string) => { + lifecycles.push(lifecycle) + const fn = createLifeCycleBase(lifecycle) + return (callback: T, target?: ComponentInternalInstance | null) => { + return fn(callback, target) + } +} +if (typeof plus === 'object') { + // TODO App +} else if (typeof window === 'object' && 'document' in window) { + // TODO H5 +} else { + mp.init(lifecycles) +} + +export const onShow = createLifeCycle('onShow') +export const onHide = createLifeCycle('onHide') + +export const onLaunch = createLifeCycle('onLaunch') +export const onError = createLifeCycle('onError') +export const onPageNotFound = createLifeCycle('onPageNotFound') +export const onUnhandledRejection = createLifeCycle('onUnhandledRejection') +export const onThemeChange = createLifeCycle('onThemeChange') +export const onUniNViewMessage = createLifeCycle('onUniNViewMessage') + +export const onInit = createLifeCycle('onInit') +export const onLoad = createLifeCycle('onLoad') +export const onReady = createLifeCycle('onReady') +export const onUnload = createLifeCycle('onUnload') +export const onPullDownRefresh = createLifeCycle('onPullDownRefresh') +export const onReachBottom = createLifeCycle('onReachBottom') +export const onShareAppMessage = createLifeCycle('onShareAppMessage') +export const onShareTimeline = createLifeCycle('onShareTimeline') +export const onAddToFavorites = createLifeCycle('onAddToFavorites') +export const onPageScroll = createLifeCycle('onPageScroll') +export const onResize = createLifeCycle('onResize') +export const onTabItemTap = createLifeCycle('onTabItemTap') +export const onNavigationBarButtonTap = createLifeCycle('onNavigationBarButtonTap') +export const onBackPress = createLifeCycle('onBackPress') +export const onNavigationBarSearchInputChanged = createLifeCycle('onNavigationBarSearchInputChanged') +export const onNavigationBarSearchInputConfirmed = createLifeCycle('onNavigationBarSearchInputConfirmed') +export const onNavigationBarSearchInputClicked = createLifeCycle('onNavigationBarSearchInputClicked') diff --git a/packages/uni-app/src/mp.ts b/packages/uni-app/src/mp.ts new file mode 100644 index 0000000000000000000000000000000000000000..0a07e74b5de41db7d7bd830a9d39f55f3c474070 --- /dev/null +++ b/packages/uni-app/src/mp.ts @@ -0,0 +1,58 @@ +import Vue from 'vue' + +interface SetupFunction extends Function { + lifecycles?: string[] +} + +function updateLifeCycle(lifecycles: string[], setupLifecycles: string[], fn?: SetupFunction) { + if (fn) { + if (fn.lifecycles) { + fn.lifecycles.forEach(item => { + if (!setupLifecycles.includes(item)) { + setupLifecycles.push(item) + } + }) + } else { + const fnString = fn.toString() + lifecycles.forEach(item => { + if (!setupLifecycles.includes(item) && (new RegExp(`\\b(${item})\\b`)).test(fnString)) { + setupLifecycles.push(item) + } + }) + } + } +} + +export function init(lifecycles: string[]) { + // 通过 setup 函数简易分析使用到的生命周期,合并至 options 中 + // TODO 编译过程静态分析 或 将页面 Vue 组件创建移至小程序组件创建之前 + let setup = Vue.config.optionMergeStrategies.setup + const extend = Vue.extend + Vue.extend = function () { + const extendedVue = extend.apply(this, arguments) + const newOptions = extendedVue.options + const setup: SetupFunction | undefined = newOptions.setup + if (setup && setup.lifecycles) { + setup.lifecycles.forEach(item => { + newOptions[item] = newOptions[item] || [function noop() { }] + }) + } + return extendedVue + } + Object.defineProperty(Vue.config.optionMergeStrategies, 'setup', { + set(fn) { + setup = fn + }, + get() { + return function (to: Function, from: Function) { + if (typeof setup === 'function') { + const newSetup: SetupFunction = setup.apply(this, arguments) + newSetup.lifecycles = newSetup.lifecycles || [] + updateLifeCycle(lifecycles, newSetup.lifecycles, from) + updateLifeCycle(lifecycles, newSetup.lifecycles, to) + return newSetup + } + } + } + }) +} diff --git a/packages/uni-app/tsconfig.json b/packages/uni-app/tsconfig.json new file mode 100644 index 0000000000000000000000000000000000000000..47545b54502addc8f21c3fa51546a2f317284610 --- /dev/null +++ b/packages/uni-app/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "CommonJS", + "target": "ES5", + "outDir": "dist", + "sourceMap": false, + "rootDir": "src", + "removeComments": true, + "declaration": true, + "skipLibCheck": true, + "paths": { + "@vue/composition-api": [ + "../../packages/vue-cli-plugin-uni/packages/@vue/composition-api" + ] + } + }, + "include": [ + "src" + ] +} \ No newline at end of file diff --git a/packages/uni-app/yarn.lock b/packages/uni-app/yarn.lock new file mode 100644 index 0000000000000000000000000000000000000000..51fe2c33fd1c1387cfc0faaaa1ca9e620ae183c3 --- /dev/null +++ b/packages/uni-app/yarn.lock @@ -0,0 +1,13 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@dcloudio/types@^3.0.15": + version "3.0.15" + resolved "https://registry.yarnpkg.com/@dcloudio/types/-/types-3.0.15.tgz#ec72fadb8b276c9e35f97ff74af7cd3170301118" + integrity sha512-3ngPB4X1Nql8OxWn3sjXgGYAB57mPnAzzmlOBv1nppYGJMD/Hn/oet1LUK72IdJKxiCU5kMBftWylDPQAx6Y7g== + +typescript@^4.8.3: + version "4.8.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.8.3.tgz#d59344522c4bc464a65a730ac695007fdb66dd88" + integrity sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig== diff --git a/packages/uni-cli-i18n/locales/zh_CN.json b/packages/uni-cli-i18n/locales/zh_CN.json index a86b19ca3765e01dee1c6d83b2b6b8b6d6001b8d..74893fe52bdda8e20c08e67d80d6413e24246a3b 100644 --- a/packages/uni-cli-i18n/locales/zh_CN.json +++ b/packages/uni-cli-i18n/locales/zh_CN.json @@ -48,7 +48,7 @@ "pluginUni.entryDileNoExistsCheckAfterRetry": "{{0}} 入口文件不存在,请检查后重试", "pluginUni.nvueCompileModeForDetail": "当前nvue编译模式:{{0}}。编译模式差异见 {{1}}", "pluginUni.currentProjectDefaultSpaceId": "当前项目的uniCloud使用的默认服务空间spaceId为:{{0}}", - "pluginUni.unicloudReleaseH5": "发布H5,需要在uniCloud web控制台操作,绑定安全域名,否则会因为跨域问题而无法访问。教程参考:{{0}}", + "pluginUni.unicloudReleaseH5": "发布web站点需要在uniCloud web控制台操作,绑定安全域名,否则会因为跨域问题而无法访问。教程参考:{{0}}", "pluginUni.unicloudShowedRunByHBuilderX": "当前项目使用了uniCloud,为避免云函数调用跨域问题,建议在HBuilderX内置浏览器里调试,如使用外部浏览器需处理跨域,详见:{{0}}", "pluginUni.pleaseSpecifyPluginName": "请指定插件名", "pluginUni.pluginNameNotExist": "插件名称不存在", diff --git a/packages/uni-cli-shared/components/ad.mixin.js b/packages/uni-cli-shared/components/ad.mixin.js index 8a2aeb38168c08872dd11881cff5030044be8886..a22c1a517a37f1f6385af1a6e54b197031b511a2 100644 --- a/packages/uni-cli-shared/components/ad.mixin.js +++ b/packages/uni-cli-shared/components/ad.mixin.js @@ -54,12 +54,14 @@ class AdBase { }) ad.onError(({ code, - message + message, + detail }) => { this._isLoading = false const data = { code: code, - errMsg: message + errMsg: message, + detail: detail } if (this._retry && code === -5008) { diff --git a/packages/uni-cli-shared/lib/cache.js b/packages/uni-cli-shared/lib/cache.js index 23c2adcfce874fc366620431365754e55bfe2bfa..0e3cbc786b61ebd9f140b51c7cce45e7821cb00f 100644 --- a/packages/uni-cli-shared/lib/cache.js +++ b/packages/uni-cli-shared/lib/cache.js @@ -1,6 +1,9 @@ const fs = require('fs') const path = require('path') const crypto = require('crypto') +const { + isNormalPage +} = require('./util') /** * 1.page-loader 缓存基础的 app.json page.json project.config.json * 2.main-loader 缓存 app.json 中的 usingComponents 节点 @@ -49,7 +52,9 @@ function getJsonFile (name) { function getChangedJsonFileMap (clear = true) { const changedJsonFileMap = new Map() for (const name of changedJsonFileSet.values()) { - changedJsonFileMap.set(name + '.json', jsonFileMap.get(name)) + if (isNormalPage(name)) { + changedJsonFileMap.set(name + '.json', jsonFileMap.get(name)) + } } clear && changedJsonFileSet.clear() return changedJsonFileMap @@ -361,4 +366,4 @@ module.exports = { getChangedJsonFileMap, getSpecialMethods, supportGlobalUsingComponents -} +} diff --git a/packages/uni-cli-shared/lib/file-loader.js b/packages/uni-cli-shared/lib/file-loader.js index 0bc89f57bef6d2b52e5f85b6d89fef0b4fb2b762..c2cdced406b6c355ec137564a92f8dfd594425ee 100644 --- a/packages/uni-cli-shared/lib/file-loader.js +++ b/packages/uni-cli-shared/lib/file-loader.js @@ -1,17 +1,16 @@ const path = require('path') - -const isWin = /^win/.test(process.platform) - -const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path) +const { + normalizeNodeModules +} = require('./util') module.exports = { loader: 'file-loader', options: { publicPath (url, resourcePath, context) { - return '/' + normalizePath(path.relative(process.env.UNI_INPUT_DIR, resourcePath)) + return '/' + normalizeNodeModules(path.relative(process.env.UNI_INPUT_DIR, resourcePath)) }, outputPath (url, resourcePath, context) { - return normalizePath(path.relative(process.env.UNI_INPUT_DIR, resourcePath)) + return normalizeNodeModules(path.relative(process.env.UNI_INPUT_DIR, resourcePath)) } } } diff --git a/packages/uni-cli-shared/lib/index.js b/packages/uni-cli-shared/lib/index.js index 70528402fce0618c423d0ab5aa22d3adca296a45..ea7878eaf3f33c9994559a36672a3f7a98e54436 100644 --- a/packages/uni-cli-shared/lib/index.js +++ b/packages/uni-cli-shared/lib/index.js @@ -112,5 +112,6 @@ module.exports = { getPlatformGlobal, getPlatformStat, getPlatformPush, - getPlatformUniCloud -} + getPlatformUniCloud, + uniModulesLoader: normalizePath(require.resolve('./uni_modules-loader')) +} diff --git a/packages/uni-cli-shared/lib/manifest.js b/packages/uni-cli-shared/lib/manifest.js index 7e0748a75c03e30020572bbc000d5ca50dbc6dac..156aa101c65ddfb67314b8c56a06e1ede9f9d4d1 100644 --- a/packages/uni-cli-shared/lib/manifest.js +++ b/packages/uni-cli-shared/lib/manifest.js @@ -108,7 +108,7 @@ function isEnableUniPushV1 (manifestJson, platform) { if (isEnableUniPushV2(manifestJson, platform)) { return false } - if (platform === 'app-plus') { + if (platform === 'app-plus') { const platformOptions = manifestJson[platform] const sdkConfigs = platformOptions && platformOptions.distribute && platformOptions.distribute.sdkConfigs const push = sdkConfigs && sdkConfigs.push @@ -135,6 +135,19 @@ function isEnableUniPushV2 (manifestJson, platform) { return platformOptions && platformOptions.unipush && platformOptions.unipush.enable === true } +function isEnableSecureNetwork (manifestJson, platform) { + if (!manifestJson) { + manifestJson = getManifestJson() + } + const platformOptions = manifestJson[platform] + if (platform === 'app-plus') { + return !!( + platformOptions && platformOptions.modules && platformOptions.modules.SecureNetwork + ) + } + return platformOptions && platformOptions.secureNetwork && platformOptions.secureNetwork.enable === true +} + function isUniPushOffline (manifestJson) { if (!manifestJson) { manifestJson = getManifestJson() @@ -149,8 +162,9 @@ module.exports = { getManifestJson, parseManifestJson, getNetworkTimeout, - getH5Options, + getH5Options, isEnableUniPushV1, isEnableUniPushV2, - isUniPushOffline -} + isUniPushOffline, + isEnableSecureNetwork +} diff --git a/packages/uni-cli-shared/lib/pages.js b/packages/uni-cli-shared/lib/pages.js index acf03c89e49c1af446726db49523c98fe2bfbe12..0f70942ea91fa7219fef277b6f8755a91f472273 100644 --- a/packages/uni-cli-shared/lib/pages.js +++ b/packages/uni-cli-shared/lib/pages.js @@ -6,7 +6,8 @@ const { removeExt, normalizePath, camelize, - capitalize + capitalize, + isNormalPage } = require('./util') const { @@ -113,7 +114,9 @@ function isNVuePage (page, root = '') { function isValidPage (page, root = '') { if (typeof page === 'string' || !page.path) { // 不合法的配置 - console.warn(uniI18n.__('cliShared.pagesJsonError', { 0: 'https://uniapp.dcloud.io/collocation/pages?id=pages' })) + console.warn(uniI18n.__('cliShared.pagesJsonError', { + 0: 'https://uniapp.dcloud.io/collocation/pages?id=pages' + })) return false } let pagePath = page.path @@ -213,7 +216,10 @@ function parseEntry (pagesJson) { const weixinConfig = manifestConfig['mp-weixin'] || {} const independentSwitch = !!weixinConfig.independent if (independentSwitch) { - Object.values(process.UNI_SUBPACKAGES).forEach(({ root, independent = false }) => { + Object.values(process.UNI_SUBPACKAGES).forEach(({ + root, + independent = false + }) => { if (root && independent) { const pkgRootMainJsKey = `${root}/common/main` // const pkgRootMainJsPath = `${process.env.UNI_INPUT_DIR}/${root}/main.js`; @@ -239,7 +245,9 @@ function parseEntry (pagesJson) { // pages pagesJson.pages.forEach(page => { - process.UNI_ENTRY[page.path] = getMainJsPath(page.path) + if (isNormalPage(page.path)) { + process.UNI_ENTRY[page.path] = getMainJsPath(page.path) + } }) // subPackages if (Array.isArray(pagesJson.subPackages) && pagesJson.subPackages.length) { @@ -404,7 +412,11 @@ function initAutoComponents () { }) if (conflictFiles.length > 0) { conflictFiles.forEach(files => { - console.warn(uniI18n.__('cliShared.easycomConflict', { 0: '[' + files.map((file, index) => { return file }).join(',') + ']' })) + console.warn(uniI18n.__('cliShared.easycomConflict', { + 0: '[' + files.map((file, index) => { + return file + }).join(',') + ']' + })) console.log('\n') }) } @@ -519,7 +531,9 @@ function parseUsingAutoImportComponents (usingAutoImportComponents) { const BUILT_IN_COMPONENTS = ['page-meta', 'navigation-bar', 'uni-match-media'] -const BUILT_IN_EASYCOMS = ['unicloud-db', 'uniad', 'ad-rewarded-video', 'ad-fullscreen-video', 'ad-interstitial', 'ad-interactive'] +const BUILT_IN_EASYCOMS = ['unicloud-db', 'uniad', 'ad-rewarded-video', 'ad-fullscreen-video', 'ad-interstitial', + 'ad-interactive' +] function isBuiltInComponent (name) { // uni-template-compiler/lib/util.js 识别微信内置组件 return BUILT_IN_COMPONENTS.includes(name) @@ -551,4 +565,4 @@ module.exports = { getGlobalUsingComponentsCode, parseUsingAutoImportComponents, generateGlobalUsingComponentsCode -} +} diff --git a/packages/uni-cli-shared/lib/uni_modules-loader.js b/packages/uni-cli-shared/lib/uni_modules-loader.js new file mode 100644 index 0000000000000000000000000000000000000000..a630c374e5105cba33c433968a246f5e67b35b3f --- /dev/null +++ b/packages/uni-cli-shared/lib/uni_modules-loader.js @@ -0,0 +1,8 @@ +const { + genUniModulesExports +} = require('./uni_modules/uni_modules') + +module.exports = function () { + this.cacheable && this.cacheable() + return genUniModulesExports() +} diff --git a/packages/uni-cli-shared/lib/uni_modules/uni_modules.js b/packages/uni-cli-shared/lib/uni_modules/uni_modules.js new file mode 100644 index 0000000000000000000000000000000000000000..ae8b1789eb9f889119fe32afd95f2521431d2f4e --- /dev/null +++ b/packages/uni-cli-shared/lib/uni_modules/uni_modules.js @@ -0,0 +1,109 @@ +'use strict' +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { default: mod } +} +Object.defineProperty(exports, '__esModule', { value: true }) +exports.parseDefines = exports.parseExports = exports.genUniModulesExports = void 0 +const path_1 = __importDefault(require('path')) +const fs_extra_1 = __importDefault(require('fs-extra')) +const merge_1 = require('merge') +function genUniModulesExports () { + const uniModulesDir = path_1.default.resolve(process.env.UNI_INPUT_DIR, 'uni_modules') + if (!fs_extra_1.default.existsSync(uniModulesDir)) { + return '' + } + const importCodes = [] + const assignCodes = [] + fs_extra_1.default.readdirSync(uniModulesDir).forEach((uniModuleDir) => { + var _a, _b + const pkgPath = path_1.default.resolve(uniModulesDir, uniModuleDir, 'package.json') + if (!fs_extra_1.default.existsSync(pkgPath)) { + return + } + const exports = (_b = (_a = JSON.parse(fs_extra_1.default.readFileSync(pkgPath, 'utf8'))) === null || _a === void 0 ? void 0 : _a.uni_modules) === null || _b === void 0 ? void 0 : _b.exports + if (exports) { + const [exportsImportCodes, exportsAssignCodes] = parseExports(process.env.UNI_PLATFORM === 'h5' ? 'web' : process.env.UNI_PLATFORM, `@/uni_modules/${uniModuleDir}`, exports) + importCodes.push(...exportsImportCodes) + assignCodes.push(...exportsAssignCodes) + } + }) + if (!importCodes.length) { + return '' + } + return `${importCodes.join('\n')} +${assignCodes.join('\n')}` +} +exports.genUniModulesExports = genUniModulesExports +function parseExports (platform, source, exports = {}) { + const rootDefines = {} + Object.keys(exports).forEach((name) => { + if (name.startsWith('uni')) { + rootDefines[name] = exports[name] + } + }) + const platformDefines = exports[platform] + // 该平台不支持 + if (platformDefines === false) { + return [[], []] + } + return parseDefines(source, (0, merge_1.recursive)(true, rootDefines, platformDefines)) +} +exports.parseExports = parseExports +function parseDefines (source, defines = {}) { + const importCodes = [] + const assignCodes = [] + Object.keys(defines).forEach((name) => { + const [defineImportCodes, defineAssignCodes] = parseDefine(source, name, defines[name]) + importCodes.push(...defineImportCodes) + assignCodes.push(...defineAssignCodes) + }) + return [importCodes, assignCodes] +} +exports.parseDefines = parseDefines +/** + * uni:'getBatteryInfo' + * import getBatteryInfo from '..' + * + * uni:['getBatteryInfo'] + * import { getBatteryInfo } from '..' + * + * uni:['openLocation','chooseLocation'] + * import { openLocation, chooseLocation } from '..' + * + * uni:{ + * onUserCaptureScreen: "onCaptureScreen" + * offUserCaptureScreen: "offCaptureScreen" + * } + * + * uni.getBatteryInfo = getBatteryInfo + * @param source + * @param globalObject + * @param define + * @returns + */ +function parseDefine (source, globalObject, define) { + const importCodes = [] + const assignCodes = [] + if (typeof define === 'string') { + importCodes.push(`import ${define} from '${source}'`) + assignCodes.push(`${globalObject}.${define} = ${define}`) + } else if (Array.isArray(define)) { + importCodes.push(`import { ${define.join(', ')} } from '${source}'`) + define.forEach((d) => { + assignCodes.push(`${globalObject}.${d} = ${d}`) + }) + } else { + const keys = Object.keys(define) + const specifiers = [] + keys.forEach((d) => { + if (d !== define[d]) { + specifiers.push(`${define[d]} as ${d}`) + } else { + specifiers.push(d) + } + assignCodes.push(`${globalObject}.${d} = ${d}`) + }) + importCodes.push(`import { ${specifiers.join(', ')} } from '${source}'`) + } + return [importCodes, assignCodes] +} diff --git a/packages/uni-cli-shared/lib/util.js b/packages/uni-cli-shared/lib/util.js index 19dc3e8041589bed505dcee966136e36c07a9407..ef07d861dd23bc99150853fd371b29db3236efea 100644 --- a/packages/uni-cli-shared/lib/util.js +++ b/packages/uni-cli-shared/lib/util.js @@ -150,8 +150,17 @@ function pathToGlob (pathString, glob, options = {}) { } return path.posix.join(safeStr, glob) } +/** + * 字节跳动小程序可以配置 ext:// 开头的插件页面模板,如 ext://microapp-trade-plugin/order-confirm + * @param pagePath + * @returns + */ +function isNormalPage (pagePath) { + return !pagePath.startsWith('ext://') +} module.exports = { + isNormalPage, isInHBuilderX, isInHBuilderXAlpha, getCLIContext, diff --git a/packages/uni-h5/manifest.json b/packages/uni-h5/manifest.json index d437330122fc97f39bdf3b38b4a9dc48f063b6f2..f50bb092f21441f7134a64b974b70de37629c76b 100644 --- a/packages/uni-h5/manifest.json +++ b/packages/uni-h5/manifest.json @@ -317,6 +317,30 @@ ] ] ], + "onLocationChange": [ + "/platforms/h5/service/api/location/location-change.js", + [] + ], + "onLocationChangeError": [ + "/platforms/h5/service/api/location/location-change.js", + [] + ], + "startLocationUpdate": [ + "/platforms/h5/service/api/location/location-change.js", + [] + ], + "stopLocationUpdate": [ + "/platforms/h5/service/api/location/location-change.js", + [] + ], + "offLocationChange": [ + "/platforms/h5/service/api/location/location-change.js", + [] + ], + "offLocationChangeError": [ + "/platforms/h5/service/api/location/location-change.js", + [] + ], "chooseImage": [ "/platforms/h5/service/api/media/choose-image.js", [ @@ -359,8 +383,12 @@ "MovableView" ], [ - "/platforms/h5/components/system-routes/preview-image/index.vue", + "/platforms/h5/components/app/popup/preview-image/index.vue", "PreviewImage" + ], + [ + "/platforms/h5/components/app/popup/mixins/preview-image.js", + "PreviewImageMixin" ] ] ], diff --git a/packages/uni-mp-kuaishou/lib/uni.config.js b/packages/uni-mp-kuaishou/lib/uni.config.js index 7ad8172c247cf07adb2c164213f8bdaee2f9f146..da2363cf6561f909a2ea719f9a96b048d2848192 100644 --- a/packages/uni-mp-kuaishou/lib/uni.config.js +++ b/packages/uni-mp-kuaishou/lib/uni.config.js @@ -11,7 +11,8 @@ module.exports = { style: '.css', template: '.ksml' }, - project: 'project.ks.json' + project: 'project.ks.json', + subPackages: true }, copyWebpackOptions (platformOptions, vueOptions) { const copyOptions = ['kscomponents', 'ext.json'] diff --git a/packages/uni-template-compiler/lib/mp.js b/packages/uni-template-compiler/lib/mp.js index 14a3b13505c8d4967977e7f0250f8dac5eb537d5..f495a4b280704a73cdaf3f7cb6f7f24a47c80076 100644 --- a/packages/uni-template-compiler/lib/mp.js +++ b/packages/uni-template-compiler/lib/mp.js @@ -58,7 +58,7 @@ const tags = { 'login', 'inline-payment-panel' ], - 'mp-weixin': [ + 'mp-weixin': [ 'page-container', 'page-meta', 'navigation-bar', @@ -76,7 +76,8 @@ const tags = { 'ix-grid', 'ix-native-grid', 'ix-native-list', - 'mkt' + 'mkt', + 'page-container' ] } @@ -161,4 +162,4 @@ module.exports = function getCompilerOptions (platform) { baseCompiler, require(id + '/lib/uni.compiler.js') ) -} +} diff --git a/packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js b/packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js index 97be217eea33cf3a70872553674c2fd809080151..db325fec1bddf78d7cb6ba90d3b0f111c856fbc7 100644 --- a/packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js +++ b/packages/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js @@ -91,6 +91,7 @@ const plugins = [ UNI_PLATFORM: JSON.stringify(process.env.UNI_PLATFORM), VUE_APP_PLATFORM: JSON.stringify(process.env.UNI_PLATFORM), UNI_CLOUD_PROVIDER: process.env.UNI_CLOUD_PROVIDER, + UNI_SECURE_NETWORK: process.env.UNI_SECURE_NETWORK, UNICLOUD_DEBUG: process.env.UNICLOUD_DEBUG, RUN_BY_HBUILDERX: process.env.RUN_BY_HBUILDERX, UNI_AUTOMATOR_WS_ENDPOINT: JSON.stringify(process.env.UNI_AUTOMATOR_WS_ENDPOINT), diff --git a/packages/vue-cli-plugin-uni/commands/build.js b/packages/vue-cli-plugin-uni/commands/build.js index 0b64298d0bb05a97447db6204f06f545fa066de6..1f927af553188b7f8c2413d8630a7aa647456b03 100644 --- a/packages/vue-cli-plugin-uni/commands/build.js +++ b/packages/vue-cli-plugin-uni/commands/build.js @@ -210,8 +210,7 @@ async function build (args, api, options) { if (process.env.UNI_PLATFORM === 'h5' && !isInHBuilderX) { console.log() - console.log('欢迎将H5站部署到uniCloud前端网页托管平台,高速、免费、安全、省心,详见:') - console.log('https://uniapp.dcloud.io/uniCloud/hosting') + console.log('欢迎将web站点部署到uniCloud前端网页托管平台,高速、免费、安全、省心,详见:https://uniapp.dcloud.io/uniCloud/hosting') } } else { const dirMsg = runByHBuilderX ? '' diff --git a/packages/vue-cli-plugin-uni/generator.js b/packages/vue-cli-plugin-uni/generator.js index 639920ae05c034b81831592eedbb1f365e43c657..ab9f80d23dcd7ed2ba7a9f55a11002b7b7bb613e 100644 --- a/packages/vue-cli-plugin-uni/generator.js +++ b/packages/vue-cli-plugin-uni/generator.js @@ -52,6 +52,7 @@ module.exports = (api, options, rootOptions) => { scripts: {} }, dependencies: { + '@dcloudio/uni-app': version, '@dcloudio/uni-app-plus': version, '@dcloudio/uni-h5': version, '@dcloudio/uni-mp-vue': version, diff --git a/packages/vue-cli-plugin-uni/lib/app-plus/index.js b/packages/vue-cli-plugin-uni/lib/app-plus/index.js index 88935bb52d3043667f7d6c279851986777b0edf4..b0c9abe5ab4d82769f5879659b6f7f7aeab37896 100644 --- a/packages/vue-cli-plugin-uni/lib/app-plus/index.js +++ b/packages/vue-cli-plugin-uni/lib/app-plus/index.js @@ -5,7 +5,8 @@ const { getMainEntry, getPlatformStat, getPlatformPush, - getPlatformUniCloud + getPlatformUniCloud, + uniModulesLoader } = require('@dcloudio/uni-cli-shared') const vueLoader = require('@dcloudio/uni-cli-shared/lib/vue-loader') @@ -65,7 +66,7 @@ const v3 = { const pushCode = getPlatformPush() const uniCloudCode = getPlatformUniCloud() - const beforeCode = 'import \'uni-pages\';' + const beforeCode = `import 'uni-pages';import '${uniModulesLoader}!';` if (!webpackConfig.optimization) { webpackConfig.optimization = {} } @@ -163,7 +164,7 @@ const v3 = { compiler: vueLoader.compiler, before: [ beforeCode + require('../util').getAutomatorCode() + statCode + pushCode + uniCloudCode + - getGlobalUsingComponentsCode() + getGlobalUsingComponentsCode() ] } }] @@ -278,4 +279,4 @@ if (process.env.UNI_USING_V3) { module.exports = v3 } else { module.exports = require('../mp') -} +} diff --git a/packages/vue-cli-plugin-uni/lib/chain-webpack.js b/packages/vue-cli-plugin-uni/lib/chain-webpack.js index b263aca74bafdfccafc5ac9b79dc1cf9e837e9bc..f4076ded6b7b287e16961cc50632e1d8bcfa7b6b 100644 --- a/packages/vue-cli-plugin-uni/lib/chain-webpack.js +++ b/packages/vue-cli-plugin-uni/lib/chain-webpack.js @@ -135,6 +135,7 @@ module.exports = function chainWebpack (platformOptions, vueOptions, api) { 'process.env.UNI_PLATFORM': JSON.stringify(process.env.UNI_PLATFORM), 'process.env.UNI_SUB_PLATFORM': JSON.stringify(process.env.UNI_SUB_PLATFORM), 'process.env.UNI_CLOUD_PROVIDER': process.env.UNI_CLOUD_PROVIDER, + 'process.env.UNI_SECURE_NETWORK': process.env.UNI_SECURE_NETWORK, 'process.env.UNICLOUD_DEBUG': process.env.UNICLOUD_DEBUG, 'process.env.RUN_BY_HBUILDERX': process.env.RUN_BY_HBUILDERX, 'process.env.UNI_AUTOMATOR_WS_ENDPOINT': JSON.stringify(process.env.UNI_AUTOMATOR_WS_ENDPOINT), @@ -160,6 +161,14 @@ module.exports = function chainWebpack (platformOptions, vueOptions, api) { defines.__UNI_ROUTER_MODE__ = JSON.stringify('hash') } + if (process.env.UNI_CLOUD_PROVIDER && process.env.NODE_ENV !== 'development') { + webpackConfig.optimization.minimizer('terser').tap((args) => { + // reduce_vars 优化常量 + args[0].terserOptions.compress.reduce_vars = true + return args + }) + } + webpackConfig .plugin('uni-define') .use(require.resolve('webpack/lib/DefinePlugin'), [defines]) diff --git a/packages/vue-cli-plugin-uni/lib/configure-webpack.js b/packages/vue-cli-plugin-uni/lib/configure-webpack.js index 307619935ed1c60bbc9b2b931396fc19b6f0a86d..40c0eaf8941658ded91381a5248652500b9b5215 100644 --- a/packages/vue-cli-plugin-uni/lib/configure-webpack.js +++ b/packages/vue-cli-plugin-uni/lib/configure-webpack.js @@ -383,7 +383,8 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt JSON.stringify({ type: 'stat' }), - vuex: require.resolve('@dcloudio/vue-cli-plugin-uni/packages/vuex3') + vuex: require.resolve('@dcloudio/vue-cli-plugin-uni/packages/vuex3'), + '@vue/composition-api': require.resolve('@dcloudio/vue-cli-plugin-uni/packages/@vue/composition-api') }, modules: [ process.env.UNI_INPUT_DIR, diff --git a/packages/vue-cli-plugin-uni/lib/env.js b/packages/vue-cli-plugin-uni/lib/env.js index a8b151a51f9429fa8ed3c6d104024dff25d52207..21cbe12718350a50bda884df1889b676ea820f49 100644 --- a/packages/vue-cli-plugin-uni/lib/env.js +++ b/packages/vue-cli-plugin-uni/lib/env.js @@ -24,7 +24,8 @@ const { getManifestJson, isEnableUniPushV1, isEnableUniPushV2, - isUniPushOffline + isUniPushOffline, + isEnableSecureNetwork } = require('@dcloudio/uni-cli-shared/lib/manifest') const manifestJsonObj = getManifestJson() @@ -129,6 +130,9 @@ if (!process.env.UNI_CLOUD_PROVIDER && process.env.UNI_CLOUD_SPACES) { } catch (e) {} } +// 安全网络 +process.env.UNI_SECURE_NETWORK = isEnableSecureNetwork(manifestJsonObj, process.env.UNI_PLATFORM) + // 初始化环境变量 process.env.UNI_CLI_CONTEXT = require('@dcloudio/uni-cli-shared/lib/util').getCLIContext() diff --git a/packages/vue-cli-plugin-uni/lib/h5/index.js b/packages/vue-cli-plugin-uni/lib/h5/index.js index d0d621ba7dffdc612fb12583e6f201d6e0d26e47..e1ebb66350effa1b7115129eed3ae94059c23c57 100644 --- a/packages/vue-cli-plugin-uni/lib/h5/index.js +++ b/packages/vue-cli-plugin-uni/lib/h5/index.js @@ -7,7 +7,8 @@ const { getH5Options, getPlatformStat, getPlatformPush, - getPlatformUniCloud + getPlatformUniCloud, + uniModulesLoader } = require('@dcloudio/uni-cli-shared') const { @@ -103,7 +104,7 @@ module.exports = { } catch (e) {} const beforeCode = (useBuiltIns === 'entry' ? 'import \'@babel/polyfill\';' : '') + - `import 'uni-pages';import 'uni-${process.env.UNI_PLATFORM}';` + `import 'uni-pages';import 'uni-${process.env.UNI_PLATFORM}';import '${uniModulesLoader}!';` return { resolve: { @@ -194,4 +195,4 @@ module.exports = { require('./cssnano-options')(webpackConfig) } } -} +} diff --git a/packages/vue-cli-plugin-uni/lib/mp/index.js b/packages/vue-cli-plugin-uni/lib/mp/index.js index c708a89fd90c7e93842a7a3099e9dfb7a74711c0..b204449d8138fcad2eef3f73c1d29dc960e69483 100644 --- a/packages/vue-cli-plugin-uni/lib/mp/index.js +++ b/packages/vue-cli-plugin-uni/lib/mp/index.js @@ -9,7 +9,8 @@ const { getPlatformCssnano, getPlatformStat, getPlatformPush, - getPlatformUniCloud + getPlatformUniCloud, + uniModulesLoader } = require('@dcloudio/uni-cli-shared') const WebpackUniAppPlugin = require('../../packages/webpack-uni-app-loader/plugin/index') @@ -181,7 +182,7 @@ module.exports = { const pushCode = getPlatformPush() const uniCloudCode = getPlatformUniCloud() - let beforeCode = 'import \'uni-pages\';' + let beforeCode = `import 'uni-pages';import '${uniModulesLoader}!';` const plugins = [ new WebpackUniAppPlugin(), diff --git a/packages/vue-cli-plugin-uni/packages/@vue/composition-api/LICENSE b/packages/vue-cli-plugin-uni/packages/@vue/composition-api/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..1c4bdb5dc69ca69eea38c2227601249c47603447 --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/@vue/composition-api/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019-present, liximomo(X.L) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/vue-cli-plugin-uni/packages/@vue/composition-api/README.md b/packages/vue-cli-plugin-uni/packages/@vue/composition-api/README.md new file mode 100644 index 0000000000000000000000000000000000000000..79908ab5c21267301ef691cdee3348780fdfca38 --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/@vue/composition-api/README.md @@ -0,0 +1,558 @@ +# @vue/composition-api + +Vue 2 plugin for **Composition API** + +[![npm](https://img.shields.io/npm/v/@vue/composition-api)](https://www.npmjs.com/package/@vue/composition-api) +[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/vuejs/composition-api/Build%20&%20Test)](https://github.com/vuejs/composition-api/actions?query=workflow%3A%22Build+%26+Test%22) +[![Minzipped size](https://badgen.net/bundlephobia/minzip/@vue/composition-api)](https://bundlephobia.com/result?p=@vue/composition-api) + +English | [中文](./README.zh-CN.md) ・ [**Composition API Docs**](https://v3.vuejs.org/guide/composition-api-introduction.html) + + +> ⚠️ With the release of [Vue 2.7](https://blog.vuejs.org/posts/vue-2-7-naruto.html), which has Composition API built-in, **you no longer need this plugin**. Thereby this plugin has entered maintenance mode and will only support Vue 2.6 or earlier. This project will reach End of Life by the end of 2022. + +## Installation + +### NPM + +```bash +npm install @vue/composition-api +# or +yarn add @vue/composition-api +``` + +You must install `@vue/composition-api` as a plugin via `Vue.use()` before you can use the [Composition API](https://composition-api.vuejs.org/) to compose your component. + +```js +import Vue from 'vue' +import VueCompositionAPI from '@vue/composition-api' + +Vue.use(VueCompositionAPI) +``` + +```js +// use the APIs +import { ref, reactive } from '@vue/composition-api' +``` + +> :bulb: When you migrate to Vue 3, just replacing `@vue/composition-api` to `vue` and your code should just work. + +### CDN + +Include `@vue/composition-api` after Vue and it will install itself automatically. + + +```html + + +``` + + +`@vue/composition-api` will be exposed to global variable `window.VueCompositionAPI`. + +```ts +const { ref, reactive } = VueCompositionAPI +``` + +## TypeScript Support + +> TypeScript version **>4.2** is required + +To let TypeScript properly infer types inside Vue component options, you need to define components with `defineComponent` + +```ts +import { defineComponent } from '@vue/composition-api' + +export default defineComponent({ + // type inference enabled +}) +``` + +### JSX/TSX + +JSX is now officially supported on [vuejs/jsx](https://github.com/vuejs/jsx). You can enable it by following [this document](https://github.com/vuejs/jsx/tree/dev/packages/babel-preset-jsx#usage). A community maintained version can be found at [babel-preset-vca-jsx](https://github.com/luwanquan/babel-preset-vca-jsx) by [@luwanquan](https://github.com/luwanquan). + +To support TSX, create a declaration file with the following content in your project. + +```ts +// file: shim-tsx.d.ts +import Vue, { VNode } from 'vue'; +import { ComponentRenderProxy } from '@vue/composition-api'; + +declare global { + namespace JSX { + interface Element extends VNode {} + interface ElementClass extends ComponentRenderProxy {} + interface ElementAttributesProperty { + $props: any; // specify the property name to use + } + interface IntrinsicElements { + [elem: string]: any; + } + } +} +``` + +## SSR + +Even if there is no definitive Vue 3 API for SSR yet, this plugin implements the `onServerPrefetch` lifecycle hook that allows you to use the `serverPrefetch` hook found in the classic API. + +```js +import { onServerPrefetch } from '@vue/composition-api' + +export default { + setup(props, { ssrContext }) { + const result = ref() + + onServerPrefetch(async () => { + result.value = await callApi(ssrContext.someId) + }) + + return { + result, + } + } +} +``` + +## Browser Compatibility + +`@vue/composition-api` supports all modern browsers and IE11+. For lower versions IE you should install `WeakMap` polyfill (for example from `core-js` package). + +## Limitations + +> :white_check_mark: Support     :x: Not Supported + +### `Ref` Unwrap + +
+ +❌ Should NOT use ref in a plain object when working with Array + + +```js +const a = { + count: ref(0), +} +const b = reactive({ + list: [a], // `a.count` will not unwrap!! +}) + +// no unwrap for `count`, `.value` is required +b.list[0].count.value === 0 // true +``` + +```js +const b = reactive({ + list: [ + { + count: ref(0), // no unwrap!! + }, + ], +}) + +// no unwrap for `count`, `.value` is required +b.list[0].count.value === 0 // true +``` + +
+ +
+ +✅ Should always use ref in a reactive when working with Array + + +```js +const a = reactive({ + list: [ + reactive({ + count: ref(0), + }), + ] +}) +// unwrapped +a.list[0].count === 0 // true + +a.list.push( + reactive({ + count: ref(1), + }) +) +// unwrapped +a.list[1].count === 1 // true +``` + +
+ +### Template Refs + +
+ +✅ String ref && return it from setup() + + +```html + + + +``` + +
+ +
+ +✅ String ref && return it from setup() && Render Function / JSX + + +```jsx +export default { + setup() { + const root = ref(null) + + onMounted(() => { + // the DOM element will be assigned to the ref after initial render + console.log(root.value) //
+ }) + + return { + root, + } + }, + render() { + // with JSX + return () =>
+ }, +} +``` + +
+ +
+ +❌ Function ref + + +```html + + + +``` + +
+ +
+ +❌ Render Function / JSX in setup() + + +```jsx +export default { + setup() { + const root = ref(null) + + return () => + h('div', { + ref: root, + }) + + // with JSX + return () =>
+ }, +} +``` + +
+ +
+ +⚠️ $refs accessing workaround + + +
+ +> :warning: **Warning**: The `SetupContext.refs` won't exist in `Vue 3.0`. `@vue/composition-api` provide it as a workaround here. + +If you really want to use template refs in this case, you can access `vm.$refs` via `SetupContext.refs` + +```jsx +export default { + setup(initProps, setupContext) { + const refs = setupContext.refs + onMounted(() => { + // the DOM element will be assigned to the ref after initial render + console.log(refs.root) //
+ }) + + return () => + h('div', { + ref: 'root', + }) + + // with JSX + return () =>
+ }, +} +``` + +
+ +### Reactive + +
+ +⚠️ reactive() mutates the original object + + +`reactive` uses `Vue.observable` underneath which will ***mutate*** the original object. + +> :bulb: In Vue 3, it will return an new proxy object. + +
+ +
+ +⚠️ set and del workaround for adding and deleting reactive properties + + +> ⚠️ Warning: `set` and `del` do NOT exist in Vue 3. We provide them as a workaround here, due to the limitation of [Vue 2.x reactivity system](https://vuejs.org/v2/guide/reactivity.html#For-Objects). +> +> In Vue 2, you will need to call `set` to track new keys on an `object`(similar to `Vue.set` but for `reactive objects` created by the Composition API). In Vue 3, you can just assign them like normal objects. +> +> Similarly, in Vue 2 you will need to call `del` to [ensure a key deletion triggers view updates](https://vuejs.org/v2/api/#Vue-delete) in reactive objects (similar to `Vue.delete` but for `reactive objects` created by the Composition API). In Vue 3 you can just delete them by calling `delete foo.bar`. + +```ts +import { reactive, set, del } from '@vue/composition-api' + +const a = reactive({ + foo: 1 +}) + +// add new reactive key +set(a, 'bar', 1) + +// remove a key and trigger reactivity +del(a, 'bar') +``` + +
+ +### Watch + +
+ +❌ onTrack and onTrigger are not available in WatchOptions + + +```js +watch(() => { + /* ... */ +}, { + immediate: true, + onTrack() {}, // not available + onTrigger() {}, // not available +}) +``` + +
+ +### `createApp` + +
+ +⚠️ createApp() is global + + +In Vue 3, `createApp()` is introduced to provide context(plugin, components, etc.) isolation between app instances. Due the the design of Vue 2, in this plugin, we provide `createApp()` as a forward compatible API which is just an alias of the global. + +```ts +const app1 = createApp(RootComponent1) +app1.component('Foo', Foo) // equivalent to Vue.component('Foo', Foo) +app1.use(VueRouter) // equivalent to Vue.use(VueRouter) + +const app2 = createApp(RootComponent2) +app2.component('Bar', Bar) // equivalent to Vue.use('Bar', Bar) +``` + +
+ +### `createElement` / `h` + +
+ +⚠️ createElement / h workaround + + +
+ +`createElement` / `h` in Vue 2 is only accessable in `render()` function. To use it outside of `render()`, you can explicitly bind a component instance to it. + +> :warning: **Warning**: This ability is provided as a workaround Vue 2, it's not part of the Vue 3 API. + +```jsx +import { h as _h } from '@vue/composition-api' + +export default { + setup() { + const vm = getCurrentInstance() + const h = _h.bind(vm) + + return () => + h('div', { + ref: 'root', + }) + }, +} +``` + +
+ + +### `shallowReadonly` + +
+ +⚠️ shallowReadonly() will create a new object and with the same root properties, new properties added will not be readonly or reactive. + + +> :bulb: In Vue 3, it will return an new proxy object. + +
+ +### `readonly` + +
+ +⚠️ readonly() provides only type-level readonly check. + + +`readonly()` is provided as API alignment with Vue 3 on type-level only. Use isReadonly() on it or it's properties can not be guaranteed. + +
+ +### `props` + +
+ +⚠️ toRefs(props.foo) will incorrectly warn when accessing nested levels of props.
+    ⚠️ isReactive(props.foo) will return false. +
+ +```ts +defineComponent({ + setup(props) { + const { bar } = toRefs(props.foo) // it will `warn` + + // use this instead + const { foo } = toRefs(props) + const a = foo.value.bar + } +}) +``` + +
+ +### `computed().effect` + +
+ +⚠️ computed() has a property effect set to true instead of a ReactiveEffect. + + +Due to the difference in implementation, there is no such concept as a `ReactiveEffect` in `@vue/composition-api`. Therefore, `effect` is merely `true` to enable differentiating computed from refs: + +```ts +function isComputed(o: ComputedRef | unknown): o is ComputedRef +function isComputed(o: any): o is ComputedRef { + return !!(isRef(o) && o.effect) +} +``` + +
+ +### Missing APIs + +The following APIs introduced in Vue 3 are not available in this plugin. + +- `onRenderTracked` +- `onRenderTriggered` +- `isProxy` + +### Reactive APIs in `data()` + +
+ +❌ Passing ref, reactive or other reactive apis to data() would not work. + + +```jsx +export default { + data() { + return { + // will result { a: { value: 1 } } in template + a: ref(1), + } + }, +} +``` + +
+ +### `emits` Options + +
+ +❌ emits option is provided in type-level only, in order to align with Vue 3's type interface. Does NOT have actual effects on the code. + + +```ts +defineComponent({ + emits: { + // has no effects + submit: (eventOption) => { + if (...) { + return true + } else { + console.warn('Invalid submit event payload!') + return false + } + } + } +}) +``` + +
+ +### Performance Impact + +Due the the limitation of Vue2's public API. `@vue/composition-api` inevitably introduces some performance overhead. Note that in most scenarios, this shouldn't be the source of performance issues. + +You can check the [benchmark results](https://antfu.github.io/vue-composition-api-benchmark-results/) for more details. diff --git a/packages/vue-cli-plugin-uni/packages/@vue/composition-api/README.zh-CN.md b/packages/vue-cli-plugin-uni/packages/@vue/composition-api/README.zh-CN.md new file mode 100644 index 0000000000000000000000000000000000000000..95fe59e510e59fcb5bb1ce841b0ac908773582e5 --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/@vue/composition-api/README.zh-CN.md @@ -0,0 +1,568 @@ +# @vue/composition-api + +用于提供 **组合式 API** 的 Vue 2 插件. + +[![npm](https://img.shields.io/npm/v/@vue/composition-api)](https://www.npmjs.com/package/@vue/composition-api) +[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/vuejs/composition-api/Build%20&%20Test)](https://github.com/vuejs/composition-api/actions?query=workflow%3A%22Build+%26+Test%22) + +[English](./README.md) | 中文 ・ [**组合式 API 文档**](https://v3.cn.vuejs.org/guide/composition-api-introduction.html) + + +> ⚠️ 随着 [Vue 2.7](https://blog.vuejs.org/posts/vue-2-7-naruto.html)的发布,它内置了Composition API,**你不再需要这个插件了**。因此,这个插件已经进入维护模式,将只支持Vue 2.6 或更早的版本。本项目将在 2022 年底达到生命终点(EOL)。 + +## 安装 + +### NPM + +```bash +npm install @vue/composition-api +# or +yarn add @vue/composition-api +``` + +在使用 `@vue/composition-api` 前,必须先通过 `Vue.use()` 进行安装。之后才可使用新的 [**组合式 API**](https://composition-api.vuejs.org/zh) 进行组件开发。 + +```js +import Vue from 'vue' +import VueCompositionAPI from '@vue/composition-api' + +Vue.use(VueCompositionAPI) +``` + +```js +// 使用 API +import { ref, reactive } from '@vue/composition-api' +``` + +> :bulb: 当迁移到 Vue 3 时,只需简单的将 `@vue/composition-api` 替换成 `vue` 即可。你现有的代码几乎无需进行额外的改动。 + +### CDN + +在 Vue 之后引入 `@vue/composition-api` ,插件将会自动完成安装。 + + +```html + + +``` + + +`@vue/composition-api` 将会暴露在全局变量 `window.VueCompositionAPI` 中。 + +```ts +const { ref, reactive } = VueCompositionAPI +``` + +## TypeScript 支持 + +> 本插件要求使用 TypeScript **4.2** 或以上版本 + +为了让 TypeScript 在 Vue 组件选项中正确地进行类型推导,我们必须使用 `defineComponent` 来定义组件: + +```ts +import { defineComponent } from '@vue/composition-api' + +export default defineComponent({ + // 类型推断启用 +}) +``` + +### JSX/TSX + +JSX 现已在 [vuejs/jsx](https://github.com/vuejs/jsx) 中官方支持。你可以根据[这篇文档](https://github.com/vuejs/jsx/tree/dev/packages/babel-preset-jsx#usage)开启支持。你也可以使用由 [@luwanquan](https://github.com/luwanquan) 维护的社区版本 [babel-preset-vca-jsx](https://github.com/luwanquan/babel-preset-vca-jsx)。 + +对于 TSX 支持,请在你的项目中创建如下声明文件: + +```ts +// file: shim-tsx.d.ts +import Vue, { VNode } from 'vue'; +import { ComponentRenderProxy } from '@vue/composition-api'; + +declare global { + namespace JSX { + interface Element extends VNode {} + interface ElementClass extends ComponentRenderProxy {} + interface ElementAttributesProperty { + $props: any; // specify the property name to use + } + interface IntrinsicElements { + [elem: string]: any; + } + } +} +``` + +## SSR + +尽管 Vue 3 暂时没有给出确定的 SSR 的 API,这个插件实现了 `onServerPrefetch` 生命周期钩子函数。这个钩子允许你使用传统 API 中的 `serverPrefetch` 函数。 + +```js +import { onServerPrefetch } from '@vue/composition-api' + +export default { + setup(props, { ssrContext }) { + const result = ref() + + onServerPrefetch(async () => { + result.value = await callApi(ssrContext.someId) + }) + + return { + result, + } + }, +} +``` + +## 浏览器兼容性 + +`@vue/composition-api` 支持所有现代浏览器以及IE11+。对于更低版本的IE浏览器你需要安装`WeakMap` polyfill (例如使用 `core-js`库)。 + +## 限制 + +> :white_check_mark: 支持     :x: 不支持 + +### `Ref` 自动展开 (unwrap) + +
+ +❌ 不要 在数组中使用含有 ref 的普通对象 + + +```js +const a = { + count: ref(0), +} +const b = reactive({ + list: [a], // `a.count` 不会自动展开!! +}) + +// `count` 不会自动展开, 须使用 `.value` +b.list[0].count.value === 0 // true +``` + +```js +const b = reactive({ + list: [ + { + count: ref(0), // 不会自动展开!! + }, + ], +}) + +// `count` 不会自动展开, 须使用 `.value` +b.list[0].count.value === 0 // true +``` + +
+ +
+ +✅ 在数组中,应该 总是将 ref 存放到 reactive 对象中 + + +```js +const a = reactive({ + count: ref(0), +}) +const b = reactive({ + list: [a], +}) +// 自动展开 +b.list[0].count === 0 // true + +b.list.push( + reactive({ + count: ref(1), + }) +) +// 自动展开 +b.list[1].count === 1 // true +``` + +
+ +### 模板 Refs + +
+ +✅ 字符串 ref && 从 setup() 返回 ref + + +```html + + + +``` + +
+ +
+ +✅ 字符串 ref && 从 setup() 返回 ref && 渲染函数 / JSX + + +```jsx +export default { + setup() { + const root = ref(null) + + onMounted(() => { + // 在初次渲染后 DOM 元素会被赋值给 ref + console.log(root.value) //
+ }) + + return { + root, + } + }, + render() { + // 使用 JSX + return () =>
+ }, +} +``` + +
+ +
+ +❌ 函数 ref + + +```html + + + +``` + +
+ +
+ +❌ 在 setup() 中的渲染函数 / JSX + + +```jsx +export default { + setup() { + const root = ref(null) + + return () => + h('div', { + ref: root, + }) + + // 使用 JSX + return () =>
+ }, +} +``` + +
+ +
+ +⚠️ $refs 访问的变通方案 + + +> :warning: **警告**: `SetupContext.refs` 并非 `Vue 3.0` 的一部分, `@vue/composition-api` 将其暴露在 `SetupContext` 中只是临时提供一种变通方案。 + +如果你依然选择在 `setup()` 中写 `render` 函数,那么你可以使用 `SetupContext.refs` 来访问模板引用,它等价于 Vue 2.x 中的 `this.$refs`: + +```js +export default { + setup(initProps, setupContext) { + const refs = setupContext.refs + onMounted(() => { + // 在初次渲染后 DOM 元素会被赋值给 ref + console.log(refs.root) //
+ }) + + return () => + h('div', { + ref: 'root', + }) + + // 使用 JSX + return () =>
+ }, +} +``` + +如果项目使用了 TypeScript,你还需要扩展 `SetupContext` 类型: + +```ts +import Vue from 'vue' + +declare module '@vue/composition-api' { + interface SetupContext { + readonly refs: { [key: string]: Vue | Element | Vue[] | Element[] } + } +} +``` + +
+ +### Reactive + +
+ +⚠️ reactive() 会返回一个修改过的原始的对象 + + +此行为与 Vue 2 中的 `Vue.observable` 一致 + +> :bulb: 在 Vue 3 中,`reactive()` 会返回一个新的的代理对象 + +
+ +
+ +⚠️ setdel 添加与刪除响应式属性变通方案 + + +> ⚠️ 警告: `set` 和 `del` 并非 Vue 3 的一部分。由于 [Vue 2.x 响应式系统的限制](https://vuejs.org/v2/guide/reactivity.html#For-Objects), 我们在这里提供它们作为一种变通方案。 +> 在 Vue 2中,你将需要调用`set` 去追踪`object`上新的属性 (与`Vue.set`类似,但用于由 Composition API 创建的`reactive objects`)。在 Vue 3 中,你只需要像对待普通对象一样直接为属性赋值即可。 +> +> 同样地, 在 Vue 2 中你将需要调用`del`去 [确保响应式对象中属性的删除将触发视图更新](https://vuejs.org/v2/api/#Vue-delete) (与`Vue.delete`类似,但用于由 Composition API 创建的`reactive objects`)。在Vue3中,你只需要通过调用 `delete foo.bar` 来删除它们。 + +```ts +import { reactive, set, del } from '@vue/composition-api' + +const a = reactive({ + foo: 1 +}) + +// 添加新的响应式属性 +set(a, 'bar', 1) + +// 刪除属性并触发响应式更新 +del(a, 'bar') +``` + +
+ +### Watch + +
+ +❌ 不支持 onTrackonTrigger 选项 + + +```js +watch( + () => { + /* ... */ + }, + { + immediate: true, + onTrack() {}, // 不可用 + onTrigger() {}, // 不可用 + } +) +``` + +
+ +### `createApp` + +
+ +⚠️ createApp() 是全局的 + + +在 Vue3 中,引入了 `createApp()` 来隔离不同应用实例的上下文(plugin, components 等)。 由于 Vue2 的设计,在这个插件中,我们提供 `createApp()` 作为一个向前兼容的 API ,它只是全局的一个别名。 + +```ts +const app1 = createApp(RootComponent1) +app1.component('Foo', Foo) // 相当于 Vue.component('Foo', Foo) +app1.use(VueRouter) // 相当于 Vue.use(VueRouter) + +const app2 = createApp(RootComponent2) +app2.component('Bar', Bar) // 相当于 Vue.use('Bar', Bar) +``` + +
+ +### `createElement` / `h` + +
+ +⚠️ createElement / h 变通方案 + + +
+ +在 Vue2中 `createElement` / `h` 只能通过 `render()` 函数访问。要在 `render()`之外使用它, 你可以显式地给它绑定一个组件实例。 + +> :warning: **警告**: 此功能是作为 Vue 2 的变通方法提供的,它不是 Vue 3 API 的一部分。 + +```jsx +import { h as _h } from '@vue/composition-api' + +export default { + setup() { + const vm = getCurrentInstance() + const h = _h.bind(vm) + + return () => + h('div', { + ref: 'root', + }) + }, +} +``` + +
+ + +### `shallowReadonly` + +
+ +⚠️ shallowReadonly() 会返回一个新的浅拷贝对象,在此之后新加的字段将不会获得只读或响应式状态。 + + +> :bulb: 在 Vue 3 中,`shallowReadonly()` 会返回一个新的的代理对象 + +
+ +### `readonly` + +
+ +⚠️ readonly() 只提供类型层面的只读。 + + +`readonly()` 只在类型层面提供和 Vue 3 的对齐。在其返回值或其属性上使用 isReadonly() 检查的结果将无法保证。 + +
+ +### `props` + +
+ +⚠️ 当使用 toRefs 访问深层属性对象 (如 toRefs(props.foo) 时将会得到不正确的警告。
+     ⚠️ isReactive(props.foo) 将会返回 false。 +
+ +```ts +defineComponent({ + setup(props) { + const { bar } = toRefs(props.foo) // it will `warn` + + // use this instead + const { foo } = toRefs(props) + const a = foo.value.bar + } +}) +``` + +
+ +### `computed().effect` + +
+ +⚠️ computed() 拥有一个被设置为 trueeffect 属性,用来代替 ReactiveEffect。 + + +由于实现上的不同, 在 `@vue/composition-api` 中没有 `ReactiveEffect` 这种概念。 因此, `effect` 为 `true` 只是为了能够区分 computed 和 refs: + +```ts +function isComputed(o: ComputedRef | unknown): o is ComputedRef +function isComputed(o: any): o is ComputedRef { + return !!(isRef(o) && o.effect) +} +``` + +
+ +### 缺失的 API + +以下在 Vue 3 新引入的 API ,在本插件中暂不适用: + +- `onRenderTracked` +- `onRenderTriggered` +- `isProxy` + +### 在 `data()` 中使用组合式 API + +
+ +❌ 在 data() 中使用 ref, reactive 或其他组合式 API 将不会生效 + + +```jsx +export default { + data() { + return { + // 在模版中会成为 { a: { value: 1 } } + a: ref(1), + } + }, +} +``` + +
+ +### `emit` 选项 + +
+ +❌ emit 仅因在类型定义中对齐 Vue3 的选项而提供,不会有任何效果。 + + +```ts +defineComponent({ + emit: { + // 无效 + submit: (eventOption) => { + if (...) { + return true + } else { + console.warn('Invalid submit event payload!') + return false + } + } + } +}) +``` + +
+ +### 性能影响 + +由于 Vue 2 的公共 API 的限制,`@vue/composition-api` 不可避免地引入了额外的性能开销。除非在极端情况下,否则这并不会对你造成影响。 + +你可以查看这个 [跑分结果](https://antfu.github.io/vue-composition-api-benchmark-results/) 了解更多信息。 diff --git a/packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.common.js b/packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.common.js new file mode 100644 index 0000000000000000000000000000000000000000..d9fa3696f7be5ad1f036897ecffb78e9529f118a --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.common.js @@ -0,0 +1,2303 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +/****************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */ +/* global Reflect, Promise */ + +var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); +}; + +function __extends(d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +} + +var __assign = function() { + __assign = Object.assign || function __assign(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; + +function __values(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +} + +function __read(o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +} + +function __spreadArray(to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +} + +/** + * Displays a warning message (using console.error) with a stack trace if the + * function is called inside of active component. + * + * @param message warning message to be displayed + */ +function warn$1(message) { + var _a; + warn(message, (_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy); +} + +var activeEffectScope; +var effectScopeStack = []; +var EffectScopeImpl = /** @class */ (function () { + function EffectScopeImpl(vm) { + this.active = true; + this.effects = []; + this.cleanups = []; + this.vm = vm; + } + EffectScopeImpl.prototype.run = function (fn) { + if (this.active) { + try { + this.on(); + return fn(); + } + finally { + this.off(); + } + } + else { + warn$1("cannot run an inactive effect scope."); + } + return; + }; + EffectScopeImpl.prototype.on = function () { + if (this.active) { + effectScopeStack.push(this); + activeEffectScope = this; + } + }; + EffectScopeImpl.prototype.off = function () { + if (this.active) { + effectScopeStack.pop(); + activeEffectScope = effectScopeStack[effectScopeStack.length - 1]; + } + }; + EffectScopeImpl.prototype.stop = function () { + if (this.active) { + this.vm.$destroy(); + this.effects.forEach(function (e) { return e.stop(); }); + this.cleanups.forEach(function (cleanup) { return cleanup(); }); + this.active = false; + } + }; + return EffectScopeImpl; +}()); +var EffectScope = /** @class */ (function (_super) { + __extends(EffectScope, _super); + function EffectScope(detached) { + if (detached === void 0) { detached = false; } + var _this = this; + var vm = undefined; + withCurrentInstanceTrackingDisabled(function () { + vm = defineComponentInstance(getVueConstructor()); + }); + _this = _super.call(this, vm) || this; + if (!detached) { + recordEffectScope(_this); + } + return _this; + } + return EffectScope; +}(EffectScopeImpl)); +function recordEffectScope(effect, scope) { + var _a; + scope = scope || activeEffectScope; + if (scope && scope.active) { + scope.effects.push(effect); + return; + } + // destroy on parent component unmounted + var vm = (_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy; + vm && vm.$on('hook:destroyed', function () { return effect.stop(); }); +} +function effectScope(detached) { + return new EffectScope(detached); +} +function getCurrentScope() { + return activeEffectScope; +} +function onScopeDispose(fn) { + if (activeEffectScope) { + activeEffectScope.cleanups.push(fn); + } + else { + warn$1("onScopeDispose() is called when there is no active effect scope" + + " to be associated with."); + } +} +/** + * @internal + **/ +function getCurrentScopeVM() { + var _a, _b; + return ((_a = getCurrentScope()) === null || _a === void 0 ? void 0 : _a.vm) || ((_b = getCurrentInstance()) === null || _b === void 0 ? void 0 : _b.proxy); +} +/** + * @internal + **/ +function bindCurrentScopeToVM(vm) { + if (!vm.scope) { + var scope_1 = new EffectScopeImpl(vm.proxy); + vm.scope = scope_1; + vm.proxy.$on('hook:destroyed', function () { return scope_1.stop(); }); + } + return vm.scope; +} + +var vueDependency = undefined; +try { + var requiredVue = require('vue'); + if (requiredVue && isVue(requiredVue)) { + vueDependency = requiredVue; + } + else if (requiredVue && + 'default' in requiredVue && + isVue(requiredVue.default)) { + vueDependency = requiredVue.default; + } +} +catch (_a) { + // not available +} +var vueConstructor = null; +var currentInstance = null; +var currentInstanceTracking = true; +var PluginInstalledFlag = '__composition_api_installed__'; +function isVue(obj) { + return obj && isFunction(obj) && obj.name === 'Vue'; +} +function isVueRegistered(Vue) { + // resolve issue: https://github.com/vuejs/composition-api/issues/876#issue-1087619365 + return vueConstructor && hasOwn(Vue, PluginInstalledFlag); +} +function getVueConstructor() { + { + assert(vueConstructor, "must call Vue.use(VueCompositionAPI) before using any function."); + } + return vueConstructor; +} +// returns registered vue or `vue` dependency +function getRegisteredVueOrDefault() { + var constructor = vueConstructor || vueDependency; + { + assert(constructor, "No vue dependency found."); + } + return constructor; +} +function setVueConstructor(Vue) { + // @ts-ignore + if (vueConstructor && Vue.__proto__ !== vueConstructor.__proto__) { + warn('[vue-composition-api] another instance of Vue installed'); + } + vueConstructor = Vue; + Object.defineProperty(Vue, PluginInstalledFlag, { + configurable: true, + writable: true, + value: true, + }); +} +/** + * For `effectScope` to create instance without populate the current instance + * @internal + **/ +function withCurrentInstanceTrackingDisabled(fn) { + var prev = currentInstanceTracking; + currentInstanceTracking = false; + try { + fn(); + } + finally { + currentInstanceTracking = prev; + } +} +function setCurrentInstance(instance) { + if (!currentInstanceTracking) + return; + var prev = currentInstance; + prev === null || prev === void 0 ? void 0 : prev.scope.off(); + currentInstance = instance; + currentInstance === null || currentInstance === void 0 ? void 0 : currentInstance.scope.on(); +} +function getCurrentInstance() { + return currentInstance; +} +var instanceMapCache = new WeakMap(); +function toVue3ComponentInstance(vm) { + if (instanceMapCache.has(vm)) { + return instanceMapCache.get(vm); + } + var instance = { + proxy: vm, + update: vm.$forceUpdate, + type: vm.$options, + uid: vm._uid, + // $emit is defined on prototype and it expected to be bound + emit: vm.$emit.bind(vm), + parent: null, + root: null, // to be immediately set + }; + bindCurrentScopeToVM(instance); + // map vm.$props = + var instanceProps = [ + 'data', + 'props', + 'attrs', + 'refs', + 'vnode', + 'slots', + ]; + instanceProps.forEach(function (prop) { + proxy(instance, prop, { + get: function () { + return vm["$".concat(prop)]; + }, + }); + }); + proxy(instance, 'isMounted', { + get: function () { + // @ts-expect-error private api + return vm._isMounted; + }, + }); + proxy(instance, 'isUnmounted', { + get: function () { + // @ts-expect-error private api + return vm._isDestroyed; + }, + }); + proxy(instance, 'isDeactivated', { + get: function () { + // @ts-expect-error private api + return vm._inactive; + }, + }); + proxy(instance, 'emitted', { + get: function () { + // @ts-expect-error private api + return vm._events; + }, + }); + instanceMapCache.set(vm, instance); + if (vm.$parent) { + instance.parent = toVue3ComponentInstance(vm.$parent); + } + if (vm.$root) { + instance.root = toVue3ComponentInstance(vm.$root); + } + return instance; +} + +var toString = function (x) { return Object.prototype.toString.call(x); }; +function isNative(Ctor) { + return typeof Ctor === 'function' && /native code/.test(Ctor.toString()); +} +var hasSymbol = typeof Symbol !== 'undefined' && + isNative(Symbol) && + typeof Reflect !== 'undefined' && + isNative(Reflect.ownKeys); +var noopFn = function (_) { return _; }; +function proxy(target, key, _a) { + var get = _a.get, set = _a.set; + Object.defineProperty(target, key, { + enumerable: true, + configurable: true, + get: get || noopFn, + set: set || noopFn, + }); +} +function def(obj, key, val, enumerable) { + Object.defineProperty(obj, key, { + value: val, + enumerable: !!enumerable, + writable: true, + configurable: true, + }); +} +function hasOwn(obj, key) { + return Object.hasOwnProperty.call(obj, key); +} +function assert(condition, msg) { + if (!condition) { + throw new Error("[vue-composition-api] ".concat(msg)); + } +} +function isPrimitive(value) { + return (typeof value === 'string' || + typeof value === 'number' || + // $flow-disable-line + typeof value === 'symbol' || + typeof value === 'boolean'); +} +function isArray(x) { + return Array.isArray(x); +} +var objectToString = Object.prototype.toString; +var toTypeString = function (value) { + return objectToString.call(value); +}; +var isMap = function (val) { + return toTypeString(val) === '[object Map]'; +}; +var isSet = function (val) { + return toTypeString(val) === '[object Set]'; +}; +var MAX_VALID_ARRAY_LENGTH = 4294967295; // Math.pow(2, 32) - 1 +function isValidArrayIndex(val) { + var n = parseFloat(String(val)); + return (n >= 0 && + Math.floor(n) === n && + isFinite(val) && + n <= MAX_VALID_ARRAY_LENGTH); +} +function isObject(val) { + return val !== null && typeof val === 'object'; +} +function isPlainObject(x) { + return toString(x) === '[object Object]'; +} +function isFunction(x) { + return typeof x === 'function'; +} +function isUndef(v) { + return v === undefined || v === null; +} +function warn(msg, vm) { + var Vue = getRegisteredVueOrDefault(); + if (!Vue || !Vue.util) + console.warn("[vue-composition-api] ".concat(msg)); + else + Vue.util.warn(msg, vm); +} +function logError(err, vm, info) { + { + warn("Error in ".concat(info, ": \"").concat(err.toString(), "\""), vm); + } + if (typeof window !== 'undefined' && typeof console !== 'undefined') { + console.error(err); + } + else { + throw err; + } +} +/** + * Object.is polyfill + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is + * */ +function isSame(value1, value2) { + if (value1 === value2) { + return value1 !== 0 || 1 / value1 === 1 / value2; + } + else { + return value1 !== value1 && value2 !== value2; + } +} + +function getCurrentInstanceForFn(hook, target) { + target = target || getCurrentInstance(); + if (!target) { + warn("".concat(hook, " is called when there is no active component instance to be ") + + "associated with. " + + "Lifecycle injection APIs can only be used during execution of setup()."); + } + return target; +} +function defineComponentInstance(Ctor, options) { + if (options === void 0) { options = {}; } + var silent = Ctor.config.silent; + Ctor.config.silent = true; + var vm = new Ctor(options); + Ctor.config.silent = silent; + return vm; +} +function isComponentInstance(obj) { + var Vue = getVueConstructor(); + return Vue && obj instanceof Vue; +} +function createSlotProxy(vm, slotName) { + return (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + if (!vm.$scopedSlots[slotName]) { + return warn("slots.".concat(slotName, "() got called outside of the \"render()\" scope"), vm); + } + return vm.$scopedSlots[slotName].apply(vm, args); + }); +} +function resolveSlots(slots, normalSlots) { + var res; + if (!slots) { + res = {}; + } + else if (slots._normalized) { + // fast path 1: child component re-render only, parent did not change + return slots._normalized; + } + else { + res = {}; + for (var key in slots) { + if (slots[key] && key[0] !== '$') { + res[key] = true; + } + } + } + // expose normal slots on scopedSlots + for (var key in normalSlots) { + if (!(key in res)) { + res[key] = true; + } + } + return res; +} +var vueInternalClasses; +var getVueInternalClasses = function () { + if (!vueInternalClasses) { + var vm = defineComponentInstance(getVueConstructor(), { + computed: { + value: function () { + return 0; + }, + }, + }); + // to get Watcher class + var Watcher = vm._computedWatchers.value.constructor; + // to get Dep class + var Dep = vm._data.__ob__.dep.constructor; + vueInternalClasses = { + Watcher: Watcher, + Dep: Dep, + }; + vm.$destroy(); + } + return vueInternalClasses; +}; + +function createSymbol(name) { + return hasSymbol ? Symbol.for(name) : name; +} +var WatcherPreFlushQueueKey = createSymbol('composition-api.preFlushQueue'); +var WatcherPostFlushQueueKey = createSymbol('composition-api.postFlushQueue'); +// must be a string, symbol key is ignored in reactive +var RefKey = 'composition-api.refKey'; + +var accessModifiedSet = new WeakMap(); +var rawSet = new WeakMap(); +var readonlySet = new WeakMap(); + +/** + * Set a property on an object. Adds the new property, triggers change + * notification and intercept it's subsequent access if the property doesn't + * already exist. + */ +function set$1(target, key, val) { + var Vue = getVueConstructor(); + // @ts-expect-error https://github.com/vuejs/vue/pull/12132 + var _a = Vue.util, warn = _a.warn, defineReactive = _a.defineReactive; + if ((isUndef(target) || isPrimitive(target))) { + warn("Cannot set reactive property on undefined, null, or primitive value: ".concat(target)); + } + var ob = target.__ob__; + function ssrMockReactivity() { + // in SSR, there is no __ob__. Mock for reactivity check + if (ob && isObject(val) && !hasOwn(val, '__ob__')) { + mockReactivityDeep(val); + } + } + if (isArray(target)) { + if (isValidArrayIndex(key)) { + target.length = Math.max(target.length, key); + target.splice(key, 1, val); + ssrMockReactivity(); + return val; + } + else if (key === 'length' && val !== target.length) { + target.length = val; + ob === null || ob === void 0 ? void 0 : ob.dep.notify(); + return val; + } + } + if (key in target && !(key in Object.prototype)) { + target[key] = val; + ssrMockReactivity(); + return val; + } + if (target._isVue || (ob && ob.vmCount)) { + warn('Avoid adding reactive properties to a Vue instance or its root $data ' + + 'at runtime - declare it upfront in the data option.'); + return val; + } + if (!ob) { + target[key] = val; + return val; + } + defineReactive(ob.value, key, val); + // IMPORTANT: define access control before trigger watcher + defineAccessControl(target, key, val); + ssrMockReactivity(); + ob.dep.notify(); + return val; +} + +var _isForceTrigger = false; +function isForceTrigger() { + return _isForceTrigger; +} +function setForceTrigger(v) { + _isForceTrigger = v; +} + +var RefImpl = /** @class */ (function () { + function RefImpl(_a) { + var get = _a.get, set = _a.set; + proxy(this, 'value', { + get: get, + set: set, + }); + } + return RefImpl; +}()); +function createRef(options, isReadonly, isComputed) { + if (isReadonly === void 0) { isReadonly = false; } + if (isComputed === void 0) { isComputed = false; } + var r = new RefImpl(options); + // add effect to differentiate refs from computed + if (isComputed) + r.effect = true; + // seal the ref, this could prevent ref from being observed + // It's safe to seal the ref, since we really shouldn't extend it. + // related issues: #79 + var sealed = Object.seal(r); + if (isReadonly) + readonlySet.set(sealed, true); + return sealed; +} +function ref(raw) { + var _a; + if (isRef(raw)) { + return raw; + } + var value = reactive((_a = {}, _a[RefKey] = raw, _a)); + return createRef({ + get: function () { return value[RefKey]; }, + set: function (v) { return (value[RefKey] = v); }, + }); +} +function isRef(value) { + return value instanceof RefImpl; +} +function unref(ref) { + return isRef(ref) ? ref.value : ref; +} +function toRefs(obj) { + if (!isReactive(obj)) { + warn("toRefs() expects a reactive object but received a plain one."); + } + if (!isPlainObject(obj)) + return obj; + var ret = {}; + for (var key in obj) { + ret[key] = toRef(obj, key); + } + return ret; +} +function customRef(factory) { + var version = ref(0); + return createRef(factory(function () { return void version.value; }, function () { + ++version.value; + })); +} +function toRef(object, key) { + if (!(key in object)) + set$1(object, key, undefined); + var v = object[key]; + if (isRef(v)) + return v; + return createRef({ + get: function () { return object[key]; }, + set: function (v) { return (object[key] = v); }, + }); +} +function shallowRef(raw) { + var _a; + if (isRef(raw)) { + return raw; + } + var value = shallowReactive((_a = {}, _a[RefKey] = raw, _a)); + return createRef({ + get: function () { return value[RefKey]; }, + set: function (v) { return (value[RefKey] = v); }, + }); +} +function triggerRef(value) { + if (!isRef(value)) + return; + setForceTrigger(true); + value.value = value.value; + setForceTrigger(false); +} +function proxyRefs(objectWithRefs) { + var _a, e_1, _b; + if (isReactive(objectWithRefs)) { + return objectWithRefs; + } + var value = reactive((_a = {}, _a[RefKey] = objectWithRefs, _a)); + def(value, RefKey, value[RefKey], false); + var _loop_1 = function (key) { + proxy(value, key, { + get: function () { + if (isRef(value[RefKey][key])) { + return value[RefKey][key].value; + } + return value[RefKey][key]; + }, + set: function (v) { + if (isRef(value[RefKey][key])) { + return (value[RefKey][key].value = unref(v)); + } + value[RefKey][key] = unref(v); + }, + }); + }; + try { + for (var _c = __values(Object.keys(objectWithRefs)), _d = _c.next(); !_d.done; _d = _c.next()) { + var key = _d.value; + _loop_1(key); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_d && !_d.done && (_b = _c.return)) _b.call(_c); + } + finally { if (e_1) throw e_1.error; } + } + return value; +} + +var SKIPFLAG = '__v_skip'; +function isRaw(obj) { + var _a; + return Boolean(obj && + hasOwn(obj, '__ob__') && + typeof obj.__ob__ === 'object' && + ((_a = obj.__ob__) === null || _a === void 0 ? void 0 : _a[SKIPFLAG])); +} +function isReactive(obj) { + var _a; + return Boolean(obj && + hasOwn(obj, '__ob__') && + typeof obj.__ob__ === 'object' && + !((_a = obj.__ob__) === null || _a === void 0 ? void 0 : _a[SKIPFLAG])); +} +/** + * Proxing property access of target. + * We can do unwrapping and other things here. + */ +function setupAccessControl(target) { + if (!isPlainObject(target) || + isRaw(target) || + isArray(target) || + isRef(target) || + isComponentInstance(target) || + accessModifiedSet.has(target)) + return; + accessModifiedSet.set(target, true); + var keys = Object.keys(target); + for (var i = 0; i < keys.length; i++) { + defineAccessControl(target, keys[i]); + } +} +/** + * Auto unwrapping when access property + */ +function defineAccessControl(target, key, val) { + if (key === '__ob__') + return; + if (isRaw(target[key])) + return; + var getter; + var setter; + var property = Object.getOwnPropertyDescriptor(target, key); + if (property) { + if (property.configurable === false) { + return; + } + getter = property.get; + setter = property.set; + if ((!getter || setter) /* not only have getter */ && + arguments.length === 2) { + val = target[key]; + } + } + setupAccessControl(val); + proxy(target, key, { + get: function getterHandler() { + var value = getter ? getter.call(target) : val; + // if the key is equal to RefKey, skip the unwrap logic + if (key !== RefKey && isRef(value)) { + return value.value; + } + else { + return value; + } + }, + set: function setterHandler(newVal) { + if (getter && !setter) + return; + // If the key is equal to RefKey, skip the unwrap logic + // If and only if "value" is ref and "newVal" is not a ref, + // the assignment should be proxied to "value" ref. + if (key !== RefKey && isRef(val) && !isRef(newVal)) { + val.value = newVal; + } + else if (setter) { + setter.call(target, newVal); + val = newVal; + } + else { + val = newVal; + } + setupAccessControl(newVal); + }, + }); +} +function observe(obj) { + var Vue = getRegisteredVueOrDefault(); + var observed; + if (Vue.observable) { + observed = Vue.observable(obj); + } + else { + var vm = defineComponentInstance(Vue, { + data: { + $$state: obj, + }, + }); + observed = vm._data.$$state; + } + // in SSR, there is no __ob__. Mock for reactivity check + if (!hasOwn(observed, '__ob__')) { + mockReactivityDeep(observed); + } + return observed; +} +/** + * Mock __ob__ for object recursively + */ +function mockReactivityDeep(obj, seen) { + var e_1, _a; + if (seen === void 0) { seen = new Set(); } + if (seen.has(obj) || hasOwn(obj, '__ob__') || !Object.isExtensible(obj)) + return; + def(obj, '__ob__', mockObserver(obj)); + seen.add(obj); + try { + for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) { + var key = _c.value; + var value = obj[key]; + if (!(isPlainObject(value) || isArray(value)) || + isRaw(value) || + !Object.isExtensible(value)) { + continue; + } + mockReactivityDeep(value, seen); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } +} +function mockObserver(value) { + if (value === void 0) { value = {}; } + return { + value: value, + dep: { + notify: noopFn, + depend: noopFn, + addSub: noopFn, + removeSub: noopFn, + }, + }; +} +function createObserver() { + return observe({}).__ob__; +} +function shallowReactive(obj) { + var e_2, _a; + if (!isObject(obj)) { + { + warn('"shallowReactive()" must be called on an object.'); + } + return obj; + } + if (!(isPlainObject(obj) || isArray(obj)) || + isRaw(obj) || + !Object.isExtensible(obj)) { + return obj; + } + var observed = observe(isArray(obj) ? [] : {}); + var ob = observed.__ob__; + var _loop_1 = function (key) { + var val = obj[key]; + var getter; + var setter; + var property = Object.getOwnPropertyDescriptor(obj, key); + if (property) { + if (property.configurable === false) { + return "continue"; + } + getter = property.get; + setter = property.set; + } + proxy(observed, key, { + get: function getterHandler() { + var _a; + (_a = ob.dep) === null || _a === void 0 ? void 0 : _a.depend(); + return val; + }, + set: function setterHandler(newVal) { + var _a; + if (getter && !setter) + return; + if (!isForceTrigger() && val === newVal) + return; + if (setter) { + setter.call(obj, newVal); + } + else { + val = newVal; + } + (_a = ob.dep) === null || _a === void 0 ? void 0 : _a.notify(); + }, + }); + }; + try { + for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) { + var key = _c.value; + _loop_1(key); + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_2) throw e_2.error; } + } + return observed; +} +/** + * Make obj reactivity + */ +function reactive(obj) { + if (!isObject(obj)) { + { + warn('"reactive()" must be called on an object.'); + } + return obj; + } + if (!(isPlainObject(obj) || isArray(obj)) || + isRaw(obj) || + !Object.isExtensible(obj)) { + return obj; + } + var observed = observe(obj); + setupAccessControl(observed); + return observed; +} +/** + * Make sure obj can't be a reactive + */ +function markRaw(obj) { + if (!(isPlainObject(obj) || isArray(obj)) || !Object.isExtensible(obj)) { + return obj; + } + // set the vue observable flag at obj + var ob = createObserver(); + ob[SKIPFLAG] = true; + def(obj, '__ob__', ob); + // mark as Raw + rawSet.set(obj, true); + return obj; +} +function toRaw(observed) { + var _a; + if (isRaw(observed) || !Object.isExtensible(observed)) { + return observed; + } + return ((_a = observed === null || observed === void 0 ? void 0 : observed.__ob__) === null || _a === void 0 ? void 0 : _a.value) || observed; +} + +function isReadonly(obj) { + return readonlySet.has(obj); +} +/** + * **In @vue/composition-api, `reactive` only provides type-level readonly check** + * + * Creates a readonly copy of the original object. Note the returned copy is not + * made reactive, but `readonly` can be called on an already reactive object. + */ +function readonly(target) { + if (!isObject(target)) { + warn("value cannot be made reactive: ".concat(String(target))); + } + else { + readonlySet.set(target, true); + } + return target; +} +function shallowReadonly(obj) { + var e_1, _a; + if (!isObject(obj)) { + { + warn("value cannot be made reactive: ".concat(String(obj))); + } + return obj; + } + if (!(isPlainObject(obj) || isArray(obj)) || + (!Object.isExtensible(obj) && !isRef(obj))) { + return obj; + } + var readonlyObj = isRef(obj) + ? new RefImpl({}) + : isReactive(obj) + ? observe({}) + : {}; + var source = reactive({}); + var ob = source.__ob__; + var _loop_1 = function (key) { + var val = obj[key]; + var getter; + var property = Object.getOwnPropertyDescriptor(obj, key); + if (property) { + if (property.configurable === false && !isRef(obj)) { + return "continue"; + } + getter = property.get; + } + proxy(readonlyObj, key, { + get: function getterHandler() { + var value = getter ? getter.call(obj) : val; + ob.dep.depend(); + return value; + }, + set: function (v) { + { + warn("Set operation on key \"".concat(key, "\" failed: target is readonly.")); + } + }, + }); + }; + try { + for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) { + var key = _c.value; + _loop_1(key); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } + readonlySet.set(readonlyObj, true); + return readonlyObj; +} + +/** + * Delete a property and trigger change if necessary. + */ +function del(target, key) { + var Vue = getVueConstructor(); + var warn = Vue.util.warn; + if ((isUndef(target) || isPrimitive(target))) { + warn("Cannot delete reactive property on undefined, null, or primitive value: ".concat(target)); + } + if (isArray(target) && isValidArrayIndex(key)) { + target.splice(key, 1); + return; + } + var ob = target.__ob__; + if (target._isVue || (ob && ob.vmCount)) { + warn('Avoid deleting properties on a Vue instance or its root $data ' + + '- just set it to null.'); + return; + } + if (!hasOwn(target, key)) { + return; + } + delete target[key]; + if (!ob) { + return; + } + ob.dep.notify(); +} + +var genName = function (name) { return "on".concat(name[0].toUpperCase() + name.slice(1)); }; +function createLifeCycle(lifeCyclehook) { + return function (callback, target) { + var instance = getCurrentInstanceForFn(genName(lifeCyclehook), target); + return (instance && + injectHookOption(getVueConstructor(), instance, lifeCyclehook, callback)); + }; +} +function injectHookOption(Vue, instance, hook, val) { + var options = instance.proxy.$options; + var mergeFn = Vue.config.optionMergeStrategies[hook]; + var wrappedHook = wrapHookCall(instance, val); + options[hook] = mergeFn(options[hook], wrappedHook); + return wrappedHook; +} +function wrapHookCall(instance, fn) { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var prev = getCurrentInstance(); + setCurrentInstance(instance); + try { + return fn.apply(void 0, __spreadArray([], __read(args), false)); + } + finally { + setCurrentInstance(prev); + } + }; +} +var onBeforeMount = createLifeCycle('beforeMount'); +var onMounted = createLifeCycle('mounted'); +var onBeforeUpdate = createLifeCycle('beforeUpdate'); +var onUpdated = createLifeCycle('updated'); +var onBeforeUnmount = createLifeCycle('beforeDestroy'); +var onUnmounted = createLifeCycle('destroyed'); +var onErrorCaptured = createLifeCycle('errorCaptured'); +var onActivated = createLifeCycle('activated'); +var onDeactivated = createLifeCycle('deactivated'); +var onServerPrefetch = createLifeCycle('serverPrefetch'); + +var fallbackVM; +function flushPreQueue() { + flushQueue(this, WatcherPreFlushQueueKey); +} +function flushPostQueue() { + flushQueue(this, WatcherPostFlushQueueKey); +} +function hasWatchEnv(vm) { + return vm[WatcherPreFlushQueueKey] !== undefined; +} +function installWatchEnv(vm) { + vm[WatcherPreFlushQueueKey] = []; + vm[WatcherPostFlushQueueKey] = []; + vm.$on('hook:beforeUpdate', flushPreQueue); + vm.$on('hook:updated', flushPostQueue); +} +function getWatcherOption(options) { + return __assign({ + immediate: false, + deep: false, + flush: 'pre', + }, options); +} +function getWatchEffectOption(options) { + return __assign({ + flush: 'pre', + }, options); +} +function getWatcherVM() { + var vm = getCurrentScopeVM(); + if (!vm) { + if (!fallbackVM) { + fallbackVM = defineComponentInstance(getVueConstructor()); + } + vm = fallbackVM; + } + else if (!hasWatchEnv(vm)) { + installWatchEnv(vm); + } + return vm; +} +function flushQueue(vm, key) { + var queue = vm[key]; + for (var index = 0; index < queue.length; index++) { + queue[index](); + } + queue.length = 0; +} +function queueFlushJob(vm, fn, mode) { + // flush all when beforeUpdate and updated are not fired + var fallbackFlush = function () { + vm.$nextTick(function () { + if (vm[WatcherPreFlushQueueKey].length) { + flushQueue(vm, WatcherPreFlushQueueKey); + } + if (vm[WatcherPostFlushQueueKey].length) { + flushQueue(vm, WatcherPostFlushQueueKey); + } + }); + }; + switch (mode) { + case 'pre': + fallbackFlush(); + vm[WatcherPreFlushQueueKey].push(fn); + break; + case 'post': + fallbackFlush(); + vm[WatcherPostFlushQueueKey].push(fn); + break; + default: + assert(false, "flush must be one of [\"post\", \"pre\", \"sync\"], but got ".concat(mode)); + break; + } +} +function createVueWatcher(vm, getter, callback, options) { + var index = vm._watchers.length; + // @ts-ignore: use undocumented options + vm.$watch(getter, callback, { + immediate: options.immediateInvokeCallback, + deep: options.deep, + lazy: options.noRun, + sync: options.sync, + before: options.before, + }); + return vm._watchers[index]; +} +// We have to monkeypatch the teardown function so Vue will run +// runCleanup() when it tears down the watcher on unmounted. +function patchWatcherTeardown(watcher, runCleanup) { + var _teardown = watcher.teardown; + watcher.teardown = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + _teardown.apply(watcher, args); + runCleanup(); + }; +} +function createWatcher(vm, source, cb, options) { + var _a; + if (!cb) { + if (options.immediate !== undefined) { + warn("watch() \"immediate\" option is only respected when using the " + + "watch(source, callback, options?) signature."); + } + if (options.deep !== undefined) { + warn("watch() \"deep\" option is only respected when using the " + + "watch(source, callback, options?) signature."); + } + } + var flushMode = options.flush; + var isSync = flushMode === 'sync'; + var cleanup; + var registerCleanup = function (fn) { + cleanup = function () { + try { + fn(); + } + catch ( + // FIXME: remove any + error) { + logError(error, vm, 'onCleanup()'); + } + }; + }; + // cleanup before running getter again + var runCleanup = function () { + if (cleanup) { + cleanup(); + cleanup = null; + } + }; + var createScheduler = function (fn) { + if (isSync || + /* without a current active instance, ignore pre|post mode */ vm === + fallbackVM) { + return fn; + } + return (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return queueFlushJob(vm, function () { + fn.apply(void 0, __spreadArray([], __read(args), false)); + }, flushMode); + }); + }; + // effect watch + if (cb === null) { + var running_1 = false; + var getter_1 = function () { + // preventing the watch callback being call in the same execution + if (running_1) { + return; + } + try { + running_1 = true; + source(registerCleanup); + } + finally { + running_1 = false; + } + }; + var watcher_1 = createVueWatcher(vm, getter_1, noopFn, { + deep: options.deep || false, + sync: isSync, + before: runCleanup, + }); + patchWatcherTeardown(watcher_1, runCleanup); + // enable the watcher update + watcher_1.lazy = false; + var originGet = watcher_1.get.bind(watcher_1); + // always run watchEffect + watcher_1.get = createScheduler(originGet); + return function () { + watcher_1.teardown(); + }; + } + var deep = options.deep; + var isMultiSource = false; + var getter; + if (isRef(source)) { + getter = function () { return source.value; }; + } + else if (isReactive(source)) { + getter = function () { return source; }; + deep = true; + } + else if (isArray(source)) { + isMultiSource = true; + getter = function () { + return source.map(function (s) { + if (isRef(s)) { + return s.value; + } + else if (isReactive(s)) { + return traverse(s); + } + else if (isFunction(s)) { + return s(); + } + else { + warn("Invalid watch source: ".concat(JSON.stringify(s), ".\n A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types."), vm); + return noopFn; + } + }); + }; + } + else if (isFunction(source)) { + getter = source; + } + else { + getter = noopFn; + warn("Invalid watch source: ".concat(JSON.stringify(source), ".\n A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types."), vm); + } + if (deep) { + var baseGetter_1 = getter; + getter = function () { return traverse(baseGetter_1()); }; + } + var applyCb = function (n, o) { + if (!deep && + isMultiSource && + n.every(function (v, i) { return isSame(v, o[i]); })) + return; + // cleanup before running cb again + runCleanup(); + return cb(n, o, registerCleanup); + }; + var callback = createScheduler(applyCb); + if (options.immediate) { + var originalCallback_1 = callback; + // `shiftCallback` is used to handle the first sync effect run. + // The subsequent callbacks will redirect to `callback`. + var shiftCallback_1 = function (n, o) { + shiftCallback_1 = originalCallback_1; + // o is undefined on the first call + return applyCb(n, isArray(n) ? [] : o); + }; + callback = function (n, o) { + return shiftCallback_1(n, o); + }; + } + // @ts-ignore: use undocumented option "sync" + var stop = vm.$watch(getter, callback, { + immediate: options.immediate, + deep: deep, + sync: isSync, + }); + // Once again, we have to hack the watcher for proper teardown + var watcher = vm._watchers[vm._watchers.length - 1]; + // if the return value is reactive and deep:true + // watch for changes, this might happen when new key is added + if (isReactive(watcher.value) && ((_a = watcher.value.__ob__) === null || _a === void 0 ? void 0 : _a.dep) && deep) { + watcher.value.__ob__.dep.addSub({ + update: function () { + // this will force the source to be revaluated and the callback + // executed if needed + watcher.run(); + }, + }); + } + patchWatcherTeardown(watcher, runCleanup); + return function () { + stop(); + }; +} +function watchEffect(effect, options) { + var opts = getWatchEffectOption(options); + var vm = getWatcherVM(); + return createWatcher(vm, effect, null, opts); +} +function watchPostEffect(effect) { + return watchEffect(effect, { flush: 'post' }); +} +function watchSyncEffect(effect) { + return watchEffect(effect, { flush: 'sync' }); +} +// implementation +function watch(source, cb, options) { + var callback = null; + if (isFunction(cb)) { + // source watch + callback = cb; + } + else { + // effect watch + { + warn("`watch(fn, options?)` signature has been moved to a separate API. " + + "Use `watchEffect(fn, options?)` instead. `watch` now only " + + "supports `watch(source, cb, options?) signature."); + } + options = cb; + callback = null; + } + var opts = getWatcherOption(options); + var vm = getWatcherVM(); + return createWatcher(vm, source, callback, opts); +} +function traverse(value, seen) { + if (seen === void 0) { seen = new Set(); } + if (!isObject(value) || seen.has(value) || rawSet.has(value)) { + return value; + } + seen.add(value); + if (isRef(value)) { + traverse(value.value, seen); + } + else if (isArray(value)) { + for (var i = 0; i < value.length; i++) { + traverse(value[i], seen); + } + } + else if (isSet(value) || isMap(value)) { + value.forEach(function (v) { + traverse(v, seen); + }); + } + else if (isPlainObject(value)) { + for (var key in value) { + traverse(value[key], seen); + } + } + return value; +} + +// implement +function computed(getterOrOptions) { + var vm = getCurrentScopeVM(); + var getter; + var setter; + if (isFunction(getterOrOptions)) { + getter = getterOrOptions; + } + else { + getter = getterOrOptions.get; + setter = getterOrOptions.set; + } + var computedSetter; + var computedGetter; + if (vm && !vm.$isServer) { + var _a = getVueInternalClasses(), Watcher_1 = _a.Watcher, Dep_1 = _a.Dep; + var watcher_1; + computedGetter = function () { + if (!watcher_1) { + watcher_1 = new Watcher_1(vm, getter, noopFn, { lazy: true }); + } + if (watcher_1.dirty) { + watcher_1.evaluate(); + } + if (Dep_1.target) { + watcher_1.depend(); + } + return watcher_1.value; + }; + computedSetter = function (v) { + if (!setter) { + warn('Write operation failed: computed value is readonly.', vm); + return; + } + if (setter) { + setter(v); + } + }; + } + else { + // fallback + var computedHost_1 = defineComponentInstance(getVueConstructor(), { + computed: { + $$state: { + get: getter, + set: setter, + }, + }, + }); + vm && vm.$on('hook:destroyed', function () { return computedHost_1.$destroy(); }); + computedGetter = function () { return computedHost_1.$$state; }; + computedSetter = function (v) { + if (!setter) { + warn('Write operation failed: computed value is readonly.', vm); + return; + } + computedHost_1.$$state = v; + }; + } + return createRef({ + get: computedGetter, + set: computedSetter, + }, !setter, true); +} + +var NOT_FOUND = {}; +function resolveInject(provideKey, vm) { + var source = vm; + while (source) { + // @ts-ignore + if (source._provided && hasOwn(source._provided, provideKey)) { + //@ts-ignore + return source._provided[provideKey]; + } + source = source.$parent; + } + return NOT_FOUND; +} +function provide(key, value) { + var _a; + var vm = (_a = getCurrentInstanceForFn('provide')) === null || _a === void 0 ? void 0 : _a.proxy; + if (!vm) + return; + if (!vm._provided) { + var provideCache_1 = {}; + proxy(vm, '_provided', { + get: function () { return provideCache_1; }, + set: function (v) { return Object.assign(provideCache_1, v); }, + }); + } + vm._provided[key] = value; +} +function inject(key, defaultValue, treatDefaultAsFactory) { + var _a; + if (treatDefaultAsFactory === void 0) { treatDefaultAsFactory = false; } + var vm = (_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy; + if (!vm) { + warn("inject() can only be used inside setup() or functional components."); + return; + } + if (!key) { + warn("injection \"".concat(String(key), "\" not found."), vm); + return defaultValue; + } + var val = resolveInject(key, vm); + if (val !== NOT_FOUND) { + return val; + } + else if (arguments.length > 1) { + return treatDefaultAsFactory && isFunction(defaultValue) + ? defaultValue() + : defaultValue; + } + else { + warn("Injection \"".concat(String(key), "\" not found."), vm); + } +} + +var EMPTY_OBJ = Object.freeze({}) + ; +var useCssModule = function (name) { + var _a; + if (name === void 0) { name = '$style'; } + var instance = getCurrentInstance(); + if (!instance) { + warn("useCssModule must be called inside setup()"); + return EMPTY_OBJ; + } + var mod = (_a = instance.proxy) === null || _a === void 0 ? void 0 : _a[name]; + if (!mod) { + warn("Current instance does not have CSS module named \"".concat(name, "\".")); + return EMPTY_OBJ; + } + return mod; +}; +/** + * @deprecated use `useCssModule` instead. + */ +var useCSSModule = useCssModule; + +function createApp(rootComponent, rootProps) { + if (rootProps === void 0) { rootProps = undefined; } + var V = getVueConstructor(); + var mountedVM = undefined; + var provide = {}; + var app = { + config: V.config, + use: V.use.bind(V), + mixin: V.mixin.bind(V), + component: V.component.bind(V), + provide: function (key, value) { + provide[key] = value; + return this; + }, + directive: function (name, dir) { + if (dir) { + V.directive(name, dir); + return app; + } + else { + return V.directive(name); + } + }, + mount: function (el, hydrating) { + if (!mountedVM) { + mountedVM = new V(__assign(__assign({ propsData: rootProps }, rootComponent), { provide: __assign(__assign({}, provide), rootComponent.provide) })); + mountedVM.$mount(el, hydrating); + return mountedVM; + } + else { + { + warn("App has already been mounted.\n" + + "If you want to remount the same app, move your app creation logic " + + "into a factory function and create fresh app instances for each " + + "mount - e.g. `const createMyApp = () => createApp(App)`"); + } + return mountedVM; + } + }, + unmount: function () { + if (mountedVM) { + mountedVM.$destroy(); + mountedVM = undefined; + } + else { + warn("Cannot unmount an app that is not mounted."); + } + }, + }; + return app; +} + +var nextTick = function nextTick() { + var _a; + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return (_a = getVueConstructor()) === null || _a === void 0 ? void 0 : _a.nextTick.apply(this, args); +}; + +var fallbackCreateElement; +var createElement = function createElement() { + var _a; + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var instance = (this === null || this === void 0 ? void 0 : this.proxy) || ((_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy); + if (!instance) { + warn('`createElement()` has been called outside of render function.'); + if (!fallbackCreateElement) { + fallbackCreateElement = defineComponentInstance(getVueConstructor()).$createElement; + } + return fallbackCreateElement.apply(fallbackCreateElement, args); + } + return instance.$createElement.apply(instance, args); +}; + +function useSlots() { + return getContext().slots; +} +function useAttrs() { + return getContext().attrs; +} +function getContext() { + var i = getCurrentInstance(); + if (!i) { + warn("useContext() called without active instance."); + } + return i.setupContext; +} + +function set(vm, key, value) { + var state = (vm.__composition_api_state__ = + vm.__composition_api_state__ || {}); + state[key] = value; +} +function get(vm, key) { + return (vm.__composition_api_state__ || {})[key]; +} +var vmStateManager = { + set: set, + get: get, +}; + +function asVmProperty(vm, propName, propValue) { + var props = vm.$options.props; + if (!(propName in vm) && !(props && hasOwn(props, propName))) { + if (isRef(propValue)) { + proxy(vm, propName, { + get: function () { return propValue.value; }, + set: function (val) { + propValue.value = val; + }, + }); + } + else { + proxy(vm, propName, { + get: function () { + if (isReactive(propValue)) { + propValue.__ob__.dep.depend(); + } + return propValue; + }, + set: function (val) { + propValue = val; + }, + }); + } + { + // expose binding to Vue Devtool as a data property + // delay this until state has been resolved to prevent repeated works + vm.$nextTick(function () { + if (Object.keys(vm._data).indexOf(propName) !== -1) { + return; + } + if (isRef(propValue)) { + proxy(vm._data, propName, { + get: function () { return propValue.value; }, + set: function (val) { + propValue.value = val; + }, + }); + } + else { + proxy(vm._data, propName, { + get: function () { return propValue; }, + set: function (val) { + propValue = val; + }, + }); + } + }); + } + } + else { + if (props && hasOwn(props, propName)) { + warn("The setup binding property \"".concat(propName, "\" is already declared as a prop."), vm); + } + else { + warn("The setup binding property \"".concat(propName, "\" is already declared."), vm); + } + } +} +function updateTemplateRef(vm) { + var rawBindings = vmStateManager.get(vm, 'rawBindings') || {}; + if (!rawBindings || !Object.keys(rawBindings).length) + return; + var refs = vm.$refs; + var oldRefKeys = vmStateManager.get(vm, 'refs') || []; + for (var index = 0; index < oldRefKeys.length; index++) { + var key = oldRefKeys[index]; + var setupValue = rawBindings[key]; + if (!refs[key] && setupValue && isRef(setupValue)) { + setupValue.value = null; + } + } + var newKeys = Object.keys(refs); + var validNewKeys = []; + for (var index = 0; index < newKeys.length; index++) { + var key = newKeys[index]; + var setupValue = rawBindings[key]; + if (refs[key] && setupValue && isRef(setupValue)) { + setupValue.value = refs[key]; + validNewKeys.push(key); + } + } + vmStateManager.set(vm, 'refs', validNewKeys); +} +function afterRender(vm) { + var stack = [vm._vnode]; + var updated; + while (stack.length) { + var vnode = stack.pop(); + if (vnode) { + if (vnode.context) { + updateTemplateRef(vnode.context); + updated = true; + } + if (vnode.children) { + for (var i = 0; i < vnode.children.length; ++i) { + stack.push(vnode.children[i]); + } + } + } + } + if (!updated) { + updateTemplateRef(vm); + } +} +function updateVmAttrs(vm, ctx) { + var e_1, _a; + if (!vm) { + return; + } + var attrBindings = vmStateManager.get(vm, 'attrBindings'); + if (!attrBindings && !ctx) { + // fix 840 + return; + } + if (!attrBindings) { + var observedData = reactive({}); + attrBindings = { ctx: ctx, data: observedData }; + vmStateManager.set(vm, 'attrBindings', attrBindings); + proxy(ctx, 'attrs', { + get: function () { + return attrBindings === null || attrBindings === void 0 ? void 0 : attrBindings.data; + }, + set: function () { + warn("Cannot assign to '$attrs' because it is a read-only property", vm); + }, + }); + } + var source = vm.$attrs; + var _loop_1 = function (attr) { + if (!hasOwn(attrBindings.data, attr)) { + proxy(attrBindings.data, attr, { + get: function () { + // to ensure it always return the latest value + return vm.$attrs[attr]; + }, + }); + } + }; + try { + for (var _b = __values(Object.keys(source)), _c = _b.next(); !_c.done; _c = _b.next()) { + var attr = _c.value; + _loop_1(attr); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } +} +function resolveScopedSlots(vm, slotsProxy) { + var parentVNode = vm.$options._parentVnode; + if (!parentVNode) + return; + var prevSlots = vmStateManager.get(vm, 'slots') || []; + var curSlots = resolveSlots(parentVNode.data.scopedSlots, vm.$slots); + // remove staled slots + for (var index = 0; index < prevSlots.length; index++) { + var key = prevSlots[index]; + if (!curSlots[key]) { + delete slotsProxy[key]; + } + } + // proxy fresh slots + var slotNames = Object.keys(curSlots); + for (var index = 0; index < slotNames.length; index++) { + var key = slotNames[index]; + if (!slotsProxy[key]) { + slotsProxy[key] = createSlotProxy(vm, key); + } + } + vmStateManager.set(vm, 'slots', slotNames); +} +function activateCurrentInstance(instance, fn, onError) { + var preVm = getCurrentInstance(); + setCurrentInstance(instance); + try { + return fn(instance); + } + catch ( + // FIXME: remove any + err) { + if (onError) { + onError(err); + } + else { + throw err; + } + } + finally { + setCurrentInstance(preVm); + } +} + +function mixin(Vue) { + Vue.mixin({ + beforeCreate: functionApiInit, + mounted: function () { + afterRender(this); + }, + beforeUpdate: function () { + updateVmAttrs(this); + }, + updated: function () { + afterRender(this); + }, + }); + /** + * Vuex init hook, injected into each instances init hooks list. + */ + function functionApiInit() { + var vm = this; + var $options = vm.$options; + var setup = $options.setup, render = $options.render; + if (render) { + // keep currentInstance accessible for createElement + $options.render = function () { + var _this = this; + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return activateCurrentInstance(toVue3ComponentInstance(vm), function () { + return render.apply(_this, args); + }); + }; + } + if (!setup) { + return; + } + if (!isFunction(setup)) { + { + warn('The "setup" option should be a function that returns a object in component definitions.', vm); + } + return; + } + var data = $options.data; + // wrapper the data option, so we can invoke setup before data get resolved + $options.data = function wrappedData() { + initSetup(vm, vm.$props); + return isFunction(data) + ? data.call(vm, vm) + : data || {}; + }; + } + function initSetup(vm, props) { + if (props === void 0) { props = {}; } + var setup = vm.$options.setup; + var ctx = createSetupContext(vm); + var instance = toVue3ComponentInstance(vm); + instance.setupContext = ctx; + // fake reactive for `toRefs(props)` + def(props, '__ob__', createObserver()); + // resolve scopedSlots and slots to functions + resolveScopedSlots(vm, ctx.slots); + var binding; + activateCurrentInstance(instance, function () { + // make props to be fake reactive, this is for `toRefs(props)` + binding = setup(props, ctx); + }); + if (!binding) + return; + if (isFunction(binding)) { + // keep typescript happy with the binding type. + var bindingFunc_1 = binding; + // keep currentInstance accessible for createElement + vm.$options.render = function () { + resolveScopedSlots(vm, ctx.slots); + return activateCurrentInstance(instance, function () { return bindingFunc_1(); }); + }; + return; + } + else if (isObject(binding)) { + if (isReactive(binding)) { + binding = toRefs(binding); + } + vmStateManager.set(vm, 'rawBindings', binding); + var bindingObj_1 = binding; + Object.keys(bindingObj_1).forEach(function (name) { + var bindingValue = bindingObj_1[name]; + if (!isRef(bindingValue)) { + if (!isReactive(bindingValue)) { + if (isFunction(bindingValue)) { + var copy_1 = bindingValue; + bindingValue = bindingValue.bind(vm); + Object.keys(copy_1).forEach(function (ele) { + bindingValue[ele] = copy_1[ele]; + }); + } + else if (!isObject(bindingValue)) { + bindingValue = ref(bindingValue); + } + else if (hasReactiveArrayChild(bindingValue)) { + // creates a custom reactive properties without make the object explicitly reactive + // NOTE we should try to avoid this, better implementation needed + customReactive(bindingValue); + } + } + else if (isArray(bindingValue)) { + bindingValue = ref(bindingValue); + } + } + asVmProperty(vm, name, bindingValue); + }); + return; + } + { + assert(false, "\"setup\" must return a \"Object\" or a \"Function\", got \"".concat(Object.prototype.toString + .call(binding) + .slice(8, -1), "\"")); + } + } + function customReactive(target, seen) { + if (seen === void 0) { seen = new Set(); } + if (seen.has(target)) + return; + if (!isPlainObject(target) || + isRef(target) || + isReactive(target) || + isRaw(target)) + return; + var Vue = getVueConstructor(); + // @ts-expect-error https://github.com/vuejs/vue/pull/12132 + var defineReactive = Vue.util.defineReactive; + Object.keys(target).forEach(function (k) { + var val = target[k]; + defineReactive(target, k, val); + if (val) { + seen.add(val); + customReactive(val, seen); + } + return; + }); + } + function hasReactiveArrayChild(target, visited) { + if (visited === void 0) { visited = new Map(); } + if (visited.has(target)) { + return visited.get(target); + } + visited.set(target, false); + if (isArray(target) && isReactive(target)) { + visited.set(target, true); + return true; + } + if (!isPlainObject(target) || isRaw(target) || isRef(target)) { + return false; + } + return Object.keys(target).some(function (x) { + return hasReactiveArrayChild(target[x], visited); + }); + } + function createSetupContext(vm) { + var ctx = { slots: {} }; + var propsPlain = [ + 'root', + 'parent', + 'refs', + 'listeners', + 'isServer', + 'ssrContext', + ]; + var methodReturnVoid = ['emit']; + propsPlain.forEach(function (key) { + var srcKey = "$".concat(key); + proxy(ctx, key, { + get: function () { return vm[srcKey]; }, + set: function () { + warn("Cannot assign to '".concat(key, "' because it is a read-only property"), vm); + }, + }); + }); + updateVmAttrs(vm, ctx); + methodReturnVoid.forEach(function (key) { + var srcKey = "$".concat(key); + proxy(ctx, key, { + get: function () { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var fn = vm[srcKey]; + fn.apply(vm, args); + }; + }, + }); + }); + return ctx; + } +} + +/** + * Helper that recursively merges two data objects together. + */ +function mergeData(from, to) { + if (!from) + return to; + if (!to) + return from; + var key; + var toVal; + var fromVal; + var keys = hasSymbol ? Reflect.ownKeys(from) : Object.keys(from); + for (var i = 0; i < keys.length; i++) { + key = keys[i]; + // in case the object is already observed... + if (key === '__ob__') + continue; + toVal = to[key]; + fromVal = from[key]; + if (!hasOwn(to, key)) { + to[key] = fromVal; + } + else if (toVal !== fromVal && + isPlainObject(toVal) && + !isRef(toVal) && + isPlainObject(fromVal) && + !isRef(fromVal)) { + mergeData(fromVal, toVal); + } + } + return to; +} +function install(Vue) { + if (isVueRegistered(Vue)) { + { + warn('[vue-composition-api] already installed. Vue.use(VueCompositionAPI) should be called only once.'); + } + return; + } + { + if (Vue.version) { + if (Vue.version[0] !== '2' || Vue.version[1] !== '.') { + warn("[vue-composition-api] only works with Vue 2, v".concat(Vue.version, " found.")); + } + } + else { + warn('[vue-composition-api] no Vue version found'); + } + } + Vue.config.optionMergeStrategies.setup = function (parent, child) { + return function mergedSetupFn(props, context) { + return mergeData(isFunction(parent) ? parent(props, context) || {} : undefined, isFunction(child) ? child(props, context) || {} : undefined); + }; + }; + setVueConstructor(Vue); + mixin(Vue); +} +var Plugin = { + install: function (Vue) { return install(Vue); }, +}; + +// implementation, close to no-op +function defineComponent(options) { + return options; +} + +function defineAsyncComponent(source) { + if (isFunction(source)) { + source = { loader: source }; + } + var loader = source.loader, loadingComponent = source.loadingComponent, errorComponent = source.errorComponent, _a = source.delay, delay = _a === void 0 ? 200 : _a, timeout = source.timeout, // undefined = never times out + _b = source.suspensible, // undefined = never times out + suspensible = _b === void 0 ? false : _b, // in Vue 3 default is true + userOnError = source.onError; + if (suspensible) { + warn("The suspensiblbe option for async components is not supported in Vue2. It is ignored."); + } + var pendingRequest = null; + var retries = 0; + var retry = function () { + retries++; + pendingRequest = null; + return load(); + }; + var load = function () { + var thisRequest; + return (pendingRequest || + (thisRequest = pendingRequest = + loader() + .catch(function (err) { + err = err instanceof Error ? err : new Error(String(err)); + if (userOnError) { + return new Promise(function (resolve, reject) { + var userRetry = function () { return resolve(retry()); }; + var userFail = function () { return reject(err); }; + userOnError(err, userRetry, userFail, retries + 1); + }); + } + else { + throw err; + } + }) + .then(function (comp) { + if (thisRequest !== pendingRequest && pendingRequest) { + return pendingRequest; + } + if (!comp) { + warn("Async component loader resolved to undefined. " + + "If you are using retry(), make sure to return its return value."); + } + // interop module default + if (comp && + (comp.__esModule || comp[Symbol.toStringTag] === 'Module')) { + comp = comp.default; + } + if (comp && !isObject(comp) && !isFunction(comp)) { + throw new Error("Invalid async component load result: ".concat(comp)); + } + return comp; + }))); + }; + return function () { + var component = load(); + return { + component: component, + delay: delay, + timeout: timeout, + error: errorComponent, + loading: loadingComponent, + }; + }; +} + +var version = "1.7.0"; +// auto install when using CDN +if (typeof window !== 'undefined' && window.Vue) { + window.Vue.use(Plugin); +} + +exports.EffectScope = EffectScope; +exports.computed = computed; +exports.createApp = createApp; +exports.createLifeCycle = createLifeCycle; +exports.createRef = createRef; +exports.customRef = customRef; +exports["default"] = Plugin; +exports.defineAsyncComponent = defineAsyncComponent; +exports.defineComponent = defineComponent; +exports.del = del; +exports.effectScope = effectScope; +exports.getCurrentInstance = getCurrentInstance; +exports.getCurrentScope = getCurrentScope; +exports.h = createElement; +exports.inject = inject; +exports.isRaw = isRaw; +exports.isReactive = isReactive; +exports.isReadonly = isReadonly; +exports.isRef = isRef; +exports.markRaw = markRaw; +exports.nextTick = nextTick; +exports.onActivated = onActivated; +exports.onBeforeMount = onBeforeMount; +exports.onBeforeUnmount = onBeforeUnmount; +exports.onBeforeUpdate = onBeforeUpdate; +exports.onDeactivated = onDeactivated; +exports.onErrorCaptured = onErrorCaptured; +exports.onMounted = onMounted; +exports.onScopeDispose = onScopeDispose; +exports.onServerPrefetch = onServerPrefetch; +exports.onUnmounted = onUnmounted; +exports.onUpdated = onUpdated; +exports.provide = provide; +exports.proxyRefs = proxyRefs; +exports.reactive = reactive; +exports.readonly = readonly; +exports.ref = ref; +exports.set = set$1; +exports.shallowReactive = shallowReactive; +exports.shallowReadonly = shallowReadonly; +exports.shallowRef = shallowRef; +exports.toRaw = toRaw; +exports.toRef = toRef; +exports.toRefs = toRefs; +exports.triggerRef = triggerRef; +exports.unref = unref; +exports.useAttrs = useAttrs; +exports.useCSSModule = useCSSModule; +exports.useCssModule = useCssModule; +exports.useSlots = useSlots; +exports.version = version; +exports.warn = warn$1; +exports.watch = watch; +exports.watchEffect = watchEffect; +exports.watchPostEffect = watchPostEffect; +exports.watchSyncEffect = watchSyncEffect; diff --git a/packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.common.prod.js b/packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.common.prod.js new file mode 100644 index 0000000000000000000000000000000000000000..ffb40ed5986da27f1aa5d7ae0aec8b3d05925402 --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.common.prod.js @@ -0,0 +1 @@ +"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};var n,e=function(){return e=Object.assign||function(t){for(var n,e=1,r=arguments.length;e=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}function o(t,n){var e="function"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var r,o,i=e.call(t),u=[];try{for(;(void 0===n||n-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return u}function i(t,n,e){if(e||2===arguments.length)for(var r,o=0,i=n.length;o=0&&Math.floor(n)===n&&isFinite(t)&&n<=4294967295}function U(t){return null!==t&&"object"==typeof t}function A(t){return"[object Object]"===function(t){return Object.prototype.toString.call(t)}(t)}function B(t){return"function"==typeof t}function W(t,n){return n=n||x()}function T(t,n){void 0===n&&(n={});var e=t.config.silent;t.config.silent=!0;var r=new t(n);return t.config.silent=e,r}function V(t,n){return function(){for(var e=[],r=0;r1?e&&B(n)?n():n:void 0}},exports.isRaw=rt,exports.isReactive=ot,exports.isReadonly=function(t){return L.has(t)},exports.isRef=Z,exports.markRaw=function(t){if(!A(t)&&!R(t)||!Object.isExtensible(t))return t;var n=ct();return n.__v_skip=!0,k(t,"__ob__",n),q.set(t,!0),t},exports.nextTick=function(){for(var t,n=[],e=0;e = ComponentObjectPropsOptions

| string[]; +declare type ComponentObjectPropsOptions

= { + [K in keyof P]: Prop | null; +}; +declare type Prop = PropOptions | PropType; +declare type DefaultFactory = () => T | null | undefined; +interface PropOptions { + type?: PropType | true | null; + required?: boolean; + default?: D | DefaultFactory | null | undefined | object; + validator?(value: unknown): boolean; +} +declare type PropType = PropConstructor | PropConstructor[]; +declare type PropConstructor = { + new (...args: any[]): T & object; +} | { + (): T; +} | { + new (...args: string[]): Function; +}; +declare type RequiredKeys = { + [K in keyof T]: T[K] extends { + required: true; + } | { + default: any; + } | BooleanConstructor | { + type: BooleanConstructor; + } ? K : never; +}[keyof T]; +declare type OptionalKeys = Exclude>; +declare type ExtractFunctionPropType = any[], TResult = any> = T extends (...args: TArgs) => TResult ? T : never; +declare type ExtractCorrectPropType = T extends Function ? ExtractFunctionPropType : Exclude; +declare type InferPropType = T extends null ? any : T extends { + type: null | true; +} ? any : T extends ObjectConstructor | { + type: ObjectConstructor; +} ? Record : T extends BooleanConstructor | { + type: BooleanConstructor; +} ? boolean : T extends DateConstructor | { + type: DateConstructor; +} ? Date : T extends FunctionConstructor ? Function : T extends Prop ? unknown extends V ? D extends null | undefined ? V : D : ExtractCorrectPropType : T; +declare type ExtractPropTypes = { + [K in keyof Pick>]: InferPropType; +} & { + [K in keyof Pick>]?: InferPropType; +}; +declare type DefaultKeys = { + [K in keyof T]: T[K] extends { + default: any; + } | BooleanConstructor | { + type: BooleanConstructor; + } ? T[K] extends { + type: BooleanConstructor; + required: true; + } ? never : K : never; +}[keyof T]; +declare type ExtractDefaultPropTypes = O extends object ? { + [K in keyof Pick>]: InferPropType; +} : {}; + +declare type UnionToIntersection = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never; + +declare type Slot = (...args: any[]) => VNode[]; +declare type InternalSlots = { + [name: string]: Slot | undefined; +}; +declare type ObjectEmitsOptions = Record any) | null>; +declare type EmitsOptions = ObjectEmitsOptions | string[]; +declare type EmitFn = Options extends Array ? (event: V, ...args: any[]) => ReturnType : {} extends Options ? (event: string, ...args: any[]) => ReturnType : UnionToIntersection<{ + [key in Event]: Options[key] extends (...args: infer Args) => any ? (event: key, ...args: Args) => ReturnType : (event: key, ...args: any[]) => ReturnType; +}[Event]>; +declare type ComponentRenderEmitFn = EmitFn; +declare type Slots = Readonly; +interface SetupContext { + attrs: Data; + slots: Slots; + emit: EmitFn; + /** + * @deprecated not available in Vue 2 + */ + expose: (exposed?: Record) => void; + /** + * @deprecated not available in Vue 3 + */ + readonly parent: ComponentInstance | null; + /** + * @deprecated not available in Vue 3 + */ + readonly root: ComponentInstance; + /** + * @deprecated not available in Vue 3 + */ + readonly listeners: { + [key in string]?: Function; + }; + /** + * @deprecated not available in Vue 3 + */ + readonly refs: { + [key: string]: Vue | Element | Vue[] | Element[]; + }; +} +/** + * We expose a subset of properties on the internal instance as they are + * useful for advanced external libraries and tools. + */ +declare interface ComponentInternalInstance { + uid: number; + type: Record; + parent: ComponentInternalInstance | null; + root: ComponentInternalInstance; + /** + * Vnode representing this component in its parent's vdom tree + */ + vnode: VNode; + /** + * Root vnode of this component's own vdom tree + */ + /** + * The reactive effect for rendering and patching the component. Callable. + */ + update: Function; + data: Data; + props: Data; + attrs: Data; + refs: Data; + emit: EmitFn; + slots: InternalSlots; + emitted: Record | null; + proxy: ComponentInstance; + isMounted: boolean; + isUnmounted: boolean; + isDeactivated: boolean; +} +declare function getCurrentInstance(): ComponentInternalInstance | null; + +declare type EmitsToProps = T extends string[] ? { + [K in string & `on${Capitalize}`]?: (...args: any[]) => any; +} : T extends ObjectEmitsOptions ? { + [K in string & `on${Capitalize}`]?: K extends `on${infer C}` ? T[Uncapitalize] extends null ? (...args: any[]) => any : (...args: T[Uncapitalize] extends (...args: infer P) => any ? P : never) => any : never; +} : {}; +declare type ComponentInstance = InstanceType; +declare type ComponentRenderProxy

= { + $data: D; + $props: Readonly & Omit

: P & PublicProps>; + $attrs: Record; + $emit: ComponentRenderEmitFn>; +} & Readonly

& ShallowUnwrapRef & D & M & ExtractComputedReturns & Omit; +declare type VueConstructorProxy & ({} extends Emits ? {} : EmitsToProps)> = Omit & { + new (...args: any[]): ComponentRenderProxy, Data, Computed, Methods, Mixin, Extends, Emits, Props, ExtractDefaultPropTypes, true>; +}; +declare type DefaultData = object | ((this: V) => object); +declare type DefaultMethods = { + [key: string]: (this: V, ...args: any[]) => any; +}; +declare type DefaultComputed = { + [key: string]: any; +}; +declare type VueProxy, Computed extends ComputedOptions = DefaultComputed, Methods extends MethodOptions = DefaultMethods, Mixin = {}, Extends = {}, Emits extends EmitsOptions = {}> = ComponentOptions & Data, Methods, Computed, PropsOptions, ExtractPropTypes> & VueConstructorProxy; +declare type ComponentPublicInstance

= { + $: ComponentInternalInstance; + $data: D; + $props: MakeDefaultsOptional extends true ? Partial & Omit

: P & PublicProps; + $attrs: Data; + $refs: Data; + $slots: Slots; + $root: ComponentPublicInstance | null; + $parent: ComponentPublicInstance | null; + $emit: EmitFn; + $el: any; + $forceUpdate: () => void; + $nextTick: typeof nextTick; + $watch(source: string | Function, cb: Function, options?: WatchOptions): WatchStopHandle; +} & P & ShallowUnwrapRef & UnwrapNestedRefs & ExtractComputedReturns & M; + +declare type ComputedGetter$1 = (ctx?: any) => T; +declare type ComputedSetter$1 = (v: T) => void; +interface WritableComputedOptions$1 { + get: ComputedGetter$1; + set: ComputedSetter$1; +} +declare type ComputedOptions = Record | WritableComputedOptions$1>; +interface MethodOptions { + [key: string]: Function; +} +declare type SetupFunction = (this: void, props: Readonly, ctx: SetupContext) => RawBindings | (() => VNode | null) | void; +interface ComponentOptionsBase extends Omit, 'data' | 'computed' | 'method' | 'setup' | 'props'> { + [key: string]: any; + data?: (this: Props & Vue$1, vm: Props) => D; + computed?: C; + methods?: M; +} +declare type ExtractComputedReturns = { + [key in keyof T]: T[key] extends { + get: (...args: any[]) => infer TReturn; + } ? TReturn : T[key] extends (...args: any[]) => infer TReturn ? TReturn : never; +}; +declare type ComponentOptionsWithProps> = ComponentOptionsBase & { + props?: PropsOptions; + emits?: Emits & ThisType; + setup?: SetupFunction; +} & ThisType>; +declare type ComponentOptionsWithArrayProps> = ComponentOptionsBase & { + props?: PropNames[]; + emits?: Emits & ThisType; + setup?: SetupFunction; +} & ThisType>; +declare type ComponentOptionsWithoutProps = ComponentOptionsBase & { + props?: undefined; + emits?: Emits & ThisType; + setup?: SetupFunction; +} & ThisType>; + +declare type AnyObject = Record; +declare type Equal = (() => U extends Left ? 1 : 0) extends (() => U extends Right ? 1 : 0) ? true : false; +declare type HasDefined = Equal extends true ? false : true; + +/** + * overload 1: object format with no props + */ +declare function defineComponent(options: ComponentOptionsWithoutProps<{}, RawBindings, D, C, M, Mixin, Extends, Emits>): VueProxy<{}, RawBindings, D, C, M, Mixin, Extends, Emits>; +/** + * overload 2: object format with array props declaration + * props inferred as `{ [key in PropNames]?: any }` + * + * return type is for Vetur and TSX support + */ +declare function defineComponent(options: ComponentOptionsWithArrayProps): VueProxy, RawBindings, D, C, M, Mixin, Extends, Emits>; +/** + * overload 3: object format with object props declaration + * + * see `ExtractPropTypes` in './componentProps.ts' + */ +declare function defineComponent(options: HasDefined extends true ? ComponentOptionsWithProps : ComponentOptionsWithProps): VueProxy; + +declare type Component = VueProxy; +declare type ComponentOrComponentOptions = Component | ComponentOptionsWithoutProps | ComponentOptionsWithArrayProps | ComponentOptionsWithProps; +declare type AsyncComponentResolveResult = T | { + default: T; +}; +declare type AsyncComponentLoader = () => Promise; +interface AsyncComponentOptions { + loader: AsyncComponentLoader; + loadingComponent?: ComponentOrComponentOptions; + errorComponent?: ComponentOrComponentOptions; + delay?: number; + timeout?: number; + suspensible?: boolean; + onError?: (error: Error, retry: () => void, fail: () => void, attempts: number) => any; +} +declare function defineAsyncComponent(source: AsyncComponentLoader | AsyncComponentOptions): AsyncComponent; + +declare type DirectiveModifiers = Record; +interface DirectiveBinding extends Readonly { + readonly modifiers: DirectiveModifiers; + readonly value: V; + readonly oldValue: V | null; +} +declare type DirectiveHook = (el: T, binding: DirectiveBinding, vnode: VNode, prevVNode: Prev) => void; +interface ObjectDirective { + bind?: DirectiveHook; + inserted?: DirectiveHook; + update?: DirectiveHook; + componentUpdated?: DirectiveHook; + unbind?: DirectiveHook; +} +declare type FunctionDirective = DirectiveHook; +declare type Directive = ObjectDirective | FunctionDirective; + +declare const Plugin: { + install: (Vue: VueConstructor) => void; +}; + +declare const _refBrand: unique symbol; +interface Ref { + readonly [_refBrand]: true; + value: T; +} +interface WritableComputedRef extends Ref { + /** + * `effect` is added to be able to differentiate refs from computed properties. + * **Differently from Vue 3, it's just `true`**. This is because there is no equivalent + * of `ReactiveEffect` in `@vue/composition-api`. + */ + effect: true; +} +interface ComputedRef extends WritableComputedRef { + readonly value: T; +} +declare type ToRefs = { + [K in keyof T]: Ref; +}; +declare type CollectionTypes = IterableCollections | WeakCollections; +declare type IterableCollections = Map | Set; +declare type WeakCollections = WeakMap | WeakSet; +declare type BaseTypes = string | number | boolean | Node | Window; +declare type ShallowUnwrapRef = { + [K in keyof T]: T[K] extends Ref ? V : T[K]; +}; +declare type UnwrapRef = T extends Ref ? UnwrapRefSimple : UnwrapRefSimple; +declare type UnwrapRefSimple = T extends Function | CollectionTypes | BaseTypes | Ref ? T : T extends Array ? { + [K in keyof T]: UnwrapRefSimple; +} : T extends object ? { + [P in keyof T]: P extends symbol ? T[P] : UnwrapRef; +} : T; +interface RefOption { + get(): T; + set?(x: T): void; +} +declare class RefImpl implements Ref { + readonly [_refBrand]: true; + value: T; + constructor({ get, set }: RefOption); +} +declare function createRef(options: RefOption, isReadonly?: boolean, isComputed?: boolean): RefImpl; +declare function ref(raw: T): T extends Ref ? T : Ref>; +declare function ref(raw: T): Ref>; +declare function ref(): Ref; +declare function isRef(value: any): value is Ref; +declare function unref(ref: T | Ref): T; +declare function toRefs(obj: T): ToRefs; +declare type CustomRefFactory = (track: () => void, trigger: () => void) => { + get: () => T; + set: (value: T) => void; +}; +declare function customRef(factory: CustomRefFactory): Ref; +declare function toRef(object: T, key: K): Ref; +declare function shallowRef(value: T): T extends Ref ? T : Ref; +declare function shallowRef(value: T): Ref; +declare function shallowRef(): Ref; +declare function triggerRef(value: any): void; +declare function proxyRefs(objectWithRefs: T): ShallowUnwrapRef; + +declare function isRaw(obj: any): boolean; +declare function isReactive(obj: any): boolean; +declare function shallowReactive(obj: T): T; +/** + * Make obj reactivity + */ +declare function reactive(obj: T): UnwrapRef; +/** + * Make sure obj can't be a reactive + */ +declare function markRaw(obj: T): T; +declare function toRaw(observed: T): T; + +declare function isReadonly(obj: any): boolean; +declare type Primitive = string | number | boolean | bigint | symbol | undefined | null; +declare type Builtin = Primitive | Function | Date | Error | RegExp; +declare type DeepReadonly = T extends Builtin ? T : T extends Map ? ReadonlyMap, DeepReadonly> : T extends ReadonlyMap ? ReadonlyMap, DeepReadonly> : T extends WeakMap ? WeakMap, DeepReadonly> : T extends Set ? ReadonlySet> : T extends ReadonlySet ? ReadonlySet> : T extends WeakSet ? WeakSet> : T extends Promise ? Promise> : T extends {} ? { + readonly [K in keyof T]: DeepReadonly; +} : Readonly; +declare type UnwrapNestedRefs = T extends Ref ? T : UnwrapRefSimple; +/** + * **In @vue/composition-api, `reactive` only provides type-level readonly check** + * + * Creates a readonly copy of the original object. Note the returned copy is not + * made reactive, but `readonly` can be called on an already reactive object. + */ +declare function readonly(target: T): DeepReadonly>; +declare function shallowReadonly(obj: T): Readonly; + +/** + * Set a property on an object. Adds the new property, triggers change + * notification and intercept it's subsequent access if the property doesn't + * already exist. + */ +declare function set(target: AnyObject, key: any, val: T): T; + +/** + * Delete a property and trigger change if necessary. + */ +declare function del(target: AnyObject, key: any): void; + +declare function createLifeCycle(lifeCyclehook: string): (callback: Function, target?: ComponentInternalInstance | null | undefined) => Function | null; +declare const onBeforeMount: (callback: Function, target?: ComponentInternalInstance | null | undefined) => Function | null; +declare const onMounted: (callback: Function, target?: ComponentInternalInstance | null | undefined) => Function | null; +declare const onBeforeUpdate: (callback: Function, target?: ComponentInternalInstance | null | undefined) => Function | null; +declare const onUpdated: (callback: Function, target?: ComponentInternalInstance | null | undefined) => Function | null; +declare const onBeforeUnmount: (callback: Function, target?: ComponentInternalInstance | null | undefined) => Function | null; +declare const onUnmounted: (callback: Function, target?: ComponentInternalInstance | null | undefined) => Function | null; +declare const onErrorCaptured: (callback: Function, target?: ComponentInternalInstance | null | undefined) => Function | null; +declare const onActivated: (callback: Function, target?: ComponentInternalInstance | null | undefined) => Function | null; +declare const onDeactivated: (callback: Function, target?: ComponentInternalInstance | null | undefined) => Function | null; +declare const onServerPrefetch: (callback: Function, target?: ComponentInternalInstance | null | undefined) => Function | null; + +declare type WatchEffect = (onInvalidate: InvalidateCbRegistrator) => void; +declare type WatchSource = Ref | ComputedRef | (() => T); +declare type WatchCallback = (value: V, oldValue: OV, onInvalidate: InvalidateCbRegistrator) => any; +declare type MapSources = { + [K in keyof T]: T[K] extends WatchSource ? Immediate extends true ? V | undefined : V : never; +}; +declare type MultiWatchSources = (WatchSource | object)[]; +interface WatchOptionsBase { + flush?: FlushMode; +} +declare type InvalidateCbRegistrator = (cb: () => void) => void; +declare type FlushMode = 'pre' | 'post' | 'sync'; +interface WatchOptions extends WatchOptionsBase { + immediate?: Immediate; + deep?: boolean; +} +interface VueWatcher { + lazy: boolean; + get(): any; + teardown(): void; + run(): void; + value: any; +} +declare type WatchStopHandle = () => void; +declare function watchEffect(effect: WatchEffect, options?: WatchOptionsBase): WatchStopHandle; +declare function watchPostEffect(effect: WatchEffect): WatchStopHandle; +declare function watchSyncEffect(effect: WatchEffect): WatchStopHandle; +declare function watch, Immediate extends Readonly = false>(sources: [...T], cb: WatchCallback, MapSources>, options?: WatchOptions): WatchStopHandle; +declare function watch, Immediate extends Readonly = false>(sources: T, cb: WatchCallback, MapSources>, options?: WatchOptions): WatchStopHandle; +declare function watch = false>(sources: [...T], cb: WatchCallback, MapSources>, options?: WatchOptions): WatchStopHandle; +declare function watch = false>(source: WatchSource, cb: WatchCallback, options?: WatchOptions): WatchStopHandle; +declare function watch = false>(source: T, cb: WatchCallback, options?: WatchOptions): WatchStopHandle; + +declare type ComputedGetter = (ctx?: any) => T; +declare type ComputedSetter = (v: T) => void; +interface WritableComputedOptions { + get: ComputedGetter; + set: ComputedSetter; +} +declare function computed(getter: ComputedGetter): ComputedRef; +declare function computed(options: WritableComputedOptions): WritableComputedRef; + +interface InjectionKey extends Symbol { +} +declare function provide(key: InjectionKey | string, value: T): void; +declare function inject(key: InjectionKey | string): T | undefined; +declare function inject(key: InjectionKey | string, defaultValue: T, treatDefaultAsFactory?: false): T; +declare function inject(key: InjectionKey | string, defaultValue: T | (() => T), treatDefaultAsFactory?: true): T; + +declare const useCssModule: (name?: string) => Record; +/** + * @deprecated use `useCssModule` instead. + */ +declare const useCSSModule: (name?: string) => Record; + +interface App { + config: VueConstructor['config']; + use: VueConstructor['use']; + mixin: VueConstructor['mixin']; + component: VueConstructor['component']; + directive(name: string): Directive | undefined; + directive(name: string, directive: Directive): this; + provide(key: InjectionKey | symbol | string, value: T): this; + mount: Vue$1['$mount']; + unmount: Vue$1['$destroy']; +} +declare function createApp(rootComponent: any, rootProps?: any): App; + +declare type NextTick = Vue$1['$nextTick']; +declare const nextTick: NextTick; + +interface H extends CreateElement { + (this: ComponentInternalInstance | null | undefined, tag?: string | Component$1 | AsyncComponent$1 | (() => Component$1), children?: VNodeChildren): VNode$1; + (this: ComponentInternalInstance | null | undefined, tag?: string | Component$1 | AsyncComponent$1 | (() => Component$1), data?: VNodeData, children?: VNodeChildren): VNode$1; +} +declare const createElement: H; + +/** + * Displays a warning message (using console.error) with a stack trace if the + * function is called inside of active component. + * + * @param message warning message to be displayed + */ +declare function warn(message: string): void; + +declare class EffectScopeImpl { + active: boolean; + effects: EffectScope[]; + cleanups: (() => void)[]; + constructor(vm: Vue); + run(fn: () => T): T | undefined; + on(): void; + off(): void; + stop(): void; +} +declare class EffectScope extends EffectScopeImpl { + constructor(detached?: boolean); +} +declare function effectScope(detached?: boolean): EffectScope; +declare function getCurrentScope(): EffectScope | undefined; +declare function onScopeDispose(fn: () => void): void; + +declare function useSlots(): SetupContext['slots']; +declare function useAttrs(): SetupContext['attrs']; + +declare const version: string; + +declare module 'vue/types/options' { + interface ComponentOptions { + setup?: SetupFunction; + } +} + +export { App, ComponentInstance, ComponentInternalInstance, ComponentPropsOptions, ComponentPublicInstance, ComponentRenderProxy, ComputedGetter, ComputedOptions, ComputedRef, ComputedSetter, Data, DeepReadonly, Directive, DirectiveBinding, DirectiveHook, DirectiveModifiers, EffectScope, ExtractDefaultPropTypes, ExtractPropTypes, FlushMode, FunctionDirective, InjectionKey, MethodOptions, ObjectDirective, PropOptions, PropType, Ref, SetupContext, SetupFunction, ShallowUnwrapRef, ToRefs, UnwrapNestedRefs, UnwrapRef, UnwrapRefSimple, VueWatcher, WatchCallback, WatchEffect, WatchOptions, WatchOptionsBase, WatchSource, WatchStopHandle, WritableComputedOptions, WritableComputedRef, computed, createApp, createLifeCycle, createRef, customRef, Plugin as default, defineAsyncComponent, defineComponent, del, effectScope, getCurrentInstance, getCurrentScope, createElement as h, inject, isRaw, isReactive, isReadonly, isRef, markRaw, nextTick, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, provide, proxyRefs, reactive, readonly, ref, set, shallowReactive, shallowReadonly, shallowRef, toRaw, toRef, toRefs, triggerRef, unref, useAttrs, useCSSModule, useCssModule, useSlots, version, warn, watch, watchEffect, watchPostEffect, watchSyncEffect }; diff --git a/packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.esm.js b/packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.esm.js new file mode 100644 index 0000000000000000000000000000000000000000..9a1b7b3994fd45c0b9cf7c0eb66e9761c45435cd --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.esm.js @@ -0,0 +1,2259 @@ +/****************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */ +/* global Reflect, Promise */ + +var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); +}; + +function __extends(d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +} + +var __assign = function() { + __assign = Object.assign || function __assign(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; + +function __values(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +} + +function __read(o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +} + +function __spreadArray(to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +} + +/** + * Displays a warning message (using console.error) with a stack trace if the + * function is called inside of active component. + * + * @param message warning message to be displayed + */ +function warn$1(message) { + var _a; + warn(message, (_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy); +} + +var activeEffectScope; +var effectScopeStack = []; +var EffectScopeImpl = /** @class */ (function () { + function EffectScopeImpl(vm) { + this.active = true; + this.effects = []; + this.cleanups = []; + this.vm = vm; + } + EffectScopeImpl.prototype.run = function (fn) { + if (this.active) { + try { + this.on(); + return fn(); + } + finally { + this.off(); + } + } + else if ((process.env.NODE_ENV !== 'production')) { + warn$1("cannot run an inactive effect scope."); + } + return; + }; + EffectScopeImpl.prototype.on = function () { + if (this.active) { + effectScopeStack.push(this); + activeEffectScope = this; + } + }; + EffectScopeImpl.prototype.off = function () { + if (this.active) { + effectScopeStack.pop(); + activeEffectScope = effectScopeStack[effectScopeStack.length - 1]; + } + }; + EffectScopeImpl.prototype.stop = function () { + if (this.active) { + this.vm.$destroy(); + this.effects.forEach(function (e) { return e.stop(); }); + this.cleanups.forEach(function (cleanup) { return cleanup(); }); + this.active = false; + } + }; + return EffectScopeImpl; +}()); +var EffectScope = /** @class */ (function (_super) { + __extends(EffectScope, _super); + function EffectScope(detached) { + if (detached === void 0) { detached = false; } + var _this = this; + var vm = undefined; + withCurrentInstanceTrackingDisabled(function () { + vm = defineComponentInstance(getVueConstructor()); + }); + _this = _super.call(this, vm) || this; + if (!detached) { + recordEffectScope(_this); + } + return _this; + } + return EffectScope; +}(EffectScopeImpl)); +function recordEffectScope(effect, scope) { + var _a; + scope = scope || activeEffectScope; + if (scope && scope.active) { + scope.effects.push(effect); + return; + } + // destroy on parent component unmounted + var vm = (_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy; + vm && vm.$on('hook:destroyed', function () { return effect.stop(); }); +} +function effectScope(detached) { + return new EffectScope(detached); +} +function getCurrentScope() { + return activeEffectScope; +} +function onScopeDispose(fn) { + if (activeEffectScope) { + activeEffectScope.cleanups.push(fn); + } + else if ((process.env.NODE_ENV !== 'production')) { + warn$1("onScopeDispose() is called when there is no active effect scope" + + " to be associated with."); + } +} +/** + * @internal + **/ +function getCurrentScopeVM() { + var _a, _b; + return ((_a = getCurrentScope()) === null || _a === void 0 ? void 0 : _a.vm) || ((_b = getCurrentInstance()) === null || _b === void 0 ? void 0 : _b.proxy); +} +/** + * @internal + **/ +function bindCurrentScopeToVM(vm) { + if (!vm.scope) { + var scope_1 = new EffectScopeImpl(vm.proxy); + vm.scope = scope_1; + vm.proxy.$on('hook:destroyed', function () { return scope_1.stop(); }); + } + return vm.scope; +} + +var vueDependency = undefined; +try { + var requiredVue = require('vue'); + if (requiredVue && isVue(requiredVue)) { + vueDependency = requiredVue; + } + else if (requiredVue && + 'default' in requiredVue && + isVue(requiredVue.default)) { + vueDependency = requiredVue.default; + } +} +catch (_a) { + // not available +} +var vueConstructor = null; +var currentInstance = null; +var currentInstanceTracking = true; +var PluginInstalledFlag = '__composition_api_installed__'; +function isVue(obj) { + return obj && isFunction(obj) && obj.name === 'Vue'; +} +function isVueRegistered(Vue) { + // resolve issue: https://github.com/vuejs/composition-api/issues/876#issue-1087619365 + return vueConstructor && hasOwn(Vue, PluginInstalledFlag); +} +function getVueConstructor() { + if ((process.env.NODE_ENV !== 'production')) { + assert(vueConstructor, "must call Vue.use(VueCompositionAPI) before using any function."); + } + return vueConstructor; +} +// returns registered vue or `vue` dependency +function getRegisteredVueOrDefault() { + var constructor = vueConstructor || vueDependency; + if ((process.env.NODE_ENV !== 'production')) { + assert(constructor, "No vue dependency found."); + } + return constructor; +} +function setVueConstructor(Vue) { + // @ts-ignore + if ((process.env.NODE_ENV !== 'production') && vueConstructor && Vue.__proto__ !== vueConstructor.__proto__) { + warn('[vue-composition-api] another instance of Vue installed'); + } + vueConstructor = Vue; + Object.defineProperty(Vue, PluginInstalledFlag, { + configurable: true, + writable: true, + value: true, + }); +} +/** + * For `effectScope` to create instance without populate the current instance + * @internal + **/ +function withCurrentInstanceTrackingDisabled(fn) { + var prev = currentInstanceTracking; + currentInstanceTracking = false; + try { + fn(); + } + finally { + currentInstanceTracking = prev; + } +} +function setCurrentInstance(instance) { + if (!currentInstanceTracking) + return; + var prev = currentInstance; + prev === null || prev === void 0 ? void 0 : prev.scope.off(); + currentInstance = instance; + currentInstance === null || currentInstance === void 0 ? void 0 : currentInstance.scope.on(); +} +function getCurrentInstance() { + return currentInstance; +} +var instanceMapCache = new WeakMap(); +function toVue3ComponentInstance(vm) { + if (instanceMapCache.has(vm)) { + return instanceMapCache.get(vm); + } + var instance = { + proxy: vm, + update: vm.$forceUpdate, + type: vm.$options, + uid: vm._uid, + // $emit is defined on prototype and it expected to be bound + emit: vm.$emit.bind(vm), + parent: null, + root: null, // to be immediately set + }; + bindCurrentScopeToVM(instance); + // map vm.$props = + var instanceProps = [ + 'data', + 'props', + 'attrs', + 'refs', + 'vnode', + 'slots', + ]; + instanceProps.forEach(function (prop) { + proxy(instance, prop, { + get: function () { + return vm["$".concat(prop)]; + }, + }); + }); + proxy(instance, 'isMounted', { + get: function () { + // @ts-expect-error private api + return vm._isMounted; + }, + }); + proxy(instance, 'isUnmounted', { + get: function () { + // @ts-expect-error private api + return vm._isDestroyed; + }, + }); + proxy(instance, 'isDeactivated', { + get: function () { + // @ts-expect-error private api + return vm._inactive; + }, + }); + proxy(instance, 'emitted', { + get: function () { + // @ts-expect-error private api + return vm._events; + }, + }); + instanceMapCache.set(vm, instance); + if (vm.$parent) { + instance.parent = toVue3ComponentInstance(vm.$parent); + } + if (vm.$root) { + instance.root = toVue3ComponentInstance(vm.$root); + } + return instance; +} + +var toString = function (x) { return Object.prototype.toString.call(x); }; +function isNative(Ctor) { + return typeof Ctor === 'function' && /native code/.test(Ctor.toString()); +} +var hasSymbol = typeof Symbol !== 'undefined' && + isNative(Symbol) && + typeof Reflect !== 'undefined' && + isNative(Reflect.ownKeys); +var noopFn = function (_) { return _; }; +function proxy(target, key, _a) { + var get = _a.get, set = _a.set; + Object.defineProperty(target, key, { + enumerable: true, + configurable: true, + get: get || noopFn, + set: set || noopFn, + }); +} +function def(obj, key, val, enumerable) { + Object.defineProperty(obj, key, { + value: val, + enumerable: !!enumerable, + writable: true, + configurable: true, + }); +} +function hasOwn(obj, key) { + return Object.hasOwnProperty.call(obj, key); +} +function assert(condition, msg) { + if (!condition) { + throw new Error("[vue-composition-api] ".concat(msg)); + } +} +function isPrimitive(value) { + return (typeof value === 'string' || + typeof value === 'number' || + // $flow-disable-line + typeof value === 'symbol' || + typeof value === 'boolean'); +} +function isArray(x) { + return Array.isArray(x); +} +var objectToString = Object.prototype.toString; +var toTypeString = function (value) { + return objectToString.call(value); +}; +var isMap = function (val) { + return toTypeString(val) === '[object Map]'; +}; +var isSet = function (val) { + return toTypeString(val) === '[object Set]'; +}; +var MAX_VALID_ARRAY_LENGTH = 4294967295; // Math.pow(2, 32) - 1 +function isValidArrayIndex(val) { + var n = parseFloat(String(val)); + return (n >= 0 && + Math.floor(n) === n && + isFinite(val) && + n <= MAX_VALID_ARRAY_LENGTH); +} +function isObject(val) { + return val !== null && typeof val === 'object'; +} +function isPlainObject(x) { + return toString(x) === '[object Object]'; +} +function isFunction(x) { + return typeof x === 'function'; +} +function isUndef(v) { + return v === undefined || v === null; +} +function warn(msg, vm) { + var Vue = getRegisteredVueOrDefault(); + if (!Vue || !Vue.util) + console.warn("[vue-composition-api] ".concat(msg)); + else + Vue.util.warn(msg, vm); +} +function logError(err, vm, info) { + if ((process.env.NODE_ENV !== 'production')) { + warn("Error in ".concat(info, ": \"").concat(err.toString(), "\""), vm); + } + if (typeof window !== 'undefined' && typeof console !== 'undefined') { + console.error(err); + } + else { + throw err; + } +} +/** + * Object.is polyfill + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is + * */ +function isSame(value1, value2) { + if (value1 === value2) { + return value1 !== 0 || 1 / value1 === 1 / value2; + } + else { + return value1 !== value1 && value2 !== value2; + } +} + +function getCurrentInstanceForFn(hook, target) { + target = target || getCurrentInstance(); + if ((process.env.NODE_ENV !== 'production') && !target) { + warn("".concat(hook, " is called when there is no active component instance to be ") + + "associated with. " + + "Lifecycle injection APIs can only be used during execution of setup()."); + } + return target; +} +function defineComponentInstance(Ctor, options) { + if (options === void 0) { options = {}; } + var silent = Ctor.config.silent; + Ctor.config.silent = true; + var vm = new Ctor(options); + Ctor.config.silent = silent; + return vm; +} +function isComponentInstance(obj) { + var Vue = getVueConstructor(); + return Vue && obj instanceof Vue; +} +function createSlotProxy(vm, slotName) { + return (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + if (!vm.$scopedSlots[slotName]) { + if ((process.env.NODE_ENV !== 'production')) + return warn("slots.".concat(slotName, "() got called outside of the \"render()\" scope"), vm); + return; + } + return vm.$scopedSlots[slotName].apply(vm, args); + }); +} +function resolveSlots(slots, normalSlots) { + var res; + if (!slots) { + res = {}; + } + else if (slots._normalized) { + // fast path 1: child component re-render only, parent did not change + return slots._normalized; + } + else { + res = {}; + for (var key in slots) { + if (slots[key] && key[0] !== '$') { + res[key] = true; + } + } + } + // expose normal slots on scopedSlots + for (var key in normalSlots) { + if (!(key in res)) { + res[key] = true; + } + } + return res; +} +var vueInternalClasses; +var getVueInternalClasses = function () { + if (!vueInternalClasses) { + var vm = defineComponentInstance(getVueConstructor(), { + computed: { + value: function () { + return 0; + }, + }, + }); + // to get Watcher class + var Watcher = vm._computedWatchers.value.constructor; + // to get Dep class + var Dep = vm._data.__ob__.dep.constructor; + vueInternalClasses = { + Watcher: Watcher, + Dep: Dep, + }; + vm.$destroy(); + } + return vueInternalClasses; +}; + +function createSymbol(name) { + return hasSymbol ? Symbol.for(name) : name; +} +var WatcherPreFlushQueueKey = createSymbol('composition-api.preFlushQueue'); +var WatcherPostFlushQueueKey = createSymbol('composition-api.postFlushQueue'); +// must be a string, symbol key is ignored in reactive +var RefKey = 'composition-api.refKey'; + +var accessModifiedSet = new WeakMap(); +var rawSet = new WeakMap(); +var readonlySet = new WeakMap(); + +/** + * Set a property on an object. Adds the new property, triggers change + * notification and intercept it's subsequent access if the property doesn't + * already exist. + */ +function set$1(target, key, val) { + var Vue = getVueConstructor(); + // @ts-expect-error https://github.com/vuejs/vue/pull/12132 + var _a = Vue.util, warn = _a.warn, defineReactive = _a.defineReactive; + if ((process.env.NODE_ENV !== 'production') && (isUndef(target) || isPrimitive(target))) { + warn("Cannot set reactive property on undefined, null, or primitive value: ".concat(target)); + } + var ob = target.__ob__; + function ssrMockReactivity() { + // in SSR, there is no __ob__. Mock for reactivity check + if (ob && isObject(val) && !hasOwn(val, '__ob__')) { + mockReactivityDeep(val); + } + } + if (isArray(target)) { + if (isValidArrayIndex(key)) { + target.length = Math.max(target.length, key); + target.splice(key, 1, val); + ssrMockReactivity(); + return val; + } + else if (key === 'length' && val !== target.length) { + target.length = val; + ob === null || ob === void 0 ? void 0 : ob.dep.notify(); + return val; + } + } + if (key in target && !(key in Object.prototype)) { + target[key] = val; + ssrMockReactivity(); + return val; + } + if (target._isVue || (ob && ob.vmCount)) { + (process.env.NODE_ENV !== 'production') && + warn('Avoid adding reactive properties to a Vue instance or its root $data ' + + 'at runtime - declare it upfront in the data option.'); + return val; + } + if (!ob) { + target[key] = val; + return val; + } + defineReactive(ob.value, key, val); + // IMPORTANT: define access control before trigger watcher + defineAccessControl(target, key, val); + ssrMockReactivity(); + ob.dep.notify(); + return val; +} + +var _isForceTrigger = false; +function isForceTrigger() { + return _isForceTrigger; +} +function setForceTrigger(v) { + _isForceTrigger = v; +} + +var RefImpl = /** @class */ (function () { + function RefImpl(_a) { + var get = _a.get, set = _a.set; + proxy(this, 'value', { + get: get, + set: set, + }); + } + return RefImpl; +}()); +function createRef(options, isReadonly, isComputed) { + if (isReadonly === void 0) { isReadonly = false; } + if (isComputed === void 0) { isComputed = false; } + var r = new RefImpl(options); + // add effect to differentiate refs from computed + if (isComputed) + r.effect = true; + // seal the ref, this could prevent ref from being observed + // It's safe to seal the ref, since we really shouldn't extend it. + // related issues: #79 + var sealed = Object.seal(r); + if (isReadonly) + readonlySet.set(sealed, true); + return sealed; +} +function ref(raw) { + var _a; + if (isRef(raw)) { + return raw; + } + var value = reactive((_a = {}, _a[RefKey] = raw, _a)); + return createRef({ + get: function () { return value[RefKey]; }, + set: function (v) { return (value[RefKey] = v); }, + }); +} +function isRef(value) { + return value instanceof RefImpl; +} +function unref(ref) { + return isRef(ref) ? ref.value : ref; +} +function toRefs(obj) { + if ((process.env.NODE_ENV !== 'production') && !isReactive(obj)) { + warn("toRefs() expects a reactive object but received a plain one."); + } + if (!isPlainObject(obj)) + return obj; + var ret = {}; + for (var key in obj) { + ret[key] = toRef(obj, key); + } + return ret; +} +function customRef(factory) { + var version = ref(0); + return createRef(factory(function () { return void version.value; }, function () { + ++version.value; + })); +} +function toRef(object, key) { + if (!(key in object)) + set$1(object, key, undefined); + var v = object[key]; + if (isRef(v)) + return v; + return createRef({ + get: function () { return object[key]; }, + set: function (v) { return (object[key] = v); }, + }); +} +function shallowRef(raw) { + var _a; + if (isRef(raw)) { + return raw; + } + var value = shallowReactive((_a = {}, _a[RefKey] = raw, _a)); + return createRef({ + get: function () { return value[RefKey]; }, + set: function (v) { return (value[RefKey] = v); }, + }); +} +function triggerRef(value) { + if (!isRef(value)) + return; + setForceTrigger(true); + value.value = value.value; + setForceTrigger(false); +} +function proxyRefs(objectWithRefs) { + var _a, e_1, _b; + if (isReactive(objectWithRefs)) { + return objectWithRefs; + } + var value = reactive((_a = {}, _a[RefKey] = objectWithRefs, _a)); + def(value, RefKey, value[RefKey], false); + var _loop_1 = function (key) { + proxy(value, key, { + get: function () { + if (isRef(value[RefKey][key])) { + return value[RefKey][key].value; + } + return value[RefKey][key]; + }, + set: function (v) { + if (isRef(value[RefKey][key])) { + return (value[RefKey][key].value = unref(v)); + } + value[RefKey][key] = unref(v); + }, + }); + }; + try { + for (var _c = __values(Object.keys(objectWithRefs)), _d = _c.next(); !_d.done; _d = _c.next()) { + var key = _d.value; + _loop_1(key); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_d && !_d.done && (_b = _c.return)) _b.call(_c); + } + finally { if (e_1) throw e_1.error; } + } + return value; +} + +var SKIPFLAG = '__v_skip'; +function isRaw(obj) { + var _a; + return Boolean(obj && + hasOwn(obj, '__ob__') && + typeof obj.__ob__ === 'object' && + ((_a = obj.__ob__) === null || _a === void 0 ? void 0 : _a[SKIPFLAG])); +} +function isReactive(obj) { + var _a; + return Boolean(obj && + hasOwn(obj, '__ob__') && + typeof obj.__ob__ === 'object' && + !((_a = obj.__ob__) === null || _a === void 0 ? void 0 : _a[SKIPFLAG])); +} +/** + * Proxing property access of target. + * We can do unwrapping and other things here. + */ +function setupAccessControl(target) { + if (!isPlainObject(target) || + isRaw(target) || + isArray(target) || + isRef(target) || + isComponentInstance(target) || + accessModifiedSet.has(target)) + return; + accessModifiedSet.set(target, true); + var keys = Object.keys(target); + for (var i = 0; i < keys.length; i++) { + defineAccessControl(target, keys[i]); + } +} +/** + * Auto unwrapping when access property + */ +function defineAccessControl(target, key, val) { + if (key === '__ob__') + return; + if (isRaw(target[key])) + return; + var getter; + var setter; + var property = Object.getOwnPropertyDescriptor(target, key); + if (property) { + if (property.configurable === false) { + return; + } + getter = property.get; + setter = property.set; + if ((!getter || setter) /* not only have getter */ && + arguments.length === 2) { + val = target[key]; + } + } + setupAccessControl(val); + proxy(target, key, { + get: function getterHandler() { + var value = getter ? getter.call(target) : val; + // if the key is equal to RefKey, skip the unwrap logic + if (key !== RefKey && isRef(value)) { + return value.value; + } + else { + return value; + } + }, + set: function setterHandler(newVal) { + if (getter && !setter) + return; + // If the key is equal to RefKey, skip the unwrap logic + // If and only if "value" is ref and "newVal" is not a ref, + // the assignment should be proxied to "value" ref. + if (key !== RefKey && isRef(val) && !isRef(newVal)) { + val.value = newVal; + } + else if (setter) { + setter.call(target, newVal); + val = newVal; + } + else { + val = newVal; + } + setupAccessControl(newVal); + }, + }); +} +function observe(obj) { + var Vue = getRegisteredVueOrDefault(); + var observed; + if (Vue.observable) { + observed = Vue.observable(obj); + } + else { + var vm = defineComponentInstance(Vue, { + data: { + $$state: obj, + }, + }); + observed = vm._data.$$state; + } + // in SSR, there is no __ob__. Mock for reactivity check + if (!hasOwn(observed, '__ob__')) { + mockReactivityDeep(observed); + } + return observed; +} +/** + * Mock __ob__ for object recursively + */ +function mockReactivityDeep(obj, seen) { + var e_1, _a; + if (seen === void 0) { seen = new Set(); } + if (seen.has(obj) || hasOwn(obj, '__ob__') || !Object.isExtensible(obj)) + return; + def(obj, '__ob__', mockObserver(obj)); + seen.add(obj); + try { + for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) { + var key = _c.value; + var value = obj[key]; + if (!(isPlainObject(value) || isArray(value)) || + isRaw(value) || + !Object.isExtensible(value)) { + continue; + } + mockReactivityDeep(value, seen); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } +} +function mockObserver(value) { + if (value === void 0) { value = {}; } + return { + value: value, + dep: { + notify: noopFn, + depend: noopFn, + addSub: noopFn, + removeSub: noopFn, + }, + }; +} +function createObserver() { + return observe({}).__ob__; +} +function shallowReactive(obj) { + var e_2, _a; + if (!isObject(obj)) { + if ((process.env.NODE_ENV !== 'production')) { + warn('"shallowReactive()" must be called on an object.'); + } + return obj; + } + if (!(isPlainObject(obj) || isArray(obj)) || + isRaw(obj) || + !Object.isExtensible(obj)) { + return obj; + } + var observed = observe(isArray(obj) ? [] : {}); + var ob = observed.__ob__; + var _loop_1 = function (key) { + var val = obj[key]; + var getter; + var setter; + var property = Object.getOwnPropertyDescriptor(obj, key); + if (property) { + if (property.configurable === false) { + return "continue"; + } + getter = property.get; + setter = property.set; + } + proxy(observed, key, { + get: function getterHandler() { + var _a; + (_a = ob.dep) === null || _a === void 0 ? void 0 : _a.depend(); + return val; + }, + set: function setterHandler(newVal) { + var _a; + if (getter && !setter) + return; + if (!isForceTrigger() && val === newVal) + return; + if (setter) { + setter.call(obj, newVal); + } + else { + val = newVal; + } + (_a = ob.dep) === null || _a === void 0 ? void 0 : _a.notify(); + }, + }); + }; + try { + for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) { + var key = _c.value; + _loop_1(key); + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_2) throw e_2.error; } + } + return observed; +} +/** + * Make obj reactivity + */ +function reactive(obj) { + if (!isObject(obj)) { + if ((process.env.NODE_ENV !== 'production')) { + warn('"reactive()" must be called on an object.'); + } + return obj; + } + if (!(isPlainObject(obj) || isArray(obj)) || + isRaw(obj) || + !Object.isExtensible(obj)) { + return obj; + } + var observed = observe(obj); + setupAccessControl(observed); + return observed; +} +/** + * Make sure obj can't be a reactive + */ +function markRaw(obj) { + if (!(isPlainObject(obj) || isArray(obj)) || !Object.isExtensible(obj)) { + return obj; + } + // set the vue observable flag at obj + var ob = createObserver(); + ob[SKIPFLAG] = true; + def(obj, '__ob__', ob); + // mark as Raw + rawSet.set(obj, true); + return obj; +} +function toRaw(observed) { + var _a; + if (isRaw(observed) || !Object.isExtensible(observed)) { + return observed; + } + return ((_a = observed === null || observed === void 0 ? void 0 : observed.__ob__) === null || _a === void 0 ? void 0 : _a.value) || observed; +} + +function isReadonly(obj) { + return readonlySet.has(obj); +} +/** + * **In @vue/composition-api, `reactive` only provides type-level readonly check** + * + * Creates a readonly copy of the original object. Note the returned copy is not + * made reactive, but `readonly` can be called on an already reactive object. + */ +function readonly(target) { + if ((process.env.NODE_ENV !== 'production') && !isObject(target)) { + warn("value cannot be made reactive: ".concat(String(target))); + } + else { + readonlySet.set(target, true); + } + return target; +} +function shallowReadonly(obj) { + var e_1, _a; + if (!isObject(obj)) { + if ((process.env.NODE_ENV !== 'production')) { + warn("value cannot be made reactive: ".concat(String(obj))); + } + return obj; + } + if (!(isPlainObject(obj) || isArray(obj)) || + (!Object.isExtensible(obj) && !isRef(obj))) { + return obj; + } + var readonlyObj = isRef(obj) + ? new RefImpl({}) + : isReactive(obj) + ? observe({}) + : {}; + var source = reactive({}); + var ob = source.__ob__; + var _loop_1 = function (key) { + var val = obj[key]; + var getter; + var property = Object.getOwnPropertyDescriptor(obj, key); + if (property) { + if (property.configurable === false && !isRef(obj)) { + return "continue"; + } + getter = property.get; + } + proxy(readonlyObj, key, { + get: function getterHandler() { + var value = getter ? getter.call(obj) : val; + ob.dep.depend(); + return value; + }, + set: function (v) { + if ((process.env.NODE_ENV !== 'production')) { + warn("Set operation on key \"".concat(key, "\" failed: target is readonly.")); + } + }, + }); + }; + try { + for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) { + var key = _c.value; + _loop_1(key); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } + readonlySet.set(readonlyObj, true); + return readonlyObj; +} + +/** + * Delete a property and trigger change if necessary. + */ +function del(target, key) { + var Vue = getVueConstructor(); + var warn = Vue.util.warn; + if ((process.env.NODE_ENV !== 'production') && (isUndef(target) || isPrimitive(target))) { + warn("Cannot delete reactive property on undefined, null, or primitive value: ".concat(target)); + } + if (isArray(target) && isValidArrayIndex(key)) { + target.splice(key, 1); + return; + } + var ob = target.__ob__; + if (target._isVue || (ob && ob.vmCount)) { + (process.env.NODE_ENV !== 'production') && + warn('Avoid deleting properties on a Vue instance or its root $data ' + + '- just set it to null.'); + return; + } + if (!hasOwn(target, key)) { + return; + } + delete target[key]; + if (!ob) { + return; + } + ob.dep.notify(); +} + +var genName = function (name) { return "on".concat(name[0].toUpperCase() + name.slice(1)); }; +function createLifeCycle(lifeCyclehook) { + return function (callback, target) { + var instance = getCurrentInstanceForFn(genName(lifeCyclehook), target); + return (instance && + injectHookOption(getVueConstructor(), instance, lifeCyclehook, callback)); + }; +} +function injectHookOption(Vue, instance, hook, val) { + var options = instance.proxy.$options; + var mergeFn = Vue.config.optionMergeStrategies[hook]; + var wrappedHook = wrapHookCall(instance, val); + options[hook] = mergeFn(options[hook], wrappedHook); + return wrappedHook; +} +function wrapHookCall(instance, fn) { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var prev = getCurrentInstance(); + setCurrentInstance(instance); + try { + return fn.apply(void 0, __spreadArray([], __read(args), false)); + } + finally { + setCurrentInstance(prev); + } + }; +} +var onBeforeMount = createLifeCycle('beforeMount'); +var onMounted = createLifeCycle('mounted'); +var onBeforeUpdate = createLifeCycle('beforeUpdate'); +var onUpdated = createLifeCycle('updated'); +var onBeforeUnmount = createLifeCycle('beforeDestroy'); +var onUnmounted = createLifeCycle('destroyed'); +var onErrorCaptured = createLifeCycle('errorCaptured'); +var onActivated = createLifeCycle('activated'); +var onDeactivated = createLifeCycle('deactivated'); +var onServerPrefetch = createLifeCycle('serverPrefetch'); + +var fallbackVM; +function flushPreQueue() { + flushQueue(this, WatcherPreFlushQueueKey); +} +function flushPostQueue() { + flushQueue(this, WatcherPostFlushQueueKey); +} +function hasWatchEnv(vm) { + return vm[WatcherPreFlushQueueKey] !== undefined; +} +function installWatchEnv(vm) { + vm[WatcherPreFlushQueueKey] = []; + vm[WatcherPostFlushQueueKey] = []; + vm.$on('hook:beforeUpdate', flushPreQueue); + vm.$on('hook:updated', flushPostQueue); +} +function getWatcherOption(options) { + return __assign({ + immediate: false, + deep: false, + flush: 'pre', + }, options); +} +function getWatchEffectOption(options) { + return __assign({ + flush: 'pre', + }, options); +} +function getWatcherVM() { + var vm = getCurrentScopeVM(); + if (!vm) { + if (!fallbackVM) { + fallbackVM = defineComponentInstance(getVueConstructor()); + } + vm = fallbackVM; + } + else if (!hasWatchEnv(vm)) { + installWatchEnv(vm); + } + return vm; +} +function flushQueue(vm, key) { + var queue = vm[key]; + for (var index = 0; index < queue.length; index++) { + queue[index](); + } + queue.length = 0; +} +function queueFlushJob(vm, fn, mode) { + // flush all when beforeUpdate and updated are not fired + var fallbackFlush = function () { + vm.$nextTick(function () { + if (vm[WatcherPreFlushQueueKey].length) { + flushQueue(vm, WatcherPreFlushQueueKey); + } + if (vm[WatcherPostFlushQueueKey].length) { + flushQueue(vm, WatcherPostFlushQueueKey); + } + }); + }; + switch (mode) { + case 'pre': + fallbackFlush(); + vm[WatcherPreFlushQueueKey].push(fn); + break; + case 'post': + fallbackFlush(); + vm[WatcherPostFlushQueueKey].push(fn); + break; + default: + assert(false, "flush must be one of [\"post\", \"pre\", \"sync\"], but got ".concat(mode)); + break; + } +} +function createVueWatcher(vm, getter, callback, options) { + var index = vm._watchers.length; + // @ts-ignore: use undocumented options + vm.$watch(getter, callback, { + immediate: options.immediateInvokeCallback, + deep: options.deep, + lazy: options.noRun, + sync: options.sync, + before: options.before, + }); + return vm._watchers[index]; +} +// We have to monkeypatch the teardown function so Vue will run +// runCleanup() when it tears down the watcher on unmounted. +function patchWatcherTeardown(watcher, runCleanup) { + var _teardown = watcher.teardown; + watcher.teardown = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + _teardown.apply(watcher, args); + runCleanup(); + }; +} +function createWatcher(vm, source, cb, options) { + var _a; + if ((process.env.NODE_ENV !== 'production') && !cb) { + if (options.immediate !== undefined) { + warn("watch() \"immediate\" option is only respected when using the " + + "watch(source, callback, options?) signature."); + } + if (options.deep !== undefined) { + warn("watch() \"deep\" option is only respected when using the " + + "watch(source, callback, options?) signature."); + } + } + var flushMode = options.flush; + var isSync = flushMode === 'sync'; + var cleanup; + var registerCleanup = function (fn) { + cleanup = function () { + try { + fn(); + } + catch ( + // FIXME: remove any + error) { + logError(error, vm, 'onCleanup()'); + } + }; + }; + // cleanup before running getter again + var runCleanup = function () { + if (cleanup) { + cleanup(); + cleanup = null; + } + }; + var createScheduler = function (fn) { + if (isSync || + /* without a current active instance, ignore pre|post mode */ vm === + fallbackVM) { + return fn; + } + return (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return queueFlushJob(vm, function () { + fn.apply(void 0, __spreadArray([], __read(args), false)); + }, flushMode); + }); + }; + // effect watch + if (cb === null) { + var running_1 = false; + var getter_1 = function () { + // preventing the watch callback being call in the same execution + if (running_1) { + return; + } + try { + running_1 = true; + source(registerCleanup); + } + finally { + running_1 = false; + } + }; + var watcher_1 = createVueWatcher(vm, getter_1, noopFn, { + deep: options.deep || false, + sync: isSync, + before: runCleanup, + }); + patchWatcherTeardown(watcher_1, runCleanup); + // enable the watcher update + watcher_1.lazy = false; + var originGet = watcher_1.get.bind(watcher_1); + // always run watchEffect + watcher_1.get = createScheduler(originGet); + return function () { + watcher_1.teardown(); + }; + } + var deep = options.deep; + var isMultiSource = false; + var getter; + if (isRef(source)) { + getter = function () { return source.value; }; + } + else if (isReactive(source)) { + getter = function () { return source; }; + deep = true; + } + else if (isArray(source)) { + isMultiSource = true; + getter = function () { + return source.map(function (s) { + if (isRef(s)) { + return s.value; + } + else if (isReactive(s)) { + return traverse(s); + } + else if (isFunction(s)) { + return s(); + } + else { + (process.env.NODE_ENV !== 'production') && + warn("Invalid watch source: ".concat(JSON.stringify(s), ".\n A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types."), vm); + return noopFn; + } + }); + }; + } + else if (isFunction(source)) { + getter = source; + } + else { + getter = noopFn; + (process.env.NODE_ENV !== 'production') && + warn("Invalid watch source: ".concat(JSON.stringify(source), ".\n A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types."), vm); + } + if (deep) { + var baseGetter_1 = getter; + getter = function () { return traverse(baseGetter_1()); }; + } + var applyCb = function (n, o) { + if (!deep && + isMultiSource && + n.every(function (v, i) { return isSame(v, o[i]); })) + return; + // cleanup before running cb again + runCleanup(); + return cb(n, o, registerCleanup); + }; + var callback = createScheduler(applyCb); + if (options.immediate) { + var originalCallback_1 = callback; + // `shiftCallback` is used to handle the first sync effect run. + // The subsequent callbacks will redirect to `callback`. + var shiftCallback_1 = function (n, o) { + shiftCallback_1 = originalCallback_1; + // o is undefined on the first call + return applyCb(n, isArray(n) ? [] : o); + }; + callback = function (n, o) { + return shiftCallback_1(n, o); + }; + } + // @ts-ignore: use undocumented option "sync" + var stop = vm.$watch(getter, callback, { + immediate: options.immediate, + deep: deep, + sync: isSync, + }); + // Once again, we have to hack the watcher for proper teardown + var watcher = vm._watchers[vm._watchers.length - 1]; + // if the return value is reactive and deep:true + // watch for changes, this might happen when new key is added + if (isReactive(watcher.value) && ((_a = watcher.value.__ob__) === null || _a === void 0 ? void 0 : _a.dep) && deep) { + watcher.value.__ob__.dep.addSub({ + update: function () { + // this will force the source to be revaluated and the callback + // executed if needed + watcher.run(); + }, + }); + } + patchWatcherTeardown(watcher, runCleanup); + return function () { + stop(); + }; +} +function watchEffect(effect, options) { + var opts = getWatchEffectOption(options); + var vm = getWatcherVM(); + return createWatcher(vm, effect, null, opts); +} +function watchPostEffect(effect) { + return watchEffect(effect, { flush: 'post' }); +} +function watchSyncEffect(effect) { + return watchEffect(effect, { flush: 'sync' }); +} +// implementation +function watch(source, cb, options) { + var callback = null; + if (isFunction(cb)) { + // source watch + callback = cb; + } + else { + // effect watch + if ((process.env.NODE_ENV !== 'production')) { + warn("`watch(fn, options?)` signature has been moved to a separate API. " + + "Use `watchEffect(fn, options?)` instead. `watch` now only " + + "supports `watch(source, cb, options?) signature."); + } + options = cb; + callback = null; + } + var opts = getWatcherOption(options); + var vm = getWatcherVM(); + return createWatcher(vm, source, callback, opts); +} +function traverse(value, seen) { + if (seen === void 0) { seen = new Set(); } + if (!isObject(value) || seen.has(value) || rawSet.has(value)) { + return value; + } + seen.add(value); + if (isRef(value)) { + traverse(value.value, seen); + } + else if (isArray(value)) { + for (var i = 0; i < value.length; i++) { + traverse(value[i], seen); + } + } + else if (isSet(value) || isMap(value)) { + value.forEach(function (v) { + traverse(v, seen); + }); + } + else if (isPlainObject(value)) { + for (var key in value) { + traverse(value[key], seen); + } + } + return value; +} + +// implement +function computed(getterOrOptions) { + var vm = getCurrentScopeVM(); + var getter; + var setter; + if (isFunction(getterOrOptions)) { + getter = getterOrOptions; + } + else { + getter = getterOrOptions.get; + setter = getterOrOptions.set; + } + var computedSetter; + var computedGetter; + if (vm && !vm.$isServer) { + var _a = getVueInternalClasses(), Watcher_1 = _a.Watcher, Dep_1 = _a.Dep; + var watcher_1; + computedGetter = function () { + if (!watcher_1) { + watcher_1 = new Watcher_1(vm, getter, noopFn, { lazy: true }); + } + if (watcher_1.dirty) { + watcher_1.evaluate(); + } + if (Dep_1.target) { + watcher_1.depend(); + } + return watcher_1.value; + }; + computedSetter = function (v) { + if ((process.env.NODE_ENV !== 'production') && !setter) { + warn('Write operation failed: computed value is readonly.', vm); + return; + } + if (setter) { + setter(v); + } + }; + } + else { + // fallback + var computedHost_1 = defineComponentInstance(getVueConstructor(), { + computed: { + $$state: { + get: getter, + set: setter, + }, + }, + }); + vm && vm.$on('hook:destroyed', function () { return computedHost_1.$destroy(); }); + computedGetter = function () { return computedHost_1.$$state; }; + computedSetter = function (v) { + if ((process.env.NODE_ENV !== 'production') && !setter) { + warn('Write operation failed: computed value is readonly.', vm); + return; + } + computedHost_1.$$state = v; + }; + } + return createRef({ + get: computedGetter, + set: computedSetter, + }, !setter, true); +} + +var NOT_FOUND = {}; +function resolveInject(provideKey, vm) { + var source = vm; + while (source) { + // @ts-ignore + if (source._provided && hasOwn(source._provided, provideKey)) { + //@ts-ignore + return source._provided[provideKey]; + } + source = source.$parent; + } + return NOT_FOUND; +} +function provide(key, value) { + var _a; + var vm = (_a = getCurrentInstanceForFn('provide')) === null || _a === void 0 ? void 0 : _a.proxy; + if (!vm) + return; + if (!vm._provided) { + var provideCache_1 = {}; + proxy(vm, '_provided', { + get: function () { return provideCache_1; }, + set: function (v) { return Object.assign(provideCache_1, v); }, + }); + } + vm._provided[key] = value; +} +function inject(key, defaultValue, treatDefaultAsFactory) { + var _a; + if (treatDefaultAsFactory === void 0) { treatDefaultAsFactory = false; } + var vm = (_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy; + if (!vm) { + (process.env.NODE_ENV !== 'production') && + warn("inject() can only be used inside setup() or functional components."); + return; + } + if (!key) { + (process.env.NODE_ENV !== 'production') && warn("injection \"".concat(String(key), "\" not found."), vm); + return defaultValue; + } + var val = resolveInject(key, vm); + if (val !== NOT_FOUND) { + return val; + } + else if (arguments.length > 1) { + return treatDefaultAsFactory && isFunction(defaultValue) + ? defaultValue() + : defaultValue; + } + else if ((process.env.NODE_ENV !== 'production')) { + warn("Injection \"".concat(String(key), "\" not found."), vm); + } +} + +var EMPTY_OBJ = (process.env.NODE_ENV !== 'production') + ? Object.freeze({}) + : {}; +var useCssModule = function (name) { + var _a; + if (name === void 0) { name = '$style'; } + var instance = getCurrentInstance(); + if (!instance) { + (process.env.NODE_ENV !== 'production') && warn("useCssModule must be called inside setup()"); + return EMPTY_OBJ; + } + var mod = (_a = instance.proxy) === null || _a === void 0 ? void 0 : _a[name]; + if (!mod) { + (process.env.NODE_ENV !== 'production') && + warn("Current instance does not have CSS module named \"".concat(name, "\".")); + return EMPTY_OBJ; + } + return mod; +}; +/** + * @deprecated use `useCssModule` instead. + */ +var useCSSModule = useCssModule; + +function createApp(rootComponent, rootProps) { + if (rootProps === void 0) { rootProps = undefined; } + var V = getVueConstructor(); + var mountedVM = undefined; + var provide = {}; + var app = { + config: V.config, + use: V.use.bind(V), + mixin: V.mixin.bind(V), + component: V.component.bind(V), + provide: function (key, value) { + provide[key] = value; + return this; + }, + directive: function (name, dir) { + if (dir) { + V.directive(name, dir); + return app; + } + else { + return V.directive(name); + } + }, + mount: function (el, hydrating) { + if (!mountedVM) { + mountedVM = new V(__assign(__assign({ propsData: rootProps }, rootComponent), { provide: __assign(__assign({}, provide), rootComponent.provide) })); + mountedVM.$mount(el, hydrating); + return mountedVM; + } + else { + if ((process.env.NODE_ENV !== 'production')) { + warn("App has already been mounted.\n" + + "If you want to remount the same app, move your app creation logic " + + "into a factory function and create fresh app instances for each " + + "mount - e.g. `const createMyApp = () => createApp(App)`"); + } + return mountedVM; + } + }, + unmount: function () { + if (mountedVM) { + mountedVM.$destroy(); + mountedVM = undefined; + } + else if ((process.env.NODE_ENV !== 'production')) { + warn("Cannot unmount an app that is not mounted."); + } + }, + }; + return app; +} + +var nextTick = function nextTick() { + var _a; + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return (_a = getVueConstructor()) === null || _a === void 0 ? void 0 : _a.nextTick.apply(this, args); +}; + +var fallbackCreateElement; +var createElement = function createElement() { + var _a; + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var instance = (this === null || this === void 0 ? void 0 : this.proxy) || ((_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy); + if (!instance) { + (process.env.NODE_ENV !== 'production') && + warn('`createElement()` has been called outside of render function.'); + if (!fallbackCreateElement) { + fallbackCreateElement = defineComponentInstance(getVueConstructor()).$createElement; + } + return fallbackCreateElement.apply(fallbackCreateElement, args); + } + return instance.$createElement.apply(instance, args); +}; + +function useSlots() { + return getContext().slots; +} +function useAttrs() { + return getContext().attrs; +} +function getContext() { + var i = getCurrentInstance(); + if ((process.env.NODE_ENV !== 'production') && !i) { + warn("useContext() called without active instance."); + } + return i.setupContext; +} + +function set(vm, key, value) { + var state = (vm.__composition_api_state__ = + vm.__composition_api_state__ || {}); + state[key] = value; +} +function get(vm, key) { + return (vm.__composition_api_state__ || {})[key]; +} +var vmStateManager = { + set: set, + get: get, +}; + +function asVmProperty(vm, propName, propValue) { + var props = vm.$options.props; + if (!(propName in vm) && !(props && hasOwn(props, propName))) { + if (isRef(propValue)) { + proxy(vm, propName, { + get: function () { return propValue.value; }, + set: function (val) { + propValue.value = val; + }, + }); + } + else { + proxy(vm, propName, { + get: function () { + if (isReactive(propValue)) { + propValue.__ob__.dep.depend(); + } + return propValue; + }, + set: function (val) { + propValue = val; + }, + }); + } + if ((process.env.NODE_ENV !== 'production')) { + // expose binding to Vue Devtool as a data property + // delay this until state has been resolved to prevent repeated works + vm.$nextTick(function () { + if (Object.keys(vm._data).indexOf(propName) !== -1) { + return; + } + if (isRef(propValue)) { + proxy(vm._data, propName, { + get: function () { return propValue.value; }, + set: function (val) { + propValue.value = val; + }, + }); + } + else { + proxy(vm._data, propName, { + get: function () { return propValue; }, + set: function (val) { + propValue = val; + }, + }); + } + }); + } + } + else if ((process.env.NODE_ENV !== 'production')) { + if (props && hasOwn(props, propName)) { + warn("The setup binding property \"".concat(propName, "\" is already declared as a prop."), vm); + } + else { + warn("The setup binding property \"".concat(propName, "\" is already declared."), vm); + } + } +} +function updateTemplateRef(vm) { + var rawBindings = vmStateManager.get(vm, 'rawBindings') || {}; + if (!rawBindings || !Object.keys(rawBindings).length) + return; + var refs = vm.$refs; + var oldRefKeys = vmStateManager.get(vm, 'refs') || []; + for (var index = 0; index < oldRefKeys.length; index++) { + var key = oldRefKeys[index]; + var setupValue = rawBindings[key]; + if (!refs[key] && setupValue && isRef(setupValue)) { + setupValue.value = null; + } + } + var newKeys = Object.keys(refs); + var validNewKeys = []; + for (var index = 0; index < newKeys.length; index++) { + var key = newKeys[index]; + var setupValue = rawBindings[key]; + if (refs[key] && setupValue && isRef(setupValue)) { + setupValue.value = refs[key]; + validNewKeys.push(key); + } + } + vmStateManager.set(vm, 'refs', validNewKeys); +} +function afterRender(vm) { + var stack = [vm._vnode]; + var updated; + while (stack.length) { + var vnode = stack.pop(); + if (vnode) { + if (vnode.context) { + updateTemplateRef(vnode.context); + updated = true; + } + if (vnode.children) { + for (var i = 0; i < vnode.children.length; ++i) { + stack.push(vnode.children[i]); + } + } + } + } + if (!updated) { + updateTemplateRef(vm); + } +} +function updateVmAttrs(vm, ctx) { + var e_1, _a; + if (!vm) { + return; + } + var attrBindings = vmStateManager.get(vm, 'attrBindings'); + if (!attrBindings && !ctx) { + // fix 840 + return; + } + if (!attrBindings) { + var observedData = reactive({}); + attrBindings = { ctx: ctx, data: observedData }; + vmStateManager.set(vm, 'attrBindings', attrBindings); + proxy(ctx, 'attrs', { + get: function () { + return attrBindings === null || attrBindings === void 0 ? void 0 : attrBindings.data; + }, + set: function () { + (process.env.NODE_ENV !== 'production') && + warn("Cannot assign to '$attrs' because it is a read-only property", vm); + }, + }); + } + var source = vm.$attrs; + var _loop_1 = function (attr) { + if (!hasOwn(attrBindings.data, attr)) { + proxy(attrBindings.data, attr, { + get: function () { + // to ensure it always return the latest value + return vm.$attrs[attr]; + }, + }); + } + }; + try { + for (var _b = __values(Object.keys(source)), _c = _b.next(); !_c.done; _c = _b.next()) { + var attr = _c.value; + _loop_1(attr); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } +} +function resolveScopedSlots(vm, slotsProxy) { + var parentVNode = vm.$options._parentVnode; + if (!parentVNode) + return; + var prevSlots = vmStateManager.get(vm, 'slots') || []; + var curSlots = resolveSlots(parentVNode.data.scopedSlots, vm.$slots); + // remove staled slots + for (var index = 0; index < prevSlots.length; index++) { + var key = prevSlots[index]; + if (!curSlots[key]) { + delete slotsProxy[key]; + } + } + // proxy fresh slots + var slotNames = Object.keys(curSlots); + for (var index = 0; index < slotNames.length; index++) { + var key = slotNames[index]; + if (!slotsProxy[key]) { + slotsProxy[key] = createSlotProxy(vm, key); + } + } + vmStateManager.set(vm, 'slots', slotNames); +} +function activateCurrentInstance(instance, fn, onError) { + var preVm = getCurrentInstance(); + setCurrentInstance(instance); + try { + return fn(instance); + } + catch ( + // FIXME: remove any + err) { + if (onError) { + onError(err); + } + else { + throw err; + } + } + finally { + setCurrentInstance(preVm); + } +} + +function mixin(Vue) { + Vue.mixin({ + beforeCreate: functionApiInit, + mounted: function () { + afterRender(this); + }, + beforeUpdate: function () { + updateVmAttrs(this); + }, + updated: function () { + afterRender(this); + }, + }); + /** + * Vuex init hook, injected into each instances init hooks list. + */ + function functionApiInit() { + var vm = this; + var $options = vm.$options; + var setup = $options.setup, render = $options.render; + if (render) { + // keep currentInstance accessible for createElement + $options.render = function () { + var _this = this; + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return activateCurrentInstance(toVue3ComponentInstance(vm), function () { + return render.apply(_this, args); + }); + }; + } + if (!setup) { + return; + } + if (!isFunction(setup)) { + if ((process.env.NODE_ENV !== 'production')) { + warn('The "setup" option should be a function that returns a object in component definitions.', vm); + } + return; + } + var data = $options.data; + // wrapper the data option, so we can invoke setup before data get resolved + $options.data = function wrappedData() { + initSetup(vm, vm.$props); + return isFunction(data) + ? data.call(vm, vm) + : data || {}; + }; + } + function initSetup(vm, props) { + if (props === void 0) { props = {}; } + var setup = vm.$options.setup; + var ctx = createSetupContext(vm); + var instance = toVue3ComponentInstance(vm); + instance.setupContext = ctx; + // fake reactive for `toRefs(props)` + def(props, '__ob__', createObserver()); + // resolve scopedSlots and slots to functions + resolveScopedSlots(vm, ctx.slots); + var binding; + activateCurrentInstance(instance, function () { + // make props to be fake reactive, this is for `toRefs(props)` + binding = setup(props, ctx); + }); + if (!binding) + return; + if (isFunction(binding)) { + // keep typescript happy with the binding type. + var bindingFunc_1 = binding; + // keep currentInstance accessible for createElement + vm.$options.render = function () { + resolveScopedSlots(vm, ctx.slots); + return activateCurrentInstance(instance, function () { return bindingFunc_1(); }); + }; + return; + } + else if (isObject(binding)) { + if (isReactive(binding)) { + binding = toRefs(binding); + } + vmStateManager.set(vm, 'rawBindings', binding); + var bindingObj_1 = binding; + Object.keys(bindingObj_1).forEach(function (name) { + var bindingValue = bindingObj_1[name]; + if (!isRef(bindingValue)) { + if (!isReactive(bindingValue)) { + if (isFunction(bindingValue)) { + var copy_1 = bindingValue; + bindingValue = bindingValue.bind(vm); + Object.keys(copy_1).forEach(function (ele) { + bindingValue[ele] = copy_1[ele]; + }); + } + else if (!isObject(bindingValue)) { + bindingValue = ref(bindingValue); + } + else if (hasReactiveArrayChild(bindingValue)) { + // creates a custom reactive properties without make the object explicitly reactive + // NOTE we should try to avoid this, better implementation needed + customReactive(bindingValue); + } + } + else if (isArray(bindingValue)) { + bindingValue = ref(bindingValue); + } + } + asVmProperty(vm, name, bindingValue); + }); + return; + } + if ((process.env.NODE_ENV !== 'production')) { + assert(false, "\"setup\" must return a \"Object\" or a \"Function\", got \"".concat(Object.prototype.toString + .call(binding) + .slice(8, -1), "\"")); + } + } + function customReactive(target, seen) { + if (seen === void 0) { seen = new Set(); } + if (seen.has(target)) + return; + if (!isPlainObject(target) || + isRef(target) || + isReactive(target) || + isRaw(target)) + return; + var Vue = getVueConstructor(); + // @ts-expect-error https://github.com/vuejs/vue/pull/12132 + var defineReactive = Vue.util.defineReactive; + Object.keys(target).forEach(function (k) { + var val = target[k]; + defineReactive(target, k, val); + if (val) { + seen.add(val); + customReactive(val, seen); + } + return; + }); + } + function hasReactiveArrayChild(target, visited) { + if (visited === void 0) { visited = new Map(); } + if (visited.has(target)) { + return visited.get(target); + } + visited.set(target, false); + if (isArray(target) && isReactive(target)) { + visited.set(target, true); + return true; + } + if (!isPlainObject(target) || isRaw(target) || isRef(target)) { + return false; + } + return Object.keys(target).some(function (x) { + return hasReactiveArrayChild(target[x], visited); + }); + } + function createSetupContext(vm) { + var ctx = { slots: {} }; + var propsPlain = [ + 'root', + 'parent', + 'refs', + 'listeners', + 'isServer', + 'ssrContext', + ]; + var methodReturnVoid = ['emit']; + propsPlain.forEach(function (key) { + var srcKey = "$".concat(key); + proxy(ctx, key, { + get: function () { return vm[srcKey]; }, + set: function () { + (process.env.NODE_ENV !== 'production') && + warn("Cannot assign to '".concat(key, "' because it is a read-only property"), vm); + }, + }); + }); + updateVmAttrs(vm, ctx); + methodReturnVoid.forEach(function (key) { + var srcKey = "$".concat(key); + proxy(ctx, key, { + get: function () { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var fn = vm[srcKey]; + fn.apply(vm, args); + }; + }, + }); + }); + if (process.env.NODE_ENV === 'test') { + ctx._vm = vm; + } + return ctx; + } +} + +/** + * Helper that recursively merges two data objects together. + */ +function mergeData(from, to) { + if (!from) + return to; + if (!to) + return from; + var key; + var toVal; + var fromVal; + var keys = hasSymbol ? Reflect.ownKeys(from) : Object.keys(from); + for (var i = 0; i < keys.length; i++) { + key = keys[i]; + // in case the object is already observed... + if (key === '__ob__') + continue; + toVal = to[key]; + fromVal = from[key]; + if (!hasOwn(to, key)) { + to[key] = fromVal; + } + else if (toVal !== fromVal && + isPlainObject(toVal) && + !isRef(toVal) && + isPlainObject(fromVal) && + !isRef(fromVal)) { + mergeData(fromVal, toVal); + } + } + return to; +} +function install(Vue) { + if (isVueRegistered(Vue)) { + if ((process.env.NODE_ENV !== 'production')) { + warn('[vue-composition-api] already installed. Vue.use(VueCompositionAPI) should be called only once.'); + } + return; + } + if ((process.env.NODE_ENV !== 'production')) { + if (Vue.version) { + if (Vue.version[0] !== '2' || Vue.version[1] !== '.') { + warn("[vue-composition-api] only works with Vue 2, v".concat(Vue.version, " found.")); + } + } + else { + warn('[vue-composition-api] no Vue version found'); + } + } + Vue.config.optionMergeStrategies.setup = function (parent, child) { + return function mergedSetupFn(props, context) { + return mergeData(isFunction(parent) ? parent(props, context) || {} : undefined, isFunction(child) ? child(props, context) || {} : undefined); + }; + }; + setVueConstructor(Vue); + mixin(Vue); +} +var Plugin = { + install: function (Vue) { return install(Vue); }, +}; + +// implementation, close to no-op +function defineComponent(options) { + return options; +} + +function defineAsyncComponent(source) { + if (isFunction(source)) { + source = { loader: source }; + } + var loader = source.loader, loadingComponent = source.loadingComponent, errorComponent = source.errorComponent, _a = source.delay, delay = _a === void 0 ? 200 : _a, timeout = source.timeout, // undefined = never times out + _b = source.suspensible, // undefined = never times out + suspensible = _b === void 0 ? false : _b, // in Vue 3 default is true + userOnError = source.onError; + if ((process.env.NODE_ENV !== 'production') && suspensible) { + warn("The suspensiblbe option for async components is not supported in Vue2. It is ignored."); + } + var pendingRequest = null; + var retries = 0; + var retry = function () { + retries++; + pendingRequest = null; + return load(); + }; + var load = function () { + var thisRequest; + return (pendingRequest || + (thisRequest = pendingRequest = + loader() + .catch(function (err) { + err = err instanceof Error ? err : new Error(String(err)); + if (userOnError) { + return new Promise(function (resolve, reject) { + var userRetry = function () { return resolve(retry()); }; + var userFail = function () { return reject(err); }; + userOnError(err, userRetry, userFail, retries + 1); + }); + } + else { + throw err; + } + }) + .then(function (comp) { + if (thisRequest !== pendingRequest && pendingRequest) { + return pendingRequest; + } + if ((process.env.NODE_ENV !== 'production') && !comp) { + warn("Async component loader resolved to undefined. " + + "If you are using retry(), make sure to return its return value."); + } + // interop module default + if (comp && + (comp.__esModule || comp[Symbol.toStringTag] === 'Module')) { + comp = comp.default; + } + if ((process.env.NODE_ENV !== 'production') && comp && !isObject(comp) && !isFunction(comp)) { + throw new Error("Invalid async component load result: ".concat(comp)); + } + return comp; + }))); + }; + return function () { + var component = load(); + return { + component: component, + delay: delay, + timeout: timeout, + error: errorComponent, + loading: loadingComponent, + }; + }; +} + +var version = "1.7.0"; +// auto install when using CDN +if (typeof window !== 'undefined' && window.Vue) { + window.Vue.use(Plugin); +} + +export { EffectScope, computed, createApp, createLifeCycle, createRef, customRef, Plugin as default, defineAsyncComponent, defineComponent, del, effectScope, getCurrentInstance, getCurrentScope, createElement as h, inject, isRaw, isReactive, isReadonly, isRef, markRaw, nextTick, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, provide, proxyRefs, reactive, readonly, ref, set$1 as set, shallowReactive, shallowReadonly, shallowRef, toRaw, toRef, toRefs, triggerRef, unref, useAttrs, useCSSModule, useCssModule, useSlots, version, warn$1 as warn, watch, watchEffect, watchPostEffect, watchSyncEffect }; diff --git a/packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.js b/packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.js new file mode 100644 index 0000000000000000000000000000000000000000..e933fa25720539fc3270cd48d4ace2c234eb3a9b --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.js @@ -0,0 +1,2309 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.VueCompositionAPI = {})); +})(this, (function (exports) { 'use strict'; + + /****************************************************************************** + Copyright (c) Microsoft Corporation. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + PERFORMANCE OF THIS SOFTWARE. + ***************************************************************************** */ + /* global Reflect, Promise */ + + var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + + function __extends(d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + } + + var __assign = function() { + __assign = Object.assign || function __assign(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); + }; + + function __values(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); + } + + function __read(o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; + } + + function __spreadArray(to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); + } + + /** + * Displays a warning message (using console.error) with a stack trace if the + * function is called inside of active component. + * + * @param message warning message to be displayed + */ + function warn$1(message) { + var _a; + warn(message, (_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy); + } + + var activeEffectScope; + var effectScopeStack = []; + var EffectScopeImpl = /** @class */ (function () { + function EffectScopeImpl(vm) { + this.active = true; + this.effects = []; + this.cleanups = []; + this.vm = vm; + } + EffectScopeImpl.prototype.run = function (fn) { + if (this.active) { + try { + this.on(); + return fn(); + } + finally { + this.off(); + } + } + else { + warn$1("cannot run an inactive effect scope."); + } + return; + }; + EffectScopeImpl.prototype.on = function () { + if (this.active) { + effectScopeStack.push(this); + activeEffectScope = this; + } + }; + EffectScopeImpl.prototype.off = function () { + if (this.active) { + effectScopeStack.pop(); + activeEffectScope = effectScopeStack[effectScopeStack.length - 1]; + } + }; + EffectScopeImpl.prototype.stop = function () { + if (this.active) { + this.vm.$destroy(); + this.effects.forEach(function (e) { return e.stop(); }); + this.cleanups.forEach(function (cleanup) { return cleanup(); }); + this.active = false; + } + }; + return EffectScopeImpl; + }()); + var EffectScope = /** @class */ (function (_super) { + __extends(EffectScope, _super); + function EffectScope(detached) { + if (detached === void 0) { detached = false; } + var _this = this; + var vm = undefined; + withCurrentInstanceTrackingDisabled(function () { + vm = defineComponentInstance(getVueConstructor()); + }); + _this = _super.call(this, vm) || this; + if (!detached) { + recordEffectScope(_this); + } + return _this; + } + return EffectScope; + }(EffectScopeImpl)); + function recordEffectScope(effect, scope) { + var _a; + scope = scope || activeEffectScope; + if (scope && scope.active) { + scope.effects.push(effect); + return; + } + // destroy on parent component unmounted + var vm = (_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy; + vm && vm.$on('hook:destroyed', function () { return effect.stop(); }); + } + function effectScope(detached) { + return new EffectScope(detached); + } + function getCurrentScope() { + return activeEffectScope; + } + function onScopeDispose(fn) { + if (activeEffectScope) { + activeEffectScope.cleanups.push(fn); + } + else { + warn$1("onScopeDispose() is called when there is no active effect scope" + + " to be associated with."); + } + } + /** + * @internal + **/ + function getCurrentScopeVM() { + var _a, _b; + return ((_a = getCurrentScope()) === null || _a === void 0 ? void 0 : _a.vm) || ((_b = getCurrentInstance()) === null || _b === void 0 ? void 0 : _b.proxy); + } + /** + * @internal + **/ + function bindCurrentScopeToVM(vm) { + if (!vm.scope) { + var scope_1 = new EffectScopeImpl(vm.proxy); + vm.scope = scope_1; + vm.proxy.$on('hook:destroyed', function () { return scope_1.stop(); }); + } + return vm.scope; + } + + var vueDependency = undefined; + try { + var requiredVue = require('vue'); + if (requiredVue && isVue(requiredVue)) { + vueDependency = requiredVue; + } + else if (requiredVue && + 'default' in requiredVue && + isVue(requiredVue.default)) { + vueDependency = requiredVue.default; + } + } + catch (_a) { + // not available + } + var vueConstructor = null; + var currentInstance = null; + var currentInstanceTracking = true; + var PluginInstalledFlag = '__composition_api_installed__'; + function isVue(obj) { + return obj && isFunction(obj) && obj.name === 'Vue'; + } + function isVueRegistered(Vue) { + // resolve issue: https://github.com/vuejs/composition-api/issues/876#issue-1087619365 + return vueConstructor && hasOwn(Vue, PluginInstalledFlag); + } + function getVueConstructor() { + { + assert(vueConstructor, "must call Vue.use(VueCompositionAPI) before using any function."); + } + return vueConstructor; + } + // returns registered vue or `vue` dependency + function getRegisteredVueOrDefault() { + var constructor = vueConstructor || vueDependency; + { + assert(constructor, "No vue dependency found."); + } + return constructor; + } + function setVueConstructor(Vue) { + // @ts-ignore + if (vueConstructor && Vue.__proto__ !== vueConstructor.__proto__) { + warn('[vue-composition-api] another instance of Vue installed'); + } + vueConstructor = Vue; + Object.defineProperty(Vue, PluginInstalledFlag, { + configurable: true, + writable: true, + value: true, + }); + } + /** + * For `effectScope` to create instance without populate the current instance + * @internal + **/ + function withCurrentInstanceTrackingDisabled(fn) { + var prev = currentInstanceTracking; + currentInstanceTracking = false; + try { + fn(); + } + finally { + currentInstanceTracking = prev; + } + } + function setCurrentInstance(instance) { + if (!currentInstanceTracking) + return; + var prev = currentInstance; + prev === null || prev === void 0 ? void 0 : prev.scope.off(); + currentInstance = instance; + currentInstance === null || currentInstance === void 0 ? void 0 : currentInstance.scope.on(); + } + function getCurrentInstance() { + return currentInstance; + } + var instanceMapCache = new WeakMap(); + function toVue3ComponentInstance(vm) { + if (instanceMapCache.has(vm)) { + return instanceMapCache.get(vm); + } + var instance = { + proxy: vm, + update: vm.$forceUpdate, + type: vm.$options, + uid: vm._uid, + // $emit is defined on prototype and it expected to be bound + emit: vm.$emit.bind(vm), + parent: null, + root: null, // to be immediately set + }; + bindCurrentScopeToVM(instance); + // map vm.$props = + var instanceProps = [ + 'data', + 'props', + 'attrs', + 'refs', + 'vnode', + 'slots', + ]; + instanceProps.forEach(function (prop) { + proxy(instance, prop, { + get: function () { + return vm["$".concat(prop)]; + }, + }); + }); + proxy(instance, 'isMounted', { + get: function () { + // @ts-expect-error private api + return vm._isMounted; + }, + }); + proxy(instance, 'isUnmounted', { + get: function () { + // @ts-expect-error private api + return vm._isDestroyed; + }, + }); + proxy(instance, 'isDeactivated', { + get: function () { + // @ts-expect-error private api + return vm._inactive; + }, + }); + proxy(instance, 'emitted', { + get: function () { + // @ts-expect-error private api + return vm._events; + }, + }); + instanceMapCache.set(vm, instance); + if (vm.$parent) { + instance.parent = toVue3ComponentInstance(vm.$parent); + } + if (vm.$root) { + instance.root = toVue3ComponentInstance(vm.$root); + } + return instance; + } + + var toString = function (x) { return Object.prototype.toString.call(x); }; + function isNative(Ctor) { + return typeof Ctor === 'function' && /native code/.test(Ctor.toString()); + } + var hasSymbol = typeof Symbol !== 'undefined' && + isNative(Symbol) && + typeof Reflect !== 'undefined' && + isNative(Reflect.ownKeys); + var noopFn = function (_) { return _; }; + function proxy(target, key, _a) { + var get = _a.get, set = _a.set; + Object.defineProperty(target, key, { + enumerable: true, + configurable: true, + get: get || noopFn, + set: set || noopFn, + }); + } + function def(obj, key, val, enumerable) { + Object.defineProperty(obj, key, { + value: val, + enumerable: !!enumerable, + writable: true, + configurable: true, + }); + } + function hasOwn(obj, key) { + return Object.hasOwnProperty.call(obj, key); + } + function assert(condition, msg) { + if (!condition) { + throw new Error("[vue-composition-api] ".concat(msg)); + } + } + function isPrimitive(value) { + return (typeof value === 'string' || + typeof value === 'number' || + // $flow-disable-line + typeof value === 'symbol' || + typeof value === 'boolean'); + } + function isArray(x) { + return Array.isArray(x); + } + var objectToString = Object.prototype.toString; + var toTypeString = function (value) { + return objectToString.call(value); + }; + var isMap = function (val) { + return toTypeString(val) === '[object Map]'; + }; + var isSet = function (val) { + return toTypeString(val) === '[object Set]'; + }; + var MAX_VALID_ARRAY_LENGTH = 4294967295; // Math.pow(2, 32) - 1 + function isValidArrayIndex(val) { + var n = parseFloat(String(val)); + return (n >= 0 && + Math.floor(n) === n && + isFinite(val) && + n <= MAX_VALID_ARRAY_LENGTH); + } + function isObject(val) { + return val !== null && typeof val === 'object'; + } + function isPlainObject(x) { + return toString(x) === '[object Object]'; + } + function isFunction(x) { + return typeof x === 'function'; + } + function isUndef(v) { + return v === undefined || v === null; + } + function warn(msg, vm) { + var Vue = getRegisteredVueOrDefault(); + if (!Vue || !Vue.util) + console.warn("[vue-composition-api] ".concat(msg)); + else + Vue.util.warn(msg, vm); + } + function logError(err, vm, info) { + { + warn("Error in ".concat(info, ": \"").concat(err.toString(), "\""), vm); + } + if (typeof window !== 'undefined' && typeof console !== 'undefined') { + console.error(err); + } + else { + throw err; + } + } + /** + * Object.is polyfill + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is + * */ + function isSame(value1, value2) { + if (value1 === value2) { + return value1 !== 0 || 1 / value1 === 1 / value2; + } + else { + return value1 !== value1 && value2 !== value2; + } + } + + function getCurrentInstanceForFn(hook, target) { + target = target || getCurrentInstance(); + if (!target) { + warn("".concat(hook, " is called when there is no active component instance to be ") + + "associated with. " + + "Lifecycle injection APIs can only be used during execution of setup()."); + } + return target; + } + function defineComponentInstance(Ctor, options) { + if (options === void 0) { options = {}; } + var silent = Ctor.config.silent; + Ctor.config.silent = true; + var vm = new Ctor(options); + Ctor.config.silent = silent; + return vm; + } + function isComponentInstance(obj) { + var Vue = getVueConstructor(); + return Vue && obj instanceof Vue; + } + function createSlotProxy(vm, slotName) { + return (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + if (!vm.$scopedSlots[slotName]) { + return warn("slots.".concat(slotName, "() got called outside of the \"render()\" scope"), vm); + } + return vm.$scopedSlots[slotName].apply(vm, args); + }); + } + function resolveSlots(slots, normalSlots) { + var res; + if (!slots) { + res = {}; + } + else if (slots._normalized) { + // fast path 1: child component re-render only, parent did not change + return slots._normalized; + } + else { + res = {}; + for (var key in slots) { + if (slots[key] && key[0] !== '$') { + res[key] = true; + } + } + } + // expose normal slots on scopedSlots + for (var key in normalSlots) { + if (!(key in res)) { + res[key] = true; + } + } + return res; + } + var vueInternalClasses; + var getVueInternalClasses = function () { + if (!vueInternalClasses) { + var vm = defineComponentInstance(getVueConstructor(), { + computed: { + value: function () { + return 0; + }, + }, + }); + // to get Watcher class + var Watcher = vm._computedWatchers.value.constructor; + // to get Dep class + var Dep = vm._data.__ob__.dep.constructor; + vueInternalClasses = { + Watcher: Watcher, + Dep: Dep, + }; + vm.$destroy(); + } + return vueInternalClasses; + }; + + function createSymbol(name) { + return hasSymbol ? Symbol.for(name) : name; + } + var WatcherPreFlushQueueKey = createSymbol('composition-api.preFlushQueue'); + var WatcherPostFlushQueueKey = createSymbol('composition-api.postFlushQueue'); + // must be a string, symbol key is ignored in reactive + var RefKey = 'composition-api.refKey'; + + var accessModifiedSet = new WeakMap(); + var rawSet = new WeakMap(); + var readonlySet = new WeakMap(); + + /** + * Set a property on an object. Adds the new property, triggers change + * notification and intercept it's subsequent access if the property doesn't + * already exist. + */ + function set$1(target, key, val) { + var Vue = getVueConstructor(); + // @ts-expect-error https://github.com/vuejs/vue/pull/12132 + var _a = Vue.util, warn = _a.warn, defineReactive = _a.defineReactive; + if ((isUndef(target) || isPrimitive(target))) { + warn("Cannot set reactive property on undefined, null, or primitive value: ".concat(target)); + } + var ob = target.__ob__; + function ssrMockReactivity() { + // in SSR, there is no __ob__. Mock for reactivity check + if (ob && isObject(val) && !hasOwn(val, '__ob__')) { + mockReactivityDeep(val); + } + } + if (isArray(target)) { + if (isValidArrayIndex(key)) { + target.length = Math.max(target.length, key); + target.splice(key, 1, val); + ssrMockReactivity(); + return val; + } + else if (key === 'length' && val !== target.length) { + target.length = val; + ob === null || ob === void 0 ? void 0 : ob.dep.notify(); + return val; + } + } + if (key in target && !(key in Object.prototype)) { + target[key] = val; + ssrMockReactivity(); + return val; + } + if (target._isVue || (ob && ob.vmCount)) { + warn('Avoid adding reactive properties to a Vue instance or its root $data ' + + 'at runtime - declare it upfront in the data option.'); + return val; + } + if (!ob) { + target[key] = val; + return val; + } + defineReactive(ob.value, key, val); + // IMPORTANT: define access control before trigger watcher + defineAccessControl(target, key, val); + ssrMockReactivity(); + ob.dep.notify(); + return val; + } + + var _isForceTrigger = false; + function isForceTrigger() { + return _isForceTrigger; + } + function setForceTrigger(v) { + _isForceTrigger = v; + } + + var RefImpl = /** @class */ (function () { + function RefImpl(_a) { + var get = _a.get, set = _a.set; + proxy(this, 'value', { + get: get, + set: set, + }); + } + return RefImpl; + }()); + function createRef(options, isReadonly, isComputed) { + if (isReadonly === void 0) { isReadonly = false; } + if (isComputed === void 0) { isComputed = false; } + var r = new RefImpl(options); + // add effect to differentiate refs from computed + if (isComputed) + r.effect = true; + // seal the ref, this could prevent ref from being observed + // It's safe to seal the ref, since we really shouldn't extend it. + // related issues: #79 + var sealed = Object.seal(r); + if (isReadonly) + readonlySet.set(sealed, true); + return sealed; + } + function ref(raw) { + var _a; + if (isRef(raw)) { + return raw; + } + var value = reactive((_a = {}, _a[RefKey] = raw, _a)); + return createRef({ + get: function () { return value[RefKey]; }, + set: function (v) { return (value[RefKey] = v); }, + }); + } + function isRef(value) { + return value instanceof RefImpl; + } + function unref(ref) { + return isRef(ref) ? ref.value : ref; + } + function toRefs(obj) { + if (!isReactive(obj)) { + warn("toRefs() expects a reactive object but received a plain one."); + } + if (!isPlainObject(obj)) + return obj; + var ret = {}; + for (var key in obj) { + ret[key] = toRef(obj, key); + } + return ret; + } + function customRef(factory) { + var version = ref(0); + return createRef(factory(function () { return void version.value; }, function () { + ++version.value; + })); + } + function toRef(object, key) { + if (!(key in object)) + set$1(object, key, undefined); + var v = object[key]; + if (isRef(v)) + return v; + return createRef({ + get: function () { return object[key]; }, + set: function (v) { return (object[key] = v); }, + }); + } + function shallowRef(raw) { + var _a; + if (isRef(raw)) { + return raw; + } + var value = shallowReactive((_a = {}, _a[RefKey] = raw, _a)); + return createRef({ + get: function () { return value[RefKey]; }, + set: function (v) { return (value[RefKey] = v); }, + }); + } + function triggerRef(value) { + if (!isRef(value)) + return; + setForceTrigger(true); + value.value = value.value; + setForceTrigger(false); + } + function proxyRefs(objectWithRefs) { + var _a, e_1, _b; + if (isReactive(objectWithRefs)) { + return objectWithRefs; + } + var value = reactive((_a = {}, _a[RefKey] = objectWithRefs, _a)); + def(value, RefKey, value[RefKey], false); + var _loop_1 = function (key) { + proxy(value, key, { + get: function () { + if (isRef(value[RefKey][key])) { + return value[RefKey][key].value; + } + return value[RefKey][key]; + }, + set: function (v) { + if (isRef(value[RefKey][key])) { + return (value[RefKey][key].value = unref(v)); + } + value[RefKey][key] = unref(v); + }, + }); + }; + try { + for (var _c = __values(Object.keys(objectWithRefs)), _d = _c.next(); !_d.done; _d = _c.next()) { + var key = _d.value; + _loop_1(key); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_d && !_d.done && (_b = _c.return)) _b.call(_c); + } + finally { if (e_1) throw e_1.error; } + } + return value; + } + + var SKIPFLAG = '__v_skip'; + function isRaw(obj) { + var _a; + return Boolean(obj && + hasOwn(obj, '__ob__') && + typeof obj.__ob__ === 'object' && + ((_a = obj.__ob__) === null || _a === void 0 ? void 0 : _a[SKIPFLAG])); + } + function isReactive(obj) { + var _a; + return Boolean(obj && + hasOwn(obj, '__ob__') && + typeof obj.__ob__ === 'object' && + !((_a = obj.__ob__) === null || _a === void 0 ? void 0 : _a[SKIPFLAG])); + } + /** + * Proxing property access of target. + * We can do unwrapping and other things here. + */ + function setupAccessControl(target) { + if (!isPlainObject(target) || + isRaw(target) || + isArray(target) || + isRef(target) || + isComponentInstance(target) || + accessModifiedSet.has(target)) + return; + accessModifiedSet.set(target, true); + var keys = Object.keys(target); + for (var i = 0; i < keys.length; i++) { + defineAccessControl(target, keys[i]); + } + } + /** + * Auto unwrapping when access property + */ + function defineAccessControl(target, key, val) { + if (key === '__ob__') + return; + if (isRaw(target[key])) + return; + var getter; + var setter; + var property = Object.getOwnPropertyDescriptor(target, key); + if (property) { + if (property.configurable === false) { + return; + } + getter = property.get; + setter = property.set; + if ((!getter || setter) /* not only have getter */ && + arguments.length === 2) { + val = target[key]; + } + } + setupAccessControl(val); + proxy(target, key, { + get: function getterHandler() { + var value = getter ? getter.call(target) : val; + // if the key is equal to RefKey, skip the unwrap logic + if (key !== RefKey && isRef(value)) { + return value.value; + } + else { + return value; + } + }, + set: function setterHandler(newVal) { + if (getter && !setter) + return; + // If the key is equal to RefKey, skip the unwrap logic + // If and only if "value" is ref and "newVal" is not a ref, + // the assignment should be proxied to "value" ref. + if (key !== RefKey && isRef(val) && !isRef(newVal)) { + val.value = newVal; + } + else if (setter) { + setter.call(target, newVal); + val = newVal; + } + else { + val = newVal; + } + setupAccessControl(newVal); + }, + }); + } + function observe(obj) { + var Vue = getRegisteredVueOrDefault(); + var observed; + if (Vue.observable) { + observed = Vue.observable(obj); + } + else { + var vm = defineComponentInstance(Vue, { + data: { + $$state: obj, + }, + }); + observed = vm._data.$$state; + } + // in SSR, there is no __ob__. Mock for reactivity check + if (!hasOwn(observed, '__ob__')) { + mockReactivityDeep(observed); + } + return observed; + } + /** + * Mock __ob__ for object recursively + */ + function mockReactivityDeep(obj, seen) { + var e_1, _a; + if (seen === void 0) { seen = new Set(); } + if (seen.has(obj) || hasOwn(obj, '__ob__') || !Object.isExtensible(obj)) + return; + def(obj, '__ob__', mockObserver(obj)); + seen.add(obj); + try { + for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) { + var key = _c.value; + var value = obj[key]; + if (!(isPlainObject(value) || isArray(value)) || + isRaw(value) || + !Object.isExtensible(value)) { + continue; + } + mockReactivityDeep(value, seen); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } + } + function mockObserver(value) { + if (value === void 0) { value = {}; } + return { + value: value, + dep: { + notify: noopFn, + depend: noopFn, + addSub: noopFn, + removeSub: noopFn, + }, + }; + } + function createObserver() { + return observe({}).__ob__; + } + function shallowReactive(obj) { + var e_2, _a; + if (!isObject(obj)) { + { + warn('"shallowReactive()" must be called on an object.'); + } + return obj; + } + if (!(isPlainObject(obj) || isArray(obj)) || + isRaw(obj) || + !Object.isExtensible(obj)) { + return obj; + } + var observed = observe(isArray(obj) ? [] : {}); + var ob = observed.__ob__; + var _loop_1 = function (key) { + var val = obj[key]; + var getter; + var setter; + var property = Object.getOwnPropertyDescriptor(obj, key); + if (property) { + if (property.configurable === false) { + return "continue"; + } + getter = property.get; + setter = property.set; + } + proxy(observed, key, { + get: function getterHandler() { + var _a; + (_a = ob.dep) === null || _a === void 0 ? void 0 : _a.depend(); + return val; + }, + set: function setterHandler(newVal) { + var _a; + if (getter && !setter) + return; + if (!isForceTrigger() && val === newVal) + return; + if (setter) { + setter.call(obj, newVal); + } + else { + val = newVal; + } + (_a = ob.dep) === null || _a === void 0 ? void 0 : _a.notify(); + }, + }); + }; + try { + for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) { + var key = _c.value; + _loop_1(key); + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_2) throw e_2.error; } + } + return observed; + } + /** + * Make obj reactivity + */ + function reactive(obj) { + if (!isObject(obj)) { + { + warn('"reactive()" must be called on an object.'); + } + return obj; + } + if (!(isPlainObject(obj) || isArray(obj)) || + isRaw(obj) || + !Object.isExtensible(obj)) { + return obj; + } + var observed = observe(obj); + setupAccessControl(observed); + return observed; + } + /** + * Make sure obj can't be a reactive + */ + function markRaw(obj) { + if (!(isPlainObject(obj) || isArray(obj)) || !Object.isExtensible(obj)) { + return obj; + } + // set the vue observable flag at obj + var ob = createObserver(); + ob[SKIPFLAG] = true; + def(obj, '__ob__', ob); + // mark as Raw + rawSet.set(obj, true); + return obj; + } + function toRaw(observed) { + var _a; + if (isRaw(observed) || !Object.isExtensible(observed)) { + return observed; + } + return ((_a = observed === null || observed === void 0 ? void 0 : observed.__ob__) === null || _a === void 0 ? void 0 : _a.value) || observed; + } + + function isReadonly(obj) { + return readonlySet.has(obj); + } + /** + * **In @vue/composition-api, `reactive` only provides type-level readonly check** + * + * Creates a readonly copy of the original object. Note the returned copy is not + * made reactive, but `readonly` can be called on an already reactive object. + */ + function readonly(target) { + if (!isObject(target)) { + warn("value cannot be made reactive: ".concat(String(target))); + } + else { + readonlySet.set(target, true); + } + return target; + } + function shallowReadonly(obj) { + var e_1, _a; + if (!isObject(obj)) { + { + warn("value cannot be made reactive: ".concat(String(obj))); + } + return obj; + } + if (!(isPlainObject(obj) || isArray(obj)) || + (!Object.isExtensible(obj) && !isRef(obj))) { + return obj; + } + var readonlyObj = isRef(obj) + ? new RefImpl({}) + : isReactive(obj) + ? observe({}) + : {}; + var source = reactive({}); + var ob = source.__ob__; + var _loop_1 = function (key) { + var val = obj[key]; + var getter; + var property = Object.getOwnPropertyDescriptor(obj, key); + if (property) { + if (property.configurable === false && !isRef(obj)) { + return "continue"; + } + getter = property.get; + } + proxy(readonlyObj, key, { + get: function getterHandler() { + var value = getter ? getter.call(obj) : val; + ob.dep.depend(); + return value; + }, + set: function (v) { + { + warn("Set operation on key \"".concat(key, "\" failed: target is readonly.")); + } + }, + }); + }; + try { + for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) { + var key = _c.value; + _loop_1(key); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } + readonlySet.set(readonlyObj, true); + return readonlyObj; + } + + /** + * Delete a property and trigger change if necessary. + */ + function del(target, key) { + var Vue = getVueConstructor(); + var warn = Vue.util.warn; + if ((isUndef(target) || isPrimitive(target))) { + warn("Cannot delete reactive property on undefined, null, or primitive value: ".concat(target)); + } + if (isArray(target) && isValidArrayIndex(key)) { + target.splice(key, 1); + return; + } + var ob = target.__ob__; + if (target._isVue || (ob && ob.vmCount)) { + warn('Avoid deleting properties on a Vue instance or its root $data ' + + '- just set it to null.'); + return; + } + if (!hasOwn(target, key)) { + return; + } + delete target[key]; + if (!ob) { + return; + } + ob.dep.notify(); + } + + var genName = function (name) { return "on".concat(name[0].toUpperCase() + name.slice(1)); }; + function createLifeCycle(lifeCyclehook) { + return function (callback, target) { + var instance = getCurrentInstanceForFn(genName(lifeCyclehook), target); + return (instance && + injectHookOption(getVueConstructor(), instance, lifeCyclehook, callback)); + }; + } + function injectHookOption(Vue, instance, hook, val) { + var options = instance.proxy.$options; + var mergeFn = Vue.config.optionMergeStrategies[hook]; + var wrappedHook = wrapHookCall(instance, val); + options[hook] = mergeFn(options[hook], wrappedHook); + return wrappedHook; + } + function wrapHookCall(instance, fn) { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var prev = getCurrentInstance(); + setCurrentInstance(instance); + try { + return fn.apply(void 0, __spreadArray([], __read(args), false)); + } + finally { + setCurrentInstance(prev); + } + }; + } + var onBeforeMount = createLifeCycle('beforeMount'); + var onMounted = createLifeCycle('mounted'); + var onBeforeUpdate = createLifeCycle('beforeUpdate'); + var onUpdated = createLifeCycle('updated'); + var onBeforeUnmount = createLifeCycle('beforeDestroy'); + var onUnmounted = createLifeCycle('destroyed'); + var onErrorCaptured = createLifeCycle('errorCaptured'); + var onActivated = createLifeCycle('activated'); + var onDeactivated = createLifeCycle('deactivated'); + var onServerPrefetch = createLifeCycle('serverPrefetch'); + + var fallbackVM; + function flushPreQueue() { + flushQueue(this, WatcherPreFlushQueueKey); + } + function flushPostQueue() { + flushQueue(this, WatcherPostFlushQueueKey); + } + function hasWatchEnv(vm) { + return vm[WatcherPreFlushQueueKey] !== undefined; + } + function installWatchEnv(vm) { + vm[WatcherPreFlushQueueKey] = []; + vm[WatcherPostFlushQueueKey] = []; + vm.$on('hook:beforeUpdate', flushPreQueue); + vm.$on('hook:updated', flushPostQueue); + } + function getWatcherOption(options) { + return __assign({ + immediate: false, + deep: false, + flush: 'pre', + }, options); + } + function getWatchEffectOption(options) { + return __assign({ + flush: 'pre', + }, options); + } + function getWatcherVM() { + var vm = getCurrentScopeVM(); + if (!vm) { + if (!fallbackVM) { + fallbackVM = defineComponentInstance(getVueConstructor()); + } + vm = fallbackVM; + } + else if (!hasWatchEnv(vm)) { + installWatchEnv(vm); + } + return vm; + } + function flushQueue(vm, key) { + var queue = vm[key]; + for (var index = 0; index < queue.length; index++) { + queue[index](); + } + queue.length = 0; + } + function queueFlushJob(vm, fn, mode) { + // flush all when beforeUpdate and updated are not fired + var fallbackFlush = function () { + vm.$nextTick(function () { + if (vm[WatcherPreFlushQueueKey].length) { + flushQueue(vm, WatcherPreFlushQueueKey); + } + if (vm[WatcherPostFlushQueueKey].length) { + flushQueue(vm, WatcherPostFlushQueueKey); + } + }); + }; + switch (mode) { + case 'pre': + fallbackFlush(); + vm[WatcherPreFlushQueueKey].push(fn); + break; + case 'post': + fallbackFlush(); + vm[WatcherPostFlushQueueKey].push(fn); + break; + default: + assert(false, "flush must be one of [\"post\", \"pre\", \"sync\"], but got ".concat(mode)); + break; + } + } + function createVueWatcher(vm, getter, callback, options) { + var index = vm._watchers.length; + // @ts-ignore: use undocumented options + vm.$watch(getter, callback, { + immediate: options.immediateInvokeCallback, + deep: options.deep, + lazy: options.noRun, + sync: options.sync, + before: options.before, + }); + return vm._watchers[index]; + } + // We have to monkeypatch the teardown function so Vue will run + // runCleanup() when it tears down the watcher on unmounted. + function patchWatcherTeardown(watcher, runCleanup) { + var _teardown = watcher.teardown; + watcher.teardown = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + _teardown.apply(watcher, args); + runCleanup(); + }; + } + function createWatcher(vm, source, cb, options) { + var _a; + if (!cb) { + if (options.immediate !== undefined) { + warn("watch() \"immediate\" option is only respected when using the " + + "watch(source, callback, options?) signature."); + } + if (options.deep !== undefined) { + warn("watch() \"deep\" option is only respected when using the " + + "watch(source, callback, options?) signature."); + } + } + var flushMode = options.flush; + var isSync = flushMode === 'sync'; + var cleanup; + var registerCleanup = function (fn) { + cleanup = function () { + try { + fn(); + } + catch ( + // FIXME: remove any + error) { + logError(error, vm, 'onCleanup()'); + } + }; + }; + // cleanup before running getter again + var runCleanup = function () { + if (cleanup) { + cleanup(); + cleanup = null; + } + }; + var createScheduler = function (fn) { + if (isSync || + /* without a current active instance, ignore pre|post mode */ vm === + fallbackVM) { + return fn; + } + return (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return queueFlushJob(vm, function () { + fn.apply(void 0, __spreadArray([], __read(args), false)); + }, flushMode); + }); + }; + // effect watch + if (cb === null) { + var running_1 = false; + var getter_1 = function () { + // preventing the watch callback being call in the same execution + if (running_1) { + return; + } + try { + running_1 = true; + source(registerCleanup); + } + finally { + running_1 = false; + } + }; + var watcher_1 = createVueWatcher(vm, getter_1, noopFn, { + deep: options.deep || false, + sync: isSync, + before: runCleanup, + }); + patchWatcherTeardown(watcher_1, runCleanup); + // enable the watcher update + watcher_1.lazy = false; + var originGet = watcher_1.get.bind(watcher_1); + // always run watchEffect + watcher_1.get = createScheduler(originGet); + return function () { + watcher_1.teardown(); + }; + } + var deep = options.deep; + var isMultiSource = false; + var getter; + if (isRef(source)) { + getter = function () { return source.value; }; + } + else if (isReactive(source)) { + getter = function () { return source; }; + deep = true; + } + else if (isArray(source)) { + isMultiSource = true; + getter = function () { + return source.map(function (s) { + if (isRef(s)) { + return s.value; + } + else if (isReactive(s)) { + return traverse(s); + } + else if (isFunction(s)) { + return s(); + } + else { + warn("Invalid watch source: ".concat(JSON.stringify(s), ".\n A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types."), vm); + return noopFn; + } + }); + }; + } + else if (isFunction(source)) { + getter = source; + } + else { + getter = noopFn; + warn("Invalid watch source: ".concat(JSON.stringify(source), ".\n A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types."), vm); + } + if (deep) { + var baseGetter_1 = getter; + getter = function () { return traverse(baseGetter_1()); }; + } + var applyCb = function (n, o) { + if (!deep && + isMultiSource && + n.every(function (v, i) { return isSame(v, o[i]); })) + return; + // cleanup before running cb again + runCleanup(); + return cb(n, o, registerCleanup); + }; + var callback = createScheduler(applyCb); + if (options.immediate) { + var originalCallback_1 = callback; + // `shiftCallback` is used to handle the first sync effect run. + // The subsequent callbacks will redirect to `callback`. + var shiftCallback_1 = function (n, o) { + shiftCallback_1 = originalCallback_1; + // o is undefined on the first call + return applyCb(n, isArray(n) ? [] : o); + }; + callback = function (n, o) { + return shiftCallback_1(n, o); + }; + } + // @ts-ignore: use undocumented option "sync" + var stop = vm.$watch(getter, callback, { + immediate: options.immediate, + deep: deep, + sync: isSync, + }); + // Once again, we have to hack the watcher for proper teardown + var watcher = vm._watchers[vm._watchers.length - 1]; + // if the return value is reactive and deep:true + // watch for changes, this might happen when new key is added + if (isReactive(watcher.value) && ((_a = watcher.value.__ob__) === null || _a === void 0 ? void 0 : _a.dep) && deep) { + watcher.value.__ob__.dep.addSub({ + update: function () { + // this will force the source to be revaluated and the callback + // executed if needed + watcher.run(); + }, + }); + } + patchWatcherTeardown(watcher, runCleanup); + return function () { + stop(); + }; + } + function watchEffect(effect, options) { + var opts = getWatchEffectOption(options); + var vm = getWatcherVM(); + return createWatcher(vm, effect, null, opts); + } + function watchPostEffect(effect) { + return watchEffect(effect, { flush: 'post' }); + } + function watchSyncEffect(effect) { + return watchEffect(effect, { flush: 'sync' }); + } + // implementation + function watch(source, cb, options) { + var callback = null; + if (isFunction(cb)) { + // source watch + callback = cb; + } + else { + // effect watch + { + warn("`watch(fn, options?)` signature has been moved to a separate API. " + + "Use `watchEffect(fn, options?)` instead. `watch` now only " + + "supports `watch(source, cb, options?) signature."); + } + options = cb; + callback = null; + } + var opts = getWatcherOption(options); + var vm = getWatcherVM(); + return createWatcher(vm, source, callback, opts); + } + function traverse(value, seen) { + if (seen === void 0) { seen = new Set(); } + if (!isObject(value) || seen.has(value) || rawSet.has(value)) { + return value; + } + seen.add(value); + if (isRef(value)) { + traverse(value.value, seen); + } + else if (isArray(value)) { + for (var i = 0; i < value.length; i++) { + traverse(value[i], seen); + } + } + else if (isSet(value) || isMap(value)) { + value.forEach(function (v) { + traverse(v, seen); + }); + } + else if (isPlainObject(value)) { + for (var key in value) { + traverse(value[key], seen); + } + } + return value; + } + + // implement + function computed(getterOrOptions) { + var vm = getCurrentScopeVM(); + var getter; + var setter; + if (isFunction(getterOrOptions)) { + getter = getterOrOptions; + } + else { + getter = getterOrOptions.get; + setter = getterOrOptions.set; + } + var computedSetter; + var computedGetter; + if (vm && !vm.$isServer) { + var _a = getVueInternalClasses(), Watcher_1 = _a.Watcher, Dep_1 = _a.Dep; + var watcher_1; + computedGetter = function () { + if (!watcher_1) { + watcher_1 = new Watcher_1(vm, getter, noopFn, { lazy: true }); + } + if (watcher_1.dirty) { + watcher_1.evaluate(); + } + if (Dep_1.target) { + watcher_1.depend(); + } + return watcher_1.value; + }; + computedSetter = function (v) { + if (!setter) { + warn('Write operation failed: computed value is readonly.', vm); + return; + } + if (setter) { + setter(v); + } + }; + } + else { + // fallback + var computedHost_1 = defineComponentInstance(getVueConstructor(), { + computed: { + $$state: { + get: getter, + set: setter, + }, + }, + }); + vm && vm.$on('hook:destroyed', function () { return computedHost_1.$destroy(); }); + computedGetter = function () { return computedHost_1.$$state; }; + computedSetter = function (v) { + if (!setter) { + warn('Write operation failed: computed value is readonly.', vm); + return; + } + computedHost_1.$$state = v; + }; + } + return createRef({ + get: computedGetter, + set: computedSetter, + }, !setter, true); + } + + var NOT_FOUND = {}; + function resolveInject(provideKey, vm) { + var source = vm; + while (source) { + // @ts-ignore + if (source._provided && hasOwn(source._provided, provideKey)) { + //@ts-ignore + return source._provided[provideKey]; + } + source = source.$parent; + } + return NOT_FOUND; + } + function provide(key, value) { + var _a; + var vm = (_a = getCurrentInstanceForFn('provide')) === null || _a === void 0 ? void 0 : _a.proxy; + if (!vm) + return; + if (!vm._provided) { + var provideCache_1 = {}; + proxy(vm, '_provided', { + get: function () { return provideCache_1; }, + set: function (v) { return Object.assign(provideCache_1, v); }, + }); + } + vm._provided[key] = value; + } + function inject(key, defaultValue, treatDefaultAsFactory) { + var _a; + if (treatDefaultAsFactory === void 0) { treatDefaultAsFactory = false; } + var vm = (_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy; + if (!vm) { + warn("inject() can only be used inside setup() or functional components."); + return; + } + if (!key) { + warn("injection \"".concat(String(key), "\" not found."), vm); + return defaultValue; + } + var val = resolveInject(key, vm); + if (val !== NOT_FOUND) { + return val; + } + else if (arguments.length > 1) { + return treatDefaultAsFactory && isFunction(defaultValue) + ? defaultValue() + : defaultValue; + } + else { + warn("Injection \"".concat(String(key), "\" not found."), vm); + } + } + + var EMPTY_OBJ = Object.freeze({}) + ; + var useCssModule = function (name) { + var _a; + if (name === void 0) { name = '$style'; } + var instance = getCurrentInstance(); + if (!instance) { + warn("useCssModule must be called inside setup()"); + return EMPTY_OBJ; + } + var mod = (_a = instance.proxy) === null || _a === void 0 ? void 0 : _a[name]; + if (!mod) { + warn("Current instance does not have CSS module named \"".concat(name, "\".")); + return EMPTY_OBJ; + } + return mod; + }; + /** + * @deprecated use `useCssModule` instead. + */ + var useCSSModule = useCssModule; + + function createApp(rootComponent, rootProps) { + if (rootProps === void 0) { rootProps = undefined; } + var V = getVueConstructor(); + var mountedVM = undefined; + var provide = {}; + var app = { + config: V.config, + use: V.use.bind(V), + mixin: V.mixin.bind(V), + component: V.component.bind(V), + provide: function (key, value) { + provide[key] = value; + return this; + }, + directive: function (name, dir) { + if (dir) { + V.directive(name, dir); + return app; + } + else { + return V.directive(name); + } + }, + mount: function (el, hydrating) { + if (!mountedVM) { + mountedVM = new V(__assign(__assign({ propsData: rootProps }, rootComponent), { provide: __assign(__assign({}, provide), rootComponent.provide) })); + mountedVM.$mount(el, hydrating); + return mountedVM; + } + else { + { + warn("App has already been mounted.\n" + + "If you want to remount the same app, move your app creation logic " + + "into a factory function and create fresh app instances for each " + + "mount - e.g. `const createMyApp = () => createApp(App)`"); + } + return mountedVM; + } + }, + unmount: function () { + if (mountedVM) { + mountedVM.$destroy(); + mountedVM = undefined; + } + else { + warn("Cannot unmount an app that is not mounted."); + } + }, + }; + return app; + } + + var nextTick = function nextTick() { + var _a; + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return (_a = getVueConstructor()) === null || _a === void 0 ? void 0 : _a.nextTick.apply(this, args); + }; + + var fallbackCreateElement; + var createElement = function createElement() { + var _a; + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var instance = (this === null || this === void 0 ? void 0 : this.proxy) || ((_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy); + if (!instance) { + warn('`createElement()` has been called outside of render function.'); + if (!fallbackCreateElement) { + fallbackCreateElement = defineComponentInstance(getVueConstructor()).$createElement; + } + return fallbackCreateElement.apply(fallbackCreateElement, args); + } + return instance.$createElement.apply(instance, args); + }; + + function useSlots() { + return getContext().slots; + } + function useAttrs() { + return getContext().attrs; + } + function getContext() { + var i = getCurrentInstance(); + if (!i) { + warn("useContext() called without active instance."); + } + return i.setupContext; + } + + function set(vm, key, value) { + var state = (vm.__composition_api_state__ = + vm.__composition_api_state__ || {}); + state[key] = value; + } + function get(vm, key) { + return (vm.__composition_api_state__ || {})[key]; + } + var vmStateManager = { + set: set, + get: get, + }; + + function asVmProperty(vm, propName, propValue) { + var props = vm.$options.props; + if (!(propName in vm) && !(props && hasOwn(props, propName))) { + if (isRef(propValue)) { + proxy(vm, propName, { + get: function () { return propValue.value; }, + set: function (val) { + propValue.value = val; + }, + }); + } + else { + proxy(vm, propName, { + get: function () { + if (isReactive(propValue)) { + propValue.__ob__.dep.depend(); + } + return propValue; + }, + set: function (val) { + propValue = val; + }, + }); + } + { + // expose binding to Vue Devtool as a data property + // delay this until state has been resolved to prevent repeated works + vm.$nextTick(function () { + if (Object.keys(vm._data).indexOf(propName) !== -1) { + return; + } + if (isRef(propValue)) { + proxy(vm._data, propName, { + get: function () { return propValue.value; }, + set: function (val) { + propValue.value = val; + }, + }); + } + else { + proxy(vm._data, propName, { + get: function () { return propValue; }, + set: function (val) { + propValue = val; + }, + }); + } + }); + } + } + else { + if (props && hasOwn(props, propName)) { + warn("The setup binding property \"".concat(propName, "\" is already declared as a prop."), vm); + } + else { + warn("The setup binding property \"".concat(propName, "\" is already declared."), vm); + } + } + } + function updateTemplateRef(vm) { + var rawBindings = vmStateManager.get(vm, 'rawBindings') || {}; + if (!rawBindings || !Object.keys(rawBindings).length) + return; + var refs = vm.$refs; + var oldRefKeys = vmStateManager.get(vm, 'refs') || []; + for (var index = 0; index < oldRefKeys.length; index++) { + var key = oldRefKeys[index]; + var setupValue = rawBindings[key]; + if (!refs[key] && setupValue && isRef(setupValue)) { + setupValue.value = null; + } + } + var newKeys = Object.keys(refs); + var validNewKeys = []; + for (var index = 0; index < newKeys.length; index++) { + var key = newKeys[index]; + var setupValue = rawBindings[key]; + if (refs[key] && setupValue && isRef(setupValue)) { + setupValue.value = refs[key]; + validNewKeys.push(key); + } + } + vmStateManager.set(vm, 'refs', validNewKeys); + } + function afterRender(vm) { + var stack = [vm._vnode]; + var updated; + while (stack.length) { + var vnode = stack.pop(); + if (vnode) { + if (vnode.context) { + updateTemplateRef(vnode.context); + updated = true; + } + if (vnode.children) { + for (var i = 0; i < vnode.children.length; ++i) { + stack.push(vnode.children[i]); + } + } + } + } + if (!updated) { + updateTemplateRef(vm); + } + } + function updateVmAttrs(vm, ctx) { + var e_1, _a; + if (!vm) { + return; + } + var attrBindings = vmStateManager.get(vm, 'attrBindings'); + if (!attrBindings && !ctx) { + // fix 840 + return; + } + if (!attrBindings) { + var observedData = reactive({}); + attrBindings = { ctx: ctx, data: observedData }; + vmStateManager.set(vm, 'attrBindings', attrBindings); + proxy(ctx, 'attrs', { + get: function () { + return attrBindings === null || attrBindings === void 0 ? void 0 : attrBindings.data; + }, + set: function () { + warn("Cannot assign to '$attrs' because it is a read-only property", vm); + }, + }); + } + var source = vm.$attrs; + var _loop_1 = function (attr) { + if (!hasOwn(attrBindings.data, attr)) { + proxy(attrBindings.data, attr, { + get: function () { + // to ensure it always return the latest value + return vm.$attrs[attr]; + }, + }); + } + }; + try { + for (var _b = __values(Object.keys(source)), _c = _b.next(); !_c.done; _c = _b.next()) { + var attr = _c.value; + _loop_1(attr); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } + } + function resolveScopedSlots(vm, slotsProxy) { + var parentVNode = vm.$options._parentVnode; + if (!parentVNode) + return; + var prevSlots = vmStateManager.get(vm, 'slots') || []; + var curSlots = resolveSlots(parentVNode.data.scopedSlots, vm.$slots); + // remove staled slots + for (var index = 0; index < prevSlots.length; index++) { + var key = prevSlots[index]; + if (!curSlots[key]) { + delete slotsProxy[key]; + } + } + // proxy fresh slots + var slotNames = Object.keys(curSlots); + for (var index = 0; index < slotNames.length; index++) { + var key = slotNames[index]; + if (!slotsProxy[key]) { + slotsProxy[key] = createSlotProxy(vm, key); + } + } + vmStateManager.set(vm, 'slots', slotNames); + } + function activateCurrentInstance(instance, fn, onError) { + var preVm = getCurrentInstance(); + setCurrentInstance(instance); + try { + return fn(instance); + } + catch ( + // FIXME: remove any + err) { + if (onError) { + onError(err); + } + else { + throw err; + } + } + finally { + setCurrentInstance(preVm); + } + } + + function mixin(Vue) { + Vue.mixin({ + beforeCreate: functionApiInit, + mounted: function () { + afterRender(this); + }, + beforeUpdate: function () { + updateVmAttrs(this); + }, + updated: function () { + afterRender(this); + }, + }); + /** + * Vuex init hook, injected into each instances init hooks list. + */ + function functionApiInit() { + var vm = this; + var $options = vm.$options; + var setup = $options.setup, render = $options.render; + if (render) { + // keep currentInstance accessible for createElement + $options.render = function () { + var _this = this; + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return activateCurrentInstance(toVue3ComponentInstance(vm), function () { + return render.apply(_this, args); + }); + }; + } + if (!setup) { + return; + } + if (!isFunction(setup)) { + { + warn('The "setup" option should be a function that returns a object in component definitions.', vm); + } + return; + } + var data = $options.data; + // wrapper the data option, so we can invoke setup before data get resolved + $options.data = function wrappedData() { + initSetup(vm, vm.$props); + return isFunction(data) + ? data.call(vm, vm) + : data || {}; + }; + } + function initSetup(vm, props) { + if (props === void 0) { props = {}; } + var setup = vm.$options.setup; + var ctx = createSetupContext(vm); + var instance = toVue3ComponentInstance(vm); + instance.setupContext = ctx; + // fake reactive for `toRefs(props)` + def(props, '__ob__', createObserver()); + // resolve scopedSlots and slots to functions + resolveScopedSlots(vm, ctx.slots); + var binding; + activateCurrentInstance(instance, function () { + // make props to be fake reactive, this is for `toRefs(props)` + binding = setup(props, ctx); + }); + if (!binding) + return; + if (isFunction(binding)) { + // keep typescript happy with the binding type. + var bindingFunc_1 = binding; + // keep currentInstance accessible for createElement + vm.$options.render = function () { + resolveScopedSlots(vm, ctx.slots); + return activateCurrentInstance(instance, function () { return bindingFunc_1(); }); + }; + return; + } + else if (isObject(binding)) { + if (isReactive(binding)) { + binding = toRefs(binding); + } + vmStateManager.set(vm, 'rawBindings', binding); + var bindingObj_1 = binding; + Object.keys(bindingObj_1).forEach(function (name) { + var bindingValue = bindingObj_1[name]; + if (!isRef(bindingValue)) { + if (!isReactive(bindingValue)) { + if (isFunction(bindingValue)) { + var copy_1 = bindingValue; + bindingValue = bindingValue.bind(vm); + Object.keys(copy_1).forEach(function (ele) { + bindingValue[ele] = copy_1[ele]; + }); + } + else if (!isObject(bindingValue)) { + bindingValue = ref(bindingValue); + } + else if (hasReactiveArrayChild(bindingValue)) { + // creates a custom reactive properties without make the object explicitly reactive + // NOTE we should try to avoid this, better implementation needed + customReactive(bindingValue); + } + } + else if (isArray(bindingValue)) { + bindingValue = ref(bindingValue); + } + } + asVmProperty(vm, name, bindingValue); + }); + return; + } + { + assert(false, "\"setup\" must return a \"Object\" or a \"Function\", got \"".concat(Object.prototype.toString + .call(binding) + .slice(8, -1), "\"")); + } + } + function customReactive(target, seen) { + if (seen === void 0) { seen = new Set(); } + if (seen.has(target)) + return; + if (!isPlainObject(target) || + isRef(target) || + isReactive(target) || + isRaw(target)) + return; + var Vue = getVueConstructor(); + // @ts-expect-error https://github.com/vuejs/vue/pull/12132 + var defineReactive = Vue.util.defineReactive; + Object.keys(target).forEach(function (k) { + var val = target[k]; + defineReactive(target, k, val); + if (val) { + seen.add(val); + customReactive(val, seen); + } + return; + }); + } + function hasReactiveArrayChild(target, visited) { + if (visited === void 0) { visited = new Map(); } + if (visited.has(target)) { + return visited.get(target); + } + visited.set(target, false); + if (isArray(target) && isReactive(target)) { + visited.set(target, true); + return true; + } + if (!isPlainObject(target) || isRaw(target) || isRef(target)) { + return false; + } + return Object.keys(target).some(function (x) { + return hasReactiveArrayChild(target[x], visited); + }); + } + function createSetupContext(vm) { + var ctx = { slots: {} }; + var propsPlain = [ + 'root', + 'parent', + 'refs', + 'listeners', + 'isServer', + 'ssrContext', + ]; + var methodReturnVoid = ['emit']; + propsPlain.forEach(function (key) { + var srcKey = "$".concat(key); + proxy(ctx, key, { + get: function () { return vm[srcKey]; }, + set: function () { + warn("Cannot assign to '".concat(key, "' because it is a read-only property"), vm); + }, + }); + }); + updateVmAttrs(vm, ctx); + methodReturnVoid.forEach(function (key) { + var srcKey = "$".concat(key); + proxy(ctx, key, { + get: function () { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var fn = vm[srcKey]; + fn.apply(vm, args); + }; + }, + }); + }); + return ctx; + } + } + + /** + * Helper that recursively merges two data objects together. + */ + function mergeData(from, to) { + if (!from) + return to; + if (!to) + return from; + var key; + var toVal; + var fromVal; + var keys = hasSymbol ? Reflect.ownKeys(from) : Object.keys(from); + for (var i = 0; i < keys.length; i++) { + key = keys[i]; + // in case the object is already observed... + if (key === '__ob__') + continue; + toVal = to[key]; + fromVal = from[key]; + if (!hasOwn(to, key)) { + to[key] = fromVal; + } + else if (toVal !== fromVal && + isPlainObject(toVal) && + !isRef(toVal) && + isPlainObject(fromVal) && + !isRef(fromVal)) { + mergeData(fromVal, toVal); + } + } + return to; + } + function install(Vue) { + if (isVueRegistered(Vue)) { + { + warn('[vue-composition-api] already installed. Vue.use(VueCompositionAPI) should be called only once.'); + } + return; + } + { + if (Vue.version) { + if (Vue.version[0] !== '2' || Vue.version[1] !== '.') { + warn("[vue-composition-api] only works with Vue 2, v".concat(Vue.version, " found.")); + } + } + else { + warn('[vue-composition-api] no Vue version found'); + } + } + Vue.config.optionMergeStrategies.setup = function (parent, child) { + return function mergedSetupFn(props, context) { + return mergeData(isFunction(parent) ? parent(props, context) || {} : undefined, isFunction(child) ? child(props, context) || {} : undefined); + }; + }; + setVueConstructor(Vue); + mixin(Vue); + } + var Plugin = { + install: function (Vue) { return install(Vue); }, + }; + + // implementation, close to no-op + function defineComponent(options) { + return options; + } + + function defineAsyncComponent(source) { + if (isFunction(source)) { + source = { loader: source }; + } + var loader = source.loader, loadingComponent = source.loadingComponent, errorComponent = source.errorComponent, _a = source.delay, delay = _a === void 0 ? 200 : _a, timeout = source.timeout, // undefined = never times out + _b = source.suspensible, // undefined = never times out + suspensible = _b === void 0 ? false : _b, // in Vue 3 default is true + userOnError = source.onError; + if (suspensible) { + warn("The suspensiblbe option for async components is not supported in Vue2. It is ignored."); + } + var pendingRequest = null; + var retries = 0; + var retry = function () { + retries++; + pendingRequest = null; + return load(); + }; + var load = function () { + var thisRequest; + return (pendingRequest || + (thisRequest = pendingRequest = + loader() + .catch(function (err) { + err = err instanceof Error ? err : new Error(String(err)); + if (userOnError) { + return new Promise(function (resolve, reject) { + var userRetry = function () { return resolve(retry()); }; + var userFail = function () { return reject(err); }; + userOnError(err, userRetry, userFail, retries + 1); + }); + } + else { + throw err; + } + }) + .then(function (comp) { + if (thisRequest !== pendingRequest && pendingRequest) { + return pendingRequest; + } + if (!comp) { + warn("Async component loader resolved to undefined. " + + "If you are using retry(), make sure to return its return value."); + } + // interop module default + if (comp && + (comp.__esModule || comp[Symbol.toStringTag] === 'Module')) { + comp = comp.default; + } + if (comp && !isObject(comp) && !isFunction(comp)) { + throw new Error("Invalid async component load result: ".concat(comp)); + } + return comp; + }))); + }; + return function () { + var component = load(); + return { + component: component, + delay: delay, + timeout: timeout, + error: errorComponent, + loading: loadingComponent, + }; + }; + } + + var version = "1.7.0"; + // auto install when using CDN + if (typeof window !== 'undefined' && window.Vue) { + window.Vue.use(Plugin); + } + + exports.EffectScope = EffectScope; + exports.computed = computed; + exports.createApp = createApp; + exports.createLifeCycle = createLifeCycle; + exports.createRef = createRef; + exports.customRef = customRef; + exports["default"] = Plugin; + exports.defineAsyncComponent = defineAsyncComponent; + exports.defineComponent = defineComponent; + exports.del = del; + exports.effectScope = effectScope; + exports.getCurrentInstance = getCurrentInstance; + exports.getCurrentScope = getCurrentScope; + exports.h = createElement; + exports.inject = inject; + exports.isRaw = isRaw; + exports.isReactive = isReactive; + exports.isReadonly = isReadonly; + exports.isRef = isRef; + exports.markRaw = markRaw; + exports.nextTick = nextTick; + exports.onActivated = onActivated; + exports.onBeforeMount = onBeforeMount; + exports.onBeforeUnmount = onBeforeUnmount; + exports.onBeforeUpdate = onBeforeUpdate; + exports.onDeactivated = onDeactivated; + exports.onErrorCaptured = onErrorCaptured; + exports.onMounted = onMounted; + exports.onScopeDispose = onScopeDispose; + exports.onServerPrefetch = onServerPrefetch; + exports.onUnmounted = onUnmounted; + exports.onUpdated = onUpdated; + exports.provide = provide; + exports.proxyRefs = proxyRefs; + exports.reactive = reactive; + exports.readonly = readonly; + exports.ref = ref; + exports.set = set$1; + exports.shallowReactive = shallowReactive; + exports.shallowReadonly = shallowReadonly; + exports.shallowRef = shallowRef; + exports.toRaw = toRaw; + exports.toRef = toRef; + exports.toRefs = toRefs; + exports.triggerRef = triggerRef; + exports.unref = unref; + exports.useAttrs = useAttrs; + exports.useCSSModule = useCSSModule; + exports.useCssModule = useCssModule; + exports.useSlots = useSlots; + exports.version = version; + exports.warn = warn$1; + exports.watch = watch; + exports.watchEffect = watchEffect; + exports.watchPostEffect = watchPostEffect; + exports.watchSyncEffect = watchSyncEffect; + + Object.defineProperty(exports, '__esModule', { value: true }); + +})); diff --git a/packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.mjs b/packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.mjs new file mode 100644 index 0000000000000000000000000000000000000000..9a1b7b3994fd45c0b9cf7c0eb66e9761c45435cd --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.mjs @@ -0,0 +1,2259 @@ +/****************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */ +/* global Reflect, Promise */ + +var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); +}; + +function __extends(d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +} + +var __assign = function() { + __assign = Object.assign || function __assign(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; + +function __values(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +} + +function __read(o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +} + +function __spreadArray(to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +} + +/** + * Displays a warning message (using console.error) with a stack trace if the + * function is called inside of active component. + * + * @param message warning message to be displayed + */ +function warn$1(message) { + var _a; + warn(message, (_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy); +} + +var activeEffectScope; +var effectScopeStack = []; +var EffectScopeImpl = /** @class */ (function () { + function EffectScopeImpl(vm) { + this.active = true; + this.effects = []; + this.cleanups = []; + this.vm = vm; + } + EffectScopeImpl.prototype.run = function (fn) { + if (this.active) { + try { + this.on(); + return fn(); + } + finally { + this.off(); + } + } + else if ((process.env.NODE_ENV !== 'production')) { + warn$1("cannot run an inactive effect scope."); + } + return; + }; + EffectScopeImpl.prototype.on = function () { + if (this.active) { + effectScopeStack.push(this); + activeEffectScope = this; + } + }; + EffectScopeImpl.prototype.off = function () { + if (this.active) { + effectScopeStack.pop(); + activeEffectScope = effectScopeStack[effectScopeStack.length - 1]; + } + }; + EffectScopeImpl.prototype.stop = function () { + if (this.active) { + this.vm.$destroy(); + this.effects.forEach(function (e) { return e.stop(); }); + this.cleanups.forEach(function (cleanup) { return cleanup(); }); + this.active = false; + } + }; + return EffectScopeImpl; +}()); +var EffectScope = /** @class */ (function (_super) { + __extends(EffectScope, _super); + function EffectScope(detached) { + if (detached === void 0) { detached = false; } + var _this = this; + var vm = undefined; + withCurrentInstanceTrackingDisabled(function () { + vm = defineComponentInstance(getVueConstructor()); + }); + _this = _super.call(this, vm) || this; + if (!detached) { + recordEffectScope(_this); + } + return _this; + } + return EffectScope; +}(EffectScopeImpl)); +function recordEffectScope(effect, scope) { + var _a; + scope = scope || activeEffectScope; + if (scope && scope.active) { + scope.effects.push(effect); + return; + } + // destroy on parent component unmounted + var vm = (_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy; + vm && vm.$on('hook:destroyed', function () { return effect.stop(); }); +} +function effectScope(detached) { + return new EffectScope(detached); +} +function getCurrentScope() { + return activeEffectScope; +} +function onScopeDispose(fn) { + if (activeEffectScope) { + activeEffectScope.cleanups.push(fn); + } + else if ((process.env.NODE_ENV !== 'production')) { + warn$1("onScopeDispose() is called when there is no active effect scope" + + " to be associated with."); + } +} +/** + * @internal + **/ +function getCurrentScopeVM() { + var _a, _b; + return ((_a = getCurrentScope()) === null || _a === void 0 ? void 0 : _a.vm) || ((_b = getCurrentInstance()) === null || _b === void 0 ? void 0 : _b.proxy); +} +/** + * @internal + **/ +function bindCurrentScopeToVM(vm) { + if (!vm.scope) { + var scope_1 = new EffectScopeImpl(vm.proxy); + vm.scope = scope_1; + vm.proxy.$on('hook:destroyed', function () { return scope_1.stop(); }); + } + return vm.scope; +} + +var vueDependency = undefined; +try { + var requiredVue = require('vue'); + if (requiredVue && isVue(requiredVue)) { + vueDependency = requiredVue; + } + else if (requiredVue && + 'default' in requiredVue && + isVue(requiredVue.default)) { + vueDependency = requiredVue.default; + } +} +catch (_a) { + // not available +} +var vueConstructor = null; +var currentInstance = null; +var currentInstanceTracking = true; +var PluginInstalledFlag = '__composition_api_installed__'; +function isVue(obj) { + return obj && isFunction(obj) && obj.name === 'Vue'; +} +function isVueRegistered(Vue) { + // resolve issue: https://github.com/vuejs/composition-api/issues/876#issue-1087619365 + return vueConstructor && hasOwn(Vue, PluginInstalledFlag); +} +function getVueConstructor() { + if ((process.env.NODE_ENV !== 'production')) { + assert(vueConstructor, "must call Vue.use(VueCompositionAPI) before using any function."); + } + return vueConstructor; +} +// returns registered vue or `vue` dependency +function getRegisteredVueOrDefault() { + var constructor = vueConstructor || vueDependency; + if ((process.env.NODE_ENV !== 'production')) { + assert(constructor, "No vue dependency found."); + } + return constructor; +} +function setVueConstructor(Vue) { + // @ts-ignore + if ((process.env.NODE_ENV !== 'production') && vueConstructor && Vue.__proto__ !== vueConstructor.__proto__) { + warn('[vue-composition-api] another instance of Vue installed'); + } + vueConstructor = Vue; + Object.defineProperty(Vue, PluginInstalledFlag, { + configurable: true, + writable: true, + value: true, + }); +} +/** + * For `effectScope` to create instance without populate the current instance + * @internal + **/ +function withCurrentInstanceTrackingDisabled(fn) { + var prev = currentInstanceTracking; + currentInstanceTracking = false; + try { + fn(); + } + finally { + currentInstanceTracking = prev; + } +} +function setCurrentInstance(instance) { + if (!currentInstanceTracking) + return; + var prev = currentInstance; + prev === null || prev === void 0 ? void 0 : prev.scope.off(); + currentInstance = instance; + currentInstance === null || currentInstance === void 0 ? void 0 : currentInstance.scope.on(); +} +function getCurrentInstance() { + return currentInstance; +} +var instanceMapCache = new WeakMap(); +function toVue3ComponentInstance(vm) { + if (instanceMapCache.has(vm)) { + return instanceMapCache.get(vm); + } + var instance = { + proxy: vm, + update: vm.$forceUpdate, + type: vm.$options, + uid: vm._uid, + // $emit is defined on prototype and it expected to be bound + emit: vm.$emit.bind(vm), + parent: null, + root: null, // to be immediately set + }; + bindCurrentScopeToVM(instance); + // map vm.$props = + var instanceProps = [ + 'data', + 'props', + 'attrs', + 'refs', + 'vnode', + 'slots', + ]; + instanceProps.forEach(function (prop) { + proxy(instance, prop, { + get: function () { + return vm["$".concat(prop)]; + }, + }); + }); + proxy(instance, 'isMounted', { + get: function () { + // @ts-expect-error private api + return vm._isMounted; + }, + }); + proxy(instance, 'isUnmounted', { + get: function () { + // @ts-expect-error private api + return vm._isDestroyed; + }, + }); + proxy(instance, 'isDeactivated', { + get: function () { + // @ts-expect-error private api + return vm._inactive; + }, + }); + proxy(instance, 'emitted', { + get: function () { + // @ts-expect-error private api + return vm._events; + }, + }); + instanceMapCache.set(vm, instance); + if (vm.$parent) { + instance.parent = toVue3ComponentInstance(vm.$parent); + } + if (vm.$root) { + instance.root = toVue3ComponentInstance(vm.$root); + } + return instance; +} + +var toString = function (x) { return Object.prototype.toString.call(x); }; +function isNative(Ctor) { + return typeof Ctor === 'function' && /native code/.test(Ctor.toString()); +} +var hasSymbol = typeof Symbol !== 'undefined' && + isNative(Symbol) && + typeof Reflect !== 'undefined' && + isNative(Reflect.ownKeys); +var noopFn = function (_) { return _; }; +function proxy(target, key, _a) { + var get = _a.get, set = _a.set; + Object.defineProperty(target, key, { + enumerable: true, + configurable: true, + get: get || noopFn, + set: set || noopFn, + }); +} +function def(obj, key, val, enumerable) { + Object.defineProperty(obj, key, { + value: val, + enumerable: !!enumerable, + writable: true, + configurable: true, + }); +} +function hasOwn(obj, key) { + return Object.hasOwnProperty.call(obj, key); +} +function assert(condition, msg) { + if (!condition) { + throw new Error("[vue-composition-api] ".concat(msg)); + } +} +function isPrimitive(value) { + return (typeof value === 'string' || + typeof value === 'number' || + // $flow-disable-line + typeof value === 'symbol' || + typeof value === 'boolean'); +} +function isArray(x) { + return Array.isArray(x); +} +var objectToString = Object.prototype.toString; +var toTypeString = function (value) { + return objectToString.call(value); +}; +var isMap = function (val) { + return toTypeString(val) === '[object Map]'; +}; +var isSet = function (val) { + return toTypeString(val) === '[object Set]'; +}; +var MAX_VALID_ARRAY_LENGTH = 4294967295; // Math.pow(2, 32) - 1 +function isValidArrayIndex(val) { + var n = parseFloat(String(val)); + return (n >= 0 && + Math.floor(n) === n && + isFinite(val) && + n <= MAX_VALID_ARRAY_LENGTH); +} +function isObject(val) { + return val !== null && typeof val === 'object'; +} +function isPlainObject(x) { + return toString(x) === '[object Object]'; +} +function isFunction(x) { + return typeof x === 'function'; +} +function isUndef(v) { + return v === undefined || v === null; +} +function warn(msg, vm) { + var Vue = getRegisteredVueOrDefault(); + if (!Vue || !Vue.util) + console.warn("[vue-composition-api] ".concat(msg)); + else + Vue.util.warn(msg, vm); +} +function logError(err, vm, info) { + if ((process.env.NODE_ENV !== 'production')) { + warn("Error in ".concat(info, ": \"").concat(err.toString(), "\""), vm); + } + if (typeof window !== 'undefined' && typeof console !== 'undefined') { + console.error(err); + } + else { + throw err; + } +} +/** + * Object.is polyfill + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is + * */ +function isSame(value1, value2) { + if (value1 === value2) { + return value1 !== 0 || 1 / value1 === 1 / value2; + } + else { + return value1 !== value1 && value2 !== value2; + } +} + +function getCurrentInstanceForFn(hook, target) { + target = target || getCurrentInstance(); + if ((process.env.NODE_ENV !== 'production') && !target) { + warn("".concat(hook, " is called when there is no active component instance to be ") + + "associated with. " + + "Lifecycle injection APIs can only be used during execution of setup()."); + } + return target; +} +function defineComponentInstance(Ctor, options) { + if (options === void 0) { options = {}; } + var silent = Ctor.config.silent; + Ctor.config.silent = true; + var vm = new Ctor(options); + Ctor.config.silent = silent; + return vm; +} +function isComponentInstance(obj) { + var Vue = getVueConstructor(); + return Vue && obj instanceof Vue; +} +function createSlotProxy(vm, slotName) { + return (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + if (!vm.$scopedSlots[slotName]) { + if ((process.env.NODE_ENV !== 'production')) + return warn("slots.".concat(slotName, "() got called outside of the \"render()\" scope"), vm); + return; + } + return vm.$scopedSlots[slotName].apply(vm, args); + }); +} +function resolveSlots(slots, normalSlots) { + var res; + if (!slots) { + res = {}; + } + else if (slots._normalized) { + // fast path 1: child component re-render only, parent did not change + return slots._normalized; + } + else { + res = {}; + for (var key in slots) { + if (slots[key] && key[0] !== '$') { + res[key] = true; + } + } + } + // expose normal slots on scopedSlots + for (var key in normalSlots) { + if (!(key in res)) { + res[key] = true; + } + } + return res; +} +var vueInternalClasses; +var getVueInternalClasses = function () { + if (!vueInternalClasses) { + var vm = defineComponentInstance(getVueConstructor(), { + computed: { + value: function () { + return 0; + }, + }, + }); + // to get Watcher class + var Watcher = vm._computedWatchers.value.constructor; + // to get Dep class + var Dep = vm._data.__ob__.dep.constructor; + vueInternalClasses = { + Watcher: Watcher, + Dep: Dep, + }; + vm.$destroy(); + } + return vueInternalClasses; +}; + +function createSymbol(name) { + return hasSymbol ? Symbol.for(name) : name; +} +var WatcherPreFlushQueueKey = createSymbol('composition-api.preFlushQueue'); +var WatcherPostFlushQueueKey = createSymbol('composition-api.postFlushQueue'); +// must be a string, symbol key is ignored in reactive +var RefKey = 'composition-api.refKey'; + +var accessModifiedSet = new WeakMap(); +var rawSet = new WeakMap(); +var readonlySet = new WeakMap(); + +/** + * Set a property on an object. Adds the new property, triggers change + * notification and intercept it's subsequent access if the property doesn't + * already exist. + */ +function set$1(target, key, val) { + var Vue = getVueConstructor(); + // @ts-expect-error https://github.com/vuejs/vue/pull/12132 + var _a = Vue.util, warn = _a.warn, defineReactive = _a.defineReactive; + if ((process.env.NODE_ENV !== 'production') && (isUndef(target) || isPrimitive(target))) { + warn("Cannot set reactive property on undefined, null, or primitive value: ".concat(target)); + } + var ob = target.__ob__; + function ssrMockReactivity() { + // in SSR, there is no __ob__. Mock for reactivity check + if (ob && isObject(val) && !hasOwn(val, '__ob__')) { + mockReactivityDeep(val); + } + } + if (isArray(target)) { + if (isValidArrayIndex(key)) { + target.length = Math.max(target.length, key); + target.splice(key, 1, val); + ssrMockReactivity(); + return val; + } + else if (key === 'length' && val !== target.length) { + target.length = val; + ob === null || ob === void 0 ? void 0 : ob.dep.notify(); + return val; + } + } + if (key in target && !(key in Object.prototype)) { + target[key] = val; + ssrMockReactivity(); + return val; + } + if (target._isVue || (ob && ob.vmCount)) { + (process.env.NODE_ENV !== 'production') && + warn('Avoid adding reactive properties to a Vue instance or its root $data ' + + 'at runtime - declare it upfront in the data option.'); + return val; + } + if (!ob) { + target[key] = val; + return val; + } + defineReactive(ob.value, key, val); + // IMPORTANT: define access control before trigger watcher + defineAccessControl(target, key, val); + ssrMockReactivity(); + ob.dep.notify(); + return val; +} + +var _isForceTrigger = false; +function isForceTrigger() { + return _isForceTrigger; +} +function setForceTrigger(v) { + _isForceTrigger = v; +} + +var RefImpl = /** @class */ (function () { + function RefImpl(_a) { + var get = _a.get, set = _a.set; + proxy(this, 'value', { + get: get, + set: set, + }); + } + return RefImpl; +}()); +function createRef(options, isReadonly, isComputed) { + if (isReadonly === void 0) { isReadonly = false; } + if (isComputed === void 0) { isComputed = false; } + var r = new RefImpl(options); + // add effect to differentiate refs from computed + if (isComputed) + r.effect = true; + // seal the ref, this could prevent ref from being observed + // It's safe to seal the ref, since we really shouldn't extend it. + // related issues: #79 + var sealed = Object.seal(r); + if (isReadonly) + readonlySet.set(sealed, true); + return sealed; +} +function ref(raw) { + var _a; + if (isRef(raw)) { + return raw; + } + var value = reactive((_a = {}, _a[RefKey] = raw, _a)); + return createRef({ + get: function () { return value[RefKey]; }, + set: function (v) { return (value[RefKey] = v); }, + }); +} +function isRef(value) { + return value instanceof RefImpl; +} +function unref(ref) { + return isRef(ref) ? ref.value : ref; +} +function toRefs(obj) { + if ((process.env.NODE_ENV !== 'production') && !isReactive(obj)) { + warn("toRefs() expects a reactive object but received a plain one."); + } + if (!isPlainObject(obj)) + return obj; + var ret = {}; + for (var key in obj) { + ret[key] = toRef(obj, key); + } + return ret; +} +function customRef(factory) { + var version = ref(0); + return createRef(factory(function () { return void version.value; }, function () { + ++version.value; + })); +} +function toRef(object, key) { + if (!(key in object)) + set$1(object, key, undefined); + var v = object[key]; + if (isRef(v)) + return v; + return createRef({ + get: function () { return object[key]; }, + set: function (v) { return (object[key] = v); }, + }); +} +function shallowRef(raw) { + var _a; + if (isRef(raw)) { + return raw; + } + var value = shallowReactive((_a = {}, _a[RefKey] = raw, _a)); + return createRef({ + get: function () { return value[RefKey]; }, + set: function (v) { return (value[RefKey] = v); }, + }); +} +function triggerRef(value) { + if (!isRef(value)) + return; + setForceTrigger(true); + value.value = value.value; + setForceTrigger(false); +} +function proxyRefs(objectWithRefs) { + var _a, e_1, _b; + if (isReactive(objectWithRefs)) { + return objectWithRefs; + } + var value = reactive((_a = {}, _a[RefKey] = objectWithRefs, _a)); + def(value, RefKey, value[RefKey], false); + var _loop_1 = function (key) { + proxy(value, key, { + get: function () { + if (isRef(value[RefKey][key])) { + return value[RefKey][key].value; + } + return value[RefKey][key]; + }, + set: function (v) { + if (isRef(value[RefKey][key])) { + return (value[RefKey][key].value = unref(v)); + } + value[RefKey][key] = unref(v); + }, + }); + }; + try { + for (var _c = __values(Object.keys(objectWithRefs)), _d = _c.next(); !_d.done; _d = _c.next()) { + var key = _d.value; + _loop_1(key); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_d && !_d.done && (_b = _c.return)) _b.call(_c); + } + finally { if (e_1) throw e_1.error; } + } + return value; +} + +var SKIPFLAG = '__v_skip'; +function isRaw(obj) { + var _a; + return Boolean(obj && + hasOwn(obj, '__ob__') && + typeof obj.__ob__ === 'object' && + ((_a = obj.__ob__) === null || _a === void 0 ? void 0 : _a[SKIPFLAG])); +} +function isReactive(obj) { + var _a; + return Boolean(obj && + hasOwn(obj, '__ob__') && + typeof obj.__ob__ === 'object' && + !((_a = obj.__ob__) === null || _a === void 0 ? void 0 : _a[SKIPFLAG])); +} +/** + * Proxing property access of target. + * We can do unwrapping and other things here. + */ +function setupAccessControl(target) { + if (!isPlainObject(target) || + isRaw(target) || + isArray(target) || + isRef(target) || + isComponentInstance(target) || + accessModifiedSet.has(target)) + return; + accessModifiedSet.set(target, true); + var keys = Object.keys(target); + for (var i = 0; i < keys.length; i++) { + defineAccessControl(target, keys[i]); + } +} +/** + * Auto unwrapping when access property + */ +function defineAccessControl(target, key, val) { + if (key === '__ob__') + return; + if (isRaw(target[key])) + return; + var getter; + var setter; + var property = Object.getOwnPropertyDescriptor(target, key); + if (property) { + if (property.configurable === false) { + return; + } + getter = property.get; + setter = property.set; + if ((!getter || setter) /* not only have getter */ && + arguments.length === 2) { + val = target[key]; + } + } + setupAccessControl(val); + proxy(target, key, { + get: function getterHandler() { + var value = getter ? getter.call(target) : val; + // if the key is equal to RefKey, skip the unwrap logic + if (key !== RefKey && isRef(value)) { + return value.value; + } + else { + return value; + } + }, + set: function setterHandler(newVal) { + if (getter && !setter) + return; + // If the key is equal to RefKey, skip the unwrap logic + // If and only if "value" is ref and "newVal" is not a ref, + // the assignment should be proxied to "value" ref. + if (key !== RefKey && isRef(val) && !isRef(newVal)) { + val.value = newVal; + } + else if (setter) { + setter.call(target, newVal); + val = newVal; + } + else { + val = newVal; + } + setupAccessControl(newVal); + }, + }); +} +function observe(obj) { + var Vue = getRegisteredVueOrDefault(); + var observed; + if (Vue.observable) { + observed = Vue.observable(obj); + } + else { + var vm = defineComponentInstance(Vue, { + data: { + $$state: obj, + }, + }); + observed = vm._data.$$state; + } + // in SSR, there is no __ob__. Mock for reactivity check + if (!hasOwn(observed, '__ob__')) { + mockReactivityDeep(observed); + } + return observed; +} +/** + * Mock __ob__ for object recursively + */ +function mockReactivityDeep(obj, seen) { + var e_1, _a; + if (seen === void 0) { seen = new Set(); } + if (seen.has(obj) || hasOwn(obj, '__ob__') || !Object.isExtensible(obj)) + return; + def(obj, '__ob__', mockObserver(obj)); + seen.add(obj); + try { + for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) { + var key = _c.value; + var value = obj[key]; + if (!(isPlainObject(value) || isArray(value)) || + isRaw(value) || + !Object.isExtensible(value)) { + continue; + } + mockReactivityDeep(value, seen); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } +} +function mockObserver(value) { + if (value === void 0) { value = {}; } + return { + value: value, + dep: { + notify: noopFn, + depend: noopFn, + addSub: noopFn, + removeSub: noopFn, + }, + }; +} +function createObserver() { + return observe({}).__ob__; +} +function shallowReactive(obj) { + var e_2, _a; + if (!isObject(obj)) { + if ((process.env.NODE_ENV !== 'production')) { + warn('"shallowReactive()" must be called on an object.'); + } + return obj; + } + if (!(isPlainObject(obj) || isArray(obj)) || + isRaw(obj) || + !Object.isExtensible(obj)) { + return obj; + } + var observed = observe(isArray(obj) ? [] : {}); + var ob = observed.__ob__; + var _loop_1 = function (key) { + var val = obj[key]; + var getter; + var setter; + var property = Object.getOwnPropertyDescriptor(obj, key); + if (property) { + if (property.configurable === false) { + return "continue"; + } + getter = property.get; + setter = property.set; + } + proxy(observed, key, { + get: function getterHandler() { + var _a; + (_a = ob.dep) === null || _a === void 0 ? void 0 : _a.depend(); + return val; + }, + set: function setterHandler(newVal) { + var _a; + if (getter && !setter) + return; + if (!isForceTrigger() && val === newVal) + return; + if (setter) { + setter.call(obj, newVal); + } + else { + val = newVal; + } + (_a = ob.dep) === null || _a === void 0 ? void 0 : _a.notify(); + }, + }); + }; + try { + for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) { + var key = _c.value; + _loop_1(key); + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_2) throw e_2.error; } + } + return observed; +} +/** + * Make obj reactivity + */ +function reactive(obj) { + if (!isObject(obj)) { + if ((process.env.NODE_ENV !== 'production')) { + warn('"reactive()" must be called on an object.'); + } + return obj; + } + if (!(isPlainObject(obj) || isArray(obj)) || + isRaw(obj) || + !Object.isExtensible(obj)) { + return obj; + } + var observed = observe(obj); + setupAccessControl(observed); + return observed; +} +/** + * Make sure obj can't be a reactive + */ +function markRaw(obj) { + if (!(isPlainObject(obj) || isArray(obj)) || !Object.isExtensible(obj)) { + return obj; + } + // set the vue observable flag at obj + var ob = createObserver(); + ob[SKIPFLAG] = true; + def(obj, '__ob__', ob); + // mark as Raw + rawSet.set(obj, true); + return obj; +} +function toRaw(observed) { + var _a; + if (isRaw(observed) || !Object.isExtensible(observed)) { + return observed; + } + return ((_a = observed === null || observed === void 0 ? void 0 : observed.__ob__) === null || _a === void 0 ? void 0 : _a.value) || observed; +} + +function isReadonly(obj) { + return readonlySet.has(obj); +} +/** + * **In @vue/composition-api, `reactive` only provides type-level readonly check** + * + * Creates a readonly copy of the original object. Note the returned copy is not + * made reactive, but `readonly` can be called on an already reactive object. + */ +function readonly(target) { + if ((process.env.NODE_ENV !== 'production') && !isObject(target)) { + warn("value cannot be made reactive: ".concat(String(target))); + } + else { + readonlySet.set(target, true); + } + return target; +} +function shallowReadonly(obj) { + var e_1, _a; + if (!isObject(obj)) { + if ((process.env.NODE_ENV !== 'production')) { + warn("value cannot be made reactive: ".concat(String(obj))); + } + return obj; + } + if (!(isPlainObject(obj) || isArray(obj)) || + (!Object.isExtensible(obj) && !isRef(obj))) { + return obj; + } + var readonlyObj = isRef(obj) + ? new RefImpl({}) + : isReactive(obj) + ? observe({}) + : {}; + var source = reactive({}); + var ob = source.__ob__; + var _loop_1 = function (key) { + var val = obj[key]; + var getter; + var property = Object.getOwnPropertyDescriptor(obj, key); + if (property) { + if (property.configurable === false && !isRef(obj)) { + return "continue"; + } + getter = property.get; + } + proxy(readonlyObj, key, { + get: function getterHandler() { + var value = getter ? getter.call(obj) : val; + ob.dep.depend(); + return value; + }, + set: function (v) { + if ((process.env.NODE_ENV !== 'production')) { + warn("Set operation on key \"".concat(key, "\" failed: target is readonly.")); + } + }, + }); + }; + try { + for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) { + var key = _c.value; + _loop_1(key); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } + readonlySet.set(readonlyObj, true); + return readonlyObj; +} + +/** + * Delete a property and trigger change if necessary. + */ +function del(target, key) { + var Vue = getVueConstructor(); + var warn = Vue.util.warn; + if ((process.env.NODE_ENV !== 'production') && (isUndef(target) || isPrimitive(target))) { + warn("Cannot delete reactive property on undefined, null, or primitive value: ".concat(target)); + } + if (isArray(target) && isValidArrayIndex(key)) { + target.splice(key, 1); + return; + } + var ob = target.__ob__; + if (target._isVue || (ob && ob.vmCount)) { + (process.env.NODE_ENV !== 'production') && + warn('Avoid deleting properties on a Vue instance or its root $data ' + + '- just set it to null.'); + return; + } + if (!hasOwn(target, key)) { + return; + } + delete target[key]; + if (!ob) { + return; + } + ob.dep.notify(); +} + +var genName = function (name) { return "on".concat(name[0].toUpperCase() + name.slice(1)); }; +function createLifeCycle(lifeCyclehook) { + return function (callback, target) { + var instance = getCurrentInstanceForFn(genName(lifeCyclehook), target); + return (instance && + injectHookOption(getVueConstructor(), instance, lifeCyclehook, callback)); + }; +} +function injectHookOption(Vue, instance, hook, val) { + var options = instance.proxy.$options; + var mergeFn = Vue.config.optionMergeStrategies[hook]; + var wrappedHook = wrapHookCall(instance, val); + options[hook] = mergeFn(options[hook], wrappedHook); + return wrappedHook; +} +function wrapHookCall(instance, fn) { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var prev = getCurrentInstance(); + setCurrentInstance(instance); + try { + return fn.apply(void 0, __spreadArray([], __read(args), false)); + } + finally { + setCurrentInstance(prev); + } + }; +} +var onBeforeMount = createLifeCycle('beforeMount'); +var onMounted = createLifeCycle('mounted'); +var onBeforeUpdate = createLifeCycle('beforeUpdate'); +var onUpdated = createLifeCycle('updated'); +var onBeforeUnmount = createLifeCycle('beforeDestroy'); +var onUnmounted = createLifeCycle('destroyed'); +var onErrorCaptured = createLifeCycle('errorCaptured'); +var onActivated = createLifeCycle('activated'); +var onDeactivated = createLifeCycle('deactivated'); +var onServerPrefetch = createLifeCycle('serverPrefetch'); + +var fallbackVM; +function flushPreQueue() { + flushQueue(this, WatcherPreFlushQueueKey); +} +function flushPostQueue() { + flushQueue(this, WatcherPostFlushQueueKey); +} +function hasWatchEnv(vm) { + return vm[WatcherPreFlushQueueKey] !== undefined; +} +function installWatchEnv(vm) { + vm[WatcherPreFlushQueueKey] = []; + vm[WatcherPostFlushQueueKey] = []; + vm.$on('hook:beforeUpdate', flushPreQueue); + vm.$on('hook:updated', flushPostQueue); +} +function getWatcherOption(options) { + return __assign({ + immediate: false, + deep: false, + flush: 'pre', + }, options); +} +function getWatchEffectOption(options) { + return __assign({ + flush: 'pre', + }, options); +} +function getWatcherVM() { + var vm = getCurrentScopeVM(); + if (!vm) { + if (!fallbackVM) { + fallbackVM = defineComponentInstance(getVueConstructor()); + } + vm = fallbackVM; + } + else if (!hasWatchEnv(vm)) { + installWatchEnv(vm); + } + return vm; +} +function flushQueue(vm, key) { + var queue = vm[key]; + for (var index = 0; index < queue.length; index++) { + queue[index](); + } + queue.length = 0; +} +function queueFlushJob(vm, fn, mode) { + // flush all when beforeUpdate and updated are not fired + var fallbackFlush = function () { + vm.$nextTick(function () { + if (vm[WatcherPreFlushQueueKey].length) { + flushQueue(vm, WatcherPreFlushQueueKey); + } + if (vm[WatcherPostFlushQueueKey].length) { + flushQueue(vm, WatcherPostFlushQueueKey); + } + }); + }; + switch (mode) { + case 'pre': + fallbackFlush(); + vm[WatcherPreFlushQueueKey].push(fn); + break; + case 'post': + fallbackFlush(); + vm[WatcherPostFlushQueueKey].push(fn); + break; + default: + assert(false, "flush must be one of [\"post\", \"pre\", \"sync\"], but got ".concat(mode)); + break; + } +} +function createVueWatcher(vm, getter, callback, options) { + var index = vm._watchers.length; + // @ts-ignore: use undocumented options + vm.$watch(getter, callback, { + immediate: options.immediateInvokeCallback, + deep: options.deep, + lazy: options.noRun, + sync: options.sync, + before: options.before, + }); + return vm._watchers[index]; +} +// We have to monkeypatch the teardown function so Vue will run +// runCleanup() when it tears down the watcher on unmounted. +function patchWatcherTeardown(watcher, runCleanup) { + var _teardown = watcher.teardown; + watcher.teardown = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + _teardown.apply(watcher, args); + runCleanup(); + }; +} +function createWatcher(vm, source, cb, options) { + var _a; + if ((process.env.NODE_ENV !== 'production') && !cb) { + if (options.immediate !== undefined) { + warn("watch() \"immediate\" option is only respected when using the " + + "watch(source, callback, options?) signature."); + } + if (options.deep !== undefined) { + warn("watch() \"deep\" option is only respected when using the " + + "watch(source, callback, options?) signature."); + } + } + var flushMode = options.flush; + var isSync = flushMode === 'sync'; + var cleanup; + var registerCleanup = function (fn) { + cleanup = function () { + try { + fn(); + } + catch ( + // FIXME: remove any + error) { + logError(error, vm, 'onCleanup()'); + } + }; + }; + // cleanup before running getter again + var runCleanup = function () { + if (cleanup) { + cleanup(); + cleanup = null; + } + }; + var createScheduler = function (fn) { + if (isSync || + /* without a current active instance, ignore pre|post mode */ vm === + fallbackVM) { + return fn; + } + return (function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return queueFlushJob(vm, function () { + fn.apply(void 0, __spreadArray([], __read(args), false)); + }, flushMode); + }); + }; + // effect watch + if (cb === null) { + var running_1 = false; + var getter_1 = function () { + // preventing the watch callback being call in the same execution + if (running_1) { + return; + } + try { + running_1 = true; + source(registerCleanup); + } + finally { + running_1 = false; + } + }; + var watcher_1 = createVueWatcher(vm, getter_1, noopFn, { + deep: options.deep || false, + sync: isSync, + before: runCleanup, + }); + patchWatcherTeardown(watcher_1, runCleanup); + // enable the watcher update + watcher_1.lazy = false; + var originGet = watcher_1.get.bind(watcher_1); + // always run watchEffect + watcher_1.get = createScheduler(originGet); + return function () { + watcher_1.teardown(); + }; + } + var deep = options.deep; + var isMultiSource = false; + var getter; + if (isRef(source)) { + getter = function () { return source.value; }; + } + else if (isReactive(source)) { + getter = function () { return source; }; + deep = true; + } + else if (isArray(source)) { + isMultiSource = true; + getter = function () { + return source.map(function (s) { + if (isRef(s)) { + return s.value; + } + else if (isReactive(s)) { + return traverse(s); + } + else if (isFunction(s)) { + return s(); + } + else { + (process.env.NODE_ENV !== 'production') && + warn("Invalid watch source: ".concat(JSON.stringify(s), ".\n A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types."), vm); + return noopFn; + } + }); + }; + } + else if (isFunction(source)) { + getter = source; + } + else { + getter = noopFn; + (process.env.NODE_ENV !== 'production') && + warn("Invalid watch source: ".concat(JSON.stringify(source), ".\n A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types."), vm); + } + if (deep) { + var baseGetter_1 = getter; + getter = function () { return traverse(baseGetter_1()); }; + } + var applyCb = function (n, o) { + if (!deep && + isMultiSource && + n.every(function (v, i) { return isSame(v, o[i]); })) + return; + // cleanup before running cb again + runCleanup(); + return cb(n, o, registerCleanup); + }; + var callback = createScheduler(applyCb); + if (options.immediate) { + var originalCallback_1 = callback; + // `shiftCallback` is used to handle the first sync effect run. + // The subsequent callbacks will redirect to `callback`. + var shiftCallback_1 = function (n, o) { + shiftCallback_1 = originalCallback_1; + // o is undefined on the first call + return applyCb(n, isArray(n) ? [] : o); + }; + callback = function (n, o) { + return shiftCallback_1(n, o); + }; + } + // @ts-ignore: use undocumented option "sync" + var stop = vm.$watch(getter, callback, { + immediate: options.immediate, + deep: deep, + sync: isSync, + }); + // Once again, we have to hack the watcher for proper teardown + var watcher = vm._watchers[vm._watchers.length - 1]; + // if the return value is reactive and deep:true + // watch for changes, this might happen when new key is added + if (isReactive(watcher.value) && ((_a = watcher.value.__ob__) === null || _a === void 0 ? void 0 : _a.dep) && deep) { + watcher.value.__ob__.dep.addSub({ + update: function () { + // this will force the source to be revaluated and the callback + // executed if needed + watcher.run(); + }, + }); + } + patchWatcherTeardown(watcher, runCleanup); + return function () { + stop(); + }; +} +function watchEffect(effect, options) { + var opts = getWatchEffectOption(options); + var vm = getWatcherVM(); + return createWatcher(vm, effect, null, opts); +} +function watchPostEffect(effect) { + return watchEffect(effect, { flush: 'post' }); +} +function watchSyncEffect(effect) { + return watchEffect(effect, { flush: 'sync' }); +} +// implementation +function watch(source, cb, options) { + var callback = null; + if (isFunction(cb)) { + // source watch + callback = cb; + } + else { + // effect watch + if ((process.env.NODE_ENV !== 'production')) { + warn("`watch(fn, options?)` signature has been moved to a separate API. " + + "Use `watchEffect(fn, options?)` instead. `watch` now only " + + "supports `watch(source, cb, options?) signature."); + } + options = cb; + callback = null; + } + var opts = getWatcherOption(options); + var vm = getWatcherVM(); + return createWatcher(vm, source, callback, opts); +} +function traverse(value, seen) { + if (seen === void 0) { seen = new Set(); } + if (!isObject(value) || seen.has(value) || rawSet.has(value)) { + return value; + } + seen.add(value); + if (isRef(value)) { + traverse(value.value, seen); + } + else if (isArray(value)) { + for (var i = 0; i < value.length; i++) { + traverse(value[i], seen); + } + } + else if (isSet(value) || isMap(value)) { + value.forEach(function (v) { + traverse(v, seen); + }); + } + else if (isPlainObject(value)) { + for (var key in value) { + traverse(value[key], seen); + } + } + return value; +} + +// implement +function computed(getterOrOptions) { + var vm = getCurrentScopeVM(); + var getter; + var setter; + if (isFunction(getterOrOptions)) { + getter = getterOrOptions; + } + else { + getter = getterOrOptions.get; + setter = getterOrOptions.set; + } + var computedSetter; + var computedGetter; + if (vm && !vm.$isServer) { + var _a = getVueInternalClasses(), Watcher_1 = _a.Watcher, Dep_1 = _a.Dep; + var watcher_1; + computedGetter = function () { + if (!watcher_1) { + watcher_1 = new Watcher_1(vm, getter, noopFn, { lazy: true }); + } + if (watcher_1.dirty) { + watcher_1.evaluate(); + } + if (Dep_1.target) { + watcher_1.depend(); + } + return watcher_1.value; + }; + computedSetter = function (v) { + if ((process.env.NODE_ENV !== 'production') && !setter) { + warn('Write operation failed: computed value is readonly.', vm); + return; + } + if (setter) { + setter(v); + } + }; + } + else { + // fallback + var computedHost_1 = defineComponentInstance(getVueConstructor(), { + computed: { + $$state: { + get: getter, + set: setter, + }, + }, + }); + vm && vm.$on('hook:destroyed', function () { return computedHost_1.$destroy(); }); + computedGetter = function () { return computedHost_1.$$state; }; + computedSetter = function (v) { + if ((process.env.NODE_ENV !== 'production') && !setter) { + warn('Write operation failed: computed value is readonly.', vm); + return; + } + computedHost_1.$$state = v; + }; + } + return createRef({ + get: computedGetter, + set: computedSetter, + }, !setter, true); +} + +var NOT_FOUND = {}; +function resolveInject(provideKey, vm) { + var source = vm; + while (source) { + // @ts-ignore + if (source._provided && hasOwn(source._provided, provideKey)) { + //@ts-ignore + return source._provided[provideKey]; + } + source = source.$parent; + } + return NOT_FOUND; +} +function provide(key, value) { + var _a; + var vm = (_a = getCurrentInstanceForFn('provide')) === null || _a === void 0 ? void 0 : _a.proxy; + if (!vm) + return; + if (!vm._provided) { + var provideCache_1 = {}; + proxy(vm, '_provided', { + get: function () { return provideCache_1; }, + set: function (v) { return Object.assign(provideCache_1, v); }, + }); + } + vm._provided[key] = value; +} +function inject(key, defaultValue, treatDefaultAsFactory) { + var _a; + if (treatDefaultAsFactory === void 0) { treatDefaultAsFactory = false; } + var vm = (_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy; + if (!vm) { + (process.env.NODE_ENV !== 'production') && + warn("inject() can only be used inside setup() or functional components."); + return; + } + if (!key) { + (process.env.NODE_ENV !== 'production') && warn("injection \"".concat(String(key), "\" not found."), vm); + return defaultValue; + } + var val = resolveInject(key, vm); + if (val !== NOT_FOUND) { + return val; + } + else if (arguments.length > 1) { + return treatDefaultAsFactory && isFunction(defaultValue) + ? defaultValue() + : defaultValue; + } + else if ((process.env.NODE_ENV !== 'production')) { + warn("Injection \"".concat(String(key), "\" not found."), vm); + } +} + +var EMPTY_OBJ = (process.env.NODE_ENV !== 'production') + ? Object.freeze({}) + : {}; +var useCssModule = function (name) { + var _a; + if (name === void 0) { name = '$style'; } + var instance = getCurrentInstance(); + if (!instance) { + (process.env.NODE_ENV !== 'production') && warn("useCssModule must be called inside setup()"); + return EMPTY_OBJ; + } + var mod = (_a = instance.proxy) === null || _a === void 0 ? void 0 : _a[name]; + if (!mod) { + (process.env.NODE_ENV !== 'production') && + warn("Current instance does not have CSS module named \"".concat(name, "\".")); + return EMPTY_OBJ; + } + return mod; +}; +/** + * @deprecated use `useCssModule` instead. + */ +var useCSSModule = useCssModule; + +function createApp(rootComponent, rootProps) { + if (rootProps === void 0) { rootProps = undefined; } + var V = getVueConstructor(); + var mountedVM = undefined; + var provide = {}; + var app = { + config: V.config, + use: V.use.bind(V), + mixin: V.mixin.bind(V), + component: V.component.bind(V), + provide: function (key, value) { + provide[key] = value; + return this; + }, + directive: function (name, dir) { + if (dir) { + V.directive(name, dir); + return app; + } + else { + return V.directive(name); + } + }, + mount: function (el, hydrating) { + if (!mountedVM) { + mountedVM = new V(__assign(__assign({ propsData: rootProps }, rootComponent), { provide: __assign(__assign({}, provide), rootComponent.provide) })); + mountedVM.$mount(el, hydrating); + return mountedVM; + } + else { + if ((process.env.NODE_ENV !== 'production')) { + warn("App has already been mounted.\n" + + "If you want to remount the same app, move your app creation logic " + + "into a factory function and create fresh app instances for each " + + "mount - e.g. `const createMyApp = () => createApp(App)`"); + } + return mountedVM; + } + }, + unmount: function () { + if (mountedVM) { + mountedVM.$destroy(); + mountedVM = undefined; + } + else if ((process.env.NODE_ENV !== 'production')) { + warn("Cannot unmount an app that is not mounted."); + } + }, + }; + return app; +} + +var nextTick = function nextTick() { + var _a; + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return (_a = getVueConstructor()) === null || _a === void 0 ? void 0 : _a.nextTick.apply(this, args); +}; + +var fallbackCreateElement; +var createElement = function createElement() { + var _a; + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var instance = (this === null || this === void 0 ? void 0 : this.proxy) || ((_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy); + if (!instance) { + (process.env.NODE_ENV !== 'production') && + warn('`createElement()` has been called outside of render function.'); + if (!fallbackCreateElement) { + fallbackCreateElement = defineComponentInstance(getVueConstructor()).$createElement; + } + return fallbackCreateElement.apply(fallbackCreateElement, args); + } + return instance.$createElement.apply(instance, args); +}; + +function useSlots() { + return getContext().slots; +} +function useAttrs() { + return getContext().attrs; +} +function getContext() { + var i = getCurrentInstance(); + if ((process.env.NODE_ENV !== 'production') && !i) { + warn("useContext() called without active instance."); + } + return i.setupContext; +} + +function set(vm, key, value) { + var state = (vm.__composition_api_state__ = + vm.__composition_api_state__ || {}); + state[key] = value; +} +function get(vm, key) { + return (vm.__composition_api_state__ || {})[key]; +} +var vmStateManager = { + set: set, + get: get, +}; + +function asVmProperty(vm, propName, propValue) { + var props = vm.$options.props; + if (!(propName in vm) && !(props && hasOwn(props, propName))) { + if (isRef(propValue)) { + proxy(vm, propName, { + get: function () { return propValue.value; }, + set: function (val) { + propValue.value = val; + }, + }); + } + else { + proxy(vm, propName, { + get: function () { + if (isReactive(propValue)) { + propValue.__ob__.dep.depend(); + } + return propValue; + }, + set: function (val) { + propValue = val; + }, + }); + } + if ((process.env.NODE_ENV !== 'production')) { + // expose binding to Vue Devtool as a data property + // delay this until state has been resolved to prevent repeated works + vm.$nextTick(function () { + if (Object.keys(vm._data).indexOf(propName) !== -1) { + return; + } + if (isRef(propValue)) { + proxy(vm._data, propName, { + get: function () { return propValue.value; }, + set: function (val) { + propValue.value = val; + }, + }); + } + else { + proxy(vm._data, propName, { + get: function () { return propValue; }, + set: function (val) { + propValue = val; + }, + }); + } + }); + } + } + else if ((process.env.NODE_ENV !== 'production')) { + if (props && hasOwn(props, propName)) { + warn("The setup binding property \"".concat(propName, "\" is already declared as a prop."), vm); + } + else { + warn("The setup binding property \"".concat(propName, "\" is already declared."), vm); + } + } +} +function updateTemplateRef(vm) { + var rawBindings = vmStateManager.get(vm, 'rawBindings') || {}; + if (!rawBindings || !Object.keys(rawBindings).length) + return; + var refs = vm.$refs; + var oldRefKeys = vmStateManager.get(vm, 'refs') || []; + for (var index = 0; index < oldRefKeys.length; index++) { + var key = oldRefKeys[index]; + var setupValue = rawBindings[key]; + if (!refs[key] && setupValue && isRef(setupValue)) { + setupValue.value = null; + } + } + var newKeys = Object.keys(refs); + var validNewKeys = []; + for (var index = 0; index < newKeys.length; index++) { + var key = newKeys[index]; + var setupValue = rawBindings[key]; + if (refs[key] && setupValue && isRef(setupValue)) { + setupValue.value = refs[key]; + validNewKeys.push(key); + } + } + vmStateManager.set(vm, 'refs', validNewKeys); +} +function afterRender(vm) { + var stack = [vm._vnode]; + var updated; + while (stack.length) { + var vnode = stack.pop(); + if (vnode) { + if (vnode.context) { + updateTemplateRef(vnode.context); + updated = true; + } + if (vnode.children) { + for (var i = 0; i < vnode.children.length; ++i) { + stack.push(vnode.children[i]); + } + } + } + } + if (!updated) { + updateTemplateRef(vm); + } +} +function updateVmAttrs(vm, ctx) { + var e_1, _a; + if (!vm) { + return; + } + var attrBindings = vmStateManager.get(vm, 'attrBindings'); + if (!attrBindings && !ctx) { + // fix 840 + return; + } + if (!attrBindings) { + var observedData = reactive({}); + attrBindings = { ctx: ctx, data: observedData }; + vmStateManager.set(vm, 'attrBindings', attrBindings); + proxy(ctx, 'attrs', { + get: function () { + return attrBindings === null || attrBindings === void 0 ? void 0 : attrBindings.data; + }, + set: function () { + (process.env.NODE_ENV !== 'production') && + warn("Cannot assign to '$attrs' because it is a read-only property", vm); + }, + }); + } + var source = vm.$attrs; + var _loop_1 = function (attr) { + if (!hasOwn(attrBindings.data, attr)) { + proxy(attrBindings.data, attr, { + get: function () { + // to ensure it always return the latest value + return vm.$attrs[attr]; + }, + }); + } + }; + try { + for (var _b = __values(Object.keys(source)), _c = _b.next(); !_c.done; _c = _b.next()) { + var attr = _c.value; + _loop_1(attr); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } + finally { if (e_1) throw e_1.error; } + } +} +function resolveScopedSlots(vm, slotsProxy) { + var parentVNode = vm.$options._parentVnode; + if (!parentVNode) + return; + var prevSlots = vmStateManager.get(vm, 'slots') || []; + var curSlots = resolveSlots(parentVNode.data.scopedSlots, vm.$slots); + // remove staled slots + for (var index = 0; index < prevSlots.length; index++) { + var key = prevSlots[index]; + if (!curSlots[key]) { + delete slotsProxy[key]; + } + } + // proxy fresh slots + var slotNames = Object.keys(curSlots); + for (var index = 0; index < slotNames.length; index++) { + var key = slotNames[index]; + if (!slotsProxy[key]) { + slotsProxy[key] = createSlotProxy(vm, key); + } + } + vmStateManager.set(vm, 'slots', slotNames); +} +function activateCurrentInstance(instance, fn, onError) { + var preVm = getCurrentInstance(); + setCurrentInstance(instance); + try { + return fn(instance); + } + catch ( + // FIXME: remove any + err) { + if (onError) { + onError(err); + } + else { + throw err; + } + } + finally { + setCurrentInstance(preVm); + } +} + +function mixin(Vue) { + Vue.mixin({ + beforeCreate: functionApiInit, + mounted: function () { + afterRender(this); + }, + beforeUpdate: function () { + updateVmAttrs(this); + }, + updated: function () { + afterRender(this); + }, + }); + /** + * Vuex init hook, injected into each instances init hooks list. + */ + function functionApiInit() { + var vm = this; + var $options = vm.$options; + var setup = $options.setup, render = $options.render; + if (render) { + // keep currentInstance accessible for createElement + $options.render = function () { + var _this = this; + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return activateCurrentInstance(toVue3ComponentInstance(vm), function () { + return render.apply(_this, args); + }); + }; + } + if (!setup) { + return; + } + if (!isFunction(setup)) { + if ((process.env.NODE_ENV !== 'production')) { + warn('The "setup" option should be a function that returns a object in component definitions.', vm); + } + return; + } + var data = $options.data; + // wrapper the data option, so we can invoke setup before data get resolved + $options.data = function wrappedData() { + initSetup(vm, vm.$props); + return isFunction(data) + ? data.call(vm, vm) + : data || {}; + }; + } + function initSetup(vm, props) { + if (props === void 0) { props = {}; } + var setup = vm.$options.setup; + var ctx = createSetupContext(vm); + var instance = toVue3ComponentInstance(vm); + instance.setupContext = ctx; + // fake reactive for `toRefs(props)` + def(props, '__ob__', createObserver()); + // resolve scopedSlots and slots to functions + resolveScopedSlots(vm, ctx.slots); + var binding; + activateCurrentInstance(instance, function () { + // make props to be fake reactive, this is for `toRefs(props)` + binding = setup(props, ctx); + }); + if (!binding) + return; + if (isFunction(binding)) { + // keep typescript happy with the binding type. + var bindingFunc_1 = binding; + // keep currentInstance accessible for createElement + vm.$options.render = function () { + resolveScopedSlots(vm, ctx.slots); + return activateCurrentInstance(instance, function () { return bindingFunc_1(); }); + }; + return; + } + else if (isObject(binding)) { + if (isReactive(binding)) { + binding = toRefs(binding); + } + vmStateManager.set(vm, 'rawBindings', binding); + var bindingObj_1 = binding; + Object.keys(bindingObj_1).forEach(function (name) { + var bindingValue = bindingObj_1[name]; + if (!isRef(bindingValue)) { + if (!isReactive(bindingValue)) { + if (isFunction(bindingValue)) { + var copy_1 = bindingValue; + bindingValue = bindingValue.bind(vm); + Object.keys(copy_1).forEach(function (ele) { + bindingValue[ele] = copy_1[ele]; + }); + } + else if (!isObject(bindingValue)) { + bindingValue = ref(bindingValue); + } + else if (hasReactiveArrayChild(bindingValue)) { + // creates a custom reactive properties without make the object explicitly reactive + // NOTE we should try to avoid this, better implementation needed + customReactive(bindingValue); + } + } + else if (isArray(bindingValue)) { + bindingValue = ref(bindingValue); + } + } + asVmProperty(vm, name, bindingValue); + }); + return; + } + if ((process.env.NODE_ENV !== 'production')) { + assert(false, "\"setup\" must return a \"Object\" or a \"Function\", got \"".concat(Object.prototype.toString + .call(binding) + .slice(8, -1), "\"")); + } + } + function customReactive(target, seen) { + if (seen === void 0) { seen = new Set(); } + if (seen.has(target)) + return; + if (!isPlainObject(target) || + isRef(target) || + isReactive(target) || + isRaw(target)) + return; + var Vue = getVueConstructor(); + // @ts-expect-error https://github.com/vuejs/vue/pull/12132 + var defineReactive = Vue.util.defineReactive; + Object.keys(target).forEach(function (k) { + var val = target[k]; + defineReactive(target, k, val); + if (val) { + seen.add(val); + customReactive(val, seen); + } + return; + }); + } + function hasReactiveArrayChild(target, visited) { + if (visited === void 0) { visited = new Map(); } + if (visited.has(target)) { + return visited.get(target); + } + visited.set(target, false); + if (isArray(target) && isReactive(target)) { + visited.set(target, true); + return true; + } + if (!isPlainObject(target) || isRaw(target) || isRef(target)) { + return false; + } + return Object.keys(target).some(function (x) { + return hasReactiveArrayChild(target[x], visited); + }); + } + function createSetupContext(vm) { + var ctx = { slots: {} }; + var propsPlain = [ + 'root', + 'parent', + 'refs', + 'listeners', + 'isServer', + 'ssrContext', + ]; + var methodReturnVoid = ['emit']; + propsPlain.forEach(function (key) { + var srcKey = "$".concat(key); + proxy(ctx, key, { + get: function () { return vm[srcKey]; }, + set: function () { + (process.env.NODE_ENV !== 'production') && + warn("Cannot assign to '".concat(key, "' because it is a read-only property"), vm); + }, + }); + }); + updateVmAttrs(vm, ctx); + methodReturnVoid.forEach(function (key) { + var srcKey = "$".concat(key); + proxy(ctx, key, { + get: function () { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var fn = vm[srcKey]; + fn.apply(vm, args); + }; + }, + }); + }); + if (process.env.NODE_ENV === 'test') { + ctx._vm = vm; + } + return ctx; + } +} + +/** + * Helper that recursively merges two data objects together. + */ +function mergeData(from, to) { + if (!from) + return to; + if (!to) + return from; + var key; + var toVal; + var fromVal; + var keys = hasSymbol ? Reflect.ownKeys(from) : Object.keys(from); + for (var i = 0; i < keys.length; i++) { + key = keys[i]; + // in case the object is already observed... + if (key === '__ob__') + continue; + toVal = to[key]; + fromVal = from[key]; + if (!hasOwn(to, key)) { + to[key] = fromVal; + } + else if (toVal !== fromVal && + isPlainObject(toVal) && + !isRef(toVal) && + isPlainObject(fromVal) && + !isRef(fromVal)) { + mergeData(fromVal, toVal); + } + } + return to; +} +function install(Vue) { + if (isVueRegistered(Vue)) { + if ((process.env.NODE_ENV !== 'production')) { + warn('[vue-composition-api] already installed. Vue.use(VueCompositionAPI) should be called only once.'); + } + return; + } + if ((process.env.NODE_ENV !== 'production')) { + if (Vue.version) { + if (Vue.version[0] !== '2' || Vue.version[1] !== '.') { + warn("[vue-composition-api] only works with Vue 2, v".concat(Vue.version, " found.")); + } + } + else { + warn('[vue-composition-api] no Vue version found'); + } + } + Vue.config.optionMergeStrategies.setup = function (parent, child) { + return function mergedSetupFn(props, context) { + return mergeData(isFunction(parent) ? parent(props, context) || {} : undefined, isFunction(child) ? child(props, context) || {} : undefined); + }; + }; + setVueConstructor(Vue); + mixin(Vue); +} +var Plugin = { + install: function (Vue) { return install(Vue); }, +}; + +// implementation, close to no-op +function defineComponent(options) { + return options; +} + +function defineAsyncComponent(source) { + if (isFunction(source)) { + source = { loader: source }; + } + var loader = source.loader, loadingComponent = source.loadingComponent, errorComponent = source.errorComponent, _a = source.delay, delay = _a === void 0 ? 200 : _a, timeout = source.timeout, // undefined = never times out + _b = source.suspensible, // undefined = never times out + suspensible = _b === void 0 ? false : _b, // in Vue 3 default is true + userOnError = source.onError; + if ((process.env.NODE_ENV !== 'production') && suspensible) { + warn("The suspensiblbe option for async components is not supported in Vue2. It is ignored."); + } + var pendingRequest = null; + var retries = 0; + var retry = function () { + retries++; + pendingRequest = null; + return load(); + }; + var load = function () { + var thisRequest; + return (pendingRequest || + (thisRequest = pendingRequest = + loader() + .catch(function (err) { + err = err instanceof Error ? err : new Error(String(err)); + if (userOnError) { + return new Promise(function (resolve, reject) { + var userRetry = function () { return resolve(retry()); }; + var userFail = function () { return reject(err); }; + userOnError(err, userRetry, userFail, retries + 1); + }); + } + else { + throw err; + } + }) + .then(function (comp) { + if (thisRequest !== pendingRequest && pendingRequest) { + return pendingRequest; + } + if ((process.env.NODE_ENV !== 'production') && !comp) { + warn("Async component loader resolved to undefined. " + + "If you are using retry(), make sure to return its return value."); + } + // interop module default + if (comp && + (comp.__esModule || comp[Symbol.toStringTag] === 'Module')) { + comp = comp.default; + } + if ((process.env.NODE_ENV !== 'production') && comp && !isObject(comp) && !isFunction(comp)) { + throw new Error("Invalid async component load result: ".concat(comp)); + } + return comp; + }))); + }; + return function () { + var component = load(); + return { + component: component, + delay: delay, + timeout: timeout, + error: errorComponent, + loading: loadingComponent, + }; + }; +} + +var version = "1.7.0"; +// auto install when using CDN +if (typeof window !== 'undefined' && window.Vue) { + window.Vue.use(Plugin); +} + +export { EffectScope, computed, createApp, createLifeCycle, createRef, customRef, Plugin as default, defineAsyncComponent, defineComponent, del, effectScope, getCurrentInstance, getCurrentScope, createElement as h, inject, isRaw, isReactive, isReadonly, isRef, markRaw, nextTick, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, provide, proxyRefs, reactive, readonly, ref, set$1 as set, shallowReactive, shallowReadonly, shallowRef, toRaw, toRef, toRefs, triggerRef, unref, useAttrs, useCSSModule, useCssModule, useSlots, version, warn$1 as warn, watch, watchEffect, watchPostEffect, watchSyncEffect }; diff --git a/packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.prod.js b/packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.prod.js new file mode 100644 index 0000000000000000000000000000000000000000..eea1a2b12027e179aad0921d20c170d51d94b3d0 --- /dev/null +++ b/packages/vue-cli-plugin-uni/packages/@vue/composition-api/dist/vue-composition-api.prod.js @@ -0,0 +1 @@ +!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n="undefined"!=typeof globalThis?globalThis:n||self).VueCompositionAPI={})}(this,(function(n){"use strict";var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=t[e])},t(n,e)};var e,r=function(){return r=Object.assign||function(n){for(var t,e=1,r=arguments.length;e=n.length&&(n=void 0),{value:n&&n[r++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function i(n,t){var e="function"==typeof Symbol&&n[Symbol.iterator];if(!e)return n;var r,o,i=e.call(n),u=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(n){o={error:n}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return u}function u(n,t,e){if(e||2===arguments.length)for(var r,o=0,i=t.length;o=0&&Math.floor(t)===t&&isFinite(n)&&t<=4294967295}function B(n){return null!==n&&"object"==typeof n}function T(n){return"[object Object]"===function(n){return Object.prototype.toString.call(n)}(n)}function V(n){return"function"==typeof n}function W(n,t){return t=t||$()}function z(n,t){void 0===t&&(t={});var e=n.config.silent;n.config.silent=!0;var r=new n(t);return n.config.silent=e,r}function F(n,t){return function(){for(var e=[],r=0;r1?e&&V(t)?t():t:void 0}},n.isRaw=un,n.isReactive=fn,n.isReadonly=function(n){return H.has(n)},n.isRef=tn,n.markRaw=function(n){if(!T(n)&&!M(n)||!Object.isExtensible(n))return n;var t=vn();return t.__v_skip=!0,C(n,"__ob__",t),G.set(n,!0),n},n.nextTick=function(){for(var n,t=[],e=0;e= 2.5 < 2.7" + }, + "devDependencies": { + "@rollup/plugin-node-resolve": "^13.3.0", + "@rollup/plugin-replace": "^4.0.0", + "@types/jest": "^26.0.24", + "@types/node": "^17.0.31", + "bumpp": "^7.1.1", + "conventional-changelog-cli": "^2.2.2", + "conventional-github-releaser": "^3.1.5", + "cross-env": "^7.0.3", + "jest": "^26.6.3", + "lint-staged": "^12.4.1", + "prettier": "^2.6.2", + "rimraf": "^3.0.2", + "rollup": "^2.72.0", + "rollup-plugin-dts": "^4.2.1", + "rollup-plugin-terser": "^7.0.2", + "rollup-plugin-typescript2": "^0.31.2", + "simple-git-hooks": "^2.7.0", + "ts-jest": "^26.5.6", + "tslib": "^2.4.0", + "typescript": "^4.6.4", + "vue": "^2.6.14", + "vue-router": "^3.5.3", + "vue-server-renderer": "^2.6.14", + "vue3": "npm:vue@3.2.21" + }, + "simple-git-hooks": { + "pre-commit": "lint-staged" + }, + "lint-staged": { + "*.js": [ + "prettier --write" + ], + "*.ts?(x)": [ + "prettier --parser=typescript --write" + ] + }, + "jest": { + "verbose": true, + "globals": { + "__DEV__": true, + "__VERSION__": "0.0.0" + }, + "setupFiles": [ + "/test/setupTest.js" + ], + "setupFilesAfterEnv": [ + "/test/helpers/wait-for-update.js" + ], + "moduleFileExtensions": [ + "ts", + "js" + ], + "testMatch": [ + "/test/**/*.spec.{js,ts}" + ], + "preset": "ts-jest" + }, + "prettier": { + "semi": false, + "singleQuote": true, + "printWidth": 80 + } +} diff --git a/packages/vue-cli-plugin-uni/packages/mp-vue/dist/mp.runtime.esm.js b/packages/vue-cli-plugin-uni/packages/mp-vue/dist/mp.runtime.esm.js index 383ee9a44a4cb9fa9e1a86fe00d9f4ea5f2000d6..e496d70589f4133bb723b0fe441696e374610531 100644 --- a/packages/vue-cli-plugin-uni/packages/mp-vue/dist/mp.runtime.esm.js +++ b/packages/vue-cli-plugin-uni/packages/mp-vue/dist/mp.runtime.esm.js @@ -5420,6 +5420,8 @@ Vue.version = '2.6.11'; */ var ARRAYTYPE = '[object Array]'; var OBJECTTYPE = '[object Object]'; +var NULLTYPE = '[object Null]'; +var UNDEFINEDTYPE = '[object Undefined]'; // const FUNCTIONTYPE = '[object Function]' function diff(current, pre) { @@ -5453,6 +5455,16 @@ function syncKeys(current, pre) { } } +function nullOrUndefined(currentType, preType) { + if( + (currentType === NULLTYPE || currentType === UNDEFINEDTYPE) && + (preType === NULLTYPE || preType === UNDEFINEDTYPE) + ) { + return false + } + return true +} + function _diff(current, pre, path, result) { if (current === pre) { return } var rootCurrentType = type(current); @@ -5467,7 +5479,7 @@ function _diff(current, pre, path, result) { var currentType = type(currentValue); var preType = type(preValue); if (currentType != ARRAYTYPE && currentType != OBJECTTYPE) { - if (currentValue !== pre[key]) { + if (currentValue !== pre[key] && nullOrUndefined(currentType, preType)) { setResult(result, (path == '' ? '' : path + ".") + key, currentValue); } } else if (currentType == ARRAYTYPE) { @@ -5585,6 +5597,16 @@ function nextTick$1(vm, cb) { /* */ +function clearInstance(key, value) { + // 简易去除 Vue 和小程序组件实例 + if (value) { + if (value._isVue || (value.$vm && value.$vm._isVue)) { + return {} + } + } + return value +} + function cloneWithData(vm) { // 确保当前 vm 所有数据被同步 var ret = Object.create(null); @@ -5616,7 +5638,7 @@ function cloneWithData(vm) { ret['value'] = vm.value; } - return JSON.parse(JSON.stringify(ret)) + return JSON.parse(JSON.stringify(ret, clearInstance)) } var patch = function(oldVnode, vnode) { diff --git a/packages/vue-cli-plugin-uni/packages/uni-cloud/dist/index.js b/packages/vue-cli-plugin-uni/packages/uni-cloud/dist/index.js index 48fbbe8282407072fbe7cada1a3643bc65a40728..f3b586aa5f3d58a1e8341660b94d14f9314186e2 100644 --- a/packages/vue-cli-plugin-uni/packages/uni-cloud/dist/index.js +++ b/packages/vue-cli-plugin-uni/packages/uni-cloud/dist/index.js @@ -1 +1,2 @@ -import{initVueI18n as e}from"@dcloudio/uni-i18n";import t from"@/pages.json";"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function n(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function s(e,t,n){return e(n={path:t,exports:{},require:function(e,t){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==t&&n.path)}},n.exports),n.exports}var o=s((function(e,t){var n;e.exports=(n=n||function(e,t){var n=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),s={},o=s.lib={},r=o.Base={extend:function(e){var t=n(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},i=o.WordArray=r.extend({init:function(e,n){e=this.words=e||[],this.sigBytes=n!=t?n:4*e.length},toString:function(e){return(e||c).stringify(this)},concat:function(e){var t=this.words,n=e.words,s=this.sigBytes,o=e.sigBytes;if(this.clamp(),s%4)for(var r=0;r>>2]>>>24-r%4*8&255;t[s+r>>>2]|=i<<24-(s+r)%4*8}else for(r=0;r>>2]=n[r>>>2];return this.sigBytes+=o,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=r.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n,s=[],o=function(t){t=t;var n=987654321,s=4294967295;return function(){var o=((n=36969*(65535&n)+(n>>16)&s)<<16)+(t=18e3*(65535&t)+(t>>16)&s)&s;return o/=4294967296,(o+=.5)*(e.random()>.5?1:-1)}},r=0;r>>2]>>>24-o%4*8&255;s.push((r>>>4).toString(16)),s.push((15&r).toString(16))}return s.join("")},parse:function(e){for(var t=e.length,n=[],s=0;s>>3]|=parseInt(e.substr(s,2),16)<<24-s%8*4;return new i.init(n,t/2)}},u=a.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,s=[],o=0;o>>2]>>>24-o%4*8&255;s.push(String.fromCharCode(r))}return s.join("")},parse:function(e){for(var t=e.length,n=[],s=0;s>>2]|=(255&e.charCodeAt(s))<<24-s%4*8;return new i.init(n,t)}},l=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},h=o.BufferedBlockAlgorithm=r.extend({reset:function(){this._data=new i.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,s=n.words,o=n.sigBytes,r=this.blockSize,a=o/(4*r),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*r,u=e.min(4*c,o);if(c){for(var l=0;l>>24)|4278255360&(o<<24|o>>>8)}var r=this._hash.words,i=e[t+0],c=e[t+1],f=e[t+2],g=e[t+3],p=e[t+4],m=e[t+5],y=e[t+6],_=e[t+7],w=e[t+8],k=e[t+9],v=e[t+10],T=e[t+11],S=e[t+12],P=e[t+13],A=e[t+14],I=e[t+15],b=r[0],O=r[1],C=r[2],E=r[3];b=u(b,O,C,E,i,7,a[0]),E=u(E,b,O,C,c,12,a[1]),C=u(C,E,b,O,f,17,a[2]),O=u(O,C,E,b,g,22,a[3]),b=u(b,O,C,E,p,7,a[4]),E=u(E,b,O,C,m,12,a[5]),C=u(C,E,b,O,y,17,a[6]),O=u(O,C,E,b,_,22,a[7]),b=u(b,O,C,E,w,7,a[8]),E=u(E,b,O,C,k,12,a[9]),C=u(C,E,b,O,v,17,a[10]),O=u(O,C,E,b,T,22,a[11]),b=u(b,O,C,E,S,7,a[12]),E=u(E,b,O,C,P,12,a[13]),C=u(C,E,b,O,A,17,a[14]),b=l(b,O=u(O,C,E,b,I,22,a[15]),C,E,c,5,a[16]),E=l(E,b,O,C,y,9,a[17]),C=l(C,E,b,O,T,14,a[18]),O=l(O,C,E,b,i,20,a[19]),b=l(b,O,C,E,m,5,a[20]),E=l(E,b,O,C,v,9,a[21]),C=l(C,E,b,O,I,14,a[22]),O=l(O,C,E,b,p,20,a[23]),b=l(b,O,C,E,k,5,a[24]),E=l(E,b,O,C,A,9,a[25]),C=l(C,E,b,O,g,14,a[26]),O=l(O,C,E,b,w,20,a[27]),b=l(b,O,C,E,P,5,a[28]),E=l(E,b,O,C,f,9,a[29]),C=l(C,E,b,O,_,14,a[30]),b=h(b,O=l(O,C,E,b,S,20,a[31]),C,E,m,4,a[32]),E=h(E,b,O,C,w,11,a[33]),C=h(C,E,b,O,T,16,a[34]),O=h(O,C,E,b,A,23,a[35]),b=h(b,O,C,E,c,4,a[36]),E=h(E,b,O,C,p,11,a[37]),C=h(C,E,b,O,_,16,a[38]),O=h(O,C,E,b,v,23,a[39]),b=h(b,O,C,E,P,4,a[40]),E=h(E,b,O,C,i,11,a[41]),C=h(C,E,b,O,g,16,a[42]),O=h(O,C,E,b,y,23,a[43]),b=h(b,O,C,E,k,4,a[44]),E=h(E,b,O,C,S,11,a[45]),C=h(C,E,b,O,I,16,a[46]),b=d(b,O=h(O,C,E,b,f,23,a[47]),C,E,i,6,a[48]),E=d(E,b,O,C,_,10,a[49]),C=d(C,E,b,O,A,15,a[50]),O=d(O,C,E,b,m,21,a[51]),b=d(b,O,C,E,S,6,a[52]),E=d(E,b,O,C,g,10,a[53]),C=d(C,E,b,O,v,15,a[54]),O=d(O,C,E,b,c,21,a[55]),b=d(b,O,C,E,w,6,a[56]),E=d(E,b,O,C,I,10,a[57]),C=d(C,E,b,O,y,15,a[58]),O=d(O,C,E,b,P,21,a[59]),b=d(b,O,C,E,p,6,a[60]),E=d(E,b,O,C,T,10,a[61]),C=d(C,E,b,O,f,15,a[62]),O=d(O,C,E,b,k,21,a[63]),r[0]=r[0]+b|0,r[1]=r[1]+O|0,r[2]=r[2]+C|0,r[3]=r[3]+E|0},_doFinalize:function(){var t=this._data,n=t.words,s=8*this._nDataBytes,o=8*t.sigBytes;n[o>>>5]|=128<<24-o%32;var r=e.floor(s/4294967296),i=s;n[15+(o+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),n[14+(o+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t.sigBytes=4*(n.length+1),this._process();for(var a=this._hash,c=a.words,u=0;u<4;u++){var l=c[u];c[u]=16711935&(l<<8|l>>>24)|4278255360&(l<<24|l>>>8)}return a},clone:function(){var e=r.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,n,s,o,r,i){var a=e+(t&n|~t&s)+o+i;return(a<>>32-r)+t}function l(e,t,n,s,o,r,i){var a=e+(t&s|n&~s)+o+i;return(a<>>32-r)+t}function h(e,t,n,s,o,r,i){var a=e+(t^n^s)+o+i;return(a<>>32-r)+t}function d(e,t,n,s,o,r,i){var a=e+(n^(t|~s))+o+i;return(a<>>32-r)+t}t.MD5=r._createHelper(c),t.HmacMD5=r._createHmacHelper(c)}(Math),n.MD5)})),s((function(e,t){var n,s,r;e.exports=(s=(n=o).lib.Base,r=n.enc.Utf8,void(n.algo.HMAC=s.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=r.parse(t));var n=e.blockSize,s=4*n;t.sigBytes>s&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),i=this._iKey=t.clone(),a=o.words,c=i.words,u=0;u{v.indexOf(n)>-1&&function(e,t,n){let s=T[e][t];s||(s=T[e][t]=[]),-1===s.indexOf(n)&&"function"==typeof n&&s.push(n)}(e,n,t[n])}))}function P(e,t){T[e]||(T[e]={}),l(t)?Object.keys(t).forEach((n=>{v.indexOf(n)>-1&&function(e,t,n){const s=T[e][t];if(!s)return;const o=s.indexOf(n);o>-1&&s.splice(o,1)}(e,n,t[n])})):delete T[e]}function A(e,t){return e&&0!==e.length?e.reduce(((e,n)=>e.then((()=>n(t)))),Promise.resolve()):Promise.resolve()}function I(e,t){return T[e]&&T[e][t]||[]}function b(e){S("callObject",e)}const O=k("_globalUniCloudListener"),C="response",E="needLogin",R="refreshToken",U="clientdb",x="cloudfunction",L="cloudobject";function D(e){return O[e]||(O[e]=[]),O[e]}function N(e,t){const n=D(e);n.includes(t)||n.push(t)}function q(e,t){const n=D(e),s=n.indexOf(t);-1!==s&&n.splice(s,1)}function F(e,t){const n=D(e);for(let e=0;e{M&&e(),function t(){if("function"==typeof getCurrentPages){const t=getCurrentPages();t&&t[0]&&(M=!0,e())}M||setTimeout((()=>{t()}),30)}()}));function $(){return j}function K(e,t){return t?function(n){let s=!1;if("callFunction"===t){const e=n&&n.type||i;s=e!==i}const o="callFunction"===t&&!s;let r;r=this.isReady?Promise.resolve():this.initUniCloud,n=n||{};const a=r.then((()=>s?Promise.resolve():A(I(t,"invoke"),n))).then((()=>e.call(this,n))).then((e=>s?Promise.resolve(e):A(I(t,"success"),e).then((()=>A(I(t,"complete"),e))).then((()=>(o&&F(C,{type:x,content:e}),Promise.resolve(e))))),(e=>s?Promise.reject(e):A(I(t,"fail"),e).then((()=>A(I(t,"complete"),e))).then((()=>(F(C,{type:x,content:e}),Promise.reject(e))))));if(!(n.success||n.fail||n.complete))return a;a.then((e=>{n.success&&n.success(e),n.complete&&n.complete(e),o&&F(C,{type:x,content:e})}),(e=>{n.fail&&n.fail(e),n.complete&&n.complete(e),o&&F(C,{type:x,content:e})}))}:function(t){if(!((t=t||{}).success||t.fail||t.complete))return e.call(this,t);e.call(this,t).then((e=>{t.success&&t.success(e),t.complete&&t.complete(e)}),(e=>{t.fail&&t.fail(e),t.complete&&t.complete(e)}))}}class B extends Error{constructor(e){super(e.message),this.errMsg=e.message||"",this.errCode=this.code=e.code||"SYSTEM_ERROR",this.requestId=e.requestId}}function H(){let e,t;try{if(uni.getLaunchOptionsSync){if(uni.getLaunchOptionsSync.toString().indexOf("not yet implemented")>-1)return;const{scene:n,channel:s}=uni.getLaunchOptionsSync();e=s,t=n}}catch(e){}return{channel:e,scene:t}}let W;function z(){const e=uni.getLocale&&uni.getLocale()||"en";if(W)return{...W,locale:e,LOCALE:e};const t=uni.getSystemInfoSync(),{deviceId:n,osName:s,uniPlatform:o,appId:r}=t,i=["pixelRatio","brand","model","system","language","version","platform","host","SDKVersion","swanNativeVersion","app","AppPlatform","fontSizeSetting"];for(let e=0;e{t(Object.assign(e,{complete(e){e||(e={}),d&&"web"===g&&e.errMsg&&0===e.errMsg.indexOf("request:fail")&&console.warn("发布H5,需要在uniCloud后台操作,绑定安全域名,否则会因为跨域问题而无法访问。教程参考:https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5");const t=e.data&&e.data.header&&e.data.header["x-serverless-request-id"]||e.header&&e.header["request-id"];if(!e.statusCode||e.statusCode>=400)return s(new B({code:"SYS_ERR",message:e.errMsg||"request:fail",requestId:t}));const o=e.data;if(o.error)return s(new B({code:o.error.code,message:o.error.message,requestId:t}));o.result=o.data,o.requestId=t,delete o.data,n(o)}}))}))}};var V={request:e=>uni.request(e),uploadFile:e=>uni.uploadFile(e),setStorageSync:(e,t)=>uni.setStorageSync(e,t),getStorageSync:e=>uni.getStorageSync(e),removeStorageSync:e=>uni.removeStorageSync(e),clearStorageSync:()=>uni.clearStorageSync()},Y={"uniCloud.init.paramRequired":"{param} required","uniCloud.uploadFile.fileError":"filePath should be instance of File"};const{t:X}=e({"zh-Hans":{"uniCloud.init.paramRequired":"缺少参数:{param}","uniCloud.uploadFile.fileError":"filePath应为File对象"},"zh-Hant":{"uniCloud.init.paramRequired":"缺少参数:{param}","uniCloud.uploadFile.fileError":"filePath应为File对象"},en:Y,fr:{"uniCloud.init.paramRequired":"{param} required","uniCloud.uploadFile.fileError":"filePath should be instance of File"},es:{"uniCloud.init.paramRequired":"{param} required","uniCloud.uploadFile.fileError":"filePath should be instance of File"},ja:Y},"zh-Hans");var G=class{constructor(e){["spaceId","clientSecret"].forEach((t=>{if(!Object.prototype.hasOwnProperty.call(e,t))throw new Error(X("uniCloud.init.paramRequired",{param:t}))})),this.config=Object.assign({},{endpoint:"https://api.bspapp.com"},e),this.config.provider="aliyun",this.config.requestUrl=this.config.endpoint+"/client",this.config.envType=this.config.envType||"public",this.config.accessTokenKey="access_token_"+this.config.spaceId,this.adapter=V,this._getAccessTokenPromise=null,this._getAccessTokenPromiseStatus=null}get hasAccessToken(){return!!this.accessToken}setAccessToken(e){this.accessToken=e}requestWrapped(e){return J.wrappedRequest(e,this.adapter.request)}requestAuth(e){return this.requestWrapped(e)}request(e,t){return Promise.resolve().then((()=>this.hasAccessToken?t?this.requestWrapped(e):this.requestWrapped(e).catch((t=>new Promise(((e,n)=>{!t||"GATEWAY_INVALID_TOKEN"!==t.code&&"InvalidParameter.InvalidToken"!==t.code?n(t):e()})).then((()=>this.getAccessToken())).then((()=>{const t=this.rebuildRequest(e);return this.request(t,!0)})))):this.getAccessToken().then((()=>{const t=this.rebuildRequest(e);return this.request(t,!0)}))))}rebuildRequest(e){const t=Object.assign({},e);return t.data.token=this.accessToken,t.header["x-basement-token"]=this.accessToken,t.header["x-serverless-sign"]=J.sign(t.data,this.config.clientSecret),t}setupRequest(e,t){const n=Object.assign({},e,{spaceId:this.config.spaceId,timestamp:Date.now()}),s={"Content-Type":"application/json"};return"auth"!==t&&(n.token=this.accessToken,s["x-basement-token"]=this.accessToken),s["x-serverless-sign"]=J.sign(n,this.config.clientSecret),{url:this.config.requestUrl,method:"POST",data:n,dataType:"json",header:s}}getAccessToken(){if("pending"===this._getAccessTokenPromiseStatus)return this._getAccessTokenPromise;this._getAccessTokenPromiseStatus="pending";return this._getAccessTokenPromise=this.requestAuth(this.setupRequest({method:"serverless.auth.user.anonymousAuthorize",params:"{}"},"auth")).then((e=>new Promise(((t,n)=>{e.result&&e.result.accessToken?(this.setAccessToken(e.result.accessToken),this._getAccessTokenPromiseStatus="fulfilled",t(this.accessToken)):(this._getAccessTokenPromiseStatus="rejected",n(new B({code:"AUTH_FAILED",message:"获取accessToken失败"})))}))),(e=>(this._getAccessTokenPromiseStatus="rejected",Promise.reject(e)))),this._getAccessTokenPromise}authorize(){this.getAccessToken()}callFunction(e){const t={method:"serverless.function.runtime.invoke",params:JSON.stringify({functionTarget:e.name,functionArgs:e.data||{}})};return this.request(this.setupRequest(t))}getOSSUploadOptionsFromPath(e){const t={method:"serverless.file.resource.generateProximalSign",params:JSON.stringify(e)};return this.request(this.setupRequest(t))}uploadFileToOSS({url:e,formData:t,name:n,filePath:s,fileType:o,onUploadProgress:r}){return new Promise(((i,a)=>{const c=this.adapter.uploadFile({url:e,formData:t,name:n,filePath:s,fileType:o,header:{"X-OSS-server-side-encrpytion":"AES256"},success(e){e&&e.statusCode<400?i(e):a(new B({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){a(new B({code:e.code||"UPLOAD_FAILED",message:e.message||e.errMsg||"文件上传失败"}))}});"function"==typeof r&&c&&"function"==typeof c.onProgressUpdate&&c.onProgressUpdate((e=>{r({loaded:e.totalBytesSent,total:e.totalBytesExpectedToSend})}))}))}reportOSSUpload(e){const t={method:"serverless.file.resource.report",params:JSON.stringify(e)};return this.request(this.setupRequest(t))}uploadFile({filePath:e,cloudPath:t,fileType:n="image",onUploadProgress:s,config:o}){if("string"!==u(t))throw new B({code:"INVALID_PARAM",message:"cloudPath必须为字符串类型"});if(!(t=t.trim()))throw new B({code:"CLOUDPATH_REQUIRED",message:"cloudPath不可为空"});if(/:\/\//.test(t))throw new B({code:"INVALID_PARAM",message:"cloudPath不合法"});const r=o&&o.envType||this.config.envType;let i,a;return this.getOSSUploadOptionsFromPath({env:r,filename:t}).then((t=>{const o=t.result;i=o.id,a="https://"+o.cdnDomain+"/"+o.ossPath;const r={url:"https://"+o.host,formData:{"Cache-Control":"max-age=2592000","Content-Disposition":"attachment",OSSAccessKeyId:o.accessKeyId,Signature:o.signature,host:o.host,id:i,key:o.ossPath,policy:o.policy,success_action_status:200},fileName:"file",name:"file",filePath:e,fileType:n};return this.uploadFileToOSS(Object.assign({},r,{onUploadProgress:s}))})).then((()=>this.reportOSSUpload({id:i}))).then((t=>new Promise(((n,s)=>{t.success?n({success:!0,filePath:e,fileID:a}):s(new B({code:"UPLOAD_FAILED",message:"文件上传失败"}))}))))}deleteFile({fileList:e}){const t={method:"serverless.file.resource.delete",params:JSON.stringify({id:e[0]})};return this.request(this.setupRequest(t))}getTempFileURL({fileList:e}={}){return new Promise(((t,n)=>{Array.isArray(e)&&0!==e.length||n(new B({code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"})),t({fileList:e.map((e=>({fileID:e,tempFileURL:e})))})}))}};var Q={init(e){const t=new G(e),n={signInAnonymously:function(){return t.authorize()},getLoginState:function(){return Promise.resolve(!1)}};return t.auth=function(){return n},t.customAuth=t.auth,t}};const Z="undefined"!=typeof location&&"http:"===location.protocol?"http:":"https:";var ee;!function(e){e.local="local",e.none="none",e.session="session"}(ee||(ee={}));var te=function(){};const ne=()=>{let e;if(!Promise){e=()=>{},e.promise={};const t=()=>{throw new B({message:'Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.'})};return Object.defineProperty(e.promise,"then",{get:t}),Object.defineProperty(e.promise,"catch",{get:t}),e}const t=new Promise(((t,n)=>{e=(e,s)=>e?n(e):t(s)}));return e.promise=t,e};function se(e){return void 0===e}function oe(e){return"[object Null]"===Object.prototype.toString.call(e)}var re;function ie(e){const t=(n=e,"[object Array]"===Object.prototype.toString.call(n)?e:[e]);var n;for(const e of t){const{isMatch:t,genAdapter:n,runtime:s}=e;if(t())return{adapter:n(),runtime:s}}}!function(e){e.WEB="web",e.WX_MP="wx_mp"}(re||(re={}));const ae={adapter:null,runtime:void 0},ce=["anonymousUuidKey"];class ue extends te{constructor(){super(),ae.adapter.root.tcbObject||(ae.adapter.root.tcbObject={})}setItem(e,t){ae.adapter.root.tcbObject[e]=t}getItem(e){return ae.adapter.root.tcbObject[e]}removeItem(e){delete ae.adapter.root.tcbObject[e]}clear(){delete ae.adapter.root.tcbObject}}function le(e,t){switch(e){case"local":return t.localStorage||new ue;case"none":return new ue;default:return t.sessionStorage||new ue}}class he{constructor(e){if(!this._storage){this._persistence=ae.adapter.primaryStorage||e.persistence,this._storage=le(this._persistence,ae.adapter);const t=`access_token_${e.env}`,n=`access_token_expire_${e.env}`,s=`refresh_token_${e.env}`,o=`anonymous_uuid_${e.env}`,r=`login_type_${e.env}`,i=`user_info_${e.env}`;this.keys={accessTokenKey:t,accessTokenExpireKey:n,refreshTokenKey:s,anonymousUuidKey:o,loginTypeKey:r,userInfoKey:i}}}updatePersistence(e){if(e===this._persistence)return;const t="local"===this._persistence;this._persistence=e;const n=le(e,ae.adapter);for(const e in this.keys){const s=this.keys[e];if(t&&ce.includes(e))continue;const o=this._storage.getItem(s);se(o)||oe(o)||(n.setItem(s,o),this._storage.removeItem(s))}this._storage=n}setStore(e,t,n){if(!this._storage)return;const s={version:n||"localCachev1",content:t},o=JSON.stringify(s);try{this._storage.setItem(e,o)}catch(e){throw e}}getStore(e,t){try{if(!this._storage)return}catch(e){return""}t=t||"localCachev1";const n=this._storage.getItem(e);if(!n)return"";if(n.indexOf(t)>=0){return JSON.parse(n).content}return""}removeStore(e){this._storage.removeItem(e)}}const de={},fe={};function ge(e){return de[e]}class pe{constructor(e,t){this.data=t||null,this.name=e}}class me extends pe{constructor(e,t){super("error",{error:e,data:t}),this.error=e}}const ye=new class{constructor(){this._listeners={}}on(e,t){return function(e,t,n){n[e]=n[e]||[],n[e].push(t)}(e,t,this._listeners),this}off(e,t){return function(e,t,n){if(n&&n[e]){const s=n[e].indexOf(t);-1!==s&&n[e].splice(s,1)}}(e,t,this._listeners),this}fire(e,t){if(e instanceof me)return console.error(e.error),this;const n="string"==typeof e?new pe(e,t||{}):e;const s=n.name;if(this._listens(s)){n.target=this;const e=this._listeners[s]?[...this._listeners[s]]:[];for(const t of e)t.call(this,n)}return this}_listens(e){return this._listeners[e]&&this._listeners[e].length>0}};function _e(e,t){ye.on(e,t)}function we(e,t={}){ye.fire(e,t)}function ke(e,t){ye.off(e,t)}const ve="loginStateChanged",Te="loginStateExpire",Se="loginTypeChanged",Pe="anonymousConverted",Ae="refreshAccessToken";var Ie;!function(e){e.ANONYMOUS="ANONYMOUS",e.WECHAT="WECHAT",e.WECHAT_PUBLIC="WECHAT-PUBLIC",e.WECHAT_OPEN="WECHAT-OPEN",e.CUSTOM="CUSTOM",e.EMAIL="EMAIL",e.USERNAME="USERNAME",e.NULL="NULL"}(Ie||(Ie={}));const be=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"],Oe={"X-SDK-Version":"1.3.5"};function Ce(e,t,n){const s=e[t];e[t]=function(t){const o={},r={};n.forEach((n=>{const{data:s,headers:i}=n.call(e,t);Object.assign(o,s),Object.assign(r,i)}));const i=t.data;return i&&(()=>{var e;if(e=i,"[object FormData]"!==Object.prototype.toString.call(e))t.data={...i,...o};else for(const e in o)i.append(e,o[e])})(),t.headers={...t.headers||{},...r},s.call(e,t)}}function Ee(){const e=Math.random().toString(16).slice(2);return{data:{seqId:e},headers:{...Oe,"x-seqid":e}}}class Re{constructor(e={}){var t;this.config=e,this._reqClass=new ae.adapter.reqClass({timeout:this.config.timeout,timeoutMsg:`请求在${this.config.timeout/1e3}s内未完成,已中断`,restrictedMethods:["post"]}),this._cache=ge(this.config.env),this._localCache=(t=this.config.env,fe[t]),Ce(this._reqClass,"post",[Ee]),Ce(this._reqClass,"upload",[Ee]),Ce(this._reqClass,"download",[Ee])}async post(e){return await this._reqClass.post(e)}async upload(e){return await this._reqClass.upload(e)}async download(e){return await this._reqClass.download(e)}async refreshAccessToken(){let e,t;this._refreshAccessTokenPromise||(this._refreshAccessTokenPromise=this._refreshAccessToken());try{e=await this._refreshAccessTokenPromise}catch(e){t=e}if(this._refreshAccessTokenPromise=null,this._shouldRefreshAccessTokenHook=null,t)throw t;return e}async _refreshAccessToken(){const{accessTokenKey:e,accessTokenExpireKey:t,refreshTokenKey:n,loginTypeKey:s,anonymousUuidKey:o}=this._cache.keys;this._cache.removeStore(e),this._cache.removeStore(t);let r=this._cache.getStore(n);if(!r)throw new B({message:"未登录CloudBase"});const i={refresh_token:r},a=await this.request("auth.fetchAccessTokenWithRefreshToken",i);if(a.data.code){const{code:e}=a.data;if("SIGN_PARAM_INVALID"===e||"REFRESH_TOKEN_EXPIRED"===e||"INVALID_REFRESH_TOKEN"===e){if(this._cache.getStore(s)===Ie.ANONYMOUS&&"INVALID_REFRESH_TOKEN"===e){const e=this._cache.getStore(o),t=this._cache.getStore(n),s=await this.send("auth.signInAnonymously",{anonymous_uuid:e,refresh_token:t});return this.setRefreshToken(s.refresh_token),this._refreshAccessToken()}we(Te),this._cache.removeStore(n)}throw new B({code:a.data.code,message:`刷新access token失败:${a.data.code}`})}if(a.data.access_token)return we(Ae),this._cache.setStore(e,a.data.access_token),this._cache.setStore(t,a.data.access_token_expire+Date.now()),{accessToken:a.data.access_token,accessTokenExpire:a.data.access_token_expire};a.data.refresh_token&&(this._cache.removeStore(n),this._cache.setStore(n,a.data.refresh_token),this._refreshAccessToken())}async getAccessToken(){const{accessTokenKey:e,accessTokenExpireKey:t,refreshTokenKey:n}=this._cache.keys;if(!this._cache.getStore(n))throw new B({message:"refresh token不存在,登录状态异常"});let s=this._cache.getStore(e),o=this._cache.getStore(t),r=!0;return this._shouldRefreshAccessTokenHook&&!await this._shouldRefreshAccessTokenHook(s,o)&&(r=!1),(!s||!o||o{e.wxOpenId&&e.wxPublicId&&(t=!0)})),{users:n,hasPrimaryUid:t}}setPrimaryUid(e){return this._request.send("auth.setPrimaryUid",{uid:e})}unlink(e){return this._request.send("auth.unlink",{platform:e})}async update(e){const{nickName:t,gender:n,avatarUrl:s,province:o,country:r,city:i}=e,{data:a}=await this._request.send("auth.updateUserInfo",{nickName:t,gender:n,avatarUrl:s,province:o,country:r,city:i});this.setLocalUserInfo(a)}async refresh(){const{data:e}=await this._request.send("auth.getUserInfo",{});return this.setLocalUserInfo(e),e}setUserInfo(){const{userInfoKey:e}=this._cache.keys,t=this._cache.getStore(e);["uid","loginType","openid","wxOpenId","wxPublicId","unionId","qqMiniOpenId","email","hasPassword","customUserId","nickName","gender","avatarUrl"].forEach((e=>{this[e]=t[e]})),this.location={country:t.country,province:t.province,city:t.city}}setLocalUserInfo(e){const{userInfoKey:t}=this._cache.keys;this._cache.setStore(t,e),this.setUserInfo()}}class Ne{constructor(e){if(!e)throw new B({code:"PARAM_ERROR",message:"envId is not defined"});this._cache=ge(e);const{refreshTokenKey:t,accessTokenKey:n,accessTokenExpireKey:s}=this._cache.keys,o=this._cache.getStore(t),r=this._cache.getStore(n),i=this._cache.getStore(s);this.credential={refreshToken:o,accessToken:r,accessTokenExpire:i},this.user=new De(e)}get isAnonymousAuth(){return this.loginType===Ie.ANONYMOUS}get isCustomAuth(){return this.loginType===Ie.CUSTOM}get isWeixinAuth(){return this.loginType===Ie.WECHAT||this.loginType===Ie.WECHAT_OPEN||this.loginType===Ie.WECHAT_PUBLIC}get loginType(){return this._cache.getStore(this._cache.keys.loginTypeKey)}}class qe extends Le{async signIn(){this._cache.updatePersistence("local");const{anonymousUuidKey:e,refreshTokenKey:t}=this._cache.keys,n=this._cache.getStore(e)||void 0,s=this._cache.getStore(t)||void 0,o=await this._request.send("auth.signInAnonymously",{anonymous_uuid:n,refresh_token:s});if(o.uuid&&o.refresh_token){this._setAnonymousUUID(o.uuid),this.setRefreshToken(o.refresh_token),await this._request.refreshAccessToken(),we(ve),we(Se,{env:this.config.env,loginType:Ie.ANONYMOUS,persistence:"local"});const e=new Ne(this.config.env);return await e.user.refresh(),e}throw new B({message:"匿名登录失败"})}async linkAndRetrieveDataWithTicket(e){const{anonymousUuidKey:t,refreshTokenKey:n}=this._cache.keys,s=this._cache.getStore(t),o=this._cache.getStore(n),r=await this._request.send("auth.linkAndRetrieveDataWithTicket",{anonymous_uuid:s,refresh_token:o,ticket:e});if(r.refresh_token)return this._clearAnonymousUUID(),this.setRefreshToken(r.refresh_token),await this._request.refreshAccessToken(),we(Pe,{env:this.config.env}),we(Se,{loginType:Ie.CUSTOM,persistence:"local"}),{credential:{refreshToken:r.refresh_token}};throw new B({message:"匿名转化失败"})}_setAnonymousUUID(e){const{anonymousUuidKey:t,loginTypeKey:n}=this._cache.keys;this._cache.removeStore(t),this._cache.setStore(t,e),this._cache.setStore(n,Ie.ANONYMOUS)}_clearAnonymousUUID(){this._cache.removeStore(this._cache.keys.anonymousUuidKey)}}class Fe extends Le{async signIn(e){if("string"!=typeof e)throw new B({param:"PARAM_ERROR",message:"ticket must be a string"});const{refreshTokenKey:t}=this._cache.keys,n=await this._request.send("auth.signInWithTicket",{ticket:e,refresh_token:this._cache.getStore(t)||""});if(n.refresh_token)return this.setRefreshToken(n.refresh_token),await this._request.refreshAccessToken(),we(ve),we(Se,{env:this.config.env,loginType:Ie.CUSTOM,persistence:this.config.persistence}),await this.refreshUserInfo(),new Ne(this.config.env);throw new B({message:"自定义登录失败"})}}class Me extends Le{async signIn(e,t){if("string"!=typeof e)throw new B({code:"PARAM_ERROR",message:"email must be a string"});const{refreshTokenKey:n}=this._cache.keys,s=await this._request.send("auth.signIn",{loginType:"EMAIL",email:e,password:t,refresh_token:this._cache.getStore(n)||""}),{refresh_token:o,access_token:r,access_token_expire:i}=s;if(o)return this.setRefreshToken(o),r&&i?this.setAccessToken(r,i):await this._request.refreshAccessToken(),await this.refreshUserInfo(),we(ve),we(Se,{env:this.config.env,loginType:Ie.EMAIL,persistence:this.config.persistence}),new Ne(this.config.env);throw s.code?new B({code:s.code,message:`邮箱登录失败: ${s.message}`}):new B({message:"邮箱登录失败"})}async activate(e){return this._request.send("auth.activateEndUserMail",{token:e})}async resetPasswordWithToken(e,t){return this._request.send("auth.resetPasswordWithToken",{token:e,newPassword:t})}}class je extends Le{async signIn(e,t){if("string"!=typeof e)throw new B({code:"PARAM_ERROR",message:"username must be a string"});"string"!=typeof t&&(t="",console.warn("password is empty"));const{refreshTokenKey:n}=this._cache.keys,s=await this._request.send("auth.signIn",{loginType:Ie.USERNAME,username:e,password:t,refresh_token:this._cache.getStore(n)||""}),{refresh_token:o,access_token_expire:r,access_token:i}=s;if(o)return this.setRefreshToken(o),i&&r?this.setAccessToken(i,r):await this._request.refreshAccessToken(),await this.refreshUserInfo(),we(ve),we(Se,{env:this.config.env,loginType:Ie.USERNAME,persistence:this.config.persistence}),new Ne(this.config.env);throw s.code?new B({code:s.code,message:`用户名密码登录失败: ${s.message}`}):new B({message:"用户名密码登录失败"})}}class $e{constructor(e){this.config=e,this._cache=ge(e.env),this._request=xe(e.env),this._onAnonymousConverted=this._onAnonymousConverted.bind(this),this._onLoginTypeChanged=this._onLoginTypeChanged.bind(this),_e(Se,this._onLoginTypeChanged)}get currentUser(){const e=this.hasLoginState();return e&&e.user||null}get loginType(){return this._cache.getStore(this._cache.keys.loginTypeKey)}anonymousAuthProvider(){return new qe(this.config)}customAuthProvider(){return new Fe(this.config)}emailAuthProvider(){return new Me(this.config)}usernameAuthProvider(){return new je(this.config)}async signInAnonymously(){return new qe(this.config).signIn()}async signInWithEmailAndPassword(e,t){return new Me(this.config).signIn(e,t)}signInWithUsernameAndPassword(e,t){return new je(this.config).signIn(e,t)}async linkAndRetrieveDataWithTicket(e){this._anonymousAuthProvider||(this._anonymousAuthProvider=new qe(this.config)),_e(Pe,this._onAnonymousConverted);return await this._anonymousAuthProvider.linkAndRetrieveDataWithTicket(e)}async signOut(){if(this.loginType===Ie.ANONYMOUS)throw new B({message:"匿名用户不支持登出操作"});const{refreshTokenKey:e,accessTokenKey:t,accessTokenExpireKey:n}=this._cache.keys,s=this._cache.getStore(e);if(!s)return;const o=await this._request.send("auth.logout",{refresh_token:s});return this._cache.removeStore(e),this._cache.removeStore(t),this._cache.removeStore(n),we(ve),we(Se,{env:this.config.env,loginType:Ie.NULL,persistence:this.config.persistence}),o}async signUpWithEmailAndPassword(e,t){return this._request.send("auth.signUpWithEmailAndPassword",{email:e,password:t})}async sendPasswordResetEmail(e){return this._request.send("auth.sendPasswordResetEmail",{email:e})}onLoginStateChanged(e){_e(ve,(()=>{const t=this.hasLoginState();e.call(this,t)}));const t=this.hasLoginState();e.call(this,t)}onLoginStateExpired(e){_e(Te,e.bind(this))}onAccessTokenRefreshed(e){_e(Ae,e.bind(this))}onAnonymousConverted(e){_e(Pe,e.bind(this))}onLoginTypeChanged(e){_e(Se,(()=>{const t=this.hasLoginState();e.call(this,t)}))}async getAccessToken(){return{accessToken:(await this._request.getAccessToken()).accessToken,env:this.config.env}}hasLoginState(){const{refreshTokenKey:e}=this._cache.keys;return this._cache.getStore(e)?new Ne(this.config.env):null}async isUsernameRegistered(e){if("string"!=typeof e)throw new B({code:"PARAM_ERROR",message:"username must be a string"});const{data:t}=await this._request.send("auth.isUsernameRegistered",{username:e});return t&&t.isRegistered}getLoginState(){return Promise.resolve(this.hasLoginState())}async signInWithTicket(e){return new Fe(this.config).signIn(e)}shouldRefreshAccessToken(e){this._request._shouldRefreshAccessTokenHook=e.bind(this)}getUserInfo(){return this._request.send("auth.getUserInfo",{}).then((e=>e.code?e:{...e.data,requestId:e.seqId}))}getAuthHeader(){const{refreshTokenKey:e,accessTokenKey:t}=this._cache.keys,n=this._cache.getStore(e);return{"x-cloudbase-credentials":this._cache.getStore(t)+"/@@/"+n}}_onAnonymousConverted(e){const{env:t}=e.data;t===this.config.env&&this._cache.updatePersistence(this.config.persistence)}_onLoginTypeChanged(e){const{loginType:t,persistence:n,env:s}=e.data;s===this.config.env&&(this._cache.updatePersistence(n),this._cache.setStore(this._cache.keys.loginTypeKey,t))}}const Ke=function(e,t){t=t||ne();const n=xe(this.config.env),{cloudPath:s,filePath:o,onUploadProgress:r,fileType:i="image"}=e;return n.send("storage.getUploadMetadata",{path:s}).then((e=>{const{data:{url:a,authorization:c,token:u,fileId:l,cosFileId:h},requestId:d}=e,f={key:s,signature:c,"x-cos-meta-fileid":h,success_action_status:"201","x-cos-security-token":u};n.upload({url:a,data:f,file:o,name:s,fileType:i,onUploadProgress:r}).then((e=>{201===e.statusCode?t(null,{fileID:l,requestId:d}):t(new B({code:"STORAGE_REQUEST_FAIL",message:`STORAGE_REQUEST_FAIL: ${e.data}`}))})).catch((e=>{t(e)}))})).catch((e=>{t(e)})),t.promise},Be=function(e,t){t=t||ne();const n=xe(this.config.env),{cloudPath:s}=e;return n.send("storage.getUploadMetadata",{path:s}).then((e=>{t(null,e)})).catch((e=>{t(e)})),t.promise},He=function({fileList:e},t){if(t=t||ne(),!e||!Array.isArray(e))return{code:"INVALID_PARAM",message:"fileList必须是非空的数组"};for(let t of e)if(!t||"string"!=typeof t)return{code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"};const n={fileid_list:e};return xe(this.config.env).send("storage.batchDeleteFile",n).then((e=>{e.code?t(null,e):t(null,{fileList:e.data.delete_list,requestId:e.requestId})})).catch((e=>{t(e)})),t.promise},We=function({fileList:e},t){t=t||ne(),e&&Array.isArray(e)||t(null,{code:"INVALID_PARAM",message:"fileList必须是非空的数组"});let n=[];for(let s of e)"object"==typeof s?(s.hasOwnProperty("fileID")&&s.hasOwnProperty("maxAge")||t(null,{code:"INVALID_PARAM",message:"fileList的元素必须是包含fileID和maxAge的对象"}),n.push({fileid:s.fileID,max_age:s.maxAge})):"string"==typeof s?n.push({fileid:s}):t(null,{code:"INVALID_PARAM",message:"fileList的元素必须是字符串"});const s={file_list:n};return xe(this.config.env).send("storage.batchGetDownloadUrl",s).then((e=>{e.code?t(null,e):t(null,{fileList:e.data.download_list,requestId:e.requestId})})).catch((e=>{t(e)})),t.promise},ze=async function({fileID:e},t){const n=(await We.call(this,{fileList:[{fileID:e,maxAge:600}]})).fileList[0];if("SUCCESS"!==n.code)return t?t(n):new Promise((e=>{e(n)}));const s=xe(this.config.env);let o=n.download_url;if(o=encodeURI(o),!t)return s.download({url:o});t(await s.download({url:o}))},Je=function({name:e,data:t,query:n,parse:s,search:o},r){const i=r||ne();let a;try{a=t?JSON.stringify(t):""}catch(e){return Promise.reject(e)}if(!e)return Promise.reject(new B({code:"PARAM_ERROR",message:"函数名不能为空"}));const c={inQuery:n,parse:s,search:o,function_name:e,request_data:a};return xe(this.config.env).send("functions.invokeFunction",c).then((e=>{if(e.code)i(null,e);else{let t=e.data.response_data;if(s)i(null,{result:t,requestId:e.requestId});else try{t=JSON.parse(e.data.response_data),i(null,{result:t,requestId:e.requestId})}catch(e){i(new B({message:"response data must be json"}))}}return i.promise})).catch((e=>{i(e)})),i.promise},Ve={timeout:15e3,persistence:"session"},Ye={};class Xe{constructor(e){this.config=e||this.config,this.authObj=void 0}init(e){switch(ae.adapter||(this.requestClient=new ae.adapter.reqClass({timeout:e.timeout||5e3,timeoutMsg:`请求在${(e.timeout||5e3)/1e3}s内未完成,已中断`})),this.config={...Ve,...e},!0){case this.config.timeout>6e5:console.warn("timeout大于可配置上限[10分钟],已重置为上限数值"),this.config.timeout=6e5;break;case this.config.timeout<100:console.warn("timeout小于可配置下限[100ms],已重置为下限数值"),this.config.timeout=100}return new Xe(this.config)}auth({persistence:e}={}){if(this.authObj)return this.authObj;const t=e||ae.adapter.primaryStorage||Ve.persistence;var n;return t!==this.config.persistence&&(this.config.persistence=t),function(e){const{env:t}=e;de[t]=new he(e),fe[t]=new he({...e,persistence:"local"})}(this.config),n=this.config,Ue[n.env]=new Re(n),this.authObj=new $e(this.config),this.authObj}on(e,t){return _e.apply(this,[e,t])}off(e,t){return ke.apply(this,[e,t])}callFunction(e,t){return Je.apply(this,[e,t])}deleteFile(e,t){return He.apply(this,[e,t])}getTempFileURL(e,t){return We.apply(this,[e,t])}downloadFile(e,t){return ze.apply(this,[e,t])}uploadFile(e,t){return Ke.apply(this,[e,t])}getUploadMetadata(e,t){return Be.apply(this,[e,t])}registerExtension(e){Ye[e.name]=e}async invokeExtension(e,t){const n=Ye[e];if(!n)throw new B({message:`扩展${e} 必须先注册`});return await n.invoke(t,this)}useAdapters(e){const{adapter:t,runtime:n}=ie(e)||{};t&&(ae.adapter=t),n&&(ae.runtime=n)}}var Ge=new Xe;function Qe(e,t,n){void 0===n&&(n={});var s=/\?/.test(t),o="";for(var r in n)""===o?!s&&(t+="?"):o+="&",o+=r+"="+encodeURIComponent(n[r]);return/^http(s)?:\/\//.test(t+=o)?t:""+e+t}class Ze{post(e){const{url:t,data:n,headers:s}=e;return new Promise(((e,o)=>{V.request({url:Qe("https:",t),data:n,method:"POST",header:s,success(t){e(t)},fail(e){o(e)}})}))}upload(e){return new Promise(((t,n)=>{const{url:s,file:o,data:r,headers:i,fileType:a}=e,c=V.uploadFile({url:Qe("https:",s),name:"file",formData:Object.assign({},r),filePath:o,fileType:a,header:i,success(e){const n={statusCode:e.statusCode,data:e.data||{}};200===e.statusCode&&r.success_action_status&&(n.statusCode=parseInt(r.success_action_status,10)),t(n)},fail(e){n(new Error(e.errMsg||"uploadFile:fail"))}});"function"==typeof e.onUploadProgress&&c&&"function"==typeof c.onProgressUpdate&&c.onProgressUpdate((t=>{e.onUploadProgress({loaded:t.totalBytesSent,total:t.totalBytesExpectedToSend})}))}))}}const et={setItem(e,t){V.setStorageSync(e,t)},getItem:e=>V.getStorageSync(e),removeItem(e){V.removeStorageSync(e)},clear(){V.clearStorageSync()}};var tt={genAdapter:function(){return{root:{},reqClass:Ze,localStorage:et,primaryStorage:"local"}},isMatch:function(){return!0},runtime:"uni_app"};Ge.useAdapters(tt);const nt=Ge,st=nt.init;nt.init=function(e){e.env=e.spaceId;const t=st.call(this,e);t.config.provider="tencent",t.config.spaceId=e.spaceId;const n=t.auth;return t.auth=function(e){const t=n.call(this,e);return["linkAndRetrieveDataWithTicket","signInAnonymously","signOut","getAccessToken","getLoginState","signInWithTicket","getUserInfo"].forEach((e=>{t[e]=K(t[e]).bind(t)})),t},t.customAuth=t.auth,t};var ot=nt;function rt(){return{token:V.getStorageSync("uni_id_token")||V.getStorageSync("uniIdToken"),tokenExpired:V.getStorageSync("uni_id_token_expired")}}function it({token:e,tokenExpired:t}={}){e&&V.setStorageSync("uni_id_token",e),t&&V.setStorageSync("uni_id_token_expired",t)}function at(){if(!d||"web"!==g)return;uni.getStorageSync("__LAST_DCLOUD_APPID")!==_&&(uni.setStorageSync("__LAST_DCLOUD_APPID",_),console.warn("检测到当前项目与上次运行到此端口的项目不一致,自动清理uni-id保存的token信息(仅开发调试时生效)"),V.removeStorageSync("uni_id_token"),V.removeStorageSync("uniIdToken"),V.removeStorageSync("uni_id_token_expired"))}var ct=class extends G{getAccessToken(){return new Promise(((e,t)=>{const n="Anonymous_Access_token";this.setAccessToken(n),e(n)}))}setupRequest(e,t){const n=Object.assign({},e,{spaceId:this.config.spaceId,timestamp:Date.now()}),s={"Content-Type":"application/json"};"auth"!==t&&(n.token=this.accessToken,s["x-basement-token"]=this.accessToken),s["x-serverless-sign"]=J.sign(n,this.config.clientSecret);const o=z();s["x-client-info"]=encodeURIComponent(JSON.stringify(o));const{token:r}=rt();return s["x-client-token"]=r,{url:this.config.requestUrl,method:"POST",data:n,dataType:"json",header:JSON.parse(JSON.stringify(s))}}uploadFileToOSS({url:e,formData:t,name:n,filePath:s,fileType:o,onUploadProgress:r}){return new Promise(((i,a)=>{const c=this.adapter.uploadFile({url:e,formData:t,name:n,filePath:s,fileType:o,success(e){e&&e.statusCode<400?i(e):a(new B({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){a(new B({code:e.code||"UPLOAD_FAILED",message:e.message||e.errMsg||"文件上传失败"}))}});"function"==typeof r&&c&&"function"==typeof c.onProgressUpdate&&c.onProgressUpdate((e=>{r({loaded:e.totalBytesSent,total:e.totalBytesExpectedToSend})}))}))}uploadFile({filePath:e,cloudPath:t,fileType:n="image",onUploadProgress:s}){if(!t)throw new B({code:"CLOUDPATH_REQUIRED",message:"cloudPath不可为空"});let o;return this.getOSSUploadOptionsFromPath({cloudPath:t}).then((t=>{const{url:r,formData:i,name:a}=t.result;o=t.result.fileUrl;const c={url:r,formData:i,name:a,filePath:e,fileType:n};return this.uploadFileToOSS(Object.assign({},c,{onUploadProgress:s}))})).then((()=>this.reportOSSUpload({cloudPath:t}))).then((t=>new Promise(((n,s)=>{t.success?n({success:!0,filePath:e,fileID:o}):s(new B({code:"UPLOAD_FAILED",message:"文件上传失败"}))}))))}deleteFile({fileList:e}){const t={method:"serverless.file.resource.delete",params:JSON.stringify({fileList:e})};return this.request(this.setupRequest(t))}getTempFileURL({fileList:e}={}){const t={method:"serverless.file.resource.getTempFileURL",params:JSON.stringify({fileList:e})};return this.request(this.setupRequest(t))}};var ut={init(e){const t=new ct(e),n={signInAnonymously:function(){return t.authorize()},getLoginState:function(){return Promise.resolve(!1)}};return t.auth=function(){return n},t.customAuth=t.auth,t}};function lt({data:e}){let t;t=z();const n=JSON.parse(JSON.stringify(e||{}));if(Object.assign(n,{clientInfo:t}),!n.uniIdToken){const{token:e}=rt();e&&(n.uniIdToken=e)}return n}function ht({name:e,data:t}={}){const{localAddress:n,localPort:s}=this.__dev__,o={aliyun:"aliyun",tencent:"tcb"}[this.config.provider],r=this.config.spaceId,i=`http://${n}:${s}/system/check-function`,a=`http://${n}:${s}/cloudfunctions/${e}`;return new Promise(((t,n)=>{V.request({method:"POST",url:i,data:{name:e,platform:g,provider:o,spaceId:r},timeout:3e3,success(e){t(e)},fail(){t({data:{code:"NETWORK_ERROR",message:"连接本地调试服务失败,请检查客户端是否和主机在同一局域网下,自动切换为已部署的云函数。"}})}})})).then((({data:e}={})=>{const{code:t,message:n}=e||{};return{code:0===t?0:t||"SYS_ERR",message:n||"SYS_ERR"}})).then((({code:n,message:s})=>{if(0!==n){switch(n){case"MODULE_ENCRYPTED":console.error(`此云函数(${e})依赖加密公共模块不可本地调试,自动切换为云端已部署的云函数`);break;case"FUNCTION_ENCRYPTED":console.error(`此云函数(${e})已加密不可本地调试,自动切换为云端已部署的云函数`);break;case"ACTION_ENCRYPTED":console.error(s||"需要访问加密的uni-clientDB-action,自动切换为云端环境");break;case"NETWORK_ERROR":{const e="连接本地调试服务失败,请检查客户端是否和主机在同一局域网下";throw console.error(e),new Error(e)}case"SWITCH_TO_CLOUD":break;default:{const e=`检测本地调试服务出现错误:${s},请检查网络环境或重启客户端再试`;throw console.error(e),new Error(e)}}return this._callCloudFunction({name:e,data:t})}return new Promise(((e,n)=>{const s=lt.call(this,{data:t});V.request({method:"POST",url:a,data:{provider:o,platform:g,param:s},success:({statusCode:t,data:s}={})=>!t||t>=400?n(new B({code:s.code||"SYS_ERR",message:s.message||"request:fail"})):e({result:s}),fail(e){n(new B({code:e.code||e.errCode||"SYS_ERR",message:e.message||e.errMsg||"request:fail"}))}})}))}))}const dt=[{rule:/fc_function_not_found|FUNCTION_NOT_FOUND/,content:",云函数[{functionName}]在云端不存在,请检查此云函数名称是否正确以及该云函数是否已上传到服务空间",mode:"append"}];var ft=/[\\^$.*+?()[\]{}|]/g,gt=RegExp(ft.source);function pt(e,t,n){return e.replace(new RegExp((s=t)&>.test(s)?s.replace(ft,"\\$&"):s,"g"),n);var s}function mt({functionName:e,result:t,logPvd:n}){if(this.__dev__.debugLog&&t&&t.requestId){const s=JSON.stringify({spaceId:this.config.spaceId,functionName:e,requestId:t.requestId});console.log(`[${n}-request]${s}[/${n}-request]`)}}function yt(e){const t=e.callFunction,n=function(n){const s=n.name;n.data=lt.call(e,{data:n.data});const o={aliyun:"aliyun",tencent:"tcb",tcb:"tcb"}[this.config.provider];return t.call(this,n).then((e=>(e.errCode=0,mt.call(this,{functionName:s,result:e,logPvd:o}),Promise.resolve(e))),(e=>(mt.call(this,{functionName:s,result:e,logPvd:o}),e&&e.message&&(e.message=function({message:e="",extraInfo:t={},formatter:n=[]}={}){for(let s=0;s(console.warn("当前返回结果为Promise类型,不可直接访问其result属性,详情请参考:https://uniapp.dcloud.net.cn/uniCloud/faq?id=promise"),{})}),o}}const _t=Symbol("CLIENT_DB_INTERNAL");function wt(e,t){return e.then="DoNotReturnProxyWithAFunctionNamedThen",e._internalType=_t,e.__ob__=void 0,new Proxy(e,{get(e,n,s){if("_uniClient"===n)return null;if(n in e||"string"!=typeof n){const t=e[n];return"function"==typeof t?t.bind(e):t}return t.get(e,n,s)}})}function kt(e){return{on:(t,n)=>{e[t]=e[t]||[],e[t].indexOf(n)>-1||e[t].push(n)},off:(t,n)=>{e[t]=e[t]||[];const s=e[t].indexOf(n);-1!==s&&e[t].splice(s,1)}}}const vt=["db.Geo","db.command","command.aggregate"];function Tt(e,t){return vt.indexOf(`${e}.${t}`)>-1}function St(e){switch(u(e)){case"array":return e.map((e=>St(e)));case"object":return e._internalType===_t||Object.keys(e).forEach((t=>{e[t]=St(e[t])})),e;case"regexp":return{$regexp:{source:e.source,flags:e.flags}};case"date":return{$date:e.toISOString()};default:return e}}function Pt(e){return e&&e.content&&e.content.$method}class At{constructor(e,t,n){this.content=e,this.prevStage=t||null,this.udb=null,this._database=n}toJSON(){let e=this;const t=[e.content];for(;e.prevStage;)e=e.prevStage,t.push(e.content);return{$db:t.reverse().map((e=>({$method:e.$method,$param:St(e.$param)})))}}getAction(){const e=this.toJSON().$db.find((e=>"action"===e.$method));return e&&e.$param&&e.$param[0]}getCommand(){return{$db:this.toJSON().$db.filter((e=>"action"!==e.$method))}}get isAggregate(){let e=this;for(;e;){const t=Pt(e),n=Pt(e.prevStage);if("aggregate"===t&&"collection"===n||"pipeline"===t)return!0;e=e.prevStage}return!1}get isCommand(){let e=this;for(;e;){if("command"===Pt(e))return!0;e=e.prevStage}return!1}get isAggregateCommand(){let e=this;for(;e;){const t=Pt(e),n=Pt(e.prevStage);if("aggregate"===t&&"command"===n)return!0;e=e.prevStage}return!1}get count(){if(!this.isAggregate)return function(){return this._send("count",Array.from(arguments))};const e=this;return function(){return It({$method:"count",$param:St(Array.from(arguments))},e,this._database)}}get remove(){if(!this.isCommand)return function(){return this._send("remove",Array.from(arguments))};const e=this;return function(){return It({$method:"remove",$param:St(Array.from(arguments))},e,this._database)}}get(){return this._send("get",Array.from(arguments))}add(){return this._send("add",Array.from(arguments))}update(){return this._send("update",Array.from(arguments))}end(){return this._send("end",Array.from(arguments))}get set(){if(!this.isCommand)return function(){throw new Error("JQL禁止使用set方法")};const e=this;return function(){return It({$method:"set",$param:St(Array.from(arguments))},e,this._database)}}_send(e,t){const n=this.getAction(),s=this.getCommand();if(s.$db.push({$method:e,$param:St(t)}),d){const e=s.$db.find((e=>"collection"===e.$method)),t=e&&e.$param;t&&1===t.length&&"string"==typeof e.$param[0]&&e.$param[0].indexOf(",")>-1&&console.warn("检测到使用JQL语法联表查询时,未使用getTemp先过滤主表数据,在主表数据量大的情况下可能会查询缓慢。\n- 如何优化请参考此文档:https://uniapp.dcloud.net.cn/uniCloud/jql?id=lookup-with-temp \n- 如果主表数据量很小请忽略此信息,项目发行时不会出现此提示。")}return this._database._callCloudFunction({action:n,command:s})}}function It(e,t,n){return wt(new At(e,t,n),{get(e,t){let s="db";return e&&e.content&&(s=e.content.$method),Tt(s,t)?It({$method:t},e,n):function(){return It({$method:t,$param:St(Array.from(arguments))},e,n)}}})}function bt({path:e,method:t}){return class{constructor(){this.param=Array.from(arguments)}toJSON(){return{$newDb:[...e.map((e=>({$method:e}))),{$method:t,$param:this.param}]}}}}class Ot extends class{constructor({uniClient:e={}}={}){this._uniClient=e,this._authCallBacks={},this._dbCallBacks={},e.isDefault&&(this._dbCallBacks=k("_globalUniCloudDatabaseCallback")),this.auth=kt(this._authCallBacks),Object.assign(this,kt(this._dbCallBacks)),this.env=wt({},{get:(e,t)=>({$env:t})}),this.Geo=wt({},{get:(e,t)=>bt({path:["Geo"],method:t})}),this.serverDate=bt({path:[],method:"serverDate"}),this.RegExp=bt({path:[],method:"RegExp"})}getCloudEnv(e){if("string"!=typeof e||!e.trim())throw new Error("getCloudEnv参数错误");return{$env:e.replace("$cloudEnv_","")}}_callback(e,t){const n=this._dbCallBacks;n[e]&&n[e].forEach((e=>{e(...t)}))}_callbackAuth(e,t){const n=this._authCallBacks;n[e]&&n[e].forEach((e=>{e(...t)}))}multiSend(){const e=Array.from(arguments),t=e.map((e=>{const t=e.getAction(),n=e.getCommand();if("getTemp"!==n.$db[n.$db.length-1].$method)throw new Error("multiSend只支持子命令内使用getTemp");return{action:t,command:n}}));return this._callCloudFunction({multiCommand:t,queryList:e})}}{_callCloudFunction({action:e,command:t,multiCommand:n,queryList:s}){function o(e,t){if(n&&s)for(let n=0;nA(I("database","complete"),e))).then((()=>(o(null,e),F(C,{type:U,content:e}),Promise.reject(e))))}const a=A(I("database","invoke")),u=this._uniClient;return a.then((()=>u.callFunction({name:"DCloud-clientDB",type:c,data:{action:e,command:t,multiCommand:n}}))).then((e=>{const{code:t,message:n,token:s,tokenExpired:r,systemInfo:a=[]}=e.result;if(a)for(let e=0;e(console.warn(s),t)})}}return function(e){return A(I("database","success"),e).then((()=>A(I("database","complete"),e))).then((()=>(o(e,null),F(C,{type:U,content:e}),Promise.resolve(e))))}(e)}),(e=>{/fc_function_not_found|FUNCTION_NOT_FOUND/g.test(e.message)&&console.warn("clientDB未初始化,请在web控制台保存一次schema以开启clientDB");return i(new B({code:e.code||"SYSTEM_ERROR",message:e.message,requestId:e.requestId}))}))}}function Ct(e){e.database=function(t){if(t&&Object.keys(t).length>0)return e.init(t).database();if(this._database)return this._database;const n=function(e,t={}){return wt(new e(t),{get:(e,t)=>Tt("db",t)?It({$method:t},null,e):function(){return It({$method:t,$param:St(Array.from(arguments))},null,e)}})}(Ot,{uniClient:e});return this._database=n,n}}const Et="token无效,跳转登录页面",Rt="token过期,跳转登录页面",Ut={TOKEN_INVALID_TOKEN_EXPIRED:Rt,TOKEN_INVALID_INVALID_CLIENTID:Et,TOKEN_INVALID:Et,TOKEN_INVALID_WRONG_TOKEN:Et,TOKEN_INVALID_ANONYMOUS_USER:Et},xt={"uni-id-token-expired":Rt,"uni-id-check-token-failed":Et,"uni-id-token-not-exist":Et,"uni-id-check-device-feature-failed":Et};function Lt(e,t){let n="";return n=e?`${e}/${t}`:t,n.replace(/^\//,"")}function Dt(e=[],t=""){const n=[],s=[];return e.forEach((e=>{!0===e.needLogin?n.push(Lt(t,e.path)):!1===e.needLogin&&s.push(Lt(t,e.path))})),{needLoginPage:n,notNeedLoginPage:s}}function Nt(e){return e.split("?")[0].replace(/^\//,"")}function qt(){return function(e){let t=e&&e.$page&&e.$page.fullPath||"";return t?("/"!==t.charAt(0)&&(t="/"+t),t):t}(function(){const e=getCurrentPages();return e[e.length-1]}())}function Ft(){return Nt(qt())}function Mt(e="",t={}){if(!e)return!1;if(!(t&&t.list&&t.list.length))return!1;const n=t.list,s=Nt(e);return n.some((e=>e.pagePath===s))}const jt=!!t.uniIdRouter;const{loginPage:$t,routerNeedLogin:Kt,resToLogin:Bt,needLoginPage:Ht,notNeedLoginPage:Wt,loginPageInTabBar:zt}=function({pages:e=[],subPackages:n=[],uniIdRouter:s={},tabBar:o={}}=t){const{loginPage:r,needLogin:i=[],resToLogin:a=!0}=s,{needLoginPage:c,notNeedLoginPage:u}=Dt(e),{needLoginPage:l,notNeedLoginPage:h}=function(e=[]){const t=[],n=[];return e.forEach((e=>{const{root:s,pages:o=[]}=e,{needLoginPage:r,notNeedLoginPage:i}=Dt(o,s);t.push(...r),n.push(...i)})),{needLoginPage:t,notNeedLoginPage:n}}(n);return{loginPage:r,routerNeedLogin:i,resToLogin:a,needLoginPage:[...c,...l],notNeedLoginPage:[...u,...h],loginPageInTabBar:Mt(r,o)}}();if(Ht.indexOf($t)>-1)throw new Error(`Login page [${$t}] should not be "needLogin", please check your pages.json`);function Jt(e){const t=Nt(function(e){const t=Ft(),n=e.charAt(0),s=e.split("?")[0];if("/"===n)return s;const o=s.replace(/^\//,"").split("/"),r=t.split("/");r.pop();for(let e=0;e-1)&&(Ht.indexOf(t)>-1||Kt.some((t=>function(e,t){return new RegExp(t).test(e)}(e,t))))}function Vt({redirect:e}){const t=Nt(e),n=Nt($t);return Ft()!==n&&t!==n}function Yt({api:e,redirect:t}={}){if(!t||!Vt({redirect:t}))return;const n=function(e,t){return"/"!==e.charAt(0)&&(e="/"+e),t?e.indexOf("?")>-1?e+`&uniIdRedirectUrl=${encodeURIComponent(t)}`:e+`?uniIdRedirectUrl=${encodeURIComponent(t)}`:e}($t,t);zt?"navigateTo"!==e&&"redirectTo"!==e||(e="switchTab"):"switchTab"===e&&(e="navigateTo"),setTimeout((()=>{uni[e]({url:n})}))}function Xt({url:e}={}){const t={abortLoginPageJump:!1,autoToLoginPage:!1},n=function(){const{token:e,tokenExpired:t}=rt();let n;if(e){if(t0)return setTimeout((()=>{F(E,n)}),0),t.abortLoginPageJump=!0,t;t.autoToLoginPage=!0}return t}function Gt(){!function(){const e=qt(),{abortLoginPageJump:t,autoToLoginPage:n}=Xt({url:e});t||n&&Yt({api:"redirectTo",redirect:e})}();const e=["navigateTo","redirectTo","reLaunch","switchTab"];for(let t=0;t{const{type:t,content:n}=e;let s=!1;switch(t){case"cloudobject":s=function(e){const{errCode:t}=e;return t in xt}(n);break;case"clientdb":s=function(e){const{errCode:t}=e;return t in Ut}(n)}s&&function(e={}){const t=D(E);$().then((()=>{const n=qt();if(n&&Vt({redirect:n}))return t.length>0?F(E,Object.assign({uniIdRedirectUrl:n},e)):void($t&&Yt({api:"navigateTo",redirect:n}))}))}(n)}))}function Zt(e){!function(e){e.onResponse=function(e){N(C,e)},e.offResponse=function(e){q(C,e)}}(e),function(e){e.onNeedLogin=function(e){N(E,e)},e.offNeedLogin=function(e){q(E,e)},jt&&(k("uni-cloud-status").needLoginInit||(k("uni-cloud-status").needLoginInit=!0,$().then((()=>{Gt.call(e)})),Bt&&Qt.call(e)))}(e),function(e){e.onRefreshToken=function(e){N(R,e)},e.offRefreshToken=function(e){q(R,e)}}(e)}let en;const tn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",nn=/^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;function sn(){const e=rt().token||"",t=e.split(".");if(!e||3!==t.length)return{uid:null,role:[],permission:[],tokenExpired:0};let n;try{n=JSON.parse((s=t[1],decodeURIComponent(en(s).split("").map((function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)})).join(""))))}catch(e){throw new Error("获取当前用户信息出错,详细错误信息为:"+e.message)}var s;return n.tokenExpired=1e3*n.exp,delete n.exp,delete n.iat,n}en="function"!=typeof atob?function(e){if(e=String(e).replace(/[\t\n\f\r ]+/g,""),!nn.test(e))throw new Error("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");var t;e+="==".slice(2-(3&e.length));for(var n,s,o="",r=0;r>16&255):64===s?String.fromCharCode(t>>16&255,t>>8&255):String.fromCharCode(t>>16&255,t>>8&255,255&t);return o}:atob;var on=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0});const n="chooseAndUploadFile:ok",s="chooseAndUploadFile:fail";function o(e,t){return e.tempFiles.forEach(((e,n)=>{e.name||(e.name=e.path.substring(e.path.lastIndexOf("/")+1)),t&&(e.fileType=t),e.cloudPath=Date.now()+"_"+n+e.name.substring(e.name.lastIndexOf("."))})),e.tempFilePaths||(e.tempFilePaths=e.tempFiles.map((e=>e.path))),e}function r(e,t,{onChooseFile:s,onUploadProgress:o}){return t.then((e=>{if(s){const t=s(e);if(void 0!==t)return Promise.resolve(t).then((t=>void 0===t?e:t))}return e})).then((t=>!1===t?{errMsg:n,tempFilePaths:[],tempFiles:[]}:function(e,t,s=5,o){(t=Object.assign({},t)).errMsg=n;const r=t.tempFiles,i=r.length;let a=0;return new Promise((n=>{for(;a=i)return void(!r.find((e=>!e.url&&!e.errMsg))&&n(t));const u=r[s];e.uploadFile({filePath:u.path,cloudPath:u.cloudPath,fileType:u.fileType,onUploadProgress(e){e.index=s,e.tempFile=u,e.tempFilePath=u.path,o&&o(e)}}).then((e=>{u.url=e.fileID,s{u.errMsg=e.errMsg||e.message,s{uni.chooseImage({count:t,sizeType:n,sourceType:r,extension:i,success(t){e(o(t,"image"))},fail(e){a({errMsg:e.errMsg.replace("chooseImage:fail",s)})}})}))}(t),t):"video"===t.type?r(e,function(e){const{camera:t,compressed:n,maxDuration:r,sourceType:i=["album","camera"],extension:a}=e;return new Promise(((e,c)=>{uni.chooseVideo({camera:t,compressed:n,maxDuration:r,sourceType:i,extension:a,success(t){const{tempFilePath:n,duration:s,size:r,height:i,width:a}=t;e(o({errMsg:"chooseVideo:ok",tempFilePaths:[n],tempFiles:[{name:t.tempFile&&t.tempFile.name||"",path:n,size:r,type:t.tempFile&&t.tempFile.type||"",width:a,height:i,duration:s,fileType:"video",cloudPath:""}]},"video"))},fail(e){c({errMsg:e.errMsg.replace("chooseVideo:fail",s)})}})}))}(t),t):r(e,function(e){const{count:t,extension:n}=e;return new Promise(((e,r)=>{let i=uni.chooseFile;if("undefined"!=typeof wx&&"function"==typeof wx.chooseMessageFile&&(i=wx.chooseMessageFile),"function"!=typeof i)return r({errMsg:s+" 请指定 type 类型,该平台仅支持选择 image 或 video。"});i({type:"all",count:t,extension:n,success(t){e(o(t))},fail(e){r({errMsg:e.errMsg.replace("chooseFile:fail",s)})}})}))}(t),t)}}})),rn=n(on);const an="manual";function cn(e){return{props:{localdata:{type:Array,default:()=>[]},options:{type:[Object,Array],default:()=>({})},spaceInfo:{type:Object,default:()=>({})},collection:{type:[String,Array],default:""},action:{type:String,default:""},field:{type:String,default:""},orderby:{type:String,default:""},where:{type:[String,Object],default:""},pageData:{type:String,default:"add"},pageCurrent:{type:Number,default:1},pageSize:{type:Number,default:20},getcount:{type:[Boolean,String],default:!1},gettree:{type:[Boolean,String],default:!1},gettreepath:{type:[Boolean,String],default:!1},startwith:{type:String,default:""},limitlevel:{type:Number,default:10},groupby:{type:String,default:""},groupField:{type:String,default:""},distinct:{type:[Boolean,String],default:!1},foreignKey:{type:String,default:""},loadtime:{type:String,default:"auto"},manual:{type:Boolean,default:!1}},data:()=>({mixinDatacomLoading:!1,mixinDatacomHasMore:!1,mixinDatacomResData:[],mixinDatacomErrorMessage:"",mixinDatacomPage:{}}),created(){this.mixinDatacomPage={current:this.pageCurrent,size:this.pageSize,count:0},this.$watch((()=>{var e=[];return["pageCurrent","pageSize","localdata","collection","action","field","orderby","where","getont","getcount","gettree","groupby","groupField","distinct"].forEach((t=>{e.push(this[t])})),e}),((e,t)=>{if(this.loadtime===an)return;let n=!1;const s=[];for(let o=2;o{this.mixinDatacomLoading=!1;const{data:s,count:o}=n.result;this.getcount&&(this.mixinDatacomPage.count=o),this.mixinDatacomHasMore=s.length{this.mixinDatacomLoading=!1,this.mixinDatacomErrorMessage=e,n&&n(e)})))},mixinDatacomGet(t={}){let n=e.database(this.spaceInfo);const s=t.action||this.action;s&&(n=n.action(s));const o=t.collection||this.collection;n=Array.isArray(o)?n.collection(...o):n.collection(o);const r=t.where||this.where;r&&Object.keys(r).length&&(n=n.where(r));const i=t.field||this.field;i&&(n=n.field(i));const a=t.foreignKey||this.foreignKey;a&&(n=n.foreignKey(a));const c=t.groupby||this.groupby;c&&(n=n.groupBy(c));const u=t.groupField||this.groupField;u&&(n=n.groupField(u));!0===(void 0!==t.distinct?t.distinct:this.distinct)&&(n=n.distinct());const l=t.orderby||this.orderby;l&&(n=n.orderBy(l));const h=void 0!==t.pageCurrent?t.pageCurrent:this.mixinDatacomPage.current,d=void 0!==t.pageSize?t.pageSize:this.mixinDatacomPage.size,f=void 0!==t.getcount?t.getcount:this.getcount,g=void 0!==t.gettree?t.gettree:this.gettree,p=void 0!==t.gettreepath?t.gettreepath:this.gettreepath,m={getCount:f},y={limitLevel:void 0!==t.limitlevel?t.limitlevel:this.limitlevel,startWith:void 0!==t.startwith?t.startwith:this.startwith};return g&&(m.getTree=y),p&&(m.getTreePath=y),n=n.skip(d*(h-1)).limit(d).get(m),n}}}}function un(e){return function(t,n={}){n=function(e,t={}){return e.customUI=t.customUI||e.customUI,Object.assign(e.loadingOptions,t.loadingOptions),Object.assign(e.errorOptions,t.errorOptions),"object"==typeof t.secretMethods&&(e.secretMethods=t.secretMethods),e}({customUI:!1,loadingOptions:{title:"加载中...",mask:!0},errorOptions:{type:"modal",retry:!1}},n);const{customUI:s,loadingOptions:o,errorOptions:r}=n,i=!s;return new Proxy({},{get:(s,c)=>function({fn:e,interceptorName:t,getCallbackArgs:n}={}){return async function(...s){const o=n?n({params:s}):{};let r,i;try{return await A(I(t,"invoke"),{...o}),r=await e(...s),await A(I(t,"success"),{...o,result:r}),r}catch(e){throw i=e,await A(I(t,"fail"),{...o,error:i}),i}finally{await A(I(t,"complete"),i?{...o,error:i}:{...o,result:r})}}}({fn:async function s(...u){let l;i&&uni.showLoading({title:o.title,mask:o.mask});const h={name:t,type:a,data:{method:c,params:u}};"object"==typeof n.secretMethods&&function(e,t){const n=t.data.method,s=e.secretMethods[n];s&&(t.secret=s)}(n,h);try{l=await e.callFunction(h)}catch(e){l={result:e}}const{errCode:d,errMsg:f,newToken:g}=l.result||{};if(i&&uni.hideLoading(),g&&g.token&&g.tokenExpired&&(it(g),F(R,{...g})),d){if(i)if("toast"===r.type)uni.showToast({title:f,icon:"none"});else{if("modal"!==r.type)throw new Error(`Invalid errorOptions.type: ${r.type}`);{const{confirm:e}=await async function({title:e,content:t,showCancel:n,cancelText:s,confirmText:o}={}){return new Promise(((r,i)=>{uni.showModal({title:e,content:t,showCancel:n,cancelText:s,confirmText:o,success(e){r(e)},fail(){r({confirm:!1,cancel:!0})}})}))}({title:"提示",content:f,showCancel:r.retry,cancelText:"取消",confirmText:r.retry?"重试":"确定"});if(r.retry&&e)return s(...u)}}const e=new B({code:d,message:f,requestId:l.requestId});throw e.detail=l.result,F(C,{type:L,content:e}),e}return F(C,{type:L,content:l.result}),l.result},interceptorName:"callObject",getCallbackArgs:function({params:e}={}){return{objectName:t,methodName:c,params:e}}})})}}async function ln(e,t){const n=`http://${e}:${t}/system/ping`;try{const e=await(s={url:n,timeout:500},new Promise(((e,t)=>{V.request({...s,success(t){e(t)},fail(e){t(e)}})})));return!(!e.data||0!==e.data.code)}catch(e){return!1}var s}function hn(e){if(e.initUniCloudStatus&&"rejected"!==e.initUniCloudStatus)return;let t=Promise.resolve();var n;n=1,t=new Promise(((e,t)=>{setTimeout((()=>{e()}),n)})),e.isReady=!1,e.isDefault=!1;const s=e.auth();e.initUniCloudStatus="pending",e.initUniCloud=t.then((()=>s.getLoginState())).then((e=>e?Promise.resolve():s.signInAnonymously())).then((()=>{if(!d)return Promise.resolve();if("app"===g){const{osName:e,osVersion:t}=uni.getSystemInfoSync();"ios"===e&&function(e){if(!e||"string"!=typeof e)return 0;const t=e.match(/^(\d+)./);return t&&t[1]?parseInt(t[1]):0}(t)>=14&&console.warn("iOS 14及以上版本连接uniCloud本地调试服务需要允许客户端查找并连接到本地网络上的设备(仅开发模式生效,发行模式会连接uniCloud云端服务)")}if(d&&e.__dev__.debugInfo){const{address:t,servePort:n}=e.__dev__.debugInfo;return async function(e,t){let n;for(let s=0;s{if(!d)return Promise.resolve();const s=console["app"===g?"error":"warn"];if(t)e.__dev__.localAddress=t,e.__dev__.localPort=n;else if(e.__dev__.debugInfo){let t="";"remote"===e.__dev__.debugInfo.initialLaunchType?(e.__dev__.debugInfo.forceRemote=!0,t="当前客户端和HBuilderX不在同一局域网下(或其他网络原因无法连接HBuilderX),uniCloud本地调试服务不对当前客户端生效。\n- 如果不使用uniCloud本地调试服务,请直接忽略此信息。\n- 如需使用uniCloud本地调试服务,请将客户端与主机连接到同一局域网下并重新运行到客户端。\n- 如果在HBuilderX开启的状态下切换过网络环境,请重启HBuilderX后再试\n- 检查系统防火墙是否拦截了HBuilderX自带的nodejs"):t="无法连接uniCloud本地调试服务,请检查当前客户端是否与主机在同一局域网下。\n- 如需使用uniCloud本地调试服务,请将客户端与主机连接到同一局域网下并重新运行到客户端。\n- 如果在HBuilderX开启的状态下切换过网络环境,请重启HBuilderX后再试\n- 检查系统防火墙是否拦截了HBuilderX自带的nodejs","web"===g&&(t+="\n- 部分浏览器开启节流模式之后访问本地地址受限,请检查是否启用了节流模式"),0===g.indexOf("mp-")&&(t+="\n- 小程序中如何使用uniCloud,请参考:https://uniapp.dcloud.net.cn/uniCloud/publish.html#useinmp"),s(t)}})).then((()=>{at(),e.isReady=!0,e.initUniCloudStatus="fulfilled"})).catch((t=>{console.error(t),e.initUniCloudStatus="rejected"}))}const dn={tcb:ot,tencent:ot,aliyun:Q,private:ut};let fn=new class{init(e){let t={};const n=dn[e.provider];if(!n)throw new Error("未提供正确的provider参数");t=n.init(e),t.__dev__={},t.__dev__.debugLog=d&&("web"===g&&navigator.userAgent.indexOf("HBuilderX")>0||"app"===g);const s=p;d&&s&&!s.code&&(t.__dev__.debugInfo=s),hn(t),t.reInit=function(){hn(this)},yt(t),function(e){const t=e.uploadFile;e.uploadFile=function(e){return t.call(this,e)}}(t),Ct(t),function(e){e.getCurrentUserInfo=sn,e.chooseAndUploadFile=rn.initChooseAndUploadFile(e),Object.assign(e,{get mixinDatacom(){return cn(e)}}),e.importObject=un(e)}(t);return["callFunction","uploadFile","deleteFile","getTempFileURL","downloadFile","chooseAndUploadFile"].forEach((e=>{if(!t[e])return;const n=t[e];t[e]=function(){return t.reInit(),n.apply(t,Array.from(arguments))},t[e]=K(t[e],e).bind(t)})),t.init=this.init,t}};(()=>{const e=m;let t={};if(e&&1===e.length)t=e[0],fn=fn.init(t),fn.isDefault=!0;else{const t=["auth","callFunction","uploadFile","deleteFile","getTempFileURL","downloadFile","database","getCurrentUSerInfo","importObject"];let n;n=e&&e.length>0?"应用有多个服务空间,请通过uniCloud.init方法指定要使用的服务空间":y?"应用未关联服务空间,请在uniCloud目录右键关联服务空间":"uni-app cli项目内使用uniCloud需要使用HBuilderX的运行菜单运行项目,且需要在uniCloud目录关联服务空间",t.forEach((e=>{fn[e]=function(){return console.error(n),Promise.reject(new B({code:"SYS_ERR",message:n}))}}))}Object.assign(fn,{get mixinDatacom(){return cn(fn)}}),Zt(fn),fn.addInterceptor=S,fn.removeInterceptor=P,fn.interceptObject=b,d&&"web"===g&&(window.uniCloud=fn)})();var gn=fn;export{gn as default}; +import{initVueI18n as e}from"@dcloudio/uni-i18n";import t from"@/pages.json";"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function n(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function s(e,t,n){return e(n={path:t,exports:{},require:function(e,t){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==t&&n.path)}},n.exports),n.exports}var r=s((function(e,t){var n;e.exports=(n=n||function(e,t){var n=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),s={},r=s.lib={},i=r.Base={extend:function(e){var t=n(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},o=r.WordArray=i.extend({init:function(e,n){e=this.words=e||[],this.sigBytes=n!=t?n:4*e.length},toString:function(e){return(e||c).stringify(this)},concat:function(e){var t=this.words,n=e.words,s=this.sigBytes,r=e.sigBytes;if(this.clamp(),s%4)for(var i=0;i>>2]>>>24-i%4*8&255;t[s+i>>>2]|=o<<24-(s+i)%4*8}else for(i=0;i>>2]=n[i>>>2];return this.sigBytes+=r,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n,s=[],r=function(t){t=t;var n=987654321,s=4294967295;return function(){var r=((n=36969*(65535&n)+(n>>16)&s)<<16)+(t=18e3*(65535&t)+(t>>16)&s)&s;return r/=4294967296,(r+=.5)*(e.random()>.5?1:-1)}},i=0;i>>2]>>>24-r%4*8&255;s.push((i>>>4).toString(16)),s.push((15&i).toString(16))}return s.join("")},parse:function(e){for(var t=e.length,n=[],s=0;s>>3]|=parseInt(e.substr(s,2),16)<<24-s%8*4;return new o.init(n,t/2)}},u=a.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,s=[],r=0;r>>2]>>>24-r%4*8&255;s.push(String.fromCharCode(i))}return s.join("")},parse:function(e){for(var t=e.length,n=[],s=0;s>>2]|=(255&e.charCodeAt(s))<<24-s%4*8;return new o.init(n,t)}},h=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},l=r.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new o.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=h.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,s=n.words,r=n.sigBytes,i=this.blockSize,a=r/(4*i),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*i,u=e.min(4*c,r);if(c){for(var h=0;h>>24)|4278255360&(r<<24|r>>>8)}var i=this._hash.words,o=e[t+0],c=e[t+1],f=e[t+2],p=e[t+3],g=e[t+4],m=e[t+5],y=e[t+6],_=e[t+7],w=e[t+8],v=e[t+9],S=e[t+10],k=e[t+11],T=e[t+12],I=e[t+13],b=e[t+14],A=e[t+15],P=i[0],C=i[1],E=i[2],O=i[3];P=u(P,C,E,O,o,7,a[0]),O=u(O,P,C,E,c,12,a[1]),E=u(E,O,P,C,f,17,a[2]),C=u(C,E,O,P,p,22,a[3]),P=u(P,C,E,O,g,7,a[4]),O=u(O,P,C,E,m,12,a[5]),E=u(E,O,P,C,y,17,a[6]),C=u(C,E,O,P,_,22,a[7]),P=u(P,C,E,O,w,7,a[8]),O=u(O,P,C,E,v,12,a[9]),E=u(E,O,P,C,S,17,a[10]),C=u(C,E,O,P,k,22,a[11]),P=u(P,C,E,O,T,7,a[12]),O=u(O,P,C,E,I,12,a[13]),E=u(E,O,P,C,b,17,a[14]),P=h(P,C=u(C,E,O,P,A,22,a[15]),E,O,c,5,a[16]),O=h(O,P,C,E,y,9,a[17]),E=h(E,O,P,C,k,14,a[18]),C=h(C,E,O,P,o,20,a[19]),P=h(P,C,E,O,m,5,a[20]),O=h(O,P,C,E,S,9,a[21]),E=h(E,O,P,C,A,14,a[22]),C=h(C,E,O,P,g,20,a[23]),P=h(P,C,E,O,v,5,a[24]),O=h(O,P,C,E,b,9,a[25]),E=h(E,O,P,C,p,14,a[26]),C=h(C,E,O,P,w,20,a[27]),P=h(P,C,E,O,I,5,a[28]),O=h(O,P,C,E,f,9,a[29]),E=h(E,O,P,C,_,14,a[30]),P=l(P,C=h(C,E,O,P,T,20,a[31]),E,O,m,4,a[32]),O=l(O,P,C,E,w,11,a[33]),E=l(E,O,P,C,k,16,a[34]),C=l(C,E,O,P,b,23,a[35]),P=l(P,C,E,O,c,4,a[36]),O=l(O,P,C,E,g,11,a[37]),E=l(E,O,P,C,_,16,a[38]),C=l(C,E,O,P,S,23,a[39]),P=l(P,C,E,O,I,4,a[40]),O=l(O,P,C,E,o,11,a[41]),E=l(E,O,P,C,p,16,a[42]),C=l(C,E,O,P,y,23,a[43]),P=l(P,C,E,O,v,4,a[44]),O=l(O,P,C,E,T,11,a[45]),E=l(E,O,P,C,A,16,a[46]),P=d(P,C=l(C,E,O,P,f,23,a[47]),E,O,o,6,a[48]),O=d(O,P,C,E,_,10,a[49]),E=d(E,O,P,C,b,15,a[50]),C=d(C,E,O,P,m,21,a[51]),P=d(P,C,E,O,T,6,a[52]),O=d(O,P,C,E,p,10,a[53]),E=d(E,O,P,C,S,15,a[54]),C=d(C,E,O,P,c,21,a[55]),P=d(P,C,E,O,w,6,a[56]),O=d(O,P,C,E,A,10,a[57]),E=d(E,O,P,C,y,15,a[58]),C=d(C,E,O,P,I,21,a[59]),P=d(P,C,E,O,g,6,a[60]),O=d(O,P,C,E,k,10,a[61]),E=d(E,O,P,C,f,15,a[62]),C=d(C,E,O,P,v,21,a[63]),i[0]=i[0]+P|0,i[1]=i[1]+C|0,i[2]=i[2]+E|0,i[3]=i[3]+O|0},_doFinalize:function(){var t=this._data,n=t.words,s=8*this._nDataBytes,r=8*t.sigBytes;n[r>>>5]|=128<<24-r%32;var i=e.floor(s/4294967296),o=s;n[15+(r+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),n[14+(r+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),t.sigBytes=4*(n.length+1),this._process();for(var a=this._hash,c=a.words,u=0;u<4;u++){var h=c[u];c[u]=16711935&(h<<8|h>>>24)|4278255360&(h<<24|h>>>8)}return a},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,n,s,r,i,o){var a=e+(t&n|~t&s)+r+o;return(a<>>32-i)+t}function h(e,t,n,s,r,i,o){var a=e+(t&s|n&~s)+r+o;return(a<>>32-i)+t}function l(e,t,n,s,r,i,o){var a=e+(t^n^s)+r+o;return(a<>>32-i)+t}function d(e,t,n,s,r,i,o){var a=e+(n^(t|~s))+r+o;return(a<>>32-i)+t}t.MD5=i._createHelper(c),t.HmacMD5=i._createHmacHelper(c)}(Math),n.MD5)})),s((function(e,t){var n;e.exports=(n=i,void function(){var e=n,t=e.lib.Base,s=e.enc.Utf8;e.algo.HMAC=t.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=s.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var i=this._oKey=t.clone(),o=this._iKey=t.clone(),a=i.words,c=o.words,u=0;u{T.indexOf(n)>-1&&function(e,t,n){let s=I[e][t];s||(s=I[e][t]=[]),-1===s.indexOf(n)&&"function"==typeof n&&s.push(n)}(e,n,t[n])}))}function A(e,t){I[e]||(I[e]={}),l(t)?Object.keys(t).forEach((n=>{T.indexOf(n)>-1&&function(e,t,n){const s=I[e][t];if(!s)return;const r=s.indexOf(n);r>-1&&s.splice(r,1)}(e,n,t[n])})):delete I[e]}function P(e,t){return e&&0!==e.length?e.reduce(((e,n)=>e.then((()=>n(t)))),Promise.resolve()):Promise.resolve()}function C(e,t){return I[e]&&I[e][t]||[]}function E(e){b("callObject",e)}const O=k("_globalUniCloudListener"),R="response",U="needLogin",x="refreshToken",L="clientdb",D="cloudfunction",N="cloudobject";function q(e){return O[e]||(O[e]=[]),O[e]}function F(e,t){const n=q(e);n.includes(t)||n.push(t)}function K(e,t){const n=q(e),s=n.indexOf(t);-1!==s&&n.splice(s,1)}function M(e,t){const n=q(e);for(let e=0;e{B&&e(),function t(){if("function"==typeof getCurrentPages){const t=getCurrentPages();t&&t[0]&&(B=!0,e())}B||setTimeout((()=>{t()}),30)}()})),j)}function W(e,t){return t?function(n){let s=!1;if("callFunction"===t){const e=n&&n.type||a;s=e!==a}const r="callFunction"===t&&!s;let i;i=this.isReady?Promise.resolve():this.initUniCloud,n=n||{};const o=i.then((()=>s?Promise.resolve():P(C(t,"invoke"),n))).then((()=>e.call(this,n))).then((e=>s?Promise.resolve(e):P(C(t,"success"),e).then((()=>P(C(t,"complete"),e))).then((()=>(r&&M(R,{type:D,content:e}),Promise.resolve(e))))),(e=>s?Promise.reject(e):P(C(t,"fail"),e).then((()=>P(C(t,"complete"),e))).then((()=>(M(R,{type:D,content:e}),Promise.reject(e))))));if(!(n.success||n.fail||n.complete))return o;o.then((e=>{n.success&&n.success(e),n.complete&&n.complete(e),r&&M(R,{type:D,content:e})}),(e=>{n.fail&&n.fail(e),n.complete&&n.complete(e),r&&M(R,{type:D,content:e})}))}:function(t){if(!((t=t||{}).success||t.fail||t.complete))return e.call(this,t);e.call(this,t).then((e=>{t.success&&t.success(e),t.complete&&t.complete(e)}),(e=>{t.fail&&t.fail(e),t.complete&&t.complete(e)}))}}class H extends Error{constructor(e){const t=e.code||"SYSTEM_ERROR",n=e.message||"unknown system error";super(n),this.errMsg=n,this.errCode=this.code=t,this.requestId=e.requestId}}function J(){let e,t;try{if(uni.getLaunchOptionsSync){if(uni.getLaunchOptionsSync.toString().indexOf("not yet implemented")>-1)return;const{scene:n,channel:s}=uni.getLaunchOptionsSync();e=s,t=n}}catch(e){}return{channel:e,scene:t}}function V(){const e=uni.getLocale&&uni.getLocale()||"en";if($)return{...$,locale:e,LOCALE:e};const t=uni.getSystemInfoSync(),{deviceId:n,osName:s,uniPlatform:r,appId:i}=t,o=["pixelRatio","brand","model","system","language","version","platform","host","SDKVersion","swanNativeVersion","app","AppPlatform","fontSizeSetting"];for(let e=0;e{t(Object.assign(e,{complete(e){e||(e={}),f&&"web"===m&&e.errMsg&&0===e.errMsg.indexOf("request:fail")&&console.warn("发布H5,需要在uniCloud后台操作,绑定安全域名,否则会因为跨域问题而无法访问。教程参考:https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5");const t=e.data&&e.data.header&&e.data.header["x-serverless-request-id"]||e.header&&e.header["request-id"];if(!e.statusCode||e.statusCode>=400)return s(new H({code:"SYS_ERR",message:e.errMsg||"request:fail",requestId:t}));const r=e.data;if(r.error)return s(new H({code:r.error.code,message:r.error.message,requestId:t}));r.result=r.data,r.requestId=t,delete r.data,n(r)}}))}))}};var Q={request:e=>uni.request(e),uploadFile:e=>uni.uploadFile(e),setStorageSync:(e,t)=>uni.setStorageSync(e,t),getStorageSync:e=>uni.getStorageSync(e),removeStorageSync:e=>uni.removeStorageSync(e),clearStorageSync:()=>uni.clearStorageSync()},X={"uniCloud.init.paramRequired":"{param} required","uniCloud.uploadFile.fileError":"filePath should be instance of File"};const{t:G}=e({"zh-Hans":{"uniCloud.init.paramRequired":"缺少参数:{param}","uniCloud.uploadFile.fileError":"filePath应为File对象"},"zh-Hant":{"uniCloud.init.paramRequired":"缺少参数:{param}","uniCloud.uploadFile.fileError":"filePath应为File对象"},en:X,fr:{"uniCloud.init.paramRequired":"{param} required","uniCloud.uploadFile.fileError":"filePath should be instance of File"},es:{"uniCloud.init.paramRequired":"{param} required","uniCloud.uploadFile.fileError":"filePath should be instance of File"},ja:X},"zh-Hans");var Z=class{constructor(e){["spaceId","clientSecret"].forEach((t=>{if(!Object.prototype.hasOwnProperty.call(e,t))throw new Error(G("uniCloud.init.paramRequired",{param:t}))})),this.config=Object.assign({},{endpoint:"https://api.bspapp.com"},e),this.config.provider="aliyun",this.config.requestUrl=this.config.endpoint+"/client",this.config.envType=this.config.envType||"public",this.config.accessTokenKey="access_token_"+this.config.spaceId,this.adapter=Q,this._getAccessTokenPromise=null,this._getAccessTokenPromiseStatus=null}get hasAccessToken(){return!!this.accessToken}setAccessToken(e){this.accessToken=e}requestWrapped(e){return Y.wrappedRequest(e,this.adapter.request)}requestAuth(e){return this.requestWrapped(e)}request(e,t){return Promise.resolve().then((()=>this.hasAccessToken?t?this.requestWrapped(e):this.requestWrapped(e).catch((t=>new Promise(((e,n)=>{!t||"GATEWAY_INVALID_TOKEN"!==t.code&&"InvalidParameter.InvalidToken"!==t.code?n(t):e()})).then((()=>this.getAccessToken())).then((()=>{const t=this.rebuildRequest(e);return this.request(t,!0)})))):this.getAccessToken().then((()=>{const t=this.rebuildRequest(e);return this.request(t,!0)}))))}rebuildRequest(e){const t=Object.assign({},e);return t.data.token=this.accessToken,t.header["x-basement-token"]=this.accessToken,t.header["x-serverless-sign"]=Y.sign(t.data,this.config.clientSecret),t}setupRequest(e,t){const n=Object.assign({},e,{spaceId:this.config.spaceId,timestamp:Date.now()}),s={"Content-Type":"application/json"};return"auth"!==t&&(n.token=this.accessToken,s["x-basement-token"]=this.accessToken),s["x-serverless-sign"]=Y.sign(n,this.config.clientSecret),{url:this.config.requestUrl,method:"POST",data:n,dataType:"json",header:s}}getAccessToken(){if("pending"===this._getAccessTokenPromiseStatus)return this._getAccessTokenPromise;this._getAccessTokenPromiseStatus="pending";return this._getAccessTokenPromise=this.requestAuth(this.setupRequest({method:"serverless.auth.user.anonymousAuthorize",params:"{}"},"auth")).then((e=>new Promise(((t,n)=>{e.result&&e.result.accessToken?(this.setAccessToken(e.result.accessToken),this._getAccessTokenPromiseStatus="fulfilled",t(this.accessToken)):(this._getAccessTokenPromiseStatus="rejected",n(new H({code:"AUTH_FAILED",message:"获取accessToken失败"})))}))),(e=>(this._getAccessTokenPromiseStatus="rejected",Promise.reject(e)))),this._getAccessTokenPromise}authorize(){this.getAccessToken()}callFunction(e){const t={method:"serverless.function.runtime.invoke",params:JSON.stringify({functionTarget:e.name,functionArgs:e.data||{}})};return this.request(this.setupRequest(t))}getOSSUploadOptionsFromPath(e){const t={method:"serverless.file.resource.generateProximalSign",params:JSON.stringify(e)};return this.request(this.setupRequest(t))}uploadFileToOSS({url:e,formData:t,name:n,filePath:s,fileType:r,onUploadProgress:i}){return new Promise(((o,a)=>{const c=this.adapter.uploadFile({url:e,formData:t,name:n,filePath:s,fileType:r,header:{"X-OSS-server-side-encrpytion":"AES256"},success(e){e&&e.statusCode<400?o(e):a(new H({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){a(new H({code:e.code||"UPLOAD_FAILED",message:e.message||e.errMsg||"文件上传失败"}))}});"function"==typeof i&&c&&"function"==typeof c.onProgressUpdate&&c.onProgressUpdate((e=>{i({loaded:e.totalBytesSent,total:e.totalBytesExpectedToSend})}))}))}reportOSSUpload(e){const t={method:"serverless.file.resource.report",params:JSON.stringify(e)};return this.request(this.setupRequest(t))}uploadFile({filePath:e,cloudPath:t,fileType:n="image",onUploadProgress:s,config:r}){if("string"!==h(t))throw new H({code:"INVALID_PARAM",message:"cloudPath必须为字符串类型"});if(!(t=t.trim()))throw new H({code:"CLOUDPATH_REQUIRED",message:"cloudPath不可为空"});if(/:\/\//.test(t))throw new H({code:"INVALID_PARAM",message:"cloudPath不合法"});const i=r&&r.envType||this.config.envType;let o,a;return this.getOSSUploadOptionsFromPath({env:i,filename:t}).then((t=>{const r=t.result;o=r.id,a="https://"+r.cdnDomain+"/"+r.ossPath;const i={url:"https://"+r.host,formData:{"Cache-Control":"max-age=2592000","Content-Disposition":"attachment",OSSAccessKeyId:r.accessKeyId,Signature:r.signature,host:r.host,id:o,key:r.ossPath,policy:r.policy,success_action_status:200},fileName:"file",name:"file",filePath:e,fileType:n};return this.uploadFileToOSS(Object.assign({},i,{onUploadProgress:s}))})).then((()=>this.reportOSSUpload({id:o}))).then((t=>new Promise(((n,s)=>{t.success?n({success:!0,filePath:e,fileID:a}):s(new H({code:"UPLOAD_FAILED",message:"文件上传失败"}))}))))}deleteFile({fileList:e}){const t={method:"serverless.file.resource.delete",params:JSON.stringify({id:e[0]})};return this.request(this.setupRequest(t))}getTempFileURL({fileList:e}={}){return new Promise(((t,n)=>{Array.isArray(e)&&0!==e.length||n(new H({code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"})),t({fileList:e.map((e=>({fileID:e,tempFileURL:e})))})}))}};var ee={init(e){const t=new Z(e),n={signInAnonymously:function(){return t.authorize()},getLoginState:function(){return Promise.resolve(!1)}};return t.auth=function(){return n},t.customAuth=t.auth,t}};const te="undefined"!=typeof location&&"http:"===location.protocol?"http:":"https:";var ne;!function(e){e.local="local",e.none="none",e.session="session"}(ne||(ne={}));var se=function(){};const re=()=>{let e;if(!Promise){e=()=>{},e.promise={};const t=()=>{throw new H({message:'Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.'})};return Object.defineProperty(e.promise,"then",{get:t}),Object.defineProperty(e.promise,"catch",{get:t}),e}const t=new Promise(((t,n)=>{e=(e,s)=>e?n(e):t(s)}));return e.promise=t,e};function ie(e){return void 0===e}function oe(e){return"[object Null]"===Object.prototype.toString.call(e)}var ae;function ce(e){const t=(n=e,"[object Array]"===Object.prototype.toString.call(n)?e:[e]);var n;for(const e of t){const{isMatch:t,genAdapter:n,runtime:s}=e;if(t())return{adapter:n(),runtime:s}}}!function(e){e.WEB="web",e.WX_MP="wx_mp"}(ae||(ae={}));const ue={adapter:null,runtime:void 0},he=["anonymousUuidKey"];class le extends se{constructor(){super(),ue.adapter.root.tcbObject||(ue.adapter.root.tcbObject={})}setItem(e,t){ue.adapter.root.tcbObject[e]=t}getItem(e){return ue.adapter.root.tcbObject[e]}removeItem(e){delete ue.adapter.root.tcbObject[e]}clear(){delete ue.adapter.root.tcbObject}}function de(e,t){switch(e){case"local":return t.localStorage||new le;case"none":return new le;default:return t.sessionStorage||new le}}class fe{constructor(e){if(!this._storage){this._persistence=ue.adapter.primaryStorage||e.persistence,this._storage=de(this._persistence,ue.adapter);const t=`access_token_${e.env}`,n=`access_token_expire_${e.env}`,s=`refresh_token_${e.env}`,r=`anonymous_uuid_${e.env}`,i=`login_type_${e.env}`,o=`user_info_${e.env}`;this.keys={accessTokenKey:t,accessTokenExpireKey:n,refreshTokenKey:s,anonymousUuidKey:r,loginTypeKey:i,userInfoKey:o}}}updatePersistence(e){if(e===this._persistence)return;const t="local"===this._persistence;this._persistence=e;const n=de(e,ue.adapter);for(const e in this.keys){const s=this.keys[e];if(t&&he.includes(e))continue;const r=this._storage.getItem(s);ie(r)||oe(r)||(n.setItem(s,r),this._storage.removeItem(s))}this._storage=n}setStore(e,t,n){if(!this._storage)return;const s={version:n||"localCachev1",content:t},r=JSON.stringify(s);try{this._storage.setItem(e,r)}catch(e){throw e}}getStore(e,t){try{if(!this._storage)return}catch(e){return""}t=t||"localCachev1";const n=this._storage.getItem(e);if(!n)return"";if(n.indexOf(t)>=0){return JSON.parse(n).content}return""}removeStore(e){this._storage.removeItem(e)}}const pe={},ge={};function me(e){return pe[e]}class ye{constructor(e,t){this.data=t||null,this.name=e}}class _e extends ye{constructor(e,t){super("error",{error:e,data:t}),this.error=e}}const we=new class{constructor(){this._listeners={}}on(e,t){return function(e,t,n){n[e]=n[e]||[],n[e].push(t)}(e,t,this._listeners),this}off(e,t){return function(e,t,n){if(n&&n[e]){const s=n[e].indexOf(t);-1!==s&&n[e].splice(s,1)}}(e,t,this._listeners),this}fire(e,t){if(e instanceof _e)return console.error(e.error),this;const n="string"==typeof e?new ye(e,t||{}):e;const s=n.name;if(this._listens(s)){n.target=this;const e=this._listeners[s]?[...this._listeners[s]]:[];for(const t of e)t.call(this,n)}return this}_listens(e){return this._listeners[e]&&this._listeners[e].length>0}};function ve(e,t){we.on(e,t)}function Se(e,t={}){we.fire(e,t)}function ke(e,t){we.off(e,t)}const Te="loginStateChanged",Ie="loginStateExpire",be="loginTypeChanged",Ae="anonymousConverted",Pe="refreshAccessToken";var Ce;!function(e){e.ANONYMOUS="ANONYMOUS",e.WECHAT="WECHAT",e.WECHAT_PUBLIC="WECHAT-PUBLIC",e.WECHAT_OPEN="WECHAT-OPEN",e.CUSTOM="CUSTOM",e.EMAIL="EMAIL",e.USERNAME="USERNAME",e.NULL="NULL"}(Ce||(Ce={}));const Ee=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"],Oe={"X-SDK-Version":"1.3.5"};function Re(e,t,n){const s=e[t];e[t]=function(t){const r={},i={};n.forEach((n=>{const{data:s,headers:o}=n.call(e,t);Object.assign(r,s),Object.assign(i,o)}));const o=t.data;return o&&(()=>{var e;if(e=o,"[object FormData]"!==Object.prototype.toString.call(e))t.data={...o,...r};else for(const e in r)o.append(e,r[e])})(),t.headers={...t.headers||{},...i},s.call(e,t)}}function Ue(){const e=Math.random().toString(16).slice(2);return{data:{seqId:e},headers:{...Oe,"x-seqid":e}}}class xe{constructor(e={}){var t;this.config=e,this._reqClass=new ue.adapter.reqClass({timeout:this.config.timeout,timeoutMsg:`请求在${this.config.timeout/1e3}s内未完成,已中断`,restrictedMethods:["post"]}),this._cache=me(this.config.env),this._localCache=(t=this.config.env,ge[t]),Re(this._reqClass,"post",[Ue]),Re(this._reqClass,"upload",[Ue]),Re(this._reqClass,"download",[Ue])}async post(e){return await this._reqClass.post(e)}async upload(e){return await this._reqClass.upload(e)}async download(e){return await this._reqClass.download(e)}async refreshAccessToken(){let e,t;this._refreshAccessTokenPromise||(this._refreshAccessTokenPromise=this._refreshAccessToken());try{e=await this._refreshAccessTokenPromise}catch(e){t=e}if(this._refreshAccessTokenPromise=null,this._shouldRefreshAccessTokenHook=null,t)throw t;return e}async _refreshAccessToken(){const{accessTokenKey:e,accessTokenExpireKey:t,refreshTokenKey:n,loginTypeKey:s,anonymousUuidKey:r}=this._cache.keys;this._cache.removeStore(e),this._cache.removeStore(t);let i=this._cache.getStore(n);if(!i)throw new H({message:"未登录CloudBase"});const o={refresh_token:i},a=await this.request("auth.fetchAccessTokenWithRefreshToken",o);if(a.data.code){const{code:e}=a.data;if("SIGN_PARAM_INVALID"===e||"REFRESH_TOKEN_EXPIRED"===e||"INVALID_REFRESH_TOKEN"===e){if(this._cache.getStore(s)===Ce.ANONYMOUS&&"INVALID_REFRESH_TOKEN"===e){const e=this._cache.getStore(r),t=this._cache.getStore(n),s=await this.send("auth.signInAnonymously",{anonymous_uuid:e,refresh_token:t});return this.setRefreshToken(s.refresh_token),this._refreshAccessToken()}Se(Ie),this._cache.removeStore(n)}throw new H({code:a.data.code,message:`刷新access token失败:${a.data.code}`})}if(a.data.access_token)return Se(Pe),this._cache.setStore(e,a.data.access_token),this._cache.setStore(t,a.data.access_token_expire+Date.now()),{accessToken:a.data.access_token,accessTokenExpire:a.data.access_token_expire};a.data.refresh_token&&(this._cache.removeStore(n),this._cache.setStore(n,a.data.refresh_token),this._refreshAccessToken())}async getAccessToken(){const{accessTokenKey:e,accessTokenExpireKey:t,refreshTokenKey:n}=this._cache.keys;if(!this._cache.getStore(n))throw new H({message:"refresh token不存在,登录状态异常"});let s=this._cache.getStore(e),r=this._cache.getStore(t),i=!0;return this._shouldRefreshAccessTokenHook&&!await this._shouldRefreshAccessTokenHook(s,r)&&(i=!1),(!s||!r||r{e.wxOpenId&&e.wxPublicId&&(t=!0)})),{users:n,hasPrimaryUid:t}}setPrimaryUid(e){return this._request.send("auth.setPrimaryUid",{uid:e})}unlink(e){return this._request.send("auth.unlink",{platform:e})}async update(e){const{nickName:t,gender:n,avatarUrl:s,province:r,country:i,city:o}=e,{data:a}=await this._request.send("auth.updateUserInfo",{nickName:t,gender:n,avatarUrl:s,province:r,country:i,city:o});this.setLocalUserInfo(a)}async refresh(){const{data:e}=await this._request.send("auth.getUserInfo",{});return this.setLocalUserInfo(e),e}setUserInfo(){const{userInfoKey:e}=this._cache.keys,t=this._cache.getStore(e);["uid","loginType","openid","wxOpenId","wxPublicId","unionId","qqMiniOpenId","email","hasPassword","customUserId","nickName","gender","avatarUrl"].forEach((e=>{this[e]=t[e]})),this.location={country:t.country,province:t.province,city:t.city}}setLocalUserInfo(e){const{userInfoKey:t}=this._cache.keys;this._cache.setStore(t,e),this.setUserInfo()}}class Fe{constructor(e){if(!e)throw new H({code:"PARAM_ERROR",message:"envId is not defined"});this._cache=me(e);const{refreshTokenKey:t,accessTokenKey:n,accessTokenExpireKey:s}=this._cache.keys,r=this._cache.getStore(t),i=this._cache.getStore(n),o=this._cache.getStore(s);this.credential={refreshToken:r,accessToken:i,accessTokenExpire:o},this.user=new qe(e)}get isAnonymousAuth(){return this.loginType===Ce.ANONYMOUS}get isCustomAuth(){return this.loginType===Ce.CUSTOM}get isWeixinAuth(){return this.loginType===Ce.WECHAT||this.loginType===Ce.WECHAT_OPEN||this.loginType===Ce.WECHAT_PUBLIC}get loginType(){return this._cache.getStore(this._cache.keys.loginTypeKey)}}class Ke extends Ne{async signIn(){this._cache.updatePersistence("local");const{anonymousUuidKey:e,refreshTokenKey:t}=this._cache.keys,n=this._cache.getStore(e)||void 0,s=this._cache.getStore(t)||void 0,r=await this._request.send("auth.signInAnonymously",{anonymous_uuid:n,refresh_token:s});if(r.uuid&&r.refresh_token){this._setAnonymousUUID(r.uuid),this.setRefreshToken(r.refresh_token),await this._request.refreshAccessToken(),Se(Te),Se(be,{env:this.config.env,loginType:Ce.ANONYMOUS,persistence:"local"});const e=new Fe(this.config.env);return await e.user.refresh(),e}throw new H({message:"匿名登录失败"})}async linkAndRetrieveDataWithTicket(e){const{anonymousUuidKey:t,refreshTokenKey:n}=this._cache.keys,s=this._cache.getStore(t),r=this._cache.getStore(n),i=await this._request.send("auth.linkAndRetrieveDataWithTicket",{anonymous_uuid:s,refresh_token:r,ticket:e});if(i.refresh_token)return this._clearAnonymousUUID(),this.setRefreshToken(i.refresh_token),await this._request.refreshAccessToken(),Se(Ae,{env:this.config.env}),Se(be,{loginType:Ce.CUSTOM,persistence:"local"}),{credential:{refreshToken:i.refresh_token}};throw new H({message:"匿名转化失败"})}_setAnonymousUUID(e){const{anonymousUuidKey:t,loginTypeKey:n}=this._cache.keys;this._cache.removeStore(t),this._cache.setStore(t,e),this._cache.setStore(n,Ce.ANONYMOUS)}_clearAnonymousUUID(){this._cache.removeStore(this._cache.keys.anonymousUuidKey)}}class Me extends Ne{async signIn(e){if("string"!=typeof e)throw new H({param:"PARAM_ERROR",message:"ticket must be a string"});const{refreshTokenKey:t}=this._cache.keys,n=await this._request.send("auth.signInWithTicket",{ticket:e,refresh_token:this._cache.getStore(t)||""});if(n.refresh_token)return this.setRefreshToken(n.refresh_token),await this._request.refreshAccessToken(),Se(Te),Se(be,{env:this.config.env,loginType:Ce.CUSTOM,persistence:this.config.persistence}),await this.refreshUserInfo(),new Fe(this.config.env);throw new H({message:"自定义登录失败"})}}class je extends Ne{async signIn(e,t){if("string"!=typeof e)throw new H({code:"PARAM_ERROR",message:"email must be a string"});const{refreshTokenKey:n}=this._cache.keys,s=await this._request.send("auth.signIn",{loginType:"EMAIL",email:e,password:t,refresh_token:this._cache.getStore(n)||""}),{refresh_token:r,access_token:i,access_token_expire:o}=s;if(r)return this.setRefreshToken(r),i&&o?this.setAccessToken(i,o):await this._request.refreshAccessToken(),await this.refreshUserInfo(),Se(Te),Se(be,{env:this.config.env,loginType:Ce.EMAIL,persistence:this.config.persistence}),new Fe(this.config.env);throw s.code?new H({code:s.code,message:`邮箱登录失败: ${s.message}`}):new H({message:"邮箱登录失败"})}async activate(e){return this._request.send("auth.activateEndUserMail",{token:e})}async resetPasswordWithToken(e,t){return this._request.send("auth.resetPasswordWithToken",{token:e,newPassword:t})}}class $e extends Ne{async signIn(e,t){if("string"!=typeof e)throw new H({code:"PARAM_ERROR",message:"username must be a string"});"string"!=typeof t&&(t="",console.warn("password is empty"));const{refreshTokenKey:n}=this._cache.keys,s=await this._request.send("auth.signIn",{loginType:Ce.USERNAME,username:e,password:t,refresh_token:this._cache.getStore(n)||""}),{refresh_token:r,access_token_expire:i,access_token:o}=s;if(r)return this.setRefreshToken(r),o&&i?this.setAccessToken(o,i):await this._request.refreshAccessToken(),await this.refreshUserInfo(),Se(Te),Se(be,{env:this.config.env,loginType:Ce.USERNAME,persistence:this.config.persistence}),new Fe(this.config.env);throw s.code?new H({code:s.code,message:`用户名密码登录失败: ${s.message}`}):new H({message:"用户名密码登录失败"})}}class Be{constructor(e){this.config=e,this._cache=me(e.env),this._request=De(e.env),this._onAnonymousConverted=this._onAnonymousConverted.bind(this),this._onLoginTypeChanged=this._onLoginTypeChanged.bind(this),ve(be,this._onLoginTypeChanged)}get currentUser(){const e=this.hasLoginState();return e&&e.user||null}get loginType(){return this._cache.getStore(this._cache.keys.loginTypeKey)}anonymousAuthProvider(){return new Ke(this.config)}customAuthProvider(){return new Me(this.config)}emailAuthProvider(){return new je(this.config)}usernameAuthProvider(){return new $e(this.config)}async signInAnonymously(){return new Ke(this.config).signIn()}async signInWithEmailAndPassword(e,t){return new je(this.config).signIn(e,t)}signInWithUsernameAndPassword(e,t){return new $e(this.config).signIn(e,t)}async linkAndRetrieveDataWithTicket(e){this._anonymousAuthProvider||(this._anonymousAuthProvider=new Ke(this.config)),ve(Ae,this._onAnonymousConverted);return await this._anonymousAuthProvider.linkAndRetrieveDataWithTicket(e)}async signOut(){if(this.loginType===Ce.ANONYMOUS)throw new H({message:"匿名用户不支持登出操作"});const{refreshTokenKey:e,accessTokenKey:t,accessTokenExpireKey:n}=this._cache.keys,s=this._cache.getStore(e);if(!s)return;const r=await this._request.send("auth.logout",{refresh_token:s});return this._cache.removeStore(e),this._cache.removeStore(t),this._cache.removeStore(n),Se(Te),Se(be,{env:this.config.env,loginType:Ce.NULL,persistence:this.config.persistence}),r}async signUpWithEmailAndPassword(e,t){return this._request.send("auth.signUpWithEmailAndPassword",{email:e,password:t})}async sendPasswordResetEmail(e){return this._request.send("auth.sendPasswordResetEmail",{email:e})}onLoginStateChanged(e){ve(Te,(()=>{const t=this.hasLoginState();e.call(this,t)}));const t=this.hasLoginState();e.call(this,t)}onLoginStateExpired(e){ve(Ie,e.bind(this))}onAccessTokenRefreshed(e){ve(Pe,e.bind(this))}onAnonymousConverted(e){ve(Ae,e.bind(this))}onLoginTypeChanged(e){ve(be,(()=>{const t=this.hasLoginState();e.call(this,t)}))}async getAccessToken(){return{accessToken:(await this._request.getAccessToken()).accessToken,env:this.config.env}}hasLoginState(){const{refreshTokenKey:e}=this._cache.keys;return this._cache.getStore(e)?new Fe(this.config.env):null}async isUsernameRegistered(e){if("string"!=typeof e)throw new H({code:"PARAM_ERROR",message:"username must be a string"});const{data:t}=await this._request.send("auth.isUsernameRegistered",{username:e});return t&&t.isRegistered}getLoginState(){return Promise.resolve(this.hasLoginState())}async signInWithTicket(e){return new Me(this.config).signIn(e)}shouldRefreshAccessToken(e){this._request._shouldRefreshAccessTokenHook=e.bind(this)}getUserInfo(){return this._request.send("auth.getUserInfo",{}).then((e=>e.code?e:{...e.data,requestId:e.seqId}))}getAuthHeader(){const{refreshTokenKey:e,accessTokenKey:t}=this._cache.keys,n=this._cache.getStore(e);return{"x-cloudbase-credentials":this._cache.getStore(t)+"/@@/"+n}}_onAnonymousConverted(e){const{env:t}=e.data;t===this.config.env&&this._cache.updatePersistence(this.config.persistence)}_onLoginTypeChanged(e){const{loginType:t,persistence:n,env:s}=e.data;s===this.config.env&&(this._cache.updatePersistence(n),this._cache.setStore(this._cache.keys.loginTypeKey,t))}}const ze=function(e,t){t=t||re();const n=De(this.config.env),{cloudPath:s,filePath:r,onUploadProgress:i,fileType:o="image"}=e;return n.send("storage.getUploadMetadata",{path:s}).then((e=>{const{data:{url:a,authorization:c,token:u,fileId:h,cosFileId:l},requestId:d}=e,f={key:s,signature:c,"x-cos-meta-fileid":l,success_action_status:"201","x-cos-security-token":u};n.upload({url:a,data:f,file:r,name:s,fileType:o,onUploadProgress:i}).then((e=>{201===e.statusCode?t(null,{fileID:h,requestId:d}):t(new H({code:"STORAGE_REQUEST_FAIL",message:`STORAGE_REQUEST_FAIL: ${e.data}`}))})).catch((e=>{t(e)}))})).catch((e=>{t(e)})),t.promise},We=function(e,t){t=t||re();const n=De(this.config.env),{cloudPath:s}=e;return n.send("storage.getUploadMetadata",{path:s}).then((e=>{t(null,e)})).catch((e=>{t(e)})),t.promise},He=function({fileList:e},t){if(t=t||re(),!e||!Array.isArray(e))return{code:"INVALID_PARAM",message:"fileList必须是非空的数组"};for(let t of e)if(!t||"string"!=typeof t)return{code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"};const n={fileid_list:e};return De(this.config.env).send("storage.batchDeleteFile",n).then((e=>{e.code?t(null,e):t(null,{fileList:e.data.delete_list,requestId:e.requestId})})).catch((e=>{t(e)})),t.promise},Je=function({fileList:e},t){t=t||re(),e&&Array.isArray(e)||t(null,{code:"INVALID_PARAM",message:"fileList必须是非空的数组"});let n=[];for(let s of e)"object"==typeof s?(s.hasOwnProperty("fileID")&&s.hasOwnProperty("maxAge")||t(null,{code:"INVALID_PARAM",message:"fileList的元素必须是包含fileID和maxAge的对象"}),n.push({fileid:s.fileID,max_age:s.maxAge})):"string"==typeof s?n.push({fileid:s}):t(null,{code:"INVALID_PARAM",message:"fileList的元素必须是字符串"});const s={file_list:n};return De(this.config.env).send("storage.batchGetDownloadUrl",s).then((e=>{e.code?t(null,e):t(null,{fileList:e.data.download_list,requestId:e.requestId})})).catch((e=>{t(e)})),t.promise},Ve=async function({fileID:e},t){const n=(await Je.call(this,{fileList:[{fileID:e,maxAge:600}]})).fileList[0];if("SUCCESS"!==n.code)return t?t(n):new Promise((e=>{e(n)}));const s=De(this.config.env);let r=n.download_url;if(r=encodeURI(r),!t)return s.download({url:r});t(await s.download({url:r}))},Ye=function({name:e,data:t,query:n,parse:s,search:r},i){const o=i||re();let a;try{a=t?JSON.stringify(t):""}catch(e){return Promise.reject(e)}if(!e)return Promise.reject(new H({code:"PARAM_ERROR",message:"函数名不能为空"}));const c={inQuery:n,parse:s,search:r,function_name:e,request_data:a};return De(this.config.env).send("functions.invokeFunction",c).then((e=>{if(e.code)o(null,e);else{let t=e.data.response_data;if(s)o(null,{result:t,requestId:e.requestId});else try{t=JSON.parse(e.data.response_data),o(null,{result:t,requestId:e.requestId})}catch(e){o(new H({message:"response data must be json"}))}}return o.promise})).catch((e=>{o(e)})),o.promise},Qe={timeout:15e3,persistence:"session"},Xe={};class Ge{constructor(e){this.config=e||this.config,this.authObj=void 0}init(e){switch(ue.adapter||(this.requestClient=new ue.adapter.reqClass({timeout:e.timeout||5e3,timeoutMsg:`请求在${(e.timeout||5e3)/1e3}s内未完成,已中断`})),this.config={...Qe,...e},!0){case this.config.timeout>6e5:console.warn("timeout大于可配置上限[10分钟],已重置为上限数值"),this.config.timeout=6e5;break;case this.config.timeout<100:console.warn("timeout小于可配置下限[100ms],已重置为下限数值"),this.config.timeout=100}return new Ge(this.config)}auth({persistence:e}={}){if(this.authObj)return this.authObj;const t=e||ue.adapter.primaryStorage||Qe.persistence;var n;return t!==this.config.persistence&&(this.config.persistence=t),function(e){const{env:t}=e;pe[t]=new fe(e),ge[t]=new fe({...e,persistence:"local"})}(this.config),n=this.config,Le[n.env]=new xe(n),this.authObj=new Be(this.config),this.authObj}on(e,t){return ve.apply(this,[e,t])}off(e,t){return ke.apply(this,[e,t])}callFunction(e,t){return Ye.apply(this,[e,t])}deleteFile(e,t){return He.apply(this,[e,t])}getTempFileURL(e,t){return Je.apply(this,[e,t])}downloadFile(e,t){return Ve.apply(this,[e,t])}uploadFile(e,t){return ze.apply(this,[e,t])}getUploadMetadata(e,t){return We.apply(this,[e,t])}registerExtension(e){Xe[e.name]=e}async invokeExtension(e,t){const n=Xe[e];if(!n)throw new H({message:`扩展${e} 必须先注册`});return await n.invoke(t,this)}useAdapters(e){const{adapter:t,runtime:n}=ce(e)||{};t&&(ue.adapter=t),n&&(ue.runtime=n)}}var Ze=new Ge;function et(e,t,n){void 0===n&&(n={});var s=/\?/.test(t),r="";for(var i in n)""===r?!s&&(t+="?"):r+="&",r+=i+"="+encodeURIComponent(n[i]);return/^http(s)?:\/\//.test(t+=r)?t:""+e+t}class tt{post(e){const{url:t,data:n,headers:s}=e;return new Promise(((e,r)=>{Q.request({url:et("https:",t),data:n,method:"POST",header:s,success(t){e(t)},fail(e){r(e)}})}))}upload(e){return new Promise(((t,n)=>{const{url:s,file:r,data:i,headers:o,fileType:a}=e,c=Q.uploadFile({url:et("https:",s),name:"file",formData:Object.assign({},i),filePath:r,fileType:a,header:o,success(e){const n={statusCode:e.statusCode,data:e.data||{}};200===e.statusCode&&i.success_action_status&&(n.statusCode=parseInt(i.success_action_status,10)),t(n)},fail(e){n(new Error(e.errMsg||"uploadFile:fail"))}});"function"==typeof e.onUploadProgress&&c&&"function"==typeof c.onProgressUpdate&&c.onProgressUpdate((t=>{e.onUploadProgress({loaded:t.totalBytesSent,total:t.totalBytesExpectedToSend})}))}))}}const nt={setItem(e,t){Q.setStorageSync(e,t)},getItem:e=>Q.getStorageSync(e),removeItem(e){Q.removeStorageSync(e)},clear(){Q.clearStorageSync()}};var st={genAdapter:function(){return{root:{},reqClass:tt,localStorage:nt,primaryStorage:"local"}},isMatch:function(){return!0},runtime:"uni_app"};Ze.useAdapters(st);const rt=Ze,it=rt.init;rt.init=function(e){e.env=e.spaceId;const t=it.call(this,e);t.config.provider="tencent",t.config.spaceId=e.spaceId;const n=t.auth;return t.auth=function(e){const t=n.call(this,e);return["linkAndRetrieveDataWithTicket","signInAnonymously","signOut","getAccessToken","getLoginState","signInWithTicket","getUserInfo"].forEach((e=>{t[e]=W(t[e]).bind(t)})),t},t.customAuth=t.auth,t};var ot=rt;function at(){return{token:Q.getStorageSync("uni_id_token")||Q.getStorageSync("uniIdToken"),tokenExpired:Q.getStorageSync("uni_id_token_expired")}}function ct({token:e,tokenExpired:t}={}){e&&Q.setStorageSync("uni_id_token",e),t&&Q.setStorageSync("uni_id_token_expired",t)}function ut(){if(!f||"web"!==m)return;uni.getStorageSync("__LAST_DCLOUD_APPID")!==v&&(uni.setStorageSync("__LAST_DCLOUD_APPID",v),console.warn("检测到当前项目与上次运行到此端口的项目不一致,自动清理uni-id保存的token信息(仅开发调试时生效)"),Q.removeStorageSync("uni_id_token"),Q.removeStorageSync("uniIdToken"),Q.removeStorageSync("uni_id_token_expired"))}var ht=class extends Z{getAccessToken(){return new Promise(((e,t)=>{const n="Anonymous_Access_token";this.setAccessToken(n),e(n)}))}setupRequest(e,t){const n=Object.assign({},e,{spaceId:this.config.spaceId,timestamp:Date.now()}),s={"Content-Type":"application/json"};"auth"!==t&&(n.token=this.accessToken,s["x-basement-token"]=this.accessToken),s["x-serverless-sign"]=Y.sign(n,this.config.clientSecret);const r=V();s["x-client-info"]=encodeURIComponent(JSON.stringify(r));const{token:i}=at();return s["x-client-token"]=i,{url:this.config.requestUrl,method:"POST",data:n,dataType:"json",header:JSON.parse(JSON.stringify(s))}}uploadFileToOSS({url:e,formData:t,name:n,filePath:s,fileType:r,onUploadProgress:i}){return new Promise(((o,a)=>{const c=this.adapter.uploadFile({url:e,formData:t,name:n,filePath:s,fileType:r,success(e){e&&e.statusCode<400?o(e):a(new H({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){a(new H({code:e.code||"UPLOAD_FAILED",message:e.message||e.errMsg||"文件上传失败"}))}});"function"==typeof i&&c&&"function"==typeof c.onProgressUpdate&&c.onProgressUpdate((e=>{i({loaded:e.totalBytesSent,total:e.totalBytesExpectedToSend})}))}))}uploadFile({filePath:e,cloudPath:t,fileType:n="image",onUploadProgress:s}){if(!t)throw new H({code:"CLOUDPATH_REQUIRED",message:"cloudPath不可为空"});let r;return this.getOSSUploadOptionsFromPath({cloudPath:t}).then((t=>{const{url:i,formData:o,name:a}=t.result;r=t.result.fileUrl;const c={url:i,formData:o,name:a,filePath:e,fileType:n};return this.uploadFileToOSS(Object.assign({},c,{onUploadProgress:s}))})).then((()=>this.reportOSSUpload({cloudPath:t}))).then((t=>new Promise(((n,s)=>{t.success?n({success:!0,filePath:e,fileID:r}):s(new H({code:"UPLOAD_FAILED",message:"文件上传失败"}))}))))}deleteFile({fileList:e}){const t={method:"serverless.file.resource.delete",params:JSON.stringify({fileList:e})};return this.request(this.setupRequest(t))}getTempFileURL({fileList:e}={}){const t={method:"serverless.file.resource.getTempFileURL",params:JSON.stringify({fileList:e})};return this.request(this.setupRequest(t))}};var lt={init(e){const t=new ht(e),n={signInAnonymously:function(){return t.authorize()},getLoginState:function(){return Promise.resolve(!1)}};return t.auth=function(){return n},t.customAuth=t.auth,t}};function dt({data:e}){let t;t=V();const n=JSON.parse(JSON.stringify(e||{}));if(Object.assign(n,{clientInfo:t}),!n.uniIdToken){const{token:e}=at();e&&(n.uniIdToken=e)}return n}function ft({name:e,data:t}={}){const{localAddress:n,localPort:s}=this.__dev__,r={aliyun:"aliyun",tencent:"tcb"}[this.config.provider],i=this.config.spaceId,o=`http://${n}:${s}/system/check-function`,a=`http://${n}:${s}/cloudfunctions/${e}`;return new Promise(((t,n)=>{Q.request({method:"POST",url:o,data:{name:e,platform:m,provider:r,spaceId:i},timeout:3e3,success(e){t(e)},fail(){t({data:{code:"NETWORK_ERROR",message:"连接本地调试服务失败,请检查客户端是否和主机在同一局域网下,自动切换为已部署的云函数。"}})}})})).then((({data:e}={})=>{const{code:t,message:n}=e||{};return{code:0===t?0:t||"SYS_ERR",message:n||"SYS_ERR"}})).then((({code:n,message:s})=>{if(0!==n){switch(n){case"MODULE_ENCRYPTED":console.error(`此云函数(${e})依赖加密公共模块不可本地调试,自动切换为云端已部署的云函数`);break;case"FUNCTION_ENCRYPTED":console.error(`此云函数(${e})已加密不可本地调试,自动切换为云端已部署的云函数`);break;case"ACTION_ENCRYPTED":console.error(s||"需要访问加密的uni-clientDB-action,自动切换为云端环境");break;case"NETWORK_ERROR":{const e="连接本地调试服务失败,请检查客户端是否和主机在同一局域网下";throw console.error(e),new Error(e)}case"SWITCH_TO_CLOUD":break;default:{const e=`检测本地调试服务出现错误:${s},请检查网络环境或重启客户端再试`;throw console.error(e),new Error(e)}}return this._callCloudFunction({name:e,data:t})}return new Promise(((e,n)=>{const s=dt.call(this,{data:t});Q.request({method:"POST",url:a,data:{provider:r,platform:m,param:s},success:({statusCode:t,data:s}={})=>!t||t>=400?n(new H({code:s.code||"SYS_ERR",message:s.message||"request:fail"})):e({result:s}),fail(e){n(new H({code:e.code||e.errCode||"SYS_ERR",message:e.message||e.errMsg||"request:fail"}))}})}))}))}const pt=[{rule:/fc_function_not_found|FUNCTION_NOT_FOUND/,content:",云函数[{functionName}]在云端不存在,请检查此云函数名称是否正确以及该云函数是否已上传到服务空间",mode:"append"}];var gt=/[\\^$.*+?()[\]{}|]/g,mt=RegExp(gt.source);function yt(e,t,n){return e.replace(new RegExp((s=t)&&mt.test(s)?s.replace(gt,"\\$&"):s,"g"),n);var s}const _t="none",wt="request",vt="response",St="both";class kt{constructor({secretType:e,uniCloudIns:t}={}){this.secretType=e||_t,this.uniCloudIns=t;const{provider:n,spaceId:s}=this.uniCloudIns.config;this.provider=n,this.spaceId=s}getSystemInfo(){return this._systemInfo||(this._systemInfo=uni.getSystemInfoSync()),this._systemInfo}get appId(){return this.getSystemInfo().appId}get deviceId(){return this.getSystemInfo().deviceId}async encryptData(e){return this.secretType===_t||this.secretType===_t?e:this.platformEncryptData(e)}async decryptResult(e){if(this.secretType===_t)return e;const{content:t}=e;return t?this.secretType===wt?t:this.platformDecryptResult(e):e}wrapCallFunction(e){const t=this;return async function({name:n,data:s}={}){await t.prepare();const r=await t.encryptData(s),i=await e({name:n,data:r});return i.result=await t.decryptResult(i.result),i}}} +/*! MIT License. Copyright 2015-2018 Richard Moore . See LICENSE.txt. */function Tt(e){return parseInt(e)===e}function It(e){if(!Tt(e.length))return!1;for(var t=0;t255)return!1;return!0}function bt(e,t){if(e.buffer&&"Uint8Array"===e.name)return t&&(e=e.slice?e.slice():Array.prototype.slice.call(e)),e;if(Array.isArray(e)){if(!It(e))throw new Error("Array contains invalid value: "+e);return new Uint8Array(e)}if(Tt(e.length)&&It(e))return new Uint8Array(e);throw new Error("unsupported array-like object")}function At(e){return new Uint8Array(e)}function Pt(e,t,n,s,r){null==s&&null==r||(e=e.slice?e.slice(s,r):Array.prototype.slice.call(e,s,r)),t.set(e,n)}var Ct,Et={toBytes:function(e){var t=[],n=0;for(e=encodeURI(e);n191&&s<224?(t.push(String.fromCharCode((31&s)<<6|63&e[n+1])),n+=2):(t.push(String.fromCharCode((15&s)<<12|(63&e[n+1])<<6|63&e[n+2])),n+=3)}return t.join("")}},Ot=(Ct="0123456789abcdef",{toBytes:function(e){for(var t=[],n=0;n>4]+Ct[15&s])}return t.join("")}}),Rt={16:10,24:12,32:14},Ut=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],xt=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],Lt=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],Dt=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],Nt=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],qt=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],Ft=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],Kt=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],Mt=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],jt=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],$t=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],Bt=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],zt=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],Wt=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],Ht=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function Jt(e){for(var t=[],n=0;n>2,this._Ke[n][t%4]=i[t],this._Kd[e-n][t%4]=i[t];for(var o,a=0,c=r;c>16&255]<<24^xt[o>>8&255]<<16^xt[255&o]<<8^xt[o>>24&255]^Ut[a]<<24,a+=1,8!=r)for(t=1;t>8&255]<<8^xt[o>>16&255]<<16^xt[o>>24&255]<<24;for(t=r/2+1;t>2,h=c%4,this._Ke[u][h]=i[t],this._Kd[e-u][h]=i[t++],c++}for(var u=1;u>24&255]^zt[o>>16&255]^Wt[o>>8&255]^Ht[255&o]}encrypt(e){if(16!=e.length)throw new Error("invalid plaintext size (must be 16 bytes)");for(var t=this._Ke.length-1,n=[0,0,0,0],s=Jt(e),r=0;r<4;r++)s[r]^=this._Ke[0][r];for(var i=1;i>24&255]^Nt[s[(r+1)%4]>>16&255]^qt[s[(r+2)%4]>>8&255]^Ft[255&s[(r+3)%4]]^this._Ke[i][r];s=n.slice()}var o,a=At(16);for(r=0;r<4;r++)o=this._Ke[t][r],a[4*r]=255&(xt[s[r]>>24&255]^o>>24),a[4*r+1]=255&(xt[s[(r+1)%4]>>16&255]^o>>16),a[4*r+2]=255&(xt[s[(r+2)%4]>>8&255]^o>>8),a[4*r+3]=255&(xt[255&s[(r+3)%4]]^o);return a}decrypt(e){if(16!=e.length)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var t=this._Kd.length-1,n=[0,0,0,0],s=Jt(e),r=0;r<4;r++)s[r]^=this._Kd[0][r];for(var i=1;i>24&255]^Mt[s[(r+3)%4]>>16&255]^jt[s[(r+2)%4]>>8&255]^$t[255&s[(r+1)%4]]^this._Kd[i][r];s=n.slice()}var o,a=At(16);for(r=0;r<4;r++)o=this._Kd[t][r],a[4*r]=255&(Lt[s[r]>>24&255]^o>>24),a[4*r+1]=255&(Lt[s[(r+3)%4]>>16&255]^o>>16),a[4*r+2]=255&(Lt[s[(r+2)%4]>>8&255]^o>>8),a[4*r+3]=255&(Lt[255&s[(r+1)%4]]^o);return a}}class Yt{constructor(e){if(!(this instanceof Yt))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new Vt(e)}encrypt(e){if((e=bt(e)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var t=At(e.length),n=At(16),s=0;sNumber.MAX_SAFE_INTEGER)throw new Error("integer value out of safe range");for(var t=15;t>=0;--t)this._counter[t]=e%256,e=parseInt(e/256)}setBytes(e){if(16!=(e=bt(e,!0)).length)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=e}increment(){for(var e=15;e>=0;e--){if(255!==this._counter[e]){this._counter[e]++;break}this._counter[e]=0}}}class en{constructor(e,t){if(!(this instanceof en))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",t instanceof Zt||(t=new Zt(t)),this._counter=t,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new Vt(e)}encrypt(e){for(var t=bt(e,!0),n=0;n16)throw new Error("PKCS#7 padding byte out of range");for(var n=e.length-t,s=0;sDate.now()}async wxLogin(){return new Promise(((e,t)=>{uni.login({success:({code:t}={})=>{e(t)},fail:e=>{t(new H({code:e.errCode||"SYSTEM_ERROR",message:e.errMsg}))}})}))}async prepare(){return new Promise(((e,t)=>{if(!this.isLogin())return t(new Error("Login is required"));e()})).catch((()=>this.wxLogin().then((e=>this.uniCloudIns.importObject("uni-id-co").loginByWeixin({code:e})))))}async getUserEncryptKey(){if(this.userEncryptKey)return this.userEncryptKey;if(on&&on.expireTime){const e=Date.now();if(on.expireTime-e>0)return this.userEncryptKey=on,this.userEncryptKey}return new Promise(((e,t)=>{uni.getUserCryptoManager().getLatestUserKey({success:t=>{on=t,this.userEncryptKey=t,e(this.userEncryptKey)},fail:e=>{t(new H({code:e.errCode||"SYSTEM_ERROR",message:e.errMsg}))}})}))}getWxAppId(){return wx.getAccountInfoSync().miniProgram.appId}async platformEncryptData(e){const{encryptKey:t,iv:n,version:s}=await this.getUserEncryptKey(),r={secretType:this.secretType,encryptKeyId:s};return this.secretType===vt?{content:e,_uniCloudOptions:r}:{content:nn(JSON.stringify({data:JSON.stringify(e),appId:this.appId,deviceId:this.deviceId,wxAppId:this.getWxAppId(),simulator:"devtools"===uni.getSystemInfoSync().platform,timestamp:Date.now()}),t,n),_uniCloudOptions:r}}async platformDecryptResult(e){const{content:t}=e,{encryptKey:n,iv:s}=await this.getUserEncryptKey();return JSON.parse(function(e,t,n){const s=new Uint8Array(uni.base64ToArrayBuffer(e)),r=new Uint8Array(uni.base64ToArrayBuffer(t)),i=tn.utils.utf8.toBytes(n),o=new tn.ModeOfOperation.cbc(r,i),a=tn.padding.pkcs7.strip(o.decrypt(s));return tn.utils.utf8.fromBytes(a)}(t,n,s))}}function cn(e){const t=["hasClientKey","encryptGetClientKeyPayload","setClientKey","encrypt","decrypt"],n={};for(let s=0;s{"function"==typeof e[r]?e[r](...t,(function({type:e,data:t,message:r}={}){"success"===e?n(t):s(new H({code:"SYSTEM_ERROR",message:r||"[secureNetwork]failed"}))})):s(new Error("[secureNetwork]请检查manifest.json内是否开启安全网络模块,另外注意标准基座不支持安全网络模块"))}))}}return n}class un extends kt{constructor(e){super(e),this.appUtils={...cn(uni.requireNativePlugin("plus"))},this.systemInfo=sn||(sn=uni.getSystemInfoSync())}async hasClientKey(){return void 0===this._hasClientKey&&(this._hasClientKey=await this.appUtils.hasClientKey({provider:this.provider,spaceId:this.spaceId})),this._hasClientKey}async getAppClientKey(){const{data:e,key:t}=await this.appUtils.encryptGetClientKeyPayload({data:JSON.stringify({})}),n=(await this.uniCloudIns.callFunction({name:"DCloud-clientDB",data:{redirectTo:"encryption",action:"getAppClientKey",data:e,key:t}})).result||{};if(0!==n.errCode)throw new H({code:n.errCode||n.code||"SYSTEM_ERROR",message:n.errMsg||n.message});const{clientKey:s,key:r}=n;await this.appUtils.setClientKey({provider:this.provider,spaceId:this.spaceId,clientKey:s,key:r})}async ensureClientKey(){!0!==await this.hasClientKey()&&await this.getAppClientKey()}async prepare(){await this.ensureClientKey()}async platformEncryptData(e){const{data:t,key:n}=await this.appUtils.encrypt({provider:this.provider,spaceId:this.spaceId,data:JSON.stringify(e)}),s={secretType:this.secretType,encryptKeyId:n};return this.secretType===vt?{content:e,_uniCloudOptions:s}:{content:t,_uniCloudOptions:s}}async platformDecryptResult(e){const{content:t,_uniCloudOptions:n={}}=e,s=n.encryptKeyId,r=await this.appUtils.decrypt({provider:this.provider,spaceId:this.spaceId,data:t,key:s});return JSON.parse(r.data)}}function hn({secretType:e}={}){return e===wt||e===vt||e===St}function ln({functionName:e,result:t,logPvd:n}){if(this.__dev__.debugLog&&t&&t.requestId){const s=JSON.stringify({spaceId:this.config.spaceId,functionName:e,requestId:t.requestId});console.log(`[${n}-request]${s}[/${n}-request]`)}}function dn(e){const t=e.callFunction,n=function(n){const s=n.name;n.data=dt.call(e,{data:n.data});const r={aliyun:"aliyun",tencent:"tcb",tcb:"tcb"}[this.config.provider],i=hn(n);return t.call(this,n).then((e=>(e.errCode=0,!i&&ln.call(this,{functionName:s,result:e,logPvd:r}),Promise.resolve(e))),(e=>(!i&&ln.call(this,{functionName:s,result:e,logPvd:r}),e&&e.message&&(e.message=function({message:e="",extraInfo:t={},formatter:n=[]}={}){for(let s=0;s(console.warn("当前返回结果为Promise类型,不可直接访问其result属性,详情请参考:https://uniapp.dcloud.net.cn/uniCloud/faq?id=promise"),{})}),r}}rn=g?"mp-weixin"===m?an:"app"===m?un:class{constructor(){throw new Error(`[SecureNetwork]: Platform ${m} is not supported`)}}:class{constructor(){throw new Error(`[SecureNetwork]: Platform ${m} is not enabled`)}};const fn=Symbol("CLIENT_DB_INTERNAL");function pn(e,t){return e.then="DoNotReturnProxyWithAFunctionNamedThen",e._internalType=fn,e.inspect=null,e.__ob__=void 0,new Proxy(e,{get(e,n,s){if("_uniClient"===n)return null;if("symbol"==typeof n)return e[n];if(n in e||"string"!=typeof n){const t=e[n];return"function"==typeof t?t.bind(e):t}return t.get(e,n,s)}})}function gn(e){return{on:(t,n)=>{e[t]=e[t]||[],e[t].indexOf(n)>-1||e[t].push(n)},off:(t,n)=>{e[t]=e[t]||[];const s=e[t].indexOf(n);-1!==s&&e[t].splice(s,1)}}}const mn=["db.Geo","db.command","command.aggregate"];function yn(e,t){return mn.indexOf(`${e}.${t}`)>-1}function _n(e){switch(h(e)){case"array":return e.map((e=>_n(e)));case"object":return e._internalType===fn||Object.keys(e).forEach((t=>{e[t]=_n(e[t])})),e;case"regexp":return{$regexp:{source:e.source,flags:e.flags}};case"date":return{$date:e.toISOString()};default:return e}}function wn(e){return e&&e.content&&e.content.$method}class vn{constructor(e,t,n){this.content=e,this.prevStage=t||null,this.udb=null,this._database=n}toJSON(){let e=this;const t=[e.content];for(;e.prevStage;)e=e.prevStage,t.push(e.content);return{$db:t.reverse().map((e=>({$method:e.$method,$param:_n(e.$param)})))}}getAction(){const e=this.toJSON().$db.find((e=>"action"===e.$method));return e&&e.$param&&e.$param[0]}getCommand(){return{$db:this.toJSON().$db.filter((e=>"action"!==e.$method))}}get isAggregate(){let e=this;for(;e;){const t=wn(e),n=wn(e.prevStage);if("aggregate"===t&&"collection"===n||"pipeline"===t)return!0;e=e.prevStage}return!1}get isCommand(){let e=this;for(;e;){if("command"===wn(e))return!0;e=e.prevStage}return!1}get isAggregateCommand(){let e=this;for(;e;){const t=wn(e),n=wn(e.prevStage);if("aggregate"===t&&"command"===n)return!0;e=e.prevStage}return!1}get count(){if(!this.isAggregate)return function(){return this._send("count",Array.from(arguments))};const e=this;return function(){return Sn({$method:"count",$param:_n(Array.from(arguments))},e,this._database)}}get remove(){if(!this.isCommand)return function(){return this._send("remove",Array.from(arguments))};const e=this;return function(){return Sn({$method:"remove",$param:_n(Array.from(arguments))},e,this._database)}}get(){return this._send("get",Array.from(arguments))}add(){return this._send("add",Array.from(arguments))}update(){return this._send("update",Array.from(arguments))}end(){return this._send("end",Array.from(arguments))}get set(){if(!this.isCommand)return function(){throw new Error("JQL禁止使用set方法")};const e=this;return function(){return Sn({$method:"set",$param:_n(Array.from(arguments))},e,this._database)}}_send(e,t){const n=this.getAction(),s=this.getCommand();if(s.$db.push({$method:e,$param:_n(t)}),f){const e=s.$db.find((e=>"collection"===e.$method)),t=e&&e.$param;t&&1===t.length&&"string"==typeof e.$param[0]&&e.$param[0].indexOf(",")>-1&&console.warn("检测到使用JQL语法联表查询时,未使用getTemp先过滤主表数据,在主表数据量大的情况下可能会查询缓慢。\n- 如何优化请参考此文档:https://uniapp.dcloud.net.cn/uniCloud/jql?id=lookup-with-temp \n- 如果主表数据量很小请忽略此信息,项目发行时不会出现此提示。")}return this._database._callCloudFunction({action:n,command:s})}}function Sn(e,t,n){return pn(new vn(e,t,n),{get(e,t){let s="db";return e&&e.content&&(s=e.content.$method),yn(s,t)?Sn({$method:t},e,n):function(){return Sn({$method:t,$param:_n(Array.from(arguments))},e,n)}}})}function kn({path:e,method:t}){return class{constructor(){this.param=Array.from(arguments)}toJSON(){return{$newDb:[...e.map((e=>({$method:e}))),{$method:t,$param:this.param}]}}}}function Tn(e,t={}){return pn(new e(t),{get:(e,t)=>yn("db",t)?Sn({$method:t},null,e):function(){return Sn({$method:t,$param:_n(Array.from(arguments))},null,e)}})}class In extends class{constructor({uniClient:e={},isJQL:t=!1}={}){this._uniClient=e,this._authCallBacks={},this._dbCallBacks={},e.isDefault&&(this._dbCallBacks=k("_globalUniCloudDatabaseCallback")),t||(this.auth=gn(this._authCallBacks)),this._isJQL=t,Object.assign(this,gn(this._dbCallBacks)),this.env=pn({},{get:(e,t)=>({$env:t})}),this.Geo=pn({},{get:(e,t)=>kn({path:["Geo"],method:t})}),this.serverDate=kn({path:[],method:"serverDate"}),this.RegExp=kn({path:[],method:"RegExp"})}getCloudEnv(e){if("string"!=typeof e||!e.trim())throw new Error("getCloudEnv参数错误");return{$env:e.replace("$cloudEnv_","")}}_callback(e,t){const n=this._dbCallBacks;n[e]&&n[e].forEach((e=>{e(...t)}))}_callbackAuth(e,t){const n=this._authCallBacks;n[e]&&n[e].forEach((e=>{e(...t)}))}multiSend(){const e=Array.from(arguments),t=e.map((e=>{const t=e.getAction(),n=e.getCommand();if("getTemp"!==n.$db[n.$db.length-1].$method)throw new Error("multiSend只支持子命令内使用getTemp");return{action:t,command:n}}));return this._callCloudFunction({multiCommand:t,queryList:e})}}{_parseResult(e){return this._isJQL?e.result:e}_callCloudFunction({action:e,command:t,multiCommand:n,queryList:s}){function r(e,t){if(n&&s)for(let n=0;nP(C(o,"complete"),e))).then((()=>(r(null,e),M(R,{type:L,content:e}),Promise.reject(e))))}const c=P(C(o,"invoke")),h=this._uniClient;return c.then((()=>h.callFunction({name:"DCloud-clientDB",type:u,data:{action:e,command:t,multiCommand:n}}))).then((e=>{const{code:t,message:n,token:s,tokenExpired:c,systemInfo:u=[]}=e.result;if(u)for(let e=0;e(console.warn(s),t)})}}return function(e){return P(C(o,"success"),e).then((()=>P(C(o,"complete"),e))).then((()=>{r(e,null);const t=i._parseResult(e);return M(R,{type:L,content:t}),Promise.resolve(t)}))}(e)}),(e=>{/fc_function_not_found|FUNCTION_NOT_FOUND/g.test(e.message)&&console.warn("clientDB未初始化,请在web控制台保存一次schema以开启clientDB");return a(new H({code:e.code||"SYSTEM_ERROR",message:e.message,requestId:e.requestId}))}))}}const bn="token无效,跳转登录页面",An="token过期,跳转登录页面",Pn={TOKEN_INVALID_TOKEN_EXPIRED:An,TOKEN_INVALID_INVALID_CLIENTID:bn,TOKEN_INVALID:bn,TOKEN_INVALID_WRONG_TOKEN:bn,TOKEN_INVALID_ANONYMOUS_USER:bn},Cn={"uni-id-token-expired":An,"uni-id-check-token-failed":bn,"uni-id-token-not-exist":bn,"uni-id-check-device-feature-failed":bn};function En(e,t){let n="";return n=e?`${e}/${t}`:t,n.replace(/^\//,"")}function On(e=[],t=""){const n=[],s=[];return e.forEach((e=>{!0===e.needLogin?n.push(En(t,e.path)):!1===e.needLogin&&s.push(En(t,e.path))})),{needLoginPage:n,notNeedLoginPage:s}}function Rn(e){return e.split("?")[0].replace(/^\//,"")}function Un(){return function(e){let t=e&&e.$page&&e.$page.fullPath||"";return t?("/"!==t.charAt(0)&&(t="/"+t),t):t}(function(){const e=getCurrentPages();return e[e.length-1]}())}function xn(){return Rn(Un())}function Ln(e="",t={}){if(!e)return!1;if(!(t&&t.list&&t.list.length))return!1;const n=t.list,s=Rn(e);return n.some((e=>e.pagePath===s))}const Dn=!!t.uniIdRouter;const{loginPage:Nn,routerNeedLogin:qn,resToLogin:Fn,needLoginPage:Kn,notNeedLoginPage:Mn,loginPageInTabBar:jn}=function({pages:e=[],subPackages:n=[],uniIdRouter:s={},tabBar:r={}}=t){const{loginPage:i,needLogin:o=[],resToLogin:a=!0}=s,{needLoginPage:c,notNeedLoginPage:u}=On(e),{needLoginPage:h,notNeedLoginPage:l}=function(e=[]){const t=[],n=[];return e.forEach((e=>{const{root:s,pages:r=[]}=e,{needLoginPage:i,notNeedLoginPage:o}=On(r,s);t.push(...i),n.push(...o)})),{needLoginPage:t,notNeedLoginPage:n}}(n);return{loginPage:i,routerNeedLogin:o,resToLogin:a,needLoginPage:[...c,...h],notNeedLoginPage:[...u,...l],loginPageInTabBar:Ln(i,r)}}();if(Kn.indexOf(Nn)>-1)throw new Error(`Login page [${Nn}] should not be "needLogin", please check your pages.json`);function $n(e){const t=Rn(function(e){const t=xn(),n=e.charAt(0),s=e.split("?")[0];if("/"===n)return s;const r=s.replace(/^\//,"").split("/"),i=t.split("/");i.pop();for(let e=0;e-1)&&(Kn.indexOf(t)>-1||qn.some((t=>function(e,t){return new RegExp(t).test(e)}(e,t))))}function Bn({redirect:e}){const t=Rn(e),n=Rn(Nn);return xn()!==n&&t!==n}function zn({api:e,redirect:t}={}){if(!t||!Bn({redirect:t}))return;const n=function(e,t){return"/"!==e.charAt(0)&&(e="/"+e),t?e.indexOf("?")>-1?e+`&uniIdRedirectUrl=${encodeURIComponent(t)}`:e+`?uniIdRedirectUrl=${encodeURIComponent(t)}`:e}(Nn,t);jn?"navigateTo"!==e&&"redirectTo"!==e||(e="switchTab"):"switchTab"===e&&(e="navigateTo"),setTimeout((()=>{uni[e]({url:n})}))}function Wn({url:e}={}){const t={abortLoginPageJump:!1,autoToLoginPage:!1},n=function(){const{token:e,tokenExpired:t}=at();let n;if(e){if(t0)return setTimeout((()=>{M(U,n)}),0),t.abortLoginPageJump=!0,t;t.autoToLoginPage=!0}return t}function Hn(){!function(){const e=Un(),{abortLoginPageJump:t,autoToLoginPage:n}=Wn({url:e});t||n&&zn({api:"redirectTo",redirect:e})}();const e=["navigateTo","redirectTo","reLaunch","switchTab"];for(let t=0;t{const{type:t,content:n}=e;let s=!1;switch(t){case"cloudobject":s=function(e){const{errCode:t}=e;return t in Cn}(n);break;case"clientdb":s=function(e){const{errCode:t}=e;return t in Pn}(n)}s&&function(e={}){const t=q(U);z().then((()=>{const n=Un();if(n&&Bn({redirect:n}))return t.length>0?M(U,Object.assign({uniIdRedirectUrl:n},e)):void(Nn&&zn({api:"navigateTo",redirect:n}))}))}(n)}))}function Vn(e){!function(e){e.onResponse=function(e){F(R,e)},e.offResponse=function(e){K(R,e)}}(e),function(e){e.onNeedLogin=function(e){F(U,e)},e.offNeedLogin=function(e){K(U,e)},Dn&&(k("uni-cloud-status").needLoginInit||(k("uni-cloud-status").needLoginInit=!0,z().then((()=>{Hn.call(e)})),Fn&&Jn.call(e)))}(e),function(e){e.onRefreshToken=function(e){F(x,e)},e.offRefreshToken=function(e){K(x,e)}}(e)}let Yn;const Qn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Xn=/^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;function Gn(){const e=at().token||"",t=e.split(".");if(!e||3!==t.length)return{uid:null,role:[],permission:[],tokenExpired:0};let n;try{n=JSON.parse((s=t[1],decodeURIComponent(Yn(s).split("").map((function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)})).join(""))))}catch(e){throw new Error("获取当前用户信息出错,详细错误信息为:"+e.message)}var s;return n.tokenExpired=1e3*n.exp,delete n.exp,delete n.iat,n}Yn="function"!=typeof atob?function(e){if(e=String(e).replace(/[\t\n\f\r ]+/g,""),!Xn.test(e))throw new Error("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");var t;e+="==".slice(2-(3&e.length));for(var n,s,r="",i=0;i>16&255):64===s?String.fromCharCode(t>>16&255,t>>8&255):String.fromCharCode(t>>16&255,t>>8&255,255&t);return r}:atob;var Zn=s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0});const n="chooseAndUploadFile:ok",s="chooseAndUploadFile:fail";function r(e,t){return e.tempFiles.forEach(((e,n)=>{e.name||(e.name=e.path.substring(e.path.lastIndexOf("/")+1)),t&&(e.fileType=t),e.cloudPath=Date.now()+"_"+n+e.name.substring(e.name.lastIndexOf("."))})),e.tempFilePaths||(e.tempFilePaths=e.tempFiles.map((e=>e.path))),e}function i(e,t,{onChooseFile:s,onUploadProgress:r}){return t.then((e=>{if(s){const t=s(e);if(void 0!==t)return Promise.resolve(t).then((t=>void 0===t?e:t))}return e})).then((t=>!1===t?{errMsg:n,tempFilePaths:[],tempFiles:[]}:function(e,t,s=5,r){(t=Object.assign({},t)).errMsg=n;const i=t.tempFiles,o=i.length;let a=0;return new Promise((n=>{for(;a=o)return void(!i.find((e=>!e.url&&!e.errMsg))&&n(t));const u=i[s];e.uploadFile({filePath:u.path,cloudPath:u.cloudPath,fileType:u.fileType,onUploadProgress(e){e.index=s,e.tempFile=u,e.tempFilePath=u.path,r&&r(e)}}).then((e=>{u.url=e.fileID,s{u.errMsg=e.errMsg||e.message,s{uni.chooseImage({count:t,sizeType:n,sourceType:i,extension:o,success(t){e(r(t,"image"))},fail(e){a({errMsg:e.errMsg.replace("chooseImage:fail",s)})}})}))}(t),t):"video"===t.type?i(e,function(e){const{camera:t,compressed:n,maxDuration:i,sourceType:o=["album","camera"],extension:a}=e;return new Promise(((e,c)=>{uni.chooseVideo({camera:t,compressed:n,maxDuration:i,sourceType:o,extension:a,success(t){const{tempFilePath:n,duration:s,size:i,height:o,width:a}=t;e(r({errMsg:"chooseVideo:ok",tempFilePaths:[n],tempFiles:[{name:t.tempFile&&t.tempFile.name||"",path:n,size:i,type:t.tempFile&&t.tempFile.type||"",width:a,height:o,duration:s,fileType:"video",cloudPath:""}]},"video"))},fail(e){c({errMsg:e.errMsg.replace("chooseVideo:fail",s)})}})}))}(t),t):i(e,function(e){const{count:t,extension:n}=e;return new Promise(((e,i)=>{let o=uni.chooseFile;if("undefined"!=typeof wx&&"function"==typeof wx.chooseMessageFile&&(o=wx.chooseMessageFile),"function"!=typeof o)return i({errMsg:s+" 请指定 type 类型,该平台仅支持选择 image 或 video。"});o({type:"all",count:t,extension:n,success(t){e(r(t))},fail(e){i({errMsg:e.errMsg.replace("chooseFile:fail",s)})}})}))}(t),t)}}})),es=n(Zn);const ts="manual";function ns(e){return{props:{localdata:{type:Array,default:()=>[]},options:{type:[Object,Array],default:()=>({})},spaceInfo:{type:Object,default:()=>({})},collection:{type:[String,Array],default:""},action:{type:String,default:""},field:{type:String,default:""},orderby:{type:String,default:""},where:{type:[String,Object],default:""},pageData:{type:String,default:"add"},pageCurrent:{type:Number,default:1},pageSize:{type:Number,default:20},getcount:{type:[Boolean,String],default:!1},gettree:{type:[Boolean,String],default:!1},gettreepath:{type:[Boolean,String],default:!1},startwith:{type:String,default:""},limitlevel:{type:Number,default:10},groupby:{type:String,default:""},groupField:{type:String,default:""},distinct:{type:[Boolean,String],default:!1},foreignKey:{type:String,default:""},loadtime:{type:String,default:"auto"},manual:{type:Boolean,default:!1}},data:()=>({mixinDatacomLoading:!1,mixinDatacomHasMore:!1,mixinDatacomResData:[],mixinDatacomErrorMessage:"",mixinDatacomPage:{}}),created(){this.mixinDatacomPage={current:this.pageCurrent,size:this.pageSize,count:0},this.$watch((()=>{var e=[];return["pageCurrent","pageSize","localdata","collection","action","field","orderby","where","getont","getcount","gettree","groupby","groupField","distinct"].forEach((t=>{e.push(this[t])})),e}),((e,t)=>{if(this.loadtime===ts)return;let n=!1;const s=[];for(let r=2;r{this.mixinDatacomLoading=!1;const{data:s,count:r}=n.result;this.getcount&&(this.mixinDatacomPage.count=r),this.mixinDatacomHasMore=s.length{this.mixinDatacomLoading=!1,this.mixinDatacomErrorMessage=e,n&&n(e)})))},mixinDatacomGet(t={}){let n=e.database(this.spaceInfo);const s=t.action||this.action;s&&(n=n.action(s));const r=t.collection||this.collection;n=Array.isArray(r)?n.collection(...r):n.collection(r);const i=t.where||this.where;i&&Object.keys(i).length&&(n=n.where(i));const o=t.field||this.field;o&&(n=n.field(o));const a=t.foreignKey||this.foreignKey;a&&(n=n.foreignKey(a));const c=t.groupby||this.groupby;c&&(n=n.groupBy(c));const u=t.groupField||this.groupField;u&&(n=n.groupField(u));!0===(void 0!==t.distinct?t.distinct:this.distinct)&&(n=n.distinct());const h=t.orderby||this.orderby;h&&(n=n.orderBy(h));const l=void 0!==t.pageCurrent?t.pageCurrent:this.mixinDatacomPage.current,d=void 0!==t.pageSize?t.pageSize:this.mixinDatacomPage.size,f=void 0!==t.getcount?t.getcount:this.getcount,p=void 0!==t.gettree?t.gettree:this.gettree,g=void 0!==t.gettreepath?t.gettreepath:this.gettreepath,m={getCount:f},y={limitLevel:void 0!==t.limitlevel?t.limitlevel:this.limitlevel,startWith:void 0!==t.startwith?t.startwith:this.startwith};return p&&(m.getTree=y),g&&(m.getTreePath=y),n=n.skip(d*(l-1)).limit(d).get(m),n}}}}function ss(e){return function(t,n={}){n=function(e,t={}){return e.customUI=t.customUI||e.customUI,e.parseSystemError=t.parseSystemError||e.parseSystemError,Object.assign(e.loadingOptions,t.loadingOptions),Object.assign(e.errorOptions,t.errorOptions),"object"==typeof t.secretMethods&&(e.secretMethods=t.secretMethods),e}({customUI:!1,loadingOptions:{title:"加载中...",mask:!0},errorOptions:{type:"modal",retry:!1}},n);const{customUI:s,loadingOptions:r,errorOptions:i,parseSystemError:o}=n,a=!s;return new Proxy({},{get:(s,u)=>function({fn:e,interceptorName:t,getCallbackArgs:n}={}){return async function(...s){const r=n?n({params:s}):{};let i,o;try{return await P(C(t,"invoke"),{...r}),i=await e(...s),await P(C(t,"success"),{...r,result:i}),i}catch(e){throw o=e,await P(C(t,"fail"),{...r,error:o}),o}finally{await P(C(t,"complete"),o?{...r,error:o}:{...r,result:i})}}}({fn:async function s(...h){let l;a&&uni.showLoading({title:r.title,mask:r.mask});const d={name:t,type:c,data:{method:u,params:h}};"object"==typeof n.secretMethods&&function(e,t){const n=t.data.method,s=e.secretMethods||{},r=s[n]||s["*"];r&&(t.secret=r)}(n,d);try{l=await e.callFunction(d)}catch(e){l={result:e}}const{errCode:f,errMsg:p,newToken:g}=l.result||{};if(a&&uni.hideLoading(),g&&g.token&&g.tokenExpired&&(ct(g),M(x,{...g})),f){const e=o?await o({objectName:t,methodName:u,params:h,errCode:f,errMsg:p}):p;if(a)if("toast"===i.type)uni.showToast({title:e,icon:"none"});else{if("modal"!==i.type)throw new Error(`Invalid errorOptions.type: ${i.type}`);{const{confirm:t}=await async function({title:e,content:t,showCancel:n,cancelText:s,confirmText:r}={}){return new Promise(((i,o)=>{uni.showModal({title:e,content:t,showCancel:n,cancelText:s,confirmText:r,success(e){i(e)},fail(){i({confirm:!1,cancel:!0})}})}))}({title:"提示",content:e,showCancel:i.retry,cancelText:"取消",confirmText:i.retry?"重试":"确定"});if(i.retry&&t)return s(...h)}}const n=new H({code:f,message:p,requestId:l.requestId});throw n.detail=l.result,M(R,{type:N,content:n}),n}return M(R,{type:N,content:l.result}),l.result},interceptorName:"callObject",getCallbackArgs:function({params:e}={}){return{objectName:t,methodName:u,params:e}}})})}}async function rs(e,t){const n=`http://${e}:${t}/system/ping`;try{const e=await(s={url:n,timeout:500},new Promise(((e,t)=>{Q.request({...s,success(t){e(t)},fail(e){t(e)}})})));return!(!e.data||0!==e.data.code)}catch(e){return!1}var s}function is(e){if(e.initUniCloudStatus&&"rejected"!==e.initUniCloudStatus)return;let t=Promise.resolve();var n;n=1,t=new Promise(((e,t)=>{setTimeout((()=>{e()}),n)})),e.isReady=!1,e.isDefault=!1;const s=e.auth();e.initUniCloudStatus="pending",e.initUniCloud=t.then((()=>s.getLoginState())).then((e=>e?Promise.resolve():s.signInAnonymously())).then((()=>{if(!f)return Promise.resolve();if("app"===m){const{osName:e,osVersion:t}=uni.getSystemInfoSync();"ios"===e&&function(e){if(!e||"string"!=typeof e)return 0;const t=e.match(/^(\d+)./);return t&&t[1]?parseInt(t[1]):0}(t)>=14&&console.warn("iOS 14及以上版本连接uniCloud本地调试服务需要允许客户端查找并连接到本地网络上的设备(仅开发模式生效,发行模式会连接uniCloud云端服务)")}if(f&&e.__dev__.debugInfo){const{address:t,servePort:n}=e.__dev__.debugInfo;return async function(e,t){let n;for(let s=0;s{if(!f)return Promise.resolve();const s=console["app"===m?"error":"warn"];if(t)e.__dev__.localAddress=t,e.__dev__.localPort=n;else if(e.__dev__.debugInfo){let t="";"remote"===e.__dev__.debugInfo.initialLaunchType?(e.__dev__.debugInfo.forceRemote=!0,t="当前客户端和HBuilderX不在同一局域网下(或其他网络原因无法连接HBuilderX),uniCloud本地调试服务不对当前客户端生效。\n- 如果不使用uniCloud本地调试服务,请直接忽略此信息。\n- 如需使用uniCloud本地调试服务,请将客户端与主机连接到同一局域网下并重新运行到客户端。\n- 如果在HBuilderX开启的状态下切换过网络环境,请重启HBuilderX后再试\n- 检查系统防火墙是否拦截了HBuilderX自带的nodejs"):t="无法连接uniCloud本地调试服务,请检查当前客户端是否与主机在同一局域网下。\n- 如需使用uniCloud本地调试服务,请将客户端与主机连接到同一局域网下并重新运行到客户端。\n- 如果在HBuilderX开启的状态下切换过网络环境,请重启HBuilderX后再试\n- 检查系统防火墙是否拦截了HBuilderX自带的nodejs","web"===m&&(t+="\n- 部分浏览器开启节流模式之后访问本地地址受限,请检查是否启用了节流模式"),0===m.indexOf("mp-")&&(t+="\n- 小程序中如何使用uniCloud,请参考:https://uniapp.dcloud.net.cn/uniCloud/publish.html#useinmp"),s(t)}})).then((()=>{ut(),e.isReady=!0,e.initUniCloudStatus="fulfilled"})).catch((t=>{console.error(t),e.initUniCloudStatus="rejected"}))}const os={tcb:ot,tencent:ot,aliyun:ee,private:lt};let as=new class{init(e){let t={};const n=os[e.provider];if(!n)throw new Error("未提供正确的provider参数");t=n.init(e),t.__dev__={},t.__dev__.debugLog=f&&("web"===m&&navigator.userAgent.indexOf("HBuilderX")>0||"app"===m);const s=y;f&&s&&!s.code&&(t.__dev__.debugInfo=s),is(t),t.reInit=function(){is(this)},dn(t),function(e){const t=e.uploadFile;e.uploadFile=function(e){return t.call(this,e)}}(t),function(e){e.database=function(t){if(t&&Object.keys(t).length>0)return e.init(t).database();if(this._database)return this._database;const n=Tn(In,{uniClient:e});return this._database=n,n},e.databaseForJQL=function(t){if(t&&Object.keys(t).length>0)return e.init(t).databaseForJQL();if(this._databaseForJQL)return this._databaseForJQL;const n=Tn(In,{uniClient:e,isJQL:!0});return this._databaseForJQL=n,n}}(t),function(e){e.getCurrentUserInfo=Gn,e.chooseAndUploadFile=es.initChooseAndUploadFile(e),Object.assign(e,{get mixinDatacom(){return ns(e)}}),e.importObject=ss(e)}(t);return["callFunction","uploadFile","deleteFile","getTempFileURL","downloadFile","chooseAndUploadFile"].forEach((e=>{if(!t[e])return;const n=t[e];t[e]=function(){return t.reInit(),n.apply(t,Array.from(arguments))},t[e]=W(t[e],e).bind(t)})),t.init=this.init,t}};(()=>{const e=_;let t={};if(e&&1===e.length)t=e[0],as=as.init(t),as.isDefault=!0;else{const t=["auth","callFunction","uploadFile","deleteFile","getTempFileURL","downloadFile","database","getCurrentUSerInfo","importObject"];let n;n=e&&e.length>0?"应用有多个服务空间,请通过uniCloud.init方法指定要使用的服务空间":w?"应用未关联服务空间,请在uniCloud目录右键关联服务空间":"uni-app cli项目内使用uniCloud需要使用HBuilderX的运行菜单运行项目,且需要在uniCloud目录关联服务空间",t.forEach((e=>{as[e]=function(){return console.error(n),Promise.reject(new H({code:"SYS_ERR",message:n}))}}))}Object.assign(as,{get mixinDatacom(){return ns(as)}}),Vn(as),as.addInterceptor=b,as.removeInterceptor=A,as.interceptObject=E,f&&"web"===m&&(window.uniCloud=as)})();var cs=as;export{cs as default}; diff --git a/packages/webpack-uni-pages-loader/lib/index-new.js b/packages/webpack-uni-pages-loader/lib/index-new.js index d59f81e040e83e24f8c02e7c74d7ba6b6372f051..752f4b20668b47cee8fc78c63383042caa9461d2 100644 --- a/packages/webpack-uni-pages-loader/lib/index-new.js +++ b/packages/webpack-uni-pages-loader/lib/index-new.js @@ -39,9 +39,11 @@ const { // 将开发者手动设置的 usingComponents 调整名称,方便与自动解析到的 usingComponents 做最后合并 function renameUsingComponents (jsonObj) { - if (jsonObj.usingComponents) { - jsonObj.customUsingComponents = jsonObj.usingComponents + if (jsonObj.usingComponents || jsonObj.usingSwanComponents) { + // 暂定 usingComponents 优先级高于 usingSwanComponents + jsonObj.customUsingComponents = Object.assign({}, jsonObj.usingSwanComponents, jsonObj.usingComponents) delete jsonObj.usingComponents + delete jsonObj.usingSwanComponents } return jsonObj } diff --git a/packages/webpack-uni-pages-loader/lib/platforms/h5.js b/packages/webpack-uni-pages-loader/lib/platforms/h5.js index 72feaf423b9479221485da70659ccb68503a5b0d..99de71e4c0b077d044f4925cece4765a4919bef2 100644 --- a/packages/webpack-uni-pages-loader/lib/platforms/h5.js +++ b/packages/webpack-uni-pages-loader/lib/platforms/h5.js @@ -257,32 +257,6 @@ const genSystemRoutes = function () { return [ ` { -path: '/preview-image', -component: { - render (createElement) { - return createElement( - 'Page', - { - props:{ - navigationStyle:'custom' - } - }, - [ - createElement('system-preview-image', { - slot: 'page' - }) - ] - ) - } -}, -meta:{ - name:'preview-image', - pagePath:'/preview-image' -} -} - `, - ` -{ path: '/choose-location', component: { render (createElement) { diff --git a/packages/webpack-uni-pages-loader/lib/platforms/mp.js b/packages/webpack-uni-pages-loader/lib/platforms/mp.js index 6a2250d11ef74b82ca759e086dc2c440f5302399..f948fe0176f3fe9d2c823abc110a69e3a605c0d1 100644 --- a/packages/webpack-uni-pages-loader/lib/platforms/mp.js +++ b/packages/webpack-uni-pages-loader/lib/platforms/mp.js @@ -49,9 +49,11 @@ function deepCopy (name, value, json) { const pagesJson2AppJson = { globalStyle: function (name, value, json) { json.window = parseStyle(value) - if (json.window.usingComponents) { - json.usingComponents = json.window.usingComponents + if (json.window.usingComponents || json.window.usingSwanComponents) { + // 暂定 usingComponents 优先级高于 usingSwanComponents + json.usingComponents = Object.assign({}, json.window.usingSwanComponents, json.window.usingComponents) delete json.window.usingComponents + delete json.window.usingSwanComponents } else { json.usingComponents = {} } diff --git a/packages/webpack-uni-pages-loader/lib/util.js b/packages/webpack-uni-pages-loader/lib/util.js index 739f903caab579237b3fdc42f0ea1b27522a5902..44a33ad6e2180a8d2f595e28185e9982fd62c245 100644 --- a/packages/webpack-uni-pages-loader/lib/util.js +++ b/packages/webpack-uni-pages-loader/lib/util.js @@ -133,6 +133,7 @@ function parseTabBar (style = {}) { const NON_APP_JSON_KEYS = [ 'appid', 'unipush', + 'secureNetwork', 'usingComponents', 'optimization', 'scopedSlotsCompiler', diff --git a/src/core/runtime/index.js b/src/core/runtime/index.js index 0f0c8f515f2ca6f130b375979b8fddf68a953ad4..dce0129c2f6e62f68474b640ad425c0ee9dbcf7b 100644 --- a/src/core/runtime/index.js +++ b/src/core/runtime/index.js @@ -67,7 +67,7 @@ if (typeof Proxy !== 'undefined' && __PLATFORM__ !== 'app-plus') { if (eventApi[name]) { return eventApi[name] } - if (!hasOwn(__GLOBAL__, name) && !hasOwn(protocols, name)) { + if (typeof __GLOBAL__[name] !== 'function' && !hasOwn(protocols, name)) { return } return promisify(name, wrapper(name, __GLOBAL__[name])) diff --git a/src/core/runtime/wrapper/util.js b/src/core/runtime/wrapper/util.js index ec1a8ba366ebce2a7d77b89ba8c2add2a662eb53..4a93a1e870cb5341f8e76e96a3959275d3ec2d60 100644 --- a/src/core/runtime/wrapper/util.js +++ b/src/core/runtime/wrapper/util.js @@ -50,7 +50,7 @@ function hasHook (hook, vueOptions) { return false } - if (isFn(vueOptions[hook])) { + if (isFn(vueOptions[hook]) || Array.isArray(vueOptions[hook])) { return true } const mixins = vueOptions.mixins diff --git a/src/core/service/api/plugin/push.js b/src/core/service/api/plugin/push.js index e340373ae54a8b6e114b4fc7a4e02de2eab8c981..152e56e553c6d7298e1a0bd6a10dc985b5706c55 100644 --- a/src/core/service/api/plugin/push.js +++ b/src/core/service/api/plugin/push.js @@ -133,7 +133,7 @@ export const onPushMessage = (fn) => { onPushMessageCallbacks.push(fn) } // 不能程序启动时就监听,因为离线事件,仅触发一次,框架监听后,无法转发给还没开始监听的开发者 - if (__PLATFORM__ === 'app' && !listening) { + if (__PLATFORM__ === 'app-plus' && !listening) { listening = true plus.push.addEventListener('click', (result) => { invokePushCallback({ diff --git a/src/core/view/components/editor/index.vue b/src/core/view/components/editor/index.vue index 01d473c09fa1c82872edcef0c40d06180adf0223..0b6fd4eb68256d0ed7e0727eaacc41e8a34d5f01 100644 --- a/src/core/view/components/editor/index.vue +++ b/src/core/view/components/editor/index.vue @@ -29,7 +29,6 @@ function isiOS () { return false } -let textChanging = false export default { name: 'Editor', mixins: [subscriber, emitter, keyboard], @@ -106,6 +105,9 @@ export default { }) }, methods: { + _textChangeHandler () { + this.$trigger('input', {}, this.getContents()) + }, _handleSubscribe ({ type, data @@ -161,18 +163,19 @@ export default { range = quill.getSelection(true) const { src = '', alt = '', width = '', height = '', extClass = '', data = {} } = options const path = this.$getRealPath(src) - quill.insertEmbed(range.index, 'image', path, Quill.sources.USER) + quill.insertEmbed(range.index, 'image', path, Quill.sources.SILENT) const local = /^(file|blob):/.test(path) ? path : false - // 防止 formatText 多次触发 Quill.events.TEXT_CHANGE 事件 - textChanging = true - quill.formatText(range.index, 1, 'data-local', local) - quill.formatText(range.index, 1, 'alt', alt) - quill.formatText(range.index, 1, 'width', width) - quill.formatText(range.index, 1, 'height', height) - quill.formatText(range.index, 1, 'class', extClass) - textChanging = false - quill.formatText(range.index, 1, 'data-custom', Object.keys(data).map(key => `${key}=${data[key]}`).join('&')) + quill.formatText(range.index, 1, 'data-local', local, Quill.sources.SILENT) + quill.formatText(range.index, 1, 'alt', alt, Quill.sources.SILENT) + quill.formatText(range.index, 1, 'width', width, Quill.sources.SILENT) + quill.formatText(range.index, 1, 'height', height, Quill.sources.SILENT) + quill.formatText(range.index, 1, 'class', extClass, Quill.sources.SILENT) + quill.formatText(range.index, 1, 'data-custom', Object.keys(data).map(key => `${key}=${data[key]}`).join('&'), Quill.sources.SILENT) quill.setSelection(range.index + 1, Quill.sources.SILENT) + quill.scrollIntoView() + setTimeout(() => { + this._textChangeHandler() + }, 1000) } break case 'insertText': @@ -289,11 +292,7 @@ export default { } }) }) - quill.on(Quill.events.TEXT_CHANGE, () => { - if (!textChanging) { - this.$trigger('input', {}, this.getContents()) - } - }) + quill.on(Quill.events.TEXT_CHANGE, this._textChangeHandler) quill.on(Quill.events.SELECTION_CHANGE, this.updateStatus.bind(this)) quill.on(Quill.events.SCROLL_OPTIMIZE, () => { const range = quill.selection.getRange()[0] diff --git a/src/core/view/components/swiper/index.vue b/src/core/view/components/swiper/index.vue index 842e95d11f6458d51127c70bd30232b506ec4158..213b16c47072fd844b3847107141eb017ecb5909 100644 --- a/src/core/view/components/swiper/index.vue +++ b/src/core/view/components/swiper/index.vue @@ -1,4 +1,3 @@ - + diff --git a/src/platforms/h5/components/app/tabBar.vue b/src/platforms/h5/components/app/tabBar.vue index e62521018f6fe43e251365a192f9afb3da546058..cc029947cce22bb4a223a2a07ca077e4376034d5 100644 --- a/src/platforms/h5/components/app/tabBar.vue +++ b/src/platforms/h5/components/app/tabBar.vue @@ -55,13 +55,6 @@ v-else-if="!item.isMidButton" :src="_getRealPath(getIconPath(item,index))" > -

- {{ item.badge }} -
{{ item.text }} -
- {{ item.badge }} -
+
+
+ {{ item.badge }}
@@ -199,14 +192,14 @@ uni-tabbar .uni-tabbar__reddot { position: absolute; - top: 0; + top: 2px; right: 0; width: 12px; height: 12px; border-radius: 50%; background-color: #f43530; color: #ffffff; - transform: translate(40%, -20%); + transform: translate(40%, 0%); } uni-tabbar .uni-tabbar__badge { diff --git a/src/platforms/h5/components/system-routes/index.js b/src/platforms/h5/components/system-routes/index.js index e3c90930eec5a70cd47004f514534ed000260f04..41decc80eee3d66829a0946763b6fb26e85d2b23 100644 --- a/src/platforms/h5/components/system-routes/index.js +++ b/src/platforms/h5/components/system-routes/index.js @@ -1,9 +1,7 @@ import ChooseLocation from './choose-location' import OpenLocation from './open-location' -import PreviewImage from './preview-image' export default { ChooseLocation, - OpenLocation, - PreviewImage -} + OpenLocation +} diff --git a/src/platforms/h5/components/system-routes/open-location/index.vue b/src/platforms/h5/components/system-routes/open-location/index.vue index 139c5cca86534452e568b8e9d84e3f7dadc71137..564a709e30e1cd7aca9a7c0bf301d223f0577f10 100644 --- a/src/platforms/h5/components/system-routes/open-location/index.vue +++ b/src/platforms/h5/components/system-routes/open-location/index.vue @@ -141,17 +141,15 @@ export default { url = `https://www.google.com/maps/dir/?api=1${origin}&destination=${this.latitude}%2C${this.longitude}` } else if (mapInfo.type === MapType.QQ) { const fromcoord = this.location.latitude - ? `&fromcoord=${this.location.latitude}%2C${this.location.longitude}` + ? `&fromcoord=${this.location.latitude}%2C${this.location.longitude}&from=${encodeURIComponent( + '我的位置' + )}` : '' url = `https://apis.map.qq.com/uri/v1/routeplan?type=drive${fromcoord}&tocoord=${this.latitude - }%2C${this.longitude}&from=${encodeURIComponent( - '我的位置' - )}&to=${encodeURIComponent(this.name || '目的地')}&ref=${mapInfo.key}` + }%2C${this.longitude}&to=${encodeURIComponent(this.name || '目的地')}&ref=${mapInfo.key}` } else if (mapInfo.type === MapType.AMAP) { - url = `https://m.amap.com/navi/?dest=${this.longitude},${this.latitude}&key=${mapInfo.key}` - if (this.name) { - url += `&destName=${this.name}` - } + const from = this.location.latitude ? `from=${this.location.longitude},${this.location.latitude},${encodeURIComponent('我的位置')}&` : '' + url = `https://uri.amap.com/navigation?${from}to=${this.longitude},${this.latitude},${encodeURIComponent(this.name || '目的地')}}` } window.open(url) } diff --git a/src/platforms/h5/components/system-routes/preview-image/index.vue b/src/platforms/h5/components/system-routes/preview-image/index.vue deleted file mode 100644 index 7ed12d78caf86ec5456433f9439cc0430e596bf3..0000000000000000000000000000000000000000 --- a/src/platforms/h5/components/system-routes/preview-image/index.vue +++ /dev/null @@ -1,87 +0,0 @@ - - - - diff --git a/src/platforms/h5/helpers/location.js b/src/platforms/h5/helpers/location.js index f00476e9368485db04908553d1a7960d674bb9e2..e7fecbb1256df82a885b5b3d527e2a181659fd3e 100644 --- a/src/platforms/h5/helpers/location.js +++ b/src/platforms/h5/helpers/location.js @@ -1,3 +1,6 @@ +import { getJSONP } from './get-jsonp' +import { loadMaps } from '../view/components/map/maps' + export const ICON_PATH_ORIGIN = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIQAAACECAMAAABmmnOVAAAC01BMVEUAAAAAef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef96quGStdqStdpbnujMzMzCyM7Gyc7Ky83MzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMwAef8GfP0yjfNWnOp0qOKKsdyYt9mju9aZt9mMstx1qeJYnekyjvIIfP0qivVmouaWttnMzMyat9lppOUujPQKffxhoOfNzc3Y2Njh4eHp6enu7u7y8vL19fXv7+/i4uLZ2dnOzs6auNgOf/sKff15quHR0dHx8fH9/f3////j4+N6quFdn+iywdPb29vw8PD+/v7c3NyywtLa2tr29vbS0tLd3d38/Pzf39/o6Ojc7f+q0v+HwP9rsf9dqv9Hnv9Vpv/q6urj8P+Vx/9Am/8Pgf8Iff/z8/OAvP95uf/n5+c5l//V6f+52v+y1//7+/vt7e0rkP/09PTQ0NDq9P8Whf+cy//W1tbe3t7A3v/m5ubs7OxOov/r6+vk5OQiaPjKAAAAknRSTlMACBZ9oB71/jiqywJBZATT6hBukRXv+zDCAVrkDIf4JbQsTb7eVeJLbwfa8Rh4G/OlPS/6/kxQ9/xdmZudoJxNVhng7B6wtWdzAtQOipcF1329wS44doK/BAkyP1pvgZOsrbnGXArAg34G2IsD1eMRe7bi7k5YnqFT9V0csyPedQyYD3p/Fje+hDpskq/MwpRBC6yKp2MAAAQdSURBVHja7Zn1exMxGIAPHbrhDsPdneHuNtzd3d3dIbjLh93o2o4i7TpgG1Jk0g0mMNwd/gTa5rq129reHnK5e/bk/TFNk/dJ7r5894XjGAwGg8GgTZasCpDIll1+hxw5vXLJLpEboTx5ZXbIhyzkl9fB28cqUaCgrBKFkI3CcjoUKYolihWXUSI7EihRUjaHXF52CVRKLoe8eZIdUOkyMknkRw6UlcehYAFHiXK+skgURk6Ul8OhQjFnCVRRBolKqRxQ5SzUHaqgNGSj7VCmalqJnDkoS5RF6ZCbroNvufQkUD6qEuXTdUA+3hQdqiEXVKfnUKOmK4latalJ1EEuoZZ6162HJ9x/4OChw0eOHj12/MTJU6dxG7XUu751tjNnz4ET5y9ctLZTSr0beKFLl89bpuUDrqgC1RqNWqsKuqqzNFw7e51S6u3tc+OmZUJ9kCHY6ECwOkRvab51iUrqXej2HYDQsHBjWgx3Ae7dppB6N2wEcF9jdMGDUIDGTaR2aNoM9FqjG7QmaN5CWgc/gIePjG559BigpZQOrYB/4jBfRGRUtDkmJjY6KjLCofkpD62lc2gDfMpWPIuLdwyV8XEpHgaddBZ+wBuSFcwJqSN2ovmZ/dfnOvCTxqGtwzq8SEjv4EhISn48eWgnhUP7DvDSvgzxrs6vV6+FLiro2EkCic4QKkzwJsH1KYreCp0eQhfyDl1B/w4P/xa5JVJ4U03QjbRD9x7wXlgH5IE3wmMBHXoSlugFAcI6f/AkkSi8q6HQm6xDn77wEQ8djTwSj3tqAMguRTe4ikeOQyJ4YV+KfkQl+oNW5GbY4gWOWgbwJ+kwAD6Fi90MK2ZsrIeBBCUGwRXbqJ+/iJMQliIEBhOU6AJhtlG/IpHE2bqrYQg5h6HA4yQiRqwEfkGCdTCMmMRw+IbPDCQaHCsCYAQxiZHw3TbmD/ESOHgHwShiEqPhp/gggYkSztIxxCRawy/bmEniJaJtfwiEscQkxkFgRqJESqQwwHhiEuMBp3Vm8RK/cZoHEzKXhCK2QxEPpiJe0YlKCFaKCNv/cYBNUsBRPlkJSc0U+dM7E9H0ThGJbgZT/iR7yj+VqMS06Qr4+OFm2JdCxIa8lugzkJs5K6MfxAaYPUcBpYG5khZJEkUUSb7DPCnKRfPBXj6M8FwuegoLpCgXcQszVjhbJFUJUee2hBhLoYTIcYtB57KY+opSMdVqwatSlZVj05aV//CwJLMX2DluaUcwhXm4ali2XOoLjxUrPV26zFtF4f5p0Gp310+z13BUWNvbehEXona6iAtX/zVZmtfN4WixfsNky4S6gCCVVq3RPLdfSfpv3MRRZfPoLc6Xs/5bt3EyMGzE9h07/Xft2t15z6i9+zgGg8FgMBgMBoPBYDAYDAYj8/APG67Rie8pUDsAAAAASUVORK5CYII=' export const ICON_PATH_TARGET = @@ -38,3 +41,74 @@ export function getMapInfo () { } export const IS_AMAP = getMapInfo().type === MapType.AMAP + +export function translateGeo (type, coords, skip) { + const mapInfo = getMapInfo() + const wgs84Map = [MapType.GOOGLE] + if ( + type.toUpperCase() === 'WGS84' || + wgs84Map.includes(mapInfo.type) || + skip + ) { + return Promise.resolve(coords) + } + + if (mapInfo.type === MapType.QQ) { + return new Promise((resolve, reject) => { + getJSONP( + `https://apis.map.qq.com/jsapi?qt=translate&type=1&points=${coords.longitude},${coords.latitude}&key=${mapInfo.key}&output=jsonp&pf=jsapi&ref=jsapi`, + { + callback: 'cb' + }, + res => { + if ( + 'detail' in res && + 'points' in res.detail && + res.detail.points.length + ) { + const location = res.detail.points[0] + resolve({ + longitude: location.lng, + latitude: location.lat, + altitude: coords.altitude, + accuracy: coords.accuracy, + altitudeAccuracy: coords.altitudeAccuracy, + heading: coords.heading, + speed: coords.speed + }) + } else { + reject(new Error('translate geo fail')) + } + }, + () => reject(new Error('translate geo fail')) + ) + }) + } + + if (mapInfo.type === MapType.AMAP) { + return new Promise((resolve, reject) => { + loadMaps([], () => { + window.AMap.convertFrom( + [coords.longitude, coords.latitude], + 'gps', + (_, res) => { + if (res.info === 'ok' && res.locations.length) { + const { lat, lng } = res.locations[0] + resolve({ + longitude: lng, + latitude: lat, + altitude: coords.altitude, + accuracy: coords.accuracy, + altitudeAccuracy: coords.altitudeAccuracy, + heading: coords.heading, + speed: coords.speed + }) + } else { + reject(new Error('translate geo fail')) + } + } + ) + }) + }) + } +} diff --git a/src/platforms/h5/service/api/location/get-location.js b/src/platforms/h5/service/api/location/get-location.js index 64f40c434eccaf3a8a8e7e0cb6ba3bfbb97f4936..20eaa2db37a2989d4ede34c0f730a59c1ccce88a 100644 --- a/src/platforms/h5/service/api/location/get-location.js +++ b/src/platforms/h5/service/api/location/get-location.js @@ -3,9 +3,9 @@ import { } from '../../../helpers/get-jsonp' import { MapType, - getMapInfo + getMapInfo, + translateGeo } from '../../../helpers/location' -import { loadMaps } from '../../../view/components/map/maps' /** * 获取定位信息 @@ -73,62 +73,22 @@ export function getLocation ({ } }) }).then((coords, skip) => { - const wgs84Map = [MapType.GOOGLE] - if (type.toUpperCase() === 'WGS84' || wgs84Map.includes(mapInfo.type) || skip) { - return coords - } - - if (mapInfo.type === MapType.QQ) { - return new Promise((resolve) => { - getJSONP(`https://apis.map.qq.com/jsapi?qt=translate&type=1&points=${coords.longitude},${coords.latitude}&key=${mapInfo.key}&output=jsonp&pf=jsapi&ref=jsapi`, { - callback: 'cb' - }, (res) => { - if ('detail' in res && 'points' in res.detail && res.detail.points.length) { - const location = res.detail.points[0] - resolve(Object.assign({}, coords, { - longitude: location.lng, - latitude: location.lat - })) - } else { - resolve(coords) - } - }, () => resolve(coords)) + translateGeo(type, coords, skip) + .then(coords => { + invoke( + callbackId, + Object.assign(coords, { + errMsg: 'getLocation:ok', + verticalAccuracy: coords.altitudeAccuracy || 0, + // 无专门水平精度,使用位置精度替代 + horizontalAccuracy: coords.accuracy + }) + ) }) - } - - if (mapInfo.type === MapType.AMAP) { - return new Promise((resolve) => { - loadMaps([], () => { - window.AMap.convertFrom( - [coords.longitude, coords.latitude], - 'gps', - (_, res) => { - if (res.info === 'ok' && res.locations.length) { - const { lat, lng } = res.locations[0] - resolve( - Object.assign({}, coords, { - longitude: lng, - latitude: lat - }) - ) - } else { - resolve(coords) - } - } - ) + .catch(error => { + invoke(callbackId, { + errMsg: 'getLocation:fail ' + error.message }) }) - } - }).then(coords => { - invoke(callbackId, Object.assign(coords, { - errMsg: 'getLocation:ok', - verticalAccuracy: coords.altitudeAccuracy || 0, - // 无专门水平精度,使用位置精度替代 - horizontalAccuracy: coords.accuracy - })) - }).catch(error => { - invoke(callbackId, { - errMsg: 'getLocation:fail ' + error.message - }) }) } diff --git a/src/platforms/h5/service/api/location/location-change.js b/src/platforms/h5/service/api/location/location-change.js new file mode 100644 index 0000000000000000000000000000000000000000..8f412434085b552c1def8c97e1bc88060f064cfa --- /dev/null +++ b/src/platforms/h5/service/api/location/location-change.js @@ -0,0 +1,96 @@ +import { translateGeo } from '../../../helpers/location' + +const { invokeCallbackHandler: invoke } = UniServiceJSBridge +const callbackIds = [] +const callbackOnErrorIds = [] +const callbackOffErrorIds = [] +let watchId + +/** + * 开始更新定位 + */ +export function startLocationUpdate ({ type = 'wgs84' }) { + if (navigator.geolocation) { + watchId = navigator.geolocation.watchPosition( + res => { + translateGeo(type, res.coords) + .then((coords) => { + callbackIds.forEach(callbackId => { + invoke(callbackId, coords) + }) + }).catch(error => { + callbackOnErrorIds.forEach(callbackId => { + invoke(callbackId, { + errMsg: 'onLocationChange:fail' + error.message + }) + }) + }) + }, + error => { + callbackOnErrorIds.forEach(callbackId => { + invoke(callbackId, { + errMsg: 'onLocationChange:fail' + error.message + }) + }) + } + ) + } else { + callbackOnErrorIds.forEach(callbackId => { + invoke(callbackId, { + errMsg: 'onLocationChange:fail device nonsupport geolocation' + }) + }) + } +} + +/** + * 暂停更新定位 + * @param {*} callbackId + */ +export function stopLocationUpdate (callbackId) { + if (watchId) { + navigator.geolocation.clearWatch(watchId) + } else { + invoke(callbackId, { errMsg: 'stopLocationUpdate:fail' }) + } + return {} +} + +/** + * 监听更新定位 + * @param {*} callbackId + */ +export function onLocationChange (callbackId) { + callbackIds.push(callbackId) +} + +/** + * 监听更新定位失败 + * @param {*} callbackId + */ +export function onLocationChangeError (callbackId) { + callbackOnErrorIds.push(callbackId) +} + +// 移除实时地理位置变化事件的监听函数 +export function offLocationChange (callbackId) { + if (callbackId) { + const index = callbackIds.indexOf(callbackId) + if (index >= 0) { + callbackIds.splice(index, 1) + } else { + callbackOffErrorIds.forEach(callbackId => { + invoke(callbackId, { + errMsg: 'offLocationChange:fail' + }) + }) + } + } else { + callbackIds.length = 0 + } +} + +// 移除实时地理位置变化事件的监听函数 +export function offLocationChangeError (callbackId) { + callbackOffErrorIds.push(callbackId) +} diff --git a/src/platforms/h5/service/api/media/preview-image.js b/src/platforms/h5/service/api/media/preview-image.js index b508424506355bdfd83fbb80934a4794f675b5ed..0f78fe7e760f6db0e5e654dec3a2b8fbf95691a5 100644 --- a/src/platforms/h5/service/api/media/preview-image.js +++ b/src/platforms/h5/service/api/media/preview-image.js @@ -1,39 +1,20 @@ const { + emit, invokeCallbackHandler: invoke } = UniServiceJSBridge -export function previewImage ({ - urls, - current -}, callbackId) { - getApp().$router.push({ - type: 'navigateTo', - path: '/preview-image', - params: { - urls, - current - } - }, function () { +export function previewImage (args, callbackId) { + emit('onShowPreviewImage', args, function (res) { invoke(callbackId, { errMsg: 'previewImage:ok' }) - }, function () { - invoke(callbackId, { - errMsg: 'previewImage:fail' - }) }) } export function closePreviewImage (_, callbackId) { - const $router = getApp().$router - if ($router.history.current.path === '/preview-image') { - $router.back() + emit('onClosePreviewImage', function () { invoke(callbackId, { errMsg: 'closePreviewImage:ok' }) - } else { - invoke(callbackId, { - errMsg: 'closePreviewImage:fail' - }) - } + }) } diff --git a/src/platforms/h5/view/components/map/map-control.js b/src/platforms/h5/view/components/map/map-control.js deleted file mode 100644 index 6bed9e0fd7d766b326478071eb5e08198c1d6f39..0000000000000000000000000000000000000000 --- a/src/platforms/h5/view/components/map/map-control.js +++ /dev/null @@ -1,90 +0,0 @@ -import getRealPath from 'uni-platform/helpers/get-real-path' - -export default { - props: { - id: { - type: [Number, String], - default: '' - }, - position: { - type: Object, - require: true - }, - iconPath: { - type: String, - require: true - }, - clickable: { - type: Boolean, - default: false - } - }, - data () { - return { - control: null - } - }, - watch: { - props: function () { - this.updateControl() - } - }, - mounted () { - this.$parent.mapReady(() => { - this.addControl() - }) - }, - beforeDestroy () { - this.removeControl() - }, - methods: { - addControl () { - this.control = document.createElement('div') - const style = this.control.style - style.position = 'absolute' - style.width = 0 - style.height = 0 - style.top = 0 - style.left = 0 - style.zIndex = 999 - const img = new Image() - img.src = getRealPath(this.iconPath) - img.onload = () => { - if (this.position.width) { - img.width = this.position.width - } - if (this.position.height) { - img.height = this.position.height - } - const style = img.style - style.position = 'absolute' - style.left = (this.position.left || 0) + 'px' - style.top = (this.position.top || 0) + 'px' - style.maxWidth = 'initial' - - this.control.appendChild(img) - this.$parent.$el.appendChild(this.control) - } - img.onclick = ($event) => { - if (this.clickable) { - this.$parent.$trigger('controltap', $event, { - controlId: this.id - }) - } - $event.stopPropagation() - } - }, - updateControl () { - this.removeControl() - this.addControl() - }, - removeControl () { - if (this.control) { - this.control.remove() - } - } - }, - render () { - return null - } -} diff --git a/src/platforms/h5/view/components/map/map-control.vue b/src/platforms/h5/view/components/map/map-control.vue new file mode 100644 index 0000000000000000000000000000000000000000..f63dae1660bfa23abd06474b6dca1a183bacbec6 --- /dev/null +++ b/src/platforms/h5/view/components/map/map-control.vue @@ -0,0 +1,76 @@ + + + + + diff --git a/src/platforms/h5/view/components/picker/index.vue b/src/platforms/h5/view/components/picker/index.vue index a52b1f6a3d3f87b498bd0c4e9e3a7c2ea3752922..3d78fb19ebb86ccc741bcc37710df7dbdbcf21c9 100644 --- a/src/platforms/h5/view/components/picker/index.vue +++ b/src/platforms/h5/view/components/picker/index.vue @@ -129,7 +129,7 @@ function getDefaultStartValue () { return '00:00' } if (this.mode === mode.DATE) { - const year = new Date().getFullYear() - 100 + const year = new Date().getFullYear() - 150 switch (this.fields) { case fields.YEAR: return year.toString() @@ -147,7 +147,7 @@ function getDefaultEndValue () { return '23:59' } if (this.mode === mode.DATE) { - const year = new Date().getFullYear() + 100 + const year = new Date().getFullYear() + 150 switch (this.fields) { case fields.YEAR: return year.toString() @@ -160,6 +160,29 @@ function getDefaultEndValue () { return '' } +function getYearStartEnd (props) { + const year = new Date().getFullYear() + let start = year - 61 + let end = year + 61 + if (props.start) { + const _year = new Date(props.start).getFullYear() + if (!isNaN(_year) && _year < start) { + start = _year + } + } + if (props.end) { + const _year = new Date(props.start).getFullYear() + if (!isNaN(_year) && _year > end) { + end = _year + } + } + + return { + start, + end + } +} + const mode = { SELECTOR: 'selector', MULTISELECTOR: 'multiSelector', @@ -427,8 +450,8 @@ export default { }, _createDate () { var years = [] - var year = new Date().getFullYear() - for (let i = year - 150, end = year + 150; i <= end; i++) { + var year = getYearStartEnd(this) + for (let i = year.start, end = year.end; i <= end; i++) { years.push(String(i)) } var months = [] diff --git a/src/platforms/mp-alipay/runtime/wrapper/component-parser.js b/src/platforms/mp-alipay/runtime/wrapper/component-parser.js index 9cc232f0bd9166f5441309fb218b7170eff65a56..dda935c2da3eb5a108d3532778d2e53b2148e5e5 100644 --- a/src/platforms/mp-alipay/runtime/wrapper/component-parser.js +++ b/src/platforms/mp-alipay/runtime/wrapper/component-parser.js @@ -101,7 +101,7 @@ function initVm (VueComponent) { } } -export default function parseComponent (vueComponentOptions) { +export default function parseComponent (vueComponentOptions, needVueOptions) { const [VueComponent, vueOptions] = initVueComponent(Vue, vueComponentOptions) const properties = initProperties(vueOptions.props, false, vueOptions.__file) @@ -164,5 +164,5 @@ export default function parseComponent (vueComponentOptions) { }) } - return componentOptions + return needVueOptions ? [componentOptions, vueOptions] : componentOptions } diff --git a/src/platforms/mp-alipay/runtime/wrapper/page-parser.js b/src/platforms/mp-alipay/runtime/wrapper/page-parser.js index 11c0fe59194f8412fc89fb5284e8449907a7b10e..f6e1af47a22d0212fe6a36f07544331b0849b6b6 100644 --- a/src/platforms/mp-alipay/runtime/wrapper/page-parser.js +++ b/src/platforms/mp-alipay/runtime/wrapper/page-parser.js @@ -93,8 +93,10 @@ export default function parsePage (vuePageOptions) { triggerEvent } - initHooks(pageOptions, hooks, vuePageOptions) - initUnknownHooks(pageOptions, vuePageOptions, ['onReady']) + Object.assign(pageOptions.events, vueOptions.events || {}) + + initHooks(pageOptions, hooks, vueOptions) + initUnknownHooks(pageOptions, vueOptions, ['onReady']) if (Array.isArray(vueOptions.wxsCallMethods)) { vueOptions.wxsCallMethods.forEach(callMethod => { diff --git a/src/platforms/mp-alipay/runtime/wrapper/util.js b/src/platforms/mp-alipay/runtime/wrapper/util.js index 1b3e3e9f1c54e0968c49d94a9d381b720932e544..508e949e0ec3caf228db245b0c5f8c8469e53c3d 100644 --- a/src/platforms/mp-alipay/runtime/wrapper/util.js +++ b/src/platforms/mp-alipay/runtime/wrapper/util.js @@ -141,7 +141,7 @@ function handleProps (ref) { } export function handleRef (ref) { - if (!ref) { + if (!(ref && this.$vm)) { return } if (ref.props['data-com-type'] === 'wx') { diff --git a/src/platforms/mp-baidu/runtime/api/index.js b/src/platforms/mp-baidu/runtime/api/index.js index 1d88c0b99427b04b90b50adadf8a0389b1d7759b..204de79da4b212eeea7212f1fec0d8aece47b2dd 100644 --- a/src/platforms/mp-baidu/runtime/api/index.js +++ b/src/platforms/mp-baidu/runtime/api/index.js @@ -24,6 +24,14 @@ export function requestPayment (params) { } } +export function createIntersectionObserver (component, options) { + if (options && options.observeAll) { + options.selectAll = options.observeAll + delete options.observeAll + } + return swan.createIntersectionObserver(component, options) +} + export { createMediaQueryObserver } diff --git a/src/platforms/mp-baidu/runtime/wrapper/component-parser.js b/src/platforms/mp-baidu/runtime/wrapper/component-parser.js index cda77ff0670abcc040367c8e8f1aebaaf61dca64..552a7f219ebdda1fac9f39ab52c0110cb7674486 100644 --- a/src/platforms/mp-baidu/runtime/wrapper/component-parser.js +++ b/src/platforms/mp-baidu/runtime/wrapper/component-parser.js @@ -25,11 +25,11 @@ import parseBaseComponent from '../../../mp-weixin/runtime/wrapper/component-bas const newLifecycle = swan.canIUse('lifecycle-2-0') -export default function parseComponent (vueOptions) { - const componentOptions = parseBaseComponent(vueOptions, { +export default function parseComponent (vueComponentOptions, needVueOptions) { + const [componentOptions, vueOptions] = parseBaseComponent(vueComponentOptions, { isPage, initRelation - }) + }, true) // 关于百度小程序生命周期的说明(组件作为页面时): // lifetimes:attached --> methods:onShow --> methods:onLoad --> methods:onReady @@ -90,5 +90,5 @@ export default function parseComponent (vueOptions) { } delete componentOptions.methods.__l - return componentOptions + return needVueOptions ? [componentOptions, vueOptions] : componentOptions } diff --git a/src/platforms/mp-baidu/runtime/wrapper/page-parser.js b/src/platforms/mp-baidu/runtime/wrapper/page-parser.js index fec3bddfeb5f558f9e27549be91945b6299422fc..440f71b94d7e935659abab745ed2776910b63b35 100644 --- a/src/platforms/mp-baidu/runtime/wrapper/page-parser.js +++ b/src/platforms/mp-baidu/runtime/wrapper/page-parser.js @@ -2,11 +2,6 @@ import { stringifyQuery } from 'uni-shared/query' -import { - isPage, - initRelation -} from './util' - import parseBasePage from '../../../mp-weixin/runtime/wrapper/page-base-parser' function detached ($vm) { @@ -24,10 +19,7 @@ function onPageUnload ($vm) { } export default function parsePage (vuePageOptions) { - const pageOptions = parseBasePage(vuePageOptions, { - isPage, - initRelation - }) + const pageOptions = parseBasePage(vuePageOptions) // 纠正百度小程序生命周期methods:onShow在methods:onLoad之前触发的问题 pageOptions.methods.onShow = function onShow () { diff --git a/src/platforms/mp-jd/runtime/wrapper/component-parser.js b/src/platforms/mp-jd/runtime/wrapper/component-parser.js index 26dbc9c5442b64ee1f54ee73c1d488b8ca3428f9..9cc9403315ba6bb457d69ecdb8be3b3ea5d8f9d4 100644 --- a/src/platforms/mp-jd/runtime/wrapper/component-parser.js +++ b/src/platforms/mp-jd/runtime/wrapper/component-parser.js @@ -1,11 +1,11 @@ import parseBaseComponent from '../../../mp-weixin/runtime/wrapper/component-parser' -export default function parseComponent (vueComponentOptions) { - const componentOptions = parseBaseComponent(vueComponentOptions) +export default function parseComponent (vueComponentOptions, needVueOptions) { + const [componentOptions, vueOptions] = parseBaseComponent(vueComponentOptions, true) // 京东小程序 lifetimes 存在兼容问题 const lifetimes = componentOptions.lifetimes Object.keys(lifetimes).forEach(key => { componentOptions[key] = lifetimes[key] }) - return componentOptions + return needVueOptions ? [componentOptions, vueOptions] : componentOptions } diff --git a/src/platforms/mp-jd/runtime/wrapper/util.js b/src/platforms/mp-jd/runtime/wrapper/util.js deleted file mode 100644 index 7fb3ce5b6424fafddaad76e77271e9d6072c1a0e..0000000000000000000000000000000000000000 --- a/src/platforms/mp-jd/runtime/wrapper/util.js +++ /dev/null @@ -1,86 +0,0 @@ -export const mocks = ['__route__', '__wxExparserNodeId__', '__wxWebviewId__'] - -export function findVmByVueId (vm, vuePid) { - const $children = vm.$children - // 优先查找直属(反向查找:https://github.com/dcloudio/uni-app/issues/1200) - for (let i = $children.length - 1; i >= 0; i--) { - const childVm = $children[i] - if (childVm.$scope._$vueId === vuePid) { - return childVm - } - } - // 反向递归查找 - let parentVm - for (let i = $children.length - 1; i >= 0; i--) { - parentVm = findVmByVueId($children[i], vuePid) - if (parentVm) { - return parentVm - } - } -} - -export function initBehavior (options) { - return Behavior(options) -} - -export function isPage () { - return !!this.route -} - -export function initRelation (detail) { - this.triggerEvent('__l', detail) -} - -function selectAllComponents (mpInstance, selector, $refs) { - const components = mpInstance.selectAllComponents(selector) - components.forEach(component => { - const ref = component.dataset.ref - $refs[ref] = component.$vm || component - if (__PLATFORM__ === 'mp-weixin') { - if (component.dataset.vueGeneric === 'scoped') { - component.selectAllComponents('.scoped-ref').forEach(scopedComponent => { - selectAllComponents(scopedComponent, selector, $refs) - }) - } - } - }) -} - -export function initRefs (vm) { - const mpInstance = vm.$scope - Object.defineProperty(vm, '$refs', { - get () { - const $refs = {} - selectAllComponents(mpInstance, '.vue-ref', $refs) - // TODO 暂不考虑 for 中的 scoped - const forComponents = mpInstance.selectAllComponents('.vue-ref-in-for') - forComponents.forEach(component => { - const ref = component.dataset.ref - if (!$refs[ref]) { - $refs[ref] = [] - } - $refs[ref].push(component.$vm || component) - }) - return $refs - } - }) -} - -export function handleLink (event) { - const { - vuePid, - vueOptions - } = event.detail || event.value // detail 是微信,value 是百度(dipatch) - - let parentVm - - if (vuePid) { - parentVm = findVmByVueId(this.$vm, vuePid) - } - - if (!parentVm) { - parentVm = this.$vm - } - - vueOptions.parent = parentVm -} diff --git a/src/platforms/mp-kuaishou/runtime/api/protocols.js b/src/platforms/mp-kuaishou/runtime/api/protocols.js index fd596f57ee81d449adf33a95c783a2358c07d688..efb6abaf4d07d5c8a62e0b15a5298e563eac791e 100644 --- a/src/platforms/mp-kuaishou/runtime/api/protocols.js +++ b/src/platforms/mp-kuaishou/runtime/api/protocols.js @@ -10,7 +10,16 @@ export const protocols = { previewImage, getSystemInfo, getSystemInfoSync: getSystemInfo, - getUserProfile + getUserProfile, + requestPayment: { + name: ks.pay ? 'pay' : 'requestPayment', + args (fromArgs) { + if (typeof fromArgs === 'object') { + // ks.pay 服务类型 id(固定值为 '1') + if (ks.pay && !fromArgs.serviceId) fromArgs.serviceId = '1' + } + } + } } export const todos = [ 'vibrate' diff --git a/src/platforms/mp-kuaishou/runtime/wrapper/component-parser.js b/src/platforms/mp-kuaishou/runtime/wrapper/component-parser.js index fd3ebae87ec19f04a4e30b0463da0c6b54c7efc4..20de859168ede61230457a3ddc1757e5ee3b0f5f 100644 --- a/src/platforms/mp-kuaishou/runtime/wrapper/component-parser.js +++ b/src/platforms/mp-kuaishou/runtime/wrapper/component-parser.js @@ -7,8 +7,8 @@ import { fixSetDataEnd } from '../../../mp-weixin/runtime/wrapper/fix-set-data' -export default function parseComponent (vueComponentOptions) { - const componentOptions = parseBaseComponent(vueComponentOptions) +export default function parseComponent (vueComponentOptions, needVueOptions) { + const [componentOptions, vueOptions] = parseBaseComponent(vueComponentOptions, true) const oldAttached = componentOptions.lifetimes.attached componentOptions.lifetimes.attached = function attached () { // 暂不区分版本 @@ -21,5 +21,5 @@ export default function parseComponent (vueComponentOptions) { } oldAttached.call(this) } - return componentOptions + return needVueOptions ? [componentOptions, vueOptions] : componentOptions } diff --git a/src/platforms/mp-lark/runtime/wrapper/component-parser.js b/src/platforms/mp-lark/runtime/wrapper/component-parser.js index 9d78729c8c9d3a856f7dd9d16088a0e804d7bd82..0353bb3e9783c893091343bfc21c3efce5a0fdf5 100644 --- a/src/platforms/mp-lark/runtime/wrapper/component-parser.js +++ b/src/platforms/mp-lark/runtime/wrapper/component-parser.js @@ -11,8 +11,11 @@ import { import parseBaseComponent from '../../../mp-weixin/runtime/wrapper/component-base-parser' -export default function parseComponent (vueOptions) { - const [componentOptions, VueComponent] = parseBaseComponent(vueOptions) +export default function parseComponent (vueComponentOptions, needVueOptions) { + const [componentOptions, vueOptions, VueComponent] = parseBaseComponent(vueComponentOptions, { + isPage, + initRelation + }, true) componentOptions.lifetimes.attached = function attached () { const properties = this.properties @@ -46,5 +49,5 @@ export default function parseComponent (vueOptions) { componentOptions.methods.__l = handleLink - return componentOptions + return needVueOptions ? [componentOptions, vueOptions] : componentOptions } diff --git a/src/platforms/mp-lark/runtime/wrapper/page-parser.js b/src/platforms/mp-lark/runtime/wrapper/page-parser.js index 6598851b0a2982bd538f235064b7cd82f9db1f8b..54d6306521c597c57f33402742281d14b723d2a2 100644 --- a/src/platforms/mp-lark/runtime/wrapper/page-parser.js +++ b/src/platforms/mp-lark/runtime/wrapper/page-parser.js @@ -1,16 +1,11 @@ import { - isPage, - instances, - initRelation + instances } from './util' import parseBasePage from '../../../mp-weixin/runtime/wrapper/page-base-parser' export default function parsePage (vuePageOptions) { - const pageOptions = parseBasePage(vuePageOptions, { - isPage, - initRelation - }) + const pageOptions = parseBasePage(vuePageOptions) // 页面需要在 ready 中触发,其他组件是在 handleLink 中触发 pageOptions.lifetimes.ready = function ready () { if (this.$vm && this.$vm.mpType === 'page') { diff --git a/src/platforms/mp-qq/runtime/wrapper/component-parser.js b/src/platforms/mp-qq/runtime/wrapper/component-parser.js index 49f48ab77ac78a39bc37f665775e616a3d43bdfc..a9ab1cbe09343d1a948cb093ab840cfe067acaac 100644 --- a/src/platforms/mp-qq/runtime/wrapper/component-parser.js +++ b/src/platforms/mp-qq/runtime/wrapper/component-parser.js @@ -1,5 +1,5 @@ import parseBaseComponent from '../../../mp-weixin/runtime/wrapper/component-parser' -export default function parseComponent (vueComponentOptions) { - return parseBaseComponent(vueComponentOptions) -} +export default function parseComponent (vueComponentOptions, needVueOptions) { + return parseBaseComponent(vueComponentOptions, needVueOptions) +} diff --git a/src/platforms/mp-toutiao/runtime/wrapper/component-parser.js b/src/platforms/mp-toutiao/runtime/wrapper/component-parser.js index be28d0313c4a1bd90f0080bc117656caad8a4bd8..91438fe5b7f9bddb2e36b07a31936da4a868b11a 100644 --- a/src/platforms/mp-toutiao/runtime/wrapper/component-parser.js +++ b/src/platforms/mp-toutiao/runtime/wrapper/component-parser.js @@ -20,8 +20,11 @@ function currentComponents (mpInstance, callback) { } } -export default function parseComponent (vueOptions) { - const [componentOptions, VueComponent] = parseBaseComponent(vueOptions) +export default function parseComponent (vueComponentOptions, needVueOptions) { + const [componentOptions, vueOptions, VueComponent] = parseBaseComponent(vueComponentOptions, { + isPage, + initRelation + }, true) const lifetimes = componentOptions.lifetimes // 基础库 2.0 以上 attached 顺序错乱,按照 created 顺序强制纠正 @@ -87,5 +90,5 @@ export default function parseComponent (vueOptions) { componentOptions.methods.__l = handleLink - return componentOptions + return needVueOptions ? [componentOptions, vueOptions] : componentOptions } diff --git a/src/platforms/mp-toutiao/runtime/wrapper/page-parser.js b/src/platforms/mp-toutiao/runtime/wrapper/page-parser.js index 4776891a4cb033286997ed247d77e4f96069e7d0..2701ff821ed3e45b0b3689909bb5151a0c571265 100644 --- a/src/platforms/mp-toutiao/runtime/wrapper/page-parser.js +++ b/src/platforms/mp-toutiao/runtime/wrapper/page-parser.js @@ -1,17 +1,12 @@ import { - isPage, instances, - components, - initRelation + components } from './util' import parseBasePage from '../../../mp-weixin/runtime/wrapper/page-base-parser' export default function parsePage (vuePageOptions) { - const pageOptions = parseBasePage(vuePageOptions, { - isPage, - initRelation - }) + const pageOptions = parseBasePage(vuePageOptions) const lifetimes = pageOptions.lifetimes const oldCreated = lifetimes.created lifetimes.created = function created () { diff --git a/src/platforms/mp-toutiao/runtime/wrapper/util.js b/src/platforms/mp-toutiao/runtime/wrapper/util.js index 44aadf0c4227c8747508e1fc689b9e82ade0e31c..6169f43131fc52ea5bef9f193e905540df5d43fa 100644 --- a/src/platforms/mp-toutiao/runtime/wrapper/util.js +++ b/src/platforms/mp-toutiao/runtime/wrapper/util.js @@ -1,5 +1,6 @@ import { - findVmByVueId + findVmByVueId, + initRefs as initRefsBase } from '../../../mp-weixin/runtime/wrapper/util' export const mocks = ['__route__', '__webviewId__', '__nodeid__', '__nodeId__'] @@ -13,26 +14,7 @@ export function initRefs (vm) { /* eslint-disable no-undef */ const minorVersion = parseInt(tt.getSystemInfoSync().SDKVersion.split('.')[1]) if (minorVersion > 16) { - Object.defineProperty(vm, '$refs', { - get () { - const $refs = {} - // mpInstance 销毁后 selectAllComponents 取值为 null - const components = mpInstance.selectAllComponents('.vue-ref') || [] - components.forEach(component => { - const ref = component.dataset.ref - $refs[ref] = component.$vm || component - }) - const forComponents = mpInstance.selectAllComponents('.vue-ref-in-for') || [] - forComponents.forEach(component => { - const ref = component.dataset.ref - if (!$refs[ref]) { - $refs[ref] = [] - } - $refs[ref].push(component.$vm || component) - }) - return $refs - } - }) + initRefsBase(vm) } else { mpInstance.selectAllComponents('.vue-ref', (components) => { components.forEach(component => { diff --git a/src/platforms/mp-weixin/runtime/wrapper/component-base-parser.js b/src/platforms/mp-weixin/runtime/wrapper/component-base-parser.js index 44fa0299f927111b439e1cd3c5dbb32ff875151a..deb711b15a90c7cffbbe8ab3f137c1099f462d97 100644 --- a/src/platforms/mp-weixin/runtime/wrapper/component-base-parser.js +++ b/src/platforms/mp-weixin/runtime/wrapper/component-base-parser.js @@ -18,7 +18,7 @@ import { export default function parseBaseComponent (vueComponentOptions, { isPage, initRelation -} = {}) { +} = {}, needVueOptions) { const [VueComponent, vueOptions] = initVueComponent(Vue, vueComponentOptions) const options = { @@ -110,6 +110,9 @@ export default function parseBaseComponent (vueComponentOptions, { }) } + if (needVueOptions) { + return [componentOptions, vueOptions, VueComponent] + } if (isPage) { return componentOptions } diff --git a/src/platforms/mp-weixin/runtime/wrapper/component-parser.js b/src/platforms/mp-weixin/runtime/wrapper/component-parser.js index e84b4456e72a258b95e6e4496d8f6c9b1a6a6298..e58620446eff25203f968f27d4f463791da17069 100644 --- a/src/platforms/mp-weixin/runtime/wrapper/component-parser.js +++ b/src/platforms/mp-weixin/runtime/wrapper/component-parser.js @@ -5,9 +5,9 @@ import { initRelation } from './util' -export default function parseComponent (vueComponentOptions) { +export default function parseComponent (vueComponentOptions, needVueOptions) { return parseBaseComponent(vueComponentOptions, { isPage, initRelation - }) -} + }, needVueOptions) +} diff --git a/src/platforms/mp-weixin/runtime/wrapper/page-base-parser.js b/src/platforms/mp-weixin/runtime/wrapper/page-base-parser.js index e8fe85ef6f34a4af97629f5cade06b259bc5ff5d..6b9064265c53b2bf5d795a5ddbbae70b84f34cd8 100644 --- a/src/platforms/mp-weixin/runtime/wrapper/page-base-parser.js +++ b/src/platforms/mp-weixin/runtime/wrapper/page-base-parser.js @@ -18,16 +18,10 @@ const hooks = [ hooks.push(...PAGE_EVENT_HOOKS) -export default function parseBasePage (vuePageOptions, { - isPage, - initRelation -}) { - const pageOptions = parseComponent(vuePageOptions, { - isPage, - initRelation - }) - - initHooks(pageOptions.methods, hooks, vuePageOptions) +export default function parseBasePage (vuePageOptions) { + const [pageOptions, vueOptions] = parseComponent(vuePageOptions, true) + + initHooks(pageOptions.methods, hooks, vueOptions) pageOptions.methods.onLoad = function (query) { this.options = query diff --git a/src/platforms/mp-weixin/runtime/wrapper/page-parser.js b/src/platforms/mp-weixin/runtime/wrapper/page-parser.js index 0a64ca8610c4c4a8152bb1a8ddbda6644ee9636f..26c762f98ce07ae744d3294b1159d5ed35751173 100644 --- a/src/platforms/mp-weixin/runtime/wrapper/page-parser.js +++ b/src/platforms/mp-weixin/runtime/wrapper/page-parser.js @@ -1,13 +1,5 @@ import parseBasePage from './page-base-parser' -import { - isPage, - initRelation -} from './util' - export default function parsePage (vuePageOptions) { - return parseBasePage(vuePageOptions, { - isPage, - initRelation - }) -} + return parseBasePage(vuePageOptions) +} diff --git a/src/platforms/mp-weixin/runtime/wrapper/util.js b/src/platforms/mp-weixin/runtime/wrapper/util.js index 34abec9b16c4be414397b07f491837d242cb618b..877a1e45c84de7a525228eebbb34fb45eb465a81 100644 --- a/src/platforms/mp-weixin/runtime/wrapper/util.js +++ b/src/platforms/mp-weixin/runtime/wrapper/util.js @@ -32,7 +32,7 @@ export function initRelation (detail) { } function selectAllComponents (mpInstance, selector, $refs) { - const components = mpInstance.selectAllComponents(selector) + const components = mpInstance.selectAllComponents(selector) || [] components.forEach(component => { const ref = component.dataset.ref $refs[ref] = component.$vm || component @@ -46,14 +46,33 @@ function selectAllComponents (mpInstance, selector, $refs) { }) } +export function syncRefs (refs, newRefs) { + const oldKeys = new Set(...Object.keys(refs)) + const newKeys = Object.keys(newRefs) + newKeys.forEach(key => { + const oldValue = refs[key] + const newValue = newRefs[key] + if (Array.isArray(oldValue) && Array.isArray(newValue) && oldValue.length === newValue.length && newValue.every(value => oldValue.includes(value))) { + return + } + refs[key] = newValue + oldKeys.delete(key) + }) + oldKeys.forEach(key => { + delete refs[key] + }) + return refs +} + export function initRefs (vm) { const mpInstance = vm.$scope + const refs = {} Object.defineProperty(vm, '$refs', { get () { const $refs = {} selectAllComponents(mpInstance, '.vue-ref', $refs) // TODO 暂不考虑 for 中的 scoped - const forComponents = mpInstance.selectAllComponents('.vue-ref-in-for') + const forComponents = mpInstance.selectAllComponents('.vue-ref-in-for') || [] forComponents.forEach(component => { const ref = component.dataset.ref if (!$refs[ref]) { @@ -61,7 +80,7 @@ export function initRefs (vm) { } $refs[ref].push(component.$vm || component) }) - return $refs + return syncRefs(refs, $refs) } }) } diff --git a/src/platforms/mp-xhs/runtime/wrapper/component-parser.js b/src/platforms/mp-xhs/runtime/wrapper/component-parser.js index bd4d6f660fd05dcb8ea14067ae81c7d2ffd5e58e..7ae942b2b4019a940ef737ce1f7082f38cc4002f 100644 --- a/src/platforms/mp-xhs/runtime/wrapper/component-parser.js +++ b/src/platforms/mp-xhs/runtime/wrapper/component-parser.js @@ -19,8 +19,8 @@ import { fixSetDataEnd } from '../../../mp-weixin/runtime/wrapper/fix-set-data' -export default function parseComponent (vueComponentOptions) { - const componentOptions = parseBaseComponent(vueComponentOptions) +export default function parseComponent (vueComponentOptions, needVueOptions) { + const [componentOptions, vueOptions] = parseBaseComponent(vueComponentOptions, true) const oldAttached = componentOptions.lifetimes.attached componentOptions.lifetimes.attached = function attached () { // 暂不区分版本 @@ -32,5 +32,5 @@ export default function parseComponent (vueComponentOptions) { } oldAttached.call(this) } - return componentOptions + return needVueOptions ? [componentOptions, vueOptions] : componentOptions } diff --git a/src/platforms/mp-xhs/runtime/wrapper/page-parser.js b/src/platforms/mp-xhs/runtime/wrapper/page-parser.js index f206ca955fbea1bbaf4e771249e6f4c88595322a..3384f57f3a6c59ed1b61b82da738e18f9d179160 100644 --- a/src/platforms/mp-xhs/runtime/wrapper/page-parser.js +++ b/src/platforms/mp-xhs/runtime/wrapper/page-parser.js @@ -80,8 +80,8 @@ export default function parsePage (vuePageOptions) { triggerEvent: function noop () {} } - initHooks(pageOptions, hooks, vuePageOptions) - initUnknownHooks(pageOptions, vuePageOptions, ['onReady']) + initHooks(pageOptions, hooks, vueOptions) + initUnknownHooks(pageOptions, vueOptions, ['onReady']) if (Array.isArray(vueOptions.wxsCallMethods)) { vueOptions.wxsCallMethods.forEach(callMethod => { diff --git a/src/platforms/quickapp-webview/runtime/wrapper/component-parser.js b/src/platforms/quickapp-webview/runtime/wrapper/component-parser.js index da644ba7a93bd624af50f58f1706969a23b21a8e..0353bb3e9783c893091343bfc21c3efce5a0fdf5 100644 --- a/src/platforms/quickapp-webview/runtime/wrapper/component-parser.js +++ b/src/platforms/quickapp-webview/runtime/wrapper/component-parser.js @@ -11,8 +11,11 @@ import { import parseBaseComponent from '../../../mp-weixin/runtime/wrapper/component-base-parser' -export default function parseComponent (vueOptions) { - const [componentOptions, VueComponent] = parseBaseComponent(vueOptions) +export default function parseComponent (vueComponentOptions, needVueOptions) { + const [componentOptions, vueOptions, VueComponent] = parseBaseComponent(vueComponentOptions, { + isPage, + initRelation + }, true) componentOptions.lifetimes.attached = function attached () { const properties = this.properties @@ -46,5 +49,5 @@ export default function parseComponent (vueOptions) { componentOptions.methods.__l = handleLink - return componentOptions -} + return needVueOptions ? [componentOptions, vueOptions] : componentOptions +} diff --git a/src/platforms/quickapp-webview/runtime/wrapper/page-parser.js b/src/platforms/quickapp-webview/runtime/wrapper/page-parser.js index b02d1728fca63d3c85986ca271dbccaaec9374d5..a9345234398a86acf87886bb459357c7529a1a64 100644 --- a/src/platforms/quickapp-webview/runtime/wrapper/page-parser.js +++ b/src/platforms/quickapp-webview/runtime/wrapper/page-parser.js @@ -1,16 +1,11 @@ import { - isPage, - instances, - initRelation + instances } from './util' import parseBasePage from '../../../mp-weixin/runtime/wrapper/page-base-parser' export default function parsePage (vuePageOptions) { - const pageOptions = parseBasePage(vuePageOptions, { - isPage, - initRelation - }) + const pageOptions = parseBasePage(vuePageOptions) // 页面需要在 ready 中触发,其他组件是在 handleLink 中触发 pageOptions.lifetimes.ready = function ready () { if (this.$vm && this.$vm.mpType === 'page') {