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

chore: workflow (+1 squashed commit)

Squashed commits:
[328ce6a83] feat(app): add invokeServiceMethod
上级 7642a0ce
......@@ -393,7 +393,7 @@ declare namespace UniApp {
* @param event
* @param callback
*/
subscribe(event: string, callback: CallbackFunction): void
subscribe(event: string, callback: CallbackFunction, once?: boolean): void
/**
* 取消订阅 Service 的自定义事件
* 如果没有提供参数,则移除所有的事件监听器;
......@@ -417,5 +417,16 @@ declare namespace UniApp {
* @param pageId
*/
publishHandler(event: string, args?: unknown, pageId?: number): void
/**
* 执行 View 层方法,并获取返回值
* @param name
* @param args
* @param callback
*/
invokeServiceMethod<Args = any, Res = any>(
name: string,
args: Args,
callback?: (res: Res) => void
): void
}
}
......@@ -1143,7 +1143,37 @@ uni-input[hidden] {
.uni-label-pointer {
cursor: pointer;
}
uni-movable-area {
uni-map {
width: 300px;
height: 225px;
display: inline-block;
line-height: 0;
overflow: hidden;
position: relative;
}
uni-map[hidden] {
display: none;
}
.uni-map-container {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
overflow: hidden;
background-color: black;
}
.uni-map-slot {
position: absolute;
top: 0;
width: 100%;
height: 100%;
overflow: hidden;
pointer-events: none;
}uni-movable-area {
display: block;
position: relative;
width: 10px;
......
......@@ -1587,6 +1587,54 @@ var serviceContext = (function (vue) {
}));
}
});
const initI18nScanCodeMsgsOnce = /*#__PURE__*/ once(() => {
const name = 'uni.scanCode.';
{
useI18n().add(LOCALE_EN, normalizeMessages(name, {
title: 'Scan code',
album: 'Album',
fail: 'Recognition failure',
'flash.on': 'Tap to turn light on',
'flash.off': 'Tap to turn light off',
}));
}
{
useI18n().add(LOCALE_ES, normalizeMessages(name, {
title: 'Código de escaneo',
album: 'Álbum',
fail: 'Échec de la reconnaissance',
'flash.on': 'Toque para encender la luz',
'flash.off': 'Toque para apagar la luz',
}));
}
{
useI18n().add(LOCALE_FR, normalizeMessages(name, {
title: 'Code d’analyse',
album: 'Album',
fail: 'Fallo de reconocimiento',
'flash.on': "Appuyez pour activer l'éclairage",
'flash.off': "Appuyez pour désactiver l'éclairage",
}));
}
{
useI18n().add(LOCALE_ZH_HANS, normalizeMessages(name, {
title: '扫码',
album: '相册',
fail: '识别失败',
'flash.on': '轻触照亮',
'flash.off': '轻触关闭',
}));
}
{
useI18n().add(LOCALE_ZH_HANT, normalizeMessages(name, {
title: '掃碼',
album: '相冊',
fail: '識別失敗',
'flash.on': '輕觸照亮',
'flash.off': '輕觸關閉',
}));
}
});
const initI18nStartSoterAuthenticationMsgsOnce = /*#__PURE__*/ once(() => {
const name = 'uni.startSoterAuthentication.';
{
......@@ -1610,8 +1658,6 @@ var serviceContext = (function (vue) {
}
});
const INVOKE_VIEW_API = 'invokeViewApi';
const E = function () {
// Keep this empty so it's easier to inherit from
// (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)
......@@ -1694,6 +1740,9 @@ var serviceContext = (function (vue) {
};
}
const INVOKE_VIEW_API = 'invokeViewApi';
const INVOKE_SERVICE_API = 'invokeServiceApi';
function hasRpx(str) {
str = str + '';
return str.indexOf('rpx') !== -1 || str.indexOf('upx') !== -1;
......@@ -1861,13 +1910,15 @@ var serviceContext = (function (vue) {
}
}
let invokeViewMethodId = 0;
const invokeOnCallback = (name, res) => UniServiceJSBridge.emit('api.' + name, res);
let invokeViewMethodId = 1;
function publishViewMethodName() {
return getCurrentPageId() + '.' + INVOKE_VIEW_API;
}
const invokeViewMethod = (name, args, pageId, callback) => {
const { subscribe, publishHandler } = UniServiceJSBridge;
const id = invokeViewMethodId++;
const id = callback ? invokeViewMethodId++ : 0;
callback && subscribe(INVOKE_VIEW_API + '.' + id, callback, true);
publishHandler(publishViewMethodName(), { id, name, args }, pageId);
};
......@@ -1880,8 +1931,34 @@ var serviceContext = (function (vue) {
return () => {
unsubscribe(subscribeName);
};
};
const invokeOnCallback = (name, res) => UniServiceJSBridge.emit('api.' + name, res);
};
const serviceMethods = Object.create(null);
function subscribeServiceMethod() {
UniServiceJSBridge.subscribe(INVOKE_SERVICE_API, onInvokeServiceMethod);
}
function registerServiceMethod(name, fn) {
if (!serviceMethods[name]) {
serviceMethods[name] = fn;
}
}
function onInvokeServiceMethod({ id, name, args, }, pageId) {
const publish = (res) => {
id &&
UniServiceJSBridge.publishHandler(INVOKE_SERVICE_API + '.' + id, res, pageId);
};
const handler = serviceMethods[name];
if (handler) {
handler(args, publish);
}
else {
publish({});
if ((process.env.NODE_ENV !== 'production')) {
console.error(formatLog('invokeViewMethod', name, 'not register'));
}
}
}
const ServiceJSBridge = /*#__PURE__*/ extend(initBridge('view' /* view 指的是 service 层订阅的是 view 层事件 */), {
invokeOnCallback,
invokeViewMethod,
......@@ -2052,8 +2129,21 @@ var serviceContext = (function (vue) {
return false;
}
function operateVideoPlayer(videoId, pageId, type, data) { }
function operateMap(id, pageId, type, data) { }
function operateVideoPlayer(videoId, pageId, type, data) {
UniServiceJSBridge.invokeViewMethod('video.' + videoId, {
videoId,
type,
data,
}, pageId);
}
function operateMap(id, pageId, type, data, operateMapCallback) {
UniServiceJSBridge.invokeViewMethod('map.' + id, {
type,
data,
}, pageId, operateMapCallback);
}
function addIntersectionObserver(args, pageId) { }
function removeIntersectionObserver(args, pageId) { }
function addMediaQueryObserver(args, pageId) { }
......@@ -2295,40 +2385,48 @@ var serviceContext = (function (vue) {
];
const API_CREATE_INNER_AUDIO_CONTEXT = 'createInnerAudioContext';
const RATES = [0.5, 0.8, 1.0, 1.25, 1.5, 2.0];
class VideoContext {
constructor(id, pageId) {
this.id = id;
this.pageId = pageId;
}
play() {
operateVideoPlayer(this.id, this.pageId);
operateVideoPlayer(this.id, this.pageId, 'play');
}
pause() {
operateVideoPlayer(this.id, this.pageId);
operateVideoPlayer(this.id, this.pageId, 'pause');
}
stop() {
operateVideoPlayer(this.id, this.pageId);
operateVideoPlayer(this.id, this.pageId, 'stop');
}
seek(position) {
operateVideoPlayer(this.id, this.pageId);
operateVideoPlayer(this.id, this.pageId, 'seek', {
position,
});
}
sendDanmu(args) {
operateVideoPlayer(this.id, this.pageId);
operateVideoPlayer(this.id, this.pageId, 'sendDanmu', args);
}
playbackRate(rate) {
operateVideoPlayer(this.id, this.pageId);
if (!~RATES.indexOf(rate)) {
rate = 1.0;
}
operateVideoPlayer(this.id, this.pageId, 'playbackRate', {
rate,
});
}
requestFullScreen(args = {}) {
operateVideoPlayer(this.id, this.pageId);
operateVideoPlayer(this.id, this.pageId, 'requestFullScreen', args);
}
exitFullScreen() {
operateVideoPlayer(this.id, this.pageId);
operateVideoPlayer(this.id, this.pageId, 'exitFullScreen');
}
showStatusBar() {
operateVideoPlayer(this.id, this.pageId);
operateVideoPlayer(this.id, this.pageId, 'showStatusBar');
}
hideStatusBar() {
operateVideoPlayer(this.id, this.pageId);
operateVideoPlayer(this.id, this.pageId, 'hideStatusBar');
}
}
const createVideoContext = defineSyncApi(API_CREATE_VIDEO_CONTEXT, (id, context) => {
......@@ -2338,28 +2436,48 @@ var serviceContext = (function (vue) {
return new VideoContext(id, getPageIdByVm(getCurrentPageVm()));
});
const operateMapCallback = (options, res) => {
const errMsg = res.errMsg || '';
if (new RegExp('\\:\\s*fail').test(errMsg)) {
options.fail && options.fail(res);
}
else {
options.success && options.success(res);
}
options.complete && options.complete(res);
};
const operateMapWrap = (id, pageId, type, options) => {
operateMap(id, pageId, type, options, (res) => {
options && operateMapCallback(options, res);
});
};
class MapContext {
constructor(id, pageId) {
this.id = id;
this.pageId = pageId;
}
getCenterLocation(options) {
operateMap(this.id, this.pageId);
operateMapWrap(this.id, this.pageId, 'getCenterLocation', options);
}
moveToLocation() {
operateMap(this.id, this.pageId);
operateMapWrap(this.id, this.pageId, 'moveToLocation');
}
getScale(options) {
operateMap(this.id, this.pageId);
operateMapWrap(this.id, this.pageId, 'getScale', options);
}
getRegion(options) {
operateMap(this.id, this.pageId);
operateMapWrap(this.id, this.pageId, 'getRegion', options);
}
includePoints(options) {
operateMap(this.id, this.pageId);
operateMapWrap(this.id, this.pageId, 'includePoints', options);
}
translateMarker(options) {
operateMap(this.id, this.pageId);
operateMapWrap(this.id, this.pageId, 'translateMarker', options);
}
$getAppMap() {
{
return plus.maps.getMapById(this.pageId + '-map-' + this.id);
}
}
addCustomLayer() { }
removeCustomLayer() { }
......@@ -2370,8 +2488,7 @@ var serviceContext = (function (vue) {
addMarkers() { }
removeMarkers() { }
moveAlong() { }
openMapAp() { }
$getAppMap() { }
openMapApp() { }
}
const createMapContext = defineSyncApi(API_CREATE_MAP_CONTEXT, (id, context) => {
if (context) {
......@@ -4027,6 +4144,13 @@ var serviceContext = (function (vue) {
authContent: String,
};
const API_SCAN_CODE = 'scanCode';
const ScanCodeProtocol = {
onlyFromCamera: Boolean,
scanType: Array,
autoDecodeCharSet: Boolean,
};
const API_GET_STORAGE = 'getStorage';
const GetStorageProtocol = {
key: {
......@@ -5774,8 +5898,222 @@ var serviceContext = (function (vue) {
}
}, StartSoterAuthenticationProtocols, StartSoterAuthenticationOptions);
let plus_;
let weex_;
let BroadcastChannel_;
function getRuntime() {
return typeof window === 'object' &&
typeof navigator === 'object' &&
typeof document === 'object'
? 'webview'
: 'v8';
}
function getPageId() {
return plus_.webview.currentWebview().id;
}
let channel;
let globalEvent$1;
const callbacks$2 = {};
function onPlusMessage$1(res) {
const message = res.data && res.data.__message;
if (!message || !message.__page) {
return;
}
const pageId = message.__page;
const callback = callbacks$2[pageId];
callback && callback(message);
if (!message.keep) {
delete callbacks$2[pageId];
}
}
function addEventListener(pageId, callback) {
if (getRuntime() === 'v8') {
if (BroadcastChannel_) {
channel && channel.close();
channel = new BroadcastChannel_(getPageId());
channel.onmessage = onPlusMessage$1;
}
else if (!globalEvent$1) {
globalEvent$1 = weex_.requireModule('globalEvent');
globalEvent$1.addEventListener('plusMessage', onPlusMessage$1);
}
}
else {
// @ts-ignore
window.__plusMessage = onPlusMessage$1;
}
callbacks$2[pageId] = callback;
}
class Page {
constructor(webview) {
this.webview = webview;
}
sendMessage(data) {
const message = {
__message: {
data,
},
};
const id = this.webview.id;
if (BroadcastChannel_) {
const channel = new BroadcastChannel_(id);
channel.postMessage(message);
}
else {
plus_.webview.postMessageToUniNView &&
plus_.webview.postMessageToUniNView(message, id);
}
}
close() {
this.webview.close();
}
}
function showPage({ context = {}, url, data = {}, style = {}, onMessage, onClose, }) {
// eslint-disable-next-line
plus_ = context.plus || plus;
// eslint-disable-next-line
weex_ = context.weex || (typeof weex === 'object' ? weex : null);
// eslint-disable-next-line
BroadcastChannel_ =
context.BroadcastChannel ||
(typeof BroadcastChannel === 'object' ? BroadcastChannel : null);
const titleNView = {
autoBackButton: true,
titleSize: '17px',
};
const pageId = `page${Date.now()}`;
style = Object.assign({}, style);
if (style.titleNView !== false && style.titleNView !== 'none') {
style.titleNView = Object.assign(titleNView, style.titleNView);
}
const defaultStyle = {
top: 0,
bottom: 0,
usingComponents: {},
popGesture: 'close',
scrollIndicator: 'none',
animationType: 'pop-in',
animationDuration: 200,
uniNView: {
path: `${(typeof process === 'object' &&
process.env &&
process.env.VUE_APP_TEMPLATE_PATH) ||
''}/${url}.js`,
defaultFontSize: plus_.screen.resolutionWidth / 20,
viewport: plus_.screen.resolutionWidth,
},
};
style = Object.assign(defaultStyle, style);
const page = plus_.webview.create('', pageId, style, {
extras: {
from: getPageId(),
runtime: getRuntime(),
data,
useGlobalEvent: !BroadcastChannel_,
},
});
page.addEventListener('close', onClose);
addEventListener(pageId, (message) => {
if (typeof onMessage === 'function') {
onMessage(message.data);
}
if (!message.keep) {
page.close('auto');
}
});
page.show(style.animationType, style.animationDuration);
return new Page(page);
}
function getStatusBarStyle$1() {
let style = plus.navigator.getStatusBarStyle();
if (style === 'UIStatusBarStyleBlackTranslucent' ||
style === 'UIStatusBarStyleBlackOpaque' ||
style === 'null') {
style = 'light';
}
else if (style === 'UIStatusBarStyleDefault') {
style = 'dark';
}
return style;
}
const scanCode = defineAsyncApi(API_SCAN_CODE, (options, { resolve, reject }) => {
initI18nScanCodeMsgsOnce();
const { t } = useI18n();
const statusBarStyle = getStatusBarStyle$1();
const isDark = statusBarStyle !== 'light';
let result;
let success = false;
const page = showPage({
url: '__uniappscan',
data: Object.assign({}, options, {
messages: {
fail: t('uni.scanCode.fail'),
'flash.on': t('uni.scanCode.flash.on'),
'flash.off': t('uni.scanCode.flash.off'),
},
}),
style: {
// @ts-ignore
animationType: options.animationType || 'pop-in',
titleNView: {
autoBackButton: true,
// @ts-ignore
type: 'float',
// @ts-ignore
titleText: options.titleText || t('uni.scanCode.title'),
titleColor: '#ffffff',
backgroundColor: 'rgba(0,0,0,0)',
buttons: !options.onlyFromCamera
? [
{
// @ts-ignore
text: options.albumText || t('uni.scanCode.album'),
fontSize: '17px',
width: '60px',
onclick: () => {
page.sendMessage({
type: 'gallery',
});
},
},
]
: [],
},
popGesture: 'close',
background: '#000000',
backButtonAutoControl: 'close',
},
onMessage({ event, detail, }) {
result = detail;
success = event === 'marked';
},
onClose() {
if (isDark) {
plus.navigator.setStatusBarStyle('dark');
}
result
? success
? (delete result.message, resolve(result))
: reject(result.message)
: reject('cancel');
},
});
if (isDark) {
plus.navigator.setStatusBarStyle('light');
page.webview.addEventListener('popGesture', ({ type, result }) => {
if (type === 'start') {
plus.navigator.setStatusBarStyle('dark');
}
else if (type === 'end' && !result) {
plus.navigator.setStatusBarStyle('light');
}
});
}
}, ScanCodeProtocol);
const onThemeChange = defineOnApi(ON_THEME_CHANGE, () => {
UniServiceJSBridge.on(ON_THEME_CHANGE, res => {
UniServiceJSBridge.on(ON_THEME_CHANGE, (res) => {
UniServiceJSBridge.invokeOnCallback(ON_THEME_CHANGE, res);
});
});
......@@ -5929,7 +6267,7 @@ var serviceContext = (function (vue) {
}
},
};
const callbacks$2 = {
const callbacks$1 = {
pause: null,
resume: null,
start: null,
......@@ -5940,29 +6278,29 @@ var serviceContext = (function (vue) {
const state = res.state;
delete res.state;
delete res.errMsg;
if (state && typeof callbacks$2[state] === 'function') {
callbacks$2[state](res);
if (state && typeof callbacks$1[state] === 'function') {
callbacks$1[state](res);
}
}
class RecorderManager {
constructor() { }
onError(callback) {
callbacks$2.error = callback;
callbacks$1.error = callback;
}
onFrameRecorded(callback) { }
onInterruptionBegin(callback) { }
onInterruptionEnd(callback) { }
onPause(callback) {
callbacks$2.pause = callback;
callbacks$1.pause = callback;
}
onResume(callback) {
callbacks$2.resume = callback;
callbacks$1.resume = callback;
}
onStart(callback) {
callbacks$2.start = callback;
callbacks$1.start = callback;
}
onStop(callback) {
callbacks$2.stop = callback;
callbacks$1.stop = callback;
}
pause() {
Recorder.pause();
......@@ -6493,7 +6831,7 @@ var serviceContext = (function (vue) {
const socketTasks = [];
const socketsMap = {};
const globalEvent$1 = {
const globalEvent = {
open: '',
close: '',
error: '',
......@@ -6595,8 +6933,8 @@ var serviceContext = (function (vue) {
}
socketStateChange(name, res = {}) {
const data = name === 'message' ? res : {};
if (this === socketTasks[0] && globalEvent$1[name]) {
UniServiceJSBridge.invokeOnCallback(globalEvent$1[name], data);
if (this === socketTasks[0] && globalEvent[name]) {
UniServiceJSBridge.invokeOnCallback(globalEvent[name], data);
}
// WYQ fix: App平台修复websocket onOpen时发送数据报错的Bug
this._callbacks[name].forEach((callback) => {
......@@ -6695,7 +7033,7 @@ var serviceContext = (function (vue) {
function on(event) {
const api = `onSocket${capitalize(event)}`;
return defineOnApi(api, () => {
globalEvent$1[event] = api;
globalEvent[event] = api;
});
}
const onSocketOpen = /*#__PURE__*/ on('open');
......@@ -7077,7 +7415,7 @@ var serviceContext = (function (vue) {
'error',
'waiting',
];
const callbacks$1 = {
const callbacks = {
canplay: [],
play: [],
pause: [],
......@@ -7256,7 +7594,7 @@ var serviceContext = (function (vue) {
});
}
function onBackgroundAudioStateChange({ state, errMsg, errCode, dataUrl, }) {
callbacks$1[state].forEach((callback) => {
callbacks[state].forEach((callback) => {
if (typeof callback === 'function') {
callback(state === 'error'
? {
......@@ -7271,7 +7609,7 @@ var serviceContext = (function (vue) {
eventNames.forEach((item) => {
BackgroundAudioManager.prototype[`on${capitalize(item)}`] =
function (callback) {
callbacks$1[item].push(callback);
callbacks[item].push(callback);
};
});
});
......@@ -7497,133 +7835,6 @@ var serviceContext = (function (vue) {
});
}, GetLocationProtocol, GetLocationOptions);
let plus_;
let weex_;
let BroadcastChannel_;
function getRuntime() {
return typeof window === 'object' &&
typeof navigator === 'object' &&
typeof document === 'object'
? 'webview'
: 'v8';
}
function getPageId() {
return plus_.webview.currentWebview().id;
}
let channel;
let globalEvent;
const callbacks = {};
function onPlusMessage$1(res) {
const message = res.data && res.data.__message;
if (!message || !message.__page) {
return;
}
const pageId = message.__page;
const callback = callbacks[pageId];
callback && callback(message);
if (!message.keep) {
delete callbacks[pageId];
}
}
function addEventListener(pageId, callback) {
if (getRuntime() === 'v8') {
if (BroadcastChannel_) {
channel && channel.close();
channel = new BroadcastChannel_(getPageId());
channel.onmessage = onPlusMessage$1;
}
else if (!globalEvent) {
globalEvent = weex_.requireModule('globalEvent');
globalEvent.addEventListener('plusMessage', onPlusMessage$1);
}
}
else {
// @ts-ignore
window.__plusMessage = onPlusMessage$1;
}
callbacks[pageId] = callback;
}
class Page {
constructor(webview) {
this.webview = webview;
}
sendMessage(data) {
const message = {
__message: {
data,
},
};
const id = this.webview.id;
if (BroadcastChannel_) {
const channel = new BroadcastChannel_(id);
channel.postMessage(message);
}
else {
plus_.webview.postMessageToUniNView &&
plus_.webview.postMessageToUniNView(message, id);
}
}
close() {
this.webview.close();
}
}
function showPage({ context = {}, url, data = {}, style = {}, onMessage, onClose, }) {
// eslint-disable-next-line
plus_ = context.plus || plus;
// eslint-disable-next-line
weex_ = context.weex || (typeof weex === 'object' ? weex : null);
// eslint-disable-next-line
BroadcastChannel_ =
context.BroadcastChannel ||
(typeof BroadcastChannel === 'object' ? BroadcastChannel : null);
const titleNView = {
autoBackButton: true,
titleSize: '17px',
};
const pageId = `page${Date.now()}`;
style = Object.assign({}, style);
if (style.titleNView !== false && style.titleNView !== 'none') {
style.titleNView = Object.assign(titleNView, style.titleNView);
}
const defaultStyle = {
top: 0,
bottom: 0,
usingComponents: {},
popGesture: 'close',
scrollIndicator: 'none',
animationType: 'pop-in',
animationDuration: 200,
uniNView: {
path: `${(typeof process === 'object' &&
process.env &&
process.env.VUE_APP_TEMPLATE_PATH) ||
''}/${url}.js`,
defaultFontSize: plus_.screen.resolutionWidth / 20,
viewport: plus_.screen.resolutionWidth,
},
};
style = Object.assign(defaultStyle, style);
const page = plus_.webview.create('', pageId, style, {
extras: {
from: getPageId(),
runtime: getRuntime(),
data,
useGlobalEvent: !BroadcastChannel_,
},
});
page.addEventListener('close', onClose);
addEventListener(pageId, (message) => {
if (typeof onMessage === 'function') {
onMessage(message.data);
}
if (!message.keep) {
page.close('auto');
}
});
page.show(style.animationType, style.animationDuration);
return new Page(page);
}
function getStatusBarStyle() {
let style = plus.navigator.getStatusBarStyle();
if (style === 'UIStatusBarStyleBlackTranslucent' ||
......@@ -8646,7 +8857,6 @@ var serviceContext = (function (vue) {
const VD_SYNC = 'vdSync';
const ON_WEBVIEW_READY = 'onWebviewReady';
const INVOKE_SERVICE_API = 'invokeServiceApi';
const ACTION_TYPE_DICT = 0;
function onNodeEvent(nodeId, evt, pageNode) {
......@@ -8671,6 +8881,28 @@ var serviceContext = (function (vue) {
});
}
function subscribeAd() {
// view 层通过 UniViewJSBridge.invokeServiceMethod('getAdData', args, function({data})=>{console.log(data)})
registerServiceMethod('getAdData', (args, resolve) => {
// TODO args: view 层传输的参数,处理完之后,resolve:回传给 service,如resolve({data})
});
}
const API_ROUTE = [
'switchTab',
'reLaunch',
'redirectTo',
'navigateTo',
'navigateBack',
];
function subscribeNavigator() {
API_ROUTE.forEach((name) => {
registerServiceMethod(name, (args) => {
uni[name](args);
});
});
}
function initNVue(webviewStyle, routeMeta, path) {
if (path && routeMeta.isNVue) {
webviewStyle.uniNView = {
......@@ -9173,11 +9405,10 @@ var serviceContext = (function (vue) {
// 非纯原生
subscribe(ON_WEBVIEW_READY, subscribeWebviewReady);
subscribe(VD_SYNC, onVdSync);
subscribe(INVOKE_SERVICE_API, onInvokeServiceApi);
subscribeServiceMethod();
subscribeAd();
subscribeNavigator();
}
}
function onInvokeServiceApi({ data: { method, args }, }) {
uni[method] && uni[method](args);
}
let appCtx;
......@@ -10531,6 +10762,7 @@ var serviceContext = (function (vue) {
checkIsSupportSoterAuthentication: checkIsSupportSoterAuthentication,
checkIsSoterEnrolledInDevice: checkIsSoterEnrolledInDevice,
startSoterAuthentication: startSoterAuthentication,
scanCode: scanCode,
onThemeChange: onThemeChange,
getImageInfo: getImageInfo,
getVideoInfo: getVideoInfo,
......
......@@ -6,12 +6,12 @@
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";
var resizeSensor = "@keyframes once-show {\n from {\n top: 0;\n }\n}\nuni-resize-sensor,\nuni-resize-sensor > div {\n position: absolute;\n left: 0;\n top: 0;\n right: 0;\n bottom: 0;\n overflow: hidden;\n}\nuni-resize-sensor {\n display: block;\n z-index: -1;\n visibility: hidden;\n animation: once-show 1ms;\n}\nuni-resize-sensor > div > div {\n position: absolute;\n left: 0;\n top: 0;\n}\nuni-resize-sensor > div:first-child > div {\n width: 100000px;\n height: 100000px;\n}\nuni-resize-sensor > div:last-child > div {\n width: 200%;\n height: 200%;\n}\n";
function makeMap$1(str, expectsLowerCase) {
const map = Object.create(null);
const map2 = Object.create(null);
const list2 = str.split(",");
for (let i = 0; i < list2.length; i++) {
map[list2[i]] = true;
map2[list2[i]] = true;
}
return expectsLowerCase ? (val) => !!map[val.toLowerCase()] : (val) => !!map[val];
return expectsLowerCase ? (val) => !!map2[val.toLowerCase()] : (val) => !!map2[val];
}
const GLOBALS_WHITE_LISTED = "Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt";
const isGloballyWhitelisted = /* @__PURE__ */ makeMap$1(GLOBALS_WHITE_LISTED);
......@@ -568,7 +568,6 @@
}));
}
});
const INVOKE_VIEW_API = "invokeViewApi";
const E = function() {
};
E.prototype = {
......@@ -642,14 +641,22 @@
}
};
}
const ViewJSBridge = /* @__PURE__ */ initBridge("service");
const INVOKE_VIEW_API = "invokeViewApi";
const INVOKE_SERVICE_API = "invokeServiceApi";
let invokeServiceMethodId = 1;
const invokeServiceMethod = (name, args, callback) => {
const { subscribe, publishHandler: publishHandler2 } = UniViewJSBridge;
const id2 = callback ? invokeServiceMethodId++ : 0;
callback && subscribe(INVOKE_SERVICE_API + "." + id2, callback, true);
publishHandler2(INVOKE_SERVICE_API, { id: id2, name, args });
};
const viewMethods = Object.create(null);
function normalizeViewMethodName(pageId, name) {
return pageId + "." + name;
}
function subscribeViewMethod(pageId) {
UniViewJSBridge.subscribe(normalizeViewMethodName(pageId, INVOKE_VIEW_API), onInvokeViewMethod);
}
const viewMethods = Object.create(null);
function registerViewMethod(pageId, name, fn) {
name = normalizeViewMethodName(pageId, name);
if (!viewMethods[name]) {
......@@ -667,7 +674,7 @@
}, pageId) {
name = normalizeViewMethodName(pageId, name);
const publish = (res) => {
UniViewJSBridge.publishHandler(INVOKE_VIEW_API + "." + id2, res);
id2 && UniViewJSBridge.publishHandler(INVOKE_VIEW_API + "." + id2, res);
};
const handler = viewMethods[name];
if (handler) {
......@@ -679,6 +686,9 @@
}
}
}
const ViewJSBridge = /* @__PURE__ */ extend(initBridge("service"), {
invokeServiceMethod
});
const LONGPRESS_TIMEOUT = 350;
const LONGPRESS_THRESHOLD = 10;
const passiveOptions$2 = passive(true);
......@@ -3964,7 +3974,31 @@
return result;
}
const isTeleport = (type) => type.__isTeleport;
const COMPONENTS = "components";
function resolveComponent(name, maybeSelfReference) {
return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
}
const NULL_DYNAMIC_COMPONENT = Symbol();
function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
const instance = currentRenderingInstance || currentInstance;
if (instance) {
const Component = instance.type;
if (type === COMPONENTS) {
const selfName = getComponentName(Component);
if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
return Component;
}
}
const res = resolve(instance[type] || Component[type], name) || resolve(instance.appContext[type], name);
if (!res && maybeSelfReference) {
return Component;
}
return res;
}
}
function resolve(registry, name) {
return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
}
const Fragment = Symbol(void 0);
const Text$1 = Symbol(void 0);
const Comment$1 = Symbol(void 0);
......@@ -5411,7 +5445,6 @@
[ON_PAGE_SCROLL, ON_REACH_BOTTOM];
const VD_SYNC = "vdSync";
const ON_WEBVIEW_READY = "onWebviewReady";
const INVOKE_SERVICE_API = "invokeServiceApi";
const ACTION_TYPE_DICT = 0;
const APP_SERVICE_ID = "__uniapp__service";
const UniViewJSBridge$1 = /* @__PURE__ */ extend(ViewJSBridge, {
......@@ -5729,31 +5762,20 @@
confirmColor: PRIMARY_COLOR
}
});
function invokeServiceApi(method, args = {}) {
UniViewJSBridge.publishHandler(INVOKE_SERVICE_API, {
data: {
method,
args
},
options: {
timestamp: Date.now()
}
});
}
function navigateTo(args) {
invokeServiceApi("navigateTo", args);
UniViewJSBridge.invokeServiceMethod("navigateTo", args);
}
function navigateBack(args) {
invokeServiceApi("navigateBack", args);
UniViewJSBridge.invokeServiceMethod("navigateBack", args);
}
function reLaunch(args) {
invokeServiceApi("reLaunch", args);
UniViewJSBridge.invokeServiceMethod("reLaunch", args);
}
function redirectTo(args) {
invokeServiceApi("redirectTo", args);
UniViewJSBridge.invokeServiceMethod("redirectTo", args);
}
function switchTab(args) {
invokeServiceApi("switchTab", args);
UniViewJSBridge.invokeServiceMethod("switchTab", args);
}
var uni$1 = /* @__PURE__ */ Object.freeze({
__proto__: null,
......@@ -6558,7 +6580,7 @@
return fields;
}
const uniLabelKey = PolySymbol("uniLabel");
const props$o = {
const props$p = {
for: {
type: String,
default: ""
......@@ -6566,7 +6588,7 @@
};
var Label = /* @__PURE__ */ defineBuiltInComponent({
name: "Label",
props: props$o,
props: props$p,
setup(props2, {
slots
}) {
......@@ -7022,7 +7044,7 @@
tempCanvas.height = height;
return tempCanvas;
}
const props$n = {
const props$o = {
canvasId: {
type: String,
default: ""
......@@ -7038,7 +7060,7 @@
compatConfig: {
MODE: 3
},
props: props$n,
props: props$o,
computed: {
id() {
return this.canvasId;
......@@ -7155,7 +7177,7 @@
function actionsChanged({
actions,
reserve
}, resolve) {
}, resolve2) {
if (!actions) {
return;
}
......@@ -7206,7 +7228,7 @@
});
color = LinearGradient;
} else if (data[0] === "pattern") {
const loaded = checkImageLoaded(data[1], actions.slice(index2 + 1), resolve, function(image2) {
const loaded = checkImageLoaded(data[1], actions.slice(index2 + 1), resolve2, function(image2) {
if (image2) {
c2d[method1] = c2d.createPattern(image2, data[2]);
}
......@@ -7255,7 +7277,7 @@
var url = dataArray[0];
var otherData = dataArray.slice(1);
_images = _images || {};
if (checkImageLoaded(url, actions.slice(index2 + 1), resolve, function(image2) {
if (checkImageLoaded(url, actions.slice(index2 + 1), resolve2, function(image2) {
if (image2) {
c2d.drawImage.apply(c2d, [image2].concat([...otherData.slice(4, 8)], [...otherData.slice(0, 4)]));
}
......@@ -7277,7 +7299,7 @@
}
}
if (!actionsWaiting.value) {
resolve({
resolve2({
errMsg: "drawCanvas:ok"
});
}
......@@ -7319,7 +7341,7 @@
}
});
}
function checkImageLoaded(src, actions, resolve, fn) {
function checkImageLoaded(src, actions, resolve2, fn) {
var image2 = _images[src];
if (image2.ready) {
fn(image2);
......@@ -7337,7 +7359,7 @@
actionsChanged({
actions: action[0],
reserve: action[1]
}, resolve);
}, resolve2);
action = actions2.shift();
}
};
......@@ -7355,7 +7377,7 @@
dataType,
quality = 1,
type = "png"
}, resolve) {
}, resolve2) {
const canvas2 = canvasRef.value;
let data;
const maxWidth = canvas2.offsetWidth - x;
......@@ -7412,10 +7434,10 @@
}
newCanvas.height = newCanvas.width = 0;
context.__hidpi__ = false;
if (!resolve) {
if (!resolve2) {
return result;
} else {
resolve(result);
resolve2(result);
}
}
function putImageData({
......@@ -7425,7 +7447,7 @@
width,
height,
compressed
}, resolve) {
}, resolve2) {
try {
if (!height) {
height = Math.round(data.length / 4 / width);
......@@ -7440,12 +7462,12 @@
canvasRef.value.getContext("2d").drawImage(canvas2, x, y, width, height);
canvas2.height = canvas2.width = 0;
} catch (error) {
resolve({
resolve2({
errMsg: "canvasPutImageData:fail"
});
return;
}
resolve({
resolve2({
errMsg: "canvasPutImageData:ok"
});
}
......@@ -7459,7 +7481,7 @@
fileType,
quality,
dirname
}, resolve) {
}, resolve2) {
const res = getImageData({
x,
y,
......@@ -7473,7 +7495,7 @@
quality
});
if (!res.data || !res.data.length) {
resolve({
resolve2({
errMsg: res.errMsg.replace("canvasPutImageData", "toTempFilePath")
});
return;
......@@ -7486,10 +7508,10 @@
putImageData,
toTempFilePath
};
function _handleSubscribe(type, data, resolve) {
function _handleSubscribe(type, data, resolve2) {
let method = methods2[type];
if (type.indexOf("_") !== 0 && typeof method === "function") {
method(data, resolve);
method(data, resolve2);
}
}
return extend(methods2, {
......@@ -7498,7 +7520,7 @@
});
}
const uniCheckGroupKey = PolySymbol("uniCheckGroup");
const props$m = {
const props$n = {
name: {
type: String,
default: ""
......@@ -7506,7 +7528,7 @@
};
var CheckboxGroup = /* @__PURE__ */ defineBuiltInComponent({
name: "CheckboxGroup",
props: props$m,
props: props$n,
emits: ["change"],
setup(props2, {
emit: emit2,
......@@ -7560,7 +7582,7 @@
}
return getFieldsValue;
}
const props$l = {
const props$m = {
checked: {
type: [Boolean, String],
default: false
......@@ -7584,7 +7606,7 @@
};
var Checkbox = /* @__PURE__ */ defineBuiltInComponent({
name: "Checkbox",
props: props$l,
props: props$m,
setup(props2, {
slots
}) {
......@@ -7732,7 +7754,7 @@
});
}
}
const props$k = {
const props$l = {
cursorSpacing: {
type: [Number, String],
default: 0
......@@ -8408,7 +8430,7 @@
});
});
const id2 = useContextInfo();
useSubscribe((type, data, resolve) => {
useSubscribe((type, data, resolve2) => {
const { options, callbackId } = data;
let res;
let range;
......@@ -8545,7 +8567,7 @@
errMsg = "not ready";
}
if (callbackId) {
resolve({
resolve2({
callbackId,
data: extend({}, res, {
errMsg: `${type}:${errMsg ? "fail " + errMsg : "ok"}`
......@@ -8554,7 +8576,7 @@
}
}, id2, true);
}
const props$j = /* @__PURE__ */ extend({}, props$k, {
const props$k = /* @__PURE__ */ extend({}, props$l, {
id: {
type: String,
default: ""
......@@ -8582,7 +8604,7 @@
});
var Editor = /* @__PURE__ */ defineBuiltInComponent({
name: "Editor",
props: props$j,
props: props$k,
emit: ["ready", "focus", "blur", "input", "statuschange", ...emit$1],
setup(props2, {
emit: emit2
......@@ -8671,7 +8693,7 @@
};
}
});
const props$i = {
const props$j = {
src: {
type: String,
default: ""
......@@ -8710,7 +8732,7 @@
};
var Image$1 = /* @__PURE__ */ defineBuiltInComponent({
name: "Image",
props: props$i,
props: props$j,
setup(props2, {
emit: emit2
}) {
......@@ -8991,17 +9013,17 @@
uniForm.removeField(ctx);
});
}
function getSelectedTextRange(_, resolve) {
function getSelectedTextRange(_, resolve2) {
const activeElement = document.activeElement;
if (!activeElement) {
return resolve({});
return resolve2({});
}
const data = {};
if (["input", "textarea"].includes(activeElement.tagName.toLowerCase())) {
data.start = activeElement.selectionStart;
data.end = activeElement.selectionEnd;
}
resolve(data);
resolve2(data);
}
const UniViewJSBridgeSubscribe = function() {
registerViewMethod(getCurrentPageId(), "getSelectedTextRange", getSelectedTextRange);
......@@ -9011,7 +9033,7 @@
function getValueString(value) {
return value === null ? "" : String(value);
}
const props$h = /* @__PURE__ */ extend({}, {
const props$i = /* @__PURE__ */ extend({}, {
name: {
type: String,
default: ""
......@@ -9076,7 +9098,7 @@
type: String,
default: "done"
}
}, props$k);
}, props$l);
const emit = [
"input",
"focus",
......@@ -9282,7 +9304,7 @@
trigger: trigger2
};
}
const props$g = /* @__PURE__ */ extend({}, props$h, {
const props$h = /* @__PURE__ */ extend({}, props$i, {
placeholderClass: {
type: String,
default: "input-placeholder"
......@@ -9294,7 +9316,7 @@
});
var Input = /* @__PURE__ */ defineBuiltInComponent({
name: "Input",
props: props$g,
props: props$h,
emits: ["confirm", ...emit],
setup(props2, {
emit: emit2
......@@ -9499,7 +9521,7 @@
const instance = getCurrentInstance();
instance.rebuild = callback;
}
const props$f = {
const props$g = {
scaleArea: {
type: Boolean,
default: false
......@@ -9508,7 +9530,7 @@
var MovableArea = /* @__PURE__ */ defineBuiltInComponent({
inheritAttrs: false,
name: "MovableArea",
props: props$f,
props: props$g,
setup(props2, {
slots
}) {
......@@ -10127,7 +10149,7 @@
this._springY.reconfigure(e2, t2, n);
this._springScale.reconfigure(e2, t2, n);
};
const props$e = {
const props$f = {
direction: {
type: String,
default: "none"
......@@ -10183,7 +10205,7 @@
};
var MovableView = /* @__PURE__ */ defineBuiltInComponent({
name: "MovableView",
props: props$e,
props: props$f,
emits: ["change", "scale"],
setup(props2, {
slots,
......@@ -10776,7 +10798,7 @@
};
}
const OPEN_TYPES = ["navigate", "redirect", "switchTab", "reLaunch", "navigateBack"];
const props$d = {
const props$e = {
hoverClass: {
type: String,
default: "navigator-hover"
......@@ -10818,7 +10840,7 @@
compatConfig: {
MODE: 3
},
props: props$d,
props: props$e,
setup(props2, {
slots
}) {
......@@ -10875,7 +10897,7 @@
};
}
});
const props$c = {
const props$d = {
value: {
type: Array,
default() {
......@@ -10922,7 +10944,7 @@
}
var PickerView = /* @__PURE__ */ defineBuiltInComponent({
name: "PickerView",
props: props$c,
props: props$d,
emits: ["change", "pickstart", "pickend", "update:value"],
setup(props2, {
slots,
......@@ -11883,7 +11905,7 @@
backgroundColor: "#EBEBEB",
activeMode: "backwards"
};
const props$b = {
const props$c = {
percent: {
type: [Number, String],
default: 0,
......@@ -11932,7 +11954,7 @@
};
var Progress = /* @__PURE__ */ defineBuiltInComponent({
name: "Progress",
props: props$b,
props: props$c,
setup(props2) {
const state = useProgressState(props2);
_activeAnimation(state, props2);
......@@ -12006,7 +12028,7 @@
}
}
const uniRadioGroupKey = PolySymbol("uniCheckGroup");
const props$a = {
const props$b = {
name: {
type: String,
default: ""
......@@ -12014,7 +12036,7 @@
};
var RadioGroup = /* @__PURE__ */ defineBuiltInComponent({
name: "RadioGroup",
props: props$a,
props: props$b,
setup(props2, {
emit: emit2,
slots
......@@ -12095,7 +12117,7 @@
}
return fields;
}
const props$9 = {
const props$a = {
checked: {
type: [Boolean, String],
default: false
......@@ -12119,7 +12141,7 @@
};
var Radio = /* @__PURE__ */ defineBuiltInComponent({
name: "Radio",
props: props$9,
props: props$a,
setup(props2, {
slots
}) {
......@@ -12415,7 +12437,7 @@
});
return parentNode;
}
const props$8 = {
const props$9 = {
nodes: {
type: [Array, String],
default: function() {
......@@ -12428,7 +12450,7 @@
compatConfig: {
MODE: 3
},
props: props$8,
props: props$9,
setup(props2) {
const rootRef = ref(null);
function _renderNodes(nodes) {
......@@ -12455,7 +12477,7 @@
}
});
const passiveOptions = passive(true);
const props$7 = {
const props$8 = {
scrollX: {
type: [Boolean, String],
default: false
......@@ -12518,7 +12540,7 @@
compatConfig: {
MODE: 3
},
props: props$7,
props: props$8,
emits: ["scroll", "scrolltoupper", "scrolltolower", "refresherrefresh", "refresherrestore", "refresherpulling", "refresherabort", "update:refresherTriggered"],
setup(props2, {
emit: emit2,
......@@ -12948,7 +12970,7 @@
}
});
}
const props$6 = {
const props$7 = {
name: {
type: String,
default: ""
......@@ -13004,7 +13026,7 @@
};
var Slider = /* @__PURE__ */ defineBuiltInComponent({
name: "Slider",
props: props$6,
props: props$7,
emits: ["changing", "change"],
setup(props2, {
emit: emit2
......@@ -13175,7 +13197,7 @@
return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m);
}
};
const props$5 = {
const props$6 = {
indicatorDots: {
type: [Boolean, String],
default: false
......@@ -13656,7 +13678,7 @@
}
var Swiper = /* @__PURE__ */ defineBuiltInComponent({
name: "Swiper",
props: props$5,
props: props$6,
emits: ["change", "transition", "animationfinish", "update:current", "update:currentItemId"],
setup(props2, {
slots,
......@@ -13762,7 +13784,7 @@
};
}
});
const props$4 = {
const props$5 = {
itemId: {
type: String,
default: ""
......@@ -13770,7 +13792,7 @@
};
var SwiperItem = /* @__PURE__ */ defineBuiltInComponent({
name: "SwiperItem",
props: props$4,
props: props$5,
setup(props2, {
slots
}) {
......@@ -13821,7 +13843,7 @@
};
}
});
const props$3 = {
const props$4 = {
name: {
type: String,
default: ""
......@@ -13849,7 +13871,7 @@
};
var Switch = /* @__PURE__ */ defineBuiltInComponent({
name: "Switch",
props: props$3,
props: props$4,
emits: ["change"],
setup(props2, {
emit: emit2
......@@ -13953,7 +13975,7 @@
}
return text2.replace(/&nbsp;/g, SPACE_UNICODE.nbsp).replace(/&ensp;/g, SPACE_UNICODE.ensp).replace(/&emsp;/g, SPACE_UNICODE.emsp).replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&").replace(/&quot;/g, '"').replace(/&apos;/g, "'");
}
const props$2 = /* @__PURE__ */ extend({}, props$h, {
const props$3 = /* @__PURE__ */ extend({}, props$i, {
placeholderClass: {
type: String,
default: "input-placeholder"
......@@ -13974,7 +13996,7 @@
}
var Textarea = /* @__PURE__ */ defineBuiltInComponent({
name: "Textarea",
props: props$2,
props: props$3,
emit: ["confirm", "linechange", ...emit],
setup(props2, {
emit: emit2
......@@ -14133,8 +14155,8 @@
if (!name) {
return;
}
registerViewMethod(pageId || getCurrentPageId(), name, ({ type, data }, resolve) => {
callback(type, data, resolve);
registerViewMethod(pageId || getCurrentPageId(), name, ({ type, data }, resolve2) => {
callback(type, data, resolve2);
});
}
function removeSubscribe(name) {
......@@ -14777,7 +14799,7 @@
});
}
const TEMP_PATH = "_doc/uniapp_temp/";
const props$1 = {
const props$2 = {
src: {
type: String,
default: ""
......@@ -14848,7 +14870,7 @@
}
var CoverImage = /* @__PURE__ */ defineBuiltInComponent({
name: "CoverImage",
props: props$1,
props: props$2,
emits: ["click", "load", "error"],
setup(props2, {
emit: emit2
......@@ -14963,12 +14985,380 @@
super(id2, "uni-live-pusher", parentNodeId, refNodeId);
}
}
var map = "uni-map {\n width: 300px;\n height: 225px;\n display: inline-block;\n line-height: 0;\n overflow: hidden;\n position: relative;\n}\n\nuni-map[hidden] {\n display: none;\n}\n\n.uni-map-container {\n width: 100%;\n height: 100%;\n position: absolute;\n top: 0;\n left: 0;\n overflow: hidden;\n background-color: black;\n}\n\n.uni-map-slot {\n position: absolute;\n top: 0;\n width: 100%;\n height: 100%;\n overflow: hidden;\n pointer-events: none;\n}";
const convertCoordinates = (lng, lat, callback) => {
callback({
coord: {
latitude: lat,
longitude: lng
}
});
};
function parseHex(color) {
if (color.indexOf("#") !== 0) {
return {
color,
opacity: 1
};
}
const opacity = color.substr(7, 2);
return {
color: color.substr(0, 7),
opacity: opacity ? Number("0x" + opacity) / 255 : 1
};
}
const props$1 = {
id: {
type: String,
default: ""
},
latitude: {
type: [Number, String],
default: ""
},
longitude: {
type: [Number, String],
default: ""
},
scale: {
type: [String, Number],
default: 16
},
markers: {
type: Array,
default() {
return [];
}
},
polyline: {
type: Array,
default() {
return [];
}
},
circles: {
type: Array,
default() {
return [];
}
},
controls: {
type: Array,
default() {
return [];
}
}
};
var Map$1 = /* @__PURE__ */ defineBuiltInComponent({
name: "Map"
name: "Map",
props: props$1,
emits: ["click", "regionchange", "controltap", "markertap", "callouttap"],
setup(props2, {
emit: emit2
}) {
const rootRef = ref(null);
const trigger2 = useCustomEvent(rootRef, emit2);
const containerRef = ref(null);
const attrs2 = useNativeAttrs(props2, ["id"]);
const {
position,
hidden,
onParentReady
} = useNative(containerRef);
let map2;
const {
_addMarkers,
_addMapLines,
_addMapCircles,
_setMap
} = useMapMethods(props2, trigger2);
onParentReady(() => {
map2 = extend(plus.maps.create(getCurrentPageId() + "-map-" + (props2.id || Date.now()), Object.assign({}, attrs2.value, position)), {
__markers__: [],
__markers_map__: {},
__lines__: [],
__circles__: []
});
map2.setZoom(parseInt(String(props2.scale)));
plus.webview.currentWebview().append(map2);
if (hidden.value) {
map2.hide();
}
map2.onclick = (e2) => {
trigger2("click", {}, e2);
};
map2.onstatuschanged = (e2) => {
trigger2("regionchange", {}, {});
};
_setMap(map2);
_addMarkers(props2.markers);
_addMapLines(props2.polyline);
_addMapCircles(props2.circles);
watch(() => attrs2.value, (attrs3) => map2 && map2.setStyles(attrs3), {
deep: true
});
watch(() => position, (position2) => map2 && map2.setStyles(position2), {
deep: true
});
watch(() => hidden.value, (val) => {
map2 && map2[val ? "hide" : "show"]();
});
watch(() => props2.scale, (val) => {
map2 && map2.setZoom(parseInt(String(val)));
});
watch([() => props2.latitude, () => props2.longitude], ([latitude, longitude]) => {
map2 && map2.setStyles({
center: new plus.maps.Point(Number(latitude), Number(longitude))
});
});
watch(() => props2.markers, (val) => {
_addMarkers(val, true);
});
watch(() => props2.polyline, (val) => {
_addMapLines(val);
});
watch(() => props2.circles, (val) => {
_addMapCircles(val);
});
});
const mapControls = computed$1(() => props2.controls.map((control) => {
const position2 = {
position: "absolute"
};
["top", "left", "width", "height"].forEach((key) => {
if (control.position[key]) {
position2[key] = control.position[key] + "px";
}
});
return {
id: control.id,
iconPath: getRealPath(control.iconPath),
position: position2
};
}));
onBeforeUnmount(() => {
if (map2) {
map2.close();
}
});
return () => {
return createVNode("uni-map", {
"ref": rootRef,
"id": props2.id
}, {
default: () => [createVNode("div", {
"ref": containerRef,
"class": "uni-map-container"
}, null, 512), mapControls.value.map((control, index2) => createVNode(resolveComponent("v-uni-cover-image"), {
"key": index2,
"src": control.iconPath,
"style": control.position,
"auto-size": true,
"onClick": () => trigger2("controltap", {}, {
controlId: control.id
})
}, null, 8, ["src", "style", "auto-size", "onClick"])), createVNode("div", {
"class": "uni-map-slot"
}, null)],
_: 1
}, 8, ["id"]);
};
}
});
function useMapMethods(props2, trigger2) {
let map2;
function moveToLocation(resolve2, {
longitude,
latitude
} = {}) {
if (!map2)
return;
map2.setCenter(new plus.maps.Point(Number(longitude || props2.longitude), Number(latitude || props2.latitude)));
resolve2({
errMsg: "moveToLocation:ok"
});
}
function getCenterLocation(resolve2) {
if (!map2)
return;
map2.getCurrentCenter((state, point) => {
resolve2({
longitude: point.getLng(),
latitude: point.getLat(),
errMsg: "getCenterLocation:ok"
});
});
}
function getRegion(resolve2) {
if (!map2)
return;
const rect = map2.getBounds();
resolve2({
southwest: rect.getSouthWest(),
northeast: rect.getNorthEast(),
errMsg: "getRegion:ok"
});
}
function getScale(resolve2) {
if (!map2)
return;
resolve2({
scale: map2.getZoom(),
errMsg: "getScale:ok"
});
}
function _addMarker(marker) {
if (!map2)
return;
const {
id: id2,
latitude,
longitude,
iconPath,
callout,
label: label2
} = marker;
convertCoordinates(longitude, latitude, (res) => {
const {
latitude: latitude2,
longitude: longitude2
} = res.coord;
const nativeMarker = new plus.maps.Marker(new plus.maps.Point(longitude2, latitude2));
if (iconPath) {
nativeMarker.setIcon(getRealPath(iconPath));
}
if (label2 && label2.content) {
nativeMarker.setLabel(label2.content);
}
let nativeBubble = void 0;
if (callout && callout.content) {
nativeBubble = new plus.maps.Bubble(callout.content);
}
if (nativeBubble) {
nativeMarker.setBubble(nativeBubble);
}
if (id2 || id2 === 0) {
nativeMarker.onclick = (e2) => {
trigger2("markertap", {}, {
markerId: id2
});
};
if (nativeBubble) {
nativeBubble.onclick = () => {
trigger2("callouttap", {}, {
markerId: id2
});
};
}
}
map2.addOverlay(nativeMarker);
map2.__markers__.push(nativeMarker);
map2.__markers_map__[id2 + ""] = nativeMarker;
});
}
function _clearMarkers() {
if (!map2)
return;
const markers = map2.__markers__;
markers.forEach((marker) => {
map2.removeOverlay(marker);
});
map2.__markers__ = [];
map2.__markers_map__ = {};
}
function _addMarkers(markers, clear2) {
if (clear2) {
_clearMarkers();
}
markers.forEach((marker) => {
_addMarker(marker);
});
}
function _addMapLines(lines) {
if (!map2)
return;
if (map2.__lines__.length > 0) {
map2.__lines__.forEach((circle) => {
map2.removeOverlay(circle);
});
map2.__lines__ = [];
}
lines.forEach((line) => {
const {
color,
width
} = line;
const points = line.points.map((point) => new plus.maps.Point(point.longitude, point.latitude));
const polyline = new plus.maps.Polyline(points);
if (color) {
const strokeStyle = parseHex(color);
polyline.setStrokeColor(strokeStyle.color);
polyline.setStrokeOpacity(strokeStyle.opacity);
}
if (width) {
polyline.setLineWidth(width);
}
map2.addOverlay(polyline);
map2.__lines__.push(polyline);
});
}
function _addMapCircles(circles) {
if (!map2)
return;
if (map2.__circles__.length > 0) {
map2.__circles__.forEach((circle) => {
map2.removeOverlay(circle);
});
map2.__circles__ = [];
}
circles.forEach((circle) => {
const {
latitude,
longitude,
color,
fillColor,
radius,
strokeWidth
} = circle;
const nativeCircle = new plus.maps.Circle(new plus.maps.Point(longitude, latitude), radius);
if (color) {
const strokeStyle = parseHex(color);
nativeCircle.setStrokeColor(strokeStyle.color);
nativeCircle.setStrokeOpacity(strokeStyle.opacity);
}
if (fillColor) {
const fillStyle = parseHex(fillColor);
nativeCircle.setFillColor(fillStyle.color);
nativeCircle.setFillOpacity(fillStyle.opacity);
}
if (strokeWidth) {
nativeCircle.setLineWidth(strokeWidth);
}
map2.addOverlay(nativeCircle);
map2.__circles__.push(nativeCircle);
});
}
const methods2 = {
moveToLocation,
getCenterLocation,
getRegion,
getScale
};
useSubscribe((type, data, resolve2) => {
methods2[type] && methods2[type](resolve2, data);
}, useContextInfo(), true);
return {
_addMarkers,
_addMapLines,
_addMapCircles,
_setMap(_map) {
map2 = _map;
}
};
}
class UniMap extends UniComponent {
constructor(id2, parentNodeId, refNodeId, nodeJson) {
super(id2, "uni-map", Map$1, parentNodeId, refNodeId, nodeJson);
super(id2, "uni-map", Map$1, parentNodeId, refNodeId, nodeJson, ".uni-map-slot");
}
}
var movableArea = "uni-movable-area {\n display: block;\n position: relative;\n width: 10px;\n height: 10px;\n}\n\nuni-movable-area[hidden] {\n display: none;\n}\n";
......
......@@ -2,8 +2,6 @@ export const VD_SYNC = 'vdSync'
export const ON_WEBVIEW_READY = 'onWebviewReady'
export const INVOKE_SERVICE_API = 'invokeServiceApi'
export let ACTION_MINIFY = true
// __tests__
export function setActionMinify(minify: boolean) {
......
import { registerServiceMethod } from '@dcloudio/uni-core'
export function subscribeAd() {
// view 层通过 UniViewJSBridge.invokeServiceMethod('getAdData', args, function({data})=>{console.log(data)})
registerServiceMethod('getAdData', (args, resolve) => {
// TODO args: view 层传输的参数,处理完之后,resolve:回传给 service,如resolve({data})
})
}
import {
INVOKE_SERVICE_API,
ON_WEBVIEW_READY,
VD_SYNC,
} from '../../../../constants'
import { subscribeServiceMethod } from '@dcloudio/uni-core'
import { ON_WEBVIEW_READY, VD_SYNC } from '../../../../constants'
import { onVdSync } from '../../dom'
import { onPlusMessage } from '../initGlobalEvent'
import { subscribeAd } from './ad'
import { subscribeNavigator } from './navigator'
import { subscribeWebviewReady } from './webviewReady'
export function initSubscribeHandlers() {
......@@ -21,14 +20,8 @@ export function initSubscribeHandlers() {
// 非纯原生
subscribe(ON_WEBVIEW_READY, subscribeWebviewReady)
subscribe(VD_SYNC, onVdSync)
subscribe(INVOKE_SERVICE_API, onInvokeServiceApi)
subscribeServiceMethod()
subscribeAd()
subscribeNavigator()
}
}
function onInvokeServiceApi({
data: { method, args },
}: {
data: { method: UniApp.OpenType; args: any }
}) {
uni[method] && uni[method](args)
}
import { registerServiceMethod } from '@dcloudio/uni-core'
const API_ROUTE = [
'switchTab',
'reLaunch',
'redirectTo',
'navigateTo',
'navigateBack',
] as const
export function subscribeNavigator() {
API_ROUTE.forEach((name) => {
registerServiceMethod(name, (args) => {
uni[name](args)
})
})
}
import { INVOKE_SERVICE_API } from '../../constants'
function invokeServiceApi(method: string, args: Record<string, any> = {}) {
UniViewJSBridge.publishHandler(INVOKE_SERVICE_API, {
data: {
method,
args,
},
options: {
timestamp: Date.now(),
},
})
}
export function navigateTo(args: Record<string, any>) {
invokeServiceApi('navigateTo', args)
UniViewJSBridge.invokeServiceMethod('navigateTo', args)
}
export function navigateBack(args: Record<string, any>) {
invokeServiceApi('navigateBack', args)
UniViewJSBridge.invokeServiceMethod('navigateBack', args)
}
export function reLaunch(args: Record<string, any>) {
invokeServiceApi('reLaunch', args)
UniViewJSBridge.invokeServiceMethod('reLaunch', args)
}
export function redirectTo(args: Record<string, any>) {
invokeServiceApi('redirectTo', args)
UniViewJSBridge.invokeServiceMethod('redirectTo', args)
}
export function switchTab(args: Record<string, any>) {
invokeServiceApi('switchTab', args)
UniViewJSBridge.invokeServiceMethod('switchTab', args)
}
......@@ -957,10 +957,10 @@ export default function vueFactory(exports) {
if (type === "clear"
/* CLEAR */
) {
// collection being cleared
// trigger all effects for target
depsMap.forEach(add);
} else if (key === 'length' && isArray(target)) {
// collection being cleared
// trigger all effects for target
depsMap.forEach(add);
} else if (key === 'length' && isArray(target)) {
depsMap.forEach((dep, key) => {
if (key === 'length' || key >= newValue) {
add(dep);
......@@ -1088,12 +1088,12 @@ export default function vueFactory(exports) {
if (key === "__v_isReactive"
/* IS_REACTIVE */
) {
return !isReadonly;
} else if (key === "__v_isReadonly"
return !isReadonly;
} else if (key === "__v_isReadonly"
/* IS_READONLY */
) {
return isReadonly;
} else if (key === "__v_raw"
return isReadonly;
} else if (key === "__v_raw"
/* RAW */
&& receiver === (isReadonly ? shallow ? shallowReadonlyMap : readonlyMap : shallow ? shallowReactiveMap : reactiveMap).get(target)) {
return target;
......@@ -1587,16 +1587,16 @@ export default function vueFactory(exports) {
if (key === "__v_isReactive"
/* IS_REACTIVE */
) {
return !isReadonly;
} else if (key === "__v_isReadonly"
return !isReadonly;
} else if (key === "__v_isReadonly"
/* IS_READONLY */
) {
return isReadonly;
} else if (key === "__v_raw"
return isReadonly;
} else if (key === "__v_raw"
/* RAW */
) {
return target;
}
return target;
}
return Reflect.get(hasOwn(instrumentations, key) && key in target ? instrumentations : target, key, receiver);
};
......@@ -1733,8 +1733,8 @@ export default function vueFactory(exports) {
if (targetType === 0
/* INVALID */
) {
return target;
}
return target;
}
var proxy = new Proxy(target, targetType === 2
/* COLLECTION */
......@@ -3033,12 +3033,12 @@ export default function vueFactory(exports) {
if (vnode.shapeFlag & 4
/* STATEFUL_COMPONENT */
) {
// withProxy is a proxy with a different `has` trap only for
// runtime-compiled render functions using `with` block.
var proxyToUse = withProxy || proxy;
result = normalizeVNode(render.call(proxyToUse, proxyToUse, renderCache, props, setupState, data, ctx));
fallthroughAttrs = attrs;
} else {
// withProxy is a proxy with a different `has` trap only for
// runtime-compiled render functions using `with` block.
var proxyToUse = withProxy || proxy;
result = normalizeVNode(render.call(proxyToUse, proxyToUse, renderCache, props, setupState, data, ctx));
fallthroughAttrs = attrs;
} else {
// functional
var _render = Component; // in dev, mark attrs accessed if optional props (attrs === props)
......@@ -3073,9 +3073,9 @@ export default function vueFactory(exports) {
if (process.env.NODE_ENV !== 'production' && result.patchFlag > 0 && result.patchFlag & 2048
/* DEV_ROOT_FRAGMENT */
) {
;
[root, setRoot] = getChildRoot(result);
}
;
[root, setRoot] = getChildRoot(result);
}
if (fallthroughAttrs && inheritAttrs !== false) {
var keys = Object.keys(fallthroughAttrs);
......@@ -3089,16 +3089,16 @@ export default function vueFactory(exports) {
|| shapeFlag & 6
/* COMPONENT */
) {
if (propsOptions && keys.some(isModelListener)) {
// If a v-model listener (onUpdate:xxx) has a corresponding declared
// prop, it indicates this component expects to handle v-model and
// it should not fallthrough.
// related: #1543, #1643, #1989
fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions);
}
if (propsOptions && keys.some(isModelListener)) {
// If a v-model listener (onUpdate:xxx) has a corresponding declared
// prop, it indicates this component expects to handle v-model and
// it should not fallthrough.
// related: #1543, #1643, #1989
fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOptions);
}
root = cloneVNode(root, fallthroughAttrs);
} else if (process.env.NODE_ENV !== 'production' && !accessedAttrs && root.type !== Comment$1) {
root = cloneVNode(root, fallthroughAttrs);
} else if (process.env.NODE_ENV !== 'production' && !accessedAttrs && root.type !== Comment$1) {
var allAttrs = Object.keys(attrs);
var eventAttrs = [];
var extraAttrs = [];
......@@ -3292,33 +3292,33 @@ export default function vueFactory(exports) {
if (patchFlag & 1024
/* DYNAMIC_SLOTS */
) {
// slot content that references values that might have changed,
// e.g. in a v-for
return true;
}
// slot content that references values that might have changed,
// e.g. in a v-for
return true;
}
if (patchFlag & 16
/* FULL_PROPS */
) {
if (!prevProps) {
return !!nextProps;
} // presence of this flag indicates props are always non-null
if (!prevProps) {
return !!nextProps;
} // presence of this flag indicates props are always non-null
return hasPropsChanged(prevProps, nextProps, emits);
} else if (patchFlag & 8
return hasPropsChanged(prevProps, nextProps, emits);
} else if (patchFlag & 8
/* PROPS */
) {
var dynamicProps = nextVNode.dynamicProps;
var dynamicProps = nextVNode.dynamicProps;
for (var i = 0; i < dynamicProps.length; i++) {
var key = dynamicProps[i];
for (var i = 0; i < dynamicProps.length; i++) {
var key = dynamicProps[i];
if (nextProps[key] !== prevProps[key] && !isEmitListener(emits, key)) {
return true;
}
if (nextProps[key] !== prevProps[key] && !isEmitListener(emits, key)) {
return true;
}
}
}
} else {
// this path is only taken by manually written render functions
// so presence of any children leads to a forced update
......@@ -4552,9 +4552,9 @@ export default function vueFactory(exports) {
} else if (vnode.shapeFlag & 128
/* SUSPENSE */
) {
vnode.ssContent.transition = hooks.clone(vnode.ssContent);
vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
} else {
vnode.ssContent.transition = hooks.clone(vnode.ssContent);
vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
} else {
vnode.transition = hooks;
}
}
......@@ -4573,8 +4573,8 @@ export default function vueFactory(exports) {
ret = ret.concat(getTransitionRawChildren(child.children, keepComment));
} // comment placeholders should be skipped, e.g. v-if
else if (keepComment || child.type !== Comment$1) {
ret.push(child);
}
ret.push(child);
}
} // #1126 if a transition children list contains multiple sub fragments, these
// fragments will be merged into a flat children array. Since each v-for
// fragment may contain different static bindings inside, we need to de-op
......@@ -4992,8 +4992,8 @@ export default function vueFactory(exports) {
if (rawVNode.shapeFlag & 128
/* SUSPENSE */
) {
rawVNode.ssContent = vnode;
}
rawVNode.ssContent = vnode;
}
} // #1513 it's possible for the returned vnode to be cloned due to attr
// fallthrough or scopeId, so the vnode here may not be the final vnode
// that is mounted. Instead of caching it directly, we store the pending
......@@ -5123,18 +5123,18 @@ export default function vueFactory(exports) {
if (shapeFlag & 256
/* COMPONENT_SHOULD_KEEP_ALIVE */
) {
shapeFlag -= 256
/* COMPONENT_SHOULD_KEEP_ALIVE */
;
}
shapeFlag -= 256
/* COMPONENT_SHOULD_KEEP_ALIVE */
;
}
if (shapeFlag & 512
/* COMPONENT_KEPT_ALIVE */
) {
shapeFlag -= 512
/* COMPONENT_KEPT_ALIVE */
;
}
shapeFlag -= 512
/* COMPONENT_KEPT_ALIVE */
;
}
vnode.shapeFlag = shapeFlag;
}
......@@ -5757,37 +5757,37 @@ export default function vueFactory(exports) {
if (patchFlag & 8
/* PROPS */
) {
// Compiler-generated props & no keys change, just set the updated
// the props.
var propsToUpdate = instance.vnode.dynamicProps;
for (var i = 0; i < propsToUpdate.length; i++) {
var key = propsToUpdate[i]; // PROPS flag guarantees rawProps to be non-null
var value = rawProps[key];
if (options) {
// attr / props separation was done on init and will be consistent
// in this code path, so just check if attrs have it.
if (hasOwn(attrs, key)) {
if (value !== attrs[key]) {
attrs[key] = value;
hasAttrsChanged = true;
}
} else {
var camelizedKey = camelize(key);
props[camelizedKey] = resolvePropValue(options, rawCurrentProps, camelizedKey, value, instance, false
/* isAbsent */
);
}
} else {
// Compiler-generated props & no keys change, just set the updated
// the props.
var propsToUpdate = instance.vnode.dynamicProps;
for (var i = 0; i < propsToUpdate.length; i++) {
var key = propsToUpdate[i]; // PROPS flag guarantees rawProps to be non-null
var value = rawProps[key];
if (options) {
// attr / props separation was done on init and will be consistent
// in this code path, so just check if attrs have it.
if (hasOwn(attrs, key)) {
if (value !== attrs[key]) {
attrs[key] = value;
hasAttrsChanged = true;
}
} else {
var camelizedKey = camelize(key);
props[camelizedKey] = resolvePropValue(options, rawCurrentProps, camelizedKey, value, instance, false
/* isAbsent */
);
}
} else {
if (value !== attrs[key]) {
attrs[key] = value;
hasAttrsChanged = true;
}
}
}
}
} else {
// full props update.
if (setFullProps(instance, rawProps, props, attrs)) {
......@@ -5799,13 +5799,9 @@ export default function vueFactory(exports) {
var kebabKey;
for (var _key6 in rawCurrentProps) {
if (!rawProps || // for camelCase
!hasOwn(rawProps, _key6) && ( // it's possible the original props was passed in as kebab-case
// and converted to camelCase (#955)
(kebabKey = hyphenate(_key6)) === _key6 || !hasOwn(rawProps, kebabKey))) {
if (!rawProps || !hasOwn(rawProps, _key6) && ((kebabKey = hyphenate(_key6)) === _key6 || !hasOwn(rawProps, kebabKey))) {
if (options) {
if (rawPrevProps && ( // for camelCase
rawPrevProps[_key6] !== undefined || // for kebab-case
if (rawPrevProps && (rawPrevProps[_key6] !== undefined || // for kebab-case
rawPrevProps[kebabKey] !== undefined)) {
props[_key6] = resolvePropValue(options, rawCurrentProps, _key6, undefined, instance, true
/* isAbsent */
......@@ -6250,18 +6246,18 @@ export default function vueFactory(exports) {
if (instance.vnode.shapeFlag & 32
/* SLOTS_CHILDREN */
) {
var type = children._;
var type = children._;
if (type) {
// users can get the shallow readonly version of the slots object through `this.$slots`,
// we should avoid the proxy object polluting the slots of the internal instance
instance.slots = toRaw(children); // make compiler marker non-enumerable
if (type) {
// users can get the shallow readonly version of the slots object through `this.$slots`,
// we should avoid the proxy object polluting the slots of the internal instance
instance.slots = toRaw(children); // make compiler marker non-enumerable
def(children, '_', type);
} else {
normalizeObjectSlots(children, instance.slots = {});
}
def(children, '_', type);
} else {
normalizeObjectSlots(children, instance.slots = {});
}
} else {
instance.slots = {};
if (children) {
......@@ -6283,41 +6279,41 @@ export default function vueFactory(exports) {
if (vnode.shapeFlag & 32
/* SLOTS_CHILDREN */
) {
var type = children._;
if (type) {
// compiled slots.
if (process.env.NODE_ENV !== 'production' && isHmrUpdating) {
// Parent was HMR updated so slot content may have changed.
// force update slots and mark instance for hmr as well
extend(slots, children);
} else if (optimized && type === 1
var type = children._;
if (type) {
// compiled slots.
if (process.env.NODE_ENV !== 'production' && isHmrUpdating) {
// Parent was HMR updated so slot content may have changed.
// force update slots and mark instance for hmr as well
extend(slots, children);
} else if (optimized && type === 1
/* STABLE */
) {
// compiled AND stable.
// no need to update, and skip stale slots removal.
needDeletionCheck = false;
} else {
// compiled but dynamic (v-if/v-for on slots) - update slots, but skip
// normalization.
extend(slots, children); // #2893
// when rendering the optimized slots by manually written render function,
// we need to delete the `slots._` flag if necessary to make subsequent updates reliable,
// i.e. let the `renderSlot` create the bailed Fragment
if (!optimized && type === 1
/* STABLE */
) {
// compiled AND stable.
// no need to update, and skip stale slots removal.
needDeletionCheck = false;
} else {
// compiled but dynamic (v-if/v-for on slots) - update slots, but skip
// normalization.
extend(slots, children); // #2893
// when rendering the optimized slots by manually written render function,
// we need to delete the `slots._` flag if necessary to make subsequent updates reliable,
// i.e. let the `renderSlot` create the bailed Fragment
if (!optimized && type === 1
/* STABLE */
) {
delete slots._;
}
delete slots._;
}
} else {
needDeletionCheck = !children.$stable;
normalizeObjectSlots(children, slots);
}
} else {
needDeletionCheck = !children.$stable;
normalizeObjectSlots(children, slots);
}
deletionComparisonTarget = children;
} else if (children) {
deletionComparisonTarget = children;
} else if (children) {
// non slot object children (direct value) passed to a component
normalizeVNodeSlots(instance, children);
deletionComparisonTarget = {
......@@ -6662,8 +6658,8 @@ export default function vueFactory(exports) {
if (domType !== 3
/* TEXT */
) {
nextNode = onMismatch();
} else {
nextNode = onMismatch();
} else {
if (node.data !== vnode.children) {
hasMismatch = true;
process.env.NODE_ENV !== 'production' && warn("Hydration text mismatch:" + "\n- Client: ".concat(JSON.stringify(node.data)) + "\n- Server: ".concat(JSON.stringify(vnode.children)));
......@@ -6690,8 +6686,8 @@ export default function vueFactory(exports) {
if (domType !== 1
/* ELEMENT */
) {
nextNode = onMismatch();
} else {
nextNode = onMismatch();
} else {
// determine anchor, adopt content
nextNode = node; // if the static vnode has its content stripped during build,
// adopt it from the server-rendered HTML.
......@@ -6726,58 +6722,58 @@ export default function vueFactory(exports) {
if (shapeFlag & 1
/* ELEMENT */
) {
if (domType !== 1
/* ELEMENT */
|| vnode.type.toLowerCase() !== node.tagName.toLowerCase()) {
nextNode = onMismatch();
} else {
nextNode = hydrateElement(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
}
} else if (shapeFlag & 6
if (domType !== 1
/* ELEMENT */
|| vnode.type.toLowerCase() !== node.tagName.toLowerCase()) {
nextNode = onMismatch();
} else {
nextNode = hydrateElement(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized);
}
} else if (shapeFlag & 6
/* COMPONENT */
) {
// when setting up the render effect, if the initial vnode already
// has .el set, the component will perform hydration instead of mount
// on its sub-tree.
vnode.slotScopeIds = slotScopeIds;
var container = parentNode(node);
mountComponent(vnode, container, null, parentComponent, parentSuspense, isSVGContainer(container), optimized); // component may be async, so in the case of fragments we cannot rely
// on component's rendered output to determine the end of the fragment
// instead, we do a lookahead to find the end anchor node.
nextNode = isFragmentStart ? locateClosingAsyncAnchor(node) : nextSibling(node); // #3787
// if component is async, it may get moved / unmounted before its
// inner component is loaded, so we need to give it a placeholder
// vnode that matches its adopted DOM.
if (isAsyncWrapper(vnode)) {
var subTree;
if (isFragmentStart) {
subTree = createVNode(Fragment);
subTree.anchor = nextNode ? nextNode.previousSibling : container.lastChild;
} else {
subTree = node.nodeType === 3 ? createTextVNode('') : createVNode('div');
}
subTree.el = node;
vnode.component.subTree = subTree;
// when setting up the render effect, if the initial vnode already
// has .el set, the component will perform hydration instead of mount
// on its sub-tree.
vnode.slotScopeIds = slotScopeIds;
var container = parentNode(node);
mountComponent(vnode, container, null, parentComponent, parentSuspense, isSVGContainer(container), optimized); // component may be async, so in the case of fragments we cannot rely
// on component's rendered output to determine the end of the fragment
// instead, we do a lookahead to find the end anchor node.
nextNode = isFragmentStart ? locateClosingAsyncAnchor(node) : nextSibling(node); // #3787
// if component is async, it may get moved / unmounted before its
// inner component is loaded, so we need to give it a placeholder
// vnode that matches its adopted DOM.
if (isAsyncWrapper(vnode)) {
var subTree;
if (isFragmentStart) {
subTree = createVNode(Fragment);
subTree.anchor = nextNode ? nextNode.previousSibling : container.lastChild;
} else {
subTree = node.nodeType === 3 ? createTextVNode('') : createVNode('div');
}
} else if (shapeFlag & 64
subTree.el = node;
vnode.component.subTree = subTree;
}
} else if (shapeFlag & 64
/* TELEPORT */
) {
if (domType !== 8
/* COMMENT */
) {
nextNode = onMismatch();
} else {
nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, rendererInternals, hydrateChildren);
}
} else if (shapeFlag & 128
if (domType !== 8
/* COMMENT */
) {
nextNode = onMismatch();
} else {
nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, rendererInternals, hydrateChildren);
}
} else if (shapeFlag & 128
/* SUSPENSE */
) {
nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, isSVGContainer(parentNode(node)), slotScopeIds, optimized, rendererInternals, hydrateNode);
} else if (process.env.NODE_ENV !== 'production') {
nextNode = vnode.type.hydrate(node, vnode, parentComponent, parentSuspense, isSVGContainer(parentNode(node)), slotScopeIds, optimized, rendererInternals, hydrateNode);
} else if (process.env.NODE_ENV !== 'production') {
warn('Invalid HostVNode type:', type, "(".concat(typeof type, ")"));
}
......@@ -6806,78 +6802,78 @@ export default function vueFactory(exports) {
if (forcePatchValue || patchFlag !== -1
/* HOISTED */
) {
if (dirs) {
invokeDirectiveHook(vnode, null, parentComponent, 'created');
} // props
if (dirs) {
invokeDirectiveHook(vnode, null, parentComponent, 'created');
} // props
if (props) {
if (forcePatchValue || !optimized || patchFlag & 16
/* FULL_PROPS */
|| patchFlag & 32
/* HYDRATE_EVENTS */
) {
for (var key in props) {
if (forcePatchValue && key.endsWith('value') || isOn(key) && !isReservedProp(key)) {
patchProp(el, key, null, props[key]);
}
if (props) {
if (forcePatchValue || !optimized || patchFlag & 16
/* FULL_PROPS */
|| patchFlag & 32
/* HYDRATE_EVENTS */
) {
for (var key in props) {
if (forcePatchValue && key.endsWith('value') || isOn(key) && !isReservedProp(key)) {
patchProp(el, key, null, props[key]);
}
} else if (props.onClick) {
// Fast path for click listeners (which is most often) to avoid
// iterating through props.
patchProp(el, 'onClick', null, props.onClick);
}
} // vnode / directive hooks
} else if (props.onClick) {
// Fast path for click listeners (which is most often) to avoid
// iterating through props.
patchProp(el, 'onClick', null, props.onClick);
}
} // vnode / directive hooks
var vnodeHooks;
var vnodeHooks;
if (vnodeHooks = props && props.onVnodeBeforeMount) {
invokeVNodeHook(vnodeHooks, parentComponent, vnode);
}
if (vnodeHooks = props && props.onVnodeBeforeMount) {
invokeVNodeHook(vnodeHooks, parentComponent, vnode);
}
if (dirs) {
invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount');
}
if (dirs) {
invokeDirectiveHook(vnode, null, parentComponent, 'beforeMount');
}
if ((vnodeHooks = props && props.onVnodeMounted) || dirs) {
queueEffectWithSuspense(() => {
vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted');
}, parentSuspense);
} // children
if ((vnodeHooks = props && props.onVnodeMounted) || dirs) {
queueEffectWithSuspense(() => {
vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
dirs && invokeDirectiveHook(vnode, null, parentComponent, 'mounted');
}, parentSuspense);
} // children
if (shapeFlag & 16
/* ARRAY_CHILDREN */
&& // skip if element has innerHTML / textContent
!(props && (props.innerHTML || props.textContent))) {
var next = hydrateChildren(el.firstChild, vnode, el, parentComponent, parentSuspense, slotScopeIds, optimized);
var _hasWarned = false;
if (shapeFlag & 16
/* ARRAY_CHILDREN */
&& // skip if element has innerHTML / textContent
!(props && (props.innerHTML || props.textContent))) {
var next = hydrateChildren(el.firstChild, vnode, el, parentComponent, parentSuspense, slotScopeIds, optimized);
var _hasWarned = false;
while (next) {
hasMismatch = true;
while (next) {
hasMismatch = true;
if (process.env.NODE_ENV !== 'production' && !_hasWarned) {
warn("Hydration children mismatch in <".concat(vnode.type, ">: ") + "server rendered element contains more child nodes than client vdom.");
_hasWarned = true;
} // The SSRed DOM contains more nodes than it should. Remove them.
if (process.env.NODE_ENV !== 'production' && !_hasWarned) {
warn("Hydration children mismatch in <".concat(vnode.type, ">: ") + "server rendered element contains more child nodes than client vdom.");
_hasWarned = true;
} // The SSRed DOM contains more nodes than it should. Remove them.
var cur = next;
next = next.nextSibling;
remove(cur);
}
} else if (shapeFlag & 8
/* TEXT_CHILDREN */
) {
if (el.textContent !== vnode.children) {
hasMismatch = true;
process.env.NODE_ENV !== 'production' && warn("Hydration text content mismatch in <".concat(vnode.type, ">:\n") + "- Client: ".concat(el.textContent, "\n") + "- Server: ".concat(vnode.children));
el.textContent = vnode.children;
}
}
var cur = next;
next = next.nextSibling;
remove(cur);
}
} else if (shapeFlag & 8
/* TEXT_CHILDREN */
) {
if (el.textContent !== vnode.children) {
hasMismatch = true;
process.env.NODE_ENV !== 'production' && warn("Hydration text content mismatch in <".concat(vnode.type, ">:\n") + "- Client: ".concat(el.textContent, "\n") + "- Server: ".concat(vnode.children));
el.textContent = vnode.children;
}
}
}
return el.nextSibling;
};
......@@ -7221,9 +7217,9 @@ export default function vueFactory(exports) {
if (n2.patchFlag === -2
/* BAIL */
) {
optimized = false;
n2.dynamicChildren = null;
}
optimized = false;
n2.dynamicChildren = null;
}
var {
type,
......@@ -7257,20 +7253,20 @@ export default function vueFactory(exports) {
if (shapeFlag & 1
/* ELEMENT */
) {
processElement(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
} else if (shapeFlag & 6
processElement(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
} else if (shapeFlag & 6
/* COMPONENT */
) {
processComponent(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
} else if (shapeFlag & 64
processComponent(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
} else if (shapeFlag & 64
/* TELEPORT */
) {
type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals);
} else if (shapeFlag & 128
type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals);
} else if (shapeFlag & 128
/* SUSPENSE */
) {
type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals);
} else if (process.env.NODE_ENV !== 'production') {
type.process(n1, n2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized, internals);
} else if (process.env.NODE_ENV !== 'production') {
warn('Invalid VNode type:', type, "(".concat(typeof type, ")"));
}
......@@ -7393,12 +7389,12 @@ export default function vueFactory(exports) {
if (!(process.env.NODE_ENV !== 'production') && vnode.el && hostCloneNode !== undefined && patchFlag === -1
/* HOISTED */
) {
// If a vnode has non-null el, it means it's being reused.
// Only static vnodes can be reused, so its mounted DOM nodes should be
// exactly the same, and we can simply do a clone here.
// only do this in production since cloned trees cannot be HMR updated.
el = vnode.el = hostCloneNode(vnode.el);
} else {
// If a vnode has non-null el, it means it's being reused.
// Only static vnodes can be reused, so its mounted DOM nodes should be
// exactly the same, and we can simply do a clone here.
// only do this in production since cloned trees cannot be HMR updated.
el = vnode.el = hostCloneNode(vnode.el);
} else {
el = vnode.el = hostCreateElement( // fixed by xxxxxx
vnode.type, container); // mount children first, since some props may rely on child content
// being already rendered, e.g. `<select value>`
......@@ -7406,12 +7402,12 @@ export default function vueFactory(exports) {
if (shapeFlag & 8
/* TEXT_CHILDREN */
) {
hostSetElementText(el, vnode.children);
} else if (shapeFlag & 16
hostSetElementText(el, vnode.children);
} else if (shapeFlag & 16
/* ARRAY_CHILDREN */
) {
mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized || !!vnode.dynamicChildren);
}
mountChildren(vnode.children, el, null, parentComponent, parentSuspense, isSVG && type !== 'foreignObject', slotScopeIds, optimized || !!vnode.dynamicChildren);
}
if (dirs) {
invokeDirectiveHook(vnode, null, parentComponent, 'created');
......@@ -7485,8 +7481,8 @@ export default function vueFactory(exports) {
if (process.env.NODE_ENV !== 'production' && subTree.patchFlag > 0 && subTree.patchFlag & 2048
/* DEV_ROOT_FRAGMENT */
) {
subTree = filterSingleRoot(subTree.children) || subTree;
}
subTree = filterSingleRoot(subTree.children) || subTree;
}
if (vnode === subTree) {
var parentVNode = parentComponent.vnode;
......@@ -7541,26 +7537,26 @@ export default function vueFactory(exports) {
if (patchFlag & 16
/* FULL_PROPS */
) {
// element props contain dynamic keys, full diff needed
patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG);
} else {
// element props contain dynamic keys, full diff needed
patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG);
} else {
// class
// this flag is matched when the element has dynamic class bindings.
if (patchFlag & 2
/* CLASS */
) {
if (oldProps.class !== newProps.class) {
hostPatchProp(el, 'class', null, newProps.class, isSVG);
}
} // style
if (oldProps.class !== newProps.class) {
hostPatchProp(el, 'class', null, newProps.class, isSVG);
}
} // style
// this flag is matched when the element has dynamic style bindings
if (patchFlag & 4
/* STYLE */
) {
hostPatchProp(el, 'style', oldProps.style, newProps.style, isSVG);
} // props
hostPatchProp(el, 'style', oldProps.style, newProps.style, isSVG);
} // props
// This flag is matched when the element has dynamic prop/attr bindings
// other than class and style. The keys of dynamic prop/attrs are saved for
// faster iteration.
......@@ -7571,19 +7567,19 @@ export default function vueFactory(exports) {
if (patchFlag & 8
/* PROPS */
) {
// if the flag is present then dynamicProps must be non-null
var propsToUpdate = n2.dynamicProps;
// if the flag is present then dynamicProps must be non-null
var propsToUpdate = n2.dynamicProps;
for (var i = 0; i < propsToUpdate.length; i++) {
var key = propsToUpdate[i];
var prev = oldProps[key];
var next = newProps[key];
for (var i = 0; i < propsToUpdate.length; i++) {
var key = propsToUpdate[i];
var prev = oldProps[key];
var next = newProps[key];
if (next !== prev || hostForcePatchProp && hostForcePatchProp(el, key)) {
hostPatchProp(el, key, prev, next, isSVG, n1.children, parentComponent, parentSuspense, unmountChildren);
}
if (next !== prev || hostForcePatchProp && hostForcePatchProp(el, key)) {
hostPatchProp(el, key, prev, next, isSVG, n1.children, parentComponent, parentSuspense, unmountChildren);
}
}
}
} // text
// This flag is matched when the element has only dynamic text children.
......@@ -7591,10 +7587,10 @@ export default function vueFactory(exports) {
if (patchFlag & 1
/* TEXT */
) {
if (n1.children !== n2.children) {
hostSetElementText(el, n2.children);
}
if (n1.children !== n2.children) {
hostSetElementText(el, n2.children);
}
}
} else if (!optimized && dynamicChildren == null) {
// unoptimized, full diff
patchProps(el, n2, oldProps, newProps, parentComponent, parentSuspense, isSVG);
......@@ -7629,9 +7625,7 @@ export default function vueFactory(exports) {
var container = // oldVNode may be an errored async setup() component inside Suspense
// which will not have a mounted element
oldVNode.el && ( // - In the case of a Fragment, we need to provide the actual parent
// of the Fragment itself so it can move its children.
oldVNode.type === Fragment || // - In the case of different nodes, there is going to be a replacement
oldVNode.el && (oldVNode.type === Fragment || // - In the case of different nodes, there is going to be a replacement
// which also requires the correct parent container
!isSameVNodeType(oldVNode, newVNode) || // - In the case of a component, it could contain anything.
oldVNode.shapeFlag & 6
......@@ -7740,8 +7734,8 @@ export default function vueFactory(exports) {
if (n2.shapeFlag & 512
/* COMPONENT_KEPT_ALIVE */
) {
parentComponent.ctx.activate(n2, container, anchor, isSVG, optimized);
} else {
parentComponent.ctx.activate(n2, container, anchor, isSVG, optimized);
} else {
mountComponent(n2, container, anchor, parentComponent, parentSuspense, isSVG, optimized);
}
} else {
......@@ -7933,8 +7927,8 @@ export default function vueFactory(exports) {
if (initialVNode.shapeFlag & 256
/* COMPONENT_SHOULD_KEEP_ALIVE */
) {
instance.a && queuePostRenderEffect(instance.a, parentSuspense);
}
instance.a && queuePostRenderEffect(instance.a, parentSuspense);
}
instance.isMounted = true;
......@@ -8068,62 +8062,62 @@ export default function vueFactory(exports) {
if (patchFlag & 128
/* KEYED_FRAGMENT */
) {
// this could be either fully-keyed or mixed (some keyed some not)
// presence of patchFlag means children are guaranteed to be arrays
patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
return;
} else if (patchFlag & 256
// this could be either fully-keyed or mixed (some keyed some not)
// presence of patchFlag means children are guaranteed to be arrays
patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
return;
} else if (patchFlag & 256
/* UNKEYED_FRAGMENT */
) {
// unkeyed
patchUnkeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
return;
}
// unkeyed
patchUnkeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
return;
}
} // children has 3 possibilities: text, array or no children.
if (shapeFlag & 8
/* TEXT_CHILDREN */
) {
// text children fast path
if (prevShapeFlag & 16
/* ARRAY_CHILDREN */
) {
unmountChildren(c1, parentComponent, parentSuspense);
}
// text children fast path
if (prevShapeFlag & 16
/* ARRAY_CHILDREN */
) {
unmountChildren(c1, parentComponent, parentSuspense);
}
if (c2 !== c1) {
hostSetElementText(container, c2);
}
} else {
if (c2 !== c1) {
hostSetElementText(container, c2);
}
} else {
if (prevShapeFlag & 16
/* ARRAY_CHILDREN */
) {
// prev children was array
if (shapeFlag & 16
/* ARRAY_CHILDREN */
) {
// two arrays, cannot assume anything, do full diff
patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
} else {
// no new children, just unmount old
unmountChildren(c1, parentComponent, parentSuspense, true);
}
// prev children was array
if (shapeFlag & 16
/* ARRAY_CHILDREN */
) {
// two arrays, cannot assume anything, do full diff
patchKeyedChildren(c1, c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
} else {
// no new children, just unmount old
unmountChildren(c1, parentComponent, parentSuspense, true);
}
} else {
// prev children was text OR null
// new children is array OR null
if (prevShapeFlag & 8
/* TEXT_CHILDREN */
) {
hostSetElementText(container, '');
} // mount new if array
hostSetElementText(container, '');
} // mount new if array
if (shapeFlag & 16
/* ARRAY_CHILDREN */
) {
mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
}
mountChildren(c2, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
}
}
}
};
......@@ -8217,120 +8211,120 @@ export default function vueFactory(exports) {
// (b c)
// i = 0, e1 = 0, e2 = -1
else if (i > e2) {
while (i <= e1) {
unmount(c1[i], parentComponent, parentSuspense, true);
i++;
}
} // 5. unknown sequence
// [i ... e1 + 1]: a b [c d e] f g
// [i ... e2 + 1]: a b [e d c h] f g
// i = 2, e1 = 4, e2 = 5
else {
var s1 = i; // prev starting index
while (i <= e1) {
unmount(c1[i], parentComponent, parentSuspense, true);
i++;
}
} // 5. unknown sequence
// [i ... e1 + 1]: a b [c d e] f g
// [i ... e2 + 1]: a b [e d c h] f g
// i = 2, e1 = 4, e2 = 5
else {
var s1 = i; // prev starting index
var s2 = i; // next starting index
// 5.1 build key:index map for newChildren
var s2 = i; // next starting index
// 5.1 build key:index map for newChildren
var keyToNewIndexMap = new Map();
var keyToNewIndexMap = new Map();
for (i = s2; i <= e2; i++) {
var nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
for (i = s2; i <= e2; i++) {
var nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
if (nextChild.key != null) {
if (process.env.NODE_ENV !== 'production' && keyToNewIndexMap.has(nextChild.key)) {
warn("Duplicate keys found during update:", JSON.stringify(nextChild.key), "Make sure keys are unique.");
}
if (nextChild.key != null) {
if (process.env.NODE_ENV !== 'production' && keyToNewIndexMap.has(nextChild.key)) {
warn("Duplicate keys found during update:", JSON.stringify(nextChild.key), "Make sure keys are unique.");
}
keyToNewIndexMap.set(nextChild.key, i);
}
} // 5.2 loop through old children left to be patched and try to patch
// matching nodes & remove nodes that are no longer present
keyToNewIndexMap.set(nextChild.key, i);
}
} // 5.2 loop through old children left to be patched and try to patch
// matching nodes & remove nodes that are no longer present
var j;
var patched = 0;
var toBePatched = e2 - s2 + 1;
var moved = false; // used to track whether any node has moved
var j;
var patched = 0;
var toBePatched = e2 - s2 + 1;
var moved = false; // used to track whether any node has moved
var maxNewIndexSoFar = 0; // works as Map<newIndex, oldIndex>
// Note that oldIndex is offset by +1
// and oldIndex = 0 is a special value indicating the new node has
// no corresponding old node.
// used for determining longest stable subsequence
var maxNewIndexSoFar = 0; // works as Map<newIndex, oldIndex>
// Note that oldIndex is offset by +1
// and oldIndex = 0 is a special value indicating the new node has
// no corresponding old node.
// used for determining longest stable subsequence
var newIndexToOldIndexMap = new Array(toBePatched);
var newIndexToOldIndexMap = new Array(toBePatched);
for (i = 0; i < toBePatched; i++) {
newIndexToOldIndexMap[i] = 0;
}
for (i = 0; i < toBePatched; i++) {
newIndexToOldIndexMap[i] = 0;
}
for (i = s1; i <= e1; i++) {
var prevChild = c1[i];
for (i = s1; i <= e1; i++) {
var prevChild = c1[i];
if (patched >= toBePatched) {
// all new children have been patched so this can only be a removal
unmount(prevChild, parentComponent, parentSuspense, true);
continue;
}
if (patched >= toBePatched) {
// all new children have been patched so this can only be a removal
unmount(prevChild, parentComponent, parentSuspense, true);
continue;
}
var newIndex = void 0;
var newIndex = void 0;
if (prevChild.key != null) {
newIndex = keyToNewIndexMap.get(prevChild.key);
} else {
// key-less node, try to locate a key-less node of the same type
for (j = s2; j <= e2; j++) {
if (newIndexToOldIndexMap[j - s2] === 0 && isSameVNodeType(prevChild, c2[j])) {
newIndex = j;
break;
}
}
if (prevChild.key != null) {
newIndex = keyToNewIndexMap.get(prevChild.key);
} else {
// key-less node, try to locate a key-less node of the same type
for (j = s2; j <= e2; j++) {
if (newIndexToOldIndexMap[j - s2] === 0 && isSameVNodeType(prevChild, c2[j])) {
newIndex = j;
break;
}
}
}
if (newIndex === undefined) {
unmount(prevChild, parentComponent, parentSuspense, true);
} else {
newIndexToOldIndexMap[newIndex - s2] = i + 1;
if (newIndex === undefined) {
unmount(prevChild, parentComponent, parentSuspense, true);
} else {
newIndexToOldIndexMap[newIndex - s2] = i + 1;
if (newIndex >= maxNewIndexSoFar) {
maxNewIndexSoFar = newIndex;
} else {
moved = true;
}
if (newIndex >= maxNewIndexSoFar) {
maxNewIndexSoFar = newIndex;
} else {
moved = true;
}
patch(prevChild, c2[newIndex], container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
patched++;
}
} // 5.3 move and mount
// generate longest stable subsequence only when nodes have moved
var increasingNewIndexSequence = moved ? getSequence(newIndexToOldIndexMap) : EMPTY_ARR;
j = increasingNewIndexSequence.length - 1; // looping backwards so that we can use last patched node as anchor
for (i = toBePatched - 1; i >= 0; i--) {
var nextIndex = s2 + i;
var _nextChild = c2[nextIndex];
var _anchor2 = nextIndex + 1 < l2 ? c2[nextIndex + 1].el : parentAnchor;
if (newIndexToOldIndexMap[i] === 0) {
// mount new
patch(null, _nextChild, container, _anchor2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
} else if (moved) {
// move if:
// There is no stable subsequence (e.g. a reverse)
// OR current node is not among the stable sequence
if (j < 0 || i !== increasingNewIndexSequence[j]) {
move(_nextChild, container, _anchor2, 2
/* REORDER */
);
} else {
j--;
}
}
patch(prevChild, c2[newIndex], container, null, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
patched++;
}
} // 5.3 move and mount
// generate longest stable subsequence only when nodes have moved
var increasingNewIndexSequence = moved ? getSequence(newIndexToOldIndexMap) : EMPTY_ARR;
j = increasingNewIndexSequence.length - 1; // looping backwards so that we can use last patched node as anchor
for (i = toBePatched - 1; i >= 0; i--) {
var nextIndex = s2 + i;
var _nextChild = c2[nextIndex];
var _anchor2 = nextIndex + 1 < l2 ? c2[nextIndex + 1].el : parentAnchor;
if (newIndexToOldIndexMap[i] === 0) {
// mount new
patch(null, _nextChild, container, _anchor2, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
} else if (moved) {
// move if:
// There is no stable subsequence (e.g. a reverse)
// OR current node is not among the stable sequence
if (j < 0 || i !== increasingNewIndexSequence[j]) {
move(_nextChild, container, _anchor2, 2
/* REORDER */
);
} else {
j--;
}
}
}
}
};
var move = (vnode, container, anchor, moveType, parentSuspense = null) => {
......@@ -8345,23 +8339,23 @@ export default function vueFactory(exports) {
if (shapeFlag & 6
/* COMPONENT */
) {
move(vnode.component.subTree, container, anchor, moveType);
return;
}
move(vnode.component.subTree, container, anchor, moveType);
return;
}
if (shapeFlag & 128
/* SUSPENSE */
) {
vnode.suspense.move(container, anchor, moveType);
return;
}
vnode.suspense.move(container, anchor, moveType);
return;
}
if (shapeFlag & 64
/* TELEPORT */
) {
type.move(vnode, container, anchor, internals);
return;
}
type.move(vnode, container, anchor, internals);
return;
}
if (type === Fragment) {
hostInsert(el, container, anchor);
......@@ -8390,10 +8384,10 @@ export default function vueFactory(exports) {
if (moveType === 0
/* ENTER */
) {
transition.beforeEnter(el);
hostInsert(el, container, anchor);
queuePostRenderEffect(() => transition.enter(el), parentSuspense);
} else {
transition.beforeEnter(el);
hostInsert(el, container, anchor);
queuePostRenderEffect(() => transition.enter(el), parentSuspense);
} else {
var {
leave,
delayLeave,
......@@ -8440,9 +8434,9 @@ export default function vueFactory(exports) {
if (shapeFlag & 256
/* COMPONENT_SHOULD_KEEP_ALIVE */
) {
parentComponent.ctx.deactivate(vnode);
return;
}
parentComponent.ctx.deactivate(vnode);
return;
}
var shouldInvokeDirs = shapeFlag & 1
/* ELEMENT */
......@@ -8456,14 +8450,14 @@ export default function vueFactory(exports) {
if (shapeFlag & 6
/* COMPONENT */
) {
unmountComponent(vnode.component, parentSuspense, doRemove);
} else {
unmountComponent(vnode.component, parentSuspense, doRemove);
} else {
if (shapeFlag & 128
/* SUSPENSE */
) {
vnode.suspense.unmount(parentSuspense, doRemove);
return;
}
vnode.suspense.unmount(parentSuspense, doRemove);
return;
}
if (shouldInvokeDirs) {
invokeDirectiveHook(vnode, null, parentComponent, 'beforeUnmount');
......@@ -8472,9 +8466,8 @@ export default function vueFactory(exports) {
if (shapeFlag & 64
/* TELEPORT */
) {
vnode.type.remove(vnode, parentComponent, parentSuspense, optimized, internals, doRemove);
} else if (dynamicChildren && ( // #1153: fast path should not be taken for non-stable (v-for) fragments
type !== Fragment || patchFlag > 0 && patchFlag & 64
vnode.type.remove(vnode, parentComponent, parentSuspense, optimized, internals, doRemove);
} else if (dynamicChildren && (type !== Fragment || patchFlag > 0 && patchFlag & 64
/* STABLE_FRAGMENT */
)) {
// fast path for block nodes: only need to unmount dynamic children.
......@@ -8626,14 +8619,14 @@ export default function vueFactory(exports) {
if (vnode.shapeFlag & 6
/* COMPONENT */
) {
return getNextHostNode(vnode.component.subTree);
}
return getNextHostNode(vnode.component.subTree);
}
if (vnode.shapeFlag & 128
/* SUSPENSE */
) {
return vnode.suspense.next();
}
return vnode.suspense.next();
}
return hostNextSibling(vnode.anchor || vnode.el);
};
......@@ -8712,9 +8705,9 @@ export default function vueFactory(exports) {
if (c2.patchFlag <= 0 || c2.patchFlag === 32
/* HYDRATE_EVENTS */
) {
c2 = ch2[i] = cloneIfMounted(ch2[i]);
c2.el = c1.el;
}
c2 = ch2[i] = cloneIfMounted(ch2[i]);
c2.el = c1.el;
}
if (!shallow) traverseStaticChildren(c1, c2);
} // also inherit for comment nodes, but not placeholders (e.g. v-if which
......@@ -8867,8 +8860,8 @@ export default function vueFactory(exports) {
if (shapeFlag & 16
/* ARRAY_CHILDREN */
) {
mountChildren(children, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
}
mountChildren(children, container, anchor, parentComponent, parentSuspense, isSVG, slotScopeIds, optimized);
}
};
if (disabled) {
......@@ -8959,11 +8952,11 @@ export default function vueFactory(exports) {
if (shapeFlag & 16
/* ARRAY_CHILDREN */
) {
for (var i = 0; i < children.length; i++) {
var child = children[i];
unmount(child, parentComponent, parentSuspense, true, !!child.dynamicChildren);
}
for (var i = 0; i < children.length; i++) {
var child = children[i];
unmount(child, parentComponent, parentSuspense, true, !!child.dynamicChildren);
}
}
}
},
......@@ -8983,8 +8976,8 @@ export default function vueFactory(exports) {
if (moveType === 0
/* TARGET_CHANGE */
) {
insert(vnode.targetAnchor, container, parentAnchor);
}
insert(vnode.targetAnchor, container, parentAnchor);
}
var {
el,
......@@ -9009,12 +9002,12 @@ export default function vueFactory(exports) {
if (shapeFlag & 16
/* ARRAY_CHILDREN */
) {
for (var i = 0; i < children.length; i++) {
move(children[i], container, parentAnchor, 2
/* REORDER */
);
}
for (var i = 0; i < children.length; i++) {
move(children[i], container, parentAnchor, 2
/* REORDER */
);
}
}
} // move main view anchor if this is a re-order.
......@@ -9040,16 +9033,16 @@ export default function vueFactory(exports) {
if (vnode.shapeFlag & 16
/* ARRAY_CHILDREN */
) {
if (isTeleportDisabled(vnode.props)) {
vnode.anchor = hydrateChildren(nextSibling(node), vnode, parentNode(node), parentComponent, parentSuspense, slotScopeIds, optimized);
vnode.targetAnchor = targetNode;
} else {
vnode.anchor = nextSibling(node);
vnode.targetAnchor = hydrateChildren(targetNode, vnode, target, parentComponent, parentSuspense, slotScopeIds, optimized);
}
target._lpa = vnode.targetAnchor && nextSibling(vnode.targetAnchor);
if (isTeleportDisabled(vnode.props)) {
vnode.anchor = hydrateChildren(nextSibling(node), vnode, parentNode(node), parentComponent, parentSuspense, slotScopeIds, optimized);
vnode.targetAnchor = targetNode;
} else {
vnode.anchor = nextSibling(node);
vnode.targetAnchor = hydrateChildren(targetNode, vnode, target, parentComponent, parentSuspense, slotScopeIds, optimized);
}
target._lpa = vnode.targetAnchor && nextSibling(vnode.targetAnchor);
}
}
return vnode.anchor && nextSibling(vnode.anchor);
......@@ -9376,24 +9369,20 @@ export default function vueFactory(exports) {
if (shapeFlag & 128
/* SUSPENSE */
) {
type.normalize(vnode);
}
type.normalize(vnode);
}
if (isBlockTreeEnabled > 0 && // avoid a block node from tracking itself
!isBlockNode && // has current parent block
currentBlock && ( // presence of a patch flag indicates this node needs patching on updates.
// component nodes also should always be patched, because even if the
// component doesn't need to update, it needs to persist the instance on to
// the next vnode so that it can be properly unmounted later.
patchFlag > 0 || shapeFlag & 6
currentBlock && (patchFlag > 0 || shapeFlag & 6
/* COMPONENT */
) && // the EVENTS flag is only for hydration and if it is the only flag, the
// vnode should not be considered dynamic due to handler caching.
patchFlag !== 32
/* HYDRATE_EVENTS */
) {
currentBlock.push(vnode);
}
currentBlock.push(vnode);
}
return vnode;
}
......@@ -9543,18 +9532,18 @@ export default function vueFactory(exports) {
|| shapeFlag & 64
/* TELEPORT */
) {
// Normalize slot to plain children for plain element and Teleport
var slot = children.default;
// Normalize slot to plain children for plain element and Teleport
var slot = children.default;
if (slot) {
// _c marker is added by withCtx() indicating this is a compiled slot
slot._c && (slot._d = false);
normalizeChildren(vnode, slot());
slot._c && (slot._d = true);
}
if (slot) {
// _c marker is added by withCtx() indicating this is a compiled slot
slot._c && (slot._d = false);
normalizeChildren(vnode, slot());
slot._c && (slot._d = true);
}
return;
} else {
return;
} else {
type = 32
/* SLOTS_CHILDREN */
;
......@@ -9570,10 +9559,10 @@ export default function vueFactory(exports) {
if (currentRenderingInstance.slots._ === 1
/* STABLE */
) {
children._ = 1
/* STABLE */
;
} else {
children._ = 1
/* STABLE */
;
} else {
children._ = 2
/* DYNAMIC */
;
......@@ -9597,11 +9586,11 @@ export default function vueFactory(exports) {
if (shapeFlag & 64
/* TELEPORT */
) {
type = 16
/* ARRAY_CHILDREN */
;
children = [createTextVNode(children)];
} else {
type = 16
/* ARRAY_CHILDREN */
;
children = [createTextVNode(children)];
} else {
type = 8
/* TEXT_CHILDREN */
;
......@@ -9920,8 +9909,7 @@ export default function vueFactory(exports) {
/* CONTEXT */
;
return ctx[key];
} else if ( // window properties
globalProperties = appContext.config.globalProperties, hasOwn(globalProperties, key)) {
} else if (globalProperties = appContext.config.globalProperties, hasOwn(globalProperties, key)) {
{
return globalProperties[key];
}
......@@ -11207,15 +11195,15 @@ export default function vueFactory(exports) {
if (vnode.shapeFlag & 128
/* SUSPENSE */
) {
var suspense = vnode.suspense;
vnode = suspense.activeBranch;
var suspense = vnode.suspense;
vnode = suspense.activeBranch;
if (suspense.pendingBranch && !suspense.isHydrating) {
suspense.effects.push(() => {
setVarsOnVNode(suspense.activeBranch, vars);
});
}
} // drill down HOCs until it's a non-component vnode
if (suspense.pendingBranch && !suspense.isHydrating) {
suspense.effects.push(() => {
setVarsOnVNode(suspense.activeBranch, vars);
});
}
} // drill down HOCs until it's a non-component vnode
while (vnode.component) {
......
export const INVOKE_VIEW_API = 'invokeViewApi'
export const INVOKE_SERVICE_API = 'invokeServiceApi'
......@@ -2,3 +2,4 @@ export * from './i18n'
export * from './view'
export * from './service'
export * from './helpers'
export * from './constants'
import { extend } from '@vue/shared'
import { INVOKE_VIEW_API } from '../../constants'
import { getCurrentPageId } from '../../helpers'
import { initBridge } from '../../helpers/bridge'
let invokeViewMethodId = 0
function publishViewMethodName() {
return getCurrentPageId() + '.' + INVOKE_VIEW_API
}
const invokeViewMethod: UniApp.UniServiceJSBridge['invokeViewMethod'] = (
name: string,
args: unknown,
pageId: number,
callback?: (res: any) => void
) => {
const { subscribe, publishHandler } = UniServiceJSBridge
const id = invokeViewMethodId++
callback && subscribe(INVOKE_VIEW_API + '.' + id, callback, true)
publishHandler(publishViewMethodName(), { id, name, args }, pageId)
}
const invokeViewMethodKeepAlive: UniApp.UniServiceJSBridge['invokeViewMethodKeepAlive'] =
(
name: string,
args: unknown,
callback: (res: any) => void,
pageId: number
) => {
const { subscribe, unsubscribe, publishHandler } = UniServiceJSBridge
const id = invokeViewMethodId++
const subscribeName = INVOKE_VIEW_API + '.' + id
subscribe(subscribeName, callback)
publishHandler(publishViewMethodName(), { id, name, args }, pageId)
return () => {
unsubscribe(subscribeName)
}
}
const invokeOnCallback: UniApp.UniServiceJSBridge['invokeOnCallback'] = (
name: string,
res: unknown
) => UniServiceJSBridge.emit('api.' + name, res)
import { invokeOnCallback } from './invokeOnCallback'
import { invokeViewMethod, invokeViewMethodKeepAlive } from './invokeViewMethod'
export const ServiceJSBridge = /*#__PURE__*/ extend(
initBridge('view' /* view 指的是 service 层订阅的是 view 层事件 */),
......@@ -52,3 +12,8 @@ export const ServiceJSBridge = /*#__PURE__*/ extend(
invokeViewMethodKeepAlive,
}
)
export {
registerServiceMethod,
subscribeServiceMethod,
} from './subscribeServiceMethod'
export const invokeOnCallback: UniApp.UniServiceJSBridge['invokeOnCallback'] = (
name: string,
res: unknown
) => UniServiceJSBridge.emit('api.' + name, res)
import { INVOKE_VIEW_API } from '../../constants'
import { getCurrentPageId } from '../../helpers/page'
let invokeViewMethodId = 1
function publishViewMethodName() {
return getCurrentPageId() + '.' + INVOKE_VIEW_API
}
export const invokeViewMethod: UniApp.UniServiceJSBridge['invokeViewMethod'] = (
name: string,
args: unknown,
pageId: number,
callback?: (res: any) => void
) => {
const { subscribe, publishHandler } = UniServiceJSBridge
const id = callback ? invokeViewMethodId++ : 0
callback && subscribe(INVOKE_VIEW_API + '.' + id, callback, true)
publishHandler(publishViewMethodName(), { id, name, args }, pageId)
}
export const invokeViewMethodKeepAlive: UniApp.UniServiceJSBridge['invokeViewMethodKeepAlive'] =
(
name: string,
args: unknown,
callback: (res: any) => void,
pageId: number
) => {
const { subscribe, unsubscribe, publishHandler } = UniServiceJSBridge
const id = invokeViewMethodId++
const subscribeName = INVOKE_VIEW_API + '.' + id
subscribe(subscribeName, callback)
publishHandler(publishViewMethodName(), { id, name, args }, pageId)
return () => {
unsubscribe(subscribeName)
}
}
import { formatLog } from '@dcloudio/uni-shared'
import { INVOKE_SERVICE_API } from '../../constants'
type ServiceMethod<Args = any, Res = any> = (
args: Args,
publish: (res: Res) => void
) => void
const serviceMethods: Record<string, ServiceMethod<any>> = Object.create(null)
export function subscribeServiceMethod() {
UniServiceJSBridge.subscribe(INVOKE_SERVICE_API, onInvokeServiceMethod)
}
export function registerServiceMethod<Args = any, Res = any>(
name: string,
fn: ServiceMethod<Args, Res>
) {
if (!serviceMethods[name]) {
serviceMethods[name] = fn
}
}
function onInvokeServiceMethod(
{
id,
name,
args,
}: {
id: number
name: string
args: any
},
pageId: number
) {
const publish = (res: unknown) => {
id &&
UniServiceJSBridge.publishHandler(
INVOKE_SERVICE_API + '.' + id,
res,
pageId
)
}
const handler = serviceMethods[name]
if (handler) {
handler(args, publish)
} else {
publish({})
if (__DEV__) {
console.error(formatLog('invokeViewMethod', name, 'not register'))
}
}
}
export { ServiceJSBridge } from './bridge'
export {
ServiceJSBridge,
registerServiceMethod,
subscribeServiceMethod,
} from './bridge'
export { initService, initAppVm, initPageVm } from './init'
export { initServicePlugin } from './plugin'
import { formatLog } from '@dcloudio/uni-shared'
import { INVOKE_VIEW_API } from '../../constants'
import { initBridge } from '../../helpers/bridge'
export const ViewJSBridge = /*#__PURE__*/ initBridge('service')
function normalizeViewMethodName(pageId: number, name: string) {
return pageId + '.' + name
}
export function subscribeViewMethod(pageId: number) {
UniViewJSBridge.subscribe(
normalizeViewMethodName(pageId, INVOKE_VIEW_API),
onInvokeViewMethod
)
}
/**
* 仅 h5 平台需要主动取消监听
* @param pageId
*/
export function unsubscribeViewMethod(pageId: number) {
if (__DEV__) {
console.log(formatLog('unsubscribeViewMethod', pageId, INVOKE_VIEW_API))
}
UniViewJSBridge.unsubscribe(normalizeViewMethodName(pageId, INVOKE_VIEW_API))
Object.keys(viewMethods).forEach((name) => {
if (name.indexOf(pageId + '.') === 0) {
if (__DEV__) {
console.log(formatLog('unsubscribeViewMethod', name))
}
delete viewMethods[name]
}
})
}
import { extend } from '@vue/shared'
type ViewMethod<Args = any, Res = any> = (
args: Args,
publish: (res: Res) => void
) => void
const viewMethods: Record<string, ViewMethod<any>> = Object.create(null)
export function registerViewMethod<Args = any, Res = any>(
pageId: number,
name: string,
fn: ViewMethod<Args, Res>
) {
name = normalizeViewMethodName(pageId, name)
if (!viewMethods[name]) {
viewMethods[name] = fn
}
}
export function unregisterViewMethod(pageId: number, name: string) {
name = normalizeViewMethodName(pageId, name)
delete viewMethods[name]
}
function onInvokeViewMethod(
{
id,
name,
args,
}: {
id: number
name: string
args: any
},
pageId: number
) {
name = normalizeViewMethodName(pageId, name)
const publish = (res: unknown) => {
UniViewJSBridge.publishHandler(INVOKE_VIEW_API + '.' + id, res)
}
const handler = viewMethods[name]
if (handler) {
handler(args, publish)
} else {
publish({})
if (__DEV__) {
console.error(formatLog('invokeViewMethod', name, 'not register'))
}
}
}
import { initBridge } from '../../helpers/bridge'
import { invokeServiceMethod } from './invokeServiceMethod'
export const ViewJSBridge = /*#__PURE__*/ extend(initBridge('service'), {
invokeServiceMethod,
})
export {
subscribeViewMethod,
unsubscribeViewMethod,
registerViewMethod,
unregisterViewMethod,
} from './subscribeViewMethod'
import { INVOKE_SERVICE_API } from '../../constants'
let invokeServiceMethodId = 1
export const invokeServiceMethod: UniApp.UniViewJSBridge['invokeServiceMethod'] =
(name: string, args: unknown, callback?: (res: any) => void) => {
const { subscribe, publishHandler } = UniViewJSBridge
const id = callback ? invokeServiceMethodId++ : 0
callback && subscribe(INVOKE_SERVICE_API + '.' + id, callback, true)
publishHandler(INVOKE_SERVICE_API, { id, name, args })
}
import { formatLog } from '@dcloudio/uni-shared'
import { INVOKE_VIEW_API } from '../../constants'
type ViewMethod<Args = any, Res = any> = (
args: Args,
publish: (res: Res) => void
) => void
const viewMethods: Record<string, ViewMethod<any>> = Object.create(null)
function normalizeViewMethodName(pageId: number, name: string) {
return pageId + '.' + name
}
export function subscribeViewMethod(pageId: number) {
UniViewJSBridge.subscribe(
normalizeViewMethodName(pageId, INVOKE_VIEW_API),
onInvokeViewMethod
)
}
/**
* 仅 h5 平台需要主动取消监听
* @param pageId
*/
export function unsubscribeViewMethod(pageId: number) {
if (__DEV__) {
console.log(formatLog('unsubscribeViewMethod', pageId, INVOKE_VIEW_API))
}
UniViewJSBridge.unsubscribe(normalizeViewMethodName(pageId, INVOKE_VIEW_API))
Object.keys(viewMethods).forEach((name) => {
if (name.indexOf(pageId + '.') === 0) {
if (__DEV__) {
console.log(formatLog('unsubscribeViewMethod', name))
}
delete viewMethods[name]
}
})
}
export function registerViewMethod<Args = any, Res = any>(
pageId: number,
name: string,
fn: ViewMethod<Args, Res>
) {
name = normalizeViewMethodName(pageId, name)
if (!viewMethods[name]) {
viewMethods[name] = fn
}
}
export function unregisterViewMethod(pageId: number, name: string) {
name = normalizeViewMethodName(pageId, name)
delete viewMethods[name]
}
function onInvokeViewMethod(
{
id,
name,
args,
}: {
id: number
name: string
args: any
},
pageId: number
) {
name = normalizeViewMethodName(pageId, name)
const publish = (res: unknown) => {
id && UniViewJSBridge.publishHandler(INVOKE_VIEW_API + '.' + id, res)
}
const handler = viewMethods[name]
if (handler) {
handler(args, publish)
} else {
publish({})
if (__DEV__) {
console.error(formatLog('invokeViewMethod', name, 'not register'))
}
}
}
......@@ -307,7 +307,6 @@ const initI18nVideoMsgsOnce = /* @__PURE__ */ uniShared.once(() => {
useI18n().add(uniI18n.LOCALE_ZH_HANT, normalizeMessages(name, { danmu: "\u5F48\u5E55", volume: "\u97F3\u91CF" }));
}
});
const INVOKE_VIEW_API = "invokeViewApi";
const E = function() {
};
E.prototype = {
......@@ -381,17 +380,28 @@ function initBridge(subscribeNamespace) {
}
};
}
const ViewJSBridge = /* @__PURE__ */ initBridge("service");
const INVOKE_VIEW_API = "invokeViewApi";
const INVOKE_SERVICE_API = "invokeServiceApi";
let invokeServiceMethodId = 1;
const invokeServiceMethod = (name, args, callback) => {
const { subscribe, publishHandler } = UniViewJSBridge;
const id = callback ? invokeServiceMethodId++ : 0;
callback && subscribe(INVOKE_SERVICE_API + "." + id, callback, true);
publishHandler(INVOKE_SERVICE_API, { id, name, args });
};
const viewMethods = Object.create(null);
function normalizeViewMethodName(pageId, name) {
return pageId + "." + name;
}
const viewMethods = Object.create(null);
function registerViewMethod(pageId, name, fn) {
name = normalizeViewMethodName(pageId, name);
if (!viewMethods[name]) {
viewMethods[name] = fn;
}
}
const ViewJSBridge = /* @__PURE__ */ shared.extend(initBridge("service"), {
invokeServiceMethod
});
uniShared.passive(true);
const onEventPrevent = /* @__PURE__ */ vue.withModifiers(() => {
}, ["prevent"]);
......@@ -582,13 +592,14 @@ function createNativeEvent(evt) {
}
return event;
}
let invokeViewMethodId = 0;
const invokeOnCallback = (name, res) => UniServiceJSBridge.emit("api." + name, res);
let invokeViewMethodId = 1;
function publishViewMethodName() {
return getCurrentPageId() + "." + INVOKE_VIEW_API;
}
const invokeViewMethod = (name, args, pageId, callback) => {
const { subscribe, publishHandler } = UniServiceJSBridge;
const id = invokeViewMethodId++;
const id = callback ? invokeViewMethodId++ : 0;
callback && subscribe(INVOKE_VIEW_API + "." + id, callback, true);
publishHandler(publishViewMethodName(), { id, name, args }, pageId);
};
......@@ -602,7 +613,6 @@ const invokeViewMethodKeepAlive = (name, args, callback, pageId) => {
unsubscribe(subscribeName);
};
};
const invokeOnCallback = (name, res) => UniServiceJSBridge.emit("api." + name, res);
const ServiceJSBridge = /* @__PURE__ */ shared.extend(initBridge("view"), {
invokeOnCallback,
invokeViewMethod,
......
......@@ -396,7 +396,6 @@ const initI18nVideoMsgsOnce = /* @__PURE__ */ once(() => {
useI18n().add(LOCALE_ZH_HANT, normalizeMessages(name, { danmu: "\u5F48\u5E55", volume: "\u97F3\u91CF" }));
}
});
const INVOKE_VIEW_API = "invokeViewApi";
const E = function() {
};
E.prototype = {
......@@ -470,7 +469,16 @@ function initBridge(subscribeNamespace) {
}
};
}
const ViewJSBridge = /* @__PURE__ */ initBridge("service");
const INVOKE_VIEW_API = "invokeViewApi";
const INVOKE_SERVICE_API = "invokeServiceApi";
let invokeServiceMethodId = 1;
const invokeServiceMethod = (name, args, callback) => {
const { subscribe, publishHandler } = UniViewJSBridge;
const id2 = callback ? invokeServiceMethodId++ : 0;
callback && subscribe(INVOKE_SERVICE_API + "." + id2, callback, true);
publishHandler(INVOKE_SERVICE_API, { id: id2, name, args });
};
const viewMethods = Object.create(null);
function normalizeViewMethodName(pageId, name) {
return pageId + "." + name;
}
......@@ -491,7 +499,6 @@ function unsubscribeViewMethod(pageId) {
}
});
}
const viewMethods = Object.create(null);
function registerViewMethod(pageId, name, fn) {
name = normalizeViewMethodName(pageId, name);
if (!viewMethods[name]) {
......@@ -509,7 +516,7 @@ function onInvokeViewMethod({
}, pageId) {
name = normalizeViewMethodName(pageId, name);
const publish = (res) => {
UniViewJSBridge.publishHandler(INVOKE_VIEW_API + "." + id2, res);
id2 && UniViewJSBridge.publishHandler(INVOKE_VIEW_API + "." + id2, res);
};
const handler = viewMethods[name];
if (handler) {
......@@ -521,6 +528,9 @@ function onInvokeViewMethod({
}
}
}
const ViewJSBridge = /* @__PURE__ */ extend(initBridge("service"), {
invokeServiceMethod
});
const LONGPRESS_TIMEOUT = 350;
const LONGPRESS_THRESHOLD = 10;
const passiveOptions$2 = passive(true);
......@@ -1350,13 +1360,14 @@ function initAppConfig$1(appConfig) {
function initViewPlugin(app) {
initAppConfig$1(app._context.config);
}
let invokeViewMethodId = 0;
const invokeOnCallback = (name, res) => UniServiceJSBridge.emit("api." + name, res);
let invokeViewMethodId = 1;
function publishViewMethodName() {
return getCurrentPageId() + "." + INVOKE_VIEW_API;
}
const invokeViewMethod = (name, args, pageId, callback) => {
const { subscribe, publishHandler } = UniServiceJSBridge;
const id2 = invokeViewMethodId++;
const id2 = callback ? invokeViewMethodId++ : 0;
callback && subscribe(INVOKE_VIEW_API + "." + id2, callback, true);
publishHandler(publishViewMethodName(), { id: id2, name, args }, pageId);
};
......@@ -1370,7 +1381,6 @@ const invokeViewMethodKeepAlive = (name, args, callback, pageId) => {
unsubscribe(subscribeName);
};
};
const invokeOnCallback = (name, res) => UniServiceJSBridge.emit("api." + name, res);
const ServiceJSBridge = /* @__PURE__ */ extend(initBridge("view"), {
invokeOnCallback,
invokeViewMethod,
......@@ -2027,11 +2037,11 @@ function operateVideoPlayer(videoId, pageId, type, data) {
data
}, pageId);
}
function operateMap(id2, pageId, type, data) {
function operateMap(id2, pageId, type, data, operateMapCallback2) {
UniServiceJSBridge.invokeViewMethod("map." + id2, {
type,
data
}, pageId);
}, pageId, operateMapCallback2);
}
function getRootInfo(fields2) {
const info = {};
......@@ -3013,28 +3023,44 @@ const createVideoContext = /* @__PURE__ */ defineSyncApi(API_CREATE_VIDEO_CONTEX
}
return new VideoContext(id2, getPageIdByVm(getCurrentPageVm()));
});
const operateMapCallback = (options, res) => {
const errMsg = res.errMsg || "";
if (new RegExp("\\:\\s*fail").test(errMsg)) {
options.fail && options.fail(res);
} else {
options.success && options.success(res);
}
options.complete && options.complete(res);
};
const operateMapWrap = (id2, pageId, type, options) => {
operateMap(id2, pageId, type, options, (res) => {
options && operateMapCallback(options, res);
});
};
class MapContext {
constructor(id2, pageId) {
this.id = id2;
this.pageId = pageId;
}
getCenterLocation(options) {
operateMap(this.id, this.pageId, "getCenterLocation", options);
operateMapWrap(this.id, this.pageId, "getCenterLocation", options);
}
moveToLocation() {
operateMap(this.id, this.pageId, "moveToLocation");
operateMapWrap(this.id, this.pageId, "moveToLocation");
}
getScale(options) {
operateMap(this.id, this.pageId, "getScale", options);
operateMapWrap(this.id, this.pageId, "getScale", options);
}
getRegion(options) {
operateMap(this.id, this.pageId, "getRegion", options);
operateMapWrap(this.id, this.pageId, "getRegion", options);
}
includePoints(options) {
operateMap(this.id, this.pageId, "includePoints", options);
operateMapWrap(this.id, this.pageId, "includePoints", options);
}
translateMarker(options) {
operateMap(this.id, this.pageId, "translateMarker", options);
operateMapWrap(this.id, this.pageId, "translateMarker", options);
}
$getAppMap() {
}
addCustomLayer() {
}
......@@ -3054,9 +3080,7 @@ class MapContext {
}
moveAlong() {
}
openMapAp() {
}
$getAppMap() {
openMapApp() {
}
}
const createMapContext = /* @__PURE__ */ defineSyncApi(API_CREATE_MAP_CONTEXT, (id2, context) => {
......
......@@ -40,7 +40,7 @@
"@types/sass": "^1.16.0"
},
"uni-app": {
"compilerVersion": "3.1.22"
"compilerVersion": "3.1.23"
},
"gitHead": "3b83cc9dc4c9a214747c626f79693559c338044f"
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册