提交 7033a52e 编写于 作者: fxy060608's avatar fxy060608

wip(mp): mp-baidu

上级 c7e4fa0c
......@@ -96,7 +96,7 @@
"semver": "^7.3.4",
"ts-jest": "^27.0.3",
"typescript": "^4.4.3",
"vite": "^2.6.10",
"vite": "^2.6.11",
"vue": "^3.2.20",
"yorkie": "^2.0.0"
},
......
......@@ -32,6 +32,6 @@
"compression": "^1.7.4",
"cypress": "^7.3.0",
"serve-static": "^1.14.1",
"vite": "^2.6.10"
"vite": "^2.6.11"
}
}
此差异已折叠。
......@@ -57,7 +57,11 @@ function parsePagesJson(
) {
nvuePages.push(pagePath)
}
pageJsons[pagePath] = parseWindowOptions(style, platform, windowOptionsMap)
pageJsons[pagePath] = parseWindowOptions(
style,
platform,
windowOptionsMap
) as PageWindowOptions
}
// pages
validatePages(pagesJson, jsonStr)
......
......@@ -21,6 +21,7 @@ type Style = 'v2' | string
type RestartStrategy = 'homePage' | 'homePageAndLatestPage' | string
export interface PageWindowOptions extends ShareWindowOptions {
component: true // 百度小程序页面必须配置component: true
disableScroll?: boolean // false
usingComponents?: UsingComponents
initialRenderingCache?: 'static' | string
......
......@@ -32,11 +32,15 @@ export function parseWindowOptions(
windowOptionsMap?: Record<string, string>
): PageWindowOptions | AppWindowOptions {
if (!style) {
return {}
return {
component: true,
}
}
const platformStyle = style[platform] || {}
removePlatformStyle(trimJson(style) as any)
const res: PageWindowOptions | AppWindowOptions = {}
const res: PageWindowOptions | AppWindowOptions = {
component: true,
}
if (windowOptionsMap) {
return extend(convert(res, style, windowOptionsMap), platformStyle)
}
......
......@@ -187,6 +187,31 @@ const initI18nShowModalMsgsOnce = /* @__PURE__ */ once(() => {
useI18n().add(LOCALE_ZH_HANT, normalizeMessages(name, keys, ["\u53D6\u6D88", "\u78BA\u5B9A"]), false);
}
});
const initI18nChooseFileMsgsOnce = /* @__PURE__ */ once(() => {
const name = "uni.chooseFile.";
const keys = ["notUserActivation"];
if (__UNI_FEATURE_I18N_EN__) {
useI18n().add(LOCALE_EN, normalizeMessages(name, keys, [
"File chooser dialog can only be shown with a user activation"
]), false);
}
if (__UNI_FEATURE_I18N_ES__) {
useI18n().add(LOCALE_ES, normalizeMessages(name, keys, [
"El cuadro de di\xE1logo del selector de archivos solo se puede mostrar con la activaci\xF3n del usuario"
]), false);
}
if (__UNI_FEATURE_I18N_FR__) {
useI18n().add(LOCALE_FR, normalizeMessages(name, keys, [
"La bo\xEEte de dialogue du s\xE9lecteur de fichier ne peut \xEAtre affich\xE9e qu'avec une activation par l'utilisateur"
]), false);
}
if (__UNI_FEATURE_I18N_ZH_HANS__) {
useI18n().add(LOCALE_ZH_HANS, normalizeMessages(name, keys, ["\u6587\u4EF6\u9009\u62E9\u5668\u5BF9\u8BDD\u6846\u53EA\u80FD\u5728\u7528\u6237\u6FC0\u6D3B\u65F6\u663E\u793A"]), false);
}
if (__UNI_FEATURE_I18N_ZH_HANT__) {
useI18n().add(LOCALE_ZH_HANT, normalizeMessages(name, keys, ["\u6587\u4EF6\u9078\u64C7\u5668\u5C0D\u8A71\u6846\u53EA\u80FD\u5728\u7528\u6236\u6FC0\u6D3B\u6642\u986F\u793A"]), false);
}
});
const initI18nSetClipboardDataMsgsOnce = /* @__PURE__ */ once(() => {
const name = "uni.setClipboardData.";
const keys = ["success", "fail"];
......@@ -8032,7 +8057,8 @@ const passiveOptions$1 = passive(true);
const states = [];
let userInteract = 0;
let inited;
function addInteractListener(vm) {
const setUserAction = (userAction) => states.forEach((vm) => vm.userAction = userAction);
function addInteractListener(vm = { userAction: false }) {
if (!inited) {
const eventNames = [
"touchstart",
......@@ -8043,16 +8069,11 @@ function addInteractListener(vm) {
];
eventNames.forEach((eventName) => {
document.addEventListener(eventName, function() {
states.forEach((vm2) => {
vm2.userAction = true;
userInteract++;
setTimeout(() => {
userInteract--;
if (!userInteract) {
vm2.userAction = false;
}
}, 0);
});
!userInteract && setUserAction(true);
userInteract++;
setTimeout(() => {
!--userInteract && setUserAction(false);
}, 0);
}, passiveOptions$1);
});
inited = true;
......@@ -8065,6 +8086,7 @@ function removeInteractListener(vm) {
states.splice(index2, 1);
}
}
const getInteractStatus = () => !!userInteract;
function useUserAction() {
const state2 = reactive({
userAction: false
......@@ -16518,6 +16540,7 @@ const MIMEType = {
}
};
const ALL = "all";
addInteractListener();
function isWXEnv() {
const ua2 = window.navigator.userAgent.toLowerCase();
const matchUA = ua2.match(/MicroMessenger/i);
......@@ -16566,6 +16589,8 @@ const chooseFile = /* @__PURE__ */ defineAsyncApi(API_CHOOSE_FILE, ({
type,
extension
}, { resolve, reject }) => {
initI18nChooseFileMsgsOnce();
const { t: t2 } = useI18n();
if (fileInput) {
document.body.removeChild(fileInput);
fileInput = null;
......@@ -16603,7 +16628,11 @@ const chooseFile = /* @__PURE__ */ defineAsyncApi(API_CHOOSE_FILE, ({
};
resolve(res);
});
fileInput.click();
if (getInteractStatus()) {
fileInput.click();
} else {
reject(t2("uni.chooseFile.notUserActivation"));
}
}, ChooseFileProtocol, ChooseFileOptions);
let imageInput = null;
const chooseImage = /* @__PURE__ */ defineAsyncApi(API_CHOOSE_IMAGE, ({
......@@ -16611,6 +16640,8 @@ const chooseImage = /* @__PURE__ */ defineAsyncApi(API_CHOOSE_IMAGE, ({
sourceType,
extension
}, { resolve, reject }) => {
initI18nChooseFileMsgsOnce();
const { t: t2 } = useI18n();
if (imageInput) {
document.body.removeChild(imageInput);
imageInput = null;
......@@ -16648,7 +16679,11 @@ const chooseImage = /* @__PURE__ */ defineAsyncApi(API_CHOOSE_IMAGE, ({
};
resolve(res);
});
imageInput.click();
if (getInteractStatus()) {
imageInput.click();
} else {
reject(t2("uni.chooseFile.notUserActivation"));
}
}, ChooseImageProtocol, ChooseImageOptions);
let index$c = 0;
let overflow = "";
......@@ -16881,6 +16916,8 @@ const previewImage = /* @__PURE__ */ defineAsyncApi(API_PREVIEW_IMAGE, (args, {
}, PreviewImageProtocol, PreviewImageOptions);
let videoInput = null;
const chooseVideo = /* @__PURE__ */ defineAsyncApi(API_CHOOSE_VIDEO, ({ sourceType, extension }, { resolve, reject }) => {
initI18nChooseFileMsgsOnce();
const { t: t2 } = useI18n();
if (videoInput) {
document.body.removeChild(videoInput);
videoInput = null;
......@@ -16931,7 +16968,11 @@ const chooseVideo = /* @__PURE__ */ defineAsyncApi(API_CHOOSE_VIDEO, ({ sourceTy
resolve(callbackResult);
}
});
videoInput.click();
if (getInteractStatus()) {
videoInput.click();
} else {
reject(t2("uni.chooseFile.notUserActivation"));
}
}, ChooseVideoProtocol, ChooseVideoOptions);
const request = /* @__PURE__ */ defineTaskApi(API_REQUEST, ({
url,
......
import { isCustomElement, isNativeTag } from '@dcloudio/uni-shared'
import { compile, CompilerOptions } from '@dcloudio/uni-mp-compiler'
import { transformFor } from '../src/plugin/transforms/vFor'
export function assert(
template: string,
templateCode: string,
renderCode: string,
options: CompilerOptions = {}
) {
const res = compile(template, {
mode: 'module',
filename: 'foo.vue',
prefixIdentifiers: true,
inline: true,
isNativeTag,
isCustomElement,
generatorOpts: {
concise: true,
},
nodeTransforms: [transformFor],
miniProgram: {
slot: {
fallback: false,
},
directive: 's-',
emitFile({ source }) {
// console.log(source)
if (!options.onError) {
expect(source).toBe(templateCode)
}
return ''
},
},
...options,
})
if (!options.onError) {
expect(res.code).toBe(renderCode)
}
}
import { assert } from './testUtils'
describe(`mp-baidu: transform v-for`, () => {
test(`with key`, () => {
assert(
`<view v-for="item in items" :key="item.id"/>`,
`<view s-for="a trackBy item.id" s-for-item="item"/>`,
`(_ctx, _cache) => {
return { a: _f(_ctx.items, (item, k0, i0) => { return {}; }) }
}`
)
})
test(`without key`, () => {
assert(
`<view v-for="item in items"/>`,
`<view s-for="{{a}}" s-for-item="item"/>`,
`(_ctx, _cache) => {
return { a: _f(_ctx.items, (item, k0, i0) => { return {}; }) }
}`
)
})
})
import { assert } from './testUtils'
describe(`mp-baidu: transform v-if`, () => {
test(`basic`, () => {
assert(
`<view v-if="ok"/><view v-else-if="ok1"/><view v-else/>`,
`<view s-if="{{a}}"/><view s-elif="{{b}}"/><view s-else/>`,
`(_ctx, _cache) => {
return _e({ a: _ctx.ok }, _ctx.ok ? {} : _ctx.ok1 ? {} : {}, { b: _ctx.ok1 })
}`
)
})
})
{
"input": {
"src/runtime/index.ts": "dist/uni.mp.esm.js",
"src/api/index.ts": "dist/uni.api.esm.js"
},
"alias": {
"entries": [
{
"find": "@dcloudio/uni-platform",
"replacement": "packages/uni-mp-baidu/src/platform/index.ts"
},
{
"find": "@dcloudio/uni-mp-platform",
"replacement": "packages/uni-mp-core/src/platform/index.ts"
}
[
{
"input": {
"src/plugin/index.ts": "dist/uni.compiler.js"
},
"output": {
"format": "cjs"
},
"external": [
"@dcloudio/uni-cli-shared",
"@dcloudio/uni-mp-compiler",
"@dcloudio/uni-mp-vite",
"@vue/compiler-core"
]
},
"replacements": {
"__GLOBAL__": "swan",
"__PLATFORM__": "\"mp-baidu\"",
"__PLATFORM_TITLE__": "百度小程序"
},
"external": ["@dcloudio/uni-i18n", "@vue/shared", "vue"]
}
{
"input": {
"src/runtime/index.ts": "dist/uni.mp.esm.js",
"src/api/index.ts": "dist/uni.api.esm.js"
},
"alias": {
"entries": [
{
"find": "@dcloudio/uni-platform",
"replacement": "packages/uni-mp-baidu/src/platform/index.ts"
},
{
"find": "@dcloudio/uni-mp-platform",
"replacement": "packages/uni-mp-core/src/platform/index.ts"
}
]
},
"replacements": {
"__GLOBAL__": "swan",
"__PLATFORM__": "\"mp-baidu\"",
"__PLATFORM_TITLE__": "百度小程序"
},
"external": ["@dcloudio/uni-i18n", "@vue/shared", "vue"]
}
]
'use strict';
var uniCliShared = require('@dcloudio/uni-cli-shared');
var initMiniProgramPlugin = require('@dcloudio/uni-mp-vite');
var uniMpCompiler = require('@dcloudio/uni-mp-compiler');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var initMiniProgramPlugin__default = /*#__PURE__*/_interopDefaultLegacy(initMiniProgramPlugin);
var appid = "";
var host = "baiduboxapp";
var projectname = "";
var setting = {
autoAudits: false,
urlCheck: false
};
var source = {
appid: appid,
"compilation-args": {
common: {
babelSetting: {
ignore: [
]
},
enhance: true,
ignorePrefixCss: false
},
selected: -3
},
host: host,
projectname: projectname,
setting: setting
};
const transformFor = (node) => {
if (!uniMpCompiler.isForElementNode(node)) {
return;
}
const keyProp = uniMpCompiler.findProp(node, 'key', true);
if (keyProp) {
const { exp } = keyProp;
if (exp) {
const key = uniMpCompiler.genExpr(exp);
node.vFor.sourceCode = `${node.vFor.sourceAlias} trackBy ${key}`;
node.props.splice(node.props.indexOf(keyProp), 1);
}
}
};
const uniMiniProgramBaiduPlugin = {
name: 'vite:uni-mp-baidu',
config() {
return {
define: {
__VUE_CREATED_DEFERRED__: false,
},
};
},
};
const projectConfigFilename = 'project.swan.json';
const options = {
vite: {
inject: {
uni: [
uniCliShared.resolveBuiltIn('@dcloudio/uni-mp-baidu/dist/uni.api.esm.js'),
'default',
],
},
alias: {
'uni-mp-runtime': uniCliShared.resolveBuiltIn('@dcloudio/uni-mp-baidu/dist/uni.mp.esm.js'),
},
copyOptions: {
assets: ['swancomponents'],
},
},
global: 'swan',
app: {
darkmode: false,
subpackages: true,
},
project: {
filename: projectConfigFilename,
source,
},
template: {
filter: {
extname: '.swan',
lang: 'sjs',
generate(filter, filename) {
if (filename) {
return `<import-sjs src="${filename}.sjs" module="${filter.name}"/>`;
}
return `<import-sjs module="${filter.name}">
${filter.code}
</import-sjs>`;
},
},
slot: {
fallback: false,
},
extname: '.swan',
directive: 's-',
compilerOptions: {
nodeTransforms: [transformFor],
},
},
style: {
extname: '.css',
},
};
var index = [uniMiniProgramBaiduPlugin, ...initMiniProgramPlugin__default["default"](options)];
module.exports = index;
......@@ -835,7 +835,7 @@ function parse$1(componentOptions) {
fixSetDataStart(this);
oldAttached.call(this);
this.pageinstance.$vm = this.$vm;
this.$vm.__call_hook('onInit', query);
this.$vm.$callHook('onInit', query);
};
lifetimes.attached = function attached() {
if (!this.$vm) {
......
......@@ -18,7 +18,9 @@
"license": "Apache-2.0",
"uni-app": {
"name": "mp-baidu",
"title": "百度小程序"
"title": "百度小程序",
"apply": "mp-baidu",
"main": "dist/uni.compiler.js"
},
"gitHead": "1efa8efd0a9eddeabdba75c020d015ebf31b8177"
}
import type { Plugin } from 'vite'
import { resolveBuiltIn } from '@dcloudio/uni-cli-shared'
import initMiniProgramPlugin, {
UniMiniProgramPluginOptions,
} from '@dcloudio/uni-mp-vite'
import source from './project.swan.json'
import { transformFor } from './transforms/vFor'
const uniMiniProgramBaiduPlugin: Plugin = {
name: 'vite:uni-mp-baidu',
config() {
return {
define: {
__VUE_CREATED_DEFERRED__: false,
},
}
},
}
const projectConfigFilename = 'project.swan.json'
const options: UniMiniProgramPluginOptions = {
vite: {
inject: {
uni: [
resolveBuiltIn('@dcloudio/uni-mp-baidu/dist/uni.api.esm.js'),
'default',
],
},
alias: {
'uni-mp-runtime': resolveBuiltIn(
'@dcloudio/uni-mp-baidu/dist/uni.mp.esm.js'
),
},
copyOptions: {
assets: ['swancomponents'],
},
},
global: 'swan',
app: {
darkmode: false,
subpackages: true,
},
project: {
filename: projectConfigFilename,
source,
},
template: {
filter: {
extname: '.swan',
lang: 'sjs',
generate(filter, filename) {
if (filename) {
return `<import-sjs src="${filename}.sjs" module="${filter.name}"/>`
}
return `<import-sjs module="${filter.name}">
${filter.code}
</import-sjs>`
},
},
slot: {
fallback: false,
},
extname: '.swan',
directive: 's-',
compilerOptions: {
nodeTransforms: [transformFor],
},
},
style: {
extname: '.css',
},
}
export default [uniMiniProgramBaiduPlugin, ...initMiniProgramPlugin(options)]
{
"appid": "",
"compilation-args": {
"common": {
"babelSetting": {
"ignore": []
},
"enhance": true,
"ignorePrefixCss": false
},
"selected": -3
},
"host": "baiduboxapp",
"projectname": "",
"setting": {
"autoAudits": false,
"urlCheck": false
}
}
import {
genExpr,
findProp,
isForElementNode,
DirectiveNode,
NodeTransform,
} from '@dcloudio/uni-mp-compiler'
export const transformFor: NodeTransform = (node) => {
if (!isForElementNode(node)) {
return
}
const keyProp = findProp(node, 'key', true)
if (keyProp) {
const { exp } = keyProp as DirectiveNode
if (exp) {
const key = genExpr(exp)
node.vFor.sourceCode = `${node.vFor.sourceAlias} trackBy ${key}`
node.props.splice(node.props.indexOf(keyProp), 1)
}
}
}
......@@ -48,7 +48,7 @@ export function parse(componentOptions: MPComponentOptions) {
fixSetDataStart(this as MPComponentInstance)
oldAttached.call(this)
this.pageinstance.$vm = this.$vm
this.$vm.__call_hook('onInit', query)
this.$vm.$callHook('onInit', query)
}
lifetimes.attached = function attached(this: MPComponentInstance) {
if (!this.$vm) {
......
......@@ -75,28 +75,28 @@ describe('compiler: transform class', () => {
test('v-bind:class object syntax + class', () => {
assert(
`<view :class="{ red: isRed }" class="foo bar"/>`,
`<view class="{{[a && 'red', 'foo bar']}}"/>`,
`<view class="{{[a && 'red', 'foo', 'bar']}}"/>`,
`(_ctx, _cache) => {
return { a: _ctx.isRed ? 1 : 0 }
}`
)
assert(
`<view class="foo bar" :class="{ red: isRed }"/>`,
`<view class="{{['foo bar', a && 'red']}}"/>`,
`<view class="{{['foo', 'bar', a && 'red']}}"/>`,
`(_ctx, _cache) => {
return { a: _ctx.isRed ? 1 : 0 }
}`
)
assert(
`<view :class="{ a: 1, b: 0, c: true, d: false, e: null, f: undefined, g: ok, h: handle(ok), i: ok>1, j, [k]:1, [l]:m, ...n, ...{a:true}, ...{b:o} }" class="foo bar"/>`,
`<view class="{{['a', 'c', a && 'g', b && 'h', c && 'i', d && 'j', e, g && f, h, i, j, 'foo bar']}}"/>`,
`<view class="{{['a', 'c', a && 'g', b && 'h', c && 'i', d && 'j', e, g && f, h, i, j, 'foo', 'bar']}}"/>`,
`(_ctx, _cache) => {
return { a: _ctx.ok ? 1 : 0, b: _ctx.handle(_ctx.ok) ? 1 : 0, c: _ctx.ok > 1 ? 1 : 0, d: _ctx.j ? 1 : 0, e: _ctx.k, f: _ctx.l, g: _ctx.m ? 1 : 0, h: _n(_ctx.n), i: _n({ a: true }), j: _n({ b: _ctx.o }) }
}`
)
assert(
`<view class="foo bar" :class="{ a: 1, b: 0, c: true, d: false, e: null, f: undefined, g: ok, h: handle(ok), i: ok>1, j, [k]:1, [l]:m, ...n, ...{a:true}, ...{b:o} }"/>`,
`<view class="{{['foo bar', 'a', 'c', a && 'g', b && 'h', c && 'i', d && 'j', e, g && f, h, i, j]}}"/>`,
`<view class="{{['foo', 'bar', 'a', 'c', a && 'g', b && 'h', c && 'i', d && 'j', e, g && f, h, i, j]}}"/>`,
`(_ctx, _cache) => {
return { a: _ctx.ok ? 1 : 0, b: _ctx.handle(_ctx.ok) ? 1 : 0, c: _ctx.ok > 1 ? 1 : 0, d: _ctx.j ? 1 : 0, e: _ctx.k, f: _ctx.l, g: _ctx.m ? 1 : 0, h: _n(_ctx.n), i: _n({ a: true }), j: _n({ b: _ctx.o }) }
}`
......@@ -128,28 +128,28 @@ describe('compiler: transform class', () => {
test('v-bind:class array syntax + class', () => {
assert(
`<view :class="[classA, classB]" class="foo bar"/>`,
`<view class="{{[a, b, 'foo bar']}}"/>`,
`<view class="{{[a, b, 'foo', 'bar']}}"/>`,
`(_ctx, _cache) => {
return { a: _n(_ctx.classA), b: _n(_ctx.classB) }
}`
)
assert(
`<view class="foo bar" :class="[classA, classB]"/>`,
`<view class="{{['foo bar', a, b]}}"/>`,
`<view class="{{['foo', 'bar', a, b]}}"/>`,
`(_ctx, _cache) => {
return { a: _n(_ctx.classA), b: _n(_ctx.classB) }
}`
)
assert(
`<view :class="[classA, classB, { classC: isC, classD: isD }, 'classE', isF ? 'classF' : '', isG && 'classG', ...classH, ...[classI,classJ], handle(classK) ]" class="foo bar"/>`,
`<view class="{{[a, b, c, 'classE', d, e, f, g, h, 'foo bar']}}"/>`,
`<view class="{{[a, b, c, 'classE', d, e, f, g, h, 'foo', 'bar']}}"/>`,
`(_ctx, _cache) => {
return { a: _n(_ctx.classA), b: _n(_ctx.classB), c: _n({ classC: _ctx.isC, classD: _ctx.isD }), d: _n(_ctx.isF ? 'classF' : ''), e: _n(_ctx.isG && 'classG'), f: _n(_ctx.classH), g: _n([_ctx.classI, _ctx.classJ]), h: _n(_ctx.handle(_ctx.classK)) }
}`
)
assert(
`<view class="foo bar" :class="[classA, classB, { classC: isC, classD: isD }, 'classE', isF ? 'classF' : '', isG && 'classG', ...classH, ...[classI,classJ], handle(classK) ]"/>`,
`<view class="{{['foo bar', a, b, c, 'classE', d, e, f, g, h]}}"/>`,
`<view class="{{['foo', 'bar', a, b, c, 'classE', d, e, f, g, h]}}"/>`,
`(_ctx, _cache) => {
return { a: _n(_ctx.classA), b: _n(_ctx.classB), c: _n({ classC: _ctx.isC, classD: _ctx.isD }), d: _n(_ctx.isF ? 'classF' : ''), e: _n(_ctx.isG && 'classG'), f: _n(_ctx.classH), g: _n([_ctx.classI, _ctx.classJ]), h: _n(_ctx.handle(_ctx.classK)) }
}`
......
......@@ -5,7 +5,7 @@ describe('compiler: transform component', () => {
// test('basic', () => {
// assert(
// `<custom/>`,
// `<custom class="v-r" v-i="2a9ec0b0-0" bind:__l="__l"/>`,
// `<custom v-i="2a9ec0b0-0" bind:__l="__l"/>`,
// `(_ctx, _cache) => {
// return {}
// }`,
......@@ -17,7 +17,7 @@ describe('compiler: transform component', () => {
test('component + component', () => {
assert(
`<custom><custom1/></custom>`,
`<custom class="v-r" v-s="{{['default']}}" v-i="2a9ec0b0-0" bind:__l="__l"><custom1 class="v-r" v-i="2a9ec0b0-1,2a9ec0b0-0" bind:__l="__l"/></custom>`,
`<custom v-s="{{['default']}}" v-i="2a9ec0b0-0" bind:__l="__l"><custom1 v-i="2a9ec0b0-1,2a9ec0b0-0" bind:__l="__l"/></custom>`,
`(_ctx, _cache) => {
return {}
}`,
......@@ -29,7 +29,7 @@ describe('compiler: transform component', () => {
test('component + component + component', () => {
assert(
`<custom><custom1><custom2/><custom2/></custom1></custom>`,
`<custom class="v-r" v-s="{{['default']}}" v-i="2a9ec0b0-0" bind:__l="__l"><custom1 class="v-r" v-s="{{['default']}}" v-i="2a9ec0b0-1,2a9ec0b0-0" bind:__l="__l"><custom2 class="v-r" v-i="2a9ec0b0-2,2a9ec0b0-1" bind:__l="__l"/><custom2 class="v-r" v-i="2a9ec0b0-3,2a9ec0b0-1" bind:__l="__l"/></custom1></custom>`,
`<custom v-s="{{['default']}}" v-i="2a9ec0b0-0" bind:__l="__l"><custom1 v-s="{{['default']}}" v-i="2a9ec0b0-1,2a9ec0b0-0" bind:__l="__l"><custom2 v-i="2a9ec0b0-2,2a9ec0b0-1" bind:__l="__l"/><custom2 v-i="2a9ec0b0-3,2a9ec0b0-1" bind:__l="__l"/></custom1></custom>`,
`(_ctx, _cache) => {
return {}
}`,
......@@ -41,7 +41,7 @@ describe('compiler: transform component', () => {
test('component with v-for', () => {
assert(
`<custom v-for="item in items"/>`,
`<custom wx:for="{{a}}" wx:for-item="item" class="v-r-i-f" v-i="{{item.a}}" bind:__l="__l"/>`,
`<custom wx:for="{{a}}" wx:for-item="item" v-i="{{item.a}}" bind:__l="__l"/>`,
`(_ctx, _cache) => {
return { a: _f(_ctx.items, (item, k0, i0) => { return { a: '2a9ec0b0-0' + '-' + i0 }; }) }
}`,
......@@ -51,7 +51,7 @@ describe('compiler: transform component', () => {
)
assert(
`<custom v-for="(item,key,index) in items"/>`,
`<custom wx:for="{{a}}" wx:for-item="item" class="v-r-i-f" v-i="{{item.a}}" bind:__l="__l"/>`,
`<custom wx:for="{{a}}" wx:for-item="item" v-i="{{item.a}}" bind:__l="__l"/>`,
`(_ctx, _cache) => {
return { a: _f(_ctx.items, (item, key, index) => { return { a: '2a9ec0b0-0' + '-' + index }; }) }
}`,
......@@ -63,7 +63,7 @@ describe('compiler: transform component', () => {
test('component + component with v-for', () => {
assert(
`<custom><custom1 v-for="item in items"/></custom>`,
`<custom class="v-r" v-s="{{['default']}}" v-i="2a9ec0b0-0" bind:__l="__l"><custom1 wx:for="{{a}}" wx:for-item="item" class="v-r-i-f" v-i="{{item.a}}" bind:__l="__l"/></custom>`,
`<custom v-s="{{['default']}}" v-i="2a9ec0b0-0" bind:__l="__l"><custom1 wx:for="{{a}}" wx:for-item="item" v-i="{{item.a}}" bind:__l="__l"/></custom>`,
`(_ctx, _cache) => {
return { a: _f(_ctx.items, (item, k0, i0) => { return { a: '2a9ec0b0-1' + '-' + i0 + ',' + '2a9ec0b0-0' }; }) }
}`,
......@@ -75,7 +75,7 @@ describe('compiler: transform component', () => {
test('component with v-for + component', () => {
assert(
`<custom v-for="item in items"><custom1/></custom>`,
`<custom wx:for="{{a}}" wx:for-item="item" class="v-r-i-f" v-s="{{['default']}}" v-i="{{item.b}}" bind:__l="__l"><custom1 class="v-r-i-f" v-i="{{item.a}}" bind:__l="__l"/></custom>`,
`<custom wx:for="{{a}}" wx:for-item="item" v-s="{{['default']}}" v-i="{{item.b}}" bind:__l="__l"><custom1 v-i="{{item.a}}" bind:__l="__l"/></custom>`,
`(_ctx, _cache) => {
return { a: _f(_ctx.items, (item, k0, i0) => { return { a: '2a9ec0b0-1' + '-' + i0 + ',' + ('2a9ec0b0-0' + '-' + i0), b: '2a9ec0b0-0' + '-' + i0 }; }) }
}`,
......@@ -87,7 +87,7 @@ describe('compiler: transform component', () => {
test('component with v-for + component with v-for', () => {
assert(
`<custom v-for="item in items"><custom1 v-for="item1 in item.items"/></custom>`,
`<custom wx:for="{{a}}" wx:for-item="item" class="v-r-i-f" v-s="{{['default']}}" v-i="{{item.b}}" bind:__l="__l"><custom1 wx:for="{{item.a}}" wx:for-item="item1" class="v-r-i-f" v-i="{{item1.a}}" bind:__l="__l"/></custom>`,
`<custom wx:for="{{a}}" wx:for-item="item" v-s="{{['default']}}" v-i="{{item.b}}" bind:__l="__l"><custom1 wx:for="{{item.a}}" wx:for-item="item1" v-i="{{item1.a}}" bind:__l="__l"/></custom>`,
`(_ctx, _cache) => {
return { a: _f(_ctx.items, (item, k0, i0) => { return { a: _f(item.items, (item1, k1, i1) => { return { a: '2a9ec0b0-1' + '-' + i0 + '-' + i1 + ',' + ('2a9ec0b0-0' + '-' + i0) }; }), b: '2a9ec0b0-0' + '-' + i0 }; }) }
}`,
......
import { assert } from './testUtils'
describe('compiler: transform ref', () => {
test('v-r', () => {
test('without ref', () => {
assert(
`<custom/>`,
`<custom class="v-r" v-i="2a9ec0b0-0"/>`,
`<custom v-i="2a9ec0b0-0"/>`,
`(_ctx, _cache) => {
return {}
}`
)
assert(
`<custom/><custom/><custom1/>`,
`<custom class="v-r" v-i="2a9ec0b0-0"/><custom class="v-r" v-i="2a9ec0b0-1"/><custom1 class="v-r" v-i="2a9ec0b0-2"/>`,
`<custom v-i="2a9ec0b0-0"/><custom v-i="2a9ec0b0-1"/><custom1 v-i="2a9ec0b0-2"/>`,
`(_ctx, _cache) => {
return {}
}`
)
})
test('v-r-i-f', () => {
assert(
`<custom v-for="item in items"/>`,
`<custom wx:for="{{a}}" wx:for-item="item" class="v-r-i-f" v-i="{{item.a}}"/>`,
`(_ctx, _cache) => {
return { a: _f(_ctx.items, (item, k0, i0) => { return { a: '2a9ec0b0-0' + '-' + i0 }; }) }
}`
)
})
......@@ -32,6 +23,13 @@ describe('compiler: transform ref', () => {
`<custom class="v-r" data-ref="custom" v-i="2a9ec0b0-0"/>`,
`(_ctx, _cache) => {
return {}
}`
)
assert(
`<custom v-for="item in items" ref="custom"/>`,
`<custom wx:for="{{a}}" wx:for-item="item" class="v-r-i-f" data-ref="custom" v-i="{{item.a}}"/>`,
`(_ctx, _cache) => {
return { a: _f(_ctx.items, (item, k0, i0) => { return { a: '2a9ec0b0-0' + '-' + i0 }; }) }
}`
)
})
......@@ -41,6 +39,13 @@ describe('compiler: transform ref', () => {
`<custom class="v-r" data-ref="{{a}}" v-i="2a9ec0b0-0"/>`,
`(_ctx, _cache) => {
return { a: _ctx.custom }
}`
)
assert(
`<custom v-for="item in items" :ref="custom"/>`,
`<custom wx:for="{{a}}" wx:for-item="item" class="v-r-i-f" data-ref="{{b}}" v-i="{{item.a}}"/>`,
`(_ctx, _cache) => {
return { a: _f(_ctx.items, (item, k0, i0) => { return { a: '2a9ec0b0-0' + '-' + i0 }; }), b: _ctx.custom }
}`
)
})
......
......@@ -33,7 +33,7 @@ describe('compiler: transform scopeId', () => {
)
assert(
`<view class="bar" :class="foo"/>`,
`<view class="{{['bar data-v-5584ec96', a]}}"/>`,
`<view class="{{['bar', 'data-v-5584ec96', a]}}"/>`,
`(_ctx, _cache) => {
return { a: _n(_ctx.foo) }
}`,
......@@ -41,7 +41,7 @@ describe('compiler: transform scopeId', () => {
)
assert(
`<view :class="foo" class="bar"/>`,
`<view class="{{[a, 'bar data-v-5584ec96']}}"/>`,
`<view class="{{[a, 'bar', 'data-v-5584ec96']}}"/>`,
`(_ctx, _cache) => {
return { a: _n(_ctx.foo) }
}`,
......
......@@ -4,7 +4,7 @@ describe('compiler: transform v-model', () => {
test(`component v-model`, () => {
assert(
`<Comp v-model="model" />`,
`<comp class="v-r" v-i="2a9ec0b0-0" modelValue="{{a}}" bindupdateModelValue="{{b}}"/>`,
`<comp v-i="2a9ec0b0-0" modelValue="{{a}}" bindupdateModelValue="{{b}}"/>`,
`(_ctx, _cache) => {
return { a: _ctx.model, b: _o($event => _ctx.model = $event) }
}`
......@@ -13,7 +13,7 @@ describe('compiler: transform v-model', () => {
test(`component v-model with cache`, () => {
assert(
`<Comp v-model="model" />`,
`<comp class="v-r" v-i="2a9ec0b0-0" modelValue="{{a}}" bindupdateModelValue="{{b}}"/>`,
`<comp v-i="2a9ec0b0-0" modelValue="{{a}}" bindupdateModelValue="{{b}}"/>`,
`(_ctx, _cache) => {
return { a: _ctx.model, b: _o($event => _ctx.model = $event) }
}`,
......
......@@ -4,14 +4,14 @@ describe('compiler: transform v-slot', () => {
test('default slot', () => {
assert(
`<custom><template v-slot/></custom>`,
`<custom class="v-r" v-s="{{['default']}}" v-i="2a9ec0b0-0"><view /></custom>`,
`<custom v-s="{{['default']}}" v-i="2a9ec0b0-0"><view /></custom>`,
`(_ctx, _cache) => {
return {}
}`
)
assert(
`<custom>test</custom>`,
`<custom class="v-r" v-s="{{['default']}}" v-i="2a9ec0b0-0">test</custom>`,
`<custom v-s="{{['default']}}" v-i="2a9ec0b0-0">test</custom>`,
`(_ctx, _cache) => {
return {}
}`
......@@ -20,7 +20,7 @@ describe('compiler: transform v-slot', () => {
test('named slots', () => {
assert(
`<custom><template v-slot:header/><template v-slot:default/><template v-slot:footer/></custom>`,
`<custom class="v-r" v-s="{{['header','default','footer']}}" v-i="2a9ec0b0-0"><view slot="header"/><view slot="default"/><view slot="footer"/></custom>`,
`<custom v-s="{{['header','default','footer']}}" v-i="2a9ec0b0-0"><view slot="header"/><view slot="default"/><view slot="footer"/></custom>`,
`(_ctx, _cache) => {
return {}
}`
......@@ -30,7 +30,7 @@ describe('compiler: transform v-slot', () => {
test('scoped slots', () => {
assert(
`<custom><template v-slot:default="slotProps"><view>{{ slotProps.item }}</view></template></custom>`,
`<custom class="v-r" v-s="{{['default']}}" v-i="2a9ec0b0-0"><view slot="default"><block wx:for="{{a}}" wx:for-item="slotProps" wx:key="b"><view>{{slotProps.a}}</view></block></view></custom>`,
`<custom v-s="{{['default']}}" v-i="2a9ec0b0-0"><view slot="default"><block wx:for="{{a}}" wx:for-item="slotProps" wx:key="b"><view>{{slotProps.a}}</view></block></view></custom>`,
`(_ctx, _cache) => {
return { a: _w((slotProps, s0, i0) => { return { a: _t(slotProps.item), b: s0 }; }, { name: 'default', vueId: '2a9ec0b0-0' }) }
}`
......@@ -40,7 +40,7 @@ describe('compiler: transform v-slot', () => {
test('scoped slots + scoped slots', () => {
assert(
`<custom><template v-slot:default="slotProps"><custom1><template v-slot:default="slotProps1">{{ slotProps.item }}{{ slotProps1.item }}</template></custom1></template></custom>`,
`<custom class="v-r" v-s="{{['default']}}" v-i="2a9ec0b0-0"><view slot="default"><block wx:for="{{a}}" wx:for-item="slotProps" wx:key="d"><custom1 class="v-r" v-s="{{['default']}}" v-i="{{slotProps.c}}"><view slot="default"><block wx:for="{{slotProps.a}}" wx:for-item="slotProps1" wx:key="b">{{slotProps.b}}{{slotProps1.a}}</block></view></custom1></block></view></custom>`,
`<custom v-s="{{['default']}}" v-i="2a9ec0b0-0"><view slot="default"><block wx:for="{{a}}" wx:for-item="slotProps" wx:key="d"><custom1 v-s="{{['default']}}" v-i="{{slotProps.c}}"><view slot="default"><block wx:for="{{slotProps.a}}" wx:for-item="slotProps1" wx:key="b">{{slotProps.b}}{{slotProps1.a}}</block></view></custom1></block></view></custom>`,
`(_ctx, _cache) => {
return { a: _w((slotProps, s0, i0) => { return { a: _w((slotProps1, s1, i1) => { return { a: _t(slotProps1.item), b: s1 }; }, { name: 'default', vueId: '2a9ec0b0-1' + '-' + i0 + ',' + '2a9ec0b0-0' }), b: _t(slotProps.item), c: '2a9ec0b0-1' + '-' + i0 + ',' + '2a9ec0b0-0', d: s0 }; }, { name: 'default', vueId: '2a9ec0b0-0' }) }
}`
......@@ -50,7 +50,7 @@ describe('compiler: transform v-slot', () => {
test('v-if + scoped slots', () => {
assert(
`<custom><template v-if="ok" v-slot:default="slotProps"><view>{{ slotProps.item }}</view></template></custom>`,
`<custom class="v-r" v-s="{{['default']}}" v-i="2a9ec0b0-0"><view wx:if="{{a}}" slot="default"><block wx:for="{{b}}" wx:for-item="slotProps" wx:key="b"><view>{{slotProps.a}}</view></block></view></custom>`,
`<custom v-s="{{['default']}}" v-i="2a9ec0b0-0"><view wx:if="{{a}}" slot="default"><block wx:for="{{b}}" wx:for-item="slotProps" wx:key="b"><view>{{slotProps.a}}</view></block></view></custom>`,
`(_ctx, _cache) => {
return _e({ a: _ctx.ok }, _ctx.ok ? { b: _w((slotProps, s0, i0) => { return { a: _t(slotProps.item), b: s0 }; }, { name: 'default', vueId: '2a9ec0b0-0' }) } : {})
}`
......@@ -60,7 +60,7 @@ describe('compiler: transform v-slot', () => {
test('v-for + scoped slots', () => {
assert(
`<custom v-for="item in items"><template v-slot:default="slotProps"><view>{{ slotProps.item }}</view></template></custom>`,
`<custom wx:for="{{a}}" wx:for-item="item" class="v-r-i-f" v-s="{{['default']}}" v-i="{{item.b}}"><view slot="default"><block wx:for="{{item.a}}" wx:for-item="slotProps" wx:key="b"><view>{{slotProps.a}}</view></block></view></custom>`,
`<custom wx:for="{{a}}" wx:for-item="item" v-s="{{['default']}}" v-i="{{item.b}}"><view slot="default"><block wx:for="{{item.a}}" wx:for-item="slotProps" wx:key="b"><view>{{slotProps.a}}</view></block></view></custom>`,
`(_ctx, _cache) => {
return { a: _f(_ctx.items, (item, k0, i0) => { return { a: _w((slotProps, s1, i1) => { return { a: _t(slotProps.item), b: s1 }; }, { name: 'default', vueId: '2a9ec0b0-0' + '-' + i0 }), b: '2a9ec0b0-0' + '-' + i0 }; }) }
}`
......@@ -70,7 +70,7 @@ describe('compiler: transform v-slot', () => {
test('v-for + v-for + scoped slots', () => {
assert(
`<view v-for="item in items"><custom v-for="item1 in item.list" :item="item1"><template v-slot:default="slotProps"><view>{{ slotProps.item }}</view></template></custom></view>`,
`<view wx:for="{{a}}" wx:for-item="item"><custom wx:for="{{item.a}}" wx:for-item="item1" class="v-r-i-f" v-s="{{['default']}}" item="{{item1.b}}" v-i="{{item1.c}}"><view slot="default"><block wx:for="{{item1.a}}" wx:for-item="slotProps" wx:key="b"><view>{{slotProps.a}}</view></block></view></custom></view>`,
`<view wx:for="{{a}}" wx:for-item="item"><custom wx:for="{{item.a}}" wx:for-item="item1" v-s="{{['default']}}" item="{{item1.b}}" v-i="{{item1.c}}"><view slot="default"><block wx:for="{{item1.a}}" wx:for-item="slotProps" wx:key="b"><view>{{slotProps.a}}</view></block></view></custom></view>`,
`(_ctx, _cache) => {
return { a: _f(_ctx.items, (item, k0, i0) => { return { a: _f(item.list, (item1, k1, i1) => { return { a: _w((slotProps, s2, i2) => { return { a: _t(slotProps.item), b: s2 }; }, { name: 'default', vueId: '2a9ec0b0-0' + '-' + i0 + '-' + i1 }), b: item1, c: '2a9ec0b0-0' + '-' + i0 + '-' + i1 }; }) }; }) }
}`
......
......@@ -10,6 +10,18 @@ import { baseCompile } from './compile'
import { parserOptions } from './parserOptions'
import { CompilerOptions } from './options'
export { findProp } from '@vue/compiler-core'
export type {
CompilerOptions,
DirectiveNode,
NodeTransform,
TransformContext,
SimpleExpressionNode,
} from '@vue/compiler-core'
export { genExpr } from './codegen'
export { isForElementNode } from './transforms/vFor'
export * from './runtimeHelpers'
export function parse(template: string, options: ParserOptions = {}): RootNode {
......
......@@ -7,14 +7,14 @@ import {
ObjectProperty,
SpreadElement,
} from '@babel/types'
import {
NodeTransform as VueNodeTransform,
DirectiveTransform as VueDirectiveTransform,
} from '@vue/compiler-core'
import { MiniProgramCompilerOptions } from '@dcloudio/uni-cli-shared'
import { BindingMetadata, CompilerError, RootNode } from '@vue/compiler-core'
import IdentifierGenerator from './identifier'
import {
DirectiveTransform,
NodeTransform,
TransformContext,
} from './transform'
import { TransformContext } from './transform'
import { VForOptions } from './transforms/vFor'
export interface CodegenRootNode extends RootNode {
......@@ -58,8 +58,8 @@ export interface TransformOptions
filters?: string[]
renderDataSpread?: boolean
cacheHandlers?: boolean
nodeTransforms?: NodeTransform[]
directiveTransforms?: Record<string, DirectiveTransform | undefined>
nodeTransforms?: VueNodeTransform[]
directiveTransforms?: Record<string, VueDirectiveTransform | undefined>
isBuiltInComponent?: (tag: string) => symbol | void
isCustomElement?: (tag: string) => boolean | void
expressionPlugins?: ParserPlugin[]
......
......@@ -17,7 +17,7 @@ import {
} from '@vue/compiler-core'
import { TemplateCodegenOptions } from '../options'
import { genExpr } from '../codegen'
import { isForElementNode, VForOptions } from '../transforms/vFor'
import { ForElementNode, isForElementNode } from '../transforms/vFor'
import { IfElementNode, isIfElementNode } from '../transforms/vIf'
import { findSlotName } from '../transforms/vSlot'
interface TemplateCodegenContext {
......@@ -95,11 +95,11 @@ function genVElse({ push, directive }: TemplateCodegenContext) {
}
function genVFor(
{ sourceAlias, valueAlias }: VForOptions,
node: ElementNode,
node: ForElementNode,
{ push, directive }: TemplateCodegenContext
) {
push(` ${directive}for="{{${sourceAlias}}}"`)
const { sourceCode, valueAlias } = node.vFor
push(` ${directive}for="${sourceCode}"`)
if (valueAlias) {
push(` ${directive}for-item="${valueAlias}"`)
}
......@@ -216,7 +216,7 @@ function genElement(node: ElementNode, context: TemplateCodegenContext) {
}
}
if (isForElementNode(node)) {
genVFor(node.vFor, node, context)
genVFor(node, context)
}
if (props.length) {
genElementProps(node, context)
......
......@@ -160,7 +160,7 @@ export function traverseNode(
const { nodeTransforms } = context
const exitFns = []
for (let i = 0; i < nodeTransforms.length; i++) {
const onExit = nodeTransforms[i](node, context)
const onExit = nodeTransforms[i](node, context as any)
if (onExit) {
if (isArray(onExit)) {
exitFns.push(...onExit)
......
......@@ -82,20 +82,26 @@ export function rewriteClass(
if (staticClassPropIndex > -1) {
const staticClass = (props[staticClassPropIndex] as AttributeNode).value!
.content
if (staticClass.trim()) {
if (staticClass) {
if (!isArrayExpression(classBidingExpr)) {
classBidingExpr = arrayExpression([classBidingExpr])
}
const staticClassLiterals = parseStaticClass(staticClass)
if (index > staticClassPropIndex) {
classBidingExpr.elements.unshift(stringLiteral(staticClass))
classBidingExpr.elements.unshift(...staticClassLiterals)
} else {
classBidingExpr.elements.push(stringLiteral(staticClass))
classBidingExpr.elements.push(...staticClassLiterals)
}
}
}
classBindingProp.exp = createSimpleExpression(genBabelExpr(classBidingExpr))
}
function parseStaticClass(staticClass: string): StringLiteral[] {
// 已经在 parse 阶段格式化了多余空格等
return staticClass.split(' ').map((clazz) => stringLiteral(clazz))
}
function rewriteClassExpression(
expr: ExpressionNode,
context: TransformContext
......
import { ComponentNode } from '@vue/compiler-core'
import { ComponentNode, findProp } from '@vue/compiler-core'
import { isVForScope, NodeTransform, TransformContext } from '../transform'
import { createAttributeNode, createBindDirectiveNode } from '../ast'
import { addStaticClass } from './transformElement'
......@@ -61,6 +61,10 @@ function addVueId(node: ComponentNode, context: TransformContext) {
}
function addVueRef(node: ComponentNode, context: TransformContext) {
// 仅配置了 ref 属性的,才需要增补 vue-ref
if (!findProp(node, 'ref')) {
return
}
return addStaticClass(
node,
// vue-ref-in-for
......
......@@ -275,7 +275,7 @@ export function processProps(
const directiveTransform = context.directiveTransforms[name]
if (directiveTransform) {
const { props } = directiveTransform(prop, node, context)
const { props } = directiveTransform(prop, node, context as any)
if (props.length) {
prop.exp = props[0].value as ExpressionNode
}
......
......@@ -44,6 +44,7 @@ import { createVSlotCallExpression, isScopedSlotVFor } from './vSlot'
export type VForOptions = Omit<ForParseResult, 'tagType'> & {
sourceExpr?: Expression
sourceAlias: string
sourceCode: string
valueCode: string
valueExpr: Identifier | Pattern | RestElement
valueAlias: string
......@@ -103,15 +104,18 @@ export const transformFor = createStructuralDirectiveTransform(
const indexAlias = parseAlias(indexExpr, indexCode, 'i' + scopes.vFor)
// 先占位vFor,后续更新 cloneSourceExpr 为 CallExpression
const cloneSourceExpr = cloneNode(sourceExpr!, false)
const sourceAlias = rewriteExpression(
source,
context,
cloneSourceExpr,
parentScope
).content
const sourceCode = `{{${sourceAlias}}}`
const vForData: VForOptions = {
source,
sourceExpr,
sourceAlias: rewriteExpression(
source,
context,
cloneSourceExpr,
parentScope
).content,
sourceAlias,
sourceCode,
value,
valueCode,
valueExpr,
......
......@@ -82,7 +82,7 @@ function fix2648(bundle) {
catch (_a) { }
}
const uniMiniProgramWeixinPlugin = {
const uniMiniProgramQQPlugin = {
name: 'vite:uni-mp-qq',
config() {
return {
......@@ -120,7 +120,7 @@ const options = {
},
global: 'qq',
app: {
darkmode: true,
darkmode: false,
subpackages: true,
},
project: {
......@@ -153,6 +153,6 @@ ${filter.code}
extname: '.qss',
},
};
var index = [uniMiniProgramWeixinPlugin, ...initMiniProgramPlugin__default["default"](options)];
var index = [uniMiniProgramQQPlugin, ...initMiniProgramPlugin__default["default"](options)];
module.exports = index;
......@@ -7,7 +7,7 @@ import initMiniProgramPlugin, {
import source from './project.config.json'
import { fix2648 } from './fix2648'
const uniMiniProgramWeixinPlugin: Plugin = {
const uniMiniProgramQQPlugin: Plugin = {
name: 'vite:uni-mp-qq',
config() {
return {
......@@ -48,7 +48,7 @@ const options: UniMiniProgramPluginOptions = {
},
global: 'qq',
app: {
darkmode: true,
darkmode: false,
subpackages: true,
},
project: {
......@@ -82,4 +82,4 @@ ${filter.code}
},
}
export default [uniMiniProgramWeixinPlugin, ...initMiniProgramPlugin(options)]
export default [uniMiniProgramQQPlugin, ...initMiniProgramPlugin(options)]
......@@ -7,7 +7,8 @@ import {
parseManifestJsonOnce,
findMiniProgramTemplateFiles,
} from '@dcloudio/uni-cli-shared'
import { CompilerOptions } from '@vue/compiler-core'
import type { CompilerOptions } from '@dcloudio/uni-mp-compiler'
import { uniOptions } from './uni'
import { buildOptions } from './build'
......
......@@ -5,8 +5,8 @@ import {
UniVitePlugin,
MiniProgramCompilerOptions,
} from '@dcloudio/uni-cli-shared'
import { CompilerOptions, TemplateCompiler } from '@vue/compiler-sfc'
import { TemplateCompiler } from '@vue/compiler-sfc'
import type { CompilerOptions } from '@dcloudio/uni-mp-compiler'
import * as compiler from '@dcloudio/uni-mp-compiler'
export function uniOptions({
......@@ -26,6 +26,6 @@ export function uniOptions({
isNativeTag,
isCustomElement,
...compilerOptions,
},
} as any,
}
}
......@@ -61,8 +61,8 @@ export function uniEntryPlugin({
)
this.addWatchFile(filepath)
return {
code: `import Page from '${filepath}?mpType=page'
${global}.createPage(Page)`,
code: `import MiniProgramPage from '${filepath}?mpType=page'
${global}.createPage(MiniProgramPage)`,
}
} else if (isUniComponentUrl(id)) {
const filepath = normalizePath(
......
'use strict';
var version = "3.0.0-alpha-3021020211012005";
var version = "3.0.0-alpha-3021020211025001";
const STAT_VERSION = version;
const STAT_URL = 'https://tongji.dcloud.io/uni/stat';
......
var version = "3.0.0-alpha-3021020211012005";
var version = "3.0.0-alpha-3021020211025001";
const STAT_VERSION = version;
const STAT_URL = 'https://tongji.dcloud.io/uni/stat';
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册