提交 99fedc9d 编写于 作者: fxy060608's avatar fxy060608

wip(uvue): 增加 transformElemment.spec.ts

上级 ed691558
......@@ -78,14 +78,17 @@ export function compile(
): CodegenResult {
options.rootDir = options.rootDir || ''
options.targetLanguage = options.targetLanguage || 'kotlin'
const ast = baseParse(template, {
comments: false,
isNativeTag(tag) {
const isNativeTag =
options?.isNativeTag ||
function (tag: string) {
return (
isAppUVueNativeTag(tag) ||
!!options.parseUTSComponent?.(tag, options.targetLanguage!)
)
},
}
const ast = baseParse(template, {
comments: false,
isNativeTag,
})
const [nodeTransforms, directiveTransforms] = getBaseTransformPreset(
options.prefixIdentifiers
......
......@@ -111,7 +111,13 @@ export interface TransformOptions
slotted?: boolean
}
export type CompilerOptions = TransformOptions & CodegenOptions
export type CompilerOptions = {
/**
* e.g. platform native elements, e.g. `<div>` for browsers
*/
isNativeTag?: (tag: string) => boolean
} & TransformOptions &
CodegenOptions
export interface CodegenResult {
ast?: RootNode
......
......@@ -30,6 +30,7 @@ import {
isString,
PatchFlags,
PatchFlagNames,
EMPTY_OBJ,
} from '@vue/shared'
import { defaultOnError, defaultOnWarn } from './errors'
import { TransformOptions } from './options'
......@@ -123,6 +124,7 @@ export function createTransformContext(
directiveTransforms = {},
scopeId = null,
slotted = true,
bindingMetadata = EMPTY_OBJ,
isBuiltInComponent = NOOP,
isCustomElement = NOOP,
onError = defaultOnError,
......@@ -136,7 +138,7 @@ export function createTransformContext(
targetLanguage,
selfName: nameMatch && capitalize(camelize(nameMatch[1])),
prefixIdentifiers,
bindingMetadata: {},
bindingMetadata,
nodeTransforms,
directiveTransforms,
elements: new Set(),
......
import { NodeTransform, NodeTypes } from '@vue/compiler-core'
import { NodeTypes } from '@vue/compiler-core'
import { parse } from '@dcloudio/uni-nvue-styler'
import { createCompilerError } from '../errors'
import { NodeTransform } from '../transform'
// Verify that the template style is in compliance with specifications
export const transformStyle: NodeTransform = (node, context) => {
......
......@@ -72,6 +72,7 @@ const customElements = [
'live-preview',
'aweme-live-book',
'aweme-user-card',
'rtc-room',
];
const projectConfigFilename = 'project.config.json';
const nodeTransforms = [
......
......@@ -72,6 +72,7 @@ const customElements = [
'live-preview',
'aweme-live-book',
'aweme-user-card',
'rtc-room',
];
const projectConfigFilename = 'project.config.json';
const nodeTransforms = [
......
......@@ -22,7 +22,7 @@ export const customElements = [
'live-preview',
'aweme-live-book',
'aweme-user-card',
'rtc-room'
'rtc-room',
]
const projectConfigFilename = 'project.config.json'
......
......@@ -5581,7 +5581,7 @@ packages:
normalize-path: 3.0.0
readdirp: 3.6.0
optionalDependencies:
fsevents: 2.3.2
fsevents: 2.3.3
/ci-info@1.6.0:
resolution: {integrity: sha512-vsGdkwSCDpWmP80ncATX7iea5DWQemg1UgCW5J8tqjU3lYw4FBYuj89J0CTVomA7BEfvSZd84GmHko+MxFQU2A==}
......@@ -6865,8 +6865,8 @@ packages:
/fs.realpath@1.0.0:
resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==}
/fsevents@2.3.2:
resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==}
/fsevents@2.3.3:
resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==}
engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
os: [darwin]
requiresBuild: true
......@@ -7780,7 +7780,7 @@ packages:
micromatch: 4.0.5
walker: 1.0.8
optionalDependencies:
fsevents: 2.3.2
fsevents: 2.3.3
dev: false
/jest-haste-map@29.5.0:
......@@ -7799,7 +7799,7 @@ packages:
micromatch: 4.0.5
walker: 1.0.8
optionalDependencies:
fsevents: 2.3.2
fsevents: 2.3.3
dev: true
/jest-jasmine2@27.5.1:
......@@ -9860,14 +9860,14 @@ packages:
engines: {node: '>=14.18.0', npm: '>=8.0.0'}
hasBin: true
optionalDependencies:
fsevents: 2.3.2
fsevents: 2.3.3
/rollup@3.21.5:
resolution: {integrity: sha512-a4NTKS4u9PusbUJcfF4IMxuqjFzjm6ifj76P54a7cKnvVzJaG12BLVR+hgU2YDGHzyMMQNxLAZWuALsn8q2oQg==}
engines: {node: '>=14.18.0', npm: '>=8.0.0'}
hasBin: true
optionalDependencies:
fsevents: 2.3.2
fsevents: 2.3.3
/run-parallel@1.2.0:
resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==}
......@@ -10795,7 +10795,7 @@ packages:
rollup: 3.20.6
terser: 5.4.0
optionalDependencies:
fsevents: 2.3.2
fsevents: 2.3.3
dev: true
/vite@4.3.5(@types/node@18.16.2)(terser@5.4.0):
......@@ -10829,7 +10829,7 @@ packages:
rollup: 3.21.5
terser: 5.4.0
optionalDependencies:
fsevents: 2.3.2
fsevents: 2.3.3
/vlq@0.2.3:
resolution: {integrity: sha512-DRibZL6DsNhIgYQ+wNdWDL2SL3bKPlVrRiBqV5yuMm++op8W4kGFtaQfCs4KEJn0wBZcHVHJ3eoywX8983k1ow==}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册