Compare commits

..

19 Commits

Author SHA1 Message Date
hyde zhou 7c75834010 bump version to 4.0.0-alpha.17 (#135) 2026-05-11 23:18:35 +08:00
hyde zhou 8fd985af75 bump version to 4.0.0-alpha.16 (#134) 2026-05-07 15:35:41 +08:00
qiuguohua cc97bc8af4 V4.0.0 fix get window info cache (#123) 2026-05-07 15:16:18 +08:00
tangkai 92124590fe update (#131) 2026-04-29 16:10:42 +08:00
tangkai 822ac6026c update assets.js (#129) 2026-04-29 13:04:48 +08:00
hyde zhou 4a6f83bd6d Revert "refactor platforms (#126)" (#128) 2026-04-28 23:12:10 +08:00
tangkai 04f063eb2b add key value to assets.js (#127) 2026-04-28 23:09:53 +08:00
hyde zhou 910865bd8b refactor platforms (#126) 2026-04-28 18:53:46 +08:00
hyde zhou e384f54ed2 bump version to 4.0.0-alpha.15 (#125) 2026-04-28 16:46:44 +08:00
hyde zhou 5964835c83 bump version to 4.0.0-alpha.14 (#122) 2026-04-22 15:36:07 +08:00
tangkai f4ae16247c overrideClips_experimental error handle (#121) 2026-04-22 15:30:17 +08:00
qiuguohua 4b4a3ca13f Fix the issue where getWindowInfo does not have a cache, which causes lag. (#120) 2026-04-22 15:29:46 +08:00
hyde zhou f1c5d21be6 bump version to 4.0.0-alpha.13 (#119) 2026-04-15 14:09:42 +08:00
bofeng-song da75e89f4a export interface for CLI (#118) 2026-04-15 10:07:46 +08:00
hyde zhou aba27a715d bump version to 4.0.0-alpha.12 (#116) 2026-04-08 16:41:15 +08:00
hyde zhou 62c1eb58c3 bump version to 4.0.0-alpha.11 (#112) 2026-04-01 15:15:56 +08:00
hyde zhou 5b09978eb1 bump version to 4.0.0-alpha.10 (#108) 2026-03-25 15:59:52 +08:00
hyde zhou 1b8da1df9b fix HarmonyOS Next file size error. ((port from https://github.com/cocos/cocos-engine/pull/19100) (#106) 2026-03-25 14:23:12 +08:00
Raz ea6ff53aad [Spine] Complete spine 4.2 PhysicsConstraint wasm binding (#98) 2026-03-25 14:22:44 +08:00
11 changed files with 244 additions and 84 deletions
@@ -160,7 +160,8 @@ class ClipMotionEval implements MotionEval {
public overrideClips (context: AnimationGraphBindingContext): void {
const { _originalClip: originalClip } = this;
const overriding = context.clipOverrides?.get(originalClip);
const clipOverrides: any = context.clipOverrides;
const overriding: AnimationClip | null = clipOverrides && clipOverrides.get ? clipOverrides.get(originalClip) : null;
if (overriding) {
this._setClip(overriding, context);
}
+14 -12
View File
@@ -33,16 +33,16 @@ const MAGIC = 0x4E4F4343;
const CHUNK_ALIGN_AS = 8;
export class CCON {
constructor (document: unknown, chunks: Uint8Array[]) {
constructor(document: unknown, chunks: Uint8Array[]) {
this._document = document;
this._chunks = chunks;
}
get document (): unknown {
get document(): unknown {
return this._document;
}
get chunks (): Uint8Array[] {
get chunks(): Uint8Array[] {
return this._chunks;
}
@@ -50,7 +50,7 @@ export class CCON {
private declare _chunks: Uint8Array[];
}
export function encodeCCONBinary (ccon: CCON): Uint8Array {
export function encodeCCONBinary(ccon: CCON): Uint8Array {
const { document, chunks } = ccon;
const jsonBytes = new Uint8Array(notepackEncode(document));
@@ -75,7 +75,7 @@ export function encodeCCONBinary (ccon: CCON): Uint8Array {
headerView.setUint32(8, ccobBuilder.byteLength, true);
return ccobBuilder.get();
function uint32Bytes (value: number): ArrayBufferView {
function uint32Bytes(value: number): ArrayBufferView {
const bytes = new ArrayBuffer(4);
const view = new DataView(bytes);
view.setUint32(0, value, true);
@@ -83,7 +83,7 @@ export function encodeCCONBinary (ccon: CCON): Uint8Array {
}
}
export function decodeCCONBinary (bytes: Uint8Array): CCON {
export function decodeCCONBinary(bytes: Uint8Array): CCON {
if (bytes.length < 16) {
throw new InvalidCCONError(getError(13102));
}
@@ -159,7 +159,7 @@ interface BufferConstructor {
from(buffer: ArrayBuffer, byteOffset?: number, byteLength?: number): Buffer;
}
function decodeJson (data: Uint8Array): string {
function decodeJson(data: Uint8Array): string {
if (typeof TextDecoder !== 'undefined') {
return new TextDecoder().decode(data);
} else if ('Buffer' in globalThis) {
@@ -177,13 +177,13 @@ export class BufferBuilder {
private _viewOrPaddings: (ArrayBufferView | number)[] = [];
private _length = 0;
constructor () {}
constructor() { }
get byteLength (): number {
get byteLength(): number {
return this._length;
}
public alignAs (align: number): number {
public alignAs(align: number): number {
if (align !== 0) {
const remainder = this._length % align;
if (remainder !== 0) {
@@ -196,14 +196,14 @@ export class BufferBuilder {
return 0;
}
public append (view: ArrayBufferView): number {
public append(view: ArrayBufferView): number {
const result = this._length;
this._viewOrPaddings.push(view);
this._length += view.byteLength;
return result;
}
public get (): Uint8Array {
public get(): Uint8Array {
const result = new Uint8Array(this._length);
let counter = 0;
this._viewOrPaddings.forEach((viewOrPadding) => {
@@ -219,4 +219,6 @@ export class BufferBuilder {
}
cclegacy.internal.decodeCCONBinary = decodeCCONBinary;
cclegacy.internal.encodeCCONBinary = encodeCCONBinary;
cclegacy.internal.CCON = CCON;
cclegacy.internal.BufferBuilder = BufferBuilder;
+126
View File
@@ -42,6 +42,24 @@ declare namespace spine {
delete();
}
/**
* @version 4.2
*/
class SPVectorPhysicsConstraintPtr {
size(): number;
get(index: number): PhysicsConstraint;
delete();
}
/**
* @version 4.2
*/
class SPVectorPhysicsConstraintDataPtr {
size(): number;
get(index: number): PhysicsConstraintData;
delete();
}
class Animation {
constructor(name: string, timelines: Array<Timeline>, duration: number);
duration: number;
@@ -708,6 +726,10 @@ declare namespace spine {
ikConstraints: Array<IkConstraint>;
transformConstraints: Array<TransformConstraint>;
pathConstraints: Array<PathConstraint>;
/**
* @version 4.2
*/
physicsConstraints: Array<PhysicsConstraint>;
_updateCache: Updatable[];
skin: Skin;
color: Color;
@@ -735,8 +757,24 @@ declare namespace spine {
findIkConstraint(constraintName: string): IkConstraint;
findTransformConstraint(constraintName: string): TransformConstraint;
findPathConstraint(constraintName: string): PathConstraint;
/**
* @version 4.2
*/
findPhysicsConstraint(constraintName: string): PhysicsConstraint;
/**
* @version 4.2
*/
getPhysicsConstraints(): SPVectorPhysicsConstraintPtr;
//getBounds(offset: Vector2, size: Vector2, temp?: Array<number>): void;
update(delta: number): void;
/**
* @version 4.2
*/
updateWorldTransform(physics: Physics): void;
/**
* @version 4.2
*/
updateWorldTransform(physics: Physics, parent: Bone): void;
}
class SkeletonBinary {
static AttachmentTypeValues: number[];
@@ -812,6 +850,10 @@ declare namespace spine {
ikConstraints: IkConstraintData[];
transformConstraints: TransformConstraintData[];
pathConstraints: PathConstraintData[];
/**
* @version 4.2
*/
physicsConstraints: PhysicsConstraintData[];
x: number;
y: number;
width: number;
@@ -835,6 +877,14 @@ declare namespace spine {
findTransformConstraint(constraintName: string): TransformConstraintData;
findPathConstraint(constraintName: string): PathConstraintData;
findPathConstraintIndex(pathConstraintName: string): number;
/**
* @version 4.2
*/
findPhysicsConstraint(constraintName: string): PhysicsConstraintData;
/**
* @version 4.2
*/
getPhysicsConstraints(): SPVectorPhysicsConstraintDataPtr;
}
class SkeletonJson {
attachmentLoader: AttachmentLoader;
@@ -1005,6 +1055,82 @@ declare namespace spine {
local: boolean;
constructor(name: string);
}
/**
* @version 4.2
*/
enum Physics {
none = 0,
reset = 1,
update = 2,
pose = 3
}
/**
* @version 4.2
*/
class PhysicsConstraint implements Updatable {
data: PhysicsConstraintData;
bone: Bone;
inertia: number;
strength: number;
damping: number;
massInverse: number;
wind: number;
gravity: number;
mix: number;
_reset: boolean;
ux: number;
uy: number;
cx: number;
cy: number;
tx: number;
ty: number;
xOffset: number;
xVelocity: number;
yOffset: number;
yVelocity: number;
rotateOffset: number;
rotateVelocity: number;
scaleOffset: number;
scaleVelocity: number;
remaining: number;
lastTime: number;
active: boolean;
constructor(data: PhysicsConstraintData, skeleton: Skeleton);
isActive(): boolean;
reset(): void;
setToSetupPose(): void;
update(): void;
translate(x: number, y: number): void;
rotate(x: number, y: number, degrees: number): void;
}
/**
* @version 4.2
*/
class PhysicsConstraintData extends ConstraintData {
bone: BoneData;
x: number;
y: number;
rotate: number;
scaleX: number;
shearX: number;
limit: number;
step: number;
inertia: number;
strength: number;
damping: number;
massInverse: number;
wind: number;
gravity: number;
mix: number;
inertiaGlobal: boolean;
strengthGlobal: boolean;
dampingGlobal: boolean;
massGlobal: boolean;
windGlobal: boolean;
gravityGlobal: boolean;
mixGlobal: boolean;
constructor(name: string);
}
class Triangulator {
private convexPolygons;
private convexPolygonsIndices;
+5
View File
@@ -38,6 +38,11 @@ module.exports = {
newCubeMap: 'CubeMap',
newRenderTexture: 'Render Texture',
newScene: 'Scene',
newScene:{
'2d': '2D Scene',
'3d': '3D Scene',
quality: 'High Quality Scene',
},
newPrefab: 'Node Prefab',
newMaterial: 'Material',
newPhysicsMaterial: 'Physics Material',
+5
View File
@@ -37,6 +37,11 @@ module.exports = {
newTypeScript: '脚本 (TypeScript)',
newCubeMap: '立方体贴图',
newScene: '场景',
newScene:{
'2d': '2D 场景',
'3d': '3D 场景',
quality: '高质量场景',
},
newPrefab: '预制 (Prefab)',
newRenderTexture: '渲染纹理 (Render Texture)',
newMaterial: '材质',
@@ -33,6 +33,7 @@ using SPVectorIkConstraintPtr = Vector<IkConstraint*>;
using SPVectorIkConstraintDataPtr = Vector<IkConstraintData*>;
using SPVectorTransformConstraintPtr = Vector<TransformConstraint*>;
using SPVectorPathConstraintPtr = Vector<PathConstraint*>;
using SPVectorPhysicsConstraintPtr = Vector<PhysicsConstraint*>;
using SPVectorTimelinePtr = Vector<Timeline*>;
using SPVectorTrackEntryPtr = Vector<TrackEntry*>;
using SPVectorUpdatablePtr = Vector<Updatable*>;
@@ -207,6 +208,8 @@ DEFINE_ALLOW_RAW_POINTER(TrackEntry)
DEFINE_ALLOW_RAW_POINTER(IkConstraintData)
DEFINE_ALLOW_RAW_POINTER(PathConstraintData)
DEFINE_ALLOW_RAW_POINTER(TransformConstraintData)
DEFINE_ALLOW_RAW_POINTER(PhysicsConstraintData)
DEFINE_ALLOW_RAW_POINTER(PhysicsConstraint)
DEFINE_ALLOW_RAW_POINTER(SPVectorUnsignedShort)
DEFINE_ALLOW_RAW_POINTER(SPVectorFloat)
DEFINE_ALLOW_RAW_POINTER(SPVectorEventPtr)
@@ -516,7 +519,7 @@ EMSCRIPTEN_BINDINGS(spine) {
REGISTER_SPINE_ENUM(TextureFilter);
REGISTER_SPINE_ENUM(TextureWrap);
REGISTER_SPINE_ENUM(AttachmentType);
REGISTER_SPINE_ENUM(Physics);
REGISTER_SPINE_VECTOR(SPVectorDebugShape, false);
@@ -544,7 +547,9 @@ EMSCRIPTEN_BINDINGS(spine) {
REGISTER_SPINE_VECTOR(SPVectorIkConstraintDataPtr, false);
REGISTER_SPINE_VECTOR(SPVectorTransformConstraintPtr, false);
REGISTER_SPINE_VECTOR(SPVectorPathConstraintPtr, false);
REGISTER_SPINE_VECTOR(SPVectorTimelinePtr, true); // .set used in Animation constructor
REGISTER_SPINE_VECTOR(SPVectorTimelinePtr, true); // .set used in Animation constructor
REGISTER_SPINE_VECTOR(SPVectorPhysicsConstraintDataPtr, false);
REGISTER_SPINE_VECTOR(SPVectorPhysicsConstraintPtr, false);
REGISTER_SPINE_VECTOR(SPVectorTrackEntryPtr, false);
REGISTER_SPINE_VECTOR(SPVectorUpdatablePtr, false);
REGISTER_SPINE_VECTOR(SPVectorSkinEntryPtr, false);
@@ -879,6 +884,64 @@ EMSCRIPTEN_BINDINGS(spine) {
.property("mixScaleY", &TransformConstraint::getMixScaleY)
.property("mixShearY", &TransformConstraint::getMixShearY);
class_<PhysicsConstraintData, base<ConstraintData>>("PhysicsConstraintData")
.constructor<const String &>()
.property("bone", &PhysicsConstraintData::getBone)
.property("x", &PhysicsConstraintData::getX, &PhysicsConstraintData::setX)
.property("y", &PhysicsConstraintData::getY, &PhysicsConstraintData::setY)
.property("rotate", &PhysicsConstraintData::getRotate, &PhysicsConstraintData::setRotate)
.property("scaleX", &PhysicsConstraintData::getScaleX, &PhysicsConstraintData::setScaleX)
.property("shearX", &PhysicsConstraintData::getShearX, &PhysicsConstraintData::setShearX)
.property("limit", &PhysicsConstraintData::getLimit, &PhysicsConstraintData::setLimit)
.property("step", &PhysicsConstraintData::getStep, &PhysicsConstraintData::setStep)
.property("inertia", &PhysicsConstraintData::getInertia, &PhysicsConstraintData::setInertia)
.property("strength", &PhysicsConstraintData::getStrength, &PhysicsConstraintData::setStrength)
.property("damping", &PhysicsConstraintData::getDamping, &PhysicsConstraintData::setDamping)
.property("massInverse", &PhysicsConstraintData::getMassInverse, &PhysicsConstraintData::setMassInverse)
.property("wind", &PhysicsConstraintData::getWind, &PhysicsConstraintData::setWind)
.property("gravity", &PhysicsConstraintData::getGravity, &PhysicsConstraintData::setGravity)
.property("mix", &PhysicsConstraintData::getMix, &PhysicsConstraintData::setMix)
.property("inertiaGlobal", &PhysicsConstraintData::isInertiaGlobal, &PhysicsConstraintData::setInertiaGlobal)
.property("strengthGlobal", &PhysicsConstraintData::isStrengthGlobal, &PhysicsConstraintData::setStrengthGlobal)
.property("dampingGlobal", &PhysicsConstraintData::isDampingGlobal, &PhysicsConstraintData::setDampingGlobal)
.property("massGlobal", &PhysicsConstraintData::isMassGlobal, &PhysicsConstraintData::setMassGlobal)
.property("windGlobal", &PhysicsConstraintData::isWindGlobal, &PhysicsConstraintData::setWindGlobal)
.property("gravityGlobal", &PhysicsConstraintData::isGravityGlobal, &PhysicsConstraintData::setGravityGlobal)
.property("mixGlobal", &PhysicsConstraintData::isMixGlobal, &PhysicsConstraintData::setMixGlobal);
class_<PhysicsConstraint, base<Updatable>>("PhysicsConstraint")
.constructor<PhysicsConstraintData &, Skeleton &>()
.property("data", GETTER_RVAL_TO_PTR(PhysicsConstraint, getData, PhysicsConstraintData*))
.property("bone", &PhysicsConstraint::getBone, &PhysicsConstraint::setBone)
.property("inertia", &PhysicsConstraint::getInertia, &PhysicsConstraint::setInertia)
.property("strength", &PhysicsConstraint::getStrength, &PhysicsConstraint::setStrength)
.property("damping", &PhysicsConstraint::getDamping, &PhysicsConstraint::setDamping)
.property("massInverse", &PhysicsConstraint::getMassInverse, &PhysicsConstraint::setMassInverse)
.property("wind", &PhysicsConstraint::getWind, &PhysicsConstraint::setWind)
.property("gravity", &PhysicsConstraint::getGravity, &PhysicsConstraint::setGravity)
.property("mix", &PhysicsConstraint::getMix, &PhysicsConstraint::setMix)
.property("_reset", &PhysicsConstraint::getReset, &PhysicsConstraint::setReset)
.property("ux", &PhysicsConstraint::getUx, &PhysicsConstraint::setUx)
.property("uy", &PhysicsConstraint::getUy, &PhysicsConstraint::setUy)
.property("cx", &PhysicsConstraint::getCx, &PhysicsConstraint::setCx)
.property("cy", &PhysicsConstraint::getCy, &PhysicsConstraint::setCy)
.property("tx", &PhysicsConstraint::getTx, &PhysicsConstraint::setTx)
.property("ty", &PhysicsConstraint::getTy, &PhysicsConstraint::setTy)
.property("xOffset", &PhysicsConstraint::getXOffset, &PhysicsConstraint::setXOffset)
.property("xVelocity", &PhysicsConstraint::getXVelocity, &PhysicsConstraint::setXVelocity)
.property("yOffset", &PhysicsConstraint::getYOffset, &PhysicsConstraint::setYOffset)
.property("yVelocity", &PhysicsConstraint::getYVelocity, &PhysicsConstraint::setYVelocity)
.property("rotateOffset", &PhysicsConstraint::getRotateOffset, &PhysicsConstraint::setRotateOffset)
.property("rotateVelocity", &PhysicsConstraint::getRotateVelocity, &PhysicsConstraint::setRotateVelocity)
.property("scaleOffset", &PhysicsConstraint::getScaleOffset, &PhysicsConstraint::setScaleOffset)
.property("scaleVelocity", &PhysicsConstraint::getScaleVelocity, &PhysicsConstraint::setScaleVelocity)
.property("remaining", &PhysicsConstraint::getRemaining, &PhysicsConstraint::setRemaining)
.property("lastTime", &PhysicsConstraint::getLastTime, &PhysicsConstraint::setLastTime)
.function("reset", &PhysicsConstraint::reset)
.function("setToSetupPose", &PhysicsConstraint::setToSetupPose)
.function("translate", &PhysicsConstraint::translate)
.function("rotate", &PhysicsConstraint::rotate);
class_<Bone, base<Updatable>>("Bone")
.constructor<BoneData &, Skeleton &, Bone *>()
.property("data", GETTER_RVAL_TO_PTR(Bone, getData, BoneData*))
@@ -1058,7 +1121,7 @@ EMSCRIPTEN_BINDINGS(spine) {
.function("findAnimation", &SkeletonData::findAnimation, allow_raw_pointers())
.function("findIkConstraint", &SkeletonData::findIkConstraint, allow_raw_pointers())
.function("findTransformConstraint", &SkeletonData::findTransformConstraint, allow_raw_pointers())
.function("findPhysicsConstraint", &SkeletonData::findPathConstraint, allow_raw_pointers())
.function("findPhysicsConstraint", &SkeletonData::findPhysicsConstraint, allow_raw_pointers())
.function("findPathConstraint", &SkeletonData::findPathConstraint, allow_raw_pointers());
class_<Animation>("Animation")
@@ -1295,6 +1358,8 @@ EMSCRIPTEN_BINDINGS(spine) {
return &obj.getTransformConstraints(); }), allow_raw_pointer<SPVectorTransformConstraintPtr>())
.function("getPathConstraints", optional_override([](Skeleton &obj){
return &obj.getPathConstraints(); }), allow_raw_pointer<SPVectorPathConstraintPtr>())
.function("getPhysicsConstraints", optional_override([](Skeleton &obj){
return &obj.getPhysicsConstraints(); }), allow_raw_pointer<SPVectorPhysicsConstraintPtr>())
.function("getUpdateCacheList", optional_override([](Skeleton &obj){
return &obj.getUpdateCacheList(); }), allow_raw_pointer<SPVectorUpdatablePtr>())
.property("skin", &Skeleton::_skin)
@@ -1322,6 +1387,7 @@ EMSCRIPTEN_BINDINGS(spine) {
.function("findIkConstraint", &Skeleton::findIkConstraint, allow_raw_pointers())
.function("findTransformConstraint", &Skeleton::findTransformConstraint, allow_raw_pointers())
.function("findPathConstraint", &Skeleton::findPathConstraint, allow_raw_pointers())
.function("findPhysicsConstraint", &Skeleton::findPhysicsConstraint, allow_raw_pointers())
//.function("getBounds", optional_override([](Skeleton &obj, &outX, ) {}), allow_raw_pointers())
.function("update", &Skeleton::update);
@@ -178,6 +178,11 @@ long FileUtilsOpenHarmony::getFileSize(const std::string &filepath) {
if (fullPath.empty()) {
return 0;
}
if(fullPath[0] == '/') {
return FileUtils::getFileSize(fullPath);
}
if (nullptr == _nativeResourceManager) {
CC_LOG_ERROR("nativeResourceManager is nullptr");
return 0;
@@ -201,11 +206,11 @@ bool FileUtilsOpenHarmony::isFileExistInternal(const std::string &strFilePath) c
return false;
}
if (strFilePath[0] != '/') {
if (strFilePath[0] != '/') {
const char *s = strFilePath.c_str();
// Found "@assets/" at the beginning of the path and we don't want it
if (strFilePath.find(ASSETS_FOLDER_NAME) == 0) s += strlen(ASSETS_FOLDER_NAME);
if (nullptr == _nativeResourceManager) {
CC_LOG_ERROR("nativeResourceManager is nullptr");
return false;
@@ -217,7 +222,7 @@ bool FileUtilsOpenHarmony::isFileExistInternal(const std::string &strFilePath) c
return true;
}
return false;
}
}
FILE *fp = fopen(strFilePath.c_str(), "r");
if (fp) {
fclose(fp);
+1 -1
View File
@@ -3,6 +3,6 @@
"type": "github",
"owner": "cocos",
"name": "cocos-engine-external",
"checkout": "v4.0.0-3"
"checkout": "v4.0.0-4"
}
}
+2 -62
View File
@@ -1,12 +1,12 @@
{
"name": "cocos-creator",
"version": "4.0.0-alpha.9",
"version": "4.0.0-alpha.17",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "cocos-creator",
"version": "4.0.0-alpha.9",
"version": "4.0.0-alpha.17",
"hasInstallScript": true,
"license": "MIT",
"dependencies": {
@@ -9532,14 +9532,6 @@
"integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==",
"dev": true
},
"node_modules/growly": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz",
"integrity": "sha512-+xGQY0YyAWCnqy7Cd++hc2JqMYzlm0dG30Jd0beaA64sROr8C4nt8Yc9V5Ro3avlSUDTN0ulqP/VBKi1/lLygw==",
"dev": true,
"optional": true,
"peer": true
},
"node_modules/gulp": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/gulp/-/gulp-4.0.2.tgz",
@@ -14590,39 +14582,6 @@
"integrity": "sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==",
"dev": true
},
"node_modules/node-notifier": {
"version": "8.0.2",
"resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-8.0.2.tgz",
"integrity": "sha512-oJP/9NAdd9+x2Q+rfphB2RJCHjod70RcRLjosiPMMu5gjIfwVnOUGq2nbTjTUbmy0DJ/tFIVT30+Qe3nzl4TJg==",
"dev": true,
"optional": true,
"peer": true,
"dependencies": {
"growly": "^1.3.0",
"is-wsl": "^2.2.0",
"semver": "^7.3.2",
"shellwords": "^0.1.1",
"uuid": "^8.3.0",
"which": "^2.0.2"
}
},
"node_modules/node-notifier/node_modules/semver": {
"version": "7.5.4",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz",
"integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==",
"dev": true,
"optional": true,
"peer": true,
"dependencies": {
"lru-cache": "^6.0.0"
},
"bin": {
"semver": "bin/semver.js"
},
"engines": {
"node": ">=10"
}
},
"node_modules/node-releases": {
"version": "2.0.13",
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.13.tgz",
@@ -16490,14 +16449,6 @@
"integrity": "sha512-Vpfqwm4EnqGdlsBFNmHhxhElJYrdfcxPThu+ryKS5J8L/fhAwLazFZtq+S+TWZ9ANj2piSQLGj6NQg+lKPmxrw==",
"dev": true
},
"node_modules/shellwords": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz",
"integrity": "sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==",
"dev": true,
"optional": true,
"peer": true
},
"node_modules/side-channel": {
"version": "1.0.4",
"resolved": "https://registry.npmmirror.com/side-channel/-/side-channel-1.0.4.tgz",
@@ -18165,17 +18116,6 @@
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
},
"node_modules/uuid": {
"version": "8.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
"dev": true,
"optional": true,
"peer": true,
"bin": {
"uuid": "dist/bin/uuid"
}
},
"node_modules/v8-to-istanbul": {
"version": "9.1.0",
"resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.1.0.tgz",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "cocos-creator",
"version": "4.0.0-alpha.9",
"version": "4.0.0-alpha.17",
"description": "Cocos Creator is a cross-platform 2D & 3D game engine written in C++ and TypeScript, licensed under MIT.",
"homepage": "http://www.cocos.com",
"license": "MIT",
+11 -1
View File
@@ -24,7 +24,7 @@
*/
import { ALIPAY, BYTEDANCE, HUAWEI, OPPO, RUNTIME_BASED, SUD, SUDV2, VIVO, MIGU, HONOR, WECHAT, XIAOMI, DEBUG, TEST, TAOBAO, TAOBAO_MINIGAME, WECHAT_MINI_PROGRAM } from 'internal:constants';
import { minigame, SystemInfo as MinigameSystemInfo } from 'pal/minigame';
import { minigame, SystemInfo as MinigameSystemInfo, WindowInfo } from 'pal/minigame';
import { IFeatureMap } from 'pal/system-info';
import { EventTarget } from '../../../cocos/core/event';
import { checkPalIntegrity, withImpl } from '../../integrity-check';
@@ -100,7 +100,10 @@ if (BYTEDANCE) {
}
const originalGetSystemInfoSync = minigame.getSystemInfoSync;
// Some platforms may not have this interface(getWindowInfo).
const originalGetWindowInfo = minigame.getWindowInfo;
let _cachedSystemInfo: MinigameSystemInfo = originalGetSystemInfoSync.call(minigame);
let _cachedWindowInfo: WindowInfo | undefined = originalGetWindowInfo?.call(minigame);
function testAndUpdateSystemInfoCache (testAmount: number, testInterval: number): void {
let successfullyTestTimes = 0;
@@ -127,12 +130,19 @@ if (WECHAT && versionCompare(minigame.getAppBaseInfo().SDKVersion, '2.25.3') < 0
minigame.onWindowResize?.(() => {
// update cached system info
_cachedSystemInfo = originalGetSystemInfoSync.call(minigame);
_cachedWindowInfo = originalGetWindowInfo?.call(minigame);
});
minigame.getSystemInfoSync = function (): MinigameSystemInfo {
return _cachedSystemInfo;
};
if (originalGetWindowInfo !== undefined) {
minigame.getWindowInfo = function (): WindowInfo {
return _cachedWindowInfo!;
};
}
class SystemInfo extends EventTarget {
public declare readonly networkType: NetworkType;
public declare readonly isNative: boolean;