@cocos/cocos-cli-types 0.0.1-alpha.15.1 → 0.0.1-alpha.17.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.
package/assets.d.ts CHANGED
@@ -965,6 +965,99 @@ declare enum NormalImportSetting {
965
965
  recalculate = 3
966
966
  }
967
967
 
968
+ /**
969
+ * Listen to Asset Added Event // 监听资源添加事件
970
+ * @param listener Callback function that receives asset information
971
+ * @returns Function to remove the listener
972
+ *
973
+ * 推荐用法:
974
+ * ```typescript
975
+ * const removeListener = onAssetAdded((info) => {
976
+ * console.log(`资源已添加: ${info.name}`);
977
+ * console.log(` 逻辑路径: ${info.url}`);
978
+ * console.log(` 物理路径: ${info.file}`);
979
+ * });
980
+ * // 稍后移除监听
981
+ * removeListener();
982
+ * ```
983
+ */
984
+ export declare function onAssetAdded(listener: (info: IAssetInfo) => void): () => void;
985
+
986
+ /**
987
+ * Listen to Asset Changed Event // 监听资源变更事件
988
+ * @param listener Callback function that receives asset information
989
+ * @returns Function to remove the listener
990
+ *
991
+ * 推荐用法:
992
+ * ```typescript
993
+ * const removeListener = onAssetChanged((info) => {
994
+ * console.log(`资源已变更: ${info.name}`);
995
+ * });
996
+ * // 稍后移除监听
997
+ * removeListener();
998
+ * ```
999
+ */
1000
+ export declare function onAssetChanged(listener: (info: IAssetInfo) => void): () => void;
1001
+
1002
+ /**
1003
+ * Listen to Asset Removed Event // 监听资源删除事件
1004
+ * @param listener Callback function that receives asset information
1005
+ * @returns Function to remove the listener
1006
+ *
1007
+ * 推荐用法:
1008
+ * ```typescript
1009
+ * const removeListener = onAssetRemoved((info) => {
1010
+ * console.log(`资源已删除: ${info.name}`);
1011
+ * });
1012
+ * // 稍后移除监听
1013
+ * removeListener();
1014
+ * ```
1015
+ */
1016
+ export declare function onAssetRemoved(listener: (info: IAssetInfo) => void): () => void;
1017
+
1018
+ /**
1019
+ * Register listener for when a specific database finishes starting.
1020
+ *
1021
+ * 注册单个数据库启动完成后的事件监听。
1022
+ *
1023
+ * **注意事项 (Notice)**:
1024
+ * - 这个事件可能会被触发多次(如果项目存在多个子数据库,如 `assets`, `internal`)。
1025
+ * - 主要用于需要做更精细化并行控制的上层逻辑,通常情况下普通的业务逻辑不需要关心此事件,直接监听 `onReady` 即可。
1026
+ *
1027
+ * @param listener 回调函数,接收启动完成的 dbInfo
1028
+ * @returns 移除监听的函数
1029
+ */
1030
+ export declare function onDBReady(listener: (dbInfo: IAssetDBInfo) => void): () => void;
1031
+
1032
+ /**
1033
+ * Register listener for initialization progress.
1034
+ *
1035
+ * 注册初始化过程中的进度监听。
1036
+ *
1037
+ * **注意事项 (Notice)**:
1038
+ * - **仅在启动阶段有效**。一旦触发过一次 `ready` 事件(即启动阶段结束),将不再会有新的进度消息。
1039
+ * - 启动时的资源冷导入会抛出密集的进度信息,建议在 UI 层面进行适当的节流(throttle)渲染。
1040
+ *
1041
+ * @param listener 回调函数,包含当前进度、总数、当前处理的资源 url 和导入状态
1042
+ * @returns 移除监听的函数
1043
+ */
1044
+ export declare function onProgress(listener: (current: number, total: number, url: string, state: 'processing' | 'success' | 'failed') => void): () => void;
1045
+
1046
+ /**
1047
+ * Register listener for when all asset databases are fully initialized.
1048
+ *
1049
+ * 注册数据库初始化完全完成后的事件监听。
1050
+ *
1051
+ * **注意事项 (Notice)**:
1052
+ * - 触发此事件代表**所有**注册的资源数据库都已经完全导入并初始化完成(启动阶段结束)。
1053
+ * - 收到此事件后,表示所有的资源查询、操作 API 都可以安全调用。
1054
+ * - 第一次 ready 后,将不再有 progress 进度消息。
1055
+ *
1056
+ * @param listener 回调函数
1057
+ * @returns 移除监听的函数
1058
+ */
1059
+ export declare function onReady(listener: () => void): () => void;
1060
+
968
1061
  /** 粒子资源的 userData */
