@vue-jsx-vapor/compiler 2.3.6 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +28 -37
- package/dist/index.d.cts +236 -237
- package/dist/index.d.ts +236 -237
- package/dist/index.js +2 -10
- package/package.json +6 -20
package/dist/index.cjs
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
"use strict";
|
2
1
|
//#region rolldown:runtime
|
3
2
|
var __create = Object.create;
|
4
3
|
var __defProp = Object.defineProperty;
|
@@ -516,12 +515,7 @@ function processDynamicChildren(context) {
|
|
516
515
|
prevDynamics[0].flags -= DynamicFlag.NON_TEMPLATE;
|
517
516
|
const anchor = prevDynamics[0].anchor = context.increaseId();
|
518
517
|
registerInsertion(prevDynamics, context, anchor);
|
519
|
-
} else registerInsertion(
|
520
|
-
prevDynamics,
|
521
|
-
context,
|
522
|
-
-1
|
523
|
-
/* prepend */
|
524
|
-
);
|
518
|
+
} else registerInsertion(prevDynamics, context, -1);
|
525
519
|
prevDynamics = [];
|
526
520
|
}
|
527
521
|
hasStaticTemplate = true;
|
@@ -544,10 +538,7 @@ function registerInsertion(dynamics, context, anchor) {
|
|
544
538
|
|
545
539
|
//#endregion
|
546
540
|
//#region src/transforms/transformElement.ts
|
547
|
-
const isReservedProp = /* @__PURE__ */ (0, __vue_shared.makeMap)(
|
548
|
-
// the leading comma is intentional so empty string "" is also included
|
549
|
-
",key,ref,ref_for,ref_key,"
|
550
|
-
);
|
541
|
+
const isReservedProp = /* @__PURE__ */ (0, __vue_shared.makeMap)(",key,ref,ref_for,ref_key,");
|
551
542
|
const isEventRegex = /^on[A-Z]/;
|
552
543
|
const isDirectiveRegex = /^v-[a-z]/;
|
553
544
|
const transformElement = (node, context) => {
|
@@ -1423,29 +1414,29 @@ function getBaseTransformPreset() {
|
|
1423
1414
|
}
|
1424
1415
|
|
1425
1416
|
//#endregion
|
1426
|
-
exports.DynamicFlag = DynamicFlag
|
1427
|
-
exports.IRDynamicPropsKind = IRDynamicPropsKind
|
1428
|
-
exports.IRNodeTypes = IRNodeTypes
|
1429
|
-
exports.IRSlotType = IRSlotType
|
1430
|
-
exports.TransformContext = TransformContext
|
1431
|
-
exports.compile = compile
|
1432
|
-
exports.createStructuralDirectiveTransform = createStructuralDirectiveTransform
|
1433
|
-
exports.generate = __vue_compiler_vapor.generate
|
1434
|
-
exports.isBlockOperation = isBlockOperation
|
1435
|
-
exports.transform = transform
|
1436
|
-
exports.transformChildren = transformChildren
|
1437
|
-
exports.transformElement = transformElement
|
1438
|
-
exports.transformNode = transformNode
|
1439
|
-
exports.transformTemplateRef = transformTemplateRef
|
1440
|
-
exports.transformText = transformText
|
1441
|
-
exports.transformVBind = transformVBind
|
1442
|
-
exports.transformVFor = transformVFor
|
1443
|
-
exports.transformVHtml = transformVHtml
|
1444
|
-
exports.transformVIf = transformVIf
|
1445
|
-
exports.transformVModel = transformVModel
|
1446
|
-
exports.transformVOn = transformVOn
|
1447
|
-
exports.transformVOnce = transformVOnce
|
1448
|
-
exports.transformVShow = transformVShow
|
1449
|
-
exports.transformVSlot = transformVSlot
|
1450
|
-
exports.transformVSlots = transformVSlots
|
1451
|
-
exports.transformVText = transformVText
|
1417
|
+
exports.DynamicFlag = DynamicFlag;
|
1418
|
+
exports.IRDynamicPropsKind = IRDynamicPropsKind;
|
1419
|
+
exports.IRNodeTypes = IRNodeTypes;
|
1420
|
+
exports.IRSlotType = IRSlotType;
|
1421
|
+
exports.TransformContext = TransformContext;
|
1422
|
+
exports.compile = compile;
|
1423
|
+
exports.createStructuralDirectiveTransform = createStructuralDirectiveTransform;
|
1424
|
+
exports.generate = __vue_compiler_vapor.generate;
|
1425
|
+
exports.isBlockOperation = isBlockOperation;
|
1426
|
+
exports.transform = transform;
|
1427
|
+
exports.transformChildren = transformChildren;
|
1428
|
+
exports.transformElement = transformElement;
|
1429
|
+
exports.transformNode = transformNode;
|
1430
|
+
exports.transformTemplateRef = transformTemplateRef;
|
1431
|
+
exports.transformText = transformText;
|
1432
|
+
exports.transformVBind = transformVBind;
|
1433
|
+
exports.transformVFor = transformVFor;
|
1434
|
+
exports.transformVHtml = transformVHtml;
|
1435
|
+
exports.transformVIf = transformVIf;
|
1436
|
+
exports.transformVModel = transformVModel;
|
1437
|
+
exports.transformVOn = transformVOn;
|
1438
|
+
exports.transformVOnce = transformVOnce;
|
1439
|
+
exports.transformVShow = transformVShow;
|
1440
|
+
exports.transformVSlot = transformVSlot;
|
1441
|
+
exports.transformVSlots = transformVSlots;
|
1442
|
+
exports.transformVText = transformVText;
|
package/dist/index.d.cts
CHANGED
@@ -7,44 +7,44 @@ import { Prettify } from "@vue/shared";
|
|
7
7
|
type NodeTransform = (node: BlockIRNode['node'], context: TransformContext<BlockIRNode['node']>) => void | (() => void) | (() => void)[];
|
8
8
|
type DirectiveTransform = (dir: JSXAttribute, node: JSXElement, context: TransformContext<JSXElement>) => DirectiveTransformResult | void;
|
9
9
|
interface DirectiveTransformResult {
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
10
|
+
key: SimpleExpressionNode;
|
11
|
+
value: SimpleExpressionNode;
|
12
|
+
modifier?: '.' | '^';
|
13
|
+
runtimeCamelize?: boolean;
|
14
|
+
handler?: boolean;
|
15
|
+
handlerModifiers?: SetEventIRNode['modifiers'];
|
16
|
+
model?: boolean;
|
17
|
+
modelModifiers?: string[];
|
18
18
|
}
|
19
19
|
type StructuralDirectiveTransform = (node: JSXElement, dir: JSXAttribute, context: TransformContext) => void | (() => void);
|
20
20
|
type TransformOptions = HackOptions<TransformOptions$1>;
|
21
21
|
declare class TransformContext<T extends BlockIRNode['node'] = BlockIRNode['node']> {
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
22
|
+
ir: RootIRNode;
|
23
|
+
node: T;
|
24
|
+
parent: TransformContext<RootNode | JSXElement | JSXFragment> | null;
|
25
|
+
root: TransformContext<RootNode>;
|
26
|
+
index: number;
|
27
|
+
block: BlockIRNode;
|
28
|
+
options: Required<Omit<TransformOptions, 'filename' | keyof CompilerCompatOptions>>;
|
29
|
+
template: string;
|
30
|
+
childrenTemplate: (string | null)[];
|
31
|
+
dynamic: IRDynamicInfo;
|
32
|
+
inVOnce: boolean;
|
33
|
+
inVFor: number;
|
34
|
+
comment: CommentNode[];
|
35
|
+
component: Set<string>;
|
36
|
+
directive: Set<string>;
|
37
|
+
slots: IRSlots[];
|
38
|
+
private globalId;
|
39
|
+
constructor(ir: RootIRNode, node: T, options?: TransformOptions);
|
40
|
+
enterBlock(ir: BlockIRNode, isVFor?: boolean): () => void;
|
41
|
+
increaseId: () => number;
|
42
|
+
reference(): number;
|
43
|
+
pushTemplate(content: string): number;
|
44
|
+
registerTemplate(): number;
|
45
|
+
registerEffect(expressions: SimpleExpressionNode[], ...operations: OperationNode[]): void;
|
46
|
+
registerOperation(...node: OperationNode[]): void;
|
47
|
+
create<E extends T>(node: E, index: number): TransformContext<E>;
|
48
48
|
}
|
49
49
|
declare function transform(node: RootNode, options?: TransformOptions): RootIRNode;
|
50
50
|
declare function transformNode(context: TransformContext<BlockIRNode['node']>): void;
|
@@ -53,56 +53,57 @@ declare function createStructuralDirectiveTransform(name: string | string[], fn:
|
|
53
53
|
//#endregion
|
54
54
|
//#region src/ir/component.d.ts
|
55
55
|
interface IRProp extends Omit<DirectiveTransformResult, 'value'> {
|
56
|
-
|
56
|
+
values: SimpleExpressionNode[];
|
57
57
|
}
|
58
58
|
declare enum IRDynamicPropsKind {
|
59
|
-
|
60
|
-
|
59
|
+
EXPRESSION = 0,
|
60
|
+
// v-bind="value"
|
61
|
+
ATTRIBUTE = 1,
|
61
62
|
}
|
62
63
|
type IRPropsStatic = IRProp[];
|
63
64
|
interface IRPropsDynamicExpression {
|
64
|
-
|
65
|
-
|
66
|
-
|
65
|
+
kind: IRDynamicPropsKind.EXPRESSION;
|
66
|
+
value: SimpleExpressionNode;
|
67
|
+
handler?: boolean;
|
67
68
|
}
|
68
69
|
interface IRPropsDynamicAttribute extends IRProp {
|
69
|
-
|
70
|
+
kind: IRDynamicPropsKind.ATTRIBUTE;
|
70
71
|
}
|
71
72
|
type IRProps = IRPropsStatic | IRPropsDynamicAttribute | IRPropsDynamicExpression;
|
72
73
|
interface SlotBlockIRNode extends BlockIRNode {
|
73
|
-
|
74
|
+
props?: SimpleExpressionNode;
|
74
75
|
}
|
75
76
|
declare enum IRSlotType {
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
77
|
+
STATIC = 0,
|
78
|
+
DYNAMIC = 1,
|
79
|
+
LOOP = 2,
|
80
|
+
CONDITIONAL = 3,
|
81
|
+
EXPRESSION = 4,
|
81
82
|
}
|
82
83
|
interface IRSlotsStatic {
|
83
|
-
|
84
|
-
|
84
|
+
slotType: IRSlotType.STATIC;
|
85
|
+
slots: Record<string, SlotBlockIRNode>;
|
85
86
|
}
|
86
87
|
interface IRSlotDynamicBasic {
|
87
|
-
|
88
|
-
|
89
|
-
|
88
|
+
slotType: IRSlotType.DYNAMIC;
|
89
|
+
name: SimpleExpressionNode;
|
90
|
+
fn: SlotBlockIRNode;
|
90
91
|
}
|
91
92
|
interface IRSlotDynamicLoop {
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
93
|
+
slotType: IRSlotType.LOOP;
|
94
|
+
name: SimpleExpressionNode;
|
95
|
+
fn: SlotBlockIRNode;
|
96
|
+
loop: IRFor$1;
|
96
97
|
}
|
97
98
|
interface IRSlotDynamicConditional {
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
99
|
+
slotType: IRSlotType.CONDITIONAL;
|
100
|
+
condition: SimpleExpressionNode;
|
101
|
+
positive: IRSlotDynamicBasic;
|
102
|
+
negative?: IRSlotDynamicBasic | IRSlotDynamicConditional;
|
102
103
|
}
|
103
104
|
interface IRSlotsExpression {
|
104
|
-
|
105
|
-
|
105
|
+
slotType: IRSlotType.EXPRESSION;
|
106
|
+
slots: SimpleExpressionNode;
|
106
107
|
}
|
107
108
|
type IRSlotDynamic = IRSlotDynamicBasic | IRSlotDynamicLoop | IRSlotDynamicConditional;
|
108
109
|
type IRSlots = IRSlotsStatic | IRSlotDynamic | IRSlotsExpression;
|
@@ -110,234 +111,235 @@ type IRSlots = IRSlotsStatic | IRSlotDynamic | IRSlotsExpression;
|
|
110
111
|
//#endregion
|
111
112
|
//#region src/ir/index.d.ts
|
112
113
|
declare enum IRNodeTypes {
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
114
|
+
ROOT = 0,
|
115
|
+
BLOCK = 1,
|
116
|
+
SET_PROP = 2,
|
117
|
+
SET_DYNAMIC_PROPS = 3,
|
118
|
+
SET_TEXT = 4,
|
119
|
+
SET_EVENT = 5,
|
120
|
+
SET_DYNAMIC_EVENTS = 6,
|
121
|
+
SET_HTML = 7,
|
122
|
+
SET_TEMPLATE_REF = 8,
|
123
|
+
INSERT_NODE = 9,
|
124
|
+
PREPEND_NODE = 10,
|
125
|
+
CREATE_COMPONENT_NODE = 11,
|
126
|
+
SLOT_OUTLET_NODE = 12,
|
127
|
+
DIRECTIVE = 13,
|
128
|
+
DECLARE_OLD_REF = 14,
|
129
|
+
// consider make it more general
|
130
|
+
IF = 15,
|
131
|
+
FOR = 16,
|
132
|
+
GET_TEXT_CHILD = 17,
|
133
|
+
CREATE_NODES = 18,
|
134
|
+
SET_NODES = 19,
|
133
135
|
}
|
134
136
|
interface BaseIRNode {
|
135
|
-
|
137
|
+
type: IRNodeTypes;
|
136
138
|
}
|
137
139
|
interface RootNode {
|
138
|
-
|
139
|
-
|
140
|
-
|
140
|
+
type: IRNodeTypes.ROOT;
|
141
|
+
source: string;
|
142
|
+
children: JSXFragment['children'];
|
141
143
|
}
|
142
144
|
interface BlockIRNode extends BaseIRNode {
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
145
|
+
type: IRNodeTypes.BLOCK;
|
146
|
+
node: RootNode | Node;
|
147
|
+
dynamic: IRDynamicInfo;
|
148
|
+
tempId: number;
|
149
|
+
effect: IREffect[];
|
150
|
+
operation: OperationNode[];
|
151
|
+
expressions: SimpleExpressionNode[];
|
152
|
+
returns: number[];
|
151
153
|
}
|
152
154
|
interface RootIRNode {
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
155
|
+
type: IRNodeTypes.ROOT;
|
156
|
+
node: RootNode;
|
157
|
+
source: string;
|
158
|
+
template: string[];
|
159
|
+
rootTemplateIndex?: number;
|
160
|
+
component: Set<string>;
|
161
|
+
directive: Set<string>;
|
162
|
+
block: BlockIRNode;
|
163
|
+
hasTemplateRef: boolean;
|
162
164
|
}
|
163
165
|
interface IfIRNode extends BaseIRNode {
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
166
|
+
type: IRNodeTypes.IF;
|
167
|
+
id: number;
|
168
|
+
condition: SimpleExpressionNode;
|
169
|
+
positive: BlockIRNode;
|
170
|
+
negative?: BlockIRNode | IfIRNode;
|
171
|
+
once?: boolean;
|
172
|
+
parent?: number;
|
173
|
+
anchor?: number;
|
172
174
|
}
|
173
175
|
interface IRFor {
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
176
|
+
source: SimpleExpressionNode;
|
177
|
+
value?: SimpleExpressionNode;
|
178
|
+
key?: SimpleExpressionNode;
|
179
|
+
index?: SimpleExpressionNode;
|
178
180
|
}
|
179
181
|
interface ForIRNode extends BaseIRNode, IRFor {
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
182
|
+
type: IRNodeTypes.FOR;
|
183
|
+
id: number;
|
184
|
+
keyProp?: SimpleExpressionNode;
|
185
|
+
render: BlockIRNode;
|
186
|
+
once: boolean;
|
187
|
+
component: boolean;
|
188
|
+
onlyChild: boolean;
|
189
|
+
parent?: number;
|
190
|
+
anchor?: number;
|
189
191
|
}
|
190
192
|
interface SetPropIRNode extends BaseIRNode {
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
193
|
+
type: IRNodeTypes.SET_PROP;
|
194
|
+
element: number;
|
195
|
+
prop: IRProp;
|
196
|
+
root: boolean;
|
197
|
+
tag: string;
|
196
198
|
}
|
197
199
|
interface SetDynamicPropsIRNode extends BaseIRNode {
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
200
|
+
type: IRNodeTypes.SET_DYNAMIC_PROPS;
|
201
|
+
element: number;
|
202
|
+
props: IRProps[];
|
203
|
+
root: boolean;
|
202
204
|
}
|
203
205
|
interface SetDynamicEventsIRNode extends BaseIRNode {
|
204
|
-
|
205
|
-
|
206
|
-
|
206
|
+
type: IRNodeTypes.SET_DYNAMIC_EVENTS;
|
207
|
+
element: number;
|
208
|
+
event: SimpleExpressionNode;
|
207
209
|
}
|
208
210
|
interface SetTextIRNode extends BaseIRNode {
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
211
|
+
type: IRNodeTypes.SET_TEXT;
|
212
|
+
element: number;
|
213
|
+
values: SimpleExpressionNode[];
|
214
|
+
generated?: boolean;
|
213
215
|
}
|
214
216
|
interface SetNodesIRNode extends BaseIRNode {
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
217
|
+
type: IRNodeTypes.SET_NODES;
|
218
|
+
element: number;
|
219
|
+
values: SimpleExpressionNode[];
|
220
|
+
generated?: boolean;
|
219
221
|
}
|
220
222
|
type KeyOverride = [find: string, replacement: string];
|
221
223
|
interface SetEventIRNode extends BaseIRNode {
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
224
|
+
type: IRNodeTypes.SET_EVENT;
|
225
|
+
element: number;
|
226
|
+
key: SimpleExpressionNode;
|
227
|
+
value?: SimpleExpressionNode;
|
228
|
+
modifiers: {
|
229
|
+
options: string[];
|
230
|
+
keys: string[];
|
231
|
+
nonKeys: string[];
|
232
|
+
};
|
233
|
+
keyOverride?: KeyOverride;
|
234
|
+
delegate: boolean;
|
235
|
+
/** Whether it's in effect */
|
236
|
+
effect: boolean;
|
235
237
|
}
|
236
238
|
interface SetHtmlIRNode extends BaseIRNode {
|
237
|
-
|
238
|
-
|
239
|
-
|
239
|
+
type: IRNodeTypes.SET_HTML;
|
240
|
+
element: number;
|
241
|
+
value: SimpleExpressionNode;
|
240
242
|
}
|
241
243
|
interface SetTemplateRefIRNode extends BaseIRNode {
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
244
|
+
type: IRNodeTypes.SET_TEMPLATE_REF;
|
245
|
+
element: number;
|
246
|
+
value: SimpleExpressionNode;
|
247
|
+
refFor: boolean;
|
248
|
+
effect: boolean;
|
247
249
|
}
|
248
250
|
interface CreateNodesIRNode extends BaseIRNode {
|
249
|
-
|
250
|
-
|
251
|
-
|
251
|
+
type: IRNodeTypes.CREATE_NODES;
|
252
|
+
id: number;
|
253
|
+
values?: SimpleExpressionNode[];
|
252
254
|
}
|
253
255
|
interface InsertNodeIRNode extends BaseIRNode {
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
256
|
+
type: IRNodeTypes.INSERT_NODE;
|
257
|
+
elements: number[];
|
258
|
+
parent: number;
|
259
|
+
anchor?: number;
|
258
260
|
}
|
259
261
|
interface PrependNodeIRNode extends BaseIRNode {
|
260
|
-
|
261
|
-
|
262
|
-
|
262
|
+
type: IRNodeTypes.PREPEND_NODE;
|
263
|
+
elements: number[];
|
264
|
+
parent: number;
|
263
265
|
}
|
264
266
|
interface DirectiveIRNode extends BaseIRNode {
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
267
|
+
type: IRNodeTypes.DIRECTIVE;
|
268
|
+
element: number;
|
269
|
+
dir: VaporDirectiveNode;
|
270
|
+
name: string;
|
271
|
+
builtin?: boolean;
|
272
|
+
asset?: boolean;
|
273
|
+
modelType?: 'text' | 'dynamic' | 'radio' | 'checkbox' | 'select';
|
272
274
|
}
|
273
275
|
interface CreateComponentIRNode extends BaseIRNode {
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
276
|
+
type: IRNodeTypes.CREATE_COMPONENT_NODE;
|
277
|
+
id: number;
|
278
|
+
tag: string;
|
279
|
+
props: IRProps[];
|
280
|
+
slots: IRSlots[];
|
281
|
+
asset: boolean;
|
282
|
+
root: boolean;
|
283
|
+
once: boolean;
|
284
|
+
dynamic?: SimpleExpressionNode;
|
285
|
+
parent?: number;
|
286
|
+
anchor?: number;
|
285
287
|
}
|
286
288
|
interface DeclareOldRefIRNode extends BaseIRNode {
|
287
|
-
|
288
|
-
|
289
|
+
type: IRNodeTypes.DECLARE_OLD_REF;
|
290
|
+
id: number;
|
289
291
|
}
|
290
292
|
interface SlotOutletIRNode extends BaseIRNode {
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
293
|
+
type: IRNodeTypes.SLOT_OUTLET_NODE;
|
294
|
+
id: number;
|
295
|
+
name: SimpleExpressionNode;
|
296
|
+
props: IRProps[];
|
297
|
+
fallback?: BlockIRNode;
|
298
|
+
parent?: number;
|
299
|
+
anchor?: number;
|
298
300
|
}
|
299
301
|
interface GetTextChildIRNode extends BaseIRNode {
|
300
|
-
|
301
|
-
|
302
|
+
type: IRNodeTypes.GET_TEXT_CHILD;
|
303
|
+
parent: number;
|
302
304
|
}
|
303
305
|
type IRNode = OperationNode | RootIRNode;
|
304
306
|
type OperationNode = SetPropIRNode | SetDynamicPropsIRNode | SetTextIRNode | SetNodesIRNode | SetEventIRNode | SetDynamicEventsIRNode | SetHtmlIRNode | SetTemplateRefIRNode | CreateNodesIRNode | InsertNodeIRNode | PrependNodeIRNode | DirectiveIRNode | IfIRNode | ForIRNode | CreateComponentIRNode | DeclareOldRefIRNode | SlotOutletIRNode | GetTextChildIRNode;
|
305
307
|
declare enum DynamicFlag {
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
308
|
+
NONE = 0,
|
309
|
+
/**
|
310
|
+
* This node is referenced and needs to be saved as a variable.
|
311
|
+
*/
|
312
|
+
REFERENCED = 1,
|
313
|
+
/**
|
314
|
+
* This node is not generated from template, but is generated dynamically.
|
315
|
+
*/
|
316
|
+
NON_TEMPLATE = 2,
|
317
|
+
/**
|
318
|
+
* This node needs to be inserted back into the template.
|
319
|
+
*/
|
320
|
+
INSERT = 4,
|
319
321
|
}
|
320
322
|
interface IRDynamicInfo {
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
323
|
+
id?: number;
|
324
|
+
flags: DynamicFlag;
|
325
|
+
anchor?: number;
|
326
|
+
children: IRDynamicInfo[];
|
327
|
+
template?: number;
|
328
|
+
hasDynamicChild?: boolean;
|
329
|
+
operation?: OperationNode;
|
328
330
|
}
|
329
331
|
interface IREffect {
|
330
|
-
|
331
|
-
|
332
|
+
expressions: SimpleExpressionNode[];
|
333
|
+
operations: OperationNode[];
|
332
334
|
}
|
333
335
|
type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & Pick<U, Extract<keyof U, keyof T>>;
|
334
336
|
type HackOptions<T> = Prettify<Overwrite<T, {
|
335
|
-
|
336
|
-
|
337
|
+
nodeTransforms?: NodeTransform[];
|
338
|
+
directiveTransforms?: Record<string, DirectiveTransform | undefined>;
|
337
339
|
}>>;
|
338
340
|
type VaporDirectiveNode = Overwrite<DirectiveNode, {
|
339
|
-
|
340
|
-
|
341
|
+
exp: Exclude<DirectiveNode['exp'], CompoundExpressionNode>;
|
342
|
+
arg: Exclude<DirectiveNode['arg'], CompoundExpressionNode>;
|
341
343
|
}>;
|
342
344
|
type InsertionStateTypes = IfIRNode | ForIRNode | SlotOutletIRNode | CreateComponentIRNode;
|
343
345
|
declare function isBlockOperation(op: OperationNode): op is InsertionStateTypes;
|
@@ -345,17 +347,14 @@ declare function isBlockOperation(op: OperationNode): op is InsertionStateTypes;
|
|
345
347
|
//#endregion
|
346
348
|
//#region src/compile.d.ts
|
347
349
|
interface VaporCodegenResult$1 extends Omit<VaporCodegenResult, 'ast'> {
|
348
|
-
|
349
|
-
|
350
|
+
ast: RootIRNode;
|
351
|
+
customHelpers: Set<string>;
|
350
352
|
}
|
351
353
|
declare function compile(source: JSXElement | JSXFragment | string, options?: CompilerOptions): VaporCodegenResult$1;
|
352
354
|
type CompilerOptions = HackOptions<CompilerOptions$1> & {
|
353
|
-
|
355
|
+
source?: string;
|
354
356
|
};
|
355
|
-
type TransformPreset = [
|
356
|
-
NodeTransform[],
|
357
|
-
Record<string, DirectiveTransform>
|
358
|
-
];
|
357
|
+
type TransformPreset = [NodeTransform[], Record<string, DirectiveTransform>];
|
359
358
|
|
360
359
|
//#endregion
|
361
360
|
//#region src/transforms/transformText.d.ts
|
package/dist/index.d.ts
CHANGED
@@ -7,44 +7,44 @@ import { JSXAttribute, JSXElement, JSXFragment, Node } from "@babel/types";
|
|
7
7
|
type NodeTransform = (node: BlockIRNode['node'], context: TransformContext<BlockIRNode['node']>) => void | (() => void) | (() => void)[];
|
8
8
|
type DirectiveTransform = (dir: JSXAttribute, node: JSXElement, context: TransformContext<JSXElement>) => DirectiveTransformResult | void;
|
9
9
|
interface DirectiveTransformResult {
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
10
|
+
key: SimpleExpressionNode;
|
11
|
+
value: SimpleExpressionNode;
|
12
|
+
modifier?: '.' | '^';
|
13
|
+
runtimeCamelize?: boolean;
|
14
|
+
handler?: boolean;
|
15
|
+
handlerModifiers?: SetEventIRNode['modifiers'];
|
16
|
+
model?: boolean;
|
17
|
+
modelModifiers?: string[];
|
18
18
|
}
|
19
19
|
type StructuralDirectiveTransform = (node: JSXElement, dir: JSXAttribute, context: TransformContext) => void | (() => void);
|
20
20
|
type TransformOptions = HackOptions<TransformOptions$1>;
|
21
21
|
declare class TransformContext<T extends BlockIRNode['node'] = BlockIRNode['node']> {
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
22
|
+
ir: RootIRNode;
|
23
|
+
node: T;
|
24
|
+
parent: TransformContext<RootNode | JSXElement | JSXFragment> | null;
|
25
|
+
root: TransformContext<RootNode>;
|
26
|
+
index: number;
|
27
|
+
block: BlockIRNode;
|
28
|
+
options: Required<Omit<TransformOptions, 'filename' | keyof CompilerCompatOptions>>;
|
29
|
+
template: string;
|
30
|
+
childrenTemplate: (string | null)[];
|
31
|
+
dynamic: IRDynamicInfo;
|
32
|
+
inVOnce: boolean;
|
33
|
+
inVFor: number;
|
34
|
+
comment: CommentNode[];
|
35
|
+
component: Set<string>;
|
36
|
+
directive: Set<string>;
|
37
|
+
slots: IRSlots[];
|
38
|
+
private globalId;
|
39
|
+
constructor(ir: RootIRNode, node: T, options?: TransformOptions);
|
40
|
+
enterBlock(ir: BlockIRNode, isVFor?: boolean): () => void;
|
41
|
+
increaseId: () => number;
|
42
|
+
reference(): number;
|
43
|
+
pushTemplate(content: string): number;
|
44
|
+
registerTemplate(): number;
|
45
|
+
registerEffect(expressions: SimpleExpressionNode[], ...operations: OperationNode[]): void;
|
46
|
+
registerOperation(...node: OperationNode[]): void;
|
47
|
+
create<E extends T>(node: E, index: number): TransformContext<E>;
|
48
48
|
}
|
49
49
|
declare function transform(node: RootNode, options?: TransformOptions): RootIRNode;
|
50
50
|
declare function transformNode(context: TransformContext<BlockIRNode['node']>): void;
|
@@ -53,56 +53,57 @@ declare function createStructuralDirectiveTransform(name: string | string[], fn:
|
|
53
53
|
//#endregion
|
54
54
|
//#region src/ir/component.d.ts
|
55
55
|
interface IRProp extends Omit<DirectiveTransformResult, 'value'> {
|
56
|
-
|
56
|
+
values: SimpleExpressionNode[];
|
57
57
|
}
|
58
58
|
declare enum IRDynamicPropsKind {
|
59
|
-
|
60
|
-
|
59
|
+
EXPRESSION = 0,
|
60
|
+
// v-bind="value"
|
61
|
+
ATTRIBUTE = 1,
|
61
62
|
}
|
62
63
|
type IRPropsStatic = IRProp[];
|
63
64
|
interface IRPropsDynamicExpression {
|
64
|
-
|
65
|
-
|
66
|
-
|
65
|
+
kind: IRDynamicPropsKind.EXPRESSION;
|
66
|
+
value: SimpleExpressionNode;
|
67
|
+
handler?: boolean;
|
67
68
|
}
|
68
69
|
interface IRPropsDynamicAttribute extends IRProp {
|
69
|
-
|
70
|
+
kind: IRDynamicPropsKind.ATTRIBUTE;
|
70
71
|
}
|
71
72
|
type IRProps = IRPropsStatic | IRPropsDynamicAttribute | IRPropsDynamicExpression;
|
72
73
|
interface SlotBlockIRNode extends BlockIRNode {
|
73
|
-
|
74
|
+
props?: SimpleExpressionNode;
|
74
75
|
}
|
75
76
|
declare enum IRSlotType {
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
77
|
+
STATIC = 0,
|
78
|
+
DYNAMIC = 1,
|
79
|
+
LOOP = 2,
|
80
|
+
CONDITIONAL = 3,
|
81
|
+
EXPRESSION = 4,
|
81
82
|
}
|
82
83
|
interface IRSlotsStatic {
|
83
|
-
|
84
|
-
|
84
|
+
slotType: IRSlotType.STATIC;
|
85
|
+
slots: Record<string, SlotBlockIRNode>;
|
85
86
|
}
|
86
87
|
interface IRSlotDynamicBasic {
|
87
|
-
|
88
|
-
|
89
|
-
|
88
|
+
slotType: IRSlotType.DYNAMIC;
|
89
|
+
name: SimpleExpressionNode;
|
90
|
+
fn: SlotBlockIRNode;
|
90
91
|
}
|
91
92
|
interface IRSlotDynamicLoop {
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
93
|
+
slotType: IRSlotType.LOOP;
|
94
|
+
name: SimpleExpressionNode;
|
95
|
+
fn: SlotBlockIRNode;
|
96
|
+
loop: IRFor$1;
|
96
97
|
}
|
97
98
|
interface IRSlotDynamicConditional {
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
99
|
+
slotType: IRSlotType.CONDITIONAL;
|
100
|
+
condition: SimpleExpressionNode;
|
101
|
+
positive: IRSlotDynamicBasic;
|
102
|
+
negative?: IRSlotDynamicBasic | IRSlotDynamicConditional;
|
102
103
|
}
|
103
104
|
interface IRSlotsExpression {
|
104
|
-
|
105
|
-
|
105
|
+
slotType: IRSlotType.EXPRESSION;
|
106
|
+
slots: SimpleExpressionNode;
|
106
107
|
}
|
107
108
|
type IRSlotDynamic = IRSlotDynamicBasic | IRSlotDynamicLoop | IRSlotDynamicConditional;
|
108
109
|
type IRSlots = IRSlotsStatic | IRSlotDynamic | IRSlotsExpression;
|
@@ -110,234 +111,235 @@ type IRSlots = IRSlotsStatic | IRSlotDynamic | IRSlotsExpression;
|
|
110
111
|
//#endregion
|
111
112
|
//#region src/ir/index.d.ts
|
112
113
|
declare enum IRNodeTypes {
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
114
|
+
ROOT = 0,
|
115
|
+
BLOCK = 1,
|
116
|
+
SET_PROP = 2,
|
117
|
+
SET_DYNAMIC_PROPS = 3,
|
118
|
+
SET_TEXT = 4,
|
119
|
+
SET_EVENT = 5,
|
120
|
+
SET_DYNAMIC_EVENTS = 6,
|
121
|
+
SET_HTML = 7,
|
122
|
+
SET_TEMPLATE_REF = 8,
|
123
|
+
INSERT_NODE = 9,
|
124
|
+
PREPEND_NODE = 10,
|
125
|
+
CREATE_COMPONENT_NODE = 11,
|
126
|
+
SLOT_OUTLET_NODE = 12,
|
127
|
+
DIRECTIVE = 13,
|
128
|
+
DECLARE_OLD_REF = 14,
|
129
|
+
// consider make it more general
|
130
|
+
IF = 15,
|
131
|
+
FOR = 16,
|
132
|
+
GET_TEXT_CHILD = 17,
|
133
|
+
CREATE_NODES = 18,
|
134
|
+
SET_NODES = 19,
|
133
135
|
}
|
134
136
|
interface BaseIRNode {
|
135
|
-
|
137
|
+
type: IRNodeTypes;
|
136
138
|
}
|
137
139
|
interface RootNode {
|
138
|
-
|
139
|
-
|
140
|
-
|
140
|
+
type: IRNodeTypes.ROOT;
|
141
|
+
source: string;
|
142
|
+
children: JSXFragment['children'];
|
141
143
|
}
|
142
144
|
interface BlockIRNode extends BaseIRNode {
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
145
|
+
type: IRNodeTypes.BLOCK;
|
146
|
+
node: RootNode | Node;
|
147
|
+
dynamic: IRDynamicInfo;
|
148
|
+
tempId: number;
|
149
|
+
effect: IREffect[];
|
150
|
+
operation: OperationNode[];
|
151
|
+
expressions: SimpleExpressionNode[];
|
152
|
+
returns: number[];
|
151
153
|
}
|
152
154
|
interface RootIRNode {
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
155
|
+
type: IRNodeTypes.ROOT;
|
156
|
+
node: RootNode;
|
157
|
+
source: string;
|
158
|
+
template: string[];
|
159
|
+
rootTemplateIndex?: number;
|
160
|
+
component: Set<string>;
|
161
|
+
directive: Set<string>;
|
162
|
+
block: BlockIRNode;
|
163
|
+
hasTemplateRef: boolean;
|
162
164
|
}
|
163
165
|
interface IfIRNode extends BaseIRNode {
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
166
|
+
type: IRNodeTypes.IF;
|
167
|
+
id: number;
|
168
|
+
condition: SimpleExpressionNode;
|
169
|
+
positive: BlockIRNode;
|
170
|
+
negative?: BlockIRNode | IfIRNode;
|
171
|
+
once?: boolean;
|
172
|
+
parent?: number;
|
173
|
+
anchor?: number;
|
172
174
|
}
|
173
175
|
interface IRFor {
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
176
|
+
source: SimpleExpressionNode;
|
177
|
+
value?: SimpleExpressionNode;
|
178
|
+
key?: SimpleExpressionNode;
|
179
|
+
index?: SimpleExpressionNode;
|
178
180
|
}
|
179
181
|
interface ForIRNode extends BaseIRNode, IRFor {
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
182
|
+
type: IRNodeTypes.FOR;
|
183
|
+
id: number;
|
184
|
+
keyProp?: SimpleExpressionNode;
|
185
|
+
render: BlockIRNode;
|
186
|
+
once: boolean;
|
187
|
+
component: boolean;
|
188
|
+
onlyChild: boolean;
|
189
|
+
parent?: number;
|
190
|
+
anchor?: number;
|
189
191
|
}
|
190
192
|
interface SetPropIRNode extends BaseIRNode {
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
193
|
+
type: IRNodeTypes.SET_PROP;
|
194
|
+
element: number;
|
195
|
+
prop: IRProp;
|
196
|
+
root: boolean;
|
197
|
+
tag: string;
|
196
198
|
}
|
197
199
|
interface SetDynamicPropsIRNode extends BaseIRNode {
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
200
|
+
type: IRNodeTypes.SET_DYNAMIC_PROPS;
|
201
|
+
element: number;
|
202
|
+
props: IRProps[];
|
203
|
+
root: boolean;
|
202
204
|
}
|
203
205
|
interface SetDynamicEventsIRNode extends BaseIRNode {
|
204
|
-
|
205
|
-
|
206
|
-
|
206
|
+
type: IRNodeTypes.SET_DYNAMIC_EVENTS;
|
207
|
+
element: number;
|
208
|
+
event: SimpleExpressionNode;
|
207
209
|
}
|
208
210
|
interface SetTextIRNode extends BaseIRNode {
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
211
|
+
type: IRNodeTypes.SET_TEXT;
|
212
|
+
element: number;
|
213
|
+
values: SimpleExpressionNode[];
|
214
|
+
generated?: boolean;
|
213
215
|
}
|
214
216
|
interface SetNodesIRNode extends BaseIRNode {
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
217
|
+
type: IRNodeTypes.SET_NODES;
|
218
|
+
element: number;
|
219
|
+
values: SimpleExpressionNode[];
|
220
|
+
generated?: boolean;
|
219
221
|
}
|
220
222
|
type KeyOverride = [find: string, replacement: string];
|
221
223
|
interface SetEventIRNode extends BaseIRNode {
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
224
|
+
type: IRNodeTypes.SET_EVENT;
|
225
|
+
element: number;
|
226
|
+
key: SimpleExpressionNode;
|
227
|
+
value?: SimpleExpressionNode;
|
228
|
+
modifiers: {
|
229
|
+
options: string[];
|
230
|
+
keys: string[];
|
231
|
+
nonKeys: string[];
|
232
|
+
};
|
233
|
+
keyOverride?: KeyOverride;
|
234
|
+
delegate: boolean;
|
235
|
+
/** Whether it's in effect */
|
236
|
+
effect: boolean;
|
235
237
|
}
|
236
238
|
interface SetHtmlIRNode extends BaseIRNode {
|
237
|
-
|
238
|
-
|
239
|
-
|
239
|
+
type: IRNodeTypes.SET_HTML;
|
240
|
+
element: number;
|
241
|
+
value: SimpleExpressionNode;
|
240
242
|
}
|
241
243
|
interface SetTemplateRefIRNode extends BaseIRNode {
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
244
|
+
type: IRNodeTypes.SET_TEMPLATE_REF;
|
245
|
+
element: number;
|
246
|
+
value: SimpleExpressionNode;
|
247
|
+
refFor: boolean;
|
248
|
+
effect: boolean;
|
247
249
|
}
|
248
250
|
interface CreateNodesIRNode extends BaseIRNode {
|
249
|
-
|
250
|
-
|
251
|
-
|
251
|
+
type: IRNodeTypes.CREATE_NODES;
|
252
|
+
id: number;
|
253
|
+
values?: SimpleExpressionNode[];
|
252
254
|
}
|
253
255
|
interface InsertNodeIRNode extends BaseIRNode {
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
256
|
+
type: IRNodeTypes.INSERT_NODE;
|
257
|
+
elements: number[];
|
258
|
+
parent: number;
|
259
|
+
anchor?: number;
|
258
260
|
}
|
259
261
|
interface PrependNodeIRNode extends BaseIRNode {
|
260
|
-
|
261
|
-
|
262
|
-
|
262
|
+
type: IRNodeTypes.PREPEND_NODE;
|
263
|
+
elements: number[];
|
264
|
+
parent: number;
|
263
265
|
}
|
264
266
|
interface DirectiveIRNode extends BaseIRNode {
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
267
|
+
type: IRNodeTypes.DIRECTIVE;
|
268
|
+
element: number;
|
269
|
+
dir: VaporDirectiveNode;
|
270
|
+
name: string;
|
271
|
+
builtin?: boolean;
|
272
|
+
asset?: boolean;
|
273
|
+
modelType?: 'text' | 'dynamic' | 'radio' | 'checkbox' | 'select';
|
272
274
|
}
|
273
275
|
interface CreateComponentIRNode extends BaseIRNode {
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
276
|
+
type: IRNodeTypes.CREATE_COMPONENT_NODE;
|
277
|
+
id: number;
|
278
|
+
tag: string;
|
279
|
+
props: IRProps[];
|
280
|
+
slots: IRSlots[];
|
281
|
+
asset: boolean;
|
282
|
+
root: boolean;
|
283
|
+
once: boolean;
|
284
|
+
dynamic?: SimpleExpressionNode;
|
285
|
+
parent?: number;
|
286
|
+
anchor?: number;
|
285
287
|
}
|
286
288
|
interface DeclareOldRefIRNode extends BaseIRNode {
|
287
|
-
|
288
|
-
|
289
|
+
type: IRNodeTypes.DECLARE_OLD_REF;
|
290
|
+
id: number;
|
289
291
|
}
|
290
292
|
interface SlotOutletIRNode extends BaseIRNode {
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
293
|
+
type: IRNodeTypes.SLOT_OUTLET_NODE;
|
294
|
+
id: number;
|
295
|
+
name: SimpleExpressionNode;
|
296
|
+
props: IRProps[];
|
297
|
+
fallback?: BlockIRNode;
|
298
|
+
parent?: number;
|
299
|
+
anchor?: number;
|
298
300
|
}
|
299
301
|
interface GetTextChildIRNode extends BaseIRNode {
|
300
|
-
|
301
|
-
|
302
|
+
type: IRNodeTypes.GET_TEXT_CHILD;
|
303
|
+
parent: number;
|
302
304
|
}
|
303
305
|
type IRNode = OperationNode | RootIRNode;
|
304
306
|
type OperationNode = SetPropIRNode | SetDynamicPropsIRNode | SetTextIRNode | SetNodesIRNode | SetEventIRNode | SetDynamicEventsIRNode | SetHtmlIRNode | SetTemplateRefIRNode | CreateNodesIRNode | InsertNodeIRNode | PrependNodeIRNode | DirectiveIRNode | IfIRNode | ForIRNode | CreateComponentIRNode | DeclareOldRefIRNode | SlotOutletIRNode | GetTextChildIRNode;
|
305
307
|
declare enum DynamicFlag {
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
308
|
+
NONE = 0,
|
309
|
+
/**
|
310
|
+
* This node is referenced and needs to be saved as a variable.
|
311
|
+
*/
|
312
|
+
REFERENCED = 1,
|
313
|
+
/**
|
314
|
+
* This node is not generated from template, but is generated dynamically.
|
315
|
+
*/
|
316
|
+
NON_TEMPLATE = 2,
|
317
|
+
/**
|
318
|
+
* This node needs to be inserted back into the template.
|
319
|
+
*/
|
320
|
+
INSERT = 4,
|
319
321
|
}
|
320
322
|
interface IRDynamicInfo {
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
323
|
+
id?: number;
|
324
|
+
flags: DynamicFlag;
|
325
|
+
anchor?: number;
|
326
|
+
children: IRDynamicInfo[];
|
327
|
+
template?: number;
|
328
|
+
hasDynamicChild?: boolean;
|
329
|
+
operation?: OperationNode;
|
328
330
|
}
|
329
331
|
interface IREffect {
|
330
|
-
|
331
|
-
|
332
|
+
expressions: SimpleExpressionNode[];
|
333
|
+
operations: OperationNode[];
|
332
334
|
}
|
333
335
|
type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & Pick<U, Extract<keyof U, keyof T>>;
|
334
336
|
type HackOptions<T> = Prettify<Overwrite<T, {
|
335
|
-
|
336
|
-
|
337
|
+
nodeTransforms?: NodeTransform[];
|
338
|
+
directiveTransforms?: Record<string, DirectiveTransform | undefined>;
|
337
339
|
}>>;
|
338
340
|
type VaporDirectiveNode = Overwrite<DirectiveNode, {
|
339
|
-
|
340
|
-
|
341
|
+
exp: Exclude<DirectiveNode['exp'], CompoundExpressionNode>;
|
342
|
+
arg: Exclude<DirectiveNode['arg'], CompoundExpressionNode>;
|
341
343
|
}>;
|
342
344
|
type InsertionStateTypes = IfIRNode | ForIRNode | SlotOutletIRNode | CreateComponentIRNode;
|
343
345
|
declare function isBlockOperation(op: OperationNode): op is InsertionStateTypes;
|
@@ -345,17 +347,14 @@ declare function isBlockOperation(op: OperationNode): op is InsertionStateTypes;
|
|
345
347
|
//#endregion
|
346
348
|
//#region src/compile.d.ts
|
347
349
|
interface VaporCodegenResult$1 extends Omit<VaporCodegenResult, 'ast'> {
|
348
|
-
|
349
|
-
|
350
|
+
ast: RootIRNode;
|
351
|
+
customHelpers: Set<string>;
|
350
352
|
}
|
351
353
|
declare function compile(source: JSXElement | JSXFragment | string, options?: CompilerOptions): VaporCodegenResult$1;
|
352
354
|
type CompilerOptions = HackOptions<CompilerOptions$1> & {
|
353
|
-
|
355
|
+
source?: string;
|
354
356
|
};
|
355
|
-
type TransformPreset = [
|
356
|
-
NodeTransform[],
|
357
|
-
Record<string, DirectiveTransform>
|
358
|
-
];
|
357
|
+
type TransformPreset = [NodeTransform[], Record<string, DirectiveTransform>];
|
359
358
|
|
360
359
|
//#endregion
|
361
360
|
//#region src/transforms/transformText.d.ts
|
package/dist/index.js
CHANGED
@@ -492,12 +492,7 @@ function processDynamicChildren(context) {
|
|
492
492
|
prevDynamics[0].flags -= DynamicFlag.NON_TEMPLATE;
|
493
493
|
const anchor = prevDynamics[0].anchor = context.increaseId();
|
494
494
|
registerInsertion(prevDynamics, context, anchor);
|
495
|
-
} else registerInsertion(
|
496
|
-
prevDynamics,
|
497
|
-
context,
|
498
|
-
-1
|
499
|
-
/* prepend */
|
500
|
-
);
|
495
|
+
} else registerInsertion(prevDynamics, context, -1);
|
501
496
|
prevDynamics = [];
|
502
497
|
}
|
503
498
|
hasStaticTemplate = true;
|
@@ -520,10 +515,7 @@ function registerInsertion(dynamics, context, anchor) {
|
|
520
515
|
|
521
516
|
//#endregion
|
522
517
|
//#region src/transforms/transformElement.ts
|
523
|
-
const isReservedProp = /* @__PURE__ */ makeMap(
|
524
|
-
// the leading comma is intentional so empty string "" is also included
|
525
|
-
",key,ref,ref_for,ref_key,"
|
526
|
-
);
|
518
|
+
const isReservedProp = /* @__PURE__ */ makeMap(",key,ref,ref_for,ref_key,");
|
527
519
|
const isEventRegex = /^on[A-Z]/;
|
528
520
|
const isDirectiveRegex = /^v-[a-z]/;
|
529
521
|
const transformElement = (node, context) => {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vue-jsx-vapor/compiler",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.4.1",
|
4
4
|
"description": "Vue JSX Vapor Compiler",
|
5
5
|
"type": "module",
|
6
6
|
"keywords": [
|
@@ -26,22 +26,8 @@
|
|
26
26
|
"types": "dist/index.d.ts",
|
27
27
|
"exports": {
|
28
28
|
".": {
|
29
|
-
"
|
30
|
-
"
|
31
|
-
"import": "./dist/index.js"
|
32
|
-
},
|
33
|
-
"./*": "./*"
|
34
|
-
},
|
35
|
-
"typesVersions": {
|
36
|
-
"*": {
|
37
|
-
"*": [
|
38
|
-
"./dist/*",
|
39
|
-
"./*"
|
40
|
-
]
|
41
|
-
}
|
42
|
-
},
|
43
|
-
"publishConfig": {
|
44
|
-
".": {
|
29
|
+
"types": "./dist/index.d.ts",
|
30
|
+
"jsx-vapor-dev": "./src/index.ts",
|
45
31
|
"require": "./dist/index.cjs",
|
46
32
|
"import": "./dist/index.js"
|
47
33
|
},
|
@@ -50,9 +36,9 @@
|
|
50
36
|
"dependencies": {
|
51
37
|
"@babel/parser": "^7.26.8",
|
52
38
|
"@babel/types": "^7.26.8",
|
53
|
-
"@vue/compiler-dom": "https://pkg.pr.new/@vue/compiler-dom@
|
54
|
-
"@vue/compiler-vapor": "https://pkg.pr.new/@vue/compiler-vapor@
|
55
|
-
"@vue/shared": "https://pkg.pr.new/@vue/shared@
|
39
|
+
"@vue/compiler-dom": "https://pkg.pr.new/@vue/compiler-dom@46e707d",
|
40
|
+
"@vue/compiler-vapor": "https://pkg.pr.new/@vue/compiler-vapor@46e707d",
|
41
|
+
"@vue/shared": "https://pkg.pr.new/@vue/shared@46e707d"
|
56
42
|
},
|
57
43
|
"scripts": {
|
58
44
|
"build": "tsdown",
|