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

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.
@@ -9,6 +9,8 @@ declare type EventEmitterMethods = Pick<EventEmitter, 'on' | 'off' | 'once' | 'e
9
9
 
10
10
  export declare function get<T>(key: string, scope?: ConfigurationScope): Promise<T>;
11
11
 
12
+ export declare function getMetadata(): Promise<ICocosConfigurationNode[]>;
13
+
12
14
  /**
13
15
  * 配置基类接口
14
16
  */
@@ -51,6 +53,36 @@ export declare interface IBaseConfiguration extends EventEmitterMethods {
51
53
  save(): Promise<boolean>;
52
54
  }
53
55
 
56
+ export declare interface ICocosConfigurationNode {
57
+ id: string;
58
+ title: string;
59
+ group: string;
60
+ order?: number;
61
+ properties: Record<string, ICocosConfigurationPropertySchema>;
62
+ }
63
+
64
+ /**
65
+ * Cocos 配置元数据定义。
66
+ *
67
+ * 基于 COCOS_CONFIG 类型(@types/cocos.config.d.ts)展开,
68
+ * 按 group(顶级模块) → node(二级字段) 组织。
69
+ *
70
+ * 供 Pink 配置面板渲染使用,通过 CocosHostConfiguration.getMetadata() 返回。
71
+ */
72
+ export declare interface ICocosConfigurationPropertySchema {
73
+ type: 'string' | 'number' | 'boolean' | 'object' | 'array';
74
+ default?: unknown;
75
+ title?: string;
76
+ description?: string;
77
+ scope: string[];
78
+ enum?: any[];
79
+ enumDescriptions?: string[];
80
+ minimum?: number;
81
+ maximum?: number;
82
+ step?: number;
83
+ order?: number;
84
+ }
85
+
54
86
  /**
55
87
  * 配置的格式
56
88
  */
package/engine.d.ts CHANGED
@@ -352,4 +352,6 @@ export declare interface ModuleRenderConfig {
352
352
  migrationScript?: string;
353
353
  }
354
354
 
355
+ export declare function startEngineCompilation(force?: boolean): Promise<void>;
356
+
355
357
  export { };
package/index.d.ts CHANGED
@@ -1,6 +1,10 @@
1
1
  /// <reference types="node" />
2
2
 
3
+ import { ChunkInfo } from '@cocos/creator-programming-quick-pack/lib/loader';
3
4
  import { EventEmitter } from 'events';
5
+ import { NextFunction } from 'express';
6
+ import { Request as Request_2 } from 'express';
7
+ import { Response as Response_2 } from 'express';
4
8
 
5
9
  /** 动画剪辑资源的 userData */
