diff --git a/packages/uni-app-plus/dist/style.css b/packages/uni-app-plus/dist/style.css
index d199d7552670780269e5d866d8395879aead9d9f..c84638b1361ca86e0444ed739ce84d0aa6c170a9 100644
--- a/packages/uni-app-plus/dist/style.css
+++ b/packages/uni-app-plus/dist/style.css
@@ -109,6 +109,11 @@ uni-button[loading]:before {
[nvue] uni-swiper-item {
position: absolute;
}
+uni-text[selectable] {
+ cursor: auto;
+ -webkit-user-select: text;
+ user-select: text;
+}
uni-view {
display: block;
}
@@ -1693,11 +1698,6 @@ uni-switch .uni-checkbox-input svg {
.uni-checkbox-input.uni-checkbox-input-disabled:before {
color: #adadad;
}
-uni-text[selectable] {
- cursor: auto;
- -webkit-user-select: text;
- user-select: text;
-}
uni-textarea {
width: 300px;
height: 150px;
diff --git a/packages/uni-app-plus/dist/uni-app-service.es.js b/packages/uni-app-plus/dist/uni-app-service.es.js
index 13aee6b4ebf0a9478a378792411750cf8101cd47..eb1c8c22907432c055b19782179e6c61763f0a0f 100644
--- a/packages/uni-app-plus/dist/uni-app-service.es.js
+++ b/packages/uni-app-plus/dist/uni-app-service.es.js
@@ -4590,7 +4590,7 @@ var serviceContext = (function (vue) {
}
});
}
- send(args) {
+ send(args, callopt = true) {
if (this.readyState !== this.OPEN) {
callOptions(args, 'sendSocketMessage:fail WebSocket is not connected');
}
@@ -4604,23 +4604,23 @@ var serviceContext = (function (vue) {
}
: args.data,
});
- callOptions(args, 'sendSocketMessage:ok');
+ callopt && callOptions(args, 'sendSocketMessage:ok');
}
catch (error) {
- callOptions(args, `sendSocketMessage:fail ${error}`);
+ callopt && callOptions(args, `sendSocketMessage:fail ${error}`);
}
}
- close(args) {
+ close(args, callopt = true) {
this.readyState = this.CLOSING;
try {
this._socket.close(extend({
id: this.id,
args,
}));
- callOptions(args, 'closeSocket:ok');
+ callopt && callOptions(args, 'closeSocket:ok');
}
catch (error) {
- callOptions(args, `closeSocket:fail ${error}`);
+ callopt && callOptions(args, `closeSocket:fail ${error}`);
}
}
onOpen(callback) {
@@ -4660,21 +4660,20 @@ var serviceContext = (function (vue) {
const sendSocketMessage = defineAsyncApi(API_SEND_SOCKET_MESSAGE, (args, { resolve, reject }) => {
const socketTask = socketTasks[0];
if (!socketTask || socketTask.readyState !== socketTask.OPEN) {
- reject('sendSocketMessage:fail WebSocket is not connected');
+ reject('WebSocket is not connected');
return;
}
- socketTask.send({ data: args.data });
+ socketTask.send({ data: args.data }, false);
resolve();
}, SendSocketMessageProtocol);
const closeSocket = defineAsyncApi(API_CLOSE_SOCKET, (args, { resolve, reject }) => {
const socketTask = socketTasks[0];
if (!socketTask) {
- reject('closeSocket:fail WebSocket is not connected');
+ reject('WebSocket is not connected');
return;
}
socketTask.readyState = socketTask.CLOSING;
- const { code, reason } = args;
- socketTask.close({ code, reason });
+ socketTask.close(args, false);
resolve();
}, CloseSocketProtocol);
function on(event) {
diff --git a/packages/uni-app-plus/dist/uni-app-view.umd.js b/packages/uni-app-plus/dist/uni-app-view.umd.js
index 2ba3d4eabbf5675f07b7cd685ec8a7fd3acf54b6..56955a10c76507eb85c02792d5222166d3b76843 100644
--- a/packages/uni-app-plus/dist/uni-app-view.umd.js
+++ b/packages/uni-app-plus/dist/uni-app-view.umd.js
@@ -4,9 +4,6 @@
"use strict";
var base = "* {\n margin: 0;\n -webkit-tap-highlight-color: rgba(0, 0, 0, 0);\n -webkit-tap-highlight-color: transparent;\n}\n\nhtml,\nbody {\n -webkit-user-select: none;\n user-select: none;\n width: 100%;\n}\n\nhtml {\n height: 100%;\n height: 100vh;\n width: 100%;\n width: 100vw;\n}\n\nbody {\n overflow-x: hidden;\n background-color: white;\n}\n\ninput[type='search']::-webkit-search-cancel-button {\n display: none;\n}\n\n.uni-loading,\nuni-button[loading]:before {\n background: transparent\n url('data:image/svg+xml;base64, PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMjAiIGhlaWdodD0iMTIwIiB2aWV3Qm94PSIwIDAgMTAwIDEwMCI+PHBhdGggZmlsbD0ibm9uZSIgZD0iTTAgMGgxMDB2MTAwSDB6Ii8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTlFOUU5IiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDAgLTMwKSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iIzk4OTY5NyIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgzMCAxMDUuOTggNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjOUI5OTlBIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKDYwIDc1Ljk4IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0EzQTFBMiIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSg5MCA2NSA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNBQkE5QUEiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoMTIwIDU4LjY2IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0IyQjJCMiIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgxNTAgNTQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjQkFCOEI5IiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKDE4MCA1MCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDMkMwQzEiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTE1MCA0NS45OCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDQkNCQ0IiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTEyMCA0MS4zNCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNEMkQyRDIiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTkwIDM1IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0RBREFEQSIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgtNjAgMjQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTJFMkUyIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKC0zMCAtNS45OCA2NSkiLz48L3N2Zz4=')\n no-repeat;\n}\n\n.uni-loading {\n width: 20px;\n height: 20px;\n display: inline-block;\n vertical-align: middle;\n animation: uni-loading 1s steps(12, end) infinite;\n background-size: 100%;\n}\n\n@keyframes uni-loading {\n 0% {\n transform: rotate3d(0, 0, 1, 0deg);\n }\n\n 100% {\n transform: rotate3d(0, 0, 1, 360deg);\n }\n}\n";
var nvue = "[nvue] uni-view,\n[nvue] uni-label,\n[nvue] uni-swiper-item,\n[nvue] uni-scroll-view {\n display: flex;\n flex-shrink: 0;\n flex-grow: 0;\n flex-basis: auto;\n align-items: stretch;\n align-content: flex-start;\n}\n\n[nvue] uni-button {\n margin: 0;\n}\n\n[nvue-dir-row] uni-view,\n[nvue-dir-row] uni-label,\n[nvue-dir-row] uni-swiper-item {\n flex-direction: row;\n}\n\n[nvue-dir-column] uni-view,\n[nvue-dir-column] uni-label,\n[nvue-dir-column] uni-swiper-item {\n flex-direction: column;\n}\n\n[nvue-dir-row-reverse] uni-view,\n[nvue-dir-row-reverse] uni-label,\n[nvue-dir-row-reverse] uni-swiper-item {\n flex-direction: row-reverse;\n}\n\n[nvue-dir-column-reverse] uni-view,\n[nvue-dir-column-reverse] uni-label,\n[nvue-dir-column-reverse] uni-swiper-item {\n flex-direction: column-reverse;\n}\n\n[nvue] uni-view,\n[nvue] uni-image,\n[nvue] uni-input,\n[nvue] uni-scroll-view,\n[nvue] uni-swiper,\n[nvue] uni-swiper-item,\n[nvue] uni-text,\n[nvue] uni-textarea,\n[nvue] uni-video {\n position: relative;\n border: 0px solid #000000;\n box-sizing: border-box;\n}\n\n[nvue] uni-swiper-item {\n position: absolute;\n}\n";
- const VD_SYNC = "vdSync";
- const ON_WEBVIEW_READY = "onWebviewReady";
- const INVOKE_API = "invokeApi";
function makeMap$1(str, expectsLowerCase) {
const map = Object.create(null);
const list2 = str.split(",");
@@ -684,6 +681,87 @@
};
}
const ViewJSBridge = /* @__PURE__ */ initBridge("service");
+ const LONGPRESS_TIMEOUT = 350;
+ const LONGPRESS_THRESHOLD = 10;
+ const passiveOptions$2 = passive(true);
+ let longPressTimer = 0;
+ function clearLongPressTimer() {
+ if (longPressTimer) {
+ clearTimeout(longPressTimer);
+ longPressTimer = 0;
+ }
+ }
+ let startPageX = 0;
+ let startPageY = 0;
+ function touchstart(evt) {
+ clearLongPressTimer();
+ if (evt.touches.length !== 1) {
+ return;
+ }
+ const { pageX, pageY } = evt.touches[0];
+ startPageX = pageX;
+ startPageY = pageY;
+ longPressTimer = setTimeout(function() {
+ const customEvent = new CustomEvent("longpress", {
+ bubbles: true,
+ cancelable: true,
+ target: evt.target,
+ currentTarget: evt.currentTarget
+ });
+ customEvent.touches = evt.touches;
+ customEvent.changedTouches = evt.changedTouches;
+ evt.target.dispatchEvent(customEvent);
+ }, LONGPRESS_TIMEOUT);
+ }
+ function touchmove(evt) {
+ if (!longPressTimer) {
+ return;
+ }
+ if (evt.touches.length !== 1) {
+ return clearLongPressTimer();
+ }
+ const { pageX, pageY } = evt.touches[0];
+ if (Math.abs(pageX - startPageX) > LONGPRESS_THRESHOLD || Math.abs(pageY - startPageY) > LONGPRESS_THRESHOLD) {
+ return clearLongPressTimer();
+ }
+ }
+ function initLongPress() {
+ window.addEventListener("touchstart", touchstart, passiveOptions$2);
+ window.addEventListener("touchmove", touchmove, passiveOptions$2);
+ window.addEventListener("touchend", clearLongPressTimer, passiveOptions$2);
+ window.addEventListener("touchcancel", clearLongPressTimer, passiveOptions$2);
+ }
+ function checkValue$1(value, defaultValue) {
+ const newValue = Number(value);
+ return isNaN(newValue) ? defaultValue : newValue;
+ }
+ function getWindowWidth() {
+ const screenFix = /^Apple/.test(navigator.vendor) && typeof window.orientation === "number";
+ const landscape = screenFix && Math.abs(window.orientation) === 90;
+ var screenWidth = screenFix ? Math[landscape ? "max" : "min"](screen.width, screen.height) : screen.width;
+ var windowWidth = Math.min(window.innerWidth, document.documentElement.clientWidth, screenWidth) || screenWidth;
+ return windowWidth;
+ }
+ function useRem() {
+ function updateRem() {
+ const config = __uniConfig.globalStyle || {};
+ const maxWidth = checkValue$1(config.rpxCalcMaxDeviceWidth, 960);
+ const baseWidth = checkValue$1(config.rpxCalcBaseDeviceWidth, 375);
+ let width = getWindowWidth();
+ width = width <= maxWidth ? width : baseWidth;
+ document.documentElement.style.fontSize = width / 23.4375 + "px";
+ }
+ updateRem();
+ document.addEventListener("DOMContentLoaded", updateRem);
+ window.addEventListener("load", updateRem);
+ window.addEventListener("resize", updateRem);
+ }
+ function initView() {
+ useRem();
+ {
+ initLongPress();
+ }
+ }
const targetMap = new WeakMap();
const effectStack = [];
let activeEffect;
@@ -3061,7 +3139,7 @@
}
const { type, ref: ref2, shapeFlag } = n2;
switch (type) {
- case Text$1:
+ case Text:
processText(n1, n2, container, anchor);
break;
case Comment$1:
@@ -3883,7 +3961,7 @@
const isTeleport = (type) => type.__isTeleport;
const NULL_DYNAMIC_COMPONENT = Symbol();
const Fragment = Symbol(void 0);
- const Text$1 = Symbol(void 0);
+ const Text = Symbol(void 0);
const Comment$1 = Symbol(void 0);
const Static = Symbol(void 0);
const blockStack = [];
@@ -4019,7 +4097,7 @@
return cloned;
}
function createTextVNode(text2 = " ", flag = 0) {
- return createVNode(Text$1, null, text2, flag);
+ return createVNode(Text, null, text2, flag);
}
function normalizeVNode(child) {
if (child == null || typeof child === "boolean") {
@@ -4029,7 +4107,7 @@
} else if (typeof child === "object") {
return cloneIfMounted(child);
} else {
- return createVNode(Text$1, null, String(child));
+ return createVNode(Text, null, String(child));
}
}
function cloneIfMounted(child) {
@@ -5360,6 +5438,9 @@
}
return res;
}
+ const VD_SYNC = "vdSync";
+ const ON_WEBVIEW_READY = "onWebviewReady";
+ const INVOKE_API = "invokeApi";
const APP_SERVICE_ID = "__uniapp__service";
const UniViewJSBridge$1 = /* @__PURE__ */ extend(ViewJSBridge, {
publishHandler
@@ -5381,322 +5462,408 @@
}
}, APP_SERVICE_ID);
}
- 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;
- const ACTION_TYPE_EVENT = 20;
- class UniNode {
- constructor(id2, tag) {
- this.id = id2;
- this.tag = tag;
+ function validateProtocolFail(name, msg) {
+ console.warn(`${name}: ${msg}`);
+ }
+ function validateProtocol(name, data, protocol, onFail) {
+ if (!onFail) {
+ onFail = validateProtocolFail;
}
- init(nodeJson) {
- if (hasOwn$1(nodeJson, "t")) {
- this.$.textContent = nodeJson.t || "";
+ for (const key in protocol) {
+ const errMsg = validateProp(key, data[key], protocol[key], !hasOwn$1(data, key));
+ if (isString(errMsg)) {
+ onFail(name, errMsg);
}
}
- setText(text2) {
- this.$.textContent = text2;
+ }
+ function validateProtocols(name, args, protocol, onFail) {
+ if (!protocol) {
+ return;
}
- insert(parentNodeId, refNodeId, nodeJson) {
- this.init(nodeJson);
- const node = this.$;
- const parentNode = $(parentNodeId).$;
- if (refNodeId === -1) {
- parentNode.appendChild(node);
- } else {
- parentNode.insertBefore(node, $(refNodeId).$);
- }
+ if (!isArray(protocol)) {
+ return validateProtocol(name, args[0] || Object.create(null), protocol, onFail);
}
- remove() {
- const { $: $2 } = this;
- $2.parentNode.removeChild($2);
+ const len = protocol.length;
+ const argsLen = args.length;
+ for (let i = 0; i < len; i++) {
+ const opts = protocol[i];
+ const data = Object.create(null);
+ if (argsLen > i) {
+ data[opts.name] = args[i];
+ }
+ validateProtocol(name, data, { [opts.name]: opts }, onFail);
}
}
- class UniComment extends UniNode {
- constructor(id2) {
- super(id2, "#comment");
- this.$ = document.createComment("");
+ function validateProp(name, value, prop, isAbsent) {
+ if (!isPlainObject(prop)) {
+ prop = { type: prop };
}
- }
- class UniTextNode extends UniNode {
- constructor(id2) {
- super(id2, "#text");
- this.$ = document.createTextNode("");
+ const { type, required, validator } = prop;
+ if (required && isAbsent) {
+ return 'Missing required args: "' + name + '"';
}
- }
- var view = "uni-view {\n display: block;\n}\nuni-view[hidden] {\n display: none;\n}\n";
- function patchClass(el, clazz) {
- el.className = clazz;
- }
- function patchStyle(el, value) {
- const style = el.style;
- if (isString(value)) {
- if (value === "") {
- el.removeAttribute("style");
- } else {
- style.cssText = rpx2px$1(value, true);
+ if (value == null && !required) {
+ return;
+ }
+ if (type != null) {
+ let isValid = false;
+ const types = isArray(type) ? type : [type];
+ const expectedTypes = [];
+ for (let i = 0; i < types.length && !isValid; i++) {
+ const { valid, expectedType } = assertType(value, types[i]);
+ expectedTypes.push(expectedType || "");
+ isValid = valid;
}
- } else {
- for (const key in value) {
- setStyle(style, key, value[key]);
+ if (!isValid) {
+ return getInvalidTypeMessage(name, value, expectedTypes);
}
}
+ if (validator) {
+ return validator(value);
+ }
}
- const importantRE = /\s*!important$/;
- function setStyle(style, name, val) {
- if (isArray(val)) {
- val.forEach((v2) => setStyle(style, name, v2));
+ const isSimpleType = /* @__PURE__ */ makeMap$1("String,Number,Boolean,Function,Symbol");
+ function assertType(value, type) {
+ let valid;
+ const expectedType = getType(type);
+ if (isSimpleType(expectedType)) {
+ const t2 = typeof value;
+ valid = t2 === expectedType.toLowerCase();
+ if (!valid && t2 === "object") {
+ valid = value instanceof type;
+ }
+ } else if (expectedType === "Object") {
+ valid = isObject$1(value);
+ } else if (expectedType === "Array") {
+ valid = isArray(value);
} else {
- val = rpx2px$1(val, true);
- if (name.startsWith("--")) {
- style.setProperty(name, val);
- } else {
- const prefixed = autoPrefix(style, name);
- if (importantRE.test(val)) {
- style.setProperty(hyphenate(prefixed), val.replace(importantRE, ""), "important");
- } else {
- style[prefixed] = val;
- }
+ {
+ valid = value instanceof type || toRawType(value) === getType(type);
}
}
+ return {
+ valid,
+ expectedType
+ };
}
- const prefixes = ["Webkit"];
- const prefixCache = {};
- function autoPrefix(style, rawName) {
- const cached = prefixCache[rawName];
- if (cached) {
- return cached;
+ function getInvalidTypeMessage(name, value, expectedTypes) {
+ let message = `Invalid args: type check failed for args "${name}". Expected ${expectedTypes.map(capitalize).join(", ")}`;
+ const expectedType = expectedTypes[0];
+ const receivedType = toRawType(value);
+ const expectedValue = styleValue(value, expectedType);
+ const receivedValue = styleValue(value, receivedType);
+ if (expectedTypes.length === 1 && isExplicable(expectedType) && !isBoolean(expectedType, receivedType)) {
+ message += ` with value ${expectedValue}`;
}
- let name = camelize(rawName);
- if (name !== "filter" && name in style) {
- return prefixCache[rawName] = name;
+ message += `, got ${receivedType} `;
+ if (isExplicable(receivedType)) {
+ message += `with value ${receivedValue}.`;
}
- name = capitalize(name);
- for (let i = 0; i < prefixes.length; i++) {
- const prefixed = prefixes[i] + name;
- if (prefixed in style) {
- return prefixCache[rawName] = prefixed;
- }
+ return message;
+ }
+ function getType(ctor) {
+ const match = ctor && ctor.toString().match(/^\s*function (\w+)/);
+ return match ? match[1] : "";
+ }
+ function styleValue(value, type) {
+ if (type === "String") {
+ return `"${value}"`;
+ } else if (type === "Number") {
+ return `${Number(value)}`;
+ } else {
+ return `${value}`;
}
- return rawName;
}
- function patchEvent(el, name, flag) {
- const [type, options] = parseEventName(decodeAttr(name));
- if (flag === -1) {
- const listener = el.__listeners[type];
- if (listener) {
- el.removeEventListener(type, listener);
+ function isExplicable(type) {
+ const explicitTypes = ["string", "number", "boolean"];
+ return explicitTypes.some((elem) => type.toLowerCase() === elem);
+ }
+ function isBoolean(...args) {
+ return args.some((elem) => elem.toLowerCase() === "boolean");
+ }
+ function formatApiArgs(args, options) {
+ const params = args[0];
+ if (!options || !isPlainObject(options.formatArgs) && isPlainObject(params)) {
+ return;
+ }
+ const formatArgs = options.formatArgs;
+ const keys = Object.keys(formatArgs);
+ for (let i = 0; i < keys.length; i++) {
+ const name = keys[i];
+ const formatterOrDefaultValue = formatArgs[name];
+ if (isFunction(formatterOrDefaultValue)) {
+ const errMsg = formatterOrDefaultValue(args[0][name], params);
+ if (isString(errMsg)) {
+ return errMsg;
+ }
} else {
- console.error(formatLog(`tag`, el.tagName, el.__id, "event[" + type + "] not found"));
- }
- } else {
- if (el.__listeners[type]) {
- {
- console.error(formatLog(`tag`, el.tagName, el.__id, "event[" + type + "] already registered"));
+ if (!hasOwn$1(params, name)) {
+ params[name] = formatterOrDefaultValue;
}
- return;
}
- el.__listeners[type] = createInvoker(el.__id, flag, options);
- el.addEventListener(type, el.__listeners[type], options);
}
}
- function createInvoker(id2, flag, options) {
- const invoker = (evt) => {
- const event = $nne(evt);
- event.type = normalizeEventType(evt.type, options);
- UniViewJSBridge.publishHandler(VD_SYNC, [[ACTION_TYPE_EVENT, id2, event]]);
- };
- if (!flag) {
- return invoker;
+ function beforeInvokeApi(name, args, protocol, options) {
+ {
+ validateProtocols(name, args, protocol);
}
- return withModifiers(invoker, resolveModifier(flag));
- }
- function resolveModifier(flag) {
- const modifiers = [];
- if (flag & EventModifierFlags.prevent) {
- modifiers.push("prevent");
+ if (options && options.beforeInvoke) {
+ const errMsg2 = options.beforeInvoke(args);
+ if (isString(errMsg2)) {
+ return errMsg2;
+ }
}
- if (flag & EventModifierFlags.self) {
- modifiers.push("self");
+ const errMsg = formatApiArgs(args, options);
+ if (errMsg) {
+ return errMsg;
}
- if (flag & EventModifierFlags.stop) {
- modifiers.push("stop");
+ }
+ function wrapperSyncApi(name, fn, protocol, options) {
+ return (...args) => {
+ const errMsg = beforeInvokeApi(name, args, protocol, options);
+ if (errMsg) {
+ throw new Error(errMsg);
+ }
+ return fn.apply(null, args);
+ };
+ }
+ function defineSyncApi(name, fn, protocol, options) {
+ return wrapperSyncApi(name, fn, protocol, options);
+ }
+ function getBaseSystemInfo() {
+ if (typeof __SYSTEM_INFO__ !== "undefined") {
+ return window.__SYSTEM_INFO__;
}
- return modifiers;
+ const { resolutionWidth } = plus.screen.getCurrentSize();
+ return {
+ platform: (plus.os.name || "").toLowerCase(),
+ pixelRatio: plus.screen.scale,
+ windowWidth: Math.round(resolutionWidth)
+ };
}
- class UniElement extends UniNode {
- constructor(id2, element) {
- super(id2, element.tagName);
- this.$ = element;
- this.$.__id = id2;
- this.$.__listeners = Object.create(null);
+ function getRealPath(filepath) {
+ if (filepath.indexOf("//") === 0) {
+ return "https:" + filepath;
}
- init(nodeJson) {
- super.init(nodeJson);
- if (hasOwn$1(nodeJson, "a")) {
- this.setAttrs(nodeJson.a);
- }
+ if (SCHEME_RE.test(filepath) || DATA_RE.test(filepath)) {
+ return filepath;
}
- setAttrs(attrs2) {
- Object.keys(attrs2).forEach((name) => {
- this.setAttr(name, attrs2[name]);
- });
+ if (isSystemURL(filepath)) {
+ return "file://" + normalizeLocalPath(filepath);
}
- setAttr(name, value) {
- if (name === ".c") {
- patchClass(this.$, value);
- } else if (name === ".s") {
- patchStyle(this.$, value);
- } else if (name.indexOf(".e") === 0) {
- patchEvent(this.$, name, value);
- } else {
- this.$.setAttribute(decodeAttr(name), value);
+ const wwwPath = "file://" + normalizeLocalPath("_www");
+ if (filepath.indexOf("/") === 0) {
+ if (filepath.startsWith("/storage/") || filepath.includes("/Containers/Data/Application/")) {
+ return "file://" + filepath;
}
+ return wwwPath + filepath;
}
- removeAttr(name) {
- if (name === ".c") {
- patchClass(this.$, "");
- } else if (name === ".s") {
- patchStyle(this.$, "");
- } else if (name.indexOf(".e") === 0) {
- patchEvent(this.$, name, -1);
+ if (filepath.indexOf("../") === 0 || filepath.indexOf("./") === 0) {
+ if (typeof __id__ === "string") {
+ return wwwPath + getRealRoute("/" + __id__, filepath);
} else {
- this.$.removeAttribute(decodeAttr(name));
+ const pages = getCurrentPages();
+ if (pages.length) {
+ return wwwPath + getRealRoute("/" + pages[pages.length - 1].route, filepath);
+ }
}
}
+ return filepath;
}
- function isHoverAttr(name) {
- return name.indexOf(".h") === 0;
- }
- class UniHoverElement extends UniElement {
- setAttr(name, value) {
- if (!isHoverAttr(name)) {
- return super.setAttr(name, value);
- }
- name = camelize(decodeAttr(name));
- if (!this._hover) {
- this._hover = new Hover(this.$);
- }
- const { _hover } = this;
- _hover[name] = value;
- if (name !== "hoverClass") {
- return;
- }
- if (_hover.hoverClass && _hover.hoverClass !== "none") {
- _hover.addEvent();
- } else {
- _hover.removeEvent();
- }
+ const normalizeLocalPath = cacheStringFunction((filepath) => {
+ return plus.io.convertLocalFileSystemURL(filepath).replace(/^\/?apps\//, "/android_asset/apps/").replace(/\/$/, "");
+ });
+ function isSystemURL(filepath) {
+ if (filepath.indexOf("_www") === 0 || filepath.indexOf("_doc") === 0 || filepath.indexOf("_documents") === 0 || filepath.indexOf("_downloads") === 0) {
+ return true;
}
- removeAttr(name) {
- if (!isHoverAttr(name)) {
- return super.removeAttr(name);
- }
+ return false;
+ }
+ function saveImage(base64, dirname, callback) {
+ }
+ function getSameOriginUrl(url) {
+ return Promise.resolve(url);
+ }
+ const API_UPX2PX = "upx2px";
+ const Upx2pxProtocol = [
+ {
+ name: "upx",
+ type: [Number, String],
+ required: true
}
+ ];
+ const EPS = 1e-4;
+ const BASE_DEVICE_WIDTH = 750;
+ let isIOS = false;
+ let deviceWidth = 0;
+ let deviceDPR = 0;
+ function checkDeviceWidth() {
+ const { platform, pixelRatio: pixelRatio2, windowWidth } = getBaseSystemInfo();
+ deviceWidth = windowWidth;
+ deviceDPR = pixelRatio2;
+ isIOS = platform === "ios";
}
- class Hover {
- constructor($2) {
- this.hoverClass = "none";
- this.hoverStopPropagation = false;
- this.hoverStartTime = 50;
- this.hoverStayTime = 400;
- this._listening = false;
- this._hovering = false;
- this._hoverTouch = false;
- this._hoverStartTimer = 0;
- this._hoverStayTimer = 0;
- this.$ = $2;
- this.__hoverTouchStart = this._hoverTouchStart.bind(this);
- this.__hoverTouchEnd = this._hoverTouchEnd.bind(this);
- this.__hoverTouchCancel = this._hoverTouchCancel.bind(this);
+ function checkValue(value, defaultValue) {
+ const newValue = Number(value);
+ return isNaN(newValue) ? defaultValue : newValue;
+ }
+ const upx2px = /* @__PURE__ */ defineSyncApi(API_UPX2PX, (number, newDeviceWidth) => {
+ if (deviceWidth === 0) {
+ checkDeviceWidth();
}
- get hovering() {
- return this._hovering;
+ number = Number(number);
+ if (number === 0) {
+ return 0;
}
- set hovering(hovering) {
- this._hovering = hovering;
- if (hovering) {
- this.$.classList.add(this.hoverClass);
- } else {
- this.$.classList.remove(this.hoverClass);
- }
+ let width = newDeviceWidth || deviceWidth;
+ {
+ const config = __uniConfig.globalStyle || {};
+ const maxWidth = checkValue(config.rpxCalcMaxDeviceWidth, 960);
+ const baseWidth = checkValue(config.rpxCalcBaseDeviceWidth, 375);
+ width = width <= maxWidth ? width : baseWidth;
}
- addEvent() {
- if (this._listening) {
- return;
- }
- {
- console.log(formatLog(this.$.tagName, "Hover", "addEventListener", this.hoverClass));
- }
- this._listening = true;
- this.$.addEventListener("touchstart", this.__hoverTouchStart);
- this.$.addEventListener("touchend", this.__hoverTouchEnd);
- this.$.addEventListener("touchcancel", this.__hoverTouchCancel);
+ let result = number / BASE_DEVICE_WIDTH * width;
+ if (result < 0) {
+ result = -result;
}
- removeEvent() {
- if (!this._listening) {
- return;
- }
- {
- console.log(formatLog(this.$.tagName, "Hover", "removeEventListener"));
+ result = Math.floor(result + EPS);
+ if (result === 0) {
+ if (deviceDPR === 1 || !isIOS) {
+ result = 1;
+ } else {
+ result = 0.5;
}
- this._listening = false;
- this.$.removeEventListener("touchstart", this.__hoverTouchStart);
- this.$.removeEventListener("touchend", this.__hoverTouchEnd);
- this.$.removeEventListener("touchcancel", this.__hoverTouchCancel);
}
- _hoverTouchStart(evt) {
- if (evt._hoverPropagationStopped) {
- return;
- }
- if (!this.hoverClass || this.hoverClass === "none" || this.$.disabled) {
- return;
- }
- if (evt.touches.length > 1) {
- return;
- }
- if (this.hoverStopPropagation) {
- evt._hoverPropagationStopped = true;
- }
- this._hoverTouch = true;
- this._hoverStartTimer = setTimeout(() => {
- this.hovering = true;
- if (!this._hoverTouch) {
- this._hoverReset();
+ return number < 0 ? -result : result;
+ }, Upx2pxProtocol);
+ createCallbacks("canvasEvent");
+ createCallbacks("getSelectedTextRangeEvent");
+ ({
+ beforeInvoke() {
+ initI18nShowModalMsgsOnce();
+ },
+ formatArgs: {
+ title: "",
+ content: "",
+ showCancel: true,
+ cancelText(_value, params) {
+ if (!hasOwn$1(params, "cancelText")) {
+ const { t: t2 } = useI18n();
+ params.cancelText = t2("uni.showModal.cancel");
+ }
+ },
+ cancelColor: "#000",
+ confirmText(_value, params) {
+ if (!hasOwn$1(params, "confirmText")) {
+ const { t: t2 } = useI18n();
+ params.confirmText = t2("uni.showModal.confirm");
}
- }, this.hoverStartTime);
+ },
+ confirmColor: PRIMARY_COLOR
}
- _hoverTouchEnd() {
- this._hoverTouch = false;
- if (this.hovering) {
- this._hoverReset();
+ });
+ function invokeApi(method, args = {}) {
+ UniViewJSBridge.publishHandler(INVOKE_API, {
+ data: {
+ method,
+ args
+ },
+ options: {
+ timestamp: Date.now()
}
- }
- _hoverReset() {
- requestAnimationFrame(() => {
- clearTimeout(this._hoverStayTimer);
- this._hoverStayTimer = setTimeout(() => {
- this.hovering = false;
- }, this.hoverStayTime);
- });
- }
- _hoverTouchCancel() {
- this._hoverTouch = false;
- this.hovering = false;
- clearTimeout(this._hoverStartTimer);
+ });
+ }
+ function navigateTo(args) {
+ invokeApi("navigateTo", args);
+ }
+ function navigateBack(args) {
+ invokeApi("navigateBack", args);
+ }
+ function reLaunch(args) {
+ invokeApi("reLaunch", args);
+ }
+ function redirectTo(args) {
+ invokeApi("redirectTo", args);
+ }
+ function switchTab(args) {
+ invokeApi("switchTab", args);
+ }
+ var uni$1 = /* @__PURE__ */ Object.freeze({
+ __proto__: null,
+ [Symbol.toStringTag]: "Module",
+ upx2px,
+ navigateTo,
+ navigateBack,
+ reLaunch,
+ redirectTo,
+ switchTab
+ });
+ function preventDoubleTap() {
+ if (String(navigator.vendor).indexOf("Apple") === 0) {
+ let firstEvent = null;
+ let timeout;
+ document.documentElement.addEventListener("click", (event) => {
+ const TIME_MAX = 450;
+ const PAGE_MAX = 44;
+ clearTimeout(timeout);
+ if (firstEvent && Math.abs(event.pageX - firstEvent.pageX) <= PAGE_MAX && Math.abs(event.pageY - firstEvent.pageY) <= PAGE_MAX && event.timeStamp - firstEvent.timeStamp <= TIME_MAX) {
+ event.preventDefault();
+ }
+ firstEvent = event;
+ timeout = setTimeout(() => {
+ firstEvent = null;
+ }, TIME_MAX);
+ });
}
}
- class UniViewElement extends UniHoverElement {
+ 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;
+ const ACTION_TYPE_EVENT = 20;
+ class UniNode {
+ constructor(id2, tag) {
+ this.isMounted = false;
+ this.isUnmounted = false;
+ this.id = id2;
+ this.tag = tag;
+ }
+ init(nodeJson) {
+ if (hasOwn$1(nodeJson, "t")) {
+ this.$.textContent = nodeJson.t || "";
+ }
+ }
+ setText(text2) {
+ this.$.textContent = text2;
+ }
+ insert(parentNodeId, refNodeId, nodeJson) {
+ this.init(nodeJson);
+ const node = this.$;
+ const parentNode = $(parentNodeId).$;
+ if (refNodeId === -1) {
+ parentNode.appendChild(node);
+ } else {
+ parentNode.insertBefore(node, $(refNodeId).$);
+ }
+ this.isMounted = true;
+ }
+ remove() {
+ const { $: $2 } = this;
+ $2.parentNode.removeChild($2);
+ this.isUnmounted = false;
+ }
+ }
+ class UniComment extends UniNode {
constructor(id2) {
- super(id2, document.createElement("uni-view"));
+ super(id2, "#comment");
+ this.$ = document.createComment("");
}
}
+ var text$1 = "uni-text[selectable] {\n cursor: auto;\n -webkit-user-select: text;\n user-select: text;\n}\n";
var subscriber = {
mounted() {
this._toggleListeners("subscribe", this.id);
@@ -6421,60 +6588,6 @@
});
feedback.show("slide-in-right");
}
- function getBaseSystemInfo() {
- if (typeof __SYSTEM_INFO__ !== "undefined") {
- return window.__SYSTEM_INFO__;
- }
- const { resolutionWidth } = plus.screen.getCurrentSize();
- return {
- platform: (plus.os.name || "").toLowerCase(),
- pixelRatio: plus.screen.scale,
- windowWidth: Math.round(resolutionWidth)
- };
- }
- function getRealPath(filepath) {
- if (filepath.indexOf("//") === 0) {
- return "https:" + filepath;
- }
- if (SCHEME_RE.test(filepath) || DATA_RE.test(filepath)) {
- return filepath;
- }
- if (isSystemURL(filepath)) {
- return "file://" + normalizeLocalPath(filepath);
- }
- const wwwPath = "file://" + normalizeLocalPath("_www");
- if (filepath.indexOf("/") === 0) {
- if (filepath.startsWith("/storage/") || filepath.includes("/Containers/Data/Application/")) {
- return "file://" + filepath;
- }
- return wwwPath + filepath;
- }
- if (filepath.indexOf("../") === 0 || filepath.indexOf("./") === 0) {
- if (typeof __id__ === "string") {
- return wwwPath + getRealRoute("/" + __id__, filepath);
- } else {
- const pages = getCurrentPages();
- if (pages.length) {
- return wwwPath + getRealRoute("/" + pages[pages.length - 1].route, filepath);
- }
- }
- }
- return filepath;
- }
- const normalizeLocalPath = cacheStringFunction((filepath) => {
- return plus.io.convertLocalFileSystemURL(filepath).replace(/^\/?apps\//, "/android_asset/apps/").replace(/\/$/, "");
- });
- function isSystemURL(filepath) {
- if (filepath.indexOf("_www") === 0 || filepath.indexOf("_doc") === 0 || filepath.indexOf("_documents") === 0 || filepath.indexOf("_downloads") === 0) {
- return true;
- }
- return false;
- }
- function saveImage(base64, dirname, callback) {
- }
- function getSameOriginUrl(url) {
- return Promise.resolve(url);
- }
var ResizeSensor = /* @__PURE__ */ defineBuiltInComponent({
name: "ResizeSensor",
props: {
@@ -7870,7 +7983,7 @@
});
return result;
}
- function text$1(Quill) {
+ function text(Quill) {
const { Scope, Attributor } = Quill.import("parchment");
const text2 = [
{
@@ -7940,7 +8053,7 @@
background,
box,
font,
- text: text$1,
+ text,
image: image$1
};
const options = {};
@@ -13603,18 +13716,20 @@
}
return uniLabel;
}
- function _isSlot(s) {
- return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
- }
const SPACE_UNICODE = {
ensp: "\u2002",
emsp: "\u2003",
nbsp: "\xA0"
};
- function normalizeText(text2, {
- space,
- decode
- }) {
+ function parseText(text2, options) {
+ return text2.replace(/\\n/g, "\n").split("\n").map((text22) => {
+ return normalizeText(text22, options);
+ });
+ }
+ function normalizeText(text2, { space, decode }) {
+ if (!text2) {
+ return text2;
+ }
if (space && SPACE_UNICODE[space]) {
text2 = text2.replace(/ /g, SPACE_UNICODE[space]);
}
@@ -13623,63 +13738,6 @@
}
return text2.replace(/ /g, SPACE_UNICODE.nbsp).replace(/ /g, SPACE_UNICODE.ensp).replace(/ /g, SPACE_UNICODE.emsp).replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&").replace(/"/g, '"').replace(/'/g, "'");
}
- var Text = /* @__PURE__ */ defineBuiltInComponent({
- name: "Text",
- props: {
- selectable: {
- type: [Boolean, String],
- default: false
- },
- space: {
- type: String,
- default: ""
- },
- decode: {
- type: [Boolean, String],
- default: false
- }
- },
- setup(props2, {
- slots
- }) {
- return () => {
- let _slot;
- const children = [];
- if (slots.default) {
- slots.default().forEach((vnode) => {
- if (vnode.shapeFlag & 8) {
- const lines = vnode.children.replace(/\\n/g, "\n").split("\n");
- const len = lines.length - 1;
- lines.forEach((text2, index2) => {
- if (index2 === 0 && !text2)
- ;
- else {
- children.push(createTextVNode(normalizeText(text2, {
- space: props2.space,
- decode: props2.decode
- })));
- }
- if (index2 !== len) {
- children.push(createVNode("br"));
- }
- });
- } else {
- if (vnode.shapeFlag & 6 && vnode.type.name !== "Text") {
- console.warn("Do not nest other components in the text component, as there may be display differences on different platforms.");
- }
- children.push(vnode);
- }
- });
- }
- return createVNode("uni-text", {
- "selectable": props2.selectable ? true : null
- }, _isSlot(_slot = createVNode("span", null, children)) ? _slot : {
- default: () => [_slot],
- _: 1
- }, 8, ["selectable"]);
- };
- }
- });
const props$2 = /* @__PURE__ */ extend({}, props$h, {
placeholderClass: {
type: String,
@@ -13740,169 +13798,499 @@
}) {
heightRef.value = height;
}
- function confirm(event) {
- trigger2("confirm", event, {
- value: state.value
- });
+ function confirm(event) {
+ trigger2("confirm", event, {
+ value: state.value
+ });
+ }
+ function onKeyDownEnter(event) {
+ if (event.key !== "Enter") {
+ return;
+ }
+ if (isDone.value) {
+ event.preventDefault();
+ }
+ }
+ function onKeyUpEnter(event) {
+ if (event.key !== "Enter") {
+ return;
+ }
+ if (isDone.value) {
+ confirm(event);
+ const textarea2 = event.target;
+ textarea2.blur();
+ }
+ }
+ {
+ setFixMargin();
+ }
+ return () => {
+ let textareaNode = props2.disabled && fixDisabledColor ? createVNode("textarea", {
+ "ref": fieldRef,
+ "value": state.value,
+ "tabindex": "-1",
+ "readonly": !!props2.disabled,
+ "maxlength": state.maxlength,
+ "class": {
+ "uni-textarea-textarea": true,
+ "uni-textarea-textarea-fix-margin": fixMargin
+ },
+ "style": {
+ overflowY: props2.autoHeight ? "hidden" : "auto"
+ },
+ "onFocus": (event) => event.target.blur()
+ }, null, 46, ["value", "readonly", "maxlength", "onFocus"]) : createVNode("textarea", {
+ "ref": fieldRef,
+ "value": state.value,
+ "disabled": !!props2.disabled,
+ "maxlength": state.maxlength,
+ "enterkeyhint": props2.confirmType,
+ "class": {
+ "uni-textarea-textarea": true,
+ "uni-textarea-textarea-fix-margin": fixMargin
+ },
+ "style": {
+ overflowY: props2.autoHeight ? "hidden" : "auto"
+ },
+ "onKeydown": onKeyDownEnter,
+ "onKeyup": onKeyUpEnter
+ }, null, 46, ["value", "disabled", "maxlength", "enterkeyhint", "onKeydown", "onKeyup"]);
+ return createVNode("uni-textarea", {
+ "ref": rootRef
+ }, {
+ default: () => [createVNode("div", {
+ "class": "uni-textarea-wrapper"
+ }, [withDirectives(createVNode("div", mergeProps(scopedAttrsState.attrs, {
+ "style": props2.placeholderStyle,
+ "class": ["uni-textarea-placeholder", props2.placeholderClass]
+ }), [props2.placeholder], 16), [[vShow, !state.value.length]]), createVNode("div", {
+ "ref": lineRef,
+ "class": "uni-textarea-line"
+ }, [" "], 512), createVNode("div", {
+ "class": "uni-textarea-compute"
+ }, [valueCompute.value.map((item) => createVNode("div", null, [item.trim() ? item : "."])), createVNode(ResizeSensor, {
+ "initial": true,
+ "onResize": onResize
+ }, null, 8, ["initial", "onResize"])]), props2.confirmType === "search" ? createVNode("form", {
+ "action": "",
+ "onSubmit": () => false,
+ "class": "uni-input-form"
+ }, [textareaNode], 40, ["onSubmit"]) : textareaNode])]
+ }, 512);
+ };
+ }
+ });
+ /* @__PURE__ */ defineBuiltInComponent({
+ name: "View",
+ props: extend({}, hoverProps),
+ setup(props2, {
+ slots
+ }) {
+ const {
+ hovering,
+ binding
+ } = useHover(props2);
+ return () => {
+ const hoverClass = props2.hoverClass;
+ if (hoverClass && hoverClass !== "none") {
+ return createVNode("uni-view", mergeProps({
+ "class": hovering.value ? hoverClass : ""
+ }, binding), {
+ default: () => [slots.default && slots.default()]
+ }, 16, ["class"]);
+ }
+ return createVNode("uni-view", null, {
+ default: () => [slots.default && slots.default()]
+ });
+ };
+ }
+ });
+ function normalizeEvent(pageId2, vm, id2) {
+ if (!id2) {
+ id2 = vm.id;
+ }
+ if (!id2) {
+ return;
+ }
+ return pageId2 + "." + vm.$options.name.toLowerCase() + "." + id2;
+ }
+ function addSubscribe(name, callback) {
+ if (!name) {
+ return;
+ }
+ UniViewJSBridge.subscribe(name, ({ type, data }) => {
+ callback(type, data);
+ });
+ }
+ function removeSubscribe(name) {
+ if (!name) {
+ return;
+ }
+ UniViewJSBridge.unsubscribe(name);
+ }
+ function useSubscribe(callback, name, multiple) {
+ const instance = getCurrentInstance();
+ const vm = instance.proxy;
+ const pageId2 = multiple || !name ? useCurrentPageId() : 0;
+ onMounted(() => {
+ addSubscribe(name || normalizeEvent(pageId2, vm), callback);
+ if (multiple || !name) {
+ watch(() => vm.id, (value, oldValue) => {
+ addSubscribe(normalizeEvent(pageId2, vm, value), callback);
+ removeSubscribe(oldValue && normalizeEvent(pageId2, vm, oldValue));
+ });
+ }
+ });
+ onBeforeUnmount(() => {
+ removeSubscribe(name || normalizeEvent(pageId2, vm));
+ });
+ }
+ let index = 0;
+ function useContextInfo(_id) {
+ const page = useCurrentPageId();
+ const instance = getCurrentInstance();
+ const vm = instance.proxy;
+ const type = vm.$options.name.toLowerCase();
+ const id2 = _id || vm.id || `context${index++}`;
+ onMounted(() => {
+ const el = vm.$el;
+ el.__uniContextInfo = {
+ id: id2,
+ type,
+ page
+ };
+ });
+ return `${page}.${type}.${id2}`;
+ }
+ function patchClass(el, clazz) {
+ el.className = clazz;
+ }
+ function patchStyle(el, value) {
+ const style = el.style;
+ if (isString(value)) {
+ if (value === "") {
+ el.removeAttribute("style");
+ } else {
+ style.cssText = rpx2px$1(value, true);
+ }
+ } else {
+ for (const key in value) {
+ setStyle(style, key, value[key]);
+ }
+ }
+ }
+ const importantRE = /\s*!important$/;
+ function setStyle(style, name, val) {
+ if (isArray(val)) {
+ val.forEach((v2) => setStyle(style, name, v2));
+ } else {
+ val = rpx2px$1(val, true);
+ if (name.startsWith("--")) {
+ style.setProperty(name, val);
+ } else {
+ const prefixed = autoPrefix(style, name);
+ if (importantRE.test(val)) {
+ style.setProperty(hyphenate(prefixed), val.replace(importantRE, ""), "important");
+ } else {
+ style[prefixed] = val;
+ }
+ }
+ }
+ }
+ const prefixes = ["Webkit"];
+ const prefixCache = {};
+ function autoPrefix(style, rawName) {
+ const cached = prefixCache[rawName];
+ if (cached) {
+ return cached;
+ }
+ let name = camelize(rawName);
+ if (name !== "filter" && name in style) {
+ return prefixCache[rawName] = name;
+ }
+ name = capitalize(name);
+ for (let i = 0; i < prefixes.length; i++) {
+ const prefixed = prefixes[i] + name;
+ if (prefixed in style) {
+ return prefixCache[rawName] = prefixed;
+ }
+ }
+ return rawName;
+ }
+ function patchEvent(el, name, flag) {
+ const [type, options] = parseEventName(decodeAttr(name));
+ if (flag === -1) {
+ const listener = el.__listeners[type];
+ if (listener) {
+ el.removeEventListener(type, listener);
+ } else {
+ console.error(formatLog(`tag`, el.tagName, el.__id, "event[" + type + "] not found"));
+ }
+ } else {
+ if (el.__listeners[type]) {
+ {
+ console.error(formatLog(`tag`, el.tagName, el.__id, "event[" + type + "] already registered"));
+ }
+ return;
+ }
+ el.__listeners[type] = createInvoker(el.__id, flag, options);
+ el.addEventListener(type, el.__listeners[type], options);
+ }
+ }
+ function createInvoker(id2, flag, options) {
+ const invoker = (evt) => {
+ const event = $nne(evt);
+ event.type = normalizeEventType(evt.type, options);
+ UniViewJSBridge.publishHandler(VD_SYNC, [[ACTION_TYPE_EVENT, id2, event]]);
+ };
+ if (!flag) {
+ return invoker;
+ }
+ return withModifiers(invoker, resolveModifier(flag));
+ }
+ function resolveModifier(flag) {
+ const modifiers = [];
+ if (flag & EventModifierFlags.prevent) {
+ modifiers.push("prevent");
+ }
+ if (flag & EventModifierFlags.self) {
+ modifiers.push("self");
+ }
+ if (flag & EventModifierFlags.stop) {
+ modifiers.push("stop");
+ }
+ return modifiers;
+ }
+ const postActionJobs = new Set();
+ function queuePostActionJob(job) {
+ postActionJobs.add(job);
+ }
+ function flushPostActionJobs() {
+ {
+ console.log(formatLog(`flushPostActionJobs`, postActionJobs.size));
+ }
+ try {
+ postActionJobs.forEach((fn) => fn());
+ } finally {
+ postActionJobs.clear();
+ }
+ }
+ class UniElement extends UniNode {
+ constructor(id2, element, propNames = []) {
+ super(id2, element.tagName);
+ this.$props = reactive({});
+ this.$ = element;
+ this.$.__id = id2;
+ this.$.__listeners = Object.create(null);
+ this.$propNames = propNames;
+ this._update = this.update.bind(this);
+ }
+ init(nodeJson) {
+ if (hasOwn$1(nodeJson, "a")) {
+ this.setAttrs(nodeJson.a);
+ }
+ super.init(nodeJson);
+ watch(this.$props, () => {
+ queuePostActionJob(this._update);
+ }, { flush: "sync" });
+ this.update();
+ }
+ setAttrs(attrs2) {
+ Object.keys(attrs2).forEach((name) => {
+ this.setAttr(name, attrs2[name]);
+ });
+ }
+ setAttr(name, value) {
+ if (name === ".c") {
+ patchClass(this.$, value);
+ } else if (name === ".s") {
+ patchStyle(this.$, value);
+ } else if (name.indexOf(".e") === 0) {
+ patchEvent(this.$, name, value);
+ } else {
+ this.setAttribute(decodeAttr(name), value);
+ }
+ }
+ removeAttr(name) {
+ if (name === ".c") {
+ patchClass(this.$, "");
+ } else if (name === ".s") {
+ patchStyle(this.$, "");
+ } else if (name.indexOf(".e") === 0) {
+ patchEvent(this.$, name, -1);
+ } else {
+ this.removeAttribute(decodeAttr(name));
+ }
+ }
+ setAttribute(name, value) {
+ if (this.$propNames.indexOf(name) !== -1) {
+ this.$props[name] = value;
+ } else {
+ this.$.setAttribute(name, value);
+ }
+ }
+ removeAttribute(name) {
+ if (this.$propNames.indexOf(name) !== -1) {
+ delete this.$props[name];
+ } else {
+ this.$.removeAttribute(name);
}
- function onKeyDownEnter(event) {
- if (event.key !== "Enter") {
- return;
- }
- if (isDone.value) {
- event.preventDefault();
- }
+ }
+ update() {
+ }
+ }
+ const PROP_NAMES_HOVER$1 = ["space", "decode"];
+ class UniTextElement extends UniElement {
+ constructor(id2) {
+ super(id2, document.createElement("uni-text"), PROP_NAMES_HOVER$1);
+ this._text = "";
+ }
+ init(nodeJson) {
+ this._text = nodeJson.t || "";
+ super.init(nodeJson);
+ }
+ setText(text2) {
+ this._text = text2;
+ }
+ update() {
+ {
+ console.log(formatLog("Text", "update"));
}
- function onKeyUpEnter(event) {
- if (event.key !== "Enter") {
- return;
+ const {
+ $props: { space, decode }
+ } = this;
+ this.$.innerHTML = parseText(this._text, {
+ space,
+ decode
+ }).join("
");
+ }
+ }
+ class UniTextNode extends UniNode {
+ constructor(id2) {
+ super(id2, "#text");
+ this.$ = document.createTextNode("");
+ }
+ }
+ var view = "uni-view {\n display: block;\n}\nuni-view[hidden] {\n display: none;\n}\n";
+ const PROP_NAMES_HOVER = [
+ "hover-class",
+ "hover-stop-propagation",
+ "hover-start-time",
+ "hover-stay-time"
+ ];
+ class UniHoverElement extends UniElement {
+ constructor(id2, element, propNames = []) {
+ super(id2, element, [...PROP_NAMES_HOVER, ...propNames]);
+ }
+ update() {
+ const hoverClass = this.$props["hover-class"];
+ if (hoverClass && hoverClass !== "none") {
+ if (!this._hover) {
+ this._hover = new Hover(this.$, this.$props);
}
- if (isDone.value) {
- confirm(event);
- const textarea2 = event.target;
- textarea2.blur();
+ this._hover.addEvent();
+ } else {
+ if (this._hover) {
+ this._hover.removeEvent();
}
}
+ }
+ }
+ class Hover {
+ constructor($2, props2) {
+ this._listening = false;
+ this._hovering = false;
+ this._hoverTouch = false;
+ this._hoverStartTimer = 0;
+ this._hoverStayTimer = 0;
+ this.$ = $2;
+ this.props = props2;
+ this.__hoverTouchStart = this._hoverTouchStart.bind(this);
+ this.__hoverTouchEnd = this._hoverTouchEnd.bind(this);
+ this.__hoverTouchCancel = this._hoverTouchCancel.bind(this);
+ }
+ get hovering() {
+ return this._hovering;
+ }
+ set hovering(hovering) {
+ this._hovering = hovering;
+ const hoverClass = this.props["hover-class"];
+ if (hovering) {
+ this.$.classList.add(hoverClass);
+ } else {
+ this.$.classList.remove(hoverClass);
+ }
+ }
+ addEvent() {
+ if (this._listening) {
+ return;
+ }
{
- setFixMargin();
+ console.log(formatLog(this.$.tagName, "Hover", "addEventListener", this.props["hover-class"]));
}
- return () => {
- let textareaNode = props2.disabled && fixDisabledColor ? createVNode("textarea", {
- "ref": fieldRef,
- "value": state.value,
- "tabindex": "-1",
- "readonly": !!props2.disabled,
- "maxlength": state.maxlength,
- "class": {
- "uni-textarea-textarea": true,
- "uni-textarea-textarea-fix-margin": fixMargin
- },
- "style": {
- overflowY: props2.autoHeight ? "hidden" : "auto"
- },
- "onFocus": (event) => event.target.blur()
- }, null, 46, ["value", "readonly", "maxlength", "onFocus"]) : createVNode("textarea", {
- "ref": fieldRef,
- "value": state.value,
- "disabled": !!props2.disabled,
- "maxlength": state.maxlength,
- "enterkeyhint": props2.confirmType,
- "class": {
- "uni-textarea-textarea": true,
- "uni-textarea-textarea-fix-margin": fixMargin
- },
- "style": {
- overflowY: props2.autoHeight ? "hidden" : "auto"
- },
- "onKeydown": onKeyDownEnter,
- "onKeyup": onKeyUpEnter
- }, null, 46, ["value", "disabled", "maxlength", "enterkeyhint", "onKeydown", "onKeyup"]);
- return createVNode("uni-textarea", {
- "ref": rootRef
- }, {
- default: () => [createVNode("div", {
- "class": "uni-textarea-wrapper"
- }, [withDirectives(createVNode("div", mergeProps(scopedAttrsState.attrs, {
- "style": props2.placeholderStyle,
- "class": ["uni-textarea-placeholder", props2.placeholderClass]
- }), [props2.placeholder], 16), [[vShow, !state.value.length]]), createVNode("div", {
- "ref": lineRef,
- "class": "uni-textarea-line"
- }, [" "], 512), createVNode("div", {
- "class": "uni-textarea-compute"
- }, [valueCompute.value.map((item) => createVNode("div", null, [item.trim() ? item : "."])), createVNode(ResizeSensor, {
- "initial": true,
- "onResize": onResize
- }, null, 8, ["initial", "onResize"])]), props2.confirmType === "search" ? createVNode("form", {
- "action": "",
- "onSubmit": () => false,
- "class": "uni-input-form"
- }, [textareaNode], 40, ["onSubmit"]) : textareaNode])]
- }, 512);
- };
+ this._listening = true;
+ this.$.addEventListener("touchstart", this.__hoverTouchStart);
+ this.$.addEventListener("touchend", this.__hoverTouchEnd);
+ this.$.addEventListener("touchcancel", this.__hoverTouchCancel);
}
- });
- /* @__PURE__ */ defineBuiltInComponent({
- name: "View",
- props: extend({}, hoverProps),
- setup(props2, {
- slots
- }) {
- const {
- hovering,
- binding
- } = useHover(props2);
- return () => {
- const hoverClass = props2.hoverClass;
- if (hoverClass && hoverClass !== "none") {
- return createVNode("uni-view", mergeProps({
- "class": hovering.value ? hoverClass : ""
- }, binding), {
- default: () => [slots.default && slots.default()]
- }, 16, ["class"]);
+ removeEvent() {
+ if (!this._listening) {
+ return;
+ }
+ {
+ console.log(formatLog(this.$.tagName, "Hover", "removeEventListener"));
+ }
+ this._listening = false;
+ this.$.removeEventListener("touchstart", this.__hoverTouchStart);
+ this.$.removeEventListener("touchend", this.__hoverTouchEnd);
+ this.$.removeEventListener("touchcancel", this.__hoverTouchCancel);
+ }
+ _hoverTouchStart(evt) {
+ if (evt._hoverPropagationStopped) {
+ return;
+ }
+ const hoverClass = this.props["hover-class"];
+ if (!hoverClass || hoverClass === "none" || this.$.disabled) {
+ return;
+ }
+ if (evt.touches.length > 1) {
+ return;
+ }
+ if (this.props["hover-stop-propagation"]) {
+ evt._hoverPropagationStopped = true;
+ }
+ this._hoverTouch = true;
+ this._hoverStartTimer = setTimeout(() => {
+ this.hovering = true;
+ if (!this._hoverTouch) {
+ this._hoverReset();
}
- return createVNode("uni-view", null, {
- default: () => [slots.default && slots.default()]
- });
- };
+ }, this.props["hover-start-time"]);
}
- });
- function normalizeEvent(pageId2, vm, id2) {
- if (!id2) {
- id2 = vm.id;
+ _hoverTouchEnd() {
+ this._hoverTouch = false;
+ if (this.hovering) {
+ this._hoverReset();
+ }
}
- if (!id2) {
- return;
+ _hoverReset() {
+ requestAnimationFrame(() => {
+ clearTimeout(this._hoverStayTimer);
+ this._hoverStayTimer = setTimeout(() => {
+ this.hovering = false;
+ }, this.props["hover-stay-time"]);
+ });
}
- return pageId2 + "." + vm.$options.name.toLowerCase() + "." + id2;
- }
- function addSubscribe(name, callback) {
- if (!name) {
- return;
+ _hoverTouchCancel() {
+ this._hoverTouch = false;
+ this.hovering = false;
+ clearTimeout(this._hoverStartTimer);
}
- UniViewJSBridge.subscribe(name, ({ type, data }) => {
- callback(type, data);
- });
}
- function removeSubscribe(name) {
- if (!name) {
- return;
+ class UniViewElement extends UniHoverElement {
+ constructor(id2) {
+ super(id2, document.createElement("uni-view"));
}
- UniViewJSBridge.unsubscribe(name);
- }
- function useSubscribe(callback, name, multiple) {
- const instance = getCurrentInstance();
- const vm = instance.proxy;
- const pageId2 = multiple || !name ? useCurrentPageId() : 0;
- onMounted(() => {
- addSubscribe(name || normalizeEvent(pageId2, vm), callback);
- if (multiple || !name) {
- watch(() => vm.id, (value, oldValue) => {
- addSubscribe(normalizeEvent(pageId2, vm, value), callback);
- removeSubscribe(oldValue && normalizeEvent(pageId2, vm, oldValue));
- });
- }
- });
- onBeforeUnmount(() => {
- removeSubscribe(name || normalizeEvent(pageId2, vm));
- });
- }
- let index = 0;
- function useContextInfo(_id) {
- const page = useCurrentPageId();
- const instance = getCurrentInstance();
- const vm = instance.proxy;
- const type = vm.$options.name.toLowerCase();
- const id2 = _id || vm.id || `context${index++}`;
- onMounted(() => {
- const el = vm.$el;
- el.__uniContextInfo = {
- id: id2,
- type,
- page
- };
- });
- return `${page}.${type}.${id2}`;
}
var Ad = /* @__PURE__ */ defineBuiltInComponent({
name: "Ad"
@@ -14352,9 +14740,7 @@
const defaultSlots = slots.default ? flatVNode(slots.default()) : [];
let text2 = "";
defaultSlots.forEach((node) => {
- if (!node.type === Text) {
- text2 += node.children || "";
- }
+ text2 += node.children || "";
});
content.text = text2;
return createVNode("uni-cover-view", {
@@ -14533,12 +14919,6 @@
super(id2, "uni-switch", Switch);
}
}
- var text = "uni-text[selectable] {\n cursor: auto;\n -webkit-user-select: text;\n user-select: text;\n}\n";
- class UniText extends UniComponent {
- constructor(id2) {
- super(id2, "uni-text", Text);
- }
- }
var textarea = "uni-textarea {\n width: 300px;\n height: 150px;\n display: block;\n position: relative;\n font-size: 16px;\n line-height: normal;\n white-space: pre-wrap;\n word-break: break-all;\n box-sizing: content-box !important;\n}\nuni-textarea[hidden] {\n display: none;\n}\n.uni-textarea-wrapper,\n.uni-textarea-placeholder,\n.uni-textarea-line,\n.uni-textarea-compute,\n.uni-textarea-textarea {\n outline: none;\n border: none;\n padding: 0;\n margin: 0;\n text-decoration: inherit;\n}\n.uni-textarea-wrapper {\n display: block;\n position: relative;\n width: 100%;\n height: 100%;\n min-height: inherit;\n}\n.uni-textarea-placeholder,\n.uni-textarea-line,\n.uni-textarea-compute,\n.uni-textarea-textarea {\n position: absolute;\n width: 100%;\n height: 100%;\n left: 0;\n top: 0;\n white-space: inherit;\n word-break: inherit;\n}\n.uni-textarea-placeholder {\n color: grey;\n overflow: hidden;\n}\n.uni-textarea-line,\n.uni-textarea-compute {\n visibility: hidden;\n height: auto;\n}\n.uni-textarea-line {\n width: 1em;\n}\n.uni-textarea-textarea {\n resize: none;\n background: none;\n color: inherit;\n opacity: 1;\n font: inherit;\n line-height: inherit;\n letter-spacing: inherit;\n text-align: inherit;\n text-indent: inherit;\n text-transform: inherit;\n text-shadow: inherit;\n}\n/* \u7528\u4E8E\u89E3\u51B3 iOS textarea \u5185\u90E8\u9ED8\u8BA4\u8FB9\u8DDD */\n.uni-textarea-textarea-fix-margin {\n width: auto;\n right: 0;\n margin: 0 -3px;\n}\n.uni-textarea-textarea:disabled {\n /* \u7528\u4E8E\u91CD\u7F6EiOS14\u4EE5\u4E0B\u7981\u7528\u72B6\u6001\u6587\u5B57\u989C\u8272 */\n -webkit-text-fill-color: currentcolor;\n}\n";
class UniTextarea extends UniComponent {
constructor(id2) {
@@ -14764,7 +15144,7 @@
,
UniViewElement,
UniImage,
- UniText,
+ UniTextElement,
UniTextNode,
UniComment,
UniNavigator,
@@ -14803,438 +15183,137 @@
UniSwiperItem,
UniSwitch,
UniTextarea,
- UniVideo,
- UniWebView
- ];
- function createBuiltInComponent(type, id2) {
- return new BuiltInComponents[type](id2);
- }
- function createWrapper(component, props2) {
- return () => h(component, props2);
- }
- const elements = new Map();
- function $(id2) {
- return elements.get(id2);
- }
- function createElement(id2, tag) {
- let element;
- if (isString(tag)) {
- element = new UniElement(id2, document.createElement(tag));
- } else {
- element = createBuiltInComponent(tag, id2);
- }
- elements.set(id2, element);
- return element;
- }
- function onPageCreated() {
- }
- function onPageCreate({
- css,
- route,
- platform,
- pixelRatio: pixelRatio2,
- windowWidth,
- disableScroll,
- onPageScroll,
- onPageReachBottom,
- onReachBottomDistance,
- statusbarHeight,
- windowTop,
- windowBottom
- }) {
- initSystemInfo(platform, pixelRatio2, windowWidth);
- initPageElement();
- if (css) {
- initPageCss(route);
- }
- const pageId2 = plus.webview.currentWebview().id;
- window.__id__ = pageId2;
- document.title = `${route}[${pageId2}]`;
- initCssVar(statusbarHeight, windowTop, windowBottom);
- if (disableScroll) {
- document.addEventListener("touchmove", disableScrollListener);
- } else if (onPageScroll || onPageReachBottom) {
- initPageScroll(onPageScroll, onPageReachBottom, onReachBottomDistance);
- }
- }
- function initSystemInfo(platform, pixelRatio2, windowWidth) {
- window.__SYSTEM_INFO__ = {
- platform,
- pixelRatio: pixelRatio2,
- windowWidth
- };
- }
- function initPageElement() {
- createElement(0, "div").$ = document.getElementById("app");
- }
- function initPageCss(route) {
- const element = document.createElement("link");
- element.type = "text/css";
- element.rel = "stylesheet";
- element.href = route + ".css";
- document.head.appendChild(element);
- }
- function initCssVar(statusbarHeight, windowTop, windowBottom) {
- const cssVars = {
- "--window-left": "0px",
- "--window-right": "0px",
- "--window-top": windowTop + "px",
- "--window-bottom": windowBottom + "px",
- "--status-bar-height": statusbarHeight + "px"
- };
- {
- console.log(formatLog("initCssVar", cssVars));
- }
- updateCssVar(cssVars);
- }
- function initPageScroll(onPageScroll, onPageReachBottom, onReachBottomDistance) {
- const opts = {};
- if (onPageScroll) {
- opts.onPageScroll = (scrollTop) => {
- UniViewJSBridge.publishHandler("onPageScroll", { scrollTop });
- };
- }
- if (onPageReachBottom) {
- opts.onReachBottomDistance = onReachBottomDistance;
- opts.onReachBottom = () => UniViewJSBridge.publishHandler("onReachBottom");
- }
- requestAnimationFrame(() => document.addEventListener("scroll", createScrollListener(opts)));
- }
- function onVdSync(actions) {
- actions.forEach((action) => {
- switch (action[0]) {
- case ACTION_TYPE_PAGE_CREATE:
- return onPageCreate(action[1]);
- case ACTION_TYPE_PAGE_CREATED:
- return onPageCreated();
- case ACTION_TYPE_CREATE:
- return createElement(action[1], action[2]);
- case ACTION_TYPE_INSERT:
- return $(action[1]).insert(action[2], action[3], action[4]);
- case ACTION_TYPE_REMOVE:
- return $(action[1]).remove();
- case ACTION_TYPE_SET_ATTRIBUTE:
- return $(action[1]).setAttr(action[2], action[3]);
- case ACTION_TYPE_REMOVE_ATTRIBUTE:
- return $(action[1]).removeAttr(action[2]);
- case ACTION_TYPE_SET_TEXT:
- return $(action[1]).setText(action[2]);
- }
- });
- }
- function initSubscribeHandlers() {
- const { subscribe } = UniViewJSBridge;
- subscribe(VD_SYNC, onVdSync);
- }
- function preventDoubleTap() {
- if (String(navigator.vendor).indexOf("Apple") === 0) {
- let firstEvent = null;
- let timeout;
- document.documentElement.addEventListener("click", (event) => {
- const TIME_MAX = 450;
- const PAGE_MAX = 44;
- clearTimeout(timeout);
- if (firstEvent && Math.abs(event.pageX - firstEvent.pageX) <= PAGE_MAX && Math.abs(event.pageY - firstEvent.pageY) <= PAGE_MAX && event.timeStamp - firstEvent.timeStamp <= TIME_MAX) {
- event.preventDefault();
- }
- firstEvent = event;
- timeout = setTimeout(() => {
- firstEvent = null;
- }, TIME_MAX);
- });
- }
- }
- function initView() {
- initSubscribeHandlers();
- preventDoubleTap();
- }
- function validateProtocolFail(name, msg) {
- console.warn(`${name}: ${msg}`);
- }
- function validateProtocol(name, data, protocol, onFail) {
- if (!onFail) {
- onFail = validateProtocolFail;
- }
- for (const key in protocol) {
- const errMsg = validateProp(key, data[key], protocol[key], !hasOwn$1(data, key));
- if (isString(errMsg)) {
- onFail(name, errMsg);
- }
- }
- }
- function validateProtocols(name, args, protocol, onFail) {
- if (!protocol) {
- return;
- }
- if (!isArray(protocol)) {
- return validateProtocol(name, args[0] || Object.create(null), protocol, onFail);
- }
- const len = protocol.length;
- const argsLen = args.length;
- for (let i = 0; i < len; i++) {
- const opts = protocol[i];
- const data = Object.create(null);
- if (argsLen > i) {
- data[opts.name] = args[i];
- }
- validateProtocol(name, data, { [opts.name]: opts }, onFail);
- }
- }
- function validateProp(name, value, prop, isAbsent) {
- if (!isPlainObject(prop)) {
- prop = { type: prop };
- }
- const { type, required, validator } = prop;
- if (required && isAbsent) {
- return 'Missing required args: "' + name + '"';
- }
- if (value == null && !required) {
- return;
- }
- if (type != null) {
- let isValid = false;
- const types = isArray(type) ? type : [type];
- const expectedTypes = [];
- for (let i = 0; i < types.length && !isValid; i++) {
- const { valid, expectedType } = assertType(value, types[i]);
- expectedTypes.push(expectedType || "");
- isValid = valid;
- }
- if (!isValid) {
- return getInvalidTypeMessage(name, value, expectedTypes);
- }
- }
- if (validator) {
- return validator(value);
- }
- }
- const isSimpleType = /* @__PURE__ */ makeMap$1("String,Number,Boolean,Function,Symbol");
- function assertType(value, type) {
- let valid;
- const expectedType = getType(type);
- if (isSimpleType(expectedType)) {
- const t2 = typeof value;
- valid = t2 === expectedType.toLowerCase();
- if (!valid && t2 === "object") {
- valid = value instanceof type;
- }
- } else if (expectedType === "Object") {
- valid = isObject$1(value);
- } else if (expectedType === "Array") {
- valid = isArray(value);
- } else {
- {
- valid = value instanceof type || toRawType(value) === getType(type);
- }
- }
- return {
- valid,
- expectedType
- };
- }
- function getInvalidTypeMessage(name, value, expectedTypes) {
- let message = `Invalid args: type check failed for args "${name}". Expected ${expectedTypes.map(capitalize).join(", ")}`;
- const expectedType = expectedTypes[0];
- const receivedType = toRawType(value);
- const expectedValue = styleValue(value, expectedType);
- const receivedValue = styleValue(value, receivedType);
- if (expectedTypes.length === 1 && isExplicable(expectedType) && !isBoolean(expectedType, receivedType)) {
- message += ` with value ${expectedValue}`;
- }
- message += `, got ${receivedType} `;
- if (isExplicable(receivedType)) {
- message += `with value ${receivedValue}.`;
- }
- return message;
- }
- function getType(ctor) {
- const match = ctor && ctor.toString().match(/^\s*function (\w+)/);
- return match ? match[1] : "";
- }
- function styleValue(value, type) {
- if (type === "String") {
- return `"${value}"`;
- } else if (type === "Number") {
- return `${Number(value)}`;
- } else {
- return `${value}`;
- }
+ UniVideo,
+ UniWebView
+ ];
+ function createBuiltInComponent(type, id2) {
+ return new BuiltInComponents[type](id2);
}
- function isExplicable(type) {
- const explicitTypes = ["string", "number", "boolean"];
- return explicitTypes.some((elem) => type.toLowerCase() === elem);
+ function createWrapper(component, props2) {
+ return () => h(component, props2);
}
- function isBoolean(...args) {
- return args.some((elem) => elem.toLowerCase() === "boolean");
+ const elements = new Map();
+ function $(id2) {
+ return elements.get(id2);
}
- function formatApiArgs(args, options) {
- const params = args[0];
- if (!options || !isPlainObject(options.formatArgs) && isPlainObject(params)) {
- return;
- }
- const formatArgs = options.formatArgs;
- const keys = Object.keys(formatArgs);
- for (let i = 0; i < keys.length; i++) {
- const name = keys[i];
- const formatterOrDefaultValue = formatArgs[name];
- if (isFunction(formatterOrDefaultValue)) {
- const errMsg = formatterOrDefaultValue(args[0][name], params);
- if (isString(errMsg)) {
- return errMsg;
- }
- } else {
- if (!hasOwn$1(params, name)) {
- params[name] = formatterOrDefaultValue;
- }
- }
+ function createElement(id2, tag) {
+ let element;
+ if (isString(tag)) {
+ element = new UniElement(id2, document.createElement(tag));
+ } else {
+ element = createBuiltInComponent(tag, id2);
}
+ elements.set(id2, element);
+ return element;
}
- function beforeInvokeApi(name, args, protocol, options) {
- {
- validateProtocols(name, args, protocol);
- }
- if (options && options.beforeInvoke) {
- const errMsg2 = options.beforeInvoke(args);
- if (isString(errMsg2)) {
- return errMsg2;
- }
+ function onPageCreated() {
+ }
+ function onPageCreate({
+ css,
+ route,
+ platform,
+ pixelRatio: pixelRatio2,
+ windowWidth,
+ disableScroll,
+ onPageScroll,
+ onPageReachBottom,
+ onReachBottomDistance,
+ statusbarHeight,
+ windowTop,
+ windowBottom
+ }) {
+ initSystemInfo(platform, pixelRatio2, windowWidth);
+ initPageElement();
+ if (css) {
+ initPageCss(route);
}
- const errMsg = formatApiArgs(args, options);
- if (errMsg) {
- return errMsg;
+ const pageId2 = plus.webview.currentWebview().id;
+ window.__id__ = pageId2;
+ document.title = `${route}[${pageId2}]`;
+ initCssVar(statusbarHeight, windowTop, windowBottom);
+ if (disableScroll) {
+ document.addEventListener("touchmove", disableScrollListener);
+ } else if (onPageScroll || onPageReachBottom) {
+ initPageScroll(onPageScroll, onPageReachBottom, onReachBottomDistance);
}
}
- function wrapperSyncApi(name, fn, protocol, options) {
- return (...args) => {
- const errMsg = beforeInvokeApi(name, args, protocol, options);
- if (errMsg) {
- throw new Error(errMsg);
- }
- return fn.apply(null, args);
+ function initSystemInfo(platform, pixelRatio2, windowWidth) {
+ window.__SYSTEM_INFO__ = {
+ platform,
+ pixelRatio: pixelRatio2,
+ windowWidth
};
}
- function defineSyncApi(name, fn, protocol, options) {
- return wrapperSyncApi(name, fn, protocol, options);
- }
- const API_UPX2PX = "upx2px";
- const Upx2pxProtocol = [
- {
- name: "upx",
- type: [Number, String],
- required: true
- }
- ];
- const EPS = 1e-4;
- const BASE_DEVICE_WIDTH = 750;
- let isIOS = false;
- let deviceWidth = 0;
- let deviceDPR = 0;
- function checkDeviceWidth() {
- const { platform, pixelRatio: pixelRatio2, windowWidth } = getBaseSystemInfo();
- deviceWidth = windowWidth;
- deviceDPR = pixelRatio2;
- isIOS = platform === "ios";
+ function initPageElement() {
+ createElement(0, "div").$ = document.getElementById("app");
}
- function checkValue(value, defaultValue) {
- const newValue = Number(value);
- return isNaN(newValue) ? defaultValue : newValue;
+ function initPageCss(route) {
+ const element = document.createElement("link");
+ element.type = "text/css";
+ element.rel = "stylesheet";
+ element.href = route + ".css";
+ document.head.appendChild(element);
}
- const upx2px = /* @__PURE__ */ defineSyncApi(API_UPX2PX, (number, newDeviceWidth) => {
- if (deviceWidth === 0) {
- checkDeviceWidth();
- }
- number = Number(number);
- if (number === 0) {
- return 0;
- }
- let width = newDeviceWidth || deviceWidth;
+ function initCssVar(statusbarHeight, windowTop, windowBottom) {
+ const cssVars = {
+ "--window-left": "0px",
+ "--window-right": "0px",
+ "--window-top": windowTop + "px",
+ "--window-bottom": windowBottom + "px",
+ "--status-bar-height": statusbarHeight + "px"
+ };
{
- const config = __uniConfig.globalStyle || {};
- const maxWidth = checkValue(config.rpxCalcMaxDeviceWidth, 960);
- const baseWidth = checkValue(config.rpxCalcBaseDeviceWidth, 375);
- width = width <= maxWidth ? width : baseWidth;
- }
- let result = number / BASE_DEVICE_WIDTH * width;
- if (result < 0) {
- result = -result;
+ console.log(formatLog("initCssVar", cssVars));
}
- result = Math.floor(result + EPS);
- if (result === 0) {
- if (deviceDPR === 1 || !isIOS) {
- result = 1;
- } else {
- result = 0.5;
- }
+ updateCssVar(cssVars);
+ }
+ function initPageScroll(onPageScroll, onPageReachBottom, onReachBottomDistance) {
+ const opts = {};
+ if (onPageScroll) {
+ opts.onPageScroll = (scrollTop) => {
+ UniViewJSBridge.publishHandler("onPageScroll", { scrollTop });
+ };
}
- return number < 0 ? -result : result;
- }, Upx2pxProtocol);
- createCallbacks("canvasEvent");
- createCallbacks("getSelectedTextRangeEvent");
- ({
- beforeInvoke() {
- initI18nShowModalMsgsOnce();
- },
- formatArgs: {
- title: "",
- content: "",
- showCancel: true,
- cancelText(_value, params) {
- if (!hasOwn$1(params, "cancelText")) {
- const { t: t2 } = useI18n();
- params.cancelText = t2("uni.showModal.cancel");
- }
- },
- cancelColor: "#000",
- confirmText(_value, params) {
- if (!hasOwn$1(params, "confirmText")) {
- const { t: t2 } = useI18n();
- params.confirmText = t2("uni.showModal.confirm");
- }
- },
- confirmColor: PRIMARY_COLOR
+ if (onPageReachBottom) {
+ opts.onReachBottomDistance = onReachBottomDistance;
+ opts.onReachBottom = () => UniViewJSBridge.publishHandler("onReachBottom");
}
- });
- function invokeApi(method, args = {}) {
- UniViewJSBridge.publishHandler(INVOKE_API, {
- data: {
- method,
- args
- },
- options: {
- timestamp: Date.now()
+ requestAnimationFrame(() => document.addEventListener("scroll", createScrollListener(opts)));
+ }
+ function onVdSync(actions) {
+ actions.forEach((action) => {
+ switch (action[0]) {
+ case ACTION_TYPE_PAGE_CREATE:
+ return onPageCreate(action[1]);
+ case ACTION_TYPE_PAGE_CREATED:
+ return onPageCreated();
+ case ACTION_TYPE_CREATE:
+ return createElement(action[1], action[2]);
+ case ACTION_TYPE_INSERT:
+ return $(action[1]).insert(action[2], action[3], action[4]);
+ case ACTION_TYPE_REMOVE:
+ return $(action[1]).remove();
+ case ACTION_TYPE_SET_ATTRIBUTE:
+ return $(action[1]).setAttr(action[2], action[3]);
+ case ACTION_TYPE_REMOVE_ATTRIBUTE:
+ return $(action[1]).removeAttr(action[2]);
+ case ACTION_TYPE_SET_TEXT:
+ return $(action[1]).setText(action[2]);
}
});
+ flushPostActionJobs();
}
- function navigateTo(args) {
- invokeApi("navigateTo", args);
- }
- function navigateBack(args) {
- invokeApi("navigateBack", args);
- }
- function reLaunch(args) {
- invokeApi("reLaunch", args);
- }
- function redirectTo(args) {
- invokeApi("redirectTo", args);
- }
- function switchTab(args) {
- invokeApi("switchTab", args);
+ function initSubscribeHandlers() {
+ const { subscribe } = UniViewJSBridge;
+ subscribe(VD_SYNC, onVdSync);
}
- var uni$1 = /* @__PURE__ */ Object.freeze({
- __proto__: null,
- [Symbol.toStringTag]: "Module",
- upx2px,
- navigateTo,
- navigateBack,
- reLaunch,
- redirectTo,
- switchTab
- });
window.uni = uni$1;
window.UniViewJSBridge = UniViewJSBridge$1;
window.rpx2px = upx2px;
function onWebviewReady() {
initView();
+ initSubscribeHandlers();
+ preventDoubleTap();
UniViewJSBridge$1.publishHandler(ON_WEBVIEW_READY);
}
if (typeof plus !== "undefined") {
diff --git a/packages/uni-app-plus/src/view/components/cover-view/index.tsx b/packages/uni-app-plus/src/view/components/cover-view/index.tsx
index 34cc626ddf6dab57f71210b99e823771cf4ba438..e509d2947f4ff158ac7165d23861aff0f7f19e3c 100644
--- a/packages/uni-app-plus/src/view/components/cover-view/index.tsx
+++ b/packages/uni-app-plus/src/view/components/cover-view/index.tsx
@@ -4,7 +4,7 @@ import {
useCustomEvent,
EmitEvent,
flatVNode,
- Text,
+ // Text,
} from '@dcloudio/uni-components'
import { useCover } from '../../../helpers/useCover'
@@ -22,9 +22,9 @@ export default /*#__PURE__*/ defineBuiltInComponent({
const defaultSlots = slots.default ? flatVNode(slots.default()) : []
let text = ''
defaultSlots.forEach((node) => {
- if (!node.type === Text) {
- text += node.children || ''
- }
+ // if (!node.type === Text) {
+ text += node.children || ''
+ // }
})
content.text = text
return (
diff --git a/packages/uni-app-plus/src/view/framework/dom/components/UniComponent.ts b/packages/uni-app-plus/src/view/framework/dom/components/UniComponent.ts
index 8a496a24ff205e123c8e08df9da416fd92b7d7f7..edddbc6bbf3c4bb6769c244aa81e2b197863f3be 100644
--- a/packages/uni-app-plus/src/view/framework/dom/components/UniComponent.ts
+++ b/packages/uni-app-plus/src/view/framework/dom/components/UniComponent.ts
@@ -21,9 +21,7 @@ export class UniComponent extends UniNode {
this.setAttr(n, a[n])
})
}
- const vm = createApp(createWrapper(this.$component, this.$props)).mount(
- container
- )
+ createApp(createWrapper(this.$component, this.$props)).mount(container)
this.$ = container.firstElementChild!
if (hasOwn(nodeJson, 't')) {
this.$.textContent = nodeJson.t || ''
diff --git a/packages/uni-app-plus/src/view/framework/dom/components/UniText.ts b/packages/uni-app-plus/src/view/framework/dom/components/UniText.ts
deleted file mode 100644
index 6edeb42974ef1aaef7c0eaef110fc249ac58ca85..0000000000000000000000000000000000000000
--- a/packages/uni-app-plus/src/view/framework/dom/components/UniText.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import '@dcloudio/uni-components/style/text.css'
-import { Text } from '@dcloudio/uni-components'
-
-import { UniComponent } from './UniComponent'
-
-export class UniText extends UniComponent {
- constructor(id: number) {
- super(id, 'uni-text', Text)
- }
-}
diff --git a/packages/uni-app-plus/src/view/framework/dom/components/index.ts b/packages/uni-app-plus/src/view/framework/dom/components/index.ts
index 5c8e47de7ba886046687db114e9f2cfa5852facd..e9051d7f5cb6b869542047d4d7bebc465e803412 100644
--- a/packages/uni-app-plus/src/view/framework/dom/components/index.ts
+++ b/packages/uni-app-plus/src/view/framework/dom/components/index.ts
@@ -1,5 +1,6 @@
import { defineComponent, h } from 'vue'
import { UniComment } from '../elements/UniComment'
+import { UniTextElement } from '../elements/UniTextElement'
import { UniTextNode } from '../elements/UniTextNode'
import { UniViewElement } from '../elements/UniViewElement'
import { UniAd } from './UniAd'
@@ -38,7 +39,6 @@ import { UniSlider } from './UniSlider'
import { UniSwiper } from './UniSwiper'
import { UniSwiperItem } from './UniSwiperItem'
import { UniSwitch } from './UniSwitch'
-import { UniText } from './UniText'
import { UniTextarea } from './UniTextarea'
import { UniVideo } from './UniVideo'
import { UniWebView } from './UniWebView'
@@ -52,7 +52,7 @@ const BuiltInComponents = [
,
UniViewElement,
UniImage,
- UniText,
+ UniTextElement,
UniTextNode,
UniComment,
UniNavigator,
diff --git a/packages/uni-app-plus/src/view/framework/dom/elements/UniElement.ts b/packages/uni-app-plus/src/view/framework/dom/elements/UniElement.ts
index f63fd0ad89a652769d6888d44057b841b8b57674..4f6519cb107b08680c1c97051624bfb753e0b908 100644
--- a/packages/uni-app-plus/src/view/framework/dom/elements/UniElement.ts
+++ b/packages/uni-app-plus/src/view/framework/dom/elements/UniElement.ts
@@ -1,25 +1,41 @@
import { hasOwn } from '@vue/shared'
import { decodeAttr, UniNodeJSON } from '@dcloudio/uni-shared'
-
+import { reactive, watch } from 'vue'
import { UniNode } from './UniNode'
import { patchClass } from '../modules/class'
import { patchStyle } from '../modules/style'
import { patchEvent } from '../modules/events'
import { UniCustomElement } from '../components'
+import { queuePostActionJob } from '../scheduler'
-export class UniElement extends UniNode {
+export class UniElement extends UniNode {
$: UniCustomElement
- constructor(id: number, element: Element) {
+ $props: T = reactive({} as any)
+ $propNames: string[]
+ protected _update?: Function
+ constructor(id: number, element: Element, propNames: string[] = []) {
super(id, element.tagName)
this.$ = element as UniCustomElement
this.$.__id = id
this.$.__listeners = Object.create(null)
+
+ this.$propNames = propNames
+
+ this._update = this.update.bind(this)
}
init(nodeJson: Partial) {
- super.init(nodeJson)
if (hasOwn(nodeJson, 'a')) {
this.setAttrs(nodeJson.a!)
}
+ super.init(nodeJson)
+ watch(
+ this.$props,
+ () => {
+ queuePostActionJob(this._update!)
+ },
+ { flush: 'sync' }
+ )
+ this.update()
}
setAttrs(attrs: Record) {
Object.keys(attrs).forEach((name) => {
@@ -34,7 +50,7 @@ export class UniElement extends UniNode {
} else if (name.indexOf('.e') === 0) {
patchEvent(this.$, name, value as number)
} else {
- this.$.setAttribute(decodeAttr(name), value as string)
+ this.setAttribute(decodeAttr(name), value as string)
}
}
removeAttr(name: string) {
@@ -45,7 +61,22 @@ export class UniElement extends UniNode {
} else if (name.indexOf('.e') === 0) {
patchEvent(this.$, name, -1)
} else {
- this.$.removeAttribute(decodeAttr(name))
+ this.removeAttribute(decodeAttr(name))
+ }
+ }
+ setAttribute(name: string, value: unknown) {
+ if (this.$propNames.indexOf(name) !== -1) {
+ ;(this.$props as any)[name] = value
+ } else {
+ this.$.setAttribute(name, value as string)
+ }
+ }
+ removeAttribute(name: string) {
+ if (this.$propNames.indexOf(name) !== -1) {
+ delete (this.$props as any)[name]
+ } else {
+ this.$.removeAttribute(name)
}
}
+ update() {}
}
diff --git a/packages/uni-app-plus/src/view/framework/dom/elements/UniHoverElement.ts b/packages/uni-app-plus/src/view/framework/dom/elements/UniHoverElement.ts
index 1d88aec71debae6b79e3876a9667b1d7e1b37c64..0edd85b87c35090fa5fc024a81bd9571be6d7bda 100644
--- a/packages/uni-app-plus/src/view/framework/dom/elements/UniHoverElement.ts
+++ b/packages/uni-app-plus/src/view/framework/dom/elements/UniHoverElement.ts
@@ -1,36 +1,34 @@
-import { camelize } from '@vue/shared'
-import { decodeAttr, formatLog } from '@dcloudio/uni-shared'
+import { formatLog } from '@dcloudio/uni-shared'
import { UniElement } from './UniElement'
-function isHoverAttr(name: string) {
- return name.indexOf('.h') === 0
+interface HoverProps {
+ 'hover-class': string | 'none'
+ 'hover-stop-propagation': boolean
+ 'hover-start-time': number
+ 'hover-stay-time': number
}
-
-export class UniHoverElement extends UniElement {
+const PROP_NAMES_HOVER = [
+ 'hover-class',
+ 'hover-stop-propagation',
+ 'hover-start-time',
+ 'hover-stay-time',
+]
+export class UniHoverElement extends UniElement {
private _hover?: Hover
-
- setAttr(name: string, value: unknown) {
- if (!isHoverAttr(name)) {
- return super.setAttr(name, value)
- }
- name = camelize(decodeAttr(name))
- if (!this._hover) {
- this._hover = new Hover(this.$)
- }
- const { _hover } = this
- ;(_hover as any)[name] = value
- if (name !== 'hoverClass') {
- return
- }
- if (_hover.hoverClass && _hover.hoverClass !== 'none') {
- _hover.addEvent()
- } else {
- _hover.removeEvent()
- }
+ constructor(id: number, element: Element, propNames: string[] = []) {
+ super(id, element, [...PROP_NAMES_HOVER, ...propNames])
}
- removeAttr(name: string) {
- if (!isHoverAttr(name)) {
- return super.removeAttr(name)
+ update() {
+ const hoverClass = this.$props['hover-class']
+ if (hoverClass && hoverClass !== 'none') {
+ if (!this._hover) {
+ this._hover = new Hover(this.$, this.$props)
+ }
+ this._hover.addEvent()
+ } else {
+ if (this._hover) {
+ this._hover.removeEvent()
+ }
}
}
}
@@ -38,10 +36,7 @@ export class UniHoverElement extends UniElement {
class Hover {
private $: Element
- hoverClass: string = 'none'
- hoverStopPropagation: boolean = false
- hoverStartTime: number = 50
- hoverStayTime: number = 400
+ private props: HoverProps
private _listening: boolean = false
@@ -53,9 +48,11 @@ class Hover {
private __hoverTouchStart!: (evt: Event) => void
private __hoverTouchEnd!: (evt?: Event) => void
private __hoverTouchCancel!: (evt?: Event) => void
- constructor($: Element) {
+ constructor($: Element, props: HoverProps) {
this.$ = $
+ this.props = props
+
this.__hoverTouchStart = this._hoverTouchStart.bind(this)
this.__hoverTouchEnd = this._hoverTouchEnd.bind(this)
this.__hoverTouchCancel = this._hoverTouchCancel.bind(this)
@@ -67,10 +64,11 @@ class Hover {
set hovering(hovering: boolean) {
this._hovering = hovering
+ const hoverClass = this.props['hover-class']
if (hovering) {
- this.$.classList.add(this.hoverClass)
+ this.$.classList.add(hoverClass)
} else {
- this.$.classList.remove(this.hoverClass)
+ this.$.classList.remove(hoverClass)
}
}
@@ -80,7 +78,12 @@ class Hover {
}
if (__DEV__) {
console.log(
- formatLog(this.$.tagName, 'Hover', 'addEventListener', this.hoverClass)
+ formatLog(
+ this.$.tagName,
+ 'Hover',
+ 'addEventListener',
+ this.props['hover-class']
+ )
)
}
this._listening = true
@@ -104,17 +107,14 @@ class Hover {
if ((evt as any)._hoverPropagationStopped) {
return
}
- if (
- !this.hoverClass ||
- this.hoverClass === 'none' ||
- (this.$ as any).disabled
- ) {
+ const hoverClass = this.props['hover-class']
+ if (!hoverClass || hoverClass === 'none' || (this.$ as any).disabled) {
return
}
if ((evt as TouchEvent).touches.length > 1) {
return
}
- if (this.hoverStopPropagation) {
+ if (this.props['hover-stop-propagation']) {
;(evt as any)._hoverPropagationStopped = true
}
this._hoverTouch = true
@@ -124,7 +124,7 @@ class Hover {
// 防止在hoverStartTime时间内触发了 touchend 或 touchcancel
this._hoverReset()
}
- }, this.hoverStartTime)
+ }, this.props['hover-start-time'])
}
_hoverTouchEnd() {
this._hoverTouch = false
@@ -137,7 +137,7 @@ class Hover {
clearTimeout(this._hoverStayTimer)
this._hoverStayTimer = setTimeout(() => {
this.hovering = false
- }, this.hoverStayTime)
+ }, this.props['hover-stay-time'])
})
}
_hoverTouchCancel() {
diff --git a/packages/uni-app-plus/src/view/framework/dom/elements/UniNode.ts b/packages/uni-app-plus/src/view/framework/dom/elements/UniNode.ts
index bc1209420e50577c4556e0bee3e660c780fa124b..543c63a0e20a23d3c92c0269d1f15d913f33ca6d 100644
--- a/packages/uni-app-plus/src/view/framework/dom/elements/UniNode.ts
+++ b/packages/uni-app-plus/src/view/framework/dom/elements/UniNode.ts
@@ -7,6 +7,8 @@ export class UniNode {
id: number
tag: string
$!: Element | Text | Comment
+ isMounted: boolean = false
+ isUnmounted: boolean = false
constructor(id: number, tag: string) {
this.id = id
this.tag = tag
@@ -32,9 +34,11 @@ export class UniNode {
} else {
parentNode.insertBefore(node, $(refNodeId).$)
}
+ this.isMounted = true
}
remove() {
const { $ } = this
$.parentNode!.removeChild($)
+ this.isUnmounted = false
}
}
diff --git a/packages/uni-app-plus/src/view/framework/dom/elements/UniTextElement.ts b/packages/uni-app-plus/src/view/framework/dom/elements/UniTextElement.ts
new file mode 100644
index 0000000000000000000000000000000000000000..cff8e3a6503adb4adc64be317634fd9aeb467f71
--- /dev/null
+++ b/packages/uni-app-plus/src/view/framework/dom/elements/UniTextElement.ts
@@ -0,0 +1,40 @@
+import '@dcloudio/uni-components/style/text.css'
+import { DecodeOptions, parseText } from '@dcloudio/uni-components'
+import { UniElement } from './UniElement'
+import { formatLog, UniNodeJSON } from '@dcloudio/uni-shared'
+
+interface TextProps {
+ space: DecodeOptions['space']
+ decode: boolean
+}
+
+const PROP_NAMES_HOVER = ['space', 'decode']
+
+export class UniTextElement extends UniElement {
+ private _text: string = ''
+
+ constructor(id: number) {
+ super(id, document.createElement('uni-text'), PROP_NAMES_HOVER)
+ }
+ init(nodeJson: Partial) {
+ this._text = nodeJson.t || ''
+ super.init(nodeJson)
+ }
+
+ setText(text: string) {
+ this._text = text
+ }
+
+ update() {
+ if (__DEV__) {
+ console.log(formatLog('Text', 'update'))
+ }
+ const {
+ $props: { space, decode },
+ } = this
+ this.$.innerHTML = parseText(this._text, {
+ space,
+ decode,
+ }).join('
')
+ }
+}
diff --git a/packages/uni-app-plus/src/view/framework/dom/index.ts b/packages/uni-app-plus/src/view/framework/dom/index.ts
index 1cbe9e47a3b4365557ab8879c016bd07265e6bd7..f938df9b76b6426241e703a43989fd27f63873d1 100644
--- a/packages/uni-app-plus/src/view/framework/dom/index.ts
+++ b/packages/uni-app-plus/src/view/framework/dom/index.ts
@@ -10,6 +10,7 @@ import {
PageAction,
} from '../../../PageAction'
import { $, createElement, onPageCreate, onPageCreated } from './page'
+import { flushPostActionJobs } from './scheduler'
export function onVdSync(actions: PageAction[]) {
actions.forEach((action) => {
@@ -32,4 +33,5 @@ export function onVdSync(actions: PageAction[]) {
return $(action[1]).setText(action[2])
}
})
+ flushPostActionJobs()
}
diff --git a/packages/uni-app-plus/src/view/framework/dom/scheduler.ts b/packages/uni-app-plus/src/view/framework/dom/scheduler.ts
new file mode 100644
index 0000000000000000000000000000000000000000..a845aeaeb0fc302e817e647d4915c409c26e84fd
--- /dev/null
+++ b/packages/uni-app-plus/src/view/framework/dom/scheduler.ts
@@ -0,0 +1,16 @@
+import { formatLog } from '@dcloudio/uni-shared'
+
+const postActionJobs = new Set()
+export function queuePostActionJob(job: Function) {
+ postActionJobs.add(job)
+}
+export function flushPostActionJobs() {
+ if (__DEV__) {
+ console.log(formatLog(`flushPostActionJobs`, postActionJobs.size))
+ }
+ try {
+ postActionJobs.forEach((fn) => fn())
+ } finally {
+ postActionJobs.clear()
+ }
+}
diff --git a/packages/uni-app-plus/src/view/framework/index.ts b/packages/uni-app-plus/src/view/framework/index.ts
deleted file mode 100644
index db13055bcd41fbb937925943edb90915449a9487..0000000000000000000000000000000000000000
--- a/packages/uni-app-plus/src/view/framework/index.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { initSubscribeHandlers } from './subscriber'
-import { preventDoubleTap } from './gesture'
-
-export function initView() {
- initSubscribeHandlers()
- preventDoubleTap()
-}
diff --git a/packages/uni-app-plus/src/view/index.ts b/packages/uni-app-plus/src/view/index.ts
index 04a075199a5f977a83f9952816d4357dfbea7abf..a28b82a3ab8fe5c6762aa5d249b4f5522e4b2f95 100644
--- a/packages/uni-app-plus/src/view/index.ts
+++ b/packages/uni-app-plus/src/view/index.ts
@@ -1,16 +1,19 @@
import '../../style/framework/base.css'
import '@dcloudio/uni-h5/style/framework/nvue.css'
-
+import { initView } from '@dcloudio/uni-core'
import { ON_WEBVIEW_READY } from '../constants'
import { UniViewJSBridge } from './bridge'
-import { initView } from './framework'
import * as uni from './api'
+import { preventDoubleTap } from './framework/gesture'
+import { initSubscribeHandlers } from './framework/subscriber'
;(window as any).uni = uni
;(window as any).UniViewJSBridge = UniViewJSBridge
;(window as any).rpx2px = uni.upx2px
function onWebviewReady() {
initView()
+ initSubscribeHandlers()
+ preventDoubleTap()
UniViewJSBridge.publishHandler(ON_WEBVIEW_READY)
}
if (typeof plus !== 'undefined') {
diff --git a/packages/uni-app-plus/vite.config.ts b/packages/uni-app-plus/vite.config.ts
index 3888caa2c2846fee46b07b87e862a0fc36b9811f..610d8bc0f7e44c0c10a87fcd15809d3cbb8e8757 100644
--- a/packages/uni-app-plus/vite.config.ts
+++ b/packages/uni-app-plus/vite.config.ts
@@ -22,6 +22,7 @@ const rollupPlugins = [
defineSyncApi: `/*#__PURE__*/ defineSyncApi`,
defineAsyncApi: `/*#__PURE__*/ defineAsyncApi`,
__IMPORT_META_ENV_BASE_URL__: 'import.meta.env.BASE_URL', //直接使用import.meta.env.BASE_URL会被vite替换成'/'
+ __UNI_FEATURE_LONGPRESS__: JSON.stringify(true),
},
preventAssignment: true,
}),
diff --git a/packages/uni-components/src/components/text/index.tsx b/packages/uni-components/src/components/text/index.tsx
index 282743807006aae9bcc23543a12d3ba609c53d4a..d1f2ddae7bc0fb9f8df2a86952240bc420ca096f 100644
--- a/packages/uni-components/src/components/text/index.tsx
+++ b/packages/uni-components/src/components/text/index.tsx
@@ -1,33 +1,6 @@
import { VNode, Component, createTextVNode, createVNode } from 'vue'
import { defineBuiltInComponent } from '../../helpers/component'
-
-const SPACE_UNICODE = {
- ensp: '\u2002',
- emsp: '\u2003',
- nbsp: '\u00a0',
-}
-
-interface DecodeOptions {
- space: keyof typeof SPACE_UNICODE
- decode: boolean
-}
-function normalizeText(text: string, { space, decode }: DecodeOptions) {
- if (space && SPACE_UNICODE[space]) {
- text = text.replace(/ /g, SPACE_UNICODE[space])
- }
- if (!decode) {
- return text
- }
- return text
- .replace(/ /g, SPACE_UNICODE.nbsp)
- .replace(/ /g, SPACE_UNICODE.ensp)
- .replace(/ /g, SPACE_UNICODE.emsp)
- .replace(/</g, '<')
- .replace(/>/g, '>')
- .replace(/&/g, '&')
- .replace(/"/g, '"')
- .replace(/'/g, "'")
-}
+import { DecodeOptions, parseText } from '../../helpers/text'
export default /*#__PURE__*/ defineBuiltInComponent({
name: 'Text',
@@ -51,22 +24,16 @@ export default /*#__PURE__*/ defineBuiltInComponent({
if (slots.default) {
slots.default().forEach((vnode) => {
if (vnode.shapeFlag & 8 /* TEXT_CHILDREN */) {
- const lines = (vnode.children as string)
- .replace(/\\n/g, '\n')
- .split('\n')
+ const lines = parseText(vnode.children as string, {
+ space: props.space as DecodeOptions['space'],
+ decode: props.decode as boolean,
+ })
const len = lines.length - 1
- lines.forEach((text, index) => {
- if (index === 0 && !text) {
- //临时方案解决(\n横向布局) Hydration node mismatch
+ lines.forEach((line, index) => {
+ if (index === 0 && !line) {
+ // 临时方案解决(\n横向布局) Hydration node mismatch
} else {
- children.push(
- createTextVNode(
- normalizeText(text, {
- space: props.space as DecodeOptions['space'],
- decode: props.decode as boolean,
- })
- )
- )
+ children.push(createTextVNode(line))
}
if (index !== len) {
children.push(createVNode('br'))
diff --git a/packages/uni-components/src/helpers/text.ts b/packages/uni-components/src/helpers/text.ts
new file mode 100644
index 0000000000000000000000000000000000000000..09eee86e647571d7f9587ded1027863ac2cec663
--- /dev/null
+++ b/packages/uni-components/src/helpers/text.ts
@@ -0,0 +1,40 @@
+const SPACE_UNICODE = {
+ ensp: '\u2002',
+ emsp: '\u2003',
+ nbsp: '\u00a0',
+}
+
+export interface DecodeOptions {
+ space?: keyof typeof SPACE_UNICODE
+ decode?: boolean
+}
+
+export function parseText(text: string, options: DecodeOptions) {
+ return text
+ .replace(/\\n/g, '\n')
+ .split('\n')
+ .map((text) => {
+ return normalizeText(text, options)
+ })
+}
+
+function normalizeText(text: string, { space, decode }: DecodeOptions) {
+ if (!text) {
+ return text
+ }
+ if (space && SPACE_UNICODE[space]) {
+ text = text.replace(/ /g, SPACE_UNICODE[space])
+ }
+ if (!decode) {
+ return text
+ }
+ return text
+ .replace(/ /g, SPACE_UNICODE.nbsp)
+ .replace(/ /g, SPACE_UNICODE.ensp)
+ .replace(/ /g, SPACE_UNICODE.emsp)
+ .replace(/</g, '<')
+ .replace(/>/g, '>')
+ .replace(/&/g, '&')
+ .replace(/"/g, '"')
+ .replace(/'/g, "'")
+}
diff --git a/packages/uni-components/src/index.ts b/packages/uni-components/src/index.ts
index 84d3b1367b4c2d2b4716e0330a3280c65a6a5192..dc51f3e635a8a216dd632d28ea732942bba64c21 100644
--- a/packages/uni-components/src/index.ts
+++ b/packages/uni-components/src/index.ts
@@ -12,6 +12,7 @@ export type {
EmitEvent,
} from './helpers/useEvent'
export * from './helpers/scroller'
+export { parseText } from './helpers/text'
export { useUserAction } from './helpers/useUserAction'
export { useAttrs } from './helpers/useAttrs'
export { useBooleanAttr } from './helpers/useBooleanAttr'
@@ -23,3 +24,4 @@ export {
export { flatVNode } from './helpers/flatVNode'
export { uniFormKey } from './components/form'
export type { UniFormCtx } from './components/form'
+export type { DecodeOptions } from './helpers/text'
diff --git a/packages/uni-h5/dist/uni-h5.cjs.js b/packages/uni-h5/dist/uni-h5.cjs.js
index b542085888b510c10f9fb51ce8a4dd4080b2337d..151b06e84b455f1d5332bcf45926c0e91f13cbff 100644
--- a/packages/uni-h5/dist/uni-h5.cjs.js
+++ b/packages/uni-h5/dist/uni-h5.cjs.js
@@ -6284,18 +6284,20 @@ function useSwitchInject(props2, switchChecked) {
}
return uniLabel;
}
-function _isSlot$3(s) {
- return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !vue.isVNode(s);
-}
const SPACE_UNICODE = {
ensp: "\u2002",
emsp: "\u2003",
nbsp: "\xA0"
};
-function normalizeText(text, {
- space,
- decode
-}) {
+function parseText(text, options) {
+ return text.replace(/\\n/g, "\n").split("\n").map((text2) => {
+ return normalizeText(text2, options);
+ });
+}
+function normalizeText(text, { space, decode }) {
+ if (!text) {
+ return text;
+ }
if (space && SPACE_UNICODE[space]) {
text = text.replace(/ /g, SPACE_UNICODE[space]);
}
@@ -6304,6 +6306,9 @@ function normalizeText(text, {
}
return text.replace(/ /g, SPACE_UNICODE.nbsp).replace(/ /g, SPACE_UNICODE.ensp).replace(/ /g, SPACE_UNICODE.emsp).replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&").replace(/"/g, '"').replace(/'/g, "'");
}
+function _isSlot$3(s) {
+ return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !vue.isVNode(s);
+}
var index$d = /* @__PURE__ */ defineBuiltInComponent({
name: "Text",
props: {
@@ -6329,16 +6334,16 @@ var index$d = /* @__PURE__ */ defineBuiltInComponent({
if (slots.default) {
slots.default().forEach((vnode) => {
if (vnode.shapeFlag & 8) {
- const lines = vnode.children.replace(/\\n/g, "\n").split("\n");
+ const lines = parseText(vnode.children, {
+ space: props2.space,
+ decode: props2.decode
+ });
const len = lines.length - 1;
- lines.forEach((text, index2) => {
- if (index2 === 0 && !text)
+ lines.forEach((line, index2) => {
+ if (index2 === 0 && !line)
;
else {
- children.push(vue.createTextVNode(normalizeText(text, {
- space: props2.space,
- decode: props2.decode
- })));
+ children.push(vue.createTextVNode(line));
}
if (index2 !== len) {
children.push(vue.createVNode("br"));
diff --git a/packages/uni-h5/dist/uni-h5.es.js b/packages/uni-h5/dist/uni-h5.es.js
index e751fedabcbaa15a13d85790acb11d84b5519db6..d572b36de01708261944c6a4b9696ce931a9f64f 100644
--- a/packages/uni-h5/dist/uni-h5.es.js
+++ b/packages/uni-h5/dist/uni-h5.es.js
@@ -12718,18 +12718,20 @@ function useSwitchInject(props2, switchChecked) {
}
return uniLabel;
}
-function _isSlot$5(s) {
- return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
-}
const SPACE_UNICODE = {
ensp: "\u2002",
emsp: "\u2003",
nbsp: "\xA0"
};
-function normalizeText(text2, {
- space,
- decode: decode2
-}) {
+function parseText(text2, options) {
+ return text2.replace(/\\n/g, "\n").split("\n").map((text22) => {
+ return normalizeText(text22, options);
+ });
+}
+function normalizeText(text2, { space, decode: decode2 }) {
+ if (!text2) {
+ return text2;
+ }
if (space && SPACE_UNICODE[space]) {
text2 = text2.replace(/ /g, SPACE_UNICODE[space]);
}
@@ -12738,6 +12740,9 @@ function normalizeText(text2, {
}
return text2.replace(/ /g, SPACE_UNICODE.nbsp).replace(/ /g, SPACE_UNICODE.ensp).replace(/ /g, SPACE_UNICODE.emsp).replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&").replace(/"/g, '"').replace(/'/g, "'");
}
+function _isSlot$5(s) {
+ return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
+}
var index$d = /* @__PURE__ */ defineBuiltInComponent({
name: "Text",
props: {
@@ -12763,16 +12768,16 @@ var index$d = /* @__PURE__ */ defineBuiltInComponent({
if (slots.default) {
slots.default().forEach((vnode) => {
if (vnode.shapeFlag & 8) {
- const lines = vnode.children.replace(/\\n/g, "\n").split("\n");
+ const lines = parseText(vnode.children, {
+ space: props2.space,
+ decode: props2.decode
+ });
const len = lines.length - 1;
- lines.forEach((text2, index2) => {
- if (index2 === 0 && !text2)
+ lines.forEach((line, index2) => {
+ if (index2 === 0 && !line)
;
else {
- children.push(createTextVNode(normalizeText(text2, {
- space: props2.space,
- decode: props2.decode
- })));
+ children.push(createTextVNode(line));
}
if (index2 !== len) {
children.push(createVNode("br"));
diff --git a/yarn.lock b/yarn.lock
index f222845ba1141e489f688d9a419178c15bf2fd32..70c9cbfe9dfcafaaadd0e11e3b3ca3502234e231 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -924,8 +924,8 @@
"@dcloudio/types@^2.3.2":
version "2.3.2"
- resolved "https://registry.nlark.com/@dcloudio/types/download/@dcloudio/types-2.3.2.tgz#8c4c7e22ad650588935d07754c1f1552d86b7a97"
- integrity sha1-jEx+Iq1lBYiTXQd1TB8VUthrepc=
+ resolved "https://registry.yarnpkg.com/@dcloudio/types/-/types-2.3.2.tgz#8c4c7e22ad650588935d07754c1f1552d86b7a97"
+ integrity sha512-ZyAkqPwlPtXtGcf7qYkB/iX4nER/JcNeCXR2VPqXxBmagE8wjRYtkKjso1YUsFyDIoaNBBY1CtzV3iKa6oREeg==
"@eslint/eslintrc@^0.4.2":
version "0.4.2"
@@ -2382,9 +2382,9 @@
integrity sha512-DN/CCT1HQG6HquBNJdLkvV+4v5l/oEuwOHUPLxI+Eub0NED+lk0YUfba04WGH90EINiUrNgClkNnwGmbICeWMQ==
"@types/node@*":
- version "16.3.0"
- resolved "https://registry.yarnpkg.com/@types/node/-/node-16.3.0.tgz#1836664e4fad13b51b07eb6e882a53925e6543c4"
- integrity sha512-OydMCocGMGqw/1BnWbhtK+AtwyWTOigtrQlRe57OQmTNcI3HKlVI5FGlh+c4mSqInMPLynFrTlYjfajPu9O/eQ==
+ version "16.3.1"
+ resolved "https://registry.yarnpkg.com/@types/node/-/node-16.3.1.tgz#24691fa2b0c3ec8c0d34bfcfd495edac5593ebb4"
+ integrity sha512-N87VuQi7HEeRJkhzovao/JviiqKjDKMVKxKMfUvSKw+MbkbW8R0nA3fi/MQhhlxV2fQ+2ReM+/Nt4efdrJx3zA==
"@types/node@10.17.13":
version "10.17.13"
@@ -2941,12 +2941,12 @@ at-least-node@^1.0.0:
integrity sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==
autoprefixer@^10.2.5:
- version "10.2.6"
- resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-10.2.6.tgz#aadd9ec34e1c98d403e01950038049f0eb252949"
- integrity sha512-8lChSmdU6dCNMCQopIf4Pe5kipkAGj/fvTMslCsih0uHpOrXOPUEVOmYMMqmw3cekQkSD7EhIeuYl5y0BLdKqg==
+ version "10.3.0"
+ resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-10.3.0.tgz#c60803dce9268f7fe0a5e5c1fe48a74356d7b864"
+ integrity sha512-BzVzdjs47nT3MphTddr8eSsPVEIUCF96X6iC8V5iEB8RtxrU+ybtdhHV5rsqRqOsoyh/acQaYs7YupHPUECgmg==
dependencies:
browserslist "^4.16.6"
- caniuse-lite "^1.0.30001230"
+ caniuse-lite "^1.0.30001243"
colorette "^1.2.2"
fraction.js "^4.1.1"
normalize-range "^0.1.2"
@@ -3327,7 +3327,7 @@ camelcase@^6.0.0, camelcase@^6.2.0:
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.2.0.tgz#924af881c9d525ac9d87f40d964e5cea982a1809"
integrity sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg==
-caniuse-lite@^1.0.30001219, caniuse-lite@^1.0.30001230:
+caniuse-lite@^1.0.30001219, caniuse-lite@^1.0.30001243:
version "1.0.30001243"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001243.tgz#d9250155c91e872186671c523f3ae50cfc94a3aa"
integrity sha512-vNxw9mkTBtkmLFnJRv/2rhs1yufpDfCkBZexG3Y0xdOH2Z/eE/85E4Dl5j1YUN34nZVsSp6vVRFQRrez9wJMRA==
@@ -4066,9 +4066,9 @@ ee-first@1.1.1:
integrity sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=
electron-to-chromium@^1.3.723:
- version "1.3.771"
- resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.771.tgz#c4aa601e6420e11926095f75fe803956a1b4bd81"
- integrity sha512-zHMomTqkpnAD9W5rhXE1aiU3ogGFrqWzdvM4C6222SREiqsWQb2w0S7P2Ii44qCaGimmAP1z+OydllM438uJyA==
+ version "1.3.772"
+ resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.772.tgz#fd1ed39f9f3149f62f581734e4f026e600369479"
+ integrity sha512-X/6VRCXWALzdX+RjCtBU6cyg8WZgoxm9YA02COmDOiNJEZ59WkQggDbWZ4t/giHi/3GS+cvdrP6gbLISANAGYA==
elliptic@^6.5.3:
version "6.5.4"
@@ -8289,9 +8289,9 @@ rollup-pluginutils@^2.3.1, rollup-pluginutils@^2.8.2:
estree-walker "^0.6.1"
rollup@^2.35.1, rollup@^2.38.5:
- version "2.53.0"
- resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.53.0.tgz#5b6bc7820a03f361d2ae3dcabdc99d269a754709"
- integrity sha512-spgrY78Toh+m0+zaOoeaayJKuzFuWy6o1PdFIBMVwRcuxT0xCOX9A5rChyKe+2ruL4lePKWUMImS4mMW1QAkmQ==
+ version "2.53.1"
+ resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.53.1.tgz#b60439efd1eb41bdb56630509bd99aae78b575d3"
+ integrity sha512-yiTCvcYXZEulNWNlEONOQVlhXA/hgxjelFSjNcrwAAIfYx/xqjSHwqg/cCaWOyFRKr+IQBaXwt723m8tCaIUiw==
optionalDependencies:
fsevents "~2.3.2"
@@ -9567,9 +9567,9 @@ write-pkg@^4.0.0:
write-json-file "^3.2.0"
ws@^7.4.5:
- version "7.5.2"
- resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.2.tgz#09cc8fea3bec1bc5ed44ef51b42f945be36900f6"
- integrity sha512-lkF7AWRicoB9mAgjeKbGqVUekLnSNO4VjKVnuPHpQeOxZOErX6BPXwJk70nFslRCEEA8EVW7ZjKwXaP9N+1sKQ==
+ version "7.5.3"
+ resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.3.tgz#160835b63c7d97bfab418fc1b8a9fced2ac01a74"
+ integrity sha512-kQ/dHIzuLrS6Je9+uv81ueZomEwH0qVYstcAQ4/Z93K8zeko9gtAbttJWzoC5ukqXY1PpoouV3+VSOqEAFt5wg==
xml-name-validator@^3.0.0:
version "3.0.0"