@vue/compiler-ssr 3.3.0-alpha.2 → 3.3.0-alpha.3

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.
@@ -83,8 +83,8 @@ function ssrProcessIf(node, context, disableNestedFragments = false) {
83
83
  }
84
84
  function processIfBranch(branch, context, disableNestedFragments = false) {
85
85
  const { children } = branch;
86
- const needFragmentWrapper = !disableNestedFragments && (children.length !== 1 || children[0].type !== "element") && // optimize away nested fragments when the only child is a ForNode
87
- !(children.length === 1 && children[0].type === 11);
86
+ const needFragmentWrapper = !disableNestedFragments && (children.length !== 1 || children[0].type !== "1") && // optimize away nested fragments when the only child is a ForNode
87
+ !(children.length === 1 && children[0].type === "11");
88
88
  return processChildrenAsStatement(branch, context, needFragmentWrapper);
89
89
  }
90
90
 
@@ -93,7 +93,7 @@ const ssrTransformFor = compilerDom.createStructuralDirectiveTransform(
93
93
  compilerDom.processFor
94
94
  );
95
95
  function ssrProcessFor(node, context, disableNestedFragments = false) {
96
- const needFragmentWrapper = !disableNestedFragments && (node.children.length !== 1 || node.children[0].type !== "element");
96
+ const needFragmentWrapper = !disableNestedFragments && (node.children.length !== 1 || node.children[0].type !== "1");
97
97
  const renderLoop = compilerDom.createFunctionExpression(
98
98
  compilerDom.createForLoopParams(node.parseResult)
99
99
  );
@@ -133,7 +133,7 @@ const ssrTransformSlotOutlet = (node, context) => {
133
133
  }
134
134
  let method = SSR_RENDER_SLOT;
135
135
  const parent = context.parent;
136
- if (parent && parent.type === "element" && parent.tagType === 1 && compilerDom.resolveComponentType(parent, context, true) === compilerDom.TRANSITION && parent.children.filter((c) => c.type === "element").length === 1) {
136
+ if (parent && parent.type === "1" && parent.tagType === "1" && compilerDom.resolveComponentType(parent, context, true) === compilerDom.TRANSITION && parent.children.filter((c) => c.type === "1").length === 1) {
137
137
  method = SSR_RENDER_SLOT_INNER;
138
138
  if (!(context.scopeId && context.slotted !== false)) {
139
139
  args.push("null");
@@ -162,20 +162,20 @@ function createSSRCompilerError(code, loc) {
162
162
  }
163
163
  const SSRErrorMessages = {
164
164
  [62]: `Unsafe attribute name for SSR.`,
165
- [63]: `Missing the 'to' prop on teleport element.`,
166
- [64]: `Invalid AST node during SSR transform.`
165
+ ["63"]: `Missing the 'to' prop on teleport element.`,
166
+ ["64"]: `Invalid AST node during SSR transform.`
167
167
  };
168
168
 
169
169
  function ssrProcessTeleport(node, context) {
170
170
  const targetProp = compilerDom.findProp(node, "to");
171
171
  if (!targetProp) {
172
172
  context.onError(
173
- createSSRCompilerError(63, node.loc)
173
+ createSSRCompilerError("63", node.loc)
174
174
  );
175
175
  return;
176
176
  }
177
177
  let target;
178
- if (targetProp.type === 6) {
178
+ if (targetProp.type === "6") {
179
179
  target = targetProp.value && compilerDom.createSimpleExpression(targetProp.value.content, true);
180
180
  } else {
181
181
  target = targetProp.exp;
@@ -183,7 +183,7 @@ function ssrProcessTeleport(node, context) {
183
183
  if (!target) {
184
184
  context.onError(
185
185
  createSSRCompilerError(
186
- 63,
186
+ "63",
187
187
  targetProp.loc
188
188
  )
189
189
  );
@@ -196,7 +196,7 @@ function ssrProcessTeleport(node, context) {
196
196
  true
197
197
  /* allow empty */
198
198
  );
199
- const disabled = disabledProp ? disabledProp.type === 6 ? `true` : disabledProp.exp || `false` : `false`;
199
+ const disabled = disabledProp ? disabledProp.type === "6" ? `true` : disabledProp.exp || `false` : `false`;
200
200
  const contentRenderFn = compilerDom.createFunctionExpression(
201
201
  [`_push`],
202
202
  void 0,
@@ -269,7 +269,7 @@ function ssrProcessSuspense(node, context) {
269
269
 
270
270
  const rawChildrenMap = /* @__PURE__ */ new WeakMap();
271
271
  const ssrTransformElement = (node, context) => {
272
- if (node.type !== "element" || node.tagType !== 0) {
272
+ if (node.type !== "1" || node.tagType !== "0") {
273
273
  return;
274
274
  }
275
275
  return function ssrPostTransformElement() {
@@ -277,7 +277,7 @@ const ssrTransformElement = (node, context) => {
277
277
  const needTagForRuntime = node.tag === "textarea" || node.tag.indexOf("-") > 0;
278
278
  const hasDynamicVBind = compilerDom.hasDynamicKeyVBind(node);
279
279
  const hasCustomDir = node.props.some(
280
- (p) => p.type === 7 && !shared.isBuiltInDirective(p.name)
280
+ (p) => p.type === "7" && !shared.isBuiltInDirective(p.name)
281
281
  );
282
282
  const needMergeProps = hasDynamicVBind || hasCustomDir;
283
283
  if (needMergeProps) {
@@ -298,7 +298,7 @@ const ssrTransformElement = (node, context) => {
298
298
  );
299
299
  if (node.tag === "textarea") {
300
300
  const existingText = node.children[0];
301
- if (!existingText || existingText.type !== 5) {
301
+ if (!existingText || existingText.type !== "5") {
302
302
  const tempId = `_temp${context.temps++}`;
303
303
  propsExp.arguments = [
304
304
  compilerDom.createAssignmentExpression(
@@ -359,14 +359,14 @@ const ssrTransformElement = (node, context) => {
359
359
  if (node.tag === "input" && isTrueFalseValue(prop)) {
360
360
  continue;
361
361
  }
362
- if (prop.type === 7) {
362
+ if (prop.type === "7") {
363
363
  if (prop.name === "html" && prop.exp) {
364
364
  rawChildrenMap.set(node, prop.exp);
365
365
  } else if (prop.name === "text" && prop.exp) {
366
366
  node.children = [compilerDom.createInterpolation(prop.exp, prop.loc)];
367
367
  } else if (prop.name === "slot") {
368
368
  context.onError(
369
- compilerDom.createCompilerError(40, prop.loc)
369
+ compilerDom.createCompilerError("40", prop.loc)
370
370
  );
371
371
  } else if (isTextareaWithValue(node, prop) && prop.exp) {
372
372
  if (!needMergeProps) {
@@ -487,7 +487,7 @@ const ssrTransformElement = (node, context) => {
487
487
  function buildSSRProps(props, directives, context) {
488
488
  let mergePropsArgs = [];
489
489
  if (props) {
490
- if (props.type === 14) {
490
+ if (props.type === "14") {
491
491
  mergePropsArgs = props.arguments;
492
492
  } else {
493
493
  mergePropsArgs.push(props);
@@ -506,7 +506,7 @@ function buildSSRProps(props, directives, context) {
506
506
  return mergePropsArgs.length > 1 ? compilerDom.createCallExpression(context.helper(compilerDom.MERGE_PROPS), mergePropsArgs) : mergePropsArgs[0];
507
507
  }
508
508
  function isTrueFalseValue(prop) {
509
- if (prop.type === 7) {
509
+ if (prop.type === "7") {
510
510
  return prop.name === "bind" && prop.arg && compilerDom.isStaticExp(prop.arg) && (prop.arg.content === "true-value" || prop.arg.content === "false-value");
511
511
  } else {
512
512
  return prop.name === "true-value" || prop.name === "false-value";
@@ -517,7 +517,7 @@ function isTextareaWithValue(node, prop) {
517
517
  }
518
518
  function mergeCall(call, arg) {
519
519
  const existing = call.arguments[0];
520
- if (existing.type === 17) {
520
+ if (existing.type === "17") {
521
521
  existing.elements.push(arg);
522
522
  } else {
523
523
  call.arguments[0] = compilerDom.createArrayExpression([existing, arg]);
@@ -532,7 +532,7 @@ function removeStaticBinding(tag, binding) {
532
532
  }
533
533
  function findVModel(node) {
534
534
  return node.props.find(
535
- (p) => p.type === 7 && p.name === "model" && p.exp
535
+ (p) => p.type === "7" && p.name === "model" && p.exp
536
536
  );
537
537
  }
538
538
  function ssrProcessElement(node, context) {
@@ -588,7 +588,7 @@ function ssrProcessTransitionGroup(node, context) {
588
588
  const entry = wipMap$1.get(node);
589
589
  if (entry) {
590
590
  const { tag, propsExp } = entry;
591
- if (tag.type === 7) {
591
+ if (tag.type === "7") {
592
592
  context.pushStringPart(`<`);
593
593
  context.pushStringPart(tag.exp);
594
594
  if (propsExp) {
@@ -628,7 +628,7 @@ const wipMap = /* @__PURE__ */ new WeakMap();
628
628
  const WIP_SLOT = Symbol();
629
629
  const componentTypeMap = /* @__PURE__ */ new WeakMap();
630
630
  const ssrTransformComponent = (node, context) => {
631
- if (node.type !== "element" || node.tagType !== 1) {
631
+ if (node.type !== "1" || node.tagType !== "1") {
632
632
  return;
633
633
  }
634
634
  const component = compilerDom.resolveComponentType(
@@ -729,7 +729,7 @@ function ssrProcessComponent(node, context, parent) {
729
729
  context.pushStringPart(``);
730
730
  }
731
731
  if (component === compilerDom.TRANSITION) {
732
- node.children = node.children.filter((c) => c.type !== "comment");
732
+ node.children = node.children.filter((c) => c.type !== "3");
733
733
  }
734
734
  processChildren(node, context);
735
735
  }
@@ -783,16 +783,16 @@ function createVNodeSlotBranch(props, children, parentContext) {
783
783
  }
784
784
  };
785
785
  const wrapperNode = {
786
- type: "element",
787
- ns: 0,
786
+ type: "1",
787
+ ns: "0",
788
788
  tag: "template",
789
- tagType: 3,
789
+ tagType: "3",
790
790
  isSelfClosing: false,
791
791
  // important: provide v-slot="props" on the wrapper for proper
792
792
  // scope analysis
793
793
  props: [
794
794
  {
795
- type: 7,
795
+ type: "7",
796
796
  name: "slot",
797
797
  exp: props,
798
798
  arg: void 0,
@@ -923,23 +923,23 @@ function processChildren(parent, context, asFragment = false, disableNestedFragm
923
923
  for (let i = 0; i < children.length; i++) {
924
924
  const child = children[i];
925
925
  switch (child.type) {
926
- case "element":
926
+ case "1":
927
927
  switch (child.tagType) {
928
- case 0:
928
+ case "0":
929
929
  ssrProcessElement(child, context);
930
930
  break;
931
- case 1:
931
+ case "1":
932
932
  ssrProcessComponent(child, context, parent);
933
933
  break;
934
- case 2:
934
+ case "2":
935
935
  ssrProcessSlotOutlet(child, context);
936
936
  break;
937
- case 3:
937
+ case "3":
938
938
  break;
939
939
  default:
940
940
  context.onError(
941
941
  createSSRCompilerError(
942
- 64,
942
+ "64",
943
943
  child.loc
944
944
  )
945
945
  );
@@ -947,32 +947,32 @@ function processChildren(parent, context, asFragment = false, disableNestedFragm
947
947
  return exhaustiveCheck2;
948
948
  }
949
949
  break;
950
- case "text":
950
+ case "2":
951
951
  context.pushStringPart(shared.escapeHtml(child.content));
952
952
  break;
953
- case "comment":
953
+ case "3":
954
954
  context.pushStringPart(`<!--${child.content}-->`);
955
955
  break;
956
- case 5:
956
+ case "5":
957
957
  context.pushStringPart(
958
958
  compilerDom.createCallExpression(context.helper(SSR_INTERPOLATE), [child.content])
959
959
  );
960
960
  break;
961
- case 9:
961
+ case "9":
962
962
  ssrProcessIf(child, context, disableNestedFragments);
963
963
  break;
964
- case 11:
964
+ case "11":
965
965
  ssrProcessFor(child, context, disableNestedFragments);
966
966
  break;
967
- case 10:
967
+ case "10":
968
968
  break;
969
- case 12:
970
- case 8:
969
+ case "12":
970
+ case "8":
971
971
  break;
972
972
  default:
973
973
  context.onError(
974
974
  createSSRCompilerError(
975
- 64,
975
+ "64",
976
976
  child.loc
977
977
  )
978
978
  );
@@ -997,13 +997,13 @@ const ssrTransformModel = (dir, node, context) => {
997
997
  if (value) {
998
998
  context.onError(
999
999
  compilerDom.createDOMCompilerError(
1000
- 58,
1000
+ "58",
1001
1001
  value.loc
1002
1002
  )
1003
1003
  );
1004
1004
  }
1005
1005
  }
1006
- if (node.tagType === 0) {
1006
+ if (node.tagType === "0") {
1007
1007
  const res = { props: [] };
1008
1008
  const defaultProps = [
1009
1009
  // default value binding for text type inputs
@@ -1013,7 +1013,7 @@ const ssrTransformModel = (dir, node, context) => {
1013
1013
  const type = compilerDom.findProp(node, "type");
1014
1014
  if (type) {
1015
1015
  const value = findValueBinding(node);
1016
- if (type.type === 7) {
1016
+ if (type.type === "7") {
1017
1017
  res.ssrTagParts = [
1018
1018
  compilerDom.createCallExpression(context.helper(SSR_RENDER_DYNAMIC_MODEL), [
1019
1019
  type.exp,
@@ -1037,7 +1037,7 @@ const ssrTransformModel = (dir, node, context) => {
1037
1037
  case "checkbox":
1038
1038
  const trueValueBinding = compilerDom.findProp(node, "true-value");
1039
1039
  if (trueValueBinding) {
1040
- const trueValue = trueValueBinding.type === 6 ? JSON.stringify(trueValueBinding.value.content) : trueValueBinding.exp;
1040
+ const trueValue = trueValueBinding.type === "6" ? JSON.stringify(trueValueBinding.value.content) : trueValueBinding.exp;
1041
1041
  res.props = [
1042
1042
  compilerDom.createObjectProperty(
1043
1043
  `checked`,
@@ -1066,7 +1066,7 @@ const ssrTransformModel = (dir, node, context) => {
1066
1066
  case "file":
1067
1067
  context.onError(
1068
1068
  compilerDom.createDOMCompilerError(
1069
- 57,
1069
+ "57",
1070
1070
  dir.loc
1071
1071
  )
1072
1072
  );
@@ -1087,7 +1087,7 @@ const ssrTransformModel = (dir, node, context) => {
1087
1087
  } else if (node.tag === "select") ; else {
1088
1088
  context.onError(
1089
1089
  compilerDom.createDOMCompilerError(
1090
- 55,
1090
+ "55",
1091
1091
  dir.loc
1092
1092
  )
1093
1093
  );
@@ -1099,13 +1099,13 @@ const ssrTransformModel = (dir, node, context) => {
1099
1099
  };
1100
1100
  function findValueBinding(node) {
1101
1101
  const valueBinding = compilerDom.findProp(node, "value");
1102
- return valueBinding ? valueBinding.type === 7 ? valueBinding.exp : compilerDom.createSimpleExpression(valueBinding.value.content, true) : compilerDom.createSimpleExpression(`null`, false);
1102
+ return valueBinding ? valueBinding.type === "7" ? valueBinding.exp : compilerDom.createSimpleExpression(valueBinding.value.content, true) : compilerDom.createSimpleExpression(`null`, false);
1103
1103
  }
1104
1104
 
1105
1105
  const ssrTransformShow = (dir, node, context) => {
1106
1106
  if (!dir.exp) {
1107
1107
  context.onError(
1108
- compilerDom.createDOMCompilerError(59)
1108
+ compilerDom.createDOMCompilerError("59")
1109
1109
  );
1110
1110
  }
1111
1111
  return {
@@ -1129,13 +1129,13 @@ const ssrTransformShow = (dir, node, context) => {
1129
1129
  };
1130
1130
  };
1131
1131
 
1132
- const filterChild = (node) => node.children.filter((n) => n.type !== "comment");
1132
+ const filterChild = (node) => node.children.filter((n) => n.type !== "3");
1133
1133
  const hasSingleChild = (node) => filterChild(node).length === 1;
1134
1134
  const ssrInjectFallthroughAttrs = (node, context) => {
1135
- if (node.type === 0) {
1135
+ if (node.type === "0") {
1136
1136
  context.identifiers._attrs = 1;
1137
1137
  }
1138
- if (node.type === "element" && node.tagType === 1 && (compilerDom.isBuiltInType(node.tag, "Transition") || compilerDom.isBuiltInType(node.tag, "KeepAlive"))) {
1138
+ if (node.type === "1" && node.tagType === "1" && (compilerDom.isBuiltInType(node.tag, "Transition") || compilerDom.isBuiltInType(node.tag, "KeepAlive"))) {
1139
1139
  const rootChildren = filterChild(context.root);
1140
1140
  if (rootChildren.length === 1 && rootChildren[0] === node) {
1141
1141
  if (hasSingleChild(node)) {
@@ -1145,20 +1145,20 @@ const ssrInjectFallthroughAttrs = (node, context) => {
1145
1145
  }
1146
1146
  }
1147
1147
  const parent = context.parent;
1148
- if (!parent || parent.type !== 0) {
1148
+ if (!parent || parent.type !== "0") {
1149
1149
  return;
1150
1150
  }
1151
- if (node.type === 10 && hasSingleChild(node)) {
1151
+ if (node.type === "10" && hasSingleChild(node)) {
1152
1152
  let hasEncounteredIf = false;
1153
1153
  for (const c of filterChild(parent)) {
1154
- if (c.type === 9 || c.type === "element" && compilerDom.findDir(c, "if")) {
1154
+ if (c.type === "9" || c.type === "1" && compilerDom.findDir(c, "if")) {
1155
1155
  if (hasEncounteredIf)
1156
1156
  return;
1157
1157
  hasEncounteredIf = true;
1158
1158
  } else if (
1159
1159
  // node before v-if
1160
1160
  !hasEncounteredIf || // non else nodes
1161
- !(c.type === "element" && compilerDom.findDir(c, /else/, true))
1161
+ !(c.type === "1" && compilerDom.findDir(c, /else/, true))
1162
1162
  ) {
1163
1163
  return;
1164
1164
  }
@@ -1169,9 +1169,9 @@ const ssrInjectFallthroughAttrs = (node, context) => {
1169
1169
  }
1170
1170
  };
1171
1171
  function injectFallthroughAttrs(node) {
1172
- if (node.type === "element" && (node.tagType === 0 || node.tagType === 1) && !compilerDom.findDir(node, "for")) {
1172
+ if (node.type === "1" && (node.tagType === "0" || node.tagType === "1") && !compilerDom.findDir(node, "for")) {
1173
1173
  node.props.push({
1174
- type: 7,
1174
+ type: "7",
1175
1175
  name: "bind",
1176
1176
  arg: void 0,
1177
1177
  exp: compilerDom.createSimpleExpression(`_attrs`, false),
@@ -1185,14 +1185,14 @@ const ssrInjectCssVars = (node, context) => {
1185
1185
  if (!context.ssrCssVars) {
1186
1186
  return;
1187
1187
  }
1188
- if (node.type === 0) {
1188
+ if (node.type === "0") {
1189
1189
  context.identifiers._cssVars = 1;
1190
1190
  }
1191
1191
  const parent = context.parent;
1192
- if (!parent || parent.type !== 0) {
1192
+ if (!parent || parent.type !== "0") {
1193
1193
  return;
1194
1194
  }
1195
- if (node.type === 10) {
1195
+ if (node.type === "10") {
1196
1196
  for (const child of node.children) {
1197
1197
  injectCssVars(child);
1198
1198
  }
@@ -1201,10 +1201,10 @@ const ssrInjectCssVars = (node, context) => {
1201
1201
  }
1202
1202
  };
1203
1203
  function injectCssVars(node) {
1204
- if (node.type === "element" && (node.tagType === 0 || node.tagType === 1) && !compilerDom.findDir(node, "for")) {
1204
+ if (node.type === "1" && (node.tagType === "0" || node.tagType === "1") && !compilerDom.findDir(node, "for")) {
1205
1205
  if (compilerDom.isBuiltInType(node.tag, "Suspense")) {
1206
1206
  for (const child of node.children) {
1207
- if (child.type === "element" && child.tagType === 3) {
1207
+ if (child.type === "1" && child.tagType === "3") {
1208
1208
  child.children.forEach(injectCssVars);
1209
1209
  } else {
1210
1210
  injectCssVars(child);
@@ -1212,7 +1212,7 @@ function injectCssVars(node) {
1212
1212
  }
1213
1213
  } else {
1214
1214
  node.props.push({
1215
- type: 7,
1215
+ type: "7",
1216
1216
  name: "bind",
1217
1217
  arg: void 0,
1218
1218
  exp: compilerDom.createSimpleExpression(`_cssVars`, false),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/compiler-ssr",
3
- "version": "3.3.0-alpha.2",
3
+ "version": "3.3.0-alpha.3",
4
4
  "description": "@vue/compiler-ssr",
5
5
  "main": "dist/compiler-ssr.cjs.js",
6
6
  "types": "dist/compiler-ssr.d.ts",
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-ssr#readme",
30
30
  "dependencies": {
31
- "@vue/shared": "3.3.0-alpha.2",
32
- "@vue/compiler-dom": "3.3.0-alpha.2"
31
+ "@vue/shared": "3.3.0-alpha.3",
32
+ "@vue/compiler-dom": "3.3.0-alpha.3"
33
33
  }
34
34
  }