@cocos/cocos-cli-types 0.0.1-alpha.17.4 → 0.0.1-alpha.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/builder.d.ts +784 -2
  2. package/package.json +1 -1
package/builder.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  /// <reference types="node" />
2
2
 
3
- import { EventEmitter } from 'events';
3
+ import EventEmitter from 'events';
4
+ import { EventEmitter as EventEmitter_2 } from 'stream';
4
5
  import type { PluginItem } from '@babel/core';
6
+ import { SpriteFrame } from 'cc';
5
7
 
6
8
  declare interface AcornNode {
7
9
  end: number;
@@ -447,7 +449,7 @@ export declare interface BuildCheckResult {
447
449
  level: IConsoleType;
448
450
  }
449
451
 
450
- declare interface BuildConfiguration {
452
+ export declare interface BuildConfiguration {
451
453
  common: IBuildCommonOptions;
452
454
  platforms: {
453
455
  'web-desktop'?: WebDesktopBuildOptions & OverwriteProjectSettings;
@@ -460,6 +462,99 @@ declare interface BuildConfiguration {
460
462
  textureCompressConfig: UserCompressConfig;
461
463
  }
462
464
 
465
+ /**
466
+ * 资源管理器,主要负责资源的缓存查询缓存等
467
+ * 所有 __ 开头的属性方法都不对外公开
468
+ */
469
+ declare class BuilderAssetCache implements BuilderCache {
470
+ readonly scenes: Array<IBuildSceneItem>;
471
+ readonly scriptUuids: Array<string>;
472
+ assetUuids: Array<string>;
473
+ private readonly instanceMap;
474
+ private readonly _task?;
475
+ constructor(task?: IBuilder);
476
+ /**
477
+ * 初始化
478
+ */
479
+ init(): Promise<void>;
480
+ /**
481
+ * 查询某个 uuid 是否存在
482
+ * @param uuid
483
+ * @returns
484
+ */
485
+ hasAsset(uuid: string): Promise<boolean>;
486
+ /**
487
+ * 添加一个资源到缓存
488
+ * @param asset
489
+ */
490
+ addAsset(asset: IAsset, type?: string): void;
491
+ /**
492
+ * 删除一个资源的缓存
493
+ */
494
+ removeAsset(uuid: string, type?: string): void;
495
+ /**
496
+ * 查询指定 uuid 的资源信息
497
+ * @param uuid
498
+ */
499
+ getAssetInfo(uuid: string): IAssetInfo;
500
+ /**
501
+ * 添加或修改一个实例化对象到缓存
502
+ * @param instance
503
+ */
504
+ addInstance(instance: any): void;
505
+ /**
506
+ * 删除一个资源的缓存
507
+ * @param uuid
508
+ */
509
+ clearAsset(uuid: string): void;
510
+ /**
511
+ * 查询一个资源的 meta 数据
512
+ * @param uuid
513
+ */
514
+ getMeta(uuid: string): Promise<any>;
515
+ addMeta(uuid: string, meta: any): Promise<void>;
516
+ /**
517
+ * 获取指定 uuid 资源的依赖资源 uuid 列表
518
+ * @param uuid
519
+ */
520
+ getDependUuids(uuid: string): Promise<readonly string[]>;
521
+ /**
522
+ * 深度获取指定 uuid 资源的依赖资源 uuid 列表
523
+ * @param uuid
524
+ */
525
+ getDependUuidsDeep(uuid: string): Promise<string[]>;
526
+ /**
527
+ *
528
+ * 获取指定 uuid 资源在 library 内的序列化 JSON 内容
529
+ * @param uuid
530
+ */
531
+ getLibraryJSON(uuid: string): Promise<any>;
532
+ /**
533
+ * 获取指定 uuid 资源的重新序列化后的 JSON 内容(最终输出)
534
+ * @param uuid
535
+ * @param options
536
+ */
537
+ getSerializedJSON(uuid: string, options: ISerializedOptions): Promise<any>;
538
+ /**
539
+ * 直接输出某个资源序列化 JSON 到指定包内
540
+ * @param uuid
541
+ * @param destDir
542
+ * @param options
543
+ */
544
+ outputAssetJson(uuid: string, destDir: string, options: IInternalBuildOptions): Promise<void>;
545
+ /**
546
+ * 循环一种数据
547
+ * @param type
548
+ * @param handle
549
+ */
550
+ forEach(type: string, handle: Function): Promise<undefined>;
551
+ /**
552
+ * 查询一个资源反序列化后的实例
553
+ * @param uuid
554
+ */
555
+ getInstance(uuid: string): Promise<any>;
556
+ }
557
+
463
558
  export declare interface BuilderCache {
464
559
  readonly scenes: Array<IBuildSceneItem>;
465
560
  readonly scriptUuids: Array<string>;
@@ -515,6 +610,163 @@ export declare namespace BuildPlugin {
515
610
  export type Unload = () => Promise<void> | void;
516
611
  }
517
612
 
613
+ declare class BuildResult implements IBuildResult {
614
+ private readonly __task;
615
+ settings?: ISettings;
616
+ dest: string;
617
+ get paths(): IBuildPaths;
618
+ constructor(task: IBuilder);
619
+ /**
620
+ * 指定的 uuid 资源是否包含在构建资源中
621
+ */
622
+ containsAsset(uuid: string): boolean;
623
+ /**
624
+ * 获取指定 uuid 原始资源的存放路径(不包括序列化 json)
625
+ * 自动图集的小图 uuid 和自动图集的 uuid 都将会查询到合图大图的生成路径
626
+ * 实际返回多个路径的情况:查询 uuid 为自动图集资源,且对应图集生成多张大图,纹理压缩会有多个图片格式路径
627
+ */
628
+ getRawAssetPaths(uuid: string): IRawAssetPathInfo[];
629
+ /**
630
+ * 获取指定 uuid 资源的路径相关信息
631
+ * @return Array<{raw?: string | string[]; import?: string; groupIndex?: number;}>
632
+ * @return.raw: 该资源源文件的实际存储位置,存在多个为数组,不存在则为空
633
+ * @return.import: 该资源序列化数据的实际存储位置,不存在为空,可能是 .bin 或者 .json 格式
634
+ * @return.groupIndex: 若该资源的序列化数据在某个分组内,这里标识在分组内的 index,不存在为空
635
+ */
636
+ getAssetPathInfo(uuid: string): IAssetPathInfo[];
637
+ /**
638
+ * @deprecated please use getImportAssetPaths instead
639
+ * @param uuid
640
+ */
641
+ getJsonPathInfo(uuid: string): IImportAssetPathInfo[];
642
+ /**
643
+ * 指定 uuid 资源的序列化信息在构建后的信息
644
+ * @param uuid
645
+ */
646
+ getImportAssetPaths(uuid: string): IImportAssetPathInfo[];
647
+ }
648
+
649
+ declare class BuildStageTask extends BuildTaskBase implements IBuildStageTask {
650
+ options: IBuildOptionBase;
651
+ hooksInfo: IBuildHooksInfo;
652
+ private root;
653
+ hookMap: Record<string, string>;
654
+ constructor(id: string, config: IBuildStageConfig);
655
+ run(): Promise<boolean>;
656
+ break(reason: string): void;
657
+ handleHook(func: Function, internal: boolean): Promise<void>;
658
+ saveOptions(): Promise<void>;
659
+ }
660
+
661
+ declare class BuildTask extends BuildTaskBase implements IBuilder {
662
+ cache: BuilderAssetCache;
663
+ result: InternalBuildResult_2;
664
+ buildTemplate: BuildTemplate;
665
+ buildResult?: BuildResult;
666
+ options: IInternalBuildOptions;
667
+ hooksInfo: IBuildHooksInfo;
668
+ taskManager: TaskManager;
669
+ private mainTaskWeight;
670
+ static isCommandBuild: boolean;
671
+ private currentStageTask?;
672
+ bundleManager: BundleManager;
673
+ hookMap: Record<IPluginHookName, IPluginHookName>;
674
+ pipeline: (string | Function | IBuildTask[])[];
675
+ /**
676
+ * 构建任务的结果缓存,只允许接口访问
677
+ */
678
+ private taskResMap;
679
+ static utils: IBuildUtils;
680
+ get utils(): IBuildUtils;
681
+ constructor(id: string, options: IBuildOptionBase);
682
+ get stage(): string;
683
+ /**
684
+ * 获取某个任务结果
685
+ * @param name
686
+ */
687
+ getTaskResult(name: keyof ITaskResultMap_2): {
688
+ projectJs: string;
689
+ systemJs: string;
690
+ polyfillsJs: string | null;
691
+ } | IBuildPacResult_2 | undefined;
692
+ /**
693
+ * 开始整理构建需要的参数
694
+ */
695
+ init(): Promise<void>;
696
+ /**
697
+ * 执行具体的构建任务
698
+ */
699
+ run(): Promise<boolean>;
700
+ /**
701
+ * 仅构建 Bundle 流程
702
+ */
703
+ buildBundleOnly(): Promise<void>;
704
+ private postBuild;
705
+ private handleBuildStageTask;
706
+ private initBundleManager;
707
+ break(reason: string): void;
708
+ lockAssetDB(): Promise<void>;
709
+ unLockAssetDB(): void;
710
+ /**
711
+ * 获取预览 settings 信息
712
+ */
713
+ getPreviewSettings(): Promise<ISettings>;
714
+ private initOptions;
715
+ /**
716
+ * 执行某个任务列表
717
+ * @param buildTasks 任务列表数组
718
+ * @param weight 全部任务列表所占权重
719
+ * @param args 需要传递给任务的其他参数
720
+ */
721
+ private runBuildTask;
722
+ handleHook(func: Function, internal: boolean, ...args: any[]): Promise<void>;
723
+ onError(error: Error, throwError?: boolean): void;
724
+ runErrorHook(): Promise<void>;
725
+ }
726
+
727
+ declare abstract class BuildTaskBase extends EventEmitter {
728
+ breakReason?: string;
729
+ name: string;
730
+ progress: number;
731
+ error?: Error;
732
+ abstract hooksInfo: IBuildHooksInfo;
733
+ abstract options: IBuildOptionBase;
734
+ abstract hookMap: Record<string, string>;
735
+ hookWeight: number;
736
+ id: string;
737
+ buildExitRes: IBuildResultSuccess;
738
+ constructor(id: string, name: string);
739
+ break(reason: string): void;
740
+ onError(error: Error, throwError?: boolean): void;
741
+ /**
742
+ * 更新进度消息 log
743
+ * @param message
744
+ * @param increment
745
+ * @param outputType
746
+ */
747
+ updateProcess(message: string, increment?: number, outputType?: IConsoleType): void;
748
+ abstract handleHook(func: Function, internal: boolean, ...args: any[]): Promise<void>;
749
+ abstract run(): Promise<boolean>;
750
+ runPluginTask(funcName: string, weight?: number): Promise<void>;
751
+ }
752
+
753
+ declare class BuildTemplate implements IBuildTemplate {
754
+ _buildTemplateDirs: string[];
755
+ map: Record<string, {
756
+ url: string;
757
+ path: string;
758
+ }>;
759
+ _versionUser: string;
760
+ config?: BuildTemplateConfig;
761
+ get isEnable(): boolean;
762
+ constructor(platform: Platform | string, taskName: string, config?: BuildTemplateConfig);
763
+ query(name: string): string;
764
+ private _initVersion;
765
+ findFile(relativeUrl: string): string;
766
+ initUrl(relativeUrl: string, name?: string): string | undefined;
767
+ copyTo(dest: string): Promise<void>;
768
+ }
769
+
518
770
  export declare interface BuildTemplateConfig {
519
771
  templates: {
520
772
  path: string;
@@ -532,6 +784,13 @@ export declare const enum BuiltinBundleName {
532
784
  INTERNAL = 'internal'
533
785
  }
534
786
 
787
+ declare enum BuiltinBundleName_2 {
788
+ RESOURCES = 'resources',
789
+ MAIN = 'main',
790
+ START_SCENE = 'start-scene',
791
+ INTERNAL = 'internal'
792
+ }
793
+
535
794
  export declare type BundleCompressionType = 'none' | 'merge_dep' | 'merge_all_json' | 'subpackage' | 'zip';
536
795
 
537
796
  export declare const enum BundleCompressionTypes {
@@ -542,6 +801,14 @@ export declare const enum BundleCompressionTypes {
542
801
  ZIP = 'zip'
543
802
  }
544
803
 
804
+ declare enum BundleCompressionTypes_2 {
805
+ NONE = 'none',
806
+ MERGE_DEP = 'merge_dep',
807
+ MERGE_ALL_JSON = 'merge_all_json',
808
+ SUBPACKAGE = 'subpackage',
809
+ ZIP = 'zip'
810
+ }
811
+
545
812
  export declare interface BundleConfigItem {
546
813
  isRemote?: boolean;
547
814
  compressionType: BundleCompressionType;
@@ -559,6 +826,114 @@ export declare interface BundleFilterConfig {
559
826
  assets?: string[];
560
827
  }
561
828
 
829
+ declare class BundleManager extends BuildTaskBase implements IBundleManager {
830
+ static BuiltinBundleName: typeof BuiltinBundleName_2;
831
+ static BundleConfigs: Record<string, Record<string, {
832
+ isRemote: boolean;
833
+ compressionType: BundleCompressionTypes_2;
834
+ }>>;
835
+ private _task?;
836
+ options: IInternalBundleBuildOptions;
837
+ destDir: string;
838
+ hooksInfo: IBuildHooksInfo;
839
+ bundleMap: Record<string, IBundle>;
840
+ bundles: IBundle[];
841
+ _pacAssets: string[];
842
+ _bundleGroupInPriority?: Array<IBundle[]>;
843
+ imageCompressManager?: TextureCompress_2;
844
+ scriptBuilder: ScriptBuilder_2;
845
+ packResults: PacInfo[];
846
+ cache: BuilderAssetCache;
847
+ hookMap: {
848
+ onBeforeBundleInit: string;
849
+ onAfterBundleInit: string;
850
+ onBeforeBundleDataTask: string;
851
+ onAfterBundleDataTask: string;
852
+ onBeforeBundleBuildTask: string;
853
+ onAfterBundleBuildTask: string;
854
+ };
855
+ pipeline: (string | Function)[];
856
+ get bundleGroupInPriority(): IBundle[][];
857
+ static internalBundlePriority: Record<string, number>;
858
+ private constructor();
859
+ static create(options: IBuildOptionBase, task?: IBuilder): Promise<BundleManager>;
860
+ loadScript(scriptUuids: string[], pluginScripts: IPluginScriptInfo[]): Promise<void>;
861
+ /**
862
+ * 初始化项目设置的一些 bundle 配置信息
863
+ */
864
+ static initStaticBundleConfig(): Promise<void>;
865
+ getUserConfig(ID?: string): {
866
+ isRemote: boolean;
867
+ compressionType: BundleCompressionTypes_2;
868
+ } | null;
869
+ /**
870
+ * 对 options 上的数据做补全处理
871
+ */
872
+ initOptions(): Promise<void>;
873
+ clearBundleDest(): void;
874
+ /**
875
+ * 初始化整理资源列表
876
+ */
877
+ initAsset(): Promise<void>;
878
+ initBundleConfig(): Promise<void>;
879
+ buildAsset(): Promise<void>;
880
+ /**
881
+ * 独立构建 Bundle 时调用
882
+ * @returns
883
+ */
884
+ run(): Promise<boolean>;
885
+ outputBundle(): Promise<void>;
886
+ private addBundle;
887
+ private getDefaultBundleConfig;
888
+ /**
889
+ * 根据参数初始化一些信息配置,整理所有的 bundle 分组信息
890
+ */
891
+ initBundle(): Promise<void>;
892
+ /**
893
+ * 初始化内置 Bundle(由于一些历史的 bundle 行为配置,内置 Bundle 的配置需要单独处理)
894
+ */
895
+ private initInternalBundleConfigs;
896
+ /**
897
+ * 填充成完整可用的项目 Bundle 配置(传入自定义配置 > Bundle 文件夹配置 > 默认配置)
898
+ * @param customConfig
899
+ * @returns IBundleInitOptions | null
900
+ */
901
+ private patchProjectBundleConfig;
902
+ /**
903
+ * 初始化 bundle 分组内的根资源信息
904
+ * 初始化 bundle 内的各项不同的处理任务
905
+ */
906
+ private initBundleRootAssets;
907
+ /**
908
+ * 按照 Bundle 优先级整理 Bundle 的资源列表
909
+ */
910
+ private initBundleShareAssets;
911
+ /**
912
+ * 根据不同的选项做不同的 bundle 任务注册
913
+ */
914
+ bundleDataTask(): Promise<void>;
915
+ /**
916
+ * 纹理压缩处理
917
+ * @returns
918
+ */
919
+ private compressImage;
920
+ /**
921
+ * 执行自动图集任务
922
+ */
923
+ private packImage;
924
+ /**
925
+ * 编译项目脚本
926
+ */
927
+ buildScript(): Promise<any>;
928
+ /**
929
+ * 输出所有的 bundle 资源,包含脚本、json、普通资源、纹理压缩、图集等
930
+ */
931
+ private outputAssets;
932
+ handleHook(func: Function, internal: boolean, ...args: any[]): Promise<void>;
933
+ runAllTask(): Promise<void>;
934
+ runBuildTask(handle: Function, increment: number): Promise<void>;
935
+ }
936
+
562
937
  export declare type BundlePlatformType = 'native' | 'miniGame' | 'web';
563
938
 
564
939
  export declare interface BundleRenderConfig {
@@ -568,6 +943,8 @@ export declare interface BundleRenderConfig {
568
943
  minOptionList?: Record<string, any[]>;
569
944
  }
570
945
 
946
+ declare type CCEnvConstants = ConstantManager.CCEnvConstants;
947
+
571
948
  declare type ChangeEvent = 'create' | 'update' | 'delete';
572
949
 
573
950
  declare interface ChokidarOptions {
@@ -646,11 +1023,33 @@ declare class CocosParams<T> {
646
1023
  constructor(params: CocosParams<T>);
647
1024
  }
648
1025
 
1026
+ declare interface CompressCacheInfo {
1027
+ option: {
1028
+ mtime: number | string;
1029
+ src: string;
1030
+ compressOptions: Record<string, Record<string, string | number>>;
1031
+ };
1032
+ mipmapFiles: string[] | undefined;
1033
+ customConfigs: Record<string, ICustomConfig>;
1034
+ dest?: string[];
1035
+ }
1036
+
649
1037
  export declare interface CompressedInfo {
650
1038
  suffixs: string[];
651
1039
  imagePathNoExt: string;
652
1040
  }
653
1041
 
1042
+ declare interface CompressExecuteInfo {
1043
+ busyFormatType: Partial<Record<ITextureCompressFormatType | string, number>>;
1044
+ busyAsset: Set<string>;
1045
+ resolve: Function;
1046
+ reject: Function;
1047
+ state: 'progress' | 'success' | 'failed';
1048
+ complete: number;
1049
+ total: number;
1050
+ childProcess: number;
1051
+ }
1052
+
654
1053
  declare interface Config {
655
1054
  /**
656
1055
  * Engine features. Keys are feature IDs.
@@ -709,6 +1108,12 @@ declare interface Context {
709
1108
  buildTimeConstants?: object;
710
1109
  }
711
1110
 
1111
+ export declare function createBuildStageTask(taskId: string, stageName: string, options: IBuildStageOptions): Promise<BuildStageTask>;
1112
+
1113
+ export declare function createBuildTask<P extends Platform>(platform: P, options?: IBuildCommandOption): Promise<BuildTask>;
1114
+
1115
+ export declare function createBundleBuildTask(bundleOptions: IBundleBuildOptions): Promise<BundleManager>;
1116
+
712
1117
  export declare interface CustomBundleConfig {
713
1118
  displayName: string;
714
1119
  configs: Record<BundlePlatformType, CustomBundleConfigItem>;
@@ -1675,6 +2080,12 @@ export declare interface IBuildPacResult {
1675
2080
  imageToPac: Record<string, string>;
1676
2081
  }
1677
2082
 
2083
+ declare interface IBuildPacResult_2 {
2084
+ spriteToImage: Record<string, string>;
2085
+ textureToImage: Record<string, string>;
2086
+ imageToPac: Record<string, string>;
2087
+ }
2088
+
1678
2089
  export declare interface IBuildPanel {
1679
2090
  Vue: any;
1680
2091
  validator: {
@@ -1845,6 +2256,12 @@ export declare interface IBuildSeparateEngineResult {
1845
2256
 
1846
2257
  export declare type IBuildStage = 'build' | 'bundle' | 'make' | 'run' | string;
1847
2258
 
2259
+ declare interface IBuildStageConfig extends IBuildStageItem {
2260
+ root: string;
2261
+ hooksInfo: IBuildHooksInfo;
2262
+ buildTaskOptions: IBuildOptionBase;
2263
+ }
2264
+
1848
2265
  export declare type IBuildStageHooks = (root: string, options: IBuildOptionBase) => Promise<void> | void;
1849
2266
 
1850
2267
  export declare interface IBuildStageItem {
@@ -2359,6 +2776,8 @@ declare interface IConstantInfo {
2359
2776
  dynamic?: boolean;
2360
2777
  }
2361
2778
 
2779
+ declare type ICustomAssetHandlerType = 'compressTextures';
2780
+
2362
2781
  export declare type ICustomBuildIconInfo = IBuildIconItem & {
2363
2782
  pkgName: string;
2364
2783
  };
@@ -2803,6 +3222,12 @@ export declare interface ImportMap {
2803
3222
  scopes?: Record<string, Record<string, string>>;
2804
3223
  }
2805
3224
 
3225
+ declare interface ImportMapOptions {
3226
+ data: ImportMapWithImports;
3227
+ format?: 'commonjs' | 'esm';
3228
+ output: string;
3229
+ }
3230
+
2806
3231
  export declare type ImportMapWithImports = ImportMap & {
2807
3232
  imports: NonNullable<ImportMap['imports']>;
2808
3233
  };
@@ -2940,10 +3365,44 @@ export declare interface InternalBuildResult {
2940
3365
  separateEngineResult?: IBuildSeparateEngineResult;
2941
3366
  }
2942
3367
 
3368
+ declare class InternalBuildResult_2 extends EventEmitter implements InternalBuildResult {
3369
+ settings: ISettings;
3370
+ scriptPackages: string[];
3371
+ pluginVers: Record<string, string>;
3372
+ compressImageResult: ICompressImageResult;
3373
+ /**
3374
+ * @param name
3375
+ * @param options
3376
+ * 导入映射
3377
+ */
3378
+ importMap: ImportMapWithImports;
3379
+ rawOptions: IBuildOptionBase;
3380
+ paths: IBuildPaths;
3381
+ compileOptions: any;
3382
+ private __task;
3383
+ pluginScripts: Array<{
3384
+ uuid: string;
3385
+ url: string;
3386
+ file: string;
3387
+ }>;
3388
+ separateEngineResult?: IBuildSeparateEngineResult;
3389
+ get dest(): string;
3390
+ constructor(task: IBuilder, preview: boolean);
3391
+ }
3392
+
2943
3393
  declare type InternalModuleFormat = 'amd' | 'cjs' | 'es' | 'iife' | 'system' | 'umd';
2944
3394
 
2945
3395
  declare type InternalNativePlatform = 'mac' | 'android' | 'google-play' | 'windows' | 'ios' | 'ohos' | 'harmonyos-next';
2946
3396
 
3397
+ declare interface InternalPackageInfo {
3398
+ name: string;
3399
+ path: string;
3400
+ buildPath: string;
3401
+ doc?: string;
3402
+ displayName?: string;
3403
+ version: string;
3404
+ }
3405
+
2947
3406
  export declare type InternalPlatform = 'web-desktop' | 'web-mobile' | 'mac' | 'ios' | 'android' | 'google-play' | 'windows' | 'ohos' | 'harmonyos-next';
2948
3407
 
2949
3408
  declare type InteropType = boolean | 'auto' | 'esModule' | 'default' | 'defaultOnly';
@@ -3109,6 +3568,10 @@ export declare interface IPluginRegisterInfo {
3109
3568
  type: 'plugin';
3110
3569
  }
3111
3570
 
3571
+ declare interface IPluginScriptInfo extends PluginScriptInfo {
3572
+ url: string;
3573
+ }
3574
+
3112
3575
  export declare interface IPolyFills {
3113
3576
  /**
3114
3577
  * True if async functions polyfills(i.e. regeneratorRuntime) needs to be included.
@@ -3181,6 +3644,15 @@ export declare interface IScriptOptions {
3181
3644
  bundleCommonChunk: boolean;
3182
3645
  }
3183
3646
 
3647
+ declare interface IScriptProjectOption extends SharedSettings {
3648
+ ccEnvConstants: CCEnvConstants;
3649
+ dbInfos: {
3650
+ dbID: string;
3651
+ target: string;
3652
+ }[];
3653
+ customMacroList: MacroItem[];
3654
+ }
3655
+
3184
3656
  export declare interface ISerializedOptions {
3185
3657
  debug: boolean;
3186
3658
  useCCONB?: boolean;
@@ -3384,6 +3856,15 @@ export declare interface ITaskResultMap {
3384
3856
  'build-task/pac'?: IBuildPacResult;
3385
3857
  }
3386
3858
 
3859
+ declare interface ITaskResultMap_2 {
3860
+ 'build-task/script'?: {
3861
+ projectJs: string;
3862
+ systemJs: string;
3863
+ polyfillsJs: string | null;
3864
+ };
3865
+ 'build-task/pac'?: IBuildPacResult_2;
3866
+ }
3867
+
3387
3868
  export declare type ITaskState = 'waiting' | 'success' | 'failure' | 'cancel' | 'processing' | 'none';
3388
3869
 
3389
3870
  export declare interface ITextureCompressConfig {
@@ -3984,6 +4465,36 @@ export declare interface OverwriteProjectSettings extends IEngineConfig {
3984
4465
  engineInfo: EngineInfo;
3985
4466
  }
3986
4467
 
4468
+ /**
4469
+ * 一个图集信息
4470
+ */
4471
+ declare class PacInfo implements IPacInfo {
4472
+ spriteFrameInfos: SpriteFrameInfo[];
4473
+ spriteFrames: SpriteFrame[];
4474
+ relativePath: string;
4475
+ relativeDir: string;
4476
+ path: string;
4477
+ uuid: string;
4478
+ imagePath: string;
4479
+ imageUuid: string;
4480
+ textureUuid: string;
4481
+ name: string;
4482
+ width: number;
4483
+ height: number;
4484
+ dirty: boolean;
4485
+ packOptions: IPackOptions;
4486
+ storeInfo: PacStoreInfo;
4487
+ result?: IPackResult;
4488
+ constructor(pacAsset: IAsset, options?: Partial<IPackOptions>);
4489
+ initSpriteFramesWithRange(includeAssets?: string[]): Promise<this>;
4490
+ /**
4491
+ * @param {Object} pacAssetInfo 从 db 中获取出来的 pac 信息
4492
+ */
4493
+ initSpriteFrames(spriteFrameAssets: (IAsset)[]): Promise<this>;
4494
+ private queryInvalidSpriteAssets;
4495
+ toJSON(): void;
4496
+ }
4497
+
3987
4498
  export declare interface PacStoreInfo {
3988
4499
  pac: StoreInfo;
3989
4500
  sprites: ISpriteFrameInfo[];
@@ -4221,6 +4732,103 @@ declare type PluginHooks = {
4221
4732
  */
4222
4733
  declare type PluginImpl<O extends object = object> = (options?: O) => Plugin_2;
4223
4734
 
4735
+ declare class PluginManager extends EventEmitter {
4736
+ bundleConfigs: Record<string, PlatformBundleConfig>;
4737
+ commonOptionConfig: Record<string, Record<string, IBuilderConfigItem & {
4738
+ verifyKey: string;
4739
+ }>>;
4740
+ pkgOptionConfigs: Record<string, Record<string, IDisplayOptions>>;
4741
+ platformConfig: Record<string, IPlatformConfig>;
4742
+ buildTemplateConfigMap: Record<string, BuildTemplateConfig>;
4743
+ configMap: Record<string, Record<string, IInternalBuildPluginConfig>>;
4744
+ private builderPathsMap;
4745
+ private customBuildStagesMap;
4746
+ protected customBuildStages: Record<string, {
4747
+ [pkgName: string]: IBuildStageItem[];
4748
+ }>;
4749
+ private assetHandlers;
4750
+ protected readonly pkgPriorities: Record<string, number>;
4751
+ packageRegisterInfo: Map<string, InternalPackageInfo>;
4752
+ private platformRegisterInfoPool;
4753
+ constructor();
4754
+ init(): Promise<void>;
4755
+ registerAllPlatform(): Promise<void>;
4756
+ register(platform: string): Promise<void>;
4757
+ checkPlatform(platform: string): boolean;
4758
+ private registerPlatform;
4759
+ private internalRegister;
4760
+ _registerI18n(registerInfo: IBuilderRegisterInfo): void;
4761
+ getCommonOptionConfigs(platform: Platform): Record<string, IBuilderConfigItem>;
4762
+ getCommonOptionConfigByKey(key: keyof IBuildTaskOption, options: IBuildTaskOption): IBuilderConfigItem | null;
4763
+ getPackageOptionConfigByKey(key: string, pkgName: string, options: IBuildTaskOption): IBuilderConfigItem | null;
4764
+ getOptionConfigByKey(key: keyof IBuildTaskOption, options: IBuildTaskOption): IBuilderConfigItem | null;
4765
+ /**
4766
+ * 完整校验构建参数(校验平台插件相关的参数校验)
4767
+ * @param options
4768
+ */
4769
+ checkOptions(options: MakeRequired<IBuildCommandOption, 'platform' | 'mainBundleCompressionType'>): Promise<undefined | IBuildTaskOption>;
4770
+ checkCommonOptions(options: IBuildTaskOption): Promise<Record<string, BuildCheckResult>>;
4771
+ checkCommonOptionByKey(key: keyof IBuildTaskOption, value: any, options: IBuildTaskOption): Promise<BuildCheckResult>;
4772
+ /**
4773
+ * 校验构建插件注册的构建参数
4774
+ * @param options
4775
+ */
4776
+ private checkPluginOptions;
4777
+ shouldGenerateOptions(platform: Platform | string): boolean;
4778
+ /**
4779
+ * 获取平台默认值
4780
+ * @param platform
4781
+ */
4782
+ getOptionsByPlatform<P extends Platform | string>(platform: P): Promise<IBuildTaskOption>;
4783
+ getTexturePlatformConfigs(): Record<string, ITextureCompressConfig>;
4784
+ queryPlatformConfig(): {
4785
+ native: string[];
4786
+ config: Record<string, IPlatformConfig>;
4787
+ };
4788
+ /**
4789
+ * 获取带有钩子函数的构建阶段任务
4790
+ * @param platform
4791
+ * @returns
4792
+ */
4793
+ getBuildStageWithHookTasks(platform: Platform | string, taskName: string): IBuildStageItem | null;
4794
+ /**
4795
+ * 查询某个平台的阶段性任务按钮配置信息
4796
+ * @param platform
4797
+ */
4798
+ getBuildStageConfigByPlatform(platform: Platform): Record<string, any> | null;
4799
+ /**
4800
+ * 根据插件权重传参的插件数组
4801
+ * @param pkgNames
4802
+ * @returns
4803
+ */
4804
+ private sortPkgNameWidthPriority;
4805
+ /**
4806
+ * 获取平台插件的构建路径信息
4807
+ * @param platform
4808
+ */
4809
+ getHooksInfo(platform: Platform | string): IBuildHooksInfo;
4810
+ getBuildTemplateConfig(platform: string): BuildTemplateConfig;
4811
+ /**
4812
+ * 根据类型获取对应的执行方法
4813
+ * @param type
4814
+ * @returns
4815
+ */
4816
+ getAssetHandlers(type: ICustomAssetHandlerType): {
4817
+ pkgNameOrder: string[];
4818
+ handles: Record<string, Function>;
4819
+ };
4820
+ }
4821
+
4822
+ export declare const pluginManager: PluginManager;
4823
+
4824
+ declare interface PluginScriptInfo {
4825
+ /**
4826
+ * 脚本文件。
4827
+ */
4828
+ file: string;
4829
+ uuid: string;
4830
+ }
4831
+
4224
4832
  /** JavaScript 插件脚本的 userData */
4225
4833
  declare interface PluginScriptUserData {
4226
4834
  isPlugin: true;
@@ -4637,6 +5245,28 @@ export declare class ScriptBuilder {
4637
5245
  static outputImportMap(importMap: ImportMap, options: IImportMapOptions): Promise<void>;
4638
5246
  }
4639
5247
 
5248
+ declare class ScriptBuilder_2 {
5249
+ _scriptOptions: IScriptOptions;
5250
+ _importMapOptions: ImportMapOptions;
5251
+ scriptPackages: string[];
5252
+ static projectOptions: IScriptProjectOption;
5253
+ initTaskOptions(options: IInternalBuildOptions | IInternalBundleBuildOptions): {
5254
+ scriptOptions: IScriptOptions;
5255
+ importMapOptions: {
5256
+ format: 'esm' | 'commonjs' | undefined;
5257
+ data: {
5258
+ imports: {};
5259
+ };
5260
+ output: string;
5261
+ };
5262
+ };
5263
+ initProjectOptions(options: IInternalBuildOptions | IInternalBundleBuildOptions): Promise<void>;
5264
+ buildBundleScript(bundles: IBundle[]): Promise<any>;
5265
+ static buildPolyfills(options: IPolyFills | undefined, dest: string): Promise<any>;
5266
+ static buildSystemJs(options: IBuildSystemJsOption): Promise<any>;
5267
+ static outputImportMap(importMap: ImportMap, options: IImportMapOptions): Promise<void>;
5268
+ }
5269
+
4640
5270
  /** JavaScript 脚本模块的 userData */
4641
5271
  declare interface ScriptModuleUserData {
4642
5272
  isPlugin: false;
@@ -4667,6 +5297,22 @@ declare interface SerializedTimings {
4667
5297
  [label: string]: [number, number, number];
4668
5298
  }
4669
5299
 
5300
+ declare interface SharedSettings {
5301
+ useDefineForClassFields: boolean;
5302
+ allowDeclareFields: boolean;
5303
+ loose: boolean;
5304
+ guessCommonJsExports: boolean;
5305
+ exportsConditions: string[];
5306
+ preserveSymlinks: boolean;
5307
+ importMap?: {
5308
+ json: {
5309
+ imports?: Record<string, string>;
5310
+ scopes?: Record<string, Record<string, string>>;
5311
+ };
5312
+ url: string;
5313
+ };
5314
+ }
5315
+
4670
5316
  declare type ShouldTransformCachedModuleHook = (
4671
5317
  this: PluginContext,
4672
5318
  options: {
@@ -4774,6 +5420,34 @@ declare interface SpriteFrameBaseAssetUserData {
4774
5420
  vertices: SpriteFrameVertices;
4775
5421
  }
4776
5422
 
5423
+ declare class SpriteFrameInfo {
5424
+ name: string;
5425
+ uuid: string;
5426
+ imageUuid: string;
5427
+ textureUuid: string;
5428
+ spriteFrame: SpriteFrame;
5429
+ trim: {
5430
+ width: number;
5431
+ height: number;
5432
+ rotatedWidth: number;
5433
+ rotatedHeight: number;
5434
+ x: number;
5435
+ y: number;
5436
+ };
5437
+ rawWidth: number;
5438
+ rawHeight: number;
5439
+ width: number;
5440
+ height: number;
5441
+ originalPath: string;
5442
+ rotated: boolean;
5443
+ _file: string;
5444
+ _libraryPath: string;
5445
+ _pacUuid: string;
5446
+ private _mtime;
5447
+ constructor(spriteFrame: SpriteFrame, assetInfo: IAsset, options: IPackOptions);
5448
+ toJSON(): any;
5449
+ }
5450
+
4777
5451
  declare interface SpriteFrameVertices {
4778
5452
  rawPosition: number[];
4779
5453
  indexes: number[];
@@ -5001,6 +5675,21 @@ export declare const enum TaskAddResult {
5001
5675
  PARAM_ERROR = 2
5002
5676
  }
5003
5677
 
5678
+ declare class TaskManager {
5679
+ private static readonly tasks;
5680
+ static readonly pluginTasks: Record<IPluginHookName, IPluginHookName>;
5681
+ private static buildTaskMap;
5682
+ activeTasks: Set<TaskType>;
5683
+ get taskWeight(): number;
5684
+ static getBuildTask(type: TaskType): any[];
5685
+ static getTaskHandleFromNames(taskNames: string[]): any[];
5686
+ static getCustomTaskName(name: string): string;
5687
+ activeTask(type: TaskType): any[];
5688
+ activeCustomTask(name: string, taskNames: string[]): any[];
5689
+ }
5690
+
5691
+ declare type TaskType = 'dataTasks' | 'settingTasks' | 'buildTasks' | 'md5Tasks' | 'postprocessTasks' | string;
5692
+
5004
5693
  declare type Test = string;
5005
5694
 
5006
5695
  declare interface Texture2DAssetUserData extends TextureBaseAssetUserData {
@@ -5025,6 +5714,99 @@ export declare interface TextureCompress {
5025
5714
  run(): Promise<void>;
5026
5715
  }
5027
5716
 
5717
+ declare class TextureCompress_2 extends EventEmitter_2 {
5718
+ _taskMap: Record<string, IImageTaskInfo>;
5719
+ platform: string;
5720
+ static overwriteFormats: Record<string, string>;
5721
+ static _presetIdToCompressOption: Record<string, Record<string, Record<string, number | string>>>;
5722
+ static allTextureCompressConfig: AllTextureCompressConfig;
5723
+ static userCompressConfig: UserCompressConfig;
5724
+ static compressCacheDir: string;
5725
+ static storedCompressInfo: Record<string, CompressCacheInfo>;
5726
+ static storedCompressInfoPath: string;
5727
+ static enableMipMaps: boolean;
5728
+ _waitingCompressQueue: Set<ICompressConfig>;
5729
+ _compressAssetLen: number;
5730
+ _compressExecuteInfo: CompressExecuteInfo | null;
5731
+ textureCompress: boolean;
5732
+ constructor(platform: string, textureCompress?: boolean);
5733
+ static initCommonOptions(): Promise<void>;
5734
+ init(): Promise<void>;
5735
+ /**
5736
+ * 更新缓存的纹理压缩项目配置
5737
+ */
5738
+ updateUserConfig(): Promise<void>;
5739
+ static queryTextureCompressCache(uuid: string): CompressCacheInfo;
5740
+ /**
5741
+ * 根据资源信息返回资源的纹理压缩任务,无压缩任务的返回 null
5742
+ * @param assetInfo
5743
+ * @returns IImageTaskInfo | null
5744
+ */
5745
+ addTask(uuid: string, task: IImageTaskInfo): IImageTaskInfo;
5746
+ /**
5747
+ * 根据 Image 信息添加资源的压缩任务
5748
+ * @param assetInfo (不支持自动图集)
5749
+ * @returns
5750
+ */
5751
+ addTaskWithAssetInfo(assetInfo: Asset | VirtualAsset): IImageTaskInfo | {
5752
+ src: string;
5753
+ presetId: any;
5754
+ compressOptions: Record<string, Record<string, string | number>>;
5755
+ hasAlpha: any;
5756
+ mtime: any;
5757
+ hasMipmaps: boolean;
5758
+ dest: never[];
5759
+ suffix: never[];
5760
+ } | undefined;
5761
+ /**
5762
+ * 根据图集或者 Image 资源信息返回资源的纹理压缩任务,无压缩任务的返回 null
5763
+ */
5764
+ genTaskInfoFromAssetInfo(assetInfo: Asset | VirtualAsset): IImageTaskInfo | {
5765
+ src: string;
5766
+ presetId: any;
5767
+ compressOptions: Record<string, Record<string, string | number>>;
5768
+ hasAlpha: any;
5769
+ mtime: any;
5770
+ hasMipmaps: boolean;
5771
+ dest: never[];
5772
+ suffix: never[];
5773
+ } | null | undefined;
5774
+ /**
5775
+ * 根据纹理压缩配置 id 获取对应的纹理压缩选项
5776
+ * @param presetId
5777
+ * @returns Record<string, number | string> | null
5778
+ */
5779
+ getCompressOptions(presetId: string): (Record<string, Record<string, number | string>>) | null;
5780
+ /**
5781
+ * 查询某个指定 uuid 资源的纹理压缩任务
5782
+ * @param uuid
5783
+ * @returns
5784
+ */
5785
+ queryTask(uuid: string): IImageTaskInfo;
5786
+ removeTask(uuid: string): void;
5787
+ /**
5788
+ * 执行所有纹理压缩任务,支持限定任务,否则将执行收集的所有纹理压缩任务
5789
+ */
5790
+ run(taskMap?: Record<string, IImageTaskInfo>): Promise<Record<string, IImageTaskInfo> | undefined>;
5791
+ /**
5792
+ * 筛选整理压缩任务中缓存失效的实际需要压缩的任务队列
5793
+ * @param taskMap
5794
+ * @returns
5795
+ */
5796
+ private sortImageTask;
5797
+ executeCompressQueue(): Promise<unknown> | undefined;
5798
+ _getNextTask(): ICompressConfig | null;
5799
+ _checkTaskCanExecute(taskConfig: ICompressConfig): boolean;
5800
+ _compressImage(config: ICompressConfig): Promise<void>;
5801
+ /**
5802
+ * 检查压缩任务是否已经完成,如未完成,则继续执行剩下的任务
5803
+ * @returns
5804
+ */
5805
+ _step(): Promise<any>;
5806
+ private customCompressImage;
5807
+ compressImageByConfig(optionItem: ICompressConfig): Promise<void>;
5808
+ }
5809
+
5028
5810
  declare interface TextureCubeAssetUserData extends TextureBaseAssetUserData {
5029
5811
  imageDatabaseUri?: string;
5030
5812
  isRGBE: boolean;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@cocos/cocos-cli-types",
3
3
  "description": "types for cocos cli",
4
4
  "author": "cocos cli",
5
- "version": "0.0.1-alpha.17.4",
5
+ "version": "0.0.1-alpha.19.1",
6
6
  "main": "index.d.ts",
7
7
  "types": "index.d.ts",
8
8
  "exports": {