weapp-vite 7.3.0 → 7.5.0

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.
Files changed (91) hide show
  1. package/README.md +154 -6
  2. package/bin/bootstrap.js +14 -1
  3. package/dist/adapters-CcHrsYaj.mjs +1 -0
  4. package/dist/analyze-ZJUvEdaY.mjs +248 -0
  5. package/dist/auto-import-components/resolvers.mjs +1 -2
  6. package/dist/auto-import-presets/wevu-router.mjs +1 -2
  7. package/dist/auto-import-presets/wevu.mjs +1 -2
  8. package/dist/auto-routes.mjs +2 -1
  9. package/dist/budget-BD7VqLCl.d.mts +178 -0
  10. package/dist/chunkStrategy-DRA5WpB-.mjs +1436 -0
  11. package/dist/cli-acceptance.d.mts +1 -0
  12. package/dist/cli-acceptance.mjs +21 -0
  13. package/dist/cli.mjs +1918 -2089
  14. package/dist/compatibility.mjs +1 -2
  15. package/dist/{config-1J4rToMR.d.mts → config-V0L-IAJf.d.mts} +419 -39
  16. package/dist/config.d.mts +2 -2
  17. package/dist/config.mjs +1 -1
  18. package/dist/constants-DEZdcsMn.mjs +85 -0
  19. package/dist/{createContext-cqr9Y4EV.mjs → createCompilerContextInstance-DJH_P_nZ.mjs} +17602 -15886
  20. package/dist/createContext-BqYzHhY9.mjs +12 -0
  21. package/dist/dashboard/analyze.d.mts +48 -0
  22. package/dist/dashboard/analyze.mjs +1 -0
  23. package/dist/dashboard/vite.d.mts +9 -0
  24. package/dist/dashboard/vite.mjs +44 -0
  25. package/dist/dashboard-DvqF3Key.mjs +1842 -0
  26. package/dist/dashboard.d.mts +3 -0
  27. package/dist/dashboard.mjs +1 -0
  28. package/dist/dashboardViteBridge-Dy3nAD4m.mjs +299 -0
  29. package/dist/dev-fR5GiJRO.mjs +63 -0
  30. package/dist/devProvider-BGBkw28J.mjs +1050 -0
  31. package/dist/docs/README.md +154 -6
  32. package/dist/docs/ai-workflows.md +4 -0
  33. package/dist/docs/doctor.md +38 -0
  34. package/dist/docs/getting-started.md +52 -1
  35. package/dist/docs/index.md +6 -2
  36. package/dist/docs/mcp.md +94 -1
  37. package/dist/docs/testing.md +29 -2
  38. package/dist/docs/troubleshooting.md +8 -0
  39. package/dist/docs/uni-app-component-libraries.md +8 -7
  40. package/dist/docs/upload.md +226 -0
  41. package/dist/docs/vite-plugin.md +171 -0
  42. package/dist/docs/vue-sfc.md +19 -0
  43. package/dist/docs/weapp-config.md +374 -2
  44. package/dist/docs/wevu-authoring.md +10 -0
  45. package/dist/doctor-worker.d.mts +1 -0
  46. package/dist/doctor-worker.mjs +59 -0
  47. package/dist/doctor.d.mts +144 -0
  48. package/dist/doctor.mjs +848 -0
  49. package/dist/eslint.mjs +1 -2
  50. package/dist/file-DRb4eWqw.mjs +1 -0
  51. package/dist/{file-CKB0Tn8Z.mjs → file-sC3jD7Fh.mjs} +16 -93
  52. package/dist/files-BqxFIPRp.mjs +45 -0
  53. package/dist/getInstance-DiGSzBNI.mjs +28 -0
  54. package/dist/getInstance-SiE6WZRh.mjs +1 -0
  55. package/dist/index-C9HjUX5c.d.mts +741 -0
  56. package/dist/index.d.mts +10 -8
  57. package/dist/index.mjs +3 -2
  58. package/dist/json.d.mts +1 -1
  59. package/dist/json.mjs +1 -2
  60. package/dist/lifecycle-BROTlwSL.mjs +320 -0
  61. package/dist/loadConfig-C3BQhz7F.mjs +59 -0
  62. package/dist/loadConfig-VGtBF4qm.mjs +1 -0
  63. package/dist/logger-DGn5iEVN.mjs +1 -0
  64. package/dist/{mcp-BG6TliEg.mjs → mcp-Cj8Maqo6.mjs} +16 -7
  65. package/dist/mcp-D3Yh24Cj.mjs +529 -0
  66. package/dist/mcp.d.mts +6 -3
  67. package/dist/mcp.mjs +1 -2
  68. package/dist/package-7swhyLmf.mjs +91 -0
  69. package/dist/path-doV773b7.mjs +103 -0
  70. package/dist/platform-CnkySBKz.mjs +175 -0
  71. package/dist/processCleanup-B6KA30Zc.mjs +77 -0
  72. package/dist/protocol-vg8HGJ4n.mjs +138 -0
  73. package/dist/{resolvers-icNxkpcy.mjs → resolvers-Dod-euqX.mjs} +4 -1
  74. package/dist/resolvers.mjs +1 -2
  75. package/dist/runtime.mjs +1 -2
  76. package/dist/session-PskhD-nZ.mjs +390 -0
  77. package/dist/test.d.mts +1 -0
  78. package/dist/test.mjs +201 -44
  79. package/dist/types.d.mts +2 -2
  80. package/dist/upload-D4msblBf.mjs +562 -0
  81. package/dist/upload-worker.d.mts +1 -0
  82. package/dist/upload-worker.mjs +161 -0
  83. package/dist/utils-CJSCgEj6.mjs +1094 -0
  84. package/dist/vite.d.mts +9 -0
  85. package/dist/vite.mjs +270 -0
  86. package/dist/volar.d.mts +2 -2
  87. package/dist/web-apis.mjs +1 -2
  88. package/package.json +85 -37
  89. package/dist/file-CvgkbGIx.mjs +0 -2
  90. package/dist/getInstance-CZ1s63zd.mjs +0 -2
  91. package/dist/logger-mt4mSTqV.mjs +0 -2
package/dist/types.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { f as Resolver } from "./index-CaXAtb9e.mjs";
2
2
  import { n as AutoRoutesSubPackage, t as AutoRoutes } from "./routes-C7fCmf92.mjs";
