@vue-jsx-vapor/compiler 2.0.1 → 2.1.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 CHANGED
@@ -5,6 +5,13 @@ var _parser = require('@babel/parser');
5
5
  var _compilervapor = require('@vue/compiler-vapor');
6
6
  var _shared = require('@vue/shared');
7
7
 
8
+ // src/generate.ts
9
+
10
+
11
+
12
+
13
+
14
+
8
15
  // src/ir/component.ts
9
16
  var IRDynamicPropsKind = /* @__PURE__ */ ((IRDynamicPropsKind2) => {
10
17
  IRDynamicPropsKind2[IRDynamicPropsKind2["EXPRESSION"] = 0] = "EXPRESSION";
@@ -33,14 +40,15 @@ var IRNodeTypes = /* @__PURE__ */ ((IRNodeTypes2) => {
33
40
  IRNodeTypes2[IRNodeTypes2["SET_TEMPLATE_REF"] = 8] = "SET_TEMPLATE_REF";
34
41
  IRNodeTypes2[IRNodeTypes2["INSERT_NODE"] = 9] = "INSERT_NODE";
35
42
  IRNodeTypes2[IRNodeTypes2["PREPEND_NODE"] = 10] = "PREPEND_NODE";
36
- IRNodeTypes2[IRNodeTypes2["CREATE_TEXT_NODE"] = 11] = "CREATE_TEXT_NODE";
37
- IRNodeTypes2[IRNodeTypes2["CREATE_COMPONENT_NODE"] = 12] = "CREATE_COMPONENT_NODE";
38
- IRNodeTypes2[IRNodeTypes2["SLOT_OUTLET_NODE"] = 13] = "SLOT_OUTLET_NODE";
39
- IRNodeTypes2[IRNodeTypes2["DIRECTIVE"] = 14] = "DIRECTIVE";
40
- IRNodeTypes2[IRNodeTypes2["DECLARE_OLD_REF"] = 15] = "DECLARE_OLD_REF";
41
- IRNodeTypes2[IRNodeTypes2["IF"] = 16] = "IF";
42
- IRNodeTypes2[IRNodeTypes2["FOR"] = 17] = "FOR";
43
- IRNodeTypes2[IRNodeTypes2["GET_TEXT_CHILD"] = 18] = "GET_TEXT_CHILD";
43
+ IRNodeTypes2[IRNodeTypes2["CREATE_COMPONENT_NODE"] = 11] = "CREATE_COMPONENT_NODE";
44
+ IRNodeTypes2[IRNodeTypes2["SLOT_OUTLET_NODE"] = 12] = "SLOT_OUTLET_NODE";
45
+ IRNodeTypes2[IRNodeTypes2["DIRECTIVE"] = 13] = "DIRECTIVE";
46
+ IRNodeTypes2[IRNodeTypes2["DECLARE_OLD_REF"] = 14] = "DECLARE_OLD_REF";
47
+ IRNodeTypes2[IRNodeTypes2["IF"] = 15] = "IF";
48
+ IRNodeTypes2[IRNodeTypes2["FOR"] = 16] = "FOR";
49
+ IRNodeTypes2[IRNodeTypes2["GET_TEXT_CHILD"] = 17] = "GET_TEXT_CHILD";
50
+ IRNodeTypes2[IRNodeTypes2["CREATE_NODES"] = 18] = "CREATE_NODES";
51
+ IRNodeTypes2[IRNodeTypes2["SET_NODES"] = 19] = "SET_NODES";
44
52
  return IRNodeTypes2;
45
53
  })(IRNodeTypes || {});
46
54
  var DynamicFlag = /* @__PURE__ */ ((DynamicFlag2) => {
@@ -50,6 +58,49 @@ var DynamicFlag = /* @__PURE__ */ ((DynamicFlag2) => {
50
58
  DynamicFlag2[DynamicFlag2["INSERT"] = 4] = "INSERT";
51
59
  return DynamicFlag2;
52
60
  })(DynamicFlag || {});
61
+ function isBlockOperation(op) {
62
+ const type = op.type;
63
+ return type === 11 /* CREATE_COMPONENT_NODE */ || type === 12 /* SLOT_OUTLET_NODE */ || type === 15 /* IF */ || type === 16 /* FOR */;
64
+ }
65
+
66
+ // src/generate.ts
67
+ var customGenOperation = (oper, context) => {
68
+ if (oper.type === 18 /* CREATE_NODES */) {
69
+ return genCreateNodes(oper, context);
70
+ } else if (oper.type === 19 /* SET_NODES */) {
71
+ return genSetNodes(oper, context);
72
+ }
73
+ };
74
+ function genSetNodes(oper, context) {
75
+ const { helper } = context;
76
+ const { element, values, generated } = oper;
77
+ return [
78
+ _compilervapor.NEWLINE,
79
+ ..._compilervapor.genCall.call(void 0,
80
+ helper("setNodes"),
81
+ `${generated ? "x" : "n"}${element}`,
82
+ combineValues(values, context)
83
+ )
84
+ ];
85
+ }
86
+ function genCreateNodes(oper, context) {
87
+ const { helper } = context;
88
+ const { id, values } = oper;
89
+ return [
90
+ _compilervapor.NEWLINE,
91
+ `const n${id} = `,
92
+ ..._compilervapor.genCall.call(void 0, helper("createNodes"), values && combineValues(values, context))
93
+ ];
94
+ }
95
+ function combineValues(values, context) {
96
+ return values.flatMap((value, i) => {
97
+ const exp = _compilervapor.genExpression.call(void 0, value, context);
98
+ if (i > 0) {
99
+ exp.unshift(", ");
100
+ }
101
+ return exp;
102
+ });
103
+ }
53
104
 
54
105
  // src/transform.ts
55
106
 
@@ -217,17 +268,25 @@ function resolveNode(node, context) {
217
268
  const props = node.openingElement.attributes.reduce(
218
269
  (result, attr) => {
219
270
  if (attr.type === "JSXAttribute") {
220
- if (tagType === _compilerdom.ElementTypes.COMPONENT) {
221
- result.push(resolveDirectiveNode(attr, context));
222
- } else {
223
- result.push({
271
+ result.push(
272
+ _optionalChain([attr, 'access', _9 => _9.value, 'optionalAccess', _10 => _10.type]) === "StringLiteral" ? {
224
273
  type: _compilerdom.NodeTypes.ATTRIBUTE,
225
274
  name: String(attr.name.name),
226
275
  nameLoc: resolveLocation(attr.name.loc, context),
227
276
  value: resolveValue(attr.value, context),
228
277
  loc: resolveLocation(attr.loc, context)
229
- });
230
- }
278
+ } : resolveDirectiveNode(attr, context)
279
+ );
280
+ } else if (attr.type === "JSXSpreadAttribute") {
281
+ result.push({
282
+ type: _compilerdom.NodeTypes.DIRECTIVE,
283
+ name: "bind",
284
+ rawName: getText(attr, context),
285
+ exp: resolveExpression(attr.argument, context),
286
+ arg: void 0,
287
+ loc: resolveLocation(node.loc, context),
288
+ modifiers: []
289
+ });
231
290
  }
232
291
  return result;
233
292
  },
@@ -249,34 +308,35 @@ var namespaceRE = /^(?:\$([\w-]+)\$)?([\w-]+)?/;
249
308
  function resolveDirectiveNode(node, context, withFn = false) {
250
309
  const { value, name } = node;
251
310
  let nameString = name.type === "JSXNamespacedName" ? name.namespace.name : name.type === "JSXIdentifier" ? name.name : "";
252
- let argString = name.type === "JSXNamespacedName" ? name.name.name : "";
253
- if (name.type !== "JSXNamespacedName" && !argString) {
254
- const [newName, modifiers2] = nameString.split("_");
255
- nameString = newName;
256
- argString = `_${modifiers2}`;
257
- }
311
+ const isDirective = nameString.startsWith("v-");
258
312
  let modifiers = [];
259
313
  let isStatic = true;
260
- const result = argString.match(namespaceRE);
261
- if (result) {
262
- let modifierString = "";
263
- [, argString, modifierString] = result;
264
- if (argString) {
265
- argString = argString.replaceAll("_", ".");
266
- isStatic = false;
267
- if (modifierString && modifierString.startsWith("_"))
268
- modifiers = modifierString.slice(1).split("_");
269
- } else if (modifierString) {
270
- ;
271
- [argString, ...modifiers] = modifierString.split("_");
314
+ let argString = name.type === "JSXNamespacedName" ? name.name.name : "";
315
+ if (name.type !== "JSXNamespacedName" && !argString) {
316
+ ;
317
+ [nameString, ...modifiers] = nameString.split("_");
318
+ } else {
319
+ const result = argString.match(namespaceRE);
320
+ if (result) {
321
+ let modifierString = "";
322
+ [, argString, modifierString] = result;
323
+ if (argString) {
324
+ argString = argString.replaceAll("_", ".");
325
+ isStatic = false;
326
+ if (modifierString && modifierString.startsWith("_"))
327
+ modifiers = modifierString.slice(1).split("_");
328
+ } else if (modifierString) {
329
+ ;
330
+ [argString, ...modifiers] = modifierString.split("_");
331
+ }
272
332
  }
273
333
  }
274
- const arg = argString && name.type === "JSXNamespacedName" ? resolveSimpleExpression(argString, isStatic, name.name.loc) : void 0;
334
+ const arg = isDirective ? argString && name.type === "JSXNamespacedName" ? resolveSimpleExpression(argString, isStatic, name.name.loc) : void 0 : resolveSimpleExpression(nameString, true, name.loc);
275
335
  const exp = value ? withFn && value.type === "JSXExpressionContainer" ? resolveExpressionWithFn(value.expression, context) : resolveExpression(value, context) : void 0;
276
336
  return {
277
337
  type: _compilerdom.NodeTypes.DIRECTIVE,
278
- name: nameString.slice(2),
279
- rawName: `${nameString}:${argString}`,
338
+ name: isDirective ? nameString.slice(2) : "bind",
339
+ rawName: getText(name, context),
280
340
  exp,
281
341
  arg,
282
342
  loc: resolveLocation(node.loc, context),
@@ -305,7 +365,7 @@ function isJSXComponent(node) {
305
365
  }
306
366
  }
307
367
  function findProp(expression, key) {
308
- if (_optionalChain([expression, 'optionalAccess', _9 => _9.type]) === "JSXElement") {
368
+ if (_optionalChain([expression, 'optionalAccess', _11 => _11.type]) === "JSXElement") {
309
369
  for (const attr of expression.openingElement.attributes) {
310
370
  const name = attr.type === "JSXAttribute" && (attr.name.type === "JSXIdentifier" ? attr.name.name : attr.name.type === "JSXNamespacedName" ? attr.name.namespace.name : "").split("_")[0];
311
371
  if (name && (_shared.isString.call(void 0, key) ? name === key : key.test(name))) {
@@ -358,6 +418,7 @@ function wrapFragment(node) {
358
418
  ]);
359
419
  }
360
420
  var EMPTY_EXPRESSION = _compilerdom.createSimpleExpression.call(void 0, "", true);
421
+ var isFragmentNode = (node) => node.type === 0 /* ROOT */ || node.type === "JSXFragment" || node.type === "JSXElement" && !!isTemplate(node);
361
422
 
362
423
  // src/transform.ts
363
424
  var defaultOptions = {
@@ -582,18 +643,15 @@ function processDynamicChildren(context) {
582
643
  context.childrenTemplate[index - prevDynamics.length] = `<!>`;
583
644
  prevDynamics[0].flags -= 2 /* NON_TEMPLATE */;
584
645
  const anchor = prevDynamics[0].anchor = context.increaseId();
585
- context.registerOperation({
586
- type: 9 /* INSERT_NODE */,
587
- elements: prevDynamics.map((child2) => child2.id),
588
- parent: context.reference(),
589
- anchor
590
- });
646
+ registerInsertion(prevDynamics, context, anchor);
591
647
  } else {
592
- context.registerOperation({
593
- type: 10 /* PREPEND_NODE */,
594
- elements: prevDynamics.map((child2) => child2.id),
595
- parent: context.reference()
596
- });
648
+ prevDynamics[0].flags -= 2 /* NON_TEMPLATE */;
649
+ registerInsertion(
650
+ prevDynamics,
651
+ context,
652
+ -1
653
+ /* prepend */
654
+ );
597
655
  }
598
656
  prevDynamics = [];
599
657
  }
@@ -601,11 +659,23 @@ function processDynamicChildren(context) {
601
659
  }
602
660
  }
603
661
  if (prevDynamics.length) {
604
- context.registerOperation({
605
- type: 9 /* INSERT_NODE */,
606
- elements: prevDynamics.map((child) => child.id),
607
- parent: context.reference()
608
- });
662
+ registerInsertion(prevDynamics, context);
663
+ }
664
+ }
665
+ function registerInsertion(dynamics, context, anchor) {
666
+ for (const child of dynamics) {
667
+ console.log(child);
668
+ if (child.template != null) {
669
+ context.registerOperation({
670
+ type: 9 /* INSERT_NODE */,
671
+ elements: dynamics.map((child2) => child2.id),
672
+ parent: context.reference(),
673
+ anchor
674
+ });
675
+ } else if (child.operation && isBlockOperation(child.operation)) {
676
+ child.operation.parent = context.reference();
677
+ child.operation.anchor = anchor;
678
+ }
609
679
  }
610
680
  }
611
681
 
@@ -667,8 +737,8 @@ function transformComponentElement(tag, propsResult, singleRoot, context) {
667
737
  context.component.add(tag);
668
738
  }
669
739
  context.dynamic.flags |= 2 /* NON_TEMPLATE */ | 4 /* INSERT */;
670
- context.registerOperation({
671
- type: 12 /* CREATE_COMPONENT_NODE */,
740
+ context.dynamic.operation = {
741
+ type: 11 /* CREATE_COMPONENT_NODE */,
672
742
  id: context.reference(),
673
743
  tag,
674
744
  props: propsResult[0] ? propsResult[1] : [propsResult[1]],
@@ -676,7 +746,7 @@ function transformComponentElement(tag, propsResult, singleRoot, context) {
676
746
  root: singleRoot,
677
747
  slots: [...context.slots],
678
748
  once: context.inVOnce
679
- });
749
+ };
680
750
  context.slots = [];
681
751
  }
682
752
  function transformNativeElement(tag, propsResult, singleRoot, context) {
@@ -775,7 +845,7 @@ function transformProp(prop, node, context) {
775
845
  if (prop.type === "JSXSpreadAttribute") return;
776
846
  let name = prop.name.type === "JSXIdentifier" ? prop.name.name : prop.name.type === "JSXNamespacedName" ? prop.name.namespace.name : "";
777
847
  name = name.split("_")[0];
778
- if (!isDirectiveRegex.test(name) && (!prop.value || prop.value.type === "StringLiteral")) {
848
+ if (!isDirectiveRegex.test(name) && !isEventRegex.test(name) && (!prop.value || prop.value.type === "StringLiteral")) {
779
849
  if (isReservedProp(name)) return;
780
850
  return {
781
851
  key: resolveSimpleExpression(name, true, prop.name.loc),
@@ -833,14 +903,14 @@ function mergePropValues(existing, incoming) {
833
903
  var transformTemplateRef = (node, context) => {
834
904
  if (node.type !== "JSXElement") return;
835
905
  const dir = findProp(node, "ref");
836
- if (!_optionalChain([dir, 'optionalAccess', _10 => _10.value])) return;
906
+ if (!_optionalChain([dir, 'optionalAccess', _12 => _12.value])) return;
837
907
  context.ir.hasTemplateRef = true;
838
908
  const value = resolveExpression(dir.value, context);
839
909
  return () => {
840
910
  const id = context.reference();
841
911
  const effect = !isConstantExpression(value);
842
912
  effect && context.registerOperation({
843
- type: 15 /* DECLARE_OLD_REF */,
913
+ type: 14 /* DECLARE_OLD_REF */,
844
914
  id
845
915
  });
846
916
  context.registerEffect([value], {
@@ -862,7 +932,7 @@ function processConditionalExpression(node, context) {
862
932
  const condition = resolveExpression(test, context);
863
933
  const [branch, onExit] = createBranch(consequent, context);
864
934
  const operation = {
865
- type: 16 /* IF */,
935
+ type: 15 /* IF */,
866
936
  id,
867
937
  condition,
868
938
  positive: branch,
@@ -871,7 +941,7 @@ function processConditionalExpression(node, context) {
871
941
  return [
872
942
  () => {
873
943
  onExit();
874
- context.registerOperation(operation);
944
+ context.dynamic.operation = operation;
875
945
  },
876
946
  () => {
877
947
  const [branch2, onExit2] = createBranch(alternate, context);
@@ -892,7 +962,7 @@ function processLogicalExpression(node, context) {
892
962
  context
893
963
  );
894
964
  const operation = {
895
- type: 16 /* IF */,
965
+ type: 15 /* IF */,
896
966
  id,
897
967
  condition,
898
968
  positive: branch,
@@ -901,7 +971,7 @@ function processLogicalExpression(node, context) {
901
971
  return [
902
972
  () => {
903
973
  onExit();
904
- context.registerOperation(operation);
974
+ context.dynamic.operation = operation;
905
975
  },
906
976
  () => {
907
977
  const [branch2, onExit2] = createBranch(
@@ -923,18 +993,35 @@ var transformText = (node, context) => {
923
993
  context.dynamic.flags |= 2 /* NON_TEMPLATE */;
924
994
  return;
925
995
  }
926
- if (node.type === "JSXElement" && !isTemplate(node) && !isJSXComponent(node) && isAllTextLike(node.children)) {
927
- processTextLikeContainer(
928
- node.children,
929
- context
930
- );
996
+ const isFragment = isFragmentNode(node);
997
+ if ((node.type === "JSXElement" && !isTemplate(node) && !isJSXComponent(node) || isFragment) && node.children.length) {
998
+ let hasInterp = false;
999
+ let isAllTextLike = true;
1000
+ for (const c of node.children) {
1001
+ if (c.type === "JSXExpressionContainer" && c.expression.type !== "ConditionalExpression" && c.expression.type !== "LogicalExpression") {
1002
+ hasInterp = true;
1003
+ } else if (c.type !== "JSXText") {
1004
+ isAllTextLike = false;
1005
+ }
1006
+ }
1007
+ if (!isFragment && isAllTextLike && hasInterp) {
1008
+ processTextContainer(node.children, context);
1009
+ } else if (hasInterp) {
1010
+ for (let i = 0; i < node.children.length; i++) {
1011
+ const c = node.children[i];
1012
+ const prev = node.children[i - 1];
1013
+ if (c.type === "JSXExpressionContainer" && prev && prev.type === "JSXText") {
1014
+ seen.get(context.root).add(prev);
1015
+ }
1016
+ }
1017
+ }
931
1018
  } else if (node.type === "JSXExpressionContainer") {
932
1019
  if (node.expression.type === "ConditionalExpression") {
933
1020
  return processConditionalExpression(node.expression, context);
934
1021
  } else if (node.expression.type === "LogicalExpression") {
935
1022
  return processLogicalExpression(node.expression, context);
936
1023
  } else {
937
- processTextLike(context);
1024
+ processInterpolation(context);
938
1025
  }
939
1026
  } else if (node.type === "JSXText") {
940
1027
  const value = resolveJSXText(node);
@@ -945,35 +1032,54 @@ var transformText = (node, context) => {
945
1032
  }
946
1033
  }
947
1034
  };
948
- function processTextLike(context) {
949
- const nexts = _optionalChain([context, 'access', _11 => _11.parent, 'access', _12 => _12.node, 'access', _13 => _13.children, 'optionalAccess', _14 => _14.slice, 'call', _15 => _15(context.index)]);
1035
+ function processInterpolation(context) {
1036
+ const parent = context.parent.node;
1037
+ const children = parent.children;
1038
+ const nexts = children.slice(context.index);
950
1039
  const idx = nexts.findIndex((n) => !isTextLike(n));
951
1040
  const nodes = idx !== -1 ? nexts.slice(0, idx) : nexts;
1041
+ const prev = children[context.index - 1];
1042
+ if (prev && prev.type === "JSXText") {
1043
+ nodes.unshift(prev);
1044
+ }
952
1045
  const values = createTextLikeExpressions(nodes, context);
953
1046
  if (!values.length) {
954
1047
  context.dynamic.flags |= 2 /* NON_TEMPLATE */;
955
1048
  return;
956
1049
  }
957
1050
  const id = context.reference();
958
- context.dynamic.flags |= 4 /* INSERT */ | 2 /* NON_TEMPLATE */;
959
- context.registerOperation({
960
- type: 11 /* CREATE_TEXT_NODE */,
961
- id,
962
- values,
963
- jsx: true
964
- });
1051
+ if (isFragmentNode(parent)) {
1052
+ context.registerOperation({
1053
+ type: 18 /* CREATE_NODES */,
1054
+ id,
1055
+ values
1056
+ });
1057
+ } else {
1058
+ context.template += " ";
1059
+ context.registerOperation({
1060
+ type: 19 /* SET_NODES */,
1061
+ element: id,
1062
+ values
1063
+ });
1064
+ }
965
1065
  }
966
- function processTextLikeContainer(children, context) {
1066
+ function processTextContainer(children, context) {
967
1067
  const values = createTextLikeExpressions(children, context);
968
1068
  const literals = values.map(getLiteralExpressionValue);
969
1069
  if (literals.every((l) => l != null)) {
970
1070
  context.childrenTemplate = literals.map((l) => String(l));
971
1071
  } else {
1072
+ context.childrenTemplate = [" "];
972
1073
  context.registerOperation({
973
- type: 4 /* SET_TEXT */,
1074
+ type: 17 /* GET_TEXT_CHILD */,
1075
+ parent: context.reference()
1076
+ });
1077
+ context.registerOperation({
1078
+ type: 19 /* SET_NODES */,
974
1079
  element: context.reference(),
975
1080
  values,
976
- jsx: true
1081
+ // indicates this node is generated, so prefix should be "x" instead of "n"
1082
+ generated: true
977
1083
  });
978
1084
  }
979
1085
  }
@@ -986,10 +1092,6 @@ function createTextLikeExpressions(nodes, context) {
986
1092
  }
987
1093
  return values;
988
1094
  }
989
- function isAllTextLike(children) {
990
- return !!children.length && children.every(isTextLike) && // at least one an interpolation
991
- children.some((n) => n.type === "JSXExpressionContainer");
992
- }
993
1095
  function isTextLike(node) {
994
1096
  return node.type === "JSXExpressionContainer" && node.expression.type !== "ConditionalExpression" && node.expression.type !== "LogicalExpression" || node.type === "JSXText";
995
1097
  }
@@ -1051,8 +1153,8 @@ function processFor(node, dir, context) {
1051
1153
  exitBlock();
1052
1154
  const { parent } = context;
1053
1155
  const isOnlyChild = parent && parent.block.node !== parent.node && parent.node.children.length === 1;
1054
- context.registerOperation({
1055
- type: 17 /* FOR */,
1156
+ context.dynamic.operation = {
1157
+ type: 16 /* FOR */,
1056
1158
  id,
1057
1159
  source,
1058
1160
  value,
@@ -1063,7 +1165,7 @@ function processFor(node, dir, context) {
1063
1165
  once: context.inVOnce || !!(source.ast && _compilerdom.isConstantNode.call(void 0, source.ast, {})),
1064
1166
  component: isComponent,
1065
1167
  onlyChild: !!isOnlyChild
1066
- });
1168
+ };
1067
1169
  };
1068
1170
  }
1069
1171
  function getForParseResult(dir, context) {
@@ -1135,22 +1237,28 @@ function processIf(node, attribute, context) {
1135
1237
  const [branch, onExit] = createBranch(node, context);
1136
1238
  return () => {
1137
1239
  onExit();
1138
- context.registerOperation({
1139
- type: 16 /* IF */,
1240
+ context.dynamic.operation = {
1241
+ type: 15 /* IF */,
1140
1242
  id,
1141
1243
  condition: dir.exp,
1142
1244
  positive: branch,
1143
1245
  once: context.inVOnce || _compilerdom.isConstantNode.call(void 0, attribute.value, context.options.bindingMetadata)
1144
- });
1246
+ };
1145
1247
  };
1146
1248
  } else {
1147
1249
  const siblingIf = getSiblingIf(context);
1148
- const { operation } = context.block;
1149
- let lastIfNode = operation.at(-1);
1250
+ const siblings = context.parent && context.parent.dynamic.children;
1251
+ let lastIfNode;
1252
+ if (siblings) {
1253
+ let i = siblings.length;
1254
+ while (i--) {
1255
+ if (siblings[i].operation) lastIfNode = siblings[i].operation;
1256
+ }
1257
+ }
1150
1258
  if (
1151
1259
  // check if v-if is the sibling node
1152
1260
  !siblingIf || // check if IfNode is the last operation and get the root IfNode
1153
- !lastIfNode || lastIfNode.type !== 16 /* IF */
1261
+ !lastIfNode || lastIfNode.type !== 15 /* IF */
1154
1262
  ) {
1155
1263
  context.options.onError(
1156
1264
  _compilerdom.createCompilerError.call(void 0,
@@ -1160,7 +1268,7 @@ function processIf(node, attribute, context) {
1160
1268
  );
1161
1269
  return;
1162
1270
  }
1163
- while (lastIfNode.negative && lastIfNode.negative.type === 16 /* IF */) {
1271
+ while (lastIfNode.negative && lastIfNode.negative.type === 15 /* IF */) {
1164
1272
  lastIfNode = lastIfNode.negative;
1165
1273
  }
1166
1274
  if (dir.name === "else-if" && lastIfNode.negative) {
@@ -1177,7 +1285,7 @@ function processIf(node, attribute, context) {
1177
1285
  lastIfNode.negative = branch;
1178
1286
  } else {
1179
1287
  lastIfNode.negative = {
1180
- type: 16 /* IF */,
1288
+ type: 15 /* IF */,
1181
1289
  id: -1,
1182
1290
  condition: dir.exp,
1183
1291
  positive: branch,
@@ -1491,7 +1599,7 @@ var transformVSlots = (node, context) => {
1491
1599
  (attr) => attr.type === "JSXAttribute" && attr.name.name.toString() === "v-slots"
1492
1600
  );
1493
1601
  const vSlotsDir = attributes[vSlotsIndex];
1494
- if (vSlotsDir && _optionalChain([vSlotsDir, 'access', _16 => _16.value, 'optionalAccess', _17 => _17.type]) === "JSXExpressionContainer") {
1602
+ if (vSlotsDir && _optionalChain([vSlotsDir, 'access', _13 => _13.value, 'optionalAccess', _14 => _14.type]) === "JSXExpressionContainer") {
1495
1603
  attributes.splice(vSlotsIndex, 1);
1496
1604
  context.slots = [
1497
1605
  {
@@ -1556,7 +1664,10 @@ function compile(source, options = {}) {
1556
1664
  )
1557
1665
  })
1558
1666
  );
1559
- return _compilervapor.generate.call(void 0, ir, resolvedOptions);
1667
+ return _compilervapor.generate.call(void 0, ir, {
1668
+ ...resolvedOptions,
1669
+ customGenOperation
1670
+ });
1560
1671
  }
1561
1672
  function getBaseTransformPreset() {
1562
1673
  return [
@@ -1618,4 +1729,5 @@ var transformVText = (dir, node, context) => {
1618
1729
 
1619
1730
 
1620
1731
 
1621
- exports.DynamicFlag = DynamicFlag; exports.IRDynamicPropsKind = IRDynamicPropsKind; exports.IRNodeTypes = IRNodeTypes; exports.IRSlotType = IRSlotType; exports.TransformContext = TransformContext; exports.compile = compile; exports.createStructuralDirectiveTransform = createStructuralDirectiveTransform; exports.generate = _compilervapor.generate; exports.resolveDirectiveNode = resolveDirectiveNode; exports.resolveNode = resolveNode; exports.transform = transform; exports.transformChildren = transformChildren; exports.transformElement = transformElement; exports.transformNode = transformNode; exports.transformTemplateRef = transformTemplateRef; exports.transformText = transformText; exports.transformVBind = transformVBind; exports.transformVFor = transformVFor; exports.transformVHtml = transformVHtml; exports.transformVIf = transformVIf; exports.transformVModel = transformVModel; exports.transformVOn = transformVOn; exports.transformVOnce = transformVOnce; exports.transformVShow = transformVShow; exports.transformVSlot = transformVSlot; exports.transformVSlots = transformVSlots; exports.transformVText = transformVText;
1732
+
1733
+ exports.DynamicFlag = DynamicFlag; exports.IRDynamicPropsKind = IRDynamicPropsKind; exports.IRNodeTypes = IRNodeTypes; exports.IRSlotType = IRSlotType; exports.TransformContext = TransformContext; exports.compile = compile; exports.createStructuralDirectiveTransform = createStructuralDirectiveTransform; exports.generate = _compilervapor.generate; exports.isBlockOperation = isBlockOperation; exports.resolveDirectiveNode = resolveDirectiveNode; exports.resolveNode = resolveNode; exports.transform = transform; exports.transformChildren = transformChildren; exports.transformElement = transformElement; exports.transformNode = transformNode; exports.transformTemplateRef = transformTemplateRef; exports.transformText = transformText; exports.transformVBind = transformVBind; exports.transformVFor = transformVFor; exports.transformVHtml = transformVHtml; exports.transformVIf = transformVIf; exports.transformVModel = transformVModel; exports.transformVOn = transformVOn; exports.transformVOnce = transformVOnce; exports.transformVShow = transformVShow; exports.transformVSlot = transformVSlot; exports.transformVSlots = transformVSlots; exports.transformVText = transformVText;
package/dist/index.d.cts CHANGED
@@ -116,14 +116,15 @@ declare enum IRNodeTypes {
116
116
  SET_TEMPLATE_REF = 8,
117
117
  INSERT_NODE = 9,
118
118
  PREPEND_NODE = 10,
119
- CREATE_TEXT_NODE = 11,
120
- CREATE_COMPONENT_NODE = 12,
121
- SLOT_OUTLET_NODE = 13,
122
- DIRECTIVE = 14,
123
- DECLARE_OLD_REF = 15,// consider make it more general
124
- IF = 16,
125
- FOR = 17,
126
- GET_TEXT_CHILD = 18
119
+ CREATE_COMPONENT_NODE = 11,
120
+ SLOT_OUTLET_NODE = 12,
121
+ DIRECTIVE = 13,
122
+ DECLARE_OLD_REF = 14,// consider make it more general
123
+ IF = 15,
124
+ FOR = 16,
125
+ GET_TEXT_CHILD = 17,
126
+ CREATE_NODES = 18,
127
+ SET_NODES = 19
127
128
  }
128
129
  interface BaseIRNode {
129
130
  type: IRNodeTypes;
@@ -161,6 +162,8 @@ interface IfIRNode extends BaseIRNode {
161
162
  positive: BlockIRNode;
162
163
  negative?: BlockIRNode | IfIRNode;
163
164
  once?: boolean;
165
+ parent?: number;
166
+ anchor?: number;
164
167
  }
165
168
  interface IRFor {
166
169
  source: SimpleExpressionNode;
@@ -176,6 +179,8 @@ interface ForIRNode extends BaseIRNode, IRFor {
176
179
  once: boolean;
177
180
  component: boolean;
178
181
  onlyChild: boolean;
182
+ parent?: number;
183
+ anchor?: number;
179
184
  }
180
185
  interface SetPropIRNode extends BaseIRNode {
181
186
  type: IRNodeTypes.SET_PROP;
@@ -195,12 +200,11 @@ interface SetDynamicEventsIRNode extends BaseIRNode {
195
200
  element: number;
196
201
  event: SimpleExpressionNode;
197
202
  }
198
- interface SetTextIRNode extends BaseIRNode {
199
- type: IRNodeTypes.SET_TEXT;
203
+ interface SetNodesIRNode extends BaseIRNode {
204
+ type: IRNodeTypes.SET_NODES;
200
205
  element: number;
201
206
  values: SimpleExpressionNode[];
202
207
  generated?: boolean;
203
- jsx?: boolean;
204
208
  }
205
209
  type KeyOverride = [find: string, replacement: string];
206
210
  interface SetEventIRNode extends BaseIRNode {
@@ -230,11 +234,10 @@ interface SetTemplateRefIRNode extends BaseIRNode {
230
234
  refFor: boolean;
231
235
  effect: boolean;
232
236
  }
233
- interface CreateTextNodeIRNode extends BaseIRNode {
234
- type: IRNodeTypes.CREATE_TEXT_NODE;
237
+ interface CreateNodesIRNode extends BaseIRNode {
238
+ type: IRNodeTypes.CREATE_NODES;
235
239
  id: number;
236
240
  values?: SimpleExpressionNode[];
237
- jsx?: boolean;
238
241
  }
239
242
  interface InsertNodeIRNode extends BaseIRNode {
240
243
  type: IRNodeTypes.INSERT_NODE;
@@ -266,6 +269,8 @@ interface CreateComponentIRNode extends BaseIRNode {
266
269
  root: boolean;
267
270
  once: boolean;
268
271
  dynamic?: SimpleExpressionNode;
272
+ parent?: number;
273
+ anchor?: number;
269
274
  }
270
275
  interface DeclareOldRefIRNode extends BaseIRNode {
271
276
  type: IRNodeTypes.DECLARE_OLD_REF;
@@ -277,13 +282,15 @@ interface SlotOutletIRNode extends BaseIRNode {
277
282
  name: SimpleExpressionNode;
278
283
  props: IRProps[];
279
284
  fallback?: BlockIRNode;
285
+ parent?: number;
286
+ anchor?: number;
280
287
  }
281
288
  interface GetTextChildIRNode extends BaseIRNode {
282
289
  type: IRNodeTypes.GET_TEXT_CHILD;
283
290
  parent: number;
284
291
  }
285
292
  type IRNode = OperationNode | RootIRNode;
286
- type OperationNode = SetPropIRNode | SetDynamicPropsIRNode | SetTextIRNode | SetEventIRNode | SetDynamicEventsIRNode | SetHtmlIRNode | SetTemplateRefIRNode | CreateTextNodeIRNode | InsertNodeIRNode | PrependNodeIRNode | DirectiveIRNode | IfIRNode | ForIRNode | CreateComponentIRNode | DeclareOldRefIRNode | SlotOutletIRNode | GetTextChildIRNode;
293
+ type OperationNode = SetPropIRNode | SetDynamicPropsIRNode | SetNodesIRNode | SetEventIRNode | SetDynamicEventsIRNode | SetHtmlIRNode | SetTemplateRefIRNode | CreateNodesIRNode | InsertNodeIRNode | PrependNodeIRNode | DirectiveIRNode | IfIRNode | ForIRNode | CreateComponentIRNode | DeclareOldRefIRNode | SlotOutletIRNode | GetTextChildIRNode;
287
294
  declare enum DynamicFlag {
288
295
  NONE = 0,
289
296
  /**
@@ -306,6 +313,7 @@ interface IRDynamicInfo {
306
313
  children: IRDynamicInfo[];
307
314
  template?: number;
308
315
  hasDynamicChild?: boolean;
316
+ operation?: OperationNode;
309
317
  }
310
318
  interface IREffect {
311
319
  expressions: SimpleExpressionNode[];
@@ -320,9 +328,12 @@ type VaporDirectiveNode = Overwrite<DirectiveNode, {
320
328
  exp: Exclude<DirectiveNode['exp'], CompoundExpressionNode>;
321
329
  arg: Exclude<DirectiveNode['arg'], CompoundExpressionNode>;
322
330
  }>;
331
+ type InsertionStateTypes = IfIRNode | ForIRNode | SlotOutletIRNode | CreateComponentIRNode;
332
+ declare function isBlockOperation(op: OperationNode): op is InsertionStateTypes;
323
333
 
324
334
  interface VaporCodegenResult extends Omit<VaporCodegenResult$1, 'ast'> {
325
335
  ast: RootIRNode;
336
+ customHelpers: Set<string>;
326
337
  }
327
338
  declare function compile(source: JSXElement | JSXFragment | string, options?: CompilerOptions): VaporCodegenResult;
328
339
  type CompilerOptions = HackOptions<CompilerOptions$1> & {
@@ -366,4 +377,4 @@ declare const transformVOnce: NodeTransform;
366
377
 
367
378
  declare const transformVText: DirectiveTransform;
368
379
 
369
- export { type BaseIRNode, type BlockIRNode, type CompilerOptions, type CreateComponentIRNode, type CreateTextNodeIRNode, type DeclareOldRefIRNode, type DirectiveIRNode, type DirectiveTransform, type DirectiveTransformResult, DynamicFlag, type ForIRNode, type GetTextChildIRNode, type HackOptions, type IRDynamicInfo, IRDynamicPropsKind, type IREffect, type IRFor, type IRNode, IRNodeTypes, type IRProp, type IRProps, type IRPropsDynamicAttribute, type IRPropsDynamicExpression, type IRPropsStatic, type IRSlotDynamic, type IRSlotDynamicBasic, type IRSlotDynamicConditional, type IRSlotDynamicLoop, IRSlotType, type IRSlots, type IRSlotsExpression, type IRSlotsStatic, type IfIRNode, type InsertNodeIRNode, type KeyOverride, type NodeTransform, type OperationNode, type PrependNodeIRNode, type RootIRNode, type RootNode, type SetDynamicEventsIRNode, type SetDynamicPropsIRNode, type SetEventIRNode, type SetHtmlIRNode, type SetPropIRNode, type SetTemplateRefIRNode, type SetTextIRNode, type SlotBlockIRNode, type SlotOutletIRNode, type StructuralDirectiveTransform, TransformContext, type TransformOptions, type TransformPreset, type VaporDirectiveNode, compile, createStructuralDirectiveTransform, resolveDirectiveNode, resolveNode, transform, transformChildren, transformElement, transformNode, transformTemplateRef, transformText, transformVBind, transformVFor, transformVHtml, transformVIf, transformVModel, transformVOn, transformVOnce, transformVShow, transformVSlot, transformVSlots, transformVText };
380
+ export { type BaseIRNode, type BlockIRNode, type CompilerOptions, type CreateComponentIRNode, type CreateNodesIRNode, type DeclareOldRefIRNode, type DirectiveIRNode, type DirectiveTransform, type DirectiveTransformResult, DynamicFlag, type ForIRNode, type GetTextChildIRNode, type HackOptions, type IRDynamicInfo, IRDynamicPropsKind, type IREffect, type IRFor, type IRNode, IRNodeTypes, type IRProp, type IRProps, type IRPropsDynamicAttribute, type IRPropsDynamicExpression, type IRPropsStatic, type IRSlotDynamic, type IRSlotDynamicBasic, type IRSlotDynamicConditional, type IRSlotDynamicLoop, IRSlotType, type IRSlots, type IRSlotsExpression, type IRSlotsStatic, type IfIRNode, type InsertNodeIRNode, type InsertionStateTypes, type KeyOverride, type NodeTransform, type OperationNode, type PrependNodeIRNode, type RootIRNode, type RootNode, type SetDynamicEventsIRNode, type SetDynamicPropsIRNode, type SetEventIRNode, type SetHtmlIRNode, type SetNodesIRNode, type SetPropIRNode, type SetTemplateRefIRNode, type SlotBlockIRNode, type SlotOutletIRNode, type StructuralDirectiveTransform, TransformContext, type TransformOptions, type TransformPreset, type VaporDirectiveNode, compile, createStructuralDirectiveTransform, isBlockOperation, resolveDirectiveNode, resolveNode, transform, transformChildren, transformElement, transformNode, transformTemplateRef, transformText, transformVBind, transformVFor, transformVHtml, transformVIf, transformVModel, transformVOn, transformVOnce, transformVShow, transformVSlot, transformVSlots, transformVText };
package/dist/index.d.ts CHANGED
@@ -116,14 +116,15 @@ declare enum IRNodeTypes {
116
116
  SET_TEMPLATE_REF = 8,
117
117
  INSERT_NODE = 9,
118
118
  PREPEND_NODE = 10,
119
- CREATE_TEXT_NODE = 11,
120
- CREATE_COMPONENT_NODE = 12,
121
- SLOT_OUTLET_NODE = 13,
122
- DIRECTIVE = 14,
123
- DECLARE_OLD_REF = 15,// consider make it more general
124
- IF = 16,
125
- FOR = 17,
126
- GET_TEXT_CHILD = 18
119
+ CREATE_COMPONENT_NODE = 11,
120
+ SLOT_OUTLET_NODE = 12,
121
+ DIRECTIVE = 13,
122
+ DECLARE_OLD_REF = 14,// consider make it more general
123
+ IF = 15,
124
+ FOR = 16,
125
+ GET_TEXT_CHILD = 17,
126
+ CREATE_NODES = 18,
127
+ SET_NODES = 19
127
128
  }
128
129
  interface BaseIRNode {
129
130
  type: IRNodeTypes;
@@ -161,6 +162,8 @@ interface IfIRNode extends BaseIRNode {
161
162
  positive: BlockIRNode;
162
163
  negative?: BlockIRNode | IfIRNode;
163
164
  once?: boolean;
165
+ parent?: number;
166
+ anchor?: number;
164
167
  }
165
168
  interface IRFor {
166
169
  source: SimpleExpressionNode;
@@ -176,6 +179,8 @@ interface ForIRNode extends BaseIRNode, IRFor {
176
179
  once: boolean;
177
180
  component: boolean;
178
181
  onlyChild: boolean;
182
+ parent?: number;
183
+ anchor?: number;
179
184
  }
180
185
  interface SetPropIRNode extends BaseIRNode {
181
186
  type: IRNodeTypes.SET_PROP;
@@ -195,12 +200,11 @@ interface SetDynamicEventsIRNode extends BaseIRNode {
195
200
  element: number;
196
201
  event: SimpleExpressionNode;
197
202
  }
198
- interface SetTextIRNode extends BaseIRNode {
199
- type: IRNodeTypes.SET_TEXT;
203
+ interface SetNodesIRNode extends BaseIRNode {
204
+ type: IRNodeTypes.SET_NODES;
200
205
  element: number;
201
206
  values: SimpleExpressionNode[];
202
207
  generated?: boolean;
203
- jsx?: boolean;
204
208
  }
205
209
  type KeyOverride = [find: string, replacement: string];
206
210
  interface SetEventIRNode extends BaseIRNode {
@@ -230,11 +234,10 @@ interface SetTemplateRefIRNode extends BaseIRNode {
230
234
  refFor: boolean;
231
235
  effect: boolean;
232
236
  }
233
- interface CreateTextNodeIRNode extends BaseIRNode {
234
- type: IRNodeTypes.CREATE_TEXT_NODE;
237
+ interface CreateNodesIRNode extends BaseIRNode {
238
+ type: IRNodeTypes.CREATE_NODES;
235
239
  id: number;
236
240
  values?: SimpleExpressionNode[];
237
- jsx?: boolean;
238
241
  }
239
242
  interface InsertNodeIRNode extends BaseIRNode {
240
243
  type: IRNodeTypes.INSERT_NODE;
@@ -266,6 +269,8 @@ interface CreateComponentIRNode extends BaseIRNode {
266
269
  root: boolean;
267
270
  once: boolean;
268
271
  dynamic?: SimpleExpressionNode;
272
+ parent?: number;
273
+ anchor?: number;
269
274
  }
270
275
  interface DeclareOldRefIRNode extends BaseIRNode {
271
276
  type: IRNodeTypes.DECLARE_OLD_REF;
@@ -277,13 +282,15 @@ interface SlotOutletIRNode extends BaseIRNode {
277
282
  name: SimpleExpressionNode;
278
283
  props: IRProps[];
279
284
  fallback?: BlockIRNode;
285
+ parent?: number;
286
+ anchor?: number;
280
287
  }
281
288
  interface GetTextChildIRNode extends BaseIRNode {
282
289
  type: IRNodeTypes.GET_TEXT_CHILD;
283
290
  parent: number;
284
291
  }
285
292
  type IRNode = OperationNode | RootIRNode;
286
- type OperationNode = SetPropIRNode | SetDynamicPropsIRNode | SetTextIRNode | SetEventIRNode | SetDynamicEventsIRNode | SetHtmlIRNode | SetTemplateRefIRNode | CreateTextNodeIRNode | InsertNodeIRNode | PrependNodeIRNode | DirectiveIRNode | IfIRNode | ForIRNode | CreateComponentIRNode | DeclareOldRefIRNode | SlotOutletIRNode | GetTextChildIRNode;
293
+ type OperationNode = SetPropIRNode | SetDynamicPropsIRNode | SetNodesIRNode | SetEventIRNode | SetDynamicEventsIRNode | SetHtmlIRNode | SetTemplateRefIRNode | CreateNodesIRNode | InsertNodeIRNode | PrependNodeIRNode | DirectiveIRNode | IfIRNode | ForIRNode | CreateComponentIRNode | DeclareOldRefIRNode | SlotOutletIRNode | GetTextChildIRNode;
287
294
  declare enum DynamicFlag {
288
295
  NONE = 0,
289
296
  /**
@@ -306,6 +313,7 @@ interface IRDynamicInfo {
306
313
  children: IRDynamicInfo[];
307
314
  template?: number;
308
315
  hasDynamicChild?: boolean;
316
+ operation?: OperationNode;
309
317
  }
310
318
  interface IREffect {
311
319
  expressions: SimpleExpressionNode[];
@@ -320,9 +328,12 @@ type VaporDirectiveNode = Overwrite<DirectiveNode, {
320
328
  exp: Exclude<DirectiveNode['exp'], CompoundExpressionNode>;
321
329
  arg: Exclude<DirectiveNode['arg'], CompoundExpressionNode>;
322
330
  }>;
331
+ type InsertionStateTypes = IfIRNode | ForIRNode | SlotOutletIRNode | CreateComponentIRNode;
332
+ declare function isBlockOperation(op: OperationNode): op is InsertionStateTypes;
323
333
 
324
334
  interface VaporCodegenResult extends Omit<VaporCodegenResult$1, 'ast'> {
325
335
  ast: RootIRNode;
336
+ customHelpers: Set<string>;
326
337
  }
327
338
  declare function compile(source: JSXElement | JSXFragment | string, options?: CompilerOptions): VaporCodegenResult;
328
339
  type CompilerOptions = HackOptions<CompilerOptions$1> & {
@@ -366,4 +377,4 @@ declare const transformVOnce: NodeTransform;
366
377
 
367
378
  declare const transformVText: DirectiveTransform;
368
379
 
369
- export { type BaseIRNode, type BlockIRNode, type CompilerOptions, type CreateComponentIRNode, type CreateTextNodeIRNode, type DeclareOldRefIRNode, type DirectiveIRNode, type DirectiveTransform, type DirectiveTransformResult, DynamicFlag, type ForIRNode, type GetTextChildIRNode, type HackOptions, type IRDynamicInfo, IRDynamicPropsKind, type IREffect, type IRFor, type IRNode, IRNodeTypes, type IRProp, type IRProps, type IRPropsDynamicAttribute, type IRPropsDynamicExpression, type IRPropsStatic, type IRSlotDynamic, type IRSlotDynamicBasic, type IRSlotDynamicConditional, type IRSlotDynamicLoop, IRSlotType, type IRSlots, type IRSlotsExpression, type IRSlotsStatic, type IfIRNode, type InsertNodeIRNode, type KeyOverride, type NodeTransform, type OperationNode, type PrependNodeIRNode, type RootIRNode, type RootNode, type SetDynamicEventsIRNode, type SetDynamicPropsIRNode, type SetEventIRNode, type SetHtmlIRNode, type SetPropIRNode, type SetTemplateRefIRNode, type SetTextIRNode, type SlotBlockIRNode, type SlotOutletIRNode, type StructuralDirectiveTransform, TransformContext, type TransformOptions, type TransformPreset, type VaporDirectiveNode, compile, createStructuralDirectiveTransform, resolveDirectiveNode, resolveNode, transform, transformChildren, transformElement, transformNode, transformTemplateRef, transformText, transformVBind, transformVFor, transformVHtml, transformVIf, transformVModel, transformVOn, transformVOnce, transformVShow, transformVSlot, transformVSlots, transformVText };
380
+ export { type BaseIRNode, type BlockIRNode, type CompilerOptions, type CreateComponentIRNode, type CreateNodesIRNode, type DeclareOldRefIRNode, type DirectiveIRNode, type DirectiveTransform, type DirectiveTransformResult, DynamicFlag, type ForIRNode, type GetTextChildIRNode, type HackOptions, type IRDynamicInfo, IRDynamicPropsKind, type IREffect, type IRFor, type IRNode, IRNodeTypes, type IRProp, type IRProps, type IRPropsDynamicAttribute, type IRPropsDynamicExpression, type IRPropsStatic, type IRSlotDynamic, type IRSlotDynamicBasic, type IRSlotDynamicConditional, type IRSlotDynamicLoop, IRSlotType, type IRSlots, type IRSlotsExpression, type IRSlotsStatic, type IfIRNode, type InsertNodeIRNode, type InsertionStateTypes, type KeyOverride, type NodeTransform, type OperationNode, type PrependNodeIRNode, type RootIRNode, type RootNode, type SetDynamicEventsIRNode, type SetDynamicPropsIRNode, type SetEventIRNode, type SetHtmlIRNode, type SetNodesIRNode, type SetPropIRNode, type SetTemplateRefIRNode, type SlotBlockIRNode, type SlotOutletIRNode, type StructuralDirectiveTransform, TransformContext, type TransformOptions, type TransformPreset, type VaporDirectiveNode, compile, createStructuralDirectiveTransform, isBlockOperation, resolveDirectiveNode, resolveNode, transform, transformChildren, transformElement, transformNode, transformTemplateRef, transformText, transformVBind, transformVFor, transformVHtml, transformVIf, transformVModel, transformVOn, transformVOnce, transformVShow, transformVSlot, transformVSlots, transformVText };
package/dist/index.js CHANGED
@@ -5,6 +5,13 @@ import {
5
5
  } from "@vue/compiler-vapor";
6
6
  import { extend as extend5, isString as isString3 } from "@vue/shared";
7
7
 
8
+ // src/generate.ts
9
+ import {
10
+ genCall,
11
+ genExpression,
12
+ NEWLINE
13
+ } from "@vue/compiler-vapor";
14
+
8
15
  // src/ir/component.ts
9
16
  var IRDynamicPropsKind = /* @__PURE__ */ ((IRDynamicPropsKind2) => {
10
17
  IRDynamicPropsKind2[IRDynamicPropsKind2["EXPRESSION"] = 0] = "EXPRESSION";
@@ -33,14 +40,15 @@ var IRNodeTypes = /* @__PURE__ */ ((IRNodeTypes2) => {
33
40
  IRNodeTypes2[IRNodeTypes2["SET_TEMPLATE_REF"] = 8] = "SET_TEMPLATE_REF";
34
41
  IRNodeTypes2[IRNodeTypes2["INSERT_NODE"] = 9] = "INSERT_NODE";
35
42
  IRNodeTypes2[IRNodeTypes2["PREPEND_NODE"] = 10] = "PREPEND_NODE";
36
- IRNodeTypes2[IRNodeTypes2["CREATE_TEXT_NODE"] = 11] = "CREATE_TEXT_NODE";
37
- IRNodeTypes2[IRNodeTypes2["CREATE_COMPONENT_NODE"] = 12] = "CREATE_COMPONENT_NODE";
38
- IRNodeTypes2[IRNodeTypes2["SLOT_OUTLET_NODE"] = 13] = "SLOT_OUTLET_NODE";
39
- IRNodeTypes2[IRNodeTypes2["DIRECTIVE"] = 14] = "DIRECTIVE";
40
- IRNodeTypes2[IRNodeTypes2["DECLARE_OLD_REF"] = 15] = "DECLARE_OLD_REF";
41
- IRNodeTypes2[IRNodeTypes2["IF"] = 16] = "IF";
42
- IRNodeTypes2[IRNodeTypes2["FOR"] = 17] = "FOR";
43
- IRNodeTypes2[IRNodeTypes2["GET_TEXT_CHILD"] = 18] = "GET_TEXT_CHILD";
43
+ IRNodeTypes2[IRNodeTypes2["CREATE_COMPONENT_NODE"] = 11] = "CREATE_COMPONENT_NODE";
44
+ IRNodeTypes2[IRNodeTypes2["SLOT_OUTLET_NODE"] = 12] = "SLOT_OUTLET_NODE";
45
+ IRNodeTypes2[IRNodeTypes2["DIRECTIVE"] = 13] = "DIRECTIVE";
46
+ IRNodeTypes2[IRNodeTypes2["DECLARE_OLD_REF"] = 14] = "DECLARE_OLD_REF";
47
+ IRNodeTypes2[IRNodeTypes2["IF"] = 15] = "IF";
48
+ IRNodeTypes2[IRNodeTypes2["FOR"] = 16] = "FOR";
49
+ IRNodeTypes2[IRNodeTypes2["GET_TEXT_CHILD"] = 17] = "GET_TEXT_CHILD";
50
+ IRNodeTypes2[IRNodeTypes2["CREATE_NODES"] = 18] = "CREATE_NODES";
51
+ IRNodeTypes2[IRNodeTypes2["SET_NODES"] = 19] = "SET_NODES";
44
52
  return IRNodeTypes2;
45
53
  })(IRNodeTypes || {});
46
54
  var DynamicFlag = /* @__PURE__ */ ((DynamicFlag2) => {
@@ -50,6 +58,49 @@ var DynamicFlag = /* @__PURE__ */ ((DynamicFlag2) => {
50
58
  DynamicFlag2[DynamicFlag2["INSERT"] = 4] = "INSERT";
51
59
  return DynamicFlag2;
52
60
  })(DynamicFlag || {});
61
+ function isBlockOperation(op) {
62
+ const type = op.type;
63
+ return type === 11 /* CREATE_COMPONENT_NODE */ || type === 12 /* SLOT_OUTLET_NODE */ || type === 15 /* IF */ || type === 16 /* FOR */;
64
+ }
65
+
66
+ // src/generate.ts
67
+ var customGenOperation = (oper, context) => {
68
+ if (oper.type === 18 /* CREATE_NODES */) {
69
+ return genCreateNodes(oper, context);
70
+ } else if (oper.type === 19 /* SET_NODES */) {
71
+ return genSetNodes(oper, context);
72
+ }
73
+ };
74
+ function genSetNodes(oper, context) {
75
+ const { helper } = context;
76
+ const { element, values, generated } = oper;
77
+ return [
78
+ NEWLINE,
79
+ ...genCall(
80
+ helper("setNodes"),
81
+ `${generated ? "x" : "n"}${element}`,
82
+ combineValues(values, context)
83
+ )
84
+ ];
85
+ }
86
+ function genCreateNodes(oper, context) {
87
+ const { helper } = context;
88
+ const { id, values } = oper;
89
+ return [
90
+ NEWLINE,
91
+ `const n${id} = `,
92
+ ...genCall(helper("createNodes"), values && combineValues(values, context))
93
+ ];
94
+ }
95
+ function combineValues(values, context) {
96
+ return values.flatMap((value, i) => {
97
+ const exp = genExpression(value, context);
98
+ if (i > 0) {
99
+ exp.unshift(", ");
100
+ }
101
+ return exp;
102
+ });
103
+ }
53
104
 
54
105
  // src/transform.ts
55
106
  import {
@@ -217,17 +268,25 @@ function resolveNode(node, context) {
217
268
  const props = node.openingElement.attributes.reduce(
218
269
  (result, attr) => {
219
270
  if (attr.type === "JSXAttribute") {
220
- if (tagType === ElementTypes.COMPONENT) {
221
- result.push(resolveDirectiveNode(attr, context));
222
- } else {
223
- result.push({
271
+ result.push(
272
+ attr.value?.type === "StringLiteral" ? {
224
273
  type: NodeTypes.ATTRIBUTE,
225
274
  name: String(attr.name.name),
226
275
  nameLoc: resolveLocation(attr.name.loc, context),
227
276
  value: resolveValue(attr.value, context),
228
277
  loc: resolveLocation(attr.loc, context)
229
- });
230
- }
278
+ } : resolveDirectiveNode(attr, context)
279
+ );
280
+ } else if (attr.type === "JSXSpreadAttribute") {
281
+ result.push({
282
+ type: NodeTypes.DIRECTIVE,
283
+ name: "bind",
284
+ rawName: getText(attr, context),
285
+ exp: resolveExpression(attr.argument, context),
286
+ arg: void 0,
287
+ loc: resolveLocation(node.loc, context),
288
+ modifiers: []
289
+ });
231
290
  }
232
291
  return result;
233
292
  },
@@ -249,34 +308,35 @@ var namespaceRE = /^(?:\$([\w-]+)\$)?([\w-]+)?/;
249
308
  function resolveDirectiveNode(node, context, withFn = false) {
250
309
  const { value, name } = node;
251
310
  let nameString = name.type === "JSXNamespacedName" ? name.namespace.name : name.type === "JSXIdentifier" ? name.name : "";
252
- let argString = name.type === "JSXNamespacedName" ? name.name.name : "";
253
- if (name.type !== "JSXNamespacedName" && !argString) {
254
- const [newName, modifiers2] = nameString.split("_");
255
- nameString = newName;
256
- argString = `_${modifiers2}`;
257
- }
311
+ const isDirective = nameString.startsWith("v-");
258
312
  let modifiers = [];
259
313
  let isStatic = true;
260
- const result = argString.match(namespaceRE);
261
- if (result) {
262
- let modifierString = "";
263
- [, argString, modifierString] = result;
264
- if (argString) {
265
- argString = argString.replaceAll("_", ".");
266
- isStatic = false;
267
- if (modifierString && modifierString.startsWith("_"))
268
- modifiers = modifierString.slice(1).split("_");
269
- } else if (modifierString) {
270
- ;
271
- [argString, ...modifiers] = modifierString.split("_");
314
+ let argString = name.type === "JSXNamespacedName" ? name.name.name : "";
315
+ if (name.type !== "JSXNamespacedName" && !argString) {
316
+ ;
317
+ [nameString, ...modifiers] = nameString.split("_");
318
+ } else {
319
+ const result = argString.match(namespaceRE);
320
+ if (result) {
321
+ let modifierString = "";
322
+ [, argString, modifierString] = result;
323
+ if (argString) {
324
+ argString = argString.replaceAll("_", ".");
325
+ isStatic = false;
326
+ if (modifierString && modifierString.startsWith("_"))
327
+ modifiers = modifierString.slice(1).split("_");
328
+ } else if (modifierString) {
329
+ ;
330
+ [argString, ...modifiers] = modifierString.split("_");
331
+ }
272
332
  }
273
333
  }
274
- const arg = argString && name.type === "JSXNamespacedName" ? resolveSimpleExpression(argString, isStatic, name.name.loc) : void 0;
334
+ const arg = isDirective ? argString && name.type === "JSXNamespacedName" ? resolveSimpleExpression(argString, isStatic, name.name.loc) : void 0 : resolveSimpleExpression(nameString, true, name.loc);
275
335
  const exp = value ? withFn && value.type === "JSXExpressionContainer" ? resolveExpressionWithFn(value.expression, context) : resolveExpression(value, context) : void 0;
276
336
  return {
277
337
  type: NodeTypes.DIRECTIVE,
278
- name: nameString.slice(2),
279
- rawName: `${nameString}:${argString}`,
338
+ name: isDirective ? nameString.slice(2) : "bind",
339
+ rawName: getText(name, context),
280
340
  exp,
281
341
  arg,
282
342
  loc: resolveLocation(node.loc, context),
@@ -358,6 +418,7 @@ function wrapFragment(node) {
358
418
  ]);
359
419
  }
360
420
  var EMPTY_EXPRESSION = createSimpleExpression2("", true);
421
+ var isFragmentNode = (node) => node.type === 0 /* ROOT */ || node.type === "JSXFragment" || node.type === "JSXElement" && !!isTemplate(node);
361
422
 
362
423
  // src/transform.ts
363
424
  var defaultOptions = {
@@ -582,18 +643,15 @@ function processDynamicChildren(context) {
582
643
  context.childrenTemplate[index - prevDynamics.length] = `<!>`;
583
644
  prevDynamics[0].flags -= 2 /* NON_TEMPLATE */;
584
645
  const anchor = prevDynamics[0].anchor = context.increaseId();
585
- context.registerOperation({
586
- type: 9 /* INSERT_NODE */,
587
- elements: prevDynamics.map((child2) => child2.id),
588
- parent: context.reference(),
589
- anchor
590
- });
646
+ registerInsertion(prevDynamics, context, anchor);
591
647
  } else {
592
- context.registerOperation({
593
- type: 10 /* PREPEND_NODE */,
594
- elements: prevDynamics.map((child2) => child2.id),
595
- parent: context.reference()
596
- });
648
+ prevDynamics[0].flags -= 2 /* NON_TEMPLATE */;
649
+ registerInsertion(
650
+ prevDynamics,
651
+ context,
652
+ -1
653
+ /* prepend */
654
+ );
597
655
  }
598
656
  prevDynamics = [];
599
657
  }
@@ -601,11 +659,23 @@ function processDynamicChildren(context) {
601
659
  }
602
660
  }
603
661
  if (prevDynamics.length) {
604
- context.registerOperation({
605
- type: 9 /* INSERT_NODE */,
606
- elements: prevDynamics.map((child) => child.id),
607
- parent: context.reference()
608
- });
662
+ registerInsertion(prevDynamics, context);
663
+ }
664
+ }
665
+ function registerInsertion(dynamics, context, anchor) {
666
+ for (const child of dynamics) {
667
+ console.log(child);
668
+ if (child.template != null) {
669
+ context.registerOperation({
670
+ type: 9 /* INSERT_NODE */,
671
+ elements: dynamics.map((child2) => child2.id),
672
+ parent: context.reference(),
673
+ anchor
674
+ });
675
+ } else if (child.operation && isBlockOperation(child.operation)) {
676
+ child.operation.parent = context.reference();
677
+ child.operation.anchor = anchor;
678
+ }
609
679
  }
610
680
  }
611
681
 
@@ -667,8 +737,8 @@ function transformComponentElement(tag, propsResult, singleRoot, context) {
667
737
  context.component.add(tag);
668
738
  }
669
739
  context.dynamic.flags |= 2 /* NON_TEMPLATE */ | 4 /* INSERT */;
670
- context.registerOperation({
671
- type: 12 /* CREATE_COMPONENT_NODE */,
740
+ context.dynamic.operation = {
741
+ type: 11 /* CREATE_COMPONENT_NODE */,
672
742
  id: context.reference(),
673
743
  tag,
674
744
  props: propsResult[0] ? propsResult[1] : [propsResult[1]],
@@ -676,7 +746,7 @@ function transformComponentElement(tag, propsResult, singleRoot, context) {
676
746
  root: singleRoot,
677
747
  slots: [...context.slots],
678
748
  once: context.inVOnce
679
- });
749
+ };
680
750
  context.slots = [];
681
751
  }
682
752
  function transformNativeElement(tag, propsResult, singleRoot, context) {
@@ -775,7 +845,7 @@ function transformProp(prop, node, context) {
775
845
  if (prop.type === "JSXSpreadAttribute") return;
776
846
  let name = prop.name.type === "JSXIdentifier" ? prop.name.name : prop.name.type === "JSXNamespacedName" ? prop.name.namespace.name : "";
777
847
  name = name.split("_")[0];
778
- if (!isDirectiveRegex.test(name) && (!prop.value || prop.value.type === "StringLiteral")) {
848
+ if (!isDirectiveRegex.test(name) && !isEventRegex.test(name) && (!prop.value || prop.value.type === "StringLiteral")) {
779
849
  if (isReservedProp(name)) return;
780
850
  return {
781
851
  key: resolveSimpleExpression(name, true, prop.name.loc),
@@ -840,7 +910,7 @@ var transformTemplateRef = (node, context) => {
840
910
  const id = context.reference();
841
911
  const effect = !isConstantExpression(value);
842
912
  effect && context.registerOperation({
843
- type: 15 /* DECLARE_OLD_REF */,
913
+ type: 14 /* DECLARE_OLD_REF */,
844
914
  id
845
915
  });
846
916
  context.registerEffect([value], {
@@ -862,7 +932,7 @@ function processConditionalExpression(node, context) {
862
932
  const condition = resolveExpression(test, context);
863
933
  const [branch, onExit] = createBranch(consequent, context);
864
934
  const operation = {
865
- type: 16 /* IF */,
935
+ type: 15 /* IF */,
866
936
  id,
867
937
  condition,
868
938
  positive: branch,
@@ -871,7 +941,7 @@ function processConditionalExpression(node, context) {
871
941
  return [
872
942
  () => {
873
943
  onExit();
874
- context.registerOperation(operation);
944
+ context.dynamic.operation = operation;
875
945
  },
876
946
  () => {
877
947
  const [branch2, onExit2] = createBranch(alternate, context);
@@ -892,7 +962,7 @@ function processLogicalExpression(node, context) {
892
962
  context
893
963
  );
894
964
  const operation = {
895
- type: 16 /* IF */,
965
+ type: 15 /* IF */,
896
966
  id,
897
967
  condition,
898
968
  positive: branch,
@@ -901,7 +971,7 @@ function processLogicalExpression(node, context) {
901
971
  return [
902
972
  () => {
903
973
  onExit();
904
- context.registerOperation(operation);
974
+ context.dynamic.operation = operation;
905
975
  },
906
976
  () => {
907
977
  const [branch2, onExit2] = createBranch(
@@ -923,18 +993,35 @@ var transformText = (node, context) => {
923
993
  context.dynamic.flags |= 2 /* NON_TEMPLATE */;
924
994
  return;
925
995
  }
926
- if (node.type === "JSXElement" && !isTemplate(node) && !isJSXComponent(node) && isAllTextLike(node.children)) {
927
- processTextLikeContainer(
928
- node.children,
929
- context
930
- );
996
+ const isFragment = isFragmentNode(node);
997
+ if ((node.type === "JSXElement" && !isTemplate(node) && !isJSXComponent(node) || isFragment) && node.children.length) {
998
+ let hasInterp = false;
999
+ let isAllTextLike = true;
1000
+ for (const c of node.children) {
1001
+ if (c.type === "JSXExpressionContainer" && c.expression.type !== "ConditionalExpression" && c.expression.type !== "LogicalExpression") {
1002
+ hasInterp = true;
1003
+ } else if (c.type !== "JSXText") {
1004
+ isAllTextLike = false;
1005
+ }
1006
+ }
1007
+ if (!isFragment && isAllTextLike && hasInterp) {
1008
+ processTextContainer(node.children, context);
1009
+ } else if (hasInterp) {
1010
+ for (let i = 0; i < node.children.length; i++) {
1011
+ const c = node.children[i];
1012
+ const prev = node.children[i - 1];
1013
+ if (c.type === "JSXExpressionContainer" && prev && prev.type === "JSXText") {
1014
+ seen.get(context.root).add(prev);
1015
+ }
1016
+ }
1017
+ }
931
1018
  } else if (node.type === "JSXExpressionContainer") {
932
1019
  if (node.expression.type === "ConditionalExpression") {
933
1020
  return processConditionalExpression(node.expression, context);
934
1021
  } else if (node.expression.type === "LogicalExpression") {
935
1022
  return processLogicalExpression(node.expression, context);
936
1023
  } else {
937
- processTextLike(context);
1024
+ processInterpolation(context);
938
1025
  }
939
1026
  } else if (node.type === "JSXText") {
940
1027
  const value = resolveJSXText(node);
@@ -945,35 +1032,54 @@ var transformText = (node, context) => {
945
1032
  }
946
1033
  }
947
1034
  };
948
- function processTextLike(context) {
949
- const nexts = context.parent.node.children?.slice(context.index);
1035
+ function processInterpolation(context) {
1036
+ const parent = context.parent.node;
1037
+ const children = parent.children;
1038
+ const nexts = children.slice(context.index);
950
1039
  const idx = nexts.findIndex((n) => !isTextLike(n));
951
1040
  const nodes = idx !== -1 ? nexts.slice(0, idx) : nexts;
1041
+ const prev = children[context.index - 1];
1042
+ if (prev && prev.type === "JSXText") {
1043
+ nodes.unshift(prev);
1044
+ }
952
1045
  const values = createTextLikeExpressions(nodes, context);
953
1046
  if (!values.length) {
954
1047
  context.dynamic.flags |= 2 /* NON_TEMPLATE */;
955
1048
  return;
956
1049
  }
957
1050
  const id = context.reference();
958
- context.dynamic.flags |= 4 /* INSERT */ | 2 /* NON_TEMPLATE */;
959
- context.registerOperation({
960
- type: 11 /* CREATE_TEXT_NODE */,
961
- id,
962
- values,
963
- jsx: true
964
- });
1051
+ if (isFragmentNode(parent)) {
1052
+ context.registerOperation({
1053
+ type: 18 /* CREATE_NODES */,
1054
+ id,
1055
+ values
1056
+ });
1057
+ } else {
1058
+ context.template += " ";
1059
+ context.registerOperation({
1060
+ type: 19 /* SET_NODES */,
1061
+ element: id,
1062
+ values
1063
+ });
1064
+ }
965
1065
  }
966
- function processTextLikeContainer(children, context) {
1066
+ function processTextContainer(children, context) {
967
1067
  const values = createTextLikeExpressions(children, context);
968
1068
  const literals = values.map(getLiteralExpressionValue);
969
1069
  if (literals.every((l) => l != null)) {
970
1070
  context.childrenTemplate = literals.map((l) => String(l));
971
1071
  } else {
1072
+ context.childrenTemplate = [" "];
972
1073
  context.registerOperation({
973
- type: 4 /* SET_TEXT */,
1074
+ type: 17 /* GET_TEXT_CHILD */,
1075
+ parent: context.reference()
1076
+ });
1077
+ context.registerOperation({
1078
+ type: 19 /* SET_NODES */,
974
1079
  element: context.reference(),
975
1080
  values,
976
- jsx: true
1081
+ // indicates this node is generated, so prefix should be "x" instead of "n"
1082
+ generated: true
977
1083
  });
978
1084
  }
979
1085
  }
@@ -986,10 +1092,6 @@ function createTextLikeExpressions(nodes, context) {
986
1092
  }
987
1093
  return values;
988
1094
  }
989
- function isAllTextLike(children) {
990
- return !!children.length && children.every(isTextLike) && // at least one an interpolation
991
- children.some((n) => n.type === "JSXExpressionContainer");
992
- }
993
1095
  function isTextLike(node) {
994
1096
  return node.type === "JSXExpressionContainer" && node.expression.type !== "ConditionalExpression" && node.expression.type !== "LogicalExpression" || node.type === "JSXText";
995
1097
  }
@@ -1051,8 +1153,8 @@ function processFor(node, dir, context) {
1051
1153
  exitBlock();
1052
1154
  const { parent } = context;
1053
1155
  const isOnlyChild = parent && parent.block.node !== parent.node && parent.node.children.length === 1;
1054
- context.registerOperation({
1055
- type: 17 /* FOR */,
1156
+ context.dynamic.operation = {
1157
+ type: 16 /* FOR */,
1056
1158
  id,
1057
1159
  source,
1058
1160
  value,
@@ -1063,7 +1165,7 @@ function processFor(node, dir, context) {
1063
1165
  once: context.inVOnce || !!(source.ast && isConstantNode(source.ast, {})),
1064
1166
  component: isComponent,
1065
1167
  onlyChild: !!isOnlyChild
1066
- });
1168
+ };
1067
1169
  };
1068
1170
  }
1069
1171
  function getForParseResult(dir, context) {
@@ -1135,22 +1237,28 @@ function processIf(node, attribute, context) {
1135
1237
  const [branch, onExit] = createBranch(node, context);
1136
1238
  return () => {
1137
1239
  onExit();
1138
- context.registerOperation({
1139
- type: 16 /* IF */,
1240
+ context.dynamic.operation = {
1241
+ type: 15 /* IF */,
1140
1242
  id,
1141
1243
  condition: dir.exp,
1142
1244
  positive: branch,
1143
1245
  once: context.inVOnce || isConstantNode2(attribute.value, context.options.bindingMetadata)
1144
- });
1246
+ };
1145
1247
  };
1146
1248
  } else {
1147
1249
  const siblingIf = getSiblingIf(context);
1148
- const { operation } = context.block;
1149
- let lastIfNode = operation.at(-1);
1250
+ const siblings = context.parent && context.parent.dynamic.children;
1251
+ let lastIfNode;
1252
+ if (siblings) {
1253
+ let i = siblings.length;
1254
+ while (i--) {
1255
+ if (siblings[i].operation) lastIfNode = siblings[i].operation;
1256
+ }
1257
+ }
1150
1258
  if (
1151
1259
  // check if v-if is the sibling node
1152
1260
  !siblingIf || // check if IfNode is the last operation and get the root IfNode
1153
- !lastIfNode || lastIfNode.type !== 16 /* IF */
1261
+ !lastIfNode || lastIfNode.type !== 15 /* IF */
1154
1262
  ) {
1155
1263
  context.options.onError(
1156
1264
  createCompilerError2(
@@ -1160,7 +1268,7 @@ function processIf(node, attribute, context) {
1160
1268
  );
1161
1269
  return;
1162
1270
  }
1163
- while (lastIfNode.negative && lastIfNode.negative.type === 16 /* IF */) {
1271
+ while (lastIfNode.negative && lastIfNode.negative.type === 15 /* IF */) {
1164
1272
  lastIfNode = lastIfNode.negative;
1165
1273
  }
1166
1274
  if (dir.name === "else-if" && lastIfNode.negative) {
@@ -1177,7 +1285,7 @@ function processIf(node, attribute, context) {
1177
1285
  lastIfNode.negative = branch;
1178
1286
  } else {
1179
1287
  lastIfNode.negative = {
1180
- type: 16 /* IF */,
1288
+ type: 15 /* IF */,
1181
1289
  id: -1,
1182
1290
  condition: dir.exp,
1183
1291
  positive: branch,
@@ -1556,7 +1664,10 @@ function compile(source, options = {}) {
1556
1664
  )
1557
1665
  })
1558
1666
  );
1559
- return generate(ir, resolvedOptions);
1667
+ return generate(ir, {
1668
+ ...resolvedOptions,
1669
+ customGenOperation
1670
+ });
1560
1671
  }
1561
1672
  function getBaseTransformPreset() {
1562
1673
  return [
@@ -1599,6 +1710,7 @@ export {
1599
1710
  compile,
1600
1711
  createStructuralDirectiveTransform,
1601
1712
  generate,
1713
+ isBlockOperation,
1602
1714
  resolveDirectiveNode,
1603
1715
  resolveNode,
1604
1716
  transform,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue-jsx-vapor/compiler",
3
- "version": "2.0.1",
3
+ "version": "2.1.1",
4
4
  "description": "Vue JSX Vapor Compiler",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -50,9 +50,9 @@
50
50
  "dependencies": {
51
51
  "@babel/parser": "^7.26.8",
52
52
  "@babel/types": "^7.26.8",
53
- "@vue/compiler-dom": "https://pkg.pr.new/@vue/compiler-dom@ce35a8c",
54
- "@vue/compiler-vapor": "https://pkg.pr.new/@vue/compiler-vapor@ce35a8c",
55
- "@vue/shared": "https://pkg.pr.new/@vue/shared@ce35a8c"
53
+ "@vue/compiler-dom": "https://pkg.pr.new/@vue/compiler-dom@34957eb",
54
+ "@vue/compiler-vapor": "https://pkg.pr.new/@vue/compiler-vapor@13044",
55
+ "@vue/shared": "https://pkg.pr.new/@vue/shared@34957eb"
56
56
  },
57
57
  "scripts": {
58
58
  "build": "tsup",