weapp-vite 7.3.0 → 7.4.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.
- package/README.md +104 -6
- package/dist/adapters-BwnMMIZR.mjs +2 -0
- package/dist/auto-routes.mjs +1 -1
- package/dist/cli.mjs +594 -631
- package/dist/{config-1J4rToMR.d.mts → config-Dbvj5yK7.d.mts} +332 -9
- package/dist/config.d.mts +2 -2
- package/dist/constants-WOsG3Eqd.mjs +85 -0
- package/dist/{createContext-cqr9Y4EV.mjs → createContext-UOEgeYnA.mjs} +3637 -1051
- package/dist/dashboard/vite.d.mts +9 -0
- package/dist/dashboard/vite.mjs +44 -0
- package/dist/dashboard-BzaVesmQ.mjs +558 -0
- package/dist/dashboard.d.mts +2 -0
- package/dist/dashboard.mjs +2 -0
- package/dist/docs/README.md +104 -6
- package/dist/docs/getting-started.md +50 -1
- package/dist/docs/index.md +3 -1
- package/dist/docs/upload.md +189 -0
- package/dist/docs/weapp-config.md +320 -2
- package/dist/file-D19nbDoN.mjs +2 -0
- package/dist/{file-CKB0Tn8Z.mjs → file-giE9UMZa.mjs} +3 -86
- package/dist/getInstance-CYF1vl5l.mjs +2 -0
- package/dist/index-DbqVupg0.d.mts +246 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/json.d.mts +1 -1
- package/dist/mcp.d.mts +1 -1
- package/dist/platform-DTWs5QRi.mjs +175 -0
- package/dist/test.mjs +1 -1
- package/dist/types.d.mts +2 -2
- package/dist/upload-D0RcEWrq.mjs +403 -0
- package/dist/upload-worker.d.mts +1 -0
- package/dist/upload-worker.mjs +28 -0
- package/package.json +46 -24
- package/dist/file-CvgkbGIx.mjs +0 -2
- package/dist/getInstance-CZ1s63zd.mjs +0 -2
|
@@ -7,9 +7,10 @@ import "@weapp-vite/ast/operations/onPageScroll";
|
|
|
7
7
|
import { LoggerConfig } from "@weapp-core/logger";
|
|
8
8
|
import "@weapp-vite/ast/babel";
|
|
9
9
|
import { ComponentStyleOptions, ResolveSfcBlockSrcOptions, StaticRouteValue, VueSfcBlockSignatures } from "wevu/compiler";
|
|
10
|
-
import { ConfigEnv, ConfigEnv as ConfigEnv$1, InlineConfig, InlineConfig as InlineConfig$1, Plugin as Plugin$
|
|
10
|
+
import { ConfigEnv, ConfigEnv as ConfigEnv$1, InlineConfig, InlineConfig as InlineConfig$1, Plugin, Plugin as Plugin$2, PluginOption, ResolvedConfig, ResolvedConfig as ResolvedConfig$1, UserConfig, ViteDevServer, ViteDevServer as ViteDevServer$1, build } from "vite";
|
|
11
11
|
import { LRUCache } from "lru-cache";
|
|
12
12
|
import { fdir } from "fdir";
|
|
13
|
+
import { HmrCompilerAsset as WeappCompilerHmrAsset, HmrCompilerPreparation, HmrCompilerPreparation as WeappCompilerHmrPreparation, HmrCompilerRequest, HmrCompilerRequest as WeappCompilerHmrRequest } from "@weapp-vite/hmr";
|
|
13
14
|
import { InputOption, OutputBundle, ResolvedId, RolldownBuild, RolldownOptions, RolldownOutput, RolldownOutput as RolldownOutput$1, RolldownPlugin, RolldownPluginOption, RolldownWatcher, RolldownWatcher as RolldownWatcher$1, WatchOptions as RolldownWatchOptions } from "rolldown";
|
|
14
15
|
import { Options } from "rolldown-plugin-dts";
|
|
15
16
|
import PQueue from "p-queue";
|
|
@@ -18,7 +19,7 @@ import { PluginOptions } from "vite-tsconfig-paths";
|
|
|
18
19
|
import { WrapPluginOptions } from "vite-plugin-performance";
|
|
19
20
|
import { ComputedDefinitions as ComputedDefinitions$1, MethodDefinitions as MethodDefinitions$1, PageLayoutMeta, Ref, WevuDefaults } from "wevu";
|
|
20
21
|
import { MiniProgramNetworkDefaults } from "@wevu/web-apis";
|
|
21
|
-
import { App, App as App$1, Component, Component as Component$1, GenerateType, Page, Page as Page$1, Plugin, Sitemap, Sitemap as Sitemap$1, Theme, Theme as Theme$1 } from "@weapp-core/schematics";
|
|
22
|
+
import { App, App as App$1, Component, Component as Component$1, GenerateType, Page, Page as Page$1, Plugin as Plugin$1, Sitemap, Sitemap as Sitemap$1, Theme, Theme as Theme$1 } from "@weapp-core/schematics";
|
|
22
23
|
import { WeappWebPluginOptions } from "@weapp-vite/web/plugin";
|
|
23
24
|
import { CompilerOptions } from "typescript";
|
|
24
25
|
import { CreateCompilerOptions } from "weapp-tailwindcss/core";
|
|
@@ -368,6 +369,241 @@ interface ChunksConfig {
|
|
|
368
369
|
duplicateWarningBytes?: number;
|
|
369
370
|
}
|
|
370
371
|
//#endregion
|
|
372
|
+
//#region src/types/config/projectConfig.d.ts
|
|
373
|
+
/** 保留原生工具新增字段,已声明字段仍提供类型检查与补全。 */
|
|
374
|
+
interface NativeOptions {
|
|
375
|
+
[key: string]: unknown;
|
|
376
|
+
}
|
|
377
|
+
/** 内联配置的公共入口;平台字段由 `MultiPlatformProjectConfigs` 按平台提供。 */
|
|
378
|
+
interface MultiPlatformProjectConfig extends NativeOptions {
|
|
379
|
+
appid?: string;
|
|
380
|
+
appId?: string;
|
|
381
|
+
/** 代码输出目录由构建器管理,请使用 `build.outDir`。 */
|
|
382
|
+
miniprogramRoot?: never;
|
|
383
|
+
srcMiniprogramRoot?: never;
|
|
384
|
+
smartProgramRoot?: never;
|
|
385
|
+
}
|
|
386
|
+
interface PackRule<ExtraType extends string = never> extends NativeOptions {
|
|
387
|
+
type?: 'file' | 'folder' | 'suffix' | 'prefix' | 'regexp' | ExtraType | (string & {});
|
|
388
|
+
value?: string;
|
|
389
|
+
}
|
|
390
|
+
interface PackOptions<ExtraType extends string = never> extends NativeOptions {
|
|
391
|
+
ignore?: PackRule<ExtraType>[];
|
|
392
|
+
include?: PackRule<ExtraType>[];
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* 微信开发者工具配置;不替代 Vite 的构建设置。
|
|
396
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html
|
|
397
|
+
*/
|
|
398
|
+
interface WeappProjectConfig extends MultiPlatformProjectConfig {
|
|
399
|
+
projectname?: string;
|
|
400
|
+
description?: string;
|
|
401
|
+
compileType?: 'miniprogram' | 'plugin' | (string & {});
|
|
402
|
+
libVersion?: 'latest' | 'trial' | 'widelyUsed' | (string & {});
|
|
403
|
+
packOptions?: PackOptions;
|
|
404
|
+
setting?: NativeOptions & {
|
|
405
|
+
es6?: boolean;
|
|
406
|
+
enhance?: boolean;
|
|
407
|
+
postcss?: boolean;
|
|
408
|
+
minified?: boolean;
|
|
409
|
+
minifyWXSS?: boolean;
|
|
410
|
+
minifyWXML?: boolean;
|
|
411
|
+
urlCheck?: boolean;
|
|
412
|
+
compileHotReLoad?: boolean;
|
|
413
|
+
ignoreUploadUnusedFiles?: boolean;
|
|
414
|
+
packNpmManually?: boolean;
|
|
415
|
+
uploadWithSourceMap?: boolean;
|
|
416
|
+
useCompilerPlugins?: string[] | false;
|
|
417
|
+
babelSetting?: NativeOptions & {
|
|
418
|
+
ignore?: string[];
|
|
419
|
+
outputPath?: string;
|
|
420
|
+
};
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* 支付宝 format 2 项目配置;编译选项属于 `compileOptions`,而非微信的 `setting`。
|
|
425
|
+
* @see https://opendocs.alipay.com/mini/03dbc3
|
|
426
|
+
*/
|
|
427
|
+
interface AlipayProjectConfig extends MultiPlatformProjectConfig {
|
|
428
|
+
format?: number;
|
|
429
|
+
compileType?: 'mini' | 'plugin' | (string & {});
|
|
430
|
+
uploadExclude?: string[];
|
|
431
|
+
assetsInclude?: string[];
|
|
432
|
+
compileOptions?: NativeOptions & {
|
|
433
|
+
component2?: boolean;
|
|
434
|
+
typescript?: boolean;
|
|
435
|
+
less?: boolean;
|
|
436
|
+
treeShaking?: boolean;
|
|
437
|
+
resolveAlias?: Record<string, string>;
|
|
438
|
+
globalObjectMode?: 'legacy' | 'enable' | 'fake' | (string & {});
|
|
439
|
+
transpile?: NativeOptions & {
|
|
440
|
+
script?: NativeOptions & {
|
|
441
|
+
ignore?: string[];
|
|
442
|
+
};
|
|
443
|
+
};
|
|
444
|
+
};
|
|
445
|
+
developOptions?: NativeOptions & {
|
|
446
|
+
hotReload?: boolean;
|
|
447
|
+
parallel?: boolean;
|
|
448
|
+
sourcemap?: boolean;
|
|
449
|
+
minify?: boolean;
|
|
450
|
+
skipTranspile?: boolean;
|
|
451
|
+
lazyCompile?: boolean;
|
|
452
|
+
};
|
|
453
|
+
scripts?: NativeOptions & {
|
|
454
|
+
watch?: string;
|
|
455
|
+
beforeCompile?: string;
|
|
456
|
+
beforePreview?: string;
|
|
457
|
+
beforeUpload?: string;
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* 抖音开发者工具配置,保留平台自己的字段名称和类型。
|
|
462
|
+
* @see https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/framework/general-configuration
|
|
463
|
+
*/
|
|
464
|
+
interface TtProjectConfig extends MultiPlatformProjectConfig {
|
|
465
|
+
projectname?: string;
|
|
466
|
+
disablePrivate?: boolean;
|
|
467
|
+
packOptions?: PackOptions<'glob'>;
|
|
468
|
+
setting?: NativeOptions & {
|
|
469
|
+
es6?: boolean;
|
|
470
|
+
urlCheck?: boolean;
|
|
471
|
+
autoCompile?: boolean;
|
|
472
|
+
mockUpdate?: boolean;
|
|
473
|
+
scripts?: boolean;
|
|
474
|
+
mockLogin?: boolean;
|
|
475
|
+
compileHotReLoad?: boolean;
|
|
476
|
+
nativeCompile?: boolean;
|
|
477
|
+
IDEPreviewHotRestartCache?: boolean;
|
|
478
|
+
bigPackageSizeSupport?: boolean;
|
|
479
|
+
webDetect?: boolean;
|
|
480
|
+
useCompilerPlugins?: string[];
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* 小红书公开 SDK 默认配置中的稳定字段;未列出的原生字段仍可透传。
|
|
485
|
+
* @see https://unpkg.com/xhs-mp-project@2.1.6/dist/index.js
|
|
486
|
+
*/
|
|
487
|
+
interface XhsProjectConfig extends MultiPlatformProjectConfig {
|
|
488
|
+
projectname?: string;
|
|
489
|
+
description?: string;
|
|
490
|
+
compileType?: 'miniprogram' | (string & {});
|
|
491
|
+
libVersion?: 'latest' | (string & {});
|
|
492
|
+
setting?: NativeOptions & {
|
|
493
|
+
minified?: boolean;
|
|
494
|
+
urlCheck?: boolean;
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* 百度智能小程序配置;编译参数属于 `compilation-args.common`。
|
|
499
|
+
* @see https://unpkg.com/swan-toolkit@3.23.1-beta.1/sdk/program/sdk-impl/compile-impl.js
|
|
500
|
+
*/
|
|
501
|
+
interface SwanProjectConfig extends MultiPlatformProjectConfig {
|
|
502
|
+
'compileType'?: string;
|
|
503
|
+
'developType'?: string;
|
|
504
|
+
'setting'?: NativeOptions & {
|
|
505
|
+
urlCheck?: boolean;
|
|
506
|
+
};
|
|
507
|
+
'compilation-args'?: NativeOptions & {
|
|
508
|
+
common?: NativeOptions & {
|
|
509
|
+
ignoreTransJs?: boolean;
|
|
510
|
+
ignorePrefixCss?: boolean;
|
|
511
|
+
};
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
/** 六端内联配置映射;按平台补全原生字段,同时允许原生扩展字段。 */
|
|
515
|
+
interface MultiPlatformProjectConfigs {
|
|
516
|
+
/** 微信:生成 `project.config.json`。 */
|
|
517
|
+
weapp?: WeappProjectConfig;
|
|
518
|
+
/** 支付宝:生成 `mini.project.json`。 */
|
|
519
|
+
alipay?: AlipayProjectConfig;
|
|
520
|
+
/** 抖音:生成 `project.config.json`。 */
|
|
521
|
+
tt?: TtProjectConfig;
|
|
522
|
+
/** 小红书:生成 `project.config.json`。 */
|
|
523
|
+
xhs?: XhsProjectConfig;
|
|
524
|
+
/** 京东:生成 `project.config.json`;未建立原生设置 schema 的字段保持透传。 */
|
|
525
|
+
jd?: MultiPlatformProjectConfig;
|
|
526
|
+
/** 百度:生成 `project.swan.json`。 */
|
|
527
|
+
swan?: SwanProjectConfig;
|
|
528
|
+
}
|
|
529
|
+
//#endregion
|
|
530
|
+
//#region src/types/config/wxmlTransform.d.ts
|
|
531
|
+
/** 模板属性的新值;字符串为字面量,表达式只生成绑定而不在构建端求值。 */
|
|
532
|
+
type WxmlAttributeValue = string | number | boolean | {
|
|
533
|
+
expression: string;
|
|
534
|
+
};
|
|
535
|
+
/** 源码位置使用从零开始的偏移及从一开始的行列。 */
|
|
536
|
+
interface WxmlSourceLocation {
|
|
537
|
+
readonly offset: number;
|
|
538
|
+
readonly line: number;
|
|
539
|
+
readonly column: number;
|
|
540
|
+
}
|
|
541
|
+
/** 原始属性内容不解码、不求值;无值属性的 rawValue 为 null。 */
|
|
542
|
+
interface WxmlAttribute {
|
|
543
|
+
readonly name: string;
|
|
544
|
+
readonly rawValue: string | null;
|
|
545
|
+
readonly quote: string | undefined;
|
|
546
|
+
}
|
|
547
|
+
/** 父节点只提供观察接口,不允许通过子节点改写父树。 */
|
|
548
|
+
interface WxmlElementInfo {
|
|
549
|
+
/** 当前未删除的直接子标签;不包含文本、注释或脚本模块内容。 */
|
|
550
|
+
readonly children: readonly WxmlElementInfo[];
|
|
551
|
+
readonly tagName: string;
|
|
552
|
+
readonly attributes: readonly WxmlAttribute[];
|
|
553
|
+
readonly parent: WxmlElementInfo | undefined;
|
|
554
|
+
readonly location: WxmlSourceLocation;
|
|
555
|
+
hasAttribute: (name: string) => boolean;
|
|
556
|
+
getAttribute: (name: string) => WxmlAttribute | undefined;
|
|
557
|
+
}
|
|
558
|
+
/** 当前节点的编辑句柄仅在本次 edit 调用中有效。 */
|
|
559
|
+
interface WxmlTransformNode extends WxmlElementInfo {
|
|
560
|
+
readonly children: readonly WxmlTransformNode[];
|
|
561
|
+
/** 按源码深度优先顺序遍历后代,不含自身;必须等待完成。 */
|
|
562
|
+
walk: (visitor: WxmlTransformVisitor) => Promise<void>;
|
|
563
|
+
/** 只跳过当前回调所属遍历的后代,不改变其他遍历。 */
|
|
564
|
+
skipChildren: () => void;
|
|
565
|
+
setAttribute: (name: string, value: WxmlAttributeValue) => void;
|
|
566
|
+
setBooleanAttribute: (name: string) => void;
|
|
567
|
+
renameAttribute: (from: string, to: string) => void;
|
|
568
|
+
removeAttribute: (name: string) => void;
|
|
569
|
+
renameTag: (name: string) => void;
|
|
570
|
+
remove: () => void;
|
|
571
|
+
}
|
|
572
|
+
type WxmlTransformVisitor = (node: WxmlTransformNode) => void | Promise<void>;
|
|
573
|
+
type WxmlTransformResult = string | null | void;
|
|
574
|
+
/** 函数接收当前平台的输出模板;源码阶段依赖由原有组件配置负责。 */
|
|
575
|
+
interface WxmlTransformContext {
|
|
576
|
+
readonly fileName: string;
|
|
577
|
+
readonly root: string;
|
|
578
|
+
readonly platform: MpPlatform$1;
|
|
579
|
+
readonly mode: string;
|
|
580
|
+
readonly isDev: boolean;
|
|
581
|
+
readonly subPackageRoot: string | undefined;
|
|
582
|
+
edit: (code: string, visitor: WxmlTransformVisitor) => Promise<string>;
|
|
583
|
+
addWatchFile: (file: string) => void;
|
|
584
|
+
warn: (message: string) => void;
|
|
585
|
+
error: (message: string) => never;
|
|
586
|
+
}
|
|
587
|
+
type WxmlTransform = (code: string, context: WxmlTransformContext) => WxmlTransformResult | Promise<WxmlTransformResult>;
|
|
588
|
+
//#endregion
|
|
589
|
+
//#region src/types/config/wxmlValidate.d.ts
|
|
590
|
+
/** 诊断位置对应最终输出模板;不映射回 Vue 等源文件。 */
|
|
591
|
+
interface WxmlValidationDiagnostic {
|
|
592
|
+
severity: 'warning' | 'error';
|
|
593
|
+
code?: string;
|
|
594
|
+
message: string;
|
|
595
|
+
location?: WxmlSourceLocation;
|
|
596
|
+
}
|
|
597
|
+
/** 校验只观察模板,不能通过节点改写产物。 */
|
|
598
|
+
type WxmlValidationVisitor = (node: WxmlElementInfo) => void | Promise<void>;
|
|
599
|
+
/** 所有回调观察同一份完成输出转换的模板。 */
|
|
600
|
+
interface WxmlValidationContext extends Pick<WxmlTransformContext, 'fileName' | 'root' | 'platform' | 'mode' | 'isDev' | 'subPackageRoot' | 'addWatchFile'> {
|
|
601
|
+
walk: (visitor: WxmlValidationVisitor) => Promise<void>;
|
|
602
|
+
report: (diagnostic: WxmlValidationDiagnostic) => void;
|
|
603
|
+
}
|
|
604
|
+
/** 返回值不用于转换;非 undefined 返回值会作为配置错误报告。 */
|
|
605
|
+
type WxmlValidate = (code: string, context: WxmlValidationContext) => void | Promise<void>;
|
|
606
|
+
//#endregion
|
|
371
607
|
//#region src/types/config/features.d.ts
|
|
372
608
|
/**
|
|
373
609
|
* @description 自动导入组件配置
|
|
@@ -412,7 +648,27 @@ interface WeappUniAppConfig {
|
|
|
412
648
|
*/
|
|
413
649
|
include: string[];
|
|
414
650
|
}
|
|
415
|
-
|
|
651
|
+
/** 最终模板中的标签限定属性删除规则,名称区分大小写并支持 `*`。 */
|
|
652
|
+
interface WxmlRemoveAttrRule {
|
|
653
|
+
tag: string | string[];
|
|
654
|
+
name: string | string[];
|
|
655
|
+
}
|
|
656
|
+
/** 最终模板的可选清理;对象形式只执行显式配置,不叠加预设。 */
|
|
657
|
+
interface WxmlRemoveOptions {
|
|
658
|
+
attr?: Array<string | WxmlRemoveAttrRule>;
|
|
659
|
+
tag?: string[];
|
|
660
|
+
comment?: boolean;
|
|
661
|
+
}
|
|
662
|
+
type EnhanceWxmlOptions = ScanWxmlOptions & Omit<HandleWxmlOptions, 'removeComment'> & {
|
|
663
|
+
/** @deprecated 仅保留类型兼容,未接入编译流程;请使用 `weapp.wxml.remove.comment`。 */
|
|
664
|
+
removeComment?: boolean;
|
|
665
|
+
/** `true` 删除四种测试属性及普通注释;环境由用户配置控制。 */
|
|
666
|
+
remove?: boolean | WxmlRemoveOptions;
|
|
667
|
+
/** 在最终模板清理前按顺序执行同步或异步转换。 */
|
|
668
|
+
transform?: WxmlTransform | WxmlTransform[];
|
|
669
|
+
/** 在输出插件处理后、HMR 比较及发布前检查最终模板。 */
|
|
670
|
+
validate?: WxmlValidate | WxmlValidate[];
|
|
671
|
+
};
|
|
416
672
|
/**
|
|
417
673
|
* @description WXML 扫描阶段配置
|
|
418
674
|
*/
|
|
@@ -447,7 +703,11 @@ interface MultiPlatformConfig {
|
|
|
447
703
|
enabled?: boolean;
|
|
448
704
|
projectConfigRoot?: string;
|
|
449
705
|
/**
|
|
450
|
-
* @description
|
|
706
|
+
* @description 各平台的原生项目配置;不可与 `projectConfigRoot` 同时设置。
|
|
707
|
+
*/
|
|
708
|
+
projectConfigs?: MultiPlatformProjectConfigs;
|
|
709
|
+
/**
|
|
710
|
+
* @description 多平台模式下允许参与构建/开发的目标平台集合;省略时从 `projectConfigs` 的平台键推断。
|
|
451
711
|
*/
|
|
452
712
|
targets?: 'all' | readonly MpPlatform$1[];
|
|
453
713
|
}
|
|
@@ -618,6 +878,7 @@ interface WeappWorkerConfig {
|
|
|
618
878
|
* @description Vue 模板编译配置
|
|
619
879
|
*/
|
|
620
880
|
interface WeappVueTemplateConfig {
|
|
881
|
+
/** @deprecated 仅保留类型兼容,未接入编译流程;请使用 `weapp.wxml.remove.comment`。 */
|
|
621
882
|
removeComments?: boolean;
|
|
622
883
|
simplifyWhitespace?: boolean;
|
|
623
884
|
formatWxml?: boolean | 'auto';
|
|
@@ -798,6 +1059,19 @@ interface WeappAnalyzeConfig {
|
|
|
798
1059
|
*/
|
|
799
1060
|
history?: boolean | WeappAnalyzeHistoryConfig;
|
|
800
1061
|
}
|
|
1062
|
+
/**
|
|
1063
|
+
* @description 显式执行 build --upload 或 upload 命令时使用的默认参数,不会触发自动上传。
|
|
1064
|
+
*/
|
|
1065
|
+
interface WeappUploadConfig {
|
|
1066
|
+
/**
|
|
1067
|
+
* 上传版本;CLI --uv 优先,未配置时读取 package.json.version。
|
|
1068
|
+
*/
|
|
1069
|
+
version?: string;
|
|
1070
|
+
/**
|
|
1071
|
+
* 上传说明;CLI --desc 优先,未配置时使用项目名称与版本。
|
|
1072
|
+
*/
|
|
1073
|
+
desc?: string;
|
|
1074
|
+
}
|
|
801
1075
|
/**
|
|
802
1076
|
* @description weapp-vite 主配置
|
|
803
1077
|
*/
|
|
@@ -853,6 +1127,11 @@ interface WeappViteConfig {
|
|
|
853
1127
|
* analyze 报告配置。
|
|
854
1128
|
*/
|
|
855
1129
|
analyze?: WeappAnalyzeConfig;
|
|
1130
|
+
/**
|
|
1131
|
+
* 上传默认参数。仅在显式执行 build --upload 或 upload 且构建与产物校验成功后上传;
|
|
1132
|
+
* 普通 build、dev/HMR、preview 和上传 dry-run 不触发上传。
|
|
1133
|
+
*/
|
|
1134
|
+
upload?: WeappUploadConfig;
|
|
856
1135
|
/**
|
|
857
1136
|
* 局部构建范围。默认不启用,启用后只构建主包和指定分包。
|
|
858
1137
|
*/
|
|
@@ -984,6 +1263,8 @@ interface WeappCompilerOutputRequest {
|
|
|
984
1263
|
state?: unknown;
|
|
985
1264
|
}
|
|
986
1265
|
interface WeappCompilerPluginController {
|
|
1266
|
+
/** 同批次资产与脚本必须使用此调用持有的固定状态。 */
|
|
1267
|
+
prepareHmr?: (request: HmrCompilerRequest) => HmrCompilerPreparation | Promise<HmrCompilerPreparation>;
|
|
987
1268
|
buildStart?: () => void | Promise<void>;
|
|
988
1269
|
claimSource?: (request: WeappCompilerSourceRequest) => boolean | WeappCompilerSourceClaim | Promise<boolean | WeappCompilerSourceClaim | null> | null;
|
|
989
1270
|
transformSource?: (request: WeappCompilerSourceRequest) => WeappCompilerTransformResult | null | Promise<WeappCompilerTransformResult | null>;
|
|
@@ -1481,6 +1762,7 @@ interface ResolvedMultiPlatformConfig {
|
|
|
1481
1762
|
enabled: boolean;
|
|
1482
1763
|
projectConfigRoot: string;
|
|
1483
1764
|
targets: readonly MpPlatform$1[];
|
|
1765
|
+
projectConfigs?: MultiPlatformProjectConfigs;
|
|
1484
1766
|
}
|
|
1485
1767
|
//#endregion
|
|
1486
1768
|
//#region src/utils/json.d.ts
|
|
@@ -1701,6 +1983,16 @@ interface GlassEaselAnalysisFact {
|
|
|
1701
1983
|
diagnostics: Map<string, GlassEaselDiagnostic>;
|
|
1702
1984
|
sourceIds: Set<string>;
|
|
1703
1985
|
}
|
|
1986
|
+
interface GlassEaselAnalyzeResult {
|
|
1987
|
+
detected: boolean;
|
|
1988
|
+
minimumBaseLibrary: '3.8.12';
|
|
1989
|
+
migrationGuide: string;
|
|
1990
|
+
diagnostics: GlassEaselDiagnostic[];
|
|
1991
|
+
summary: {
|
|
1992
|
+
errors: number;
|
|
1993
|
+
warnings: number;
|
|
1994
|
+
};
|
|
1995
|
+
}
|
|
1704
1996
|
interface GlassEaselTemplateFinding {
|
|
1705
1997
|
code: Extract<GlassEaselDiagnosticCode, 'GE002' | 'GE003' | 'GE004'>;
|
|
1706
1998
|
severity: GlassEaselDiagnosticSeverity;
|
|
@@ -1758,6 +2050,21 @@ interface WxmlToken {
|
|
|
1758
2050
|
declare function scanWxml(wxml: string | Buffer, options?: ScanWxmlOptions): WxmlToken;
|
|
1759
2051
|
type ScanWxmlResult = ReturnType<typeof scanWxml>;
|
|
1760
2052
|
//#endregion
|
|
2053
|
+
//#region src/wxml/processing/registry.d.ts
|
|
2054
|
+
type TemplateDependencies = Map<string, Set<string>>;
|
|
2055
|
+
type ProcessingStage = 'transform' | 'validate';
|
|
2056
|
+
interface WxmlDependencyRegistry {
|
|
2057
|
+
dependencies: Map<string, TemplateDependencies>;
|
|
2058
|
+
pending: Map<symbol, {
|
|
2059
|
+
scope: string;
|
|
2060
|
+
stage: ProcessingStage;
|
|
2061
|
+
templates: TemplateDependencies;
|
|
2062
|
+
}>;
|
|
2063
|
+
failed: Map<string, TemplateDependencies>;
|
|
2064
|
+
references: Map<string, number>;
|
|
2065
|
+
listeners: Set<(files: string[]) => void>;
|
|
2066
|
+
}
|
|
2067
|
+
//#endregion
|
|
1761
2068
|
//#region src/runtime/autoImport/types.d.ts
|
|
1762
2069
|
interface LocalAutoImportMatch {
|
|
1763
2070
|
kind: 'local';
|
|
@@ -1799,6 +2106,7 @@ interface LibEntryState {
|
|
|
1799
2106
|
relativeBase: string;
|
|
1800
2107
|
}
|
|
1801
2108
|
interface RuntimeState {
|
|
2109
|
+
wxmlProcessing: WxmlDependencyRegistry;
|
|
1802
2110
|
glassEasel: {
|
|
1803
2111
|
analysisByOwner: Map<string, GlassEaselAnalysisFact>;
|
|
1804
2112
|
warnedDiagnostics: Set<string>;
|
|
@@ -1841,6 +2149,8 @@ interface RuntimeState {
|
|
|
1841
2149
|
npmBuilt: boolean;
|
|
1842
2150
|
independent: {
|
|
1843
2151
|
outputs: Map<string, RolldownOutput>;
|
|
2152
|
+
watchFiles: Map<string, Set<string>>;
|
|
2153
|
+
watchListeners: Set<(files: string[]) => void>;
|
|
1844
2154
|
pendingOutputs: Promise<RolldownOutput>[];
|
|
1845
2155
|
};
|
|
1846
2156
|
output: {
|
|
@@ -1924,6 +2234,12 @@ interface RuntimeState {
|
|
|
1924
2234
|
snapshotResolveMs?: number;
|
|
1925
2235
|
snapshotBuildMs?: number;
|
|
1926
2236
|
writeMs?: number;
|
|
2237
|
+
finalizePrepareMs?: number;
|
|
2238
|
+
finalizeTemplateMs?: number;
|
|
2239
|
+
finalizePublishMs?: number;
|
|
2240
|
+
publicationValidateMs?: number;
|
|
2241
|
+
publicationIndependentMs?: number;
|
|
2242
|
+
publicationPruneMs?: number;
|
|
1927
2243
|
watchToDirtyMs?: number;
|
|
1928
2244
|
emitMs?: number;
|
|
1929
2245
|
sharedChunkResolveMs?: number;
|
|
@@ -1982,6 +2298,12 @@ interface RuntimeState {
|
|
|
1982
2298
|
snapshotResolveMs?: number;
|
|
1983
2299
|
snapshotBuildMs?: number;
|
|
1984
2300
|
writeMs?: number;
|
|
2301
|
+
finalizePrepareMs?: number;
|
|
2302
|
+
finalizeTemplateMs?: number;
|
|
2303
|
+
finalizePublishMs?: number;
|
|
2304
|
+
publicationValidateMs?: number;
|
|
2305
|
+
publicationIndependentMs?: number;
|
|
2306
|
+
publicationPruneMs?: number;
|
|
1985
2307
|
watchToDirtyMs?: number;
|
|
1986
2308
|
emitMs?: number;
|
|
1987
2309
|
sharedChunkResolveMs?: number;
|
|
@@ -2037,7 +2359,7 @@ interface RuntimeState {
|
|
|
2037
2359
|
independentSubPackageMap: Map<string, SubPackageMetaValue>;
|
|
2038
2360
|
warnedMessages: Set<string>;
|
|
2039
2361
|
appEntry?: AppEntry;
|
|
2040
|
-
pluginJson?: Plugin;
|
|
2362
|
+
pluginJson?: Plugin$1;
|
|
2041
2363
|
pluginJsonPath?: string;
|
|
2042
2364
|
isDirty: boolean;
|
|
2043
2365
|
independentDirtyRoots: Set<string>;
|
|
@@ -2058,7 +2380,7 @@ interface RuntimeState {
|
|
|
2058
2380
|
//#region src/runtime/scanPlugin/service/index.d.ts
|
|
2059
2381
|
interface ScanService {
|
|
2060
2382
|
appEntry?: AppEntry;
|
|
2061
|
-
pluginJson?: Plugin;
|
|
2383
|
+
pluginJson?: Plugin$1;
|
|
2062
2384
|
pluginJsonPath?: string;
|
|
2063
2385
|
readonly mainPackageStyleEntries: StyleEntry[] | undefined;
|
|
2064
2386
|
subPackageMap: Map<string, SubPackageMetaValue>;
|
|
@@ -2165,7 +2487,8 @@ type AutoRoutesFileEvent = ChangeEvent | 'rename';
|
|
|
2165
2487
|
//#region src/runtime/autoRoutesPlugin/service.d.ts
|
|
2166
2488
|
type PageDeclarationSourceResolver = NonNullable<ScanRoutesOptions['resolvePageDeclarationSource']>;
|
|
2167
2489
|
interface AutoRoutesService {
|
|
2168
|
-
|
|
2490
|
+
/** 活动构建解析器只参与本次刷新,不替换服务持有的长期解析器。 */
|
|
2491
|
+
ensureFresh: (resolve?: PageDeclarationSourceResolver) => Promise<void>;
|
|
2169
2492
|
markDirty: () => void;
|
|
2170
2493
|
getSnapshot: () => AutoRoutes;
|
|
2171
2494
|
getReference: () => AutoRoutes;
|
|
@@ -2180,7 +2503,7 @@ interface AutoRoutesService {
|
|
|
2180
2503
|
isPageSource: (filePath: string) => boolean;
|
|
2181
2504
|
/** 判断文件是否属于逻辑页面声明或其外部脚本依赖。 */
|
|
2182
2505
|
isPageDeclarationSource: (filePath: string) => boolean;
|
|
2183
|
-
/**
|
|
2506
|
+
/** 注册服务持有的长期解析器;构建钩子通过 ensureFresh 参数提供临时解析器。 */
|
|
2184
2507
|
setPageDeclarationSourceResolver: (resolve?: PageDeclarationSourceResolver) => void;
|
|
2185
2508
|
handleFileChange: (filePath: string, event?: AutoRoutesFileEvent) => Promise<boolean>;
|
|
2186
2509
|
isInitialized: () => boolean;
|
|
@@ -2264,4 +2587,4 @@ declare module 'vite' {
|
|
|
2264
2587
|
*/
|
|
2265
2588
|
declare function defineConfig<T extends UserConfigExport>(config: T): T;
|
|
2266
2589
|
//#endregion
|
|
2267
|
-
export {
|
|
2590
|
+
export { WeappCompilerHmrRequest as $, NpmMainPackageConfig as $n, WeappSubPackageConfig as $t, PluginOption as A, DeprecatedInlineDynamicImports as An, WeappWebConfig as Ar, ScanWxmlOptions as At, ViteDevServer$1 as B, GenerateTemplateFileSource as Bn, WeappVitePlatform as Br, WeappInjectRequestGlobalsTarget as Bt, GlassEaselAnalyzeResult as C, Alias as Cn, WeappLibInternalDtsOptions as Cr, WeappViteConfig as Ct, InlineConfig$1 as D, ChunksConfig as Dn, WeappManagedServerTsconfigConfig as Dr, EnhanceWxmlOptions as Dt, ConfigEnv$1 as E, BuildNpmPackageMeta as En, WeappManagedNodeTsconfigConfig as Er, EnhanceOptions as Et, RolldownOutput$1 as F, GenerateOptions as Fn, isWeappViteHost as Fr, WeappAutoRoutesIncludePattern as Ft, Entry as G, JsonConfig as Gn, WebPlatform as Gr, WeappNpmConfig as Gt, AppEntry as H, GenerateTemplateScope as Hn, WeappViteTargetDescriptor as Hr, WeappInjectWebRuntimeGlobalsConfig as Ht, RolldownPlugin as I, GenerateTemplate as In, resolveWeappViteHostMeta as Ir, WeappBuildScopeConfig as It, ComponentsMap as J, JsonMergeStage as Jn, isWebPlatform as Jr, WeappReactCompilerConfig as Jt, EntryJsonFragment as K, JsonMergeContext as Kn, getSupportedWeappVitePlatforms as Kr, WeappPreloadNetwork as Kt, RolldownPluginOption as L, GenerateTemplateContext as Ln, ResolveWeappViteTargetOptions as Lr, WeappBuildScopeObjectConfig as Lt, ResolvedConfig$1 as M, GenerateExtensionsOptions as Mn, WeappViteHostMeta as Mr, WeappAppPreludeMode as Mt, RolldownBuild as N, GenerateFileType as Nn, applyWeappViteHostMeta as Nr, WeappAutoRoutesConfig as Nt, MethodDefinitions$1 as O, CopyGlobs as On, WeappManagedSharedTsconfigConfig as Or, HandleWxmlOptions as Ot, RolldownOptions as P, GenerateFilenamesOptions as Pn, createWeappViteHostMeta as Pr, WeappAutoRoutesInclude as Pt, WeappCompilerHmrPreparation as Q, NpmDependencyPattern as Qn, WeappRouteRules as Qt, RolldownWatchOptions as R, GenerateTemplateEntry as Rn, ResolvedWeappViteTarget as Rr, WeappHmrConfig as Rt, CompilerContext as S, MultiPlatformProjectConfigs as Sn, WeappLibFileName as Sr, WeappUploadConfig as St, ComputedDefinitions$1 as T, AlipayNpmMode as Tn, WeappManagedAppTsconfigConfig as Tr, AutoImportComponentsOption as Tt, BaseEntry as U, GenerateTemplatesConfig as Un, WeappViteTargetInput as Ur, WeappInjectWebRuntimeGlobalsTarget as Ut, BindingErrorLike as V, GenerateTemplateInlineSource as Vn, WeappViteRuntime as Vr, WeappInjectWeapiConfig as Vt, ComponentEntry as W, JsFormat as Wn, WeappViteTargetKind as Wr, WeappMcpConfig as Wt, WxmlDep as X, MpPlatform$1 as Xn, WeappRequestRuntimeConfig as Xt, ScanComponentItem as Y, JsonMergeStrategy as Yn, resolveWeappViteTarget as Yr, WeappReactConfig as Yt, WeappCompilerHmrAsset as Z, NpmBuildOptions as Zn, WeappRouteRule as Zt, definePageJson as _, WxmlTransformContext as _n, SubPackageStyleScope as _r, WeappAnalyzeHistoryConfig as _t, UserConfigFnNoEnvPlain as a, WeappWorkerConfig as an, SharedChunkDynamicImports as ar, WeappCompilerPluginFactory as at, ChangeEvent as b, WxmlTransformVisitor as bn, WeappLibDtsOptions as br, WeappForwardConsoleLogLevel as bt, UserConfigFnPromise as c, WxmlValidate as cn, SharedChunkStrategy as cr, WeappCompilerResourceKind as ct, Component$1 as d, WxmlValidationVisitor as dn, StyleEntry as dr, WeappCompilerTransformResult as dt, WeappUniAppConfig as en, NpmPackageFilesConfig as er, WeappCompilerOutputRequest as et, Page$1 as f, WxmlAttribute as fn, StyleScope as fr, ProjectConfig as ft, defineComponentJson as g, WxmlTransform as gn, SubPackageStyleEntry as gr, WeappAnalyzeConfig as gt, defineAppJson as h, WxmlSourceLocation as hn, SubPackageStyleConfigObject as hr, WeappAnalyzeBudgetConfig as ht, UserConfigFnNoEnv as i, WeappWevuConfig as in, ResolvedAlias as ir, WeappCompilerPluginController as it, Ref as j, GenerateDirsOptions as jn, WEAPP_VITE_HOST_NAME as jr, WeappAppPreludeConfig as jt, Plugin$2 as k, CopyOptions as kn, WeappManagedTypeScriptConfig as kr, MultiPlatformConfig as kt, defineConfig as l, WxmlValidationContext as ln, StyleConfigEntry as lr, WeappCompilerSourceClaim as lt, Theme$1 as m, WxmlElementInfo as mn, SubPackageStyleConfigEntry as mr, UserConfig$2 as mt, UserConfigExport as n, WeappVueTemplateConfig as nn, NpmStrategy as nr, WeappCompilerPluginCapabilities as nt, UserConfigFnObject as o, WxmlRemoveAttrRule as on, SharedChunkMode as or, WeappCompilerPluginOption as ot, Sitemap$1 as p, WxmlAttributeValue as pn, SubPackage as pr, SubPackageMetaValue as pt, PageEntry as q, JsonMergeFunction as qn, getSupportedWeappViteTargetDescriptors as qr, WeappPreloadRule as qt, UserConfigFn as r, WeappWebRuntimeConfig as rn, NpmSubPackageConfig as rr, WeappCompilerPluginContext as rt, UserConfigFnObjectPlain as s, WxmlRemoveOptions as sn, SharedChunkOverride as sr, WeappCompilerPluginPhase as st, UserConfig$1 as t, WeappVueConfig as tn, NpmPluginPackageConfig as tr, WeappCompilerPlugin as tt, App$1 as u, WxmlValidationDiagnostic as un, StyleConfigObject as ur, WeappCompilerSourceRequest as ut, defineSitemapJson as v, WxmlTransformNode as vn, WeappLibComponentJson as vr, WeappDebugConfig as vt, LoadConfigOptions as w, AliasOptions as wn, WeappLibVueTscOptions as wr, AutoImportComponents as wt, WeappVitePluginApi as x, MultiPlatformProjectConfig as xn, WeappLibEntryContext as xr, WeappTailwindcssOptions as xt, defineThemeJson as y, WxmlTransformResult as yn, WeappLibConfig as yr, WeappForwardConsoleConfig as yt, RolldownWatcher$1 as z, GenerateTemplateFactory as zn, WEB_PLATFORM_ALIASES as zr, WeappInjectRequestGlobalsConfig as zt };
|
package/dist/config.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as WeappCompilerHmrRequest, Ct as WeappViteConfig, Fr as isWeappViteHost, Ir as resolveWeappViteHostMeta, Mr as WeappViteHostMeta, Nr as applyWeappViteHostMeta, Pr as createWeappViteHostMeta, Q as WeappCompilerHmrPreparation, Sn as MultiPlatformProjectConfigs, Vr as WeappViteRuntime, Z as WeappCompilerHmrAsset, _ as definePageJson, _n as WxmlTransformContext, a as UserConfigFnNoEnvPlain, bn as WxmlTransformVisitor, c as UserConfigFnPromise, cn as WxmlValidate, d as Component, dn as WxmlValidationVisitor, f as Page, fn as WxmlAttribute, g as defineComponentJson, gn as WxmlTransform, h as defineAppJson, hn as WxmlSourceLocation, i as UserConfigFnNoEnv, it as WeappCompilerPluginController, jr as WEAPP_VITE_HOST_NAME, l as defineConfig, ln as WxmlValidationContext, m as Theme, mn as WxmlElementInfo, n as UserConfigExport, nt as WeappCompilerPluginCapabilities, o as UserConfigFnObject, on as WxmlRemoveAttrRule, ot as WeappCompilerPluginOption, p as Sitemap, pn as WxmlAttributeValue, r as UserConfigFn, rt as WeappCompilerPluginContext, s as UserConfigFnObjectPlain, sn as WxmlRemoveOptions, t as UserConfig, tt as WeappCompilerPlugin, u as App, un as WxmlValidationDiagnostic, v as defineSitemapJson, vn as WxmlTransformNode, xn as MultiPlatformProjectConfig, y as defineThemeJson, yn as WxmlTransformResult } from "./config-Dbvj5yK7.mjs";
|
|
2
2
|
import { t as WeappI18nConfig } from "./types-CgZn5X6j.mjs";
|
|
3
|
-
export { type App, type Component, type Page, type Sitemap, type Theme, UserConfig, UserConfigExport, UserConfigFn, UserConfigFnNoEnv, UserConfigFnNoEnvPlain, UserConfigFnObject, UserConfigFnObjectPlain, UserConfigFnPromise, WEAPP_VITE_HOST_NAME, type WeappCompilerPlugin, type WeappCompilerPluginCapabilities, type WeappCompilerPluginContext, type WeappCompilerPluginController, type WeappCompilerPluginOption, type WeappI18nConfig, type WeappViteConfig, WeappViteHostMeta, type WeappViteRuntime, applyWeappViteHostMeta, createWeappViteHostMeta, defineAppJson, defineComponentJson, defineConfig, definePageJson, defineSitemapJson, defineThemeJson, isWeappViteHost, resolveWeappViteHostMeta };
|
|
3
|
+
export { type App, type Component, type MultiPlatformProjectConfig, type MultiPlatformProjectConfigs, type Page, type Sitemap, type Theme, UserConfig, UserConfigExport, UserConfigFn, UserConfigFnNoEnv, UserConfigFnNoEnvPlain, UserConfigFnObject, UserConfigFnObjectPlain, UserConfigFnPromise, WEAPP_VITE_HOST_NAME, type WeappCompilerHmrAsset, type WeappCompilerHmrPreparation, type WeappCompilerHmrRequest, type WeappCompilerPlugin, type WeappCompilerPluginCapabilities, type WeappCompilerPluginContext, type WeappCompilerPluginController, type WeappCompilerPluginOption, type WeappI18nConfig, type WeappViteConfig, WeappViteHostMeta, type WeappViteRuntime, type WxmlAttribute, type WxmlAttributeValue, type WxmlElementInfo, type WxmlRemoveAttrRule, type WxmlRemoveOptions, type WxmlSourceLocation, type WxmlTransform, type WxmlTransformContext, type WxmlTransformNode, type WxmlTransformResult, type WxmlTransformVisitor, type WxmlValidate, type WxmlValidationContext, type WxmlValidationDiagnostic, type WxmlValidationVisitor, applyWeappViteHostMeta, createWeappViteHostMeta, defineAppJson, defineComponentJson, defineConfig, definePageJson, defineSitemapJson, defineThemeJson, isWeappViteHost, resolveWeappViteHostMeta };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { t as MINI_PROGRAM_PLATFORM_ADAPTERS } from "./adapters-BwnMMIZR.mjs";
|
|
2
|
+
//#region src/platforms/sourceAssets.ts
|
|
3
|
+
const PORTABLE_TEMPLATE_EXTENSIONS = ["wxml", "html"];
|
|
4
|
+
const PORTABLE_STYLE_EXTENSIONS = [
|
|
5
|
+
"wxss",
|
|
6
|
+
"css",
|
|
7
|
+
"scss",
|
|
8
|
+
"less",
|
|
9
|
+
"sass",
|
|
10
|
+
"styl"
|
|
11
|
+
];
|
|
12
|
+
function uniqueExtensions(extensions) {
|
|
13
|
+
return Array.from(new Set(extensions.filter((extension) => Boolean(extension))));
|
|
14
|
+
}
|
|
15
|
+
const ALL_NATIVE_TEMPLATE_EXTENSIONS = uniqueExtensions(MINI_PROGRAM_PLATFORM_ADAPTERS.map((adapter) => adapter.outputExtensions.wxml));
|
|
16
|
+
const ALL_NATIVE_STYLE_EXTENSIONS = uniqueExtensions(MINI_PROGRAM_PLATFORM_ADAPTERS.map((adapter) => adapter.outputExtensions.wxss));
|
|
17
|
+
const ALL_NATIVE_STYLE_RESOLVER_EXTENSIONS = ALL_NATIVE_STYLE_EXTENSIONS.filter((extension) => extension !== "css");
|
|
18
|
+
const ALL_SOURCE_TEMPLATE_EXTENSIONS = uniqueExtensions([...PORTABLE_TEMPLATE_EXTENSIONS, ...ALL_NATIVE_TEMPLATE_EXTENSIONS]);
|
|
19
|
+
const ALL_SOURCE_STYLE_EXTENSIONS = uniqueExtensions([...PORTABLE_STYLE_EXTENSIONS, ...ALL_NATIVE_STYLE_EXTENSIONS]);
|
|
20
|
+
function getAdapter(platform) {
|
|
21
|
+
return platform ? MINI_PROGRAM_PLATFORM_ADAPTERS.find((adapter) => adapter.id === platform) : void 0;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* 返回当前平台的模板源码选择顺序。
|
|
25
|
+
* 原生平台后缀优先,便携源码后缀作为兼容回退。
|
|
26
|
+
*/
|
|
27
|
+
function getSourceTemplateExtensions(platform) {
|
|
28
|
+
const nativeExtension = getAdapter(platform)?.outputExtensions.wxml;
|
|
29
|
+
return platform ? uniqueExtensions([nativeExtension, ...PORTABLE_TEMPLATE_EXTENSIONS]) : ALL_SOURCE_TEMPLATE_EXTENSIONS;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 返回当前平台的样式源码选择顺序。
|
|
33
|
+
* 原生平台后缀优先,预处理器和便携样式后缀继续可用。
|
|
34
|
+
*/
|
|
35
|
+
function getSourceStyleExtensions(platform) {
|
|
36
|
+
const nativeExtension = getAdapter(platform)?.outputExtensions.wxss;
|
|
37
|
+
return platform ? uniqueExtensions([nativeExtension, ...PORTABLE_STYLE_EXTENSIONS]) : ALL_SOURCE_STYLE_EXTENSIONS;
|
|
38
|
+
}
|
|
39
|
+
function isSourceTemplateExtension(extension) {
|
|
40
|
+
const normalized = extension.startsWith(".") ? extension.slice(1) : extension;
|
|
41
|
+
return getSourceTemplateExtensions().includes(normalized);
|
|
42
|
+
}
|
|
43
|
+
function isSourceStyleExtension(extension) {
|
|
44
|
+
const normalized = extension.startsWith(".") ? extension.slice(1) : extension;
|
|
45
|
+
return getSourceStyleExtensions().includes(normalized);
|
|
46
|
+
}
|
|
47
|
+
function isNativeTemplateSource(filePath, platform) {
|
|
48
|
+
const nativeExtension = getAdapter(platform)?.outputExtensions.wxml;
|
|
49
|
+
return Boolean(nativeExtension && filePath.endsWith(`.${nativeExtension}`));
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/constants.ts
|
|
53
|
+
const VERSION = "__VERSION__";
|
|
54
|
+
/**
|
|
55
|
+
* 源代码支持的 js 文件格式
|
|
56
|
+
*/
|
|
57
|
+
const jsExtensions = ["ts", "js"];
|
|
58
|
+
const scriptExtensions = [
|
|
59
|
+
"ts",
|
|
60
|
+
"js",
|
|
61
|
+
"tsx",
|
|
62
|
+
"jsx"
|
|
63
|
+
];
|
|
64
|
+
/**
|
|
65
|
+
* 源代码支持的 vue 文件格式
|
|
66
|
+
*/
|
|
67
|
+
const vueExtensions = ["vue"];
|
|
68
|
+
/**
|
|
69
|
+
* 源代码支持的 json 文件格式
|
|
70
|
+
*/
|
|
71
|
+
const configExtensions = [
|
|
72
|
+
"jsonc",
|
|
73
|
+
"json",
|
|
74
|
+
...jsExtensions.map((x) => `json.${x}`)
|
|
75
|
+
];
|
|
76
|
+
/**
|
|
77
|
+
* 源代码支持的 css 文件格式
|
|
78
|
+
*/
|
|
79
|
+
const supportedCssLangs = ALL_SOURCE_STYLE_EXTENSIONS;
|
|
80
|
+
/**
|
|
81
|
+
* 源代码支持的 wxml 文件格式
|
|
82
|
+
*/
|
|
83
|
+
const templateExtensions = ALL_SOURCE_TEMPLATE_EXTENSIONS;
|
|
84
|
+
//#endregion
|
|
85
|
+
export { supportedCssLangs as a, ALL_NATIVE_STYLE_RESOLVER_EXTENSIONS as c, isNativeTemplateSource as d, isSourceStyleExtension as f, scriptExtensions as i, getSourceStyleExtensions as l, configExtensions as n, templateExtensions as o, isSourceTemplateExtension as p, jsExtensions as r, vueExtensions as s, VERSION as t, getSourceTemplateExtensions as u };
|