@vue/compiler-core 3.6.0-beta.10 → 3.6.0-beta.12

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-core v3.6.0-beta.10
2
+ * @vue/compiler-core v3.6.0-beta.12
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -3176,6 +3176,7 @@ function createTransformContext(root, { filename = "", prefixIdentifiers = false
3176
3176
  constantCache: /* @__PURE__ */ new WeakMap(),
3177
3177
  temps: 0,
3178
3178
  identifiers: Object.create(null),
3179
+ identifierScopes: Object.create(null),
3179
3180
  scopes: {
3180
3181
  vFor: 0,
3181
3182
  vSlot: 0,
@@ -3226,16 +3227,20 @@ function createTransformContext(root, { filename = "", prefixIdentifiers = false
3226
3227
  context.parent.children.splice(removalIndex, 1);
3227
3228
  },
3228
3229
  onNodeRemoved: _vue_shared.NOOP,
3229
- addIdentifiers(exp) {
3230
- if ((0, _vue_shared.isString)(exp)) addId(exp);
3231
- else if (exp.identifiers) exp.identifiers.forEach(addId);
3232
- else if (exp.type === 4) addId(exp.content);
3230
+ addIdentifiers(exp, type = "local") {
3231
+ if ((0, _vue_shared.isString)(exp)) addId(exp, type);
3232
+ else if (exp.identifiers) exp.identifiers.forEach((id) => addId(id, type));
3233
+ else if (exp.type === 4) addId(exp.content, type);
3233
3234
  },
3234
3235
  removeIdentifiers(exp) {
3235
3236
  if ((0, _vue_shared.isString)(exp)) removeId(exp);
3236
3237
  else if (exp.identifiers) exp.identifiers.forEach(removeId);
3237
3238
  else if (exp.type === 4) removeId(exp.content);
3238
3239
  },
3240
+ isSlotScopeIdentifier(name) {
3241
+ const scopes = context.identifierScopes[name];
3242
+ return scopes ? scopes[scopes.length - 1] === "slot" : false;
3243
+ },
3239
3244
  hoist(exp) {
3240
3245
  if ((0, _vue_shared.isString)(exp)) exp = createSimpleExpression(exp);
3241
3246
  context.hoists.push(exp);
@@ -3250,13 +3255,16 @@ function createTransformContext(root, { filename = "", prefixIdentifiers = false
3250
3255
  }
3251
3256
  };
3252
3257
  context.filters = /* @__PURE__ */ new Set();
3253
- function addId(id) {
3254
- const { identifiers } = context;
3258
+ function addId(id, type) {
3259
+ const { identifiers, identifierScopes } = context;
3255
3260
  if (identifiers[id] === void 0) identifiers[id] = 0;
3256
3261
  identifiers[id]++;
3262
+ (identifierScopes[id] || (identifierScopes[id] = [])).push(type);
3257
3263
  }
3258
3264
  function removeId(id) {
3259
3265
  context.identifiers[id]--;
3266
+ const scopes = context.identifierScopes[id];
3267
+ if (scopes) scopes.pop();
3260
3268
  }
3261
3269
  return context;
3262
3270
  }
@@ -4339,7 +4347,7 @@ const trackSlotScopes = (node, context) => {
4339
4347
  const vSlot = findDir(node, "slot");
4340
4348
  if (vSlot) {
4341
4349
  const slotProps = vSlot.exp;
4342
- if (context.prefixIdentifiers) slotProps && context.addIdentifiers(slotProps);
4350
+ if (context.prefixIdentifiers) slotProps && context.addIdentifiers(slotProps, "slot");
4343
4351
  context.scopes.vSlot++;
4344
4352
  return () => {
4345
4353
  if (context.prefixIdentifiers) slotProps && context.removeIdentifiers(slotProps);
@@ -4560,6 +4568,15 @@ function resolveComponentType(node, context, ssr = false) {
4560
4568
  if (!ssr) context.helper(builtIn);
4561
4569
  return builtIn;
4562
4570
  }
4571
+ {
4572
+ const fromScope = resolveSlotScopeReference(tag, context);
4573
+ if (fromScope) return fromScope;
4574
+ const dotIndex = tag.indexOf(".");
4575
+ if (dotIndex > 0) {
4576
+ const ns = resolveSlotScopeReference(tag.slice(0, dotIndex), context);
4577
+ if (ns) return ns + tag.slice(dotIndex);
4578
+ }
4579
+ }
4563
4580
  {
4564
4581
  const fromSetup = resolveSetupReference(tag, context);
4565
4582
  if (fromSetup) return fromSetup;
@@ -4578,6 +4595,14 @@ function resolveComponentType(node, context, ssr = false) {
4578
4595
  context.components.add(tag);
4579
4596
  return toValidAssetId(tag, `component`);
4580
4597
  }
4598
+ function resolveSlotScopeReference(name, context) {
4599
+ const camelName = (0, _vue_shared.camelize)(name);
4600
+ const PascalName = (0, _vue_shared.capitalize)(camelName);
4601
+ const isInSlotScope = (reference) => context.isSlotScopeIdentifier(reference);
4602
+ if (isInSlotScope(name)) return name;
4603
+ if (isInSlotScope(camelName)) return camelName;
4604
+ if (isInSlotScope(PascalName)) return PascalName;
4605
+ }
4581
4606
  function resolveSetupReference(name, context) {
4582
4607
  const bindings = context.bindingMetadata;
4583
4608
  if (!bindings || bindings.__isScriptSetup === false) return;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-core v3.6.0-beta.10
2
+ * @vue/compiler-core v3.6.0-beta.12
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -3155,6 +3155,7 @@ function createTransformContext(root, { filename = "", prefixIdentifiers = false
3155
3155
  constantCache: /* @__PURE__ */ new WeakMap(),
3156
3156
  temps: 0,
3157
3157
  identifiers: Object.create(null),
3158
+ identifierScopes: Object.create(null),
3158
3159
  scopes: {
3159
3160
  vFor: 0,
3160
3161
  vSlot: 0,
@@ -3199,16 +3200,20 @@ function createTransformContext(root, { filename = "", prefixIdentifiers = false
3199
3200
  context.parent.children.splice(removalIndex, 1);
3200
3201
  },
3201
3202
  onNodeRemoved: _vue_shared.NOOP,
3202
- addIdentifiers(exp) {
3203
- if ((0, _vue_shared.isString)(exp)) addId(exp);
3204
- else if (exp.identifiers) exp.identifiers.forEach(addId);
3205
- else if (exp.type === 4) addId(exp.content);
3203
+ addIdentifiers(exp, type = "local") {
3204
+ if ((0, _vue_shared.isString)(exp)) addId(exp, type);
3205
+ else if (exp.identifiers) exp.identifiers.forEach((id) => addId(id, type));
3206
+ else if (exp.type === 4) addId(exp.content, type);
3206
3207
  },
3207
3208
  removeIdentifiers(exp) {
3208
3209
  if ((0, _vue_shared.isString)(exp)) removeId(exp);
3209
3210
  else if (exp.identifiers) exp.identifiers.forEach(removeId);
3210
3211
  else if (exp.type === 4) removeId(exp.content);
3211
3212
  },
3213
+ isSlotScopeIdentifier(name) {
3214
+ const scopes = context.identifierScopes[name];
3215
+ return scopes ? scopes[scopes.length - 1] === "slot" : false;
3216
+ },
3212
3217
  hoist(exp) {
3213
3218
  if ((0, _vue_shared.isString)(exp)) exp = createSimpleExpression(exp);
3214
3219
  context.hoists.push(exp);
@@ -3223,13 +3228,16 @@ function createTransformContext(root, { filename = "", prefixIdentifiers = false
3223
3228
  }
3224
3229
  };
3225
3230
  context.filters = /* @__PURE__ */ new Set();
3226
- function addId(id) {
3227
- const { identifiers } = context;
3231
+ function addId(id, type) {
3232
+ const { identifiers, identifierScopes } = context;
3228
3233
  if (identifiers[id] === void 0) identifiers[id] = 0;
3229
3234
  identifiers[id]++;
3235
+ (identifierScopes[id] || (identifierScopes[id] = [])).push(type);
3230
3236
  }
3231
3237
  function removeId(id) {
3232
3238
  context.identifiers[id]--;
3239
+ const scopes = context.identifierScopes[id];
3240
+ if (scopes) scopes.pop();
3233
3241
  }
3234
3242
  return context;
3235
3243
  }
@@ -4297,7 +4305,7 @@ const trackSlotScopes = (node, context) => {
4297
4305
  const vSlot = findDir(node, "slot");
4298
4306
  if (vSlot) {
4299
4307
  const slotProps = vSlot.exp;
4300
- if (context.prefixIdentifiers) slotProps && context.addIdentifiers(slotProps);
4308
+ if (context.prefixIdentifiers) slotProps && context.addIdentifiers(slotProps, "slot");
4301
4309
  context.scopes.vSlot++;
4302
4310
  return () => {
4303
4311
  if (context.prefixIdentifiers) slotProps && context.removeIdentifiers(slotProps);
@@ -4513,6 +4521,15 @@ function resolveComponentType(node, context, ssr = false) {
4513
4521
  if (!ssr) context.helper(builtIn);
4514
4522
  return builtIn;
4515
4523
  }
4524
+ {
4525
+ const fromScope = resolveSlotScopeReference(tag, context);
4526
+ if (fromScope) return fromScope;
4527
+ const dotIndex = tag.indexOf(".");
4528
+ if (dotIndex > 0) {
4529
+ const ns = resolveSlotScopeReference(tag.slice(0, dotIndex), context);
4530
+ if (ns) return ns + tag.slice(dotIndex);
4531
+ }
4532
+ }
4516
4533
  {
4517
4534
  const fromSetup = resolveSetupReference(tag, context);
4518
4535
  if (fromSetup) return fromSetup;
@@ -4531,6 +4548,14 @@ function resolveComponentType(node, context, ssr = false) {
4531
4548
  context.components.add(tag);
4532
4549
  return toValidAssetId(tag, `component`);
4533
4550
  }
4551
+ function resolveSlotScopeReference(name, context) {
4552
+ const camelName = (0, _vue_shared.camelize)(name);
4553
+ const PascalName = (0, _vue_shared.capitalize)(camelName);
4554
+ const isInSlotScope = (reference) => context.isSlotScopeIdentifier(reference);
4555
+ if (isInSlotScope(name)) return name;
4556
+ if (isInSlotScope(camelName)) return camelName;
4557
+ if (isInSlotScope(PascalName)) return PascalName;
4558
+ }
4534
4559
  function resolveSetupReference(name, context) {
4535
4560
  const bindings = context.bindingMetadata;
4536
4561
  if (!bindings || bindings.__isScriptSetup === false) return;
@@ -90,6 +90,7 @@ export interface ImportItem {
90
90
  exp: SimpleExpressionNode;
91
91
  path: string;
92
92
  }
93
+ type IdentifierScopeType = "local" | "slot";
93
94
  export interface TransformContext extends Required<Omit<TransformOptions, keyof CompilerCompatOptions>>, CompilerCompatOptions {
94
95
  selfName: string | null;
95
96
  root: RootNode;
@@ -103,6 +104,9 @@ export interface TransformContext extends Required<Omit<TransformOptions, keyof
103
104
  identifiers: {
104
105
  [name: string]: number | undefined;
105
106
  };
107
+ identifierScopes: {
108
+ [name: string]: IdentifierScopeType[] | undefined;
109
+ };
106
110
  scopes: {
107
111
  vFor: number;
108
112
  vSlot: number;
@@ -120,8 +124,9 @@ export interface TransformContext extends Required<Omit<TransformOptions, keyof
120
124
  replaceNode(node: TemplateChildNode): void;
121
125
  removeNode(node?: TemplateChildNode): void;
122
126
  onNodeRemoved(): void;
123
- addIdentifiers(exp: ExpressionNode | string): void;
127
+ addIdentifiers(exp: ExpressionNode | string, type?: IdentifierScopeType): void;
124
128
  removeIdentifiers(exp: ExpressionNode | string): void;
129
+ isSlotScopeIdentifier(name: string): boolean;
125
130
  hoist(exp: string | JSChildNode | ArrayExpression): SimpleExpressionNode;
126
131
  cache(exp: JSChildNode, isVNode?: boolean, inVOnce?: boolean): CacheExpression;
127
132
  constantCache: WeakMap<TemplateChildNode, ConstantTypes>;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-core v3.6.0-beta.10
2
+ * @vue/compiler-core v3.6.0-beta.12
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -2514,6 +2514,7 @@ function createTransformContext(root, { filename = "", prefixIdentifiers = false
2514
2514
  constantCache: /* @__PURE__ */ new WeakMap(),
2515
2515
  temps: 0,
2516
2516
  identifiers: Object.create(null),
2517
+ identifierScopes: Object.create(null),
2517
2518
  scopes: {
2518
2519
  vFor: 0,
2519
2520
  vSlot: 0,
@@ -2567,8 +2568,12 @@ function createTransformContext(root, { filename = "", prefixIdentifiers = false
2567
2568
  context.parent.children.splice(removalIndex, 1);
2568
2569
  },
2569
2570
  onNodeRemoved: NOOP,
2570
- addIdentifiers(exp) {},
2571
+ addIdentifiers(exp, type = "local") {},
2571
2572
  removeIdentifiers(exp) {},
2573
+ isSlotScopeIdentifier(name) {
2574
+ const scopes = context.identifierScopes[name];
2575
+ return scopes ? scopes[scopes.length - 1] === "slot" : false;
2576
+ },
2572
2577
  hoist(exp) {
2573
2578
  if (isString(exp)) exp = createSimpleExpression(exp);
2574
2579
  context.hoists.push(exp);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/compiler-core",
3
- "version": "3.6.0-beta.10",
3
+ "version": "3.6.0-beta.12",
4
4
  "description": "@vue/compiler-core",
5
5
  "main": "index.js",
6
6
  "module": "dist/compiler-core.esm-bundler.js",
@@ -46,11 +46,11 @@
46
46
  },
47
47
  "homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-core#readme",
48
48
  "dependencies": {
49
- "@babel/parser": "^7.29.2",
49
+ "@babel/parser": "^7.29.3",
50
50
  "entities": "^7.0.1",
51
51
  "estree-walker": "^2.0.2",
52
52
  "source-map-js": "^1.2.1",
53
- "@vue/shared": "3.6.0-beta.10"
53
+ "@vue/shared": "3.6.0-beta.12"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@babel/types": "^7.29.0"