提交 8dece5ed 编写于 作者: Q qiang

Merge branch 'next' of github.com:dcloudio/uni-app into next

# Conflicts:
#	packages/uni-stat/dist/uni-stat.cjs.js
#	packages/uni-stat/dist/uni-stat.es.js
......@@ -83,7 +83,7 @@
"semver": "^7.3.5",
"ts-jest": "^27.0.3",
"typescript": "^4.5.3",
"vite": "^2.7.6",
"vite": "^2.7.7",
"vue": "3.2.26",
"vue-router": "^4.0.12",
"yorkie": "^2.0.0"
......
......@@ -21,6 +21,6 @@
"compression": "^1.7.4",
"cypress": "^7.3.0",
"serve-static": "^1.14.1",
"vite": "^2.7.6"
"vite": "^2.7.7"
}
}
......@@ -17216,6 +17216,14 @@ var serviceContext = (function (vue) {
}
}
const downgrade = plus.os.name === 'Android' && parseInt(plus.os.version) < 6;
const ANI_SHOW = downgrade ? 'slide-in-right' : 'pop-in';
const ANI_DURATION = 300;
const ANI_CLOSE = downgrade ? 'slide-out-right' : 'pop-out';
const VIEW_WEBVIEW_PATH = '_www/__uniappview.html';
const WEBVIEW_ID_PREFIX = 'webviewId';
const SDK_UNI_MP_NATIVE_EVENT = 'uniMPNativeEvent';
function initGlobalEvent() {
const plusGlobalEvent = plus.globalEvent;
const weexGlobalEvent = weex.requireModule('globalEvent');
......@@ -17254,6 +17262,11 @@ var serviceContext = (function (vue) {
});
}
});
weexGlobalEvent.addEventListener(SDK_UNI_MP_NATIVE_EVENT, function (res) {
if (res && res.event) {
emit(SDK_UNI_MP_NATIVE_EVENT + '.' + res.event, res.data);
}
});
plusGlobalEvent.addEventListener('plusMessage', subscribePlusMessage);
// nvue webview post message
plusGlobalEvent.addEventListener('WebviewPostMessage', subscribePlusMessage);
......@@ -17484,13 +17497,6 @@ var serviceContext = (function (vue) {
});
}
const downgrade = plus.os.name === 'Android' && parseInt(plus.os.version) < 6;
const ANI_SHOW = downgrade ? 'slide-in-right' : 'pop-in';
const ANI_DURATION = 300;
const ANI_CLOSE = downgrade ? 'slide-out-right' : 'pop-out';
const VIEW_WEBVIEW_PATH = '_www/__uniappview.html';
const WEBVIEW_ID_PREFIX = 'webviewId';
function initNVue(webviewStyle, routeMeta, path) {
if (path && routeMeta.isNVue) {
webviewStyle.uniNView = {
......@@ -19160,7 +19166,11 @@ var serviceContext = (function (vue) {
}
resolve();
});
});
});
function onHostEventReceive(name, fn) {
UniServiceJSBridge.on(SDK_UNI_MP_NATIVE_EVENT + '.' + name, fn);
}
const onNativeEventReceive = onHostEventReceive;
const EventType = {
load: 'load',
......@@ -19929,6 +19939,8 @@ var serviceContext = (function (vue) {
restoreGlobal: restoreGlobal,
sendHostEvent: sendHostEvent,
navigateToMiniProgram: navigateToMiniProgram,
onHostEventReceive: onHostEventReceive,
onNativeEventReceive: onNativeEventReceive,
createRewardedVideoAd: createRewardedVideoAd,
createFullScreenVideoAd: createFullScreenVideoAd,
createInterstitialAd: createInterstitialAd,
......
因为 它太大了无法显示 source diff 。你可以改为 查看blob
import { defineAsyncApi } from '@dcloudio/uni-api'
import { sendNativeEvent } from './requireNativePlugin'
import { SDK_UNI_MP_NATIVE_EVENT } from '../../constants'
export const sendHostEvent = sendNativeEvent
......@@ -26,3 +27,12 @@ export const navigateToMiniProgram =
})
}
)
export function onHostEventReceive(
name: string,
fn: (...args: unknown[]) => void
) {
UniServiceJSBridge.on(SDK_UNI_MP_NATIVE_EVENT + '.' + name, fn)
}
export const onNativeEventReceive = onHostEventReceive
......@@ -8,3 +8,5 @@ export const ANI_CLOSE = downgrade ? 'slide-out-right' : 'pop-out'
export const VIEW_WEBVIEW_PATH = '_www/__uniappview.html'
export const WEBVIEW_ID_PREFIX = 'webviewId'
export const SDK_UNI_MP_NATIVE_EVENT = 'uniMPNativeEvent'
......@@ -5,6 +5,7 @@ import {
ON_THEME_CHANGE,
ON_KEYBOARD_HEIGHT_CHANGE,
} from '@dcloudio/uni-shared'
import { SDK_UNI_MP_NATIVE_EVENT } from '../../constants'
import {
EVENT_BACKBUTTON,
backbuttonListener,
......@@ -62,6 +63,15 @@ export function initGlobalEvent() {
}
)
weexGlobalEvent.addEventListener(
SDK_UNI_MP_NATIVE_EVENT,
function (res: { event: string; data: unknown }) {
if (res && res.event) {
emit(SDK_UNI_MP_NATIVE_EVENT + '.' + res.event, res.data)
}
}
)
plusGlobalEvent.addEventListener('plusMessage', subscribePlusMessage)
// nvue webview post message
plusGlobalEvent.addEventListener('WebviewPostMessage', subscribePlusMessage)
......
......@@ -232,3 +232,15 @@ export function setHolderText(holder: Element, clazz: string, text: string) {
// 添加文本节点
holder.appendChild(document.createTextNode(text))
}
const vModelNames = ['value', 'modelValue']
export function initVModel(props: Record<string, any>) {
vModelNames.forEach((name) => {
if (hasOwn(props, name)) {
const event = 'onUpdate:' + name
if (!hasOwn(props, event)) {
props[event] = (v: string) => (props[name] = v)
}
}
})
}
import '@dcloudio/uni-components/style/input.css'
import { Input } from '@dcloudio/uni-components'
import { UniNodeJSON } from '@dcloudio/uni-shared'
import { UniComponent } from './UniComponent'
import { initVModel, UniComponent } from './UniComponent'
export class UniInput extends UniComponent {
constructor(
......@@ -12,4 +12,8 @@ export class UniInput extends UniComponent {
) {
super(id, 'uni-input', Input, parentNodeId, refNodeId, nodeJson)
}
init(nodeJson: Partial<UniNodeJSON>): void {
super.init(nodeJson)
initVModel(this.$props)
}
}
import '@dcloudio/uni-components/style/textarea.css'
import { Textarea } from '@dcloudio/uni-components'
import { UniNodeJSON } from '@dcloudio/uni-shared'
import { UniComponent } from './UniComponent'
import { initVModel, UniComponent } from './UniComponent'
export class UniTextarea extends UniComponent {
constructor(
......@@ -12,4 +12,9 @@ export class UniTextarea extends UniComponent {
) {
super(id, 'uni-textarea', Textarea, parentNodeId, refNodeId, nodeJson)
}
init(nodeJson: Partial<UniNodeJSON>): void {
super.init(nodeJson)
initVModel(this.$props)
}
}
......@@ -8,7 +8,7 @@ const hbxPlugins = {
less: 'compile-less/node_modules/less',
sass: 'compile-dart-sass/node_modules/sass',
stylus: 'compile-stylus/node_modules/stylus',
// pug: 'compile-pug-cli/node_modules/pug',
pug: 'compile-pug-cli/node_modules/pug',
} as const
export function initModuleAlias() {
......
......@@ -35,6 +35,10 @@ export function hasJsonFile(filename: string) {
)
}
export function getComponentJsonFilenames() {
return [...jsonComponentsCache.keys()]
}
export function findJsonFile(filename: string) {
if (filename === 'app') {
return appJsonCache
......
......@@ -6,7 +6,7 @@ import {
uniViteInjectPlugin,
UNI_EASYCOM_EXCLUDE,
} from '@dcloudio/uni-cli-shared'
import { uniH5PLugin } from './plugin'
import { uniH5Plugin } from './plugin'
import { uniCssPlugin } from './plugins/css'
import { uniEasycomPlugin } from './plugins/easycom'
import { uniInjectPlugin } from './plugins/inject'
......@@ -35,5 +35,5 @@ export default [
uniSSRPlugin(),
uniSetupPlugin(),
uniRenderjsPlugin(),
uniH5PLugin(),
uniH5Plugin(),
]
......@@ -10,7 +10,7 @@ import { createUni } from './uni'
import { createConfig } from './config'
import { isString } from '@vue/shared'
export function uniH5PLugin(): UniVitePlugin {
export function uniH5Plugin(): UniVitePlugin {
const configOptions: {
resolvedConfig: ResolvedConfig | null
} = {
......
......@@ -122,6 +122,12 @@ class EventChannel {
}
}
const MINI_PROGRAM_PAGE_RUNTIME_HOOKS = {
onPageScroll: 1,
onShareAppMessage: 1 << 1,
onShareTimeline: 1 << 2,
};
const eventChannels = {};
const eventChannelStack = [];
function getEventChannel(id) {
......@@ -236,7 +242,7 @@ function callHook(name, args) {
return hooks && invokeArrayFns(hooks, args);
}
const PAGE_HOOKS = [
const PAGE_INIT_HOOKS = [
ON_LOAD,
ON_SHOW,
ON_HIDE,
......@@ -283,6 +289,17 @@ function initHooks(mpOptions, hooks, excludes = EXCLUDE_HOOKS) {
}
function initUnknownHooks(mpOptions, vueOptions, excludes = EXCLUDE_HOOKS) {
findHooks(vueOptions).forEach((hook) => initHook(mpOptions, hook, excludes));
}
function initRuntimeHooks(mpOptions, runtimeHooks) {
if (!runtimeHooks) {
return;
}
const hooks = Object.keys(MINI_PROGRAM_PAGE_RUNTIME_HOOKS);
hooks.forEach((hook) => {
if (runtimeHooks & MINI_PROGRAM_PAGE_RUNTIME_HOOKS[hook]) {
initHook(mpOptions, hook, []);
}
});
}
my.appLaunchHooks = [];
......@@ -878,8 +895,9 @@ function initCreatePage() {
if (__VUE_OPTIONS_API__) {
pageOptions.data = initData();
}
initHooks(pageOptions, PAGE_HOOKS);
initHooks(pageOptions, PAGE_INIT_HOOKS);
initUnknownHooks(pageOptions, vueOptions);
initRuntimeHooks(pageOptions, vueOptions.__runtimeHooks);
initWxsCallMethods(pageOptions, vueOptions.wxsCallMethods);
return Page(pageOptions);
};
......
import { ComponentOptions } from 'vue'
import {
PAGE_HOOKS,
PAGE_INIT_HOOKS,
initData,
initHooks,
initUnknownHooks,
$destroyComponent,
initWxsCallMethods,
initRuntimeHooks,
} from '@dcloudio/uni-mp-core'
import {
......@@ -65,9 +66,9 @@ export function initCreatePage() {
if (__VUE_OPTIONS_API__) {
pageOptions.data = initData(vueOptions)
}
initHooks(pageOptions, PAGE_HOOKS)
initHooks(pageOptions, PAGE_INIT_HOOKS)
initUnknownHooks(pageOptions, vueOptions)
initRuntimeHooks(pageOptions, vueOptions.__runtimeHooks)
initWxsCallMethods(
pageOptions as WechatMiniprogram.Component.MethodOption,
vueOptions.wxsCallMethods
......
......@@ -190,6 +190,12 @@ class EventChannel {
}
}
const MINI_PROGRAM_PAGE_RUNTIME_HOOKS = {
onPageScroll: 1,
onShareAppMessage: 1 << 1,
onShareTimeline: 1 << 2,
};
const eventChannels = {};
const eventChannelStack = [];
function getEventChannel(id) {
......@@ -299,7 +305,7 @@ function callHook(name, args) {
return hooks && invokeArrayFns(hooks, args);
}
const PAGE_HOOKS = [
const PAGE_INIT_HOOKS = [
ON_LOAD,
ON_SHOW,
ON_HIDE,
......@@ -346,6 +352,17 @@ function initHooks(mpOptions, hooks, excludes = EXCLUDE_HOOKS) {
}
function initUnknownHooks(mpOptions, vueOptions, excludes = EXCLUDE_HOOKS) {
findHooks(vueOptions).forEach((hook) => initHook$1(mpOptions, hook, excludes));
}
function initRuntimeHooks(mpOptions, runtimeHooks) {
if (!runtimeHooks) {
return;
}
const hooks = Object.keys(MINI_PROGRAM_PAGE_RUNTIME_HOOKS);
hooks.forEach((hook) => {
if (runtimeHooks & MINI_PROGRAM_PAGE_RUNTIME_HOOKS[hook]) {
initHook$1(mpOptions, hook, []);
}
});
}
swan.appLaunchHooks = [];
......@@ -891,8 +908,9 @@ function parsePage(vueOptions, parseOptions) {
};
return this.$vm && this.$vm.$callHook(ON_LOAD, query);
};
initHooks(methods, PAGE_HOOKS);
initHooks(methods, PAGE_INIT_HOOKS);
initUnknownHooks(methods, vueOptions);
initRuntimeHooks(methods, vueOptions.__runtimeHooks);
parse && parse(miniProgramPageOptions, { handleLink });
return miniProgramPageOptions;
}
......
......@@ -24,9 +24,10 @@ export {
} from './runtime/componentOptions'
export { initProps } from './runtime/componentProps'
export {
PAGE_HOOKS,
initHooks,
initUnknownHooks,
initRuntimeHooks,
PAGE_INIT_HOOKS,
} from './runtime/componentHooks'
export { initMocks, initComponentInstance } from './runtime/componentInstance'
export { $createComponent, $destroyComponent } from './runtime/component'
......
import {
MINI_PROGRAM_PAGE_RUNTIME_HOOKS,
ON_ADD_TO_FAVORITES,
ON_HIDE,
ON_LOAD,
......@@ -18,7 +19,7 @@ import { MiniProgramAppOptions } from '../index'
import { CustomAppInstanceProperty } from './app'
import { CustomComponentInstanceProperty } from './component'
export const PAGE_HOOKS = [
export const PAGE_INIT_HOOKS = [
ON_LOAD,
ON_SHOW,
ON_HIDE,
......@@ -95,3 +96,20 @@ export function initUnknownHooks(
) {
findHooks(vueOptions).forEach((hook) => initHook(mpOptions, hook, excludes))
}
export function initRuntimeHooks(
mpOptions: MiniProgramAppOptions | WechatMiniprogram.Component.MethodOption,
runtimeHooks?: number
) {
if (!runtimeHooks) {
return
}
const hooks = Object.keys(
MINI_PROGRAM_PAGE_RUNTIME_HOOKS
) as (keyof typeof MINI_PROGRAM_PAGE_RUNTIME_HOOKS)[]
hooks.forEach((hook) => {
if (runtimeHooks & MINI_PROGRAM_PAGE_RUNTIME_HOOKS[hook]) {
initHook(mpOptions, hook, [])
}
})
}
......@@ -7,7 +7,12 @@ import {
parseComponent,
CustomComponentInstanceProperty,
} from './component'
import { PAGE_HOOKS, initHooks, initUnknownHooks } from './componentHooks'
import {
PAGE_INIT_HOOKS,
initHooks,
initUnknownHooks,
initRuntimeHooks,
} from './componentHooks'
import { initPageProps } from './componentProps'
function parsePage(
......@@ -43,9 +48,9 @@ function parsePage(
return this.$vm && this.$vm.$callHook(ON_LOAD, query)
}
initHooks(methods, PAGE_HOOKS)
initHooks(methods, PAGE_INIT_HOOKS)
initUnknownHooks(methods, vueOptions)
initRuntimeHooks(methods, vueOptions.__runtimeHooks)
parse && parse(miniProgramPageOptions, { handleLink })
return miniProgramPageOptions
......
......@@ -185,6 +185,12 @@ class EventChannel {
}
}
const MINI_PROGRAM_PAGE_RUNTIME_HOOKS = {
onPageScroll: 1,
onShareAppMessage: 1 << 1,
onShareTimeline: 1 << 2,
};
const eventChannels = {};
const eventChannelStack = [];
function getEventChannel(id) {
......@@ -294,7 +300,7 @@ function callHook(name, args) {
return hooks && invokeArrayFns(hooks, args);
}
const PAGE_HOOKS = [
const PAGE_INIT_HOOKS = [
ON_LOAD,
ON_SHOW,
ON_HIDE,
......@@ -341,6 +347,17 @@ function initHooks(mpOptions, hooks, excludes = EXCLUDE_HOOKS) {
}
function initUnknownHooks(mpOptions, vueOptions, excludes = EXCLUDE_HOOKS) {
findHooks(vueOptions).forEach((hook) => initHook$1(mpOptions, hook, excludes));
}
function initRuntimeHooks(mpOptions, runtimeHooks) {
if (!runtimeHooks) {
return;
}
const hooks = Object.keys(MINI_PROGRAM_PAGE_RUNTIME_HOOKS);
hooks.forEach((hook) => {
if (runtimeHooks & MINI_PROGRAM_PAGE_RUNTIME_HOOKS[hook]) {
initHook$1(mpOptions, hook, []);
}
});
}
ks.appLaunchHooks = [];
......@@ -875,8 +892,9 @@ function parsePage(vueOptions, parseOptions) {
};
return this.$vm && this.$vm.$callHook(ON_LOAD, query);
};
initHooks(methods, PAGE_HOOKS);
initHooks(methods, PAGE_INIT_HOOKS);
initUnknownHooks(methods, vueOptions);
initRuntimeHooks(methods, vueOptions.__runtimeHooks);
parse && parse(miniProgramPageOptions, { handleLink });
return miniProgramPageOptions;
}
......
......@@ -185,6 +185,12 @@ class EventChannel {
}
}
const MINI_PROGRAM_PAGE_RUNTIME_HOOKS = {
onPageScroll: 1,
onShareAppMessage: 1 << 1,
onShareTimeline: 1 << 2,
};
const eventChannels = {};
const eventChannelStack = [];
function getEventChannel(id) {
......@@ -290,7 +296,7 @@ function callHook(name, args) {
return hooks && invokeArrayFns(hooks, args);
}
const PAGE_HOOKS = [
const PAGE_INIT_HOOKS = [
ON_LOAD,
ON_SHOW,
ON_HIDE,
......@@ -340,6 +346,17 @@ function initHooks(mpOptions, hooks, excludes = EXCLUDE_HOOKS) {
}
function initUnknownHooks(mpOptions, vueOptions, excludes = EXCLUDE_HOOKS) {
findHooks(vueOptions).forEach((hook) => initHook$1(mpOptions, hook, excludes));
}
function initRuntimeHooks(mpOptions, runtimeHooks) {
if (!runtimeHooks) {
return;
}
const hooks = Object.keys(MINI_PROGRAM_PAGE_RUNTIME_HOOKS);
hooks.forEach((hook) => {
if (runtimeHooks & MINI_PROGRAM_PAGE_RUNTIME_HOOKS[hook]) {
initHook$1(mpOptions, hook, []);
}
});
}
tt.appLaunchHooks = [];
......@@ -848,8 +865,9 @@ function parsePage(vueOptions, parseOptions) {
};
return this.$vm && this.$vm.$callHook(ON_LOAD, query);
};
initHooks(methods, PAGE_HOOKS);
initHooks(methods, PAGE_INIT_HOOKS);
initUnknownHooks(methods, vueOptions);
initRuntimeHooks(methods, vueOptions.__runtimeHooks);
parse && parse(miniProgramPageOptions, { handleLink });
return miniProgramPageOptions;
}
......
......@@ -185,6 +185,12 @@ class EventChannel {
}
}
const MINI_PROGRAM_PAGE_RUNTIME_HOOKS = {
onPageScroll: 1,
onShareAppMessage: 1 << 1,
onShareTimeline: 1 << 2,
};
const eventChannels = {};
const eventChannelStack = [];
function getEventChannel(id) {
......@@ -290,7 +296,7 @@ function callHook(name, args) {
return hooks && invokeArrayFns(hooks, args);
}
const PAGE_HOOKS = [
const PAGE_INIT_HOOKS = [
ON_LOAD,
ON_SHOW,
ON_HIDE,
......@@ -337,6 +343,17 @@ function initHooks(mpOptions, hooks, excludes = EXCLUDE_HOOKS) {
}
function initUnknownHooks(mpOptions, vueOptions, excludes = EXCLUDE_HOOKS) {
findHooks(vueOptions).forEach((hook) => initHook$1(mpOptions, hook, excludes));
}
function initRuntimeHooks(mpOptions, runtimeHooks) {
if (!runtimeHooks) {
return;
}
const hooks = Object.keys(MINI_PROGRAM_PAGE_RUNTIME_HOOKS);
hooks.forEach((hook) => {
if (runtimeHooks & MINI_PROGRAM_PAGE_RUNTIME_HOOKS[hook]) {
initHook$1(mpOptions, hook, []);
}
});
}
qq.appLaunchHooks = [];
......@@ -837,8 +854,9 @@ function parsePage(vueOptions, parseOptions) {
};
return this.$vm && this.$vm.$callHook(ON_LOAD, query);
};
initHooks(methods, PAGE_HOOKS);
initHooks(methods, PAGE_INIT_HOOKS);
initUnknownHooks(methods, vueOptions);
initRuntimeHooks(methods, vueOptions.__runtimeHooks);
parse && parse(miniProgramPageOptions, { handleLink });
return miniProgramPageOptions;
}
......
......@@ -185,6 +185,12 @@ class EventChannel {
}
}
const MINI_PROGRAM_PAGE_RUNTIME_HOOKS = {
onPageScroll: 1,
onShareAppMessage: 1 << 1,
onShareTimeline: 1 << 2,
};
const eventChannels = {};
const eventChannelStack = [];
function getEventChannel(id) {
......@@ -290,7 +296,7 @@ function callHook(name, args) {
return hooks && invokeArrayFns(hooks, args);
}
const PAGE_HOOKS = [
const PAGE_INIT_HOOKS = [
ON_LOAD,
ON_SHOW,
ON_HIDE,
......@@ -340,6 +346,17 @@ function initHooks(mpOptions, hooks, excludes = EXCLUDE_HOOKS) {
}
function initUnknownHooks(mpOptions, vueOptions, excludes = EXCLUDE_HOOKS) {
findHooks(vueOptions).forEach((hook) => initHook$1(mpOptions, hook, excludes));
}
function initRuntimeHooks(mpOptions, runtimeHooks) {
if (!runtimeHooks) {
return;
}
const hooks = Object.keys(MINI_PROGRAM_PAGE_RUNTIME_HOOKS);
hooks.forEach((hook) => {
if (runtimeHooks & MINI_PROGRAM_PAGE_RUNTIME_HOOKS[hook]) {
initHook$1(mpOptions, hook, []);
}
});
}
tt.appLaunchHooks = [];
......@@ -848,8 +865,9 @@ function parsePage(vueOptions, parseOptions) {
};
return this.$vm && this.$vm.$callHook(ON_LOAD, query);
};
initHooks(methods, PAGE_HOOKS);
initHooks(methods, PAGE_INIT_HOOKS);
initUnknownHooks(methods, vueOptions);
initRuntimeHooks(methods, vueOptions.__runtimeHooks);
parse && parse(miniProgramPageOptions, { handleLink });
return miniProgramPageOptions;
}
......
......@@ -10,6 +10,7 @@ import { uniPagesJsonPlugin } from './plugins/pagesJson'
import { uniEntryPlugin } from './plugins/entry'
import { uniRenderjsPlugin } from './plugins/renderjs'
import { uniRuntimeHooksPlugin } from './plugins/runtimeHooks'
import { uniSubpackagePlugin } from './plugins/subpackage'
import { uniMiniProgramPluginPlugin } from './plugins/plugin'
......@@ -32,6 +33,7 @@ export default (options: UniMiniProgramPluginOptions) => {
uniEntryPlugin(options),
uniViteInjectPlugin(extend({}, options.vite.inject)),
uniRenderjsPlugin({ lang: options.template.filter?.lang }),
uniRuntimeHooksPlugin(),
uniMiniProgramPlugin(options),
(options: {
vueOptions?: { script?: Partial<SFCScriptCompileOptions> }
......
......@@ -8,6 +8,7 @@ import {
parseManifestJsonOnce,
findMiniProgramTemplateFiles,
MiniProgramCompilerOptions,
getComponentJsonFilenames,
} from '@dcloudio/uni-cli-shared'
import type { CompilerOptions } from '@dcloudio/uni-mp-compiler'
......@@ -22,6 +23,7 @@ import type {
SFCTemplateCompileOptions,
SFCTemplateCompileResults,
} from '@vue/compiler-sfc'
import { hasOwn } from '@vue/shared'
export interface UniMiniProgramPluginOptions {
cdn?: number
......@@ -153,6 +155,16 @@ export function uniMiniProgramPlugin(
source: templateFiles[filename],
})
})
// 部分组件可能模板为空
getComponentJsonFilenames().forEach((jsonFilename) => {
if (!hasOwn(templateFiles, jsonFilename)) {
this.emitFile({
type: 'asset',
fileName: jsonFilename + template.extname,
source: `<block/>`,
})
}
})
if (!nvueCssEmitted) {
const nvueCssPaths = getNVueCssPaths(resolvedConfig)
if (nvueCssPaths && nvueCssPaths.length) {
......
import type { Plugin } from 'vite'
import { MINI_PROGRAM_PAGE_RUNTIME_HOOKS } from '@dcloudio/uni-shared'
import { isUniPageSfcFile } from '@dcloudio/uni-cli-shared'
type RuntimeHooks = keyof typeof MINI_PROGRAM_PAGE_RUNTIME_HOOKS
export function uniRuntimeHooksPlugin(): Plugin {
return {
name: 'vite:uni-mp-runtime-hooks',
enforce: 'post',
async transform(source, id) {
if (!isUniPageSfcFile(id)) {
return null
}
if (!source.includes('_sfc_main')) {
return null
}
const matches = source.match(
new RegExp(
`(${Object.keys(MINI_PROGRAM_PAGE_RUNTIME_HOOKS).join('|')})`,
'g'
)
)
if (!matches) {
return null
}
if (matches.includes('onShareTimeline')) {
matches.push('onShareAppMessage')
}
const hooks = new Set<RuntimeHooks>(matches as RuntimeHooks[])
let flag = 0
for (const hook of hooks) {
flag |= MINI_PROGRAM_PAGE_RUNTIME_HOOKS[hook]
}
return source + `;_sfc_main.__runtimeHooks = ${flag};`
},
}
}
......@@ -57,6 +57,12 @@ const invokeArrayFns = (fns, arg) => {
return ret;
};
const MINI_PROGRAM_PAGE_RUNTIME_HOOKS = {
onPageScroll: 1,
onShareAppMessage: 1 << 1,
onShareTimeline: 1 << 2,
};
const eventChannels = {};
const eventChannelStack = [];
function getEventChannel(id) {
......@@ -162,7 +168,7 @@ function callHook(name, args) {
return hooks && invokeArrayFns(hooks, args);
}
const PAGE_HOOKS = [
const PAGE_INIT_HOOKS = [
ON_LOAD,
ON_SHOW,
ON_HIDE,
......@@ -209,6 +215,17 @@ function initHooks(mpOptions, hooks, excludes = EXCLUDE_HOOKS) {
}
function initUnknownHooks(mpOptions, vueOptions, excludes = EXCLUDE_HOOKS) {
findHooks(vueOptions).forEach((hook) => initHook$1(mpOptions, hook, excludes));
}
function initRuntimeHooks(mpOptions, runtimeHooks) {
if (!runtimeHooks) {
return;
}
const hooks = Object.keys(MINI_PROGRAM_PAGE_RUNTIME_HOOKS);
hooks.forEach((hook) => {
if (runtimeHooks & MINI_PROGRAM_PAGE_RUNTIME_HOOKS[hook]) {
initHook$1(mpOptions, hook, []);
}
});
}
wx.appLaunchHooks = [];
......@@ -709,8 +726,9 @@ function parsePage(vueOptions, parseOptions) {
};
return this.$vm && this.$vm.$callHook(ON_LOAD, query);
};
initHooks(methods, PAGE_HOOKS);
initHooks(methods, PAGE_INIT_HOOKS);
initUnknownHooks(methods, vueOptions);
initRuntimeHooks(methods, vueOptions.__runtimeHooks);
parse && parse(miniProgramPageOptions, { handleLink });
return miniProgramPageOptions;
}
......
......@@ -185,6 +185,12 @@ class EventChannel {
}
}
const MINI_PROGRAM_PAGE_RUNTIME_HOOKS = {
onPageScroll: 1,
onShareAppMessage: 1 << 1,
onShareTimeline: 1 << 2,
};
const eventChannels = {};
const eventChannelStack = [];
function getEventChannel(id) {
......@@ -290,7 +296,7 @@ function callHook(name, args) {
return hooks && invokeArrayFns(hooks, args);
}
const PAGE_HOOKS = [
const PAGE_INIT_HOOKS = [
ON_LOAD,
ON_SHOW,
ON_HIDE,
......@@ -337,6 +343,17 @@ function initHooks(mpOptions, hooks, excludes = EXCLUDE_HOOKS) {
}
function initUnknownHooks(mpOptions, vueOptions, excludes = EXCLUDE_HOOKS) {
findHooks(vueOptions).forEach((hook) => initHook$1(mpOptions, hook, excludes));
}
function initRuntimeHooks(mpOptions, runtimeHooks) {
if (!runtimeHooks) {
return;
}
const hooks = Object.keys(MINI_PROGRAM_PAGE_RUNTIME_HOOKS);
hooks.forEach((hook) => {
if (runtimeHooks & MINI_PROGRAM_PAGE_RUNTIME_HOOKS[hook]) {
initHook$1(mpOptions, hook, []);
}
});
}
qa.appLaunchHooks = [];
......@@ -826,8 +843,9 @@ function parsePage(vueOptions, parseOptions) {
};
return this.$vm && this.$vm.$callHook(ON_LOAD, query);
};
initHooks(methods, PAGE_HOOKS);
initHooks(methods, PAGE_INIT_HOOKS);
initUnknownHooks(methods, vueOptions);
initRuntimeHooks(methods, vueOptions.__runtimeHooks);
parse && parse(miniProgramPageOptions, { handleLink });
return miniProgramPageOptions;
}
......
......@@ -1201,7 +1201,12 @@ const UniLifecycleHooks = [
ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED,
ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED,
ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED,
];
];
const MINI_PROGRAM_PAGE_RUNTIME_HOOKS = {
onPageScroll: 1,
onShareAppMessage: 1 << 1,
onShareTimeline: 1 << 2,
};
function getEnvLocale() {
const { env } = process;
......@@ -1242,6 +1247,7 @@ exports.EventModifierFlags = EventModifierFlags;
exports.I18N_JSON_DELIMITERS = I18N_JSON_DELIMITERS;
exports.JSON_PROTOCOL = JSON_PROTOCOL;
exports.LINEFEED = LINEFEED;
exports.MINI_PROGRAM_PAGE_RUNTIME_HOOKS = MINI_PROGRAM_PAGE_RUNTIME_HOOKS;
exports.NAVBAR_HEIGHT = NAVBAR_HEIGHT;
exports.NODE_TYPE_COMMENT = NODE_TYPE_COMMENT;
exports.NODE_TYPE_ELEMENT = NODE_TYPE_ELEMENT;
......
......@@ -258,6 +258,12 @@ export declare const JSON_PROTOCOL = "json://";
export declare const LINEFEED = "\n";
export declare const MINI_PROGRAM_PAGE_RUNTIME_HOOKS: {
readonly onPageScroll: 1;
readonly onShareAppMessage: number;
readonly onShareTimeline: number;
};
export declare const NAVBAR_HEIGHT = 44;
declare type NavigateToOptionEvents = Record<string, (...args: any[]) => void>;
......
......@@ -1197,7 +1197,12 @@ const UniLifecycleHooks = [
ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED,
ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED,
ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED,
];
];
const MINI_PROGRAM_PAGE_RUNTIME_HOOKS = {
onPageScroll: 1,
onShareAppMessage: 1 << 1,
onShareTimeline: 1 << 2,
};
function getEnvLocale() {
const { env } = process;
......@@ -1205,4 +1210,4 @@ function getEnvLocale() {
return (lang && lang.replace(/[.:].*/, '')) || 'en';
}
export { ACTION_TYPE_ADD_EVENT, ACTION_TYPE_ADD_WXS_EVENT, ACTION_TYPE_CREATE, ACTION_TYPE_EVENT, ACTION_TYPE_INSERT, ACTION_TYPE_PAGE_CREATE, ACTION_TYPE_PAGE_CREATED, ACTION_TYPE_PAGE_SCROLL, ACTION_TYPE_REMOVE, ACTION_TYPE_REMOVE_ATTRIBUTE, ACTION_TYPE_REMOVE_EVENT, ACTION_TYPE_SET_ATTRIBUTE, ACTION_TYPE_SET_TEXT, ATTR_CHANGE_PREFIX, ATTR_CLASS, ATTR_INNER_HTML, ATTR_STYLE, ATTR_TEXT_CONTENT, ATTR_V_OWNER_ID, ATTR_V_RENDERJS, ATTR_V_SHOW, BACKGROUND_COLOR, BUILT_IN_TAGS, BUILT_IN_TAG_NAMES, COMPONENT_NAME_PREFIX, COMPONENT_PREFIX, COMPONENT_SELECTOR_PREFIX, DATA_RE, EventChannel, EventModifierFlags, I18N_JSON_DELIMITERS, JSON_PROTOCOL, LINEFEED, NAVBAR_HEIGHT, NODE_TYPE_COMMENT, NODE_TYPE_ELEMENT, NODE_TYPE_PAGE, NODE_TYPE_TEXT, NVueTextNode, ON_ADD_TO_FAVORITES, ON_APP_ENTER_BACKGROUND, ON_APP_ENTER_FOREGROUND, ON_BACK_PRESS, ON_ERROR, ON_HIDE, ON_KEYBOARD_HEIGHT_CHANGE, ON_LAUNCH, ON_LOAD, ON_NAVIGATION_BAR_BUTTON_TAP, ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED, ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED, ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED, ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED, ON_PAGE_NOT_FOUND, ON_PAGE_SCROLL, ON_PULL_DOWN_REFRESH, ON_REACH_BOTTOM, ON_REACH_BOTTOM_DISTANCE, ON_READY, ON_RESIZE, ON_SHARE_APP_MESSAGE, ON_SHARE_TIMELINE, ON_SHOW, ON_TAB_ITEM_TAP, ON_THEME_CHANGE, ON_UNHANDLE_REJECTION, ON_UNLOAD, ON_WEB_INVOKE_APP_SERVICE, ON_WXS_INVOKE_CALL_METHOD, PLUS_RE, PRIMARY_COLOR, RENDERJS_MODULES, RESPONSIVE_MIN_WIDTH, SCHEME_RE, SELECTED_COLOR, SLOT_DEFAULT_NAME, TABBAR_HEIGHT, TAGS, UNI_SSR, UNI_SSR_DATA, UNI_SSR_GLOBAL_DATA, UNI_SSR_STORE, UNI_SSR_TITLE, UNI_STORAGE_LOCALE, UniBaseNode, UniCommentNode, UniElement, UniEvent, UniInputElement, UniLifecycleHooks, UniNode, UniTextAreaElement, UniTextNode, WEB_INVOKE_APPSERVICE, WXS_MODULES, WXS_PROTOCOL, addFont, addLeadingSlash, cache, cacheStringFunction, callOptions, createIsCustomElement, createRpx2Unit, createUniEvent, debounce, decode, decodedQuery, defaultMiniProgramRpx2Unit, defaultRpx2Unit, dynamicSlotName, forcePatchProp, formatAppLog, formatDateTime, formatH5Log, formatLog, getCustomDataset, getEnvLocale, getLen, getValueByDataPath, initCustomDataset, invokeArrayFns, isAppNativeTag, isBuiltInComponent, isComponentInternalInstance, isComponentTag, isH5CustomElement, isH5NativeTag, isMiniProgramNativeTag, isRootHook, normalizeDataset, normalizeEventType, normalizeTarget, once, parseEventName, parseQuery, parseUrl, passive, plusReady, removeLeadingSlash, resolveComponentInstance, resolveOwnerEl, resolveOwnerVm, sanitise, scrollTo, stringifyQuery, updateElementStyle };
export { ACTION_TYPE_ADD_EVENT, ACTION_TYPE_ADD_WXS_EVENT, ACTION_TYPE_CREATE, ACTION_TYPE_EVENT, ACTION_TYPE_INSERT, ACTION_TYPE_PAGE_CREATE, ACTION_TYPE_PAGE_CREATED, ACTION_TYPE_PAGE_SCROLL, ACTION_TYPE_REMOVE, ACTION_TYPE_REMOVE_ATTRIBUTE, ACTION_TYPE_REMOVE_EVENT, ACTION_TYPE_SET_ATTRIBUTE, ACTION_TYPE_SET_TEXT, ATTR_CHANGE_PREFIX, ATTR_CLASS, ATTR_INNER_HTML, ATTR_STYLE, ATTR_TEXT_CONTENT, ATTR_V_OWNER_ID, ATTR_V_RENDERJS, ATTR_V_SHOW, BACKGROUND_COLOR, BUILT_IN_TAGS, BUILT_IN_TAG_NAMES, COMPONENT_NAME_PREFIX, COMPONENT_PREFIX, COMPONENT_SELECTOR_PREFIX, DATA_RE, EventChannel, EventModifierFlags, I18N_JSON_DELIMITERS, JSON_PROTOCOL, LINEFEED, MINI_PROGRAM_PAGE_RUNTIME_HOOKS, NAVBAR_HEIGHT, NODE_TYPE_COMMENT, NODE_TYPE_ELEMENT, NODE_TYPE_PAGE, NODE_TYPE_TEXT, NVueTextNode, ON_ADD_TO_FAVORITES, ON_APP_ENTER_BACKGROUND, ON_APP_ENTER_FOREGROUND, ON_BACK_PRESS, ON_ERROR, ON_HIDE, ON_KEYBOARD_HEIGHT_CHANGE, ON_LAUNCH, ON_LOAD, ON_NAVIGATION_BAR_BUTTON_TAP, ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED, ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED, ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED, ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED, ON_PAGE_NOT_FOUND, ON_PAGE_SCROLL, ON_PULL_DOWN_REFRESH, ON_REACH_BOTTOM, ON_REACH_BOTTOM_DISTANCE, ON_READY, ON_RESIZE, ON_SHARE_APP_MESSAGE, ON_SHARE_TIMELINE, ON_SHOW, ON_TAB_ITEM_TAP, ON_THEME_CHANGE, ON_UNHANDLE_REJECTION, ON_UNLOAD, ON_WEB_INVOKE_APP_SERVICE, ON_WXS_INVOKE_CALL_METHOD, PLUS_RE, PRIMARY_COLOR, RENDERJS_MODULES, RESPONSIVE_MIN_WIDTH, SCHEME_RE, SELECTED_COLOR, SLOT_DEFAULT_NAME, TABBAR_HEIGHT, TAGS, UNI_SSR, UNI_SSR_DATA, UNI_SSR_GLOBAL_DATA, UNI_SSR_STORE, UNI_SSR_TITLE, UNI_STORAGE_LOCALE, UniBaseNode, UniCommentNode, UniElement, UniEvent, UniInputElement, UniLifecycleHooks, UniNode, UniTextAreaElement, UniTextNode, WEB_INVOKE_APPSERVICE, WXS_MODULES, WXS_PROTOCOL, addFont, addLeadingSlash, cache, cacheStringFunction, callOptions, createIsCustomElement, createRpx2Unit, createUniEvent, debounce, decode, decodedQuery, defaultMiniProgramRpx2Unit, defaultRpx2Unit, dynamicSlotName, forcePatchProp, formatAppLog, formatDateTime, formatH5Log, formatLog, getCustomDataset, getEnvLocale, getLen, getValueByDataPath, initCustomDataset, invokeArrayFns, isAppNativeTag, isBuiltInComponent, isComponentInternalInstance, isComponentTag, isH5CustomElement, isH5NativeTag, isMiniProgramNativeTag, isRootHook, normalizeDataset, normalizeEventType, normalizeTarget, once, parseEventName, parseQuery, parseUrl, passive, plusReady, removeLeadingSlash, resolveComponentInstance, resolveOwnerEl, resolveOwnerVm, sanitise, scrollTo, stringifyQuery, updateElementStyle };
......@@ -75,3 +75,9 @@ export const UniLifecycleHooks = [
ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED,
ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED,
] as const
export const MINI_PROGRAM_PAGE_RUNTIME_HOOKS = {
onPageScroll: 1,
onShareAppMessage: 1 << 1,
onShareTimeline: 1 << 2,
} as const
'use strict';
var version = "3.0.0-alpha-3030320211225001";
var version = "3.0.0-alpha-3030320211224001";
const STAT_VERSION = version;
const STAT_URL = 'https://tongji.dcloud.io/uni/stat';
......
var version = "3.0.0-alpha-3030320211225001";
var version = "3.0.0-alpha-3030320211224001";
const STAT_VERSION = version;
const STAT_URL = 'https://tongji.dcloud.io/uni/stat';
......
......@@ -9,7 +9,7 @@ export function rewriteCompilerSfcParse() {
const compilerSfc = require(resolveBuiltIn('@vue/compiler-sfc'))
const { parse } = compilerSfc
compilerSfc.parse = (source: string, options: SFCParseOptions) => {
if (options.filename) {
if (options?.filename) {
const extname = path.extname(options.filename)
// wxs、filter、renderjs
if (extname && !EXTNAME_VUE.includes(extname)) {
......
......@@ -46,7 +46,7 @@ importers:
semver: ^7.3.5
ts-jest: ^27.0.3
typescript: ^4.5.3
vite: ^2.7.6
vite: ^2.7.7
vue: 3.2.26
vue-router: ^4.0.12
yorkie: ^2.0.0
......@@ -65,7 +65,7 @@ importers:
'@rollup/plugin-strip': 2.1.0_rollup@2.60.2
'@types/jest': 26.0.24
'@typescript-eslint/parser': 5.5.0_eslint@7.32.0+typescript@4.5.3
'@vitejs/plugin-vue': 2.0.1_vite@2.7.6+vue@3.2.26
'@vitejs/plugin-vue': 2.0.1_vite@2.7.7+vue@3.2.26
'@vitejs/plugin-vue-jsx': 1.3.3
'@vue/reactivity': 3.2.26
'@vue/runtime-core': 3.2.26
......@@ -93,7 +93,7 @@ importers:
semver: 7.3.5
ts-jest: 27.1.0_560d4ec5932803928b08544817dafdad
typescript: 4.5.3
vite: 2.7.6
vite: 2.7.7
vue: 3.2.26
vue-router: 4.0.12_vue@3.2.26
yorkie: 2.0.0
......@@ -107,7 +107,7 @@ importers:
compression: ^1.7.4
cypress: ^7.3.0
serve-static: ^1.14.1
vite: ^2.7.6
vite: ^2.7.7
vue: 3.2.26
vue-router: ^4.0.12
vuex: ^4.0.2
......@@ -123,7 +123,7 @@ importers:
compression: 1.7.4
cypress: 7.7.0
serve-static: 1.14.1
vite: 2.7.6
vite: 2.7.7
packages/size-check:
specifiers:
......@@ -215,7 +215,7 @@ importers:
'@dcloudio/uni-i18n': link:../uni-i18n
'@dcloudio/uni-shared': link:../uni-shared
'@rollup/pluginutils': 4.1.2
'@vitejs/plugin-vue': 2.0.1_vite@2.7.6+vue@3.2.26
'@vitejs/plugin-vue': 2.0.1_vite@2.7.7+vue@3.2.26
'@vue/compiler-sfc': 3.2.26
debug: 4.3.3
fs-extra: 10.0.0
......@@ -817,8 +817,8 @@ importers:
'@dcloudio/uni-cli-shared': link:../uni-cli-shared
'@dcloudio/uni-shared': link:../uni-shared
'@rollup/pluginutils': 4.1.2
'@vitejs/plugin-legacy': 1.6.4_vite@2.7.6
'@vitejs/plugin-vue': 2.0.1_vite@2.7.6+vue@3.2.26
'@vitejs/plugin-legacy': 1.6.4_vite@2.7.7
'@vitejs/plugin-vue': 2.0.1_vite@2.7.7+vue@3.2.26
'@vitejs/plugin-vue-jsx': 1.3.3
'@vue/compiler-core': 3.2.26
'@vue/compiler-dom': 3.2.26
......@@ -3183,7 +3183,7 @@ packages:
eslint-visitor-keys: 3.1.0
dev: true
/@vitejs/plugin-legacy/1.6.4_vite@2.7.6:
/@vitejs/plugin-legacy/1.6.4_vite@2.7.7:
resolution: {integrity: sha512-geH2F3hTRN++E4n9NZ0JFumxIWUKqW4FA9PAgM7Q6RvUOUUYW4tlURhEmCBYfZSN24H/yX3mEolX+wFVErsAYQ==}
engines: {node: '>=12.0.0'}
peerDependencies:
......@@ -3194,7 +3194,7 @@ packages:
magic-string: 0.25.7
regenerator-runtime: 0.13.9
systemjs: 6.11.0
vite: 2.7.6
vite: 2.7.7
dev: false
/@vitejs/plugin-vue-jsx/1.3.3:
......@@ -3210,14 +3210,14 @@ packages:
transitivePeerDependencies:
- supports-color
/@vitejs/plugin-vue/2.0.1_vite@2.7.6+vue@3.2.26:
/@vitejs/plugin-vue/2.0.1_vite@2.7.7+vue@3.2.26:
resolution: {integrity: sha512-wtdMnGVvys9K8tg+DxowU1ytTrdVveXr3LzdhaKakysgGXyrsfaeds2cDywtvujEASjWOwWL/OgWM+qoeM8Plg==}
engines: {node: '>=12.0.0'}
peerDependencies:
vite: ^2.5.10
vue: ^3.2.25
dependencies:
vite: 2.7.6
vite: 2.7.7
vue: 3.2.26
/@vue/babel-helper-vue-transform-on/1.0.2:
......@@ -8948,8 +8948,8 @@ packages:
extsprintf: 1.3.0
dev: true
/vite/2.7.6:
resolution: {integrity: sha512-PBNoc87rDYLtkpFU9dbVeGdbcyKzz6c34oScqivE3FEa3BhVa4ASupCzcz0eDIiSECovfLcQnLUJt9vhiEU08g==}
/vite/2.7.7:
resolution: {integrity: sha512-Nm4ingl//gMSj/p1aCBHuTc5Fd8W8Mwdci/HUvqCVq8xaJqF7z08S/LRq1M9kS0jRfJk1/f/CwUyQAr6YgsOLw==}
engines: {node: '>=12.2.0'}
hasBin: true
peerDependencies:
......
......@@ -22,7 +22,7 @@ const pkgs = {
next: '9.1.9',
},
vite: {
latest: '2.7.6',
latest: '2.7.7',
},
'@vitejs/plugin-vue': {
latest: '2.0.1',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册