weapp-vite 5.6.0 → 5.6.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.
@@ -22964,6 +22964,8 @@ var watchedCssExts = new Set(supportedCssLangs.map((ext2) => `.${ext2}`));
22964
22964
  var configSuffixes = configExtensions.map((ext2) => `.${ext2}`);
22965
22965
  var sidecarSuffixes = [...configSuffixes, ...watchedCssExts];
22966
22966
  var watchLimitErrorCodes = /* @__PURE__ */ new Set(["EMFILE", "ENOSPC"]);
22967
+ var importProtocols = /^(?:https?:|data:|blob:|\/)/i;
22968
+ var cssImportRE = /@(import|wv-keep-import)\s+(?:url\()?['"]?([^'")\s]+)['"]?\)?/gi;
22967
22969
  function isWatchLimitError(error) {
22968
22970
  if (!error || typeof error !== "object") {
22969
22971
  return false;
@@ -22974,9 +22976,198 @@ function isWatchLimitError(error) {
22974
22976
  }
22975
22977
  return watchLimitErrorCodes.has(maybeError.code);
22976
22978
  }
22977
- async function invalidateEntryForSidecar(filePath) {
22979
+ function normalizePath2(p) {
22980
+ return _pathe2.default.normalize(p);
22981
+ }
22982
+ function ensureCssGraph(ctx) {
22983
+ return ctx.runtimeState.css;
22984
+ }
22985
+ function cleanupImporterGraph(ctx, importer) {
22986
+ const graph = ensureCssGraph(ctx);
22987
+ const normalizedImporter = normalizePath2(importer);
22988
+ const existingDeps = graph.importerToDependencies.get(normalizedImporter);
22989
+ if (!existingDeps) {
22990
+ return;
22991
+ }
22992
+ graph.importerToDependencies.delete(normalizedImporter);
22993
+ for (const dep of existingDeps) {
22994
+ const importers = graph.dependencyToImporters.get(dep);
22995
+ if (!importers) {
22996
+ continue;
22997
+ }
22998
+ importers.delete(normalizedImporter);
22999
+ if (importers.size === 0) {
23000
+ graph.dependencyToImporters.delete(dep);
23001
+ }
23002
+ }
23003
+ }
23004
+ function registerCssImports(ctx, importer, dependencies) {
23005
+ const graph = ensureCssGraph(ctx);
23006
+ const normalizedImporter = normalizePath2(importer);
23007
+ const normalizedDeps = /* @__PURE__ */ new Set();
23008
+ for (const dependency of dependencies) {
23009
+ if (!dependency) {
23010
+ continue;
23011
+ }
23012
+ normalizedDeps.add(normalizePath2(dependency));
23013
+ }
23014
+ const previousDeps = _nullishCoalesce(graph.importerToDependencies.get(normalizedImporter), () => ( /* @__PURE__ */ new Set()));
23015
+ if (previousDeps.size) {
23016
+ for (const previous of previousDeps) {
23017
+ if (normalizedDeps.has(previous)) {
23018
+ continue;
23019
+ }
23020
+ const importers = graph.dependencyToImporters.get(previous);
23021
+ if (!importers) {
23022
+ continue;
23023
+ }
23024
+ importers.delete(normalizedImporter);
23025
+ if (importers.size === 0) {
23026
+ graph.dependencyToImporters.delete(previous);
23027
+ }
23028
+ }
23029
+ }
23030
+ graph.importerToDependencies.set(normalizedImporter, normalizedDeps);
23031
+ for (const dependency of normalizedDeps) {
23032
+ let importers = graph.dependencyToImporters.get(dependency);
23033
+ if (!importers) {
23034
+ importers = /* @__PURE__ */ new Set();
23035
+ graph.dependencyToImporters.set(dependency, importers);
23036
+ }
23037
+ importers.add(normalizedImporter);
23038
+ }
23039
+ }
23040
+ async function extractCssImportDependencies(ctx, importer) {
23041
+ try {
23042
+ const stats = await actualFS.default.promises.stat(importer);
23043
+ if (!stats.isFile()) {
23044
+ cleanupImporterGraph(ctx, importer);
23045
+ return;
23046
+ }
23047
+ } catch (e27) {
23048
+ cleanupImporterGraph(ctx, importer);
23049
+ return;
23050
+ }
23051
+ let cssContent;
23052
+ try {
23053
+ cssContent = await actualFS.default.promises.readFile(importer, "utf8");
23054
+ } catch (e28) {
23055
+ cleanupImporterGraph(ctx, importer);
23056
+ return;
23057
+ }
23058
+ cssImportRE.lastIndex = 0;
23059
+ const dependencies = /* @__PURE__ */ new Set();
23060
+ const dir = _pathe2.default.dirname(importer);
23061
+ while (true) {
23062
+ const match2 = cssImportRE.exec(cssContent);
23063
+ if (!match2) {
23064
+ break;
23065
+ }
23066
+ const rawSpecifier = _optionalChain([match2, 'access', _362 => _362[2], 'optionalAccess', _363 => _363.trim, 'call', _364 => _364()]);
23067
+ if (!rawSpecifier) {
23068
+ continue;
23069
+ }
23070
+ if (importProtocols.test(rawSpecifier)) {
23071
+ if (rawSpecifier.startsWith("/")) {
23072
+ const absolute = _pathe2.default.resolve(ctx.configService.absoluteSrcRoot, rawSpecifier.slice(1));
23073
+ dependencies.add(absolute);
23074
+ const ext3 = _pathe2.default.extname(absolute);
23075
+ if (ext3) {
23076
+ dependencies.add(absolute.slice(0, -ext3.length));
23077
+ }
23078
+ }
23079
+ continue;
23080
+ }
23081
+ let specifier = rawSpecifier;
23082
+ if (specifier.startsWith("@/")) {
23083
+ specifier = _pathe2.default.join(ctx.configService.absoluteSrcRoot, specifier.slice(2));
23084
+ } else if (specifier === "@") {
23085
+ specifier = ctx.configService.absoluteSrcRoot;
23086
+ }
23087
+ if (specifier.startsWith("~")) {
23088
+ specifier = specifier.slice(1);
23089
+ }
23090
+ const cleaned = specifier.replace(/[?#].*$/, "");
23091
+ const resolved = _pathe2.default.resolve(dir, cleaned);
23092
+ dependencies.add(resolved);
23093
+ const ext2 = _pathe2.default.extname(resolved);
23094
+ if (!ext2) {
23095
+ dependencies.add(resolved);
23096
+ } else {
23097
+ dependencies.add(resolved.slice(0, -ext2.length));
23098
+ }
23099
+ }
23100
+ registerCssImports(ctx, importer, dependencies);
23101
+ }
23102
+ function collectCssImporters(ctx, dependency) {
23103
+ const graph = ensureCssGraph(ctx);
23104
+ const normalizedDependency = normalizePath2(dependency);
23105
+ const matches2 = /* @__PURE__ */ new Set();
23106
+ const direct = graph.dependencyToImporters.get(normalizedDependency);
23107
+ if (direct) {
23108
+ for (const importer of direct) {
23109
+ matches2.add(importer);
23110
+ }
23111
+ }
23112
+ const ext2 = _pathe2.default.extname(normalizedDependency);
23113
+ if (ext2) {
23114
+ const base = normalizedDependency.slice(0, -ext2.length);
23115
+ const baseMatches = graph.dependencyToImporters.get(base);
23116
+ if (baseMatches) {
23117
+ for (const importer of baseMatches) {
23118
+ matches2.add(importer);
23119
+ }
23120
+ }
23121
+ }
23122
+ return matches2;
23123
+ }
23124
+ async function resolveScriptForCss(cache2, basePath) {
23125
+ const cached = cache2.get(basePath);
23126
+ if (cached !== void 0) {
23127
+ return cached;
23128
+ }
23129
+ const result = await findJsEntry(basePath);
23130
+ const scriptPath = result.path;
23131
+ cache2.set(basePath, scriptPath);
23132
+ return scriptPath;
23133
+ }
23134
+ async function collectAffectedScriptsAndImporters(ctx, startCssFile) {
23135
+ const queue = [normalizePath2(startCssFile)];
23136
+ const visitedCss = /* @__PURE__ */ new Set();
23137
+ const affectedImporters = /* @__PURE__ */ new Set();
23138
+ const affectedScripts = /* @__PURE__ */ new Set();
23139
+ const scriptCache = /* @__PURE__ */ new Map();
23140
+ while (queue.length) {
23141
+ const current2 = queue.shift();
23142
+ if (visitedCss.has(current2)) {
23143
+ continue;
23144
+ }
23145
+ visitedCss.add(current2);
23146
+ const ext2 = _pathe2.default.extname(current2);
23147
+ if (ext2) {
23148
+ const base = current2.slice(0, -ext2.length);
23149
+ const script = await resolveScriptForCss(scriptCache, base);
23150
+ if (script) {
23151
+ affectedScripts.add(script);
23152
+ }
23153
+ }
23154
+ const importers = collectCssImporters(ctx, current2);
23155
+ for (const importer of importers) {
23156
+ if (!visitedCss.has(importer)) {
23157
+ queue.push(importer);
23158
+ }
23159
+ affectedImporters.add(importer);
23160
+ }
23161
+ }
23162
+ return {
23163
+ importers: affectedImporters,
23164
+ scripts: affectedScripts
23165
+ };
23166
+ }
23167
+ async function invalidateEntryForSidecar(ctx, filePath, event = "update") {
22978
23168
  const configSuffix = configSuffixes.find((suffix) => filePath.endsWith(suffix));
22979
23169
  const ext2 = _pathe2.default.extname(filePath);
23170
+ const normalizedPath = normalizePath2(filePath);
22980
23171
  let scriptBasePath;
22981
23172
  if (configSuffix) {
22982
23173
  scriptBasePath = filePath.slice(0, -configSuffix.length);
@@ -22986,11 +23177,51 @@ async function invalidateEntryForSidecar(filePath) {
22986
23177
  if (!scriptBasePath) {
22987
23178
  return;
22988
23179
  }
22989
- const { path: scriptPath } = await findJsEntry(scriptBasePath);
22990
- if (!scriptPath) {
23180
+ const touchedTargets = /* @__PURE__ */ new Set();
23181
+ const touchedScripts = /* @__PURE__ */ new Set();
23182
+ const primaryScript = await findJsEntry(scriptBasePath);
23183
+ if (primaryScript.path) {
23184
+ touchedScripts.add(primaryScript.path);
23185
+ }
23186
+ if (!primaryScript.path && ext2 && watchedCssExts.has(ext2)) {
23187
+ const { importers, scripts } = await collectAffectedScriptsAndImporters(ctx, normalizedPath);
23188
+ for (const importer of importers) {
23189
+ touchedTargets.add(importer);
23190
+ }
23191
+ for (const script of scripts) {
23192
+ touchedScripts.add(script);
23193
+ }
23194
+ }
23195
+ const isCssSidecar = Boolean(ext2 && watchedCssExts.has(ext2));
23196
+ const configService = ctx.configService;
23197
+ const relativeSource = configService.relativeCwd(normalizedPath);
23198
+ for (const target of touchedTargets) {
23199
+ try {
23200
+ await touch(target);
23201
+ } catch (e29) {
23202
+ }
23203
+ }
23204
+ for (const script of touchedScripts) {
23205
+ try {
23206
+ await touch(script);
23207
+ } catch (e30) {
23208
+ }
23209
+ }
23210
+ if (!touchedTargets.size && !touchedScripts.size) {
23211
+ if (event === "create" && isCssSidecar) {
23212
+ logger_default.info(`[sidecar:${event}] ${relativeSource} \u65B0\u589E\uFF0C\u4F46\u672A\u627E\u5230\u5F15\u7528\u65B9\uFF0C\u7B49\u5F85\u540E\u7EED\u5173\u8054`);
23213
+ }
22991
23214
  return;
22992
23215
  }
22993
- await touch(scriptPath);
23216
+ const touchedList = [];
23217
+ for (const target of touchedTargets) {
23218
+ touchedList.push(configService.relativeCwd(target));
23219
+ }
23220
+ for (const script of touchedScripts) {
23221
+ touchedList.push(configService.relativeCwd(script));
23222
+ }
23223
+ const uniqueTouched = Array.from(new Set(touchedList));
23224
+ logger_default.success(`[sidecar:${event}] ${relativeSource} -> \u5237\u65B0 ${uniqueTouched.join(", ")}`);
22994
23225
  }
22995
23226
  function ensureSidecarWatcher(ctx, rootDir) {
22996
23227
  if (!ctx.configService.isDev || !rootDir || _process2.default.env.VITEST === "true" || _process2.default.env.NODE_ENV === "test") {
@@ -23004,32 +23235,51 @@ function ensureSidecarWatcher(ctx, rootDir) {
23004
23235
  if (sidecarWatcherMap.has(absRoot)) {
23005
23236
  return;
23006
23237
  }
23007
- const handleSidecarChange = (filePath) => {
23238
+ let isReady = false;
23239
+ const handleSidecarChange = (event, filePath, ready) => {
23008
23240
  if (!isSidecarFile(filePath)) {
23009
23241
  return;
23010
23242
  }
23011
- void invalidateEntryForSidecar(filePath);
23243
+ const ext2 = _pathe2.default.extname(filePath);
23244
+ const isCssFile = Boolean(ext2 && watchedCssExts.has(ext2));
23245
+ if (isCssFile && (event === "create" || event === "update")) {
23246
+ void extractCssImportDependencies(ctx, filePath);
23247
+ }
23248
+ const shouldInvalidate = event === "create" && ready || event === "delete";
23249
+ if (shouldInvalidate) {
23250
+ void (async () => {
23251
+ await invalidateEntryForSidecar(ctx, filePath, event);
23252
+ if (isCssFile && event === "delete") {
23253
+ cleanupImporterGraph(ctx, filePath);
23254
+ }
23255
+ })();
23256
+ return;
23257
+ }
23258
+ if (isCssFile && event === "delete") {
23259
+ cleanupImporterGraph(ctx, filePath);
23260
+ }
23012
23261
  };
23013
23262
  const patterns = [
23014
23263
  ...configExtensions.map((ext2) => _pathe2.default.join(absRoot, `**/*.${ext2}`)),
23015
23264
  ...supportedCssLangs.map((ext2) => _pathe2.default.join(absRoot, `**/*.${ext2}`))
23016
23265
  ];
23017
23266
  const watcher = esm_default.watch(patterns, {
23018
- ignoreInitial: true,
23267
+ ignoreInitial: false,
23019
23268
  persistent: true,
23020
23269
  awaitWriteFinish: {
23021
23270
  stabilityThreshold: 100,
23022
23271
  pollInterval: 20
23023
23272
  }
23024
23273
  });
23025
- const forwardChange = (input) => {
23274
+ const forwardChange = (event, input) => {
23026
23275
  if (!input) {
23027
23276
  return;
23028
23277
  }
23029
- handleSidecarChange(_pathe2.default.normalize(input));
23278
+ handleSidecarChange(event, _pathe2.default.normalize(input), isReady);
23030
23279
  };
23031
- watcher.on("add", forwardChange);
23032
- watcher.on("unlink", forwardChange);
23280
+ watcher.on("add", (path36) => forwardChange("create", path36));
23281
+ watcher.on("change", (path36) => forwardChange("update", path36));
23282
+ watcher.on("unlink", (path36) => forwardChange("delete", path36));
23033
23283
  watcher.on("raw", (eventName, rawPath, details) => {
23034
23284
  if (eventName !== "rename") {
23035
23285
  return;
@@ -23040,14 +23290,17 @@ function ensureSidecarWatcher(ctx, rootDir) {
23040
23290
  }
23041
23291
  const baseDir = typeof details === "object" && details && "watchedPath" in details ? _nullishCoalesce(details.watchedPath, () => ( absRoot)) : absRoot;
23042
23292
  const resolved = _pathe2.default.isAbsolute(candidate) ? candidate : _pathe2.default.resolve(baseDir, candidate);
23043
- forwardChange(resolved);
23293
+ forwardChange("create", resolved);
23294
+ });
23295
+ watcher.on("ready", () => {
23296
+ isReady = true;
23044
23297
  });
23045
23298
  watcher.on("error", (error) => {
23046
23299
  if (!isWatchLimitError(error)) {
23047
23300
  return;
23048
23301
  }
23049
23302
  const relativeRoot = ctx.configService.relativeCwd(absRoot);
23050
- const code = _nullishCoalesce(_optionalChain([error, 'optionalAccess', _362 => _362.code]), () => ( "UNKNOWN"));
23303
+ const code = _nullishCoalesce(_optionalChain([error, 'optionalAccess', _365 => _365.code]), () => ( "UNKNOWN"));
23051
23304
  logger_default.warn(`[watch] ${relativeRoot} \u76D1\u542C\u6570\u91CF\u8FBE\u5230\u4E0A\u9650 (${code})\uFF0C\u4FA7\u8F66\u6587\u4EF6\u76D1\u542C\u5DF2\u505C\u7528`);
23052
23305
  });
23053
23306
  sidecarWatcherMap.set(absRoot, {
@@ -23214,7 +23467,7 @@ function createCacheKey(options) {
23214
23467
  return `${options.removeComment ? 1 : 0}|${options.transformEvent ? 1 : 0}`;
23215
23468
  }
23216
23469
  function getCachedResult(data2, cacheKey) {
23217
- return _optionalChain([handleCache, 'access', _363 => _363.get, 'call', _364 => _364(data2), 'optionalAccess', _365 => _365.get, 'call', _366 => _366(cacheKey)]);
23470
+ return _optionalChain([handleCache, 'access', _366 => _366.get, 'call', _367 => _367(data2), 'optionalAccess', _368 => _368.get, 'call', _369 => _369(cacheKey)]);
23218
23471
  }
23219
23472
  function setCachedResult(data2, cacheKey, result) {
23220
23473
  let cacheForToken = handleCache.get(data2);
@@ -23290,7 +23543,7 @@ function handleWxml(data2, options) {
23290
23543
  if (shouldTransformInlineWxs) {
23291
23544
  for (const { end, start, value } of inlineWxsTokens) {
23292
23545
  const { result } = getCachedInlineWxsTransform(value);
23293
- if (_optionalChain([result, 'optionalAccess', _367 => _367.code])) {
23546
+ if (_optionalChain([result, 'optionalAccess', _370 => _370.code])) {
23294
23547
  ms.update(start, end, `
23295
23548
  ${result.code}`);
23296
23549
  }
@@ -23341,11 +23594,11 @@ function emitWxmlAssetsWithCache(options) {
23341
23594
  });
23342
23595
  const emittedFiles = [];
23343
23596
  for (const { id, fileName, token } of currentPackageWxmls) {
23344
- _optionalChain([runtime, 'access', _368 => _368.addWatchFile, 'optionalCall', _369 => _369(id)]);
23597
+ _optionalChain([runtime, 'access', _371 => _371.addWatchFile, 'optionalCall', _372 => _372(id)]);
23345
23598
  const deps = wxmlService.depsMap.get(id);
23346
23599
  if (deps) {
23347
23600
  for (const dep of deps) {
23348
- _optionalChain([runtime, 'access', _370 => _370.addWatchFile, 'optionalCall', _371 => _371(dep)]);
23601
+ _optionalChain([runtime, 'access', _373 => _373.addWatchFile, 'optionalCall', _374 => _374(dep)]);
23349
23602
  }
23350
23603
  }
23351
23604
  emittedFiles.push(fileName);
@@ -23427,7 +23680,7 @@ function createCoreLifecyclePlugin(state) {
23427
23680
  let handledByIndependentWatcher = false;
23428
23681
  let independentMeta;
23429
23682
  if (change.event === "create" || change.event === "delete") {
23430
- await invalidateEntryForSidecar(id);
23683
+ await invalidateEntryForSidecar(ctx, id, change.event);
23431
23684
  }
23432
23685
  if (!subPackageMeta) {
23433
23686
  if (relativeSrc === "app.json" || relativeCwd === "project.config.json" || relativeCwd === "project.private.config.json") {
@@ -23441,7 +23694,7 @@ function createCoreLifecyclePlugin(state) {
23441
23694
  buildService.invalidateIndependentOutput(independentRoot);
23442
23695
  scanService.markIndependentDirty(independentRoot);
23443
23696
  handledByIndependentWatcher = true;
23444
- if (_optionalChain([independentMeta, 'optionalAccess', _372 => _372.watchSharedStyles]) !== false) {
23697
+ if (_optionalChain([independentMeta, 'optionalAccess', _375 => _375.watchSharedStyles]) !== false) {
23445
23698
  invalidateSharedStyleCache();
23446
23699
  }
23447
23700
  }
@@ -23489,7 +23742,7 @@ function createCoreLifecyclePlugin(state) {
23489
23742
  options.input = scannedInput;
23490
23743
  },
23491
23744
  async load(id) {
23492
- _optionalChain([configService, 'access', _373 => _373.weappViteConfig, 'optionalAccess', _374 => _374.debug, 'optionalAccess', _375 => _375.load, 'optionalCall', _376 => _376(id, subPackageMeta)]);
23745
+ _optionalChain([configService, 'access', _376 => _376.weappViteConfig, 'optionalAccess', _377 => _377.debug, 'optionalAccess', _378 => _378.load, 'optionalCall', _379 => _379(id, subPackageMeta)]);
23493
23746
  const relativeBasename = _shared.removeExtensionDeep.call(void 0, configService.relativeAbsoluteSrcRoot(id));
23494
23747
  if (isCSSRequest(id)) {
23495
23748
  const parsed = parseRequest(id);
@@ -23503,7 +23756,7 @@ function createCoreLifecyclePlugin(state) {
23503
23756
  }
23504
23757
  return null;
23505
23758
  }
23506
- if (loadedEntrySet.has(id) || _optionalChain([subPackageMeta, 'optionalAccess', _377 => _377.entries, 'access', _378 => _378.includes, 'call', _379 => _379(relativeBasename)])) {
23759
+ if (loadedEntrySet.has(id) || _optionalChain([subPackageMeta, 'optionalAccess', _380 => _380.entries, 'access', _381 => _381.includes, 'call', _382 => _382(relativeBasename)])) {
23507
23760
  return await loadEntry.call(this, id, "component");
23508
23761
  }
23509
23762
  if (relativeBasename === "app") {
@@ -23534,8 +23787,8 @@ function createCoreLifecyclePlugin(state) {
23534
23787
  return subPackageRoots.find((root) => filePath === root || filePath.startsWith(`${root}/`));
23535
23788
  };
23536
23789
  var matchSubPackage = matchSubPackage2;
23537
- const sharedStrategy = _nullishCoalesce(_optionalChain([configService, 'access', _380 => _380.weappViteConfig, 'optionalAccess', _381 => _381.chunks, 'optionalAccess', _382 => _382.sharedStrategy]), () => ( DEFAULT_SHARED_CHUNK_STRATEGY));
23538
- const shouldLogChunks = _nullishCoalesce(_optionalChain([configService, 'access', _383 => _383.weappViteConfig, 'optionalAccess', _384 => _384.chunks, 'optionalAccess', _385 => _385.logOptimization]), () => ( true));
23790
+ const sharedStrategy = _nullishCoalesce(_optionalChain([configService, 'access', _383 => _383.weappViteConfig, 'optionalAccess', _384 => _384.chunks, 'optionalAccess', _385 => _385.sharedStrategy]), () => ( DEFAULT_SHARED_CHUNK_STRATEGY));
23791
+ const shouldLogChunks = _nullishCoalesce(_optionalChain([configService, 'access', _386 => _386.weappViteConfig, 'optionalAccess', _387 => _387.chunks, 'optionalAccess', _388 => _388.logOptimization]), () => ( true));
23539
23792
  const subPackageRoots = Array.from(scanService.subPackageMap.keys()).filter(Boolean);
23540
23793
  applySharedChunkStrategy.call(this, bundle, {
23541
23794
  strategy: sharedStrategy,
@@ -23580,10 +23833,10 @@ function createCoreLifecyclePlugin(state) {
23580
23833
  } : void 0
23581
23834
  });
23582
23835
  }
23583
- if (_optionalChain([configService, 'access', _386 => _386.weappViteConfig, 'optionalAccess', _387 => _387.debug, 'optionalAccess', _388 => _388.watchFiles])) {
23836
+ if (_optionalChain([configService, 'access', _389 => _389.weappViteConfig, 'optionalAccess', _390 => _390.debug, 'optionalAccess', _391 => _391.watchFiles])) {
23584
23837
  const watcherService = ctx.watcherService;
23585
- const watcherRoot = _nullishCoalesce(_optionalChain([subPackageMeta, 'optionalAccess', _389 => _389.subPackage, 'access', _390 => _390.root]), () => ( "/"));
23586
- const watcher = _optionalChain([watcherService, 'optionalAccess', _391 => _391.getRollupWatcher, 'call', _392 => _392(watcherRoot)]);
23838
+ const watcherRoot = _nullishCoalesce(_optionalChain([subPackageMeta, 'optionalAccess', _392 => _392.subPackage, 'access', _393 => _393.root]), () => ( "/"));
23839
+ const watcher = _optionalChain([watcherService, 'optionalAccess', _394 => _394.getRollupWatcher, 'call', _395 => _395(watcherRoot)]);
23587
23840
  let watchFiles;
23588
23841
  if (watcher && typeof watcher.getWatchFiles === "function") {
23589
23842
  watchFiles = await watcher.getWatchFiles();
@@ -23597,7 +23850,7 @@ function createCoreLifecyclePlugin(state) {
23597
23850
  }
23598
23851
  },
23599
23852
  buildEnd() {
23600
- _optionalChain([debug2, 'optionalCall', _393 => _393(`${subPackageMeta ? `\u72EC\u7ACB\u5206\u5305 ${subPackageMeta.subPackage.root}` : "\u4E3B\u5305"} ${Array.from(this.getModuleIds()).length} \u4E2A\u6A21\u5757\u88AB\u7F16\u8BD1`)]);
23853
+ _optionalChain([debug2, 'optionalCall', _396 => _396(`${subPackageMeta ? `\u72EC\u7ACB\u5206\u5305 ${subPackageMeta.subPackage.root}` : "\u4E3B\u5305"} ${Array.from(this.getModuleIds()).length} \u4E2A\u6A21\u5757\u88AB\u7F16\u8BD1`)]);
23601
23854
  }
23602
23855
  };
23603
23856
  }
@@ -23681,7 +23934,7 @@ async function flushIndependentBuilds(state) {
23681
23934
  }
23682
23935
  const outputs = await Promise.all(pendingIndependentBuilds);
23683
23936
  for (const { rollup } of outputs) {
23684
- const bundleOutputs = Array.isArray(_optionalChain([rollup, 'optionalAccess', _394 => _394.output])) ? rollup.output : [];
23937
+ const bundleOutputs = Array.isArray(_optionalChain([rollup, 'optionalAccess', _397 => _397.output])) ? rollup.output : [];
23685
23938
  for (const output of bundleOutputs) {
23686
23939
  if (output.type === "chunk") {
23687
23940
  this.emitFile({
@@ -23718,13 +23971,13 @@ function toPosixPath(value) {
23718
23971
  var styleMatcherCache = /* @__PURE__ */ new WeakMap();
23719
23972
  function collectSharedStyleEntries(ctx, configService) {
23720
23973
  const map = /* @__PURE__ */ new Map();
23721
- const registry = _optionalChain([ctx, 'access', _395 => _395.scanService, 'optionalAccess', _396 => _396.subPackageMap]);
23722
- if (!_optionalChain([registry, 'optionalAccess', _397 => _397.size])) {
23974
+ const registry = _optionalChain([ctx, 'access', _398 => _398.scanService, 'optionalAccess', _399 => _399.subPackageMap]);
23975
+ if (!_optionalChain([registry, 'optionalAccess', _400 => _400.size])) {
23723
23976
  return map;
23724
23977
  }
23725
23978
  const currentRoot = configService.currentSubPackageRoot;
23726
23979
  for (const [root, meta] of registry.entries()) {
23727
- if (!_optionalChain([meta, 'access', _398 => _398.styleEntries, 'optionalAccess', _399 => _399.length])) {
23980
+ if (!_optionalChain([meta, 'access', _401 => _401.styleEntries, 'optionalAccess', _402 => _402.length])) {
23728
23981
  continue;
23729
23982
  }
23730
23983
  if (currentRoot && root !== currentRoot) {
@@ -23769,12 +24022,12 @@ function getStyleMatcher(entry) {
23769
24022
  if (cached) {
23770
24023
  return cached;
23771
24024
  }
23772
- const includePatterns = _optionalChain([entry, 'access', _400 => _400.include, 'optionalAccess', _401 => _401.length]) ? entry.include : ["**/*"];
23773
- const excludePatterns = _optionalChain([entry, 'access', _402 => _402.exclude, 'optionalAccess', _403 => _403.length]) ? entry.exclude : void 0;
24025
+ const includePatterns = _optionalChain([entry, 'access', _403 => _403.include, 'optionalAccess', _404 => _404.length]) ? entry.include : ["**/*"];
24026
+ const excludePatterns = _optionalChain([entry, 'access', _405 => _405.exclude, 'optionalAccess', _406 => _406.length]) ? entry.exclude : void 0;
23774
24027
  const matcher = {
23775
24028
  include: _picomatch2.default.call(void 0, includePatterns, { dot: true })
23776
24029
  };
23777
- if (_optionalChain([excludePatterns, 'optionalAccess', _404 => _404.length])) {
24030
+ if (_optionalChain([excludePatterns, 'optionalAccess', _407 => _407.length])) {
23778
24031
  matcher.exclude = _picomatch2.default.call(void 0, excludePatterns, { dot: true });
23779
24032
  }
23780
24033
  styleMatcherCache.set(entry, matcher);
@@ -23879,7 +24132,7 @@ function injectSharedStyleImports(css2, modulePath, fileName, sharedStyles, conf
23879
24132
  }
23880
24133
  const normalizedFileName = toPosixPath(fileName);
23881
24134
  const entries = findSharedStylesForModule(normalizedModule, normalizedFileName, sharedStyles);
23882
- if (!_optionalChain([entries, 'optionalAccess', _405 => _405.length])) {
24135
+ if (!_optionalChain([entries, 'optionalAccess', _408 => _408.length])) {
23883
24136
  return css2;
23884
24137
  }
23885
24138
  const specifiers = resolveImportSpecifiers(fileName, entries);
@@ -24094,14 +24347,14 @@ function createPluginPruner() {
24094
24347
  name: "weapp-vite:preflight",
24095
24348
  enforce: "pre",
24096
24349
  configResolved(config) {
24097
- if (!_optionalChain([config, 'access', _406 => _406.plugins, 'optionalAccess', _407 => _407.length])) {
24350
+ if (!_optionalChain([config, 'access', _409 => _409.plugins, 'optionalAccess', _410 => _410.length])) {
24098
24351
  return;
24099
24352
  }
24100
24353
  for (const removePlugin of removePlugins) {
24101
24354
  const idx = config.plugins.findIndex((plugin) => plugin.name === removePlugin);
24102
24355
  if (idx > -1) {
24103
24356
  const [plugin] = config.plugins.splice(idx, 1);
24104
- plugin && _optionalChain([debug3, 'optionalCall', _408 => _408("remove plugin", plugin.name)]);
24357
+ plugin && _optionalChain([debug3, 'optionalCall', _411 => _411("remove plugin", plugin.name)]);
24105
24358
  }
24106
24359
  }
24107
24360
  }
@@ -24140,8 +24393,8 @@ function createWorkerBuildPlugin(ctx) {
24140
24393
  name: "weapp-vite:workers",
24141
24394
  enforce: "pre",
24142
24395
  async options(options) {
24143
- const workerConfig = _optionalChain([configService, 'access', _409 => _409.weappViteConfig, 'optionalAccess', _410 => _410.worker]);
24144
- const entries = Array.isArray(_optionalChain([workerConfig, 'optionalAccess', _411 => _411.entry])) ? workerConfig.entry : [_optionalChain([workerConfig, 'optionalAccess', _412 => _412.entry])];
24396
+ const workerConfig = _optionalChain([configService, 'access', _412 => _412.weappViteConfig, 'optionalAccess', _413 => _413.worker]);
24397
+ const entries = Array.isArray(_optionalChain([workerConfig, 'optionalAccess', _414 => _414.entry])) ? workerConfig.entry : [_optionalChain([workerConfig, 'optionalAccess', _415 => _415.entry])];
24145
24398
  const normalized = (await Promise.all(entries.filter(Boolean).map((entry) => resolveWorkerEntry(ctx, entry)))).filter((result) => Boolean(result.value)).reduce((acc, cur) => {
24146
24399
  acc[cur.key] = cur.value;
24147
24400
  return acc;
@@ -24258,7 +24511,7 @@ async function transformWxsFile(state, wxsPath) {
24258
24511
  const { result, importees } = transformWxsCode(rawCode, {
24259
24512
  filename: wxsPath
24260
24513
  });
24261
- if (typeof _optionalChain([result, 'optionalAccess', _413 => _413.code]) === "string") {
24514
+ if (typeof _optionalChain([result, 'optionalAccess', _416 => _416.code]) === "string") {
24262
24515
  code = result.code;
24263
24516
  }
24264
24517
  const dirname5 = _pathe2.default.dirname(wxsPath);
@@ -24291,13 +24544,13 @@ async function transformWxsFile(state, wxsPath) {
24291
24544
  var RUNTIME_PLUGINS_SYMBOL = Symbol.for("weapp-runtime:plugins");
24292
24545
  function attachRuntimePlugins(ctx, plugins) {
24293
24546
  const runtimePlugins = ctx[RUNTIME_PLUGINS_SYMBOL];
24294
- if (!_optionalChain([runtimePlugins, 'optionalAccess', _414 => _414.length])) {
24547
+ if (!_optionalChain([runtimePlugins, 'optionalAccess', _417 => _417.length])) {
24295
24548
  return plugins;
24296
24549
  }
24297
24550
  return [...runtimePlugins, ...plugins];
24298
24551
  }
24299
24552
  function applyInspect(ctx, plugins) {
24300
- const inspectOptions = _optionalChain([ctx, 'access', _415 => _415.configService, 'access', _416 => _416.weappViteConfig, 'optionalAccess', _417 => _417.debug, 'optionalAccess', _418 => _418.inspect]);
24553
+ const inspectOptions = _optionalChain([ctx, 'access', _418 => _418.configService, 'access', _419 => _419.weappViteConfig, 'optionalAccess', _420 => _420.debug, 'optionalAccess', _421 => _421.inspect]);
24301
24554
  if (!inspectOptions) {
24302
24555
  return plugins;
24303
24556
  }
@@ -24388,7 +24641,7 @@ function createMergeFactories(options) {
24388
24641
  const currentOptions = getOptions2();
24389
24642
  applyRuntimePlatform("miniprogram");
24390
24643
  const external = [];
24391
- if (_optionalChain([currentOptions, 'access', _419 => _419.packageJson, 'optionalAccess', _420 => _420.dependencies])) {
24644
+ if (_optionalChain([currentOptions, 'access', _422 => _422.packageJson, 'optionalAccess', _423 => _423.dependencies])) {
24392
24645
  external.push(
24393
24646
  ...Object.keys(currentOptions.packageJson.dependencies).map((pkg) => {
24394
24647
  return new RegExp(`^${pkg.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&")}(\\/|$)`);
@@ -24403,7 +24656,7 @@ function createMergeFactories(options) {
24403
24656
  const watchInclude = [
24404
24657
  _pathe2.default.join(currentOptions.cwd, currentOptions.srcRoot, "**")
24405
24658
  ];
24406
- const pluginRootConfig = _optionalChain([currentOptions, 'access', _421 => _421.config, 'access', _422 => _422.weapp, 'optionalAccess', _423 => _423.pluginRoot]);
24659
+ const pluginRootConfig = _optionalChain([currentOptions, 'access', _424 => _424.config, 'access', _425 => _425.weapp, 'optionalAccess', _426 => _426.pluginRoot]);
24407
24660
  if (pluginRootConfig) {
24408
24661
  const absolutePluginRoot = _pathe2.default.resolve(currentOptions.cwd, pluginRootConfig);
24409
24662
  const relativeToSrc = _pathe2.default.relative(
@@ -24463,7 +24716,7 @@ function createMergeFactories(options) {
24463
24716
  );
24464
24717
  inlineConfig.logLevel = "info";
24465
24718
  injectBuiltinAliases(inlineConfig);
24466
- const currentRoot = _optionalChain([subPackageMeta, 'optionalAccess', _424 => _424.subPackage, 'access', _425 => _425.root]);
24719
+ const currentRoot = _optionalChain([subPackageMeta, 'optionalAccess', _427 => _427.subPackage, 'access', _428 => _428.root]);
24467
24720
  setOptions({
24468
24721
  ...currentOptions,
24469
24722
  currentSubPackageRoot: currentRoot
@@ -24474,7 +24727,7 @@ function createMergeFactories(options) {
24474
24727
  ensureConfigService();
24475
24728
  const currentOptions = getOptions2();
24476
24729
  const web = currentOptions.weappWeb;
24477
- if (!_optionalChain([web, 'optionalAccess', _426 => _426.enabled])) {
24730
+ if (!_optionalChain([web, 'optionalAccess', _429 => _429.enabled])) {
24478
24731
  return void 0;
24479
24732
  }
24480
24733
  applyRuntimePlatform("web");
@@ -24565,7 +24818,7 @@ function createConfigService(ctx) {
24565
24818
  defineEnv[key] = value;
24566
24819
  }
24567
24820
  function getDefineImportMetaEnv() {
24568
- const mpPlatform = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _427 => _427.platform]), () => ( DEFAULT_MP_PLATFORM));
24821
+ const mpPlatform = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _430 => _430.platform]), () => ( DEFAULT_MP_PLATFORM));
24569
24822
  const resolvedPlatform = _nullishCoalesce(defineEnv.PLATFORM, () => ( mpPlatform));
24570
24823
  const env = {
24571
24824
  PLATFORM: resolvedPlatform,
@@ -24581,7 +24834,7 @@ function createConfigService(ctx) {
24581
24834
  }
24582
24835
  function applyRuntimePlatform(runtime) {
24583
24836
  const isWeb = runtime === "web";
24584
- const mpPlatform = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _428 => _428.platform]), () => ( DEFAULT_MP_PLATFORM));
24837
+ const mpPlatform = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _431 => _431.platform]), () => ( DEFAULT_MP_PLATFORM));
24585
24838
  const resolvedPlatform = isWeb ? "web" : mpPlatform;
24586
24839
  setDefineEnv("PLATFORM", resolvedPlatform);
24587
24840
  setDefineEnv("IS_WEB", isWeb);
@@ -24692,10 +24945,10 @@ function createConfigService(ctx) {
24692
24945
  return options.srcRoot;
24693
24946
  },
24694
24947
  get pluginRoot() {
24695
- return _optionalChain([options, 'access', _429 => _429.config, 'access', _430 => _430.weapp, 'optionalAccess', _431 => _431.pluginRoot]);
24948
+ return _optionalChain([options, 'access', _432 => _432.config, 'access', _433 => _433.weapp, 'optionalAccess', _434 => _434.pluginRoot]);
24696
24949
  },
24697
24950
  get absolutePluginRoot() {
24698
- if (_optionalChain([options, 'access', _432 => _432.config, 'access', _433 => _433.weapp, 'optionalAccess', _434 => _434.pluginRoot])) {
24951
+ if (_optionalChain([options, 'access', _435 => _435.config, 'access', _436 => _436.weapp, 'optionalAccess', _437 => _437.pluginRoot])) {
24699
24952
  return _pathe2.default.resolve(options.cwd, options.config.weapp.pluginRoot);
24700
24953
  }
24701
24954
  },
@@ -24725,7 +24978,7 @@ function createConfigService(ctx) {
24725
24978
  },
24726
24979
  relativeAbsoluteSrcRoot(p) {
24727
24980
  const absoluteSrcRoot = _pathe2.default.resolve(options.cwd, options.srcRoot);
24728
- const pluginRootConfig = _optionalChain([options, 'access', _435 => _435.config, 'access', _436 => _436.weapp, 'optionalAccess', _437 => _437.pluginRoot]);
24981
+ const pluginRootConfig = _optionalChain([options, 'access', _438 => _438.config, 'access', _439 => _439.weapp, 'optionalAccess', _440 => _440.pluginRoot]);
24729
24982
  if (pluginRootConfig) {
24730
24983
  const absolutePluginRoot = _pathe2.default.resolve(options.cwd, pluginRootConfig);
24731
24984
  const relativeToPlugin = _pathe2.default.relative(absolutePluginRoot, p);
@@ -24777,10 +25030,10 @@ function createJsonService(ctx) {
24777
25030
  }
24778
25031
  let resultJson;
24779
25032
  if (/app\.json(?:\.[jt]s)?$/.test(filepath)) {
24780
- await _optionalChain([ctx, 'access', _438 => _438.autoRoutesService, 'optionalAccess', _439 => _439.ensureFresh, 'call', _440 => _440()]);
25033
+ await _optionalChain([ctx, 'access', _441 => _441.autoRoutesService, 'optionalAccess', _442 => _442.ensureFresh, 'call', _443 => _443()]);
24781
25034
  }
24782
25035
  if (/\.json\.[jt]s$/.test(filepath)) {
24783
- const routesReference = _optionalChain([ctx, 'access', _441 => _441.autoRoutesService, 'optionalAccess', _442 => _442.getReference, 'call', _443 => _443()]);
25036
+ const routesReference = _optionalChain([ctx, 'access', _444 => _444.autoRoutesService, 'optionalAccess', _445 => _445.getReference, 'call', _446 => _446()]);
24784
25037
  const fallbackRoutes = _nullishCoalesce(routesReference, () => ( { pages: [], entries: [], subPackages: [] }));
24785
25038
  const routesModule = {
24786
25039
  routes: fallbackRoutes,
@@ -24829,7 +25082,7 @@ function createJsonService(ctx) {
24829
25082
  return resultJson;
24830
25083
  } catch (error) {
24831
25084
  logger_default.error(`\u6B8B\u7834\u7684JSON\u6587\u4EF6: ${filepath}`);
24832
- _optionalChain([debug, 'optionalCall', _444 => _444(error)]);
25085
+ _optionalChain([debug, 'optionalCall', _447 => _447(error)]);
24833
25086
  }
24834
25087
  }
24835
25088
  function resolve8(entry) {
@@ -24884,7 +25137,7 @@ function createNpmService(ctx) {
24884
25137
  if (!ctx.configService) {
24885
25138
  throw new Error("configService must be initialized before writing npm cache");
24886
25139
  }
24887
- if (_optionalChain([ctx, 'access', _445 => _445.configService, 'access', _446 => _446.weappViteConfig, 'optionalAccess', _447 => _447.npm, 'optionalAccess', _448 => _448.cache])) {
25140
+ if (_optionalChain([ctx, 'access', _448 => _448.configService, 'access', _449 => _449.weappViteConfig, 'optionalAccess', _450 => _450.npm, 'optionalAccess', _451 => _451.cache])) {
24888
25141
  await _fsextra2.default.outputJSON(getDependenciesCacheFilePath(root), {
24889
25142
  hash: dependenciesCacheHash()
24890
25143
  });
@@ -24897,7 +25150,7 @@ function createNpmService(ctx) {
24897
25150
  }
24898
25151
  }
24899
25152
  async function checkDependenciesCacheOutdate(root) {
24900
- if (_optionalChain([ctx, 'access', _449 => _449.configService, 'optionalAccess', _450 => _450.weappViteConfig, 'optionalAccess', _451 => _451.npm, 'optionalAccess', _452 => _452.cache])) {
25153
+ if (_optionalChain([ctx, 'access', _452 => _452.configService, 'optionalAccess', _453 => _453.weappViteConfig, 'optionalAccess', _454 => _454.npm, 'optionalAccess', _455 => _455.cache])) {
24901
25154
  const json = await readDependenciesCache(root);
24902
25155
  if (_shared.isObject.call(void 0, json)) {
24903
25156
  return dependenciesCacheHash() !== json.hash;
@@ -24930,7 +25183,7 @@ function createNpmService(ctx) {
24930
25183
  target: "es6",
24931
25184
  external: []
24932
25185
  });
24933
- const resolvedOptions = _optionalChain([ctx, 'access', _453 => _453.configService, 'optionalAccess', _454 => _454.weappViteConfig, 'optionalAccess', _455 => _455.npm, 'optionalAccess', _456 => _456.buildOptions, 'optionalCall', _457 => _457(
25186
+ const resolvedOptions = _optionalChain([ctx, 'access', _456 => _456.configService, 'optionalAccess', _457 => _457.weappViteConfig, 'optionalAccess', _458 => _458.npm, 'optionalAccess', _459 => _459.buildOptions, 'optionalCall', _460 => _460(
24934
25187
  mergedOptions,
24935
25188
  { name, entry }
24936
25189
  )]);
@@ -25030,7 +25283,7 @@ function createNpmService(ctx) {
25030
25283
  throw new Error("configService must be initialized before resolving npm relation list");
25031
25284
  }
25032
25285
  let packNpmRelationList = [];
25033
- if (_optionalChain([ctx, 'access', _458 => _458.configService, 'access', _459 => _459.projectConfig, 'access', _460 => _460.setting, 'optionalAccess', _461 => _461.packNpmManually]) && Array.isArray(ctx.configService.projectConfig.setting.packNpmRelationList)) {
25286
+ if (_optionalChain([ctx, 'access', _461 => _461.configService, 'access', _462 => _462.projectConfig, 'access', _463 => _463.setting, 'optionalAccess', _464 => _464.packNpmManually]) && Array.isArray(ctx.configService.projectConfig.setting.packNpmRelationList)) {
25034
25287
  packNpmRelationList = ctx.configService.projectConfig.setting.packNpmRelationList;
25035
25288
  } else {
25036
25289
  packNpmRelationList = [
@@ -25043,10 +25296,10 @@ function createNpmService(ctx) {
25043
25296
  return packNpmRelationList;
25044
25297
  }
25045
25298
  async function build3(options) {
25046
- if (!_optionalChain([ctx, 'access', _462 => _462.configService, 'optionalAccess', _463 => _463.weappViteConfig, 'optionalAccess', _464 => _464.npm, 'optionalAccess', _465 => _465.enable])) {
25299
+ if (!_optionalChain([ctx, 'access', _465 => _465.configService, 'optionalAccess', _466 => _466.weappViteConfig, 'optionalAccess', _467 => _467.npm, 'optionalAccess', _468 => _468.enable])) {
25047
25300
  return;
25048
25301
  }
25049
- _optionalChain([debug, 'optionalCall', _466 => _466("buildNpm start")]);
25302
+ _optionalChain([debug, 'optionalCall', _469 => _469("buildNpm start")]);
25050
25303
  const packNpmRelationList = getPackNpmRelationList();
25051
25304
  const [mainRelation, ...subRelations] = packNpmRelationList;
25052
25305
  const packageJsonPath = _pathe2.default.resolve(ctx.configService.cwd, mainRelation.packageJsonPath);
@@ -25121,7 +25374,7 @@ function createNpmService(ctx) {
25121
25374
  }
25122
25375
  }
25123
25376
  }
25124
- _optionalChain([debug, 'optionalCall', _467 => _467("buildNpm end")]);
25377
+ _optionalChain([debug, 'optionalCall', _470 => _470("buildNpm end")]);
25125
25378
  }
25126
25379
  return {
25127
25380
  getDependenciesCacheFilePath,
@@ -25165,7 +25418,7 @@ var TimeoutError = (_class16 = class _TimeoutError extends Error {
25165
25418
  __init36() {this.name = "TimeoutError"}
25166
25419
  constructor(message, options) {
25167
25420
  super(message, options);_class16.prototype.__init36.call(this);;
25168
- _optionalChain([Error, 'access', _468 => _468.captureStackTrace, 'optionalCall', _469 => _469(this, _TimeoutError)]);
25421
+ _optionalChain([Error, 'access', _471 => _471.captureStackTrace, 'optionalCall', _472 => _472(this, _TimeoutError)]);
25169
25422
  }
25170
25423
  }, _class16);
25171
25424
  var getAbortedReason = (signal) => _nullishCoalesce(signal.reason, () => ( new DOMException("This operation was aborted.", "AbortError")));
@@ -25183,7 +25436,7 @@ function pTimeout(promise, options) {
25183
25436
  if (typeof milliseconds !== "number" || Math.sign(milliseconds) !== 1) {
25184
25437
  throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${milliseconds}\``);
25185
25438
  }
25186
- if (_optionalChain([signal, 'optionalAccess', _470 => _470.aborted])) {
25439
+ if (_optionalChain([signal, 'optionalAccess', _473 => _473.aborted])) {
25187
25440
  reject(getAbortedReason(signal));
25188
25441
  return;
25189
25442
  }
@@ -25281,7 +25534,7 @@ var PriorityQueue = class {
25281
25534
  }
25282
25535
  dequeue() {
25283
25536
  const item = this.#queue.shift();
25284
- return _optionalChain([item, 'optionalAccess', _471 => _471.run]);
25537
+ return _optionalChain([item, 'optionalAccess', _474 => _474.run]);
25285
25538
  }
25286
25539
  filter(options) {
25287
25540
  return this.#queue.filter((element) => element.priority === options.priority).map((element) => element.run);
@@ -25342,10 +25595,10 @@ var PQueue = class extends import_index2.default {
25342
25595
  ...options
25343
25596
  };
25344
25597
  if (!(typeof options.intervalCap === "number" && options.intervalCap >= 1)) {
25345
- throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${_nullishCoalesce(_optionalChain([options, 'access', _472 => _472.intervalCap, 'optionalAccess', _473 => _473.toString, 'call', _474 => _474()]), () => ( ""))}\` (${typeof options.intervalCap})`);
25598
+ throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${_nullishCoalesce(_optionalChain([options, 'access', _475 => _475.intervalCap, 'optionalAccess', _476 => _476.toString, 'call', _477 => _477()]), () => ( ""))}\` (${typeof options.intervalCap})`);
25346
25599
  }
25347
25600
  if (options.interval === void 0 || !(Number.isFinite(options.interval) && options.interval >= 0)) {
25348
- throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${_nullishCoalesce(_optionalChain([options, 'access', _475 => _475.interval, 'optionalAccess', _476 => _476.toString, 'call', _477 => _477()]), () => ( ""))}\` (${typeof options.interval})`);
25601
+ throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${_nullishCoalesce(_optionalChain([options, 'access', _478 => _478.interval, 'optionalAccess', _479 => _479.toString, 'call', _480 => _480()]), () => ( ""))}\` (${typeof options.interval})`);
25349
25602
  }
25350
25603
  this.#carryoverIntervalCount = _nullishCoalesce(_nullishCoalesce(options.carryoverIntervalCount, () => ( options.carryoverConcurrencyCount)), () => ( false));
25351
25604
  this.#isIntervalIgnored = options.intervalCap === Number.POSITIVE_INFINITY || options.interval === 0;
@@ -25552,7 +25805,7 @@ var PQueue = class extends import_index2.default {
25552
25805
  });
25553
25806
  try {
25554
25807
  try {
25555
- _optionalChain([options, 'access', _478 => _478.signal, 'optionalAccess', _479 => _479.throwIfAborted, 'call', _480 => _480()]);
25808
+ _optionalChain([options, 'access', _481 => _481.signal, 'optionalAccess', _482 => _482.throwIfAborted, 'call', _483 => _483()]);
25556
25809
  } catch (error) {
25557
25810
  if (!this.#isIntervalIgnored) {
25558
25811
  this.#intervalCount--;
@@ -25925,7 +26178,7 @@ var FileCache = class {
25925
26178
  return true;
25926
26179
  }
25927
26180
  const cachedMtime = this.mtimeMap.get(id);
25928
- const nextSignature = _optionalChain([options, 'optionalAccess', _481 => _481.content]) !== void 0 ? createSignature(options.content) : void 0;
26181
+ const nextSignature = _optionalChain([options, 'optionalAccess', _484 => _484.content]) !== void 0 ? createSignature(options.content) : void 0;
25929
26182
  const updateSignature = () => {
25930
26183
  if (nextSignature !== void 0) {
25931
26184
  this.signatureMap.set(id, nextSignature);
@@ -26038,6 +26291,10 @@ function createRuntimeState() {
26038
26291
  json: {
26039
26292
  cache: new FileCache()
26040
26293
  },
26294
+ css: {
26295
+ importerToDependencies: /* @__PURE__ */ new Map(),
26296
+ dependencyToImporters: /* @__PURE__ */ new Map()
26297
+ },
26041
26298
  watcher: {
26042
26299
  rollupWatcherMap: /* @__PURE__ */ new Map(),
26043
26300
  sidecarWatcherMap: /* @__PURE__ */ new Map()
@@ -26156,7 +26413,7 @@ function coerceStyleConfig(entry) {
26156
26413
  if (!entry || typeof entry !== "object") {
26157
26414
  return void 0;
26158
26415
  }
26159
- const source = _optionalChain([entry, 'access', _482 => _482.source, 'optionalAccess', _483 => _483.toString, 'call', _484 => _484(), 'access', _485 => _485.trim, 'call', _486 => _486()]);
26416
+ const source = _optionalChain([entry, 'access', _485 => _485.source, 'optionalAccess', _486 => _486.toString, 'call', _487 => _487(), 'access', _488 => _488.trim, 'call', _489 => _489()]);
26160
26417
  if (!source) {
26161
26418
  return void 0;
26162
26419
  }
@@ -26332,7 +26589,7 @@ function normalizeSubPackageStyleEntries(styles, subPackage, configService) {
26332
26589
  if (!service) {
26333
26590
  return void 0;
26334
26591
  }
26335
- const root = _optionalChain([subPackage, 'access', _487 => _487.root, 'optionalAccess', _488 => _488.trim, 'call', _489 => _489()]);
26592
+ const root = _optionalChain([subPackage, 'access', _490 => _490.root, 'optionalAccess', _491 => _491.trim, 'call', _492 => _492()]);
26336
26593
  if (!root) {
26337
26594
  return void 0;
26338
26595
  }
@@ -26440,7 +26697,7 @@ function createScanService(ctx) {
26440
26697
  if (!ctx.configService) {
26441
26698
  throw new Error("configService must be initialized before scanning subpackages");
26442
26699
  }
26443
- const json = _optionalChain([scanState, 'access', _490 => _490.appEntry, 'optionalAccess', _491 => _491.json]);
26700
+ const json = _optionalChain([scanState, 'access', _493 => _493.appEntry, 'optionalAccess', _494 => _494.json]);
26444
26701
  if (scanState.isDirty || subPackageMap.size === 0) {
26445
26702
  subPackageMap.clear();
26446
26703
  independentSubPackageMap.clear();
@@ -26458,15 +26715,15 @@ function createScanService(ctx) {
26458
26715
  subPackage,
26459
26716
  entries: resolveSubPackageEntries(subPackage)
26460
26717
  };
26461
- const subPackageConfig = _optionalChain([ctx, 'access', _492 => _492.configService, 'access', _493 => _493.weappViteConfig, 'optionalAccess', _494 => _494.subPackages, 'optionalAccess', _495 => _495[subPackage.root]]);
26462
- meta.subPackage.dependencies = _optionalChain([subPackageConfig, 'optionalAccess', _496 => _496.dependencies]);
26463
- meta.subPackage.inlineConfig = _optionalChain([subPackageConfig, 'optionalAccess', _497 => _497.inlineConfig]);
26718
+ const subPackageConfig = _optionalChain([ctx, 'access', _495 => _495.configService, 'access', _496 => _496.weappViteConfig, 'optionalAccess', _497 => _497.subPackages, 'optionalAccess', _498 => _498[subPackage.root]]);
26719
+ meta.subPackage.dependencies = _optionalChain([subPackageConfig, 'optionalAccess', _499 => _499.dependencies]);
26720
+ meta.subPackage.inlineConfig = _optionalChain([subPackageConfig, 'optionalAccess', _500 => _500.inlineConfig]);
26464
26721
  meta.styleEntries = normalizeSubPackageStyleEntries(
26465
- _optionalChain([subPackageConfig, 'optionalAccess', _498 => _498.styles]),
26722
+ _optionalChain([subPackageConfig, 'optionalAccess', _501 => _501.styles]),
26466
26723
  subPackage,
26467
26724
  ctx.configService
26468
26725
  );
26469
- meta.watchSharedStyles = _nullishCoalesce(_optionalChain([subPackageConfig, 'optionalAccess', _499 => _499.watchSharedStyles]), () => ( true));
26726
+ meta.watchSharedStyles = _nullishCoalesce(_optionalChain([subPackageConfig, 'optionalAccess', _502 => _502.watchSharedStyles]), () => ( true));
26470
26727
  metas.push(meta);
26471
26728
  if (subPackage.root) {
26472
26729
  subPackageMap.set(subPackage.root, meta);
@@ -26522,11 +26779,11 @@ function createScanService(ctx) {
26522
26779
  loadSubPackages,
26523
26780
  isMainPackageFileName,
26524
26781
  get workersOptions() {
26525
- return _optionalChain([scanState, 'access', _500 => _500.appEntry, 'optionalAccess', _501 => _501.json, 'optionalAccess', _502 => _502.workers]);
26782
+ return _optionalChain([scanState, 'access', _503 => _503.appEntry, 'optionalAccess', _504 => _504.json, 'optionalAccess', _505 => _505.workers]);
26526
26783
  },
26527
26784
  get workersDir() {
26528
- const workersOptions = _optionalChain([scanState, 'access', _503 => _503.appEntry, 'optionalAccess', _504 => _504.json, 'optionalAccess', _505 => _505.workers]);
26529
- return typeof workersOptions === "object" ? _optionalChain([workersOptions, 'optionalAccess', _506 => _506.path]) : workersOptions;
26785
+ const workersOptions = _optionalChain([scanState, 'access', _506 => _506.appEntry, 'optionalAccess', _507 => _507.json, 'optionalAccess', _508 => _508.workers]);
26786
+ return typeof workersOptions === "object" ? _optionalChain([workersOptions, 'optionalAccess', _509 => _509.path]) : workersOptions;
26530
26787
  },
26531
26788
  markDirty() {
26532
26789
  scanState.isDirty = true;
@@ -26573,7 +26830,7 @@ function createWatcherService(ctx) {
26573
26830
  },
26574
26831
  setRollupWatcher(watcher, root = "/") {
26575
26832
  const oldWatcher = rollupWatcherMap.get(root);
26576
- _optionalChain([oldWatcher, 'optionalAccess', _507 => _507.close, 'call', _508 => _508()]);
26833
+ _optionalChain([oldWatcher, 'optionalAccess', _510 => _510.close, 'call', _511 => _511()]);
26577
26834
  rollupWatcherMap.set(root, watcher);
26578
26835
  },
26579
26836
  closeAll() {
@@ -26586,7 +26843,7 @@ function createWatcherService(ctx) {
26586
26843
  });
26587
26844
  });
26588
26845
  sidecarWatcherMap.clear();
26589
- void _optionalChain([ctx, 'access', _509 => _509.webService, 'optionalAccess', _510 => _510.close, 'call', _511 => _511(), 'access', _512 => _512.catch, 'call', _513 => _513(() => {
26846
+ void _optionalChain([ctx, 'access', _512 => _512.webService, 'optionalAccess', _513 => _513.close, 'call', _514 => _514(), 'access', _515 => _515.catch, 'call', _516 => _516(() => {
26590
26847
  })]);
26591
26848
  },
26592
26849
  close(root = "/") {
@@ -26602,7 +26859,7 @@ function createWatcherService(ctx) {
26602
26859
  sidecarWatcherMap.delete(root);
26603
26860
  }
26604
26861
  if (rollupWatcherMap.size === 0 && sidecarWatcherMap.size === 0) {
26605
- void _optionalChain([ctx, 'access', _514 => _514.webService, 'optionalAccess', _515 => _515.close, 'call', _516 => _516(), 'access', _517 => _517.catch, 'call', _518 => _518(() => {
26862
+ void _optionalChain([ctx, 'access', _517 => _517.webService, 'optionalAccess', _518 => _518.close, 'call', _519 => _519(), 'access', _520 => _520.catch, 'call', _521 => _521(() => {
26606
26863
  })]);
26607
26864
  }
26608
26865
  }
@@ -26615,7 +26872,7 @@ function createWatcherServicePlugin(ctx) {
26615
26872
  name: "weapp-runtime:watcher-service",
26616
26873
  closeBundle() {
26617
26874
  const configService = ctx.configService;
26618
- const isWatchMode = _optionalChain([configService, 'optionalAccess', _519 => _519.isDev]) || Boolean(_optionalChain([configService, 'optionalAccess', _520 => _520.inlineConfig, 'optionalAccess', _521 => _521.build, 'optionalAccess', _522 => _522.watch]));
26875
+ const isWatchMode = _optionalChain([configService, 'optionalAccess', _522 => _522.isDev]) || Boolean(_optionalChain([configService, 'optionalAccess', _523 => _523.inlineConfig, 'optionalAccess', _524 => _524.build, 'optionalAccess', _525 => _525.watch]));
26619
26876
  if (!isWatchMode) {
26620
26877
  service.closeAll();
26621
26878
  }
@@ -26632,10 +26889,10 @@ function createWebService(ctx) {
26632
26889
  }
26633
26890
  let devServer;
26634
26891
  function isEnabled() {
26635
- return Boolean(_optionalChain([ctx, 'access', _523 => _523.configService, 'optionalAccess', _524 => _524.weappWebConfig, 'optionalAccess', _525 => _525.enabled]));
26892
+ return Boolean(_optionalChain([ctx, 'access', _526 => _526.configService, 'optionalAccess', _527 => _527.weappWebConfig, 'optionalAccess', _528 => _528.enabled]));
26636
26893
  }
26637
26894
  async function startDevServer() {
26638
- if (!_optionalChain([ctx, 'access', _526 => _526.configService, 'optionalAccess', _527 => _527.isDev])) {
26895
+ if (!_optionalChain([ctx, 'access', _529 => _529.configService, 'optionalAccess', _530 => _530.isDev])) {
26639
26896
  return void 0;
26640
26897
  }
26641
26898
  if (!isEnabled()) {
@@ -26644,7 +26901,7 @@ function createWebService(ctx) {
26644
26901
  if (devServer) {
26645
26902
  return devServer;
26646
26903
  }
26647
- const inlineConfig = _optionalChain([ctx, 'access', _528 => _528.configService, 'optionalAccess', _529 => _529.mergeWeb, 'call', _530 => _530()]);
26904
+ const inlineConfig = _optionalChain([ctx, 'access', _531 => _531.configService, 'optionalAccess', _532 => _532.mergeWeb, 'call', _533 => _533()]);
26648
26905
  if (!inlineConfig) {
26649
26906
  return void 0;
26650
26907
  }
@@ -26657,7 +26914,7 @@ function createWebService(ctx) {
26657
26914
  if (!isEnabled()) {
26658
26915
  return void 0;
26659
26916
  }
26660
- const inlineConfig = _optionalChain([ctx, 'access', _531 => _531.configService, 'optionalAccess', _532 => _532.mergeWeb, 'call', _533 => _533()]);
26917
+ const inlineConfig = _optionalChain([ctx, 'access', _534 => _534.configService, 'optionalAccess', _535 => _535.mergeWeb, 'call', _536 => _536()]);
26661
26918
  if (!inlineConfig) {
26662
26919
  return void 0;
26663
26920
  }
@@ -26687,7 +26944,7 @@ function createWebServicePlugin(ctx) {
26687
26944
  return {
26688
26945
  name: "weapp-runtime:web-service",
26689
26946
  async closeBundle() {
26690
- if (!_optionalChain([ctx, 'access', _534 => _534.configService, 'optionalAccess', _535 => _535.isDev])) {
26947
+ if (!_optionalChain([ctx, 'access', _537 => _537.configService, 'optionalAccess', _538 => _538.isDev])) {
26691
26948
  await service.close();
26692
26949
  }
26693
26950
  }
@@ -29336,7 +29593,7 @@ function createWxmlService(ctx) {
29336
29593
  return set3;
29337
29594
  }
29338
29595
  function clearAll() {
29339
- const currentRoot = _optionalChain([ctx, 'access', _536 => _536.configService, 'optionalAccess', _537 => _537.currentSubPackageRoot]);
29596
+ const currentRoot = _optionalChain([ctx, 'access', _539 => _539.configService, 'optionalAccess', _540 => _540.currentSubPackageRoot]);
29340
29597
  if (!currentRoot) {
29341
29598
  depsMap.clear();
29342
29599
  tokenMap.clear();
@@ -29395,7 +29652,7 @@ function createWxmlService(ctx) {
29395
29652
  if (!ctx.configService) {
29396
29653
  throw new Error("configService must be initialized before scanning wxml");
29397
29654
  }
29398
- const wxmlConfig = _nullishCoalesce(_optionalChain([ctx, 'access', _538 => _538.configService, 'access', _539 => _539.weappViteConfig, 'optionalAccess', _540 => _540.wxml]), () => ( _optionalChain([ctx, 'access', _541 => _541.configService, 'access', _542 => _542.weappViteConfig, 'optionalAccess', _543 => _543.enhance, 'optionalAccess', _544 => _544.wxml])));
29655
+ const wxmlConfig = _nullishCoalesce(_optionalChain([ctx, 'access', _541 => _541.configService, 'access', _542 => _542.weappViteConfig, 'optionalAccess', _543 => _543.wxml]), () => ( _optionalChain([ctx, 'access', _544 => _544.configService, 'access', _545 => _545.weappViteConfig, 'optionalAccess', _546 => _546.enhance, 'optionalAccess', _547 => _547.wxml])));
29399
29656
  return scanWxml(wxml, {
29400
29657
  platform: ctx.configService.platform,
29401
29658
  ...wxmlConfig === true ? {} : wxmlConfig