Skip to content

Commit

Permalink
all 4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
miltoncandelero committed Jan 16, 2023
1 parent e6582dd commit dcdf52e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
6 changes: 2 additions & 4 deletions bundles/all-4.1/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { SpineParser } from '@pixi-spine/loader-4.1';
export { SpineParser };
import '@pixi-spine/loader-4.1'; // Side effect install the loader
// eslint-disable-next-line @typescript-eslint/no-duplicate-imports
export * from '@pixi-spine/runtime-4.1';
export * from '@pixi-spine/base';

SpineParser.registerLoaderPlugin();
27 changes: 14 additions & 13 deletions packages/loader-4.1/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
/* eslint-disable spaced-comment */
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="../global.d.ts" />
import { AbstractSpineParser } from '@pixi-spine/loader-base';

import '@pixi-spine/loader-base'; // Side effect install atlas loader
// eslint-disable-next-line @typescript-eslint/no-duplicate-imports
import { ISpineResource, SpineLoaderAbstract } from '@pixi-spine/loader-base';
import type { ISkeletonParser, TextureAtlas } from '@pixi-spine/base';
import { LoaderResource, Loader } from '@pixi/loaders';
import { AtlasAttachmentLoader, SkeletonBinary, SkeletonJson } from '@pixi-spine/runtime-4.1';
import { AtlasAttachmentLoader, SkeletonBinary, SkeletonData, SkeletonJson } from '@pixi-spine/runtime-4.1';

/**
* @public
* @internal
*/
export class SpineParser extends AbstractSpineParser {
class SpineParser extends SpineLoaderAbstract<SkeletonData> {
createBinaryParser(): ISkeletonParser {
return new SkeletonBinary(null);
}
Expand All @@ -18,17 +20,16 @@ export class SpineParser extends AbstractSpineParser {
return new SkeletonJson(null);
}

parseData(resource: LoaderResource, parser: ISkeletonParser, atlas: TextureAtlas, dataToParse: any): void {
parseData(parser: ISkeletonParser, atlas: TextureAtlas, dataToParse: any): ISpineResource<SkeletonData> {
const parserCast = parser as SkeletonBinary | SkeletonJson;

parserCast.attachmentLoader = new AtlasAttachmentLoader(atlas);
resource.spineData = parserCast.readSkeletonData(dataToParse);
resource.spineAtlas = atlas;
}

static use = new SpineParser().genMiddleware().use;

static registerLoaderPlugin() {
Loader.registerPlugin(SpineParser);
return {
spineData: parserCast.readSkeletonData(dataToParse),
spineAtlas: atlas,
};
}
}

new SpineParser().installLoader();
1 change: 0 additions & 1 deletion packages/loader-uni/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
/// <reference path="../global.d.ts" />
import '@pixi-spine/loader-base'; // Side effect install atlas loader
import { SpineLoader } from './SpineLoader';
export * from './SpineLoader';
export * from './Spine';
export * from './versions';

Expand Down

0 comments on commit dcdf52e

Please sign in to comment.