969
1062
  declare interface ParticleAssetUserData {
970
1063
  totalParticles: number;
@@ -1246,6 +1339,11 @@ declare interface SpriteFrameVertices {
1246
1339
  maxPos: number[];
1247
1340
  }
1248
1341
 
1342
+ /**
1343
+ * Start Asset DB // 启动资源数据库,开始扫描和导入资源
1344
+ */
1345
+ export declare function start(): Promise<void>;
1346
+
1249
1347
  /** 支持创建的资源类型常量数组(用于 Zod enum 和 TypeScript type) */
1250
1348
  declare const SUPPORT_CREATE_TYPES: readonly ['animation-clip', 'typescript', 'auto-atlas', 'effect', 'scene', 'prefab', 'material', 'terrain', 'physics-material', 'label-atlas', 'render-texture', 'directory', 'effect-header'];
1251
1349
 
package/builder.d.ts CHANGED
@@ -4842,7 +4842,7 @@ declare class StatsQuery {
4842
4842
  */
4843
4843
  declare namespace StatsQuery {
4844
4844
  namespace ConstantManager {
4845
- type PlatformType = 'WEB_EDITOR' | 'WEB_MOBILE' | 'WEB_DESKTOP' | 'WECHAT' | 'WECHAT_MINI_PROGRAM' | 'BYTEDANCE' | 'XIAOMI' | 'ALIPAY' | 'TAOBAO' | 'TAOBAO_MINIGAME' | 'OPPO' | 'VIVO' | 'HUAWEI' | 'MIGU' | 'HONOR' | 'COCOS_RUNTIME' | 'NATIVE_EDITOR' | 'ANDROID' | 'WINDOWS' | 'IOS' | 'MAC' | 'OHOS' | 'OPEN_HARMONY' | 'LINUX' | 'HTML5' | 'NATIVE' | 'NODEJS' | 'INVALID_PLATFORM';
4845
+ type PlatformType = 'WEB_EDITOR' | 'WEB_MOBILE' | 'WEB_DESKTOP' | 'WECHAT' | 'WECHAT_MINI_PROGRAM' | 'BYTEDANCE' | 'XIAOMI' | 'ALIPAY' | 'TAOBAO' | 'TAOBAO_MINIGAME' | 'OPPO' | 'VIVO' | 'HUAWEI' | 'MIGU' | 'HONOR' | 'COCOS_RUNTIME' | 'SUD' | 'SUDV2' | 'NATIVE_EDITOR' | 'ANDROID' | 'WINDOWS' | 'IOS' | 'MAC' | 'OHOS' | 'OPEN_HARMONY' | 'LINUX' | 'HTML5' | 'NATIVE' | 'NODEJS' | 'INVALID_PLATFORM';
4846
4846
  type IPlatformConfig = { [key in PlatformType]: boolean };
4847
4847
  interface IInternalFlagConfig {
4848
4848
  SERVER_MODE: boolean;
@@ -1,3 +1,56 @@
1
+ import { EventEmitter } from 'events';
2
+
3
+ /**
4
+ * 配置范围
5
+ */
6
+ export declare type ConfigurationScope = 'default' | 'project';
7
+
8
+ declare type EventEmitterMethods = Pick<EventEmitter, 'on' | 'off' | 'once' | 'emit'>;
9
+
10
+ export declare function get<T>(key: string, scope?: ConfigurationScope): Promise<T>;
11
+
12
+ /**
13
+ * 配置基类接口
14
+ */
15
+ export declare interface IBaseConfiguration extends EventEmitterMethods {
16
+ /**
17
+ * 模块名
18
+ */
19
+ moduleName: string;
20
+ /**
21
+ * 默认配置数据
22
+ */
23
+ getDefaultConfig(): Record<string, any> | undefined;
24
+ /**
25
+ * 获取配置值
26
+ * @param key 配置键名,支持点号分隔的嵌套路径
27
+ * @param scope 配置作用域,不指定时按优先级查找
28
+ */
29
+ get<T>(key?: string, scope?: ConfigurationScope): Promise<T>;
30
+ /**
31
+ * 获取指定范围的所有配置,默认是 project
32
+ * @param scope
33
+ */
34
+ getAll(scope?: ConfigurationScope): Record<string, any> | undefined;
35
+ /**
36
+ * 设置配置值
37
+ * @param key 配置键名,支持点号分隔的嵌套路径
38
+ * @param value 新的配置值
39
+ * @param scope 配置作用域,默认为 'project'
40
+ */
41
+ set<T>(key: string, value: T, scope?: ConfigurationScope): Promise<boolean>;
42
+ /**
43
+ * 移除配置值
44
+ * @param key 配置键名,支持点号分隔的嵌套路径
45
+ * @param scope 配置作用域,默认为 'project'
46
+ */
47
+ remove(key: string, scope?: ConfigurationScope): Promise<boolean>;
48
+ /**
49
+ * 保存配置
50
+ */
51
+ save(): Promise<boolean>;
52
+ }
53
+
1
54
  /**
2
55
  * 配置的格式
3
56
  */
@@ -10,8 +63,16 @@ export declare interface IConfiguration {
10
63
 
11
64
  export declare function init(projectPath: string): Promise<void>;
12
65
 
66
+ export declare function migrate(): Promise<void>;
67
+
13
68
  export declare function migrateFromProject(): Promise<IConfiguration>;
14
69
 
15
70
  export declare function reload(): Promise<void>;
16
71
 
72
+ export declare function remove(key: string, scope?: ConfigurationScope): Promise<boolean>;
73
+
74
+ export declare function save(force?: boolean): Promise<void>;
75
+
76
+ export declare function set<T>(key: string, value: T, scope?: ConfigurationScope): Promise<boolean>;
77
+
17
78
  export { };
package/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  /// <reference types="node" />
2
2
 
3
+ import { EventEmitter } from 'events';
4
+
3
5
  /** 动画剪辑资源的 userData */
4
6
  declare interface AnimationClipAssetUserData {
5
7
  /** 动画名称 */
@@ -208,6 +210,10 @@ declare interface AssetOperationOption {
208
210
  export declare namespace Assets {
209
211
  export {
210
212
  init,
213
+ start,
214
+ onReady,
215
+ onDBReady,
216
+ onProgress,
211
217
  deleteAsset,
212
218
  refresh,
213
219
  queryAssetInfo,
@@ -232,6 +238,9 @@ export declare namespace Assets {
232
238
  queryAssetUserDataConfig,
233
239
  updateAssetUserData,
234
240
  queryAssetConfigMap,
241
+ onAssetAdded,
242
+ onAssetChanged,
243
+ onAssetRemoved,
235
244
  CreateAssetOptions,
236
245
  IAssetConfig,
237
246
  IAssetDBInfo,
@@ -346,10 +355,22 @@ export declare namespace Configuration {
346
355
  init_3 as init,
347
356
  migrateFromProject,
348
357
  reload,
349
- IConfiguration
358
+ migrate,
359
+ get,
360
+ set,
361
+ remove,
362
+ save,
363
+ IConfiguration,
364
+ ConfigurationScope,
365
+ IBaseConfiguration
350
366
  };
351
367
  }
352
368
 
369
+ /**
370
+ * 配置范围
371
+ */
372
+ declare type ConfigurationScope = 'default' | 'project';
373
+
353
374
  /**
354
375
  * Create Asset // 创建资源
355
376
  */
@@ -428,6 +449,8 @@ export declare namespace Engine {
428
449
  };
429
450
  }
430
451
 
452
+ declare type EventEmitterMethods = Pick<EventEmitter, 'on' | 'off' | 'once' | 'emit'>;
453
+
431
454
  declare interface ExecuteAssetDBScriptMethodOptions {
432
455
  name: string;
433
456
  method: string;
@@ -476,6 +499,8 @@ declare interface FontDefDictionary {
476
499
  [charId: number]: FontDef;
477
500
  }
478
501
 
502
+ declare function get<T>(key: string, scope?: ConfigurationScope): Promise<T>;
503
+
479
504
  /** glTF 动画资源的 userData */
480
505
  declare interface GltfAnimationAssetUserData {
481
506
  gltfIndex: number;
@@ -752,6 +777,48 @@ declare type IAssetType =
752
777
  | 'RenderStage' // 渲染阶段
753
778
  | 'RenderFlow';
754
779
 
780
+ /**
781
+ * 配置基类接口
782
+ */
783
+ declare interface IBaseConfiguration extends EventEmitterMethods {
784
+ /**
785
+ * 模块名
786
+ */
787
+ moduleName: string;
788
+ /**
789
+ * 默认配置数据
790
+ */
791
+ getDefaultConfig(): Record<string, any> | undefined;
792
+ /**
793
+ * 获取配置值
794
+ * @param key 配置键名,支持点号分隔的嵌套路径
795
+ * @param scope 配置作用域,不指定时按优先级查找
796
+ */
797
+ get<T>(key?: string, scope?: ConfigurationScope): Promise<T>;
798
+ /**
799
+ * 获取指定范围的所有配置,默认是 project
800
+ * @param scope
801
+ */
802
+ getAll(scope?: ConfigurationScope): Record<string, any> | undefined;
803
+ /**
804
+ * 设置配置值
805
+ * @param key 配置键名,支持点号分隔的嵌套路径
806
+ * @param value 新的配置值
807
+ * @param scope 配置作用域,默认为 'project'
808
+ */
809
+ set<T>(key: string, value: T, scope?: ConfigurationScope): Promise<boolean>;
810
+ /**
811
+ * 移除配置值
812
+ * @param key 配置键名,支持点号分隔的嵌套路径
813
+ * @param scope 配置作用域,默认为 'project'
814
+ */
815
+ remove(key: string, scope?: ConfigurationScope): Promise<boolean>;
816
+ /**
817
+ * 保存配置
818
+ */
819
+ save(): Promise<boolean>;
820
+ }
821
+
755
822
  /**
756
823
  * 配置的格式
757
824
  */
@@ -1034,6 +1101,8 @@ declare interface MeshSimplifyOptions {
1034
1101
  lockBoundary?: boolean;
1035
1102
  }
1036
1103
 
1104
+ declare function migrate(): Promise<void>;
1105
+
1037
1106
  declare function migrateFromProject(): Promise<IConfiguration>;
1038
1107
 
1039
1108
  /**
@@ -1060,6 +1129,99 @@ declare enum NormalImportSetting {
1060
1129
  recalculate = 3
1061
1130
  }
1062
1131
 
1132
+ /**
1133
+ * Listen to Asset Added Event // 监听资源添加事件
1134
+ * @param listener Callback function that receives asset information
1135
+ * @returns Function to remove the listener
1136
+ *
1137
+ * 推荐用法:
1138
+ * ```typescript
1139
+ * const removeListener = onAssetAdded((info) => {
1140
+ * console.log(`资源已添加: ${info.name}`);
1141
+ * console.log(` 逻辑路径: ${info.url}`);
1142
+ * console.log(` 物理路径: ${info.file}`);
1143
+ * });
1144
+ * // 稍后移除监听
1145
+ * removeListener();
1146
+ * ```
1147
+ */
1148
+ declare function onAssetAdded(listener: (info: IAssetInfo) => void): () => void;
1149
+
1150
+ /**
1151
+ * Listen to Asset Changed Event // 监听资源变更事件
1152
+ * @param listener Callback function that receives asset information
1153
+ * @returns Function to remove the listener
1154
+ *
1155
+ * 推荐用法:
1156
+ * ```typescript
1157
+ * const removeListener = onAssetChanged((info) => {
1158
+ * console.log(`资源已变更: ${info.name}`);
1159
+ * });
1160
+ * // 稍后移除监听
1161
+ * removeListener();
1162
+ * ```
1163
+ */
1164
+ declare function onAssetChanged(listener: (info: IAssetInfo) => void): () => void;
1165
+
1166
+ /**
1167
+ * Listen to Asset Removed Event // 监听资源删除事件
1168
+ * @param listener Callback function that receives asset information
1169
+ * @returns Function to remove the listener
1170
+ *
1171
+ * 推荐用法:
1172
+ * ```typescript
1173
+ * const removeListener = onAssetRemoved((info) => {
1174
+ * console.log(`资源已删除: ${info.name}`);
1175
+ * });
1176
+ * // 稍后移除监听
1177
+ * removeListener();
1178
+ * ```
1179
+ */
1180
+ declare function onAssetRemoved(listener: (info: IAssetInfo) => void): () => void;
1181
+
1182
+ /**
1183
+ * Register listener for when a specific database finishes starting.
1184
+ *
1185
+ * 注册单个数据库启动完成后的事件监听。
1186
+ *
1187
+ * **注意事项 (Notice)**:
1188
+ * - 这个事件可能会被触发多次(如果项目存在多个子数据库,如 `assets`, `internal`)。
1189
+ * - 主要用于需要做更精细化并行控制的上层逻辑,通常情况下普通的业务逻辑不需要关心此事件,直接监听 `onReady` 即可。
1190
+ *
1191
+ * @param listener 回调函数,接收启动完成的 dbInfo
1192
+ * @returns 移除监听的函数
1193
+ */
1194
+ declare function onDBReady(listener: (dbInfo: IAssetDBInfo) => void): () => void;
1195
+
1196
+ /**
1197
+ * Register listener for initialization progress.
1198
+ *
1199
+ * 注册初始化过程中的进度监听。
1200
+ *
1201
+ * **注意事项 (Notice)**:
1202
+ * - **仅在启动阶段有效**。一旦触发过一次 `ready` 事件(即启动阶段结束),将不再会有新的进度消息。
1203
+ * - 启动时的资源冷导入会抛出密集的进度信息,建议在 UI 层面进行适当的节流(throttle)渲染。
1204
+ *
1205
+ * @param listener 回调函数,包含当前进度、总数、当前处理的资源 url 和导入状态
1206
+ * @returns 移除监听的函数
1207
+ */
1208
+ declare function onProgress(listener: (current: number, total: number, url: string, state: 'processing' | 'success' | 'failed') => void): () => void;
1209
+
1210
+ /**
1211
+ * Register listener for when all asset databases are fully initialized.
1212
+ *
1213
+ * 注册数据库初始化完全完成后的事件监听。
1214
+ *
1215
+ * **注意事项 (Notice)**:
1216
+ * - 触发此事件代表**所有**注册的资源数据库都已经完全导入并初始化完成(启动阶段结束)。
1217
+ * - 收到此事件后,表示所有的资源查询、操作 API 都可以安全调用。
1218
+ * - 第一次 ready 后,将不再有 progress 进度消息。
1219
+ *
1220
+ * @param listener 回调函数
1221
+ * @returns 移除监听的函数
1222
+ */
1223
+ declare function onReady(listener: () => void): () => void;
1224
+
1063
1225
  declare function open_2(projectPath: string): Promise<void>;
1064
1226
 
1065
1227
  /** 粒子资源的 userData */
@@ -1243,6 +1405,8 @@ declare function reimportAsset(pathOrUrlOrUUID: string): Promise<IAssetInfo>;
1243
1405
 
1244
1406
  declare function reload(): Promise<void>;
1245
1407
 
1408
+ declare function remove(key: string, scope?: ConfigurationScope): Promise<boolean>;
1409
+
1246
1410
  /**
1247
1411
  * Rename Asset // 重命名资源
1248
1412
  */
@@ -1264,6 +1428,8 @@ declare interface RtSpriteFrameAssetUserData {
1264
1428
  height?: number;
1265
1429
  }
1266
1430
 
1431
+ declare function save(force?: boolean): Promise<void>;
1432
+
1267
1433
  /**
1268
1434
  * Save Asset // 保存资源
1269
1435
  */
@@ -1289,6 +1455,8 @@ declare interface SerializedAssetFinder {
1289
1455
  scenes?: Array<string | null>;
1290
1456
  }
1291
1457
 
1458
+ declare function set<T>(key: string, value: T, scope?: ConfigurationScope): Promise<boolean>;
1459
+
1292
1460
  declare interface SimplifyOptions {
1293
1461
  // 压缩比例
1294
1462
  targetRatio?: number;
@@ -1359,6 +1527,11 @@ declare interface SpriteFrameVertices {
1359
1527
  maxPos: number[];
1360
1528
  }
1361
1529
 
1530
+ /**
1531
+ * Start Asset DB // 启动资源数据库,开始扫描和导入资源
1532
+ */
1533
+ declare function start(): Promise<void>;
1534
+
1362
1535
  /** 支持创建的资源类型常量数组(用于 Zod enum 和 TypeScript type) */
1363
1536
  declare const SUPPORT_CREATE_TYPES: readonly ['animation-clip', 'typescript', 'auto-atlas', 'effect', 'scene', 'prefab', 'material', 'terrain', 'physics-material', 'label-atlas', 'render-texture', 'directory', 'effect-header'];
1364
1537
 
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.15.1",
5
+ "version": "0.0.1-alpha.17.1",
6
6
  "main": "index.d.ts",
7
7
  "types": "index.d.ts",
8
8
  "files": [