weapp-vite 6.15.1 → 6.15.4
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/auto-routes.mjs +1 -1
- package/dist/cli.mjs +3 -3
- package/dist/{config-BykrQhv6.d.mts → config-B5YFoO3u.d.mts} +22 -8
- package/dist/config.d.mts +1 -1
- package/dist/{createContext-D6nJRaMk.mjs → createContext-BuwQryVc.mjs} +286 -60
- package/dist/file-BVlUDAip.mjs +2 -0
- package/dist/{file-DNhOO3wU.mjs → file-x_pM3sdN.mjs} +1 -1
- package/dist/getInstance-DPy6RmDl.mjs +2 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/json.d.mts +1 -1
- package/dist/mcp.d.mts +1 -1
- package/dist/types.d.mts +2 -2
- package/dist/web-apis.d.mts +3 -1
- package/dist/web-apis.mjs +2 -1
- package/package.json +10 -10
- package/dist/file-B9K91wb0.mjs +0 -2
- package/dist/getInstance-B1h6WfJF.mjs +0 -2
package/dist/auto-routes.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as getCompilerContext, u as getRouteRuntimeGlobalKeys } from "./createContext-
|
|
1
|
+
import { i as getCompilerContext, u as getRouteRuntimeGlobalKeys } from "./createContext-BuwQryVc.mjs";
|
|
2
2
|
//#region src/auto-routes.ts
|
|
3
3
|
const ROUTE_RUNTIME_OVERRIDE_KEY = Symbol.for("weapp-vite.route-runtime");
|
|
4
4
|
function createGetter(resolver) {
|
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as isPathInside, _ as DEFAULT_MP_PLATFORM, b as resolveMiniPlatform, c as createSharedBuildConfig, d as resolveWeappConfigFile, f as checkRuntime, g as createCjsConfigLoadError, h as parseCommentJson, l as SHARED_CHUNK_VIRTUAL_PREFIX, m as loadViteConfigFile, n as syncProjectSupportFiles, p as getProjectConfigFileName, r as syncManagedTsconfigBootstrapFiles, s as formatBytes, t as createCompilerContext, v as getDefaultIdeProjectRoot, x as shouldPassPlatformArgToIdeOpen, y as normalizeMiniPlatform } from "./createContext-
|
|
1
|
+
import { S as isPathInside, _ as DEFAULT_MP_PLATFORM, b as resolveMiniPlatform, c as createSharedBuildConfig, d as resolveWeappConfigFile, f as checkRuntime, g as createCjsConfigLoadError, h as parseCommentJson, l as SHARED_CHUNK_VIRTUAL_PREFIX, m as loadViteConfigFile, n as syncProjectSupportFiles, p as getProjectConfigFileName, r as syncManagedTsconfigBootstrapFiles, s as formatBytes, t as createCompilerContext, v as getDefaultIdeProjectRoot, x as shouldPassPlatformArgToIdeOpen, y as normalizeMiniPlatform } from "./createContext-BuwQryVc.mjs";
|
|
2
2
|
import { r as logger_default, t as colors } from "./logger-CgxdNjvb.mjs";
|
|
3
|
-
import { h as VERSION } from "./file-
|
|
3
|
+
import { h as VERSION } from "./file-x_pM3sdN.mjs";
|
|
4
4
|
import { a as resolveWeappMcpConfig, o as startWeappViteMcpServer } from "./mcp-DRlj32v4.mjs";
|
|
5
5
|
import { createRequire } from "node:module";
|
|
6
6
|
import path, { posix } from "pathe";
|
|
@@ -2077,7 +2077,7 @@ function registerPrepareCommand(cli) {
|
|
|
2077
2077
|
}
|
|
2078
2078
|
//#endregion
|
|
2079
2079
|
//#region package.json
|
|
2080
|
-
var version = "6.15.
|
|
2080
|
+
var version = "6.15.4";
|
|
2081
2081
|
//#endregion
|
|
2082
2082
|
//#region src/cli/devHotkeys/format.ts
|
|
2083
2083
|
const FULLWIDTH_ASCII_START = 65281;
|
|
@@ -416,20 +416,29 @@ interface WeappInjectWeapiConfig {
|
|
|
416
416
|
replaceWx?: boolean;
|
|
417
417
|
globalName?: string;
|
|
418
418
|
}
|
|
419
|
-
type
|
|
419
|
+
type WeappInjectWebRuntimeGlobalsTarget = 'fetch' | 'Headers' | 'Request' | 'Response' | 'TextEncoder' | 'TextDecoder' | 'AbortController' | 'AbortSignal' | 'XMLHttpRequest' | 'WebSocket' | 'atob' | 'btoa' | 'queueMicrotask' | 'performance' | 'crypto' | 'Event' | 'CustomEvent';
|
|
420
|
+
type WeappInjectRequestGlobalsTarget = WeappInjectWebRuntimeGlobalsTarget;
|
|
420
421
|
/**
|
|
421
|
-
* @description
|
|
422
|
+
* @description Web Runtime 全局对象注入配置
|
|
422
423
|
*/
|
|
423
|
-
interface
|
|
424
|
+
interface WeappInjectWebRuntimeGlobalsConfig {
|
|
424
425
|
enabled?: boolean;
|
|
425
|
-
targets?:
|
|
426
|
+
targets?: WeappInjectWebRuntimeGlobalsTarget[];
|
|
426
427
|
dependencies?: (string | RegExp)[];
|
|
427
428
|
prelude?: boolean;
|
|
428
429
|
}
|
|
429
430
|
/**
|
|
430
|
-
* @description `
|
|
431
|
+
* @description 已废弃,请迁移到 `WeappInjectWebRuntimeGlobalsConfig`
|
|
431
432
|
*/
|
|
432
|
-
interface
|
|
433
|
+
interface WeappInjectRequestGlobalsConfig extends WeappInjectWebRuntimeGlobalsConfig {}
|
|
434
|
+
/**
|
|
435
|
+
* @description `app.prelude` 中的 Web Runtime 安装配置
|
|
436
|
+
*/
|
|
437
|
+
interface WeappWebRuntimeConfig extends Omit<WeappInjectWebRuntimeGlobalsConfig, 'prelude'> {}
|
|
438
|
+
/**
|
|
439
|
+
* @description 已废弃,请迁移到 `WeappWebRuntimeConfig`
|
|
440
|
+
*/
|
|
441
|
+
interface WeappRequestRuntimeConfig extends WeappWebRuntimeConfig {}
|
|
433
442
|
type WeappAppPreludeMode = 'inline' | 'entry' | 'require';
|
|
434
443
|
/**
|
|
435
444
|
* @description `app.prelude` 前置注入配置
|
|
@@ -437,6 +446,10 @@ type WeappAppPreludeMode = 'inline' | 'entry' | 'require';
|
|
|
437
446
|
interface WeappAppPreludeConfig {
|
|
438
447
|
enabled?: boolean;
|
|
439
448
|
mode?: WeappAppPreludeMode;
|
|
449
|
+
webRuntime?: boolean | WeappWebRuntimeConfig;
|
|
450
|
+
/**
|
|
451
|
+
* @deprecated 已废弃,请迁移到 `weapp.appPrelude.webRuntime`。
|
|
452
|
+
*/
|
|
440
453
|
requestRuntime?: boolean | WeappRequestRuntimeConfig;
|
|
441
454
|
}
|
|
442
455
|
/**
|
|
@@ -626,8 +639,9 @@ interface WeappViteConfig {
|
|
|
626
639
|
routeRules?: WeappRouteRules;
|
|
627
640
|
appPrelude?: boolean | WeappAppPreludeConfig;
|
|
628
641
|
injectWeapi?: boolean | WeappInjectWeapiConfig;
|
|
642
|
+
injectWebRuntimeGlobals?: boolean | WeappInjectWebRuntimeGlobalsConfig;
|
|
629
643
|
/**
|
|
630
|
-
* @deprecated 已废弃,请迁移到 `weapp.appPrelude.
|
|
644
|
+
* @deprecated 已废弃,请迁移到 `weapp.appPrelude.webRuntime`。
|
|
631
645
|
*/
|
|
632
646
|
injectRequestGlobals?: boolean | WeappInjectRequestGlobalsConfig;
|
|
633
647
|
mcp?: boolean | WeappMcpConfig;
|
|
@@ -1551,4 +1565,4 @@ declare function defineConfig(config: UserConfigFnObjectPlain): UserConfigFnObje
|
|
|
1551
1565
|
declare function defineConfig(config: UserConfigFn): UserConfigFn;
|
|
1552
1566
|
declare function defineConfig(config: UserConfigFnPromise): UserConfigFnPromise;
|
|
1553
1567
|
//#endregion
|
|
1554
|
-
export { WeappDebugConfig as $,
|
|
1568
|
+
export { WeappDebugConfig as $, JsonConfig as $t, Ref as A, WeappManagedServerTsconfigConfig as An, WeappWevuConfig as At, BindingErrorLike as B, resolveWeappViteHostMeta as Bn, GenerateExtensionsOptions as Bt, LoadConfigOptions as C, WeappLibDtsOptions as Cn, WeappRequestRuntimeConfig as Ct, MethodDefinitions$1 as D, WeappLibVueTscOptions as Dn, WeappVueConfig as Dt, InlineConfig$1 as E, WeappLibInternalDtsOptions as En, WeappSubPackageConfig as Et, RolldownPlugin as F, WeappViteHostMeta as Fn, BuildNpmPackageMeta as Ft, EntryJsonFragment as G, GenerateTemplateContext as Gt, BaseEntry as H, GenerateFilenamesOptions as Ht, RolldownPluginOption as I, WeappViteRuntime as In, ChunksConfig as It, ScanComponentItem as J, GenerateTemplateFileSource as Jt, PageEntry as K, GenerateTemplateEntry as Kt, RolldownWatchOptions as L, applyWeappViteHostMeta as Ln, CopyGlobs as Lt, RolldownBuild as M, WeappManagedTypeScriptConfig as Mn, Alias as Mt, RolldownOptions as N, WeappWebConfig as Nn, AliasOptions as Nt, Plugin$1 as O, WeappManagedAppTsconfigConfig as On, WeappVueTemplateConfig as Ot, RolldownOutput$1 as P, WEAPP_VITE_HOST_NAME as Pn, AlipayNpmMode as Pt, UserConfig$2 as Q, JsFormat as Qt, RolldownWatcher$1 as R, createWeappViteHostMeta as Rn, CopyOptions as Rt, CompilerContext as S, WeappLibConfig as Sn, WeappNpmConfig as St, ConfigEnv$1 as T, WeappLibFileName as Tn, WeappRouteRules as Tt, ComponentEntry as U, GenerateOptions as Ut, AppEntry as V, GenerateFileType as Vt, Entry as W, GenerateTemplate as Wt, ProjectConfig as X, GenerateTemplateScope as Xt, WxmlDep as Y, GenerateTemplateInlineSource as Yt, SubPackageMetaValue as Z, GenerateTemplatesConfig as Zt, definePageJson as _, SubPackageStyleConfigEntry as _n, WeappInjectRequestGlobalsTarget as _t, UserConfigFnNoEnvPlain as a, NpmBuildOptions as an, EnhanceOptions as at, ChangeEvent as b, SubPackageStyleScope as bn, WeappInjectWebRuntimeGlobalsTarget as bt, UserConfigFnPromise as c, NpmPluginPackageConfig as cn, MultiPlatformConfig as ct, Component$1 as d, ResolvedAlias as dn, WeappAppPreludeMode as dt, JsonMergeContext as en, WeappForwardConsoleConfig as et, Page$1 as f, SharedChunkDynamicImports as fn, WeappAutoRoutesConfig as ft, defineComponentJson as g, SubPackage as gn, WeappInjectRequestGlobalsConfig as gt, defineAppJson as h, SharedChunkStrategy as hn, WeappHmrConfig as ht, UserConfigFnNoEnv as i, MpPlatform as in, AutoImportComponentsOption as it, ResolvedConfig as j, WeappManagedSharedTsconfigConfig as jn, WeappWorkerConfig as jt, PluginOption as k, WeappManagedNodeTsconfigConfig as kn, WeappWebRuntimeConfig as kt, defineConfig as l, NpmStrategy as ln, ScanWxmlOptions as lt, Theme$1 as m, SharedChunkOverride as mn, WeappAutoRoutesIncludePattern as mt, UserConfigExport as n, JsonMergeStage as nn, WeappViteConfig as nt, UserConfigFnObject as o, NpmDependencyPattern as on, EnhanceWxmlOptions as ot, Sitemap$1 as p, SharedChunkMode as pn, WeappAutoRoutesInclude as pt, ComponentsMap as q, GenerateTemplateFactory as qt, UserConfigFn as r, JsonMergeStrategy as rn, AutoImportComponents as rt, UserConfigFnObjectPlain as s, NpmMainPackageConfig as sn, HandleWxmlOptions as st, UserConfig$1 as t, JsonMergeFunction as tn, WeappForwardConsoleLogLevel as tt, App$1 as u, NpmSubPackageConfig as un, WeappAppPreludeConfig as ut, defineSitemapJson as v, SubPackageStyleConfigObject as vn, WeappInjectWeapiConfig as vt, ComputedDefinitions$1 as w, WeappLibEntryContext as wn, WeappRouteRule as wt, WeappVitePluginApi as x, WeappLibComponentJson as xn, WeappMcpConfig as xt, defineThemeJson as y, SubPackageStyleEntry as yn, WeappInjectWebRuntimeGlobalsConfig as yt, ViteDevServer$1 as z, isWeappViteHost as zn, GenerateDirsOptions as zt };
|
package/dist/config.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Bn as resolveWeappViteHostMeta, Fn as WeappViteHostMeta, In as WeappViteRuntime, Ln as applyWeappViteHostMeta, Pn as WEAPP_VITE_HOST_NAME, Rn as createWeappViteHostMeta, _ as definePageJson, a as UserConfigFnNoEnvPlain, c as UserConfigFnPromise, d as Component, f as Page, g as defineComponentJson, h as defineAppJson, i as UserConfigFnNoEnv, l as defineConfig, m as Theme, n as UserConfigExport, nt as WeappViteConfig, o as UserConfigFnObject, p as Sitemap, r as UserConfigFn, s as UserConfigFnObjectPlain, t as UserConfig, u as App, v as defineSitemapJson, y as defineThemeJson, zn as isWeappViteHost } from "./config-B5YFoO3u.mjs";
|
|
2
2
|
export { App, Component, Page, Sitemap, Theme, UserConfig, UserConfigExport, UserConfigFn, UserConfigFnNoEnv, UserConfigFnNoEnvPlain, UserConfigFnObject, UserConfigFnObjectPlain, UserConfigFnPromise, WEAPP_VITE_HOST_NAME, WeappViteConfig, WeappViteHostMeta, WeappViteRuntime, applyWeappViteHostMeta, createWeappViteHostMeta, defineAppJson, defineComponentJson, defineConfig, definePageJson, defineSitemapJson, defineThemeJson, isWeappViteHost, resolveWeappViteHostMeta };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as applyWeappViteHostMeta } from "./pluginHost-BzPJL4F-.mjs";
|
|
2
2
|
import { n as configureLogger, r as logger_default } from "./logger-CgxdNjvb.mjs";
|
|
3
|
-
import { _ as jsExtensions, a as findJsonEntry, b as vueExtensions, c as isJsOrTs, d as touch, g as configExtensions, i as findJsEntry, l as isTemplate, n as changeFileExtension, o as findTemplateEntry, p as inlineAutoRoutesImports, r as findCssEntry, s as findVueEntry, t as extractConfigFromVue, v as supportedCssLangs, y as templateExtensions } from "./file-
|
|
3
|
+
import { _ as jsExtensions, a as findJsonEntry, b as vueExtensions, c as isJsOrTs, d as touch, g as configExtensions, i as findJsEntry, l as isTemplate, n as changeFileExtension, o as findTemplateEntry, p as inlineAutoRoutesImports, r as findCssEntry, s as findVueEntry, t as extractConfigFromVue, v as supportedCssLangs, y as templateExtensions } from "./file-x_pM3sdN.mjs";
|
|
4
4
|
import { createRequire, isBuiltin } from "node:module";
|
|
5
5
|
import path, { posix } from "pathe";
|
|
6
6
|
import { normalize, relative, win32 } from "node:path";
|
|
@@ -30,7 +30,7 @@ import os from "node:os";
|
|
|
30
30
|
import { getPackageInfo, getPackageInfoSync, resolveModule } from "local-pkg";
|
|
31
31
|
import { spawn } from "node:child_process";
|
|
32
32
|
import * as t from "@weapp-vite/ast/babelTypes";
|
|
33
|
-
import { APP_PRELUDE_CHUNK_MARKER, APP_PRELUDE_GUARD_KEY, APP_PRELUDE_REQUIRE_MARKER, REQUEST_GLOBAL_ACTUALS_KEY, REQUEST_GLOBAL_BUNDLE_HOST_REF, REQUEST_GLOBAL_BUNDLE_MARKER, REQUEST_GLOBAL_CHUNK_HOST_REF, REQUEST_GLOBAL_CHUNK_MODULE_REF, REQUEST_GLOBAL_EXPOSE_HELPER, REQUEST_GLOBAL_INSTALLER_HOST_REF, REQUEST_GLOBAL_LAZY_CONSTRUCTOR_HELPER, REQUEST_GLOBAL_LAZY_FUNCTION_HELPER, REQUEST_GLOBAL_LOCAL_BINDINGS_MARKER, REQUEST_GLOBAL_MARK_PLACEHOLDER_HELPER, REQUEST_GLOBAL_PASSIVE_BINDINGS_MARKER, REQUEST_GLOBAL_PASSIVE_BINDINGS_MARKER as REQUEST_GLOBAL_PASSIVE_BINDINGS_MARKER$1, REQUEST_GLOBAL_PLACEHOLDER_KEY, REQUEST_GLOBAL_PRELUDE_GUARD_KEY, REQUEST_GLOBAL_PRELUDE_MARKER, REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER, WEAPP_VITE_INJECTED_API_IDENTIFIER, WEVU_EXPRESSION_ERROR_IDENTIFIER, WEVU_INTERNAL_KEY_IDENTIFIER, WEVU_LAYOUT_BIND_PREFIX, WEVU_PAGE_LAYOUT_CURRENT_NAME_IDENTIFIER, WEVU_PAGE_LAYOUT_CURRENT_PROPS_IDENTIFIER, WEVU_PAGE_LAYOUT_NAME_KEY, WEVU_PAGE_LAYOUT_NEXT_NAME_IDENTIFIER, WEVU_PAGE_LAYOUT_NEXT_PROPS_IDENTIFIER, WEVU_PAGE_LAYOUT_NONE, WEVU_PAGE_LAYOUT_PROPS_KEY, WEVU_PAGE_LAYOUT_SETTER_KEY, WEVU_SCOPED_SLOT_CREATOR_KEY } from "@weapp-core/constants";
|
|
33
|
+
import { APP_PRELUDE_CHUNK_MARKER, APP_PRELUDE_GUARD_KEY, APP_PRELUDE_REQUIRE_MARKER, REQUEST_GLOBAL_ACTUALS_KEY, REQUEST_GLOBAL_BUNDLE_HOST_REF, REQUEST_GLOBAL_BUNDLE_MARKER, REQUEST_GLOBAL_CHUNK_HOST_REF, REQUEST_GLOBAL_CHUNK_MODULE_REF, REQUEST_GLOBAL_EXPOSE_HELPER, REQUEST_GLOBAL_INSTALLER_HOST_REF, REQUEST_GLOBAL_LAZY_CONSTRUCTOR_HELPER, REQUEST_GLOBAL_LAZY_FUNCTION_HELPER, REQUEST_GLOBAL_LOCAL_BINDINGS_MARKER, REQUEST_GLOBAL_MARK_PLACEHOLDER_HELPER, REQUEST_GLOBAL_PASSIVE_BINDINGS_MARKER, REQUEST_GLOBAL_PASSIVE_BINDINGS_MARKER as REQUEST_GLOBAL_PASSIVE_BINDINGS_MARKER$1, REQUEST_GLOBAL_PLACEHOLDER_KEY, REQUEST_GLOBAL_PRELUDE_GUARD_KEY, REQUEST_GLOBAL_PRELUDE_MARKER, REQUEST_GLOBAL_SYNTHETIC_EXPORT_NAME, REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER, WEAPP_VITE_INJECTED_API_IDENTIFIER, WEVU_EXPRESSION_ERROR_IDENTIFIER, WEVU_INTERNAL_KEY_IDENTIFIER, WEVU_LAYOUT_BIND_PREFIX, WEVU_PAGE_LAYOUT_CURRENT_NAME_IDENTIFIER, WEVU_PAGE_LAYOUT_CURRENT_PROPS_IDENTIFIER, WEVU_PAGE_LAYOUT_NAME_KEY, WEVU_PAGE_LAYOUT_NEXT_NAME_IDENTIFIER, WEVU_PAGE_LAYOUT_NEXT_PROPS_IDENTIFIER, WEVU_PAGE_LAYOUT_NONE, WEVU_PAGE_LAYOUT_PROPS_KEY, WEVU_PAGE_LAYOUT_SETTER_KEY, WEVU_SCOPED_SLOT_CREATOR_KEY } from "@weapp-core/constants";
|
|
34
34
|
import { Buffer as Buffer$1 } from "node:buffer";
|
|
35
35
|
import fs$2, { existsSync } from "node:fs";
|
|
36
36
|
import chokidar from "chokidar";
|
|
@@ -14199,7 +14199,7 @@ function refreshModuleGraph(pluginCtx, state) {
|
|
|
14199
14199
|
if (importers.size) state.moduleImporters.set(normalizedId, importers);
|
|
14200
14200
|
}
|
|
14201
14201
|
}
|
|
14202
|
-
function appendSharedChunkImporters(bundle, state, onlyEntryIds) {
|
|
14202
|
+
function appendSharedChunkImporters(bundle, state, onlyEntryIds, previousImporters) {
|
|
14203
14203
|
const getTrackedImporterIds = (chunk) => {
|
|
14204
14204
|
const trackedImporterIds = /* @__PURE__ */ new Set();
|
|
14205
14205
|
if (chunk.facadeModuleId) {
|
|
@@ -14234,7 +14234,14 @@ function appendSharedChunkImporters(bundle, state, onlyEntryIds) {
|
|
|
14234
14234
|
if (!imports.size) continue;
|
|
14235
14235
|
for (const imported of imports) {
|
|
14236
14236
|
const target = bundle[imported];
|
|
14237
|
-
if (!target || target.type !== "chunk")
|
|
14237
|
+
if (!target || target.type !== "chunk") {
|
|
14238
|
+
if (previousImporters?.get(imported)?.has(entryId)) {
|
|
14239
|
+
const current = state.hmrSharedChunkImporters.get(imported);
|
|
14240
|
+
if (current) current.add(entryId);
|
|
14241
|
+
else state.hmrSharedChunkImporters.set(imported, new Set([entryId]));
|
|
14242
|
+
}
|
|
14243
|
+
continue;
|
|
14244
|
+
}
|
|
14238
14245
|
if (getTrackedImporterIds(target).size) continue;
|
|
14239
14246
|
const current = state.hmrSharedChunkImporters.get(imported);
|
|
14240
14247
|
if (current) current.add(entryId);
|
|
@@ -14248,11 +14255,13 @@ function refreshSharedChunkImporters(bundle, state) {
|
|
|
14248
14255
|
}
|
|
14249
14256
|
function refreshPartialSharedChunkImporters(bundle, state, entryIds) {
|
|
14250
14257
|
if (!entryIds.size) return;
|
|
14258
|
+
const previousImporters = /* @__PURE__ */ new Map();
|
|
14259
|
+
for (const [chunkId, importers] of state.hmrSharedChunkImporters) previousImporters.set(chunkId, new Set(importers));
|
|
14251
14260
|
for (const [chunkId, importers] of state.hmrSharedChunkImporters) {
|
|
14252
14261
|
for (const entryId of entryIds) importers.delete(entryId);
|
|
14253
14262
|
if (importers.size === 0) state.hmrSharedChunkImporters.delete(chunkId);
|
|
14254
14263
|
}
|
|
14255
|
-
appendSharedChunkImporters(bundle, state, entryIds);
|
|
14264
|
+
appendSharedChunkImporters(bundle, state, entryIds, previousImporters);
|
|
14256
14265
|
}
|
|
14257
14266
|
//#endregion
|
|
14258
14267
|
//#region src/plugins/core/helpers/independent.ts
|
|
@@ -14283,12 +14292,39 @@ const FULL_REQUEST_GLOBAL_TARGETS = [
|
|
|
14283
14292
|
"Headers",
|
|
14284
14293
|
"Request",
|
|
14285
14294
|
"Response",
|
|
14295
|
+
"TextEncoder",
|
|
14296
|
+
"TextDecoder",
|
|
14286
14297
|
"AbortController",
|
|
14287
14298
|
"AbortSignal",
|
|
14288
14299
|
"XMLHttpRequest",
|
|
14289
|
-
"WebSocket"
|
|
14300
|
+
"WebSocket",
|
|
14301
|
+
"atob",
|
|
14302
|
+
"btoa",
|
|
14303
|
+
"queueMicrotask",
|
|
14304
|
+
"performance",
|
|
14305
|
+
"crypto",
|
|
14306
|
+
"Event",
|
|
14307
|
+
"CustomEvent"
|
|
14290
14308
|
];
|
|
14291
14309
|
const ABORT_REQUEST_GLOBAL_TARGETS = ["AbortController", "AbortSignal"];
|
|
14310
|
+
const REQUEST_RUNTIME_REQUEST_TARGETS = [
|
|
14311
|
+
"fetch",
|
|
14312
|
+
"Headers",
|
|
14313
|
+
"Request",
|
|
14314
|
+
"Response",
|
|
14315
|
+
"TextEncoder",
|
|
14316
|
+
"TextDecoder",
|
|
14317
|
+
"AbortController",
|
|
14318
|
+
"AbortSignal",
|
|
14319
|
+
"XMLHttpRequest"
|
|
14320
|
+
];
|
|
14321
|
+
const REQUEST_RUNTIME_CORE_USAGE_TARGETS = new Set([
|
|
14322
|
+
"fetch",
|
|
14323
|
+
"Headers",
|
|
14324
|
+
"Request",
|
|
14325
|
+
"Response",
|
|
14326
|
+
"XMLHttpRequest"
|
|
14327
|
+
]);
|
|
14292
14328
|
const DEFAULT_REQUEST_GLOBAL_DEPENDENCIES = [
|
|
14293
14329
|
"axios",
|
|
14294
14330
|
"graphql-request",
|
|
@@ -14296,6 +14332,7 @@ const DEFAULT_REQUEST_GLOBAL_DEPENDENCIES = [
|
|
|
14296
14332
|
"engine.io-client"
|
|
14297
14333
|
];
|
|
14298
14334
|
const DEFAULT_ABORT_GLOBAL_DEPENDENCIES = ["@tanstack/query-core", "@tanstack/vue-query"];
|
|
14335
|
+
const WEBSOCKET_USAGE_HINT_RE = /\bwebsocket\b/iu;
|
|
14299
14336
|
const REQUEST_GLOBAL_FREE_BINDING_TARGETS = new Set([
|
|
14300
14337
|
...FULL_REQUEST_GLOBAL_TARGETS,
|
|
14301
14338
|
"URL",
|
|
@@ -14303,10 +14340,37 @@ const REQUEST_GLOBAL_FREE_BINDING_TARGETS = new Set([
|
|
|
14303
14340
|
"Blob",
|
|
14304
14341
|
"FormData"
|
|
14305
14342
|
]);
|
|
14306
|
-
|
|
14307
|
-
|
|
14343
|
+
const CODE_USAGE_AUTO_RULES = [
|
|
14344
|
+
{
|
|
14345
|
+
dependencyPatterns: ["axios", "graphql-request"],
|
|
14346
|
+
targets: [...REQUEST_RUNTIME_REQUEST_TARGETS]
|
|
14347
|
+
},
|
|
14348
|
+
{
|
|
14349
|
+
dependencyPatterns: ["socket.io-client", "engine.io-client"],
|
|
14350
|
+
targets: [...FULL_REQUEST_GLOBAL_TARGETS]
|
|
14351
|
+
},
|
|
14352
|
+
{
|
|
14353
|
+
dependencyPatterns: [...DEFAULT_ABORT_GLOBAL_DEPENDENCIES],
|
|
14354
|
+
targets: [...ABORT_REQUEST_GLOBAL_TARGETS]
|
|
14355
|
+
}
|
|
14356
|
+
];
|
|
14357
|
+
function resolveAppPreludeWebRuntimeConfig(appPrelude, warn) {
|
|
14358
|
+
if (!appPrelude || typeof appPrelude !== "object") return;
|
|
14359
|
+
const webRuntime = appPrelude.webRuntime;
|
|
14308
14360
|
const requestRuntime = appPrelude.requestRuntime;
|
|
14361
|
+
if (webRuntime !== void 0) {
|
|
14362
|
+
if (requestRuntime !== void 0) warn?.("`weapp.appPrelude.requestRuntime` 已废弃,且当前会被 `weapp.appPrelude.webRuntime` 覆盖。请迁移到 `weapp.appPrelude.webRuntime`。");
|
|
14363
|
+
if (typeof webRuntime === "boolean") return webRuntime ? {
|
|
14364
|
+
enabled: true,
|
|
14365
|
+
prelude: true
|
|
14366
|
+
} : false;
|
|
14367
|
+
return {
|
|
14368
|
+
...webRuntime,
|
|
14369
|
+
prelude: true
|
|
14370
|
+
};
|
|
14371
|
+
}
|
|
14309
14372
|
if (requestRuntime === void 0) return;
|
|
14373
|
+
warn?.("`weapp.appPrelude.requestRuntime` 已废弃,请迁移到 `weapp.appPrelude.webRuntime`。");
|
|
14310
14374
|
if (typeof requestRuntime === "boolean") return requestRuntime ? {
|
|
14311
14375
|
enabled: true,
|
|
14312
14376
|
prelude: true
|
|
@@ -14380,13 +14444,19 @@ function resolveInjectRequestGlobalsOptions(config, packageJson) {
|
|
|
14380
14444
|
};
|
|
14381
14445
|
}
|
|
14382
14446
|
function resolveRequestRuntimeOptions(input, packageJson, warn) {
|
|
14383
|
-
const nestedConfig =
|
|
14447
|
+
const nestedConfig = resolveAppPreludeWebRuntimeConfig(input.appPrelude, warn);
|
|
14448
|
+
const preferredTopLevelConfig = input.webRuntime;
|
|
14384
14449
|
const legacyConfig = input.injectRequestGlobals;
|
|
14385
14450
|
if (nestedConfig !== void 0) {
|
|
14386
|
-
if (
|
|
14451
|
+
if (preferredTopLevelConfig !== void 0) warn?.("`weapp.injectWebRuntimeGlobals` 当前会被 `weapp.appPrelude.webRuntime` 覆盖。请优先使用 `weapp.appPrelude.webRuntime`。");
|
|
14452
|
+
if (legacyConfig !== void 0) warn?.("`weapp.injectRequestGlobals` 已废弃,且当前会被 `weapp.appPrelude.webRuntime` 覆盖。请迁移到 `weapp.appPrelude.webRuntime`。");
|
|
14387
14453
|
return resolveInjectRequestGlobalsOptions(nestedConfig, packageJson);
|
|
14388
14454
|
}
|
|
14389
|
-
if (
|
|
14455
|
+
if (preferredTopLevelConfig !== void 0) {
|
|
14456
|
+
if (legacyConfig !== void 0) warn?.("`weapp.injectRequestGlobals` 已废弃,且当前会被 `weapp.injectWebRuntimeGlobals` 覆盖。请迁移到 `weapp.injectWebRuntimeGlobals`。");
|
|
14457
|
+
return resolveInjectRequestGlobalsOptions(preferredTopLevelConfig, packageJson);
|
|
14458
|
+
}
|
|
14459
|
+
if (legacyConfig !== void 0) warn?.("`weapp.injectRequestGlobals` 已废弃,请迁移到 `weapp.appPrelude.webRuntime`。");
|
|
14390
14460
|
return resolveInjectRequestGlobalsOptions(legacyConfig, packageJson);
|
|
14391
14461
|
}
|
|
14392
14462
|
function resolveRequestGlobalsRuntimeModuleId() {
|
|
@@ -14394,7 +14464,11 @@ function resolveRequestGlobalsRuntimeModuleId() {
|
|
|
14394
14464
|
}
|
|
14395
14465
|
function resolveRequestGlobalsBindingTargets(targets) {
|
|
14396
14466
|
const bindingTargets = [...targets];
|
|
14397
|
-
if (targets.some((target) => target === "fetch" || target === "Request" || target === "Response" || target === "XMLHttpRequest"
|
|
14467
|
+
if (targets.some((target) => target === "fetch" || target === "Request" || target === "Response" || target === "XMLHttpRequest" || target === "WebSocket")) {
|
|
14468
|
+
bindingTargets.push("TextEncoder", "TextDecoder");
|
|
14469
|
+
bindingTargets.push("URL", "URLSearchParams", "Blob", "FormData");
|
|
14470
|
+
}
|
|
14471
|
+
if (targets.includes("CustomEvent")) bindingTargets.push("Event");
|
|
14398
14472
|
return [...new Set(bindingTargets)].filter((target) => REQUEST_GLOBAL_FREE_BINDING_TARGETS.has(target));
|
|
14399
14473
|
}
|
|
14400
14474
|
/**
|
|
@@ -14414,12 +14488,18 @@ function createRequestGlobalsPassiveBindingsCode(targets) {
|
|
|
14414
14488
|
`function ${REQUEST_GLOBAL_MARK_PLACEHOLDER_HELPER}(value){try{Object.defineProperty(value,${JSON.stringify(REQUEST_GLOBAL_PLACEHOLDER_KEY)},{value:true,configurable:true})}catch{value[${JSON.stringify(REQUEST_GLOBAL_PLACEHOLDER_KEY)}]=true}return value}`,
|
|
14415
14489
|
`function ${REQUEST_GLOBAL_LAZY_FUNCTION_HELPER}(name){const placeholder=function(...args){const actual=${REQUEST_GLOBAL_ACTUALS_KEY}[name];if(typeof actual!=="function"){throw new Error(name+" is not initialized")}return actual.apply(this,args)};return ${REQUEST_GLOBAL_MARK_PLACEHOLDER_HELPER}(placeholder)}`,
|
|
14416
14490
|
`function ${REQUEST_GLOBAL_LAZY_CONSTRUCTOR_HELPER}(name){const placeholder=function(...args){const actual=${REQUEST_GLOBAL_ACTUALS_KEY}[name];if(typeof actual!=="function"){throw new Error(name+" is not initialized")}return Reflect.construct(actual,args)};return ${REQUEST_GLOBAL_MARK_PLACEHOLDER_HELPER}(placeholder)}`,
|
|
14491
|
+
`function __weappViteRequestGlobalsLazyObject(name,keys){const placeholder=Object.create(null);for(const key of keys){placeholder[key]=function(...args){const actual=${REQUEST_GLOBAL_ACTUALS_KEY}[name];const actualValue=actual?.[key];if(typeof actualValue!=="function"){throw new Error(name+"."+key+" is not initialized")}return actualValue.apply(actual,args)}}return ${REQUEST_GLOBAL_MARK_PLACEHOLDER_HELPER}(placeholder)}`,
|
|
14417
14492
|
`function ${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(value,args){if(typeof value!=="function"||value?.[${JSON.stringify(REQUEST_GLOBAL_PLACEHOLDER_KEY)}]===true){return false}try{return Reflect.construct(value,args),true}catch{return false}}`,
|
|
14418
|
-
`function ${REQUEST_GLOBAL_EXPOSE_HELPER}(name,value){if(value==null){return value}const current=globalThis[name];if(current===value){return value}if(typeof current!=="function"||current?.[${JSON.stringify(REQUEST_GLOBAL_PLACEHOLDER_KEY)}]===true){try{globalThis[name]=value}catch{}}return value}`
|
|
14493
|
+
`function ${REQUEST_GLOBAL_EXPOSE_HELPER}(name,value){if(value==null){return value}const current=globalThis[name];if(current===value){return value}if((typeof current!=="function"&&typeof current!=="object")||current?.[${JSON.stringify(REQUEST_GLOBAL_PLACEHOLDER_KEY)}]===true){try{globalThis[name]=value}catch{}}return value}`
|
|
14419
14494
|
].join(";")};${bindingTargets.map((target) => {
|
|
14420
14495
|
if (target === "fetch") return `var fetch = ${REQUEST_GLOBAL_EXPOSE_HELPER}("fetch",typeof ${REQUEST_GLOBAL_ACTUALS_KEY}["fetch"]==="function"&&${REQUEST_GLOBAL_ACTUALS_KEY}["fetch"]?.[${JSON.stringify(REQUEST_GLOBAL_PLACEHOLDER_KEY)}]!==true?${REQUEST_GLOBAL_ACTUALS_KEY}["fetch"]:typeof globalThis.fetch==="function"&&globalThis.fetch?.[${JSON.stringify(REQUEST_GLOBAL_PLACEHOLDER_KEY)}]!==true?globalThis.fetch:${REQUEST_GLOBAL_LAZY_FUNCTION_HELPER}("fetch"))`;
|
|
14496
|
+
if (target === "atob") return `var atob = ${REQUEST_GLOBAL_EXPOSE_HELPER}("atob",typeof ${REQUEST_GLOBAL_ACTUALS_KEY}["atob"]==="function"&&${REQUEST_GLOBAL_ACTUALS_KEY}["atob"]?.[${JSON.stringify(REQUEST_GLOBAL_PLACEHOLDER_KEY)}]!==true?${REQUEST_GLOBAL_ACTUALS_KEY}["atob"]:typeof globalThis.atob==="function"&&globalThis.atob?.[${JSON.stringify(REQUEST_GLOBAL_PLACEHOLDER_KEY)}]!==true?globalThis.atob:${REQUEST_GLOBAL_LAZY_FUNCTION_HELPER}("atob"))`;
|
|
14497
|
+
if (target === "btoa") return `var btoa = ${REQUEST_GLOBAL_EXPOSE_HELPER}("btoa",typeof ${REQUEST_GLOBAL_ACTUALS_KEY}["btoa"]==="function"&&${REQUEST_GLOBAL_ACTUALS_KEY}["btoa"]?.[${JSON.stringify(REQUEST_GLOBAL_PLACEHOLDER_KEY)}]!==true?${REQUEST_GLOBAL_ACTUALS_KEY}["btoa"]:typeof globalThis.btoa==="function"&&globalThis.btoa?.[${JSON.stringify(REQUEST_GLOBAL_PLACEHOLDER_KEY)}]!==true?globalThis.btoa:${REQUEST_GLOBAL_LAZY_FUNCTION_HELPER}("btoa"))`;
|
|
14498
|
+
if (target === "queueMicrotask") return `var queueMicrotask = ${REQUEST_GLOBAL_EXPOSE_HELPER}("queueMicrotask",typeof ${REQUEST_GLOBAL_ACTUALS_KEY}["queueMicrotask"]==="function"&&${REQUEST_GLOBAL_ACTUALS_KEY}["queueMicrotask"]?.[${JSON.stringify(REQUEST_GLOBAL_PLACEHOLDER_KEY)}]!==true?${REQUEST_GLOBAL_ACTUALS_KEY}["queueMicrotask"]:typeof globalThis.queueMicrotask==="function"&&globalThis.queueMicrotask?.[${JSON.stringify(REQUEST_GLOBAL_PLACEHOLDER_KEY)}]!==true?globalThis.queueMicrotask:${REQUEST_GLOBAL_LAZY_FUNCTION_HELPER}("queueMicrotask"))`;
|
|
14421
14499
|
const placeholderFactory = `${REQUEST_GLOBAL_LAZY_CONSTRUCTOR_HELPER}(${JSON.stringify(target)})`;
|
|
14422
14500
|
const actualRef = `${REQUEST_GLOBAL_ACTUALS_KEY}[${JSON.stringify(target)}]`;
|
|
14501
|
+
if (target === "performance") return `var performance = ${REQUEST_GLOBAL_EXPOSE_HELPER}("performance",${actualRef}&&typeof ${actualRef}.now==="function"&&${actualRef}?.[${JSON.stringify(REQUEST_GLOBAL_PLACEHOLDER_KEY)}]!==true?${actualRef}:globalThis.performance&&typeof globalThis.performance.now==="function"&&globalThis.performance?.[${JSON.stringify(REQUEST_GLOBAL_PLACEHOLDER_KEY)}]!==true?globalThis.performance:__weappViteRequestGlobalsLazyObject("performance",["now"]))`;
|
|
14502
|
+
if (target === "crypto") return `var crypto = ${REQUEST_GLOBAL_EXPOSE_HELPER}("crypto",${actualRef}&&typeof ${actualRef}.getRandomValues==="function"&&${actualRef}?.[${JSON.stringify(REQUEST_GLOBAL_PLACEHOLDER_KEY)}]!==true?${actualRef}:globalThis.crypto&&typeof globalThis.crypto.getRandomValues==="function"&&globalThis.crypto?.[${JSON.stringify(REQUEST_GLOBAL_PLACEHOLDER_KEY)}]!==true?globalThis.crypto:__weappViteRequestGlobalsLazyObject("crypto",["getRandomValues"]))`;
|
|
14423
14503
|
if (target === "URL") return `var URL = ${REQUEST_GLOBAL_EXPOSE_HELPER}("URL",${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(${actualRef},["https://request-globals.invalid"])?${actualRef}:${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(globalThis.URL,["https://request-globals.invalid"])?globalThis.URL:${placeholderFactory})`;
|
|
14424
14504
|
if (target === "URLSearchParams") return `var URLSearchParams = ${REQUEST_GLOBAL_EXPOSE_HELPER}("URLSearchParams",${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(${actualRef},["client=graphql-request"])?${actualRef}:${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(globalThis.URLSearchParams,["client=graphql-request"])?globalThis.URLSearchParams:${placeholderFactory})`;
|
|
14425
14505
|
if (target === "Blob") return `var Blob = ${REQUEST_GLOBAL_EXPOSE_HELPER}("Blob",${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(${actualRef},[])?${actualRef}:${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(globalThis.Blob,[])?globalThis.Blob:${placeholderFactory})`;
|
|
@@ -14427,6 +14507,8 @@ function createRequestGlobalsPassiveBindingsCode(targets) {
|
|
|
14427
14507
|
if (target === "Headers") return `var Headers = ${REQUEST_GLOBAL_EXPOSE_HELPER}("Headers",${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(${actualRef},[])?${actualRef}:${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(globalThis.Headers,[])?globalThis.Headers:${placeholderFactory})`;
|
|
14428
14508
|
if (target === "Request") return `var Request = ${REQUEST_GLOBAL_EXPOSE_HELPER}("Request",${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(${actualRef},["https://request-globals.invalid"])?${actualRef}:${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(globalThis.Request,["https://request-globals.invalid"])?globalThis.Request:${placeholderFactory})`;
|
|
14429
14509
|
if (target === "Response") return `var Response = ${REQUEST_GLOBAL_EXPOSE_HELPER}("Response",${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(${actualRef},[null])?${actualRef}:${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(globalThis.Response,[null])?globalThis.Response:${placeholderFactory})`;
|
|
14510
|
+
if (target === "TextEncoder") return `var TextEncoder = ${REQUEST_GLOBAL_EXPOSE_HELPER}("TextEncoder",${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(${actualRef},[])?${actualRef}:${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(globalThis.TextEncoder,[])?globalThis.TextEncoder:${placeholderFactory})`;
|
|
14511
|
+
if (target === "TextDecoder") return `var TextDecoder = ${REQUEST_GLOBAL_EXPOSE_HELPER}("TextDecoder",${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(${actualRef},[])?${actualRef}:${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(globalThis.TextDecoder,[])?globalThis.TextDecoder:${placeholderFactory})`;
|
|
14430
14512
|
if (target === "XMLHttpRequest") return `var XMLHttpRequest = ${REQUEST_GLOBAL_EXPOSE_HELPER}("XMLHttpRequest",${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(${actualRef},[])?${actualRef}:${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(globalThis.XMLHttpRequest,[])?globalThis.XMLHttpRequest:${placeholderFactory})`;
|
|
14431
14513
|
if (target === "WebSocket") return `var WebSocket = ${REQUEST_GLOBAL_EXPOSE_HELPER}("WebSocket",${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(${actualRef},["wss://request-globals.invalid"])?${actualRef}:${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(globalThis.WebSocket,["wss://request-globals.invalid"])?globalThis.WebSocket:${placeholderFactory})`;
|
|
14432
14514
|
if (target === "AbortController") return `var AbortController = ${REQUEST_GLOBAL_EXPOSE_HELPER}("AbortController",${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(${actualRef},[])?${actualRef}:${REQUEST_GLOBAL_USABLE_CONSTRUCTOR_HELPER}(globalThis.AbortController,[])?globalThis.AbortController:${placeholderFactory})`;
|
|
@@ -14436,6 +14518,90 @@ function createRequestGlobalsPassiveBindingsCode(targets) {
|
|
|
14436
14518
|
const MANUAL_REQUEST_GLOBALS_IMPORT_RE = /from\s*['"](?:@wevu\/web-apis|weapp-vite\/web-apis)['"]/;
|
|
14437
14519
|
const MANUAL_INSTALL_REQUEST_GLOBALS_CALL_RE = /\binstallRequestGlobals\s*\(/;
|
|
14438
14520
|
const MANUAL_INSTALL_ABORT_GLOBALS_CALL_RE = /\binstallAbortGlobals\s*\(/;
|
|
14521
|
+
function normalizeResolvedRequestGlobalTargets(targets, allowedTargets) {
|
|
14522
|
+
const resolvedSet = new Set(targets);
|
|
14523
|
+
return allowedTargets.filter((target) => resolvedSet.has(target));
|
|
14524
|
+
}
|
|
14525
|
+
function extractRequestGlobalsUsageSource(code) {
|
|
14526
|
+
if (!code.includes("<script")) return code;
|
|
14527
|
+
const { descriptor, errors } = parse(code, {
|
|
14528
|
+
filename: "request-globals-usage.vue",
|
|
14529
|
+
ignoreEmpty: false
|
|
14530
|
+
});
|
|
14531
|
+
if (errors.length > 0) return code;
|
|
14532
|
+
return [descriptor.script?.content, descriptor.scriptSetup?.content].filter((content) => typeof content === "string" && content.trim().length > 0).join("\n");
|
|
14533
|
+
}
|
|
14534
|
+
function resolveReferencedRequestGlobalsTargets(code, allowedTargets) {
|
|
14535
|
+
if (allowedTargets.length === 0) return [];
|
|
14536
|
+
const usageSource = extractRequestGlobalsUsageSource(code);
|
|
14537
|
+
if (!usageSource.trim()) return [];
|
|
14538
|
+
const allowedTargetSet = new Set(allowedTargets);
|
|
14539
|
+
if (!allowedTargets.some((target) => new RegExp(`\\b${target}\\b`, "u").test(usageSource))) return [];
|
|
14540
|
+
try {
|
|
14541
|
+
const ast = parseJsLike(usageSource);
|
|
14542
|
+
const resolvedTargets = /* @__PURE__ */ new Set();
|
|
14543
|
+
traverse(ast, { Identifier(path) {
|
|
14544
|
+
const identifierName = path.node?.name;
|
|
14545
|
+
if (!identifierName || !allowedTargetSet.has(identifierName)) return;
|
|
14546
|
+
if (typeof path.isReferencedIdentifier === "function" && !path.isReferencedIdentifier()) return;
|
|
14547
|
+
if (path.scope?.hasBinding?.(identifierName)) return;
|
|
14548
|
+
resolvedTargets.add(identifierName);
|
|
14549
|
+
} });
|
|
14550
|
+
return [...resolvedTargets];
|
|
14551
|
+
} catch {
|
|
14552
|
+
return allowedTargets.filter((target) => new RegExp(`\\b${target}\\b`, "u").test(usageSource));
|
|
14553
|
+
}
|
|
14554
|
+
}
|
|
14555
|
+
function matchesRequestGlobalDependencyPattern(specifier, pattern) {
|
|
14556
|
+
if (typeof pattern === "string") return specifier === pattern;
|
|
14557
|
+
pattern.lastIndex = 0;
|
|
14558
|
+
return pattern.test(specifier);
|
|
14559
|
+
}
|
|
14560
|
+
function resolveImportedRequestGlobalsTargets(code, allowedTargets) {
|
|
14561
|
+
if (allowedTargets.length === 0) return [];
|
|
14562
|
+
const matchedSpecifiers = /* @__PURE__ */ new Set();
|
|
14563
|
+
const knownDependencyLiterals = [
|
|
14564
|
+
"axios",
|
|
14565
|
+
"graphql-request",
|
|
14566
|
+
"socket.io-client",
|
|
14567
|
+
"engine.io-client",
|
|
14568
|
+
"@tanstack/query-core",
|
|
14569
|
+
"@tanstack/vue-query"
|
|
14570
|
+
];
|
|
14571
|
+
if (!knownDependencyLiterals.some((specifier) => code.includes(specifier))) return [];
|
|
14572
|
+
const addSpecifier = (specifier) => {
|
|
14573
|
+
if (typeof specifier === "string" && specifier.length > 0) matchedSpecifiers.add(specifier);
|
|
14574
|
+
};
|
|
14575
|
+
try {
|
|
14576
|
+
traverse(parseJsLike(extractRequestGlobalsUsageSource(code)), {
|
|
14577
|
+
ImportDeclaration(path) {
|
|
14578
|
+
addSpecifier(path.node?.source?.value);
|
|
14579
|
+
},
|
|
14580
|
+
ExportNamedDeclaration(path) {
|
|
14581
|
+
addSpecifier(path.node?.source?.value);
|
|
14582
|
+
},
|
|
14583
|
+
ExportAllDeclaration(path) {
|
|
14584
|
+
addSpecifier(path.node?.source?.value);
|
|
14585
|
+
},
|
|
14586
|
+
CallExpression(path) {
|
|
14587
|
+
if (path.node?.callee?.type === "Import") {
|
|
14588
|
+
addSpecifier(path.node.arguments?.[0]?.value);
|
|
14589
|
+
return;
|
|
14590
|
+
}
|
|
14591
|
+
if (path.node?.callee?.type === "Identifier" && path.node.callee.name === "require") addSpecifier(path.node.arguments?.[0]?.value);
|
|
14592
|
+
}
|
|
14593
|
+
});
|
|
14594
|
+
} catch {
|
|
14595
|
+
for (const specifier of knownDependencyLiterals) if (code.includes(specifier)) matchedSpecifiers.add(specifier);
|
|
14596
|
+
}
|
|
14597
|
+
if (matchedSpecifiers.size === 0) return [];
|
|
14598
|
+
const resolvedTargets = /* @__PURE__ */ new Set();
|
|
14599
|
+
for (const specifier of matchedSpecifiers) for (const rule of CODE_USAGE_AUTO_RULES) {
|
|
14600
|
+
if (!rule.dependencyPatterns.some((pattern) => matchesRequestGlobalDependencyPattern(specifier, pattern))) continue;
|
|
14601
|
+
for (const target of rule.targets) if (allowedTargets.includes(target)) resolvedTargets.add(target);
|
|
14602
|
+
}
|
|
14603
|
+
return normalizeResolvedRequestGlobalTargets(resolvedTargets, allowedTargets);
|
|
14604
|
+
}
|
|
14439
14605
|
function resolveManualRequestGlobalsTargets(code) {
|
|
14440
14606
|
if (!MANUAL_REQUEST_GLOBALS_IMPORT_RE.test(code)) return [];
|
|
14441
14607
|
const targets = /* @__PURE__ */ new Set();
|
|
@@ -14444,6 +14610,26 @@ function resolveManualRequestGlobalsTargets(code) {
|
|
|
14444
14610
|
return [...targets];
|
|
14445
14611
|
}
|
|
14446
14612
|
/**
|
|
14613
|
+
* @description 根据源码里的实际引用情况,推导 auto 模式需要安装的最小请求全局集合。
|
|
14614
|
+
*/
|
|
14615
|
+
function resolveAutoRequestGlobalsTargets(code, allowedTargets) {
|
|
14616
|
+
const importedTargets = resolveImportedRequestGlobalsTargets(code, allowedTargets);
|
|
14617
|
+
const referencedTargets = resolveReferencedRequestGlobalsTargets(code, allowedTargets);
|
|
14618
|
+
const hasWebSocketUsageHint = allowedTargets.includes("WebSocket") && WEBSOCKET_USAGE_HINT_RE.test(code);
|
|
14619
|
+
if (referencedTargets.length === 0 && importedTargets.length === 0 && !hasWebSocketUsageHint) return [];
|
|
14620
|
+
const resolvedTargets = /* @__PURE__ */ new Set();
|
|
14621
|
+
for (const target of importedTargets) resolvedTargets.add(target);
|
|
14622
|
+
const referencedTargetSet = new Set(referencedTargets);
|
|
14623
|
+
for (const target of referencedTargets) resolvedTargets.add(target);
|
|
14624
|
+
if (referencedTargets.some((target) => REQUEST_RUNTIME_CORE_USAGE_TARGETS.has(target))) {
|
|
14625
|
+
for (const target of REQUEST_RUNTIME_REQUEST_TARGETS) if (allowedTargets.includes(target)) resolvedTargets.add(target);
|
|
14626
|
+
} else if (referencedTargetSet.has("AbortController") || referencedTargetSet.has("AbortSignal")) {
|
|
14627
|
+
for (const target of ABORT_REQUEST_GLOBAL_TARGETS) if (allowedTargets.includes(target)) resolvedTargets.add(target);
|
|
14628
|
+
}
|
|
14629
|
+
if (allowedTargets.includes("WebSocket") && (referencedTargetSet.has("WebSocket") || importedTargets.includes("WebSocket") || hasWebSocketUsageHint)) resolvedTargets.add("WebSocket");
|
|
14630
|
+
return normalizeResolvedRequestGlobalTargets(resolvedTargets, allowedTargets);
|
|
14631
|
+
}
|
|
14632
|
+
/**
|
|
14447
14633
|
* @description 生成入口文件用的请求全局对象注入代码。
|
|
14448
14634
|
*/
|
|
14449
14635
|
function createInjectRequestGlobalsCode(targets, options) {
|
|
@@ -14452,7 +14638,7 @@ function createInjectRequestGlobalsCode(targets, options) {
|
|
|
14452
14638
|
return passiveBindingsCode ? `/* ${REQUEST_GLOBAL_PASSIVE_BINDINGS_MARKER} */ ${passiveBindingsCode}\n` : "";
|
|
14453
14639
|
}
|
|
14454
14640
|
const runtimeModuleId = resolveRequestGlobalsRuntimeModuleId();
|
|
14455
|
-
const lines = [`import {
|
|
14641
|
+
const lines = [`import { installWebRuntimeGlobals as __weappViteInstallRequestGlobals } from ${JSON.stringify(runtimeModuleId)}`];
|
|
14456
14642
|
if (options?.localBindings) {
|
|
14457
14643
|
const bindingTargets = resolveRequestGlobalsBindingTargets(targets);
|
|
14458
14644
|
lines.push(`const ${REQUEST_GLOBAL_INSTALLER_HOST_REF} = __weappViteInstallRequestGlobals({ targets: ${JSON.stringify(targets)} }) || globalThis`, ...bindingTargets.map((target) => `var ${target} = ${REQUEST_GLOBAL_INSTALLER_HOST_REF}.${target}`));
|
|
@@ -14482,8 +14668,7 @@ function injectRequestGlobalsIntoSfc(source, targets, options) {
|
|
|
14482
14668
|
if (errors.length > 0) return `${createInjectRequestGlobalsSfcCode(targets, options)}${source}`;
|
|
14483
14669
|
const inlineScript = descriptor.script && !descriptor.script.src ? descriptor.script : void 0;
|
|
14484
14670
|
if (inlineScript) return injectCodeIntoSfcBlock(source, inlineScript.loc.start.offset, injection);
|
|
14485
|
-
|
|
14486
|
-
if (inlineScriptSetup) return injectCodeIntoSfcBlock(source, inlineScriptSetup.loc.start.offset, injection);
|
|
14671
|
+
if (descriptor.scriptSetup && !descriptor.scriptSetup.src ? descriptor.scriptSetup : void 0) return `${createInjectRequestGlobalsSfcCode(targets, options)}${source}`;
|
|
14487
14672
|
if (!descriptor.script) return `${createInjectRequestGlobalsSfcCode(targets, options)}${source}`;
|
|
14488
14673
|
if (!descriptor.scriptSetup) return `${createInjectRequestGlobalsSfcCode(targets, {
|
|
14489
14674
|
...options,
|
|
@@ -28895,6 +29080,9 @@ function rewriteJsonNpmImportsToLocalRoot(bundle, root, dependencyPatterns, depe
|
|
|
28895
29080
|
}
|
|
28896
29081
|
//#endregion
|
|
28897
29082
|
//#region src/plugins/core/lifecycle/emit/requestGlobals.ts
|
|
29083
|
+
function resolveChunkRequestGlobalsTargets(code, targets, mode) {
|
|
29084
|
+
return mode === "auto" ? resolveAutoRequestGlobalsTargets(code, targets) : targets;
|
|
29085
|
+
}
|
|
28898
29086
|
function resolveRequestGlobalsInstallerName(code) {
|
|
28899
29087
|
const installerMatch = code.match(REQUEST_GLOBAL_INSTALLER_RE);
|
|
28900
29088
|
if (installerMatch?.[1]) return installerMatch[1];
|
|
@@ -28957,38 +29145,42 @@ function resolveRequestGlobalsExportName(code) {
|
|
|
28957
29145
|
return null;
|
|
28958
29146
|
}
|
|
28959
29147
|
}
|
|
28960
|
-
function injectRequestGlobalsBundleRuntime(bundle, targets) {
|
|
29148
|
+
function injectRequestGlobalsBundleRuntime(bundle, targets, mode) {
|
|
28961
29149
|
const installerChunks = /* @__PURE__ */ new Map();
|
|
28962
29150
|
if (targets.length === 0) return installerChunks;
|
|
28963
|
-
const bindingTargets = resolveRequestGlobalsBindingTargets(targets);
|
|
28964
29151
|
for (const output of Object.values(bundle)) {
|
|
28965
29152
|
if (output?.type !== "chunk") continue;
|
|
28966
29153
|
const chunk = output;
|
|
28967
29154
|
if (chunk.code.includes(REQUEST_GLOBAL_BUNDLE_MARKER)) continue;
|
|
28968
29155
|
const installerName = resolveRequestGlobalsInstallerName(chunk.code);
|
|
28969
29156
|
const exportName = resolveRequestGlobalsExportName(chunk.code);
|
|
28970
|
-
if (!installerName
|
|
28971
|
-
|
|
28972
|
-
|
|
29157
|
+
if (!installerName) continue;
|
|
29158
|
+
const resolvedExportName = exportName ?? REQUEST_GLOBAL_SYNTHETIC_EXPORT_NAME;
|
|
29159
|
+
installerChunks.set(toPosixPath(chunk.fileName), resolvedExportName);
|
|
29160
|
+
const chunkTargets = resolveChunkRequestGlobalsTargets(chunk.code, targets, mode);
|
|
29161
|
+
if (chunkTargets.length === 0) continue;
|
|
29162
|
+
const bindingTargets = resolveRequestGlobalsBindingTargets(chunkTargets);
|
|
29163
|
+
if (bindingTargets.length === 0) continue;
|
|
29164
|
+
const passiveBindingsCode = createRequestGlobalsPassiveBindingsCode(chunkTargets);
|
|
29165
|
+
const syntheticExportCode = exportName ? "" : `Object.defineProperty(exports,${JSON.stringify(REQUEST_GLOBAL_SYNTHETIC_EXPORT_NAME)},{enumerable:false,get:function(){return ${installerName}}});`;
|
|
28973
29166
|
const runtimeBindingCode = [
|
|
28974
|
-
`const ${REQUEST_GLOBAL_BUNDLE_HOST_REF} = ${installerName}({ targets: ${JSON.stringify(
|
|
29167
|
+
`const ${REQUEST_GLOBAL_BUNDLE_HOST_REF} = ${installerName}({ targets: ${JSON.stringify(chunkTargets)} }) || globalThis`,
|
|
28975
29168
|
...bindingTargets.map((target) => `${REQUEST_GLOBAL_ACTUALS_KEY}[${JSON.stringify(target)}] = ${REQUEST_GLOBAL_BUNDLE_HOST_REF}.${target}`),
|
|
29169
|
+
...bindingTargets.map((target) => `try{globalThis[${JSON.stringify(target)}]=${REQUEST_GLOBAL_BUNDLE_HOST_REF}.${target}}catch{}`),
|
|
28976
29170
|
...bindingTargets.map((target) => `${target} = ${REQUEST_GLOBAL_BUNDLE_HOST_REF}.${target}`)
|
|
28977
29171
|
].join(";");
|
|
28978
29172
|
const bundlePrelude = `/* ${REQUEST_GLOBAL_BUNDLE_MARKER} */ ${passiveBindingsCode}\n`;
|
|
28979
29173
|
const firstRequireMatch = chunk.code.match(REQUEST_GLOBAL_REQUIRE_DECLARATOR_RE);
|
|
28980
29174
|
if (firstRequireMatch?.[0]) {
|
|
28981
|
-
chunk.code = `${bundlePrelude}${chunk.code.replace(firstRequireMatch[0], (match) => `${match};${runtimeBindingCode}`)}\n`;
|
|
29175
|
+
chunk.code = `${bundlePrelude}${chunk.code.replace(firstRequireMatch[0], (match) => `${match};${syntheticExportCode}${runtimeBindingCode}`)}\n`;
|
|
28982
29176
|
continue;
|
|
28983
29177
|
}
|
|
28984
|
-
chunk.code = `${bundlePrelude}${chunk.code}\n;${runtimeBindingCode};\n`;
|
|
29178
|
+
chunk.code = `${bundlePrelude}${syntheticExportCode}${chunk.code}\n;${runtimeBindingCode};\n`;
|
|
28985
29179
|
}
|
|
28986
29180
|
return installerChunks;
|
|
28987
29181
|
}
|
|
28988
|
-
function injectRequestGlobalsPassiveBindings(bundle, installerChunks, targets, entriesMap) {
|
|
28989
|
-
if (
|
|
28990
|
-
if (resolveRequestGlobalsBindingTargets(targets).length === 0) return;
|
|
28991
|
-
const passiveBindingsCode = createRequestGlobalsPassiveBindingsCode(targets);
|
|
29182
|
+
function injectRequestGlobalsPassiveBindings(bundle, installerChunks, targets, mode, entriesMap) {
|
|
29183
|
+
if (targets.length === 0) return;
|
|
28992
29184
|
for (const output of Object.values(bundle)) {
|
|
28993
29185
|
if (output?.type !== "chunk") continue;
|
|
28994
29186
|
const chunk = output;
|
|
@@ -28997,13 +29189,15 @@ function injectRequestGlobalsPassiveBindings(bundle, installerChunks, targets, e
|
|
|
28997
29189
|
const entryName = chunk.fileName.replace(REQUEST_GLOBAL_ENTRY_NAME_RE, "");
|
|
28998
29190
|
const entryType = entriesMap?.get(entryName)?.type;
|
|
28999
29191
|
if (entryType === "page" || entryType === "component" || entryType === "app") continue;
|
|
29192
|
+
const chunkTargets = resolveChunkRequestGlobalsTargets(chunk.code, targets, mode);
|
|
29193
|
+
if (chunkTargets.length === 0) continue;
|
|
29194
|
+
const passiveBindingsCode = createRequestGlobalsPassiveBindingsCode(chunkTargets);
|
|
29195
|
+
if (!passiveBindingsCode) continue;
|
|
29000
29196
|
chunk.code = `/* ${REQUEST_GLOBAL_PASSIVE_BINDINGS_MARKER} */ ${passiveBindingsCode}\n${chunk.code}`;
|
|
29001
29197
|
}
|
|
29002
29198
|
}
|
|
29003
|
-
function injectRequestGlobalsLocalBindings(bundle, installerChunks, targets, entriesMap) {
|
|
29004
|
-
if (
|
|
29005
|
-
const bindingTargets = resolveRequestGlobalsBindingTargets(targets);
|
|
29006
|
-
if (bindingTargets.length === 0) return;
|
|
29199
|
+
function injectRequestGlobalsLocalBindings(bundle, installerChunks, targets, mode, entriesMap) {
|
|
29200
|
+
if (targets.length === 0) return;
|
|
29007
29201
|
for (const output of Object.values(bundle)) {
|
|
29008
29202
|
if (output?.type !== "chunk") continue;
|
|
29009
29203
|
const chunk = output;
|
|
@@ -29011,6 +29205,12 @@ function injectRequestGlobalsLocalBindings(bundle, installerChunks, targets, ent
|
|
|
29011
29205
|
const entryType = entriesMap?.get(entryName)?.type;
|
|
29012
29206
|
if (entryType !== "page" && entryType !== "component" && entryType !== "app") continue;
|
|
29013
29207
|
if (chunk.code.includes(REQUEST_GLOBAL_LOCAL_BINDINGS_MARKER)) continue;
|
|
29208
|
+
const chunkTargets = resolveChunkRequestGlobalsTargets(chunk.code, targets, mode);
|
|
29209
|
+
if (chunkTargets.length === 0) continue;
|
|
29210
|
+
const bindingTargets = resolveRequestGlobalsBindingTargets(chunkTargets);
|
|
29211
|
+
if (bindingTargets.length === 0) continue;
|
|
29212
|
+
const inlineInstallerName = resolveRequestGlobalsInstallerName(chunk.code);
|
|
29213
|
+
const firstRequireMatch = chunk.code.match(REQUEST_GLOBAL_REQUIRE_DECLARATOR_RE);
|
|
29014
29214
|
let requireImportLiteral = null;
|
|
29015
29215
|
let exportName;
|
|
29016
29216
|
for (const requireMatch of chunk.code.matchAll(REQUEST_GLOBAL_REQUIRE_DECLARATOR_RE)) {
|
|
@@ -29022,14 +29222,26 @@ function injectRequestGlobalsLocalBindings(bundle, installerChunks, targets, ent
|
|
|
29022
29222
|
requireImportLiteral = requireMatch[2] ?? null;
|
|
29023
29223
|
break;
|
|
29024
29224
|
}
|
|
29025
|
-
|
|
29026
|
-
|
|
29027
|
-
|
|
29028
|
-
|
|
29225
|
+
const installerHostExpression = inlineInstallerName ? `${inlineInstallerName}({ targets: ${JSON.stringify(chunkTargets)} }) || globalThis` : requireImportLiteral && exportName ? `${REQUEST_GLOBAL_CHUNK_MODULE_REF}[${JSON.stringify(exportName)}]({ targets: ${JSON.stringify(chunkTargets)} }) || globalThis` : null;
|
|
29226
|
+
if (!installerHostExpression) {
|
|
29227
|
+
const passiveBindingsCode = createRequestGlobalsPassiveBindingsCode(chunkTargets);
|
|
29228
|
+
if (!passiveBindingsCode) continue;
|
|
29229
|
+
chunk.code = `/* ${REQUEST_GLOBAL_LOCAL_BINDINGS_MARKER} */ ${passiveBindingsCode}\n${chunk.code}`;
|
|
29230
|
+
continue;
|
|
29231
|
+
}
|
|
29232
|
+
const injectionCode = [
|
|
29233
|
+
...!inlineInstallerName && requireImportLiteral ? [`const ${REQUEST_GLOBAL_CHUNK_MODULE_REF} = require(${requireImportLiteral})`] : [],
|
|
29234
|
+
`const ${REQUEST_GLOBAL_CHUNK_HOST_REF} = ${installerHostExpression}`,
|
|
29029
29235
|
`const ${REQUEST_GLOBAL_ACTUALS_KEY} = globalThis[${JSON.stringify(REQUEST_GLOBAL_ACTUALS_KEY)}] || (globalThis[${JSON.stringify(REQUEST_GLOBAL_ACTUALS_KEY)}] = Object.create(null))`,
|
|
29030
29236
|
...bindingTargets.map((target) => `${REQUEST_GLOBAL_ACTUALS_KEY}[${JSON.stringify(target)}] = ${REQUEST_GLOBAL_CHUNK_HOST_REF}.${target}`),
|
|
29237
|
+
...bindingTargets.map((target) => `try{globalThis[${JSON.stringify(target)}]=${REQUEST_GLOBAL_CHUNK_HOST_REF}.${target}}catch{}`),
|
|
29031
29238
|
...bindingTargets.map((target) => `var ${target} = ${REQUEST_GLOBAL_CHUNK_HOST_REF}.${target}`)
|
|
29032
|
-
].join(";")
|
|
29239
|
+
].join(";");
|
|
29240
|
+
if (inlineInstallerName && firstRequireMatch?.[0]) {
|
|
29241
|
+
chunk.code = `/* ${REQUEST_GLOBAL_LOCAL_BINDINGS_MARKER} */ ${chunk.code.replace(firstRequireMatch[0], (match) => `${match};${injectionCode}`)}\n`;
|
|
29242
|
+
continue;
|
|
29243
|
+
}
|
|
29244
|
+
chunk.code = `/* ${REQUEST_GLOBAL_LOCAL_BINDINGS_MARKER} */ ${injectionCode};\n${chunk.code}`;
|
|
29033
29245
|
}
|
|
29034
29246
|
}
|
|
29035
29247
|
function resolveRequestGlobalsInstallerImport(chunk, installerChunks) {
|
|
@@ -29051,18 +29263,19 @@ function toRequireRequestPath(fromFileName, toFileName) {
|
|
|
29051
29263
|
const relativePath = toPosixPath(path.relative(path.dirname(fromFileName), toFileName));
|
|
29052
29264
|
return relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
|
|
29053
29265
|
}
|
|
29054
|
-
function createRequestGlobalsPreludeCode(chunk, installerChunks, targets) {
|
|
29055
|
-
|
|
29056
|
-
|
|
29266
|
+
function createRequestGlobalsPreludeCode(chunk, installerChunks, targets, mode) {
|
|
29267
|
+
const chunkTargets = resolveChunkRequestGlobalsTargets(chunk.code, targets, mode);
|
|
29268
|
+
if (chunkTargets.length === 0 || chunk.code.includes(REQUEST_GLOBAL_PRELUDE_MARKER)) return;
|
|
29269
|
+
const bindingTargets = resolveRequestGlobalsBindingTargets(chunkTargets);
|
|
29057
29270
|
if (bindingTargets.length === 0) return;
|
|
29058
29271
|
const installerName = resolveRequestGlobalsInstallerName(chunk.code);
|
|
29059
29272
|
const exportName = resolveRequestGlobalsExportName(chunk.code);
|
|
29060
29273
|
let installerHostCode;
|
|
29061
|
-
if (installerName && exportName) installerHostCode = `${installerName}({ targets: ${JSON.stringify(
|
|
29274
|
+
if (installerName && exportName) installerHostCode = `${installerName}({ targets: ${JSON.stringify(chunkTargets)} }) || globalThis`;
|
|
29062
29275
|
else {
|
|
29063
29276
|
const installerImport = resolveRequestGlobalsInstallerImport(chunk, installerChunks);
|
|
29064
29277
|
if (!installerImport?.requireImportLiteral || !installerImport.exportName) return;
|
|
29065
|
-
installerHostCode = `require(${installerImport.requireImportLiteral})[${JSON.stringify(installerImport.exportName)}]({ targets: ${JSON.stringify(
|
|
29278
|
+
installerHostCode = `require(${installerImport.requireImportLiteral})[${JSON.stringify(installerImport.exportName)}]({ targets: ${JSON.stringify(chunkTargets)} }) || globalThis`;
|
|
29066
29279
|
}
|
|
29067
29280
|
return [
|
|
29068
29281
|
`/* ${REQUEST_GLOBAL_PRELUDE_MARKER} */`,
|
|
@@ -29074,16 +29287,18 @@ function createRequestGlobalsPreludeCode(chunk, installerChunks, targets) {
|
|
|
29074
29287
|
` const ${REQUEST_GLOBAL_INSTALLER_HOST_REF} = ${installerHostCode}`,
|
|
29075
29288
|
` const ${REQUEST_GLOBAL_ACTUALS_KEY} = globalThis[${JSON.stringify(REQUEST_GLOBAL_ACTUALS_KEY)}] || (globalThis[${JSON.stringify(REQUEST_GLOBAL_ACTUALS_KEY)}] = Object.create(null))`,
|
|
29076
29289
|
...bindingTargets.map((target) => ` ${REQUEST_GLOBAL_ACTUALS_KEY}[${JSON.stringify(target)}] = ${REQUEST_GLOBAL_INSTALLER_HOST_REF}.${target}`),
|
|
29290
|
+
...bindingTargets.map((target) => ` try { globalThis[${JSON.stringify(target)}] = ${REQUEST_GLOBAL_INSTALLER_HOST_REF}.${target} } catch {}`),
|
|
29077
29291
|
`})();`
|
|
29078
29292
|
].join("\n");
|
|
29079
29293
|
}
|
|
29080
|
-
function createRequestGlobalsPreludeAssetCode(preludeFileName, chunk, installerChunks, targets) {
|
|
29081
|
-
|
|
29082
|
-
|
|
29294
|
+
function createRequestGlobalsPreludeAssetCode(preludeFileName, chunk, installerChunks, targets, mode) {
|
|
29295
|
+
const chunkTargets = resolveChunkRequestGlobalsTargets(chunk.code, targets, mode);
|
|
29296
|
+
if (chunkTargets.length === 0) return;
|
|
29297
|
+
const bindingTargets = resolveRequestGlobalsBindingTargets(chunkTargets);
|
|
29083
29298
|
if (bindingTargets.length === 0) return;
|
|
29084
29299
|
const installerImport = resolveRequestGlobalsInstallerImport(chunk, installerChunks);
|
|
29085
29300
|
if (!installerImport?.installerChunkFileName || !installerImport.exportName) return;
|
|
29086
|
-
const installerHostCode = `require(${JSON.stringify(toRequireRequestPath(preludeFileName, installerImport.installerChunkFileName))})[${JSON.stringify(installerImport.exportName)}]({ targets: ${JSON.stringify(
|
|
29301
|
+
const installerHostCode = `require(${JSON.stringify(toRequireRequestPath(preludeFileName, installerImport.installerChunkFileName))})[${JSON.stringify(installerImport.exportName)}]({ targets: ${JSON.stringify(chunkTargets)} }) || globalThis`;
|
|
29087
29302
|
return [
|
|
29088
29303
|
`/* ${REQUEST_GLOBAL_PRELUDE_MARKER} */`,
|
|
29089
29304
|
`(() => {`,
|
|
@@ -29094,6 +29309,7 @@ function createRequestGlobalsPreludeAssetCode(preludeFileName, chunk, installerC
|
|
|
29094
29309
|
` const ${REQUEST_GLOBAL_INSTALLER_HOST_REF} = ${installerHostCode}`,
|
|
29095
29310
|
` const ${REQUEST_GLOBAL_ACTUALS_KEY} = globalThis[${JSON.stringify(REQUEST_GLOBAL_ACTUALS_KEY)}] || (globalThis[${JSON.stringify(REQUEST_GLOBAL_ACTUALS_KEY)}] = Object.create(null))`,
|
|
29096
29311
|
...bindingTargets.map((target) => ` ${REQUEST_GLOBAL_ACTUALS_KEY}[${JSON.stringify(target)}] = ${REQUEST_GLOBAL_INSTALLER_HOST_REF}.${target}`),
|
|
29312
|
+
...bindingTargets.map((target) => ` try { globalThis[${JSON.stringify(target)}] = ${REQUEST_GLOBAL_INSTALLER_HOST_REF}.${target} } catch {}`),
|
|
29097
29313
|
`})();`
|
|
29098
29314
|
].join("\n");
|
|
29099
29315
|
}
|
|
@@ -29218,7 +29434,7 @@ function emitAppPreludeRequireAssets(bundle, appPreludeCode, state, requestGloba
|
|
|
29218
29434
|
const scopeChunks = Object.values(bundle).filter((output) => {
|
|
29219
29435
|
return output?.type === "chunk" && resolveAppPreludeRequireFileName(output.fileName, state) === fileName;
|
|
29220
29436
|
});
|
|
29221
|
-
const source = [requestGlobalsPreludeOptions.enabled ? scopeChunks.map((chunk) => createRequestGlobalsPreludeAssetCode(fileName, chunk, requestGlobalsPreludeOptions.installerChunks, requestGlobalsPreludeOptions.targets)).find(Boolean) : void 0, appPreludeCode].filter(Boolean).join("\n");
|
|
29437
|
+
const source = [requestGlobalsPreludeOptions.enabled ? scopeChunks.map((chunk) => createRequestGlobalsPreludeAssetCode(fileName, chunk, requestGlobalsPreludeOptions.installerChunks, requestGlobalsPreludeOptions.targets, requestGlobalsPreludeOptions.mode)).find(Boolean) : void 0, appPreludeCode].filter(Boolean).join("\n");
|
|
29222
29438
|
emitFile?.({
|
|
29223
29439
|
type: "asset",
|
|
29224
29440
|
fileName,
|
|
@@ -29236,7 +29452,7 @@ function injectAppPreludeCode(bundle, appPreludeCode, options, state, requestGlo
|
|
|
29236
29452
|
if (chunk.code.includes(APP_PRELUDE_CHUNK_MARKER) || chunk.code.includes(APP_PRELUDE_REQUIRE_MARKER)) continue;
|
|
29237
29453
|
const isTargetEntryChunk = chunk.isEntry === true || entryChunkFileNames?.has(chunk.fileName) === true;
|
|
29238
29454
|
if (entryChunkFileNames && !isTargetEntryChunk) continue;
|
|
29239
|
-
const injectedCode = [requestGlobalsPreludeOptions.enabled && options.mode !== "require" ? createRequestGlobalsPreludeCode(chunk, requestGlobalsPreludeOptions.installerChunks, requestGlobalsPreludeOptions.targets) : void 0, options.mode === "require" ? appPreludeCode ? createAppPreludeRequireStatement(chunk.fileName, resolveAppPreludeRequireFileName(chunk.fileName, state)) : void 0 : appPreludeCode].filter(Boolean).join("\n");
|
|
29455
|
+
const injectedCode = [requestGlobalsPreludeOptions.enabled && options.mode !== "require" ? createRequestGlobalsPreludeCode(chunk, requestGlobalsPreludeOptions.installerChunks, requestGlobalsPreludeOptions.targets, requestGlobalsPreludeOptions.mode) : void 0, options.mode === "require" ? appPreludeCode ? createAppPreludeRequireStatement(chunk.fileName, resolveAppPreludeRequireFileName(chunk.fileName, state)) : void 0 : appPreludeCode].filter(Boolean).join("\n");
|
|
29240
29456
|
if (!injectedCode) continue;
|
|
29241
29457
|
chunk.code = prependChunkCodePreservingDirectives(chunk.code, injectedCode);
|
|
29242
29458
|
}
|
|
@@ -29255,6 +29471,7 @@ function createGenerateBundleHook(state, isPluginBuild) {
|
|
|
29255
29471
|
const astEngine = resolveAstEngine(configService.weappViteConfig);
|
|
29256
29472
|
const injectRequestGlobalsOptions = resolveRequestRuntimeOptions({
|
|
29257
29473
|
appPrelude: configService.weappViteConfig?.appPrelude,
|
|
29474
|
+
webRuntime: configService.weappViteConfig?.injectWebRuntimeGlobals,
|
|
29258
29475
|
injectRequestGlobals: configService.weappViteConfig?.injectRequestGlobals
|
|
29259
29476
|
}, configService.packageJson, (message) => logger_default.warn(message));
|
|
29260
29477
|
const npmBuildCandidateDependencies = resolveNpmBuildCandidateDependencyRecordSync(ctx, configService.packageJson);
|
|
@@ -29386,10 +29603,10 @@ function createGenerateBundleHook(state, isPluginBuild) {
|
|
|
29386
29603
|
const injectWeapiGlobalName = resolveInjectWeapiGlobalName(state);
|
|
29387
29604
|
if (injectWeapiGlobalName) rewriteBundlePlatformApi(rolldownBundle, injectWeapiGlobalName, { astEngine });
|
|
29388
29605
|
rewriteBundleDynamicGlobalResolution(rolldownBundle);
|
|
29389
|
-
const installerChunks = injectRequestGlobalsOptions?.targets?.length ? injectRequestGlobalsBundleRuntime(rolldownBundle, injectRequestGlobalsOptions.targets) : /* @__PURE__ */ new Map();
|
|
29606
|
+
const installerChunks = injectRequestGlobalsOptions?.targets?.length ? injectRequestGlobalsBundleRuntime(rolldownBundle, injectRequestGlobalsOptions.targets, injectRequestGlobalsOptions.mode) : /* @__PURE__ */ new Map();
|
|
29390
29607
|
if (injectRequestGlobalsOptions?.targets?.length) {
|
|
29391
|
-
injectRequestGlobalsPassiveBindings(rolldownBundle, installerChunks, injectRequestGlobalsOptions.targets, state.entriesMap);
|
|
29392
|
-
injectRequestGlobalsLocalBindings(rolldownBundle, installerChunks, injectRequestGlobalsOptions.targets, state.entriesMap);
|
|
29608
|
+
injectRequestGlobalsPassiveBindings(rolldownBundle, installerChunks, injectRequestGlobalsOptions.targets, injectRequestGlobalsOptions.mode, state.entriesMap);
|
|
29609
|
+
injectRequestGlobalsLocalBindings(rolldownBundle, installerChunks, injectRequestGlobalsOptions.targets, injectRequestGlobalsOptions.mode, state.entriesMap);
|
|
29393
29610
|
injectAxiosFetchAdapterEnv(rolldownBundle);
|
|
29394
29611
|
}
|
|
29395
29612
|
const appPreludeOptions = resolveAppPreludeOptions(state);
|
|
@@ -29402,6 +29619,7 @@ function createGenerateBundleHook(state, isPluginBuild) {
|
|
|
29402
29619
|
}, state, {
|
|
29403
29620
|
enabled: injectRequestGlobalsOptions?.prelude === true,
|
|
29404
29621
|
installerChunks,
|
|
29622
|
+
mode: injectRequestGlobalsOptions?.mode ?? "explicit",
|
|
29405
29623
|
targets: injectRequestGlobalsOptions?.targets ?? []
|
|
29406
29624
|
}, (asset) => this.emitFile(asset));
|
|
29407
29625
|
refreshModuleGraph(this, state);
|
|
@@ -29482,10 +29700,20 @@ function getCssRealPath(res) {
|
|
|
29482
29700
|
}
|
|
29483
29701
|
//#endregion
|
|
29484
29702
|
//#region src/plugins/core/lifecycle/load/requestGlobals.ts
|
|
29703
|
+
const NORMAL_SFC_SCRIPT_RE = /<script(?![^>]*setup)[^>]*>/u;
|
|
29485
29704
|
function resolvePassiveRequestGlobalsTargets(code, requestGlobalsTargets) {
|
|
29486
29705
|
if (requestGlobalsTargets.length > 0) return [];
|
|
29487
29706
|
return resolveManualRequestGlobalsTargets(code);
|
|
29488
29707
|
}
|
|
29708
|
+
function resolveRequestGlobalsTargetsForCode(code, sourceId, options) {
|
|
29709
|
+
const requestGlobalsTargets = options?.targets ?? [];
|
|
29710
|
+
if (requestGlobalsTargets.length === 0) return [];
|
|
29711
|
+
if (options?.mode === "auto") {
|
|
29712
|
+
if (sourceId.endsWith(".vue") && code.includes("<script setup") && !NORMAL_SFC_SCRIPT_RE.test(code)) return [];
|
|
29713
|
+
return resolveAutoRequestGlobalsTargets(code, requestGlobalsTargets);
|
|
29714
|
+
}
|
|
29715
|
+
return requestGlobalsTargets;
|
|
29716
|
+
}
|
|
29489
29717
|
function injectRequestGlobalsIntoLoadResult(result, sourceId, targets, options) {
|
|
29490
29718
|
if (!result || typeof result !== "object" || !("code" in result) || typeof result.code !== "string" || targets.length === 0) return result;
|
|
29491
29719
|
if (sourceId.endsWith(".vue")) return {
|
|
@@ -29682,12 +29910,9 @@ function createLoadHook(state) {
|
|
|
29682
29910
|
};
|
|
29683
29911
|
const injectRequestGlobalsOptions = resolveRequestRuntimeOptions({
|
|
29684
29912
|
appPrelude: configService.weappViteConfig?.appPrelude,
|
|
29913
|
+
webRuntime: configService.weappViteConfig?.injectWebRuntimeGlobals,
|
|
29685
29914
|
injectRequestGlobals: configService.weappViteConfig?.injectRequestGlobals
|
|
29686
29915
|
}, configService.packageJson, (message) => logger_default.warn(message));
|
|
29687
|
-
function resolveRequestGlobalsTargets() {
|
|
29688
|
-
if (!injectRequestGlobalsOptions) return [];
|
|
29689
|
-
return injectRequestGlobalsOptions.targets;
|
|
29690
|
-
}
|
|
29691
29916
|
async function ensureWeapiAvailable(pluginCtx, importer) {
|
|
29692
29917
|
if (weapiResolution.checked) return weapiResolution.available;
|
|
29693
29918
|
weapiResolution.checked = true;
|
|
@@ -29720,14 +29945,14 @@ function createLoadHook(state) {
|
|
|
29720
29945
|
const injectOptions = resolveInjectWeapiOptions$1(configService);
|
|
29721
29946
|
if (configService.weappLibConfig?.enabled ? ctx.runtimeState.lib.entries.get(sourceId) : void 0) {
|
|
29722
29947
|
const result = await loadEntry.call(this, sourceId, "component");
|
|
29723
|
-
const requestGlobalsTargets =
|
|
29948
|
+
const requestGlobalsTargets = result && typeof result === "object" && "code" in result ? resolveRequestGlobalsTargetsForCode(result.code, sourceId, injectRequestGlobalsOptions) : injectRequestGlobalsOptions?.targets ?? [];
|
|
29724
29949
|
if (requestGlobalsTargets.length === 0) return result;
|
|
29725
29950
|
return injectRequestGlobalsIntoLoadResult(result, sourceId, requestGlobalsTargets, { localBindings: true });
|
|
29726
29951
|
}
|
|
29727
29952
|
const relativeBasename = removeExtensionDeep(configService.relativeAbsoluteSrcRoot(sourceId));
|
|
29728
29953
|
if (relativeBasename === resolveRootEntryBasename(state)) {
|
|
29729
29954
|
const result = await loadEntry.call(this, sourceId, "app");
|
|
29730
|
-
const requestGlobalsTargets =
|
|
29955
|
+
const requestGlobalsTargets = result && typeof result === "object" && "code" in result ? resolveRequestGlobalsTargetsForCode(result.code, sourceId, injectRequestGlobalsOptions) : injectRequestGlobalsOptions?.targets ?? [];
|
|
29731
29956
|
const passiveRequestGlobalsTargets = result && typeof result === "object" && "code" in result ? resolvePassiveRequestGlobalsTargets(result.code, requestGlobalsTargets) : [];
|
|
29732
29957
|
if (requestGlobalsTargets.length === 0 && passiveRequestGlobalsTargets.length > 0) return injectRequestGlobalsIntoLoadResult(result, sourceId, passiveRequestGlobalsTargets, { passiveLocalBindings: true });
|
|
29733
29958
|
if (!injectOptions || configService.weappLibConfig?.enabled) return injectRequestGlobalsIntoLoadResult(result, sourceId, requestGlobalsTargets, { localBindings: true });
|
|
@@ -29752,7 +29977,7 @@ function createLoadHook(state) {
|
|
|
29752
29977
|
if (loadedEntrySet.has(sourceId) || isDeclaredEntry || subPackageMeta?.entries.includes(relativeBasename)) {
|
|
29753
29978
|
const loadType = declaredEntryType === "page" ? "page" : "component";
|
|
29754
29979
|
const result = await loadEntry.call(this, sourceId, loadType);
|
|
29755
|
-
const requestGlobalsTargets =
|
|
29980
|
+
const requestGlobalsTargets = result && typeof result === "object" && "code" in result ? resolveRequestGlobalsTargetsForCode(result.code, sourceId, injectRequestGlobalsOptions) : injectRequestGlobalsOptions?.targets ?? [];
|
|
29756
29981
|
const passiveRequestGlobalsTargets = result && typeof result === "object" && "code" in result ? resolvePassiveRequestGlobalsTargets(result.code, requestGlobalsTargets) : [];
|
|
29757
29982
|
if (requestGlobalsTargets.length === 0 && passiveRequestGlobalsTargets.length > 0) return injectRequestGlobalsIntoLoadResult(result, sourceId, passiveRequestGlobalsTargets, { passiveLocalBindings: true });
|
|
29758
29983
|
if (!injectOptions || !injectOptions.replaceWx || configService.weappLibConfig?.enabled) return injectRequestGlobalsIntoLoadResult(result, sourceId, requestGlobalsTargets, { localBindings: true });
|
|
@@ -29815,10 +30040,11 @@ function createTransformHook(state) {
|
|
|
29815
30040
|
const astEngine = resolveAstEngine(configService.weappViteConfig);
|
|
29816
30041
|
const injectRequestGlobalsOptions = resolveRequestRuntimeOptions({
|
|
29817
30042
|
appPrelude: configService.weappViteConfig?.appPrelude,
|
|
30043
|
+
webRuntime: configService.weappViteConfig?.injectWebRuntimeGlobals,
|
|
29818
30044
|
injectRequestGlobals: configService.weappViteConfig?.injectRequestGlobals
|
|
29819
30045
|
}, configService.packageJson, (message) => logger_default.warn(message));
|
|
29820
30046
|
function resolveRequestGlobalsTransformCode(id, code) {
|
|
29821
|
-
const requestGlobalsTargets = injectRequestGlobalsOptions?.targets?.length ? injectRequestGlobalsOptions.targets : resolveManualRequestGlobalsTargets(code);
|
|
30047
|
+
const requestGlobalsTargets = injectRequestGlobalsOptions?.targets?.length ? injectRequestGlobalsOptions.mode === "auto" ? resolveAutoRequestGlobalsTargets(code, injectRequestGlobalsOptions.targets) : injectRequestGlobalsOptions.targets : resolveManualRequestGlobalsTargets(code);
|
|
29822
30048
|
if (requestGlobalsTargets.length === 0) return null;
|
|
29823
30049
|
const passiveLocalBindings = !injectRequestGlobalsOptions?.targets?.length;
|
|
29824
30050
|
if (code.includes("__weappViteInstallRequestGlobals") || code.includes(REQUEST_GLOBAL_PASSIVE_BINDINGS_MARKER$1)) return null;
|
|
@@ -34770,7 +34996,7 @@ async function loadAppEntry(ctx, scanState) {
|
|
|
34770
34996
|
const vueAppPath = await findVueEntry(appBasename);
|
|
34771
34997
|
let configFromVue;
|
|
34772
34998
|
if (!appConfigFile && vueAppPath) {
|
|
34773
|
-
const { extractConfigFromVue } = await import("./file-
|
|
34999
|
+
const { extractConfigFromVue } = await import("./file-BVlUDAip.mjs");
|
|
34774
35000
|
configFromVue = await extractConfigFromVue(vueAppPath);
|
|
34775
35001
|
if (configFromVue) appConfigFile = vueAppPath;
|
|
34776
35002
|
}
|
|
@@ -84,7 +84,7 @@ function resolveAutoRoutesMacroImportPath() {
|
|
|
84
84
|
}
|
|
85
85
|
async function resolveAutoRoutesInlineSnapshot() {
|
|
86
86
|
try {
|
|
87
|
-
const { getCompilerContext } = await import("./getInstance-
|
|
87
|
+
const { getCompilerContext } = await import("./getInstance-DPy6RmDl.mjs");
|
|
88
88
|
const compilerContext = getCompilerContext();
|
|
89
89
|
const service = compilerContext.autoRoutesService;
|
|
90
90
|
const reference = service?.getReference?.();
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as Ref, C as LoadConfigOptions, D as MethodDefinitions, E as InlineConfig, F as RolldownPlugin, Fn as
|
|
1
|
+
import { A as Ref, Bn as resolveWeappViteHostMeta, C as LoadConfigOptions, D as MethodDefinitions, E as InlineConfig, F as RolldownPlugin, Fn as WeappViteHostMeta, I as RolldownPluginOption, In as WeappViteRuntime, L as RolldownWatchOptions, Ln as applyWeappViteHostMeta, M as RolldownBuild, N as RolldownOptions, O as Plugin, P as RolldownOutput, Pn as WEAPP_VITE_HOST_NAME, R as RolldownWatcher, Rn as createWeappViteHostMeta, S as CompilerContext, T as ConfigEnv, _ as definePageJson, a as UserConfigFnNoEnvPlain, c as UserConfigFnPromise, d as Component, f as Page, g as defineComponentJson, h as defineAppJson, i as UserConfigFnNoEnv, j as ResolvedConfig, k as PluginOption, l as defineConfig, m as Theme, n as UserConfigExport, nt as WeappViteConfig, o as UserConfigFnObject, p as Sitemap, r as UserConfigFn, s as UserConfigFnObjectPlain, t as UserConfig, u as App, v as defineSitemapJson, w as ComputedDefinitions, y as defineThemeJson, z as ViteDevServer, zn as isWeappViteHost } from "./config-B5YFoO3u.mjs";
|
|
2
2
|
import { a as createWevuComponent, i as WevuComponentOptions, n as defineProps, r as setPageLayout, t as defineEmits } from "./runtime-DSLk7kWi.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/createContext.d.ts
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as createCompilerContext } from "./createContext-
|
|
1
|
+
import { t as createCompilerContext } from "./createContext-BuwQryVc.mjs";
|
|
2
2
|
import { a as defineThemeJson, i as defineSitemapJson, n as defineComponentJson, r as definePageJson, t as defineAppJson } from "./json-wnfVS9jE.mjs";
|
|
3
3
|
import { a as resolveWeappViteHostMeta, i as isWeappViteHost, n as applyWeappViteHostMeta, r as createWeappViteHostMeta, t as WEAPP_VITE_HOST_NAME } from "./pluginHost-BzPJL4F-.mjs";
|
|
4
4
|
import { t as defineConfig } from "./config-B2xtjEug.mjs";
|
package/dist/json.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as definePageJson, d as Component, f as Page, g as defineComponentJson, h as defineAppJson, m as Theme, p as Sitemap, u as App, v as defineSitemapJson, y as defineThemeJson } from "./config-
|
|
1
|
+
import { _ as definePageJson, d as Component, f as Page, g as defineComponentJson, h as defineAppJson, m as Theme, p as Sitemap, u as App, v as defineSitemapJson, y as defineThemeJson } from "./config-B5YFoO3u.mjs";
|
|
2
2
|
export { App, Component, Page, Sitemap, Theme, defineAppJson, defineComponentJson, definePageJson, defineSitemapJson, defineThemeJson };
|
package/dist/mcp.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { xt as WeappMcpConfig } from "./config-B5YFoO3u.mjs";
|
|
2
2
|
import { CreateServerOptions, DEFAULT_MCP_ENDPOINT, DEFAULT_MCP_HOST, DEFAULT_MCP_PORT, McpServerHandle, StartMcpServerOptions, createWeappViteMcpServer } from "@weapp-vite/mcp";
|
|
3
3
|
|
|
4
4
|
//#region src/mcp.d.ts
|
package/dist/types.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { c as Resolver } from "./index-6QUk3Zbc.mjs";
|
|
2
2
|
import { n as AutoRoutesSubPackage, t as AutoRoutes } from "./routes-DiEBrMtj.mjs";
|
|
3
|
-
import { $ as WeappDebugConfig, $t as
|
|
4
|
-
export { Alias, AliasOptions, AlipayNpmMode, AppEntry, AutoImportComponents, AutoImportComponentsOption, AutoRoutes, AutoRoutesSubPackage, BaseEntry, BindingErrorLike, BuildNpmPackageMeta, ChangeEvent, ChunksConfig, ComponentEntry, ComponentsMap, ComputedDefinitions, ConfigEnv, CopyGlobs, CopyOptions, EnhanceOptions, EnhanceWxmlOptions, Entry, EntryJsonFragment, GenerateDirsOptions, GenerateExtensionsOptions, GenerateFileType, GenerateFilenamesOptions, GenerateOptions, GenerateTemplate, GenerateTemplateContext, GenerateTemplateEntry, GenerateTemplateFactory, GenerateTemplateFileSource, GenerateTemplateInlineSource, GenerateTemplateScope, GenerateTemplatesConfig, HandleWxmlOptions, InlineConfig, JsFormat, JsonConfig, JsonMergeContext, JsonMergeFunction, JsonMergeStage, JsonMergeStrategy, MethodDefinitions, MpPlatform, MultiPlatformConfig, NpmBuildOptions, NpmDependencyPattern, NpmMainPackageConfig, NpmPluginPackageConfig, NpmStrategy, NpmSubPackageConfig, PageEntry, Plugin, PluginOption, ProjectConfig, Ref, ResolvedAlias, ResolvedConfig, Resolver, RolldownBuild, RolldownOptions, RolldownOutput, RolldownPlugin, RolldownPluginOption, RolldownWatchOptions, RolldownWatcher, ScanComponentItem, ScanWxmlOptions, SharedChunkDynamicImports, SharedChunkMode, SharedChunkOverride, SharedChunkStrategy, SubPackage, SubPackageMetaValue, SubPackageStyleConfigEntry, SubPackageStyleConfigObject, SubPackageStyleEntry, SubPackageStyleScope, UserConfig, ViteDevServer, WeappAppPreludeConfig, WeappAppPreludeMode, WeappAutoRoutesConfig, WeappAutoRoutesInclude, WeappAutoRoutesIncludePattern, WeappDebugConfig, WeappForwardConsoleConfig, WeappForwardConsoleLogLevel, WeappHmrConfig, WeappInjectRequestGlobalsConfig, WeappInjectRequestGlobalsTarget, WeappInjectWeapiConfig, WeappLibComponentJson, WeappLibConfig, WeappLibDtsOptions, WeappLibEntryContext, WeappLibFileName, WeappLibInternalDtsOptions, WeappLibVueTscOptions, WeappManagedAppTsconfigConfig, WeappManagedNodeTsconfigConfig, WeappManagedServerTsconfigConfig, WeappManagedSharedTsconfigConfig, WeappManagedTypeScriptConfig, WeappMcpConfig, WeappNpmConfig, WeappRequestRuntimeConfig, WeappRouteRule, WeappRouteRules, WeappSubPackageConfig, WeappViteConfig, WeappViteHostMeta, WeappVitePluginApi, WeappViteRuntime, WeappVueConfig, WeappVueTemplateConfig, WeappWebConfig, WeappWevuConfig, WeappWorkerConfig, WxmlDep };
|
|
3
|
+
import { $ as WeappDebugConfig, $t as JsonConfig, A as Ref, An as WeappManagedServerTsconfigConfig, At as WeappWevuConfig, B as BindingErrorLike, Bt as GenerateExtensionsOptions, Cn as WeappLibDtsOptions, Ct as WeappRequestRuntimeConfig, D as MethodDefinitions, Dn as WeappLibVueTscOptions, Dt as WeappVueConfig, E as InlineConfig, En as WeappLibInternalDtsOptions, Et as WeappSubPackageConfig, F as RolldownPlugin, Fn as WeappViteHostMeta, Ft as BuildNpmPackageMeta, G as EntryJsonFragment, Gt as GenerateTemplateContext, H as BaseEntry, Ht as GenerateFilenamesOptions, I as RolldownPluginOption, In as WeappViteRuntime, It as ChunksConfig, J as ScanComponentItem, Jt as GenerateTemplateFileSource, K as PageEntry, Kt as GenerateTemplateEntry, L as RolldownWatchOptions, Lt as CopyGlobs, M as RolldownBuild, Mn as WeappManagedTypeScriptConfig, Mt as Alias, N as RolldownOptions, Nn as WeappWebConfig, Nt as AliasOptions, O as Plugin, On as WeappManagedAppTsconfigConfig, Ot as WeappVueTemplateConfig, P as RolldownOutput, Pt as AlipayNpmMode, Q as UserConfig, Qt as JsFormat, R as RolldownWatcher, Rt as CopyOptions, Sn as WeappLibConfig, St as WeappNpmConfig, T as ConfigEnv, Tn as WeappLibFileName, Tt as WeappRouteRules, U as ComponentEntry, Ut as GenerateOptions, V as AppEntry, Vt as GenerateFileType, W as Entry, Wt as GenerateTemplate, X as ProjectConfig, Xt as GenerateTemplateScope, Y as WxmlDep, Yt as GenerateTemplateInlineSource, Z as SubPackageMetaValue, Zt as GenerateTemplatesConfig, _n as SubPackageStyleConfigEntry, _t as WeappInjectRequestGlobalsTarget, an as NpmBuildOptions, at as EnhanceOptions, b as ChangeEvent, bn as SubPackageStyleScope, bt as WeappInjectWebRuntimeGlobalsTarget, cn as NpmPluginPackageConfig, ct as MultiPlatformConfig, dn as ResolvedAlias, dt as WeappAppPreludeMode, en as JsonMergeContext, et as WeappForwardConsoleConfig, fn as SharedChunkDynamicImports, ft as WeappAutoRoutesConfig, gn as SubPackage, gt as WeappInjectRequestGlobalsConfig, hn as SharedChunkStrategy, ht as WeappHmrConfig, in as MpPlatform, it as AutoImportComponentsOption, j as ResolvedConfig, jn as WeappManagedSharedTsconfigConfig, jt as WeappWorkerConfig, k as PluginOption, kn as WeappManagedNodeTsconfigConfig, kt as WeappWebRuntimeConfig, ln as NpmStrategy, lt as ScanWxmlOptions, mn as SharedChunkOverride, mt as WeappAutoRoutesIncludePattern, nn as JsonMergeStage, nt as WeappViteConfig, on as NpmDependencyPattern, ot as EnhanceWxmlOptions, pn as SharedChunkMode, pt as WeappAutoRoutesInclude, q as ComponentsMap, qt as GenerateTemplateFactory, rn as JsonMergeStrategy, rt as AutoImportComponents, sn as NpmMainPackageConfig, st as HandleWxmlOptions, tn as JsonMergeFunction, tt as WeappForwardConsoleLogLevel, un as NpmSubPackageConfig, ut as WeappAppPreludeConfig, vn as SubPackageStyleConfigObject, vt as WeappInjectWeapiConfig, w as ComputedDefinitions, wn as WeappLibEntryContext, wt as WeappRouteRule, x as WeappVitePluginApi, xn as WeappLibComponentJson, xt as WeappMcpConfig, yn as SubPackageStyleEntry, yt as WeappInjectWebRuntimeGlobalsConfig, z as ViteDevServer, zt as GenerateDirsOptions } from "./config-B5YFoO3u.mjs";
|
|
4
|
+
export { Alias, AliasOptions, AlipayNpmMode, AppEntry, AutoImportComponents, AutoImportComponentsOption, AutoRoutes, AutoRoutesSubPackage, BaseEntry, BindingErrorLike, BuildNpmPackageMeta, ChangeEvent, ChunksConfig, ComponentEntry, ComponentsMap, ComputedDefinitions, ConfigEnv, CopyGlobs, CopyOptions, EnhanceOptions, EnhanceWxmlOptions, Entry, EntryJsonFragment, GenerateDirsOptions, GenerateExtensionsOptions, GenerateFileType, GenerateFilenamesOptions, GenerateOptions, GenerateTemplate, GenerateTemplateContext, GenerateTemplateEntry, GenerateTemplateFactory, GenerateTemplateFileSource, GenerateTemplateInlineSource, GenerateTemplateScope, GenerateTemplatesConfig, HandleWxmlOptions, InlineConfig, JsFormat, JsonConfig, JsonMergeContext, JsonMergeFunction, JsonMergeStage, JsonMergeStrategy, MethodDefinitions, MpPlatform, MultiPlatformConfig, NpmBuildOptions, NpmDependencyPattern, NpmMainPackageConfig, NpmPluginPackageConfig, NpmStrategy, NpmSubPackageConfig, PageEntry, Plugin, PluginOption, ProjectConfig, Ref, ResolvedAlias, ResolvedConfig, Resolver, RolldownBuild, RolldownOptions, RolldownOutput, RolldownPlugin, RolldownPluginOption, RolldownWatchOptions, RolldownWatcher, ScanComponentItem, ScanWxmlOptions, SharedChunkDynamicImports, SharedChunkMode, SharedChunkOverride, SharedChunkStrategy, SubPackage, SubPackageMetaValue, SubPackageStyleConfigEntry, SubPackageStyleConfigObject, SubPackageStyleEntry, SubPackageStyleScope, UserConfig, ViteDevServer, WeappAppPreludeConfig, WeappAppPreludeMode, WeappAutoRoutesConfig, WeappAutoRoutesInclude, WeappAutoRoutesIncludePattern, WeappDebugConfig, WeappForwardConsoleConfig, WeappForwardConsoleLogLevel, WeappHmrConfig, WeappInjectRequestGlobalsConfig, WeappInjectRequestGlobalsTarget, WeappInjectWeapiConfig, WeappInjectWebRuntimeGlobalsConfig, WeappInjectWebRuntimeGlobalsTarget, WeappLibComponentJson, WeappLibConfig, WeappLibDtsOptions, WeappLibEntryContext, WeappLibFileName, WeappLibInternalDtsOptions, WeappLibVueTscOptions, WeappManagedAppTsconfigConfig, WeappManagedNodeTsconfigConfig, WeappManagedServerTsconfigConfig, WeappManagedSharedTsconfigConfig, WeappManagedTypeScriptConfig, WeappMcpConfig, WeappNpmConfig, WeappRequestRuntimeConfig, WeappRouteRule, WeappRouteRules, WeappSubPackageConfig, WeappViteConfig, WeappViteHostMeta, WeappVitePluginApi, WeappViteRuntime, WeappVueConfig, WeappVueTemplateConfig, WeappWebConfig, WeappWebRuntimeConfig, WeappWevuConfig, WeappWorkerConfig, WxmlDep };
|
package/dist/web-apis.d.mts
CHANGED
package/dist/web-apis.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weapp-vite",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "6.15.
|
|
4
|
+
"version": "6.15.4",
|
|
5
5
|
"description": "weapp-vite 一个现代化的小程序打包工具",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -95,12 +95,12 @@
|
|
|
95
95
|
"@vue/language-core": "^3.2.6",
|
|
96
96
|
"cac": "^7.0.0",
|
|
97
97
|
"chokidar": "^5.0.0",
|
|
98
|
-
"comment-json": "^
|
|
98
|
+
"comment-json": "^5.0.0",
|
|
99
99
|
"debug": "^4.4.3",
|
|
100
100
|
"fdir": "^6.5.0",
|
|
101
101
|
"htmlparser2": "^12.0.0",
|
|
102
102
|
"local-pkg": "^1.1.2",
|
|
103
|
-
"lru-cache": "^11.3.
|
|
103
|
+
"lru-cache": "^11.3.5",
|
|
104
104
|
"magic-string": "^0.30.21",
|
|
105
105
|
"merge": "^2.1.1",
|
|
106
106
|
"p-queue": "^9.1.2",
|
|
@@ -116,32 +116,32 @@
|
|
|
116
116
|
"vite-tsconfig-paths": "^6.1.1",
|
|
117
117
|
"vue": "^3.5.32",
|
|
118
118
|
"vue-tsc": "^3.2.6",
|
|
119
|
-
"@weapp-core/constants": "0.1.
|
|
119
|
+
"@weapp-core/constants": "^0.1.1",
|
|
120
120
|
"@weapp-core/init": "6.0.6",
|
|
121
121
|
"@weapp-core/logger": "3.1.1",
|
|
122
122
|
"@weapp-core/schematics": "6.0.4",
|
|
123
123
|
"@weapp-core/shared": "3.0.3",
|
|
124
|
-
"@weapp-vite/ast": "6.15.
|
|
124
|
+
"@weapp-vite/ast": "6.15.4",
|
|
125
125
|
"@weapp-vite/mcp": "1.2.1",
|
|
126
126
|
"@weapp-vite/miniprogram-automator": "1.0.2",
|
|
127
127
|
"@weapp-vite/volar": "2.0.8",
|
|
128
|
-
"@weapp-vite/web": "1.3.
|
|
128
|
+
"@weapp-vite/web": "1.3.15",
|
|
129
129
|
"@wevu/api": "0.2.3",
|
|
130
|
-
"@wevu/web-apis": "1.2.
|
|
130
|
+
"@wevu/web-apis": "1.2.6",
|
|
131
131
|
"rolldown-require": "2.0.13",
|
|
132
132
|
"vite-plugin-performance": "2.0.1",
|
|
133
133
|
"weapp-ide-cli": "5.2.2",
|
|
134
|
-
"wevu": "6.15.
|
|
134
|
+
"wevu": "6.15.4"
|
|
135
135
|
},
|
|
136
136
|
"publishConfig": {
|
|
137
137
|
"access": "public",
|
|
138
138
|
"registry": "https://registry.npmjs.org"
|
|
139
139
|
},
|
|
140
140
|
"devDependencies": {
|
|
141
|
-
"oxc-parser": "^0.
|
|
141
|
+
"oxc-parser": "^0.125.0",
|
|
142
142
|
"oxc-walker": "^0.7.0",
|
|
143
143
|
"tailwindcss": "^4.2.2",
|
|
144
|
-
"ts-morph": "^
|
|
144
|
+
"ts-morph": "^28.0.0"
|
|
145
145
|
},
|
|
146
146
|
"scripts": {
|
|
147
147
|
"stub": "unbuild --stub",
|
package/dist/file-B9K91wb0.mjs
DELETED