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

wip(app): uni-app-plus

上级 2e759719
{
"input": {
"src/service/index.ts": "dist/uni-app-service.es.js"
[
{
"input": {
"src/service/index.ts": "dist/uni-app-service.es.js"
},
"output": {
"name": "serviceContext",
"format": "iife",
"banner": "export function createServiceContext(Vue,weex, plus,instanceContext){\nconst setTimeout = instanceContext.setTimeout;\nconst clearTimeout = instanceContext.clearTimeout;\nconst setInterval = instanceContext.setInterval;\nconst clearInterval = instanceContext.clearInterval;\nconst __uniConfig = instanceContext.__uniConfig;\nconst __uniRoutes = instanceContext.__uniRoutes;\n",
"footer": "const uni = serviceContext.uni;\nconst getApp = serviceContext.getApp;\nconst getCurrentPages = serviceContext.getCurrentPages;\nconst UniServiceJSBridge = serviceContext.UniServiceJSBridge;\nreturn serviceContext;\n}",
"globals": {
"vue": "Vue"
}
},
"replacements": {
"__PLATFORM__": "'app'",
"__VUE_OPTIONS_API__": "true",
"__VUE_PROD_DEVTOOLS__": "false",
"__UNI_FEATURE_WX__": "true",
"__UNI_FEATURE_PROMISE__": "false",
"__UNI_FEATURE_I18N_EN__": "true",
"__UNI_FEATURE_I18N_ES__": "true",
"__UNI_FEATURE_I18N_FR__": "true",
"__UNI_FEATURE_I18N_ZH_HANS__": "true",
"__UNI_FEATURE_I18N_ZH_HANT__": "true"
},
"external": ["vue"]
},
"output": {
"name": "serviceContext",
"format": "iife",
"banner": "export function createServiceContext(Vue,weex, plus,instanceContext){\nconst setTimeout = instanceContext.setTimeout;\nconst clearTimeout = instanceContext.clearTimeout;\nconst setInterval = instanceContext.setInterval;\nconst clearInterval = instanceContext.clearInterval;\nconst __uniConfig = instanceContext.__uniConfig;\nconst __uniRoutes = instanceContext.__uniRoutes;\n",
"footer": "const uni = serviceContext.uni;\nconst getApp = serviceContext.getApp;\nconst getCurrentPages = serviceContext.getCurrentPages;\nconst UniServiceJSBridge = serviceContext.UniServiceJSBridge;\nreturn serviceContext;\n}",
"globals": {
"vue": "Vue"
}
},
"replacements": {
"__PLATFORM__": "'app'",
"__VUE_OPTIONS_API__": "true",
"__VUE_PROD_DEVTOOLS__": "false",
"__UNI_FEATURE_WX__": "true",
"__UNI_FEATURE_PROMISE__": "false",
"__UNI_FEATURE_I18N_EN__": "true",
"__UNI_FEATURE_I18N_ES__": "true",
"__UNI_FEATURE_I18N_FR__": "true",
"__UNI_FEATURE_I18N_ZH_HANS__": "true",
"__UNI_FEATURE_I18N_ZH_HANT__": "true"
},
"external": ["vue"]
}
{
"input": {
"src/service/framework/dom/decodeActions.ts": "dist/tools.umd.js"
},
"output": {
"name": "Tools",
"format": "umd"
},
"external": false
}
]
* {
margin: 0;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
-webkit-tap-highlight-color: transparent;
}
html,
body {
-webkit-user-select: none;
user-select: none;
width: 100%;
}
html {
height: 100%;
height: 100vh;
width: 100%;
width: 100vw;
}
body {
overflow-x: hidden;
background-color: white;
}
input[type='search']::-webkit-search-cancel-button {
display: none;
}
.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);
}
}
[nvue] uni-view,
[nvue] uni-label,
[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] uni-button {
margin: 0;
}
[nvue-dir-row] uni-view,
[nvue-dir-row] uni-label,
[nvue-dir-row] uni-swiper-item {
flex-direction: row;
}
[nvue-dir-column] uni-view,
[nvue-dir-column] uni-label,
[nvue-dir-column] uni-swiper-item {
flex-direction: column;
}
[nvue-dir-row-reverse] uni-view,
[nvue-dir-row-reverse] uni-label,
[nvue-dir-row-reverse] uni-swiper-item {
flex-direction: row-reverse;
}
[nvue-dir-column-reverse] uni-view,
[nvue-dir-column-reverse] uni-label,
[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-view {
display: block;
}
uni-view[hidden] {
display: none;
}
uni-button {
position: relative;
display: block;
margin-left: auto;
margin-right: auto;
padding-left: 14px;
padding-right: 14px;
box-sizing: border-box;
font-size: 18px;
text-align: center;
text-decoration: none;
line-height: 2.55555556;
border-radius: 5px;
-webkit-tap-highlight-color: transparent;
overflow: hidden;
color: #000000;
background-color: #f8f8f8;
cursor: pointer;
}
uni-button[hidden] {
display: none !important;
}
uni-button:after {
content: ' ';
width: 200%;
height: 200%;
position: absolute;
top: 0;
left: 0;
border: 1px solid rgba(0, 0, 0, 0.2);
transform: scale(0.5);
transform-origin: 0 0;
box-sizing: border-box;
border-radius: 10px;
}
uni-button[native] {
padding-left: 0;
padding-right: 0;
}
uni-button[native] .uni-button-cover-view-wrapper {
border: inherit;
border-color: inherit;
border-radius: inherit;
background-color: inherit;
}
uni-button[native] .uni-button-cover-view-inner {
padding-left: 14px;
padding-right: 14px;
}
uni-button uni-cover-view {
line-height: inherit;
white-space: inherit;
}
uni-button[type='default'] {
color: #000000;
background-color: #f8f8f8;
}
uni-button[type='primary'] {
color: #ffffff;
background-color: #007aff;
}
uni-button[type='warn'] {
color: #ffffff;
background-color: #e64340;
}
uni-button[disabled] {
color: rgba(255, 255, 255, 0.6);
cursor: not-allowed;
}
uni-button[disabled][type='default'],
uni-button[disabled]:not([type]) {
color: rgba(0, 0, 0, 0.3);
background-color: #f7f7f7;
}
uni-button[disabled][type='primary'] {
background-color: rgba(0, 122, 255, 0.6);
}
uni-button[disabled][type='warn'] {
background-color: #ec8b89;
}
uni-button[type='primary'][plain] {
color: #007aff;
border: 1px solid #007aff;
background-color: transparent;
}
uni-button[type='primary'][plain][disabled] {
color: rgba(0, 0, 0, 0.2);
border-color: rgba(0, 0, 0, 0.2);
}
uni-button[type='primary'][plain]:after {
border-width: 0;
}
uni-button[type='default'][plain] {
color: #353535;
border: 1px solid #353535;
background-color: transparent;
}
uni-button[type='default'][plain][disabled] {
color: rgba(0, 0, 0, 0.2);
border-color: rgba(0, 0, 0, 0.2);
}
uni-button[type='default'][plain]:after {
border-width: 0;
}
uni-button[plain] {
color: #353535;
border: 1px solid #353535;
background-color: transparent;
}
uni-button[plain][disabled] {
color: rgba(0, 0, 0, 0.2);
border-color: rgba(0, 0, 0, 0.2);
}
uni-button[plain]:after {
border-width: 0;
}
uni-button[plain][native] .uni-button-cover-view-inner {
padding: 0;
}
uni-button[type='warn'][plain] {
color: #e64340;
border: 1px solid #e64340;
background-color: transparent;
}
uni-button[type='warn'][plain][disabled] {
color: rgba(0, 0, 0, 0.2);
border-color: rgba(0, 0, 0, 0.2);
}
uni-button[type='warn'][plain]:after {
border-width: 0;
}
uni-button[size='mini'] {
display: inline-block;
line-height: 2.3;
font-size: 13px;
padding: 0 1.34em;
}
uni-button[size='mini'][native] {
padding: 0;
}
uni-button[size='mini'][native] .uni-button-cover-view-inner {
padding: 0 1.34em;
}
uni-button[loading]:not([disabled]) {
cursor: progress;
}
uni-button[loading]:before {
content: ' ';
display: inline-block;
width: 18px;
height: 18px;
vertical-align: middle;
animation: uni-loading 1s steps(12, end) infinite;
background-size: 100%;
}
uni-button[loading][type='primary'] {
color: rgba(255, 255, 255, 0.6);
background-color: #0062cc;
}
uni-button[loading][type='primary'][plain] {
color: #007aff;
background-color: transparent;
}
uni-button[loading][type='default'] {
color: rgba(0, 0, 0, 0.6);
background-color: #dedede;
}
uni-button[loading][type='default'][plain] {
color: #353535;
background-color: transparent;
}
uni-button[loading][type='warn'] {
color: rgba(255, 255, 255, 0.6);
background-color: #ce3c39;
}
uni-button[loading][type='warn'][plain] {
color: #e64340;
background-color: transparent;
}
uni-button[loading][native]:before {
content: none;
}
.button-hover {
color: rgba(0, 0, 0, 0.6);
background-color: #dedede;
}
.button-hover[plain] {
color: rgba(53, 53, 53, 0.6);
border-color: rgba(53, 53, 53, 0.6);
background-color: transparent;
}
.button-hover[type='primary'] {
color: rgba(255, 255, 255, 0.6);
background-color: #0062cc;
}
.button-hover[type='primary'][plain] {
color: rgba(26, 173, 25, 0.6);
border-color: rgba(26, 173, 25, 0.6);
background-color: transparent;
}
.button-hover[type='default'] {
color: rgba(0, 0, 0, 0.6);
background-color: #dedede;
}
.button-hover[type='default'][plain] {
color: rgba(53, 53, 53, 0.6);
border-color: rgba(53, 53, 53, 0.6);
background-color: transparent;
}
.button-hover[type='warn'] {
color: rgba(255, 255, 255, 0.6);
background-color: #ce3c39;
}
.button-hover[type='warn'][plain] {
color: rgba(230, 67, 64, 0.6);
border-color: rgba(230, 67, 64, 0.6);
background-color: transparent;
}
(function (window, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : window || self, factory(window.Tools = {}));
}(this, (function (exports) { 'use strict';
const COMPONENT_MAP = {
VIEW: 1,
IMAGE: 2,
TEXT: 3,
'#text': 4,
'#comment': 5,
NAVIGATOR: 6,
FORM: 7,
BUTTON: 8,
INPUT: 9,
LABEL: 10,
RADIO: 11,
CHECKBOX: 12,
'CHECKBOX-GROUP': 13,
AD: 14,
AUDIO: 15,
CAMERA: 16,
CANVAS: 17,
'COVER-IMAGE': 18,
'COVER-VIEW': 19,
EDITOR: 20,
'FUNCTIONAL-PAGE-NAVIGATOR': 21,
ICON: 22,
'RADIO-GROUP': 23,
'LIVE-PLAYER': 24,
'LIVE-PUSHER': 25,
MAP: 26,
'MOVABLE-AREA': 27,
'MOVABLE-VIEW': 28,
'OFFICIAL-ACCOUNT': 29,
'OPEN-DATA': 30,
PICKER: 31,
'PICKER-VIEW': 32,
'PICKER-VIEW-COLUMN': 33,
PROGRESS: 34,
'RICH-TEXT': 35,
'SCROLL-VIEW': 36,
SLIDER: 37,
SWIPER: 38,
'SWIPER-ITEM': 39,
SWITCH: 40,
TEXTAREA: 41,
VIDEO: 42,
'WEB-VIEW': 43,
};
function decodeArrMap(objMap) {
return Object.keys(objMap).reduce((arr, name) => {
arr.push(name.toLowerCase());
return arr;
}, ['']);
}
const DECODED_COMPONENT_ARR = /*#__PURE__*/ decodeArrMap(COMPONENT_MAP);
function decodeTag(tag) {
return (DECODED_COMPONENT_ARR[tag] || tag);
}
const ACTION_TYPE_PAGE_CREATE = 1;
const ACTION_TYPE_PAGE_CREATED = 2;
const ACTION_TYPE_CREATE = 3;
const ACTION_TYPE_INSERT = 4;
const ACTION_TYPE_REMOVE = 5;
const ACTION_TYPE_SET_ATTRIBUTE = 6;
const ACTION_TYPE_REMOVE_ATTRIBUTE = 7;
const ACTION_TYPE_SET_TEXT = 8;
function decodePageCreateAction([, pageCreateData]) {
return ['pageCreate', pageCreateData];
}
function decodePageCreatedAction([]) {
return ['pageCreated'];
}
function decodeCreateAction([, nodeId, nodeName]) {
return ['create', nodeId, decodeTag(nodeName)];
}
function decodeInsertAction([, ...action]) {
return ['insert', ...action];
}
function decodeRemoveAction([, ...action]) {
return ['remove', ...action];
}
function decodeSetAttributeAction([, ...action]) {
return ['setAttr', ...action];
}
function decodeRemoveAttributeAction([, ...action]) {
return ['removeAttr', ...action];
}
function decodeSetTextAction([, ...action]) {
return ['setText', action];
}
function decodeActions(actions) {
return actions.map((action) => {
switch (action[0]) {
case ACTION_TYPE_PAGE_CREATE:
return decodePageCreateAction(action);
case ACTION_TYPE_PAGE_CREATED:
return decodePageCreatedAction(action);
case ACTION_TYPE_CREATE:
return decodeCreateAction(action);
case ACTION_TYPE_INSERT:
return decodeInsertAction(action);
case ACTION_TYPE_REMOVE:
return decodeRemoveAction(action);
case ACTION_TYPE_SET_ATTRIBUTE:
return decodeSetAttributeAction(action);
case ACTION_TYPE_REMOVE_ATTRIBUTE:
return decodeRemoveAttributeAction(action);
case ACTION_TYPE_SET_TEXT:
return decodeSetTextAction(action);
}
return action;
});
}
exports.decodeActions = decodeActions;
Object.defineProperty(exports, '__esModule', { value: true });
})));
......@@ -141,6 +141,8 @@ var serviceContext = (function (vue) {
*/
const capitalize = cacheStringFunction$1((str) => str.charAt(0).toUpperCase() + str.slice(1));
const CHOOSE_SIZE_TYPES = ['original', 'compressed'];
const CHOOSE_SOURCE_TYPES = ['album', 'camera'];
const HTTP_METHODS = [
'GET',
'OPTIONS',
......@@ -157,6 +159,14 @@ var serviceContext = (function (vue) {
}
return str;
}
function elemsInArray(strArr, optionalVal) {
if (!isArray(strArr) ||
strArr.length === 0 ||
strArr.find((val) => optionalVal.indexOf(val) === -1)) {
return optionalVal;
}
return strArr;
}
function validateProtocolFail(name, msg) {
console.warn(`${name}: ${msg}`);
}
......@@ -774,48 +784,6 @@ var serviceContext = (function (vue) {
}
return [hyphenate(name.slice(2)), options];
}
const EVENT_MAP = {
onClick: '.e0',
onChange: '.e1',
onInput: '.e2',
onLoad: '.e3',
onError: '.e4',
onTouchstart: '.e5',
onTouchmove: '.e6',
onTouchcancel: '.e7',
onTouchend: '.e8',
onLongpress: '.e9',
onTransitionend: '.ea',
onAnimationstart: '.eb',
onAnimationiteration: '.ec',
onAnimationend: '.ed',
onTouchforcechange: '.ee',
};
const OPTIONS = [
'Capture',
'CaptureOnce',
'CapturePassive',
'CaptureOncePassive',
'Once',
'OncePassive',
'Passive',
];
const BASE_ATTR_MAP = {
class: '.c',
style: '.s',
'hover-class': '.h0',
'hover-stop-propagation': '.h1',
'hover-start-time': '.h2',
'hover-stay-time': '.h3',
};
/*#__PURE__*/ extend(BASE_ATTR_MAP, Object.keys(EVENT_MAP).reduce((res, name) => {
const value = EVENT_MAP[name];
res[name] = value;
OPTIONS.forEach((v, i) => {
res[name + v] = value + i;
});
return res;
}, Object.create(null)));
const COMPONENT_MAP = {
VIEW: 1,
IMAGE: 2,
......@@ -1444,6 +1412,44 @@ var serviceContext = (function (vue) {
}));
}
});
const initI18nChooseVideoMsgsOnce = /*#__PURE__*/ once(() => {
const name = 'uni.chooseVideo.';
{
useI18n().add(LOCALE_EN, normalizeMessages(name, {
cancel: 'Cancel',
'sourceType.album': 'Album',
'sourceType.camera': 'Camera',
}));
}
{
useI18n().add(LOCALE_ES, normalizeMessages(name, {
cancel: 'Cancelar',
'sourceType.album': 'Álbum',
'sourceType.camera': 'Cámara',
}));
}
{
useI18n().add(LOCALE_FR, normalizeMessages(name, {
cancel: 'Annuler',
'sourceType.album': 'Album',
'sourceType.camera': 'Caméra',
}));
}
{
useI18n().add(LOCALE_ZH_HANS, normalizeMessages(name, {
cancel: '取消',
'sourceType.album': '从相册选择',
'sourceType.camera': '拍摄',
}));
}
{
useI18n().add(LOCALE_ZH_HANT, normalizeMessages(name, {
cancel: '取消',
'sourceType.album': '從相冊選擇',
'sourceType.camera': '拍攝',
}));
}
});
const initI18nStartSoterAuthenticationMsgsOnce = /*#__PURE__*/ once(() => {
const name = 'uni.startSoterAuthentication.';
{
......@@ -2168,6 +2174,62 @@ var serviceContext = (function (vue) {
altitude: Boolean,
};
const API_CHOOSE_IMAGE = 'chooseImage';
const ChooseImageOptions = {
formatArgs: {
count(value, params) {
if (!value || value <= 0) {
params.count = 9;
}
},
sizeType(sizeType, params) {
params.sizeType = elemsInArray(sizeType, CHOOSE_SIZE_TYPES);
},
sourceType(sourceType, params) {
params.sourceType = elemsInArray(sourceType, CHOOSE_SOURCE_TYPES);
},
extension(extension, params) {
if (extension instanceof Array && extension.length === 0) {
return 'param extension should not be empty.';
}
if (!extension)
params.extension = [''];
},
},
};
const ChooseImageProtocol = {
count: Number,
sizeType: [Array, String],
sourceType: Array,
extension: Array,
};
const API_CHOOSE_VIDEO = 'chooseVideo';
const ChooseVideoOptions = {
formatArgs: {
sourceType(sourceType, params) {
params.sourceType = elemsInArray(sourceType, CHOOSE_SOURCE_TYPES);
},
compressed: true,
maxDuration: 60,
camera: 'back',
extension(extension, params) {
if (extension instanceof Array && extension.length === 0) {
return 'param extension should not be empty.';
}
if (!extension)
params.extension = [''];
},
},
};
const ChooseVideoProtocol = {
sourceType: Array,
compressed: Boolean,
maxDuration: Number,
camera: String,
extension: Array,
};
const API_GET_IMAGE_INFO = 'getImageInfo';
const GetImageInfoOptions = {
formatArgs: {
......@@ -3119,7 +3181,7 @@ var serviceContext = (function (vue) {
resolve(getStorageInfoSync());
}));
const getFileInfo = defineAsyncApi(API_GET_FILE_INFO, (options, { resolve, reject }) => {
const getFileInfo$1 = defineAsyncApi(API_GET_FILE_INFO, (options, { resolve, reject }) => {
plus.io.getFileInfo(extend(options, {
success: warpPlusSuccessCallback(resolve),
fail: warpPlusErrorCallback(reject),
......@@ -3899,7 +3961,7 @@ var serviceContext = (function (vue) {
return array[array.length - 1];
}
const compressImage = defineAsyncApi(API_COMPRESS_IMAGE, (options, { resolve, reject }) => {
const compressImage$1 = defineAsyncApi(API_COMPRESS_IMAGE, (options, { resolve, reject }) => {
const dst = `${TEMP_PATH}/compressed/${Date.now()}_${getFileName(options.src)}`;
plus.zip.compressImage(extend({}, options, {
dst,
......@@ -3921,6 +3983,236 @@ var serviceContext = (function (vue) {
}, reject);
}, CompressVideoProtocol, CompressVideoOptions);
/**
* 获取文件信息
* @param {string} filePath 文件路径
* @returns {Promise} 文件信息Promise
*/
function getFileInfo(filePath) {
return new Promise((resolve, reject) => {
plus.io.resolveLocalFileSystemURL(filePath, function (entry) {
entry.getMetadata(resolve, reject, false);
}, reject);
});
}
function compressImage(tempFilePath) {
const dst = `${TEMP_PATH}/compressed/${Date.now()}_${getFileName(tempFilePath)}`;
return new Promise((resolve) => {
plus.nativeUI.showWaiting();
plus.zip.compressImage({
src: tempFilePath,
dst,
overwrite: true,
}, () => {
plus.nativeUI.closeWaiting();
resolve(dst);
}, () => {
plus.nativeUI.closeWaiting();
resolve(tempFilePath);
});
});
}
const chooseImage = defineAsyncApi(API_CHOOSE_IMAGE,
// @ts-ignore crop 属性App特有
({ count, sizeType, sourceType, crop } = {}, { resolve, reject }) => {
initI18nChooseImageMsgsOnce();
const { t } = useI18n();
const errorCallback = warpPlusErrorCallback(reject);
function successCallback(paths) {
const tempFiles = [];
const tempFilePaths = [];
// plus.zip.compressImage 压缩文件并发调用在iOS端容易出现问题(图像错误、闪退),改为队列执行
paths
.reduce((promise, path) => {
return promise
.then(() => {
return getFileInfo(path);
})
.then((fileInfo) => {
const size = fileInfo.size;
// 压缩阈值 0.5 兆
const THRESHOLD = 1024 * 1024 * 0.5;
// 判断是否需要压缩
if (!crop &&
sizeType.includes('compressed') &&
size > THRESHOLD) {
return compressImage(path).then((dstPath) => {
path = dstPath;
return getFileInfo(path);
});
}
return fileInfo;
})
.then(({ size }) => {
tempFilePaths.push(path);
tempFiles.push({
path,
size: size,
});
});
}, Promise.resolve())
.then(() => {
resolve({
tempFilePaths,
tempFiles,
});
})
.catch(errorCallback);
}
function openCamera() {
const camera = plus.camera.getCamera();
camera.captureImage((path) => successCallback([path]), errorCallback, {
filename: TEMP_PATH + '/camera/',
resolution: 'high',
crop,
});
}
function openAlbum() {
// NOTE 5+此API分单选和多选,多选返回files:string[]
// @ts-ignore
plus.gallery.pick(({ files }) => successCallback(files), errorCallback, {
maximum: count,
multiple: true,
system: false,
filename: TEMP_PATH + '/gallery/',
permissionAlert: true,
crop,
});
}
if (sourceType.length === 1) {
if (sourceType.includes('album')) {
openAlbum();
return;
}
else if (sourceType.includes('camera')) {
openCamera();
return;
}
}
plus.nativeUI.actionSheet({
cancel: t('uni.chooseImage.cancel'),
buttons: [
{
title: t('uni.chooseImage.sourceType.camera'),
},
{
title: t('uni.chooseImage.sourceType.album'),
},
],
}, (e) => {
switch (e.index) {
case 1:
openCamera();
break;
case 2:
openAlbum();
break;
default:
errorCallback();
break;
}
});
}, ChooseImageProtocol, ChooseImageOptions);
const chooseVideo = defineAsyncApi(API_CHOOSE_VIDEO, ({ sourceType, compressed, maxDuration, camera }, { resolve, reject }) => {
initI18nChooseVideoMsgsOnce();
const { t } = useI18n();
const errorCallback = warpPlusErrorCallback(reject);
function successCallback(tempFilePath = '') {
const filename = `${TEMP_PATH}/compressed/${Date.now()}_${getFileName(tempFilePath)}`;
const compressVideo = compressed
? new Promise((resolve) => {
plus.zip.compressVideo({
src: tempFilePath,
filename,
}, ({ tempFilePath }) => {
resolve(tempFilePath);
}, () => {
resolve(tempFilePath);
});
})
: Promise.resolve(tempFilePath);
if (compressed) {
plus.nativeUI.showWaiting();
}
compressVideo.then((tempFilePath) => {
if (compressed) {
plus.nativeUI.closeWaiting();
}
plus.io.getVideoInfo({
filePath: tempFilePath,
success(videoInfo) {
const result = {
errMsg: 'chooseVideo:ok',
tempFilePath: tempFilePath,
size: videoInfo.size,
duration: videoInfo.duration,
width: videoInfo.width,
height: videoInfo.height,
};
resolve(result);
},
fail: errorCallback,
});
});
}
function openAlbum() {
plus.gallery.pick(
// NOTE 5+此API分单选和多选,多选返回files:string[]
// @ts-ignore
({ files }) => successCallback(files[0]), errorCallback, {
filter: 'video',
system: false,
// 不启用 multiple 时 system 无效
multiple: true,
maximum: 1,
filename: TEMP_PATH + '/gallery/',
permissionAlert: true,
});
}
function openCamera() {
const plusCamera = plus.camera.getCamera();
plusCamera.startVideoCapture(successCallback, errorCallback, {
index: camera === 'front' ? '2' : '1',
videoMaximumDuration: maxDuration,
filename: TEMP_PATH + '/camera/',
});
}
if (sourceType.length === 1) {
if (sourceType.includes('album')) {
openAlbum();
return;
}
else if (sourceType.includes('camera')) {
openCamera();
return;
}
}
plus.nativeUI.actionSheet({
cancel: t('uni.chooseVideo.cancel'),
buttons: [
{
title: t('uni.chooseVideo.sourceType.camera'),
},
{
title: t('uni.chooseVideo.sourceType.album'),
},
],
}, (e) => {
switch (e.index) {
case 1:
openCamera();
break;
case 2:
openAlbum();
break;
default:
errorCallback();
break;
}
});
}, ChooseVideoProtocol, ChooseVideoOptions);
const showKeyboard = defineAsyncApi(API_SHOW_KEYBOARD, (_, { resolve }) => {
plus.key.showSoftKeybord();
resolve();
......@@ -4483,7 +4775,7 @@ var serviceContext = (function (vue) {
audio.__timing = setInterval(() => {
const currentTime = audio.currentTime;
if (currentTime !== oldCurrentTime) {
emit(audio, 'timeupdate');
emit(audio, 'timeUpdate');
}
}, 200);
}
......@@ -4623,7 +4915,7 @@ var serviceContext = (function (vue) {
});
});
function emit(audio, state, errMsg, errCode) {
const name = `on${state[0].toUpperCase() + state.substr(1)}`;
const name = `on${capitalize(state)}`;
audio._callbacks[name].forEach((callback) => {
if (typeof callback === 'function') {
callback(state === 'error'
......@@ -7338,7 +7630,7 @@ var serviceContext = (function (vue) {
clearStorage: clearStorage,
getStorageInfoSync: getStorageInfoSync,
getStorageInfo: getStorageInfo,
getFileInfo: getFileInfo,
getFileInfo: getFileInfo$1,
openDocument: openDocument,
onCompassChange: onCompassChange,
offCompassChange: offCompassChange,
......@@ -7391,8 +7683,10 @@ var serviceContext = (function (vue) {
getRecorderManager: getRecorderManager,
saveVideoToPhotosAlbum: saveVideoToPhotosAlbum,
saveImageToPhotosAlbum: saveImageToPhotosAlbum,
compressImage: compressImage,
compressImage: compressImage$1,
compressVideo: compressVideo,
chooseImage: chooseImage,
chooseVideo: chooseVideo,
showKeyboard: showKeyboard,
hideKeyboard: hideKeyboard,
downloadFile: downloadFile,
......
......@@ -17,9 +17,7 @@
"url": "https://github.com/dcloudio/uni-app/issues"
},
"dependencies": {
"@webcomponents/custom-elements": "^1.4.3",
"vue": "^3.1.4",
"vue3-webcomponent-wrapper": "^0.1.4"
"vue": "^3.1.4"
},
"gitHead": "56deaeb47d42e924d10282d7af418ccee6b139bf"
}
import '@dcloudio/uni-components/style/view.css'
export function View() {
return document.createElement('uni-view')
}
......@@ -2,16 +2,16 @@ import { hasOwn } from '@vue/shared'
import { decodeAttr, UniNodeJSON } from '@dcloudio/uni-shared'
import { UniNode } from './UniNode'
import { UniCustomElement } from './utils'
import { patchClass } from './modules/class'
import { patchStyle } from './modules/style'
import { patchEvent } from './modules/events'
import { UniCustomElement } from './components'
export class UniElement extends UniNode {
$: UniCustomElement
constructor(id: number, tag: string) {
super(id, tag)
this.$ = document.createElement(tag) as unknown as UniCustomElement
constructor(id: number, element: Element) {
super(id, element.tagName)
this.$ = element as UniCustomElement
this.$.__id = id
this.$.__listeners = Object.create(null)
}
......
import { hasOwn } from '@vue/shared'
import { UniNodeJSON } from '@dcloudio/uni-shared'
import { $ } from './utils'
import { $ } from '.'
export class UniNode {
id: number
......
import '@dcloudio/uni-components/style/view.css'
import { UniHoverElement } from './UniHoverElement'
export class UniViewElement extends UniHoverElement {
constructor(id: number) {
super(id, 'uni-view')
super(id, document.createElement('uni-view'))
}
}
import '@dcloudio/uni-components/style/button.css'
import { hasOwn } from '@vue/shared'
import { Button } from '@dcloudio/uni-components'
import { createApp, reactive, watch } from 'vue'
import { createWrapper } from '.'
import {
decodeAttr,
formatLog,
parseEventName,
UniNodeJSON,
} from '@dcloudio/uni-shared'
import { UniNode } from '../UniNode'
import { createInvoker } from '../modules/events'
const UniButton = createWrapper(Button)
export class UniButtonElement extends UniNode {
private $props!: Record<string, any>
constructor(id: number) {
super(id, 'uni-button')
}
init(nodeJson: Partial<UniNodeJSON>) {
const container = document.createElement('div')
this.$props = reactive({})
const { a } = nodeJson
if (a) {
Object.keys(a).forEach((n) => {
this.setAttr(n, a[n])
})
}
const vm = createApp(UniButton, { attrs: this.$props }).mount(container)
this.$ = container.firstElementChild!
if (hasOwn(nodeJson, 't')) {
this.$.textContent = nodeJson.t || ''
}
watch(this.$props, () => {
if (__DEV__) {
console.log(formatLog(this.tag, 'props', 'forceUpdate'))
}
vm.$forceUpdate()
})
}
setAttr(name: string, value: unknown) {
const decoded = decodeAttr(name)
if (name.indexOf('.e') === 0) {
this.$props[decoded] = createInvoker(
this.id,
value as number,
parseEventName(decoded)[1]
)
} else {
this.$props[decoded] = value
}
}
removeAttr(name: string) {
this.$props[decodeAttr(name)] = null
}
}
import { defineComponent, h, reactive } from 'vue'
import { UniComment } from '../UniComment'
import { UniText } from '../UniText'
import { UniViewElement } from '../UniViewElement'
import { UniButtonElement } from './UniButtonElement'
export interface UniCustomElement extends Element {
__id: number
__listeners: Record<string, (evt: Event) => void>
}
const BuiltInComponents = [
,
UniViewElement,
,
,
UniText,
UniComment,
,
,
UniButtonElement,
]
export function createBuiltInComponent(type: number, id: number) {
return new BuiltInComponents[type]!(id)
}
export function createWrapper(component: ReturnType<typeof defineComponent>) {
return defineComponent({
props: ['attrs'],
data() {
return {
props: this.attrs,
}
},
render() {
return h(component, this.props)
},
})
}
export * from './utils'
import { isString } from '@vue/shared'
import { createBuiltInComponent } from './components'
import { UniElement } from './UniElement'
import { UniText } from './UniText'
const elements = new Map<number, UniElement | UniText>()
export function $(id: number) {
return elements.get(id) as UniElement
}
export function createElement(id: number, tag: string | number) {
let element: UniElement | UniText
if (isString(tag)) {
element = new UniElement(id, document.createElement(tag))
} else {
element = createBuiltInComponent(tag, id)
}
elements.set(id, element)
return element
}
......@@ -9,7 +9,7 @@ import {
} from '@dcloudio/uni-shared'
import { VD_SYNC } from '../../../../../constants'
import { ACTION_TYPE_EVENT } from '../../../../../PageAction'
import { UniCustomElement } from '../utils'
import { UniCustomElement } from '../components'
export function patchEvent(el: UniCustomElement, name: string, flag: number) {
const [type, options] = parseEventName(decodeAttr(name))
......@@ -43,7 +43,7 @@ export function patchEvent(el: UniCustomElement, name: string, flag: number) {
}
}
function createInvoker(
export function createInvoker(
id: number,
flag: number,
options?: AddEventListenerOptions
......
import { isString } from '@vue/shared'
import { UniComment } from './UniComment'
import { UniElement } from './UniElement'
import { UniText } from './UniText'
import { UniViewElement } from './UniViewElement'
export interface UniCustomElement extends Element {
__id: number
__listeners: Record<string, (evt: Event) => void>
}
const elements = new Map<number, UniElement | UniText>()
const UniBuiltInComponents = [, UniViewElement, , , UniText, UniComment]
function createUniComponent(type: number, id: number) {
return new UniBuiltInComponents[type]!(id)
}
export function $(id: number) {
return elements.get(id) as UniElement
}
export function createElement(id: number, tag: string | number) {
let element: UniElement | UniText
if (isString(tag)) {
element = new UniElement(id, tag)
} else {
element = createUniComponent(tag, id)
}
elements.set(id, element)
return element
}
import '@webcomponents/custom-elements'
import './components'
import './ready'
import '../../style/framework/base.css'
import '@dcloudio/uni-h5/style/framework/nvue.css'
import { ON_WEBVIEW_READY } from '../constants'
import { UniViewJSBridge } from './bridge'
import { initView } from './framework'
;(window as any).UniViewJSBridge = UniViewJSBridge
function onWebviewReady() {
initView()
UniViewJSBridge.publishHandler(ON_WEBVIEW_READY)
}
if (typeof plus !== 'undefined') {
onWebviewReady()
} else {
document.addEventListener('plusready', onWebviewReady)
}
import { ON_WEBVIEW_READY } from '../constants'
import { UniViewJSBridge } from './bridge'
import { initView } from './framework'
;(window as any).UniViewJSBridge = UniViewJSBridge
function onWebviewReady() {
initView()
UniViewJSBridge.publishHandler(ON_WEBVIEW_READY)
}
if (typeof plus !== 'undefined') {
onWebviewReady()
} else {
document.addEventListener('plusready', onWebviewReady)
}
* {
margin: 0;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
-webkit-tap-highlight-color: transparent;
}
html,
body {
-webkit-user-select: none;
user-select: none;
width: 100%;
}
html {
height: 100%;
height: 100vh;
width: 100%;
width: 100vw;
}
body {
overflow-x: hidden;
background-color: white;
}
input[type='search']::-webkit-search-cancel-button {
display: none;
}
.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);
}
}
......@@ -42,8 +42,13 @@ export default defineConfig({
global: 'window',
__DEV__: true,
__TEST__: false,
__PLATFORM__: JSON.stringify('h5'),
__PLATFORM__: JSON.stringify('app'),
__NODE_JS__: false,
__UNI_FEATURE_I18N_EN__: true,
__UNI_FEATURE_I18N_ES__: true,
__UNI_FEATURE_I18N_FR__: true,
__UNI_FEATURE_I18N_ZH_HANS__: true,
__UNI_FEATURE_I18N_ZH_HANT__: true,
},
resolve: {
alias: [
......@@ -77,6 +82,15 @@ export default defineConfig({
},
],
},
css: {
postcss: {
plugins: [
require('autoprefixer')({
overrideBrowserslist: ['Android > 4.4', 'iOS >= 10'],
}),
],
},
},
plugins: [
vue({
template: {
......
......@@ -416,15 +416,18 @@ export default function vueFactory(exports) {
'hover-stop-propagation': '.h1',
'hover-start-time': '.h2',
'hover-stay-time': '.h3'
};
var ATTR_MAP = /*#__PURE__*/extend$1(BASE_ATTR_MAP, Object.keys(EVENT_MAP).reduce(function (res, name) {
var value = EVENT_MAP[name];
res[name] = value;
OPTIONS.forEach(function (v, i) {
res[name + v] = value + i;
});
return res;
}, Object.create(null)));
}; // 该代码会单独编译成一个decode js,用于开发时测试,故尽可能独立,不使用 @vue/shared 的 extend
var ATTR_MAP = /*#__PURE__*/function () {
return Object.assign(BASE_ATTR_MAP, Object.keys(EVENT_MAP).reduce(function (res, name) {
var value = EVENT_MAP[name];
res[name] = value;
OPTIONS.forEach(function (v, i) {
res[name + v] = value + i;
});
return res;
}, Object.create(null)));
}();
function encodeAttr(name) {
return ATTR_MAP[name] || name;
......
......@@ -5,48 +5,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var shared = require('@vue/shared');
const EVENT_MAP = {
onClick: '.e0',
onChange: '.e1',
onInput: '.e2',
onLoad: '.e3',
onError: '.e4',
onTouchstart: '.e5',
onTouchmove: '.e6',
onTouchcancel: '.e7',
onTouchend: '.e8',
onLongpress: '.e9',
onTransitionend: '.ea',
onAnimationstart: '.eb',
onAnimationiteration: '.ec',
onAnimationend: '.ed',
onTouchforcechange: '.ee',
};
const OPTIONS = [
'Capture',
'CaptureOnce',
'CapturePassive',
'CaptureOncePassive',
'Once',
'OncePassive',
'Passive',
];
const BASE_ATTR_MAP = {
class: '.c',
style: '.s',
'hover-class': '.h0',
'hover-stop-propagation': '.h1',
'hover-start-time': '.h2',
'hover-stay-time': '.h3',
};
/*#__PURE__*/ shared.extend(BASE_ATTR_MAP, Object.keys(EVENT_MAP).reduce((res, name) => {
const value = EVENT_MAP[name];
res[name] = value;
OPTIONS.forEach((v, i) => {
res[name + v] = value + i;
});
return res;
}, Object.create(null)));
const sanitise = (val) => (val && JSON.parse(JSON.stringify(val))) || val;
const UNI_SSR = '__uniSSR';
const UNI_SSR_DATA = 'data';
......
import { shallowRef, ref, getCurrentInstance, isInSSRComponentSetup, injectHook } from 'vue';
import { extend, hasOwn, isString } from '@vue/shared';
import { hasOwn, isString } from '@vue/shared';
const EVENT_MAP = {
onClick: '.e0',
onChange: '.e1',
onInput: '.e2',
onLoad: '.e3',
onError: '.e4',
onTouchstart: '.e5',
onTouchmove: '.e6',
onTouchcancel: '.e7',
onTouchend: '.e8',
onLongpress: '.e9',
onTransitionend: '.ea',
onAnimationstart: '.eb',
onAnimationiteration: '.ec',
onAnimationend: '.ed',
onTouchforcechange: '.ee',
};
const OPTIONS = [
'Capture',
'CaptureOnce',
'CapturePassive',
'CaptureOncePassive',
'Once',
'OncePassive',
'Passive',
];
const BASE_ATTR_MAP = {
class: '.c',
style: '.s',
'hover-class': '.h0',
'hover-stop-propagation': '.h1',
'hover-start-time': '.h2',
'hover-stay-time': '.h3',
};
/*#__PURE__*/ extend(BASE_ATTR_MAP, Object.keys(EVENT_MAP).reduce((res, name) => {
const value = EVENT_MAP[name];
res[name] = value;
OPTIONS.forEach((v, i) => {
res[name + v] = value + i;
});
return res;
}, Object.create(null)));
const sanitise = (val) => (val && JSON.parse(JSON.stringify(val))) || val;
const UNI_SSR = '__uniSSR';
const UNI_SSR_DATA = 'data';
......
......@@ -3,6 +3,10 @@ import { ComponentPublicInstance, getCurrentInstance } from 'vue'
import { rpx2px } from './util'
export function useCurrentPageId() {
if (__PLATFORM__ === 'app') {
// view 层
return parseInt((window as any).__id__)
}
return getCurrentInstance()!.root.proxy!.$page.id
}
......
......@@ -234,49 +234,7 @@ function stringifyQuery(obj, encodeStr = encode) {
.join('&')
: null;
return res ? `?${res}` : '';
}
const EVENT_MAP = {
onClick: '.e0',
onChange: '.e1',
onInput: '.e2',
onLoad: '.e3',
onError: '.e4',
onTouchstart: '.e5',
onTouchmove: '.e6',
onTouchcancel: '.e7',
onTouchend: '.e8',
onLongpress: '.e9',
onTransitionend: '.ea',
onAnimationstart: '.eb',
onAnimationiteration: '.ec',
onAnimationend: '.ed',
onTouchforcechange: '.ee',
};
const OPTIONS = [
'Capture',
'CaptureOnce',
'CapturePassive',
'CaptureOncePassive',
'Once',
'OncePassive',
'Passive',
];
const BASE_ATTR_MAP = {
class: '.c',
style: '.s',
'hover-class': '.h0',
'hover-stop-propagation': '.h1',
'hover-start-time': '.h2',
'hover-stay-time': '.h3',
};
/*#__PURE__*/ extend(BASE_ATTR_MAP, Object.keys(EVENT_MAP).reduce((res, name) => {
const value = EVENT_MAP[name];
res[name] = value;
OPTIONS.forEach((v, i) => {
res[name + v] = value + i;
});
return res;
}, Object.create(null)));
}
function initVueIds(vueIds, mpInstance) {
if (!vueIds) {
......
......@@ -225,49 +225,7 @@ function stringifyQuery(obj, encodeStr = encode) {
.join('&')
: null;
return res ? `?${res}` : '';
}
const EVENT_MAP = {
onClick: '.e0',
onChange: '.e1',
onInput: '.e2',
onLoad: '.e3',
onError: '.e4',
onTouchstart: '.e5',
onTouchmove: '.e6',
onTouchcancel: '.e7',
onTouchend: '.e8',
onLongpress: '.e9',
onTransitionend: '.ea',
onAnimationstart: '.eb',
onAnimationiteration: '.ec',
onAnimationend: '.ed',
onTouchforcechange: '.ee',
};
const OPTIONS = [
'Capture',
'CaptureOnce',
'CapturePassive',
'CaptureOncePassive',
'Once',
'OncePassive',
'Passive',
];
const BASE_ATTR_MAP = {
class: '.c',
style: '.s',
'hover-class': '.h0',
'hover-stop-propagation': '.h1',
'hover-start-time': '.h2',
'hover-stay-time': '.h3',
};
/*#__PURE__*/ extend(BASE_ATTR_MAP, Object.keys(EVENT_MAP).reduce((res, name) => {
const value = EVENT_MAP[name];
res[name] = value;
OPTIONS.forEach((v, i) => {
res[name + v] = value + i;
});
return res;
}, Object.create(null)));
}
function initBehavior(options) {
return Behavior(options);
......
......@@ -225,49 +225,7 @@ function stringifyQuery(obj, encodeStr = encode) {
.join('&')
: null;
return res ? `?${res}` : '';
}
const EVENT_MAP = {
onClick: '.e0',
onChange: '.e1',
onInput: '.e2',
onLoad: '.e3',
onError: '.e4',
onTouchstart: '.e5',
onTouchmove: '.e6',
onTouchcancel: '.e7',
onTouchend: '.e8',
onLongpress: '.e9',
onTransitionend: '.ea',
onAnimationstart: '.eb',
onAnimationiteration: '.ec',
onAnimationend: '.ed',
onTouchforcechange: '.ee',
};
const OPTIONS = [
'Capture',
'CaptureOnce',
'CapturePassive',
'CaptureOncePassive',
'Once',
'OncePassive',
'Passive',
];
const BASE_ATTR_MAP = {
class: '.c',
style: '.s',
'hover-class': '.h0',
'hover-stop-propagation': '.h1',
'hover-start-time': '.h2',
'hover-stay-time': '.h3',
};
/*#__PURE__*/ extend(BASE_ATTR_MAP, Object.keys(EVENT_MAP).reduce((res, name) => {
const value = EVENT_MAP[name];
res[name] = value;
OPTIONS.forEach((v, i) => {
res[name + v] = value + i;
});
return res;
}, Object.create(null)));
}
function initBehavior(options) {
return Behavior(options);
......
......@@ -228,49 +228,7 @@ function stringifyQuery(obj, encodeStr = encode) {
.join('&')
: null;
return res ? `?${res}` : '';
}
const EVENT_MAP = {
onClick: '.e0',
onChange: '.e1',
onInput: '.e2',
onLoad: '.e3',
onError: '.e4',
onTouchstart: '.e5',
onTouchmove: '.e6',
onTouchcancel: '.e7',
onTouchend: '.e8',
onLongpress: '.e9',
onTransitionend: '.ea',
onAnimationstart: '.eb',
onAnimationiteration: '.ec',
onAnimationend: '.ed',
onTouchforcechange: '.ee',
};
const OPTIONS = [
'Capture',
'CaptureOnce',
'CapturePassive',
'CaptureOncePassive',
'Once',
'OncePassive',
'Passive',
];
const BASE_ATTR_MAP = {
class: '.c',
style: '.s',
'hover-class': '.h0',
'hover-stop-propagation': '.h1',
'hover-start-time': '.h2',
'hover-stay-time': '.h3',
};
/*#__PURE__*/ extend(BASE_ATTR_MAP, Object.keys(EVENT_MAP).reduce((res, name) => {
const value = EVENT_MAP[name];
res[name] = value;
OPTIONS.forEach((v, i) => {
res[name + v] = value + i;
});
return res;
}, Object.create(null)));
}
function initBehavior(options) {
return Behavior(options);
......
import { isFunction, extend, isSymbol, isMap, isObject, toRawType, def, isArray, isString, isPromise, toHandlerKey, remove, EMPTY_OBJ, camelize, capitalize, normalizeClass, normalizeStyle, isOn, NOOP, isGloballyWhitelisted, isIntegerKey, hasOwn, hasChanged, invokeArrayFns as invokeArrayFns$1, makeMap, isSet, NO, toNumber, hyphenate, isReservedProp, EMPTY_ARR, toTypeString } from '@vue/shared';
import { isFunction, isSymbol, extend, isMap, isObject, toRawType, def, isArray, isString, isPromise, toHandlerKey, remove, EMPTY_OBJ, camelize, capitalize, normalizeClass, normalizeStyle, isOn, NOOP, isGloballyWhitelisted, isIntegerKey, hasOwn, hasChanged, invokeArrayFns as invokeArrayFns$1, makeMap, isSet, NO, toNumber, hyphenate, isReservedProp, EMPTY_ARR, toTypeString } from '@vue/shared';
export { camelize } from '@vue/shared';
import { injectHook as injectHook$1 } from 'vue';
......@@ -13,48 +13,6 @@ function applyOptions$1(options, instance, publicThis) {
});
}
const EVENT_MAP = {
onClick: '.e0',
onChange: '.e1',
onInput: '.e2',
onLoad: '.e3',
onError: '.e4',
onTouchstart: '.e5',
onTouchmove: '.e6',
onTouchcancel: '.e7',
onTouchend: '.e8',
onLongpress: '.e9',
onTransitionend: '.ea',
onAnimationstart: '.eb',
onAnimationiteration: '.ec',
onAnimationend: '.ed',
onTouchforcechange: '.ee',
};
const OPTIONS = [
'Capture',
'CaptureOnce',
'CapturePassive',
'CaptureOncePassive',
'Once',
'OncePassive',
'Passive',
];
const BASE_ATTR_MAP = {
class: '.c',
style: '.s',
'hover-class': '.h0',
'hover-stop-propagation': '.h1',
'hover-start-time': '.h2',
'hover-stay-time': '.h3',
};
/*#__PURE__*/ extend(BASE_ATTR_MAP, Object.keys(EVENT_MAP).reduce((res, name) => {
const value = EVENT_MAP[name];
res[name] = value;
OPTIONS.forEach((v, i) => {
res[name + v] = value + i;
});
return res;
}, Object.create(null)));
const invokeArrayFns = (fns, arg) => {
let ret;
for (let i = 0; i < fns.length; i++) {
......
......@@ -225,49 +225,7 @@ function stringifyQuery(obj, encodeStr = encode) {
.join('&')
: null;
return res ? `?${res}` : '';
}
const EVENT_MAP = {
onClick: '.e0',
onChange: '.e1',
onInput: '.e2',
onLoad: '.e3',
onError: '.e4',
onTouchstart: '.e5',
onTouchmove: '.e6',
onTouchcancel: '.e7',
onTouchend: '.e8',
onLongpress: '.e9',
onTransitionend: '.ea',
onAnimationstart: '.eb',
onAnimationiteration: '.ec',
onAnimationend: '.ed',
onTouchforcechange: '.ee',
};
const OPTIONS = [
'Capture',
'CaptureOnce',
'CapturePassive',
'CaptureOncePassive',
'Once',
'OncePassive',
'Passive',
];
const BASE_ATTR_MAP = {
class: '.c',
style: '.s',
'hover-class': '.h0',
'hover-stop-propagation': '.h1',
'hover-start-time': '.h2',
'hover-stay-time': '.h3',
};
/*#__PURE__*/ extend(BASE_ATTR_MAP, Object.keys(EVENT_MAP).reduce((res, name) => {
const value = EVENT_MAP[name];
res[name] = value;
OPTIONS.forEach((v, i) => {
res[name + v] = value + i;
});
return res;
}, Object.create(null)));
}
function initBehavior(options) {
return Behavior(options);
......
......@@ -225,49 +225,7 @@ function stringifyQuery(obj, encodeStr = encode) {
.join('&')
: null;
return res ? `?${res}` : '';
}
const EVENT_MAP = {
onClick: '.e0',
onChange: '.e1',
onInput: '.e2',
onLoad: '.e3',
onError: '.e4',
onTouchstart: '.e5',
onTouchmove: '.e6',
onTouchcancel: '.e7',
onTouchend: '.e8',
onLongpress: '.e9',
onTransitionend: '.ea',
onAnimationstart: '.eb',
onAnimationiteration: '.ec',
onAnimationend: '.ed',
onTouchforcechange: '.ee',
};
const OPTIONS = [
'Capture',
'CaptureOnce',
'CapturePassive',
'CaptureOncePassive',
'Once',
'OncePassive',
'Passive',
];
const BASE_ATTR_MAP = {
class: '.c',
style: '.s',
'hover-class': '.h0',
'hover-stop-propagation': '.h1',
'hover-start-time': '.h2',
'hover-stay-time': '.h3',
};
/*#__PURE__*/ extend(BASE_ATTR_MAP, Object.keys(EVENT_MAP).reduce((res, name) => {
const value = EVENT_MAP[name];
res[name] = value;
OPTIONS.forEach((v, i) => {
res[name + v] = value + i;
});
return res;
}, Object.create(null)));
}
function initBehavior(options) {
return Behavior(options);
......
......@@ -554,14 +554,17 @@ const BASE_ATTR_MAP = {
'hover-start-time': '.h2',
'hover-stay-time': '.h3',
};
const ATTR_MAP = /*#__PURE__*/ shared.extend(BASE_ATTR_MAP, Object.keys(EVENT_MAP).reduce((res, name) => {
const value = EVENT_MAP[name];
res[name] = value;
OPTIONS.forEach((v, i) => {
res[name + v] = value + i;
});
return res;
}, Object.create(null)));
// 该代码会单独编译成一个decode js,用于开发时测试,故尽可能独立,不使用 @vue/shared 的 extend
const ATTR_MAP = /*#__PURE__*/ (() => {
return Object.assign(BASE_ATTR_MAP, Object.keys(EVENT_MAP).reduce((res, name) => {
const value = EVENT_MAP[name];
res[name] = value;
OPTIONS.forEach((v, i) => {
res[name + v] = value + i;
});
return res;
}, Object.create(null)));
})();
function encodeAttr(name) {
return ATTR_MAP[name] || name;
}
......
......@@ -550,14 +550,17 @@ const BASE_ATTR_MAP = {
'hover-start-time': '.h2',
'hover-stay-time': '.h3',
};
const ATTR_MAP = /*#__PURE__*/ extend(BASE_ATTR_MAP, Object.keys(EVENT_MAP).reduce((res, name) => {
const value = EVENT_MAP[name];
res[name] = value;
OPTIONS.forEach((v, i) => {
res[name + v] = value + i;
});
return res;
}, Object.create(null)));
// 该代码会单独编译成一个decode js,用于开发时测试,故尽可能独立,不使用 @vue/shared 的 extend
const ATTR_MAP = /*#__PURE__*/ (() => {
return Object.assign(BASE_ATTR_MAP, Object.keys(EVENT_MAP).reduce((res, name) => {
const value = EVENT_MAP[name];
res[name] = value;
OPTIONS.forEach((v, i) => {
res[name + v] = value + i;
});
return res;
}, Object.create(null)));
})();
function encodeAttr(name) {
return ATTR_MAP[name] || name;
}
......
import { extend } from '@vue/shared'
export const EventOptionFlags = {
capture: 1,
once: 1 << 1,
......@@ -79,17 +77,20 @@ const BASE_ATTR_MAP = {
'hover-stay-time': '.h3',
}
export const ATTR_MAP = /*#__PURE__*/ extend(
BASE_ATTR_MAP,
Object.keys(EVENT_MAP).reduce((res, name) => {
const value = EVENT_MAP[name as keyof typeof EVENT_MAP]
res[name] = value
OPTIONS.forEach((v, i) => {
res[name + v] = value + i
})
return res
}, Object.create(null))
)
// 该代码会单独编译成一个decode js,用于开发时测试,故尽可能独立,不使用 @vue/shared 的 extend
export const ATTR_MAP = /*#__PURE__*/ (() => {
return Object.assign(
BASE_ATTR_MAP,
Object.keys(EVENT_MAP).reduce((res, name) => {
const value = EVENT_MAP[name as keyof typeof EVENT_MAP]
res[name] = value
OPTIONS.forEach((v, i) => {
res[name + v] = value + i
})
return res
}, Object.create(null))
)
})()
export function encodeAttr(name: string) {
return ATTR_MAP[name as keyof typeof ATTR_MAP] || name
......
......@@ -110,6 +110,8 @@ export function initPluginVueOptions(
directiveTransforms
)
}
// App,MP 平台不支持使用静态节点
compilerOptions.hoistStatic = false
return vueOptions
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册