3
- import { $ as WeappCompilerPluginContext, $n as WeappLibEntryContext, $t as WeappWevuConfig, A as Ref, An as NpmDependencyPattern, At as WeappAutoRoutesIncludePattern, B as BindingErrorLike, Bn as SharedChunkStrategy, Bt as WeappNpmConfig, Cn as JsonConfig, Ct as HandleWxmlOptions, D as MethodDefinitions, Dn as JsonMergeStrategy, Dt as WeappAppPreludeMode, E as InlineConfig, En as JsonMergeStage, Et as WeappAppPreludeConfig, F as RolldownPlugin, Fn as NpmSubPackageConfig, Ft as WeappInjectRequestGlobalsTarget, G as EntryJsonFragment, Gn as SubPackage, Gt as WeappRequestRuntimeConfig, H as BaseEntry, Hn as StyleConfigObject, Ht as WeappPreloadRule, I as RolldownPluginOption, In as ResolvedAlias, It as WeappInjectWeapiConfig, J as ScanComponentItem, Jn as SubPackageStyleEntry, Jt as WeappSubPackageConfig, K as PageEntry, Kn as SubPackageStyleConfigEntry, Kt as WeappRouteRule, L as RolldownWatchOptions, Ln as SharedChunkDynamicImports, Lt as WeappInjectWebRuntimeGlobalsConfig, M as RolldownBuild, Mn as NpmPackageFilesConfig, Mt as WeappBuildScopeObjectConfig, N as RolldownOptions, Nn as NpmPluginPackageConfig, Nt as WeappHmrConfig, O as Plugin, On as MpPlatform, Ot as WeappAutoRoutesConfig, P as RolldownOutput, Pn as NpmStrategy, Pt as WeappInjectRequestGlobalsConfig, Q as WeappCompilerPluginCapabilities, Qn as WeappLibDtsOptions, Qt as WeappWebRuntimeConfig, R as RolldownWatcher, Rn as SharedChunkMode, Rt as WeappInjectWebRuntimeGlobalsTarget, Sn as JsFormat, St as EnhanceWxmlOptions, T as ConfigEnv, Tn as JsonMergeFunction, Tt as ScanWxmlOptions, U as ComponentEntry, Un as StyleEntry, Ut as WeappReactCompilerConfig, V as AppEntry, Vn as StyleConfigEntry, Vt as WeappPreloadNetwork, W as Entry, Wn as StyleScope, Wt as WeappReactConfig, X as WeappCompilerOutputRequest, Xn as WeappLibComponentJson, Xt as WeappVueConfig, Y as WxmlDep, Yn as SubPackageStyleScope, Yt as WeappUniAppConfig, Z as WeappCompilerPlugin, Zn as WeappLibConfig, Zt as WeappVueTemplateConfig, _n as GenerateTemplateFactory, _t as WeappTailwindcssOptions, an as ChunksConfig, ar as WeappManagedServerTsconfigConfig, at as WeappCompilerSourceClaim, b as ChangeEvent, bn as GenerateTemplateScope, bt as AutoImportComponentsOption, cn as DeprecatedInlineDynamicImports, cr as WeappWebConfig, ct as ProjectConfig, dn as GenerateFileType, dt as WeappAnalyzeBudgetConfig, en as WeappWorkerConfig, er as WeappLibFileName, et as WeappCompilerPluginController, fn as GenerateFilenamesOptions, ft as WeappAnalyzeConfig, gn as GenerateTemplateEntry, gt as WeappForwardConsoleLogLevel, hn as GenerateTemplateContext, ht as WeappForwardConsoleConfig, in as BuildNpmPackageMeta, ir as WeappManagedNodeTsconfigConfig, it as WeappCompilerResourceKind, j as ResolvedConfig, jn as NpmMainPackageConfig, jt as WeappBuildScopeConfig, k as PluginOption, kn as NpmBuildOptions, kt as WeappAutoRoutesInclude, ln as GenerateDirsOptions, lt as SubPackageMetaValue, mn as GenerateTemplate, mt as WeappDebugConfig, nn as AliasOptions, nr as WeappLibVueTscOptions, nt as WeappCompilerPluginOption, on as CopyGlobs, or as WeappManagedSharedTsconfigConfig, ot as WeappCompilerSourceRequest, pn as GenerateOptions, pt as WeappAnalyzeHistoryConfig, q as ComponentsMap, qn as SubPackageStyleConfigObject, qt as WeappRouteRules, rn as AlipayNpmMode, rr as WeappManagedAppTsconfigConfig, rt as WeappCompilerPluginPhase, sn as CopyOptions, sr as WeappManagedTypeScriptConfig, st as WeappCompilerTransformResult, tn as Alias, tr as WeappLibInternalDtsOptions, tt as WeappCompilerPluginFactory, un as GenerateExtensionsOptions, ur as WeappViteHostMeta, ut as UserConfig, vn as GenerateTemplateFileSource, vt as WeappViteConfig, w as ComputedDefinitions, wn as JsonMergeContext, wt as MultiPlatformConfig, x as WeappVitePluginApi, xn as GenerateTemplatesConfig, xt as EnhanceOptions, yn as GenerateTemplateInlineSource, yr as WeappViteRuntime, yt as AutoImportComponents, z as ViteDevServer, zn as SharedChunkOverride, zt as WeappMcpConfig } from "./config-1J4rToMR.mjs";
3
+ import { $ as WeappCompilerHmrRequest, $n as NpmMainPackageConfig, $t as WeappSubPackageConfig, A as PluginOption, An as DeprecatedInlineDynamicImports, Ar as WeappWebConfig, At as ScanWxmlOptions, B as ViteDevServer, Bn as GenerateTemplateFileSource, Bt as WeappInjectRequestGlobalsTarget, Cn as Alias, Cr as WeappLibInternalDtsOptions, Ct as WeappViteConfig, D as InlineConfig, Dn as ChunksConfig, Dr as WeappManagedServerTsconfigConfig, Dt as EnhanceWxmlOptions, E as ConfigEnv, En as BuildNpmPackageMeta, Er as WeappManagedNodeTsconfigConfig, Et as EnhanceOptions, F as RolldownOutput, Fn as GenerateOptions, Ft as WeappAutoRoutesIncludePattern, G as Entry, Gn as JsonConfig, Gt as WeappNpmConfig, H as AppEntry, Hn as GenerateTemplateScope, Ht as WeappInjectWebRuntimeGlobalsConfig, I as RolldownPlugin, In as GenerateTemplate, It as WeappBuildScopeConfig, J as ComponentsMap, Jn as JsonMergeStage, Jt as WeappReactCompilerConfig, K as EntryJsonFragment, Kn as JsonMergeContext, Kt as WeappPreloadNetwork, L as RolldownPluginOption, Ln as GenerateTemplateContext, Lt as WeappBuildScopeObjectConfig, M as ResolvedConfig, Mn as GenerateExtensionsOptions, Mr as WeappViteHostMeta, Mt as WeappAppPreludeMode, N as RolldownBuild, Nn as GenerateFileType, Nt as WeappAutoRoutesConfig, O as MethodDefinitions, On as CopyGlobs, Or as WeappManagedSharedTsconfigConfig, Ot as HandleWxmlOptions, P as RolldownOptions, Pn as GenerateFilenamesOptions, Pt as WeappAutoRoutesInclude, Q as WeappCompilerHmrPreparation, Qn as NpmDependencyPattern, Qt as WeappRouteRules, R as RolldownWatchOptions, Rn as GenerateTemplateEntry, Rt as WeappHmrConfig, Sn as MultiPlatformProjectConfigs, Sr as WeappLibFileName, St as WeappUploadConfig, T as ComputedDefinitions, Tn as AlipayNpmMode, Tr as WeappManagedAppTsconfigConfig, Tt as AutoImportComponentsOption, U as BaseEntry, Un as GenerateTemplatesConfig, Ut as WeappInjectWebRuntimeGlobalsTarget, V as BindingErrorLike, Vn as GenerateTemplateInlineSource, Vr as WeappViteRuntime, Vt as WeappInjectWeapiConfig, W as ComponentEntry, Wn as JsFormat, Wt as WeappMcpConfig, X as WxmlDep, Xn as MpPlatform, Xt as WeappRequestRuntimeConfig, Y as ScanComponentItem, Yn as JsonMergeStrategy, Yt as WeappReactConfig, Z as WeappCompilerHmrAsset, Zn as NpmBuildOptions, Zt as WeappRouteRule, _n as WxmlTransformContext, _r as SubPackageStyleScope, _t as WeappAnalyzeHistoryConfig, an as WeappWorkerConfig, ar as SharedChunkDynamicImports, at as WeappCompilerPluginFactory, b as ChangeEvent, bn as WxmlTransformVisitor, br as WeappLibDtsOptions, bt as WeappForwardConsoleLogLevel, cn as WxmlValidate, cr as SharedChunkStrategy, ct as WeappCompilerResourceKind, dn as WxmlValidationVisitor, dr as StyleEntry, dt as WeappCompilerTransformResult, en as WeappUniAppConfig, er as NpmPackageFilesConfig, et as WeappCompilerOutputRequest, fn as WxmlAttribute, fr as StyleScope, ft as ProjectConfig, gn as WxmlTransform, gr as SubPackageStyleEntry, gt as WeappAnalyzeConfig, hn as WxmlSourceLocation, hr as SubPackageStyleConfigObject, ht as WeappAnalyzeBudgetConfig, in as WeappWevuConfig, ir as ResolvedAlias, it as WeappCompilerPluginController, j as Ref, jn as GenerateDirsOptions, jt as WeappAppPreludeConfig, k as Plugin, kn as CopyOptions, kr as WeappManagedTypeScriptConfig, kt as MultiPlatformConfig, ln as WxmlValidationContext, lr as StyleConfigEntry, lt as WeappCompilerSourceClaim, mn as WxmlElementInfo, mr as SubPackageStyleConfigEntry, mt as UserConfig, nn as WeappVueTemplateConfig, nr as NpmStrategy, nt as WeappCompilerPluginCapabilities, on as WxmlRemoveAttrRule, or as SharedChunkMode, ot as WeappCompilerPluginOption, pn as WxmlAttributeValue, pr as SubPackage, pt as SubPackageMetaValue, q as PageEntry, qn as JsonMergeFunction, qt as WeappPreloadRule, rn as WeappWebRuntimeConfig, rr as NpmSubPackageConfig, rt as WeappCompilerPluginContext, sn as WxmlRemoveOptions, sr as SharedChunkOverride, st as WeappCompilerPluginPhase, tn as WeappVueConfig, tr as NpmPluginPackageConfig, tt as WeappCompilerPlugin, un as WxmlValidationDiagnostic, ur as StyleConfigObject, ut as WeappCompilerSourceRequest, vn as WxmlTransformNode, vr as WeappLibComponentJson, vt as WeappDebugConfig, wn as AliasOptions, wr as WeappLibVueTscOptions, wt as AutoImportComponents, x as WeappVitePluginApi, xn as MultiPlatformProjectConfig, xr as WeappLibEntryContext, xt as WeappTailwindcssOptions, yn as WxmlTransformResult, yr as WeappLibConfig, yt as WeappForwardConsoleConfig, z as RolldownWatcher, zn as GenerateTemplateFactory, zt as WeappInjectRequestGlobalsConfig } from "./config-V0L-IAJf.mjs";
4
4
  import { t as WeappI18nConfig } from "./types-CgZn5X6j.mjs";
