提交 7ab8af11 编写于 作者: fxy060608's avatar fxy060608

build(deps): bump vite from 2.0.0-beta.4 to 2.0.0-beta.31

上级 2d1b746b
......@@ -11,7 +11,7 @@ module.exports = {
'error',
// we are only using this rule to check for unused arguments since TS
// catches unused variables but not args.
{ varsIgnorePattern: '.*', args: 'after-used', argsIgnorePattern: '^_' },
{ varsIgnorePattern: '.*', args: 'none' },
],
// most of the codebase are expected to be env agnostic
'no-restricted-globals': ['error', ...DOMGlobals, ...NodeGlobals],
......
uni-tabbar {
display: block;
box-sizing: border-box;
position: fixed;
left: 0;
bottom: 0;
width: 100%;
z-index: 998;
}
uni-tabbar .uni-tabbar {
display: flex;
position: fixed;
left: 0;
bottom: 0;
width: 100%;
z-index: 998;
box-sizing: border-box;
padding-bottom: 0;
padding-bottom: constant(safe-area-inset-bottom);
padding-bottom: env(safe-area-inset-bottom);
}
uni-tabbar .uni-tabbar ~ .uni-placeholder {
width: 100%;
height: 50px;
margin-bottom: 0;
margin-bottom: constant(safe-area-inset-bottom);
margin-bottom: env(safe-area-inset-bottom);
}
uni-tabbar .uni-tabbar * {
box-sizing: border-box;
}
uni-tabbar .uni-tabbar__item {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
flex: 1;
font-size: 0;
text-align: center;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
uni-tabbar .uni-tabbar__bd {
position: relative;
height: 50px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
cursor: pointer;
}
uni-tabbar .uni-tabbar__icon {
position: relative;
display: inline-block;
margin-top: 5px;
width: 24px;
height: 24px;
}
uni-tabbar .uni-tabbar__icon.uni-tabbar__icon__diff {
margin-top: 0px;
width: 34px;
height: 34px;
}
uni-tabbar .uni-tabbar__icon img {
width: 100%;
height: 100%;
}
uni-tabbar .uni-tabbar__label {
position: relative;
text-align: center;
font-size: 10px;
line-height: 1.8;
}
uni-tabbar .uni-tabbar-border {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 1px;
transform: scaleY(0.5);
}
uni-tabbar .uni-tabbar__reddot {
position: absolute;
top: 0;
right: 0;
width: 12px;
height: 12px;
border-radius: 50%;
background-color: #f43530;
color: #ffffff;
transform: translate(40%, -20%);
}
uni-tabbar .uni-tabbar__badge {
width: auto;
height: 16px;
line-height: 16px;
border-radius: 16px;
min-width: 16px;
padding: 0 2px;
font-size: 12px;
text-align: center;
white-space: nowrap;
}
uni-toast {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 999;
display: block;
box-sizing: border-box;
pointer-events: none;
}
uni-toast .uni-sample-toast {
position: fixed;
z-index: 999;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
max-width: 80%;
}
uni-toast .uni-simple-toast__text {
display: inline-block;
vertical-align: middle;
color: #ffffff;
background-color: rgba(17, 17, 17, 0.7);
padding: 10px 20px;
border-radius: 5px;
font-size: 13px;
text-align: center;
max-width: 100%;
word-break: break-all;
white-space: normal;
}
uni-toast .uni-mask {
pointer-events: auto;
}
uni-toast .uni-toast {
position: fixed;
z-index: 999;
width: 8em;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: rgba(17, 17, 17, 0.7);
text-align: center;
border-radius: 5px;
color: #ffffff;
}
uni-toast .uni-toast * {
box-sizing: border-box;
}
uni-toast .uni-toast__icon {
margin: 20px 0 0;
width: 38px;
height: 38px;
vertical-align: baseline;
}
uni-toast .uni-icon_toast {
margin: 15px 0 0;
}
uni-toast .uni-icon_toast.uni-icon-success-no-circle:before {
color: #ffffff;
font-size: 55px;
}
uni-toast .uni-icon_toast.uni-loading {
margin: 20px 0 0;
width: 38px;
height: 38px;
vertical-align: baseline;
}
uni-toast .uni-toast__content {
margin: 0 0 15px;
}
uni-modal {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 999;
display: block;
box-sizing: border-box;
}
uni-modal .uni-modal {
position: fixed;
z-index: 999;
width: 80%;
max-width: 300px;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: #ffffff;
text-align: center;
border-radius: 3px;
overflow: hidden;
}
uni-modal .uni-modal * {
box-sizing: border-box;
}
uni-modal .uni-modal__hd {
padding: 1em 1.6em 0.3em;
}
uni-modal .uni-modal__title {
font-weight: 400;
font-size: 18px;
word-wrap:break-word;
word-break:break-all;
white-space: pre-wrap;
overflow : hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
uni-modal .uni-modal__bd {
padding: 1.3em 1.6em 1.3em;
min-height: 40px;
font-size: 15px;
line-height: 1.4;
word-wrap: break-word;
word-break: break-all;
white-space: pre-wrap;
color: #999999;
max-height: 400px;
overflow-y: auto;
}
uni-modal .uni-modal__ft {
position: relative;
line-height: 48px;
font-size: 18px;
display: flex;
}
uni-modal .uni-modal__ft:after {
content: " ";
position: absolute;
left: 0;
top: 0;
right: 0;
height: 1px;
border-top: 1px solid #d5d5d6;
color: #d5d5d6;
transform-origin: 0 0;
transform: scaleY(0.5);
}
uni-modal .uni-modal__btn {
display: block;
flex: 1;
color: #3cc51f;
text-decoration: none;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
position: relative;
}
uni-modal .uni-modal__btn:active {
background-color: #eeeeee;
}
uni-modal .uni-modal__btn:after {
content: " ";
position: absolute;
left: 0;
top: 0;
width: 1px;
bottom: 0;
border-left: 1px solid #d5d5d6;
color: #d5d5d6;
transform-origin: 0 0;
transform: scaleX(0.5);
}
uni-modal .uni-modal__btn:first-child:after {
display: none;
}
uni-modal .uni-modal__btn_default {
color: #353535;
}
uni-modal .uni-modal__btn_primary {
color: #007aff;
}
uni-actionsheet {
display: block;
box-sizing: border-box;
}
uni-actionsheet .uni-actionsheet {
position: fixed;
left: 0;
bottom: 0;
transform: translate(0, 100%);
backface-visibility: hidden;
z-index: 999;
width: 100%;
background-color: #efeff4;
visibility: hidden;
transition: transform 0.3s, visibility 0.3s;
}
uni-actionsheet .uni-actionsheet.uni-actionsheet_toggle {
visibility: visible;
transform: translate(0, 0);
}
uni-actionsheet .uni-actionsheet * {
box-sizing: border-box;
}
uni-actionsheet .uni-actionsheet__menu {
background-color: #fcfcfd;
}
uni-actionsheet .uni-actionsheet__action {
margin-top: 6px;
background-color: #fcfcfd;
}
uni-actionsheet .uni-actionsheet__cell ,
uni-actionsheet .uni-actionsheet__title {
position: relative;
padding: 10px 0;
text-align: center;
font-size: 18px;
}
uni-actionsheet .uni-actionsheet__cell:before {
content: " ";
position: absolute;
left: 0;
top: 0;
right: 0;
height: 1px;
border-top: 1px solid #e5e5e5;
color: #e5e5e5;
transform-origin: 0 0;
transform: scaleY(0.5);
}
uni-actionsheet .uni-actionsheet__cell:active {
background-color: #ececec;
}
uni-actionsheet .uni-actionsheet__cell:first-child:before {
display: none;
}
* {
margin: 0;
-webkit-tap-highlight-color: transparent;
}
@font-face {
font-weight: normal;
font-style: normal;
font-family: "uni";
src: url('data:application/octet-stream;base64,AAEAAAALAIAAAwAwR1NVQrD+s+0AAAE4AAAAQk9TLzJAKEx+AAABfAAAAFZjbWFw65cFHQAAAhwAAAJQZ2x5ZvCRR/EAAASUAAAKtGhlYWQLKIN9AAAA4AAAADZoaGVhCCwD+gAAALwAAAAkaG10eEJo//8AAAHUAAAASGxvY2EYqhW6AAAEbAAAACZtYXhwASEAVQAAARgAAAAgbmFtZeNcHtgAAA9IAAAB5nBvc3T6bLhLAAARMAAAAOYAAQAAA+gAAABaA+j/////A+kAAQAAAAAAAAAAAAAAAAAAABIAAQAAAAEAACkCj3dfDzz1AAsD6AAAAADUER9XAAAAANQRH1f//wAAA+kD6gAAAAgAAgAAAAAAAAABAAAAEgBJAAUAAAAAAAIAAAAKAAoAAAD/AAAAAAAAAAEAAAAKAB4ALAABREZMVAAIAAQAAAAAAAAAAQAAAAFsaWdhAAgAAAABAAAAAQAEAAQAAAABAAgAAQAGAAAAAQAAAAAAAQOwAZAABQAIAnoCvAAAAIwCegK8AAAB4AAxAQIAAAIABQMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUGZFZABA6gHqEQPoAAAAWgPqAAAAAAABAAAAAAAAAAAAAAPoAAAD6AAAA+gAAAPoAAAD6AAAA+gAAAPoAAAD6AAAA+gAAAPoAAAD6AAAA+gAAAPoAAAD6AAAA+j//wPoAAAD6AAAAAAABQAAAAMAAAAsAAAABAAAAXQAAQAAAAAAbgADAAEAAAAsAAMACgAAAXQABABCAAAABAAEAAEAAOoR//8AAOoB//8AAAABAAQAAAABAAIAAwAEAAUABgAHAAgACQAKAAsADAANAA4ADwAQABEAAAEGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAANwAAAAAAAAAEQAA6gEAAOoBAAAAAQAA6gIAAOoCAAAAAgAA6gMAAOoDAAAAAwAA6gQAAOoEAAAABAAA6gUAAOoFAAAABQAA6gYAAOoGAAAABgAA6gcAAOoHAAAABwAA6ggAAOoIAAAACAAA6gkAAOoJAAAACQAA6goAAOoKAAAACgAA6gsAAOoLAAAACwAA6gwAAOoMAAAADAAA6g0AAOoNAAAADQAA6g4AAOoOAAAADgAA6g8AAOoPAAAADwAA6hAAAOoQAAAAEAAA6hEAAOoRAAAAEQAAAAAARgCMANIBJgF4AcQCMgJgAqgC/ANIA6YD/gROBKAE9AVaAAAAAgAAAAADrwOtABQAKQAAASIHBgcGFBcWFxYyNzY3NjQnJicmAyInJicmNDc2NzYyFxYXFhQHBgcGAfV4Z2Q7PDw7ZGfwZmQ7PDw7ZGZ4bl5bNjc3Nlte215bNjc3NlteA608O2Rn8GdjOzw8O2Nn8GdkOzz8rzc1W17bXlw1Nzc1XF7bXls1NwAAAAACAAAAAAOzA7MAFwAtAAABIgcGBwYVFBcWFxYzMjc2NzY1NCcmJyYTBwYiLwEmNjsBETQ2OwEyFhURMzIWAe52Z2Q7PT07ZGd2fGpmOz4+O2ZpIXYOKA52Dg0XXQsHJgcLXRcNA7M+O2ZqfHZnZDs9PTtkZ3Z9aWY7Pv3wmhISmhIaARcICwsI/ukaAAMAAAAAA+UD5QAXACMALAAAASIHBgcGFRQXFhcWMzI3Njc2NTQnJicmAxQrASI1AzQ7ATIHJyImNDYyFhQGAe6Ecm9BRERBb3KEiXZxQkREQnF1aQIxAwgCQgMBIxIZGSQZGQPkREJxdomEcm9BRERBb3KEinVxQkT9HQICAWICAjEZIxkZIxkAAAAAAwAAAAADsQPkABsAKgAzAAABBgcGBwYHBjcRFBcWFxYXNjc2NzY1ESQXJicmBzMyFhUDFAYrASInAzQ2EyImNDYyFhQGAfVBQTg7LDt/IEc+bF5sbF1tPUj+2KhQQVVvNAQGDAMCJgUBCwYeDxYWHhUVA+QPEg4SDhIpCv6tj3VkST4dHT5JZHWPAVNeNRkSGPwGBP7GAgMFAToEBv5AFR8VFR8VAAAAAgAAAAADsQPkABkALgAAAQYHBgc2BREUFxYXFhc2NzY3NjURJBcmJyYTAQYvASY/ATYyHwEWNjclNjIfARYB9VVVQk+v/tFHPmxebGxdbT1I/tGvT0JVo/7VBASKAwMSAQUBcQEFAgESAgUBEQQD4xMYEhk3YP6sjnVlSD8cHD9IZXWOAVRgNxkSGP62/tkDA48EBBkCAVYCAQHlAQIQBAAAAAACAAAAAAPkA+QAFwAtAAABIgcGBwYVFBcWFxYzMjc2NzY1NCcmJyYTAQYiLwEmPwE2Mh8BFjI3ATYyHwEWAe6Ecm9BQ0NCbnODiXVxQkREQnF1kf6gAQUBowMDFgEFAYUCBQEBQwIFARUEA+NEQnF1iYNzbkJDQ0FvcoSJdXFCRP6j/qUBAagEBR4CAWYBAQENAgIVBAAAAAQAAAAAA68DrQAUACkAPwBDAAABIgcGBwYUFxYXFjI3Njc2NCcmJyYDIicmJyY0NzY3NjIXFhcWFAcGBwYTBQ4BLwEmBg8BBhYfARYyNwE+ASYiFzAfAQH1eGdkOzw8O2Rn8GZkOzw8O2RmeG5eWzY3NzZbXtteWzY3NzZbXmn+9gYSBmAGDwUDBQEGfQUQBgElBQELEBUBAQOtPDtkZ/BnYzs8PDtjZ/BnZDs8/K83NVte215cNTc3NVxe215bNTcCJt0FAQVJBQIGBAcRBoAGBQEhBQ8LBAEBAAABAAAAAAO7AzoAFwAAEy4BPwE+AR8BFjY3ATYWFycWFAcBBiInPQoGBwUHGgzLDCELAh0LHwsNCgr9uQoeCgGzCyEOCw0HCZMJAQoBvgkCCg0LHQv9sQsKAAAAAAIAAAAAA+UD5gAXACwAAAEiBwYHBhUUFxYXFjMyNzY3NjU0JyYnJhMHBi8BJicmNRM0NjsBMhYVExceAQHvhHJvQUNDQm5zg4l1cUJEREJxdVcQAwT6AwIEEAMCKwIDDsUCAQPlREJxdYmDc25CQ0NBb3KEiXVxQkT9VhwEAncCAgMGAXoCAwMC/q2FAgQAAAQAAAAAA68DrQADABgALQAzAAABMB8BAyIHBgcGFBcWFxYyNzY3NjQnJicmAyInJicmNDc2NzYyFxYXFhQHBgcGAyMVMzUjAuUBAfJ4Z2Q7PDw7ZGfwZmQ7PDw7ZGZ4bl5bNjc3Nlte215bNjc3NltemyT92QKDAQEBLDw7ZGfwZ2M7PDw7Y2fwZ2Q7PPyvNzVbXtteXDU3NzVcXtteWzU3AjH9JAAAAAMAAAAAA+QD5AAXACcAMAAAASIHBgcGFRQXFhcWMzI3Njc2NTQnJicmAzMyFhUDFAYrASImNQM0NhMiJjQ2MhYUBgHuhHJvQUNDQm5zg4l1cUJEREJxdZ42BAYMAwInAwMMBh8PFhYeFhYD40RCcXWJg3NuQkNDQW9yhIl1cUJE/vYGBf7AAgMDAgFABQb+NhYfFhYfFgAABAAAAAADwAPAAAgAEgAoAD0AAAEyNjQmIgYUFhcjFTMRIxUzNSMDIgcGBwYVFBYXFjMyNzY3NjU0Jy4BAyInJicmNDc2NzYyFxYXFhQHBgcGAfQYISEwISFRjzk5yTorhG5rPT99am+DdmhlPD4+PMyFbV5bNTc3NVte2l5bNTc3NVteAqAiLyIiLyI5Hf7EHBwCsT89a26Ed8w8Pj48ZWh2g29qffyjNzVbXtpeWzU3NzVbXtpeWzU3AAADAAAAAAOoA6gACwAgADUAAAEHJwcXBxc3FzcnNwMiBwYHBhQXFhcWMjc2NzY0JyYnJgMiJyYnJjQ3Njc2MhcWFxYUBwYHBgKOmpocmpocmpocmpq2dmZiOjs7OmJm7GZiOjs7OmJmdmtdWTQ2NjRZXdZdWTQ2NjRZXQKqmpocmpocmpocmpoBGTs6YmbsZmI6Ozs6YmbsZmI6O/zCNjRZXdZdWTQ2NjRZXdZdWTQ2AAMAAAAAA+kD6gAaAC8AMAAAAQYHBiMiJyYnJjQ3Njc2MhcWFxYVFAcGBwEHATI3Njc2NCcmJyYiBwYHBhQXFhcWMwKONUBCR21dWjU3NzVaXdpdWzU2GBcrASM5/eBXS0grKysrSEuuSkkqLCwqSUpXASMrFxg2NVtd2l1aNTc3NVpdbUdCQDX+3jkBGSsrSEuuSkkqLCwqSUquS0grKwAC//8AAAPoA+gAFAAwAAABIgcGBwYQFxYXFiA3Njc2ECcmJyYTFg4BIi8BBwYuATQ/AScmPgEWHwE3Nh4BBg8BAfSIdHFDRERDcXQBEHRxQ0REQ3F0SQoBFBsKoqgKGxMKqKIKARQbCqKoChsUAQqoA+hEQ3F0/vB0cUNERENxdAEQdHFDRP1jChsTCqiiCgEUGwqiqAobFAEKqKIKARQbCqIAAAIAAAAAA+QD5AAXADQAAAEiBwYHBhUUFxYXFjMyNzY3NjU0JyYnJhMUBiMFFxYUDwEGLwEuAT8BNh8BFhQPAQUyFh0BAe6Ecm9BQ0NCbnODiXVxQkREQnF1fwQC/pGDAQEVAwTsAgEC7AQEFAIBhAFwAgMD40RCcXWJg3NuQkNDQW9yhIl1cUJE/fYCAwuVAgQCFAQE0AIFAtEEBBQCBQGVCwMDJwAAAAUAAAAAA9QD0wAjACcANwBHAEgAAAERFAYjISImNREjIiY9ATQ2MyE1NDYzITIWHQEhMhYdARQGIyERIREHIgYVERQWOwEyNjURNCYjISIGFREUFjsBMjY1ETQmKwEDeyYb/XYbJkMJDQ0JAQYZEgEvExkBBgkNDQn9CQJc0QkNDQktCQ0NCf7sCQ0NCS0JDQ0JLQMi/TQbJiYbAswMCiwJDS4SGRkSLg0JLAoM/UwCtGsNCf5NCQ0NCQGzCQ0NCf5NCQ0NCQGzCQ0AAAAAEADGAAEAAAAAAAEABAAAAAEAAAAAAAIABwAEAAEAAAAAAAMABAALAAEAAAAAAAQABAAPAAEAAAAAAAUACwATAAEAAAAAAAYABAAeAAEAAAAAAAoAKwAiAAEAAAAAAAsAEwBNAAMAAQQJAAEACABgAAMAAQQJAAIADgBoAAMAAQQJAAMACAB2AAMAAQQJAAQACAB+AAMAAQQJAAUAFgCGAAMAAQQJAAYACACcAAMAAQQJAAoAVgCkAAMAAQQJAAsAJgD6d2V1aVJlZ3VsYXJ3ZXVpd2V1aVZlcnNpb24gMS4wd2V1aUdlbmVyYXRlZCBieSBzdmcydHRmIGZyb20gRm9udGVsbG8gcHJvamVjdC5odHRwOi8vZm9udGVsbG8uY29tAHcAZQB1AGkAUgBlAGcAdQBsAGEAcgB3AGUAdQBpAHcAZQB1AGkAVgBlAHIAcwBpAG8AbgAgADEALgAwAHcAZQB1AGkARwBlAG4AZQByAGEAdABlAGQAIABiAHkAIABzAHYAZwAyAHQAdABmACAAZgByAG8AbQAgAEYAbwBuAHQAZQBsAGwAbwAgAHAAcgBvAGoAZQBjAHQALgBoAHQAdABwADoALwAvAGYAbwBuAHQAZQBsAGwAbwAuAGMAbwBtAAAAAgAAAAAAAAAKAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAASAQIBAwEEAQUBBgEHAQgBCQEKAQsBDAENAQ4BDwEQAREBEgETAAZjaXJjbGUIZG93bmxvYWQEaW5mbwxzYWZlX3N1Y2Nlc3MJc2FmZV93YXJuB3N1Y2Nlc3MOc3VjY2Vzcy1jaXJjbGURc3VjY2Vzcy1uby1jaXJjbGUHd2FpdGluZw53YWl0aW5nLWNpcmNsZQR3YXJuC2luZm8tY2lyY2xlBmNhbmNlbAZzZWFyY2gFY2xlYXIEYmFjawZkZWxldGUAAAAA') format('truetype');
}
@font-face {
font-weight: normal;
font-style: normal;
font-family: "unibtn";
src: url('data:application/octet-stream;base64,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') format('truetype')
}
html,
body {
-webkit-user-select: none;
user-select: none;
width: 100%;
height: 100%;
}
body {
overflow-x: hidden;
}
[class^="uni-icon-"],
[class*=" uni-icon-"] {
display: inline-block;
vertical-align: middle;
font: normal normal normal 14px/1 "uni";
font-size: inherit;
text-rendering: auto;
-webkit-font-smoothing: antialiased;
}
[class^="uni-btn-icon"],
[class*=" uni-btn-icon"] {
display: inline-block;
font: normal normal normal 14px/1 "unibtn";
font-size: inherit;
text-rendering: auto;
-webkit-font-smoothing: antialiased;
}
[class^="uni-btn-icon"]:before,
[class*=" uni-btn-icon"]:before {
margin: 0;
box-sizing: border-box;
}
.uni-icon-success-no-circle:before {
content: "\EA08";
}
.uni-loading,
uni-button[loading]:before {
background: transparent url("data:image/svg+xml;base64, PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMjAiIGhlaWdodD0iMTIwIiB2aWV3Qm94PSIwIDAgMTAwIDEwMCI+PHBhdGggZmlsbD0ibm9uZSIgZD0iTTAgMGgxMDB2MTAwSDB6Ii8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTlFOUU5IiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDAgLTMwKSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iIzk4OTY5NyIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgzMCAxMDUuOTggNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjOUI5OTlBIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKDYwIDc1Ljk4IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0EzQTFBMiIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSg5MCA2NSA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNBQkE5QUEiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoMTIwIDU4LjY2IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0IyQjJCMiIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgxNTAgNTQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjQkFCOEI5IiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKDE4MCA1MCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDMkMwQzEiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTE1MCA0NS45OCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDQkNCQ0IiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTEyMCA0MS4zNCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNEMkQyRDIiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTkwIDM1IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0RBREFEQSIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgtNjAgMjQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTJFMkUyIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKC0zMCAtNS45OCA2NSkiLz48L3N2Zz4=") no-repeat;
}
.uni-loading {
width: 20px;
height: 20px;
display: inline-block;
vertical-align: middle;
animation: uni-loading 1s steps(12, end) infinite;
background-size: 100%;
}
@keyframes uni-loading {
0% {
transform: rotate3d(0, 0, 1, 0deg);
}
100% {
transform: rotate3d(0, 0, 1, 360deg);
}
}
.uni-mask {
position: fixed;
z-index: 999;
top: 0;
right: 0;
left: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.6);
}
.uni-fade-enter-active,
.uni-fade-leave-active {
transition-duration: 0.25s;
transition-property: opacity;
transition-timing-function: ease;
}
.uni-fade-enter,
.uni-fade-leave-active {
opacity: 0
}
[nvue] uni-view,
[nvue] uni-swiper-item,
[nvue] uni-scroll-view {
display: flex;
flex-shrink: 0;
flex-grow: 0;
flex-basis: auto;
align-items: stretch;
align-content: flex-start;
}
[nvue-dir-row] uni-view,
[nvue-dir-row] uni-swiper-item {
flex-direction: row;
}
[nvue-dir-column] uni-view,
[nvue-dir-column] uni-swiper-item {
flex-direction: column;
}
[nvue-dir-row-reverse] uni-view,
[nvue-dir-row-reverse] uni-swiper-item {
flex-direction: row-reverse;
}
[nvue-dir-column-reverse] uni-view,
[nvue-dir-column-reverse] uni-swiper-item {
flex-direction: column-reverse;
}
[nvue] uni-view,
[nvue] uni-image,
[nvue] uni-input,
[nvue] uni-scroll-view,
[nvue] uni-swiper,
[nvue] uni-swiper-item,
[nvue] uni-text,
[nvue] uni-textarea,
[nvue] uni-video {
position: relative;
border: 0px solid #000000;
box-sizing: border-box;
}
[nvue] uni-swiper-item {
position: absolute;
}
uni-app {
display: block;
box-sizing: border-box;
width: 100%;
height: 100%;
}
uni-canvas {
width: 300px;
height: 150px;
display: block;
position: relative;
}
uni-canvas > canvas {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
uni-checkbox-group[hidden] {
display: none;
}
.ql-container {
display: block;
position: relative;
box-sizing: border-box;
-webkit-user-select: text;
user-select: text;
outline: none;
overflow: hidden;
width: 100%;
height: 200px;
min-height: 200px;
}
.ql-container[hidden] {
display: none;
}
.ql-container .ql-editor {
position: relative;
font-size: inherit;
line-height: inherit;
font-family: inherit;
min-height: inherit;
width: 100%;
height: 100%;
padding: 0;
overflow-x: hidden;
overflow-y: auto;
-webkit-tap-highlight-color: transparent;
-webkit-touch-callout: none;
-webkit-overflow-scrolling: touch;
}
.ql-container .ql-editor::-webkit-scrollbar {
width: 0 !important;
}
.ql-container .ql-editor.scroll-disabled {
overflow: hidden;
}
.ql-container .ql-image-overlay {
display: flex;
position: absolute;
box-sizing: border-box;
border: 1px dashed #ccc;
justify-content: center;
align-items: center;
-webkit-user-select: none;
user-select: none;
}
.ql-container .ql-image-overlay .ql-image-size {
position: absolute;
padding: 4px 8px;
text-align: center;
background-color: #fff;
color: #888;
border: 1px solid #ccc;
box-sizing: border-box;
opacity: 0.8;
right: 4px;
top: 4px;
font-size: 12px;
display: inline-block;
width: auto;
}
.ql-container .ql-image-overlay .ql-image-toolbar {
position: relative;
text-align: center;
box-sizing: border-box;
background: #000;
border-radius: 5px;
color: #fff;
font-size: 0;
min-height: 24px;
z-index: 100;
}
.ql-container .ql-image-overlay .ql-image-toolbar span {
display: inline-block;
cursor: pointer;
padding: 5px;
font-size: 12px;
border-right: 1px solid #fff;
}
.ql-container .ql-image-overlay .ql-image-toolbar span:last-child {
border-right: 0;
}
.ql-container .ql-image-overlay .ql-image-toolbar span.triangle-up {
padding: 0;
position: absolute;
top: -12px;
left: 50%;
transform: translatex(-50%);
width: 0;
height: 0;
border-width: 6px;
border-style: solid;
border-color: transparent transparent black transparent;
}
.ql-container .ql-image-overlay .ql-image-handle {
position: absolute;
height: 12px;
width: 12px;
border-radius: 50%;
border: 1px solid #ccc;
box-sizing: border-box;
background: #fff;
}
.ql-container img {
display: inline-block;
max-width: 100%;
}
.ql-clipboard p {
margin: 0;
padding: 0;
}
.ql-editor {
box-sizing: border-box;
height: 100%;
outline: none;
overflow-y: auto;
tab-size: 4;
-moz-tab-size: 4;
text-align: left;
white-space: pre-wrap;
word-wrap: break-word;
}
.ql-editor > * {
cursor: text;
}
.ql-editor p,
.ql-editor ol,
.ql-editor ul,
.ql-editor pre,
.ql-editor blockquote,
.ql-editor h1,
.ql-editor h2,
.ql-editor h3,
.ql-editor h4,
.ql-editor h5,
.ql-editor h6 {
margin: 0;
padding: 0;
counter-reset: list-1 list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9;
}
.ql-editor ol > li,
.ql-editor ul > li {
list-style-type: none;
}
.ql-editor ul > li::before {
content: '\2022';
}
.ql-editor ul[data-checked=true],
.ql-editor ul[data-checked=false] {
pointer-events: none;
}
.ql-editor ul[data-checked=true] > li *,
.ql-editor ul[data-checked=false] > li * {
pointer-events: all;
}
.ql-editor ul[data-checked=true] > li::before,
.ql-editor ul[data-checked=false] > li::before {
color: #777;
cursor: pointer;
pointer-events: all;
}
.ql-editor ul[data-checked=true] > li::before {
content: '\2611';
}
.ql-editor ul[data-checked=false] > li::before {
content: '\2610';
}
.ql-editor li::before {
display: inline-block;
white-space: nowrap;
width: 2em;
}
.ql-editor ol li {
counter-reset: list-1 list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9;
counter-increment: list-0;
}
.ql-editor ol li:before {
content: counter(list-0, decimal) '. ';
}
.ql-editor ol li.ql-indent-1 {
counter-increment: list-1;
}
.ql-editor ol li.ql-indent-1:before {
content: counter(list-1, lower-alpha) '. ';
}
.ql-editor ol li.ql-indent-1 {
counter-reset: list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9;
}
.ql-editor ol li.ql-indent-2 {
counter-increment: list-2;
}
.ql-editor ol li.ql-indent-2:before {
content: counter(list-2, lower-roman) '. ';
}
.ql-editor ol li.ql-indent-2 {
counter-reset: list-3 list-4 list-5 list-6 list-7 list-8 list-9;
}
.ql-editor ol li.ql-indent-3 {
counter-increment: list-3;
}
.ql-editor ol li.ql-indent-3:before {
content: counter(list-3, decimal) '. ';
}
.ql-editor ol li.ql-indent-3 {
counter-reset: list-4 list-5 list-6 list-7 list-8 list-9;
}
.ql-editor ol li.ql-indent-4 {
counter-increment: list-4;
}
.ql-editor ol li.ql-indent-4:before {
content: counter(list-4, lower-alpha) '. ';
}
.ql-editor ol li.ql-indent-4 {
counter-reset: list-5 list-6 list-7 list-8 list-9;
}
.ql-editor ol li.ql-indent-5 {
counter-increment: list-5;
}
.ql-editor ol li.ql-indent-5:before {
content: counter(list-5, lower-roman) '. ';
}
.ql-editor ol li.ql-indent-5 {
counter-reset: list-6 list-7 list-8 list-9;
}
.ql-editor ol li.ql-indent-6 {
counter-increment: list-6;
}
.ql-editor ol li.ql-indent-6:before {
content: counter(list-6, decimal) '. ';
}
.ql-editor ol li.ql-indent-6 {
counter-reset: list-7 list-8 list-9;
}
.ql-editor ol li.ql-indent-7 {
counter-increment: list-7;
}
.ql-editor ol li.ql-indent-7:before {
content: counter(list-7, lower-alpha) '. ';
}
.ql-editor ol li.ql-indent-7 {
counter-reset: list-8 list-9;
}
.ql-editor ol li.ql-indent-8 {
counter-increment: list-8;
}
.ql-editor ol li.ql-indent-8:before {
content: counter(list-8, lower-roman) '. ';
}
.ql-editor ol li.ql-indent-8 {
counter-reset: list-9;
}
.ql-editor ol li.ql-indent-9 {
counter-increment: list-9;
}
.ql-editor ol li.ql-indent-9:before {
content: counter(list-9, decimal) '. ';
}
.ql-editor .ql-indent-1:not(.ql-direction-rtl) {
padding-left: 2em;
}
.ql-editor li.ql-indent-1:not(.ql-direction-rtl) {
padding-left: 2em;
}
.ql-editor .ql-indent-1.ql-direction-rtl.ql-align-right {
padding-right: 2em;
}
.ql-editor li.ql-indent-1.ql-direction-rtl.ql-align-right {
padding-right: 2em;
}
.ql-editor .ql-indent-2:not(.ql-direction-rtl) {
padding-left: 4em;
}
.ql-editor li.ql-indent-2:not(.ql-direction-rtl) {
padding-left: 4em;
}
.ql-editor .ql-indent-2.ql-direction-rtl.ql-align-right {
padding-right: 4em;
}
.ql-editor li.ql-indent-2.ql-direction-rtl.ql-align-right {
padding-right: 4em;
}
.ql-editor .ql-indent-3:not(.ql-direction-rtl) {
padding-left: 6em;
}
.ql-editor li.ql-indent-3:not(.ql-direction-rtl) {
padding-left: 6em;
}
.ql-editor .ql-indent-3.ql-direction-rtl.ql-align-right {
padding-right: 6em;
}
.ql-editor li.ql-indent-3.ql-direction-rtl.ql-align-right {
padding-right: 6em;
}
.ql-editor .ql-indent-4:not(.ql-direction-rtl) {
padding-left: 8em;
}
.ql-editor li.ql-indent-4:not(.ql-direction-rtl) {
padding-left: 8em;
}
.ql-editor .ql-indent-4.ql-direction-rtl.ql-align-right {
padding-right: 8em;
}
.ql-editor li.ql-indent-4.ql-direction-rtl.ql-align-right {
padding-right: 8em;
}
.ql-editor .ql-indent-5:not(.ql-direction-rtl) {
padding-left: 10em;
}
.ql-editor li.ql-indent-5:not(.ql-direction-rtl) {
padding-left: 10em;
}
.ql-editor .ql-indent-5.ql-direction-rtl.ql-align-right {
padding-right: 10em;
}
.ql-editor li.ql-indent-5.ql-direction-rtl.ql-align-right {
padding-right: 10em;
}
.ql-editor .ql-indent-6:not(.ql-direction-rtl) {
padding-left: 12em;
}
.ql-editor li.ql-indent-6:not(.ql-direction-rtl) {
padding-left: 12em;
}
.ql-editor .ql-indent-6.ql-direction-rtl.ql-align-right {
padding-right: 12em;
}
.ql-editor li.ql-indent-6.ql-direction-rtl.ql-align-right {
padding-right: 12em;
}
.ql-editor .ql-indent-7:not(.ql-direction-rtl) {
padding-left: 14em;
}
.ql-editor li.ql-indent-7:not(.ql-direction-rtl) {
padding-left: 14em;
}
.ql-editor .ql-indent-7.ql-direction-rtl.ql-align-right {
padding-right: 14em;
}
.ql-editor li.ql-indent-7.ql-direction-rtl.ql-align-right {
padding-right: 14em;
}
.ql-editor .ql-indent-8:not(.ql-direction-rtl) {
padding-left: 16em;
}
.ql-editor li.ql-indent-8:not(.ql-direction-rtl) {
padding-left: 16em;
}
.ql-editor .ql-indent-8.ql-direction-rtl.ql-align-right {
padding-right: 16em;
}
.ql-editor li.ql-indent-8.ql-direction-rtl.ql-align-right {
padding-right: 16em;
}
.ql-editor .ql-indent-9:not(.ql-direction-rtl) {
padding-left: 18em;
}
.ql-editor li.ql-indent-9:not(.ql-direction-rtl) {
padding-left: 18em;
}
.ql-editor .ql-indent-9.ql-direction-rtl.ql-align-right {
padding-right: 18em;
}
.ql-editor li.ql-indent-9.ql-direction-rtl.ql-align-right {
padding-right: 18em;
}
.ql-editor .ql-direction-rtl {
direction: rtl;
text-align: inherit;
}
.ql-editor .ql-align-center {
text-align: center;
}
.ql-editor .ql-align-justify {
text-align: justify;
}
.ql-editor .ql-align-right {
text-align: right;
}
.ql-editor.ql-blank::before {
color: rgba(0, 0, 0, 0.6);
content: attr(data-placeholder);
font-style: italic;
pointer-events: none;
position: absolute;
}
.ql-container.ql-disabled .ql-editor ul[data-checked] > li::before {
pointer-events: none;
}
.ql-clipboard {
left: -100000px;
height: 1px;
overflow-y: hidden;
position: absolute;
top: 50%;
}
uni-icon {
display: inline-block;
font-size: 0;
box-sizing: border-box;
}
uni-icon[hidden] {
display: none;
}
uni-icon > i {
font: normal normal normal 14px/1 'weui';
}
uni-icon > i:before {
margin: 0;
box-sizing: border-box;
}
@font-face {
font-weight: normal;
font-style: normal;
font-family: 'weui';
src: url('data:application/octet-stream;base64,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')
format('truetype');
}
.uni-icon-success:before {
content: '\EA06';
}
.uni-icon-success_circle:before {
content: '\EA07';
}
.uni-icon-success_no_circle:before {
content: '\EA08';
}
.uni-icon-safe_success:before {
content: '\EA04';
}
.uni-icon-safe_warn:before {
content: '\EA05';
}
.uni-icon-info:before {
content: '\EA03';
}
.uni-icon-info_circle:before {
content: '\EA0C';
}
.uni-icon-warn:before {
content: '\EA0B';
}
.uni-icon-waiting:before {
content: '\EA09';
}
.uni-icon-waiting_circle:before {
content: '\EA0A';
}
.uni-icon-circle:before {
content: '\EA01';
}
.uni-icon-cancel:before {
content: '\EA0D';
}
.uni-icon-download:before {
content: '\EA02';
}
.uni-icon-search:before {
content: '\EA0E';
}
.uni-icon-clear:before {
content: '\EA0F';
}
.uni-icon-success {
color: #007aff;
}
.uni-icon-success_circle {
color: #007aff;
}
.uni-icon-success_no_circle {
color: #007aff;
}
.uni-icon-safe_success {
color: #007aff;
}
.uni-icon-safe_warn {
color: #ffbe00;
}
.uni-icon-info {
color: #10aeff;
}
.uni-icon-info_circle {
color: #007aff;
}
.uni-icon-warn {
color: #f76260;
}
.uni-icon-waiting {
color: #10aeff;
}
.uni-icon-waiting_circle {
color: #10aeff;
}
.uni-icon-circle {
color: #c9c9c9;
}
.uni-icon-cancel {
color: #f43530;
}
.uni-icon-download {
color: #007aff;
}
.uni-icon-search {
color: #b2b2b2;
}
.uni-icon-clear {
color: #b2b2b2;
}
uni-image {
width: 320px;
height: 240px;
display: inline-block;
overflow: hidden;
position: relative;
}
uni-image[hidden] {
display: none;
}
uni-image>div {
width: 100%;
height: 100%;
}
uni-image>img {
-webkit-touch-callout: none;
-webkit-user-select: none;
-moz-user-select: none;
display: block;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0;
}
uni-image>.uni-image-will-change {
will-change: transform;
}
uni-input {
display: block;
font-size: 16px;
line-height: 1.4em;
height: 1.4em;
min-height: 1.4em;
overflow: hidden;
}
uni-input[hidden] {
display: none;
}
.uni-input-wrapper,
.uni-input-placeholder,
.uni-input-form,
.uni-input-input {
outline: none;
border: none;
padding: 0;
margin: 0;
text-decoration: inherit;
}
.uni-input-wrapper,
.uni-input-form {
display: flex;
position: relative;
width: 100%;
height: 100%;
flex-direction: column;
justify-content: center;
}
.uni-input-placeholder,
.uni-input-input {
width: 100%;
}
.uni-input-placeholder {
position: absolute;
top: auto !important;
left: 0;
color: gray;
overflow: hidden;
text-overflow: clip;
white-space: pre;
word-break: keep-all;
pointer-events: none;
line-height: inherit;
}
.uni-input-input {
display: block;
height: 100%;
background: none;
color: inherit;
opacity: 1;
-webkit-text-fill-color: currentcolor;
font: inherit;
line-height: inherit;
letter-spacing: inherit;
text-align: inherit;
text-indent: inherit;
text-transform: inherit;
text-shadow: inherit;
}
.uni-input-input[type="search"]::-webkit-search-cancel-button {
display: none;
}
.uni-input-input::-webkit-outer-spin-button,
.uni-input-input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
.uni-input-input[type="number"] {
-moz-appearance: textfield;
}
.uni-label-pointer {
cursor: pointer;
}
uni-movable-view {
display: inline-block;
width: 10px;
height: 10px;
top: 0px;
left: 0px;
position: absolute;
cursor: grab;
}
uni-movable-view[hidden] {
display: none;
}
uni-navigator {
height: auto;
width: auto;
display: block;
cursor: pointer;
}
uni-navigator[hidden] {
display: none;
}
.navigator-hover {
background-color: rgba(0, 0, 0, 0.1);
opacity: 0.7;
}
uni-radio {
-webkit-tap-highlight-color: transparent;
display: inline-block;
cursor: pointer;
}
uni-radio[hidden] {
display: none;
}
uni-radio[disabled] {
cursor: not-allowed;
}
uni-radio .uni-radio-wrapper {
display: -webkit-inline-flex;
display: inline-flex;
-webkit-align-items: center;
align-items: center;
vertical-align: middle;
}
uni-radio .uni-radio-input {
-webkit-appearance: none;
appearance: none;
margin-right: 5px;
outline: 0;
border: 1px solid #D1D1D1;
background-color: #ffffff;
border-radius: 50%;
width: 22px;
height: 22px;
position: relative;
}
uni-radio:not([disabled]) .uni-radio-input:hover {
border-color: #007aff;
}
uni-radio .uni-radio-input.uni-radio-input-checked:before {
font: normal normal normal 14px/1 "uni";
content: "\EA08";
color: #ffffff;
font-size: 18px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -48%) scale(0.73);
-webkit-transform: translate(-50%, -48%) scale(0.73);
}
uni-radio .uni-radio-input.uni-radio-input-disabled {
background-color: #E1E1E1;
border-color: #D1D1D1;
}
uni-radio .uni-radio-input.uni-radio-input-disabled:before {
color: #ADADAD;
}
uni-radio-group {
display: block;
}
uni-radio-group[hidden] {
display: none;
}
@keyframes once-show {
from {
top: 0;
}
}
uni-resize-sensor,
uni-resize-sensor > div {
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
overflow: hidden;
}
uni-resize-sensor {
display: block;
z-index: -1;
visibility: hidden;
animation: once-show 1ms;
}
uni-resize-sensor > div > div {
position: absolute;
left: 0;
top: 0;
}
uni-resize-sensor > div:first-child > div {
width: 100000px;
height: 100000px;
}
uni-resize-sensor > div:last-child > div {
width: 200%;
height: 200%;
}
uni-scroll-view {
display: block;
width: 100%;
}
uni-scroll-view[hidden] {
display: none;
}
.uni-scroll-view {
position: relative;
-webkit-overflow-scrolling: touch;
width: 100%;
height: 100%;
max-height: inherit;
}
.uni-scroll-view-content {
width: 100%;
height: 100%;
}
.uni-scroll-view-refresher {
position: relative;
overflow: hidden;
}
.uni-scroll-view-refresh {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
}
.uni-scroll-view-refresh-inner {
display: flex;
align-items: center;
justify-content: center;
line-height: 0;
width: 40px;
height: 40px;
border-radius: 50%;
background-color: #fff;
box-shadow: 0 1px 6px rgba(0, 0, 0, 0.117647),
0 1px 4px rgba(0, 0, 0, 0.117647);
}
.uni-scroll-view-refresh__spinner {
transform-origin: center center;
animation: uni-scroll-view-refresh-rotate 2s linear infinite;
}
.uni-scroll-view-refresh__spinner > circle {
stroke: currentColor;
stroke-linecap: round;
animation: uni-scroll-view-refresh-dash 2s linear infinite;
}
@keyframes uni-scroll-view-refresh-rotate {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@keyframes uni-scroll-view-refresh-dash {
0% {
stroke-dasharray: 1, 200;
stroke-dashoffset: 0;
}
50% {
stroke-dasharray: 89, 200;
stroke-dashoffset: -35px;
}
100% {
stroke-dasharray: 89, 200;
stroke-dashoffset: -124px;
}
}
uni-swiper-item {
display: block;
overflow: hidden;
will-change: transform;
position: absolute;
width: 100%;
height: 100%;
cursor: grab;
}
uni-swiper-item[hidden] {
display: none;
}
uni-switch {
-webkit-tap-highlight-color: transparent;
display: inline-block;
cursor: pointer;
}
uni-switch[hidden] {
display: none;
}
uni-switch[disabled] {
cursor: not-allowed;
}
uni-switch .uni-switch-wrapper {
display: -webkit-inline-flex;
display: inline-flex;
-webkit-align-items: center;
align-items: center;
vertical-align: middle;
}
uni-switch .uni-switch-input {
-webkit-appearance: none;
appearance: none;
position: relative;
width: 52px;
height: 32px;
margin-right: 5px;
border: 1px solid #DFDFDF;
outline: 0;
border-radius: 16px;
box-sizing: border-box;
background-color: #DFDFDF;
transition: background-color 0.1s, border 0.1s;
}
uni-switch[disabled] .uni-switch-input {
opacity: .7;
}
uni-switch .uni-switch-input:before {
content: " ";
position: absolute;
top: 0;
left: 0;
width: 50px;
height: 30px;
border-radius: 15px;
background-color: #FDFDFD;
transition: -webkit-transform 0.3s;
transition: transform 0.3s;
transition: transform 0.3s, -webkit-transform 0.3s;
}
uni-switch .uni-switch-input:after {
content: " ";
position: absolute;
top: 0;
left: 0;
width: 30px;
height: 30px;
border-radius: 15px;
background-color: #FFFFFF;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
transition: -webkit-transform 0.3s;
transition: transform 0.3s;
transition: transform 0.3s, -webkit-transform 0.3s;
}
uni-switch .uni-switch-input.uni-switch-input-checked {
border-color: #007aff;
background-color: #007aff;
}
uni-switch .uni-switch-input.uni-switch-input-checked:before {
-webkit-transform: scale(0);
transform: scale(0);
}
uni-switch .uni-switch-input.uni-switch-input-checked:after {
-webkit-transform: translateX(20px);
transform: translateX(20px);
}
uni-switch .uni-checkbox-input {
margin-right: 5px;
-webkit-appearance: none;
appearance: none;
outline: 0;
border: 1px solid #D1D1D1;
background-color: #FFFFFF;
border-radius: 3px;
width: 22px;
height: 22px;
position: relative;
color: #007aff;
}
uni-switch:not([disabled]) .uni-checkbox-input:hover {
border-color: #007aff;
}
uni-switch .uni-checkbox-input.uni-checkbox-input-checked:before {
font: normal normal normal 14px/1 "uni";
content: "\EA08";
color: inherit;
font-size: 22px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -48%) scale(0.73);
-webkit-transform: translate(-50%, -48%) scale(0.73);
}
uni-switch .uni-checkbox-input.uni-checkbox-input-disabled {
background-color: #E1E1E1;
}
uni-switch .uni-checkbox-input.uni-checkbox-input-disabled:before {
color: #ADADAD;
}
uni-textarea {
width: 300px;
height: 150px;
display: block;
position: relative;
font-size: 16px;
line-height: normal;
white-space: pre-wrap;
word-break: break-all;
}
uni-textarea[hidden] {
display: none;
}
.uni-textarea-wrapper,
.uni-textarea-placeholder,
.uni-textarea-line,
.uni-textarea-compute,
.uni-textarea-textarea {
outline: none;
border: none;
padding: 0;
margin: 0;
text-decoration: inherit;
}
.uni-textarea-wrapper {
display: block;
position: relative;
width: 100%;
height: 100%;
}
.uni-textarea-placeholder,
.uni-textarea-line,
.uni-textarea-compute,
.uni-textarea-textarea {
position: absolute;
width: 100%;
height: 100%;
left: 0;
top: 0;
white-space: inherit;
word-break: inherit;
}
.uni-textarea-placeholder {
color: grey;
overflow: hidden;
}
.uni-textarea-line,
.uni-textarea-compute {
visibility: hidden;
height: auto;
}
.uni-textarea-line {
width: 1em;
}
.uni-textarea-textarea {
resize: none;
background: none;
color: inherit;
opacity: 1;
-webkit-text-fill-color: currentcolor;
font: inherit;
line-height: inherit;
letter-spacing: inherit;
text-align: inherit;
text-indent: inherit;
text-transform: inherit;
text-shadow: inherit;
}
.uni-textarea-textarea-fix-margin {
width: auto;
right: 0;
margin: 0 -3px;
}
uni-view {
display: block;
}
uni-view[hidden] {
display: none;
}
uni-page-head {
display: block;
box-sizing: border-box;
}
uni-page-head .uni-page-head {
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 44px;
height: calc(44px + constant(safe-area-inset-top));
height: calc(44px + env(safe-area-inset-top));
padding: 7px 3px;
padding-top: calc(7px + constant(safe-area-inset-top));
padding-top: calc(7px + env(safe-area-inset-top));
display: flex;
overflow: hidden;
justify-content: space-between;
box-sizing: border-box;
z-index: 998;
color: #fff;
background-color: #000;
transition-property: all;
}
uni-page-head .uni-page-head-titlePenetrate,
uni-page-head .uni-page-head-titlePenetrate .uni-page-head-bd,
uni-page-head .uni-page-head-titlePenetrate .uni-page-head-bd * {
pointer-events: none;
}
uni-page-head .uni-page-head-titlePenetrate * {
pointer-events: auto;
}
uni-page-head .uni-page-head.uni-page-head-transparent .uni-page-head-ft > div {
justify-content: center;
}
uni-page-head .uni-page-head ~ .uni-placeholder {
width: 100%;
height: 44px;
height: calc(44px + constant(safe-area-inset-top));
height: calc(44px + env(safe-area-inset-top));
}
uni-page-head .uni-placeholder-titlePenetrate {
pointer-events: none;
}
uni-page-head .uni-page-head * {
box-sizing: border-box;
}
uni-page-head .uni-page-head-hd {
display: flex;
align-items: center;
font-size: 16px;
}
uni-page-head .uni-page-head-bd {
position: absolute;
left: 70px;
right: 70px;
min-width: 0;
user-select: auto;
}
.uni-page-head-btn {
position: relative;
width: auto;
margin: 0 2px;
word-break: keep-all;
white-space: pre;
cursor: pointer;
}
.uni-page-head-transparent .uni-page-head-btn {
display: flex;
align-items: center;
width: 32px;
height: 32px;
border-radius: 50%;
background-color: rgba(0, 0, 0, 0.5);
}
uni-page-head .uni-btn-icon {
overflow: hidden;
min-width: 1em;
}
.uni-page-head-btn-red-dot::after {
content: attr(badge-text);
position: absolute;
right: 0;
top: 0;
background-color: red;
color: white;
width: 18px;
height: 18px;
line-height: 18px;
border-radius: 18px;
overflow: hidden;
transform: scale(0.5) translate(40%, -40%);
transform-origin: 100% 0;
}
.uni-page-head-btn-red-dot[badge-text]::after {
font-size: 12px;
width: auto;
min-width: 18px;
max-width: 42px;
text-align: center;
padding: 0 3px;
transform: scale(0.7) translate(40%, -40%);
}
.uni-page-head-btn-select > .uni-btn-icon::after {
display: inline-block;
font-family: 'unibtn';
content: '\e601';
margin-left: 2px;
transform: rotate(-90deg) scale(0.8);
}
.uni-page-head-search {
position: relative;
display: flex;
flex: 1;
margin: 0 2px;
line-height: 30px;
font-size: 15px;
}
.uni-page-head-search-input {
width: 100%;
height: 100%;
padding-left: 34px;
text-align: left;
}
.uni-page-head-search-placeholder {
position: absolute;
max-width: 100%;
height: 100%;
padding-left: 34px;
overflow: hidden;
word-break: keep-all;
white-space: pre;
}
.uni-page-head-search-placeholder-right {
right: 0;
}
.uni-page-head-search-placeholder-center {
left: 50%;
transform: translateX(-50%);
}
.uni-page-head-search-placeholder::before {
position: absolute;
top: 0;
left: 2px;
width: 30px;
content: '\ea0e';
display: block;
font-size: 20px;
font-family: 'uni';
text-align: center;
}
uni-page-head .uni-page-head-ft {
display: flex;
align-items: center;
flex-direction: row-reverse;
font-size: 13px;
}
uni-page-head .uni-page-head__title {
font-weight: bold;
font-size: 16px;
line-height: 30px;
text-align: center;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
uni-page-head .uni-page-head__title .uni-loading {
width: 16px;
height: 16px;
margin-top: -3px;
}
uni-page-head .uni-page-head__title .uni-page-head__title_image {
width: auto;
height: 26px;
vertical-align: middle;
}
uni-page-head .uni-page-head-shadow {
overflow: visible;
}
uni-page-head .uni-page-head-shadow::after {
content: '';
position: absolute;
left: 0;
right: 0;
top: 100%;
height: 5px;
background-size: 100% 100%;
}
uni-page-head .uni-page-head-shadow-grey::after {
background-image: url('https://cdn.dcloud.net.cn/img/shadow-grey.png');
}
uni-page-head .uni-page-head-shadow-blue::after {
background-image: url('https://cdn.dcloud.net.cn/img/shadow-blue.png');
}
uni-page-head .uni-page-head-shadow-green::after {
background-image: url('https://cdn.dcloud.net.cn/img/shadow-green.png');
}
uni-page-head .uni-page-head-shadow-orange::after {
background-image: url('https://cdn.dcloud.net.cn/img/shadow-orange.png');
}
uni-page-head .uni-page-head-shadow-red::after {
background-image: url('https://cdn.dcloud.net.cn/img/shadow-red.png');
}
uni-page-head .uni-page-head-shadow-yellow::after {
background-image: url('https://cdn.dcloud.net.cn/img/shadow-yellow.png');
}
uni-page-wrapper {
display: block;
height: 100%;
position: relative;
}
uni-page-head[uni-page-head-type="default"] ~ uni-page-wrapper {
height: calc(100% - 44px);
height: calc(100% - 44px - constant(safe-area-inset-top));
height: calc(100% - 44px - env(safe-area-inset-top));
}
.uni-app--showtabbar uni-page-wrapper {
display: block;
height: calc(100% - 50px);
height: calc(100% - 50px - constant(safe-area-inset-bottom));
height: calc(100% - 50px - env(safe-area-inset-bottom));
}
.uni-app--showtabbar uni-page-wrapper::after {
content: "";
display: block;
width: 100%;
height: 50px;
height: calc(50px + constant(safe-area-inset-bottom));
height: calc(50px + env(safe-area-inset-bottom));
}
.uni-app--showtabbar uni-page-head[uni-page-head-type="default"] ~ uni-page-wrapper {
height: calc(100% - 44px - 50px);
height: calc(100% - 44px - constant(safe-area-inset-top) - 50px - constant(safe-area-inset-bottom));
height: calc(100% - 44px - env(safe-area-inset-top) - 50px - env(safe-area-inset-bottom));
}
uni-page-body {
display: block;
box-sizing: border-box;
width: 100%;
}
uni-page-refresh {
position: absolute;
top: 0;
width: 100%;
height: 40px;
display: block;
box-sizing: border-box;
}
uni-page-refresh .uni-page-refresh {
position: absolute;
top: -45px;
left: 50%;
transform: translate3d(-50%, 0, 0);
width: 40px;
height: 40px;
justify-content: center;
align-items: center;
background: #fff;
border-radius: 50%;
box-shadow: 0 1px 6px rgba(0, 0, 0, .117647), 0 1px 4px rgba(0, 0, 0, .117647);
display: none;
z-index: 997;
}
uni-page-refresh .uni-page-refresh-inner {
display: flex;
align-items: center;
justify-content: center;
line-height: 0;
width: 40px;
height: 40px;
border-radius: 50%;
}
uni-page-refresh.uni-page-refresh--pulling .uni-page-refresh,
uni-page-refresh.uni-page-refresh--aborting .uni-page-refresh,
uni-page-refresh.uni-page-refresh--reached .uni-page-refresh,
uni-page-refresh.uni-page-refresh--refreshing .uni-page-refresh,
uni-page-refresh.uni-page-refresh--restoring .uni-page-refresh {
display: flex;
}
uni-page-refresh.uni-page-refresh--pulling .uni-page-refresh__spinner,
uni-page-refresh.uni-page-refresh--aborting .uni-page-refresh__spinner,
uni-page-refresh.uni-page-refresh--reached .uni-page-refresh__spinner,
uni-page-refresh.uni-page-refresh--refreshing .uni-page-refresh__icon,
uni-page-refresh.uni-page-refresh--restoring .uni-page-refresh__icon {
display: none;
}
uni-page-refresh.uni-page-refresh--refreshing .uni-page-refresh__spinner {
transform-origin: center center;
animation: uni-page-refresh-rotate 2s linear infinite;
}
uni-page-refresh.uni-page-refresh--refreshing .uni-page-refresh__path {
stroke-dasharray: 1, 200;
stroke-dashoffset: 0;
stroke-linecap: round;
animation: uni-page-refresh-dash 1.5s ease-in-out infinite, uni-page-refresh-colorful 6s ease-in-out infinite;
}
@keyframes uni-page-refresh-rotate {
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
@keyframes uni-page-refresh-dash {
0% {
stroke-dasharray: 1, 200;
stroke-dashoffset: 0;
}
50% {
stroke-dasharray: 89, 200;
stroke-dashoffset: -35px;
}
100% {
stroke-dasharray: 89, 200;
stroke-dashoffset: -124px;
}
}
uni-page {
display: block;
width: 100%;
height: 100%;
}
.uni-async-error {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
color: #999;
padding: 100px 0;
text-align: center;
}
.uni-async-loading {
box-sizing: border-box;
width: 100%;
padding: 50px;
text-align: center;
}
.uni-async-loading .uni-loading {
width: 30px;
height: 30px;
}
因为 它太大了无法显示 source diff 。你可以改为 查看blob
......@@ -6,7 +6,7 @@
],
"scripts": {
"build": "node scripts/build.js",
"lint": "eslint packages/**/*.ts",
"lint": "eslint packages/*/src/**/*.ts",
"format": "prettier --write --parser typescript \"packages/**/*.ts?(x)\"",
"ls-lint": "ls-lint",
"test": "jest",
......@@ -66,7 +66,7 @@
"semver": "^7.3.4",
"ts-jest": "^26.4.4",
"typescript": "^4.1.3",
"vite": "^2.0.0-beta.4",
"vite": "^2.0.0-beta.31",
"vue": "3.0.5",
"yorkie": "^2.0.0"
}
......
......@@ -38,7 +38,7 @@ export function createApi<T extends Function>(
fn: T,
protocol?: ApiProtocols
) {
return (function(...args: any[]) {
return (function (...args: any[]) {
if (type === API_TYPE_SYNC) {
if (!(__DEV__ && protocol && !validateProtocol(name!, args, protocol))) {
return fn.apply(null, formatApiArgs(args, options))
......
......@@ -16,7 +16,7 @@ for (var i = 0; i < chars.length; i++) {
lookup[chars.charCodeAt(i)] = i
}
exports.encode = function(arraybuffer) {
export function encode(arraybuffer) {
var bytes = new Uint8Array(arraybuffer),
i,
len = bytes.length,
......@@ -38,7 +38,7 @@ exports.encode = function(arraybuffer) {
return base64
}
exports.decode = function(base64) {
export function decode(base64) {
var bufferLength = base64.length * 0.75,
len = base64.length,
i,
......
......@@ -5,7 +5,7 @@ export enum HOOKS {
SUCCESS = 'success',
FAIL = 'fail',
COMPLETE = 'complete',
RETURN_VALUE = 'returnValue'
RETURN_VALUE = 'returnValue',
}
export type Interceptor = { [P in HOOKS]?: Function }
......@@ -16,7 +16,7 @@ export const globalInterceptors: Interceptors = {}
export const scopedInterceptors: { [key: string]: Interceptors } = {}
function wrapperHook(hook: Function) {
return function(data: unknown) {
return function (data: unknown) {
return hook(data) || data
}
}
......@@ -35,7 +35,7 @@ function queue(hooks: Function[], data: unknown): Promise<any> {
if (res === false) {
return {
then() {},
catch() {}
catch() {},
} as Promise<undefined>
}
}
......@@ -45,7 +45,7 @@ function queue(hooks: Function[], data: unknown): Promise<any> {
then(callback: Function) {
return callback(data)
},
catch() {}
catch() {},
}
)
}
......@@ -54,7 +54,7 @@ function wrapperOptions(
interceptors: Interceptors,
options: Record<string, any> = {}
) {
;[HOOKS.SUCCESS, HOOKS.FAIL, HOOKS.COMPLETE].forEach(name => {
;[HOOKS.SUCCESS, HOOKS.FAIL, HOOKS.COMPLETE].forEach((name) => {
const hooks = interceptors[name]
if (!isArray(hooks)) {
return
......@@ -78,7 +78,7 @@ export function wrapperReturnValue(method: string, returnValue: unknown) {
if (interceptor && isArray(interceptor.returnValue)) {
returnValueHooks.push(...interceptor.returnValue)
}
returnValueHooks.forEach(hook => {
returnValueHooks.forEach((hook) => {
returnValue = hook(returnValue) || returnValue
})
return returnValue
......@@ -86,7 +86,7 @@ export function wrapperReturnValue(method: string, returnValue: unknown) {
function getApiInterceptorHooks(method: string) {
const interceptor = Object.create(null)
Object.keys(globalInterceptors).forEach(hook => {
Object.keys(globalInterceptors).forEach((hook) => {
if (hook !== 'returnValue') {
interceptor[hook] = (globalInterceptors[
hook as HOOKS
......@@ -95,7 +95,7 @@ function getApiInterceptorHooks(method: string) {
})
const scopedInterceptor = scopedInterceptors[method]
if (scopedInterceptor) {
Object.keys(scopedInterceptor).forEach(hook => {
Object.keys(scopedInterceptor).forEach((hook) => {
if (hook !== 'returnValue') {
interceptor[hook] = (interceptor[hook] || []).concat(
scopedInterceptor[hook as HOOKS]
......@@ -116,7 +116,7 @@ export function invokeApi(
if (interceptor && Object.keys(interceptor).length) {
if (isArray(interceptor.invoke)) {
const res = queue(interceptor.invoke, options)
return res.then(options => {
return res.then((options) => {
return api(wrapperOptions(interceptor, options), ...params)
})
} else {
......
......@@ -36,10 +36,10 @@ function handlePromise(promise: Promise<any>) {
return promise
}
return promise
.then(data => {
.then((data) => {
return [null, data]
})
.catch(err => [err])
.catch((err) => [err])
}
export function shouldPromise(name: string) {
......@@ -51,13 +51,13 @@ export function shouldPromise(name: string) {
/* eslint-disable no-extend-native */
if (!Promise.prototype.finally) {
Promise.prototype.finally = function(
Promise.prototype.finally = function (
onfinally?: (() => void) | undefined | null
) {
const promise = this.constructor as PromiseConstructor
return this.then(
value => promise.resolve(onfinally && onfinally()).then(() => value),
reason =>
(value) => promise.resolve(onfinally && onfinally()).then(() => value),
(reason) =>
promise.resolve(onfinally && onfinally()).then(() => {
throw reason
})
......@@ -89,7 +89,7 @@ export function promisify(name: string, api: unknown) {
api,
Object.assign({}, options, {
success: resolve,
fail: reject
fail: reject,
}),
...params
)
......
......@@ -11,14 +11,14 @@ export const HTTP_METHODS = {
PUT: 'PUT',
DELETE: 'DELETE',
TRACE: 'TRACE',
CONNECT: 'CONNECT'
CONNECT: 'CONNECT',
}
export function normalizeStrArray(strArr: string[], optionalVal: string[]) {
if (
!isArray(strArr) ||
strArr.length === 0 ||
strArr.find(val => optionalVal.indexOf(val) === -1)
strArr.find((val) => optionalVal.indexOf(val) === -1)
) {
return optionalVal
}
......
......@@ -27,6 +27,6 @@ export {
API_TYPE_ON,
API_TYPE_SYNC,
API_TYPE_ASYNC,
API_TYPE_RETURN
API_TYPE_RETURN,
} from './helpers/api'
export { isSyncApi, isContextApi, promisify } from './helpers/promise'
......@@ -4,8 +4,8 @@ export const Base64ToArrayBufferProtocol: ProtocolOptions<String>[] = [
{
name: 'base64',
type: String,
required: true
}
required: true,
},
]
export const ArrayBufferToBase64Protocol: ProtocolOptions<
......@@ -14,6 +14,6 @@ export const ArrayBufferToBase64Protocol: ProtocolOptions<
{
name: 'arrayBuffer',
type: [ArrayBuffer, Uint8Array],
required: true
}
required: true,
},
]
import { ProtocolOptions } from '../type'
export const CanIUseProtocol: ProtocolOptions<String>[] = [
{
name: 'schema',
type: String,
required: true
}
]
import { ProtocolOptions } from '../type'
export const CanIUseProtocol: ProtocolOptions<String>[] = [
{
name: 'schema',
type: String,
required: true,
},
]
import { ProtocolOptions } from '../type'
export const $on: ProtocolOptions<String | Array<String> | Function>[] = [
{
name: 'event',
type: [String, Array],
required: true
},
{
name: 'callback',
type: Function,
required: true
}
]
export const $once = $on
export const $off: ProtocolOptions<String | Array<String> | Function>[] = [
{
name: 'event',
type: [String, Array]
},
{
name: 'callback',
type: Function
}
]
export const $emit: ProtocolOptions<String>[] = [
{
name: 'event',
type: String,
required: true
}
]
import { ProtocolOptions } from '../type'
export const $on: ProtocolOptions<String | Array<String> | Function>[] = [
{
name: 'event',
type: [String, Array],
required: true,
},
{
name: 'callback',
type: Function,
required: true,
},
]
export const $once = $on
export const $off: ProtocolOptions<String | Array<String> | Function>[] = [
{
name: 'event',
type: [String, Array],
},
{
name: 'callback',
type: Function,
},
]
export const $emit: ProtocolOptions<String>[] = [
{
name: 'event',
type: String,
required: true,
},
]
import { ProtocolOptions } from '../type'
export const AddInterceptorProtocol: ProtocolOptions<String | Object>[] = [
{
name: 'method',
type: [String, Object],
required: true
}
]
export const RemoveInterceptorProtocol = AddInterceptorProtocol
import { ProtocolOptions } from '../type'
export const AddInterceptorProtocol: ProtocolOptions<String | Object>[] = [
{
name: 'method',
type: [String, Object],
required: true,
},
]
export const RemoveInterceptorProtocol = AddInterceptorProtocol
import { ProtocolOptions } from '../type'
export const Upx2pxProtocol: ProtocolOptions<Number | String>[] = [
{
name: 'upx',
type: [Number, String],
required: true
}
]
import { ProtocolOptions } from '../type'
export const Upx2pxProtocol: ProtocolOptions<Number | String>[] = [
{
name: 'upx',
type: [Number, String],
required: true,
},
]
......@@ -3,7 +3,7 @@ import { extend } from '@vue/shared'
import { ApiProtocol, ApiOptions, Data } from '../type'
function getInt(name: string) {
return function(value: number, params: Data) {
return function (value: number, params: Data) {
if (value) {
params[name] = Math.round(value)
}
......@@ -15,31 +15,31 @@ export const CanvasGetImageDataOptions: ApiOptions = {
x: getInt('x'),
y: getInt('y'),
width: getInt('width'),
height: getInt('height')
}
height: getInt('height'),
},
}
export const CanvasGetImageDataProtocol: ApiProtocol = {
canvasId: {
type: String,
required: true
required: true,
},
x: {
type: Number,
required: true
required: true,
},
y: {
type: Number,
required: true
required: true,
},
width: {
type: Number,
required: true
required: true,
},
height: {
type: Number,
required: true
}
required: true,
},
}
export const CanvasPutImageDataOptions = CanvasGetImageDataOptions
......@@ -47,33 +47,33 @@ export const CanvasPutImageDataOptions = CanvasGetImageDataOptions
export const CanvasPutImageDataProtocol: ApiProtocol = {
canvasId: {
type: String,
required: true
required: true,
},
data: {
type: Uint8ClampedArray,
required: true
required: true,
},
x: {
type: Number,
required: true
required: true,
},
y: {
type: Number,
required: true
required: true,
},
width: {
type: Number,
required: true
required: true,
},
height: {
type: Number
}
type: Number,
},
}
const fileTypes = {
PNG: 'png',
JPG: 'jpg',
JPEG: 'jpg'
JPEG: 'jpg',
}
export const CanvasToTempFilePathOptions: ApiOptions = {
......@@ -92,56 +92,56 @@ export const CanvasToTempFilePathOptions: ApiOptions = {
quality(value: number, params: Data) {
value = Math.floor(value)
params.quality = value > 0 && value < 1 ? value : 1
}
},
},
CanvasGetImageDataOptions.formatArgs
)
),
}
export const CanvasToTempFilePathProtocol: ApiProtocol = {
x: {
type: Number,
default: 0
default: 0,
},
y: {
type: Number,
default: 0
default: 0,
},
width: {
type: Number
type: Number,
},
height: {
type: Number
type: Number,
},
destWidth: {
type: Number
type: Number,
},
destHeight: {
type: Number
type: Number,
},
canvasId: {
type: String,
required: true
required: true,
},
fileType: {
type: String
type: String,
},
quality: {
type: Number
}
type: Number,
},
}
export const DrawCanvasProtocol: ApiProtocol = {
canvasId: {
type: String,
required: true
required: true,
},
actions: {
type: Array,
required: true
required: true,
},
reserve: {
type: Boolean,
default: false
}
default: false,
},
}
import { ProtocolOptions } from '../type'
const validator: ProtocolOptions<String>[] = [
{
name: 'id',
type: String,
required: true
}
]
export const CreateAudioContextProtocol = validator
export const CreateVideoContextProtocol = validator
export const CreateMapContextProtocol = validator
export const CreateCanvasContextProtocol: ProtocolOptions<String | Object>[] = [
{
name: 'canvasId',
type: String,
required: true
},
{
name: 'componentInstance',
type: Object
}
]
import { ProtocolOptions } from '../type'
const validator: ProtocolOptions<String>[] = [
{
name: 'id',
type: String,
required: true,
},
]
export const CreateAudioContextProtocol = validator
export const CreateVideoContextProtocol = validator
export const CreateMapContextProtocol = validator
export const CreateCanvasContextProtocol: ProtocolOptions<String | Object>[] = [
{
name: 'canvasId',
type: String,
required: true,
},
{
name: 'componentInstance',
type: Object,
},
]
import { ApiProtocol } from '../type'
export const MakePhoneCallProtocol: ApiProtocol = {
phoneNumber: {
type: String,
required: true,
validator(phoneNumber: string) {
if (!phoneNumber) {
return 'makePhoneCall:fail parameter error: parameter.phoneNumber should not be empty String;'
}
}
}
}
import { ApiProtocol } from '../type'
export const MakePhoneCallProtocol: ApiProtocol = {
phoneNumber: {
type: String,
required: true,
validator(phoneNumber: string) {
if (!phoneNumber) {
return 'makePhoneCall:fail parameter error: parameter.phoneNumber should not be empty String;'
}
},
},
}
import { ApiOptions } from '../type'
export const SetClipboardDataOptions: ApiOptions = {
beforeSuccess() {
uni.showToast({
title: '内容已复制',
icon: 'success',
mask: false
})
}
}
import { ApiOptions } from '../type'
export const SetClipboardDataOptions: ApiOptions = {
beforeSuccess() {
uni.showToast({
title: '内容已复制',
icon: 'success',
mask: false,
})
},
}
......@@ -3,9 +3,9 @@ import { ApiProtocol } from '../type'
export const OpenDocumentProtocol: ApiProtocol = {
filePath: {
type: String,
required: true
required: true,
},
fileType: {
type: String
}
type: String,
},
}
import { ApiProtocol } from '../type'
export const ChooseLocationProtocol: ApiProtocol = {
keyword: {
type: String
}
}
import { ApiProtocol } from '../type'
export const ChooseLocationProtocol: ApiProtocol = {
keyword: {
type: String,
},
}
import { ApiProtocol, ApiOptions } from '../type'
const coordTypes = {
WGS84: 'WGS84',
GCJ02: 'GCJ02'
}
export const GetLocationOptions: ApiOptions = {
formatArgs: {
type(value, params) {
value = (value || '').toUpperCase()
let type = coordTypes[value as keyof typeof coordTypes]
if (!type) {
type = coordTypes.WGS84
}
params.type = type
}
}
}
export const GetLocationProtocol: ApiProtocol = {
type: {
type: String,
default: coordTypes.WGS84
},
altitude: {
type: Boolean,
default: false
}
}
import { ApiProtocol, ApiOptions } from '../type'
const coordTypes = {
WGS84: 'WGS84',
GCJ02: 'GCJ02',
}
export const GetLocationOptions: ApiOptions = {
formatArgs: {
type(value, params) {
value = (value || '').toUpperCase()
let type = coordTypes[value as keyof typeof coordTypes]
if (!type) {
type = coordTypes.WGS84
}
params.type = type
},
},
}
export const GetLocationProtocol: ApiProtocol = {
type: {
type: String,
default: coordTypes.WGS84,
},
altitude: {
type: Boolean,
default: false,
},
}
......@@ -5,27 +5,27 @@ export const OpenLocationOptions: ApiOptions = {
type(value, params) {
value = Math.floor(value)
params.scale = value >= 5 && value <= 18 ? value : 18
}
}
},
},
}
export const OpenLocationProtocol: ApiProtocol = {
latitude: {
type: Number,
required: true
required: true,
},
longitude: {
type: Number,
required: true
required: true,
},
scale: {
type: Number,
default: 18
default: 18,
},
name: {
type: String
type: String,
},
address: {
type: String
}
type: String,
},
}
import { ApiOptions, ApiProtocol } from '../type'
import {
CHOOSE_SIZE_TYPES,
CHOOSE_SOURCE_TYPES,
normalizeStrArray
} from '../../helpers/protocol'
export const ChooseImageOptions: ApiOptions = {
formatArgs: {
count(value, params) {
if (value <= 0) {
params.count = 9
}
},
sizeType(sizeType, params) {
params.sizeType = normalizeStrArray(sizeType, CHOOSE_SIZE_TYPES)
},
sourceType(sourceType, params) {
params.sourceType = normalizeStrArray(sourceType, CHOOSE_SOURCE_TYPES)
}
}
}
export const ChooseImageProtocol: ApiProtocol = {
count: {
type: Number,
default: 9
},
sizeType: {
type: [Array, String],
default: CHOOSE_SIZE_TYPES
},
sourceType: {
type: Array,
default: CHOOSE_SOURCE_TYPES
}
}
import { ApiOptions, ApiProtocol } from '../type'
import {
CHOOSE_SIZE_TYPES,
CHOOSE_SOURCE_TYPES,
normalizeStrArray,
} from '../../helpers/protocol'
export const ChooseImageOptions: ApiOptions = {
formatArgs: {
count(value, params) {
if (value <= 0) {
params.count = 9
}
},
sizeType(sizeType, params) {
params.sizeType = normalizeStrArray(sizeType, CHOOSE_SIZE_TYPES)
},
sourceType(sourceType, params) {
params.sourceType = normalizeStrArray(sourceType, CHOOSE_SOURCE_TYPES)
},
},
}
export const ChooseImageProtocol: ApiProtocol = {
count: {
type: Number,
default: 9,
},
sizeType: {
type: [Array, String],
default: CHOOSE_SIZE_TYPES,
},
sourceType: {
type: Array,
default: CHOOSE_SOURCE_TYPES,
},
}
import { CHOOSE_SOURCE_TYPES, normalizeStrArray } from '../../helpers/protocol'
import { ApiOptions, ApiProtocol } from '../type'
export const ChooseVideoOptions: ApiOptions = {
formatArgs: {
sourceType(sourceType, params) {
params.sourceType = normalizeStrArray(sourceType, CHOOSE_SOURCE_TYPES)
}
}
}
export const ChooseVideoProtocol: ApiProtocol = {
sourceType: {
type: Array,
default: CHOOSE_SOURCE_TYPES
}
}
import { CHOOSE_SOURCE_TYPES, normalizeStrArray } from '../../helpers/protocol'
import { ApiOptions, ApiProtocol } from '../type'
export const ChooseVideoOptions: ApiOptions = {
formatArgs: {
sourceType(sourceType, params) {
params.sourceType = normalizeStrArray(sourceType, CHOOSE_SOURCE_TYPES)
},
},
}
export const ChooseVideoProtocol: ApiProtocol = {
sourceType: {
type: Array,
default: CHOOSE_SOURCE_TYPES,
},
}
import { ApiOptions, ApiProtocol } from '../type'
export const GetImageInfoOptions: ApiOptions = {
formatArgs: {
src(src, params) {
params.src = (uni as any).getRealPath(src)
}
}
}
export const GetImageInfoProtocol: ApiProtocol = {
src: {
type: String,
required: true
}
}
import { ApiOptions, ApiProtocol } from '../type'
export const GetImageInfoOptions: ApiOptions = {
formatArgs: {
src(src, params) {
params.src = (uni as any).getRealPath(src)
},
},
}
export const GetImageInfoProtocol: ApiProtocol = {
src: {
type: String,
required: true,
},
}
......@@ -4,16 +4,16 @@ export const DownloadFileOptions: ApiOptions = {
formatArgs: {
header(value, params) {
params.header = value || {}
}
}
},
},
}
export const DownloadFileProtocol: ApiProtocol = {
url: {
type: String,
required: true
required: true,
},
header: {
type: Object
}
type: Object,
},
}
......@@ -17,35 +17,35 @@ export const ConnectSocketOptions: ApiOptions = {
if (typeof protocols === 'string') {
params.protocols = [protocols]
}
}
}
},
},
}
export const ConnectSocketProtocol: ApiProtocol = {
url: {
type: String,
required: true
required: true,
},
header: {
type: Object
type: Object,
},
method: {
type: String
type: String,
},
protocols: {
type: [Array, String] // 微信文档虽然写的是数组,但是可以正常传递字符串
}
type: [Array, String], // 微信文档虽然写的是数组,但是可以正常传递字符串
},
}
export const sendSocketMessage = {
data: {
type: [String, ArrayBuffer]
}
type: [String, ArrayBuffer],
},
}
export const closeSocket = {
code: {
type: Number
type: Number,
},
reason: {
type: String
}
type: String,
},
}
......@@ -3,6 +3,6 @@ import { ApiProtocol } from '../type'
export const GetProviderProtocol: ApiProtocol = {
service: {
type: String,
required: true
}
required: true,
},
}
import { ApiProtocol } from '../type'
export const LoadSubPackageProtocol: ApiProtocol = {
root: {
type: String,
required: true,
validator(value) {
const subPackages = __uniConfig.subPackages
if (!Array.isArray(subPackages) || subPackages.length === 0) {
return 'no subPackages'
}
if (!subPackages.find(subPackage => subPackage.root === value)) {
return 'root `' + value + '` is not found'
}
}
}
}
import { ApiProtocol } from '../type'
export const LoadSubPackageProtocol: ApiProtocol = {
root: {
type: String,
required: true,
validator(value) {
const subPackages = __uniConfig.subPackages
if (!Array.isArray(subPackages) || subPackages.length === 0) {
return 'no subPackages'
}
if (!subPackages.find((subPackage) => subPackage.root === value)) {
return 'root `' + value + '` is not found'
}
},
},
}
import { ApiProtocol, ProtocolOptions } from '../type'
export const GetStorageProtocol: ApiProtocol = {
key: {
type: String,
required: true
}
}
export const GetStorageSyncProtocol: ProtocolOptions[] = [
{
name: 'key',
type: String,
required: true
}
]
export const SetStorageProtocol: ApiProtocol = {
key: {
type: String,
required: true
},
data: {
required: true
}
}
export const SetStorageSyncProtocol: ProtocolOptions[] = [
{
name: 'key',
type: String,
required: true
},
{
name: 'data',
required: true
}
]
export const RemoveStorageProtocol = GetStorageProtocol
export const RemoveStorageSyncProtocol = GetStorageSyncProtocol
import { ApiProtocol, ProtocolOptions } from '../type'
export const GetStorageProtocol: ApiProtocol = {
key: {
type: String,
required: true,
},
}
export const GetStorageSyncProtocol: ProtocolOptions[] = [
{
name: 'key',
type: String,
required: true,
},
]
export const SetStorageProtocol: ApiProtocol = {
key: {
type: String,
required: true,
},
data: {
required: true,
},
}
export const SetStorageSyncProtocol: ProtocolOptions[] = [
{
name: 'key',
type: String,
required: true,
},
{
name: 'data',
required: true,
},
]
export const RemoveStorageProtocol = GetStorageProtocol
export const RemoveStorageSyncProtocol = GetStorageSyncProtocol
......@@ -3,13 +3,13 @@ import { ApiProtocol } from '../type'
export const LoadFontFaceProtocol: ApiProtocol = {
family: {
type: String,
required: true
required: true,
},
source: {
type: String,
required: true
required: true,
},
desc: {
type: Object
}
type: Object,
},
}
import { ApiOptions, ApiProtocol } from '../type'
const FRONT_COLORS = ['#ffffff', '#000000']
export const SetNavigationBarColorOptions: ApiOptions = {
formatArgs: {
animation(animation = {}, params) {
params.animation = {
duration: animation.duration || 0,
timingFunc: animation.timingFunc || 'linear'
}
}
}
}
export const SetNavigationBarColorProtocol: ApiProtocol = {
frontColor: {
type: String,
required: true,
validator(frontColor) {
if (FRONT_COLORS.indexOf(frontColor) === -1) {
return `invalid frontColor "${frontColor}"`
}
}
},
backgroundColor: {
type: String,
required: true
},
animation: {
type: Object,
default() {
return {
duration: 0,
timingFunc: 'linear'
}
}
}
}
export const SetNavigationBarTitleProtocol: ApiProtocol = {
title: {
type: String,
required: true
}
}
import { ApiOptions, ApiProtocol } from '../type'
const FRONT_COLORS = ['#ffffff', '#000000']
export const SetNavigationBarColorOptions: ApiOptions = {
formatArgs: {
animation(animation = {}, params) {
params.animation = {
duration: animation.duration || 0,
timingFunc: animation.timingFunc || 'linear',
}
},
},
}
export const SetNavigationBarColorProtocol: ApiProtocol = {
frontColor: {
type: String,
required: true,
validator(frontColor) {
if (FRONT_COLORS.indexOf(frontColor) === -1) {
return `invalid frontColor "${frontColor}"`
}
},
},
backgroundColor: {
type: String,
required: true,
},
animation: {
type: Object,
default() {
return {
duration: 0,
timingFunc: 'linear',
}
},
},
}
export const SetNavigationBarTitleProtocol: ApiProtocol = {
title: {
type: String,
required: true,
},
}
import { ApiProtocol } from '../type'
export const PageScrollToProtocol: ApiProtocol = {
scrollTop: {
type: Number,
required: true
},
duration: {
type: Number,
default: 300
}
}
import { ApiProtocol } from '../type'
export const PageScrollToProtocol: ApiProtocol = {
scrollTop: {
type: Number,
required: true,
},
duration: {
type: Number,
default: 300,
},
}
......@@ -5,12 +5,12 @@ import { API_TYPE_SYNC, createApi } from '../../helpers/api'
import {
Base64ToArrayBufferProtocol,
ArrayBufferToBase64Protocol
ArrayBufferToBase64Protocol,
} from '../../protocols/base/base64'
export const base64ToArrayBuffer = createApi<typeof uni.base64ToArrayBuffer>(
{ type: API_TYPE_SYNC, name: 'base64ToArrayBuffer' },
base64 => {
(base64) => {
return decode(base64) as ArrayBuffer
},
Base64ToArrayBufferProtocol
......@@ -18,7 +18,7 @@ export const base64ToArrayBuffer = createApi<typeof uni.base64ToArrayBuffer>(
export const arrayBufferToBase64 = createApi<typeof uni.arrayBufferToBase64>(
{ type: API_TYPE_SYNC, name: 'arrayBufferToBase64' },
arrayBuffer => {
(arrayBuffer) => {
return encode(arrayBuffer) as string
},
ArrayBufferToBase64Protocol
......
......@@ -5,21 +5,21 @@ import {
scopedInterceptors,
globalInterceptors,
Interceptors,
HOOKS
HOOKS,
} from '../../helpers/interceptor'
import { API_TYPE_SYNC, createApi } from '../../helpers/api'
import {
AddInterceptorProtocol,
RemoveInterceptorProtocol
RemoveInterceptorProtocol,
} from '../../protocols/base/interceptor'
function mergeInterceptorHook(
interceptors: Interceptors,
interceptor: Interceptor
) {
Object.keys(interceptor).forEach(hook => {
Object.keys(interceptor).forEach((hook) => {
if (isFunction(interceptor[hook as HOOKS])) {
interceptors[hook as HOOKS] = mergeHook(
interceptors[hook as HOOKS],
......@@ -36,11 +36,12 @@ function removeInterceptorHook(
if (!interceptors || !interceptor) {
return
}
Object.keys(interceptor).forEach(hook => {
Object.keys(interceptor).forEach((hook) => {
if (isFunction(interceptor[hook as HOOKS])) {
removeHook(interceptors[hook as HOOKS], interceptor[
hook as HOOKS
] as Function)
removeHook(
interceptors[hook as HOOKS],
interceptor[hook as HOOKS] as Function
)
}
})
}
......@@ -53,8 +54,8 @@ function mergeHook(
? parentVal
? parentVal.concat(childVal)
: isArray(childVal)
? childVal
: [childVal]
? childVal
: [childVal]
: parentVal
return res ? dedupeHooks(res) : res
}
......@@ -116,11 +117,11 @@ export const promiseInterceptor = {
return res
}
return res
.then(res => {
.then((res) => {
return res[1]
})
.catch(res => {
.catch((res) => {
return res[0]
})
}
},
}
......@@ -8,7 +8,7 @@ import { getCurrentPageVm } from '../utils'
const defaultOptions = {
thresholds: [0],
initialRatio: 0,
observeAll: false
observeAll: false,
}
interface Margins {
......@@ -74,7 +74,7 @@ class ServiceIntersectionObserver {
}
this._relativeInfo.push({
selector,
margins
margins,
})
return this
}
......@@ -103,7 +103,7 @@ class ServiceIntersectionObserver {
reqId: this._reqId,
component: this._component,
options: this._options,
relativeInfo: this._relativeInfo
relativeInfo: this._relativeInfo,
},
this._pageId
)
......@@ -113,7 +113,7 @@ class ServiceIntersectionObserver {
UniServiceJSBridge.publishHandler(
'removeIntersectionObserver',
{
reqId: this._reqId
reqId: this._reqId,
},
this._pageId
)
......
......@@ -7,7 +7,7 @@ import { initEasycom, matchEasycom, vueCompilerOptions } from '../src'
const rootDir = path.resolve(__dirname, 'example')
const dirs = [
path.resolve(__dirname, 'example/components'),
path.resolve(__dirname, 'example/uni_modules/plugin/components')
path.resolve(__dirname, 'example/uni_modules/plugin/components'),
]
const template = `<template><test/><test1/><test1/><test2/><some-other-comp/><checkbox-group/><checkbox-group/></template>`
......@@ -31,16 +31,16 @@ describe('easycom', () => {
expect(initEasycom({ dirs, rootDir })).toEqual([
{
pattern: new RegExp('^test$'),
replacement: '@/components/test/test.vue'
replacement: '@/components/test/test.vue',
},
{
pattern: new RegExp('^test1$'),
replacement: '@/components/test1/test1.vue'
replacement: '@/components/test1/test1.vue',
},
{
pattern: new RegExp('^test2$'),
replacement: '@/uni_modules/plugin/components/test2/test2.vue'
}
replacement: '@/uni_modules/plugin/components/test2/test2.vue',
},
])
expect(matchEasycom('test')).toBe('@/components/test/test.vue')
expect(matchEasycom('test1')).toBe('@/components/test1/test1.vue')
......@@ -54,8 +54,8 @@ describe('easycom', () => {
).toEqual([
{
pattern: new RegExp('^uni-(.*)'),
replacement: '@/components/uni-$1.vue'
}
replacement: '@/components/uni-$1.vue',
},
])
expect(matchEasycom('test')).toBe(false)
expect(matchEasycom('uni-test1')).toBe('@/components/uni-test1.vue')
......@@ -65,21 +65,21 @@ describe('easycom', () => {
initEasycom({
dirs,
rootDir,
custom: { '^test$': '@/components/uni-test.vue' }
custom: { '^test$': '@/components/uni-test.vue' },
})
).toEqual([
{
pattern: new RegExp('^test$'),
replacement: '@/components/uni-test.vue'
replacement: '@/components/uni-test.vue',
},
{
pattern: new RegExp('^test1$'),
replacement: '@/components/test1/test1.vue'
replacement: '@/components/test1/test1.vue',
},
{
pattern: new RegExp('^test2$'),
replacement: '@/uni_modules/plugin/components/test2/test2.vue'
}
replacement: '@/uni_modules/plugin/components/test2/test2.vue',
},
])
expect(matchEasycom('test')).toBe('@/components/uni-test.vue')
})
......@@ -87,17 +87,17 @@ describe('easycom', () => {
initEasycom({
dirs,
rootDir,
custom: { '^test$': '@/components/uni-test.vue' }
custom: { '^test$': '@/components/uni-test.vue' },
})
const { code } = compileTemplate(
Object.assign(sfcParseRes.descriptor, {
id,
compilerOptions: Object.assign(
{
bindingMetadata: sfcScriptBlock.bindings
bindingMetadata: sfcScriptBlock.bindings,
},
vueCompilerOptions
)
),
})
)
expect(code).toMatch(` // const _component_test = _resolveComponent("test")
......@@ -117,7 +117,7 @@ import _style_v_uni_checkbox_group from '@dcloudio/uni-h5/style/checkbox-group.c
initEasycom({
dirs,
rootDir,
custom: { '^test$': '@/components/uni-test.vue' }
custom: { '^test$': '@/components/uni-test.vue' },
})
const { code } = compileTemplate(
Object.assign(sfcParseResWithSetup.descriptor, {
......@@ -125,7 +125,7 @@ import _style_v_uni_checkbox_group from '@dcloudio/uni-h5/style/checkbox-group.c
compilerOptions: Object.assign(
{ bindingMetadata: sfcScriptBlockWithSetup.bindings },
vueCompilerOptions
)
),
})
)
expect(code)
......
......@@ -24,7 +24,7 @@
"dependencies": {
"@vue/compiler-core": "^3.0.4",
"debug": "^4.3.1",
"strip-json-comments": "^3.1.1",
"jsonc-parser": "^3.0.0",
"xregexp": "3.1.0"
},
"peerDependencies": {
......
import {
ExpressionNode,
SimpleExpressionNode,
TransformContext
TransformContext,
} from '@vue/compiler-core'
interface ImportItem {
......@@ -17,7 +17,7 @@ export function addAutoImport(
const importContent = (importItem.exp as SimpleExpressionNode).content
const importsArray = Array.from(context.imports)
const existing = importsArray.find(
i =>
(i) =>
i.path === importPath &&
(i.exp as SimpleExpressionNode).content === importContent
)
......
......@@ -7,7 +7,7 @@ import {
ElementNode,
ElementTypes,
ComponentNode,
TemplateChildNode
TemplateChildNode,
} from '@vue/compiler-core'
interface EasycomOption {
......@@ -26,7 +26,7 @@ interface EasycomCustom {
export * from './autoImport'
export const debugEasycom = debug('easycom')
export const debugEasycom = debug('uni:easycom')
const easycoms: EasycomMatcher[] = []
......@@ -62,7 +62,7 @@ export function initEasycom({
dirs,
rootDir,
custom,
extensions = ['.vue']
extensions = ['.vue'],
}: EasycomOption) {
debugEasycom(dirs, rootDir, custom, extensions)
clearEasycom()
......@@ -73,10 +73,10 @@ export function initEasycom({
if (custom) {
Object.assign(easycomsObj, custom)
}
Object.keys(easycomsObj).forEach(name => {
Object.keys(easycomsObj).forEach((name) => {
easycoms.push({
pattern: new RegExp(name),
replacement: easycomsObj[name]
replacement: easycomsObj[name],
})
})
debugEasycom(easycoms)
......@@ -95,7 +95,7 @@ export function matchEasycom(tag: string) {
if (easycomsInvalidCache.has(tag)) {
return false
}
const matcher = easycoms.find(matcher => matcher.pattern.test(tag))
const matcher = easycoms.find((matcher) => matcher.pattern.test(tag))
if (!matcher) {
easycomsInvalidCache.add(tag)
return false
......@@ -120,7 +120,7 @@ function initAutoScanEasycom(
if (!fs.existsSync(dir)) {
return easycoms
}
fs.readdirSync(dir).forEach(name => {
fs.readdirSync(dir).forEach((name) => {
const folder = path.resolve(dir, name)
if (!isDir(folder)) {
return
......@@ -147,7 +147,7 @@ function initAutoScanEasycoms(
return dirs.reduce<Record<string, string>>(
(easycoms: Record<string, string>, dir: string) => {
const curEasycoms = initAutoScanEasycom(dir, rootDir, extensions)
Object.keys(curEasycoms).forEach(name => {
Object.keys(curEasycoms).forEach((name) => {
// Use the first component when name conflict
if (!easycoms[name]) {
easycoms[name] = curEasycoms[name]
......
export * from './json'
export * from './easycom/index'
export * from './vueCompilerOptions'
export * from './preprocess/index'
export * from './transforms/transformBuiltInComponent'
export * from './transforms/transformBuiltInEasycom'
export * from './transforms/transformEasycom'
import stripJsonComments from 'strip-json-comments'
// @ts-ignore
import { preprocess } from '../lib/preprocess'
import { parse } from 'jsonc-parser'
import { preJson } from './preprocess'
const jsContext = {
APP_PLUS: false,
H5: true,
MP_360: false,
MP_ALIPAY: false,
MP_BAIDU: false,
MP_QQ: false,
MP_TOUTIAO: false,
MP_WEIXIN: false,
QUICKAPP_NATIVE: false,
QUICKAPP_WEBVIEW: false,
MP: false,
APP: false,
APP_PLUS_NVUE: false,
APP_VUE: false,
APP_NVUE: false
}
export function parseJson(jsonStr: string, shouldPreprocess: boolean = false) {
return JSON.parse(
stripJsonComments(
shouldPreprocess
? preprocess(jsonStr, jsContext, { type: 'js' })
: jsonStr
)
)
export function parseJson(jsonStr: string, shouldPre: boolean = false) {
return parse(shouldPre ? preJson(jsonStr) : jsonStr)
}
export const jsContext = {
APP_PLUS: false,
H5: true,
MP_360: false,
MP_ALIPAY: false,
MP_BAIDU: false,
MP_QQ: false,
MP_TOUTIAO: false,
MP_WEIXIN: false,
QUICKAPP_NATIVE: false,
QUICKAPP_WEBVIEW: false,
MP: false,
APP: false,
APP_PLUS_NVUE: false,
APP_VUE: false,
APP_NVUE: false,
}
export const htmlContext = {
APP_PLUS: false,
H5: true,
MP_360: false,
MP_ALIPAY: false,
MP_BAIDU: false,
MP_QQ: false,
MP_TOUTIAO: false,
MP_WEIXIN: false,
QUICKAPP_NATIVE: false,
QUICKAPP_WEBVIEW: false,
MP: false,
APP: false,
APP_PLUS_NVUE: false,
APP_VUE: false,
APP_NVUE: false,
}
import { jsContext } from './context'
export * from './context'
/* eslint-disable no-restricted-globals */
const { preprocess } = require('../../lib/preprocess')
export function preJs(jsCode: string) {
return preprocess(jsCode, jsContext, { type: 'js' })
}
export function preHtml(htmlCode: string) {
return preprocess(htmlCode, jsContext, { type: 'html' })
}
export const preCss = preJs
export const preJson = preJs
......@@ -5,7 +5,7 @@ import {
NodeTransform,
ElementNode,
createSimpleExpression,
toValidAssetId
toValidAssetId,
} from '@vue/compiler-core'
import { COMPONENT_PREFIX, isBuiltInComponent } from '@dcloudio/uni-shared'
......@@ -28,7 +28,7 @@ function createComponentImportItem(oldTag: string, node: ElementNode) {
false,
node.loc,
ConstantTypes.CAN_HOIST
)
),
}
}
function createStyleImportItem(oldTag: string, node: ElementNode) {
......@@ -39,7 +39,7 @@ function createStyleImportItem(oldTag: string, node: ElementNode) {
false,
node.loc,
ConstantTypes.CAN_HOIST
)
),
}
}
......
import { NodeTransform } from '@vue/compiler-core'
import { isComponentNode } from '../easycom/index'
export const transformBuiltInEasycom: NodeTransform = node => {
export const transformBuiltInEasycom: NodeTransform = (node) => {
if (!isComponentNode(node)) {
return
}
......
......@@ -5,7 +5,7 @@ import {
createSimpleExpression,
toValidAssetId,
ComponentNode,
TransformContext
TransformContext,
} from '@vue/compiler-core'
import { COMPONENT_PREFIX } from '@dcloudio/uni-shared'
......@@ -15,7 +15,7 @@ import {
debugEasycom,
matchEasycom,
addAutoImport,
isComponentNode
isComponentNode,
} from '../easycom'
function createImportItem(path: string, node: ComponentNode) {
......@@ -27,7 +27,7 @@ function createImportItem(path: string, node: ComponentNode) {
false,
node.loc,
ConstantTypes.CAN_HOIST
)
),
}
}
......
......@@ -3,7 +3,7 @@ import { CompilerOptions } from '@vue/compiler-sfc'
import {
COMPONENT_PREFIX,
isBuiltInComponent,
isNativeTag
isNativeTag,
} from '@dcloudio/uni-shared'
import { transformBuiltInComponent } from './transforms/transformBuiltInComponent'
......@@ -42,6 +42,6 @@ export const vueCompilerOptions: VueCompilerOptions = {
nodeTransforms: [
transformBuiltInComponent,
transformBuiltInEasycom,
transformEasycom
]
transformEasycom,
],
}
......@@ -56,5 +56,5 @@ export {
Switch,
// Text,
Textarea,
View
View,
}
......@@ -5,7 +5,7 @@ try {
get() {
/* istanbul ignore next */
supportsPassive = true
}
},
}) // https://github.com/facebook/flow/issues/285
window.addEventListener('test-passive' as any, null as any, opts)
} catch (e) {}
......
// @ts-ignore
export { default as emitter } from './emitter'
// @ts-ignore
export { default as listeners } from './listeners'
// @ts-ignore
export { default as hover } from './hover'
// @ts-ignore
export { default as subscriber } from './subscriber'
// @ts-ignore
export { default as keyboard } from './keyboard'
// @ts-ignore
export { default as baseInput } from './base-input'
// @ts-ignore
export { default as interact } from './interact'
// @ts-ignore
export { default as emitter } from './emitter'
// @ts-ignore
export { default as listeners } from './listeners'
// @ts-ignore
export { default as hover } from './hover'
// @ts-ignore
export { default as subscriber } from './subscriber'
// @ts-ignore
export { default as keyboard } from './keyboard'
// @ts-ignore
export { default as baseInput } from './base-input'
// @ts-ignore
export { default as interact } from './interact'
import path from 'path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
......@@ -21,7 +23,7 @@ export default defineConfig({
minify: false,
assetsDir: '.',
rollupOptions: {
input: 'src/index.ts',
input: path.resolve(__dirname, 'src/index.ts'),
external: ['vue', '@vue/shared', '@dcloudio/uni-shared'],
preserveEntrySignatures: 'strict',
output: {
......
......@@ -11,7 +11,7 @@ export function initBridge(namespace: 'service' | 'view') {
},
emit(event: string, ...args: any[]) {
console.log(event, args)
}
},
}
return {
on,
......@@ -32,6 +32,6 @@ export function initBridge(namespace: 'service' | 'view') {
)
}
return emit(`${namespace}.${event}`, args, pageId)
}
},
}
}
......@@ -11,7 +11,7 @@ function querySelector(
function querySelectorAll(vm: ComponentPublicInstance, selector: string) {
const nodeList = vm.$el.querySelectorAll(selector)
if (nodeList) {
return [...nodeList].map(node => node.__vue__).filter(Boolean)
return [...nodeList].map((node) => node.__vue__).filter(Boolean)
}
return []
}
......
......@@ -11,13 +11,13 @@ export function getWindowOffset() {
top: top ? top + safeAreaInsets.top : 0,
bottom: bottom ? bottom + safeAreaInsets.bottom : 0,
left: left ? left + safeAreaInsets.left : 0,
right: right ? right + safeAreaInsets.right : 0
right: right ? right + safeAreaInsets.right : 0,
}
}
return {
top: 0,
bottom: 0,
left: 0,
right: 0
right: 0,
}
}
......@@ -13,7 +13,7 @@ export function initAppConfig(appConfig: AppConfig) {
Object.defineProperty(globalProperties, '$ownerInstance', {
get() {
return this.$getComponentDescriptor(this)
}
},
})
globalProperties.$handleWxsEvent = handleWxsEvent
}
......
......@@ -40,7 +40,7 @@ export function normalizeEvent(
const { top } = getWindowOffset()
detail = {
x: $event.x,
y: $event.y - top
y: $event.y - top,
}
normalizeClickEvent($event)
}
......@@ -55,13 +55,13 @@ export function normalizeEvent(
touches: normalizeTouchList(($event as any).touches),
changedTouches: normalizeTouchList(($event as any).changedTouches),
preventDefault() {},
stopPropagation() {}
stopPropagation() {},
}
if (__PLATFORM__ === 'app-plus' && currentTarget) {
const nid = currentTarget.getAttribute('_i')
;(ret as any).options = {
nid
nid,
}
// 保留原始 currentTarget 方便后续对比
;(ret as any).$origCurrentTarget = currentTarget
......@@ -78,8 +78,8 @@ function normalizeClickEvent($event: MouseEvent) {
clientX: $event.clientX,
clientY: $event.clientY,
pageX: $event.pageX,
pageY: $event.pageY
}
pageY: $event.pageY,
},
]
}
......@@ -98,7 +98,7 @@ function normalizeTarget(
id: target.id,
offsetLeft: target.offsetLeft,
offsetTop: target.offsetTop,
dataset: normalizeDataset(target.dataset)
dataset: normalizeDataset(target.dataset),
}
if (detail) {
extend(res, detail)
......@@ -120,7 +120,7 @@ function normalizeTouchList(touches: unknown) {
pageY: touch.pageY - top,
clientX: touch.clientX,
clientY: touch.clientY - top,
force: touch.force || 0
force: touch.force || 0,
})
}
return res
......
......@@ -20,20 +20,20 @@ function getWxsClsArr(
) {
const wxsClsArr: string[] = []
let checkClassList: (cls: string) => boolean = function(cls: string) {
let checkClassList: (cls: string) => boolean = function (cls: string) {
if (isAdd) {
checkClassList = function(cls) {
checkClassList = function (cls) {
return !classList.contains(cls)
}
} else {
checkClassList = function(cls) {
checkClassList = function (cls) {
return classList.contains(cls)
}
}
return checkClassList(cls)
}
clsArr.forEach(cls => {
clsArr.forEach((cls) => {
cls = cls.replace(CLASS_RE, '')
checkClassList(cls) && wxsClsArr.push(cls)
})
......@@ -44,7 +44,7 @@ function parseStyleText(cssText: string) {
const res: Record<string, string> = {}
const listDelimiter = /;(?![^(]*\))/g
const propertyDelimiter = /:(.+)/
cssText.split(listDelimiter).forEach(function(item) {
cssText.split(listDelimiter).forEach(function (item) {
if (item) {
const tmp = item.split(propertyDelimiter)
tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim())
......@@ -124,7 +124,7 @@ class ComponentDescriptor {
const wxsClsArr = getWxsClsArr(clsArr, classList, false)
if (wxsClsArr.length) {
const removeWxsClsArr: string[] = []
wxsClsArr.forEach(cls => {
wxsClsArr.forEach((cls) => {
const clsIndex = addWxsClsArr.findIndex(
(oldCls: string) => oldCls === cls
)
......@@ -165,7 +165,7 @@ class ComponentDescriptor {
UniViewJSBridge.publishHandler('onWxsInvokeCallMethod', {
cid: (this.$vm as any)._$id,
method: funcName,
args
args,
})
}
}
......@@ -231,10 +231,10 @@ export function handleWxsEvent(this: ComponentPublicInstance, $event: Event) {
$origEvent.currentTarget as HTMLElement
) as Event
;($event as any).instance = instance
$event.preventDefault = function() {
$event.preventDefault = function () {
return $origEvent.preventDefault()
}
$event.stopPropagation = function() {
$event.stopPropagation = function () {
return $origEvent.stopPropagation()
}
}
......@@ -25,13 +25,13 @@ function touchstart(evt: TouchEvent) {
startPageX = pageX
startPageY = pageY
longPressTimer = setTimeout(function() {
longPressTimer = setTimeout(function () {
const customEvent = new CustomEvent('longpress', {
bubbles: true,
cancelable: true,
// @ts-ignore
target: evt.target,
currentTarget: evt.currentTarget
currentTarget: evt.currentTarget,
})
;(customEvent as any).touches = evt.touches
;(customEvent as any).changedTouches = evt.changedTouches
......
......@@ -17,5 +17,5 @@ export default {
initSystemComponents(app)
initRouter(app)
}
},
}
......@@ -3,7 +3,7 @@ import { RouteRecordRaw } from 'vue-router'
import {
createRouter,
createWebHashHistory,
createWebHistory
createWebHistory,
} from 'vue-router'
export function initRouter(app: App) {
......@@ -21,7 +21,7 @@ export function initRouter(app: App) {
return savedPosition
}
// TODO tabBar?
}
},
})
)
}
......@@ -12,9 +12,5 @@ export * from './service/bridge'
export { getApp, getCurrentPages } from './framework'
export { default as PageComponent } from './framework/components/page/index.vue'
export {
default as AsyncErrorComponent
} from './framework/components/async-error/index.vue'
export {
default as AsyncLoadingComponent
} from './framework/components/async-loading/index.vue'
export { default as AsyncErrorComponent } from './framework/components/async-error/index.vue'
export { default as AsyncLoadingComponent } from './framework/components/async-loading/index.vue'
......@@ -9,7 +9,7 @@ function cssSupports(css: string) {
const SCHEMA_CSS = {
'css.var': cssSupports('--a:0'),
'css.env': cssSupports('top:env(a)'),
'css.constant': cssSupports('top:constant(a)')
'css.constant': cssSupports('top:constant(a)'),
}
export const canIUse = createApi<typeof uni.canIUse>(
......
......@@ -74,7 +74,7 @@ export const getSystemInfoSync = createApi<typeof uni.getSystemInfoSync>(
/\/[\d\.,]+$/,
/^\s?[\d\.,]+$/,
/\bBrowser\b/i,
/\bMobile\b/i
/\bMobile\b/i,
]
for (let i = 0; i < infos.length; i++) {
const info = infos[i]
......@@ -107,7 +107,7 @@ export const getSystemInfoSync = createApi<typeof uni.getSystemInfoSync>(
top: safeAreaInsets.top,
bottom: windowHeight - safeAreaInsets.bottom,
width: windowWidth - safeAreaInsets.left - safeAreaInsets.right,
height: windowHeight - safeAreaInsets.top - safeAreaInsets.bottom
height: windowHeight - safeAreaInsets.top - safeAreaInsets.bottom,
}
const { top: windowTop, bottom: windowBottom } = getWindowOffset()
......@@ -133,8 +133,8 @@ export const getSystemInfoSync = createApi<typeof uni.getSystemInfoSync>(
top: safeAreaInsets.top,
right: safeAreaInsets.right,
bottom: safeAreaInsets.bottom,
left: safeAreaInsets.left
}
left: safeAreaInsets.left,
},
} as UniApp.GetSystemInfoResult
}
)
import {
API_TYPE_ASYNC,
createApi,
MakePhoneCallProtocol
MakePhoneCallProtocol,
} from '@dcloudio/uni-api'
export const makePhoneCall = createApi<typeof uni.makePhoneCall>(
{ type: API_TYPE_ASYNC, name: 'makePhoneCall' },
option => {
(option) => {
window.location.href = `tel:${option.phoneNumber}`
},
MakePhoneCallProtocol
......
import {
API_TYPE_ASYNC,
createApi,
OpenDocumentProtocol
OpenDocumentProtocol,
} from '@dcloudio/uni-api'
export const openDocument = createApi<typeof uni.openDocument>(
{ type: API_TYPE_ASYNC, name: 'openDocument' },
option => {
(option) => {
window.open(option.filePath)
},
OpenDocumentProtocol
......
......@@ -24,5 +24,5 @@ export {
arrayBufferToBase64,
base64ToArrayBuffer,
createIntersectionObserver,
createSelectorQuery
createSelectorQuery,
} from '@dcloudio/uni-api'
import {
API_TYPE_ASYNC,
createApi,
GetImageInfoOptions,
GetImageInfoProtocol
} from '@dcloudio/uni-api'
function _getServiceAddress() {
return window.location.protocol + '//' + window.location.host
}
export const getImageInfo = createApi<typeof uni.getImageInfo>(
{ type: API_TYPE_ASYNC, name: 'getImageInfo', options: GetImageInfoOptions },
({ src }, callback?: Function) => {
const img = new Image()
img.onload = function() {
callback!({
errMsg: 'getImageInfo:ok',
width: img.naturalWidth,
height: img.naturalHeight,
path: src.indexOf('/') === 0 ? _getServiceAddress() + src : src
})
}
img.onerror = function() {
callback!({
errMsg: 'getImageInfo:fail'
})
}
img.src = src
},
GetImageInfoProtocol
)
import {
API_TYPE_ASYNC,
createApi,
GetImageInfoOptions,
GetImageInfoProtocol,
} from '@dcloudio/uni-api'
function _getServiceAddress() {
return window.location.protocol + '//' + window.location.host
}
export const getImageInfo = createApi<typeof uni.getImageInfo>(
{ type: API_TYPE_ASYNC, name: 'getImageInfo', options: GetImageInfoOptions },
({ src }, callback?: Function) => {
const img = new Image()
img.onload = function () {
callback!({
errMsg: 'getImageInfo:ok',
width: img.naturalWidth,
height: img.naturalHeight,
path: src.indexOf('/') === 0 ? _getServiceAddress() + src : src,
})
}
img.onerror = function () {
callback!({
errMsg: 'getImageInfo:fail',
})
}
img.src = src
},
GetImageInfoProtocol
)
......@@ -2,7 +2,7 @@ import { API_TYPE_ASYNC, createApi } from '@dcloudio/uni-api'
export const navigateTo = createApi<typeof uni.navigateTo>(
{ type: API_TYPE_ASYNC },
options => {
(options) => {
const router = getApp().$router
router.push(options.url)
}
......
......@@ -5,5 +5,5 @@ import { ServiceJSBridge } from '@dcloudio/uni-core'
export const UniServiceJSBridge = extend(ServiceJSBridge, {
publishHandler(event: string, args: any, pageId: number) {
window.UniViewJSBridge.subscribeHandler(event, args, pageId)
}
},
})
......@@ -5,5 +5,5 @@ import { ViewJSBridge } from '@dcloudio/uni-core'
export const UniViewJSBridge = extend(ViewJSBridge, {
publishHandler(event: string, args: any, pageId: number) {
window.UniServiceJSBridge.subscribeHandler(event, args, pageId)
}
},
})
......@@ -49,7 +49,7 @@ export default defineConfig({
minify: false,
assetsDir: '.',
rollupOptions: {
input: 'src/index.ts',
input: path.resolve(__dirname, 'src/index.ts'),
external: ['vue', 'vue-router', '@vue/shared', '@dcloudio/uni-shared'],
preserveEntrySignatures: 'strict',
plugins: [
......
......@@ -23,8 +23,8 @@ const Upx2pxProtocol = [
{
name: 'upx',
type: [Number, String],
required: true
}
required: true,
},
];
const EPS = 1e-4;
......@@ -92,7 +92,7 @@ function queue(hooks, data) {
if (res === false) {
return {
then() { },
catch() { }
catch() { },
};
}
}
......@@ -101,11 +101,11 @@ function queue(hooks, data) {
then(callback) {
return callback(data);
},
catch() { }
catch() { },
});
}
function wrapperOptions(interceptors, options = {}) {
[HOOKS.SUCCESS, HOOKS.FAIL, HOOKS.COMPLETE].forEach(name => {
[HOOKS.SUCCESS, HOOKS.FAIL, HOOKS.COMPLETE].forEach((name) => {
const hooks = interceptors[name];
if (!isArray(hooks)) {
return;
......@@ -128,21 +128,21 @@ function wrapperReturnValue(method, returnValue) {
if (interceptor && isArray(interceptor.returnValue)) {
returnValueHooks.push(...interceptor.returnValue);
}
returnValueHooks.forEach(hook => {
returnValueHooks.forEach((hook) => {
returnValue = hook(returnValue) || returnValue;
});
return returnValue;
}
function getApiInterceptorHooks(method) {
const interceptor = Object.create(null);
Object.keys(globalInterceptors).forEach(hook => {
Object.keys(globalInterceptors).forEach((hook) => {
if (hook !== 'returnValue') {
interceptor[hook] = globalInterceptors[hook].slice();
}
});
const scopedInterceptor = scopedInterceptors[method];
if (scopedInterceptor) {
Object.keys(scopedInterceptor).forEach(hook => {
Object.keys(scopedInterceptor).forEach((hook) => {
if (hook !== 'returnValue') {
interceptor[hook] = (interceptor[hook] || []).concat(scopedInterceptor[hook]);
}
......@@ -155,7 +155,7 @@ function invokeApi(method, api, options, ...params) {
if (interceptor && Object.keys(interceptor).length) {
if (isArray(interceptor.invoke)) {
const res = queue(interceptor.invoke, options);
return res.then(options => {
return res.then((options) => {
return api(wrapperOptions(interceptor, options), ...params);
});
}
......@@ -170,13 +170,13 @@ const AddInterceptorProtocol = [
{
name: 'method',
type: [String, Object],
required: true
}
required: true,
},
];
const RemoveInterceptorProtocol = AddInterceptorProtocol;
function mergeInterceptorHook(interceptors, interceptor) {
Object.keys(interceptor).forEach(hook => {
Object.keys(interceptor).forEach((hook) => {
if (isFunction(interceptor[hook])) {
interceptors[hook] = mergeHook(interceptors[hook], interceptor[hook]);
}
......@@ -186,7 +186,7 @@ function removeInterceptorHook(interceptors, interceptor) {
if (!interceptors || !interceptor) {
return;
}
Object.keys(interceptor).forEach(hook => {
Object.keys(interceptor).forEach((hook) => {
if (isFunction(interceptor[hook])) {
removeHook(interceptors[hook], interceptor[hook]);
}
......@@ -263,10 +263,10 @@ function handlePromise(promise) {
return promise;
}
return promise
.then(data => {
.then((data) => {
return [null, data];
})
.catch(err => [err]);
.catch((err) => [err]);
}
function shouldPromise(name) {
if (isContextApi(name) || isSyncApi(name) || isCallbackApi(name)) {
......@@ -278,7 +278,7 @@ function shouldPromise(name) {
if (!Promise.prototype.finally) {
Promise.prototype.finally = function (onfinally) {
const promise = this.constructor;
return this.then(value => promise.resolve(onfinally && onfinally()).then(() => value), reason => promise.resolve(onfinally && onfinally()).then(() => {
return this.then((value) => promise.resolve(onfinally && onfinally()).then(() => value), (reason) => promise.resolve(onfinally && onfinally()).then(() => {
throw reason;
}));
};
......@@ -299,7 +299,7 @@ function promisify(name, api) {
return wrapperReturnValue(name, handlePromise(new Promise((resolve, reject) => {
invokeApi(name, api, Object.assign({}, options, {
success: resolve,
fail: reject
fail: reject,
}), ...params);
})));
};
......@@ -413,25 +413,25 @@ function initUni(api, protocols) {
// event-api
// provider-api?
return promisify(key, wrapper(key, my[key]));
}
},
};
return new Proxy({}, UniProxyHandlers);
}
function initGetProvider(providers) {
return function getProvider({ service, success, fail, complete }) {
return function getProvider({ service, success, fail, complete, }) {
let res;
if (providers[service]) {
res = {
errMsg: 'getProvider:ok',
service,
provider: providers[service]
provider: providers[service],
};
isFunction(success) && success(res);
}
else {
res = {
errMsg: 'getProvider:fail:服务[' + service + ']不存在'
errMsg: 'getProvider:fail:服务[' + service + ']不存在',
};
isFunction(fail) && fail(res);
}
......@@ -446,7 +446,7 @@ function addSafeAreaInsets(fromRes, toRes) {
top: safeArea.top,
left: safeArea.left,
right: fromRes.windowWidth - safeArea.right,
bottom: fromRes.windowHeight - safeArea.bottom
bottom: fromRes.windowHeight - safeArea.bottom,
};
}
}
......@@ -456,24 +456,24 @@ const getProvider = initGetProvider({
oauth: ['alipay'],
share: ['alipay'],
payment: ['alipay'],
push: ['alipay']
push: ['alipay'],
});
function setStorageSync(key, data) {
return my.setStorageSync({
key,
data
data,
});
}
function getStorageSync(key) {
const result = my.getStorageSync({
key
key,
});
// 支付宝平台会返回一个 success 值,但是目前测试的结果这个始终是 true。当没有存储数据的时候,其它平台会返回空字符串。
return result.data !== null ? result.data : '';
}
function removeStorageSync(key) {
return my.removeStorageSync({
key
key,
});
}
function startGyroscope(args) {
......@@ -482,11 +482,11 @@ function startGyroscope(args) {
}
args.success &&
args.success({
errMsg: 'startGyroscope:ok'
errMsg: 'startGyroscope:ok',
});
args.complete &&
args.complete({
errMsg: 'startGyroscope:ok'
errMsg: 'startGyroscope:ok',
});
}
function createExecCallback(execCallback) {
......@@ -609,16 +609,16 @@ const request = {
fromArgs.header = {};
}
const headers = {
'content-type': 'application/json'
'content-type': 'application/json',
};
Object.keys(fromArgs.header).forEach(key => {
Object.keys(fromArgs.header).forEach((key) => {
headers[key.toLocaleLowerCase()] = fromArgs.header[key];
});
return {
header() {
return {
name: 'headers',
value: headers
value: headers,
};
},
data(data) {
......@@ -629,32 +629,32 @@ const request = {
isPlainObject(data)) {
return {
name: 'data',
value: JSON.stringify(data)
value: JSON.stringify(data),
};
}
return {
name: 'data',
value: data
value: data,
};
},
method: 'method',
responseType: false
responseType: false,
};
},
returnValue: {
status: 'statusCode',
headers: 'header'
}
headers: 'header',
},
};
const setNavigationBarColor = {
name: 'setNavigationBar',
args: {
frontColor: false,
animation: false
}
animation: false,
},
};
const setNavigationBarTitle = {
name: 'setNavigationBar'
name: 'setNavigationBar',
};
function showModal({ showCancel = true } = {}) {
if (showCancel) {
......@@ -664,24 +664,24 @@ function showModal({ showCancel = true } = {}) {
cancelColor: false,
confirmColor: false,
cancelText: 'cancelButtonText',
confirmText: 'confirmButtonText'
confirmText: 'confirmButtonText',
},
returnValue(fromRes, toRes) {
toRes.confirm = fromRes.confirm;
toRes.cancel = !fromRes.confirm;
}
},
};
}
return {
name: 'alert',
args: {
confirmColor: false,
confirmText: 'buttonText'
confirmText: 'buttonText',
},
returnValue(fromRes, toRes) {
toRes.confirm = true;
toRes.cancel = false;
}
},
};
}
function showToast({ icon = 'success' } = {}) {
......@@ -690,50 +690,49 @@ function showToast({ icon = 'success' } = {}) {
icon: 'type',
duration: false,
image: false,
mask: false
mask: false,
};
if (icon === 'loading') {
return {
name: 'showLoading',
args
args,
};
}
return {
name: 'showToast',
args
args,
};
}
const showActionSheet = {
name: 'showActionSheet',
args: {
itemList: 'items',
itemColor: false
itemColor: false,
},
returnValue: {
index: 'tapIndex'
}
index: 'tapIndex',
},
};
const showLoading = {
args: {
title: 'content',
mask: false
}
mask: false,
},
};
const uploadFile = {
args: {
name: 'fileName'
}
// 从测试结果看,是有返回对象的,文档上没有说明。
name: 'fileName',
},
};
const downloadFile = {
returnValue: {
apFilePath: 'tempFilePath'
}
apFilePath: 'tempFilePath',
},
};
const getFileInfo = {
args: {
filePath: 'apFilePath'
}
filePath: 'apFilePath',
},
};
const compressImage = {
args(fromArgs, toArgs) {
......@@ -750,25 +749,24 @@ const compressImage = {
if (apFilePaths && apFilePaths.length) {
toRes.tempFilePath = apFilePaths[0];
}
}
},
};
const chooseVideo = {
// 支付宝小程序文档中未找到(仅在getSetting处提及),但实际可用
returnValue: {
apFilePath: 'tempFilePath'
}
apFilePath: 'tempFilePath',
},
};
const connectSocket = {
args: {
method: false,
protocols: false
}
// TODO 有没有返回值还需要测试下
protocols: false,
},
};
const chooseImage = {
returnValue: {
apFilePaths: 'tempFilePaths'
}
apFilePaths: 'tempFilePaths',
},
};
const previewImage = {
args(fromArgs, toArgs) {
......@@ -785,93 +783,93 @@ const previewImage = {
}
return {
indicator: false,
loop: false
loop: false,
};
}
},
};
const saveFile = {
args: {
tempFilePath: 'apFilePath'
tempFilePath: 'apFilePath',
},
returnValue: {
apFilePath: 'savedFilePath'
}
apFilePath: 'savedFilePath',
},
};
const getSavedFileInfo = {
args: {
filePath: 'apFilePath'
}
filePath: 'apFilePath',
},
};
const getSavedFileList = {
returnValue(fromRes, toRes) {
toRes.fileList = fromRes.fileList.map(file => {
toRes.fileList = fromRes.fileList.map((file) => {
return {
filePath: file.apFilePath,
createTime: file.createTime,
size: file.size
size: file.size,
};
});
}
},
};
const removeSavedFile = {
args: {
filePath: 'apFilePath'
}
filePath: 'apFilePath',
},
};
const getLocation = {
args: {
type: false,
altitude: false
}
altitude: false,
},
};
const openLocation = {
args: {
// TODO address 参数在阿里上是必传的
}
},
};
const getNetworkType = {
returnValue: handleNetworkInfo
returnValue: handleNetworkInfo,
};
const onNetworkStatusChange = {
returnValue: handleNetworkInfo
returnValue: handleNetworkInfo,
};
const stopAccelerometer = {
name: 'offAccelerometerChange'
name: 'offAccelerometerChange',
};
const stopCompass = {
name: 'offCompassChange'
name: 'offCompassChange',
};
const scanCode = {
name: 'scan',
args: {
onlyFromCamera: 'hideAlbum'
onlyFromCamera: 'hideAlbum',
},
returnValue: {
code: 'result'
}
code: 'result',
},
};
const setClipboardData = {
name: 'setClipboard',
args: {
data: 'text'
}
data: 'text',
},
};
const getClipboardData = {
name: 'getClipboard',
returnValue: {
text: 'data'
}
text: 'data',
},
};
const pageScrollTo = {
args: {
duration: false
}
duration: false,
},
};
const login = {
name: 'getAuthCode',
returnValue: {
authCode: 'code'
}
authCode: 'code',
},
};
const getUserInfo = {
name: my.canIUse('getOpenUserInfo') ? 'getOpenUserInfo' : 'getAuthUserInfo',
......@@ -892,86 +890,86 @@ const getUserInfo = {
toRes.userInfo = {
openId: '',
nickName: fromRes.nickName,
avatarUrl: fromRes.avatar
avatarUrl: fromRes.avatar,
};
}
}
},
};
const requestPayment = {
name: 'tradePay',
args: {
orderInfo: 'tradeNO'
}
orderInfo: 'tradeNO',
},
};
const getBLEDeviceServices = {
returnValue(fromRes, toRes) {
toRes.services = fromRes.services.map(item => {
toRes.services = fromRes.services.map((item) => {
return {
uuid: item.serviceId,
isPrimary: item.isPrimary
isPrimary: item.isPrimary,
};
});
}
},
};
const createBLEConnection = {
name: 'connectBLEDevice',
args: {
timeout: false
}
timeout: false,
},
};
const closeBLEConnection = {
name: 'disconnectBLEDevice'
name: 'disconnectBLEDevice',
};
const onBLEConnectionStateChange = {
name: 'onBLEConnectionStateChanged'
name: 'onBLEConnectionStateChanged',
};
const makePhoneCall = {
args: {
phoneNumber: 'number'
}
phoneNumber: 'number',
},
};
const stopGyroscope = {
name: 'offGyroscopeChange'
name: 'offGyroscopeChange',
};
const getSystemInfo = {
returnValue: handleSystemInfo
returnValue: handleSystemInfo,
};
const getSystemInfoSync = {
returnValue: handleSystemInfo
returnValue: handleSystemInfo,
};
// 文档没提到,但是实测可用。
const canvasToTempFilePath = {
returnValue(fromRes, toRes) {
// 真机的情况下会有 tempFilePath 这个值,因此需要主动修改。
toRes.tempFilePath = fromRes.apFilePath;
}
},
};
const setScreenBrightness = {
args: {
value: 'brightness'
}
value: 'brightness',
},
};
const getScreenBrightness = {
returnValue: {
brightness: 'value'
}
brightness: 'value',
},
};
const showShareMenu = {
name: 'showSharePanel'
name: 'showSharePanel',
};
const hideHomeButton = {
name: 'hideBackHome'
name: 'hideBackHome',
};
const saveImageToPhotosAlbum = {
name: 'saveImage',
args: {
filePath: 'url'
}
filePath: 'url',
},
};
const saveVideoToPhotosAlbum = {
args: {
filePath: 'src'
}
filePath: 'src',
},
};
const chooseAddress = {
name: 'getAddress',
......@@ -984,7 +982,7 @@ const chooseAddress = {
toRes.detailInfo = info.address;
toRes.telNumber = info.mobilePhone;
toRes.errMsg = toRes.errMsg + ' ' + fromRes.resultStatus;
}
},
};
var protocols = /*#__PURE__*/Object.freeze({
......
......@@ -50,7 +50,7 @@ const MP_METHODS = [
'createSelectorQuery',
'createIntersectionObserver',
'selectAllComponents',
'selectComponent'
'selectComponent',
];
function createEmitFn(oldEmit, ctx) {
return function emit(event, ...args) {
......@@ -85,7 +85,7 @@ function initBaseInstance(instance, options) {
Object.defineProperty(instance, 'slots', {
get() {
return this.$scope && this.$scope.props.$slots;
}
},
});
}
// $emit
......@@ -94,7 +94,7 @@ function initBaseInstance(instance, options) {
function initComponentInstance(instance, options) {
initBaseInstance(instance, options);
const ctx = instance.ctx;
MP_METHODS.forEach(method => {
MP_METHODS.forEach((method) => {
ctx[method] = function (...args) {
const mpInstance = ctx.$scope;
if (mpInstance && mpInstance[method]) {
......@@ -115,7 +115,7 @@ function initComponentInstance(instance, options) {
}
function initMocks(instance, mpInstance, mocks) {
const ctx = instance.ctx;
mocks.forEach(mock => {
mocks.forEach((mock) => {
if (hasOwn(mpInstance, mock)) {
ctx[mock] = mpInstance[mock];
}
......@@ -134,12 +134,11 @@ const PAGE_HOOKS = [
'onReachBottom',
'onPullDownRefresh',
// 'onShareTimeline', // 右上角菜单,开发者手动注册
'onAddToFavorites'
// 'onShareAppMessage' // 右上角菜单,开发者手动注册
'onAddToFavorites',
];
function findHooks(vueOptions, hooks = new Set()) {
if (vueOptions) {
Object.keys(vueOptions).forEach(name => {
Object.keys(vueOptions).forEach((name) => {
if (name.indexOf('on') === 0 && isFunction(vueOptions[name])) {
hooks.add(name);
}
......@@ -147,7 +146,7 @@ function findHooks(vueOptions, hooks = new Set()) {
if (__VUE_OPTIONS_API__) {
const { extends: extendsOptions, mixins } = vueOptions;
if (mixins) {
mixins.forEach(mixin => findHooks(mixin, hooks));
mixins.forEach((mixin) => findHooks(mixin, hooks));
}
if (extendsOptions) {
findHooks(extendsOptions, hooks);
......@@ -165,10 +164,10 @@ function initHook(mpOptions, hook, excludes) {
}
const EXCLUDE_HOOKS = ['onReady'];
function initHooks(mpOptions, hooks, excludes = EXCLUDE_HOOKS) {
hooks.forEach(hook => initHook(mpOptions, hook, excludes));
hooks.forEach((hook) => initHook(mpOptions, hook, excludes));
}
function initUnknownHooks(mpOptions, vueOptions, excludes = EXCLUDE_HOOKS) {
findHooks(vueOptions).forEach(hook => initHook(mpOptions, hook, excludes));
findHooks(vueOptions).forEach((hook) => initHook(mpOptions, hook, excludes));
}
const HOOKS = [
......@@ -177,7 +176,7 @@ const HOOKS = [
'onError',
'onThemeChange',
'onPageNotFound',
'onUnhandledRejection'
'onUnhandledRejection',
];
function parseApp(instance, parseAppOptions) {
const internalInstance = instance.$;
......@@ -193,11 +192,11 @@ function parseApp(instance, parseAppOptions) {
initBaseInstance(internalInstance, {
mpType: 'app',
mpInstance: this,
slots: []
slots: [],
});
ctx.globalData = this.globalData;
instance.$callHook('onLaunch', options);
}
},
};
const vueOptions = instance.$.type;
initHooks(appOptions, HOOKS);
......@@ -221,7 +220,7 @@ const encode = encodeURIComponent;
function stringifyQuery(obj, encodeStr = encode) {
const res = obj
? Object.keys(obj)
.map(key => {
.map((key) => {
let val = obj[key];
if (typeof val === undefined || val === null) {
val = '';
......@@ -231,7 +230,7 @@ function stringifyQuery(obj, encodeStr = encode) {
}
return encodeStr(key) + '=' + encodeStr(val);
})
.filter(x => x.length > 0)
.filter((x) => x.length > 0)
.join('&')
: null;
return res ? `?${res}` : '';
......@@ -294,7 +293,7 @@ function initDefaultProps(isBehavior = false) {
if (!isBehavior) {
properties.vueId = {
type: String,
value: ''
value: '',
};
// 小程序不能直接定义 $slots 的 props,所以通过 vueSlots 转换到 $slots
properties.vueSlots = {
......@@ -306,9 +305,9 @@ function initDefaultProps(isBehavior = false) {
$slots[slotName] = true;
});
this.setData({
$slots
$slots,
});
}
},
};
}
return properties;
......@@ -321,14 +320,14 @@ function createProperty(key, prop) {
function initProps(mpComponentOptions, rawProps, isBehavior = false) {
const properties = initDefaultProps(isBehavior);
if (isArray(rawProps)) {
rawProps.forEach(key => {
rawProps.forEach((key) => {
properties[key] = createProperty(key, {
type: null
type: null,
});
});
}
else if (isPlainObject(rawProps)) {
Object.keys(rawProps).forEach(key => {
Object.keys(rawProps).forEach((key) => {
const opts = rawProps[key];
if (isPlainObject(opts)) {
// title:{type:String,default:''}
......@@ -340,14 +339,14 @@ function initProps(mpComponentOptions, rawProps, isBehavior = false) {
opts.type = parsePropType(key, type);
properties[key] = createProperty(key, {
type: PROP_TYPES.indexOf(type) !== -1 ? type : null,
value
value,
});
}
else {
// content:String
const type = parsePropType(key, opts);
properties[key] = createProperty(key, {
type: PROP_TYPES.indexOf(type) !== -1 ? type : null
type: PROP_TYPES.indexOf(type) !== -1 ? type : null,
});
}
});
......@@ -391,7 +390,7 @@ function initBehaviors(vueOptions, initBehavior) {
}
const behaviors = [];
if (isArray(vueBehaviors)) {
vueBehaviors.forEach(behavior => {
vueBehaviors.forEach((behavior) => {
behaviors.push(behavior.replace('uni://', `${__PLATFORM_PREFIX__}://`));
if (behavior === 'uni://form-field') {
if (isArray(vueProps)) {
......@@ -401,11 +400,11 @@ function initBehaviors(vueOptions, initBehavior) {
else {
vueProps.name = {
type: String,
default: ''
default: '',
};
vueProps.value = {
type: [String, Number, Boolean, Array, Object, Date],
default: ''
default: '',
};
}
}
......@@ -417,7 +416,7 @@ function initBehaviors(vueOptions, initBehavior) {
behaviors.push(initBehavior(behavior));
}
if (isArray(vueMixins)) {
vueMixins.forEach(vueMixin => {
vueMixins.forEach((vueMixin) => {
if (vueMixin.props) {
const behavior = {};
initProps(behavior, vueMixin.props, true);
......@@ -442,7 +441,7 @@ function getValue(obj, path) {
}
function getExtraValue(instance, dataPathsArray) {
let context = instance;
dataPathsArray.forEach(dataPathArray => {
dataPathsArray.forEach((dataPathArray) => {
const dataPath = dataPathArray[0];
const value = dataPathArray[2];
if (dataPath || typeof value !== 'undefined') {
......@@ -472,12 +471,12 @@ function getExtraValue(instance, dataPathsArray) {
}
else {
if (isArray(vFor)) {
context = vFor.find(vForItem => {
context = vFor.find((vForItem) => {
return getValue(vForItem, propPath) === value;
});
}
else if (isPlainObject(vFor)) {
context = Object.keys(vFor).find(vForKey => {
context = Object.keys(vFor).find((vForKey) => {
return getValue(vFor[vForKey], propPath) === value;
});
}
......@@ -567,7 +566,7 @@ function processEventArgs(instance, event, args = [], extra = [], isCustom, meth
}
const extraObj = processEventExtra(instance, extra, event);
const ret = [];
args.forEach(arg => {
args.forEach((arg) => {
if (arg === '$event') {
if (methodName === '__set_model' && !isCustom) {
// input v-model value
......@@ -719,7 +718,7 @@ function onAliGetAuthorize(method, $event) {
$event.type = 'getphonenumber';
$event.detail.errMsg = 'getPhoneNumber:fail';
this[method]($event);
}
},
});
}
function parse(appOptions) {
......@@ -815,11 +814,11 @@ function customize(str) {
}
function initBehavior({ properties }) {
const props = {};
Object.keys(properties).forEach(key => {
Object.keys(properties).forEach((key) => {
props[key] = properties[key].value;
});
return {
props
props,
};
}
function initRelation(mpInstance, detail) {
......@@ -859,10 +858,10 @@ function initChildVues(mpInstance) {
}
const childVues = mpInstance._$childVues;
if (childVues) {
childVues.forEach(relationOptions => {
childVues.forEach((relationOptions) => {
// 父子关系
handleLink.call(mpInstance, {
detail: relationOptions
detail: relationOptions,
});
const { mpInstance: childMPInstance, createComponent } = relationOptions;
childMPInstance.$vm = createComponent(relationOptions.parent);
......@@ -904,14 +903,14 @@ function triggerEvent(type, detail) {
const eventOpts = this.props['data-event-opts'];
const target = {
dataset: {
eventOpts
}
eventOpts,
},
};
handler({
type: customize(type),
target,
currentTarget: target,
detail
detail,
});
}
const IGNORES = ['$slots', '$scopedSlots'];
......@@ -922,7 +921,7 @@ function createObserver(isDidUpdate = false) {
if (equal(prevProps, nextProps)) {
return;
}
Object.keys(prevProps).forEach(name => {
Object.keys(prevProps).forEach((name) => {
if (IGNORES.indexOf(name) === -1) {
const prevValue = prevProps[name];
const nextValue = nextProps[name];
......@@ -939,7 +938,7 @@ const handleLink$1 = (function () {
if (isComponent2) {
return function handleLink$1(detail) {
return handleLink.call(this, {
detail
detail,
});
};
}
......@@ -947,7 +946,7 @@ const handleLink$1 = (function () {
if (this.$vm && this.$vm.$.isMounted) {
// 父已初始化
return handleLink.call(this, {
detail
detail,
});
}
(this._$childVues || (this._$childVues = [])).unshift(detail);
......@@ -956,7 +955,7 @@ const handleLink$1 = (function () {
function createVueComponent(mpType, mpInstance, vueOptions, parent) {
return $createComponent({
type: vueOptions,
props: mpInstance.props
props: mpInstance.props,
}, {
mpType,
mpInstance,
......@@ -964,7 +963,7 @@ function createVueComponent(mpType, mpInstance, vueOptions, parent) {
onBeforeSetup(instance, options) {
initMocks(instance, mpInstance, mocks);
initComponentInstance(instance, options);
}
},
});
}
......@@ -974,7 +973,7 @@ function createPage(vueOptions) {
onLoad(query) {
this.options = query;
this.$page = {
fullPath: '/' + this.route + stringifyQuery(query)
fullPath: '/' + this.route + stringifyQuery(query),
};
// 初始化 vue 实例
this.$vm = createVueComponent('page', this, vueOptions);
......@@ -996,11 +995,11 @@ function createPage(vueOptions) {
// 支付宝小程序有些页面事件只能放在events下
onBack() {
this.$vm.$callHook('onBackPress');
}
},
},
__r: handleRef,
__e: handleEvent,
__l: handleLink$1
__l: handleLink$1,
};
if (__VUE_OPTIONS_API__) {
pageOptions.data = initData(vueOptions);
......@@ -1013,14 +1012,14 @@ function createPage(vueOptions) {
function initComponentProps(rawProps) {
const propertiesOptions = {
properties: {}
properties: {},
};
initProps(propertiesOptions, rawProps, false);
const properties = propertiesOptions.properties;
const props = {
onVueInit: function () { }
onVueInit: function () { },
};
Object.keys(properties).forEach(key => {
Object.keys(properties).forEach((key) => {
if (key !== 'vueSlots') {
props[key] = properties[key].value;
}
......@@ -1036,7 +1035,7 @@ function initVm(mpInstance, createComponent) {
const relationOptions = {
vuePid: mpInstance._$vuePid,
mpInstance,
createComponent
createComponent,
};
if (isComponent2) {
// 处理父子关系
......@@ -1086,8 +1085,8 @@ function createComponent(vueOptions) {
__r: handleRef,
__e: handleEvent,
__l: handleLink$1,
triggerEvent
}
triggerEvent,
},
};
if (__VUE_OPTIONS_API__) {
mpComponentOptions.data = initData(vueOptions);
......
......@@ -56,16 +56,16 @@ export const request = {
fromArgs.header = {}
}
const headers: Record<string, string> = {
'content-type': 'application/json'
'content-type': 'application/json',
}
Object.keys(fromArgs.header).forEach(key => {
Object.keys(fromArgs.header).forEach((key) => {
headers[key.toLocaleLowerCase()] = fromArgs.header[key]
})
return {
header() {
return {
name: 'headers',
value: headers
value: headers,
}
},
data(data: unknown) {
......@@ -78,32 +78,32 @@ export const request = {
) {
return {
name: 'data',
value: JSON.stringify(data)
value: JSON.stringify(data),
}
}
return {
name: 'data',
value: data
value: data,
}
},
method: 'method', // TODO 支付宝小程序仅支持 get,post
responseType: false
responseType: false,
}
},
returnValue: {
status: 'statusCode',
headers: 'header'
}
headers: 'header',
},
}
export const setNavigationBarColor = {
name: 'setNavigationBar',
args: {
frontColor: false,
animation: false
}
animation: false,
},
}
export const setNavigationBarTitle = {
name: 'setNavigationBar'
name: 'setNavigationBar',
}
export function showModal({ showCancel = true }: UniApp.ShowModalOptions = {}) {
if (showCancel) {
......@@ -113,7 +113,7 @@ export function showModal({ showCancel = true }: UniApp.ShowModalOptions = {}) {
cancelColor: false,
confirmColor: false,
cancelText: 'cancelButtonText',
confirmText: 'confirmButtonText'
confirmText: 'confirmButtonText',
},
returnValue(
fromRes: my.IConfirmSuccessResult,
......@@ -121,19 +121,19 @@ export function showModal({ showCancel = true }: UniApp.ShowModalOptions = {}) {
) {
toRes.confirm = fromRes.confirm
toRes.cancel = !fromRes.confirm
}
},
}
}
return {
name: 'alert',
args: {
confirmColor: false,
confirmText: 'buttonText'
confirmText: 'buttonText',
},
returnValue(fromRes: unknown, toRes: UniApp.ShowModalRes) {
toRes.confirm = true
toRes.cancel = false
}
},
}
}
export function showToast({ icon = 'success' }: UniApp.ShowToastOptions = {}) {
......@@ -142,50 +142,50 @@ export function showToast({ icon = 'success' }: UniApp.ShowToastOptions = {}) {
icon: 'type',
duration: false,
image: false,
mask: false
mask: false,
}
if (icon === 'loading') {
return {
name: 'showLoading',
args
args,
}
}
return {
name: 'showToast',
args
args,
}
}
export const showActionSheet = {
name: 'showActionSheet',
args: {
itemList: 'items',
itemColor: false
itemColor: false,
},
returnValue: {
index: 'tapIndex'
}
index: 'tapIndex',
},
}
export const showLoading = {
args: {
title: 'content',
mask: false
}
mask: false,
},
}
export const uploadFile = {
args: {
name: 'fileName'
}
name: 'fileName',
},
// 从测试结果看,是有返回对象的,文档上没有说明。
}
export const downloadFile = {
returnValue: {
apFilePath: 'tempFilePath'
}
apFilePath: 'tempFilePath',
},
}
export const getFileInfo = {
args: {
filePath: 'apFilePath'
}
filePath: 'apFilePath',
},
}
export const compressImage = {
args(
......@@ -208,25 +208,25 @@ export const compressImage = {
if (apFilePaths && apFilePaths.length) {
toRes.tempFilePath = apFilePaths[0]
}
}
},
}
export const chooseVideo = {
// 支付宝小程序文档中未找到(仅在getSetting处提及),但实际可用
returnValue: {
apFilePath: 'tempFilePath'
}
apFilePath: 'tempFilePath',
},
}
export const connectSocket = {
args: {
method: false,
protocols: false
}
protocols: false,
},
// TODO 有没有返回值还需要测试下
}
export const chooseImage = {
returnValue: {
apFilePaths: 'tempFilePaths'
}
apFilePaths: 'tempFilePaths',
},
}
export const previewImage = {
args(fromArgs: UniApp.PreviewImageOptions, toArgs: my.IPreviewImageOptions) {
......@@ -242,96 +242,96 @@ export const previewImage = {
}
return {
indicator: false,
loop: false
loop: false,
}
}
},
}
export const saveFile = {
args: {
tempFilePath: 'apFilePath'
tempFilePath: 'apFilePath',
},
returnValue: {
apFilePath: 'savedFilePath'
}
apFilePath: 'savedFilePath',
},
}
export const getSavedFileInfo = {
args: {
filePath: 'apFilePath'
}
filePath: 'apFilePath',
},
}
export const getSavedFileList = {
returnValue(
fromRes: my.IGetSavedFileListSuccessResult,
toRes: UniApp.GetSavedFileListSuccess
) {
toRes.fileList = fromRes.fileList.map(file => {
toRes.fileList = fromRes.fileList.map((file) => {
return {
filePath: (file as any).apFilePath, // mini-types file.d.ts 不正确
createTime: file.createTime,
size: file.size
size: file.size,
}
})
}
},
}
export const removeSavedFile = {
args: {
filePath: 'apFilePath'
}
filePath: 'apFilePath',
},
}
export const getLocation = {
args: {
type: false,
altitude: false
}
altitude: false,
},
}
export const openLocation = {
args: {
// TODO address 参数在阿里上是必传的
}
},
}
export const getNetworkType = {
returnValue: handleNetworkInfo
returnValue: handleNetworkInfo,
}
export const onNetworkStatusChange = {
returnValue: handleNetworkInfo
returnValue: handleNetworkInfo,
}
export const stopAccelerometer = {
name: 'offAccelerometerChange'
name: 'offAccelerometerChange',
}
export const stopCompass = {
name: 'offCompassChange'
name: 'offCompassChange',
}
export const scanCode = {
name: 'scan',
args: {
onlyFromCamera: 'hideAlbum'
onlyFromCamera: 'hideAlbum',
},
returnValue: {
code: 'result'
}
code: 'result',
},
}
export const setClipboardData = {
name: 'setClipboard',
args: {
data: 'text'
}
data: 'text',
},
}
export const getClipboardData = {
name: 'getClipboard',
returnValue: {
text: 'data'
}
text: 'data',
},
}
export const pageScrollTo = {
args: {
duration: false
}
duration: false,
},
}
export const login = {
name: 'getAuthCode',
returnValue: {
authCode: 'code'
}
authCode: 'code',
},
}
export const getUserInfo = {
name: my.canIUse('getOpenUserInfo') ? 'getOpenUserInfo' : 'getAuthUserInfo',
......@@ -353,55 +353,55 @@ export const getUserInfo = {
toRes.userInfo = {
openId: '',
nickName: fromRes.nickName,
avatarUrl: fromRes.avatar
avatarUrl: fromRes.avatar,
}
}
}
},
}
export const requestPayment = {
name: 'tradePay',
args: {
orderInfo: 'tradeNO'
}
orderInfo: 'tradeNO',
},
}
export const getBLEDeviceServices = {
returnValue(
fromRes: my.IGetBLEDeviceServicesSuccessResult,
toRes: UniApp.GetBLEDeviceServicesSuccess
) {
toRes.services = fromRes.services.map(item => {
toRes.services = fromRes.services.map((item) => {
return {
uuid: item.serviceId,
isPrimary: item.isPrimary
isPrimary: item.isPrimary,
}
})
}
},
}
export const createBLEConnection = {
name: 'connectBLEDevice',
args: {
timeout: false
}
timeout: false,
},
}
export const closeBLEConnection = {
name: 'disconnectBLEDevice'
name: 'disconnectBLEDevice',
}
export const onBLEConnectionStateChange = {
name: 'onBLEConnectionStateChanged'
name: 'onBLEConnectionStateChanged',
}
export const makePhoneCall = {
args: {
phoneNumber: 'number'
}
phoneNumber: 'number',
},
}
export const stopGyroscope = {
name: 'offGyroscopeChange'
name: 'offGyroscopeChange',
}
export const getSystemInfo = {
returnValue: handleSystemInfo
returnValue: handleSystemInfo,
}
export const getSystemInfoSync = {
returnValue: handleSystemInfo
returnValue: handleSystemInfo,
}
// 文档没提到,但是实测可用。
export const canvasToTempFilePath = {
......@@ -411,34 +411,34 @@ export const canvasToTempFilePath = {
) {
// 真机的情况下会有 tempFilePath 这个值,因此需要主动修改。
toRes.tempFilePath = fromRes.apFilePath
}
},
}
export const setScreenBrightness = {
args: {
value: 'brightness'
}
value: 'brightness',
},
}
export const getScreenBrightness = {
returnValue: {
brightness: 'value'
}
brightness: 'value',
},
}
export const showShareMenu = {
name: 'showSharePanel'
name: 'showSharePanel',
}
export const hideHomeButton = {
name: 'hideBackHome'
name: 'hideBackHome',
}
export const saveImageToPhotosAlbum = {
name: 'saveImage',
args: {
filePath: 'url'
}
filePath: 'url',
},
}
export const saveVideoToPhotosAlbum = {
args: {
filePath: 'src'
}
filePath: 'src',
},
}
export const chooseAddress = {
name: 'getAddress',
......@@ -451,5 +451,5 @@ export const chooseAddress = {
toRes.detailInfo = info.address
toRes.telNumber = info.mobilePhone
toRes.errMsg = toRes.errMsg + ' ' + fromRes.resultStatus
}
},
}
......@@ -6,19 +6,19 @@ export const getProvider = initGetProvider({
oauth: ['alipay'],
share: ['alipay'],
payment: ['alipay'],
push: ['alipay']
push: ['alipay'],
})
export function setStorageSync(key: string, data: any) {
return my.setStorageSync({
key,
data
data,
})
}
export function getStorageSync(key: string) {
const result = my.getStorageSync({
key
key,
})
// 支付宝平台会返回一个 success 值,但是目前测试的结果这个始终是 true。当没有存储数据的时候,其它平台会返回空字符串。
return result.data !== null ? result.data : ''
......@@ -26,7 +26,7 @@ export function getStorageSync(key: string) {
export function removeStorageSync(key: string) {
return my.removeStorageSync({
key
key,
})
}
......@@ -36,11 +36,11 @@ export function startGyroscope(args: UniApp.StartGyroscopeOptions) {
}
args.success &&
args.success({
errMsg: 'startGyroscope:ok'
errMsg: 'startGyroscope:ok',
})
args.complete &&
args.complete({
errMsg: 'startGyroscope:ok'
errMsg: 'startGyroscope:ok',
})
}
......@@ -87,7 +87,7 @@ export function createSelectorQuery() {
}
if (!(query as any).fields) {
;(query as any).fields = function(
;(query as any).fields = function (
{ rect, size, scrollOffset }: UniApp.NodeField,
callback: Function
) {
......@@ -103,7 +103,7 @@ export function createSelectorQuery() {
}
if (!(query as any).in) {
;(query as any).in = function() {
;(query as any).in = function () {
return this
}
}
......
......@@ -6,7 +6,7 @@ import {
handleEvent,
$destroyComponent,
initVueIds,
initWxsCallMethods
initWxsCallMethods,
} from '@dcloudio/uni-mp-core'
import {
initBehavior,
......@@ -20,7 +20,7 @@ import {
initChildVues,
createVueComponent,
RelationOptions,
createObserver
createObserver,
} from './util'
declare function Component<P, D, M extends tinyapp.IComponentMethods>(
......@@ -29,14 +29,14 @@ declare function Component<P, D, M extends tinyapp.IComponentMethods>(
function initComponentProps(rawProps: Record<string, any>) {
const propertiesOptions = {
properties: {}
properties: {},
}
initProps(propertiesOptions, rawProps, false)
const properties = propertiesOptions.properties as Record<string, any>
const props: Record<string, any> = {
onVueInit: function() {}
onVueInit: function () {},
}
Object.keys(properties).forEach(key => {
Object.keys(properties).forEach((key) => {
if (key !== 'vueSlots') {
props[key] = properties[key].value
}
......@@ -57,7 +57,7 @@ function initVm(
const relationOptions: RelationOptions = {
vuePid: mpInstance._$vuePid,
mpInstance,
createComponent
createComponent,
}
if (isComponent2) {
// 处理父子关系
......@@ -106,8 +106,8 @@ export function createComponent(vueOptions: ComponentOptions) {
__r: handleRef,
__e: handleEvent,
__l: handleLink,
triggerEvent
}
triggerEvent,
},
}
if (__VUE_OPTIONS_API__) {
mpComponentOptions.data = initData(vueOptions)
......
......@@ -7,7 +7,7 @@ import {
initHooks,
initUnknownHooks,
$destroyComponent,
initWxsCallMethods
initWxsCallMethods,
} from '@dcloudio/uni-mp-core'
import { stringifyQuery } from '@dcloudio/uni-shared'
......@@ -17,7 +17,7 @@ import {
handleLink,
initChildVues,
initSpecialMethods,
createVueComponent
createVueComponent,
} from './util'
declare function Page<D>(options: tinyapp.PageOptions<D>): void
......@@ -28,7 +28,7 @@ export function createPage(vueOptions: ComponentOptions) {
onLoad(query) {
this.options = query
this.$page = {
fullPath: '/' + this.route + stringifyQuery(query)
fullPath: '/' + this.route + stringifyQuery(query),
}
// 初始化 vue 实例
this.$vm = createVueComponent('page', this, vueOptions)
......@@ -50,11 +50,11 @@ export function createPage(vueOptions: ComponentOptions) {
// 支付宝小程序有些页面事件只能放在events下
onBack() {
this.$vm.$callHook('onBackPress')
}
},
},
__r: handleRef,
__e: handleEvent,
__l: handleLink
__l: handleLink,
}
if (__VUE_OPTIONS_API__) {
pageOptions.data = initData(vueOptions)
......
import { hasOwn, isArray } from '@vue/shared'
export default function equal(a: any, b: any) {
if (a === b) return true
if (a && b && typeof a === 'object' && typeof b === 'object') {
const arrA = isArray(a)
const arrB = isArray(b)
let i, length, key
if (arrA && arrB) {
length = a.length
if (length !== b.length) return false
for (i = length; i-- !== 0; ) {
if (!equal(a[i], b[i])) return false
}
return true
}
if (arrA !== arrB) return false
const dateA = a instanceof Date
const dateB = b instanceof Date
if (dateA !== dateB) return false
if (dateA && dateB) return a.getTime() === b.getTime()
const regexpA = a instanceof RegExp
const regexpB = b instanceof RegExp
if (regexpA !== regexpB) return false
if (regexpA && regexpB) return a.toString() === b.toString()
const keys = Object.keys(a)
length = keys.length
if (length !== Object.keys(b).length) {
return false
}
for (i = length; i-- !== 0; ) {
if (!hasOwn(b, keys[i])) return false
}
for (i = length; i-- !== 0; ) {
key = keys[i]
if (!equal(a[key], b[key])) return false
}
return true
}
return false
}
import { hasOwn, isArray } from '@vue/shared'
export default function equal(a: any, b: any) {
if (a === b) return true
if (a && b && typeof a === 'object' && typeof b === 'object') {
const arrA = isArray(a)
const arrB = isArray(b)
let i, length, key
if (arrA && arrB) {
length = a.length
if (length !== b.length) return false
for (i = length; i-- !== 0; ) {
if (!equal(a[i], b[i])) return false
}
return true
}
if (arrA !== arrB) return false
const dateA = a instanceof Date
const dateB = b instanceof Date
if (dateA !== dateB) return false
if (dateA && dateB) return a.getTime() === b.getTime()
const regexpA = a instanceof RegExp
const regexpB = b instanceof RegExp
if (regexpA !== regexpB) return false
if (regexpA && regexpB) return a.toString() === b.toString()
const keys = Object.keys(a)
length = keys.length
if (length !== Object.keys(b).length) {
return false
}
for (i = length; i-- !== 0; ) {
if (!hasOwn(b, keys[i])) return false
}
for (i = length; i-- !== 0; ) {
key = keys[i]
if (!equal(a[key], b[key])) return false
}
return true
}
return false
}
......@@ -35,7 +35,7 @@ function onAliGetAuthorize(
$event.type = 'getphonenumber'
$event.detail.errMsg = 'getPhoneNumber:fail'
;(this as any)[method]($event)
}
},
})
}
......
......@@ -3,14 +3,14 @@ import { hasOwn, isFunction, camelize, EMPTY_OBJ } from '@vue/shared'
import {
ComponentPublicInstance,
ComponentOptions,
ComponentInternalInstance
ComponentInternalInstance,
} from 'vue'
import {
initMocks,
$createComponent,
initComponentInstance,
CreateComponentOptions
CreateComponentOptions,
} from '@dcloudio/uni-mp-core'
import { handleLink as handleBaseLink } from '@dcloudio/uni-mp-weixin'
......@@ -35,11 +35,11 @@ function customize(str: string) {
export function initBehavior({ properties }: Record<string, any>) {
const props: Record<string, any> = {}
Object.keys(properties).forEach(key => {
Object.keys(properties).forEach((key) => {
props[key] = properties[key].value
})
return {
props
props,
}
}
......@@ -68,7 +68,7 @@ export function initSpecialMethods(
if (specialMethods) {
specialMethods.forEach((method: string) => {
if (isFunction(mpInstance.$vm[method])) {
mpInstance[method] = function(event: Record<string, any>) {
mpInstance[method] = function (event: Record<string, any>) {
if (hasOwn(event, 'markerId')) {
event.detail = typeof event.detail === 'object' ? event.detail : {}
event.detail.markerId = event.markerId
......@@ -97,10 +97,10 @@ export function initChildVues(
}
const childVues = mpInstance._$childVues as RelationOptions[]
if (childVues) {
childVues.forEach(relationOptions => {
childVues.forEach((relationOptions) => {
// 父子关系
handleBaseLink.call(mpInstance as any, {
detail: relationOptions
detail: relationOptions,
})
const { mpInstance: childMPInstance, createComponent } = relationOptions
......@@ -157,15 +157,15 @@ export function triggerEvent(
const target = {
dataset: {
eventOpts
}
eventOpts,
},
}
handler({
type: customize(type),
target,
currentTarget: target,
detail
detail,
})
}
......@@ -181,7 +181,7 @@ export function createObserver(isDidUpdate: boolean = false) {
if (deepEqual(prevProps, nextProps)) {
return
}
Object.keys(prevProps).forEach(name => {
Object.keys(prevProps).forEach((name) => {
if (IGNORES.indexOf(name) === -1) {
const prevValue = prevProps[name]
const nextValue = nextProps[name]
......@@ -197,14 +197,14 @@ export function createObserver(isDidUpdate: boolean = false) {
}
}
export const handleLink = (function() {
export const handleLink = (function () {
if (isComponent2) {
return function handleLink(
this: MPComponentInstance,
detail: RelationOptions
) {
return handleBaseLink.call(this as any, {
detail
detail,
})
}
}
......@@ -215,7 +215,7 @@ export const handleLink = (function() {
if (this.$vm && this.$vm.$.isMounted) {
// 父已初始化
return handleBaseLink.call(this as any, {
detail
detail,
})
}
// 支付宝通过 didMount 来实现,先子后父,故等父 ready 之后,统一初始化
......@@ -232,7 +232,7 @@ export function createVueComponent(
return $createComponent(
{
type: vueOptions,
props: mpInstance.props
props: mpInstance.props,
},
{
mpType,
......@@ -244,7 +244,7 @@ export function createVueComponent(
) {
initMocks(instance, mpInstance as any, mocks)
initComponentInstance(instance, options)
}
},
}
) as ComponentPublicInstance
}
......@@ -23,8 +23,8 @@ const Upx2pxProtocol = [
{
name: 'upx',
type: [Number, String],
required: true
}
required: true,
},
];
const EPS = 1e-4;
......@@ -92,7 +92,7 @@ function queue(hooks, data) {
if (res === false) {
return {
then() { },
catch() { }
catch() { },
};
}
}
......@@ -101,11 +101,11 @@ function queue(hooks, data) {
then(callback) {
return callback(data);
},
catch() { }
catch() { },
});
}
function wrapperOptions(interceptors, options = {}) {
[HOOKS.SUCCESS, HOOKS.FAIL, HOOKS.COMPLETE].forEach(name => {
[HOOKS.SUCCESS, HOOKS.FAIL, HOOKS.COMPLETE].forEach((name) => {
const hooks = interceptors[name];
if (!isArray(hooks)) {
return;
......@@ -128,21 +128,21 @@ function wrapperReturnValue(method, returnValue) {
if (interceptor && isArray(interceptor.returnValue)) {
returnValueHooks.push(...interceptor.returnValue);
}
returnValueHooks.forEach(hook => {
returnValueHooks.forEach((hook) => {
returnValue = hook(returnValue) || returnValue;
});
return returnValue;
}
function getApiInterceptorHooks(method) {
const interceptor = Object.create(null);
Object.keys(globalInterceptors).forEach(hook => {
Object.keys(globalInterceptors).forEach((hook) => {
if (hook !== 'returnValue') {
interceptor[hook] = globalInterceptors[hook].slice();
}
});
const scopedInterceptor = scopedInterceptors[method];
if (scopedInterceptor) {
Object.keys(scopedInterceptor).forEach(hook => {
Object.keys(scopedInterceptor).forEach((hook) => {
if (hook !== 'returnValue') {
interceptor[hook] = (interceptor[hook] || []).concat(scopedInterceptor[hook]);
}
......@@ -155,7 +155,7 @@ function invokeApi(method, api, options, ...params) {
if (interceptor && Object.keys(interceptor).length) {
if (isArray(interceptor.invoke)) {
const res = queue(interceptor.invoke, options);
return res.then(options => {
return res.then((options) => {
return api(wrapperOptions(interceptor, options), ...params);
});
}
......@@ -170,13 +170,13 @@ const AddInterceptorProtocol = [
{
name: 'method',
type: [String, Object],
required: true
}
required: true,
},
];
const RemoveInterceptorProtocol = AddInterceptorProtocol;
function mergeInterceptorHook(interceptors, interceptor) {
Object.keys(interceptor).forEach(hook => {
Object.keys(interceptor).forEach((hook) => {
if (isFunction(interceptor[hook])) {
interceptors[hook] = mergeHook(interceptors[hook], interceptor[hook]);
}
......@@ -186,7 +186,7 @@ function removeInterceptorHook(interceptors, interceptor) {
if (!interceptors || !interceptor) {
return;
}
Object.keys(interceptor).forEach(hook => {
Object.keys(interceptor).forEach((hook) => {
if (isFunction(interceptor[hook])) {
removeHook(interceptors[hook], interceptor[hook]);
}
......@@ -263,10 +263,10 @@ function handlePromise(promise) {
return promise;
}
return promise
.then(data => {
.then((data) => {
return [null, data];
})
.catch(err => [err]);
.catch((err) => [err]);
}
function shouldPromise(name) {
if (isContextApi(name) || isSyncApi(name) || isCallbackApi(name)) {
......@@ -278,7 +278,7 @@ function shouldPromise(name) {
if (!Promise.prototype.finally) {
Promise.prototype.finally = function (onfinally) {
const promise = this.constructor;
return this.then(value => promise.resolve(onfinally && onfinally()).then(() => value), reason => promise.resolve(onfinally && onfinally()).then(() => {
return this.then((value) => promise.resolve(onfinally && onfinally()).then(() => value), (reason) => promise.resolve(onfinally && onfinally()).then(() => {
throw reason;
}));
};
......@@ -299,7 +299,7 @@ function promisify(name, api) {
return wrapperReturnValue(name, handlePromise(new Promise((resolve, reject) => {
invokeApi(name, api, Object.assign({}, options, {
success: resolve,
fail: reject
fail: reject,
}), ...params);
})));
};
......@@ -413,25 +413,25 @@ function initUni(api, protocols) {
// event-api
// provider-api?
return promisify(key, wrapper(key, swan[key]));
}
},
};
return new Proxy({}, UniProxyHandlers);
}
function initGetProvider(providers) {
return function getProvider({ service, success, fail, complete }) {
return function getProvider({ service, success, fail, complete, }) {
let res;
if (providers[service]) {
res = {
errMsg: 'getProvider:ok',
service,
provider: providers[service]
provider: providers[service],
};
isFunction(success) && success(res);
}
else {
res = {
errMsg: 'getProvider:fail:服务[' + service + ']不存在'
errMsg: 'getProvider:fail:服务[' + service + ']不存在',
};
isFunction(fail) && fail(res);
}
......@@ -468,9 +468,9 @@ const previewImage = {
}
return {
indicator: false,
loop: false
loop: false,
};
}
},
};
function addSafeAreaInsets(fromRes, toRes) {
if (fromRes.safeArea) {
......@@ -479,12 +479,12 @@ function addSafeAreaInsets(fromRes, toRes) {
top: safeArea.top,
left: safeArea.left,
right: fromRes.windowWidth - safeArea.right,
bottom: fromRes.windowHeight - safeArea.bottom
bottom: fromRes.windowHeight - safeArea.bottom,
};
}
}
const getSystemInfo = {
returnValue: addSafeAreaInsets
returnValue: addSafeAreaInsets,
};
const getSystemInfoSync = getSystemInfo;
const redirectTo = {};
......@@ -493,7 +493,7 @@ const getProvider = initGetProvider({
oauth: ['baidu'],
share: ['baidu'],
payment: ['baidu'],
push: ['baidu']
push: ['baidu'],
});
function requestPayment(params) {
let parseError = false;
......@@ -508,7 +508,7 @@ function requestPayment(params) {
if (parseError) {
params.fail &&
params.fail({
errMsg: 'requestPayment:fail: 参数 orderInfo 数据结构不正确,参考:https://uniapp.dcloud.io/api/plugins/payment?id=orderinfo'
errMsg: 'requestPayment:fail: 参数 orderInfo 数据结构不正确,参考:https://uniapp.dcloud.io/api/plugins/payment?id=orderinfo',
});
}
else {
......@@ -537,58 +537,58 @@ const request = {
dataType(type) {
return {
name: 'dataType',
value: type === 'json' ? type : 'string'
value: type === 'json' ? type : 'string',
};
}
},
};
}
},
};
const connectSocket = {
args: {
method: false
}
method: false,
},
};
const getRecorderManager = {
returnValue(fromRes, toRes) {
toRes.onFrameRecorded = createTodoMethod('RecorderManager', 'onFrameRecorded');
}
},
};
const getBackgroundAudioManager = {
returnValue(fromRes, toRes) {
toRes.onPrev = createTodoMethod('BackgroundAudioManager', 'onPrev');
toRes.onNext = createTodoMethod('BackgroundAudioManager', 'onNext');
}
},
};
const scanCode = {
args: {
onlyFromCamera: false,
scanType: false
}
scanType: false,
},
};
const navigateToMiniProgram = {
name: 'navigateToSmartProgram',
args: {
appId: 'appKey',
envVersion: false
}
envVersion: false,
},
};
const navigateBackMiniProgram = {
name: 'navigateBackSmartProgram'
name: 'navigateBackSmartProgram',
};
const showShareMenu = {
name: 'openShare'
name: 'openShare',
};
const getAccountInfoSync = {
name: 'getEnvInfoSync',
returnValue(fromRes, toRes) {
toRes.miniProgram = {
appId: fromRes.appKey
appId: fromRes.appKey,
};
toRes.plugin = {
appId: '',
version: fromRes.sdkVersion
version: fromRes.sdkVersion,
};
}
},
};
var protocols = /*#__PURE__*/Object.freeze({
......
......@@ -50,7 +50,7 @@ const MP_METHODS = [
'createSelectorQuery',
'createIntersectionObserver',
'selectAllComponents',
'selectComponent'
'selectComponent',
];
function createEmitFn(oldEmit, ctx) {
return function emit(event, ...args) {
......@@ -77,7 +77,7 @@ function initBaseInstance(instance, options) {
{
instance.slots = {};
if (isArray(options.slots) && options.slots.length) {
options.slots.forEach(name => {
options.slots.forEach((name) => {
instance.slots[name] = true;
});
}
......@@ -88,7 +88,7 @@ function initBaseInstance(instance, options) {
function initComponentInstance(instance, options) {
initBaseInstance(instance, options);
const ctx = instance.ctx;
MP_METHODS.forEach(method => {
MP_METHODS.forEach((method) => {
ctx[method] = function (...args) {
const mpInstance = ctx.$scope;
if (mpInstance && mpInstance[method]) {
......@@ -106,7 +106,7 @@ function initComponentInstance(instance, options) {
}
function initMocks(instance, mpInstance, mocks) {
const ctx = instance.ctx;
mocks.forEach(mock => {
mocks.forEach((mock) => {
if (hasOwn(mpInstance, mock)) {
ctx[mock] = mpInstance[mock];
}
......@@ -125,12 +125,11 @@ const PAGE_HOOKS = [
'onReachBottom',
'onPullDownRefresh',
// 'onShareTimeline', // 右上角菜单,开发者手动注册
'onAddToFavorites'
// 'onShareAppMessage' // 右上角菜单,开发者手动注册
'onAddToFavorites',
];
function findHooks(vueOptions, hooks = new Set()) {
if (vueOptions) {
Object.keys(vueOptions).forEach(name => {
Object.keys(vueOptions).forEach((name) => {
if (name.indexOf('on') === 0 && isFunction(vueOptions[name])) {
hooks.add(name);
}
......@@ -138,7 +137,7 @@ function findHooks(vueOptions, hooks = new Set()) {
if (__VUE_OPTIONS_API__) {
const { extends: extendsOptions, mixins } = vueOptions;
if (mixins) {
mixins.forEach(mixin => findHooks(mixin, hooks));
mixins.forEach((mixin) => findHooks(mixin, hooks));
}
if (extendsOptions) {
findHooks(extendsOptions, hooks);
......@@ -156,10 +155,10 @@ function initHook(mpOptions, hook, excludes) {
}
const EXCLUDE_HOOKS = ['onReady'];
function initHooks(mpOptions, hooks, excludes = EXCLUDE_HOOKS) {
hooks.forEach(hook => initHook(mpOptions, hook, excludes));
hooks.forEach((hook) => initHook(mpOptions, hook, excludes));
}
function initUnknownHooks(mpOptions, vueOptions, excludes = EXCLUDE_HOOKS) {
findHooks(vueOptions).forEach(hook => initHook(mpOptions, hook, excludes));
findHooks(vueOptions).forEach((hook) => initHook(mpOptions, hook, excludes));
}
const HOOKS = [
......@@ -168,7 +167,7 @@ const HOOKS = [
'onError',
'onThemeChange',
'onPageNotFound',
'onUnhandledRejection'
'onUnhandledRejection',
];
function parseApp(instance, parseAppOptions) {
const internalInstance = instance.$;
......@@ -184,11 +183,11 @@ function parseApp(instance, parseAppOptions) {
initBaseInstance(internalInstance, {
mpType: 'app',
mpInstance: this,
slots: []
slots: [],
});
ctx.globalData = this.globalData;
instance.$callHook('onLaunch', options);
}
},
};
const vueOptions = instance.$.type;
initHooks(appOptions, HOOKS);
......@@ -212,7 +211,7 @@ const encode = encodeURIComponent;
function stringifyQuery(obj, encodeStr = encode) {
const res = obj
? Object.keys(obj)
.map(key => {
.map((key) => {
let val = obj[key];
if (typeof val === undefined || val === null) {
val = '';
......@@ -222,7 +221,7 @@ function stringifyQuery(obj, encodeStr = encode) {
}
return encodeStr(key) + '=' + encodeStr(val);
})
.filter(x => x.length > 0)
.filter((x) => x.length > 0)
.join('&')
: null;
return res ? `?${res}` : '';
......@@ -247,7 +246,7 @@ function initVueIds(vueIds, mpInstance) {
}
const EXTRAS = ['externalClasses'];
function initExtraOptions(miniProgramComponentOptions, vueOptions) {
EXTRAS.forEach(name => {
EXTRAS.forEach((name) => {
if (hasOwn(vueOptions, name)) {
miniProgramComponentOptions[name] = vueOptions[name];
}
......@@ -268,12 +267,12 @@ function initRefs(instance, mpInstance) {
get() {
const $refs = {};
const components = mpInstance.selectAllComponents('.vue-ref');
components.forEach(component => {
components.forEach((component) => {
const ref = component.dataset.ref;
$refs[ref] = component.$vm || component;
});
const forComponents = mpInstance.selectAllComponents('.vue-ref-in-for');
forComponents.forEach(component => {
forComponents.forEach((component) => {
const ref = component.dataset.ref;
if (!$refs[ref]) {
$refs[ref] = [];
......@@ -281,7 +280,7 @@ function initRefs(instance, mpInstance) {
$refs[ref].push(component.$vm || component);
});
return $refs;
}
},
});
}
function findVmByVueId(instance, vuePid) {
......@@ -335,7 +334,7 @@ function initDefaultProps(isBehavior = false) {
if (!isBehavior) {
properties.vueId = {
type: String,
value: ''
value: '',
};
// 小程序不能直接定义 $slots 的 props,所以通过 vueSlots 转换到 $slots
properties.vueSlots = {
......@@ -347,9 +346,9 @@ function initDefaultProps(isBehavior = false) {
$slots[slotName] = true;
});
this.setData({
$slots
$slots,
});
}
},
};
}
return properties;
......@@ -361,14 +360,14 @@ function createProperty(key, prop) {
function initProps(mpComponentOptions, rawProps, isBehavior = false) {
const properties = initDefaultProps(isBehavior);
if (isArray(rawProps)) {
rawProps.forEach(key => {
rawProps.forEach((key) => {
properties[key] = createProperty(key, {
type: null
type: null,
});
});
}
else if (isPlainObject(rawProps)) {
Object.keys(rawProps).forEach(key => {
Object.keys(rawProps).forEach((key) => {
const opts = rawProps[key];
if (isPlainObject(opts)) {
// title:{type:String,default:''}
......@@ -380,14 +379,14 @@ function initProps(mpComponentOptions, rawProps, isBehavior = false) {
opts.type = parsePropType(key, type, value);
properties[key] = createProperty(key, {
type: PROP_TYPES.indexOf(type) !== -1 ? type : null,
value
value,
});
}
else {
// content:String
const type = parsePropType(key, opts, null);
properties[key] = createProperty(key, {
type: PROP_TYPES.indexOf(type) !== -1 ? type : null
type: PROP_TYPES.indexOf(type) !== -1 ? type : null,
});
}
});
......@@ -431,7 +430,7 @@ function initBehaviors(vueOptions, initBehavior) {
}
const behaviors = [];
if (isArray(vueBehaviors)) {
vueBehaviors.forEach(behavior => {
vueBehaviors.forEach((behavior) => {
behaviors.push(behavior.replace('uni://', `${__PLATFORM_PREFIX__}://`));
if (behavior === 'uni://form-field') {
if (isArray(vueProps)) {
......@@ -441,11 +440,11 @@ function initBehaviors(vueOptions, initBehavior) {
else {
vueProps.name = {
type: String,
default: ''
default: '',
};
vueProps.value = {
type: [String, Number, Boolean, Array, Object, Date],
default: ''
default: '',
};
}
}
......@@ -457,7 +456,7 @@ function initBehaviors(vueOptions, initBehavior) {
behaviors.push(initBehavior(behavior));
}
if (isArray(vueMixins)) {
vueMixins.forEach(vueMixin => {
vueMixins.forEach((vueMixin) => {
if (vueMixin.props) {
const behavior = {};
initProps(behavior, vueMixin.props, true);
......@@ -486,7 +485,7 @@ function getValue(obj, path) {
}
function getExtraValue(instance, dataPathsArray) {
let context = instance;
dataPathsArray.forEach(dataPathArray => {
dataPathsArray.forEach((dataPathArray) => {
const dataPath = dataPathArray[0];
const value = dataPathArray[2];
if (dataPath || typeof value !== 'undefined') {
......@@ -516,12 +515,12 @@ function getExtraValue(instance, dataPathsArray) {
}
else {
if (isArray(vFor)) {
context = vFor.find(vForItem => {
context = vFor.find((vForItem) => {
return getValue(vForItem, propPath) === value;
});
}
else if (isPlainObject(vFor)) {
context = Object.keys(vFor).find(vForKey => {
context = Object.keys(vFor).find((vForKey) => {
return getValue(vFor[vForKey], propPath) === value;
});
}
......@@ -611,7 +610,7 @@ function processEventArgs(instance, event, args = [], extra = [], isCustom, meth
}
const extraObj = processEventExtra(instance, extra, event);
const ret = [];
args.forEach(arg => {
args.forEach((arg) => {
if (arg === '$event') {
if (methodName === '__set_model' && !isCustom) {
// input v-model value
......@@ -731,11 +730,11 @@ function handleEvent(event) {
}
}
function parseComponent(vueOptions, { parse, mocks, isPage, initRelation, handleLink, initLifetimes }) {
function parseComponent(vueOptions, { parse, mocks, isPage, initRelation, handleLink, initLifetimes, }) {
vueOptions = vueOptions.default || vueOptions;
const options = {
multipleSlots: true,
addGlobalClass: true
addGlobalClass: true,
};
if (vueOptions.options) {
extend(options, vueOptions.options);
......@@ -752,12 +751,12 @@ function parseComponent(vueOptions, { parse, mocks, isPage, initRelation, handle
},
resize(size) {
this.$vm && this.$vm.$callHook('onPageResize', size);
}
},
},
methods: {
__l: handleLink,
__e: handleEvent
}
__e: handleEvent,
},
};
if (__VUE_OPTIONS_API__) {
applyOptions(mpComponentOptions, vueOptions, initBehavior);
......@@ -791,19 +790,19 @@ function $destroyComponent(instance) {
}
function parsePage(vueOptions, parseOptions) {
const { parse, mocks, isPage, initRelation, handleLink, initLifetimes } = parseOptions;
const { parse, mocks, isPage, initRelation, handleLink, initLifetimes, } = parseOptions;
const miniProgramPageOptions = parseComponent(vueOptions, {
mocks,
isPage,
initRelation,
handleLink,
initLifetimes
initLifetimes,
});
const methods = miniProgramPageOptions.methods;
methods.onLoad = function (query) {
this.options = query;
this.$page = {
fullPath: '/' + this.route + stringifyQuery(query)
fullPath: '/' + this.route + stringifyQuery(query),
};
return this.$vm && this.$vm.$callHook('onLoad', query);
};
......@@ -868,13 +867,13 @@ var parseAppOptions = /*#__PURE__*/Object.freeze({
parse: parse
});
function initLifetimes({ mocks, isPage, initRelation, vueOptions }) {
function initLifetimes({ mocks, isPage, initRelation, vueOptions, }) {
return {
attached() {
const properties = this.properties;
initVueIds(properties.vueId, this);
const relationOptions = {
vuePid: this._$vuePid
vuePid: this._$vuePid,
};
// 处理父子关系
initRelation(this, relationOptions);
......@@ -882,7 +881,7 @@ function initLifetimes({ mocks, isPage, initRelation, vueOptions }) {
const mpInstance = this;
this.$vm = $createComponent({
type: vueOptions,
props: properties
props: properties,
}, {
mpType: isPage(mpInstance) ? 'page' : 'component',
mpInstance,
......@@ -892,7 +891,7 @@ function initLifetimes({ mocks, isPage, initRelation, vueOptions }) {
initRefs(instance, mpInstance);
initMocks(instance, mpInstance, mocks);
initComponentInstance(instance, options);
}
},
});
},
ready() {
......@@ -905,7 +904,7 @@ function initLifetimes({ mocks, isPage, initRelation, vueOptions }) {
},
detached() {
this.$vm && $destroyComponent(this.$vm);
}
},
};
}
......@@ -964,7 +963,7 @@ function parse$1(componentOptions) {
delete lifetimes.ready;
}
componentOptions.messages = {
__l: methods.__l
__l: methods.__l,
};
delete methods.__l;
}
......
......@@ -2,7 +2,7 @@ export {
redirectTo,
previewImage,
getSystemInfo,
getSystemInfoSync
getSystemInfoSync,
} from '@dcloudio/uni-mp-core'
function createTodoMethod(contextName: string, methodName: string) {
......@@ -23,17 +23,17 @@ export const request = {
dataType(type: string) {
return {
name: 'dataType',
value: type === 'json' ? type : 'string'
value: type === 'json' ? type : 'string',
}
}
},
}
}
},
}
export const connectSocket = {
args: {
method: false
}
method: false,
},
}
export const getRecorderManager = {
......@@ -42,48 +42,48 @@ export const getRecorderManager = {
'RecorderManager',
'onFrameRecorded'
)
}
},
}
export const getBackgroundAudioManager = {
returnValue(fromRes: Data, toRes: UniApp.BackgroundAudioManager) {
toRes.onPrev = createTodoMethod('BackgroundAudioManager', 'onPrev')
toRes.onNext = createTodoMethod('BackgroundAudioManager', 'onNext')
}
},
}
export const scanCode = {
args: {
onlyFromCamera: false,
scanType: false
}
scanType: false,
},
}
export const navigateToMiniProgram = {
name: 'navigateToSmartProgram',
args: {
appId: 'appKey',
envVersion: false
}
envVersion: false,
},
}
export const navigateBackMiniProgram = {
name: 'navigateBackSmartProgram'
name: 'navigateBackSmartProgram',
}
export const showShareMenu = {
name: 'openShare'
name: 'openShare',
}
export const getAccountInfoSync = {
name: 'getEnvInfoSync',
returnValue(fromRes: Data, toRes: UniApp.AccountInfo) {
toRes.miniProgram = {
appId: fromRes.appKey
appId: fromRes.appKey,
} as UniApp.MiniProgram
toRes.plugin = {
appId: '',
version: fromRes.sdkVersion
version: fromRes.sdkVersion,
}
}
},
}
......@@ -4,7 +4,7 @@ export const getProvider = initGetProvider({
oauth: ['baidu'],
share: ['baidu'],
payment: ['baidu'],
push: ['baidu']
push: ['baidu'],
})
export function requestPayment(params: UniApp.RequestPaymentOptions) {
......@@ -20,7 +20,7 @@ export function requestPayment(params: UniApp.RequestPaymentOptions) {
params.fail &&
params.fail({
errMsg:
'requestPayment:fail: 参数 orderInfo 数据结构不正确,参考:https://uniapp.dcloud.io/api/plugins/payment?id=orderinfo'
'requestPayment:fail: 参数 orderInfo 数据结构不正确,参考:https://uniapp.dcloud.io/api/plugins/payment?id=orderinfo',
})
} else {
swan.requestPolymerPayment(params)
......
import {
initCreateApp,
initCreatePage,
initCreateComponent
initCreateComponent,
} from '@dcloudio/uni-mp-core'
import '@dcloudio/uni-mp-polyfill'
......
import {
MiniProgramAppOptions,
MiniProgramAppInstance
MiniProgramAppInstance,
} from '@dcloudio/uni-mp-core'
export function parse(appOptions: MiniProgramAppOptions) {
......
......@@ -52,7 +52,7 @@ export function parse(componentOptions: MPComponentOptions) {
delete lifetimes.ready
}
;(componentOptions as any).messages = {
__l: methods.__l
__l: methods.__l,
}
delete methods.__l
}
......@@ -3,23 +3,23 @@ import { initHooks, initUnknownHooks } from '../src/runtime/componentHooks'
const vueBasicOptions = defineComponent({
onLoad() {},
beforeCreate() {}
beforeCreate() {},
})
const vueExtendsOptions = defineComponent({
extends: vueBasicOptions,
onShow() {}
onShow() {},
})
const vueMixinsOptions = defineComponent({
mixins: [vueExtendsOptions],
onHide() {}
onHide() {},
})
const vueExtendsANdMixinsOptions = defineComponent({
extends: vueBasicOptions,
mixins: [vueMixinsOptions],
onReady() {}
onReady() {},
})
describe('hooks', () => {
......
......@@ -4,7 +4,7 @@ import {
upx2px,
addInterceptor,
removeInterceptor,
promisify
promisify,
} from '@dcloudio/uni-api'
import { initWrapper } from './wrapper'
......@@ -28,7 +28,7 @@ export function initUni(api: Record<string, any>, protocols: MPProtocols) {
// event-api
// provider-api?
return promisify(key, wrapper(key, __GLOBAL__[key]))
}
},
}
return new Proxy({}, UniProxyHandlers)
}
......@@ -66,18 +66,17 @@ export const previewImage: MPProtocol = {
}
if (currentIndex > 0) {
toArgs.current = urls[currentIndex]
toArgs.urls = urls.filter(
(item, index) =>
index < currentIndex ? item !== urls[currentIndex] : true
toArgs.urls = urls.filter((item, index) =>
index < currentIndex ? item !== urls[currentIndex] : true
)
} else {
toArgs.current = urls[0]
}
return {
indicator: false,
loop: false
loop: false,
}
}
},
}
export function addSafeAreaInsets(
......@@ -90,13 +89,13 @@ export function addSafeAreaInsets(
top: safeArea.top,
left: safeArea.left,
right: fromRes.windowWidth - safeArea.right,
bottom: fromRes.windowHeight - safeArea.bottom
bottom: fromRes.windowHeight - safeArea.bottom,
}
}
}
export const getSystemInfo = {
returnValue: addSafeAreaInsets
returnValue: addSafeAreaInsets,
}
export const getSystemInfoSync = getSystemInfo
......
......@@ -12,19 +12,19 @@ export function initGetProvider(providers: PROVIDERS) {
service,
success,
fail,
complete
complete,
}: UniApp.GetProviderOptions) {
let res
if (providers[service]) {
res = {
errMsg: 'getProvider:ok',
service,
provider: providers[service]
provider: providers[service],
} as UniApp.GetProviderRes
isFunction(success) && success(res)
} else {
res = {
errMsg: 'getProvider:fail:服务[' + service + ']不存在'
errMsg: 'getProvider:fail:服务[' + service + ']不存在',
}
isFunction(fail) && fail(res)
}
......
......@@ -6,7 +6,7 @@ import {
MPProtocols,
MPProtocolArgsValue,
MPProtocolArgs,
MPProtocolObject
MPProtocolObject,
} from './protocols'
const CALLBACKS = ['success', 'fail', 'cancel', 'complete']
......@@ -17,7 +17,7 @@ export function initWrapper(protocols: MPProtocols) {
method: Function,
returnValue: unknown
) {
return function(res: Record<string, any>) {
return function (res: Record<string, any>) {
return method(processReturnValue(methodName, res, returnValue))
}
}
......@@ -99,11 +99,11 @@ export function initWrapper(protocols: MPProtocols) {
const protocol = protocols[methodName] as MPProtocolObject
if (!protocol) {
// 暂不支持的 api
return function() {
return function () {
console.error(`__PLATFORM_TITLE__ 暂不支持${methodName}`)
}
}
return function(arg1: unknown, arg2: unknown) {
return function (arg1: unknown, arg2: unknown) {
// 目前 api 最多两个参数
let options = protocol
if (isFunction(protocol)) {
......
......@@ -20,7 +20,7 @@ export { initProps } from './runtime/componentProps'
export {
PAGE_HOOKS,
initHooks,
initUnknownHooks
initUnknownHooks,
} from './runtime/componentHooks'
export { initMocks, initComponentInstance } from './runtime/componentInstance'
export { handleEvent } from './runtime/componentEvents'
......@@ -29,7 +29,7 @@ export {
initVueIds,
initRefs,
initWxsCallMethods,
findVmByVueId
findVmByVueId,
} from './runtime/util'
// protocols
......@@ -38,7 +38,7 @@ export {
previewImage,
getSystemInfo,
getSystemInfoSync,
addSafeAreaInsets
addSafeAreaInsets,
} from './api/protocols'
// types
export { MiniProgramAppOptions, MiniProgramAppInstance } from './runtime/app'
......@@ -46,7 +46,7 @@ export {
RelationOptions,
MPComponentOptions,
MPComponentInstance,
CreateLifetimesOptions
CreateLifetimesOptions,
} from './runtime/component'
export { MPProtocols } from './api/protocols'
// mp-alipay
......
......@@ -19,7 +19,7 @@ const HOOKS = [
'onError',
'onThemeChange',
'onPageNotFound',
'onUnhandledRejection'
'onUnhandledRejection',
]
export interface ParseAppOptions {
......@@ -44,12 +44,12 @@ function parseApp(
initBaseInstance(internalInstance, {
mpType: 'app',
mpInstance: this,
slots: []
slots: [],
})
ctx.globalData = this.globalData
instance.$callHook('onLaunch', options)
}
},
}
const vueOptions = instance.$.type as ComponentOptions
......
......@@ -31,7 +31,7 @@ export type MPComponentInstance = Component.Instance<
CustomComponentInstanceProperty
>
export interface RelationOptions {
export interface RelationOptions extends Record<string, unknown> {
vuePid: string | undefined
parent?: ComponentPublicInstance
}
......@@ -74,14 +74,14 @@ export function parseComponent(
isPage,
initRelation,
handleLink,
initLifetimes
initLifetimes,
}: ParseComponentOptions
) {
vueOptions = vueOptions.default || vueOptions
const options: Component.ComponentOptions = {
multipleSlots: true,
addGlobalClass: true
addGlobalClass: true,
}
if (vueOptions.options) {
......@@ -100,12 +100,12 @@ export function parseComponent(
},
resize(size) {
this.$vm && this.$vm.$callHook('onPageResize', size)
}
},
},
methods: {
__l: handleLink,
__e: handleEvent
}
__e: handleEvent,
},
}
if (__VUE_OPTIONS_API__) {
......
......@@ -2,7 +2,7 @@ import { hasOwn, NOOP, isArray, isPlainObject, isFunction } from '@vue/shared'
import { ComponentPublicInstance } from 'vue'
import { MPComponentInstance } from './component'
interface Event extends WechatMiniprogram.Event {
interface Event extends WechatMiniprogram.BaseEvent {
detail: Record<string, any>
stopPropagation: () => void
preventDefault: () => void
......@@ -26,7 +26,7 @@ function getExtraValue(
dataPathsArray: string[]
) {
let context: unknown = instance
dataPathsArray.forEach(dataPathArray => {
dataPathsArray.forEach((dataPathArray) => {
const dataPath = dataPathArray[0]
const value = dataPathArray[2]
if (dataPath || typeof value !== 'undefined') {
......@@ -53,11 +53,11 @@ function getExtraValue(
context = vFor[value]
} else {
if (isArray(vFor)) {
context = vFor.find(vForItem => {
context = vFor.find((vForItem) => {
return getValue(vForItem, propPath) === value
})
} else if (isPlainObject(vFor)) {
context = Object.keys(vFor).find(vForKey => {
context = Object.keys(vFor).find((vForKey) => {
return getValue(vFor[vForKey], propPath) === value
})
} else {
......@@ -162,7 +162,7 @@ function processEventArgs(
const extraObj = processEventExtra(instance, extra, event)
const ret: any[] = []
args.forEach(arg => {
args.forEach((arg) => {
if (arg === '$event') {
if (methodName === '__set_model' && !isCustom) {
// input v-model value
......
......@@ -20,7 +20,7 @@ export const PAGE_HOOKS = [
'onPullDownRefresh',
// 'onShareTimeline', // 右上角菜单,开发者手动注册
'onAddToFavorites'
'onAddToFavorites',
// 'onShareAppMessage' // 右上角菜单,开发者手动注册
]
......@@ -29,7 +29,7 @@ function findHooks(
hooks = new Set<string>()
): Set<string> {
if (vueOptions) {
Object.keys(vueOptions).forEach(name => {
Object.keys(vueOptions).forEach((name) => {
if (name.indexOf('on') === 0 && isFunction(vueOptions[name])) {
hooks.add(name)
}
......@@ -37,7 +37,7 @@ function findHooks(
if (__VUE_OPTIONS_API__) {
const { extends: extendsOptions, mixins } = vueOptions
if (mixins) {
mixins.forEach(mixin => findHooks(mixin, hooks))
mixins.forEach((mixin) => findHooks(mixin, hooks))
}
if (extendsOptions) {
findHooks(extendsOptions, hooks)
......@@ -53,7 +53,7 @@ function initHook(
excludes: string[]
) {
if (excludes.indexOf(hook) === -1 && !hasOwn(mpOptions, hook)) {
mpOptions[hook] = function(
mpOptions[hook] = function (
this: CustomAppInstanceProperty | CustomComponentInstanceProperty,
args: unknown
) {
......@@ -72,7 +72,7 @@ export function initHooks(
hooks: string[],
excludes: string[] = EXCLUDE_HOOKS
) {
hooks.forEach(hook => initHook(mpOptions, hook, excludes))
hooks.forEach((hook) => initHook(mpOptions, hook, excludes))
}
export function initUnknownHooks(
......@@ -80,5 +80,5 @@ export function initUnknownHooks(
vueOptions: ComponentOptions,
excludes: string[] = EXCLUDE_HOOKS
) {
findHooks(vueOptions).forEach(hook => initHook(mpOptions, hook, excludes))
findHooks(vueOptions).forEach((hook) => initHook(mpOptions, hook, excludes))
}
......@@ -4,7 +4,7 @@ import {
isArray,
toNumber,
isObject,
isPlainObject
isPlainObject,
} from '@vue/shared'
import { ComponentPublicInstance, ComponentInternalInstance } from 'vue'
......@@ -74,7 +74,7 @@ const MP_METHODS = [
'createSelectorQuery',
'createIntersectionObserver',
'selectAllComponents',
'selectComponent'
'selectComponent',
]
function createEmitFn(oldEmit: Function, ctx: Record<string, any>) {
......@@ -130,12 +130,12 @@ export function initBaseInstance(
Object.defineProperty(instance, 'slots', {
get() {
return this.$scope && this.$scope.props.$slots
}
},
})
} else {
instance.slots = {}
if (isArray(options.slots) && options.slots.length) {
options.slots.forEach(name => {
options.slots.forEach((name) => {
instance.slots[name] = true as any
})
}
......@@ -152,8 +152,8 @@ export function initComponentInstance(
initBaseInstance(instance, options)
const ctx = (instance as any).ctx
MP_METHODS.forEach(method => {
ctx[method] = function(...args: any[]) {
MP_METHODS.forEach((method) => {
ctx[method] = function (...args: any[]) {
const mpInstance = ctx.$scope as MPComponentInstance
if (mpInstance && mpInstance[method]) {
return (mpInstance[method] as Function).apply(mpInstance, args)
......@@ -179,7 +179,7 @@ export function initMocks(
mocks: string[]
) {
const ctx = (instance as any).ctx
mocks.forEach(mock => {
mocks.forEach((mock) => {
if (hasOwn(mpInstance, mock)) {
ctx[mock] = mpInstance[mock]
}
......
......@@ -52,7 +52,7 @@ export function initBehaviors(
const behaviors: string[] = []
if (isArray(vueBehaviors)) {
vueBehaviors.forEach(behavior => {
vueBehaviors.forEach((behavior) => {
behaviors.push(behavior.replace('uni://', `${__PLATFORM_PREFIX__}://`))
if (behavior === 'uni://form-field') {
if (isArray(vueProps)) {
......@@ -61,11 +61,11 @@ export function initBehaviors(
} else {
vueProps.name = {
type: String,
default: ''
default: '',
}
vueProps.value = {
type: [String, Number, Boolean, Array, Object, Date],
default: ''
default: '',
}
}
}
......@@ -77,7 +77,7 @@ export function initBehaviors(
behaviors.push(initBehavior(behavior) as string)
}
if (isArray(vueMixins)) {
vueMixins.forEach(vueMixin => {
vueMixins.forEach((vueMixin) => {
if (vueMixin.props) {
const behavior = {}
initProps(behavior, vueMixin.props, true)
......
......@@ -39,27 +39,27 @@ function initDefaultProps(isBehavior: boolean = false) {
if (!isBehavior) {
properties.vueId = {
type: String,
value: ''
value: '',
}
if (__PLATFORM__ === 'mp-toutiao') {
// 用于字节跳动小程序模拟抽象节点
properties.generic = {
type: Object
type: Object,
}
}
// 小程序不能直接定义 $slots 的 props,所以通过 vueSlots 转换到 $slots
properties.vueSlots = {
type: null,
value: [],
observer: function(this: MPComponentInstance, newVal) {
observer: function (this: MPComponentInstance, newVal) {
const $slots = Object.create(null)
newVal.forEach((slotName: string) => {
$slots[slotName] = true
})
this.setData({
$slots
$slots,
})
}
},
}
}
return properties
......@@ -81,13 +81,13 @@ export function initProps(
const properties = initDefaultProps(isBehavior)
if (isArray(rawProps)) {
rawProps.forEach(key => {
rawProps.forEach((key) => {
properties[key] = createProperty(key, {
type: null
type: null,
})
})
} else if (isPlainObject(rawProps)) {
Object.keys(rawProps).forEach(key => {
Object.keys(rawProps).forEach((key) => {
const opts = rawProps[key]
if (isPlainObject(opts)) {
// title:{type:String,default:''}
......@@ -99,13 +99,13 @@ export function initProps(
;(opts as any).type = parsePropType(key, type, value)
properties[key] = createProperty(key, {
type: PROP_TYPES.indexOf(type) !== -1 ? type : null,
value
value,
})
} else {
// content:String
const type = parsePropType(key, opts, null)
properties[key] = createProperty(key, {
type: PROP_TYPES.indexOf(type) !== -1 ? type : null
type: PROP_TYPES.indexOf(type) !== -1 ? type : null,
})
}
})
......
......@@ -5,7 +5,7 @@ import { stringifyQuery } from '@dcloudio/uni-shared'
import {
ParseComponentOptions,
parseComponent,
CustomComponentInstanceProperty
CustomComponentInstanceProperty,
} from './component'
import { PAGE_HOOKS, initHooks, initUnknownHooks } from './componentHooks'
......@@ -19,22 +19,22 @@ function parsePage(
isPage,
initRelation,
handleLink,
initLifetimes
initLifetimes,
} = parseOptions
const miniProgramPageOptions = parseComponent(vueOptions, {
mocks,
isPage,
initRelation,
handleLink,
initLifetimes
initLifetimes,
})
const methods = miniProgramPageOptions.methods as WechatMiniprogram.Component.MethodOption
methods.onLoad = function(this: CustomComponentInstanceProperty, query) {
methods.onLoad = function (this: CustomComponentInstanceProperty, query) {
;(this as any).options = query
;(this as any).$page = {
fullPath: '/' + (this as any).route + stringifyQuery(query)
fullPath: '/' + (this as any).route + stringifyQuery(query),
}
return this.$vm && this.$vm.$callHook('onLoad', query)
}
......
......@@ -12,7 +12,7 @@ function customize(str: string) {
function initTriggerEvent(mpInstance: MPComponentInstance) {
const oldTriggerEvent = mpInstance.triggerEvent
mpInstance.triggerEvent = function(event, ...args) {
mpInstance.triggerEvent = function (event, ...args) {
return oldTriggerEvent.apply(mpInstance, [customize(event), ...args])
}
}
......@@ -20,23 +20,23 @@ function initTriggerEvent(mpInstance: MPComponentInstance) {
function initHook(name: 'onLoad' | 'created', options: Record<string, any>) {
const oldHook = options[name]
if (!oldHook) {
options[name] = function(this: MPComponentInstance) {
options[name] = function (this: MPComponentInstance) {
initTriggerEvent(this)
}
} else {
options[name] = function(this: MPComponentInstance, ...args: any[]) {
options[name] = function (this: MPComponentInstance, ...args: any[]) {
initTriggerEvent(this)
return oldHook.apply(this, args)
}
}
}
Page = function(options) {
Page = function (options) {
initHook('onLoad', options)
return MPPage(options)
}
Component = function(options) {
Component = function (options) {
initHook('created', options)
return MPComponent(options)
}
......@@ -2,7 +2,7 @@ import { hasOwn, isArray } from '@vue/shared'
import {
ComponentOptions,
ComponentInternalInstance,
ComponentPublicInstance
ComponentPublicInstance,
} from 'vue'
import { MPComponentInstance, MPComponentOptions } from './component'
......@@ -35,7 +35,7 @@ export function initExtraOptions(
miniProgramComponentOptions: MPComponentOptions,
vueOptions: ComponentOptions
) {
EXTRAS.forEach(name => {
EXTRAS.forEach((name) => {
if (hasOwn(vueOptions, name)) {
;(miniProgramComponentOptions as any)[name] = vueOptions[name]
}
......@@ -50,7 +50,7 @@ export function initWxsCallMethods(
return
}
wxsCallMethods.forEach((callMethod: string) => {
methods[callMethod] = function(this: MPComponentInstance, args: unknown) {
methods[callMethod] = function (this: MPComponentInstance, args: unknown) {
return (this.$vm as any)[callMethod](args)
}
})
......@@ -64,12 +64,12 @@ export function initRefs(
get() {
const $refs: Record<string, any> = {}
const components = mpInstance.selectAllComponents('.vue-ref')
components.forEach(component => {
components.forEach((component) => {
const ref = component.dataset.ref
$refs[ref] = component.$vm || component
})
const forComponents = mpInstance.selectAllComponents('.vue-ref-in-for')
forComponents.forEach(component => {
forComponents.forEach((component) => {
const ref = component.dataset.ref
if (!$refs[ref]) {
$refs[ref] = []
......@@ -77,7 +77,7 @@ export function initRefs(
$refs[ref].push(component.$vm || component)
})
return $refs
}
},
})
}
......
......@@ -23,8 +23,8 @@ const Upx2pxProtocol = [
{
name: 'upx',
type: [Number, String],
required: true
}
required: true,
},
];
const EPS = 1e-4;
......@@ -92,7 +92,7 @@ function queue(hooks, data) {
if (res === false) {
return {
then() { },
catch() { }
catch() { },
};
}
}
......@@ -101,11 +101,11 @@ function queue(hooks, data) {
then(callback) {
return callback(data);
},
catch() { }
catch() { },
});
}
function wrapperOptions(interceptors, options = {}) {
[HOOKS.SUCCESS, HOOKS.FAIL, HOOKS.COMPLETE].forEach(name => {
[HOOKS.SUCCESS, HOOKS.FAIL, HOOKS.COMPLETE].forEach((name) => {
const hooks = interceptors[name];
if (!isArray(hooks)) {
return;
......@@ -128,21 +128,21 @@ function wrapperReturnValue(method, returnValue) {
if (interceptor && isArray(interceptor.returnValue)) {
returnValueHooks.push(...interceptor.returnValue);
}
returnValueHooks.forEach(hook => {
returnValueHooks.forEach((hook) => {
returnValue = hook(returnValue) || returnValue;
});
return returnValue;
}
function getApiInterceptorHooks(method) {
const interceptor = Object.create(null);
Object.keys(globalInterceptors).forEach(hook => {
Object.keys(globalInterceptors).forEach((hook) => {
if (hook !== 'returnValue') {
interceptor[hook] = globalInterceptors[hook].slice();
}
});
const scopedInterceptor = scopedInterceptors[method];
if (scopedInterceptor) {
Object.keys(scopedInterceptor).forEach(hook => {
Object.keys(scopedInterceptor).forEach((hook) => {
if (hook !== 'returnValue') {
interceptor[hook] = (interceptor[hook] || []).concat(scopedInterceptor[hook]);
}
......@@ -155,7 +155,7 @@ function invokeApi(method, api, options, ...params) {
if (interceptor && Object.keys(interceptor).length) {
if (isArray(interceptor.invoke)) {
const res = queue(interceptor.invoke, options);
return res.then(options => {
return res.then((options) => {
return api(wrapperOptions(interceptor, options), ...params);
});
}
......@@ -170,13 +170,13 @@ const AddInterceptorProtocol = [
{
name: 'method',
type: [String, Object],
required: true
}
required: true,
},
];
const RemoveInterceptorProtocol = AddInterceptorProtocol;
function mergeInterceptorHook(interceptors, interceptor) {
Object.keys(interceptor).forEach(hook => {
Object.keys(interceptor).forEach((hook) => {
if (isFunction(interceptor[hook])) {
interceptors[hook] = mergeHook(interceptors[hook], interceptor[hook]);
}
......@@ -186,7 +186,7 @@ function removeInterceptorHook(interceptors, interceptor) {
if (!interceptors || !interceptor) {
return;
}
Object.keys(interceptor).forEach(hook => {
Object.keys(interceptor).forEach((hook) => {
if (isFunction(interceptor[hook])) {
removeHook(interceptors[hook], interceptor[hook]);
}
......@@ -263,10 +263,10 @@ function handlePromise(promise) {
return promise;
}
return promise
.then(data => {
.then((data) => {
return [null, data];
})
.catch(err => [err]);
.catch((err) => [err]);
}
function shouldPromise(name) {
if (isContextApi(name) || isSyncApi(name) || isCallbackApi(name)) {
......@@ -278,7 +278,7 @@ function shouldPromise(name) {
if (!Promise.prototype.finally) {
Promise.prototype.finally = function (onfinally) {
const promise = this.constructor;
return this.then(value => promise.resolve(onfinally && onfinally()).then(() => value), reason => promise.resolve(onfinally && onfinally()).then(() => {
return this.then((value) => promise.resolve(onfinally && onfinally()).then(() => value), (reason) => promise.resolve(onfinally && onfinally()).then(() => {
throw reason;
}));
};
......@@ -299,7 +299,7 @@ function promisify(name, api) {
return wrapperReturnValue(name, handlePromise(new Promise((resolve, reject) => {
invokeApi(name, api, Object.assign({}, options, {
success: resolve,
fail: reject
fail: reject,
}), ...params);
})));
};
......@@ -413,25 +413,25 @@ function initUni(api, protocols) {
// event-api
// provider-api?
return promisify(key, wrapper(key, qq[key]));
}
},
};
return new Proxy({}, UniProxyHandlers);
}
function initGetProvider(providers) {
return function getProvider({ service, success, fail, complete }) {
return function getProvider({ service, success, fail, complete, }) {
let res;
if (providers[service]) {
res = {
errMsg: 'getProvider:ok',
service,
provider: providers[service]
provider: providers[service],
};
isFunction(success) && success(res);
}
else {
res = {
errMsg: 'getProvider:fail:服务[' + service + ']不存在'
errMsg: 'getProvider:fail:服务[' + service + ']不存在',
};
isFunction(fail) && fail(res);
}
......@@ -468,9 +468,9 @@ const previewImage = {
}
return {
indicator: false,
loop: false
loop: false,
};
}
},
};
function addSafeAreaInsets(fromRes, toRes) {
if (fromRes.safeArea) {
......@@ -479,12 +479,12 @@ function addSafeAreaInsets(fromRes, toRes) {
top: safeArea.top,
left: safeArea.left,
right: fromRes.windowWidth - safeArea.right,
bottom: fromRes.windowHeight - safeArea.bottom
bottom: fromRes.windowHeight - safeArea.bottom,
};
}
}
const getSystemInfo = {
returnValue: addSafeAreaInsets
returnValue: addSafeAreaInsets,
};
const getSystemInfoSync = getSystemInfo;
const redirectTo = {};
......@@ -493,7 +493,7 @@ const getProvider = initGetProvider({
oauth: ['qq'],
share: ['qq'],
payment: ['qqpay'],
push: ['qq']
push: ['qq'],
});
var shims = /*#__PURE__*/Object.freeze({
......
......@@ -50,7 +50,7 @@ const MP_METHODS = [
'createSelectorQuery',
'createIntersectionObserver',
'selectAllComponents',
'selectComponent'
'selectComponent',
];
function createEmitFn(oldEmit, ctx) {
return function emit(event, ...args) {
......@@ -77,7 +77,7 @@ function initBaseInstance(instance, options) {
{
instance.slots = {};
if (isArray(options.slots) && options.slots.length) {
options.slots.forEach(name => {
options.slots.forEach((name) => {
instance.slots[name] = true;
});
}
......@@ -88,7 +88,7 @@ function initBaseInstance(instance, options) {
function initComponentInstance(instance, options) {
initBaseInstance(instance, options);
const ctx = instance.ctx;
MP_METHODS.forEach(method => {
MP_METHODS.forEach((method) => {
ctx[method] = function (...args) {
const mpInstance = ctx.$scope;
if (mpInstance && mpInstance[method]) {
......@@ -106,7 +106,7 @@ function initComponentInstance(instance, options) {
}
function initMocks(instance, mpInstance, mocks) {
const ctx = instance.ctx;
mocks.forEach(mock => {
mocks.forEach((mock) => {
if (hasOwn(mpInstance, mock)) {
ctx[mock] = mpInstance[mock];
}
......@@ -125,12 +125,11 @@ const PAGE_HOOKS = [
'onReachBottom',
'onPullDownRefresh',
// 'onShareTimeline', // 右上角菜单,开发者手动注册
'onAddToFavorites'
// 'onShareAppMessage' // 右上角菜单,开发者手动注册
'onAddToFavorites',
];
function findHooks(vueOptions, hooks = new Set()) {
if (vueOptions) {
Object.keys(vueOptions).forEach(name => {
Object.keys(vueOptions).forEach((name) => {
if (name.indexOf('on') === 0 && isFunction(vueOptions[name])) {
hooks.add(name);
}
......@@ -138,7 +137,7 @@ function findHooks(vueOptions, hooks = new Set()) {
if (__VUE_OPTIONS_API__) {
const { extends: extendsOptions, mixins } = vueOptions;
if (mixins) {
mixins.forEach(mixin => findHooks(mixin, hooks));
mixins.forEach((mixin) => findHooks(mixin, hooks));
}
if (extendsOptions) {
findHooks(extendsOptions, hooks);
......@@ -156,10 +155,10 @@ function initHook(mpOptions, hook, excludes) {
}
const EXCLUDE_HOOKS = ['onReady'];
function initHooks(mpOptions, hooks, excludes = EXCLUDE_HOOKS) {
hooks.forEach(hook => initHook(mpOptions, hook, excludes));
hooks.forEach((hook) => initHook(mpOptions, hook, excludes));
}
function initUnknownHooks(mpOptions, vueOptions, excludes = EXCLUDE_HOOKS) {
findHooks(vueOptions).forEach(hook => initHook(mpOptions, hook, excludes));
findHooks(vueOptions).forEach((hook) => initHook(mpOptions, hook, excludes));
}
const HOOKS = [
......@@ -168,7 +167,7 @@ const HOOKS = [
'onError',
'onThemeChange',
'onPageNotFound',
'onUnhandledRejection'
'onUnhandledRejection',
];
function parseApp(instance, parseAppOptions) {
const internalInstance = instance.$;
......@@ -184,11 +183,11 @@ function parseApp(instance, parseAppOptions) {
initBaseInstance(internalInstance, {
mpType: 'app',
mpInstance: this,
slots: []
slots: [],
});
ctx.globalData = this.globalData;
instance.$callHook('onLaunch', options);
}
},
};
const vueOptions = instance.$.type;
initHooks(appOptions, HOOKS);
......@@ -212,7 +211,7 @@ const encode = encodeURIComponent;
function stringifyQuery(obj, encodeStr = encode) {
const res = obj
? Object.keys(obj)
.map(key => {
.map((key) => {
let val = obj[key];
if (typeof val === undefined || val === null) {
val = '';
......@@ -222,7 +221,7 @@ function stringifyQuery(obj, encodeStr = encode) {
}
return encodeStr(key) + '=' + encodeStr(val);
})
.filter(x => x.length > 0)
.filter((x) => x.length > 0)
.join('&')
: null;
return res ? `?${res}` : '';
......@@ -247,7 +246,7 @@ function initVueIds(vueIds, mpInstance) {
}
const EXTRAS = ['externalClasses'];
function initExtraOptions(miniProgramComponentOptions, vueOptions) {
EXTRAS.forEach(name => {
EXTRAS.forEach((name) => {
if (hasOwn(vueOptions, name)) {
miniProgramComponentOptions[name] = vueOptions[name];
}
......@@ -268,12 +267,12 @@ function initRefs(instance, mpInstance) {
get() {
const $refs = {};
const components = mpInstance.selectAllComponents('.vue-ref');
components.forEach(component => {
components.forEach((component) => {
const ref = component.dataset.ref;
$refs[ref] = component.$vm || component;
});
const forComponents = mpInstance.selectAllComponents('.vue-ref-in-for');
forComponents.forEach(component => {
forComponents.forEach((component) => {
const ref = component.dataset.ref;
if (!$refs[ref]) {
$refs[ref] = [];
......@@ -281,7 +280,7 @@ function initRefs(instance, mpInstance) {
$refs[ref].push(component.$vm || component);
});
return $refs;
}
},
});
}
function findVmByVueId(instance, vuePid) {
......@@ -324,7 +323,7 @@ function initDefaultProps(isBehavior = false) {
if (!isBehavior) {
properties.vueId = {
type: String,
value: ''
value: '',
};
// 小程序不能直接定义 $slots 的 props,所以通过 vueSlots 转换到 $slots
properties.vueSlots = {
......@@ -336,9 +335,9 @@ function initDefaultProps(isBehavior = false) {
$slots[slotName] = true;
});
this.setData({
$slots
$slots,
});
}
},
};
}
return properties;
......@@ -350,14 +349,14 @@ function createProperty(key, prop) {
function initProps(mpComponentOptions, rawProps, isBehavior = false) {
const properties = initDefaultProps(isBehavior);
if (isArray(rawProps)) {
rawProps.forEach(key => {
rawProps.forEach((key) => {
properties[key] = createProperty(key, {
type: null
type: null,
});
});
}
else if (isPlainObject(rawProps)) {
Object.keys(rawProps).forEach(key => {
Object.keys(rawProps).forEach((key) => {
const opts = rawProps[key];
if (isPlainObject(opts)) {
// title:{type:String,default:''}
......@@ -369,14 +368,14 @@ function initProps(mpComponentOptions, rawProps, isBehavior = false) {
opts.type = parsePropType(key, type);
properties[key] = createProperty(key, {
type: PROP_TYPES.indexOf(type) !== -1 ? type : null,
value
value,
});
}
else {
// content:String
const type = parsePropType(key, opts);
properties[key] = createProperty(key, {
type: PROP_TYPES.indexOf(type) !== -1 ? type : null
type: PROP_TYPES.indexOf(type) !== -1 ? type : null,
});
}
});
......@@ -420,7 +419,7 @@ function initBehaviors(vueOptions, initBehavior) {
}
const behaviors = [];
if (isArray(vueBehaviors)) {
vueBehaviors.forEach(behavior => {
vueBehaviors.forEach((behavior) => {
behaviors.push(behavior.replace('uni://', `${__PLATFORM_PREFIX__}://`));
if (behavior === 'uni://form-field') {
if (isArray(vueProps)) {
......@@ -430,11 +429,11 @@ function initBehaviors(vueOptions, initBehavior) {
else {
vueProps.name = {
type: String,
default: ''
default: '',
};
vueProps.value = {
type: [String, Number, Boolean, Array, Object, Date],
default: ''
default: '',
};
}
}
......@@ -446,7 +445,7 @@ function initBehaviors(vueOptions, initBehavior) {
behaviors.push(initBehavior(behavior));
}
if (isArray(vueMixins)) {
vueMixins.forEach(vueMixin => {
vueMixins.forEach((vueMixin) => {
if (vueMixin.props) {
const behavior = {};
initProps(behavior, vueMixin.props, true);
......@@ -475,7 +474,7 @@ function getValue(obj, path) {
}
function getExtraValue(instance, dataPathsArray) {
let context = instance;
dataPathsArray.forEach(dataPathArray => {
dataPathsArray.forEach((dataPathArray) => {
const dataPath = dataPathArray[0];
const value = dataPathArray[2];
if (dataPath || typeof value !== 'undefined') {
......@@ -505,12 +504,12 @@ function getExtraValue(instance, dataPathsArray) {
}
else {
if (isArray(vFor)) {
context = vFor.find(vForItem => {
context = vFor.find((vForItem) => {
return getValue(vForItem, propPath) === value;
});
}
else if (isPlainObject(vFor)) {
context = Object.keys(vFor).find(vForKey => {
context = Object.keys(vFor).find((vForKey) => {
return getValue(vFor[vForKey], propPath) === value;
});
}
......@@ -600,7 +599,7 @@ function processEventArgs(instance, event, args = [], extra = [], isCustom, meth
}
const extraObj = processEventExtra(instance, extra, event);
const ret = [];
args.forEach(arg => {
args.forEach((arg) => {
if (arg === '$event') {
if (methodName === '__set_model' && !isCustom) {
// input v-model value
......@@ -712,11 +711,11 @@ function handleEvent(event) {
}
}
function parseComponent(vueOptions, { parse, mocks, isPage, initRelation, handleLink, initLifetimes }) {
function parseComponent(vueOptions, { parse, mocks, isPage, initRelation, handleLink, initLifetimes, }) {
vueOptions = vueOptions.default || vueOptions;
const options = {
multipleSlots: true,
addGlobalClass: true
addGlobalClass: true,
};
if (vueOptions.options) {
extend(options, vueOptions.options);
......@@ -733,12 +732,12 @@ function parseComponent(vueOptions, { parse, mocks, isPage, initRelation, handle
},
resize(size) {
this.$vm && this.$vm.$callHook('onPageResize', size);
}
},
},
methods: {
__l: handleLink,
__e: handleEvent
}
__e: handleEvent,
},
};
if (__VUE_OPTIONS_API__) {
applyOptions(mpComponentOptions, vueOptions, initBehavior);
......@@ -772,19 +771,19 @@ function $destroyComponent(instance) {
}
function parsePage(vueOptions, parseOptions) {
const { parse, mocks, isPage, initRelation, handleLink, initLifetimes } = parseOptions;
const { parse, mocks, isPage, initRelation, handleLink, initLifetimes, } = parseOptions;
const miniProgramPageOptions = parseComponent(vueOptions, {
mocks,
isPage,
initRelation,
handleLink,
initLifetimes
initLifetimes,
});
const methods = miniProgramPageOptions.methods;
methods.onLoad = function (query) {
this.options = query;
this.$page = {
fullPath: '/' + this.route + stringifyQuery(query)
fullPath: '/' + this.route + stringifyQuery(query),
};
return this.$vm && this.$vm.$callHook('onLoad', query);
};
......@@ -834,13 +833,13 @@ Component = function (options) {
return MPComponent(options);
};
function initLifetimes({ mocks, isPage, initRelation, vueOptions }) {
function initLifetimes({ mocks, isPage, initRelation, vueOptions, }) {
return {
attached() {
const properties = this.properties;
initVueIds(properties.vueId, this);
const relationOptions = {
vuePid: this._$vuePid
vuePid: this._$vuePid,
};
// 处理父子关系
initRelation(this, relationOptions);
......@@ -848,7 +847,7 @@ function initLifetimes({ mocks, isPage, initRelation, vueOptions }) {
const mpInstance = this;
this.$vm = $createComponent({
type: vueOptions,
props: properties
props: properties,
}, {
mpType: isPage(mpInstance) ? 'page' : 'component',
mpInstance,
......@@ -858,7 +857,7 @@ function initLifetimes({ mocks, isPage, initRelation, vueOptions }) {
initRefs(instance, mpInstance);
initMocks(instance, mpInstance, mocks);
initComponentInstance(instance, options);
}
},
});
},
ready() {
......@@ -871,7 +870,7 @@ function initLifetimes({ mocks, isPage, initRelation, vueOptions }) {
},
detached() {
this.$vm && $destroyComponent(this.$vm);
}
},
};
}
......
......@@ -2,5 +2,5 @@ export {
redirectTo,
previewImage,
getSystemInfo,
getSystemInfoSync
getSystemInfoSync,
} from '@dcloudio/uni-mp-core'
......@@ -4,5 +4,5 @@ export const getProvider = initGetProvider({
oauth: ['qq'],
share: ['qq'],
payment: ['qqpay'],
push: ['qq']
push: ['qq'],
})
......@@ -23,8 +23,8 @@ const Upx2pxProtocol = [
{
name: 'upx',
type: [Number, String],
required: true
}
required: true,
},
];
const EPS = 1e-4;
......@@ -92,7 +92,7 @@ function queue(hooks, data) {
if (res === false) {
return {
then() { },
catch() { }
catch() { },
};
}
}
......@@ -101,11 +101,11 @@ function queue(hooks, data) {
then(callback) {
return callback(data);
},
catch() { }
catch() { },
});
}
function wrapperOptions(interceptors, options = {}) {
[HOOKS.SUCCESS, HOOKS.FAIL, HOOKS.COMPLETE].forEach(name => {
[HOOKS.SUCCESS, HOOKS.FAIL, HOOKS.COMPLETE].forEach((name) => {
const hooks = interceptors[name];
if (!isArray(hooks)) {
return;
......@@ -128,21 +128,21 @@ function wrapperReturnValue(method, returnValue) {
if (interceptor && isArray(interceptor.returnValue)) {
returnValueHooks.push(...interceptor.returnValue);
}
returnValueHooks.forEach(hook => {
returnValueHooks.forEach((hook) => {
returnValue = hook(returnValue) || returnValue;
});
return returnValue;
}
function getApiInterceptorHooks(method) {
const interceptor = Object.create(null);
Object.keys(globalInterceptors).forEach(hook => {
Object.keys(globalInterceptors).forEach((hook) => {
if (hook !== 'returnValue') {
interceptor[hook] = globalInterceptors[hook].slice();
}
});
const scopedInterceptor = scopedInterceptors[method];
if (scopedInterceptor) {
Object.keys(scopedInterceptor).forEach(hook => {
Object.keys(scopedInterceptor).forEach((hook) => {
if (hook !== 'returnValue') {
interceptor[hook] = (interceptor[hook] || []).concat(scopedInterceptor[hook]);
}
......@@ -155,7 +155,7 @@ function invokeApi(method, api, options, ...params) {
if (interceptor && Object.keys(interceptor).length) {
if (isArray(interceptor.invoke)) {
const res = queue(interceptor.invoke, options);
return res.then(options => {
return res.then((options) => {
return api(wrapperOptions(interceptor, options), ...params);
});
}
......@@ -170,13 +170,13 @@ const AddInterceptorProtocol = [
{
name: 'method',
type: [String, Object],
required: true
}
required: true,
},
];
const RemoveInterceptorProtocol = AddInterceptorProtocol;
function mergeInterceptorHook(interceptors, interceptor) {
Object.keys(interceptor).forEach(hook => {
Object.keys(interceptor).forEach((hook) => {
if (isFunction(interceptor[hook])) {
interceptors[hook] = mergeHook(interceptors[hook], interceptor[hook]);
}
......@@ -186,7 +186,7 @@ function removeInterceptorHook(interceptors, interceptor) {
if (!interceptors || !interceptor) {
return;
}
Object.keys(interceptor).forEach(hook => {
Object.keys(interceptor).forEach((hook) => {
if (isFunction(interceptor[hook])) {
removeHook(interceptors[hook], interceptor[hook]);
}
......@@ -263,10 +263,10 @@ function handlePromise(promise) {
return promise;
}
return promise
.then(data => {
.then((data) => {
return [null, data];
})
.catch(err => [err]);
.catch((err) => [err]);
}
function shouldPromise(name) {
if (isContextApi(name) || isSyncApi(name) || isCallbackApi(name)) {
......@@ -278,7 +278,7 @@ function shouldPromise(name) {
if (!Promise.prototype.finally) {
Promise.prototype.finally = function (onfinally) {
const promise = this.constructor;
return this.then(value => promise.resolve(onfinally && onfinally()).then(() => value), reason => promise.resolve(onfinally && onfinally()).then(() => {
return this.then((value) => promise.resolve(onfinally && onfinally()).then(() => value), (reason) => promise.resolve(onfinally && onfinally()).then(() => {
throw reason;
}));
};
......@@ -299,7 +299,7 @@ function promisify(name, api) {
return wrapperReturnValue(name, handlePromise(new Promise((resolve, reject) => {
invokeApi(name, api, Object.assign({}, options, {
success: resolve,
fail: reject
fail: reject,
}), ...params);
})));
};
......@@ -413,25 +413,25 @@ function initUni(api, protocols) {
// event-api
// provider-api?
return promisify(key, wrapper(key, tt[key]));
}
},
};
return new Proxy({}, UniProxyHandlers);
}
function initGetProvider(providers) {
return function getProvider({ service, success, fail, complete }) {
return function getProvider({ service, success, fail, complete, }) {
let res;
if (providers[service]) {
res = {
errMsg: 'getProvider:ok',
service,
provider: providers[service]
provider: providers[service],
};
isFunction(success) && success(res);
}
else {
res = {
errMsg: 'getProvider:fail:服务[' + service + ']不存在'
errMsg: 'getProvider:fail:服务[' + service + ']不存在',
};
isFunction(fail) && fail(res);
}
......@@ -468,9 +468,9 @@ const previewImage = {
}
return {
indicator: false,
loop: false
loop: false,
};
}
},
};
const redirectTo = {};
......@@ -478,7 +478,7 @@ const getProvider = initGetProvider({
oauth: ['toutiao'],
share: ['toutiao'],
payment: ['toutiao'],
push: ['toutiao']
push: ['toutiao'],
});
var shims = /*#__PURE__*/Object.freeze({
......@@ -488,74 +488,74 @@ var shims = /*#__PURE__*/Object.freeze({
const chooseImage = {
args: {
sizeType: false
}
sizeType: false,
},
};
const connectSocket = {
args: {
method: false
}
method: false,
},
};
const chooseVideo = {
args: {
camera: false
}
camera: false,
},
};
const scanCode = {
args: {
onlyFromCamera: false,
scanType: false
}
scanType: false,
},
};
const startAccelerometer = {
args: {
interval: false
}
interval: false,
},
};
const showToast = {
args: {
image: false,
mask: false
}
mask: false,
},
};
const showLoading = {
args: {
mask: false
}
mask: false,
},
};
const showModal = {
args: {
cancelColor: false,
confirmColor: false
}
confirmColor: false,
},
};
const showActionSheet = {
args: {
itemColor: false
}
itemColor: false,
},
};
const login = {
args: {
scopes: false,
timeout: false
}
timeout: false,
},
};
const getUserInfo = {
args: {
lang: false,
timeout: false
}
timeout: false,
},
};
const requestPayment = {
name: tt.pay ? 'pay' : 'requestPayment',
args: {
orderInfo: tt.pay ? 'orderInfo' : 'data'
}
orderInfo: tt.pay ? 'orderInfo' : 'data',
},
};
const getFileInfo = {
args: {
digestAlgorithm: false
}
digestAlgorithm: false,
},
};
var protocols = /*#__PURE__*/Object.freeze({
......
......@@ -50,7 +50,7 @@ const MP_METHODS = [
'createSelectorQuery',
'createIntersectionObserver',
'selectAllComponents',
'selectComponent'
'selectComponent',
];
function createEmitFn(oldEmit, ctx) {
return function emit(event, ...args) {
......@@ -77,7 +77,7 @@ function initBaseInstance(instance, options) {
{
instance.slots = {};
if (isArray(options.slots) && options.slots.length) {
options.slots.forEach(name => {
options.slots.forEach((name) => {
instance.slots[name] = true;
});
}
......@@ -88,7 +88,7 @@ function initBaseInstance(instance, options) {
function initComponentInstance(instance, options) {
initBaseInstance(instance, options);
const ctx = instance.ctx;
MP_METHODS.forEach(method => {
MP_METHODS.forEach((method) => {
ctx[method] = function (...args) {
const mpInstance = ctx.$scope;
if (mpInstance && mpInstance[method]) {
......@@ -106,7 +106,7 @@ function initComponentInstance(instance, options) {
}
function initMocks(instance, mpInstance, mocks) {
const ctx = instance.ctx;
mocks.forEach(mock => {
mocks.forEach((mock) => {
if (hasOwn(mpInstance, mock)) {
ctx[mock] = mpInstance[mock];
}
......@@ -125,12 +125,11 @@ const PAGE_HOOKS = [
'onReachBottom',
'onPullDownRefresh',
// 'onShareTimeline', // 右上角菜单,开发者手动注册
'onAddToFavorites'
// 'onShareAppMessage' // 右上角菜单,开发者手动注册
'onAddToFavorites',
];
function findHooks(vueOptions, hooks = new Set()) {
if (vueOptions) {
Object.keys(vueOptions).forEach(name => {
Object.keys(vueOptions).forEach((name) => {
if (name.indexOf('on') === 0 && isFunction(vueOptions[name])) {
hooks.add(name);
}
......@@ -138,7 +137,7 @@ function findHooks(vueOptions, hooks = new Set()) {
if (__VUE_OPTIONS_API__) {
const { extends: extendsOptions, mixins } = vueOptions;
if (mixins) {
mixins.forEach(mixin => findHooks(mixin, hooks));
mixins.forEach((mixin) => findHooks(mixin, hooks));
}
if (extendsOptions) {
findHooks(extendsOptions, hooks);
......@@ -159,10 +158,10 @@ function initHook(mpOptions, hook, excludes) {
}
const EXCLUDE_HOOKS = ['onReady'];
function initHooks(mpOptions, hooks, excludes = EXCLUDE_HOOKS) {
hooks.forEach(hook => initHook(mpOptions, hook, excludes));
hooks.forEach((hook) => initHook(mpOptions, hook, excludes));
}
function initUnknownHooks(mpOptions, vueOptions, excludes = EXCLUDE_HOOKS) {
findHooks(vueOptions).forEach(hook => initHook(mpOptions, hook, excludes));
findHooks(vueOptions).forEach((hook) => initHook(mpOptions, hook, excludes));
}
const HOOKS = [
......@@ -171,7 +170,7 @@ const HOOKS = [
'onError',
'onThemeChange',
'onPageNotFound',
'onUnhandledRejection'
'onUnhandledRejection',
];
function parseApp(instance, parseAppOptions) {
const internalInstance = instance.$;
......@@ -187,11 +186,11 @@ function parseApp(instance, parseAppOptions) {
initBaseInstance(internalInstance, {
mpType: 'app',
mpInstance: this,
slots: []
slots: [],
});
ctx.globalData = this.globalData;
instance.$callHook('onLaunch', options);
}
},
};
const vueOptions = instance.$.type;
initHooks(appOptions, HOOKS);
......@@ -215,7 +214,7 @@ const encode = encodeURIComponent;
function stringifyQuery(obj, encodeStr = encode) {
const res = obj
? Object.keys(obj)
.map(key => {
.map((key) => {
let val = obj[key];
if (typeof val === undefined || val === null) {
val = '';
......@@ -225,7 +224,7 @@ function stringifyQuery(obj, encodeStr = encode) {
}
return encodeStr(key) + '=' + encodeStr(val);
})
.filter(x => x.length > 0)
.filter((x) => x.length > 0)
.join('&')
: null;
return res ? `?${res}` : '';
......@@ -250,7 +249,7 @@ function initVueIds(vueIds, mpInstance) {
}
const EXTRAS = ['externalClasses'];
function initExtraOptions(miniProgramComponentOptions, vueOptions) {
EXTRAS.forEach(name => {
EXTRAS.forEach((name) => {
if (hasOwn(vueOptions, name)) {
miniProgramComponentOptions[name] = vueOptions[name];
}
......@@ -271,12 +270,12 @@ function initRefs(instance, mpInstance) {
get() {
const $refs = {};
const components = mpInstance.selectAllComponents('.vue-ref');
components.forEach(component => {
components.forEach((component) => {
const ref = component.dataset.ref;
$refs[ref] = component.$vm || component;
});
const forComponents = mpInstance.selectAllComponents('.vue-ref-in-for');
forComponents.forEach(component => {
forComponents.forEach((component) => {
const ref = component.dataset.ref;
if (!$refs[ref]) {
$refs[ref] = [];
......@@ -284,7 +283,7 @@ function initRefs(instance, mpInstance) {
$refs[ref].push(component.$vm || component);
});
return $refs;
}
},
});
}
function findVmByVueId(instance, vuePid) {
......@@ -327,12 +326,12 @@ function initDefaultProps(isBehavior = false) {
if (!isBehavior) {
properties.vueId = {
type: String,
value: ''
value: '',
};
{
// 用于字节跳动小程序模拟抽象节点
properties.generic = {
type: Object
type: Object,
};
}
// 小程序不能直接定义 $slots 的 props,所以通过 vueSlots 转换到 $slots
......@@ -345,9 +344,9 @@ function initDefaultProps(isBehavior = false) {
$slots[slotName] = true;
});
this.setData({
$slots
$slots,
});
}
},
};
}
return properties;
......@@ -359,14 +358,14 @@ function createProperty(key, prop) {
function initProps(mpComponentOptions, rawProps, isBehavior = false) {
const properties = initDefaultProps(isBehavior);
if (isArray(rawProps)) {
rawProps.forEach(key => {
rawProps.forEach((key) => {
properties[key] = createProperty(key, {
type: null
type: null,
});
});
}
else if (isPlainObject(rawProps)) {
Object.keys(rawProps).forEach(key => {
Object.keys(rawProps).forEach((key) => {
const opts = rawProps[key];
if (isPlainObject(opts)) {
// title:{type:String,default:''}
......@@ -378,14 +377,14 @@ function initProps(mpComponentOptions, rawProps, isBehavior = false) {
opts.type = parsePropType(key, type);
properties[key] = createProperty(key, {
type: PROP_TYPES.indexOf(type) !== -1 ? type : null,
value
value,
});
}
else {
// content:String
const type = parsePropType(key, opts);
properties[key] = createProperty(key, {
type: PROP_TYPES.indexOf(type) !== -1 ? type : null
type: PROP_TYPES.indexOf(type) !== -1 ? type : null,
});
}
});
......@@ -429,7 +428,7 @@ function initBehaviors(vueOptions, initBehavior) {
}
const behaviors = [];
if (isArray(vueBehaviors)) {
vueBehaviors.forEach(behavior => {
vueBehaviors.forEach((behavior) => {
behaviors.push(behavior.replace('uni://', `${__PLATFORM_PREFIX__}://`));
if (behavior === 'uni://form-field') {
if (isArray(vueProps)) {
......@@ -439,11 +438,11 @@ function initBehaviors(vueOptions, initBehavior) {
else {
vueProps.name = {
type: String,
default: ''
default: '',
};
vueProps.value = {
type: [String, Number, Boolean, Array, Object, Date],
default: ''
default: '',
};
}
}
......@@ -455,7 +454,7 @@ function initBehaviors(vueOptions, initBehavior) {
behaviors.push(initBehavior(behavior));
}
if (isArray(vueMixins)) {
vueMixins.forEach(vueMixin => {
vueMixins.forEach((vueMixin) => {
if (vueMixin.props) {
const behavior = {};
initProps(behavior, vueMixin.props, true);
......@@ -484,7 +483,7 @@ function getValue(obj, path) {
}
function getExtraValue(instance, dataPathsArray) {
let context = instance;
dataPathsArray.forEach(dataPathArray => {
dataPathsArray.forEach((dataPathArray) => {
const dataPath = dataPathArray[0];
const value = dataPathArray[2];
if (dataPath || typeof value !== 'undefined') {
......@@ -514,12 +513,12 @@ function getExtraValue(instance, dataPathsArray) {
}
else {
if (isArray(vFor)) {
context = vFor.find(vForItem => {
context = vFor.find((vForItem) => {
return getValue(vForItem, propPath) === value;
});
}
else if (isPlainObject(vFor)) {
context = Object.keys(vFor).find(vForKey => {
context = Object.keys(vFor).find((vForKey) => {
return getValue(vFor[vForKey], propPath) === value;
});
}
......@@ -609,7 +608,7 @@ function processEventArgs(instance, event, args = [], extra = [], isCustom, meth
}
const extraObj = processEventExtra(instance, extra, event);
const ret = [];
args.forEach(arg => {
args.forEach((arg) => {
if (arg === '$event') {
if (methodName === '__set_model' && !isCustom) {
// input v-model value
......@@ -721,11 +720,11 @@ function handleEvent(event) {
}
}
function parseComponent(vueOptions, { parse, mocks, isPage, initRelation, handleLink, initLifetimes }) {
function parseComponent(vueOptions, { parse, mocks, isPage, initRelation, handleLink, initLifetimes, }) {
vueOptions = vueOptions.default || vueOptions;
const options = {
multipleSlots: true,
addGlobalClass: true
addGlobalClass: true,
};
if (vueOptions.options) {
extend(options, vueOptions.options);
......@@ -742,12 +741,12 @@ function parseComponent(vueOptions, { parse, mocks, isPage, initRelation, handle
},
resize(size) {
this.$vm && this.$vm.$callHook('onPageResize', size);
}
},
},
methods: {
__l: handleLink,
__e: handleEvent
}
__e: handleEvent,
},
};
if (__VUE_OPTIONS_API__) {
applyOptions(mpComponentOptions, vueOptions, initBehavior);
......@@ -781,19 +780,19 @@ function $destroyComponent(instance) {
}
function parsePage(vueOptions, parseOptions) {
const { parse, mocks, isPage, initRelation, handleLink, initLifetimes } = parseOptions;
const { parse, mocks, isPage, initRelation, handleLink, initLifetimes, } = parseOptions;
const miniProgramPageOptions = parseComponent(vueOptions, {
mocks,
isPage,
initRelation,
handleLink,
initLifetimes
initLifetimes,
});
const methods = miniProgramPageOptions.methods;
methods.onLoad = function (query) {
this.options = query;
this.$page = {
fullPath: '/' + this.route + stringifyQuery(query)
fullPath: '/' + this.route + stringifyQuery(query),
};
return this.$vm && this.$vm.$callHook('onLoad', query);
};
......@@ -928,13 +927,13 @@ function initInjections(instance) {
}
}
function initLifetimes({ mocks, isPage, initRelation, vueOptions }) {
function initLifetimes({ mocks, isPage, initRelation, vueOptions, }) {
return {
attached() {
const properties = this.properties;
initVueIds(properties.vueId, this);
const relationOptions = {
vuePid: this._$vuePid
vuePid: this._$vuePid,
};
// 初始化 vue 实例
const mpInstance = this;
......@@ -944,7 +943,7 @@ function initLifetimes({ mocks, isPage, initRelation, vueOptions }) {
}
this.$vm = $createComponent({
type: vueOptions,
props: properties
props: properties,
}, {
mpType,
mpInstance,
......@@ -954,14 +953,14 @@ function initLifetimes({ mocks, isPage, initRelation, vueOptions }) {
initRefs(instance, mpInstance);
initMocks(instance, mpInstance, mocks);
initComponentInstance(instance, options);
}
},
});
// 处理父子关系
initRelation(this, relationOptions);
},
detached() {
this.$vm && $destroyComponent(this.$vm);
}
},
};
}
......@@ -969,7 +968,7 @@ const mocks = [
'__route__',
'__webviewId__',
'__nodeId__',
'__nodeid__' /* @Deprecated */
'__nodeid__' /* @Deprecated */,
];
function isPage(mpInstance) {
return (mpInstance.__nodeId__ === 0 || mpInstance.__nodeid__ === 0);
......@@ -985,10 +984,10 @@ function initRelation(mpInstance, detail) {
mpInstance.triggerEvent('__l', {
vuePid: detail.vuePid,
nodeId,
webviewId
webviewId,
});
}
function handleLink({ detail: { vuePid, nodeId, webviewId } }) {
function handleLink({ detail: { vuePid, nodeId, webviewId }, }) {
const vm = instances[webviewId + '_' + nodeId];
if (!vm) {
return;
......@@ -1046,12 +1045,12 @@ function initLifetimes$1(lifetimesOptions) {
// 清理
const webviewId = this.__webviewId__;
webviewId &&
Object.keys(instances).forEach(key => {
Object.keys(instances).forEach((key) => {
if (key.indexOf(webviewId + '_') === 0) {
delete instances[key];
}
});
}
},
});
}
......
export { redirectTo, previewImage } from '@dcloudio/uni-mp-core'
export const chooseImage = {
args: {
sizeType: false
}
sizeType: false,
},
}
export const connectSocket = {
args: {
method: false
}
method: false,
},
}
export const chooseVideo = {
args: {
camera: false
}
camera: false,
},
}
export const scanCode = {
args: {
onlyFromCamera: false,
scanType: false
}
scanType: false,
},
}
export const startAccelerometer = {
args: {
interval: false
}
interval: false,
},
}
export const showToast = {
args: {
image: false,
mask: false
}
mask: false,
},
}
export const showLoading = {
args: {
mask: false
}
mask: false,
},
}
export const showModal = {
args: {
cancelColor: false,
confirmColor: false
}
confirmColor: false,
},
}
export const showActionSheet = {
args: {
itemColor: false
}
itemColor: false,
},
}
export const login = {
args: {
scopes: false,
timeout: false
}
timeout: false,
},
}
export const getUserInfo = {
args: {
lang: false,
timeout: false
}
timeout: false,
},
}
export const requestPayment = {
name: tt.pay ? 'pay' : 'requestPayment',
args: {
orderInfo: tt.pay ? 'orderInfo' : 'data'
}
orderInfo: tt.pay ? 'orderInfo' : 'data',
},
}
export const getFileInfo = {
args: {
digestAlgorithm: false
}
digestAlgorithm: false,
},
}
......@@ -4,5 +4,5 @@ export const getProvider = initGetProvider({
oauth: ['toutiao'],
share: ['toutiao'],
payment: ['toutiao'],
push: ['toutiao']
push: ['toutiao'],
})
export { initProvide, initInjections } from './runtime/apiInject'
export {
parse as parsePage,
initLifetimes as initPageLifetimes
initLifetimes as initPageLifetimes,
} from './runtime/parsePageOptions'
export {
instances,
parse as parseComponent,
initLifetimes as initComponentLifetimes
initLifetimes as initComponentLifetimes,
} from './runtime/parseComponentOptions'
......@@ -3,7 +3,7 @@ import { isArray, isObject, isFunction } from '@vue/shared'
import {
InjectionKey,
ComponentPublicInstance,
ComponentInternalInstance
ComponentInternalInstance,
} from 'vue'
function provide<T>(
......
......@@ -4,7 +4,7 @@ import {
RelationOptions,
MPComponentInstance,
CreateComponentOptions,
CreateLifetimesOptions
CreateLifetimesOptions,
} from '@dcloudio/uni-mp-core'
import {
......@@ -13,21 +13,21 @@ import {
initVueIds,
$createComponent,
$destroyComponent,
initComponentInstance
initComponentInstance,
} from '@dcloudio/uni-mp-core'
export function initLifetimes({
mocks,
isPage,
initRelation,
vueOptions
vueOptions,
}: CreateLifetimesOptions) {
return {
attached(this: MPComponentInstance) {
const properties = this.properties
initVueIds(properties.vueId, this)
const relationOptions: RelationOptions = {
vuePid: this._$vuePid
vuePid: this._$vuePid,
}
// 初始化 vue 实例
const mpInstance = this
......@@ -38,7 +38,7 @@ export function initLifetimes({
this.$vm = $createComponent(
{
type: vueOptions,
props: properties
props: properties,
},
{
mpType,
......@@ -52,7 +52,7 @@ export function initLifetimes({
initRefs(instance, mpInstance)
initMocks(instance, mpInstance, mocks)
initComponentInstance(instance, options)
}
},
}
) as ComponentPublicInstance
......@@ -61,6 +61,6 @@ export function initLifetimes({
},
detached(this: MPComponentInstance) {
this.$vm && $destroyComponent(this.$vm)
}
},
}
}
import {
initCreateApp,
initCreatePage,
initCreateComponent
initCreateComponent,
} from '@dcloudio/uni-mp-core'
import '@dcloudio/uni-mp-polyfill'
......
......@@ -2,7 +2,7 @@ import { extend } from '@vue/shared'
import {
MPComponentInstance,
CreateLifetimesOptions
CreateLifetimesOptions,
} from '@dcloudio/uni-mp-core'
import { $destroyComponent } from '@dcloudio/uni-mp-core'
......@@ -29,11 +29,11 @@ export function initLifetimes(lifetimesOptions: CreateLifetimesOptions) {
// 清理
const webviewId = this.__webviewId__
webviewId &&
Object.keys(instances).forEach(key => {
Object.keys(instances).forEach((key) => {
if (key.indexOf(webviewId + '_') === 0) {
delete instances[key]
}
})
}
},
})
}
......@@ -13,7 +13,7 @@ export const mocks = [
'__route__',
'__webviewId__',
'__nodeId__',
'__nodeid__' /* @Deprecated */
'__nodeid__' /* @Deprecated */,
]
export function isPage(mpInstance: MPComponentInstance) {
......@@ -40,14 +40,14 @@ export function initRelation(mpInstance: MPComponentInstance, detail: Object) {
mpInstance.triggerEvent('__l', {
vuePid: (detail as any).vuePid,
nodeId,
webviewId
webviewId,
})
}
export function handleLink(
this: MPComponentInstance,
{
detail: { vuePid, nodeId, webviewId }
detail: { vuePid, nodeId, webviewId },
}: {
detail: RelationOptions
}
......
......@@ -3,6 +3,6 @@ export {
isPage,
initRelation,
handleLink,
parse
parse,
} from './parseComponentOptions'
export { initLifetimes } from './pageLifetimes'
......@@ -3247,7 +3247,7 @@ function defineEmit() {
}
// Core API ------------------------------------------------------------------
const version = "3.0.4";
const version = "3.0.5";
// import deepCopy from './deepCopy'
/**
......@@ -3661,7 +3661,7 @@ function createVueApp(rootComponent, rootProps = null) {
}
function applyOptions$1(options, instance, publicThis) {
Object.keys(options).forEach(name => {
Object.keys(options).forEach((name) => {
if (name.indexOf('on') === 0) {
const hook = options[name];
if (isFunction(hook)) {
......@@ -3737,7 +3737,7 @@ var plugin = {
createMiniProgramApp(instance);
return instance;
};
}
},
};
// @ts-ignore
......
......@@ -26,5 +26,5 @@ export default {
createMiniProgramApp(instance)
return instance
}
}
},
}
......@@ -23,8 +23,8 @@ const Upx2pxProtocol = [
{
name: 'upx',
type: [Number, String],
required: true
}
required: true,
},
];
const EPS = 1e-4;
......@@ -92,7 +92,7 @@ function queue(hooks, data) {
if (res === false) {
return {
then() { },
catch() { }
catch() { },
};
}
}
......@@ -101,11 +101,11 @@ function queue(hooks, data) {
then(callback) {
return callback(data);
},
catch() { }
catch() { },
});
}
function wrapperOptions(interceptors, options = {}) {
[HOOKS.SUCCESS, HOOKS.FAIL, HOOKS.COMPLETE].forEach(name => {
[HOOKS.SUCCESS, HOOKS.FAIL, HOOKS.COMPLETE].forEach((name) => {
const hooks = interceptors[name];
if (!isArray(hooks)) {
return;
......@@ -128,21 +128,21 @@ function wrapperReturnValue(method, returnValue) {
if (interceptor && isArray(interceptor.returnValue)) {
returnValueHooks.push(...interceptor.returnValue);
}
returnValueHooks.forEach(hook => {
returnValueHooks.forEach((hook) => {
returnValue = hook(returnValue) || returnValue;
});
return returnValue;
}
function getApiInterceptorHooks(method) {
const interceptor = Object.create(null);
Object.keys(globalInterceptors).forEach(hook => {
Object.keys(globalInterceptors).forEach((hook) => {
if (hook !== 'returnValue') {
interceptor[hook] = globalInterceptors[hook].slice();
}
});
const scopedInterceptor = scopedInterceptors[method];
if (scopedInterceptor) {
Object.keys(scopedInterceptor).forEach(hook => {
Object.keys(scopedInterceptor).forEach((hook) => {
if (hook !== 'returnValue') {
interceptor[hook] = (interceptor[hook] || []).concat(scopedInterceptor[hook]);
}
......@@ -155,7 +155,7 @@ function invokeApi(method, api, options, ...params) {
if (interceptor && Object.keys(interceptor).length) {
if (isArray(interceptor.invoke)) {
const res = queue(interceptor.invoke, options);
return res.then(options => {
return res.then((options) => {
return api(wrapperOptions(interceptor, options), ...params);
});
}
......@@ -170,13 +170,13 @@ const AddInterceptorProtocol = [
{
name: 'method',
type: [String, Object],
required: true
}
required: true,
},
];
const RemoveInterceptorProtocol = AddInterceptorProtocol;
function mergeInterceptorHook(interceptors, interceptor) {
Object.keys(interceptor).forEach(hook => {
Object.keys(interceptor).forEach((hook) => {
if (isFunction(interceptor[hook])) {
interceptors[hook] = mergeHook(interceptors[hook], interceptor[hook]);
}
......@@ -186,7 +186,7 @@ function removeInterceptorHook(interceptors, interceptor) {
if (!interceptors || !interceptor) {
return;
}
Object.keys(interceptor).forEach(hook => {
Object.keys(interceptor).forEach((hook) => {
if (isFunction(interceptor[hook])) {
removeHook(interceptors[hook], interceptor[hook]);
}
......@@ -263,10 +263,10 @@ function handlePromise(promise) {
return promise;
}
return promise
.then(data => {
.then((data) => {
return [null, data];
})
.catch(err => [err]);
.catch((err) => [err]);
}
function shouldPromise(name) {
if (isContextApi(name) || isSyncApi(name) || isCallbackApi(name)) {
......@@ -278,7 +278,7 @@ function shouldPromise(name) {
if (!Promise.prototype.finally) {
Promise.prototype.finally = function (onfinally) {
const promise = this.constructor;
return this.then(value => promise.resolve(onfinally && onfinally()).then(() => value), reason => promise.resolve(onfinally && onfinally()).then(() => {
return this.then((value) => promise.resolve(onfinally && onfinally()).then(() => value), (reason) => promise.resolve(onfinally && onfinally()).then(() => {
throw reason;
}));
};
......@@ -299,7 +299,7 @@ function promisify(name, api) {
return wrapperReturnValue(name, handlePromise(new Promise((resolve, reject) => {
invokeApi(name, api, Object.assign({}, options, {
success: resolve,
fail: reject
fail: reject,
}), ...params);
})));
};
......@@ -413,25 +413,25 @@ function initUni(api, protocols) {
// event-api
// provider-api?
return promisify(key, wrapper(key, wx[key]));
}
},
};
return new Proxy({}, UniProxyHandlers);
}
function initGetProvider(providers) {
return function getProvider({ service, success, fail, complete }) {
return function getProvider({ service, success, fail, complete, }) {
let res;
if (providers[service]) {
res = {
errMsg: 'getProvider:ok',
service,
provider: providers[service]
provider: providers[service],
};
isFunction(success) && success(res);
}
else {
res = {
errMsg: 'getProvider:fail:服务[' + service + ']不存在'
errMsg: 'getProvider:fail:服务[' + service + ']不存在',
};
isFunction(fail) && fail(res);
}
......@@ -468,9 +468,9 @@ const previewImage = {
}
return {
indicator: false,
loop: false
loop: false,
};
}
},
};
function addSafeAreaInsets(fromRes, toRes) {
if (fromRes.safeArea) {
......@@ -479,12 +479,12 @@ function addSafeAreaInsets(fromRes, toRes) {
top: safeArea.top,
left: safeArea.left,
right: fromRes.windowWidth - safeArea.right,
bottom: fromRes.windowHeight - safeArea.bottom
bottom: fromRes.windowHeight - safeArea.bottom,
};
}
}
const getSystemInfo = {
returnValue: addSafeAreaInsets
returnValue: addSafeAreaInsets,
};
const getSystemInfoSync = getSystemInfo;
const redirectTo = {};
......@@ -493,7 +493,7 @@ const getProvider = initGetProvider({
oauth: ['weixin'],
share: ['weixin'],
payment: ['wxpay'],
push: ['weixin']
push: ['weixin'],
});
var shims = /*#__PURE__*/Object.freeze({
......
......@@ -50,7 +50,7 @@ const MP_METHODS = [
'createSelectorQuery',
'createIntersectionObserver',
'selectAllComponents',
'selectComponent'
'selectComponent',
];
function createEmitFn(oldEmit, ctx) {
return function emit(event, ...args) {
......@@ -77,7 +77,7 @@ function initBaseInstance(instance, options) {
{
instance.slots = {};
if (isArray(options.slots) && options.slots.length) {
options.slots.forEach(name => {
options.slots.forEach((name) => {
instance.slots[name] = true;
});
}
......@@ -88,7 +88,7 @@ function initBaseInstance(instance, options) {
function initComponentInstance(instance, options) {
initBaseInstance(instance, options);
const ctx = instance.ctx;
MP_METHODS.forEach(method => {
MP_METHODS.forEach((method) => {
ctx[method] = function (...args) {
const mpInstance = ctx.$scope;
if (mpInstance && mpInstance[method]) {
......@@ -106,7 +106,7 @@ function initComponentInstance(instance, options) {
}
function initMocks(instance, mpInstance, mocks) {
const ctx = instance.ctx;
mocks.forEach(mock => {
mocks.forEach((mock) => {
if (hasOwn(mpInstance, mock)) {
ctx[mock] = mpInstance[mock];
}
......@@ -125,12 +125,11 @@ const PAGE_HOOKS = [
'onReachBottom',
'onPullDownRefresh',
// 'onShareTimeline', // 右上角菜单,开发者手动注册
'onAddToFavorites'
// 'onShareAppMessage' // 右上角菜单,开发者手动注册
'onAddToFavorites',
];
function findHooks(vueOptions, hooks = new Set()) {
if (vueOptions) {
Object.keys(vueOptions).forEach(name => {
Object.keys(vueOptions).forEach((name) => {
if (name.indexOf('on') === 0 && isFunction(vueOptions[name])) {
hooks.add(name);
}
......@@ -138,7 +137,7 @@ function findHooks(vueOptions, hooks = new Set()) {
if (__VUE_OPTIONS_API__) {
const { extends: extendsOptions, mixins } = vueOptions;
if (mixins) {
mixins.forEach(mixin => findHooks(mixin, hooks));
mixins.forEach((mixin) => findHooks(mixin, hooks));
}
if (extendsOptions) {
findHooks(extendsOptions, hooks);
......@@ -156,10 +155,10 @@ function initHook(mpOptions, hook, excludes) {
}
const EXCLUDE_HOOKS = ['onReady'];
function initHooks(mpOptions, hooks, excludes = EXCLUDE_HOOKS) {
hooks.forEach(hook => initHook(mpOptions, hook, excludes));
hooks.forEach((hook) => initHook(mpOptions, hook, excludes));
}
function initUnknownHooks(mpOptions, vueOptions, excludes = EXCLUDE_HOOKS) {
findHooks(vueOptions).forEach(hook => initHook(mpOptions, hook, excludes));
findHooks(vueOptions).forEach((hook) => initHook(mpOptions, hook, excludes));
}
const HOOKS = [
......@@ -168,7 +167,7 @@ const HOOKS = [
'onError',
'onThemeChange',
'onPageNotFound',
'onUnhandledRejection'
'onUnhandledRejection',
];
function parseApp(instance, parseAppOptions) {
const internalInstance = instance.$;
......@@ -184,11 +183,11 @@ function parseApp(instance, parseAppOptions) {
initBaseInstance(internalInstance, {
mpType: 'app',
mpInstance: this,
slots: []
slots: [],
});
ctx.globalData = this.globalData;
instance.$callHook('onLaunch', options);
}
},
};
const vueOptions = instance.$.type;
initHooks(appOptions, HOOKS);
......@@ -212,7 +211,7 @@ const encode = encodeURIComponent;
function stringifyQuery(obj, encodeStr = encode) {
const res = obj
? Object.keys(obj)
.map(key => {
.map((key) => {
let val = obj[key];
if (typeof val === undefined || val === null) {
val = '';
......@@ -222,7 +221,7 @@ function stringifyQuery(obj, encodeStr = encode) {
}
return encodeStr(key) + '=' + encodeStr(val);
})
.filter(x => x.length > 0)
.filter((x) => x.length > 0)
.join('&')
: null;
return res ? `?${res}` : '';
......@@ -247,7 +246,7 @@ function initVueIds(vueIds, mpInstance) {
}
const EXTRAS = ['externalClasses'];
function initExtraOptions(miniProgramComponentOptions, vueOptions) {
EXTRAS.forEach(name => {
EXTRAS.forEach((name) => {
if (hasOwn(vueOptions, name)) {
miniProgramComponentOptions[name] = vueOptions[name];
}
......@@ -268,12 +267,12 @@ function initRefs(instance, mpInstance) {
get() {
const $refs = {};
const components = mpInstance.selectAllComponents('.vue-ref');
components.forEach(component => {
components.forEach((component) => {
const ref = component.dataset.ref;
$refs[ref] = component.$vm || component;
});
const forComponents = mpInstance.selectAllComponents('.vue-ref-in-for');
forComponents.forEach(component => {
forComponents.forEach((component) => {
const ref = component.dataset.ref;
if (!$refs[ref]) {
$refs[ref] = [];
......@@ -281,7 +280,7 @@ function initRefs(instance, mpInstance) {
$refs[ref].push(component.$vm || component);
});
return $refs;
}
},
});
}
function findVmByVueId(instance, vuePid) {
......@@ -324,7 +323,7 @@ function initDefaultProps(isBehavior = false) {
if (!isBehavior) {
properties.vueId = {
type: String,
value: ''
value: '',
};
// 小程序不能直接定义 $slots 的 props,所以通过 vueSlots 转换到 $slots
properties.vueSlots = {
......@@ -336,9 +335,9 @@ function initDefaultProps(isBehavior = false) {
$slots[slotName] = true;
});
this.setData({
$slots
$slots,
});
}
},
};
}
return properties;
......@@ -350,14 +349,14 @@ function createProperty(key, prop) {
function initProps(mpComponentOptions, rawProps, isBehavior = false) {
const properties = initDefaultProps(isBehavior);
if (isArray(rawProps)) {
rawProps.forEach(key => {
rawProps.forEach((key) => {
properties[key] = createProperty(key, {
type: null
type: null,
});
});
}
else if (isPlainObject(rawProps)) {
Object.keys(rawProps).forEach(key => {
Object.keys(rawProps).forEach((key) => {
const opts = rawProps[key];
if (isPlainObject(opts)) {
// title:{type:String,default:''}
......@@ -369,14 +368,14 @@ function initProps(mpComponentOptions, rawProps, isBehavior = false) {
opts.type = parsePropType(key, type);
properties[key] = createProperty(key, {
type: PROP_TYPES.indexOf(type) !== -1 ? type : null,
value
value,
});
}
else {
// content:String
const type = parsePropType(key, opts);
properties[key] = createProperty(key, {
type: PROP_TYPES.indexOf(type) !== -1 ? type : null
type: PROP_TYPES.indexOf(type) !== -1 ? type : null,
});
}
});
......@@ -420,7 +419,7 @@ function initBehaviors(vueOptions, initBehavior) {
}
const behaviors = [];
if (isArray(vueBehaviors)) {
vueBehaviors.forEach(behavior => {
vueBehaviors.forEach((behavior) => {
behaviors.push(behavior.replace('uni://', `${__PLATFORM_PREFIX__}://`));
if (behavior === 'uni://form-field') {
if (isArray(vueProps)) {
......@@ -430,11 +429,11 @@ function initBehaviors(vueOptions, initBehavior) {
else {
vueProps.name = {
type: String,
default: ''
default: '',
};
vueProps.value = {
type: [String, Number, Boolean, Array, Object, Date],
default: ''
default: '',
};
}
}
......@@ -446,7 +445,7 @@ function initBehaviors(vueOptions, initBehavior) {
behaviors.push(initBehavior(behavior));
}
if (isArray(vueMixins)) {
vueMixins.forEach(vueMixin => {
vueMixins.forEach((vueMixin) => {
if (vueMixin.props) {
const behavior = {};
initProps(behavior, vueMixin.props, true);
......@@ -475,7 +474,7 @@ function getValue(obj, path) {
}
function getExtraValue(instance, dataPathsArray) {
let context = instance;
dataPathsArray.forEach(dataPathArray => {
dataPathsArray.forEach((dataPathArray) => {
const dataPath = dataPathArray[0];
const value = dataPathArray[2];
if (dataPath || typeof value !== 'undefined') {
......@@ -505,12 +504,12 @@ function getExtraValue(instance, dataPathsArray) {
}
else {
if (isArray(vFor)) {
context = vFor.find(vForItem => {
context = vFor.find((vForItem) => {
return getValue(vForItem, propPath) === value;
});
}
else if (isPlainObject(vFor)) {
context = Object.keys(vFor).find(vForKey => {
context = Object.keys(vFor).find((vForKey) => {
return getValue(vFor[vForKey], propPath) === value;
});
}
......@@ -600,7 +599,7 @@ function processEventArgs(instance, event, args = [], extra = [], isCustom, meth
}
const extraObj = processEventExtra(instance, extra, event);
const ret = [];
args.forEach(arg => {
args.forEach((arg) => {
if (arg === '$event') {
if (methodName === '__set_model' && !isCustom) {
// input v-model value
......@@ -712,11 +711,11 @@ function handleEvent(event) {
}
}
function parseComponent(vueOptions, { parse, mocks, isPage, initRelation, handleLink, initLifetimes }) {
function parseComponent(vueOptions, { parse, mocks, isPage, initRelation, handleLink, initLifetimes, }) {
vueOptions = vueOptions.default || vueOptions;
const options = {
multipleSlots: true,
addGlobalClass: true
addGlobalClass: true,
};
if (vueOptions.options) {
extend(options, vueOptions.options);
......@@ -733,12 +732,12 @@ function parseComponent(vueOptions, { parse, mocks, isPage, initRelation, handle
},
resize(size) {
this.$vm && this.$vm.$callHook('onPageResize', size);
}
},
},
methods: {
__l: handleLink,
__e: handleEvent
}
__e: handleEvent,
},
};
if (__VUE_OPTIONS_API__) {
applyOptions(mpComponentOptions, vueOptions, initBehavior);
......@@ -772,19 +771,19 @@ function $destroyComponent(instance) {
}
function parsePage(vueOptions, parseOptions) {
const { parse, mocks, isPage, initRelation, handleLink, initLifetimes } = parseOptions;
const { parse, mocks, isPage, initRelation, handleLink, initLifetimes, } = parseOptions;
const miniProgramPageOptions = parseComponent(vueOptions, {
mocks,
isPage,
initRelation,
handleLink,
initLifetimes
initLifetimes,
});
const methods = miniProgramPageOptions.methods;
methods.onLoad = function (query) {
this.options = query;
this.$page = {
fullPath: '/' + this.route + stringifyQuery(query)
fullPath: '/' + this.route + stringifyQuery(query),
};
return this.$vm && this.$vm.$callHook('onLoad', query);
};
......@@ -834,13 +833,13 @@ Component = function (options) {
return MPComponent(options);
};
function initLifetimes({ mocks, isPage, initRelation, vueOptions }) {
function initLifetimes({ mocks, isPage, initRelation, vueOptions, }) {
return {
attached() {
const properties = this.properties;
initVueIds(properties.vueId, this);
const relationOptions = {
vuePid: this._$vuePid
vuePid: this._$vuePid,
};
// 处理父子关系
initRelation(this, relationOptions);
......@@ -848,7 +847,7 @@ function initLifetimes({ mocks, isPage, initRelation, vueOptions }) {
const mpInstance = this;
this.$vm = $createComponent({
type: vueOptions,
props: properties
props: properties,
}, {
mpType: isPage(mpInstance) ? 'page' : 'component',
mpInstance,
......@@ -858,7 +857,7 @@ function initLifetimes({ mocks, isPage, initRelation, vueOptions }) {
initRefs(instance, mpInstance);
initMocks(instance, mpInstance, mocks);
initComponentInstance(instance, options);
}
},
});
},
ready() {
......@@ -871,7 +870,7 @@ function initLifetimes({ mocks, isPage, initRelation, vueOptions }) {
},
detached() {
this.$vm && $destroyComponent(this.$vm);
}
},
};
}
......
......@@ -2,5 +2,5 @@ export {
redirectTo,
previewImage,
getSystemInfo,
getSystemInfoSync
getSystemInfoSync,
} from '@dcloudio/uni-mp-core'
......@@ -4,5 +4,5 @@ export const getProvider = initGetProvider({
oauth: ['weixin'],
share: ['weixin'],
payment: ['wxpay'],
push: ['weixin']
push: ['weixin'],
})
import {
initCreateApp,
initCreatePage,
initCreateComponent
initCreateComponent,
} from '@dcloudio/uni-mp-core'
import '@dcloudio/uni-mp-polyfill'
......
......@@ -4,7 +4,7 @@ import {
RelationOptions,
MPComponentInstance,
CreateComponentOptions,
CreateLifetimesOptions
CreateLifetimesOptions,
} from '@dcloudio/uni-mp-core'
import {
......@@ -13,21 +13,21 @@ import {
initVueIds,
$createComponent,
$destroyComponent,
initComponentInstance
initComponentInstance,
} from '@dcloudio/uni-mp-core'
export function initLifetimes({
mocks,
isPage,
initRelation,
vueOptions
vueOptions,
}: CreateLifetimesOptions) {
return {
attached(this: MPComponentInstance) {
const properties = this.properties
initVueIds(properties.vueId, this)
const relationOptions: RelationOptions = {
vuePid: this._$vuePid
vuePid: this._$vuePid,
}
// 处理父子关系
initRelation(this, relationOptions)
......@@ -36,7 +36,7 @@ export function initLifetimes({
this.$vm = $createComponent(
{
type: vueOptions,
props: properties
props: properties,
},
{
mpType: isPage(mpInstance) ? 'page' : 'component',
......@@ -50,7 +50,7 @@ export function initLifetimes({
initRefs(instance, mpInstance)
initMocks(instance, mpInstance, mocks)
initComponentInstance(instance, options)
}
},
}
) as ComponentPublicInstance
},
......@@ -66,6 +66,6 @@ export function initLifetimes({
},
detached(this: MPComponentInstance) {
this.$vm && $destroyComponent(this.$vm)
}
},
}
}
......@@ -10,7 +10,10 @@ export function isPage(mpInstance: MPComponentInstance) {
return !!mpInstance.route
}
export function initRelation(mpInstance: MPComponentInstance, detail: object) {
export function initRelation(
mpInstance: MPComponentInstance,
detail: Record<string, unknown>
) {
mpInstance.triggerEvent('__l', detail)
}
......
......@@ -23,8 +23,8 @@ const Upx2pxProtocol = [
{
name: 'upx',
type: [Number, String],
required: true
}
required: true,
},
];
const EPS = 1e-4;
......@@ -92,7 +92,7 @@ function queue(hooks, data) {
if (res === false) {
return {
then() { },
catch() { }
catch() { },
};
}
}
......@@ -101,11 +101,11 @@ function queue(hooks, data) {
then(callback) {
return callback(data);
},
catch() { }
catch() { },
});
}
function wrapperOptions(interceptors, options = {}) {
[HOOKS.SUCCESS, HOOKS.FAIL, HOOKS.COMPLETE].forEach(name => {
[HOOKS.SUCCESS, HOOKS.FAIL, HOOKS.COMPLETE].forEach((name) => {
const hooks = interceptors[name];
if (!isArray(hooks)) {
return;
......@@ -128,21 +128,21 @@ function wrapperReturnValue(method, returnValue) {
if (interceptor && isArray(interceptor.returnValue)) {
returnValueHooks.push(...interceptor.returnValue);
}
returnValueHooks.forEach(hook => {
returnValueHooks.forEach((hook) => {
returnValue = hook(returnValue) || returnValue;
});
return returnValue;
}
function getApiInterceptorHooks(method) {
const interceptor = Object.create(null);
Object.keys(globalInterceptors).forEach(hook => {
Object.keys(globalInterceptors).forEach((hook) => {
if (hook !== 'returnValue') {
interceptor[hook] = globalInterceptors[hook].slice();
}
});
const scopedInterceptor = scopedInterceptors[method];
if (scopedInterceptor) {
Object.keys(scopedInterceptor).forEach(hook => {
Object.keys(scopedInterceptor).forEach((hook) => {
if (hook !== 'returnValue') {
interceptor[hook] = (interceptor[hook] || []).concat(scopedInterceptor[hook]);
}
......@@ -155,7 +155,7 @@ function invokeApi(method, api, options, ...params) {
if (interceptor && Object.keys(interceptor).length) {
if (isArray(interceptor.invoke)) {
const res = queue(interceptor.invoke, options);
return res.then(options => {
return res.then((options) => {
return api(wrapperOptions(interceptor, options), ...params);
});
}
......@@ -170,13 +170,13 @@ const AddInterceptorProtocol = [
{
name: 'method',
type: [String, Object],
required: true
}
required: true,
},
];
const RemoveInterceptorProtocol = AddInterceptorProtocol;
function mergeInterceptorHook(interceptors, interceptor) {
Object.keys(interceptor).forEach(hook => {
Object.keys(interceptor).forEach((hook) => {
if (isFunction(interceptor[hook])) {
interceptors[hook] = mergeHook(interceptors[hook], interceptor[hook]);
}
......@@ -186,7 +186,7 @@ function removeInterceptorHook(interceptors, interceptor) {
if (!interceptors || !interceptor) {
return;
}
Object.keys(interceptor).forEach(hook => {
Object.keys(interceptor).forEach((hook) => {
if (isFunction(interceptor[hook])) {
removeHook(interceptors[hook], interceptor[hook]);
}
......@@ -263,10 +263,10 @@ function handlePromise(promise) {
return promise;
}
return promise
.then(data => {
.then((data) => {
return [null, data];
})
.catch(err => [err]);
.catch((err) => [err]);
}
function shouldPromise(name) {
if (isContextApi(name) || isSyncApi(name) || isCallbackApi(name)) {
......@@ -278,7 +278,7 @@ function shouldPromise(name) {
if (!Promise.prototype.finally) {
Promise.prototype.finally = function (onfinally) {
const promise = this.constructor;
return this.then(value => promise.resolve(onfinally && onfinally()).then(() => value), reason => promise.resolve(onfinally && onfinally()).then(() => {
return this.then((value) => promise.resolve(onfinally && onfinally()).then(() => value), (reason) => promise.resolve(onfinally && onfinally()).then(() => {
throw reason;
}));
};
......@@ -299,7 +299,7 @@ function promisify(name, api) {
return wrapperReturnValue(name, handlePromise(new Promise((resolve, reject) => {
invokeApi(name, api, Object.assign({}, options, {
success: resolve,
fail: reject
fail: reject,
}), ...params);
})));
};
......@@ -413,25 +413,25 @@ function initUni(api, protocols) {
// event-api
// provider-api?
return promisify(key, wrapper(key, qa[key]));
}
},
};
return new Proxy({}, UniProxyHandlers);
}
function initGetProvider(providers) {
return function getProvider({ service, success, fail, complete }) {
return function getProvider({ service, success, fail, complete, }) {
let res;
if (providers[service]) {
res = {
errMsg: 'getProvider:ok',
service,
provider: providers[service]
provider: providers[service],
};
isFunction(success) && success(res);
}
else {
res = {
errMsg: 'getProvider:fail:服务[' + service + ']不存在'
errMsg: 'getProvider:fail:服务[' + service + ']不存在',
};
isFunction(fail) && fail(res);
}
......@@ -468,9 +468,9 @@ const previewImage = {
}
return {
indicator: false,
loop: false
loop: false,
};
}
},
};
function addSafeAreaInsets(fromRes, toRes) {
if (fromRes.safeArea) {
......@@ -479,12 +479,12 @@ function addSafeAreaInsets(fromRes, toRes) {
top: safeArea.top,
left: safeArea.left,
right: fromRes.windowWidth - safeArea.right,
bottom: fromRes.windowHeight - safeArea.bottom
bottom: fromRes.windowHeight - safeArea.bottom,
};
}
}
const getSystemInfo = {
returnValue: addSafeAreaInsets
returnValue: addSafeAreaInsets,
};
const getSystemInfoSync = getSystemInfo;
const redirectTo = {};
......@@ -493,7 +493,7 @@ const providers = {
oauth: [],
share: [],
payment: [],
push: []
push: [],
};
if (qa.canIUse('getAccountProvider')) {
providers.oauth.push(qa.getAccountProvider());
......
......@@ -50,7 +50,7 @@ const MP_METHODS = [
'createSelectorQuery',
'createIntersectionObserver',
'selectAllComponents',
'selectComponent'
'selectComponent',
];
function createEmitFn(oldEmit, ctx) {
return function emit(event, ...args) {
......@@ -77,7 +77,7 @@ function initBaseInstance(instance, options) {
{
instance.slots = {};
if (isArray(options.slots) && options.slots.length) {
options.slots.forEach(name => {
options.slots.forEach((name) => {
instance.slots[name] = true;
});
}
......@@ -88,7 +88,7 @@ function initBaseInstance(instance, options) {
function initComponentInstance(instance, options) {
initBaseInstance(instance, options);
const ctx = instance.ctx;
MP_METHODS.forEach(method => {
MP_METHODS.forEach((method) => {
ctx[method] = function (...args) {
const mpInstance = ctx.$scope;
if (mpInstance && mpInstance[method]) {
......@@ -106,7 +106,7 @@ function initComponentInstance(instance, options) {
}
function initMocks(instance, mpInstance, mocks) {
const ctx = instance.ctx;
mocks.forEach(mock => {
mocks.forEach((mock) => {
if (hasOwn(mpInstance, mock)) {
ctx[mock] = mpInstance[mock];
}
......@@ -125,12 +125,11 @@ const PAGE_HOOKS = [
'onReachBottom',
'onPullDownRefresh',
// 'onShareTimeline', // 右上角菜单,开发者手动注册
'onAddToFavorites'
// 'onShareAppMessage' // 右上角菜单,开发者手动注册
'onAddToFavorites',
];
function findHooks(vueOptions, hooks = new Set()) {
if (vueOptions) {
Object.keys(vueOptions).forEach(name => {
Object.keys(vueOptions).forEach((name) => {
if (name.indexOf('on') === 0 && isFunction(vueOptions[name])) {
hooks.add(name);
}
......@@ -138,7 +137,7 @@ function findHooks(vueOptions, hooks = new Set()) {
if (__VUE_OPTIONS_API__) {
const { extends: extendsOptions, mixins } = vueOptions;
if (mixins) {
mixins.forEach(mixin => findHooks(mixin, hooks));
mixins.forEach((mixin) => findHooks(mixin, hooks));
}
if (extendsOptions) {
findHooks(extendsOptions, hooks);
......@@ -156,10 +155,10 @@ function initHook(mpOptions, hook, excludes) {
}
const EXCLUDE_HOOKS = ['onReady'];
function initHooks(mpOptions, hooks, excludes = EXCLUDE_HOOKS) {
hooks.forEach(hook => initHook(mpOptions, hook, excludes));
hooks.forEach((hook) => initHook(mpOptions, hook, excludes));
}
function initUnknownHooks(mpOptions, vueOptions, excludes = EXCLUDE_HOOKS) {
findHooks(vueOptions).forEach(hook => initHook(mpOptions, hook, excludes));
findHooks(vueOptions).forEach((hook) => initHook(mpOptions, hook, excludes));
}
const HOOKS = [
......@@ -168,7 +167,7 @@ const HOOKS = [
'onError',
'onThemeChange',
'onPageNotFound',
'onUnhandledRejection'
'onUnhandledRejection',
];
function parseApp(instance, parseAppOptions) {
const internalInstance = instance.$;
......@@ -184,11 +183,11 @@ function parseApp(instance, parseAppOptions) {
initBaseInstance(internalInstance, {
mpType: 'app',
mpInstance: this,
slots: []
slots: [],
});
ctx.globalData = this.globalData;
instance.$callHook('onLaunch', options);
}
},
};
const vueOptions = instance.$.type;
initHooks(appOptions, HOOKS);
......@@ -212,7 +211,7 @@ const encode = encodeURIComponent;
function stringifyQuery(obj, encodeStr = encode) {
const res = obj
? Object.keys(obj)
.map(key => {
.map((key) => {
let val = obj[key];
if (typeof val === undefined || val === null) {
val = '';
......@@ -222,7 +221,7 @@ function stringifyQuery(obj, encodeStr = encode) {
}
return encodeStr(key) + '=' + encodeStr(val);
})
.filter(x => x.length > 0)
.filter((x) => x.length > 0)
.join('&')
: null;
return res ? `?${res}` : '';
......@@ -247,7 +246,7 @@ function initVueIds(vueIds, mpInstance) {
}
const EXTRAS = ['externalClasses'];
function initExtraOptions(miniProgramComponentOptions, vueOptions) {
EXTRAS.forEach(name => {
EXTRAS.forEach((name) => {
if (hasOwn(vueOptions, name)) {
miniProgramComponentOptions[name] = vueOptions[name];
}
......@@ -268,12 +267,12 @@ function initRefs(instance, mpInstance) {
get() {
const $refs = {};
const components = mpInstance.selectAllComponents('.vue-ref');
components.forEach(component => {
components.forEach((component) => {
const ref = component.dataset.ref;
$refs[ref] = component.$vm || component;
});
const forComponents = mpInstance.selectAllComponents('.vue-ref-in-for');
forComponents.forEach(component => {
forComponents.forEach((component) => {
const ref = component.dataset.ref;
if (!$refs[ref]) {
$refs[ref] = [];
......@@ -281,7 +280,7 @@ function initRefs(instance, mpInstance) {
$refs[ref].push(component.$vm || component);
});
return $refs;
}
},
});
}
......@@ -305,7 +304,7 @@ function initDefaultProps(isBehavior = false) {
if (!isBehavior) {
properties.vueId = {
type: String,
value: ''
value: '',
};
// 小程序不能直接定义 $slots 的 props,所以通过 vueSlots 转换到 $slots
properties.vueSlots = {
......@@ -317,9 +316,9 @@ function initDefaultProps(isBehavior = false) {
$slots[slotName] = true;
});
this.setData({
$slots
$slots,
});
}
},
};
}
return properties;
......@@ -331,14 +330,14 @@ function createProperty(key, prop) {
function initProps(mpComponentOptions, rawProps, isBehavior = false) {
const properties = initDefaultProps(isBehavior);
if (isArray(rawProps)) {
rawProps.forEach(key => {
rawProps.forEach((key) => {
properties[key] = createProperty(key, {
type: null
type: null,
});
});
}
else if (isPlainObject(rawProps)) {
Object.keys(rawProps).forEach(key => {
Object.keys(rawProps).forEach((key) => {
const opts = rawProps[key];
if (isPlainObject(opts)) {
// title:{type:String,default:''}
......@@ -350,14 +349,14 @@ function initProps(mpComponentOptions, rawProps, isBehavior = false) {
opts.type = parsePropType(key, type);
properties[key] = createProperty(key, {
type: PROP_TYPES.indexOf(type) !== -1 ? type : null,
value
value,
});
}
else {
// content:String
const type = parsePropType(key, opts);
properties[key] = createProperty(key, {
type: PROP_TYPES.indexOf(type) !== -1 ? type : null
type: PROP_TYPES.indexOf(type) !== -1 ? type : null,
});
}
});
......@@ -401,7 +400,7 @@ function initBehaviors(vueOptions, initBehavior) {
}
const behaviors = [];
if (isArray(vueBehaviors)) {
vueBehaviors.forEach(behavior => {
vueBehaviors.forEach((behavior) => {
behaviors.push(behavior.replace('uni://', `${__PLATFORM_PREFIX__}://`));
if (behavior === 'uni://form-field') {
if (isArray(vueProps)) {
......@@ -411,11 +410,11 @@ function initBehaviors(vueOptions, initBehavior) {
else {
vueProps.name = {
type: String,
default: ''
default: '',
};
vueProps.value = {
type: [String, Number, Boolean, Array, Object, Date],
default: ''
default: '',
};
}
}
......@@ -427,7 +426,7 @@ function initBehaviors(vueOptions, initBehavior) {
behaviors.push(initBehavior(behavior));
}
if (isArray(vueMixins)) {
vueMixins.forEach(vueMixin => {
vueMixins.forEach((vueMixin) => {
if (vueMixin.props) {
const behavior = {};
initProps(behavior, vueMixin.props, true);
......@@ -456,7 +455,7 @@ function getValue(obj, path) {
}
function getExtraValue(instance, dataPathsArray) {
let context = instance;
dataPathsArray.forEach(dataPathArray => {
dataPathsArray.forEach((dataPathArray) => {
const dataPath = dataPathArray[0];
const value = dataPathArray[2];
if (dataPath || typeof value !== 'undefined') {
......@@ -486,12 +485,12 @@ function getExtraValue(instance, dataPathsArray) {
}
else {
if (isArray(vFor)) {
context = vFor.find(vForItem => {
context = vFor.find((vForItem) => {
return getValue(vForItem, propPath) === value;
});
}
else if (isPlainObject(vFor)) {
context = Object.keys(vFor).find(vForKey => {
context = Object.keys(vFor).find((vForKey) => {
return getValue(vFor[vForKey], propPath) === value;
});
}
......@@ -581,7 +580,7 @@ function processEventArgs(instance, event, args = [], extra = [], isCustom, meth
}
const extraObj = processEventExtra(instance, extra, event);
const ret = [];
args.forEach(arg => {
args.forEach((arg) => {
if (arg === '$event') {
if (methodName === '__set_model' && !isCustom) {
// input v-model value
......@@ -693,11 +692,11 @@ function handleEvent(event) {
}
}
function parseComponent(vueOptions, { parse, mocks, isPage, initRelation, handleLink, initLifetimes }) {
function parseComponent(vueOptions, { parse, mocks, isPage, initRelation, handleLink, initLifetimes, }) {
vueOptions = vueOptions.default || vueOptions;
const options = {
multipleSlots: true,
addGlobalClass: true
addGlobalClass: true,
};
if (vueOptions.options) {
extend(options, vueOptions.options);
......@@ -714,12 +713,12 @@ function parseComponent(vueOptions, { parse, mocks, isPage, initRelation, handle
},
resize(size) {
this.$vm && this.$vm.$callHook('onPageResize', size);
}
},
},
methods: {
__l: handleLink,
__e: handleEvent
}
__e: handleEvent,
},
};
if (__VUE_OPTIONS_API__) {
applyOptions(mpComponentOptions, vueOptions, initBehavior);
......@@ -753,19 +752,19 @@ function $destroyComponent(instance) {
}
function parsePage(vueOptions, parseOptions) {
const { parse, mocks, isPage, initRelation, handleLink, initLifetimes } = parseOptions;
const { parse, mocks, isPage, initRelation, handleLink, initLifetimes, } = parseOptions;
const miniProgramPageOptions = parseComponent(vueOptions, {
mocks,
isPage,
initRelation,
handleLink,
initLifetimes
initLifetimes,
});
const methods = miniProgramPageOptions.methods;
methods.onLoad = function (query) {
this.options = query;
this.$page = {
fullPath: '/' + this.route + stringifyQuery(query)
fullPath: '/' + this.route + stringifyQuery(query),
};
return this.$vm && this.$vm.$callHook('onLoad', query);
};
......@@ -900,13 +899,13 @@ function initInjections(instance) {
}
}
function initLifetimes({ mocks, isPage, initRelation, vueOptions }) {
function initLifetimes({ mocks, isPage, initRelation, vueOptions, }) {
return {
attached() {
const properties = this.properties;
initVueIds(properties.vueId, this);
const relationOptions = {
vuePid: this._$vuePid
vuePid: this._$vuePid,
};
// 初始化 vue 实例
const mpInstance = this;
......@@ -916,7 +915,7 @@ function initLifetimes({ mocks, isPage, initRelation, vueOptions }) {
}
this.$vm = $createComponent({
type: vueOptions,
props: properties
props: properties,
}, {
mpType,
mpInstance,
......@@ -926,14 +925,14 @@ function initLifetimes({ mocks, isPage, initRelation, vueOptions }) {
initRefs(instance, mpInstance);
initMocks(instance, mpInstance, mocks);
initComponentInstance(instance, options);
}
},
});
// 处理父子关系
initRelation(this, relationOptions);
},
detached() {
this.$vm && $destroyComponent(this.$vm);
}
},
};
}
......@@ -962,12 +961,12 @@ function initLifetimes$1(lifetimesOptions) {
// 清理
const webviewId = this.__webviewId__;
webviewId &&
Object.keys(instances).forEach(key => {
Object.keys(instances).forEach((key) => {
if (key.indexOf(webviewId + '_') === 0) {
delete instances[key];
}
});
}
},
});
}
......@@ -983,10 +982,10 @@ function initRelation(mpInstance) {
instances[webviewId + '_' + nodeId] = mpInstance.$vm;
mpInstance.triggerEvent('__l', {
nodeId,
webviewId
webviewId,
});
}
function handleLink({ detail: { nodeId, webviewId } }) {
function handleLink({ detail: { nodeId, webviewId }, }) {
const vm = instances[webviewId + '_' + nodeId];
if (!vm) {
return;
......@@ -1026,7 +1025,7 @@ function handleLink({ detail: { nodeId, webviewId } }) {
else {
(parentVm._$childVues || (parentVm._$childVues = [])).push([
createdVm,
mountedVm
mountedVm,
]);
}
}
......
......@@ -2,5 +2,5 @@ export {
redirectTo,
previewImage,
getSystemInfo,
getSystemInfoSync
getSystemInfoSync,
} from '@dcloudio/uni-mp-core'
......@@ -4,7 +4,7 @@ const providers = {
oauth: [] as string[],
share: [],
payment: [] as string[],
push: []
push: [],
}
if (qa.canIUse('getAccountProvider')) {
......
import {
initCreateApp,
initCreatePage,
initCreateComponent
initCreateComponent,
} from '@dcloudio/uni-mp-core'
import '@dcloudio/uni-mp-polyfill'
......
......@@ -3,14 +3,14 @@ import { MPComponentInstance } from '@dcloudio/uni-mp-core'
import {
instances,
initProvide,
initInjections
initInjections,
} from '@dcloudio/uni-mp-toutiao'
export { mocks, isPage } from '@dcloudio/uni-mp-baidu'
export {
parseComponent as parse,
initComponentLifetimes as initLifetimes
initComponentLifetimes as initLifetimes,
} from '@dcloudio/uni-mp-toutiao'
interface RelationOptions {
......@@ -25,14 +25,14 @@ export function initRelation(mpInstance: MPComponentInstance) {
instances[webviewId + '_' + nodeId] = mpInstance.$vm
mpInstance.triggerEvent('__l', {
nodeId,
webviewId
webviewId,
})
}
export function handleLink(
this: MPComponentInstance,
{
detail: { nodeId, webviewId }
detail: { nodeId, webviewId },
}: {
detail: RelationOptions
}
......@@ -48,7 +48,7 @@ export function handleLink(
vm.$.parent = parentVm.$
const createdVm = function() {
const createdVm = function () {
if (__VUE_OPTIONS_API__) {
;(parentVm as any).$children.push(vm)
const parent = parentVm.$ as any
......@@ -60,7 +60,7 @@ export function handleLink(
}
vm.$callSyncHook('created')
}
const mountedVm = function() {
const mountedVm = function () {
// 处理当前 vm 子
if (vm._$childVues) {
vm._$childVues.forEach(([createdVm]: Function[]) => createdVm())
......@@ -77,7 +77,7 @@ export function handleLink(
} else {
;(parentVm._$childVues || (parentVm._$childVues = [])).push([
createdVm,
mountedVm
mountedVm,
])
}
}
......@@ -2,9 +2,9 @@ export {
mocks,
isPage,
initRelation,
handleLink
handleLink,
} from './parseComponentOptions'
export {
parsePage as parse,
initPageLifetimes as initLifetimes
initPageLifetimes as initLifetimes,
} from '@dcloudio/uni-mp-toutiao'
......@@ -35,7 +35,7 @@ const encode = encodeURIComponent;
function stringifyQuery(obj, encodeStr = encode) {
const res = obj
? Object.keys(obj)
.map(key => {
.map((key) => {
let val = obj[key];
if (typeof val === undefined || val === null) {
val = '';
......@@ -45,7 +45,7 @@ function stringifyQuery(obj, encodeStr = encode) {
}
return encodeStr(key) + '=' + encodeStr(val);
})
.filter(x => x.length > 0)
.filter((x) => x.length > 0)
.join('&')
: null;
return res ? `?${res}` : '';
......@@ -92,7 +92,7 @@ const BUILT_IN_TAGS = [
'uni-textarea',
'uni-video',
'uni-view',
'uni-web-view'
'uni-web-view',
];
const TAGS = [
'uni-app',
......@@ -112,7 +112,7 @@ const TAGS = [
'uni-modal',
'uni-toast',
'uni-resize-sensor',
'uni-shadow-root'
'uni-shadow-root',
];
function isBuiltInComponent(tag) {
return BUILT_IN_TAGS.indexOf('uni-' + tag) !== -1;
......
......@@ -31,7 +31,7 @@ const encode = encodeURIComponent;
function stringifyQuery(obj, encodeStr = encode) {
const res = obj
? Object.keys(obj)
.map(key => {
.map((key) => {
let val = obj[key];
if (typeof val === undefined || val === null) {
val = '';
......@@ -41,7 +41,7 @@ function stringifyQuery(obj, encodeStr = encode) {
}
return encodeStr(key) + '=' + encodeStr(val);
})
.filter(x => x.length > 0)
.filter((x) => x.length > 0)
.join('&')
: null;
return res ? `?${res}` : '';
......@@ -88,7 +88,7 @@ const BUILT_IN_TAGS = [
'uni-textarea',
'uni-video',
'uni-view',
'uni-web-view'
'uni-web-view',
];
const TAGS = [
'uni-app',
......@@ -108,7 +108,7 @@ const TAGS = [
'uni-modal',
'uni-toast',
'uni-resize-sensor',
'uni-shadow-root'
'uni-shadow-root',
];
function isBuiltInComponent(tag) {
return BUILT_IN_TAGS.indexOf('uni-' + tag) !== -1;
......
export function debounce(fn: Function, delay: number) {
let timeout: any
const newFn = function(this: any) {
const newFn = function (this: any) {
clearTimeout(timeout)
const timerFn = () => fn.apply(this, arguments)
timeout = setTimeout(timerFn, delay)
}
newFn.cancel = function() {
newFn.cancel = function () {
clearTimeout(timeout)
}
return newFn
......
......@@ -4,7 +4,7 @@ const encode = encodeURIComponent
export function stringifyQuery(obj?: Record<string, any>, encodeStr = encode) {
const res = obj
? Object.keys(obj)
.map(key => {
.map((key) => {
let val = obj[key]
if (typeof val === undefined || val === null) {
val = ''
......@@ -13,7 +13,7 @@ export function stringifyQuery(obj?: Record<string, any>, encodeStr = encode) {
}
return encodeStr(key) + '=' + encodeStr(val)
})
.filter(x => x.length > 0)
.filter((x) => x.length > 0)
.join('&')
: null
return res ? `?${res}` : ''
......
......@@ -41,7 +41,7 @@ export const BUILT_IN_TAGS = [
'uni-textarea',
'uni-video',
'uni-view',
'uni-web-view'
'uni-web-view',
]
export const TAGS = [
......@@ -62,7 +62,7 @@ export const TAGS = [
'uni-modal',
'uni-toast',
'uni-resize-sensor',
'uni-shadow-root'
'uni-shadow-root',
]
export function isBuiltInComponent(tag: string) {
......
......@@ -32,7 +32,7 @@ export const enum UniLifecycleHooks {
ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED = 'onNavigationBarSearchInputClicked',
ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED = 'onNavigationBarSearchInputChanged',
ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED = 'onNavigationBarSearchInputConfirmed',
ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED = 'onNavigationBarSearchInputFocusChanged'
ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED = 'onNavigationBarSearchInputFocusChanged',
}
export const createHook = <T extends Function = () => any>(
......
......@@ -3,7 +3,7 @@ import { isFunction } from '@vue/shared'
import {
ComponentOptions,
ComponentInternalInstance,
ComponentPublicInstance
ComponentPublicInstance,
} from '@vue/runtime-core'
// @ts-ignore
import { injectHook } from 'vue'
......@@ -13,7 +13,7 @@ export function applyOptions(
instance: ComponentInternalInstance,
publicThis: ComponentPublicInstance
) {
Object.keys(options).forEach(name => {
Object.keys(options).forEach((name) => {
if (name.indexOf('on') === 0) {
const hook = options[name]
if (isFunction(hook)) {
......
......@@ -25,10 +25,15 @@
"debug": "^4.3.1",
"estree-walker": "^2.0.1",
"fs-extra": "^9.0.1",
"magic-string": "^0.25.7"
"jsonc-parser": "^3.0.0",
"magic-string": "^0.25.7",
"slash": "^3.0.0"
},
"peerDependencies": {
"@dcloudio/uni-cli-shared": "^3.0.0",
"vite": "^2.0.0-beta.4"
"vite": "^2.0.0-beta.31"
},
"devDependencies": {
"@types/sass": "^1.16.0"
}
}
......@@ -17,5 +17,5 @@ export const buildPluginCopy: Plugin = {
// }
// }
// }, 100)
}
},
}
......@@ -5,7 +5,7 @@ export const buildPluginDynamicImport: Plugin = {
renderDynamicImport() {
return {
left: 'dynamicImportPolyfill(',
right: ')'
right: ')',
}
}
},
}
......@@ -9,13 +9,13 @@ import {
Identifier,
MemberExpression,
MethodDefinition,
ExportSpecifier
ExportSpecifier,
} from 'estree'
import {
attachScopes,
createFilter,
makeLegalIdentifier
makeLegalIdentifier,
} from '@rollup/pluginutils'
import { walk } from 'estree-walker'
......@@ -107,7 +107,7 @@ function inject(options: InjectOptions) {
const modulesMap = new Map<string, string | [string, string]>()
const namespaceModulesMap = new Map<string, string | [string, string]>()
Object.keys(modules).forEach(name => {
Object.keys(modules).forEach((name) => {
if (name.endsWith('.')) {
namespaceModulesMap.set(name, modules[name])
}
......@@ -122,9 +122,7 @@ function inject(options: InjectOptions) {
}
const firstpass = new RegExp(
`(?:${Array.from(modulesMap.keys())
.map(escape)
.join('|')})`,
`(?:${Array.from(modulesMap.keys()).map(escape).join('|')})`,
'g'
)
const sourceMap = options.sourceMap !== false
......@@ -142,7 +140,7 @@ function inject(options: InjectOptions) {
} catch (err) {
this.warn({
code: 'PARSE_ERROR',
message: `plugin-inject: failed to parse ${id}. Consider restricting the plugin to particular files via options.include`
message: `plugin-inject: failed to parse ${id}. Consider restricting the plugin to particular files via options.include`,
})
}
if (!ast) {
......@@ -150,9 +148,9 @@ function inject(options: InjectOptions) {
}
const imports = new Set()
ast.body.forEach(node => {
ast.body.forEach((node) => {
if (node.type === 'ImportDeclaration') {
node.specifiers.forEach(specifier => {
node.specifiers.forEach((specifier) => {
imports.add(specifier.local.name)
})
}
......@@ -205,7 +203,7 @@ function inject(options: InjectOptions) {
(node as AcornNode).end,
importLocalName,
{
storeName: true
storeName: true,
}
)
}
......@@ -246,14 +244,14 @@ function inject(options: InjectOptions) {
if ((node as any).scope) {
scope = scope.parent
}
}
},
})
if (newImports.size === 0) {
return {
code,
ast,
map: sourceMap ? magicString.generateMap({ hires: true }) : null
map: sourceMap ? magicString.generateMap({ hires: true }) : null,
}
}
const importBlock = Array.from(newImports.values()).join('\n\n')
......@@ -262,9 +260,9 @@ function inject(options: InjectOptions) {
return {
code: magicString.toString(),
map: sourceMap ? magicString.generateMap({ hires: true }) : null
map: sourceMap ? magicString.generateMap({ hires: true }) : null,
}
}
},
} as Plugin
}
......@@ -274,5 +272,5 @@ export const buildPluginInject: Plugin = inject({
'uni.': '@dcloudio/uni-h5',
getApp: ['@dcloudio/uni-h5', 'getApp'],
getCurrentPages: ['@dcloudio/uni-h5', 'getCurrentPages'],
UniServiceJSBridge: ['@dcloudio/uni-h5', 'UniServiceJSBridge']
UniServiceJSBridge: ['@dcloudio/uni-h5', 'UniServiceJSBridge'],
})
import { Plugin } from 'rollup'
import { getRoot, isMainJs, wrapperMainCode } from '../utils'
let transformed = false
export const buildPluginMainJs: Plugin = {
name: 'uni:main',
async transform(code: string, id: string) {
if (!transformed && isMainJs(id)) {
code = wrapperMainCode(code, getRoot(id))
transformed = true
}
return { code }
}
}
import fs from 'fs'
import { Plugin } from 'rollup'
import { parsePagesJson } from '../utils'
let transformed = false
const pagesJsonName = 'pages.json'
const pagesJsonAliasName = pagesJsonName + '.js'
export const buildPluginPagesJson: Plugin = {
name: 'uni:pages',
resolveId(source) {
if (!transformed && source.endsWith(pagesJsonName)) {
transformed = true
return source.replace(pagesJsonName, pagesJsonAliasName)
}
return null
},
load(id) {
if (id.endsWith(pagesJsonAliasName)) {
return parsePagesJson(
fs
.readFileSync(id.replace(pagesJsonAliasName, pagesJsonName))
.toString()
)
}
return null
}
}
export * from './buildPluginCopy'
export * from './buildPluginInject'
export * from './buildPluginMainJs'
export * from './buildPluginPagesJson'
export * from './buildPluginDynamicImport'
import { UserConfig } from 'vite'
import { VitePluginUniResolvedOptions } from '..'
export function createAlias(
_options: VitePluginUniResolvedOptions
): UserConfig['alias'] {
return {
vue: '@dcloudio/uni-h5-vue',
}
}
import { UserConfig } from 'vite'
import { VitePluginUniResolvedOptions } from '..'
export function createCss(
_options: VitePluginUniResolvedOptions
): UserConfig['css'] {
return {
preprocessorOptions: {
scss: {},
},
}
}
import { UserConfig } from 'vite'
import { VitePluginUniResolvedOptions } from '..'
export function createDefine(
_options: VitePluginUniResolvedOptions
): UserConfig['define'] {
return {
__UNI_WX_API__: true,
__UNI_WXS_API__: true,
__UNI_ROUTER_MODE__: JSON.stringify('hash'),
}
}
import { Plugin } from 'vite'
import { VitePluginUniResolvedOptions } from '..'
import { createAlias } from './alias'
import { createDefine } from './define'
import { createServer } from './server'
import { createOptimizeDeps } from './optimizeDeps'
import { createCss } from './css'
export function createConfig(
options: VitePluginUniResolvedOptions
): Plugin['config'] {
return () => {
return {
define: createDefine(options),
alias: createAlias(options),
optimizeDeps: createOptimizeDeps(options),
server: createServer(options),
css: createCss(options),
}
}
}
import { UserConfig } from 'vite'
import { VitePluginUniResolvedOptions } from '..'
export function createOptimizeDeps(
_options: VitePluginUniResolvedOptions
): UserConfig['optimizeDeps'] {
return {
exclude: [
'vue',
'vue-router',
'@dcloudio/uni-h5',
'@dcloudio/uni-h5-vue',
'@dcloudio/uni-shared',
],
}
}
import { UserConfig } from 'vite'
import { VitePluginUniResolvedOptions } from '..'
export function createServer(
_options: VitePluginUniResolvedOptions
): UserConfig['server'] {
return {
watch: {
ignored: ['**/node_modules/**', '**/.git/**', '**/uniCloud**'],
},
}
}
import path from 'path'
import { Plugin, UserConfig } from 'vite'
import { VitePluginUniResolvedOptions } from '..'
import { resolvePlugins } from './plugins'
export function createConfigResolved(options: VitePluginUniResolvedOptions) {
return ((config) => {
options.root = config.root
options.inputDir = path.resolve(config.root, 'src')
resolvePlugins((config as unknown) as UserConfig, options)
}) as Plugin['configResolved']
}
/**
* https://github.com/rollup/plugins/blob/master/packages/json/src/index.js
*
* This source code is licensed under the MIT license found in the
* LICENSE file at
* https://github.com/rollup/plugins/blob/master/LICENSE
*/
import { createFilter, dataToEsm } from '@rollup/pluginutils'
import { FilterPattern } from '@rollup/pluginutils'
import { Plugin } from 'rollup'
export interface RollupJsonOptions {
/**
* All JSON files will be parsed by default,
* but you can also specifically include files
*/
include?: FilterPattern
/**
* All JSON files will be parsed by default,
* but you can also specifically exclude files
*/
exclude?: FilterPattern
/**
* For tree-shaking, properties will be declared as variables, using
* either `var` or `const`.
* @default false
*/
preferConst?: boolean
/**
* Specify indentation for the generated default export
* @default '\t'
*/
indent?: string
/**
* Ignores indent and generates the smallest code
* @default false
*/
compact?: boolean
/**
* Generate a named export for every property of the JSON object
* @default true
*/
namedExports?: boolean
}
// Custom json filter for vite
const jsonExtRE = new RegExp(`\\.json($|\\?)`)
export function jsonPlugin(options: RollupJsonOptions = {}): Plugin {
const filter = createFilter(options.include, options.exclude)
const indent = 'indent' in options ? options.indent : '\t'
return {
name: 'vite:json',
transform(json, id) {
if (!jsonExtRE.test(id) || !filter(id)) return null
try {
const parsed = JSON.parse(json)
return {
code: dataToEsm(parsed, {
preferConst: options.preferConst,
compact: options.compact,
namedExports: options.namedExports,
indent,
}),
map: { mappings: '' },
}
} catch (e) {
const errorMessageList = /[\d]/.exec(e.message)
const position = errorMessageList && parseInt(errorMessageList[0], 10)
const msg = position
? `, invalid JSON syntax found at line ${position}`
: `.`
this.error(`Failed to parse JSON file` + msg, e.idx)
}
},
}
}
import { FilterPattern } from '@rollup/pluginutils'
import debug from 'debug'
import { UserConfig } from 'vite'
import { VitePluginUniResolvedOptions } from '../..'
import { uniPrePlugin } from './pre'
import { uniJsonPlugin } from './json'
import { uniPreCssPlugin } from './preCss'
import { uniPostVuePlugin } from './postVue'
const debugPlugin = debug('uni:plugin')
export interface UniPluginFilterOptions extends VitePluginUniResolvedOptions {
include?: FilterPattern
exclude?: FilterPattern
}
const UNI_H5_RE = /@dcloudio\/uni-h5/
const uniPrePluginOptions: Partial<UniPluginFilterOptions> = {
exclude: [
/pages\.json\.js$/,
/vite\/dist\/client\/client\.js$/,
/vue&type=/,
UNI_H5_RE,
],
}
const uniPreCssPluginOptions: Partial<UniPluginFilterOptions> = {
exclude: [UNI_H5_RE],
}
const uniPostVuePluginOptions: Partial<UniPluginFilterOptions> = {
exclude: [UNI_H5_RE],
}
export function resolvePlugins(
config: UserConfig,
options: VitePluginUniResolvedOptions
) {
const jsonIndex = config.plugins!.findIndex(
(plugin) => (plugin as Plugin).name === 'vite:json'
)
config.plugins!.splice(jsonIndex, 1, uniJsonPlugin(options))
const cssIndex = config.plugins!.findIndex(
(plugin) => (plugin as Plugin).name === 'vite:css'
)
config.plugins!.splice(
cssIndex + 1,
0,
uniPreCssPlugin(Object.assign(uniPreCssPluginOptions, options))
)
config.plugins!.unshift(
uniPrePlugin(Object.assign(uniPrePluginOptions, options))
)
if (process.env.DEBUG) {
const vueIndex = config.plugins!.findIndex(
(plugin) => (plugin as Plugin).name === 'vite:vue'
)
config.plugins!.splice(
vueIndex + 1,
0,
uniPostVuePlugin(Object.assign(uniPostVuePluginOptions, options))
)
debugPlugin(config.plugins!.map((p) => (p as Plugin).name))
}
}
import path from 'path'
import slash from 'slash'
import { Plugin } from 'vite'
import { parse } from 'jsonc-parser'
import { VitePluginUniResolvedOptions } from '../..'
import { jsonPlugin } from './baseJson'
export function uniJsonPlugin(options: VitePluginUniResolvedOptions): Plugin {
const vitePluginJson = jsonPlugin({ preferConst: true, namedExports: true })
const pagesJsonPath = slash(path.resolve(options.inputDir, 'pages.json'))
return {
name: 'vite:uni-json',
transform(code, id) {
if (id.startsWith(pagesJsonPath)) {
code = JSON.stringify(parse(code))
}
return vitePluginJson.transform!.call(this, code, id)
},
}
}
import debug from 'debug'
import qs from 'querystring'
import { Plugin } from 'vite'
import { createFilter } from '@rollup/pluginutils'
import { UniPluginFilterOptions } from '.'
const debugPostVue = debug('uni:post-vue')
export function uniPostVuePlugin(options: UniPluginFilterOptions): Plugin {
const filter = createFilter(options.include, options.exclude)
return {
name: 'vite:uni-post-vue',
transform(code, id) {
const { filename, query } = parseVueRequest(id)
if (!query.vue && !filter(filename)) {
return
}
if (query.vue) {
debugPostVue(id)
// TODO
// 目前 vite 在 process.env.DEBUG 时,会追加 sourcemap 对象到文件中,如果 source 中包含/**/注释,会报错
// 暂时移除此类请求的 sourcemap
;(this as any).sourcemapChain.length = 0
return code
}
},
}
}
interface VueQuery {
vue?: boolean
src?: boolean
type?: 'script' | 'template' | 'style' | 'custom'
index?: number
lang?: string
}
function parseVueRequest(id: string) {
const [filename, rawQuery] = id.split(`?`, 2)
const query = qs.parse(rawQuery) as VueQuery
if (query.vue != null) {
query.vue = true
}
if (query.src != null) {
query.src = true
}
if (query.index != null) {
query.index = Number(query.index)
}
return {
filename,
query,
}
}
import path from 'path'
import debug from 'debug'
import { Plugin } from 'vite'
import { createFilter } from '@rollup/pluginutils'
import { UniPluginFilterOptions } from '.'
const { preJs, preHtml } = require('@dcloudio/uni-cli-shared')
const debugPreJs = debug('uni:pre-js')
const debugPreHtml = debug('uni:pre-html')
const debugPreIgnore = debug('uni:pre-ignore')
const debugPreJsTry = debug('uni:pre-js-try')
const PRE_JS_EXTNAME = ['.js', '.ts', '.json', '.css', '.vue', '.nvue']
const PRE_HTML_EXTNAME = ['.vue', '.nvue']
export function uniPrePlugin(options: UniPluginFilterOptions): Plugin {
const filter = createFilter(options.include, options.exclude)
return {
name: 'vite:uni-pre',
transform(code, id) {
if (!filter(id)) {
debugPreIgnore(id)
return code
}
const extname = path.extname(id)
const isHtml = PRE_HTML_EXTNAME.includes(extname)
const isJs = PRE_JS_EXTNAME.includes(extname)
const isPre = isHtml || isJs
const hasEndif = isPre && code.includes('#endif')
if (isPre && !hasEndif) {
debugPreJsTry(id)
}
if (isHtml && hasEndif) {
code = preHtml(code)
debugPreHtml(id)
}
if (isJs && hasEndif) {
code = preJs(code)
debugPreJs(id)
}
return code
},
}
}
import debug from 'debug'
import { Plugin } from 'vite'
import { createFilter } from '@rollup/pluginutils'
import { UniPluginFilterOptions } from '.'
const { preJs } = require('@dcloudio/uni-cli-shared')
const debugPre = debug('uni:pre-css')
const debugPreIgnore = debug('uni:pre-css-ignore')
const debugPreTry = debug('uni:pre-css-try')
const cssLangs = `\\.(css|less|sass|scss|styl|stylus|postcss)($|\\?)`
const cssLangRE = new RegExp(cssLangs)
export function uniPreCssPlugin(options: UniPluginFilterOptions): Plugin {
const filter = createFilter(options.include, options.exclude)
return {
name: 'vite:uni-pre-css',
transform(code, id) {
if (!filter(id)) {
debugPreIgnore(id)
return code
}
if (!cssLangRE.test(id)) {
return
}
if (!code.includes('#endif')) {
debugPreTry(id)
return
}
debugPre(id)
return preJs(code)
},
}
}
import path from 'path'
import debug from 'debug'
import { ViteDevServer } from 'vite'
import { VitePluginUniResolvedOptions } from '..'
const { initEasycom } = require('@dcloudio/uni-cli-shared')
const debugEasycom = debug('uni:easycom')
export function initEasycoms(inputDir: string) {
const dirs = ['components'].map((dir) => path.resolve(inputDir, dir))
const easycomOptions = { dirs, rootDir: inputDir }
initEasycom(easycomOptions)
debugEasycom(easycomOptions)
return {
dirs,
refresh() {
initEasycom(easycomOptions)
},
}
}
export const serveEasycom = (
server: ViteDevServer,
options: VitePluginUniResolvedOptions
) => {
const { dirs, refresh } = initEasycoms(options.inputDir)
server.watcher.on('all', (eventName, path) => {
if (!['add', 'unlink'].includes(eventName)) {
return
}
if (dirs.find((dir) => path.startsWith(dir))) {
refresh()
}
})
}
import { Plugin } from 'vite'
import { VitePluginUniResolvedOptions } from '..'
import { serveEasycom } from './easycom'
export function createConfigureServer(
options: VitePluginUniResolvedOptions
): Plugin['configureServer'] {
return function (server) {
options.devServer = server
serveEasycom(server, options)
}
}
import { Plugin } from 'vite'
import path from 'path'
import { vueCompilerOptions } from '@dcloudio/uni-cli-shared'
import { Plugin, ViteDevServer } from 'vite'
import {
serverPluginEnv,
serverPluginMainJs,
serverPluginPagesJson,
} from './server'
import { createLoad } from './load'
import { createConfig } from './config'
import { createResolveId } from './resolveId'
import { createConfigResolved } from './configResolved'
import { createConfigureServer } from './configureServer'
import {
buildPluginCopy,
buildPluginInject,
buildPluginMainJs,
buildPluginPagesJson,
buildPluginDynamicImport,
} from './build'
import { initEasycoms, dynamicImportCode, transform } from './utils'
const VUES = ['vue', 'vue.js', './vue.js', 'dist/vue.runtime.esm-bundler.js']
const plugins = [
buildPluginMainJs,
buildPluginPagesJson,
buildPluginInject,
buildPluginCopy,
]
if (dynamicImportCode) {
plugins.push(buildPluginDynamicImport)
const { vueCompilerOptions } = require('@dcloudio/uni-cli-shared')
export interface VitePluginUniOptions {
inputDir?: string
}
const plugin: Plugin = {
configureServer: [serverPluginEnv, serverPluginMainJs, serverPluginPagesJson],
rollupInputOptions: {
plugins,
},
vueCompilerOptions,
configureBuild({ root }) {
initEasycoms(root)
},
export interface VitePluginUniResolvedOptions extends VitePluginUniOptions {
root: string
inputDir: string
devServer?: ViteDevServer
}
// TODO 等待 vite 升级支持以下配置
Object.assign(plugin, {
optimizeDeps: {
exclude: [
'vue',
'vue-router',
'@dcloudio/uni-h5',
'@dcloudio/uni-h5-vue',
'@dcloudio/uni-shared',
],
},
chokidarWatchOptions: {
ignored: [
'**/node_modules/**',
'**/.git/**',
'**/uniCloud-aliyun/**',
'**/uniCloud-tcb/**',
],
},
})
interface Options {}
export default function uniPlugin(_rawOptions: Options = {}): Plugin {
export const uniVueCompilerOptions = vueCompilerOptions
export default function uniPlugin(
rawOptions: VitePluginUniOptions = {}
): Plugin {
const options: VitePluginUniResolvedOptions = {
...rawOptions,
root: process.cwd(),
inputDir: rawOptions.inputDir || path.resolve(process.cwd(), 'src'),
}
return {
name: 'vite:uni',
config(config) {
config.define = {
__UNI_WX_API__: true,
__UNI_WXS_API__: true,
__UNI_ROUTER_MODE__: JSON.stringify('hash'),
...config.define,
}
},
async resolveId(id) {
if (VUES.includes(id)) {
return '@dcloudio/uni-h5-vue'
}
if (id.startsWith('@/')) {
return id.replace('@/', '/src/')
}
},
transform,
configureServer() {},
config: createConfig(options),
configResolved: createConfigResolved(options),
configureServer: createConfigureServer(options),
resolveId: createResolveId(options),
load: createLoad(options),
}
}
import debug from 'debug'
import { Plugin } from 'vite'
import { VitePluginUniResolvedOptions } from '..'
import { main } from './main'
import { pages } from './pages'
const debugLoad = debug('uni:load')
const loads = [main, pages]
export function createLoad(
options: VitePluginUniResolvedOptions
): Plugin['load'] {
return (id) => {
const item = loads.find((item) => item.test(id, options.inputDir))
if (item) {
debugLoad(id)
return item.load(id, options)
}
}
}
import fs from 'fs'
import path from 'path'
import slash from 'slash'
import { VitePluginUniResolvedOptions } from '..'
let mainJsPath: string
let mainTsPath: string
let pagesJsPath: string
export const main = {
test(id: string, inputDir: string) {
if (!mainJsPath) {
const mainPath = slash(path.resolve(inputDir, 'main'))
mainJsPath = mainPath + '.js'
mainTsPath = mainPath + '.ts'
}
return id === mainJsPath || id === mainTsPath
},
load(filename: string, options: VitePluginUniResolvedOptions) {
if (!pagesJsPath) {
pagesJsPath = slash(path.resolve(options.inputDir, 'pages.json.js'))
}
return `import '${pagesJsPath}';
${fs.readFileSync(filename, 'utf-8').toString()}
`
},
}
import fs from 'fs'
import path from 'path'
import slash from 'slash'
import { camelize, capitalize } from '@vue/shared'
import { VitePluginUniResolvedOptions } from '..'
const { parseJson } = require('@dcloudio/uni-cli-shared')
import { parseJson } from '@dcloudio/uni-cli-shared'
export const pages = {
test(id: string, _inputDir: string) {
return id.endsWith('pages.json.js')
},
load(filename: string, options: VitePluginUniResolvedOptions) {
return (
(options.devServer ? registerGlobalCode : '') +
parsePagesJson(
fs.readFileSync(filename.substr(0, filename.length - 3), 'utf-8')
)
)
},
}
interface PageOptions {
path: string
......@@ -31,6 +46,38 @@ interface PageRouteOptions {
}
}
function parsePagesJson(jsonStr: string) {
const pagesJson = formatPagesJson(jsonStr)
const definePagesCode = generatePagesDefineCode(pagesJson)
const uniRoutesCode = generateRoutes(pagesJson).join(',')
const uniConfigCode = generateConfig(pagesJson)
return `
import {
defineAsyncComponent,
resolveComponent,
createVNode,
withCtx,
openBlock,
createBlock
} from 'vue'
import {
PageComponent
} from '@dcloudio/uni-h5'
${definePagesCode}
window.__uniConfig=${uniConfigCode}
window.__uniRoutes=[${uniRoutesCode}]
`
}
const registerGlobalCode = `import {uni,getCurrentPages,getApp,UniServiceJSBridge,UniViewJSBridge} from '@dcloudio/uni-h5'
window.getApp = getApp
window.getCurrentPages = getCurrentPages
window.uni = window.__GLOBAL__ = uni
window.UniViewJSBridge = UniViewJSBridge
window.UniServiceJSBridge = UniServiceJSBridge
`
function formatPages(pagesJson: Record<string, any>, jsonStr: string) {
if (!Array.isArray(pagesJson.pages)) {
pagesJson.pages = []
......@@ -87,7 +134,7 @@ function formatPagesJson(jsonStr: string) {
let pagesJson: Record<string, any> = {
pages: [],
}
//TODO preprocess
// preprocess
try {
pagesJson = parseJson(jsonStr, true)
} catch (e) {
......@@ -156,16 +203,16 @@ function formatPagesRoute(pagesJson: Record<string, any>): PageRouteOptions[] {
function generatePageRoute({ name, path, props, meta }: PageRouteOptions) {
return `{
path:'/${meta.isEntry ? '' : path}',
component:{
render() {
return (openBlock(), createBlock(PageComponent, Object.assign({}, __uniConfig.globalStyle, ${JSON.stringify(
props
)}), {page: withCtx(() => [createVNode(${name})]), _: 1}, 16))
}
},
meta: ${JSON.stringify(meta)}
}`
path:'/${meta.isEntry ? '' : path}',
component:{
render() {
return (openBlock(), createBlock(PageComponent, Object.assign({}, __uniConfig.globalStyle, ${JSON.stringify(
props
)}), {page: withCtx(() => [createVNode(${name})]), _: 1}, 16))
}
},
meta: ${JSON.stringify(meta)}
}`
}
function generatePagesRoute(pagesRouteOptions: PageRouteOptions[]) {
......@@ -186,27 +233,3 @@ function generateConfig(pagesJson: Record<string, any>) {
pagesJson.router = {} // TODO
return JSON.stringify(pagesJson)
}
export function parsePagesJson(jsonStr: string) {
const pagesJson = formatPagesJson(jsonStr)
const definePagesCode = generatePagesDefineCode(pagesJson)
const uniRoutesCode = generateRoutes(pagesJson).join(',')
const uniConfigCode = generateConfig(pagesJson)
return `
import {
defineAsyncComponent,
resolveComponent,
createVNode,
withCtx,
openBlock,
createBlock
} from 'vue'
import {
PageComponent
} from '@dcloudio/uni-h5'
${definePagesCode}
window.__uniConfig=${uniConfigCode}
window.__uniRoutes=[${uniRoutesCode}]
`
}
import path from 'path'
import debug from 'debug'
import { Plugin } from 'vite'
import { VitePluginUniResolvedOptions } from '.'
const debugResolve = debug('uni:resolve')
const VUES = ['vue', 'vue.js', './vue.js', 'dist/vue.runtime.esm-bundler.js']
let pagesJsonJsPath: string
export function createResolveId(
options: VitePluginUniResolvedOptions
): Plugin['resolveId'] {
return function (id) {
if (id.endsWith('pages.json.js')) {
if (!pagesJsonJsPath) {
pagesJsonJsPath = path.resolve(options.inputDir, 'pages.json.js')
}
debugResolve(id)
return pagesJsonJsPath
}
if (VUES.includes(id)) {
debugResolve(id)
return '@dcloudio/uni-h5-vue'
}
if (id.startsWith('@/')) {
debugResolve(id)
return id.replace('@/', '/src/')
}
}
}
export * from './serveEasycom'
export * from './serveMainJs'
export * from './servePagesJson'
import { ViteDevServer } from 'vite'
import { initEasycoms } from '../utils'
export const serveEasycom = (server: ViteDevServer) => {
const { dirs, refresh } = initEasycoms(server.config.root)
server.watcher.on('all', (eventName, path) => {
if (!['add', 'unlink'].includes(eventName)) {
return
}
if (dirs.find((dir) => path.startsWith(dir))) {
refresh()
}
})
}
import path from 'path'
import { readBody, ViteDevServer } from 'vite'
import { getRoot, isMainJs, wrapperMainCode } from '../utils'
export const serveMainJs = (server: ViteDevServer) => {
server.app.use(async (ctx, next) => {
await next()
if (isMainJs(ctx.path)) {
const body = await readBody(ctx.body)
ctx.body = wrapperMainCode(body!, getRoot(path.resolve(root, ctx.path)))
}
})
}
import { ViteDevServer } from 'vite'
import { parsePagesJson } from '../utils'
const uniCode = `import {uni,getCurrentPages,getApp,UniServiceJSBridge,UniViewJSBridge} from '@dcloudio/uni-h5'
window.getApp = getApp
window.getCurrentPages = getCurrentPages
window.uni = window.__GLOBAL__ = uni
window.UniViewJSBridge = UniViewJSBridge
window.UniServiceJSBridge = UniServiceJSBridge
`
export const servePagesJson = (server: ViteDevServer) => {
server.app.use(async (ctx, next) => {
const isPagesJson = ctx.path.endsWith('pages.json')
if (isPagesJson) {
//skip serverPluginJson
delete ctx.query.import
}
await next()
if (isPagesJson) {
const body = await readBody(ctx.body)
ctx.type = 'js'
ctx.body = body ? uniCode + parsePagesJson(body) : ''
}
})
}
let dynamicImportPolyfill = false
try {
/* eslint-disable no-restricted-globals */
require.resolve('dynamic-import-polyfill')
dynamicImportPolyfill = true
} catch (e) {}
export const dynamicImportCode = dynamicImportPolyfill
? `import dynamicImportPolyfill from 'dynamic-import-polyfill'
dynamicImportPolyfill.initialize({
importFunctionName: 'dynamicImportPolyfill'
})
`
: ''
import path from 'path'
import { initEasycom } from '@dcloudio/uni-cli-shared'
export function initEasycoms(root: string) {
const rootDir = path.resolve(root, 'src')
const dirs = ['components'].map((dir) => path.resolve(rootDir, dir))
const easycomOptions = { dirs, rootDir: rootDir }
initEasycom(easycomOptions)
return {
dirs,
refresh() {
initEasycom(easycomOptions)
},
}
}
export * from './mainJs'
export * from './easycom'
export * from './transform'
export * from './pagesJson'
export * from './dynamicImport'
import path from 'path'
import slash from 'slash'
import { dynamicImportCode } from './dynamicImport'
const MAIN_RE = /main.[jt]s/
export function isMainJs(path: string) {
return MAIN_RE.test(path)
}
export function getRoot(mainJsPath: string) {
return mainJsPath.replace(MAIN_RE, '')
}
export function wrapperMainCode(code: string, root: string) {
return `${dynamicImportCode}
import '${slash(path.resolve(root, 'pages.json'))}'
${code}
`
}
import path from 'path'
import debug from 'debug'
import { TransformHook } from 'rollup'
const debugPre = debug('uni:pre')
const extensions = ['.vue', '.nvue', '.js', '.json', '.css']
export const transform: TransformHook = (code, id) => {
const extname = path.extname(id)
if (!extensions.includes(extname)) {
return
}
// TODO
debugPre(id)
return code
}
......@@ -46,7 +46,7 @@ async function build(target) {
}
const bundler = pkg.buildOptions && pkg.buildOptions.bundler
const types = buildTypes && pkg.types
const types = target === 'uni-shared' || (buildTypes && pkg.types)
// if building a specific format, do not remove dist.
if (!formats && bundler !== 'vite') {
await fs.remove(`${pkgDir}/dist`)
......
因为 它太大了无法显示 source diff 。你可以改为 查看blob
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册