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

wip(uts): compiler

上级 de241521
......@@ -11,7 +11,7 @@ describe('compiler:codegen', () => {
test(`function:kotlin`, () => {
assert(
`<view/>`,
`@Suppress("UNUSED_PARAMETER") function PagesIndexIndexRender(ctx: PagesIndexIndex): VNode | null {\n return createElementVNode("view")\n}`,
`@Suppress("UNUSED_PARAMETER") function PagesIndexIndexRender(_ctx: PagesIndexIndex): VNode | null {\n return createElementVNode("view")\n}`,
{
targetLanguage: 'kotlin',
mode: 'function',
......
......@@ -56,7 +56,7 @@ export default 'pages.json'`
${imports
.map((p) => {
const className = genClassName(p)
return `import ${className}Class from './${p}.uvue'`
return `import { ${className}Class } from './${p}.uvue'`
})
.join('\n')}
const __uniRoutes = [${routes.join(',\n')}]
......
......@@ -15,7 +15,7 @@ class ${filename} extends ${parentClass} {
return ${filename}Render(ctx)
}
}
export default UTSAndroid.getKotlinClass(${filename})
export const ${filename}Class = UTSAndroid.getKotlinClass(${filename})
`
}
return (
......@@ -29,7 +29,7 @@ class ${filename} extends ${parentClass} {
}
}
export default UTSAndroid.getKotlinClass(${filename})
export const ${filename}Class = UTSAndroid.getKotlinClass(${filename})
`
)
}
......
......@@ -59,6 +59,7 @@ function createCodegenContext(
targetLanguage,
mode = 'default',
prefixIdentifiers = false,
bindingMetadata = {},
sourceMap = false,
filename = '',
}: CodegenOptions
......@@ -67,6 +68,7 @@ function createCodegenContext(
targetLanguage,
mode,
prefixIdentifiers,
bindingMetadata,
sourceMap,
filename,
source: ast.loc.source,
......@@ -84,7 +86,7 @@ function createCodegenContext(
if (context.map) {
if (node) {
let name
if (node.type === NodeTypes.SIMPLE_EXPRESSION && !node.isStatic) {
if (node.type === NodeTypes.SIMPLE_EXPRESSION) {
const content = node.content.replace(/^_ctx\./, '')
if (content !== node.content && isSimpleIdentifier(content)) {
name = content
......
import { CompilerError } from '@vue/compiler-core'
import { BindingMetadata, CompilerError } from '@vue/compiler-core'
import { RawSourceMap } from 'source-map'
import { DirectiveTransform, NodeTransform } from './transform'
......@@ -9,6 +9,11 @@ interface SharedTransformCodegenOptions {
* @default false
*/
prefixIdentifiers?: boolean
/**
* Optional binding metadata analyzed from script - used to optimize
* binding access when `prefixIdentifiers` is enabled.
*/
bindingMetadata?: BindingMetadata
/**
* Filename for source map generation.
* Also used for self-recursive reference in templates
......
......@@ -117,6 +117,7 @@ export function createTransformContext(
targetLanguage,
selfName: nameMatch && capitalize(camelize(nameMatch[1])),
prefixIdentifiers,
bindingMetadata: {},
nodeTransforms,
directiveTransforms,
isBuiltInComponent,
......
......@@ -6,5 +6,5 @@ export function genRenderFunctionDecl({
}: CompilerOptions): string {
return `${
targetLanguage === 'kotlin' ? '@Suppress("UNUSED_PARAMETER") ' : ''
}function ${filename}Render(ctx: ${filename}): VNode | null`
}function ${filename}Render(_ctx: ${filename}): VNode | null`
}
......@@ -74,6 +74,7 @@ export function uniAppUVuePlugin(): Plugin {
| 'swift',
mode: 'function',
filename: className,
prefixIdentifiers: true,
})
: ''),
})
......
......@@ -1268,7 +1268,9 @@ var shims = /*#__PURE__*/Object.freeze({
const compressImage = {
args(fromArgs, toArgs) {
// https://developers.weixin.qq.com/community/develop/doc/000c08940c865011298e0a43256800?highLine=compressHeight
// @ts-expect-error
if (fromArgs.compressedHeight && !toArgs.compressHeight) {
// @ts-expect-error
toArgs.compressHeight = fromArgs.compressedHeight;
}
// @ts-expect-error
......
......@@ -19,6 +19,7 @@ const DEFAULT_IMPORTS = [
'io.dcloud.uts.*',
'io.dcloud.uts.framework.*',
'io.dcloud.uts.vue.*',
'io.dcloud.uts.vue.shared.*',
'io.dcloud.uts.vue.reactivity.*',
]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册