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

feat: add uni-vue-devtools

上级 0997993f
......@@ -32,6 +32,7 @@ declare var __APP_VIEW__: boolean
// Feature flags
declare var __VUE_OPTIONS_API__: boolean
declare var __VUE_PROD_DEVTOOLS__: boolean
declare var __UNI_FEATURE_WX__: boolean
declare var __UNI_FEATURE_WXS__: boolean
......
......@@ -30,3 +30,7 @@ export function getPlatforms() {
export function getPlatformDir() {
return process.env.UNI_SUB_PLATFORM || process.env.UNI_PLATFORM
}
export function isMiniProgramPlatform() {
return !['app', 'app-plus', 'h5', 'web'].includes(process.env.UNI_PLATFORM)
}
......@@ -3,7 +3,7 @@ import path from 'path'
import * as UTSCompiler from '@dcloudio/uni-uts-v1'
import { isInHBuilderX } from './hbx'
import { runByHBuilderX } from './hbx'
import { normalizePath } from './utils'
/**
......@@ -82,7 +82,7 @@ function resolveUtsFile(
export function resolveUTSCompiler(): typeof UTSCompiler {
let compilerPath: string = ''
if (isInHBuilderX()) {
if (runByHBuilderX()) {
try {
compilerPath = require.resolve(
path.resolve(process.env.UNI_HBUILDERX_PLUGINS, 'uniapp-uts-v1')
......
......@@ -151,7 +151,7 @@ exports.default = () => [
return {
define: {
'process.env.UNI_SECURE_NETWORK_ENABLE': isSecureNetworkEnabled,
'process.env.UNI_SECURE_NETWORK_CONFIG': process.env.UNI_SECURE_NETWORK_CONFIG,
'process.env.UNI_SECURE_NETWORK_CONFIG': process.env.UNI_SECURE_NETWORK_CONFIG || JSON.stringify([]),
},
};
},
......
import {
ComponentOptions,
createElementBlock,
defineComponent,
openBlock,
} from 'vue'
import { createElementBlock, defineComponent, openBlock } from 'vue'
import { camelize, capitalize } from '@vue/shared'
import animation from './animation'
/**
......@@ -30,9 +25,11 @@ export const defineBuiltInComponent: typeof defineComponent = (
* @returns
*/
export const defineSystemComponent: typeof defineComponent = (options: any) => {
// 标记 devtools 隐藏
options.devtools = { hide: true }
// 标记为保留组件
options.__reserved = true
;(options as ComponentOptions).compatConfig = {
options.compatConfig = {
MODE: 3, // 标记为vue3
}
return defineComponent(options)
......
......@@ -680,6 +680,7 @@ const defineBuiltInComponent = (options) => {
return defineSystemComponent(options);
};
const defineSystemComponent = (options) => {
options.devtools = { hide: true };
options.__reserved = true;
options.compatConfig = {
MODE: 3
......@@ -828,7 +829,7 @@ function normalizeCustomEvent(name, domEvt, el, detail) {
};
}
const uniFormKey = PolySymbol(process.env.NODE_ENV !== "production" ? "uniForm" : "uf");
const index$E = /* @__PURE__ */ defineBuiltInComponent({
const index$C = /* @__PURE__ */ defineBuiltInComponent({
name: "Form",
emits: ["submit", "reset"],
setup(_props, {
......@@ -888,7 +889,7 @@ function useProvideLabel() {
});
return handlers;
}
const index$D = /* @__PURE__ */ defineBuiltInComponent({
const index$B = /* @__PURE__ */ defineBuiltInComponent({
name: "Label",
props: labelProps,
setup(props2, {
......@@ -962,7 +963,7 @@ const buttonProps = {
default: false
}
};
const index$C = /* @__PURE__ */ defineBuiltInComponent({
const index$A = /* @__PURE__ */ defineBuiltInComponent({
name: "Button",
props: buttonProps,
setup(props2, {
......@@ -1865,7 +1866,7 @@ const props$q = {
default: true
}
};
const index$B = /* @__PURE__ */ defineBuiltInComponent({
const index$z = /* @__PURE__ */ defineBuiltInComponent({
inheritAttrs: false,
name: "Canvas",
compatConfig: {
......@@ -2335,7 +2336,7 @@ const props$p = {
default: ""
}
};
const index$A = /* @__PURE__ */ defineBuiltInComponent({
const index$y = /* @__PURE__ */ defineBuiltInComponent({
name: "CheckboxGroup",
props: props$p,
emits: ["change"],
......@@ -2411,7 +2412,7 @@ const props$o = {
default: ""
}
};
const index$z = /* @__PURE__ */ defineBuiltInComponent({
const index$x = /* @__PURE__ */ defineBuiltInComponent({
name: "Checkbox",
props: props$o,
setup(props2, {
......@@ -2711,7 +2712,7 @@ const props$m = /* @__PURE__ */ shared.extend({}, props$n, {
default: false
}
});
const index$y = /* @__PURE__ */ defineBuiltInComponent({
const index$w = /* @__PURE__ */ defineBuiltInComponent({
name: "Editor",
props: props$m,
emit: ["ready", "focus", "blur", "input", "statuschange", ...emit$1],
......@@ -2772,7 +2773,7 @@ const ICONS = {
c: GREY_COLOR
}
};
const index$x = /* @__PURE__ */ defineBuiltInComponent({
const index$v = /* @__PURE__ */ defineBuiltInComponent({
name: "Icon",
props: {
type: {
......@@ -2836,7 +2837,7 @@ const IMAGE_MODES = {
"bottom left": ["left bottom"],
"bottom right": ["right bottom"]
};
const index$w = /* @__PURE__ */ defineBuiltInComponent({
const index$u = /* @__PURE__ */ defineBuiltInComponent({
name: "Image",
props: props$l,
setup(props2, {
......@@ -3630,7 +3631,7 @@ const movableAreaProps = {
default: false
}
};
const index$v = /* @__PURE__ */ defineBuiltInComponent({
const index$t = /* @__PURE__ */ defineBuiltInComponent({
inheritAttrs: false,
name: "MovableArea",
props: movableAreaProps,
......@@ -4178,7 +4179,7 @@ const movableViewProps = {
function v(a, b) {
return +((1e3 * a - 1e3 * b) / 1e3).toFixed(1);
}
const index$u = /* @__PURE__ */ defineBuiltInComponent({
const index$s = /* @__PURE__ */ defineBuiltInComponent({
name: "MovableView",
props: movableViewProps,
emits: ["change", "scale"],
......@@ -4822,7 +4823,7 @@ function createNavigatorOnClick(props2) {
}
};
}
const index$t = /* @__PURE__ */ defineBuiltInComponent({
const index$r = /* @__PURE__ */ defineBuiltInComponent({
name: "Navigator",
inheritAttrs: false,
compatConfig: {
......@@ -5147,7 +5148,7 @@ const progressProps = {
default: 0
}
};
const index$s = /* @__PURE__ */ defineBuiltInComponent({
const index$q = /* @__PURE__ */ defineBuiltInComponent({
name: "Progress",
props: progressProps,
setup(props2) {
......@@ -5226,7 +5227,7 @@ const props$i = {
default: ""
}
};
const index$r = /* @__PURE__ */ defineBuiltInComponent({
const index$p = /* @__PURE__ */ defineBuiltInComponent({
name: "RadioGroup",
props: props$i,
setup(props2, {
......@@ -5327,7 +5328,7 @@ const props$h = {
default: ""
}
};
const index$q = /* @__PURE__ */ defineBuiltInComponent({
const index$o = /* @__PURE__ */ defineBuiltInComponent({
name: "Radio",
props: props$h,
setup(props2, {
......@@ -5659,7 +5660,7 @@ const props$g = {
}
}
};
const index$p = /* @__PURE__ */ defineBuiltInComponent({
const index$n = /* @__PURE__ */ defineBuiltInComponent({
name: "RichText",
compatConfig: {
MODE: 3
......@@ -5750,7 +5751,7 @@ const props$f = {
default: false
}
};
const index$o = /* @__PURE__ */ defineBuiltInComponent({
const index$m = /* @__PURE__ */ defineBuiltInComponent({
name: "ScrollView",
compatConfig: {
MODE: 3
......@@ -6077,7 +6078,7 @@ const props$e = {
default: false
}
};
const index$n = /* @__PURE__ */ defineBuiltInComponent({
const index$l = /* @__PURE__ */ defineBuiltInComponent({
name: "Slider",
props: props$e,
emits: ["changing", "change"],
......@@ -6634,7 +6635,7 @@ function useLayout(props2, state, swiperContexts, slideFrameRef, emit2, trigger)
swiperEnabled
};
}
const index$m = /* @__PURE__ */ defineBuiltInComponent({
const index$k = /* @__PURE__ */ defineBuiltInComponent({
name: "Swiper",
props: props$d,
emits: ["change", "transition", "animationfinish", "update:current", "update:currentItemId"],
......@@ -6863,7 +6864,7 @@ const props$c = {
default: ""
}
};
const index$l = /* @__PURE__ */ defineBuiltInComponent({
const index$j = /* @__PURE__ */ defineBuiltInComponent({
name: "SwiperItem",
props: props$c,
setup(props2, {
......@@ -6908,7 +6909,7 @@ const props$b = {
default: "#007aff"
}
};
const index$k = /* @__PURE__ */ defineBuiltInComponent({
const index$i = /* @__PURE__ */ defineBuiltInComponent({
name: "Switch",
props: props$b,
emits: ["change"],
......@@ -7001,7 +7002,7 @@ function normalizeText(text, { space, decode }) {
}
return text.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 index$j = /* @__PURE__ */ defineBuiltInComponent({
const index$h = /* @__PURE__ */ defineBuiltInComponent({
name: "Text",
props: {
selectable: {
......@@ -7073,7 +7074,7 @@ const props$a = /* @__PURE__ */ shared.extend({}, props$k, {
});
let fixMargin = false;
const ConfirmTypes = ["done", "go", "next", "search", "send"];
const index$i = /* @__PURE__ */ defineBuiltInComponent({
const index$g = /* @__PURE__ */ defineBuiltInComponent({
name: "Textarea",
props: props$a,
emits: ["confirm", "linechange", ...emit],
......@@ -7195,7 +7196,7 @@ const index$i = /* @__PURE__ */ defineBuiltInComponent({
};
}
});
const index$h = /* @__PURE__ */ defineBuiltInComponent({
const index$f = /* @__PURE__ */ defineBuiltInComponent({
name: "View",
props: shared.extend({}, hoverProps),
setup(props2, {
......@@ -7220,13 +7221,13 @@ function useSubscribe(callback, name, multiple, pageId) {
const instance = vue.getCurrentInstance();
instance.proxy;
}
let index$g = 0;
let index$e = 0;
function useContextInfo(_id) {
useCurrentPageId();
const instance = vue.getCurrentInstance();
const vm = instance.proxy;
const type = vm.$options.name.toLowerCase();
const id = _id || vm.id || `context${index$g++}`;
const id = _id || vm.id || `context${index$e++}`;
return `${type}.${id}`;
}
function injectLifecycleHook(name, hook, publicThis, instance) {
......@@ -7627,7 +7628,7 @@ function initHistory() {
return vueRouter.createMemoryHistory(routerBase);
}
}
const index$f = {
const index$d = {
install(app) {
initApp$1(app);
if (!app.config.warnHandler) {
......@@ -7656,12 +7657,48 @@ function warnHandler(msg, instance, trace) {
}
console.warn(...warnArgs);
}
const clazz = { class: "uni-async-loading" };
const loadingVNode = /* @__PURE__ */ vue.createVNode(
"i",
{ class: "uni-loading" },
null,
-1
);
const AsyncLoadingComponent = /* @__PURE__ */ defineSystemComponent({
name: "AsyncLoading",
render() {
return vue.openBlock(), vue.createBlock("div", clazz, [loadingVNode]);
}
});
function reload() {
window.location.reload();
}
const AsyncErrorComponent = /* @__PURE__ */ defineSystemComponent({
name: "AsyncError",
setup() {
initI18nAsyncMsgsOnce();
const {
t: t2
} = useI18n();
return () => vue.createVNode("div", {
"class": "uni-async-error",
"onClick": reload
}, [t2("uni.async.error")], 8, ["onClick"]);
}
});
let appVm;
function getApp$1() {
return appVm;
}
function initApp(vm) {
appVm = vm;
const app = appVm.$.appContext.app;
if (!app.component(AsyncLoadingComponent.name)) {
app.component(AsyncLoadingComponent.name, AsyncLoadingComponent);
}
if (!app.component(AsyncErrorComponent.name)) {
app.component(AsyncErrorComponent.name, AsyncErrorComponent);
}
initAppVm(appVm);
defineGlobalData(appVm);
}
......@@ -8293,7 +8330,7 @@ const props$9 = {
default: true
}
};
const index$e = /* @__PURE__ */ defineBuiltInComponent({
const index$c = /* @__PURE__ */ defineBuiltInComponent({
name: "Video",
props: props$9,
emits: ["fullscreenchange", "progress", "loadedmetadata", "waiting", "error", "play", "pause", "ended", "timeupdate"],
......@@ -8526,7 +8563,7 @@ const props$8 = {
default: true
}
};
const index$d = /* @__PURE__ */ defineBuiltInComponent({
const index$b = /* @__PURE__ */ defineBuiltInComponent({
inheritAttrs: false,
name: "WebView",
props: props$8,
......@@ -9660,7 +9697,7 @@ function useMap(props2, rootRef, emit2) {
trigger
};
}
const index$c = /* @__PURE__ */ defineBuiltInComponent({
const index$a = /* @__PURE__ */ defineBuiltInComponent({
name: "Map",
props: props$2,
emits: ["markertap", "labeltap", "callouttap", "controltap", "regionchange", "tap", "click", "updated", "update:scale", "update:latitude", "update:longitude"],
......@@ -9696,7 +9733,7 @@ const props$1 = {
default: 0
}
};
const index$b = /* @__PURE__ */ defineBuiltInComponent({
const index$9 = /* @__PURE__ */ defineBuiltInComponent({
name: "CoverView",
compatConfig: {
MODE: 3
......@@ -9734,7 +9771,7 @@ const index$b = /* @__PURE__ */ defineBuiltInComponent({
};
}
});
const index$a = /* @__PURE__ */ defineBuiltInComponent({
const index$8 = /* @__PURE__ */ defineBuiltInComponent({
name: "CoverImage",
compatConfig: {
MODE: 3
......@@ -9983,7 +10020,7 @@ const props = {
default: ""
}
};
const index$9 = /* @__PURE__ */ defineBuiltInComponent({
const index$7 = /* @__PURE__ */ defineBuiltInComponent({
name: "Picker",
compatConfig: {
MODE: 3
......@@ -10598,12 +10635,12 @@ function usePickerForm(_resetFormData, _getFormData) {
uniForm.addField(field);
}
}
const index$8 = /* @__PURE__ */ defineUnsupportedComponent("ad");
const index$7 = /* @__PURE__ */ defineUnsupportedComponent("ad-content-page");
const index$6 = /* @__PURE__ */ defineUnsupportedComponent("ad-draw");
const index$5 = /* @__PURE__ */ defineUnsupportedComponent("camera");
const index$4 = /* @__PURE__ */ defineUnsupportedComponent("live-player");
const index$3 = /* @__PURE__ */ defineUnsupportedComponent("live-pusher");
const index$6 = /* @__PURE__ */ defineUnsupportedComponent("ad");
const index$5 = /* @__PURE__ */ defineUnsupportedComponent("ad-content-page");
const index$4 = /* @__PURE__ */ defineUnsupportedComponent("ad-draw");
const index$3 = /* @__PURE__ */ defineUnsupportedComponent("camera");
const index$2 = /* @__PURE__ */ defineUnsupportedComponent("live-player");
const index$1 = /* @__PURE__ */ defineUnsupportedComponent("live-pusher");
const UniViewJSBridge$1 = /* @__PURE__ */ shared.extend(ViewJSBridge, {
publishHandler(event, args, pageId) {
UniServiceJSBridge.subscribeHandler(event, args, pageId);
......@@ -12190,7 +12227,7 @@ function createPageRefreshTsx(refreshRef, pageMeta) {
"ref": refreshRef
}, null, 512);
}
const index$2 = defineSystemComponent({
const index = defineSystemComponent({
name: "Page",
setup(_props, ctx) {
const pageMeta = providePageMeta(getStateId());
......@@ -12213,81 +12250,52 @@ function createPageBodyVNode(ctx) {
}
);
}
function reload() {
window.location.reload();
}
const index$1 = /* @__PURE__ */ defineSystemComponent({
name: "AsyncError",
setup() {
initI18nAsyncMsgsOnce();
const {
t: t2
} = useI18n();
return () => vue.createVNode("div", {
"class": "uni-async-error",
"onClick": reload
}, [t2("uni.async.error")], 8, ["onClick"]);
}
});
const clazz = { class: "uni-async-loading" };
const loadingVNode = /* @__PURE__ */ vue.createVNode(
"i",
{ class: "uni-loading" },
null,
-1
);
const index = /* @__PURE__ */ defineSystemComponent({
name: "AsyncLoading",
render() {
return vue.openBlock(), vue.createBlock("div", clazz, [loadingVNode]);
}
});
exports.Ad = index$8;
exports.AdContentPage = index$7;
exports.AdDraw = index$6;
exports.AsyncErrorComponent = index$1;
exports.AsyncLoadingComponent = index;
exports.Button = index$C;
exports.Camera = index$5;
exports.Canvas = index$B;
exports.Checkbox = index$z;
exports.CheckboxGroup = index$A;
exports.CoverImage = index$a;
exports.CoverView = index$b;
exports.Editor = index$y;
exports.Form = index$E;
exports.Icon = index$x;
exports.Image = index$w;
exports.Ad = index$6;
exports.AdContentPage = index$5;
exports.AdDraw = index$4;
exports.AsyncErrorComponent = AsyncErrorComponent;
exports.AsyncLoadingComponent = AsyncLoadingComponent;
exports.Button = index$A;
exports.Camera = index$3;
exports.Canvas = index$z;
exports.Checkbox = index$x;
exports.CheckboxGroup = index$y;
exports.CoverImage = index$8;
exports.CoverView = index$9;
exports.Editor = index$w;
exports.Form = index$C;
exports.Icon = index$v;
exports.Image = index$u;
exports.Input = Input;
exports.Label = index$D;
exports.Label = index$B;
exports.LayoutComponent = LayoutComponent;
exports.LivePlayer = index$4;
exports.LivePusher = index$3;
exports.Map = index$c;
exports.MovableArea = index$v;
exports.MovableView = index$u;
exports.Navigator = index$t;
exports.PageComponent = index$2;
exports.Picker = index$9;
exports.LivePlayer = index$2;
exports.LivePusher = index$1;
exports.Map = index$a;
exports.MovableArea = index$t;
exports.MovableView = index$s;
exports.Navigator = index$r;
exports.PageComponent = index;
exports.Picker = index$7;
exports.PickerView = PickerView;
exports.PickerViewColumn = PickerViewColumn;
exports.Progress = index$s;
exports.Radio = index$q;
exports.RadioGroup = index$r;
exports.Progress = index$q;
exports.Radio = index$o;
exports.RadioGroup = index$p;
exports.ResizeSensor = ResizeSensor;
exports.RichText = index$p;
exports.ScrollView = index$o;
exports.Slider = index$n;
exports.Swiper = index$m;
exports.SwiperItem = index$l;
exports.Switch = index$k;
exports.Text = index$j;
exports.Textarea = index$i;
exports.RichText = index$n;
exports.ScrollView = index$m;
exports.Slider = index$l;
exports.Swiper = index$k;
exports.SwiperItem = index$j;
exports.Switch = index$i;
exports.Text = index$h;
exports.Textarea = index$g;
exports.UniServiceJSBridge = UniServiceJSBridge$1;
exports.UniViewJSBridge = UniViewJSBridge$1;
exports.Video = index$e;
exports.View = index$h;
exports.WebView = index$d;
exports.Video = index$c;
exports.View = index$f;
exports.WebView = index$b;
exports.clearStorage = clearStorage;
exports.clearStorageSync = clearStorageSync;
exports.getApp = getApp$1;
......@@ -12300,7 +12308,7 @@ exports.getStorageInfo = getStorageInfo;
exports.getStorageInfoSync = getStorageInfoSync;
exports.getStorageSync = getStorageSync;
exports.getSystemInfoSync = getSystemInfoSync;
exports.plugin = index$f;
exports.plugin = index$d;
exports.removeStorage = removeStorage;
exports.removeStorageSync = removeStorageSync;
exports.request = request;
......
import { withModifiers, createVNode, getCurrentInstance, ref, defineComponent, openBlock, createElementBlock, provide, computed, watch, onUnmounted, inject, onBeforeUnmount, mergeProps, injectHook, reactive, onActivated, onMounted, nextTick, onBeforeMount, withDirectives, vShow, shallowRef, watchEffect, isVNode, Fragment, markRaw, Comment, h, createTextVNode, onBeforeActivate, onBeforeDeactivate, createBlock, renderList, onDeactivated, createApp, Transition, effectScope, withCtx, KeepAlive, resolveDynamicComponent, createElementVNode, normalizeStyle, renderSlot } from "vue";
import { withModifiers, createVNode, getCurrentInstance, ref, defineComponent, openBlock, createElementBlock, provide, computed, watch, onUnmounted, inject, onBeforeUnmount, mergeProps, injectHook, reactive, onActivated, onMounted, nextTick, onBeforeMount, withDirectives, vShow, shallowRef, watchEffect, isVNode, Fragment, markRaw, Comment, h, createTextVNode, createBlock, onBeforeActivate, onBeforeDeactivate, renderList, onDeactivated, createApp, Transition, effectScope, withCtx, KeepAlive, resolveDynamicComponent, createElementVNode, normalizeStyle, renderSlot } from "vue";
import { isString, extend, isArray, remove, stringifyStyle, parseStringStyle, isPlainObject, isFunction, capitalize, camelize, hasOwn, isObject, toRawType, makeMap as makeMap$1, isPromise, hyphenate, invokeArrayFns as invokeArrayFns$1 } from "@vue/shared";
import { once, UNI_STORAGE_LOCALE, I18N_JSON_DELIMITERS, Emitter, passive, initCustomDatasetOnce, resolveComponentInstance, normalizeStyles, addLeadingSlash, invokeArrayFns, removeLeadingSlash, resolveOwnerVm, resolveOwnerEl, ON_WXS_INVOKE_CALL_METHOD, normalizeTarget, ON_RESIZE, ON_APP_ENTER_FOREGROUND, ON_APP_ENTER_BACKGROUND, ON_SHOW, ON_HIDE, ON_PAGE_SCROLL, ON_REACH_BOTTOM, EventChannel, SCHEME_RE, DATA_RE, getCustomDataset, LINEFEED, ON_ERROR, callOptions, ON_UNHANDLE_REJECTION, ON_PAGE_NOT_FOUND, PRIMARY_COLOR, getLen, debounce, isUniLifecycleHook, ON_LOAD, UniLifecycleHooks, invokeCreateErrorHandler, invokeCreateVueAppHook, parseQuery, NAVBAR_HEIGHT, ON_UNLOAD, ON_REACH_BOTTOM_DISTANCE, decodedQuery, WEB_INVOKE_APPSERVICE, ON_WEB_INVOKE_APP_SERVICE, ON_THEME_CHANGE, updateElementStyle, sortObject, OFF_THEME_CHANGE, ON_BACK_PRESS, parseUrl, addFont, ON_NAVIGATION_BAR_CHANGE, scrollTo, RESPONSIVE_MIN_WIDTH, onCreateVueApp, formatDateTime, ON_NAVIGATION_BAR_BUTTON_TAP, ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED, ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED, ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED, ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED, ON_PULL_DOWN_REFRESH } from "@dcloudio/uni-shared";
import { onCreateVueApp as onCreateVueApp2 } from "@dcloudio/uni-shared";
......@@ -1910,6 +1910,7 @@ const defineBuiltInComponent = (options) => {
return defineSystemComponent(options);
};
const defineSystemComponent = (options) => {
options.devtools = { hide: true };
options.__reserved = true;
options.compatConfig = {
MODE: 3
......@@ -2058,7 +2059,7 @@ function normalizeCustomEvent(name, domEvt, el, detail) {
};
}
const uniFormKey = PolySymbol(process.env.NODE_ENV !== "production" ? "uniForm" : "uf");
const index$B = /* @__PURE__ */ defineBuiltInComponent({
const index$z = /* @__PURE__ */ defineBuiltInComponent({
name: "Form",
emits: ["submit", "reset"],
setup(_props, {
......@@ -2118,7 +2119,7 @@ function useProvideLabel() {
});
return handlers;
}
const index$A = /* @__PURE__ */ defineBuiltInComponent({
const index$y = /* @__PURE__ */ defineBuiltInComponent({
name: "Label",
props: labelProps,
setup(props2, {
......@@ -2249,7 +2250,7 @@ const buttonProps = {
default: false
}
};
const index$z = /* @__PURE__ */ defineBuiltInComponent({
const index$x = /* @__PURE__ */ defineBuiltInComponent({
name: "Button",
props: buttonProps,
setup(props2, {
......@@ -4662,13 +4663,13 @@ const createMediaQueryObserver = /* @__PURE__ */ defineSyncApi("createMediaQuery
}
return new ServiceMediaQueryObserver(getCurrentPageVm());
});
let index$y = 0;
let index$w = 0;
let optionsCache = {};
function operateEditor(componentId, pageId, type, options) {
const data = { options };
const needCallOptions = options && ("success" in options || "fail" in options || "complete" in options);
if (needCallOptions) {
const callbackId = String(index$y++);
const callbackId = String(index$w++);
data.callbackId = callbackId;
optionsCache[callbackId] = options;
}
......@@ -7227,7 +7228,7 @@ const props$x = {
default: true
}
};
const index$x = /* @__PURE__ */ defineBuiltInComponent({
const index$v = /* @__PURE__ */ defineBuiltInComponent({
inheritAttrs: false,
name: "Canvas",
compatConfig: {
......@@ -7700,7 +7701,7 @@ const props$w = {
default: ""
}
};
const index$w = /* @__PURE__ */ defineBuiltInComponent({
const index$u = /* @__PURE__ */ defineBuiltInComponent({
name: "CheckboxGroup",
props: props$w,
emits: ["change"],
......@@ -7776,7 +7777,7 @@ const props$v = {
default: ""
}
};
const index$v = /* @__PURE__ */ defineBuiltInComponent({
const index$t = /* @__PURE__ */ defineBuiltInComponent({
name: "Checkbox",
props: props$v,
setup(props2, {
......@@ -8721,7 +8722,7 @@ const props$t = /* @__PURE__ */ extend({}, props$u, {
default: false
}
});
const index$u = /* @__PURE__ */ defineBuiltInComponent({
const index$s = /* @__PURE__ */ defineBuiltInComponent({
name: "Editor",
props: props$t,
emit: ["ready", "focus", "blur", "input", "statuschange", ...emit$1],
......@@ -8783,7 +8784,7 @@ const ICONS = {
c: GREY_COLOR
}
};
const index$t = /* @__PURE__ */ defineBuiltInComponent({
const index$r = /* @__PURE__ */ defineBuiltInComponent({
name: "Icon",
props: {
type: {
......@@ -8847,7 +8848,7 @@ const IMAGE_MODES = {
"bottom left": ["left bottom"],
"bottom right": ["right bottom"]
};
const index$s = /* @__PURE__ */ defineBuiltInComponent({
const index$q = /* @__PURE__ */ defineBuiltInComponent({
name: "Image",
props: props$s,
setup(props2, {
......@@ -11212,7 +11213,7 @@ function createNavigatorOnClick(props2) {
}
};
}
const index$r = /* @__PURE__ */ defineBuiltInComponent({
const index$p = /* @__PURE__ */ defineBuiltInComponent({
name: "Navigator",
inheritAttrs: false,
compatConfig: {
......@@ -12327,7 +12328,7 @@ const progressProps = {
default: 0
}
};
const index$q = /* @__PURE__ */ defineBuiltInComponent({
const index$o = /* @__PURE__ */ defineBuiltInComponent({
name: "Progress",
props: progressProps,
setup(props2) {
......@@ -12406,7 +12407,7 @@ const props$p = {
default: ""
}
};
const index$p = /* @__PURE__ */ defineBuiltInComponent({
const index$n = /* @__PURE__ */ defineBuiltInComponent({
name: "RadioGroup",
props: props$p,
setup(props2, {
......@@ -12513,7 +12514,7 @@ const props$o = {
default: ""
}
};
const index$o = /* @__PURE__ */ defineBuiltInComponent({
const index$m = /* @__PURE__ */ defineBuiltInComponent({
name: "Radio",
props: props$o,
setup(props2, {
......@@ -12855,7 +12856,7 @@ const props$n = {
}
}
};
const index$n = /* @__PURE__ */ defineBuiltInComponent({
const index$l = /* @__PURE__ */ defineBuiltInComponent({
name: "RichText",
compatConfig: {
MODE: 3
......@@ -13425,7 +13426,7 @@ const props$l = {
default: false
}
};
const index$m = /* @__PURE__ */ defineBuiltInComponent({
const index$k = /* @__PURE__ */ defineBuiltInComponent({
name: "Slider",
props: props$l,
emits: ["changing", "change"],
......@@ -14401,7 +14402,7 @@ const props$i = {
default: "#007aff"
}
};
const index$l = /* @__PURE__ */ defineBuiltInComponent({
const index$j = /* @__PURE__ */ defineBuiltInComponent({
name: "Switch",
props: props$i,
emits: ["change"],
......@@ -14503,7 +14504,7 @@ function normalizeText(text2, { space, decode: decode2 }) {
}
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 index$k = /* @__PURE__ */ defineBuiltInComponent({
const index$i = /* @__PURE__ */ defineBuiltInComponent({
name: "Text",
props: {
selectable: {
......@@ -14579,7 +14580,7 @@ function setFixMargin() {
const DARK_TEST_STRING = "(prefers-color-scheme: dark)";
fixMargin = String(navigator.platform).indexOf("iP") === 0 && String(navigator.vendor).indexOf("Apple") === 0 && window.matchMedia(DARK_TEST_STRING).media !== DARK_TEST_STRING;
}
const index$j = /* @__PURE__ */ defineBuiltInComponent({
const index$h = /* @__PURE__ */ defineBuiltInComponent({
name: "Textarea",
props: props$h,
emits: ["confirm", "linechange", ...emit],
......@@ -14704,7 +14705,7 @@ const index$j = /* @__PURE__ */ defineBuiltInComponent({
};
}
});
const index$i = /* @__PURE__ */ defineBuiltInComponent({
const index$g = /* @__PURE__ */ defineBuiltInComponent({
name: "View",
props: extend({}, hoverProps),
setup(props2, {
......@@ -14775,13 +14776,13 @@ function useOn(name, callback) {
onMounted(() => UniViewJSBridge.on(name, callback));
onBeforeUnmount(() => UniViewJSBridge.off(name));
}
let index$h = 0;
let index$f = 0;
function useContextInfo(_id) {
const page = useCurrentPageId();
const instance2 = getCurrentInstance();
const vm = instance2.proxy;
const type = vm.$options.name.toLowerCase();
const id2 = _id || vm.id || `context${index$h++}`;
const id2 = _id || vm.id || `context${index$f++}`;
onMounted(() => {
const el = vm.$el;
el.__uniContextInfo = {
......@@ -15093,7 +15094,7 @@ const envMethod = /* @__PURE__ */ (() => cssEnv ? "env" : cssConstant ? "constan
function updateCurPageCssVar(pageMeta) {
let windowTopValue = 0;
let windowBottomValue = 0;
if (__UNI_FEATURE_NAVIGATIONBAR__ && ["default", "float"].indexOf(pageMeta.navigationBar.type) > -1) {
if (__UNI_FEATURE_NAVIGATIONBAR__ && pageMeta.navigationBar.style !== "custom" && ["default", "float"].indexOf(pageMeta.navigationBar.type) > -1) {
windowTopValue = NAVBAR_HEIGHT;
}
if (__UNI_FEATURE_TABBAR__ && pageMeta.isTabBar) {
......@@ -15353,7 +15354,7 @@ function initHistory() {
});
return history2;
}
const index$g = {
const index$e = {
install(app) {
initApp$1(app);
initViewPlugin(app);
......@@ -15384,12 +15385,48 @@ function warnHandler(msg, instance2, trace) {
}
console.warn(...warnArgs);
}
const clazz = { class: "uni-async-loading" };
const loadingVNode = /* @__PURE__ */ createVNode(
"i",
{ class: "uni-loading" },
null,
-1
);
const AsyncLoadingComponent = /* @__PURE__ */ defineSystemComponent({
name: "AsyncLoading",
render() {
return openBlock(), createBlock("div", clazz, [loadingVNode]);
}
});
function reload() {
window.location.reload();
}
const AsyncErrorComponent = /* @__PURE__ */ defineSystemComponent({
name: "AsyncError",
setup() {
initI18nAsyncMsgsOnce();
const {
t: t2
} = useI18n();
return () => createVNode("div", {
"class": "uni-async-error",
"onClick": reload
}, [t2("uni.async.error")], 8, ["onClick"]);
}
});
let appVm;
function getApp$1() {
return appVm;
}
function initApp(vm) {
appVm = vm;
const app = appVm.$.appContext.app;
if (!app.component(AsyncLoadingComponent.name)) {
app.component(AsyncLoadingComponent.name, AsyncLoadingComponent);
}
if (!app.component(AsyncErrorComponent.name)) {
app.component(AsyncErrorComponent.name, AsyncErrorComponent);
}
initAppVm(appVm);
defineGlobalData(appVm);
initService();
......@@ -16213,7 +16250,7 @@ const props$g = {
default: true
}
};
const index$f = /* @__PURE__ */ defineBuiltInComponent({
const index$d = /* @__PURE__ */ defineBuiltInComponent({
name: "Video",
props: props$g,
emits: ["fullscreenchange", "progress", "loadedmetadata", "waiting", "error", "play", "pause", "ended", "timeupdate"],
......@@ -16446,7 +16483,7 @@ const props$f = {
default: true
}
};
const index$e = /* @__PURE__ */ defineBuiltInComponent({
const index$c = /* @__PURE__ */ defineBuiltInComponent({
inheritAttrs: false,
name: "WebView",
props: props$f,
......@@ -16535,11 +16572,11 @@ function useWebViewSize(rootRef, iframeRef, fullscreen) {
};
return _resize;
}
let index$d = 0;
let index$b = 0;
function getJSONP(url, options, success, error) {
var js = document.createElement("script");
var callbackKey = options.callback || "callback";
var callbackName = "__uni_jsonp_callback_" + index$d++;
var callbackName = "__uni_jsonp_callback_" + index$b++;
var timeout = options.timeout || 3e4;
var timing;
function end() {
......@@ -18887,13 +18924,13 @@ function usePopup(props2, {
});
return visible;
}
let index$c = 0;
let index$a = 0;
let overflow = "";
function preventScroll(prevent) {
let before = index$c;
index$c += prevent ? 1 : -1;
index$c = Math.max(0, index$c);
if (index$c > 0) {
let before = index$a;
index$a += prevent ? 1 : -1;
index$a = Math.max(0, index$a);
if (index$a > 0) {
if (before === 0) {
overflow = document.body.style.overflow;
document.body.style.overflow = "hidden";
......@@ -23148,7 +23185,7 @@ const props$1 = {
default: 0
}
};
const index$b = /* @__PURE__ */ defineBuiltInComponent({
const index$9 = /* @__PURE__ */ defineBuiltInComponent({
name: "CoverView",
compatConfig: {
MODE: 3
......@@ -23189,7 +23226,7 @@ const index$b = /* @__PURE__ */ defineBuiltInComponent({
};
}
});
const index$a = /* @__PURE__ */ defineBuiltInComponent({
const index$8 = /* @__PURE__ */ defineBuiltInComponent({
name: "CoverImage",
compatConfig: {
MODE: 3
......@@ -23362,7 +23399,7 @@ const props = {
default: ""
}
};
const index$9 = /* @__PURE__ */ defineBuiltInComponent({
const index$7 = /* @__PURE__ */ defineBuiltInComponent({
name: "Picker",
compatConfig: {
MODE: 3
......@@ -24003,12 +24040,12 @@ function usePickerForm(_resetFormData, _getFormData) {
});
}
}
const index$8 = /* @__PURE__ */ defineUnsupportedComponent("ad");
const index$7 = /* @__PURE__ */ defineUnsupportedComponent("ad-content-page");
const index$6 = /* @__PURE__ */ defineUnsupportedComponent("ad-draw");
const index$5 = /* @__PURE__ */ defineUnsupportedComponent("camera");
const index$4 = /* @__PURE__ */ defineUnsupportedComponent("live-player");
const index$3 = /* @__PURE__ */ defineUnsupportedComponent("live-pusher");
const index$6 = /* @__PURE__ */ defineUnsupportedComponent("ad");
const index$5 = /* @__PURE__ */ defineUnsupportedComponent("ad-content-page");
const index$4 = /* @__PURE__ */ defineUnsupportedComponent("ad-draw");
const index$3 = /* @__PURE__ */ defineUnsupportedComponent("camera");
const index$2 = /* @__PURE__ */ defineUnsupportedComponent("live-player");
const index$1 = /* @__PURE__ */ defineUnsupportedComponent("live-pusher");
const UniViewJSBridge$1 = /* @__PURE__ */ extend(ViewJSBridge, {
publishHandler(event, args, pageId) {
UniServiceJSBridge.subscribeHandler(event, args, pageId);
......@@ -24741,7 +24778,7 @@ function createPageRefreshTsx(refreshRef, pageMeta) {
"ref": refreshRef
}, null, 512);
}
const index$2 = defineSystemComponent({
const index = defineSystemComponent({
name: "Page",
setup(_props, ctx) {
const pageMeta = providePageMeta(getStateId());
......@@ -24764,86 +24801,57 @@ function createPageBodyVNode(ctx) {
}
);
}
function reload() {
window.location.reload();
}
const index$1 = /* @__PURE__ */ defineSystemComponent({
name: "AsyncError",
setup() {
initI18nAsyncMsgsOnce();
const {
t: t2
} = useI18n();
return () => createVNode("div", {
"class": "uni-async-error",
"onClick": reload
}, [t2("uni.async.error")], 8, ["onClick"]);
}
});
const clazz = { class: "uni-async-loading" };
const loadingVNode = /* @__PURE__ */ createVNode(
"i",
{ class: "uni-loading" },
null,
-1
);
const index = /* @__PURE__ */ defineSystemComponent({
name: "AsyncLoading",
render() {
return openBlock(), createBlock("div", clazz, [loadingVNode]);
}
});
export {
$emit,
$off,
$on,
$once,
index$8 as Ad,
index$7 as AdContentPage,
index$6 as AdDraw,
index$1 as AsyncErrorComponent,
index as AsyncLoadingComponent,
index$z as Button,
index$5 as Camera,
index$x as Canvas,
index$v as Checkbox,
index$w as CheckboxGroup,
index$a as CoverImage,
index$b as CoverView,
index$u as Editor,
index$B as Form,
index$t as Icon,
index$s as Image,
index$6 as Ad,
index$5 as AdContentPage,
index$4 as AdDraw,
AsyncErrorComponent,
AsyncLoadingComponent,
index$x as Button,
index$3 as Camera,
index$v as Canvas,
index$t as Checkbox,
index$u as CheckboxGroup,
index$8 as CoverImage,
index$9 as CoverView,
index$s as Editor,
index$z as Form,
index$r as Icon,
index$q as Image,
Input,
index$A as Label,
index$y as Label,
LayoutComponent,
index$4 as LivePlayer,
index$3 as LivePusher,
index$2 as LivePlayer,
index$1 as LivePusher,
Map$1 as Map,
MovableArea,
MovableView,
index$r as Navigator,
index$2 as PageComponent,
index$9 as Picker,
index$p as Navigator,
index as PageComponent,
index$7 as Picker,
PickerView,
PickerViewColumn,
index$q as Progress,
index$o as Radio,
index$p as RadioGroup,
index$o as Progress,
index$m as Radio,
index$n as RadioGroup,
ResizeSensor,
index$n as RichText,
index$l as RichText,
ScrollView,
index$m as Slider,
index$k as Slider,
Swiper,
SwiperItem,
index$l as Switch,
index$k as Text,
index$j as Textarea,
index$j as Switch,
index$i as Text,
index$h as Textarea,
UniServiceJSBridge$1 as UniServiceJSBridge,
UniViewJSBridge$1 as UniViewJSBridge,
index$f as Video,
index$i as View,
index$e as WebView,
index$d as Video,
index$g as View,
index$c as WebView,
addInterceptor,
addPhoneContact,
arrayBufferToBase64,
......@@ -24962,7 +24970,7 @@ export {
openDocument,
openLocation,
pageScrollTo,
index$g as plugin,
index$e as plugin,
preloadPage,
previewImage,
reLaunch,
......
......@@ -176,6 +176,14 @@ const HOOKS = [
];
function parseApp(instance, parseAppOptions) {
const internalInstance = instance.$;
if (__VUE_PROD_DEVTOOLS__) {
// 定制 App 的 $children
Object.defineProperty(internalInstance.ctx, '$children', {
get() {
return getCurrentPages().map((page) => page.$vm);
},
});
}
const appOptions = {
globalData: (instance.$options && instance.$options.globalData) || {},
$vm: instance,
......
......@@ -192,6 +192,14 @@ const HOOKS = [
];
function parseApp(instance, parseAppOptions) {
const internalInstance = instance.$;
if (__VUE_PROD_DEVTOOLS__) {
// 定制 App 的 $children
Object.defineProperty(internalInstance.ctx, '$children', {
get() {
return getCurrentPages().map((page) => page.$vm);
},
});
}
const appOptions = {
globalData: (instance.$options && instance.$options.globalData) || {},
$vm: instance,
......
......@@ -42,6 +42,16 @@ export function parseApp(
parseAppOptions?: ParseAppOptions
) {
const internalInstance = instance.$
if (__VUE_PROD_DEVTOOLS__) {
// 定制 App 的 $children
Object.defineProperty((internalInstance as any).ctx, '$children', {
get() {
return getCurrentPages().map((page) => page.$vm)
},
})
}
const appOptions: MiniProgramAppOptions = {
globalData: (instance.$options && instance.$options.globalData) || {},
$vm: instance, // mp-alipay 组件 data 初始化比 onLaunch 早,提前挂载
......
......@@ -192,6 +192,14 @@ const HOOKS = [
];
function parseApp(instance, parseAppOptions) {
const internalInstance = instance.$;
if (__VUE_PROD_DEVTOOLS__) {
// 定制 App 的 $children
Object.defineProperty(internalInstance.ctx, '$children', {
get() {
return getCurrentPages().map((page) => page.$vm);
},
});
}
const appOptions = {
globalData: (instance.$options && instance.$options.globalData) || {},
$vm: instance,
......
......@@ -191,6 +191,14 @@ const HOOKS = [
];
function parseApp(instance, parseAppOptions) {
const internalInstance = instance.$;
if (__VUE_PROD_DEVTOOLS__) {
// 定制 App 的 $children
Object.defineProperty(internalInstance.ctx, '$children', {
get() {
return getCurrentPages().map((page) => page.$vm);
},
});
}
const appOptions = {
globalData: (instance.$options && instance.$options.globalData) || {},
$vm: instance,
......
......@@ -188,6 +188,14 @@ const HOOKS = [
];
function parseApp(instance, parseAppOptions) {
const internalInstance = instance.$;
if (__VUE_PROD_DEVTOOLS__) {
// 定制 App 的 $children
Object.defineProperty(internalInstance.ctx, '$children', {
get() {
return getCurrentPages().map((page) => page.$vm);
},
});
}
const appOptions = {
globalData: (instance.$options && instance.$options.globalData) || {},
$vm: instance,
......
......@@ -191,6 +191,14 @@ const HOOKS = [
];
function parseApp(instance, parseAppOptions) {
const internalInstance = instance.$;
if (__VUE_PROD_DEVTOOLS__) {
// 定制 App 的 $children
Object.defineProperty(internalInstance.ctx, '$children', {
get() {
return getCurrentPages().map((page) => page.$vm);
},
});
}
const appOptions = {
globalData: (instance.$options && instance.$options.globalData) || {},
$vm: instance,
......
......@@ -1607,13 +1607,94 @@ function checkRecursiveUpdates(seen, fn) {
}
}
let devtools;
let buffer = [];
let devtoolsNotInstalled = false;
function emit(event, ...args) {
if (devtools) {
devtools.emit(event, ...args);
}
else if (!devtoolsNotInstalled) {
buffer.push({ event, args });
}
}
function setDevtoolsHook(hook, target) {
var _a, _b;
devtools = hook;
if (devtools) {
devtools.enabled = true;
buffer.forEach(({ event, args }) => devtools.emit(event, ...args));
buffer = [];
}
else if (
// handle late devtools injection - only do this if we are in an actual
// browser environment to avoid the timer handle stalling test runner exit
// (#4815)
typeof window !== 'undefined' &&
// some envs mock window but not fully
// eslint-disable-next-line no-restricted-globals
window.HTMLElement &&
// also exclude jsdom
// eslint-disable-next-line no-restricted-globals
!((_b = (_a = window.navigator) === null || _a === void 0 ? void 0 : _a.userAgent) === null || _b === void 0 ? void 0 : _b.includes('jsdom'))) {
const replay = (target.__VUE_DEVTOOLS_HOOK_REPLAY__ =
target.__VUE_DEVTOOLS_HOOK_REPLAY__ || []);
replay.push((newHook) => {
setDevtoolsHook(newHook, target);
});
// clear buffer after 3s - the user probably doesn't have devtools installed
// at all, and keeping the buffer will cause memory leaks (#4738)
setTimeout(() => {
if (!devtools) {
target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
devtoolsNotInstalled = true;
buffer = [];
}
}, 3000);
}
else {
// non-browser env, assume not installed
devtoolsNotInstalled = true;
buffer = [];
}
}
function devtoolsInitApp(app, version) {
emit("app:init" /* DevtoolsHooks.APP_INIT */, app, version, {
Fragment,
Text,
Comment,
Static
});
}
const devtoolsComponentAdded = /*#__PURE__*/ createDevtoolsComponentHook("component:added" /* DevtoolsHooks.COMPONENT_ADDED */);
const devtoolsComponentUpdated =
/*#__PURE__*/ createDevtoolsComponentHook("component:updated" /* DevtoolsHooks.COMPONENT_UPDATED */);
const _devtoolsComponentRemoved = /*#__PURE__*/ createDevtoolsComponentHook("component:removed" /* DevtoolsHooks.COMPONENT_REMOVED */);
const devtoolsComponentRemoved = (component) => {
if (devtools &&
typeof devtools.cleanupBuffer === 'function' &&
// remove the component if it wasn't buffered
!devtools.cleanupBuffer(component)) {
_devtoolsComponentRemoved(component);
}
};
function createDevtoolsComponentHook(hook) {
return (component) => {
emit(hook, component.appContext.app, component.uid, component.parent ? component.parent.uid : undefined, component);
emit(hook, component.appContext.app, component.uid,
// fixed by xxxxxx
// 为 0 是 App,无 parent 是 Page 指向 App
component.uid === 0
? undefined
: component.parent
? component.parent.uid
: 0, component);
};
}
const devtoolsPerfStart = /*#__PURE__*/ createDevtoolsPerformanceHook("perf:start" /* DevtoolsHooks.PERFORMANCE_START */);
const devtoolsPerfEnd = /*#__PURE__*/ createDevtoolsPerformanceHook("perf:end" /* DevtoolsHooks.PERFORMANCE_END */);
function createDevtoolsPerformanceHook(hook) {
return (component, type, time) => {
emit(hook, component.appContext.app, component.uid, component, type, time);
};
}
function devtoolsComponentEmit(component, event, params) {
......@@ -1659,7 +1740,7 @@ function emit$1(instance, event, ...rawArgs) {
args = rawArgs.map(toNumber);
}
}
if ((process.env.NODE_ENV !== 'production') || false) {
if ((process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__) {
devtoolsComponentEmit(instance, event, args);
}
if ((process.env.NODE_ENV !== 'production')) {
......@@ -1813,7 +1894,7 @@ function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot // false on
setBlockTracking(1);
}
}
if ((process.env.NODE_ENV !== 'production') || false) {
if ((process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__) {
devtoolsComponentUpdated(ctx);
}
return res;
......@@ -2011,7 +2092,7 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
// pass undefined as the old value when it's changed for the first time
oldValue === INITIAL_WATCHER_VALUE
? undefined
: (isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE)
: isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE
? []
: oldValue,
onCleanup
......@@ -3662,6 +3743,44 @@ hydrate) {
};
}
/* eslint-disable no-restricted-globals */
let supported;
let perf;
function startMeasure(instance, type) {
if (instance.appContext.config.performance && isSupported()) {
perf.mark(`vue-${type}-${instance.uid}`);
}
if ((process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__) {
devtoolsPerfStart(instance, type, isSupported() ? perf.now() : Date.now());
}
}
function endMeasure(instance, type) {
if (instance.appContext.config.performance && isSupported()) {
const startTag = `vue-${type}-${instance.uid}`;
const endTag = startTag + `:end`;
perf.mark(endTag);
perf.measure(`<${formatComponentName(instance, instance.type)}> ${type}`, startTag, endTag);
perf.clearMarks(startTag);
perf.clearMarks(endTag);
}
if ((process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__) {
devtoolsPerfEnd(instance, type, isSupported() ? perf.now() : Date.now());
}
}
function isSupported() {
if (supported !== undefined) {
return supported;
}
if (typeof window !== 'undefined' && window.performance) {
supported = true;
perf = window.performance;
}
else {
supported = false;
}
return supported;
}
const queuePostRenderEffect = queuePostFlushCb;
const isTeleport = (type) => type.__isTeleport;
......@@ -3669,7 +3788,7 @@ const isTeleport = (type) => type.__isTeleport;
const Fragment = Symbol((process.env.NODE_ENV !== 'production') ? 'Fragment' : undefined);
const Text = Symbol((process.env.NODE_ENV !== 'production') ? 'Text' : undefined);
const Comment = Symbol((process.env.NODE_ENV !== 'production') ? 'Comment' : undefined);
Symbol((process.env.NODE_ENV !== 'production') ? 'Static' : undefined);
const Static = Symbol((process.env.NODE_ENV !== 'production') ? 'Static' : undefined);
let currentBlock = null;
// Whether we should be tracking dynamic child nodes inside a block.
// Only tracks when this value is > 0
......@@ -4203,7 +4322,7 @@ function handleSetupResult(instance, setupResult, isSSR) {
}
// setup returned bindings.
// assuming a render function compiled from template is present.
if ((process.env.NODE_ENV !== 'production') || false) {
if ((process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__) {
instance.devtoolsRawSetupState = setupResult;
}
instance.setupState = proxyRefs(setupResult);
......@@ -4958,8 +5077,15 @@ function mountComponent(initialVNode, options) {
}
if ((process.env.NODE_ENV !== 'production')) {
pushWarningContext(initialVNode);
startMeasure(instance, `mount`);
}
if ((process.env.NODE_ENV !== 'production')) {
startMeasure(instance, `init`);
}
setupComponent(instance);
if ((process.env.NODE_ENV !== 'production')) {
endMeasure(instance, `init`);
}
if (__VUE_OPTIONS_API__) {
// $children
if (options.parentComponent && instance.proxy) {
......@@ -4969,6 +5095,7 @@ function mountComponent(initialVNode, options) {
setupRenderEffect(instance);
if ((process.env.NODE_ENV !== 'production')) {
popWarningContext();
endMeasure(instance, `mount`);
}
return instance.proxy;
}
......@@ -5092,11 +5219,23 @@ function setupRenderEffect(instance) {
onBeforeUnmount(() => {
setRef$1(instance, true);
}, instance);
if ((process.env.NODE_ENV !== 'production')) {
startMeasure(instance, `patch`);
}
patch(instance, renderComponentRoot(instance));
if ((process.env.NODE_ENV !== 'production')) {
endMeasure(instance, `patch`);
}
if ((process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__) {
devtoolsComponentAdded(instance);
}
}
else {
// updateComponent
const { bu, u } = instance;
const { next, bu, u } = instance;
if ((process.env.NODE_ENV !== 'production')) {
pushWarningContext(next || instance.vnode);
}
// Disallow component effect recursion during pre-lifecycle hooks.
toggleRecurse(instance, false);
updateComponentPreRender();
......@@ -5105,11 +5244,23 @@ function setupRenderEffect(instance) {
invokeArrayFns(bu);
}
toggleRecurse(instance, true);
if ((process.env.NODE_ENV !== 'production')) {
startMeasure(instance, `patch`);
}
patch(instance, renderComponentRoot(instance));
if ((process.env.NODE_ENV !== 'production')) {
endMeasure(instance, `patch`);
}
// updated hook
if (u) {
queuePostRenderEffect$1(u);
}
if ((process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__) {
devtoolsComponentUpdated(instance);
}
if ((process.env.NODE_ENV !== 'production')) {
popWarningContext();
}
}
};
// create reactive effect for rendering
......@@ -5152,9 +5303,31 @@ function unmountComponent(instance) {
queuePostRenderEffect$1(() => {
instance.isUnmounted = true;
});
if ((process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__) {
devtoolsComponentRemoved(instance);
}
}
const oldCreateApp = createAppAPI();
function getTarget() {
if (typeof window !== 'undefined') {
return window;
}
if (typeof globalThis !== 'undefined') {
return globalThis;
}
if (typeof global !== 'undefined') {
return global;
}
if (typeof my !== 'undefined') {
return my;
}
}
function createVueApp(rootComponent, rootProps = null) {
const target = getTarget();
target.__VUE__ = true;
if ((process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__) {
setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__, target);
}
const app = oldCreateApp(rootComponent, rootProps);
const appContext = app._context;
initAppConfig(appContext.config);
......@@ -5179,6 +5352,9 @@ function createVueApp(rootComponent, rootProps = null) {
props: null
});
app._instance = instance.$;
if ((process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__) {
devtoolsInitApp(app, version);
}
instance.$app = app;
instance.$createComponent = createComponent;
instance.$destroyComponent = destroyComponent;
......
......@@ -1607,13 +1607,94 @@ function checkRecursiveUpdates(seen, fn) {
}
}
let devtools;
let buffer = [];
let devtoolsNotInstalled = false;
function emit(event, ...args) {
if (devtools) {
devtools.emit(event, ...args);
}
else if (!devtoolsNotInstalled) {
buffer.push({ event, args });
}
}
function setDevtoolsHook(hook, target) {
var _a, _b;
devtools = hook;
if (devtools) {
devtools.enabled = true;
buffer.forEach(({ event, args }) => devtools.emit(event, ...args));
buffer = [];
}
else if (
// handle late devtools injection - only do this if we are in an actual
// browser environment to avoid the timer handle stalling test runner exit
// (#4815)
typeof window !== 'undefined' &&
// some envs mock window but not fully
// eslint-disable-next-line no-restricted-globals
window.HTMLElement &&
// also exclude jsdom
// eslint-disable-next-line no-restricted-globals
!((_b = (_a = window.navigator) === null || _a === void 0 ? void 0 : _a.userAgent) === null || _b === void 0 ? void 0 : _b.includes('jsdom'))) {
const replay = (target.__VUE_DEVTOOLS_HOOK_REPLAY__ =
target.__VUE_DEVTOOLS_HOOK_REPLAY__ || []);
replay.push((newHook) => {
setDevtoolsHook(newHook, target);
});
// clear buffer after 3s - the user probably doesn't have devtools installed
// at all, and keeping the buffer will cause memory leaks (#4738)
setTimeout(() => {
if (!devtools) {
target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
devtoolsNotInstalled = true;
buffer = [];
}
}, 3000);
}
else {
// non-browser env, assume not installed
devtoolsNotInstalled = true;
buffer = [];
}
}
function devtoolsInitApp(app, version) {
emit("app:init" /* DevtoolsHooks.APP_INIT */, app, version, {
Fragment,
Text,
Comment,
Static
});
}
const devtoolsComponentAdded = /*#__PURE__*/ createDevtoolsComponentHook("component:added" /* DevtoolsHooks.COMPONENT_ADDED */);
const devtoolsComponentUpdated =
/*#__PURE__*/ createDevtoolsComponentHook("component:updated" /* DevtoolsHooks.COMPONENT_UPDATED */);
const _devtoolsComponentRemoved = /*#__PURE__*/ createDevtoolsComponentHook("component:removed" /* DevtoolsHooks.COMPONENT_REMOVED */);
const devtoolsComponentRemoved = (component) => {
if (devtools &&
typeof devtools.cleanupBuffer === 'function' &&
// remove the component if it wasn't buffered
!devtools.cleanupBuffer(component)) {
_devtoolsComponentRemoved(component);
}
};
function createDevtoolsComponentHook(hook) {
return (component) => {
emit(hook, component.appContext.app, component.uid, component.parent ? component.parent.uid : undefined, component);
emit(hook, component.appContext.app, component.uid,
// fixed by xxxxxx
// 为 0 是 App,无 parent 是 Page 指向 App
component.uid === 0
? undefined
: component.parent
? component.parent.uid
: 0, component);
};
}
const devtoolsPerfStart = /*#__PURE__*/ createDevtoolsPerformanceHook("perf:start" /* DevtoolsHooks.PERFORMANCE_START */);
const devtoolsPerfEnd = /*#__PURE__*/ createDevtoolsPerformanceHook("perf:end" /* DevtoolsHooks.PERFORMANCE_END */);
function createDevtoolsPerformanceHook(hook) {
return (component, type, time) => {
emit(hook, component.appContext.app, component.uid, component, type, time);
};
}
function devtoolsComponentEmit(component, event, params) {
......@@ -1659,7 +1740,7 @@ function emit$1(instance, event, ...rawArgs) {
args = rawArgs.map(toNumber);
}
}
if ((process.env.NODE_ENV !== 'production') || false) {
if ((process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__) {
devtoolsComponentEmit(instance, event, args);
}
if ((process.env.NODE_ENV !== 'production')) {
......@@ -1813,7 +1894,7 @@ function withCtx(fn, ctx = currentRenderingInstance, isNonScopedSlot // false on
setBlockTracking(1);
}
}
if ((process.env.NODE_ENV !== 'production') || false) {
if ((process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__) {
devtoolsComponentUpdated(ctx);
}
return res;
......@@ -2011,7 +2092,7 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
// pass undefined as the old value when it's changed for the first time
oldValue === INITIAL_WATCHER_VALUE
? undefined
: (isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE)
: isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE
? []
: oldValue,
onCleanup
......@@ -3662,6 +3743,44 @@ hydrate) {
};
}
/* eslint-disable no-restricted-globals */
let supported;
let perf;
function startMeasure(instance, type) {
if (instance.appContext.config.performance && isSupported()) {
perf.mark(`vue-${type}-${instance.uid}`);
}
if ((process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__) {
devtoolsPerfStart(instance, type, isSupported() ? perf.now() : Date.now());
}
}
function endMeasure(instance, type) {
if (instance.appContext.config.performance && isSupported()) {
const startTag = `vue-${type}-${instance.uid}`;
const endTag = startTag + `:end`;
perf.mark(endTag);
perf.measure(`<${formatComponentName(instance, instance.type)}> ${type}`, startTag, endTag);
perf.clearMarks(startTag);
perf.clearMarks(endTag);
}
if ((process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__) {
devtoolsPerfEnd(instance, type, isSupported() ? perf.now() : Date.now());
}
}
function isSupported() {
if (supported !== undefined) {
return supported;
}
if (typeof window !== 'undefined' && window.performance) {
supported = true;
perf = window.performance;
}
else {
supported = false;
}
return supported;
}
const queuePostRenderEffect = queuePostFlushCb;
const isTeleport = (type) => type.__isTeleport;
......@@ -3669,7 +3788,7 @@ const isTeleport = (type) => type.__isTeleport;
const Fragment = Symbol((process.env.NODE_ENV !== 'production') ? 'Fragment' : undefined);
const Text = Symbol((process.env.NODE_ENV !== 'production') ? 'Text' : undefined);
const Comment = Symbol((process.env.NODE_ENV !== 'production') ? 'Comment' : undefined);
Symbol((process.env.NODE_ENV !== 'production') ? 'Static' : undefined);
const Static = Symbol((process.env.NODE_ENV !== 'production') ? 'Static' : undefined);
let currentBlock = null;
// Whether we should be tracking dynamic child nodes inside a block.
// Only tracks when this value is > 0
......@@ -4203,7 +4322,7 @@ function handleSetupResult(instance, setupResult, isSSR) {
}
// setup returned bindings.
// assuming a render function compiled from template is present.
if ((process.env.NODE_ENV !== 'production') || false) {
if ((process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__) {
instance.devtoolsRawSetupState = setupResult;
}
instance.setupState = proxyRefs(setupResult);
......@@ -4958,8 +5077,15 @@ function mountComponent(initialVNode, options) {
}
if ((process.env.NODE_ENV !== 'production')) {
pushWarningContext(initialVNode);
startMeasure(instance, `mount`);
}
if ((process.env.NODE_ENV !== 'production')) {
startMeasure(instance, `init`);
}
setupComponent(instance);
if ((process.env.NODE_ENV !== 'production')) {
endMeasure(instance, `init`);
}
if (__VUE_OPTIONS_API__) {
// $children
if (options.parentComponent && instance.proxy) {
......@@ -4969,6 +5095,7 @@ function mountComponent(initialVNode, options) {
setupRenderEffect(instance);
if ((process.env.NODE_ENV !== 'production')) {
popWarningContext();
endMeasure(instance, `mount`);
}
return instance.proxy;
}
......@@ -5092,11 +5219,23 @@ function setupRenderEffect(instance) {
onBeforeUnmount(() => {
setRef(instance, true);
}, instance);
if ((process.env.NODE_ENV !== 'production')) {
startMeasure(instance, `patch`);
}
patch(instance, renderComponentRoot(instance));
if ((process.env.NODE_ENV !== 'production')) {
endMeasure(instance, `patch`);
}
if ((process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__) {
devtoolsComponentAdded(instance);
}
}
else {
// updateComponent
const { bu, u } = instance;
const { next, bu, u } = instance;
if ((process.env.NODE_ENV !== 'production')) {
pushWarningContext(next || instance.vnode);
}
// Disallow component effect recursion during pre-lifecycle hooks.
toggleRecurse(instance, false);
updateComponentPreRender();
......@@ -5105,11 +5244,23 @@ function setupRenderEffect(instance) {
invokeArrayFns(bu);
}
toggleRecurse(instance, true);
if ((process.env.NODE_ENV !== 'production')) {
startMeasure(instance, `patch`);
}
patch(instance, renderComponentRoot(instance));
if ((process.env.NODE_ENV !== 'production')) {
endMeasure(instance, `patch`);
}
// updated hook
if (u) {
queuePostRenderEffect$1(u);
}
if ((process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__) {
devtoolsComponentUpdated(instance);
}
if ((process.env.NODE_ENV !== 'production')) {
popWarningContext();
}
}
};
// create reactive effect for rendering
......@@ -5152,9 +5303,31 @@ function unmountComponent(instance) {
queuePostRenderEffect$1(() => {
instance.isUnmounted = true;
});
if ((process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__) {
devtoolsComponentRemoved(instance);
}
}
const oldCreateApp = createAppAPI();
function getTarget() {
if (typeof window !== 'undefined') {
return window;
}
if (typeof globalThis !== 'undefined') {
return globalThis;
}
if (typeof global !== 'undefined') {
return global;
}
if (typeof my !== 'undefined') {
return my;
}
}
function createVueApp(rootComponent, rootProps = null) {
const target = getTarget();
target.__VUE__ = true;
if ((process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__) {
setDevtoolsHook(target.__VUE_DEVTOOLS_GLOBAL_HOOK__, target);
}
const app = oldCreateApp(rootComponent, rootProps);
const appContext = app._context;
initAppConfig(appContext.config);
......@@ -5179,6 +5352,9 @@ function createVueApp(rootComponent, rootProps = null) {
props: null
});
app._instance = instance.$;
if ((process.env.NODE_ENV !== 'production') || __VUE_PROD_DEVTOOLS__) {
devtoolsInitApp(app, version);
}
instance.$app = app;
instance.$createComponent = createComponent;
instance.$destroyComponent = destroyComponent;
......
......@@ -182,6 +182,14 @@ const HOOKS = [
];
function parseApp(instance, parseAppOptions) {
const internalInstance = instance.$;
if (__VUE_PROD_DEVTOOLS__) {
// 定制 App 的 $children
Object.defineProperty(internalInstance.ctx, '$children', {
get() {
return getCurrentPages().map((page) => page.$vm);
},
});
}
const appOptions = {
globalData: (instance.$options && instance.$options.globalData) || {},
$vm: instance,
......
......@@ -188,6 +188,14 @@ const HOOKS = [
];
function parseApp(instance, parseAppOptions) {
const internalInstance = instance.$;
if (__VUE_PROD_DEVTOOLS__) {
// 定制 App 的 $children
Object.defineProperty(internalInstance.ctx, '$children', {
get() {
return getCurrentPages().map((page) => page.$vm);
},
});
}
const appOptions = {
globalData: (instance.$options && instance.$options.globalData) || {},
$vm: instance,
......
[
{
"input": {
"src/compiler/index.ts": "dist/uni.compiler.js"
},
"output": {
"format": "cjs"
},
"external": [
"@dcloudio/uni-cli-shared"
]
},
{
"input": {
"src/runtime.ts": "dist/runtime.es.js"
},
"compilerOptions": {
"declaration": false
}
}
]
\ No newline at end of file
function getTarget() {
// eslint-disable-next-line no-restricted-globals
if (typeof window !== 'undefined') {
// eslint-disable-next-line no-restricted-globals
return window;
}
if (typeof globalThis !== 'undefined') {
return globalThis;
}
if (typeof my !== 'undefined') {
return my;
}
}
class Socket {
constructor(host) {
this.sid = '';
this.ackTimeout = 5000;
this.closed = false;
this._ackTimer = 0;
this._onCallbacks = {};
this.host = host;
setTimeout(() => {
this.connect();
}, 50);
}
connect() {
// close: 1
// message: 4
// noop: 6
// open: 0
// ping: 2
// pong: 3
// upgrade: 5
this._socket = uni.connectSocket({
url: `ws://${this.host}/socket.io/?EIO=4&transport=websocket`,
complete() {
// NOOP
},
});
this._socket.onOpen((res) => {
// NOOP
});
this._socket.onMessage(({ data }) => {
if (typeof data !== 'string') {
return;
}
if (data[0] === '0') {
this._send('40');
const res = JSON.parse(data.slice(1));
this.sid = res.sid;
}
else if (data[0] + data[1] === '40') {
this.sid = JSON.parse(data.slice(2)).sid;
this._trigger('connect');
}
else if (data === '3') {
this._send('2');
}
else if (data === '2') {
this._send('3');
}
else {
const match = /\[.*\]/.exec(data);
if (!match)
return;
try {
const [event, args] = JSON.parse(match[0]);
this._trigger(event, args);
}
catch (err) {
console.error('Vue DevTools onMessage: ', err);
}
}
});
this._socket.onClose((res) => {
this.closed = true;
this._trigger('disconnect', res);
});
this._socket.onError((res) => {
console.error(res.errMsg);
});
}
on(event, callback) {
(this._onCallbacks[event] || (this._onCallbacks[event] = [])).push(callback);
}
emit(event, data) {
if (this.closed) {
return;
}
this._heartbeat();
// message: 4 + parser.EVENT: 2
this._send(`42${JSON.stringify(typeof data !== 'undefined' ? [event, data] : [event])}`);
}
disconnect() {
clearTimeout(this._ackTimer);
if (this._socket && !this.closed) {
// message: 4 + close: 1
this._send('41');
this._socket.close({});
}
}
_heartbeat() {
clearTimeout(this._ackTimer);
this._ackTimer = setTimeout(() => {
this._socket && this._socket.send({ data: '3' });
}, this.ackTimeout);
}
_send(data) {
this._socket && this._socket.send({ data });
}
_trigger(event, args) {
const callbacks = this._onCallbacks[event];
if (callbacks) {
callbacks.forEach((callback) => {
callback(args);
});
}
}
}
getTarget().__VUE_DEVTOOLS_SOCKET__ = new Socket(__VUE_DEVTOOLS_HOST__ + ':' + __VUE_DEVTOOLS_PORT__);
'use strict';
var fs = require('fs');
var path = require('path');
var uniCliShared = require('@dcloudio/uni-cli-shared');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
const uniVueDevtoolsPlugin = () => {
let copied = false;
return {
name: 'uni:vue-devtools',
config() {
return {
define: {
__VUE_PROD_DEVTOOLS__: process.env.__VUE_PROD_DEVTOOLS__ === 'true',
__VUE_DEVTOOLS_HOST__: JSON.stringify(process.env.__VUE_DEVTOOLS_HOST__ || 'localhost'),
__VUE_DEVTOOLS_PORT__: JSON.stringify(process.env.__VUE_DEVTOOLS_PORT__ || '8098'),
},
};
},
generateBundle() {
// 仅处理小程序
if (!uniCliShared.isMiniProgramPlatform()) {
return;
}
if (copied || process.env.__VUE_PROD_DEVTOOLS__ !== 'true') {
return;
}
copied = true;
const vueDevtoolsDir = path__default["default"].resolve(process.env.UNI_OUTPUT_DIR, 'vue-devtools');
if (!fs__default["default"].existsSync(vueDevtoolsDir)) {
fs__default["default"].mkdirSync(vueDevtoolsDir, { recursive: true });
}
fs__default["default"].copyFileSync(path__default["default"].resolve(__dirname, '../lib/mp/backend.js'), path__default["default"].resolve(vueDevtoolsDir, 'backend.js'));
fs__default["default"].copyFileSync(path__default["default"].resolve(__dirname, '../lib/mp/hook.js'), path__default["default"].resolve(vueDevtoolsDir, 'hook.js'));
},
};
};
var index = () => [
uniVueDevtoolsPlugin(),
uniCliShared.defineUniMainJsPlugin((opts) => {
let devtoolsCode = `;import '@dcloudio/uni-vue-devtools';`;
if (uniCliShared.isMiniProgramPlatform()) {
devtoolsCode += `require('./vue-devtools/hook.js');require('./vue-devtools/backend.js');`;
}
else {
const dir = process.env.UNI_PLATFORM === 'app' ? 'app' : 'web';
devtoolsCode += `import '@dcloudio/uni-vue-devtools/lib/${dir}/hook.js';import '@dcloudio/uni-vue-devtools/lib/${dir}/backend.js';`;
}
return {
name: 'uni:vue-devtools-main-js',
enforce: 'post',
transform(code, id) {
if (process.env.__VUE_PROD_DEVTOOLS__ !== 'true') {
return;
}
if (!opts.filter(id)) {
return;
}
return {
code: devtoolsCode + code,
map: null,
};
},
};
}),
];
module.exports = index;
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
{
"name": "@dcloudio/uni-vue-devtools",
"version": "3.0.0-alpha-3060920221111002",
"description": "uni-vue-devtools",
"main": "dist/runtime.es.js",
"files": [
"dist"
],
"repository": {
"type": "git",
"url": "git+https://github.com/dcloudio/uni-app.git",
"directory": "packages/uni-vue-devtools"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"license": "Apache-2.0",
"uni-app": {
"name": "vue-devtools",
"title": "Vue Devtools",
"main": "dist/uni.compiler.js"
},
"dependencies": {
"@dcloudio/uni-cli-shared": "3.0.0-alpha-3060920221111002"
}
}
\ No newline at end of file
import type { Plugin } from 'vite'
import fs from 'fs'
import path from 'path'
import {
defineUniMainJsPlugin,
isMiniProgramPlatform,
} from '@dcloudio/uni-cli-shared'
const uniVueDevtoolsPlugin = (): Plugin => {
let copied = false
return {
name: 'uni:vue-devtools',
config() {
return {
define: {
__VUE_PROD_DEVTOOLS__: process.env.__VUE_PROD_DEVTOOLS__ === 'true',
__VUE_DEVTOOLS_HOST__: JSON.stringify(
process.env.__VUE_DEVTOOLS_HOST__ || 'localhost'
),
__VUE_DEVTOOLS_PORT__: JSON.stringify(
process.env.__VUE_DEVTOOLS_PORT__ || '8098'
),
},
}
},
generateBundle() {
// 仅处理小程序
if (!isMiniProgramPlatform()) {
return
}
if (copied || process.env.__VUE_PROD_DEVTOOLS__ !== 'true') {
return
}
copied = true
const vueDevtoolsDir = path.resolve(
process.env.UNI_OUTPUT_DIR!,
'vue-devtools'
)
if (!fs.existsSync(vueDevtoolsDir)) {
fs.mkdirSync(vueDevtoolsDir, { recursive: true })
}
fs.copyFileSync(
path.resolve(__dirname, '../lib/mp/backend.js'),
path.resolve(vueDevtoolsDir, 'backend.js')
)
fs.copyFileSync(
path.resolve(__dirname, '../lib/mp/hook.js'),
path.resolve(vueDevtoolsDir, 'hook.js')
)
},
}
}
export default () => [
uniVueDevtoolsPlugin(),
defineUniMainJsPlugin((opts) => {
let devtoolsCode = `;import '@dcloudio/uni-vue-devtools';`
if (isMiniProgramPlatform()) {
devtoolsCode += `require('./vue-devtools/hook.js');require('./vue-devtools/backend.js');`
} else {
const dir = process.env.UNI_PLATFORM === 'app' ? 'app' : 'web'
devtoolsCode += `import '@dcloudio/uni-vue-devtools/lib/${dir}/hook.js';import '@dcloudio/uni-vue-devtools/lib/${dir}/backend.js';`
}
return {
name: 'uni:vue-devtools-main-js',
enforce: 'post',
transform(code: string, id: string) {
if (process.env.__VUE_PROD_DEVTOOLS__ !== 'true') {
return
}
if (!opts.filter(id)) {
return
}
return {
code: devtoolsCode + code,
map: null,
}
},
}
}),
]
declare const __VUE_DEVTOOLS_HOST__: string
declare const __VUE_DEVTOOLS_PORT__: string
type Callback = (data: unknown) => void
function getTarget() {
// eslint-disable-next-line no-restricted-globals
if (typeof window !== 'undefined') {
// eslint-disable-next-line no-restricted-globals
return window
}
if (typeof globalThis !== 'undefined') {
return globalThis
}
if (typeof my !== 'undefined') {
return my
}
}
class Socket {
host: string
sid: string = ''
ackTimeout: number = 5000
closed: boolean = false
private _socket?: UniApp.SocketTask
private _ackTimer: number = 0
private _onCallbacks: Record<string, Callback[]> = {}
constructor(host: string) {
this.host = host
setTimeout(() => {
this.connect()
}, 50)
}
connect() {
// close: 1
// message: 4
// noop: 6
// open: 0
// ping: 2
// pong: 3
// upgrade: 5
this._socket = uni.connectSocket({
url: `ws://${this.host}/socket.io/?EIO=4&transport=websocket`,
complete() {
// NOOP
},
})
this._socket.onOpen((res) => {
// NOOP
})
this._socket.onMessage(({ data }) => {
if (typeof data !== 'string') {
return
}
if (data[0] === '0') {
this._send('40')
const res = JSON.parse(data.slice(1))
this.sid = res.sid
} else if (data[0] + data[1] === '40') {
this.sid = JSON.parse(data.slice(2)).sid
this._trigger('connect')
} else if (data === '3') {
this._send('2')
} else if (data === '2') {
this._send('3')
} else {
const match = /\[.*\]/.exec(data)
if (!match) return
try {
const [event, args] = JSON.parse(match[0])
this._trigger(event, args)
} catch (err) {
console.error('Vue DevTools onMessage: ', err)
}
}
})
this._socket.onClose((res) => {
this.closed = true
this._trigger('disconnect', res)
})
this._socket.onError((res) => {
console.error(res.errMsg)
})
}
on(event: string, callback: Callback) {
;(this._onCallbacks[event] || (this._onCallbacks[event] = [])).push(
callback
)
}
emit(event: string, data?: unknown) {
if (this.closed) {
return
}
this._heartbeat()
// message: 4 + parser.EVENT: 2
this._send(
`42${JSON.stringify(
typeof data !== 'undefined' ? [event, data] : [event]
)}`
)
}
disconnect() {
clearTimeout(this._ackTimer)
if (this._socket && !this.closed) {
// message: 4 + close: 1
this._send('41')
this._socket.close({})
}
}
_heartbeat() {
clearTimeout(this._ackTimer)
this._ackTimer = setTimeout(() => {
this._socket && this._socket.send({ data: '3' })
}, this.ackTimeout) as unknown as number
}
_send(data: string) {
this._socket && this._socket.send({ data })
}
_trigger(event: string, args?: unknown) {
const callbacks = this._onCallbacks[event]
if (callbacks) {
callbacks.forEach((callback) => {
callback(args)
})
}
}
}
;(getTarget() as any).__VUE_DEVTOOLS_SOCKET__ = new Socket(
__VUE_DEVTOOLS_HOST__ + ':' + __VUE_DEVTOOLS_PORT__
)
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"paths": {
"@dcloudio/*": ["packages/*/src"]
}
},
"include": [
"src",
"../global.d.ts",
"../shims-node.d.ts",
"../shims-uni-app.d.ts"
]
}
......@@ -8,7 +8,6 @@ export function createDefine(
): UserConfig['define'] {
return extend(
{
__VUE_PROD_DEVTOOLS__: false,
__VUE_I18N_FULL_INSTALL__: true,
__VUE_I18N_LEGACY_API__: true,
__VUE_I18N_PROD_DEVTOOLS__: false,
......
......@@ -49,6 +49,7 @@ importers:
rollup-plugin-vue: ^6.0.0
semver: ^7.3.5
simple-git-hooks: ^2.8.0
terser: ^5.4.0
ts-jest: ^27.0.3
typescript: ^4.8.4
vite: 3.2.3
......@@ -101,9 +102,10 @@ importers:
rollup-plugin-vue: 6.0.0_@vue+compiler-sfc@3.2.45
semver: 7.3.8
simple-git-hooks: 2.8.1
terser: 5.15.1
ts-jest: 27.1.5_lyiamwgdmh3b2ykplbjttelceq
typescript: 4.8.4
vite: 3.2.3_@types+node@17.0.45
vite: 3.2.3_vzrngsk7qqxnkez5xb3b5vihai
vue: 3.2.45
vue-router: 4.1.6_vue@3.2.45
yorkie: 2.0.0
......@@ -829,6 +831,12 @@ importers:
'@dcloudio/uni-mp-vue': link:../uni-mp-vue
'@dcloudio/uni-shared': link:../uni-shared
packages/uni-vue-devtools:
specifiers:
'@dcloudio/uni-cli-shared': 3.0.0-alpha-3060920221111002
dependencies:
'@dcloudio/uni-cli-shared': link:../uni-cli-shared
packages/uts:
specifiers:
'@dcloudio/uts-darwin-arm64': 3.0.0-alpha-3060920221111002
......@@ -3064,7 +3072,7 @@ packages:
'@babel/core': 7.19.6
'@babel/plugin-transform-typescript': 7.20.0_@babel+core@7.19.6
'@vue/babel-plugin-jsx': 1.1.1_@babel+core@7.19.6
vite: 3.2.3_@types+node@17.0.45
vite: 3.2.3_vzrngsk7qqxnkez5xb3b5vihai
vue: 3.2.45
transitivePeerDependencies:
- supports-color
......@@ -3076,7 +3084,7 @@ packages:
vite: ^3.0.0
vue: ^3.2.25
dependencies:
vite: 3.2.3_@types+node@17.0.45
vite: 3.2.3_vzrngsk7qqxnkez5xb3b5vihai
vue: 3.2.45
/@vue/babel-helper-vue-transform-on/1.0.2:
......@@ -8295,7 +8303,7 @@ packages:
fsevents: 2.3.2
dev: true
/vite/3.2.3_@types+node@17.0.45:
/vite/3.2.3_terser@5.15.1:
resolution: {integrity: sha512-h8jl1TZ76eGs3o2dIBSsvXDLb1m/Ec1iej8ZMdz+PsaFUsftZeWe2CZOI3qogEsMNaywc17gu0q6cQDzh/weCQ==}
engines: {node: ^14.18.0 || >=16.0.0}
hasBin: true
......@@ -8320,15 +8328,15 @@ packages:
terser:
optional: true
dependencies:
'@types/node': 17.0.45
esbuild: 0.15.12
postcss: 8.4.18
resolve: 1.22.1
rollup: 2.79.1
terser: 5.15.1
optionalDependencies:
fsevents: 2.3.2
/vite/3.2.3_terser@5.15.1:
/vite/3.2.3_vzrngsk7qqxnkez5xb3b5vihai:
resolution: {integrity: sha512-h8jl1TZ76eGs3o2dIBSsvXDLb1m/Ec1iej8ZMdz+PsaFUsftZeWe2CZOI3qogEsMNaywc17gu0q6cQDzh/weCQ==}
engines: {node: ^14.18.0 || >=16.0.0}
hasBin: true
......@@ -8353,6 +8361,7 @@ packages:
terser:
optional: true
dependencies:
'@types/node': 17.0.45
esbuild: 0.15.12
postcss: 8.4.18
resolve: 1.22.1
......
......@@ -34,6 +34,7 @@ const priority = {
'uni-cloud': 10,
'uni-automator': 10,
'uni-stacktracey': 8,
'uni-vue-devtools': 6,
'size-check': 0,
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册