5
- export { Alias, AliasOptions, AlipayNpmMode, AppEntry, AutoImportComponents, AutoImportComponentsOption, AutoRoutes, AutoRoutesSubPackage, BaseEntry, BindingErrorLike, BuildNpmPackageMeta, ChangeEvent, ChunksConfig, ComponentEntry, ComponentsMap, type ComputedDefinitions, type ConfigEnv, CopyGlobs, CopyOptions, DeprecatedInlineDynamicImports, EnhanceOptions, EnhanceWxmlOptions, Entry, EntryJsonFragment, GenerateDirsOptions, GenerateExtensionsOptions, GenerateFileType, GenerateFilenamesOptions, GenerateOptions, GenerateTemplate, GenerateTemplateContext, GenerateTemplateEntry, GenerateTemplateFactory, GenerateTemplateFileSource, GenerateTemplateInlineSource, GenerateTemplateScope, GenerateTemplatesConfig, HandleWxmlOptions, type InlineConfig, JsFormat, JsonConfig, JsonMergeContext, JsonMergeFunction, JsonMergeStage, JsonMergeStrategy, type MethodDefinitions, MpPlatform, MultiPlatformConfig, NpmBuildOptions, NpmDependencyPattern, NpmMainPackageConfig, NpmPackageFilesConfig, NpmPluginPackageConfig, NpmStrategy, NpmSubPackageConfig, PageEntry, type Plugin, type PluginOption, ProjectConfig, type Ref, ResolvedAlias, type ResolvedConfig, type Resolver, type RolldownBuild, type RolldownOptions, type RolldownOutput, type RolldownPlugin, type RolldownPluginOption, type RolldownWatchOptions, type RolldownWatcher, ScanComponentItem, ScanWxmlOptions, SharedChunkDynamicImports, SharedChunkMode, SharedChunkOverride, SharedChunkStrategy, StyleConfigEntry, StyleConfigObject, StyleEntry, StyleScope, SubPackage, SubPackageMetaValue, SubPackageStyleConfigEntry, SubPackageStyleConfigObject, SubPackageStyleEntry, SubPackageStyleScope, UserConfig, type ViteDevServer, WeappAnalyzeBudgetConfig, WeappAnalyzeConfig, WeappAnalyzeHistoryConfig, WeappAppPreludeConfig, WeappAppPreludeMode, WeappAutoRoutesConfig, WeappAutoRoutesInclude, WeappAutoRoutesIncludePattern, WeappBuildScopeConfig, WeappBuildScopeObjectConfig, WeappCompilerOutputRequest, WeappCompilerPlugin, WeappCompilerPluginCapabilities, WeappCompilerPluginContext, WeappCompilerPluginController, WeappCompilerPluginFactory, WeappCompilerPluginOption, WeappCompilerPluginPhase, WeappCompilerResourceKind, WeappCompilerSourceClaim, WeappCompilerSourceRequest, WeappCompilerTransformResult, WeappDebugConfig, WeappForwardConsoleConfig, WeappForwardConsoleLogLevel, WeappHmrConfig, type WeappI18nConfig, WeappInjectRequestGlobalsConfig, WeappInjectRequestGlobalsTarget, WeappInjectWeapiConfig, WeappInjectWebRuntimeGlobalsConfig, WeappInjectWebRuntimeGlobalsTarget, WeappLibComponentJson, WeappLibConfig, WeappLibDtsOptions, WeappLibEntryContext, WeappLibFileName, WeappLibInternalDtsOptions, WeappLibVueTscOptions, WeappManagedAppTsconfigConfig, WeappManagedNodeTsconfigConfig, WeappManagedServerTsconfigConfig, WeappManagedSharedTsconfigConfig, WeappManagedTypeScriptConfig, WeappMcpConfig, WeappNpmConfig, WeappPreloadNetwork, WeappPreloadRule, WeappReactCompilerConfig, WeappReactConfig, WeappRequestRuntimeConfig, WeappRouteRule, WeappRouteRules, WeappSubPackageConfig, WeappTailwindcssOptions, WeappUniAppConfig, WeappViteConfig, type WeappViteHostMeta, WeappVitePluginApi, type WeappViteRuntime, WeappVueConfig, WeappVueTemplateConfig, WeappWebConfig, WeappWebRuntimeConfig, WeappWevuConfig, WeappWorkerConfig, WxmlDep };
5
+ export { Alias, AliasOptions, AlipayNpmMode, AppEntry, AutoImportComponents, AutoImportComponentsOption, AutoRoutes, AutoRoutesSubPackage, BaseEntry, BindingErrorLike, BuildNpmPackageMeta, ChangeEvent, ChunksConfig, ComponentEntry, ComponentsMap, type ComputedDefinitions, type ConfigEnv, CopyGlobs, CopyOptions, DeprecatedInlineDynamicImports, EnhanceOptions, EnhanceWxmlOptions, Entry, EntryJsonFragment, GenerateDirsOptions, GenerateExtensionsOptions, GenerateFileType, GenerateFilenamesOptions, GenerateOptions, GenerateTemplate, GenerateTemplateContext, GenerateTemplateEntry, GenerateTemplateFactory, GenerateTemplateFileSource, GenerateTemplateInlineSource, GenerateTemplateScope, GenerateTemplatesConfig, HandleWxmlOptions, type InlineConfig, JsFormat, type JsonConfig, type JsonMergeContext, type JsonMergeFunction, type JsonMergeStage, type JsonMergeStrategy, type MethodDefinitions, MpPlatform, MultiPlatformConfig, MultiPlatformProjectConfig, MultiPlatformProjectConfigs, NpmBuildOptions, NpmDependencyPattern, NpmMainPackageConfig, NpmPackageFilesConfig, NpmPluginPackageConfig, NpmStrategy, NpmSubPackageConfig, PageEntry, type Plugin, type PluginOption, ProjectConfig, type Ref, ResolvedAlias, type ResolvedConfig, type Resolver, type RolldownBuild, type RolldownOptions, type RolldownOutput, type RolldownPlugin, type RolldownPluginOption, type RolldownWatchOptions, type RolldownWatcher, ScanComponentItem, ScanWxmlOptions, SharedChunkDynamicImports, SharedChunkMode, SharedChunkOverride, SharedChunkStrategy, StyleConfigEntry, StyleConfigObject, StyleEntry, StyleScope, SubPackage, SubPackageMetaValue, SubPackageStyleConfigEntry, SubPackageStyleConfigObject, SubPackageStyleEntry, SubPackageStyleScope, UserConfig, type ViteDevServer, WeappAnalyzeBudgetConfig, WeappAnalyzeConfig, WeappAnalyzeHistoryConfig, WeappAppPreludeConfig, WeappAppPreludeMode, WeappAutoRoutesConfig, WeappAutoRoutesInclude, WeappAutoRoutesIncludePattern, WeappBuildScopeConfig, WeappBuildScopeObjectConfig, type WeappCompilerHmrAsset, type WeappCompilerHmrPreparation, type WeappCompilerHmrRequest, WeappCompilerOutputRequest, WeappCompilerPlugin, WeappCompilerPluginCapabilities, WeappCompilerPluginContext, WeappCompilerPluginController, WeappCompilerPluginFactory, WeappCompilerPluginOption, WeappCompilerPluginPhase, WeappCompilerResourceKind, WeappCompilerSourceClaim, WeappCompilerSourceRequest, WeappCompilerTransformResult, WeappDebugConfig, WeappForwardConsoleConfig, WeappForwardConsoleLogLevel, WeappHmrConfig, type WeappI18nConfig, WeappInjectRequestGlobalsConfig, WeappInjectRequestGlobalsTarget, WeappInjectWeapiConfig, WeappInjectWebRuntimeGlobalsConfig, WeappInjectWebRuntimeGlobalsTarget, WeappLibComponentJson, WeappLibConfig, WeappLibDtsOptions, WeappLibEntryContext, WeappLibFileName, WeappLibInternalDtsOptions, WeappLibVueTscOptions, WeappManagedAppTsconfigConfig, WeappManagedNodeTsconfigConfig, WeappManagedServerTsconfigConfig, WeappManagedSharedTsconfigConfig, WeappManagedTypeScriptConfig, WeappMcpConfig, WeappNpmConfig, WeappPreloadNetwork, WeappPreloadRule, WeappReactCompilerConfig, WeappReactConfig, WeappRequestRuntimeConfig, WeappRouteRule, WeappRouteRules, WeappSubPackageConfig, WeappTailwindcssOptions, WeappUniAppConfig, WeappUploadConfig, WeappViteConfig, type WeappViteHostMeta, WeappVitePluginApi, type WeappViteRuntime, WeappVueConfig, WeappVueTemplateConfig, WeappWebConfig, WeappWebRuntimeConfig, WeappWevuConfig, WeappWorkerConfig, WxmlAttribute, WxmlAttributeValue, WxmlDep, WxmlElementInfo, WxmlRemoveAttrRule, WxmlRemoveOptions, WxmlSourceLocation, WxmlTransform, WxmlTransformContext, WxmlTransformNode, WxmlTransformResult, WxmlTransformVisitor, WxmlValidate, WxmlValidationContext, WxmlValidationDiagnostic, WxmlValidationVisitor };
@@ -0,0 +1,562 @@
1
+ import { m as resolveMiniPlatform } from "./platform-CnkySBKz.mjs";
2
+ import { r as logger_default } from "./logger-DGn5iEVN.mjs";
3
+ import { createRequire } from "node:module";
4
+ import process from "node:process";
5
+ import { pathToFileURL } from "node:url";
6
+ import path from "node:path";
7
+ import { mkdir, readFile, stat } from "node:fs/promises";
8
+ import { getPackageInfo } from "local-pkg";
9
+ import { execFile, execFileSync } from "node:child_process";
10
+ //#region src/cli/upload/processTree.ts
11
+ function childPids(pid, lifetime) {
12
+ if (process.platform === "win32") {
13
+ const since = lifetime ? `[DateTimeOffset]::FromUnixTimeMilliseconds(${lifetime.start}).UtcDateTime` : `(Get-CimInstance Win32_Process -Filter 'ProcessId = ${pid}').CreationDate.ToUniversalTime()`;
14
+ const until = lifetime ? `[DateTimeOffset]::FromUnixTimeMilliseconds(${lifetime.end}).UtcDateTime` : "[DateTime]::UtcNow";
15
+ return execFileSync("powershell.exe", [
16
+ "-NoProfile",
17
+ "-NonInteractive",
18
+ "-Command",
19
+ `$ErrorActionPreference = 'Stop'; $since = ${since}; $until = ${until}; Get-CimInstance Win32_Process -Filter 'ParentProcessId = ${pid}' | Where-Object { \$_.CreationDate.ToUniversalTime() -ge \$since -and \$_.CreationDate.ToUniversalTime() -le \$until } | Select-Object -ExpandProperty ProcessId`
20
+ ], {
21
+ encoding: "utf8",
22
+ windowsHide: true,
23
+ timeout: 3e4,
24
+ stdio: [
25
+ "ignore",
26
+ "pipe",
27
+ "ignore"
28
+ ]
29
+ }).split(/\s+/).map(Number).filter((value) => Number.isSafeInteger(value) && value > 0);
30
+ }
31
+ const output = execFileSync("ps", [
32
+ "-A",
33
+ "-o",
34
+ "pid=,ppid="
35
+ ], {
36
+ encoding: "utf8",
37
+ timeout: 5e3,
38
+ stdio: [
39
+ "ignore",
40
+ "pipe",
41
+ "ignore"
42
+ ]
43
+ });
44
+ const children = /* @__PURE__ */ new Map();
45
+ for (const line of output.trim().split(/\r?\n/)) {
46
+ const [child, parent] = line.trim().split(/\s+/).map(Number);
47
+ if (child && parent) {
48
+ const siblings = children.get(parent) ?? [];
49
+ siblings.push(child);
50
+ children.set(parent, siblings);
51
+ }
52
+ }
53
+ const descendants = [];
54
+ const visit = (parent) => {
55
+ for (const child of children.get(parent) ?? []) {
56
+ visit(child);
57
+ descendants.push(child);
58
+ }
59
+ };
60
+ visit(pid);
61
+ return descendants;
62
+ }
63
+ function killPid(pid) {
64
+ try {
65
+ process.kill(pid, "SIGKILL");
66
+ } catch (error) {
67
+ if (error.code !== "ESRCH") throw error;
68
+ }
69
+ }
70
+ /** POSIX 使用独立进程组;已退出的根进程不再授权向其正 PID 发信号。 */
71
+ function terminateUploadProcess(pid, options) {
72
+ if (process.platform === "win32") {
73
+ if (options?.exited) {
74
+ if (!options.lifetime) throw new Error("缺少已退出进程的生命周期,无法确认子进程归属。");
75
+ for (const child of childPids(pid, options.lifetime)) terminateUploadProcess(child);
76
+ return;
77
+ }
78
+ try {
79
+ execFileSync("taskkill", [
80
+ "/PID",
81
+ String(pid),
82
+ "/T",
83
+ "/F"
84
+ ], {
85
+ windowsHide: true,
86
+ timeout: 5e3,
87
+ stdio: "ignore"
88
+ });
89
+ } catch (error) {
90
+ try {
91
+ process.kill(pid, 0);
92
+ } catch (probeError) {
93
+ if (probeError.code === "ESRCH") {
94
+ if (!options?.lifetime) throw new Error("根进程已消失,无法确认子进程归属。");
95
+ for (const child of childPids(pid, options.lifetime)) terminateUploadProcess(child);
96
+ return;
97
+ }
98
+ }
99
+ throw error;
100
+ }
101
+ return;
102
+ }
103
+ if (options?.processGroup) {
104
+ try {
105
+ process.kill(-pid, "SIGKILL");
106
+ } catch (error) {
107
+ if (error.code !== "ESRCH") throw error;
108
+ if (!options.exited) killPid(pid);
109
+ }
110
+ return;
111
+ }
112
+ if (!options?.exited) killPid(pid);
113
+ }
114
+ /** 只终止当前 worker 所属的本地子进程,不推断远端任务状态。 */
115
+ function terminateUploadDescendants(pid) {
116
+ for (const child of childPids(pid)) terminateUploadProcess(child);
117
+ }
118
+ //#endregion
119
+ //#region src/cli/upload/tools.ts
120
+ function requireUploadEnv(context, name) {
121
+ const value = context.env[name]?.trim();
122
+ if (!value) throw new Error(`上传缺少环境变量 ${name}。请通过环境变量或项目 .env 文件配置凭据。`);
123
+ return value;
124
+ }
125
+ function requireUploadAppId(context) {
126
+ const appid = context.appid?.trim();
127
+ if (!appid || appid === "touristappid") throw new Error("上传需要目标平台的真实 AppID,请检查项目配置。");
128
+ return appid;
129
+ }
130
+ function redactUploadSecrets(message, secrets) {
131
+ for (const secret of [...new Set(secrets)].filter(Boolean).sort((a, b) => b.length - a.length)) message = message.split(secret).join("[REDACTED]");
132
+ return message.replace(/\b([a-z][a-z\d+.-]*:\/\/)[^\s/]+@/gi, "$1[REDACTED]@");
133
+ }
134
+ async function loadUploadPackage(specifier, cwd) {
135
+ let resolved;
136
+ try {
137
+ resolved = createRequire(path.join(cwd, "package.json")).resolve(specifier);
138
+ } catch {
139
+ const packageName = specifier.startsWith("@") ? specifier.split("/").slice(0, 2).join("/") : specifier.split("/")[0];
140
+ throw new Error(`无法解析上传工具 ${specifier},请在项目中安装:pnpm add -D ${packageName}`);
141
+ }
142
+ const loaded = await import(pathToFileURL(resolved).href);
143
+ return loaded.default ?? loaded;
144
+ }
145
+ /** 使用 Node 直接执行包入口,避免 Windows 的 .cmd 解析与 shell 引号差异。 */
146
+ async function runUploadCli(context, packageName, binName, args, secrets, captureOutput = false) {
147
+ const info = await getPackageInfo(packageName, { paths: [context.cwd] });
148
+ const bins = info?.packageJson.bin;
149
+ const bin = typeof bins === "string" ? bins : bins && typeof bins === "object" ? bins[binName] : void 0;
150
+ if (!info || typeof bin !== "string") throw new Error(`无法解析上传工具 ${binName},请在项目中安装:pnpm add -D ${packageName}`);
151
+ return new Promise((resolve, reject) => {
152
+ const child = execFile(process.execPath, [path.resolve(info.rootPath, bin), ...args], {
153
+ cwd: context.cwd,
154
+ env: context.env,
155
+ maxBuffer: 4194304,
156
+ encoding: "utf8",
157
+ windowsHide: true
158
+ }, (error, stdout, stderr) => {
159
+ const safeOutput = redactUploadSecrets(`${stdout}\n${stderr}`, secrets).trim();
160
+ if (error) {
161
+ reject(/* @__PURE__ */ new Error(`${packageName} 执行失败(${error.signal ?? error.code ?? "unknown"})${safeOutput ? `\n${safeOutput}` : ""}`));
162
+ return;
163
+ }
164
+ if (safeOutput && !captureOutput) logger_default.info(safeOutput);
165
+ resolve(stdout);
166
+ });
167
+ function cancel() {
168
+ if (child.pid) try {
169
+ if (process.platform !== "win32") terminateUploadDescendants(child.pid);
170
+ terminateUploadProcess(child.pid);
171
+ } catch {
172
+ child.kill("SIGKILL");
173
+ process.stderr.write("无法确认上传 CLI 子进程已全部终止。\n");
174
+ process.exitCode = 1;
175
+ }
176
+ }
177
+ process.once("exit", cancel);
178
+ child.once("close", () => process.off("exit", cancel));
179
+ child.stdin?.end();
180
+ });
181
+ }
182
+ //#endregion
183
+ //#region src/cli/upload/providers/alipay.ts
184
+ /** 校验支付宝身份密钥及上传版本,只在执行阶段加载并调用官方 SDK。 */
185
+ async function prepareAlipayUpload(context, action = "upload") {
186
+ const appId = requireUploadAppId({
187
+ ...context,
188
+ appid: context.env.ALIPAY_APP_ID?.trim() || context.appid
189
+ });
190
+ const identityKeyPath = path.resolve(context.cwd, requireUploadEnv(context, "ALIPAY_IDENTITY_KEY_PATH"));
191
+ if (action === "upload") {
192
+ if (!/^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)$/.test(context.version) || context.version.split(".").some((part) => Number(part) > 2147483647)) throw new Error("支付宝上传版本必须为 x.y.z 格式,各段不能有前导零且不能超过 2147483647。");
193
+ if (context.desc.length >= 200) throw new Error("支付宝上传描述必须少于 200 个字符。");
194
+ }
195
+ let identityKey;
196
+ try {
197
+ if (!(await stat(identityKeyPath)).isFile()) throw new Error("not a file");
198
+ identityKey = await readFile(identityKeyPath, "utf8");
199
+ } catch {
200
+ throw new Error("无法读取 ALIPAY_IDENTITY_KEY_PATH 指定的身份密钥文件;相对路径以项目根目录为基准。");
201
+ }
202
+ const secrets = [identityKey];
203
+ let identity;
204
+ try {
205
+ identity = JSON.parse(identityKey, (_key, value) => {
206
+ if (typeof value === "string" && value) secrets.push(value);
207
+ return value;
208
+ });
209
+ } catch {
210
+ throw new Error("ALIPAY_IDENTITY_KEY_PATH 必须指向从支付宝开放平台获取的 JSON 身份密钥文件。");
211
+ }
212
+ const alipay = identity && typeof identity === "object" && "alipay" in identity ? identity.alipay : void 0;
213
+ if (!alipay || typeof alipay !== "object" || !("authentication" in alipay) || !alipay.authentication) throw new Error("支付宝身份密钥文件缺少 alipay.authentication。请从开放平台重新获取身份密钥。");
214
+ return {
215
+ secrets,
216
+ async run(onProgress) {
217
+ const sdk = await loadUploadPackage("minidev", context.cwd);
218
+ if (action === "preview") {
219
+ const result = await sdk.minidev.preview({
220
+ appId,
221
+ project: context.projectPath,
222
+ identityKeyPath,
223
+ clientType: "alipay"
224
+ });
225
+ const qrCodeUrl = typeof result?.qrcodeUrl === "string" ? result.qrcodeUrl.trim() : "";
226
+ if (!qrCodeUrl) throw new Error("支付宝预览未返回二维码地址。");
227
+ return { qrCodeUrl };
228
+ }
229
+ return sdk.minidev.upload({
230
+ appId,
231
+ project: context.projectPath,
232
+ identityKeyPath,
233
+ clientType: "alipay",
234
+ version: context.version,
235
+ versionDescription: context.desc,
236
+ experience: false
237
+ }, onProgress ? {
238
+ onLog: (message) => onProgress({
239
+ type: "log",
240
+ message: redactUploadSecrets(message, secrets)
241
+ }),
242
+ onTaskCreated: (taskId) => onProgress({
243
+ type: "task-created",
244
+ message: redactUploadSecrets(taskId, secrets)
245
+ }),
246
+ onVersionCreated: (version) => onProgress({
247
+ type: "version-created",
248
+ message: redactUploadSecrets(version, secrets)
249
+ })
250
+ } : void 0);
251
+ }
252
+ };
253
+ }
254
+ //#endregion
255
+ //#region src/cli/upload/providers/douyin.ts
256
+ /** 校验抖音项目与 Token 对应的 AppID,仅在执行阶段调用官方上传或预览 SDK。 */
257
+ async function prepareDouyinUpload(context, action = "upload") {
258
+ const token = requireUploadEnv(context, "TT_UPLOAD_TOKEN");
259
+ const appid = context.env.TT_APP_ID?.trim() || requireUploadAppId(context);
260
+ if (action === "upload" && !/^\d+\.\d+\.\d+$/.test(context.version)) throw new Error("抖音上传版本号必须为 x.y.z 格式。");
261
+ if (action === "upload" && !context.desc.trim()) throw new Error("抖音上传需要非空版本描述。");
262
+ if (JSON.parse(await readFile(path.join(context.projectPath, "project.config.json"), "utf8"))?.appid !== appid) throw new Error("抖音 project.config.json 的 appid 必须与 TT_APP_ID 或项目配置的 AppID 一致,禁止向其他小程序上传。");
263
+ return {
264
+ secrets: [token],
265
+ async run() {
266
+ const sdk = await loadUploadPackage("tt-ide-cli", context.cwd);
267
+ sdk.setAppConfig({
268
+ appid,
269
+ config: { token }
270
+ });
271
+ if (action === "preview") {
272
+ const result = await sdk.preview({
273
+ project: { path: context.projectPath },
274
+ page: {
275
+ path: "",
276
+ query: "",
277
+ scene: "",
278
+ launchFrom: "",
279
+ location: ""
280
+ },
281
+ qrcode: { format: null },
282
+ cache: true,
283
+ copyToClipboard: false
284
+ });
285
+ if (typeof result?.shortUrl !== "string" || !result.shortUrl.trim()) throw new Error("抖音预览未返回有效的预览链接。");
286
+ return { previewUrl: result.shortUrl.trim() };
287
+ }
288
+ return sdk.upload({
289
+ project: { path: context.projectPath },
290
+ version: context.version,
291
+ changeLog: context.desc,
292
+ qrcode: { format: null },
293
+ copyToClipboard: false
294
+ });
295
+ }
296
+ };
297
+ }
298
+ //#endregion
299
+ //#region src/cli/upload/providers/jd.ts
300
+ /** 京东 SDK 不解析 IDE 配置,需要将项目根目录转换为 app.json 所在目录。 */
301
+ async function prepareJdUpload(context, action = "upload") {
302
+ const privateKey = requireUploadEnv(context, "JD_PRIVATE_KEY");
303
+ let projectPath = context.projectPath;
304
+ const configText = await readFile(path.join(projectPath, "project.config.json"), "utf8").catch((error) => {
305
+ if (error.code === "ENOENT") return;
306
+ throw error;
307
+ });
308
+ if (configText !== void 0) {
309
+ let config;
310
+ try {
311
+ config = JSON.parse(configText);
312
+ } catch {
313
+ throw new Error("京东项目的 project.config.json 不是有效的 JSON。");
314
+ }
315
+ if (!config || typeof config !== "object" || Array.isArray(config)) throw new Error("京东项目的 project.config.json 必须是 JSON 对象。");
316
+ if ("miniprogramRoot" in config) {
317
+ if (typeof config.miniprogramRoot !== "string") throw new TypeError("京东项目配置的 miniprogramRoot 必须是字符串。");
318
+ projectPath = path.resolve(projectPath, config.miniprogramRoot);
319
+ }
320
+ }
321
+ try {
322
+ if (!(await stat(path.join(projectPath, "app.json"))).isFile()) throw new Error("not a file");
323
+ } catch {
324
+ throw new Error(`京东${action === "preview" ? "预览" : "上传"}目录缺少 app.json,请先构建并检查 project.config.json 的 miniprogramRoot。`);
325
+ }
326
+ return {
327
+ secrets: [privateKey],
328
+ async run() {
329
+ const ci = await loadUploadPackage("jd-miniprogram-ci", context.cwd);
330
+ if (action === "preview") {
331
+ const result = await ci.preview({
332
+ privateKey,
333
+ projectPath,
334
+ qrcodeFormat: "image",
335
+ ignores: ["node_modules/**/*"]
336
+ });
337
+ const qrCodeUrl = typeof result?.imgUrl === "string" ? result.imgUrl.trim() : "";
338
+ if (!qrCodeUrl) throw new Error("京东预览未返回二维码地址。");
339
+ return { qrCodeUrl };
340
+ }
341
+ return ci.upload({
342
+ privateKey,
343
+ projectPath,
344
+ uv: context.version,
345
+ desc: context.desc,
346
+ ignores: ["node_modules/**/*"]
347
+ });
348
+ }
349
+ };
350
+ }
351
+ //#endregion
352
+ //#region src/cli/upload/providers/swan.ts
353
+ /** 使用官方百度 CLI 上传或预览普通小程序,JSON 模式会在认证失败时拒绝交互登录。 */
354
+ async function prepareSwanUpload(context, action = "upload") {
355
+ const token = requireUploadEnv(context, "SWAN_UPLOAD_TOKEN");
356
+ const minSwanVersion = requireUploadEnv(context, "SWAN_MIN_VERSION");
357
+ const appid = requireUploadAppId(context);
358
+ if (action === "upload" && !/^\d+(?:\.\d+){1,3}$/.test(context.version)) throw new Error("百度上传版本号必须由 2 至 4 段数字组成,例如 1.0.0。");
359
+ const projectConfig = JSON.parse(await readFile(path.join(context.projectPath, "project.swan.json"), "utf8"));
360
+ if (projectConfig?.appid !== appid) throw new Error("百度 project.swan.json 的 appid 必须与项目配置的 AppID 一致,禁止向其他小程序上传。");
361
+ if (projectConfig.developType && projectConfig.developType !== "normal") throw new Error("百度统一上传仅支持普通小程序,不执行插件、动态库或扩展的发布。");
362
+ const secrets = [token];
363
+ return {
364
+ secrets,
365
+ async run() {
366
+ if (action === "preview") {
367
+ const output = await runUploadCli({
368
+ ...context,
369
+ env: {
370
+ ...context.env,
371
+ IS_NODE_JS: "true"
372
+ }
373
+ }, "swan-toolkit", "swan", [
374
+ "preview",
375
+ "--project-path",
376
+ context.projectPath,
377
+ "--token",
378
+ token,
379
+ "--min-swan-version",
380
+ minSwanVersion,
381
+ "--json"
382
+ ], secrets, true);
383
+ let result;
384
+ try {
385
+ const marker = /^NODE_JS_ENV_RESULT:/m.exec(output);
386
+ if (!marker) throw new Error("缺少官方 JSON 结果标记。");
387
+ result = JSON.parse(output.slice(marker.index + marker[0].length));
388
+ } catch {
389
+ throw new Error("百度预览未返回有效的 JSON 结果。");
390
+ }
391
+ const list = result?.list;
392
+ const previewUrl = Array.isArray(list) ? list[list.length - 1]?.url : void 0;
393
+ if (typeof previewUrl !== "string" || !previewUrl.trim()) throw new Error("百度预览未返回有效的预览链接。");
394
+ return { previewUrl: previewUrl.trim() };
395
+ }
396
+ const output = await runUploadCli({
397
+ ...context,
398
+ env: {
399
+ ...context.env,
400
+ IS_NODE_JS: "true"
401
+ }
402
+ }, "swan-toolkit", "swan", [
403
+ "upload",
404
+ "--project-path",
405
+ context.projectPath,
406
+ "--token",
407
+ token,
408
+ "--release-version",
409
+ context.version,
410
+ "--min-swan-version",
411
+ minSwanVersion,
412
+ "--desc",
413
+ context.desc,
414
+ "--json"
415
+ ], secrets, true);
416
+ try {
417
+ const marker = /^NODE_JS_ENV_RESULT:/m.exec(output);
418
+ if (!marker) throw new Error("缺少官方 JSON 结果标记。");
419
+ return JSON.parse(output.slice(marker.index + marker[0].length));
420
+ } catch {
421
+ throw new Error("百度上传未返回有效的 JSON 结果。");
422
+ }
423
+ }
424
+ };
425
+ }
426
+ //#endregion
427
+ //#region src/cli/upload/providers/wechat.ts
428
+ /** 校验微信凭据,SDK 自行读取 IDE 项目中的 miniprogramRoot。 */
429
+ async function prepareWechatUpload(context, action = "upload") {
430
+ const appid = requireUploadAppId({
431
+ ...context,
432
+ appid: context.env.WEAPP_CI_APPID?.trim() || context.appid
433
+ });
434
+ const keyPath = path.resolve(context.cwd, requireUploadEnv(context, "WEAPP_CI_PRIVATE_KEY_PATH"));
435
+ const robotValue = context.env.WEAPP_CI_ROBOT?.trim();
436
+ if (robotValue !== void 0 && !/^0*(?:[1-9]|[12]\d|30)$/.test(robotValue)) throw new Error("WEAPP_CI_ROBOT 必须是 1 到 30 之间的整数。");
437
+ const robot = robotValue === void 0 ? void 0 : Number(robotValue);
438
+ let privateKey;
439
+ try {
440
+ if (!(await stat(keyPath)).isFile()) throw new Error("not a file");
441
+ privateKey = await readFile(keyPath, "utf8");
442
+ } catch {
443
+ throw new Error("无法读取 WEAPP_CI_PRIVATE_KEY_PATH 指定的私钥文件;相对路径以项目根目录为基准。");
444
+ }
445
+ if (!privateKey.trim()) throw new Error("WEAPP_CI_PRIVATE_KEY_PATH 指定的私钥文件不能为空。");
446
+ const secrets = [privateKey, privateKey.trim()];
447
+ return {
448
+ secrets,
449
+ async run(onProgress) {
450
+ const ci = await loadUploadPackage("miniprogram-ci", context.cwd);
451
+ const project = new ci.Project({
452
+ appid,
453
+ type: "miniProgram",
454
+ projectPath: context.projectPath,
455
+ privateKey,
456
+ ignores: ["node_modules/**/*"]
457
+ });
458
+ if (action === "preview") {
459
+ const qrCodePath = context.qrCodePath;
460
+ if (!qrCodePath) throw new Error("微信预览缺少二维码输出路径。");
461
+ await mkdir(path.dirname(qrCodePath), { recursive: true });
462
+ await ci.preview({
463
+ project,
464
+ desc: context.desc,
465
+ robot,
466
+ setting: { useProjectConfig: true },
467
+ qrcodeFormat: "image",
468
+ qrcodeOutputDest: qrCodePath
469
+ });
470
+ const qrCodeFile = await stat(qrCodePath).catch(() => void 0);
471
+ if (!qrCodeFile?.isFile() || qrCodeFile.size === 0) throw new Error("微信预览未生成有效的二维码文件。");
472
+ return { qrCodeFile: qrCodePath };
473
+ }
474
+ return ci.upload({
475
+ project,
476
+ version: context.version,
477
+ desc: context.desc,
478
+ robot,
479
+ setting: { useProjectConfig: true },
480
+ onProgressUpdate: onProgress ? (task) => {
481
+ onProgress({
482
+ type: "progress",
483
+ message: redactUploadSecrets(typeof task === "string" ? task : `${task.status}: ${task.message}`, secrets)
484
+ });
485
+ } : void 0
486
+ });
487
+ }
488
+ };
489
+ }
490
+ //#endregion
491
+ //#region src/cli/upload/providers/xhs.ts
492
+ /** 使用独立的官方 CI 实例上传或预览小红书项目,禁止回退到扫码登录。 */
493
+ async function prepareXhsUpload(context, action = "upload") {
494
+ const token = requireUploadEnv(context, "XHS_UPLOAD_TOKEN");
495
+ const appid = context.env.XHS_APP_ID?.trim() || requireUploadAppId(context);
496
+ if (action === "upload" && (!context.version.trim() || !context.desc.trim())) throw new Error("小红书上传需要非空版本号和版本描述。");
497
+ if (JSON.parse(await readFile(path.join(context.projectPath, "project.config.json"), "utf8"))?.appid !== appid) throw new Error("小红书 project.config.json 的 appid 必须与 XHS_APP_ID 或项目配置的 AppID 一致,禁止向其他小程序上传。");
498
+ return {
499
+ secrets: [token],
500
+ async run(onProgress) {
501
+ const { CI } = await loadUploadPackage("xhs-mp-cli/dist/ci.js", context.cwd);
502
+ const sdk = new CI();
503
+ sdk.core.login = async () => {
504
+ throw new Error("小红书上传与预览仅支持 Token 认证,禁止扫码登录,请检查 XHS_UPLOAD_TOKEN 和项目 AppID。");
505
+ };
506
+ sdk.setAppConfig({
507
+ appId: appid,
508
+ config: { token }
509
+ });
510
+ if (action === "preview") {
511
+ const result = await sdk.preview({
512
+ project: { projectPath: context.projectPath },
513
+ verbose: false
514
+ });
515
+ if (typeof result?.qrcodeUrl !== "string" || !result.qrcodeUrl.trim()) throw new Error("小红书预览未返回有效的预览链接。");
516
+ return { previewUrl: result.qrcodeUrl.trim() };
517
+ }
518
+ return sdk.upload({
519
+ project: { projectPath: context.projectPath },
520
+ version: context.version,
521
+ desc: context.desc,
522
+ verbose: false,
523
+ progressCallback: onProgress ? (progress) => {
524
+ if (progress === -1) onProgress({
525
+ type: "log",
526
+ message: "小红书 SDK 报告上传失败。"
527
+ });
528
+ else if (Number.isFinite(progress) && progress >= 0 && progress <= 100) onProgress({
529
+ type: "progress",
530
+ percent: progress
531
+ });
532
+ } : void 0
533
+ });
534
+ }
535
+ };
536
+ }
537
+ //#endregion
538
+ //#region src/cli/upload/index.ts
539
+ const providers = {
540
+ weapp: prepareWechatUpload,
541
+ alipay: prepareAlipayUpload,
542
+ tt: prepareDouyinUpload,
543
+ xhs: prepareXhsUpload,
544
+ jd: prepareJdUpload,
545
+ swan: prepareSwanUpload
546
+ };
547
+ function resolveUploadPlatforms(value) {
548
+ if (value === void 0) return [void 0];
549
+ if (value === "all") return Object.keys(providers);
550
+ const platforms = value.split(",").map((name) => {
551
+ const platform = resolveMiniPlatform(name);
552
+ if (!platform || !Object.hasOwn(providers, platform)) throw new Error(`不支持上传或预览平台 "${name}",可选:${Object.keys(providers).join(", ")} 或 all。`);
553
+ return platform;
554
+ });
555
+ return [...new Set(platforms)];
556
+ }
557
+ function prepareUpload(platform, context, action = "upload") {
558
+ if (!Object.hasOwn(providers, platform)) throw new Error(`不支持上传或预览平台 "${platform}"。`);
559
+ return providers[platform](context, action);
560
+ }
561
+ //#endregion
562
+ export { terminateUploadProcess as a, terminateUploadDescendants as i, resolveUploadPlatforms as n, redactUploadSecrets as r, prepareUpload as t };
@@ -0,0 +1 @@
1
+ export {}