Complete internal submodule smoke closure
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled

This commit is contained in:
mes123456
2026-09-07 12:58:28 +08:00
parent f87a72732c
commit b940b8bac8
30 changed files with 4176 additions and 17 deletions

View File

@@ -154,6 +154,12 @@ function validPropertyKeys(value: unknown, allowed: readonly string[]): value is
Object.keys(value).length > 0 && Object.keys(value).every((key) => allowed.includes(key));
}
function validPhysicsSettings(value: unknown, allowed: readonly string[]): value is Record<string, unknown> {
return validPropertyKeys(value, allowed) && Object.values(value).every((item) =>
item === null || typeof item === "boolean" || typeof item === "string" ||
(typeof item === "number" && Number.isFinite(item)));
}
function validOperatorJson(value: unknown, depth = 0): value is WebEngineOperatorProperty {
if (depth > 8 || value === null || typeof value === "string" || typeof value === "boolean") return true;
if (typeof value === "number") return Number.isFinite(value);
@@ -372,6 +378,45 @@ function assertFutureCapability(payload: Extract<WebEngineRequest["command"], {
if (!currentSnapshot?.scenes.some((scene) => scene.id === payload.dataId) || (payload.cameraObjectId !== null && (typeof payload.cameraObjectId !== "string" || !currentSnapshot?.nodes.some((node) => node.id === payload.cameraObjectId && node.type === "CAMERA")))) throw report("RENDER_PROPERTY_INVALID", "setCameraView target is invalid");
return;
}
if (payload.type === "setRigidBodySettings") {
if (!currentSnapshot?.nodes.some((node) => node.id === payload.objectId) ||
!["RIGID_BODY", "SOFT_BODY"].includes(payload.family ?? "RIGID_BODY") ||
!validPhysicsSettings(payload.settings, ["type", "mass", "friction", "restitution", "collisionShape", "kinematic", "enabled", "linearDamping", "angularDamping", "stepsPerSecond", "solverIterations", "nodeMass", "gravity", "mediaFriction", "physicsSpeed", "goalSpring", "goalFriction", "solverFlags"])) {
throw report("PHYSICS_MANIFEST_INVALID", "setRigidBodySettings target, family or settings are invalid");
}
return;
}
if (payload.type === "setClothSettings") {
if (!currentSnapshot?.nodes.some((node) => node.id === payload.objectId) ||
!validPhysicsSettings(payload.settings, ["mass", "airDamping", "tensionStiffness", "compressionStiffness", "shearStiffness", "bendingStiffness", "springDamping", "pinStiffness", "quality", "usePin"])) {
throw report("PHYSICS_MANIFEST_INVALID", "setClothSettings target or settings are invalid");
}
return;
}
if (payload.type === "setFluidSettings") {
if (!currentSnapshot?.nodes.some((node) => node.id === payload.objectId) ||
!validPhysicsSettings(payload.settings, ["fluidType", "domainType", "resolution", "timeScale", "viscosity", "gravity", "cacheFrameStart", "cacheFrameEnd", "cacheType"])) {
throw report("PHYSICS_MANIFEST_INVALID", "setFluidSettings target or settings are invalid");
}
return;
}
if (payload.type === "setParticleCache") {
if (!currentSnapshot?.nodes.some((node) => node.id === payload.objectId) ||
!validPhysicsSettings(payload.settings, ["frameStart", "frameEnd", "cacheType", "compression", "useDiskCache", "pointCacheId"])) {
throw report("PHYSICS_MANIFEST_INVALID", "setParticleCache target or settings are invalid");
}
return;
}
if (payload.type === "setSimulationPlayback") {
if (!validPhysicsSettings(payload.settings, ["frame", "playing", "direction", "reset"]) ||
(payload.settings.frame !== undefined && (typeof payload.settings.frame !== "number" || !Number.isSafeInteger(payload.settings.frame) || payload.settings.frame < -1_000_000 || payload.settings.frame > 1_000_000)) ||
(payload.settings.playing !== undefined && typeof payload.settings.playing !== "boolean") ||
(payload.settings.reset !== undefined && typeof payload.settings.reset !== "boolean") ||
(payload.settings.direction !== undefined && payload.settings.direction !== -1 && payload.settings.direction !== 1)) {
throw report("PHYSICS_MANIFEST_INVALID", "setSimulationPlayback settings are invalid");
}
return;
}
if (payload.type === "setLightLinking") {
if (typeof payload.dataId !== "string" || payload.dataId.length === 0 || (payload.target !== undefined && payload.target !== "OBJECT" && payload.target !== "WORLD") || (payload.lightgroup !== null && (typeof payload.lightgroup !== "string" || payload.lightgroup.length === 0 || new TextEncoder().encode(payload.lightgroup).byteLength > 63))) throw report("RENDER_PROPERTY_INVALID", "setLightLinking target is invalid");
return;