From 8bcb87a4ae6f66c1b040d2c2a7fa54341fd56594 Mon Sep 17 00:00:00 2001 From: Vladyslav Pohorielov Date: Tue, 24 Oct 2023 18:04:25 +0300 Subject: [PATCH] fix: add getLoader method to SpineLoader, export atlas and spine loaders --- .../loader-base/src/SpineLoaderAbstract.ts | 20 +++++++++++++++---- packages/loader-base/src/atlasLoader.ts | 12 +++++++++-- packages/loader-uni/src/index.ts | 1 + 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/packages/loader-base/src/SpineLoaderAbstract.ts b/packages/loader-base/src/SpineLoaderAbstract.ts index de54a14d..68249c9b 100644 --- a/packages/loader-base/src/SpineLoaderAbstract.ts +++ b/packages/loader-base/src/SpineLoaderAbstract.ts @@ -3,8 +3,15 @@ import { AssetExtension, checkExtension, LoadAsset, Loader, LoaderParserPriority import { BaseTexture, extensions, ExtensionType, settings, Texture, utils } from '@pixi/core'; import { makeSpineTextureAtlasLoaderFunctionFromPixiLoaderObject } from './atlasLoader'; -type SPINEJSON = any; -type SPINEBINARY = ArrayBuffer; +/** + * @public + */ +export type SPINEJSON = any; + +/** + * @public + */ +export type SPINEBINARY = ArrayBuffer; function isJson(resource: unknown): resource is SPINEJSON { return resource.hasOwnProperty('bones'); @@ -27,10 +34,11 @@ export abstract class SpineLoaderAbstract { abstract parseData(parser: ISkeletonParser, atlas: TextureAtlas, dataToParse: any): ISpineResource; - public installLoader(): any { + public getLoader(): AssetExtension, ISpineMetadata> { // eslint-disable-next-line @typescript-eslint/no-this-alias const spineAdapter = this; - const spineLoaderExtension: AssetExtension, ISpineMetadata> = { + + return { extension: ExtensionType.Asset, loader: { @@ -141,6 +149,10 @@ export abstract class SpineLoaderAbstract { // }, }, } as AssetExtension, ISpineMetadata>; + } + + public installLoader(): any { + const spineLoaderExtension = this.getLoader(); extensions.add(spineLoaderExtension); diff --git a/packages/loader-base/src/atlasLoader.ts b/packages/loader-base/src/atlasLoader.ts index 454cc3c1..60146a29 100644 --- a/packages/loader-base/src/atlasLoader.ts +++ b/packages/loader-base/src/atlasLoader.ts @@ -3,9 +3,17 @@ import { type AssetExtension, LoaderParserPriority, LoadAsset, Loader, checkExte import { BaseTexture, extensions, ExtensionType, settings, Texture, utils } from '@pixi/core'; import type { ISpineMetadata } from './SpineLoaderAbstract'; -type RawAtlas = string; +/** + * Type of atlas file content. + * @public + */ +export type RawAtlas = string; -const spineTextureAtlasLoader: AssetExtension = { +/** + * This variable is used loader extension for atlas files loading. + * @public + */ +export const spineTextureAtlasLoader: AssetExtension = { extension: ExtensionType.Asset, // cache: { diff --git a/packages/loader-uni/src/index.ts b/packages/loader-uni/src/index.ts index 78d73e0e..e46f854e 100644 --- a/packages/loader-uni/src/index.ts +++ b/packages/loader-uni/src/index.ts @@ -3,6 +3,7 @@ /// import '@pixi-spine/loader-base'; // Side effect install atlas loader import { SpineLoader } from './SpineLoader'; +export { SpineLoader }; export * from './Spine'; export * from './versions';