@safe-engine/pixi 8.4.3 → 8.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/app.d.ts +2 -2
  2. package/dist/app.d.ts.map +1 -1
  3. package/dist/base/EnhancedComponent.d.ts +3 -2
  4. package/dist/base/EnhancedComponent.d.ts.map +1 -1
  5. package/dist/base/EnhancedComponent.js +1 -1
  6. package/dist/components/NodeComp.d.ts +1 -0
  7. package/dist/components/NodeComp.d.ts.map +1 -1
  8. package/dist/components/NodeComp.js +10 -0
  9. package/dist/core/loader.d.ts +2 -1
  10. package/dist/core/loader.d.ts.map +1 -1
  11. package/dist/core/loader.js +2 -3
  12. package/dist/gui/GUIComponent.d.ts +17 -15
  13. package/dist/gui/GUIComponent.d.ts.map +1 -1
  14. package/dist/gui/GUIComponent.js +2 -9
  15. package/dist/gui/GUISystem.d.ts.map +1 -1
  16. package/dist/gui/GUISystem.js +13 -10
  17. package/dist/index.d.ts +0 -1
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +0 -1
  20. package/dist/norender/Touch.d.ts +2 -20
  21. package/dist/norender/Touch.d.ts.map +1 -1
  22. package/dist/norender/Touch.js +1 -1
  23. package/dist/render/RenderComponent.d.ts +6 -10
  24. package/dist/render/RenderComponent.d.ts.map +1 -1
  25. package/dist/richtext/RichTextComp.d.ts +2 -1
  26. package/dist/richtext/RichTextComp.d.ts.map +1 -1
  27. package/dist/richtext/RichTextComp.js +1 -1
  28. package/dist/spine/SpineComponent.d.ts +5 -3
  29. package/dist/spine/SpineComponent.d.ts.map +1 -1
  30. package/dist/spine/SpineComponent.js +1 -1
  31. package/dist/spine/lib/Spine.d.ts +2 -2
  32. package/dist/spine/lib/Spine.d.ts.map +1 -1
  33. package/dist/spine/lib/Spine.js +19 -20
  34. package/package.json +5 -5
  35. package/src/app.ts +2 -2
  36. package/src/base/EnhancedComponent.ts +4 -3
  37. package/src/components/NodeComp.ts +8 -0
  38. package/src/core/loader.ts +7 -5
  39. package/src/gui/GUIComponent.ts +31 -35
  40. package/src/gui/GUISystem.ts +12 -9
  41. package/src/index.ts +0 -2
  42. package/src/norender/Touch.ts +3 -3
  43. package/src/render/RenderComponent.ts +17 -17
  44. package/src/richtext/RichTextComp.ts +10 -6
  45. package/src/spine/SpineComponent.ts +5 -5
  46. package/src/spine/lib/Spine.ts +313 -329
  47. package/dist/spine/lib/assets/atlasLoader.d.ts +0 -34
  48. package/dist/spine/lib/assets/atlasLoader.d.ts.map +0 -1
  49. package/dist/spine/lib/assets/atlasLoader.js +0 -122
  50. package/dist/spine/lib/assets/skeletonLoader.d.ts +0 -30
  51. package/dist/spine/lib/assets/skeletonLoader.d.ts.map +0 -1
  52. package/dist/spine/lib/assets/skeletonLoader.js +0 -70
  53. package/src/@types/safex.d.ts +0 -15
  54. package/src/spine/lib/assets/atlasLoader.ts +0 -158
  55. package/src/spine/lib/assets/skeletonLoader.ts +0 -81