6
10
  declare interface AnimationClipAssetUserData {
@@ -100,6 +104,23 @@ declare interface AnimationImportSetting {
100
104
  /** 所有资源处理器类型的常量数组(用于 Zod enum 和 TypeScript type) */
101
105
  declare const ASSET_HANDLER_TYPES: string[];
102
106
 
107
+ declare enum AssetActionEnum {
108
+ 'add' = 0,
109
+ 'change' = 1,
110
+ 'delete' = 2,
111
+ 'none' = 3
112
+ }
113
+
114
+ declare interface AssetChangeInfo {
115
+ type: AssetChangeType;
116
+ uuid: string;
117
+ filePath: string;
118
+ importer: string;
119
+ userData: object;
120
+ }
121
+
122
+ declare type AssetChangeType = AssetActionEnum;
123
+
103
124
  /**
104
125
  * 资源数据库启动参数
105
126
  */
@@ -435,9 +456,12 @@ export declare namespace Configuration {
435
456
  set,
436
457
  remove,
437
458
  save,
459
+ getMetadata,
438
460
  IConfiguration,
439
461
  ConfigurationScope,
440
- IBaseConfiguration
462
+ IBaseConfiguration,
463
+ ICocosConfigurationNode,
464
+ ICocosConfigurationPropertySchema
441
465
  };
442
466
  }
443
467
 
@@ -524,6 +548,7 @@ export declare namespace Engine {
524
548
  getInfo,
525
549
  getConfig,
526
550
  initEngine,
551
+ startEngineCompilation,
527
552
  EngineInfo,
528
553
  IFlags,
529
554
  MakeRequired,
@@ -642,6 +667,32 @@ declare function getInfo(): Promise<EngineInfo>;
642
667
 
643
668
  declare function getInfo_2(): Promise<ProjectInfo>;
644
669
 
670
+ declare function getMetadata(): Promise<ICocosConfigurationNode[]>;
671
+
672
+ declare function getProgrammingFacet(): Promise<ProgrammingFacet>;
673
+
674
+ /**
675
+ * Get the MCP registration status.
676
+ */
677
+ declare function getStatus(): {
678
+ registered: boolean;
679
+ url?: string;
680
+ };
681
+
682
+ /**
683
+ * Get the server running status.
684
+ */
685
+ declare function getStatus_2(): {
686
+ running: boolean;
687
+ url?: string;
688
+ };
689
+
690
+ /**
691
+ * Get the current server base URL.
692
+ * Returns undefined if the server is not running.
693
+ */
694
+ declare function getUrl(): string | undefined;
695
+
645
696
  /** glTF 动画资源的 userData */
646
697
  declare interface GltfAnimationAssetUserData {
647
698
  gltfIndex: number;
@@ -965,6 +1016,36 @@ declare interface IChunkContent {
965
1016
  clips: string[];
966
1017
  }
967
1018
 
1019
+ declare interface ICocosConfigurationNode {
1020
+ id: string;
1021
+ title: string;
1022
+ group: string;
1023
+ order?: number;
1024
+ properties: Record<string, ICocosConfigurationPropertySchema>;
1025
+ }
1026
+
1027
+ /**
1028
+ * Cocos 配置元数据定义。
1029
+ *
1030
+ * 基于 COCOS_CONFIG 类型(@types/cocos.config.d.ts)展开,
1031
+ * 按 group(顶级模块) → node(二级字段) 组织。
1032
+ *
1033
+ * 供 Pink 配置面板渲染使用,通过 CocosHostConfiguration.getMetadata() 返回。
1034
+ */
1035
+ declare interface ICocosConfigurationPropertySchema {
1036
+ type: 'string' | 'number' | 'boolean' | 'object' | 'array';
1037
+ default?: unknown;
1038
+ title?: string;
1039
+ description?: string;
1040
+ scope: string[];
1041
+ enum?: any[];
1042
+ enumDescriptions?: string[];
1043
+ minimum?: number;
1044
+ maximum?: number;
1045
+ step?: number;
1046
+ order?: number;
1047
+ }
1048
+
968
1049
  declare interface ICollisionMatrix {
969
1050
  [x: string]: number;
970
1051
  }
@@ -1077,6 +1158,25 @@ declare interface IEngineModuleConfig {
1077
1158
  noDeprecatedFeatures?: { value: boolean, version: string };
1078
1159
  }
1079
1160
 
1161
+ declare interface IEngineOptions {
1162
+ /**
1163
+ * 引擎仓库根目录。
1164
+ */
1165
+ root: string;
1166
+ /**
1167
+ * 引擎编译后的根目录。
1168
+ */
1169
+ distRoot: string;
1170
+ /**
1171
+ * 引擎基础 URL。
1172
+ */
1173
+ baseUrl: string;
1174
+ /**
1175
+ * 使用的引擎功能。
1176
+ */
1177
+ features: string[];
1178
+ }
1179
+
1080
1180
  declare interface IEngineProjectConfig extends Exclude<IEngineConfig, 'includeModules' | 'flags' | 'noDeprecatedFeatures'> {
1081
1181
  configs?: Record<string, IEngineModuleConfig>;
1082
1182
  globalConfigKey?: string;
@@ -1164,6 +1264,11 @@ declare type IFlags = Record<string, boolean | number>;
1164
1264
 
1165
1265
  declare type IFlags_2 = Record<string, boolean | number>;
1166
1266
 
1267
+ declare interface IGetPostConfig {
1268
+ url: string | RegExp;
1269
+ handler: (req: Request_2, res: Response_2, next?: NextFunction) => Promise<void>;
1270
+ }
1271
+
1167
1272
  declare interface IInitEngineInfo {
1168
1273
  importBase: string;
1169
1274
  nativeBase: string;
@@ -1219,6 +1324,13 @@ declare interface ImageMeta {
1219
1324
  remap?: string;
1220
1325
  }
1221
1326
 
1327
+ declare interface IMiddlewareContribution {
1328
+ get?: IGetPostConfig[];
1329
+ post?: IGetPostConfig[];
1330
+ staticFiles?: IStaticFileConfig[];
1331
+ socket?: ISocketConfig;
1332
+ }
1333
+
1222
1334
  declare interface IModuleConfig {
1223
1335
  moduleTreeDump: {
1224
1336
  default: IModules;
@@ -1245,6 +1357,11 @@ declare type IModules = Record<string, IModuleItem>;
1245
1357
  */
1246
1358
  declare function importAsset(source: string, target: string, options?: AssetOperationOption): Promise<IAssetInfo[]>;
1247
1359
 
1360
+ declare interface ImportMap {
1361
+ imports?: Record<string, string>;
1362
+ scopes?: Record<string, Record<string, string>>;
1363
+ }
1364
+
1248
1365
  declare function init(): Promise<void>;
1249
1366
 
1250
1367
  declare function init_2(projectPath: string): Promise<void>;
@@ -1255,10 +1372,18 @@ declare function init_4(projectPath: string): Promise<void>;
1255
1372
 
1256
1373
  declare function init_5(projectPath: string): Promise<void>;
1257
1374
 
1258
- declare function init_6(projectPath: string): Promise<void>;
1375
+ /**
1376
+ * Initialize the scene module.
1377
+ * Registers the scene middleware and initializes scene config.
1378
+ */
1379
+ declare function init_6(): Promise<void>;
1380
+
1381
+ declare function init_7(projectPath: string): Promise<void>;
1259
1382
 
1260
1383
  declare function initEngine(enginePath: string, projectPath: string, serverURL?: string): Promise<void>;
1261
1384
 
1385
+ declare function initProgrammingFacet(): Promise<ProgrammingFacet>;
1386
+
1262
1387
  declare interface IPhysicsConfig {
1263
1388
  gravity: IVec3Like; // (0,-10, 0)
1264
1389
  allowSleep: boolean; // true
@@ -1369,6 +1494,11 @@ declare interface IRedirectInfo {
1369
1494
  uuid: string;
1370
1495
  }
1371
1496
 
1497
+ declare interface ISocketConfig {
1498
+ connection: (socket: any) => void;
1499
+ disconnect: (socket: any) => void;
1500
+ }
1501
+
1372
1502
  declare interface ISplashBackgroundColor {
1373
1503
  x: number;
1374
1504
  y: number;
@@ -1395,6 +1525,11 @@ declare interface ISplashSetting {
1395
1525
  }
1396
1526
  }
1397
1527
 
1528
+ declare interface IStaticFileConfig {
1529
+ url: string;
1530
+ path: string;
1531
+ }
1532
+
1398
1533
  declare type ISupportCreateCCType =
1399
1534
  | 'cc.AnimationClip' // 动画剪辑
1400
1535
  | 'cc.Script' // 脚本(TypeScript/JavaScript)
@@ -1504,6 +1639,14 @@ declare type MacroItem = {
1504
1639
 
1505
1640
  declare type MakeRequired<T, K extends keyof T> = T & Required<Pick<T, K>>;
1506
1641
 
1642
+ export declare namespace Mcp {
1643
+ export {
1644
+ register,
1645
+ unregister,
1646
+ getStatus
1647
+ };
1648
+ }
1649
+
1507
1650
  declare interface MeshClusterOptions {
1508
1651
  enable: boolean;
1509
1652
  coneCluster?: boolean;
@@ -1768,6 +1911,43 @@ declare interface PrefabAssetUserData {
1768
1911
  syncNodeName?: string;
1769
1912
  }
1770
1913
 
1914
+ declare class ProgrammingFacet {
1915
+ private _packerDriverUpdateCount;
1916
+ private _asyncIteration;
1917
+ static create(engine: IEngineOptions, projectPath: string): Promise<ProgrammingFacet>;
1918
+ get engineRoot(): string;
1919
+ get engineDistRoot(): string;
1920
+ get systemJsHomeDir(): string;
1921
+ get systemJsIndexFile(): string;
1922
+ get engineImportMapURL(): string;
1923
+ get packImportMapURL(): string;
1924
+ get packResolutionDetailMapURL(): string;
1925
+ loadPackResource(url: string): Promise<{
1926
+ type: 'json';
1927
+ json: unknown;
1928
+ } | {
1929
+ type: 'chunk';
1930
+ chunk: ChunkInfo;
1931
+ }>;
1932
+ getGlobalImportMap(): Promise<ImportMap & {
1933
+ imports: NonNullable<ImportMap['imports']>;
1934
+ }>;
1935
+ private reload;
1936
+ notifyPackDriverUpdated(): Promise<any>;
1937
+ private _staticImportMap;
1938
+ private _engineRoot;
1939
+ private _engineDistRoot;
1940
+ private _systemJsHomeDir;
1941
+ private _systemJsBundleFileName;
1942
+ private _engineStatsQuery;
1943
+ private _quickPackLoader;
1944
+ private constructor();
1945
+ private _getQuickPackLoader;
1946
+ private _initialize;
1947
+ private _buildSystemJs;
1948
+ private _resetQuickPackLoader;
1949
+ }
1950
+
1771
1951
  export declare namespace Project {
1772
1952
  export {
1773
1953
  init_5 as init,
@@ -1977,6 +2157,36 @@ declare function queryUUID(urlOrPath: string): Promise<string | null>;
1977
2157
  */
1978
2158
  declare function refresh(dir: string): Promise<number>;
1979
2159
 
2160
+ /**
2161
+ * MCP Facade Module
2162
+ *
2163
+ * Called by the cocos-code utility process to register MCP middleware
2164
+ * in an already-initialized environment.
2165
+ * Prerequisite: the Server module must be started before calling this module.
2166
+ * This module only handles MCP-specific work: populating the toolRegistry
2167
+ * and registering MCP routes on the running server.
2168
+ */
2169
+ /**
2170
+ * Register MCP middleware on the running server.
2171
+ *
2172
+ * Note: the Express server must already be started via the Server module.
2173
+ * This function only:
2174
+ * 1. Imports API modules to populate the toolRegistry (@tool decorator side-effects)
2175
+ * 2. Creates McpMiddleware and registers routes on the server
2176
+ *
2177
+ * @returns MCP endpoint URL (e.g. http://localhost:9527/mcp)
2178
+ */
2179
+ declare function register(): Promise<string>;
2180
+
2181
+ /**
2182
+ * Register a middleware contribution (routes, static files, sockets)
2183
+ * on the running server.
2184
+ *
2185
+ * @param name Middleware identifier
2186
+ * @param module Middleware contribution config
2187
+ */
2188
+ declare function register_2(name: string, module: IMiddlewareContribution): Promise<void>;
2189
+
1980
2190
  /**
1981
2191
  * Reimport Asset // 重新导入资源
1982
2192
  */
@@ -2014,9 +2224,19 @@ declare function save(force?: boolean): Promise<void>;
2014
2224
  */
2015
2225
  declare function saveAsset(pathOrUrlOrUUID: string, data: string | Buffer): Promise<IAssetInfo>;
2016
2226
 
2017
- export declare namespace Scripting {
2227
+ export declare namespace Scene {
2018
2228
  export {
2019
2229
  init_6 as init,
2230
+ startupWorker
2231
+ };
2232
+ }
2233
+
2234
+ export declare namespace Scripting {
2235
+ export {
2236
+ init_7 as init,
2237
+ initProgrammingFacet,
2238
+ getProgrammingFacet,
2239
+ startCompileScript,
2020
2240
  SharedSettings,
2021
2241
  IPluginScriptInfo,
2022
2242
  FilterPluginOptions
@@ -2037,6 +2257,16 @@ declare interface SerializedAssetFinder {
2037
2257
  scenes?: Array<string | null>;
2038
2258
  }
2039
2259
 
2260
+ export declare namespace Server {
2261
+ export {
2262
+ start_2 as start,
2263
+ stop_2 as stop,
2264
+ getUrl,
2265
+ register_2 as register,
2266
+ getStatus_2 as getStatus
2267
+ };
2268
+ }
2269
+
2040
2270
  declare function set<T>(key: string, value: T, scope?: ConfigurationScope): Promise<boolean>;
2041
2271
 
2042
2272
  declare interface SharedSettings {
@@ -2130,6 +2360,40 @@ declare interface SpriteFrameVertices {
2130
2360
  */
2131
2361
  declare function start(): Promise<void>;
2132
2362
 
2363
+ /**
2364
+ * Server Facade Module
2365
+ *
2366
+ * Provides a simplified interface for managing the Express HTTP server.
2367
+ * Wraps the core server service with startup guards and status tracking.
2368
+ */
2369
+ /**
2370
+ * Initialize and start the Express HTTP server.
2371
+ *
2372
+ * @param port Optional port number; auto-selected if omitted
2373
+ * @returns The server base URL (e.g. http://localhost:9527)
2374
+ */
2375
+ declare function start_2(port?: number): Promise<string>;
2376
+
2377
+ /**
2378
+ * 在独立的子进程中运行项目脚本编译
2379
+ * 以避免阻塞主进程
2380
+ */
2381
+ declare function startCompileScript(assetChanges?: AssetChangeInfo[]): Promise<void>;
2382
+
2383
+ declare function startEngineCompilation(force?: boolean): Promise<void>;
2384
+
2385
+ /**
2386
+ * Start the scene worker process.
2387
+ *
2388
+ * @param projectPath Path to the project directory
2389
+ */
2390
+ declare function startupWorker(projectPath: string): Promise<void>;
2391
+
2392
+ /**
2393
+ * Stop the Express HTTP server.
2394
+ */
2395
+ declare function stop_2(): Promise<void>;
2396
+
2133
2397
  /** 支持创建的资源类型常量数组(用于 Zod enum 和 TypeScript type) */
2134
2398
  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'];
2135
2399
 
@@ -2192,6 +2456,12 @@ declare interface ThumbnailInfo {
2192
2456
  value: string; // 具体 icon 名字或者 image 路径,image 路径支持绝对路径、 db:// 、 project:// 、和 packages:// 下的路径
2193
2457
  }
2194
2458
 
2459
+ /**
2460
+ * Clean up MCP state.
2461
+ * Note: does NOT stop the Express server — use the Server module for that.
2462
+ */
2463
+ declare function unregister(): Promise<void>;
2464
+
2195
2465
  /**
2196
2466
  * Update Asset User Data // 更新资源用户数据
2197
2467
  */
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.19.1",
5
+ "version": "0.0.1-alpha.21.2",
6
6
  "main": "index.d.ts",
7
7
  "types": "index.d.ts",
8
8
  "exports": {
package/scripting.d.ts CHANGED
@@ -1,3 +1,24 @@
1
+ /// <reference types="node" />
2
+
3
+ import { ChunkInfo } from '@cocos/creator-programming-quick-pack/lib/loader';
4
+
5
+ declare enum AssetActionEnum {
6
+ 'add' = 0,
7
+ 'change' = 1,
8
+ 'delete' = 2,
9
+ 'none' = 3
10
+ }
11
+
12
+ declare interface AssetChangeInfo {
13
+ type: AssetChangeType;
14
+ uuid: string;
15
+ filePath: string;
16
+ importer: string;
17
+ userData: object;
18
+ }
19
+
20
+ declare type AssetChangeType = AssetActionEnum;
21
+
1
22
  export declare interface FilterPluginOptions {
2
23
  loadPluginInEditor?: boolean;
3
24
  loadPluginInWeb?: boolean;
@@ -5,8 +26,36 @@ export declare interface FilterPluginOptions {
5
26
  loadPluginInMiniGame?: boolean;
6
27
  }
7
28
 
29
+ export declare function getProgrammingFacet(): Promise<ProgrammingFacet>;
30
+
31
+ declare interface IEngineOptions {
32
+ /**
33
+ * 引擎仓库根目录。
34
+ */
35
+ root: string;
36
+ /**
37
+ * 引擎编译后的根目录。
38
+ */
39
+ distRoot: string;
40
+ /**
41
+ * 引擎基础 URL。
42
+ */
43
+ baseUrl: string;
44
+ /**
45
+ * 使用的引擎功能。
46
+ */
47
+ features: string[];
48
+ }
49
+
50
+ declare interface ImportMap {
51
+ imports?: Record<string, string>;
52
+ scopes?: Record<string, Record<string, string>>;
53
+ }
54
+
8
55
  export declare function init(projectPath: string): Promise<void>;
9
56
 
57
+ export declare function initProgrammingFacet(): Promise<ProgrammingFacet>;
58
+
10
59
  export declare interface IPluginScriptInfo extends PluginScriptInfo {
11
60
  url: string;
12
61
  }
@@ -19,6 +68,43 @@ declare interface PluginScriptInfo {
19
68
  uuid: string;
20
69
  }
21
70
 
71
+ declare class ProgrammingFacet {
72
+ private _packerDriverUpdateCount;
73
+ private _asyncIteration;
74
+ static create(engine: IEngineOptions, projectPath: string): Promise<ProgrammingFacet>;
75
+ get engineRoot(): string;
76
+ get engineDistRoot(): string;
77
+ get systemJsHomeDir(): string;
78
+ get systemJsIndexFile(): string;
79
+ get engineImportMapURL(): string;
80
+ get packImportMapURL(): string;
81
+ get packResolutionDetailMapURL(): string;
82
+ loadPackResource(url: string): Promise<{
83
+ type: 'json';
84
+ json: unknown;
85
+ } | {
86
+ type: 'chunk';
87
+ chunk: ChunkInfo;
88
+ }>;
89
+ getGlobalImportMap(): Promise<ImportMap & {
90
+ imports: NonNullable<ImportMap['imports']>;
91
+ }>;
92
+ private reload;
93
+ notifyPackDriverUpdated(): Promise<any>;
94
+ private _staticImportMap;
95
+ private _engineRoot;
96
+ private _engineDistRoot;
97
+ private _systemJsHomeDir;
98
+ private _systemJsBundleFileName;
99
+ private _engineStatsQuery;
100
+ private _quickPackLoader;
101
+ private constructor();
102
+ private _getQuickPackLoader;
103
+ private _initialize;
104
+ private _buildSystemJs;
105
+ private _resetQuickPackLoader;
106
+ }
107
+
22
108
  export declare interface SharedSettings {
23
109
  useDefineForClassFields: boolean;
24
110
  allowDeclareFields: boolean;
@@ -35,4 +121,10 @@ export declare interface SharedSettings {
35
121
  };
36
122
  }
37
123
 
124
+ /**
125
+ * 在独立的子进程中运行项目脚本编译
126
+ * 以避免阻塞主进程
127
+ */
128
+ export declare function startCompileScript(assetChanges?: AssetChangeInfo[]): Promise<void>;
129
+
38
130
  export { };