提交 e1801408 编写于 作者: Q qiang

Merge branch 'dev' into alpha

# Conflicts:
#	packages/uni-mp-kuaishou/dist/index.js
......@@ -1400,9 +1400,6 @@ var serviceContext = (function () {
t(key, values) {
return t(key, values);
},
getLocale() {
return i18n.getLocale();
},
setLocale(newLocale) {
return i18n.setLocale(newLocale);
},
......@@ -20964,6 +20961,9 @@ var serviceContext = (function () {
}
const evalJSCode =
`typeof UniViewJSBridge !== 'undefined' && UniViewJSBridge.subscribeHandler("${eventType}",${args},__PAGE_ID__)`;
if (process.env.NODE_ENV !== 'production') {
console.log(`UNIAPP[publishHandler]:[${+new Date()}]`, 'length', evalJSCode.length);
}
pageIds.forEach(id => {
const webview = plus.webview.getWebviewById(String(id));
webview && webview.evalJS(evalJSCode.replace('__PAGE_ID__', id));
......
......@@ -27,7 +27,7 @@ module.exports = {
subPackages: true
},
copyWebpackOptions (platformOptions, vueOptions) {
const copyOptions = []
const copyOptions = ['androidPrivacy.json']
const componentsCopyOption = getComponentsCopyOption()
if (componentsCopyOption) {
copyOptions.push(componentsCopyOption)
......
import { isPlainObject, isArray, extend, hyphenate, isObject, hasOwn, toNumber, capitalize, isFunction, NOOP, EMPTY_OBJ, camelize } from '@vue/shared';
import { onUnmounted } from 'vue';
const encode = encodeURIComponent;
function stringifyQuery(obj, encodeStr = encode) {
......@@ -391,6 +392,9 @@ function initBaseInstance(instance, options) {
}
function initComponentInstance(instance, options) {
initBaseInstance(instance, options);
{
initScopedSlotsParams(instance);
}
const ctx = instance.ctx;
MP_METHODS.forEach((method) => {
ctx[method] = function (...args) {
......@@ -440,6 +444,53 @@ function callHook(name, args) {
}
const hooks = this.$[name];
return hooks && invokeArrayFns(hooks, args);
}
const center = {};
const parents = {};
function initScopedSlotsParams(instance) {
const ctx = instance.ctx;
ctx.$hasScopedSlotsParams = function (vueId) {
const has = center[vueId];
if (!has) {
parents[vueId] = this;
onUnmounted(() => {
delete parents[vueId];
}, instance);
}
return has;
};
ctx.$getScopedSlotsParams = function (vueId, name, key) {
const data = center[vueId];
if (data) {
const object = data[name] || {};
return key ? object[key] : object;
}
else {
parents[vueId] = this;
onUnmounted(() => {
delete parents[vueId];
}, instance);
}
};
ctx.$setScopedSlotsParams = function (name, value) {
const vueIds = instance.attrs.vueId;
if (vueIds) {
const vueId = vueIds.split(',')[0];
const object = center[vueId] = center[vueId] || {};
object[name] = value;
if (parents[vueId]) {
parents[vueId].$forceUpdate();
}
}
};
onUnmounted(function () {
const propsData = instance.attrs;
const vueId = propsData && propsData.vueId;
if (vueId) {
delete center[vueId];
delete parents[vueId];
}
}, instance);
}
const PAGE_HOOKS = [
......
import { isPlainObject, hasOwn, isArray, extend, hyphenate, isObject, toNumber, isFunction, NOOP, camelize } from '@vue/shared';
import { onUnmounted } from 'vue';
const encode = encodeURIComponent;
function stringifyQuery(obj, encodeStr = encode) {
......@@ -419,6 +420,9 @@ function initBaseInstance(instance, options) {
}
function initComponentInstance(instance, options) {
initBaseInstance(instance, options);
{
initScopedSlotsParams(instance);
}
const ctx = instance.ctx;
MP_METHODS.forEach((method) => {
ctx[method] = function (...args) {
......@@ -465,6 +469,53 @@ function callHook(name, args) {
}
const hooks = this.$[name];
return hooks && invokeArrayFns(hooks, args);
}
const center = {};
const parents = {};
function initScopedSlotsParams(instance) {
const ctx = instance.ctx;
ctx.$hasScopedSlotsParams = function (vueId) {
const has = center[vueId];
if (!has) {
parents[vueId] = this;
onUnmounted(() => {
delete parents[vueId];
}, instance);
}
return has;
};
ctx.$getScopedSlotsParams = function (vueId, name, key) {
const data = center[vueId];
if (data) {
const object = data[name] || {};
return key ? object[key] : object;
}
else {
parents[vueId] = this;
onUnmounted(() => {
delete parents[vueId];
}, instance);
}
};
ctx.$setScopedSlotsParams = function (name, value) {
const vueIds = instance.attrs.vueId;
if (vueIds) {
const vueId = vueIds.split(',')[0];
const object = center[vueId] = center[vueId] || {};
object[name] = value;
if (parents[vueId]) {
parents[vueId].$forceUpdate();
}
}
};
onUnmounted(function () {
const propsData = instance.attrs;
const vueId = propsData && propsData.vueId;
if (vueId) {
delete center[vueId];
delete parents[vueId];
}
}, instance);
}
const PAGE_HOOKS = [
......
......@@ -1845,13 +1845,12 @@ function fixSetDataEnd (mpInstance) {
}
}
const SDKVersion = ks.getSystemInfoSync().SDKVersion;
function parseComponent$1 (vueComponentOptions) {
const componentOptions = parseComponent(vueComponentOptions);
const oldAttached = componentOptions.lifetimes.attached;
componentOptions.lifetimes.attached = function attached () {
if (isPage.call(this) && parseFloat(SDKVersion) <= 1.13) {
// 暂不区分版本
if (isPage.call(this)) {
// 解决快手小程序页面 attached 生命周期 setData 导致数据同步异常的问题
fixSetDataStart(this);
setTimeout(() => {
......
此差异已折叠。
此差异已折叠。
import { isPlainObject, hasOwn, isArray, extend, hyphenate, isObject, toNumber, isFunction, NOOP, camelize } from '@vue/shared';
import { onUnmounted } from 'vue';
const encode = encodeURIComponent;
function stringifyQuery(obj, encodeStr = encode) {
......@@ -419,6 +420,9 @@ function initBaseInstance(instance, options) {
}
function initComponentInstance(instance, options) {
initBaseInstance(instance, options);
{
initScopedSlotsParams(instance);
}
const ctx = instance.ctx;
MP_METHODS.forEach((method) => {
ctx[method] = function (...args) {
......@@ -465,6 +469,53 @@ function callHook(name, args) {
}
const hooks = this.$[name];
return hooks && invokeArrayFns(hooks, args);
}
const center = {};
const parents = {};
function initScopedSlotsParams(instance) {
const ctx = instance.ctx;
ctx.$hasScopedSlotsParams = function (vueId) {
const has = center[vueId];
if (!has) {
parents[vueId] = this;
onUnmounted(() => {
delete parents[vueId];
}, instance);
}
return has;
};
ctx.$getScopedSlotsParams = function (vueId, name, key) {
const data = center[vueId];
if (data) {
const object = data[name] || {};
return key ? object[key] : object;
}
else {
parents[vueId] = this;
onUnmounted(() => {
delete parents[vueId];
}, instance);
}
};
ctx.$setScopedSlotsParams = function (name, value) {
const vueIds = instance.attrs.vueId;
if (vueIds) {
const vueId = vueIds.split(',')[0];
const object = center[vueId] = center[vueId] || {};
object[name] = value;
if (parents[vueId]) {
parents[vueId].$forceUpdate();
}
}
};
onUnmounted(function () {
const propsData = instance.attrs;
const vueId = propsData && propsData.vueId;
if (vueId) {
delete center[vueId];
delete parents[vueId];
}
}, instance);
}
const PAGE_HOOKS = [
......
import { isPlainObject, hasOwn, isArray, extend, hyphenate, isObject, toNumber, isFunction, NOOP, camelize } from '@vue/shared';
import { onUnmounted } from 'vue';
const encode = encodeURIComponent;
function stringifyQuery(obj, encodeStr = encode) {
......@@ -419,6 +420,9 @@ function initBaseInstance(instance, options) {
}
function initComponentInstance(instance, options) {
initBaseInstance(instance, options);
{
initScopedSlotsParams(instance);
}
const ctx = instance.ctx;
MP_METHODS.forEach((method) => {
ctx[method] = function (...args) {
......@@ -465,6 +469,53 @@ function callHook(name, args) {
}
const hooks = this.$[name];
return hooks && invokeArrayFns(hooks, args);
}
const center = {};
const parents = {};
function initScopedSlotsParams(instance) {
const ctx = instance.ctx;
ctx.$hasScopedSlotsParams = function (vueId) {
const has = center[vueId];
if (!has) {
parents[vueId] = this;
onUnmounted(() => {
delete parents[vueId];
}, instance);
}
return has;
};
ctx.$getScopedSlotsParams = function (vueId, name, key) {
const data = center[vueId];
if (data) {
const object = data[name] || {};
return key ? object[key] : object;
}
else {
parents[vueId] = this;
onUnmounted(() => {
delete parents[vueId];
}, instance);
}
};
ctx.$setScopedSlotsParams = function (name, value) {
const vueIds = instance.attrs.vueId;
if (vueIds) {
const vueId = vueIds.split(',')[0];
const object = center[vueId] = center[vueId] || {};
object[name] = value;
if (parents[vueId]) {
parents[vueId].$forceUpdate();
}
}
};
onUnmounted(function () {
const propsData = instance.attrs;
const vueId = propsData && propsData.vueId;
if (vueId) {
delete center[vueId];
delete parents[vueId];
}
}, instance);
}
const PAGE_HOOKS = [
......
import { isPlainObject, hasOwn, isArray, extend, hyphenate, isObject, toNumber, isFunction, NOOP, camelize } from '@vue/shared';
import { onUnmounted } from 'vue';
const encode = encodeURIComponent;
function stringifyQuery(obj, encodeStr = encode) {
......@@ -365,6 +366,9 @@ function initBaseInstance(instance, options) {
}
function initComponentInstance(instance, options) {
initBaseInstance(instance, options);
{
initScopedSlotsParams(instance);
}
const ctx = instance.ctx;
MP_METHODS.forEach((method) => {
ctx[method] = function (...args) {
......@@ -411,6 +415,53 @@ function callHook(name, args) {
}
const hooks = this.$[name];
return hooks && invokeArrayFns(hooks, args);
}
const center = {};
const parents = {};
function initScopedSlotsParams(instance) {
const ctx = instance.ctx;
ctx.$hasScopedSlotsParams = function (vueId) {
const has = center[vueId];
if (!has) {
parents[vueId] = this;
onUnmounted(() => {
delete parents[vueId];
}, instance);
}
return has;
};
ctx.$getScopedSlotsParams = function (vueId, name, key) {
const data = center[vueId];
if (data) {
const object = data[name] || {};
return key ? object[key] : object;
}
else {
parents[vueId] = this;
onUnmounted(() => {
delete parents[vueId];
}, instance);
}
};
ctx.$setScopedSlotsParams = function (name, value) {
const vueIds = instance.attrs.vueId;
if (vueIds) {
const vueId = vueIds.split(',')[0];
const object = center[vueId] = center[vueId] || {};
object[name] = value;
if (parents[vueId]) {
parents[vueId].$forceUpdate();
}
}
};
onUnmounted(function () {
const propsData = instance.attrs;
const vueId = propsData && propsData.vueId;
if (vueId) {
delete center[vueId];
delete parents[vueId];
}
}, instance);
}
const PAGE_HOOKS = [
......
......@@ -28,7 +28,8 @@ module.exports = {
'sitemap.json',
'ext.json',
'custom-tab-bar',
'plugin.json'
'plugin.json',
'functional-pages'
]
const workers = platformOptions.workers
workers && copyOptions.push(workers)
......
......@@ -97,6 +97,14 @@ describe('mp:compiler-mp-weixin', () => {
scopedSlotsCompiler: 'auto'
}
)
assertCodegen(
'<my-component><template v-slot="{item}"><view @click="getValue(item)">{{item}}</view><template></my-component>',
'<my-component generic:scoped-slots-default="test-my-component-default" data-vue-generic="scoped" vue-id="551070e6-1" bind:__l="__l" vue-slots="{{[\'default\']}}"></my-component>',
'with(this){}',
{
scopedSlotsCompiler: 'auto'
}
)
assertCodegen(
'<my-component><template v-slot="{item}">{{getValue(item)}}<template></my-component>',
'<my-component scoped-slots-compiler="augmented" vue-id="551070e6-1" bind:__l="__l" vue-slots="{{[\'default\']}}"><block><block wx:if="{{$root.m0}}">{{$root.m1}}</block></block></my-component>',
......
......@@ -62,7 +62,8 @@ const tags = {
'cashier',
'ix-grid',
'ix-native-grid',
'ix-native-list'
'ix-native-list',
'mkt'
]
}
......
......@@ -2,17 +2,27 @@ const t = require('@babel/types')
const {
METHOD_BUILT_IN,
METHOD_CREATE_EMPTY_VNODE
METHOD_CREATE_EMPTY_VNODE,
METHOD_CREATE_ELEMENT
} = require('../../constants')
function needSlotMode (path, ids) {
let need
path.traverse({
noScope: false,
Property (path) {
// 跳过事件
if (path.node.key.name === 'on') {
const parentPath = path.parentPath.parentPath
if (t.isCallExpression(parentPath) && parentPath.node.callee.name === METHOD_CREATE_ELEMENT) {
path.skip()
}
}
},
Identifier (path) {
const name = path.node.name
if (path.key !== 'key' && (path.key !== 'property' || path.parent.computed)) {
// 使用方法或作用域外数据
// 使用作用域内方法或作用域外数据
if (name in ids) {
need = path.key === 'callee' ? true : need
} else if (!path.scope.hasBinding(name) && !METHOD_BUILT_IN.includes(name)) {
......
......@@ -208,7 +208,16 @@ if (process.env.UNI_USING_NATIVE || process.env.UNI_USING_V3_NATIVE) {
const array = [{
from: path.resolve(process.env.UNI_INPUT_DIR, 'static'),
to: 'static'
}]
}]
const androidPrivacyPath = path.resolve(process.env.UNI_INPUT_DIR, 'androidPrivacy.json')
if (fs.existsSync(androidPrivacyPath)) {
array.push({
from: androidPrivacyPath,
to: 'androidPrivacy.json'
})
}
const hybridHtmlPath = path.resolve(process.env.UNI_INPUT_DIR, 'hybrid/html')
if (fs.existsSync(hybridHtmlPath)) {
array.push({
......@@ -216,6 +225,7 @@ if (process.env.UNI_USING_NATIVE || process.env.UNI_USING_V3_NATIVE) {
to: 'hybrid/html'
})
}
if (process.env.UNI_USING_NVUE_COMPILER) {
array.push({
from: path.resolve(getTemplatePath(), 'common'),
......
......@@ -283,10 +283,6 @@ process.env.SCOPED_SLOTS_COMPILER = modes.includes(scopedSlotsCompiler) ? scoped
if (process.env.UNI_PLATFORM === 'mp-kuaishou' && process.env.SCOPED_SLOTS_COMPILER !== modes[0]) {
process.env.SCOPED_SLOTS_COMPILER = modes[2]
}
// Vue3 暂时固定为 legacy 模式
if (process.env.UNI_USING_VUE3) {
process.env.SCOPED_SLOTS_COMPILER = modes[0]
}
if (
process.env.UNI_USING_COMPONENTS ||
......
......@@ -172,7 +172,7 @@ module.exports = {
if (process.env.UNI_MP_PLUGIN) {
// 小程序插件入口使用
// packages\webpack-uni-mp-loader\lib\plugin\index-new.js -> addMPPluginRequire
beforeCode += `wx.__webpack_require_${process.env.UNI_MP_PLUGIN.replace('-', '_')}__ = __webpack_require__;`
beforeCode += `wx.__webpack_require_${process.env.UNI_MP_PLUGIN.replace(/-/g, '_')}__ = __webpack_require__;`
const UNI_MP_PLUGIN_MAIN = process.env.UNI_MP_PLUGIN_MAIN
if (UNI_MP_PLUGIN_MAIN) {
......@@ -304,4 +304,4 @@ module.exports = {
webpackConfig.plugins.delete('preload')
webpackConfig.plugins.delete('prefetch')
}
}
}
......@@ -73,14 +73,14 @@ function addMPPluginRequire (compilation) {
if (name === process.env.UNI_MP_PLUGIN_MAIN) {
const modules = compilation.modules
const mainFilePath = path.resolve(process.env.UNI_INPUT_DIR, process.env.UNI_MP_PLUGIN_MAIN).replace(/\\/g, '/')
const mainFilePath = normalizePath(path.resolve(process.env.UNI_INPUT_DIR, process.env.UNI_MP_PLUGIN_MAIN))
const uniModuleId = modules.find(module => module.resource && normalizePath(module.resource) === mainFilePath).id
const newlineIndex = compilation.assets[name].source().lastIndexOf('\n')
const source = compilation.assets[name].source().substring(0, newlineIndex) +
`\nmodule.exports = wx.__webpack_require_${process.env.UNI_MP_PLUGIN.replace('-', '_')}__(${uniModuleId});\n` +
`\nmodule.exports = wx.__webpack_require_${process.env.UNI_MP_PLUGIN.replace(/-/g, '_')}__('${uniModuleId}');\n` +
compilation.assets[name].source().substring(newlineIndex + 1)
compilation.assets[name] = {
......
......@@ -7,13 +7,12 @@ import {
fixSetDataEnd
} from '../../../mp-weixin/runtime/wrapper/fix-set-data'
const SDKVersion = __GLOBAL__.getSystemInfoSync().SDKVersion
export default function parseComponent (vueComponentOptions) {
const componentOptions = parseBaseComponent(vueComponentOptions)
const oldAttached = componentOptions.lifetimes.attached
componentOptions.lifetimes.attached = function attached () {
if (isPage.call(this) && parseFloat(SDKVersion) <= 1.13) {
// 暂不区分版本
if (isPage.call(this)) {
// 解决快手小程序页面 attached 生命周期 setData 导致数据同步异常的问题
fixSetDataStart(this)
setTimeout(() => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册