1
1
import {
2
+ type TransformOptions as BaseTransformOptions ,
2
3
type CommentNode ,
3
4
type CompilerCompatOptions ,
4
5
type SimpleExpressionNode ,
5
6
defaultOnError ,
6
7
defaultOnWarn ,
7
8
} from '@vue/compiler-dom'
8
9
import { EMPTY_OBJ , NOOP , extend , isArray } from '@vue/shared'
10
+ import { newBlock , newDynamic } from './transforms/utils'
11
+ import { isConstantExpression } from './utils'
9
12
import {
13
+ type BlockIRNode ,
10
14
DynamicFlag ,
15
+ type HackOptions ,
11
16
type IRDynamicInfo ,
12
17
IRNodeTypes ,
13
18
type IRSlots ,
14
19
type OperationNode ,
20
+ type RootIRNode ,
21
+ type RootNode ,
15
22
type VaporDirectiveNode ,
16
- } from '@vue-vapor/compiler-vapor'
17
- import { newBlock , newDynamic } from './transforms/utils'
18
- import { isConstantExpression } from './utils'
19
- import type { CompilerOptions } from './compile'
20
- import type { JSXAttribute , JSXElement } from '@babel/types'
21
- import type { BlockIRNode , RootIRNode , RootNode } from './ir/index'
23
+ } from './ir/index'
24
+ import type { JSXElement , JSXFragment } from '@babel/types'
22
25
23
26
export type NodeTransform = (
24
27
node : BlockIRNode [ 'node' ] ,
@@ -32,17 +35,16 @@ export type DirectiveTransform = (
32
35
) => DirectiveTransformResult | void
33
36
34
37
export interface DirectiveTransformResult {
35
- key : JSXAttribute [ 'name' ]
36
- value : JSXAttribute [ 'value' ]
38
+ key : SimpleExpressionNode
39
+ value : SimpleExpressionNode
37
40
modifier ?: '.' | '^'
38
41
runtimeCamelize ?: boolean
39
42
handler ?: boolean
40
43
model ?: boolean
41
44
modelModifiers ?: string [ ]
42
45
}
43
46
44
- export type TransformOptions = CompilerOptions
45
-
47
+ export type TransformOptions = HackOptions < BaseTransformOptions >
46
48
const defaultOptions = {
47
49
filename : '' ,
48
50
prefixIdentifiers : false ,
@@ -70,7 +72,7 @@ const defaultOptions = {
70
72
export class TransformContext <
71
73
T extends BlockIRNode [ 'node' ] = BlockIRNode [ 'node' ] ,
72
74
> {
73
- parent : TransformContext < RootNode > | null = null
75
+ parent : TransformContext < RootNode | JSXElement | JSXFragment > | null = null
74
76
root : TransformContext < RootNode >
75
77
index : number = 0
76
78
@@ -100,7 +102,7 @@ export class TransformContext<
100
102
options : TransformOptions = { } ,
101
103
) {
102
104
this . options = extend ( { } , defaultOptions , options )
103
- this . root = this as TransformContext < T >
105
+ this . root = this as TransformContext < RootNode >
104
106
}
105
107
106
108
enterBlock ( ir : BlockIRNode , isVFor : boolean = false ) : ( ) => void {
0 commit comments