diff --git a/.github/workflows/native-ts-build.yml b/.github/workflows/native-ts-build.yml
index 4fbfba260fd..bb4955c72ca 100644
--- a/.github/workflows/native-ts-build.yml
+++ b/.github/workflows/native-ts-build.yml
@@ -27,7 +27,7 @@ jobs:
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- - run: npm ci --ignore-scripts
+ - run: npm ci
- run: npx gulp build-debug-infos
- name: Download external
run: |
diff --git a/gulpfile.js b/gulpfile.js
index 88cd57aa566..129aa036dfa 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -106,14 +106,11 @@ gulp.task('build-h5-minified', gulp.series('build-debug-infos', async () => {
gulp.task('build-declarations', async () => {
const outDir = ps.join('bin', '.declarations');
- const { build } = require('@cocos/build-engine/lib/build-declarations');
+ const { dtsBundler } = require('@cocos/ccbuild');
await fs.emptyDir(outDir);
- return await build({
+ return await dtsBundler.build({
engine: __dirname,
outDir,
- withIndex: true,
- withExports: false,
- withEditorExports: true,
});
});
diff --git a/package-lock.json b/package-lock.json
index 922dfddf11b..f99e1bb429d 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -16,7 +16,7 @@
"dependencies": {
"@cocos/box2d": "1.0.1",
"@cocos/cannon": "1.2.8",
- "@cocos/ccbuild": "2.0.3-alpha.13",
+ "@cocos/ccbuild": "2.0.3-alpha.14",
"@cocos/dragonbones-js": "^1.0.1",
"@pal/env": "*",
"@pal/utils": "*"
@@ -2001,9 +2001,9 @@
}
},
"node_modules/@cocos/ccbuild": {
- "version": "2.0.3-alpha.13",
- "resolved": "https://registry.npmjs.org/@cocos/ccbuild/-/ccbuild-2.0.3-alpha.13.tgz",
- "integrity": "sha512-TAoMos2FLz3gqMA4AyL2/px6p9dopQQGW3cT5kNejbbOvfcPyYNF3BbgZjG3FP4s9hvcLTe2eIwaUrBC2bQsjg==",
+ "version": "2.0.3-alpha.14",
+ "resolved": "https://registry.npmjs.org/@cocos/ccbuild/-/ccbuild-2.0.3-alpha.14.tgz",
+ "integrity": "sha512-Hy6dInlmxnLwaaYeZKjPlUCvDmJk0bWb/2irqCIGSvU4JBEjFJCPVsGK1+9MCMQyb2YPW1StAgjVM651nGWGuw==",
"dependencies": {
"@babel/core": "^7.20.12",
"@babel/helper-module-imports": "7.18.6",
@@ -4817,6 +4817,10 @@
"@babel/types": "^7.3.0"
}
},
+ "node_modules/@types/cc-ambient-types": {
+ "resolved": "packages/cc-ambient-types",
+ "link": true
+ },
"node_modules/@types/dedent": {
"version": "0.7.0",
"resolved": "https://registry.npmjs.org/@types/dedent/-/dedent-0.7.0.tgz",
@@ -23055,6 +23059,14 @@
"node": ">=6"
}
},
+ "packages/cc-ambient-types": {
+ "name": "@types/cc-ambient-types",
+ "version": "1.0.0",
+ "license": "MIT",
+ "devDependencies": {
+ "@cocos/ccbuild": "*"
+ }
+ },
"packages/native-pack-tool": {
"version": "0.0.1",
"hasInstallScript": true,
diff --git a/package.json b/package.json
index 2cabd4e8e40..8c24b55d274 100644
--- a/package.json
+++ b/package.json
@@ -18,18 +18,17 @@
],
"scripts": {
"server": "http-server . -p 8002 -o playground/index.html",
- "postinstall": "turbo build && gulp build-debug-infos && npm run build-declaration && npm run bundle-adapter && npm run fetch-ral",
- "build": "gulp build",
+ "postinstall": "npm run build",
+ "build": "turbo build && npm run build-root",
+ "build-root": "gulp build-debug-infos && gulp build-declarations && npm run bundle-adapter && npm run fetch-ral",
"build:dev": "gulp build-h5-source",
"build:min": "gulp build-h5-minified",
- "build-declaration": "npm run build-const && gulp build-declarations",
"build-api-json": "gulp build-api-json -i index.ts -o ./3d-api-docs/tempJson",
"build-api": "npm run build-api-json && gulp build-3d-api -i index.ts -o ./3d-api-docs -j ./3d-api-docs/tempJson",
"checkout-engine-version": "node ./scripts/checkout-engine-version.js",
"varify-engine-version": "node ./scripts/varify-engine-version.js",
"fetch-ral": "node ./scripts/fetch-ral.js",
"bundle-adapter": "node ./scripts/bundle-adapter.js",
- "build-const": "node ./scripts/build-consts.js",
"clear": "node ./scripts/clear-cache.js",
"clear-platform": "node ./native/utils/clear-platform.js && node ./scripts/clear-file.js",
"update:native-external": "node ./native/utils/update-external.js",
@@ -44,7 +43,7 @@
"@pal/utils": "*",
"@cocos/box2d": "1.0.1",
"@cocos/cannon": "1.2.8",
- "@cocos/ccbuild": "2.0.3-alpha.13",
+ "@cocos/ccbuild": "2.0.3-alpha.14",
"@cocos/dragonbones-js": "^1.0.1"
},
"devDependencies": {
diff --git a/packages/build-engine/tsconfig.json b/packages/build-engine/tsconfig.json
index e36f68d896b..49fb8b1376a 100644
--- a/packages/build-engine/tsconfig.json
+++ b/packages/build-engine/tsconfig.json
@@ -7,7 +7,8 @@
"sourceMap": true,
"declaration": true,
"rootDir": "src",
- "outDir": "lib"
+ "outDir": "lib",
+ "types": []
},
"exclude": [
"lib",
diff --git a/packages/cc-ambient-types/package.json b/packages/cc-ambient-types/package.json
new file mode 100644
index 00000000000..ed60280ddbf
--- /dev/null
+++ b/packages/cc-ambient-types/package.json
@@ -0,0 +1,21 @@
+{
+ "$schema": "../../schemas/module-config.schema.json",
+ "name": "@types/cc-ambient-types",
+ "version": "1.0.0",
+ "description": "",
+ "scripts": {
+ "build": "node ./scripts/build-consts.js"
+ },
+ "license": "MIT",
+ "types": "./src/index.d.ts",
+ "exports": {
+ ".": {
+ "node": "./src/index.d.ts",
+ "types": "./src/index.d.ts"
+ },
+ "./query": "./scripts/query.js"
+ },
+ "devDependencies": {
+ "@cocos/ccbuild": "*"
+ }
+}
diff --git a/scripts/build-consts.js b/packages/cc-ambient-types/scripts/build-consts.js
similarity index 76%
rename from scripts/build-consts.js
rename to packages/cc-ambient-types/scripts/build-consts.js
index 76234dc79a6..c0392314edf 100644
--- a/scripts/build-consts.js
+++ b/packages/cc-ambient-types/scripts/build-consts.js
@@ -1,10 +1,11 @@
-const { StatsQuery } = require('@cocos/build-engine');
+const { StatsQuery } = require('@cocos/ccbuild');
const ps = require('path');
const fsExt = require('fs-extra');
const chalk = require('chalk').default;
-const engineRoot = ps.join(__dirname, '../');
-const targetConstFile = ps.join(engineRoot, `./@types/consts.d.ts`);
+const engineRoot = ps.join(__dirname, '../../../');
+const pkgRoot = ps.join(__dirname, '../');
+const targetConstFile = ps.join(pkgRoot, `./lib/consts.d.ts`);
console.log(chalk.green(`\nGenerate consts.d.ts: ${targetConstFile}\n`));
diff --git a/packages/cc-ambient-types/scripts/query.js b/packages/cc-ambient-types/scripts/query.js
new file mode 100644
index 00000000000..b29c710dc7b
--- /dev/null
+++ b/packages/cc-ambient-types/scripts/query.js
@@ -0,0 +1,14 @@
+const ps = require('path');
+const fs = require('fs');
+
+function formatPath (path) {
+ return path.replace(/\\/g, '/');
+}
+
+exports.getDtsFiles = function () {
+ const indexFile = ps.join(__dirname, '../src/index.d.ts');
+ const indexContent = fs.readFileSync(indexFile, 'utf8');
+ const reg = /".*"/g;
+ const dtsFiles = indexContent.match(reg).map(relativePath => formatPath(ps.join(ps.dirname(indexFile), relativePath.slice(1, -1))));
+ return dtsFiles;
+};
\ No newline at end of file
diff --git a/@types/editor-extends.d.ts b/packages/cc-ambient-types/src/editor-extends.d.ts
similarity index 100%
rename from @types/editor-extends.d.ts
rename to packages/cc-ambient-types/src/editor-extends.d.ts
diff --git a/@types/globals.d.ts b/packages/cc-ambient-types/src/globals.d.ts
similarity index 100%
rename from @types/globals.d.ts
rename to packages/cc-ambient-types/src/globals.d.ts
diff --git a/packages/cc-ambient-types/src/index.d.ts b/packages/cc-ambient-types/src/index.d.ts
new file mode 100644
index 00000000000..fbe8586b81e
--- /dev/null
+++ b/packages/cc-ambient-types/src/index.d.ts
@@ -0,0 +1,30 @@
+/* eslint-disable @typescript-eslint/triple-slash-reference */
+// default ambient types
+///
+///
+///
+///
+///
+///
+
+// node_modules types
+///
+
+// pal types
+///
+///
+///
+///
+///
+///
+///
+///
+
+// external types
+///
+///
+///
+///
+///
+///
+///
diff --git a/@types/jsb.d.ts b/packages/cc-ambient-types/src/jsb.d.ts
similarity index 100%
rename from @types/jsb.d.ts
rename to packages/cc-ambient-types/src/jsb.d.ts
diff --git a/@types/pal/audio.d.ts b/packages/cc-ambient-types/src/pal/audio.d.ts
similarity index 90%
rename from @types/pal/audio.d.ts
rename to packages/cc-ambient-types/src/pal/audio.d.ts
index 45a18e8c0e2..c7ba14ddd65 100644
--- a/@types/pal/audio.d.ts
+++ b/packages/cc-ambient-types/src/pal/audio.d.ts
@@ -50,7 +50,7 @@ declare module 'pal/audio' {
* @param opts Load options.
* @returns The audio player.
*/
- static load (url: string, opts?: import('pal/audio/type').AudioLoadOptions): Promise;
+ static load (url: string, opts?: import('../../../../pal/audio/type').AudioLoadOptions): Promise;
/**
* Asynchronously load a native audio for playing one shot.
@@ -59,7 +59,7 @@ declare module 'pal/audio' {
* @param opts Load options.
* @returns The native audio such as `HTMLAudioElement` or `AudioBuffer`.
*/
- static loadNative (url: string, opts?: import('pal/audio/type').AudioLoadOptions): Promise;
+ static loadNative (url: string, opts?: import('../../../../pal/audio/type').AudioLoadOptions): Promise;
/**
* Asynchronously load an OneShotAudio instance.
@@ -68,7 +68,7 @@ declare module 'pal/audio' {
* @param opts Load options.
* @returns The OneShotAudio instance.
*/
- static loadOneShotAudio (url: string, volume: number, opts?: import('pal/audio/type').AudioLoadOptions): Promise;
+ static loadOneShotAudio (url: string, volume: number, opts?: import('../../../../pal/audio/type').AudioLoadOptions): Promise;
/**
* Max audio channel count allowed on current platform.
@@ -86,13 +86,13 @@ declare module 'pal/audio' {
* The type of this player.
* For WEB platform, it can be `WEB_AUDIO` or `DOM_AUDIO`.
*/
- get type (): import('pal/audio/type').AudioType;
+ get type (): import('../../../../pal/audio/type').AudioType;
/**
* The state of this player.
* The state would be restored to `INIT` when the audio finished its playing.
*/
- get state (): import('pal/audio/type').AudioState;
+ get state (): import('../../../../pal/audio/type').AudioState;
/**
* Gets or sets whether if the playing audio should be looped.
@@ -126,7 +126,7 @@ declare module 'pal/audio' {
* Get pcm data view from specified channel.
* @param channelIndex The channel index. 0 is left channel, 1 is right channel.
*/
- public getPCMData (channelIndex: number): import('pal/audio/type').AudioPCMDataView | undefined;
+ public getPCMData (channelIndex: number): import('../../../../pal/audio/type').AudioPCMDataView | undefined;
/**
* Asynchronously seeks the player's playing time onto specified location.
diff --git a/@types/pal/image.d.ts b/packages/cc-ambient-types/src/pal/image.d.ts
similarity index 76%
rename from @types/pal/image.d.ts
rename to packages/cc-ambient-types/src/pal/image.d.ts
index d1236a6aea3..7a242f2e590 100644
--- a/@types/pal/image.d.ts
+++ b/packages/cc-ambient-types/src/pal/image.d.ts
@@ -1,9 +1,9 @@
declare module 'pal/image' {
- export type ImageSource = import('pal/image/types').ImageSource;
- export type IMemoryImageSource = import('pal/image/types').IMemoryImageSource;
- export type PixelFormat = import('cocos/asset/assets/asset-enum').PixelFormat;
- export type RawDataType = import('pal/image/types').RawDataType;
+ export type ImageSource = import('../../../../pal/image/types').ImageSource;
+ export type IMemoryImageSource = import('../../../../pal/image/types').IMemoryImageSource;
+ export type PixelFormat = import('../../../../cocos/asset/assets/asset-enum').PixelFormat;
+ export type RawDataType = import('../../../../pal/image/types').RawDataType;
export class ImageData {
constructor (source?: ImageSource | ArrayBufferView);
/**
diff --git a/@types/pal/input-box.d.ts b/packages/cc-ambient-types/src/pal/input-box.d.ts
similarity index 100%
rename from @types/pal/input-box.d.ts
rename to packages/cc-ambient-types/src/pal/input-box.d.ts
diff --git a/@types/pal/input.d.ts b/packages/cc-ambient-types/src/pal/input.d.ts
similarity index 83%
rename from @types/pal/input.d.ts
rename to packages/cc-ambient-types/src/pal/input.d.ts
index 892fa1c294f..911c38ffef5 100644
--- a/@types/pal/input.d.ts
+++ b/packages/cc-ambient-types/src/pal/input.d.ts
@@ -1,11 +1,11 @@
declare module 'pal/input' {
- type InputSourceButton = import('pal/input/input-source').InputSourceButton;
- type InputSourceStick = import('pal/input/input-source').InputSourceStick;
- type InputSourceDpad = import('pal/input/input-source').InputSourceDpad;
- type InputSourcePosition = import('pal/input/input-source').InputSourcePosition;
- type InputSourceOrientation = import('pal/input/input-source').InputSourceOrientation;
+ type InputSourceButton = import('../../../../pal/input/input-source').InputSourceButton;
+ type InputSourceStick = import('../../../../pal/input/input-source').InputSourceStick;
+ type InputSourceDpad = import('../../../../pal/input/input-source').InputSourceDpad;
+ type InputSourcePosition = import('../../../../pal/input/input-source').InputSourcePosition;
+ type InputSourceOrientation = import('../../../../pal/input/input-source').InputSourceOrientation;
- type TouchCallback = (res: import('cocos/input/types').EventTouch) => void;
+ type TouchCallback = (res: import('../../../../cocos/input/types').EventTouch) => void;
/**
* Class designed for touch input.
*/
@@ -13,10 +13,10 @@ declare module 'pal/input' {
/**
* Register the touch event callback.
*/
- public on (eventType: import('cocos/input/types/event-enum').InputEventType, callback: TouchCallback, target?: any);
+ public on (eventType: import('../../../../cocos/input/types/event-enum').InputEventType, callback: TouchCallback, target?: any);
}
- type MouseCallback = (res: import('cocos/input/types').EventMouse) => void;
+ type MouseCallback = (res: import('../../../../cocos/input/types').EventMouse) => void;
/**
* Class designed for mouse input.
*/
@@ -24,7 +24,7 @@ declare module 'pal/input' {
/**
* Register the mouse event callback.
*/
- public on (eventType: import('cocos/input/types/event-enum').InputEventType, callback: MouseCallback, target?: any);
+ public on (eventType: import('../../../../cocos/input/types/event-enum').InputEventType, callback: MouseCallback, target?: any);
public dispatchMouseDownEvent? (nativeMouseEvent: any);
public dispatchMouseMoveEvent? (nativeMouseEvent: any);
@@ -32,7 +32,7 @@ declare module 'pal/input' {
public dispatchScrollEvent? (nativeMouseEvent: any);
}
- type KeyboardCallback = (res: import('cocos/input/types').EventKeyboard) => void;
+ type KeyboardCallback = (res: import('../../../../cocos/input/types').EventKeyboard) => void;
/**
* Class Designed for keyboard input.
*/
@@ -40,13 +40,13 @@ declare module 'pal/input' {
/**
* Register the keyboard event callback.
*/
- public on (eventType: import('cocos/input/types/event-enum').InputEventType, callback: KeyboardCallback, target?: any);
+ public on (eventType: import('../../../../cocos/input/types/event-enum').InputEventType, callback: KeyboardCallback, target?: any);
public dispatchKeyboardDownEvent? (nativeKeyboardEvent: any);
public dispatchKeyboardUpEvent? (nativeKeyboardEvent: any);
}
- type GamepadCallback = (res: import('cocos/input/types/event').EventGamepad) => void;
+ type GamepadCallback = (res: import('../../../../cocos/input/types/event').EventGamepad) => void;
/**
* Class designed for gamepad input
@@ -60,7 +60,7 @@ declare module 'pal/input' {
/**
* @engineInternal
*/
- public static _on (eventType: import('cocos/input/types/event-enum').InputEventType, cb: GamepadCallback, target?: any);
+ public static _on (eventType: import('../../../../cocos/input/types/event-enum').InputEventType, cb: GamepadCallback, target?: any);
public static all: GamepadInputDevice[];
public static xr: (GamepadInputDevice | null);
@@ -216,7 +216,7 @@ declare module 'pal/input' {
public get aimRightOrientation (): InputSourceOrientation;
}
- type AccelerometerCallback = (res: import('cocos/input/types').EventAcceleration) => void;
+ type AccelerometerCallback = (res: import('../../../../cocos/input/types').EventAcceleration) => void;
/**
* Class designed for accelerometer input
*/
@@ -240,10 +240,10 @@ declare module 'pal/input' {
/**
* Register the acceleration event callback.
*/
- public on (eventType: import('cocos/input/types/event-enum').InputEventType, callback: AccelerometerCallback, target?: any);
+ public on (eventType: import('../../../../cocos/input/types/event-enum').InputEventType, callback: AccelerometerCallback, target?: any);
}
- type HandleCallback = (res: import('cocos/input/types').EventHandle) => void;
+ type HandleCallback = (res: import('../../../../cocos/input/types').EventHandle) => void;
/**
* Class designed for handle input.
*/
@@ -252,7 +252,7 @@ declare module 'pal/input' {
* Register the handle event callback.
* @engineInternal
*/
- public _on (eventType: import('cocos/input/types/event-enum').InputEventType, callback: HandleCallback, target?: any);
+ public _on (eventType: import('../../../../cocos/input/types/event-enum').InputEventType, callback: HandleCallback, target?: any);
/**
* @en The control button in the north direction which is generally the button Y
@@ -382,7 +382,7 @@ declare module 'pal/input' {
public get aimRightOrientation (): InputSourceOrientation;
}
- type HMDCallback = (res: import('cocos/input/types').EventHMD) => void;
+ type HMDCallback = (res: import('../../../../cocos/input/types').EventHMD) => void;
/**
* Class designed for HMD input.
*/
@@ -391,7 +391,7 @@ declare module 'pal/input' {
* Register the hmd event callback.
* @engineInternal
*/
- public _on (eventType: import('cocos/input/types/event-enum').InputEventType, callback: HMDCallback, target?: any);
+ public _on (eventType: import('../../../../cocos/input/types/event-enum').InputEventType, callback: HMDCallback, target?: any);
/**
* @en The position Left view
@@ -425,7 +425,7 @@ declare module 'pal/input' {
public get headMiddleOrientation (): InputSourceOrientation;
}
- type HandheldCallback = (res: import('cocos/input/types').EventHandheld) => void;
+ type HandheldCallback = (res: import('../../../../cocos/input/types').EventHandheld) => void;
/**
* Class designed for Handheld input.
*/
@@ -434,7 +434,7 @@ declare module 'pal/input' {
* Register the handheld event callback.
* @engineInternal
*/
- public _on (eventType: import('cocos/input/types/event-enum').InputEventType, callback: HandheldCallback, target?: any);
+ public _on (eventType: import('../../../../cocos/input/types/event-enum').InputEventType, callback: HandheldCallback, target?: any);
/**
* @en The position handheld
* @zh 手持设备相机位置
diff --git a/@types/pal/minigame.d.ts b/packages/cc-ambient-types/src/pal/minigame.d.ts
similarity index 98%
rename from @types/pal/minigame.d.ts
rename to packages/cc-ambient-types/src/pal/minigame.d.ts
index 934f7b47eb9..c0ce870046c 100644
--- a/@types/pal/minigame.d.ts
+++ b/packages/cc-ambient-types/src/pal/minigame.d.ts
@@ -10,7 +10,7 @@ declare module 'pal/minigame' {
// system
isDevTool: boolean;
isLandscape: boolean;
- orientation: import('pal/screen-adapter/enum-type').Orientation;
+ orientation: import('../../../../pal/screen-adapter/enum-type').Orientation;
getSystemInfoSync(): SystemInfo;
onShow(callback: () => void): void;
offShow(callback: () => void): void;
diff --git a/@types/pal/pacer.d.ts b/packages/cc-ambient-types/src/pal/pacer.d.ts
similarity index 100%
rename from @types/pal/pacer.d.ts
rename to packages/cc-ambient-types/src/pal/pacer.d.ts
diff --git a/@types/pal/screen-adapter.d.ts b/packages/cc-ambient-types/src/pal/screen-adapter.d.ts
similarity index 83%
rename from @types/pal/screen-adapter.d.ts
rename to packages/cc-ambient-types/src/pal/screen-adapter.d.ts
index 363e6f42326..cf6fd3a2da1 100644
--- a/@types/pal/screen-adapter.d.ts
+++ b/packages/cc-ambient-types/src/pal/screen-adapter.d.ts
@@ -70,14 +70,14 @@ declare module 'pal/screen-adapter' {
/**
* Get and set the size of current window in physical pixels.
*/
- public get windowSize (): import('cocos/core/math').Size;
- public set windowSize (size: import('cocos/core/math').Size);
+ public get windowSize (): import('../../../../cocos/core/math').Size;
+ public set windowSize (size: import('../../../../cocos/core/math').Size);
/**
* Get the current resolution of game.
* This is a readonly property, you can change the value by setting screenAdapter.resolutionScale.
*/
- public get resolution (): import('cocos/core/math').Size;
+ public get resolution (): import('../../../../cocos/core/math').Size;
/**
* Get and set the resolution scale of screen, which will affect the quality of the rendering.
@@ -90,8 +90,8 @@ declare module 'pal/screen-adapter' {
* Get or set the orientation of current game.
* Available on mobile related platform for now.
*/
- public get orientation (): import('pal/screen-adapter/enum-type').Orientation;
- public set orientation (value: import('pal/screen-adapter/enum-type').Orientation);
+ public get orientation (): import('../../../../pal/screen-adapter/enum-type').Orientation;
+ public set orientation (value: import('../../../../pal/screen-adapter/enum-type').Orientation);
/**
* Get the SafeAreaEdge based on the screen coordinate system in physical pixels.
@@ -111,9 +111,9 @@ declare module 'pal/screen-adapter' {
*/
public exitFullScreen (): Promise;
- on (event: import('pal/screen-adapter/enum-type').PalScreenEvent, cb: (...args: any) => void, target?: any);
- once (event: import('pal/screen-adapter/enum-type').PalScreenEvent, cb: (...args: any) => void, target?: any);
- off (event: import('pal/screen-adapter/enum-type').PalScreenEvent, cb?: (...args: any) => void, target?: any);
+ on (event: import('../../../../pal/screen-adapter/enum-type').PalScreenEvent, cb: (...args: any) => void, target?: any);
+ once (event: import('../../../../pal/screen-adapter/enum-type').PalScreenEvent, cb: (...args: any) => void, target?: any);
+ off (event: import('../../../../pal/screen-adapter/enum-type').PalScreenEvent, cb?: (...args: any) => void, target?: any);
}
export const screenAdapter: ScreenAdapter;
diff --git a/@types/pal/system-info.d.ts b/packages/cc-ambient-types/src/pal/system-info.d.ts
similarity index 79%
rename from @types/pal/system-info.d.ts
rename to packages/cc-ambient-types/src/pal/system-info.d.ts
index cec8f7f032c..137965f9478 100644
--- a/@types/pal/system-info.d.ts
+++ b/packages/cc-ambient-types/src/pal/system-info.d.ts
@@ -1,12 +1,12 @@
// TODO: some interface need to be designed in a module called 'Application' and 'Network'
declare module 'pal/system-info' {
- type Feature = import('../../pal/system-info/enum-type').Feature;
- type NetworkType = import('../../pal/system-info/enum-type').NetworkType;
- type Platform = import('../../pal/system-info/enum-type').Platform;
- type Language = import('../../pal/system-info/enum-type').Language;
- type OS = import('../../pal/system-info/enum-type').OS;
- type BrowserType = import('../../pal/system-info/enum-type').BrowserType;
- type PalSystemEvent = import('../../pal/system-info/enum-type').PalSystemEvent;
+ type Feature = import('../../../../pal/system-info/enum-type').Feature;
+ type NetworkType = import('../../../../pal/system-info/enum-type').NetworkType;
+ type Platform = import('../../../../pal/system-info/enum-type').Platform;
+ type Language = import('../../../../pal/system-info/enum-type').Language;
+ type OS = import('../../../../pal/system-info/enum-type').OS;
+ type BrowserType = import('../../../../pal/system-info/enum-type').BrowserType;
+ type PalSystemEvent = import('../../../../pal/system-info/enum-type').PalSystemEvent;
export type IFeatureMap = {
[feature in Feature]: boolean;
diff --git a/@types/pal/wasm.d.ts b/packages/cc-ambient-types/src/pal/wasm.d.ts
similarity index 100%
rename from @types/pal/wasm.d.ts
rename to packages/cc-ambient-types/src/pal/wasm.d.ts
diff --git a/@types/webGL.extras.d.ts b/packages/cc-ambient-types/src/webGL.extras.d.ts
similarity index 100%
rename from @types/webGL.extras.d.ts
rename to packages/cc-ambient-types/src/webGL.extras.d.ts
diff --git a/@types/webGL2.extras.d.ts b/packages/cc-ambient-types/src/webGL2.extras.d.ts
similarity index 100%
rename from @types/webGL2.extras.d.ts
rename to packages/cc-ambient-types/src/webGL2.extras.d.ts
diff --git a/packages/cc-ambient-types/tsconfig.json b/packages/cc-ambient-types/tsconfig.json
new file mode 100644
index 00000000000..4ba8a30fe67
--- /dev/null
+++ b/packages/cc-ambient-types/tsconfig.json
@@ -0,0 +1,11 @@
+{
+ "extends": "../../tsconfig.json",
+ "compilerOptions": {
+ "outDir": "./lib/",
+ "rootDir": "./src/",
+ "baseUrl": "./"
+ },
+ "include": [
+ "src/**/*.ts"
+ ]
+}
diff --git a/packages/native-pack-tool/tsconfig.json b/packages/native-pack-tool/tsconfig.json
index b3bd649c3c6..b40f381e0f3 100644
--- a/packages/native-pack-tool/tsconfig.json
+++ b/packages/native-pack-tool/tsconfig.json
@@ -7,7 +7,8 @@
"sourceMap": true,
"declaration": true,
"rootDir": "./src",
- "outDir": "./lib"
+ "outDir": "./lib",
+ "types": []
},
"exclude": [
"lib",
diff --git a/packages/typedoc-plugin/tsconfig.json b/packages/typedoc-plugin/tsconfig.json
index 74cec6f1746..93e69c114c5 100644
--- a/packages/typedoc-plugin/tsconfig.json
+++ b/packages/typedoc-plugin/tsconfig.json
@@ -7,7 +7,8 @@
"sourceMap": true,
"esModuleInterop": true,
"strict": true,
- "skipLibCheck": true
+ "skipLibCheck": true,
+ "types": []
},
"exclude": [
"lib",
diff --git a/schemas/module-config.schema.json b/schemas/module-config.schema.json
index ddd68a06d0b..e38deaa8468 100644
--- a/schemas/module-config.schema.json
+++ b/schemas/module-config.schema.json
@@ -391,6 +391,10 @@
"types"
],
"type": "object"
+ },
+ "./query": {
+ "description": "This export provide a the path of javascript module which exports some method to query the info of module.",
+ "type": "string"
}
},
"required": [
diff --git a/scripts/compile-native-ts.js b/scripts/compile-native-ts.js
index 6445fb0404b..39a2d5bab88 100644
--- a/scripts/compile-native-ts.js
+++ b/scripts/compile-native-ts.js
@@ -85,28 +85,16 @@ async function compileTsEngine () {
console.log('typescript version: ' + ts.version);
console.log('compile source file: ', entries);
+ let dtsFiles = require('@types/cc-ambient-types/query').getDtsFiles();
+ dtsFiles = dtsFiles.map(file => ps.join(buildOutput, ps.relative(engineRoot, file)).slice(0, -'.d.ts'.length));
+ dtsFiles.push(ps.join(buildOutput, './@types/lib.dom'));
+
const compilerOptions = {
strict: true,
noImplicitAny: false,
experimentalDecorators: true,
lib: ["lib.es2015.d.ts", "lib.es2017.d.ts"],
- types: [
- "./@types/editor-extends",
- "./@types/globals",
- "./@types/jsb",
- "./@types/lib.dom",
- "./@types/webGL.extras",
- "./@types/webGL2.extras",
-
- // pal
- "./@types/pal/system-info",
- "./@types/pal/screen-adapter",
- "./@types/pal/minigame",
- "./@types/pal/audio",
- "./@types/pal/input",
- "./@types/pal/pacer",
- "./@types/pal/wasm",
- ].map(typePath => normalizePath(ps.join(buildOutput, typePath))),
+ types: dtsFiles,
skipLibCheck: true,
rootDir: buildOutput,
// outDir: normalizePath(ps.join(buildOutput, '__out__')),
diff --git a/tsconfig.json b/tsconfig.json
index 69a42d256dc..2d92f1835db 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -23,33 +23,8 @@
]
},
"types": [
- "./@types/globals",
- "./@types/consts",
- "./@types/jsb",
- "./@types/editor-extends",
- "./@types/webGL.extras",
- "./@types/webGL2.extras",
- "./node_modules/@cocos/cannon/CANNON",
- "./node_modules/@types/jest/index",
-
- // external types
- "./native/external/emscripten/external-wasm",
- "./native/external/emscripten/bullet/bullet",
- "./native/external/emscripten/physx/physx",
- "./native/external/emscripten/webgpu/webgpu",
- "./native/external/emscripten/spine/spine",
- "./native/external/emscripten/meshopt/meshopt_decoder",
- "./native/external/emscripten/box2d/box2d",
-
- // pal
- "./@types/pal/system-info",
- "./@types/pal/screen-adapter",
- "./@types/pal/minigame",
- "./@types/pal/audio",
- "./@types/pal/input",
- "./@types/pal/pacer",
- "./@types/pal/wasm",
- "./@types/pal/image",
+ "cc-ambient-types",
+ "./node_modules/@types/jest/index"
]
},
"include": [