@cocos/cocos-cli-types 0.0.1-alpha.24.2 → 0.0.1-alpha.25.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 (4) hide show
  1. package/assets.d.ts +1 -1
  2. package/cli.d.ts +36 -211
  3. package/index.d.ts +37 -212
  4. package/package.json +1 -1
package/assets.d.ts CHANGED
@@ -1238,7 +1238,7 @@ export declare function reimportAsset(pathOrUrlOrUUID: string): Promise<IAssetIn
1238
1238
  /**
1239
1239
  * Rename Asset // 重命名资源
1240
1240
  */
1241
- export declare function renameAsset(source: string, target: string, options?: AssetOperationOption): Promise<any>;
1241
+ export declare function renameAsset(source: string, newName: string, options?: AssetOperationOption): Promise<any>;
1242
1242
 
1243
1243
  /** 渲染纹理资源的 userData */
1244
1244
  export declare interface RenderTextureAssetUserData extends TextureBaseAssetUserData {
package/cli.d.ts CHANGED
@@ -485,7 +485,7 @@ export declare interface GlTFUserData {
485
485
  * 添加/创建组件的选项
486
486
  */
487
487
  export declare interface IAddComponentOptions {
488
- nodePath: string;
488
+ nodePathOrUuid: string;
489
489
  component: string;
490
490
  }
491
491
 
@@ -689,31 +689,31 @@ export declare interface IComponentService extends IServiceEvents {
689
689
  /**
690
690
  * 添加组件到指定节点,返回添加后的组件信息
691
691
  * @param params - 添加组件选项
692
- * @param params.nodePath - 目标节点路径
692
+ * @param params.nodePathOrUuid - 目标节点路径或 UUID
693
693
  * @param params.component - 组件类名,支持精确匹配('cc.Label')和模糊匹配('label')
694
694
  * @returns 添加成功后的组件信息
695
695
  *
696
696
  * @example
697
697
  * ```ts
698
698
  * // 通过节点路径 + 精确组件名
699
- * const comp = await add({ nodePath: 'Canvas/MyNode', component: 'cc.Label' });
699
+ * const comp = await addComponent({ nodePathOrUuid: 'Canvas/MyNode', component: 'cc.Label' });
700
700
  *
701
- * // 通过节点路径 + 模糊组件名
702
- * const comp = await add({ nodePath: 'Canvas/MyNode', component: 'label' });
701
+ * // 通过节点 UUID + 模糊组件名
702
+ * const comp = await addComponent({ nodePathOrUuid: 'abc-123-uuid', component: 'label' });
703
703
  * ```
704
704
  */
705
- add(params: IAddComponentOptions): Promise<IComponent>;
705
+ addComponent(params: IAddComponentOptions): Promise<IComponent>;
706
706
  /**
707
707
  * 删除指定组件
708
708
  * @param params - 删除组件选项
709
- * @param params.path - 组件路径
709
+ * @param params.path - 组件路径,支持路径、UUID 或资源 URL
710
710
  * @returns 删除成功返回 true,失败返回 false
711
711
  */
712
- remove(params: IRemoveComponentOptions): Promise<boolean>;
712
+ removeComponent(params: IRemoveComponentOptions): Promise<boolean>;
713
713
  /**
714
714
  * 设置组件属性
715
715
  * - CLI 调用时传入 ISetPropertyOptions,通过 componentPath 定位,属性为扁平键值对
716
- * - 编辑器调用时传入 ISetPropertyOptionsForEditor,通过节点路径 + dump 路径定位,属性为 IProperty 格式
716
+ * - 编辑器调用时传入 ISetPropertyOptionsForEditor,通过节点 UUID + dump 路径定位,属性为 IProperty 格式
717
717
  *
718
718
  * @param params - 设置属性选项,根据调用方不同传入不同类型
719
719
  * @returns 设置成功返回 true,失败返回 false
@@ -726,9 +726,9 @@ export declare interface IComponentService extends IServiceEvents {
726
726
  * properties: { string: 'Hello', fontSize: 32 },
727
727
  * });
728
728
  *
729
- * // 编辑器方式:通过节点路径 + dump 路径定位,传 IProperty 格式
729
+ * // 编辑器方式:通过节点 UUID + dump 路径定位,传 IProperty 格式
730
730
  * await setProperty({
731
- * nodePath: 'Canvas/MyNode',
731
+ * uuid: 'node-uuid',
732
732
  * path: '__comps__.0.string',
733
733
  * dump: { value: 'Hello', type: 'String' },
734
734
  * });
@@ -746,33 +746,33 @@ export declare interface IComponentService extends IServiceEvents {
746
746
  * @example
747
747
  * ```ts
748
748
  * CLI 模式:返回 IComponent(扁平属性)
749
- * const comp = await query({ path: 'Canvas/cc.Label_1' }) as IComponent;
749
+ * const comp = await queryComponent({ path: 'Canvas/cc.Label_1' }) as IComponent;
750
750
  *
751
751
  * 编辑器模式:直接传 string,这里是uuid,因为与cli重复了,也支持 path 和 url
752
- * const comp = await query('uuid') as IComponentForEditor;
752
+ * const comp = await queryComponent('uuid') as IComponentForEditor;
753
753
  * ```
754
754
  */
755
- query(params: IQueryComponentOptions | string): Promise<IComponent | IComponentForEditor | null>;
755
+ queryComponent(params: IQueryComponentOptions | string): Promise<IComponent | IComponentForEditor | null>;
756
756
  /**
757
757
  * 获取所有已注册的组件类名,包含内置与自定义组件
758
758
  * @returns 组件类名数组,如 ['cc.Label', 'cc.Sprite', 'MyCustomComponent']
759
759
  */
760
- queryAll(): Promise<string[]>;
760
+ queryAllComponent(): Promise<string[]>;
761
761
  /**
762
- * 创建组件(编辑器使用),与 add 不同的是仅返回是否成功
762
+ * 创建组件(编辑器使用),与 addComponent 不同的是仅返回是否成功
763
763
  * @param params - 添加组件选项
764
- * @param params.nodePath - 目标节点路径
764
+ * @param params.nodePathOrUuid - 目标节点路径或 UUID
765
765
  * @param params.component - 组件类名
766
766
  * @returns 创建成功返回 true,失败返回 false
767
767
  */
768
- create(params: IAddComponentOptions): Promise<boolean>;
768
+ createComponent(params: IAddComponentOptions): Promise<boolean>;
769
769
  /**
770
770
  * 复位组件,将组件所有属性恢复为默认值
771
771
  * @param params - 查询组件选项,用于定位要复位的组件
772
- * @param params.path - 组件路径
772
+ * @param params.path - 组件路径,支持路径、UUID 或资源 URL
773
773
  * @returns 复位成功返回 true,失败返回 false
774
774
  */
775
- reset(params: IQueryComponentOptions): Promise<boolean>;
775
+ resetComponent(params: IQueryComponentOptions): Promise<boolean>;
776
776
  /**
777
777
  * 获取所有注册类名,支持按继承关系过滤
778
778
  * @param options - 过滤选项,不传则返回所有注册类
@@ -797,25 +797,25 @@ export declare interface IComponentService extends IServiceEvents {
797
797
  }[]>;
798
798
  /**
799
799
  * 查询指定节点上所有组件暴露的可调用函数
800
- * @param path - 节点路径
800
+ * @param uuid - 节点 UUID
801
801
  * @returns 节点上组件的函数信息,节点不存在时返回空对象
802
802
  */
803
- queryFunctionOfNode(path: string): Promise<any>;
803
+ queryComponentFunctionOfNode(uuid: string): Promise<any>;
804
804
  /**
805
805
  * 执行组件上的指定方法
806
806
  * @param options - 执行选项
807
- * @param options.path - 组件路径,如 'Canvas/cc.Label_1'
807
+ * @param options.uuid - 组件实例的 UUID
808
808
  * @param options.name - 要执行的方法名,如 'onLoad'、'start'
809
809
  * @param options.args - 方法参数列表
810
810
  * @returns 执行成功返回 true,失败返回 false
811
811
  */
812
- executeMethod(options: IExecuteComponentMethodOptions): Promise<any>;
812
+ executeComponentMethod(options: IExecuteComponentMethodOptions): Promise<boolean>;
813
813
  /**
814
814
  * 查询指定名称的组件是否已注册(是否存在对应脚本)
815
815
  * @param name - 组件类名,如 'cc.Label'
816
816
  * @returns 存在返回 true,不存在返回 false
817
817
  */
818
- hasScript(name: string): Promise<boolean>;
818
+ queryComponentHasScript(name: string): Promise<boolean>;
819
819
  init(): void;
820
820
  unregisterCompMgrEvents(): void;
821
821
  }
@@ -921,7 +921,7 @@ export declare interface IEngineService extends IServiceEvents {
921
921
  * 执行组件方法的选项
922
922
  */
923
923
  export declare interface IExecuteComponentMethodOptions {
924
- path: string;
924
+ uuid: string;
925
925
  name: string;
926
926
  args: any[];
927
927
  }
@@ -1057,31 +1057,6 @@ export declare interface INode extends INodeIdentifier {
1057
1057
  prefab: IPrefabInfo | null;
1058
1058
  }
1059
1059
 
1060
- export declare interface INodeForEditor {
1061
- active: IProperty;
1062
- locked: IProperty;
1063
- name: IProperty;
1064
- position: IProperty;
1065
- /**
1066
- * 此为 dump 数据,非 node.rotation
1067
- * 实际指向 node.eulerAngles
1068
- * rotation 为了给用户更友好的文案
1069
- */
1070
- rotation: IProperty;
1071
- mobility: IProperty;
1072
- scale: IProperty;
1073
- layer: IProperty;
1074
- uuid: IProperty;
1075
- children: IProperty[];
1076
- parent: IProperty;
1077
- __comps__: IProperty[];
1078
- __type__: string;
1079
- __prefab__?: IPrefabForEditor;
1080
- _prefabInstance?: any;
1081
- removedComponents?: IRemovedComponentInfo[];
1082
- mountedRoot?: string;
1083
- }
1084
-
1085
1060
  export declare interface INodeIdentifier {
1086
1061
  nodeId: string;
1087
1062
  path: string;
@@ -1106,144 +1081,30 @@ export declare interface INodeService extends IServiceEvents {
1106
1081
  * 创建节点
1107
1082
  * @param params
1108
1083
  */
1109
- createByType(params: ICreateByNodeTypeParams): Promise<INode | null>;
1084
+ createNodeByType(params: ICreateByNodeTypeParams): Promise<INode | null>;
1110
1085
  /**
1111
1086
  * 创建节点
1112
1087
  * @param params
1113
1088
  */
1114
- createByAsset(params: ICreateByAssetParams): Promise<INode | null>;
1089
+ createNodeByAsset(params: ICreateByAssetParams): Promise<INode | null>;
1115
1090
  /**
1116
1091
  * 删除节点
1117
1092
  * @param params
1118
1093
  */
1119
- delete(params: IDeleteNodeParams): Promise<IDeleteNodeResult | null>;
1094
+ deleteNode(params: IDeleteNodeParams): Promise<IDeleteNodeResult | null>;
1120
1095
  /**
1121
1096
  * 更新节点
1122
1097
  * @param params
1123
1098
  */
1124
- update(params: IUpdateNodeParams): Promise<IUpdateNodeResult>;
1099
+ updateNode(params: IUpdateNodeParams): Promise<IUpdateNodeResult>;
1125
1100
  /**
1126
- * 查询节点信息
1127
- * - 不传参数时,返回当前场景的 dump 数据(ISceneForEditor)
1128
- * - 传入 string 时,返回指定路径节点的 dump 数据(编辑器模式,返回 INodeForEditor 数据)
1129
- * - 传入 IQueryNodeParams 时,返回 INode(CLI 模式)
1130
- *
1131
- * @param params - 查询选项、节点路径字符串或不传
1132
- * @returns 如果传入 IQueryNodeParams 返回 INode,如果传入 string 或不传返回 INodeForEditor 或 ISceneForEditor,未找到返回 null
1101
+ * 查询节点
1133
1102
  */
1134
- query(params?: IQueryNodeParams | string): Promise<INode | INodeForEditor | ISceneForEditor | null>;
1103
+ queryNode(params: IQueryNodeParams): Promise<INode | null>;
1135
1104
  /**
1136
1105
  * 查询节点树(层级管理器格式)
1137
1106
  */
1138
1107
  queryNodeTree(params: IQueryNodeTreeParams): Promise<INodeTreeItem | null>;
1139
- /**
1140
- * 预览设置节点属性,临时应用属性变更但不记录到 undo 栈
1141
- * 用于编辑器中拖拽滑块等实时预览场景,首次调用时会缓存原始值,
1142
- * 可通过 cancelPreviewSetProperty 恢复
1143
- *
1144
- * @param options - 设置属性选项
1145
- * @param options.nodePath - 节点路径
1146
- * @param options.path - 属性路径,如 'position'、'scale'
1147
- * @param options.dump - 属性的 dump 数据
1148
- * @returns 设置成功返回 true,节点或属性路径无效返回 false
1149
- *
1150
- * @example
1151
- * ```ts
1152
- * // 预览修改节点位置
1153
- * await previewSetProperty({
1154
- * nodePath: 'Canvas/MyNode',
1155
- * path: 'position',
1156
- * dump: { value: { x: 100, y: 200, z: 0 }, type: 'cc.Vec3' },
1157
- * });
1158
- * ```
1159
- */
1160
- previewSetProperty(options: ISetPropertyOptionsForEditor): Promise<boolean>;
1161
- /**
1162
- * 取消预览设置,将节点属性恢复到 previewSetProperty 调用前的值
1163
- * 仅使用 options.nodePath 和 options.path,options.dump 不会被使用
1164
- *
1165
- * @param options - 设置属性选项
1166
- * @param options.nodePath - 节点路径
1167
- * @param options.path - 属性路径
1168
- * @returns 恢复成功返回 true,无缓存的预览数据或节点无效返回 false
1169
- */
1170
- cancelPreviewSetProperty(options: ISetPropertyOptionsForEditor): Promise<boolean>;
1171
- /**
1172
- * 设置节点属性,会记录到 undo 栈
1173
- *
1174
- * @param options - 设置属性选项
1175
- * @param options.nodePath - 节点路径
1176
- * @param options.path - 属性路径,如 'position'、'rotation'、'layer'
1177
- * @param options.dump - 属性的 dump 数据
1178
- * @returns 设置成功返回 true,节点不存在返回 false
1179
- *
1180
- * @example
1181
- * ```ts
1182
- * await setProperty({
1183
- * nodePath: 'Canvas/MyNode',
1184
- * path: 'position',
1185
- * dump: { value: { x: 100, y: 200, z: 0 }, type: 'cc.Vec3' },
1186
- * });
1187
- * ```
1188
- */
1189
- setProperty(options: ISetPropertyOptionsForEditor): Promise<boolean>;
1190
- /**
1191
- * 重置节点的变换属性(position、rotation、scale、mobility)到默认值
1192
- *
1193
- * @param path - 节点路径
1194
- * @returns 重置成功返回 true,节点不存在返回 false
1195
- */
1196
- reset(path: string): Promise<boolean>;
1197
- /**
1198
- * 重置节点的单个属性到 CCClass 定义的默认值
1199
- * 仅使用 options.nodePath 和 options.path,options.dump 不会被使用
1200
- *
1201
- * @param options - 设置属性选项
1202
- * @param options.nodePath - 节点路径
1203
- * @param options.path - 属性路径,如 'position'、'scale'
1204
- * @returns 重置成功返回 true,节点不存在返回 false
1205
- */
1206
- resetProperty(options: ISetPropertyOptionsForEditor): Promise<boolean>;
1207
- /**
1208
- * 将节点上值为 null 的属性初始化为默认实例
1209
- * 当属性为 null 且有定义构造函数类型时,会创建该类型的新实例
1210
- * 仅使用 options.nodePath 和 options.path,options.dump 不会被使用
1211
- *
1212
- * @param options - 设置属性选项
1213
- * @param options.nodePath - 节点路径
1214
- * @param options.path - 属性路径
1215
- * @returns 初始化成功返回 true,节点不存在返回 false
1216
- *
1217
- * @example
1218
- * ```ts
1219
- * // 将节点上值为 null 的自定义属性初始化
1220
- * await updatePropertyFromNull({
1221
- * nodePath: 'Canvas/MyNode',
1222
- * path: 'customProperty',
1223
- * dump: {} as IProperty,
1224
- * });
1225
- * ```
1226
- */
1227
- updatePropertyFromNull(options: ISetPropertyOptionsForEditor): Promise<boolean>;
1228
- /**
1229
- * 设置节点及其所有子节点的 layer 属性
1230
- * 递归将相同的 layer 值应用到整个节点子树
1231
- * 仅使用 options.nodePath 和 options.dump,options.path 不会被使用(内部固定为 'layer')
1232
- *
1233
- * @param options - 设置属性选项
1234
- * @param options.nodePath - 节点路径
1235
- * @param options.dump - layer 属性的 dump 数据
1236
- *
1237
- * @example
1238
- * ```ts
1239
- * await setNodeAndChildrenLayer({
1240
- * nodePath: 'Canvas/MyNode',
1241
- * path: 'layer',
1242
- * dump: { value: 1 << 25, type: 'Enum' },
1243
- * });
1244
- * ```
1245
- */
1246
- setNodeAndChildrenLayer(options: ISetPropertyOptionsForEditor): Promise<void>;
1247
1108
  }
1248
1109
 
1249
1110
  export declare interface INodeTreeComponent {
@@ -1294,16 +1155,6 @@ export declare interface IPrefab {
1294
1155
  persistent: boolean;
1295
1156
  }
1296
1157
 
1297
- export declare interface IPrefabForEditor {
1298
- uuid: string;
1299
- fileId: string;
1300
- rootUuid: string;
1301
- sync: boolean;
1302
- prefabStateInfo: IPrefabStateInfo;
1303
- targetOverrides?: ITargetOverrideInfoForEditor[];
1304
- instance?: IProperty;
1305
- }
1306
-
1307
1158
  export declare interface IPrefabInfo {
1308
1159
  /** 关联的预制体资源信息 */
1309
1160
  asset?: IPrefab;
@@ -1497,11 +1348,6 @@ export declare interface IRemoveComponentOptions {
1497
1348
  path: string;
1498
1349
  }
1499
1350
 
1500
- export declare interface IRemovedComponentInfo {
1501
- name: string;
1502
- fileID: string;
1503
- }
1504
-
1505
1351
  export declare interface IRevertToPrefabParams {
1506
1352
  nodePath: string;
1507
1353
  }
@@ -1523,20 +1369,6 @@ export declare interface IScene extends IBaseIdentifier {
1523
1369
  components: IComponentIdentifier[];
1524
1370
  }
1525
1371
 
1526
- export declare interface ISceneForEditor {
1527
- name: IProperty;
1528
- active: IProperty;
1529
- locked: IProperty;
1530
- _globals: Record<string, IProperty>;
1531
- isScene: boolean;
1532
- autoReleaseAssets: IProperty;
1533
- uuid: IProperty;
1534
- children: IProperty[];
1535
- parent: string;
1536
- __type__: string;
1537
- targetOverrides?: ITargetOverrideInfoForEditor[];
1538
- }
1539
-
1540
1372
  export declare interface ISceneMouseEvent {
1541
1373
  x: number;
1542
1374
  y: number;
@@ -1615,9 +1447,10 @@ export declare interface IServiceEvents {
1615
1447
  onSetPropertyComponent?(comp: Component): void;
1616
1448
  onComponentAdded?(comp: Component): void;
1617
1449
  onComponentRemoved?(comp: Component): void;
1618
- onBeforeChangeComponent?(node: Node_2): void;
1619
- onBeforeAddComponent?(name: string, node: Node_2): void;
1620
1450
  onBeforeRemoveComponent?(comp: Component): void;
1451
+ onComponentBeforeChanged?(node: Node_2): void;
1452
+ onBeforeComponentAdded?(name: string, node: Node_2): void;
1453
+ onComponentChanged?(name: string, opts: IChangeNodeOptions): void;
1621
1454
  onAssetDeleted?(uuid: string): void;
1622
1455
  onAssetChanged?(uuid: string): void;
1623
1456
  onAssetRefreshed?(uuid: string): void;
@@ -1658,7 +1491,7 @@ export declare interface ISetPropertyOptions {
1658
1491
  * 编辑器设置组件属性的选项
1659
1492
  */
1660
1493
  export declare interface ISetPropertyOptionsForEditor {
1661
- nodePath: string;
1494
+ uuid: string;
1662
1495
  path: string;
1663
1496
  dump: IProperty;
1664
1497
  record?: boolean;
@@ -1696,14 +1529,6 @@ export declare interface ITargetOverrideInfo {
1696
1529
  targetInfo: ITargetInfo | null;
1697
1530
  }
1698
1531
 
1699
- export declare interface ITargetOverrideInfoForEditor {
1700
- source: string;
1701
- sourceInfo?: string[];
1702
- propertyPath: string[];
1703
- target: string;
1704
- targetInfo?: string[];
1705
- }
1706
-
1707
1532
  export declare interface IUndoService {
1708
1533
  beginRecording(uuids: string[], options?: any): string;
1709
1534
  endRecording(commandId: string): void;
package/index.d.ts CHANGED
@@ -975,7 +975,7 @@ export declare namespace i18n {
975
975
  * 添加/创建组件的选项
976
976
  */
977
977
  export declare interface IAddComponentOptions {
978
- nodePath: string;
978
+ nodePathOrUuid: string;
979
979
  component: string;
980
980
  }
981
981
 
@@ -1274,31 +1274,31 @@ export declare interface IComponentService extends IServiceEvents {
1274
1274
  /**
1275
1275
  * 添加组件到指定节点,返回添加后的组件信息
1276
1276
  * @param params - 添加组件选项
1277
- * @param params.nodePath - 目标节点路径
1277
+ * @param params.nodePathOrUuid - 目标节点路径或 UUID
1278
1278
  * @param params.component - 组件类名,支持精确匹配('cc.Label')和模糊匹配('label')
1279
1279
  * @returns 添加成功后的组件信息
1280
1280
  *
1281
1281
  * @example
1282
1282
  * ```ts
1283
1283
  * // 通过节点路径 + 精确组件名
1284
- * const comp = await add({ nodePath: 'Canvas/MyNode', component: 'cc.Label' });
1284
+ * const comp = await addComponent({ nodePathOrUuid: 'Canvas/MyNode', component: 'cc.Label' });
1285
1285
  *
1286
- * // 通过节点路径 + 模糊组件名
1287
- * const comp = await add({ nodePath: 'Canvas/MyNode', component: 'label' });
1286
+ * // 通过节点 UUID + 模糊组件名
1287
+ * const comp = await addComponent({ nodePathOrUuid: 'abc-123-uuid', component: 'label' });
1288
1288
  * ```
1289
1289
  */
1290
- add(params: IAddComponentOptions): Promise<IComponent>;
1290
+ addComponent(params: IAddComponentOptions): Promise<IComponent>;
1291
1291
  /**
1292
1292
  * 删除指定组件
1293
1293
  * @param params - 删除组件选项
1294
- * @param params.path - 组件路径
1294
+ * @param params.path - 组件路径,支持路径、UUID 或资源 URL
1295
1295
  * @returns 删除成功返回 true,失败返回 false
1296
1296
  */
1297
- remove(params: IRemoveComponentOptions): Promise<boolean>;
1297
+ removeComponent(params: IRemoveComponentOptions): Promise<boolean>;
1298
1298
  /**
1299
1299
  * 设置组件属性
1300
1300
  * - CLI 调用时传入 ISetPropertyOptions,通过 componentPath 定位,属性为扁平键值对
1301
- * - 编辑器调用时传入 ISetPropertyOptionsForEditor,通过节点路径 + dump 路径定位,属性为 IProperty 格式
1301
+ * - 编辑器调用时传入 ISetPropertyOptionsForEditor,通过节点 UUID + dump 路径定位,属性为 IProperty 格式
1302
1302
  *
1303
1303
  * @param params - 设置属性选项,根据调用方不同传入不同类型
1304
1304
  * @returns 设置成功返回 true,失败返回 false
@@ -1311,9 +1311,9 @@ export declare interface IComponentService extends IServiceEvents {
1311
1311
  * properties: { string: 'Hello', fontSize: 32 },
1312
1312
  * });
1313
1313
  *
1314
- * // 编辑器方式:通过节点路径 + dump 路径定位,传 IProperty 格式
1314
+ * // 编辑器方式:通过节点 UUID + dump 路径定位,传 IProperty 格式
1315
1315
  * await setProperty({
1316
- * nodePath: 'Canvas/MyNode',
1316
+ * uuid: 'node-uuid',
1317
1317
  * path: '__comps__.0.string',
1318
1318
  * dump: { value: 'Hello', type: 'String' },
1319
1319
  * });
@@ -1331,33 +1331,33 @@ export declare interface IComponentService extends IServiceEvents {
1331
1331
  * @example
1332
1332
  * ```ts
1333
1333
  * CLI 模式:返回 IComponent(扁平属性)
1334
- * const comp = await query({ path: 'Canvas/cc.Label_1' }) as IComponent;
1334
+ * const comp = await queryComponent({ path: 'Canvas/cc.Label_1' }) as IComponent;
1335
1335
  *
1336
1336
  * 编辑器模式:直接传 string,这里是uuid,因为与cli重复了,也支持 path 和 url
1337
- * const comp = await query('uuid') as IComponentForEditor;
1337
+ * const comp = await queryComponent('uuid') as IComponentForEditor;
1338
1338
  * ```
1339
1339
  */
1340
- query(params: IQueryComponentOptions | string): Promise<IComponent | IComponentForEditor | null>;
1340
+ queryComponent(params: IQueryComponentOptions | string): Promise<IComponent | IComponentForEditor | null>;
1341
1341
  /**
1342
1342
  * 获取所有已注册的组件类名,包含内置与自定义组件
1343
1343
  * @returns 组件类名数组,如 ['cc.Label', 'cc.Sprite', 'MyCustomComponent']
1344
1344
  */
1345
- queryAll(): Promise<string[]>;
1345
+ queryAllComponent(): Promise<string[]>;
1346
1346
  /**
1347
- * 创建组件(编辑器使用),与 add 不同的是仅返回是否成功
1347
+ * 创建组件(编辑器使用),与 addComponent 不同的是仅返回是否成功
1348
1348
  * @param params - 添加组件选项
1349
- * @param params.nodePath - 目标节点路径
1349
+ * @param params.nodePathOrUuid - 目标节点路径或 UUID
1350
1350
  * @param params.component - 组件类名
1351
1351
  * @returns 创建成功返回 true,失败返回 false
1352
1352
  */
1353
- create(params: IAddComponentOptions): Promise<boolean>;
1353
+ createComponent(params: IAddComponentOptions): Promise<boolean>;
1354
1354
  /**
1355
1355
  * 复位组件,将组件所有属性恢复为默认值
1356
1356
  * @param params - 查询组件选项,用于定位要复位的组件
1357
- * @param params.path - 组件路径
1357
+ * @param params.path - 组件路径,支持路径、UUID 或资源 URL
1358
1358
  * @returns 复位成功返回 true,失败返回 false
1359
1359
  */
1360
- reset(params: IQueryComponentOptions): Promise<boolean>;
1360
+ resetComponent(params: IQueryComponentOptions): Promise<boolean>;
1361
1361
  /**
1362
1362
  * 获取所有注册类名,支持按继承关系过滤
1363
1363
  * @param options - 过滤选项,不传则返回所有注册类
@@ -1382,25 +1382,25 @@ export declare interface IComponentService extends IServiceEvents {
1382
1382
  }[]>;
1383
1383
  /**
1384
1384
  * 查询指定节点上所有组件暴露的可调用函数
1385
- * @param path - 节点路径
1385
+ * @param uuid - 节点 UUID
1386
1386
  * @returns 节点上组件的函数信息,节点不存在时返回空对象
1387
1387
  */
1388
- queryFunctionOfNode(path: string): Promise<any>;
1388
+ queryComponentFunctionOfNode(uuid: string): Promise<any>;
1389
1389
  /**
1390
1390
  * 执行组件上的指定方法
1391
1391
  * @param options - 执行选项
1392
- * @param options.path - 组件路径,如 'Canvas/cc.Label_1'
1392
+ * @param options.uuid - 组件实例的 UUID
1393
1393
  * @param options.name - 要执行的方法名,如 'onLoad'、'start'
1394
1394
  * @param options.args - 方法参数列表
1395
1395
  * @returns 执行成功返回 true,失败返回 false
1396
1396
  */
1397
- executeMethod(options: IExecuteComponentMethodOptions): Promise<any>;
1397
+ executeComponentMethod(options: IExecuteComponentMethodOptions): Promise<boolean>;
1398
1398
  /**
1399
1399
  * 查询指定名称的组件是否已注册(是否存在对应脚本)
1400
1400
  * @param name - 组件类名,如 'cc.Label'
1401
1401
  * @returns 存在返回 true,不存在返回 false
1402
1402
  */
1403
- hasScript(name: string): Promise<boolean>;
1403
+ queryComponentHasScript(name: string): Promise<boolean>;
1404
1404
  init(): void;
1405
1405
  unregisterCompMgrEvents(): void;
1406
1406
  }
@@ -1638,7 +1638,7 @@ export declare interface IEngineService extends IServiceEvents {
1638
1638
  * 执行组件方法的选项
1639
1639
  */
1640
1640
  export declare interface IExecuteComponentMethodOptions {
1641
- path: string;
1641
+ uuid: string;
1642
1642
  name: string;
1643
1643
  args: any[];
1644
1644
  }
@@ -1892,31 +1892,6 @@ export declare interface INode extends INodeIdentifier {
1892
1892
  prefab: IPrefabInfo | null;
1893
1893
  }
1894
1894
 
1895
- export declare interface INodeForEditor {
1896
- active: IProperty;
1897
- locked: IProperty;
1898
- name: IProperty;
1899
- position: IProperty;
1900
- /**
1901
- * 此为 dump 数据,非 node.rotation
1902
- * 实际指向 node.eulerAngles
1903
- * rotation 为了给用户更友好的文案
1904
- */
1905
- rotation: IProperty;
1906
- mobility: IProperty;
1907
- scale: IProperty;
1908
- layer: IProperty;
1909
- uuid: IProperty;
1910
- children: IProperty[];
1911
- parent: IProperty;
1912
- __comps__: IProperty[];
1913
- __type__: string;
1914
- __prefab__?: IPrefabForEditor;
1915
- _prefabInstance?: any;
1916
- removedComponents?: IRemovedComponentInfo[];
1917
- mountedRoot?: string;
1918
- }
1919
-
1920
1895
  export declare interface INodeIdentifier {
1921
1896
  nodeId: string;
1922
1897
  path: string;
@@ -1941,144 +1916,30 @@ export declare interface INodeService extends IServiceEvents {
1941
1916
  * 创建节点
1942
1917
  * @param params
1943
1918
  */
1944
- createByType(params: ICreateByNodeTypeParams): Promise<INode | null>;
1919
+ createNodeByType(params: ICreateByNodeTypeParams): Promise<INode | null>;
1945
1920
  /**
1946
1921
  * 创建节点
1947
1922
  * @param params
1948
1923
  */
1949
- createByAsset(params: ICreateByAssetParams): Promise<INode | null>;
1924
+ createNodeByAsset(params: ICreateByAssetParams): Promise<INode | null>;
1950
1925
  /**
1951
1926
  * 删除节点
1952
1927
  * @param params
1953
1928
  */
1954
- delete(params: IDeleteNodeParams): Promise<IDeleteNodeResult | null>;
1929
+ deleteNode(params: IDeleteNodeParams): Promise<IDeleteNodeResult | null>;
1955
1930
  /**
1956
1931
  * 更新节点
1957
1932
  * @param params
1958
1933
  */
1959
- update(params: IUpdateNodeParams): Promise<IUpdateNodeResult>;
1934
+ updateNode(params: IUpdateNodeParams): Promise<IUpdateNodeResult>;
1960
1935
  /**
1961
- * 查询节点信息
1962
- * - 不传参数时,返回当前场景的 dump 数据(ISceneForEditor)
1963
- * - 传入 string 时,返回指定路径节点的 dump 数据(编辑器模式,返回 INodeForEditor 数据)
1964
- * - 传入 IQueryNodeParams 时,返回 INode(CLI 模式)
1965
- *
1966
- * @param params - 查询选项、节点路径字符串或不传
1967
- * @returns 如果传入 IQueryNodeParams 返回 INode,如果传入 string 或不传返回 INodeForEditor 或 ISceneForEditor,未找到返回 null
1936
+ * 查询节点
1968
1937
  */
1969
- query(params?: IQueryNodeParams | string): Promise<INode | INodeForEditor | ISceneForEditor | null>;
1938
+ queryNode(params: IQueryNodeParams): Promise<INode | null>;
1970
1939
  /**
1971
1940
  * 查询节点树(层级管理器格式)
1972
1941
  */
1973
1942
  queryNodeTree(params: IQueryNodeTreeParams): Promise<INodeTreeItem | null>;
1974
- /**
1975
- * 预览设置节点属性,临时应用属性变更但不记录到 undo 栈
1976
- * 用于编辑器中拖拽滑块等实时预览场景,首次调用时会缓存原始值,
1977
- * 可通过 cancelPreviewSetProperty 恢复
1978
- *
1979
- * @param options - 设置属性选项
1980
- * @param options.nodePath - 节点路径
1981
- * @param options.path - 属性路径,如 'position'、'scale'
1982
- * @param options.dump - 属性的 dump 数据
1983
- * @returns 设置成功返回 true,节点或属性路径无效返回 false
1984
- *
1985
- * @example
1986
- * ```ts
1987
- * // 预览修改节点位置
1988
- * await previewSetProperty({
1989
- * nodePath: 'Canvas/MyNode',
1990
- * path: 'position',
1991
- * dump: { value: { x: 100, y: 200, z: 0 }, type: 'cc.Vec3' },
1992
- * });
1993
- * ```
1994
- */
1995
- previewSetProperty(options: ISetPropertyOptionsForEditor): Promise<boolean>;
1996
- /**
1997
- * 取消预览设置,将节点属性恢复到 previewSetProperty 调用前的值
1998
- * 仅使用 options.nodePath 和 options.path,options.dump 不会被使用
1999
- *
2000
- * @param options - 设置属性选项
2001
- * @param options.nodePath - 节点路径
2002
- * @param options.path - 属性路径
2003
- * @returns 恢复成功返回 true,无缓存的预览数据或节点无效返回 false
2004
- */
2005
- cancelPreviewSetProperty(options: ISetPropertyOptionsForEditor): Promise<boolean>;
2006
- /**
2007
- * 设置节点属性,会记录到 undo 栈
2008
- *
2009
- * @param options - 设置属性选项
2010
- * @param options.nodePath - 节点路径
2011
- * @param options.path - 属性路径,如 'position'、'rotation'、'layer'
2012
- * @param options.dump - 属性的 dump 数据
2013
- * @returns 设置成功返回 true,节点不存在返回 false
2014
- *
2015
- * @example
2016
- * ```ts
2017
- * await setProperty({
2018
- * nodePath: 'Canvas/MyNode',
2019
- * path: 'position',
2020
- * dump: { value: { x: 100, y: 200, z: 0 }, type: 'cc.Vec3' },
2021
- * });
2022
- * ```
2023
- */
2024
- setProperty(options: ISetPropertyOptionsForEditor): Promise<boolean>;
2025
- /**
2026
- * 重置节点的变换属性(position、rotation、scale、mobility)到默认值
2027
- *
2028
- * @param path - 节点路径
2029
- * @returns 重置成功返回 true,节点不存在返回 false
2030
- */
2031
- reset(path: string): Promise<boolean>;
2032
- /**
2033
- * 重置节点的单个属性到 CCClass 定义的默认值
2034
- * 仅使用 options.nodePath 和 options.path,options.dump 不会被使用
2035
- *
2036
- * @param options - 设置属性选项
2037
- * @param options.nodePath - 节点路径
2038
- * @param options.path - 属性路径,如 'position'、'scale'
2039
- * @returns 重置成功返回 true,节点不存在返回 false
2040
- */
2041
- resetProperty(options: ISetPropertyOptionsForEditor): Promise<boolean>;
2042
- /**
2043
- * 将节点上值为 null 的属性初始化为默认实例
2044
- * 当属性为 null 且有定义构造函数类型时,会创建该类型的新实例
2045
- * 仅使用 options.nodePath 和 options.path,options.dump 不会被使用
2046
- *
2047
- * @param options - 设置属性选项
2048
- * @param options.nodePath - 节点路径
2049
- * @param options.path - 属性路径
2050
- * @returns 初始化成功返回 true,节点不存在返回 false
2051
- *
2052
- * @example
2053
- * ```ts
2054
- * // 将节点上值为 null 的自定义属性初始化
2055
- * await updatePropertyFromNull({
2056
- * nodePath: 'Canvas/MyNode',
2057
- * path: 'customProperty',
2058
- * dump: {} as IProperty,
2059
- * });
2060
- * ```
2061
- */
2062
- updatePropertyFromNull(options: ISetPropertyOptionsForEditor): Promise<boolean>;
2063
- /**
2064
- * 设置节点及其所有子节点的 layer 属性
2065
- * 递归将相同的 layer 值应用到整个节点子树
2066
- * 仅使用 options.nodePath 和 options.dump,options.path 不会被使用(内部固定为 'layer')
2067
- *
2068
- * @param options - 设置属性选项
2069
- * @param options.nodePath - 节点路径
2070
- * @param options.dump - layer 属性的 dump 数据
2071
- *
2072
- * @example
2073
- * ```ts
2074
- * await setNodeAndChildrenLayer({
2075
- * nodePath: 'Canvas/MyNode',
2076
- * path: 'layer',
2077
- * dump: { value: 1 << 25, type: 'Enum' },
2078
- * });
2079
- * ```
2080
- */
2081
- setNodeAndChildrenLayer(options: ISetPropertyOptionsForEditor): Promise<void>;
2082
1943
  }
2083
1944
 
2084
1945
  export declare interface INodeTreeComponent {
@@ -2159,16 +2020,6 @@ export declare interface IPrefab {
2159
2020
  persistent: boolean;
2160
2021
  }
2161
2022
 
2162
- export declare interface IPrefabForEditor {
2163
- uuid: string;
2164
- fileId: string;
2165
- rootUuid: string;
2166
- sync: boolean;
2167
- prefabStateInfo: IPrefabStateInfo;
2168
- targetOverrides?: ITargetOverrideInfoForEditor[];
2169
- instance?: IProperty;
2170
- }
2171
-
2172
2023
  export declare interface IPrefabInfo {
2173
2024
  /** 关联的预制体资源信息 */
2174
2025
  asset?: IPrefab;
@@ -2435,11 +2286,6 @@ export declare interface IRemoveComponentOptions {
2435
2286
  path: string;
2436
2287
  }
2437
2288
 
2438
- export declare interface IRemovedComponentInfo {
2439
- name: string;
2440
- fileID: string;
2441
- }
2442
-
2443
2289
  export declare interface IRevertToPrefabParams {
2444
2290
  nodePath: string;
2445
2291
  }
@@ -2461,20 +2307,6 @@ export declare interface IScene extends IBaseIdentifier {
2461
2307
  components: IComponentIdentifier[];
2462
2308
  }
2463
2309
 
2464
- export declare interface ISceneForEditor {
2465
- name: IProperty;
2466
- active: IProperty;
2467
- locked: IProperty;
2468
- _globals: Record<string, IProperty>;
2469
- isScene: boolean;
2470
- autoReleaseAssets: IProperty;
2471
- uuid: IProperty;
2472
- children: IProperty[];
2473
- parent: string;
2474
- __type__: string;
2475
- targetOverrides?: ITargetOverrideInfoForEditor[];
2476
- }
2477
-
2478
2310
  export declare interface ISceneMouseEvent {
2479
2311
  x: number;
2480
2312
  y: number;
@@ -2553,9 +2385,10 @@ export declare interface IServiceEvents {
2553
2385
  onSetPropertyComponent?(comp: Component): void;
2554
2386
  onComponentAdded?(comp: Component): void;
2555
2387
  onComponentRemoved?(comp: Component): void;
2556
- onBeforeChangeComponent?(node: Node_2): void;
2557
- onBeforeAddComponent?(name: string, node: Node_2): void;
2558
2388
  onBeforeRemoveComponent?(comp: Component): void;
2389
+ onComponentBeforeChanged?(node: Node_2): void;
2390
+ onBeforeComponentAdded?(name: string, node: Node_2): void;
2391
+ onComponentChanged?(name: string, opts: IChangeNodeOptions): void;
2559
2392
  onAssetDeleted?(uuid: string): void;
2560
2393
  onAssetChanged?(uuid: string): void;
2561
2394
  onAssetRefreshed?(uuid: string): void;
@@ -2596,7 +2429,7 @@ export declare interface ISetPropertyOptions {
2596
2429
  * 编辑器设置组件属性的选项
2597
2430
  */
2598
2431
  export declare interface ISetPropertyOptionsForEditor {
2599
- nodePath: string;
2432
+ uuid: string;
2600
2433
  path: string;
2601
2434
  dump: IProperty;
2602
2435
  record?: boolean;
@@ -2670,14 +2503,6 @@ export declare interface ITargetOverrideInfo {
2670
2503
  targetInfo: ITargetInfo | null;
2671
2504
  }
2672
2505
 
2673
- export declare interface ITargetOverrideInfoForEditor {
2674
- source: string;
2675
- sourceInfo?: string[];
2676
- propertyPath: string[];
2677
- target: string;
2678
- targetInfo?: string[];
2679
- }
2680
-
2681
2506
  export declare interface IUerDataConfigItem {
2682
2507
  key?: string; // 唯一标识符
2683
2508
  // 配置显示的名字,如果需要翻译,则传入 i18n:${key}
@@ -3507,7 +3332,7 @@ export declare function remove(key: string, scope?: ConfigurationScope): Promise
3507
3332
  /**
3508
3333
  * Rename Asset // 重命名资源
3509
3334
  */
3510
- export declare function renameAsset(source: string, target: string, options?: AssetOperationOption): Promise<any>;
3335
+ export declare function renameAsset(source: string, newName: string, options?: AssetOperationOption): Promise<any>;
3511
3336
 
3512
3337
  /** 渲染纹理资源的 userData */
3513
3338
  export declare interface RenderTextureAssetUserData extends TextureBaseAssetUserData {
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.24.2",
5
+ "version": "0.0.1-alpha.25.1",
6
6
  "main": "index.d.ts",
7
7
  "types": "index.d.ts",
8
8
  "exports": {