@@ -1,34 +0,0 @@
1
- /** ****************************************************************************
2
- * Spine Runtimes License Agreement
3
- * Last updated July 28, 2023. Replaces all prior versions.
4
- *
5
- * Copyright (c) 2013-2023, Esoteric Software LLC
6
- *
7
- * Integration of the Spine Runtimes into software or otherwise creating
8
- * derivative works of the Spine Runtimes is permitted under the terms and
9
- * conditions of Section 2 of the Spine Editor License Agreement:
10
- * http://esotericsoftware.com/spine-editor-license
11
- *
12
- * Otherwise, it is permitted to integrate the Spine Runtimes into software or
13
- * otherwise create derivative works of the Spine Runtimes (collectively,
14
- * "Products"), provided that each user of the Products must obtain their own
15
- * Spine Editor license and redistribution of the Products in any form must
16
- * include this license and copyright notice.
17
- *
18
- * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
19
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
- * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
22
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
24
- * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
25
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
27
- * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
- *****************************************************************************/
29
- import { TextureSource } from 'pixi.js';
30
- export interface ISpineAtlasMetadata {
31
- imageMetadata?: any;
32
- images?: TextureSource | string | Record<string, TextureSource | string>;
33
- }
34
- //# sourceMappingURL=atlasLoader.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"atlasLoader.d.ts","sourceRoot":"","sources":["../../../../src/spine/lib/assets/atlasLoader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;+EA2B+E;AAE/E,OAAO,EAQN,aAAa,EACb,MAAM,SAAS,CAAC;AAiHjB,MAAM,WAAW,mBAAmB;IAEnC,aAAa,CAAC,EAAE,GAAG,CAAC;IAGpB,MAAM,CAAC,EAAE,aAAa,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAAC,CAAC;CACzE"}
@@ -1,122 +0,0 @@
1
- /** ****************************************************************************
2
- * Spine Runtimes License Agreement
3
- * Last updated July 28, 2023. Replaces all prior versions.
4
- *
5
- * Copyright (c) 2013-2023, Esoteric Software LLC
6
- *
7
- * Integration of the Spine Runtimes into software or otherwise creating
8
- * derivative works of the Spine Runtimes is permitted under the terms and
9
- * conditions of Section 2 of the Spine Editor License Agreement:
10
- * http://esotericsoftware.com/spine-editor-license
11
- *
12
- * Otherwise, it is permitted to integrate the Spine Runtimes into software or
13
- * otherwise create derivative works of the Spine Runtimes (collectively,
14
- * "Products"), provided that each user of the Products must obtain their own
15
- * Spine Editor license and redistribution of the Products in any form must
16
- * include this license and copyright notice.
17
- *
18
- * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
19
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
- * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
22
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
24
- * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
25
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
27
- * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
- *****************************************************************************/
29
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
30
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
31
- return new (P || (P = Promise))(function (resolve, reject) {
32
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
33
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
34
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
35
- step((generator = generator.apply(thisArg, _arguments || [])).next());
36
- });
37
- };
38
- import { checkExtension, DOMAdapter, extensions, ExtensionType, LoaderParserPriority, path, Resolver, TextureSource } from 'pixi.js';
39
- import { SpineTexture } from '../SpineTexture.js';
40
- import { TextureAtlas } from '@esotericsoftware/spine-core';
41
- const spineTextureAtlasLoader = {
42
- extension: ExtensionType.Asset,
43
- resolver: {
44
- test: (value) => checkExtension(value, ".atlas"),
45
- parse: (value) => {
46
- var _a, _b, _c;
47
- const split = value.split('.');
48
- return {
49
- resolution: parseFloat((_c = (_b = (_a = Resolver.RETINA_PREFIX) === null || _a === void 0 ? void 0 : _a.exec(value)) === null || _b === void 0 ? void 0 : _b[1]) !== null && _c !== void 0 ? _c : '1'),
50
- format: split[split.length - 2],
51
- src: value,
52
- };
53
- },
54
- },
55
- loader: {
56
- extension: {
57
- type: ExtensionType.LoadParser,
58
- priority: LoaderParserPriority.Normal,
59
- name: 'spineTextureAtlasLoader',
60
- },
61
- test(url) {
62
- return checkExtension(url, '.atlas');
63
- },
64
- load(url) {
65
- return __awaiter(this, void 0, void 0, function* () {
66
- const response = yield DOMAdapter.get().fetch(url);
67
- const txt = yield response.text();
68
- return txt;
69
- });
70
- },
71
- testParse(asset, options) {
72
- const isExtensionRight = checkExtension(options.src, '.atlas');
73
- const isString = typeof asset === 'string';
74
- return Promise.resolve(isExtensionRight && isString);
75
- },
76
- unload(atlas) {
77
- atlas.dispose();
78
- },
79
- parse(asset, options, loader) {
80
- return __awaiter(this, void 0, void 0, function* () {
81
- const metadata = options.data || {};
82
- let basePath = path.dirname(options.src);
83
- if (basePath && basePath.lastIndexOf('/') !== basePath.length - 1) {
84
- basePath += '/';
85
- }
86
- // Retval is going to be a texture atlas. However we need to wait for it's callback to resolve this promise.
87
- const retval = new TextureAtlas(asset);
88
- // If the user gave me only one texture, that one is assumed to be the "first" texture in the atlas
89
- if (metadata.images instanceof TextureSource || typeof metadata.images === 'string') {
90
- const pixiTexture = metadata.images;
91
- metadata.images = {};
92
- metadata.images[retval.pages[0].name] = pixiTexture;
93
- }
94
- // we will wait for all promises for the textures at the same time at the end.
95
- const textureLoadingPromises = [];
96
- // fill the pages
97
- for (const page of retval.pages) {
98
- const pageName = page.name;
99
- const providedPage = (metadata === null || metadata === void 0 ? void 0 : metadata.images) ? metadata.images[pageName] : undefined;
100
- if (providedPage instanceof TextureSource) {
101
- page.setTexture(SpineTexture.from(providedPage));
102
- }
103
- else {
104
- // eslint-disable-next-line max-len
105
- const url = providedPage !== null && providedPage !== void 0 ? providedPage : path.normalize([...basePath.split(path.sep), pageName].join(path.sep));
106
- const assetsToLoadIn = {
107
- src: url,
108
- data: Object.assign(Object.assign({}, metadata.imageMetadata), { alphaMode: page.pma ? 'premultiplied-alpha' : 'premultiply-alpha-on-upload' })
109
- };
110
- const pixiPromise = loader.load(assetsToLoadIn).then((texture) => {
111
- page.setTexture(SpineTexture.from(texture.source));
112
- });
113
- textureLoadingPromises.push(pixiPromise);
114
- }
115
- }
116
- yield Promise.all(textureLoadingPromises);
117
- return retval;
118
- });
119
- },
120
- },
121
- };
122
- extensions.add(spineTextureAtlasLoader);
@@ -1,30 +0,0 @@
1
- /** ****************************************************************************
2
- * Spine Runtimes License Agreement
3
- * Last updated July 28, 2023. Replaces all prior versions.
4
- *
5
- * Copyright (c) 2013-2023, Esoteric Software LLC
6
- *
7
- * Integration of the Spine Runtimes into software or otherwise creating
8
- * derivative works of the Spine Runtimes is permitted under the terms and
9
- * conditions of Section 2 of the Spine Editor License Agreement:
10
- * http://esotericsoftware.com/spine-editor-license
11
- *
12
- * Otherwise, it is permitted to integrate the Spine Runtimes into software or
13
- * otherwise create derivative works of the Spine Runtimes (collectively,
14
- * "Products"), provided that each user of the Products must obtain their own
15
- * Spine Editor license and redistribution of the Products in any form must
16
- * include this license and copyright notice.
17
- *
18
- * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
19
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
- * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
22
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
24
- * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
25
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
27
- * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
- *****************************************************************************/
29
- export {};
30
- //# sourceMappingURL=skeletonLoader.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"skeletonLoader.d.ts","sourceRoot":"","sources":["../../../../src/spine/lib/assets/skeletonLoader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;+EA2B+E"}
@@ -1,70 +0,0 @@
1
- /** ****************************************************************************
2
- * Spine Runtimes License Agreement
3
- * Last updated July 28, 2023. Replaces all prior versions.
4
- *
5
- * Copyright (c) 2013-2023, Esoteric Software LLC
6
- *
7
- * Integration of the Spine Runtimes into software or otherwise creating
8
- * derivative works of the Spine Runtimes is permitted under the terms and
9
- * conditions of Section 2 of the Spine Editor License Agreement:
10
- * http://esotericsoftware.com/spine-editor-license
11
- *
12
- * Otherwise, it is permitted to integrate the Spine Runtimes into software or
13
- * otherwise create derivative works of the Spine Runtimes (collectively,
14
- * "Products"), provided that each user of the Products must obtain their own
15
- * Spine Editor license and redistribution of the Products in any form must
16
- * include this license and copyright notice.
17
- *
18
- * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
19
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
- * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
22
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
24
- * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
25
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
27
- * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
- *****************************************************************************/
29
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
30
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
31
- return new (P || (P = Promise))(function (resolve, reject) {
32
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
33
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
34
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
35
- step((generator = generator.apply(thisArg, _arguments || [])).next());
36
- });
37
- };
38
- import { checkExtension, DOMAdapter, extensions, ExtensionType, LoaderParserPriority } from 'pixi.js';
39
- function isJson(resource) {
40
- return Object.prototype.hasOwnProperty.call(resource, 'bones');
41
- }
42
- function isBuffer(resource) {
43
- return resource instanceof Uint8Array;
44
- }
45
- const spineLoaderExtension = {
46
- extension: ExtensionType.Asset,
47
- loader: {
48
- extension: {
49
- type: ExtensionType.LoadParser,
50
- priority: LoaderParserPriority.Normal,
51
- name: 'spineSkeletonLoader',
52
- },
53
- test(url) {
54
- return checkExtension(url, '.skel');
55
- },
56
- load(url) {
57
- return __awaiter(this, void 0, void 0, function* () {
58
- const response = yield DOMAdapter.get().fetch(url);
59
- const buffer = new Uint8Array(yield response.arrayBuffer());
60
- return buffer;
61
- });
62
- },
63
- testParse(asset, options) {
64
- const isJsonSpineModel = checkExtension(options.src, '.json') && isJson(asset);
65
- const isBinarySpineModel = checkExtension(options.src, '.skel') && isBuffer(asset);
66
- return Promise.resolve(isJsonSpineModel || isBinarySpineModel);
67
- },
68
- },
69
- };
70
- extensions.add(spineLoaderExtension);
@@ -1,15 +0,0 @@
1
- import { NodeComp } from "..";
2
-
3
- interface BaseComponentProps {
4
- $ref?: object;
5
- $refNode?: NodeComp<any>
6
- $push?: object[];
7
- node?: Partial<NodeComp>;
8
- }
9
-
10
- interface NodeCompProps {
11
- nodeName?: string
12
- }
13
-
14
- interface LoadingBarProps {
15
- }
@@ -1,158 +0,0 @@
1
- /** ****************************************************************************
2
- * Spine Runtimes License Agreement
3
- * Last updated July 28, 2023. Replaces all prior versions.
4
- *
5
- * Copyright (c) 2013-2023, Esoteric Software LLC
6
- *
7
- * Integration of the Spine Runtimes into software or otherwise creating
8
- * derivative works of the Spine Runtimes is permitted under the terms and
9
- * conditions of Section 2 of the Spine Editor License Agreement:
10
- * http://esotericsoftware.com/spine-editor-license
11
- *
12
- * Otherwise, it is permitted to integrate the Spine Runtimes into software or
13
- * otherwise create derivative works of the Spine Runtimes (collectively,
14
- * "Products"), provided that each user of the Products must obtain their own
15
- * Spine Editor license and redistribution of the Products in any form must
16
- * include this license and copyright notice.
17
- *
18
- * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
19
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
- * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
22
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
24
- * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
25
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
27
- * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
- *****************************************************************************/
29
-
30
- import {
31
- checkExtension,
32
- DOMAdapter,
33
- extensions,
34
- ExtensionType,
35
- LoaderParserPriority,
36
- path,
37
- Resolver,
38
- TextureSource
39
- } from 'pixi.js';
40
- import { SpineTexture } from '../SpineTexture.js';
41
- import { TextureAtlas } from '@esotericsoftware/spine-core';
42
-
43
- import type { AssetExtension, Loader, ResolvedAsset, Texture, UnresolvedAsset } from 'pixi.js';
44
-
45
- type RawAtlas = string;
46
-
47
- const spineTextureAtlasLoader: AssetExtension<RawAtlas | TextureAtlas, ISpineAtlasMetadata> = {
48
- extension: ExtensionType.Asset,
49
-
50
- resolver: {
51
- test: (value: string): boolean => checkExtension(value, ".atlas"),
52
- parse: (value: string): UnresolvedAsset => {
53
- const split = value.split('.');
54
-
55
- return {
56
- resolution: parseFloat(Resolver.RETINA_PREFIX?.exec(value)?.[1] ?? '1'),
57
- format: split[split.length - 2],
58
- src: value,
59
- };
60
- },
61
- },
62
-
63
- loader: {
64
- extension: {
65
- type: ExtensionType.LoadParser,
66
- priority: LoaderParserPriority.Normal,
67
- name: 'spineTextureAtlasLoader',
68
- },
69
-
70
- test (url: string): boolean {
71
- return checkExtension(url, '.atlas');
72
- },
73
-
74
- async load (url: string): Promise<RawAtlas> {
75
- const response = await DOMAdapter.get().fetch(url);
76
-
77
- const txt = await response.text();
78
-
79
- return txt;
80
- },
81
-
82
- testParse (asset: unknown, options: ResolvedAsset): Promise<boolean> {
83
- const isExtensionRight = checkExtension(options.src as string, '.atlas');
84
- const isString = typeof asset === 'string';
85
-
86
- return Promise.resolve(isExtensionRight && isString);
87
- },
88
-
89
- unload (atlas: TextureAtlas) {
90
- atlas.dispose();
91
- },
92
-
93
- async parse (asset: RawAtlas, options: ResolvedAsset, loader: Loader): Promise<TextureAtlas> {
94
- const metadata: ISpineAtlasMetadata = options.data || {};
95
- let basePath = path.dirname(options.src as string);
96
-
97
- if (basePath && basePath.lastIndexOf('/') !== basePath.length - 1) {
98
- basePath += '/';
99
- }
100
-
101
- // Retval is going to be a texture atlas. However we need to wait for it's callback to resolve this promise.
102
- const retval = new TextureAtlas(asset);
103
-
104
- // If the user gave me only one texture, that one is assumed to be the "first" texture in the atlas
105
- if (metadata.images instanceof TextureSource || typeof metadata.images === 'string') {
106
- const pixiTexture = metadata.images;
107
-
108
- metadata.images = {} as Record<string, TextureSource | string>;
109
- metadata.images[retval.pages[0].name] = pixiTexture;
110
- }
111
-
112
- // we will wait for all promises for the textures at the same time at the end.
113
- const textureLoadingPromises: Promise<any>[] = [];
114
-
115
- // fill the pages
116
- for (const page of retval.pages) {
117
- const pageName = page.name;
118
- const providedPage = metadata?.images ? metadata.images[pageName] : undefined;
119
-
120
- if (providedPage instanceof TextureSource) {
121
- page.setTexture(SpineTexture.from(providedPage));
122
- }
123
- else {
124
- // eslint-disable-next-line max-len
125
- const url: string = providedPage ?? path.normalize([...basePath.split(path.sep), pageName].join(path.sep));
126
-
127
- const assetsToLoadIn = {
128
- src: url,
129
- data: {
130
- ...metadata.imageMetadata,
131
- alphaMode: page.pma ? 'premultiplied-alpha' : 'premultiply-alpha-on-upload'
132
- }
133
- };
134
-
135
- const pixiPromise = loader.load<Texture>(assetsToLoadIn).then((texture) => {
136
- page.setTexture(SpineTexture.from(texture.source));
137
- });
138
-
139
- textureLoadingPromises.push(pixiPromise);
140
- }
141
- }
142
-
143
- await Promise.all(textureLoadingPromises);
144
-
145
- return retval;
146
- },
147
- },
148
- } as AssetExtension<RawAtlas | TextureAtlas, ISpineAtlasMetadata>;
149
-
150
- extensions.add(spineTextureAtlasLoader);
151
-
152
- export interface ISpineAtlasMetadata {
153
- // If you are downloading an .atlas file, this metadata will go to the Texture loader
154
- imageMetadata?: any;
155
- // If you already have atlas pages loaded as pixi textures
156
- // and want to use that to create the atlas, you can pass them here
157
- images?: TextureSource | string | Record<string, TextureSource | string>;
158
- }
@@ -1,81 +0,0 @@
1
- /** ****************************************************************************
2
- * Spine Runtimes License Agreement
3
- * Last updated July 28, 2023. Replaces all prior versions.
4
- *
5
- * Copyright (c) 2013-2023, Esoteric Software LLC
6
- *
7
- * Integration of the Spine Runtimes into software or otherwise creating
8
- * derivative works of the Spine Runtimes is permitted under the terms and
9
- * conditions of Section 2 of the Spine Editor License Agreement:
10
- * http://esotericsoftware.com/spine-editor-license
11
- *
12
- * Otherwise, it is permitted to integrate the Spine Runtimes into software or
13
- * otherwise create derivative works of the Spine Runtimes (collectively,
14
- * "Products"), provided that each user of the Products must obtain their own
15
- * Spine Editor license and redistribution of the Products in any form must
16
- * include this license and copyright notice.
17
- *
18
- * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
19
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
- * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
22
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
24
- * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
25
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
27
- * SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
- *****************************************************************************/
29
-
30
- import {
31
- type AssetExtension,
32
- checkExtension,
33
- DOMAdapter,
34
- extensions,
35
- ExtensionType,
36
- LoaderParserPriority,
37
- ResolvedAsset
38
- } from 'pixi.js';
39
-
40
- type SkeletonJsonAsset = any;
41
- type SkeletonBinaryAsset = Uint8Array;
42
-
43
- function isJson (resource: any): resource is SkeletonJsonAsset {
44
- return Object.prototype.hasOwnProperty.call(resource, 'bones');
45
- }
46
-
47
- function isBuffer (resource: any): resource is SkeletonBinaryAsset {
48
- return resource instanceof Uint8Array;
49
- }
50
-
51
- const spineLoaderExtension: AssetExtension<SkeletonJsonAsset | SkeletonBinaryAsset> = {
52
- extension: ExtensionType.Asset,
53
-
54
- loader: {
55
- extension: {
56
- type: ExtensionType.LoadParser,
57
- priority: LoaderParserPriority.Normal,
58
- name: 'spineSkeletonLoader',
59
- },
60
-
61
- test (url) {
62
- return checkExtension(url, '.skel');
63
- },
64
-
65
- async load (url: string): Promise<SkeletonBinaryAsset> {
66
- const response = await DOMAdapter.get().fetch(url);
67
-
68
- const buffer = new Uint8Array(await response.arrayBuffer());
69
-
70
- return buffer;
71
- },
72
- testParse (asset: unknown, options: ResolvedAsset): Promise<boolean> {
73
- const isJsonSpineModel = checkExtension(options.src!, '.json') && isJson(asset);
74
- const isBinarySpineModel = checkExtension(options.src!, '.skel') && isBuffer(asset);
75
-
76
- return Promise.resolve(isJsonSpineModel || isBinarySpineModel);
77
- },
78
- },
79
- } as AssetExtension<SkeletonJsonAsset | SkeletonBinaryAsset>;
80
-
81
- extensions.add(spineLoaderExtension);