Added types for editor instance error.

This commit is contained in:
Davide Tantillo 2025-11-17 15:42:14 +01:00
parent a6519f3017
commit 5cb027c4eb

View File

@ -23,7 +23,7 @@ class SpineC3PluginInstance extends SDK.IWorldInstanceBase {
skins: string[] = []; skins: string[] = [];
animation?: string; animation?: string;
_inst!: SDK.IWorldInstance & { errors: Record<string, string> }; _inst!: SDK.IWorldInstance & { errors: SpineC3EditorError };
private assetLoader: AssetLoader; private assetLoader: AssetLoader;
private skeletonRenderer: SkeletonRendererCore; private skeletonRenderer: SkeletonRendererCore;
@ -45,7 +45,7 @@ class SpineC3PluginInstance extends SDK.IWorldInstanceBase {
private tempColors = new Float32Array(4096); private tempColors = new Float32Array(4096);
// errors // errors
private errors: Record<string, string> = {}; private errors: SpineC3EditorError = {};
constructor (sdkType: SDK.ITypeBase, inst: SDK.IWorldInstance) { constructor (sdkType: SDK.ITypeBase, inst: SDK.IWorldInstance) {
super(sdkType, inst); super(sdkType, inst);
@ -415,13 +415,14 @@ class SpineC3PluginInstance extends SDK.IWorldInstanceBase {
skeleton.updateWorldTransform(spine.Physics.update); skeleton.updateWorldTransform(spine.Physics.update);
} }
private setError (key: string, condition: boolean, message: string) { private setError (key: SpineC3EditorErrorType, condition: boolean, message: string) {
if (condition) { if (condition) {
this.errors[key] = message; this.errors[key] = message;
return; return;
} }
delete this.errors[key]; delete this.errors[key];
} }
private hasErrors () { private hasErrors () {
const { errors, skins, animation, spineBounds } = this; const { errors, skins, animation, spineBounds } = this;
@ -480,6 +481,9 @@ class SpineC3PluginInstance extends SDK.IWorldInstanceBase {
} }
}; };
type SpineC3EditorErrorType = "boundsAnimationSkinType" | "nonExistingAnimation" | "boundsNoDimension";
type SpineC3EditorError = Partial<Record<SpineC3EditorErrorType, string>>;
PLUGIN_CLASS.Instance = SpineC3PluginInstance; PLUGIN_CLASS.Instance = SpineC3PluginInstance;
export type { SpineC3PluginInstance as SDKEditorInstanceClass }; export type { SpineC3PluginInstance as SDKEditorInstanceClass };