@wevu/compiler 6.16.4 → 6.16.6

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.d.mts CHANGED
@@ -213,6 +213,7 @@ interface ScopedSlotComponentAsset {
213
213
  componentName: string;
214
214
  slotKey: string;
215
215
  template: string;
216
+ componentGenerics?: Record<string, true>;
216
217
  classStyleBindings?: ClassStyleBinding[];
217
218
  classStyleWxs?: boolean;
218
219
  inlineExpressions?: InlineExpressionAsset[];
package/dist/index.mjs CHANGED
@@ -328,6 +328,11 @@ async function pathExists$1(path) {
328
328
  }
329
329
  }
330
330
  //#endregion
331
+ //#region src/utils/object.ts
332
+ function hasOwn(source, key) {
333
+ return Object.prototype.hasOwnProperty.call(source, key);
334
+ }
335
+ //#endregion
331
336
  //#region src/plugins/vue/transform/tempDirLock.ts
332
337
  const locks = /* @__PURE__ */ new Map();
333
338
  async function withTempDirLock(tempDir, fn) {
@@ -500,7 +505,7 @@ const __weapp_defineThemeJson = (config) => (__weapp_json_macro_values.push(conf
500
505
  if (typeof next === "function") next = next();
501
506
  if (next && typeof next.then === "function") next = await next;
502
507
  if (!next || typeof next !== "object" || Array.isArray(next)) throw new Error("宏的返回值必须解析为对象。");
503
- if (Object.hasOwn(next, "$schema")) delete next.$schema;
508
+ if (hasOwn(next, "$schema")) delete next.$schema;
504
509
  if (options?.merge) {
505
510
  const merged = options.merge(accumulator, next);
506
511
  if (merged && typeof merged === "object" && !Array.isArray(merged)) accumulator = merged;
@@ -2435,7 +2440,7 @@ function stripVirtualHostFromDefaults(defaults) {
2435
2440
  const next = { ...defaults };
2436
2441
  const options = next.options;
2437
2442
  if (!isPlainRecord(options)) return next;
2438
- if (!Object.hasOwn(options, "virtualHost")) return next;
2443
+ if (!hasOwn(options, "virtualHost")) return next;
2439
2444
  const copiedOptions = { ...options };
2440
2445
  delete copiedOptions.virtualHost;
2441
2446
  if (Object.keys(copiedOptions).length > 0) next.options = copiedOptions;
@@ -2855,7 +2860,7 @@ function resolveObjectExpressionFromProgram(program, name) {
2855
2860
  const normalized = unwrapTypeLikeExpression(declarator.init);
2856
2861
  if (t.isObjectExpression(normalized)) return normalized;
2857
2862
  if (t.isCallExpression(normalized) && isObjectAssignCall(normalized)) {
2858
- const lastArg = normalized.arguments.at(-1);
2863
+ const lastArg = normalized.arguments[normalized.arguments.length - 1];
2859
2864
  if (lastArg && !t.isSpreadElement(lastArg) && t.isExpression(lastArg)) {
2860
2865
  const lastNormalized = unwrapTypeLikeExpression(lastArg);
2861
2866
  if (t.isObjectExpression(lastNormalized)) return lastNormalized;
@@ -3052,10 +3057,10 @@ function lowerOptionalChain(node) {
3052
3057
  if (!chain) return t.cloneNode(node);
3053
3058
  const segments = [chain.base];
3054
3059
  for (const operation of chain.operations) {
3055
- const currentBase = t.cloneNode(segments.at(-1));
3060
+ const currentBase = t.cloneNode(segments[segments.length - 1]);
3056
3061
  segments.push(applyOptionalChainOperation(currentBase, operation));
3057
3062
  }
3058
- let lowered = t.cloneNode(segments.at(-1));
3063
+ let lowered = t.cloneNode(segments[segments.length - 1]);
3059
3064
  for (let index = chain.operations.length - 1; index >= 0; index--) {
3060
3065
  if (!chain.operations[index].optional) continue;
3061
3066
  lowered = t.conditionalExpression(t.binaryExpression("==", t.cloneNode(segments[index]), t.nullLiteral()), t.identifier("undefined"), lowered);
@@ -5050,7 +5055,7 @@ function collectScopePropMapping(context) {
5050
5055
  if (!context.slotMultipleInstance) return mapping;
5051
5056
  for (const scope of context.scopeStack) for (const name of scope) {
5052
5057
  if (!IDENTIFIER_RE$3.test(name)) continue;
5053
- if (!Object.hasOwn(mapping, name)) mapping[name] = name;
5058
+ if (!hasOwn(mapping, name)) mapping[name] = name;
5054
5059
  }
5055
5060
  return mapping;
5056
5061
  }
@@ -5157,7 +5162,7 @@ function rewriteScopedSlotExpression(exp, context) {
5157
5162
  const name = path.node.name;
5158
5163
  if (SCOPED_SLOT_GLOBALS.has(name)) return;
5159
5164
  if (path.scope.hasBinding(name)) return;
5160
- if (Object.hasOwn(forAliases, name)) {
5165
+ if (hasOwn(forAliases, name)) {
5161
5166
  const aliasExp = parseBabelExpression(forAliases[name]);
5162
5167
  if (aliasExp) {
5163
5168
  replaceIdentifierWithExpression(path, t.cloneNode(aliasExp, true));
@@ -5165,7 +5170,7 @@ function rewriteScopedSlotExpression(exp, context) {
5165
5170
  }
5166
5171
  }
5167
5172
  if (locals.has(name)) return;
5168
- if (Object.hasOwn(slotProps, name)) {
5173
+ if (hasOwn(slotProps, name)) {
5169
5174
  replaceIdentifierWithExpression(path, createMemberAccess(WEVU_SLOT_PROPS_DATA_KEY, slotProps[name]));
5170
5175
  return;
5171
5176
  }
@@ -5186,7 +5191,7 @@ function rewriteForAliasExpression(exp, context) {
5186
5191
  if (!path.isReferencedIdentifier()) return;
5187
5192
  const name = path.node.name;
5188
5193
  if (path.scope.hasBinding(name)) return;
5189
- if (!Object.hasOwn(forAliases, name)) return;
5194
+ if (!hasOwn(forAliases, name)) return;
5190
5195
  const aliasExp = parseBabelExpression(forAliases[name]);
5191
5196
  if (!aliasExp) return;
5192
5197
  replaceIdentifierWithExpression(path, t.cloneNode(aliasExp, true));
@@ -5353,7 +5358,7 @@ function createMemberAccess$1(target, prop) {
5353
5358
  return t.memberExpression(t.identifier(target), t.stringLiteral(prop), true);
5354
5359
  }
5355
5360
  function resolveSlotPropBinding(slotProps, name) {
5356
- if (!Object.hasOwn(slotProps, name)) return null;
5361
+ if (!hasOwn(slotProps, name)) return null;
5357
5362
  const prop = slotProps[name];
5358
5363
  if (!prop) return WEVU_SLOT_PROPS_DATA_KEY;
5359
5364
  return generateExpression(createMemberAccess$1(WEVU_SLOT_PROPS_DATA_KEY, prop));
@@ -5583,7 +5588,7 @@ function normalizeJsExpressionWithContext(exp, context, options) {
5583
5588
  const name = path.node.name;
5584
5589
  if (JS_RUNTIME_GLOBALS.has(name)) return;
5585
5590
  if (path.scope.hasBinding(name)) return;
5586
- if (Object.hasOwn(forAliases, name)) {
5591
+ if (hasOwn(forAliases, name)) {
5587
5592
  const aliasExp = parseBabelExpression(forAliases[name]);
5588
5593
  if (aliasExp) {
5589
5594
  const replacement = t.cloneNode(aliasExp, true);
@@ -5599,7 +5604,7 @@ function normalizeJsExpressionWithContext(exp, context, options) {
5599
5604
  }
5600
5605
  if (locals.has(name)) return;
5601
5606
  let replacement;
5602
- if (context.rewriteScopedSlot) if (Object.hasOwn(slotProps, name)) {
5607
+ if (context.rewriteScopedSlot) if (hasOwn(slotProps, name)) {
5603
5608
  const prop = slotProps[name];
5604
5609
  const base = createThisMemberAccess(WEVU_SLOT_PROPS_DATA_KEY);
5605
5610
  replacement = createUnrefCall(prop ? createMemberAccess(base, prop) : base);
@@ -6352,9 +6357,16 @@ function createScopedSlotComponent(context, slotKey, props, children, transformN
6352
6357
  const index = context.scopedSlotComponents.length;
6353
6358
  const id = `${slotKey}-${index}`;
6354
6359
  const componentName = `scoped-slot-${ownerHash}-${slotKey}-${index}`;
6360
+ const asset = {
6361
+ id,
6362
+ componentName,
6363
+ slotKey,
6364
+ template: ""
6365
+ };
6366
+ context.scopedSlotComponents.push(asset);
6355
6367
  const scopedContext = {
6356
6368
  ...context,
6357
- scopedSlotComponents: [],
6369
+ scopedSlotComponents: context.scopedSlotComponents,
6358
6370
  componentGenerics: {},
6359
6371
  scopeStack: [],
6360
6372
  slotPropStack: [],
@@ -6373,15 +6385,11 @@ function createScopedSlotComponent(context, slotKey, props, children, transformN
6373
6385
  return children.map((child) => transformNode(child, scopedContext)).join("");
6374
6386
  });
6375
6387
  if (scopedContext.classStyleWxs) template = `${buildClassStyleWxsTag(scopedContext.classStyleWxsExtension || "wxs", scopedContext.classStyleWxsSrc)}\n${template}`;
6376
- context.scopedSlotComponents.push({
6377
- id,
6378
- componentName,
6379
- slotKey,
6380
- template,
6381
- classStyleBindings: scopedContext.classStyleBindings.length ? scopedContext.classStyleBindings : void 0,
6382
- classStyleWxs: scopedContext.classStyleWxs || void 0,
6383
- inlineExpressions: scopedContext.inlineExpressions.length ? scopedContext.inlineExpressions : void 0
6384
- });
6388
+ asset.template = template;
6389
+ asset.componentGenerics = Object.keys(scopedContext.componentGenerics).length ? scopedContext.componentGenerics : void 0;
6390
+ asset.classStyleBindings = scopedContext.classStyleBindings.length ? scopedContext.classStyleBindings : void 0;
6391
+ asset.classStyleWxs = scopedContext.classStyleWxs || void 0;
6392
+ asset.inlineExpressions = scopedContext.inlineExpressions.length ? scopedContext.inlineExpressions : void 0;
6385
6393
  return {
6386
6394
  componentName,
6387
6395
  slotKey
@@ -7387,7 +7395,7 @@ function rewriteFunctionSourceWithScopeValues(source, scopeValues) {
7387
7395
  traverse(wrappedAst, { Identifier(path) {
7388
7396
  if (!path.isReferencedIdentifier()) return;
7389
7397
  if (path.scope.hasBinding(path.node.name)) return;
7390
- if (!Object.hasOwn(scopeValues, path.node.name)) return;
7398
+ if (!hasOwn(scopeValues, path.node.name)) return;
7391
7399
  try {
7392
7400
  const replacement = serializeStaticValueToExpression(scopeValues[path.node.name], /* @__PURE__ */ new WeakSet(), {});
7393
7401
  path.replaceWith(parseExpressionFromSource(replacement));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wevu/compiler",
3
3
  "type": "module",
4
- "version": "6.16.4",
4
+ "version": "6.16.6",
5
5
  "description": "wevu 编译器基础包,面向小程序模板的编译与转换",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -42,17 +42,17 @@
42
42
  ],
43
43
  "dependencies": {
44
44
  "@jridgewell/remapping": "^2.3.5",
45
- "@vue/compiler-core": "^3.5.33",
46
- "@vue/compiler-dom": "^3.5.33",
45
+ "@vue/compiler-core": "^3.5.34",
46
+ "@vue/compiler-dom": "^3.5.34",
47
47
  "comment-json": "^5.0.0",
48
48
  "lru-cache": "^11.3.6",
49
49
  "magic-string": "^0.30.21",
50
50
  "merge": "^2.1.1",
51
51
  "pathe": "^2.0.3",
52
- "vue": "^3.5.33",
52
+ "vue": "^3.5.34",
53
53
  "@weapp-core/constants": "^0.1.4",
54
54
  "@weapp-core/shared": "3.0.4",
55
- "@weapp-vite/ast": "6.16.4",
55
+ "@weapp-vite/ast": "6.16.6",
56
56
  "rolldown-require": "2.0.15"
57
57
  },
58
58
  "publishConfig": {